diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..78c2558 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,14 @@ +.git +.gitignore +data +browser_data +frontend/node_modules +frontend/dist +internal/webui/static +server +xianyu-server +init-admin +*.db +*.sqlite +*.sqlite3 +cover.out diff --git a/.gitignore b/.gitignore index 0c351f1..59ee91f 100644 --- a/.gitignore +++ b/.gitignore @@ -24,9 +24,15 @@ /frontend/node_modules/ /frontend/.env.local /frontend/.env.*.local +/internal/server/data/ -# Frontend build artifacts (hash 化文件名,每次构建变化,不入库;index.html 与稳定 SVG 仍跟踪) +# Embedded frontend build assets (index.html references hashed files, so JS/CSS must be tracked) /internal/webui/static/assets/ +!/internal/webui/static/assets/ +!/internal/webui/static/assets/*.css +!/internal/webui/static/assets/*.js +!/internal/webui/static/assets/*.svg +/internal/webui/static/assets/*.map # OS / editor .DS_Store diff --git a/Dockerfile.debian13 b/Dockerfile.debian13 new file mode 100644 index 0000000..5d018b1 --- /dev/null +++ b/Dockerfile.debian13 @@ -0,0 +1,49 @@ +# syntax=docker/dockerfile:1.7 + +FROM node:22-trixie AS frontend +WORKDIR /src/frontend +COPY frontend/package*.json ./ +RUN npm ci +COPY frontend/ ./ +RUN npm run build + +FROM node:22-trixie AS playwright-driver +RUN npm install -g playwright@1.57.0 \ + && mkdir -p /ms-playwright-go/package \ + && cp -a /usr/local/lib/node_modules/playwright/. /ms-playwright-go/package/ \ + && if [ -d /usr/local/lib/node_modules/playwright-core ]; then \ + mkdir -p /ms-playwright-go/package/node_modules \ + && cp -a /usr/local/lib/node_modules/playwright-core /ms-playwright-go/package/node_modules/playwright-core; \ + fi + +FROM golang:1.26-trixie AS backend +WORKDIR /src +COPY go.mod go.sum ./ +RUN go mod download +COPY . . +COPY --from=frontend /src/internal/webui/static ./internal/webui/static +RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/xianyu-server ./cmd/server + +FROM debian:13-slim AS runtime +ENV TZ=Asia/Shanghai +ENV BROWSER_HEADLESS=true +ENV PLAYWRIGHT_DRIVER_PATH=/ms-playwright-go +ENV PLAYWRIGHT_NODEJS_PATH=/usr/bin/node +ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 +ENV PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium +WORKDIR /app +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + ca-certificates \ + chromium \ + curl \ + fonts-liberation \ + fonts-noto-cjk \ + nodejs \ + tzdata \ + && rm -rf /var/lib/apt/lists/* +COPY --from=backend /out/xianyu-server /app/xianyu-server +COPY --from=playwright-driver /ms-playwright-go /ms-playwright-go +RUN mkdir -p /app/data /app/browser_data +EXPOSE 8080 +CMD ["/app/xianyu-server", "-addr", ":8080"] diff --git a/cmd/dbverify/main.go b/cmd/dbverify/main.go index fac8c5f..b684b8f 100644 --- a/cmd/dbverify/main.go +++ b/cmd/dbverify/main.go @@ -13,6 +13,8 @@ package main import ( "context" + "crypto/rand" + "encoding/hex" "fmt" "os" "strings" @@ -22,6 +24,17 @@ import ( ) func main() { + var cleanup func() error + fail := func(format string, args ...any) { + if cleanup != nil { + if err := cleanup(); err != nil { + fmt.Printf("⚠️ 清理验证数据失败: %v\n", err) + } + } + fmt.Printf(format, args...) + os.Exit(1) + } + if len(os.Args) < 2 { fmt.Println("用法: dbverify ") os.Exit(1) @@ -33,8 +46,7 @@ func main() { fmt.Printf("连接 %s ...\n", maskURL(url)) database, dialect, err := db.Open(ctx, url) if err != nil { - fmt.Printf("❌ Open 失败: %v\n", err) - os.Exit(1) + fail("❌ Open 失败: %v\n", err) } defer database.Close() fmt.Printf("✅ 迁移成功,方言=%s\n", dialect) @@ -42,72 +54,79 @@ func main() { store := db.NewStore(database, dialect) // 1) 创建用户(用唯一用户名,避免在已有数据的库上因 admin 重名而失败)。 - username := fmt.Sprintf("verify_%d", time.Now().UnixNano()) - ok, err := store.Users.Create(ctx, username, username+"@test.local", "pw123456") + ids := newVerifyIDs(time.Now().UnixNano()) + username := ids.username + accountID := ids.accountID + orderID := ids.orderID + itemID := ids.itemID + buyerID := ids.buyerID + cleanup = func() error { + cleanupCtx, cleanupCancel := context.WithTimeout(context.Background(), 15*time.Second) + defer cleanupCancel() + return cleanupVerifyData(cleanupCtx, store, ids) + } + password, err := newVerifyPassword() + if err != nil { + fail("❌ 生成验证密码失败: %v\n", err) + } + ok, err := store.Users.Create(ctx, username, username+"@test.local", password) if err != nil || !ok { - fmt.Printf("❌ 创建用户失败: err=%v ok=%v\n", err, ok) - os.Exit(1) + fail("❌ 创建用户失败: err=%v ok=%v\n", err, ok) } - if err := store.Users.SetAdmin(ctx, username); err != nil { - fmt.Printf("❌ 设置管理员失败: %v\n", err) - os.Exit(1) + adminUser, err := store.Users.GetByUsername(ctx, username) + if err != nil { + fail("❌ 查询验证用户失败: %v\n", err) } - adminUser, _ := store.Users.GetByUsername(ctx, username) userID := adminUser.ID - fmt.Printf("✅ 创建用户 %s (id=%d)\n", username, userID) + fmt.Printf("✅ 创建验证用户 %s (id=%d)\n", username, userID) // 2) 保存 cookie(dialectUpsert: ON CONFLICT/ON DUPLICATE KEY) - if err := store.Cookies.Save(ctx, "acc1", "unb=123; _m_h5_tk=tk_1;", userID); err != nil { - fmt.Printf("❌ 保存 cookie 失败: %v\n", err) - os.Exit(1) + if err := store.Cookies.Save(ctx, accountID, "unb=123; _m_h5_tk=tk_1;", userID); err != nil { + fail("❌ 保存 cookie 失败: %v\n", err) + } + if err := store.Cookies.SetStatus(ctx, accountID, false); err != nil { + fail("❌ 禁用验证账号失败: %v\n", err) } // 再 Save 一次验证 upsert - if err := store.Cookies.Save(ctx, "acc1", "unb=123; _m_h5_tk=tk_2;", userID); err != nil { - fmt.Printf("❌ 二次保存 cookie 失败: %v\n", err) - os.Exit(1) + if err := store.Cookies.Save(ctx, accountID, "unb=123; _m_h5_tk=tk_2;", userID); err != nil { + fail("❌ 二次保存 cookie 失败: %v\n", err) } - v, _ := store.Cookies.GetValue(ctx, "acc1") + v, _ := store.Cookies.GetValue(ctx, accountID) fmt.Printf("✅ cookie upsert 成功,value=%s\n", v) // 3) 系统设置 upsert(dialectUpsert + key 保留字引用) if err := store.Settings.Set(ctx, "theme_color", "blue"); err != nil { - fmt.Printf("❌ 系统设置 Set 失败: %v\n", err) - os.Exit(1) + fail("❌ 系统设置 Set 失败: %v\n", err) } if err := store.Settings.Set(ctx, "theme_color", "green"); err != nil { - fmt.Printf("❌ 系统设置二次 Set 失败: %v\n", err) - os.Exit(1) + fail("❌ 系统设置二次 Set 失败: %v\n", err) } fmt.Println("✅ 系统设置 upsert 成功(key 保留字处理 OK)") // 4) 订单 upsert(INSERT IGNORE + 动态 UPDATE) - if err := store.Orders.Upsert(ctx, "order-1", db.OrderUpsertOpts{ - ItemID: "item-1", BuyerID: "buyer-1", CookieID: "acc1", OrderStatus: "paid", Amount: "19.90", + if err := store.Orders.Upsert(ctx, orderID, db.OrderUpsertOpts{ + ItemID: itemID, BuyerID: buyerID, CookieID: accountID, OrderStatus: "paid", Amount: "19.90", }); err != nil { - fmt.Printf("❌ 订单 Upsert 失败: %v\n", err) - os.Exit(1) + fail("❌ 订单 Upsert 失败: %v\n", err) } // 二次 upsert 验证不重复插入 - if err := store.Orders.Upsert(ctx, "order-1", db.OrderUpsertOpts{ + if err := store.Orders.Upsert(ctx, orderID, db.OrderUpsertOpts{ OrderStatus: "shipped", ChatID: "chat-1", }); err != nil { - fmt.Printf("❌ 订单二次 Upsert 失败: %v\n", err) - os.Exit(1) + fail("❌ 订单二次 Upsert 失败: %v\n", err) } fmt.Println("✅ 订单 upsert 成功(INSERT IGNORE + UPDATE OK)") // 5) 商品信息 upsert(dialectUpsert,UNIQUE(cookie_id, item_id)) if err := store.Items.Upsert(ctx, &db.ItemInfoRow{ - CookieID: "acc1", ItemID: "item-1", ItemTitle: "测试商品", ItemPrice: "19.90", + CookieID: accountID, ItemID: itemID, ItemTitle: "测试商品", ItemPrice: "19.90", }); err != nil { - fmt.Printf("❌ 商品 Upsert 失败: %v\n", err) - os.Exit(1) + fail("❌ 商品 Upsert 失败: %v\n", err) } if err := store.Items.Upsert(ctx, &db.ItemInfoRow{ - CookieID: "acc1", ItemID: "item-1", ItemTitle: "更新后商品", ItemPrice: "29.90", + CookieID: accountID, ItemID: itemID, ItemTitle: "更新后商品", ItemPrice: "29.90", }); err != nil { - fmt.Printf("❌ 商品二次 Upsert 失败: %v\n", err) - os.Exit(1) + fail("❌ 商品二次 Upsert 失败: %v\n", err) } fmt.Println("✅ 商品信息 upsert 成功") @@ -116,63 +135,61 @@ func main() { Name: "测试卡组", Type: "data", DataContent: "card-1\ncard-2\ncard-3", Enabled: true, UserID: userID, }) if err != nil { - fmt.Printf("❌ 创建卡密失败: %v\n", err) - os.Exit(1) + fail("❌ 创建卡密失败: %v\n", err) } fmt.Printf("✅ 创建卡密组 (id=%d)\n", cardID) // 7) 卡密批量追加(AppendBatchData) added, err := store.Cards.AppendBatchData(ctx, cardID, "card-4\ncard-5") if err != nil { - fmt.Printf("❌ 追加卡密失败: %v\n", err) - os.Exit(1) + fail("❌ 追加卡密失败: %v\n", err) } fmt.Printf("✅ 追加卡密 %d 个\n", added) // 8) 通知渠道 + 绑定(dialectUpsert) chID, err := store.Notifications.CreateChannel(ctx, &db.NotificationChannelRow{ - Name: "测试渠道", Type: "webhook", Config: `{"webhook_url":"http://x"}`, Enabled: true, UserID: userID, + Name: "测试渠道", Type: "webhook", Config: `{"webhook_url":"http://x"}`, Enabled: false, UserID: userID, }) if err != nil { - fmt.Printf("❌ 创建通知渠道失败: %v\n", err) - os.Exit(1) + fail("❌ 创建通知渠道失败: %v\n", err) } - if err := store.Notifications.SetBindings(ctx, "acc1", []int64{chID}); err != nil { - fmt.Printf("❌ 绑定通知渠道失败: %v\n", err) - os.Exit(1) + if err := store.Notifications.SetBindings(ctx, accountID, []int64{chID}); err != nil { + fail("❌ 绑定通知渠道失败: %v\n", err) } fmt.Printf("✅ 通知渠道 + 绑定 OK (channel=%d)\n", chID) // 9) 自动化规则(TryStartRun 用 INSERT IGNORE + UNIQUE 防重) ruleID, err := store.Automation.Create(ctx, db.AutomationRuleInput{ - UserID: userID, CookieID: "acc1", ItemID: "item-1", Name: "付款发货", - TriggerType: "order_paid", Enabled: true, Priority: 100, + UserID: userID, CookieID: accountID, ItemID: itemID, Name: "付款发货", + TriggerType: "order_paid", Enabled: false, Priority: 100, }) if err != nil { - fmt.Printf("❌ 创建自动化规则失败: %v\n", err) - os.Exit(1) + fail("❌ 创建自动化规则失败: %v\n", err) } runID, started, err := store.Automation.TryStartRun(ctx, db.AutomationRun{ - RuleID: ruleID, CookieID: "acc1", TriggerType: "order_paid", TriggerKey: "order-1", Status: "running", + RuleID: ruleID, CookieID: accountID, TriggerType: "order_paid", TriggerKey: orderID, Status: "running", }) if err != nil || !started { - fmt.Printf("❌ TryStartRun 失败: err=%v started=%v\n", err, started) - os.Exit(1) + fail("❌ TryStartRun 失败: err=%v started=%v\n", err, started) } // 重复触发应 started=false _, started2, err := store.Automation.TryStartRun(ctx, db.AutomationRun{ - RuleID: ruleID, CookieID: "acc1", TriggerType: "order_paid", TriggerKey: "order-1", Status: "running", + RuleID: ruleID, CookieID: accountID, TriggerType: "order_paid", TriggerKey: orderID, Status: "running", }) if err != nil { - fmt.Printf("❌ TryStartRun 二次调用失败: %v\n", err) - os.Exit(1) + fail("❌ TryStartRun 二次调用失败: %v\n", err) } if started2 { - fmt.Printf("❌ TryStartRun 重复触发未防重\n") - os.Exit(1) + fail("❌ TryStartRun 重复触发未防重\n") } fmt.Printf("✅ 自动化规则 + 防重 OK (rule=%d run=%d)\n", ruleID, runID) + if err := cleanup(); err != nil { + fmt.Printf("❌ 清理验证数据失败: %v\n", err) + os.Exit(1) + } + cleanup = nil + fmt.Println("✅ 验证数据已清理") fmt.Println("\n🎉 全部验证通过") } @@ -189,3 +206,60 @@ func maskURL(url string) string { } return url } + +type verifyIDs struct { + username string + accountID string + orderID string + itemID string + buyerID string +} + +func newVerifyIDs(n int64) verifyIDs { + suffix := fmt.Sprintf("%d", n) + return verifyIDs{ + username: "verify_" + suffix, + accountID: "acc_" + suffix, + orderID: "order_" + suffix, + itemID: "item_" + suffix, + buyerID: "buyer_" + suffix, + } +} + +func newVerifyPassword() (string, error) { + var b [24]byte + if _, err := rand.Read(b[:]); err != nil { + return "", err + } + return "verify_" + hex.EncodeToString(b[:]), nil +} + +func cleanupVerifyData(ctx context.Context, store *db.Store, ids verifyIDs) error { + userID := int64(0) + if user, err := store.Users.GetByUsername(ctx, ids.username); err == nil { + userID = user.ID + } + queries := []struct { + query string + args []any + }{ + {`DELETE FROM automation_runs WHERE trigger_key=? OR cookie_id=?`, []any{ids.orderID, ids.accountID}}, + {`DELETE FROM automation_rule_actions WHERE rule_id IN (SELECT id FROM automation_rules WHERE cookie_id=? OR user_id=?)`, []any{ids.accountID, userID}}, + {`DELETE FROM automation_rules WHERE cookie_id=? OR user_id=?`, []any{ids.accountID, userID}}, + {`DELETE FROM message_notifications WHERE cookie_id=? OR channel_id IN (SELECT id FROM notification_channels WHERE user_id=? AND name=?)`, []any{ids.accountID, userID, "测试渠道"}}, + {`DELETE FROM notification_channels WHERE user_id=? AND name=?`, []any{userID, "测试渠道"}}, + {`DELETE FROM cards WHERE user_id=? AND name=?`, []any{userID, "测试卡组"}}, + {`DELETE FROM item_info WHERE cookie_id=? AND item_id=?`, []any{ids.accountID, ids.itemID}}, + {`DELETE FROM orders WHERE order_id=? OR cookie_id=?`, []any{ids.orderID, ids.accountID}}, + {`DELETE FROM cookie_status WHERE cookie_id=?`, []any{ids.accountID}}, + {`DELETE FROM cookies WHERE id=?`, []any{ids.accountID}}, + {`DELETE FROM sessions WHERE user_id=?`, []any{userID}}, + {`DELETE FROM users WHERE username=? AND email=?`, []any{ids.username, ids.username + "@test.local"}}, + } + for _, q := range queries { + if _, err := store.DB.ExecContext(ctx, q.query, q.args...); err != nil { + return err + } + } + return nil +} diff --git a/cmd/dbverify/main_test.go b/cmd/dbverify/main_test.go index 90fdc4d..c6403f4 100644 --- a/cmd/dbverify/main_test.go +++ b/cmd/dbverify/main_test.go @@ -1,15 +1,22 @@ package main -import "testing" +import ( + "context" + "errors" + "path/filepath" + "testing" + + "xianyu-go/internal/db" +) // TestMaskURL 验证带凭证的数据库 URL 脱敏:保留 scheme + host,密码替换为 ***。 func TestMaskURL(t *testing.T) { cases := map[string]string{ - "mysql://user:secret@tcp(host:3306)/db?x=1": "mysql://***@tcp(host:3306)/db?x=1", - "postgres://user:pass@host:5432/db": "postgres://***@host:5432/db", - "postgresql://u:p@h:5432/d": "postgresql://***@h:5432/d", - "sqlite://data/x.db": "sqlite://data/x.db", // 无密码,原样 - "/local/path.db": "/local/path.db", // 非 URL,原样 + "mysql://user:secret@tcp(host:3306)/db?x=1": "mysql://***@tcp(host:3306)/db?x=1", + "postgres://user:pass@host:5432/db": "postgres://***@host:5432/db", + "postgresql://u:p@h:5432/d": "postgresql://***@h:5432/d", + "sqlite://data/x.db": "sqlite://data/x.db", // 无密码,原样 + "/local/path.db": "/local/path.db", // 非 URL,原样 } for in, want := range cases { if got := maskURL(in); got != want { @@ -17,3 +24,154 @@ func TestMaskURL(t *testing.T) { } } } + +func TestNewVerifyIDsAreUniqueForPersistentRuns(t *testing.T) { + ids := newVerifyIDs(12345) + want := map[string]string{ + "username": "verify_12345", + "accountID": "acc_12345", + "orderID": "order_12345", + "itemID": "item_12345", + "buyerID": "buyer_12345", + } + got := map[string]string{ + "username": ids.username, + "accountID": ids.accountID, + "orderID": ids.orderID, + "itemID": ids.itemID, + "buyerID": ids.buyerID, + } + for key, wantValue := range want { + if got[key] != wantValue { + t.Fatalf("%s=%q want %q", key, got[key], wantValue) + } + } + if ids.username == ids.accountID || ids.accountID == ids.orderID || ids.orderID == ids.itemID { + t.Fatalf("验证用 ID 不应互相复用: %+v", ids) + } +} + +func TestNewVerifyPasswordIsNotFixedDefault(t *testing.T) { + first, err := newVerifyPassword() + if err != nil { + t.Fatalf("newVerifyPassword: %v", err) + } + second, err := newVerifyPassword() + if err != nil { + t.Fatalf("newVerifyPassword second: %v", err) + } + if first == "pw123456" || second == "pw123456" { + t.Fatal("验证用户不应使用固定弱密码") + } + if first == second { + t.Fatalf("验证密码应随机生成,got %q", first) + } +} + +func TestCleanupVerifyDataRemovesRowsAndVerifyDataIsDisabled(t *testing.T) { + ctx := context.Background() + database, dialect, err := db.Open(ctx, filepath.Join(t.TempDir(), "verify.db")) + if err != nil { + t.Fatalf("Open: %v", err) + } + defer database.Close() + store := db.NewStore(database, dialect) + ids := newVerifyIDs(987654321) + + password, err := newVerifyPassword() + if err != nil { + t.Fatalf("newVerifyPassword: %v", err) + } + ok, err := store.Users.Create(ctx, ids.username, ids.username+"@test.local", password) + if err != nil || !ok { + t.Fatalf("Create user: ok=%v err=%v", ok, err) + } + user, err := store.Users.GetByUsername(ctx, ids.username) + if err != nil { + t.Fatalf("GetByUsername: %v", err) + } + if user.IsAdmin { + t.Fatal("dbverify 创建的验证用户不应是管理员") + } + if err := store.Cookies.Save(ctx, ids.accountID, "unb=123; _m_h5_tk=tk_1;", user.ID); err != nil { + t.Fatalf("Save cookie: %v", err) + } + if err := store.Cookies.SetStatus(ctx, ids.accountID, false); err != nil { + t.Fatalf("SetStatus false: %v", err) + } + if store.Cookies.GetStatus(ctx, ids.accountID) { + t.Fatal("dbverify 验证账号应默认禁用,避免被服务启动") + } + if err := store.Orders.Upsert(ctx, ids.orderID, db.OrderUpsertOpts{ItemID: ids.itemID, BuyerID: ids.buyerID, CookieID: ids.accountID}); err != nil { + t.Fatalf("Orders.Upsert: %v", err) + } + if err := store.Items.Upsert(ctx, &db.ItemInfoRow{CookieID: ids.accountID, ItemID: ids.itemID, ItemTitle: "测试商品"}); err != nil { + t.Fatalf("Items.Upsert: %v", err) + } + cardID, err := store.Cards.Create(ctx, &db.CardFull{Name: "测试卡组", Type: "data", DataContent: "card", Enabled: true, UserID: user.ID}) + if err != nil || cardID == 0 { + t.Fatalf("Cards.Create: id=%d err=%v", cardID, err) + } + channelID, err := store.Notifications.CreateChannel(ctx, &db.NotificationChannelRow{ + Name: "测试渠道", Type: "webhook", Config: `{"webhook_url":"http://x"}`, Enabled: false, UserID: user.ID, + }) + if err != nil { + t.Fatalf("CreateChannel: %v", err) + } + var channelEnabled int + if err := store.DB.QueryRowContext(ctx, `SELECT enabled FROM notification_channels WHERE id=?`, channelID).Scan(&channelEnabled); err != nil { + t.Fatalf("query channel enabled: %v", err) + } + if channelEnabled != 0 { + t.Fatal("dbverify 验证通知渠道应默认禁用") + } + if err := store.Notifications.SetBindings(ctx, ids.accountID, []int64{channelID}); err != nil { + t.Fatalf("SetBindings: %v", err) + } + ruleID, err := store.Automation.Create(ctx, db.AutomationRuleInput{ + UserID: user.ID, CookieID: ids.accountID, ItemID: ids.itemID, Name: "付款发货", + TriggerType: "order_paid", Enabled: false, Priority: 100, + }) + if err != nil { + t.Fatalf("Automation.Create: %v", err) + } + if _, started, err := store.Automation.TryStartRun(ctx, db.AutomationRun{ + RuleID: ruleID, CookieID: ids.accountID, TriggerType: "order_paid", TriggerKey: ids.orderID, Status: "running", + }); err != nil || !started { + t.Fatalf("TryStartRun: started=%v err=%v", started, err) + } + + if err := cleanupVerifyData(ctx, store, ids); err != nil { + t.Fatalf("cleanupVerifyData: %v", err) + } + if _, err := store.Users.GetByUsername(ctx, ids.username); !errors.Is(err, db.ErrNotFound) { + t.Fatalf("验证用户应被清理,err=%v", err) + } + if _, err := store.Cookies.GetValue(ctx, ids.accountID); !errors.Is(err, db.ErrNotFound) { + t.Fatalf("验证账号应被清理,err=%v", err) + } + var count int + for name, query := range map[string]string{ + "automation_runs": `SELECT COUNT(*) FROM automation_runs WHERE cookie_id=? OR trigger_key=?`, + "automation_rules": `SELECT COUNT(*) FROM automation_rules WHERE cookie_id=? OR item_id=?`, + "notification_links": `SELECT COUNT(*) FROM message_notifications WHERE cookie_id=?`, + "orders": `SELECT COUNT(*) FROM orders WHERE cookie_id=? OR order_id=?`, + "items": `SELECT COUNT(*) FROM item_info WHERE cookie_id=? OR item_id=?`, + } { + var err error + switch name { + case "automation_runs", "orders": + err = store.DB.QueryRowContext(ctx, query, ids.accountID, ids.orderID).Scan(&count) + case "automation_rules", "items": + err = store.DB.QueryRowContext(ctx, query, ids.accountID, ids.itemID).Scan(&count) + default: + err = store.DB.QueryRowContext(ctx, query, ids.accountID).Scan(&count) + } + if err != nil { + t.Fatalf("count %s: %v", name, err) + } + if count != 0 { + t.Fatalf("%s 未清理干净,count=%d", name, count) + } + } +} diff --git a/cmd/server/main.go b/cmd/server/main.go index 6a8b0f3..5a7dd0f 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -29,6 +29,7 @@ import ( "xianyu-go/internal/browser" "xianyu-go/internal/db" "xianyu-go/internal/notify" + "xianyu-go/internal/renewal" "xianyu-go/internal/server" ) @@ -105,6 +106,7 @@ func main() { logger.Error("启动账号引擎失败", "err", err) } go automation.NewScheduler(autoCenter).Run(ctx) + go renewal.NewScheduler(store, mgr, bm, ap, logger).Run(ctx) // 3) HTTP 服务。 srv := server.New(store, mgr, bm, *secure, *webDir, *addr, logger, autoCenter, notifier) diff --git a/docker-compose.debian13-postgres17.yml b/docker-compose.debian13-postgres17.yml new file mode 100644 index 0000000..78ad381 --- /dev/null +++ b/docker-compose.debian13-postgres17.yml @@ -0,0 +1,78 @@ +x-app-env: &app-env + DATABASE_URL: postgres://${POSTGRES_USER:-xianyu}:${POSTGRES_PASSWORD:-xianyu_password}@postgres:5432/${POSTGRES_DB:-xianyu}?sslmode=disable + TZ: ${TZ:-Asia/Shanghai} + BROWSER_HEADLESS: ${BROWSER_HEADLESS:-true} + PLAYWRIGHT_DRIVER_PATH: ${PLAYWRIGHT_DRIVER_PATH:-/ms-playwright-go} + PLAYWRIGHT_NODEJS_PATH: ${PLAYWRIGHT_NODEJS_PATH:-/usr/bin/node} + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: ${PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD:-1} + PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH: ${PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH:-/usr/bin/chromium} + XIANYU_ADMIN_PASSWORD: ${XIANYU_ADMIN_PASSWORD:-} + +x-app-volumes: &app-volumes + - app_data:/app/data + - browser_data:/app/browser_data + +services: + postgres: + image: postgres:17-trixie + restart: unless-stopped + environment: + POSTGRES_DB: ${POSTGRES_DB:-xianyu} + POSTGRES_USER: ${POSTGRES_USER:-xianyu} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-xianyu_password} + TZ: ${TZ:-Asia/Shanghai} + volumes: + - postgres_data:/var/lib/postgresql/data + ports: + - "${POSTGRES_PORT:-5432}:5432" + healthcheck: + test: ["CMD-SHELL", "pg_isready -U \"$${POSTGRES_USER}\" -d \"$${POSTGRES_DB}\""] + interval: 10s + timeout: 5s + retries: 10 + + app: + image: ${XIANYU_IMAGE:-xianyu-go:debian13} + build: + context: . + dockerfile: Dockerfile.debian13 + restart: unless-stopped + depends_on: + postgres: + condition: service_healthy + environment: *app-env + command: ["/app/xianyu-server", "-addr", ":8080"] + ports: + - "${XIANYU_HTTP_PORT:-8080}:8080" + volumes: *app-volumes + healthcheck: + test: ["CMD-SHELL", "curl -fsS http://127.0.0.1:8080/health >/dev/null || exit 1"] + interval: 30s + timeout: 5s + retries: 5 + start_period: 30s + + init-admin: + image: ${XIANYU_IMAGE:-xianyu-go:debian13} + build: + context: . + dockerfile: Dockerfile.debian13 + profiles: ["init"] + restart: "no" + depends_on: + postgres: + condition: service_healthy + environment: *app-env + command: + - /bin/sh + - -c + - >- + test -n "$$XIANYU_ADMIN_PASSWORD" || + { echo "XIANYU_ADMIN_PASSWORD is required"; exit 1; }; + exec /app/xianyu-server -init-admin -admin-password "$$XIANYU_ADMIN_PASSWORD" + volumes: *app-volumes + +volumes: + postgres_data: + app_data: + browser_data: diff --git a/frontend/public/squircle.svg b/frontend/assets/squircle.svg similarity index 100% rename from frontend/public/squircle.svg rename to frontend/assets/squircle.svg diff --git a/frontend/components/AccountList.tsx b/frontend/components/AccountList.tsx index c0ac38f..ba8069e 100644 --- a/frontend/components/AccountList.tsx +++ b/frontend/components/AccountList.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; import { createPortal } from 'react-dom'; import { AccountDetail, AIReplySettings, NotificationChannel } from '../types'; import { @@ -28,6 +28,8 @@ import { RefreshCw, Save, User, Clock, MessageCircle, Upload, Key, Eye, EyeOff, Bot, Settings, AlertCircle, ExternalLink, Bell } from 'lucide-react'; +import { buildAccountLoginInfoUpdate } from './accountEdit'; +import { createQRLoginPoller } from './qrPolling'; type ModalType = 'edit' | 'ai-settings' | null; @@ -72,6 +74,37 @@ const AccountList: React.FC = () => { custom_prompts: '', }); const [saving, setSaving] = useState(false); + const qrPollerRef = useRef | null>(null); + const qrCloseTimerRef = useRef | null>(null); + if (qrPollerRef.current === null) { + qrPollerRef.current = createQRLoginPoller(); + } + + const clearQRCloseTimer = () => { + if (qrCloseTimerRef.current !== null) { + window.clearTimeout(qrCloseTimerRef.current); + qrCloseTimerRef.current = null; + } + }; + + const stopQRPolling = () => { + qrPollerRef.current?.stop(); + }; + + const closeQRModal = () => { + stopQRPolling(); + clearQRCloseTimer(); + setShowQRModal(false); + }; + + const scheduleQRModalClose = () => { + clearQRCloseTimer(); + qrCloseTimerRef.current = window.setTimeout(() => { + qrCloseTimerRef.current = null; + setShowQRModal(false); + loadAccounts(); + }, 1000); + }; const refreshRuntimeStatuses = async () => { try { @@ -130,6 +163,13 @@ const AccountList: React.FC = () => { return () => window.clearInterval(timer); }, []); + useEffect(() => { + return () => { + stopQRPolling(); + clearQRCloseTimer(); + }; + }, []); + const runtimePresentation = (account: AccountDetail) => { if (!account.enabled || account.runtime_state === 'disabled') { return { label: '已停用', badge: 'bg-gray-100 text-gray-500', dot: 'bg-gray-300' }; @@ -258,16 +298,9 @@ const AccountList: React.FC = () => { } // 更新登录信息 - if ( - editForm.username !== (editingAccount.username || '') || - editForm.login_password !== (editingAccount.login_password || '') || - editForm.show_browser !== (editingAccount.show_browser || false) - ) { - promises.push(updateAccountLoginInfo(editingAccount.id, { - username: editForm.username, - login_password: editForm.login_password, - show_browser: editForm.show_browser, - })); + const loginInfo = buildAccountLoginInfoUpdate(editingAccount, editForm); + if (loginInfo) { + promises.push(updateAccountLoginInfo(editingAccount.id, loginInfo)); } // 更新通知渠道绑定(覆盖式,总是提交以支持解绑) @@ -308,17 +341,19 @@ const AccountList: React.FC = () => { throw new Error('已取消覆盖当前账号授权'); } } - await updateAccountCookie(target.id, cookies); + await updateAccountCookie(target.id, cookies, 'qr_scan'); return target.id; } if (!unb) { throw new Error('扫码结果缺少账号ID,无法添加账号'); } - await addAccount(unb, cookies); + await addAccount(unb, cookies, 'qr_scan'); return unb; }; const startQRLogin = async (target?: AccountDetail) => { + stopQRPolling(); + clearQRCloseTimer(); const targetAccount = target || null; setQrReauthTarget(targetAccount); setShowQRModal(true); @@ -335,10 +370,8 @@ const AccountList: React.FC = () => { setQrSessionId(res.session_id); setQrStatus('waiting'); - const interval = setInterval(async () => { - const statusRes = await checkQRLoginStatus(res.session_id!); - if (statusRes.status === 'success') { - clearInterval(interval); + qrPollerRef.current?.start(res.session_id, checkQRLoginStatus, { + onSuccess: async (statusRes) => { setQrStatus('success'); if (statusRes.cookies && statusRes.unb) { try { @@ -346,18 +379,22 @@ const AccountList: React.FC = () => { } catch (e) { console.error('保存扫码授权失败', e); setQrStatus('error'); + return; } } - setTimeout(() => { - setShowQRModal(false); - loadAccounts(); - }, 1000); - } else if (statusRes.status === 'scanned') { + scheduleQRModalClose(); + }, + onScanned: () => { setQrStatus('waiting'); // 已扫描,继续等待确认 - } else if (statusRes.status === 'expired' || statusRes.status === 'cancelled' || statusRes.status === 'error' || statusRes.status === 'not_found') { - clearInterval(interval); + }, + onTerminalError: () => { setQrStatus('error'); - } else if (statusRes.status === 'verification_required') { + }, + onPollError: (error) => { + console.error('轮询扫码状态失败', error); + setQrStatus('error'); + }, + onVerificationRequired: (statusRes) => { setQrStatus('verification'); setVerificationUrl(statusRes.verification_url || ''); if (statusRes.face_qr_url) { @@ -366,8 +403,8 @@ const AccountList: React.FC = () => { if (statusRes.verification_screenshot) { setVerificationScreenshot(statusRes.verification_screenshot); } - } - }, 2000); + }, + }); } } catch (e) { setQrStatus('error'); @@ -381,12 +418,10 @@ const AccountList: React.FC = () => { try { const res = await completeQRVerification(qrSessionId); if (res.success && res.cookies && res.unb) { + stopQRPolling(); await persistQRLoginResult(res.cookies, res.unb, qrReauthTarget); setQrStatus('success'); - setTimeout(() => { - setShowQRModal(false); - loadAccounts(); - }, 1000); + scheduleQRModalClose(); } else { setQrStatus('verification'); alert('验证未完成:' + (res.message || '可能验证尚未通过,请先在验证页面完成验证')); @@ -577,7 +612,7 @@ const AccountList: React.FC = () => {
-
-
-
登录滑动验证码
-
开启后账号密码登录需要完成滑动验证
-
- -
-
启用商品自动同步
diff --git a/frontend/components/accountEdit.test.ts b/frontend/components/accountEdit.test.ts new file mode 100644 index 0000000..8a0ba02 --- /dev/null +++ b/frontend/components/accountEdit.test.ts @@ -0,0 +1,36 @@ +import { expect, test } from 'vitest'; +import { buildAccountLoginInfoUpdate } from './accountEdit'; + +test('buildAccountLoginInfoUpdate omits blank password while updating other login fields', () => { + const payload = buildAccountLoginInfoUpdate( + { id: 'acc1', enabled: true, auto_confirm: true, username: 'old-user', show_browser: true }, + { username: 'new-user', login_password: '', show_browser: false }, + ); + + expect(payload).toEqual({ + username: 'new-user', + show_browser: false, + }); +}); + +test('buildAccountLoginInfoUpdate includes password only when user entered one', () => { + const payload = buildAccountLoginInfoUpdate( + { id: 'acc1', enabled: true, auto_confirm: true, username: 'old-user', show_browser: false }, + { username: 'old-user', login_password: 'new-secret', show_browser: false }, + ); + + expect(payload).toEqual({ + username: 'old-user', + login_password: 'new-secret', + show_browser: false, + }); +}); + +test('buildAccountLoginInfoUpdate skips unchanged login info', () => { + const payload = buildAccountLoginInfoUpdate( + { id: 'acc1', enabled: true, auto_confirm: true, username: 'old-user', show_browser: false }, + { username: 'old-user', login_password: '', show_browser: false }, + ); + + expect(payload).toBeNull(); +}); diff --git a/frontend/components/accountEdit.ts b/frontend/components/accountEdit.ts new file mode 100644 index 0000000..4c61d30 --- /dev/null +++ b/frontend/components/accountEdit.ts @@ -0,0 +1,34 @@ +import { AccountDetail } from '../types'; + +export interface AccountLoginEditForm { + username: string; + login_password: string; + show_browser: boolean; +} + +export interface AccountLoginInfoPayload { + username: string; + login_password?: string; + show_browser: boolean; +} + +export const buildAccountLoginInfoUpdate = ( + account: AccountDetail, + form: AccountLoginEditForm, +): AccountLoginInfoPayload | null => { + const usernameChanged = form.username !== (account.username || ''); + const showBrowserChanged = form.show_browser !== (account.show_browser || false); + const passwordChanged = form.login_password !== ''; + if (!usernameChanged && !showBrowserChanged && !passwordChanged) { + return null; + } + + const payload: AccountLoginInfoPayload = { + username: form.username, + show_browser: form.show_browser, + }; + if (passwordChanged) { + payload.login_password = form.login_password; + } + return payload; +}; diff --git a/frontend/components/qrPolling.test.ts b/frontend/components/qrPolling.test.ts new file mode 100644 index 0000000..4c90265 --- /dev/null +++ b/frontend/components/qrPolling.test.ts @@ -0,0 +1,98 @@ +import { afterEach, expect, test, vi } from 'vitest'; +import { createQRLoginPoller } from './qrPolling'; + +afterEach(() => { + vi.useRealTimers(); +}); + +const flushMicrotasks = async () => { + await Promise.resolve(); + await Promise.resolve(); +}; + +test('QR poller clears the previous interval before starting another session', () => { + vi.useFakeTimers(); + const checkStatus = vi.fn().mockResolvedValue({ status: 'waiting' }); + const handlers = { + onSuccess: vi.fn(), + onTerminalError: vi.fn(), + onPollError: vi.fn(), + }; + const poller = createQRLoginPoller(); + + poller.start('sid-1', checkStatus, handlers); + poller.start('sid-2', checkStatus, handlers); + vi.advanceTimersByTime(2000); + + expect(checkStatus).toHaveBeenCalledTimes(1); + expect(checkStatus).toHaveBeenCalledWith('sid-2'); +}); + +test('QR poller stops on success and terminal errors', async () => { + vi.useFakeTimers(); + const checkStatus = vi.fn() + .mockResolvedValueOnce({ status: 'success', cookies: 'a=b', unb: 'acc1' }) + .mockResolvedValueOnce({ status: 'expired' }); + const onSuccess = vi.fn(); + const onTerminalError = vi.fn(); + const poller = createQRLoginPoller(); + + poller.start('sid-1', checkStatus, { + onSuccess, + onTerminalError, + onPollError: vi.fn(), + }); + await vi.advanceTimersByTimeAsync(2000); + await flushMicrotasks(); + + expect(onSuccess).toHaveBeenCalledWith({ status: 'success', cookies: 'a=b', unb: 'acc1' }); + expect(poller.isActive()).toBe(false); + await vi.advanceTimersByTimeAsync(4000); + expect(checkStatus).toHaveBeenCalledTimes(1); + + poller.start('sid-2', checkStatus, { + onSuccess, + onTerminalError, + onPollError: vi.fn(), + }); + await vi.advanceTimersByTimeAsync(2000); + await flushMicrotasks(); + + expect(onTerminalError).toHaveBeenCalledWith({ status: 'expired' }); + expect(poller.isActive()).toBe(false); +}); + +test('QR poller keeps polling during verification and stops on thrown errors', async () => { + vi.useFakeTimers(); + const checkStatus = vi.fn() + .mockResolvedValueOnce({ + status: 'verification_required', + verification_url: 'https://verify.example', + face_qr_url: 'https://face.example', + }) + .mockRejectedValueOnce(new Error('network down')); + const onVerificationRequired = vi.fn(); + const onPollError = vi.fn(); + const poller = createQRLoginPoller(); + + poller.start('sid-1', checkStatus, { + onSuccess: vi.fn(), + onTerminalError: vi.fn(), + onPollError, + onVerificationRequired, + }); + await vi.advanceTimersByTimeAsync(2000); + await flushMicrotasks(); + + expect(onVerificationRequired).toHaveBeenCalledWith(expect.objectContaining({ + status: 'verification_required', + face_qr_url: 'https://face.example', + })); + expect(poller.isActive()).toBe(true); + + await vi.advanceTimersByTimeAsync(2000); + await flushMicrotasks(); + + expect(onPollError).toHaveBeenCalledWith(expect.any(Error)); + expect(poller.isActive()).toBe(false); +}); diff --git a/frontend/components/qrPolling.ts b/frontend/components/qrPolling.ts new file mode 100644 index 0000000..31ff799 --- /dev/null +++ b/frontend/components/qrPolling.ts @@ -0,0 +1,81 @@ +export interface QRLoginStatusResult { + status?: string; + cookies?: string; + unb?: string; + verification_url?: string; + verification_screenshot?: string; + face_qr_url?: string; +} + +interface QRLoginPollerTimers { + setInterval: (handler: () => void, timeout: number) => ReturnType; + clearInterval: (id: ReturnType) => void; +} + +export interface QRLoginPollHandlers { + onSuccess: (status: QRLoginStatusResult) => void | Promise; + onScanned?: (status: QRLoginStatusResult) => void; + onVerificationRequired?: (status: QRLoginStatusResult) => void; + onTerminalError: (status: QRLoginStatusResult) => void; + onPollError: (error: unknown) => void; +} + +const terminalQRStatuses = new Set(['expired', 'cancelled', 'error', 'not_found']); + +export const createQRLoginPoller = ( + timers: QRLoginPollerTimers = { + setInterval: globalThis.setInterval.bind(globalThis), + clearInterval: globalThis.clearInterval.bind(globalThis), + }, +) => { + let interval: ReturnType | null = null; + + const stop = () => { + if (interval !== null) { + timers.clearInterval(interval); + interval = null; + } + }; + + const start = ( + sessionId: string, + checkStatus: (sessionId: string) => Promise, + handlers: QRLoginPollHandlers, + intervalMs = 2000, + ) => { + stop(); + interval = timers.setInterval(() => { + void (async () => { + try { + const statusRes = await checkStatus(sessionId); + if (statusRes.status === 'success') { + stop(); + await handlers.onSuccess(statusRes); + return; + } + if (statusRes.status === 'scanned') { + handlers.onScanned?.(statusRes); + return; + } + if (statusRes.status === 'verification_required') { + handlers.onVerificationRequired?.(statusRes); + return; + } + if (statusRes.status && terminalQRStatuses.has(statusRes.status)) { + stop(); + handlers.onTerminalError(statusRes); + } + } catch (error) { + stop(); + handlers.onPollError(error); + } + })(); + }, intervalMs); + }; + + return { + start, + stop, + isActive: () => interval !== null, + }; +}; diff --git a/frontend/index.css b/frontend/index.css index 6ffb34c..880a9c5 100644 --- a/frontend/index.css +++ b/frontend/index.css @@ -7,8 +7,8 @@ mask 让容器背景色(蓝)也裁成超椭圆形状。 shadow 改用 filter:drop-shadow,跟随 mask 后的实际形状(box-shadow 会被 mask 裁掉)。 */ .squircle { - -webkit-mask-image: url(/static/squircle.svg); - mask-image: url(/static/squircle.svg); + -webkit-mask-image: url('./assets/squircle.svg'); + mask-image: url('./assets/squircle.svg'); -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; diff --git a/frontend/services/api.test.ts b/frontend/services/api.test.ts index 4e4dd5f..3586652 100644 --- a/frontend/services/api.test.ts +++ b/frontend/services/api.test.ts @@ -1,5 +1,19 @@ import { afterEach, expect, test, vi } from 'vitest'; -import { getItems, getOrders, getShippingRules, getValidOrders, updateShippingRule } from './api'; +import { + addAccount, + cancelPasswordLogin, + checkPasswordLoginStatus, + getAccountDetails, + getItems, + getOrders, + getShippingRules, + getSystemSettings, + getValidOrders, + passwordLogin, + updateAccountCookie, + updateAccountLoginInfo, + updateShippingRule, +} from './api'; afterEach(() => vi.unstubAllGlobals()); @@ -56,6 +70,110 @@ test('getItems normalizes multi-spec flags from backend values', async () => { }); }); +test('getSystemSettings normalizes boolean strings', async () => { + vi.stubGlobal('fetch', vi.fn().mockResolvedValue(jsonResponse({ + registration_enabled: 'false', + show_default_login_info: 'true', + item_sync_enabled: '0', + ai_model: 'qwen-plus', + }))); + + const settings = await getSystemSettings(); + expect(settings.registration_enabled).toBe(false); + expect(settings.show_default_login_info).toBe(true); + expect(settings.item_sync_enabled).toBe(false); + expect(settings.ai_model).toBe('qwen-plus'); +}); + +test('account cookie APIs include login_method when provided', async () => { + const fetchMock = vi.fn().mockImplementation(() => Promise.resolve(jsonResponse({ success: true }))); + vi.stubGlobal('fetch', fetchMock); + + await addAccount('acc1', 'unb=acc1', 'qr_scan'); + expect(fetchMock).toHaveBeenCalledWith('/cookies', expect.objectContaining({ + method: 'POST', + credentials: 'include', + })); + expect(JSON.parse(fetchMock.mock.calls[0][1].body)).toEqual({ + id: 'acc1', + value: 'unb=acc1', + login_method: 'qr_scan', + }); + + await updateAccountCookie('acc1', 'unb=acc1; x=1', 'qr_scan'); + expect(fetchMock).toHaveBeenCalledWith('/cookies/acc1', expect.objectContaining({ + method: 'PUT', + credentials: 'include', + })); + expect(JSON.parse(fetchMock.mock.calls[1][1].body)).toEqual({ + id: 'acc1', + value: 'unb=acc1; x=1', + login_method: 'qr_scan', + }); +}); + +test('getAccountDetails normalizes show_browser and never exposes password', async () => { + vi.stubGlobal('fetch', vi.fn().mockResolvedValue(jsonResponse([{ + id: 'acc1', + enabled: true, + auto_confirm: true, + remark: '主账号', + pause_duration: 0, + username: 'login-user', + show_browser: '1', + login_password: 'should-not-leak', + }]))); + + const accounts = await getAccountDetails(); + expect(accounts[0]).toMatchObject({ + id: 'acc1', + username: 'login-user', + show_browser: true, + login_password: '', + }); +}); + +test('updateAccountLoginInfo sends exactly provided fields', async () => { + const fetchMock = vi.fn().mockResolvedValue(jsonResponse({ success: true })); + vi.stubGlobal('fetch', fetchMock); + + await updateAccountLoginInfo('acc1', { username: 'login-user', show_browser: false }); + expect(fetchMock).toHaveBeenCalledWith('/cookies/acc1/login-info', expect.objectContaining({ + method: 'PUT', + credentials: 'include', + })); + expect(JSON.parse(fetchMock.mock.calls[0][1].body)).toEqual({ + username: 'login-user', + show_browser: false, + }); +}); + +test('password login service uses upstream-compatible routes', async () => { + const fetchMock = vi.fn() + .mockResolvedValueOnce(jsonResponse({ success: true, session_id: 'sid', status: 'processing' })) + .mockResolvedValueOnce(jsonResponse({ status: 'success', account_id: 'acc1', cookie_count: 2 })) + .mockResolvedValueOnce(jsonResponse({ success: true })); + vi.stubGlobal('fetch', fetchMock); + + await passwordLogin({ account_id: 'acc1', account: 'u', password: 'p' }); + expect(fetchMock).toHaveBeenNthCalledWith(1, '/password-login', expect.objectContaining({ + method: 'POST', + credentials: 'include', + })); + expect(JSON.parse(fetchMock.mock.calls[0][1].body)).toEqual({ + account_id: 'acc1', + account: 'u', + password: 'p', + }); + + const status = await checkPasswordLoginStatus('sid'); + expect(status.status).toBe('success'); + expect(fetchMock).toHaveBeenNthCalledWith(2, '/password-login/check/sid', expect.objectContaining({ method: 'GET' })); + + await cancelPasswordLogin('sid'); + expect(fetchMock).toHaveBeenNthCalledWith(3, '/password-login/cancel/sid', expect.objectContaining({ method: 'DELETE' })); +}); + test('getShippingRules exposes buyer reviewed gift rules as automation rules', async () => { vi.stubGlobal('fetch', vi.fn().mockResolvedValue(jsonResponse([{ id: 12, diff --git a/frontend/services/api.ts b/frontend/services/api.ts index 0fce3fa..318ba9e 100644 --- a/frontend/services/api.ts +++ b/frontend/services/api.ts @@ -5,6 +5,22 @@ import { Item, AIReplySettings, ShippingRule, ReplyRule, DefaultReply, AutomationAction } from '../types'; +const BOOLEAN_SETTING_KEYS = new Set([ + 'registration_enabled', + 'show_default_login_info', + 'item_sync_enabled', +]); + +const normalizeSettings = (settings: Record): SystemSettings => { + const out: Record = { ...settings }; + for (const key of BOOLEAN_SETTING_KEYS) { + if (key in out) { + out[key] = out[key] === true || out[key] === 'true' || out[key] === '1' || out[key] === 1; + } + } + return out as SystemSettings; +}; + // Auth export const login = async (data: { username?: string; password?: string; email?: string; verification_code?: string }): Promise => { return post('/login', data); @@ -31,8 +47,8 @@ export const updateLoginCredentials = async (data: { }; // Accounts -export const addAccount = async (id: string, value: string): Promise => { - return post('/cookies', { id, value }); +export const addAccount = async (id: string, value: string, loginMethod?: string): Promise => { + return post('/cookies', { id, value, login_method: loginMethod }); }; const accountAvatarURL = (item: any, version: string): string => { @@ -64,7 +80,7 @@ export const getAccountDetails = async (): Promise => { pause_duration: item.pause_duration, username: item.username || '', login_password: '', - show_browser: item.show_browser, + show_browser: item.show_browser === true || item.show_browser === 1 || item.show_browser === '1' || item.show_browser === 'true', nickname: item.nickname || item.remark || `账号 ${item.id.substring(0,6)}`, avatar_url: accountAvatarURL(item, avatarVersion), profile_error: item.profile_error || '', @@ -116,8 +132,45 @@ export const updateAccountPauseDuration = async (id: string, pauseDuration: numb return put(`/cookies/${id}/pause-duration`, { pause_duration: pauseDuration }); }; -export const updateAccountCookie = async (id: string, value: string): Promise => { - return put(`/cookies/${id}`, { id, value }); +export const updateAccountCookie = async (id: string, value: string, loginMethod?: string): Promise => { + return put(`/cookies/${id}`, { id, value, login_method: loginMethod }); +}; + +export interface PasswordLoginStartResponse { + success: boolean; + session_id?: string; + status?: 'processing' | 'failed'; + message?: string; +} + +export interface PasswordLoginStatusResponse { + status: 'processing' | 'success' | 'failed' | 'verification_required' | 'not_found' | 'error'; + message?: string; + account_id?: string; + is_new_account?: boolean; + cookie_count?: number; + verification_url?: string; + screenshot_path?: string; + qr_code_url?: string; + error?: string; + reason?: string; +} + +export const passwordLogin = async (data: { + account_id: string; + account: string; + password: string; + show_browser?: boolean; +}): Promise => { + return post('/password-login', data); +}; + +export const checkPasswordLoginStatus = async (sessionId: string): Promise => { + return get(`/password-login/check/${sessionId}`); +}; + +export const cancelPasswordLogin = async (sessionId: string): Promise => { + return del(`/password-login/cancel/${sessionId}`); }; export const refreshAccountProfile = async (id: string): Promise => { @@ -580,7 +633,7 @@ export const deleteReplyRule = async (id: string, cookieId: string): Promise => { const res = await get<{data: SystemSettings}>('/system-settings'); - return res.data || res; // handle {success:true, data: {...}} wrapper if exists + return normalizeSettings(res.data || res); // handle {success:true, data: {...}} wrapper if exists }; export const updateSystemSettings = async (settings: Partial): Promise => { diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 072c466..1fb97be 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -147,7 +147,30 @@ export default defineConfig({ sourcemap: false, rollupOptions: { output: { - manualChunks: undefined, + manualChunks(id) { + const modulePath = id.split(path.sep).join('/'); + if (!modulePath.includes('/node_modules/')) { + return undefined; + } + if ( + modulePath.includes('/react/') || + modulePath.includes('/react-dom/') || + modulePath.includes('/scheduler/') + ) { + return 'react-vendor'; + } + if ( + modulePath.includes('/recharts/') || + modulePath.includes('/victory-vendor/') || + modulePath.includes('/d3-') + ) { + return 'charts-vendor'; + } + if (modulePath.includes('/lucide-react/')) { + return 'icons-vendor'; + } + return 'vendor'; + }, }, }, emptyOutDir: true, diff --git a/internal/adapter/adapter.go b/internal/adapter/adapter.go index f035d48..0de0ce9 100644 --- a/internal/adapter/adapter.go +++ b/internal/adapter/adapter.go @@ -17,6 +17,10 @@ import ( "xianyu-go/internal/browser" "xianyu-go/internal/db" "xianyu-go/internal/engine" + "xianyu-go/internal/renewal" + "xianyu-go/internal/xianyu/cookierefresh" + "xianyu-go/internal/xianyu/protocol" + xrenew "xianyu-go/internal/xianyu/renew" ) // browserManager 是 adapter 所需的浏览器能力最小契约。*browser.Manager 实现该接口; @@ -27,6 +31,10 @@ type browserManager interface { PasswordLogin(ctx context.Context, account, password, cookieID, userDataDir string, headless bool) (map[string]string, error) } +type browserQuickRenewer interface { + BrowserQuickRenew(ctx context.Context, cookieID, cookieStr string, headless bool) (string, error) +} + // Adapter 实现 engine.Handler 与 automation.OrderDetailFetcher, // 把系统消息、订单详情抓取和密码登录刷新接到浏览器与自动化中心。 // @@ -38,11 +46,14 @@ type Adapter struct { logger *slog.Logger automation *automation.Center notifier notifyNotifier + renewSvc xrenew.Service + cooldown *renewal.CooldownManager - mu sync.Mutex - lastLoginByCID map[string]time.Time orderFetchMu sync.Mutex lastOrderFetch time.Time + + passwordMu sync.Mutex + passwordProcessing map[string]struct{} } // notifyNotifier 是 *notify.Notifier 的最小接口,避免 adapter 直接依赖 notify 包 @@ -57,7 +68,13 @@ func New(store *db.Store, bm *browser.Manager, logger *slog.Logger) *Adapter { if logger == nil { logger = slog.Default() } - return &Adapter{store: store, browser: browserManagerOrNil(bm), logger: logger} + return &Adapter{ + store: store, + browser: browserManagerOrNil(bm), + logger: logger, + cooldown: renewal.GlobalCooldown, + passwordProcessing: make(map[string]struct{}), + } } // browserManagerOrNil 把 *browser.Manager 转为接口;nil 时返回 nil 接口。 @@ -77,6 +94,9 @@ func (a *Adapter) SetNotifier(n notifyNotifier) { a.notifier = n } // SetBrowser 覆盖浏览器实现,便于测试注入桩。 func (a *Adapter) SetBrowser(b browserManager) { a.browser = b } +// SetRenewService 覆盖轻量续期服务,便于测试注入本地 HTTP 服务。 +func (a *Adapter) SetRenewService(s xrenew.Service) { a.renewSvc = s } + // HandleChatMessage 用户聊天消息由 Account 内部 ReplyService 处理,此处空实现满足接口。 func (a *Adapter) HandleChatMessage(_ context.Context, _ engine.ChatMessage) error { return nil @@ -157,51 +177,292 @@ func (a *Adapter) localOrderDetail(ctx context.Context, orderID string) (*automa // OnPasswordLoginRefresh 连续失败时恢复 Cookie。 // -// 恢复顺序是“浏览器快速续期 -> 密码登录”。快速续期复用旧 Cookie 打开闲鱼, -// 尝试点“快速进入”刷新浏览器登录态;这比账号密码登录更轻,风控压力也更小。 +// 恢复顺序是“轻量续期 -> 浏览器快速续期 -> 密码登录”。轻量续期/快速续期复用旧 Cookie +// 刷新登录态;这比账号密码登录更轻,风控压力也更小。 // 同一账号冷却 engine.PasswordLoginMinGap,避免短时间反复触发浏览器恢复。 func (a *Adapter) OnPasswordLoginRefresh(ctx context.Context, cookieID string) bool { - if a.browser == nil { - a.logger.Warn("密码登录刷新失败:浏览器自动化已禁用") - return false + cooldown := a.cooldown + if cooldown == nil { + cooldown = renewal.GlobalCooldown } - a.mu.Lock() - if a.lastLoginByCID == nil { - a.lastLoginByCID = make(map[string]time.Time) - } - last := a.lastLoginByCID[cookieID] - if !last.IsZero() && time.Since(last) < engine.PasswordLoginMinGap { - remain := engine.PasswordLoginMinGap - time.Since(last) - a.mu.Unlock() + if ok, remain := cooldown.TryPasswordLogin(cookieID); !ok { a.logger.Warn("密码登录刷新冷却中", "account", cookieID, "remain", remain.Round(time.Second)) + a.recordPasswordLogin(ctx, cookieID, 0, "skipped_cooldown", "login_cooldown", fmt.Sprintf("密码登录刷新冷却中,还需等待 %s", remain.Round(time.Second))) return false } - a.mu.Unlock() + if !a.beginPasswordLogin(cookieID) { + a.logger.Warn("密码登录刷新已在处理中", "account", cookieID) + return false + } + defer a.finishPasswordLogin(cookieID) d, err := a.store.Cookies.GetDetails(ctx, cookieID) if err != nil { a.logger.Warn("密码登录刷新失败:读取账号详情失败", "account", cookieID, "err", err) + a.recordPasswordLogin(ctx, cookieID, 0, "failed", "account_lookup_failed", err.Error()) return false } - a.mu.Lock() - a.lastLoginByCID[cookieID] = time.Now() - a.mu.Unlock() - // 先走 Cookie 快速续期。只要旧 Cookie 还能触发快速进入,就不暴露账号密码登录, - // 也减少滑块/人脸/设备校验等更重风控的概率。 - if a.saveRecoveredBrowserCookies(ctx, cookieID, d.UserID, func() (map[string]string, error) { - return a.browser.CookieRenew(ctx, cookieID, d.Value, !d.ShowBrowser) - }, "浏览器快速续期") { + if a.tryLightRenewBeforePassword(ctx, d) { + a.recordPasswordLogin(ctx, cookieID, d.UserID, "success", "", "密码登录前轻量续期成功") return true } - if strings.TrimSpace(d.Username) == "" || strings.TrimSpace(d.Password) == "" { - a.logger.Warn("密码登录刷新失败:账号未配置登录用户名或密码", "account", cookieID) + if latest, err := a.store.Cookies.GetDetails(ctx, cookieID); err == nil && latest != nil && latest.Value != "" && latest.Value != d.Value { + a.logger.Info("密码登录前检测到 DB Cookie 已被外部更新,跳过密码登录", "account", cookieID) + if a.store.Tokens != nil { + _ = a.store.Tokens.Clear(ctx, cookieID) + } + a.recordPasswordLogin(ctx, cookieID, d.UserID, "success", "cookie_already_updated_externally", "数据库中的 Cookie 已被外部更新,跳过密码登录") + return true + } + + if a.browser == nil { + a.logger.Warn("密码登录刷新失败:浏览器自动化已禁用,接口轻量续期也未恢复", "account", cookieID) + a.recordPasswordLogin(ctx, cookieID, d.UserID, "failed", "browser_disabled", "浏览器自动化已禁用,接口轻量续期未恢复") return false } - return a.saveRecoveredBrowserCookies(ctx, cookieID, d.UserID, func() (map[string]string, error) { - return a.browser.PasswordLogin(ctx, d.Username, d.Password, cookieID, "", !d.ShowBrowser) - }, "密码登录刷新") + + if strings.TrimSpace(d.Username) == "" || strings.TrimSpace(d.Password) == "" { + msg := "账号已掉线且未配置账号密码" + a.logger.Warn("密码登录刷新失败:账号未配置登录用户名或密码", "account", cookieID) + if err := a.store.Cookies.SetStatusWithReason(ctx, cookieID, false, msg); err != nil { + a.logger.Warn("未配置账号密码时停用账号失败", "account", cookieID, "err", err) + } + a.recordPasswordLogin(ctx, cookieID, d.UserID, "no_credentials", "no_credentials", msg) + return false + } + cookies, err := a.browser.PasswordLogin(ctx, d.Username, d.Password, cookieID, "", !d.ShowBrowser) + if err != nil { + a.handlePasswordLoginError(ctx, cookieID, err) + a.recordPasswordLogin(ctx, cookieID, d.UserID, "failed", passwordLoginFailureReason(err), err.Error()) + return false + } + cookieStr := browser.MarshalCookies(cookies) + if strings.TrimSpace(cookieStr) == "" { + a.logger.Warn("密码登录刷新失败:浏览器未返回 cookie", "account", cookieID) + a.recordPasswordLogin(ctx, cookieID, d.UserID, "failed", "empty_cookies", "浏览器未返回 cookie") + return false + } + if err := a.store.Cookies.Save(ctx, cookieID, cookieStr, d.UserID); err != nil { + a.logger.Warn("密码登录刷新失败:保存 cookie 失败", "account", cookieID, "err", err) + a.recordPasswordLogin(ctx, cookieID, d.UserID, "failed", "cookie_update_failed", err.Error()) + return false + } + if a.store.Tokens != nil { + _ = a.store.Tokens.Clear(ctx, cookieID) + } + _ = a.store.Cookies.MarkLogin(ctx, cookieID, "password", time.Now().Unix()) + a.recordPasswordLogin(ctx, cookieID, d.UserID, "success", "", "账号密码登录刷新成功") + a.logger.Info("密码登录刷新 cookie 成功", "account", cookieID) + return true +} + +func (a *Adapter) beginPasswordLogin(cookieID string) bool { + a.passwordMu.Lock() + defer a.passwordMu.Unlock() + if a.passwordProcessing == nil { + a.passwordProcessing = make(map[string]struct{}) + } + if _, ok := a.passwordProcessing[cookieID]; ok { + return false + } + a.passwordProcessing[cookieID] = struct{}{} + return true +} + +func (a *Adapter) finishPasswordLogin(cookieID string) { + a.passwordMu.Lock() + defer a.passwordMu.Unlock() + delete(a.passwordProcessing, cookieID) +} + +func (a *Adapter) recordPasswordLogin(ctx context.Context, cookieID string, userID int64, status, failureReason, message string) { + if a.store == nil || a.store.LoginLogs == nil { + return + } + if err := a.store.LoginLogs.Add(ctx, db.AccountLoginLog{ + CookieID: cookieID, + UserID: userID, + Method: "password", + Status: status, + Message: truncateMessage(message, 500), + TriggerReason: "令牌/Session过期", + FailureReason: failureReason, + ErrorMessage: truncateMessage(message, 500), + AccountIdentifier: cookieID, + DurationMS: 0, + CreatedAt: time.Now().Unix(), + }); err != nil { + a.logger.Warn("记录密码登录日志失败", "account", cookieID, "err", err) + } +} + +func passwordLoginFailureReason(err error) string { + if err == nil { + return "" + } + msg := err.Error() + if isPasswordLoginBadCredentials(msg) { + return "bad_credentials" + } + event := browser.PasswordLoginEventFromError(err) + if event.Reason != "" { + return event.Reason + } + if event.Status == browser.PasswordLoginStatusVerificationRequired { + return "verification_required" + } + return "other" +} + +func truncateMessage(s string, n int) string { + if n <= 0 || len(s) <= n { + return s + } + return s[:n] +} + +func (a *Adapter) tryLightRenewBeforePassword(ctx context.Context, d *db.CookieDetail) bool { + if d == nil { + return false + } + current := d.Value + api := a.renewSvc + save := func(cookieStr string) { + if strings.TrimSpace(cookieStr) == "" || cookieStr == current { + return + } + if err := a.store.Cookies.UpdateRenewalCookie(ctx, d.ID, cookieStr, cookierefresh.MetadataWithoutSnapshot(d.MetadataJSON), time.Now().Unix()); err != nil { + a.logger.Warn("轻量续期保存 Cookie 失败", "account", d.ID, "err", err) + return + } + current = cookieStr + d.Value = cookieStr + if a.store.Tokens != nil { + _ = a.store.Tokens.Clear(ctx, d.ID) + } + } + apiRenew := func(cookieStr string) (*xrenew.Result, error) { + runCtx, cancel := context.WithTimeout(ctx, 90*time.Second) + defer cancel() + return api.RenewAPIFirst(runCtx, cookieStr) + } + browserRenew := func(cookieStr string) (string, error) { + if a.browser == nil { + return "", fmt.Errorf("浏览器自动化未启用") + } + if br, ok := a.browser.(browserQuickRenewer); ok { + runCtx, cancel := context.WithTimeout(ctx, 5*time.Minute) + defer cancel() + return br.BrowserQuickRenew(runCtx, d.ID, cookieStr, !d.ShowBrowser) + } + m, err := a.browser.CookieRenew(ctx, d.ID, cookieStr, !d.ShowBrowser) + if err != nil { + return "", err + } + return browser.MarshalCookies(m), nil + } + + hasLongLogin := strings.TrimSpace(protocol.TransCookies(current)["havana_lgc2_77"]) != "" + if hasLongLogin { + browserCookies := current + if renewed, err := browserRenew(current); err == nil && renewed != "" { + browserCookies = renewed + save(browserCookies) + } else if err != nil { + a.logger.Warn("密码登录前浏览器续期失败,继续尝试接口续期", "account", d.ID, "err", err) + } + if res, err := apiRenew(browserCookies); err == nil && res != nil { + save(res.NewCookies) + if res.Success { + a.logger.Info("密码登录前浏览器+接口续期成功,跳过密码登录", "account", d.ID) + return true + } + } + return false + } + + res, err := apiRenew(current) + if err == nil && res != nil { + save(res.NewCookies) + if res.Success { + a.logger.Info("密码登录前接口续期成功,跳过密码登录", "account", d.ID) + return true + } + } + browserInput := current + if res != nil && strings.TrimSpace(res.NewCookies) != "" { + browserInput = res.NewCookies + } + browserCookies, err := browserRenew(browserInput) + if err != nil || browserCookies == "" { + return false + } + save(browserCookies) + verify, err := apiRenew(browserCookies) + if err != nil || verify == nil { + return false + } + save(verify.NewCookies) + if verify.Success { + a.logger.Info("密码登录前浏览器续期并通过接口验证,跳过密码登录", "account", d.ID) + return true + } + return false +} + +func (a *Adapter) handlePasswordLoginError(ctx context.Context, cookieID string, err error) { + msg := err.Error() + a.logger.Warn("密码登录刷新失败", "account", cookieID, "err", err) + if isPasswordLoginDisableError(msg) { + _ = a.store.Cookies.SetStatusWithReason(ctx, cookieID, false, msg) + if isPasswordLoginBadCredentials(msg) { + a.markPasswordError(cookieID) + } + return + } + if isPasswordLoginRetryableVerification(msg) { + a.markPasswordError(cookieID) + } +} + +func isPasswordLoginBadCredentials(msg string) bool { + return strings.Contains(msg, "账密错误") || + strings.Contains(msg, "账号密码错误") || + strings.Contains(msg, "用户名或密码错误") || + strings.Contains(msg, "账号或密码错误") || + strings.Contains(msg, "密码错误") +} + +func isPasswordLoginDisableError(msg string) bool { + return isPasswordLoginBadCredentials(msg) || + strings.Contains(msg, "账号不存在") || + strings.Contains(msg, "账号已被冻结") || + strings.Contains(msg, "账号被冻结") || + strings.Contains(msg, "账户被冻结") || + strings.Contains(msg, "账号已锁定") || + strings.Contains(msg, "账户已锁定") || + strings.Contains(msg, "操作过于频繁") || + strings.Contains(msg, "登录过于频繁") || + strings.Contains(msg, "暂时无法登录") +} + +func isPasswordLoginRetryableVerification(msg string) bool { + event := browser.PasswordLoginEventFromMessage(msg) + return event.Reason == "baxia_punish_captcha" || + event.Status == browser.PasswordLoginStatusVerificationRequired || + strings.Contains(msg, "人工验证") || + strings.Contains(msg, "人脸验证") || + strings.Contains(msg, "身份验证") +} + +func (a *Adapter) markPasswordError(cookieID string) { + cooldown := a.cooldown + if cooldown == nil { + cooldown = renewal.GlobalCooldown + } + cooldown.MarkPasswordError(cookieID) } // saveRecoveredBrowserCookies 执行浏览器恢复动作,统一校验、保存 Cookie 并清理 token 缓存。 diff --git a/internal/adapter/adapter_test.go b/internal/adapter/adapter_test.go index 9aa581d..fe6b441 100644 --- a/internal/adapter/adapter_test.go +++ b/internal/adapter/adapter_test.go @@ -3,12 +3,17 @@ package adapter import ( "context" "errors" + "net/http" + "net/http/httptest" "path/filepath" + "strings" "testing" "xianyu-go/internal/automation" "xianyu-go/internal/browser" "xianyu-go/internal/db" + "xianyu-go/internal/renewal" + xrenew "xianyu-go/internal/xianyu/renew" ) // fakeNotifier 记录告警调用,供 OnAccountAlert 断言。 @@ -54,10 +59,52 @@ func newAdapterTestStore(t *testing.T) (*db.Store, func()) { ctx := context.Background() s.Users.Create(ctx, "admin", "a@e.com", "pw") admin, _ := s.Users.GetByUsername(ctx, "admin") - s.Cookies.Save(ctx, "cid", "unb=1; _m_h5_tk=tk;", admin.ID) + s.Cookies.Save(ctx, "cid", "unb=1; _m_h5_tk=tk; havana_lgc2_77=lgc;", admin.ID) + renewal.GlobalCooldown.Reset("cid") return s, func() { d.Close() } } +func verifiedRenewService(t *testing.T) (xrenew.Service, func()) { + t.Helper() + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/hasLogin.do", "/silentHasLogin.do": + _, _ = w.Write([]byte(`{"content":{"success":true}}`)) + case "/setLoginSettings.do": + http.SetCookie(w, &http.Cookie{Name: "havana_lgc2_77", Value: "verified"}) + _, _ = w.Write([]byte(`{"content":{"success":true}}`)) + default: + http.NotFound(w, r) + } + })) + return xrenew.Service{ + HTTPClient: srv.Client(), + HasLoginURL: srv.URL + "/hasLogin.do", + SilentHasLoginURL: srv.URL + "/silentHasLogin.do", + SetLoginSettingsURL: srv.URL + "/setLoginSettings.do", + RetryDelay: -1, + }, srv.Close +} + +func unverifiedRenewService(t *testing.T) (xrenew.Service, func()) { + t.Helper() + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/hasLogin.do", "/silentHasLogin.do", "/setLoginSettings.do": + _, _ = w.Write([]byte(`{"content":{"success":true}}`)) + default: + http.NotFound(w, r) + } + })) + return xrenew.Service{ + HTTPClient: srv.Client(), + HasLoginURL: srv.URL + "/hasLogin.do", + SilentHasLoginURL: srv.URL + "/silentHasLogin.do", + SetLoginSettingsURL: srv.URL + "/setLoginSettings.do", + RetryDelay: -1, + }, srv.Close +} + // TestOnAccountAlert_ForwardedToNotifier 注入 notifier 后告警被转发;未注入时不 panic。 func TestOnAccountAlert_ForwardedToNotifier(t *testing.T) { store, cleanup := newAdapterTestStore(t) @@ -140,25 +187,60 @@ func TestFetchOrderDetail_BrowserFallback(t *testing.T) { } } -// TestOnPasswordLoginRefresh_BrowserNilReturnsFalse 浏览器未启用时直接返回 false。 -func TestOnPasswordLoginRefresh_BrowserNilReturnsFalse(t *testing.T) { +// TestOnPasswordLoginRefresh_BrowserNilStillUsesAPIRenew 浏览器未启用时仍先尝试接口轻量续期。 +func TestOnPasswordLoginRefresh_BrowserNilStillUsesAPIRenew(t *testing.T) { store, cleanup := newAdapterTestStore(t) defer cleanup() a := New(store, nil, nil) - if a.OnPasswordLoginRefresh(context.Background(), "cid") { - t.Fatal("browser=nil 应返回 false") + renewSvc, closeRenew := verifiedRenewService(t) + defer closeRenew() + a.SetRenewService(renewSvc) + if !a.OnPasswordLoginRefresh(context.Background(), "cid") { + t.Fatal("browser=nil 但接口续期成功时应返回 true") + } + saved, _ := store.Cookies.GetValue(context.Background(), "cid") + if !strings.Contains(saved, "havana_lgc2_77=verified") { + t.Fatalf("接口续期 cookie 未保存: %q", saved) } } -// TestOnPasswordLoginRefresh_NoCredentialsReturnsFalse 有浏览器但账号未配密码时返回 false。 -func TestOnPasswordLoginRefresh_NoCredentialsReturnsFalse(t *testing.T) { +// TestOnPasswordLoginRefresh_BrowserNilReturnsFalseAfterAPIFailure 接口轻量续期也失败后才因浏览器不可用失败。 +func TestOnPasswordLoginRefresh_BrowserNilReturnsFalseAfterAPIFailure(t *testing.T) { store, cleanup := newAdapterTestStore(t) defer cleanup() a := New(store, nil, nil) - a.SetBrowser(&fakeBrowser{renewErr: errors.New("quick enter unavailable")}) + renewSvc, closeRenew := unverifiedRenewService(t) + defer closeRenew() + a.SetRenewService(renewSvc) if a.OnPasswordLoginRefresh(context.Background(), "cid") { + t.Fatal("browser=nil 且接口续期失败时应返回 false") + } + logs, err := store.LoginLogs.ListByCookie(context.Background(), "cid", 10) + if err != nil || len(logs) != 1 || logs[0].FailureReason != "browser_disabled" { + t.Fatalf("浏览器不可用应记录 browser_disabled: logs=%#v err=%v", logs, err) + } +} + +// TestOnPasswordLoginRefresh_NoCredentialsReturnsFalse 有浏览器但账号未配密码时返回 false 并停用账号。 +func TestOnPasswordLoginRefresh_NoCredentialsReturnsFalse(t *testing.T) { + store, cleanup := newAdapterTestStore(t) + defer cleanup() + ctx := context.Background() + a := New(store, nil, nil) + renewSvc, closeRenew := unverifiedRenewService(t) + defer closeRenew() + a.SetRenewService(renewSvc) + a.SetBrowser(&fakeBrowser{renewErr: errors.New("quick enter unavailable")}) + if a.OnPasswordLoginRefresh(ctx, "cid") { t.Fatal("账号未配用户名/密码应返回 false") } + if store.Cookies.GetStatus(ctx, "cid") { + t.Fatal("未配置账号密码应自动停用账号,避免持续重试") + } + logs, err := store.LoginLogs.ListByCookie(ctx, "cid", 10) + if err != nil || len(logs) != 1 || logs[0].Status != "no_credentials" || logs[0].FailureReason != "no_credentials" { + t.Fatalf("无凭据应记录 no_credentials 日志: logs=%#v err=%v", logs, err) + } } // TestOnPasswordLoginRefresh_BrowserRenewSuccess 无账密时旧 Cookie 仍可快速续期,应保存新 Cookie 并跳过密码登录。 @@ -172,6 +254,9 @@ func TestOnPasswordLoginRefresh_BrowserRenewSuccess(t *testing.T) { fb := &fakeBrowser{renewCookies: map[string]string{"unb": "1", "_m_h5_tk": "renewed"}} a := New(store, nil, nil) + renewSvc, closeRenew := verifiedRenewService(t) + defer closeRenew() + a.SetRenewService(renewSvc) a.SetBrowser(fb) if !a.OnPasswordLoginRefresh(ctx, "cid") { t.Fatal("快速续期成功应返回 true") @@ -183,12 +268,16 @@ func TestOnPasswordLoginRefresh_BrowserRenewSuccess(t *testing.T) { t.Fatalf("快速续期成功后不应密码登录,got %d", fb.loginCalls) } saved, _ := store.Cookies.GetValue(ctx, "cid") - if saved == "" || saved == "unb=1; _m_h5_tk=tk;" { + if !strings.Contains(saved, "_m_h5_tk=renewed") || !strings.Contains(saved, "havana_lgc2_77=verified") { t.Fatalf("快速续期 cookie 未保存: %q", saved) } if _, err := store.Tokens.Get(ctx, "cid"); err != db.ErrNotFound { t.Fatalf("Cookie 更新后应清除旧 token,got %v", err) } + logs, err := store.LoginLogs.ListByCookie(ctx, "cid", 10) + if err != nil || len(logs) != 1 || logs[0].Status != "success" { + t.Fatalf("快速续期应记录登录日志: logs=%#v err=%v", logs, err) + } } // TestOnPasswordLoginRefresh_Success 配好凭据后浏览器登录成功,cookie 被保存。 @@ -201,6 +290,9 @@ func TestOnPasswordLoginRefresh_Success(t *testing.T) { fb := &fakeBrowser{renewErr: errors.New("quick enter unavailable"), loginCookies: map[string]string{"unb": "1", "_m_h5_tk": "fresh"}} a := New(store, nil, nil) + renewSvc, closeRenew := unverifiedRenewService(t) + defer closeRenew() + a.SetRenewService(renewSvc) a.SetBrowser(fb) if !a.OnPasswordLoginRefresh(ctx, "cid") { t.Fatal("登录成功应返回 true") @@ -212,6 +304,17 @@ func TestOnPasswordLoginRefresh_Success(t *testing.T) { if saved == "" { t.Fatal("刷新的 cookie 应已保存") } + d, err := store.Cookies.GetDetails(ctx, "cid") + if err != nil { + t.Fatalf("GetDetails: %v", err) + } + if d.LoginMethod != "password" || d.LastLoginAt == 0 { + t.Fatalf("密码登录成功后应标记登录审计字段: %+v", d) + } + logs, err := store.LoginLogs.ListByCookie(ctx, "cid", 10) + if err != nil || len(logs) != 1 || logs[0].Status != "success" { + t.Fatalf("密码登录成功应记录日志: logs=%#v err=%v", logs, err) + } } // TestOnPasswordLoginRefresh_LoginError 浏览器登录返回错误时返回 false 且不保存 cookie。 @@ -223,10 +326,77 @@ func TestOnPasswordLoginRefresh_LoginError(t *testing.T) { fb := &fakeBrowser{renewErr: errors.New("quick enter unavailable"), loginErr: errors.New("captcha required")} a := New(store, nil, nil) + renewSvc, closeRenew := unverifiedRenewService(t) + defer closeRenew() + a.SetRenewService(renewSvc) a.SetBrowser(fb) if a.OnPasswordLoginRefresh(ctx, "cid") { t.Fatal("登录失败应返回 false") } + logs, err := store.LoginLogs.ListByCookie(ctx, "cid", 10) + if err != nil || len(logs) != 1 || logs[0].Status != "failed" || logs[0].FailureReason != "verification_required" { + t.Fatalf("密码登录失败应记录日志: logs=%#v err=%v", logs, err) + } +} + +func TestOnPasswordLoginRefresh_BaxiaFailureReason(t *testing.T) { + store, cleanup := newAdapterTestStore(t) + defer cleanup() + ctx := context.Background() + store.DB.ExecContext(ctx, `UPDATE cookies SET username='u', password='p' WHERE id='cid'`) + + fb := &fakeBrowser{renewErr: errors.New("quick enter unavailable"), loginErr: errors.New("baxia-punish 风控图形验证")} + a := New(store, nil, nil) + renewSvc, closeRenew := unverifiedRenewService(t) + defer closeRenew() + a.SetRenewService(renewSvc) + a.SetBrowser(fb) + if a.OnPasswordLoginRefresh(ctx, "cid") { + t.Fatal("风控失败应返回 false") + } + logs, err := store.LoginLogs.ListByCookie(ctx, "cid", 10) + if err != nil || len(logs) != 1 || logs[0].FailureReason != "baxia_punish_captcha" { + t.Fatalf("baxia 风控应记录专用 failure_reason: logs=%#v err=%v", logs, err) + } + if !store.Cookies.GetStatus(ctx, "cid") { + t.Fatal("baxia 风控只应冷却,不应停用账号") + } +} + +func TestOnPasswordLoginRefresh_DisablesFrozenAccountError(t *testing.T) { + store, cleanup := newAdapterTestStore(t) + defer cleanup() + ctx := context.Background() + store.DB.ExecContext(ctx, `UPDATE cookies SET username='u', password='p' WHERE id='cid'`) + + fb := &fakeBrowser{renewErr: errors.New("quick enter unavailable"), loginErr: errors.New("账号已被冻结")} + a := New(store, nil, nil) + renewSvc, closeRenew := unverifiedRenewService(t) + defer closeRenew() + a.SetRenewService(renewSvc) + a.SetBrowser(fb) + if a.OnPasswordLoginRefresh(ctx, "cid") { + t.Fatal("冻结账号登录失败应返回 false") + } + if store.Cookies.GetStatus(ctx, "cid") { + t.Fatal("冻结账号登录错误应停用账号") + } +} + +func TestPasswordLoginProcessingLock(t *testing.T) { + store, cleanup := newAdapterTestStore(t) + defer cleanup() + a := New(store, nil, nil) + if !a.beginPasswordLogin("cid") { + t.Fatal("首次获取 processing 锁应成功") + } + if a.beginPasswordLogin("cid") { + t.Fatal("同账号重复获取 processing 锁应失败") + } + a.finishPasswordLogin("cid") + if !a.beginPasswordLogin("cid") { + t.Fatal("释放后应可再次获取 processing 锁") + } } // TestOnPasswordLoginRefresh_Cooldown 同一账号短时间内第二次刷新被冷却拒绝。 @@ -238,6 +408,9 @@ func TestOnPasswordLoginRefresh_Cooldown(t *testing.T) { fb := &fakeBrowser{renewErr: errors.New("quick enter unavailable"), loginCookies: map[string]string{"unb": "1"}} a := New(store, nil, nil) + renewSvc, closeRenew := unverifiedRenewService(t) + defer closeRenew() + a.SetRenewService(renewSvc) a.SetBrowser(fb) if !a.OnPasswordLoginRefresh(ctx, "cid") { t.Fatal("首次应成功") @@ -249,4 +422,8 @@ func TestOnPasswordLoginRefresh_Cooldown(t *testing.T) { if fb.loginCalls != 1 { t.Fatalf("冷却期内不应调用浏览器,got calls=%d", fb.loginCalls) } + logs, err := store.LoginLogs.ListByCookie(ctx, "cid", 10) + if err != nil || len(logs) != 2 || logs[0].Status != "skipped_cooldown" || logs[0].FailureReason != "login_cooldown" { + t.Fatalf("冷却拒绝应记录 skipped_cooldown 日志: logs=%#v err=%v", logs, err) + } } diff --git a/internal/browser/cookierenew.go b/internal/browser/cookierenew.go index e5dcb71..e80a007 100644 --- a/internal/browser/cookierenew.go +++ b/internal/browser/cookierenew.go @@ -3,9 +3,21 @@ package browser import ( "context" "fmt" + "os" + "path/filepath" + "strings" "time" "github.com/playwright-community/playwright-go" + + "xianyu-go/internal/xianyu/cookierefresh" +) + +const ( + quickRenewPageLoadWait = 3 * time.Second + quickRenewAfterClick = 5 * time.Second + quickRenewTimeoutMS = 30000 + quickRenewUA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36" ) // CookieRenew 用现有 Cookie 打开闲鱼页面,尝试通过“快速进入”刷新浏览器登录态。 @@ -13,47 +25,349 @@ import ( // 这个方法位于密码登录之前:如果 Cookie 仍保留可续期的浏览器会话,页面通常会给出 // 免输密码的快速进入入口。成功点击后提取完整 Cookie,可避免更重的账号密码登录。 func (m *Manager) CookieRenew(ctx context.Context, cookieID, cookieStr string, headless bool) (map[string]string, error) { - if cookieStr == "" { - return nil, fmt.Errorf("Cookie为空,无法浏览器续期") - } - page, release, err := m.newPage(ctx, cookieID, cookieStr, headless) + newCookies, err := m.BrowserQuickRenew(ctx, cookieID, cookieStr, headless) if err != nil { return nil, err } + return cookierefresh.ParseCookieString(newCookies), nil +} + +// BrowserQuickRenew 使用持久化浏览器上下文执行“快速进入”Cookie 续期。 +func (m *Manager) BrowserQuickRenew(ctx context.Context, cookieID, cookieStr string, headless bool) (string, error) { + if cookieStr == "" { + return "", fmt.Errorf("Cookie为空,无法浏览器续期") + } + + bctx, release, err := m.newPersistentRenewContext(ctx, cookieID, cookieStr, nil, quickRenewHeadless(headless)) + if err != nil { + return "", err + } defer release() - if _, err := page.Goto(goofishIMURL, playwright.PageGotoOptions{ - WaitUntil: playwright.WaitUntilStateDomcontentloaded, - Timeout: playwright.Float(30000), - }); err != nil { - m.logger.Warn("浏览器续期访问 IM 页面异常", "cookieID", cookieID, "err", err) + page, err := bctx.NewPage() + if err != nil { + return "", fmt.Errorf("新建 page 失败: %w", err) } - if checkLoginSuccess(page) { - m.logger.Info("浏览器续期:已有有效登录态", "cookieID", cookieID) - return extractPageCookies(page) + defer func() { _ = page.Close() }() + + if _, err := page.Goto(goofishHomeURL, playwright.PageGotoOptions{ + WaitUntil: playwright.WaitUntilStateDomcontentloaded, + Timeout: playwright.Float(quickRenewTimeoutMS), + }); err != nil { + m.logger.Warn("浏览器续期访问首页异常", "cookieID", cookieID, "err", err) + } + time.Sleep(quickRenewPageLoadWait) + + hasQuickEnter := clickQuickEnter(page) + if hasQuickEnter { + time.Sleep(quickRenewAfterClick) + } else if !checkAlreadyLoggedIn(page) { + return "", fmt.Errorf("未找到[快速进入]按钮且未检测到登录状态,需要账号密码登录") } - if !clickQuickEnter(page) { - return nil, fmt.Errorf("未找到快速进入入口,需要密码登录") + all, err := bctx.Cookies() + if err != nil { + return "", fmt.Errorf("提取 cookie 失败: %w", err) } - time.Sleep(5 * time.Second) - if !checkLoginSuccess(page) { - return nil, fmt.Errorf("快速进入后仍未检测到登录态") + newSnapshot := cookieSnapshotFromPlaywright(all) + if len(newSnapshot) == 0 { + return "", fmt.Errorf("点击[快速进入]后未获取到浏览器Cookie") } - m.logger.Info("浏览器续期:快速进入成功", "cookieID", cookieID) - return extractPageCookies(page) + cookieFromBrowser := cookierefresh.CookieStringFromSnapshot(newSnapshot) + merged := cookierefresh.MergeOriginalFields(cookieStr, cookieFromBrowser) + m.logger.Info("浏览器续期成功", "cookieID", cookieID, "has_quick_enter", hasQuickEnter, "cookie_count", len(newSnapshot)) + return merged, nil +} + +// CookiesRefreshSnapshot 执行定时 COOKIES 续期:打开首页、刷新页面并返回完整 Cookie 快照。 +func (m *Manager) CookiesRefreshSnapshot(ctx context.Context, cookieID, cookieStr string, snapshot []cookierefresh.BrowserCookie, headless bool) (string, []cookierefresh.BrowserCookie, error) { + if cookieStr == "" && len(snapshot) == 0 { + return "", nil, fmt.Errorf("Cookie为空,且无完整Cookie快照,无法执行续期") + } + bctx, release, err := m.newEphemeralRefreshContext(ctx, cookieID, cookieStr, snapshot, cookiesRefreshHeadless(headless)) + if err != nil { + return "", nil, err + } + defer release() + + page, err := bctx.NewPage() + if err != nil { + return "", nil, fmt.Errorf("新建 page 失败: %w", err) + } + defer func() { _ = page.Close() }() + + if _, err := page.Goto(goofishHomeURL, playwright.PageGotoOptions{ + WaitUntil: playwright.WaitUntilStateDomcontentloaded, + Timeout: playwright.Float(60000), + }); err != nil { + m.logger.Warn("COOKIES续期访问首页异常", "cookieID", cookieID, "err", err) + } + time.Sleep(2 * time.Second) + + for i := 0; i < 3; i++ { + if _, err := page.Reload(playwright.PageReloadOptions{ + WaitUntil: playwright.WaitUntilStateDomcontentloaded, + Timeout: playwright.Float(60000), + }); err != nil { + m.logger.Warn("COOKIES续期 reload 异常", "cookieID", cookieID, "attempt", i+1, "err", err) + } + time.Sleep(2 * time.Second) + } + + if modal, err := page.QuerySelector(".ant-modal-body"); err == nil && modal != nil { + text, _ := modal.TextContent() + if len(text) > 120 { + text = text[:120] + } + if text != "" { + return "", nil, fmt.Errorf("页面存在 ant-modal-body,判定续期失败: %s", text) + } + return "", nil, fmt.Errorf("页面存在 ant-modal-body,判定续期失败") + } + + all, err := bctx.Cookies() + if err != nil { + return "", nil, fmt.Errorf("提取 cookie 失败: %w", err) + } + newSnapshot := cookieSnapshotFromPlaywright(all) + if len(newSnapshot) == 0 { + return "", nil, fmt.Errorf("页面刷新完成,但未获取到浏览器Cookie") + } + newCookies := cookierefresh.CookieStringFromSnapshot(newSnapshot) + m.logger.Info("COOKIES续期成功", "cookieID", cookieID, "cookie_count", len(newSnapshot)) + return newCookies, newSnapshot, nil +} + +// CookieRenewSnapshot 兼容旧调用,等价于定时 COOKIES 快照续期。 +func (m *Manager) CookieRenewSnapshot(ctx context.Context, cookieID, cookieStr string, snapshot []cookierefresh.BrowserCookie, headless bool) (string, []cookierefresh.BrowserCookie, error) { + return m.CookiesRefreshSnapshot(ctx, cookieID, cookieStr, snapshot, headless) } func clickQuickEnter(page playwright.Page) bool { frames := append([]playwright.Frame{page.MainFrame()}, page.Frames()...) for _, f := range frames { - for _, sel := range loginBtnSelectors { + for _, sel := range quickEnterSelectors { el, err := f.QuerySelector(sel) - if err == nil && el != nil { - _ = el.Click() + if err == nil && el != nil && elementVisible(el) { + if err := el.Click(); err == nil { + return true + } + } + } + buttons, err := f.QuerySelectorAll("button") + if err != nil { + continue + } + for _, btn := range buttons { + text, _ := btn.TextContent() + if strings.Contains(strings.TrimSpace(text), "快速进入") && elementVisible(btn) { + _ = btn.Click() return true } } } return false } + +var quickEnterSelectors = []string{ + `button:has-text("快速进入")`, + `button[type="submit"]:has-text("快速进入")`, + `.fm-button:has-text("快速进入")`, + `.fn-button:has-text("快速进入")`, +} + +var loggedInSelectors = []string{ + "div.nick", + ".header-right .nick", + ".rc-virtual-list-holder-inner", + `img[src*="img.alicdn.com"][class*="avatar"]`, + `img[src*="img.alicdn.com"][style*="border-radius"]`, + `.header-container img[src*="img.alicdn.com"]`, + "#nc_1_n1z", + ".nc-container", + ".nc_scale", + `div:has-text("请拖动下方滑块完成验证")`, + `div:has-text("请按住滑块")`, +} + +func checkAlreadyLoggedIn(page playwright.Page) bool { + for _, sel := range loggedInSelectors { + el, err := page.QuerySelector(sel) + if err == nil && el != nil && elementVisible(el) { + return true + } + } + bodyText, err := page.TextContent("body") + if err == nil && strings.Contains(bodyText, "消息") && (strings.Contains(bodyText, "订单") || strings.Contains(bodyText, "发闲置")) { + return true + } + return false +} + +func elementVisible(el playwright.ElementHandle) bool { + visible, err := el.IsVisible() + return err == nil && visible +} + +func cleanSingletonFiles(userDataDir string) { + for _, name := range []string{"SingletonLock", "SingletonSocket", "SingletonCookie"} { + _ = os.Remove(filepath.Join(userDataDir, name)) + } +} + +func (m *Manager) newPersistentRenewContext(ctx context.Context, cookieID, cookieStr string, snapshot []cookierefresh.BrowserCookie, headless bool) (playwright.BrowserContext, func(), error) { + lock := m.accountRenewLock(cookieID) + lock.Lock() + unlock := func() { lock.Unlock() } + + releaseSlot, err := m.acquireRenewSlot(ctx) + if err != nil { + unlock() + return nil, nil, err + } + + if err := m.init(); err != nil { + releaseSlot() + unlock() + return nil, nil, err + } + + userDataDir := filepath.Join("browser_data", "user_"+pureUserID(cookieID)) + cleanSingletonFiles(userDataDir) + var bctx playwright.BrowserContext + var lastErr error + for attempt := 1; attempt <= 2; attempt++ { + bctx, err = m.pw.Chromium.LaunchPersistentContext(userDataDir, playwright.BrowserTypeLaunchPersistentContextOptions{ + Headless: playwright.Bool(headless), + Args: chromiumLaunchArgs(), + ExecutablePath: chromiumExecutablePath(), + UserAgent: playwright.String(quickRenewUA), + Viewport: &playwright.Size{Width: 1280, Height: 720}, + Locale: playwright.String(defaultLang), + TimezoneId: playwright.String(defaultTZ), + Timeout: playwright.Float(quickRenewTimeoutMS), + }) + if err == nil { + break + } + lastErr = err + cleanSingletonFiles(userDataDir) + time.Sleep(time.Second) + } + if bctx == nil { + releaseSlot() + unlock() + return nil, nil, fmt.Errorf("启动持久化浏览器失败: %w", lastErr) + } + + if err := bctx.AddInitScript(playwright.Script{Content: playwright.String(stealthScript())}); err != nil { + m.logger.Warn("注入 stealth 脚本失败", "err", err) + } + if len(snapshot) > 0 { + if err := bctx.AddCookies(snapshotToOptionalCookies(snapshot)); err != nil { + m.logger.Warn("浏览器续期注入 Cookie 快照失败", "cookieID", cookieID, "err", err) + } + } else if cookieStr != "" { + if err := addCookieStr(bctx, cookieStr); err != nil { + m.logger.Warn("浏览器续期注入 Cookie 字符串失败", "cookieID", cookieID, "err", err) + } + } + + release := func() { + _ = bctx.Close() + releaseSlot() + unlock() + } + return bctx, release, nil +} + +func (m *Manager) newEphemeralRefreshContext(ctx context.Context, cookieID, cookieStr string, snapshot []cookierefresh.BrowserCookie, headless bool) (playwright.BrowserContext, func(), error) { + releaseSlot, err := m.acquireRenewSlot(ctx) + if err != nil { + return nil, nil, err + } + if err := m.init(); err != nil { + releaseSlot() + return nil, nil, err + } + browser, err := m.pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{ + Headless: playwright.Bool(headless), + Args: chromiumLaunchArgs(), + ExecutablePath: chromiumExecutablePath(), + }) + if err != nil { + releaseSlot() + return nil, nil, fmt.Errorf("启动 chromium 失败: %w", err) + } + bctx, err := browser.NewContext(playwright.BrowserNewContextOptions{ + UserAgent: playwright.String("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"), + Viewport: &playwright.Size{Width: 1280, Height: 720}, + Locale: playwright.String(defaultLang), + TimezoneId: playwright.String(defaultTZ), + }) + if err != nil { + _ = browser.Close() + releaseSlot() + return nil, nil, fmt.Errorf("创建 context 失败: %w", err) + } + if err := bctx.AddInitScript(playwright.Script{Content: playwright.String(`Object.defineProperty(navigator, 'webdriver', { get: () => undefined }); Object.defineProperty(navigator, 'languages', { get: () => ['zh-CN', 'zh', 'en'] }); window.chrome = { runtime: {} };`)}); err != nil { + m.logger.Warn("注入 COOKIES 续期 stealth 脚本失败", "cookieID", cookieID, "err", err) + } + if len(snapshot) > 0 { + if err := bctx.AddCookies(snapshotToOptionalCookies(snapshot)); err != nil { + m.logger.Warn("COOKIES续期注入 Cookie 快照失败", "cookieID", cookieID, "err", err) + } + } else if cookieStr != "" { + if err := addCookieStr(bctx, cookieStr); err != nil { + m.logger.Warn("COOKIES续期注入 Cookie 字符串失败", "cookieID", cookieID, "err", err) + } + } + release := func() { + _ = bctx.Close() + _ = browser.Close() + releaseSlot() + } + return bctx, release, nil +} + +func quickRenewHeadless(headless bool) bool { + switch strings.ToLower(strings.TrimSpace(os.Getenv("BROWSER_HEADLESS"))) { + case "true", "1", "yes", "on": + return true + case "false", "0", "no", "off": + return false + default: + return headless + } +} + +func cookiesRefreshHeadless(headless bool) bool { + return quickRenewHeadless(headless) +} + +func pureUserID(cookieID string) string { + cookieID = sanitize(cookieID) + parts := strings.Split(cookieID, "_") + if len(parts) >= 2 { + last := parts[len(parts)-1] + if len(last) >= 10 && allDigits(last) { + return strings.Join(parts[:len(parts)-1], "_") + } + } + if cookieID == "" { + return "unknown" + } + return cookieID +} + +func allDigits(s string) bool { + if s == "" { + return false + } + for _, r := range s { + if r < '0' || r > '9' { + return false + } + } + return true +} diff --git a/internal/browser/cookies.go b/internal/browser/cookies.go index f5be807..cab43e1 100644 --- a/internal/browser/cookies.go +++ b/internal/browser/cookies.go @@ -7,8 +7,12 @@ import ( "time" "github.com/playwright-community/playwright-go" + + "xianyu-go/internal/xianyu/cookierefresh" ) +var cookieDomains = []string{".goofish.com", ".taobao.com", ".alipay.com"} + // parseCookieStr 把 "k=v; k2=v2" 解析为 map。 func parseCookieStr(s string) map[string]string { m := make(map[string]string) @@ -35,7 +39,7 @@ func MarshalCookies(m map[string]string) string { return cookieMarshal(m) } -// parseCookieStrToPlaywright 把 cookie 字符串转成 playwright OptionalCookie(domain .goofish.com)。 +// parseCookieStrToPlaywright 把 cookie 字符串转成 playwright OptionalCookie。 func parseCookieStrToPlaywright(s string) []playwright.OptionalCookie { var cookies []playwright.OptionalCookie for _, part := range strings.Split(s, ";") { @@ -46,17 +50,74 @@ func parseCookieStrToPlaywright(s string) []playwright.OptionalCookie { if name == "" { continue } - cookies = append(cookies, playwright.OptionalCookie{ - Name: name, - Value: value, - Domain: playwright.String(goofishDot), - Path: playwright.String("/"), - }) + for _, domain := range cookieDomains { + cookies = append(cookies, playwright.OptionalCookie{ + Name: name, + Value: value, + Domain: playwright.String(domain), + Path: playwright.String("/"), + }) + } } } return cookies } +func snapshotToOptionalCookies(snapshot []cookierefresh.BrowserCookie) []playwright.OptionalCookie { + var out []playwright.OptionalCookie + for _, c := range cookierefresh.NormalizeSnapshot(snapshot) { + domain := c.Domain + if domain == "" { + domain = goofishDot + } + path := c.Path + if path == "" { + path = "/" + } + oc := playwright.OptionalCookie{ + Name: c.Name, + Value: c.Value, + Domain: playwright.String(domain), + Path: playwright.String(path), + HttpOnly: playwright.Bool(c.HTTPOnly), + Secure: playwright.Bool(c.Secure), + } + if c.Expires > 0 { + oc.Expires = playwright.Float(c.Expires) + } + switch c.SameSite { + case "Strict": + oc.SameSite = playwright.SameSiteAttributeStrict + case "Lax": + oc.SameSite = playwright.SameSiteAttributeLax + case "None": + oc.SameSite = playwright.SameSiteAttributeNone + } + out = append(out, oc) + } + return out +} + +func cookieSnapshotFromPlaywright(cs []playwright.Cookie) []cookierefresh.BrowserCookie { + out := make([]cookierefresh.BrowserCookie, 0, len(cs)) + for _, c := range cs { + bc := cookierefresh.BrowserCookie{ + Name: c.Name, + Value: c.Value, + Domain: c.Domain, + Path: c.Path, + Expires: c.Expires, + HTTPOnly: c.HttpOnly, + Secure: c.Secure, + } + if c.SameSite != nil { + bc.SameSite = string(*c.SameSite) + } + out = append(out, bc) + } + return cookierefresh.NormalizeSnapshot(out) +} + // cookiesToMap 把 playwright Cookie 切片转成 map。 func cookiesToMap(cs []playwright.Cookie) map[string]string { m := make(map[string]string, len(cs)) diff --git a/internal/browser/cookies_test.go b/internal/browser/cookies_test.go index af6fb15..164fa93 100644 --- a/internal/browser/cookies_test.go +++ b/internal/browser/cookies_test.go @@ -22,17 +22,24 @@ func TestParseCookieStrRoundTrip(t *testing.T) { func TestParseCookieStrToPlaywright(t *testing.T) { cookies := parseCookieStrToPlaywright("a=1; b=2") - if len(cookies) != 2 { - t.Fatalf("应解析 2 个 cookie,got %d", len(cookies)) + if len(cookies) != 2*len(cookieDomains) { + t.Fatalf("应按多个域名注入 cookie,got %d", len(cookies)) } + domains := make(map[string]bool) for _, c := range cookies { - if c.Domain == nil || *c.Domain != goofishDot { - t.Fatalf("domain 应为 %s: %+v", goofishDot, c.Domain) + if c.Domain == nil { + t.Fatalf("domain 不能为空: %+v", c.Domain) } + domains[*c.Domain] = true if c.Path == nil || *c.Path != "/" { t.Fatalf("path 应为 /: %+v", c.Path) } } + for _, domain := range cookieDomains { + if !domains[domain] { + t.Fatalf("缺少 domain %s: %+v", domain, domains) + } + } } func TestParseCookieStrEmpty(t *testing.T) { diff --git a/internal/browser/lifecycle.go b/internal/browser/lifecycle.go index 4504726..a85776b 100644 --- a/internal/browser/lifecycle.go +++ b/internal/browser/lifecycle.go @@ -7,6 +7,8 @@ import ( "errors" "fmt" "log/slog" + "os" + "strings" "sync" "time" @@ -18,13 +20,14 @@ import ( // 默认 UA、语言、时区与视口。 const ( - defaultUA = xianyu.BrowserUA - defaultW = 1920 - defaultH = 1080 - defaultLang = "zh-CN" - defaultTZ = "Asia/Shanghai" - goofishDot = ".goofish.com" - goofishIMURL = "https://www.goofish.com/im" + defaultUA = xianyu.BrowserUA + defaultW = 1920 + defaultH = 1080 + defaultLang = "zh-CN" + defaultTZ = "Asia/Shanghai" + goofishDot = ".goofish.com" + goofishHomeURL = "https://www.goofish.com/" + goofishIMURL = "https://www.goofish.com/im" ) // chromiumLaunchArgs 统一 Chromium 启动参数。 @@ -52,6 +55,22 @@ func chromiumLaunchArgs() []string { } } +func chromiumExecutablePath() *string { + if path := strings.TrimSpace(os.Getenv("PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH")); path != "" { + return playwright.String(path) + } + return nil +} + +func skipPlaywrightBrowserDownload() bool { + switch strings.ToLower(strings.TrimSpace(os.Getenv("PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD"))) { + case "1", "true", "yes", "on": + return true + default: + return false + } +} + // Manager 管理浏览器生命周期与按账号复用的上下文池。 type Manager struct { pw *playwright.Playwright @@ -67,6 +86,10 @@ type Manager struct { idleTTL time.Duration creates singleflight.Group + renewMu sync.Mutex + renewLocks map[string]*sync.Mutex + renewSlots chan struct{} + // 允许测试注入自定义 playwright / 安装函数。 installFn func() error runFn func() (*playwright.Playwright, error) @@ -85,15 +108,21 @@ func NewManager(logger *slog.Logger) *Manager { logger = slog.Default() } return &Manager{ - logger: logger, - pool: make(map[string]*poolEntry), - maxSize: 3, - idleTTL: 5 * time.Minute, + logger: logger, + pool: make(map[string]*poolEntry), + maxSize: 3, + idleTTL: 5 * time.Minute, + renewLocks: make(map[string]*sync.Mutex), + renewSlots: make(chan struct{}, 3), installFn: func() error { - return playwright.Install(&playwright.RunOptions{ + opts := &playwright.RunOptions{ Browsers: []string{"chromium"}, Verbose: false, - }) + } + if skipPlaywrightBrowserDownload() { + opts.SkipInstallBrowsers = true + } + return playwright.Install(opts) }, runFn: func() (*playwright.Playwright, error) { return playwright.Run() @@ -101,6 +130,32 @@ func NewManager(logger *slog.Logger) *Manager { } } +func (m *Manager) accountRenewLock(cookieID string) *sync.Mutex { + m.renewMu.Lock() + defer m.renewMu.Unlock() + if m.renewLocks == nil { + m.renewLocks = make(map[string]*sync.Mutex) + } + lock := m.renewLocks[cookieID] + if lock == nil { + lock = &sync.Mutex{} + m.renewLocks[cookieID] = lock + } + return lock +} + +func (m *Manager) acquireRenewSlot(ctx context.Context) (func(), error) { + if m.renewSlots == nil { + m.renewSlots = make(chan struct{}, 3) + } + select { + case m.renewSlots <- struct{}{}: + return func() { <-m.renewSlots }, nil + case <-ctx.Done(): + return nil, ctx.Err() + } +} + // init 懒加载 playwright(首次调用时下载 driver + chromium)。 func (m *Manager) init() error { m.once.Do(func() { @@ -202,8 +257,9 @@ func (m *Manager) acquireEntry(cookieID, cookieStr string, headless bool) (*pool func (m *Manager) createEntry(cookieID, cookieStr string, headless bool) (*poolEntry, error) { browser, err := m.pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{ - Headless: playwright.Bool(headless), - Args: chromiumLaunchArgs(), + Headless: playwright.Bool(headless), + Args: chromiumLaunchArgs(), + ExecutablePath: chromiumExecutablePath(), }) if err != nil { return nil, fmt.Errorf("启动 chromium 失败: %w", err) diff --git a/internal/browser/passwordlogin.go b/internal/browser/passwordlogin.go index c921c39..37e4df5 100644 --- a/internal/browser/passwordlogin.go +++ b/internal/browser/passwordlogin.go @@ -2,6 +2,7 @@ package browser import ( "context" + "encoding/base64" "fmt" "path/filepath" "strings" @@ -26,10 +27,24 @@ var loginSuccessSelectors = []string{ ".rc-virtual-list-holder-inner", // IM 页面侧边栏有子元素则已登录 } +const ( + passwordVerificationWaitInterval = 10 * time.Second + passwordVerificationMaxWait = 5 * time.Minute +) + // PasswordLogin 用账号密码通过浏览器登录闲鱼,返回完整 cookie map。 // 移植自 xianyu_slider_stealth.login_with_password_playwright。 // userDataDir:空字符串用临时目录,非空则持久化(跨次复用 session)。 func (m *Manager) PasswordLogin(ctx context.Context, account, password, cookieID, userDataDir string, headless bool) (map[string]string, error) { + return m.passwordLogin(ctx, account, password, cookieID, userDataDir, headless, nil) +} + +// PasswordLoginWithEvents 在密码登录过程中上报中间状态。 +func (m *Manager) PasswordLoginWithEvents(ctx context.Context, account, password, cookieID, userDataDir string, headless bool, onEvent PasswordLoginEventHandler) (map[string]string, error) { + return m.passwordLogin(ctx, account, password, cookieID, userDataDir, headless, onEvent) +} + +func (m *Manager) passwordLogin(ctx context.Context, account, password, cookieID, userDataDir string, headless bool, onEvent PasswordLoginEventHandler) (map[string]string, error) { if err := m.init(); err != nil { return nil, err } @@ -37,14 +52,16 @@ func (m *Manager) PasswordLogin(ctx context.Context, account, password, cookieID if userDataDir == "" { userDataDir = filepath.Join("browser_data", "user_"+sanitize(cookieID)) } + headless = quickRenewHeadless(headless) bctx, err := m.pw.Chromium.LaunchPersistentContext(userDataDir, playwright.BrowserTypeLaunchPersistentContextOptions{ - Headless: playwright.Bool(headless), - Args: chromiumLaunchArgs(), - UserAgent: playwright.String(defaultUA), - Viewport: &playwright.Size{Width: 1980, Height: 1024}, - Locale: playwright.String(defaultLang), - TimezoneId: playwright.String(defaultTZ), + Headless: playwright.Bool(headless), + Args: chromiumLaunchArgs(), + ExecutablePath: chromiumExecutablePath(), + UserAgent: playwright.String(defaultUA), + Viewport: &playwright.Size{Width: 1980, Height: 1024}, + Locale: playwright.String(defaultLang), + TimezoneId: playwright.String(defaultTZ), }) if err != nil { return nil, fmt.Errorf("启动持久化浏览器失败: %w", err) @@ -73,11 +90,32 @@ func (m *Manager) PasswordLogin(ctx context.Context, account, password, cookieID return extractPageCookies(page) } + if clickQuickEnter(page) { + m.logger.Info("密码登录:已点击[快速进入],等待页面刷新", "cookieID", cookieID) + time.Sleep(quickRenewAfterClick) + cookies, err := extractPageCookies(page) + if err == nil && quickEnterCookiesUsable(cookies) { + m.logger.Info("密码登录:快速进入成功,跳过账号密码输入", "cookieID", cookieID) + return cookies, nil + } + m.logger.Info("密码登录:快速进入未获取到有效 Cookie,继续账号密码登录", "cookieID", cookieID) + if _, err := page.Goto(goofishIMURL, playwright.PageGotoOptions{ + WaitUntil: playwright.WaitUntilStateDomcontentloaded, + Timeout: playwright.Float(30000), + }); err != nil { + m.logger.Warn("密码登录:快速进入失败后重新访问 IM 页面异常", "cookieID", cookieID, "err", err) + } + time.Sleep(2 * time.Second) + } + // 在主页和所有 iframe 中找登录表单。 idEl, pwdEl, submitEl := findLoginForm(page) if idEl == nil { return nil, fmt.Errorf("未找到登录表单,可能页面结构已变更") } + if pwdEl == nil { + return nil, fmt.Errorf("未找到密码输入框,可能页面结构已变更") + } if err := idEl.Click(); err == nil { _ = page.Fill(getCSSSelector(idEl, loginIDSelectors), account) @@ -108,30 +146,170 @@ func (m *Manager) PasswordLogin(ctx context.Context, account, password, cookieID } if !checkLoginSuccess(page) { - // 采集错误信息。 - errMsg := "" - if el, err := page.QuerySelector(".login-error-msg"); err == nil && el != nil { - errMsg, _ = el.TextContent() - } - if errMsg == "" { - c, _ := page.Content() - for _, kw := range []string{"账密错误", "账号密码错误", "用户名或密码错误", "密码错误"} { - if strings.Contains(c, kw) { - errMsg = kw - break - } - } - } - if errMsg == "" { - errMsg = "登录失败" - } - return nil, fmt.Errorf("密码登录失败: %s", errMsg) + return m.handlePasswordLoginPending(ctx, page, onEvent) } m.logger.Info("密码登录成功", "cookieID", cookieID) return extractPageCookies(page) } +func quickEnterCookiesUsable(cookies map[string]string) bool { + if len(cookies) == 0 { + return false + } + return strings.TrimSpace(cookies["unb"]) != "" +} + +func (m *Manager) handlePasswordLoginPending(ctx context.Context, page playwright.Page, onEvent PasswordLoginEventHandler) (map[string]string, error) { + if msg := passwordLoginErrorFromPage(page); msg != "" { + if onEvent != nil { + onEvent(PasswordLoginEventFromMessage(msg)) + } + return nil, fmt.Errorf("密码登录失败: %s", msg) + } + if event, ok := passwordBaxiaEventFromPage(page); ok { + if onEvent != nil { + onEvent(event) + } + return nil, fmt.Errorf("密码登录失败: %s", event.Message) + } + if event, ok := passwordVerificationEventFromPage(page); ok { + if onEvent != nil { + onEvent(event) + } + cookies, err := waitPasswordVerification(ctx, page, onEvent) + if err == nil { + m.logger.Info("密码登录人工验证完成") + return cookies, nil + } + return nil, err + } + errMsg := "登录失败" + if onEvent != nil { + onEvent(PasswordLoginEventFromMessage(errMsg)) + } + return nil, fmt.Errorf("密码登录失败: %s", errMsg) +} + +func waitPasswordVerification(ctx context.Context, page playwright.Page, onEvent PasswordLoginEventHandler) (map[string]string, error) { + ticker := time.NewTicker(passwordVerificationWaitInterval) + defer ticker.Stop() + timer := time.NewTimer(passwordVerificationMaxWait) + defer timer.Stop() + for { + select { + case <-ctx.Done(): + return nil, ctx.Err() + case <-timer.C: + return nil, fmt.Errorf("密码登录失败: 人工验证超时") + case <-ticker.C: + } + if checkLoginSuccess(page) { + return extractPageCookies(page) + } + if msg := passwordLoginErrorFromPage(page); msg != "" { + return nil, fmt.Errorf("密码登录失败: %s", msg) + } + if event, ok := passwordBaxiaEventFromPage(page); ok { + return nil, fmt.Errorf("密码登录失败: %s", event.Message) + } + if event, ok := passwordVerificationEventFromPage(page); ok && onEvent != nil { + onEvent(event) + } + } +} + +func passwordLoginErrorFromPage(page playwright.Page) string { + if el, err := page.QuerySelector(".login-error-msg"); err == nil && el != nil { + if msg, _ := el.TextContent(); strings.TrimSpace(msg) != "" { + return strings.TrimSpace(msg) + } + } + for _, htmlText := range passwordLoginHTMLs(page) { + if msg := detectPasswordLoginErrorHTML(htmlText); msg != "" { + return msg + } + } + return "" +} + +func passwordBaxiaEventFromPage(page playwright.Page) (PasswordLoginEvent, bool) { + for _, htmlText := range passwordLoginHTMLs(page) { + if event, ok := detectPasswordBaxiaPunishHTML(htmlText); ok { + return event, true + } + } + return PasswordLoginEvent{}, false +} + +func passwordVerificationEventFromPage(page playwright.Page) (PasswordLoginEvent, bool) { + if event, ok := passwordVerificationEventFromContent(pageContent(page), page.URL()); ok { + event.ScreenshotPath = firstNonEmptyString(event.ScreenshotPath, passwordVerificationScreenshot(page)) + return event, true + } + for _, frame := range page.Frames() { + if event, ok := passwordVerificationEventFromContent(frameContent(frame), frame.URL()); ok { + event.ScreenshotPath = firstNonEmptyString(event.ScreenshotPath, passwordVerificationScreenshot(page)) + return event, true + } + } + return PasswordLoginEvent{}, false +} + +func passwordVerificationEventFromContent(htmlText, frameURL string) (PasswordLoginEvent, bool) { + event, ok := detectPasswordVerificationHTML(htmlText) + if !ok { + return PasswordLoginEvent{}, false + } + if event.VerificationURL == "" && looksLikeVerificationURL(frameURL) { + event.VerificationURL = frameURL + } + return event, true +} + +func passwordLoginHTMLs(page playwright.Page) []string { + htmls := []string{pageContent(page)} + for _, frame := range page.Frames() { + htmls = append(htmls, frameContent(frame)) + } + return htmls +} + +func pageContent(page playwright.Page) string { + content, _ := page.Content() + return content +} + +func frameContent(frame playwright.Frame) string { + content, _ := frame.Content() + return content +} + +func passwordVerificationScreenshot(page playwright.Page) string { + raw, err := page.Screenshot(playwright.PageScreenshotOptions{ + FullPage: playwright.Bool(true), + Timeout: playwright.Float(5000), + }) + if err != nil || len(raw) == 0 { + return "" + } + return "data:image/png;base64," + base64.StdEncoding.EncodeToString(raw) +} + +func looksLikeVerificationURL(raw string) bool { + lower := strings.ToLower(raw) + return containsAny(lower, "passport", "verify", "photo", "iv/", "identity", "login", "qrcode") +} + +func firstNonEmptyString(values ...string) string { + for _, value := range values { + if strings.TrimSpace(value) != "" { + return value + } + } + return "" +} + func checkLoginSuccess(page playwright.Page) bool { for _, sel := range loginSuccessSelectors { el, err := page.QuerySelector(sel) diff --git a/internal/browser/passwordlogin_detect.go b/internal/browser/passwordlogin_detect.go new file mode 100644 index 0000000..86420ae --- /dev/null +++ b/internal/browser/passwordlogin_detect.go @@ -0,0 +1,103 @@ +package browser + +import ( + "html" + "regexp" + "strings" +) + +var ( + htmlTagPattern = regexp.MustCompile(`(?is)<[^>]+>`) + scriptStylePattern = regexp.MustCompile(`(?is)]*>.*?|]*>.*?`) + verificationURLRe = regexp.MustCompile(`https?://[^\s"'<>\\]+`) + dataImageURLRe = regexp.MustCompile(`data:image/[^;"'\s<>]+;base64,[A-Za-z0-9+/=]+`) + escapedSlashPattern = strings.NewReplacer(`\/`, `/`, `\u0026`, `&`) +) + +func detectPasswordBaxiaPunishHTML(htmlText string) (PasswordLoginEvent, bool) { + if !IsBaxiaPunishMessage(htmlText) { + return PasswordLoginEvent{}, false + } + msg := "触发闲鱼风控图形验证(baxia-punish),账号正常但暂时无法自动登录" + return PasswordLoginEvent{ + Status: PasswordLoginStatusFailed, + Message: msg, + Error: msg, + Reason: "baxia_punish_captcha", + CooldownHours: 5, + }, true +} + +func detectPasswordLoginErrorHTML(htmlText string) string { + text := normalizeHTMLText(htmlText) + for _, keyword := range []string{ + "账密错误", "账号密码错误", "用户名或密码错误", "账号或密码错误", "密码错误", + "账号不存在", "账号已被冻结", "账号被冻结", "账户被冻结", "账号已锁定", "账户已锁定", + "操作过于频繁", "登录过于频繁", "暂时无法登录", + } { + if strings.Contains(text, keyword) { + return keyword + } + } + return "" +} + +func detectPasswordVerificationHTML(htmlText string) (PasswordLoginEvent, bool) { + normalized := normalizeHTMLText(htmlText) + lower := strings.ToLower(htmlText) + if !containsAny(normalized, + "人脸验证", "人脸识别", "身份验证", "安全验证", "扫码验证", "验证二维码", + "请使用手机", "请在手机", "请在浏览器中完成验证", + ) && !containsAny(lower, + "alibaba-login-box", "iframe_redirect", "iframeredirect", "photoverify", "iv/photoverify", + "verifyurl", "identity_verify", "normal_validate", "verifycode", "qrcode", + ) { + return PasswordLoginEvent{}, false + } + msg := "密码登录需要人工验证,请在浏览器中完成验证后等待自动继续" + event := PasswordLoginEvent{ + Status: PasswordLoginStatusVerificationRequired, + Message: msg, + Error: msg, + VerificationURL: extractPasswordVerificationURL(htmlText), + QRCodeURL: extractPasswordQRURL(htmlText), + } + return event, true +} + +func extractPasswordVerificationURL(htmlText string) string { + cleaned := escapedSlashPattern.Replace(html.UnescapeString(htmlText)) + matches := verificationURLRe.FindAllString(cleaned, -1) + for _, raw := range matches { + url := strings.TrimRight(raw, ".,);]") + lower := strings.ToLower(url) + if containsAny(lower, "passport", "verify", "photo", "iv/", "identity", "login", "qrcode") { + return url + } + } + return "" +} + +func extractPasswordQRURL(htmlText string) string { + cleaned := escapedSlashPattern.Replace(html.UnescapeString(htmlText)) + if match := dataImageURLRe.FindString(cleaned); match != "" { + return match + } + return "" +} + +func normalizeHTMLText(htmlText string) string { + cleaned := scriptStylePattern.ReplaceAllString(htmlText, " ") + cleaned = htmlTagPattern.ReplaceAllString(cleaned, " ") + cleaned = escapedSlashPattern.Replace(html.UnescapeString(cleaned)) + return strings.Join(strings.Fields(cleaned), " ") +} + +func containsAny(s string, keywords ...string) bool { + for _, keyword := range keywords { + if strings.Contains(s, keyword) { + return true + } + } + return false +} diff --git a/internal/browser/passwordlogin_detect_test.go b/internal/browser/passwordlogin_detect_test.go new file mode 100644 index 0000000..c5aec70 --- /dev/null +++ b/internal/browser/passwordlogin_detect_test.go @@ -0,0 +1,61 @@ +package browser + +import "testing" + +func TestDetectPasswordBaxiaPunishHTML(t *testing.T) { + html := `
请找两个松鼠
` + event, ok := detectPasswordBaxiaPunishHTML(html) + if !ok { + t.Fatal("应识别 baxia 图形验证") + } + if event.Status != PasswordLoginStatusFailed || event.Reason != "baxia_punish_captcha" || event.CooldownHours != 5 { + t.Fatalf("baxia 事件异常: %+v", event) + } +} + +func TestPasswordEventFromMessageDoesNotTreatFaceRiskAsBaxia(t *testing.T) { + event := PasswordLoginEventFromMessage("账号触发风控,需要人脸验证") + if event.Reason == "baxia_punish_captcha" { + t.Fatalf("普通人脸验证不应按 baxia 冷却: %+v", event) + } + if event.Status != PasswordLoginStatusVerificationRequired { + t.Fatalf("人脸验证应标记 verification_required: %+v", event) + } +} + +func TestDetectPasswordLoginErrorHTML(t *testing.T) { + msg := detectPasswordLoginErrorHTML(``) + if msg != "账号或密码错误" { + t.Fatalf("登录错误识别=%q", msg) + } + msg = detectPasswordLoginErrorHTML(`账号已被冻结,请联系平台`) + if msg != "账号已被冻结" { + t.Fatalf("冻结错误识别=%q", msg) + } +} + +func TestDetectPasswordVerificationHTML(t *testing.T) { + html := `
需要人脸验证,请使用手机扫码
` + event, ok := detectPasswordVerificationHTML(html) + if !ok { + t.Fatal("应识别人脸验证") + } + if event.Status != PasswordLoginStatusVerificationRequired { + t.Fatalf("验证状态异常: %+v", event) + } + if event.VerificationURL != "https://passport.goofish.com/iv/photoVerify/index.htm?token=abc" { + t.Fatalf("验证 URL 提取异常: %q", event.VerificationURL) + } +} + +func TestQuickEnterCookiesUsableRequiresUNB(t *testing.T) { + if quickEnterCookiesUsable(map[string]string{"_m_h5_tk": "tk"}) { + t.Fatal("快速进入未拿到 unb 不应视为成功") + } + if !quickEnterCookiesUsable(map[string]string{"unb": " 123 "}) { + t.Fatal("快速进入拿到 unb 应视为成功") + } + if quickEnterCookiesUsable(nil) { + t.Fatal("空 Cookie 不应视为成功") + } +} diff --git a/internal/browser/passwordlogin_events.go b/internal/browser/passwordlogin_events.go new file mode 100644 index 0000000..951be1b --- /dev/null +++ b/internal/browser/passwordlogin_events.go @@ -0,0 +1,54 @@ +package browser + +import "strings" + +const ( + PasswordLoginStatusProcessing = "processing" + PasswordLoginStatusVerificationRequired = "verification_required" + PasswordLoginStatusFailed = "failed" +) + +// PasswordLoginEvent 描述密码登录过程中的中间状态,供 HTTP 会话轮询接口展示。 +type PasswordLoginEvent struct { + Status string + Message string + Error string + Reason string + VerificationURL string + ScreenshotPath string + QRCodeURL string + CooldownHours int +} + +type PasswordLoginEventHandler func(PasswordLoginEvent) + +func PasswordLoginEventFromError(err error) PasswordLoginEvent { + if err == nil { + return PasswordLoginEvent{} + } + return PasswordLoginEventFromMessage(err.Error()) +} + +func PasswordLoginEventFromMessage(msg string) PasswordLoginEvent { + lower := strings.ToLower(msg) + event := PasswordLoginEvent{Status: PasswordLoginStatusFailed, Message: msg, Error: msg} + switch { + case IsBaxiaPunishMessage(msg) || (strings.Contains(msg, "风控") && strings.Contains(msg, "图形验证")): + event.Reason = "baxia_punish_captcha" + event.CooldownHours = 5 + case strings.Contains(msg, "人脸") || strings.Contains(lower, "verification") || strings.Contains(lower, "captcha"): + event.Status = PasswordLoginStatusVerificationRequired + } + return event +} + +func IsBaxiaPunishMessage(msg string) bool { + lower := strings.ToLower(msg) + return strings.Contains(lower, "baxia") || + strings.Contains(lower, "punish") || + strings.Contains(lower, "scratch-captcha") || + strings.Contains(lower, "captcha-question") || + strings.Contains(lower, "scratch-captcha-container") || + strings.Contains(msg, "找两个") || + strings.Contains(msg, "松鼠") +} diff --git a/internal/browser/passwordlogin_events_test.go b/internal/browser/passwordlogin_events_test.go new file mode 100644 index 0000000..16e63e9 --- /dev/null +++ b/internal/browser/passwordlogin_events_test.go @@ -0,0 +1,37 @@ +package browser + +import ( + "errors" + "testing" +) + +func TestPasswordLoginEventFromErrorVerification(t *testing.T) { + event := PasswordLoginEventFromError(errors.New("需要人脸验证")) + if event.Status != PasswordLoginStatusVerificationRequired { + t.Fatalf("status=%q want verification_required", event.Status) + } +} + +func TestPasswordLoginEventFromErrorBaxia(t *testing.T) { + event := PasswordLoginEventFromError(errors.New("baxia-punish verification 风控图形验证")) + if event.Status != PasswordLoginStatusFailed || event.Reason != "baxia_punish_captcha" || event.CooldownHours != 5 { + t.Fatalf("event=%+v", event) + } +} + +func TestIsBaxiaPunishMessage(t *testing.T) { + for _, msg := range []string{"baxia-punish", "scratch-captcha-container", "找两个松鼠"} { + if !IsBaxiaPunishMessage(msg) { + t.Fatalf("%q should be recognized as baxia punish", msg) + } + } + if PasswordLoginEventFromMessage("触发风控图形验证").Reason != "baxia_punish_captcha" { + t.Fatal("明确的风控图形验证应按 baxia 冷却") + } + if IsBaxiaPunishMessage("用户名或密码错误") { + t.Fatal("ordinary password error should not be recognized as baxia") + } + if IsBaxiaPunishMessage("触发风控,需要人脸验证") { + t.Fatal("ordinary face verification should not be recognized as baxia") + } +} diff --git a/internal/browser/pure_extra_test.go b/internal/browser/pure_extra_test.go index ec37291..29418f6 100644 --- a/internal/browser/pure_extra_test.go +++ b/internal/browser/pure_extra_test.go @@ -1,16 +1,14 @@ package browser -import ( - "testing" -) +import "testing" // TestSanitize 特殊字符替换为下划线(用于 userDataDir 命名)。 func TestSanitize(t *testing.T) { cases := map[string]string{ - "acc_1": "acc_1", - "acc/1:2 3": "acc_1_2_3", - `a\b:c d`: "a_b_c_d", - "": "", + "acc_1": "acc_1", + "acc/1:2 3": "acc_1_2_3", + `a\b:c d`: "a_b_c_d", + "": "", } for in, want := range cases { if got := sanitize(in); got != want { @@ -31,6 +29,81 @@ func TestGetCSSSelector(t *testing.T) { } } +func TestPureUserIDMatchesReferenceRule(t *testing.T) { + cases := map[string]string{ + "foo_1234567890": "foo", + "foo_bar_1234567890": "foo_bar", + "foo_123": "foo_123", + "foo": "foo", + "": "unknown", + "foo/bar_1234567890": "foo_bar", + } + for in, want := range cases { + if got := pureUserID(in); got != want { + t.Fatalf("pureUserID(%q)=%q want %q", in, got, want) + } + } +} + +func TestQuickRenewHeadlessUsesArgumentUnlessEnvOverrides(t *testing.T) { + t.Setenv("BROWSER_HEADLESS", "") + if !quickRenewHeadless(true) { + t.Fatal("未设置环境变量时应使用传入的 headless=true") + } + if quickRenewHeadless(false) { + t.Fatal("未设置环境变量时应使用传入的 headless=false") + } + t.Setenv("BROWSER_HEADLESS", "true") + if !quickRenewHeadless(false) { + t.Fatal("BROWSER_HEADLESS=true 时应使用 headless") + } + t.Setenv("BROWSER_HEADLESS", "false") + if quickRenewHeadless(true) { + t.Fatal("BROWSER_HEADLESS=false 时应使用可视化浏览器") + } +} + +func TestCookiesRefreshHeadlessUsesAccountPreference(t *testing.T) { + t.Setenv("BROWSER_HEADLESS", "") + if !cookiesRefreshHeadless(true) { + t.Fatal("定时 COOKIES 续期应尊重 headless=true") + } + if cookiesRefreshHeadless(false) { + t.Fatal("show_browser=true 时定时 COOKIES 续期应使用可视化浏览器") + } + t.Setenv("BROWSER_HEADLESS", "true") + if !cookiesRefreshHeadless(false) { + t.Fatal("环境变量应仍可强制定时 COOKIES 续期 headless") + } +} + +func TestChromiumExecutablePathFromEnv(t *testing.T) { + t.Setenv("PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH", "") + if chromiumExecutablePath() != nil { + t.Fatal("未设置 PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH 时应返回 nil") + } + t.Setenv("PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH", " /usr/bin/chromium ") + got := chromiumExecutablePath() + if got == nil || *got != "/usr/bin/chromium" { + t.Fatalf("chromiumExecutablePath=%v", got) + } +} + +func TestSkipPlaywrightBrowserDownloadFromEnv(t *testing.T) { + t.Setenv("PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD", "") + if skipPlaywrightBrowserDownload() { + t.Fatal("默认不应跳过浏览器下载") + } + t.Setenv("PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD", "true") + if !skipPlaywrightBrowserDownload() { + t.Fatal("true 应跳过浏览器下载") + } + t.Setenv("PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD", "0") + if skipPlaywrightBrowserDownload() { + t.Fatal("0 不应跳过浏览器下载") + } +} + // TestCalculateSlideDistance_Fallback nil 轨道/按钮时走兜底距离。 func TestCalculateSlideDistance_Fallback(t *testing.T) { // 无 scratch:220-259。 @@ -44,4 +117,3 @@ func TestCalculateSlideDistance_Fallback(t *testing.T) { t.Fatalf("scratch 兜底应 55-91,got %v err=%v", dist, err) } } - diff --git a/internal/browser/qrrefresh.go b/internal/browser/qrrefresh.go index dcb6ec6..bb9e25a 100644 --- a/internal/browser/qrrefresh.go +++ b/internal/browser/qrrefresh.go @@ -26,8 +26,9 @@ func (m *Manager) QRCookieRefresh(ctx context.Context, tmpCookies, verificationU // QR 刷新不复用账号池:一次性上下文,注入临时 cookie,访问后提取。 browser, err := m.pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{ - Headless: playwright.Bool(true), - Args: chromiumLaunchArgs(), + Headless: playwright.Bool(true), + Args: chromiumLaunchArgs(), + ExecutablePath: chromiumExecutablePath(), }) if err != nil { return "", "", fmt.Errorf("启动 chromium 失败: %w", err) diff --git a/internal/db/account_login_logs.go b/internal/db/account_login_logs.go new file mode 100644 index 0000000..f56e490 --- /dev/null +++ b/internal/db/account_login_logs.go @@ -0,0 +1,69 @@ +package db + +import ( + "context" + "database/sql" +) + +// AccountLoginLogs 管理账号登录审计记录。 +type AccountLoginLogs struct { + DB *sql.DB +} + +// Add 写入一条账号登录审计记录。 +func (l *AccountLoginLogs) Add(ctx context.Context, log AccountLoginLog) error { + if log.AccountIdentifier == "" { + log.AccountIdentifier = log.CookieID + } + if log.OwnerID == 0 { + log.OwnerID = log.UserID + } + if log.ErrorMessage == "" { + log.ErrorMessage = log.Message + } + _, err := l.DB.ExecContext(ctx, + `INSERT INTO account_login_logs ( + cookie_id, user_id, owner_id, account_pk, account_identifier, + username, method, status, message, trigger_reason, failure_reason, + error_message, updated_cookie_names, duration_ms, created_at + ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, + log.CookieID, log.UserID, log.OwnerID, log.AccountPK, log.AccountIdentifier, + log.Username, log.Method, log.Status, log.Message, log.TriggerReason, log.FailureReason, + log.ErrorMessage, log.UpdatedCookieNames, log.DurationMS, log.CreatedAt) + return err +} + +// ListByCookie 按账号倒序读取登录审计记录。 +func (l *AccountLoginLogs) ListByCookie(ctx context.Context, cookieID string, limit int) ([]AccountLoginLog, error) { + if limit <= 0 { + limit = 20 + } + rows, err := l.DB.QueryContext(ctx, + `SELECT id, cookie_id, user_id, COALESCE(owner_id,0), COALESCE(account_pk,0), + COALESCE(account_identifier,''), COALESCE(username,''), method, status, + COALESCE(message,''), COALESCE(trigger_reason,''), COALESCE(failure_reason,''), + COALESCE(error_message,''), COALESCE(updated_cookie_names,''), COALESCE(duration_ms,0), + created_at + FROM account_login_logs + WHERE cookie_id=? + ORDER BY created_at DESC, id DESC + LIMIT ?`, cookieID, limit) + if err != nil { + return nil, err + } + defer rows.Close() + var out []AccountLoginLog + for rows.Next() { + var log AccountLoginLog + if err := rows.Scan( + &log.ID, &log.CookieID, &log.UserID, &log.OwnerID, &log.AccountPK, + &log.AccountIdentifier, &log.Username, &log.Method, &log.Status, + &log.Message, &log.TriggerReason, &log.FailureReason, &log.ErrorMessage, + &log.UpdatedCookieNames, &log.DurationMS, &log.CreatedAt, + ); err != nil { + return nil, err + } + out = append(out, log) + } + return out, rows.Err() +} diff --git a/internal/db/automation.go b/internal/db/automation.go index c76fed8..8685a2c 100644 --- a/internal/db/automation.go +++ b/internal/db/automation.go @@ -98,7 +98,7 @@ type AutomationActionInput struct { func (a *AutomationRules) ListForUser(ctx context.Context, userID int64) ([]AutomationRule, error) { rows, err := a.DB.QueryContext(ctx, ` SELECT r.id,r.user_id,r.cookie_id,r.item_id,COALESCE(i.item_title,''),r.name,r.trigger_type,r.enabled, - r.priority,r.config_json,COALESCE(r.created_at,''),COALESCE(r.updated_at,'') + r.priority,r.config_json,r.created_at,r.updated_at FROM automation_rules r LEFT JOIN item_info i ON i.cookie_id=r.cookie_id AND i.item_id=r.item_id WHERE r.user_id=? @@ -130,7 +130,7 @@ SELECT r.id,r.user_id,r.cookie_id,r.item_id,COALESCE(i.item_title,''),r.name,r.t func (a *AutomationRules) Match(ctx context.Context, cookieID, itemID, triggerType string) ([]AutomationRule, error) { rows, err := a.DB.QueryContext(ctx, ` SELECT r.id,r.user_id,r.cookie_id,r.item_id,COALESCE(i.item_title,''),r.name,r.trigger_type,r.enabled, - r.priority,r.config_json,COALESCE(r.created_at,''),COALESCE(r.updated_at,'') + r.priority,r.config_json,r.created_at,r.updated_at FROM automation_rules r LEFT JOIN item_info i ON i.cookie_id=r.cookie_id AND i.item_id=r.item_id WHERE r.enabled=1 @@ -322,7 +322,7 @@ SELECT order_id,item_id,buyer_id,spec_name,spec_value,quantity,amount,order_stat receiver_name,receiver_phone,receiver_address,receiver_city,version,chat_id,system_shipped, COALESCE(paid_at,''),COALESCE(shipped_at,''),COALESCE(completed_at,''), COALESCE(buyer_reviewed_at,''),COALESCE(last_review_request_at,''),review_request_count, - COALESCE(created_at,''),COALESCE(updated_at,'') + created_at,updated_at FROM orders WHERE system_shipped=1 AND COALESCE(buyer_reviewed_at,'')='' diff --git a/internal/db/cookies.go b/internal/db/cookies.go index 2ef43ba..bcc2c86 100644 --- a/internal/db/cookies.go +++ b/internal/db/cookies.go @@ -108,11 +108,15 @@ func (c *Cookies) GetDetails(ctx context.Context, cookieID string) (*CookieDetai var autoConfirm, showBrowser int var pauseDuration sql.NullInt64 err := c.DB.QueryRowContext(ctx, - `SELECT id, value, user_id, auto_confirm, remark, pause_duration, username, password, - show_browser, COALESCE(nickname,''), COALESCE(avatar_url,''), created_at + `SELECT id, value, user_id, auto_confirm, COALESCE(remark,''), pause_duration, + COALESCE(username,''), COALESCE(password,''), + show_browser, COALESCE(nickname,''), COALESCE(avatar_url,''), + COALESCE(metadata_json,''), COALESCE(last_refresh_at,0), + COALESCE(login_method,''), COALESCE(last_login_at,0), created_at FROM cookies WHERE id=?`, cookieID).Scan( &d.ID, &d.Value, &d.UserID, &autoConfirm, &d.Remark, &pauseDuration, - &d.Username, &d.Password, &showBrowser, &d.Nickname, &d.AvatarURL, &d.CreatedAt) + &d.Username, &d.Password, &showBrowser, &d.Nickname, &d.AvatarURL, + &d.MetadataJSON, &d.LastRefreshAt, &d.LoginMethod, &d.LastLoginAt, &d.CreatedAt) if err != nil { if errors.Is(err, sql.ErrNoRows) { return nil, ErrNotFound @@ -129,6 +133,30 @@ func (c *Cookies) GetDetails(ctx context.Context, cookieID string) (*CookieDetai return &d, nil } +// UpdateLoginInfo 保存账号密码登录资料。 +func (c *Cookies) UpdateLoginInfo(ctx context.Context, cookieID, username, password string, showBrowser bool) error { + v := 0 + if showBrowser { + v = 1 + } + _, err := c.DB.ExecContext(ctx, + `UPDATE cookies + SET username=?, password=?, show_browser=?, updated_at=CURRENT_TIMESTAMP + WHERE id=?`, + username, password, v, cookieID) + return err +} + +// MarkLogin 记录账号最近一次成功登录方式。 +func (c *Cookies) MarkLogin(ctx context.Context, cookieID, method string, loginAt int64) error { + _, err := c.DB.ExecContext(ctx, + `UPDATE cookies + SET login_method=?, last_login_at=?, updated_at=CURRENT_TIMESTAMP + WHERE id=?`, + method, loginAt, cookieID) + return err +} + // UpdateProfile 保存账号展示资料。 func (c *Cookies) UpdateProfile(ctx context.Context, cookieID, nickname, avatarURL string) error { _, err := c.DB.ExecContext(ctx, @@ -164,17 +192,23 @@ func (c *Cookies) GetAutoConfirm(ctx context.Context, cookieID string) (bool, er // SetStatus 启用/禁用账号(cookie_status 表)。 func (c *Cookies) SetStatus(ctx context.Context, cookieID string, enabled bool) error { + return c.SetStatusWithReason(ctx, cookieID, enabled, "") +} + +// SetStatusWithReason 启用/禁用账号并记录禁用原因。 +func (c *Cookies) SetStatusWithReason(ctx context.Context, cookieID string, enabled bool, reason string) error { v := 0 if enabled { v = 1 } _, err := c.DB.ExecContext(ctx, - `INSERT INTO cookie_status (cookie_id, enabled, updated_at) VALUES (?, ?, CURRENT_TIMESTAMP)`+ + `INSERT INTO cookie_status (cookie_id, enabled, disable_reason, updated_at) VALUES (?, ?, ?, CURRENT_TIMESTAMP)`+ dialectUpsert(c.Dialect, []string{"cookie_id"}, map[string]string{ - "enabled": "EXCLUDED.enabled", - "updated_at": "CURRENT_TIMESTAMP", + "enabled": "EXCLUDED.enabled", + "disable_reason": "EXCLUDED.disable_reason", + "updated_at": "CURRENT_TIMESTAMP", }), - cookieID, v) + cookieID, v, reason) return err } diff --git a/internal/db/extras.go b/internal/db/extras.go index 6757501..46d5103 100644 --- a/internal/db/extras.go +++ b/internal/db/extras.go @@ -50,6 +50,30 @@ func (k *Keywords) Add(ctx context.Context, cookieID, keyword, reply, itemID, kw cookieID, keyword, reply, nullable(itemID), kwType, nullable(imageURL)) } +// ReplaceForCookie 覆盖某账号的全部关键词。 +func (k *Keywords) ReplaceForCookie(ctx context.Context, cookieID string, rows []KeywordRow) error { + tx, err := k.DB.BeginTx(ctx, nil) + if err != nil { + return err + } + defer tx.Rollback() + if _, err := tx.ExecContext(ctx, `DELETE FROM keywords WHERE cookie_id=?`, cookieID); err != nil { + return err + } + for _, row := range rows { + kwType := row.Type + if kwType == "" { + kwType = "text" + } + if _, err := tx.ExecContext(ctx, + `INSERT INTO keywords (cookie_id, keyword, reply, item_id, type, image_url) VALUES (?,?,?,?,?,?)`, + cookieID, row.Keyword, row.Reply, nullable(row.ItemID), kwType, nullable(row.ImageURL)); err != nil { + return err + } + } + return tx.Commit() +} + // DeleteByIndex 按索引(0-based,按 id 顺序)删除某账号的一个关键字。 func (k *Keywords) DeleteByIndex(ctx context.Context, cookieID string, index int) error { rows, err := k.DB.QueryContext(ctx, @@ -229,13 +253,13 @@ func (n *Notifications) SetBindings(ctx context.Context, cookieID string, channe return err } for _, channelID := range channelIDs { - var exists int + var exists bool if err := tx.QueryRowContext(ctx, `SELECT EXISTS(SELECT 1 FROM notification_channels WHERE id=? AND user_id=?)`, channelID, userID).Scan(&exists); err != nil { return err } - if exists == 0 { + if !exists { return ErrForbidden } } @@ -263,7 +287,8 @@ type SystemSettings struct { // Get 取单项设置。 func (s *SystemSettings) Get(ctx context.Context, key string) (string, error) { var v string - err := s.DB.QueryRowContext(ctx, `SELECT value FROM system_settings WHERE key=?`, key).Scan(&v) + keyCol := dialectQuote(s.Dialect, "key") + err := s.DB.QueryRowContext(ctx, `SELECT value FROM system_settings WHERE `+keyCol+`=?`, key).Scan(&v) if err != nil { if errors.Is(err, sql.ErrNoRows) { return "", nil @@ -275,7 +300,8 @@ func (s *SystemSettings) Get(ctx context.Context, key string) (string, error) { // All 取全部设置(key→value)。 func (s *SystemSettings) All(ctx context.Context) (map[string]string, error) { - rows, err := s.DB.QueryContext(ctx, `SELECT key, value FROM system_settings`) + keyCol := dialectQuote(s.Dialect, "key") + rows, err := s.DB.QueryContext(ctx, `SELECT `+keyCol+`, value FROM system_settings`) if err != nil { return nil, err } @@ -307,7 +333,7 @@ func (s *SystemSettings) Set(ctx context.Context, key, value string) error { // PublicSystemKeys 是公开设置键白名单(前端登录页等无需登录可读)。 var PublicSystemKeys = map[string]bool{ "theme_color": true, "registration_enabled": true, - "show_default_login_info": true, "login_captcha_enabled": true, + "show_default_login_info": true, } // Public 取公开设置子集。 diff --git a/internal/db/extras_test.go b/internal/db/extras_test.go index 7799ae9..926c64e 100644 --- a/internal/db/extras_test.go +++ b/internal/db/extras_test.go @@ -272,9 +272,8 @@ func TestSettings_Public(t *testing.T) { if _, ok := pub["qq_reply_secret_key"]; ok { t.Fatal("qq_reply_secret_key 不应外露") } - // 迁移默认就位的公开 key(login_captcha_enabled 等)应可见。 - if pub["login_captcha_enabled"] != "true" { - t.Fatalf("login_captcha_enabled 应为 true, got %q", pub["login_captcha_enabled"]) + if _, ok := pub["login_captcha_enabled"]; ok { + t.Fatal("未实现的登录验证码开关不应公开") } // 白名单内其它默认 key(show_default_login_info)也应可见。 if pub["show_default_login_info"] != "true" { @@ -305,6 +304,16 @@ func TestCookies_DeleteAndStatuses(t *testing.T) { if _, err := s.Cookies.GetDetails(ctx, "nope"); !errors.Is(err, ErrNotFound) { t.Fatalf("want ErrNotFound, got %v", err) } + if _, err := s.DB.ExecContext(ctx, `UPDATE cookies SET remark=NULL, username=NULL, password=NULL WHERE id=?`, cid); err != nil { + t.Fatalf("set nullable text fields: %v", err) + } + details, err := s.Cookies.GetDetails(ctx, cid) + if err != nil { + t.Fatalf("GetDetails should tolerate NULL text fields: %v", err) + } + if details.Remark != "" || details.Username != "" || details.Password != "" { + t.Fatalf("NULL text fields should decode as empty strings: %+v", details) + } // GetAutoConfirm 不存在 → ErrNotFound。 if _, err := s.Cookies.GetAutoConfirm(ctx, "nope"); !errors.Is(err, ErrNotFound) { diff --git a/internal/db/item_publish_batches.go b/internal/db/item_publish_batches.go index 5ff3730..966d775 100644 --- a/internal/db/item_publish_batches.go +++ b/internal/db/item_publish_batches.go @@ -107,7 +107,7 @@ func (b *ItemPublishBatches) Get(ctx context.Context, userID int64, id string) ( var out ItemPublishBatch err := b.DB.QueryRowContext(ctx, `SELECT id,user_id,default_cookie_id,filename,upload_dir,status,total_count,success_count,failed_count, - COALESCE(created_at,''),COALESCE(updated_at,'') + created_at,updated_at FROM item_publish_batches WHERE id=? AND user_id=?`, id, userID).Scan( &out.ID, &out.UserID, &out.DefaultCookieID, &out.Filename, &out.UploadDir, &out.Status, &out.TotalCount, &out.SuccessCount, &out.FailedCount, &out.CreatedAt, &out.UpdatedAt) @@ -125,7 +125,7 @@ func (b *ItemPublishBatches) Rows(ctx context.Context, batchID string) ([]ItemPu rows, err := b.DB.QueryContext(ctx, `SELECT id,batch_id,row_no,cookie_id,title,description,price,original_price,quantity,postage_mode,postage, images_json,COALESCE(automation_json,'{}'),status,item_id,item_url,error_message, - raw_json,COALESCE(created_at,''),COALESCE(updated_at,'') + raw_json,created_at,updated_at FROM item_publish_batch_rows WHERE batch_id=? ORDER BY row_no`, batchID) if err != nil { return nil, err @@ -154,7 +154,7 @@ func (b *ItemPublishBatches) PendingRows(ctx context.Context, batchID string, fa rows, err := b.DB.QueryContext(ctx, `SELECT id,batch_id,row_no,cookie_id,title,description,price,original_price,quantity,postage_mode,postage, images_json,COALESCE(automation_json,'{}'),status,item_id,item_url,error_message, - raw_json,COALESCE(created_at,''),COALESCE(updated_at,'') + raw_json,created_at,updated_at FROM item_publish_batch_rows WHERE batch_id=? AND status IN `+statuses+` ORDER BY row_no`, batchID) if err != nil { return nil, err @@ -221,6 +221,26 @@ func (b *ItemPublishBatches) MarkRowFailed(ctx context.Context, rowID int64, mes return err } +// MarkRunningFailed 将批次内仍在 running 的行标为失败。 +func (b *ItemPublishBatches) MarkRunningFailed(ctx context.Context, batchID, message string) error { + _, err := b.DB.ExecContext(ctx, + `UPDATE item_publish_batch_rows + SET status='failed',error_message=?,updated_at=CURRENT_TIMESTAMP + WHERE batch_id=? AND status='running'`, + message, batchID) + return err +} + +// MarkUnfinishedFailed 将批次内 pending/running 行标为失败。 +func (b *ItemPublishBatches) MarkUnfinishedFailed(ctx context.Context, batchID, message string) error { + _, err := b.DB.ExecContext(ctx, + `UPDATE item_publish_batch_rows + SET status='failed',error_message=?,updated_at=CURRENT_TIMESTAMP + WHERE batch_id=? AND status IN ('pending','running')`, + message, batchID) + return err +} + // ResetFailed 将批次内所有 failed 行重置为 pending,便于失败重试。 func (b *ItemPublishBatches) ResetFailed(ctx context.Context, batchID string) error { _, err := b.DB.ExecContext(ctx, diff --git a/internal/db/migrations/mysql/00011_renewal_scheduler.sql b/internal/db/migrations/mysql/00011_renewal_scheduler.sql new file mode 100644 index 0000000..0f8b97b --- /dev/null +++ b/internal/db/migrations/mysql/00011_renewal_scheduler.sql @@ -0,0 +1,47 @@ +-- +goose Up +ALTER TABLE cookies ADD COLUMN metadata_json TEXT; +ALTER TABLE cookies ADD COLUMN last_refresh_at BIGINT NOT NULL DEFAULT 0; +ALTER TABLE cookie_status ADD COLUMN disable_reason TEXT; + +CREATE TABLE IF NOT EXISTS cookie_refresh_schedules ( + cookie_id VARCHAR(191) PRIMARY KEY, + expire_at BIGINT NOT NULL DEFAULT 0, + disabled TINYINT(1) NOT NULL DEFAULT 0, + consecutive_failures INT NOT NULL DEFAULT 0, + last_error TEXT NOT NULL, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + CONSTRAINT fk_cookie_refresh_schedules_cookie FOREIGN KEY (cookie_id) REFERENCES cookies(id) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS scheduled_cookies_refresh_log ( + id BIGINT PRIMARY KEY AUTO_INCREMENT, + cookie_id VARCHAR(191) NOT NULL, + status VARCHAR(32) NOT NULL, + message TEXT NOT NULL, + updated_cookie_names TEXT NOT NULL, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE IF NOT EXISTS scheduled_login_renew_log ( + id BIGINT PRIMARY KEY AUTO_INCREMENT, + cookie_id VARCHAR(191) NOT NULL, + status VARCHAR(32) NOT NULL, + message TEXT NOT NULL, + updated_cookie_names TEXT NOT NULL, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE IF NOT EXISTS scheduled_api_cookie_renew_log ( + id BIGINT PRIMARY KEY AUTO_INCREMENT, + cookie_id VARCHAR(191) NOT NULL, + status VARCHAR(32) NOT NULL, + message TEXT NOT NULL, + updated_cookie_names TEXT NOT NULL, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +-- +goose Down +DROP TABLE IF EXISTS scheduled_api_cookie_renew_log; +DROP TABLE IF EXISTS scheduled_login_renew_log; +DROP TABLE IF EXISTS scheduled_cookies_refresh_log; +DROP TABLE IF EXISTS cookie_refresh_schedules; diff --git a/internal/db/migrations/mysql/00012_renewal_alignment.sql b/internal/db/migrations/mysql/00012_renewal_alignment.sql new file mode 100644 index 0000000..a24fd37 --- /dev/null +++ b/internal/db/migrations/mysql/00012_renewal_alignment.sql @@ -0,0 +1,20 @@ +-- +goose Up +ALTER TABLE cookie_refresh_schedules ADD COLUMN last_status VARCHAR(32); +ALTER TABLE cookie_refresh_schedules ADD COLUMN last_error_message TEXT; +ALTER TABLE cookie_refresh_schedules ADD COLUMN last_refresh_at BIGINT NOT NULL DEFAULT 0; + +ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN batch_id VARCHAR(36); +ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN updated_cookie_count INT NOT NULL DEFAULT 0; +ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN next_expire_at BIGINT NOT NULL DEFAULT 0; +ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN error_message TEXT; + +ALTER TABLE scheduled_login_renew_log ADD COLUMN batch_id VARCHAR(36); +ALTER TABLE scheduled_login_renew_log ADD COLUMN error_message TEXT; + +ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN batch_id VARCHAR(36); +ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN updated_cookie_count INT NOT NULL DEFAULT 0; +ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN response_content TEXT; +ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN error_message TEXT; + +-- +goose Down +SELECT 1; diff --git a/internal/db/migrations/mysql/00013_account_login_audit.sql b/internal/db/migrations/mysql/00013_account_login_audit.sql new file mode 100644 index 0000000..506b426 --- /dev/null +++ b/internal/db/migrations/mysql/00013_account_login_audit.sql @@ -0,0 +1,34 @@ +-- +goose Up +ALTER TABLE cookies ADD COLUMN login_method VARCHAR(32) NOT NULL DEFAULT ''; +ALTER TABLE cookies ADD COLUMN last_login_at BIGINT NOT NULL DEFAULT 0; + +CREATE TABLE IF NOT EXISTS account_login_logs ( + id BIGINT PRIMARY KEY AUTO_INCREMENT, + cookie_id VARCHAR(255) NOT NULL, + user_id BIGINT NOT NULL DEFAULT 0, + owner_id BIGINT NOT NULL DEFAULT 0, + account_pk BIGINT NOT NULL DEFAULT 0, + account_identifier VARCHAR(80) NOT NULL DEFAULT '', + username VARCHAR(255) NOT NULL DEFAULT '', + method VARCHAR(32) NOT NULL DEFAULT '', + status VARCHAR(32) NOT NULL, + message TEXT NOT NULL, + trigger_reason VARCHAR(128) NOT NULL DEFAULT '', + failure_reason VARCHAR(64) NOT NULL DEFAULT '', + error_message TEXT NOT NULL, + updated_cookie_names VARCHAR(500) NOT NULL DEFAULT '', + duration_ms BIGINT NOT NULL DEFAULT 0, + created_at BIGINT NOT NULL +); + +CREATE INDEX idx_account_login_logs_cookie_created + ON account_login_logs(cookie_id, created_at DESC); +CREATE INDEX idx_account_login_logs_identifier_status_created + ON account_login_logs(account_identifier, status, created_at DESC); +CREATE INDEX idx_account_login_logs_owner_created + ON account_login_logs(owner_id, created_at DESC); + +-- +goose Down +DROP TABLE IF EXISTS account_login_logs; +ALTER TABLE cookies DROP COLUMN last_login_at; +ALTER TABLE cookies DROP COLUMN login_method; diff --git a/internal/db/migrations/postgres/00011_renewal_scheduler.sql b/internal/db/migrations/postgres/00011_renewal_scheduler.sql new file mode 100644 index 0000000..589bd7f --- /dev/null +++ b/internal/db/migrations/postgres/00011_renewal_scheduler.sql @@ -0,0 +1,46 @@ +-- +goose Up +ALTER TABLE cookies ADD COLUMN metadata_json TEXT DEFAULT ''; +ALTER TABLE cookies ADD COLUMN last_refresh_at BIGINT NOT NULL DEFAULT 0; +ALTER TABLE cookie_status ADD COLUMN disable_reason TEXT DEFAULT ''; + +CREATE TABLE IF NOT EXISTS cookie_refresh_schedules ( + cookie_id TEXT PRIMARY KEY REFERENCES cookies(id) ON DELETE CASCADE, + expire_at BIGINT NOT NULL DEFAULT 0, + disabled INTEGER NOT NULL DEFAULT 0, + consecutive_failures INTEGER NOT NULL DEFAULT 0, + last_error TEXT NOT NULL DEFAULT '', + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE IF NOT EXISTS scheduled_cookies_refresh_log ( + id BIGSERIAL PRIMARY KEY, + cookie_id TEXT NOT NULL, + status TEXT NOT NULL, + message TEXT NOT NULL DEFAULT '', + updated_cookie_names TEXT NOT NULL DEFAULT '', + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE IF NOT EXISTS scheduled_login_renew_log ( + id BIGSERIAL PRIMARY KEY, + cookie_id TEXT NOT NULL, + status TEXT NOT NULL, + message TEXT NOT NULL DEFAULT '', + updated_cookie_names TEXT NOT NULL DEFAULT '', + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE IF NOT EXISTS scheduled_api_cookie_renew_log ( + id BIGSERIAL PRIMARY KEY, + cookie_id TEXT NOT NULL, + status TEXT NOT NULL, + message TEXT NOT NULL DEFAULT '', + updated_cookie_names TEXT NOT NULL DEFAULT '', + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +-- +goose Down +DROP TABLE IF EXISTS scheduled_api_cookie_renew_log; +DROP TABLE IF EXISTS scheduled_login_renew_log; +DROP TABLE IF EXISTS scheduled_cookies_refresh_log; +DROP TABLE IF EXISTS cookie_refresh_schedules; diff --git a/internal/db/migrations/postgres/00012_renewal_alignment.sql b/internal/db/migrations/postgres/00012_renewal_alignment.sql new file mode 100644 index 0000000..5351764 --- /dev/null +++ b/internal/db/migrations/postgres/00012_renewal_alignment.sql @@ -0,0 +1,20 @@ +-- +goose Up +ALTER TABLE cookie_refresh_schedules ADD COLUMN last_status TEXT DEFAULT ''; +ALTER TABLE cookie_refresh_schedules ADD COLUMN last_error_message TEXT DEFAULT ''; +ALTER TABLE cookie_refresh_schedules ADD COLUMN last_refresh_at BIGINT NOT NULL DEFAULT 0; + +ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN batch_id TEXT DEFAULT ''; +ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN updated_cookie_count INTEGER NOT NULL DEFAULT 0; +ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN next_expire_at BIGINT NOT NULL DEFAULT 0; +ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN error_message TEXT DEFAULT ''; + +ALTER TABLE scheduled_login_renew_log ADD COLUMN batch_id TEXT DEFAULT ''; +ALTER TABLE scheduled_login_renew_log ADD COLUMN error_message TEXT DEFAULT ''; + +ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN batch_id TEXT DEFAULT ''; +ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN updated_cookie_count INTEGER NOT NULL DEFAULT 0; +ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN response_content TEXT DEFAULT ''; +ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN error_message TEXT DEFAULT ''; + +-- +goose Down +SELECT 1; diff --git a/internal/db/migrations/postgres/00013_account_login_audit.sql b/internal/db/migrations/postgres/00013_account_login_audit.sql new file mode 100644 index 0000000..99e1ba9 --- /dev/null +++ b/internal/db/migrations/postgres/00013_account_login_audit.sql @@ -0,0 +1,37 @@ +-- +goose Up +ALTER TABLE cookies ADD COLUMN login_method TEXT NOT NULL DEFAULT ''; +ALTER TABLE cookies ADD COLUMN last_login_at BIGINT NOT NULL DEFAULT 0; + +CREATE TABLE IF NOT EXISTS account_login_logs ( + id BIGSERIAL PRIMARY KEY, + cookie_id TEXT NOT NULL, + user_id BIGINT NOT NULL DEFAULT 0, + owner_id BIGINT NOT NULL DEFAULT 0, + account_pk BIGINT NOT NULL DEFAULT 0, + account_identifier TEXT NOT NULL DEFAULT '', + username TEXT NOT NULL DEFAULT '', + method TEXT NOT NULL DEFAULT '', + status TEXT NOT NULL, + message TEXT NOT NULL DEFAULT '', + trigger_reason TEXT NOT NULL DEFAULT '', + failure_reason TEXT NOT NULL DEFAULT '', + error_message TEXT NOT NULL DEFAULT '', + updated_cookie_names TEXT NOT NULL DEFAULT '', + duration_ms BIGINT NOT NULL DEFAULT 0, + created_at BIGINT NOT NULL +); + +CREATE INDEX IF NOT EXISTS idx_account_login_logs_cookie_created + ON account_login_logs(cookie_id, created_at DESC); +CREATE INDEX IF NOT EXISTS idx_account_login_logs_identifier_status_created + ON account_login_logs(account_identifier, status, created_at DESC); +CREATE INDEX IF NOT EXISTS idx_account_login_logs_owner_created + ON account_login_logs(owner_id, created_at DESC); + +-- +goose Down +DROP INDEX IF EXISTS idx_account_login_logs_owner_created; +DROP INDEX IF EXISTS idx_account_login_logs_identifier_status_created; +DROP INDEX IF EXISTS idx_account_login_logs_cookie_created; +DROP TABLE IF EXISTS account_login_logs; +ALTER TABLE cookies DROP COLUMN IF EXISTS last_login_at; +ALTER TABLE cookies DROP COLUMN IF EXISTS login_method; diff --git a/internal/db/migrations/sqlite/00011_renewal_scheduler.sql b/internal/db/migrations/sqlite/00011_renewal_scheduler.sql new file mode 100644 index 0000000..1230fe6 --- /dev/null +++ b/internal/db/migrations/sqlite/00011_renewal_scheduler.sql @@ -0,0 +1,47 @@ +-- +goose Up +ALTER TABLE cookies ADD COLUMN metadata_json TEXT DEFAULT ''; +ALTER TABLE cookies ADD COLUMN last_refresh_at INTEGER DEFAULT 0; +ALTER TABLE cookie_status ADD COLUMN disable_reason TEXT DEFAULT ''; + +CREATE TABLE IF NOT EXISTS cookie_refresh_schedules ( + cookie_id TEXT PRIMARY KEY, + expire_at INTEGER NOT NULL DEFAULT 0, + disabled INTEGER NOT NULL DEFAULT 0, + consecutive_failures INTEGER NOT NULL DEFAULT 0, + last_error TEXT NOT NULL DEFAULT '', + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (cookie_id) REFERENCES cookies(id) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS scheduled_cookies_refresh_log ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + cookie_id TEXT NOT NULL, + status TEXT NOT NULL, + message TEXT NOT NULL DEFAULT '', + updated_cookie_names TEXT NOT NULL DEFAULT '', + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE IF NOT EXISTS scheduled_login_renew_log ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + cookie_id TEXT NOT NULL, + status TEXT NOT NULL, + message TEXT NOT NULL DEFAULT '', + updated_cookie_names TEXT NOT NULL DEFAULT '', + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE IF NOT EXISTS scheduled_api_cookie_renew_log ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + cookie_id TEXT NOT NULL, + status TEXT NOT NULL, + message TEXT NOT NULL DEFAULT '', + updated_cookie_names TEXT NOT NULL DEFAULT '', + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +-- +goose Down +DROP TABLE IF EXISTS scheduled_api_cookie_renew_log; +DROP TABLE IF EXISTS scheduled_login_renew_log; +DROP TABLE IF EXISTS scheduled_cookies_refresh_log; +DROP TABLE IF EXISTS cookie_refresh_schedules; diff --git a/internal/db/migrations/sqlite/00012_renewal_alignment.sql b/internal/db/migrations/sqlite/00012_renewal_alignment.sql new file mode 100644 index 0000000..e65a2da --- /dev/null +++ b/internal/db/migrations/sqlite/00012_renewal_alignment.sql @@ -0,0 +1,20 @@ +-- +goose Up +ALTER TABLE cookie_refresh_schedules ADD COLUMN last_status TEXT DEFAULT ''; +ALTER TABLE cookie_refresh_schedules ADD COLUMN last_error_message TEXT DEFAULT ''; +ALTER TABLE cookie_refresh_schedules ADD COLUMN last_refresh_at INTEGER DEFAULT 0; + +ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN batch_id TEXT DEFAULT ''; +ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN updated_cookie_count INTEGER DEFAULT 0; +ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN next_expire_at INTEGER DEFAULT 0; +ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN error_message TEXT DEFAULT ''; + +ALTER TABLE scheduled_login_renew_log ADD COLUMN batch_id TEXT DEFAULT ''; +ALTER TABLE scheduled_login_renew_log ADD COLUMN error_message TEXT DEFAULT ''; + +ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN batch_id TEXT DEFAULT ''; +ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN updated_cookie_count INTEGER DEFAULT 0; +ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN response_content TEXT DEFAULT ''; +ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN error_message TEXT DEFAULT ''; + +-- +goose Down +SELECT 1; diff --git a/internal/db/migrations/sqlite/00013_account_login_audit.sql b/internal/db/migrations/sqlite/00013_account_login_audit.sql new file mode 100644 index 0000000..0c77047 --- /dev/null +++ b/internal/db/migrations/sqlite/00013_account_login_audit.sql @@ -0,0 +1,35 @@ +-- +goose Up +ALTER TABLE cookies ADD COLUMN login_method TEXT NOT NULL DEFAULT ''; +ALTER TABLE cookies ADD COLUMN last_login_at INTEGER NOT NULL DEFAULT 0; + +CREATE TABLE IF NOT EXISTS account_login_logs ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + cookie_id TEXT NOT NULL, + user_id INTEGER NOT NULL DEFAULT 0, + owner_id INTEGER NOT NULL DEFAULT 0, + account_pk INTEGER NOT NULL DEFAULT 0, + account_identifier TEXT NOT NULL DEFAULT '', + username TEXT NOT NULL DEFAULT '', + method TEXT NOT NULL DEFAULT '', + status TEXT NOT NULL, + message TEXT NOT NULL DEFAULT '', + trigger_reason TEXT NOT NULL DEFAULT '', + failure_reason TEXT NOT NULL DEFAULT '', + error_message TEXT NOT NULL DEFAULT '', + updated_cookie_names TEXT NOT NULL DEFAULT '', + duration_ms INTEGER NOT NULL DEFAULT 0, + created_at INTEGER NOT NULL +); + +CREATE INDEX IF NOT EXISTS idx_account_login_logs_cookie_created + ON account_login_logs(cookie_id, created_at DESC); +CREATE INDEX IF NOT EXISTS idx_account_login_logs_identifier_status_created + ON account_login_logs(account_identifier, status, created_at DESC); +CREATE INDEX IF NOT EXISTS idx_account_login_logs_owner_created + ON account_login_logs(owner_id, created_at DESC); + +-- +goose Down +DROP INDEX IF EXISTS idx_account_login_logs_owner_created; +DROP INDEX IF EXISTS idx_account_login_logs_identifier_status_created; +DROP INDEX IF EXISTS idx_account_login_logs_cookie_created; +DROP TABLE IF EXISTS account_login_logs; diff --git a/internal/db/models.go b/internal/db/models.go index 57f8d8f..2db51c9 100644 --- a/internal/db/models.go +++ b/internal/db/models.go @@ -35,5 +35,29 @@ type CookieDetail struct { ShowBrowser bool Nickname string AvatarURL string + MetadataJSON string + LastRefreshAt int64 + LoginMethod string + LastLoginAt int64 CreatedAt string } + +// AccountLoginLog 记录账号登录/续登尝试。 +type AccountLoginLog struct { + ID int64 + CookieID string + UserID int64 + OwnerID int64 + AccountPK int64 + AccountIdentifier string + Username string + Method string + Status string + Message string + TriggerReason string + FailureReason string + ErrorMessage string + UpdatedCookieNames string + DurationMS int64 + CreatedAt int64 +} diff --git a/internal/db/multidb_test.go b/internal/db/multidb_test.go index 9677634..7019375 100644 --- a/internal/db/multidb_test.go +++ b/internal/db/multidb_test.go @@ -180,6 +180,50 @@ func TestMultiDB_CookiesUpsertBool(t *testing.T) { } } +func TestMultiDB_SettingsQuoteKey(t *testing.T) { + for _, tg := range allTestTargets(t) { + t.Run(tg.name, func(t *testing.T) { + defer tg.cleanup() + ctx := context.Background() + s := tg.store + + if err := s.Settings.Set(ctx, "theme_color", "green"); err != nil { + t.Fatalf("Settings.Set: %v", err) + } + got, err := s.Settings.Get(ctx, "theme_color") + if err != nil || got != "green" { + t.Fatalf("Settings.Get=%q err=%v want green", got, err) + } + all, err := s.Settings.All(ctx) + if err != nil || all["theme_color"] != "green" { + t.Fatalf("Settings.All=%v err=%v", all, err) + } + + username := tg.name + "_settings_user_" + fmt.Sprintf("%d", atomic.AddUint64(&multidbCounter, 1)) + if ok, err := s.Users.Create(ctx, username, username+"@e.com", "pw"); err != nil || !ok { + t.Fatalf("create user: ok=%v err=%v", ok, err) + } + user, _ := s.Users.GetByUsername(ctx, username) + keyCol := dialectQuote(tg.dialect, "key") + if _, err := s.DB.ExecContext(ctx, + `INSERT INTO user_settings (user_id, `+keyCol+`, value, updated_at) VALUES (?,?,?,CURRENT_TIMESTAMP)`+ + dialectUpsert(tg.dialect, []string{"user_id", keyCol}, map[string]string{ + "value": "EXCLUDED.value", + "updated_at": "CURRENT_TIMESTAMP", + }), + user.ID, "dashboard_range", "30"); err != nil { + t.Fatalf("insert user_settings: %v", err) + } + var value string + if err := s.DB.QueryRowContext(ctx, + `SELECT value FROM user_settings WHERE user_id=? AND `+keyCol+`=?`, + user.ID, "dashboard_range").Scan(&value); err != nil || value != "30" { + t.Fatalf("select user_settings=%q err=%v want 30", value, err) + } + }) + } +} + // TestMultiDB_OrdersUpsertNullScan 验证订单部分字段 Upsert 后 Get 能正确扫描 NULL 列。 func TestMultiDB_OrdersUpsertNullScan(t *testing.T) { for _, tg := range allTestTargets(t) { diff --git a/internal/db/renewal.go b/internal/db/renewal.go new file mode 100644 index 0000000..9b29548 --- /dev/null +++ b/internal/db/renewal.go @@ -0,0 +1,236 @@ +package db + +import ( + "context" + "database/sql" + "errors" + "strings" + "time" +) + +// RenewalAccount 是续期调度所需的账号视图。 +type RenewalAccount struct { + ID string + Value string + UserID int64 + Enabled bool + Username string + Password string + ShowBrowser bool + MetadataJSON string + LastRefreshAt int64 +} + +// CookieRefreshSchedule 对应 cookie_refresh_schedules。 +type CookieRefreshSchedule struct { + CookieID string + ExpireAt int64 + Disabled bool + ConsecutiveFailures int + LastError string + LastStatus string + LastErrorMessage string + LastRefreshAt int64 +} + +// RenewalLog 是三类续期任务日志的通用写入模型。 +type RenewalLog struct { + BatchID string + CookieID string + Status string + Message string + ErrorMessage string + UpdatedCookieNames []string + UpdatedCookieCount int + ResponseContent string + NextExpireAt int64 +} + +// RenewalStore 保存续期任务计划与日志。 +type RenewalStore struct { + DB *sql.DB + Dialect Dialect +} + +// AllRenewalAccounts 返回所有账号,包含启用状态;浏览器 cookie 续期会用到禁用账号。 +func (c *Cookies) AllRenewalAccounts(ctx context.Context) ([]RenewalAccount, error) { + rows, err := c.DB.QueryContext(ctx, + `SELECT c.id, c.value, c.user_id, COALESCE(cs.enabled, 1), + COALESCE(c.username,''), COALESCE(c.password,''), COALESCE(c.show_browser,0), + COALESCE(c.metadata_json,''), COALESCE(c.last_refresh_at,0) + FROM cookies c + LEFT JOIN cookie_status cs ON cs.cookie_id = c.id + ORDER BY c.id`) + if err != nil { + return nil, err + } + defer rows.Close() + return scanRenewalAccounts(rows) +} + +// ActiveRenewalAccounts 返回启用账号,用于 WS/API 续期类任务。 +func (c *Cookies) ActiveRenewalAccounts(ctx context.Context) ([]RenewalAccount, error) { + rows, err := c.DB.QueryContext(ctx, + `SELECT c.id, c.value, c.user_id, COALESCE(cs.enabled, 1), + COALESCE(c.username,''), COALESCE(c.password,''), COALESCE(c.show_browser,0), + COALESCE(c.metadata_json,''), COALESCE(c.last_refresh_at,0) + FROM cookies c + LEFT JOIN cookie_status cs ON cs.cookie_id = c.id + WHERE COALESCE(cs.enabled, 1) <> 0 + ORDER BY c.id`) + if err != nil { + return nil, err + } + defer rows.Close() + return scanRenewalAccounts(rows) +} + +func scanRenewalAccounts(rows *sql.Rows) ([]RenewalAccount, error) { + var out []RenewalAccount + for rows.Next() { + var a RenewalAccount + var enabled, showBrowser int + if err := rows.Scan(&a.ID, &a.Value, &a.UserID, &enabled, &a.Username, &a.Password, &showBrowser, &a.MetadataJSON, &a.LastRefreshAt); err != nil { + return nil, err + } + a.Enabled = enabled != 0 + a.ShowBrowser = showBrowser != 0 + out = append(out, a) + } + return out, rows.Err() +} + +// UpdateRenewalCookie 保存续期后的 Cookie,同时写入浏览器快照和最后续期时间。 +func (c *Cookies) UpdateRenewalCookie(ctx context.Context, cookieID, cookieValue, metadataJSON string, lastRefreshAt int64) error { + if lastRefreshAt <= 0 { + lastRefreshAt = time.Now().Unix() + } + _, err := c.DB.ExecContext(ctx, + `UPDATE cookies + SET value=?, metadata_json=?, last_refresh_at=?, updated_at=CURRENT_TIMESTAMP + WHERE id=?`, + cookieValue, metadataJSON, lastRefreshAt, cookieID) + if err != nil { + return err + } + return nil +} + +// GetCookieRefreshSchedule 读取浏览器 Cookie 续期计划。 +func (r *RenewalStore) GetCookieRefreshSchedule(ctx context.Context, cookieID string) (*CookieRefreshSchedule, error) { + var s CookieRefreshSchedule + var disabled int + err := r.DB.QueryRowContext(ctx, + `SELECT cookie_id, expire_at, disabled, consecutive_failures, COALESCE(last_error,''), + COALESCE(last_status,''), COALESCE(last_error_message,''), COALESCE(last_refresh_at,0) + FROM cookie_refresh_schedules WHERE cookie_id=?`, cookieID). + Scan(&s.CookieID, &s.ExpireAt, &disabled, &s.ConsecutiveFailures, &s.LastError, + &s.LastStatus, &s.LastErrorMessage, &s.LastRefreshAt) + if err != nil { + if errors.Is(err, sql.ErrNoRows) { + return nil, ErrNotFound + } + return nil, err + } + s.Disabled = disabled != 0 + return &s, nil +} + +// UpsertCookieRefreshSchedule 写入浏览器 Cookie 续期计划。 +func (r *RenewalStore) UpsertCookieRefreshSchedule(ctx context.Context, s CookieRefreshSchedule) error { + disabled := 0 + if s.Disabled { + disabled = 1 + } + _, err := r.DB.ExecContext(ctx, + `INSERT INTO cookie_refresh_schedules + (cookie_id, expire_at, disabled, consecutive_failures, last_error, + last_status, last_error_message, last_refresh_at, updated_at) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)`+ + dialectUpsert(r.Dialect, []string{"cookie_id"}, map[string]string{ + "expire_at": "EXCLUDED.expire_at", + "disabled": "EXCLUDED.disabled", + "consecutive_failures": "EXCLUDED.consecutive_failures", + "last_error": "EXCLUDED.last_error", + "last_status": "EXCLUDED.last_status", + "last_error_message": "EXCLUDED.last_error_message", + "last_refresh_at": "EXCLUDED.last_refresh_at", + "updated_at": "CURRENT_TIMESTAMP", + }), + s.CookieID, s.ExpireAt, disabled, s.ConsecutiveFailures, s.LastError, + s.LastStatus, s.LastErrorMessage, s.LastRefreshAt) + return err +} + +// AddBrowserCookieRenewLog 记录浏览器 Cookie 续期日志。 +func (r *RenewalStore) AddBrowserCookieRenewLog(ctx context.Context, log RenewalLog) error { + if log.UpdatedCookieCount == 0 { + log.UpdatedCookieCount = len(log.UpdatedCookieNames) + } + _, err := r.DB.ExecContext(ctx, + `INSERT INTO scheduled_cookies_refresh_log + (batch_id, cookie_id, status, message, error_message, updated_cookie_names, + updated_cookie_count, next_expire_at, created_at) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)`, + log.BatchID, log.CookieID, log.Status, log.Message, firstNonEmpty(log.ErrorMessage, log.Message), + strings.Join(log.UpdatedCookieNames, ","), log.UpdatedCookieCount, log.NextExpireAt) + return err +} + +// AddLoginRenewLog 记录 login_renew 任务日志。 +func (r *RenewalStore) AddLoginRenewLog(ctx context.Context, log RenewalLog) error { + _, err := r.DB.ExecContext(ctx, + `INSERT INTO scheduled_login_renew_log + (batch_id, cookie_id, status, message, error_message, updated_cookie_names, created_at) + VALUES (?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)`, + log.BatchID, log.CookieID, log.Status, log.Message, firstNonEmpty(log.ErrorMessage, log.Message), + strings.Join(log.UpdatedCookieNames, ",")) + return err +} + +// AddAPICookieRenewLog 记录 api_cookie_renew 任务日志。 +func (r *RenewalStore) AddAPICookieRenewLog(ctx context.Context, log RenewalLog) error { + if log.UpdatedCookieCount == 0 { + log.UpdatedCookieCount = len(log.UpdatedCookieNames) + } + _, err := r.DB.ExecContext(ctx, + `INSERT INTO scheduled_api_cookie_renew_log + (batch_id, cookie_id, status, message, error_message, updated_cookie_names, + updated_cookie_count, response_content, created_at) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)`, + log.BatchID, log.CookieID, log.Status, log.Message, firstNonEmpty(log.ErrorMessage, log.Message), + strings.Join(log.UpdatedCookieNames, ","), log.UpdatedCookieCount, log.ResponseContent) + return err +} + +// RecentBrowserCookieRenewStatuses 返回最近 limit 条浏览器续期日志状态。 +func (r *RenewalStore) RecentBrowserCookieRenewStatuses(ctx context.Context, cookieID string, limit int) ([]string, error) { + if limit <= 0 { + return nil, nil + } + rows, err := r.DB.QueryContext(ctx, + `SELECT status FROM scheduled_cookies_refresh_log + WHERE cookie_id=? ORDER BY id DESC LIMIT ?`, cookieID, limit) + if err != nil { + return nil, err + } + defer rows.Close() + var statuses []string + for rows.Next() { + var status string + if err := rows.Scan(&status); err != nil { + return nil, err + } + statuses = append(statuses, status) + } + return statuses, rows.Err() +} + +func firstNonEmpty(values ...string) string { + for _, v := range values { + if strings.TrimSpace(v) != "" { + return v + } + } + return "" +} diff --git a/internal/db/repository_test.go b/internal/db/repository_test.go index dc15c03..33f3ac3 100644 --- a/internal/db/repository_test.go +++ b/internal/db/repository_test.go @@ -154,3 +154,47 @@ func TestCookieSaveRequiresInit(t *testing.T) { t.Fatalf("GetAutoConfirm=%v want false, err=%v", enabled, err) } } + +func TestCookieLoginAudit(t *testing.T) { + s, cleanup := newTestDB(t) + defer cleanup() + ctx := context.Background() + + if _, err := s.Users.Create(ctx, "admin", "a@e.com", "pw"); err != nil { + t.Fatalf("Create user: %v", err) + } + admin, _ := s.Users.GetByUsername(ctx, "admin") + if err := s.Cookies.Save(ctx, "cid", "cookievalue", admin.ID); err != nil { + t.Fatalf("Save cookie: %v", err) + } + if err := s.Cookies.UpdateLoginInfo(ctx, "cid", "login-user", "secret", true); err != nil { + t.Fatalf("UpdateLoginInfo: %v", err) + } + if err := s.Cookies.MarkLogin(ctx, "cid", "password", 12345); err != nil { + t.Fatalf("MarkLogin: %v", err) + } + d, err := s.Cookies.GetDetails(ctx, "cid") + if err != nil { + t.Fatalf("GetDetails: %v", err) + } + if d.Username != "login-user" || d.Password != "secret" || !d.ShowBrowser { + t.Fatalf("登录资料未保存: %+v", d) + } + if d.LoginMethod != "password" || d.LastLoginAt != 12345 { + t.Fatalf("登录审计字段异常: method=%q at=%d", d.LoginMethod, d.LastLoginAt) + } + + if err := s.LoginLogs.Add(ctx, AccountLoginLog{CookieID: "cid", UserID: admin.ID, Method: "password", Status: "failed", Message: "wrong", CreatedAt: 10}); err != nil { + t.Fatalf("Add log failed: %v", err) + } + if err := s.LoginLogs.Add(ctx, AccountLoginLog{CookieID: "cid", UserID: admin.ID, Method: "password", Status: "success", Message: "ok", CreatedAt: 20}); err != nil { + t.Fatalf("Add log success: %v", err) + } + logs, err := s.LoginLogs.ListByCookie(ctx, "cid", 10) + if err != nil { + t.Fatalf("ListByCookie: %v", err) + } + if len(logs) != 2 || logs[0].Status != "success" || logs[1].Status != "failed" { + t.Fatalf("登录日志排序/内容异常: %#v", logs) + } +} diff --git a/internal/db/store.go b/internal/db/store.go index 2613bb6..45450f5 100644 --- a/internal/db/store.go +++ b/internal/db/store.go @@ -22,6 +22,8 @@ type Store struct { WSMessages *WSMessageStore PublishBatches *ItemPublishBatches Tokens *AccountTokens + Renewal *RenewalStore + LoginLogs *AccountLoginLogs } // NewStore 基于 *sql.DB 构造聚合 store。dialect 用于业务 SQL 方言分支。 @@ -45,5 +47,7 @@ func NewStore(db *sql.DB, dialect Dialect) *Store { WSMessages: &WSMessageStore{DB: db}, PublishBatches: &ItemPublishBatches{DB: db}, Tokens: &AccountTokens{DB: db, Dialect: dialect}, + Renewal: &RenewalStore{DB: db, Dialect: dialect}, + LoginLogs: &AccountLoginLogs{DB: db}, } } diff --git a/internal/db/users.go b/internal/db/users.go index 6e7b26c..13faf6a 100644 --- a/internal/db/users.go +++ b/internal/db/users.go @@ -24,12 +24,12 @@ type Users struct { // IsSystemInitialized 系统是否已初始化(至少存在 admin 用户)。 // IsSystemInitialized 判断系统是否已有管理员账号。 func (u *Users) IsSystemInitialized(ctx context.Context) (bool, error) { - var exists int + var exists bool err := u.DB.QueryRowContext(ctx, `SELECT EXISTS(SELECT 1 FROM users WHERE is_admin=1)`).Scan(&exists) if err != nil { return false, fmt.Errorf("检查系统初始化: %w", err) } - return exists == 1, nil + return exists, nil } // GetAdmin 返回首个管理员账号。 @@ -143,12 +143,12 @@ func (u *Users) UpdateCredentials(ctx context.Context, userID int64, username, p } defer tx.Rollback() - var exists int + var exists bool if err := tx.QueryRowContext(ctx, `SELECT EXISTS(SELECT 1 FROM users WHERE username=? AND id<>?)`, username, userID).Scan(&exists); err != nil { return err } - if exists != 0 { + if exists { return ErrUsernameTaken } diff --git a/internal/engine/account.go b/internal/engine/account.go index a4dd649..dd61c00 100644 --- a/internal/engine/account.go +++ b/internal/engine/account.go @@ -31,17 +31,19 @@ const ( MessageExpireTime = time.Hour // 去重有效期 ProcessedIDsMaxSize = 10000 // 去重表上限,超限清理 HeartbeatInterval = 15 * time.Second - // token 心跳间隔。主动刷新 token 让服务端持续续期 cookie(_m_h5_tk / - // sgcookie 等),避免 cookie 自然滑向过期。15 分钟一次,平衡保活与风控。 - // 不宜过短,否则易触发阿里系滑块风控。 - TokenRefreshInterval = 15 * time.Minute - TokenRefreshMinGap = time.Minute - MessageCooldown = 5 * time.Minute // 收到消息后 5 分钟内不刷 cookie - PasswordLoginMinGap = 30 * time.Minute + // token_refresh_loop 与对方项目一致,默认 20 小时一次;在线保活主要由 + // cookieRefreshLoop 负责,每 180 秒刷新一次 Cookie/token。 + TokenRefreshInterval = 20 * time.Hour + CookieRefreshInterval = 180 * time.Second + CookieRefreshCheckInterval = 60 * time.Second + TokenRefreshMinGap = time.Minute + MessageCooldown = 5 * time.Minute // 收到消息后 5 分钟内不刷 cookie + PasswordLoginMinGap = 5 * time.Minute - // TokenCacheTTL 缓存的 accessToken 视为有效的时长。tokenRefreshLoop 每 15min - // 刷新一次会续期该缓存;短重启 / 瞬时 mtop 失败时回退到此缓存不掉线。 - TokenCacheTTL = 90 * time.Minute + // TokenCacheTTLMin/Max 控制缓存 accessToken 的随机有效期。短重启 / 瞬时 + // mtop 失败时回退到此缓存不掉线;在线 Cookie 保活由 cookieRefreshLoop 续期。 + TokenCacheTTLMin = 5 * time.Hour + TokenCacheTTLMax = 10 * time.Hour // ShortConnectionThreshold 连接维持不足此时长视为短连接,疑似 token 失效, // 清除 token 缓存下轮重新派生,避免反复用失效缓存 token。 ShortConnectionThreshold = 30 * time.Second @@ -120,11 +122,13 @@ type Account struct { // 运行时状态(受 mu 保护) mu sync.Mutex + refreshMu sync.Mutex currentToken string deviceID string connFailures int lastMsgReceived time.Time lastTokenRefresh time.Time + lastCookieRefresh time.Time lastPasswordLogin time.Time runtimeState string runtimeMessage string @@ -397,7 +401,7 @@ func (a *Account) Run(parent context.Context) error { a.mu.Unlock() a.setRuntimeState(RuntimeOnline, "消息服务连接正常") - // 3) 心跳 + 消息接收,并并行运行 token 定时刷新。 + // 3) 心跳 + 消息接收,并并行运行 token/cookie 定时刷新。 hbCtx, hbCancel := context.WithCancel(ctx) var hbErr error hbDone := make(chan struct{}) @@ -413,8 +417,15 @@ func (a *Account) Run(parent context.Context) error { close(refreshDone) }() + cookieRefreshDone := make(chan struct{}) + go func() { + a.cookieRefreshLoop(hbCtx, conn) + close(cookieRefreshDone) + }() + recvErr := conn.ReceiveLoop(ctx, a.dispatch) hbCancel() + <-cookieRefreshDone <-refreshDone <-hbDone // 确保 hbErr 写入完成后再读取(消除数据竞争)。 _ = conn.Close() @@ -576,8 +587,8 @@ func (a *Account) tryLoginStatusCheck(ctx context.Context) loginStatusCheckResul // tryAPIRenew 是密码登录前的轻量恢复层。 // 闲鱼很多“登录态滑向过期”的场景会先允许 hasLogin/silentHasLogin/ // setLoginSettings 刷新一批 Cookie;直接上密码登录更重,也更容易触发风控。 -// 因此这里先尝试接口续期:只要 Cookie 有变化就保存并清 token 缓存,让下一轮 -// acquireToken 用新 Cookie 重新派生 accessToken。 +// 因此这里先尝试接口续期:只有 setLoginSettings 确认成功才短路后续恢复; +// 如果只拿到部分 Cookie,仍会保存并清 token,但继续降级到浏览器/密码登录。 func (a *Account) tryAPIRenew(ctx context.Context) bool { if a.renewer == nil { return false @@ -590,23 +601,26 @@ func (a *Account) tryAPIRenew(ctx context.Context) bool { a.logger.Warn("接口续期失败", "err", err) return false } - if res == nil || res.NewCookies == "" || res.NewCookies == cookieStr { - if res != nil { - a.logger.Info("接口续期未产生 Cookie 更新", "success", res.Success, "message", res.Message) - } + if res == nil { return false } - if !a.adoptRecoveredCookie(ctx, res.NewCookies, "接口续期") { - return false + updated := false + if res.NewCookies != "" && res.NewCookies != cookieStr { + updated = a.adoptRecoveredCookie(ctx, res.NewCookies, "接口续期") } if res.Success { - a.setRuntimeState(RuntimeConnecting, "登录凭证已接口续期,正在重新连接") + if !updated { + a.setRuntimeState(RuntimeConnecting, "登录凭证已接口续期,正在重新连接") + } a.logger.Info("接口续期成功", "method", res.RenewMethod, "updated", strings.Join(res.UpdatedCookieNames, ",")) return true } - a.setRuntimeState(RuntimeConnecting, "登录凭证已有新 Cookie,正在重新验证") - a.logger.Info("接口续期返回部分 Cookie 更新,下一轮重新验证", "updated", strings.Join(res.UpdatedCookieNames, ",")) - return true + if updated { + a.logger.Info("接口续期返回部分 Cookie 更新,继续降级恢复", "updated", strings.Join(res.UpdatedCookieNames, ",")) + return false + } + a.logger.Info("接口续期未产生可用恢复", "success", res.Success, "message", res.Message) + return false } // adoptRecoveredCookie 统一接收“轻量检查/接口续期/浏览器恢复”拿到的新 Cookie。 @@ -676,8 +690,23 @@ func withRetryJitter(base time.Duration) time.Duration { // 成功时把 token + device_id 缓存到 DB(saveTokenCache),供进程重启复用与 // 稳态重连时跳过 mtop(acquireToken 命中缓存即直接返回)。 func (a *Account) refreshToken(ctx context.Context) (string, string, error) { + a.refreshMu.Lock() + defer a.refreshMu.Unlock() + + a.reloadCookieFromDB(ctx) + a.mu.Lock() cookieStr := a.CookieStr + currentToken := a.currentToken + lastMsg := a.lastMsgReceived + if !lastMsg.IsZero() && time.Since(lastMsg) < MessageCooldown { + a.mu.Unlock() + a.logger.Info("收到消息冷却中,跳过 token/cookie 刷新", "cooldown", MessageCooldown) + if currentToken != "" { + return currentToken, cookieStr, nil + } + return "", "", fmt.Errorf("收到消息冷却中,跳过 token/cookie 刷新") + } last := a.lastTokenRefresh if !last.IsZero() && time.Since(last) < TokenRefreshMinGap { remain := TokenRefreshMinGap - time.Since(last) @@ -719,6 +748,9 @@ func (a *Account) refreshToken(ctx context.Context) (string, string, error) { return "", "", fmt.Errorf("token API 未返回结果") } a.saveTokenCache(ctx, deviceID, res.AccessToken) + a.mu.Lock() + a.lastMsgReceived = time.Time{} + a.mu.Unlock() return res.AccessToken, cookieStr, nil } @@ -783,12 +815,12 @@ func (a *Account) ensureDeviceIDCached(ctx context.Context) { } } -// saveTokenCache 把 accessToken + device_id 缓存到 DB(expire_at = now + TokenCacheTTL)。 +// saveTokenCache 把 accessToken + device_id 缓存到 DB(expire_at = now + tokenCacheTTL)。 func (a *Account) saveTokenCache(ctx context.Context, deviceID, accessToken string) { if a.store == nil || a.store.Tokens == nil || accessToken == "" { return } - if err := a.store.Tokens.Save(ctx, a.CookieID, deviceID, accessToken, time.Now().Add(TokenCacheTTL).Unix()); err != nil { + if err := a.store.Tokens.Save(ctx, a.CookieID, deviceID, accessToken, time.Now().Add(tokenCacheTTL()).Unix()); err != nil { a.logger.Warn("缓存 accessToken 失败", "err", err) } } @@ -868,6 +900,66 @@ func (a *Account) tokenRefreshLoop(ctx context.Context, conn WSConn) { } } +// cookieRefreshLoop 复刻对方项目的在线 Cookie 刷新循环: +// 每 60 秒检查一次,满 180 秒才刷新;收到消息后 5 分钟内跳过; +// 单次失败 5 秒后重试一次,session 过期则主动关闭 WS 进入恢复链路。 +func (a *Account) cookieRefreshLoop(ctx context.Context, conn WSConn) { + ticker := time.NewTicker(CookieRefreshCheckInterval) + defer ticker.Stop() + a.mu.Lock() + if a.lastCookieRefresh.IsZero() { + a.lastCookieRefresh = time.Now() + } + a.mu.Unlock() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + } + if ctx.Err() != nil { + return + } + a.mu.Lock() + lastRefresh := a.lastCookieRefresh + lastMsg := a.lastMsgReceived + a.mu.Unlock() + if time.Since(lastRefresh) < CookieRefreshInterval { + continue + } + if !lastMsg.IsZero() && time.Since(lastMsg) < MessageCooldown { + a.logger.Info("收到消息冷却中,跳过在线 cookie 刷新", "cooldown", MessageCooldown) + continue + } + if a.refreshOnlineCookie(ctx, conn) { + continue + } + if sleepCtx(ctx, 5*time.Second) != nil { + return + } + _ = a.refreshOnlineCookie(ctx, conn) + } +} + +func (a *Account) refreshOnlineCookie(ctx context.Context, conn WSConn) bool { + token, _, err := a.refreshToken(ctx) + if err != nil { + a.logger.Warn("在线 cookie 刷新失败", "err", err) + if mtop.IsSessionExpiredErr(err) { + a.clearTokenCache(ctx) + _ = conn.Close() + } + return false + } + a.mu.Lock() + a.currentToken = token + a.lastCookieRefresh = time.Now() + a.mu.Unlock() + conn.SetAccessToken(token) + a.logger.Info("在线 cookie 刷新成功") + return true +} + // RuntimeStatus 返回账号当前连接状态的线程安全快照。 func (a *Account) RuntimeStatus() RuntimeStatus { a.mu.Lock() diff --git a/internal/engine/account_extra_test.go b/internal/engine/account_extra_test.go index fc293f9..10b7d5c 100644 --- a/internal/engine/account_extra_test.go +++ b/internal/engine/account_extra_test.go @@ -9,6 +9,8 @@ import ( "time" "xianyu-go/internal/automation" + "xianyu-go/internal/db" + xrenew "xianyu-go/internal/xianyu/renew" ) // TestStop_IdempotentAndClearsTimers Stop 重复调用幂等;调用后防抖定时器被清空。 @@ -98,6 +100,83 @@ func (a *alertCountingHandler) OnAccountAlert(_ context.Context, _, level, _, _ } } +type stubCookieRenewer struct { + result *xrenew.Result + err error + calls int + got string +} + +func (s *stubCookieRenewer) RenewAPIFirst(_ context.Context, cookiesStr string) (*xrenew.Result, error) { + s.calls++ + s.got = cookiesStr + return s.result, s.err +} + +func TestTryAPIRenewSuccessShortCircuitsRecovery(t *testing.T) { + acc, _, store, cleanup := newAccountForTest(t) + defer cleanup() + ctx := context.Background() + if err := store.Tokens.Save(ctx, "cid", "did-old", "tok-old", time.Now().Add(time.Hour).Unix()); err != nil { + t.Fatalf("save token: %v", err) + } + renewer := &stubCookieRenewer{result: &xrenew.Result{ + Success: true, + RenewMethod: "api", + NewCookies: "unb=123; _m_h5_tk=tk_2;", + UpdatedCookieNames: []string{"_m_h5_tk"}, + }} + acc.renewer = renewer + + if !acc.tryAPIRenew(ctx) { + t.Fatal("接口续期成功应短路后续恢复") + } + if renewer.calls != 1 || renewer.got != "unb=123; _m_h5_tk=tk_1;" { + t.Fatalf("renewer 调用异常: calls=%d got=%q", renewer.calls, renewer.got) + } + if got := acc.currentCookieStr(); got != "unb=123; _m_h5_tk=tk_2;" { + t.Fatalf("内存 cookie 未更新: %q", got) + } + saved, _ := store.Cookies.GetValue(ctx, "cid") + if saved != "unb=123; _m_h5_tk=tk_2;" { + t.Fatalf("DB cookie 未更新: %q", saved) + } + if _, err := store.Tokens.Get(ctx, "cid"); err != db.ErrNotFound { + t.Fatalf("接口续期更新 cookie 后应清 token,got %v", err) + } +} + +func TestTryAPIRenewPartialCookiesContinueRecovery(t *testing.T) { + acc, _, store, cleanup := newAccountForTest(t) + defer cleanup() + ctx := context.Background() + if err := store.Tokens.Save(ctx, "cid", "did-old", "tok-old", time.Now().Add(time.Hour).Unix()); err != nil { + t.Fatalf("save token: %v", err) + } + renewer := &stubCookieRenewer{result: &xrenew.Result{ + Success: false, + RenewMethod: "none", + NewCookies: "unb=123; _m_h5_tk=partial;", + UpdatedCookieNames: []string{"_m_h5_tk"}, + Message: "setLoginSettings 未返回 Set-Cookie", + }} + acc.renewer = renewer + + if acc.tryAPIRenew(ctx) { + t.Fatal("仅有部分 Cookie 更新时不应短路后续浏览器/密码恢复") + } + if got := acc.currentCookieStr(); got != "unb=123; _m_h5_tk=partial;" { + t.Fatalf("部分 cookie 应先保存到内存: %q", got) + } + saved, _ := store.Cookies.GetValue(ctx, "cid") + if saved != "unb=123; _m_h5_tk=partial;" { + t.Fatalf("部分 cookie 应先保存到 DB: %q", saved) + } + if _, err := store.Tokens.Get(ctx, "cid"); err != db.ErrNotFound { + t.Fatalf("部分 cookie 更新后也应清 token,got %v", err) + } +} + // TestSetRuntimeError_AllBranches 覆盖验证/captcha、token 失效、默认重连三分支 // 及告警去重逻辑(仅从非验证态进入验证态时告警一次)。 func TestSetRuntimeError_AllBranches(t *testing.T) { diff --git a/internal/engine/token_cache.go b/internal/engine/token_cache.go new file mode 100644 index 0000000..9fc9cc0 --- /dev/null +++ b/internal/engine/token_cache.go @@ -0,0 +1,45 @@ +package engine + +import ( + "crypto/rand" + "math/big" + "os" + "strconv" + "strings" + "time" +) + +const tokenCacheTTLGranularity = time.Second + +func tokenCacheTTL() time.Duration { + minTTL, minOK := tokenCacheTTLEnv("TOKEN_CACHE_TTL_MIN_HOURS", TokenCacheTTLMin) + maxTTL, maxOK := tokenCacheTTLEnv("TOKEN_CACHE_TTL_MAX_HOURS", TokenCacheTTLMax) + if !minOK || !maxOK || minTTL > maxTTL { + minTTL = TokenCacheTTLMin + maxTTL = TokenCacheTTLMax + } + if maxTTL == minTTL { + return minTTL + } + steps := int64((maxTTL - minTTL) / tokenCacheTTLGranularity) + if steps <= 0 { + return minTTL + } + n, err := rand.Int(rand.Reader, big.NewInt(steps+1)) + if err != nil { + return minTTL + } + return minTTL + time.Duration(n.Int64())*tokenCacheTTLGranularity +} + +func tokenCacheTTLEnv(key string, fallback time.Duration) (time.Duration, bool) { + raw := strings.TrimSpace(os.Getenv(key)) + if raw == "" { + return fallback, true + } + hours, err := strconv.ParseFloat(raw, 64) + if err != nil || hours <= 0 { + return fallback, false + } + return time.Duration(hours * float64(time.Hour)), true +} diff --git a/internal/engine/token_cache_test.go b/internal/engine/token_cache_test.go new file mode 100644 index 0000000..25bd568 --- /dev/null +++ b/internal/engine/token_cache_test.go @@ -0,0 +1,41 @@ +package engine + +import ( + "testing" + "time" +) + +func TestTokenCacheTTLFixedEnv(t *testing.T) { + t.Setenv("TOKEN_CACHE_TTL_MIN_HOURS", "2") + t.Setenv("TOKEN_CACHE_TTL_MAX_HOURS", "2") + if got := tokenCacheTTL(); got != 2*time.Hour { + t.Fatalf("tokenCacheTTL=%s want 2h", got) + } +} + +func TestTokenCacheTTLMaxBelowMinFallsBackToDefaultRange(t *testing.T) { + t.Setenv("TOKEN_CACHE_TTL_MIN_HOURS", "4") + t.Setenv("TOKEN_CACHE_TTL_MAX_HOURS", "2") + got := tokenCacheTTL() + if got < TokenCacheTTLMin || got > TokenCacheTTLMax { + t.Fatalf("tokenCacheTTL=%s want within [%s,%s]", got, TokenCacheTTLMin, TokenCacheTTLMax) + } +} + +func TestTokenCacheTTLInvalidEnvFallsBackToDefaultRange(t *testing.T) { + t.Setenv("TOKEN_CACHE_TTL_MIN_HOURS", "bad") + t.Setenv("TOKEN_CACHE_TTL_MAX_HOURS", "also-bad") + got := tokenCacheTTL() + if got < TokenCacheTTLMin || got > TokenCacheTTLMax { + t.Fatalf("tokenCacheTTL=%s want within [%s,%s]", got, TokenCacheTTLMin, TokenCacheTTLMax) + } +} + +func TestTokenCacheTTLPartiallyInvalidEnvFallsBackToDefaultRange(t *testing.T) { + t.Setenv("TOKEN_CACHE_TTL_MIN_HOURS", "2") + t.Setenv("TOKEN_CACHE_TTL_MAX_HOURS", "bad") + got := tokenCacheTTL() + if got < TokenCacheTTLMin || got > TokenCacheTTLMax { + t.Fatalf("tokenCacheTTL=%s want within [%s,%s]", got, TokenCacheTTLMin, TokenCacheTTLMax) + } +} diff --git a/internal/renewal/cooldown.go b/internal/renewal/cooldown.go new file mode 100644 index 0000000..e96ec89 --- /dev/null +++ b/internal/renewal/cooldown.go @@ -0,0 +1,95 @@ +package renewal + +import ( + "sync" + "time" +) + +// CooldownManager 保存登录恢复相关冷却状态。 +// Scheduler 和运行时 Adapter 共用同一实例,避免同一账号被重复触发密码登录。 +type CooldownManager struct { + mu sync.Mutex + + sessionExpiredByCookie map[string]time.Time + passwordLoginByCookie map[string]time.Time + passwordErrorByCookie map[string]time.Time +} + +// GlobalCooldown 是服务进程内的统一续期冷却状态。 +var GlobalCooldown = NewCooldownManager() + +func NewCooldownManager() *CooldownManager { + return &CooldownManager{ + sessionExpiredByCookie: make(map[string]time.Time), + passwordLoginByCookie: make(map[string]time.Time), + passwordErrorByCookie: make(map[string]time.Time), + } +} + +func (m *CooldownManager) MarkSessionExpired(cookieID string) { + if m == nil { + return + } + m.mu.Lock() + defer m.mu.Unlock() + m.sessionExpiredByCookie[cookieID] = time.Now() +} + +func (m *CooldownManager) IsSessionCooled(cookieID string) (bool, time.Duration) { + if m == nil { + return false, 0 + } + m.mu.Lock() + defer m.mu.Unlock() + last := m.sessionExpiredByCookie[cookieID] + if last.IsZero() { + return false, 0 + } + remain := sessionExpiredCooldown - time.Since(last) + return remain > 0, remain +} + +func (m *CooldownManager) TryPasswordLogin(cookieID string) (bool, time.Duration) { + if m == nil { + return true, 0 + } + m.mu.Lock() + defer m.mu.Unlock() + now := time.Now() + last := m.passwordLoginByCookie[cookieID] + if !last.IsZero() { + remain := passwordLoginCooldown - now.Sub(last) + if remain > 0 { + return false, remain + } + } + lastErr := m.passwordErrorByCookie[cookieID] + if !lastErr.IsZero() { + remain := passwordErrorCooldown - now.Sub(lastErr) + if remain > 0 { + return false, remain + } + } + m.passwordLoginByCookie[cookieID] = now + return true, 0 +} + +func (m *CooldownManager) MarkPasswordError(cookieID string) { + if m == nil { + return + } + m.mu.Lock() + defer m.mu.Unlock() + m.passwordErrorByCookie[cookieID] = time.Now() +} + +func (m *CooldownManager) Reset(cookieID string) { + if m == nil { + return + } + m.mu.Lock() + defer m.mu.Unlock() + delete(m.sessionExpiredByCookie, cookieID) + delete(m.passwordLoginByCookie, cookieID) + delete(m.passwordErrorByCookie, cookieID) +} diff --git a/internal/renewal/scheduler.go b/internal/renewal/scheduler.go new file mode 100644 index 0000000..871c592 --- /dev/null +++ b/internal/renewal/scheduler.go @@ -0,0 +1,513 @@ +package renewal + +import ( + "context" + crand "crypto/rand" + "encoding/hex" + "fmt" + "log/slog" + "math/big" + "reflect" + "strconv" + "strings" + "time" + + "xianyu-go/internal/db" + "xianyu-go/internal/xianyu/cookierefresh" + "xianyu-go/internal/xianyu/mtop" + apirenew "xianyu-go/internal/xianyu/renew" +) + +const ( + loginRenewInterval = 600 * time.Second + cookiesRefreshInterval = 600 * time.Second + apiCookieRenewInterval = 3600 * time.Second + accountRequestInterval = time.Second + browserInitialDelayMax = 30 * time.Second + browserSuccessDelayMin = 60 * time.Second + browserSuccessDelayRange = 240 * time.Second + disabledFailureLimit = 10 + sessionExpiredCooldown = 300 * time.Second + passwordLoginCooldown = 300 * time.Second + passwordErrorCooldown = 5 * time.Hour +) + +const ( + loginRenewEnabledSetting = "renewal.login_renew.enabled" + loginRenewIntervalSetting = "renewal.login_renew.interval_seconds" + apiCookieRenewEnabledSetting = "renewal.api_cookie_renew.enabled" + apiCookieRenewIntervalSetting = "renewal.api_cookie_renew.interval_seconds" + cookiesRefreshEnabledSetting = "renewal.cookies_refresh.enabled" + cookiesRefreshIntervalSetting = "renewal.cookies_refresh.interval_seconds" +) + +type AccountStarter interface { + Start(ctx context.Context, cookieID, cookieValue string) error +} + +type BrowserRenewer interface { + BrowserQuickRenew(ctx context.Context, cookieID, cookieStr string, headless bool) (string, error) + CookiesRefreshSnapshot(ctx context.Context, cookieID, cookieStr string, snapshot []cookierefresh.BrowserCookie, headless bool) (string, []cookierefresh.BrowserCookie, error) +} + +type PasswordRefresher interface { + OnPasswordLoginRefresh(ctx context.Context, cookieID string) bool +} + +type Scheduler struct { + store *db.Store + starter AccountStarter + browser BrowserRenewer + refresher PasswordRefresher + logger *slog.Logger + mtop *mtop.ClientImpl + api apirenew.Service + cooldown *CooldownManager +} + +func NewScheduler(store *db.Store, starter AccountStarter, browser BrowserRenewer, refresher PasswordRefresher, logger *slog.Logger) *Scheduler { + if logger == nil { + logger = slog.Default() + } + return &Scheduler{ + store: store, + starter: starter, + browser: browserRenewerOrNil(browser), + refresher: refresher, + logger: logger, + mtop: mtop.NewClient(), + api: apirenew.Service{}, + cooldown: GlobalCooldown, + } +} + +func browserRenewerOrNil(browser BrowserRenewer) BrowserRenewer { + if browser == nil { + return nil + } + v := reflect.ValueOf(browser) + switch v.Kind() { + case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Pointer, reflect.Slice: + if v.IsNil() { + return nil + } + } + return browser +} + +func (s *Scheduler) Run(ctx context.Context) { + if s == nil || s.store == nil { + return + } + go s.runFixed(ctx, "login_renew", loginRenewEnabledSetting, loginRenewIntervalSetting, false, loginRenewInterval, s.executeLoginRenew) + go s.runFixed(ctx, "api_cookie_renew", apiCookieRenewEnabledSetting, apiCookieRenewIntervalSetting, true, apiCookieRenewInterval, s.executeAPICookieRenew) + go s.runFixed(ctx, "cookies_refresh", cookiesRefreshEnabledSetting, cookiesRefreshIntervalSetting, false, cookiesRefreshInterval, s.executeBrowserCookieRefresh) +} + +func (s *Scheduler) runFixed(ctx context.Context, name, settingKey, intervalKey string, defaultEnabled bool, defaultInterval time.Duration, fn func(context.Context)) { + if s.settingEnabled(ctx, settingKey, defaultEnabled) { + fn(ctx) + } + for { + interval := s.settingInterval(ctx, intervalKey, defaultInterval) + timer := time.NewTimer(interval) + select { + case <-ctx.Done(): + timer.Stop() + return + case <-timer.C: + } + if !s.settingEnabled(ctx, settingKey, defaultEnabled) { + continue + } + s.logger.Info("执行续期任务", "task", name) + fn(ctx) + } +} + +func (s *Scheduler) executeLoginRenew(ctx context.Context) { + batchID := newBatchID() + accounts, err := s.store.Cookies.ActiveRenewalAccounts(ctx) + if err != nil { + s.logger.Warn("login_renew 加载账号失败", "err", err) + return + } + for i, account := range accounts { + if s.isSessionCooled(account.ID) { + s.logger.Info("login_renew session 冷却中,跳过", "account", account.ID) + continue + } + s.loginRenewOne(ctx, batchID, account) + if i < len(accounts)-1 { + _ = sleepCtx(ctx, accountRequestInterval) + } + } +} + +func (s *Scheduler) loginRenewOne(ctx context.Context, batchID string, account db.RenewalAccount) { + runCtx, cancel := context.WithTimeout(ctx, 30*time.Second) + defer cancel() + res, err := s.mtop.CheckLoginStatusContext(runCtx, account.Value) + if err != nil { + s.addLoginLog(ctx, batchID, account.ID, "failed", err.Error(), nil) + s.logger.Warn("login_renew 失败", "account", account.ID, "err", err) + return + } + if res == nil { + s.addLoginLog(ctx, batchID, account.ID, "failed", "loginuser.get 未返回结果", nil) + return + } + updated := cookierefresh.ChangedCookieNames(account.Value, res.UpdatedCookies) + if res.UpdatedCookies != "" && res.UpdatedCookies != account.Value { + metadata := cookierefresh.MetadataWithoutSnapshot(account.MetadataJSON) + if err := s.store.Cookies.UpdateRenewalCookie(ctx, account.ID, res.UpdatedCookies, metadata, time.Now().Unix()); err != nil { + s.addLoginLog(ctx, batchID, account.ID, "failed", "保存 Cookie 失败: "+err.Error(), updated) + return + } + s.clearToken(ctx, account.ID) + } + s.addLoginLog(ctx, batchID, account.ID, res.Status, res.Message, updated) + if res.Status == mtop.LoginStatusSessionExpired || res.Status == mtop.LoginStatusTokenEmpty { + s.markSessionExpired(account.ID) + s.triggerPasswordLoginAsync(account.ID) + } +} + +func (s *Scheduler) executeAPICookieRenew(ctx context.Context) { + batchID := newBatchID() + accounts, err := s.store.Cookies.ActiveRenewalAccounts(ctx) + if err != nil { + s.logger.Warn("api_cookie_renew 加载账号失败", "err", err) + return + } + for i, account := range accounts { + s.apiCookieRenewOne(ctx, batchID, account) + if i < len(accounts)-1 { + _ = sleepCtx(ctx, accountRequestInterval) + } + } +} + +func (s *Scheduler) apiCookieRenewOne(ctx context.Context, batchID string, account db.RenewalAccount) { + res, err := s.renewAPI(ctx, account.Value) + if err != nil { + s.addAPILog(ctx, db.RenewalLog{BatchID: batchID, CookieID: account.ID, Status: "failed", ErrorMessage: err.Error()}) + s.logger.Warn("api_cookie_renew 失败", "account", account.ID, "err", err) + return + } + if res == nil { + s.addAPILog(ctx, db.RenewalLog{BatchID: batchID, CookieID: account.ID, Status: "failed", ErrorMessage: "接口续期未返回结果"}) + return + } + if res.Success { + updated := cookierefresh.ChangedCookieNames(account.Value, res.NewCookies) + if res.NewCookies != "" && res.NewCookies != account.Value { + if !s.saveRenewedCookies(ctx, account.ID, res.NewCookies, cookierefresh.MetadataWithoutSnapshot(account.MetadataJSON)) { + s.addAPILog(ctx, db.RenewalLog{BatchID: batchID, CookieID: account.ID, Status: "failed", ErrorMessage: "保存 Cookie 失败", UpdatedCookieNames: updated}) + return + } + } + status := "success" + if len(updated) > 0 { + status = "cookie_updated" + } + s.addAPILog(ctx, db.RenewalLog{BatchID: batchID, CookieID: account.ID, Status: status, Message: res.Message, UpdatedCookieNames: updated, ResponseContent: res.ResponseText}) + return + } + + if res.NewCookies != "" && res.NewCookies != account.Value { + updated := cookierefresh.ChangedCookieNames(account.Value, res.NewCookies) + if !s.saveRenewedCookies(ctx, account.ID, res.NewCookies, cookierefresh.MetadataWithoutSnapshot(account.MetadataJSON)) { + s.addAPILog(ctx, db.RenewalLog{BatchID: batchID, CookieID: account.ID, Status: "failed", ErrorMessage: "保存部分 Cookie 失败", UpdatedCookieNames: updated}) + return + } + s.logger.Info("api_cookie_renew 保留接口返回的部分 Cookie 更新", "account", account.ID, "updated", strings.Join(updated, ",")) + } + + browserInput := firstNonEmpty(res.NewCookies, account.Value) + var browserCookies string + var browserErr error + if s.browser != nil { + bctx, cancel := context.WithTimeout(ctx, 5*time.Minute) + browserCookies, browserErr = s.browser.BrowserQuickRenew(bctx, account.ID, browserInput, !account.ShowBrowser) + cancel() + } else { + browserErr = fmt.Errorf("浏览器自动化未启用") + } + if browserErr == nil && browserCookies != "" { + verify, verifyErr := s.renewAPI(ctx, browserCookies) + if verifyErr == nil && verify != nil && verify.Success { + finalCookies := firstNonEmpty(verify.NewCookies, browserCookies) + updated := cookierefresh.ChangedCookieNames(account.Value, finalCookies) + if finalCookies != account.Value { + if !s.saveRenewedCookies(ctx, account.ID, finalCookies, cookierefresh.MetadataWithoutSnapshot(account.MetadataJSON)) { + s.addAPILog(ctx, db.RenewalLog{BatchID: batchID, CookieID: account.ID, Status: "failed", ErrorMessage: "保存 Cookie 失败", UpdatedCookieNames: updated}) + return + } + } + s.addAPILog(ctx, db.RenewalLog{BatchID: batchID, CookieID: account.ID, Status: "browser_renewed", Message: "接口续期失败,浏览器续期成功,setLoginSettings验证通过", UpdatedCookieNames: updated, ResponseContent: verify.ResponseText}) + return + } + updated := cookierefresh.ChangedCookieNames(account.Value, browserCookies) + if len(updated) > 0 { + _ = s.saveRenewedCookies(ctx, account.ID, browserCookies, cookierefresh.MetadataWithoutSnapshot(account.MetadataJSON)) + } + res.Message = "接口续期和浏览器续期均失败,需要账号密码登录" + } + + s.markSessionExpired(account.ID) + s.triggerPasswordLoginAsync(account.ID) + msg := res.Message + if browserErr != nil { + msg = msg + ";浏览器续期失败: " + browserErr.Error() + } + updated := cookierefresh.ChangedCookieNames(account.Value, firstNonEmpty(browserCookies, res.NewCookies)) + s.addAPILog(ctx, db.RenewalLog{ + BatchID: batchID, + CookieID: account.ID, + Status: "need_password_login", + ErrorMessage: msg, + UpdatedCookieNames: updated, + ResponseContent: res.ResponseText, + }) +} + +func (s *Scheduler) executeBrowserCookieRefresh(ctx context.Context) { + batchID := newBatchID() + accounts, err := s.store.Cookies.AllRenewalAccounts(ctx) + if err != nil { + s.logger.Warn("cookies_refresh 加载账号失败", "err", err) + return + } + now := time.Now().Unix() + for _, account := range accounts { + if !account.Enabled && s.disabledAccountShouldSkip(ctx, account.ID) { + continue + } + schedule, err := s.store.Renewal.GetCookieRefreshSchedule(ctx, account.ID) + if err != nil { + expireAt := now + int64(randomDuration(browserInitialDelayMax).Seconds()) + schedule = &db.CookieRefreshSchedule{CookieID: account.ID, ExpireAt: expireAt, LastStatus: "initialized"} + _ = s.store.Renewal.UpsertCookieRefreshSchedule(ctx, *schedule) + _ = s.store.Renewal.AddBrowserCookieRenewLog(ctx, db.RenewalLog{ + BatchID: batchID, + CookieID: account.ID, + Status: "initialized", + Message: "首次初始化续期时间", + NextExpireAt: expireAt, + }) + continue + } + if schedule.Disabled || schedule.ExpireAt > now { + _ = s.store.Renewal.AddBrowserCookieRenewLog(ctx, db.RenewalLog{ + BatchID: batchID, + CookieID: account.ID, + Status: "success", + Message: fmt.Sprintf("未到期,跳过,剩余 %d 秒", schedule.ExpireAt-now), + NextExpireAt: schedule.ExpireAt, + }) + continue + } + s.browserCookieRefreshOne(ctx, batchID, account, *schedule) + } +} + +func (s *Scheduler) browserCookieRefreshOne(ctx context.Context, batchID string, account db.RenewalAccount, schedule db.CookieRefreshSchedule) { + if s.browser == nil { + schedule.LastStatus = "failed" + schedule.LastErrorMessage = "浏览器自动化未启用" + _ = s.store.Renewal.UpsertCookieRefreshSchedule(ctx, schedule) + _ = s.store.Renewal.AddBrowserCookieRenewLog(ctx, db.RenewalLog{BatchID: batchID, CookieID: account.ID, Status: "failed", ErrorMessage: schedule.LastErrorMessage}) + return + } + runCtx, cancel := context.WithTimeout(ctx, 5*time.Minute) + defer cancel() + oldSnapshot := cookierefresh.SnapshotFromMetadata(account.MetadataJSON) + newCookies, newSnapshot, err := s.browser.CookiesRefreshSnapshot(runCtx, account.ID, account.Value, oldSnapshot, !account.ShowBrowser) + if err != nil { + schedule.ConsecutiveFailures++ + schedule.LastStatus = "failed" + schedule.LastError = err.Error() + schedule.LastErrorMessage = err.Error() + _ = s.store.Renewal.UpsertCookieRefreshSchedule(ctx, schedule) + _ = s.store.Renewal.AddBrowserCookieRenewLog(ctx, db.RenewalLog{BatchID: batchID, CookieID: account.ID, Status: "failed", ErrorMessage: err.Error(), NextExpireAt: schedule.ExpireAt}) + s.logger.Warn("cookies_refresh 失败", "account", account.ID, "err", err) + return + } + metadata := cookierefresh.MetadataWithSnapshot(account.MetadataJSON, newSnapshot) + updated := cookierefresh.ChangedSnapshotLabels(oldSnapshot, newSnapshot) + if err := s.store.Cookies.UpdateRenewalCookie(ctx, account.ID, newCookies, metadata, time.Now().Unix()); err != nil { + _ = s.store.Renewal.AddBrowserCookieRenewLog(ctx, db.RenewalLog{BatchID: batchID, CookieID: account.ID, Status: "failed", ErrorMessage: "保存 Cookie 失败: " + err.Error(), UpdatedCookieNames: updated}) + return + } + s.clearToken(ctx, account.ID) + if !account.Enabled { + if err := s.store.Cookies.SetStatusWithReason(ctx, account.ID, true, ""); err != nil { + s.logger.Warn("cookies_refresh 自动启用账号失败", "account", account.ID, "err", err) + } else if s.starter != nil { + if err := s.starter.Start(ctx, account.ID, newCookies); err != nil { + s.logger.Warn("cookies_refresh 启动账号失败", "account", account.ID, "err", err) + } + } + } + nextExpire := time.Now().Add(browserSuccessDelay()).Unix() + schedule.Disabled = false + schedule.ConsecutiveFailures = 0 + schedule.LastError = "" + schedule.LastStatus = "success" + schedule.LastErrorMessage = "" + schedule.LastRefreshAt = time.Now().Unix() + schedule.ExpireAt = nextExpire + _ = s.store.Renewal.UpsertCookieRefreshSchedule(ctx, schedule) + _ = s.store.Renewal.AddBrowserCookieRenewLog(ctx, db.RenewalLog{ + BatchID: batchID, + CookieID: account.ID, + Status: "success", + Message: fmt.Sprintf("页面校验通过,全量获取到 %d 个浏览器Cookie", len(newSnapshot)), + UpdatedCookieNames: updated, + NextExpireAt: nextExpire, + }) +} + +func (s *Scheduler) renewAPI(ctx context.Context, cookieStr string) (*apirenew.Result, error) { + runCtx, cancel := context.WithTimeout(ctx, 90*time.Second) + defer cancel() + return s.api.RenewAPIFirst(runCtx, cookieStr) +} + +func (s *Scheduler) saveRenewedCookies(ctx context.Context, cookieID, cookieStr, metadata string) bool { + if err := s.store.Cookies.UpdateRenewalCookie(ctx, cookieID, cookieStr, metadata, time.Now().Unix()); err != nil { + s.logger.Warn("保存续期 Cookie 失败", "account", cookieID, "err", err) + return false + } + s.clearToken(ctx, cookieID) + return true +} + +func (s *Scheduler) addLoginLog(ctx context.Context, batchID, cookieID, status, message string, updated []string) { + _ = s.store.Renewal.AddLoginRenewLog(ctx, db.RenewalLog{BatchID: batchID, CookieID: cookieID, Status: status, Message: message, UpdatedCookieNames: updated}) +} + +func (s *Scheduler) addAPILog(ctx context.Context, log db.RenewalLog) { + _ = s.store.Renewal.AddAPICookieRenewLog(ctx, log) +} + +func (s *Scheduler) markSessionExpired(cookieID string) { + s.cooldown.MarkSessionExpired(cookieID) +} + +func (s *Scheduler) isSessionCooled(cookieID string) bool { + ok, _ := s.cooldown.IsSessionCooled(cookieID) + return ok +} + +func (s *Scheduler) triggerPasswordLoginAsync(cookieID string) { + if s.refresher == nil { + return + } + go s.refresher.OnPasswordLoginRefresh(context.Background(), cookieID) +} + +func (s *Scheduler) disabledAccountShouldSkip(ctx context.Context, cookieID string) bool { + statuses, err := s.store.Renewal.RecentBrowserCookieRenewStatuses(ctx, cookieID, disabledFailureLimit) + if err != nil || len(statuses) < disabledFailureLimit { + return false + } + for _, status := range statuses { + if status != "failed" { + return false + } + } + return true +} + +func (s *Scheduler) settingEnabled(ctx context.Context, key string, defaultEnabled bool) bool { + if s.store == nil || s.store.Settings == nil { + return defaultEnabled + } + value, err := s.store.Settings.Get(ctx, key) + if err != nil || strings.TrimSpace(value) == "" { + return defaultEnabled + } + switch strings.ToLower(strings.TrimSpace(value)) { + case "1", "true", "yes", "on", "enabled": + return true + case "0", "false", "no", "off", "disabled": + return false + default: + return defaultEnabled + } +} + +func (s *Scheduler) settingInterval(ctx context.Context, key string, defaultInterval time.Duration) time.Duration { + if s.store == nil || s.store.Settings == nil { + return defaultInterval + } + value, err := s.store.Settings.Get(ctx, key) + if err != nil || strings.TrimSpace(value) == "" { + return defaultInterval + } + value = strings.TrimSpace(value) + if seconds, err := strconv.ParseFloat(value, 64); err == nil && seconds > 0 { + return time.Duration(seconds * float64(time.Second)) + } + if d, err := time.ParseDuration(value); err == nil && d > 0 { + return d + } + return defaultInterval +} + +func (s *Scheduler) clearToken(ctx context.Context, cookieID string) { + if s.store.Tokens == nil { + return + } + if err := s.store.Tokens.Clear(ctx, cookieID); err != nil { + s.logger.Warn("续期后清除 token 缓存失败", "account", cookieID, "err", err) + } +} + +func browserSuccessDelay() time.Duration { + return browserSuccessDelayMin + randomDuration(browserSuccessDelayRange) +} + +func randomDuration(max time.Duration) time.Duration { + if max <= 0 { + return 0 + } + n, err := crand.Int(crand.Reader, big.NewInt(int64(max))) + if err != nil { + return 0 + } + return time.Duration(n.Int64()) +} + +func newBatchID() string { + var b [16]byte + if _, err := crand.Read(b[:]); err != nil { + return fmt.Sprintf("%d", time.Now().UnixNano()) + } + return hex.EncodeToString(b[:]) +} + +func firstNonEmpty(values ...string) string { + for _, value := range values { + if strings.TrimSpace(value) != "" { + return value + } + } + return "" +} + +func sleepCtx(ctx context.Context, d time.Duration) error { + if d <= 0 { + return nil + } + timer := time.NewTimer(d) + defer timer.Stop() + select { + case <-ctx.Done(): + return ctx.Err() + case <-timer.C: + return nil + } +} diff --git a/internal/renewal/scheduler_test.go b/internal/renewal/scheduler_test.go new file mode 100644 index 0000000..2c086f0 --- /dev/null +++ b/internal/renewal/scheduler_test.go @@ -0,0 +1,383 @@ +package renewal + +import ( + "context" + "errors" + "net/http" + "net/http/httptest" + "path/filepath" + "strings" + "sync/atomic" + "testing" + "time" + + "xianyu-go/internal/db" + "xianyu-go/internal/xianyu/cookierefresh" + apirenew "xianyu-go/internal/xianyu/renew" +) + +func newSchedulerTestStore(t *testing.T) (*db.Store, func()) { + t.Helper() + d, _, err := db.Open(context.Background(), filepath.Join(t.TempDir(), "renewal.db")) + if err != nil { + t.Fatalf("Open: %v", err) + } + return db.NewStore(d, db.DialectSQLite), func() { d.Close() } +} + +type schedulerFakeBrowser struct { + quickCookies string + quickErr error + quickCalls int + quickInputs []string +} + +func (f *schedulerFakeBrowser) BrowserQuickRenew(_ context.Context, _ string, cookieStr string, _ bool) (string, error) { + f.quickCalls++ + f.quickInputs = append(f.quickInputs, cookieStr) + return f.quickCookies, f.quickErr +} + +func (f *schedulerFakeBrowser) CookiesRefreshSnapshot(_ context.Context, _, _ string, _ []cookierefresh.BrowserCookie, _ bool) (string, []cookierefresh.BrowserCookie, error) { + return "", nil, errors.New("not implemented") +} + +type schedulerFakePasswordRefresher struct { + calls atomic.Int32 + ch chan string +} + +func (f *schedulerFakePasswordRefresher) OnPasswordLoginRefresh(_ context.Context, cookieID string) bool { + f.calls.Add(1) + if f.ch != nil { + select { + case f.ch <- cookieID: + default: + } + } + return true +} + +func (f *schedulerFakePasswordRefresher) waitCookie(t *testing.T, want string) { + t.Helper() + select { + case got := <-f.ch: + if got != want { + t.Fatalf("password refresher cookieID=%q want %q", got, want) + } + case <-time.After(time.Second): + t.Fatalf("password refresher 未触发") + } +} + +type apiRenewLogSnapshot struct { + status string + message string + errorMessage string + updatedCookieNames string + responseContent string +} + +func createSchedulerAccount(t *testing.T, store *db.Store, cookieID, cookieValue string) db.RenewalAccount { + t.Helper() + ctx := context.Background() + username := "user_" + strings.ReplaceAll(cookieID, "-", "_") + if ok, err := store.Users.Create(ctx, username, username+"@example.com", "pw"); err != nil || !ok { + t.Fatalf("Create user: ok=%v err=%v", ok, err) + } + user, err := store.Users.GetByUsername(ctx, username) + if err != nil { + t.Fatalf("GetByUsername: %v", err) + } + if err := store.Cookies.Save(ctx, cookieID, cookieValue, user.ID); err != nil { + t.Fatalf("Save cookie: %v", err) + } + return db.RenewalAccount{ID: cookieID, Value: cookieValue, UserID: user.ID, Enabled: true} +} + +func lastAPIRenewLog(t *testing.T, store *db.Store, cookieID string) apiRenewLogSnapshot { + t.Helper() + var log apiRenewLogSnapshot + err := store.DB.QueryRowContext(context.Background(), + `SELECT status, COALESCE(message,''), COALESCE(error_message,''), COALESCE(updated_cookie_names,''), COALESCE(response_content,'') + FROM scheduled_api_cookie_renew_log + WHERE cookie_id=? + ORDER BY id DESC LIMIT 1`, cookieID). + Scan(&log.status, &log.message, &log.errorMessage, &log.updatedCookieNames, &log.responseContent) + if err != nil { + t.Fatalf("query api renew log: %v", err) + } + return log +} + +func schedulerRenewServiceFromServer(srv *httptest.Server) apirenew.Service { + return apirenew.Service{ + HTTPClient: srv.Client(), + HasLoginURL: srv.URL + "/hasLogin.do", + SilentHasLoginURL: srv.URL + "/silentHasLogin.do", + SetLoginSettingsURL: srv.URL + "/setLoginSettings.do", + RetryDelay: -1, + } +} + +func TestSchedulerIntervalsAligned(t *testing.T) { + if loginRenewInterval != 10*time.Minute { + t.Fatalf("loginRenewInterval=%s want 10m", loginRenewInterval) + } + if cookiesRefreshInterval != 10*time.Minute { + t.Fatalf("cookiesRefreshInterval=%s want 10m", cookiesRefreshInterval) + } + if apiCookieRenewInterval != time.Hour { + t.Fatalf("apiCookieRenewInterval=%s want 1h", apiCookieRenewInterval) + } +} + +func TestSchedulerDefaultsMatchUpstreamConfig(t *testing.T) { + store, cleanup := newSchedulerTestStore(t) + defer cleanup() + ctx := context.Background() + s := NewScheduler(store, nil, nil, nil, nil) + + if s.settingEnabled(ctx, loginRenewEnabledSetting, false) { + t.Fatal("login_renew 未配置时应默认关闭") + } + if s.settingEnabled(ctx, cookiesRefreshEnabledSetting, false) { + t.Fatal("cookies_refresh 未配置时应默认关闭") + } + if !s.settingEnabled(ctx, apiCookieRenewEnabledSetting, true) { + t.Fatal("api_cookie_renew 未配置时应默认开启") + } +} + +func TestNewSchedulerTreatsTypedNilBrowserAsDisabled(t *testing.T) { + store, cleanup := newSchedulerTestStore(t) + defer cleanup() + ctx := context.Background() + account := createSchedulerAccount(t, store, "cid-typed-nil-browser", "unb=1; cookie2=c2") + refresher := &schedulerFakePasswordRefresher{ch: make(chan string, 1)} + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/hasLogin.do", "/silentHasLogin.do", "/setLoginSettings.do": + _, _ = w.Write([]byte(`{"content":{"success":true}}`)) + default: + http.NotFound(w, r) + } + })) + defer srv.Close() + + var typedNilBrowser *schedulerFakeBrowser + s := NewScheduler(store, nil, typedNilBrowser, refresher, nil) + if s.browser != nil { + t.Fatal("typed nil BrowserRenewer 应被规范化为 nil") + } + s.api = schedulerRenewServiceFromServer(srv) + s.cooldown = NewCooldownManager() + + s.apiCookieRenewOne(ctx, "batch-typed-nil-browser", account) + refresher.waitCookie(t, "cid-typed-nil-browser") + log := lastAPIRenewLog(t, store, "cid-typed-nil-browser") + if log.status != "need_password_login" || !strings.Contains(log.errorMessage, "浏览器自动化未启用") { + t.Fatalf("typed nil browser 应按浏览器禁用处理: %+v", log) + } +} + +func TestSchedulerSettingEnabledOverrides(t *testing.T) { + store, cleanup := newSchedulerTestStore(t) + defer cleanup() + ctx := context.Background() + s := NewScheduler(store, nil, nil, nil, nil) + + if err := store.Settings.Set(ctx, loginRenewEnabledSetting, "enabled"); err != nil { + t.Fatalf("Set enabled: %v", err) + } + if !s.settingEnabled(ctx, loginRenewEnabledSetting, false) { + t.Fatal("enabled 应开启任务") + } + if err := store.Settings.Set(ctx, loginRenewEnabledSetting, "off"); err != nil { + t.Fatalf("Set off: %v", err) + } + if s.settingEnabled(ctx, loginRenewEnabledSetting, true) { + t.Fatal("off 应关闭任务") + } +} + +func TestSchedulerSettingIntervalOverrides(t *testing.T) { + store, cleanup := newSchedulerTestStore(t) + defer cleanup() + ctx := context.Background() + s := NewScheduler(store, nil, nil, nil, nil) + + if got := s.settingInterval(ctx, loginRenewIntervalSetting, loginRenewInterval); got != loginRenewInterval { + t.Fatalf("未配置间隔应返回默认值: %s", got) + } + if err := store.Settings.Set(ctx, loginRenewIntervalSetting, "30"); err != nil { + t.Fatalf("Set seconds: %v", err) + } + if got := s.settingInterval(ctx, loginRenewIntervalSetting, loginRenewInterval); got != 30*time.Second { + t.Fatalf("秒数间隔=%s want 30s", got) + } + if err := store.Settings.Set(ctx, loginRenewIntervalSetting, "2m"); err != nil { + t.Fatalf("Set duration: %v", err) + } + if got := s.settingInterval(ctx, loginRenewIntervalSetting, loginRenewInterval); got != 2*time.Minute { + t.Fatalf("duration 间隔=%s want 2m", got) + } + if err := store.Settings.Set(ctx, loginRenewIntervalSetting, "-1"); err != nil { + t.Fatalf("Set invalid: %v", err) + } + if got := s.settingInterval(ctx, loginRenewIntervalSetting, loginRenewInterval); got != loginRenewInterval { + t.Fatalf("非法间隔应回退默认值: %s", got) + } +} + +func TestAPICookieRenewOneSavesPartialCookiesBeforePasswordLogin(t *testing.T) { + store, cleanup := newSchedulerTestStore(t) + defer cleanup() + ctx := context.Background() + account := createSchedulerAccount(t, store, "cid-partial", "unb=1; cookie2=c2") + refresher := &schedulerFakePasswordRefresher{ch: make(chan string, 1)} + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/hasLogin.do": + http.SetCookie(w, &http.Cookie{Name: "sgcookie", Value: "s1"}) + _, _ = w.Write([]byte(`{"content":{"success":true}}`)) + case "/silentHasLogin.do": + http.SetCookie(w, &http.Cookie{Name: "_m_h5_tk", Value: "tk_1"}) + _, _ = w.Write([]byte(`{"content":{"success":true},"marker":"silent-partial"}`)) + case "/setLoginSettings.do": + _, _ = w.Write([]byte(`{"content":{"success":false}}`)) + default: + http.NotFound(w, r) + } + })) + defer srv.Close() + + s := NewScheduler(store, nil, nil, refresher, nil) + s.api = schedulerRenewServiceFromServer(srv) + s.cooldown = NewCooldownManager() + s.apiCookieRenewOne(ctx, "batch-partial", account) + refresher.waitCookie(t, "cid-partial") + + got, err := store.Cookies.GetValue(ctx, "cid-partial") + if err != nil { + t.Fatalf("GetValue: %v", err) + } + for _, want := range []string{"sgcookie=s1", "_m_h5_tk=tk_1"} { + if !strings.Contains(got, want) { + t.Fatalf("部分 Cookie 未保存,缺少 %s: %q", want, got) + } + } + log := lastAPIRenewLog(t, store, "cid-partial") + if log.status != "need_password_login" { + t.Fatalf("status=%q want need_password_login, log=%+v", log.status, log) + } + if !strings.Contains(log.updatedCookieNames, "sgcookie") || !strings.Contains(log.updatedCookieNames, "_m_h5_tk") { + t.Fatalf("updated_cookie_names 未记录部分更新: %+v", log) + } + if !strings.Contains(log.responseContent, "silent-partial") { + t.Fatalf("response_content 应记录 silentHasLogin 响应: %+v", log) + } +} + +func TestAPICookieRenewOneSavesBrowserCookiesWhenVerifyFails(t *testing.T) { + store, cleanup := newSchedulerTestStore(t) + defer cleanup() + ctx := context.Background() + account := createSchedulerAccount(t, store, "cid-browser-fail", "unb=1; cookie2=c2") + browser := &schedulerFakeBrowser{quickCookies: "unb=1; cookie2=c2; sgcookie=s1; _m_h5_tk=tk_1; browser=b1"} + refresher := &schedulerFakePasswordRefresher{ch: make(chan string, 1)} + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/hasLogin.do": + http.SetCookie(w, &http.Cookie{Name: "sgcookie", Value: "s1"}) + _, _ = w.Write([]byte(`{"content":{"success":true}}`)) + case "/silentHasLogin.do": + http.SetCookie(w, &http.Cookie{Name: "_m_h5_tk", Value: "tk_1"}) + _, _ = w.Write([]byte(`{"content":{"success":true},"marker":"silent-browser-fail"}`)) + case "/setLoginSettings.do": + _, _ = w.Write([]byte(`{"content":{"success":true}}`)) + default: + http.NotFound(w, r) + } + })) + defer srv.Close() + + s := NewScheduler(store, nil, browser, refresher, nil) + s.api = schedulerRenewServiceFromServer(srv) + s.cooldown = NewCooldownManager() + s.apiCookieRenewOne(ctx, "batch-browser-fail", account) + refresher.waitCookie(t, "cid-browser-fail") + + if browser.quickCalls != 1 { + t.Fatalf("BrowserQuickRenew calls=%d want 1", browser.quickCalls) + } + if len(browser.quickInputs) != 1 || !strings.Contains(browser.quickInputs[0], "sgcookie=s1") || !strings.Contains(browser.quickInputs[0], "_m_h5_tk=tk_1") { + t.Fatalf("浏览器续期输入未使用接口部分更新: %#v", browser.quickInputs) + } + got, err := store.Cookies.GetValue(ctx, "cid-browser-fail") + if err != nil { + t.Fatalf("GetValue: %v", err) + } + for _, want := range []string{"sgcookie=s1", "_m_h5_tk=tk_1", "browser=b1"} { + if !strings.Contains(got, want) { + t.Fatalf("浏览器 Cookie 未保存,缺少 %s: %q", want, got) + } + } + log := lastAPIRenewLog(t, store, "cid-browser-fail") + if log.status != "need_password_login" { + t.Fatalf("status=%q want need_password_login, log=%+v", log.status, log) + } + if !strings.Contains(log.updatedCookieNames, "browser") { + t.Fatalf("updated_cookie_names 未记录浏览器更新: %+v", log) + } +} + +func TestAPICookieRenewOneBrowserRenewedAfterVerifySuccess(t *testing.T) { + store, cleanup := newSchedulerTestStore(t) + defer cleanup() + ctx := context.Background() + account := createSchedulerAccount(t, store, "cid-browser-ok", "unb=1; cookie2=c2") + browser := &schedulerFakeBrowser{quickCookies: "unb=1; cookie2=c2; browser=b1"} + var setLoginCalls atomic.Int32 + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/hasLogin.do": + _, _ = w.Write([]byte(`{"content":{"success":true}}`)) + case "/silentHasLogin.do": + _, _ = w.Write([]byte(`{"content":{"success":true},"marker":"silent-browser-ok"}`)) + case "/setLoginSettings.do": + if setLoginCalls.Add(1) == 2 { + http.SetCookie(w, &http.Cookie{Name: "havana_lgc2_77", Value: "lgc"}) + } + _, _ = w.Write([]byte(`{"content":{"success":true}}`)) + default: + http.NotFound(w, r) + } + })) + defer srv.Close() + + s := NewScheduler(store, nil, browser, nil, nil) + s.api = schedulerRenewServiceFromServer(srv) + s.cooldown = NewCooldownManager() + s.apiCookieRenewOne(ctx, "batch-browser-ok", account) + + if browser.quickCalls != 1 || setLoginCalls.Load() != 2 { + t.Fatalf("browser calls=%d setLoginCalls=%d", browser.quickCalls, setLoginCalls.Load()) + } + got, err := store.Cookies.GetValue(ctx, "cid-browser-ok") + if err != nil { + t.Fatalf("GetValue: %v", err) + } + for _, want := range []string{"browser=b1", "havana_lgc2_77=lgc"} { + if !strings.Contains(got, want) { + t.Fatalf("最终 Cookie 缺少 %s: %q", want, got) + } + } + log := lastAPIRenewLog(t, store, "cid-browser-ok") + if log.status != "browser_renewed" { + t.Fatalf("status=%q want browser_renewed, log=%+v", log.status, log) + } + if !strings.Contains(log.responseContent, "silent-browser-ok") { + t.Fatalf("response_content 应记录验证阶段 silentHasLogin 响应: %+v", log) + } +} diff --git a/internal/server/cookie_handlers.go b/internal/server/cookie_handlers.go index 60758db..f7c4ef9 100644 --- a/internal/server/cookie_handlers.go +++ b/internal/server/cookie_handlers.go @@ -96,9 +96,12 @@ func (s *Server) listCookieDetails(w http.ResponseWriter, r *http.Request) { "auto_confirm": d.AutoConfirm, "remark": d.Remark, "pause_duration": d.PauseDuration, + "show_browser": d.ShowBrowser, "username": d.Username, "nickname": cachedAccountNickname(d), "avatar_url": d.AvatarURL, + "login_method": d.LoginMethod, + "last_login_at": d.LastLoginAt, "profile_error": "", "ai_enabled": false, }) @@ -130,6 +133,8 @@ func (s *Server) getCookieDetails(w http.ResponseWriter, r *http.Request) { "username": d.Username, "nickname": cachedAccountNickname(d), "avatar_url": d.AvatarURL, + "login_method": d.LoginMethod, + "last_login_at": d.LastLoginAt, "profile_error": "", "has_cookie": true, }) @@ -162,8 +167,9 @@ func (s *Server) refreshCookieProfile(w http.ResponseWriter, r *http.Request) { // addCookie 添加账号 cookie。 func (s *Server) addCookie(w http.ResponseWriter, r *http.Request) { var req struct { - ID string `json:"id"` - Value string `json:"value"` + ID string `json:"id"` + Value string `json:"value"` + LoginMethod string `json:"login_method"` } if err := decodeJSON(r, &req); err != nil || req.ID == "" || req.Value == "" { writeErr(w, http.StatusBadRequest, "缺少 id 或 value") @@ -181,6 +187,11 @@ func (s *Server) addCookie(w http.ResponseWriter, r *http.Request) { if d, err := s.Store.Cookies.GetDetails(r.Context(), req.ID); err == nil { s.refreshAccountProfile(r.Context(), d) } + loginMethod := normalizeLoginMethod(req.LoginMethod) + if loginMethod == "" { + loginMethod = loginMethodManual + } + s.markSuccessfulLogin(r.Context(), req.ID, sess.UserID, loginMethod, "账号登录成功") if s.Manager != nil && s.Store.Cookies.GetStatus(r.Context(), req.ID) { if err := s.Manager.Restart(r.Context(), req.ID); err != nil { s.Logger.Error("更新后重启账号失败", "cookie_id", req.ID, "err", err) @@ -196,7 +207,8 @@ func (s *Server) updateCookie(w http.ResponseWriter, r *http.Request) { return } var req struct { - Value string `json:"value"` + Value string `json:"value"` + LoginMethod string `json:"login_method"` } if err := decodeJSON(r, &req); err != nil { writeErr(w, http.StatusBadRequest, "请求格式错误") @@ -214,6 +226,9 @@ func (s *Server) updateCookie(w http.ResponseWriter, r *http.Request) { if d, err := s.Store.Cookies.GetDetails(r.Context(), cid); err == nil { s.refreshAccountProfile(r.Context(), d) } + if loginMethod := normalizeLoginMethod(req.LoginMethod); loginMethod != "" { + s.markSuccessfulLogin(r.Context(), cid, sess.UserID, loginMethod, "账号登录成功") + } if s.Manager != nil && s.Store.Cookies.GetStatus(r.Context(), cid) { if err := s.Manager.Restart(r.Context(), cid); err != nil { s.Logger.Error("更新后重启账号失败", "cookie_id", cid, "err", err) @@ -225,7 +240,8 @@ func (s *Server) updateCookie(w http.ResponseWriter, r *http.Request) { // updateCookieLoginInfo 更新账号登录信息(用户名/密码/显示浏览器)。 func (s *Server) updateCookieLoginInfo(w http.ResponseWriter, r *http.Request) { cid := chi.URLParam(r, "cid") - if _, ok := s.requireCookieOwner(w, r, cid); !ok { + detail, ok := s.requireCookieOwner(w, r, cid) + if !ok { return } var req struct { @@ -242,14 +258,10 @@ func (s *Server) updateCookieLoginInfo(w http.ResponseWriter, r *http.Request) { if password == "" { password = req.LoginPassword } - sb := 0 - if req.ShowBrowser { - sb = 1 + if password == "" && detail != nil { + password = detail.Password } - _, err := s.Store.DB.ExecContext(r.Context(), - `UPDATE cookies SET username=?, password=?, show_browser=?, updated_at=CURRENT_TIMESTAMP WHERE id=?`, - req.Username, password, sb, cid) - if err != nil { + if err := s.Store.Cookies.UpdateLoginInfo(r.Context(), cid, req.Username, password, req.ShowBrowser); err != nil { writeErr(w, http.StatusInternalServerError, "更新失败") return } diff --git a/internal/server/cookie_handlers_test.go b/internal/server/cookie_handlers_test.go index dd5fae1..70f5612 100644 --- a/internal/server/cookie_handlers_test.go +++ b/internal/server/cookie_handlers_test.go @@ -93,6 +93,35 @@ func TestGetCookieDetails(t *testing.T) { } } +func TestListCookieDetailsIncludesShowBrowser(t *testing.T) { + srv, store, cleanup := newTestServer(t) + defer cleanup() + ctx := context.Background() + if err := store.Cookies.UpdateLoginInfo(ctx, "acc1", "login-user", "secret", true); err != nil { + t.Fatalf("UpdateLoginInfo: %v", err) + } + h := srv.Router() + cookie := loginHelper(t, h) + + req := httptest.NewRequest(http.MethodGet, "/cookies/details", nil) + req.AddCookie(cookie) + rec := httptest.NewRecorder() + h.ServeHTTP(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String()) + } + var details []map[string]any + if err := json.Unmarshal(rec.Body.Bytes(), &details); err != nil { + t.Fatalf("decode details: %v", err) + } + if len(details) != 1 || details[0]["show_browser"] != true { + t.Fatalf("账号列表应返回 show_browser=true: %+v", details) + } + if _, ok := details[0]["login_password"]; ok { + t.Fatalf("账号列表不应返回登录密码: %+v", details[0]) + } +} + // TestGetCookieDetailsBadCookie 无权账号 403。 func TestGetCookieDetailsBadCookie(t *testing.T) { srv, _, cleanup := newTestServer(t) @@ -111,8 +140,9 @@ func TestGetCookieDetailsBadCookie(t *testing.T) { // TestUpdateCookie 更新 cookie 值。 func TestUpdateCookie(t *testing.T) { - srv, _, cleanup := newTestServer(t) + srv, store, cleanup := newTestServer(t) defer cleanup() + ctx := context.Background() h := srv.Router() cookie := loginHelper(t, h) @@ -124,6 +154,50 @@ func TestUpdateCookie(t *testing.T) { if rec.Code != 200 { t.Fatalf("update status=%d body=%s", rec.Code, rec.Body.String()) } + d, err := store.Cookies.GetDetails(ctx, "acc1") + if err != nil { + t.Fatalf("GetDetails: %v", err) + } + if d.LoginMethod != "" || d.LastLoginAt != 0 { + t.Fatalf("普通 Cookie 更新不应刷新登录审计字段: method=%q last=%d", d.LoginMethod, d.LastLoginAt) + } +} + +func TestUpdateCookieQRLoginEnablesAccount(t *testing.T) { + srv, store, cleanup := newTestServer(t) + defer cleanup() + ctx := context.Background() + if err := store.Cookies.SetStatusWithReason(ctx, "acc1", false, "token 失效"); err != nil { + t.Fatalf("SetStatusWithReason: %v", err) + } + h := srv.Router() + cookie := loginHelper(t, h) + + body := `{"value":"unb=123; _m_h5_tk=qr_2;","login_method":"qr_scan"}` + req := httptest.NewRequest(http.MethodPut, "/cookies/acc1", strings.NewReader(body)) + req.AddCookie(cookie) + rec := httptest.NewRecorder() + h.ServeHTTP(rec, req) + if rec.Code != 200 { + t.Fatalf("update status=%d body=%s", rec.Code, rec.Body.String()) + } + if !store.Cookies.GetStatus(ctx, "acc1") { + t.Fatal("扫码登录成功后应重新启用账号") + } + var reason string + if err := store.DB.QueryRowContext(ctx, `SELECT disable_reason FROM cookie_status WHERE cookie_id='acc1'`).Scan(&reason); err != nil { + t.Fatalf("query disable_reason: %v", err) + } + if reason != "" { + t.Fatalf("扫码登录成功后应清空禁用原因,got %q", reason) + } + d, err := store.Cookies.GetDetails(ctx, "acc1") + if err != nil { + t.Fatalf("GetDetails: %v", err) + } + if d.LoginMethod != "qr_scan" || d.LastLoginAt == 0 { + t.Fatalf("扫码登录应刷新登录审计字段: %+v", d) + } } // TestUpdateCookieBadJSON 非法 JSON 400。 @@ -144,8 +218,9 @@ func TestUpdateCookieBadJSON(t *testing.T) { // TestUpdateCookieLoginInfo 更新登录信息。 func TestUpdateCookieLoginInfo(t *testing.T) { - srv, _, cleanup := newTestServer(t) + srv, store, cleanup := newTestServer(t) defer cleanup() + ctx := context.Background() h := srv.Router() cookie := loginHelper(t, h) @@ -157,6 +232,29 @@ func TestUpdateCookieLoginInfo(t *testing.T) { if rec.Code != 200 { t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String()) } + d, err := store.Cookies.GetDetails(ctx, "acc1") + if err != nil { + t.Fatalf("GetDetails: %v", err) + } + if d.Username != "u1" || d.Password != "p1" || !d.ShowBrowser { + t.Fatalf("登录信息未正确保存: %+v", d) + } + + body = `{"username":"u2","login_password":"","show_browser":false}` + req = httptest.NewRequest(http.MethodPut, "/cookies/acc1/login-info", strings.NewReader(body)) + req.AddCookie(cookie) + rec = httptest.NewRecorder() + h.ServeHTTP(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String()) + } + d, err = store.Cookies.GetDetails(ctx, "acc1") + if err != nil { + t.Fatalf("GetDetails after empty password: %v", err) + } + if d.Username != "u2" || d.Password != "p1" || d.ShowBrowser { + t.Fatalf("空密码更新应保留原密码并更新其他字段: %+v", d) + } } // TestUpdateCookieLoginInfoBadJSON 非法 JSON 400。 @@ -295,6 +393,35 @@ func TestAddCookieBad(t *testing.T) { } } +func TestAddCookieDefaultsManualLoginAudit(t *testing.T) { + srv, store, cleanup := newTestServer(t) + defer cleanup() + srv.Manager = nil + ctx := context.Background() + h := srv.Router() + cookie := loginHelper(t, h) + + body := `{"id":"acc-manual","value":"unb=456; _m_h5_tk=manual_1;"}` + req := httptest.NewRequest(http.MethodPost, "/cookies", strings.NewReader(body)) + req.AddCookie(cookie) + rec := httptest.NewRecorder() + h.ServeHTTP(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("add status=%d body=%s", rec.Code, rec.Body.String()) + } + d, err := store.Cookies.GetDetails(ctx, "acc-manual") + if err != nil { + t.Fatalf("GetDetails: %v", err) + } + if d.LoginMethod != "manual" || d.LastLoginAt == 0 { + t.Fatalf("手动新增 Cookie 应记录 manual 登录审计字段: %+v", d) + } + logs, err := store.LoginLogs.ListByCookie(ctx, "acc-manual", 10) + if err != nil || len(logs) != 1 || logs[0].Method != "manual" || logs[0].TriggerReason != "手动Cookie录入" { + t.Fatalf("手动新增 Cookie 应记录登录日志: logs=%#v err=%v", logs, err) + } +} + // TestAddCookieBadJSON 非法 JSON 400。 func TestAddCookieBadJSON(t *testing.T) { srv, _, cleanup := newTestServer(t) @@ -347,10 +474,10 @@ func TestCachedAccountNickname(t *testing.T) { // TestNormalizeProfileAvatarURL 头像 URL 归一。 func TestNormalizeProfileAvatarURL(t *testing.T) { cases := map[string]string{ - "": "", - "//img.alicdn.com/x.jpg": "https://img.alicdn.com/x.jpg", - "http://img.alicdn.com/x.jpg": "https://img.alicdn.com/x.jpg", - "https://img.alicdn.com/x.jpg": "https://img.alicdn.com/x.jpg", + "": "", + "//img.alicdn.com/x.jpg": "https://img.alicdn.com/x.jpg", + "http://img.alicdn.com/x.jpg": "https://img.alicdn.com/x.jpg", + "https://img.alicdn.com/x.jpg": "https://img.alicdn.com/x.jpg", " https://img.alicdn.com/x.jpg ": "https://img.alicdn.com/x.jpg", } for in, want := range cases { diff --git a/internal/server/item_publish_batch_handlers.go b/internal/server/item_publish_batch_handlers.go index 249a012..b18e263 100644 --- a/internal/server/item_publish_batch_handlers.go +++ b/internal/server/item_publish_batch_handlers.go @@ -273,7 +273,9 @@ func (s *Server) startItemPublishBatch(w http.ResponseWriter, r *http.Request) { // #nosec G118 -- 批处理必须在请求结束后继续,并由 30 分钟超时保证退出。 go func() { jobCtx, cancel := context.WithTimeout(context.Background(), 30*time.Minute) + s.registerPublishBatchCancel(batch.ID, cancel) defer cancel() + defer s.unregisterPublishBatchCancel(batch.ID) s.runItemPublishBatch(jobCtx, sess.UserID, batch.ID, false) }() writeJSON(w, http.StatusOK, map[string]any{"success": true, "batch_id": batch.ID}) @@ -306,6 +308,9 @@ func (s *Server) cancelItemPublishBatch(w http.ResponseWriter, r *http.Request) writeErr(w, http.StatusInternalServerError, "取消任务失败") return } + s.cancelPublishBatch(batchID) + _ = s.Store.PublishBatches.MarkUnfinishedFailed(r.Context(), batchID, "任务已取消") + _ = s.Store.PublishBatches.Recount(r.Context(), batchID) writeJSON(w, http.StatusOK, map[string]any{"success": true}) } @@ -328,7 +333,9 @@ func (s *Server) retryFailedItemPublishBatch(w http.ResponseWriter, r *http.Requ // #nosec G118 -- 批处理必须在请求结束后继续,并由 30 分钟超时保证退出。 go func() { jobCtx, cancel := context.WithTimeout(context.Background(), 30*time.Minute) + s.registerPublishBatchCancel(batchID, cancel) defer cancel() + defer s.unregisterPublishBatchCancel(batchID) s.runItemPublishBatch(jobCtx, sess.UserID, batchID, false) }() writeJSON(w, http.StatusOK, map[string]any{"success": true, "batch_id": batchID}) @@ -374,36 +381,122 @@ func (s *Server) runItemPublishBatch(ctx context.Context, userID int64, batchID } client := s.mtopClient() for idx, row := range rows { - status, err := s.Store.PublishBatches.BatchStatus(ctx, batchID) - if err != nil || status == "canceled" { - _ = s.Store.PublishBatches.Recount(ctx, batchID) + if ctx.Err() != nil { + s.finishInterruptedPublishBatch(ctx, userID, batchID) return } - _ = s.Store.PublishBatches.MarkRowRunning(ctx, row.ID) - if err := s.publishBatchRow(ctx, userID, client, row); err != nil { - _ = s.Store.PublishBatches.MarkRowFailed(ctx, row.ID, err.Error()) + wctx, cancel := publishStatusContext(ctx) + status, err := s.Store.PublishBatches.BatchStatus(wctx, batchID) + cancel() + if err != nil || status == "canceled" { + wctx, cancel := publishStatusContext(ctx) + if status == "canceled" { + _ = s.Store.PublishBatches.MarkUnfinishedFailed(wctx, batchID, "任务已取消") + } + _ = s.Store.PublishBatches.Recount(wctx, batchID) + cancel() + return } - _ = s.Store.PublishBatches.Recount(ctx, batchID) + wctx, cancel = publishStatusContext(ctx) + _ = s.Store.PublishBatches.MarkRowRunning(wctx, row.ID) + cancel() + if err := s.publishBatchRow(ctx, userID, client, row); err != nil { + message := err.Error() + if status, _ := s.Store.PublishBatches.BatchStatus(context.Background(), batchID); status == "canceled" { + message = "任务已取消" + } + wctx, cancel := publishStatusContext(ctx) + _ = s.Store.PublishBatches.MarkRowFailed(wctx, row.ID, message) + cancel() + } + wctx, cancel = publishStatusContext(ctx) + _ = s.Store.PublishBatches.Recount(wctx, batchID) + cancel() if idx < len(rows)-1 { delay := time.Duration(10+idx%21) * time.Second timer := time.NewTimer(delay) select { case <-ctx.Done(): timer.Stop() + s.finishInterruptedPublishBatch(ctx, userID, batchID) return case <-timer.C: } } } - _ = s.Store.PublishBatches.Recount(ctx, batchID) - batch, err := s.Store.PublishBatches.Get(ctx, userID, batchID) - if err == nil && batch.Status != "canceled" { - finalStatus := "completed" - if batch.SuccessCount == 0 && batch.FailedCount > 0 { - finalStatus = "failed" - } - _ = s.Store.PublishBatches.SetBatchStatus(ctx, batchID, finalStatus) + s.finishPublishBatch(ctx, userID, batchID) +} + +func (s *Server) registerPublishBatchCancel(batchID string, cancel context.CancelFunc) { + s.publishMu.Lock() + defer s.publishMu.Unlock() + if s.publishCancels == nil { + s.publishCancels = make(map[string]context.CancelFunc) } + if old := s.publishCancels[batchID]; old != nil { + old() + } + s.publishCancels[batchID] = cancel +} + +func (s *Server) unregisterPublishBatchCancel(batchID string) { + s.publishMu.Lock() + defer s.publishMu.Unlock() + delete(s.publishCancels, batchID) +} + +func (s *Server) cancelPublishBatch(batchID string) { + s.publishMu.Lock() + cancel := s.publishCancels[batchID] + s.publishMu.Unlock() + if cancel != nil { + cancel() + } +} + +func publishStatusContext(parent context.Context) (context.Context, context.CancelFunc) { + if parent != nil && parent.Err() == nil { + return context.WithTimeout(parent, 5*time.Second) + } + return context.WithTimeout(context.Background(), 5*time.Second) +} + +func (s *Server) finishInterruptedPublishBatch(ctx context.Context, userID int64, batchID string) { + wctx, cancel := publishStatusContext(ctx) + defer cancel() + if status, _ := s.Store.PublishBatches.BatchStatus(wctx, batchID); status == "canceled" { + _ = s.Store.PublishBatches.MarkUnfinishedFailed(wctx, batchID, "任务已取消") + _ = s.Store.PublishBatches.Recount(wctx, batchID) + return + } + _ = s.Store.PublishBatches.MarkUnfinishedFailed(wctx, batchID, "任务超时或已中断") + _ = s.Store.PublishBatches.Recount(wctx, batchID) + s.finishPublishBatch(wctx, userID, batchID) +} + +func (s *Server) finishPublishBatch(ctx context.Context, userID int64, batchID string) { + wctx, cancel := publishStatusContext(ctx) + defer cancel() + _ = s.Store.PublishBatches.Recount(wctx, batchID) + batch, err := s.Store.PublishBatches.Get(wctx, userID, batchID) + if err != nil || batch.Status == "canceled" { + return + } + finalStatus := finalPublishBatchStatus(batch) + _ = s.Store.PublishBatches.SetBatchStatus(wctx, batchID, finalStatus) +} + +func finalPublishBatchStatus(batch *db.ItemPublishBatch) string { + if batch == nil { + return "failed" + } + if batch.FailedCount > 0 { + if batch.SuccessCount > 0 { + return "partially_failed" + } + return "failed" + } + return "completed" } func (s *Server) publishBatchRow(ctx context.Context, userID int64, client mtop.Client, row db.ItemPublishBatchRow) error { @@ -444,6 +537,12 @@ func (s *Server) publishBatchRow(ctx context.Context, userID int64, client mtop. } return err } + if ctx.Err() != nil { + return ctx.Err() + } + if status, _ := s.Store.PublishBatches.BatchStatus(ctx, row.BatchID); status == "canceled" { + return context.Canceled + } if res.UpdatedCookies != "" && res.UpdatedCookies != cookieValue { if err := s.Store.Cookies.Save(ctx, row.CookieID, res.UpdatedCookies, userID); err != nil { s.Logger.Error("发布商品后保存刷新 cookie 失败", "cookie_id", row.CookieID, "err", err) @@ -762,9 +861,9 @@ func (s *Server) cookieValueForUser(ctx context.Context, userID int64, cookieID } func (s *Server) cardOwnedByUser(ctx context.Context, userID int64, cardID int64) bool { - var exists int + var exists bool err := s.Store.DB.QueryRowContext(ctx, `SELECT EXISTS(SELECT 1 FROM cards WHERE id=? AND user_id=?)`, cardID, userID).Scan(&exists) - return err == nil && exists != 0 + return err == nil && exists } func (s *Server) publishUploadRoot() string { diff --git a/internal/server/keyword_handlers.go b/internal/server/keyword_handlers.go index dbf1a85..ed85646 100644 --- a/internal/server/keyword_handlers.go +++ b/internal/server/keyword_handlers.go @@ -6,6 +6,7 @@ import ( "github.com/go-chi/chi/v5" "xianyu-go/internal/auth" + "xianyu-go/internal/db" ) // mountKeywordsReal 关键字端点。 @@ -98,11 +99,45 @@ func (s *Server) addKeywordWithItemID(w http.ResponseWriter, r *http.Request) { return } var req struct { - Keyword string `json:"keyword"` - Reply string `json:"reply"` - ItemID string `json:"item_id"` + Keyword string `json:"keyword"` + Reply string `json:"reply"` + ItemID string `json:"item_id"` + Keywords *[]struct { + Keyword string `json:"keyword"` + Reply string `json:"reply"` + ItemID string `json:"item_id"` + Type string `json:"type"` + ImageURL string `json:"image_url"` + } `json:"keywords"` } - if err := decodeJSON(r, &req); err != nil || req.Keyword == "" { + if err := decodeJSON(r, &req); err != nil { + writeErr(w, http.StatusBadRequest, "请求格式错误") + return + } + if req.Keywords != nil { + rows := make([]db.KeywordRow, 0, len(*req.Keywords)) + for _, item := range *req.Keywords { + if item.Keyword == "" { + writeErr(w, http.StatusBadRequest, "keyword 必填") + return + } + rows = append(rows, db.KeywordRow{ + CookieID: cid, + Keyword: item.Keyword, + Reply: item.Reply, + ItemID: item.ItemID, + Type: item.Type, + ImageURL: item.ImageURL, + }) + } + if err := s.Store.Keywords.ReplaceForCookie(r.Context(), cid, rows); err != nil { + writeErr(w, http.StatusInternalServerError, "保存失败") + return + } + writeJSON(w, http.StatusOK, map[string]any{"success": true}) + return + } + if req.Keyword == "" { writeErr(w, http.StatusBadRequest, "keyword 必填") return } diff --git a/internal/server/login_audit.go b/internal/server/login_audit.go new file mode 100644 index 0000000..2e9e3aa --- /dev/null +++ b/internal/server/login_audit.go @@ -0,0 +1,87 @@ +package server + +import ( + "context" + "strings" + "time" + + "xianyu-go/internal/db" +) + +const ( + loginMethodManual = "manual" + loginMethodPassword = "password" + loginMethodQRScan = "qr_scan" + loginStatusSuccess = "success" + loginStatusFailed = "failed" +) + +func normalizeLoginMethod(method string) string { + switch strings.ToLower(strings.TrimSpace(method)) { + case "manual", "cookie", "manual_cookie": + return loginMethodManual + case "password", "password_login": + return loginMethodPassword + case "qr", "qr_login", "qr_scan": + return loginMethodQRScan + default: + return strings.ToLower(strings.TrimSpace(method)) + } +} + +func (s *Server) markSuccessfulLogin(ctx context.Context, cookieID string, userID int64, method, message string) { + method = normalizeLoginMethod(method) + if method == "" { + return + } + at := time.Now().Unix() + if err := s.Store.Cookies.MarkLogin(ctx, cookieID, method, at); err != nil { + if s.Logger != nil { + s.Logger.Warn("记录账号登录方式失败", "cookie_id", cookieID, "method", method, "err", err) + } + return + } + if method == loginMethodPassword || method == loginMethodQRScan { + if err := s.Store.Cookies.SetStatusWithReason(ctx, cookieID, true, ""); err != nil && s.Logger != nil { + s.Logger.Warn("成功登录后启用账号失败", "cookie_id", cookieID, "method", method, "err", err) + } + } + s.addLoginLog(ctx, cookieID, userID, method, loginStatusSuccess, "", message, at) +} + +func (s *Server) addLoginLog(ctx context.Context, cookieID string, userID int64, method, status, failureReason, message string, at int64) { + if s.Store == nil || s.Store.LoginLogs == nil { + return + } + if at == 0 { + at = time.Now().Unix() + } + if err := s.Store.LoginLogs.Add(ctx, db.AccountLoginLog{ + CookieID: cookieID, + UserID: userID, + OwnerID: userID, + AccountIdentifier: cookieID, + Method: normalizeLoginMethod(method), + Status: status, + Message: truncate(message, 500), + TriggerReason: loginTriggerReason(method), + FailureReason: failureReason, + ErrorMessage: truncate(message, 500), + CreatedAt: at, + }); err != nil && s.Logger != nil { + s.Logger.Warn("记录账号登录日志失败", "cookie_id", cookieID, "method", method, "status", status, "err", err) + } +} + +func loginTriggerReason(method string) string { + switch normalizeLoginMethod(method) { + case loginMethodManual: + return "手动Cookie录入" + case loginMethodPassword: + return "账号密码登录" + case loginMethodQRScan: + return "扫码登录" + default: + return "" + } +} diff --git a/internal/server/ownership_helpers.go b/internal/server/ownership_helpers.go index 5353bae..70a92fd 100644 --- a/internal/server/ownership_helpers.go +++ b/internal/server/ownership_helpers.go @@ -71,11 +71,11 @@ func (s *Server) requireChannelOwner(w http.ResponseWriter, r *http.Request, cha writeErr(w, http.StatusUnauthorized, "未授权访问") return false } - var exists int + var exists bool err := s.Store.DB.QueryRowContext(r.Context(), `SELECT EXISTS(SELECT 1 FROM notification_channels WHERE id=? AND user_id=?)`, channelID, sess.UserID).Scan(&exists) - if err != nil || exists == 0 { + if err != nil || !exists { writeErr(w, http.StatusForbidden, "无权操作该通知渠道") return false } diff --git a/internal/server/password_login_handlers.go b/internal/server/password_login_handlers.go new file mode 100644 index 0000000..1be908e --- /dev/null +++ b/internal/server/password_login_handlers.go @@ -0,0 +1,429 @@ +package server + +import ( + "context" + "crypto/rand" + "encoding/base64" + "errors" + "net/http" + "strings" + "time" + + "github.com/go-chi/chi/v5" + + "xianyu-go/internal/auth" + "xianyu-go/internal/browser" + "xianyu-go/internal/db" +) + +type passwordLoginRunner interface { + PasswordLogin(ctx context.Context, account, password, cookieID, userDataDir string, headless bool) (map[string]string, error) +} + +type passwordLoginEventRunner interface { + PasswordLoginWithEvents(ctx context.Context, account, password, cookieID, userDataDir string, headless bool, onEvent browser.PasswordLoginEventHandler) (map[string]string, error) +} + +const ( + passwordLoginSessionMaxAge = time.Hour + passwordLoginProcessingTimeout = 5 * time.Minute + passwordLoginBaxiaPunishReason = "baxia_punish_captcha" + passwordLoginBaxiaPunishCooldown = 5 +) + +type passwordLoginSession struct { + ID string + AccountID string + Account string + UserID int64 + Status string + Message string + Error string + Reason string + VerificationURL string + ScreenshotPath string + QRCodeURL string + CooldownHours int + IsNewAccount bool + CookieCount int + ShowBrowser bool + CreatedAt time.Time + cancel context.CancelFunc +} + +func (s *Server) mountPasswordLogin(r chi.Router) { + r.Post("/password-login", s.startPasswordLogin) + r.Get("/password-login/check/{session_id}", s.checkPasswordLogin) + r.Delete("/password-login/cancel/{session_id}", s.cancelPasswordLogin) +} + +func (s *Server) startPasswordLogin(w http.ResponseWriter, r *http.Request) { + var req struct { + AccountID string `json:"account_id"` + CookieID string `json:"cookie_id"` + Account string `json:"account"` + Username string `json:"username"` + Password string `json:"password"` + ShowBrowser bool `json:"show_browser"` + } + if err := decodeJSON(r, &req); err != nil { + writeJSON(w, http.StatusOK, map[string]any{"success": false, "message": "请求格式错误"}) + return + } + accountID := firstNonEmpty(req.AccountID, req.CookieID) + account := firstNonEmpty(req.Account, req.Username) + accountID = strings.TrimSpace(accountID) + account = strings.TrimSpace(account) + if accountID == "" || account == "" || req.Password == "" { + writeJSON(w, http.StatusOK, map[string]any{"success": false, "message": "账号ID、登录账号和密码不能为空"}) + return + } + if s.PasswordLogin == nil { + writeJSON(w, http.StatusOK, map[string]any{"success": false, "message": "浏览器登录服务不可用"}) + return + } + sess := auth.SessionFromContext(r.Context()) + if sess == nil { + writeErr(w, http.StatusUnauthorized, "未授权访问") + return + } + if ok, message := s.canStartPasswordLogin(r.Context(), sess.UserID, accountID); !ok { + writeJSON(w, http.StatusOK, map[string]any{"success": false, "message": message}) + return + } + s.cleanupExpiredPasswordLoginSessions() + if sid := s.currentPasswordLoginSession(accountID); sid != "" { + writeJSON(w, http.StatusOK, map[string]any{ + "success": true, + "session_id": sid, + "status": "processing", + "message": "账号正在处理中,请稍候...", + }) + return + } + + sessionID, err := newPasswordSessionID() + if err != nil { + writeJSON(w, http.StatusOK, map[string]any{"success": false, "message": "创建登录会话失败"}) + return + } + ctx, cancel := context.WithCancel(context.Background()) + loginSession := &passwordLoginSession{ + ID: sessionID, + AccountID: accountID, + Account: account, + UserID: sess.UserID, + Status: "processing", + Message: "登录处理中,请稍候...", + ShowBrowser: req.ShowBrowser, + CreatedAt: time.Now(), + cancel: cancel, + } + s.passwordMu.Lock() + s.passwordSessions[sessionID] = loginSession + s.passwordProcessing[accountID] = sessionID + s.passwordMu.Unlock() + + go s.runPasswordLoginSession(ctx, loginSession, req.Password) + + writeJSON(w, http.StatusOK, map[string]any{ + "success": true, + "session_id": sessionID, + "status": "processing", + "message": "登录任务已启动,请等待...", + }) +} + +func (s *Server) checkPasswordLogin(w http.ResponseWriter, r *http.Request) { + sessionID := chi.URLParam(r, "session_id") + s.cleanupExpiredPasswordLoginSessions() + + s.passwordMu.Lock() + session, ok := s.passwordSessions[sessionID] + if !ok { + s.passwordMu.Unlock() + writeJSON(w, http.StatusOK, map[string]any{"status": "not_found", "message": "会话不存在或已过期"}) + return + } + response := passwordSessionResponse(session) + if session.Status == "success" || session.Status == "failed" { + delete(s.passwordSessions, sessionID) + delete(s.passwordProcessing, session.AccountID) + } + s.passwordMu.Unlock() + writeJSON(w, http.StatusOK, response) +} + +func (s *Server) cancelPasswordLogin(w http.ResponseWriter, r *http.Request) { + sessionID := chi.URLParam(r, "session_id") + s.passwordMu.Lock() + session, ok := s.passwordSessions[sessionID] + if !ok { + s.passwordMu.Unlock() + writeJSON(w, http.StatusOK, map[string]any{"success": false, "code": 404, "message": "会话不存在", "data": nil}) + return + } + if session.cancel != nil { + session.cancel() + } + delete(s.passwordSessions, sessionID) + delete(s.passwordProcessing, session.AccountID) + s.passwordMu.Unlock() + writeJSON(w, http.StatusOK, map[string]any{"success": true, "code": 200, "message": "登录会话已取消", "data": nil}) +} + +func (s *Server) runPasswordLoginSession(ctx context.Context, session *passwordLoginSession, password string) { + var ( + cookies map[string]string + err error + ) + headless := !session.ShowBrowser + if runner, ok := s.PasswordLogin.(passwordLoginEventRunner); ok { + cookies, err = runner.PasswordLoginWithEvents(ctx, session.Account, password, session.AccountID, "", headless, func(event browser.PasswordLoginEvent) { + s.applyPasswordLoginEvent(session, event) + }) + } else { + cookies, err = s.PasswordLogin.PasswordLogin(ctx, session.Account, password, session.AccountID, "", headless) + } + if err != nil { + event := browser.PasswordLoginEventFromError(err) + status := event.Status + if status == "" { + status = "failed" + } + reason := passwordLoginReason(err) + s.failPasswordLoginSession(session, status, err.Error(), reason, event.CooldownHours) + s.addLoginLog(context.Background(), session.AccountID, session.UserID, loginMethodPassword, loginStatusFailed, reason, err.Error(), 0) + return + } + accountID, isNew, err := s.savePasswordLoginCookies(ctx, session, password, cookies) + if err != nil { + s.failPasswordLoginSession(session, "failed", "保存登录结果失败: "+err.Error(), "", 0) + s.addLoginLog(context.Background(), session.AccountID, session.UserID, loginMethodPassword, loginStatusFailed, "cookie_update_failed", err.Error(), 0) + return + } + s.completePasswordLoginSession(session, func(current *passwordLoginSession) { + current.Status = "success" + current.Message = "账号 " + accountID + " 登录成功" + current.AccountID = accountID + current.IsNewAccount = isNew + current.CookieCount = len(cookies) + }) +} + +func (s *Server) savePasswordLoginCookies(ctx context.Context, session *passwordLoginSession, password string, cookies map[string]string) (string, bool, error) { + if len(cookies) == 0 { + return "", false, errors.New("浏览器未返回 cookie") + } + accountID := cookieAccountID(cookies, session.AccountID) + cookieValue := browser.MarshalCookies(cookies) + _, err := s.Store.Cookies.GetDetails(ctx, accountID) + isNew := errors.Is(err, db.ErrNotFound) + if err != nil && !errors.Is(err, db.ErrNotFound) { + return "", false, err + } + if err := s.Store.Cookies.Save(ctx, accountID, cookieValue, session.UserID); err != nil { + return "", false, err + } + if err := s.Store.Cookies.UpdateLoginInfo(ctx, accountID, session.Account, password, session.ShowBrowser); err != nil { + return "", false, err + } + s.markSuccessfulLogin(ctx, accountID, session.UserID, loginMethodPassword, "账号密码登录成功") + if s.Store.Tokens != nil { + _ = s.Store.Tokens.Clear(ctx, accountID) + } + if d, err := s.Store.Cookies.GetDetails(ctx, accountID); err == nil { + s.refreshAccountProfile(ctx, d) + } + if s.Manager != nil && s.Store.Cookies.GetStatus(ctx, accountID) { + if err := s.Manager.Restart(ctx, accountID); err != nil && s.Logger != nil { + s.Logger.Warn("密码登录后重启账号失败", "cookie_id", accountID, "err", err) + } + } + return accountID, isNew, nil +} + +func (s *Server) canStartPasswordLogin(ctx context.Context, userID int64, accountID string) (bool, string) { + d, err := s.Store.Cookies.GetDetails(ctx, accountID) + if err == nil { + if d.UserID != userID { + return false, "无权限操作该账号" + } + if !s.Store.Cookies.GetStatus(ctx, accountID) { + return false, "账号已禁用,请先在账号管理中启用" + } + return true, "" + } + if errors.Is(err, db.ErrNotFound) { + return true, "" + } + return false, "查询账号失败" +} + +func (s *Server) currentPasswordLoginSession(accountID string) string { + s.passwordMu.Lock() + defer s.passwordMu.Unlock() + return s.passwordProcessing[accountID] +} + +func (s *Server) completePasswordLoginSession(session *passwordLoginSession, mutate func(*passwordLoginSession)) { + s.finishPasswordLoginSession(session, mutate) +} + +func (s *Server) updatePasswordLoginSession(session *passwordLoginSession, mutate func(*passwordLoginSession)) bool { + s.passwordMu.Lock() + defer s.passwordMu.Unlock() + current, ok := s.passwordSessions[session.ID] + if !ok || current != session { + return false + } + mutate(current) + return true +} + +func (s *Server) finishPasswordLoginSession(session *passwordLoginSession, mutate func(*passwordLoginSession)) { + s.passwordMu.Lock() + defer s.passwordMu.Unlock() + current, ok := s.passwordSessions[session.ID] + if !ok || current != session { + return + } + originalAccountID := current.AccountID + mutate(current) + delete(s.passwordProcessing, originalAccountID) + delete(s.passwordProcessing, current.AccountID) +} + +func (s *Server) applyPasswordLoginEvent(session *passwordLoginSession, event browser.PasswordLoginEvent) { + if event.Status == "" { + return + } + apply := func(current *passwordLoginSession) { + current.Status = event.Status + current.Message = firstNonEmpty(event.Message, current.Message) + current.Error = firstNonEmpty(event.Error, current.Error) + current.Reason = firstNonEmpty(event.Reason, current.Reason) + current.VerificationURL = firstNonEmpty(event.VerificationURL, current.VerificationURL) + current.ScreenshotPath = firstNonEmpty(event.ScreenshotPath, current.ScreenshotPath) + current.QRCodeURL = firstNonEmpty(event.QRCodeURL, current.QRCodeURL) + if event.CooldownHours > 0 { + current.CooldownHours = event.CooldownHours + } + } + if passwordLoginEventIsTerminal(event.Status) { + s.finishPasswordLoginSession(session, apply) + return + } + s.updatePasswordLoginSession(session, apply) +} + +func (s *Server) failPasswordLoginSession(session *passwordLoginSession, status, message, reason string, cooldownHours int) { + s.completePasswordLoginSession(session, func(current *passwordLoginSession) { + current.Status = status + current.Message = message + current.Error = message + current.Reason = reason + current.CooldownHours = cooldownHours + }) +} + +func passwordLoginEventIsTerminal(status string) bool { + return status == "success" || status == browser.PasswordLoginStatusFailed +} + +func (s *Server) cleanupExpiredPasswordLoginSessions() { + now := time.Now() + s.passwordMu.Lock() + defer s.passwordMu.Unlock() + for sessionID, session := range s.passwordSessions { + age := now.Sub(session.CreatedAt) + if session.Status == "processing" && age > passwordLoginProcessingTimeout { + if session.cancel != nil { + session.cancel() + } + session.Status = "failed" + session.Message = "登录处理超时,请稍后重试" + session.Error = session.Message + delete(s.passwordProcessing, session.AccountID) + } + if age <= passwordLoginSessionMaxAge { + continue + } + if session.cancel != nil { + session.cancel() + } + delete(s.passwordSessions, sessionID) + delete(s.passwordProcessing, session.AccountID) + } +} + +func passwordSessionResponse(session *passwordLoginSession) map[string]any { + resp := map[string]any{ + "status": session.Status, + "message": session.Message, + } + if session.Status == "success" { + resp["account_id"] = session.AccountID + resp["is_new_account"] = session.IsNewAccount + resp["cookie_count"] = session.CookieCount + } + if session.Status == "failed" { + resp["error"] = session.Error + if session.Reason != "" { + resp["reason"] = session.Reason + } + if session.CooldownHours > 0 { + resp["cooldown_hours"] = session.CooldownHours + } + } + if session.Status == "verification_required" { + resp["verification_url"] = session.VerificationURL + resp["screenshot_path"] = session.ScreenshotPath + resp["qr_code_url"] = session.QRCodeURL + resp["error"] = session.Error + if session.CooldownHours > 0 { + resp["cooldown_hours"] = session.CooldownHours + } + } + return resp +} + +func newPasswordSessionID() (string, error) { + var b [18]byte + if _, err := rand.Read(b[:]); err != nil { + return "", err + } + return base64.RawURLEncoding.EncodeToString(b[:]), nil +} + +func cookieAccountID(cookies map[string]string, fallback string) string { + for k, v := range cookies { + if strings.EqualFold(strings.TrimSpace(k), "unb") && strings.TrimSpace(v) != "" { + return strings.TrimSpace(v) + } + } + return fallback +} + +func loginStatusForPasswordError(err error) string { + return browser.PasswordLoginEventFromError(err).Status +} + +func passwordLoginReason(err error) string { + if err == nil { + return "" + } + msg := err.Error() + if strings.Contains(msg, "账密错误") || strings.Contains(msg, "账号密码错误") || + strings.Contains(msg, "用户名或密码错误") || strings.Contains(msg, "密码错误") { + return "bad_credentials" + } + event := browser.PasswordLoginEventFromError(err) + if event.Reason != "" { + return event.Reason + } + if event.Status == browser.PasswordLoginStatusVerificationRequired { + return "verification_required" + } + return "other" +} diff --git a/internal/server/password_login_handlers_test.go b/internal/server/password_login_handlers_test.go new file mode 100644 index 0000000..d2e0901 --- /dev/null +++ b/internal/server/password_login_handlers_test.go @@ -0,0 +1,384 @@ +package server + +import ( + "context" + "encoding/json" + "errors" + "net/http" + "net/http/httptest" + "strings" + "sync" + "testing" + "time" + + "xianyu-go/internal/browser" + "xianyu-go/internal/db" +) + +type fakePasswordLoginRunner struct { + mu sync.Mutex + cookies map[string]string + err error + block chan struct{} + events []browser.PasswordLoginEvent + calls int + lastAccount string + lastHeadless bool +} + +func (f *fakePasswordLoginRunner) PasswordLogin(ctx context.Context, account, password, cookieID, userDataDir string, headless bool) (map[string]string, error) { + f.mu.Lock() + f.calls++ + f.lastAccount = account + f.lastHeadless = headless + f.mu.Unlock() + if f.block != nil { + select { + case <-f.block: + case <-ctx.Done(): + return nil, ctx.Err() + } + } + return f.cookies, f.err +} + +func (f *fakePasswordLoginRunner) PasswordLoginWithEvents(ctx context.Context, account, password, cookieID, userDataDir string, headless bool, onEvent browser.PasswordLoginEventHandler) (map[string]string, error) { + for _, event := range f.events { + onEvent(event) + } + return f.PasswordLogin(ctx, account, password, cookieID, userDataDir, headless) +} + +func (f *fakePasswordLoginRunner) snapshot() (int, string, bool) { + f.mu.Lock() + defer f.mu.Unlock() + return f.calls, f.lastAccount, f.lastHeadless +} + +func loginForPasswordTest(t *testing.T, h http.Handler) *http.Cookie { + t.Helper() + req := httptest.NewRequest(http.MethodPost, "/login", strings.NewReader(`{"username":"admin","password":"pw"}`)) + rec := httptest.NewRecorder() + h.ServeHTTP(rec, req) + if rec.Code != http.StatusOK || len(rec.Result().Cookies()) == 0 { + t.Fatalf("login status=%d body=%s", rec.Code, rec.Body.String()) + } + return rec.Result().Cookies()[0] +} + +func startPasswordLoginForTest(t *testing.T, h http.Handler, cookie *http.Cookie, body string) map[string]any { + t.Helper() + req := httptest.NewRequest(http.MethodPost, "/password-login", strings.NewReader(body)) + req.AddCookie(cookie) + rec := httptest.NewRecorder() + h.ServeHTTP(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("start status=%d body=%s", rec.Code, rec.Body.String()) + } + var out map[string]any + if err := json.Unmarshal(rec.Body.Bytes(), &out); err != nil { + t.Fatalf("decode start: %v body=%s", err, rec.Body.String()) + } + return out +} + +func checkPasswordLoginForTest(t *testing.T, h http.Handler, cookie *http.Cookie, sessionID string) map[string]any { + t.Helper() + req := httptest.NewRequest(http.MethodGet, "/password-login/check/"+sessionID, nil) + req.AddCookie(cookie) + rec := httptest.NewRecorder() + h.ServeHTTP(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("check status=%d body=%s", rec.Code, rec.Body.String()) + } + var out map[string]any + if err := json.Unmarshal(rec.Body.Bytes(), &out); err != nil { + t.Fatalf("decode check: %v body=%s", err, rec.Body.String()) + } + return out +} + +func cancelPasswordLoginForTest(t *testing.T, h http.Handler, cookie *http.Cookie, sessionID string) { + t.Helper() + req := httptest.NewRequest(http.MethodDelete, "/password-login/cancel/"+sessionID, nil) + req.AddCookie(cookie) + rec := httptest.NewRecorder() + h.ServeHTTP(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("cancel status=%d body=%s", rec.Code, rec.Body.String()) + } +} + +func waitPasswordLoginStatus(t *testing.T, h http.Handler, cookie *http.Cookie, sessionID, want string) map[string]any { + t.Helper() + var out map[string]any + for i := 0; i < 50; i++ { + out = checkPasswordLoginForTest(t, h, cookie, sessionID) + if out["status"] == want { + return out + } + time.Sleep(10 * time.Millisecond) + } + t.Fatalf("status did not reach %q, last=%+v", want, out) + return nil +} + +func waitLoginLogCount(t *testing.T, store *db.Store, cookieID string, want int) []db.AccountLoginLog { + t.Helper() + var logs []db.AccountLoginLog + var err error + for i := 0; i < 50; i++ { + logs, err = store.LoginLogs.ListByCookie(context.Background(), cookieID, 10) + if err == nil && len(logs) >= want { + return logs + } + time.Sleep(10 * time.Millisecond) + } + t.Fatalf("login logs did not reach %d: logs=%#v err=%v", want, logs, err) + return nil +} + +func TestPasswordLoginSessionSuccessSavesCookiesAndAudit(t *testing.T) { + srv, store, cleanup := newTestServer(t) + defer cleanup() + srv.Manager = nil + fake := &fakePasswordLoginRunner{cookies: map[string]string{"unb": "acc1", "_m_h5_tk": "fresh"}} + srv.PasswordLogin = fake + h := srv.Router() + cookie := loginForPasswordTest(t, h) + if err := store.Tokens.Save(context.Background(), "acc1", "did", "token", time.Now().Add(time.Hour).Unix()); err != nil { + t.Fatalf("save token: %v", err) + } + + start := startPasswordLoginForTest(t, h, cookie, `{"account_id":"acc1","account":"login-user","password":"secret","show_browser":false}`) + if start["success"] != true || start["status"] != "processing" { + t.Fatalf("start response=%+v", start) + } + sessionID, _ := start["session_id"].(string) + if sessionID == "" { + t.Fatalf("missing session_id: %+v", start) + } + done := waitPasswordLoginStatus(t, h, cookie, sessionID, "success") + if done["account_id"] != "acc1" || done["is_new_account"] != false { + t.Fatalf("success response=%+v", done) + } + calls, account, headless := fake.snapshot() + if calls != 1 || account != "login-user" || !headless { + t.Fatalf("PasswordLogin 调用异常: calls=%d account=%q headless=%v", calls, account, headless) + } + saved, _ := store.Cookies.GetValue(context.Background(), "acc1") + if !strings.Contains(saved, "_m_h5_tk=fresh") { + t.Fatalf("cookie 未保存: %q", saved) + } + d, err := store.Cookies.GetDetails(context.Background(), "acc1") + if err != nil { + t.Fatalf("GetDetails: %v", err) + } + if d.Username != "login-user" || d.Password != "secret" || d.ShowBrowser || d.LoginMethod != "password" || d.LastLoginAt == 0 { + t.Fatalf("登录信息/审计字段异常: %+v", d) + } + if _, err := store.Tokens.Get(context.Background(), "acc1"); !errors.Is(err, db.ErrNotFound) { + t.Fatalf("密码登录成功应清 token,got %v", err) + } + logs, err := store.LoginLogs.ListByCookie(context.Background(), "acc1", 10) + if err != nil || len(logs) != 1 || logs[0].Status != "success" { + t.Fatalf("登录日志异常: logs=%#v err=%v", logs, err) + } +} + +func TestPasswordLoginUnavailableWhenBrowserManagerNil(t *testing.T) { + srv, _, cleanup := newTestServer(t) + defer cleanup() + h := srv.Router() + cookie := loginForPasswordTest(t, h) + + start := startPasswordLoginForTest(t, h, cookie, `{"account_id":"acc1","account":"u","password":"p"}`) + if start["success"] != false || start["message"] != "浏览器登录服务不可用" { + t.Fatalf("nil 浏览器应返回不可用且不启动登录: %+v", start) + } +} + +func TestPasswordLoginSessionShowBrowserRunsVisibleAndSavesPreference(t *testing.T) { + srv, store, cleanup := newTestServer(t) + defer cleanup() + srv.Manager = nil + fake := &fakePasswordLoginRunner{cookies: map[string]string{"unb": "acc1", "_m_h5_tk": "fresh"}} + srv.PasswordLogin = fake + h := srv.Router() + cookie := loginForPasswordTest(t, h) + + start := startPasswordLoginForTest(t, h, cookie, `{"account_id":"acc1","account":"login-user","password":"secret","show_browser":true}`) + sessionID, _ := start["session_id"].(string) + if sessionID == "" { + t.Fatalf("missing session_id: %+v", start) + } + waitPasswordLoginStatus(t, h, cookie, sessionID, "success") + + calls, account, headless := fake.snapshot() + if calls != 1 || account != "login-user" || headless { + t.Fatalf("show_browser=true 应使用可视浏览器: calls=%d account=%q headless=%v", calls, account, headless) + } + d, err := store.Cookies.GetDetails(context.Background(), "acc1") + if err != nil { + t.Fatalf("GetDetails: %v", err) + } + if !d.ShowBrowser { + t.Fatalf("show_browser=true 应按原请求落库: %+v", d) + } +} + +func TestPasswordLoginDuplicateStartReturnsProcessingSession(t *testing.T) { + srv, store, cleanup := newTestServer(t) + defer cleanup() + srv.Manager = nil + fake := &fakePasswordLoginRunner{block: make(chan struct{}), cookies: map[string]string{"unb": "acc1"}} + srv.PasswordLogin = fake + h := srv.Router() + cookie := loginForPasswordTest(t, h) + + first := startPasswordLoginForTest(t, h, cookie, `{"account_id":"acc1","account":"u","password":"p"}`) + second := startPasswordLoginForTest(t, h, cookie, `{"account_id":"acc1","account":"u","password":"p"}`) + if first["session_id"] == "" || second["session_id"] != first["session_id"] || second["status"] != "processing" { + t.Fatalf("重复启动应返回同一 processing 会话: first=%+v second=%+v", first, second) + } + + cancelPasswordLoginForTest(t, h, cookie, first["session_id"].(string)) + waitLoginLogCount(t, store, "acc1", 1) +} + +func TestPasswordLoginVerificationRequiredKeepsProcessingLock(t *testing.T) { + srv, store, cleanup := newTestServer(t) + defer cleanup() + srv.Manager = nil + fake := &fakePasswordLoginRunner{ + block: make(chan struct{}), + events: []browser.PasswordLoginEvent{{ + Status: browser.PasswordLoginStatusVerificationRequired, + Message: "需要人脸验证,请查看验证截图", + Error: "需要人脸验证", + ScreenshotPath: "/tmp/face.png", + }}, + cookies: map[string]string{"unb": "acc1"}, + } + srv.PasswordLogin = fake + h := srv.Router() + cookie := loginForPasswordTest(t, h) + + first := startPasswordLoginForTest(t, h, cookie, `{"account_id":"acc1","account":"u","password":"p"}`) + sessionID := first["session_id"].(string) + waitPasswordLoginStatus(t, h, cookie, sessionID, "verification_required") + second := startPasswordLoginForTest(t, h, cookie, `{"account_id":"acc1","account":"u","password":"p"}`) + if second["session_id"] != sessionID { + t.Fatalf("验证码等待期间应继续复用同一会话: first=%+v second=%+v", first, second) + } + if calls, _, _ := fake.snapshot(); calls != 1 { + t.Fatalf("验证码等待期间不应启动第二个浏览器任务,calls=%d", calls) + } + + cancelPasswordLoginForTest(t, h, cookie, sessionID) + waitLoginLogCount(t, store, "acc1", 1) +} + +func TestPasswordLoginProcessingTimeoutReleasesAccount(t *testing.T) { + srv, store, cleanup := newTestServer(t) + defer cleanup() + srv.Manager = nil + fake := &fakePasswordLoginRunner{block: make(chan struct{}), cookies: map[string]string{"unb": "acc1"}} + srv.PasswordLogin = fake + h := srv.Router() + cookie := loginForPasswordTest(t, h) + + first := startPasswordLoginForTest(t, h, cookie, `{"account_id":"acc1","account":"u","password":"p"}`) + sessionID := first["session_id"].(string) + srv.passwordMu.Lock() + srv.passwordSessions[sessionID].CreatedAt = time.Now().Add(-(passwordLoginProcessingTimeout + time.Second)) + srv.passwordMu.Unlock() + + second := startPasswordLoginForTest(t, h, cookie, `{"account_id":"acc1","account":"u","password":"p"}`) + if second["session_id"] == "" || second["session_id"] == sessionID { + t.Fatalf("processing 超时后应创建新会话: first=%+v second=%+v", first, second) + } + oldStatus := checkPasswordLoginForTest(t, h, cookie, sessionID) + if oldStatus["status"] != "failed" { + t.Fatalf("超时旧会话应标记 failed: %+v", oldStatus) + } + cancelPasswordLoginForTest(t, h, cookie, second["session_id"].(string)) + waitLoginLogCount(t, store, "acc1", 2) +} + +func TestPasswordLoginSessionExpiresAfterOneHour(t *testing.T) { + srv, store, cleanup := newTestServer(t) + defer cleanup() + srv.Manager = nil + fake := &fakePasswordLoginRunner{block: make(chan struct{}), cookies: map[string]string{"unb": "acc1"}} + srv.PasswordLogin = fake + h := srv.Router() + cookie := loginForPasswordTest(t, h) + + start := startPasswordLoginForTest(t, h, cookie, `{"account_id":"acc1","account":"u","password":"p"}`) + sessionID := start["session_id"].(string) + srv.passwordMu.Lock() + srv.passwordSessions[sessionID].CreatedAt = time.Now().Add(-(passwordLoginSessionMaxAge + time.Second)) + srv.passwordMu.Unlock() + + done := checkPasswordLoginForTest(t, h, cookie, sessionID) + if done["status"] != "not_found" { + t.Fatalf("1小时后会话应过期: %+v", done) + } + waitLoginLogCount(t, store, "acc1", 1) +} + +func TestPasswordLoginVerificationRequired(t *testing.T) { + srv, store, cleanup := newTestServer(t) + defer cleanup() + srv.Manager = nil + srv.PasswordLogin = &fakePasswordLoginRunner{ + events: []browser.PasswordLoginEvent{{ + Status: browser.PasswordLoginStatusVerificationRequired, + Message: "需要人脸验证,请查看验证截图", + Error: "需要人脸验证", + ScreenshotPath: "/tmp/face.png", + }}, + err: errors.New("需要人脸验证"), + } + h := srv.Router() + cookie := loginForPasswordTest(t, h) + + start := startPasswordLoginForTest(t, h, cookie, `{"account_id":"acc1","account":"u","password":"p"}`) + sessionID := start["session_id"].(string) + done := waitPasswordLoginStatus(t, h, cookie, sessionID, "verification_required") + if done["error"] == "" { + t.Fatalf("verification_required 应带 error: %+v", done) + } + if done["screenshot_path"] != "/tmp/face.png" { + t.Fatalf("verification_required 应带截图: %+v", done) + } + again := checkPasswordLoginForTest(t, h, cookie, sessionID) + if again["status"] != "verification_required" { + t.Fatalf("验证态会话应保留: %+v", again) + } + logs := waitLoginLogCount(t, store, "acc1", 1) + if logs[0].FailureReason != "verification_required" { + t.Fatalf("验证态应记录 failure_reason: %#v", logs) + } +} + +func TestPasswordLoginBaxiaReason(t *testing.T) { + srv, store, cleanup := newTestServer(t) + defer cleanup() + srv.Manager = nil + srv.PasswordLogin = &fakePasswordLoginRunner{err: errors.New("baxia-punish 风控图形验证")} + h := srv.Router() + cookie := loginForPasswordTest(t, h) + + start := startPasswordLoginForTest(t, h, cookie, `{"account_id":"acc1","account":"u","password":"p"}`) + sessionID := start["session_id"].(string) + done := waitPasswordLoginStatus(t, h, cookie, sessionID, "failed") + if done["reason"] != "baxia_punish_captcha" || done["cooldown_hours"] != float64(5) { + t.Fatalf("baxia 错误应带 reason/cooldown: %+v", done) + } + logs, err := store.LoginLogs.ListByCookie(context.Background(), "acc1", 10) + if err != nil || len(logs) != 1 || logs[0].FailureReason != "baxia_punish_captcha" { + t.Fatalf("baxia 错误应记录专用 failure_reason: logs=%#v err=%v", logs, err) + } +} diff --git a/internal/server/publish_batch_run_test.go b/internal/server/publish_batch_run_test.go index adb1654..275896b 100644 --- a/internal/server/publish_batch_run_test.go +++ b/internal/server/publish_batch_run_test.go @@ -20,6 +20,25 @@ import ( // minimalPNG 是一张 1x1 PNG,供发布批次图片 zip 复用。 var minimalPNG = []byte{0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1F, 0x15, 0xC4, 0x89, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9C, 0x63, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x01, 0x0D, 0x0A, 0x2D, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82} +func TestFinalPublishBatchStatus(t *testing.T) { + cases := []struct { + name string + in db.ItemPublishBatch + want string + }{ + {name: "completed", in: db.ItemPublishBatch{SuccessCount: 2}, want: "completed"}, + {name: "failed", in: db.ItemPublishBatch{FailedCount: 2}, want: "failed"}, + {name: "partially failed", in: db.ItemPublishBatch{SuccessCount: 1, FailedCount: 1}, want: "partially_failed"}, + } + for _, tt := range cases { + t.Run(tt.name, func(t *testing.T) { + if got := finalPublishBatchStatus(&tt.in); got != tt.want { + t.Fatalf("got %q want %q", got, tt.want) + } + }) + } +} + // buildImageZip 构造含一张图片的 zip 字节流。 func buildImageZip(t *testing.T) []byte { t.Helper() @@ -59,6 +78,33 @@ func previewPublishBatch(t *testing.T, h http.Handler, cookie *http.Cookie) stri return res["preview_id"].(string) } +func previewTwoRowPublishBatch(t *testing.T, h http.Handler, cookie *http.Cookie) string { + t.Helper() + var buf bytes.Buffer + mw := multipart.NewWriter(&buf) + _ = mw.WriteField("default_cookie_id", "acc1") + csvField, _ := mw.CreateFormFile("file", "products.csv") + csvField.Write([]byte("账号ID,标题,价格,库存,图片\nacc1,商品A,12.50,5,img/a.png\nacc1,商品B,13.50,5,img/a.png\n")) + zipField, _ := mw.CreateFormFile("images_zip", "images.zip") + zipField.Write(buildImageZip(t)) + _ = mw.Close() + + req := httptest.NewRequest(http.MethodPost, "/items/publish-batches/preview", &buf) + req.Header.Set("Content-Type", mw.FormDataContentType()) + req.AddCookie(cookie) + rec := httptest.NewRecorder() + h.ServeHTTP(rec, req) + if rec.Code != 200 { + t.Fatalf("preview status=%d body=%s", rec.Code, rec.Body.String()) + } + var res map[string]any + json.Unmarshal(rec.Body.Bytes(), &res) + if res["valid"].(float64) != 2 { + t.Fatalf("预检应 2 行有效,got %+v", res) + } + return res["preview_id"].(string) +} + // TestRunItemPublishBatch_FailureMarksRowFailed 启动批次后,mock mtop 对发布请求返回失败, // 验证 runItemPublishBatch/publishBatchRow 把行标记为 failed。 func TestRunItemPublishBatch_FailureMarksRowFailed(t *testing.T) { @@ -118,8 +164,83 @@ func TestRunItemPublishBatch_FailureMarksRowFailed(t *testing.T) { h.ServeHTTP(rec, req) var got map[string]any json.Unmarshal(rec.Body.Bytes(), &got) - if got["status"] == nil { - t.Fatalf("批次详情异常: %+v", got) + if got["status"] != "failed" { + t.Fatalf("status=%v want failed body=%+v", got["status"], got) + } + if got["failed"] != float64(1) { + t.Fatalf("failed=%v want 1 body=%+v", got["failed"], got) + } + rows, _ := got["rows"].([]any) + if len(rows) != 1 { + t.Fatalf("rows=%+v want 1 row", got["rows"]) + } + row, _ := rows[0].(map[string]any) + if row["status"] != "failed" || row["error_message"] == "" { + t.Fatalf("row should be failed with error message: %+v", row) + } +} + +func TestCancelItemPublishBatchMarksUnfinishedRowsFailed(t *testing.T) { + srv, _, cleanup := newTestServer(t) + defer cleanup() + srv.MTop = withMTopTransport(roundTripFunc(func(req *http.Request) (*http.Response, error) { + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case <-time.After(300 * time.Millisecond): + } + return &http.Response{ + StatusCode: http.StatusOK, + Header: make(http.Header), + Body: io.NopCloser(strings.NewReader(`{"ret":["SUCCESS::调用成功"],"data":{"itemId":"late-item"}}`)), + Request: req, + }, nil + })) + + h := srv.Router() + cookie := loginHelper(t, h) + batchID := previewTwoRowPublishBatch(t, h, cookie) + + startReq := httptest.NewRequest(http.MethodPost, "/items/publish-batches", strings.NewReader(`{"preview_id":"`+batchID+`"}`)) + startReq.AddCookie(cookie) + startRec := httptest.NewRecorder() + h.ServeHTTP(startRec, startReq) + if startRec.Code != http.StatusOK { + t.Fatalf("start status=%d body=%s", startRec.Code, startRec.Body.String()) + } + + cancelReq := httptest.NewRequest(http.MethodPost, "/items/publish-batches/"+batchID+"/cancel", nil) + cancelReq.AddCookie(cookie) + cancelRec := httptest.NewRecorder() + h.ServeHTTP(cancelRec, cancelReq) + if cancelRec.Code != http.StatusOK { + t.Fatalf("cancel status=%d body=%s", cancelRec.Code, cancelRec.Body.String()) + } + + deadline := time.Now().Add(2 * time.Second) + var got map[string]any + for time.Now().Before(deadline) { + req := httptest.NewRequest(http.MethodGet, "/items/publish-batches/"+batchID, nil) + req.AddCookie(cookie) + rec := httptest.NewRecorder() + h.ServeHTTP(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("detail status=%d body=%s", rec.Code, rec.Body.String()) + } + json.Unmarshal(rec.Body.Bytes(), &got) + if got["pending"] == float64(0) && got["running"] == float64(0) { + break + } + time.Sleep(20 * time.Millisecond) + } + if got["status"] != "canceled" { + t.Fatalf("status=%v want canceled body=%+v", got["status"], got) + } + if got["pending"] != float64(0) || got["running"] != float64(0) { + t.Fatalf("取消后不应残留 pending/running: %+v", got) + } + if got["failed"] != got["total"] { + t.Fatalf("取消后未完成行应全部失败: total=%v failed=%v body=%+v", got["total"], got["failed"], got) } } @@ -129,10 +250,17 @@ func TestRunItemPublishBatch_Success(t *testing.T) { defer cleanup() // 所有 mtop 调用返回 SUCCESS;发布调用返回 itemId。 srv.MTop = withMTopTransport(roundTripFunc(func(req *http.Request) (*http.Response, error) { - body := `{"ret":["SUCCESS::调用成功"],"data":{"itemId":"123456","itemUrl":"https://x/item/123456"}}` - // 类目推荐接口需要返回 catId 才能继续后续步骤。 - if strings.Contains(req.URL.RawQuery, "recommend") || strings.Contains(req.URL.RawQuery, "category") { - body = `{"ret":["SUCCESS::调用成功"],"data":{"catId":"100","categoryId":"100"}}` + u := req.URL.String() + body := `{"ret":["SUCCESS::调用成功"],"data":{}}` + switch { + case strings.Contains(u, "stream-upload.goofish.com"): + body = `{"object":{"url":"https://img.alicdn.com/published.png","pix":"800_800"}}` + case strings.Contains(u, "mtop.taobao.idle.local.poi.get"): + body = `{"ret":["SUCCESS::调用成功"],"data":{"commonAddresses":[{"address":"北京"}]}}` + case strings.Contains(u, "mtop.taobao.idle.kgraph.property.recommend"): + body = `{"ret":["SUCCESS::调用成功"],"data":{"categoryPredictResult":{"catId":"100","catName":"数码"}}}` + case strings.Contains(u, "mtop.idle.pc.idleitem.publish"): + body = `{"ret":["SUCCESS::调用成功"],"data":{"itemId":"123456","url":"https://x/item/123456","picUrl":"https://img.alicdn.com/published.png","categoryId":"100","categoryName":"数码","title":"商品A","priceText":"12.50","quantity":"5"}}` } return &http.Response{ StatusCode: http.StatusOK, @@ -177,6 +305,29 @@ func TestRunItemPublishBatch_Success(t *testing.T) { if status == "running" { t.Fatal("批次应在 8s 内完成") } + req := httptest.NewRequest(http.MethodGet, "/items/publish-batches/"+batchID, nil) + req.AddCookie(cookie) + rec := httptest.NewRecorder() + h.ServeHTTP(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("detail status=%d body=%s", rec.Code, rec.Body.String()) + } + var got map[string]any + json.Unmarshal(rec.Body.Bytes(), &got) + if got["status"] != "completed" { + t.Fatalf("status=%v want completed body=%+v", got["status"], got) + } + if got["success"] != float64(1) { + t.Fatalf("success=%v want 1 body=%+v", got["success"], got) + } + rows, _ := got["rows"].([]any) + if len(rows) != 1 { + t.Fatalf("rows=%+v want 1 row", got["rows"]) + } + row, _ := rows[0].(map[string]any) + if row["status"] != "success" || row["item_id"] == "" { + t.Fatalf("row should be success with item_id: %+v", row) + } } // TestCreatePublishAutomationRules 覆盖自动化规则创建(通过成功发布路径间接覆盖)。 diff --git a/internal/server/qrlogin_handlers.go b/internal/server/qrlogin_handlers.go index 05d9f13..83cca7c 100644 --- a/internal/server/qrlogin_handlers.go +++ b/internal/server/qrlogin_handlers.go @@ -1,15 +1,23 @@ package server import ( + "context" + "errors" "net/http" + "strings" "github.com/go-chi/chi/v5" + + "xianyu-go/internal/auth" + "xianyu-go/internal/db" + "xianyu-go/internal/xianyu/protocol" ) // mountQRLoginReal 扫码登录端点(纯 HTTP,不需要浏览器)。 func (s *Server) mountQRLoginReal(r chi.Router) { r.Post("/qr-login/generate", s.generateQRLogin) r.Get("/qr-login/check/{session_id}", s.checkQRLoginStatus) + r.Get("/qr-login/status/{session_id}", s.checkQRLoginStatusAndPersist) r.Post("/qr-login/complete-verification/{session_id}", s.completeQRVerification) } @@ -42,6 +50,40 @@ func (s *Server) checkQRLoginStatus(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusOK, result) } +// checkQRLoginStatusAndPersist 兼容上游 /status 语义:扫码成功后由后端幂等保存账号。 +func (s *Server) checkQRLoginStatusAndPersist(w http.ResponseWriter, r *http.Request) { + sessionID := chi.URLParam(r, "session_id") + if sessionID == "" { + writeErr(w, http.StatusBadRequest, "缺少 session_id") + return + } + result := cloneQRStatus(s.QRLogin.GetSessionStatus(sessionID)) + if qrStatus(result) != "success" { + writeJSON(w, http.StatusOK, result) + return + } + sess := auth.SessionFromContext(r.Context()) + if sess == nil { + writeErr(w, http.StatusUnauthorized, "未授权访问") + return + } + persisted, err := s.persistQRLoginSuccess(r.Context(), sess.UserID, sessionID, result) + if err != nil { + if s.Logger != nil { + s.Logger.Warn("保存扫码登录结果失败", "session_id", sessionID, "err", err) + } + result["success"] = false + result["status"] = "error" + result["message"] = "保存扫码登录结果失败: " + err.Error() + writeJSON(w, http.StatusOK, result) + return + } + result["success"] = true + result["account_id"] = persisted.AccountID + result["is_new_account"] = persisted.IsNew + writeJSON(w, http.StatusOK, result) +} + // completeQRVerification 用户完成风控验证后调用,提取真实 cookie 并入库。 func (s *Server) completeQRVerification(w http.ResponseWriter, r *http.Request) { sessionID := chi.URLParam(r, "session_id") @@ -58,9 +100,90 @@ func (s *Server) completeQRVerification(w http.ResponseWriter, r *http.Request) }) return } - writeJSON(w, http.StatusOK, map[string]any{ + resp := map[string]any{ "success": true, "cookies": cookies, "unb": unb, - }) + } + sess := auth.SessionFromContext(r.Context()) + if sess != nil { + persisted, persistErr := s.persistQRLoginSuccess(r.Context(), sess.UserID, sessionID, map[string]any{ + "status": "success", + "cookies": cookies, + "unb": unb, + }) + if persistErr != nil { + if s.Logger != nil { + s.Logger.Warn("保存扫码验证结果失败", "session_id", sessionID, "err", persistErr) + } + resp["success"] = false + resp["message"] = "保存扫码登录结果失败: " + persistErr.Error() + writeJSON(w, http.StatusOK, resp) + return + } + resp["account_id"] = persisted.AccountID + resp["is_new_account"] = persisted.IsNew + } + writeJSON(w, http.StatusOK, resp) +} + +func (s *Server) persistQRLoginSuccess(ctx context.Context, userID int64, sessionID string, result map[string]any) (qrLoginPersistence, error) { + s.qrMu.Lock() + defer s.qrMu.Unlock() + if s.qrPersisted == nil { + s.qrPersisted = make(map[string]qrLoginPersistence) + } + if persisted, ok := s.qrPersisted[sessionID]; ok { + return persisted, nil + } + cookies := qrString(result, "cookies") + accountID := strings.TrimSpace(firstNonEmpty(qrString(result, "unb"), protocol.TransCookies(cookies)["unb"])) + if cookies == "" || accountID == "" { + return qrLoginPersistence{}, errors.New("扫码结果缺少 cookies 或 unb") + } + + _, err := s.Store.Cookies.GetDetails(ctx, accountID) + isNew := errors.Is(err, db.ErrNotFound) + if err != nil && !errors.Is(err, db.ErrNotFound) { + return qrLoginPersistence{}, err + } + if err := s.Store.Cookies.Save(ctx, accountID, cookies, userID); err != nil { + if errors.Is(err, db.ErrForbidden) { + return qrLoginPersistence{}, errors.New("该账号ID已存在且不属于当前用户") + } + return qrLoginPersistence{}, err + } + s.markSuccessfulLogin(ctx, accountID, userID, loginMethodQRScan, "扫码登录成功") + if s.Store.Tokens != nil { + _ = s.Store.Tokens.Clear(ctx, accountID) + } + if d, err := s.Store.Cookies.GetDetails(ctx, accountID); err == nil { + s.refreshAccountProfile(ctx, d) + } + if s.Manager != nil && s.Store.Cookies.GetStatus(ctx, accountID) { + if err := s.Manager.Restart(ctx, accountID); err != nil && s.Logger != nil { + s.Logger.Warn("扫码登录后重启账号失败", "cookie_id", accountID, "err", err) + } + } + persisted := qrLoginPersistence{AccountID: accountID, IsNew: isNew} + s.qrPersisted[sessionID] = persisted + return persisted, nil +} + +func cloneQRStatus(src map[string]any) map[string]any { + dst := make(map[string]any, len(src)) + for k, v := range src { + dst[k] = v + } + return dst +} + +func qrStatus(result map[string]any) string { + status, _ := result["status"].(string) + return status +} + +func qrString(result map[string]any, key string) string { + value, _ := result[key].(string) + return strings.TrimSpace(value) } diff --git a/internal/server/qrlogin_keyword_test.go b/internal/server/qrlogin_keyword_test.go index 1f82aeb..91fecc6 100644 --- a/internal/server/qrlogin_keyword_test.go +++ b/internal/server/qrlogin_keyword_test.go @@ -3,16 +3,56 @@ package server import ( "context" "encoding/json" + "errors" "net/http" "net/http/httptest" "strings" "testing" + + "xianyu-go/internal/db" ) +type fakeQRLoginService struct { + status map[string]any + generateErr error + completeCookies string + completeUNB string + completeErr error +} + +func (f *fakeQRLoginService) GenerateQRCode(context.Context) (string, string, error) { + if f.generateErr != nil { + return "", "", f.generateErr + } + return "qr-session", "data:image/png;base64,abc", nil +} + +func (f *fakeQRLoginService) GetSessionStatus(sessionID string) map[string]any { + if sessionID == "no-such-session" { + return map[string]any{"status": "not_found"} + } + out := make(map[string]any, len(f.status)+1) + for k, v := range f.status { + out[k] = v + } + if _, ok := out["session_id"]; !ok { + out["session_id"] = sessionID + } + return out +} + +func (f *fakeQRLoginService) CompleteVerification(context.Context, string) (string, string, error) { + if f.completeErr != nil { + return "", "", f.completeErr + } + return f.completeCookies, f.completeUNB, nil +} + // TestGenerateQRLogin 生成扫码登录二维码。 func TestGenerateQRLogin(t *testing.T) { srv, _, cleanup := newTestServer(t) defer cleanup() + srv.QRLogin = &fakeQRLoginService{} h := srv.Router() cookie := loginHelper(t, h) @@ -34,6 +74,7 @@ func TestGenerateQRLogin(t *testing.T) { func TestCheckQRLoginStatusEmptySession(t *testing.T) { srv, _, cleanup := newTestServer(t) defer cleanup() + srv.QRLogin = &fakeQRLoginService{} h := srv.Router() cookie := loginHelper(t, h) @@ -52,6 +93,7 @@ func TestCheckQRLoginStatusEmptySession(t *testing.T) { func TestCompleteQRVerificationBadSession(t *testing.T) { srv, _, cleanup := newTestServer(t) defer cleanup() + srv.QRLogin = &fakeQRLoginService{completeErr: errors.New("会话不存在")} h := srv.Router() cookie := loginHelper(t, h) @@ -69,6 +111,88 @@ func TestCompleteQRVerificationBadSession(t *testing.T) { } } +func TestQRLoginStatusPersistsSuccessIdempotently(t *testing.T) { + srv, store, cleanup := newTestServer(t) + defer cleanup() + srv.Manager = nil + srv.QRLogin = &fakeQRLoginService{status: map[string]any{ + "status": "success", + "cookies": "unb=qr-new; _m_h5_tk=qr-token;", + "unb": "qr-new", + }} + h := srv.Router() + cookie := loginHelper(t, h) + + for i := 0; i < 2; i++ { + req := httptest.NewRequest(http.MethodGet, "/qr-login/status/s1", nil) + req.AddCookie(cookie) + rec := httptest.NewRecorder() + h.ServeHTTP(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String()) + } + var res map[string]any + if err := json.Unmarshal(rec.Body.Bytes(), &res); err != nil { + t.Fatalf("decode response: %v", err) + } + if res["success"] != true || res["account_id"] != "qr-new" { + t.Fatalf("扫码状态保存响应异常: %+v", res) + } + } + + d, err := store.Cookies.GetDetails(context.Background(), "qr-new") + if err != nil { + t.Fatalf("GetDetails qr-new: %v", err) + } + if d.LoginMethod != "qr_scan" || d.LastLoginAt == 0 { + t.Fatalf("扫码登录应标记登录审计字段: %+v", d) + } + logs, err := store.LoginLogs.ListByCookie(context.Background(), "qr-new", 10) + if err != nil || len(logs) != 1 || logs[0].Status != "success" || logs[0].Method != "qr_scan" { + t.Fatalf("重复轮询不应重复记录登录日志: logs=%#v err=%v", logs, err) + } +} + +func TestCompleteQRVerificationPersistsAndReenablesAccount(t *testing.T) { + srv, store, cleanup := newTestServer(t) + defer cleanup() + ctx := context.Background() + srv.Manager = nil + srv.QRLogin = &fakeQRLoginService{ + completeCookies: "unb=acc1; _m_h5_tk=qr-fresh;", + completeUNB: "acc1", + } + if err := store.Cookies.SetStatusWithReason(ctx, "acc1", false, "token 失效"); err != nil { + t.Fatalf("SetStatusWithReason: %v", err) + } + if err := store.Tokens.Save(ctx, "acc1", "did", "token", 9999999999); err != nil { + t.Fatalf("Save token: %v", err) + } + h := srv.Router() + cookie := loginHelper(t, h) + + req := httptest.NewRequest(http.MethodPost, "/qr-login/complete-verification/s1", nil) + req.AddCookie(cookie) + rec := httptest.NewRecorder() + h.ServeHTTP(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String()) + } + var res map[string]any + if err := json.Unmarshal(rec.Body.Bytes(), &res); err != nil { + t.Fatalf("decode response: %v", err) + } + if res["success"] != true || res["account_id"] != "acc1" { + t.Fatalf("完成验证响应异常: %+v", res) + } + if !store.Cookies.GetStatus(ctx, "acc1") { + t.Fatal("扫码验证成功后应重新启用账号") + } + if _, err := store.Tokens.Get(ctx, "acc1"); !errors.Is(err, db.ErrNotFound) { + t.Fatalf("扫码验证成功后应清 token,got %v", err) + } +} + // TestKeywordsListAndDelete 关键字列表与删除(覆盖 listKeywords / listKeywordsWithItemID / listKeywordsWithType)。 func TestKeywordsListAndDelete(t *testing.T) { srv, _, cleanup := newTestServer(t) @@ -137,6 +261,51 @@ func TestAddKeywordBadJSON(t *testing.T) { } } +func TestReplaceKeywordsWithItemID(t *testing.T) { + srv, _, cleanup := newTestServer(t) + defer cleanup() + h := srv.Router() + cookie := loginHelper(t, h) + + postBatch := func(body string) []map[string]any { + req := httptest.NewRequest(http.MethodPost, "/keywords-with-item-id/acc1", strings.NewReader(body)) + req.AddCookie(cookie) + rec := httptest.NewRecorder() + h.ServeHTTP(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("replace status=%d body=%s", rec.Code, rec.Body.String()) + } + + listReq := httptest.NewRequest(http.MethodGet, "/keywords-with-item-id/acc1", nil) + listReq.AddCookie(cookie) + listRec := httptest.NewRecorder() + h.ServeHTTP(listRec, listReq) + if listRec.Code != http.StatusOK { + t.Fatalf("list status=%d body=%s", listRec.Code, listRec.Body.String()) + } + var rows []map[string]any + if err := json.Unmarshal(listRec.Body.Bytes(), &rows); err != nil { + t.Fatal(err) + } + return rows + } + + rows := postBatch(`{"keywords":[{"keyword":"在吗","reply":"在的","item_id":""},{"keyword":"价格","reply":"50","item_id":"it1"}]}`) + if len(rows) != 2 || rows[1]["item_id"] != "it1" { + t.Fatalf("批量新增异常: %+v", rows) + } + + rows = postBatch(`{"keywords":[{"keyword":"在吗","reply":"稍等","item_id":""}]}`) + if len(rows) != 1 || rows[0]["reply"] != "稍等" { + t.Fatalf("批量覆盖编辑异常: %+v", rows) + } + + rows = postBatch(`{"keywords":[]}`) + if len(rows) != 0 { + t.Fatalf("空数组应清空关键词: %+v", rows) + } +} + // TestDeleteKeywordNotFound 不存在关键字 404。 func TestDeleteKeywordNotFound(t *testing.T) { srv, _, cleanup := newTestServer(t) diff --git a/internal/server/server.go b/internal/server/server.go index 675a128..4574f5b 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -12,6 +12,7 @@ import ( "os" "path/filepath" "strings" + "sync" "time" "github.com/go-chi/chi/v5" @@ -28,20 +29,42 @@ import ( "xianyu-go/internal/xianyu/qrlogin" ) +type qrLoginService interface { + GenerateQRCode(ctx context.Context) (sessionID string, qrCodeURL string, err error) + GetSessionStatus(sessionID string) map[string]any + CompleteVerification(ctx context.Context, sessionID string) (cookies string, unb string, err error) +} + +type qrLoginPersistence struct { + AccountID string + IsNew bool +} + // Server 聚合 HTTP 服务依赖。Automation 与 Notifier 由构造函数注入, // 不再允许外部直接改字段,避免运行时被替换成 nil。 type Server struct { - Store *db.Store - Auth *auth.Service - Manager *account.Manager - automation *automation.Center - Browser *browser.Manager - notifier *notify.Notifier - MTop mtop.Client - QRLogin *qrlogin.Manager - Logger *slog.Logger - WebDir string // 前端静态资源目录(含 index.html) - Addr string + Store *db.Store + Auth *auth.Service + Manager *account.Manager + automation *automation.Center + Browser *browser.Manager + PasswordLogin passwordLoginRunner + notifier *notify.Notifier + MTop mtop.Client + QRLogin qrLoginService + Logger *slog.Logger + WebDir string // 前端静态资源目录(含 index.html) + Addr string + + publishMu sync.Mutex + publishCancels map[string]context.CancelFunc + + passwordMu sync.Mutex + passwordSessions map[string]*passwordLoginSession + passwordProcessing map[string]string + + qrMu sync.Mutex + qrPersisted map[string]qrLoginPersistence } // New 构造。autoCenter/notifier 由调用方完成创建后注入(创建顺序: @@ -57,20 +80,33 @@ func New(store *db.Store, manager *account.Manager, bm *browser.Manager, secure }) } return &Server{ - Store: store, - Auth: &auth.Service{Store: store, Logger: logger, Secure: secure}, - Manager: manager, - automation: autoCenter, - Browser: bm, - notifier: notifier, - MTop: mtop.NewClient(), - QRLogin: qrMgr, - Logger: logger, - WebDir: webDir, - Addr: addr, + Store: store, + Auth: &auth.Service{Store: store, Logger: logger, Secure: secure}, + Manager: manager, + automation: autoCenter, + Browser: bm, + PasswordLogin: passwordLoginRunnerForBrowser(bm), + notifier: notifier, + MTop: mtop.NewClient(), + QRLogin: qrMgr, + Logger: logger, + WebDir: webDir, + Addr: addr, + + publishCancels: make(map[string]context.CancelFunc), + passwordSessions: make(map[string]*passwordLoginSession), + passwordProcessing: make(map[string]string), + qrPersisted: make(map[string]qrLoginPersistence), } } +func passwordLoginRunnerForBrowser(bm *browser.Manager) passwordLoginRunner { + if bm == nil { + return nil + } + return bm +} + // mtopClient 返回注入的 mtop 客户端;未注入时退回默认 HTTP 实现(保证零值可用)。 func (s *Server) mtopClient() mtop.Client { if s.MTop != nil { @@ -110,6 +146,8 @@ func (s *Server) Router() http.Handler { s.mountCookies(r) // 扫码登录 s.mountQRLoginReal(r) + // 密码登录 + s.mountPasswordLogin(r) // 订单 s.mountOrdersReal(r) // 订单分析(仪表盘) @@ -275,7 +313,7 @@ func isAPIPath(path string) bool { "/system-settings", "/ai-reply", "/ai-models", "/user-settings", "/item-reply", "/itemReplays", - "/qr-login", + "/qr-login", "/password-login", "/static/", // 静态资源(由 /static/* handler 处理,不进 catch-all) } for _, p := range apiPrefixes { diff --git a/internal/server/settings_handlers.go b/internal/server/settings_handlers.go index 2cde985..92f0032 100644 --- a/internal/server/settings_handlers.go +++ b/internal/server/settings_handlers.go @@ -331,8 +331,9 @@ func (s *Server) mountUserReal(r chi.Router) { func (s *Server) listUserSettings(w http.ResponseWriter, r *http.Request) { sess := authSess(r) + keyCol := db.DialectQuote(s.Store.Dialect, "key") rows, err := s.Store.DB.QueryContext(r.Context(), - `SELECT key, value FROM user_settings WHERE user_id=?`, sess.UserID) + `SELECT `+keyCol+`, value FROM user_settings WHERE user_id=?`, sess.UserID) if err != nil { writeErr(w, http.StatusInternalServerError, "查询失败") return @@ -356,8 +357,9 @@ func (s *Server) getUserSetting(w http.ResponseWriter, r *http.Request) { sess := authSess(r) key := chi.URLParam(r, "key") var v string + keyCol := db.DialectQuote(s.Store.Dialect, "key") err := s.Store.DB.QueryRowContext(r.Context(), - `SELECT value FROM user_settings WHERE user_id=? AND key=?`, sess.UserID, key).Scan(&v) + `SELECT value FROM user_settings WHERE user_id=? AND `+keyCol+`=?`, sess.UserID, key).Scan(&v) if err != nil { writeJSON(w, http.StatusOK, map[string]any{"value": ""}) return diff --git a/internal/webui/static/assets/charts-vendor-B_BfwiL0.js b/internal/webui/static/assets/charts-vendor-B_BfwiL0.js new file mode 100644 index 0000000..2f7dc3f --- /dev/null +++ b/internal/webui/static/assets/charts-vendor-B_BfwiL0.js @@ -0,0 +1,59 @@ +import{r as d,b as fo,R as Sp}from"./react-vendor-DZnRGM0-.js";import{c as Z,g as Qt,u as cu,w as Ip,a as P,s as Ca,b as Te,t as Ep,p as re,d as Qe,e as q,f as kp,D as G,I as su,r as Xf,E as jp,h as Cp,i as Tp,j as ir,k as dn,l as $p,m as Mp,n as Dp,P as _p}from"./vendor-w5t2K9ux.js";var Np=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"];function vo(e){if(typeof e!="string")return!1;var t=Np;return t.includes(e)}var Lp=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-errormessage","aria-expanded","aria-flowto","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","className","color","height","id","lang","max","media","method","min","name","style","target","width","role","tabIndex","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","href","ideographic","imageRendering","in2","in","intercept","k1","k2","k3","k4","k","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x1","x2","x","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlns","xmlnsXlink","xmlSpace","y1","y2","y","yChannelSelector","z","zoomAndPan","ref","key","angle"],Rp=new Set(Lp);function Zf(e){return typeof e!="string"?!1:Rp.has(e)}function Qf(e){return typeof e=="string"&&e.startsWith("data-")}function Le(e){if(typeof e!="object"||e===null)return{};var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(Zf(r)||Qf(r))&&(t[r]=e[r]);return t}function Jt(e){if(e==null)return null;if(d.isValidElement(e)&&typeof e.props=="object"&&e.props!==null){var t=e.props;return Le(t)}return typeof e=="object"&&!Array.isArray(e)?Le(e):null}function Ke(e){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(Zf(r)||Qf(r)||vo(r))&&(t[r]=e[r]);return t}function Bp(e){return e==null?null:d.isValidElement(e)?Ke(e.props):typeof e=="object"&&!Array.isArray(e)?Ke(e):null}var zp=["children","width","height","viewBox","className","style","title","desc"];function $i(){return $i=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var r=e.children,n=e.width,a=e.height,i=e.viewBox,o=e.className,l=e.style,u=e.title,c=e.desc,s=Kp(e,zp),f=i||{width:n,height:a,x:0,y:0},v=Z("recharts-surface",o);return d.createElement("svg",$i({},Ke(s),{className:v,width:n,height:a,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:t}),d.createElement("title",null,u),d.createElement("desc",null,c),r)}),Fp=["children","className"];function Mi(){return Mi=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var r=e.children,n=e.className,a=Up(e,Fp),i=Z("recharts-layer",n);return d.createElement("g",Mi({className:i},Ke(a),{ref:t}),r)}),Jf=d.createContext(null),Vp=()=>d.useContext(Jf);function te(e){return function(){return e}}const ed=Math.cos,Vn=Math.sin,et=Math.sqrt,Gn=Math.PI,Ta=2*Gn,Di=Math.PI,_i=2*Di,Vt=1e-6,Gp=_i-Vt;function td(e){this._+=e[0];for(let t=1,r=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return td;const r=10**t;return function(n){this._+=n[0];for(let a=1,i=n.length;aVt)if(!(Math.abs(f*u-c*s)>Vt)||!i)this._append`L${this._x1=t},${this._y1=r}`;else{let h=n-o,m=a-l,p=u*u+c*c,y=h*h+m*m,g=Math.sqrt(p),x=Math.sqrt(v),A=i*Math.tan((Di-Math.acos((p+v-y)/(2*g*x)))/2),w=A/x,O=A/g;Math.abs(w-1)>Vt&&this._append`L${t+w*s},${r+w*f}`,this._append`A${i},${i},0,0,${+(f*h>s*m)},${this._x1=t+O*u},${this._y1=r+O*c}`}}arc(t,r,n,a,i,o){if(t=+t,r=+r,n=+n,o=!!o,n<0)throw new Error(`negative radius: ${n}`);let l=n*Math.cos(a),u=n*Math.sin(a),c=t+l,s=r+u,f=1^o,v=o?a-i:i-a;this._x1===null?this._append`M${c},${s}`:(Math.abs(this._x1-c)>Vt||Math.abs(this._y1-s)>Vt)&&this._append`L${c},${s}`,n&&(v<0&&(v=v%_i+_i),v>Gp?this._append`A${n},${n},0,1,${f},${t-l},${r-u}A${n},${n},0,1,${f},${this._x1=c},${this._y1=s}`:v>Vt&&this._append`A${n},${n},0,${+(v>=Di)},${f},${this._x1=t+n*Math.cos(i)},${this._y1=r+n*Math.sin(i)}`)}rect(t,r,n,a){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+r}h${n=+n}v${+a}h${-n}Z`}toString(){return this._}}function mo(e){let t=3;return e.digits=function(r){if(!arguments.length)return t;if(r==null)t=null;else{const n=Math.floor(r);if(!(n>=0))throw new RangeError(`invalid digits: ${r}`);t=n}return e},()=>new qp(t)}function po(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function rd(e){this._context=e}rd.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function $a(e){return new rd(e)}function nd(e){return e[0]}function ad(e){return e[1]}function id(e,t){var r=te(!0),n=null,a=$a,i=null,o=mo(l);e=typeof e=="function"?e:e===void 0?nd:te(e),t=typeof t=="function"?t:t===void 0?ad:te(t);function l(u){var c,s=(u=po(u)).length,f,v=!1,h;for(n==null&&(i=a(h=o())),c=0;c<=s;++c)!(c=h;--m)l.point(A[m],w[m]);l.lineEnd(),l.areaEnd()}g&&(A[v]=+e(y,v,f),w[v]=+t(y,v,f),l.point(n?+n(y,v,f):A[v],r?+r(y,v,f):w[v]))}if(x)return l=null,x+""||null}function s(){return id().defined(a).curve(o).context(i)}return c.x=function(f){return arguments.length?(e=typeof f=="function"?f:te(+f),n=null,c):e},c.x0=function(f){return arguments.length?(e=typeof f=="function"?f:te(+f),c):e},c.x1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:te(+f),c):n},c.y=function(f){return arguments.length?(t=typeof f=="function"?f:te(+f),r=null,c):t},c.y0=function(f){return arguments.length?(t=typeof f=="function"?f:te(+f),c):t},c.y1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:te(+f),c):r},c.lineX0=c.lineY0=function(){return s().x(e).y(t)},c.lineY1=function(){return s().x(e).y(r)},c.lineX1=function(){return s().x(n).y(t)},c.defined=function(f){return arguments.length?(a=typeof f=="function"?f:te(!!f),c):a},c.curve=function(f){return arguments.length?(o=f,i!=null&&(l=o(i)),c):o},c.context=function(f){return arguments.length?(f==null?i=l=null:l=o(i=f),c):i},c}class od{constructor(t,r){this._context=t,this._x=r}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,r){switch(t=+t,r=+r,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,r):this._context.moveTo(t,r);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,r,t,r):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+r)/2,t,this._y0,t,r);break}}this._x0=t,this._y0=r}}function Xp(e){return new od(e,!0)}function Zp(e){return new od(e,!1)}const yo={draw(e,t){const r=et(t/Gn);e.moveTo(r,0),e.arc(0,0,r,0,Ta)}},Qp={draw(e,t){const r=et(t/5)/2;e.moveTo(-3*r,-r),e.lineTo(-r,-r),e.lineTo(-r,-3*r),e.lineTo(r,-3*r),e.lineTo(r,-r),e.lineTo(3*r,-r),e.lineTo(3*r,r),e.lineTo(r,r),e.lineTo(r,3*r),e.lineTo(-r,3*r),e.lineTo(-r,r),e.lineTo(-3*r,r),e.closePath()}},ld=et(1/3),Jp=ld*2,ey={draw(e,t){const r=et(t/Jp),n=r*ld;e.moveTo(0,-r),e.lineTo(n,0),e.lineTo(0,r),e.lineTo(-n,0),e.closePath()}},ty={draw(e,t){const r=et(t),n=-r/2;e.rect(n,n,r,r)}},ry=.8908130915292852,ud=Vn(Gn/10)/Vn(7*Gn/10),ny=Vn(Ta/10)*ud,ay=-ed(Ta/10)*ud,iy={draw(e,t){const r=et(t*ry),n=ny*r,a=ay*r;e.moveTo(0,-r),e.lineTo(n,a);for(let i=1;i<5;++i){const o=Ta*i/5,l=ed(o),u=Vn(o);e.lineTo(u*r,-l*r),e.lineTo(l*n-u*a,u*n+l*a)}e.closePath()}},vi=et(3),oy={draw(e,t){const r=-et(t/(vi*3));e.moveTo(0,r*2),e.lineTo(-vi*r,-r),e.lineTo(vi*r,-r),e.closePath()}},We=-.5,Fe=et(3)/2,Ni=1/et(12),ly=(Ni/2+1)*3,uy={draw(e,t){const r=et(t/ly),n=r/2,a=r*Ni,i=n,o=r*Ni+r,l=-i,u=o;e.moveTo(n,a),e.lineTo(i,o),e.lineTo(l,u),e.lineTo(We*n-Fe*a,Fe*n+We*a),e.lineTo(We*i-Fe*o,Fe*i+We*o),e.lineTo(We*l-Fe*u,Fe*l+We*u),e.lineTo(We*n+Fe*a,We*a-Fe*n),e.lineTo(We*i+Fe*o,We*o-Fe*i),e.lineTo(We*l+Fe*u,We*u-Fe*l),e.closePath()}};function cy(e,t){let r=null,n=mo(a);e=typeof e=="function"?e:te(e||yo),t=typeof t=="function"?t:te(t===void 0?64:+t);function a(){let i;if(r||(r=i=n()),e.apply(this,arguments).draw(r,+t.apply(this,arguments)),i)return r=null,i+""||null}return a.type=function(i){return arguments.length?(e=typeof i=="function"?i:te(i),a):e},a.size=function(i){return arguments.length?(t=typeof i=="function"?i:te(+i),a):t},a.context=function(i){return arguments.length?(r=i??null,a):r},a}function Yn(){}function qn(e,t,r){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+r)/6)}function cd(e){this._context=e}cd.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:qn(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:qn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function sy(e){return new cd(e)}function sd(e){this._context=e}sd.prototype={areaStart:Yn,areaEnd:Yn,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:qn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function fy(e){return new sd(e)}function fd(e){this._context=e}fd.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var r=(this._x0+4*this._x1+e)/6,n=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(r,n):this._context.moveTo(r,n);break;case 3:this._point=4;default:qn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function dy(e){return new fd(e)}function dd(e){this._context=e}dd.prototype={areaStart:Yn,areaEnd:Yn,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function vy(e){return new dd(e)}function fu(e){return e<0?-1:1}function du(e,t,r){var n=e._x1-e._x0,a=t-e._x1,i=(e._y1-e._y0)/(n||a<0&&-0),o=(r-e._y1)/(a||n<0&&-0),l=(i*a+o*n)/(n+a);return(fu(i)+fu(o))*Math.min(Math.abs(i),Math.abs(o),.5*Math.abs(l))||0}function vu(e,t){var r=e._x1-e._x0;return r?(3*(e._y1-e._y0)/r-t)/2:t}function hi(e,t,r){var n=e._x0,a=e._y0,i=e._x1,o=e._y1,l=(i-n)/3;e._context.bezierCurveTo(n+l,a+l*t,i-l,o-l*r,i,o)}function Xn(e){this._context=e}Xn.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:hi(this,this._t0,vu(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var r=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,hi(this,vu(this,r=du(this,e,t)),r);break;default:hi(this,this._t0,r=du(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=r}}};function vd(e){this._context=new hd(e)}(vd.prototype=Object.create(Xn.prototype)).point=function(e,t){Xn.prototype.point.call(this,t,e)};function hd(e){this._context=e}hd.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,r,n,a,i){this._context.bezierCurveTo(t,e,n,r,i,a)}};function hy(e){return new Xn(e)}function my(e){return new vd(e)}function md(e){this._context=e}md.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,r=e.length;if(r)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),r===2)this._context.lineTo(e[1],t[1]);else for(var n=hu(e),a=hu(t),i=0,o=1;o=0;--t)a[t]=(o[t]-a[t+1])/i[t];for(i[r-1]=(e[r]+a[r-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var r=this._x*(1-this._t)+e*this._t;this._context.lineTo(r,this._y),this._context.lineTo(r,t)}break}}this._x=e,this._y=t}};function yy(e){return new Ma(e,.5)}function gy(e){return new Ma(e,0)}function by(e){return new Ma(e,1)}function er(e,t){if((o=e.length)>1)for(var r=1,n,a,i=e[t[0]],o,l=i.length;r=0;)r[t]=t;return r}function xy(e,t){return e[t]}function wy(e){const t=[];return t.key=e,t}function Ay(){var e=te([]),t=Li,r=er,n=xy;function a(i){var o=Array.from(e.apply(this,arguments),wy),l,u=o.length,c=-1,s;for(const f of i)for(l=0,++c;l0){for(var r,n,a=0,i=e[0].length,o;a0){for(var r=0,n=e[t[0]],a,i=n.length;r0)||!((i=(a=e[t[0]]).length)>0))){for(var r=0,n=1,a,i,o;n1&&arguments[1]!==void 0?arguments[1]:Iy,r=10**t,n=Math.round(e*r)/r;return Object.is(n,-0)?0:n}function Se(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{var l=r[o-1];return typeof l=="string"?a+l+i:l!==void 0?a+Tt(l)+i:a+i},"")}var we=e=>e===0?0:e>0?1:-1,Je=e=>typeof e=="number"&&e!=+e,tr=e=>typeof e=="string"&&e.length>1&&e.indexOf("%")===e.length-1,$=e=>(typeof e=="number"||e instanceof Number)&&!Je(e),ut=e=>$(e)||typeof e=="string",Ey=0,nn=e=>{var t=++Ey;return"".concat(e||"").concat(t)},Ce=function(t,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!$(t)&&typeof t!="string")return n;var i;if(tr(t)){if(r==null)return n;var o=t.indexOf("%");i=r*parseFloat(t.slice(0,o))/100}else i=+t;return Je(i)&&(i=n),a&&r!=null&&i>r&&(i=r),i},pd=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,r={},n=0;nn&&(typeof t=="function"?t(n):Qt(n,t))===r)}var ie=e=>e===null||typeof e>"u",vn=e=>ie(e)?e:"".concat(e.charAt(0).toUpperCase()).concat(e.slice(1));function _e(e){return e!=null}function or(){}var ky=["type","size","sizeType"];function Ri(){return Ri=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t="symbol".concat(vn(e));return gd[t]||yo},Ny=(e,t,r)=>{if(t==="area")return e;switch(r){case"cross":return 5*e*e/9;case"diamond":return .5*e*e/Math.sqrt(3);case"square":return e*e;case"star":{var n=18*Dy;return 1.25*e*e*(Math.tan(n)-Math.tan(n*2)*Math.tan(n)**2)}case"triangle":return Math.sqrt(3)*e*e/4;case"wye":return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},Ly=(e,t)=>{gd["symbol".concat(vn(e))]=t},bd=e=>{var t=e.type,r=t===void 0?"circle":t,n=e.size,a=n===void 0?64:n,i=e.sizeType,o=i===void 0?"area":i,l=$y(e,ky),u=pu(pu({},l),{},{type:r,size:a,sizeType:o}),c="circle";typeof r=="string"&&(c=r);var s=()=>{var p=_y(c),y=cy().type(p).size(Ny(a,o,c)),g=y();if(g!==null)return g},f=u.className,v=u.cx,h=u.cy,m=Ke(u);return $(v)&&$(h)&&$(a)?d.createElement("path",Ri({},m,{className:Z("recharts-symbols",f),transform:"translate(".concat(v,", ").concat(h,")"),d:s()})):null};bd.registerSymbol=Ly;var xd=e=>"radius"in e&&"startAngle"in e&&"endAngle"in e,go=(e,t)=>{if(!e||typeof e=="function"||typeof e=="boolean")return null;var r=e;if(d.isValidElement(e)&&(r=e.props),typeof r!="object"&&typeof r!="function")return null;var n={};return Object.keys(r).forEach(a=>{vo(a)&&typeof r[a]=="function"&&(n[a]=(i=>r[a](r,i)))}),n},Ry=(e,t,r)=>n=>(e(t,r,n),null),hn=(e,t,r)=>{if(e===null||typeof e!="object"&&typeof e!="function")return null;var n=null;return Object.keys(e).forEach(a=>{var i=e[a];vo(a)&&typeof i=="function"&&(n||(n={}),n[a]=Ry(i,t,r))}),n};function yu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function By(e){for(var t=1;t(o[l]===void 0&&n[l]!==void 0&&(o[l]=n[l]),o),r);return i}function Zn(){return Zn=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var h=f.formatter||a,m=Z({"recharts-legend-item":!0,["legend-item-".concat(v)]:!0,inactive:f.inactive});if(f.type==="none")return null;var p=typeof l=="object"?wd({},l):{};p.color=f.inactive?i:p.color||f.color;var y=h?h(f.value,f,v):f.value;return d.createElement("li",Zn({className:m,style:c,key:"legend-item-".concat(v)},hn(e,f,v)),d.createElement(ho,{width:r,height:r,viewBox:u,style:s,"aria-label":"".concat(f.value," legend icon")},d.createElement(Yy,{data:f,iconType:o,inactiveColor:i})),d.createElement("span",{className:"recharts-legend-item-text",style:p},y))})}var Xy=e=>{var t=Ae(e,Vy),r=t.payload,n=t.layout,a=t.align;if(!r||!r.length)return null;var i={padding:0,margin:0,textAlign:n==="horizontal"?a:"left"};return d.createElement("ul",{className:"recharts-default-legend",style:i},d.createElement(qy,Zn({},t,{payload:r})))};function Ad(e,t,r){return t===!0?cu(e,r):typeof t=="function"?cu(e,t):e}var bo=d.createContext(null),Zy=e=>e,ee=()=>{var e=d.useContext(bo);return e?e.store.dispatch:Zy},Fn=()=>{},Qy=()=>Fn,Jy=(e,t)=>e===t;function M(e){var t=d.useContext(bo),r=d.useMemo(()=>t?n=>{if(n!=null)return e(n)}:Fn,[t,e]);return Ip.useSyncExternalStoreWithSelector(t?t.subscription.addNestedSub:Qy,t?t.store.getState:Fn,t?t.store.getState:Fn,r,Jy)}var Pd=e=>e.legend.settings,eg=e=>e.legend.size,tg=e=>e.legend.payload,rg=P([tg,Pd],(e,t)=>{var r=t.itemSorter,n=e.flat(1);return r?Ca(n,r):n});function ng(){return M(rg)}function ag(e,t){return ug(e)||lg(e,t)||og(e,t)||ig()}function ig(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function og(e,t){if(e){if(typeof e=="string")return bu(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?bu(e,t):void 0}}function bu(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r$n||Math.abs(e.left-t.left)>$n||Math.abs(e.top-t.top)>$n||Math.abs(e.width-t.width)>$n}function wu(e){var t=e.getBoundingClientRect();return{height:t.height,left:t.left,top:t.top,width:t.width}}function Od(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=d.useState({height:0,left:0,top:0,width:0}),r=ag(t,2),n=r[0],a=r[1],i=d.useRef(null),o=d.useRef(n);o.current=n;var l=d.useCallback(u=>{if(i.current!=null&&(i.current.disconnect(),i.current=null),u!=null){var c=wu(u);if(xu(c,o.current)&&a(c),typeof ResizeObserver<"u"){var s=new ResizeObserver(()=>{var f=wu(u);xu(f,o.current)&&a(f)});s.observe(u),i.current=s}}},[...e]);return d.useEffect(()=>()=>{var u;(u=i.current)===null||u===void 0||u.disconnect()},[]),[n,l]}var cg={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},Sd=Te({name:"chartLayout",initialState:cg,reducers:{setLayout(e,t){e.layoutType=t.payload},setChartSize(e,t){e.width=t.payload.width,e.height=t.payload.height},setMargin(e,t){var r,n,a,i;e.margin.top=(r=t.payload.top)!==null&&r!==void 0?r:0,e.margin.right=(n=t.payload.right)!==null&&n!==void 0?n:0,e.margin.bottom=(a=t.payload.bottom)!==null&&a!==void 0?a:0,e.margin.left=(i=t.payload.left)!==null&&i!==void 0?i:0},setScale(e,t){e.scale=t.payload}}}),Da=Sd.actions,sg=Da.setMargin,fg=Da.setLayout,dg=Da.setChartSize,vg=Da.setScale,hg=Sd.reducer;function Id(e,t,r){return Array.isArray(e)&&e&&t+r!==0?e.slice(t,r+1):e}function H(e){return Number.isFinite(e)}function ct(e){return typeof e=="number"&&e>0&&Number.isFinite(e)}function Au(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function gr(e){for(var t=1;t{if(t&&r){var n=r.width,a=r.height,i=t.align,o=t.verticalAlign,l=t.layout;if((l==="vertical"||l==="horizontal"&&o==="middle")&&i!=="center"&&$(e[i]))return gr(gr({},e),{},{[i]:e[i]+(n||0)});if((l==="horizontal"||l==="vertical"&&i==="center")&&o!=="middle"&&$(e[o]))return gr(gr({},e),{},{[o]:e[o]+(a||0)})}return e},ft=(e,t)=>e==="horizontal"&&t==="xAxis"||e==="vertical"&&t==="yAxis"||e==="centric"&&t==="angleAxis"||e==="radial"&&t==="radiusAxis",Ed=(e,t,r,n)=>{if(n)return e.map(l=>l.coordinate);var a,i,o=e.map(l=>(l.coordinate===t&&(a=!0),l.coordinate===r&&(i=!0),l.coordinate));return a||o.push(t),i||o.push(r),o},kd=(e,t,r)=>{if(!e)return null;var n=e.duplicateDomain,a=e.type,i=e.range,o=e.scale,l=e.realScaleType,u=e.isCategorical,c=e.categoricalDomain,s=e.tickCount,f=e.ticks,v=e.niceTicks,h=e.axisType;if(!o)return null;var m=l==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,p=a==="category"&&o.bandwidth?o.bandwidth()/m:0;if(p=h==="angleAxis"&&i&&i.length>=2?we(i[0]-i[1])*2*p:p,f||v){var y=(f||v||[]).map((g,x)=>{var A=n?n.indexOf(g):g,w=o.map(A);return H(w)?{coordinate:w+p,value:g,offset:p,index:x}:null}).filter(_e);return y}return u&&c?c.map((g,x)=>{var A=o.map(g);return H(A)?{coordinate:A+p,value:g,index:x,offset:p}:null}).filter(_e):o.ticks&&s!=null?o.ticks(s).map((g,x)=>{var A=o.map(g);return H(A)?{coordinate:A+p,value:g,index:x,offset:p}:null}).filter(_e):o.domain().map((g,x)=>{var A=o.map(g);return H(A)?{coordinate:A+p,value:n?n[g]:g,index:x,offset:p}:null}).filter(_e)},bg=(e,t)=>{if(!t||t.length!==2||!$(t[0])||!$(t[1]))return e;var r=Math.min(t[0],t[1]),n=Math.max(t[0],t[1]),a=[e[0],e[1]];return(!$(e[0])||e[0]n)&&(a[1]=n),a[0]>n&&(a[0]=n),a[1]{var t,r=e.length;if(!(r<=0)){var n=(t=e[0])===null||t===void 0?void 0:t.length;if(!(n==null||n<=0))for(var a=0;a=0?(c[0]=i,i+=v,c[1]=i):(c[0]=o,o+=v,c[1]=o)}}}},wg=e=>{var t,r=e.length;if(!(r<=0)){var n=(t=e[0])===null||t===void 0?void 0:t.length;if(!(n==null||n<=0))for(var a=0;a=0?(u[0]=i,i+=c,u[1]=i):(u[0]=0,u[1]=0)}}}},Ag={sign:xg,expand:Py,none:er,silhouette:Oy,wiggle:Sy,positive:wg},Pg=(e,t,r)=>{var n,a=(n=Ag[r])!==null&&n!==void 0?n:er,i=Ay().keys(t).value((l,u)=>Number(Q(l,u,0))).order(Li).offset(a),o=i(e);return o.forEach((l,u)=>{l.forEach((c,s)=>{var f=Q(e[s],t[u],0);Array.isArray(f)&&f.length===2&&$(f[0])&&$(f[1])&&(c[0]=f[0],c[1]=f[1])})}),o};function jd(e){return e==null?void 0:String(e)}function Pu(e){var t=e.axis,r=e.ticks,n=e.bandSize,a=e.entry,i=e.index,o=e.dataKey;if(t.type==="category"){if(!t.allowDuplicatedCategory&&t.dataKey&&!ie(a[t.dataKey])){var l=yd(r,"value",a[t.dataKey]);if(l)return l.coordinate+n/2}return r!=null&&r[i]?r[i].coordinate+n/2:null}var u=Q(a,ie(o)?t.dataKey:o),c=t.scale.map(u);return $(c)?c:null}var Ou=e=>{var t=e.axis,r=e.ticks,n=e.offset,a=e.bandSize,i=e.entry,o=e.index;if(t.type==="category")return r[o]?r[o].coordinate+n:null;var l=Q(i,t.dataKey,t.scale.domain()[o]);if(ie(l))return null;var u=t.scale.map(l);return $(u)?u-a/2+n:null},Og=e=>{var t=e.numericAxis,r=t.scale.domain();if(t.type==="number"){var n=Math.min(r[0],r[1]),a=Math.max(r[0],r[1]);return n<=0&&a>=0?0:a<0?a:n}return r[0]},Sg=e=>{var t=e.flat(2).filter($);return[Math.min(...t),Math.max(...t)]},Ig=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],Eg=(e,t,r)=>{if(!(e==null||Object.keys(e).length===0))return Ig(Object.keys(e).reduce((n,a)=>{var i=e[a];if(!i)return n;var o=i.stackedData,l=o.reduce((u,c)=>{var s=Id(c,t,r),f=Sg(s);return!H(f[0])||!H(f[1])?u:[Math.min(u[0],f[0]),Math.max(u[1],f[1])]},[1/0,-1/0]);return[Math.min(l[0],n[0]),Math.max(l[1],n[1])]},[1/0,-1/0]))},Su=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Iu=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Ar=(e,t,r)=>{if(e&&e.scale&&e.scale.bandwidth){var n=e.scale.bandwidth();if(!r||n>0)return n}if(e&&t&&t.length>=2){for(var a=Ca(t,s=>s.coordinate),i=1/0,o=1,l=a.length;o{if(t==="horizontal")return e.relativeX;if(t==="vertical")return e.relativeY},jg=(e,t)=>t==="centric"?e.angle:e.radius,At=e=>e.layout.width,Pt=e=>e.layout.height,Cg=e=>e.layout.scale,Cd=e=>e.layout.margin,_a=P(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),Na=P(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),Td="data-recharts-item-index",$d="data-recharts-item-id",mn=60;function ku(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Mn(e){for(var t=1;te.brush.height;function _g(e){var t=Na(e);return t.reduce((r,n)=>{if(n.orientation==="left"&&!n.mirror&&!n.hide){var a=typeof n.width=="number"?n.width:mn;return r+a}return r},0)}function Ng(e){var t=Na(e);return t.reduce((r,n)=>{if(n.orientation==="right"&&!n.mirror&&!n.hide){var a=typeof n.width=="number"?n.width:mn;return r+a}return r},0)}function Lg(e){var t=_a(e);return t.reduce((r,n)=>n.orientation==="top"&&!n.mirror&&!n.hide?r+n.height:r,0)}function Rg(e){var t=_a(e);return t.reduce((r,n)=>n.orientation==="bottom"&&!n.mirror&&!n.hide?r+n.height:r,0)}var ge=P([At,Pt,Cd,Dg,_g,Ng,Lg,Rg,Pd,eg],(e,t,r,n,a,i,o,l,u,c)=>{var s={left:(r.left||0)+a,right:(r.right||0)+i},f={top:(r.top||0)+o,bottom:(r.bottom||0)+l},v=Mn(Mn({},f),s),h=v.bottom;v.bottom+=n,v=gg(v,u,c);var m=e-v.left-v.right,p=t-v.top-v.bottom;return Mn(Mn({brushBottom:h},v),{},{width:Math.max(m,0),height:Math.max(p,0)})}),Bg=P(ge,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),xo=P(At,Pt,(e,t)=>({x:0,y:0,width:e,height:t})),zg=d.createContext(null),$e=()=>d.useContext(zg)!=null,La=e=>e.brush,Ra=P([La,ge,Cd],(e,t,r)=>({height:e.height,x:$(e.x)?e.x:t.left,y:$(e.y)?e.y:t.top+t.height+t.brushBottom-((r==null?void 0:r.bottom)||0),width:$(e.width)?e.width:t.width})),Qn=function(t,r){for(var n=arguments.length,a=new Array(n>2?n-2:0),i=2;ia[o++]))}},it={width:"100%",height:"100%",debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},Md=(e,t,r)=>{var n=r.width,a=n===void 0?it.width:n,i=r.height,o=i===void 0?it.height:i,l=r.aspect,u=r.maxHeight,c=tr(a)?e:Number(a),s=tr(o)?t:Number(o);return l&&l>0&&(c?s=c/l:s&&(c=s*l),u&&s!=null&&s>u&&(s=u)),{calculatedWidth:c,calculatedHeight:s}},Kg={width:0,height:0,overflow:"visible"},Wg={width:0,overflowX:"visible"},Fg={height:0,overflowY:"visible"},Ug={},Hg=e=>{var t=e.width,r=e.height,n=tr(t),a=tr(r);return n&&a?Kg:n?Wg:a?Fg:Ug};function Vg(e){var t=e.width,r=e.height,n=e.aspect,a=t,i=r;return a===void 0&&i===void 0?(a=it.width,i=it.height):a===void 0?a=n&&n>0?void 0:it.width:i===void 0&&(i=n&&n>0?void 0:it.height),{width:a,height:i}}var Gg=["aspect","initialDimension","width","height","minWidth","minHeight","maxHeight","children","debounce","id","className","onResize","style"];function Jn(){return Jn=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=Array(t);r({width:r,height:n}),[r,n]);return ab(a)?d.createElement(Dd.Provider,{value:a},t):null}var wo=()=>d.useContext(Dd),ib=d.forwardRef((e,t)=>{var r=e.aspect,n=e.initialDimension,a=n===void 0?it.initialDimension:n,i=e.width,o=e.height,l=e.minWidth,u=l===void 0?it.minWidth:l,c=e.minHeight,s=e.maxHeight,f=e.children,v=e.debounce,h=v===void 0?it.debounce:v,m=e.id,p=e.className,y=e.onResize,g=e.style,x=g===void 0?{}:g,A=rb(e,Gg),w=d.useRef(null),O=d.useRef();O.current=y,d.useImperativeHandle(t,()=>w.current);var b=d.useState({containerWidth:a.width,containerHeight:a.height}),S=Zg(b,2),I=S[0],k=S[1],E=d.useCallback((W,F)=>{k(L=>{var V=Math.round(W),K=Math.round(F);return L.containerWidth===V&&L.containerHeight===K?L:{containerWidth:V,containerHeight:K}})},[]);d.useEffect(()=>{if(w.current==null||typeof ResizeObserver>"u")return or;var W=le=>{var de,ae=le[0];if(ae!=null){var Me=ae.contentRect,Be=Me.width,qe=Me.height;E(Be,qe),(de=O.current)===null||de===void 0||de.call(O,Be,qe)}};h>0&&(W=Ep(W,h,{trailing:!0,leading:!1}));var F=new ResizeObserver(W),L=w.current.getBoundingClientRect(),V=L.width,K=L.height;return E(V,K),F.observe(w.current),()=>{F.disconnect()}},[E,h]);var T=I.containerWidth,j=I.containerHeight;Qn(!r||r>0,"The aspect(%s) must be greater than zero.",r);var N=Md(T,j,{width:i,height:o,aspect:r,maxHeight:s}),_=N.calculatedWidth,R=N.calculatedHeight;return Qn(T<0||j<0||_!=null&&_>0||R!=null&&R>0,`The width(%s) and height(%s) of chart should be greater than 0, + please check the style of container, or the props width(%s) and height(%s), + or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the + height and width.`,_,R,i,o,u,c,r),d.createElement("div",Jn({id:m?"".concat(m):void 0,className:Z("recharts-responsive-container",p),style:Cu(Cu({},x),{},{width:i,height:o,minWidth:u,minHeight:c,maxHeight:s}),ref:w},A),d.createElement("div",{style:Hg({width:i,height:o})},d.createElement(_d,{width:_,height:R},f)))}),lD=d.forwardRef((e,t)=>{var r=wo();if(ct(r.width)&&ct(r.height))return e.children;var n=Vg({width:e.width,height:e.height,aspect:e.aspect}),a=n.width,i=n.height,o=Md(void 0,void 0,{width:a,height:i,aspect:e.aspect,maxHeight:e.maxHeight}),l=o.calculatedWidth,u=o.calculatedHeight;return $(l)&&$(u)?d.createElement(_d,{width:l,height:u},e.children):d.createElement(ib,Jn({},e,{width:a,height:i,ref:t}))});function Ao(e){if(e)return{x:e.x,y:e.y,upperWidth:"upperWidth"in e?e.upperWidth:e.width,lowerWidth:"lowerWidth"in e?e.lowerWidth:e.width,width:e.width,height:e.height}}var Ba=()=>{var e,t=$e(),r=M(Bg),n=M(Ra),a=(e=M(La))===null||e===void 0?void 0:e.padding;return!t||!n||!a?r:{width:n.width-a.left-a.right,height:n.height-a.top-a.bottom,x:a.left,y:a.top}},ob={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},Nd=()=>{var e;return(e=M(ge))!==null&&e!==void 0?e:ob},Po=()=>M(At),Oo=()=>M(Pt),lb=()=>M(e=>e.layout.margin),Y=e=>e.layout.layoutType,lr=()=>M(Y),So=()=>{var e=lr();if(e==="horizontal"||e==="vertical")return e},Io=e=>{var t=e.layout.layoutType;if(t==="centric"||t==="radial")return t},ub=()=>M(Io),cb=()=>{var e=lr();return e!==void 0},pn=e=>{var t=ee(),r=$e(),n=e.width,a=e.height,i=wo(),o=n,l=a;return i&&(o=i.width>0?i.width:n,l=i.height>0?i.height:a),d.useEffect(()=>{!r&&ct(o)&&ct(l)&&t(dg({width:o,height:l}))},[t,r,o,l]),null},sb={settings:{layout:"horizontal",align:"center",verticalAlign:"bottom",itemSorter:"value"},size:{width:0,height:0},payload:[]},Ld=Te({name:"legend",initialState:sb,reducers:{setLegendSize(e,t){e.size.width=t.payload.width,e.size.height=t.payload.height},setLegendSettings(e,t){e.settings.align=t.payload.align,e.settings.layout=t.payload.layout,e.settings.verticalAlign=t.payload.verticalAlign,e.settings.itemSorter=t.payload.itemSorter},addLegendPayload:{reducer(e,t){e.payload.push(q(t.payload))},prepare:re()},replaceLegendPayload:{reducer(e,t){var r=t.payload,n=r.prev,a=r.next,i=Qe(e).payload.indexOf(q(n));i>-1&&(e.payload[i]=q(a))},prepare:re()},removeLegendPayload:{reducer(e,t){var r=Qe(e).payload.indexOf(q(t.payload));r>-1&&e.payload.splice(r,1)},prepare:re()}}}),yn=Ld.actions,$u=yn.setLegendSize,fb=yn.setLegendSettings,Rd=yn.addLegendPayload,Bd=yn.replaceLegendPayload,zd=yn.removeLegendPayload,db=Ld.reducer,vb=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle","radius","throttledEvents"]);function hb(e,t){return e==null&&t==null?!0:typeof e=="number"&&typeof t=="number"?e===t||e!==e&&t!==t:e===t}function Tr(e,t){var r=new Set([...Object.keys(e),...Object.keys(t)]);for(var n of r)if(vb.has(n)){if(e[n]==null&&t[n]==null)continue;if(!kp(e[n],t[n]))return!1}else if(!hb(e[n],t[n]))return!1;return!0}var mb=["contextPayload"];function Bi(){return Bi=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=Array(t);r{i(fb({align:t,layout:r,verticalAlign:n,itemSorter:a}))},[i,t,r,n,a]),null}function Cb(e){var t=e.width,r=e.height,n=ee();return d.useLayoutEffect(()=>{n($u({width:t,height:r}))},[n,t,r]),d.useLayoutEffect(()=>()=>{n($u({width:0,height:0}))},[n]),null}function Tb(e,t,r,n){return e==="vertical"&&t!=null?{height:t}:e==="horizontal"?{width:r||n}:null}var $b={align:"center",iconSize:14,inactiveColor:"#ccc",itemSorter:"value",labelStyle:{},layout:"horizontal",verticalAlign:"bottom"};function Mb(e){var t=Ae(e,$b),r=ng(),n=Vp(),a=lb(),i=t.width,o=t.height,l=t.wrapperStyle,u=t.portal,c=Od([r]),s=pb(c,2),f=s[0],v=s[1],h=Po(),m=Oo();if(h==null||m==null)return null;var p=h-((a==null?void 0:a.left)||0)-((a==null?void 0:a.right)||0),y=Tb(t.layout,o,i,p),g=u?l:Pr(Pr({position:"absolute",width:(y==null?void 0:y.width)||i||"auto",height:(y==null?void 0:y.height)||o||"auto"},kb(l,t,a,h,m,f)),l),x=u??n;if(x==null||r==null)return null;var A=d.createElement("div",{className:"recharts-legend-wrapper",style:g,ref:v},d.createElement(jb,{layout:t.layout,align:t.align,verticalAlign:t.verticalAlign,itemSorter:t.itemSorter}),!u&&d.createElement(Cb,{width:f.width,height:f.height}),d.createElement(Eb,Bi({},t,y,{margin:a,chartWidth:h,chartHeight:m,contextPayload:r})));return fo.createPortal(A,x)}var Db=d.memo(Mb,Tr);Db.displayName="Legend";function zi(){return zi=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=Array(t);r{var t=e.separator,r=t===void 0?fr.separator:t,n=e.contentStyle,a=e.itemStyle,i=e.labelStyle,o=i===void 0?fr.labelStyle:i,l=e.payload,u=e.formatter,c=e.itemSorter,s=e.wrapperClassName,f=e.labelClassName,v=e.label,h=e.labelFormatter,m=e.accessibilityLayer,p=m===void 0?fr.accessibilityLayer:m,y=()=>{if(l&&l.length){var I={padding:0,margin:0},k=Ub(l,c),E=k.map((T,j)=>{if(!T||T.type==="none")return null;var N=T.formatter||u||Fb,_=T.value,R=T.name,W=_,F=R;if(N){var L=N(_,R,T,j,l);if(Array.isArray(L)){var V=Rb(L,2);W=V[0],F=V[1]}else if(L!=null)W=L;else return null}var K=Kr(Kr({},fr.itemStyle),{},{color:T.color||fr.itemStyle.color},a);return d.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(j),style:K},ut(F)?d.createElement("span",{className:"recharts-tooltip-item-name"},F):null,ut(F)?d.createElement("span",{className:"recharts-tooltip-item-separator"},r):null,d.createElement("span",{className:"recharts-tooltip-item-value"},W),d.createElement("span",{className:"recharts-tooltip-item-unit"},T.unit||""))});return d.createElement("ul",{className:"recharts-tooltip-item-list",style:I},E)}return null},g=Kr(Kr({},fr.contentStyle),n),x=Kr({margin:0},o),A=!ie(v),w=A?v:"",O=Z("recharts-default-tooltip",s),b=Z("recharts-tooltip-label",f);A&&h&&l!==void 0&&l!==null&&(w=h(v,l));var S=p?{role:"status","aria-live":"assertive"}:{};return d.createElement("div",zi({className:O,style:g},S),d.createElement("p",{className:b,style:x},d.isValidElement(w)?w:"".concat(w)),y())},Wr="recharts-tooltip-wrapper",Vb={visibility:"hidden"};function Gb(e){var t=e.coordinate,r=e.translateX,n=e.translateY;return Z(Wr,{["".concat(Wr,"-right")]:$(r)&&t&&$(t.x)&&r>=t.x,["".concat(Wr,"-left")]:$(r)&&t&&$(t.x)&&r=t.y,["".concat(Wr,"-top")]:$(n)&&t&&$(t.y)&&n0?a:0),f=r[n]+a;if(t[n])return o[n]?s:f;var v=u[n];if(v==null)return 0;if(o[n]){var h=s,m=v;return hy?Math.max(s,v):Math.max(f,v)}function Yb(e){var t=e.translateX,r=e.translateY,n=e.useTranslate3d;return{transform:n?"translate3d(".concat(t,"px, ").concat(r,"px, 0)"):"translate(".concat(t,"px, ").concat(r,"px)")}}function qb(e){var t=e.allowEscapeViewBox,r=e.coordinate,n=e.offsetTop,a=e.offsetLeft,i=e.position,o=e.reverseDirection,l=e.tooltipBox,u=e.useTranslate3d,c=e.viewBox,s,f,v;return l.height>0&&l.width>0&&r?(f=Lu({allowEscapeViewBox:t,coordinate:r,key:"x",offset:a,position:i,reverseDirection:o,tooltipDimension:l.width,viewBox:c,viewBoxDimension:c.width}),v=Lu({allowEscapeViewBox:t,coordinate:r,key:"y",offset:n,position:i,reverseDirection:o,tooltipDimension:l.height,viewBox:c,viewBoxDimension:c.height}),s=Yb({translateX:f,translateY:v,useTranslate3d:u})):s=Vb,{cssProperties:s,cssClasses:Gb({translateX:f,translateY:v,coordinate:r})}}var Xb=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),gn={isSsr:Xb()};function Zb(e,t){return t0(e)||e0(e,t)||Jb(e,t)||Qb()}function Qb(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Jb(e,t){if(e){if(typeof e=="string")return Ru(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ru(e,t):void 0}}function Ru(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);rgn.isSsr||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches),t=Zb(e,2),r=t[0],n=t[1];return d.useEffect(()=>{if(window.matchMedia){var a=window.matchMedia("(prefers-reduced-motion: reduce)"),i=()=>{n(a.matches)};return a.addEventListener("change",i),()=>{a.removeEventListener("change",i)}}},[]),r}function Bu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function dr(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=Array(t);r({dismissed:!1,dismissedAtCoordinate:{x:0,y:0}})),c=i0(u,2),s=c[0],f=c[1];d.useEffect(()=>{var g=x=>{if(x.key==="Escape"){var A,w,O,b;f({dismissed:!0,dismissedAtCoordinate:{x:(A=(w=e.coordinate)===null||w===void 0?void 0:w.x)!==null&&A!==void 0?A:0,y:(O=(b=e.coordinate)===null||b===void 0?void 0:b.y)!==null&&O!==void 0?O:0}})}};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g)}},[(t=e.coordinate)===null||t===void 0?void 0:t.x,(r=e.coordinate)===null||r===void 0?void 0:r.y]),s.dismissed&&(((n=(a=e.coordinate)===null||a===void 0?void 0:a.x)!==null&&n!==void 0?n:0)!==s.dismissedAtCoordinate.x||((i=(o=e.coordinate)===null||o===void 0?void 0:o.y)!==null&&i!==void 0?i:0)!==s.dismissedAtCoordinate.y)&&f(dr(dr({},s),{},{dismissed:!1}));var v=qb({allowEscapeViewBox:e.allowEscapeViewBox,coordinate:e.coordinate,offsetLeft:typeof e.offset=="number"?e.offset:e.offset.x,offsetTop:typeof e.offset=="number"?e.offset:e.offset.y,position:e.position,reverseDirection:e.reverseDirection,tooltipBox:{height:e.lastBoundingBox.height,width:e.lastBoundingBox.width},useTranslate3d:e.useTranslate3d,viewBox:e.viewBox}),h=v.cssClasses,m=v.cssProperties,p=e.hasPortalFromProps?{}:dr(dr({transition:s0({prefersReducedMotion:l,isAnimationActive:e.isAnimationActive,active:e.active,animationDuration:e.animationDuration,animationEasing:e.animationEasing})},m),{},{pointerEvents:"none",position:"absolute",top:0,left:0}),y=dr(dr({},p),{},{visibility:!s.dismissed&&e.active&&e.hasPayload?"visible":"hidden"},e.wrapperStyle);return d.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:h,style:y,ref:e.innerRef},e.children)}var d0=d.memo(f0),Wd=()=>{var e;return(e=M(t=>t.rootProps.accessibilityLayer))!==null&&e!==void 0?e:!0};function Ki(){return Ki=Object.assign?Object.assign.bind():function(e){for(var t=1;tH(e.x)&&H(e.y),Uu=e=>e.base!=null&&ea(e.base)&&ea(e),Fr=e=>e.x,Ur=e=>e.y,p0=(e,t)=>{if(typeof e=="function")return e;var r="curve".concat(vn(e));if((r==="curveMonotone"||r==="curveBump")&&t){var n=Fu["".concat(r).concat(t==="vertical"?"Y":"X")];if(n)return n}return Fu[r]||$a},Hu={connectNulls:!1,type:"linear"},y0=e=>{var t=e.type,r=t===void 0?Hu.type:t,n=e.points,a=n===void 0?[]:n,i=e.baseLine,o=e.layout,l=e.connectNulls,u=l===void 0?Hu.connectNulls:l,c=p0(r,o),s=u?a.filter(ea):a;if(Array.isArray(i)){var f,v=a.map((g,x)=>Wu(Wu({},g),{},{base:i[x]}));o==="vertical"?f=Tn().y(Ur).x1(Fr).x0(g=>g.base.x):f=Tn().x(Fr).y1(Ur).y0(g=>g.base.y);var h=f.defined(Uu).curve(c),m=u?v.filter(Uu):v;return h(m)}var p;o==="vertical"&&$(i)?p=Tn().y(Ur).x1(Fr).x0(i):$(i)?p=Tn().x(Fr).y1(Ur).y0(i):p=id().x(Fr).y(Ur);var y=p.defined(ea).curve(c);return y(s)},Jr=e=>{var t=e.className,r=e.points,n=e.path,a=e.pathRef,i=lr();if((!r||!r.length)&&!n)return null;var o={type:e.type,points:e.points,baseLine:e.baseLine,layout:e.layout||i,connectNulls:e.connectNulls},l=r&&r.length?y0(o):n;return d.createElement("path",Ki({},Le(e),go(e),{className:Z("recharts-curve",t),d:l===null?void 0:l,ref:a}))},g0=["x","y","top","left","width","height","className"];function Wi(){return Wi=Object.assign?Object.assign.bind():function(e){for(var t=1;t"M".concat(e,",").concat(a,"v").concat(n,"M").concat(i,",").concat(t,"h").concat(r),I0=e=>{var t=e.x,r=t===void 0?0:t,n=e.y,a=n===void 0?0:n,i=e.top,o=i===void 0?0:i,l=e.left,u=l===void 0?0:l,c=e.width,s=c===void 0?0:c,f=e.height,v=f===void 0?0:f,h=e.className,m=P0(e,g0),p=b0({x:r,y:a,top:o,left:u,width:s,height:v},m);return!$(r)||!$(a)||!$(s)||!$(v)||!$(o)||!$(u)?null:d.createElement("path",Wi({},Ke(p),{className:Z("recharts-cross",h),d:S0(r,a,s,v,o,u)}))};function E0(e,t,r,n){var a=n/2;return{stroke:"none",fill:"#ccc",x:e==="horizontal"?t.x-a:r.left+.5,y:e==="horizontal"?r.top+.5:t.y-a,width:e==="horizontal"?n:r.width-1,height:e==="horizontal"?r.height-1:n}}var ta=1e-4,Fd=(e,t)=>[0,3*e,3*t-6*e,3*e-3*t+1],Ud=(e,t)=>e.map((r,n)=>r*t**n).reduce((r,n)=>r+n),Gu=(e,t)=>r=>{var n=Fd(e,t);return Ud(n,r)},k0=(e,t)=>r=>{var n=Fd(e,t),a=[...n.map((i,o)=>i*o).slice(1),0];return Ud(a,r)},j0=e=>{var t,r=e.split("(");if(r.length!==2||r[0]!=="cubic-bezier")return null;var n=(t=r[1])===null||t===void 0||(t=t.split(")")[0])===null||t===void 0?void 0:t.split(",");if(n==null||n.length!==4)return null;var a=n.map(i=>parseFloat(i));return[a[0],a[1],a[2],a[3]]},C0=function(){for(var t=arguments.length,r=new Array(t),n=0;n{var a=Gu(e,r),i=Gu(t,n),o=k0(e,r),l=c=>c>1?1:c<0?0:c,u=c=>{for(var s=c>1?1:c,f=s,v=0;v<8;++v){var h=a(f)-s,m=o(f);if(Math.abs(h-s)0&&arguments[0]!==void 0?arguments[0]:{},r=t.stiff,n=r===void 0?100:r,a=t.damping,i=a===void 0?8:a,o=t.dt,l=o===void 0?16.67:o,u=1,c=[0],s=0,f=0,v=1e4,h=0;h{var x,A,w;if(g<=0)return 0;if(g>=1)return u;var O=g*y,b=Math.floor(O),S=O-b;return((x=c[b])!==null&&x!==void 0?x:0)+(((A=c[b+1])!==null&&A!==void 0?A:0)-((w=c[b])!==null&&w!==void 0?w:0))*S}},M0=e=>{if(typeof e=="string")switch(e){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return Yu(e);case"spring":return $0();default:if(e.split("(")[0]==="cubic-bezier")return Yu(e)}return typeof e=="function"?e:null},D0=(e,t,r)=>{var n,a=i=>{var o=t.tick(i);if(t.getState()==="active"){if(r(t.getInterpolated()),t.getProgress()===1){t.complete(),n=void 0;return}n=e.setTimeout(a,o);return}n=e.setTimeout(a,o)};return n=e.setTimeout(a,0),()=>{var i;return(i=n)===null||i===void 0?void 0:i()}},Hd=d.createContext(D0);Hd.Provider;function _0(e){var t=d.useContext(Hd);return d.useMemo(()=>e??t,[e,t])}function N0(e,t,r){return(t=L0(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function L0(e){var t=R0(e,"string");return typeof t=="symbol"?t:t+""}function R0(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var qu="init",Xu="pending",Zu="active",B0="completed";function mi(e){return Math.max(0,e)}class z0{getAnimationStartedTime(){return this.animationStartedTime}getBeginStartedTime(){return this.beginStartedTime}constructor(t){var r;N0(this,"state",qu),this.animationId=t.animationId,this.onAnimationEnd=t.onAnimationEnd,this.animationDuration=mi(t.animationDuration),this.animationBegin=mi(t.animationBegin),this.progress=0,this.from=t.from,this.to=t.to,this.easing=t.easing,(r=t.onAnimationStart)===null||r===void 0||r.call(t)}getState(){return this.state}getEasing(){return this.easing}getAnimationDuration(){return this.animationDuration}tick(t){if(this.getState()===qu)return this.state=Xu,this.beginStartedTime=t,this.animationBegin;if(this.getState()===Xu){if(this.beginStartedTime==null)throw new Error;var r=t-this.beginStartedTime;return r>=this.animationBegin?(this.state=Zu,this.animationStartedTime=t,this.nextAnimationUpdate(0)):mi(this.animationBegin-r)}if(this.getState()===Zu){if(this.animationStartedTime==null)throw new Error;var n=t-this.animationStartedTime;return this.setProgress(n/this.animationDuration),this.nextAnimationUpdate(n)}return 0}setProgress(t){this.progress=Math.min(1,Math.max(0,t))}getProgress(){return this.progress}complete(){if(this.progress=1,this.state==="active"){var t;(t=this.onAnimationEnd)===null||t===void 0||t.call(this)}this.state=B0}getFrom(){return this.from}getTo(){return this.to}getAnimationId(){return this.animationId}getAnimationBegin(){return this.animationBegin}}class K0 extends z0{nextAnimationUpdate(){return 0}getInterpolated(){return this.easing(ue(this.getFrom(),this.getTo(),this.getProgress()))}}class W0{setTimeout(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=performance.now(),a=null,i=o=>{o-n>=r?t(o):a=requestAnimationFrame(i)};return a=requestAnimationFrame(i),()=>{a!=null&&cancelAnimationFrame(a)}}}function F0(e,t){return G0(e)||V0(e,t)||H0(e,t)||U0()}function U0(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function H0(e,t){if(e){if(typeof e=="string")return Qu(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Qu(e,t):void 0}}function Qu(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r{},onAnimationStart:()=>{}},Ju=0,pi=1;function Vd(e){var t=Ae(e,Y0),r=t.animationId,n=t.isActive,a=t.canBegin,i=t.duration,o=t.easing,l=t.begin,u=t.onAnimationEnd,c=t.onAnimationStart,s=t.children,f=Kd(),v=n==="auto"?!gn.isSsr&&!f:n,h=_0(t.animationController),m=d.useState(v?Ju:pi),p=F0(m,2),y=p[0],g=p[1];return d.useEffect(()=>{v||g(pi)},[v]),d.useEffect(()=>{var x=M0(o);if(!v||!a||x==null)return or;var A=new W0,w=new K0({animationId:r,easing:x,animationDuration:i,animationBegin:l,onAnimationStart:c,onAnimationEnd:u,from:Ju,to:pi});return h(A,w,g)},[h,r,v,a,i,o,l,c,u]),s(Number(y))}function Gd(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",r=d.useRef(nn(t)),n=d.useRef(e);return n.current!==e&&(r.current=nn(t),n.current=e),r.current}var q0=e=>e.replace(/([A-Z])/g,t=>"-".concat(t.toLowerCase())),X0=(e,t,r)=>e.map(n=>"".concat(q0(n)," ").concat(t,"ms ").concat(r)).join(","),Z0=["radius"],Q0=["radius"],ec,tc,rc,nc,ac,ic,oc,lc,uc,cc;function sc(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function fc(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=Array(t);r{var i=Tt(r),o=Tt(n),l=Math.min(Math.abs(i)/2,Math.abs(o)/2),u=o>=0?1:-1,c=i>=0?1:-1,s=o>=0&&i>=0||o<0&&i<0?1:0,f;if(l>0&&Array.isArray(a)){for(var v=[0,0,0,0],h=0,m=4;hl?l:y}f=Se(ec||(ec=rt(["M",",",""])),e,t+u*v[0]),v[0]>0&&(f+=Se(tc||(tc=rt(["A ",",",",0,0,",",",",",""])),v[0],v[0],s,e+c*v[0],t)),f+=Se(rc||(rc=rt(["L ",",",""])),e+r-c*v[1],t),v[1]>0&&(f+=Se(nc||(nc=rt(["A ",",",",0,0,",`, + `,",",""])),v[1],v[1],s,e+r,t+u*v[1])),f+=Se(ac||(ac=rt(["L ",",",""])),e+r,t+n-u*v[2]),v[2]>0&&(f+=Se(ic||(ic=rt(["A ",",",",0,0,",`, + `,",",""])),v[2],v[2],s,e+r-c*v[2],t+n)),f+=Se(oc||(oc=rt(["L ",",",""])),e+c*v[3],t+n),v[3]>0&&(f+=Se(lc||(lc=rt(["A ",",",",0,0,",`, + `,",",""])),v[3],v[3],s,e,t+n-u*v[3])),f+="Z"}else if(l>0&&a===+a&&a>0){var g=Math.min(l,a);f=Se(uc||(uc=rt(["M ",",",` + A `,",",",0,0,",",",",",` + L `,",",` + A `,",",",0,0,",",",",",` + L `,",",` + A `,",",",0,0,",",",",",` + L `,",",` + A `,",",",0,0,",",",","," Z"])),e,t+u*g,g,g,s,e+c*g,t,e+r-c*g,t,g,g,s,e+r,t+u*g,e+r,t+n-u*g,g,g,s,e+r-c*g,t+n,e+c*g,t+n,g,g,s,e,t+n-u*g)}else f=Se(cc||(cc=rt(["M ",","," h "," v "," h "," Z"])),e,t,r,n,-r);return f},mc={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Yd=e=>{var t=Ae(e,mc),r=d.useRef(null),n=d.useState(-1),a=nx(n,2),i=a[0],o=a[1];d.useEffect(()=>{if(r.current&&r.current.getTotalLength)try{var L=r.current.getTotalLength();L&&o(L)}catch{}},[]);var l=t.x,u=t.y,c=t.width,s=t.height,f=t.radius,v=t.className,h=t.animationEasing,m=t.animationDuration,p=t.animationBegin,y=t.isAnimationActive,g=t.isUpdateAnimationActive,x=d.useRef(c),A=d.useRef(s),w=d.useRef(l),O=d.useRef(u),b=d.useMemo(()=>({x:l,y:u,width:c,height:s,radius:f}),[l,u,c,s,f]),S=Gd(b,"rectangle-");if(l!==+l||u!==+u||c!==+c||s!==+s||c===0||s===0)return null;var I=Z("recharts-rectangle",v);if(!g){var k=Ke(t);k.radius;var E=dc(k,Z0);return d.createElement("path",ra({},E,{x:Tt(l),y:Tt(u),width:Tt(c),height:Tt(s),radius:typeof f=="number"?f:void 0,className:I,d:hc(l,u,c,s,f)}))}var T=x.current,j=A.current,N=w.current,_=O.current,R="0px ".concat(i===-1?1:i,"px"),W="".concat(i,"px ").concat(i,"px"),F=X0(["strokeDasharray"],m,typeof h=="string"?h:mc.animationEasing);return d.createElement(Vd,{animationId:S,key:S,canBegin:i>0,duration:m,easing:h,isActive:g,begin:p},L=>{var V=ue(T,c,L),K=ue(j,s,L),le=ue(N,l,L),de=ue(_,u,L);r.current&&(x.current=V,A.current=K,w.current=le,O.current=de);var ae;y?L>0?ae={transition:F,strokeDasharray:W}:ae={strokeDasharray:R}:ae={strokeDasharray:W};var Me=Ke(t);Me.radius;var Be=dc(Me,Q0);return d.createElement("path",ra({},Be,{radius:typeof f=="number"?f:void 0,className:I,d:hc(le,de,V,K,f),ref:r,style:fc(fc({},ae),t.style)}))})};function pc(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function yc(e){for(var t=1;te*180/Math.PI,ve=(e,t,r,n)=>({x:e+Math.cos(-na*n)*r,y:t+Math.sin(-na*n)*r}),qd=function(t,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(t-(n.left||0)-(n.right||0)),Math.abs(r-(n.top||0)-(n.bottom||0)))/2},dx=(e,t)=>{var r=e.x,n=e.y,a=t.x,i=t.y;return Math.sqrt((r-a)**2+(n-i)**2)},vx=(e,t)=>{var r=e.x,n=e.y,a=t.cx,i=t.cy,o=dx({x:r,y:n},{x:a,y:i});if(o<=0)return{radius:o,angle:0};var l=(r-a)/o,u=Math.acos(l);return n>i&&(u=2*Math.PI-u),{radius:o,angle:fx(u),angleInRadian:u}},hx=e=>{var t=e.startAngle,r=e.endAngle,n=Math.floor(t/360),a=Math.floor(r/360),i=Math.min(n,a);return{startAngle:t-i*360,endAngle:r-i*360}},mx=(e,t)=>{var r=t.startAngle,n=t.endAngle,a=Math.floor(r/360),i=Math.floor(n/360),o=Math.min(a,i);return e+o*360},px=(e,t)=>{var r=e.relativeX,n=e.relativeY,a=vx({x:r,y:n},t),i=a.radius,o=a.angle,l=t.innerRadius,u=t.outerRadius;if(iu||i===0)return null;var c=hx(t),s=c.startAngle,f=c.endAngle,v=o,h;if(s<=f){for(;v>f;)v-=360;for(;v=s&&v<=f}else{for(;v>s;)v-=360;for(;v=f&&v<=s}return h?yc(yc({},t),{},{radius:i,angle:mx(v,t)}):null};function Xd(e){var t=e.cx,r=e.cy,n=e.radius,a=e.startAngle,i=e.endAngle,o=ve(t,r,n,a),l=ve(t,r,n,i);return{points:[o,l],cx:t,cy:r,radius:n,startAngle:a,endAngle:i}}var gc,bc,xc,wc,Ac,Pc,Oc;function Fi(){return Fi=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var r=we(t-e),n=Math.min(Math.abs(t-e),359.999);return r*n},Dn=e=>{var t=e.cx,r=e.cy,n=e.radius,a=e.angle,i=e.sign,o=e.isExternal,l=e.cornerRadius,u=e.cornerIsExternal,c=l*(o?1:-1)+n,s=Math.asin(l/c)/na,f=u?a:a+i*s,v=ve(t,r,c,f),h=ve(t,r,n,f),m=u?a-i*s:a,p=ve(t,r,c*Math.cos(s*na),m);return{center:v,circleTangency:h,lineTangency:p,theta:s}},Zd=e=>{var t=e.cx,r=e.cy,n=e.innerRadius,a=e.outerRadius,i=e.startAngle,o=e.endAngle,l=yx(i,o),u=i+l,c=ve(t,r,a,i),s=ve(t,r,a,u),f=Se(gc||(gc=Gt(["M ",",",` + A `,",",`,0, + `,",",`, + `,",",` + `])),c.x,c.y,a,a,+(Math.abs(l)>180),+(i>u),s.x,s.y);if(n>0){var v=ve(t,r,n,i),h=ve(t,r,n,u);f+=Se(bc||(bc=Gt(["L ",",",` + A `,",",`,0, + `,",",`, + `,","," Z"])),h.x,h.y,n,n,+(Math.abs(l)>180),+(i<=u),v.x,v.y)}else f+=Se(xc||(xc=Gt(["L ",","," Z"])),t,r);return f},gx=e=>{var t=e.cx,r=e.cy,n=e.innerRadius,a=e.outerRadius,i=e.cornerRadius,o=e.forceCornerRadius,l=e.cornerIsExternal,u=e.startAngle,c=e.endAngle,s=we(c-u),f=Dn({cx:t,cy:r,radius:a,angle:u,sign:s,cornerRadius:i,cornerIsExternal:l}),v=f.circleTangency,h=f.lineTangency,m=f.theta,p=Dn({cx:t,cy:r,radius:a,angle:c,sign:-s,cornerRadius:i,cornerIsExternal:l}),y=p.circleTangency,g=p.lineTangency,x=p.theta,A=l?Math.abs(u-c):Math.abs(u-c)-m-x;if(A<0)return o?Se(wc||(wc=Gt(["M ",",",` + a`,",",",0,0,1,",`,0 + a`,",",",0,0,1,",`,0 + `])),h.x,h.y,i,i,i*2,i,i,-i*2):Zd({cx:t,cy:r,innerRadius:n,outerRadius:a,startAngle:u,endAngle:c});var w=Se(Ac||(Ac=Gt(["M ",",",` + A`,",",",0,0,",",",",",` + A`,",",",0,",",",",",",",` + A`,",",",0,0,",",",",",` + `])),h.x,h.y,i,i,+(s<0),v.x,v.y,a,a,+(A>180),+(s<0),y.x,y.y,i,i,+(s<0),g.x,g.y);if(n>0){var O=Dn({cx:t,cy:r,radius:n,angle:u,sign:s,isExternal:!0,cornerRadius:i,cornerIsExternal:l}),b=O.circleTangency,S=O.lineTangency,I=O.theta,k=Dn({cx:t,cy:r,radius:n,angle:c,sign:-s,isExternal:!0,cornerRadius:i,cornerIsExternal:l}),E=k.circleTangency,T=k.lineTangency,j=k.theta,N=l?Math.abs(u-c):Math.abs(u-c)-I-j;if(N<0&&i===0)return"".concat(w,"L").concat(t,",").concat(r,"Z");w+=Se(Pc||(Pc=Gt(["L",",",` + A`,",",",0,0,",",",",",` + A`,",",",0,",",",",",",",` + A`,",",",0,0,",",",",","Z"])),T.x,T.y,i,i,+(s<0),E.x,E.y,n,n,+(N>180),+(s>0),b.x,b.y,i,i,+(s<0),S.x,S.y)}else w+=Se(Oc||(Oc=Gt(["L",",","Z"])),t,r);return w},bx={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},Qd=e=>{var t=Ae(e,bx),r=t.cx,n=t.cy,a=t.innerRadius,i=t.outerRadius,o=t.cornerRadius,l=t.forceCornerRadius,u=t.cornerIsExternal,c=t.startAngle,s=t.endAngle,f=t.className;if(i0&&Math.abs(c-s)<360?p=gx({cx:r,cy:n,innerRadius:a,outerRadius:i,cornerRadius:Math.min(m,h/2),forceCornerRadius:l,cornerIsExternal:u,startAngle:c,endAngle:s}):p=Zd({cx:r,cy:n,innerRadius:a,outerRadius:i,startAngle:c,endAngle:s}),d.createElement("path",Fi({},Ke(t),{className:v,d:p}))};function xx(e,t,r){if(e==="horizontal")return[{x:t.x,y:r.top},{x:t.x,y:r.top+r.height}];if(e==="vertical")return[{x:r.left,y:t.y},{x:r.left+r.width,y:t.y}];if(xd(t)){if(e==="centric"){var n=t.cx,a=t.cy,i=t.innerRadius,o=t.outerRadius,l=t.angle,u=ve(n,a,i,l),c=ve(n,a,o,l);return[{x:u.x,y:u.y},{x:c.x,y:c.y}]}return Xd(t)}}var tt=e=>e.chartData,bn=P([tt],e=>{var t=e.chartData!=null?e.chartData.length-1:0;return{chartData:e.chartData,computedData:e.computedData,dataEndIndex:t,dataStartIndex:0}}),za=(e,t,r,n)=>n?bn(e):tt(e),Jd=(e,t,r)=>r?bn(e):tt(e),wx=P([za],e=>{var t=e.chartData,r=e.dataStartIndex,n=e.dataEndIndex;return t!=null?t.slice(r,n+1):[]}),Ax=P([bn],e=>{var t=e.chartData,r=e.dataStartIndex,n=e.dataEndIndex;return t!=null?t.slice(r,n+1):[]}),Px=P([tt],e=>{var t=e.chartData,r=e.dataStartIndex,n=e.dataEndIndex;return t!=null?t.slice(r,n+1):[]});function Eo(e,t){return Ex(e)||Ix(e,t)||Sx(e,t)||Ox()}function Ox(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sx(e,t){if(e){if(typeof e=="string")return Sc(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Sc(e,t):void 0}}function Sc(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);re.length)&&(t=e.length);for(var r=0,n=Array(t);r{var t=an(e,2),r=t[0],n=t[1],a=r,i=n;return r>n&&(a=n,i=r),[a,i]},ko=(e,t,r)=>{if(e.lte(0))return new G(0);var n=tv(e.toNumber()),a=new G(10).pow(n),i=e.div(a),o=n!==1?.05:.1,l=new G(Math.ceil(i.div(o).toNumber())).add(r).mul(o),u=l.mul(a);return t?new G(u.toNumber()):new G(Math.ceil(u.toNumber()))},av=(e,t,r)=>{var n;if(e.lte(0))return new G(0);var a=[1,2,2.5,5],i=e.toNumber(),o=Math.floor(new G(i).abs().log(10).toNumber()),l=new G(10).pow(o),u=e.div(l).toNumber(),c=a.findIndex(h=>h>=u-1e-10);if(c===-1&&(l=l.mul(10),c=0),c+=r,c>=a.length){var s=Math.floor(c/a.length);c%=a.length,l=l.mul(new G(10).pow(s))}var f=(n=a[c])!==null&&n!==void 0?n:1,v=new G(f).mul(l);return t?v:new G(Math.ceil(v.toNumber()))},Mx=(e,t,r)=>{var n=new G(1),a=new G(e);if(!a.isint()&&r){var i=Math.abs(e);i<1?(n=new G(10).pow(tv(e)-1),a=new G(Math.floor(a.div(n).toNumber())).mul(n)):i>1&&(a=new G(Math.floor(e)))}else e===0?a=new G(Math.floor((t-1)/2)):r||(a=new G(Math.floor(e)));for(var o=Math.floor((t-1)/2),l=[],u=0;u4&&arguments[4]!==void 0?arguments[4]:0,o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:ko;if(!Number.isFinite((r-t)/(n-1)))return{step:new G(0),tickMin:new G(0),tickMax:new G(0)};var l=o(new G(r).sub(t).div(n-1),a,i),u;t<=0&&r>=0?u=new G(0):(u=new G(t).add(r).div(2),u=u.sub(new G(u).mod(l)));var c=Math.ceil(u.sub(t).div(l).toNumber()),s=Math.ceil(new G(r).sub(u).div(l).toNumber()),f=c+s+1;return f>n?iv(t,r,n,a,i+1,o):(f0?s+(n-f):s,c=r>0?c:c+(n-f)),{step:l,tickMin:u.sub(new G(c).mul(l)),tickMax:u.add(new G(s).mul(l))})},kc=function(t){var r=an(t,2),n=r[0],a=r[1],i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"auto",u=Math.max(i,2),c=nv([n,a]),s=an(c,2),f=s[0],v=s[1];if(f===-1/0||v===1/0){var h=v===1/0?[f,...Array(i-1).fill(1/0)]:[...Array(i-1).fill(-1/0),v];return n>a?h.reverse():h}if(f===v)return Mx(f,i,o);var m=l==="snap125"?av:ko,p=iv(f,v,u,o,0,m),y=p.step,g=p.tickMin,x=p.tickMax,A=rv(g,x.add(new G(.1).mul(y)),y);return n>a?A.reverse():A},jc=function(t,r){var n=an(t,2),a=n[0],i=n[1],o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"auto",u=nv([a,i]),c=an(u,2),s=c[0],f=c[1];if(s===-1/0||f===1/0)return[a,i];if(s===f)return[s];var v=l==="snap125"?av:ko,h=Math.max(r,2),m=v(new G(f).sub(s).div(h-1),o,0),p=[...rv(new G(s),new G(f),m),f];return o===!1&&(p=p.map(y=>Math.round(y))),a>i?p.reverse():p},ov=e=>e.rootProps.maxBarSize,Dx=e=>e.rootProps.barGap,lv=e=>e.rootProps.barCategoryGap,_x=e=>e.rootProps.barSize,xn=e=>e.rootProps.stackOffset,uv=e=>e.rootProps.reverseStackOrder,jo=e=>e.options.chartName,Co=e=>e.rootProps.syncId,cv=e=>e.rootProps.syncMethod,To=e=>e.options.eventEmitter,Nx=e=>e.rootProps.baseValue,he={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Wt={allowDecimals:!1,allowDataOverflow:!1,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"auto"},nt={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!0,includeHidden:!1,radiusAxisId:0,reversed:!1,scale:"auto",tick:!0,tickCount:5,type:"auto"},Ka=(e,t)=>{if(!(!e||!t))return e!=null&&e.reversed?[t[1],t[0]]:t};function Wa(e,t,r){if(r!=="auto")return r;if(e!=null)return ft(e,t)?"category":"number"}function Cc(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function aa(e){for(var t=1;t{if(t!=null)return e.polarAxis.angleAxis[t]},$o=P([zx,Io],(e,t)=>{var r;if(e!=null)return e;var n=(r=Wa(t,"angleAxis",Tc.type))!==null&&r!==void 0?r:"category";return aa(aa({},Tc),{},{type:n})}),Kx=(e,t)=>e.polarAxis.radiusAxis[t],Mo=P([Kx,Io],(e,t)=>{var r;if(e!=null)return e;var n=(r=Wa(t,"radiusAxis",$c.type))!==null&&r!==void 0?r:"category";return aa(aa({},$c),{},{type:n})}),Fa=e=>e.polarOptions,Do=P([At,Pt,ge],qd),sv=P([Fa,Do],(e,t)=>{if(e!=null)return Ce(e.innerRadius,t,0)}),fv=P([Fa,Do],(e,t)=>{if(e!=null)return Ce(e.outerRadius,t,t*.8)}),Wx=e=>{if(e==null)return[0,0];var t=e.startAngle,r=e.endAngle;return[t,r]},dv=P([Fa],Wx);P([$o,dv],Ka);var vv=P([Do,sv,fv],(e,t,r)=>{if(!(e==null||t==null||r==null))return[t,r]});P([Mo,vv],Ka);var hv=P([Y,Fa,sv,fv,At,Pt],(e,t,r,n,a,i)=>{if(!(e!=="centric"&&e!=="radial"||t==null||r==null||n==null)){var o=t.cx,l=t.cy,u=t.startAngle,c=t.endAngle;return{cx:Ce(o,a,a/2),cy:Ce(l,i,i/2),innerRadius:r,outerRadius:n,startAngle:u,endAngle:c,clockWise:!1}}}),oe=(e,t)=>t,wn=(e,t,r)=>r;function Ua(e){return e==null?void 0:e.id}function mv(e,t,r){var n=t.chartData,a=n===void 0?[]:n,i=r.allowDuplicatedCategory,o=r.dataKey,l=new Map;return e.forEach(u=>{var c,s=(c=u.data)!==null&&c!==void 0?c:a;if(!(s==null||s.length===0)){var f=Ua(u);s.forEach((v,h)=>{var m=o==null||i?h:String(Q(v,o,null)),p=Q(v,u.dataKey,0),y;l.has(m)?y=l.get(m):y={},Object.assign(y,{[f]:p}),l.set(m,y)})}}),Array.from(l.values())}function Ha(e){return"stackId"in e&&e.stackId!=null&&e.dataKey!=null}var Va=(e,t)=>e===t?!0:e==null||t==null?!1:e[0]===t[0]&&e[1]===t[1];function Ga(e,t){return Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t}function Fx(e,t){if(e.length===t.length){for(var r=0;r{var t=Y(e);return t==="horizontal"?"xAxis":t==="vertical"?"yAxis":t==="centric"?"angleAxis":"radiusAxis"},$r=e=>e.tooltip.settings.axisId;function _o(e){if(e!=null){var t=e.ticks,r=e.bandwidth,n=e.range(),a=[Math.min(...n),Math.max(...n)];return{domain:()=>e.domain(),range:(function(i){function o(){return i.apply(this,arguments)}return o.toString=function(){return i.toString()},o})(()=>a),rangeMin:()=>a[0],rangeMax:()=>a[1],isInRange(i){var o=a[0],l=a[1];return o<=l?i>=o&&i<=l:i>=l&&i<=o},bandwidth:r?()=>r.call(e):void 0,ticks:t?i=>t.call(e,i):void 0,map:(i,o)=>{var l=e(i);if(l!=null){if(e.bandwidth&&o!==null&&o!==void 0&&o.position){var u=e.bandwidth();switch(o.position){case"middle":l+=u/2;break;case"end":l+=u;break}}return l}}}}}var pv=(e,t)=>{if(t!=null)switch(e){case"linear":{if(!ot(t)){for(var r,n,a=0;an)&&(n=i))}return r!==void 0&&n!==void 0?[r,n]:void 0}return t}default:return t}};function $t(e,t){return e==null||t==null?NaN:et?1:e>=t?0:NaN}function Ux(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function No(e){let t,r,n;e.length!==2?(t=$t,r=(l,u)=>$t(e(l),u),n=(l,u)=>e(l)-u):(t=e===$t||e===Ux?e:Hx,r=e,n=e);function a(l,u,c=0,s=l.length){if(c>>1;r(l[f],u)<0?c=f+1:s=f}while(c>>1;r(l[f],u)<=0?c=f+1:s=f}while(cc&&n(l[f-1],u)>-n(l[f],u)?f-1:f}return{left:a,center:o,right:i}}function Hx(){return 0}function yv(e){return e===null?NaN:+e}function*Vx(e,t){for(let r of e)r!=null&&(r=+r)>=r&&(yield r)}const Gx=No($t),An=Gx.right;No(yv).center;function Yx(e=$t){if(e===$t)return gv;if(typeof e!="function")throw new TypeError("compare is not a function");return(t,r)=>{const n=e(t,r);return n||n===0?n:(e(r,r)===0)-(e(t,t)===0)}}function gv(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et?1:0)}const qx=Math.sqrt(50),Xx=Math.sqrt(10),Zx=Math.sqrt(2);function ia(e,t,r){const n=(t-e)/Math.max(0,r),a=Math.floor(Math.log10(n)),i=n/Math.pow(10,a),o=i>=qx?10:i>=Xx?5:i>=Zx?2:1;let l,u,c;return a<0?(c=Math.pow(10,-a)/o,l=Math.round(e*c),u=Math.round(t*c),l/ct&&--u,c=-c):(c=Math.pow(10,a)*o,l=Math.round(e/c),u=Math.round(t/c),l*ct&&--u),u0))return[];if(e===t)return[e];const n=t=a))return[];const l=i-a+1,u=new Array(l);if(n)if(o<0)for(let c=0;c=n)&&(r=n);return r}function Dc(e,t){let r;for(const n of e)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function bv(e,t,r=0,n=1/0,a){if(t=Math.floor(t),r=Math.floor(Math.max(0,r)),n=Math.floor(Math.min(e.length-1,n)),!(r<=t&&t<=n))return e;for(a=a===void 0?gv:Yx(a);n>r;){if(n-r>600){const u=n-r+1,c=t-r+1,s=Math.log(u),f=.5*Math.exp(2*s/3),v=.5*Math.sqrt(s*f*(u-f)/u)*(c-u/2<0?-1:1),h=Math.max(r,Math.floor(t-c*f/u+v)),m=Math.min(n,Math.floor(t+(u-c)*f/u+v));bv(e,t,h,m,a)}const i=e[t];let o=r,l=n;for(Hr(e,r,t),a(e[n],i)>0&&Hr(e,r,n);o0;)--l}a(e[r],i)===0?Hr(e,r,l):(++l,Hr(e,l,n)),l<=t&&(r=l+1),t<=l&&(n=l-1)}return e}function Hr(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function Qx(e,t,r){if(e=Float64Array.from(Vx(e)),!(!(n=e.length)||isNaN(t=+t))){if(t<=0||n<2)return Dc(e);if(t>=1)return Mc(e);var n,a=(n-1)*t,i=Math.floor(a),o=Mc(bv(e,i).subarray(0,i+1)),l=Dc(e.subarray(i+1));return o+(l-o)*(a-i)}}function Jx(e,t,r=yv){if(!(!(n=e.length)||isNaN(t=+t))){if(t<=0||n<2)return+r(e[0],0,e);if(t>=1)return+r(e[n-1],n-1,e);var n,a=(n-1)*t,i=Math.floor(a),o=+r(e[i],i,e),l=+r(e[i+1],i+1,e);return o+(l-o)*(a-i)}}function ew(e,t,r){e=+e,t=+t,r=(a=arguments.length)<2?(t=e,e=0,1):a<3?1:+r;for(var n=-1,a=Math.max(0,Math.ceil((t-e)/r))|0,i=new Array(a);++n>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?_n(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?_n(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=nw.exec(e))?new Ne(t[1],t[2],t[3],1):(t=aw.exec(e))?new Ne(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=iw.exec(e))?_n(t[1],t[2],t[3],t[4]):(t=ow.exec(e))?_n(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=lw.exec(e))?Kc(t[1],t[2]/100,t[3]/100,1):(t=uw.exec(e))?Kc(t[1],t[2]/100,t[3]/100,t[4]):_c.hasOwnProperty(e)?Rc(_c[e]):e==="transparent"?new Ne(NaN,NaN,NaN,0):null}function Rc(e){return new Ne(e>>16&255,e>>8&255,e&255,1)}function _n(e,t,r,n){return n<=0&&(e=t=r=NaN),new Ne(e,t,r,n)}function fw(e){return e instanceof Pn||(e=un(e)),e?(e=e.rgb(),new Ne(e.r,e.g,e.b,e.opacity)):new Ne}function Yi(e,t,r,n){return arguments.length===1?fw(e):new Ne(e,t,r,n??1)}function Ne(e,t,r,n){this.r=+e,this.g=+t,this.b=+r,this.opacity=+n}Bo(Ne,Yi,wv(Pn,{brighter(e){return e=e==null?oa:Math.pow(oa,e),new Ne(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?on:Math.pow(on,e),new Ne(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ne(Zt(this.r),Zt(this.g),Zt(this.b),la(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Bc,formatHex:Bc,formatHex8:dw,formatRgb:zc,toString:zc}));function Bc(){return`#${Yt(this.r)}${Yt(this.g)}${Yt(this.b)}`}function dw(){return`#${Yt(this.r)}${Yt(this.g)}${Yt(this.b)}${Yt((isNaN(this.opacity)?1:this.opacity)*255)}`}function zc(){const e=la(this.opacity);return`${e===1?"rgb(":"rgba("}${Zt(this.r)}, ${Zt(this.g)}, ${Zt(this.b)}${e===1?")":`, ${e})`}`}function la(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Zt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Yt(e){return e=Zt(e),(e<16?"0":"")+e.toString(16)}function Kc(e,t,r,n){return n<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new Ze(e,t,r,n)}function Av(e){if(e instanceof Ze)return new Ze(e.h,e.s,e.l,e.opacity);if(e instanceof Pn||(e=un(e)),!e)return new Ze;if(e instanceof Ze)return e;e=e.rgb();var t=e.r/255,r=e.g/255,n=e.b/255,a=Math.min(t,r,n),i=Math.max(t,r,n),o=NaN,l=i-a,u=(i+a)/2;return l?(t===i?o=(r-n)/l+(r0&&u<1?0:o,new Ze(o,l,u,e.opacity)}function vw(e,t,r,n){return arguments.length===1?Av(e):new Ze(e,t,r,n??1)}function Ze(e,t,r,n){this.h=+e,this.s=+t,this.l=+r,this.opacity=+n}Bo(Ze,vw,wv(Pn,{brighter(e){return e=e==null?oa:Math.pow(oa,e),new Ze(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?on:Math.pow(on,e),new Ze(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*t,a=2*r-n;return new Ne(yi(e>=240?e-240:e+120,a,n),yi(e,a,n),yi(e<120?e+240:e-120,a,n),this.opacity)},clamp(){return new Ze(Wc(this.h),Nn(this.s),Nn(this.l),la(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=la(this.opacity);return`${e===1?"hsl(":"hsla("}${Wc(this.h)}, ${Nn(this.s)*100}%, ${Nn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Wc(e){return e=(e||0)%360,e<0?e+360:e}function Nn(e){return Math.max(0,Math.min(1,e||0))}function yi(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}const zo=e=>()=>e;function hw(e,t){return function(r){return e+r*t}}function mw(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(n){return Math.pow(e+n*t,r)}}function pw(e){return(e=+e)==1?Pv:function(t,r){return r-t?mw(t,r,e):zo(isNaN(t)?r:t)}}function Pv(e,t){var r=t-e;return r?hw(e,r):zo(isNaN(e)?t:e)}const Fc=(function e(t){var r=pw(t);function n(a,i){var o=r((a=Yi(a)).r,(i=Yi(i)).r),l=r(a.g,i.g),u=r(a.b,i.b),c=Pv(a.opacity,i.opacity);return function(s){return a.r=o(s),a.g=l(s),a.b=u(s),a.opacity=c(s),a+""}}return n.gamma=e,n})(1);function yw(e,t){t||(t=[]);var r=e?Math.min(t.length,e.length):0,n=t.slice(),a;return function(i){for(a=0;ar&&(i=t.slice(r,i),l[o]?l[o]+=i:l[++o]=i),(n=n[0])===(a=a[0])?l[o]?l[o]+=a:l[++o]=a:(l[++o]=null,u.push({i:o,x:ua(n,a)})),r=gi.lastIndex;return rt&&(r=e,e=t,t=r),function(n){return Math.max(e,Math.min(t,n))}}function kw(e,t,r){var n=e[0],a=e[1],i=t[0],o=t[1];return a2?jw:kw,u=c=null,f}function f(v){return v==null||isNaN(v=+v)?i:(u||(u=l(e.map(n),t,r)))(n(o(v)))}return f.invert=function(v){return o(a((c||(c=l(t,e.map(n),ua)))(v)))},f.domain=function(v){return arguments.length?(e=Array.from(v,ca),s()):e.slice()},f.range=function(v){return arguments.length?(t=Array.from(v),s()):t.slice()},f.rangeRound=function(v){return t=Array.from(v),r=Ko,s()},f.clamp=function(v){return arguments.length?(o=v?!0:De,s()):o!==De},f.interpolate=function(v){return arguments.length?(r=v,s()):r},f.unknown=function(v){return arguments.length?(i=v,f):i},function(v,h){return n=v,a=h,s()}}function Wo(){return Ya()(De,De)}function Cw(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function sa(e,t){if(!isFinite(e)||e===0)return null;var r=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"),n=e.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+e.slice(r+1)]}function Or(e){return e=sa(Math.abs(e)),e?e[1]:NaN}function Tw(e,t){return function(r,n){for(var a=r.length,i=[],o=0,l=e[0],u=0;a>0&&l>0&&(u+l+1>n&&(l=Math.max(1,n-u)),i.push(r.substring(a-=l,a+l)),!((u+=l+1)>n));)l=e[o=(o+1)%e.length];return i.reverse().join(t)}}function $w(e){return function(t){return t.replace(/[0-9]/g,function(r){return e[+r]})}}var Mw=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function cn(e){if(!(t=Mw.exec(e)))throw new Error("invalid format: "+e);var t;return new Fo({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}cn.prototype=Fo.prototype;function Fo(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}Fo.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Dw(e){e:for(var t=e.length,r=1,n=-1,a;r0&&(n=0);break}return n>0?e.slice(0,n)+e.slice(a+1):e}var fa;function _w(e,t){var r=sa(e,t);if(!r)return fa=void 0,e.toPrecision(t);var n=r[0],a=r[1],i=a-(fa=Math.max(-8,Math.min(8,Math.floor(a/3)))*3)+1,o=n.length;return i===o?n:i>o?n+new Array(i-o+1).join("0"):i>0?n.slice(0,i)+"."+n.slice(i):"0."+new Array(1-i).join("0")+sa(e,Math.max(0,t+i-1))[0]}function Hc(e,t){var r=sa(e,t);if(!r)return e+"";var n=r[0],a=r[1];return a<0?"0."+new Array(-a).join("0")+n:n.length>a+1?n.slice(0,a+1)+"."+n.slice(a+1):n+new Array(a-n.length+2).join("0")}const Vc={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:Cw,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>Hc(e*100,t),r:Hc,s:_w,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function Gc(e){return e}var Yc=Array.prototype.map,qc=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Nw(e){var t=e.grouping===void 0||e.thousands===void 0?Gc:Tw(Yc.call(e.grouping,Number),e.thousands+""),r=e.currency===void 0?"":e.currency[0]+"",n=e.currency===void 0?"":e.currency[1]+"",a=e.decimal===void 0?".":e.decimal+"",i=e.numerals===void 0?Gc:$w(Yc.call(e.numerals,String)),o=e.percent===void 0?"%":e.percent+"",l=e.minus===void 0?"−":e.minus+"",u=e.nan===void 0?"NaN":e.nan+"";function c(f,v){f=cn(f);var h=f.fill,m=f.align,p=f.sign,y=f.symbol,g=f.zero,x=f.width,A=f.comma,w=f.precision,O=f.trim,b=f.type;b==="n"?(A=!0,b="g"):Vc[b]||(w===void 0&&(w=12),O=!0,b="g"),(g||h==="0"&&m==="=")&&(g=!0,h="0",m="=");var S=(v&&v.prefix!==void 0?v.prefix:"")+(y==="$"?r:y==="#"&&/[boxX]/.test(b)?"0"+b.toLowerCase():""),I=(y==="$"?n:/[%p]/.test(b)?o:"")+(v&&v.suffix!==void 0?v.suffix:""),k=Vc[b],E=/[defgprs%]/.test(b);w=w===void 0?6:/[gprs]/.test(b)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function T(j){var N=S,_=I,R,W,F;if(b==="c")_=k(j)+_,j="";else{j=+j;var L=j<0||1/j<0;if(j=isNaN(j)?u:k(Math.abs(j),w),O&&(j=Dw(j)),L&&+j==0&&p!=="+"&&(L=!1),N=(L?p==="("?p:l:p==="-"||p==="("?"":p)+N,_=(b==="s"&&!isNaN(j)&&fa!==void 0?qc[8+fa/3]:"")+_+(L&&p==="("?")":""),E){for(R=-1,W=j.length;++RF||F>57){_=(F===46?a+j.slice(R+1):j.slice(R))+_,j=j.slice(0,R);break}}}A&&!g&&(j=t(j,1/0));var V=N.length+j.length+_.length,K=V>1)+N+j+_+K.slice(V);break;default:j=K+N+j+_;break}return i(j)}return T.toString=function(){return f+""},T}function s(f,v){var h=Math.max(-8,Math.min(8,Math.floor(Or(v)/3)))*3,m=Math.pow(10,-h),p=c((f=cn(f),f.type="f",f),{suffix:qc[8+h/3]});return function(y){return p(m*y)}}return{format:c,formatPrefix:s}}var Ln,Uo,Ov;Lw({thousands:",",grouping:[3],currency:["$",""]});function Lw(e){return Ln=Nw(e),Uo=Ln.format,Ov=Ln.formatPrefix,Ln}function Rw(e){return Math.max(0,-Or(Math.abs(e)))}function Bw(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Or(t)/3)))*3-Or(Math.abs(e)))}function zw(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,Or(t)-Or(e))+1}function Sv(e,t,r,n){var a=Vi(e,t,r),i;switch(n=cn(n??",f"),n.type){case"s":{var o=Math.max(Math.abs(e),Math.abs(t));return n.precision==null&&!isNaN(i=Bw(a,o))&&(n.precision=i),Ov(n,o)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(i=zw(a,Math.max(Math.abs(e),Math.abs(t))))&&(n.precision=i-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(i=Rw(a))&&(n.precision=i-(n.type==="%")*2);break}}return Uo(n)}function Rt(e){var t=e.domain;return e.ticks=function(r){var n=t();return Ui(n[0],n[n.length-1],r??10)},e.tickFormat=function(r,n){var a=t();return Sv(a[0],a[a.length-1],r??10,n)},e.nice=function(r){r==null&&(r=10);var n=t(),a=0,i=n.length-1,o=n[a],l=n[i],u,c,s=10;for(l0;){if(c=Hi(o,l,r),c===u)return n[a]=o,n[i]=l,t(n);if(c>0)o=Math.floor(o/c)*c,l=Math.ceil(l/c)*c;else if(c<0)o=Math.ceil(o*c)/c,l=Math.floor(l*c)/c;else break;u=c}return e},e}function Iv(){var e=Wo();return e.copy=function(){return On(e,Iv())},Ge.apply(e,arguments),Rt(e)}function Ev(e){var t;function r(n){return n==null||isNaN(n=+n)?t:n}return r.invert=r,r.domain=r.range=function(n){return arguments.length?(e=Array.from(n,ca),r):e.slice()},r.unknown=function(n){return arguments.length?(t=n,r):t},r.copy=function(){return Ev(e).unknown(t)},e=arguments.length?Array.from(e,ca):[0,1],Rt(r)}function kv(e,t){e=e.slice();var r=0,n=e.length-1,a=e[r],i=e[n],o;return iMath.pow(e,t)}function Hw(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function Qc(e){return(t,r)=>-e(-t,r)}function Ho(e){const t=e(Xc,Zc),r=t.domain;let n=10,a,i;function o(){return a=Hw(n),i=Uw(n),r()[0]<0?(a=Qc(a),i=Qc(i),e(Kw,Ww)):e(Xc,Zc),t}return t.base=function(l){return arguments.length?(n=+l,o()):n},t.domain=function(l){return arguments.length?(r(l),o()):r()},t.ticks=l=>{const u=r();let c=u[0],s=u[u.length-1];const f=s0){for(;v<=h;++v)for(m=1;ms)break;g.push(p)}}else for(;v<=h;++v)for(m=n-1;m>=1;--m)if(p=v>0?m/i(-v):m*i(v),!(ps)break;g.push(p)}g.length*2{if(l==null&&(l=10),u==null&&(u=n===10?"s":","),typeof u!="function"&&(!(n%1)&&(u=cn(u)).precision==null&&(u.trim=!0),u=Uo(u)),l===1/0)return u;const c=Math.max(1,n*l/t.ticks().length);return s=>{let f=s/i(Math.round(a(s)));return f*nr(kv(r(),{floor:l=>i(Math.floor(a(l))),ceil:l=>i(Math.ceil(a(l)))})),t}function jv(){const e=Ho(Ya()).domain([1,10]);return e.copy=()=>On(e,jv()).base(e.base()),Ge.apply(e,arguments),e}function Jc(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function es(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function Vo(e){var t=1,r=e(Jc(t),es(t));return r.constant=function(n){return arguments.length?e(Jc(t=+n),es(t)):t},Rt(r)}function Cv(){var e=Vo(Ya());return e.copy=function(){return On(e,Cv()).constant(e.constant())},Ge.apply(e,arguments)}function ts(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function Vw(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function Gw(e){return e<0?-e*e:e*e}function Go(e){var t=e(De,De),r=1;function n(){return r===1?e(De,De):r===.5?e(Vw,Gw):e(ts(r),ts(1/r))}return t.exponent=function(a){return arguments.length?(r=+a,n()):r},Rt(t)}function Yo(){var e=Go(Ya());return e.copy=function(){return On(e,Yo()).exponent(e.exponent())},Ge.apply(e,arguments),e}function Yw(){return Yo.apply(null,arguments).exponent(.5)}function rs(e){return Math.sign(e)*e*e}function qw(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function Tv(){var e=Wo(),t=[0,1],r=!1,n;function a(i){var o=qw(e(i));return isNaN(o)?n:r?Math.round(o):o}return a.invert=function(i){return e.invert(rs(i))},a.domain=function(i){return arguments.length?(e.domain(i),a):e.domain()},a.range=function(i){return arguments.length?(e.range((t=Array.from(i,ca)).map(rs)),a):t.slice()},a.rangeRound=function(i){return a.range(i).round(!0)},a.round=function(i){return arguments.length?(r=!!i,a):r},a.clamp=function(i){return arguments.length?(e.clamp(i),a):e.clamp()},a.unknown=function(i){return arguments.length?(n=i,a):n},a.copy=function(){return Tv(e.domain(),t).round(r).clamp(e.clamp()).unknown(n)},Ge.apply(a,arguments),Rt(a)}function $v(){var e=[],t=[],r=[],n;function a(){var o=0,l=Math.max(1,t.length);for(r=new Array(l-1);++o0?r[l-1]:e[0],l=r?[n[r-1],t]:[n[c-1],n[c]]},o.unknown=function(u){return arguments.length&&(i=u),o},o.thresholds=function(){return n.slice()},o.copy=function(){return Mv().domain([e,t]).range(a).unknown(i)},Ge.apply(Rt(o),arguments)}function Dv(){var e=[.5],t=[0,1],r,n=1;function a(i){return i!=null&&i<=i?t[An(e,i,0,n)]:r}return a.domain=function(i){return arguments.length?(e=Array.from(i),n=Math.min(e.length,t.length-1),a):e.slice()},a.range=function(i){return arguments.length?(t=Array.from(i),n=Math.min(e.length,t.length-1),a):t.slice()},a.invertExtent=function(i){var o=t.indexOf(i);return[e[o-1],e[o]]},a.unknown=function(i){return arguments.length?(r=i,a):r},a.copy=function(){return Dv().domain(e).range(t).unknown(r)},Ge.apply(a,arguments)}const bi=new Date,xi=new Date;function be(e,t,r,n){function a(i){return e(i=arguments.length===0?new Date:new Date(+i)),i}return a.floor=i=>(e(i=new Date(+i)),i),a.ceil=i=>(e(i=new Date(i-1)),t(i,1),e(i),i),a.round=i=>{const o=a(i),l=a.ceil(i);return i-o(t(i=new Date(+i),o==null?1:Math.floor(o)),i),a.range=(i,o,l)=>{const u=[];if(i=a.ceil(i),l=l==null?1:Math.floor(l),!(i0))return u;let c;do u.push(c=new Date(+i)),t(i,l),e(i);while(cbe(o=>{if(o>=o)for(;e(o),!i(o);)o.setTime(o-1)},(o,l)=>{if(o>=o)if(l<0)for(;++l<=0;)for(;t(o,-1),!i(o););else for(;--l>=0;)for(;t(o,1),!i(o););}),r&&(a.count=(i,o)=>(bi.setTime(+i),xi.setTime(+o),e(bi),e(xi),Math.floor(r(bi,xi))),a.every=i=>(i=Math.floor(i),!isFinite(i)||!(i>0)?null:i>1?a.filter(n?o=>n(o)%i===0:o=>a.count(0,o)%i===0):a)),a}const da=be(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);da.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?be(t=>{t.setTime(Math.floor(t/e)*e)},(t,r)=>{t.setTime(+t+r*e)},(t,r)=>(r-t)/e):da);da.range;const pt=1e3,Ve=pt*60,yt=Ve*60,bt=yt*24,qo=bt*7,ns=bt*30,wi=bt*365,qt=be(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*pt)},(e,t)=>(t-e)/pt,e=>e.getUTCSeconds());qt.range;const Xo=be(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*pt)},(e,t)=>{e.setTime(+e+t*Ve)},(e,t)=>(t-e)/Ve,e=>e.getMinutes());Xo.range;const Zo=be(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*Ve)},(e,t)=>(t-e)/Ve,e=>e.getUTCMinutes());Zo.range;const Qo=be(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*pt-e.getMinutes()*Ve)},(e,t)=>{e.setTime(+e+t*yt)},(e,t)=>(t-e)/yt,e=>e.getHours());Qo.range;const Jo=be(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*yt)},(e,t)=>(t-e)/yt,e=>e.getUTCHours());Jo.range;const Sn=be(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Ve)/bt,e=>e.getDate()-1);Sn.range;const qa=be(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/bt,e=>e.getUTCDate()-1);qa.range;const _v=be(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/bt,e=>Math.floor(e/bt));_v.range;function ur(e){return be(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(t,r)=>{t.setDate(t.getDate()+r*7)},(t,r)=>(r-t-(r.getTimezoneOffset()-t.getTimezoneOffset())*Ve)/qo)}const Xa=ur(0),va=ur(1),Xw=ur(2),Zw=ur(3),Sr=ur(4),Qw=ur(5),Jw=ur(6);Xa.range;va.range;Xw.range;Zw.range;Sr.range;Qw.range;Jw.range;function cr(e){return be(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(t,r)=>{t.setUTCDate(t.getUTCDate()+r*7)},(t,r)=>(r-t)/qo)}const Za=cr(0),ha=cr(1),eA=cr(2),tA=cr(3),Ir=cr(4),rA=cr(5),nA=cr(6);Za.range;ha.range;eA.range;tA.range;Ir.range;rA.range;nA.range;const el=be(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());el.range;const tl=be(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());tl.range;const xt=be(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());xt.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:be(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,r)=>{t.setFullYear(t.getFullYear()+r*e)});xt.range;const wt=be(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());wt.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:be(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,r)=>{t.setUTCFullYear(t.getUTCFullYear()+r*e)});wt.range;function Nv(e,t,r,n,a,i){const o=[[qt,1,pt],[qt,5,5*pt],[qt,15,15*pt],[qt,30,30*pt],[i,1,Ve],[i,5,5*Ve],[i,15,15*Ve],[i,30,30*Ve],[a,1,yt],[a,3,3*yt],[a,6,6*yt],[a,12,12*yt],[n,1,bt],[n,2,2*bt],[r,1,qo],[t,1,ns],[t,3,3*ns],[e,1,wi]];function l(c,s,f){const v=sy).right(o,v);if(h===o.length)return e.every(Vi(c/wi,s/wi,f));if(h===0)return da.every(Math.max(Vi(c,s,f),1));const[m,p]=o[v/o[h-1][2]53)return null;"w"in C||(C.w=1),"Z"in C?(J=Pi(Vr(C.y,0,1)),B=J.getUTCDay(),J=B>4||B===0?ha.ceil(J):ha(J),J=qa.offset(J,(C.V-1)*7),C.y=J.getUTCFullYear(),C.m=J.getUTCMonth(),C.d=J.getUTCDate()+(C.w+6)%7):(J=Ai(Vr(C.y,0,1)),B=J.getDay(),J=B>4||B===0?va.ceil(J):va(J),J=Sn.offset(J,(C.V-1)*7),C.y=J.getFullYear(),C.m=J.getMonth(),C.d=J.getDate()+(C.w+6)%7)}else("W"in C||"U"in C)&&("w"in C||(C.w="u"in C?C.u%7:"W"in C?1:0),B="Z"in C?Pi(Vr(C.y,0,1)).getUTCDay():Ai(Vr(C.y,0,1)).getDay(),C.m=0,C.d="W"in C?(C.w+6)%7+C.W*7-(B+5)%7:C.w+C.U*7-(B+6)%7);return"Z"in C?(C.H+=C.Z/100|0,C.M+=C.Z%100,Pi(C)):Ai(C)}}function I(D,U,z,C){for(var Ee=0,J=U.length,B=z.length,ze,Kt;Ee=B)return-1;if(ze=U.charCodeAt(Ee++),ze===37){if(ze=U.charAt(Ee++),Kt=O[ze in as?U.charAt(Ee++):ze],!Kt||(C=Kt(D,z,C))<0)return-1}else if(ze!=z.charCodeAt(C++))return-1}return C}function k(D,U,z){var C=c.exec(U.slice(z));return C?(D.p=s.get(C[0].toLowerCase()),z+C[0].length):-1}function E(D,U,z){var C=h.exec(U.slice(z));return C?(D.w=m.get(C[0].toLowerCase()),z+C[0].length):-1}function T(D,U,z){var C=f.exec(U.slice(z));return C?(D.w=v.get(C[0].toLowerCase()),z+C[0].length):-1}function j(D,U,z){var C=g.exec(U.slice(z));return C?(D.m=x.get(C[0].toLowerCase()),z+C[0].length):-1}function N(D,U,z){var C=p.exec(U.slice(z));return C?(D.m=y.get(C[0].toLowerCase()),z+C[0].length):-1}function _(D,U,z){return I(D,t,U,z)}function R(D,U,z){return I(D,r,U,z)}function W(D,U,z){return I(D,n,U,z)}function F(D){return o[D.getDay()]}function L(D){return i[D.getDay()]}function V(D){return u[D.getMonth()]}function K(D){return l[D.getMonth()]}function le(D){return a[+(D.getHours()>=12)]}function de(D){return 1+~~(D.getMonth()/3)}function ae(D){return o[D.getUTCDay()]}function Me(D){return i[D.getUTCDay()]}function Be(D){return u[D.getUTCMonth()]}function qe(D){return l[D.getUTCMonth()]}function Xe(D){return a[+(D.getUTCHours()>=12)]}function zr(D){return 1+~~(D.getUTCMonth()/3)}return{format:function(D){var U=b(D+="",A);return U.toString=function(){return D},U},parse:function(D){var U=S(D+="",!1);return U.toString=function(){return D},U},utcFormat:function(D){var U=b(D+="",w);return U.toString=function(){return D},U},utcParse:function(D){var U=S(D+="",!0);return U.toString=function(){return D},U}}}var as={"-":"",_:" ",0:"0"},Oe=/^\s*\d+/,cA=/^%/,sA=/[\\^$*+?|[\]().{}]/g;function X(e,t,r){var n=e<0?"-":"",a=(n?-e:e)+"",i=a.length;return n+(i[t.toLowerCase(),r]))}function dA(e,t,r){var n=Oe.exec(t.slice(r,r+1));return n?(e.w=+n[0],r+n[0].length):-1}function vA(e,t,r){var n=Oe.exec(t.slice(r,r+1));return n?(e.u=+n[0],r+n[0].length):-1}function hA(e,t,r){var n=Oe.exec(t.slice(r,r+2));return n?(e.U=+n[0],r+n[0].length):-1}function mA(e,t,r){var n=Oe.exec(t.slice(r,r+2));return n?(e.V=+n[0],r+n[0].length):-1}function pA(e,t,r){var n=Oe.exec(t.slice(r,r+2));return n?(e.W=+n[0],r+n[0].length):-1}function is(e,t,r){var n=Oe.exec(t.slice(r,r+4));return n?(e.y=+n[0],r+n[0].length):-1}function os(e,t,r){var n=Oe.exec(t.slice(r,r+2));return n?(e.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function yA(e,t,r){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(r,r+6));return n?(e.Z=n[1]?0:-(n[2]+(n[3]||"00")),r+n[0].length):-1}function gA(e,t,r){var n=Oe.exec(t.slice(r,r+1));return n?(e.q=n[0]*3-3,r+n[0].length):-1}function bA(e,t,r){var n=Oe.exec(t.slice(r,r+2));return n?(e.m=n[0]-1,r+n[0].length):-1}function ls(e,t,r){var n=Oe.exec(t.slice(r,r+2));return n?(e.d=+n[0],r+n[0].length):-1}function xA(e,t,r){var n=Oe.exec(t.slice(r,r+3));return n?(e.m=0,e.d=+n[0],r+n[0].length):-1}function us(e,t,r){var n=Oe.exec(t.slice(r,r+2));return n?(e.H=+n[0],r+n[0].length):-1}function wA(e,t,r){var n=Oe.exec(t.slice(r,r+2));return n?(e.M=+n[0],r+n[0].length):-1}function AA(e,t,r){var n=Oe.exec(t.slice(r,r+2));return n?(e.S=+n[0],r+n[0].length):-1}function PA(e,t,r){var n=Oe.exec(t.slice(r,r+3));return n?(e.L=+n[0],r+n[0].length):-1}function OA(e,t,r){var n=Oe.exec(t.slice(r,r+6));return n?(e.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function SA(e,t,r){var n=cA.exec(t.slice(r,r+1));return n?r+n[0].length:-1}function IA(e,t,r){var n=Oe.exec(t.slice(r));return n?(e.Q=+n[0],r+n[0].length):-1}function EA(e,t,r){var n=Oe.exec(t.slice(r));return n?(e.s=+n[0],r+n[0].length):-1}function cs(e,t){return X(e.getDate(),t,2)}function kA(e,t){return X(e.getHours(),t,2)}function jA(e,t){return X(e.getHours()%12||12,t,2)}function CA(e,t){return X(1+Sn.count(xt(e),e),t,3)}function Lv(e,t){return X(e.getMilliseconds(),t,3)}function TA(e,t){return Lv(e,t)+"000"}function $A(e,t){return X(e.getMonth()+1,t,2)}function MA(e,t){return X(e.getMinutes(),t,2)}function DA(e,t){return X(e.getSeconds(),t,2)}function _A(e){var t=e.getDay();return t===0?7:t}function NA(e,t){return X(Xa.count(xt(e)-1,e),t,2)}function Rv(e){var t=e.getDay();return t>=4||t===0?Sr(e):Sr.ceil(e)}function LA(e,t){return e=Rv(e),X(Sr.count(xt(e),e)+(xt(e).getDay()===4),t,2)}function RA(e){return e.getDay()}function BA(e,t){return X(va.count(xt(e)-1,e),t,2)}function zA(e,t){return X(e.getFullYear()%100,t,2)}function KA(e,t){return e=Rv(e),X(e.getFullYear()%100,t,2)}function WA(e,t){return X(e.getFullYear()%1e4,t,4)}function FA(e,t){var r=e.getDay();return e=r>=4||r===0?Sr(e):Sr.ceil(e),X(e.getFullYear()%1e4,t,4)}function UA(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+X(t/60|0,"0",2)+X(t%60,"0",2)}function ss(e,t){return X(e.getUTCDate(),t,2)}function HA(e,t){return X(e.getUTCHours(),t,2)}function VA(e,t){return X(e.getUTCHours()%12||12,t,2)}function GA(e,t){return X(1+qa.count(wt(e),e),t,3)}function Bv(e,t){return X(e.getUTCMilliseconds(),t,3)}function YA(e,t){return Bv(e,t)+"000"}function qA(e,t){return X(e.getUTCMonth()+1,t,2)}function XA(e,t){return X(e.getUTCMinutes(),t,2)}function ZA(e,t){return X(e.getUTCSeconds(),t,2)}function QA(e){var t=e.getUTCDay();return t===0?7:t}function JA(e,t){return X(Za.count(wt(e)-1,e),t,2)}function zv(e){var t=e.getUTCDay();return t>=4||t===0?Ir(e):Ir.ceil(e)}function eP(e,t){return e=zv(e),X(Ir.count(wt(e),e)+(wt(e).getUTCDay()===4),t,2)}function tP(e){return e.getUTCDay()}function rP(e,t){return X(ha.count(wt(e)-1,e),t,2)}function nP(e,t){return X(e.getUTCFullYear()%100,t,2)}function aP(e,t){return e=zv(e),X(e.getUTCFullYear()%100,t,2)}function iP(e,t){return X(e.getUTCFullYear()%1e4,t,4)}function oP(e,t){var r=e.getUTCDay();return e=r>=4||r===0?Ir(e):Ir.ceil(e),X(e.getUTCFullYear()%1e4,t,4)}function lP(){return"+0000"}function fs(){return"%"}function ds(e){return+e}function vs(e){return Math.floor(+e/1e3)}var vr,Kv,Wv;uP({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function uP(e){return vr=uA(e),Kv=vr.format,vr.parse,Wv=vr.utcFormat,vr.utcParse,vr}function cP(e){return new Date(e)}function sP(e){return e instanceof Date?+e:+new Date(+e)}function rl(e,t,r,n,a,i,o,l,u,c){var s=Wo(),f=s.invert,v=s.domain,h=c(".%L"),m=c(":%S"),p=c("%I:%M"),y=c("%I %p"),g=c("%a %d"),x=c("%b %d"),A=c("%B"),w=c("%Y");function O(b){return(u(b)t(a/(e.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(a,i)=>Qx(e,i/n))},r.copy=function(){return Vv(t).domain(e)},Ot.apply(r,arguments)}function Ja(){var e=0,t=.5,r=1,n=1,a,i,o,l,u,c=De,s,f=!1,v;function h(p){return isNaN(p=+p)?v:(p=.5+((p=+s(p))-i)*(n*p{if(e!=null){var n=e.scale,a=e.type;if(n==="auto")return a==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!t)?"point":a==="category"?"band":"linear";if(typeof n=="string")return yP(n)?n:"point"}};function gP(e,t){for(var r=0,n=e.length,a=e[0]t)?r=i+1:n=i}return r}function Qv(e,t){if(e){var r=t??e.domain(),n=r.map(i=>{var o;return(o=e(i))!==null&&o!==void 0?o:0}),a=e.range();if(!(r.length===0||a.length<2))return i=>{var o,l,u=gP(n,i);if(u<=0)return r[0];if(u>=r.length)return r[r.length-1];var c=(o=n[u-1])!==null&&o!==void 0?o:0,s=(l=n[u])!==null&&l!==void 0?l:0;return Math.abs(i-c)<=Math.abs(i-s)?r[u-1]:r[u]}}}function bP(e){if(e!=null)return"invert"in e&&typeof e.invert=="function"?e.invert.bind(e):Qv(e,void 0)}function ms(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function ma(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=Array(t);re.cartesianAxis.xAxis[t],St=(e,t)=>{var r=eh(e,t);return r??me},pe={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:Zi,hide:!0,id:0,includeHidden:!1,interval:"preserveEnd",minTickGap:5,mirror:!1,name:void 0,orientation:"left",padding:{top:0,bottom:0},reversed:!1,scale:"auto",tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:"number",unit:void 0,niceTicks:"auto",width:mn},th=(e,t)=>e.cartesianAxis.yAxis[t],It=(e,t)=>{var r=th(e,t);return r??pe},EP={domain:[0,"auto"],includeHidden:!1,reversed:!1,allowDataOverflow:!1,allowDuplicatedCategory:!1,dataKey:void 0,id:0,name:"",range:[64,64],scale:"auto",type:"number",unit:""},ol=(e,t)=>{var r=e.cartesianAxis.zAxis[t];return r??EP},fe=(e,t,r)=>{switch(t){case"xAxis":return St(e,r);case"yAxis":return It(e,r);case"zAxis":return ol(e,r);case"angleAxis":return $o(e,r);case"radiusAxis":return Mo(e,r);default:throw new Error("Unexpected axis type: ".concat(t))}},kP=(e,t,r)=>{switch(t){case"xAxis":return St(e,r);case"yAxis":return It(e,r);default:throw new Error("Unexpected axis type: ".concat(t))}},Dr=(e,t,r)=>{switch(t){case"xAxis":return St(e,r);case"yAxis":return It(e,r);case"angleAxis":return $o(e,r);case"radiusAxis":return Mo(e,r);default:throw new Error("Unexpected axis type: ".concat(t))}},rh=e=>e.graphicalItems.cartesianItems.some(t=>t.type==="bar")||e.graphicalItems.polarItems.some(t=>t.type==="radialBar");function ll(e,t){return r=>{switch(e){case"xAxis":return"xAxisId"in r&&r.xAxisId===t;case"yAxis":return"yAxisId"in r&&r.yAxisId===t;case"zAxis":return"zAxisId"in r&&r.zAxisId===t;case"angleAxis":return"angleAxisId"in r&&r.angleAxisId===t;case"radiusAxis":return"radiusAxisId"in r&&r.radiusAxisId===t;default:return!1}}}var ei=e=>e.graphicalItems.cartesianItems,jP=P([oe,wn],ll),ul=(e,t,r)=>e.filter(r).filter(n=>(t==null?void 0:t.includeHidden)===!0?!0:!n.hide),_r=P([ei,fe,jP],ul,{memoizeOptions:{resultEqualityCheck:Ga}}),nh=P([_r],e=>e.filter(t=>t.type==="area"||t.type==="bar").filter(Ha)),ah=e=>e.filter(t=>!("stackId"in t)||t.stackId===void 0),CP=P([_r],ah),cl=e=>e.map(t=>t.data).filter(Boolean).flat(1),TP=P([_r],e=>e.some(t=>!t.data)),ih=P([_r],cl,{memoizeOptions:{resultEqualityCheck:Ga}}),sl=(e,t)=>{var r=t.chartData,n=r===void 0?[]:r,a=t.dataStartIndex,i=t.dataEndIndex;return e.length>0?e:n.slice(a,i+1)},fl=P([ih,za],sl),oh=(e,t,r)=>(t==null?void 0:t.dataKey)!=null?e.map(n=>({value:Q(n,t.dataKey)})):r.length>0?r.map(n=>n.dataKey).flatMap(n=>e.map(a=>({value:Q(a,n)}))):e.map(n=>({value:n})),lh=(e,t,r,n,a,i)=>{var o=n.chartData,l=o===void 0?[]:o,u=n.dataStartIndex,c=n.dataEndIndex,s=oh(e,t,r);if(a&&(t==null?void 0:t.dataKey)!=null&&i.length>0){var f=l.slice(u,c+1),v=f.map(h=>({value:Q(h,t.dataKey)})).filter(h=>h.value!=null);return[...v,...s]}return s},In=P([fl,fe,_r,za,TP,ih],lh);function wr(e){if(ut(e)||e instanceof Date){var t=Number(e);if(H(t))return t}}function ys(e){if(Array.isArray(e)){var t=[wr(e[0]),wr(e[1])];return ot(t)?t:void 0}var r=wr(e);if(r!=null)return[r,r]}function st(e){return e.map(wr).filter(_e)}function $P(e,t){var r=wr(e),n=wr(t);return r==null&&n==null?0:r==null?-1:n==null?1:r-n}var MP=P([In],e=>e==null?void 0:e.map(t=>t.value).sort($P));function uh(e,t){switch(e){case"xAxis":return t.direction==="x";case"yAxis":return t.direction==="y";default:return!1}}function DP(e,t,r){if(!r)return[];if(!r.length)return[];var n;if(typeof t=="number"&&!Je(t))n=t;else if(Array.isArray(t)){var a=st(t);a.length>0&&(n=Math.max(...a))}return n==null?[]:st(r.flatMap(i=>{var o=Q(e,i.dataKey),l,u;if(Array.isArray(o)){var c=Jv(o,2);l=c[0],u=c[1]}else l=u=o;if(!(!H(l)||!H(u)))return[n-l,n+u]}))}var xe=e=>{var t=Pe(e),r=$r(e);return Dr(e,t,r)},Er=P([xe],e=>e==null?void 0:e.dataKey),_P=P([nh,za,xe],mv),ch=(e,t,r,n)=>{var a={},i=t.reduce((o,l)=>{if(l.stackId==null)return o;var u=o[l.stackId];return u==null&&(u=[]),u.push(l),o[l.stackId]=u,o},a);return Object.fromEntries(Object.entries(i).map(o=>{var l=Jv(o,2),u=l[0],c=l[1],s=n?[...c].reverse():c,f=s.map(Ua);return[u,{stackedData:Pg(e,f,r),graphicalItems:s}]}))},pa=P([_P,nh,xn,uv],ch),sh=(e,t,r,n)=>{var a=t.dataStartIndex,i=t.dataEndIndex;if(n==null&&r!=="zAxis")return Eg(e,a,i)},NP=P([fe],e=>e.allowDataOverflow),dl=e=>{var t;if(e==null||!("domain"in e))return Zi;if(e.domain!=null)return e.domain;if("ticks"in e&&e.ticks!=null){if(e.type==="number"){var r=st(e.ticks);return[Math.min(...r),Math.max(...r)]}if(e.type==="category")return e.ticks.map(String)}return(t=e==null?void 0:e.domain)!==null&&t!==void 0?t:Zi},vl=P([fe],dl),hl=P([vl,NP],ev),LP=P([pa,tt,oe,hl],sh,{memoizeOptions:{resultEqualityCheck:Va}}),ti=e=>e.errorBars,RP=(e,t,r)=>e.flatMap(n=>t[n.id]).filter(Boolean).filter(n=>uh(r,n)),ya=function(){for(var t=arguments.length,r=new Array(t),n=0;n5&&arguments[5]!==void 0?arguments[5]:[],l,u;if(n.length>0&&n.forEach(c=>{var s,f=c.data!=null?[...c.data]:o,v=(s=a[c.id])===null||s===void 0?void 0:s.filter(h=>uh(i,h));f.forEach(h=>{var m,p=Q(h,(m=r.dataKey)!==null&&m!==void 0?m:c.dataKey),y=DP(h,p,v);if(y.length>=2){var g=Math.min(...y),x=Math.max(...y);(l==null||gu)&&(u=x)}var A=ys(p);A!=null&&(l=l==null?A[0]:Math.min(l,A[0]),u=u==null?A[1]:Math.max(u,A[1]))})}),(r==null?void 0:r.dataKey)!=null&&n.length===0&&t.forEach(c=>{var s=ys(Q(c,r.dataKey));s!=null&&(l=l==null?s[0]:Math.min(l,s[0]),u=u==null?s[1]:Math.max(u,s[1]))}),H(l)&&H(u))return[l,u]},BP=P([fl,fe,CP,ti,oe,wx],ml,{memoizeOptions:{resultEqualityCheck:Va}});function zP(e){var t=e.value;if(ut(t)||t instanceof Date)return t}var KP=(e,t,r)=>{var n=e.map(zP).filter(a=>a!=null);return r&&(t.dataKey==null||t.allowDuplicatedCategory&&pd(n))?Xf(0,e.length):t.allowDuplicatedCategory?n:Array.from(new Set(n))},fh=e=>e.referenceElements.dots,Nr=(e,t,r)=>e.filter(n=>n.ifOverflow==="extendDomain").filter(n=>t==="xAxis"?n.xAxisId===r:n.yAxisId===r),WP=P([fh,oe,wn],Nr),dh=e=>e.referenceElements.areas,FP=P([dh,oe,wn],Nr),vh=e=>e.referenceElements.lines,UP=P([vh,oe,wn],Nr),hh=(e,t)=>{if(e!=null){var r=st(e.map(n=>t==="xAxis"?n.x:n.y));if(r.length!==0)return[Math.min(...r),Math.max(...r)]}},HP=P(WP,oe,hh),mh=(e,t)=>{if(e!=null){var r=st(e.flatMap(n=>[t==="xAxis"?n.x1:n.y1,t==="xAxis"?n.x2:n.y2]));if(r.length!==0)return[Math.min(...r),Math.max(...r)]}},VP=P([FP,oe],mh);function GP(e){var t;if(e.x!=null)return st([e.x]);var r=(t=e.segment)===null||t===void 0?void 0:t.map(n=>n.x);return r==null||r.length===0?[]:st(r)}function YP(e){var t;if(e.y!=null)return st([e.y]);var r=(t=e.segment)===null||t===void 0?void 0:t.map(n=>n.y);return r==null||r.length===0?[]:st(r)}var ph=(e,t)=>{if(e!=null){var r=e.flatMap(n=>t==="xAxis"?GP(n):YP(n));if(r.length!==0)return[Math.min(...r),Math.max(...r)]}},qP=P([UP,oe],ph),XP=P(HP,qP,VP,(e,t,r)=>ya(e,r,t)),pl=(e,t,r,n,a,i,o,l)=>{if(r!=null)return r;var u=o==="vertical"&&l==="xAxis"||o==="horizontal"&&l==="yAxis",c=u?ya(n,i,a):ya(i,a);return kx(t,c,e.allowDataOverflow)},ZP=P([fe,vl,hl,LP,BP,XP,Y,oe],pl,{memoizeOptions:{resultEqualityCheck:Va}}),QP=[0,1],yl=(e,t,r,n,a,i,o)=>{if(!((e==null||r==null||r.length===0)&&o===void 0)){var l=e.dataKey,u=e.type,c=ft(t,i);if(c&&l==null){var s;return Xf(0,(s=r==null?void 0:r.length)!==null&&s!==void 0?s:0)}return u==="category"?KP(n,e,c):a==="expand"&&!c?QP:o}},gl=P([fe,Y,fl,In,xn,oe,ZP],yl),zt=P([fe,rh,jo],Zv),bl=(e,t,r)=>{var n=t.niceTicks;if(n!=="none"){var a=dl(t),i=Array.isArray(a)&&(a[0]==="auto"||a[1]==="auto");if((n==="snap125"||n==="adaptive")&&t!=null&&t.tickCount&&ot(e)){if(i)return kc(e,t.tickCount,t.allowDecimals,n);if(t.type==="number")return jc(e,t.tickCount,t.allowDecimals,n)}if(n==="auto"&&r==="linear"&&t!=null&&t.tickCount){if(i&&ot(e))return kc(e,t.tickCount,t.allowDecimals,"adaptive");if(t.type==="number"&&ot(e))return jc(e,t.tickCount,t.allowDecimals,"adaptive")}}},xl=P([gl,Dr,zt],bl),wl=(e,t,r,n)=>{if(n!=="angleAxis"&&(e==null?void 0:e.type)==="number"&&ot(t)&&Array.isArray(r)&&r.length>0){var a,i,o=t[0],l=(a=r[0])!==null&&a!==void 0?a:0,u=t[1],c=(i=r[r.length-1])!==null&&i!==void 0?i:0;return[Math.min(o,l),Math.max(u,c)]}return t},JP=P([fe,gl,xl,oe],wl),eO=P(In,fe,(e,t)=>{if(!(!t||t.type!=="number")){var r=1/0,n=Array.from(st(e.map(f=>f.value))).sort((f,v)=>f-v),a=n[0],i=n[n.length-1];if(a==null||i==null)return 1/0;var o=i-a;if(o===0)return 1/0;for(var l=0;la,(e,t,r,n,a)=>{if(!H(e))return 0;var i=t==="vertical"?n.height:n.width;if(a==="gap")return e*i/2;if(a==="no-gap"){var o=Ce(r,e*i),l=e*i/2;return l-o-(l-o)/i*o}return 0}),tO=(e,t,r)=>{var n=St(e,t);return n==null||typeof n.padding!="string"?0:yh(e,"xAxis",t,r,n.padding)},rO=(e,t,r)=>{var n=It(e,t);return n==null||typeof n.padding!="string"?0:yh(e,"yAxis",t,r,n.padding)},nO=P(St,tO,(e,t)=>{var r,n;if(e==null)return{left:0,right:0};var a=e.padding;return typeof a=="string"?{left:t,right:t}:{left:((r=a.left)!==null&&r!==void 0?r:0)+t,right:((n=a.right)!==null&&n!==void 0?n:0)+t}}),aO=P(It,rO,(e,t)=>{var r,n;if(e==null)return{top:0,bottom:0};var a=e.padding;return typeof a=="string"?{top:t,bottom:t}:{top:((r=a.top)!==null&&r!==void 0?r:0)+t,bottom:((n=a.bottom)!==null&&n!==void 0?n:0)+t}}),gh=P([ge,nO,Ra,La,(e,t,r)=>r],(e,t,r,n,a)=>{var i=n.padding;return a?[i.left,r.width-i.right]:[e.left+t.left,e.left+e.width-t.right]}),bh=P([ge,Y,aO,Ra,La,(e,t,r)=>r],(e,t,r,n,a,i)=>{var o=a.padding;return i?[n.height-o.bottom,o.top]:t==="horizontal"?[e.top+e.height-r.bottom,e.top+r.top]:[e.top+r.top,e.top+e.height-r.bottom]}),En=(e,t,r,n)=>{var a;switch(t){case"xAxis":return gh(e,r,n);case"yAxis":return bh(e,r,n);case"zAxis":return(a=ol(e,r))===null||a===void 0?void 0:a.range;case"angleAxis":return dv(e);case"radiusAxis":return vv(e,r);default:return}},xh=P([fe,En],Ka),iO=P([zt,JP],pv),Al=P([fe,zt,iO,xh],il),wh=(e,t,r,n)=>{if(!(r==null||r.dataKey==null)){var a=r.type,i=r.scale,o=ft(e,n);if(o&&(a==="number"||i!=="auto"))return t.map(l=>l.value)}},Pl=P([Y,In,Dr,oe],wh),ri=P([Al],_o);P([Al],bP);P([Al,MP],Qv);P([_r,ti,oe],RP);function Ah(e,t){return e.idt.id?1:0}var ni=(e,t)=>t,ai=(e,t,r)=>r,oO=P(_a,ni,ai,(e,t,r)=>e.filter(n=>n.orientation===t).filter(n=>n.mirror===r).sort(Ah)),lO=P(Na,ni,ai,(e,t,r)=>e.filter(n=>n.orientation===t).filter(n=>n.mirror===r).sort(Ah)),Ph=(e,t)=>({width:e.width,height:t.height}),uO=(e,t)=>{var r=typeof t.width=="number"?t.width:mn;return{width:r,height:e.height}},Oh=P(ge,St,Ph),cO=(e,t,r)=>{switch(t){case"top":return e.top;case"bottom":return r-e.bottom;default:return 0}},sO=(e,t,r)=>{switch(t){case"left":return e.left;case"right":return r-e.right;default:return 0}},fO=P(Pt,ge,oO,ni,ai,(e,t,r,n,a)=>{var i={},o;return r.forEach(l=>{var u=Ph(t,l);o==null&&(o=cO(t,n,e));var c=n==="top"&&!a||n==="bottom"&&a;i[l.id]=o-Number(c)*u.height,o+=(c?-1:1)*u.height}),i}),dO=P(At,ge,lO,ni,ai,(e,t,r,n,a)=>{var i={},o;return r.forEach(l=>{var u=uO(t,l);o==null&&(o=sO(t,n,e));var c=n==="left"&&!a||n==="right"&&a;i[l.id]=o-Number(c)*u.width,o+=(c?-1:1)*u.width}),i}),vO=(e,t)=>{var r=St(e,t);if(r!=null)return fO(e,r.orientation,r.mirror)},hO=P([ge,St,vO,(e,t)=>t],(e,t,r,n)=>{if(t!=null){var a=r==null?void 0:r[n];return a==null?{x:e.left,y:0}:{x:e.left,y:a}}}),mO=(e,t)=>{var r=It(e,t);if(r!=null)return dO(e,r.orientation,r.mirror)},pO=P([ge,It,mO,(e,t)=>t],(e,t,r,n)=>{if(t!=null){var a=r==null?void 0:r[n];return a==null?{x:0,y:e.top}:{x:a,y:e.top}}}),Sh=P(ge,It,(e,t)=>{var r=typeof t.width=="number"?t.width:mn;return{width:r,height:e.height}}),gs=(e,t,r)=>{switch(t){case"xAxis":return Oh(e,r).width;case"yAxis":return Sh(e,r).height;default:return}},Ih=(e,t,r,n)=>{if(r!=null){var a=r.allowDuplicatedCategory,i=r.type,o=r.dataKey,l=ft(e,n),u=t.map(s=>s.value),c=u.filter(s=>s!=null);if(o&&l&&i==="category"&&a&&pd(c))return u}},Ol=P([Y,In,fe,oe],Ih),bs=P([Y,kP,zt,ri,Ol,Pl,En,xl,oe],(e,t,r,n,a,i,o,l,u)=>{if(t!=null){var c=ft(e,u);return{angle:t.angle,interval:t.interval,minTickGap:t.minTickGap,orientation:t.orientation,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,axisType:u,categoricalDomain:i,duplicateDomain:a,isCategorical:c,niceTicks:l,range:o,realScaleType:r,scale:n}}}),yO=(e,t,r,n,a,i,o,l,u)=>{if(!(t==null||n==null)){var c=ft(e,u),s=t.type,f=t.ticks,v=t.tickCount,h=r==="scaleBand"&&typeof n.bandwidth=="function"?n.bandwidth()/2:2,m=s==="category"&&n.bandwidth?n.bandwidth()/h:0;m=u==="angleAxis"&&i!=null&&i.length>=2?we(i[0]-i[1])*2*m:m;var p=f||a;return p?p.map((y,g)=>{var x=o?o.indexOf(y):y,A=n.map(x);return H(A)?{index:g,coordinate:A+m,value:y,offset:m}:null}).filter(_e):c&&l?l.map((y,g)=>{var x=n.map(y);return H(x)?{coordinate:x+m,value:y,index:g,offset:m}:null}).filter(_e):n.ticks?n.ticks(v).map((y,g)=>{var x=n.map(y);return H(x)?{coordinate:x+m,value:y,index:g,offset:m}:null}).filter(_e):n.domain().map((y,g)=>{var x=n.map(y);return H(x)?{coordinate:x+m,value:o?o[y]:y,index:g,offset:m}:null}).filter(_e)}},Eh=P([Y,Dr,zt,ri,xl,En,Ol,Pl,oe],yO),gO=(e,t,r,n,a,i,o)=>{if(!(t==null||r==null||n==null||n[0]===n[1])){var l=ft(e,o),u=t.tickCount,c=0;return c=o==="angleAxis"&&(n==null?void 0:n.length)>=2?we(n[0]-n[1])*2*c:c,l&&i?i.map((s,f)=>{var v=r.map(s);return H(v)?{coordinate:v+c,value:s,index:f,offset:c}:null}).filter(_e):r.ticks?r.ticks(u).map((s,f)=>{var v=r.map(s);return H(v)?{coordinate:v+c,value:s,index:f,offset:c}:null}).filter(_e):r.domain().map((s,f)=>{var v=r.map(s);return H(v)?{coordinate:v+c,value:a?a[s]:s,index:f,offset:c}:null}).filter(_e)}},Dt=P([Y,Dr,ri,En,Ol,Pl,oe],gO),_t=P(fe,ri,(e,t)=>{if(!(e==null||t==null))return ma(ma({},e),{},{scale:t})}),bO=P([fe,zt,gl,xh],il),xO=P([bO],_o);P((e,t,r)=>ol(e,r),xO,(e,t)=>{if(!(e==null||t==null))return ma(ma({},e),{},{scale:t})});var wO=P([Y,_a,Na],(e,t,r)=>{switch(e){case"horizontal":return t.some(n=>n.reversed)?"right-to-left":"left-to-right";case"vertical":return r.some(n=>n.reversed)?"bottom-to-top":"top-to-bottom";case"centric":case"radial":return"left-to-right";default:return}}),AO=(e,t,r)=>{var n;return(n=e.renderedTicks[t])===null||n===void 0?void 0:n[r]};P([AO],e=>{if(!(!e||e.length===0))return t=>{var r,n=1/0,a=e[0];for(var i of e){var o=Math.abs(i.coordinate-t);oe.options.defaultTooltipEventType,jh=e=>e.options.validateTooltipEventTypes;function Ch(e,t,r){if(e==null)return t;var n=e?"axis":"item";return r==null?t:r.includes(n)?n:t}function kn(e,t){var r=kh(e),n=jh(e);return Ch(t,r,n)}function PO(e){return M(t=>kn(t,e))}var Th=(e,t)=>{var r,n=Number(t);if(!(Je(n)||t==null))return n>=0?e==null||(r=e[n])===null||r===void 0?void 0:r.value:void 0},OO=e=>e.tooltip.settings,Ct={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},SO={itemInteraction:{click:Ct,hover:Ct},axisInteraction:{click:Ct,hover:Ct},keyboardInteraction:Ct,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0,graphicalItemId:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:"hover",axisId:0,active:!1,defaultIndex:void 0}},$h=Te({name:"tooltip",initialState:SO,reducers:{addTooltipEntrySettings:{reducer(e,t){e.tooltipItemPayloads.push(q(t.payload))},prepare:re()},replaceTooltipEntrySettings:{reducer(e,t){var r=t.payload,n=r.prev,a=r.next,i=Qe(e).tooltipItemPayloads.indexOf(q(n));i>-1&&(e.tooltipItemPayloads[i]=q(a))},prepare:re()},removeTooltipEntrySettings:{reducer(e,t){var r=Qe(e).tooltipItemPayloads.indexOf(q(t.payload));r>-1&&e.tooltipItemPayloads.splice(r,1)},prepare:re()},setTooltipSettingsState(e,t){e.settings=t.payload},setActiveMouseOverItemIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.keyboardInteraction.active=!1,e.itemInteraction.hover.active=!0,e.itemInteraction.hover.index=t.payload.activeIndex,e.itemInteraction.hover.dataKey=t.payload.activeDataKey,e.itemInteraction.hover.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.hover.coordinate=t.payload.activeCoordinate},mouseLeaveChart(e){e.itemInteraction.hover.active=!1,e.axisInteraction.hover.active=!1},mouseLeaveItem(e){e.itemInteraction.hover.active=!1},setActiveClickItemIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.itemInteraction.click.active=!0,e.keyboardInteraction.active=!1,e.itemInteraction.click.index=t.payload.activeIndex,e.itemInteraction.click.dataKey=t.payload.activeDataKey,e.itemInteraction.click.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.click.coordinate=t.payload.activeCoordinate},setMouseOverAxisIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.axisInteraction.hover.active=!0,e.keyboardInteraction.active=!1,e.axisInteraction.hover.index=t.payload.activeIndex,e.axisInteraction.hover.dataKey=t.payload.activeDataKey,e.axisInteraction.hover.coordinate=t.payload.activeCoordinate},setMouseClickAxisIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.keyboardInteraction.active=!1,e.axisInteraction.click.active=!0,e.axisInteraction.click.index=t.payload.activeIndex,e.axisInteraction.click.dataKey=t.payload.activeDataKey,e.axisInteraction.click.coordinate=t.payload.activeCoordinate},setSyncInteraction(e,t){e.syncInteraction=t.payload},setKeyboardInteraction(e,t){e.keyboardInteraction.active=t.payload.active,e.keyboardInteraction.index=t.payload.activeIndex,e.keyboardInteraction.coordinate=t.payload.activeCoordinate}}}),Ye=$h.actions,IO=Ye.addTooltipEntrySettings,EO=Ye.replaceTooltipEntrySettings,kO=Ye.removeTooltipEntrySettings,jO=Ye.setTooltipSettingsState,Mh=Ye.setActiveMouseOverItemIndex,CO=Ye.mouseLeaveItem,Dh=Ye.mouseLeaveChart,TO=Ye.setActiveClickItemIndex,_h=Ye.setMouseOverAxisIndex,$O=Ye.setMouseClickAxisIndex,Zr=Ye.setSyncInteraction,ga=Ye.setKeyboardInteraction,MO=$h.reducer;function xs(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Rn(e){for(var t=1;t{if(t==null)return Ct;var a=LO(e,t,r);if(a==null)return Ct;if(a.active)return a;if(e.keyboardInteraction.active)return e.keyboardInteraction;if(e.syncInteraction.active&&e.syncInteraction.index!=null)return e.syncInteraction;var i=e.settings.active===!0;if(RO(a)){if(i)return Rn(Rn({},a),{},{active:!0})}else if(n!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:n,graphicalItemId:void 0};return Rn(Rn({},Ct),{},{coordinate:a.coordinate})};function BO(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(e instanceof Date){var t=e.valueOf();return Number.isFinite(t)?t:void 0}var r=Number(e);return Number.isFinite(r)?r:void 0}function zO(e,t){var r=BO(e),n=t[0],a=t[1];if(r===void 0)return!1;var i=Math.min(n,a),o=Math.max(n,a);return r>=i&&r<=o}function KO(e,t,r){if(r==null||t==null)return!0;var n=Q(e,t);return n==null||!ot(r)?!0:zO(n,r)}var en=(e,t,r,n)=>{var a=e==null?void 0:e.index;if(a==null)return null;var i=Number(a);if(!H(i))return a;var o=0,l=1/0;t.length>0&&(l=t.length-1);var u=Math.max(o,Math.min(i,l)),c=t[u];return c==null||KO(c,r,n)?String(u):null},Lh=(e,t,r,n,a,i,o)=>{if(i!=null){var l=o[0],u=l==null?void 0:l.getPosition(i);if(u!=null)return u;var c=a==null?void 0:a[Number(i)];if(c)switch(r){case"horizontal":return{x:c.coordinate,y:(n.top+t)/2};default:return{x:(n.left+e)/2,y:c.coordinate}}}},Rh=(e,t,r,n)=>{if(t==="axis")return e.tooltipItemPayloads;if(e.tooltipItemPayloads.length===0)return[];var a;if(r==="hover"?a=e.itemInteraction.hover.graphicalItemId:a=e.itemInteraction.click.graphicalItemId,e.syncInteraction.active&&a==null)return e.tooltipItemPayloads;if(a==null&&(n!=null||e.keyboardInteraction.active)){var i=e.tooltipItemPayloads[0];return i!=null?[i]:[]}return e.tooltipItemPayloads.filter(o=>{var l;return((l=o.settings)===null||l===void 0?void 0:l.graphicalItemId)===a})},Bh=e=>e.options.tooltipPayloadSearcher,Lr=e=>e.tooltip;function ws(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function As(e){for(var t=1;te(t)}function Ps(e){if(typeof e=="string")return e}function YO(e){if(!(e==null||typeof e!="object")){var t="name"in e?HO(e.name):void 0,r="unit"in e?VO(e.unit):void 0,n="dataKey"in e?GO(e.dataKey):void 0,a="payload"in e?e.payload:void 0,i="color"in e?Ps(e.color):void 0,o="fill"in e?Ps(e.fill):void 0;return{name:t,unit:r,dataKey:n,payload:a,color:i,fill:o}}}function qO(e,t){return e??t}var zh=(e,t,r,n,a,i,o)=>{if(!(t==null||i==null)){var l=r.chartData,u=r.computedData,c=r.dataStartIndex,s=r.dataEndIndex,f=[];return e.reduce((v,h)=>{var m,p=h.dataDefinedOnItem,y=h.settings,g=qO(p,l),x=Array.isArray(g)?Id(g,c,s):g,A=(m=y==null?void 0:y.dataKey)!==null&&m!==void 0?m:n,w=y==null?void 0:y.nameKey,O;if(n&&Array.isArray(x)&&!Array.isArray(x[0])&&o==="axis"?O=yd(x,n,a):O=i(x,t,u,w),Array.isArray(O))O.forEach(S=>{var I,k,E=YO(S),T=E==null?void 0:E.name,j=E==null?void 0:E.dataKey,N=E==null?void 0:E.payload,_=As(As({},y),{},{name:T,unit:E==null?void 0:E.unit,color:(I=E==null?void 0:E.color)!==null&&I!==void 0?I:y==null?void 0:y.color,fill:(k=E==null?void 0:E.fill)!==null&&k!==void 0?k:y==null?void 0:y.fill});v.push(Eu({tooltipEntrySettings:_,dataKey:j,payload:N,value:Q(N,j),name:T==null?void 0:String(T)}))});else{var b;v.push(Eu({tooltipEntrySettings:y,dataKey:A,payload:O,value:Q(O,A),name:(b=Q(O,w))!==null&&b!==void 0?b:y==null?void 0:y.name}))}return v},f)}},Sl=P([xe,rh,jo],Zv),XO=P([e=>e.graphicalItems.cartesianItems,e=>e.graphicalItems.polarItems],(e,t)=>[...e,...t]),ZO=P([Pe,$r],ll),sr=P([XO,xe,ZO],ul,{memoizeOptions:{resultEqualityCheck:Ga}}),QO=P([sr],e=>e.filter(Ha)),Kh=P([sr],cl,{memoizeOptions:{resultEqualityCheck:Ga}}),JO=P([sr],e=>e.some(t=>!t.data)),rr=P([Kh,tt],sl),e1=P([QO,tt,xe],mv),Il=P([rr,xe,sr,tt,JO,Kh],lh),Wh=P([xe],dl),t1=P([xe],e=>e.allowDataOverflow),Fh=P([Wh,t1],ev),r1=P([sr],e=>e.filter(Ha)),n1=P([e1,r1,xn,uv],ch),a1=P([n1,tt,Pe,Fh],sh),i1=P([sr],ah),o1=P([rr,xe,i1,ti,Pe,Px],ml,{memoizeOptions:{resultEqualityCheck:Va}}),l1=P([fh,Pe,$r],Nr),u1=P([l1,Pe],hh),c1=P([dh,Pe,$r],Nr),s1=P([c1,Pe],mh),f1=P([vh,Pe,$r],Nr),d1=P([f1,Pe],ph),v1=P([u1,d1,s1],ya),h1=P([xe,Wh,Fh,a1,o1,v1,Y,Pe],pl),kr=P([xe,Y,rr,Il,xn,Pe,h1],yl),m1=P([kr,xe,Sl],bl),p1=P([xe,kr,m1,Pe],wl),Uh=e=>{var t=Pe(e),r=$r(e),n=!1;return En(e,t,r,n)},Hh=P([xe,Uh],Ka),y1=P([xe,Sl,p1,Hh],il),Vh=P([y1],_o),g1=P([Y,Il,xe,Pe],Ih),b1=P([Y,Il,xe,Pe],wh),x1=(e,t,r,n,a,i,o,l)=>{if(t){var u=t.type,c=ft(e,l);if(n){var s=r==="scaleBand"&&n.bandwidth?n.bandwidth()/2:2,f=u==="category"&&n.bandwidth?n.bandwidth()/s:0;return f=l==="angleAxis"&&a!=null&&(a==null?void 0:a.length)>=2?we(a[0]-a[1])*2*f:f,c&&o?o.map((v,h)=>{var m=n.map(v);return H(m)?{coordinate:m+f,value:v,index:h,offset:f}:null}).filter(_e):n.domain().map((v,h)=>{var m=n.map(v);return H(m)?{coordinate:m+f,value:i?i[v]:v,index:h,offset:f}:null}).filter(_e)}}},Et=P([Y,xe,Sl,Vh,Uh,g1,b1,Pe],x1),El=P([kh,jh,OO],(e,t,r)=>Ch(r.shared,e,t)),Gh=e=>e.tooltip.settings.trigger,kl=e=>e.tooltip.settings.defaultIndex,jn=P([Lr,El,Gh,kl],Nh),Nt=P([jn,rr,Er,kr],en),Yh=P([Et,Nt],Th),jl=P([jn],e=>{if(e)return e.dataKey}),qh=P([jn],e=>{if(e)return e.graphicalItemId}),Xh=P([Lr,El,Gh,kl],Rh),w1=P([At,Pt,Y,ge,Et,kl,Xh],Lh),A1=P([jn,w1],(e,t)=>e!=null&&e.coordinate?e.coordinate:t),P1=P([jn],e=>{var t;return(t=e==null?void 0:e.active)!==null&&t!==void 0?t:!1}),O1=P([Xh,Nt,tt,Er,Yh,Bh,El],zh),S1=P([O1],e=>{if(e!=null){var t=e.map(r=>r.payload).filter(r=>r!=null);return Array.from(new Set(t))}});function Os(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Ss(e){for(var t=1;tM(xe),C1=()=>{var e=j1(),t=M(Et),r=M(Vh);return Ar(!e||!r?void 0:Ss(Ss({},e),{},{scale:r}),t)};function Is(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function hr(e){for(var t=1;t{var a=t.find(i=>i&&i.index===r);if(a){if(e==="horizontal")return{x:a.coordinate,y:n.relativeY};if(e==="vertical")return{x:n.relativeX,y:a.coordinate}}return{x:0,y:0}},_1=(e,t,r,n)=>{var a=t.find(c=>c&&c.index===r);if(a){if(e==="centric"){var i=a.coordinate,o=n.radius;return hr(hr(hr({},n),ve(n.cx,n.cy,o,i)),{},{angle:i,radius:o})}var l=a.coordinate,u=n.angle;return hr(hr(hr({},n),ve(n.cx,n.cy,l,u)),{},{angle:u,radius:l})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function N1(e,t){var r=e.relativeX,n=e.relativeY;return r>=t.left&&r<=t.left+t.width&&n>=t.top&&n<=t.top+t.height}var Zh=(e,t,r,n,a)=>{var i,o=(i=t==null?void 0:t.length)!==null&&i!==void 0?i:0;if(o<=1||e==null)return 0;if(n==="angleAxis"&&a!=null&&Math.abs(Math.abs(a[1]-a[0])-360)<=1e-6)for(var l=0;l0?(u=r[l-1])===null||u===void 0?void 0:u.coordinate:(c=r[o-1])===null||c===void 0?void 0:c.coordinate,m=(s=r[l])===null||s===void 0?void 0:s.coordinate,p=l>=o-1?(f=r[0])===null||f===void 0?void 0:f.coordinate:(v=r[l+1])===null||v===void 0?void 0:v.coordinate,y=void 0;if(!(h==null||m==null||p==null))if(we(m-h)!==we(p-m)){var g=[];if(we(p-m)===we(a[1]-a[0])){y=p;var x=m+a[1]-a[0];g[0]=Math.min(x,(x+h)/2),g[1]=Math.max(x,(x+h)/2)}else{y=h;var A=p+a[1]-a[0];g[0]=Math.min(m,(A+m)/2),g[1]=Math.max(m,(A+m)/2)}var w=[Math.min(m,(y+m)/2),Math.max(m,(y+m)/2)];if(e>w[0]&&e<=w[1]||e>=g[0]&&e<=g[1]){var O;return(O=r[l])===null||O===void 0?void 0:O.index}}else{var b=Math.min(h,p),S=Math.max(h,p);if(e>(b+m)/2&&e<=(S+m)/2){var I;return(I=r[l])===null||I===void 0?void 0:I.index}}}else if(t)for(var k=0;k(E.coordinate+j.coordinate)/2||k>0&&k(E.coordinate+j.coordinate)/2&&e<=(E.coordinate+T.coordinate)/2)return E.index}}return-1},Qh=()=>M(jo),Cl=(e,t)=>t,Jh=(e,t,r)=>r,Tl=(e,t,r,n)=>n,L1=P(Et,e=>Ca(e,t=>t.coordinate)),$l=P([Lr,Cl,Jh,Tl],Nh),Ml=P([$l,rr,Er,kr],en),R1=(e,t,r)=>{if(t!=null){var n=Lr(e);return t==="axis"?r==="hover"?n.axisInteraction.hover.dataKey:n.axisInteraction.click.dataKey:r==="hover"?n.itemInteraction.hover.dataKey:n.itemInteraction.click.dataKey}},em=P([Lr,Cl,Jh,Tl],Rh),ba=P([At,Pt,Y,ge,Et,Tl,em],Lh),B1=P([$l,ba],(e,t)=>{var r;return(r=e.coordinate)!==null&&r!==void 0?r:t}),tm=P([Et,Ml],Th),z1=P([em,Ml,tt,Er,tm,Bh,Cl],zh),K1=P([$l,Ml],(e,t)=>({isActive:e.active&&t!=null,activeIndex:t})),W1=(e,t,r,n,a,i,o)=>{if(!(!e||!r||!n||!a)&&N1(e,o)){var l=kg(e,t),u=Zh(l,i,a,r,n),c=D1(t,a,u,e);return{activeIndex:String(u),activeCoordinate:c}}},F1=(e,t,r,n,a,i,o)=>{if(!(!e||!n||!a||!i||!r)){var l=px(e,r);if(l){var u=jg(l,t),c=Zh(u,o,i,n,a),s=_1(t,i,c,l);return{activeIndex:String(c),activeCoordinate:s}}}},U1=(e,t,r,n,a,i,o,l)=>{if(!(!e||!t||!n||!a||!i))return t==="horizontal"||t==="vertical"?W1(e,t,n,a,i,o,l):F1(e,t,r,n,a,i,o)},H1=P(e=>e.zIndex.zIndexMap,(e,t)=>t,(e,t,r)=>r,(e,t,r)=>{if(t!=null){var n=e[t];if(n!=null)return r?n.panoramaElement:n.element}}),V1=P(e=>e.zIndex.zIndexMap,e=>{var t=Object.keys(e).map(n=>parseInt(n,10)).concat(Object.values(he)),r=Array.from(new Set(t));return r.sort((n,a)=>n-a)},{memoizeOptions:{resultEqualityCheck:Fx}});function Es(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function ks(e){for(var t=1;tks(ks({},e),{},{[t]:{element:void 0,panoramaElement:void 0,consumers:0}}),X1)},Q1=new Set(Object.values(he));function J1(e){return Q1.has(e)}var rm=Te({name:"zIndex",initialState:Z1,reducers:{registerZIndexPortal:{reducer:(e,t)=>{var r=t.payload.zIndex;e.zIndexMap[r]?e.zIndexMap[r].consumers+=1:e.zIndexMap[r]={consumers:1,element:void 0,panoramaElement:void 0}},prepare:re()},unregisterZIndexPortal:{reducer:(e,t)=>{var r=t.payload.zIndex;e.zIndexMap[r]&&(e.zIndexMap[r].consumers-=1,e.zIndexMap[r].consumers<=0&&!J1(r)&&delete e.zIndexMap[r])},prepare:re()},registerZIndexPortalElement:{reducer:(e,t)=>{var r=t.payload,n=r.zIndex,a=r.element,i=r.isPanorama;e.zIndexMap[n]?i?e.zIndexMap[n].panoramaElement=q(a):e.zIndexMap[n].element=q(a):e.zIndexMap[n]={consumers:0,element:i?void 0:q(a),panoramaElement:i?q(a):void 0}},prepare:re()},unregisterZIndexPortalElement:{reducer:(e,t)=>{var r=t.payload.zIndex;e.zIndexMap[r]&&(t.payload.isPanorama?e.zIndexMap[r].panoramaElement=void 0:e.zIndexMap[r].element=void 0)},prepare:re()}}}),ii=rm.actions,eS=ii.registerZIndexPortal,Oi=ii.unregisterZIndexPortal,tS=ii.registerZIndexPortalElement,rS=ii.unregisterZIndexPortalElement,nS=rm.reducer;function Re(e){var t=e.zIndex,r=e.children,n=cb(),a=n&&t!==void 0&&t!==0,i=$e(),o=d.useRef(void 0),l=d.useRef(new Set),u=ee(),c=M(f=>H1(f,t,i));if(d.useLayoutEffect(()=>{if(!a){var f=l.current;f.forEach(h=>{u(Oi({zIndex:h}))}),f.clear(),o.current=void 0;return}if(l.current.has(t)||(u(eS({zIndex:t})),l.current.add(t)),c){o.current=c;var v=l.current;v.forEach(h=>{h!==t&&(u(Oi({zIndex:h})),v.delete(h))})}},[u,t,a,c]),d.useLayoutEffect(()=>{var f=l.current;return()=>{f.forEach(v=>{u(Oi({zIndex:v}))}),f.clear()}},[u]),!a)return r;var s=c??o.current;return s?fo.createPortal(r,s):null}function Qi(){return Qi=Object.assign?Object.assign.bind():function(e){for(var t=1;td.useContext(nm),sn=new jp,Ji="recharts.syncEvent.tooltip",Cs="recharts.syncEvent.brush",Dl=(e,t)=>{if(t&&Array.isArray(e)){var r=Number.parseInt(t,10);if(!Je(r))return e[r]}},fS={chartName:"",tooltipPayloadSearcher:()=>{},eventEmitter:void 0,defaultTooltipEventType:"axis"},am=Te({name:"options",initialState:fS,reducers:{createEventEmitter:e=>{e.eventEmitter==null&&(e.eventEmitter=Symbol("rechartsEventEmitter"))}}}),dS=am.reducer,vS=am.actions.createEventEmitter;function hS(e){return e.tooltip.syncInteraction}var mS={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},im=Te({name:"chartData",initialState:mS,reducers:{setChartData(e,t){if(e.chartData=q(t.payload),t.payload==null){e.dataStartIndex=0,e.dataEndIndex=0;return}t.payload.length>0&&e.dataEndIndex!==t.payload.length-1&&(e.dataEndIndex=t.payload.length-1)},setComputedData(e,t){e.computedData=t.payload},setDataStartEndIndexes(e,t){var r=t.payload,n=r.startIndex,a=r.endIndex;n!=null&&(e.dataStartIndex=n),a!=null&&(e.dataEndIndex=a)}}}),_l=im.actions,Ts=_l.setChartData,pS=_l.setDataStartEndIndexes;_l.setComputedData;var yS=im.reducer,gS=["x","y"];function $s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function mr(e){for(var t=1;tu.rootProps.className);d.useEffect(()=>{if(e==null)return or;var u=(c,s,f)=>{if(t!==f&&e===c){if(s.payload.active===!1){r(Zr({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}if(n==="index"){var v;if(o&&s!==null&&s!==void 0&&(v=s.payload)!==null&&v!==void 0&&v.coordinate&&s.payload.sourceViewBox){var h=s.payload.coordinate,m=h.x,p=h.y,y=AS(h,gS),g=s.payload.sourceViewBox,x=g.x,A=g.y,w=g.width,O=g.height,b=mr(mr({},y),{},{x:o.x+(w?(m-x)/w:0)*o.width,y:o.y+(O?(p-A)/O:0)*o.height});r(mr(mr({},s),{},{payload:mr(mr({},s.payload),{},{coordinate:b})}))}else r(s);return}if(a!=null){var S;if(typeof n=="function"){var I={activeTooltipIndex:s.payload.index==null?void 0:Number(s.payload.index),isTooltipActive:s.payload.active,activeIndex:s.payload.index==null?void 0:Number(s.payload.index),activeLabel:s.payload.label,activeDataKey:s.payload.dataKey,activeCoordinate:s.payload.coordinate},k=n(a,I);S=a[k]}else n==="value"&&(S=a.find(F=>String(F.value)===s.payload.label));var E=s.payload.coordinate;if(E==null||o==null){r(Zr({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}if(S==null){r(Zr({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:s.payload.sourceViewBox,graphicalItemId:void 0}));return}var T=E.x,j=E.y,N=Math.min(T,o.x+o.width),_=Math.min(j,o.y+o.height),R={x:i==="horizontal"?S.coordinate:N,y:i==="horizontal"?_:S.coordinate},W=Zr({active:s.payload.active,coordinate:R,dataKey:s.payload.dataKey,index:String(S.index),label:s.payload.label,sourceViewBox:s.payload.sourceViewBox,graphicalItemId:s.payload.graphicalItemId});r(W)}}};return sn.on(Ji,u),()=>{sn.off(Ji,u)}},[l,r,t,e,n,a,i,o])}function SS(){var e=M(Co),t=M(To),r=ee();d.useEffect(()=>{if(e==null)return or;var n=(a,i,o)=>{t!==o&&e===a&&r(pS(i))};return sn.on(Cs,n),()=>{sn.off(Cs,n)}},[r,t,e])}function IS(){var e=ee();d.useEffect(()=>{e(vS())},[e]),OS(),SS()}function ES(e,t,r,n,a,i){var o=M(m=>R1(m,e,t)),l=M(qh),u=M(To),c=M(Co),s=M(cv),f=M(hS),v=(f==null?void 0:f.sourceViewBox)!=null,h=Ba();d.useEffect(()=>{if(!v&&c!=null&&u!=null){var m=Zr({active:i,coordinate:r,dataKey:o,index:a,label:typeof n=="number"?String(n):n,sourceViewBox:h,graphicalItemId:l});sn.emit(Ji,c,m,u)}},[v,r,o,l,a,n,u,c,s,i,h])}function Ms(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Ds(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=Array(t);r{S(jO({shared:x,trigger:A,axisId:b,active:a,defaultIndex:I}))},[S,x,A,b,a,I]);var k=Ba(),E=Wd(),T=PO(x),j=(t=M(z=>K1(z,T,A,I)))!==null&&t!==void 0?t:{},N=j.activeIndex,_=j.isActive,R=M(z=>z1(z,T,A,I)),W=M(z=>tm(z,T,A,I)),F=M(z=>B1(z,T,A,I)),L=R,V=sS(),K=(r=a??_)!==null&&r!==void 0?r:!1,le=Od([L,K]),de=TS(le,2),ae=de[0],Me=de[1],Be=T==="axis"?W:void 0;ES(T,A,F,Be,N,K);var qe=O??V;if(qe==null||k==null||T==null)return null;var Xe=L??Ns;K||(Xe=Ns),c&&Xe.length&&(Xe=Ad(Xe.filter(z=>z.value!=null&&(z.hide!==!0||n.includeHidden)),v,NS));var zr=Xe.length>0,D=Ds(Ds({},n),{},{payload:Xe,label:Be,active:K,activeIndex:N,coordinate:F,accessibilityLayer:E}),U=d.createElement(d0,{allowEscapeViewBox:i,animationDuration:o,animationEasing:l,isAnimationActive:s,active:K,coordinate:F,hasPayload:zr,offset:f,position:h,reverseDirection:m,useTranslate3d:p,viewBox:k,wrapperStyle:y,lastBoundingBox:ae,innerRef:Me,hasPortalFromProps:!!O},LS(u,D));return d.createElement(d.Fragment,null,fo.createPortal(U,qe),K&&d.createElement(cS,{cursor:g,tooltipEventType:T,coordinate:F,payload:Xe,index:N}))}var oi=e=>null;oi.displayName="Cell";function BS(e,t,r){return(t=zS(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function zS(e){var t=KS(e,"string");return typeof t=="symbol"?t:t+""}function KS(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}class WS{constructor(t){BS(this,"cache",new Map),this.maxSize=t}get(t){var r=this.cache.get(t);return r!==void 0&&(this.cache.delete(t),this.cache.set(t,r)),r}set(t,r){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.maxSize){var n=this.cache.keys().next().value;n!=null&&this.cache.delete(n)}this.cache.set(t,r)}clear(){this.cache.clear()}size(){return this.cache.size}}function Ls(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function FS(e){for(var t=1;t{try{var r=document.getElementById(Bs);r||(r=document.createElement("span"),r.setAttribute("id",Bs),r.setAttribute("aria-hidden","true"),document.body.appendChild(r)),Object.assign(r.style,YS,t),r.textContent="".concat(e);var n=r.getBoundingClientRect();return{width:n.width,height:n.height}}catch{return{width:0,height:0}}},tn=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t==null||gn.isSsr)return{width:0,height:0};if(!om.enableCache)return zs(t,r);var n=qS(t,r),a=Rs.get(n);if(a)return a;var i=zs(t,r);return Rs.set(n,i),i},lm;function xa(e,t){return JS(e)||QS(e,t)||ZS(e,t)||XS()}function XS(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ZS(e,t){if(e){if(typeof e=="string")return Ks(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ks(e,t):void 0}}function Ks(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);re.length)&&(t=e.length);for(var r=0,n=Array(t);r{var t=e.children,r=e.breakAll,n=e.style;try{var a=[];ie(t)||(r?a=t.toString().split(""):a=t.toString().split(cm));var i=a.map(l=>({word:l,width:tn(l,n).width})),o=r?0:tn(" ",n).width;return{wordsWithComputedWidth:i,spaceWidth:o}}catch{return null}};function fm(e){return e==="start"||e==="middle"||e==="end"||e==="inherit"}function bI(e){return ie(e)||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}var dm=(e,t,r,n)=>e.reduce((a,i)=>{var o=i.word,l=i.width,u=a[a.length-1];if(u&&l!=null&&(t==null||n||u.width+l+re.reduce((t,r)=>t.width>r.width?t:r),xI="…",Ys=(e,t,r,n,a,i,o,l)=>{var u=e.slice(0,t),c=sm({breakAll:r,style:n,children:u+xI});if(!c)return[!1,[]];var s=dm(c.wordsWithComputedWidth,i,o,l),f=s.length>a||vm(s).width>Number(i);return[f,s]},wI=(e,t,r,n,a)=>{var i=e.maxLines,o=e.children,l=e.style,u=e.breakAll,c=$(i),s=String(o),f=dm(t,n,r,a);if(!c||a)return f;var v=f.length>i||vm(f).width>Number(n);if(!v)return f;for(var h=0,m=s.length-1,p=0,y;h<=m&&p<=s.length-1;){var g=Math.floor((h+m)/2),x=g-1,A=Ys(s,x,u,l,i,n,r,a),w=Vs(A,2),O=w[0],b=w[1],S=Ys(s,g,u,l,i,n,r,a),I=Vs(S,1),k=I[0];if(!O&&!k&&(h=g+1),O&&k&&(m=g-1),!O&&k){y=b;break}p++}return y||f},qs=e=>{var t=ie(e)?[]:e.toString().split(cm);return[{words:t,width:void 0}]},AI=e=>{var t=e.width,r=e.scaleToFit,n=e.children,a=e.style,i=e.breakAll,o=e.maxLines;if((t||r)&&!gn.isSsr){var l,u,c=sm({breakAll:i,children:n,style:a});if(c){var s=c.wordsWithComputedWidth,f=c.spaceWidth;l=s,u=f}else return qs(n);return wI({breakAll:i,children:n,maxLines:o,style:a},l,u,t,!!r)}return qs(n)},hm="#808080",PI={angle:0,breakAll:!1,capHeight:"0.71em",fill:hm,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},li=d.forwardRef((e,t)=>{var r=Ae(e,PI),n=r.x,a=r.y,i=r.lineHeight,o=r.capHeight,l=r.fill,u=r.scaleToFit,c=r.textAnchor,s=r.verticalAnchor,f=Hs(r,dI),v=d.useMemo(()=>AI({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:u,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,u,f.style,f.width]),h=f.dx,m=f.dy,p=f.angle,y=f.className,g=f.breakAll,x=Hs(f,vI);if(!ut(n)||!ut(a)||v.length===0)return null;var A=Number(n)+($(h)?h:0),w=Number(a)+($(m)?m:0);if(!H(A)||!H(w))return null;var O;switch(s){case"start":O=Si("calc(".concat(o,")"));break;case"middle":O=Si("calc(".concat((v.length-1)/2," * -").concat(i," + (").concat(o," / 2))"));break;default:O=Si("calc(".concat(v.length-1," * -").concat(i,")"));break}var b=[],S=v[0];if(u&&S!=null){var I=S.width,k=f.width;b.push("scale(".concat($(k)&&$(I)?k/I:1,")"))}return p&&b.push("rotate(".concat(p,", ").concat(A,", ").concat(w,")")),b.length&&(x.transform=b.join(" ")),d.createElement("text",eo({},Ke(x),{ref:t,x:A,y:w,className:Z("recharts-text",y),textAnchor:c,fill:l.includes("url")?hm:l}),v.map((E,T)=>{var j=E.words.join(g?"":" ");return d.createElement("tspan",{x:A,dy:T===0?O:i,key:"".concat(j,"-").concat(T)},j)}))});li.displayName="Text";function Xs(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function at(e){for(var t=1;t{var t=e.viewBox,r=e.position,n=e.offset,a=n===void 0?0:n,i=e.parentViewBox,o=Ao(t),l=o.x,u=o.y,c=o.height,s=o.upperWidth,f=o.lowerWidth,v=l,h=l+(s-f)/2,m=(v+h)/2,p=(s+f)/2,y=v+s/2,g=c>=0?1:-1,x=g*a,A=g>0?"end":"start",w=g>0?"start":"end",O=s>=0?1:-1,b=O*a,S=O>0?"end":"start",I=O>0?"start":"end",k=i;if(r==="top"){var E={x:v+s/2,y:u-x,horizontalAnchor:"middle",verticalAnchor:A};return k&&(E.height=Math.max(u-k.y,0),E.width=s),E}if(r==="bottom"){var T={x:h+f/2,y:u+c+x,horizontalAnchor:"middle",verticalAnchor:w};return k&&(T.height=Math.max(k.y+k.height-(u+c),0),T.width=f),T}if(r==="left"){var j={x:m-b,y:u+c/2,horizontalAnchor:S,verticalAnchor:"middle"};return k&&(j.width=Math.max(j.x-k.x,0),j.height=c),j}if(r==="right"){var N={x:m+p+b,y:u+c/2,horizontalAnchor:I,verticalAnchor:"middle"};return k&&(N.width=Math.max(k.x+k.width-N.x,0),N.height=c),N}var _=k?{width:p,height:c}:{};return r==="insideLeft"?at({x:m+b,y:u+c/2,horizontalAnchor:I,verticalAnchor:"middle"},_):r==="insideRight"?at({x:m+p-b,y:u+c/2,horizontalAnchor:S,verticalAnchor:"middle"},_):r==="insideTop"?at({x:v+s/2,y:u+x,horizontalAnchor:"middle",verticalAnchor:w},_):r==="insideBottom"?at({x:h+f/2,y:u+c-x,horizontalAnchor:"middle",verticalAnchor:A},_):r==="insideTopLeft"?at({x:v+b,y:u+x,horizontalAnchor:I,verticalAnchor:w},_):r==="insideTopRight"?at({x:v+s-b,y:u+x,horizontalAnchor:S,verticalAnchor:w},_):r==="insideBottomLeft"?at({x:h+b,y:u+c-x,horizontalAnchor:I,verticalAnchor:A},_):r==="insideBottomRight"?at({x:h+f-b,y:u+c-x,horizontalAnchor:S,verticalAnchor:A},_):r&&typeof r=="object"&&($(r.x)||tr(r.x))&&($(r.y)||tr(r.y))?at({x:l+Ce(r.x,p),y:u+Ce(r.y,c),horizontalAnchor:"end",verticalAnchor:"end"},_):at({x:y,y:u+c/2,horizontalAnchor:"middle",verticalAnchor:"middle"},_)},kI=["labelRef"],jI=["content"];function Zs(e,t){if(e==null)return{};var r,n,a=CI(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n{var t=e.x,r=e.y,n=e.upperWidth,a=e.lowerWidth,i=e.width,o=e.height,l=e.children,u=d.useMemo(()=>({x:t,y:r,upperWidth:n,lowerWidth:a,width:i,height:o}),[t,r,n,a,i,o]);return d.createElement(mm.Provider,{value:u},l)},pm=()=>{var e=d.useContext(mm),t=Ba();return e||(t?Ao(t):void 0)},_I=d.createContext(null),NI=()=>{var e=d.useContext(_I),t=M(hv);return e||t},LI=e=>{var t=e.value,r=e.formatter,n=ie(e.children)?t:e.children;return typeof r=="function"?r(n):n},Nl=e=>e!=null&&typeof e=="function",RI=(e,t)=>{var r=we(t-e),n=Math.min(Math.abs(t-e),360);return r*n},BI=(e,t,r,n,a)=>{var i=e.offset,o=e.className,l=a.cx,u=a.cy,c=a.innerRadius,s=a.outerRadius,f=a.startAngle,v=a.endAngle,h=a.clockWise,m=(c+s)/2,p=RI(f,v),y=p>=0?1:-1,g,x;switch(t){case"insideStart":g=f+y*i,x=h;break;case"insideEnd":g=v-y*i,x=!h;break;case"end":g=v+y*i,x=h;break;default:throw new Error("Unsupported position ".concat(t))}x=p<=0?x:!x;var A=ve(l,u,m,g),w=ve(l,u,m,g+(x?1:-1)*359),O="M".concat(A.x,",").concat(A.y,` + A`).concat(m,",").concat(m,",0,1,").concat(x?0:1,`, + `).concat(w.x,",").concat(w.y),b=ie(e.id)?nn("recharts-radial-line-"):e.id;return d.createElement("text",mt({},n,{dominantBaseline:"central",className:Z("recharts-radial-bar-label",o)}),d.createElement("defs",null,d.createElement("path",{id:b,d:O})),d.createElement("textPath",{xlinkHref:"#".concat(b)},r))},zI=(e,t,r)=>{var n=e.cx,a=e.cy,i=e.innerRadius,o=e.outerRadius,l=e.startAngle,u=e.endAngle,c=(l+u)/2;if(r==="outside"){var s=ve(n,a,o+t,c),f=s.x,v=s.y;return{x:f,y:v,textAnchor:f>=n?"start":"end",verticalAnchor:"middle"}}if(r==="center")return{x:n,y:a,textAnchor:"middle",verticalAnchor:"middle"};if(r==="centerTop")return{x:n,y:a,textAnchor:"middle",verticalAnchor:"start"};if(r==="centerBottom")return{x:n,y:a,textAnchor:"middle",verticalAnchor:"end"};var h=(i+o)/2,m=ve(n,a,h,c),p=m.x,y=m.y;return{x:p,y,textAnchor:"middle",verticalAnchor:"middle"}},Un=e=>e!=null&&"cx"in e&&$(e.cx),KI={angle:0,offset:5,zIndex:he.label,position:"middle",textBreakAll:!1};function WI(e){if(!Un(e))return e;var t=e.cx,r=e.cy,n=e.outerRadius,a=n*2;return{x:t-n,y:r-n,width:a,upperWidth:a,lowerWidth:a,height:a}}function jt(e){var t=Ae(e,KI),r=t.viewBox,n=t.parentViewBox,a=t.position,i=t.value,o=t.children,l=t.content,u=t.className,c=u===void 0?"":u,s=t.textBreakAll,f=t.labelRef,v=NI(),h=pm(),m=a==="center"?h:v??h,p,y,g;r==null?p=m:Un(r)?p=r:p=Ao(r);var x=WI(p);if(!p||ie(i)&&ie(o)&&!d.isValidElement(l)&&typeof l!="function")return null;var A=Qr(Qr({},t),{},{viewBox:p});if(d.isValidElement(l)){A.labelRef;var w=Zs(A,kI);return d.cloneElement(l,w)}if(typeof l=="function"){A.content;var O=Zs(A,jI);if(y=d.createElement(l,O),d.isValidElement(y))return y}else y=LI(t);var b=Ke(t);if(Un(p)){if(a==="insideStart"||a==="insideEnd"||a==="end")return BI(t,a,y,b,p);g=zI(p,t.offset,t.position)}else{if(!x)return null;var S=EI({viewBox:x,position:a,offset:t.offset,parentViewBox:Un(n)?void 0:n});g=Qr(Qr({x:S.x,y:S.y,textAnchor:S.horizontalAnchor,verticalAnchor:S.verticalAnchor},S.width!==void 0?{width:S.width}:{}),S.height!==void 0?{height:S.height}:{})}return d.createElement(Re,{zIndex:t.zIndex},d.createElement(li,mt({ref:f,className:Z("recharts-label",c)},b,g,{textAnchor:fm(b.textAnchor)?b.textAnchor:g.textAnchor,breakAll:s}),y))}jt.displayName="Label";var FI=(e,t,r)=>{if(!e)return null;var n={viewBox:t,labelRef:r};return e===!0?d.createElement(jt,mt({key:"label-implicit"},n)):ut(e)?d.createElement(jt,mt({key:"label-implicit",value:e},n)):d.isValidElement(e)?e.type===jt?d.cloneElement(e,Qr({key:"label-implicit"},n)):d.createElement(jt,mt({key:"label-implicit",content:e},n)):Nl(e)?d.createElement(jt,mt({key:"label-implicit",content:e},n)):e&&typeof e=="object"?d.createElement(jt,mt({},e,{key:"label-implicit"},n)):null};function UI(e){var t=e.label,r=e.labelRef,n=pm();return FI(t,n,r)||null}var HI=["valueAccessor"],VI=["dataKey","clockWise","id","textBreakAll","zIndex"];function wa(){return wa=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t=Array.isArray(e.value)?e.value[e.value.length-1]:e.value;if(bI(t))return t},ym=d.createContext(void 0),gm=ym.Provider,bm=d.createContext(void 0),qI=bm.Provider;function XI(){return d.useContext(ym)}function ZI(){return d.useContext(bm)}function Hn(e){var t=e.valueAccessor,r=t===void 0?YI:t,n=Js(e,HI),a=n.dataKey;n.clockWise;var i=n.id,o=n.textBreakAll,l=n.zIndex,u=Js(n,VI),c=XI(),s=ZI(),f=c||s;return!f||!f.length?null:d.createElement(Re,{zIndex:l??he.label},d.createElement(se,{className:"recharts-label-list"},f.map((v,h)=>{var m,p=ie(a)?r(v,h):Q(v.payload,a),y=ie(i)?{}:{id:"".concat(i,"-").concat(h)};return d.createElement(jt,wa({key:"label-".concat(h)},Ke(v),u,y,{fill:(m=n.fill)!==null&&m!==void 0?m:v.fill,parentViewBox:v.parentViewBox,value:p,textBreakAll:o,viewBox:v.viewBox,index:h,zIndex:0}))})))}Hn.displayName="LabelList";function Ll(e){var t=e.label;return t?t===!0?d.createElement(Hn,{key:"labelList-implicit"}):d.isValidElement(t)||Nl(t)?d.createElement(Hn,{key:"labelList-implicit",content:t}):typeof t=="object"?d.createElement(Hn,wa({key:"labelList-implicit"},t,{type:String(t.type)})):null:null}function to(){return to=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t=e.cx,r=e.cy,n=e.r,a=e.className,i=Z("recharts-dot",a);return $(t)&&$(r)&&$(n)?d.createElement("circle",to({},Le(e),go(e),{className:i,cx:t,cy:r,r:n})):null},wm=e=>e.graphicalItems.polarItems,QI=P([oe,wn],ll),ui=P([wm,fe,QI],ul),JI=P([ui],cl),ci=P([JI,bn],sl),eE=P([ci,fe,ui],oh);P([ci,fe,ui],(e,t,r)=>r.length>0?e.flatMap(n=>r.flatMap(a=>{var i,o=Q(n,(i=t.dataKey)!==null&&i!==void 0?i:a.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):(t==null?void 0:t.dataKey)!=null?e.map(n=>({value:Q(n,t.dataKey),errorDomain:[]})):e.map(n=>({value:n,errorDomain:[]})));var ef=()=>{},tE=P([ci,fe,ui,ti,oe,Ax],ml),rE=P([fe,vl,hl,ef,tE,ef,Y,oe],pl),Am=P([fe,Y,ci,eE,xn,oe,rE],yl),nE=P([Am,Dr,zt],bl),aE=P([fe,Am,nE,oe],wl);P([zt,aE],pv);var iE={radiusAxis:{},angleAxis:{}},Pm=Te({name:"polarAxis",initialState:iE,reducers:{addRadiusAxis(e,t){e.radiusAxis[t.payload.id]=q(t.payload)},removeRadiusAxis(e,t){delete e.radiusAxis[t.payload.id]},addAngleAxis(e,t){e.angleAxis[t.payload.id]=q(t.payload)},removeAngleAxis(e,t){delete e.angleAxis[t.payload.id]}}}),si=Pm.actions;si.addRadiusAxis;si.removeRadiusAxis;si.addAngleAxis;si.removeAngleAxis;var oE=Pm.reducer;function Om(e){return e&&typeof e=="object"&&"className"in e&&typeof e.className=="string"?e.className:""}function tf(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function rf(e){for(var t=1;tt,Rl=P([wm,sE],(e,t)=>e.filter(r=>r.type==="pie").find(r=>r.id===t)),fE=[],Bl=(e,t,r)=>(r==null?void 0:r.length)===0?fE:r,Sm=P([bn,Rl,Bl],(e,t,r)=>{var n=e.chartData;if(t!=null){var a;if((t==null?void 0:t.data)!=null&&t.data.length>0?a=t.data:a=n,(!a||!a.length)&&r!=null&&(a=r.map(i=>rf(rf({},t.presentationProps),i.props))),a!=null)return a}}),dE=P([Sm,Rl,Bl],(e,t,r)=>{if(!(e==null||t==null))return e.map((n,a)=>{var i,o=Q(n,t.nameKey,t.name),l;return r!=null&&(i=r[a])!==null&&i!==void 0&&(i=i.props)!==null&&i!==void 0&&i.fill?l=r[a].props.fill:typeof n=="object"&&n!=null&&"fill"in n?l=n.fill:l=t.fill,{value:Cr(o,t.dataKey),dataKey:t.dataKey,color:l,payload:n,type:t.legendType}})}),vE=P([Sm,Rl,Bl,ge],(e,t,r,n)=>{if(!(t==null||e==null))return wk({offset:n,pieSettings:t,displayedData:e,cells:r})}),nf=e=>typeof e=="string"?e:e?e.displayName||e.name||"Component":"",af=null,Ii=null,Im=e=>{if(e===af&&Array.isArray(Ii))return Ii;var t=[];return d.Children.forEach(e,r=>{ie(r)||(Cp.isFragment(r)?t=t.concat(Im(r.props.children)):t.push(r))}),Ii=t,af=e,t};function zl(e,t){var r=[],n=[];return Array.isArray(t)?n=t.map(a=>nf(a)):n=[nf(t)],Im(e).forEach(a=>{var i=Qt(a,"type.displayName")||Qt(a,"type.name");i&&n.indexOf(i)!==-1&&r.push(a)}),r}var Em=e=>e&&typeof e=="object"&&"clipDot"in e?!!e.clipDot:!0;function of(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function lf(e){for(var t=1;t{var n=ee();return(a,i)=>o=>{e==null||e(a,i,o),n(Mh({activeIndex:String(i),activeDataKey:t,activeCoordinate:a.tooltipPosition,activeGraphicalItemId:r}))}},Fl=e=>{var t=ee();return(r,n)=>a=>{e==null||e(r,n,a),t(CO())}},Ul=(e,t,r)=>{var n=ee();return(a,i)=>o=>{e==null||e(a,i,o),n(TO({activeIndex:String(i),activeDataKey:t,activeCoordinate:a.tooltipPosition,activeGraphicalItemId:r}))}};function Hl(e){var t=e.tooltipEntrySettings,r=ee(),n=$e(),a=d.useRef(null);return d.useLayoutEffect(()=>{n||(a.current===null?r(IO(t)):a.current!==t&&r(EO({prev:a.current,next:t})),a.current=t)},[t,r,n]),d.useLayoutEffect(()=>()=>{a.current&&(r(kO(a.current)),a.current=null)},[r]),null}function jm(e){var t=e.legendPayload,r=ee(),n=$e(),a=d.useRef(null);return d.useLayoutEffect(()=>{n||(a.current===null?r(Rd(t)):a.current!==t&&r(Bd({prev:a.current,next:t})),a.current=t)},[r,n,t]),d.useLayoutEffect(()=>()=>{a.current&&(r(zd(a.current)),a.current=null)},[r]),null}function wE(e){var t=e.legendPayload,r=ee(),n=M(Y),a=d.useRef(null);return d.useLayoutEffect(()=>{n!=="centric"&&n!=="radial"||(a.current===null?r(Rd(t)):a.current!==t&&r(Bd({prev:a.current,next:t})),a.current=t)},[r,n,t]),d.useLayoutEffect(()=>()=>{a.current&&(r(zd(a.current)),a.current=null)},[r]),null}function AE(e,t){return IE(e)||SE(e,t)||OE(e,t)||PE()}function PE(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function OE(e,t){if(e){if(typeof e=="string")return uf(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?uf(e,t):void 0}}function uf(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r2&&arguments[2]!==void 0?arguments[2]:[],n=[];for(var a of r)n.push({status:"removed",prev:a});for(var i=0;ie[Math.floor(i*r)]);return Yl(n,t)}function kE(e,t){var r=t.map((n,a)=>e[a]);return Yl(r,t)}function jE(e,t){for(var r=new Map,n=0;n{var h=r(f,v);if(h!=null){var m=n.get(h);if(m!==void 0)return a.add(h),m}}),o=[];for(var l of n){var u=AE(l,2),c=u[0],s=u[1];a.has(c)||o.push(s)}return Yl(i,t,o)}function ro(e,t,r){return t==null?null:e==null?t.map(n=>({status:"added",next:n})):r===Vl?EE(e,t):r===Gl?kE(e,t):CE(e,t,r)}function Cm(e,t){var r=d.useRef(e),n=d.useRef(t.current),a=d.useRef(!0);r.current!==e&&(r.current=e,n.current=t.current,a.current=!1);var i=d.useCallback(function(o,l){var u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(l===0){a.current=!0;return}l===1&&(n.current=o),l>0&&a.current&&u&&(t.current=o)},[t]);return{startValue:n.current,syncStepValue:i}}function TE(e,t){return _E(e)||DE(e,t)||ME(e,t)||$E()}function $E(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ME(e,t){if(e){if(typeof e=="string")return cf(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?cf(e,t):void 0}}function cf(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r{typeof e=="function"&&e(),i(!0)},[e]),l=d.useCallback(()=>{typeof t=="function"&&t(),i(!1)},[t]);return{isAnimating:a,handleAnimationStart:o,handleAnimationEnd:l}}function Xl(e){var t,r=e.animationInput,n=e.animationIdPrefix,a=e.items,i=e.previousItemsRef,o=e.isAnimationActive,l=e.animationBegin,u=e.animationDuration,c=e.animationEasing,s=e.onAnimationStart,f=e.onAnimationEnd,v=e.animationInterpolateFn,h=e.animationMatchBy,m=e.shouldUpdatePreviousRef,p=e.children,y=e.layout,g=Gd(r,n),x=Cm(g,i),A=(t=x.startValue)!==null&&t!==void 0?t:null,w=ro(A,a,h??Vl);return d.createElement(Vd,{animationId:g,begin:l,duration:u,isActive:o,easing:c,onAnimationEnd:f,onAnimationStart:s,key:g},O=>{var b=A==null,S=a==null?a:v(w,O,y),I=m?m(O):O>0;return x.syncStepValue(S,O,I),S==null?null:p(S,O,b)})}var Ei;function NE(e,t){return zE(e)||BE(e,t)||RE(e,t)||LE()}function LE(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function RE(e,t){if(e){if(typeof e=="string")return sf(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?sf(e,t):void 0}}function sf(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r{var e=d.useState(()=>nn("uid-")),t=NE(e,1),r=t[0];return r},Tm=(Ei=Sp.useId)!==null&&Ei!==void 0?Ei:KE;function WE(e,t){var r=Tm();return t||(e?"".concat(e,"-").concat(r):r)}var FE=d.createContext(void 0),Zl=e=>{var t=e.id,r=e.type,n=e.children,a=WE("recharts-".concat(r),t);return d.createElement(FE.Provider,{value:a},n(a))},UE={cartesianItems:[],polarItems:[]},$m=Te({name:"graphicalItems",initialState:UE,reducers:{addCartesianGraphicalItem:{reducer(e,t){e.cartesianItems.push(q(t.payload))},prepare:re()},replaceCartesianGraphicalItem:{reducer(e,t){var r=t.payload,n=r.prev,a=r.next,i=Qe(e).cartesianItems.indexOf(q(n));i>-1&&(e.cartesianItems[i]=q(a))},prepare:re()},removeCartesianGraphicalItem:{reducer(e,t){var r=Qe(e).cartesianItems.indexOf(q(t.payload));r>-1&&e.cartesianItems.splice(r,1)},prepare:re()},addPolarGraphicalItem:{reducer(e,t){e.polarItems.push(q(t.payload))},prepare:re()},removePolarGraphicalItem:{reducer(e,t){var r=Qe(e).polarItems.indexOf(q(t.payload));r>-1&&e.polarItems.splice(r,1)},prepare:re()},replacePolarGraphicalItem:{reducer(e,t){var r=t.payload,n=r.prev,a=r.next,i=Qe(e).polarItems.indexOf(q(n));i>-1&&(e.polarItems[i]=q(a))},prepare:re()}}}),Rr=$m.actions,HE=Rr.addCartesianGraphicalItem,VE=Rr.replaceCartesianGraphicalItem,GE=Rr.removeCartesianGraphicalItem,YE=Rr.addPolarGraphicalItem,qE=Rr.removePolarGraphicalItem,XE=Rr.replacePolarGraphicalItem,ZE=$m.reducer,QE=e=>{var t=ee(),r=d.useRef(null);return d.useLayoutEffect(()=>{r.current===null?t(HE(e)):r.current!==e&&t(VE({prev:r.current,next:e})),r.current=e},[t,e]),d.useLayoutEffect(()=>()=>{r.current&&(t(GE(r.current)),r.current=null)},[t]),null},Mm=d.memo(QE),JE=e=>{var t=ee(),r=d.useRef(null);return d.useLayoutEffect(()=>{r.current===null?t(YE(e)):r.current!==e&&t(XE({prev:r.current,next:e})),r.current=e},[t,e]),d.useLayoutEffect(()=>()=>{r.current&&(t(qE(r.current)),r.current=null)},[t]),null},ek=d.memo(JE),tk=["key"],rk=["onMouseEnter","onClick","onMouseLeave"],nk=["id"],ak=["id"];function nr(){return nr=Object.assign?Object.assign.bind():function(e){for(var t=1;tzl(e.children,oi),[e.children]),r=M(n=>dE(n,e.id,t));return r==null?null:d.createElement(wE,{legendPayload:r})}function sk(e){if(!(e==null||typeof e=="boolean"||typeof e=="function")){if(d.isValidElement(e)){var t,r=(t=e.props)===null||t===void 0?void 0:t.fill;return typeof r=="string"?r:void 0}var n=e.fill;return typeof n=="string"?n:void 0}}var fk=d.memo(e=>{var t=e.dataKey,r=e.nameKey,n=e.sectors,a=e.stroke,i=e.strokeWidth,o=e.fill,l=e.name,u=e.hide,c=e.tooltipType,s=e.id,f=e.activeShape,v=sk(f),h=n.map(p=>{var y=p.tooltipPayload;return v==null||y==null?y:y.map(g=>ne(ne({},g),{},{color:v,fill:v}))}),m={dataDefinedOnItem:h,getPosition:p=>{var y;return(y=n[Number(p)])===null||y===void 0?void 0:y.tooltipPosition},settings:{stroke:a,strokeWidth:i,fill:o,dataKey:t,nameKey:r,name:Cr(l,t),hide:u,type:c,color:o,unit:"",graphicalItemId:s}};return d.createElement(Hl,{tooltipEntrySettings:m})}),dk=(e,t)=>e>t?"start":eCe(typeof t=="function"?t(e):t,r,r*.8),hk=(e,t,r)=>{var n=t.top,a=t.left,i=t.width,o=t.height,l=qd(i,o),u=a+Ce(e.cx,i,i/2),c=n+Ce(e.cy,o,o/2),s=Ce(e.innerRadius,l,0),f=vk(r,e.outerRadius,l),v=e.maxRadius||Math.sqrt(i*i+o*o)/2;return{cx:u,cy:c,innerRadius:s,outerRadius:f,maxRadius:v}},mk=(e,t)=>{var r=we(t-e),n=Math.min(Math.abs(t-e),360);return r*n},pk=(e,t)=>{if(d.isValidElement(e))return d.cloneElement(e,t);if(typeof e=="function")return e(t);var r=Z("recharts-pie-label-line",typeof e!="boolean"?e.className:"");t.key;var n=fi(t,tk);return d.createElement(Jr,nr({},n,{type:"linear",className:r}))},yk=(e,t,r)=>{if(d.isValidElement(e))return d.cloneElement(e,t);var n=r;if(typeof e=="function"&&(n=e(t),d.isValidElement(n)))return n;var a=Z("recharts-pie-label-text",Om(e));return d.createElement(li,nr({},t,{alignmentBaseline:"middle",className:a}),n)};function gk(e){var t=e.sectors,r=e.props,n=e.showLabels,a=r.label,i=r.labelLine,o=r.dataKey;if(!n||!a||!t)return null;var l=Le(r),u=Jt(a),c=Jt(i),s=typeof a=="object"&&"offsetRadius"in a&&typeof a.offsetRadius=="number"&&a.offsetRadius||20,f=t.map((v,h)=>{var m=(v.startAngle+v.endAngle)/2,p=ve(v.cx,v.cy,v.outerRadius+s,m),y=ne(ne(ne(ne({},l),v),{},{stroke:"none"},u),{},{index:h,textAnchor:dk(p.x,v.cx)},p),g=ne(ne(ne(ne({},l),v),{},{fill:"none",stroke:v.fill},c),{},{index:h,points:[ve(v.cx,v.cy,v.outerRadius,m),p],key:"line"});return d.createElement(Re,{zIndex:he.label,key:"label-".concat(v.startAngle,"-").concat(v.endAngle,"-").concat(v.midAngle,"-").concat(h)},d.createElement(se,null,i&&pk(i,g),yk(a,y,Q(v,o))))});return d.createElement(se,{className:"recharts-pie-labels"},f)}function bk(e){var t=e.sectors,r=e.props,n=e.showLabels,a=r.label;return typeof a=="object"&&a!=null&&"position"in a?d.createElement(Ll,{label:a}):d.createElement(gk,{sectors:t,props:r,showLabels:n})}function xk(e){var t=e.sectors,r=e.activeShape,n=e.inactiveShape,a=e.allOtherPieProps,i=e.shape,o=e.id,l=e.animationElapsedTime,u=e.isAnimating,c=e.isEntrance,s=M(Nt),f=M(jl),v=M(qh),h=a.onMouseEnter,m=a.onClick,p=a.onMouseLeave,y=fi(a,rk),g=Wl(h,a.dataKey,o),x=Fl(p),A=Ul(m,a.dataKey,o);return t==null||t.length===0?null:d.createElement(d.Fragment,null,t.map((w,O)=>{if((w==null?void 0:w.startAngle)===0&&(w==null?void 0:w.endAngle)===0&&t.length!==1)return null;var b=v==null||v===o,S=String(O)===s&&(f==null||a.dataKey===f)&&b,I=s?n:null,k=r&&S?r:I,E=ne(ne({},w),{},{stroke:w.stroke,tabIndex:-1,index:O,isActive:S,animationElapsedTime:l,isAnimating:u,isEntrance:c,[Td]:O,[$d]:o});return d.createElement(se,nr({key:"sector-".concat(w==null?void 0:w.startAngle,"-").concat(w==null?void 0:w.endAngle,"-").concat(w.midAngle,"-").concat(O),tabIndex:-1,className:"recharts-pie-sector"},hn(y,w,O),{onMouseEnter:g(w,O),onMouseLeave:x(w,O),onClick:A(w,O)}),d.createElement(Kl,{option:k??i,DefaultShape:Dm,shapeProps:E}))}))}function wk(e){var t,r=e.pieSettings,n=e.displayedData,a=e.cells,i=e.offset,o=r.cornerRadius,l=r.startAngle,u=r.endAngle,c=r.dataKey,s=r.nameKey,f=r.tooltipType,v=Math.abs(r.minAngle),h=mk(l,u),m=Math.abs(h),p=n.length<=1?0:(t=r.paddingAngle)!==null&&t!==void 0?t:0,y=n.filter(I=>Q(I,c,0)!==0).length,g=(m>=360?y:y-1)*p,x=n.reduce((I,k)=>{var E=Q(k,c,0);return I+($(E)?E:0)},0),A=v>0&&x>0&&n.some(I=>{var k=Q(I,c,0),E=($(k)?k:0)/x;return k!==0&&E*m0){var S;b=n.map((I,k)=>{var E=Q(I,c,0),T=Q(I,s,k),j=hk(r,i,I),N=($(E)?E:0)/x,_,R=ne(ne({},I),a&&a[k]&&a[k].props),W=R!=null&&"fill"in R&&typeof R.fill=="string"?R.fill:r.fill;k?_=S.endAngle+we(h)*p*(E!==0?1:0):_=l;var F=_+we(h)*((E!==0?w:0)+N*O),L=(_+F)/2,V=(j.innerRadius+j.outerRadius)/2,K=[{name:T,value:E,payload:R,dataKey:c,type:f,color:W,fill:W,graphicalItemId:r.id}],le=ve(j.cx,j.cy,V,L);return S=ne(ne(ne(ne({},r.presentationProps),{},{percent:N,cornerRadius:typeof o=="string"?parseFloat(o):o,name:T,tooltipPayload:K,midAngle:L,middleRadius:V,tooltipPosition:le},R),j),{},{value:E,dataKey:c,startAngle:_,endAngle:F,payload:R,paddingAngle:E!==0?we(h)*p:0}),S})}return b}function Ak(e){var t=e.showLabels,r=e.sectors,n=e.children,a=d.useMemo(()=>!t||!r?[]:r.map(i=>({value:i.value,payload:i.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:i.cx,cy:i.cy,innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,clockWise:!1},fill:i.fill})),[r,t]);return d.createElement(qI,{value:t?a:void 0},n)}var Pk=(e,t)=>{if(e==null)return[];var r=[],n=e.find(i=>i.status!=="removed"),a=n?n.next.startAngle:0;return e.forEach((i,o)=>{if(i.status!=="removed"){var l=o>0?Qt(i.next,"paddingAngle",0):0;if(i.status==="matched"){var u=ue(i.prev.endAngle-i.prev.startAngle,i.next.endAngle-i.next.startAngle,t),c=ne(ne({},i.next),{},{startAngle:a+l,endAngle:a+u+l});r.push(c),a=c.endAngle}else{var s=ue(0,i.next.endAngle-i.next.startAngle,t),f=ne(ne({},i.next),{},{startAngle:a+l,endAngle:a+s+l});r.push(f),a=f.endAngle}}}),r};function Ok(e){var t=e.props,r=e.previousSectorsRef,n=e.id,a=t.sectors,i=t.activeShape,o=t.inactiveShape,l=t.animationInterpolateFn,u=ql(t.onAnimationStart,t.onAnimationEnd),c=u.isAnimating,s=u.handleAnimationStart,f=u.handleAnimationEnd,v=ub();return v==null?null:d.createElement(Ak,{showLabels:!c,sectors:a},d.createElement(Xl,{animationInput:t,animationIdPrefix:"recharts-pie-",items:a,previousItemsRef:r,isAnimationActive:t.isAnimationActive,animationBegin:t.animationBegin,animationDuration:t.animationDuration,animationEasing:t.animationEasing,onAnimationStart:s,onAnimationEnd:f,animationInterpolateFn:l,animationMatchBy:t.animationMatchBy,layout:v},(h,m,p)=>d.createElement(se,null,d.createElement(xk,{sectors:h,activeShape:i,inactiveShape:o,allOtherPieProps:t,shape:t.shape,id:n,animationElapsedTime:m,isAnimating:c||m<1,isEntrance:p}))),d.createElement(bk,{showLabels:!c,sectors:a,props:t}),t.children)}var Sk={animationBegin:400,animationDuration:1500,animationEasing:"ease",animationInterpolateFn:Pk,animationMatchBy:Gl,cx:"50%",cy:"50%",dataKey:"value",endAngle:360,fill:"#808080",hide:!1,innerRadius:0,isAnimationActive:"auto",label:!1,labelLine:!0,legendType:"rect",minAngle:0,nameKey:"name",outerRadius:"80%",paddingAngle:0,rootTabIndex:0,shape:Dm,startAngle:0,stroke:"#fff",zIndex:he.area};function Ik(e){var t=e.id,r=fi(e,nk),n=e.hide,a=e.className,i=e.rootTabIndex,o=d.useMemo(()=>zl(e.children,oi),[e.children]),l=M(s=>vE(s,t,o)),u=d.useRef(null),c=Z("recharts-pie",a);return n||l==null?(u.current=null,d.createElement(se,{tabIndex:i,className:c})):d.createElement(Re,{zIndex:e.zIndex},d.createElement(fk,{dataKey:e.dataKey,nameKey:e.nameKey,sectors:l,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:t,activeShape:e.activeShape}),d.createElement(se,{tabIndex:i,className:c},d.createElement(Ok,{props:ne(ne({},r),{},{sectors:l}),previousSectorsRef:u,id:t})))}function Ek(e){var t=Ae(e,Sk),r=t.id,n=fi(t,ak),a=Le(n);return d.createElement(Zl,{id:r,type:"pie"},i=>d.createElement(d.Fragment,null,d.createElement(ek,{type:"pie",id:i,data:n.data,dataKey:n.dataKey,hide:n.hide,angleAxisId:0,radiusAxisId:0,name:n.name,nameKey:n.nameKey,tooltipType:n.tooltipType,legendType:n.legendType,fill:n.fill,cx:n.cx,cy:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,paddingAngle:n.paddingAngle,minAngle:n.minAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius,cornerRadius:n.cornerRadius,presentationProps:a,maxRadius:t.maxRadius}),d.createElement(ck,nr({},n,{id:i})),d.createElement(Ik,nr({},n,{id:i}))))}var kk=Ek;kk.displayName="Pie";var jk=["points"];function df(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function ki(e){for(var t=1;t{var g,x,A=ki(ki(ki({r:3},o),v),{},{index:y,cx:(g=p.x)!==null&&g!==void 0?g:void 0,cy:(x=p.y)!==null&&x!==void 0?x:void 0,dataKey:i,value:p.value,payload:p.payload,points:t});return d.createElement(_k,{key:"dot-".concat(y),option:r,dotProps:A,className:a})}),m={};return l&&u!=null&&(m.clipPath="url(#clipPath-".concat(f?"":"dots-").concat(u,")")),d.createElement(Re,{zIndex:s},d.createElement(se,Aa({className:n},m),h))}function vf(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function hf(e){for(var t=1;t({top:e.top,bottom:e.bottom,left:e.left,right:e.right})),Zk=P([Xk,At,Pt],(e,t,r)=>{if(!(!e||t==null||r==null))return{x:e.left,y:e.top,width:Math.max(0,t-e.left-e.right),height:Math.max(0,r-e.top-e.bottom)}}),Ql=()=>M(Zk),Qk=()=>M(S1);function mf(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function ji(e){for(var t=1;t{var t=e.point,r=e.childIndex,n=e.mainColor,a=e.activeDot,i=e.dataKey,o=e.clipPath;if(a===!1||t.x==null||t.y==null)return null;var l={index:r,dataKey:i,cx:t.x,cy:t.y,r:4,fill:n??"none",strokeWidth:2,stroke:"#fff",payload:t.payload,value:t.value},u=ji(ji(ji({},l),Jt(a)),go(a)),c;return d.isValidElement(a)?c=d.cloneElement(a,u):typeof a=="function"?c=a(u):c=d.createElement(xm,u),d.createElement(se,{className:"recharts-active-dot",clipPath:o},c)};function pf(e){var t=e.points,r=e.mainColor,n=e.activeDot,a=e.itemDataKey,i=e.clipPath,o=e.zIndex,l=o===void 0?he.activeDot:o,u=M(Nt),c=Qk();if(t==null||c==null)return null;var s=t.find(f=>c.includes(f.payload));return ie(s)?null:d.createElement(Re,{zIndex:l},d.createElement(rj,{point:s,childIndex:Number(u),mainColor:r,dataKey:a,activeDot:n,clipPath:i}))}function nj(e,t){return lj(e)||oj(e,t)||ij(e,t)||aj()}function aj(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ij(e,t){if(e){if(typeof e=="string")return yf(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?yf(e,t):void 0}}function yf(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r{var n=r??e;if(!ie(n))return Ce(n,t,0)},uj=(e,t,r)=>{var n={},a=e.filter(Ha),i=e.filter(c=>c.stackId==null),o=a.reduce((c,s)=>{var f=c[s.stackId];return f==null&&(f=[]),f.push(s),c[s.stackId]=f,c},n),l=Object.entries(o).map(c=>{var s,f=nj(c,2),v=f[0],h=f[1],m=h.map(y=>y.dataKey),p=gf(t,r,(s=h[0])===null||s===void 0?void 0:s.barSize);return{stackId:v,dataKeys:m,barSize:p}}),u=i.map(c=>{var s=[c.dataKey].filter(v=>v!=null),f=gf(t,r,c.barSize);return{stackId:void 0,dataKeys:s,barSize:f}});return[...l,...u]};function bf(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function zn(e){for(var t=1;tx+(A.barSize||0),0);v+=(o-1)*l,v>=r&&(v-=(o-1)*l,l=0),v>=r&&f>0&&(s=!0,f*=.9,v=o*f);var h=Math.round((r-v)/2),m={offset:h-l,size:0};u=n.reduce((x,A)=>{var w,O={stackId:A.stackId,dataKeys:A.dataKeys,position:{offset:m.offset+m.size+l,size:s?f:(w=A.barSize)!==null&&w!==void 0?w:0}},b=[...x,O];return m=O.position,b},c)}else{var p=Ce(t,r,0,!0);r-2*p-(o-1)*l<=0&&(l=0);var y=(r-2*p-(o-1)*l)/o;y>1&&(y=Math.round(y));var g=H(a)?Math.min(y,a):y;u=n.reduce((x,A,w)=>[...x,{stackId:A.stackId,dataKeys:A.dataKeys,position:{offset:p+(y+l)*w+(y-g)/2,size:g}}],c)}return u}}var vj=(e,t,r,n,a,i,o)=>{var l=ie(o)?t:o,u=dj(r,n,a!==i?a:i,e,l);return a!==i&&u!=null&&(u=u.map(c=>zn(zn({},c),{},{position:zn(zn({},c.position),{},{offset:c.position.offset-a/2})}))),u},hj=(e,t)=>{var r=Ua(t);if(!(!e||r==null||t==null)){var n=t.stackId;if(n!=null){var a=e[n];if(a){var i=a.stackedData;if(i)return i.find(o=>o.key===r)}}}},mj=(e,t)=>{if(!(e==null||t==null)){var r=e.find(n=>n.stackId===t.stackId&&t.dataKey!=null&&n.dataKeys.includes(t.dataKey));if(r!=null)return r.position}};function pj(e,t){return e&&typeof e=="object"&&"zIndex"in e&&typeof e.zIndex=="number"&&H(e.zIndex)?e.zIndex:t}var Lm=e=>{var t=e.chartData,r=ee(),n=$e();return d.useEffect(()=>n?()=>{}:(r(Ts(t)),()=>{r(Ts(void 0))}),[t,r,n]),null},xf={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},Rm=Te({name:"brush",initialState:xf,reducers:{setBrushSettings(e,t){return t.payload==null?xf:t.payload}}});Rm.actions.setBrushSettings;var yj=Rm.reducer;function gj(e){return(e%180+180)%180}var bj=function(t){var r=t.width,n=t.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=gj(a),o=i*Math.PI/180,l=Math.atan(n/r),u=o>l&&o{e.dots.push(t.payload)},removeDot:(e,t)=>{var r=Qe(e).dots.findIndex(n=>n===t.payload);r!==-1&&e.dots.splice(r,1)},addArea:(e,t)=>{e.areas.push(t.payload)},removeArea:(e,t)=>{var r=Qe(e).areas.findIndex(n=>n===t.payload);r!==-1&&e.areas.splice(r,1)},addLine:(e,t)=>{e.lines.push(q(t.payload))},removeLine:(e,t)=>{var r=Qe(e).lines.findIndex(n=>n===t.payload);r!==-1&&e.lines.splice(r,1)}}}),Br=Bm.actions;Br.addDot;Br.removeDot;Br.addArea;Br.removeArea;Br.addLine;Br.removeLine;var wj=Bm.reducer;function Aj(e,t){return Ij(e)||Sj(e,t)||Oj(e,t)||Pj()}function Pj(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Oj(e,t){if(e){if(typeof e=="string")return wf(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?wf(e,t):void 0}}function wf(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r{var t=e.children,r=d.useState("".concat(nn("recharts"),"-clip")),n=Aj(r,1),a=n[0],i=Ql();if(i==null)return null;var o=i.x,l=i.y,u=i.width,c=i.height;return d.createElement(Ej.Provider,{value:a},d.createElement("defs",null,d.createElement("clipPath",{id:a},d.createElement("rect",{x:o,y:l,height:c,width:u}))),t)};function zm(e,t){if(t<1)return[];if(t===1)return e;for(var r=[],n=0;ne*a)return!1;var i=r();return e*(t-e*i/2-n)>=0&&e*(t+e*i/2-a)<=0}function Tj(e,t){return zm(e,t+1)}function $j(e,t,r,n,a){for(var i=(n||[]).slice(),o=t.start,l=t.end,u=0,c=1,s=o,f=function(){var m=n==null?void 0:n[u];if(m===void 0)return{v:zm(n,c)};var p=u,y,g=()=>(y===void 0&&(y=r(m,p)),y),x=m.coordinate,A=u===0||fn(e,x,g,s,l);A||(u=0,s=o,c+=1),A&&(s=x+e*(g()/2+a),u+=c)},v;c<=i.length;)if(v=f(),v)return v.v;return[]}function Mj(e,t,r,n,a){var i=(n||[]).slice(),o=i.length;if(o===0)return[];for(var l=t.start,u=t.end,c=1;c<=o;c++){for(var s=(o-1)%c,f=l,v=!0,h=function(){var w=n[p];if(w==null)return 0;var O=p,b,S=()=>(b===void 0&&(b=r(w,O)),b),I=w.coordinate,k=p===s||fn(e,I,S,f,u);if(!k)return v=!1,1;k&&(f=I+e*(S()/2+a))},m,p=s;p(p===void 0&&(p=r(h,v)),p);if(v===o-1){var g=e*(m.coordinate+e*y()/2-u);i[v]=m=ke(ke({},m),{},{tickCoord:g>0?m.coordinate-g*e:m.coordinate})}else i[v]=m=ke(ke({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var x=fn(e,m.tickCoord,y,l,u);x&&(u=m.tickCoord-e*(y()/2+a),i[v]=ke(ke({},m),{},{isShow:!0}))}},s=o-1;s>=0;s--)c(s);return i}function Rj(e,t,r,n,a,i){var o=(n||[]).slice(),l=o.length,u=t.start,c=t.end;if(i){var s=n[l-1];if(s!=null){var f=r(s,l-1),v=e*(s.coordinate+e*f/2-c);if(o[l-1]=s=ke(ke({},s),{},{tickCoord:v>0?s.coordinate-v*e:s.coordinate}),s.tickCoord!=null){var h=fn(e,s.tickCoord,()=>f,u,c);h&&(c=s.tickCoord-e*(f/2+a),o[l-1]=ke(ke({},s),{},{isShow:!0}))}}}for(var m=i?l-1:l,p=function(x){var A=o[x];if(A==null)return 1;var w=A,O,b=()=>(O===void 0&&(O=r(A,x)),O);if(x===0){var S=e*(w.coordinate-e*b()/2-u);o[x]=w=ke(ke({},w),{},{tickCoord:S<0?w.coordinate-S*e:w.coordinate})}else o[x]=w=ke(ke({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var I=fn(e,w.tickCoord,b,u,c);I&&(u=w.tickCoord+e*(b()/2+a),o[x]=ke(ke({},w),{},{isShow:!0}))}},y=0;y{var S=typeof c=="function"?c(O.value,b):O.value;return m==="width"?jj(tn(S,{fontSize:t,letterSpacing:r}),p,f):tn(S,{fontSize:t,letterSpacing:r})[m]},g=a[0],x=a[1],A=a.length>=2&&g!=null&&x!=null?we(x.coordinate-g.coordinate):1,w=Cj(i,A,m);return u==="equidistantPreserveStart"?$j(A,w,y,a,o):u==="equidistantPreserveEnd"?Mj(A,w,y,a,o):(u==="preserveStart"||u==="preserveStartEnd"?h=Rj(A,w,y,a,o,u==="preserveStartEnd"):h=Lj(A,w,y,a,o),h.filter(O=>O.isShow))}var Bj=e=>{var t=e.ticks,r=e.label,n=e.labelGapWithTick,a=n,i=e.tickSize,o=i===void 0?0:i,l=e.tickMargin,u=l===void 0?0:l,c=0;if(t){Array.from(t).forEach(h=>{if(h){var m=h.getBoundingClientRect();m.width>c&&(c=m.width)}});var s=r?r.getBoundingClientRect().width:0,f=o+u,v=c+f+s+(r?a:0);return Math.round(v)}return 0},zj={xAxis:{},yAxis:{}},Km=Te({name:"renderedTicks",initialState:zj,reducers:{setRenderedTicks:(e,t)=>{var r=t.payload,n=r.axisType,a=r.axisId,i=r.ticks;e[n][a]=q(i)},removeRenderedTicks:(e,t)=>{var r=t.payload,n=r.axisType,a=r.axisId;delete e[n][a]}}}),Wm=Km.actions,Kj=Wm.setRenderedTicks,Wj=Wm.removeRenderedTicks,Fj=Km.reducer,Uj=["axisLine","width","height","className","hide","ticks","axisType","axisId"];function Pf(e,t){return Yj(e)||Gj(e,t)||Vj(e,t)||Hj()}function Hj(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Vj(e,t){if(e){if(typeof e=="string")return Of(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Of(e,t):void 0}}function Of(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r{if(n==null||r==null)return or;var i=t.map(o=>({value:o.value,coordinate:o.coordinate,offset:o.offset,index:o.index}));return a(Kj({ticks:i,axisId:n,axisType:r})),()=>{a(Wj({axisId:n,axisType:r}))}},[a,t,n,r]),null}var oC=d.forwardRef((e,t)=>{var r=e.ticks,n=r===void 0?[]:r,a=e.tick,i=e.tickLine,o=e.stroke,l=e.tickFormatter,u=e.unit,c=e.padding,s=e.tickTextProps,f=e.orientation,v=e.mirror,h=e.x,m=e.y,p=e.width,y=e.height,g=e.tickSize,x=e.tickMargin,A=e.fontSize,w=e.letterSpacing,O=e.getTicksConfig,b=e.events,S=e.axisType,I=e.axisId,k=Jl(ce(ce({},O),{},{ticks:n}),A,w),E=Le(O),T=Jt(a),j=fm(E.textAnchor)?E.textAnchor:rC(f,v),N=nC(f,v),_={};typeof i=="object"&&(_=i);var R=ce(ce({},E),{},{fill:"none"},_),W=k.map(V=>ce({entry:V},tC(V,h,m,p,y,f,g,v,x))),F=W.map(V=>{var K=V.entry,le=V.line;return d.createElement(se,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(K.value,"-").concat(K.coordinate,"-").concat(K.tickCoord)},i&&d.createElement("line",ar({},R,le,{className:Z("recharts-cartesian-axis-tick-line",Qt(i,"className"))})))}),L=W.map((V,K)=>{var le,de,ae=V.entry,Me=V.tick,Be=ce(ce(ce(ce({verticalAnchor:N},E),{},{textAnchor:j,stroke:"none",fill:o},Me),{},{index:K,payload:ae,visibleTicksCount:k.length,tickFormatter:l,padding:c},s),{},{angle:(le=(de=s==null?void 0:s.angle)!==null&&de!==void 0?de:E.angle)!==null&&le!==void 0?le:0}),qe=ce(ce({},Be),T);return d.createElement(se,ar({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(ae.value,"-").concat(ae.coordinate,"-").concat(ae.tickCoord)},hn(b,ae,K)),a&&d.createElement(aC,{option:a,tickProps:qe,value:"".concat(typeof l=="function"?l(ae.value,K):ae.value).concat(u||"")}))});return d.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(S,"-ticks")},d.createElement(iC,{ticks:k,axisId:I,axisType:S}),L.length>0&&d.createElement(Re,{zIndex:he.label},d.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(S,"-tick-labels"),ref:t},L)),F.length>0&&d.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(S,"-tick-lines")},F))}),lC=d.forwardRef((e,t)=>{var r=e.axisLine,n=e.width,a=e.height,i=e.className,o=e.hide,l=e.ticks,u=e.axisType,c=e.axisId,s=qj(e,Uj),f=d.useState(""),v=Pf(f,2),h=v[0],m=v[1],p=d.useState(""),y=Pf(p,2),g=y[0],x=y[1],A=d.useRef(null);d.useImperativeHandle(t,()=>({getCalculatedWidth:()=>{var O;return Bj({ticks:A.current,label:(O=e.labelRef)===null||O===void 0?void 0:O.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}}));var w=d.useCallback(O=>{if(O){var b=O.getElementsByClassName("recharts-cartesian-axis-tick-value");A.current=b;var S=b[0];if(S){var I=window.getComputedStyle(S),k=I.fontSize,E=I.letterSpacing;(k!==h||E!==g)&&(m(k),x(E))}}},[h,g]);return o||n!=null&&n<=0||a!=null&&a<=0?null:d.createElement(Re,{zIndex:e.zIndex},d.createElement(se,{className:Z("recharts-cartesian-axis",i)},d.createElement(eC,{x:e.x,y:e.y,width:n,height:a,orientation:e.orientation,mirror:e.mirror,axisLine:r,otherSvgProps:Le(e)}),d.createElement(oC,{ref:w,axisType:u,events:s,fontSize:h,getTicksConfig:e,height:e.height,letterSpacing:g,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:l,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:c}),d.createElement(DI,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},d.createElement(UI,{label:e.label,labelRef:e.labelRef}),e.children)))}),eu=d.forwardRef((e,t)=>{var r=Ae(e,gt);return d.createElement(lC,ar({},r,{ref:t}))});eu.displayName="CartesianAxis";var uC=["x1","y1","x2","y2","key"],cC=["offset"],sC=["xAxisId","yAxisId"],fC=["xAxisId","yAxisId"];function If(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function je(e){for(var t=1;t{var t=e.fill;if(!t||t==="none")return null;var r=e.fillOpacity,n=e.x,a=e.y,i=e.width,o=e.height,l=e.ry;return d.createElement("rect",{x:n,y:a,ry:l,width:i,height:o,stroke:"none",fill:t,fillOpacity:r,className:"recharts-cartesian-grid-bg"})};function Fm(e){var t=e.option,r=e.lineItemProps,n;if(d.isValidElement(t))n=d.cloneElement(t,r);else if(typeof t=="function")n=t(r);else{var a,i=r.x1,o=r.y1,l=r.x2,u=r.y2,c=r.key,s=Pa(r,uC),f=(a=Le(s))!==null&&a!==void 0?a:{};f.offset;var v=Pa(f,cC);n=d.createElement("line",Xt({},v,{x1:i,y1:o,x2:l,y2:u,fill:"none",key:c}))}return n}function yC(e){var t=e.x,r=e.width,n=e.horizontal,a=n===void 0?!0:n,i=e.horizontalPoints;if(!a||!i||!i.length)return null;e.xAxisId,e.yAxisId;var o=Pa(e,sC),l=i.map((u,c)=>{var s=je(je({},o),{},{x1:t,y1:u,x2:t+r,y2:u,key:"line-".concat(c),index:c});return d.createElement(Fm,{key:"line-".concat(c),option:a,lineItemProps:s})});return d.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function gC(e){var t=e.y,r=e.height,n=e.vertical,a=n===void 0?!0:n,i=e.verticalPoints;if(!a||!i||!i.length)return null;e.xAxisId,e.yAxisId;var o=Pa(e,fC),l=i.map((u,c)=>{var s=je(je({},o),{},{x1:u,y1:t,x2:u,y2:t+r,key:"line-".concat(c),index:c});return d.createElement(Fm,{option:a,lineItemProps:s,key:"line-".concat(c)})});return d.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function bC(e){var t=e.horizontalFill,r=e.fillOpacity,n=e.x,a=e.y,i=e.width,o=e.height,l=e.horizontalPoints,u=e.horizontal,c=u===void 0?!0:u;if(!c||!t||!t.length||l==null)return null;var s=l.map(v=>Math.round(v+a-a)).sort((v,h)=>v-h);a!==s[0]&&s.unshift(0);var f=s.map((v,h)=>{var m=s[h+1],p=m==null,y=p?a+o-v:m-v;if(y<=0)return null;var g=h%t.length;return d.createElement("rect",{key:"react-".concat(h),y:v,x:n,height:y,width:i,stroke:"none",fill:t[g],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return d.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},f)}function xC(e){var t=e.vertical,r=t===void 0?!0:t,n=e.verticalFill,a=e.fillOpacity,i=e.x,o=e.y,l=e.width,u=e.height,c=e.verticalPoints;if(!r||!n||!n.length)return null;var s=c.map(v=>Math.round(v+i-i)).sort((v,h)=>v-h);i!==s[0]&&s.unshift(0);var f=s.map((v,h)=>{var m=s[h+1],p=m==null,y=p?i+l-v:m-v;if(y<=0)return null;var g=h%n.length;return d.createElement("rect",{key:"react-".concat(h),x:v,y:o,width:y,height:u,stroke:"none",fill:n[g],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return d.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},f)}var wC=(e,t)=>{var r=e.xAxis,n=e.width,a=e.height,i=e.offset;return Ed(Jl(je(je(je({},gt),r),{},{ticks:kd(r),viewBox:{x:0,y:0,width:n,height:a}})),i.left,i.left+i.width,t)},AC=(e,t)=>{var r=e.yAxis,n=e.width,a=e.height,i=e.offset;return Ed(Jl(je(je(je({},gt),r),{},{ticks:kd(r),viewBox:{x:0,y:0,width:n,height:a}})),i.top,i.top+i.height,t)},PC={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:he.grid};function OC(e){var t=Po(),r=Oo(),n=Nd(),a=je(je({},Ae(e,PC)),{},{x:$(e.x)?e.x:n.left,y:$(e.y)?e.y:n.top,width:$(e.width)?e.width:n.width,height:$(e.height)?e.height:n.height}),i=a.xAxisId,o=a.yAxisId,l=a.x,u=a.y,c=a.width,s=a.height,f=a.syncWithTicks,v=a.horizontalValues,h=a.verticalValues,m=$e(),p=M(k=>bs(k,"xAxis",i,m)),y=M(k=>bs(k,"yAxis",o,m));if(!ct(c)||!ct(s)||!$(l)||!$(u))return null;var g=a.verticalCoordinatesGenerator||wC,x=a.horizontalCoordinatesGenerator||AC,A=a.horizontalPoints,w=a.verticalPoints;if((!A||!A.length)&&typeof x=="function"){var O=v&&v.length,b=x({yAxis:y?je(je({},y),{},{ticks:O?v:y.ticks}):void 0,width:t??c,height:r??s,offset:n},O?!0:f);Qn(Array.isArray(b),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof b,"]")),Array.isArray(b)&&(A=b)}if((!w||!w.length)&&typeof g=="function"){var S=h&&h.length,I=g({xAxis:p?je(je({},p),{},{ticks:S?h:p.ticks}):void 0,width:t??c,height:r??s,offset:n},S?!0:f);Qn(Array.isArray(I),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof I,"]")),Array.isArray(I)&&(w=I)}return d.createElement(Re,{zIndex:a.zIndex},d.createElement("g",{className:"recharts-cartesian-grid"},d.createElement(pC,{fill:a.fill,fillOpacity:a.fillOpacity,x:a.x,y:a.y,width:a.width,height:a.height,ry:a.ry}),d.createElement(bC,Xt({},a,{horizontalPoints:A})),d.createElement(xC,Xt({},a,{verticalPoints:w})),d.createElement(yC,Xt({},a,{offset:n,horizontalPoints:A,xAxis:p,yAxis:y})),d.createElement(gC,Xt({},a,{offset:n,verticalPoints:w,xAxis:p,yAxis:y}))))}OC.displayName="CartesianGrid";var SC={},Um=Te({name:"errorBars",initialState:SC,reducers:{addErrorBar:(e,t)=>{var r=t.payload,n=r.itemId,a=r.errorBar;e[n]||(e[n]=[]),e[n].push(a)},replaceErrorBar:(e,t)=>{var r=t.payload,n=r.itemId,a=r.prev,i=r.next;e[n]&&(e[n]=e[n].map(o=>o.dataKey===a.dataKey&&o.direction===a.direction?i:o))},removeErrorBar:(e,t)=>{var r=t.payload,n=r.itemId,a=r.errorBar;e[n]&&(e[n]=e[n].filter(i=>i.dataKey!==a.dataKey||i.direction!==a.direction))}}}),tu=Um.actions;tu.addErrorBar;tu.replaceErrorBar;tu.removeErrorBar;var IC=Um.reducer,EC=["children"];function kC(e,t){if(e==null)return{};var r,n,a=jC(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n({x:0,y:0,value:0}),errorBarOffset:0},TC=d.createContext(CC);function $C(e){var t=e.children,r=kC(e,EC);return d.createElement(TC.Provider,{value:r},t)}function ru(e,t){var r,n,a=M(c=>St(c,e)),i=M(c=>It(c,t)),o=(r=a==null?void 0:a.allowDataOverflow)!==null&&r!==void 0?r:me.allowDataOverflow,l=(n=i==null?void 0:i.allowDataOverflow)!==null&&n!==void 0?n:pe.allowDataOverflow,u=o||l;return{needClip:u,needClipX:o,needClipY:l}}function Hm(e){var t=e.xAxisId,r=e.yAxisId,n=e.clipPathId,a=Ql(),i=ru(t,r),o=i.needClipX,l=i.needClipY,u=i.needClip,c=M(A=>gh(A,t,!1)),s=M(A=>bh(A,r,!1));if(!u||!a)return null;var f=a.x,v=a.y,h=a.width,m=a.height,p=o&&c?Math.min(c[0],c[1]):f-h/2,y=l&&s?Math.min(s[0],s[1]):v-m/2,g=o&&c?Math.abs(c[1]-c[0]):h*2,x=l&&s?Math.abs(s[1]-s[0]):m*2;return d.createElement("clipPath",{id:"clipPath-".concat(n)},d.createElement("rect",{x:p,y,width:g,height:x}))}function MC(e){var t=Jt(e),r=3,n=2;if(t!=null){var a=t.r,i=t.strokeWidth,o=Number(a),l=Number(i);return(Number.isNaN(o)||o<0)&&(o=r),(Number.isNaN(l)||l<0)&&(l=n),{r:o,strokeWidth:l}}return{r,strokeWidth:n}}function vt(e,t){var r,n;return(r=(n=e.graphicalItems.cartesianItems.find(a=>a.id===t))===null||n===void 0?void 0:n.xAxisId)!==null&&r!==void 0?r:_m}function ht(e,t){var r,n;return(r=(n=e.graphicalItems.cartesianItems.find(a=>a.id===t))===null||n===void 0?void 0:n.yAxisId)!==null&&r!==void 0?r:_m}var Vm=(e,t,r)=>_t(e,"xAxis",vt(e,t),r),Gm=(e,t,r)=>Dt(e,"xAxis",vt(e,t),r),Ym=(e,t,r)=>_t(e,"yAxis",ht(e,t),r),qm=(e,t,r)=>Dt(e,"yAxis",ht(e,t),r),DC=P([Y,Vm,Ym,Gm,qm],(e,t,r,n,a)=>ft(e,"xAxis")?Ar(t,n,!1):Ar(r,a,!1)),_C=(e,t)=>t,Xm=P([ei,_C],(e,t)=>e.filter(r=>r.type==="area").find(r=>r.id===t)),Zm=e=>{var t=Y(e),r=ft(t,"xAxis");return r?"yAxis":"xAxis"},NC=(e,t)=>{var r=Zm(e);return r==="yAxis"?ht(e,t):vt(e,t)},LC=(e,t,r)=>pa(e,Zm(e),NC(e,t),r),RC=P([Xm,LC],(e,t)=>{var r;if(!(e==null||t==null)){var n=e.stackId,a=Ua(e);if(!(n==null||a==null)){var i=(r=t[n])===null||r===void 0?void 0:r.stackedData,o=i==null?void 0:i.find(l=>l.key===a);if(o!=null)return o.map(l=>[l[0],l[1]])}}}),BC=P([Y,Vm,Ym,Gm,qm,RC,Jd,DC,Xm,Nx],(e,t,r,n,a,i,o,l,u,c)=>{var s=o.chartData,f=o.dataStartIndex,v=o.dataEndIndex;if(!(u==null||e!=="horizontal"&&e!=="vertical"||t==null||r==null||n==null||a==null||n.length===0||a.length===0||l==null)){var h=u.data,m;if(h&&h.length>0?m=h:m=s==null?void 0:s.slice(f,v+1),m!=null)return fT({layout:e,xAxis:t,yAxis:r,xAxisTicks:n,yAxisTicks:a,dataStartIndex:f,areaSettings:u,stackedData:i,displayedData:m,chartBaseValue:c,bandSize:l})}}),zC=["animationElapsedTime","isAnimating","isEntrance","layout","isRange","stroke","connectNulls"],KC=["id","baseLine"];function rn(){return rn=Object.assign?Object.assign.bind():function(e){for(var t=1;tf.y||0));return $(a)?s=Math.max(a,s):a&&Array.isArray(a)&&a.length&&(s=Math.max(...a.map(f=>f.y||0),s)),$(s)?d.createElement("rect",{x:lf.x||0));return $(a)?s=Math.max(a,s):a&&Array.isArray(a)&&a.length&&(s=Math.max(...a.map(f=>f.x||0),s)),$(s)?d.createElement("rect",{x:0,y:le==null?[]:t===1?e.flatMap(r=>r.status==="removed"?[]:[r.next]):e.flatMap(r=>r.status==="matched"?[jr(jr({},r.next),{},{x:ue(r.prev.x,r.next.x,t),y:ue(r.prev.y,r.next.y,t)})]:r.status==="added"?[r.next]:[]),Jm={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",animationMatchBy:Vl,animationInterpolateFn:JC,connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,shape:VC,xAxisId:0,yAxisId:0,zIndex:he.area};function Sa(e,t){return e&&e!=="none"?e:t}var eT=e=>{var t=e.dataKey,r=e.name,n=e.stroke,a=e.fill,i=e.legendType,o=e.hide;return[{inactive:o,dataKey:t,type:i,color:Sa(n,a),value:Cr(r,t),payload:e}]},tT=d.memo(e=>{var t=e.dataKey,r=e.data,n=e.stroke,a=e.strokeWidth,i=e.fill,o=e.name,l=e.hide,u=e.unit,c=e.tooltipType,s=e.id,f={dataDefinedOnItem:r,getPosition:or,settings:{stroke:n,strokeWidth:a,fill:i,dataKey:t,nameKey:void 0,name:Cr(o,t),hide:l,type:c,color:Sa(n,i),unit:u,graphicalItemId:s}};return d.createElement(Hl,{tooltipEntrySettings:f})});function rT(e){var t=e.clipPathId,r=e.points,n=e.props,a=n.needClip,i=n.dot,o=n.dataKey,l=Le(n);return d.createElement(Lk,{points:r,dot:i,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:a,clipPathId:t})}function nT(e){var t=e.showLabels,r=e.children,n=e.points,a=n.map(i=>{var o,l,u={x:(o=i.x)!==null&&o!==void 0?o:0,y:(l=i.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return jr(jr({},u),{},{value:i.value,payload:i.payload,parentViewBox:void 0,viewBox:u,fill:void 0})});return d.createElement(gm,{value:t?a:void 0},r)}function aT(e){var t=e.points,r=e.baseLine,n=e.needClip,a=e.clipPathId,i=e.props,o=e.animationElapsedTime,l=e.isAnimating,u=e.isEntrance,c=i.layout,s=i.type,f=i.stroke,v=i.connectNulls,h=i.isRange,m=i.shape,p=i.id,y=Qm(i,GC),g=Ke(y),x=jr(jr({},g),{},{id:p,points:t,connectNulls:v,type:s,baseLine:r,layout:c,stroke:f,isRange:h,animationElapsedTime:o,isAnimating:l,isEntrance:u});return d.createElement(d.Fragment,null,(t==null?void 0:t.length)>1&&d.createElement(se,{clipPath:n?"url(#clipPath-".concat(a,")"):void 0},d.createElement(Kl,{option:m,DefaultShape:Jm.shape,shapeProps:x})),d.createElement(rT,{points:t,props:y,clipPathId:a}))}function iT(e,t,r){if($(e)){var n=$(t)?t:void 0;return ue(n,e,r)}if(ie(e)||Je(e)){var a=$(t)?t:void 0;return ue(a,0,r)}return e}function oT(e){var t=e.needClip,r=e.clipPathId,n=e.props,a=e.previousPointsRef,i=e.previousBaselineRef,o=n.points,l=n.baseLine,u=n.isAnimationActive,c=n.animationBegin,s=n.animationDuration,f=n.animationEasing,v=n.animationMatchBy,h=n.animationInterpolateFn,m=d.useMemo(()=>({points:o,baseLine:l}),[o,l]),p=Cm(m,i),y=So(),g=ql(n.onAnimationStart,n.onAnimationEnd),x=g.isAnimating,A=g.handleAnimationStart,w=g.handleAnimationEnd,O=p.startValue;if(y==null)return null;var b;return Array.isArray(l)&&Array.isArray(O)?b=ro(O,l,v):Array.isArray(l)?b=ro(null,l,v):b=null,d.createElement(Xl,{animationInput:m,animationIdPrefix:"recharts-area-",items:o,previousItemsRef:a,isAnimationActive:u,animationBegin:c,animationDuration:s,animationEasing:f,onAnimationStart:A,onAnimationEnd:w,animationInterpolateFn:h,animationMatchBy:v,layout:y},(S,I,k)=>{var E;return I===1?E=l:Array.isArray(l)?E=h(b,I,y):E=k?l:iT(l,O,I),p.syncStepValue(E,I),d.createElement(nT,{showLabels:!x,points:o},n.children,d.createElement(aT,{points:S,baseLine:E,needClip:t,clipPathId:r,props:n,animationElapsedTime:I,isAnimating:x||I<1,isEntrance:k}),d.createElement(Ll,{label:n.label}))})}function lT(e){var t=e.needClip,r=e.clipPathId,n=e.props,a=d.useRef(null),i=d.useRef();return d.createElement(oT,{needClip:t,clipPathId:r,props:n,previousPointsRef:a,previousBaselineRef:i})}class uT extends d.PureComponent{render(){var t=this.props,r=t.hide,n=t.dot,a=t.points,i=t.className,o=t.top,l=t.left,u=t.needClip,c=t.xAxisId,s=t.yAxisId,f=t.width,v=t.height,h=t.id,m=t.baseLine,p=t.zIndex;if(r)return null;var y=Z("recharts-area",i),g=h,x=MC(n),A=x.r,w=x.strokeWidth,O=Em(n),b=A*2+w,S=u?"url(#clipPath-".concat(O?"":"dots-").concat(g,")"):void 0;return d.createElement(Re,{zIndex:p},d.createElement(se,{className:y},u&&d.createElement("defs",null,d.createElement(Hm,{clipPathId:g,xAxisId:c,yAxisId:s}),!O&&d.createElement("clipPath",{id:"clipPath-dots-".concat(g)},d.createElement("rect",{x:l-b/2,y:o-b/2,width:f+b,height:v+b}))),d.createElement(lT,{needClip:u,clipPathId:g,props:this.props})),d.createElement(pf,{points:a,mainColor:Sa(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:S}),this.props.isRange&&Array.isArray(m)&&d.createElement(pf,{points:m,mainColor:Sa(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:S}))}}function cT(e){var t,r=e.activeDot,n=e.animationBegin,a=e.animationDuration,i=e.animationEasing,o=e.connectNulls,l=e.dot,u=e.fill,c=e.fillOpacity,s=e.hide,f=e.isAnimationActive,v=e.legendType,h=e.stroke,m=e.xAxisId,p=e.yAxisId,y=Qm(e,YC),g=lr(),x=Qh(),A=ru(m,p),w=A.needClip,O=$e(),b=(t=M(R=>BC(R,e.id,O)))!==null&&t!==void 0?t:{},S=b.points,I=b.isRange,k=b.baseLine,E=Ql();if(g!=="horizontal"&&g!=="vertical"||E==null||x!=="AreaChart"&&x!=="ComposedChart")return null;var T=E.height,j=E.width,N=E.x,_=E.y;return!S||!S.length?null:d.createElement(uT,Oa({},y,{activeDot:r,animationBegin:n,animationDuration:a,animationEasing:i,baseLine:k,connectNulls:o,dot:l,fill:u,fillOpacity:c,height:T,hide:s,layout:g,isAnimationActive:f,isRange:I,legendType:v,needClip:w,points:S,stroke:h,width:j,left:N,top:_,xAxisId:m,yAxisId:p}))}var sT=(e,t,r,n,a)=>{var i=r??t;if($(i))return i;var o=e==="horizontal"?a:n,l=o.scale.domain();if(o.type==="number"){var u=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return i==="dataMin"?c:i==="dataMax"||u<0?u:Math.max(Math.min(l[0],l[1]),0)}return i==="dataMin"?l[0]:i==="dataMax"?l[1]:l[0]};function fT(e){var t=e.areaSettings,r=t.connectNulls,n=t.baseValue,a=t.dataKey,i=e.stackedData,o=e.layout,l=e.chartBaseValue,u=e.xAxis,c=e.yAxis,s=e.displayedData,f=e.dataStartIndex,v=e.xAxisTicks,h=e.yAxisTicks,m=e.bandSize,p=i&&i.length,y=sT(o,l,n,u,c),g=o==="horizontal",x=!1,A=s.map((O,b)=>{var S,I,k,E;if(p)E=i[f+b];else{var T=Q(O,a);Array.isArray(T)?(E=T,x=!0):E=[y,T]}var j=(S=(I=E)===null||I===void 0?void 0:I[1])!==null&&S!==void 0?S:null,N=j==null||p&&!r&&Q(O,a)==null;if(g){var _;return{x:Pu({axis:u,ticks:v,bandSize:m,entry:O,index:b}),y:N?null:(_=c.scale.map(j))!==null&&_!==void 0?_:null,value:E,payload:O}}return{x:N?null:(k=u.scale.map(j))!==null&&k!==void 0?k:null,y:Pu({axis:c,ticks:h,bandSize:m,entry:O,index:b}),value:E,payload:O}}),w;return p||x?w=A.map(O=>{var b,S=Array.isArray(O.value)?O.value[0]:null;if(g){var I;return{x:O.x,y:S!=null&&O.y!=null&&(I=c.scale.map(S))!==null&&I!==void 0?I:null,payload:O.payload}}return{x:S!=null&&(b=u.scale.map(S))!==null&&b!==void 0?b:null,y:O.y,payload:O.payload}}):w=g?c.scale.map(y):u.scale.map(y),{points:A,baseLine:w??0,isRange:x}}function dT(e){var t=Ae(e,Jm),r=$e();return d.createElement(Zl,{id:t.id,type:"area"},n=>d.createElement(d.Fragment,null,d.createElement(jm,{legendPayload:eT(t)}),d.createElement(tT,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:n}),d.createElement(Mm,{type:"area",id:n,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:jd(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:r,connectNulls:t.connectNulls}),d.createElement(cT,Oa({},t,{id:n}))))}var vT=d.memo(dT,Tr);vT.displayName="Area";var hT=["option"];function mT(e,t){if(e==null)return{};var r,n,a=pT(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n1&&arguments[1]!==void 0?arguments[1]:0;return(n,a)=>{if($(t))return t;var i=$(n)||ie(n);return i?t(n,a):(i||Tp(),r)}},gT=(e,t,r)=>r,bT=(e,t)=>t,Cn=P([ei,bT],(e,t)=>e.filter(r=>r.type==="bar").find(r=>r.id===t)),xT=P([Cn],e=>e==null?void 0:e.maxBarSize),wT=(e,t,r,n)=>n,AT=P([Y,ei,vt,ht,gT],(e,t,r,n,a)=>t.filter(i=>e==="horizontal"?i.xAxisId===r:i.yAxisId===n).filter(i=>i.isPanorama===a).filter(i=>i.hide===!1).filter(i=>i.type==="bar")),PT=(e,t,r)=>{var n=Y(e),a=vt(e,t),i=ht(e,t);if(!(a==null||i==null))return n==="horizontal"?pa(e,"yAxis",i,r):pa(e,"xAxis",a,r)},OT=(e,t)=>{var r=Y(e),n=vt(e,t),a=ht(e,t);if(!(n==null||a==null))return r==="horizontal"?gs(e,"xAxis",n):gs(e,"yAxis",a)},ST=P([AT,_x,OT],uj),IT=(e,t,r)=>{var n,a,i=Cn(e,t);if(i==null)return 0;var o=vt(e,t),l=ht(e,t);if(o==null||l==null)return 0;var u=Y(e),c=ov(e),s=i.maxBarSize,f=ie(s)?c:s,v,h;return u==="horizontal"?(v=_t(e,"xAxis",o,r),h=Dt(e,"xAxis",o,r)):(v=_t(e,"yAxis",l,r),h=Dt(e,"yAxis",l,r)),(n=(a=Ar(v,h,!0))!==null&&a!==void 0?a:f)!==null&&n!==void 0?n:0},ep=(e,t,r)=>{var n=Y(e),a=vt(e,t),i=ht(e,t);if(!(a==null||i==null)){var o,l;return n==="horizontal"?(o=_t(e,"xAxis",a,r),l=Dt(e,"xAxis",a,r)):(o=_t(e,"yAxis",i,r),l=Dt(e,"yAxis",i,r)),Ar(o,l)}},ET=P([ST,ov,Dx,lv,IT,ep,xT],vj),kT=(e,t,r)=>{var n=vt(e,t);if(n!=null)return _t(e,"xAxis",n,r)},jT=(e,t,r)=>{var n=ht(e,t);if(n!=null)return _t(e,"yAxis",n,r)},CT=(e,t,r)=>{var n=vt(e,t);if(n!=null)return Dt(e,"xAxis",n,r)},TT=(e,t,r)=>{var n=ht(e,t);if(n!=null)return Dt(e,"yAxis",n,r)},$T=P([ET,Cn],mj),MT=P([PT,Cn],hj),DT=P([ge,xo,kT,jT,CT,TT,$T,Y,Jd,ep,MT,Cn,wT],(e,t,r,n,a,i,o,l,u,c,s,f,v)=>{var h=u.chartData,m=u.dataStartIndex,p=u.dataEndIndex;if(!(f==null||o==null||t==null||l!=="horizontal"&&l!=="vertical"||r==null||n==null||a==null||i==null||c==null)){var y=f.data,g;if(y!=null&&y.length>0?g=y:g=h==null?void 0:h.slice(m,p+1),g!=null)return v$({layout:l,barSettings:f,pos:o,parentViewBox:t,bandSize:c,xAxis:r,yAxis:n,xAxisTicks:a,yAxisTicks:i,stackedData:s,displayedData:g,offset:e,cells:v,dataStartIndex:m})}}),_T=["index"];function no(){return no=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t=d.useContext(tp);if(t!=null)return t.stackId;if(e!=null)return jd(e)},BT=(e,t)=>"recharts-bar-stack-clip-path-".concat(e,"-").concat(t),zT=e=>{var t=d.useContext(tp);if(t!=null){var r=t.stackId;return"url(#".concat(BT(r,e),")")}},rp=e=>{var t=e.index,r=NT(e,_T),n=zT(t);return d.createElement(se,no({className:"recharts-bar-stack-layer",clipPath:n},r))},KT=["onMouseEnter","onMouseLeave","onClick"],WT=["value","background","tooltipPosition"],FT=["id"],UT=["onMouseEnter","onClick","onMouseLeave"];function jf(e,t){return YT(e)||GT(e,t)||VT(e,t)||HT()}function HT(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function VT(e,t){if(e){if(typeof e=="string")return Cf(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Cf(e,t):void 0}}function Cf(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r{var t=e.dataKey,r=e.name,n=e.fill,a=e.legendType,i=e.hide;return[{inactive:i,dataKey:t,type:a,color:n,value:Cr(r,t),payload:e}]},e$=d.memo(e=>{var t=e.dataKey,r=e.stroke,n=e.strokeWidth,a=e.fill,i=e.name,o=e.hide,l=e.unit,u=e.tooltipType,c=e.id,s={dataDefinedOnItem:void 0,getPosition:or,settings:{stroke:r,strokeWidth:n,fill:a,dataKey:t,nameKey:void 0,name:Cr(i,t),hide:o,type:u,color:a,unit:l,graphicalItemId:c}};return d.createElement(Hl,{tooltipEntrySettings:s})});function t$(e){var t=M(Nt),r=e.data,n=e.dataKey,a=e.background,i=e.allOtherBarProps,o=i.onMouseEnter,l=i.onMouseLeave,u=i.onClick,c=Ia(i,KT),s=Wl(o,n,i.id),f=Fl(l),v=Ul(u,n,i.id);if(!a||r==null)return null;var h=Jt(a);return d.createElement(Re,{zIndex:pj(a,he.barBackground)},r.map((m,p)=>{m.value;var y=m.background;m.tooltipPosition;var g=Ia(m,WT);if(!y)return null;var x=s(m,m.originalDataIndex),A=f(m,m.originalDataIndex),w=v(m,m.originalDataIndex),O=ye(ye(ye(ye(ye({option:a,isActive:String(m.originalDataIndex)===t},g),{},{fill:"#eee"},y),h),hn(c,m,p)),{},{onMouseEnter:x,onMouseLeave:A,onClick:w,dataKey:n,index:p,className:"recharts-bar-background-rectangle"});return d.createElement(au,Lt({key:"background-bar-".concat(p)},O))}))}function r$(e){var t=e.showLabels,r=e.children,n=e.rects,a=n==null?void 0:n.map(i=>{var o={x:i.x,y:i.y,width:i.width,lowerWidth:i.width,upperWidth:i.width,height:i.height};return ye(ye({},o),{},{value:i.value,payload:i.payload,parentViewBox:i.parentViewBox,viewBox:o,fill:i.fill})});return d.createElement(gm,{value:t?a:void 0},r)}function n$(e){var t=e.shape,r=e.activeBar,n=e.baseProps,a=e.entry,i=e.index,o=e.dataKey,l=M(Nt),u=M(jl),c=r&&String(a.originalDataIndex)===l&&(u==null||o===u),s=d.useState(!1),f=jf(s,2),v=f[0],h=f[1],m=d.useState(!1),p=jf(m,2),y=p[0],g=p[1];d.useEffect(()=>{var S;return c?(h(!0),S=requestAnimationFrame(()=>{g(!0)})):g(!1),()=>{cancelAnimationFrame(S)}},[c]);var x=d.useCallback(()=>{c||h(!1)},[c]),A=c&&y,w=c||v,O;c?r===!0?O=t:O=r:O=t;var b=d.createElement(au,Lt({},n,{name:String(n.name)},a,{isActive:A,option:O,index:i,dataKey:o,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance,onTransitionEnd:x}));return w?d.createElement(Re,{zIndex:he.activeBar},d.createElement(rp,{index:a.originalDataIndex},b)):b}function a$(e){var t=e.shape,r=e.baseProps,n=e.entry,a=e.index,i=e.dataKey;return d.createElement(au,Lt({},r,{name:String(r.name)},n,{isActive:!1,option:t,index:a,dataKey:i,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance}))}function i$(e){var t,r=e.data,n=e.props,a=e.animationElapsedTime,i=e.isAnimating,o=e.isEntrance,l=(t=Le(n))!==null&&t!==void 0?t:{},u=l.id,c=Ia(l,FT),s=n.shape,f=n.dataKey,v=n.activeBar,h=n.onMouseEnter,m=n.onClick,p=n.onMouseLeave,y=Ia(n,UT),g=Wl(h,f,u),x=Fl(p),A=Ul(m,f,u);return r?d.createElement(d.Fragment,null,r.map((w,O)=>d.createElement(rp,Lt({index:w.originalDataIndex,key:"rectangle-".concat(w==null?void 0:w.x,"-").concat(w==null?void 0:w.y,"-").concat(w==null?void 0:w.value,"-").concat(O),className:"recharts-bar-rectangle"},hn(y,w,O),{onMouseEnter:g(w,w.originalDataIndex),onMouseLeave:x(w,w.originalDataIndex),onClick:A(w,w.originalDataIndex)}),v?d.createElement(n$,{shape:s,activeBar:v,baseProps:c,entry:w,index:O,dataKey:f,animationElapsedTime:a,isAnimating:i,isEntrance:o}):d.createElement(a$,{shape:s,baseProps:c,entry:w,index:O,dataKey:f,animationElapsedTime:a,isAnimating:i,isEntrance:o})))):null}var o$=(e,t,r)=>e==null?[]:t===1?e.flatMap(n=>n.status==="removed"?[]:[n.next]):e.flatMap(n=>{if(n.status==="removed")return r==="horizontal"?[ye(ye({},n.prev),{},{height:ue(n.prev.height,0,t),y:ue(n.prev.y,n.prev.y+n.prev.height,t)})]:[ye(ye({},n.prev),{},{width:ue(n.prev.width,0,t)})];if(n.status==="matched")return[ye(ye({},n.next),{},{x:ue(n.prev.x,n.next.x,t),y:ue(n.prev.y,n.next.y,t),width:ue(n.prev.width,n.next.width,t),height:ue(n.prev.height,n.next.height,t)})];var a=n.next;return r==="horizontal"?[ye(ye({},a),{},{height:ue(0,a.height,t),y:ue(a.stackedBarStart,a.y,t)})]:[ye(ye({},a),{},{width:ue(0,a.width,t),x:ue(a.stackedBarStart,a.x,t)})]});function l$(e){var t=e.props,r=e.previousRectanglesRef,n=t.data,a=t.isAnimationActive,i=t.animationBegin,o=t.animationDuration,l=t.animationEasing,u=t.animationInterpolateFn,c=t.layout,s=ql(t.onAnimationStart,t.onAnimationEnd),f=s.isAnimating,v=s.handleAnimationStart,h=s.handleAnimationEnd;return d.createElement(r$,{showLabels:!f,rects:n},d.createElement(Xl,{animationInput:n,animationIdPrefix:"recharts-bar-",items:n,previousItemsRef:r,isAnimationActive:a,animationBegin:i,animationDuration:o,animationEasing:l,onAnimationStart:v,onAnimationEnd:h,animationInterpolateFn:u,animationMatchBy:t.animationMatchBy,layout:c},(m,p,y)=>d.createElement(se,null,d.createElement(i$,{props:t,data:m,animationElapsedTime:p,isAnimating:f||p<1,isEntrance:y}))),d.createElement(Ll,{label:t.label}),t.children)}function u$(e){var t=d.useRef(null);return d.createElement(l$,{previousRectanglesRef:t,props:e})}var np=0,c$=(e,t)=>{var r=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:r,errorVal:Q(e,t)}};class s$ extends d.PureComponent{render(){var t=this.props,r=t.hide,n=t.data,a=t.dataKey,i=t.className,o=t.xAxisId,l=t.yAxisId,u=t.needClip,c=t.background,s=t.id;if(r||n==null)return null;var f=Z("recharts-bar",i),v=s;return d.createElement(se,{className:f,id:s},u&&d.createElement("defs",null,d.createElement(Hm,{clipPathId:v,xAxisId:o,yAxisId:l})),d.createElement(se,{className:"recharts-bar-rectangles",clipPath:u?"url(#clipPath-".concat(v,")"):void 0},d.createElement(t$,{data:n,dataKey:a,background:c,allOtherBarProps:this.props}),d.createElement(u$,this.props)))}}var f$={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",animationInterpolateFn:o$,animationMatchBy:Gl,background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:np,shape:nu,xAxisId:0,yAxisId:0,zIndex:he.bar};function d$(e){var t=e.xAxisId,r=e.yAxisId,n=e.hide,a=e.legendType,i=e.minPointSize,o=e.activeBar,l=e.animationBegin,u=e.animationDuration,c=e.animationEasing,s=e.isAnimationActive,f=ru(t,r),v=f.needClip,h=lr(),m=$e(),p=zl(e.children,oi),y=M(A=>DT(A,e.id,m,p));if(h!=="vertical"&&h!=="horizontal")return null;var g,x=y==null?void 0:y[0];return x==null||x.height==null||x.width==null?g=0:g=h==="vertical"?x.height/2:x.width/2,d.createElement($C,{xAxisId:t,yAxisId:r,data:y,dataPointFormatter:c$,errorBarOffset:g},d.createElement(s$,Lt({},e,{layout:h,needClip:v,data:y,xAxisId:t,yAxisId:r,hide:n,legendType:a,minPointSize:i,activeBar:o,animationBegin:l,animationDuration:u,animationEasing:c,isAnimationActive:s})))}function v$(e){var t=e.layout,r=e.barSettings,n=r.dataKey,a=r.minPointSize,i=r.hasCustomShape,o=e.pos,l=e.bandSize,u=e.xAxis,c=e.yAxis,s=e.xAxisTicks,f=e.yAxisTicks,v=e.stackedData,h=e.displayedData,m=e.offset,p=e.cells,y=e.parentViewBox,g=e.dataStartIndex,x=t==="horizontal"?c:u,A=v?x.scale.domain():null,w=Og({numericAxis:x}),O=x.scale.map(w);return h.map((b,S)=>{var I,k,E,T,j,N;if(v){var _=v[S+g];if(_==null)return null;I=bg(_,A)}else I=Q(b,n),Array.isArray(I)||(I=[w,I]);var R=yT(a,np)(I[1],S);if(t==="horizontal"){var W,F=c.scale.map(I[0]),L=c.scale.map(I[1]);if(F==null||L==null)return null;k=Ou({axis:u,ticks:s,bandSize:l,offset:o.offset,entry:b,index:S}),E=(W=L??F)!==null&&W!==void 0?W:void 0,T=o.size;var V=F-L;if(j=Je(V)?0:V,N={x:k,y:m.top,width:T,height:m.height},Math.abs(R)>0&&Math.abs(j)0&&Math.abs(T)d.createElement(d.Fragment,null,d.createElement(jm,{legendPayload:JT(t)}),d.createElement(e$,{dataKey:t.dataKey,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:a}),d.createElement(Mm,{type:"bar",id:a,data:void 0,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,stackId:r,hide:t.hide,barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize,isPanorama:n,hasCustomShape:t.shape!=null&&t.shape!==nu}),d.createElement(Re,{zIndex:t.zIndex},d.createElement(d$,Lt({},t,{id:a})))))}var m$=d.memo(h$,Tr);m$.displayName="Bar";var p$=["domain","range"],y$=["domain","range"];function $f(e,t){if(e==null)return{};var r,n,a=g$(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n{if(o!=null)return _f(_f({},i),{},{type:o})},[i,o]);return d.useLayoutEffect(()=>{l!=null&&(r.current===null?t(Wk(l)):r.current!==l&&t(Fk({prev:r.current,next:l})),r.current=l)},[l,t]),d.useLayoutEffect(()=>()=>{r.current&&(t(Uk(r.current)),r.current=null)},[t]),null}var E$=e=>{var t=e.xAxisId,r=e.className,n=M(xo),a=$e(),i="xAxis",o=M(v=>Eh(v,i,t,a)),l=M(v=>Oh(v,t)),u=M(v=>hO(v,t)),c=M(v=>eh(v,t));if(l==null||u==null||c==null)return null;e.dangerouslySetInnerHTML,e.ticks,e.scale;var s=io(e,x$);c.id,c.scale;var f=io(c,w$);return d.createElement(eu,ao({},s,f,{x:u.x,y:u.y,width:l.width,height:l.height,className:Z("recharts-".concat(i," ").concat(i),r),viewBox:n,ticks:o,axisType:i,axisId:t}))},k$={allowDataOverflow:me.allowDataOverflow,allowDecimals:me.allowDecimals,allowDuplicatedCategory:me.allowDuplicatedCategory,angle:me.angle,axisLine:gt.axisLine,height:me.height,hide:!1,includeHidden:me.includeHidden,interval:me.interval,label:!1,minTickGap:me.minTickGap,mirror:me.mirror,orientation:me.orientation,padding:me.padding,reversed:me.reversed,scale:me.scale,tick:me.tick,tickCount:me.tickCount,tickLine:gt.tickLine,tickSize:gt.tickSize,type:me.type,niceTicks:me.niceTicks,xAxisId:0},j$=e=>{var t=Ae(e,k$);return d.createElement(d.Fragment,null,d.createElement(I$,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),d.createElement(E$,t))},C$=d.memo(j$,ap);C$.displayName="XAxis";var T$=["type"],$$=["dangerouslySetInnerHTML","ticks","scale"],M$=["id","scale"];function oo(){return oo=Object.assign?Object.assign.bind():function(e){for(var t=1;t{if(o!=null)return Lf(Lf({},i),{},{type:o})},[o,i]);return d.useLayoutEffect(()=>{l!=null&&(r.current===null?t(Hk(l)):r.current!==l&&t(Vk({prev:r.current,next:l})),r.current=l)},[l,t]),d.useLayoutEffect(()=>()=>{r.current&&(t(Gk(r.current)),r.current=null)},[t]),null}function B$(e){var t=e.yAxisId,r=e.className,n=e.width,a=e.label,i=d.useRef(null),o=d.useRef(null),l=M(xo),u=$e(),c=ee(),s="yAxis",f=M(g=>Sh(g,t)),v=M(g=>pO(g,t)),h=M(g=>Eh(g,s,t,u)),m=M(g=>th(g,t));if(d.useLayoutEffect(()=>{if(!(n!=="auto"||!f||Nl(a)||d.isValidElement(a)||m==null)){var g=i.current;if(g){var x=g.getCalculatedWidth();Math.round(f.width)!==Math.round(x)&&c(Yk({id:t,width:x}))}}},[h,f,c,a,t,n,m]),f==null||v==null||m==null)return null;e.dangerouslySetInnerHTML,e.ticks,e.scale;var p=lo(e,$$);m.id,m.scale;var y=lo(m,M$);return d.createElement(eu,oo({},p,y,{ref:i,labelRef:o,x:v.x,y:v.y,tickTextProps:n==="auto"?{width:void 0}:{width:n},width:f.width,height:f.height,className:Z("recharts-".concat(s," ").concat(s),r),viewBox:l,ticks:h,axisType:s,axisId:t}))}var z$={allowDataOverflow:pe.allowDataOverflow,allowDecimals:pe.allowDecimals,allowDuplicatedCategory:pe.allowDuplicatedCategory,angle:pe.angle,axisLine:gt.axisLine,hide:!1,includeHidden:pe.includeHidden,interval:pe.interval,label:!1,minTickGap:pe.minTickGap,mirror:pe.mirror,orientation:pe.orientation,padding:pe.padding,reversed:pe.reversed,scale:pe.scale,tick:pe.tick,tickCount:pe.tickCount,tickLine:gt.tickLine,tickSize:gt.tickSize,type:pe.type,niceTicks:pe.niceTicks,width:pe.width,yAxisId:0},K$=e=>{var t=Ae(e,z$);return d.createElement(d.Fragment,null,d.createElement(R$,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),d.createElement(B$,t))},W$=d.memo(K$,ap);W$.displayName="YAxis";var F$=(e,t)=>t,iu=P([F$,Y,hv,Pe,Hh,Et,L1,ge],U1);function U$(e){return"getBBox"in e.currentTarget&&typeof e.currentTarget.getBBox=="function"}function ou(e){var t=e.currentTarget.getBoundingClientRect(),r,n;if(U$(e)){var a=e.currentTarget.getBBox();r=a.width>0?t.width/a.width:1,n=a.height>0?t.height/a.height:1}else{var i=e.currentTarget;r=i.offsetWidth>0?t.width/i.offsetWidth:1,n=i.offsetHeight>0?t.height/i.offsetHeight:1}var o=(l,u)=>({relativeX:Math.round((l-t.left)/r),relativeY:Math.round((u-t.top)/n)});return"touches"in e?Array.from(e.touches).map(l=>o(l.clientX,l.clientY)):o(e.clientX,e.clientY)}var ip=ir("mouseClick"),op=dn();op.startListening({actionCreator:ip,effect:(e,t)=>{var r=e.payload,n=iu(t.getState(),ou(r));(n==null?void 0:n.activeIndex)!=null&&t.dispatch($O({activeIndex:n.activeIndex,activeDataKey:void 0,activeCoordinate:n.activeCoordinate}))}});var uo=ir("mouseMove"),lp=dn(),pr=null,Ft=null,Ci=null;lp.startListening({actionCreator:uo,effect:(e,t)=>{var r=e.payload,n=t.getState(),a=n.eventSettings,i=a.throttleDelay,o=a.throttledEvents,l=o==="all"||(o==null?void 0:o.includes("mousemove"));pr!==null&&(cancelAnimationFrame(pr),pr=null),Ft!==null&&(typeof i!="number"||!l)&&(clearTimeout(Ft),Ft=null),Ci=ou(r);var u=()=>{var c=t.getState(),s=kn(c,c.tooltip.settings.shared);if(!Ci){pr=null,Ft=null;return}if(s==="axis"){var f=iu(c,Ci);(f==null?void 0:f.activeIndex)!=null?t.dispatch(_h({activeIndex:f.activeIndex,activeDataKey:void 0,activeCoordinate:f.activeCoordinate})):t.dispatch(Dh())}pr=null,Ft=null};if(!l){u();return}i==="raf"?pr=requestAnimationFrame(u):typeof i=="number"&&Ft===null&&(Ft=setTimeout(u,i))}});function H$(e,t){return t instanceof HTMLElement?"HTMLElement <".concat(t.tagName,' class="').concat(t.className,'">'):t===window?"global.window":e==="children"&&typeof t=="object"&&t!==null?"<>":t}var Rf={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index",baseValue:void 0,reverseStackOrder:!1},up=Te({name:"rootProps",initialState:Rf,reducers:{updateOptions:(e,t)=>{var r;e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=(r=t.payload.barGap)!==null&&r!==void 0?r:Rf.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),V$=up.reducer,G$=up.actions.updateOptions,Y$=null,q$={updatePolarOptions:(e,t)=>e===null?t.payload:(e.startAngle=t.payload.startAngle,e.endAngle=t.payload.endAngle,e.cx=t.payload.cx,e.cy=t.payload.cy,e.innerRadius=t.payload.innerRadius,e.outerRadius=t.payload.outerRadius,e)},cp=Te({name:"polarOptions",initialState:Y$,reducers:q$}),X$=cp.actions.updatePolarOptions,Z$=cp.reducer,sp=ir("keyDown"),fp=ir("focus"),dp=ir("blur"),di=dn(),yr=null,Ut=null,Kn=null;di.startListening({actionCreator:sp,effect:(e,t)=>{Kn=e.payload,yr!==null&&(cancelAnimationFrame(yr),yr=null);var r=t.getState(),n=r.eventSettings,a=n.throttleDelay,i=n.throttledEvents,o=i==="all"||i.includes("keydown");Ut!==null&&(typeof a!="number"||!o)&&(clearTimeout(Ut),Ut=null);var l=()=>{try{var u=t.getState(),c=u.rootProps.accessibilityLayer!==!1;if(!c)return;var s=u.tooltip.keyboardInteraction,f=Kn;if(f!=="ArrowRight"&&f!=="ArrowLeft"&&f!=="Enter")return;var v=en(s,rr(u),Er(u),kr(u)),h=v==null?-1:Number(v),m=!Number.isFinite(h)||h<0,p=Et(u),y=rr(u),g=kn(u,u.tooltip.settings.shared);if(f==="Enter"){if(m)return;var x=ba(u,g,"hover",String(s.index));t.dispatch(ga({active:!s.active,activeIndex:s.index,activeCoordinate:x}));return}var A=wO(u),w=A==="left-to-right"?1:-1,O=f==="ArrowRight"?1:-1,b;if(m){var S=Er(u),I=kr(u),k=O*w,E=R=>({active:!1,index:String(R),dataKey:void 0,graphicalItemId:void 0,coordinate:void 0});if(b=-1,k>0){for(var T=0;T=0;j--)if(en(E(j),y,S,I)!=null){b=j;break}if(b<0)return}else{b=h+O*w;var N=(p==null?void 0:p.length)||y.length;if(N===0||b>=N||b<0)return}var _=ba(u,g,"hover",String(b));t.dispatch(ga({active:!0,activeIndex:b.toString(),activeCoordinate:_}))}finally{yr=null,Ut=null}};if(!o){l();return}a==="raf"?yr=requestAnimationFrame(l):typeof a=="number"&&Ut===null&&(l(),Kn=null,Ut=setTimeout(()=>{Kn?l():(Ut=null,yr=null)},a))}});di.startListening({actionCreator:fp,effect:(e,t)=>{var r=t.getState(),n=r.rootProps.accessibilityLayer!==!1;if(n){var a=r.tooltip.keyboardInteraction;if(!a.active&&a.index==null){var i="0",o=kn(r,r.tooltip.settings.shared),l=ba(r,o,"hover",String(i));t.dispatch(ga({active:!0,activeIndex:i,activeCoordinate:l}))}}}});di.startListening({actionCreator:dp,effect:(e,t)=>{var r=t.getState(),n=r.rootProps.accessibilityLayer!==!1;if(n){var a=r.tooltip.keyboardInteraction;a.active&&t.dispatch(ga({active:!1,activeIndex:a.index,activeCoordinate:a.coordinate}))}}});function vp(e){e.persist();var t=e.currentTarget;return new Proxy(e,{get:(r,n)=>{if(n==="currentTarget")return t;var a=Reflect.get(r,n);return typeof a=="function"?a.bind(r):a}})}var Ue=ir("externalEvent"),hp=dn(),Wn=new Map,qr=new Map,Ti=new Map;hp.startListening({actionCreator:Ue,effect:(e,t)=>{var r=e.payload,n=r.handler,a=r.reactEvent;if(n!=null){var i=a.type,o=vp(a);Ti.set(i,{handler:n,reactEvent:o});var l=Wn.get(i);l!==void 0&&(cancelAnimationFrame(l),Wn.delete(i));var u=t.getState(),c=u.eventSettings,s=c.throttleDelay,f=c.throttledEvents,v=f,h=v==="all"||(v==null?void 0:v.includes(i)),m=qr.get(i);m!==void 0&&(typeof s!="number"||!h)&&(clearTimeout(m),qr.delete(i));var p=()=>{var x=Ti.get(i);try{if(!x)return;var A=x.handler,w=x.reactEvent,O=t.getState(),b={activeCoordinate:A1(O),activeDataKey:jl(O),activeIndex:Nt(O),activeLabel:Yh(O),activeTooltipIndex:Nt(O),isTooltipActive:P1(O)};A&&A(b,w)}finally{Wn.delete(i),qr.delete(i),Ti.delete(i)}};if(!h){p();return}if(s==="raf"){var y=requestAnimationFrame(p);Wn.set(i,y)}else if(typeof s=="number"){if(!qr.has(i)){p();var g=setTimeout(p,s);qr.set(i,g)}}else p()}}});var Q$=P([Lr],e=>e.tooltipItemPayloads),J$=P([Q$,(e,t)=>t,(e,t,r)=>r],(e,t,r)=>{if(t!=null){var n=e.find(i=>i.settings.graphicalItemId===r);if(n!=null){var a=n.getPosition;if(a!=null)return a(t)}}}),mp=ir("touchMove"),pp=dn(),Ht=null,kt=null,Bf=null,Xr=null;pp.startListening({actionCreator:mp,effect:(e,t)=>{var r=e.payload;if(!(r.touches==null||r.touches.length===0)){Xr=vp(r);var n=t.getState(),a=n.eventSettings,i=a.throttleDelay,o=a.throttledEvents,l=o==="all"||o.includes("touchmove");Ht!==null&&(cancelAnimationFrame(Ht),Ht=null),kt!==null&&(typeof i!="number"||!l)&&(clearTimeout(kt),kt=null),Bf=Array.from(r.touches).map(c=>ou({clientX:c.clientX,clientY:c.clientY,currentTarget:r.currentTarget}));var u=()=>{if(Xr!=null){var c=t.getState(),s=kn(c,c.tooltip.settings.shared);if(s==="axis"){var f,v=(f=Bf)===null||f===void 0?void 0:f[0];if(v==null){Ht=null,kt=null;return}var h=iu(c,v);(h==null?void 0:h.activeIndex)!=null&&t.dispatch(_h({activeIndex:h.activeIndex,activeDataKey:void 0,activeCoordinate:h.activeCoordinate}))}else if(s==="item"){var m,p=Xr.touches[0];if(document.elementFromPoint==null||p==null)return;var y=document.elementFromPoint(p.clientX,p.clientY);if(!y||!y.getAttribute)return;var g=y.getAttribute(Td),x=(m=y.getAttribute($d))!==null&&m!==void 0?m:void 0,A=sr(c).find(b=>b.id===x);if(g==null||A==null||x==null)return;var w=A.dataKey,O=J$(c,g,x);t.dispatch(Mh({activeDataKey:w,activeIndex:g,activeCoordinate:O,activeGraphicalItemId:x}))}Ht=null,kt=null}};if(!l){u();return}i==="raf"?Ht=requestAnimationFrame(u):typeof i=="number"&&kt===null&&(u(),Xr=null,kt=setTimeout(()=>{Xr?u():(kt=null,Ht=null)},i))}}});var lu={throttleDelay:"raf",throttledEvents:["mousemove","touchmove","pointermove","scroll","wheel"]},yp=Te({name:"eventSettings",initialState:lu,reducers:{setEventSettings:(e,t)=>{t.payload.throttleDelay!=null&&(e.throttleDelay=t.payload.throttleDelay),t.payload.throttledEvents!=null&&(e.throttledEvents=q(t.payload.throttledEvents))}}}),eM=yp.actions.setEventSettings,tM=yp.reducer,rM=Mp({brush:yj,cartesianAxis:qk,chartData:yS,errorBars:IC,eventSettings:tM,graphicalItems:ZE,layout:hg,legend:db,options:dS,polarAxis:oE,polarOptions:Z$,referenceElements:wj,renderedTicks:Fj,rootProps:V$,tooltip:MO,zIndex:nS}),nM=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Chart";return $p({reducer:rM,preloadedState:t,middleware:n=>{var a;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((a="es6")!==null&&a!==void 0?a:"")}).concat([op.middleware,lp.middleware,di.middleware,hp.middleware,pp.middleware])},enhancers:n=>{var a=n;return typeof n=="function"&&(a=n()),a.concat(Dp({type:"raf"}))},devTools:{serialize:{replacer:H$},name:"recharts-".concat(r)}})};function gp(e){var t=e.preloadedState,r=e.children,n=e.reduxStoreName,a=$e(),i=d.useRef(null);if(a)return r;i.current==null&&(i.current=nM(t,n));var o=bo;return d.createElement(_p,{context:o,store:i.current},r)}function aM(e){var t=e.layout,r=e.margin,n=ee(),a=$e();return d.useEffect(()=>{a||(n(fg(t)),n(sg(r)))},[n,a,t,r]),null}var bp=d.memo(aM,Tr);function xp(e){var t=ee();return d.useEffect(()=>{t(G$(e))},[t,e]),null}var iM=e=>{var t=ee();return d.useEffect(()=>{t(eM(e))},[t,e]),null},wp=d.memo(iM,Tr);function zf(e){var t=e.zIndex,r=e.isPanorama,n=d.useRef(null),a=ee();return d.useLayoutEffect(()=>(n.current&&a(tS({zIndex:t,element:n.current,isPanorama:r})),()=>{a(rS({zIndex:t,isPanorama:r}))}),[a,t,r]),d.createElement("g",{tabIndex:-1,ref:n,className:"recharts-zIndex-layer_".concat(t)})}function Kf(e){var t=e.children,r=e.isPanorama,n=M(V1);if(!n||n.length===0)return t;var a=n.filter(o=>o<0),i=n.filter(o=>o>0);return d.createElement(d.Fragment,null,a.map(o=>d.createElement(zf,{key:o,zIndex:o,isPanorama:r})),t,i.map(o=>d.createElement(zf,{key:o,zIndex:o,isPanorama:r})))}var oM=["children"];function lM(e,t){if(e==null)return{};var r,n,a=uM(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n{var r=Po(),n=Oo(),a=Wd();if(!ct(r)||!ct(n))return null;var i=e.children,o=e.otherAttributes,l=e.title,u=e.desc,c,s;return o!=null&&(typeof o.tabIndex=="number"?c=o.tabIndex:c=a?0:void 0,typeof o.role=="string"?s=o.role:s=a?"application":void 0),d.createElement(ho,Ea({},o,{title:l,desc:u,role:s,tabIndex:c,width:r,height:n,style:cM,ref:t}),i)}),fM=e=>{var t=e.children,r=M(Ra);if(!r)return null;var n=r.width,a=r.height,i=r.y,o=r.x;return d.createElement(ho,{width:n,height:a,x:o,y:i},t)},Wf=d.forwardRef((e,t)=>{var r=e.children,n=lM(e,oM),a=$e();return a?d.createElement(fM,null,d.createElement(Kf,{isPanorama:!0},r)):d.createElement(sM,Ea({ref:t},n),d.createElement(Kf,{isPanorama:!1},r))});function dM(e,t){return pM(e)||mM(e,t)||hM(e,t)||vM()}function vM(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hM(e,t){if(e){if(typeof e=="string")return Ff(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ff(e,t):void 0}}function Ff(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r{if(n!=null){var o=n.getBoundingClientRect(),l=o.width/n.offsetWidth;H(l)&&l!==i&&e(vg(l))}},[n,e,i]),a}function Uf(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function gM(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=Array(t);r(IS(),null);function ja(e){if(typeof e=="number")return e;if(typeof e=="string"){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var EM=d.forwardRef((e,t)=>{var r,n,a=d.useRef(null),i=d.useState({containerWidth:ja((r=e.style)===null||r===void 0?void 0:r.width),containerHeight:ja((n=e.style)===null||n===void 0?void 0:n.height)}),o=ka(i,2),l=o[0],u=o[1],c=d.useCallback((f,v)=>{u(h=>{var m=Math.round(f),p=Math.round(v);return h.containerWidth===m&&h.containerHeight===p?h:{containerWidth:m,containerHeight:p}})},[]),s=d.useCallback(f=>{if(typeof t=="function"&&t(f),a.current!=null&&(a.current.disconnect(),a.current=null),f!=null&&typeof ResizeObserver<"u"){var v=f.getBoundingClientRect(),h=v.width,m=v.height;c(h,m);var p=g=>{var x=g[0];if(x!=null){var A=x.contentRect,w=A.width,O=A.height;c(w,O)}},y=new ResizeObserver(p);y.observe(f),a.current=y}},[t,c]);return d.useEffect(()=>()=>{var f=a.current;f!=null&&f.disconnect()},[c]),d.createElement(d.Fragment,null,d.createElement(pn,{width:l.containerWidth,height:l.containerHeight}),d.createElement("div",Mt({ref:s},e)))}),kM=d.forwardRef((e,t)=>{var r=e.width,n=e.height,a=d.useState({containerWidth:ja(r),containerHeight:ja(n)}),i=ka(a,2),o=i[0],l=i[1],u=d.useCallback((s,f)=>{l(v=>{var h=Math.round(s),m=Math.round(f);return v.containerWidth===h&&v.containerHeight===m?v:{containerWidth:h,containerHeight:m}})},[]),c=d.useCallback(s=>{if(typeof t=="function"&&t(s),s!=null){var f=s.getBoundingClientRect(),v=f.width,h=f.height;u(v,h)}},[t,u]);return d.createElement(d.Fragment,null,d.createElement(pn,{width:o.containerWidth,height:o.containerHeight}),d.createElement("div",Mt({ref:c},e)))}),jM=d.forwardRef((e,t)=>{var r=e.width,n=e.height;return d.createElement(d.Fragment,null,d.createElement(pn,{width:r,height:n}),d.createElement("div",Mt({ref:t},e)))}),CM=d.forwardRef((e,t)=>{var r=e.width,n=e.height;return typeof r=="string"||typeof n=="string"?d.createElement(kM,Mt({},e,{ref:t})):typeof r=="number"&&typeof n=="number"?d.createElement(jM,Mt({},e,{width:r,height:n,ref:t})):d.createElement(d.Fragment,null,d.createElement(pn,{width:r,height:n}),d.createElement("div",Mt({ref:t},e)))});function TM(e){return e?EM:CM}var $M=d.forwardRef((e,t)=>{var r=e.children,n=e.className,a=e.height,i=e.onClick,o=e.onContextMenu,l=e.onDoubleClick,u=e.onMouseDown,c=e.onMouseEnter,s=e.onMouseLeave,f=e.onMouseMove,v=e.onMouseUp,h=e.onTouchEnd,m=e.onTouchMove,p=e.onTouchStart,y=e.style,g=e.width,x=e.responsive,A=e.dispatchTouchEvents,w=A===void 0?!0:A,O=d.useRef(null),b=ee(),S=d.useState(null),I=ka(S,2),k=I[0],E=I[1],T=d.useState(null),j=ka(T,2),N=j[0],_=j[1],R=yM(),W=wo(),F=(W==null?void 0:W.width)>0?W.width:g,L=(W==null?void 0:W.height)>0?W.height:a,V=d.useCallback(B=>{R(B),typeof t=="function"&&t(B),E(B),_(B),B!=null&&(O.current=B)},[R,t,E,_]),K=d.useCallback(B=>{b(ip(B)),b(Ue({handler:i,reactEvent:B}))},[b,i]),le=d.useCallback(B=>{b(uo(B)),b(Ue({handler:c,reactEvent:B}))},[b,c]),de=d.useCallback(B=>{b(Dh()),b(Ue({handler:s,reactEvent:B}))},[b,s]),ae=d.useCallback(B=>{b(uo(B)),b(Ue({handler:f,reactEvent:B}))},[b,f]),Me=d.useCallback(()=>{b(fp())},[b]),Be=d.useCallback(()=>{b(dp())},[b]),qe=d.useCallback(B=>{b(sp(B.key))},[b]),Xe=d.useCallback(B=>{b(Ue({handler:o,reactEvent:B}))},[b,o]),zr=d.useCallback(B=>{b(Ue({handler:l,reactEvent:B}))},[b,l]),D=d.useCallback(B=>{b(Ue({handler:u,reactEvent:B}))},[b,u]),U=d.useCallback(B=>{b(Ue({handler:v,reactEvent:B}))},[b,v]),z=d.useCallback(B=>{b(Ue({handler:p,reactEvent:B}))},[b,p]),C=d.useCallback(B=>{w&&b(mp(B)),b(Ue({handler:m,reactEvent:B}))},[b,w,m]),Ee=d.useCallback(B=>{b(Ue({handler:h,reactEvent:B}))},[b,h]),J=TM(x);return d.createElement(nm.Provider,{value:k},d.createElement(Jf.Provider,{value:N},d.createElement(J,{width:F??(y==null?void 0:y.width),height:L??(y==null?void 0:y.height),className:Z("recharts-wrapper",n),style:gM({position:"relative",cursor:"default",width:F,height:L},y),onClick:K,onContextMenu:Xe,onDoubleClick:zr,onFocus:Me,onBlur:Be,onKeyDown:qe,onMouseDown:D,onMouseEnter:le,onMouseLeave:de,onMouseMove:ae,onMouseUp:U,onTouchEnd:Ee,onTouchMove:C,onTouchStart:z,ref:V},d.createElement(IM,null),r)))}),MM=["width","height","responsive","children","className","style","compact","title","desc"];function DM(e,t){if(e==null)return{};var r,n,a=_M(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n{var r=e.width,n=e.height,a=e.responsive,i=e.children,o=e.className,l=e.style,u=e.compact,c=e.title,s=e.desc,f=DM(e,MM),v=Le(f);return u?d.createElement(d.Fragment,null,d.createElement(pn,{width:r,height:n}),d.createElement(Wf,{otherAttributes:v,title:c,desc:s},i)):d.createElement($M,{className:o,style:l,width:r,height:n,responsive:a??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},d.createElement(Wf,{otherAttributes:v,title:c,desc:s,ref:t},d.createElement(kj,null,i)))});function co(){return co=Object.assign?Object.assign.bind():function(e){for(var t=1;td.createElement(Pp,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:WM,tooltipPayloadSearcher:Dl,categoricalChartProps:e,ref:t}));function FM(e){var t=ee();return d.useEffect(()=>{t(X$(e))},[t,e]),null}var UM=["layout"];function so(){return so=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var r=Ae(e,nD);return d.createElement(QM,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:rD,tooltipPayloadSearcher:Dl,categoricalChartProps:r,ref:t})}),aD=["axis"],fD=d.forwardRef((e,t)=>d.createElement(Pp,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:aD,tooltipPayloadSearcher:Dl,categoricalChartProps:e,ref:t}));export{fD as A,cD as B,oi as C,Db as L,sD as P,lD as R,uD as T,C$ as X,W$ as Y,m$ as a,OC as b,vT as c,kk as d}; diff --git a/internal/webui/static/assets/icons-vendor-BmeuAUrP.js b/internal/webui/static/assets/icons-vendor-BmeuAUrP.js new file mode 100644 index 0000000..b981899 --- /dev/null +++ b/internal/webui/static/assets/icons-vendor-BmeuAUrP.js @@ -0,0 +1,346 @@ +import{r as s}from"./react-vendor-DZnRGM0-.js";/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),M=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,c,o)=>o?o.toUpperCase():c.toLowerCase()),y=t=>{const a=M(t);return a.charAt(0).toUpperCase()+a.slice(1)},k=(...t)=>t.filter((a,c,o)=>!!a&&a.trim()!==""&&o.indexOf(a)===c).join(" ").trim(),v=t=>{for(const a in t)if(a.startsWith("aria-")||a==="role"||a==="title")return!0};/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var x={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const g=s.forwardRef(({color:t="currentColor",size:a=24,strokeWidth:c=2,absoluteStrokeWidth:o,className:n="",children:h,iconNode:r,...d},i)=>s.createElement("svg",{ref:i,...x,width:a,height:a,stroke:t,strokeWidth:o?Number(c)*24/Number(a):c,className:k("lucide",n),...!h&&!v(d)&&{"aria-hidden":"true"},...d},[...r.map(([p,l])=>s.createElement(p,l)),...Array.isArray(h)?h:[h]]));/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const e=(t,a)=>{const c=s.forwardRef(({className:o,...n},h)=>s.createElement(g,{ref:h,iconNode:a,className:k(`lucide-${_(y(t))}`,`lucide-${t}`,o),...n}));return c.displayName=y(t),c};/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const m=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],H1=e("activity",m);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const u=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],L1=e("arrow-right",u);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const w=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],V1=e("bell",w);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],P1=e("bot",$);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const N=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],S1=e("box",N);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const f=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],U1=e("check",f);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const b=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],E1=e("chevron-down",b);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const C=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],B1=e("chevron-left",C);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const q=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],D1=e("chevron-right",q);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const z=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],R1=e("circle-alert",z);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const A=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],T1=e("circle-check",A);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const j=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],Z1=e("circle-dashed",j);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const H=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],I1=e("clock-3",H);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const L=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],K1=e("clock",L);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const V=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],O1=e("cloud-upload",V);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const P=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],W1=e("code",P);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const S=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],F1=e("copy",S);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const U=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],G1=e("credit-card",U);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const E=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Q1=e("database",E);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const B=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],J1=e("dollar-sign",B);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const D=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],X1=e("external-link",D);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const R=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Y1=e("eye-off",R);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const T=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],e0=e("eye",T);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Z=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],a0=e("file-down",Z);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const I=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],t0=e("file-text",I);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const K=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],c0=e("gift",K);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const O=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],o0=e("image",O);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const W=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],h0=e("key",W);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const F=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],s0=e("layers",F);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const G=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],n0=e("layout-dashboard",G);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Q=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],d0=e("link-2",Q);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const J=[["path",{d:"M16 5H3",key:"m91uny"}],["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 19H3",key:"zzsher"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]],y0=e("list-plus",J);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const X=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],k0=e("loader-circle",X);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Y=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],r0=e("lock-keyhole",Y);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const e1=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],i0=e("lock",e1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const a1=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],p0=e("log-out",a1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const t1=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],l0=e("mail",t1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const c1=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],_0=e("message-circle",c1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const o1=[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],M0=e("package-check",o1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const h1=[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],v0=e("package-plus",h1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const s1=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],x0=e("package",s1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const n1=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],g0=e("pen",n1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const d1=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],m0=e("plus",d1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const y1=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],u0=e("power",y1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const k1=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],w0=e("qr-code",k1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const r1=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],$0=e("refresh-cw",r1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const i1=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],N0=e("save",i1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const p1=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],f0=e("search",p1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const l1=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],b0=e("send",l1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _1=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],C0=e("settings",_1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const M1=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],q0=e("shield-check",M1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const v1=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],z0=e("shopping-bag",v1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const x1=[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]],A0=e("shopping-cart",x1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const g1=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],j0=e("sparkles",g1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const m1=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],H0=e("square-pen",m1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const u1=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],L0=e("trash-2",u1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const w1=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],V0=e("trending-up",w1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $1=[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]],P0=e("truck",$1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const N1=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],S0=e("upload",N1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const f1=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],U0=e("user-round",f1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const b1=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],E0=e("user",b1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const C1=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],B0=e("users",C1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const q1=[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]],D0=e("webhook",q1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const z1=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],R0=e("x",z1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const A1=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],T0=e("zap",A1);export{E1 as $,H1 as A,S1 as B,G1 as C,J1 as D,X1 as E,t0 as F,W1 as G,y0 as H,o0 as I,a0 as J,h0 as K,n0 as L,v0 as M,O1 as N,T1 as O,x0 as P,w0 as Q,$0 as R,z0 as S,V0 as T,B0 as U,Z1 as V,d0 as W,R0 as X,L1 as Y,T0 as Z,Q1 as _,V1 as a,r0 as a0,U0 as a1,q0 as a2,_0 as a3,I1 as a4,c0 as a5,s0 as a6,b0 as a7,l0 as a8,D0 as a9,i0 as aa,C0 as b,j0 as c,p0 as d,A0 as e,M0 as f,k0 as g,E0 as h,U1 as i,P1 as j,R1 as k,K1 as l,g0 as m,u0 as n,L0 as o,Y1 as p,e0 as q,N0 as r,m0 as s,P0 as t,f0 as u,H0 as v,B1 as w,D1 as x,S0 as y,F1 as z}; diff --git a/internal/webui/static/assets/index-BVGBdlzO.js b/internal/webui/static/assets/index-BVGBdlzO.js new file mode 100644 index 0000000..e94422d --- /dev/null +++ b/internal/webui/static/assets/index-BVGBdlzO.js @@ -0,0 +1,19 @@ +import{j as e,r as o,b as ue,c as ut,d as pt}from"./react-vendor-DZnRGM0-.js";import{L as ht,U as Js,S as Ys,C as us,B as Gs,Z as ps,a as qe,b as bs,c as Ks,d as gt,A as Ns,D as bt,e as vs,P as Xs,f as Ge,E as Zs,T as yt,g as _e,Q as is,h as hs,i as Fe,j as Te,k as ls,l as ws,R as ke,m as Hs,n as ft,o as Ae,X as xe,K as jt,p as Ye,q as Be,r as Le,s as De,t as _s,u as Nt,v as ze,w as vt,x as wt,y as Je,z as _t,F as ks,I as Cs,G as Ss,H as kt,J as Ct,M as os,N as Ze,O as et,V as St,W as $t,Y as gs,_ as It,$ as At,a0 as $s,a1 as Dt,a2 as st,a3 as as,a4 as tt,a5 as Lt,a6 as Pt,a7 as ys,a8 as at,a9 as Ft,aa as Rt}from"./icons-vendor-BmeuAUrP.js";import{R as He,B as Et,X as Is,Y as As,T as ds,a as Ot,C as cs,A as Mt,b as Tt,c as qt,P as Ds,d as Ls,L as Bt}from"./charts-vendor-B_BfwiL0.js";import"./vendor-w5t2K9ux.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))h(u);new MutationObserver(u=>{for(const m of u)if(m.type==="childList")for(const w of m.addedNodes)w.tagName==="LINK"&&w.rel==="modulepreload"&&h(w)}).observe(document,{childList:!0,subtree:!0});function r(u){const m={};return u.integrity&&(m.integrity=u.integrity),u.referrerPolicy&&(m.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?m.credentials="include":u.crossOrigin==="anonymous"?m.credentials="omit":m.credentials="same-origin",m}function h(u){if(u.ep)return;u.ep=!0;const m=r(u);fetch(u.href,m)}})();const zt=({activeTab:s,onNavigate:a,onLogout:r})=>{const h=[{id:"dashboard",icon:ht,label:"仪表盘"},{id:"accounts",icon:Js,label:"账号管理"},{id:"orders",icon:Ys,label:"订单管理"},{id:"cards",icon:us,label:"卡密库存"},{id:"items",icon:Gs,label:"商品列表"},{id:"rules",icon:ps,label:"自动化规则"},{id:"notifications",icon:qe,label:"通知设置"},{id:"settings",icon:bs,label:"系统与AI"}];return e.jsxs("div",{className:"w-64 h-screen fixed left-0 top-0 bg-white border-r border-gray-100 flex flex-col justify-between z-20 shadow-[4px_0_24px_rgba(0,0,0,0.02)]",children:[e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-12 px-2",children:[e.jsx("div",{className:"w-10 h-10 bg-[#0094f7] squircle flex items-center justify-center shrink-0 p-1.5",style:{filter:"drop-shadow(0 4px 12px rgba(0,148,247,0.25))"},children:e.jsx("img",{src:"/static/ydisks-logo.svg",alt:"Ydisks",className:"w-full h-full"})}),e.jsxs("h1",{className:"text-xl font-extrabold tracking-tight text-gray-900",children:["Ydisks闲鱼助手 ",e.jsx("span",{className:"text-xs bg-[#0094f7] text-white px-1.5 py-0.5 rounded ml-1",children:"PRO"})]})]}),e.jsx("nav",{className:"space-y-2",children:h.map(u=>{const m=u.icon,w=s===u.id;return e.jsxs("button",{onClick:()=>a(u.id),className:`w-full flex items-center gap-3 px-4 py-3.5 rounded-2xl transition-all duration-300 group relative overflow-hidden ${w?"bg-[#0094f7] text-white font-bold shadow-lg shadow-blue-100 transform scale-[1.02]":"text-gray-500 hover:bg-gray-50 hover:text-gray-900"}`,children:[e.jsx(m,{className:`w-5 h-5 transition-colors ${w?"text-white":"text-gray-400 group-hover:text-gray-600"}`}),e.jsx("span",{className:"text-sm tracking-wide",children:u.label}),w&&e.jsx(Ks,{className:"w-4 h-4 absolute right-3 text-white/30 animate-pulse"})]},u.id)})})]}),e.jsx("div",{className:"p-6 border-t border-gray-50",children:e.jsxs("button",{onClick:r,className:"w-full flex items-center gap-3 px-4 py-3 text-gray-500 hover:text-red-500 hover:bg-red-50 rounded-2xl transition-all duration-200 font-medium",children:[e.jsx(gt,{className:"w-5 h-5"}),e.jsx("span",{className:"text-sm",children:"退出登录"})]})})]})},Ut=s=>{if(!s)return"";const a=new URLSearchParams;for(const[h,u]of Object.entries(s))u!=null&&a.set(h,String(u));const r=a.toString();return r?`?${r}`:""},ns=async(s,a,r={})=>{const h=Ut(r.params),u=`${a}${h}`,m=await fetch(u,{method:s,credentials:"include",headers:{...r.body===void 0?{}:{"Content-Type":"application/json"}},body:r.body===void 0?void 0:JSON.stringify(r.body)}),I=(m.headers.get("content-type")||"").includes("application/json");if(!m.ok){const p=I?await m.json().catch(()=>{}):await m.text().catch(()=>{}),W=typeof p=="string"?p:(p==null?void 0:p.detail)||(p==null?void 0:p.message)||(p==null?void 0:p.msg);throw new Error(W||`请求失败: ${m.status}`)}return I?await m.json():await m.text()},ie=async(s,a)=>ns("GET",s,{params:a}),de=async(s,a)=>ns("POST",s,{body:a}),fe=async(s,a)=>ns("PUT",s,{body:a}),Ee=async(s,a)=>ns("DELETE",s,{params:a}),fs=async(s,a)=>{const r=await fetch(s,{method:"POST",credentials:"include",body:a}),m=(r.headers.get("content-type")||"").includes("application/json")?await r.json().catch(()=>{}):await r.text().catch(()=>{});if(!r.ok){const w=typeof m=="string"?m:(m==null?void 0:m.detail)||(m==null?void 0:m.message)||(m==null?void 0:m.msg),I=new Error(w||"请求失败: "+r.status);throw I.payload=m,I}return m},Wt=new Set(["registration_enabled","show_default_login_info","item_sync_enabled"]),Qt=s=>{const a={...s};for(const r of Wt)r in a&&(a[r]=a[r]===!0||a[r]==="true"||a[r]==="1"||a[r]===1);return a},Vt=async s=>de("/login",s),lt=async()=>ie("/verify"),Jt=async s=>fe("/account/credentials",s),Yt=async(s,a,r)=>de("/cookies",{id:s,value:a,login_method:r}),Gt=(s,a)=>{const r=s.avatar_url||"";if(!r)return"";try{const h=new URL(r,window.location.origin);return h.hostname.endsWith("alicdn.com")&&h.searchParams.set("_v",a),h.toString()}catch{return r}},js=async()=>{const s=await ie("/cookies/details"),a=Date.now().toString();return s.map(r=>({id:r.id,value:"",cookie:"",enabled:r.enabled,auto_confirm:r.auto_confirm,remark:r.remark,note:r.remark,pause_duration:r.pause_duration,username:r.username||"",login_password:"",show_browser:r.show_browser===!0||r.show_browser===1||r.show_browser==="1"||r.show_browser==="true",nickname:r.nickname||r.remark||`账号 ${r.id.substring(0,6)}`,avatar_url:Gt(r,a),profile_error:r.profile_error||"",ai_enabled:!1}))},Kt=async()=>ie("/cookies/runtime-status"),Xt=async()=>de("/qr-login/generate"),Zt=async s=>ie(`/qr-login/check/${s}`),Ht=async(s,a)=>fe(`/cookies/${s}/status`,{enabled:a}),ea=async s=>Ee(`/cookies/${s}`),sa=async(s,a)=>fe(`/cookies/${s}/remark`,{remark:a}),ta=async(s,a)=>fe(`/cookies/${s}/auto-confirm`,{auto_confirm:a}),aa=async(s,a)=>fe(`/cookies/${s}/pause-duration`,{pause_duration:a}),Ps=async(s,a,r)=>fe(`/cookies/${s}`,{id:s,value:a,login_method:r}),la=async s=>de(`/cookies/${s}/refresh-profile`,{}),ra=async(s,a)=>fe(`/cookies/${s}/login-info`,a),na=async()=>ie("/ai-reply-settings"),Fs=async(s,a,r=1,h=20)=>{const u={page:r,page_size:h};a&&a!=="all"&&(u.status=a);const m=await ie("/api/orders",u),I=(m.orders||m.data||[]).map(p=>({...p,id:p.id||p.order_id,status:p.status||p.order_status||"processing",quantity:Number(p.quantity||1)}));return{success:!0,data:I,total:m.total||I.length,page:m.page||r,page_size:m.page_size||h,total_pages:m.total_pages||1}},ia=async(s,a)=>fe(`/api/orders/${s}`,a),oa=async s=>Ee(`/api/orders/${s}`),da=async(s,a)=>{const r=new FormData,h=await fetch("/api/orders/refresh",{method:"POST",credentials:"include",body:r}),u=await h.json().catch(()=>({}));if(!h.ok||u.success===!1)throw new Error(u.detail||u.message||`订单同步失败: ${h.status}`);return u},ca=async s=>de(`/api/orders/${s}/refresh`),xa=async(s,a,r)=>de("/api/orders/manual-ship",{order_ids:s,ship_mode:a,custom_content:r}),ma=async s=>{const a=s instanceof FormData,r=await fetch("/api/orders/import",{method:"POST",credentials:"include",headers:{...a?{}:{"Content-Type":"application/json"}},body:a?s:JSON.stringify(s)}),h=await r.json().catch(()=>({}));if(!r.ok||h.success===!1)throw new Error(h.detail||h.message||`订单导入失败: ${r.status}`);return h},ua=async()=>ie("/admin/stats"),Rs=async(s=7)=>{let a;if(typeof s=="number"){const r=new Date,h=new Date;h.setDate(h.getDate()-s),a={start_date:h.toISOString().split("T")[0],end_date:r.toISOString().split("T")[0]}}else a=s;return ie("/analytics/orders",a)},pa=async s=>{const a=await ie("/analytics/orders/valid",{start_date:s.start_date,end_date:s.end_date});return(Array.isArray(a)?a:a.orders||[]).map(h=>({...h,id:h.id||h.order_id,status:h.status||h.order_status||"processing",quantity:Number(h.quantity||1)}))},ha=s=>{let a=s.api_config;if(typeof a=="string"&&a.trim())try{a=JSON.parse(a)}catch{a=void 0}return{...s,api_config:a||void 0}},rt=s=>({...s,api_config:s.api_config?JSON.stringify(s.api_config):""}),Ie=async()=>{const s=await ie("/cards");return(Array.isArray(s)?s:s.cards||[]).map(ha)},ga=async s=>de("/cards",rt(s)),Es=async(s,a)=>fe(`/cards/${s}`,rt(a)),ba=async s=>Ee(`/cards/${s}`),ya=async s=>{const a=new FormData;return a.append("file",s),fs("/cards/batch",a)},fa=async(s,a)=>de(`/cards/${s}/append-data`,{content:a}),xs=s=>s===!0||s===1||s==="1",Ue=async()=>{const s=await ie("/items");return(Array.isArray(s)?s:s.items||[]).map(r=>({...r,id:r.id||`${r.cookie_id}-${r.item_id}`,is_multi_spec:xs(r.is_multi_spec),is_multi_qty_ship:xs(r.is_multi_qty_ship??r.multi_quantity_delivery),multi_quantity_delivery:xs(r.multi_quantity_delivery??r.is_multi_qty_ship)}))},ja=async s=>de("/items/get-all-from-account",{cookie_id:s}),Na=async(s,a)=>Ee(`/items/${s}/${a}`),va=async(s,a)=>de(`/items/${s}`,a),wa=async s=>{const a=new FormData;a.set("cookie_id",s.cookie_id),a.set("title",s.title),a.set("description",s.description),a.set("price",s.price),a.set("original_price",s.original_price||""),a.set("quantity",String(s.quantity)),a.set("postage_mode",s.postage_mode),a.set("postage",s.postage||"");for(const r of s.images)a.append("images",r);return fs("/items/publish",a)},_a=async s=>{const a=new FormData;return a.set("file",s.file),s.imagesZip&&a.set("images_zip",s.imagesZip),s.defaultCookieId&&a.set("default_cookie_id",s.defaultCookieId),fs("/items/publish-batches/preview",a)},ka=async s=>de("/items/publish-batches",{preview_id:s}),es=async s=>ie(`/items/publish-batches/${s}`),Ca=async s=>de(`/items/publish-batches/${s}/cancel`,{}),Sa=async s=>de(`/items/publish-batches/${s}/retry-failed`,{}),$a=async(s,a,r)=>fe(`/items/${s}/${a}`,r),rs=async()=>{const s=await ie("/automation-rules");return(Array.isArray(s)?s:s.data||s.rules||[]).map(r=>{var h,u;return{id:String(r.id),name:r.name||"",trigger_type:r.trigger_type||"order_paid",item_keyword:r.item_title||r.item_id||"",cookie_id:r.cookie_id||"",item_id:r.item_id||"",item_title:r.item_title||"",card_group_id:Number(((h=(r.actions||[]).find(m=>m.action_type==="send_card"))==null?void 0:h.card_id)||0),card_group_name:((u=(r.actions||[]).find(m=>m.action_type==="send_card"))==null?void 0:u.card_name)||"",priority:r.priority||100,enabled:r.enabled||!1,config_json:r.config_json||"{}",actions:(r.actions||[]).map(m=>({id:m.id?String(m.id):void 0,action_type:m.action_type,card_id:Number(m.card_id||0),card_name:m.card_name||"",delivery_count:Number(m.delivery_count||1),message_template:m.message_template||"",delay_seconds:Number(m.delay_seconds||0),config_json:m.config_json||"{}",enabled:m.enabled!==!1,sort_order:Number(m.sort_order||0)})),variants:(r.actions||[]).filter(m=>m.action_type==="send_card").map(m=>{let w={};try{w=JSON.parse(m.config_json||"{}")}catch{}return{id:m.id?String(m.id):void 0,spec_name:w.spec_name||"",spec_value:w.spec_value||"",card_id:Number(m.card_id||0),card_name:m.card_name||"",delivery_count:Number(m.delivery_count||1),enabled:m.enabled!==!1,config_json:m.config_json||"{}"}})}})},Ia=(s,a)=>{if(s!=="order_paid")return a.map((u,m)=>({...u,sort_order:u.sort_order||m+1}));const r=a.filter(u=>u.action_type==="send_card").map((u,m)=>({...u,sort_order:m+1})),h=a.filter(u=>u.action_type!=="send_card"&&u.action_type!=="confirm_shipment");return[...r,...h.map((u,m)=>({...u,sort_order:r.length+m+1})),{action_type:"confirm_shipment",enabled:!0,sort_order:r.length+h.length+1}]},Os=async s=>{const a=s.trigger_type||"order_paid",h=[{order_paid:"付款后自动发货",buyer_reviewed:"评价后发送赠品",review_missing_timeout:"超时未评价求评价"}[a]||"自动化规则",s.item_title||s.item_id||s.cookie_id||""].filter(Boolean).join(" - "),u=s.variants&&s.variants.length>0?s.variants.map((I,p)=>({action_type:"send_card",card_id:I.card_id,delivery_count:I.delivery_count||1,enabled:I.enabled!==!1,sort_order:p+1,config_json:JSON.stringify({spec_name:I.spec_name||"",spec_value:I.spec_value||""})})):s.actions&&s.actions.length>0?s.actions:[{action_type:"send_card",card_id:s.card_group_id||0,delivery_count:1,enabled:!0,sort_order:1}],m=Ia(a,u),w={cookie_id:s.cookie_id||"",item_id:s.item_id||"",name:(s.name||"").trim()||h||"自动化规则",trigger_type:a,enabled:s.enabled??!0,priority:s.priority||100,config_json:s.config_json||"{}",actions:m.map((I,p)=>({action_type:I.action_type,card_id:I.card_id||0,delivery_count:I.delivery_count||1,message_template:I.message_template||"",delay_seconds:I.delay_seconds||0,config_json:I.config_json||"{}",enabled:I.enabled!==!1,sort_order:I.sort_order||p+1}))};return s.id?fe(`/automation-rules/${s.id}`,w):de("/automation-rules",w)},Aa=async s=>Ee(`/automation-rules/${s}`),Da=async s=>{if(!s)return[];const a=await ie(`/keywords-with-item-id/${s}`);return(Array.isArray(a)?a:[]).map((h,u)=>({id:String(u),keyword:h.keyword||"",reply_content:h.reply||"",match_type:"exact",enabled:!0}))},La=async(s,a)=>{const r=await ie(`/keywords-with-item-id/${a}`),h=Array.isArray(r)?r:[];if(s.id){const u=parseInt(s.id);u>=0&&u{const r=await ie(`/keywords-with-item-id/${a}`),h=Array.isArray(r)?r:[],u=parseInt(s);return u>=0&&u{const s=await ie("/system-settings");return Qt(s.data||s)},it=async s=>{const a=Object.entries(s).map(([r,h])=>fe(`/system-settings/${r}`,{value:String(h)}));return await Promise.all(a),{success:!0,message:"Settings saved"}},Fa=async s=>ie(`/ai-reply-settings/${s}`),Ra=async(s,a)=>{const r={ai_enabled:a.ai_enabled??!1,max_discount_percent:a.max_discount_percent??10,max_discount_amount:a.max_discount_amount??100,max_bargain_rounds:a.max_bargain_rounds??3,custom_prompts:a.custom_prompts??""};return fe(`/ai-reply-settings/${s}`,r)},Ea=async(s,a="")=>(await de("/ai-models",{base_url:s,api_key:a})).models||[],ot=async()=>({success:!0,data:(await ie("/notification-channels")||[]).map(r=>{let h;try{h=JSON.parse(r.config)}catch{h=void 0}return{id:String(r.id),name:r.name,type:r.type,config:h,enabled:r.enabled,created_at:r.created_at,updated_at:r.updated_at}})}),Oa=async s=>de("/notification-channels",{...s,config:JSON.stringify(s.config)}),Ms=async(s,a)=>{const r={...a};return"config"in a&&(r.config=JSON.stringify(a.config)),fe(`/notification-channels/${s}`,r)},Ma=async s=>Ee(`/notification-channels/${s}`),Ta=async s=>{const a=await ie(`/message-notifications/${s}`);return(a==null?void 0:a.channel_ids)||[]},qa=async(s,a)=>de(`/message-notifications/${s}`,{channel_ids:a}),Ba=async s=>de(`/notification-channels/${s}/test`,{}),Ts=async()=>ie("/api/default-replies"),za=async s=>{const a=await ie(`/api/default-reply/${s}`);return{cookie_id:s,enabled:a.enabled||!1,reply_content:a.reply_content||"",reply_once:a.reply_once||!1,reply_image_url:a.reply_image_url||""}},Ua=async(s,a)=>fe(`/api/default-reply/${s}`,{enabled:a.enabled??!1,reply_content:a.reply_content||"",reply_once:a.reply_once??!1,reply_image_url:a.reply_image_url||""}),Wa=async s=>Ee(`/api/default-reply/${s}`),Qa=async s=>de(`/api/default-reply/${s}/clear-records`,{}),Va=({status:s})=>{const a={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-[#0094f7] text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600"},r={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${a[s]||a.cancelled}`,children:r[s]||s})},ss=({title:s,value:a,icon:r,colorClass:h,trend:u})=>e.jsxs("div",{className:"ios-card p-6 rounded-xl flex flex-col justify-between hover:translate-y-[-4px] transition-all duration-300 h-full relative overflow-hidden group border-0",children:[e.jsx("div",{className:`absolute -right-6 -top-6 w-32 h-32 ${h} opacity-10 rounded-full group-hover:scale-125 transition-transform duration-500 blur-2xl`}),e.jsxs("div",{className:"flex justify-between items-start mb-6",children:[e.jsx("div",{className:`p-4 rounded-2xl ${h} bg-opacity-10 backdrop-blur-sm`,children:e.jsx(r,{className:`w-6 h-6 ${h.replace("bg-","text-")}`})}),u&&e.jsxs("span",{className:"text-xs font-bold text-white bg-[#0094f7] px-3 py-1.5 rounded-full flex items-center gap-1 shadow-sm",children:[e.jsx(yt,{className:"w-3 h-3"})," ",u]})]}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("h3",{className:"text-3xl font-extrabold text-gray-900 tracking-tight font-feature-settings-tnum",children:a}),e.jsx("p",{className:"text-gray-500 text-sm font-medium mt-1",children:s})]})]}),qs=()=>{var ae,ne;const[s,a]=o.useState(null),[r,h]=o.useState(null),[u,m]=o.useState("7days"),[w,I]=o.useState(""),[p,W]=o.useState(""),[b,Y]=o.useState(null),[G,M]=o.useState(""),[E,X]=o.useState([]),[re,Z]=o.useState(!1),[R,te]=o.useState([]),[T,F]=o.useState({}),L=["#0094f7","#3B82F6","#10B981","#F59E0B","#8B5CF6"],Q=x=>{const y=x.getFullYear(),V=String(x.getMonth()+1).padStart(2,"0"),se=String(x.getDate()).padStart(2,"0");return`${y}-${V}-${se}`},A=x=>{const y=new Date,V=Q(y);let se=V;if(x==="yesterday"){const B=new Date(y);B.setDate(B.getDate()-1);const pe=Q(B);return{startDate:pe,endDate:pe}}if(x==="3days"){const B=new Date(y);B.setDate(B.getDate()-3),se=Q(B)}else if(x==="7days"){const B=new Date(y);B.setDate(B.getDate()-7),se=Q(B)}else if(x==="30days"){const B=new Date(y);B.setDate(B.getDate()-30),se=Q(B)}else{if(x==="custom"&&w&&p)return{startDate:w,endDate:p};if(x==="custom"){const B=new Date(y);B.setDate(B.getDate()-7),se=Q(B)}}return{startDate:se,endDate:V}},$=x=>{const{startDate:y,endDate:V}=A(x);Z(!0),pa({start_date:y,end_date:V}).then(X).catch(console.error).finally(()=>Z(!1))},d=x=>{const y=new Date,{startDate:V,endDate:se}=A(x),B={start_date:V,end_date:se},pe=z(x,y);pe&&Rs(pe).then(Y).catch(console.error),Rs(B).then(h).catch(console.error)},z=(x,y)=>{switch(y.getFullYear(),String(y.getMonth()+1).padStart(2,"0"),String(y.getDate()).padStart(2,"0"),x){case"today":const V=new Date(y);V.setDate(V.getDate()-1);const se=V.getFullYear(),B=String(V.getMonth()+1).padStart(2,"0"),pe=String(V.getDate()).padStart(2,"0");return{start_date:`${se}-${B}-${pe}`,end_date:`${se}-${B}-${pe}`};case"yesterday":const je=new Date(y);je.setDate(je.getDate()-2);const he=je.getFullYear(),we=String(je.getMonth()+1).padStart(2,"0"),Ce=String(je.getDate()).padStart(2,"0");return{start_date:`${he}-${we}-${Ce}`,end_date:`${he}-${we}-${Ce}`};case"7days":const Ne=new Date(y);Ne.setDate(Ne.getDate()-7);const ge=new Date(Ne);return ge.setDate(ge.getDate()-7),{start_date:`${ge.getFullYear()}-${String(ge.getMonth()+1).padStart(2,"0")}-${String(ge.getDate()).padStart(2,"0")}`,end_date:`${Ne.getFullYear()}-${String(Ne.getMonth()+1).padStart(2,"0")}-${String(Ne.getDate()).padStart(2,"0")}`};case"30days":const be=new Date(y);be.setDate(be.getDate()-30);const t=new Date(be);return t.setDate(t.getDate()-30),{start_date:`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,end_date:`${be.getFullYear()}-${String(be.getMonth()+1).padStart(2,"0")}-${String(be.getDate()).padStart(2,"0")}`};default:return null}},H=()=>{if(!r||!b)return null;const x=r.revenue_stats.total_amount,y=b.revenue_stats.total_amount;if(y===0)return x>0?"+100%":"0%";const V=(x-y)/y*100;return`${V>=0?"+":""}${V.toFixed(1)}%`};if(o.useEffect(()=>{ua().then(a).catch(console.error),d(u),Ue().then(x=>{te(x);const y={};x.forEach(V=>{y[V.item_id]=V.item_title||V.item_id}),F(y)}).catch(console.error)},[u]),o.useEffect(()=>{$(u)},[u]),!s||!r)return e.jsx("div",{className:"p-8 flex justify-center text-gray-400",children:e.jsx(Ns,{className:"w-8 h-8 animate-spin text-[#0094f7]"})});const J=((ae=r.daily_stats)==null?void 0:ae.map(x=>({name:x.date.slice(5),amount:x.amount,orders:x.order_count,avgAmount:x.order_count>0?(x.amount/x.order_count).toFixed(2):0})))||[],U=r.item_stats||[],C=r.revenue_stats.total_orders||0,k=r.revenue_stats.total_amount||0,c=U.length>0?U.map(x=>({name:(T[x.item_id]||x.item_id).length>12?(T[x.item_id]||x.item_id).substring(0,12)+"...":T[x.item_id]||x.item_id,sales:x.order_count})).sort((x,y)=>y.sales-x.sales).slice(0,10):[],j=Math.max(...c.map(x=>x.sales),1),N=U.length>0?U.map(x=>({name:(T[x.item_id]||x.item_id).length>10?(T[x.item_id]||x.item_id).substring(0,10)+"...":T[x.item_id]||x.item_id,value:x.order_count,percent:C>0?x.order_count/C*100:0})).sort((x,y)=>y.value-x.value).slice(0,6).map((x,y)=>({...x,color:L[y%L.length]})):[],q=U.length>0?U.map(x=>({name:(T[x.item_id]||x.item_id).length>12?(T[x.item_id]||x.item_id).substring(0,12)+"...":T[x.item_id]||x.item_id,value:x.total_amount,orderCount:x.order_count,percentage:k>0?x.total_amount/k*100:0})).sort((x,y)=>y.value-x.value).slice(0,5).map((x,y)=>({...x,color:L[y%L.length],percentage:x.percentage.toFixed(1)})):[],D=[{key:"today",label:"今天"},{key:"yesterday",label:"昨天"},{key:"3days",label:"三天内"},{key:"7days",label:"7天内"},{key:"30days",label:"一个月内"},{key:"custom",label:"自定义"}],ee=((ne=D.find(x=>x.key===u))==null?void 0:ne.label)||"所选范围",O=A(u),i=G.trim().toLowerCase(),P=E.filter(x=>{var y,V,se,B;return((y=x.order_id)==null?void 0:y.toLowerCase().includes(i))||((V=x.item_id)==null?void 0:V.toLowerCase().includes(i))||((se=x.item_title)==null?void 0:se.toLowerCase().includes(i))||((B=x.buyer_id)==null?void 0:B.toLowerCase().includes(i))});return e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"运营概览"}),e.jsx("p",{className:"text-gray-500 mt-2 text-base",children:"欢迎回来,以下是闲鱼店铺的实时经营数据。"})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"text-sm font-bold text-gray-700 bg-white px-5 py-2.5 rounded-full shadow-sm border border-gray-100 flex items-center gap-2",children:[e.jsx("span",{className:"w-2.5 h-2.5 bg-green-500 rounded-full animate-pulse"}),"系统正常运行"]})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[D.map(x=>e.jsx("button",{onClick:()=>m(x.key),className:`px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${u===x.key?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:x.label},x.key)),u==="custom"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"date",value:w,onChange:x=>I(x.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-[#0094f7]"}),e.jsx("span",{className:"self-center text-gray-400",children:"-"}),e.jsx("input",{type:"date",value:p,onChange:x=>W(x.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-[#0094f7]"}),e.jsx("button",{onClick:()=>{d("custom"),$("custom")},className:"px-4 py-2 rounded-xl text-sm font-bold bg-black text-white hover:bg-gray-800 transition-colors",children:"应用"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[e.jsx(ss,{title:"累计营收 (CNY)",value:`¥${r.revenue_stats.total_amount.toLocaleString("zh-CN",{minimumFractionDigits:2})}`,icon:bt,colorClass:"bg-blue-400",trend:H()||void 0}),e.jsx(ss,{title:"活跃账号 / 总数",value:`${s.active_cookies} / ${s.total_cookies}`,icon:Js,colorClass:"bg-blue-500"}),e.jsx(ss,{title:"订单数",value:r.revenue_stats.total_orders.toLocaleString(),icon:vs,colorClass:"bg-blue-500"}),e.jsx(ss,{title:"库存卡密余量",value:s.total_cards,icon:Xs,colorClass:"bg-purple-500"})]}),e.jsxs("div",{className:"ios-card p-8 rounded-xl",children:[e.jsxs("div",{className:"mb-10",children:[e.jsx("h3",{className:"text-xl font-bold text-gray-900",children:"营收趋势分析"}),e.jsxs("p",{className:"text-sm text-gray-400 mt-1",children:[ee,"的销售额走势"]})]}),e.jsx("div",{className:"h-[350px] w-full",children:J.length===0||r.revenue_stats.total_amount===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(vs,{className:"w-16 h-16 mb-4 opacity-20"}),e.jsx("p",{className:"text-lg font-medium",children:"暂无营收数据"}),e.jsx("p",{className:"text-sm mt-2",children:"所选时间范围内暂无订单记录"})]}):J.length<=2?e.jsx(He,{width:"100%",height:"100%",children:e.jsxs(Et,{data:J,margin:{top:30,right:20,left:0,bottom:30},barCategoryGap:"45%",children:[e.jsx(Is,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:"#374151",fontSize:14,fontWeight:600},dy:10}),e.jsx(As,{axisLine:!1,tickLine:!1,tick:{fill:"#9CA3AF",fontSize:13,fontWeight:500},tickFormatter:x=>`¥${x}`}),e.jsx(ds,{contentStyle:{backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e5e7eb",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1)",padding:"12px 16px"},labelStyle:{color:"#6b7280",fontWeight:500},itemStyle:{color:"#0094f7",fontWeight:600},cursor:{fill:"rgba(0, 148, 247, 0.08)"},formatter:x=>[`¥${Number(x).toFixed(2)}`,"营收"]}),e.jsx(Ot,{dataKey:"amount",fill:"#0094f7",maxBarSize:72,radius:[12,12,0,0],stroke:"#000000",strokeWidth:0,children:J.map((x,y)=>e.jsx(cs,{fill:["#0094f7","#FCD34D","#0071e3"][y%3]},`cell-${y}`))})]})}):e.jsx(He,{width:"100%",height:"100%",children:e.jsxs(Mt,{data:J,margin:{top:10,right:10,left:-20,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"colorAmount",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0094f7",stopOpacity:.5}),e.jsx("stop",{offset:"95%",stopColor:"#0094f7",stopOpacity:0})]})}),e.jsx(Is,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:"#9CA3AF",fontSize:13,fontWeight:500},dy:15}),e.jsx(As,{axisLine:!1,tickLine:!1,tick:{fill:"#9CA3AF",fontSize:13,fontWeight:500}}),e.jsx(Tt,{vertical:!1,stroke:"#F3F4F6",strokeDasharray:"3 3"}),e.jsx(ds,{contentStyle:{backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e5e7eb",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1)",padding:"12px 16px"},labelStyle:{color:"#6b7280",fontWeight:500},itemStyle:{color:"#0094f7",fontWeight:600},cursor:{stroke:"#0094f7",strokeWidth:2,strokeDasharray:"4 4"}}),e.jsx(qt,{type:"monotone",dataKey:"amount",stroke:"#0094f7",strokeWidth:4,fillOpacity:1,fill:"url(#colorAmount)",activeDot:{r:8,fill:"#fff",stroke:"#0094f7",strokeWidth:2}})]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"ios-card p-6 rounded-xl",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品销量排行"}),e.jsx("div",{className:"h-[280px]",children:c.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:"暂无数据"}):e.jsx("div",{className:"h-full space-y-4 overflow-y-auto pr-2",children:c.map((x,y)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("span",{className:`w-7 h-7 rounded-xl flex items-center justify-center text-xs font-extrabold ${y<3?"bg-blue-600 text-white":"bg-gray-100 text-gray-500"}`,children:y+1}),e.jsx("span",{className:"font-bold text-gray-800 text-sm truncate",children:x.name})]}),e.jsxs("span",{className:"font-mono text-sm font-extrabold text-gray-900",children:[x.sales," 单"]})]}),e.jsx("div",{className:"h-3 rounded-full bg-gray-100 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-[#0094f7]",style:{width:`${Math.max(8,x.sales/j*100)}%`}})})]},`${x.name}-${y}`))})})]}),e.jsxs("div",{className:"ios-card p-6 rounded-xl",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品下单占比"}),e.jsx("div",{className:"h-[280px]",children:N.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:"暂无数据"}):e.jsx(He,{width:"100%",height:"100%",children:e.jsxs(Ds,{children:[e.jsx(Ls,{data:N,cx:"50%",cy:"50%",innerRadius:60,outerRadius:90,paddingAngle:2,dataKey:"value",label:({name:x,payload:y})=>`${x} ${Number((y==null?void 0:y.percent)||0).toFixed(1)}%`,labelLine:!1,children:N.map((x,y)=>e.jsx(cs,{fill:x.color},`cell-${y}`))}),e.jsx(Bt,{verticalAlign:"bottom",height:36,iconType:"circle",formatter:x=>e.jsx("span",{style:{color:"#6B7280",fontWeight:500},children:x})})]})})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"lg:col-span-2 ios-card p-0 rounded-xl border-0 bg-white overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"p-6 border-b border-gray-50 flex justify-between items-center bg-[#FAFAFA]",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900",children:"参与统计的订单"}),e.jsx("div",{className:"relative",children:e.jsx("input",{placeholder:"搜索订单号/商品/买家...",value:G,onChange:x=>M(x.target.value),className:"pl-4 pr-4 py-2 rounded-xl bg-white border border-gray-100 text-sm focus:border-blue-400 outline-none w-48",type:"text"})})]}),e.jsx("div",{className:"overflow-x-auto flex-1 max-h-[400px]",children:re?e.jsxs("div",{className:"flex items-center justify-center py-20 text-gray-400",children:[e.jsx(Ns,{className:"w-6 h-6 animate-spin mr-2"}),"加载中..."]}):P.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-8 text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-gray-100 flex items-center justify-center mb-4",children:e.jsx(Ge,{className:"w-7 h-7 text-gray-300"})}),i?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"没有匹配的订单"}),e.jsxs("div",{className:"text-xs text-gray-400 mt-2 max-w-md",children:["当前共有 ",E.length," 单参与统计,但没有订单号、商品、买家匹配“",G,"”。"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"当前范围内没有参与统计的订单"}),e.jsxs("div",{className:"text-xs text-gray-400 mt-2 max-w-lg leading-6",children:["日期范围:",O.startDate," 至 ",O.endDate,"; 统计口径:待发货、已发货、已完成,且订单金额不为空。 当前统计卡片订单数:",r.revenue_stats.total_orders," 单。"]})]})]}):e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"px-6 py-4",children:"订单信息"}),e.jsx("th",{className:"px-6 py-4",children:"买家信息"}),e.jsx("th",{className:"px-6 py-4",children:"金额"}),e.jsx("th",{className:"px-6 py-4",children:"状态"}),e.jsx("th",{className:"px-6 py-4 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:P.map(x=>e.jsxs("tr",{className:"hover:bg-[#FFFDE7]/50 transition-colors group",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-gray-100 overflow-hidden shadow-sm border border-gray-100 flex-shrink-0",children:e.jsx(Ge,{className:"w-full h-full text-gray-300 p-2"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm line-clamp-1",children:x.item_title||x.item_id||"未知商品"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 font-mono",children:x.order_id}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",x.quantity||1]})]})]})}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"text-sm font-bold text-gray-800",children:x.buyer_id}),x.created_at&&e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:x.created_at})]}),e.jsxs("td",{className:"px-6 py-4 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:["¥",x.amount||"0.00"]}),e.jsx("td",{className:"px-6 py-4",children:e.jsx(Va,{status:x.status||x.order_status||"unknown"})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("a",{href:`https://www.goofish.com/order-detail?orderId=${x.order_id}&role=seller`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看闲鱼详情",children:e.jsx(Zs,{className:"w-4 h-4"})})})]},x.order_id))})]})})]}),e.jsxs("div",{className:"ios-card p-6 rounded-xl bg-white",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品金额分析 (TOP5)"}),q.length===0?e.jsx("div",{className:"flex items-center justify-center h-[300px] text-gray-400",children:"暂无数据"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-[300px] relative",children:e.jsx(He,{width:"100%",height:"100%",children:e.jsxs(Ds,{children:[e.jsx(Ls,{data:q,cx:"50%",cy:"50%",innerRadius:60,outerRadius:100,paddingAngle:2,dataKey:"value",label:({name:x,payload:y})=>`${x} ${(y==null?void 0:y.percentage)||"0.0"}%`,children:q.map((x,y)=>e.jsx(cs,{fill:x.color||L[y%L.length]},`cell-${y}`))}),e.jsx(ds,{contentStyle:{backgroundColor:"#fff",border:"1px solid #e5e7eb",borderRadius:"6px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"},formatter:x=>`¥${x.toLocaleString()}`})]})})}),e.jsx("div",{className:"space-y-3 mt-4",children:q.map(x=>e.jsxs("div",{className:"flex justify-between items-center text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:x.color||L[q.indexOf(x)%L.length]}}),e.jsx("span",{className:"text-gray-600 font-medium",children:x.name})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"font-bold text-gray-900",children:["¥",x.value.toLocaleString()]}),e.jsxs("span",{className:"text-xs text-gray-500 bg-gray-100 px-2 py-0.5 rounded",children:[x.percentage,"%"]})]})]},x.name))})]})]})]})]})},Ja=(s,a)=>{const r=a.username!==(s.username||""),h=a.show_browser!==(s.show_browser||!1),u=a.login_password!=="";if(!r&&!h&&!u)return null;const m={username:a.username,show_browser:a.show_browser};return u&&(m.login_password=a.login_password),m},Ya=new Set(["expired","cancelled","error","not_found"]),Ga=(s={setInterval:globalThis.setInterval.bind(globalThis),clearInterval:globalThis.clearInterval.bind(globalThis)})=>{let a=null;const r=()=>{a!==null&&(s.clearInterval(a),a=null)};return{start:(u,m,w,I=2e3)=>{r(),a=s.setInterval(()=>{(async()=>{var p,W;try{const b=await m(u);if(b.status==="success"){r(),await w.onSuccess(b);return}if(b.status==="scanned"){(p=w.onScanned)==null||p.call(w,b);return}if(b.status==="verification_required"){(W=w.onVerificationRequired)==null||W.call(w,b);return}b.status&&Ya.has(b.status)&&(r(),w.onTerminalError(b))}catch(b){r(),w.onPollError(b)}})()},I)},stop:r,isActive:()=>a!==null}},Ka=()=>{const[s,a]=o.useState([]),[r,h]=o.useState(!0),[u,m]=o.useState(""),[w,I]=o.useState(""),[p,W]=o.useState(!1),[b,Y]=o.useState(""),[G,M]=o.useState("pending"),[E,X]=o.useState(""),[re,Z]=o.useState(""),[R,te]=o.useState(""),[T,F]=o.useState(""),[L,Q]=o.useState(null),[A,$]=o.useState(null),[d,z]=o.useState(null),[H,J]=o.useState([]),[U,C]=o.useState([]),[k,c]=o.useState({remark:"",cookie:"",auto_confirm:!1,pause_duration:0,username:"",login_password:"",show_browser:!1,showLoginPassword:!1}),[j,N]=o.useState({ai_enabled:!1,max_discount_percent:10,max_discount_amount:100,max_bargain_rounds:3,custom_prompts:""}),[q,D]=o.useState(!1),ee=o.useRef(null),O=o.useRef(null);ee.current===null&&(ee.current=Ga());const i=()=>{O.current!==null&&(window.clearTimeout(O.current),O.current=null)},P=()=>{var t;(t=ee.current)==null||t.stop()},ae=()=>{P(),i(),W(!1)},ne=()=>{i(),O.current=window.setTimeout(()=>{O.current=null,W(!1),y()},1e3)},x=async()=>{try{const t=await Kt();a(g=>g.map(S=>{const l=t[S.id];return l?{...S,runtime_state:l.state,runtime_message:l.message||"",runtime_connected:l.connected,runtime_updated_at:l.updated_at}:S}))}catch(t){console.error("Failed to load account runtime statuses:",t)}},y=async()=>{h(!0);try{const t=await js();let g={};try{g=await na()}catch(l){console.error("Failed to load AI settings:",l)}const S=t.map(l=>{var v,le,$e,Se,ve;return{...l,ai_enabled:((v=g[l.id])==null?void 0:v.ai_enabled)??!1,max_discount_percent:((le=g[l.id])==null?void 0:le.max_discount_percent)??10,max_discount_amount:(($e=g[l.id])==null?void 0:$e.max_discount_amount)??100,max_bargain_rounds:((Se=g[l.id])==null?void 0:Se.max_bargain_rounds)??3,custom_prompts:((ve=g[l.id])==null?void 0:ve.custom_prompts)??""}});a(S),window.setTimeout(x,0)}catch(t){console.error("Failed to load accounts:",t)}finally{h(!1)}};o.useEffect(()=>{y();const t=window.setInterval(x,1e4);return()=>window.clearInterval(t)},[]),o.useEffect(()=>()=>{P(),i()},[]);const V=t=>{if(!t.enabled||t.runtime_state==="disabled")return{label:"已停用",badge:"bg-gray-100 text-gray-500",dot:"bg-gray-300"};switch(t.runtime_state){case"online":return{label:"在线",badge:"bg-green-100 text-green-700",dot:"bg-green-500"};case"starting":case"connecting":return{label:"连接中",badge:"bg-blue-100 text-blue-700",dot:"bg-blue-500"};case"reconnecting":return{label:"重连中",badge:"bg-amber-100 text-amber-700",dot:"bg-amber-500"};case"auth_expired":return{label:"登录已失效",badge:"bg-red-100 text-red-700",dot:"bg-red-500"};case"verification_required":return{label:"需要验证",badge:"bg-orange-100 text-orange-700",dot:"bg-orange-500"};case"error":case"stopped":return{label:"运行异常",badge:"bg-red-100 text-red-700",dot:"bg-red-500"};default:return{label:"状态检测中",badge:"bg-gray-100 text-gray-600",dot:"bg-gray-400"}}},se=async(t,g)=>{await Ht(t,!g),y()},B=async t=>{confirm("确认删除该账号吗?")&&(await ea(t),y())},pe=async t=>{I(t.id);try{const g=await la(t.id);g!=null&&g.profile_error&&alert("资料刷新失败:"+g.profile_error),await y()}catch(g){console.error("刷新账号资料失败:",g),alert((g==null?void 0:g.message)||"刷新账号资料失败,请先重新授权该账号")}finally{I("")}},je=async t=>{z(t),c({remark:t.remark||t.note||"",cookie:t.cookie||t.value||"",auto_confirm:t.auto_confirm||!1,pause_duration:t.pause_duration||0,username:t.username||"",login_password:t.login_password||"",show_browser:t.show_browser||!1,showLoginPassword:!1}),$("edit");try{const[g,S]=await Promise.all([ot(),Ta(t.id).catch(()=>[])]);J(g.data||[]),C(S||[])}catch(g){console.error("加载通知渠道绑定失败",g),J([]),C([])}},he=async t=>{z(t),D(!0);try{const g=await Fa(t.id);N({ai_enabled:g.ai_enabled??!1,max_discount_percent:g.max_discount_percent??10,max_discount_amount:g.max_discount_amount??100,max_bargain_rounds:g.max_bargain_rounds??3,custom_prompts:g.custom_prompts??""})}catch(g){console.error("Failed to load AI settings:",g)}finally{D(!1)}$("ai-settings")},we=async()=>{if(d){D(!0);try{const t=[];k.remark!==(d.remark||d.note||"")&&t.push(sa(d.id,k.remark)),k.cookie&&k.cookie!==(d.cookie||d.value||"")&&t.push(Ps(d.id,k.cookie)),k.auto_confirm!==d.auto_confirm&&t.push(ta(d.id,k.auto_confirm)),k.pause_duration!==(d.pause_duration||0)&&t.push(aa(d.id,k.pause_duration));const g=Ja(d,k);g&&t.push(ra(d.id,g)),t.push(qa(d.id,U)),await Promise.all(t),$(null),y()}catch(t){console.error("更新账号失败:",t),alert("更新失败,请重试")}finally{D(!1)}}},Ce=async()=>{if(d){D(!0);try{await Ra(d.id,j),$(null),y()}catch(t){console.error("更新AI设置失败:",t),alert("更新失败,请重试")}finally{D(!1)}}},Ne=async(t,g,S)=>{if(S){if(g&&g!==S.id&&!confirm(`扫码返回的账号ID是 ${g},当前要重新授权的是 ${S.id}。确认用本次扫码结果覆盖当前账号授权吗?`))throw new Error("已取消覆盖当前账号授权");return await Ps(S.id,t,"qr_scan"),S.id}if(!g)throw new Error("扫码结果缺少账号ID,无法添加账号");return await Yt(g,t,"qr_scan"),g},ge=async t=>{var S;P(),i();const g=t||null;Q(g),W(!0),M("loading"),Y(""),F(""),X(""),Z(""),te("");try{const l=await Xt();l.success&&l.qr_code_url&&l.session_id&&(Y(l.qr_code_url),F(l.session_id),M("waiting"),(S=ee.current)==null||S.start(l.session_id,Zt,{onSuccess:async v=>{if(M("success"),v.cookies&&v.unb)try{await Ne(v.cookies,v.unb,g)}catch(le){console.error("保存扫码授权失败",le),M("error");return}ne()},onScanned:()=>{M("waiting")},onTerminalError:()=>{M("error")},onPollError:v=>{console.error("轮询扫码状态失败",v),M("error")},onVerificationRequired:v=>{M("verification"),X(v.verification_url||""),v.face_qr_url&&te(v.face_qr_url),v.verification_screenshot&&Z(v.verification_screenshot)}}))}catch{M("error")}};if(r)return e.jsx("div",{className:"p-20 flex justify-center",children:e.jsx(_e,{className:"w-8 h-8 text-[#0094f7] animate-spin"})});const be=s.filter(t=>{const g=u.trim().toLowerCase();return g?[t.id,t.nickname,t.remark,t.note,t.username,t.runtime_message].some(S=>(S||"").toLowerCase().includes(g)):!0});return e.jsxs("div",{className:"space-y-8 animate-fade-in relative",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"账号管理"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理您的闲鱼授权账号及设置。建议给账号填写备注,便于多账号区分。"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx("input",{value:u,onChange:t=>m(t.target.value),placeholder:"搜索昵称 / 备注 / 账号ID",className:"ios-input px-4 py-3 rounded-2xl text-sm w-full sm:w-72"}),e.jsxs("button",{onClick:()=>ge(),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(is,{className:"w-5 h-5"}),"扫码添加新账号"]})]})]}),e.jsxs("div",{className:"rounded-2xl border border-blue-100 bg-blue-50 px-5 py-4 text-sm text-blue-900 flex flex-col md:flex-row md:items-center md:justify-between gap-2",children:[e.jsxs("div",{className:"font-bold",children:["当前显示 ",be.length," / ",s.length," 个账号"]}),e.jsx("div",{className:"text-blue-700",children:"如果某个账号只显示 ID,点该账号右侧“刷新资料”;若刷新失败,先点二维码重新授权。"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6",children:[be.map(t=>{const g=V(t),S=t.runtime_state==="auth_expired"||t.runtime_state==="verification_required";return e.jsxs("div",{className:"ios-card p-6 rounded-xl flex flex-col lg:flex-row lg:items-center justify-between gap-5 group hover:border-[#0094f7] transition-all duration-300",children:[e.jsxs("div",{className:"flex items-center gap-5 sm:gap-8 min-w-0",children:[e.jsxs("div",{className:"relative",children:[t.avatar_url?e.jsx("img",{src:t.avatar_url,alt:t.nickname||"账号头像",className:"w-20 h-20 rounded-full object-cover shadow-md ring-4 ring-white bg-gray-100"}):e.jsx("div",{className:"w-20 h-20 rounded-full bg-gray-100 text-gray-400 shadow-md ring-4 ring-white flex items-center justify-center",children:e.jsx(hs,{className:"w-9 h-9"})}),e.jsx("div",{className:`absolute -bottom-1 -right-1 w-6 h-6 rounded-full border-4 border-white flex items-center justify-center ${g.dot}`,children:t.runtime_state==="online"&&e.jsx(Fe,{className:"w-3 h-3 text-white"})})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-1",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900 break-words",children:t.nickname||t.remark||`账号 ${t.id.substring(0,6)}...`}),e.jsx("span",{className:`px-2.5 py-0.5 rounded-lg text-xs font-bold ${g.badge}`,children:g.label}),t.ai_enabled&&e.jsxs("span",{className:"px-2.5 py-0.5 rounded-lg bg-purple-100 text-purple-700 text-xs font-bold flex items-center gap-1",children:[e.jsx(Te,{className:"w-3 h-3"})," AI"]}),t.profile_error&&e.jsxs("span",{className:"px-2.5 py-0.5 rounded-lg bg-amber-100 text-amber-700 text-xs font-bold flex items-center gap-1",title:t.profile_error,children:[e.jsx(ls,{className:"w-3 h-3"})," 资料未同步"]})]}),e.jsxs("div",{className:"text-sm text-gray-500 font-medium mb-3 space-y-1",children:[e.jsx("p",{children:t.remark||t.note||"暂无备注"}),e.jsxs("p",{className:"font-mono text-xs text-gray-400",children:["ID: ",t.id]})]}),t.runtime_message&&t.runtime_state!=="online"&&t.runtime_state!=="disabled"&&e.jsxs("div",{className:`mb-3 flex flex-wrap items-center gap-2 text-sm font-medium ${S?"text-red-700":"text-amber-700"}`,children:[e.jsx(ls,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{children:t.runtime_message}),S&&e.jsxs("button",{type:"button",onClick:()=>ge(t),className:"inline-flex items-center gap-1.5 rounded-lg bg-red-50 px-2.5 py-1 text-xs font-bold text-red-700 hover:bg-red-100",children:[e.jsx(is,{className:"w-3.5 h-3.5"})," 重新授权"]})]}),e.jsxs("div",{className:"flex gap-2",children:[t.auto_confirm&&e.jsxs("span",{className:"text-xs bg-blue-50 text-blue-700 px-3 py-1.5 rounded-lg font-bold flex items-center gap-1.5",children:[e.jsx(Fe,{className:"w-3 h-3"})," 自动确认发货"]}),t.pause_duration>0&&e.jsxs("span",{className:"text-xs bg-blue-50 text-blue-700 px-3 py-1.5 rounded-lg font-bold flex items-center gap-1.5",children:[e.jsx(ws,{className:"w-3 h-3"})," 暂停",t.pause_duration,"分钟"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 self-end lg:self-auto flex-shrink-0",children:[e.jsx("button",{onClick:()=>pe(t),disabled:w===t.id,className:"p-3 rounded-xl transition-colors text-gray-600 hover:bg-gray-100 disabled:opacity-50",title:"刷新昵称和头像",children:e.jsx(ke,{className:`w-5 h-5 ${w===t.id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>ge(t),className:`p-3 rounded-xl transition-colors ${S?"text-red-600 bg-red-50 hover:bg-red-100":"text-blue-600 hover:bg-blue-50"}`,title:"重新扫码授权当前账号",children:e.jsx(is,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>je(t),className:"p-3 rounded-xl hover:bg-gray-100 transition-colors text-gray-600",title:"编辑账号",children:e.jsx(Hs,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>he(t),className:"p-3 rounded-xl hover:bg-purple-100 transition-colors text-purple-600",title:"AI设置",children:e.jsx(Te,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>se(t.id,t.enabled),className:`p-3 rounded-xl transition-colors ${t.enabled?"text-green-600 hover:bg-green-50":"text-gray-400 hover:bg-gray-100"}`,title:t.enabled?"停用账号":"启用账号",children:e.jsx(ft,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>B(t.id),className:"p-3 rounded-xl hover:bg-red-100 transition-colors text-red-500",children:e.jsx(Ae,{className:"w-5 h-5"})})]})]},t.id)}),s.length===0&&e.jsxs("div",{className:"ios-card p-12 text-center",children:[e.jsx("div",{className:"w-20 h-20 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(hs,{className:"w-10 h-10 text-gray-400"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:"暂无账号"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"请点击右上角扫码添加您的闲鱼账号"})]}),s.length>0&&be.length===0&&e.jsxs("div",{className:"ios-card p-12 text-center",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:"没有匹配的账号"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"换一个关键词搜索昵称、备注或账号ID。"})]})]}),p&&ue.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container relative",style:{maxWidth:"24rem"},children:[e.jsx("button",{onClick:ae,className:"absolute top-4 right-4 z-10 w-9 h-9 flex items-center justify-center bg-gray-100 hover:bg-gray-200 rounded-full transition-colors",children:e.jsx(xe,{className:"w-5 h-5 text-gray-600"})}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900 mb-2",children:L?"重新授权账号":"扫码添加账号"}),e.jsx("p",{className:"text-gray-500 mb-8 font-medium",children:L?`请用闲鱼APP扫码,为「${L.nickname||L.remark||L.id}」刷新授权`:"请打开闲鱼APP扫描下方二维码"}),e.jsxs("div",{className:"w-64 h-64 bg-[#F7F8FA] rounded-xl mx-auto flex items-center justify-center overflow-hidden border-4 border-white shadow-inner mb-8 relative",children:[G==="loading"&&e.jsx(_e,{className:"w-10 h-10 text-[#0094f7] animate-spin"}),G==="waiting"&&e.jsx("img",{src:b,alt:"QR Code",className:"w-full h-full p-2"}),G==="success"&&e.jsxs("div",{className:"absolute inset-0 bg-white/95 flex flex-col items-center justify-center text-green-600 animate-fade-in",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mb-4",children:e.jsx(Fe,{className:"w-8 h-8"})}),e.jsx("span",{className:"font-bold text-lg",children:"登录成功"})]}),G==="error"&&e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("span",{className:"text-red-500 font-bold mb-2",children:"获取失败"}),e.jsxs("button",{onClick:()=>ge(L||void 0),className:"text-xs bg-gray-200 px-3 py-1 rounded-full flex items-center gap-1 hover:bg-gray-300",children:[e.jsx(ke,{className:"w-3 h-3"})," 重试"]})]}),G==="verification"&&e.jsxs("div",{className:"flex flex-col items-center px-4",children:[e.jsx("span",{className:"font-bold text-gray-900 mb-2",children:"需要安全验证"}),e.jsx("span",{className:"text-xs text-gray-500 mb-3 text-center",children:R?"请用手机闲鱼扫描下方二维码完成人脸验证,验证通过后将自动登录。":"正在准备验证二维码,请保持页面打开。"}),R?e.jsx("img",{src:R,alt:"人脸验证二维码",className:"w-full max-w-[210px] rounded-xl border bg-white p-2 mb-2"}):re?e.jsx("img",{src:re,alt:"验证页面",className:"w-full rounded-xl border mb-2",style:{maxHeight:200,objectFit:"contain"}}):e.jsx("div",{className:"w-full h-32 bg-gray-100 rounded-xl flex items-center justify-center mb-2",children:e.jsx(_e,{className:"w-6 h-6 animate-spin text-gray-400"})}),e.jsx("span",{className:"text-xs text-gray-400",children:"等待手机验证完成,无需点击确认。"})]})]}),e.jsx("p",{className:"text-xs text-gray-400 font-medium bg-gray-50 py-2 rounded-xl",children:"二维码有效期为5分钟,请尽快扫码。"})]})})]})}),document.body),A==="edit"&&d&&ue.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"600px"},children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑账号"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:d.nickname||d.remark||d.id})]}),e.jsx("button",{onClick:()=>$(null),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(xe,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"账号ID"}),e.jsx("input",{type:"text",value:d.id,disabled:!0,className:"w-full ios-input px-4 py-3 rounded-xl bg-gray-50 text-gray-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注"}),e.jsx("input",{type:"text",value:k.remark,onChange:t=>c({...k,remark:t.target.value}),placeholder:"为账号添加备注",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"Cookie"}),e.jsx("textarea",{value:k.cookie,onChange:t=>c({...k,cookie:t.target.value}),placeholder:"更新账号Cookie",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none font-mono text-xs"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["当前Cookie长度: ",k.cookie.length," 字符"]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(Fe,{className:"w-4 h-4 text-green-500"}),"自动确认发货"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"自动将闲鱼订单标记为已发货"})]}),e.jsx("button",{type:"button",onClick:()=>c({...k,auto_confirm:!k.auto_confirm}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${k.auto_confirm?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${k.auto_confirm?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2 flex items-center gap-2",children:[e.jsx(ws,{className:"w-4 h-4 text-blue-500"}),"暂停处理时长(分钟)"]}),e.jsx("input",{type:"number",value:k.pause_duration,onChange:t=>c({...k,pause_duration:parseInt(t.target.value)||0}),placeholder:"0",min:"0",max:"1440",className:"w-full ios-input px-4 py-3 rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"设置后会暂停处理该账号的订单,到时间后自动恢复"})]}),e.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[e.jsxs("h3",{className:"text-lg font-bold text-gray-900 mb-4 flex items-center gap-2",children:[e.jsx(jt,{className:"w-5 h-5 text-blue-500"}),"登录信息"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"用户名"}),e.jsx("input",{type:"text",value:k.username,onChange:t=>c({...k,username:t.target.value}),placeholder:"闲鱼账号/手机号",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"登录密码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:k.showLoginPassword?"text":"password",value:k.login_password,onChange:t=>c({...k,login_password:t.target.value}),placeholder:"用于自动登录",className:"w-full ios-input px-4 py-3 rounded-xl pr-12"}),e.jsx("button",{type:"button",onClick:()=>c({...k,showLoginPassword:!k.showLoginPassword}),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:k.showLoginPassword?e.jsx(Ye,{className:"w-5 h-5"}):e.jsx(Be,{className:"w-5 h-5"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"登录时显示浏览器"}),e.jsx("div",{className:"text-xs text-gray-500",children:"调试时可开启查看登录过程"})]}),e.jsx("button",{type:"button",onClick:()=>c({...k,show_browser:!k.show_browser}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${k.show_browser?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${k.show_browser?"translate-x-6":"translate-x-0"}`})})]})]})]}),H.length>0&&e.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[e.jsxs("h3",{className:"text-lg font-bold text-gray-900 mb-1 flex items-center gap-2",children:[e.jsx(qe,{className:"w-5 h-5 text-blue-500"}),"通知渠道绑定"]}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"勾选后,该账号的 token 失效、自动恢复失败、风控验证等事件会推送到这些渠道"}),e.jsx("div",{className:"space-y-2",children:H.map(t=>{const g=U.includes(Number(t.id));return e.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-xl border border-gray-200 hover:bg-gray-50 cursor-pointer transition-colors",children:[e.jsx("button",{type:"button",onClick:()=>{C(S=>g?S.filter(l=>l!==Number(t.id)):[...S,Number(t.id)])},className:`w-5 h-5 rounded-md border-2 flex items-center justify-center transition-colors flex-shrink-0 ${g?"bg-[#0094f7] border-[#0094f7]":"bg-white border-gray-300"}`,children:g&&e.jsx(Fe,{className:"w-3.5 h-3.5 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:t.name}),e.jsxs("div",{className:"text-xs text-gray-500",children:[t.type,t.enabled?"":" · 已停用"]})]})]},t.id)})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>$(null),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:q,children:"取消"}),e.jsxs("button",{onClick:we,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:q,children:[q?e.jsx(_e,{className:"w-4 h-4 animate-spin"}):e.jsx(Le,{className:"w-4 h-4"}),q?"保存中...":"保存"]})]})})]})}),document.body),A==="ai-settings"&&d&&ue.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"600px"},children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-2xl font-extrabold text-gray-900 flex items-center gap-2",children:[e.jsx(Te,{className:"w-6 h-6 text-purple-500"}),"AI助手设置"]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:d.nickname||d.remark||d.id})]}),e.jsx("button",{onClick:()=>$(null),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(xe,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-purple-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(Te,{className:"w-4 h-4 text-purple-500"}),"启用AI自动回复"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"AI将自动处理买家的砍价消息"})]}),e.jsx("button",{type:"button",onClick:()=>N({...j,ai_enabled:!j.ai_enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${j.ai_enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${j.ai_enabled?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-4",children:"砍价策略"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大折扣比例 (%)"}),e.jsx("input",{type:"number",value:j.max_discount_percent,onChange:t=>N({...j,max_discount_percent:parseInt(t.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"100"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"例如:10表示最多降价10%"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大折扣金额 (元)"}),e.jsx("input",{type:"number",value:j.max_discount_amount,onChange:t=>N({...j,max_discount_amount:parseInt(t.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"例如:100表示最多降价100元"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大砍价轮次"}),e.jsx("input",{type:"number",value:j.max_bargain_rounds,onChange:t=>N({...j,max_bargain_rounds:parseInt(t.target.value)||1}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"1",max:"10"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"买家最多可以砍价的次数"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"自定义提示词(可选)"}),e.jsx("textarea",{value:j.custom_prompts,onChange:t=>N({...j,custom_prompts:t.target.value}),placeholder:`输入自定义的AI回复规则或风格指引... + +例如:回复时保持礼貌专业、使用简洁的语言、强调产品质量等`,className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none"})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-4",children:[e.jsxs("h4",{className:"font-bold text-blue-900 mb-2 flex items-center gap-2",children:[e.jsx(bs,{className:"w-4 h-4"}),"AI如何工作"]}),e.jsxs("ul",{className:"text-xs text-blue-800 space-y-1",children:[e.jsx("li",{children:"• 自动识别买家的砍价请求"}),e.jsx("li",{children:"• 根据设定的策略智能回复"}),e.jsx("li",{children:"• 在合理范围内同意降价或礼貌拒绝"}),e.jsx("li",{children:"• 保持专业友好的沟通风格"})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>$(null),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:q,children:"取消"}),e.jsxs("button",{onClick:Ce,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:q,children:[q?e.jsx(_e,{className:"w-4 h-4 animate-spin"}):e.jsx(Le,{className:"w-4 h-4"}),q?"保存中...":"保存"]})]})})]})}),document.body)]})},Bs=({status:s})=>{const a={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-[#0094f7] text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600"},r={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${a[s]||a.cancelled}`,children:r[s]||s})},Xa=()=>{const[s,a]=o.useState([]),[r,h]=o.useState([]),[u,m]=o.useState([]),[w,I]=o.useState({}),[p,W]=o.useState("all"),[b,Y]=o.useState(""),[G,M]=o.useState(1),[E,X]=o.useState(1),[re,Z]=o.useState(!1),[R,te]=o.useState(!1),[T,F]=o.useState(!1),[L,Q]=o.useState(!1),[A,$]=o.useState(null),[d,z]=o.useState(null),[H,J]=o.useState({}),[U,C]=o.useState(!1),[k,c]=o.useState(""),[j,N]=o.useState(!1),[q,D]=o.useState(null),[ee,O]=o.useState(null),[i,P]=o.useState(null),[ae,ne]=o.useState(null),x=t=>{if(!b.trim())return t;const g=b.toLowerCase().trim();return t.filter(S=>{var l,v,le,$e,Se,ve;return((l=S.order_id)==null?void 0:l.toLowerCase().includes(g))||((v=S.item_id)==null?void 0:v.toLowerCase().includes(g))||((le=S.buyer_id)==null?void 0:le.toLowerCase().includes(g))||(($e=S.item_title)==null?void 0:$e.toLowerCase().includes(g))||((Se=S.receiver_name)==null?void 0:Se.toLowerCase().includes(g))||((ve=S.receiver_phone)==null?void 0:ve.toLowerCase().includes(g))})},y=async()=>{Z(!0);try{if(b.trim()){let t=[],g=1,S=!0;for(;S;){const l=await Fs(void 0,p,g,100);t=[...t,...l.data],S=g{a(x(r))},[r,b]);const V=(t,g)=>{if(g&&g.trim())return g;if(w[t])return w[t];const S=u.find(l=>{if(g&&l.item_title){const v=g.toLowerCase(),le=l.item_title.toLowerCase();return le.includes(v)||v.includes(le)}return!1});return S!=null&&S.item_title?S.item_title:"未知商品"},se=t=>{const g={};t.forEach(S=>{S.item_id&&(g[S.item_id]=S.item_title||S.item_id)}),I(g)};o.useEffect(()=>{y(),Ue().then(t=>{m(t),se(t)}).catch(t=>{console.error("加载商品列表失败:",t)})},[p,G,b]);const B=async()=>{Z(!0);try{const t=await da();await y(),t!=null&&t.message&&alert(t.message)}catch(t){console.error("同步订单失败:",t),alert((t==null?void 0:t.message)||"同步失败,请重试")}finally{Z(!1)}},pe=t=>{c(t),D(null),C(!0)},je=async t=>{var g;N(!0),D(null);try{const S=await xa([k],t),l=(g=S==null?void 0:S.results)==null?void 0:g[0];l!=null&&l.success?(D({success:!0,message:l.message}),y()):D({success:!1,message:(l==null?void 0:l.message)||"发货失败"})}catch(S){D({success:!1,message:(S==null?void 0:S.message)||"请求失败"})}finally{N(!1)}},he=t=>{$(t),te(!0)},we=t=>{z({...t}),F(!0)},Ce=async()=>{if(!(!d||!d.order_id))try{const t={};d.status!==void 0&&(t.order_status=d.status),d.buyer_id!==void 0&&(t.buyer_id=d.buyer_id),d.amount!==void 0&&(t.amount=d.amount),d.receiver_name!==void 0&&(t.receiver_name=d.receiver_name),d.receiver_phone!==void 0&&(t.receiver_phone=d.receiver_phone),d.receiver_address!==void 0&&(t.receiver_address=d.receiver_address),d.item_id!==void 0&&(t.item_id=d.item_id),d.quantity!==void 0&&(t.quantity=d.quantity),await ia(d.order_id,t),F(!1),z(null),y()}catch(t){console.error("更新订单失败:",t),alert("更新失败,请重试")}},Ne=async()=>{if(ee)try{const t=new FormData;t.append("file",ee),await ma(t),Q(!1),O(null),y(),alert("订单导入成功")}catch(t){alert((t==null?void 0:t.message)||"导入失败,请检查文件格式")}},ge=async t=>{P(t);try{const g=await ca(t);g.success?await y():alert(g.message||"同步失败")}catch(g){console.error("同步订单失败:",g),alert((g==null?void 0:g.message)||"同步失败,请重试")}finally{P(null)}},be=async t=>{if(confirm("确认删除该订单吗?删除后无法恢复。")){ne(t);try{await oa(t),h(g=>g.filter(S=>S.order_id!==t))}catch(g){console.error("删除订单失败:",g),alert((g==null?void 0:g.message)||"删除失败,请重试"),await y()}finally{ne(null)}}};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"订单中心"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"查看所有闲鱼交易记录与状态。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:y,className:"p-3 rounded-2xl bg-white border border-gray-100 text-gray-600 hover:bg-gray-50 hover:text-black transition-colors shadow-sm",children:e.jsx(ke,{className:`w-5 h-5 ${re?"animate-spin":""}`})}),e.jsxs("button",{onClick:()=>Q(!0),className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors text-sm flex items-center gap-2 shadow-lg",children:[e.jsx(De,{className:"w-4 h-4"}),"插入订单"]}),e.jsxs("button",{onClick:B,className:"ios-btn-primary px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 text-sm flex items-center gap-2",children:[e.jsx(_s,{className:"w-5 h-5"}),"一键同步订单"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsxs("div",{className:"p-4 border-b border-gray-50 flex flex-col md:flex-row gap-4 justify-between items-center bg-[#FAFAFA]",children:[e.jsx("div",{className:"flex gap-1 p-1 bg-gray-200/50 rounded-xl overflow-x-auto max-w-full",children:[{k:"all",v:"全部"},{k:"shipped",v:"已发货"},{k:"pending_ship",v:"待发货"},{k:"cancelled",v:"已取消"},{k:"refunding",v:"其他"}].map(t=>e.jsx("button",{onClick:()=>{W(t.k),M(1),Y("")},className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${p===t.k?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:t.v},t.k))}),e.jsxs("div",{className:"relative w-full md:w-auto group",children:[e.jsx(Nt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 group-focus-within:text-[#0094f7] transition-colors"}),e.jsx("input",{type:"text",placeholder:"搜索订单号/商品/买家...",value:b,onChange:t=>{Y(t.target.value),M(1)},className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]}),e.jsx("div",{className:"overflow-x-auto min-h-[400px]",children:e.jsxs("table",{className:"w-full text-left border-collapse table-fixed",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"px-6 py-5",style:{width:"28%"},children:"订单信息"}),e.jsx("th",{className:"px-6 py-5",style:{width:"26%"},children:"买家信息"}),e.jsx("th",{className:"px-6 py-5",style:{width:"11%"},children:"实付金额"}),e.jsx("th",{className:"px-6 py-5",style:{width:"13%"},children:"当前状态"}),e.jsx("th",{className:"px-6 py-5 text-right",style:{width:"22%"},children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:s.map(t=>e.jsxs("tr",{className:"hover:bg-[#FFFDE7]/50 transition-colors group",children:[e.jsx("td",{className:"px-6 py-5",children:e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl bg-gray-100 overflow-hidden shadow-sm border border-gray-100 flex-shrink-0",children:t.item_image?e.jsx("img",{src:t.item_image,alt:"",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300",children:e.jsx(Ge,{})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 line-clamp-1 text-sm",children:V(t.item_id,t.item_title)}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1 font-medium",children:["订单ID: ",t.order_id]}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",t.quantity," • ",t.created_at]})]})]})}),e.jsx("td",{className:"px-6 py-5",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("div",{className:"text-xs text-gray-500",children:"买家ID"}),e.jsx("div",{className:"text-sm font-bold text-gray-800",children:t.buyer_id}),t.receiver_name&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"收货人"}),e.jsx("div",{className:"text-xs text-gray-600",children:t.receiver_name})]}),t.receiver_phone&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"联系电话"}),e.jsx("div",{className:"text-xs text-gray-600 font-mono",children:t.receiver_phone})]}),t.receiver_address&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"收货地址"}),e.jsx("div",{className:"text-xs text-gray-600 line-clamp-1",children:t.receiver_address})]})]})}),e.jsx("td",{className:"px-6 py-5 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:t.amount?`¥${t.amount}`:e.jsx("span",{className:"text-xs text-amber-600 font-bold",children:"待获取"})}),e.jsx("td",{className:"px-6 py-5",children:e.jsx(Bs,{status:t.status})}),e.jsxs("td",{className:"px-6 py-5 text-right",children:[t.status==="pending_ship"&&e.jsx("button",{onClick:()=>pe(t.order_id),className:"mr-2 text-white bg-black hover:bg-gray-800 shadow-lg shadow-gray-200 text-xs font-bold px-3 py-2 rounded-xl transition-all active:scale-95",children:"立即发货"}),e.jsx("a",{href:`https://www.goofish.com/order-detail?orderId=${t.order_id}&role=seller`,target:"_blank",rel:"noopener noreferrer",className:"mr-2 inline-flex text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看闲鱼详情",children:e.jsx(Zs,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>he(t),className:"mr-2 text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看详情",children:e.jsx(Be,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>we(t),className:"mr-2 text-gray-400 hover:text-black p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"编辑订单",children:e.jsx(ze,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>ge(t.order_id),disabled:i===t.order_id,className:"mr-2 text-gray-400 hover:text-green-600 p-2 rounded-xl hover:bg-green-50 transition-colors disabled:opacity-50",title:"同步订单",children:e.jsx(ke,{className:`w-4 h-4 ${i===t.order_id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>be(t.order_id),disabled:ae===t.order_id,className:"text-gray-400 hover:text-red-500 p-2 rounded-xl hover:bg-red-50 transition-colors disabled:opacity-50",title:"删除订单",children:e.jsx(Ae,{className:"w-4 h-4"})})]})]},t.id))})]})}),e.jsxs("div",{className:"p-4 border-t border-gray-50 flex items-center justify-between bg-white",children:[e.jsxs("div",{className:"text-sm text-gray-500 font-medium pl-2",children:["第 ",G," 页 / 共 ",E," 页"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{disabled:G<=1,onClick:()=>M(t=>t-1),className:"p-2.5 rounded-xl bg-gray-50 hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed text-gray-600 transition-colors",children:e.jsx(vt,{className:"w-5 h-5"})}),e.jsx("button",{disabled:G>=E,onClick:()=>M(t=>t+1),className:"p-2.5 rounded-xl bg-gray-50 hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed text-gray-600 transition-colors",children:e.jsx(wt,{className:"w-5 h-5"})})]})]})]}),R&&A&&ue.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"订单详情"}),e.jsx("button",{onClick:()=>te(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(xe,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"订单信息"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"订单号"}),e.jsx("div",{className:"font-mono text-sm font-bold text-gray-900",children:A.order_id})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"状态"}),e.jsx(Bs,{status:A.status})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"实付金额"}),e.jsx("div",{className:"text-lg font-extrabold text-gray-900",children:A.amount?`¥${A.amount}`:"待获取"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"数量"}),e.jsx("div",{className:"font-bold text-gray-900",children:A.quantity})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"创建时间"}),e.jsx("div",{className:"text-sm font-medium text-gray-700",children:A.created_at})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"商品信息"}),e.jsxs("div",{className:"p-4 bg-gray-50 rounded-xl flex items-center gap-4",children:[A.item_image&&e.jsx("img",{src:A.item_image,alt:"",className:"w-20 h-20 rounded-xl object-cover border border-gray-200"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-bold text-gray-900 mb-1",children:V(A.item_id,A.item_title)}),e.jsxs("div",{className:"text-sm text-gray-500",children:["商品ID: ",A.item_id]}),A.item_price&&e.jsxs("div",{className:"text-sm text-gray-500 mt-1",children:["标价: ¥",A.item_price]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"买家信息"}),e.jsxs("div",{className:"p-4 bg-gray-50 rounded-xl space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"买家ID"}),e.jsx("div",{className:"font-bold text-gray-900",children:A.buyer_id})]}),A.receiver_name&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"收货人"}),e.jsx("div",{className:"font-medium text-gray-700",children:A.receiver_name})]}),A.receiver_phone&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"联系电话"}),e.jsx("div",{className:"font-mono text-sm text-gray-700",children:A.receiver_phone})]}),A.receiver_address&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"收货地址"}),e.jsx("div",{className:"text-sm text-gray-700",children:A.receiver_address})]})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>te(!1),className:"flex-1 px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"关闭"}),A.status==="pending_ship"&&e.jsx("button",{onClick:()=>{te(!1),pe(A.order_id)},className:"flex-1 px-6 py-3 rounded-xl ios-btn-primary font-bold shadow-lg shadow-blue-200",children:"立即发货"})]})})]})}),document.body),L&&ue.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"插入订单"}),e.jsx("button",{onClick:()=>Q(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(xe,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"选择Excel文件"}),e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv,.json",onChange:t=>{var g;return O(((g=t.target.files)==null?void 0:g[0])||null)},className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持 .xlsx、.csv、.tsv、.json 格式"})]}),ee&&e.jsx("div",{className:"p-3 bg-blue-50 rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Je,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"text-sm font-medium text-blue-900",children:ee.name})]})})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>Q(!1),className:"flex-1 px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"取消"}),e.jsx("button",{onClick:Ne,disabled:!ee,className:"flex-1 px-6 py-3 rounded-xl ios-btn-primary font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:"导入订单"})]})})]})}),document.body),U&&ue.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"480px"},children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"立即发货"}),e.jsx("button",{onClick:()=>{C(!1),D(null)},className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(xe,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-4",children:[e.jsx("p",{className:"text-sm text-gray-600",children:"请选择发货方式:"}),e.jsx("button",{onClick:()=>je("status_only"),disabled:j,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-gray-400 hover:bg-gray-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-100 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(_s,{className:"w-5 h-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:"仅修改闲鱼发货状态"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 leading-relaxed",children:'不实际扣除或发送卡券,仅在闲鱼平台将订单标记为"已发货"。 适用于已经给客户发过货、只是忘记在闲鱼修改状态的情况。'})]})]})}),e.jsx("button",{onClick:()=>je("full_delivery"),disabled:j,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-[#0094f7] hover:bg-blue-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-100 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Ge,{className:"w-5 h-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:"完整发货(匹配卡券并发送)"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 leading-relaxed",children:"自动匹配发货规则、获取卡券、发送卡券信息给买家,并修改发货状态。 适用于订单既没有发送卡券给买家、也没有修改发货状态的情况。"})]})]})}),j&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[e.jsx(ke,{className:"w-4 h-4 animate-spin text-gray-500"}),e.jsx("span",{className:"text-sm text-gray-500",children:"正在处理中..."})]}),q&&e.jsxs("div",{className:`p-3 rounded-xl text-sm ${q.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:[q.success?"✓ ":"✗ ",q.message]})]}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{onClick:()=>{C(!1),D(null)},className:"w-full px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:q!=null&&q.success?"完成":"取消"})})]})}),document.body),T&&d&&ue.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑订单"}),e.jsx("button",{onClick:()=>F(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(xe,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"订单号"}),e.jsx("input",{type:"text",value:d.order_id,disabled:!0,className:"w-full ios-input px-4 py-3 rounded-xl bg-gray-50 text-gray-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"订单状态"}),e.jsxs("select",{value:d.status,onChange:t=>z({...d,status:t.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"processing",children:"处理中"}),e.jsx("option",{value:"pending_ship",children:"待发货"}),e.jsx("option",{value:"shipped",children:"已发货"}),e.jsx("option",{value:"completed",children:"已完成"}),e.jsx("option",{value:"cancelled",children:"已取消"}),e.jsx("option",{value:"refunding",children:"退款中"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"买家ID"}),e.jsx("input",{type:"text",value:d.buyer_id,onChange:t=>z({...d,buyer_id:t.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"实付金额"}),e.jsx("input",{type:"number",value:d.amount,onChange:t=>z({...d,amount:parseFloat(t.target.value)}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"收货人"}),e.jsx("input",{type:"text",value:d.receiver_name||"",onChange:t=>z({...d,receiver_name:t.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"联系电话"}),e.jsx("input",{type:"text",value:d.receiver_phone||"",onChange:t=>z({...d,receiver_phone:t.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"收货地址"}),e.jsx("textarea",{value:d.receiver_address||"",onChange:t=>z({...d,receiver_address:t.target.value}),rows:2,className:"w-full ios-input px-4 py-3 rounded-xl resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"商品标题"}),e.jsx("input",{type:"text",value:d.item_title||"",onChange:t=>z({...d,item_title:t.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>F(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:Ce,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Le,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body)]})},zs=()=>({name:"",type:"data",content:"",description:"",enabled:!0,delay_seconds:0,api_method:"GET",api_timeout:10,api_headers:"",api_params:""}),Za=()=>{const[s,a]=o.useState([]),[r,h]=o.useState(!1),[u,m]=o.useState(!1),[w,I]=o.useState(null),[p,W]=o.useState({}),[b,Y]=o.useState(zs),[G,M]=o.useState(!1),[E,X]=o.useState("create"),[re,Z]=o.useState(null),[R,te]=o.useState(null),[T,F]=o.useState(!1),[L,Q]=o.useState(""),[A,$]=o.useState(""),[d,z]=o.useState(null);o.useEffect(()=>{Ie().then(a)},[]);const H=({type:i})=>{switch(i){case"text":return e.jsx(ks,{className:"w-5 h-5 text-blue-500"});case"image":return e.jsx(Cs,{className:"w-5 h-5 text-purple-500"});case"api":return e.jsx(Ss,{className:"w-5 h-5 text-blue-500"});default:return e.jsx(us,{className:"w-5 h-5 text-gray-500"})}},J=i=>{var P,ae,ne,x,y;I(i),W({id:i.id,name:i.name||"",type:i.type||"text",api_url:((P=i.api_config)==null?void 0:P.url)||"",api_method:((ae=i.api_config)==null?void 0:ae.method)||"GET",api_timeout:((ne=i.api_config)==null?void 0:ne.timeout)||10,api_headers:((x=i.api_config)==null?void 0:x.headers)||"",api_params:((y=i.api_config)==null?void 0:y.params)||"",text_content:i.text_content||"",data_content:i.data_content||"",image_url:i.image_url||"",delay_seconds:i.delay_seconds||0,description:i.description||"",enabled:i.enabled}),h(!0)},U=async()=>{var i,P,ae,ne,x,y,V,se;if(w){if(!((i=p.name)!=null&&i.trim())){alert("请输入卡密名称");return}if(!p.type){alert("请选择卡密类型");return}try{const B={name:p.name.trim(),type:p.type,description:(P=p.description)==null?void 0:P.trim(),delay_seconds:p.delay_seconds||0,enabled:p.enabled??!0};p.type==="api"?B.api_config={url:(ae=p.api_url)==null?void 0:ae.trim(),method:p.api_method,timeout:p.api_timeout||10,headers:((ne=p.api_headers)==null?void 0:ne.trim())||void 0,params:((x=p.api_params)==null?void 0:x.trim())||void 0}:p.type==="text"?B.text_content=((y=p.text_content)==null?void 0:y.trim())||"":p.type==="data"?B.data_content=((V=p.data_content)==null?void 0:V.trim())||"":p.type==="image"&&(B.image_url=((se=p.image_url)==null?void 0:se.trim())||""),await Es(w.id,B),h(!1),Ie().then(a)}catch(B){console.error("更新卡密失败:",B),alert("更新失败,请重试")}}},C=async i=>{if(confirm("确认删除该卡密吗?"))try{await ba(i),Ie().then(a)}catch(P){console.error("删除卡密失败:",P),alert("删除失败,请重试")}},k=async()=>{if(!b.name.trim()){alert("请输入卡密名称");return}if(!b.content.trim()){alert(b.type==="api"?"请输入 API 地址":"请输入卡密内容");return}try{const i={name:b.name.trim(),type:b.type,description:b.description.trim(),enabled:b.enabled,delay_seconds:b.delay_seconds};b.type==="text"&&(i.text_content=b.content.trim()),b.type==="data"&&(i.data_content=b.content.trim()),b.type==="image"&&(i.image_url=b.content.trim()),b.type==="api"&&(i.api_config={url:b.content.trim(),method:b.api_method,timeout:b.api_timeout,headers:b.api_headers.trim()||void 0,params:b.api_params.trim()||void 0}),await ga(i),m(!1),Y(zs()),Ie().then(a)}catch(i){console.error("添加卡密失败:",i),alert("添加失败,请重试")}},c=async i=>{try{await Es(i.id,{...i,enabled:!i.enabled}),Ie().then(a)}catch(P){console.error("切换状态失败:",P)}},j=async i=>{try{await navigator.clipboard.writeText(String(i)),alert(`已复制卡密组ID:${i}`)}catch{prompt("复制卡密组ID",String(i))}},N=s.filter(i=>i.type==="data"),q=()=>{const ae=[["名称","类型","内容","描述","启用","延迟秒","多规格","规格名","规格值"],...[["VIP月卡","data",`VIP-MONTH-001 +VIP-MONTH-002 +VIP-MONTH-003`,"按行消费的卡密队列","是","0","否","",""],["感谢文案","text","感谢购买,如有问题联系客服~","固定文本","是","0","否","",""],["教程图","image","https://cdn.example.com/tutorial.jpg","图片URL","是","0","否","",""]]].map(V=>V.map(se=>`"${String(se).replace(/"/g,'""')}"`).join(",")).join(` +`),ne=new Blob(["\uFEFF"+ae],{type:"text/csv;charset=utf-8"}),x=URL.createObjectURL(ne),y=document.createElement("a");y.href=x,y.download="卡密组批量导入模板.csv",document.body.appendChild(y),y.click(),y.remove(),URL.revokeObjectURL(x)},D=async()=>{if(re){F(!0),te(null);try{const i=await ya(re);if(te(i),i.created>0){const P=await Ie();a(P)}}catch(i){te({error:(i==null?void 0:i.message)||"上传失败"})}finally{F(!1)}}},ee=async()=>{if(!(!L||!A.trim())){F(!0),z(null);try{const i=await fa(L,A);z({added:i.added}),$("");const P=await Ie();a(P)}catch(i){alert("追加失败:"+((i==null?void 0:i.message)||"未知错误"))}finally{F(!1)}}},O=()=>{var i;X("create"),Z(null),te(null),Q((i=N[0])!=null&&i.id?String(N[0].id):""),$(""),z(null),M(!0)};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"卡密库存"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理自动发货的卡密、链接或图片资源。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:O,className:"px-4 py-3 bg-gray-100 hover:bg-gray-200 rounded-2xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(Je,{className:"w-5 h-5"}),"批量导入"]}),e.jsxs("button",{onClick:()=>m(!0),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(De,{className:"w-5 h-5"}),"添加新卡密"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"px-8 py-5 w-[18%]",children:"卡密名称"}),e.jsx("th",{className:"px-6 py-5 w-[12%]",children:"卡密组ID"}),e.jsx("th",{className:"px-6 py-5 w-[10%]",children:"类型"}),e.jsx("th",{className:"px-6 py-5 w-[22%]",children:"内容/库存"}),e.jsx("th",{className:"px-6 py-5 w-[18%]",children:"描述"}),e.jsx("th",{className:"px-6 py-5 w-[10%]",children:"状态"}),e.jsx("th",{className:"px-6 py-5 w-[10%] text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:s.map(i=>{let P="";return i.type==="data"&&i.data_content?P=`库存: ${i.data_content.split(` +`).filter(ne=>ne.trim()).length} 条`:i.type==="text"&&i.text_content?P=i.text_content.substring(0,20)+(i.text_content.length>20?"...":""):i.type==="api"&&i.api_config?P=i.api_config.url:i.type==="image"&&i.image_url&&(P="图片链接"),e.jsxs("tr",{className:"hover:bg-[#FFFDE7]/50 transition-colors group",children:[e.jsx("td",{className:"px-8 py-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-gray-50 rounded-xl group-hover:bg-white transition-colors",children:e.jsx(H,{type:i.type})}),e.jsx("span",{className:"font-bold text-gray-900",children:i.name})]})}),e.jsx("td",{className:"px-6 py-5",children:e.jsxs("button",{onClick:()=>j(i.id),className:"inline-flex items-center gap-2 rounded-xl bg-gray-100 px-3 py-2 font-mono text-xs font-extrabold text-gray-700 hover:bg-gray-200 transition-colors",title:"复制卡密组ID,用于批量铺货表格",children:[i.id,e.jsx(_t,{className:"w-3.5 h-3.5"})]})}),e.jsx("td",{className:"px-6 py-5",children:e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${i.type==="text"?"bg-blue-50 text-blue-600":i.type==="data"?"bg-purple-50 text-purple-600":i.type==="api"?"bg-blue-50 text-blue-600":"bg-pink-50 text-pink-600"}`,children:i.type==="text"?"文本":i.type==="data"?"批量":i.type==="api"?"API":"图片"})}),e.jsx("td",{className:"px-6 py-5",children:e.jsx("span",{className:"text-sm text-gray-600 font-mono block truncate",title:P,children:P})}),e.jsx("td",{className:"px-6 py-5",children:e.jsx("span",{className:"text-sm text-gray-500 block max-w-[200px] truncate",title:i.description||"-",children:i.description||"-"})}),e.jsx("td",{className:"px-6 py-5",children:e.jsx("button",{onClick:()=>c(i),className:`w-12 h-8 rounded-full relative transition-colors ${i.enabled?"bg-green-500":"bg-gray-300"}`,children:e.jsx("div",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-sm transition-transform ${i.enabled?"left-5":"left-1"}`})})}),e.jsx("td",{className:"px-6 py-5",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>J(i),className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(ze,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>C(i.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",children:e.jsx(Ae,{className:"w-5 h-5"})})]})})]},i.id)})})]})}),s.length===0&&e.jsxs("div",{className:"py-20 text-center text-gray-400",children:[e.jsx(Xs,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:"暂无卡密配置,请点击右上角添加。"})]})]}),r&&w&&ue.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑卡密"}),e.jsx("button",{onClick:()=>h(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(xe,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:["卡密名称 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:p.name||"",onChange:i=>W({...p,name:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:游戏点卡、会员卡等"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡券类型"}),e.jsxs("select",{value:p.type||"text",onChange:i=>W({...p,type:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"请选择类型"}),e.jsx("option",{value:"text",children:"固定文字"}),e.jsx("option",{value:"data",children:"批量数据"}),e.jsx("option",{value:"api",children:"API接口"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),p.type==="api"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 space-y-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900",children:"API 配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"API 地址"}),e.jsx("input",{type:"url",value:p.api_url||"",onChange:i=>W({...p,api_url:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://api.example.com/get-card"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"请求方法"}),e.jsxs("select",{value:p.api_method||"GET",onChange:i=>W({...p,api_method:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"超时时间(秒)"}),e.jsx("input",{type:"number",value:p.api_timeout||10,onChange:i=>W({...p,api_timeout:parseInt(i.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"1",max:"60"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"请求头(JSON 格式)"}),e.jsx("textarea",{value:p.api_headers||"",onChange:i=>W({...p,api_headers:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-20 resize-none font-mono text-sm",placeholder:'{"Authorization": "Bearer token"}'})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"请求参数(JSON 格式)"}),e.jsx("textarea",{value:p.api_params||"",onChange:i=>W({...p,api_params:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-20 resize-none font-mono text-sm",placeholder:'{"type": "card", "count": 1}'})]})]}),p.type==="text"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"固定文字配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"文字内容"}),e.jsx("textarea",{value:p.text_content||"",onChange:i=>W({...p,text_content:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none",placeholder:"请输入要发送的固定文字内容..."})]})]}),p.type==="data"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"批量数据配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"数据内容(一行一个)"}),e.jsx("textarea",{value:p.data_content||"",onChange:i=>W({...p,data_content:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-80 resize-none font-mono text-sm",placeholder:`请输入数据,每行一个: +卡号1:密码1 +卡号2:密码2 +或者 +兑换码1 +兑换码2`}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持格式:卡号:密码 或 单独的兑换码"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-blue-600",children:p.data_content?p.data_content.split(` +`).filter(i=>i.trim()).length:0})," 条"]})]})]}),p.type==="image"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"图片配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),e.jsx("input",{type:"url",value:p.image_url||"",onChange:i=>W({...p,image_url:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://example.com/image.png"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"输入图片卡密的 URL 地址"})]}),p.image_url&&e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片预览"}),e.jsx("img",{src:p.image_url,alt:"预览",className:"max-w-full max-h-48 rounded-xl border border-gray-200",onError:i=>{i.currentTarget.src="https://via.placeholder.com/400x200?text=图片加载失败"}})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"延时发货时间(秒)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",value:p.delay_seconds||0,onChange:i=>W({...p,delay_seconds:parseInt(i.target.value)||0}),className:"flex-1 ios-input px-4 py-3 rounded-xl",min:"0",max:"3600",placeholder:"0"}),e.jsx("span",{className:"text-sm text-gray-500 whitespace-nowrap",children:"秒"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"0表示立即发货,最大3600秒(1小时)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注信息"}),e.jsx("textarea",{value:p.description||"",onChange:i=>W({...p,description:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none",placeholder:"可选的备注信息"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsx("span",{className:"font-bold text-gray-900",children:"启用状态"}),e.jsx("button",{type:"button",onClick:()=>W({...p,enabled:!p.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${p.enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${p.enabled?"translate-x-7":"translate-x-1"}`})})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>h(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:U,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Le,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body),u&&ue.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"780px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"添加新卡密"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"选择交付方式并录入自动发货内容"})]}),e.jsx("button",{onClick:()=>m(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",title:"关闭",children:e.jsx(xe,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡密名称"}),e.jsx("input",{type:"text",value:b.name,onChange:i=>Y({...b,name:i.target.value}),placeholder:"例如:VIP会员卡密",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"类型"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>Y({...b,type:"data",content:""}),className:`p-3 rounded-xl font-bold transition-all ${b.type==="data"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[e.jsx(us,{className:"w-5 h-5 mx-auto mb-1"}),"批量库存"]}),e.jsxs("button",{type:"button",onClick:()=>Y({...b,type:"text",content:""}),className:`p-3 rounded-xl font-bold transition-all ${b.type==="text"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(ks,{className:"w-5 h-5 mx-auto mb-1"}),"文本"]}),e.jsxs("button",{type:"button",onClick:()=>Y({...b,type:"image",content:""}),className:`p-3 rounded-xl font-bold transition-all ${b.type==="image"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(Cs,{className:"w-5 h-5 mx-auto mb-1"}),"图片"]}),e.jsxs("button",{type:"button",onClick:()=>Y({...b,type:"api",content:""}),className:`p-3 rounded-xl font-bold transition-all ${b.type==="api"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(Ss,{className:"w-5 h-5 mx-auto mb-1"}),"API"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:b.type==="data"?"库存内容(一行一个)":b.type==="text"?"固定回复内容":b.type==="image"?"图片 URL":"API 地址"}),b.type==="api"?e.jsx("input",{type:"url",value:b.content,onChange:i=>Y({...b,content:i.target.value}),placeholder:"https://api.example.com/get-code",className:"w-full ios-input px-4 py-3 rounded-xl"}):b.type==="image"?e.jsx("input",{type:"url",value:b.content,onChange:i=>Y({...b,content:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"https://example.com/card.png"}):e.jsx("textarea",{value:b.content,onChange:i=>Y({...b,content:i.target.value}),className:`w-full ios-input px-4 py-3 rounded-xl resize-none text-sm ${b.type==="data"?"h-48 font-mono":"h-32"}`,placeholder:b.type==="data"?`CODE-123456 +CODE-789012 +...`:"请输入每次发货时发送的固定文字"}),b.type==="data"&&e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-[#0094f7]",children:b.content.split(` +`).filter(i=>i.trim()).length})," 条"]})]}),b.type==="api"&&e.jsxs("div",{className:"border-t border-gray-100 pt-5 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求方法"}),e.jsxs("select",{value:b.api_method,onChange:i=>Y({...b,api_method:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"超时时间(秒)"}),e.jsx("input",{type:"number",min:"1",max:"60",value:b.api_timeout,onChange:i=>Y({...b,api_timeout:parseInt(i.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求头(JSON)"}),e.jsx("textarea",{value:b.api_headers,onChange:i=>Y({...b,api_headers:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"Authorization":"Bearer token"}'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求参数(JSON)"}),e.jsx("textarea",{value:b.api_params,onChange:i=>Y({...b,api_params:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"order_id":"{order_id}"}'})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_180px] gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"描述"}),e.jsx("input",{value:b.description,onChange:i=>Y({...b,description:i.target.value}),placeholder:"卡密用途描述(可选)",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"延时发货(秒)"}),e.jsx("input",{type:"number",value:b.delay_seconds,onChange:i=>Y({...b,delay_seconds:parseInt(i.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"3600"})]})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>m(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:k,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(De,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),G&&ue.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"40rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量导入卡密"}),e.jsx("button",{onClick:()=>M(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(xe,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[e.jsxs("button",{onClick:()=>X("create"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${E==="create"?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(kt,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:()=>X("append"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${E==="append"?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(Je,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),E==="create"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl bg-blue-50 border border-blue-100 p-4 text-xs text-blue-900 leading-5",children:["上传表格,每行一个卡密组。表头:",e.jsx("code",{className:"bg-blue-100/70 px-1.5 py-0.5 rounded",children:"名称,类型,内容,描述,启用,延迟秒,多规格,规格名,规格值"}),'。 类型填 text/data/image/api;data 类型的"内容"按行存卡密(CSV 单元格内换行需用引号包裹)。']}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:q,className:"px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text-sm transition-colors",children:[e.jsx(Ct,{className:"w-4 h-4"}),"下载模板"]}),e.jsxs("label",{className:"flex-1 px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text-sm cursor-pointer transition-colors",children:[e.jsx(Je,{className:"w-4 h-4"}),re?re.name:"选择 .xlsx / .csv / .tsv",e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv",className:"hidden",onChange:i=>{var P;return Z(((P=i.target.files)==null?void 0:P[0])||null)}})]})]}),R&&!R.error&&e.jsxs("div",{className:"rounded-xl border border-gray-200 p-4 space-y-2",children:[e.jsxs("div",{className:"text-sm font-bold text-gray-900",children:["共 ",R.total," 行 · 成功 ",R.created," · 失败 ",R.failed]}),R.failed>0&&e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:R.rows.filter(i=>!i.success).map(i=>e.jsxs("div",{className:"text-xs text-red-600",children:["第 ",i.row_no," 行「",i.name,"」:",i.error]},i.row_no))})]})]}):e.jsx("div",{className:"space-y-4",children:N.length===0?e.jsx("div",{className:"rounded-xl bg-amber-50 border border-amber-200 p-4 text-sm text-amber-800",children:"暂无 data(批量卡密)类型的卡密组,请先创建一个再充卡密。"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"选择卡密组"}),e.jsx("select",{value:L,onChange:i=>Q(i.target.value),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",children:N.map(i=>e.jsxs("option",{value:String(i.id),children:[i.name,"(ID: ",i.id,")"]},i.id))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"卡密号(每行一个)"}),e.jsx("textarea",{value:A,onChange:i=>$(i.target.value),placeholder:`VIP-001 +VIP-002 +VIP-003`,className:"w-full ios-input px-4 py-3 rounded-xl text-sm font-mono h-40 resize-y"}),e.jsx("p",{className:"text-xs text-gray-500",children:"一行一个卡密号,空行自动忽略。会追加到该组现有库存末尾。"})]}),d&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",d.added," 个卡密"]})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:()=>M(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),E==="create"?e.jsxs("button",{onClick:D,disabled:!re||T,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[T?e.jsx(_e,{className:"w-4 h-4 animate-spin"}):e.jsx(Je,{className:"w-4 h-4"}),T?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:ee,disabled:!L||!A.trim()||T||N.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[T?e.jsx(_e,{className:"w-4 h-4 animate-spin"}):e.jsx(De,{className:"w-4 h-4"}),T?"处理中...":"追加卡密"]})]})]})}),document.body)]})},Ha=s=>{const a=String(s||"").trim();return a?/^[¥¥]/.test(a)?a:`¥${a}`:"-"},el=({onConfigureDelivery:s})=>{const[a,r]=o.useState([]),[h,u]=o.useState([]),[m,w]=o.useState([]),[I,p]=o.useState(""),[W,b]=o.useState(!1),[Y,G]=o.useState(!1),[M,E]=o.useState(!1),[X,re]=o.useState(!1),[Z,R]=o.useState(!1),[te,T]=o.useState(!1),[F,L]=o.useState(!1),[Q,A]=o.useState("upload"),[$,d]=o.useState(null),[z,H]=o.useState(null),[J,U]=o.useState(null),[C,k]=o.useState(null),[c,j]=o.useState(null),[N,q]=o.useState({}),[D,ee]=o.useState({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),[O,i]=o.useState({cookie_id:"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),P=async()=>{const l=await Ue();r(l)},ae=async()=>{u(await rs())};o.useEffect(()=>{Promise.all([js(),Ue(),rs()]).then(([l,v,le])=>{w(l),r(v),u(le)}).catch(l=>console.error("加载商品配置失败:",l))},[]),o.useEffect(()=>{if(!F||!(C!=null&&C.id)||C.status!=="running")return;const l=window.setInterval(async()=>{try{const v=await es(C.id);k(v),v.status!=="running"&&(A("done"),await P(),await ae())}catch(v){console.error("刷新批量铺货进度失败:",v)}},3e3);return()=>window.clearInterval(l)},[F,C==null?void 0:C.id,C==null?void 0:C.status]);const ne=async()=>{if(!I)return alert("请先选择账号");b(!0);try{const l=await ja(I);await P(),alert((l==null?void 0:l.message)||"商品同步完成")}catch(l){console.error("同步商品失败:",l),alert((l==null?void 0:l.message)||"同步失败,请重试")}finally{b(!1)}},x=l=>{j(l),q({...l}),re(!0)},y=async()=>{if(c)try{await $a(c.cookie_id,c.item_id,{item_title:N.item_title||"",item_description:N.item_description||"",item_category:N.item_category||"",item_price:N.item_price||"",item_detail:N.item_detail||c.item_detail||""}),await P(),await ae(),re(!1),j(null)}catch(l){console.error("更新商品失败:",l),alert("更新失败,请重试")}},V=async l=>{if(confirm(`确认删除商品"${l.item_title}"吗?`))try{await Na(l.cookie_id,l.item_id),r(v=>v.filter(le=>!(le.cookie_id===l.cookie_id&&le.item_id===l.item_id)))}catch(v){console.error("删除商品失败:",v),alert("删除失败,请重试")}},se=async()=>{try{if(!D.cookie_id||!D.item_id){alert("请选择账号并填写商品ID");return}await va(D.cookie_id,{item_id:D.item_id,item_title:D.item_title,item_price:D.item_price,item_detail:D.item_image?JSON.stringify({item_image:D.item_image}):""}),await P(),R(!1),ee({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""})}catch(l){console.error("添加商品失败:",l),alert("添加失败,请重试")}},B=async()=>{if(!O.cookie_id)return alert("请选择发布账号");if(!O.title.trim())return alert("请填写商品标题");if(!O.price.trim())return alert("请填写商品价格");if(!O.quantity||Number(O.quantity)<=0)return alert("库存数量必须大于 0");if(O.images.length===0)return alert("至少上传 1 张商品图片");if(O.postage_mode==="fixed"&&!O.postage.trim())return alert("请填写一口价邮费");G(!0);try{const l=await wa(O);if(await P(),T(!1),i({cookie_id:I||"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),l!=null&&l.item_id){const v={id:l.item_id,cookie_id:O.cookie_id,item_id:l.item_id,item_title:l.item_title||O.title,item_price:l.item_price||O.price,item_image:l.item_image};s(v),alert("商品发布成功,ID: "+l.item_id+",已为你打开发货规则配置")}else alert("商品发布成功")}catch(l){console.error("发布商品失败:",l);const v=l==null?void 0:l.payload;if((v==null?void 0:v.code)==="stock_permission_missing"){alert("发布失败:该账号没有库存发布权限,无法按库存数量发布商品。请换账号或先在闲鱼确认库存能力。");return}alert((l==null?void 0:l.message)||"发布失败,请重试")}finally{G(!1)}},pe=()=>{A("upload"),U(null),k(null),d(null),H(null),L(!0)},je=async()=>{if(!$)return alert("请先上传商品表格");if(!I)return alert("请先选择默认发布账号");E(!0);try{const l=await _a({file:$,imagesZip:z,defaultCookieId:I});U(l),k(null),A("preview")}catch(l){console.error("批量铺货预检失败:",l),alert((l==null?void 0:l.message)||"预检失败,请检查表格和图片 zip")}finally{E(!1)}},he=async()=>{if(J!=null&&J.preview_id){if(J.valid<=0)return alert("没有可发布的商品行");E(!0);try{const l=await ka(J.preview_id),v=await es(l.batch_id||J.preview_id);k(v),A(v.status==="running"?"running":"done")}catch(l){console.error("启动批量铺货失败:",l),alert((l==null?void 0:l.message)||"启动发布任务失败")}finally{E(!1)}}},we=async()=>{if(C!=null&&C.id&&confirm("确认取消当前批量铺货任务吗?正在发布的单个商品可能会继续完成。")){E(!0);try{await Ca(C.id),k(await es(C.id)),A("done")}catch(l){alert((l==null?void 0:l.message)||"取消失败")}finally{E(!1)}}},Ce=async()=>{if(C!=null&&C.id){E(!0);try{await Sa(C.id),k(await es(C.id)),A("running")}catch(l){alert((l==null?void 0:l.message)||"重试失败")}finally{E(!1)}}},Ne=()=>{const le=[["账号ID","标题","描述","价格","原价","库存","邮费模式","邮费","图片","付款发货启用","付款发货内容","评价赠品启用","评价赠品内容","求评价启用","求评价等待小时","求评价文案","求评价最多次数"],...[["","会员组合包自动发货","下单后发送主卡和附赠卡。","19.90","29.90","10","free","","images/bundle-1.jpg;images/bundle-2.jpg","是","101:1;102:1","是","201:1;202:2","是","72","亲,满意的话麻烦给个评价,谢谢~","1"],["","普通商品","仅发布商品,不创建自动化规则。","49.90","","10","fixed","8.00","https://example.com/product.jpg","否","","否","","否","","",""]]].map(Ke=>Ke.map(Xe=>`"${String(Xe).replace(/"/g,'""')}"`).join(",")).join(` +`),$e=new Blob(["\uFEFF"+le],{type:"text/csv;charset=utf-8"}),Se=URL.createObjectURL($e),ve=document.createElement("a");ve.href=Se,ve.download="批量铺货模板.csv",document.body.appendChild(ve),ve.click(),ve.remove(),URL.revokeObjectURL(Se)},ge=()=>{ee(l=>({...l,cookie_id:I||l.cookie_id})),R(!0)},be=()=>{i(l=>({...l,cookie_id:I||l.cookie_id})),T(!0)},t=l=>h.filter(v=>v.cookie_id===l.cookie_id&&v.item_id===l.item_id),g=l=>{switch(l){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"partially_failed":return"部分失败";case"canceled":return"已取消";default:return l||"-"}},S=l=>{switch(l){case"success":case"completed":return"bg-emerald-50 text-emerald-700 border-emerald-100";case"partially_failed":case"failed":return"bg-red-50 text-red-700 border-red-100";case"running":return"bg-blue-50 text-blue-700 border-blue-100";case"canceled":return"bg-gray-100 text-gray-600 border-gray-200";default:return"bg-amber-50 text-amber-700 border-amber-100"}};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"商品管理"}),e.jsx("p",{className:"text-gray-500 mt-2 text-sm",children:"监控并管理所有账号下的闲鱼商品。"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("select",{className:"ios-input px-4 py-3 rounded-xl text-sm",value:I,onChange:l=>p(l.target.value),children:[e.jsx("option",{value:"",children:"选择账号以同步"}),m.map(l=>e.jsx("option",{value:l.id,children:l.nickname},l.id))]}),e.jsxs("button",{onClick:ne,disabled:W||!I,className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:[e.jsx(ke,{className:`w-4 h-4 ${W?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:ge,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-lg",children:[e.jsx(De,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:be,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-600 text-white hover:bg-emerald-700 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(os,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:pe,className:"px-5 py-3 rounded-2xl font-bold bg-blue-600 text-white hover:bg-blue-700 transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx(Ze,{className:"w-4 h-4"}),"批量铺货"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:[a.map(l=>{const v=t(l),le=v.length>0;return e.jsxs("div",{className:"ios-card p-3 rounded-2xl hover:shadow-lg transition-all group relative flex flex-col",children:[e.jsxs("div",{className:"absolute top-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:[e.jsx("button",{onClick:()=>x(l),className:"p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md text-gray-600 hover:bg-[#0094f7] hover:text-white transition-colors",title:"编辑",children:e.jsx(ze,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>V(l),className:"p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md hover:bg-red-100 text-red-500 transition-colors",title:"删除",children:e.jsx(Ae,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"aspect-square bg-gray-100 rounded-xl mb-2.5 overflow-hidden relative",children:[l.item_image?e.jsx("img",{src:l.item_image,alt:"",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300",children:e.jsx(Gs,{className:"w-8 h-8"})}),e.jsx("div",{className:"absolute top-1.5 left-1.5 bg-black/50 backdrop-blur-md text-white text-[10px] font-bold px-1.5 py-0.5 rounded-md",children:Ha(l.item_price)})]}),e.jsx("h3",{className:"font-bold text-gray-900 line-clamp-2 text-xs mb-1.5 h-8 leading-4",children:l.item_title}),e.jsxs("div",{className:"flex justify-between items-center text-[10px] text-gray-500 mb-2",children:[e.jsxs("span",{className:"bg-gray-100 px-1.5 py-0.5 rounded truncate max-w-[80px]",children:["ID: ",l.item_id]}),e.jsxs("span",{className:`inline-flex items-center gap-1 font-bold ${le?"text-emerald-600":"text-amber-600"}`,children:[le?e.jsx(et,{className:"w-3 h-3"}):e.jsx(St,{className:"w-3 h-3"}),le?`${v.length} 规则`:"未配置"]})]}),e.jsx("div",{className:"space-y-2 mt-auto",children:e.jsxs("button",{onClick:()=>s(l),className:`w-full flex items-center justify-between gap-1 px-2.5 py-2 rounded-lg text-[11px] font-extrabold transition-all ${le?"bg-gray-900 text-white hover:bg-black":"bg-[#0094f7] text-white hover:bg-[#0071e3] shadow-md shadow-blue-100"}`,children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx($t,{className:"w-3.5 h-3.5"}),le?"查看发货规则":"关联发货规则"]}),e.jsx(gs,{className:"w-3.5 h-3.5"})]})})]},`${l.cookie_id}-${l.item_id}`)}),a.length===0&&e.jsxs("div",{className:"col-span-full py-20 text-center text-gray-400",children:[e.jsx(Ys,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),"暂无商品数据,请选择账号进行同步"]})]}),X&&c&&ue.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"560px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"编辑商品"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["ID: ",c.item_id]})]}),e.jsx("button",{onClick:()=>re(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(xe,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-4",children:[e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"商品标题",value:N.item_title||"",onChange:l=>q({...N,item_title:l.target.value})}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"价格",value:N.item_price||"",onChange:l=>q({...N,item_price:l.target.value})}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"分类",value:N.item_category||"",onChange:l=>q({...N,item_category:l.target.value})}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述",value:N.item_description||"",onChange:l=>q({...N,item_description:l.target.value})})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:y,className:"w-full ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Le,{className:"w-4 h-4"}),"保存"]})})]})}),document.body),Z&&ue.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"720px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"添加商品"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"手动建立商品与自动发货规则的关联"})]}),e.jsx("button",{onClick:()=>R(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(xe,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"所属账号"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:D.cookie_id,onChange:l=>ee({...D,cookie_id:l.target.value}),children:[e.jsx("option",{value:"",children:"选择账号"}),m.map(l=>e.jsx("option",{value:l.id,children:l.nickname||l.remark||l.id},l.id))]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品 ID"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"输入闲鱼商品 ID",value:D.item_id,onChange:l=>ee({...D,item_id:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品价格"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如 99.00",value:D.item_price,onChange:l=>ee({...D,item_price:l.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品标题"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"输入商品标题",value:D.item_title,onChange:l=>ee({...D,item_title:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"图片 URL"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"https://...",value:D.item_image,onChange:l=>ee({...D,item_image:l.target.value})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:se,className:"w-full ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(De,{className:"w-4 h-4"}),"添加商品"]})})]})}),document.body),te&&ue.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"820px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"发布商品到闲鱼"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"普通单规格发布;库存数量会写入闲鱼发布参数,用于判断账号库存能力。"})]}),e.jsx("button",{onClick:()=>T(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(xe,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx("div",{className:"rounded-2xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-800 leading-6",children:"发布时必须填写库存。若账号没有库存发布能力,后端会返回明确的“库存权限不足”错误,不会误报为普通发布失败。"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"发布账号"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:O.cookie_id,onChange:l=>i({...O,cookie_id:l.target.value}),children:[e.jsx("option",{value:"",children:"选择账号"}),m.map(l=>e.jsx("option",{value:l.id,children:l.nickname||l.remark||l.id},l.id))]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品标题"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:会员月卡自动发货",value:O.title,onChange:l=>i({...O,title:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"库存数量"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",type:"number",min:"1",placeholder:"必须大于 0",value:O.quantity,onChange:l=>i({...O,quantity:l.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品描述"}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述会用于自动识别类目;留空时使用标题",value:O.description,onChange:l=>i({...O,description:l.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"售价"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"99.00",value:O.price,onChange:l=>i({...O,price:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"原价(可选)"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"129.00",value:O.original_price,onChange:l=>i({...O,original_price:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"运费方式"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:O.postage_mode,onChange:l=>i({...O,postage_mode:l.target.value}),children:[e.jsx("option",{value:"free",children:"包邮"}),e.jsx("option",{value:"distance",children:"按距离计费"}),e.jsx("option",{value:"fixed",children:"一口价邮费"}),e.jsx("option",{value:"none",children:"无需邮寄"})]})]})]}),O.postage_mode==="fixed"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"一口价邮费"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如 8.00",value:O.postage,onChange:l=>i({...O,postage:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品图片(1-9 张)"}),e.jsxs("label",{className:"flex min-h-[120px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-emerald-300 hover:bg-emerald-50/50 transition-colors",children:[e.jsx(Ze,{className:"w-8 h-8 text-emerald-600 mb-2"}),e.jsx("span",{className:"text-sm font-bold text-gray-800",children:"选择图片"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:O.images.length?"已选择 "+O.images.length+" 张":"支持 JPG / PNG / GIF"}),e.jsx("input",{className:"hidden",type:"file",accept:"image/*",multiple:!0,onChange:l=>i({...O,images:Array.from(l.target.files||[]).slice(0,9)})})]}),O.images.length>0&&e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-3",children:O.images.map((l,v)=>e.jsx("div",{className:"aspect-square rounded-xl bg-gray-100 overflow-hidden border border-gray-100",children:e.jsx("img",{src:URL.createObjectURL(l),alt:"",className:"w-full h-full object-cover"})},l.name+v))})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{disabled:Y,onClick:B,className:"w-full bg-emerald-600 hover:bg-emerald-700 disabled:opacity-60 text-white px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(os,{className:"w-4 h-4"}),Y?"正在发布...":"发布到闲鱼"]})})]})}),document.body),F&&ue.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"980px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量铺货"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"上传商品表格和图片 zip,先预检,再逐条发布到闲鱼。"})]}),e.jsx("button",{onClick:()=>L(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(xe,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx("div",{className:"grid grid-cols-4 gap-2",children:[["upload","1 上传"],["preview","2 预检"],["running","3 发布"],["done","4 结果"]].map(([l,v])=>e.jsx("div",{className:`rounded-xl px-3 py-2 text-center text-xs font-extrabold border ${Q===l?"bg-blue-600 text-white border-blue-600":"bg-gray-50 text-gray-500 border-gray-100"}`,children:v},l))}),Q==="upload"&&e.jsxs("div",{className:"space-y-5",children:[e.jsx("div",{className:"rounded-2xl border border-blue-100 bg-blue-50 p-4 text-sm text-blue-900 leading-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-extrabold",children:"先下载模板,再按字段填写。"}),e.jsxs("div",{children:["图片字段写 zip 内相对路径,多个图片用英文分号分隔,例如 ",e.jsx("span",{className:"font-mono font-bold",children:"images/a.jpg;images/b.jpg"}),"。也支持直接填写图片 URL。"]})]}),e.jsx("button",{type:"button",onClick:Ne,className:"shrink-0 rounded-xl bg-blue-600 px-4 py-2 text-sm font-extrabold text-white hover:bg-blue-700",children:"下载CSV模板"})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"默认发布账号"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:I,onChange:l=>p(l.target.value),children:[e.jsx("option",{value:"",children:"选择账号"}),m.map(l=>e.jsx("option",{value:l.id,children:l.nickname||l.remark||l.id},l.id))]}),e.jsx("p",{className:"text-xs text-gray-500",children:"表格中“账号ID”为空时,会使用这里选择的账号。"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("label",{className:"flex min-h-[150px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-blue-300 hover:bg-blue-50 transition-colors",children:[e.jsx(Ze,{className:"w-9 h-9 text-blue-600 mb-3"}),e.jsx("span",{className:"text-sm font-extrabold text-gray-900",children:"上传商品表格"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:$?$.name:"支持 .xlsx / .csv / .tsv"}),e.jsx("input",{className:"hidden",type:"file",accept:".xlsx,.csv,.tsv",onChange:l=>{var v;return d(((v=l.target.files)==null?void 0:v[0])||null)}})]}),e.jsxs("label",{className:"flex min-h-[150px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-emerald-300 hover:bg-emerald-50 transition-colors",children:[e.jsx(Ze,{className:"w-9 h-9 text-emerald-600 mb-3"}),e.jsx("span",{className:"text-sm font-extrabold text-gray-900",children:"上传图片 zip(可选)"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:z?z.name:"表格图片字段使用 zip 内相对路径"}),e.jsx("input",{className:"hidden",type:"file",accept:".zip",onChange:l=>{var v;return H(((v=l.target.files)==null?void 0:v[0])||null)}})]})]}),e.jsxs("div",{className:"rounded-2xl bg-gray-50 border border-gray-100 p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"字段说明"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"照着下面的“什么时候填写”处理即可。预检发现问题时,会指出具体哪一行需要修改。"})]}),e.jsxs("div",{className:"rounded-xl border border-blue-100 bg-blue-50 p-4 text-xs text-blue-950",children:[e.jsx("div",{className:"text-sm font-extrabold",children:"“付款后发送的卡密”怎么填"}),e.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-3 lg:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[e.jsx("code",{className:"font-bold text-blue-700",children:"101"}),e.jsx("p",{className:"mt-1 leading-5",children:"从卡密组 101 立即发送 1 份。卡密组 ID 可以在“卡密库存”页面查看。"})]}),e.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[e.jsx("code",{className:"font-bold text-blue-700",children:"101:2"}),e.jsx("p",{className:"mt-1 leading-5",children:"每购买 1 件,就从卡密组 101 发送 2 份。买家购买 3 件时会发送 6 份。"})]}),e.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[e.jsx("code",{className:"font-bold text-blue-700",children:"101:1:0;102:2:3"}),e.jsx("p",{className:"mt-1 leading-5",children:"先立即发送卡密组 101 的 1 份,再等待 3 秒发送卡密组 102 的 2 份。"})]})]}),e.jsxs("p",{className:"mt-3 leading-5 text-blue-800",children:["每一组依次写“卡密组 ID : 每件发送几份 : 等待几秒”。份数不写时按 1 份处理,等待时间不写时立即发送。需要发送多种卡密时,用英文分号 ",e.jsx("code",{className:"font-bold",children:";"})," 隔开。"]})]}),e.jsx("div",{className:"overflow-x-auto rounded-xl border border-gray-100 bg-white",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{className:"bg-gray-50 text-gray-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"字段"}),e.jsx("th",{className:"px-3 py-2",children:"什么时候填写"}),e.jsx("th",{className:"px-3 py-2",children:"填写方法"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50 text-gray-700",children:[["账号ID","没有在上方选择默认账号时填写","填写账号 ID;已经选择默认账号时可以留空"],["标题","每个商品都要填","填写买家能看到的商品标题"],["描述","可以留空","留空时会使用商品标题作为描述"],["价格","每个商品都要填","只填数字,例如 19.90"],["原价","可以留空","需要展示划线原价时填写,例如 29.90"],["库存","可以留空","留空按 1 件处理;填写时必须大于 0"],["邮费模式","可以留空","留空表示包邮;包邮填 free,固定邮费填 fixed"],["邮费","邮费模式填 fixed 时填写","只填数字,例如 8.00"],["图片","每个商品都要填","填写 zip 内图片路径或图片网址;多张图片用英文分号隔开"],["付款后自动发货","需要付款后自动发货时填写","填“是”表示开启;不需要时填“否”或留空"],["付款后发送的卡密","“付款后自动发货”填“是”时填写","从“卡密库存”页面取得卡密组 ID,按上方示例填写"],["评价后发送赠品","需要评价赠品时填写","填“是”表示开启;不需要时填“否”或留空"],["评价后发送的卡密","“评价后发送赠品”填“是”时填写","格式和付款后发送的卡密相同,也可以同时发送多个卡密组"],["超时未评价时提醒","需要自动求评价时填写","填“是”表示开启;不需要时填“否”或留空"],["发货几小时后提醒","“超时未评价时提醒”填“是”时填写","填写等待小时数;留空按 72 小时处理"],["提醒内容","“超时未评价时提醒”填“是”时填写","填写要发送给买家的求评价消息"],["最多提醒几次","可以留空","留空只提醒 1 次"]].map(([l,v,le])=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-bold text-gray-900 whitespace-nowrap",children:l}),e.jsx("td",{className:`px-3 py-2 min-w-[210px] font-bold ${v==="每个商品都要填"?"text-red-600":v==="可以留空"?"text-gray-500":"text-amber-700"}`,children:v}),e.jsx("td",{className:"px-3 py-2 min-w-[260px]",children:le})]},l))})]})})]})]}),Q==="preview"&&J&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"rounded-2xl bg-gray-50 p-4 border border-gray-100",children:[e.jsx("div",{className:"text-xs font-bold text-gray-500",children:"总行数"}),e.jsx("div",{className:"text-2xl font-extrabold text-gray-900 mt-1",children:J.total})]}),e.jsxs("div",{className:"rounded-2xl bg-emerald-50 p-4 border border-emerald-100",children:[e.jsx("div",{className:"text-xs font-bold text-emerald-700",children:"可发布"}),e.jsx("div",{className:"text-2xl font-extrabold text-emerald-700 mt-1",children:J.valid})]}),e.jsxs("div",{className:"rounded-2xl bg-red-50 p-4 border border-red-100",children:[e.jsx("div",{className:"text-xs font-bold text-red-700",children:"有问题"}),e.jsx("div",{className:"text-2xl font-extrabold text-red-700 mt-1",children:J.invalid})]})]}),e.jsx("div",{className:"max-h-[380px] overflow-y-auto rounded-2xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-white text-xs text-gray-400 border-b border-gray-100",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3",children:"行号"}),e.jsx("th",{className:"px-4 py-3",children:"状态"}),e.jsx("th",{className:"px-4 py-3",children:"标题"}),e.jsx("th",{className:"px-4 py-3",children:"价格/库存"}),e.jsx("th",{className:"px-4 py-3",children:"图片"}),e.jsx("th",{className:"px-4 py-3",children:"问题"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:J.rows.map(l=>{var v,le;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:l.row_no}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-1 rounded-lg border text-xs font-extrabold ${l.valid?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-red-50 text-red-700 border-red-100"}`,children:l.valid?"可发布":"需修正"})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[240px] truncate",children:l.title||"-"}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:["¥",l.price||"-"," / ",l.quantity||1]}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:[((v=l.images)==null?void 0:v.length)||0," 张"]}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[280px]",children:((le=l.errors)==null?void 0:le.join(";"))||"-"})]},l.row_no)})})]})})]}),(Q==="running"||Q==="done")&&C&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[e.jsxs("div",{className:`rounded-2xl p-4 border ${S(C.status)}`,children:[e.jsx("div",{className:"text-xs font-bold opacity-70",children:"任务状态"}),e.jsx("div",{className:"text-xl font-extrabold mt-1",children:g(C.status)})]}),e.jsxs("div",{className:"rounded-2xl bg-gray-50 p-4 border border-gray-100",children:[e.jsx("div",{className:"text-xs font-bold text-gray-500",children:"总数"}),e.jsx("div",{className:"text-xl font-extrabold text-gray-900 mt-1",children:C.total})]}),e.jsxs("div",{className:"rounded-2xl bg-emerald-50 p-4 border border-emerald-100",children:[e.jsx("div",{className:"text-xs font-bold text-emerald-700",children:"成功"}),e.jsx("div",{className:"text-xl font-extrabold text-emerald-700 mt-1",children:C.success})]}),e.jsxs("div",{className:"rounded-2xl bg-red-50 p-4 border border-red-100",children:[e.jsx("div",{className:"text-xs font-bold text-red-700",children:"失败"}),e.jsx("div",{className:"text-xl font-extrabold text-red-700 mt-1",children:C.failed})]}),e.jsxs("div",{className:"rounded-2xl bg-blue-50 p-4 border border-blue-100",children:[e.jsx("div",{className:"text-xs font-bold text-blue-700",children:"等待"}),e.jsx("div",{className:"text-xl font-extrabold text-blue-700 mt-1",children:C.pending})]})]}),e.jsx("div",{className:"max-h-[420px] overflow-y-auto rounded-2xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-white text-xs text-gray-400 border-b border-gray-100",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3",children:"行号"}),e.jsx("th",{className:"px-4 py-3",children:"状态"}),e.jsx("th",{className:"px-4 py-3",children:"标题"}),e.jsx("th",{className:"px-4 py-3",children:"商品ID"}),e.jsx("th",{className:"px-4 py-3",children:"错误原因"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:C.rows.map(l=>e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:l.row_no}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-1 rounded-lg border text-xs font-extrabold ${S(l.status)}`,children:g(l.status)})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[260px] truncate",children:l.title}),e.jsx("td",{className:"px-4 py-3 text-xs font-mono",children:l.item_url?e.jsx("a",{href:l.item_url,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline",children:l.item_id}):l.item_id||"-"}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[340px]",children:l.error_message||"-"})]},l.id))})]})})]})]}),e.jsxs("div",{className:"modal-footer",children:[Q==="upload"&&e.jsxs("button",{disabled:M||!$||!I,onClick:je,className:"w-full ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2 disabled:opacity-50",children:[e.jsx(ke,{className:`w-4 h-4 ${M?"animate-spin":""}`}),M?"正在预检...":"开始预检"]}),Q==="preview"&&J&&e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{disabled:M,onClick:()=>A("upload"),className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold",children:"返回修改"}),e.jsxs("button",{disabled:M||J.valid<=0,onClick:he,className:"flex-1 ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2 disabled:opacity-50",children:[e.jsx(os,{className:"w-4 h-4"}),M?"启动中...":`确认发布 ${J.valid} 个商品`]})]}),(Q==="running"||Q==="done")&&C&&e.jsxs("div",{className:"flex gap-3 w-full",children:[C.status==="running"?e.jsx("button",{disabled:M,onClick:we,className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"取消任务"}):e.jsx("button",{onClick:()=>window.open(`/items/publish-batches/${C.id}/result.csv`,"_blank"),className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"下载结果"}),C.failed>0&&C.status!=="running"&&e.jsxs("button",{disabled:M,onClick:Ce,className:"flex-1 ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ke,{className:`w-4 h-4 ${M?"animate-spin":""}`}),"重试失败项"]}),C.status!=="running"&&e.jsx("button",{onClick:()=>{L(!1),P(),ae()},className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold",children:"完成"})]})]})]})}),document.body)]})},Us="https://dashscope.aliyuncs.com/compatible-mode/v1",sl=()=>{const[s,a]=o.useState(null),[r,h]=o.useState(!1),[u,m]=o.useState(!1),[w,I]=o.useState([]),[p,W]=o.useState(!1),[b,Y]=o.useState(""),[G,M]=o.useState(!1),E=o.useRef(null),[X,re]=o.useState(!1),[Z,R]=o.useState(!1),[te,T]=o.useState(!1),[F,L]=o.useState(!1),[Q,A]=o.useState(null),[$,d]=o.useState({new_username:"",current_password:"",new_password:"",confirm_password:""});o.useEffect(()=>{H(),lt().then(c=>{c.username&&d(j=>({...j,new_username:c.username||""}))}).catch(()=>{})},[]),o.useEffect(()=>{const c=j=>{var N;(N=E.current)!=null&&N.contains(j.target)||M(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[]);const z=async(c,j=!1)=>{const N=c||s,q=(N==null?void 0:N.ai_api_url)||(N==null?void 0:N.ai_base_url)||Us;W(!0),Y("");try{const D=await Ea(q,(N==null?void 0:N.ai_api_key)||"");I(D),M(j&&D.length>0),!(N!=null&&N.ai_model)&&D.length>0&&a(ee=>ee&&{...ee,ai_model:D[0]})}catch(D){I([]),M(!1),Y(D.message||"读取模型失败")}finally{W(!1)}},H=()=>{h(!0),nt().then(c=>{a(c),z(c)}).finally(()=>h(!1))},J=async()=>{if(s){m(!0);try{const{smtp_server:c,smtp_port:j,smtp_user:N,smtp_password:q,smtp_from:D,...ee}=s;await it(ee),alert("系统配置已保存")}catch(c){alert("保存失败:"+c.message)}finally{m(!1)}}},U=async c=>{c.preventDefault(),A(null);const j=$.new_username.trim();if(j.length<3){A({type:"error",text:"用户名至少需要 3 个字符"});return}if(!$.current_password){A({type:"error",text:"请输入当前密码确认身份"});return}if($.new_password&&$.new_password.length<8){A({type:"error",text:"新密码至少需要 8 个字符"});return}if($.new_password!==$.confirm_password){A({type:"error",text:"两次输入的新密码不一致"});return}L(!0);try{const N=await Jt({current_password:$.current_password,new_username:j,new_password:$.new_password||void 0});if(!N.success){A({type:"error",text:N.message||"登录凭据更新失败"});return}A({type:"success",text:N.message||"登录凭据已更新"}),window.setTimeout(()=>window.location.reload(),1400)}catch(N){A({type:"error",text:N.message||"登录凭据更新失败"})}finally{L(!1)}};if(!s)return e.jsx("div",{className:"p-8 text-center text-gray-400",children:"加载配置中..."});const C=s.ai_model||"",k=w;return e.jsxs("div",{className:"max-w-6xl mx-auto space-y-8 animate-fade-in pb-24",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-gray-100 rounded-2xl flex items-center justify-center",children:e.jsx(bs,{className:"w-6 h-6 text-gray-600"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-extrabold text-gray-900",children:"系统设置"}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm font-medium",children:"配置全局自动化规则与系统参数"})]})]}),e.jsxs("button",{onClick:H,className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(ke,{className:"w-4 h-4"}),"刷新"]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-gray-100 text-gray-600",children:e.jsx(It,{className:"w-4 h-4"})}),"基础设置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"允许用户注册"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1",children:"开启后允许新用户注册账号"})]}),e.jsx("button",{onClick:()=>a({...s,registration_enabled:!s.registration_enabled}),className:`w-14 h-8 rounded-full transition-all relative ${s.registration_enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("div",{className:`w-6 h-6 bg-white rounded-full absolute top-1 transition-all shadow-md ${s.registration_enabled?"left-7":"left-1"}`})})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"显示默认登录信息"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1",children:"登录页面显示默认账号密码提示"})]}),e.jsx("button",{onClick:()=>a({...s,show_default_login_info:!s.show_default_login_info}),className:`w-14 h-8 rounded-full transition-all relative ${s.show_default_login_info?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("div",{className:`w-6 h-6 bg-white rounded-full absolute top-1 transition-all shadow-md ${s.show_default_login_info?"left-7":"left-1"}`})})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"启用商品自动同步"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1",children:"定时自动获取商品信息到本地数据库"})]}),e.jsx("button",{onClick:()=>a({...s,item_sync_enabled:!s.item_sync_enabled}),className:`w-14 h-8 rounded-full transition-all relative ${s.item_sync_enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("div",{className:`w-6 h-6 bg-white rounded-full absolute top-1 transition-all shadow-md ${s.item_sync_enabled?"left-7":"left-1"}`})})]}),e.jsxs("div",{className:"space-y-3 px-4",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"商品同步间隔(分钟)"}),e.jsx("input",{type:"number",value:Math.round((s.item_sync_interval||600)/60),onChange:c=>{const j=parseInt(c.target.value)||10;a({...s,item_sync_interval:j*60})},className:"w-full ios-input px-4 py-3 rounded-xl",min:"1",max:"1440"}),e.jsx("p",{className:"text-xs text-gray-500",children:"建议:10-60分钟"})]}),e.jsxs("div",{className:"space-y-3 px-4",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"每次最多同步页数"}),e.jsx("input",{type:"number",value:s.item_sync_max_pages||5,onChange:c=>a({...s,item_sync_max_pages:parseInt(c.target.value)||5}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"1",max:"50"}),e.jsx("p",{className:"text-xs text-gray-500",children:"每页20个商品"})]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-[#0094f7] text-white",children:e.jsx(Ks,{className:"w-4 h-4"})}),"AI 智能回复配置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"API 地址"}),e.jsx("input",{type:"text",value:s.ai_api_url||Us,onChange:c=>a({...s,ai_api_url:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"https://api.openai.com/v1"}),e.jsx("p",{className:"text-xs text-gray-500",children:"无需补全 /chat/completions"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:X?"text":"password",value:s.ai_api_key||"",onChange:c=>a({...s,ai_api_key:c.target.value}),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl font-mono text-sm",placeholder:"sk-..."}),e.jsx("button",{type:"button",onClick:()=>re(!X),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:X?e.jsx(Ye,{className:"w-4 h-4"}):e.jsx(Be,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"模型"}),e.jsxs("div",{ref:E,className:"relative flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("input",{value:C,onFocus:()=>w.length>0&&M(!0),onChange:c=>{a({...s,ai_model:c.target.value}),w.length>0&&M(!0)},onKeyDown:c=>{c.key==="Escape"&&M(!1),c.key==="ArrowDown"&&w.length>0&&M(!0)},className:"w-full ios-input px-4 py-3 pr-10 rounded-xl",placeholder:"从接口读取或手动输入模型名"}),e.jsx("button",{type:"button",onClick:()=>w.length>0&&M(c=>!c),disabled:w.length===0,className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 disabled:opacity-30","aria-label":"展开模型列表",children:e.jsx(At,{className:`w-4 h-4 transition-transform ${G?"rotate-180":""}`})}),G&&e.jsx("div",{className:"absolute left-0 right-0 top-[calc(100%+6px)] z-40 max-h-64 overflow-y-auto rounded-xl border border-gray-200 bg-white shadow-xl shadow-gray-200/70 py-1",children:k.length>0?k.map(c=>e.jsxs("button",{type:"button",onClick:()=>{a({...s,ai_model:c}),M(!1)},className:"w-full px-4 py-2.5 text-left text-sm text-gray-700 hover:bg-blue-50 hover:text-[#0094f7] flex items-center justify-between gap-3",children:[e.jsx("span",{className:"truncate",children:c}),c===C&&e.jsx(Fe,{className:"w-4 h-4 shrink-0 text-[#0094f7]"})]},c)):e.jsx("div",{className:"px-4 py-3 text-sm text-gray-400",children:"没有匹配的模型"})})]}),e.jsxs("button",{type:"button",onClick:()=>z(void 0,!0),disabled:p,className:"px-4 py-3 rounded-xl bg-gray-100 text-gray-700 hover:bg-gray-200 disabled:opacity-60 font-bold flex items-center justify-center gap-2 whitespace-nowrap",children:[e.jsx(ke,{className:`w-4 h-4 ${p?"animate-spin":""}`}),"读取模型"]})]}),b?e.jsx("p",{className:"text-xs text-red-500",children:b}):e.jsx("p",{className:"text-xs text-gray-500",children:w.length>0?`已从当前 API 地址读取到 ${w.length} 个模型`:"模型列表从当前 API 地址读取,也可以手动输入模型名"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"默认自动回复内容"}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl min-h-[100px] text-sm resize-none",value:s.default_reply||"",onChange:c=>a({...s,default_reply:c.target.value}),placeholder:"设置默认的自动回复内容..."})]}),e.jsxs("div",{className:"p-3 bg-blue-50 rounded-xl text-xs text-blue-700",children:[e.jsx("strong",{children:"常见 AI 服务:"}),e.jsxs("ul",{className:"list-disc list-inside mt-1 space-y-0.5",children:[e.jsx("li",{children:"阿里云通义千问: https://dashscope.aliyuncs.com/compatible-mode/v1"}),e.jsx("li",{children:"OpenAI: https://api.openai.com/v1"})]})]})]})]})]}),e.jsx("div",{className:"space-y-8",children:e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-gray-900 text-white",children:e.jsx($s,{className:"w-4 h-4"})}),"登录凭据"]}),e.jsxs("form",{onSubmit:U,className:"ios-card rounded-xl p-6 bg-white space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"登录用户名"}),e.jsxs("div",{className:"relative",children:[e.jsx(Dt,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",value:$.new_username,onChange:c=>d({...$,new_username:c.target.value}),className:"w-full ios-input pl-11 pr-4 py-3 rounded-xl text-sm",autoComplete:"username"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"当前密码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:Z?"text":"password",value:$.current_password,onChange:c=>d({...$,current_password:c.target.value}),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm",placeholder:"用于确认当前身份",autoComplete:"current-password"}),e.jsx("button",{type:"button",onClick:()=>R(!Z),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:Z?"隐藏密码":"显示密码",children:Z?e.jsx(Ye,{className:"w-4 h-4"}):e.jsx(Be,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"新密码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:te?"text":"password",value:$.new_password,onChange:c=>d({...$,new_password:c.target.value}),className:"w-full ios-input px-4 py-3 pr-11 rounded-xl text-sm",placeholder:"不修改则留空",autoComplete:"new-password"}),e.jsx("button",{type:"button",onClick:()=>T(!te),className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:te?"隐藏密码":"显示密码",children:te?e.jsx(Ye,{className:"w-4 h-4"}):e.jsx(Be,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"确认新密码"}),e.jsx("input",{type:te?"text":"password",value:$.confirm_password,onChange:c=>d({...$,confirm_password:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"再次输入新密码",autoComplete:"new-password"})]})]}),Q&&e.jsxs("div",{className:`flex items-start gap-2 rounded-xl px-3 py-2.5 text-sm font-medium ${Q.type==="success"?"bg-green-50 text-green-700":"bg-red-50 text-red-700"}`,children:[e.jsx(st,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:Q.text})]}),e.jsxs("button",{type:"submit",disabled:F||!$.new_username||!$.current_password,className:"w-full bg-gray-900 hover:bg-black text-white px-5 py-3 rounded-xl font-bold text-sm flex items-center justify-center gap-2 transition-colors disabled:opacity-40",children:[e.jsx($s,{className:"w-4 h-4"}),F?"正在更新...":"更新登录凭据"]})]})]})})]}),e.jsx("div",{className:"fixed bottom-10 right-10 z-30",children:e.jsxs("button",{onClick:J,disabled:u,className:"ios-btn-primary px-10 py-5 rounded-xl text-lg shadow-2xl shadow-blue-200 flex items-center gap-3 transform hover:scale-105 active:scale-95 transition-all disabled:opacity-70",children:[e.jsx(Le,{className:"w-6 h-6"}),u?"保存中...":"保存所有配置"]})})]})},Re={order_paid:{label:"付款后自动发货",shortLabel:"自动发货",description:"闲鱼付款系统卡片进入自动化中心后,先发送卡密,成功后再确认发货。",flow:["付款系统卡片","匹配商品/规格","发送卡密","确认发货"],accent:"blue",icon:Ge},buyer_reviewed:{label:"评价后发送赠品",shortLabel:"评价赠品",description:"闲鱼评价系统卡片进入自动化中心后,给买家发送赠品卡密。",flow:["评价系统卡片","匹配商品/规格","发送赠品"],accent:"emerald",icon:Lt},review_missing_timeout:{label:"超时未评价求评价",shortLabel:"求评价",description:"计划任务扫描已发货未评价订单,到期后发送求评价文案。",flow:["计划任务扫描","已发货未评价","达到等待时间","发送提醒"],accent:"amber",icon:tt}},ms=["order_paid","buyer_reviewed","review_missing_timeout"],tl="亲,商品使用满意的话,麻烦给个评价,谢谢~",We=()=>({spec_name:"",spec_value:"",card_id:0,delivery_count:1,enabled:!0}),dt=s=>{if(!s)return{};try{const a=JSON.parse(s);return a&&typeof a=="object"&&!Array.isArray(a)?a:{}}catch{return{}}},Oe=(s,a={})=>{const r=dt(s);return JSON.stringify({after_shipped_hours:Number(r.after_shipped_hours||72),max_attempts:Number(r.max_attempts||1),...a})},Qe=(s,a)=>{var h;const r=((h=Re[s])==null?void 0:h.label)||"自动化规则";return a?`${r} - ${a}`:r},Ws=s=>{const a=(s||"").trim();return a?Object.values(Re).some(r=>a===r.label||a.startsWith(`${r.label} -`)):!0},Ve=(s,a=0)=>{if(s==="review_missing_timeout")return[{action_type:"send_text",message_template:tl,enabled:!0,sort_order:1}];const r={action_type:"send_card",card_id:a,delivery_count:1,enabled:!0,sort_order:1};return s==="order_paid"?[r,{action_type:"confirm_shipment",enabled:!0,sort_order:2}]:[r]},al=s=>{var r,h;if(s.trigger_type==="review_missing_timeout")return((h=(r=s.actions)==null?void 0:r.find(u=>u.action_type==="send_text"))==null?void 0:h.message_template)||"发送求评价文案";const a=(s.actions||[]).filter(u=>u.action_type==="send_card");return a.length?a.map(u=>u.card_name||`卡密 ${u.card_id}`).join(" / "):"未配置卡密库存"},Qs=(s,a=!1)=>{const r={blue:a?"border-blue-500 bg-blue-50 text-blue-700":"border-blue-100 bg-blue-50/60 text-blue-700 hover:border-blue-300",emerald:a?"border-emerald-500 bg-emerald-50 text-emerald-700":"border-emerald-100 bg-emerald-50/60 text-emerald-700 hover:border-emerald-300",amber:a?"border-amber-500 bg-amber-50 text-amber-700":"border-amber-100 bg-amber-50/60 text-amber-700 hover:border-amber-300"};return r[s]||r.blue},ll=s=>s?"bg-emerald-100 text-emerald-700":"bg-gray-200 text-gray-500",ts=s=>(s==null?void 0:s.nickname)||(s==null?void 0:s.remark)||(s==null?void 0:s.id)||"未知账号",rl=s=>s===!0||s===1||s==="1",nl=({initialDeliveryTarget:s,onDeliveryTargetHandled:a})=>{var ve,Ke,Xe;const[r,h]=o.useState("automation"),[u,m]=o.useState([]),[w,I]=o.useState([]),[p,W]=o.useState({}),[b,Y]=o.useState([]),[G,M]=o.useState([]),[E,X]=o.useState([]),[re,Z]=o.useState(!1),[R,te]=o.useState(""),[T,F]=o.useState(!1),[L,Q]=o.useState(!1),[A,$]=o.useState(!1),[d,z]=o.useState(null),[H,J]=o.useState(null),[U,C]=o.useState({cookie_id:"",enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""});b.find(n=>n.id===R);const k=o.useCallback(async()=>{const[n,f,_,K]=await Promise.all([js(),Ie(),Ue(),Ts()]);Y(n),M(f),X(_),W(K),te(ce=>{var ye;return ce||((ye=n[0])==null?void 0:ye.id)||""})},[]),c=o.useCallback(async()=>{m(await rs())},[]),j=o.useCallback(async()=>{if(!R){I([]);return}I(await Da(R))},[R]),N=o.useCallback(async()=>{W(await Ts())},[]),q=o.useCallback(async()=>{Z(!0);try{r==="automation"?await c():r==="reply"?await j():await N()}finally{Z(!1)}},[r,c,N,j]);o.useEffect(()=>{k()},[k]),o.useEffect(()=>{q()},[q]);const D=o.useMemo(()=>u.filter(n=>!R||n.cookie_id===R),[u,R]),ee=o.useMemo(()=>b.filter(n=>!R||n.id===R),[b,R]),O=o.useMemo(()=>{var f;const n={order_paid:[],buyer_reviewed:[],review_missing_timeout:[]};for(const _ of D)(f=n[_.trigger_type])==null||f.push(_);return n},[D]),i=o.useMemo(()=>{const n=(d==null?void 0:d.cookie_id)||R;return E.filter(f=>f.cookie_id===n)},[d==null?void 0:d.cookie_id,E,R]),P=o.useMemo(()=>{if(!(!(d!=null&&d.cookie_id)||!(d!=null&&d.item_id)))return E.find(n=>n.cookie_id===d.cookie_id&&n.item_id===d.item_id)},[d==null?void 0:d.cookie_id,d==null?void 0:d.item_id,E]),ae=rl(P==null?void 0:P.is_multi_spec),ne=(d==null?void 0:d.trigger_type)||"order_paid",x=Re[ne],y=dt(d==null?void 0:d.config_json),V=o.useCallback((n="order_paid",f=R,_="")=>{const K=E.find(ye=>ye.cookie_id===f&&ye.item_id===_),ce=(K==null?void 0:K.item_title)||_;return{name:Qe(n,ce),trigger_type:n,cookie_id:f,item_id:_,item_title:(K==null?void 0:K.item_title)||"",item_keyword:ce,card_group_id:0,priority:100,enabled:!0,config_json:n==="review_missing_timeout"?Oe():"{}",actions:Ve(n),variants:n==="review_missing_timeout"?[]:[We()]}},[E,R]),se=o.useCallback(n=>{var _,K;const f=n.trigger_type||"order_paid";z({...n,trigger_type:f,config_json:f==="review_missing_timeout"?Oe(n.config_json):n.config_json||"{}",actions:(_=n.actions)!=null&&_.length?n.actions.map(ce=>({...ce})):Ve(f,n.card_group_id),variants:(K=n.variants)!=null&&K.length?n.variants.map(ce=>({...ce})):f==="review_missing_timeout"?[]:[We()]}),F(!0)},[]);o.useEffect(()=>{if(!s)return;let n=!1;return(async()=>{h("automation"),te(s.cookieId),Z(!0);try{const[_,K,ce]=await Promise.all([rs(),Ue(),Ie().catch(oe=>(console.warn("加载卡密库存失败,不阻断打开自动化规则",oe),[]))]);if(n)return;m(_),X(K),M(ce);const ye=_.find(oe=>oe.cookie_id===s.cookieId&&oe.item_id===s.itemId&&oe.trigger_type==="order_paid");if(ye)se(ye);else{const oe=K.find(Pe=>Pe.cookie_id===s.cookieId&&Pe.item_id===s.itemId);z({...V("order_paid",s.cookieId,s.itemId),item_title:(oe==null?void 0:oe.item_title)||"",item_keyword:(oe==null?void 0:oe.item_title)||s.itemId,name:Qe("order_paid",(oe==null?void 0:oe.item_title)||s.itemId)}),F(!0)}}catch(_){console.error("打开商品自动化规则失败",_),alert("无法加载该商品的自动化规则")}finally{n||(Z(!1),a==null||a())}})(),()=>{n=!0}},[V,s,a,se]);const B=(n="order_paid")=>{if(!R){alert("请先选择账号");return}z(V(n)),F(!0)},pe=n=>{var K,ce,ye,oe,Pe;if(!d)return;const f=((ce=(K=d.variants)==null?void 0:K.find(me=>me.card_id))==null?void 0:ce.card_id)||((oe=(ye=d.actions)==null?void 0:ye.find(me=>me.action_type==="send_card"))==null?void 0:oe.card_id)||d.card_group_id||0,_=(P==null?void 0:P.item_title)||d.item_title||d.item_id||"";z({...d,trigger_type:n,name:Ws(d.name)?Qe(n,_):d.name,card_group_id:f,config_json:n==="review_missing_timeout"?Oe(d.config_json):"{}",actions:Ve(n,f),variants:n==="review_missing_timeout"?[]:(Pe=d.variants)!=null&&Pe.length?d.variants:[{...We(),card_id:f}]})},je=n=>{if(!d)return;const f=E.find(K=>K.cookie_id===(d.cookie_id||R)&&K.item_id===n),_=(f==null?void 0:f.item_title)||n;z({...d,item_id:n,item_title:(f==null?void 0:f.item_title)||"",item_keyword:_,name:Ws(d.name)?Qe(ne,_):d.name})},he=(ve=d==null?void 0:d.variants)!=null&&ve.length?d.variants:[We()],we=(n,f)=>{var K;if(!d)return;const _=he.map((ce,ye)=>ye===n?{...ce,...f}:ce);z({...d,variants:_,card_group_id:((K=_[0])==null?void 0:K.card_id)||0})},Ce=()=>{if(!d)return;const n=he[he.length-1];z({...d,variants:[...he,{...We(),spec_name:ae&&(n==null?void 0:n.spec_name)||"",spec_value:ae&&(n==null?void 0:n.spec_value)||""}]})},Ne=async()=>{var K,ce,ye,oe,Pe;if(!d)return;const n=d.trigger_type||"order_paid";if(!d.cookie_id){alert("请选择账号");return}const f=(K=d.variants)!=null&&K.length?d.variants:[];if(n!=="review_missing_timeout"){if(!f.length||f.some(me=>!me.card_id)){alert(n==="buyer_reviewed"?"请选择评价赠品卡密库存":"请选择发货卡密库存");return}if(ae&&f.some(me=>!me.spec_name.trim()||!me.spec_value.trim())){alert("多规格商品必须填写每一行的规格名称和规格值");return}}if(n==="review_missing_timeout"&&!(((ye=(ce=d.actions)==null?void 0:ce.find(mt=>mt.action_type==="send_text"))==null?void 0:ye.message_template)||"").trim()){alert("请填写求评价文案");return}const _=n==="review_missing_timeout"?[]:f.map(me=>({...me,spec_name:ae?me.spec_name.trim():"",spec_value:ae?me.spec_value.trim():"",delivery_count:Math.max(1,Number(me.delivery_count)||1),enabled:me.enabled!==!1}));try{await Os({...d,trigger_type:n,name:(d.name||"").trim()||Qe(n,(P==null?void 0:P.item_title)||d.item_id||""),config_json:n==="review_missing_timeout"?Oe(d.config_json):d.config_json||"{}",actions:(oe=d.actions)!=null&&oe.length?d.actions:Ve(n,((Pe=_[0])==null?void 0:Pe.card_id)||d.card_group_id||0),variants:_}),F(!1),await Promise.all([c(),k()]),alert("保存成功")}catch(me){console.error("保存自动化规则失败:",me),alert("保存失败:"+me.message)}},ge=async n=>{if(confirm("确定删除该自动化规则吗?"))try{await Aa(n),await c(),alert("删除成功")}catch(f){alert("删除失败:"+f.message)}},be=async n=>{try{await Os({...n,enabled:!n.enabled}),await c()}catch(f){alert("操作失败:"+f.message)}},t=()=>{if(!R){alert("请先选择账号");return}J({keyword:"",reply_content:"",match_type:"exact",enabled:!0}),Q(!0)},g=async()=>{var n,f;if(!(!H||!R)){if(!((n=H.keyword)!=null&&n.trim())||!((f=H.reply_content)!=null&&f.trim())){alert("请填写关键词和回复内容");return}try{await La({...H,match_type:H.match_type||"exact",enabled:!0},R),Q(!1),await j(),alert("保存成功")}catch(_){alert("保存失败:"+_.message)}}},S=async n=>{if(!(!R||!confirm("确定删除该回复规则吗?")))try{await Pa(n,R),await j(),alert("删除成功")}catch(f){alert("删除失败:"+f.message)}},l=async(n=R)=>{if(!n){alert("请先选择账号");return}try{const f=await za(n);C({cookie_id:n,enabled:f.enabled,reply_content:f.reply_content,reply_once:f.reply_once,reply_image_url:f.reply_image_url||""})}catch{C({cookie_id:n,enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""})}$(!0)},v=async()=>{if(!U.cookie_id){alert("请先选择账号");return}if(U.enabled&&!U.reply_content.trim()&&!U.reply_image_url.trim()){alert("启用默认回复时,请填写回复内容或图片 URL");return}try{await Ua(U.cookie_id,{enabled:U.enabled,reply_content:U.reply_content,reply_once:U.reply_once,reply_image_url:U.reply_image_url}),$(!1),await N(),alert("保存成功")}catch(n){alert("保存失败:"+n.message)}},le=async n=>{if(confirm("确定删除该账号默认回复吗?"))try{await Wa(n),await N(),alert("删除成功")}catch(f){alert("删除失败:"+f.message)}},$e=async n=>{if(confirm("确定清空该账号的默认回复记录吗?清空后可重新对所有会话使用“只回复一次”。"))try{await Qa(n),alert("清空成功")}catch(f){alert("清空失败:"+f.message)}},Se=r==="automation"?"新建自动化":r==="reply"?"新增关键词":"编辑默认回复";return e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"自动化规则"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"系统通知卡片只进入自动化判断;买家消息进入关键词、默认或 AI 回复。"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("select",{value:R,onChange:n=>te(n.target.value),className:"ios-input px-4 py-3 rounded-2xl text-sm min-w-64",children:[e.jsx("option",{value:"",children:"全部账号"}),b.map(n=>e.jsx("option",{value:n.id,children:ts(n)},n.id))]}),e.jsxs("button",{onClick:q,className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 hover:bg-gray-200 text-gray-700 flex items-center justify-center gap-2 transition-colors",children:[e.jsx(ke,{className:`w-4 h-4 ${re?"animate-spin":""}`}),"刷新"]}),e.jsxs("button",{onClick:r==="automation"?()=>B("order_paid"):r==="reply"?t:()=>void l(),disabled:!R,className:"ios-btn-primary px-5 py-3 rounded-2xl text-sm font-extrabold flex items-center justify-center gap-2 disabled:opacity-50",children:[e.jsx(De,{className:"w-4 h-4"}),Se]})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[{id:"automation",label:"交易自动化",icon:ps},{id:"reply",label:"关键词回复",icon:as},{id:"default",label:"账号默认回复",icon:Te}].map(n=>{const f=n.icon;return e.jsxs("button",{onClick:()=>h(n.id),className:`inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${r===n.id?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:[e.jsx(f,{className:"w-4 h-4"}),n.label]},n.id)})}),r==="automation"&&e.jsxs("div",{className:"grid grid-cols-1 2xl:grid-cols-[360px_1fr] gap-6",children:[e.jsxs("aside",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white rounded-xl p-5 border border-gray-100 shadow-sm",children:[e.jsx("h3",{className:"font-black text-gray-900 mb-1",children:"新建规则"}),e.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"先选自动化类型,再配置对应动作。"}),e.jsx("div",{className:"space-y-3",children:ms.map(n=>{const f=Re[n],_=f.icon;return e.jsx("button",{type:"button",onClick:()=>B(n),className:`w-full text-left rounded-2xl border p-4 transition-colors ${Qs(f.accent)}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/80 flex items-center justify-center shrink-0",children:e.jsx(_,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-extrabold",children:f.label}),e.jsx("div",{className:"text-xs opacity-75 mt-1 leading-5",children:f.description})]})]})},n)})})]}),e.jsxs("div",{className:"bg-white rounded-xl p-5 border border-gray-100 shadow-sm",children:[e.jsx("h3",{className:"font-black text-gray-900 mb-4",children:"规则概览"}),e.jsx("div",{className:"space-y-3",children:ms.map(n=>{const f=Re[n],_=f.icon;return e.jsxs("div",{className:"flex items-center justify-between rounded-2xl bg-gray-50 p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(_,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{className:"text-sm font-bold text-gray-700",children:f.shortLabel})]}),e.jsx("span",{className:"text-sm font-black text-gray-900",children:O[n].length})]},n)})})]})]}),e.jsx("section",{className:"space-y-4",children:D.length===0?e.jsxs("div",{className:"bg-white rounded-xl border border-dashed border-gray-200 p-16 text-center",children:[e.jsx(ps,{className:"w-12 h-12 text-gray-300 mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-black text-gray-900",children:"还没有自动化规则"}),e.jsx("p",{className:"text-gray-500 mt-2",children:"从左侧选择一个模板开始配置。"})]}):D.map(n=>{const f=Re[n.trigger_type],_=f.icon;return e.jsx("article",{className:"bg-white rounded-xl border border-gray-100 p-5 shadow-sm hover:shadow-lg transition-all",children:e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-4 min-w-0",children:[e.jsx("div",{className:`w-12 h-12 rounded-2xl flex items-center justify-center shrink-0 ${Qs(f.accent,!0)}`,children:e.jsx(_,{className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("h3",{className:"text-lg font-black text-gray-900 truncate",children:n.name}),e.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-bold ${ll(n.enabled)}`,children:n.enabled?"已启用":"已禁用"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs font-bold",children:[e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-gray-100 text-gray-600",children:f.label}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-gray-100 text-gray-600",children:n.item_title||n.item_id||"账号级规则"}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-blue-50 text-blue-700",children:al(n)})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{onClick:()=>se(n),className:"px-4 py-2 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-700 text-sm font-bold flex items-center gap-2",children:[e.jsx(ze,{className:"w-4 h-4"}),"编辑"]}),e.jsx("button",{onClick:()=>be(n),className:`px-4 py-2 rounded-xl text-sm font-bold ${n.enabled?"bg-amber-50 text-amber-700 hover:bg-amber-100":"bg-emerald-50 text-emerald-700 hover:bg-emerald-100"}`,children:n.enabled?"禁用":"启用"}),e.jsx("button",{onClick:()=>ge(n.id),className:"p-2.5 rounded-xl text-red-500 hover:bg-red-50",title:"删除",children:e.jsx(Ae,{className:"w-4 h-4"})})]})]})},n.id)})})]}),r==="reply"&&e.jsxs("section",{className:"bg-white rounded-xl border border-gray-100 p-6 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-700 bg-blue-50 px-4 py-2 rounded-xl mb-5 w-fit",children:[e.jsx(ls,{className:"w-4 h-4"}),"这里只处理买家用户消息;系统通知不会进入关键词或 AI 回复。"]}),e.jsxs("div",{className:"space-y-3",children:[w.map(n=>e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border border-gray-100 bg-[#F7F8FA] hover:bg-white hover:shadow-lg transition-all gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"px-3 py-1 bg-black text-white rounded-lg text-xs font-bold",children:n.match_type==="exact"?"精确匹配":"模糊包含"}),e.jsxs("h3",{className:"font-bold text-gray-900",children:["“",n.keyword,"”"]})]}),e.jsx("div",{className:"bg-white p-3 rounded-xl border border-gray-100 text-sm text-gray-600 leading-relaxed",children:n.reply_content})]}),e.jsxs("div",{className:"flex items-center gap-3 border-t md:border-t-0 md:border-l border-gray-200 pt-4 md:pt-0 md:pl-6",children:[e.jsx("button",{onClick:()=>{J({...n}),Q(!0)},className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(ze,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>S(n.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Ae,{className:"w-5 h-5"})})]})]},n.id)),w.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无关键词回复规则"})]})]}),r==="default"&&e.jsxs("section",{className:"bg-white rounded-xl border border-gray-100 p-6 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-700 bg-blue-50 px-4 py-2 rounded-xl mb-5 w-fit",children:[e.jsx(ls,{className:"w-4 h-4"}),"默认回复只处理买家用户消息;关键词未命中且 AI 未接管时才会使用。"]}),e.jsxs("div",{className:"space-y-3",children:[ee.map(n=>{const f=p[n.id],_=!!(f!=null&&f.enabled);return e.jsxs("div",{className:`flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border transition-all gap-4 ${_?"border-purple-100 bg-purple-50/50 hover:bg-white hover:shadow-lg":"border-gray-100 bg-[#F7F8FA] hover:bg-white hover:shadow-lg"}`,children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[e.jsx("div",{className:`w-12 h-12 rounded-2xl flex items-center justify-center ${_?"bg-purple-600 text-white":"bg-gray-200 text-gray-400"}`,children:e.jsx(Te,{className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h3",{className:"font-bold text-gray-900 text-lg truncate",children:ts(n)}),e.jsx("span",{className:`px-2 py-0.5 rounded-lg text-xs font-bold ${_?"bg-green-100 text-green-700":"bg-gray-200 text-gray-500"}`,children:_?"已启用":"未启用"}),(f==null?void 0:f.reply_once)&&e.jsx("span",{className:"px-2 py-0.5 rounded-lg text-xs font-bold bg-purple-100 text-purple-700",children:"只回复一次"})]}),e.jsx("div",{className:"text-sm text-gray-600 line-clamp-2",children:_?f.reply_content||f.reply_image_url||"已配置默认回复":"未配置默认回复"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 border-t md:border-t-0 md:border-l border-gray-200 pt-4 md:pt-0 md:pl-6",children:[e.jsx("button",{onClick:()=>void l(n.id),className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(ze,{className:"w-4 h-4"})}),_&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>void $e(n.id),className:"px-3 py-2 text-xs font-bold text-blue-600 hover:bg-blue-50 rounded-xl transition-colors",children:"清空记录"}),e.jsx("button",{onClick:()=>void le(n.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Ae,{className:"w-5 h-5"})})]})]})]},n.id)}),ee.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无账号"})]})]}),T&&d&&ue.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"72rem",maxHeight:"92vh"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-black text-gray-900",children:d.id?"编辑自动化规则":"新建自动化规则"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:x.description})]}),e.jsx("button",{onClick:()=>F(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",title:"关闭",children:e.jsx(xe,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[320px_1fr] min-h-0",children:[e.jsxs("aside",{className:"bg-slate-900 text-white p-5 overflow-y-auto",children:[e.jsx("div",{className:"text-xs font-bold text-slate-400 mb-3",children:"选择自动化类型"}),e.jsx("div",{className:"space-y-3",children:ms.map(n=>{const f=Re[n],_=f.icon,K=ne===n;return e.jsx("button",{type:"button",onClick:()=>pe(n),className:`w-full rounded-2xl p-4 text-left border transition-all ${K?"bg-white text-slate-950 border-white":"bg-white/5 text-white border-white/10 hover:bg-white/10"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_,{className:`w-5 h-5 mt-0.5 ${K?"text-[#0094f7]":"text-white"}`}),e.jsxs("div",{children:[e.jsx("div",{className:"font-black",children:f.label}),e.jsx("div",{className:`text-xs mt-1 leading-5 ${K?"text-gray-500":"text-gray-400"}`,children:f.description})]})]})},n)})}),e.jsxs("div",{className:"mt-6 rounded-2xl bg-white/5 border border-white/10 p-4",children:[e.jsx("div",{className:"text-xs font-bold text-slate-400 mb-3",children:"执行流程"}),e.jsx("div",{className:"space-y-3",children:x.flow.map((n,f)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-white text-slate-950 text-xs font-black flex items-center justify-center",children:f+1}),e.jsx("span",{className:"text-sm font-bold text-gray-100",children:n})]},n))})]})]}),e.jsx("div",{className:"p-6 overflow-y-auto bg-[#F7F8FA]",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(et,{className:"w-5 h-5 text-[#0094f7]"}),e.jsx("h4",{className:"font-black text-gray-900",children:"生效范围"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"规则名称"}),e.jsx("input",{type:"text",value:d.name||"",onChange:n=>z({...d,name:n.target.value}),placeholder:"不填时按类型和商品自动生成",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"闲鱼账号"}),e.jsxs("select",{value:d.cookie_id||"",onChange:n=>z({...d,cookie_id:n.target.value,item_id:"",item_title:"",item_keyword:""}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"选择账号"}),b.map(n=>e.jsx("option",{value:n.id,children:ts(n)},n.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关联商品"}),e.jsxs("select",{value:d.item_id||"",onChange:n=>je(n.target.value),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级规则(不限定商品)"}),i.map(n=>e.jsx("option",{value:n.item_id,children:n.item_title||n.item_id},`${n.cookie_id}-${n.item_id}`))]})]})]}),P&&ne!=="review_missing_timeout"&&e.jsxs("div",{className:"mt-4 rounded-2xl bg-gray-50 border border-gray-100 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("span",{className:"px-3 py-1.5 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:P.item_title||P.item_id}),e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${ae?"bg-blue-50 text-blue-700":"bg-gray-100 text-gray-500"}`,children:ae?"多规格商品":"普通商品"}),e.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs font-bold bg-emerald-50 text-emerald-700",children:"按订单购买数量自动发货"})]}),e.jsx("p",{className:"text-xs leading-5 text-gray-500",children:"多规格状态来自闲鱼商品本身,发布后不能在这里修改;系统会在买家付款后读取订单详情,按实际购买规格和数量匹配下面的发货规则。"})]})]}),ne!=="review_missing_timeout"?e.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pt,{className:"w-5 h-5 text-[#0094f7]"}),e.jsx("h4",{className:"font-black text-gray-900",children:ne==="buyer_reviewed"?"赠品库存":"发货库存"})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:ae?"每条发货内容绑定一个订单规格;同一规格可添加多条内容并全部发送。":"可添加多条发货内容,买家付款后会按顺序全部发送。"})]}),e.jsxs("button",{type:"button",onClick:Ce,className:"px-3 py-2 rounded-xl bg-gray-900 text-white text-xs font-bold hover:bg-black flex items-center gap-1.5",children:[e.jsx(De,{className:"w-3.5 h-3.5"}),"添加发货内容"]})]}),e.jsx("div",{className:"space-y-3",children:he.map((n,f)=>e.jsxs("div",{className:`grid grid-cols-1 gap-3 items-end rounded-2xl border border-gray-200 p-4 ${ae?"md:grid-cols-[1fr_1fr_1.4fr_110px_40px]":"md:grid-cols-[1.4fr_110px_40px]"}`,children:[ae&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"规格名称"}),e.jsx("input",{value:n.spec_name,onChange:_=>we(f,{spec_name:_.target.value}),className:"w-full ios-input px-3 py-2.5 rounded-lg",placeholder:"例如:套餐"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"规格值"}),e.jsx("input",{value:n.spec_value,onChange:_=>we(f,{spec_value:_.target.value}),className:"w-full ios-input px-3 py-2.5 rounded-lg",placeholder:"例如:30天"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"卡密库存"}),e.jsxs("select",{value:n.card_id||"",onChange:_=>we(f,{card_id:Number(_.target.value)}),className:"w-full ios-input px-3 py-2.5 rounded-lg",children:[e.jsx("option",{value:"",children:"请选择卡密库存"}),G.filter(_=>_.enabled).map(_=>e.jsx("option",{value:_.id,children:_.name},_.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"每件份数"}),e.jsx("input",{type:"number",min:"1",max:"100",value:n.delivery_count,onChange:_=>we(f,{delivery_count:Math.max(1,Number(_.target.value)||1)}),className:"w-full ios-input px-3 py-2.5 rounded-lg"})]}),e.jsx("button",{type:"button",disabled:he.length===1,onClick:()=>z({...d,variants:he.filter((_,K)=>K!==f)}),className:"w-10 h-10 flex items-center justify-center rounded-lg text-red-500 hover:bg-red-50 disabled:opacity-25",title:"删除发货内容",children:e.jsx(Ae,{className:"w-4 h-4"})})]},n.id||f))})]}):e.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(tt,{className:"w-5 h-5 text-amber-600"}),e.jsx("h4",{className:"font-black text-gray-900",children:"求评价计划"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"发货后等待小时"}),e.jsx("input",{type:"number",min:"1",value:Number(y.after_shipped_hours||72),onChange:n=>z({...d,config_json:Oe(d.config_json,{after_shipped_hours:Math.max(1,Number(n.target.value)||72)})}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最多求评次数"}),e.jsx("input",{type:"number",min:"1",value:Number(y.max_attempts||1),onChange:n=>z({...d,config_json:Oe(d.config_json,{max_attempts:Math.max(1,Number(n.target.value)||1)})}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"求评价文案"}),e.jsx("textarea",{value:((Xe=(Ke=d.actions)==null?void 0:Ke.find(n=>n.action_type==="send_text"))==null?void 0:Xe.message_template)||"",onChange:n=>{var f;return z({...d,actions:((f=d.actions)!=null&&f.length?d.actions:Ve("review_missing_timeout")).map(_=>_.action_type==="send_text"?{..._,message_template:n.target.value}:_)})},className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none"})]})]})]}),e.jsx("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-[180px_1fr] gap-4 items-end",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"优先级"}),e.jsx("input",{type:"number",value:d.priority||100,onChange:n=>z({...d,priority:Number(n.target.value)||100}),min:"1",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("label",{className:"h-[48px] flex items-center gap-3 px-4 bg-gray-50 rounded-xl text-sm font-bold text-gray-800",children:[e.jsx("input",{type:"checkbox",checked:d.enabled!==!1,onChange:n=>z({...d,enabled:n.target.checked}),className:"w-4 h-4 rounded"}),"启用规则"]})]})})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 bg-white flex gap-3",children:[e.jsx("button",{onClick:()=>F(!1),className:"flex-1 px-6 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200",children:"取消"}),e.jsxs("button",{onClick:Ne,className:"flex-1 ios-btn-primary px-6 py-3 rounded-2xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Le,{className:"w-4 h-4"}),"保存自动化规则"]})]})]})}),document.body),L&&H&&ue.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:H.id?"编辑回复规则":"新增回复规则"}),e.jsx("button",{onClick:()=>Q(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(xe,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关键词"}),e.jsx("input",{type:"text",value:H.keyword||"",onChange:n=>J({...H,keyword:n.target.value}),placeholder:"买家发送的关键词",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复内容"}),e.jsx("textarea",{value:H.reply_content||"",onChange:n=>J({...H,reply_content:n.target.value}),placeholder:"自动回复的内容",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"匹配类型"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("button",{type:"button",onClick:()=>J({...H,match_type:"exact"}),className:`p-3 rounded-xl font-bold transition-all ${H.match_type!=="fuzzy"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600"}`,children:"精确匹配"}),e.jsx("button",{type:"button",onClick:()=>J({...H,match_type:"fuzzy"}),className:`p-3 rounded-xl font-bold transition-all ${H.match_type==="fuzzy"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600"}`,children:"模糊包含"})]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:()=>Q(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:g,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ys,{className:"w-4 h-4"}),"保存规则"]})]})]})]})}),document.body),A&&ue.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"账号默认回复"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"关键词和 AI 都未处理时,才会使用默认回复。"})]}),e.jsx("button",{onClick:()=>$(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",title:"关闭",children:e.jsx(xe,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"闲鱼账号"}),e.jsxs("select",{value:U.cookie_id,onChange:n=>C({...U,cookie_id:n.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"选择账号"}),b.map(n=>e.jsx("option",{value:n.id,children:ts(n)},n.id))]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"启用默认回复"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1",children:"启用后,未命中关键词时自动发送"})]}),e.jsx("button",{type:"button",onClick:()=>C({...U,enabled:!U.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${U.enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${U.enabled?"translate-x-7":"translate-x-1"}`})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复内容"}),e.jsx("textarea",{value:U.reply_content,onChange:n=>C({...U,reply_content:n.target.value}),placeholder:"输入默认回复内容",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复图片 URL(可选)"}),e.jsx("input",{type:"text",value:U.reply_image_url,onChange:n=>C({...U,reply_image_url:n.target.value}),placeholder:"https://example.com/image.jpg",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("label",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl text-sm font-bold text-gray-800",children:[e.jsxs("span",{children:["只回复一次",e.jsx("span",{className:"block text-xs text-gray-500 font-medium mt-1",children:"同一会话只发送一次默认回复"})]}),e.jsx("input",{type:"checkbox",checked:U.reply_once,onChange:n=>C({...U,reply_once:n.target.checked}),className:"w-4 h-4 rounded"})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:()=>$(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:v,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Le,{className:"w-4 h-4"}),"保存默认回复"]})]})]})]})}),document.body)]})},Me={bark:{label:"Bark",icon:qe,fields:[{key:"server_url",label:"Bark 服务器",placeholder:"https://api.day.app",required:!0},{key:"device_key",label:"Device Key",placeholder:"你的 Bark 设备 Key",required:!0},{key:"title",label:"标题(可选)",placeholder:"闲鱼助手"},{key:"sound",label:"铃声(可选)",placeholder:"default"},{key:"group",label:"分组(可选)",placeholder:"xianyu"}],guide:{steps:["App Store 搜索并安装 Bark(免费)","打开 Bark App,首页会显示一条测试 URL,形如 https://api.day.app//这是测试推送内容","URL 路径里 那一段就是 Device Key,复制填入","服务器地址默认 https://api.day.app,自建服务端则填自建域名"],urlFormat:"https://api.day.app/<你的key>/测试内容",note:"不需要 secret,Device Key 本身就是唯一凭证。"}},dingtalk:{label:"钉钉机器人",icon:as,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://oapi.dingtalk.com/robot/send?access_token=...",required:!0},{key:"secret",label:"加签密钥",placeholder:"SEC...",help:"安全设置勾选「加签」后生成,SEC 开头"}],guide:{steps:["钉钉进入一个群(可建单人群)→ 右上角 群设置","机器人 → 添加机器人 → 选择「自定义机器人」","安全设置勾选「加签」","完成页同时展示 Webhook 地址和 SEC 开头的 Secret,两个都复制","Webhook URL 填上面,Secret 填加签密钥"],urlFormat:"https://oapi.dingtalk.com/robot/send?access_token=XXX",note:"加签密钥可选,但强烈建议启用,否则机器人可能被滥用。"}},feishu:{label:"飞书机器人",icon:as,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",required:!0},{key:"secret",label:"签名校验密钥",placeholder:"sec-...",help:"安全设置选「签名校验」后生成"}],guide:{steps:["飞书进入目标群 → 右上角 更多 → 设置","群机器人 → 添加机器人 → 自定义机器人","安全设置选择「签名校验」,复制生成的秘钥","完成会给 Webhook 地址,复制","Webhook URL 填上面,秘钥填签名校验密钥"],urlFormat:"https://open.feishu.cn/open-apis/bot/v2/hook/xxx",note:"签名密钥可选,建议启用。频率限制:单机器人 100 次/分钟。"}},wechat:{label:"企业微信机器人",icon:as,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=...",required:!0}],guide:{steps:["企业微信进入一个内部群 → 右上角 … → 群设置","找到「群机器人」(新版可能叫「消息推送」)","添加 → 选择自定义机器人","完成给 Webhook 地址(含 ?key=),复制填入"],urlFormat:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXX",note:"不需要 secret,URL 里的 key 就是唯一凭证,注意不要泄露。频率限制 20 条/分钟。"}},webhook:{label:"自定义 Webhook",icon:Ft,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://your-server/notify",required:!0}],guide:{steps:["仅适用于自己有服务器的用户:在你自己的机器上起一个 HTTP 接口收 JSON","系统会 POST 这个 URL,Content-Type: application/json","请求体固定为右侧 JSON 格式,按需解析 message 字段"],urlFormat:'{"message":"告警正文","timestamp":"2026-07-05 12:00:00","source":"xianyu-auto-reply"}',note:"若用 Server酱 / PushPlus 等第三方推送服务,格式不兼容,需写中间脚本转发,或改用对应专用渠道。"}},telegram:{label:"Telegram",icon:ys,fields:[{key:"bot_token",label:"Bot Token",placeholder:"123456:ABC-DEF...",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"-1001234567890 或你的用户 ID",required:!0}],guide:{steps:["在 Telegram 搜索 @BotFather,发送 /newbot,按提示创建机器人,拿到 Bot Token","把你的 Bot 拉进一个群,或私聊它发一条消息","浏览器访问 https://api.telegram.org/bot<你的Token>/getUpdates",'从返回 JSON 里找 "chat":{"id":xxx},xxx 就是 Chat ID(群是负数,私聊是正数)'],urlFormat:"Bot Token: 123456:ABC-DEF... Chat ID: -1001234567890",note:"群聊需先把 Bot 设为管理员才能发消息。"}},email:{label:"邮件",icon:at,fields:[{key:"smtp_server",label:"SMTP 服务器",placeholder:"smtp.qq.com",required:!0},{key:"smtp_port",label:"SMTP 端口",placeholder:"587",type:"number",required:!0},{key:"smtp_user",label:"发件邮箱",placeholder:"you@qq.com",required:!0},{key:"smtp_password",label:"密码 / 授权码",type:"password",required:!0},{key:"from",label:"收件邮箱(可选)",placeholder:"留空则发给自己"}],guide:{steps:["QQ 邮箱:服务器 smtp.qq.com,端口 587,发件邮箱填你的 QQ 邮箱","QQ 邮箱密码栏填「授权码」不是 QQ 密码:QQ 邮箱设置 → 账号 → 开启 SMTP → 生成授权码","163 邮箱:smtp.163.com:587,同样使用授权码","Gmail:smtp.gmail.com:587,密码用「应用专用密码」"],note:"收件邮箱留空时,邮件会发到发件邮箱自己。"}}},il=()=>{const[s,a]=o.useState([]),[r,h]=o.useState(!0),[u,m]=o.useState(!1),[w,I]=o.useState(null),[p,W]=o.useState(!1),[b,Y]=o.useState(""),[G,M]=o.useState(null),[E,X]=o.useState({}),[re,Z]=o.useState(!1),[R,te]=o.useState(!1),[T,F]=o.useState({name:"",type:"bark",enabled:!0,config:{}}),L=async()=>{h(!0);try{const c=await ot();a(c.data||[])}catch(c){console.error("加载通知渠道失败",c)}finally{h(!1)}},Q=async()=>{try{const c=await nt();X(c||{})}catch(c){console.error("加载 SMTP 配置失败",c)}},A=async()=>{Z(!0);try{await it({smtp_server:E.smtp_server||"",smtp_port:E.smtp_port||587,smtp_user:E.smtp_user||"",smtp_password:E.smtp_password||"",smtp_from:E.smtp_from||""}),$("success","SMTP 配置已保存")}catch(c){$("error",(c==null?void 0:c.message)||"保存失败")}finally{Z(!1)}};o.useEffect(()=>{L(),Q()},[]);const $=(c,j)=>{M({type:c,text:j}),window.setTimeout(()=>M(null),3e3)},d=()=>{I(null),F({name:"",type:"bark",enabled:!0,config:{}}),m(!0)},z=c=>{I(c),F({name:c.name,type:c.type,enabled:c.enabled,config:{...c.config||{}}}),m(!0)},H=async()=>{const c=Me[T.type];for(const j of c.fields)if(j.required&&!String(T.config[j.key]||"").trim()){$("error",`请填写 ${j.label}`);return}if(!T.name.trim()){$("error","请填写渠道名称");return}W(!0);try{const j={name:T.name.trim(),type:T.type,config:T.config,enabled:T.enabled};w?await Ms(w.id,j):await Oa(j),m(!1),await L(),$("success",w?"已更新":"已创建")}catch(j){console.error("保存失败",j),$("error",(j==null?void 0:j.message)||"保存失败")}finally{W(!1)}},J=async c=>{if(confirm(`确认删除渠道「${c.name}」吗?已绑定该渠道的账号会自动解绑。`))try{await Ma(c.id),await L(),$("success","已删除")}catch(j){$("error",(j==null?void 0:j.message)||"删除失败")}},U=async c=>{try{await Ms(c.id,{name:c.name,type:c.type,config:c.config||{},enabled:!c.enabled}),a(j=>j.map(N=>N.id===c.id?{...N,enabled:!N.enabled}:N))}catch(j){$("error",(j==null?void 0:j.message)||"切换失败")}},C=async c=>{Y(c.id);try{await Ba(c.id),$("success","测试通知已发送,请检查对应渠道")}catch(j){$("error",(j==null?void 0:j.message)||"发送失败")}finally{Y("")}},k=Me[T.type];return e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"通知设置"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"配置通知渠道,账号异常时主动推送告警"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:L,className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(ke,{className:"w-4 h-4"}),"刷新"]}),e.jsxs("button",{onClick:d,className:"ios-btn-primary px-5 py-2.5 rounded-xl font-bold flex items-center gap-2",children:[e.jsx(De,{className:"w-4 h-4"}),"新建渠道"]})]})]}),e.jsx("div",{className:"ios-card rounded-xl p-5 bg-blue-50/50 border border-blue-100",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(qe,{className:"w-5 h-5 text-[#0094f7] mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm text-gray-700 leading-6",children:["配置通知渠道并在「账号管理 → 编辑」里绑定后,以下事件会主动推送到该账号绑定的渠道:",e.jsxs("ul",{className:"mt-2 space-y-1 text-gray-600",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{children:"账号 session 失效"}),":系统正在尝试自动恢复(警告)"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"自动恢复失败"}),":账号已停止,需人工处理(严重)"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"触发风控验证"}),":可能需要扫码完成验证(警告)"]})]})]})]})}),r?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx(_e,{className:"w-8 h-8 text-[#0094f7] animate-spin"})}):s.length===0?e.jsxs("div",{className:"ios-card rounded-xl p-12 bg-white text-center",children:[e.jsx(qe,{className:"w-12 h-12 text-gray-300 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"还没有配置任何通知渠道"}),e.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"点击右上角「新建渠道」开始配置"})]}):e.jsx("div",{className:"space-y-3",children:s.map(c=>{const j=Me[c.type]||Me.webhook,N=j.icon;return e.jsxs("div",{className:"ios-card rounded-xl p-5 bg-white flex items-center gap-4",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl bg-gray-100 flex items-center justify-center flex-shrink-0",children:e.jsx(N,{className:"w-5 h-5 text-gray-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-gray-900 truncate",children:c.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 text-gray-600 font-medium",children:j.label}),!c.enabled&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 text-gray-400 font-medium",children:"已停用"})]}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 truncate",children:j.fields.map(q=>{var D;return(D=c.config)==null?void 0:D[q.key]}).filter(Boolean).map((q,D)=>e.jsx("span",{className:"mr-3",children:String(q).length>40?String(q).slice(0,40)+"…":String(q)},D))})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>U(c),className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-colors ${c.enabled?"bg-green-50 text-green-700 hover:bg-green-100":"bg-gray-100 text-gray-500 hover:bg-gray-200"}`,children:c.enabled?"启用中":"已停用"}),e.jsxs("button",{onClick:()=>C(c),disabled:b===c.id,className:"px-3 py-1.5 rounded-lg text-xs font-bold bg-blue-50 text-[#0094f7] hover:bg-blue-100 transition-colors flex items-center gap-1 disabled:opacity-50",children:[b===c.id?e.jsx(_e,{className:"w-3 h-3 animate-spin"}):e.jsx(ys,{className:"w-3 h-3"}),"测试"]}),e.jsx("button",{onClick:()=>z(c),className:"w-8 h-8 rounded-lg bg-gray-100 hover:bg-gray-200 flex items-center justify-center text-gray-600 transition-colors",title:"编辑",children:e.jsx(Hs,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>J(c),className:"w-8 h-8 rounded-lg bg-red-50 hover:bg-red-100 flex items-center justify-center text-red-500 transition-colors",title:"删除",children:e.jsx(Ae,{className:"w-4 h-4"})})]})]},c.id)})}),e.jsxs("section",{className:"ios-card rounded-xl p-6 bg-white space-y-5",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-extrabold text-gray-800",children:"SMTP 邮件配置"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"系统级邮件发送服务,用于注册验证码等邮件通知"})]}),e.jsx("div",{className:"p-2 rounded-xl bg-blue-50 text-blue-600",children:e.jsx(at,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"SMTP 服务器"}),e.jsx("input",{type:"text",value:E.smtp_server||"",onChange:c=>X({...E,smtp_server:c.target.value}),placeholder:"smtp.qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"SMTP 端口"}),e.jsx("input",{type:"number",value:E.smtp_port||587,onChange:c=>X({...E,smtp_port:parseInt(c.target.value)||587}),placeholder:"587",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件邮箱"}),e.jsx("input",{type:"email",value:E.smtp_user||"",onChange:c=>X({...E,smtp_user:c.target.value}),placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"邮箱密码 / 授权码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:R?"text":"password",value:E.smtp_password||"",onChange:c=>X({...E,smtp_password:c.target.value}),placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:()=>te(!R),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:R?e.jsx(Ye,{className:"w-4 h-4"}):e.jsx(Be,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"QQ 邮箱需使用授权码(QQ 邮箱设置 → 账号 → 开启 SMTP → 生成授权码)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件人显示名(可选)"}),e.jsx("input",{type:"text",value:E.smtp_from||"",onChange:c=>X({...E,smtp_from:c.target.value}),placeholder:"闲鱼自动回复系统",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("button",{onClick:A,disabled:re,className:"ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[re?e.jsx(_e,{className:"w-4 h-4 animate-spin"}):e.jsx(Le,{className:"w-4 h-4"}),re?"保存中...":"保存 SMTP 配置"]})]}),u&&ue.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"36rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:w?"编辑通知渠道":"新建通知渠道"}),e.jsx("button",{onClick:()=>m(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(xe,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5 overflow-y-auto flex-1 min-h-0",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"渠道名称"}),e.jsx("input",{type:"text",value:T.name,onChange:c=>F({...T,name:c.target.value}),placeholder:"例如:我的 Bark",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"渠道类型"}),e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-2",children:Object.keys(Me).map(c=>{const j=Me[c],N=j.icon,q=T.type===c;return e.jsxs("button",{type:"button",onClick:()=>F({...T,type:c,config:{}}),className:`p-3 rounded-xl border-2 flex flex-col items-center gap-1.5 transition-all ${q?"border-[#0094f7] bg-blue-50":"border-gray-100 hover:border-gray-300"}`,children:[e.jsx(N,{className:`w-5 h-5 ${q?"text-[#0094f7]":"text-gray-500"}`}),e.jsx("span",{className:`text-xs font-bold ${q?"text-[#0094f7]":"text-gray-600"}`,children:j.label})]},c)})})]}),e.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-200 p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qe,{className:"w-4 h-4 text-amber-600"}),e.jsxs("span",{className:"text-sm font-bold text-amber-800",children:["如何获取 ",k.label," 配置?"]})]}),e.jsx("ol",{className:"space-y-1.5 text-xs text-amber-900/90 leading-5 list-decimal pl-5",children:k.guide.steps.map((c,j)=>e.jsx("li",{children:c},j))}),k.guide.urlFormat&&e.jsxs("div",{className:"text-xs text-amber-900/90",children:[e.jsx("span",{className:"font-bold",children:"格式示例:"}),e.jsx("code",{className:"mt-1 block bg-amber-100/70 px-2.5 py-1.5 rounded-lg break-all font-mono text-[11px]",children:k.guide.urlFormat})]}),k.guide.note&&e.jsxs("p",{className:"text-xs text-amber-800/80 leading-5 pt-1",children:["💡 ",k.guide.note]})]}),e.jsx("div",{className:"space-y-3",children:k.fields.map(c=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:[c.label,c.required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),e.jsx("input",{type:c.type==="password"?"password":c.type==="number"?"number":"text",value:String(T.config[c.key]||""),onChange:j=>F({...T,config:{...T.config,[c.key]:j.target.value}}),placeholder:c.placeholder,className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),c.help&&e.jsx("p",{className:"text-xs text-gray-500",children:c.help})]},c.key))}),e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx("button",{type:"button",onClick:()=>F({...T,enabled:!T.enabled}),className:`relative w-11 h-6 rounded-full transition-colors ${T.enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform ${T.enabled?"translate-x-5":""}`})}),e.jsx("span",{className:"text-sm font-bold text-gray-800",children:"启用此渠道"})]})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:()=>m(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"取消"}),e.jsxs("button",{onClick:H,disabled:p,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[p?e.jsx(_e,{className:"w-4 h-4 animate-spin"}):e.jsx(Fe,{className:"w-4 h-4"}),p?"保存中...":"保存"]})]})]})}),document.body),G&&e.jsxs("div",{className:"fixed bottom-8 left-1/2 -translate-x-1/2 z-[10000] px-5 py-3 rounded-xl shadow-lg font-bold text-sm flex items-center gap-2 animate-fade-in",style:{background:G.type==="success"?"#10b981":"#ef4444",color:"white"},children:[G.type==="success"?e.jsx(Fe,{className:"w-4 h-4"}):e.jsx(xe,{className:"w-4 h-4"}),G.text]})]})},ct={"/app/dashboard":"dashboard","/app/accounts":"accounts","/app/orders":"orders","/app/cards":"cards","/app/items":"items","/app/rules":"rules","/app/notifications":"notifications","/app/settings":"settings"},ol=Object.fromEntries(Object.entries(ct).map(([s,a])=>[a,s])),Vs=()=>ct[window.location.pathname]||"dashboard",dl=/Win/i.test(navigator.platform||navigator.userAgent),cl=()=>{const[s,a]=o.useState(!1),[r,h]=o.useState(Vs),[u,m]=o.useState(!0),[w,I]=o.useState(!1),[p,W]=o.useState(""),[b,Y]=o.useState(""),[G,M]=o.useState(!1),[E,X]=o.useState(""),[re,Z]=o.useState(),R=F=>{const L=ol[F];L&&L!==window.location.pathname&&window.history.pushState({},"",L),h(F)};o.useEffect(()=>{const F=()=>h(Vs());return window.addEventListener("popstate",F),()=>window.removeEventListener("popstate",F)},[]),o.useEffect(()=>{lt().then(L=>{if((L==null?void 0:L.initialized)===!1){I(!0),a(!1);return}I(!1),L!=null&&L.authenticated&&a(!0)}).catch(()=>a(!1)).finally(()=>m(!1));const F=()=>a(!1);return window.addEventListener("auth:logout",F),()=>window.removeEventListener("auth:logout",F)},[]);const te=async F=>{F.preventDefault(),M(!0),X("");try{const L=await Vt({username:p,password:b});L.success?a(!0):X(L.message||"登录失败")}catch(L){const Q=L instanceof Error?L.message:String(L);X(Q||"登录失败")}finally{M(!1)}};if(u)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[#f5f5f7]",children:e.jsx(_e,{className:"w-8 h-8 text-[#0094f7] animate-spin"})});if(w)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-[#F4F5F7] p-4 relative overflow-hidden font-sans",children:[e.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[60%] h-[60%] bg-blue-200/40 rounded-full blur-[120px] animate-pulse"}),e.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[60%] h-[60%] bg-blue-200/30 rounded-full blur-[120px] animate-pulse",style:{animationDelay:"2s"}}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-3xl p-8 md:p-12 rounded-xl shadow-[0_20px_60px_-15px_rgba(0,0,0,0.05)] w-full max-w-xl border border-white relative z-10 animate-fade-in",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"w-24 h-24 bg-[#0094f7] squircle flex items-center justify-center mx-auto mb-6 transition-all duration-500 p-4",style:{filter:"drop-shadow(0 8px 20px rgba(0,148,247,0.3))"},children:e.jsx("img",{src:"/static/ydisks-logo.svg",alt:"Ydisks",className:"w-full h-full"})}),e.jsx("h2",{className:"text-3xl font-extrabold text-gray-900 mb-2 tracking-tight",children:"系统尚未初始化"}),e.jsx("p",{className:"text-gray-600 font-medium",children:"为避免默认口令风险,管理员必须通过服务器本机 CLI 初始化。"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 rounded-2xl bg-gray-50 border border-gray-100",children:[e.jsx("div",{className:"text-sm font-bold text-gray-900 mb-2",children:"请在服务器上执行:"}),e.jsx("pre",{className:"text-xs bg-black text-white p-4 rounded-2xl overflow-x-auto",children:dl?'.\\xianyu-server.exe -init-admin -db data\\xianyu_data.db -admin-password "请设置密码"':"./xianyu-server -init-admin -db data/xianyu_data.db -admin-password '请设置密码'"}),e.jsx("div",{className:"text-xs text-gray-500 mt-2",children:"完成后刷新页面即可进入登录。"})]}),e.jsxs("button",{type:"button",onClick:()=>window.location.reload(),className:"w-full ios-btn-primary h-14 rounded-2xl text-lg shadow-xl shadow-blue-200 mt-2 flex items-center justify-center gap-2 group",children:["我已初始化,刷新 ",e.jsx(gs,{className:"w-5 h-5 group-hover:translate-x-1 transition-transform"})]})]}),e.jsx("div",{className:"mt-8 pt-6 border-t border-gray-100 text-center",children:e.jsx("span",{className:"text-xs text-gray-400 font-medium tracking-widest uppercase",children:"Secure Bootstrap"})})]})]});if(!s)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-[#F4F5F7] p-4 relative overflow-hidden font-sans",children:[e.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[60%] h-[60%] bg-blue-200/40 rounded-full blur-[120px] animate-pulse"}),e.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[60%] h-[60%] bg-blue-200/30 rounded-full blur-[120px] animate-pulse",style:{animationDelay:"2s"}}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-3xl p-8 md:p-12 rounded-xl shadow-[0_20px_60px_-15px_rgba(0,0,0,0.05)] w-full max-w-lg border border-white relative z-10 animate-fade-in",children:[e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("div",{className:"w-24 h-24 bg-[#0094f7] squircle flex items-center justify-center mx-auto mb-6 transition-all duration-500 cursor-pointer group p-4",style:{filter:"drop-shadow(0 8px 20px rgba(0,148,247,0.3))"},children:e.jsx("img",{src:"/static/ydisks-logo.svg",alt:"Ydisks",className:"w-full h-full group-hover:scale-110 transition-transform"})}),e.jsx("h2",{className:"text-3xl font-extrabold text-gray-900 mb-2 tracking-tight",children:"欢迎回来"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"Ydisks闲鱼助手 · 自动发货与管家系统"})]}),e.jsxs("form",{onSubmit:te,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx(hs,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 group-focus-within:text-black transition-colors"}),e.jsx("input",{type:"text",placeholder:"管理员账号",value:p,onChange:F=>W(F.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(Rt,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 group-focus-within:text-black transition-colors"}),e.jsx("input",{type:"password",placeholder:"密码",value:b,onChange:F=>Y(F.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]})]}),E&&e.jsxs("div",{className:"p-3 rounded-xl bg-red-50 text-red-500 text-sm text-center font-bold flex items-center justify-center gap-2",children:[e.jsx(st,{className:"w-4 h-4"})," ",E]}),e.jsx("button",{type:"submit",disabled:G,className:"w-full ios-btn-primary h-14 rounded-2xl text-lg shadow-xl shadow-blue-200 mt-2 flex items-center justify-center gap-2 group disabled:opacity-70",children:G?e.jsx(_e,{className:"w-5 h-5 animate-spin"}):e.jsxs(e.Fragment,{children:["立即登录 ",e.jsx(gs,{className:"w-5 h-5 group-hover:translate-x-1 transition-transform"})]})})]}),e.jsx("div",{className:"mt-8 pt-6 border-t border-gray-100",children:e.jsx("div",{className:"mt-6 text-center",children:e.jsx("span",{className:"text-xs text-gray-400 font-medium tracking-widest uppercase",children:"Ydisks闲鱼助手 v1.0"})})})]})]});const T=()=>{switch(r){case"dashboard":return e.jsx(qs,{});case"accounts":return e.jsx(Ka,{});case"orders":return e.jsx(Xa,{});case"cards":return e.jsx(Za,{});case"items":return e.jsx(el,{onConfigureDelivery:F=>{Z({cookieId:F.cookie_id,itemId:F.item_id,requestId:Date.now()}),R("rules")}});case"rules":return e.jsx(nl,{initialDeliveryTarget:re,onDeliveryTargetHandled:()=>Z(void 0)});case"notifications":return e.jsx(il,{});case"settings":return e.jsx(sl,{});default:return e.jsx(qs,{})}};return e.jsxs("div",{className:"flex min-h-screen bg-[#F4F5F7] text-[#111]",children:[e.jsx(zt,{activeTab:r,onNavigate:R,onLogout:()=>{a(!1)}}),e.jsxs("main",{className:"flex-1 ml-64 p-8 md:p-12 overflow-y-auto h-screen relative scroll-smooth",children:[e.jsx("div",{className:"fixed top-0 right-0 w-[800px] h-[800px] bg-gradient-to-bl from-blue-50 to-transparent rounded-full blur-[120px] pointer-events-none -z-10 opacity-60"}),e.jsx("div",{className:"max-w-[1400px] mx-auto pb-10",children:T()})]})]})},xt=document.getElementById("root");if(!xt)throw new Error("Could not find root element to mount to");const xl=ut.createRoot(xt);xl.render(e.jsx(pt.StrictMode,{children:e.jsx(cl,{})})); diff --git a/internal/webui/static/assets/index-Bzj0nqFG.js b/internal/webui/static/assets/index-Bzj0nqFG.js deleted file mode 100644 index d5a7075..0000000 --- a/internal/webui/static/assets/index-Bzj0nqFG.js +++ /dev/null @@ -1,502 +0,0 @@ -var bT=Object.defineProperty;var wT=(e,t,n)=>t in e?bT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var sd=(e,t,n)=>wT(e,typeof t!="symbol"?t+"":t,n);function jT(e,t){for(var n=0;nr[l]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const s of l)if(s.type==="childList")for(const d of s.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&r(d)}).observe(document,{childList:!0,subtree:!0});function n(l){const s={};return l.integrity&&(s.integrity=l.integrity),l.referrerPolicy&&(s.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?s.credentials="include":l.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(l){if(l.ep)return;l.ep=!0;const s=n(l);fetch(l.href,s)}})();function Ky(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Yp={exports:{}},Bo={};/** - * @license React - * react-jsx-runtime.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Jw;function _T(){if(Jw)return Bo;Jw=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,l,s){var d=null;if(s!==void 0&&(d=""+s),l.key!==void 0&&(d=""+l.key),"key"in l){s={};for(var f in l)f!=="key"&&(s[f]=l[f])}else s=l;return l=s.ref,{$$typeof:e,type:r,key:d,ref:l!==void 0?l:null,props:s}}return Bo.Fragment=t,Bo.jsx=n,Bo.jsxs=n,Bo}var ej;function NT(){return ej||(ej=1,Yp.exports=_T()),Yp.exports}var c=NT(),Gp={exports:{}},ze={};/** - * @license React - * react.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var tj;function ST(){if(tj)return ze;tj=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),d=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),b=Symbol.iterator;function w(P){return P===null||typeof P!="object"?null:(P=b&&P[b]||P["@@iterator"],typeof P=="function"?P:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,S={};function A(P,Q,ne){this.props=P,this.context=Q,this.refs=S,this.updater=ne||j}A.prototype.isReactComponent={},A.prototype.setState=function(P,Q){if(typeof P!="object"&&typeof P!="function"&&P!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,P,Q,"setState")},A.prototype.forceUpdate=function(P){this.updater.enqueueForceUpdate(this,P,"forceUpdate")};function C(){}C.prototype=A.prototype;function M(P,Q,ne){this.props=P,this.context=Q,this.refs=S,this.updater=ne||j}var k=M.prototype=new C;k.constructor=M,_(k,A.prototype),k.isPureReactComponent=!0;var D=Array.isArray;function E(){}var $={H:null,A:null,T:null,S:null},U=Object.prototype.hasOwnProperty;function K(P,Q,ne){var I=ne.ref;return{$$typeof:e,type:P,key:Q,ref:I!==void 0?I:null,props:ne}}function T(P,Q){return K(P.type,Q,P.props)}function re(P){return typeof P=="object"&&P!==null&&P.$$typeof===e}function Z(P){var Q={"=":"=0",":":"=2"};return"$"+P.replace(/[=:]/g,function(ne){return Q[ne]})}var pe=/\/+/g;function fe(P,Q){return typeof P=="object"&&P!==null&&P.key!=null?Z(""+P.key):Q.toString(36)}function ce(P){switch(P.status){case"fulfilled":return P.value;case"rejected":throw P.reason;default:switch(typeof P.status=="string"?P.then(E,E):(P.status="pending",P.then(function(Q){P.status==="pending"&&(P.status="fulfilled",P.value=Q)},function(Q){P.status==="pending"&&(P.status="rejected",P.reason=Q)})),P.status){case"fulfilled":return P.value;case"rejected":throw P.reason}}throw P}function R(P,Q,ne,I,he){var be=typeof P;(be==="undefined"||be==="boolean")&&(P=null);var _e=!1;if(P===null)_e=!0;else switch(be){case"bigint":case"string":case"number":_e=!0;break;case"object":switch(P.$$typeof){case e:case t:_e=!0;break;case v:return _e=P._init,R(_e(P._payload),Q,ne,I,he)}}if(_e)return he=he(P),_e=I===""?"."+fe(P,0):I,D(he)?(ne="",_e!=null&&(ne=_e.replace(pe,"$&/")+"/"),R(he,Q,ne,"",function(ye){return ye})):he!=null&&(re(he)&&(he=T(he,ne+(he.key==null||P&&P.key===he.key?"":(""+he.key).replace(pe,"$&/")+"/")+_e)),Q.push(he)),1;_e=0;var W=I===""?".":I+":";if(D(P))for(var V=0;V>>1,ue=R[se];if(0>>1;sel(ne,G))Il(he,ne)?(R[se]=he,R[I]=G,se=I):(R[se]=ne,R[Q]=G,se=Q);else if(Il(he,G))R[se]=he,R[I]=G,se=I;else break e}}return z}function l(R,z){var G=R.sortIndex-z.sortIndex;return G!==0?G:R.id-z.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var d=Date,f=d.now();e.unstable_now=function(){return d.now()-f}}var m=[],h=[],v=1,y=null,b=3,w=!1,j=!1,_=!1,S=!1,A=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;function k(R){for(var z=n(h);z!==null;){if(z.callback===null)r(h);else if(z.startTime<=R)r(h),z.sortIndex=z.expirationTime,t(m,z);else break;z=n(h)}}function D(R){if(_=!1,k(R),!j)if(n(m)!==null)j=!0,E||(E=!0,Z());else{var z=n(h);z!==null&&ce(D,z.startTime-R)}}var E=!1,$=-1,U=5,K=-1;function T(){return S?!0:!(e.unstable_now()-KR&&T());){var se=y.callback;if(typeof se=="function"){y.callback=null,b=y.priorityLevel;var ue=se(y.expirationTime<=R);if(R=e.unstable_now(),typeof ue=="function"){y.callback=ue,k(R),z=!0;break t}y===n(m)&&r(m),k(R)}else r(m);y=n(m)}if(y!==null)z=!0;else{var P=n(h);P!==null&&ce(D,P.startTime-R),z=!1}}break e}finally{y=null,b=G,w=!1}z=void 0}}finally{z?Z():E=!1}}}var Z;if(typeof M=="function")Z=function(){M(re)};else if(typeof MessageChannel<"u"){var pe=new MessageChannel,fe=pe.port2;pe.port1.onmessage=re,Z=function(){fe.postMessage(null)}}else Z=function(){A(re,0)};function ce(R,z){$=A(function(){R(e.unstable_now())},z)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(R){R.callback=null},e.unstable_forceFrameRate=function(R){0>R||125se?(R.sortIndex=G,t(h,R),n(m)===null&&R===n(h)&&(_?(C($),$=-1):_=!0,ce(D,G-se))):(R.sortIndex=ue,t(m,R),j||w||(j=!0,E||(E=!0,Z()))),R},e.unstable_shouldYield=T,e.unstable_wrapCallback=function(R){var z=b;return function(){var G=b;b=z;try{return R.apply(this,arguments)}finally{b=G}}}})(Xp)),Xp}var aj;function ET(){return aj||(aj=1,Fp.exports=OT()),Fp.exports}var Wp={exports:{}},vn={};/** - * @license React - * react-dom.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var ij;function kT(){if(ij)return vn;ij=1;var e=zs();function t(m){var h="https://react.dev/errors/"+m;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Wp.exports=kT(),Wp.exports}/** - * @license React - * react-dom-client.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var sj;function CT(){if(sj)return Uo;sj=1;var e=ET(),t=zs(),n=iA();function r(a){var i="https://react.dev/errors/"+a;if(1ue||(a.current=se[ue],se[ue]=null,ue--)}function ne(a,i){ue++,se[ue]=a.current,a.current=i}var I=P(null),he=P(null),be=P(null),_e=P(null);function W(a,i){switch(ne(be,i),ne(he,a),ne(I,null),i.nodeType){case 9:case 11:a=(a=i.documentElement)&&(a=a.namespaceURI)?jw(a):0;break;default:if(a=i.tagName,i=i.namespaceURI)i=jw(i),a=_w(i,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}Q(I),ne(I,a)}function V(){Q(I),Q(he),Q(be)}function ye(a){a.memoizedState!==null&&ne(_e,a);var i=I.current,o=_w(i,a.type);i!==o&&(ne(he,a),ne(I,o))}function xe(a){he.current===a&&(Q(I),Q(he)),_e.current===a&&(Q(_e),Io._currentValue=G)}var ae,Le;function Ce(a){if(ae===void 0)try{throw Error()}catch(o){var i=o.stack.trim().match(/\n( *(at )?)/);ae=i&&i[1]||"",Le=-1)":-1p||L[u]!==ee[p]){var oe=` -`+L[u].replace(" at new "," at ");return a.displayName&&oe.includes("")&&(oe=oe.replace("",a.displayName)),oe}while(1<=u&&0<=p);break}}}finally{Y=!1,Error.prepareStackTrace=o}return(o=a?a.displayName||a.name:"")?Ce(o):""}function Pe(a,i){switch(a.tag){case 26:case 27:case 5:return Ce(a.type);case 16:return Ce("Lazy");case 13:return a.child!==i&&i!==null?Ce("Suspense Fallback"):Ce("Suspense");case 19:return Ce("SuspenseList");case 0:case 15:return ge(a.type,!1);case 11:return ge(a.type.render,!1);case 1:return ge(a.type,!0);case 31:return Ce("Activity");default:return""}}function Be(a){try{var i="",o=null;do i+=Pe(a,o),o=a,a=a.return;while(a);return i}catch(u){return` -Error generating stack: `+u.message+` -`+u.stack}}var Ve=Object.prototype.hasOwnProperty,Dt=e.unstable_scheduleCallback,ie=e.unstable_cancelCallback,De=e.unstable_shouldYield,Ue=e.unstable_requestPaint,B=e.unstable_now,Te=e.unstable_getCurrentPriorityLevel,lt=e.unstable_ImmediatePriority,Zr=e.unstable_UserBlockingPriority,Qn=e.unstable_NormalPriority,$n=e.unstable_LowPriority,wi=e.unstable_IdlePriority,xl=e.log,q=e.unstable_setDisableYieldValue,ve=null,we=null;function $e(a){if(typeof xl=="function"&&q(a),we&&typeof we.setStrictMode=="function")try{we.setStrictMode(ve,a)}catch{}}var We=Math.clz32?Math.clz32:Cr,Jt=Math.log,jt=Math.LN2;function Cr(a){return a>>>=0,a===0?32:31-(Jt(a)/jt|0)|0}var _t=256,bl=262144,Vc=4194304;function ji(a){var i=a&42;if(i!==0)return i;switch(a&-a){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return a&261888;case 262144:case 524288:case 1048576:case 2097152:return a&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return a&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return a}}function Fc(a,i,o){var u=a.pendingLanes;if(u===0)return 0;var p=0,g=a.suspendedLanes,N=a.pingedLanes;a=a.warmLanes;var O=u&134217727;return O!==0?(u=O&~g,u!==0?p=ji(u):(N&=O,N!==0?p=ji(N):o||(o=O&~a,o!==0&&(p=ji(o))))):(O=u&~g,O!==0?p=ji(O):N!==0?p=ji(N):o||(o=u&~a,o!==0&&(p=ji(o)))),p===0?0:i!==0&&i!==p&&(i&g)===0&&(g=p&-p,o=i&-i,g>=o||g===32&&(o&4194048)!==0)?i:p}function Fs(a,i){return(a.pendingLanes&~(a.suspendedLanes&~a.pingedLanes)&i)===0}function s5(a,i){switch(a){case 1:case 2:case 4:case 8:case 64:return i+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function rx(){var a=Vc;return Vc<<=1,(Vc&62914560)===0&&(Vc=4194304),a}function Dm(a){for(var i=[],o=0;31>o;o++)i.push(a);return i}function Xs(a,i){a.pendingLanes|=i,i!==268435456&&(a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0)}function o5(a,i,o,u,p,g){var N=a.pendingLanes;a.pendingLanes=o,a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0,a.expiredLanes&=o,a.entangledLanes&=o,a.errorRecoveryDisabledLanes&=o,a.shellSuspendCounter=0;var O=a.entanglements,L=a.expirationTimes,ee=a.hiddenUpdates;for(o=N&~o;0"u")return null;try{return a.activeElement||a.body}catch{return a.body}}var h5=/[\n"\\]/g;function er(a){return a.replace(h5,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function Lm(a,i,o,u,p,g,N,O){a.name="",N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?a.type=N:a.removeAttribute("type"),i!=null?N==="number"?(i===0&&a.value===""||a.value!=i)&&(a.value=""+Jn(i)):a.value!==""+Jn(i)&&(a.value=""+Jn(i)):N!=="submit"&&N!=="reset"||a.removeAttribute("value"),i!=null?Bm(a,N,Jn(i)):o!=null?Bm(a,N,Jn(o)):u!=null&&a.removeAttribute("value"),p==null&&g!=null&&(a.defaultChecked=!!g),p!=null&&(a.checked=p&&typeof p!="function"&&typeof p!="symbol"),O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"?a.name=""+Jn(O):a.removeAttribute("name")}function vx(a,i,o,u,p,g,N,O){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(a.type=g),i!=null||o!=null){if(!(g!=="submit"&&g!=="reset"||i!=null)){Rm(a);return}o=o!=null?""+Jn(o):"",i=i!=null?""+Jn(i):o,O||i===a.value||(a.value=i),a.defaultValue=i}u=u??p,u=typeof u!="function"&&typeof u!="symbol"&&!!u,a.checked=O?a.checked:!!u,a.defaultChecked=!!u,N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"&&(a.name=N),Rm(a)}function Bm(a,i,o){i==="number"&&Zc(a.ownerDocument)===a||a.defaultValue===""+o||(a.defaultValue=""+o)}function Al(a,i,o,u){if(a=a.options,i){i={};for(var p=0;p"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ym=!1;if(ea)try{var Js={};Object.defineProperty(Js,"passive",{get:function(){Ym=!0}}),window.addEventListener("test",Js,Js),window.removeEventListener("test",Js,Js)}catch{Ym=!1}var $a=null,Gm=null,Jc=null;function _x(){if(Jc)return Jc;var a,i=Gm,o=i.length,u,p="value"in $a?$a.value:$a.textContent,g=p.length;for(a=0;a=no),kx=" ",Cx=!1;function Tx(a,i){switch(a){case"keyup":return H5.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Mx(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var Cl=!1;function K5(a,i){switch(a){case"compositionend":return Mx(i);case"keypress":return i.which!==32?null:(Cx=!0,kx);case"textInput":return a=i.data,a===kx&&Cx?null:a;default:return null}}function Y5(a,i){if(Cl)return a==="compositionend"||!Zm&&Tx(a,i)?(a=_x(),Jc=Gm=$a=null,Cl=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1=i)return{node:o,offset:i-a};a=u}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=Bx(o)}}function Hx(a,i){return a&&i?a===i?!0:a&&a.nodeType===3?!1:i&&i.nodeType===3?Hx(a,i.parentNode):"contains"in a?a.contains(i):a.compareDocumentPosition?!!(a.compareDocumentPosition(i)&16):!1:!1}function qx(a){a=a!=null&&a.ownerDocument!=null&&a.ownerDocument.defaultView!=null?a.ownerDocument.defaultView:window;for(var i=Zc(a.document);i instanceof a.HTMLIFrameElement;){try{var o=typeof i.contentWindow.location.href=="string"}catch{o=!1}if(o)a=i.contentWindow;else break;i=Zc(a.document)}return i}function eh(a){var i=a&&a.nodeName&&a.nodeName.toLowerCase();return i&&(i==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||i==="textarea"||a.contentEditable==="true")}var J5=ea&&"documentMode"in document&&11>=document.documentMode,Tl=null,th=null,lo=null,nh=!1;function Kx(a,i,o){var u=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;nh||Tl==null||Tl!==Zc(u)||(u=Tl,"selectionStart"in u&&eh(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),lo&&io(lo,u)||(lo=u,u=Gu(th,"onSelect"),0>=N,p-=N,Tr=1<<32-We(i)+p|o<Re?(Ge=Ee,Ee=null):Ge=Ee.sibling;var Je=te(F,Ee,J[Re],de);if(Je===null){Ee===null&&(Ee=Ge);break}a&&Ee&&Je.alternate===null&&i(F,Ee),H=g(Je,H,Re),Qe===null?ke=Je:Qe.sibling=Je,Qe=Je,Ee=Ge}if(Re===J.length)return o(F,Ee),Fe&&na(F,Re),ke;if(Ee===null){for(;ReRe?(Ge=Ee,Ee=null):Ge=Ee.sibling;var ii=te(F,Ee,Je.value,de);if(ii===null){Ee===null&&(Ee=Ge);break}a&&Ee&&ii.alternate===null&&i(F,Ee),H=g(ii,H,Re),Qe===null?ke=ii:Qe.sibling=ii,Qe=ii,Ee=Ge}if(Je.done)return o(F,Ee),Fe&&na(F,Re),ke;if(Ee===null){for(;!Je.done;Re++,Je=J.next())Je=me(F,Je.value,de),Je!==null&&(H=g(Je,H,Re),Qe===null?ke=Je:Qe.sibling=Je,Qe=Je);return Fe&&na(F,Re),ke}for(Ee=u(Ee);!Je.done;Re++,Je=J.next())Je=le(Ee,F,Re,Je.value,de),Je!==null&&(a&&Je.alternate!==null&&Ee.delete(Je.key===null?Re:Je.key),H=g(Je,H,Re),Qe===null?ke=Je:Qe.sibling=Je,Qe=Je);return a&&Ee.forEach(function(xT){return i(F,xT)}),Fe&&na(F,Re),ke}function ct(F,H,J,de){if(typeof J=="object"&&J!==null&&J.type===_&&J.key===null&&(J=J.props.children),typeof J=="object"&&J!==null){switch(J.$$typeof){case w:e:{for(var ke=J.key;H!==null;){if(H.key===ke){if(ke=J.type,ke===_){if(H.tag===7){o(F,H.sibling),de=p(H,J.props.children),de.return=F,F=de;break e}}else if(H.elementType===ke||typeof ke=="object"&&ke!==null&&ke.$$typeof===U&&Di(ke)===H.type){o(F,H.sibling),de=p(H,J.props),mo(de,J),de.return=F,F=de;break e}o(F,H);break}else i(F,H);H=H.sibling}J.type===_?(de=Ei(J.props.children,F.mode,de,J.key),de.return=F,F=de):(de=cu(J.type,J.key,J.props,null,F.mode,de),mo(de,J),de.return=F,F=de)}return N(F);case j:e:{for(ke=J.key;H!==null;){if(H.key===ke)if(H.tag===4&&H.stateNode.containerInfo===J.containerInfo&&H.stateNode.implementation===J.implementation){o(F,H.sibling),de=p(H,J.children||[]),de.return=F,F=de;break e}else{o(F,H);break}else i(F,H);H=H.sibling}de=ch(J,F.mode,de),de.return=F,F=de}return N(F);case U:return J=Di(J),ct(F,H,J,de)}if(ce(J))return Ae(F,H,J,de);if(Z(J)){if(ke=Z(J),typeof ke!="function")throw Error(r(150));return J=ke.call(J),Me(F,H,J,de)}if(typeof J.then=="function")return ct(F,H,vu(J),de);if(J.$$typeof===M)return ct(F,H,fu(F,J),de);yu(F,J)}return typeof J=="string"&&J!==""||typeof J=="number"||typeof J=="bigint"?(J=""+J,H!==null&&H.tag===6?(o(F,H.sibling),de=p(H,J),de.return=F,F=de):(o(F,H),de=oh(J,F.mode,de),de.return=F,F=de),N(F)):o(F,H)}return function(F,H,J,de){try{fo=0;var ke=ct(F,H,J,de);return Hl=null,ke}catch(Ee){if(Ee===Ul||Ee===hu)throw Ee;var Qe=Ln(29,Ee,null,F.mode);return Qe.lanes=de,Qe.return=F,Qe}finally{}}}var zi=mb(!0),hb=mb(!1),Ha=!1;function wh(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function jh(a,i){a=a.updateQueue,i.updateQueue===a&&(i.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,callbacks:null})}function qa(a){return{lane:a,tag:0,payload:null,callback:null,next:null}}function Ka(a,i,o){var u=a.updateQueue;if(u===null)return null;if(u=u.shared,(tt&2)!==0){var p=u.pending;return p===null?i.next=i:(i.next=p.next,p.next=i),u.pending=i,i=ou(a),Zx(a,null,o),i}return su(a,u,i,o),ou(a)}function ho(a,i,o){if(i=i.updateQueue,i!==null&&(i=i.shared,(o&4194048)!==0)){var u=i.lanes;u&=a.pendingLanes,o|=u,i.lanes=o,ix(a,o)}}function _h(a,i){var o=a.updateQueue,u=a.alternate;if(u!==null&&(u=u.updateQueue,o===u)){var p=null,g=null;if(o=o.firstBaseUpdate,o!==null){do{var N={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};g===null?p=g=N:g=g.next=N,o=o.next}while(o!==null);g===null?p=g=i:g=g.next=i}else p=g=i;o={baseState:u.baseState,firstBaseUpdate:p,lastBaseUpdate:g,shared:u.shared,callbacks:u.callbacks},a.updateQueue=o;return}a=o.lastBaseUpdate,a===null?o.firstBaseUpdate=i:a.next=i,o.lastBaseUpdate=i}var Nh=!1;function po(){if(Nh){var a=Bl;if(a!==null)throw a}}function vo(a,i,o,u){Nh=!1;var p=a.updateQueue;Ha=!1;var g=p.firstBaseUpdate,N=p.lastBaseUpdate,O=p.shared.pending;if(O!==null){p.shared.pending=null;var L=O,ee=L.next;L.next=null,N===null?g=ee:N.next=ee,N=L;var oe=a.alternate;oe!==null&&(oe=oe.updateQueue,O=oe.lastBaseUpdate,O!==N&&(O===null?oe.firstBaseUpdate=ee:O.next=ee,oe.lastBaseUpdate=L))}if(g!==null){var me=p.baseState;N=0,oe=ee=L=null,O=g;do{var te=O.lane&-536870913,le=te!==O.lane;if(le?(Ye&te)===te:(u&te)===te){te!==0&&te===Ll&&(Nh=!0),oe!==null&&(oe=oe.next={lane:0,tag:O.tag,payload:O.payload,callback:null,next:null});e:{var Ae=a,Me=O;te=i;var ct=o;switch(Me.tag){case 1:if(Ae=Me.payload,typeof Ae=="function"){me=Ae.call(ct,me,te);break e}me=Ae;break e;case 3:Ae.flags=Ae.flags&-65537|128;case 0:if(Ae=Me.payload,te=typeof Ae=="function"?Ae.call(ct,me,te):Ae,te==null)break e;me=y({},me,te);break e;case 2:Ha=!0}}te=O.callback,te!==null&&(a.flags|=64,le&&(a.flags|=8192),le=p.callbacks,le===null?p.callbacks=[te]:le.push(te))}else le={lane:te,tag:O.tag,payload:O.payload,callback:O.callback,next:null},oe===null?(ee=oe=le,L=me):oe=oe.next=le,N|=te;if(O=O.next,O===null){if(O=p.shared.pending,O===null)break;le=O,O=le.next,le.next=null,p.lastBaseUpdate=le,p.shared.pending=null}}while(!0);oe===null&&(L=me),p.baseState=L,p.firstBaseUpdate=ee,p.lastBaseUpdate=oe,g===null&&(p.shared.lanes=0),Xa|=N,a.lanes=N,a.memoizedState=me}}function pb(a,i){if(typeof a!="function")throw Error(r(191,a));a.call(i)}function vb(a,i){var o=a.callbacks;if(o!==null)for(a.callbacks=null,a=0;ag?g:8;var N=R.T,O={};R.T=O,qh(a,!1,i,o);try{var L=p(),ee=R.S;if(ee!==null&&ee(O,L),L!==null&&typeof L=="object"&&typeof L.then=="function"){var oe=o3(L,u);xo(a,i,oe,Kn(a))}else xo(a,i,u,Kn(a))}catch(me){xo(a,i,{then:function(){},status:"rejected",reason:me},Kn())}finally{z.p=g,N!==null&&O.types!==null&&(N.types=O.types),R.T=N}}function h3(){}function Uh(a,i,o,u){if(a.tag!==5)throw Error(r(476));var p=Fb(a).queue;Vb(a,p,i,G,o===null?h3:function(){return Xb(a),o(u)})}function Fb(a){var i=a.memoizedState;if(i!==null)return i;i={memoizedState:G,baseState:G,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:la,lastRenderedState:G},next:null};var o={};return i.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:la,lastRenderedState:o},next:null},a.memoizedState=i,a=a.alternate,a!==null&&(a.memoizedState=i),i}function Xb(a){var i=Fb(a);i.next===null&&(i=a.alternate.memoizedState),xo(a,i.next.queue,{},Kn())}function Hh(){return un(Io)}function Wb(){return zt().memoizedState}function Zb(){return zt().memoizedState}function p3(a){for(var i=a.return;i!==null;){switch(i.tag){case 24:case 3:var o=Kn();a=qa(o);var u=Ka(i,a,o);u!==null&&(Mn(u,i,o),ho(u,i,o)),i={cache:yh()},a.payload=i;return}i=i.return}}function v3(a,i,o){var u=Kn();o={lane:u,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Ou(a)?Jb(i,o):(o=lh(a,i,o,u),o!==null&&(Mn(o,a,u),e1(o,i,u)))}function Qb(a,i,o){var u=Kn();xo(a,i,o,u)}function xo(a,i,o,u){var p={lane:u,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Ou(a))Jb(i,p);else{var g=a.alternate;if(a.lanes===0&&(g===null||g.lanes===0)&&(g=i.lastRenderedReducer,g!==null))try{var N=i.lastRenderedState,O=g(N,o);if(p.hasEagerState=!0,p.eagerState=O,Rn(O,N))return su(a,i,p,0),ft===null&&lu(),!1}catch{}finally{}if(o=lh(a,i,p,u),o!==null)return Mn(o,a,u),e1(o,i,u),!0}return!1}function qh(a,i,o,u){if(u={lane:2,revertLane:wp(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Ou(a)){if(i)throw Error(r(479))}else i=lh(a,o,u,2),i!==null&&Mn(i,a,2)}function Ou(a){var i=a.alternate;return a===Ie||i!==null&&i===Ie}function Jb(a,i){Kl=bu=!0;var o=a.pending;o===null?i.next=i:(i.next=o.next,o.next=i),a.pending=i}function e1(a,i,o){if((o&4194048)!==0){var u=i.lanes;u&=a.pendingLanes,o|=u,i.lanes=o,ix(a,o)}}var bo={readContext:un,use:_u,useCallback:At,useContext:At,useEffect:At,useImperativeHandle:At,useLayoutEffect:At,useInsertionEffect:At,useMemo:At,useReducer:At,useRef:At,useState:At,useDebugValue:At,useDeferredValue:At,useTransition:At,useSyncExternalStore:At,useId:At,useHostTransitionStatus:At,useFormState:At,useActionState:At,useOptimistic:At,useMemoCache:At,useCacheRefresh:At};bo.useEffectEvent=At;var t1={readContext:un,use:_u,useCallback:function(a,i){return jn().memoizedState=[a,i===void 0?null:i],a},useContext:un,useEffect:Rb,useImperativeHandle:function(a,i,o){o=o!=null?o.concat([a]):null,Su(4194308,4,Hb.bind(null,i,a),o)},useLayoutEffect:function(a,i){return Su(4194308,4,a,i)},useInsertionEffect:function(a,i){Su(4,2,a,i)},useMemo:function(a,i){var o=jn();i=i===void 0?null:i;var u=a();if(Ii){$e(!0);try{a()}finally{$e(!1)}}return o.memoizedState=[u,i],u},useReducer:function(a,i,o){var u=jn();if(o!==void 0){var p=o(i);if(Ii){$e(!0);try{o(i)}finally{$e(!1)}}}else p=i;return u.memoizedState=u.baseState=p,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:p},u.queue=a,a=a.dispatch=v3.bind(null,Ie,a),[u.memoizedState,a]},useRef:function(a){var i=jn();return a={current:a},i.memoizedState=a},useState:function(a){a=Ih(a);var i=a.queue,o=Qb.bind(null,Ie,i);return i.dispatch=o,[a.memoizedState,o]},useDebugValue:Lh,useDeferredValue:function(a,i){var o=jn();return Bh(o,a,i)},useTransition:function(){var a=Ih(!1);return a=Vb.bind(null,Ie,a.queue,!0,!1),jn().memoizedState=a,[!1,a]},useSyncExternalStore:function(a,i,o){var u=Ie,p=jn();if(Fe){if(o===void 0)throw Error(r(407));o=o()}else{if(o=i(),ft===null)throw Error(r(349));(Ye&127)!==0||jb(u,i,o)}p.memoizedState=o;var g={value:o,getSnapshot:i};return p.queue=g,Rb(Nb.bind(null,u,g,a),[a]),u.flags|=2048,Gl(9,{destroy:void 0},_b.bind(null,u,g,o,i),null),o},useId:function(){var a=jn(),i=ft.identifierPrefix;if(Fe){var o=Mr,u=Tr;o=(u&~(1<<32-We(u)-1)).toString(32)+o,i="_"+i+"R_"+o,o=wu++,0<\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof u.is=="string"?N.createElement("select",{is:u.is}):N.createElement("select"),u.multiple?g.multiple=!0:u.size&&(g.size=u.size);break;default:g=typeof u.is=="string"?N.createElement(p,{is:u.is}):N.createElement(p)}}g[on]=i,g[An]=u;e:for(N=i.child;N!==null;){if(N.tag===5||N.tag===6)g.appendChild(N.stateNode);else if(N.tag!==4&&N.tag!==27&&N.child!==null){N.child.return=N,N=N.child;continue}if(N===i)break e;for(;N.sibling===null;){if(N.return===null||N.return===i)break e;N=N.return}N.sibling.return=N.return,N=N.sibling}i.stateNode=g;e:switch(fn(g,p,u),p){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&oa(i)}}return vt(i),rp(i,i.type,a===null?null:a.memoizedProps,i.pendingProps,o),null;case 6:if(a&&i.stateNode!=null)a.memoizedProps!==u&&oa(i);else{if(typeof u!="string"&&i.stateNode===null)throw Error(r(166));if(a=be.current,$l(i)){if(a=i.stateNode,o=i.memoizedProps,u=null,p=cn,p!==null)switch(p.tag){case 27:case 5:u=p.memoizedProps}a[on]=i,a=!!(a.nodeValue===o||u!==null&&u.suppressHydrationWarning===!0||bw(a.nodeValue,o)),a||Ba(i,!0)}else a=Vu(a).createTextNode(u),a[on]=i,i.stateNode=a}return vt(i),null;case 31:if(o=i.memoizedState,a===null||a.memoizedState!==null){if(u=$l(i),o!==null){if(a===null){if(!u)throw Error(r(318));if(a=i.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(r(557));a[on]=i}else ki(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;vt(i),a=!1}else o=mh(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=o),a=!0;if(!a)return i.flags&256?(Un(i),i):(Un(i),null);if((i.flags&128)!==0)throw Error(r(558))}return vt(i),null;case 13:if(u=i.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(p=$l(i),u!==null&&u.dehydrated!==null){if(a===null){if(!p)throw Error(r(318));if(p=i.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(r(317));p[on]=i}else ki(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;vt(i),p=!1}else p=mh(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=p),p=!0;if(!p)return i.flags&256?(Un(i),i):(Un(i),null)}return Un(i),(i.flags&128)!==0?(i.lanes=o,i):(o=u!==null,a=a!==null&&a.memoizedState!==null,o&&(u=i.child,p=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(p=u.alternate.memoizedState.cachePool.pool),g=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(g=u.memoizedState.cachePool.pool),g!==p&&(u.flags|=2048)),o!==a&&o&&(i.child.flags|=8192),Mu(i,i.updateQueue),vt(i),null);case 4:return V(),a===null&&Sp(i.stateNode.containerInfo),vt(i),null;case 10:return aa(i.type),vt(i),null;case 19:if(Q(Pt),u=i.memoizedState,u===null)return vt(i),null;if(p=(i.flags&128)!==0,g=u.rendering,g===null)if(p)jo(u,!1);else{if(Ot!==0||a!==null&&(a.flags&128)!==0)for(a=i.child;a!==null;){if(g=xu(a),g!==null){for(i.flags|=128,jo(u,!1),a=g.updateQueue,i.updateQueue=a,Mu(i,a),i.subtreeFlags=0,a=o,o=i.child;o!==null;)Qx(o,a),o=o.sibling;return ne(Pt,Pt.current&1|2),Fe&&na(i,u.treeForkCount),i.child}a=a.sibling}u.tail!==null&&B()>$u&&(i.flags|=128,p=!0,jo(u,!1),i.lanes=4194304)}else{if(!p)if(a=xu(g),a!==null){if(i.flags|=128,p=!0,a=a.updateQueue,i.updateQueue=a,Mu(i,a),jo(u,!0),u.tail===null&&u.tailMode==="hidden"&&!g.alternate&&!Fe)return vt(i),null}else 2*B()-u.renderingStartTime>$u&&o!==536870912&&(i.flags|=128,p=!0,jo(u,!1),i.lanes=4194304);u.isBackwards?(g.sibling=i.child,i.child=g):(a=u.last,a!==null?a.sibling=g:i.child=g,u.last=g)}return u.tail!==null?(a=u.tail,u.rendering=a,u.tail=a.sibling,u.renderingStartTime=B(),a.sibling=null,o=Pt.current,ne(Pt,p?o&1|2:o&1),Fe&&na(i,u.treeForkCount),a):(vt(i),null);case 22:case 23:return Un(i),Ah(),u=i.memoizedState!==null,a!==null?a.memoizedState!==null!==u&&(i.flags|=8192):u&&(i.flags|=8192),u?(o&536870912)!==0&&(i.flags&128)===0&&(vt(i),i.subtreeFlags&6&&(i.flags|=8192)):vt(i),o=i.updateQueue,o!==null&&Mu(i,o.retryQueue),o=null,a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(o=a.memoizedState.cachePool.pool),u=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(u=i.memoizedState.cachePool.pool),u!==o&&(i.flags|=2048),a!==null&&Q(Mi),null;case 24:return o=null,a!==null&&(o=a.memoizedState.cache),i.memoizedState.cache!==o&&(i.flags|=2048),aa(Rt),vt(i),null;case 25:return null;case 30:return null}throw Error(r(156,i.tag))}function w3(a,i){switch(dh(i),i.tag){case 1:return a=i.flags,a&65536?(i.flags=a&-65537|128,i):null;case 3:return aa(Rt),V(),a=i.flags,(a&65536)!==0&&(a&128)===0?(i.flags=a&-65537|128,i):null;case 26:case 27:case 5:return xe(i),null;case 31:if(i.memoizedState!==null){if(Un(i),i.alternate===null)throw Error(r(340));ki()}return a=i.flags,a&65536?(i.flags=a&-65537|128,i):null;case 13:if(Un(i),a=i.memoizedState,a!==null&&a.dehydrated!==null){if(i.alternate===null)throw Error(r(340));ki()}return a=i.flags,a&65536?(i.flags=a&-65537|128,i):null;case 19:return Q(Pt),null;case 4:return V(),null;case 10:return aa(i.type),null;case 22:case 23:return Un(i),Ah(),a!==null&&Q(Mi),a=i.flags,a&65536?(i.flags=a&-65537|128,i):null;case 24:return aa(Rt),null;case 25:return null;default:return null}}function S1(a,i){switch(dh(i),i.tag){case 3:aa(Rt),V();break;case 26:case 27:case 5:xe(i);break;case 4:V();break;case 31:i.memoizedState!==null&&Un(i);break;case 13:Un(i);break;case 19:Q(Pt);break;case 10:aa(i.type);break;case 22:case 23:Un(i),Ah(),a!==null&&Q(Mi);break;case 24:aa(Rt)}}function _o(a,i){try{var o=i.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var p=u.next;o=p;do{if((o.tag&a)===a){u=void 0;var g=o.create,N=o.inst;u=g(),N.destroy=u}o=o.next}while(o!==p)}}catch(O){it(i,i.return,O)}}function Va(a,i,o){try{var u=i.updateQueue,p=u!==null?u.lastEffect:null;if(p!==null){var g=p.next;u=g;do{if((u.tag&a)===a){var N=u.inst,O=N.destroy;if(O!==void 0){N.destroy=void 0,p=i;var L=o,ee=O;try{ee()}catch(oe){it(p,L,oe)}}}u=u.next}while(u!==g)}}catch(oe){it(i,i.return,oe)}}function A1(a){var i=a.updateQueue;if(i!==null){var o=a.stateNode;try{vb(i,o)}catch(u){it(a,a.return,u)}}}function O1(a,i,o){o.props=$i(a.type,a.memoizedProps),o.state=a.memoizedState;try{o.componentWillUnmount()}catch(u){it(a,i,u)}}function No(a,i){try{var o=a.ref;if(o!==null){switch(a.tag){case 26:case 27:case 5:var u=a.stateNode;break;case 30:u=a.stateNode;break;default:u=a.stateNode}typeof o=="function"?a.refCleanup=o(u):o.current=u}}catch(p){it(a,i,p)}}function Dr(a,i){var o=a.ref,u=a.refCleanup;if(o!==null)if(typeof u=="function")try{u()}catch(p){it(a,i,p)}finally{a.refCleanup=null,a=a.alternate,a!=null&&(a.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(p){it(a,i,p)}else o.current=null}function E1(a){var i=a.type,o=a.memoizedProps,u=a.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":o.autoFocus&&u.focus();break e;case"img":o.src?u.src=o.src:o.srcSet&&(u.srcset=o.srcSet)}}catch(p){it(a,a.return,p)}}function ap(a,i,o){try{var u=a.stateNode;q3(u,a.type,o,i),u[An]=i}catch(p){it(a,a.return,p)}}function k1(a){return a.tag===5||a.tag===3||a.tag===26||a.tag===27&&ei(a.type)||a.tag===4}function ip(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||k1(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.tag===27&&ei(a.type)||a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function lp(a,i,o){var u=a.tag;if(u===5||u===6)a=a.stateNode,i?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(a,i):(i=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,i.appendChild(a),o=o._reactRootContainer,o!=null||i.onclick!==null||(i.onclick=Jr));else if(u!==4&&(u===27&&ei(a.type)&&(o=a.stateNode,i=null),a=a.child,a!==null))for(lp(a,i,o),a=a.sibling;a!==null;)lp(a,i,o),a=a.sibling}function Du(a,i,o){var u=a.tag;if(u===5||u===6)a=a.stateNode,i?o.insertBefore(a,i):o.appendChild(a);else if(u!==4&&(u===27&&ei(a.type)&&(o=a.stateNode),a=a.child,a!==null))for(Du(a,i,o),a=a.sibling;a!==null;)Du(a,i,o),a=a.sibling}function C1(a){var i=a.stateNode,o=a.memoizedProps;try{for(var u=a.type,p=i.attributes;p.length;)i.removeAttributeNode(p[0]);fn(i,u,o),i[on]=a,i[An]=o}catch(g){it(a,a.return,g)}}var ca=!1,Ut=!1,sp=!1,T1=typeof WeakSet=="function"?WeakSet:Set,tn=null;function j3(a,i){if(a=a.containerInfo,Ep=ed,a=qx(a),eh(a)){if("selectionStart"in a)var o={start:a.selectionStart,end:a.selectionEnd};else e:{o=(o=a.ownerDocument)&&o.defaultView||window;var u=o.getSelection&&o.getSelection();if(u&&u.rangeCount!==0){o=u.anchorNode;var p=u.anchorOffset,g=u.focusNode;u=u.focusOffset;try{o.nodeType,g.nodeType}catch{o=null;break e}var N=0,O=-1,L=-1,ee=0,oe=0,me=a,te=null;t:for(;;){for(var le;me!==o||p!==0&&me.nodeType!==3||(O=N+p),me!==g||u!==0&&me.nodeType!==3||(L=N+u),me.nodeType===3&&(N+=me.nodeValue.length),(le=me.firstChild)!==null;)te=me,me=le;for(;;){if(me===a)break t;if(te===o&&++ee===p&&(O=N),te===g&&++oe===u&&(L=N),(le=me.nextSibling)!==null)break;me=te,te=me.parentNode}me=le}o=O===-1||L===-1?null:{start:O,end:L}}else o=null}o=o||{start:0,end:0}}else o=null;for(kp={focusedElem:a,selectionRange:o},ed=!1,tn=i;tn!==null;)if(i=tn,a=i.child,(i.subtreeFlags&1028)!==0&&a!==null)a.return=i,tn=a;else for(;tn!==null;){switch(i=tn,g=i.alternate,a=i.flags,i.tag){case 0:if((a&4)!==0&&(a=i.updateQueue,a=a!==null?a.events:null,a!==null))for(o=0;o title"))),fn(g,u,o),g[on]=a,en(g),u=g;break e;case"link":var N=$w("link","href",p).get(u+(o.href||""));if(N){for(var O=0;Oct&&(N=ct,ct=Me,Me=N);var F=Ux(O,Me),H=Ux(O,ct);if(F&&H&&(le.rangeCount!==1||le.anchorNode!==F.node||le.anchorOffset!==F.offset||le.focusNode!==H.node||le.focusOffset!==H.offset)){var J=me.createRange();J.setStart(F.node,F.offset),le.removeAllRanges(),Me>ct?(le.addRange(J),le.extend(H.node,H.offset)):(J.setEnd(H.node,H.offset),le.addRange(J))}}}}for(me=[],le=O;le=le.parentNode;)le.nodeType===1&&me.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof O.focus=="function"&&O.focus(),O=0;Oo?32:o,R.T=null,o=hp,hp=null;var g=Za,N=ha;if(Yt=0,Zl=Za=null,ha=0,(tt&6)!==0)throw Error(r(331));var O=tt;if(tt|=4,H1(g.current),L1(g,g.current,N,o),tt=O,Co(0,!1),we&&typeof we.onPostCommitFiberRoot=="function")try{we.onPostCommitFiberRoot(ve,g)}catch{}return!0}finally{z.p=p,R.T=u,lw(a,i)}}function ow(a,i,o){i=nr(o,i),i=Vh(a.stateNode,i,2),a=Ka(a,i,2),a!==null&&(Xs(a,2),Pr(a))}function it(a,i,o){if(a.tag===3)ow(a,a,o);else for(;i!==null;){if(i.tag===3){ow(i,a,o);break}else if(i.tag===1){var u=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Wa===null||!Wa.has(u))){a=nr(o,a),o=c1(2),u=Ka(i,o,2),u!==null&&(u1(o,u,i,a),Xs(u,2),Pr(u));break}}i=i.return}}function gp(a,i,o){var u=a.pingCache;if(u===null){u=a.pingCache=new S3;var p=new Set;u.set(i,p)}else p=u.get(i),p===void 0&&(p=new Set,u.set(i,p));p.has(o)||(up=!0,p.add(o),a=C3.bind(null,a,i,o),i.then(a,a))}function C3(a,i,o){var u=a.pingCache;u!==null&&u.delete(i),a.pingedLanes|=a.suspendedLanes&o,a.warmLanes&=~o,ft===a&&(Ye&o)===o&&(Ot===4||Ot===3&&(Ye&62914560)===Ye&&300>B()-Iu?(tt&2)===0&&Ql(a,0):dp|=o,Wl===Ye&&(Wl=0)),Pr(a)}function cw(a,i){i===0&&(i=rx()),a=Oi(a,i),a!==null&&(Xs(a,i),Pr(a))}function T3(a){var i=a.memoizedState,o=0;i!==null&&(o=i.retryLane),cw(a,o)}function M3(a,i){var o=0;switch(a.tag){case 31:case 13:var u=a.stateNode,p=a.memoizedState;p!==null&&(o=p.retryLane);break;case 19:u=a.stateNode;break;case 22:u=a.stateNode._retryCache;break;default:throw Error(r(314))}u!==null&&u.delete(i),cw(a,o)}function D3(a,i){return Dt(a,i)}var qu=null,es=null,xp=!1,Ku=!1,bp=!1,Ja=0;function Pr(a){a!==es&&a.next===null&&(es===null?qu=es=a:es=es.next=a),Ku=!0,xp||(xp=!0,z3())}function Co(a,i){if(!bp&&Ku){bp=!0;do for(var o=!1,u=qu;u!==null;){if(a!==0){var p=u.pendingLanes;if(p===0)var g=0;else{var N=u.suspendedLanes,O=u.pingedLanes;g=(1<<31-We(42|a)+1)-1,g&=p&~(N&~O),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(o=!0,mw(u,g))}else g=Ye,g=Fc(u,u===ft?g:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(g&3)===0||Fs(u,g)||(o=!0,mw(u,g));u=u.next}while(o);bp=!1}}function P3(){uw()}function uw(){Ku=xp=!1;var a=0;Ja!==0&&Y3()&&(a=Ja);for(var i=B(),o=null,u=qu;u!==null;){var p=u.next,g=dw(u,i);g===0?(u.next=null,o===null?qu=p:o.next=p,p===null&&(es=o)):(o=u,(a!==0||(g&3)!==0)&&(Ku=!0)),u=p}Yt!==0&&Yt!==5||Co(a),Ja!==0&&(Ja=0)}function dw(a,i){for(var o=a.suspendedLanes,u=a.pingedLanes,p=a.expirationTimes,g=a.pendingLanes&-62914561;0O)break;var oe=L.transferSize,me=L.initiatorType;oe&&ww(me)&&(L=L.responseEnd,N+=oe*(L"u"?null:document;function Dw(a,i,o){var u=ts;if(u&&typeof i=="string"&&i){var p=er(i);p='link[rel="'+a+'"][href="'+p+'"]',typeof o=="string"&&(p+='[crossorigin="'+o+'"]'),Mw.has(p)||(Mw.add(p),a={rel:a,crossOrigin:o,href:i},u.querySelector(p)===null&&(i=u.createElement("link"),fn(i,"link",a),en(i),u.head.appendChild(i)))}}function eT(a){pa.D(a),Dw("dns-prefetch",a,null)}function tT(a,i){pa.C(a,i),Dw("preconnect",a,i)}function nT(a,i,o){pa.L(a,i,o);var u=ts;if(u&&a&&i){var p='link[rel="preload"][as="'+er(i)+'"]';i==="image"&&o&&o.imageSrcSet?(p+='[imagesrcset="'+er(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(p+='[imagesizes="'+er(o.imageSizes)+'"]')):p+='[href="'+er(a)+'"]';var g=p;switch(i){case"style":g=ns(a);break;case"script":g=rs(a)}or.has(g)||(a=y({rel:"preload",href:i==="image"&&o&&o.imageSrcSet?void 0:a,as:i},o),or.set(g,a),u.querySelector(p)!==null||i==="style"&&u.querySelector(Po(g))||i==="script"&&u.querySelector(zo(g))||(i=u.createElement("link"),fn(i,"link",a),en(i),u.head.appendChild(i)))}}function rT(a,i){pa.m(a,i);var o=ts;if(o&&a){var u=i&&typeof i.as=="string"?i.as:"script",p='link[rel="modulepreload"][as="'+er(u)+'"][href="'+er(a)+'"]',g=p;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=rs(a)}if(!or.has(g)&&(a=y({rel:"modulepreload",href:a},i),or.set(g,a),o.querySelector(p)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(zo(g)))return}u=o.createElement("link"),fn(u,"link",a),en(u),o.head.appendChild(u)}}}function aT(a,i,o){pa.S(a,i,o);var u=ts;if(u&&a){var p=Nl(u).hoistableStyles,g=ns(a);i=i||"default";var N=p.get(g);if(!N){var O={loading:0,preload:null};if(N=u.querySelector(Po(g)))O.loading=5;else{a=y({rel:"stylesheet",href:a,"data-precedence":i},o),(o=or.get(g))&&Ip(a,o);var L=N=u.createElement("link");en(L),fn(L,"link",a),L._p=new Promise(function(ee,oe){L.onload=ee,L.onerror=oe}),L.addEventListener("load",function(){O.loading|=1}),L.addEventListener("error",function(){O.loading|=2}),O.loading|=4,Xu(N,i,u)}N={type:"stylesheet",instance:N,count:1,state:O},p.set(g,N)}}}function iT(a,i){pa.X(a,i);var o=ts;if(o&&a){var u=Nl(o).hoistableScripts,p=rs(a),g=u.get(p);g||(g=o.querySelector(zo(p)),g||(a=y({src:a,async:!0},i),(i=or.get(p))&&$p(a,i),g=o.createElement("script"),en(g),fn(g,"link",a),o.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},u.set(p,g))}}function lT(a,i){pa.M(a,i);var o=ts;if(o&&a){var u=Nl(o).hoistableScripts,p=rs(a),g=u.get(p);g||(g=o.querySelector(zo(p)),g||(a=y({src:a,async:!0,type:"module"},i),(i=or.get(p))&&$p(a,i),g=o.createElement("script"),en(g),fn(g,"link",a),o.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},u.set(p,g))}}function Pw(a,i,o,u){var p=(p=be.current)?Fu(p):null;if(!p)throw Error(r(446));switch(a){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(i=ns(o.href),o=Nl(p).hoistableStyles,u=o.get(i),u||(u={type:"style",instance:null,count:0,state:null},o.set(i,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){a=ns(o.href);var g=Nl(p).hoistableStyles,N=g.get(a);if(N||(p=p.ownerDocument||p,N={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(a,N),(g=p.querySelector(Po(a)))&&!g._p&&(N.instance=g,N.state.loading=5),or.has(a)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},or.set(a,o),g||sT(p,a,o,N.state))),i&&u===null)throw Error(r(528,""));return N}if(i&&u!==null)throw Error(r(529,""));return null;case"script":return i=o.async,o=o.src,typeof o=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=rs(o),o=Nl(p).hoistableScripts,u=o.get(i),u||(u={type:"script",instance:null,count:0,state:null},o.set(i,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,a))}}function ns(a){return'href="'+er(a)+'"'}function Po(a){return'link[rel="stylesheet"]['+a+"]"}function zw(a){return y({},a,{"data-precedence":a.precedence,precedence:null})}function sT(a,i,o,u){a.querySelector('link[rel="preload"][as="style"]['+i+"]")?u.loading=1:(i=a.createElement("link"),u.preload=i,i.addEventListener("load",function(){return u.loading|=1}),i.addEventListener("error",function(){return u.loading|=2}),fn(i,"link",o),en(i),a.head.appendChild(i))}function rs(a){return'[src="'+er(a)+'"]'}function zo(a){return"script[async]"+a}function Iw(a,i,o){if(i.count++,i.instance===null)switch(i.type){case"style":var u=a.querySelector('style[data-href~="'+er(o.href)+'"]');if(u)return i.instance=u,en(u),u;var p=y({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return u=(a.ownerDocument||a).createElement("style"),en(u),fn(u,"style",p),Xu(u,o.precedence,a),i.instance=u;case"stylesheet":p=ns(o.href);var g=a.querySelector(Po(p));if(g)return i.state.loading|=4,i.instance=g,en(g),g;u=zw(o),(p=or.get(p))&&Ip(u,p),g=(a.ownerDocument||a).createElement("link"),en(g);var N=g;return N._p=new Promise(function(O,L){N.onload=O,N.onerror=L}),fn(g,"link",u),i.state.loading|=4,Xu(g,o.precedence,a),i.instance=g;case"script":return g=rs(o.src),(p=a.querySelector(zo(g)))?(i.instance=p,en(p),p):(u=o,(p=or.get(g))&&(u=y({},o),$p(u,p)),a=a.ownerDocument||a,p=a.createElement("script"),en(p),fn(p,"link",u),a.head.appendChild(p),i.instance=p);case"void":return null;default:throw Error(r(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(u=i.instance,i.state.loading|=4,Xu(u,o.precedence,a));return i.instance}function Xu(a,i,o){for(var u=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=u.length?u[u.length-1]:null,g=p,N=0;N title"):null)}function oT(a,i,o){if(o===1||i.itemProp!=null)return!1;switch(a){case"meta":case"title":return!0;case"style":if(typeof i.precedence!="string"||typeof i.href!="string"||i.href==="")break;return!0;case"link":if(typeof i.rel!="string"||typeof i.href!="string"||i.href===""||i.onLoad||i.onError)break;switch(i.rel){case"stylesheet":return a=i.disabled,typeof i.precedence=="string"&&a==null;default:return!0}case"script":if(i.async&&typeof i.async!="function"&&typeof i.async!="symbol"&&!i.onLoad&&!i.onError&&i.src&&typeof i.src=="string")return!0}return!1}function Lw(a){return!(a.type==="stylesheet"&&(a.state.loading&3)===0)}function cT(a,i,o,u){if(o.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var p=ns(u.href),g=i.querySelector(Po(p));if(g){i=g._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(a.count++,a=Zu.bind(a),i.then(a,a)),o.state.loading|=4,o.instance=g,en(g);return}g=i.ownerDocument||i,u=zw(u),(p=or.get(p))&&Ip(u,p),g=g.createElement("link"),en(g);var N=g;N._p=new Promise(function(O,L){N.onload=O,N.onerror=L}),fn(g,"link",u),o.instance=g}a.stylesheets===null&&(a.stylesheets=new Map),a.stylesheets.set(o,i),(i=o.state.preload)&&(o.state.loading&3)===0&&(a.count++,o=Zu.bind(a),i.addEventListener("load",o),i.addEventListener("error",o))}}var Rp=0;function uT(a,i){return a.stylesheets&&a.count===0&&Ju(a,a.stylesheets),0Rp?50:800)+i);return a.unsuspend=o,function(){a.unsuspend=null,clearTimeout(u),clearTimeout(p)}}:null}function Zu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ju(this,this.stylesheets);else if(this.unsuspend){var a=this.unsuspend;this.unsuspend=null,a()}}}var Qu=null;function Ju(a,i){a.stylesheets=null,a.unsuspend!==null&&(a.count++,Qu=new Map,i.forEach(dT,a),Qu=null,Zu.call(a))}function dT(a,i){if(!(i.state.loading&4)){var o=Qu.get(a);if(o)var u=o.get(null);else{o=new Map,Qu.set(a,o);for(var p=a.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Vp.exports=CT(),Vp.exports}var MT=TT();const DT=Ky(MT);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const PT=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),zT=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),cj=e=>{const t=zT(e);return t.charAt(0).toUpperCase()+t.slice(1)},lA=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),IT=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */var $T={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const RT=x.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:l="",children:s,iconNode:d,...f},m)=>x.createElement("svg",{ref:m,...$T,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:lA("lucide",l),...!s&&!IT(f)&&{"aria-hidden":"true"},...f},[...d.map(([h,v])=>x.createElement(h,v)),...Array.isArray(s)?s:[s]]));/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Oe=(e,t)=>{const n=x.forwardRef(({className:r,...l},s)=>x.createElement(RT,{ref:s,iconNode:t,className:lA(`lucide-${PT(cj(e))}`,`lucide-${e}`,r),...l}));return n.displayName=cj(e),n};/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const LT=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],uj=Oe("activity",LT);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const BT=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Rv=Oe("arrow-right",BT);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const UT=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],gs=Oe("bell",UT);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const HT=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],ps=Oe("bot",HT);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const qT=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],sA=Oe("box",qT);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const KT=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ci=Oe("check",KT);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const YT=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],GT=Oe("chevron-down",YT);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const VT=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],FT=Oe("chevron-left",VT);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const XT=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],WT=Oe("chevron-right",XT);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ZT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],$d=Oe("circle-alert",ZT);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const QT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],oA=Oe("circle-check",QT);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const JT=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],eM=Oe("circle-dashed",JT);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const tM=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],cA=Oe("clock-3",tM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const nM=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],dj=Oe("clock",nM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const rM=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],od=Oe("cloud-upload",rM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const aM=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],fj=Oe("code",aM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const iM=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],lM=Oe("copy",iM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const sM=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],Lv=Oe("credit-card",sM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const oM=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],cM=Oe("database",oM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const uM=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],dM=Oe("dollar-sign",uM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const fM=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],uA=Oe("external-link",fM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const mM=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],ic=Oe("eye-off",mM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const hM=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],xs=Oe("eye",hM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const pM=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],vM=Oe("file-down",pM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const yM=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],mj=Oe("file-text",yM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const gM=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],xM=Oe("gift",gM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const bM=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],hj=Oe("image",bM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const wM=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],jM=Oe("key",wM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const _M=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],NM=Oe("layers",_M);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const SM=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],AM=Oe("layout-dashboard",SM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const OM=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],EM=Oe("link-2",OM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const kM=[["path",{d:"M16 5H3",key:"m91uny"}],["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 19H3",key:"zzsher"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]],CM=Oe("list-plus",kM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const TM=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Yn=Oe("loader-circle",TM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const MM=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],pj=Oe("lock-keyhole",MM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const DM=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],PM=Oe("lock",DM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const zM=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],IM=Oe("log-out",zM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const $M=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],dA=Oe("mail",$M);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const RM=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],Cd=Oe("message-circle",RM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const LM=[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],uc=Oe("package-check",LM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const BM=[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],Zp=Oe("package-plus",BM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const UM=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],fA=Oe("package",UM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const HM=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],mA=Oe("pen",HM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const qM=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ja=Oe("plus",qM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const KM=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],YM=Oe("power",KM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const GM=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],Qp=Oe("qr-code",GM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const VM=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],pr=Oe("refresh-cw",VM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const FM=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Sa=Oe("save",FM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const XM=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],WM=Oe("search",XM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ZM=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Yy=Oe("send",ZM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const QM=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Gy=Oe("settings",QM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const JM=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],hA=Oe("shield-check",JM);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const eD=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],pA=Oe("shopping-bag",eD);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const tD=[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]],vj=Oe("shopping-cart",tD);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const nD=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],vA=Oe("sparkles",nD);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const rD=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],bs=Oe("square-pen",rD);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const aD=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],xa=Oe("trash-2",aD);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const iD=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],lD=Oe("trending-up",iD);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const sD=[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]],yj=Oe("truck",sD);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const oD=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],tc=Oe("upload",oD);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const cD=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],uD=Oe("user-round",cD);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const dD=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Bv=Oe("user",dD);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const fD=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],yA=Oe("users",fD);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const mD=[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]],hD=Oe("webhook",mD);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const pD=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Xt=Oe("x",pD);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const vD=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Uv=Oe("zap",vD),yD=({activeTab:e,onNavigate:t,onLogout:n})=>{const r=[{id:"dashboard",icon:AM,label:"仪表盘"},{id:"accounts",icon:yA,label:"账号管理"},{id:"orders",icon:pA,label:"订单管理"},{id:"cards",icon:Lv,label:"卡密库存"},{id:"items",icon:sA,label:"商品列表"},{id:"rules",icon:Uv,label:"自动化规则"},{id:"notifications",icon:gs,label:"通知设置"},{id:"settings",icon:Gy,label:"系统与AI"}];return c.jsxs("div",{className:"w-64 h-screen fixed left-0 top-0 bg-white border-r border-gray-100 flex flex-col justify-between z-20 shadow-[4px_0_24px_rgba(0,0,0,0.02)]",children:[c.jsxs("div",{className:"p-6",children:[c.jsxs("div",{className:"flex items-center gap-3 mb-12 px-2",children:[c.jsx("div",{className:"w-10 h-10 bg-[#0094f7] squircle flex items-center justify-center shrink-0 p-1.5",style:{filter:"drop-shadow(0 4px 12px rgba(0,148,247,0.25))"},children:c.jsx("img",{src:"/static/ydisks-logo.svg",alt:"Ydisks",className:"w-full h-full"})}),c.jsxs("h1",{className:"text-xl font-extrabold tracking-tight text-gray-900",children:["Ydisks闲鱼助手 ",c.jsx("span",{className:"text-xs bg-[#0094f7] text-white px-1.5 py-0.5 rounded ml-1",children:"PRO"})]})]}),c.jsx("nav",{className:"space-y-2",children:r.map(l=>{const s=l.icon,d=e===l.id;return c.jsxs("button",{onClick:()=>t(l.id),className:`w-full flex items-center gap-3 px-4 py-3.5 rounded-2xl transition-all duration-300 group relative overflow-hidden ${d?"bg-[#0094f7] text-white font-bold shadow-lg shadow-blue-100 transform scale-[1.02]":"text-gray-500 hover:bg-gray-50 hover:text-gray-900"}`,children:[c.jsx(s,{className:`w-5 h-5 transition-colors ${d?"text-white":"text-gray-400 group-hover:text-gray-600"}`}),c.jsx("span",{className:"text-sm tracking-wide",children:l.label}),d&&c.jsx(vA,{className:"w-4 h-4 absolute right-3 text-white/30 animate-pulse"})]},l.id)})})]}),c.jsx("div",{className:"p-6 border-t border-gray-50",children:c.jsxs("button",{onClick:n,className:"w-full flex items-center gap-3 px-4 py-3 text-gray-500 hover:text-red-500 hover:bg-red-50 rounded-2xl transition-all duration-200 font-medium",children:[c.jsx(IM,{className:"w-5 h-5"}),c.jsx("span",{className:"text-sm",children:"退出登录"})]})})]})},gD=e=>{if(!e)return"";const t=new URLSearchParams;for(const[r,l]of Object.entries(e))l!=null&&t.set(r,String(l));const n=t.toString();return n?`?${n}`:""},Rf=async(e,t,n={})=>{const r=gD(n.params),l=`${t}${r}`,s=await fetch(l,{method:e,credentials:"include",headers:{...n.body===void 0?{}:{"Content-Type":"application/json"}},body:n.body===void 0?void 0:JSON.stringify(n.body)}),f=(s.headers.get("content-type")||"").includes("application/json");if(!s.ok){const m=f?await s.json().catch(()=>{}):await s.text().catch(()=>{}),h=typeof m=="string"?m:(m==null?void 0:m.detail)||(m==null?void 0:m.message)||(m==null?void 0:m.msg);throw new Error(h||`请求失败: ${s.status}`)}return f?await s.json():await s.text()},Tt=async(e,t)=>Rf("GET",e,{params:t}),$t=async(e,t)=>Rf("POST",e,{body:t}),Sn=async(e,t)=>Rf("PUT",e,{body:t}),ml=async(e,t)=>Rf("DELETE",e,{params:t}),Vy=async(e,t)=>{const n=await fetch(e,{method:"POST",credentials:"include",body:t}),s=(n.headers.get("content-type")||"").includes("application/json")?await n.json().catch(()=>{}):await n.text().catch(()=>{});if(!n.ok){const d=typeof s=="string"?s:(s==null?void 0:s.detail)||(s==null?void 0:s.message)||(s==null?void 0:s.msg),f=new Error(d||"请求失败: "+n.status);throw f.payload=s,f}return s},xD=async e=>$t("/login",e),gA=async()=>Tt("/verify"),bD=async e=>Sn("/account/credentials",e),wD=async(e,t)=>$t("/cookies",{id:e,value:t}),jD=(e,t)=>{const n=e.avatar_url||"";if(!n)return"";try{const r=new URL(n,window.location.origin);return r.hostname.endsWith("alicdn.com")&&r.searchParams.set("_v",t),r.toString()}catch{return n}},Fy=async()=>{const e=await Tt("/cookies/details"),t=Date.now().toString();return e.map(n=>({id:n.id,value:"",cookie:"",enabled:n.enabled,auto_confirm:n.auto_confirm,remark:n.remark,note:n.remark,pause_duration:n.pause_duration,username:n.username||"",login_password:"",show_browser:n.show_browser,nickname:n.nickname||n.remark||`账号 ${n.id.substring(0,6)}`,avatar_url:jD(n,t),profile_error:n.profile_error||"",ai_enabled:!1}))},_D=async()=>Tt("/cookies/runtime-status"),ND=async()=>$t("/qr-login/generate"),SD=async e=>Tt(`/qr-login/check/${e}`),AD=async(e,t)=>Sn(`/cookies/${e}/status`,{enabled:t}),OD=async e=>ml(`/cookies/${e}`),ED=async(e,t)=>Sn(`/cookies/${e}/remark`,{remark:t}),kD=async(e,t)=>Sn(`/cookies/${e}/auto-confirm`,{auto_confirm:t}),CD=async(e,t)=>Sn(`/cookies/${e}/pause-duration`,{pause_duration:t}),gj=async(e,t)=>Sn(`/cookies/${e}`,{id:e,value:t}),TD=async e=>$t(`/cookies/${e}/refresh-profile`,{}),MD=async(e,t)=>Sn(`/cookies/${e}/login-info`,t),DD=async()=>Tt("/ai-reply-settings"),xj=async(e,t,n=1,r=20)=>{const l={page:n,page_size:r};t&&t!=="all"&&(l.status=t);const s=await Tt("/api/orders",l),f=(s.orders||s.data||[]).map(m=>({...m,id:m.id||m.order_id,status:m.status||m.order_status||"processing",quantity:Number(m.quantity||1)}));return{success:!0,data:f,total:s.total||f.length,page:s.page||n,page_size:s.page_size||r,total_pages:s.total_pages||1}},PD=async(e,t)=>Sn(`/api/orders/${e}`,t),zD=async e=>ml(`/api/orders/${e}`),ID=async(e,t)=>{const n=new FormData,r=await fetch("/api/orders/refresh",{method:"POST",credentials:"include",body:n}),l=await r.json().catch(()=>({}));if(!r.ok||l.success===!1)throw new Error(l.detail||l.message||`订单同步失败: ${r.status}`);return l},$D=async e=>$t(`/api/orders/${e}/refresh`),RD=async(e,t,n)=>$t("/api/orders/manual-ship",{order_ids:e,ship_mode:t,custom_content:n}),LD=async e=>{const t=e instanceof FormData,n=await fetch("/api/orders/import",{method:"POST",credentials:"include",headers:{...t?{}:{"Content-Type":"application/json"}},body:t?e:JSON.stringify(e)}),r=await n.json().catch(()=>({}));if(!n.ok||r.success===!1)throw new Error(r.detail||r.message||`订单导入失败: ${n.status}`);return r},BD=async()=>Tt("/admin/stats"),bj=async(e=7)=>{let t;if(typeof e=="number"){const n=new Date,r=new Date;r.setDate(r.getDate()-e),t={start_date:r.toISOString().split("T")[0],end_date:n.toISOString().split("T")[0]}}else t=e;return Tt("/analytics/orders",t)},UD=async e=>{const t=await Tt("/analytics/orders/valid",{start_date:e.start_date,end_date:e.end_date});return(Array.isArray(t)?t:t.orders||[]).map(r=>({...r,id:r.id||r.order_id,status:r.status||r.order_status||"processing",quantity:Number(r.quantity||1)}))},HD=e=>{let t=e.api_config;if(typeof t=="string"&&t.trim())try{t=JSON.parse(t)}catch{t=void 0}return{...e,api_config:t||void 0}},xA=e=>({...e,api_config:e.api_config?JSON.stringify(e.api_config):""}),va=async()=>{const e=await Tt("/cards");return(Array.isArray(e)?e:e.cards||[]).map(HD)},qD=async e=>$t("/cards",xA(e)),wj=async(e,t)=>Sn(`/cards/${e}`,xA(t)),KD=async e=>ml(`/cards/${e}`),YD=async e=>{const t=new FormData;return t.append("file",e),Vy("/cards/batch",t)},GD=async(e,t)=>$t(`/cards/${e}/append-data`,{content:t}),Jp=e=>e===!0||e===1||e==="1",Ns=async()=>{const e=await Tt("/items");return(Array.isArray(e)?e:e.items||[]).map(n=>({...n,id:n.id||`${n.cookie_id}-${n.item_id}`,is_multi_spec:Jp(n.is_multi_spec),is_multi_qty_ship:Jp(n.is_multi_qty_ship??n.multi_quantity_delivery),multi_quantity_delivery:Jp(n.multi_quantity_delivery??n.is_multi_qty_ship)}))},VD=async e=>$t("/items/get-all-from-account",{cookie_id:e}),FD=async(e,t)=>ml(`/items/${e}/${t}`),XD=async(e,t)=>$t(`/items/${e}`,t),WD=async e=>{const t=new FormData;t.set("cookie_id",e.cookie_id),t.set("title",e.title),t.set("description",e.description),t.set("price",e.price),t.set("original_price",e.original_price||""),t.set("quantity",String(e.quantity)),t.set("postage_mode",e.postage_mode),t.set("postage",e.postage||"");for(const n of e.images)t.append("images",n);return Vy("/items/publish",t)},ZD=async e=>{const t=new FormData;return t.set("file",e.file),e.imagesZip&&t.set("images_zip",e.imagesZip),e.defaultCookieId&&t.set("default_cookie_id",e.defaultCookieId),Vy("/items/publish-batches/preview",t)},QD=async e=>$t("/items/publish-batches",{preview_id:e}),cd=async e=>Tt(`/items/publish-batches/${e}`),JD=async e=>$t(`/items/publish-batches/${e}/cancel`,{}),eP=async e=>$t(`/items/publish-batches/${e}/retry-failed`,{}),tP=async(e,t,n)=>Sn(`/items/${e}/${t}`,n),Rd=async()=>{const e=await Tt("/automation-rules");return(Array.isArray(e)?e:e.data||e.rules||[]).map(n=>{var r,l;return{id:String(n.id),name:n.name||"",trigger_type:n.trigger_type||"order_paid",item_keyword:n.item_title||n.item_id||"",cookie_id:n.cookie_id||"",item_id:n.item_id||"",item_title:n.item_title||"",card_group_id:Number(((r=(n.actions||[]).find(s=>s.action_type==="send_card"))==null?void 0:r.card_id)||0),card_group_name:((l=(n.actions||[]).find(s=>s.action_type==="send_card"))==null?void 0:l.card_name)||"",priority:n.priority||100,enabled:n.enabled||!1,config_json:n.config_json||"{}",actions:(n.actions||[]).map(s=>({id:s.id?String(s.id):void 0,action_type:s.action_type,card_id:Number(s.card_id||0),card_name:s.card_name||"",delivery_count:Number(s.delivery_count||1),message_template:s.message_template||"",delay_seconds:Number(s.delay_seconds||0),config_json:s.config_json||"{}",enabled:s.enabled!==!1,sort_order:Number(s.sort_order||0)})),variants:(n.actions||[]).filter(s=>s.action_type==="send_card").map(s=>{let d={};try{d=JSON.parse(s.config_json||"{}")}catch{}return{id:s.id?String(s.id):void 0,spec_name:d.spec_name||"",spec_value:d.spec_value||"",card_id:Number(s.card_id||0),card_name:s.card_name||"",delivery_count:Number(s.delivery_count||1),enabled:s.enabled!==!1,config_json:s.config_json||"{}"}})}})},nP=(e,t)=>{if(e!=="order_paid")return t.map((l,s)=>({...l,sort_order:l.sort_order||s+1}));const n=t.filter(l=>l.action_type==="send_card").map((l,s)=>({...l,sort_order:s+1})),r=t.filter(l=>l.action_type!=="send_card"&&l.action_type!=="confirm_shipment");return[...n,...r.map((l,s)=>({...l,sort_order:n.length+s+1})),{action_type:"confirm_shipment",enabled:!0,sort_order:n.length+r.length+1}]},jj=async e=>{const t=e.trigger_type||"order_paid",r=[{order_paid:"付款后自动发货",buyer_reviewed:"评价后发送赠品",review_missing_timeout:"超时未评价求评价"}[t]||"自动化规则",e.item_title||e.item_id||e.cookie_id||""].filter(Boolean).join(" - "),l=e.variants&&e.variants.length>0?e.variants.map((f,m)=>({action_type:"send_card",card_id:f.card_id,delivery_count:f.delivery_count||1,enabled:f.enabled!==!1,sort_order:m+1,config_json:JSON.stringify({spec_name:f.spec_name||"",spec_value:f.spec_value||""})})):e.actions&&e.actions.length>0?e.actions:[{action_type:"send_card",card_id:e.card_group_id||0,delivery_count:1,enabled:!0,sort_order:1}],s=nP(t,l),d={cookie_id:e.cookie_id||"",item_id:e.item_id||"",name:(e.name||"").trim()||r||"自动化规则",trigger_type:t,enabled:e.enabled??!0,priority:e.priority||100,config_json:e.config_json||"{}",actions:s.map((f,m)=>({action_type:f.action_type,card_id:f.card_id||0,delivery_count:f.delivery_count||1,message_template:f.message_template||"",delay_seconds:f.delay_seconds||0,config_json:f.config_json||"{}",enabled:f.enabled!==!1,sort_order:f.sort_order||m+1}))};return e.id?Sn(`/automation-rules/${e.id}`,d):$t("/automation-rules",d)},rP=async e=>ml(`/automation-rules/${e}`),aP=async e=>{if(!e)return[];const t=await Tt(`/keywords-with-item-id/${e}`);return(Array.isArray(t)?t:[]).map((r,l)=>({id:String(l),keyword:r.keyword||"",reply_content:r.reply||"",match_type:"exact",enabled:!0}))},iP=async(e,t)=>{const n=await Tt(`/keywords-with-item-id/${t}`),r=Array.isArray(n)?n:[];if(e.id){const l=parseInt(e.id);l>=0&&l{const n=await Tt(`/keywords-with-item-id/${t}`),r=Array.isArray(n)?n:[],l=parseInt(e);return l>=0&&l{const e=await Tt("/system-settings");return e.data||e},wA=async e=>{const t=Object.entries(e).map(([n,r])=>Sn(`/system-settings/${n}`,{value:String(r)}));return await Promise.all(t),{success:!0,message:"Settings saved"}},sP=async e=>Tt(`/ai-reply-settings/${e}`),oP=async(e,t)=>{const n={ai_enabled:t.ai_enabled??!1,max_discount_percent:t.max_discount_percent??10,max_discount_amount:t.max_discount_amount??100,max_bargain_rounds:t.max_bargain_rounds??3,custom_prompts:t.custom_prompts??""};return Sn(`/ai-reply-settings/${e}`,n)},cP=async(e,t="")=>(await $t("/ai-models",{base_url:e,api_key:t})).models||[],jA=async()=>({success:!0,data:(await Tt("/notification-channels")||[]).map(n=>{let r;try{r=JSON.parse(n.config)}catch{r=void 0}return{id:String(n.id),name:n.name,type:n.type,config:r,enabled:n.enabled,created_at:n.created_at,updated_at:n.updated_at}})}),uP=async e=>$t("/notification-channels",{...e,config:JSON.stringify(e.config)}),_j=async(e,t)=>{const n={...t};return"config"in t&&(n.config=JSON.stringify(t.config)),Sn(`/notification-channels/${e}`,n)},dP=async e=>ml(`/notification-channels/${e}`),fP=async e=>{const t=await Tt(`/message-notifications/${e}`);return(t==null?void 0:t.channel_ids)||[]},mP=async(e,t)=>$t(`/message-notifications/${e}`,{channel_ids:t}),hP=async e=>$t(`/notification-channels/${e}/test`,{}),Nj=async()=>Tt("/api/default-replies"),pP=async e=>{const t=await Tt(`/api/default-reply/${e}`);return{cookie_id:e,enabled:t.enabled||!1,reply_content:t.reply_content||"",reply_once:t.reply_once||!1,reply_image_url:t.reply_image_url||""}},vP=async(e,t)=>Sn(`/api/default-reply/${e}`,{enabled:t.enabled??!1,reply_content:t.reply_content||"",reply_once:t.reply_once??!1,reply_image_url:t.reply_image_url||""}),yP=async e=>ml(`/api/default-reply/${e}`),gP=async e=>$t(`/api/default-reply/${e}/clear-records`,{});function _A(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var l=e.length;for(t=0;t{var n=e.children,r=e.width,l=e.height,s=e.viewBox,d=e.className,f=e.style,m=e.title,h=e.desc,v=NP(e,_P),y=s||{width:r,height:l,x:0,y:0},b=nt("recharts-surface",d);return x.createElement("svg",Hv({},Xn(v),{className:b,width:r,height:l,style:f,viewBox:"".concat(y.x," ").concat(y.y," ").concat(y.width," ").concat(y.height),ref:t}),x.createElement("title",null,m),x.createElement("desc",null,h),n)}),AP=["children","className"];function qv(){return qv=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=e.children,r=e.className,l=OP(e,AP),s=nt("recharts-layer",r);return x.createElement("g",qv({className:s},Xn(l),{ref:t}),n)}),It=iA(),AA=x.createContext(null),kP=()=>x.useContext(AA);function ht(e){return function(){return e}}const OA=Math.cos,Ld=Math.sin,Er=Math.sqrt,Bd=Math.PI,Lf=2*Bd,Kv=Math.PI,Yv=2*Kv,Ki=1e-6,CP=Yv-Ki;function EA(e){this._+=e[0];for(let t=1,n=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return EA;const n=10**t;return function(r){this._+=r[0];for(let l=1,s=r.length;lKi)if(!(Math.abs(y*m-h*v)>Ki)||!s)this._append`L${this._x1=t},${this._y1=n}`;else{let w=r-d,j=l-f,_=m*m+h*h,S=w*w+j*j,A=Math.sqrt(_),C=Math.sqrt(b),M=s*Math.tan((Kv-Math.acos((_+b-S)/(2*A*C)))/2),k=M/C,D=M/A;Math.abs(k-1)>Ki&&this._append`L${t+k*v},${n+k*y}`,this._append`A${s},${s},0,0,${+(y*w>v*j)},${this._x1=t+D*m},${this._y1=n+D*h}`}}arc(t,n,r,l,s,d){if(t=+t,n=+n,r=+r,d=!!d,r<0)throw new Error(`negative radius: ${r}`);let f=r*Math.cos(l),m=r*Math.sin(l),h=t+f,v=n+m,y=1^d,b=d?l-s:s-l;this._x1===null?this._append`M${h},${v}`:(Math.abs(this._x1-h)>Ki||Math.abs(this._y1-v)>Ki)&&this._append`L${h},${v}`,r&&(b<0&&(b=b%Yv+Yv),b>CP?this._append`A${r},${r},0,1,${y},${t-f},${n-m}A${r},${r},0,1,${y},${this._x1=h},${this._y1=v}`:b>Ki&&this._append`A${r},${r},0,${+(b>=Kv)},${y},${this._x1=t+r*Math.cos(s)},${this._y1=n+r*Math.sin(s)}`)}rect(t,n,r,l){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+l}h${-r}Z`}toString(){return this._}}function Zy(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new MP(t)}function Qy(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function kA(e){this._context=e}kA.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function Bf(e){return new kA(e)}function CA(e){return e[0]}function TA(e){return e[1]}function MA(e,t){var n=ht(!0),r=null,l=Bf,s=null,d=Zy(f);e=typeof e=="function"?e:e===void 0?CA:ht(e),t=typeof t=="function"?t:t===void 0?TA:ht(t);function f(m){var h,v=(m=Qy(m)).length,y,b=!1,w;for(r==null&&(s=l(w=d())),h=0;h<=v;++h)!(h=w;--j)f.point(M[j],k[j]);f.lineEnd(),f.areaEnd()}A&&(M[b]=+e(S,b,y),k[b]=+t(S,b,y),f.point(r?+r(S,b,y):M[b],n?+n(S,b,y):k[b]))}if(C)return f=null,C+""||null}function v(){return MA().defined(l).curve(d).context(s)}return h.x=function(y){return arguments.length?(e=typeof y=="function"?y:ht(+y),r=null,h):e},h.x0=function(y){return arguments.length?(e=typeof y=="function"?y:ht(+y),h):e},h.x1=function(y){return arguments.length?(r=y==null?null:typeof y=="function"?y:ht(+y),h):r},h.y=function(y){return arguments.length?(t=typeof y=="function"?y:ht(+y),n=null,h):t},h.y0=function(y){return arguments.length?(t=typeof y=="function"?y:ht(+y),h):t},h.y1=function(y){return arguments.length?(n=y==null?null:typeof y=="function"?y:ht(+y),h):n},h.lineX0=h.lineY0=function(){return v().x(e).y(t)},h.lineY1=function(){return v().x(e).y(n)},h.lineX1=function(){return v().x(r).y(t)},h.defined=function(y){return arguments.length?(l=typeof y=="function"?y:ht(!!y),h):l},h.curve=function(y){return arguments.length?(d=y,s!=null&&(f=d(s)),h):d},h.context=function(y){return arguments.length?(y==null?s=f=null:f=d(s=y),h):s},h}class DA{constructor(t,n){this._context=t,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,n){switch(t=+t,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,n,t,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,t,this._y0,t,n);break}}this._x0=t,this._y0=n}}function DP(e){return new DA(e,!0)}function PP(e){return new DA(e,!1)}const Jy={draw(e,t){const n=Er(t/Bd);e.moveTo(n,0),e.arc(0,0,n,0,Lf)}},zP={draw(e,t){const n=Er(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},PA=Er(1/3),IP=PA*2,$P={draw(e,t){const n=Er(t/IP),r=n*PA;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},RP={draw(e,t){const n=Er(t),r=-n/2;e.rect(r,r,n,n)}},LP=.8908130915292852,zA=Ld(Bd/10)/Ld(7*Bd/10),BP=Ld(Lf/10)*zA,UP=-OA(Lf/10)*zA,HP={draw(e,t){const n=Er(t*LP),r=BP*n,l=UP*n;e.moveTo(0,-n),e.lineTo(r,l);for(let s=1;s<5;++s){const d=Lf*s/5,f=OA(d),m=Ld(d);e.lineTo(m*n,-f*n),e.lineTo(f*r-m*l,m*r+f*l)}e.closePath()}},ev=Er(3),qP={draw(e,t){const n=-Er(t/(ev*3));e.moveTo(0,n*2),e.lineTo(-ev*n,-n),e.lineTo(ev*n,-n),e.closePath()}},cr=-.5,ur=Er(3)/2,Gv=1/Er(12),KP=(Gv/2+1)*3,YP={draw(e,t){const n=Er(t/KP),r=n/2,l=n*Gv,s=r,d=n*Gv+n,f=-s,m=d;e.moveTo(r,l),e.lineTo(s,d),e.lineTo(f,m),e.lineTo(cr*r-ur*l,ur*r+cr*l),e.lineTo(cr*s-ur*d,ur*s+cr*d),e.lineTo(cr*f-ur*m,ur*f+cr*m),e.lineTo(cr*r+ur*l,cr*l-ur*r),e.lineTo(cr*s+ur*d,cr*d-ur*s),e.lineTo(cr*f+ur*m,cr*m-ur*f),e.closePath()}};function GP(e,t){let n=null,r=Zy(l);e=typeof e=="function"?e:ht(e||Jy),t=typeof t=="function"?t:ht(t===void 0?64:+t);function l(){let s;if(n||(n=s=r()),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),s)return n=null,s+""||null}return l.type=function(s){return arguments.length?(e=typeof s=="function"?s:ht(s),l):e},l.size=function(s){return arguments.length?(t=typeof s=="function"?s:ht(+s),l):t},l.context=function(s){return arguments.length?(n=s??null,l):n},l}function Ud(){}function Hd(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function IA(e){this._context=e}IA.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Hd(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Hd(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function VP(e){return new IA(e)}function $A(e){this._context=e}$A.prototype={areaStart:Ud,areaEnd:Ud,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:Hd(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function FP(e){return new $A(e)}function RA(e){this._context=e}RA.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:Hd(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function XP(e){return new RA(e)}function LA(e){this._context=e}LA.prototype={areaStart:Ud,areaEnd:Ud,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function WP(e){return new LA(e)}function Sj(e){return e<0?-1:1}function Aj(e,t,n){var r=e._x1-e._x0,l=t-e._x1,s=(e._y1-e._y0)/(r||l<0&&-0),d=(n-e._y1)/(l||r<0&&-0),f=(s*l+d*r)/(r+l);return(Sj(s)+Sj(d))*Math.min(Math.abs(s),Math.abs(d),.5*Math.abs(f))||0}function Oj(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function tv(e,t,n){var r=e._x0,l=e._y0,s=e._x1,d=e._y1,f=(s-r)/3;e._context.bezierCurveTo(r+f,l+f*t,s-f,d-f*n,s,d)}function qd(e){this._context=e}qd.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:tv(this,this._t0,Oj(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,tv(this,Oj(this,n=Aj(this,e,t)),n);break;default:tv(this,this._t0,n=Aj(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function BA(e){this._context=new UA(e)}(BA.prototype=Object.create(qd.prototype)).point=function(e,t){qd.prototype.point.call(this,t,e)};function UA(e){this._context=e}UA.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,l,s){this._context.bezierCurveTo(t,e,r,n,s,l)}};function ZP(e){return new qd(e)}function QP(e){return new BA(e)}function HA(e){this._context=e}HA.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=Ej(e),l=Ej(t),s=0,d=1;d=0;--t)l[t]=(d[t]-l[t+1])/s[t];for(s[n-1]=(e[n]+l[n-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}}this._x=e,this._y=t}};function e6(e){return new Uf(e,.5)}function t6(e){return new Uf(e,0)}function n6(e){return new Uf(e,1)}function al(e,t){if((d=e.length)>1)for(var n=1,r,l,s=e[t[0]],d,f=s.length;n=0;)n[t]=t;return n}function r6(e,t){return e[t]}function a6(e){const t=[];return t.key=e,t}function i6(){var e=ht([]),t=Vv,n=al,r=r6;function l(s){var d=Array.from(e.apply(this,arguments),a6),f,m=d.length,h=-1,v;for(const y of s)for(f=0,++h;f0){for(var n,r,l=0,s=e[0].length,d;l0){for(var n=0,r=e[t[0]],l,s=r.length;n0)||!((s=(l=e[t[0]]).length)>0))){for(var n=0,r=1,l,s,d;r1&&arguments[1]!==void 0?arguments[1]:u6,n=10**t,r=Math.round(e*n)/n;return Object.is(r,-0)?0:r}function hn(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{var f=n[d-1];return typeof f=="string"?l+f+s:f!==void 0?l+di(f)+s:l+s},"")}var rn=e=>e===0?0:e>0?1:-1,Ar=e=>typeof e=="number"&&e!=+e,il=e=>typeof e=="string"&&e.length>1&&e.indexOf("%")===e.length-1,je=e=>(typeof e=="number"||e instanceof Number)&&!Ar(e),qr=e=>je(e)||typeof e=="string",d6=0,dc=e=>{var t=++d6;return"".concat(e||"").concat(t)},xn=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,l=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!je(t)&&typeof t!="string")return r;var s;if(il(t)){if(n==null)return r;var d=t.indexOf("%");s=n*parseFloat(t.slice(0,d))/100}else s=+t;return Ar(s)&&(s=r),l&&n!=null&&s>n&&(s=n),s},YA=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;rr&&(typeof t=="function"?t(r):Hr(r,t))===n)}var Nt=e=>e===null||typeof e>"u",Ac=e=>Nt(e)?e:"".concat(e.charAt(0).toUpperCase()).concat(e.slice(1));function Dn(e){return e!=null}function hl(){}var f6=["type","size","sizeType"];function Xv(){return Xv=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t="symbol".concat(Ac(e));return VA[t]||Jy},b6=(e,t,n)=>{if(t==="area")return e;switch(n){case"cross":return 5*e*e/9;case"diamond":return .5*e*e/Math.sqrt(3);case"square":return e*e;case"star":{var r=18*g6;return 1.25*e*e*(Math.tan(r)-Math.tan(r*2)*Math.tan(r)**2)}case"triangle":return Math.sqrt(3)*e*e/4;case"wye":return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},w6=(e,t)=>{VA["symbol".concat(Ac(e))]=t},FA=e=>{var t=e.type,n=t===void 0?"circle":t,r=e.size,l=r===void 0?64:r,s=e.sizeType,d=s===void 0?"area":s,f=v6(e,f6),m=Cj(Cj({},f),{},{type:n,size:l,sizeType:d}),h="circle";typeof n=="string"&&(h=n);var v=()=>{var _=x6(h),S=GP().type(_).size(b6(l,d,h)),A=S();if(A!==null)return A},y=m.className,b=m.cx,w=m.cy,j=Xn(m);return je(b)&&je(w)&&je(l)?x.createElement("path",Xv({},j,{className:nt("recharts-symbols",y),transform:"translate(".concat(b,", ").concat(w,")"),d:v()})):null};FA.registerSymbol=w6;var XA=e=>"radius"in e&&"startAngle"in e&&"endAngle"in e,n0=(e,t)=>{if(!e||typeof e=="function"||typeof e=="boolean")return null;var n=e;if(x.isValidElement(e)&&(n=e.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(l=>{Xy(l)&&typeof n[l]=="function"&&(r[l]=(s=>n[l](n,s)))}),r},j6=(e,t,n)=>r=>(e(t,n,r),null),Oc=(e,t,n)=>{if(e===null||typeof e!="object"&&typeof e!="function")return null;var r=null;return Object.keys(e).forEach(l=>{var s=e[l];Xy(l)&&typeof s=="function"&&(r||(r={}),r[l]=j6(s,t,n))}),r};function Tj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function _6(e){for(var t=1;t(d[f]===void 0&&r[f]!==void 0&&(d[f]=r[f]),d),n);return s}function Kd(){return Kd=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var w=y.formatter||l,j=nt({"recharts-legend-item":!0,["legend-item-".concat(b)]:!0,inactive:y.inactive});if(y.type==="none")return null;var _=typeof f=="object"?WA({},f):{};_.color=y.inactive?s:_.color||y.color;var S=w?w(y.value,y,b):y.value;return x.createElement("li",Kd({className:j,style:h,key:"legend-item-".concat(b)},Oc(e,y,b)),x.createElement(Wy,{width:n,height:n,viewBox:m,style:v,"aria-label":"".concat(y.value," legend icon")},x.createElement(M6,{data:y,iconType:d,inactiveColor:s})),x.createElement("span",{className:"recharts-legend-item-text",style:_},S))})}var P6=e=>{var t=an(e,C6),n=t.payload,r=t.layout,l=t.align;if(!n||!n.length)return null;var s={padding:0,margin:0,textAlign:r==="horizontal"?l:"left"};return x.createElement("ul",{className:"recharts-default-legend",style:s},x.createElement(D6,Kd({},t,{payload:n})))};function z6(e,t){const n=new Map;for(let r=0;rObject.prototype.propertyIsEnumerable.call(e,t))}function r0(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const B6="[object RegExp]",QA="[object String]",JA="[object Number]",eO="[object Boolean]",tO="[object Arguments]",U6="[object Symbol]",H6="[object Date]",q6="[object Map]",K6="[object Set]",Y6="[object Array]",G6="[object ArrayBuffer]",V6="[object Object]",F6="[object DataView]",X6="[object Uint8Array]",W6="[object Uint8ClampedArray]",Z6="[object Uint16Array]",Q6="[object Uint32Array]",J6="[object Int8Array]",ez="[object Int16Array]",tz="[object Int32Array]",nz="[object Float32Array]",rz="[object Float64Array]",Dj=typeof globalThis=="object"&&globalThis||typeof window=="object"&&window||typeof self=="object"&&self||typeof global=="object"&&global||(function(){return this})();function az(e){return typeof Dj.Buffer<"u"&&Dj.Buffer.isBuffer(e)}function iz(e,t){return Fi(e,void 0,e,new Map,t)}function Fi(e,t,n,r=new Map,l=void 0){const s=l==null?void 0:l(e,t,n,r);if(s!==void 0)return s;if(Wv(e))return e;if(r.has(e))return r.get(e);if(Array.isArray(e)){const d=new Array(e.length);r.set(e,d);for(let f=0;f{}):Zv(e,t,function r(l,s,d,f,m,h){const v=n(l,s,d,f,m,h);return v!==void 0?!!v:Zv(l,s,r,h,!1)},new Map,!0)}function Zv(e,t,n,r,l=!1){if(t===e)return!0;switch(typeof t){case"object":return oz(e,t,n,r);case"function":return Object.keys(t).length>0?Zv(e,{...t},n,r,l):Td(e,t);default:return nO(e)&&l?typeof t=="string"?t==="":!0:Td(e,t)}}function oz(e,t,n,r){if(t==null)return!0;if(Array.isArray(t))return aO(e,t,n,r);if(t instanceof Map)return cz(e,t,n,r);if(t instanceof Set)return uz(e,t,n,r);const l=Object.keys(t);if(e==null||Wv(e))return l.length===0;if(l.length===0)return!0;if(r!=null&&r.has(t))return r.get(t)===e;r==null||r.set(t,e);try{for(let s=0;s{})}function dz(e){return e=sz(e),t=>iO(t,e)}function fz(e,t){return iz(e,(n,r,l,s)=>{if(typeof e=="object"){if(r0(e)==="[object Object]"&&typeof e.constructor!="function"){const d={};return s.set(e,d),jr(d,e,l,s),d}switch(Object.prototype.toString.call(e)){case JA:case QA:case eO:{const d=new e.constructor(e==null?void 0:e.valueOf());return jr(d,e),d}case tO:{const d={};return jr(d,e),d.length=e.length,d[Symbol.iterator]=e[Symbol.iterator],d}default:return}}})}function mz(e){return fz(e)}const hz=/^(?:0|[1-9]\d*)$/;function lO(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&e=0}function sO(e){return e!=null&&typeof e!="function"&&xz(e.length)}function bz(e){return typeof e=="object"&&e!==null}function wz(e){return bz(e)&&sO(e)}function Pj(e,t=ZA){return wz(e)?z6(Array.from(e),I6(gz(t),1)):[]}function oO(e,t,n){return t===!0?Pj(e,n):typeof t=="function"?Pj(e,t):e}var nv={exports:{}},rv={},av={exports:{}},iv={};/** - * @license React - * use-sync-external-store-shim.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var zj;function jz(){if(zj)return iv;zj=1;var e=zs();function t(y,b){return y===b&&(y!==0||1/y===1/b)||y!==y&&b!==b}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,l=e.useEffect,s=e.useLayoutEffect,d=e.useDebugValue;function f(y,b){var w=b(),j=r({inst:{value:w,getSnapshot:b}}),_=j[0].inst,S=j[1];return s(function(){_.value=w,_.getSnapshot=b,m(_)&&S({inst:_})},[y,w,b]),l(function(){return m(_)&&S({inst:_}),y(function(){m(_)&&S({inst:_})})},[y]),d(w),w}function m(y){var b=y.getSnapshot;y=y.value;try{var w=b();return!n(y,w)}catch{return!0}}function h(y,b){return b()}var v=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:f;return iv.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:v,iv}var Ij;function _z(){return Ij||(Ij=1,av.exports=jz()),av.exports}/** - * @license React - * use-sync-external-store-shim/with-selector.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var $j;function Nz(){if($j)return rv;$j=1;var e=zs(),t=_z();function n(h,v){return h===v&&(h!==0||1/h===1/v)||h!==h&&v!==v}var r=typeof Object.is=="function"?Object.is:n,l=t.useSyncExternalStore,s=e.useRef,d=e.useEffect,f=e.useMemo,m=e.useDebugValue;return rv.useSyncExternalStoreWithSelector=function(h,v,y,b,w){var j=s(null);if(j.current===null){var _={hasValue:!1,value:null};j.current=_}else _=j.current;j=f(function(){function A(E){if(!C){if(C=!0,M=E,E=b(E),w!==void 0&&_.hasValue){var $=_.value;if(w($,E))return k=$}return k=E}if($=k,r(M,E))return $;var U=b(E);return w!==void 0&&w($,U)?(M=E,$):(M=E,k=U)}var C=!1,M,k,D=y===void 0?null:y;return[function(){return A(v())},D===null?void 0:function(){return A(D())}]},[v,y,b,w]);var S=l(h,j[0],j[1]);return d(function(){_.hasValue=!0,_.value=S},[S]),m(S),S},rv}var Rj;function Sz(){return Rj||(Rj=1,nv.exports=Nz()),nv.exports}var Az=Sz(),a0=x.createContext(null),Oz=e=>e,dt=()=>{var e=x.useContext(a0);return e?e.store.dispatch:Oz},Md=()=>{},Ez=()=>Md,kz=(e,t)=>e===t;function Ne(e){var t=x.useContext(a0),n=x.useMemo(()=>t?r=>{if(r!=null)return e(r)}:Md,[t,e]);return Az.useSyncExternalStoreWithSelector(t?t.subscription.addNestedSub:Ez,t?t.store.getState:Md,t?t.store.getState:Md,n,kz)}function Cz(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function Tz(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var Lj=e=>Array.isArray(e)?e:[e];function Mz(e){const t=Array.isArray(e[0])?e[0]:e;return Tz(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function Dz(e,t){const n=[],{length:r}=e;for(let l=0;ltypeof WeakRef>"u"?Pz:WeakRef,cO=zz(),Iz=0,Bj=1;function dd(){return{s:Iz,v:void 0,o:null,p:null}}function $z(e){return e instanceof cO?e.deref():e}function uO(e,t={}){let n=dd();const{resultEqualityCheck:r}=t;let l,s=0;function d(){let f=n;const{length:m}=arguments;for(let y=0,b=m;y{n=dd(),d.resetResultsCount()},d.resultsCount=()=>s,d.resetResultsCount=()=>{s=0},d}function Rz(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...l)=>{let s=0,d=0,f,m={},h=l.pop();typeof h=="object"&&(m=h,h=l.pop()),Cz(h,`createSelector expects an output function after the inputs, but received: [${typeof h}]`);const v={...n,...m},{memoize:y,memoizeOptions:b=[],argsMemoize:w=uO,argsMemoizeOptions:j=[]}=v,_=Lj(b),S=Lj(j),A=Mz(l),C=y(function(){return s++,h.apply(null,arguments)},..._),M=w(function(){d++;const D=Dz(A,arguments);return f=C.apply(null,D),f},...S);return Object.assign(M,{resultFunc:h,memoizedResultFunc:C,dependencies:A,dependencyRecomputations:()=>d,resetDependencyRecomputations:()=>{d=0},lastResult:()=>f,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:y,argsMemoize:w})};return Object.assign(r,{withTypes:()=>r}),r}var X=Rz(uO);function Lz(e,t=1){const n=[],r=Math.floor(t),l=(s,d)=>{for(let f=0;f{if(e!==t){const r=Uj(e),l=Uj(t);if(r===l&&r===0){if(et)return n==="desc"?-1:1}return n==="desc"?l-r:r-l}return 0};function dO(e){return typeof e=="symbol"||e instanceof Symbol}const Uz=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Hz=/^\w*$/;function qz(e,t){return Array.isArray(e)?!1:typeof e=="number"||typeof e=="boolean"||e==null||dO(e)?!0:typeof e=="string"&&(Hz.test(e)||!Uz.test(e))||t!=null}function Kz(e,t,n,r){if(e==null)return[];n=n,Array.isArray(e)||(e=Object.values(e)),Array.isArray(t)||(t=t==null?[null]:[t]),t.length===0&&(t=[null]),Array.isArray(n)||(n=n==null?[]:[n]),n=n.map(f=>String(f));const l=(f,m)=>{let h=f;for(let v=0;vm==null||f==null?m:typeof f=="object"&&"key"in f?Object.hasOwn(m,f.key)?m[f.key]:l(m,f.path):typeof f=="function"?f(m):Array.isArray(f)?l(m,f):typeof m=="object"?m[f]:m,d=t.map(f=>(Array.isArray(f)&&f.length===1&&(f=f[0]),f==null||typeof f=="function"||Array.isArray(f)||qz(f)?f:{key:f,path:t0(f)}));return e.map(f=>({original:f,criteria:d.map(m=>s(m,f))})).slice().sort((f,m)=>{for(let h=0;hf.original)}function Hf(e,...t){const n=t.length;return n>1&&Qv(e,t[0],t[1])?t=[]:n>2&&Qv(t[0],t[1],t[2])&&(t=[t[0]]),Kz(e,Lz(t),["asc"])}var fO=e=>e.legend.settings,Yz=e=>e.legend.size,Gz=e=>e.legend.payload,Vz=X([Gz,fO],(e,t)=>{var n=t.itemSorter,r=e.flat(1);return n?Hf(r,n):r});function Fz(){return Ne(Vz)}function Xz(e,t){return Jz(e)||Qz(e,t)||Zz(e,t)||Wz()}function Wz(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Zz(e,t){if(e){if(typeof e=="string")return Hj(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Hj(e,t):void 0}}function Hj(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);nfd||Math.abs(e.left-t.left)>fd||Math.abs(e.top-t.top)>fd||Math.abs(e.width-t.width)>fd}function Kj(e){var t=e.getBoundingClientRect();return{height:t.height,left:t.left,top:t.top,width:t.width}}function mO(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=x.useState({height:0,left:0,top:0,width:0}),n=Xz(t,2),r=n[0],l=n[1],s=x.useRef(null),d=x.useRef(r);d.current=r;var f=x.useCallback(m=>{if(s.current!=null&&(s.current.disconnect(),s.current=null),m!=null){var h=Kj(m);if(qj(h,d.current)&&l(h),typeof ResizeObserver<"u"){var v=new ResizeObserver(()=>{var y=Kj(m);qj(y,d.current)&&l(y)});v.observe(m),s.current=v}}},[...e]);return x.useEffect(()=>()=>{var m;(m=s.current)===null||m===void 0||m.disconnect()},[]),[r,f]}function mn(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var e8=typeof Symbol=="function"&&Symbol.observable||"@@observable",Yj=e8,lv=()=>Math.random().toString(36).substring(7).split("").join("."),t8={INIT:`@@redux/INIT${lv()}`,REPLACE:`@@redux/REPLACE${lv()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${lv()}`},Yd=t8;function i0(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function hO(e,t,n){if(typeof e!="function")throw new Error(mn(2));if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(mn(0));if(typeof t=="function"&&typeof n>"u"&&(n=t,t=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(mn(1));return n(hO)(e,t)}let r=e,l=t,s=new Map,d=s,f=0,m=!1;function h(){d===s&&(d=new Map,s.forEach((S,A)=>{d.set(A,S)}))}function v(){if(m)throw new Error(mn(3));return l}function y(S){if(typeof S!="function")throw new Error(mn(4));if(m)throw new Error(mn(5));let A=!0;h();const C=f++;return d.set(C,S),function(){if(A){if(m)throw new Error(mn(6));A=!1,h(),d.delete(C),s=null}}}function b(S){if(!i0(S))throw new Error(mn(7));if(typeof S.type>"u")throw new Error(mn(8));if(typeof S.type!="string")throw new Error(mn(17));if(m)throw new Error(mn(9));try{m=!0,l=r(l,S)}finally{m=!1}return(s=d).forEach(C=>{C()}),S}function w(S){if(typeof S!="function")throw new Error(mn(10));r=S,b({type:Yd.REPLACE})}function j(){const S=y;return{subscribe(A){if(typeof A!="object"||A===null)throw new Error(mn(11));function C(){const k=A;k.next&&k.next(v())}return C(),{unsubscribe:S(C)}},[Yj](){return this}}}return b({type:Yd.INIT}),{dispatch:b,subscribe:y,getState:v,replaceReducer:w,[Yj]:j}}function n8(e){Object.keys(e).forEach(t=>{const n=e[t];if(typeof n(void 0,{type:Yd.INIT})>"u")throw new Error(mn(12));if(typeof n(void 0,{type:Yd.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(mn(13))})}function pO(e){const t=Object.keys(e),n={};for(let s=0;s"u")throw f&&f.type,new Error(mn(14));h[y]=j,m=m||j!==w}return m=m||r.length!==Object.keys(d).length,m?h:d}}function Gd(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,n)=>(...r)=>t(n(...r)))}function r8(...e){return t=>(n,r)=>{const l=t(n,r);let s=()=>{throw new Error(mn(15))};const d={getState:l.getState,dispatch:(m,...h)=>s(m,...h)},f=e.map(m=>m(d));return s=Gd(...f)(l.dispatch),{...l,dispatch:s}}}function vO(e){return i0(e)&&"type"in e&&typeof e.type=="string"}var yO=Symbol.for("immer-nothing"),Gj=Symbol.for("immer-draftable"),Nn=Symbol.for("immer-state");function _r(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Vn=Object,Ss=Vn.getPrototypeOf,Vd="constructor",qf="prototype",Jv="configurable",Fd="enumerable",Dd="writable",fc="value",Aa=e=>!!e&&!!e[Nn];function Or(e){var t;return e?gO(e)||Yf(e)||!!e[Gj]||!!((t=e[Vd])!=null&&t[Gj])||Gf(e)||Vf(e):!1}var a8=Vn[qf][Vd].toString(),Vj=new WeakMap;function gO(e){if(!e||!l0(e))return!1;const t=Ss(e);if(t===null||t===Vn[qf])return!0;const n=Vn.hasOwnProperty.call(t,Vd)&&t[Vd];if(n===Object)return!0;if(!hs(n))return!1;let r=Vj.get(n);return r===void 0&&(r=Function.toString.call(n),Vj.set(n,r)),r===a8}function Kf(e,t,n=!0){Ec(e)===0?(n?Reflect.ownKeys(e):Vn.keys(e)).forEach(l=>{t(l,e[l],e)}):e.forEach((r,l)=>t(l,r,e))}function Ec(e){const t=e[Nn];return t?t.type_:Yf(e)?1:Gf(e)?2:Vf(e)?3:0}var Fj=(e,t,n=Ec(e))=>n===2?e.has(t):Vn[qf].hasOwnProperty.call(e,t),ey=(e,t,n=Ec(e))=>n===2?e.get(t):e[t],Xd=(e,t,n,r=Ec(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function i8(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Yf=Array.isArray,Gf=e=>e instanceof Map,Vf=e=>e instanceof Set,l0=e=>typeof e=="object",hs=e=>typeof e=="function",sv=e=>typeof e=="boolean";function l8(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var ya=e=>e.copy_||e.base_,s0=e=>e.modified_?e.copy_:e.base_;function ty(e,t){if(Gf(e))return new Map(e);if(Vf(e))return new Set(e);if(Yf(e))return Array[qf].slice.call(e);const n=gO(e);if(t===!0||t==="class_only"&&!n){const r=Vn.getOwnPropertyDescriptors(e);delete r[Nn];let l=Reflect.ownKeys(r);for(let s=0;s1&&Vn.defineProperties(e,{set:md,add:md,clear:md,delete:md}),Vn.freeze(e),t&&Kf(e,(n,r)=>{o0(r,!0)},!1)),e}function s8(){_r(2)}var md={[fc]:s8};function Ff(e){return e===null||!l0(e)?!0:Vn.isFrozen(e)}var Wd="MapSet",ny="Patches",Xj="ArrayMethods",xO={};function ll(e){const t=xO[e];return t||_r(0,e),t}var Wj=e=>!!xO[e],mc,bO=()=>mc,o8=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Wj(Wd)?ll(Wd):void 0,arrayMethodsPlugin_:Wj(Xj)?ll(Xj):void 0});function Zj(e,t){t&&(e.patchPlugin_=ll(ny),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ry(e){ay(e),e.drafts_.forEach(c8),e.drafts_=null}function ay(e){e===mc&&(mc=e.parent_)}var Qj=e=>mc=o8(mc,e);function c8(e){const t=e[Nn];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Jj(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[Nn].modified_&&(ry(t),_r(4)),Or(e)&&(e=e_(t,e));const{patchPlugin_:l}=t;l&&l.generateReplacementPatches_(n[Nn].base_,e,t)}else e=e_(t,n);return u8(t,e,!0),ry(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==yO?e:void 0}function e_(e,t){if(Ff(t))return t;const n=t[Nn];if(!n)return Zd(t,e.handledSet_,e);if(!Xf(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);_O(n,e)}return n.copy_}function u8(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&o0(t,n)}function wO(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Xf=(e,t)=>e.scope_===t,d8=[];function jO(e,t,n,r){const l=ya(e),s=e.type_;if(r!==void 0&&ey(l,r,s)===t){Xd(l,r,n,s);return}if(!e.draftLocations_){const f=e.draftLocations_=new Map;Kf(l,(m,h)=>{if(Aa(h)){const v=f.get(h)||[];v.push(m),f.set(h,v)}})}const d=e.draftLocations_.get(t)??d8;for(const f of d)Xd(l,f,n,s)}function f8(e,t,n){e.callbacks_.push(function(l){var f;const s=t;if(!s||!Xf(s,l))return;(f=l.mapSetPlugin_)==null||f.fixSetContents(s);const d=s0(s);jO(e,s.draft_??s,d,n),_O(s,l)})}function _O(e,t){var r;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((r=e.assigned_)==null?void 0:r.size)??0)>0)){const{patchPlugin_:l}=t;if(l){const s=l.getPath(e);s&&l.generatePatches_(e,s,t)}wO(e)}}function m8(e,t,n){const{scope_:r}=e;if(Aa(n)){const l=n[Nn];Xf(l,r)&&l.callbacks_.push(function(){Pd(e);const d=s0(l);jO(e,n,d,t)})}else Or(n)&&e.callbacks_.push(function(){const s=ya(e);e.type_===3?s.has(n)&&Zd(n,r.handledSet_,r):ey(s,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Zd(ey(e.copy_,t,e.type_),r.handledSet_,r)})}function Zd(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Aa(e)||t.has(e)||!Or(e)||Ff(e)||(t.add(e),Kf(e,(r,l)=>{if(Aa(l)){const s=l[Nn];if(Xf(s,n)){const d=s0(s);Xd(e,r,d,e.type_),wO(s)}}else Or(l)&&Zd(l,t,n)})),e}function h8(e,t){const n=Yf(e),r={type_:n?1:0,scope_:t?t.scope_:bO(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let l=r,s=Qd;n&&(l=[r],s=hc);const{revoke:d,proxy:f}=Proxy.revocable(l,s);return r.draft_=f,r.revoke_=d,[f,r]}var Qd={get(e,t){if(t===Nn)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t=="string";if(r&&n!=null&&n.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const l=ya(e);if(!Fj(l,t,e.type_))return p8(e,l,t);const s=l[t];if(e.finalized_||!Or(s)||r&&e.operationMethod&&(n!=null&&n.isMutatingArrayMethod(e.operationMethod))&&l8(t))return s;if(s===ov(e.base_,t)){Pd(e);const d=e.type_===1?+t:t,f=ly(e.scope_,s,e,d);return e.copy_[d]=f}return s},has(e,t){return t in ya(e)},ownKeys(e){return Reflect.ownKeys(ya(e))},set(e,t,n){const r=NO(ya(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const l=ov(ya(e),t),s=l==null?void 0:l[Nn];if(s&&s.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(i8(n,l)&&(n!==void 0||Fj(e.base_,t,e.type_)))return!0;Pd(e),iy(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),m8(e,t,n)),!0},deleteProperty(e,t){return Pd(e),ov(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),iy(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=ya(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[Dd]:!0,[Jv]:e.type_!==1||t!=="length",[Fd]:r[Fd],[fc]:n[t]}},defineProperty(){_r(11)},getPrototypeOf(e){return Ss(e.base_)},setPrototypeOf(){_r(12)}},hc={};for(let e in Qd){let t=Qd[e];hc[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}hc.deleteProperty=function(e,t){return hc.set.call(this,e,t,void 0)};hc.set=function(e,t,n){return Qd.set.call(this,e[0],t,n,e[0])};function ov(e,t){const n=e[Nn];return(n?ya(n):e)[t]}function p8(e,t,n){var l;const r=NO(t,n);return r?fc in r?r[fc]:(l=r.get)==null?void 0:l.call(e.draft_):void 0}function NO(e,t){if(!(t in e))return;let n=Ss(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Ss(n)}}function iy(e){e.modified_||(e.modified_=!0,e.parent_&&iy(e.parent_))}function Pd(e){e.copy_||(e.assigned_=new Map,e.copy_=ty(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var v8=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,l)=>{if(hs(n)&&!hs(r)){const d=r;r=n;const f=this;return function(h=d,...v){return f.produce(h,y=>r.call(this,y,...v))}}hs(r)||_r(6),l!==void 0&&!hs(l)&&_r(7);let s;if(Or(n)){const d=Qj(this),f=ly(d,n,void 0);let m=!0;try{s=r(f),m=!1}finally{m?ry(d):ay(d)}return Zj(d,l),Jj(s,d)}else if(!n||!l0(n)){if(s=r(n),s===void 0&&(s=n),s===yO&&(s=void 0),this.autoFreeze_&&o0(s,!0),l){const d=[],f=[];ll(ny).generateReplacementPatches_(n,s,{patches_:d,inversePatches_:f}),l(d,f)}return s}else _r(1,n)},this.produceWithPatches=(n,r)=>{if(hs(n))return(f,...m)=>this.produceWithPatches(f,h=>n(h,...m));let l,s;return[this.produce(n,r,(f,m)=>{l=f,s=m}),l,s]},sv(t==null?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),sv(t==null?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),sv(t==null?void 0:t.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){Or(t)||_r(8),Aa(t)&&(t=mr(t));const n=Qj(this),r=ly(n,t,void 0);return r[Nn].isManual_=!0,ay(n),r}finishDraft(t,n){const r=t&&t[Nn];(!r||!r.isManual_)&&_r(9);const{scope_:l}=r;return Zj(l,n),Jj(void 0,l)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,n){let r;for(r=n.length-1;r>=0;r--){const s=n[r];if(s.path.length===0&&s.op==="replace"){t=s.value;break}}r>-1&&(n=n.slice(r+1));const l=ll(ny).applyPatches_;return Aa(t)?l(t,n):this.produce(t,s=>l(s,n))}};function ly(e,t,n,r){const[l,s]=Gf(t)?ll(Wd).proxyMap_(t,n):Vf(t)?ll(Wd).proxySet_(t,n):h8(t,n);return((n==null?void 0:n.scope_)??bO()).drafts_.push(l),s.callbacks_=(n==null?void 0:n.callbacks_)??[],s.key_=r,n&&r!==void 0?f8(n,s,r):s.callbacks_.push(function(m){var v;(v=m.mapSetPlugin_)==null||v.fixSetContents(s);const{patchPlugin_:h}=m;s.modified_&&h&&h.generatePatches_(s,[],m)}),l}function mr(e){return Aa(e)||_r(10,e),SO(e)}function SO(e){if(!Or(e)||Ff(e))return e;const t=e[Nn];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=ty(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=ty(e,!0);return Kf(n,(l,s)=>{Xd(n,l,SO(s))},r),t&&(t.finalized_=!1),n}var y8=new v8,AO=y8.produce;function OO(e){return({dispatch:n,getState:r})=>l=>s=>typeof s=="function"?s(n,r,e):l(s)}var g8=OO(),x8=OO,b8=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Gd:Gd.apply(null,arguments)};function Wn(e,t){function n(...r){if(t){let l=t(...r);if(!l)throw new Error(Fn(0));return{type:e,payload:l.payload,..."meta"in l&&{meta:l.meta},..."error"in l&&{error:l.error}}}return{type:e,payload:r[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=r=>vO(r)&&r.type===e,n}var EO=class nc extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,nc.prototype)}static get[Symbol.species](){return nc}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new nc(...t[0].concat(this)):new nc(...t.concat(this))}};function t_(e){return Or(e)?AO(e,()=>{}):e}function hd(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function w8(e){return typeof e=="boolean"}var j8=()=>function(t){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:l=!0,actionCreatorCheck:s=!0}=t??{};let d=new EO;return n&&(w8(n)?d.push(g8):d.push(x8(n.extraArgument))),d},kO="RTK_autoBatch",yt=()=>e=>({payload:e,meta:{[kO]:!0}}),n_=e=>t=>{setTimeout(t,e)},_8=(e,t)=>n=>{let r=!1;const l=()=>{r||(r=!0,cancelAnimationFrame(s),clearTimeout(d),n())},s=e(l),d=setTimeout(l,t)},CO=(e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let l=!0,s=!1,d=!1;const f=new Set,m=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?_8(window.requestAnimationFrame,100):n_(10):e.type==="callback"?e.queueNotification:n_(e.timeout),h=()=>{d=!1,s&&(s=!1,f.forEach(v=>v()))};return Object.assign({},r,{subscribe(v){const y=()=>l&&v(),b=r.subscribe(y);return f.add(v),()=>{b(),f.delete(v)}},dispatch(v){var y;try{return l=!((y=v==null?void 0:v.meta)!=null&&y[kO]),s=!l,s&&(d||(d=!0,m(h))),r.dispatch(v)}finally{l=!0}}})},N8=e=>function(n){const{autoBatch:r=!0}=n??{};let l=new EO(e);return r&&l.push(CO(typeof r=="object"?r:void 0)),l};function S8(e){const t=j8(),{reducer:n=void 0,middleware:r,devTools:l=!0,preloadedState:s=void 0,enhancers:d=void 0}=e||{};let f;if(typeof n=="function")f=n;else if(i0(n))f=pO(n);else throw new Error(Fn(1));let m;typeof r=="function"?m=r(t):m=t();let h=Gd;l&&(h=b8({trace:!1,...typeof l=="object"&&l}));const v=r8(...m),y=N8(v);let b=typeof d=="function"?d(y):y();const w=h(...b);return hO(f,s,w)}function TO(e){const t={},n=[];let r;const l={addCase(s,d){const f=typeof s=="string"?s:s.type;if(!f)throw new Error(Fn(28));if(f in t)throw new Error(Fn(29));return t[f]=d,l},addAsyncThunk(s,d){return d.pending&&(t[s.pending.type]=d.pending),d.rejected&&(t[s.rejected.type]=d.rejected),d.fulfilled&&(t[s.fulfilled.type]=d.fulfilled),d.settled&&n.push({matcher:s.settled,reducer:d.settled}),l},addMatcher(s,d){return n.push({matcher:s,reducer:d}),l},addDefaultCase(s){return r=s,l}};return e(l),[t,n,r]}function A8(e){return typeof e=="function"}function O8(e,t){let[n,r,l]=TO(t),s;if(A8(e))s=()=>t_(e());else{const f=t_(e);s=()=>f}function d(f=s(),m){let h=[n[m.type],...r.filter(({matcher:v})=>v(m)).map(({reducer:v})=>v)];return h.filter(v=>!!v).length===0&&(h=[l]),h.reduce((v,y)=>{if(y)if(Aa(v)){const w=y(v,m);return w===void 0?v:w}else{if(Or(v))return AO(v,b=>y(b,m));{const b=y(v,m);if(b===void 0){if(v===null)return v;throw Error("A case reducer on a non-draftable value must not return undefined")}return b}}return v},f)}return d.getInitialState=s,d}var E8="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",k8=(e=21)=>{let t="",n=e;for(;n--;)t+=E8[Math.random()*64|0];return t},C8=Symbol.for("rtk-slice-createasyncthunk");function T8(e,t){return`${e}/${t}`}function M8({creators:e}={}){var n;const t=(n=e==null?void 0:e.asyncThunk)==null?void 0:n[C8];return function(l){const{name:s,reducerPath:d=s}=l;if(!s)throw new Error(Fn(11));const f=(typeof l.reducers=="function"?l.reducers(P8()):l.reducers)||{},m=Object.keys(f),h={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},v={addCase(k,D){const E=typeof k=="string"?k:k.type;if(!E)throw new Error(Fn(12));if(E in h.sliceCaseReducersByType)throw new Error(Fn(13));return h.sliceCaseReducersByType[E]=D,v},addMatcher(k,D){return h.sliceMatchers.push({matcher:k,reducer:D}),v},exposeAction(k,D){return h.actionCreators[k]=D,v},exposeCaseReducer(k,D){return h.sliceCaseReducersByName[k]=D,v}};m.forEach(k=>{const D=f[k],E={reducerName:k,type:T8(s,k),createNotation:typeof l.reducers=="function"};I8(D)?R8(E,D,v,t):z8(E,D,v)});function y(){const[k={},D=[],E=void 0]=typeof l.extraReducers=="function"?TO(l.extraReducers):[l.extraReducers],$={...k,...h.sliceCaseReducersByType};return O8(l.initialState,U=>{for(let K in $)U.addCase(K,$[K]);for(let K of h.sliceMatchers)U.addMatcher(K.matcher,K.reducer);for(let K of D)U.addMatcher(K.matcher,K.reducer);E&&U.addDefaultCase(E)})}const b=k=>k,w=new Map,j=new WeakMap;let _;function S(k,D){return _||(_=y()),_(k,D)}function A(){return _||(_=y()),_.getInitialState()}function C(k,D=!1){function E(U){let K=U[k];return typeof K>"u"&&D&&(K=hd(j,E,A)),K}function $(U=b){const K=hd(w,D,()=>new WeakMap);return hd(K,U,()=>{const T={};for(const[re,Z]of Object.entries(l.selectors??{}))T[re]=D8(Z,U,()=>hd(j,U,A),D);return T})}return{reducerPath:k,getSelectors:$,get selectors(){return $(E)},selectSlice:E}}const M={name:s,reducer:S,actions:h.actionCreators,caseReducers:h.sliceCaseReducersByName,getInitialState:A,...C(d),injectInto(k,{reducerPath:D,...E}={}){const $=D??d;return k.inject({reducerPath:$,reducer:S},E),{...M,...C($,!0)}}};return M}}function D8(e,t,n,r){function l(s,...d){let f=t(s);return typeof f>"u"&&r&&(f=n()),e(f,...d)}return l.unwrapped=e,l}var bn=M8();function P8(){function e(t,n){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...n}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...n){return t(...n)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:n}},asyncThunk:e}}function z8({type:e,reducerName:t,createNotation:n},r,l){let s,d;if("reducer"in r){if(n&&!$8(r))throw new Error(Fn(17));s=r.reducer,d=r.prepare}else s=r;l.addCase(e,s).exposeCaseReducer(t,s).exposeAction(t,d?Wn(e,d):Wn(e))}function I8(e){return e._reducerDefinitionType==="asyncThunk"}function $8(e){return e._reducerDefinitionType==="reducerWithPrepare"}function R8({type:e,reducerName:t},n,r,l){if(!l)throw new Error(Fn(18));const{payloadCreator:s,fulfilled:d,pending:f,rejected:m,settled:h,options:v}=n,y=l(e,s,v);r.exposeAction(t,y),d&&r.addCase(y.fulfilled,d),f&&r.addCase(y.pending,f),m&&r.addCase(y.rejected,m),h&&r.addMatcher(y.settled,h),r.exposeCaseReducer(t,{fulfilled:d||pd,pending:f||pd,rejected:m||pd,settled:h||pd})}function pd(){}var L8="task",MO="listener",DO="completed",c0="cancelled",B8=`task-${c0}`,U8=`task-${DO}`,sy=`${MO}-${c0}`,H8=`${MO}-${DO}`,Wf=class{constructor(e){sd(this,"code");sd(this,"name","TaskAbortError");sd(this,"message");this.code=e,this.message=`${L8} ${c0} (reason: ${e})`}},u0=(e,t)=>{if(typeof e!="function")throw new TypeError(Fn(32))},Jd=()=>{},PO=(e,t=Jd)=>(e.catch(t),e),zO=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),Ji=e=>{if(e.aborted)throw new Wf(e.reason)};function IO(e,t){let n=Jd;return new Promise((r,l)=>{const s=()=>l(new Wf(e.reason));if(e.aborted){s();return}n=zO(e,s),t.finally(()=>n()).then(r,l)}).finally(()=>{n=Jd})}var q8=async(e,t)=>{try{return await Promise.resolve(),{status:"ok",value:await e()}}catch(n){return{status:n instanceof Wf?"cancelled":"rejected",error:n}}finally{t==null||t()}},ef=e=>t=>PO(IO(e,t).then(n=>(Ji(e),n))),$O=e=>{const t=ef(e);return n=>t(new Promise(r=>setTimeout(r,n)))},{assign:ws}=Object,r_={},Zf="listenerMiddleware",K8=(e,t)=>{const n=r=>zO(e,()=>r.abort(e.reason));return(r,l)=>{u0(r);const s=new AbortController;n(s);const d=q8(async()=>{Ji(e),Ji(s.signal);const f=await r({pause:ef(s.signal),delay:$O(s.signal),signal:s.signal});return Ji(s.signal),f},()=>s.abort(U8));return l!=null&&l.autoJoin&&t.push(d.catch(Jd)),{result:ef(e)(d),cancel(){s.abort(B8)}}}},Y8=(e,t)=>{const n=async(r,l)=>{Ji(t);let s=()=>{};const f=[new Promise((m,h)=>{let v=e({predicate:r,effect:(y,b)=>{b.unsubscribe(),m([y,b.getState(),b.getOriginalState()])}});s=()=>{v(),h()}})];l!=null&&f.push(new Promise(m=>setTimeout(m,l,null)));try{const m=await IO(t,Promise.race(f));return Ji(t),m}finally{s()}};return((r,l)=>PO(n(r,l)))},RO=e=>{let{type:t,actionCreator:n,matcher:r,predicate:l,effect:s}=e;if(t)l=Wn(t).match;else if(n)t=n.type,l=n.match;else if(r)l=r;else if(!l)throw new Error(Fn(21));return u0(s),{predicate:l,type:t,effect:s}},LO=ws(e=>{const{type:t,predicate:n,effect:r}=RO(e);return{id:k8(),effect:r,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(Fn(22))}}},{withTypes:()=>LO}),a_=(e,t)=>{const{type:n,effect:r,predicate:l}=RO(t);return Array.from(e.values()).find(s=>(typeof n=="string"?s.type===n:s.predicate===l)&&s.effect===r)},oy=e=>{e.pending.forEach(t=>{t.abort(sy)})},G8=(e,t)=>()=>{for(const n of t.keys())oy(n);e.clear()},i_=(e,t,n)=>{try{e(t,n)}catch(r){setTimeout(()=>{throw r},0)}},BO=ws(Wn(`${Zf}/add`),{withTypes:()=>BO}),V8=Wn(`${Zf}/removeAll`),UO=ws(Wn(`${Zf}/remove`),{withTypes:()=>UO}),F8=(...e)=>{console.error(`${Zf}/error`,...e)},kc=(e={})=>{const t=new Map,n=new Map,r=w=>{const j=n.get(w)??0;n.set(w,j+1)},l=w=>{const j=n.get(w)??1;j===1?n.delete(w):n.set(w,j-1)},{extra:s,onError:d=F8}=e;u0(d);const f=w=>(w.unsubscribe=()=>t.delete(w.id),t.set(w.id,w),j=>{w.unsubscribe(),j!=null&&j.cancelActive&&oy(w)}),m=(w=>{const j=a_(t,w)??LO(w);return f(j)});ws(m,{withTypes:()=>m});const h=w=>{const j=a_(t,w);return j&&(j.unsubscribe(),w.cancelActive&&oy(j)),!!j};ws(h,{withTypes:()=>h});const v=async(w,j,_,S)=>{const A=new AbortController,C=Y8(m,A.signal),M=[];try{w.pending.add(A),r(w),await Promise.resolve(w.effect(j,ws({},_,{getOriginalState:S,condition:(k,D)=>C(k,D).then(Boolean),take:C,delay:$O(A.signal),pause:ef(A.signal),extra:s,signal:A.signal,fork:K8(A.signal,M),unsubscribe:w.unsubscribe,subscribe:()=>{t.set(w.id,w)},cancelActiveListeners:()=>{w.pending.forEach((k,D,E)=>{k!==A&&(k.abort(sy),E.delete(k))})},cancel:()=>{A.abort(sy),w.pending.delete(A)},throwIfCancelled:()=>{Ji(A.signal)}})))}catch(k){k instanceof Wf||i_(d,k,{raisedBy:"effect"})}finally{await Promise.all(M),A.abort(H8),l(w),w.pending.delete(A)}},y=G8(t,n);return{middleware:w=>j=>_=>{if(!vO(_))return j(_);if(BO.match(_))return m(_.payload);if(V8.match(_)){y();return}if(UO.match(_))return h(_.payload);let S=w.getState();const A=()=>{if(S===r_)throw new Error(Fn(23));return S};let C;try{if(C=j(_),t.size>0){const M=w.getState(),k=Array.from(t.values());for(const D of k){let E=!1;try{E=D.predicate(_,M,S)}catch($){E=!1,i_(d,$,{raisedBy:"predicate"})}E&&v(D,_,w,A)}}}finally{S=r_}return C},startListening:m,stopListening:h,clearListeners:y}};function Fn(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var X8={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},HO=bn({name:"chartLayout",initialState:X8,reducers:{setLayout(e,t){e.layoutType=t.payload},setChartSize(e,t){e.width=t.payload.width,e.height=t.payload.height},setMargin(e,t){var n,r,l,s;e.margin.top=(n=t.payload.top)!==null&&n!==void 0?n:0,e.margin.right=(r=t.payload.right)!==null&&r!==void 0?r:0,e.margin.bottom=(l=t.payload.bottom)!==null&&l!==void 0?l:0,e.margin.left=(s=t.payload.left)!==null&&s!==void 0?s:0},setScale(e,t){e.scale=t.payload}}}),Qf=HO.actions,W8=Qf.setMargin,Z8=Qf.setLayout,Q8=Qf.setChartSize,J8=Qf.setScale,eI=HO.reducer;function qO(e,t,n){return Array.isArray(e)&&e&&t+n!==0?e.slice(t,n+1):e}function He(e){return Number.isFinite(e)}function Kr(e){return typeof e=="number"&&e>0&&Number.isFinite(e)}function l_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function vs(e){for(var t=1;t{if(t&&n){var r=n.width,l=n.height,s=t.align,d=t.verticalAlign,f=t.layout;if((f==="vertical"||f==="horizontal"&&d==="middle")&&s!=="center"&&je(e[s]))return vs(vs({},e),{},{[s]:e[s]+(r||0)});if((f==="horizontal"||f==="vertical"&&s==="center")&&d!=="middle"&&je(e[d]))return vs(vs({},e),{},{[d]:e[d]+(l||0)})}return e},Vr=(e,t)=>e==="horizontal"&&t==="xAxis"||e==="vertical"&&t==="yAxis"||e==="centric"&&t==="angleAxis"||e==="radial"&&t==="radiusAxis",KO=(e,t,n,r)=>{if(r)return e.map(f=>f.coordinate);var l,s,d=e.map(f=>(f.coordinate===t&&(l=!0),f.coordinate===n&&(s=!0),f.coordinate));return l||d.push(t),s||d.push(n),d},YO=(e,t,n)=>{if(!e)return null;var r=e.duplicateDomain,l=e.type,s=e.range,d=e.scale,f=e.realScaleType,m=e.isCategorical,h=e.categoricalDomain,v=e.tickCount,y=e.ticks,b=e.niceTicks,w=e.axisType;if(!d)return null;var j=f==="scaleBand"&&d.bandwidth?d.bandwidth()/2:2,_=l==="category"&&d.bandwidth?d.bandwidth()/j:0;if(_=w==="angleAxis"&&s&&s.length>=2?rn(s[0]-s[1])*2*_:_,y||b){var S=(y||b||[]).map((A,C)=>{var M=r?r.indexOf(A):A,k=d.map(M);return He(k)?{coordinate:k+_,value:A,offset:_,index:C}:null}).filter(Dn);return S}return m&&h?h.map((A,C)=>{var M=d.map(A);return He(M)?{coordinate:M+_,value:A,index:C,offset:_}:null}).filter(Dn):d.ticks&&v!=null?d.ticks(v).map((A,C)=>{var M=d.map(A);return He(M)?{coordinate:M+_,value:A,index:C,offset:_}:null}).filter(Dn):d.domain().map((A,C)=>{var M=d.map(A);return He(M)?{coordinate:M+_,value:r?r[A]:A,index:C,offset:_}:null}).filter(Dn)},iI=(e,t)=>{if(!t||t.length!==2||!je(t[0])||!je(t[1]))return e;var n=Math.min(t[0],t[1]),r=Math.max(t[0],t[1]),l=[e[0],e[1]];return(!je(e[0])||e[0]r)&&(l[1]=r),l[0]>r&&(l[0]=r),l[1]{var t,n=e.length;if(!(n<=0)){var r=(t=e[0])===null||t===void 0?void 0:t.length;if(!(r==null||r<=0))for(var l=0;l=0?(h[0]=s,s+=b,h[1]=s):(h[0]=d,d+=b,h[1]=d)}}}},sI=e=>{var t,n=e.length;if(!(n<=0)){var r=(t=e[0])===null||t===void 0?void 0:t.length;if(!(r==null||r<=0))for(var l=0;l=0?(m[0]=s,s+=h,m[1]=s):(m[0]=0,m[1]=0)}}}},oI={sign:lI,expand:l6,none:al,silhouette:s6,wiggle:o6,positive:sI},cI=(e,t,n)=>{var r,l=(r=oI[n])!==null&&r!==void 0?r:al,s=i6().keys(t).value((f,m)=>Number(rt(f,m,0))).order(Vv).offset(l),d=s(e);return d.forEach((f,m)=>{f.forEach((h,v)=>{var y=rt(e[v],t[m],0);Array.isArray(y)&&y.length===2&&je(y[0])&&je(y[1])&&(h[0]=y[0],h[1]=y[1])})}),d};function GO(e){return e==null?void 0:String(e)}function s_(e){var t=e.axis,n=e.ticks,r=e.bandSize,l=e.entry,s=e.index,d=e.dataKey;if(t.type==="category"){if(!t.allowDuplicatedCategory&&t.dataKey&&!Nt(l[t.dataKey])){var f=GA(n,"value",l[t.dataKey]);if(f)return f.coordinate+r/2}return n!=null&&n[s]?n[s].coordinate+r/2:null}var m=rt(l,Nt(d)?t.dataKey:d),h=t.scale.map(m);return je(h)?h:null}var o_=e=>{var t=e.axis,n=e.ticks,r=e.offset,l=e.bandSize,s=e.entry,d=e.index;if(t.type==="category")return n[d]?n[d].coordinate+r:null;var f=rt(s,t.dataKey,t.scale.domain()[d]);if(Nt(f))return null;var m=t.scale.map(f);return je(m)?m-l/2+r:null},uI=e=>{var t=e.numericAxis,n=t.scale.domain();if(t.type==="number"){var r=Math.min(n[0],n[1]),l=Math.max(n[0],n[1]);return r<=0&&l>=0?0:l<0?l:r}return n[0]},dI=e=>{var t=e.flat(2).filter(je);return[Math.min(...t),Math.max(...t)]},fI=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],mI=(e,t,n)=>{if(!(e==null||Object.keys(e).length===0))return fI(Object.keys(e).reduce((r,l)=>{var s=e[l];if(!s)return r;var d=s.stackedData,f=d.reduce((m,h)=>{var v=qO(h,t,n),y=dI(v);return!He(y[0])||!He(y[1])?m:[Math.min(m[0],y[0]),Math.max(m[1],y[1])]},[1/0,-1/0]);return[Math.min(f[0],r[0]),Math.max(f[1],r[1])]},[1/0,-1/0]))},c_=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,u_=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,As=(e,t,n)=>{if(e&&e.scale&&e.scale.bandwidth){var r=e.scale.bandwidth();if(!n||r>0)return r}if(e&&t&&t.length>=2){for(var l=Hf(t,v=>v.coordinate),s=1/0,d=1,f=l.length;d{if(t==="horizontal")return e.relativeX;if(t==="vertical")return e.relativeY},pI=(e,t)=>t==="centric"?e.angle:e.radius,Ca=e=>e.layout.width,Ta=e=>e.layout.height,vI=e=>e.layout.scale,VO=e=>e.layout.margin,Jf=X(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),em=X(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),FO="data-recharts-item-index",XO="data-recharts-item-id",Cc=60;function f_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function vd(e){for(var t=1;te.brush.height;function wI(e){var t=em(e);return t.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var l=typeof r.width=="number"?r.width:Cc;return n+l}return n},0)}function jI(e){var t=em(e);return t.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var l=typeof r.width=="number"?r.width:Cc;return n+l}return n},0)}function _I(e){var t=Jf(e);return t.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function NI(e){var t=Jf(e);return t.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var Wt=X([Ca,Ta,VO,bI,wI,jI,_I,NI,fO,Yz],(e,t,n,r,l,s,d,f,m,h)=>{var v={left:(n.left||0)+l,right:(n.right||0)+s},y={top:(n.top||0)+d,bottom:(n.bottom||0)+f},b=vd(vd({},y),v),w=b.bottom;b.bottom+=r,b=aI(b,m,h);var j=e-b.left-b.right,_=t-b.top-b.bottom;return vd(vd({brushBottom:w},b),{},{width:Math.max(j,0),height:Math.max(_,0)})}),SI=X(Wt,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),d0=X(Ca,Ta,(e,t)=>({x:0,y:0,width:e,height:t})),AI=x.createContext(null),wn=()=>x.useContext(AI)!=null,tm=e=>e.brush,nm=X([tm,Wt,VO],(e,t,n)=>({height:e.height,x:je(e.x)?e.x:t.left,y:je(e.y)?e.y:t.top+t.height+t.brushBottom-((n==null?void 0:n.bottom)||0),width:je(e.width)?e.width:t.width}));function OI(e,t,{signal:n,edges:r}={}){let l,s=null;const d=r!=null&&r.includes("leading"),f=r==null||r.includes("trailing"),m=()=>{s!==null&&(e.apply(l,s),l=void 0,s=null)},h=()=>{f&&m(),w()};let v=null;const y=()=>{v!=null&&clearTimeout(v),v=setTimeout(()=>{v=null,h()},t)},b=()=>{v!==null&&(clearTimeout(v),v=null)},w=()=>{b(),l=void 0,s=null},j=()=>{m()},_=function(...S){if(n!=null&&n.aborted)return;l=this,s=S;const A=v==null;y(),d&&A&&m()};return _.schedule=y,_.cancel=w,_.flush=j,n==null||n.addEventListener("abort",w,{once:!0}),_}function EI(e,t=0,n={}){typeof n!="object"&&(n={});const{leading:r=!1,trailing:l=!0,maxWait:s}=n,d=Array(2);r&&(d[0]="leading"),l&&(d[1]="trailing");let f,m=null;const h=OI(function(...b){f=e.apply(this,b),m=null},t,{edges:d}),v=function(...b){return s!=null&&(m===null&&(m=Date.now()),Date.now()-m>=s)?(f=e.apply(this,b),m=Date.now(),h.cancel(),h.schedule(),f):(h.apply(this,b),f)},y=()=>(h.flush(),f);return v.cancel=h.cancel,v.flush=y,v}function kI(e,t=0,n={}){const{leading:r=!0,trailing:l=!0}=n;return EI(e,t,{leading:r,maxWait:t,trailing:l})}var tf=function(t,n){for(var r=arguments.length,l=new Array(r>2?r-2:0),s=2;sl[d++]))}},Rr={width:"100%",height:"100%",debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},WO=(e,t,n)=>{var r=n.width,l=r===void 0?Rr.width:r,s=n.height,d=s===void 0?Rr.height:s,f=n.aspect,m=n.maxHeight,h=il(l)?e:Number(l),v=il(d)?t:Number(d);return f&&f>0&&(h?v=h/f:v&&(h=v*f),m&&v!=null&&v>m&&(v=m)),{calculatedWidth:h,calculatedHeight:v}},CI={width:0,height:0,overflow:"visible"},TI={width:0,overflowX:"visible"},MI={height:0,overflowY:"visible"},DI={},PI=e=>{var t=e.width,n=e.height,r=il(t),l=il(n);return r&&l?CI:r?TI:l?MI:DI};function zI(e){var t=e.width,n=e.height,r=e.aspect,l=t,s=n;return l===void 0&&s===void 0?(l=Rr.width,s=Rr.height):l===void 0?l=r&&r>0?void 0:Rr.width:s===void 0&&(s=r&&r>0?void 0:Rr.height),{width:l,height:s}}var II=["aspect","initialDimension","width","height","minWidth","minHeight","maxHeight","children","debounce","id","className","onResize","style"];function nf(){return nf=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=Array(t);n({width:n,height:r}),[n,r]);return VI(l)?x.createElement(ZO.Provider,{value:l},t):null}var f0=()=>x.useContext(ZO),FI=x.forwardRef((e,t)=>{var n=e.aspect,r=e.initialDimension,l=r===void 0?Rr.initialDimension:r,s=e.width,d=e.height,f=e.minWidth,m=f===void 0?Rr.minWidth:f,h=e.minHeight,v=e.maxHeight,y=e.children,b=e.debounce,w=b===void 0?Rr.debounce:b,j=e.id,_=e.className,S=e.onResize,A=e.style,C=A===void 0?{}:A,M=YI(e,II),k=x.useRef(null),D=x.useRef();D.current=S,x.useImperativeHandle(t,()=>k.current);var E=x.useState({containerWidth:l.width,containerHeight:l.height}),$=BI(E,2),U=$[0],K=$[1],T=x.useCallback((R,z)=>{K(G=>{var se=Math.round(R),ue=Math.round(z);return G.containerWidth===se&&G.containerHeight===ue?G:{containerWidth:se,containerHeight:ue}})},[]);x.useEffect(()=>{if(k.current==null||typeof ResizeObserver>"u")return hl;var R=P=>{var Q,ne=P[0];if(ne!=null){var I=ne.contentRect,he=I.width,be=I.height;T(he,be),(Q=D.current)===null||Q===void 0||Q.call(D,he,be)}};w>0&&(R=kI(R,w,{trailing:!0,leading:!1}));var z=new ResizeObserver(R),G=k.current.getBoundingClientRect(),se=G.width,ue=G.height;return T(se,ue),z.observe(k.current),()=>{z.disconnect()}},[T,w]);var re=U.containerWidth,Z=U.containerHeight;tf(!n||n>0,"The aspect(%s) must be greater than zero.",n);var pe=WO(re,Z,{width:s,height:d,aspect:n,maxHeight:v}),fe=pe.calculatedWidth,ce=pe.calculatedHeight;return tf(re<0||Z<0||fe!=null&&fe>0||ce!=null&&ce>0,`The width(%s) and height(%s) of chart should be greater than 0, - please check the style of container, or the props width(%s) and height(%s), - or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the - height and width.`,fe,ce,s,d,m,h,n),x.createElement("div",nf({id:j?"".concat(j):void 0,className:nt("recharts-responsive-container",_),style:h_(h_({},C),{},{width:s,height:d,minWidth:m,minHeight:h,maxHeight:v}),ref:k},M),x.createElement("div",{style:PI({width:s,height:d})},x.createElement(QO,{width:fe,height:ce},y)))}),yd=x.forwardRef((e,t)=>{var n=f0();if(Kr(n.width)&&Kr(n.height))return e.children;var r=zI({width:e.width,height:e.height,aspect:e.aspect}),l=r.width,s=r.height,d=WO(void 0,void 0,{width:l,height:s,aspect:e.aspect,maxHeight:e.maxHeight}),f=d.calculatedWidth,m=d.calculatedHeight;return je(f)&&je(m)?x.createElement(QO,{width:f,height:m},e.children):x.createElement(FI,nf({},e,{width:l,height:s,ref:t}))});function m0(e){if(e)return{x:e.x,y:e.y,upperWidth:"upperWidth"in e?e.upperWidth:e.width,lowerWidth:"lowerWidth"in e?e.lowerWidth:e.width,width:e.width,height:e.height}}var rm=()=>{var e,t=wn(),n=Ne(SI),r=Ne(nm),l=(e=Ne(tm))===null||e===void 0?void 0:e.padding;return!t||!r||!l?n:{width:r.width-l.left-l.right,height:r.height-l.top-l.bottom,x:l.left,y:l.top}},XI={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},JO=()=>{var e;return(e=Ne(Wt))!==null&&e!==void 0?e:XI},h0=()=>Ne(Ca),p0=()=>Ne(Ta),WI=()=>Ne(e=>e.layout.margin),Ze=e=>e.layout.layoutType,pl=()=>Ne(Ze),v0=()=>{var e=pl();if(e==="horizontal"||e==="vertical")return e},y0=e=>{var t=e.layout.layoutType;if(t==="centric"||t==="radial")return t},ZI=()=>Ne(y0),QI=()=>{var e=pl();return e!==void 0},Tc=e=>{var t=dt(),n=wn(),r=e.width,l=e.height,s=f0(),d=r,f=l;return s&&(d=s.width>0?s.width:r,f=s.height>0?s.height:l),x.useEffect(()=>{!n&&Kr(d)&&Kr(f)&&t(Q8({width:d,height:f}))},[t,n,d,f]),null},eE=Symbol.for("immer-nothing"),v_=Symbol.for("immer-draftable"),Zn=Symbol.for("immer-state");function Nr(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var pc=Object.getPrototypeOf;function Os(e){return!!e&&!!e[Zn]}function sl(e){var t;return e?tE(e)||Array.isArray(e)||!!e[v_]||!!((t=e.constructor)!=null&&t[v_])||Mc(e)||im(e):!1}var JI=Object.prototype.constructor.toString(),y_=new WeakMap;function tE(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let r=y_.get(n);return r===void 0&&(r=Function.toString.call(n),y_.set(n,r)),r===JI}function rf(e,t,n=!0){am(e)===0?(n?Reflect.ownKeys(e):Object.keys(e)).forEach(l=>{t(l,e[l],e)}):e.forEach((r,l)=>t(l,r,e))}function am(e){const t=e[Zn];return t?t.type_:Array.isArray(e)?1:Mc(e)?2:im(e)?3:0}function cy(e,t){return am(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function nE(e,t,n){const r=am(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function e$(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Mc(e){return e instanceof Map}function im(e){return e instanceof Set}function Yi(e){return e.copy_||e.base_}function uy(e,t){if(Mc(e))return new Map(e);if(im(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=tE(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[Zn];let l=Reflect.ownKeys(r);for(let s=0;s1&&Object.defineProperties(e,{set:gd,add:gd,clear:gd,delete:gd}),Object.freeze(e),t&&Object.values(e).forEach(n=>g0(n,!0))),e}function t$(){Nr(2)}var gd={value:t$};function lm(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var n$={};function ol(e){const t=n$[e];return t||Nr(0,e),t}var vc;function rE(){return vc}function r$(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function g_(e,t){t&&(ol("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function dy(e){fy(e),e.drafts_.forEach(a$),e.drafts_=null}function fy(e){e===vc&&(vc=e.parent_)}function x_(e){return vc=r$(vc,e)}function a$(e){const t=e[Zn];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function b_(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[Zn].modified_&&(dy(t),Nr(4)),sl(e)&&(e=af(t,e),t.parent_||lf(t,e)),t.patches_&&ol("Patches").generateReplacementPatches_(n[Zn].base_,e,t.patches_,t.inversePatches_)):e=af(t,n,[]),dy(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==eE?e:void 0}function af(e,t,n){if(lm(t))return t;const r=e.immer_.shouldUseStrictIteration(),l=t[Zn];if(!l)return rf(t,(s,d)=>w_(e,l,t,s,d,n),r),t;if(l.scope_!==e)return t;if(!l.modified_)return lf(e,l.base_,!0),l.base_;if(!l.finalized_){l.finalized_=!0,l.scope_.unfinalizedDrafts_--;const s=l.copy_;let d=s,f=!1;l.type_===3&&(d=new Set(s),s.clear(),f=!0),rf(d,(m,h)=>w_(e,l,s,m,h,n,f),r),lf(e,s,!1),n&&e.patches_&&ol("Patches").generatePatches_(l,n,e.patches_,e.inversePatches_)}return l.copy_}function w_(e,t,n,r,l,s,d){if(l==null||typeof l!="object"&&!d)return;const f=lm(l);if(!(f&&!d)){if(Os(l)){const m=s&&t&&t.type_!==3&&!cy(t.assigned_,r)?s.concat(r):void 0,h=af(e,l,m);if(nE(n,r,h),Os(h))e.canAutoFreeze_=!1;else return}else d&&n.add(l);if(sl(l)&&!f){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[r]===l&&f)return;af(e,l),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&(Mc(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&lf(e,l)}}}function lf(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&g0(t,n)}function i$(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:rE(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let l=r,s=x0;n&&(l=[r],s=yc);const{revoke:d,proxy:f}=Proxy.revocable(l,s);return r.draft_=f,r.revoke_=d,f}var x0={get(e,t){if(t===Zn)return e;const n=Yi(e);if(!cy(n,t))return l$(e,n,t);const r=n[t];return e.finalized_||!sl(r)?r:r===cv(e.base_,t)?(uv(e),e.copy_[t]=hy(r,e)):r},has(e,t){return t in Yi(e)},ownKeys(e){return Reflect.ownKeys(Yi(e))},set(e,t,n){const r=aE(Yi(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const l=cv(Yi(e),t),s=l==null?void 0:l[Zn];if(s&&s.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(e$(n,l)&&(n!==void 0||cy(e.base_,t)))return!0;uv(e),my(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return cv(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,uv(e),my(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Yi(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){Nr(11)},getPrototypeOf(e){return pc(e.base_)},setPrototypeOf(){Nr(12)}},yc={};rf(x0,(e,t)=>{yc[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});yc.deleteProperty=function(e,t){return yc.set.call(this,e,t,void 0)};yc.set=function(e,t,n){return x0.set.call(this,e[0],t,n,e[0])};function cv(e,t){const n=e[Zn];return(n?Yi(n):e)[t]}function l$(e,t,n){var l;const r=aE(t,n);return r?"value"in r?r.value:(l=r.get)==null?void 0:l.call(e.draft_):void 0}function aE(e,t){if(!(t in e))return;let n=pc(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=pc(n)}}function my(e){e.modified_||(e.modified_=!0,e.parent_&&my(e.parent_))}function uv(e){e.copy_||(e.copy_=uy(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var s$=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const s=n;n=t;const d=this;return function(m=s,...h){return d.produce(m,v=>n.call(this,v,...h))}}typeof n!="function"&&Nr(6),r!==void 0&&typeof r!="function"&&Nr(7);let l;if(sl(t)){const s=x_(this),d=hy(t,void 0);let f=!0;try{l=n(d),f=!1}finally{f?dy(s):fy(s)}return g_(s,r),b_(l,s)}else if(!t||typeof t!="object"){if(l=n(t),l===void 0&&(l=t),l===eE&&(l=void 0),this.autoFreeze_&&g0(l,!0),r){const s=[],d=[];ol("Patches").generateReplacementPatches_(t,l,s,d),r(s,d)}return l}else Nr(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(d,...f)=>this.produceWithPatches(d,m=>t(m,...f));let r,l;return[this.produce(t,n,(d,f)=>{r=d,l=f}),r,l]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof(e==null?void 0:e.useStrictIteration)=="boolean"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){sl(e)||Nr(8),Os(e)&&(e=o$(e));const t=x_(this),n=hy(e,void 0);return n[Zn].isManual_=!0,fy(t),n}finishDraft(e,t){const n=e&&e[Zn];(!n||!n.isManual_)&&Nr(9);const{scope_:r}=n;return g_(r,t),b_(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const l=t[n];if(l.path.length===0&&l.op==="replace"){e=l.value;break}}n>-1&&(t=t.slice(n+1));const r=ol("Patches").applyPatches_;return Os(e)?r(e,t):this.produce(e,l=>r(l,t))}};function hy(e,t){const n=Mc(e)?ol("MapSet").proxyMap_(e,t):im(e)?ol("MapSet").proxySet_(e,t):i$(e,t);return(t?t.scope_:rE()).drafts_.push(n),n}function o$(e){return Os(e)||Nr(10,e),iE(e)}function iE(e){if(!sl(e)||lm(e))return e;const t=e[Zn];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=uy(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=uy(e,!0);return rf(n,(l,s)=>{nE(n,l,iE(s))},r),t&&(t.finalized_=!1),n}var c$=new s$;c$.produce;var u$={settings:{layout:"horizontal",align:"center",verticalAlign:"bottom",itemSorter:"value"},size:{width:0,height:0},payload:[]},lE=bn({name:"legend",initialState:u$,reducers:{setLegendSize(e,t){e.size.width=t.payload.width,e.size.height=t.payload.height},setLegendSettings(e,t){e.settings.align=t.payload.align,e.settings.layout=t.payload.layout,e.settings.verticalAlign=t.payload.verticalAlign,e.settings.itemSorter=t.payload.itemSorter},addLegendPayload:{reducer(e,t){e.payload.push(t.payload)},prepare:yt()},replaceLegendPayload:{reducer(e,t){var n=t.payload,r=n.prev,l=n.next,s=mr(e).payload.indexOf(r);s>-1&&(e.payload[s]=l)},prepare:yt()},removeLegendPayload:{reducer(e,t){var n=mr(e).payload.indexOf(t.payload);n>-1&&e.payload.splice(n,1)},prepare:yt()}}}),Dc=lE.actions,j_=Dc.setLegendSize,d$=Dc.setLegendSettings,sE=Dc.addLegendPayload,oE=Dc.replaceLegendPayload,cE=Dc.removeLegendPayload,f$=lE.reducer,dv={exports:{}},fv={};/** - * @license React - * use-sync-external-store-with-selector.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var __;function m$(){if(__)return fv;__=1;var e=zs();function t(m,h){return m===h&&(m!==0||1/m===1/h)||m!==m&&h!==h}var n=typeof Object.is=="function"?Object.is:t,r=e.useSyncExternalStore,l=e.useRef,s=e.useEffect,d=e.useMemo,f=e.useDebugValue;return fv.useSyncExternalStoreWithSelector=function(m,h,v,y,b){var w=l(null);if(w.current===null){var j={hasValue:!1,value:null};w.current=j}else j=w.current;w=d(function(){function S(D){if(!A){if(A=!0,C=D,D=y(D),b!==void 0&&j.hasValue){var E=j.value;if(b(E,D))return M=E}return M=D}if(E=M,n(C,D))return E;var $=y(D);return b!==void 0&&b(E,$)?(C=D,E):(C=D,M=$)}var A=!1,C,M,k=v===void 0?null:v;return[function(){return S(h())},k===null?void 0:function(){return S(k())}]},[h,v,y,b]);var _=r(m,w[0],w[1]);return s(function(){j.hasValue=!0,j.value=_},[_]),f(_),_},fv}var N_;function h$(){return N_||(N_=1,dv.exports=m$()),dv.exports}h$();function p$(e){e()}function v$(){let e=null,t=null;return{clear(){e=null,t=null},notify(){p$(()=>{let n=e;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=e;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const l=t={callback:n,next:null,prev:t};return l.prev?l.prev.next=l:e=l,function(){!r||e===null||(r=!1,l.next?l.next.prev=l.prev:t=l.prev,l.prev?l.prev.next=l.next:e=l.next)}}}}var S_={notify(){},get:()=>[]};function y$(e,t){let n,r=S_,l=0,s=!1;function d(_){v();const S=r.subscribe(_);let A=!1;return()=>{A||(A=!0,S(),y())}}function f(){r.notify()}function m(){j.onStateChange&&j.onStateChange()}function h(){return s}function v(){l++,n||(n=e.subscribe(m),r=v$())}function y(){l--,n&&l===0&&(n(),n=void 0,r.clear(),r=S_)}function b(){s||(s=!0,v())}function w(){s&&(s=!1,y())}const j={addNestedSub:d,notifyNestedSubs:f,handleChangeWrapper:m,isSubscribed:h,trySubscribe:b,tryUnsubscribe:w,getListeners:()=>r};return j}var g$=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",x$=g$(),b$=()=>typeof navigator<"u"&&navigator.product==="ReactNative",w$=b$(),j$=()=>x$||w$?x.useLayoutEffect:x.useEffect,_$=j$();function A_(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function N$(e,t){if(A_(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let l=0;l{const m=y$(l);return{store:l,subscription:m,getServerState:r?()=>r:void 0}},[l,r]),d=x.useMemo(()=>l.getState(),[l]);_$(()=>{const{subscription:m}=s;return m.onStateChange=m.notifyNestedSubs,m.trySubscribe(),d!==l.getState()&&m.notifyNestedSubs(),()=>{m.tryUnsubscribe(),m.onStateChange=void 0}},[s,d]);const f=n||A$;return x.createElement(f.Provider,{value:s},t)}var E$=O$,k$=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle","radius","throttledEvents"]);function C$(e,t){return e==null&&t==null?!0:typeof e=="number"&&typeof t=="number"?e===t||e!==e&&t!==t:e===t}function $s(e,t){var n=new Set([...Object.keys(e),...Object.keys(t)]);for(var r of n)if(k$.has(r)){if(e[r]==null&&t[r]==null)continue;if(!N$(e[r],t[r]))return!1}else if(!C$(e[r],t[r]))return!1;return!0}var T$=["contextPayload"];function py(){return py=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=Array(t);n{s(d$({align:t,layout:n,verticalAlign:r,itemSorter:l}))},[s,t,n,r,l]),null}function G$(e){var t=e.width,n=e.height,r=dt();return x.useLayoutEffect(()=>{r(j_({width:t,height:n}))},[r,t,n]),x.useLayoutEffect(()=>()=>{r(j_({width:0,height:0}))},[r]),null}function V$(e,t,n,r){return e==="vertical"&&t!=null?{height:t}:e==="horizontal"?{width:n||r}:null}var F$={align:"center",iconSize:14,inactiveColor:"#ccc",itemSorter:"value",labelStyle:{},layout:"horizontal",verticalAlign:"bottom"};function X$(e){var t=an(e,F$),n=Fz(),r=kP(),l=WI(),s=t.width,d=t.height,f=t.wrapperStyle,m=t.portal,h=mO([n]),v=M$(h,2),y=v[0],b=v[1],w=h0(),j=p0();if(w==null||j==null)return null;var _=w-((l==null?void 0:l.left)||0)-((l==null?void 0:l.right)||0),S=V$(t.layout,d,s,_),A=m?f:Es(Es({position:"absolute",width:(S==null?void 0:S.width)||s||"auto",height:(S==null?void 0:S.height)||d||"auto"},K$(f,t,l,w,j,y)),f),C=m??r;if(C==null||n==null)return null;var M=x.createElement("div",{className:"recharts-legend-wrapper",style:A,ref:b},x.createElement(Y$,{layout:t.layout,align:t.align,verticalAlign:t.verticalAlign,itemSorter:t.itemSorter}),!m&&x.createElement(G$,{width:y.width,height:y.height}),x.createElement(q$,py({},t,S,{margin:l,chartWidth:w,chartHeight:j,contextPayload:n})));return It.createPortal(M,C)}var uE=x.memo(X$,$s);uE.displayName="Legend";function vy(){return vy=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=Array(t);n{var t=e.separator,n=t===void 0?is.separator:t,r=e.contentStyle,l=e.itemStyle,s=e.labelStyle,d=s===void 0?is.labelStyle:s,f=e.payload,m=e.formatter,h=e.itemSorter,v=e.wrapperClassName,y=e.labelClassName,b=e.label,w=e.labelFormatter,j=e.accessibilityLayer,_=j===void 0?is.accessibilityLayer:j,S=()=>{if(f&&f.length){var U={padding:0,margin:0},K=iR(f,h),T=K.map((re,Z)=>{if(!re||re.type==="none")return null;var pe=re.formatter||m||aR,fe=re.value,ce=re.name,R=fe,z=ce;if(pe){var G=pe(fe,ce,re,Z,f);if(Array.isArray(G)){var se=J$(G,2);R=se[0],z=se[1]}else if(G!=null)R=G;else return null}var ue=Ho(Ho({},is.itemStyle),{},{color:re.color||is.itemStyle.color},l);return x.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(Z),style:ue},qr(z)?x.createElement("span",{className:"recharts-tooltip-item-name"},z):null,qr(z)?x.createElement("span",{className:"recharts-tooltip-item-separator"},n):null,x.createElement("span",{className:"recharts-tooltip-item-value"},R),x.createElement("span",{className:"recharts-tooltip-item-unit"},re.unit||""))});return x.createElement("ul",{className:"recharts-tooltip-item-list",style:U},T)}return null},A=Ho(Ho({},is.contentStyle),r),C=Ho({margin:0},d),M=!Nt(b),k=M?b:"",D=nt("recharts-default-tooltip",v),E=nt("recharts-tooltip-label",y);M&&w&&f!==void 0&&f!==null&&(k=w(b,f));var $=_?{role:"status","aria-live":"assertive"}:{};return x.createElement("div",vy({className:D,style:A},$),x.createElement("p",{className:E,style:C},x.isValidElement(k)?k:"".concat(k)),S())},qo="recharts-tooltip-wrapper",sR={visibility:"hidden"};function oR(e){var t=e.coordinate,n=e.translateX,r=e.translateY;return nt(qo,{["".concat(qo,"-right")]:je(n)&&t&&je(t.x)&&n>=t.x,["".concat(qo,"-left")]:je(n)&&t&&je(t.x)&&n=t.y,["".concat(qo,"-top")]:je(r)&&t&&je(t.y)&&r0?l:0),y=n[r]+l;if(t[r])return d[r]?v:y;var b=m[r];if(b==null)return 0;if(d[r]){var w=v,j=b;return wS?Math.max(v,b):Math.max(y,b)}function cR(e){var t=e.translateX,n=e.translateY,r=e.useTranslate3d;return{transform:r?"translate3d(".concat(t,"px, ").concat(n,"px, 0)"):"translate(".concat(t,"px, ").concat(n,"px)")}}function uR(e){var t=e.allowEscapeViewBox,n=e.coordinate,r=e.offsetTop,l=e.offsetLeft,s=e.position,d=e.reverseDirection,f=e.tooltipBox,m=e.useTranslate3d,h=e.viewBox,v,y,b;return f.height>0&&f.width>0&&n?(y=T_({allowEscapeViewBox:t,coordinate:n,key:"x",offset:l,position:s,reverseDirection:d,tooltipDimension:f.width,viewBox:h,viewBoxDimension:h.width}),b=T_({allowEscapeViewBox:t,coordinate:n,key:"y",offset:r,position:s,reverseDirection:d,tooltipDimension:f.height,viewBox:h,viewBoxDimension:h.height}),v=cR({translateX:y,translateY:b,useTranslate3d:m})):v=sR,{cssProperties:v,cssClasses:oR({translateX:y,translateY:b,coordinate:n})}}var dR=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Pc={isSsr:dR()};function fR(e,t){return vR(e)||pR(e,t)||hR(e,t)||mR()}function mR(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hR(e,t){if(e){if(typeof e=="string")return M_(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?M_(e,t):void 0}}function M_(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);nPc.isSsr||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches),t=fR(e,2),n=t[0],r=t[1];return x.useEffect(()=>{if(window.matchMedia){var l=window.matchMedia("(prefers-reduced-motion: reduce)"),s=()=>{r(l.matches)};return l.addEventListener("change",s),()=>{l.removeEventListener("change",s)}}},[]),n}function D_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function ls(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=Array(t);n({dismissed:!1,dismissedAtCoordinate:{x:0,y:0}})),h=bR(m,2),v=h[0],y=h[1];x.useEffect(()=>{var A=C=>{if(C.key==="Escape"){var M,k,D,E;y({dismissed:!0,dismissedAtCoordinate:{x:(M=(k=e.coordinate)===null||k===void 0?void 0:k.x)!==null&&M!==void 0?M:0,y:(D=(E=e.coordinate)===null||E===void 0?void 0:E.y)!==null&&D!==void 0?D:0}})}};return document.addEventListener("keydown",A),()=>{document.removeEventListener("keydown",A)}},[(t=e.coordinate)===null||t===void 0?void 0:t.x,(n=e.coordinate)===null||n===void 0?void 0:n.y]),v.dismissed&&(((r=(l=e.coordinate)===null||l===void 0?void 0:l.x)!==null&&r!==void 0?r:0)!==v.dismissedAtCoordinate.x||((s=(d=e.coordinate)===null||d===void 0?void 0:d.y)!==null&&s!==void 0?s:0)!==v.dismissedAtCoordinate.y)&&y(ls(ls({},v),{},{dismissed:!1}));var b=uR({allowEscapeViewBox:e.allowEscapeViewBox,coordinate:e.coordinate,offsetLeft:typeof e.offset=="number"?e.offset:e.offset.x,offsetTop:typeof e.offset=="number"?e.offset:e.offset.y,position:e.position,reverseDirection:e.reverseDirection,tooltipBox:{height:e.lastBoundingBox.height,width:e.lastBoundingBox.width},useTranslate3d:e.useTranslate3d,viewBox:e.viewBox}),w=b.cssClasses,j=b.cssProperties,_=e.hasPortalFromProps?{}:ls(ls({transition:SR({prefersReducedMotion:f,isAnimationActive:e.isAnimationActive,active:e.active,animationDuration:e.animationDuration,animationEasing:e.animationEasing})},j),{},{pointerEvents:"none",position:"absolute",top:0,left:0}),S=ls(ls({},_),{},{visibility:!v.dismissed&&e.active&&e.hasPayload?"visible":"hidden"},e.wrapperStyle);return x.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:w,style:S,ref:e.innerRef},e.children)}var OR=x.memo(AR),fE=()=>{var e;return(e=Ne(t=>t.rootProps.accessibilityLayer))!==null&&e!==void 0?e:!0};function yy(){return yy=Object.assign?Object.assign.bind():function(e){for(var t=1;tHe(e.x)&&He(e.y),R_=e=>e.base!=null&&sf(e.base)&&sf(e),Ko=e=>e.x,Yo=e=>e.y,TR=(e,t)=>{if(typeof e=="function")return e;var n="curve".concat(Ac(e));if((n==="curveMonotone"||n==="curveBump")&&t){var r=$_["".concat(n).concat(t==="vertical"?"Y":"X")];if(r)return r}return $_[n]||Bf},L_={connectNulls:!1,type:"linear"},MR=e=>{var t=e.type,n=t===void 0?L_.type:t,r=e.points,l=r===void 0?[]:r,s=e.baseLine,d=e.layout,f=e.connectNulls,m=f===void 0?L_.connectNulls:f,h=TR(n,d),v=m?l.filter(sf):l;if(Array.isArray(s)){var y,b=l.map((A,C)=>I_(I_({},A),{},{base:s[C]}));d==="vertical"?y=ud().y(Yo).x1(Ko).x0(A=>A.base.x):y=ud().x(Ko).y1(Yo).y0(A=>A.base.y);var w=y.defined(R_).curve(h),j=m?b.filter(R_):b;return w(j)}var _;d==="vertical"&&je(s)?_=ud().y(Yo).x1(Ko).x0(s):je(s)?_=ud().x(Ko).y1(Yo).y0(s):_=MA().x(Ko).y(Yo);var S=_.defined(sf).curve(h);return S(v)},lc=e=>{var t=e.className,n=e.points,r=e.path,l=e.pathRef,s=pl();if((!n||!n.length)&&!r)return null;var d={type:e.type,points:e.points,baseLine:e.baseLine,layout:e.layout||s,connectNulls:e.connectNulls},f=n&&n.length?MR(d):r;return x.createElement("path",yy({},zn(e),n0(e),{className:nt("recharts-curve",t),d:f===null?void 0:f,ref:l}))},DR=["x","y","top","left","width","height","className"];function gy(){return gy=Object.assign?Object.assign.bind():function(e){for(var t=1;t"M".concat(e,",").concat(l,"v").concat(r,"M").concat(s,",").concat(t,"h").concat(n),UR=e=>{var t=e.x,n=t===void 0?0:t,r=e.y,l=r===void 0?0:r,s=e.top,d=s===void 0?0:s,f=e.left,m=f===void 0?0:f,h=e.width,v=h===void 0?0:h,y=e.height,b=y===void 0?0:y,w=e.className,j=RR(e,DR),_=PR({x:n,y:l,top:d,left:m,width:v,height:b},j);return!je(n)||!je(l)||!je(v)||!je(b)||!je(d)||!je(m)?null:x.createElement("path",gy({},Xn(_),{className:nt("recharts-cross",w),d:BR(n,l,v,b,d,m)}))};function HR(e,t,n,r){var l=r/2;return{stroke:"none",fill:"#ccc",x:e==="horizontal"?t.x-l:n.left+.5,y:e==="horizontal"?n.top+.5:t.y-l,width:e==="horizontal"?r:n.width-1,height:e==="horizontal"?n.height-1:r}}var of=1e-4,mE=(e,t)=>[0,3*e,3*t-6*e,3*e-3*t+1],hE=(e,t)=>e.map((n,r)=>n*t**r).reduce((n,r)=>n+r),U_=(e,t)=>n=>{var r=mE(e,t);return hE(r,n)},qR=(e,t)=>n=>{var r=mE(e,t),l=[...r.map((s,d)=>s*d).slice(1),0];return hE(l,n)},KR=e=>{var t,n=e.split("(");if(n.length!==2||n[0]!=="cubic-bezier")return null;var r=(t=n[1])===null||t===void 0||(t=t.split(")")[0])===null||t===void 0?void 0:t.split(",");if(r==null||r.length!==4)return null;var l=r.map(s=>parseFloat(s));return[l[0],l[1],l[2],l[3]]},YR=function(){for(var t=arguments.length,n=new Array(t),r=0;r{var l=U_(e,n),s=U_(t,r),d=qR(e,n),f=h=>h>1?1:h<0?0:h,m=h=>{for(var v=h>1?1:h,y=v,b=0;b<8;++b){var w=l(y)-v,j=d(y);if(Math.abs(w-v)0&&arguments[0]!==void 0?arguments[0]:{},n=t.stiff,r=n===void 0?100:n,l=t.damping,s=l===void 0?8:l,d=t.dt,f=d===void 0?16.67:d,m=1,h=[0],v=0,y=0,b=1e4,w=0;w{var C,M,k;if(A<=0)return 0;if(A>=1)return m;var D=A*S,E=Math.floor(D),$=D-E;return((C=h[E])!==null&&C!==void 0?C:0)+(((M=h[E+1])!==null&&M!==void 0?M:0)-((k=h[E])!==null&&k!==void 0?k:0))*$}},FR=e=>{if(typeof e=="string")switch(e){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return H_(e);case"spring":return VR();default:if(e.split("(")[0]==="cubic-bezier")return H_(e)}return typeof e=="function"?e:null},XR=(e,t,n)=>{var r,l=s=>{var d=t.tick(s);if(t.getState()==="active"){if(n(t.getInterpolated()),t.getProgress()===1){t.complete(),r=void 0;return}r=e.setTimeout(l,d);return}r=e.setTimeout(l,d)};return r=e.setTimeout(l,0),()=>{var s;return(s=r)===null||s===void 0?void 0:s()}},pE=x.createContext(XR);pE.Provider;function WR(e){var t=x.useContext(pE);return x.useMemo(()=>e??t,[e,t])}function ZR(e,t,n){return(t=QR(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function QR(e){var t=JR(e,"string");return typeof t=="symbol"?t:t+""}function JR(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var q_="init",K_="pending",Y_="active",e7="completed";function pv(e){return Math.max(0,e)}class t7{getAnimationStartedTime(){return this.animationStartedTime}getBeginStartedTime(){return this.beginStartedTime}constructor(t){var n;ZR(this,"state",q_),this.animationId=t.animationId,this.onAnimationEnd=t.onAnimationEnd,this.animationDuration=pv(t.animationDuration),this.animationBegin=pv(t.animationBegin),this.progress=0,this.from=t.from,this.to=t.to,this.easing=t.easing,(n=t.onAnimationStart)===null||n===void 0||n.call(t)}getState(){return this.state}getEasing(){return this.easing}getAnimationDuration(){return this.animationDuration}tick(t){if(this.getState()===q_)return this.state=K_,this.beginStartedTime=t,this.animationBegin;if(this.getState()===K_){if(this.beginStartedTime==null)throw new Error;var n=t-this.beginStartedTime;return n>=this.animationBegin?(this.state=Y_,this.animationStartedTime=t,this.nextAnimationUpdate(0)):pv(this.animationBegin-n)}if(this.getState()===Y_){if(this.animationStartedTime==null)throw new Error;var r=t-this.animationStartedTime;return this.setProgress(r/this.animationDuration),this.nextAnimationUpdate(r)}return 0}setProgress(t){this.progress=Math.min(1,Math.max(0,t))}getProgress(){return this.progress}complete(){if(this.progress=1,this.state==="active"){var t;(t=this.onAnimationEnd)===null||t===void 0||t.call(this)}this.state=e7}getFrom(){return this.from}getTo(){return this.to}getAnimationId(){return this.animationId}getAnimationBegin(){return this.animationBegin}}class n7 extends t7{nextAnimationUpdate(){return 0}getInterpolated(){return this.easing(Et(this.getFrom(),this.getTo(),this.getProgress()))}}class r7{setTimeout(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),l=null,s=d=>{d-r>=n?t(d):l=requestAnimationFrame(s)};return l=requestAnimationFrame(s),()=>{l!=null&&cancelAnimationFrame(l)}}}function a7(e,t){return o7(e)||s7(e,t)||l7(e,t)||i7()}function i7(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function l7(e,t){if(e){if(typeof e=="string")return G_(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?G_(e,t):void 0}}function G_(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n{},onAnimationStart:()=>{}},V_=0,vv=1;function vE(e){var t=an(e,c7),n=t.animationId,r=t.isActive,l=t.canBegin,s=t.duration,d=t.easing,f=t.begin,m=t.onAnimationEnd,h=t.onAnimationStart,v=t.children,y=dE(),b=r==="auto"?!Pc.isSsr&&!y:r,w=WR(t.animationController),j=x.useState(b?V_:vv),_=a7(j,2),S=_[0],A=_[1];return x.useEffect(()=>{b||A(vv)},[b]),x.useEffect(()=>{var C=FR(d);if(!b||!l||C==null)return hl;var M=new r7,k=new n7({animationId:n,easing:C,animationDuration:s,animationBegin:f,onAnimationStart:h,onAnimationEnd:m,from:V_,to:vv});return w(M,k,A)},[w,n,b,l,s,d,f,h,m]),v(Number(S))}function yE(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=x.useRef(dc(t)),r=x.useRef(e);return r.current!==e&&(n.current=dc(t),r.current=e),n.current}var u7=e=>e.replace(/([A-Z])/g,t=>"-".concat(t.toLowerCase())),d7=(e,t,n)=>e.map(r=>"".concat(u7(r)," ").concat(t,"ms ").concat(n)).join(","),f7=["radius"],m7=["radius"],F_,X_,W_,Z_,Q_,J_,e2,t2,n2,r2;function a2(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function i2(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=Array(t);n{var s=di(n),d=di(r),f=Math.min(Math.abs(s)/2,Math.abs(d)/2),m=d>=0?1:-1,h=s>=0?1:-1,v=d>=0&&s>=0||d<0&&s<0?1:0,y;if(f>0&&Array.isArray(l)){for(var b=[0,0,0,0],w=0,j=4;wf?f:S}y=hn(F_||(F_=zr(["M",",",""])),e,t+m*b[0]),b[0]>0&&(y+=hn(X_||(X_=zr(["A ",",",",0,0,",",",",",""])),b[0],b[0],v,e+h*b[0],t)),y+=hn(W_||(W_=zr(["L ",",",""])),e+n-h*b[1],t),b[1]>0&&(y+=hn(Z_||(Z_=zr(["A ",",",",0,0,",`, - `,",",""])),b[1],b[1],v,e+n,t+m*b[1])),y+=hn(Q_||(Q_=zr(["L ",",",""])),e+n,t+r-m*b[2]),b[2]>0&&(y+=hn(J_||(J_=zr(["A ",",",",0,0,",`, - `,",",""])),b[2],b[2],v,e+n-h*b[2],t+r)),y+=hn(e2||(e2=zr(["L ",",",""])),e+h*b[3],t+r),b[3]>0&&(y+=hn(t2||(t2=zr(["A ",",",",0,0,",`, - `,",",""])),b[3],b[3],v,e,t+r-m*b[3])),y+="Z"}else if(f>0&&l===+l&&l>0){var A=Math.min(f,l);y=hn(n2||(n2=zr(["M ",",",` - A `,",",",0,0,",",",",",` - L `,",",` - A `,",",",0,0,",",",",",` - L `,",",` - A `,",",",0,0,",",",",",` - L `,",",` - A `,",",",0,0,",",",","," Z"])),e,t+m*A,A,A,v,e+h*A,t,e+n-h*A,t,A,A,v,e+n,t+m*A,e+n,t+r-m*A,A,A,v,e+n-h*A,t+r,e+h*A,t+r,A,A,v,e,t+r-m*A)}else y=hn(r2||(r2=zr(["M ",","," h "," v "," h "," Z"])),e,t,n,r,-n);return y},c2={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},gE=e=>{var t=an(e,c2),n=x.useRef(null),r=x.useState(-1),l=g7(r,2),s=l[0],d=l[1];x.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var G=n.current.getTotalLength();G&&d(G)}catch{}},[]);var f=t.x,m=t.y,h=t.width,v=t.height,y=t.radius,b=t.className,w=t.animationEasing,j=t.animationDuration,_=t.animationBegin,S=t.isAnimationActive,A=t.isUpdateAnimationActive,C=x.useRef(h),M=x.useRef(v),k=x.useRef(f),D=x.useRef(m),E=x.useMemo(()=>({x:f,y:m,width:h,height:v,radius:y}),[f,m,h,v,y]),$=yE(E,"rectangle-");if(f!==+f||m!==+m||h!==+h||v!==+v||h===0||v===0)return null;var U=nt("recharts-rectangle",b);if(!A){var K=Xn(t);K.radius;var T=l2(K,f7);return x.createElement("path",cf({},T,{x:di(f),y:di(m),width:di(h),height:di(v),radius:typeof y=="number"?y:void 0,className:U,d:o2(f,m,h,v,y)}))}var re=C.current,Z=M.current,pe=k.current,fe=D.current,ce="0px ".concat(s===-1?1:s,"px"),R="".concat(s,"px ").concat(s,"px"),z=d7(["strokeDasharray"],j,typeof w=="string"?w:c2.animationEasing);return x.createElement(vE,{animationId:$,key:$,canBegin:s>0,duration:j,easing:w,isActive:A,begin:_},G=>{var se=Et(re,h,G),ue=Et(Z,v,G),P=Et(pe,f,G),Q=Et(fe,m,G);n.current&&(C.current=se,M.current=ue,k.current=P,D.current=Q);var ne;S?G>0?ne={transition:z,strokeDasharray:R}:ne={strokeDasharray:ce}:ne={strokeDasharray:R};var I=Xn(t);I.radius;var he=l2(I,m7);return x.createElement("path",cf({},he,{radius:typeof y=="number"?y:void 0,className:U,d:o2(P,Q,se,ue,y),ref:n,style:i2(i2({},ne),t.style)}))})};function u2(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function d2(e){for(var t=1;te*180/Math.PI,Ht=(e,t,n,r)=>({x:e+Math.cos(-uf*r)*n,y:t+Math.sin(-uf*r)*n}),xE=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(t-(r.left||0)-(r.right||0)),Math.abs(n-(r.top||0)-(r.bottom||0)))/2},O7=(e,t)=>{var n=e.x,r=e.y,l=t.x,s=t.y;return Math.sqrt((n-l)**2+(r-s)**2)},E7=(e,t)=>{var n=e.x,r=e.y,l=t.cx,s=t.cy,d=O7({x:n,y:r},{x:l,y:s});if(d<=0)return{radius:d,angle:0};var f=(n-l)/d,m=Math.acos(f);return r>s&&(m=2*Math.PI-m),{radius:d,angle:A7(m),angleInRadian:m}},k7=e=>{var t=e.startAngle,n=e.endAngle,r=Math.floor(t/360),l=Math.floor(n/360),s=Math.min(r,l);return{startAngle:t-s*360,endAngle:n-s*360}},C7=(e,t)=>{var n=t.startAngle,r=t.endAngle,l=Math.floor(n/360),s=Math.floor(r/360),d=Math.min(l,s);return e+d*360},T7=(e,t)=>{var n=e.relativeX,r=e.relativeY,l=E7({x:n,y:r},t),s=l.radius,d=l.angle,f=t.innerRadius,m=t.outerRadius;if(sm||s===0)return null;var h=k7(t),v=h.startAngle,y=h.endAngle,b=d,w;if(v<=y){for(;b>y;)b-=360;for(;b=v&&b<=y}else{for(;b>v;)b-=360;for(;b=y&&b<=v}return w?d2(d2({},t),{},{radius:s,angle:C7(b,t)}):null};function bE(e){var t=e.cx,n=e.cy,r=e.radius,l=e.startAngle,s=e.endAngle,d=Ht(t,n,r,l),f=Ht(t,n,r,s);return{points:[d,f],cx:t,cy:n,radius:r,startAngle:l,endAngle:s}}var f2,m2,h2,p2,v2,y2,g2;function xy(){return xy=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=rn(t-e),r=Math.min(Math.abs(t-e),359.999);return n*r},xd=e=>{var t=e.cx,n=e.cy,r=e.radius,l=e.angle,s=e.sign,d=e.isExternal,f=e.cornerRadius,m=e.cornerIsExternal,h=f*(d?1:-1)+r,v=Math.asin(f/h)/uf,y=m?l:l+s*v,b=Ht(t,n,h,y),w=Ht(t,n,r,y),j=m?l-s*v:l,_=Ht(t,n,h*Math.cos(v*uf),j);return{center:b,circleTangency:w,lineTangency:_,theta:v}},wE=e=>{var t=e.cx,n=e.cy,r=e.innerRadius,l=e.outerRadius,s=e.startAngle,d=e.endAngle,f=M7(s,d),m=s+f,h=Ht(t,n,l,s),v=Ht(t,n,l,m),y=hn(f2||(f2=Xi(["M ",",",` - A `,",",`,0, - `,",",`, - `,",",` - `])),h.x,h.y,l,l,+(Math.abs(f)>180),+(s>m),v.x,v.y);if(r>0){var b=Ht(t,n,r,s),w=Ht(t,n,r,m);y+=hn(m2||(m2=Xi(["L ",",",` - A `,",",`,0, - `,",",`, - `,","," Z"])),w.x,w.y,r,r,+(Math.abs(f)>180),+(s<=m),b.x,b.y)}else y+=hn(h2||(h2=Xi(["L ",","," Z"])),t,n);return y},D7=e=>{var t=e.cx,n=e.cy,r=e.innerRadius,l=e.outerRadius,s=e.cornerRadius,d=e.forceCornerRadius,f=e.cornerIsExternal,m=e.startAngle,h=e.endAngle,v=rn(h-m),y=xd({cx:t,cy:n,radius:l,angle:m,sign:v,cornerRadius:s,cornerIsExternal:f}),b=y.circleTangency,w=y.lineTangency,j=y.theta,_=xd({cx:t,cy:n,radius:l,angle:h,sign:-v,cornerRadius:s,cornerIsExternal:f}),S=_.circleTangency,A=_.lineTangency,C=_.theta,M=f?Math.abs(m-h):Math.abs(m-h)-j-C;if(M<0)return d?hn(p2||(p2=Xi(["M ",",",` - a`,",",",0,0,1,",`,0 - a`,",",",0,0,1,",`,0 - `])),w.x,w.y,s,s,s*2,s,s,-s*2):wE({cx:t,cy:n,innerRadius:r,outerRadius:l,startAngle:m,endAngle:h});var k=hn(v2||(v2=Xi(["M ",",",` - A`,",",",0,0,",",",",",` - A`,",",",0,",",",",",",",` - A`,",",",0,0,",",",",",` - `])),w.x,w.y,s,s,+(v<0),b.x,b.y,l,l,+(M>180),+(v<0),S.x,S.y,s,s,+(v<0),A.x,A.y);if(r>0){var D=xd({cx:t,cy:n,radius:r,angle:m,sign:v,isExternal:!0,cornerRadius:s,cornerIsExternal:f}),E=D.circleTangency,$=D.lineTangency,U=D.theta,K=xd({cx:t,cy:n,radius:r,angle:h,sign:-v,isExternal:!0,cornerRadius:s,cornerIsExternal:f}),T=K.circleTangency,re=K.lineTangency,Z=K.theta,pe=f?Math.abs(m-h):Math.abs(m-h)-U-Z;if(pe<0&&s===0)return"".concat(k,"L").concat(t,",").concat(n,"Z");k+=hn(y2||(y2=Xi(["L",",",` - A`,",",",0,0,",",",",",` - A`,",",",0,",",",",",",",` - A`,",",",0,0,",",",",","Z"])),re.x,re.y,s,s,+(v<0),T.x,T.y,r,r,+(pe>180),+(v>0),E.x,E.y,s,s,+(v<0),$.x,$.y)}else k+=hn(g2||(g2=Xi(["L",",","Z"])),t,n);return k},P7={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},jE=e=>{var t=an(e,P7),n=t.cx,r=t.cy,l=t.innerRadius,s=t.outerRadius,d=t.cornerRadius,f=t.forceCornerRadius,m=t.cornerIsExternal,h=t.startAngle,v=t.endAngle,y=t.className;if(s0&&Math.abs(h-v)<360?_=D7({cx:n,cy:r,innerRadius:l,outerRadius:s,cornerRadius:Math.min(j,w/2),forceCornerRadius:f,cornerIsExternal:m,startAngle:h,endAngle:v}):_=wE({cx:n,cy:r,innerRadius:l,outerRadius:s,startAngle:h,endAngle:v}),x.createElement("path",xy({},Xn(t),{className:b,d:_}))};function z7(e,t,n){if(e==="horizontal")return[{x:t.x,y:n.top},{x:t.x,y:n.top+n.height}];if(e==="vertical")return[{x:n.left,y:t.y},{x:n.left+n.width,y:t.y}];if(XA(t)){if(e==="centric"){var r=t.cx,l=t.cy,s=t.innerRadius,d=t.outerRadius,f=t.angle,m=Ht(r,l,s,f),h=Ht(r,l,d,f);return[{x:m.x,y:m.y},{x:h.x,y:h.y}]}return bE(t)}}function I7(e){return dO(e)?NaN:Number(e)}function yv(e){return e?(e=I7(e),e===1/0||e===-1/0?(e<0?-1:1)*Number.MAX_VALUE:e===e?e:0):e===0?e:0}function _E(e,t,n){n&&typeof n!="number"&&Qv(e,t,n)&&(t=n=void 0),e=yv(e),t===void 0?(t=e,e=0):t=yv(t),n=n===void 0?ee.chartData,zc=X([kr],e=>{var t=e.chartData!=null?e.chartData.length-1:0;return{chartData:e.chartData,computedData:e.computedData,dataEndIndex:t,dataStartIndex:0}}),sm=(e,t,n,r)=>r?zc(e):kr(e),NE=(e,t,n)=>n?zc(e):kr(e),$7=X([sm],e=>{var t=e.chartData,n=e.dataStartIndex,r=e.dataEndIndex;return t!=null?t.slice(n,r+1):[]}),R7=X([zc],e=>{var t=e.chartData,n=e.dataStartIndex,r=e.dataEndIndex;return t!=null?t.slice(n,r+1):[]}),L7=X([kr],e=>{var t=e.chartData,n=e.dataStartIndex,r=e.dataEndIndex;return t!=null?t.slice(n,r+1):[]});function b0(e,t){return q7(e)||H7(e,t)||U7(e,t)||B7()}function B7(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function U7(e,t){if(e){if(typeof e=="string")return x2(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?x2(e,t):void 0}}function x2(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);ne.e^s.s<0?1:-1;for(r=s.d.length,l=e.d.length,t=0,n=re.d[t]^s.s<0?1:-1;return r===l?0:r>l^s.s<0?1:-1};Se.decimalPlaces=Se.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*gt;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n};Se.dividedBy=Se.div=function(e){return _a(this,new this.constructor(e))};Se.dividedToIntegerBy=Se.idiv=function(e){var t=this,n=t.constructor;return mt(_a(t,new n(e),0,1),n.precision)};Se.equals=Se.eq=function(e){return!this.cmp(e)};Se.exponent=function(){return Kt(this)};Se.greaterThan=Se.gt=function(e){return this.cmp(e)>0};Se.greaterThanOrEqualTo=Se.gte=function(e){return this.cmp(e)>=0};Se.isInteger=Se.isint=function(){return this.e>this.d.length-2};Se.isNegative=Se.isneg=function(){return this.s<0};Se.isPositive=Se.ispos=function(){return this.s>0};Se.isZero=function(){return this.s===0};Se.lessThan=Se.lt=function(e){return this.cmp(e)<0};Se.lessThanOrEqualTo=Se.lte=function(e){return this.cmp(e)<1};Se.logarithm=Se.log=function(e){var t,n=this,r=n.constructor,l=r.precision,s=l+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(Gn))throw Error(vr+"NaN");if(n.s<1)throw Error(vr+(n.s?"NaN":"-Infinity"));return n.eq(Gn)?new r(0):(wt=!1,t=_a(gc(n,s),gc(e,s),s),wt=!0,mt(t,l))};Se.minus=Se.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?kE(t,e):OE(t,(e.s=-e.s,e))};Se.modulo=Se.mod=function(e){var t,n=this,r=n.constructor,l=r.precision;if(e=new r(e),!e.s)throw Error(vr+"NaN");return n.s?(wt=!1,t=_a(n,e,0,1).times(e),wt=!0,n.minus(t)):mt(new r(n),l)};Se.naturalExponential=Se.exp=function(){return EE(this)};Se.naturalLogarithm=Se.ln=function(){return gc(this)};Se.negated=Se.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};Se.plus=Se.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?OE(t,e):kE(t,(e.s=-e.s,e))};Se.precision=Se.sd=function(e){var t,n,r,l=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(el+e);if(t=Kt(l)+1,r=l.d.length-1,n=r*gt+1,r=l.d[r],r){for(;r%10==0;r/=10)n--;for(r=l.d[0];r>=10;r/=10)n++}return e&&t>n?t:n};Se.squareRoot=Se.sqrt=function(){var e,t,n,r,l,s,d,f=this,m=f.constructor;if(f.s<1){if(!f.s)return new m(0);throw Error(vr+"NaN")}for(e=Kt(f),wt=!1,l=Math.sqrt(+f),l==0||l==1/0?(t=Lr(f.d),(t.length+e)%2==0&&(t+="0"),l=Math.sqrt(t),e=Ls((e+1)/2)-(e<0||e%2),l==1/0?t="5e"+e:(t=l.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),r=new m(t)):r=new m(l.toString()),n=m.precision,l=d=n+3;;)if(s=r,r=s.plus(_a(f,s,d+2)).times(.5),Lr(s.d).slice(0,d)===(t=Lr(r.d)).slice(0,d)){if(t=t.slice(d-3,d+1),l==d&&t=="4999"){if(mt(s,n+1,0),s.times(s).eq(f)){r=s;break}}else if(t!="9999")break;d+=4}return wt=!0,mt(r,n)};Se.times=Se.mul=function(e){var t,n,r,l,s,d,f,m,h,v=this,y=v.constructor,b=v.d,w=(e=new y(e)).d;if(!v.s||!e.s)return new y(0);for(e.s*=v.s,n=v.e+e.e,m=b.length,h=w.length,m=0;){for(t=0,l=m+r;l>r;)f=s[l]+w[r]*b[l-r-1]+t,s[l--]=f%nn|0,t=f/nn|0;s[l]=(s[l]+t)%nn|0}for(;!s[--d];)s.pop();return t?++n:s.shift(),e.d=s,e.e=n,wt?mt(e,y.precision):e};Se.toDecimalPlaces=Se.todp=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(Yr(e,0,Rs),t===void 0?t=r.rounding:Yr(t,0,8),mt(n,e+Kt(n)+1,t))};Se.toExponential=function(e,t){var n,r=this,l=r.constructor;return e===void 0?n=cl(r,!0):(Yr(e,0,Rs),t===void 0?t=l.rounding:Yr(t,0,8),r=mt(new l(r),e+1,t),n=cl(r,!0,e+1)),n};Se.toFixed=function(e,t){var n,r,l=this,s=l.constructor;return e===void 0?cl(l):(Yr(e,0,Rs),t===void 0?t=s.rounding:Yr(t,0,8),r=mt(new s(l),e+Kt(l)+1,t),n=cl(r.abs(),!1,e+Kt(r)+1),l.isneg()&&!l.isZero()?"-"+n:n)};Se.toInteger=Se.toint=function(){var e=this,t=e.constructor;return mt(new t(e),Kt(e)+1,t.rounding)};Se.toNumber=function(){return+this};Se.toPower=Se.pow=function(e){var t,n,r,l,s,d,f=this,m=f.constructor,h=12,v=+(e=new m(e));if(!e.s)return new m(Gn);if(f=new m(f),!f.s){if(e.s<1)throw Error(vr+"Infinity");return f}if(f.eq(Gn))return f;if(r=m.precision,e.eq(Gn))return mt(f,r);if(t=e.e,n=e.d.length-1,d=t>=n,s=f.s,d){if((n=v<0?-v:v)<=AE){for(l=new m(Gn),t=Math.ceil(r/gt+4),wt=!1;n%2&&(l=l.times(f),j2(l.d,t)),n=Ls(n/2),n!==0;)f=f.times(f),j2(f.d,t);return wt=!0,e.s<0?new m(Gn).div(l):mt(l,r)}}else if(s<0)throw Error(vr+"NaN");return s=s<0&&e.d[Math.max(t,n)]&1?-1:1,f.s=1,wt=!1,l=e.times(gc(f,r+h)),wt=!0,l=EE(l),l.s=s,l};Se.toPrecision=function(e,t){var n,r,l=this,s=l.constructor;return e===void 0?(n=Kt(l),r=cl(l,n<=s.toExpNeg||n>=s.toExpPos)):(Yr(e,1,Rs),t===void 0?t=s.rounding:Yr(t,0,8),l=mt(new s(l),e,t),n=Kt(l),r=cl(l,e<=n||n<=s.toExpNeg,e)),r};Se.toSignificantDigits=Se.tosd=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(Yr(e,1,Rs),t===void 0?t=r.rounding:Yr(t,0,8)),mt(new r(n),e,t)};Se.toString=Se.valueOf=Se.val=Se.toJSON=Se[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,t=Kt(e),n=e.constructor;return cl(e,t<=n.toExpNeg||t>=n.toExpPos)};function OE(e,t){var n,r,l,s,d,f,m,h,v=e.constructor,y=v.precision;if(!e.s||!t.s)return t.s||(t=new v(e)),wt?mt(t,y):t;if(m=e.d,h=t.d,d=e.e,l=t.e,m=m.slice(),s=d-l,s){for(s<0?(r=m,s=-s,f=h.length):(r=h,l=d,f=m.length),d=Math.ceil(y/gt),f=d>f?d+1:f+1,s>f&&(s=f,r.length=1),r.reverse();s--;)r.push(0);r.reverse()}for(f=m.length,s=h.length,f-s<0&&(s=f,r=h,h=m,m=r),n=0;s;)n=(m[--s]=m[s]+h[s]+n)/nn|0,m[s]%=nn;for(n&&(m.unshift(n),++l),f=m.length;m[--f]==0;)m.pop();return t.d=m,t.e=l,wt?mt(t,y):t}function Yr(e,t,n){if(e!==~~e||en)throw Error(el+e)}function Lr(e){var t,n,r,l=e.length-1,s="",d=e[0];if(l>0){for(s+=d,t=1;td?1:-1;else for(f=m=0;fl[f]?1:-1;break}return m}function n(r,l,s){for(var d=0;s--;)r[s]-=d,d=r[s]1;)r.shift()}return function(r,l,s,d){var f,m,h,v,y,b,w,j,_,S,A,C,M,k,D,E,$,U,K=r.constructor,T=r.s==l.s?1:-1,re=r.d,Z=l.d;if(!r.s)return new K(r);if(!l.s)throw Error(vr+"Division by zero");for(m=r.e-l.e,$=Z.length,D=re.length,w=new K(T),j=w.d=[],h=0;Z[h]==(re[h]||0);)++h;if(Z[h]>(re[h]||0)&&--m,s==null?C=s=K.precision:d?C=s+(Kt(r)-Kt(l))+1:C=s,C<0)return new K(0);if(C=C/gt+2|0,h=0,$==1)for(v=0,Z=Z[0],C++;(h1&&(Z=e(Z,v),re=e(re,v),$=Z.length,D=re.length),k=$,_=re.slice(0,$),S=_.length;S<$;)_[S++]=0;U=Z.slice(),U.unshift(0),E=Z[0],Z[1]>=nn/2&&++E;do v=0,f=t(Z,_,$,S),f<0?(A=_[0],$!=S&&(A=A*nn+(_[1]||0)),v=A/E|0,v>1?(v>=nn&&(v=nn-1),y=e(Z,v),b=y.length,S=_.length,f=t(y,_,b,S),f==1&&(v--,n(y,$16)throw Error(w0+Kt(e));if(!e.s)return new v(Gn);for(wt=!1,f=y,d=new v(.03125);e.abs().gte(.1);)e=e.times(d),h+=5;for(r=Math.log(Gi(2,h))/Math.LN10*2+5|0,f+=r,n=l=s=new v(Gn),v.precision=f;;){if(l=mt(l.times(e),f),n=n.times(++m),d=s.plus(_a(l,n,f)),Lr(d.d).slice(0,f)===Lr(s.d).slice(0,f)){for(;h--;)s=mt(s.times(s),f);return v.precision=y,t==null?(wt=!0,mt(s,y)):s}s=d}}function Kt(e){for(var t=e.e*gt,n=e.d[0];n>=10;n/=10)t++;return t}function gv(e,t,n){if(t>e.LN10.sd())throw wt=!0,n&&(e.precision=n),Error(vr+"LN10 precision limit exceeded");return mt(new e(e.LN10),t)}function si(e){for(var t="";e--;)t+="0";return t}function gc(e,t){var n,r,l,s,d,f,m,h,v,y=1,b=10,w=e,j=w.d,_=w.constructor,S=_.precision;if(w.s<1)throw Error(vr+(w.s?"NaN":"-Infinity"));if(w.eq(Gn))return new _(0);if(t==null?(wt=!1,h=S):h=t,w.eq(10))return t==null&&(wt=!0),gv(_,h);if(h+=b,_.precision=h,n=Lr(j),r=n.charAt(0),s=Kt(w),Math.abs(s)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)w=w.times(e),n=Lr(w.d),r=n.charAt(0),y++;s=Kt(w),r>1?(w=new _("0."+n),s++):w=new _(r+"."+n.slice(1))}else return m=gv(_,h+2,S).times(s+""),w=gc(new _(r+"."+n.slice(1)),h-b).plus(m),_.precision=S,t==null?(wt=!0,mt(w,S)):w;for(f=d=w=_a(w.minus(Gn),w.plus(Gn),h),v=mt(w.times(w),h),l=3;;){if(d=mt(d.times(v),h),m=f.plus(_a(d,new _(l),h)),Lr(m.d).slice(0,h)===Lr(f.d).slice(0,h))return f=f.times(2),s!==0&&(f=f.plus(gv(_,h+2,S).times(s+""))),f=_a(f,new _(y),h),_.precision=S,t==null?(wt=!0,mt(f,S)):f;f=m,l+=2}}function w2(e,t){var n,r,l;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;)++r;for(l=t.length;t.charCodeAt(l-1)===48;)--l;if(t=t.slice(r,l),t){if(l-=r,n=n-r-1,e.e=Ls(n/gt),e.d=[],r=(n+1)%gt,n<0&&(r+=gt),rdf||e.e<-df))throw Error(w0+n)}else e.s=0,e.e=0,e.d=[0];return e}function mt(e,t,n){var r,l,s,d,f,m,h,v,y=e.d;for(d=1,s=y[0];s>=10;s/=10)d++;if(r=t-d,r<0)r+=gt,l=t,h=y[v=0];else{if(v=Math.ceil((r+1)/gt),s=y.length,v>=s)return e;for(h=s=y[v],d=1;s>=10;s/=10)d++;r%=gt,l=r-gt+d}if(n!==void 0&&(s=Gi(10,d-l-1),f=h/s%10|0,m=t<0||y[v+1]!==void 0||h%s,m=n<4?(f||m)&&(n==0||n==(e.s<0?3:2)):f>5||f==5&&(n==4||m||n==6&&(r>0?l>0?h/Gi(10,d-l):0:y[v-1])%10&1||n==(e.s<0?8:7))),t<1||!y[0])return m?(s=Kt(e),y.length=1,t=t-s-1,y[0]=Gi(10,(gt-t%gt)%gt),e.e=Ls(-t/gt)||0):(y.length=1,y[0]=e.e=e.s=0),e;if(r==0?(y.length=v,s=1,v--):(y.length=v+1,s=Gi(10,gt-r),y[v]=l>0?(h/Gi(10,d-l)%Gi(10,l)|0)*s:0),m)for(;;)if(v==0){(y[0]+=s)==nn&&(y[0]=1,++e.e);break}else{if(y[v]+=s,y[v]!=nn)break;y[v--]=0,s=1}for(r=y.length;y[--r]===0;)y.pop();if(wt&&(e.e>df||e.e<-df))throw Error(w0+Kt(e));return e}function kE(e,t){var n,r,l,s,d,f,m,h,v,y,b=e.constructor,w=b.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new b(e),wt?mt(t,w):t;if(m=e.d,y=t.d,r=t.e,h=e.e,m=m.slice(),d=h-r,d){for(v=d<0,v?(n=m,d=-d,f=y.length):(n=y,r=h,f=m.length),l=Math.max(Math.ceil(w/gt),f)+2,d>l&&(d=l,n.length=1),n.reverse(),l=d;l--;)n.push(0);n.reverse()}else{for(l=m.length,f=y.length,v=l0;--l)m[f++]=0;for(l=y.length;l>d;){if(m[--l]0?s=s.charAt(0)+"."+s.slice(1)+si(r):d>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(l<0?"e":"e+")+l):l<0?(s="0."+si(-l-1)+s,n&&(r=n-d)>0&&(s+=si(r))):l>=d?(s+=si(l+1-d),n&&(r=n-l-1)>0&&(s=s+"."+si(r))):((r=l+1)0&&(l+1===d&&(s+="."),s+=si(r))),e.s<0?"-"+s:s}function j2(e,t){if(e.length>t)return e.length=t,!0}function CE(e){var t,n,r;function l(s){var d=this;if(!(d instanceof l))return new l(s);if(d.constructor=l,s instanceof l){d.s=s.s,d.e=s.e,d.d=(s=s.d)?s.slice():s;return}if(typeof s=="number"){if(s*0!==0)throw Error(el+s);if(s>0)d.s=1;else if(s<0)s=-s,d.s=-1;else{d.s=0,d.e=0,d.d=[0];return}if(s===~~s&&s<1e7){d.e=0,d.d=[s];return}return w2(d,s.toString())}else if(typeof s!="string")throw Error(el+s);if(s.charCodeAt(0)===45?(s=s.slice(1),d.s=-1):d.s=1,G7.test(s))w2(d,s);else throw Error(el+s)}if(l.prototype=Se,l.ROUND_UP=0,l.ROUND_DOWN=1,l.ROUND_CEIL=2,l.ROUND_FLOOR=3,l.ROUND_HALF_UP=4,l.ROUND_HALF_DOWN=5,l.ROUND_HALF_EVEN=6,l.ROUND_HALF_CEIL=7,l.ROUND_HALF_FLOOR=8,l.clone=CE,l.config=l.set=V7,e===void 0&&(e={}),e)for(r=["precision","rounding","toExpNeg","toExpPos","LN10"],t=0;t=l[t+1]&&r<=l[t+2])this[n]=r;else throw Error(el+n+": "+r);if((r=e[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(el+n+": "+r);return this}var j0=CE(Y7);Gn=new j0(1);const Xe=j0;function TE(e){var t;return e===0?t=1:t=Math.floor(new Xe(e).abs().log(10).toNumber())+1,t}function ME(e,t,n){for(var r=new Xe(e),l=0,s=[];r.lt(t)&&l<1e5;)s.push(r.toNumber()),r=r.add(n),l++;return s}function xc(e,t){return Z7(e)||W7(e,t)||X7(e,t)||F7()}function F7(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function X7(e,t){if(e){if(typeof e=="string")return _2(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_2(e,t):void 0}}function _2(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n{var t=xc(e,2),n=t[0],r=t[1],l=n,s=r;return n>r&&(l=r,s=n),[l,s]},_0=(e,t,n)=>{if(e.lte(0))return new Xe(0);var r=TE(e.toNumber()),l=new Xe(10).pow(r),s=e.div(l),d=r!==1?.05:.1,f=new Xe(Math.ceil(s.div(d).toNumber())).add(n).mul(d),m=f.mul(l);return t?new Xe(m.toNumber()):new Xe(Math.ceil(m.toNumber()))},PE=(e,t,n)=>{var r;if(e.lte(0))return new Xe(0);var l=[1,2,2.5,5],s=e.toNumber(),d=Math.floor(new Xe(s).abs().log(10).toNumber()),f=new Xe(10).pow(d),m=e.div(f).toNumber(),h=l.findIndex(w=>w>=m-1e-10);if(h===-1&&(f=f.mul(10),h=0),h+=n,h>=l.length){var v=Math.floor(h/l.length);h%=l.length,f=f.mul(new Xe(10).pow(v))}var y=(r=l[h])!==null&&r!==void 0?r:1,b=new Xe(y).mul(f);return t?b:new Xe(Math.ceil(b.toNumber()))},Q7=(e,t,n)=>{var r=new Xe(1),l=new Xe(e);if(!l.isint()&&n){var s=Math.abs(e);s<1?(r=new Xe(10).pow(TE(e)-1),l=new Xe(Math.floor(l.div(r).toNumber())).mul(r)):s>1&&(l=new Xe(Math.floor(e)))}else e===0?l=new Xe(Math.floor((t-1)/2)):n||(l=new Xe(Math.floor(e)));for(var d=Math.floor((t-1)/2),f=[],m=0;m4&&arguments[4]!==void 0?arguments[4]:0,d=arguments.length>5&&arguments[5]!==void 0?arguments[5]:_0;if(!Number.isFinite((n-t)/(r-1)))return{step:new Xe(0),tickMin:new Xe(0),tickMax:new Xe(0)};var f=d(new Xe(n).sub(t).div(r-1),l,s),m;t<=0&&n>=0?m=new Xe(0):(m=new Xe(t).add(n).div(2),m=m.sub(new Xe(m).mod(f)));var h=Math.ceil(m.sub(t).div(f).toNumber()),v=Math.ceil(new Xe(n).sub(m).div(f).toNumber()),y=h+v+1;return y>r?zE(t,n,r,l,s+1,d):(y0?v+(r-y):v,h=n>0?h:h+(r-y)),{step:f,tickMin:m.sub(new Xe(h).mul(f)),tickMax:m.add(new Xe(v).mul(f))})},N2=function(t){var n=xc(t,2),r=n[0],l=n[1],s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,f=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"auto",m=Math.max(s,2),h=DE([r,l]),v=xc(h,2),y=v[0],b=v[1];if(y===-1/0||b===1/0){var w=b===1/0?[y,...Array(s-1).fill(1/0)]:[...Array(s-1).fill(-1/0),b];return r>l?w.reverse():w}if(y===b)return Q7(y,s,d);var j=f==="snap125"?PE:_0,_=zE(y,b,m,d,0,j),S=_.step,A=_.tickMin,C=_.tickMax,M=ME(A,C.add(new Xe(.1).mul(S)),S);return r>l?M.reverse():M},S2=function(t,n){var r=xc(t,2),l=r[0],s=r[1],d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,f=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"auto",m=DE([l,s]),h=xc(m,2),v=h[0],y=h[1];if(v===-1/0||y===1/0)return[l,s];if(v===y)return[v];var b=f==="snap125"?PE:_0,w=Math.max(n,2),j=b(new Xe(y).sub(v).div(w-1),d,0),_=[...ME(new Xe(v),new Xe(y),j),y];return d===!1&&(_=_.map(S=>Math.round(S))),l>s?_.reverse():_},IE=e=>e.rootProps.maxBarSize,J7=e=>e.rootProps.barGap,$E=e=>e.rootProps.barCategoryGap,e9=e=>e.rootProps.barSize,Ic=e=>e.rootProps.stackOffset,RE=e=>e.rootProps.reverseStackOrder,N0=e=>e.options.chartName,S0=e=>e.rootProps.syncId,LE=e=>e.rootProps.syncMethod,A0=e=>e.options.eventEmitter,t9=e=>e.rootProps.baseValue,qt={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Bi={allowDecimals:!1,allowDataOverflow:!1,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"auto"},Ir={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!0,includeHidden:!1,radiusAxisId:0,reversed:!1,scale:"auto",tick:!0,tickCount:5,type:"auto"},om=(e,t)=>{if(!(!e||!t))return e!=null&&e.reversed?[t[1],t[0]]:t};function cm(e,t,n){if(n!=="auto")return n;if(e!=null)return Vr(e,t)?"category":"number"}function A2(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function ff(e){for(var t=1;t{if(t!=null)return e.polarAxis.angleAxis[t]},O0=X([i9,y0],(e,t)=>{var n;if(e!=null)return e;var r=(n=cm(t,"angleAxis",O2.type))!==null&&n!==void 0?n:"category";return ff(ff({},O2),{},{type:r})}),l9=(e,t)=>e.polarAxis.radiusAxis[t],E0=X([l9,y0],(e,t)=>{var n;if(e!=null)return e;var r=(n=cm(t,"radiusAxis",E2.type))!==null&&n!==void 0?n:"category";return ff(ff({},E2),{},{type:r})}),um=e=>e.polarOptions,k0=X([Ca,Ta,Wt],xE),BE=X([um,k0],(e,t)=>{if(e!=null)return xn(e.innerRadius,t,0)}),UE=X([um,k0],(e,t)=>{if(e!=null)return xn(e.outerRadius,t,t*.8)}),s9=e=>{if(e==null)return[0,0];var t=e.startAngle,n=e.endAngle;return[t,n]},HE=X([um],s9);X([O0,HE],om);var qE=X([k0,BE,UE],(e,t,n)=>{if(!(e==null||t==null||n==null))return[t,n]});X([E0,qE],om);var KE=X([Ze,um,BE,UE,Ca,Ta],(e,t,n,r,l,s)=>{if(!(e!=="centric"&&e!=="radial"||t==null||n==null||r==null)){var d=t.cx,f=t.cy,m=t.startAngle,h=t.endAngle;return{cx:xn(d,l,l/2),cy:xn(f,s,s/2),innerRadius:n,outerRadius:r,startAngle:m,endAngle:h,clockWise:!1}}}),St=(e,t)=>t,$c=(e,t,n)=>n;function dm(e){return e==null?void 0:e.id}function YE(e,t,n){var r=t.chartData,l=r===void 0?[]:r,s=n.allowDuplicatedCategory,d=n.dataKey,f=new Map;return e.forEach(m=>{var h,v=(h=m.data)!==null&&h!==void 0?h:l;if(!(v==null||v.length===0)){var y=dm(m);v.forEach((b,w)=>{var j=d==null||s?w:String(rt(b,d,null)),_=rt(b,m.dataKey,0),S;f.has(j)?S=f.get(j):S={},Object.assign(S,{[y]:_}),f.set(j,S)})}}),Array.from(f.values())}function fm(e){return"stackId"in e&&e.stackId!=null&&e.dataKey!=null}var mm=(e,t)=>e===t?!0:e==null||t==null?!1:e[0]===t[0]&&e[1]===t[1];function hm(e,t){return Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t}function o9(e,t){if(e.length===t.length){for(var n=0;n{var t=Ze(e);return t==="horizontal"?"xAxis":t==="vertical"?"yAxis":t==="centric"?"angleAxis":"radiusAxis"},Bs=e=>e.tooltip.settings.axisId;function C0(e){if(e!=null){var t=e.ticks,n=e.bandwidth,r=e.range(),l=[Math.min(...r),Math.max(...r)];return{domain:()=>e.domain(),range:(function(s){function d(){return s.apply(this,arguments)}return d.toString=function(){return s.toString()},d})(()=>l),rangeMin:()=>l[0],rangeMax:()=>l[1],isInRange(s){var d=l[0],f=l[1];return d<=f?s>=d&&s<=f:s>=f&&s<=d},bandwidth:n?()=>n.call(e):void 0,ticks:t?s=>t.call(e,s):void 0,map:(s,d)=>{var f=e(s);if(f!=null){if(e.bandwidth&&d!==null&&d!==void 0&&d.position){var m=e.bandwidth();switch(d.position){case"middle":f+=m/2;break;case"end":f+=m;break}}return f}}}}}var GE=(e,t)=>{if(t!=null)switch(e){case"linear":{if(!Br(t)){for(var n,r,l=0;lr)&&(r=s))}return n!==void 0&&r!==void 0?[n,r]:void 0}return t}default:return t}};function fi(e,t){return e==null||t==null?NaN:et?1:e>=t?0:NaN}function c9(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function T0(e){let t,n,r;e.length!==2?(t=fi,n=(f,m)=>fi(e(f),m),r=(f,m)=>e(f)-m):(t=e===fi||e===c9?e:u9,n=e,r=e);function l(f,m,h=0,v=f.length){if(h>>1;n(f[y],m)<0?h=y+1:v=y}while(h>>1;n(f[y],m)<=0?h=y+1:v=y}while(hh&&r(f[y-1],m)>-r(f[y],m)?y-1:y}return{left:l,center:d,right:s}}function u9(){return 0}function VE(e){return e===null?NaN:+e}function*d9(e,t){for(let n of e)n!=null&&(n=+n)>=n&&(yield n)}const f9=T0(fi),Rc=f9.right;T0(VE).center;class k2 extends Map{constructor(t,n=p9){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),t!=null)for(const[r,l]of t)this.set(r,l)}get(t){return super.get(C2(this,t))}has(t){return super.has(C2(this,t))}set(t,n){return super.set(m9(this,t),n)}delete(t){return super.delete(h9(this,t))}}function C2({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):n}function m9({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function h9({_intern:e,_key:t},n){const r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function p9(e){return e!==null&&typeof e=="object"?e.valueOf():e}function v9(e=fi){if(e===fi)return FE;if(typeof e!="function")throw new TypeError("compare is not a function");return(t,n)=>{const r=e(t,n);return r||r===0?r:(e(n,n)===0)-(e(t,t)===0)}}function FE(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et?1:0)}const y9=Math.sqrt(50),g9=Math.sqrt(10),x9=Math.sqrt(2);function mf(e,t,n){const r=(t-e)/Math.max(0,n),l=Math.floor(Math.log10(r)),s=r/Math.pow(10,l),d=s>=y9?10:s>=g9?5:s>=x9?2:1;let f,m,h;return l<0?(h=Math.pow(10,-l)/d,f=Math.round(e*h),m=Math.round(t*h),f/ht&&--m,h=-h):(h=Math.pow(10,l)*d,f=Math.round(e/h),m=Math.round(t/h),f*ht&&--m),m0))return[];if(e===t)return[e];const r=t=l))return[];const f=s-l+1,m=new Array(f);if(r)if(d<0)for(let h=0;h=r)&&(n=r);return n}function M2(e,t){let n;for(const r of e)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function XE(e,t,n=0,r=1/0,l){if(t=Math.floor(t),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(e.length-1,r)),!(n<=t&&t<=r))return e;for(l=l===void 0?FE:v9(l);r>n;){if(r-n>600){const m=r-n+1,h=t-n+1,v=Math.log(m),y=.5*Math.exp(2*v/3),b=.5*Math.sqrt(v*y*(m-y)/m)*(h-m/2<0?-1:1),w=Math.max(n,Math.floor(t-h*y/m+b)),j=Math.min(r,Math.floor(t+(m-h)*y/m+b));XE(e,t,w,j,l)}const s=e[t];let d=n,f=r;for(Go(e,n,t),l(e[r],s)>0&&Go(e,n,r);d0;)--f}l(e[n],s)===0?Go(e,n,f):(++f,Go(e,f,r)),f<=t&&(n=f+1),t<=f&&(r=f-1)}return e}function Go(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function b9(e,t,n){if(e=Float64Array.from(d9(e)),!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return M2(e);if(t>=1)return T2(e);var r,l=(r-1)*t,s=Math.floor(l),d=T2(XE(e,s).subarray(0,s+1)),f=M2(e.subarray(s+1));return d+(f-d)*(l-s)}}function w9(e,t,n=VE){if(!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return+n(e[0],0,e);if(t>=1)return+n(e[r-1],r-1,e);var r,l=(r-1)*t,s=Math.floor(l),d=+n(e[s],s,e),f=+n(e[s+1],s+1,e);return d+(f-d)*(l-s)}}function j9(e,t,n){e=+e,t=+t,n=(l=arguments.length)<2?(t=e,e=0,1):l<3?1:+n;for(var r=-1,l=Math.max(0,Math.ceil((t-e)/n))|0,s=new Array(l);++r>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?bd(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?bd(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=S9.exec(e))?new Pn(t[1],t[2],t[3],1):(t=A9.exec(e))?new Pn(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=O9.exec(e))?bd(t[1],t[2],t[3],t[4]):(t=E9.exec(e))?bd(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=k9.exec(e))?L2(t[1],t[2]/100,t[3]/100,1):(t=C9.exec(e))?L2(t[1],t[2]/100,t[3]/100,t[4]):D2.hasOwnProperty(e)?I2(D2[e]):e==="transparent"?new Pn(NaN,NaN,NaN,0):null}function I2(e){return new Pn(e>>16&255,e>>8&255,e&255,1)}function bd(e,t,n,r){return r<=0&&(e=t=n=NaN),new Pn(e,t,n,r)}function D9(e){return e instanceof Lc||(e=jc(e)),e?(e=e.rgb(),new Pn(e.r,e.g,e.b,e.opacity)):new Pn}function Ny(e,t,n,r){return arguments.length===1?D9(e):new Pn(e,t,n,r??1)}function Pn(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}P0(Pn,Ny,ZE(Lc,{brighter(e){return e=e==null?hf:Math.pow(hf,e),new Pn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?bc:Math.pow(bc,e),new Pn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Pn(tl(this.r),tl(this.g),tl(this.b),pf(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:$2,formatHex:$2,formatHex8:P9,formatRgb:R2,toString:R2}));function $2(){return`#${Wi(this.r)}${Wi(this.g)}${Wi(this.b)}`}function P9(){return`#${Wi(this.r)}${Wi(this.g)}${Wi(this.b)}${Wi((isNaN(this.opacity)?1:this.opacity)*255)}`}function R2(){const e=pf(this.opacity);return`${e===1?"rgb(":"rgba("}${tl(this.r)}, ${tl(this.g)}, ${tl(this.b)}${e===1?")":`, ${e})`}`}function pf(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function tl(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Wi(e){return e=tl(e),(e<16?"0":"")+e.toString(16)}function L2(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Sr(e,t,n,r)}function QE(e){if(e instanceof Sr)return new Sr(e.h,e.s,e.l,e.opacity);if(e instanceof Lc||(e=jc(e)),!e)return new Sr;if(e instanceof Sr)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,l=Math.min(t,n,r),s=Math.max(t,n,r),d=NaN,f=s-l,m=(s+l)/2;return f?(t===s?d=(n-r)/f+(n0&&m<1?0:d,new Sr(d,f,m,e.opacity)}function z9(e,t,n,r){return arguments.length===1?QE(e):new Sr(e,t,n,r??1)}function Sr(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}P0(Sr,z9,ZE(Lc,{brighter(e){return e=e==null?hf:Math.pow(hf,e),new Sr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?bc:Math.pow(bc,e),new Sr(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,l=2*n-r;return new Pn(xv(e>=240?e-240:e+120,l,r),xv(e,l,r),xv(e<120?e+240:e-120,l,r),this.opacity)},clamp(){return new Sr(B2(this.h),wd(this.s),wd(this.l),pf(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=pf(this.opacity);return`${e===1?"hsl(":"hsla("}${B2(this.h)}, ${wd(this.s)*100}%, ${wd(this.l)*100}%${e===1?")":`, ${e})`}`}}));function B2(e){return e=(e||0)%360,e<0?e+360:e}function wd(e){return Math.max(0,Math.min(1,e||0))}function xv(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const z0=e=>()=>e;function I9(e,t){return function(n){return e+n*t}}function $9(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function R9(e){return(e=+e)==1?JE:function(t,n){return n-t?$9(t,n,e):z0(isNaN(t)?n:t)}}function JE(e,t){var n=t-e;return n?I9(e,n):z0(isNaN(e)?t:e)}const U2=(function e(t){var n=R9(t);function r(l,s){var d=n((l=Ny(l)).r,(s=Ny(s)).r),f=n(l.g,s.g),m=n(l.b,s.b),h=JE(l.opacity,s.opacity);return function(v){return l.r=d(v),l.g=f(v),l.b=m(v),l.opacity=h(v),l+""}}return r.gamma=e,r})(1);function L9(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),l;return function(s){for(l=0;ln&&(s=t.slice(n,s),f[d]?f[d]+=s:f[++d]=s),(r=r[0])===(l=l[0])?f[d]?f[d]+=l:f[++d]=l:(f[++d]=null,m.push({i:d,x:vf(r,l)})),n=bv.lastIndex;return nt&&(n=e,e=t,t=n),function(r){return Math.max(e,Math.min(t,r))}}function W9(e,t,n){var r=e[0],l=e[1],s=t[0],d=t[1];return l2?Z9:W9,m=h=null,y}function y(b){return b==null||isNaN(b=+b)?s:(m||(m=f(e.map(r),t,n)))(r(d(b)))}return y.invert=function(b){return d(l((h||(h=f(t,e.map(r),vf)))(b)))},y.domain=function(b){return arguments.length?(e=Array.from(b,yf),v()):e.slice()},y.range=function(b){return arguments.length?(t=Array.from(b),v()):t.slice()},y.rangeRound=function(b){return t=Array.from(b),n=I0,v()},y.clamp=function(b){return arguments.length?(d=b?!0:_n,v()):d!==_n},y.interpolate=function(b){return arguments.length?(n=b,v()):n},y.unknown=function(b){return arguments.length?(s=b,y):s},function(b,w){return r=b,l=w,v()}}function $0(){return pm()(_n,_n)}function Q9(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function gf(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function ks(e){return e=gf(Math.abs(e)),e?e[1]:NaN}function J9(e,t){return function(n,r){for(var l=n.length,s=[],d=0,f=e[0],m=0;l>0&&f>0&&(m+f+1>r&&(f=Math.max(1,r-m)),s.push(n.substring(l-=f,l+f)),!((m+=f+1)>r));)f=e[d=(d+1)%e.length];return s.reverse().join(t)}}function eL(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var tL=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function _c(e){if(!(t=tL.exec(e)))throw new Error("invalid format: "+e);var t;return new R0({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}_c.prototype=R0.prototype;function R0(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}R0.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function nL(e){e:for(var t=e.length,n=1,r=-1,l;n0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(l+1):e}var xf;function rL(e,t){var n=gf(e,t);if(!n)return xf=void 0,e.toPrecision(t);var r=n[0],l=n[1],s=l-(xf=Math.max(-8,Math.min(8,Math.floor(l/3)))*3)+1,d=r.length;return s===d?r:s>d?r+new Array(s-d+1).join("0"):s>0?r.slice(0,s)+"."+r.slice(s):"0."+new Array(1-s).join("0")+gf(e,Math.max(0,t+s-1))[0]}function q2(e,t){var n=gf(e,t);if(!n)return e+"";var r=n[0],l=n[1];return l<0?"0."+new Array(-l).join("0")+r:r.length>l+1?r.slice(0,l+1)+"."+r.slice(l+1):r+new Array(l-r.length+2).join("0")}const K2={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:Q9,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>q2(e*100,t),r:q2,s:rL,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function Y2(e){return e}var G2=Array.prototype.map,V2=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function aL(e){var t=e.grouping===void 0||e.thousands===void 0?Y2:J9(G2.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",r=e.currency===void 0?"":e.currency[1]+"",l=e.decimal===void 0?".":e.decimal+"",s=e.numerals===void 0?Y2:eL(G2.call(e.numerals,String)),d=e.percent===void 0?"%":e.percent+"",f=e.minus===void 0?"−":e.minus+"",m=e.nan===void 0?"NaN":e.nan+"";function h(y,b){y=_c(y);var w=y.fill,j=y.align,_=y.sign,S=y.symbol,A=y.zero,C=y.width,M=y.comma,k=y.precision,D=y.trim,E=y.type;E==="n"?(M=!0,E="g"):K2[E]||(k===void 0&&(k=12),D=!0,E="g"),(A||w==="0"&&j==="=")&&(A=!0,w="0",j="=");var $=(b&&b.prefix!==void 0?b.prefix:"")+(S==="$"?n:S==="#"&&/[boxX]/.test(E)?"0"+E.toLowerCase():""),U=(S==="$"?r:/[%p]/.test(E)?d:"")+(b&&b.suffix!==void 0?b.suffix:""),K=K2[E],T=/[defgprs%]/.test(E);k=k===void 0?6:/[gprs]/.test(E)?Math.max(1,Math.min(21,k)):Math.max(0,Math.min(20,k));function re(Z){var pe=$,fe=U,ce,R,z;if(E==="c")fe=K(Z)+fe,Z="";else{Z=+Z;var G=Z<0||1/Z<0;if(Z=isNaN(Z)?m:K(Math.abs(Z),k),D&&(Z=nL(Z)),G&&+Z==0&&_!=="+"&&(G=!1),pe=(G?_==="("?_:f:_==="-"||_==="("?"":_)+pe,fe=(E==="s"&&!isNaN(Z)&&xf!==void 0?V2[8+xf/3]:"")+fe+(G&&_==="("?")":""),T){for(ce=-1,R=Z.length;++cez||z>57){fe=(z===46?l+Z.slice(ce+1):Z.slice(ce))+fe,Z=Z.slice(0,ce);break}}}M&&!A&&(Z=t(Z,1/0));var se=pe.length+Z.length+fe.length,ue=se>1)+pe+Z+fe+ue.slice(se);break;default:Z=ue+pe+Z+fe;break}return s(Z)}return re.toString=function(){return y+""},re}function v(y,b){var w=Math.max(-8,Math.min(8,Math.floor(ks(b)/3)))*3,j=Math.pow(10,-w),_=h((y=_c(y),y.type="f",y),{suffix:V2[8+w/3]});return function(S){return _(j*S)}}return{format:h,formatPrefix:v}}var jd,L0,ek;iL({thousands:",",grouping:[3],currency:["$",""]});function iL(e){return jd=aL(e),L0=jd.format,ek=jd.formatPrefix,jd}function lL(e){return Math.max(0,-ks(Math.abs(e)))}function sL(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(ks(t)/3)))*3-ks(Math.abs(e)))}function oL(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,ks(t)-ks(e))+1}function tk(e,t,n,r){var l=jy(e,t,n),s;switch(r=_c(r??",f"),r.type){case"s":{var d=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(s=sL(l,d))&&(r.precision=s),ek(r,d)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=oL(l,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=lL(l))&&(r.precision=s-(r.type==="%")*2);break}}return L0(r)}function gi(e){var t=e.domain;return e.ticks=function(n){var r=t();return by(r[0],r[r.length-1],n??10)},e.tickFormat=function(n,r){var l=t();return tk(l[0],l[l.length-1],n??10,r)},e.nice=function(n){n==null&&(n=10);var r=t(),l=0,s=r.length-1,d=r[l],f=r[s],m,h,v=10;for(f0;){if(h=wy(d,f,n),h===m)return r[l]=d,r[s]=f,t(r);if(h>0)d=Math.floor(d/h)*h,f=Math.ceil(f/h)*h;else if(h<0)d=Math.ceil(d*h)/h,f=Math.floor(f*h)/h;else break;m=h}return e},e}function nk(){var e=$0();return e.copy=function(){return Bc(e,nk())},yr.apply(e,arguments),gi(e)}function rk(e){var t;function n(r){return r==null||isNaN(r=+r)?t:r}return n.invert=n,n.domain=n.range=function(r){return arguments.length?(e=Array.from(r,yf),n):e.slice()},n.unknown=function(r){return arguments.length?(t=r,n):t},n.copy=function(){return rk(e).unknown(t)},e=arguments.length?Array.from(e,yf):[0,1],gi(n)}function ak(e,t){e=e.slice();var n=0,r=e.length-1,l=e[n],s=e[r],d;return sMath.pow(e,t)}function mL(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function W2(e){return(t,n)=>-e(-t,n)}function B0(e){const t=e(F2,X2),n=t.domain;let r=10,l,s;function d(){return l=mL(r),s=fL(r),n()[0]<0?(l=W2(l),s=W2(s),e(cL,uL)):e(F2,X2),t}return t.base=function(f){return arguments.length?(r=+f,d()):r},t.domain=function(f){return arguments.length?(n(f),d()):n()},t.ticks=f=>{const m=n();let h=m[0],v=m[m.length-1];const y=v0){for(;b<=w;++b)for(j=1;jv)break;A.push(_)}}else for(;b<=w;++b)for(j=r-1;j>=1;--j)if(_=b>0?j/s(-b):j*s(b),!(_v)break;A.push(_)}A.length*2{if(f==null&&(f=10),m==null&&(m=r===10?"s":","),typeof m!="function"&&(!(r%1)&&(m=_c(m)).precision==null&&(m.trim=!0),m=L0(m)),f===1/0)return m;const h=Math.max(1,r*f/t.ticks().length);return v=>{let y=v/s(Math.round(l(v)));return y*rn(ak(n(),{floor:f=>s(Math.floor(l(f))),ceil:f=>s(Math.ceil(l(f)))})),t}function ik(){const e=B0(pm()).domain([1,10]);return e.copy=()=>Bc(e,ik()).base(e.base()),yr.apply(e,arguments),e}function Z2(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function Q2(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function U0(e){var t=1,n=e(Z2(t),Q2(t));return n.constant=function(r){return arguments.length?e(Z2(t=+r),Q2(t)):t},gi(n)}function lk(){var e=U0(pm());return e.copy=function(){return Bc(e,lk()).constant(e.constant())},yr.apply(e,arguments)}function J2(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function hL(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function pL(e){return e<0?-e*e:e*e}function H0(e){var t=e(_n,_n),n=1;function r(){return n===1?e(_n,_n):n===.5?e(hL,pL):e(J2(n),J2(1/n))}return t.exponent=function(l){return arguments.length?(n=+l,r()):n},gi(t)}function q0(){var e=H0(pm());return e.copy=function(){return Bc(e,q0()).exponent(e.exponent())},yr.apply(e,arguments),e}function vL(){return q0.apply(null,arguments).exponent(.5)}function eN(e){return Math.sign(e)*e*e}function yL(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function sk(){var e=$0(),t=[0,1],n=!1,r;function l(s){var d=yL(e(s));return isNaN(d)?r:n?Math.round(d):d}return l.invert=function(s){return e.invert(eN(s))},l.domain=function(s){return arguments.length?(e.domain(s),l):e.domain()},l.range=function(s){return arguments.length?(e.range((t=Array.from(s,yf)).map(eN)),l):t.slice()},l.rangeRound=function(s){return l.range(s).round(!0)},l.round=function(s){return arguments.length?(n=!!s,l):n},l.clamp=function(s){return arguments.length?(e.clamp(s),l):e.clamp()},l.unknown=function(s){return arguments.length?(r=s,l):r},l.copy=function(){return sk(e.domain(),t).round(n).clamp(e.clamp()).unknown(r)},yr.apply(l,arguments),gi(l)}function ok(){var e=[],t=[],n=[],r;function l(){var d=0,f=Math.max(1,t.length);for(n=new Array(f-1);++d0?n[f-1]:e[0],f=n?[r[n-1],t]:[r[h-1],r[h]]},d.unknown=function(m){return arguments.length&&(s=m),d},d.thresholds=function(){return r.slice()},d.copy=function(){return ck().domain([e,t]).range(l).unknown(s)},yr.apply(gi(d),arguments)}function uk(){var e=[.5],t=[0,1],n,r=1;function l(s){return s!=null&&s<=s?t[Rc(e,s,0,r)]:n}return l.domain=function(s){return arguments.length?(e=Array.from(s),r=Math.min(e.length,t.length-1),l):e.slice()},l.range=function(s){return arguments.length?(t=Array.from(s),r=Math.min(e.length,t.length-1),l):t.slice()},l.invertExtent=function(s){var d=t.indexOf(s);return[e[d-1],e[d]]},l.unknown=function(s){return arguments.length?(n=s,l):n},l.copy=function(){return uk().domain(e).range(t).unknown(n)},yr.apply(l,arguments)}const wv=new Date,jv=new Date;function Zt(e,t,n,r){function l(s){return e(s=arguments.length===0?new Date:new Date(+s)),s}return l.floor=s=>(e(s=new Date(+s)),s),l.ceil=s=>(e(s=new Date(s-1)),t(s,1),e(s),s),l.round=s=>{const d=l(s),f=l.ceil(s);return s-d(t(s=new Date(+s),d==null?1:Math.floor(d)),s),l.range=(s,d,f)=>{const m=[];if(s=l.ceil(s),f=f==null?1:Math.floor(f),!(s0))return m;let h;do m.push(h=new Date(+s)),t(s,f),e(s);while(hZt(d=>{if(d>=d)for(;e(d),!s(d);)d.setTime(d-1)},(d,f)=>{if(d>=d)if(f<0)for(;++f<=0;)for(;t(d,-1),!s(d););else for(;--f>=0;)for(;t(d,1),!s(d););}),n&&(l.count=(s,d)=>(wv.setTime(+s),jv.setTime(+d),e(wv),e(jv),Math.floor(n(wv,jv))),l.every=s=>(s=Math.floor(s),!isFinite(s)||!(s>0)?null:s>1?l.filter(r?d=>r(d)%s===0:d=>l.count(0,d)%s===0):l)),l}const bf=Zt(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);bf.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?Zt(t=>{t.setTime(Math.floor(t/e)*e)},(t,n)=>{t.setTime(+t+n*e)},(t,n)=>(n-t)/e):bf);bf.range;const ba=1e3,hr=ba*60,wa=hr*60,Oa=wa*24,K0=Oa*7,tN=Oa*30,_v=Oa*365,Zi=Zt(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*ba)},(e,t)=>(t-e)/ba,e=>e.getUTCSeconds());Zi.range;const Y0=Zt(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*ba)},(e,t)=>{e.setTime(+e+t*hr)},(e,t)=>(t-e)/hr,e=>e.getMinutes());Y0.range;const G0=Zt(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*hr)},(e,t)=>(t-e)/hr,e=>e.getUTCMinutes());G0.range;const V0=Zt(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*ba-e.getMinutes()*hr)},(e,t)=>{e.setTime(+e+t*wa)},(e,t)=>(t-e)/wa,e=>e.getHours());V0.range;const F0=Zt(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*wa)},(e,t)=>(t-e)/wa,e=>e.getUTCHours());F0.range;const Uc=Zt(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*hr)/Oa,e=>e.getDate()-1);Uc.range;const vm=Zt(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Oa,e=>e.getUTCDate()-1);vm.range;const dk=Zt(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Oa,e=>Math.floor(e/Oa));dk.range;function vl(e){return Zt(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(t,n)=>{t.setDate(t.getDate()+n*7)},(t,n)=>(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*hr)/K0)}const ym=vl(0),wf=vl(1),gL=vl(2),xL=vl(3),Cs=vl(4),bL=vl(5),wL=vl(6);ym.range;wf.range;gL.range;xL.range;Cs.range;bL.range;wL.range;function yl(e){return Zt(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCDate(t.getUTCDate()+n*7)},(t,n)=>(n-t)/K0)}const gm=yl(0),jf=yl(1),jL=yl(2),_L=yl(3),Ts=yl(4),NL=yl(5),SL=yl(6);gm.range;jf.range;jL.range;_L.range;Ts.range;NL.range;SL.range;const X0=Zt(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());X0.range;const W0=Zt(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());W0.range;const Ea=Zt(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());Ea.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Zt(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)});Ea.range;const ka=Zt(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());ka.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Zt(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)});ka.range;function fk(e,t,n,r,l,s){const d=[[Zi,1,ba],[Zi,5,5*ba],[Zi,15,15*ba],[Zi,30,30*ba],[s,1,hr],[s,5,5*hr],[s,15,15*hr],[s,30,30*hr],[l,1,wa],[l,3,3*wa],[l,6,6*wa],[l,12,12*wa],[r,1,Oa],[r,2,2*Oa],[n,1,K0],[t,1,tN],[t,3,3*tN],[e,1,_v]];function f(h,v,y){const b=vS).right(d,b);if(w===d.length)return e.every(jy(h/_v,v/_v,y));if(w===0)return bf.every(Math.max(jy(h,v,y),1));const[j,_]=d[b/d[w-1][2]53)return null;"w"in ae||(ae.w=1),"Z"in ae?(Ce=Sv(Vo(ae.y,0,1)),Y=Ce.getUTCDay(),Ce=Y>4||Y===0?jf.ceil(Ce):jf(Ce),Ce=vm.offset(Ce,(ae.V-1)*7),ae.y=Ce.getUTCFullYear(),ae.m=Ce.getUTCMonth(),ae.d=Ce.getUTCDate()+(ae.w+6)%7):(Ce=Nv(Vo(ae.y,0,1)),Y=Ce.getDay(),Ce=Y>4||Y===0?wf.ceil(Ce):wf(Ce),Ce=Uc.offset(Ce,(ae.V-1)*7),ae.y=Ce.getFullYear(),ae.m=Ce.getMonth(),ae.d=Ce.getDate()+(ae.w+6)%7)}else("W"in ae||"U"in ae)&&("w"in ae||(ae.w="u"in ae?ae.u%7:"W"in ae?1:0),Y="Z"in ae?Sv(Vo(ae.y,0,1)).getUTCDay():Nv(Vo(ae.y,0,1)).getDay(),ae.m=0,ae.d="W"in ae?(ae.w+6)%7+ae.W*7-(Y+5)%7:ae.w+ae.U*7-(Y+6)%7);return"Z"in ae?(ae.H+=ae.Z/100|0,ae.M+=ae.Z%100,Sv(ae)):Nv(ae)}}function U(V,ye,xe,ae){for(var Le=0,Ce=ye.length,Y=xe.length,ge,Pe;Le=Y)return-1;if(ge=ye.charCodeAt(Le++),ge===37){if(ge=ye.charAt(Le++),Pe=D[ge in nN?ye.charAt(Le++):ge],!Pe||(ae=Pe(V,xe,ae))<0)return-1}else if(ge!=xe.charCodeAt(ae++))return-1}return ae}function K(V,ye,xe){var ae=h.exec(ye.slice(xe));return ae?(V.p=v.get(ae[0].toLowerCase()),xe+ae[0].length):-1}function T(V,ye,xe){var ae=w.exec(ye.slice(xe));return ae?(V.w=j.get(ae[0].toLowerCase()),xe+ae[0].length):-1}function re(V,ye,xe){var ae=y.exec(ye.slice(xe));return ae?(V.w=b.get(ae[0].toLowerCase()),xe+ae[0].length):-1}function Z(V,ye,xe){var ae=A.exec(ye.slice(xe));return ae?(V.m=C.get(ae[0].toLowerCase()),xe+ae[0].length):-1}function pe(V,ye,xe){var ae=_.exec(ye.slice(xe));return ae?(V.m=S.get(ae[0].toLowerCase()),xe+ae[0].length):-1}function fe(V,ye,xe){return U(V,t,ye,xe)}function ce(V,ye,xe){return U(V,n,ye,xe)}function R(V,ye,xe){return U(V,r,ye,xe)}function z(V){return d[V.getDay()]}function G(V){return s[V.getDay()]}function se(V){return m[V.getMonth()]}function ue(V){return f[V.getMonth()]}function P(V){return l[+(V.getHours()>=12)]}function Q(V){return 1+~~(V.getMonth()/3)}function ne(V){return d[V.getUTCDay()]}function I(V){return s[V.getUTCDay()]}function he(V){return m[V.getUTCMonth()]}function be(V){return f[V.getUTCMonth()]}function _e(V){return l[+(V.getUTCHours()>=12)]}function W(V){return 1+~~(V.getUTCMonth()/3)}return{format:function(V){var ye=E(V+="",M);return ye.toString=function(){return V},ye},parse:function(V){var ye=$(V+="",!1);return ye.toString=function(){return V},ye},utcFormat:function(V){var ye=E(V+="",k);return ye.toString=function(){return V},ye},utcParse:function(V){var ye=$(V+="",!0);return ye.toString=function(){return V},ye}}}var nN={"-":"",_:" ",0:"0"},sn=/^\s*\d+/,TL=/^%/,ML=/[\\^$*+?|[\]().{}]/g;function et(e,t,n){var r=e<0?"-":"",l=(r?-e:e)+"",s=l.length;return r+(s[t.toLowerCase(),n]))}function PL(e,t,n){var r=sn.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function zL(e,t,n){var r=sn.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function IL(e,t,n){var r=sn.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function $L(e,t,n){var r=sn.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function RL(e,t,n){var r=sn.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function rN(e,t,n){var r=sn.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function aN(e,t,n){var r=sn.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function LL(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function BL(e,t,n){var r=sn.exec(t.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function UL(e,t,n){var r=sn.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function iN(e,t,n){var r=sn.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function HL(e,t,n){var r=sn.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function lN(e,t,n){var r=sn.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function qL(e,t,n){var r=sn.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function KL(e,t,n){var r=sn.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function YL(e,t,n){var r=sn.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function GL(e,t,n){var r=sn.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function VL(e,t,n){var r=TL.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function FL(e,t,n){var r=sn.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function XL(e,t,n){var r=sn.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function sN(e,t){return et(e.getDate(),t,2)}function WL(e,t){return et(e.getHours(),t,2)}function ZL(e,t){return et(e.getHours()%12||12,t,2)}function QL(e,t){return et(1+Uc.count(Ea(e),e),t,3)}function mk(e,t){return et(e.getMilliseconds(),t,3)}function JL(e,t){return mk(e,t)+"000"}function eB(e,t){return et(e.getMonth()+1,t,2)}function tB(e,t){return et(e.getMinutes(),t,2)}function nB(e,t){return et(e.getSeconds(),t,2)}function rB(e){var t=e.getDay();return t===0?7:t}function aB(e,t){return et(ym.count(Ea(e)-1,e),t,2)}function hk(e){var t=e.getDay();return t>=4||t===0?Cs(e):Cs.ceil(e)}function iB(e,t){return e=hk(e),et(Cs.count(Ea(e),e)+(Ea(e).getDay()===4),t,2)}function lB(e){return e.getDay()}function sB(e,t){return et(wf.count(Ea(e)-1,e),t,2)}function oB(e,t){return et(e.getFullYear()%100,t,2)}function cB(e,t){return e=hk(e),et(e.getFullYear()%100,t,2)}function uB(e,t){return et(e.getFullYear()%1e4,t,4)}function dB(e,t){var n=e.getDay();return e=n>=4||n===0?Cs(e):Cs.ceil(e),et(e.getFullYear()%1e4,t,4)}function fB(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+et(t/60|0,"0",2)+et(t%60,"0",2)}function oN(e,t){return et(e.getUTCDate(),t,2)}function mB(e,t){return et(e.getUTCHours(),t,2)}function hB(e,t){return et(e.getUTCHours()%12||12,t,2)}function pB(e,t){return et(1+vm.count(ka(e),e),t,3)}function pk(e,t){return et(e.getUTCMilliseconds(),t,3)}function vB(e,t){return pk(e,t)+"000"}function yB(e,t){return et(e.getUTCMonth()+1,t,2)}function gB(e,t){return et(e.getUTCMinutes(),t,2)}function xB(e,t){return et(e.getUTCSeconds(),t,2)}function bB(e){var t=e.getUTCDay();return t===0?7:t}function wB(e,t){return et(gm.count(ka(e)-1,e),t,2)}function vk(e){var t=e.getUTCDay();return t>=4||t===0?Ts(e):Ts.ceil(e)}function jB(e,t){return e=vk(e),et(Ts.count(ka(e),e)+(ka(e).getUTCDay()===4),t,2)}function _B(e){return e.getUTCDay()}function NB(e,t){return et(jf.count(ka(e)-1,e),t,2)}function SB(e,t){return et(e.getUTCFullYear()%100,t,2)}function AB(e,t){return e=vk(e),et(e.getUTCFullYear()%100,t,2)}function OB(e,t){return et(e.getUTCFullYear()%1e4,t,4)}function EB(e,t){var n=e.getUTCDay();return e=n>=4||n===0?Ts(e):Ts.ceil(e),et(e.getUTCFullYear()%1e4,t,4)}function kB(){return"+0000"}function cN(){return"%"}function uN(e){return+e}function dN(e){return Math.floor(+e/1e3)}var ss,yk,gk;CB({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function CB(e){return ss=CL(e),yk=ss.format,ss.parse,gk=ss.utcFormat,ss.utcParse,ss}function TB(e){return new Date(e)}function MB(e){return e instanceof Date?+e:+new Date(+e)}function Z0(e,t,n,r,l,s,d,f,m,h){var v=$0(),y=v.invert,b=v.domain,w=h(".%L"),j=h(":%S"),_=h("%I:%M"),S=h("%I %p"),A=h("%a %d"),C=h("%b %d"),M=h("%B"),k=h("%Y");function D(E){return(m(E)t(l/(e.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(l,s)=>b9(e,s/r))},n.copy=function(){return jk(t).domain(e)},Ma.apply(n,arguments)}function bm(){var e=0,t=.5,n=1,r=1,l,s,d,f,m,h=_n,v,y=!1,b;function w(_){return isNaN(_=+_)?b:(_=.5+((_=+v(_))-s)*(r*_{if(e!=null){var r=e.scale,l=e.type;if(r==="auto")return l==="category"&&n&&(n.indexOf("LineChart")>=0||n.indexOf("AreaChart")>=0||n.indexOf("ComposedChart")>=0&&!t)?"point":l==="category"?"band":"linear";if(typeof r=="string")return LB(r)?r:"point"}};function BB(e,t){for(var n=0,r=e.length,l=e[0]t)?n=s+1:r=s}return n}function Ek(e,t){if(e){var n=t??e.domain(),r=n.map(s=>{var d;return(d=e(s))!==null&&d!==void 0?d:0}),l=e.range();if(!(n.length===0||l.length<2))return s=>{var d,f,m=BB(r,s);if(m<=0)return n[0];if(m>=n.length)return n[n.length-1];var h=(d=r[m-1])!==null&&d!==void 0?d:0,v=(f=r[m])!==null&&f!==void 0?f:0;return Math.abs(s-h)<=Math.abs(s-v)?n[m-1]:n[m]}}}function UB(e){if(e!=null)return"invert"in e&&typeof e.invert=="function"?e.invert.bind(e):Ek(e,void 0)}function mN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function _f(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=Array(t);ne.cartesianAxis.xAxis[t],Da=(e,t)=>{var n=Ck(e,t);return n??Gt},Vt={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:Oy,hide:!0,id:0,includeHidden:!1,interval:"preserveEnd",minTickGap:5,mirror:!1,name:void 0,orientation:"left",padding:{top:0,bottom:0},reversed:!1,scale:"auto",tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:"number",unit:void 0,niceTicks:"auto",width:Cc},Tk=(e,t)=>e.cartesianAxis.yAxis[t],Pa=(e,t)=>{var n=Tk(e,t);return n??Vt},XB={domain:[0,"auto"],includeHidden:!1,reversed:!1,allowDataOverflow:!1,allowDuplicatedCategory:!1,dataKey:void 0,id:0,name:"",range:[64,64],scale:"auto",type:"number",unit:""},tg=(e,t)=>{var n=e.cartesianAxis.zAxis[t];return n??XB},Mt=(e,t,n)=>{switch(t){case"xAxis":return Da(e,n);case"yAxis":return Pa(e,n);case"zAxis":return tg(e,n);case"angleAxis":return O0(e,n);case"radiusAxis":return E0(e,n);default:throw new Error("Unexpected axis type: ".concat(t))}},WB=(e,t,n)=>{switch(t){case"xAxis":return Da(e,n);case"yAxis":return Pa(e,n);default:throw new Error("Unexpected axis type: ".concat(t))}},Hs=(e,t,n)=>{switch(t){case"xAxis":return Da(e,n);case"yAxis":return Pa(e,n);case"angleAxis":return O0(e,n);case"radiusAxis":return E0(e,n);default:throw new Error("Unexpected axis type: ".concat(t))}},Mk=e=>e.graphicalItems.cartesianItems.some(t=>t.type==="bar")||e.graphicalItems.polarItems.some(t=>t.type==="radialBar");function ng(e,t){return n=>{switch(e){case"xAxis":return"xAxisId"in n&&n.xAxisId===t;case"yAxis":return"yAxisId"in n&&n.yAxisId===t;case"zAxis":return"zAxisId"in n&&n.zAxisId===t;case"angleAxis":return"angleAxisId"in n&&n.angleAxisId===t;case"radiusAxis":return"radiusAxisId"in n&&n.radiusAxisId===t;default:return!1}}}var wm=e=>e.graphicalItems.cartesianItems,ZB=X([St,$c],ng),rg=(e,t,n)=>e.filter(n).filter(r=>(t==null?void 0:t.includeHidden)===!0?!0:!r.hide),qs=X([wm,Mt,ZB],rg,{memoizeOptions:{resultEqualityCheck:hm}}),Dk=X([qs],e=>e.filter(t=>t.type==="area"||t.type==="bar").filter(fm)),Pk=e=>e.filter(t=>!("stackId"in t)||t.stackId===void 0),QB=X([qs],Pk),ag=e=>e.map(t=>t.data).filter(Boolean).flat(1),JB=X([qs],e=>e.some(t=>!t.data)),zk=X([qs],ag,{memoizeOptions:{resultEqualityCheck:hm}}),ig=(e,t)=>{var n=t.chartData,r=n===void 0?[]:n,l=t.dataStartIndex,s=t.dataEndIndex;return e.length>0?e:r.slice(l,s+1)},lg=X([zk,sm],ig),Ik=(e,t,n)=>(t==null?void 0:t.dataKey)!=null?e.map(r=>({value:rt(r,t.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>e.map(l=>({value:rt(l,r)}))):e.map(r=>({value:r})),$k=(e,t,n,r,l,s)=>{var d=r.chartData,f=d===void 0?[]:d,m=r.dataStartIndex,h=r.dataEndIndex,v=Ik(e,t,n);if(l&&(t==null?void 0:t.dataKey)!=null&&s.length>0){var y=f.slice(m,h+1),b=y.map(w=>({value:rt(w,t.dataKey)})).filter(w=>w.value!=null);return[...b,...v]}return v},Hc=X([lg,Mt,qs,sm,JB,zk],$k);function _s(e){if(qr(e)||e instanceof Date){var t=Number(e);if(He(t))return t}}function pN(e){if(Array.isArray(e)){var t=[_s(e[0]),_s(e[1])];return Br(t)?t:void 0}var n=_s(e);if(n!=null)return[n,n]}function Gr(e){return e.map(_s).filter(Dn)}function eU(e,t){var n=_s(e),r=_s(t);return n==null&&r==null?0:n==null?-1:r==null?1:n-r}var tU=X([Hc],e=>e==null?void 0:e.map(t=>t.value).sort(eU));function Rk(e,t){switch(e){case"xAxis":return t.direction==="x";case"yAxis":return t.direction==="y";default:return!1}}function nU(e,t,n){if(!n)return[];if(!n.length)return[];var r;if(typeof t=="number"&&!Ar(t))r=t;else if(Array.isArray(t)){var l=Gr(t);l.length>0&&(r=Math.max(...l))}return r==null?[]:Gr(n.flatMap(s=>{var d=rt(e,s.dataKey),f,m;if(Array.isArray(d)){var h=kk(d,2);f=h[0],m=h[1]}else f=m=d;if(!(!He(f)||!He(m)))return[r-f,r+m]}))}var Qt=e=>{var t=ln(e),n=Bs(e);return Hs(e,t,n)},Ms=X([Qt],e=>e==null?void 0:e.dataKey),rU=X([Dk,sm,Qt],YE),Lk=(e,t,n,r)=>{var l={},s=t.reduce((d,f)=>{if(f.stackId==null)return d;var m=d[f.stackId];return m==null&&(m=[]),m.push(f),d[f.stackId]=m,d},l);return Object.fromEntries(Object.entries(s).map(d=>{var f=kk(d,2),m=f[0],h=f[1],v=r?[...h].reverse():h,y=v.map(dm);return[m,{stackedData:cI(e,y,n),graphicalItems:v}]}))},Nf=X([rU,Dk,Ic,RE],Lk),Bk=(e,t,n,r)=>{var l=t.dataStartIndex,s=t.dataEndIndex;if(r==null&&n!=="zAxis")return mI(e,l,s)},aU=X([Mt],e=>e.allowDataOverflow),sg=e=>{var t;if(e==null||!("domain"in e))return Oy;if(e.domain!=null)return e.domain;if("ticks"in e&&e.ticks!=null){if(e.type==="number"){var n=Gr(e.ticks);return[Math.min(...n),Math.max(...n)]}if(e.type==="category")return e.ticks.map(String)}return(t=e==null?void 0:e.domain)!==null&&t!==void 0?t:Oy},og=X([Mt],sg),cg=X([og,aU],SE),iU=X([Nf,kr,St,cg],Bk,{memoizeOptions:{resultEqualityCheck:mm}}),jm=e=>e.errorBars,lU=(e,t,n)=>e.flatMap(r=>t[r.id]).filter(Boolean).filter(r=>Rk(n,r)),Sf=function(){for(var t=arguments.length,n=new Array(t),r=0;r5&&arguments[5]!==void 0?arguments[5]:[],f,m;if(r.length>0&&r.forEach(h=>{var v,y=h.data!=null?[...h.data]:d,b=(v=l[h.id])===null||v===void 0?void 0:v.filter(w=>Rk(s,w));y.forEach(w=>{var j,_=rt(w,(j=n.dataKey)!==null&&j!==void 0?j:h.dataKey),S=nU(w,_,b);if(S.length>=2){var A=Math.min(...S),C=Math.max(...S);(f==null||Am)&&(m=C)}var M=pN(_);M!=null&&(f=f==null?M[0]:Math.min(f,M[0]),m=m==null?M[1]:Math.max(m,M[1]))})}),(n==null?void 0:n.dataKey)!=null&&r.length===0&&t.forEach(h=>{var v=pN(rt(h,n.dataKey));v!=null&&(f=f==null?v[0]:Math.min(f,v[0]),m=m==null?v[1]:Math.max(m,v[1]))}),He(f)&&He(m))return[f,m]},sU=X([lg,Mt,QB,jm,St,$7],ug,{memoizeOptions:{resultEqualityCheck:mm}});function oU(e){var t=e.value;if(qr(t)||t instanceof Date)return t}var cU=(e,t,n)=>{var r=e.map(oU).filter(l=>l!=null);return n&&(t.dataKey==null||t.allowDuplicatedCategory&&YA(r))?_E(0,e.length):t.allowDuplicatedCategory?r:Array.from(new Set(r))},Uk=e=>e.referenceElements.dots,Ks=(e,t,n)=>e.filter(r=>r.ifOverflow==="extendDomain").filter(r=>t==="xAxis"?r.xAxisId===n:r.yAxisId===n),uU=X([Uk,St,$c],Ks),Hk=e=>e.referenceElements.areas,dU=X([Hk,St,$c],Ks),qk=e=>e.referenceElements.lines,fU=X([qk,St,$c],Ks),Kk=(e,t)=>{if(e!=null){var n=Gr(e.map(r=>t==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},mU=X(uU,St,Kk),Yk=(e,t)=>{if(e!=null){var n=Gr(e.flatMap(r=>[t==="xAxis"?r.x1:r.y1,t==="xAxis"?r.x2:r.y2]));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},hU=X([dU,St],Yk);function pU(e){var t;if(e.x!=null)return Gr([e.x]);var n=(t=e.segment)===null||t===void 0?void 0:t.map(r=>r.x);return n==null||n.length===0?[]:Gr(n)}function vU(e){var t;if(e.y!=null)return Gr([e.y]);var n=(t=e.segment)===null||t===void 0?void 0:t.map(r=>r.y);return n==null||n.length===0?[]:Gr(n)}var Gk=(e,t)=>{if(e!=null){var n=e.flatMap(r=>t==="xAxis"?pU(r):vU(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},yU=X([fU,St],Gk),gU=X(mU,yU,hU,(e,t,n)=>Sf(e,n,t)),dg=(e,t,n,r,l,s,d,f)=>{if(n!=null)return n;var m=d==="vertical"&&f==="xAxis"||d==="horizontal"&&f==="yAxis",h=m?Sf(r,s,l):Sf(s,l);return K7(t,h,e.allowDataOverflow)},xU=X([Mt,og,cg,iU,sU,gU,Ze,St],dg,{memoizeOptions:{resultEqualityCheck:mm}}),bU=[0,1],fg=(e,t,n,r,l,s,d)=>{if(!((e==null||n==null||n.length===0)&&d===void 0)){var f=e.dataKey,m=e.type,h=Vr(t,s);if(h&&f==null){var v;return _E(0,(v=n==null?void 0:n.length)!==null&&v!==void 0?v:0)}return m==="category"?cU(r,e,h):l==="expand"&&!h?bU:d}},mg=X([Mt,Ze,lg,Hc,Ic,St,xU],fg),bi=X([Mt,Mk,N0],Ok),hg=(e,t,n)=>{var r=t.niceTicks;if(r!=="none"){var l=sg(t),s=Array.isArray(l)&&(l[0]==="auto"||l[1]==="auto");if((r==="snap125"||r==="adaptive")&&t!=null&&t.tickCount&&Br(e)){if(s)return N2(e,t.tickCount,t.allowDecimals,r);if(t.type==="number")return S2(e,t.tickCount,t.allowDecimals,r)}if(r==="auto"&&n==="linear"&&t!=null&&t.tickCount){if(s&&Br(e))return N2(e,t.tickCount,t.allowDecimals,"adaptive");if(t.type==="number"&&Br(e))return S2(e,t.tickCount,t.allowDecimals,"adaptive")}}},pg=X([mg,Hs,bi],hg),vg=(e,t,n,r)=>{if(r!=="angleAxis"&&(e==null?void 0:e.type)==="number"&&Br(t)&&Array.isArray(n)&&n.length>0){var l,s,d=t[0],f=(l=n[0])!==null&&l!==void 0?l:0,m=t[1],h=(s=n[n.length-1])!==null&&s!==void 0?s:0;return[Math.min(d,f),Math.max(m,h)]}return t},wU=X([Mt,mg,pg,St],vg),jU=X(Hc,Mt,(e,t)=>{if(!(!t||t.type!=="number")){var n=1/0,r=Array.from(Gr(e.map(y=>y.value))).sort((y,b)=>y-b),l=r[0],s=r[r.length-1];if(l==null||s==null)return 1/0;var d=s-l;if(d===0)return 1/0;for(var f=0;fl,(e,t,n,r,l)=>{if(!He(e))return 0;var s=t==="vertical"?r.height:r.width;if(l==="gap")return e*s/2;if(l==="no-gap"){var d=xn(n,e*s),f=e*s/2;return f-d-(f-d)/s*d}return 0}),_U=(e,t,n)=>{var r=Da(e,t);return r==null||typeof r.padding!="string"?0:Vk(e,"xAxis",t,n,r.padding)},NU=(e,t,n)=>{var r=Pa(e,t);return r==null||typeof r.padding!="string"?0:Vk(e,"yAxis",t,n,r.padding)},SU=X(Da,_U,(e,t)=>{var n,r;if(e==null)return{left:0,right:0};var l=e.padding;return typeof l=="string"?{left:t,right:t}:{left:((n=l.left)!==null&&n!==void 0?n:0)+t,right:((r=l.right)!==null&&r!==void 0?r:0)+t}}),AU=X(Pa,NU,(e,t)=>{var n,r;if(e==null)return{top:0,bottom:0};var l=e.padding;return typeof l=="string"?{top:t,bottom:t}:{top:((n=l.top)!==null&&n!==void 0?n:0)+t,bottom:((r=l.bottom)!==null&&r!==void 0?r:0)+t}}),Fk=X([Wt,SU,nm,tm,(e,t,n)=>n],(e,t,n,r,l)=>{var s=r.padding;return l?[s.left,n.width-s.right]:[e.left+t.left,e.left+e.width-t.right]}),Xk=X([Wt,Ze,AU,nm,tm,(e,t,n)=>n],(e,t,n,r,l,s)=>{var d=l.padding;return s?[r.height-d.bottom,d.top]:t==="horizontal"?[e.top+e.height-n.bottom,e.top+n.top]:[e.top+n.top,e.top+e.height-n.bottom]}),qc=(e,t,n,r)=>{var l;switch(t){case"xAxis":return Fk(e,n,r);case"yAxis":return Xk(e,n,r);case"zAxis":return(l=tg(e,n))===null||l===void 0?void 0:l.range;case"angleAxis":return HE(e);case"radiusAxis":return qE(e,n);default:return}},Wk=X([Mt,qc],om),OU=X([bi,wU],GE),yg=X([Mt,bi,OU,Wk],eg),Zk=(e,t,n,r)=>{if(!(n==null||n.dataKey==null)){var l=n.type,s=n.scale,d=Vr(e,r);if(d&&(l==="number"||s!=="auto"))return t.map(f=>f.value)}},gg=X([Ze,Hc,Hs,St],Zk),_m=X([yg],C0);X([yg],UB);X([yg,tU],Ek);X([qs,jm,St],lU);function Qk(e,t){return e.idt.id?1:0}var Nm=(e,t)=>t,Sm=(e,t,n)=>n,EU=X(Jf,Nm,Sm,(e,t,n)=>e.filter(r=>r.orientation===t).filter(r=>r.mirror===n).sort(Qk)),kU=X(em,Nm,Sm,(e,t,n)=>e.filter(r=>r.orientation===t).filter(r=>r.mirror===n).sort(Qk)),Jk=(e,t)=>({width:e.width,height:t.height}),CU=(e,t)=>{var n=typeof t.width=="number"?t.width:Cc;return{width:n,height:e.height}},eC=X(Wt,Da,Jk),TU=(e,t,n)=>{switch(t){case"top":return e.top;case"bottom":return n-e.bottom;default:return 0}},MU=(e,t,n)=>{switch(t){case"left":return e.left;case"right":return n-e.right;default:return 0}},DU=X(Ta,Wt,EU,Nm,Sm,(e,t,n,r,l)=>{var s={},d;return n.forEach(f=>{var m=Jk(t,f);d==null&&(d=TU(t,r,e));var h=r==="top"&&!l||r==="bottom"&&l;s[f.id]=d-Number(h)*m.height,d+=(h?-1:1)*m.height}),s}),PU=X(Ca,Wt,kU,Nm,Sm,(e,t,n,r,l)=>{var s={},d;return n.forEach(f=>{var m=CU(t,f);d==null&&(d=MU(t,r,e));var h=r==="left"&&!l||r==="right"&&l;s[f.id]=d-Number(h)*m.width,d+=(h?-1:1)*m.width}),s}),zU=(e,t)=>{var n=Da(e,t);if(n!=null)return DU(e,n.orientation,n.mirror)},IU=X([Wt,Da,zU,(e,t)=>t],(e,t,n,r)=>{if(t!=null){var l=n==null?void 0:n[r];return l==null?{x:e.left,y:0}:{x:e.left,y:l}}}),$U=(e,t)=>{var n=Pa(e,t);if(n!=null)return PU(e,n.orientation,n.mirror)},RU=X([Wt,Pa,$U,(e,t)=>t],(e,t,n,r)=>{if(t!=null){var l=n==null?void 0:n[r];return l==null?{x:0,y:e.top}:{x:l,y:e.top}}}),tC=X(Wt,Pa,(e,t)=>{var n=typeof t.width=="number"?t.width:Cc;return{width:n,height:e.height}}),vN=(e,t,n)=>{switch(t){case"xAxis":return eC(e,n).width;case"yAxis":return tC(e,n).height;default:return}},nC=(e,t,n,r)=>{if(n!=null){var l=n.allowDuplicatedCategory,s=n.type,d=n.dataKey,f=Vr(e,r),m=t.map(v=>v.value),h=m.filter(v=>v!=null);if(d&&f&&s==="category"&&l&&YA(h))return m}},xg=X([Ze,Hc,Mt,St],nC),yN=X([Ze,WB,bi,_m,xg,gg,qc,pg,St],(e,t,n,r,l,s,d,f,m)=>{if(t!=null){var h=Vr(e,m);return{angle:t.angle,interval:t.interval,minTickGap:t.minTickGap,orientation:t.orientation,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,axisType:m,categoricalDomain:s,duplicateDomain:l,isCategorical:h,niceTicks:f,range:d,realScaleType:n,scale:r}}}),LU=(e,t,n,r,l,s,d,f,m)=>{if(!(t==null||r==null)){var h=Vr(e,m),v=t.type,y=t.ticks,b=t.tickCount,w=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,j=v==="category"&&r.bandwidth?r.bandwidth()/w:0;j=m==="angleAxis"&&s!=null&&s.length>=2?rn(s[0]-s[1])*2*j:j;var _=y||l;return _?_.map((S,A)=>{var C=d?d.indexOf(S):S,M=r.map(C);return He(M)?{index:A,coordinate:M+j,value:S,offset:j}:null}).filter(Dn):h&&f?f.map((S,A)=>{var C=r.map(S);return He(C)?{coordinate:C+j,value:S,index:A,offset:j}:null}).filter(Dn):r.ticks?r.ticks(b).map((S,A)=>{var C=r.map(S);return He(C)?{coordinate:C+j,value:S,index:A,offset:j}:null}).filter(Dn):r.domain().map((S,A)=>{var C=r.map(S);return He(C)?{coordinate:C+j,value:d?d[S]:S,index:A,offset:j}:null}).filter(Dn)}},rC=X([Ze,Hs,bi,_m,pg,qc,xg,gg,St],LU),BU=(e,t,n,r,l,s,d)=>{if(!(t==null||n==null||r==null||r[0]===r[1])){var f=Vr(e,d),m=t.tickCount,h=0;return h=d==="angleAxis"&&(r==null?void 0:r.length)>=2?rn(r[0]-r[1])*2*h:h,f&&s?s.map((v,y)=>{var b=n.map(v);return He(b)?{coordinate:b+h,value:v,index:y,offset:h}:null}).filter(Dn):n.ticks?n.ticks(m).map((v,y)=>{var b=n.map(v);return He(b)?{coordinate:b+h,value:v,index:y,offset:h}:null}).filter(Dn):n.domain().map((v,y)=>{var b=n.map(v);return He(b)?{coordinate:b+h,value:l?l[v]:v,index:y,offset:h}:null}).filter(Dn)}},hi=X([Ze,Hs,_m,qc,xg,gg,St],BU),pi=X(Mt,_m,(e,t)=>{if(!(e==null||t==null))return _f(_f({},e),{},{scale:t})}),UU=X([Mt,bi,mg,Wk],eg),HU=X([UU],C0);X((e,t,n)=>tg(e,n),HU,(e,t)=>{if(!(e==null||t==null))return _f(_f({},e),{},{scale:t})});var qU=X([Ze,Jf,em],(e,t,n)=>{switch(e){case"horizontal":return t.some(r=>r.reversed)?"right-to-left":"left-to-right";case"vertical":return n.some(r=>r.reversed)?"bottom-to-top":"top-to-bottom";case"centric":case"radial":return"left-to-right";default:return}}),KU=(e,t,n)=>{var r;return(r=e.renderedTicks[t])===null||r===void 0?void 0:r[n]};X([KU],e=>{if(!(!e||e.length===0))return t=>{var n,r=1/0,l=e[0];for(var s of e){var d=Math.abs(s.coordinate-t);de.options.defaultTooltipEventType,iC=e=>e.options.validateTooltipEventTypes;function lC(e,t,n){if(e==null)return t;var r=e?"axis":"item";return n==null?t:n.includes(r)?r:t}function Kc(e,t){var n=aC(e),r=iC(e);return lC(t,n,r)}function YU(e){return Ne(t=>Kc(t,e))}var sC=(e,t)=>{var n,r=Number(t);if(!(Ar(r)||t==null))return r>=0?e==null||(n=e[r])===null||n===void 0?void 0:n.value:void 0},GU=e=>e.tooltip.settings,ui={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},VU={itemInteraction:{click:ui,hover:ui},axisInteraction:{click:ui,hover:ui},keyboardInteraction:ui,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0,graphicalItemId:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:"hover",axisId:0,active:!1,defaultIndex:void 0}},oC=bn({name:"tooltip",initialState:VU,reducers:{addTooltipEntrySettings:{reducer(e,t){e.tooltipItemPayloads.push(t.payload)},prepare:yt()},replaceTooltipEntrySettings:{reducer(e,t){var n=t.payload,r=n.prev,l=n.next,s=mr(e).tooltipItemPayloads.indexOf(r);s>-1&&(e.tooltipItemPayloads[s]=l)},prepare:yt()},removeTooltipEntrySettings:{reducer(e,t){var n=mr(e).tooltipItemPayloads.indexOf(t.payload);n>-1&&e.tooltipItemPayloads.splice(n,1)},prepare:yt()},setTooltipSettingsState(e,t){e.settings=t.payload},setActiveMouseOverItemIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.keyboardInteraction.active=!1,e.itemInteraction.hover.active=!0,e.itemInteraction.hover.index=t.payload.activeIndex,e.itemInteraction.hover.dataKey=t.payload.activeDataKey,e.itemInteraction.hover.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.hover.coordinate=t.payload.activeCoordinate},mouseLeaveChart(e){e.itemInteraction.hover.active=!1,e.axisInteraction.hover.active=!1},mouseLeaveItem(e){e.itemInteraction.hover.active=!1},setActiveClickItemIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.itemInteraction.click.active=!0,e.keyboardInteraction.active=!1,e.itemInteraction.click.index=t.payload.activeIndex,e.itemInteraction.click.dataKey=t.payload.activeDataKey,e.itemInteraction.click.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.click.coordinate=t.payload.activeCoordinate},setMouseOverAxisIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.axisInteraction.hover.active=!0,e.keyboardInteraction.active=!1,e.axisInteraction.hover.index=t.payload.activeIndex,e.axisInteraction.hover.dataKey=t.payload.activeDataKey,e.axisInteraction.hover.coordinate=t.payload.activeCoordinate},setMouseClickAxisIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.keyboardInteraction.active=!1,e.axisInteraction.click.active=!0,e.axisInteraction.click.index=t.payload.activeIndex,e.axisInteraction.click.dataKey=t.payload.activeDataKey,e.axisInteraction.click.coordinate=t.payload.activeCoordinate},setSyncInteraction(e,t){e.syncInteraction=t.payload},setKeyboardInteraction(e,t){e.keyboardInteraction.active=t.payload.active,e.keyboardInteraction.index=t.payload.activeIndex,e.keyboardInteraction.coordinate=t.payload.activeCoordinate}}}),gr=oC.actions,FU=gr.addTooltipEntrySettings,XU=gr.replaceTooltipEntrySettings,WU=gr.removeTooltipEntrySettings,ZU=gr.setTooltipSettingsState,cC=gr.setActiveMouseOverItemIndex,QU=gr.mouseLeaveItem,uC=gr.mouseLeaveChart,JU=gr.setActiveClickItemIndex,dC=gr.setMouseOverAxisIndex,eH=gr.setMouseClickAxisIndex,rc=gr.setSyncInteraction,Af=gr.setKeyboardInteraction,tH=oC.reducer;function gN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function _d(e){for(var t=1;t{if(t==null)return ui;var l=iH(e,t,n);if(l==null)return ui;if(l.active)return l;if(e.keyboardInteraction.active)return e.keyboardInteraction;if(e.syncInteraction.active&&e.syncInteraction.index!=null)return e.syncInteraction;var s=e.settings.active===!0;if(lH(l)){if(s)return _d(_d({},l),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return _d(_d({},ui),{},{coordinate:l.coordinate})};function sH(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(e instanceof Date){var t=e.valueOf();return Number.isFinite(t)?t:void 0}var n=Number(e);return Number.isFinite(n)?n:void 0}function oH(e,t){var n=sH(e),r=t[0],l=t[1];if(n===void 0)return!1;var s=Math.min(r,l),d=Math.max(r,l);return n>=s&&n<=d}function cH(e,t,n){if(n==null||t==null)return!0;var r=rt(e,t);return r==null||!Br(n)?!0:oH(r,n)}var sc=(e,t,n,r)=>{var l=e==null?void 0:e.index;if(l==null)return null;var s=Number(l);if(!He(s))return l;var d=0,f=1/0;t.length>0&&(f=t.length-1);var m=Math.max(d,Math.min(s,f)),h=t[m];return h==null||cH(h,n,r)?String(m):null},mC=(e,t,n,r,l,s,d)=>{if(s!=null){var f=d[0],m=f==null?void 0:f.getPosition(s);if(m!=null)return m;var h=l==null?void 0:l[Number(s)];if(h)switch(n){case"horizontal":return{x:h.coordinate,y:(r.top+t)/2};default:return{x:(r.left+e)/2,y:h.coordinate}}}},hC=(e,t,n,r)=>{if(t==="axis")return e.tooltipItemPayloads;if(e.tooltipItemPayloads.length===0)return[];var l;if(n==="hover"?l=e.itemInteraction.hover.graphicalItemId:l=e.itemInteraction.click.graphicalItemId,e.syncInteraction.active&&l==null)return e.tooltipItemPayloads;if(l==null&&(r!=null||e.keyboardInteraction.active)){var s=e.tooltipItemPayloads[0];return s!=null?[s]:[]}return e.tooltipItemPayloads.filter(d=>{var f;return((f=d.settings)===null||f===void 0?void 0:f.graphicalItemId)===l})},pC=e=>e.options.tooltipPayloadSearcher,Ys=e=>e.tooltip;function xN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function bN(e){for(var t=1;te(t)}function wN(e){if(typeof e=="string")return e}function vH(e){if(!(e==null||typeof e!="object")){var t="name"in e?mH(e.name):void 0,n="unit"in e?hH(e.unit):void 0,r="dataKey"in e?pH(e.dataKey):void 0,l="payload"in e?e.payload:void 0,s="color"in e?wN(e.color):void 0,d="fill"in e?wN(e.fill):void 0;return{name:t,unit:n,dataKey:r,payload:l,color:s,fill:d}}}function yH(e,t){return e??t}var vC=(e,t,n,r,l,s,d)=>{if(!(t==null||s==null)){var f=n.chartData,m=n.computedData,h=n.dataStartIndex,v=n.dataEndIndex,y=[];return e.reduce((b,w)=>{var j,_=w.dataDefinedOnItem,S=w.settings,A=yH(_,f),C=Array.isArray(A)?qO(A,h,v):A,M=(j=S==null?void 0:S.dataKey)!==null&&j!==void 0?j:r,k=S==null?void 0:S.nameKey,D;if(r&&Array.isArray(C)&&!Array.isArray(C[0])&&d==="axis"?D=GA(C,r,l):D=s(C,t,m,k),Array.isArray(D))D.forEach($=>{var U,K,T=vH($),re=T==null?void 0:T.name,Z=T==null?void 0:T.dataKey,pe=T==null?void 0:T.payload,fe=bN(bN({},S),{},{name:re,unit:T==null?void 0:T.unit,color:(U=T==null?void 0:T.color)!==null&&U!==void 0?U:S==null?void 0:S.color,fill:(K=T==null?void 0:T.fill)!==null&&K!==void 0?K:S==null?void 0:S.fill});b.push(d_({tooltipEntrySettings:fe,dataKey:Z,payload:pe,value:rt(pe,Z),name:re==null?void 0:String(re)}))});else{var E;b.push(d_({tooltipEntrySettings:S,dataKey:M,payload:D,value:rt(D,M),name:(E=rt(D,k))!==null&&E!==void 0?E:S==null?void 0:S.name}))}return b},y)}},bg=X([Qt,Mk,N0],Ok),gH=X([e=>e.graphicalItems.cartesianItems,e=>e.graphicalItems.polarItems],(e,t)=>[...e,...t]),xH=X([ln,Bs],ng),gl=X([gH,Qt,xH],rg,{memoizeOptions:{resultEqualityCheck:hm}}),bH=X([gl],e=>e.filter(fm)),yC=X([gl],ag,{memoizeOptions:{resultEqualityCheck:hm}}),wH=X([gl],e=>e.some(t=>!t.data)),ul=X([yC,kr],ig),jH=X([bH,kr,Qt],YE),wg=X([ul,Qt,gl,kr,wH,yC],$k),gC=X([Qt],sg),_H=X([Qt],e=>e.allowDataOverflow),xC=X([gC,_H],SE),NH=X([gl],e=>e.filter(fm)),SH=X([jH,NH,Ic,RE],Lk),AH=X([SH,kr,ln,xC],Bk),OH=X([gl],Pk),EH=X([ul,Qt,OH,jm,ln,L7],ug,{memoizeOptions:{resultEqualityCheck:mm}}),kH=X([Uk,ln,Bs],Ks),CH=X([kH,ln],Kk),TH=X([Hk,ln,Bs],Ks),MH=X([TH,ln],Yk),DH=X([qk,ln,Bs],Ks),PH=X([DH,ln],Gk),zH=X([CH,PH,MH],Sf),IH=X([Qt,gC,xC,AH,EH,zH,Ze,ln],dg),Ds=X([Qt,Ze,ul,wg,Ic,ln,IH],fg),$H=X([Ds,Qt,bg],hg),RH=X([Qt,Ds,$H,ln],vg),bC=e=>{var t=ln(e),n=Bs(e),r=!1;return qc(e,t,n,r)},wC=X([Qt,bC],om),LH=X([Qt,bg,RH,wC],eg),jC=X([LH],C0),BH=X([Ze,wg,Qt,ln],nC),UH=X([Ze,wg,Qt,ln],Zk),HH=(e,t,n,r,l,s,d,f)=>{if(t){var m=t.type,h=Vr(e,f);if(r){var v=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,y=m==="category"&&r.bandwidth?r.bandwidth()/v:0;return y=f==="angleAxis"&&l!=null&&(l==null?void 0:l.length)>=2?rn(l[0]-l[1])*2*y:y,h&&d?d.map((b,w)=>{var j=r.map(b);return He(j)?{coordinate:j+y,value:b,index:w,offset:y}:null}).filter(Dn):r.domain().map((b,w)=>{var j=r.map(b);return He(j)?{coordinate:j+y,value:s?s[b]:b,index:w,offset:y}:null}).filter(Dn)}}},za=X([Ze,Qt,bg,jC,bC,BH,UH,ln],HH),jg=X([aC,iC,GU],(e,t,n)=>lC(n.shared,e,t)),_C=e=>e.tooltip.settings.trigger,_g=e=>e.tooltip.settings.defaultIndex,Yc=X([Ys,jg,_C,_g],fC),vi=X([Yc,ul,Ms,Ds],sc),NC=X([za,vi],sC),Ng=X([Yc],e=>{if(e)return e.dataKey}),SC=X([Yc],e=>{if(e)return e.graphicalItemId}),AC=X([Ys,jg,_C,_g],hC),qH=X([Ca,Ta,Ze,Wt,za,_g,AC],mC),KH=X([Yc,qH],(e,t)=>e!=null&&e.coordinate?e.coordinate:t),YH=X([Yc],e=>{var t;return(t=e==null?void 0:e.active)!==null&&t!==void 0?t:!1}),GH=X([AC,vi,kr,Ms,NC,pC,jg],vC),VH=X([GH],e=>{if(e!=null){var t=e.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(t))}});function jN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function _N(e){for(var t=1;tNe(Qt),QH=()=>{var e=ZH(),t=Ne(za),n=Ne(jC);return As(!e||!n?void 0:_N(_N({},e),{},{scale:n}),t)};function NN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function os(e){for(var t=1;t{var l=t.find(s=>s&&s.index===n);if(l){if(e==="horizontal")return{x:l.coordinate,y:r.relativeY};if(e==="vertical")return{x:r.relativeX,y:l.coordinate}}return{x:0,y:0}},rq=(e,t,n,r)=>{var l=t.find(h=>h&&h.index===n);if(l){if(e==="centric"){var s=l.coordinate,d=r.radius;return os(os(os({},r),Ht(r.cx,r.cy,d,s)),{},{angle:s,radius:d})}var f=l.coordinate,m=r.angle;return os(os(os({},r),Ht(r.cx,r.cy,f,m)),{},{angle:m,radius:f})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function aq(e,t){var n=e.relativeX,r=e.relativeY;return n>=t.left&&n<=t.left+t.width&&r>=t.top&&r<=t.top+t.height}var OC=(e,t,n,r,l)=>{var s,d=(s=t==null?void 0:t.length)!==null&&s!==void 0?s:0;if(d<=1||e==null)return 0;if(r==="angleAxis"&&l!=null&&Math.abs(Math.abs(l[1]-l[0])-360)<=1e-6)for(var f=0;f0?(m=n[f-1])===null||m===void 0?void 0:m.coordinate:(h=n[d-1])===null||h===void 0?void 0:h.coordinate,j=(v=n[f])===null||v===void 0?void 0:v.coordinate,_=f>=d-1?(y=n[0])===null||y===void 0?void 0:y.coordinate:(b=n[f+1])===null||b===void 0?void 0:b.coordinate,S=void 0;if(!(w==null||j==null||_==null))if(rn(j-w)!==rn(_-j)){var A=[];if(rn(_-j)===rn(l[1]-l[0])){S=_;var C=j+l[1]-l[0];A[0]=Math.min(C,(C+w)/2),A[1]=Math.max(C,(C+w)/2)}else{S=w;var M=_+l[1]-l[0];A[0]=Math.min(j,(M+j)/2),A[1]=Math.max(j,(M+j)/2)}var k=[Math.min(j,(S+j)/2),Math.max(j,(S+j)/2)];if(e>k[0]&&e<=k[1]||e>=A[0]&&e<=A[1]){var D;return(D=n[f])===null||D===void 0?void 0:D.index}}else{var E=Math.min(w,_),$=Math.max(w,_);if(e>(E+j)/2&&e<=($+j)/2){var U;return(U=n[f])===null||U===void 0?void 0:U.index}}}else if(t)for(var K=0;K(T.coordinate+Z.coordinate)/2||K>0&&K(T.coordinate+Z.coordinate)/2&&e<=(T.coordinate+re.coordinate)/2)return T.index}}return-1},EC=()=>Ne(N0),Sg=(e,t)=>t,kC=(e,t,n)=>n,Ag=(e,t,n,r)=>r,iq=X(za,e=>Hf(e,t=>t.coordinate)),Og=X([Ys,Sg,kC,Ag],fC),Eg=X([Og,ul,Ms,Ds],sc),lq=(e,t,n)=>{if(t!=null){var r=Ys(e);return t==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},CC=X([Ys,Sg,kC,Ag],hC),Of=X([Ca,Ta,Ze,Wt,za,Ag,CC],mC),sq=X([Og,Of],(e,t)=>{var n;return(n=e.coordinate)!==null&&n!==void 0?n:t}),TC=X([za,Eg],sC),oq=X([CC,Eg,kr,Ms,TC,pC,Sg],vC),cq=X([Og,Eg],(e,t)=>({isActive:e.active&&t!=null,activeIndex:t})),uq=(e,t,n,r,l,s,d)=>{if(!(!e||!n||!r||!l)&&aq(e,d)){var f=hI(e,t),m=OC(f,s,l,n,r),h=nq(t,l,m,e);return{activeIndex:String(m),activeCoordinate:h}}},dq=(e,t,n,r,l,s,d)=>{if(!(!e||!r||!l||!s||!n)){var f=T7(e,n);if(f){var m=pI(f,t),h=OC(m,d,s,r,l),v=rq(t,s,h,f);return{activeIndex:String(h),activeCoordinate:v}}}},fq=(e,t,n,r,l,s,d,f)=>{if(!(!e||!t||!r||!l||!s))return t==="horizontal"||t==="vertical"?uq(e,t,r,l,s,d,f):dq(e,t,n,r,l,s,d)},mq=X(e=>e.zIndex.zIndexMap,(e,t)=>t,(e,t,n)=>n,(e,t,n)=>{if(t!=null){var r=e[t];if(r!=null)return n?r.panoramaElement:r.element}}),hq=X(e=>e.zIndex.zIndexMap,e=>{var t=Object.keys(e).map(r=>parseInt(r,10)).concat(Object.values(qt)),n=Array.from(new Set(t));return n.sort((r,l)=>r-l)},{memoizeOptions:{resultEqualityCheck:o9}});function SN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function AN(e){for(var t=1;tAN(AN({},e),{},{[t]:{element:void 0,panoramaElement:void 0,consumers:0}}),gq)},bq=new Set(Object.values(qt));function wq(e){return bq.has(e)}var MC=bn({name:"zIndex",initialState:xq,reducers:{registerZIndexPortal:{reducer:(e,t)=>{var n=t.payload.zIndex;e.zIndexMap[n]?e.zIndexMap[n].consumers+=1:e.zIndexMap[n]={consumers:1,element:void 0,panoramaElement:void 0}},prepare:yt()},unregisterZIndexPortal:{reducer:(e,t)=>{var n=t.payload.zIndex;e.zIndexMap[n]&&(e.zIndexMap[n].consumers-=1,e.zIndexMap[n].consumers<=0&&!wq(n)&&delete e.zIndexMap[n])},prepare:yt()},registerZIndexPortalElement:{reducer:(e,t)=>{var n=t.payload,r=n.zIndex,l=n.element,s=n.isPanorama;e.zIndexMap[r]?s?e.zIndexMap[r].panoramaElement=l:e.zIndexMap[r].element=l:e.zIndexMap[r]={consumers:0,element:s?void 0:l,panoramaElement:s?l:void 0}},prepare:yt()},unregisterZIndexPortalElement:{reducer:(e,t)=>{var n=t.payload.zIndex;e.zIndexMap[n]&&(t.payload.isPanorama?e.zIndexMap[n].panoramaElement=void 0:e.zIndexMap[n].element=void 0)},prepare:yt()}}}),Am=MC.actions,jq=Am.registerZIndexPortal,Av=Am.unregisterZIndexPortal,_q=Am.registerZIndexPortalElement,Nq=Am.unregisterZIndexPortalElement,Sq=MC.reducer;function In(e){var t=e.zIndex,n=e.children,r=QI(),l=r&&t!==void 0&&t!==0,s=wn(),d=x.useRef(void 0),f=x.useRef(new Set),m=dt(),h=Ne(y=>mq(y,t,s));if(x.useLayoutEffect(()=>{if(!l){var y=f.current;y.forEach(w=>{m(Av({zIndex:w}))}),y.clear(),d.current=void 0;return}if(f.current.has(t)||(m(jq({zIndex:t})),f.current.add(t)),h){d.current=h;var b=f.current;b.forEach(w=>{w!==t&&(m(Av({zIndex:w})),b.delete(w))})}},[m,t,l,h]),x.useLayoutEffect(()=>{var y=f.current;return()=>{y.forEach(b=>{m(Av({zIndex:b}))}),y.clear()}},[m]),!l)return n;var v=h??d.current;return v?It.createPortal(n,v):null}function Ey(){return Ey=Object.assign?Object.assign.bind():function(e){for(var t=1;tx.useContext(DC),Ov={exports:{}},EN;function Dq(){return EN||(EN=1,(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function l(m,h,v){this.fn=m,this.context=h,this.once=v||!1}function s(m,h,v,y,b){if(typeof v!="function")throw new TypeError("The listener must be a function");var w=new l(v,y||m,b),j=n?n+h:h;return m._events[j]?m._events[j].fn?m._events[j]=[m._events[j],w]:m._events[j].push(w):(m._events[j]=w,m._eventsCount++),m}function d(m,h){--m._eventsCount===0?m._events=new r:delete m._events[h]}function f(){this._events=new r,this._eventsCount=0}f.prototype.eventNames=function(){var h=[],v,y;if(this._eventsCount===0)return h;for(y in v=this._events)t.call(v,y)&&h.push(n?y.slice(1):y);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(v)):h},f.prototype.listeners=function(h){var v=n?n+h:h,y=this._events[v];if(!y)return[];if(y.fn)return[y.fn];for(var b=0,w=y.length,j=new Array(w);b{if(t&&Array.isArray(e)){var n=Number.parseInt(t,10);if(!Ar(n))return e[n]}},Iq={chartName:"",tooltipPayloadSearcher:()=>{},eventEmitter:void 0,defaultTooltipEventType:"axis"},PC=bn({name:"options",initialState:Iq,reducers:{createEventEmitter:e=>{e.eventEmitter==null&&(e.eventEmitter=Symbol("rechartsEventEmitter"))}}}),$q=PC.reducer,Rq=PC.actions.createEventEmitter;function Lq(e){return e.tooltip.syncInteraction}var Bq={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},zC=bn({name:"chartData",initialState:Bq,reducers:{setChartData(e,t){if(e.chartData=t.payload,t.payload==null){e.dataStartIndex=0,e.dataEndIndex=0;return}t.payload.length>0&&e.dataEndIndex!==t.payload.length-1&&(e.dataEndIndex=t.payload.length-1)},setComputedData(e,t){e.computedData=t.payload},setDataStartEndIndexes(e,t){var n=t.payload,r=n.startIndex,l=n.endIndex;r!=null&&(e.dataStartIndex=r),l!=null&&(e.dataEndIndex=l)}}}),Cg=zC.actions,CN=Cg.setChartData,Uq=Cg.setDataStartEndIndexes;Cg.setComputedData;var Hq=zC.reducer,qq=["x","y"];function TN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function cs(e){for(var t=1;tm.rootProps.className);x.useEffect(()=>{if(e==null)return hl;var m=(h,v,y)=>{if(t!==y&&e===h){if(v.payload.active===!1){n(rc({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}if(r==="index"){var b;if(d&&v!==null&&v!==void 0&&(b=v.payload)!==null&&b!==void 0&&b.coordinate&&v.payload.sourceViewBox){var w=v.payload.coordinate,j=w.x,_=w.y,S=Vq(w,qq),A=v.payload.sourceViewBox,C=A.x,M=A.y,k=A.width,D=A.height,E=cs(cs({},S),{},{x:d.x+(k?(j-C)/k:0)*d.width,y:d.y+(D?(_-M)/D:0)*d.height});n(cs(cs({},v),{},{payload:cs(cs({},v.payload),{},{coordinate:E})}))}else n(v);return}if(l!=null){var $;if(typeof r=="function"){var U={activeTooltipIndex:v.payload.index==null?void 0:Number(v.payload.index),isTooltipActive:v.payload.active,activeIndex:v.payload.index==null?void 0:Number(v.payload.index),activeLabel:v.payload.label,activeDataKey:v.payload.dataKey,activeCoordinate:v.payload.coordinate},K=r(l,U);$=l[K]}else r==="value"&&($=l.find(z=>String(z.value)===v.payload.label));var T=v.payload.coordinate;if(T==null||d==null){n(rc({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}if($==null){n(rc({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:v.payload.sourceViewBox,graphicalItemId:void 0}));return}var re=T.x,Z=T.y,pe=Math.min(re,d.x+d.width),fe=Math.min(Z,d.y+d.height),ce={x:s==="horizontal"?$.coordinate:pe,y:s==="horizontal"?fe:$.coordinate},R=rc({active:v.payload.active,coordinate:ce,dataKey:v.payload.dataKey,index:String($.index),label:v.payload.label,sourceViewBox:v.payload.sourceViewBox,graphicalItemId:v.payload.graphicalItemId});n(R)}}};return Nc.on(ky,m),()=>{Nc.off(ky,m)}},[f,n,t,e,r,l,s,d])}function Wq(){var e=Ne(S0),t=Ne(A0),n=dt();x.useEffect(()=>{if(e==null)return hl;var r=(l,s,d)=>{t!==d&&e===l&&n(Uq(s))};return Nc.on(kN,r),()=>{Nc.off(kN,r)}},[n,t,e])}function Zq(){var e=dt();x.useEffect(()=>{e(Rq())},[e]),Xq(),Wq()}function Qq(e,t,n,r,l,s){var d=Ne(j=>lq(j,e,t)),f=Ne(SC),m=Ne(A0),h=Ne(S0),v=Ne(LE),y=Ne(Lq),b=(y==null?void 0:y.sourceViewBox)!=null,w=rm();x.useEffect(()=>{if(!b&&h!=null&&m!=null){var j=rc({active:s,coordinate:n,dataKey:d,index:l,label:typeof r=="number"?String(r):r,sourceViewBox:w,graphicalItemId:f});Nc.emit(ky,h,j,m)}},[b,n,d,f,l,r,m,h,v,s,w])}function MN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function DN(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=Array(t);n{$(ZU({shared:C,trigger:M,axisId:E,active:l,defaultIndex:U}))},[$,C,M,E,l,U]);var K=rm(),T=fE(),re=YU(C),Z=(t=Ne(xe=>cq(xe,re,M,U)))!==null&&t!==void 0?t:{},pe=Z.activeIndex,fe=Z.isActive,ce=Ne(xe=>oq(xe,re,M,U)),R=Ne(xe=>TC(xe,re,M,U)),z=Ne(xe=>sq(xe,re,M,U)),G=ce,se=Mq(),ue=(n=l??fe)!==null&&n!==void 0?n:!1,P=mO([G,ue]),Q=nK(P,2),ne=Q[0],I=Q[1],he=re==="axis"?R:void 0;Qq(re,M,z,he,pe,ue);var be=D??se;if(be==null||K==null||re==null)return null;var _e=G??zN;ue||(_e=zN),h&&_e.length&&(_e=oO(_e.filter(xe=>xe.value!=null&&(xe.hide!==!0||r.includeHidden)),b,sK));var W=_e.length>0,V=DN(DN({},r),{},{payload:_e,label:he,active:ue,activeIndex:pe,coordinate:z,accessibilityLayer:T}),ye=x.createElement(OR,{allowEscapeViewBox:s,animationDuration:d,animationEasing:f,isAnimationActive:v,active:ue,coordinate:z,hasPayload:W,offset:y,position:w,reverseDirection:j,useTranslate3d:_,viewBox:K,wrapperStyle:S,lastBoundingBox:ne,innerRef:I,hasPortalFromProps:!!D},oK(m,V));return x.createElement(x.Fragment,null,It.createPortal(ye,be),ue&&x.createElement(Tq,{cursor:A,tooltipEventType:re,coordinate:z,payload:_e,index:pe}))}var nl=e=>null;nl.displayName="Cell";function uK(e,t,n){return(t=dK(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function dK(e){var t=fK(e,"string");return typeof t=="symbol"?t:t+""}function fK(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}class mK{constructor(t){uK(this,"cache",new Map),this.maxSize=t}get(t){var n=this.cache.get(t);return n!==void 0&&(this.cache.delete(t),this.cache.set(t,n)),n}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.maxSize){var r=this.cache.keys().next().value;r!=null&&this.cache.delete(r)}this.cache.set(t,n)}clear(){this.cache.clear()}size(){return this.cache.size}}function IN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function hK(e){for(var t=1;t{try{var n=document.getElementById(RN);n||(n=document.createElement("span"),n.setAttribute("id",RN),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,xK,t),n.textContent="".concat(e);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},oc=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t==null||Pc.isSsr)return{width:0,height:0};if(!IC.enableCache)return LN(t,n);var r=bK(t,n),l=$N.get(r);if(l)return l;var s=LN(t,n);return $N.set(r,s),s},$C;function Ef(e,t){return NK(e)||_K(e,t)||jK(e,t)||wK()}function wK(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function jK(e,t){if(e){if(typeof e=="string")return BN(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?BN(e,t):void 0}}function BN(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);ne.length)&&(t=e.length);for(var n=0,r=Array(t);n{var t=e.children,n=e.breakAll,r=e.style;try{var l=[];Nt(t)||(n?l=t.toString().split(""):l=t.toString().split(LC));var s=l.map(f=>({word:f,width:oc(f,r).width})),d=n?0:oc(" ",r).width;return{wordsWithComputedWidth:s,spaceWidth:d}}catch{return null}};function UC(e){return e==="start"||e==="middle"||e==="end"||e==="inherit"}function KK(e){return Nt(e)||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}var HC=(e,t,n,r)=>e.reduce((l,s)=>{var d=s.word,f=s.width,m=l[l.length-1];if(m&&f!=null&&(t==null||r||m.width+f+ne.reduce((t,n)=>t.width>n.width?t:n),YK="…",VN=(e,t,n,r,l,s,d,f)=>{var m=e.slice(0,t),h=BC({breakAll:n,style:r,children:m+YK});if(!h)return[!1,[]];var v=HC(h.wordsWithComputedWidth,s,d,f),y=v.length>l||qC(v).width>Number(s);return[y,v]},GK=(e,t,n,r,l)=>{var s=e.maxLines,d=e.children,f=e.style,m=e.breakAll,h=je(s),v=String(d),y=HC(t,r,n,l);if(!h||l)return y;var b=y.length>s||qC(y).width>Number(r);if(!b)return y;for(var w=0,j=v.length-1,_=0,S;w<=j&&_<=v.length-1;){var A=Math.floor((w+j)/2),C=A-1,M=VN(v,C,m,f,s,r,n,l),k=YN(M,2),D=k[0],E=k[1],$=VN(v,A,m,f,s,r,n,l),U=YN($,1),K=U[0];if(!D&&!K&&(w=A+1),D&&K&&(j=A-1),!D&&K){S=E;break}_++}return S||y},FN=e=>{var t=Nt(e)?[]:e.toString().split(LC);return[{words:t,width:void 0}]},VK=e=>{var t=e.width,n=e.scaleToFit,r=e.children,l=e.style,s=e.breakAll,d=e.maxLines;if((t||n)&&!Pc.isSsr){var f,m,h=BC({breakAll:s,children:r,style:l});if(h){var v=h.wordsWithComputedWidth,y=h.spaceWidth;f=v,m=y}else return FN(r);return GK({breakAll:s,children:r,maxLines:d,style:l},f,m,t,!!n)}return FN(r)},KC="#808080",FK={angle:0,breakAll:!1,capHeight:"0.71em",fill:KC,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},Om=x.forwardRef((e,t)=>{var n=an(e,FK),r=n.x,l=n.y,s=n.lineHeight,d=n.capHeight,f=n.fill,m=n.scaleToFit,h=n.textAnchor,v=n.verticalAnchor,y=KN(n,$K),b=x.useMemo(()=>VK({breakAll:y.breakAll,children:y.children,maxLines:y.maxLines,scaleToFit:m,style:y.style,width:y.width}),[y.breakAll,y.children,y.maxLines,m,y.style,y.width]),w=y.dx,j=y.dy,_=y.angle,S=y.className,A=y.breakAll,C=KN(y,RK);if(!qr(r)||!qr(l)||b.length===0)return null;var M=Number(r)+(je(w)?w:0),k=Number(l)+(je(j)?j:0);if(!He(M)||!He(k))return null;var D;switch(v){case"start":D=kv("calc(".concat(d,")"));break;case"middle":D=kv("calc(".concat((b.length-1)/2," * -").concat(s," + (").concat(d," / 2))"));break;default:D=kv("calc(".concat(b.length-1," * -").concat(s,")"));break}var E=[],$=b[0];if(m&&$!=null){var U=$.width,K=y.width;E.push("scale(".concat(je(K)&&je(U)?K/U:1,")"))}return _&&E.push("rotate(".concat(_,", ").concat(M,", ").concat(k,")")),E.length&&(C.transform=E.join(" ")),x.createElement("text",Cy({},Xn(C),{ref:t,x:M,y:k,className:nt("recharts-text",S),textAnchor:h,fill:f.includes("url")?KC:f}),b.map((T,re)=>{var Z=T.words.join(A?"":" ");return x.createElement("tspan",{x:M,dy:re===0?D:s,key:"".concat(Z,"-").concat(re)},Z)}))});Om.displayName="Text";function XN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function $r(e){for(var t=1;t{var t=e.viewBox,n=e.position,r=e.offset,l=r===void 0?0:r,s=e.parentViewBox,d=m0(t),f=d.x,m=d.y,h=d.height,v=d.upperWidth,y=d.lowerWidth,b=f,w=f+(v-y)/2,j=(b+w)/2,_=(v+y)/2,S=b+v/2,A=h>=0?1:-1,C=A*l,M=A>0?"end":"start",k=A>0?"start":"end",D=v>=0?1:-1,E=D*l,$=D>0?"end":"start",U=D>0?"start":"end",K=s;if(n==="top"){var T={x:b+v/2,y:m-C,horizontalAnchor:"middle",verticalAnchor:M};return K&&(T.height=Math.max(m-K.y,0),T.width=v),T}if(n==="bottom"){var re={x:w+y/2,y:m+h+C,horizontalAnchor:"middle",verticalAnchor:k};return K&&(re.height=Math.max(K.y+K.height-(m+h),0),re.width=y),re}if(n==="left"){var Z={x:j-E,y:m+h/2,horizontalAnchor:$,verticalAnchor:"middle"};return K&&(Z.width=Math.max(Z.x-K.x,0),Z.height=h),Z}if(n==="right"){var pe={x:j+_+E,y:m+h/2,horizontalAnchor:U,verticalAnchor:"middle"};return K&&(pe.width=Math.max(K.x+K.width-pe.x,0),pe.height=h),pe}var fe=K?{width:_,height:h}:{};return n==="insideLeft"?$r({x:j+E,y:m+h/2,horizontalAnchor:U,verticalAnchor:"middle"},fe):n==="insideRight"?$r({x:j+_-E,y:m+h/2,horizontalAnchor:$,verticalAnchor:"middle"},fe):n==="insideTop"?$r({x:b+v/2,y:m+C,horizontalAnchor:"middle",verticalAnchor:k},fe):n==="insideBottom"?$r({x:w+y/2,y:m+h-C,horizontalAnchor:"middle",verticalAnchor:M},fe):n==="insideTopLeft"?$r({x:b+E,y:m+C,horizontalAnchor:U,verticalAnchor:k},fe):n==="insideTopRight"?$r({x:b+v-E,y:m+C,horizontalAnchor:$,verticalAnchor:k},fe):n==="insideBottomLeft"?$r({x:w+E,y:m+h-C,horizontalAnchor:U,verticalAnchor:M},fe):n==="insideBottomRight"?$r({x:w+y-E,y:m+h-C,horizontalAnchor:$,verticalAnchor:M},fe):n&&typeof n=="object"&&(je(n.x)||il(n.x))&&(je(n.y)||il(n.y))?$r({x:f+xn(n.x,_),y:m+xn(n.y,h),horizontalAnchor:"end",verticalAnchor:"end"},fe):$r({x:S,y:m+h/2,horizontalAnchor:"middle",verticalAnchor:"middle"},fe)},JK=["labelRef"],eY=["content"];function WN(e,t){if(e==null)return{};var n,r,l=tY(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r{var t=e.x,n=e.y,r=e.upperWidth,l=e.lowerWidth,s=e.width,d=e.height,f=e.children,m=x.useMemo(()=>({x:t,y:n,upperWidth:r,lowerWidth:l,width:s,height:d}),[t,n,r,l,s,d]);return x.createElement(YC.Provider,{value:m},f)},GC=()=>{var e=x.useContext(YC),t=rm();return e||(t?m0(t):void 0)},lY=x.createContext(null),sY=()=>{var e=x.useContext(lY),t=Ne(KE);return e||t},oY=e=>{var t=e.value,n=e.formatter,r=Nt(e.children)?t:e.children;return typeof n=="function"?n(r):r},Tg=e=>e!=null&&typeof e=="function",cY=(e,t)=>{var n=rn(t-e),r=Math.min(Math.abs(t-e),360);return n*r},uY=(e,t,n,r,l)=>{var s=e.offset,d=e.className,f=l.cx,m=l.cy,h=l.innerRadius,v=l.outerRadius,y=l.startAngle,b=l.endAngle,w=l.clockWise,j=(h+v)/2,_=cY(y,b),S=_>=0?1:-1,A,C;switch(t){case"insideStart":A=y+S*s,C=w;break;case"insideEnd":A=b-S*s,C=!w;break;case"end":A=b+S*s,C=w;break;default:throw new Error("Unsupported position ".concat(t))}C=_<=0?C:!C;var M=Ht(f,m,j,A),k=Ht(f,m,j,A+(C?1:-1)*359),D="M".concat(M.x,",").concat(M.y,` - A`).concat(j,",").concat(j,",0,1,").concat(C?0:1,`, - `).concat(k.x,",").concat(k.y),E=Nt(e.id)?dc("recharts-radial-line-"):e.id;return x.createElement("text",ga({},r,{dominantBaseline:"central",className:nt("recharts-radial-bar-label",d)}),x.createElement("defs",null,x.createElement("path",{id:E,d:D})),x.createElement("textPath",{xlinkHref:"#".concat(E)},n))},dY=(e,t,n)=>{var r=e.cx,l=e.cy,s=e.innerRadius,d=e.outerRadius,f=e.startAngle,m=e.endAngle,h=(f+m)/2;if(n==="outside"){var v=Ht(r,l,d+t,h),y=v.x,b=v.y;return{x:y,y:b,textAnchor:y>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:l,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:l,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:l,textAnchor:"middle",verticalAnchor:"end"};var w=(s+d)/2,j=Ht(r,l,w,h),_=j.x,S=j.y;return{x:_,y:S,textAnchor:"middle",verticalAnchor:"middle"}},zd=e=>e!=null&&"cx"in e&&je(e.cx),fY={angle:0,offset:5,zIndex:qt.label,position:"middle",textBreakAll:!1};function mY(e){if(!zd(e))return e;var t=e.cx,n=e.cy,r=e.outerRadius,l=r*2;return{x:t-r,y:n-r,width:l,upperWidth:l,lowerWidth:l,height:l}}function oi(e){var t=an(e,fY),n=t.viewBox,r=t.parentViewBox,l=t.position,s=t.value,d=t.children,f=t.content,m=t.className,h=m===void 0?"":m,v=t.textBreakAll,y=t.labelRef,b=sY(),w=GC(),j=l==="center"?w:b??w,_,S,A;n==null?_=j:zd(n)?_=n:_=m0(n);var C=mY(_);if(!_||Nt(s)&&Nt(d)&&!x.isValidElement(f)&&typeof f!="function")return null;var M=ac(ac({},t),{},{viewBox:_});if(x.isValidElement(f)){M.labelRef;var k=WN(M,JK);return x.cloneElement(f,k)}if(typeof f=="function"){M.content;var D=WN(M,eY);if(S=x.createElement(f,D),x.isValidElement(S))return S}else S=oY(t);var E=Xn(t);if(zd(_)){if(l==="insideStart"||l==="insideEnd"||l==="end")return uY(t,l,S,E,_);A=dY(_,t.offset,t.position)}else{if(!C)return null;var $=QK({viewBox:C,position:l,offset:t.offset,parentViewBox:zd(r)?void 0:r});A=ac(ac({x:$.x,y:$.y,textAnchor:$.horizontalAnchor,verticalAnchor:$.verticalAnchor},$.width!==void 0?{width:$.width}:{}),$.height!==void 0?{height:$.height}:{})}return x.createElement(In,{zIndex:t.zIndex},x.createElement(Om,ga({ref:y,className:nt("recharts-label",h)},E,A,{textAnchor:UC(E.textAnchor)?E.textAnchor:A.textAnchor,breakAll:v}),S))}oi.displayName="Label";var hY=(e,t,n)=>{if(!e)return null;var r={viewBox:t,labelRef:n};return e===!0?x.createElement(oi,ga({key:"label-implicit"},r)):qr(e)?x.createElement(oi,ga({key:"label-implicit",value:e},r)):x.isValidElement(e)?e.type===oi?x.cloneElement(e,ac({key:"label-implicit"},r)):x.createElement(oi,ga({key:"label-implicit",content:e},r)):Tg(e)?x.createElement(oi,ga({key:"label-implicit",content:e},r)):e&&typeof e=="object"?x.createElement(oi,ga({},e,{key:"label-implicit"},r)):null};function pY(e){var t=e.label,n=e.labelRef,r=GC();return hY(t,r,n)||null}var vY=["valueAccessor"],yY=["dataKey","clockWise","id","textBreakAll","zIndex"];function kf(){return kf=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t=Array.isArray(e.value)?e.value[e.value.length-1]:e.value;if(KK(t))return t},VC=x.createContext(void 0),FC=VC.Provider,XC=x.createContext(void 0),bY=XC.Provider;function wY(){return x.useContext(VC)}function jY(){return x.useContext(XC)}function Id(e){var t=e.valueAccessor,n=t===void 0?xY:t,r=QN(e,vY),l=r.dataKey;r.clockWise;var s=r.id,d=r.textBreakAll,f=r.zIndex,m=QN(r,yY),h=wY(),v=jY(),y=h||v;return!y||!y.length?null:x.createElement(In,{zIndex:f??qt.label},x.createElement(Ct,{className:"recharts-label-list"},y.map((b,w)=>{var j,_=Nt(l)?n(b,w):rt(b.payload,l),S=Nt(s)?{}:{id:"".concat(s,"-").concat(w)};return x.createElement(oi,kf({key:"label-".concat(w)},Xn(b),m,S,{fill:(j=r.fill)!==null&&j!==void 0?j:b.fill,parentViewBox:b.parentViewBox,value:_,textBreakAll:d,viewBox:b.viewBox,index:w,zIndex:0}))})))}Id.displayName="LabelList";function Mg(e){var t=e.label;return t?t===!0?x.createElement(Id,{key:"labelList-implicit"}):x.isValidElement(t)||Tg(t)?x.createElement(Id,{key:"labelList-implicit",content:t}):typeof t=="object"?x.createElement(Id,kf({key:"labelList-implicit"},t,{type:String(t.type)})):null:null}function Ty(){return Ty=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t=e.cx,n=e.cy,r=e.r,l=e.className,s=nt("recharts-dot",l);return je(t)&&je(n)&&je(r)?x.createElement("circle",Ty({},zn(e),n0(e),{className:s,cx:t,cy:n,r})):null},ZC=e=>e.graphicalItems.polarItems,_Y=X([St,$c],ng),Em=X([ZC,Mt,_Y],rg),NY=X([Em],ag),km=X([NY,zc],ig),SY=X([km,Mt,Em],Ik);X([km,Mt,Em],(e,t,n)=>n.length>0?e.flatMap(r=>n.flatMap(l=>{var s,d=rt(r,(s=t.dataKey)!==null&&s!==void 0?s:l.dataKey);return{value:d,errorDomain:[]}})).filter(Boolean):(t==null?void 0:t.dataKey)!=null?e.map(r=>({value:rt(r,t.dataKey),errorDomain:[]})):e.map(r=>({value:r,errorDomain:[]})));var JN=()=>{},AY=X([km,Mt,Em,jm,St,R7],ug),OY=X([Mt,og,cg,JN,AY,JN,Ze,St],dg),QC=X([Mt,Ze,km,SY,Ic,St,OY],fg),EY=X([QC,Hs,bi],hg),kY=X([Mt,QC,EY,St],vg);X([bi,kY],GE);var CY={radiusAxis:{},angleAxis:{}},JC=bn({name:"polarAxis",initialState:CY,reducers:{addRadiusAxis(e,t){e.radiusAxis[t.payload.id]=t.payload},removeRadiusAxis(e,t){delete e.radiusAxis[t.payload.id]},addAngleAxis(e,t){e.angleAxis[t.payload.id]=t.payload},removeAngleAxis(e,t){delete e.angleAxis[t.payload.id]}}}),Cm=JC.actions;Cm.addRadiusAxis;Cm.removeRadiusAxis;Cm.addAngleAxis;Cm.removeAngleAxis;var TY=JC.reducer;function e4(e){return e&&typeof e=="object"&&"className"in e&&typeof e.className=="string"?e.className:""}function eS(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function tS(e){for(var t=1;tt,Dg=X([ZC,zY],(e,t)=>e.filter(n=>n.type==="pie").find(n=>n.id===t)),IY=[],Pg=(e,t,n)=>(n==null?void 0:n.length)===0?IY:n,t4=X([zc,Dg,Pg],(e,t,n)=>{var r=e.chartData;if(t!=null){var l;if((t==null?void 0:t.data)!=null&&t.data.length>0?l=t.data:l=r,(!l||!l.length)&&n!=null&&(l=n.map(s=>tS(tS({},t.presentationProps),s.props))),l!=null)return l}}),$Y=X([t4,Dg,Pg],(e,t,n)=>{if(!(e==null||t==null))return e.map((r,l)=>{var s,d=rt(r,t.nameKey,t.name),f;return n!=null&&(s=n[l])!==null&&s!==void 0&&(s=s.props)!==null&&s!==void 0&&s.fill?f=n[l].props.fill:typeof r=="object"&&r!=null&&"fill"in r?f=r.fill:f=t.fill,{value:Is(d,t.dataKey),dataKey:t.dataKey,color:f,payload:r,type:t.legendType}})}),RY=X([t4,Dg,Pg,Wt],(e,t,n,r)=>{if(!(t==null||e==null))return XG({offset:r,pieSettings:t,displayedData:e,cells:n})}),Cv={exports:{}},ut={};/** - * @license React - * react-is.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var nS;function LY(){if(nS)return ut;nS=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),d=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.view_transition"),w=Symbol.for("react.client.reference");function j(_){if(typeof _=="object"&&_!==null){var S=_.$$typeof;switch(S){case e:switch(_=_.type,_){case n:case l:case r:case m:case h:case b:return _;default:switch(_=_&&_.$$typeof,_){case d:case f:case y:case v:return _;case s:return _;default:return S}}case t:return S}}}return ut.ContextConsumer=s,ut.ContextProvider=d,ut.Element=e,ut.ForwardRef=f,ut.Fragment=n,ut.Lazy=y,ut.Memo=v,ut.Portal=t,ut.Profiler=l,ut.StrictMode=r,ut.Suspense=m,ut.SuspenseList=h,ut.isContextConsumer=function(_){return j(_)===s},ut.isContextProvider=function(_){return j(_)===d},ut.isElement=function(_){return typeof _=="object"&&_!==null&&_.$$typeof===e},ut.isForwardRef=function(_){return j(_)===f},ut.isFragment=function(_){return j(_)===n},ut.isLazy=function(_){return j(_)===y},ut.isMemo=function(_){return j(_)===v},ut.isPortal=function(_){return j(_)===t},ut.isProfiler=function(_){return j(_)===l},ut.isStrictMode=function(_){return j(_)===r},ut.isSuspense=function(_){return j(_)===m},ut.isSuspenseList=function(_){return j(_)===h},ut.isValidElementType=function(_){return typeof _=="string"||typeof _=="function"||_===n||_===l||_===r||_===m||_===h||typeof _=="object"&&_!==null&&(_.$$typeof===y||_.$$typeof===v||_.$$typeof===d||_.$$typeof===s||_.$$typeof===f||_.$$typeof===w||_.getModuleId!==void 0)},ut.typeOf=j,ut}var rS;function BY(){return rS||(rS=1,Cv.exports=LY()),Cv.exports}var UY=BY(),aS=e=>typeof e=="string"?e:e?e.displayName||e.name||"Component":"",iS=null,Tv=null,n4=e=>{if(e===iS&&Array.isArray(Tv))return Tv;var t=[];return x.Children.forEach(e,n=>{Nt(n)||(UY.isFragment(n)?t=t.concat(n4(n.props.children)):t.push(n))}),Tv=t,iS=e,t};function zg(e,t){var n=[],r=[];return Array.isArray(t)?r=t.map(l=>aS(l)):r=[aS(t)],n4(e).forEach(l=>{var s=Hr(l,"type.displayName")||Hr(l,"type.name");s&&r.indexOf(s)!==-1&&n.push(l)}),n}var r4=e=>e&&typeof e=="object"&&"clipDot"in e?!!e.clipDot:!0;function lS(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function sS(e){for(var t=1;t{var r=dt();return(l,s)=>d=>{e==null||e(l,s,d),r(cC({activeIndex:String(s),activeDataKey:t,activeCoordinate:l.tooltipPosition,activeGraphicalItemId:n}))}},Rg=e=>{var t=dt();return(n,r)=>l=>{e==null||e(n,r,l),t(QU())}},Lg=(e,t,n)=>{var r=dt();return(l,s)=>d=>{e==null||e(l,s,d),r(JU({activeIndex:String(s),activeDataKey:t,activeCoordinate:l.tooltipPosition,activeGraphicalItemId:n}))}};function Bg(e){var t=e.tooltipEntrySettings,n=dt(),r=wn(),l=x.useRef(null);return x.useLayoutEffect(()=>{r||(l.current===null?n(FU(t)):l.current!==t&&n(XU({prev:l.current,next:t})),l.current=t)},[t,n,r]),x.useLayoutEffect(()=>()=>{l.current&&(n(WU(l.current)),l.current=null)},[n]),null}function i4(e){var t=e.legendPayload,n=dt(),r=wn(),l=x.useRef(null);return x.useLayoutEffect(()=>{r||(l.current===null?n(sE(t)):l.current!==t&&n(oE({prev:l.current,next:t})),l.current=t)},[n,r,t]),x.useLayoutEffect(()=>()=>{l.current&&(n(cE(l.current)),l.current=null)},[n]),null}function XY(e){var t=e.legendPayload,n=dt(),r=Ne(Ze),l=x.useRef(null);return x.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(l.current===null?n(sE(t)):l.current!==t&&n(oE({prev:l.current,next:t})),l.current=t)},[n,r,t]),x.useLayoutEffect(()=>()=>{l.current&&(n(cE(l.current)),l.current=null)},[n]),null}function WY(e,t){return eG(e)||JY(e,t)||QY(e,t)||ZY()}function ZY(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function QY(e,t){if(e){if(typeof e=="string")return oS(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?oS(e,t):void 0}}function oS(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n2&&arguments[2]!==void 0?arguments[2]:[],r=[];for(var l of n)r.push({status:"removed",prev:l});for(var s=0;se[Math.floor(s*n)]);return qg(r,t)}function nG(e,t){var n=t.map((r,l)=>e[l]);return qg(n,t)}function rG(e,t){for(var n=new Map,r=0;r{var w=n(y,b);if(w!=null){var j=r.get(w);if(j!==void 0)return l.add(w),j}}),d=[];for(var f of r){var m=WY(f,2),h=m[0],v=m[1];l.has(h)||d.push(v)}return qg(s,t,d)}function My(e,t,n){return t==null?null:e==null?t.map(r=>({status:"added",next:r})):n===Ug?tG(e,t):n===Hg?nG(e,t):aG(e,t,n)}function l4(e,t){var n=x.useRef(e),r=x.useRef(t.current),l=x.useRef(!0);n.current!==e&&(n.current=e,r.current=t.current,l.current=!1);var s=x.useCallback(function(d,f){var m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(f===0){l.current=!0;return}f===1&&(r.current=d),f>0&&l.current&&m&&(t.current=d)},[t]);return{startValue:r.current,syncStepValue:s}}function iG(e,t){return cG(e)||oG(e,t)||sG(e,t)||lG()}function lG(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function sG(e,t){if(e){if(typeof e=="string")return cS(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?cS(e,t):void 0}}function cS(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n{typeof e=="function"&&e(),s(!0)},[e]),f=x.useCallback(()=>{typeof t=="function"&&t(),s(!1)},[t]);return{isAnimating:l,handleAnimationStart:d,handleAnimationEnd:f}}function Yg(e){var t,n=e.animationInput,r=e.animationIdPrefix,l=e.items,s=e.previousItemsRef,d=e.isAnimationActive,f=e.animationBegin,m=e.animationDuration,h=e.animationEasing,v=e.onAnimationStart,y=e.onAnimationEnd,b=e.animationInterpolateFn,w=e.animationMatchBy,j=e.shouldUpdatePreviousRef,_=e.children,S=e.layout,A=yE(n,r),C=l4(A,s),M=(t=C.startValue)!==null&&t!==void 0?t:null,k=My(M,l,w??Ug);return x.createElement(vE,{animationId:A,begin:f,duration:m,isActive:d,easing:h,onAnimationEnd:y,onAnimationStart:v,key:A},D=>{var E=M==null,$=l==null?l:b(k,D,S),U=j?j(D):D>0;return C.syncStepValue($,D,U),$==null?null:_($,D,E)})}var Mv;function uG(e,t){return hG(e)||mG(e,t)||fG(e,t)||dG()}function dG(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fG(e,t){if(e){if(typeof e=="string")return uS(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?uS(e,t):void 0}}function uS(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n{var e=x.useState(()=>dc("uid-")),t=uG(e,1),n=t[0];return n},s4=(Mv=AT.useId)!==null&&Mv!==void 0?Mv:pG;function vG(e,t){var n=s4();return t||(e?"".concat(e,"-").concat(n):n)}var yG=x.createContext(void 0),Gg=e=>{var t=e.id,n=e.type,r=e.children,l=vG("recharts-".concat(n),t);return x.createElement(yG.Provider,{value:l},r(l))},gG={cartesianItems:[],polarItems:[]},o4=bn({name:"graphicalItems",initialState:gG,reducers:{addCartesianGraphicalItem:{reducer(e,t){e.cartesianItems.push(t.payload)},prepare:yt()},replaceCartesianGraphicalItem:{reducer(e,t){var n=t.payload,r=n.prev,l=n.next,s=mr(e).cartesianItems.indexOf(r);s>-1&&(e.cartesianItems[s]=l)},prepare:yt()},removeCartesianGraphicalItem:{reducer(e,t){var n=mr(e).cartesianItems.indexOf(t.payload);n>-1&&e.cartesianItems.splice(n,1)},prepare:yt()},addPolarGraphicalItem:{reducer(e,t){e.polarItems.push(t.payload)},prepare:yt()},removePolarGraphicalItem:{reducer(e,t){var n=mr(e).polarItems.indexOf(t.payload);n>-1&&e.polarItems.splice(n,1)},prepare:yt()},replacePolarGraphicalItem:{reducer(e,t){var n=t.payload,r=n.prev,l=n.next,s=mr(e).polarItems.indexOf(r);s>-1&&(e.polarItems[s]=l)},prepare:yt()}}}),Gs=o4.actions,xG=Gs.addCartesianGraphicalItem,bG=Gs.replaceCartesianGraphicalItem,wG=Gs.removeCartesianGraphicalItem,jG=Gs.addPolarGraphicalItem,_G=Gs.removePolarGraphicalItem,NG=Gs.replacePolarGraphicalItem,SG=o4.reducer,AG=e=>{var t=dt(),n=x.useRef(null);return x.useLayoutEffect(()=>{n.current===null?t(xG(e)):n.current!==e&&t(bG({prev:n.current,next:e})),n.current=e},[t,e]),x.useLayoutEffect(()=>()=>{n.current&&(t(wG(n.current)),n.current=null)},[t]),null},c4=x.memo(AG),OG=e=>{var t=dt(),n=x.useRef(null);return x.useLayoutEffect(()=>{n.current===null?t(jG(e)):n.current!==e&&t(NG({prev:n.current,next:e})),n.current=e},[t,e]),x.useLayoutEffect(()=>()=>{n.current&&(t(_G(n.current)),n.current=null)},[t]),null},EG=x.memo(OG),kG=["key"],CG=["onMouseEnter","onClick","onMouseLeave"],TG=["id"],MG=["id"];function dl(){return dl=Object.assign?Object.assign.bind():function(e){for(var t=1;tzg(e.children,nl),[e.children]),n=Ne(r=>$Y(r,e.id,t));return n==null?null:x.createElement(XY,{legendPayload:n})}function RG(e){if(!(e==null||typeof e=="boolean"||typeof e=="function")){if(x.isValidElement(e)){var t,n=(t=e.props)===null||t===void 0?void 0:t.fill;return typeof n=="string"?n:void 0}var r=e.fill;return typeof r=="string"?r:void 0}}var LG=x.memo(e=>{var t=e.dataKey,n=e.nameKey,r=e.sectors,l=e.stroke,s=e.strokeWidth,d=e.fill,f=e.name,m=e.hide,h=e.tooltipType,v=e.id,y=e.activeShape,b=RG(y),w=r.map(_=>{var S=_.tooltipPayload;return b==null||S==null?S:S.map(A=>bt(bt({},A),{},{color:b,fill:b}))}),j={dataDefinedOnItem:w,getPosition:_=>{var S;return(S=r[Number(_)])===null||S===void 0?void 0:S.tooltipPosition},settings:{stroke:l,strokeWidth:s,fill:d,dataKey:t,nameKey:n,name:Is(f,t),hide:m,type:h,color:d,unit:"",graphicalItemId:v}};return x.createElement(Bg,{tooltipEntrySettings:j})}),BG=(e,t)=>e>t?"start":exn(typeof t=="function"?t(e):t,n,n*.8),HG=(e,t,n)=>{var r=t.top,l=t.left,s=t.width,d=t.height,f=xE(s,d),m=l+xn(e.cx,s,s/2),h=r+xn(e.cy,d,d/2),v=xn(e.innerRadius,f,0),y=UG(n,e.outerRadius,f),b=e.maxRadius||Math.sqrt(s*s+d*d)/2;return{cx:m,cy:h,innerRadius:v,outerRadius:y,maxRadius:b}},qG=(e,t)=>{var n=rn(t-e),r=Math.min(Math.abs(t-e),360);return n*r},KG=(e,t)=>{if(x.isValidElement(e))return x.cloneElement(e,t);if(typeof e=="function")return e(t);var n=nt("recharts-pie-label-line",typeof e!="boolean"?e.className:"");t.key;var r=Tm(t,kG);return x.createElement(lc,dl({},r,{type:"linear",className:n}))},YG=(e,t,n)=>{if(x.isValidElement(e))return x.cloneElement(e,t);var r=n;if(typeof e=="function"&&(r=e(t),x.isValidElement(r)))return r;var l=nt("recharts-pie-label-text",e4(e));return x.createElement(Om,dl({},t,{alignmentBaseline:"middle",className:l}),r)};function GG(e){var t=e.sectors,n=e.props,r=e.showLabels,l=n.label,s=n.labelLine,d=n.dataKey;if(!r||!l||!t)return null;var f=zn(n),m=rl(l),h=rl(s),v=typeof l=="object"&&"offsetRadius"in l&&typeof l.offsetRadius=="number"&&l.offsetRadius||20,y=t.map((b,w)=>{var j=(b.startAngle+b.endAngle)/2,_=Ht(b.cx,b.cy,b.outerRadius+v,j),S=bt(bt(bt(bt({},f),b),{},{stroke:"none"},m),{},{index:w,textAnchor:BG(_.x,b.cx)},_),A=bt(bt(bt(bt({},f),b),{},{fill:"none",stroke:b.fill},h),{},{index:w,points:[Ht(b.cx,b.cy,b.outerRadius,j),_],key:"line"});return x.createElement(In,{zIndex:qt.label,key:"label-".concat(b.startAngle,"-").concat(b.endAngle,"-").concat(b.midAngle,"-").concat(w)},x.createElement(Ct,null,s&&KG(s,A),YG(l,S,rt(b,d))))});return x.createElement(Ct,{className:"recharts-pie-labels"},y)}function VG(e){var t=e.sectors,n=e.props,r=e.showLabels,l=n.label;return typeof l=="object"&&l!=null&&"position"in l?x.createElement(Mg,{label:l}):x.createElement(GG,{sectors:t,props:n,showLabels:r})}function FG(e){var t=e.sectors,n=e.activeShape,r=e.inactiveShape,l=e.allOtherPieProps,s=e.shape,d=e.id,f=e.animationElapsedTime,m=e.isAnimating,h=e.isEntrance,v=Ne(vi),y=Ne(Ng),b=Ne(SC),w=l.onMouseEnter,j=l.onClick,_=l.onMouseLeave,S=Tm(l,CG),A=$g(w,l.dataKey,d),C=Rg(_),M=Lg(j,l.dataKey,d);return t==null||t.length===0?null:x.createElement(x.Fragment,null,t.map((k,D)=>{if((k==null?void 0:k.startAngle)===0&&(k==null?void 0:k.endAngle)===0&&t.length!==1)return null;var E=b==null||b===d,$=String(D)===v&&(y==null||l.dataKey===y)&&E,U=v?r:null,K=n&&$?n:U,T=bt(bt({},k),{},{stroke:k.stroke,tabIndex:-1,index:D,isActive:$,animationElapsedTime:f,isAnimating:m,isEntrance:h,[FO]:D,[XO]:d});return x.createElement(Ct,dl({key:"sector-".concat(k==null?void 0:k.startAngle,"-").concat(k==null?void 0:k.endAngle,"-").concat(k.midAngle,"-").concat(D),tabIndex:-1,className:"recharts-pie-sector"},Oc(S,k,D),{onMouseEnter:A(k,D),onMouseLeave:C(k,D),onClick:M(k,D)}),x.createElement(Ig,{option:K??s,DefaultShape:u4,shapeProps:T}))}))}function XG(e){var t,n=e.pieSettings,r=e.displayedData,l=e.cells,s=e.offset,d=n.cornerRadius,f=n.startAngle,m=n.endAngle,h=n.dataKey,v=n.nameKey,y=n.tooltipType,b=Math.abs(n.minAngle),w=qG(f,m),j=Math.abs(w),_=r.length<=1?0:(t=n.paddingAngle)!==null&&t!==void 0?t:0,S=r.filter(U=>rt(U,h,0)!==0).length,A=(j>=360?S:S-1)*_,C=r.reduce((U,K)=>{var T=rt(K,h,0);return U+(je(T)?T:0)},0),M=b>0&&C>0&&r.some(U=>{var K=rt(U,h,0),T=(je(K)?K:0)/C;return K!==0&&T*j0){var $;E=r.map((U,K)=>{var T=rt(U,h,0),re=rt(U,v,K),Z=HG(n,s,U),pe=(je(T)?T:0)/C,fe,ce=bt(bt({},U),l&&l[K]&&l[K].props),R=ce!=null&&"fill"in ce&&typeof ce.fill=="string"?ce.fill:n.fill;K?fe=$.endAngle+rn(w)*_*(T!==0?1:0):fe=f;var z=fe+rn(w)*((T!==0?k:0)+pe*D),G=(fe+z)/2,se=(Z.innerRadius+Z.outerRadius)/2,ue=[{name:re,value:T,payload:ce,dataKey:h,type:y,color:R,fill:R,graphicalItemId:n.id}],P=Ht(Z.cx,Z.cy,se,G);return $=bt(bt(bt(bt({},n.presentationProps),{},{percent:pe,cornerRadius:typeof d=="string"?parseFloat(d):d,name:re,tooltipPayload:ue,midAngle:G,middleRadius:se,tooltipPosition:P},ce),Z),{},{value:T,dataKey:h,startAngle:fe,endAngle:z,payload:ce,paddingAngle:T!==0?rn(w)*_:0}),$})}return E}function WG(e){var t=e.showLabels,n=e.sectors,r=e.children,l=x.useMemo(()=>!t||!n?[]:n.map(s=>({value:s.value,payload:s.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:s.cx,cy:s.cy,innerRadius:s.innerRadius,outerRadius:s.outerRadius,startAngle:s.startAngle,endAngle:s.endAngle,clockWise:!1},fill:s.fill})),[n,t]);return x.createElement(bY,{value:t?l:void 0},r)}var ZG=(e,t)=>{if(e==null)return[];var n=[],r=e.find(s=>s.status!=="removed"),l=r?r.next.startAngle:0;return e.forEach((s,d)=>{if(s.status!=="removed"){var f=d>0?Hr(s.next,"paddingAngle",0):0;if(s.status==="matched"){var m=Et(s.prev.endAngle-s.prev.startAngle,s.next.endAngle-s.next.startAngle,t),h=bt(bt({},s.next),{},{startAngle:l+f,endAngle:l+m+f});n.push(h),l=h.endAngle}else{var v=Et(0,s.next.endAngle-s.next.startAngle,t),y=bt(bt({},s.next),{},{startAngle:l+f,endAngle:l+v+f});n.push(y),l=y.endAngle}}}),n};function QG(e){var t=e.props,n=e.previousSectorsRef,r=e.id,l=t.sectors,s=t.activeShape,d=t.inactiveShape,f=t.animationInterpolateFn,m=Kg(t.onAnimationStart,t.onAnimationEnd),h=m.isAnimating,v=m.handleAnimationStart,y=m.handleAnimationEnd,b=ZI();return b==null?null:x.createElement(WG,{showLabels:!h,sectors:l},x.createElement(Yg,{animationInput:t,animationIdPrefix:"recharts-pie-",items:l,previousItemsRef:n,isAnimationActive:t.isAnimationActive,animationBegin:t.animationBegin,animationDuration:t.animationDuration,animationEasing:t.animationEasing,onAnimationStart:v,onAnimationEnd:y,animationInterpolateFn:f,animationMatchBy:t.animationMatchBy,layout:b},(w,j,_)=>x.createElement(Ct,null,x.createElement(FG,{sectors:w,activeShape:s,inactiveShape:d,allOtherPieProps:t,shape:t.shape,id:r,animationElapsedTime:j,isAnimating:h||j<1,isEntrance:_}))),x.createElement(VG,{showLabels:!h,sectors:l,props:t}),t.children)}var JG={animationBegin:400,animationDuration:1500,animationEasing:"ease",animationInterpolateFn:ZG,animationMatchBy:Hg,cx:"50%",cy:"50%",dataKey:"value",endAngle:360,fill:"#808080",hide:!1,innerRadius:0,isAnimationActive:"auto",label:!1,labelLine:!0,legendType:"rect",minAngle:0,nameKey:"name",outerRadius:"80%",paddingAngle:0,rootTabIndex:0,shape:u4,startAngle:0,stroke:"#fff",zIndex:qt.area};function eV(e){var t=e.id,n=Tm(e,TG),r=e.hide,l=e.className,s=e.rootTabIndex,d=x.useMemo(()=>zg(e.children,nl),[e.children]),f=Ne(v=>RY(v,t,d)),m=x.useRef(null),h=nt("recharts-pie",l);return r||f==null?(m.current=null,x.createElement(Ct,{tabIndex:s,className:h})):x.createElement(In,{zIndex:e.zIndex},x.createElement(LG,{dataKey:e.dataKey,nameKey:e.nameKey,sectors:f,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:t,activeShape:e.activeShape}),x.createElement(Ct,{tabIndex:s,className:h},x.createElement(QG,{props:bt(bt({},n),{},{sectors:f}),previousSectorsRef:m,id:t})))}function tV(e){var t=an(e,JG),n=t.id,r=Tm(t,MG),l=zn(r);return x.createElement(Gg,{id:n,type:"pie"},s=>x.createElement(x.Fragment,null,x.createElement(EG,{type:"pie",id:s,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:l,maxRadius:t.maxRadius}),x.createElement($G,dl({},r,{id:s})),x.createElement(eV,dl({},r,{id:s}))))}var Dy=tV;Dy.displayName="Pie";var nV=["points"];function fS(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function Dv(e){for(var t=1;t{var A,C,M=Dv(Dv(Dv({r:3},d),b),{},{index:S,cx:(A=_.x)!==null&&A!==void 0?A:void 0,cy:(C=_.y)!==null&&C!==void 0?C:void 0,dataKey:s,value:_.value,payload:_.payload,points:t});return x.createElement(oV,{key:"dot-".concat(S),option:n,dotProps:M,className:l})}),j={};return f&&m!=null&&(j.clipPath="url(#clipPath-".concat(y?"":"dots-").concat(m,")")),x.createElement(In,{zIndex:v},x.createElement(Ct,Cf({className:r},j),w))}function mS(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function hS(e){for(var t=1;t({top:e.top,bottom:e.bottom,left:e.left,right:e.right})),NV=X([_V,Ca,Ta],(e,t,n)=>{if(!(!e||t==null||n==null))return{x:e.left,y:e.top,width:Math.max(0,t-e.left-e.right),height:Math.max(0,n-e.top-e.bottom)}}),Vg=()=>Ne(NV),SV=()=>Ne(VH);function pS(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function Pv(e){for(var t=1;t{var t=e.point,n=e.childIndex,r=e.mainColor,l=e.activeDot,s=e.dataKey,d=e.clipPath;if(l===!1||t.x==null||t.y==null)return null;var f={index:n,dataKey:s,cx:t.x,cy:t.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:t.payload,value:t.value},m=Pv(Pv(Pv({},f),rl(l)),n0(l)),h;return x.isValidElement(l)?h=x.cloneElement(l,m):typeof l=="function"?h=l(m):h=x.createElement(WC,m),x.createElement(Ct,{className:"recharts-active-dot",clipPath:d},h)};function vS(e){var t=e.points,n=e.mainColor,r=e.activeDot,l=e.itemDataKey,s=e.clipPath,d=e.zIndex,f=d===void 0?qt.activeDot:d,m=Ne(vi),h=SV();if(t==null||h==null)return null;var v=t.find(y=>h.includes(y.payload));return Nt(v)?null:x.createElement(In,{zIndex:f},x.createElement(kV,{point:v,childIndex:Number(m),mainColor:n,dataKey:l,activeDot:r,clipPath:s}))}function CV(e,t){return PV(e)||DV(e,t)||MV(e,t)||TV()}function TV(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function MV(e,t){if(e){if(typeof e=="string")return yS(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?yS(e,t):void 0}}function yS(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n{var r=n??e;if(!Nt(r))return xn(r,t,0)},zV=(e,t,n)=>{var r={},l=e.filter(fm),s=e.filter(h=>h.stackId==null),d=l.reduce((h,v)=>{var y=h[v.stackId];return y==null&&(y=[]),y.push(v),h[v.stackId]=y,h},r),f=Object.entries(d).map(h=>{var v,y=CV(h,2),b=y[0],w=y[1],j=w.map(S=>S.dataKey),_=gS(t,n,(v=w[0])===null||v===void 0?void 0:v.barSize);return{stackId:b,dataKeys:j,barSize:_}}),m=s.map(h=>{var v=[h.dataKey].filter(b=>b!=null),y=gS(t,n,h.barSize);return{stackId:void 0,dataKeys:v,barSize:y}});return[...f,...m]};function xS(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function Sd(e){for(var t=1;tC+(M.barSize||0),0);b+=(d-1)*f,b>=n&&(b-=(d-1)*f,f=0),b>=n&&y>0&&(v=!0,y*=.9,b=d*y);var w=Math.round((n-b)/2),j={offset:w-f,size:0};m=r.reduce((C,M)=>{var k,D={stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:j.offset+j.size+f,size:v?y:(k=M.barSize)!==null&&k!==void 0?k:0}},E=[...C,D];return j=D.position,E},h)}else{var _=xn(t,n,0,!0);n-2*_-(d-1)*f<=0&&(f=0);var S=(n-2*_-(d-1)*f)/d;S>1&&(S=Math.round(S));var A=He(l)?Math.min(S,l):S;m=r.reduce((C,M,k)=>[...C,{stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:_+(S+f)*k+(S-A)/2,size:A}}],h)}return m}}var BV=(e,t,n,r,l,s,d)=>{var f=Nt(d)?t:d,m=LV(n,r,l!==s?l:s,e,f);return l!==s&&m!=null&&(m=m.map(h=>Sd(Sd({},h),{},{position:Sd(Sd({},h.position),{},{offset:h.position.offset-l/2})}))),m},UV=(e,t)=>{var n=dm(t);if(!(!e||n==null||t==null)){var r=t.stackId;if(r!=null){var l=e[r];if(l){var s=l.stackedData;if(s)return s.find(d=>d.key===n)}}}},HV=(e,t)=>{if(!(e==null||t==null)){var n=e.find(r=>r.stackId===t.stackId&&t.dataKey!=null&&r.dataKeys.includes(t.dataKey));if(n!=null)return n.position}};function qV(e,t){return e&&typeof e=="object"&&"zIndex"in e&&typeof e.zIndex=="number"&&He(e.zIndex)?e.zIndex:t}var m4=e=>{var t=e.chartData,n=dt(),r=wn();return x.useEffect(()=>r?()=>{}:(n(CN(t)),()=>{n(CN(void 0))}),[t,n,r]),null},bS={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},h4=bn({name:"brush",initialState:bS,reducers:{setBrushSettings(e,t){return t.payload==null?bS:t.payload}}});h4.actions.setBrushSettings;var KV=h4.reducer;function YV(e){return(e%180+180)%180}var GV=function(t){var n=t.width,r=t.height,l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=YV(l),d=s*Math.PI/180,f=Math.atan(r/n),m=d>f&&d{e.dots.push(t.payload)},removeDot:(e,t)=>{var n=mr(e).dots.findIndex(r=>r===t.payload);n!==-1&&e.dots.splice(n,1)},addArea:(e,t)=>{e.areas.push(t.payload)},removeArea:(e,t)=>{var n=mr(e).areas.findIndex(r=>r===t.payload);n!==-1&&e.areas.splice(n,1)},addLine:(e,t)=>{e.lines.push(t.payload)},removeLine:(e,t)=>{var n=mr(e).lines.findIndex(r=>r===t.payload);n!==-1&&e.lines.splice(n,1)}}}),Vs=p4.actions;Vs.addDot;Vs.removeDot;Vs.addArea;Vs.removeArea;Vs.addLine;Vs.removeLine;var FV=p4.reducer;function XV(e,t){return JV(e)||QV(e,t)||ZV(e,t)||WV()}function WV(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ZV(e,t){if(e){if(typeof e=="string")return wS(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?wS(e,t):void 0}}function wS(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n{var t=e.children,n=x.useState("".concat(dc("recharts"),"-clip")),r=XV(n,1),l=r[0],s=Vg();if(s==null)return null;var d=s.x,f=s.y,m=s.width,h=s.height;return x.createElement(eF.Provider,{value:l},x.createElement("defs",null,x.createElement("clipPath",{id:l},x.createElement("rect",{x:d,y:f,height:h,width:m}))),t)};function v4(e,t){if(t<1)return[];if(t===1)return e;for(var n=[],r=0;re*l)return!1;var s=n();return e*(t-e*s/2-r)>=0&&e*(t+e*s/2-l)<=0}function aF(e,t){return v4(e,t+1)}function iF(e,t,n,r,l){for(var s=(r||[]).slice(),d=t.start,f=t.end,m=0,h=1,v=d,y=function(){var j=r==null?void 0:r[m];if(j===void 0)return{v:v4(r,h)};var _=m,S,A=()=>(S===void 0&&(S=n(j,_)),S),C=j.coordinate,M=m===0||Sc(e,C,A,v,f);M||(m=0,v=d,h+=1),M&&(v=C+e*(A()/2+l),m+=h)},b;h<=s.length;)if(b=y(),b)return b.v;return[]}function lF(e,t,n,r,l){var s=(r||[]).slice(),d=s.length;if(d===0)return[];for(var f=t.start,m=t.end,h=1;h<=d;h++){for(var v=(d-1)%h,y=f,b=!0,w=function(){var k=r[_];if(k==null)return 0;var D=_,E,$=()=>(E===void 0&&(E=n(k,D)),E),U=k.coordinate,K=_===v||Sc(e,U,$,y,m);if(!K)return b=!1,1;K&&(y=U+e*($()/2+l))},j,_=v;_(_===void 0&&(_=n(w,b)),_);if(b===d-1){var A=e*(j.coordinate+e*S()/2-m);s[b]=j=yn(yn({},j),{},{tickCoord:A>0?j.coordinate-A*e:j.coordinate})}else s[b]=j=yn(yn({},j),{},{tickCoord:j.coordinate});if(j.tickCoord!=null){var C=Sc(e,j.tickCoord,S,f,m);C&&(m=j.tickCoord-e*(S()/2+l),s[b]=yn(yn({},j),{},{isShow:!0}))}},v=d-1;v>=0;v--)h(v);return s}function dF(e,t,n,r,l,s){var d=(r||[]).slice(),f=d.length,m=t.start,h=t.end;if(s){var v=r[f-1];if(v!=null){var y=n(v,f-1),b=e*(v.coordinate+e*y/2-h);if(d[f-1]=v=yn(yn({},v),{},{tickCoord:b>0?v.coordinate-b*e:v.coordinate}),v.tickCoord!=null){var w=Sc(e,v.tickCoord,()=>y,m,h);w&&(h=v.tickCoord-e*(y/2+l),d[f-1]=yn(yn({},v),{},{isShow:!0}))}}}for(var j=s?f-1:f,_=function(C){var M=d[C];if(M==null)return 1;var k=M,D,E=()=>(D===void 0&&(D=n(M,C)),D);if(C===0){var $=e*(k.coordinate-e*E()/2-m);d[C]=k=yn(yn({},k),{},{tickCoord:$<0?k.coordinate-$*e:k.coordinate})}else d[C]=k=yn(yn({},k),{},{tickCoord:k.coordinate});if(k.tickCoord!=null){var U=Sc(e,k.tickCoord,E,m,h);U&&(m=k.tickCoord+e*(E()/2+l),d[C]=yn(yn({},k),{},{isShow:!0}))}},S=0;S{var $=typeof h=="function"?h(D.value,E):D.value;return j==="width"?nF(oc($,{fontSize:t,letterSpacing:n}),_,y):oc($,{fontSize:t,letterSpacing:n})[j]},A=l[0],C=l[1],M=l.length>=2&&A!=null&&C!=null?rn(C.coordinate-A.coordinate):1,k=rF(s,M,j);return m==="equidistantPreserveStart"?iF(M,k,S,l,d):m==="equidistantPreserveEnd"?lF(M,k,S,l,d):(m==="preserveStart"||m==="preserveStartEnd"?w=dF(M,k,S,l,d,m==="preserveStartEnd"):w=uF(M,k,S,l,d),w.filter(D=>D.isShow))}var fF=e=>{var t=e.ticks,n=e.label,r=e.labelGapWithTick,l=r,s=e.tickSize,d=s===void 0?0:s,f=e.tickMargin,m=f===void 0?0:f,h=0;if(t){Array.from(t).forEach(w=>{if(w){var j=w.getBoundingClientRect();j.width>h&&(h=j.width)}});var v=n?n.getBoundingClientRect().width:0,y=d+m,b=h+y+v+(n?l:0);return Math.round(b)}return 0},mF={xAxis:{},yAxis:{}},y4=bn({name:"renderedTicks",initialState:mF,reducers:{setRenderedTicks:(e,t)=>{var n=t.payload,r=n.axisType,l=n.axisId,s=n.ticks;e[r][l]=s},removeRenderedTicks:(e,t)=>{var n=t.payload,r=n.axisType,l=n.axisId;delete e[r][l]}}}),g4=y4.actions,hF=g4.setRenderedTicks,pF=g4.removeRenderedTicks,vF=y4.reducer,yF=["axisLine","width","height","className","hide","ticks","axisType","axisId"];function _S(e,t){return wF(e)||bF(e,t)||xF(e,t)||gF()}function gF(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xF(e,t){if(e){if(typeof e=="string")return NS(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?NS(e,t):void 0}}function NS(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n{if(r==null||n==null)return hl;var s=t.map(d=>({value:d.value,coordinate:d.coordinate,offset:d.offset,index:d.index}));return l(hF({ticks:s,axisId:r,axisType:n})),()=>{l(pF({axisId:r,axisType:n}))}},[l,t,r,n]),null}var DF=x.forwardRef((e,t)=>{var n=e.ticks,r=n===void 0?[]:n,l=e.tick,s=e.tickLine,d=e.stroke,f=e.tickFormatter,m=e.unit,h=e.padding,v=e.tickTextProps,y=e.orientation,b=e.mirror,w=e.x,j=e.y,_=e.width,S=e.height,A=e.tickSize,C=e.tickMargin,M=e.fontSize,k=e.letterSpacing,D=e.getTicksConfig,E=e.events,$=e.axisType,U=e.axisId,K=Fg(kt(kt({},D),{},{ticks:r}),M,k),T=zn(D),re=rl(l),Z=UC(T.textAnchor)?T.textAnchor:kF(y,b),pe=CF(y,b),fe={};typeof s=="object"&&(fe=s);var ce=kt(kt({},T),{},{fill:"none"},fe),R=K.map(se=>kt({entry:se},EF(se,w,j,_,S,y,A,b,C))),z=R.map(se=>{var ue=se.entry,P=se.line;return x.createElement(Ct,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(ue.value,"-").concat(ue.coordinate,"-").concat(ue.tickCoord)},s&&x.createElement("line",fl({},ce,P,{className:nt("recharts-cartesian-axis-tick-line",Hr(s,"className"))})))}),G=R.map((se,ue)=>{var P,Q,ne=se.entry,I=se.tick,he=kt(kt(kt(kt({verticalAnchor:pe},T),{},{textAnchor:Z,stroke:"none",fill:d},I),{},{index:ue,payload:ne,visibleTicksCount:K.length,tickFormatter:f,padding:h},v),{},{angle:(P=(Q=v==null?void 0:v.angle)!==null&&Q!==void 0?Q:T.angle)!==null&&P!==void 0?P:0}),be=kt(kt({},he),re);return x.createElement(Ct,fl({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(ne.value,"-").concat(ne.coordinate,"-").concat(ne.tickCoord)},Oc(E,ne,ue)),l&&x.createElement(TF,{option:l,tickProps:be,value:"".concat(typeof f=="function"?f(ne.value,ue):ne.value).concat(m||"")}))});return x.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat($,"-ticks")},x.createElement(MF,{ticks:K,axisId:U,axisType:$}),G.length>0&&x.createElement(In,{zIndex:qt.label},x.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat($,"-tick-labels"),ref:t},G)),z.length>0&&x.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat($,"-tick-lines")},z))}),PF=x.forwardRef((e,t)=>{var n=e.axisLine,r=e.width,l=e.height,s=e.className,d=e.hide,f=e.ticks,m=e.axisType,h=e.axisId,v=jF(e,yF),y=x.useState(""),b=_S(y,2),w=b[0],j=b[1],_=x.useState(""),S=_S(_,2),A=S[0],C=S[1],M=x.useRef(null);x.useImperativeHandle(t,()=>({getCalculatedWidth:()=>{var D;return fF({ticks:M.current,label:(D=e.labelRef)===null||D===void 0?void 0:D.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}}));var k=x.useCallback(D=>{if(D){var E=D.getElementsByClassName("recharts-cartesian-axis-tick-value");M.current=E;var $=E[0];if($){var U=window.getComputedStyle($),K=U.fontSize,T=U.letterSpacing;(K!==w||T!==A)&&(j(K),C(T))}}},[w,A]);return d||r!=null&&r<=0||l!=null&&l<=0?null:x.createElement(In,{zIndex:e.zIndex},x.createElement(Ct,{className:nt("recharts-cartesian-axis",s)},x.createElement(OF,{x:e.x,y:e.y,width:r,height:l,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:zn(e)}),x.createElement(DF,{ref:k,axisType:m,events:v,fontSize:w,getTicksConfig:e,height:e.height,letterSpacing:A,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:f,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:h}),x.createElement(iY,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},x.createElement(pY,{label:e.label,labelRef:e.labelRef}),e.children)))}),Xg=x.forwardRef((e,t)=>{var n=an(e,Na);return x.createElement(PF,fl({},n,{ref:t}))});Xg.displayName="CartesianAxis";var zF=["x1","y1","x2","y2","key"],IF=["offset"],$F=["xAxisId","yAxisId"],RF=["xAxisId","yAxisId"];function AS(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function gn(e){for(var t=1;t{var t=e.fill;if(!t||t==="none")return null;var n=e.fillOpacity,r=e.x,l=e.y,s=e.width,d=e.height,f=e.ry;return x.createElement("rect",{x:r,y:l,ry:f,width:s,height:d,stroke:"none",fill:t,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function x4(e){var t=e.option,n=e.lineItemProps,r;if(x.isValidElement(t))r=x.cloneElement(t,n);else if(typeof t=="function")r=t(n);else{var l,s=n.x1,d=n.y1,f=n.x2,m=n.y2,h=n.key,v=Tf(n,zF),y=(l=zn(v))!==null&&l!==void 0?l:{};y.offset;var b=Tf(y,IF);r=x.createElement("line",Qi({},b,{x1:s,y1:d,x2:f,y2:m,fill:"none",key:h}))}return r}function KF(e){var t=e.x,n=e.width,r=e.horizontal,l=r===void 0?!0:r,s=e.horizontalPoints;if(!l||!s||!s.length)return null;e.xAxisId,e.yAxisId;var d=Tf(e,$F),f=s.map((m,h)=>{var v=gn(gn({},d),{},{x1:t,y1:m,x2:t+n,y2:m,key:"line-".concat(h),index:h});return x.createElement(x4,{key:"line-".concat(h),option:l,lineItemProps:v})});return x.createElement("g",{className:"recharts-cartesian-grid-horizontal"},f)}function YF(e){var t=e.y,n=e.height,r=e.vertical,l=r===void 0?!0:r,s=e.verticalPoints;if(!l||!s||!s.length)return null;e.xAxisId,e.yAxisId;var d=Tf(e,RF),f=s.map((m,h)=>{var v=gn(gn({},d),{},{x1:m,y1:t,x2:m,y2:t+n,key:"line-".concat(h),index:h});return x.createElement(x4,{option:l,lineItemProps:v,key:"line-".concat(h)})});return x.createElement("g",{className:"recharts-cartesian-grid-vertical"},f)}function GF(e){var t=e.horizontalFill,n=e.fillOpacity,r=e.x,l=e.y,s=e.width,d=e.height,f=e.horizontalPoints,m=e.horizontal,h=m===void 0?!0:m;if(!h||!t||!t.length||f==null)return null;var v=f.map(b=>Math.round(b+l-l)).sort((b,w)=>b-w);l!==v[0]&&v.unshift(0);var y=v.map((b,w)=>{var j=v[w+1],_=j==null,S=_?l+d-b:j-b;if(S<=0)return null;var A=w%t.length;return x.createElement("rect",{key:"react-".concat(w),y:b,x:r,height:S,width:s,stroke:"none",fill:t[A],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return x.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},y)}function VF(e){var t=e.vertical,n=t===void 0?!0:t,r=e.verticalFill,l=e.fillOpacity,s=e.x,d=e.y,f=e.width,m=e.height,h=e.verticalPoints;if(!n||!r||!r.length)return null;var v=h.map(b=>Math.round(b+s-s)).sort((b,w)=>b-w);s!==v[0]&&v.unshift(0);var y=v.map((b,w)=>{var j=v[w+1],_=j==null,S=_?s+f-b:j-b;if(S<=0)return null;var A=w%r.length;return x.createElement("rect",{key:"react-".concat(w),x:b,y:d,width:S,height:m,stroke:"none",fill:r[A],fillOpacity:l,className:"recharts-cartesian-grid-bg"})});return x.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},y)}var FF=(e,t)=>{var n=e.xAxis,r=e.width,l=e.height,s=e.offset;return KO(Fg(gn(gn(gn({},Na),n),{},{ticks:YO(n),viewBox:{x:0,y:0,width:r,height:l}})),s.left,s.left+s.width,t)},XF=(e,t)=>{var n=e.yAxis,r=e.width,l=e.height,s=e.offset;return KO(Fg(gn(gn(gn({},Na),n),{},{ticks:YO(n),viewBox:{x:0,y:0,width:r,height:l}})),s.top,s.top+s.height,t)},WF={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:qt.grid};function b4(e){var t=h0(),n=p0(),r=JO(),l=gn(gn({},an(e,WF)),{},{x:je(e.x)?e.x:r.left,y:je(e.y)?e.y:r.top,width:je(e.width)?e.width:r.width,height:je(e.height)?e.height:r.height}),s=l.xAxisId,d=l.yAxisId,f=l.x,m=l.y,h=l.width,v=l.height,y=l.syncWithTicks,b=l.horizontalValues,w=l.verticalValues,j=wn(),_=Ne(K=>yN(K,"xAxis",s,j)),S=Ne(K=>yN(K,"yAxis",d,j));if(!Kr(h)||!Kr(v)||!je(f)||!je(m))return null;var A=l.verticalCoordinatesGenerator||FF,C=l.horizontalCoordinatesGenerator||XF,M=l.horizontalPoints,k=l.verticalPoints;if((!M||!M.length)&&typeof C=="function"){var D=b&&b.length,E=C({yAxis:S?gn(gn({},S),{},{ticks:D?b:S.ticks}):void 0,width:t??h,height:n??v,offset:r},D?!0:y);tf(Array.isArray(E),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof E,"]")),Array.isArray(E)&&(M=E)}if((!k||!k.length)&&typeof A=="function"){var $=w&&w.length,U=A({xAxis:_?gn(gn({},_),{},{ticks:$?w:_.ticks}):void 0,width:t??h,height:n??v,offset:r},$?!0:y);tf(Array.isArray(U),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof U,"]")),Array.isArray(U)&&(k=U)}return x.createElement(In,{zIndex:l.zIndex},x.createElement("g",{className:"recharts-cartesian-grid"},x.createElement(qF,{fill:l.fill,fillOpacity:l.fillOpacity,x:l.x,y:l.y,width:l.width,height:l.height,ry:l.ry}),x.createElement(GF,Qi({},l,{horizontalPoints:M})),x.createElement(VF,Qi({},l,{verticalPoints:k})),x.createElement(KF,Qi({},l,{offset:r,horizontalPoints:M,xAxis:_,yAxis:S})),x.createElement(YF,Qi({},l,{offset:r,verticalPoints:k,xAxis:_,yAxis:S}))))}b4.displayName="CartesianGrid";var ZF={},w4=bn({name:"errorBars",initialState:ZF,reducers:{addErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,l=n.errorBar;e[r]||(e[r]=[]),e[r].push(l)},replaceErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,l=n.prev,s=n.next;e[r]&&(e[r]=e[r].map(d=>d.dataKey===l.dataKey&&d.direction===l.direction?s:d))},removeErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,l=n.errorBar;e[r]&&(e[r]=e[r].filter(s=>s.dataKey!==l.dataKey||s.direction!==l.direction))}}}),Wg=w4.actions;Wg.addErrorBar;Wg.replaceErrorBar;Wg.removeErrorBar;var QF=w4.reducer,JF=["children"];function eX(e,t){if(e==null)return{};var n,r,l=tX(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r({x:0,y:0,value:0}),errorBarOffset:0},rX=x.createContext(nX);function aX(e){var t=e.children,n=eX(e,JF);return x.createElement(rX.Provider,{value:n},t)}function Zg(e,t){var n,r,l=Ne(h=>Da(h,e)),s=Ne(h=>Pa(h,t)),d=(n=l==null?void 0:l.allowDataOverflow)!==null&&n!==void 0?n:Gt.allowDataOverflow,f=(r=s==null?void 0:s.allowDataOverflow)!==null&&r!==void 0?r:Vt.allowDataOverflow,m=d||f;return{needClip:m,needClipX:d,needClipY:f}}function j4(e){var t=e.xAxisId,n=e.yAxisId,r=e.clipPathId,l=Vg(),s=Zg(t,n),d=s.needClipX,f=s.needClipY,m=s.needClip,h=Ne(M=>Fk(M,t,!1)),v=Ne(M=>Xk(M,n,!1));if(!m||!l)return null;var y=l.x,b=l.y,w=l.width,j=l.height,_=d&&h?Math.min(h[0],h[1]):y-w/2,S=f&&v?Math.min(v[0],v[1]):b-j/2,A=d&&h?Math.abs(h[1]-h[0]):w*2,C=f&&v?Math.abs(v[1]-v[0]):j*2;return x.createElement("clipPath",{id:"clipPath-".concat(r)},x.createElement("rect",{x:_,y:S,width:A,height:C}))}function iX(e){var t=rl(e),n=3,r=2;if(t!=null){var l=t.r,s=t.strokeWidth,d=Number(l),f=Number(s);return(Number.isNaN(d)||d<0)&&(d=n),(Number.isNaN(f)||f<0)&&(f=r),{r:d,strokeWidth:f}}return{r:n,strokeWidth:r}}function Xr(e,t){var n,r;return(n=(r=e.graphicalItems.cartesianItems.find(l=>l.id===t))===null||r===void 0?void 0:r.xAxisId)!==null&&n!==void 0?n:d4}function Wr(e,t){var n,r;return(n=(r=e.graphicalItems.cartesianItems.find(l=>l.id===t))===null||r===void 0?void 0:r.yAxisId)!==null&&n!==void 0?n:d4}var _4=(e,t,n)=>pi(e,"xAxis",Xr(e,t),n),N4=(e,t,n)=>hi(e,"xAxis",Xr(e,t),n),S4=(e,t,n)=>pi(e,"yAxis",Wr(e,t),n),A4=(e,t,n)=>hi(e,"yAxis",Wr(e,t),n),lX=X([Ze,_4,S4,N4,A4],(e,t,n,r,l)=>Vr(e,"xAxis")?As(t,r,!1):As(n,l,!1)),sX=(e,t)=>t,O4=X([wm,sX],(e,t)=>e.filter(n=>n.type==="area").find(n=>n.id===t)),E4=e=>{var t=Ze(e),n=Vr(t,"xAxis");return n?"yAxis":"xAxis"},oX=(e,t)=>{var n=E4(e);return n==="yAxis"?Wr(e,t):Xr(e,t)},cX=(e,t,n)=>Nf(e,E4(e),oX(e,t),n),uX=X([O4,cX],(e,t)=>{var n;if(!(e==null||t==null)){var r=e.stackId,l=dm(e);if(!(r==null||l==null)){var s=(n=t[r])===null||n===void 0?void 0:n.stackedData,d=s==null?void 0:s.find(f=>f.key===l);if(d!=null)return d.map(f=>[f[0],f[1]])}}}),dX=X([Ze,_4,S4,N4,A4,uX,NE,lX,O4,t9],(e,t,n,r,l,s,d,f,m,h)=>{var v=d.chartData,y=d.dataStartIndex,b=d.dataEndIndex;if(!(m==null||e!=="horizontal"&&e!=="vertical"||t==null||n==null||r==null||l==null||r.length===0||l.length===0||f==null)){var w=m.data,j;if(w&&w.length>0?j=w:j=v==null?void 0:v.slice(y,b+1),j!=null)return $X({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:l,dataStartIndex:y,areaSettings:m,stackedData:s,displayedData:j,chartBaseValue:h,bandSize:f})}}),fX=["animationElapsedTime","isAnimating","isEntrance","layout","isRange","stroke","connectNulls"],mX=["id","baseLine"];function cc(){return cc=Object.assign?Object.assign.bind():function(e){for(var t=1;ty.y||0));return je(l)?v=Math.max(l,v):l&&Array.isArray(l)&&l.length&&(v=Math.max(...l.map(y=>y.y||0),v)),je(v)?x.createElement("rect",{x:fy.x||0));return je(l)?v=Math.max(l,v):l&&Array.isArray(l)&&l.length&&(v=Math.max(...l.map(y=>y.x||0),v)),je(v)?x.createElement("rect",{x:0,y:fe==null?[]:t===1?e.flatMap(n=>n.status==="removed"?[]:[n.next]):e.flatMap(n=>n.status==="matched"?[Ps(Ps({},n.next),{},{x:Et(n.prev.x,n.next.x,t),y:Et(n.prev.y,n.next.y,t)})]:n.status==="added"?[n.next]:[]),C4={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",animationMatchBy:Ug,animationInterpolateFn:SX,connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,shape:gX,xAxisId:0,yAxisId:0,zIndex:qt.area};function Df(e,t){return e&&e!=="none"?e:t}var AX=e=>{var t=e.dataKey,n=e.name,r=e.stroke,l=e.fill,s=e.legendType,d=e.hide;return[{inactive:d,dataKey:t,type:s,color:Df(r,l),value:Is(n,t),payload:e}]},OX=x.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,l=e.strokeWidth,s=e.fill,d=e.name,f=e.hide,m=e.unit,h=e.tooltipType,v=e.id,y={dataDefinedOnItem:n,getPosition:hl,settings:{stroke:r,strokeWidth:l,fill:s,dataKey:t,nameKey:void 0,name:Is(d,t),hide:f,type:h,color:Df(r,s),unit:m,graphicalItemId:v}};return x.createElement(Bg,{tooltipEntrySettings:y})});function EX(e){var t=e.clipPathId,n=e.points,r=e.props,l=r.needClip,s=r.dot,d=r.dataKey,f=zn(r);return x.createElement(uV,{points:n,dot:s,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:d,baseProps:f,needClip:l,clipPathId:t})}function kX(e){var t=e.showLabels,n=e.children,r=e.points,l=r.map(s=>{var d,f,m={x:(d=s.x)!==null&&d!==void 0?d:0,y:(f=s.y)!==null&&f!==void 0?f:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Ps(Ps({},m),{},{value:s.value,payload:s.payload,parentViewBox:void 0,viewBox:m,fill:void 0})});return x.createElement(FC,{value:t?l:void 0},n)}function CX(e){var t=e.points,n=e.baseLine,r=e.needClip,l=e.clipPathId,s=e.props,d=e.animationElapsedTime,f=e.isAnimating,m=e.isEntrance,h=s.layout,v=s.type,y=s.stroke,b=s.connectNulls,w=s.isRange,j=s.shape,_=s.id,S=k4(s,xX),A=Xn(S),C=Ps(Ps({},A),{},{id:_,points:t,connectNulls:b,type:v,baseLine:n,layout:h,stroke:y,isRange:w,animationElapsedTime:d,isAnimating:f,isEntrance:m});return x.createElement(x.Fragment,null,(t==null?void 0:t.length)>1&&x.createElement(Ct,{clipPath:r?"url(#clipPath-".concat(l,")"):void 0},x.createElement(Ig,{option:j,DefaultShape:C4.shape,shapeProps:C})),x.createElement(EX,{points:t,props:S,clipPathId:l}))}function TX(e,t,n){if(je(e)){var r=je(t)?t:void 0;return Et(r,e,n)}if(Nt(e)||Ar(e)){var l=je(t)?t:void 0;return Et(l,0,n)}return e}function MX(e){var t=e.needClip,n=e.clipPathId,r=e.props,l=e.previousPointsRef,s=e.previousBaselineRef,d=r.points,f=r.baseLine,m=r.isAnimationActive,h=r.animationBegin,v=r.animationDuration,y=r.animationEasing,b=r.animationMatchBy,w=r.animationInterpolateFn,j=x.useMemo(()=>({points:d,baseLine:f}),[d,f]),_=l4(j,s),S=v0(),A=Kg(r.onAnimationStart,r.onAnimationEnd),C=A.isAnimating,M=A.handleAnimationStart,k=A.handleAnimationEnd,D=_.startValue;if(S==null)return null;var E;return Array.isArray(f)&&Array.isArray(D)?E=My(D,f,b):Array.isArray(f)?E=My(null,f,b):E=null,x.createElement(Yg,{animationInput:j,animationIdPrefix:"recharts-area-",items:d,previousItemsRef:l,isAnimationActive:m,animationBegin:h,animationDuration:v,animationEasing:y,onAnimationStart:M,onAnimationEnd:k,animationInterpolateFn:w,animationMatchBy:b,layout:S},($,U,K)=>{var T;return U===1?T=f:Array.isArray(f)?T=w(E,U,S):T=K?f:TX(f,D,U),_.syncStepValue(T,U),x.createElement(kX,{showLabels:!C,points:d},r.children,x.createElement(CX,{points:$,baseLine:T,needClip:t,clipPathId:n,props:r,animationElapsedTime:U,isAnimating:C||U<1,isEntrance:K}),x.createElement(Mg,{label:r.label}))})}function DX(e){var t=e.needClip,n=e.clipPathId,r=e.props,l=x.useRef(null),s=x.useRef();return x.createElement(MX,{needClip:t,clipPathId:n,props:r,previousPointsRef:l,previousBaselineRef:s})}class PX extends x.PureComponent{render(){var t=this.props,n=t.hide,r=t.dot,l=t.points,s=t.className,d=t.top,f=t.left,m=t.needClip,h=t.xAxisId,v=t.yAxisId,y=t.width,b=t.height,w=t.id,j=t.baseLine,_=t.zIndex;if(n)return null;var S=nt("recharts-area",s),A=w,C=iX(r),M=C.r,k=C.strokeWidth,D=r4(r),E=M*2+k,$=m?"url(#clipPath-".concat(D?"":"dots-").concat(A,")"):void 0;return x.createElement(In,{zIndex:_},x.createElement(Ct,{className:S},m&&x.createElement("defs",null,x.createElement(j4,{clipPathId:A,xAxisId:h,yAxisId:v}),!D&&x.createElement("clipPath",{id:"clipPath-dots-".concat(A)},x.createElement("rect",{x:f-E/2,y:d-E/2,width:y+E,height:b+E}))),x.createElement(DX,{needClip:m,clipPathId:A,props:this.props})),x.createElement(vS,{points:l,mainColor:Df(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:$}),this.props.isRange&&Array.isArray(j)&&x.createElement(vS,{points:j,mainColor:Df(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:$}))}}function zX(e){var t,n=e.activeDot,r=e.animationBegin,l=e.animationDuration,s=e.animationEasing,d=e.connectNulls,f=e.dot,m=e.fill,h=e.fillOpacity,v=e.hide,y=e.isAnimationActive,b=e.legendType,w=e.stroke,j=e.xAxisId,_=e.yAxisId,S=k4(e,bX),A=pl(),C=EC(),M=Zg(j,_),k=M.needClip,D=wn(),E=(t=Ne(ce=>dX(ce,e.id,D)))!==null&&t!==void 0?t:{},$=E.points,U=E.isRange,K=E.baseLine,T=Vg();if(A!=="horizontal"&&A!=="vertical"||T==null||C!=="AreaChart"&&C!=="ComposedChart")return null;var re=T.height,Z=T.width,pe=T.x,fe=T.y;return!$||!$.length?null:x.createElement(PX,Mf({},S,{activeDot:n,animationBegin:r,animationDuration:l,animationEasing:s,baseLine:K,connectNulls:d,dot:f,fill:m,fillOpacity:h,height:re,hide:v,layout:A,isAnimationActive:y,isRange:U,legendType:b,needClip:k,points:$,stroke:w,width:Z,left:pe,top:fe,xAxisId:j,yAxisId:_}))}var IX=(e,t,n,r,l)=>{var s=n??t;if(je(s))return s;var d=e==="horizontal"?l:r,f=d.scale.domain();if(d.type==="number"){var m=Math.max(f[0],f[1]),h=Math.min(f[0],f[1]);return s==="dataMin"?h:s==="dataMax"||m<0?m:Math.max(Math.min(f[0],f[1]),0)}return s==="dataMin"?f[0]:s==="dataMax"?f[1]:f[0]};function $X(e){var t=e.areaSettings,n=t.connectNulls,r=t.baseValue,l=t.dataKey,s=e.stackedData,d=e.layout,f=e.chartBaseValue,m=e.xAxis,h=e.yAxis,v=e.displayedData,y=e.dataStartIndex,b=e.xAxisTicks,w=e.yAxisTicks,j=e.bandSize,_=s&&s.length,S=IX(d,f,r,m,h),A=d==="horizontal",C=!1,M=v.map((D,E)=>{var $,U,K,T;if(_)T=s[y+E];else{var re=rt(D,l);Array.isArray(re)?(T=re,C=!0):T=[S,re]}var Z=($=(U=T)===null||U===void 0?void 0:U[1])!==null&&$!==void 0?$:null,pe=Z==null||_&&!n&&rt(D,l)==null;if(A){var fe;return{x:s_({axis:m,ticks:b,bandSize:j,entry:D,index:E}),y:pe?null:(fe=h.scale.map(Z))!==null&&fe!==void 0?fe:null,value:T,payload:D}}return{x:pe?null:(K=m.scale.map(Z))!==null&&K!==void 0?K:null,y:s_({axis:h,ticks:w,bandSize:j,entry:D,index:E}),value:T,payload:D}}),k;return _||C?k=M.map(D=>{var E,$=Array.isArray(D.value)?D.value[0]:null;if(A){var U;return{x:D.x,y:$!=null&&D.y!=null&&(U=h.scale.map($))!==null&&U!==void 0?U:null,payload:D.payload}}return{x:$!=null&&(E=m.scale.map($))!==null&&E!==void 0?E:null,y:D.y,payload:D.payload}}):k=A?h.scale.map(S):m.scale.map(S),{points:M,baseLine:k??0,isRange:C}}function RX(e){var t=an(e,C4),n=wn();return x.createElement(Gg,{id:t.id,type:"area"},r=>x.createElement(x.Fragment,null,x.createElement(i4,{legendPayload:AX(t)}),x.createElement(OX,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:r}),x.createElement(c4,{type:"area",id:r,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:GO(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),x.createElement(zX,Mf({},t,{id:r}))))}var T4=x.memo(RX,$s);T4.displayName="Area";var LX="Invariant failed";function BX(e,t){throw new Error(LX)}var UX=["option"];function HX(e,t){if(e==null)return{};var n,r,l=qX(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r1&&arguments[1]!==void 0?arguments[1]:0;return(r,l)=>{if(je(t))return t;var s=je(r)||Nt(r);return s?t(r,l):(s||BX(),n)}},YX=(e,t,n)=>n,GX=(e,t)=>t,Gc=X([wm,GX],(e,t)=>e.filter(n=>n.type==="bar").find(n=>n.id===t)),VX=X([Gc],e=>e==null?void 0:e.maxBarSize),FX=(e,t,n,r)=>r,XX=X([Ze,wm,Xr,Wr,YX],(e,t,n,r,l)=>t.filter(s=>e==="horizontal"?s.xAxisId===n:s.yAxisId===r).filter(s=>s.isPanorama===l).filter(s=>s.hide===!1).filter(s=>s.type==="bar")),WX=(e,t,n)=>{var r=Ze(e),l=Xr(e,t),s=Wr(e,t);if(!(l==null||s==null))return r==="horizontal"?Nf(e,"yAxis",s,n):Nf(e,"xAxis",l,n)},ZX=(e,t)=>{var n=Ze(e),r=Xr(e,t),l=Wr(e,t);if(!(r==null||l==null))return n==="horizontal"?vN(e,"xAxis",r):vN(e,"yAxis",l)},QX=X([XX,e9,ZX],zV),JX=(e,t,n)=>{var r,l,s=Gc(e,t);if(s==null)return 0;var d=Xr(e,t),f=Wr(e,t);if(d==null||f==null)return 0;var m=Ze(e),h=IE(e),v=s.maxBarSize,y=Nt(v)?h:v,b,w;return m==="horizontal"?(b=pi(e,"xAxis",d,n),w=hi(e,"xAxis",d,n)):(b=pi(e,"yAxis",f,n),w=hi(e,"yAxis",f,n)),(r=(l=As(b,w,!0))!==null&&l!==void 0?l:y)!==null&&r!==void 0?r:0},M4=(e,t,n)=>{var r=Ze(e),l=Xr(e,t),s=Wr(e,t);if(!(l==null||s==null)){var d,f;return r==="horizontal"?(d=pi(e,"xAxis",l,n),f=hi(e,"xAxis",l,n)):(d=pi(e,"yAxis",s,n),f=hi(e,"yAxis",s,n)),As(d,f)}},eW=X([QX,IE,J7,$E,JX,M4,VX],BV),tW=(e,t,n)=>{var r=Xr(e,t);if(r!=null)return pi(e,"xAxis",r,n)},nW=(e,t,n)=>{var r=Wr(e,t);if(r!=null)return pi(e,"yAxis",r,n)},rW=(e,t,n)=>{var r=Xr(e,t);if(r!=null)return hi(e,"xAxis",r,n)},aW=(e,t,n)=>{var r=Wr(e,t);if(r!=null)return hi(e,"yAxis",r,n)},iW=X([eW,Gc],HV),lW=X([WX,Gc],UV),sW=X([Wt,d0,tW,nW,rW,aW,iW,Ze,NE,M4,lW,Gc,FX],(e,t,n,r,l,s,d,f,m,h,v,y,b)=>{var w=m.chartData,j=m.dataStartIndex,_=m.dataEndIndex;if(!(y==null||d==null||t==null||f!=="horizontal"&&f!=="vertical"||n==null||r==null||l==null||s==null||h==null)){var S=y.data,A;if(S!=null&&S.length>0?A=S:A=w==null?void 0:w.slice(j,_+1),A!=null)return BW({layout:f,barSettings:y,pos:d,parentViewBox:t,bandSize:h,xAxis:n,yAxis:r,xAxisTicks:l,yAxisTicks:s,stackedData:v,displayedData:A,offset:e,cells:b,dataStartIndex:j})}}),oW=["index"];function Py(){return Py=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t=x.useContext(D4);if(t!=null)return t.stackId;if(e!=null)return GO(e)},fW=(e,t)=>"recharts-bar-stack-clip-path-".concat(e,"-").concat(t),mW=e=>{var t=x.useContext(D4);if(t!=null){var n=t.stackId;return"url(#".concat(fW(n,e),")")}},P4=e=>{var t=e.index,n=cW(e,oW),r=mW(t);return x.createElement(Ct,Py({className:"recharts-bar-stack-layer",clipPath:r},n))},hW=["onMouseEnter","onMouseLeave","onClick"],pW=["value","background","tooltipPosition"],vW=["id"],yW=["onMouseEnter","onClick","onMouseLeave"];function kS(e,t){return wW(e)||bW(e,t)||xW(e,t)||gW()}function gW(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xW(e,t){if(e){if(typeof e=="string")return CS(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?CS(e,t):void 0}}function CS(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n{var t=e.dataKey,n=e.name,r=e.fill,l=e.legendType,s=e.hide;return[{inactive:s,dataKey:t,type:l,color:r,value:Is(n,t),payload:e}]},OW=x.memo(e=>{var t=e.dataKey,n=e.stroke,r=e.strokeWidth,l=e.fill,s=e.name,d=e.hide,f=e.unit,m=e.tooltipType,h=e.id,v={dataDefinedOnItem:void 0,getPosition:hl,settings:{stroke:n,strokeWidth:r,fill:l,dataKey:t,nameKey:void 0,name:Is(s,t),hide:d,type:m,color:l,unit:f,graphicalItemId:h}};return x.createElement(Bg,{tooltipEntrySettings:v})});function EW(e){var t=Ne(vi),n=e.data,r=e.dataKey,l=e.background,s=e.allOtherBarProps,d=s.onMouseEnter,f=s.onMouseLeave,m=s.onClick,h=Pf(s,hW),v=$g(d,r,s.id),y=Rg(f),b=Lg(m,r,s.id);if(!l||n==null)return null;var w=rl(l);return x.createElement(In,{zIndex:qV(l,qt.barBackground)},n.map((j,_)=>{j.value;var S=j.background;j.tooltipPosition;var A=Pf(j,pW);if(!S)return null;var C=v(j,j.originalDataIndex),M=y(j,j.originalDataIndex),k=b(j,j.originalDataIndex),D=Ft(Ft(Ft(Ft(Ft({option:l,isActive:String(j.originalDataIndex)===t},A),{},{fill:"#eee"},S),w),Oc(h,j,_)),{},{onMouseEnter:C,onMouseLeave:M,onClick:k,dataKey:r,index:_,className:"recharts-bar-background-rectangle"});return x.createElement(Jg,yi({key:"background-bar-".concat(_)},D))}))}function kW(e){var t=e.showLabels,n=e.children,r=e.rects,l=r==null?void 0:r.map(s=>{var d={x:s.x,y:s.y,width:s.width,lowerWidth:s.width,upperWidth:s.width,height:s.height};return Ft(Ft({},d),{},{value:s.value,payload:s.payload,parentViewBox:s.parentViewBox,viewBox:d,fill:s.fill})});return x.createElement(FC,{value:t?l:void 0},n)}function CW(e){var t=e.shape,n=e.activeBar,r=e.baseProps,l=e.entry,s=e.index,d=e.dataKey,f=Ne(vi),m=Ne(Ng),h=n&&String(l.originalDataIndex)===f&&(m==null||d===m),v=x.useState(!1),y=kS(v,2),b=y[0],w=y[1],j=x.useState(!1),_=kS(j,2),S=_[0],A=_[1];x.useEffect(()=>{var $;return h?(w(!0),$=requestAnimationFrame(()=>{A(!0)})):A(!1),()=>{cancelAnimationFrame($)}},[h]);var C=x.useCallback(()=>{h||w(!1)},[h]),M=h&&S,k=h||b,D;h?n===!0?D=t:D=n:D=t;var E=x.createElement(Jg,yi({},r,{name:String(r.name)},l,{isActive:M,option:D,index:s,dataKey:d,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance,onTransitionEnd:C}));return k?x.createElement(In,{zIndex:qt.activeBar},x.createElement(P4,{index:l.originalDataIndex},E)):E}function TW(e){var t=e.shape,n=e.baseProps,r=e.entry,l=e.index,s=e.dataKey;return x.createElement(Jg,yi({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:l,dataKey:s,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance}))}function MW(e){var t,n=e.data,r=e.props,l=e.animationElapsedTime,s=e.isAnimating,d=e.isEntrance,f=(t=zn(r))!==null&&t!==void 0?t:{},m=f.id,h=Pf(f,vW),v=r.shape,y=r.dataKey,b=r.activeBar,w=r.onMouseEnter,j=r.onClick,_=r.onMouseLeave,S=Pf(r,yW),A=$g(w,y,m),C=Rg(_),M=Lg(j,y,m);return n?x.createElement(x.Fragment,null,n.map((k,D)=>x.createElement(P4,yi({index:k.originalDataIndex,key:"rectangle-".concat(k==null?void 0:k.x,"-").concat(k==null?void 0:k.y,"-").concat(k==null?void 0:k.value,"-").concat(D),className:"recharts-bar-rectangle"},Oc(S,k,D),{onMouseEnter:A(k,k.originalDataIndex),onMouseLeave:C(k,k.originalDataIndex),onClick:M(k,k.originalDataIndex)}),b?x.createElement(CW,{shape:v,activeBar:b,baseProps:h,entry:k,index:D,dataKey:y,animationElapsedTime:l,isAnimating:s,isEntrance:d}):x.createElement(TW,{shape:v,baseProps:h,entry:k,index:D,dataKey:y,animationElapsedTime:l,isAnimating:s,isEntrance:d})))):null}var DW=(e,t,n)=>e==null?[]:t===1?e.flatMap(r=>r.status==="removed"?[]:[r.next]):e.flatMap(r=>{if(r.status==="removed")return n==="horizontal"?[Ft(Ft({},r.prev),{},{height:Et(r.prev.height,0,t),y:Et(r.prev.y,r.prev.y+r.prev.height,t)})]:[Ft(Ft({},r.prev),{},{width:Et(r.prev.width,0,t)})];if(r.status==="matched")return[Ft(Ft({},r.next),{},{x:Et(r.prev.x,r.next.x,t),y:Et(r.prev.y,r.next.y,t),width:Et(r.prev.width,r.next.width,t),height:Et(r.prev.height,r.next.height,t)})];var l=r.next;return n==="horizontal"?[Ft(Ft({},l),{},{height:Et(0,l.height,t),y:Et(l.stackedBarStart,l.y,t)})]:[Ft(Ft({},l),{},{width:Et(0,l.width,t),x:Et(l.stackedBarStart,l.x,t)})]});function PW(e){var t=e.props,n=e.previousRectanglesRef,r=t.data,l=t.isAnimationActive,s=t.animationBegin,d=t.animationDuration,f=t.animationEasing,m=t.animationInterpolateFn,h=t.layout,v=Kg(t.onAnimationStart,t.onAnimationEnd),y=v.isAnimating,b=v.handleAnimationStart,w=v.handleAnimationEnd;return x.createElement(kW,{showLabels:!y,rects:r},x.createElement(Yg,{animationInput:r,animationIdPrefix:"recharts-bar-",items:r,previousItemsRef:n,isAnimationActive:l,animationBegin:s,animationDuration:d,animationEasing:f,onAnimationStart:b,onAnimationEnd:w,animationInterpolateFn:m,animationMatchBy:t.animationMatchBy,layout:h},(j,_,S)=>x.createElement(Ct,null,x.createElement(MW,{props:t,data:j,animationElapsedTime:_,isAnimating:y||_<1,isEntrance:S}))),x.createElement(Mg,{label:t.label}),t.children)}function zW(e){var t=x.useRef(null);return x.createElement(PW,{previousRectanglesRef:t,props:e})}var z4=0,IW=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:rt(e,t)}};class $W extends x.PureComponent{render(){var t=this.props,n=t.hide,r=t.data,l=t.dataKey,s=t.className,d=t.xAxisId,f=t.yAxisId,m=t.needClip,h=t.background,v=t.id;if(n||r==null)return null;var y=nt("recharts-bar",s),b=v;return x.createElement(Ct,{className:y,id:v},m&&x.createElement("defs",null,x.createElement(j4,{clipPathId:b,xAxisId:d,yAxisId:f})),x.createElement(Ct,{className:"recharts-bar-rectangles",clipPath:m?"url(#clipPath-".concat(b,")"):void 0},x.createElement(EW,{data:r,dataKey:l,background:h,allOtherBarProps:this.props}),x.createElement(zW,this.props)))}}var RW={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",animationInterpolateFn:DW,animationMatchBy:Hg,background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:z4,shape:Qg,xAxisId:0,yAxisId:0,zIndex:qt.bar};function LW(e){var t=e.xAxisId,n=e.yAxisId,r=e.hide,l=e.legendType,s=e.minPointSize,d=e.activeBar,f=e.animationBegin,m=e.animationDuration,h=e.animationEasing,v=e.isAnimationActive,y=Zg(t,n),b=y.needClip,w=pl(),j=wn(),_=zg(e.children,nl),S=Ne(M=>sW(M,e.id,j,_));if(w!=="vertical"&&w!=="horizontal")return null;var A,C=S==null?void 0:S[0];return C==null||C.height==null||C.width==null?A=0:A=w==="vertical"?C.height/2:C.width/2,x.createElement(aX,{xAxisId:t,yAxisId:n,data:S,dataPointFormatter:IW,errorBarOffset:A},x.createElement($W,yi({},e,{layout:w,needClip:b,data:S,xAxisId:t,yAxisId:n,hide:r,legendType:l,minPointSize:s,activeBar:d,animationBegin:f,animationDuration:m,animationEasing:h,isAnimationActive:v})))}function BW(e){var t=e.layout,n=e.barSettings,r=n.dataKey,l=n.minPointSize,s=n.hasCustomShape,d=e.pos,f=e.bandSize,m=e.xAxis,h=e.yAxis,v=e.xAxisTicks,y=e.yAxisTicks,b=e.stackedData,w=e.displayedData,j=e.offset,_=e.cells,S=e.parentViewBox,A=e.dataStartIndex,C=t==="horizontal"?h:m,M=b?C.scale.domain():null,k=uI({numericAxis:C}),D=C.scale.map(k);return w.map((E,$)=>{var U,K,T,re,Z,pe;if(b){var fe=b[$+A];if(fe==null)return null;U=iI(fe,M)}else U=rt(E,r),Array.isArray(U)||(U=[k,U]);var ce=KX(l,z4)(U[1],$);if(t==="horizontal"){var R,z=h.scale.map(U[0]),G=h.scale.map(U[1]);if(z==null||G==null)return null;K=o_({axis:m,ticks:v,bandSize:f,offset:d.offset,entry:E,index:$}),T=(R=G??z)!==null&&R!==void 0?R:void 0,re=d.size;var se=z-G;if(Z=Ar(se)?0:se,pe={x:K,y:j.top,width:re,height:j.height},Math.abs(ce)>0&&Math.abs(Z)0&&Math.abs(re)x.createElement(x.Fragment,null,x.createElement(i4,{legendPayload:AW(t)}),x.createElement(OW,{dataKey:t.dataKey,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:l}),x.createElement(c4,{type:"bar",id:l,data:void 0,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,stackId:n,hide:t.hide,barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize,isPanorama:r,hasCustomShape:t.shape!=null&&t.shape!==Qg}),x.createElement(In,{zIndex:t.zIndex},x.createElement(LW,yi({},t,{id:l})))))}var I4=x.memo(UW,$s);I4.displayName="Bar";var HW=["domain","range"],qW=["domain","range"];function MS(e,t){if(e==null)return{};var n,r,l=KW(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r{if(d!=null)return zS(zS({},s),{},{type:d})},[s,d]);return x.useLayoutEffect(()=>{f!=null&&(n.current===null?t(pV(f)):n.current!==f&&t(vV({prev:n.current,next:f})),n.current=f)},[f,t]),x.useLayoutEffect(()=>()=>{n.current&&(t(yV(n.current)),n.current=null)},[t]),null}var JW=e=>{var t=e.xAxisId,n=e.className,r=Ne(d0),l=wn(),s="xAxis",d=Ne(b=>rC(b,s,t,l)),f=Ne(b=>eC(b,t)),m=Ne(b=>IU(b,t)),h=Ne(b=>Ck(b,t));if(f==null||m==null||h==null)return null;e.dangerouslySetInnerHTML,e.ticks,e.scale;var v=Iy(e,GW);h.id,h.scale;var y=Iy(h,VW);return x.createElement(Xg,zy({},v,y,{x:m.x,y:m.y,width:f.width,height:f.height,className:nt("recharts-".concat(s," ").concat(s),n),viewBox:r,ticks:d,axisType:s,axisId:t}))},eZ={allowDataOverflow:Gt.allowDataOverflow,allowDecimals:Gt.allowDecimals,allowDuplicatedCategory:Gt.allowDuplicatedCategory,angle:Gt.angle,axisLine:Na.axisLine,height:Gt.height,hide:!1,includeHidden:Gt.includeHidden,interval:Gt.interval,label:!1,minTickGap:Gt.minTickGap,mirror:Gt.mirror,orientation:Gt.orientation,padding:Gt.padding,reversed:Gt.reversed,scale:Gt.scale,tick:Gt.tick,tickCount:Gt.tickCount,tickLine:Na.tickLine,tickSize:Na.tickSize,type:Gt.type,niceTicks:Gt.niceTicks,xAxisId:0},tZ=e=>{var t=an(e,eZ);return x.createElement(x.Fragment,null,x.createElement(QW,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),x.createElement(JW,t))},$y=x.memo(tZ,$4);$y.displayName="XAxis";var nZ=["type"],rZ=["dangerouslySetInnerHTML","ticks","scale"],aZ=["id","scale"];function Ry(){return Ry=Object.assign?Object.assign.bind():function(e){for(var t=1;t{if(d!=null)return $S($S({},s),{},{type:d})},[d,s]);return x.useLayoutEffect(()=>{f!=null&&(n.current===null?t(gV(f)):n.current!==f&&t(xV({prev:n.current,next:f})),n.current=f)},[f,t]),x.useLayoutEffect(()=>()=>{n.current&&(t(bV(n.current)),n.current=null)},[t]),null}function uZ(e){var t=e.yAxisId,n=e.className,r=e.width,l=e.label,s=x.useRef(null),d=x.useRef(null),f=Ne(d0),m=wn(),h=dt(),v="yAxis",y=Ne(A=>tC(A,t)),b=Ne(A=>RU(A,t)),w=Ne(A=>rC(A,v,t,m)),j=Ne(A=>Tk(A,t));if(x.useLayoutEffect(()=>{if(!(r!=="auto"||!y||Tg(l)||x.isValidElement(l)||j==null)){var A=s.current;if(A){var C=A.getCalculatedWidth();Math.round(y.width)!==Math.round(C)&&h(wV({id:t,width:C}))}}},[w,y,h,l,t,r,j]),y==null||b==null||j==null)return null;e.dangerouslySetInnerHTML,e.ticks,e.scale;var _=Ly(e,rZ);j.id,j.scale;var S=Ly(j,aZ);return x.createElement(Xg,Ry({},_,S,{ref:s,labelRef:d,x:b.x,y:b.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:y.width,height:y.height,className:nt("recharts-".concat(v," ").concat(v),n),viewBox:f,ticks:w,axisType:v,axisId:t}))}var dZ={allowDataOverflow:Vt.allowDataOverflow,allowDecimals:Vt.allowDecimals,allowDuplicatedCategory:Vt.allowDuplicatedCategory,angle:Vt.angle,axisLine:Na.axisLine,hide:!1,includeHidden:Vt.includeHidden,interval:Vt.interval,label:!1,minTickGap:Vt.minTickGap,mirror:Vt.mirror,orientation:Vt.orientation,padding:Vt.padding,reversed:Vt.reversed,scale:Vt.scale,tick:Vt.tick,tickCount:Vt.tickCount,tickLine:Na.tickLine,tickSize:Na.tickSize,type:Vt.type,niceTicks:Vt.niceTicks,width:Vt.width,yAxisId:0},fZ=e=>{var t=an(e,dZ);return x.createElement(x.Fragment,null,x.createElement(cZ,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),x.createElement(uZ,t))},By=x.memo(fZ,$4);By.displayName="YAxis";var mZ=(e,t)=>t,ex=X([mZ,Ze,KE,ln,wC,za,iq,Wt],fq);function hZ(e){return"getBBox"in e.currentTarget&&typeof e.currentTarget.getBBox=="function"}function tx(e){var t=e.currentTarget.getBoundingClientRect(),n,r;if(hZ(e)){var l=e.currentTarget.getBBox();n=l.width>0?t.width/l.width:1,r=l.height>0?t.height/l.height:1}else{var s=e.currentTarget;n=s.offsetWidth>0?t.width/s.offsetWidth:1,r=s.offsetHeight>0?t.height/s.offsetHeight:1}var d=(f,m)=>({relativeX:Math.round((f-t.left)/n),relativeY:Math.round((m-t.top)/r)});return"touches"in e?Array.from(e.touches).map(f=>d(f.clientX,f.clientY)):d(e.clientX,e.clientY)}var R4=Wn("mouseClick"),L4=kc();L4.startListening({actionCreator:R4,effect:(e,t)=>{var n=e.payload,r=ex(t.getState(),tx(n));(r==null?void 0:r.activeIndex)!=null&&t.dispatch(eH({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var Uy=Wn("mouseMove"),B4=kc(),us=null,Ui=null,zv=null;B4.startListening({actionCreator:Uy,effect:(e,t)=>{var n=e.payload,r=t.getState(),l=r.eventSettings,s=l.throttleDelay,d=l.throttledEvents,f=d==="all"||(d==null?void 0:d.includes("mousemove"));us!==null&&(cancelAnimationFrame(us),us=null),Ui!==null&&(typeof s!="number"||!f)&&(clearTimeout(Ui),Ui=null),zv=tx(n);var m=()=>{var h=t.getState(),v=Kc(h,h.tooltip.settings.shared);if(!zv){us=null,Ui=null;return}if(v==="axis"){var y=ex(h,zv);(y==null?void 0:y.activeIndex)!=null?t.dispatch(dC({activeIndex:y.activeIndex,activeDataKey:void 0,activeCoordinate:y.activeCoordinate})):t.dispatch(uC())}us=null,Ui=null};if(!f){m();return}s==="raf"?us=requestAnimationFrame(m):typeof s=="number"&&Ui===null&&(Ui=setTimeout(m,s))}});function pZ(e,t){return t instanceof HTMLElement?"HTMLElement <".concat(t.tagName,' class="').concat(t.className,'">'):t===window?"global.window":e==="children"&&typeof t=="object"&&t!==null?"<>":t}var RS={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index",baseValue:void 0,reverseStackOrder:!1},U4=bn({name:"rootProps",initialState:RS,reducers:{updateOptions:(e,t)=>{var n;e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=(n=t.payload.barGap)!==null&&n!==void 0?n:RS.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),vZ=U4.reducer,yZ=U4.actions.updateOptions,gZ=null,xZ={updatePolarOptions:(e,t)=>e===null?t.payload:(e.startAngle=t.payload.startAngle,e.endAngle=t.payload.endAngle,e.cx=t.payload.cx,e.cy=t.payload.cy,e.innerRadius=t.payload.innerRadius,e.outerRadius=t.payload.outerRadius,e)},H4=bn({name:"polarOptions",initialState:gZ,reducers:xZ}),bZ=H4.actions.updatePolarOptions,wZ=H4.reducer,q4=Wn("keyDown"),K4=Wn("focus"),Y4=Wn("blur"),Mm=kc(),ds=null,Hi=null,Ad=null;Mm.startListening({actionCreator:q4,effect:(e,t)=>{Ad=e.payload,ds!==null&&(cancelAnimationFrame(ds),ds=null);var n=t.getState(),r=n.eventSettings,l=r.throttleDelay,s=r.throttledEvents,d=s==="all"||s.includes("keydown");Hi!==null&&(typeof l!="number"||!d)&&(clearTimeout(Hi),Hi=null);var f=()=>{try{var m=t.getState(),h=m.rootProps.accessibilityLayer!==!1;if(!h)return;var v=m.tooltip.keyboardInteraction,y=Ad;if(y!=="ArrowRight"&&y!=="ArrowLeft"&&y!=="Enter")return;var b=sc(v,ul(m),Ms(m),Ds(m)),w=b==null?-1:Number(b),j=!Number.isFinite(w)||w<0,_=za(m),S=ul(m),A=Kc(m,m.tooltip.settings.shared);if(y==="Enter"){if(j)return;var C=Of(m,A,"hover",String(v.index));t.dispatch(Af({active:!v.active,activeIndex:v.index,activeCoordinate:C}));return}var M=qU(m),k=M==="left-to-right"?1:-1,D=y==="ArrowRight"?1:-1,E;if(j){var $=Ms(m),U=Ds(m),K=D*k,T=ce=>({active:!1,index:String(ce),dataKey:void 0,graphicalItemId:void 0,coordinate:void 0});if(E=-1,K>0){for(var re=0;re=0;Z--)if(sc(T(Z),S,$,U)!=null){E=Z;break}if(E<0)return}else{E=w+D*k;var pe=(_==null?void 0:_.length)||S.length;if(pe===0||E>=pe||E<0)return}var fe=Of(m,A,"hover",String(E));t.dispatch(Af({active:!0,activeIndex:E.toString(),activeCoordinate:fe}))}finally{ds=null,Hi=null}};if(!d){f();return}l==="raf"?ds=requestAnimationFrame(f):typeof l=="number"&&Hi===null&&(f(),Ad=null,Hi=setTimeout(()=>{Ad?f():(Hi=null,ds=null)},l))}});Mm.startListening({actionCreator:K4,effect:(e,t)=>{var n=t.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var l=n.tooltip.keyboardInteraction;if(!l.active&&l.index==null){var s="0",d=Kc(n,n.tooltip.settings.shared),f=Of(n,d,"hover",String(s));t.dispatch(Af({active:!0,activeIndex:s,activeCoordinate:f}))}}}});Mm.startListening({actionCreator:Y4,effect:(e,t)=>{var n=t.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var l=n.tooltip.keyboardInteraction;l.active&&t.dispatch(Af({active:!1,activeIndex:l.index,activeCoordinate:l.coordinate}))}}});function G4(e){e.persist();var t=e.currentTarget;return new Proxy(e,{get:(n,r)=>{if(r==="currentTarget")return t;var l=Reflect.get(n,r);return typeof l=="function"?l.bind(n):l}})}var dr=Wn("externalEvent"),V4=kc(),Od=new Map,Wo=new Map,Iv=new Map;V4.startListening({actionCreator:dr,effect:(e,t)=>{var n=e.payload,r=n.handler,l=n.reactEvent;if(r!=null){var s=l.type,d=G4(l);Iv.set(s,{handler:r,reactEvent:d});var f=Od.get(s);f!==void 0&&(cancelAnimationFrame(f),Od.delete(s));var m=t.getState(),h=m.eventSettings,v=h.throttleDelay,y=h.throttledEvents,b=y,w=b==="all"||(b==null?void 0:b.includes(s)),j=Wo.get(s);j!==void 0&&(typeof v!="number"||!w)&&(clearTimeout(j),Wo.delete(s));var _=()=>{var C=Iv.get(s);try{if(!C)return;var M=C.handler,k=C.reactEvent,D=t.getState(),E={activeCoordinate:KH(D),activeDataKey:Ng(D),activeIndex:vi(D),activeLabel:NC(D),activeTooltipIndex:vi(D),isTooltipActive:YH(D)};M&&M(E,k)}finally{Od.delete(s),Wo.delete(s),Iv.delete(s)}};if(!w){_();return}if(v==="raf"){var S=requestAnimationFrame(_);Od.set(s,S)}else if(typeof v=="number"){if(!Wo.has(s)){_();var A=setTimeout(_,v);Wo.set(s,A)}}else _()}}});var jZ=X([Ys],e=>e.tooltipItemPayloads),_Z=X([jZ,(e,t)=>t,(e,t,n)=>n],(e,t,n)=>{if(t!=null){var r=e.find(s=>s.settings.graphicalItemId===n);if(r!=null){var l=r.getPosition;if(l!=null)return l(t)}}}),F4=Wn("touchMove"),X4=kc(),qi=null,li=null,LS=null,Zo=null;X4.startListening({actionCreator:F4,effect:(e,t)=>{var n=e.payload;if(!(n.touches==null||n.touches.length===0)){Zo=G4(n);var r=t.getState(),l=r.eventSettings,s=l.throttleDelay,d=l.throttledEvents,f=d==="all"||d.includes("touchmove");qi!==null&&(cancelAnimationFrame(qi),qi=null),li!==null&&(typeof s!="number"||!f)&&(clearTimeout(li),li=null),LS=Array.from(n.touches).map(h=>tx({clientX:h.clientX,clientY:h.clientY,currentTarget:n.currentTarget}));var m=()=>{if(Zo!=null){var h=t.getState(),v=Kc(h,h.tooltip.settings.shared);if(v==="axis"){var y,b=(y=LS)===null||y===void 0?void 0:y[0];if(b==null){qi=null,li=null;return}var w=ex(h,b);(w==null?void 0:w.activeIndex)!=null&&t.dispatch(dC({activeIndex:w.activeIndex,activeDataKey:void 0,activeCoordinate:w.activeCoordinate}))}else if(v==="item"){var j,_=Zo.touches[0];if(document.elementFromPoint==null||_==null)return;var S=document.elementFromPoint(_.clientX,_.clientY);if(!S||!S.getAttribute)return;var A=S.getAttribute(FO),C=(j=S.getAttribute(XO))!==null&&j!==void 0?j:void 0,M=gl(h).find(E=>E.id===C);if(A==null||M==null||C==null)return;var k=M.dataKey,D=_Z(h,A,C);t.dispatch(cC({activeDataKey:k,activeIndex:A,activeCoordinate:D,activeGraphicalItemId:C}))}qi=null,li=null}};if(!f){m();return}s==="raf"?qi=requestAnimationFrame(m):typeof s=="number"&&li===null&&(m(),Zo=null,li=setTimeout(()=>{Zo?m():(li=null,qi=null)},s))}}});var nx={throttleDelay:"raf",throttledEvents:["mousemove","touchmove","pointermove","scroll","wheel"]},W4=bn({name:"eventSettings",initialState:nx,reducers:{setEventSettings:(e,t)=>{t.payload.throttleDelay!=null&&(e.throttleDelay=t.payload.throttleDelay),t.payload.throttledEvents!=null&&(e.throttledEvents=t.payload.throttledEvents)}}}),NZ=W4.actions.setEventSettings,SZ=W4.reducer,AZ=pO({brush:KV,cartesianAxis:jV,chartData:Hq,errorBars:QF,eventSettings:SZ,graphicalItems:SG,layout:eI,legend:f$,options:$q,polarAxis:TY,polarOptions:wZ,referenceElements:FV,renderedTicks:vF,rootProps:vZ,tooltip:tH,zIndex:Sq}),OZ=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Chart";return S8({reducer:AZ,preloadedState:t,middleware:r=>{var l;return r({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((l="es6")!==null&&l!==void 0?l:"")}).concat([L4.middleware,B4.middleware,Mm.middleware,V4.middleware,X4.middleware])},enhancers:r=>{var l=r;return typeof r=="function"&&(l=r()),l.concat(CO({type:"raf"}))},devTools:{serialize:{replacer:pZ},name:"recharts-".concat(n)}})};function Z4(e){var t=e.preloadedState,n=e.children,r=e.reduxStoreName,l=wn(),s=x.useRef(null);if(l)return n;s.current==null&&(s.current=OZ(t,r));var d=a0;return x.createElement(E$,{context:d,store:s.current},n)}function EZ(e){var t=e.layout,n=e.margin,r=dt(),l=wn();return x.useEffect(()=>{l||(r(Z8(t)),r(W8(n)))},[r,l,t,n]),null}var Q4=x.memo(EZ,$s);function J4(e){var t=dt();return x.useEffect(()=>{t(yZ(e))},[t,e]),null}var kZ=e=>{var t=dt();return x.useEffect(()=>{t(NZ(e))},[t,e]),null},e5=x.memo(kZ,$s);function BS(e){var t=e.zIndex,n=e.isPanorama,r=x.useRef(null),l=dt();return x.useLayoutEffect(()=>(r.current&&l(_q({zIndex:t,element:r.current,isPanorama:n})),()=>{l(Nq({zIndex:t,isPanorama:n}))}),[l,t,n]),x.createElement("g",{tabIndex:-1,ref:r,className:"recharts-zIndex-layer_".concat(t)})}function US(e){var t=e.children,n=e.isPanorama,r=Ne(hq);if(!r||r.length===0)return t;var l=r.filter(d=>d<0),s=r.filter(d=>d>0);return x.createElement(x.Fragment,null,l.map(d=>x.createElement(BS,{key:d,zIndex:d,isPanorama:n})),t,s.map(d=>x.createElement(BS,{key:d,zIndex:d,isPanorama:n})))}var CZ=["children"];function TZ(e,t){if(e==null)return{};var n,r,l=MZ(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r{var n=h0(),r=p0(),l=fE();if(!Kr(n)||!Kr(r))return null;var s=e.children,d=e.otherAttributes,f=e.title,m=e.desc,h,v;return d!=null&&(typeof d.tabIndex=="number"?h=d.tabIndex:h=l?0:void 0,typeof d.role=="string"?v=d.role:v=l?"application":void 0),x.createElement(Wy,zf({},d,{title:f,desc:m,role:v,tabIndex:h,width:n,height:r,style:DZ,ref:t}),s)}),zZ=e=>{var t=e.children,n=Ne(nm);if(!n)return null;var r=n.width,l=n.height,s=n.y,d=n.x;return x.createElement(Wy,{width:r,height:l,x:d,y:s},t)},HS=x.forwardRef((e,t)=>{var n=e.children,r=TZ(e,CZ),l=wn();return l?x.createElement(zZ,null,x.createElement(US,{isPanorama:!0},n)):x.createElement(PZ,zf({ref:t},r),x.createElement(US,{isPanorama:!1},n))});function IZ(e,t){return BZ(e)||LZ(e,t)||RZ(e,t)||$Z()}function $Z(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function RZ(e,t){if(e){if(typeof e=="string")return qS(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?qS(e,t):void 0}}function qS(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n{if(r!=null){var d=r.getBoundingClientRect(),f=d.width/r.offsetWidth;He(f)&&f!==s&&e(J8(f))}},[r,e,s]),l}function KS(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function HZ(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=Array(t);n(Zq(),null);function $f(e){if(typeof e=="number")return e;if(typeof e=="string"){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var ZZ=x.forwardRef((e,t)=>{var n,r,l=x.useRef(null),s=x.useState({containerWidth:$f((n=e.style)===null||n===void 0?void 0:n.width),containerHeight:$f((r=e.style)===null||r===void 0?void 0:r.height)}),d=If(s,2),f=d[0],m=d[1],h=x.useCallback((y,b)=>{m(w=>{var j=Math.round(y),_=Math.round(b);return w.containerWidth===j&&w.containerHeight===_?w:{containerWidth:j,containerHeight:_}})},[]),v=x.useCallback(y=>{if(typeof t=="function"&&t(y),l.current!=null&&(l.current.disconnect(),l.current=null),y!=null&&typeof ResizeObserver<"u"){var b=y.getBoundingClientRect(),w=b.width,j=b.height;h(w,j);var _=A=>{var C=A[0];if(C!=null){var M=C.contentRect,k=M.width,D=M.height;h(k,D)}},S=new ResizeObserver(_);S.observe(y),l.current=S}},[t,h]);return x.useEffect(()=>()=>{var y=l.current;y!=null&&y.disconnect()},[h]),x.createElement(x.Fragment,null,x.createElement(Tc,{width:f.containerWidth,height:f.containerHeight}),x.createElement("div",mi({ref:v},e)))}),QZ=x.forwardRef((e,t)=>{var n=e.width,r=e.height,l=x.useState({containerWidth:$f(n),containerHeight:$f(r)}),s=If(l,2),d=s[0],f=s[1],m=x.useCallback((v,y)=>{f(b=>{var w=Math.round(v),j=Math.round(y);return b.containerWidth===w&&b.containerHeight===j?b:{containerWidth:w,containerHeight:j}})},[]),h=x.useCallback(v=>{if(typeof t=="function"&&t(v),v!=null){var y=v.getBoundingClientRect(),b=y.width,w=y.height;m(b,w)}},[t,m]);return x.createElement(x.Fragment,null,x.createElement(Tc,{width:d.containerWidth,height:d.containerHeight}),x.createElement("div",mi({ref:h},e)))}),JZ=x.forwardRef((e,t)=>{var n=e.width,r=e.height;return x.createElement(x.Fragment,null,x.createElement(Tc,{width:n,height:r}),x.createElement("div",mi({ref:t},e)))}),eQ=x.forwardRef((e,t)=>{var n=e.width,r=e.height;return typeof n=="string"||typeof r=="string"?x.createElement(QZ,mi({},e,{ref:t})):typeof n=="number"&&typeof r=="number"?x.createElement(JZ,mi({},e,{width:n,height:r,ref:t})):x.createElement(x.Fragment,null,x.createElement(Tc,{width:n,height:r}),x.createElement("div",mi({ref:t},e)))});function tQ(e){return e?ZZ:eQ}var nQ=x.forwardRef((e,t)=>{var n=e.children,r=e.className,l=e.height,s=e.onClick,d=e.onContextMenu,f=e.onDoubleClick,m=e.onMouseDown,h=e.onMouseEnter,v=e.onMouseLeave,y=e.onMouseMove,b=e.onMouseUp,w=e.onTouchEnd,j=e.onTouchMove,_=e.onTouchStart,S=e.style,A=e.width,C=e.responsive,M=e.dispatchTouchEvents,k=M===void 0?!0:M,D=x.useRef(null),E=dt(),$=x.useState(null),U=If($,2),K=U[0],T=U[1],re=x.useState(null),Z=If(re,2),pe=Z[0],fe=Z[1],ce=UZ(),R=f0(),z=(R==null?void 0:R.width)>0?R.width:A,G=(R==null?void 0:R.height)>0?R.height:l,se=x.useCallback(Y=>{ce(Y),typeof t=="function"&&t(Y),T(Y),fe(Y),Y!=null&&(D.current=Y)},[ce,t,T,fe]),ue=x.useCallback(Y=>{E(R4(Y)),E(dr({handler:s,reactEvent:Y}))},[E,s]),P=x.useCallback(Y=>{E(Uy(Y)),E(dr({handler:h,reactEvent:Y}))},[E,h]),Q=x.useCallback(Y=>{E(uC()),E(dr({handler:v,reactEvent:Y}))},[E,v]),ne=x.useCallback(Y=>{E(Uy(Y)),E(dr({handler:y,reactEvent:Y}))},[E,y]),I=x.useCallback(()=>{E(K4())},[E]),he=x.useCallback(()=>{E(Y4())},[E]),be=x.useCallback(Y=>{E(q4(Y.key))},[E]),_e=x.useCallback(Y=>{E(dr({handler:d,reactEvent:Y}))},[E,d]),W=x.useCallback(Y=>{E(dr({handler:f,reactEvent:Y}))},[E,f]),V=x.useCallback(Y=>{E(dr({handler:m,reactEvent:Y}))},[E,m]),ye=x.useCallback(Y=>{E(dr({handler:b,reactEvent:Y}))},[E,b]),xe=x.useCallback(Y=>{E(dr({handler:_,reactEvent:Y}))},[E,_]),ae=x.useCallback(Y=>{k&&E(F4(Y)),E(dr({handler:j,reactEvent:Y}))},[E,k,j]),Le=x.useCallback(Y=>{E(dr({handler:w,reactEvent:Y}))},[E,w]),Ce=tQ(C);return x.createElement(DC.Provider,{value:K},x.createElement(AA.Provider,{value:pe},x.createElement(Ce,{width:z??(S==null?void 0:S.width),height:G??(S==null?void 0:S.height),className:nt("recharts-wrapper",r),style:HZ({position:"relative",cursor:"default",width:z,height:G},S),onClick:ue,onContextMenu:_e,onDoubleClick:W,onFocus:I,onBlur:he,onKeyDown:be,onMouseDown:V,onMouseEnter:P,onMouseLeave:Q,onMouseMove:ne,onMouseUp:ye,onTouchEnd:Le,onTouchMove:ae,onTouchStart:xe,ref:se},x.createElement(WZ,null),n)))}),rQ=["width","height","responsive","children","className","style","compact","title","desc"];function aQ(e,t){if(e==null)return{};var n,r,l=iQ(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r{var n=e.width,r=e.height,l=e.responsive,s=e.children,d=e.className,f=e.style,m=e.compact,h=e.title,v=e.desc,y=aQ(e,rQ),b=zn(y);return m?x.createElement(x.Fragment,null,x.createElement(Tc,{width:n,height:r}),x.createElement(HS,{otherAttributes:b,title:h,desc:v},s)):x.createElement(nQ,{className:d,style:f,width:n,height:r,responsive:l??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},x.createElement(HS,{otherAttributes:b,title:h,desc:v,ref:t},x.createElement(tF,null,s)))});function Hy(){return Hy=Object.assign?Object.assign.bind():function(e){for(var t=1;tx.createElement(n5,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:fQ,tooltipPayloadSearcher:kg,categoricalChartProps:e,ref:t}));function hQ(e){var t=dt();return x.useEffect(()=>{t(bZ(e))},[t,e]),null}var pQ=["layout"];function qy(){return qy=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=an(e,EQ);return x.createElement(_Q,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:OQ,tooltipPayloadSearcher:kg,categoricalChartProps:n,ref:t})}),kQ=["axis"],CQ=x.forwardRef((e,t)=>x.createElement(n5,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:kQ,tooltipPayloadSearcher:kg,categoricalChartProps:e,ref:t}));const TQ=({status:e})=>{const t={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-[#0094f7] text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600"},n={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中"};return c.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${t[e]||t.cancelled}`,children:n[e]||e})},Ed=({title:e,value:t,icon:n,colorClass:r,trend:l})=>c.jsxs("div",{className:"ios-card p-6 rounded-xl flex flex-col justify-between hover:translate-y-[-4px] transition-all duration-300 h-full relative overflow-hidden group border-0",children:[c.jsx("div",{className:`absolute -right-6 -top-6 w-32 h-32 ${r} opacity-10 rounded-full group-hover:scale-125 transition-transform duration-500 blur-2xl`}),c.jsxs("div",{className:"flex justify-between items-start mb-6",children:[c.jsx("div",{className:`p-4 rounded-2xl ${r} bg-opacity-10 backdrop-blur-sm`,children:c.jsx(n,{className:`w-6 h-6 ${r.replace("bg-","text-")}`})}),l&&c.jsxs("span",{className:"text-xs font-bold text-white bg-[#0094f7] px-3 py-1.5 rounded-full flex items-center gap-1 shadow-sm",children:[c.jsx(lD,{className:"w-3 h-3"})," ",l]})]}),c.jsxs("div",{className:"relative z-10",children:[c.jsx("h3",{className:"text-3xl font-extrabold text-gray-900 tracking-tight font-feature-settings-tnum",children:t}),c.jsx("p",{className:"text-gray-500 text-sm font-medium mt-1",children:e})]})]}),ZS=()=>{var be,_e;const[e,t]=x.useState(null),[n,r]=x.useState(null),[l,s]=x.useState("7days"),[d,f]=x.useState(""),[m,h]=x.useState(""),[v,y]=x.useState(null),[b,w]=x.useState(""),[j,_]=x.useState([]),[S,A]=x.useState(!1),[C,M]=x.useState([]),[k,D]=x.useState({}),E=["#0094f7","#3B82F6","#10B981","#F59E0B","#8B5CF6"],$=W=>{const V=W.getFullYear(),ye=String(W.getMonth()+1).padStart(2,"0"),xe=String(W.getDate()).padStart(2,"0");return`${V}-${ye}-${xe}`},U=W=>{const V=new Date,ye=$(V);let xe=ye;if(W==="yesterday"){const ae=new Date(V);ae.setDate(ae.getDate()-1);const Le=$(ae);return{startDate:Le,endDate:Le}}if(W==="3days"){const ae=new Date(V);ae.setDate(ae.getDate()-3),xe=$(ae)}else if(W==="7days"){const ae=new Date(V);ae.setDate(ae.getDate()-7),xe=$(ae)}else if(W==="30days"){const ae=new Date(V);ae.setDate(ae.getDate()-30),xe=$(ae)}else{if(W==="custom"&&d&&m)return{startDate:d,endDate:m};if(W==="custom"){const ae=new Date(V);ae.setDate(ae.getDate()-7),xe=$(ae)}}return{startDate:xe,endDate:ye}},K=W=>{const{startDate:V,endDate:ye}=U(W);A(!0),UD({start_date:V,end_date:ye}).then(_).catch(console.error).finally(()=>A(!1))},T=W=>{const V=new Date,{startDate:ye,endDate:xe}=U(W),ae={start_date:ye,end_date:xe},Le=re(W,V);Le&&bj(Le).then(y).catch(console.error),bj(ae).then(r).catch(console.error)},re=(W,V)=>{switch(V.getFullYear(),String(V.getMonth()+1).padStart(2,"0"),String(V.getDate()).padStart(2,"0"),W){case"today":const ye=new Date(V);ye.setDate(ye.getDate()-1);const xe=ye.getFullYear(),ae=String(ye.getMonth()+1).padStart(2,"0"),Le=String(ye.getDate()).padStart(2,"0");return{start_date:`${xe}-${ae}-${Le}`,end_date:`${xe}-${ae}-${Le}`};case"yesterday":const Ce=new Date(V);Ce.setDate(Ce.getDate()-2);const Y=Ce.getFullYear(),ge=String(Ce.getMonth()+1).padStart(2,"0"),Pe=String(Ce.getDate()).padStart(2,"0");return{start_date:`${Y}-${ge}-${Pe}`,end_date:`${Y}-${ge}-${Pe}`};case"7days":const Be=new Date(V);Be.setDate(Be.getDate()-7);const Ve=new Date(Be);return Ve.setDate(Ve.getDate()-7),{start_date:`${Ve.getFullYear()}-${String(Ve.getMonth()+1).padStart(2,"0")}-${String(Ve.getDate()).padStart(2,"0")}`,end_date:`${Be.getFullYear()}-${String(Be.getMonth()+1).padStart(2,"0")}-${String(Be.getDate()).padStart(2,"0")}`};case"30days":const Dt=new Date(V);Dt.setDate(Dt.getDate()-30);const ie=new Date(Dt);return ie.setDate(ie.getDate()-30),{start_date:`${ie.getFullYear()}-${String(ie.getMonth()+1).padStart(2,"0")}-${String(ie.getDate()).padStart(2,"0")}`,end_date:`${Dt.getFullYear()}-${String(Dt.getMonth()+1).padStart(2,"0")}-${String(Dt.getDate()).padStart(2,"0")}`};default:return null}},Z=()=>{if(!n||!v)return null;const W=n.revenue_stats.total_amount,V=v.revenue_stats.total_amount;if(V===0)return W>0?"+100%":"0%";const ye=(W-V)/V*100;return`${ye>=0?"+":""}${ye.toFixed(1)}%`};if(x.useEffect(()=>{BD().then(t).catch(console.error),T(l),Ns().then(W=>{M(W);const V={};W.forEach(ye=>{V[ye.item_id]=ye.item_title||ye.item_id}),D(V)}).catch(console.error)},[l]),x.useEffect(()=>{K(l)},[l]),!e||!n)return c.jsx("div",{className:"p-8 flex justify-center text-gray-400",children:c.jsx(uj,{className:"w-8 h-8 animate-spin text-[#0094f7]"})});const pe=((be=n.daily_stats)==null?void 0:be.map(W=>({name:W.date.slice(5),amount:W.amount,orders:W.order_count,avgAmount:W.order_count>0?(W.amount/W.order_count).toFixed(2):0})))||[],fe=n.item_stats||[],ce=n.revenue_stats.total_orders||0,R=n.revenue_stats.total_amount||0,z=fe.length>0?fe.map(W=>({name:(k[W.item_id]||W.item_id).length>12?(k[W.item_id]||W.item_id).substring(0,12)+"...":k[W.item_id]||W.item_id,sales:W.order_count})).sort((W,V)=>V.sales-W.sales).slice(0,10):[],G=Math.max(...z.map(W=>W.sales),1),se=fe.length>0?fe.map(W=>({name:(k[W.item_id]||W.item_id).length>10?(k[W.item_id]||W.item_id).substring(0,10)+"...":k[W.item_id]||W.item_id,value:W.order_count,percent:ce>0?W.order_count/ce*100:0})).sort((W,V)=>V.value-W.value).slice(0,6).map((W,V)=>({...W,color:E[V%E.length]})):[],ue=fe.length>0?fe.map(W=>({name:(k[W.item_id]||W.item_id).length>12?(k[W.item_id]||W.item_id).substring(0,12)+"...":k[W.item_id]||W.item_id,value:W.total_amount,orderCount:W.order_count,percentage:R>0?W.total_amount/R*100:0})).sort((W,V)=>V.value-W.value).slice(0,5).map((W,V)=>({...W,color:E[V%E.length],percentage:W.percentage.toFixed(1)})):[],P=[{key:"today",label:"今天"},{key:"yesterday",label:"昨天"},{key:"3days",label:"三天内"},{key:"7days",label:"7天内"},{key:"30days",label:"一个月内"},{key:"custom",label:"自定义"}],Q=((_e=P.find(W=>W.key===l))==null?void 0:_e.label)||"所选范围",ne=U(l),I=b.trim().toLowerCase(),he=j.filter(W=>{var V,ye,xe,ae;return((V=W.order_id)==null?void 0:V.toLowerCase().includes(I))||((ye=W.item_id)==null?void 0:ye.toLowerCase().includes(I))||((xe=W.item_title)==null?void 0:xe.toLowerCase().includes(I))||((ae=W.buyer_id)==null?void 0:ae.toLowerCase().includes(I))});return c.jsxs("div",{className:"space-y-8 animate-fade-in",children:[c.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"运营概览"}),c.jsx("p",{className:"text-gray-500 mt-2 text-base",children:"欢迎回来,以下是闲鱼店铺的实时经营数据。"})]}),c.jsx("div",{className:"flex items-center gap-3",children:c.jsxs("div",{className:"text-sm font-bold text-gray-700 bg-white px-5 py-2.5 rounded-full shadow-sm border border-gray-100 flex items-center gap-2",children:[c.jsx("span",{className:"w-2.5 h-2.5 bg-green-500 rounded-full animate-pulse"}),"系统正常运行"]})})]}),c.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[P.map(W=>c.jsx("button",{onClick:()=>s(W.key),className:`px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${l===W.key?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:W.label},W.key)),l==="custom"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"date",value:d,onChange:W=>f(W.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-[#0094f7]"}),c.jsx("span",{className:"self-center text-gray-400",children:"-"}),c.jsx("input",{type:"date",value:m,onChange:W=>h(W.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-[#0094f7]"}),c.jsx("button",{onClick:()=>{T("custom"),K("custom")},className:"px-4 py-2 rounded-xl text-sm font-bold bg-black text-white hover:bg-gray-800 transition-colors",children:"应用"})]})]}),c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[c.jsx(Ed,{title:"累计营收 (CNY)",value:`¥${n.revenue_stats.total_amount.toLocaleString("zh-CN",{minimumFractionDigits:2})}`,icon:dM,colorClass:"bg-blue-400",trend:Z()||void 0}),c.jsx(Ed,{title:"活跃账号 / 总数",value:`${e.active_cookies} / ${e.total_cookies}`,icon:yA,colorClass:"bg-blue-500"}),c.jsx(Ed,{title:"订单数",value:n.revenue_stats.total_orders.toLocaleString(),icon:vj,colorClass:"bg-blue-500"}),c.jsx(Ed,{title:"库存卡密余量",value:e.total_cards,icon:fA,colorClass:"bg-purple-500"})]}),c.jsxs("div",{className:"ios-card p-8 rounded-xl",children:[c.jsxs("div",{className:"mb-10",children:[c.jsx("h3",{className:"text-xl font-bold text-gray-900",children:"营收趋势分析"}),c.jsxs("p",{className:"text-sm text-gray-400 mt-1",children:[Q,"的销售额走势"]})]}),c.jsx("div",{className:"h-[350px] w-full",children:pe.length===0||n.revenue_stats.total_amount===0?c.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[c.jsx(vj,{className:"w-16 h-16 mb-4 opacity-20"}),c.jsx("p",{className:"text-lg font-medium",children:"暂无营收数据"}),c.jsx("p",{className:"text-sm mt-2",children:"所选时间范围内暂无订单记录"})]}):pe.length<=2?c.jsx(yd,{width:"100%",height:"100%",children:c.jsxs(mQ,{data:pe,margin:{top:30,right:20,left:0,bottom:30},barCategoryGap:"45%",children:[c.jsx($y,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:"#374151",fontSize:14,fontWeight:600},dy:10}),c.jsx(By,{axisLine:!1,tickLine:!1,tick:{fill:"#9CA3AF",fontSize:13,fontWeight:500},tickFormatter:W=>`¥${W}`}),c.jsx(Ev,{contentStyle:{backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e5e7eb",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1)",padding:"12px 16px"},labelStyle:{color:"#6b7280",fontWeight:500},itemStyle:{color:"#0094f7",fontWeight:600},cursor:{fill:"rgba(0, 148, 247, 0.08)"},formatter:W=>[`¥${Number(W).toFixed(2)}`,"营收"]}),c.jsx(I4,{dataKey:"amount",fill:"#0094f7",maxBarSize:72,radius:[12,12,0,0],stroke:"#000000",strokeWidth:0,children:pe.map((W,V)=>c.jsx(nl,{fill:["#0094f7","#FCD34D","#0071e3"][V%3]},`cell-${V}`))})]})}):c.jsx(yd,{width:"100%",height:"100%",children:c.jsxs(CQ,{data:pe,margin:{top:10,right:10,left:-20,bottom:0},children:[c.jsx("defs",{children:c.jsxs("linearGradient",{id:"colorAmount",x1:"0",y1:"0",x2:"0",y2:"1",children:[c.jsx("stop",{offset:"5%",stopColor:"#0094f7",stopOpacity:.5}),c.jsx("stop",{offset:"95%",stopColor:"#0094f7",stopOpacity:0})]})}),c.jsx($y,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:"#9CA3AF",fontSize:13,fontWeight:500},dy:15}),c.jsx(By,{axisLine:!1,tickLine:!1,tick:{fill:"#9CA3AF",fontSize:13,fontWeight:500}}),c.jsx(b4,{vertical:!1,stroke:"#F3F4F6",strokeDasharray:"3 3"}),c.jsx(Ev,{contentStyle:{backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e5e7eb",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1)",padding:"12px 16px"},labelStyle:{color:"#6b7280",fontWeight:500},itemStyle:{color:"#0094f7",fontWeight:600},cursor:{stroke:"#0094f7",strokeWidth:2,strokeDasharray:"4 4"}}),c.jsx(T4,{type:"monotone",dataKey:"amount",stroke:"#0094f7",strokeWidth:4,fillOpacity:1,fill:"url(#colorAmount)",activeDot:{r:8,fill:"#fff",stroke:"#0094f7",strokeWidth:2}})]})})})]}),c.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[c.jsxs("div",{className:"ios-card p-6 rounded-xl",children:[c.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品销量排行"}),c.jsx("div",{className:"h-[280px]",children:z.length===0?c.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:"暂无数据"}):c.jsx("div",{className:"h-full space-y-4 overflow-y-auto pr-2",children:z.map((W,V)=>c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between gap-4",children:[c.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[c.jsx("span",{className:`w-7 h-7 rounded-xl flex items-center justify-center text-xs font-extrabold ${V<3?"bg-blue-600 text-white":"bg-gray-100 text-gray-500"}`,children:V+1}),c.jsx("span",{className:"font-bold text-gray-800 text-sm truncate",children:W.name})]}),c.jsxs("span",{className:"font-mono text-sm font-extrabold text-gray-900",children:[W.sales," 单"]})]}),c.jsx("div",{className:"h-3 rounded-full bg-gray-100 overflow-hidden",children:c.jsx("div",{className:"h-full rounded-full bg-[#0094f7]",style:{width:`${Math.max(8,W.sales/G*100)}%`}})})]},`${W.name}-${V}`))})})]}),c.jsxs("div",{className:"ios-card p-6 rounded-xl",children:[c.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品下单占比"}),c.jsx("div",{className:"h-[280px]",children:se.length===0?c.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:"暂无数据"}):c.jsx(yd,{width:"100%",height:"100%",children:c.jsxs(WS,{children:[c.jsx(Dy,{data:se,cx:"50%",cy:"50%",innerRadius:60,outerRadius:90,paddingAngle:2,dataKey:"value",label:({name:W,payload:V})=>`${W} ${Number((V==null?void 0:V.percent)||0).toFixed(1)}%`,labelLine:!1,children:se.map((W,V)=>c.jsx(nl,{fill:W.color},`cell-${V}`))}),c.jsx(uE,{verticalAlign:"bottom",height:36,iconType:"circle",formatter:W=>c.jsx("span",{style:{color:"#6B7280",fontWeight:500},children:W})})]})})})]})]}),c.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[c.jsxs("div",{className:"lg:col-span-2 ios-card p-0 rounded-xl border-0 bg-white overflow-hidden flex flex-col",children:[c.jsxs("div",{className:"p-6 border-b border-gray-50 flex justify-between items-center bg-[#FAFAFA]",children:[c.jsx("h3",{className:"font-bold text-lg text-gray-900",children:"参与统计的订单"}),c.jsx("div",{className:"relative",children:c.jsx("input",{placeholder:"搜索订单号/商品/买家...",value:b,onChange:W=>w(W.target.value),className:"pl-4 pr-4 py-2 rounded-xl bg-white border border-gray-100 text-sm focus:border-blue-400 outline-none w-48",type:"text"})})]}),c.jsx("div",{className:"overflow-x-auto flex-1 max-h-[400px]",children:S?c.jsxs("div",{className:"flex items-center justify-center py-20 text-gray-400",children:[c.jsx(uj,{className:"w-6 h-6 animate-spin mr-2"}),"加载中..."]}):he.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-8 text-center",children:[c.jsx("div",{className:"w-14 h-14 rounded-2xl bg-gray-100 flex items-center justify-center mb-4",children:c.jsx(uc,{className:"w-7 h-7 text-gray-300"})}),I?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"没有匹配的订单"}),c.jsxs("div",{className:"text-xs text-gray-400 mt-2 max-w-md",children:["当前共有 ",j.length," 单参与统计,但没有订单号、商品、买家匹配“",b,"”。"]})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"当前范围内没有参与统计的订单"}),c.jsxs("div",{className:"text-xs text-gray-400 mt-2 max-w-lg leading-6",children:["日期范围:",ne.startDate," 至 ",ne.endDate,"; 统计口径:待发货、已发货、已完成,且订单金额不为空。 当前统计卡片订单数:",n.revenue_stats.total_orders," 单。"]})]})]}):c.jsxs("table",{className:"w-full text-left border-collapse",children:[c.jsx("thead",{children:c.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[c.jsx("th",{className:"px-6 py-4",children:"订单信息"}),c.jsx("th",{className:"px-6 py-4",children:"买家信息"}),c.jsx("th",{className:"px-6 py-4",children:"金额"}),c.jsx("th",{className:"px-6 py-4",children:"状态"}),c.jsx("th",{className:"px-6 py-4 text-right",children:"操作"})]})}),c.jsx("tbody",{className:"divide-y divide-gray-50",children:he.map(W=>c.jsxs("tr",{className:"hover:bg-[#FFFDE7]/50 transition-colors group",children:[c.jsx("td",{className:"px-6 py-4",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-12 h-12 rounded-xl bg-gray-100 overflow-hidden shadow-sm border border-gray-100 flex-shrink-0",children:c.jsx(uc,{className:"w-full h-full text-gray-300 p-2"})}),c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"font-bold text-gray-900 text-sm line-clamp-1",children:W.item_title||W.item_id||"未知商品"}),c.jsx("div",{className:"text-xs text-gray-500 mt-1 font-mono",children:W.order_id}),c.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",W.quantity||1]})]})]})}),c.jsxs("td",{className:"px-6 py-4",children:[c.jsx("div",{className:"text-sm font-bold text-gray-800",children:W.buyer_id}),W.created_at&&c.jsx("div",{className:"text-xs text-gray-400 mt-1",children:W.created_at})]}),c.jsxs("td",{className:"px-6 py-4 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:["¥",W.amount||"0.00"]}),c.jsx("td",{className:"px-6 py-4",children:c.jsx(TQ,{status:W.status||W.order_status||"unknown"})}),c.jsx("td",{className:"px-6 py-4 text-right",children:c.jsx("a",{href:`https://www.goofish.com/order-detail?orderId=${W.order_id}&role=seller`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看闲鱼详情",children:c.jsx(uA,{className:"w-4 h-4"})})})]},W.order_id))})]})})]}),c.jsxs("div",{className:"ios-card p-6 rounded-xl bg-white",children:[c.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品金额分析 (TOP5)"}),ue.length===0?c.jsx("div",{className:"flex items-center justify-center h-[300px] text-gray-400",children:"暂无数据"}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"h-[300px] relative",children:c.jsx(yd,{width:"100%",height:"100%",children:c.jsxs(WS,{children:[c.jsx(Dy,{data:ue,cx:"50%",cy:"50%",innerRadius:60,outerRadius:100,paddingAngle:2,dataKey:"value",label:({name:W,payload:V})=>`${W} ${(V==null?void 0:V.percentage)||"0.0"}%`,children:ue.map((W,V)=>c.jsx(nl,{fill:W.color||E[V%E.length]},`cell-${V}`))}),c.jsx(Ev,{contentStyle:{backgroundColor:"#fff",border:"1px solid #e5e7eb",borderRadius:"6px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"},formatter:W=>`¥${W.toLocaleString()}`})]})})}),c.jsx("div",{className:"space-y-3 mt-4",children:ue.map(W=>c.jsxs("div",{className:"flex justify-between items-center text-sm",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:W.color||E[ue.indexOf(W)%E.length]}}),c.jsx("span",{className:"text-gray-600 font-medium",children:W.name})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("span",{className:"font-bold text-gray-900",children:["¥",W.value.toLocaleString()]}),c.jsxs("span",{className:"text-xs text-gray-500 bg-gray-100 px-2 py-0.5 rounded",children:[W.percentage,"%"]})]})]},W.name))})]})]})]})]})},MQ=()=>{const[e,t]=x.useState([]),[n,r]=x.useState(!0),[l,s]=x.useState(""),[d,f]=x.useState(""),[m,h]=x.useState(!1),[v,y]=x.useState(""),[b,w]=x.useState("pending"),[j,_]=x.useState(""),[S,A]=x.useState(""),[C,M]=x.useState(""),[k,D]=x.useState(""),[E,$]=x.useState(null),[U,K]=x.useState(null),[T,re]=x.useState(null),[Z,pe]=x.useState([]),[fe,ce]=x.useState([]),[R,z]=x.useState({remark:"",cookie:"",auto_confirm:!1,pause_duration:0,username:"",login_password:"",show_browser:!1,showLoginPassword:!1}),[G,se]=x.useState({ai_enabled:!1,max_discount_percent:10,max_discount_amount:100,max_bargain_rounds:3,custom_prompts:""}),[ue,P]=x.useState(!1),Q=async()=>{try{const Y=await _D();t(ge=>ge.map(Pe=>{const Be=Y[Pe.id];return Be?{...Pe,runtime_state:Be.state,runtime_message:Be.message||"",runtime_connected:Be.connected,runtime_updated_at:Be.updated_at}:Pe}))}catch(Y){console.error("Failed to load account runtime statuses:",Y)}},ne=async()=>{r(!0);try{const Y=await Fy();let ge={};try{ge=await DD()}catch(Be){console.error("Failed to load AI settings:",Be)}const Pe=Y.map(Be=>{var Ve,Dt,ie,De,Ue;return{...Be,ai_enabled:((Ve=ge[Be.id])==null?void 0:Ve.ai_enabled)??!1,max_discount_percent:((Dt=ge[Be.id])==null?void 0:Dt.max_discount_percent)??10,max_discount_amount:((ie=ge[Be.id])==null?void 0:ie.max_discount_amount)??100,max_bargain_rounds:((De=ge[Be.id])==null?void 0:De.max_bargain_rounds)??3,custom_prompts:((Ue=ge[Be.id])==null?void 0:Ue.custom_prompts)??""}});t(Pe),window.setTimeout(Q,0)}catch(Y){console.error("Failed to load accounts:",Y)}finally{r(!1)}};x.useEffect(()=>{ne();const Y=window.setInterval(Q,1e4);return()=>window.clearInterval(Y)},[]);const I=Y=>{if(!Y.enabled||Y.runtime_state==="disabled")return{label:"已停用",badge:"bg-gray-100 text-gray-500",dot:"bg-gray-300"};switch(Y.runtime_state){case"online":return{label:"在线",badge:"bg-green-100 text-green-700",dot:"bg-green-500"};case"starting":case"connecting":return{label:"连接中",badge:"bg-blue-100 text-blue-700",dot:"bg-blue-500"};case"reconnecting":return{label:"重连中",badge:"bg-amber-100 text-amber-700",dot:"bg-amber-500"};case"auth_expired":return{label:"登录已失效",badge:"bg-red-100 text-red-700",dot:"bg-red-500"};case"verification_required":return{label:"需要验证",badge:"bg-orange-100 text-orange-700",dot:"bg-orange-500"};case"error":case"stopped":return{label:"运行异常",badge:"bg-red-100 text-red-700",dot:"bg-red-500"};default:return{label:"状态检测中",badge:"bg-gray-100 text-gray-600",dot:"bg-gray-400"}}},he=async(Y,ge)=>{await AD(Y,!ge),ne()},be=async Y=>{confirm("确认删除该账号吗?")&&(await OD(Y),ne())},_e=async Y=>{f(Y.id);try{const ge=await TD(Y.id);ge!=null&&ge.profile_error&&alert("资料刷新失败:"+ge.profile_error),await ne()}catch(ge){console.error("刷新账号资料失败:",ge),alert((ge==null?void 0:ge.message)||"刷新账号资料失败,请先重新授权该账号")}finally{f("")}},W=async Y=>{re(Y),z({remark:Y.remark||Y.note||"",cookie:Y.cookie||Y.value||"",auto_confirm:Y.auto_confirm||!1,pause_duration:Y.pause_duration||0,username:Y.username||"",login_password:Y.login_password||"",show_browser:Y.show_browser||!1,showLoginPassword:!1}),K("edit");try{const[ge,Pe]=await Promise.all([jA(),fP(Y.id).catch(()=>[])]);pe(ge.data||[]),ce(Pe||[])}catch(ge){console.error("加载通知渠道绑定失败",ge),pe([]),ce([])}},V=async Y=>{re(Y),P(!0);try{const ge=await sP(Y.id);se({ai_enabled:ge.ai_enabled??!1,max_discount_percent:ge.max_discount_percent??10,max_discount_amount:ge.max_discount_amount??100,max_bargain_rounds:ge.max_bargain_rounds??3,custom_prompts:ge.custom_prompts??""})}catch(ge){console.error("Failed to load AI settings:",ge)}finally{P(!1)}K("ai-settings")},ye=async()=>{if(T){P(!0);try{const Y=[];R.remark!==(T.remark||T.note||"")&&Y.push(ED(T.id,R.remark)),R.cookie&&R.cookie!==(T.cookie||T.value||"")&&Y.push(gj(T.id,R.cookie)),R.auto_confirm!==T.auto_confirm&&Y.push(kD(T.id,R.auto_confirm)),R.pause_duration!==(T.pause_duration||0)&&Y.push(CD(T.id,R.pause_duration)),(R.username!==(T.username||"")||R.login_password!==(T.login_password||"")||R.show_browser!==(T.show_browser||!1))&&Y.push(MD(T.id,{username:R.username,login_password:R.login_password,show_browser:R.show_browser})),Y.push(mP(T.id,fe)),await Promise.all(Y),K(null),ne()}catch(Y){console.error("更新账号失败:",Y),alert("更新失败,请重试")}finally{P(!1)}}},xe=async()=>{if(T){P(!0);try{await oP(T.id,G),K(null),ne()}catch(Y){console.error("更新AI设置失败:",Y),alert("更新失败,请重试")}finally{P(!1)}}},ae=async(Y,ge,Pe)=>{if(Pe){if(ge&&ge!==Pe.id&&!confirm(`扫码返回的账号ID是 ${ge},当前要重新授权的是 ${Pe.id}。确认用本次扫码结果覆盖当前账号授权吗?`))throw new Error("已取消覆盖当前账号授权");return await gj(Pe.id,Y),Pe.id}if(!ge)throw new Error("扫码结果缺少账号ID,无法添加账号");return await wD(ge,Y),ge},Le=async Y=>{const ge=Y||null;$(ge),h(!0),w("loading"),y(""),D(""),_(""),A(""),M("");try{const Pe=await ND();if(Pe.success&&Pe.qr_code_url&&Pe.session_id){y(Pe.qr_code_url),D(Pe.session_id),w("waiting");const Be=setInterval(async()=>{const Ve=await SD(Pe.session_id);if(Ve.status==="success"){if(clearInterval(Be),w("success"),Ve.cookies&&Ve.unb)try{await ae(Ve.cookies,Ve.unb,ge)}catch(Dt){console.error("保存扫码授权失败",Dt),w("error")}setTimeout(()=>{h(!1),ne()},1e3)}else Ve.status==="scanned"?w("waiting"):Ve.status==="expired"||Ve.status==="cancelled"||Ve.status==="error"||Ve.status==="not_found"?(clearInterval(Be),w("error")):Ve.status==="verification_required"&&(w("verification"),_(Ve.verification_url||""),Ve.face_qr_url&&M(Ve.face_qr_url),Ve.verification_screenshot&&A(Ve.verification_screenshot))},2e3)}}catch{w("error")}};if(n)return c.jsx("div",{className:"p-20 flex justify-center",children:c.jsx(Yn,{className:"w-8 h-8 text-[#0094f7] animate-spin"})});const Ce=e.filter(Y=>{const ge=l.trim().toLowerCase();return ge?[Y.id,Y.nickname,Y.remark,Y.note,Y.username,Y.runtime_message].some(Pe=>(Pe||"").toLowerCase().includes(ge)):!0});return c.jsxs("div",{className:"space-y-8 animate-fade-in relative",children:[c.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-end gap-4",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"账号管理"}),c.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理您的闲鱼授权账号及设置。建议给账号填写备注,便于多账号区分。"})]}),c.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[c.jsx("input",{value:l,onChange:Y=>s(Y.target.value),placeholder:"搜索昵称 / 备注 / 账号ID",className:"ios-input px-4 py-3 rounded-2xl text-sm w-full sm:w-72"}),c.jsxs("button",{onClick:()=>Le(),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[c.jsx(Qp,{className:"w-5 h-5"}),"扫码添加新账号"]})]})]}),c.jsxs("div",{className:"rounded-2xl border border-blue-100 bg-blue-50 px-5 py-4 text-sm text-blue-900 flex flex-col md:flex-row md:items-center md:justify-between gap-2",children:[c.jsxs("div",{className:"font-bold",children:["当前显示 ",Ce.length," / ",e.length," 个账号"]}),c.jsx("div",{className:"text-blue-700",children:"如果某个账号只显示 ID,点该账号右侧“刷新资料”;若刷新失败,先点二维码重新授权。"})]}),c.jsxs("div",{className:"grid grid-cols-1 gap-6",children:[Ce.map(Y=>{const ge=I(Y),Pe=Y.runtime_state==="auth_expired"||Y.runtime_state==="verification_required";return c.jsxs("div",{className:"ios-card p-6 rounded-xl flex flex-col lg:flex-row lg:items-center justify-between gap-5 group hover:border-[#0094f7] transition-all duration-300",children:[c.jsxs("div",{className:"flex items-center gap-5 sm:gap-8 min-w-0",children:[c.jsxs("div",{className:"relative",children:[Y.avatar_url?c.jsx("img",{src:Y.avatar_url,alt:Y.nickname||"账号头像",className:"w-20 h-20 rounded-full object-cover shadow-md ring-4 ring-white bg-gray-100"}):c.jsx("div",{className:"w-20 h-20 rounded-full bg-gray-100 text-gray-400 shadow-md ring-4 ring-white flex items-center justify-center",children:c.jsx(Bv,{className:"w-9 h-9"})}),c.jsx("div",{className:`absolute -bottom-1 -right-1 w-6 h-6 rounded-full border-4 border-white flex items-center justify-center ${ge.dot}`,children:Y.runtime_state==="online"&&c.jsx(ci,{className:"w-3 h-3 text-white"})})]}),c.jsxs("div",{className:"min-w-0",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-1",children:[c.jsx("h3",{className:"text-xl font-extrabold text-gray-900 break-words",children:Y.nickname||Y.remark||`账号 ${Y.id.substring(0,6)}...`}),c.jsx("span",{className:`px-2.5 py-0.5 rounded-lg text-xs font-bold ${ge.badge}`,children:ge.label}),Y.ai_enabled&&c.jsxs("span",{className:"px-2.5 py-0.5 rounded-lg bg-purple-100 text-purple-700 text-xs font-bold flex items-center gap-1",children:[c.jsx(ps,{className:"w-3 h-3"})," AI"]}),Y.profile_error&&c.jsxs("span",{className:"px-2.5 py-0.5 rounded-lg bg-amber-100 text-amber-700 text-xs font-bold flex items-center gap-1",title:Y.profile_error,children:[c.jsx($d,{className:"w-3 h-3"})," 资料未同步"]})]}),c.jsxs("div",{className:"text-sm text-gray-500 font-medium mb-3 space-y-1",children:[c.jsx("p",{children:Y.remark||Y.note||"暂无备注"}),c.jsxs("p",{className:"font-mono text-xs text-gray-400",children:["ID: ",Y.id]})]}),Y.runtime_message&&Y.runtime_state!=="online"&&Y.runtime_state!=="disabled"&&c.jsxs("div",{className:`mb-3 flex flex-wrap items-center gap-2 text-sm font-medium ${Pe?"text-red-700":"text-amber-700"}`,children:[c.jsx($d,{className:"w-4 h-4 flex-shrink-0"}),c.jsx("span",{children:Y.runtime_message}),Pe&&c.jsxs("button",{type:"button",onClick:()=>Le(Y),className:"inline-flex items-center gap-1.5 rounded-lg bg-red-50 px-2.5 py-1 text-xs font-bold text-red-700 hover:bg-red-100",children:[c.jsx(Qp,{className:"w-3.5 h-3.5"})," 重新授权"]})]}),c.jsxs("div",{className:"flex gap-2",children:[Y.auto_confirm&&c.jsxs("span",{className:"text-xs bg-blue-50 text-blue-700 px-3 py-1.5 rounded-lg font-bold flex items-center gap-1.5",children:[c.jsx(ci,{className:"w-3 h-3"})," 自动确认发货"]}),Y.pause_duration>0&&c.jsxs("span",{className:"text-xs bg-blue-50 text-blue-700 px-3 py-1.5 rounded-lg font-bold flex items-center gap-1.5",children:[c.jsx(dj,{className:"w-3 h-3"})," 暂停",Y.pause_duration,"分钟"]})]})]})]}),c.jsxs("div",{className:"flex items-center gap-3 self-end lg:self-auto flex-shrink-0",children:[c.jsx("button",{onClick:()=>_e(Y),disabled:d===Y.id,className:"p-3 rounded-xl transition-colors text-gray-600 hover:bg-gray-100 disabled:opacity-50",title:"刷新昵称和头像",children:c.jsx(pr,{className:`w-5 h-5 ${d===Y.id?"animate-spin":""}`})}),c.jsx("button",{onClick:()=>Le(Y),className:`p-3 rounded-xl transition-colors ${Pe?"text-red-600 bg-red-50 hover:bg-red-100":"text-blue-600 hover:bg-blue-50"}`,title:"重新扫码授权当前账号",children:c.jsx(Qp,{className:"w-5 h-5"})}),c.jsx("button",{onClick:()=>W(Y),className:"p-3 rounded-xl hover:bg-gray-100 transition-colors text-gray-600",title:"编辑账号",children:c.jsx(mA,{className:"w-5 h-5"})}),c.jsx("button",{onClick:()=>V(Y),className:"p-3 rounded-xl hover:bg-purple-100 transition-colors text-purple-600",title:"AI设置",children:c.jsx(ps,{className:"w-5 h-5"})}),c.jsx("button",{onClick:()=>he(Y.id,Y.enabled),className:`p-3 rounded-xl transition-colors ${Y.enabled?"text-green-600 hover:bg-green-50":"text-gray-400 hover:bg-gray-100"}`,title:Y.enabled?"停用账号":"启用账号",children:c.jsx(YM,{className:"w-5 h-5"})}),c.jsx("button",{onClick:()=>be(Y.id),className:"p-3 rounded-xl hover:bg-red-100 transition-colors text-red-500",children:c.jsx(xa,{className:"w-5 h-5"})})]})]},Y.id)}),e.length===0&&c.jsxs("div",{className:"ios-card p-12 text-center",children:[c.jsx("div",{className:"w-20 h-20 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4",children:c.jsx(Bv,{className:"w-10 h-10 text-gray-400"})}),c.jsx("h3",{className:"text-lg font-bold text-gray-900",children:"暂无账号"}),c.jsx("p",{className:"text-gray-500 mt-1",children:"请点击右上角扫码添加您的闲鱼账号"})]}),e.length>0&&Ce.length===0&&c.jsxs("div",{className:"ios-card p-12 text-center",children:[c.jsx("h3",{className:"text-lg font-bold text-gray-900",children:"没有匹配的账号"}),c.jsx("p",{className:"text-gray-500 mt-1",children:"换一个关键词搜索昵称、备注或账号ID。"})]})]}),m&&It.createPortal(c.jsx("div",{className:"modal-overlay-centered",children:c.jsxs("div",{className:"modal-container relative",style:{maxWidth:"24rem"},children:[c.jsx("button",{onClick:()=>h(!1),className:"absolute top-4 right-4 z-10 w-9 h-9 flex items-center justify-center bg-gray-100 hover:bg-gray-200 rounded-full transition-colors",children:c.jsx(Xt,{className:"w-5 h-5 text-gray-600"})}),c.jsx("div",{className:"modal-body",children:c.jsxs("div",{className:"text-center",children:[c.jsx("h3",{className:"text-2xl font-extrabold text-gray-900 mb-2",children:E?"重新授权账号":"扫码添加账号"}),c.jsx("p",{className:"text-gray-500 mb-8 font-medium",children:E?`请用闲鱼APP扫码,为「${E.nickname||E.remark||E.id}」刷新授权`:"请打开闲鱼APP扫描下方二维码"}),c.jsxs("div",{className:"w-64 h-64 bg-[#F7F8FA] rounded-xl mx-auto flex items-center justify-center overflow-hidden border-4 border-white shadow-inner mb-8 relative",children:[b==="loading"&&c.jsx(Yn,{className:"w-10 h-10 text-[#0094f7] animate-spin"}),b==="waiting"&&c.jsx("img",{src:v,alt:"QR Code",className:"w-full h-full p-2"}),b==="success"&&c.jsxs("div",{className:"absolute inset-0 bg-white/95 flex flex-col items-center justify-center text-green-600 animate-fade-in",children:[c.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mb-4",children:c.jsx(ci,{className:"w-8 h-8"})}),c.jsx("span",{className:"font-bold text-lg",children:"登录成功"})]}),b==="error"&&c.jsxs("div",{className:"flex flex-col items-center",children:[c.jsx("span",{className:"text-red-500 font-bold mb-2",children:"获取失败"}),c.jsxs("button",{onClick:()=>Le(E||void 0),className:"text-xs bg-gray-200 px-3 py-1 rounded-full flex items-center gap-1 hover:bg-gray-300",children:[c.jsx(pr,{className:"w-3 h-3"})," 重试"]})]}),b==="verification"&&c.jsxs("div",{className:"flex flex-col items-center px-4",children:[c.jsx("span",{className:"font-bold text-gray-900 mb-2",children:"需要安全验证"}),c.jsx("span",{className:"text-xs text-gray-500 mb-3 text-center",children:C?"请用手机闲鱼扫描下方二维码完成人脸验证,验证通过后将自动登录。":"正在准备验证二维码,请保持页面打开。"}),C?c.jsx("img",{src:C,alt:"人脸验证二维码",className:"w-full max-w-[210px] rounded-xl border bg-white p-2 mb-2"}):S?c.jsx("img",{src:S,alt:"验证页面",className:"w-full rounded-xl border mb-2",style:{maxHeight:200,objectFit:"contain"}}):c.jsx("div",{className:"w-full h-32 bg-gray-100 rounded-xl flex items-center justify-center mb-2",children:c.jsx(Yn,{className:"w-6 h-6 animate-spin text-gray-400"})}),c.jsx("span",{className:"text-xs text-gray-400",children:"等待手机验证完成,无需点击确认。"})]})]}),c.jsx("p",{className:"text-xs text-gray-400 font-medium bg-gray-50 py-2 rounded-xl",children:"二维码有效期为5分钟,请尽快扫码。"})]})})]})}),document.body),U==="edit"&&T&&It.createPortal(c.jsx("div",{className:"modal-overlay-centered",children:c.jsxs("div",{className:"modal-container",style:{maxWidth:"600px"},children:[c.jsxs("div",{className:"modal-header",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑账号"}),c.jsx("p",{className:"text-sm text-gray-500 mt-1",children:T.nickname||T.remark||T.id})]}),c.jsx("button",{onClick:()=>K(null),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:c.jsx(Xt,{className:"w-5 h-5 text-gray-500"})})]}),c.jsxs("div",{className:"modal-body space-y-6",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"账号ID"}),c.jsx("input",{type:"text",value:T.id,disabled:!0,className:"w-full ios-input px-4 py-3 rounded-xl bg-gray-50 text-gray-500"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注"}),c.jsx("input",{type:"text",value:R.remark,onChange:Y=>z({...R,remark:Y.target.value}),placeholder:"为账号添加备注",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"Cookie"}),c.jsx("textarea",{value:R.cookie,onChange:Y=>z({...R,cookie:Y.target.value}),placeholder:"更新账号Cookie",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none font-mono text-xs"}),c.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["当前Cookie长度: ",R.cookie.length," 字符"]})]}),c.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"font-bold text-gray-900 flex items-center gap-2",children:[c.jsx(ci,{className:"w-4 h-4 text-green-500"}),"自动确认发货"]}),c.jsx("div",{className:"text-xs text-gray-500",children:"自动将闲鱼订单标记为已发货"})]}),c.jsx("button",{type:"button",onClick:()=>z({...R,auto_confirm:!R.auto_confirm}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${R.auto_confirm?"bg-[#0094f7]":"bg-gray-300"}`,children:c.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${R.auto_confirm?"translate-x-6":"translate-x-0"}`})})]}),c.jsxs("div",{children:[c.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2 flex items-center gap-2",children:[c.jsx(dj,{className:"w-4 h-4 text-blue-500"}),"暂停处理时长(分钟)"]}),c.jsx("input",{type:"number",value:R.pause_duration,onChange:Y=>z({...R,pause_duration:parseInt(Y.target.value)||0}),placeholder:"0",min:"0",max:"1440",className:"w-full ios-input px-4 py-3 rounded-xl"}),c.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"设置后会暂停处理该账号的订单,到时间后自动恢复"})]}),c.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[c.jsxs("h3",{className:"text-lg font-bold text-gray-900 mb-4 flex items-center gap-2",children:[c.jsx(jM,{className:"w-5 h-5 text-blue-500"}),"登录信息"]}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"用户名"}),c.jsx("input",{type:"text",value:R.username,onChange:Y=>z({...R,username:Y.target.value}),placeholder:"闲鱼账号/手机号",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"登录密码"}),c.jsxs("div",{className:"relative",children:[c.jsx("input",{type:R.showLoginPassword?"text":"password",value:R.login_password,onChange:Y=>z({...R,login_password:Y.target.value}),placeholder:"用于自动登录",className:"w-full ios-input px-4 py-3 rounded-xl pr-12"}),c.jsx("button",{type:"button",onClick:()=>z({...R,showLoginPassword:!R.showLoginPassword}),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:R.showLoginPassword?c.jsx(ic,{className:"w-5 h-5"}):c.jsx(xs,{className:"w-5 h-5"})})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("div",{className:"font-bold text-gray-900",children:"登录时显示浏览器"}),c.jsx("div",{className:"text-xs text-gray-500",children:"调试时可开启查看登录过程"})]}),c.jsx("button",{type:"button",onClick:()=>z({...R,show_browser:!R.show_browser}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${R.show_browser?"bg-[#0094f7]":"bg-gray-300"}`,children:c.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${R.show_browser?"translate-x-6":"translate-x-0"}`})})]})]})]}),Z.length>0&&c.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[c.jsxs("h3",{className:"text-lg font-bold text-gray-900 mb-1 flex items-center gap-2",children:[c.jsx(gs,{className:"w-5 h-5 text-blue-500"}),"通知渠道绑定"]}),c.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"勾选后,该账号的 token 失效、自动恢复失败、风控验证等事件会推送到这些渠道"}),c.jsx("div",{className:"space-y-2",children:Z.map(Y=>{const ge=fe.includes(Number(Y.id));return c.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-xl border border-gray-200 hover:bg-gray-50 cursor-pointer transition-colors",children:[c.jsx("button",{type:"button",onClick:()=>{ce(Pe=>ge?Pe.filter(Be=>Be!==Number(Y.id)):[...Pe,Number(Y.id)])},className:`w-5 h-5 rounded-md border-2 flex items-center justify-center transition-colors flex-shrink-0 ${ge?"bg-[#0094f7] border-[#0094f7]":"bg-white border-gray-300"}`,children:ge&&c.jsx(ci,{className:"w-3.5 h-3.5 text-white"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"font-bold text-gray-900 text-sm",children:Y.name}),c.jsxs("div",{className:"text-xs text-gray-500",children:[Y.type,Y.enabled?"":" · 已停用"]})]})]},Y.id)})})]})]}),c.jsx("div",{className:"modal-footer",children:c.jsxs("div",{className:"flex gap-3 w-full",children:[c.jsx("button",{onClick:()=>K(null),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:ue,children:"取消"}),c.jsxs("button",{onClick:ye,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:ue,children:[ue?c.jsx(Yn,{className:"w-4 h-4 animate-spin"}):c.jsx(Sa,{className:"w-4 h-4"}),ue?"保存中...":"保存"]})]})})]})}),document.body),U==="ai-settings"&&T&&It.createPortal(c.jsx("div",{className:"modal-overlay-centered",children:c.jsxs("div",{className:"modal-container",style:{maxWidth:"600px"},children:[c.jsxs("div",{className:"modal-header",children:[c.jsxs("div",{children:[c.jsxs("h3",{className:"text-2xl font-extrabold text-gray-900 flex items-center gap-2",children:[c.jsx(ps,{className:"w-6 h-6 text-purple-500"}),"AI助手设置"]}),c.jsx("p",{className:"text-sm text-gray-500 mt-1",children:T.nickname||T.remark||T.id})]}),c.jsx("button",{onClick:()=>K(null),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:c.jsx(Xt,{className:"w-5 h-5 text-gray-500"})})]}),c.jsxs("div",{className:"modal-body space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 bg-purple-50 rounded-xl",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"font-bold text-gray-900 flex items-center gap-2",children:[c.jsx(ps,{className:"w-4 h-4 text-purple-500"}),"启用AI自动回复"]}),c.jsx("div",{className:"text-xs text-gray-500",children:"AI将自动处理买家的砍价消息"})]}),c.jsx("button",{type:"button",onClick:()=>se({...G,ai_enabled:!G.ai_enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${G.ai_enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:c.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${G.ai_enabled?"translate-x-6":"translate-x-0"}`})})]}),c.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[c.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-4",children:"砍价策略"}),c.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大折扣比例 (%)"}),c.jsx("input",{type:"number",value:G.max_discount_percent,onChange:Y=>se({...G,max_discount_percent:parseInt(Y.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"100"}),c.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"例如:10表示最多降价10%"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大折扣金额 (元)"}),c.jsx("input",{type:"number",value:G.max_discount_amount,onChange:Y=>se({...G,max_discount_amount:parseInt(Y.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0"}),c.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"例如:100表示最多降价100元"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大砍价轮次"}),c.jsx("input",{type:"number",value:G.max_bargain_rounds,onChange:Y=>se({...G,max_bargain_rounds:parseInt(Y.target.value)||1}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"1",max:"10"}),c.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"买家最多可以砍价的次数"})]})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"自定义提示词(可选)"}),c.jsx("textarea",{value:G.custom_prompts,onChange:Y=>se({...G,custom_prompts:Y.target.value}),placeholder:`输入自定义的AI回复规则或风格指引... - -例如:回复时保持礼貌专业、使用简洁的语言、强调产品质量等`,className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none"})]}),c.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-4",children:[c.jsxs("h4",{className:"font-bold text-blue-900 mb-2 flex items-center gap-2",children:[c.jsx(Gy,{className:"w-4 h-4"}),"AI如何工作"]}),c.jsxs("ul",{className:"text-xs text-blue-800 space-y-1",children:[c.jsx("li",{children:"• 自动识别买家的砍价请求"}),c.jsx("li",{children:"• 根据设定的策略智能回复"}),c.jsx("li",{children:"• 在合理范围内同意降价或礼貌拒绝"}),c.jsx("li",{children:"• 保持专业友好的沟通风格"})]})]})]}),c.jsx("div",{className:"modal-footer",children:c.jsxs("div",{className:"flex gap-3 w-full",children:[c.jsx("button",{onClick:()=>K(null),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:ue,children:"取消"}),c.jsxs("button",{onClick:xe,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:ue,children:[ue?c.jsx(Yn,{className:"w-4 h-4 animate-spin"}):c.jsx(Sa,{className:"w-4 h-4"}),ue?"保存中...":"保存"]})]})})]})}),document.body)]})},QS=({status:e})=>{const t={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-[#0094f7] text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600"},n={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中"};return c.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${t[e]||t.cancelled}`,children:n[e]||e})},DQ=()=>{const[e,t]=x.useState([]),[n,r]=x.useState([]),[l,s]=x.useState([]),[d,f]=x.useState({}),[m,h]=x.useState("all"),[v,y]=x.useState(""),[b,w]=x.useState(1),[j,_]=x.useState(1),[S,A]=x.useState(!1),[C,M]=x.useState(!1),[k,D]=x.useState(!1),[E,$]=x.useState(!1),[U,K]=x.useState(null),[T,re]=x.useState(null),[Z,pe]=x.useState({}),[fe,ce]=x.useState(!1),[R,z]=x.useState(""),[G,se]=x.useState(!1),[ue,P]=x.useState(null),[Q,ne]=x.useState(null),[I,he]=x.useState(null),[be,_e]=x.useState(null),W=ie=>{if(!v.trim())return ie;const De=v.toLowerCase().trim();return ie.filter(Ue=>{var B,Te,lt,Zr,Qn,$n;return((B=Ue.order_id)==null?void 0:B.toLowerCase().includes(De))||((Te=Ue.item_id)==null?void 0:Te.toLowerCase().includes(De))||((lt=Ue.buyer_id)==null?void 0:lt.toLowerCase().includes(De))||((Zr=Ue.item_title)==null?void 0:Zr.toLowerCase().includes(De))||((Qn=Ue.receiver_name)==null?void 0:Qn.toLowerCase().includes(De))||(($n=Ue.receiver_phone)==null?void 0:$n.toLowerCase().includes(De))})},V=async()=>{A(!0);try{if(v.trim()){let ie=[],De=1,Ue=!0;for(;Ue;){const B=await xj(void 0,m,De,100);ie=[...ie,...B.data],Ue=De{t(W(n))},[n,v]);const ye=(ie,De)=>{if(De&&De.trim())return De;if(d[ie])return d[ie];const Ue=l.find(B=>{if(De&&B.item_title){const Te=De.toLowerCase(),lt=B.item_title.toLowerCase();return lt.includes(Te)||Te.includes(lt)}return!1});return Ue!=null&&Ue.item_title?Ue.item_title:"未知商品"},xe=ie=>{const De={};ie.forEach(Ue=>{Ue.item_id&&(De[Ue.item_id]=Ue.item_title||Ue.item_id)}),f(De)};x.useEffect(()=>{V(),Ns().then(ie=>{s(ie),xe(ie)}).catch(ie=>{console.error("加载商品列表失败:",ie)})},[m,b,v]);const ae=async()=>{A(!0);try{const ie=await ID();await V(),ie!=null&&ie.message&&alert(ie.message)}catch(ie){console.error("同步订单失败:",ie),alert((ie==null?void 0:ie.message)||"同步失败,请重试")}finally{A(!1)}},Le=ie=>{z(ie),P(null),ce(!0)},Ce=async ie=>{var De;se(!0),P(null);try{const Ue=await RD([R],ie),B=(De=Ue==null?void 0:Ue.results)==null?void 0:De[0];B!=null&&B.success?(P({success:!0,message:B.message}),V()):P({success:!1,message:(B==null?void 0:B.message)||"发货失败"})}catch(Ue){P({success:!1,message:(Ue==null?void 0:Ue.message)||"请求失败"})}finally{se(!1)}},Y=ie=>{K(ie),M(!0)},ge=ie=>{re({...ie}),D(!0)},Pe=async()=>{if(!(!T||!T.order_id))try{const ie={};T.status!==void 0&&(ie.order_status=T.status),T.buyer_id!==void 0&&(ie.buyer_id=T.buyer_id),T.amount!==void 0&&(ie.amount=T.amount),T.receiver_name!==void 0&&(ie.receiver_name=T.receiver_name),T.receiver_phone!==void 0&&(ie.receiver_phone=T.receiver_phone),T.receiver_address!==void 0&&(ie.receiver_address=T.receiver_address),T.item_id!==void 0&&(ie.item_id=T.item_id),T.quantity!==void 0&&(ie.quantity=T.quantity),await PD(T.order_id,ie),D(!1),re(null),V()}catch(ie){console.error("更新订单失败:",ie),alert("更新失败,请重试")}},Be=async()=>{if(Q)try{const ie=new FormData;ie.append("file",Q),await LD(ie),$(!1),ne(null),V(),alert("订单导入成功")}catch(ie){alert((ie==null?void 0:ie.message)||"导入失败,请检查文件格式")}},Ve=async ie=>{he(ie);try{const De=await $D(ie);De.success?await V():alert(De.message||"同步失败")}catch(De){console.error("同步订单失败:",De),alert((De==null?void 0:De.message)||"同步失败,请重试")}finally{he(null)}},Dt=async ie=>{if(confirm("确认删除该订单吗?删除后无法恢复。")){_e(ie);try{await zD(ie),r(De=>De.filter(Ue=>Ue.order_id!==ie))}catch(De){console.error("删除订单失败:",De),alert((De==null?void 0:De.message)||"删除失败,请重试"),await V()}finally{_e(null)}}};return c.jsxs("div",{className:"space-y-6 animate-fade-in",children:[c.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"订单中心"}),c.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"查看所有闲鱼交易记录与状态。"})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("button",{onClick:V,className:"p-3 rounded-2xl bg-white border border-gray-100 text-gray-600 hover:bg-gray-50 hover:text-black transition-colors shadow-sm",children:c.jsx(pr,{className:`w-5 h-5 ${S?"animate-spin":""}`})}),c.jsxs("button",{onClick:()=>$(!0),className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors text-sm flex items-center gap-2 shadow-lg",children:[c.jsx(ja,{className:"w-4 h-4"}),"插入订单"]}),c.jsxs("button",{onClick:ae,className:"ios-btn-primary px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 text-sm flex items-center gap-2",children:[c.jsx(yj,{className:"w-5 h-5"}),"一键同步订单"]})]})]}),c.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[c.jsxs("div",{className:"p-4 border-b border-gray-50 flex flex-col md:flex-row gap-4 justify-between items-center bg-[#FAFAFA]",children:[c.jsx("div",{className:"flex gap-1 p-1 bg-gray-200/50 rounded-xl overflow-x-auto max-w-full",children:[{k:"all",v:"全部"},{k:"shipped",v:"已发货"},{k:"pending_ship",v:"待发货"},{k:"cancelled",v:"已取消"},{k:"refunding",v:"其他"}].map(ie=>c.jsx("button",{onClick:()=>{h(ie.k),w(1),y("")},className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${m===ie.k?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:ie.v},ie.k))}),c.jsxs("div",{className:"relative w-full md:w-auto group",children:[c.jsx(WM,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 group-focus-within:text-[#0094f7] transition-colors"}),c.jsx("input",{type:"text",placeholder:"搜索订单号/商品/买家...",value:v,onChange:ie=>{y(ie.target.value),w(1)},className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]}),c.jsx("div",{className:"overflow-x-auto min-h-[400px]",children:c.jsxs("table",{className:"w-full text-left border-collapse table-fixed",children:[c.jsx("thead",{children:c.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[c.jsx("th",{className:"px-6 py-5",style:{width:"28%"},children:"订单信息"}),c.jsx("th",{className:"px-6 py-5",style:{width:"26%"},children:"买家信息"}),c.jsx("th",{className:"px-6 py-5",style:{width:"11%"},children:"实付金额"}),c.jsx("th",{className:"px-6 py-5",style:{width:"13%"},children:"当前状态"}),c.jsx("th",{className:"px-6 py-5 text-right",style:{width:"22%"},children:"操作"})]})}),c.jsx("tbody",{className:"divide-y divide-gray-50",children:e.map(ie=>c.jsxs("tr",{className:"hover:bg-[#FFFDE7]/50 transition-colors group",children:[c.jsx("td",{className:"px-6 py-5",children:c.jsxs("div",{className:"flex items-center gap-5",children:[c.jsx("div",{className:"w-14 h-14 rounded-xl bg-gray-100 overflow-hidden shadow-sm border border-gray-100 flex-shrink-0",children:ie.item_image?c.jsx("img",{src:ie.item_image,alt:"",className:"w-full h-full object-cover"}):c.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300",children:c.jsx(uc,{})})}),c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"font-bold text-gray-900 line-clamp-1 text-sm",children:ye(ie.item_id,ie.item_title)}),c.jsxs("div",{className:"text-xs text-gray-500 mt-1 font-medium",children:["订单ID: ",ie.order_id]}),c.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",ie.quantity," • ",ie.created_at]})]})]})}),c.jsx("td",{className:"px-6 py-5",children:c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("div",{className:"text-xs text-gray-500",children:"买家ID"}),c.jsx("div",{className:"text-sm font-bold text-gray-800",children:ie.buyer_id}),ie.receiver_name&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-xs text-gray-500",children:"收货人"}),c.jsx("div",{className:"text-xs text-gray-600",children:ie.receiver_name})]}),ie.receiver_phone&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-xs text-gray-500",children:"联系电话"}),c.jsx("div",{className:"text-xs text-gray-600 font-mono",children:ie.receiver_phone})]}),ie.receiver_address&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-xs text-gray-500",children:"收货地址"}),c.jsx("div",{className:"text-xs text-gray-600 line-clamp-1",children:ie.receiver_address})]})]})}),c.jsx("td",{className:"px-6 py-5 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:ie.amount?`¥${ie.amount}`:c.jsx("span",{className:"text-xs text-amber-600 font-bold",children:"待获取"})}),c.jsx("td",{className:"px-6 py-5",children:c.jsx(QS,{status:ie.status})}),c.jsxs("td",{className:"px-6 py-5 text-right",children:[ie.status==="pending_ship"&&c.jsx("button",{onClick:()=>Le(ie.order_id),className:"mr-2 text-white bg-black hover:bg-gray-800 shadow-lg shadow-gray-200 text-xs font-bold px-3 py-2 rounded-xl transition-all active:scale-95",children:"立即发货"}),c.jsx("a",{href:`https://www.goofish.com/order-detail?orderId=${ie.order_id}&role=seller`,target:"_blank",rel:"noopener noreferrer",className:"mr-2 inline-flex text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看闲鱼详情",children:c.jsx(uA,{className:"w-4 h-4"})}),c.jsx("button",{onClick:()=>Y(ie),className:"mr-2 text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看详情",children:c.jsx(xs,{className:"w-4 h-4"})}),c.jsx("button",{onClick:()=>ge(ie),className:"mr-2 text-gray-400 hover:text-black p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"编辑订单",children:c.jsx(bs,{className:"w-4 h-4"})}),c.jsx("button",{onClick:()=>Ve(ie.order_id),disabled:I===ie.order_id,className:"mr-2 text-gray-400 hover:text-green-600 p-2 rounded-xl hover:bg-green-50 transition-colors disabled:opacity-50",title:"同步订单",children:c.jsx(pr,{className:`w-4 h-4 ${I===ie.order_id?"animate-spin":""}`})}),c.jsx("button",{onClick:()=>Dt(ie.order_id),disabled:be===ie.order_id,className:"text-gray-400 hover:text-red-500 p-2 rounded-xl hover:bg-red-50 transition-colors disabled:opacity-50",title:"删除订单",children:c.jsx(xa,{className:"w-4 h-4"})})]})]},ie.id))})]})}),c.jsxs("div",{className:"p-4 border-t border-gray-50 flex items-center justify-between bg-white",children:[c.jsxs("div",{className:"text-sm text-gray-500 font-medium pl-2",children:["第 ",b," 页 / 共 ",j," 页"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{disabled:b<=1,onClick:()=>w(ie=>ie-1),className:"p-2.5 rounded-xl bg-gray-50 hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed text-gray-600 transition-colors",children:c.jsx(FT,{className:"w-5 h-5"})}),c.jsx("button",{disabled:b>=j,onClick:()=>w(ie=>ie+1),className:"p-2.5 rounded-xl bg-gray-50 hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed text-gray-600 transition-colors",children:c.jsx(WT,{className:"w-5 h-5"})})]})]})]}),C&&U&&It.createPortal(c.jsx("div",{className:"modal-overlay-centered",children:c.jsxs("div",{className:"modal-container",children:[c.jsx("div",{className:"modal-header",children:c.jsxs("div",{className:"flex items-center justify-between w-full",children:[c.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"订单详情"}),c.jsx("button",{onClick:()=>M(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:c.jsx(Xt,{className:"w-5 h-5 text-gray-600"})})]})}),c.jsxs("div",{className:"modal-body space-y-6",children:[c.jsxs("div",{className:"space-y-4",children:[c.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"订单信息"}),c.jsxs("div",{className:"grid grid-cols-2 gap-4 p-4 bg-gray-50 rounded-xl",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"订单号"}),c.jsx("div",{className:"font-mono text-sm font-bold text-gray-900",children:U.order_id})]}),c.jsxs("div",{children:[c.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"状态"}),c.jsx(QS,{status:U.status})]}),c.jsxs("div",{children:[c.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"实付金额"}),c.jsx("div",{className:"text-lg font-extrabold text-gray-900",children:U.amount?`¥${U.amount}`:"待获取"})]}),c.jsxs("div",{children:[c.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"数量"}),c.jsx("div",{className:"font-bold text-gray-900",children:U.quantity})]}),c.jsxs("div",{className:"col-span-2",children:[c.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"创建时间"}),c.jsx("div",{className:"text-sm font-medium text-gray-700",children:U.created_at})]})]})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"商品信息"}),c.jsxs("div",{className:"p-4 bg-gray-50 rounded-xl flex items-center gap-4",children:[U.item_image&&c.jsx("img",{src:U.item_image,alt:"",className:"w-20 h-20 rounded-xl object-cover border border-gray-200"}),c.jsxs("div",{className:"flex-1",children:[c.jsx("div",{className:"font-bold text-gray-900 mb-1",children:ye(U.item_id,U.item_title)}),c.jsxs("div",{className:"text-sm text-gray-500",children:["商品ID: ",U.item_id]}),U.item_price&&c.jsxs("div",{className:"text-sm text-gray-500 mt-1",children:["标价: ¥",U.item_price]})]})]})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"买家信息"}),c.jsxs("div",{className:"p-4 bg-gray-50 rounded-xl space-y-3",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"买家ID"}),c.jsx("div",{className:"font-bold text-gray-900",children:U.buyer_id})]}),U.receiver_name&&c.jsxs("div",{children:[c.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"收货人"}),c.jsx("div",{className:"font-medium text-gray-700",children:U.receiver_name})]}),U.receiver_phone&&c.jsxs("div",{children:[c.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"联系电话"}),c.jsx("div",{className:"font-mono text-sm text-gray-700",children:U.receiver_phone})]}),U.receiver_address&&c.jsxs("div",{children:[c.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"收货地址"}),c.jsx("div",{className:"text-sm text-gray-700",children:U.receiver_address})]})]})]})]}),c.jsx("div",{className:"modal-footer",children:c.jsxs("div",{className:"flex gap-3 w-full",children:[c.jsx("button",{onClick:()=>M(!1),className:"flex-1 px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"关闭"}),U.status==="pending_ship"&&c.jsx("button",{onClick:()=>{M(!1),Le(U.order_id)},className:"flex-1 px-6 py-3 rounded-xl ios-btn-primary font-bold shadow-lg shadow-blue-200",children:"立即发货"})]})})]})}),document.body),E&&It.createPortal(c.jsx("div",{className:"modal-overlay-centered",children:c.jsxs("div",{className:"modal-container",children:[c.jsx("div",{className:"modal-header",children:c.jsxs("div",{className:"flex items-center justify-between w-full",children:[c.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"插入订单"}),c.jsx("button",{onClick:()=>$(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:c.jsx(Xt,{className:"w-5 h-5 text-gray-600"})})]})}),c.jsxs("div",{className:"modal-body space-y-5",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"选择Excel文件"}),c.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv,.json",onChange:ie=>{var De;return ne(((De=ie.target.files)==null?void 0:De[0])||null)},className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),c.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持 .xlsx、.csv、.tsv、.json 格式"})]}),Q&&c.jsx("div",{className:"p-3 bg-blue-50 rounded-xl",children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(tc,{className:"w-4 h-4 text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-900",children:Q.name})]})})]}),c.jsx("div",{className:"modal-footer",children:c.jsxs("div",{className:"flex gap-3 w-full",children:[c.jsx("button",{onClick:()=>$(!1),className:"flex-1 px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"取消"}),c.jsx("button",{onClick:Be,disabled:!Q,className:"flex-1 px-6 py-3 rounded-xl ios-btn-primary font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:"导入订单"})]})})]})}),document.body),fe&&It.createPortal(c.jsx("div",{className:"modal-overlay-centered",children:c.jsxs("div",{className:"modal-container",style:{maxWidth:"480px"},children:[c.jsx("div",{className:"modal-header",children:c.jsxs("div",{className:"flex items-center justify-between w-full",children:[c.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"立即发货"}),c.jsx("button",{onClick:()=>{ce(!1),P(null)},className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:c.jsx(Xt,{className:"w-5 h-5 text-gray-600"})})]})}),c.jsxs("div",{className:"modal-body space-y-4",children:[c.jsx("p",{className:"text-sm text-gray-600",children:"请选择发货方式:"}),c.jsx("button",{onClick:()=>Ce("status_only"),disabled:G,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-gray-400 hover:bg-gray-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-100 flex items-center justify-center flex-shrink-0 mt-0.5",children:c.jsx(yj,{className:"w-5 h-5 text-blue-600"})}),c.jsxs("div",{children:[c.jsx("div",{className:"font-bold text-gray-900 text-sm",children:"仅修改闲鱼发货状态"}),c.jsx("div",{className:"text-xs text-gray-500 mt-1 leading-relaxed",children:'不实际扣除或发送卡券,仅在闲鱼平台将订单标记为"已发货"。 适用于已经给客户发过货、只是忘记在闲鱼修改状态的情况。'})]})]})}),c.jsx("button",{onClick:()=>Ce("full_delivery"),disabled:G,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-[#0094f7] hover:bg-blue-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-100 flex items-center justify-center flex-shrink-0 mt-0.5",children:c.jsx(uc,{className:"w-5 h-5 text-blue-700"})}),c.jsxs("div",{children:[c.jsx("div",{className:"font-bold text-gray-900 text-sm",children:"完整发货(匹配卡券并发送)"}),c.jsx("div",{className:"text-xs text-gray-500 mt-1 leading-relaxed",children:"自动匹配发货规则、获取卡券、发送卡券信息给买家,并修改发货状态。 适用于订单既没有发送卡券给买家、也没有修改发货状态的情况。"})]})]})}),G&&c.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[c.jsx(pr,{className:"w-4 h-4 animate-spin text-gray-500"}),c.jsx("span",{className:"text-sm text-gray-500",children:"正在处理中..."})]}),ue&&c.jsxs("div",{className:`p-3 rounded-xl text-sm ${ue.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:[ue.success?"✓ ":"✗ ",ue.message]})]}),c.jsx("div",{className:"modal-footer",children:c.jsx("button",{onClick:()=>{ce(!1),P(null)},className:"w-full px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:ue!=null&&ue.success?"完成":"取消"})})]})}),document.body),k&&T&&It.createPortal(c.jsx("div",{className:"modal-overlay-centered",children:c.jsxs("div",{className:"modal-container",children:[c.jsx("div",{className:"modal-header",children:c.jsxs("div",{className:"flex items-center justify-between w-full",children:[c.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑订单"}),c.jsx("button",{onClick:()=>D(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:c.jsx(Xt,{className:"w-5 h-5 text-gray-600"})})]})}),c.jsxs("div",{className:"modal-body space-y-5",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"订单号"}),c.jsx("input",{type:"text",value:T.order_id,disabled:!0,className:"w-full ios-input px-4 py-3 rounded-xl bg-gray-50 text-gray-500"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"订单状态"}),c.jsxs("select",{value:T.status,onChange:ie=>re({...T,status:ie.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[c.jsx("option",{value:"processing",children:"处理中"}),c.jsx("option",{value:"pending_ship",children:"待发货"}),c.jsx("option",{value:"shipped",children:"已发货"}),c.jsx("option",{value:"completed",children:"已完成"}),c.jsx("option",{value:"cancelled",children:"已取消"}),c.jsx("option",{value:"refunding",children:"退款中"})]})]})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"买家ID"}),c.jsx("input",{type:"text",value:T.buyer_id,onChange:ie=>re({...T,buyer_id:ie.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"实付金额"}),c.jsx("input",{type:"number",value:T.amount,onChange:ie=>re({...T,amount:parseFloat(ie.target.value)}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"收货人"}),c.jsx("input",{type:"text",value:T.receiver_name||"",onChange:ie=>re({...T,receiver_name:ie.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"联系电话"}),c.jsx("input",{type:"text",value:T.receiver_phone||"",onChange:ie=>re({...T,receiver_phone:ie.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"收货地址"}),c.jsx("textarea",{value:T.receiver_address||"",onChange:ie=>re({...T,receiver_address:ie.target.value}),rows:2,className:"w-full ios-input px-4 py-3 rounded-xl resize-none"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"商品标题"}),c.jsx("input",{type:"text",value:T.item_title||"",onChange:ie=>re({...T,item_title:ie.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),c.jsx("div",{className:"modal-footer",children:c.jsxs("div",{className:"flex gap-3 w-full",children:[c.jsx("button",{onClick:()=>D(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),c.jsxs("button",{onClick:Pe,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[c.jsx(Sa,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body)]})},JS=()=>({name:"",type:"data",content:"",description:"",enabled:!0,delay_seconds:0,api_method:"GET",api_timeout:10,api_headers:"",api_params:""}),PQ=()=>{const[e,t]=x.useState([]),[n,r]=x.useState(!1),[l,s]=x.useState(!1),[d,f]=x.useState(null),[m,h]=x.useState({}),[v,y]=x.useState(JS),[b,w]=x.useState(!1),[j,_]=x.useState("create"),[S,A]=x.useState(null),[C,M]=x.useState(null),[k,D]=x.useState(!1),[E,$]=x.useState(""),[U,K]=x.useState(""),[T,re]=x.useState(null);x.useEffect(()=>{va().then(t)},[]);const Z=({type:I})=>{switch(I){case"text":return c.jsx(mj,{className:"w-5 h-5 text-blue-500"});case"image":return c.jsx(hj,{className:"w-5 h-5 text-purple-500"});case"api":return c.jsx(fj,{className:"w-5 h-5 text-blue-500"});default:return c.jsx(Lv,{className:"w-5 h-5 text-gray-500"})}},pe=I=>{var he,be,_e,W,V;f(I),h({id:I.id,name:I.name||"",type:I.type||"text",api_url:((he=I.api_config)==null?void 0:he.url)||"",api_method:((be=I.api_config)==null?void 0:be.method)||"GET",api_timeout:((_e=I.api_config)==null?void 0:_e.timeout)||10,api_headers:((W=I.api_config)==null?void 0:W.headers)||"",api_params:((V=I.api_config)==null?void 0:V.params)||"",text_content:I.text_content||"",data_content:I.data_content||"",image_url:I.image_url||"",delay_seconds:I.delay_seconds||0,description:I.description||"",enabled:I.enabled}),r(!0)},fe=async()=>{var I,he,be,_e,W,V,ye,xe;if(d){if(!((I=m.name)!=null&&I.trim())){alert("请输入卡密名称");return}if(!m.type){alert("请选择卡密类型");return}try{const ae={name:m.name.trim(),type:m.type,description:(he=m.description)==null?void 0:he.trim(),delay_seconds:m.delay_seconds||0,enabled:m.enabled??!0};m.type==="api"?ae.api_config={url:(be=m.api_url)==null?void 0:be.trim(),method:m.api_method,timeout:m.api_timeout||10,headers:((_e=m.api_headers)==null?void 0:_e.trim())||void 0,params:((W=m.api_params)==null?void 0:W.trim())||void 0}:m.type==="text"?ae.text_content=((V=m.text_content)==null?void 0:V.trim())||"":m.type==="data"?ae.data_content=((ye=m.data_content)==null?void 0:ye.trim())||"":m.type==="image"&&(ae.image_url=((xe=m.image_url)==null?void 0:xe.trim())||""),await wj(d.id,ae),r(!1),va().then(t)}catch(ae){console.error("更新卡密失败:",ae),alert("更新失败,请重试")}}},ce=async I=>{if(confirm("确认删除该卡密吗?"))try{await KD(I),va().then(t)}catch(he){console.error("删除卡密失败:",he),alert("删除失败,请重试")}},R=async()=>{if(!v.name.trim()){alert("请输入卡密名称");return}if(!v.content.trim()){alert(v.type==="api"?"请输入 API 地址":"请输入卡密内容");return}try{const I={name:v.name.trim(),type:v.type,description:v.description.trim(),enabled:v.enabled,delay_seconds:v.delay_seconds};v.type==="text"&&(I.text_content=v.content.trim()),v.type==="data"&&(I.data_content=v.content.trim()),v.type==="image"&&(I.image_url=v.content.trim()),v.type==="api"&&(I.api_config={url:v.content.trim(),method:v.api_method,timeout:v.api_timeout,headers:v.api_headers.trim()||void 0,params:v.api_params.trim()||void 0}),await qD(I),s(!1),y(JS()),va().then(t)}catch(I){console.error("添加卡密失败:",I),alert("添加失败,请重试")}},z=async I=>{try{await wj(I.id,{...I,enabled:!I.enabled}),va().then(t)}catch(he){console.error("切换状态失败:",he)}},G=async I=>{try{await navigator.clipboard.writeText(String(I)),alert(`已复制卡密组ID:${I}`)}catch{prompt("复制卡密组ID",String(I))}},se=e.filter(I=>I.type==="data"),ue=()=>{const be=[["名称","类型","内容","描述","启用","延迟秒","多规格","规格名","规格值"],...[["VIP月卡","data",`VIP-MONTH-001 -VIP-MONTH-002 -VIP-MONTH-003`,"按行消费的卡密队列","是","0","否","",""],["感谢文案","text","感谢购买,如有问题联系客服~","固定文本","是","0","否","",""],["教程图","image","https://cdn.example.com/tutorial.jpg","图片URL","是","0","否","",""]]].map(ye=>ye.map(xe=>`"${String(xe).replace(/"/g,'""')}"`).join(",")).join(` -`),_e=new Blob(["\uFEFF"+be],{type:"text/csv;charset=utf-8"}),W=URL.createObjectURL(_e),V=document.createElement("a");V.href=W,V.download="卡密组批量导入模板.csv",document.body.appendChild(V),V.click(),V.remove(),URL.revokeObjectURL(W)},P=async()=>{if(S){D(!0),M(null);try{const I=await YD(S);if(M(I),I.created>0){const he=await va();t(he)}}catch(I){M({error:(I==null?void 0:I.message)||"上传失败"})}finally{D(!1)}}},Q=async()=>{if(!(!E||!U.trim())){D(!0),re(null);try{const I=await GD(E,U);re({added:I.added}),K("");const he=await va();t(he)}catch(I){alert("追加失败:"+((I==null?void 0:I.message)||"未知错误"))}finally{D(!1)}}},ne=()=>{var I;_("create"),A(null),M(null),$((I=se[0])!=null&&I.id?String(se[0].id):""),K(""),re(null),w(!0)};return c.jsxs("div",{className:"space-y-6 animate-fade-in",children:[c.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"卡密库存"}),c.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理自动发货的卡密、链接或图片资源。"})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("button",{onClick:ne,className:"px-4 py-3 bg-gray-100 hover:bg-gray-200 rounded-2xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[c.jsx(tc,{className:"w-5 h-5"}),"批量导入"]}),c.jsxs("button",{onClick:()=>s(!0),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[c.jsx(ja,{className:"w-5 h-5"}),"添加新卡密"]})]})]}),c.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[c.jsx("div",{className:"overflow-x-auto",children:c.jsxs("table",{className:"w-full text-left border-collapse",children:[c.jsx("thead",{children:c.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[c.jsx("th",{className:"px-8 py-5 w-[18%]",children:"卡密名称"}),c.jsx("th",{className:"px-6 py-5 w-[12%]",children:"卡密组ID"}),c.jsx("th",{className:"px-6 py-5 w-[10%]",children:"类型"}),c.jsx("th",{className:"px-6 py-5 w-[22%]",children:"内容/库存"}),c.jsx("th",{className:"px-6 py-5 w-[18%]",children:"描述"}),c.jsx("th",{className:"px-6 py-5 w-[10%]",children:"状态"}),c.jsx("th",{className:"px-6 py-5 w-[10%] text-right",children:"操作"})]})}),c.jsx("tbody",{className:"divide-y divide-gray-50",children:e.map(I=>{let he="";return I.type==="data"&&I.data_content?he=`库存: ${I.data_content.split(` -`).filter(_e=>_e.trim()).length} 条`:I.type==="text"&&I.text_content?he=I.text_content.substring(0,20)+(I.text_content.length>20?"...":""):I.type==="api"&&I.api_config?he=I.api_config.url:I.type==="image"&&I.image_url&&(he="图片链接"),c.jsxs("tr",{className:"hover:bg-[#FFFDE7]/50 transition-colors group",children:[c.jsx("td",{className:"px-8 py-5",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"p-2 bg-gray-50 rounded-xl group-hover:bg-white transition-colors",children:c.jsx(Z,{type:I.type})}),c.jsx("span",{className:"font-bold text-gray-900",children:I.name})]})}),c.jsx("td",{className:"px-6 py-5",children:c.jsxs("button",{onClick:()=>G(I.id),className:"inline-flex items-center gap-2 rounded-xl bg-gray-100 px-3 py-2 font-mono text-xs font-extrabold text-gray-700 hover:bg-gray-200 transition-colors",title:"复制卡密组ID,用于批量铺货表格",children:[I.id,c.jsx(lM,{className:"w-3.5 h-3.5"})]})}),c.jsx("td",{className:"px-6 py-5",children:c.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${I.type==="text"?"bg-blue-50 text-blue-600":I.type==="data"?"bg-purple-50 text-purple-600":I.type==="api"?"bg-blue-50 text-blue-600":"bg-pink-50 text-pink-600"}`,children:I.type==="text"?"文本":I.type==="data"?"批量":I.type==="api"?"API":"图片"})}),c.jsx("td",{className:"px-6 py-5",children:c.jsx("span",{className:"text-sm text-gray-600 font-mono block truncate",title:he,children:he})}),c.jsx("td",{className:"px-6 py-5",children:c.jsx("span",{className:"text-sm text-gray-500 block max-w-[200px] truncate",title:I.description||"-",children:I.description||"-"})}),c.jsx("td",{className:"px-6 py-5",children:c.jsx("button",{onClick:()=>z(I),className:`w-12 h-8 rounded-full relative transition-colors ${I.enabled?"bg-green-500":"bg-gray-300"}`,children:c.jsx("div",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-sm transition-transform ${I.enabled?"left-5":"left-1"}`})})}),c.jsx("td",{className:"px-6 py-5",children:c.jsxs("div",{className:"flex items-center justify-end gap-2",children:[c.jsx("button",{onClick:()=>pe(I),className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:c.jsx(bs,{className:"w-4 h-4"})}),c.jsx("button",{onClick:()=>ce(I.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",children:c.jsx(xa,{className:"w-5 h-5"})})]})})]},I.id)})})]})}),e.length===0&&c.jsxs("div",{className:"py-20 text-center text-gray-400",children:[c.jsx(fA,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),c.jsx("p",{children:"暂无卡密配置,请点击右上角添加。"})]})]}),n&&d&&It.createPortal(c.jsx("div",{className:"modal-overlay-centered",children:c.jsxs("div",{className:"modal-container",children:[c.jsxs("div",{className:"modal-header",children:[c.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑卡密"}),c.jsx("button",{onClick:()=>r(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:c.jsx(Xt,{className:"w-5 h-5 text-gray-500"})})]}),c.jsx("div",{className:"modal-body",children:c.jsxs("div",{className:"space-y-5",children:[c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[c.jsxs("div",{children:[c.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:["卡密名称 ",c.jsx("span",{className:"text-red-500",children:"*"})]}),c.jsx("input",{type:"text",value:m.name||"",onChange:I=>h({...m,name:I.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:游戏点卡、会员卡等"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡券类型"}),c.jsxs("select",{value:m.type||"text",onChange:I=>h({...m,type:I.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[c.jsx("option",{value:"",children:"请选择类型"}),c.jsx("option",{value:"text",children:"固定文字"}),c.jsx("option",{value:"data",children:"批量数据"}),c.jsx("option",{value:"api",children:"API接口"}),c.jsx("option",{value:"image",children:"图片"})]})]})]}),m.type==="api"&&c.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 space-y-4 bg-gray-50",children:[c.jsx("h3",{className:"font-bold text-gray-900",children:"API 配置"}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"API 地址"}),c.jsx("input",{type:"url",value:m.api_url||"",onChange:I=>h({...m,api_url:I.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://api.example.com/get-card"})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"请求方法"}),c.jsxs("select",{value:m.api_method||"GET",onChange:I=>h({...m,api_method:I.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[c.jsx("option",{value:"GET",children:"GET"}),c.jsx("option",{value:"POST",children:"POST"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"超时时间(秒)"}),c.jsx("input",{type:"number",value:m.api_timeout||10,onChange:I=>h({...m,api_timeout:parseInt(I.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"1",max:"60"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"请求头(JSON 格式)"}),c.jsx("textarea",{value:m.api_headers||"",onChange:I=>h({...m,api_headers:I.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-20 resize-none font-mono text-sm",placeholder:'{"Authorization": "Bearer token"}'})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"请求参数(JSON 格式)"}),c.jsx("textarea",{value:m.api_params||"",onChange:I=>h({...m,api_params:I.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-20 resize-none font-mono text-sm",placeholder:'{"type": "card", "count": 1}'})]})]}),m.type==="text"&&c.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[c.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"固定文字配置"}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"文字内容"}),c.jsx("textarea",{value:m.text_content||"",onChange:I=>h({...m,text_content:I.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none",placeholder:"请输入要发送的固定文字内容..."})]})]}),m.type==="data"&&c.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[c.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"批量数据配置"}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"数据内容(一行一个)"}),c.jsx("textarea",{value:m.data_content||"",onChange:I=>h({...m,data_content:I.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-80 resize-none font-mono text-sm",placeholder:`请输入数据,每行一个: -卡号1:密码1 -卡号2:密码2 -或者 -兑换码1 -兑换码2`}),c.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持格式:卡号:密码 或 单独的兑换码"}),c.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",c.jsx("span",{className:"font-bold text-blue-600",children:m.data_content?m.data_content.split(` -`).filter(I=>I.trim()).length:0})," 条"]})]})]}),m.type==="image"&&c.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[c.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"图片配置"}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),c.jsx("input",{type:"url",value:m.image_url||"",onChange:I=>h({...m,image_url:I.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://example.com/image.png"}),c.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"输入图片卡密的 URL 地址"})]}),m.image_url&&c.jsxs("div",{className:"mt-3",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片预览"}),c.jsx("img",{src:m.image_url,alt:"预览",className:"max-w-full max-h-48 rounded-xl border border-gray-200",onError:I=>{I.currentTarget.src="https://via.placeholder.com/400x200?text=图片加载失败"}})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"延时发货时间(秒)"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"number",value:m.delay_seconds||0,onChange:I=>h({...m,delay_seconds:parseInt(I.target.value)||0}),className:"flex-1 ios-input px-4 py-3 rounded-xl",min:"0",max:"3600",placeholder:"0"}),c.jsx("span",{className:"text-sm text-gray-500 whitespace-nowrap",children:"秒"})]}),c.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"0表示立即发货,最大3600秒(1小时)"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注信息"}),c.jsx("textarea",{value:m.description||"",onChange:I=>h({...m,description:I.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none",placeholder:"可选的备注信息"})]}),c.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[c.jsx("span",{className:"font-bold text-gray-900",children:"启用状态"}),c.jsx("button",{type:"button",onClick:()=>h({...m,enabled:!m.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${m.enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:c.jsx("span",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${m.enabled?"translate-x-7":"translate-x-1"}`})})]})]})}),c.jsx("div",{className:"modal-footer",children:c.jsxs("div",{className:"flex gap-3 w-full",children:[c.jsx("button",{onClick:()=>r(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),c.jsxs("button",{onClick:fe,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[c.jsx(Sa,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body),l&&It.createPortal(c.jsx("div",{className:"modal-overlay-centered",children:c.jsxs("div",{className:"modal-container",style:{maxWidth:"780px"},children:[c.jsxs("div",{className:"modal-header flex items-center justify-between gap-4",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"添加新卡密"}),c.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"选择交付方式并录入自动发货内容"})]}),c.jsx("button",{onClick:()=>s(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",title:"关闭",children:c.jsx(Xt,{className:"w-5 h-5 text-gray-500"})})]}),c.jsx("div",{className:"modal-body",children:c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡密名称"}),c.jsx("input",{type:"text",value:v.name,onChange:I=>y({...v,name:I.target.value}),placeholder:"例如:VIP会员卡密",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"类型"}),c.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2",children:[c.jsxs("button",{type:"button",onClick:()=>y({...v,type:"data",content:""}),className:`p-3 rounded-xl font-bold transition-all ${v.type==="data"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[c.jsx(Lv,{className:"w-5 h-5 mx-auto mb-1"}),"批量库存"]}),c.jsxs("button",{type:"button",onClick:()=>y({...v,type:"text",content:""}),className:`p-3 rounded-xl font-bold transition-all ${v.type==="text"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600"}`,children:[c.jsx(mj,{className:"w-5 h-5 mx-auto mb-1"}),"文本"]}),c.jsxs("button",{type:"button",onClick:()=>y({...v,type:"image",content:""}),className:`p-3 rounded-xl font-bold transition-all ${v.type==="image"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600"}`,children:[c.jsx(hj,{className:"w-5 h-5 mx-auto mb-1"}),"图片"]}),c.jsxs("button",{type:"button",onClick:()=>y({...v,type:"api",content:""}),className:`p-3 rounded-xl font-bold transition-all ${v.type==="api"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600"}`,children:[c.jsx(fj,{className:"w-5 h-5 mx-auto mb-1"}),"API"]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:v.type==="data"?"库存内容(一行一个)":v.type==="text"?"固定回复内容":v.type==="image"?"图片 URL":"API 地址"}),v.type==="api"?c.jsx("input",{type:"url",value:v.content,onChange:I=>y({...v,content:I.target.value}),placeholder:"https://api.example.com/get-code",className:"w-full ios-input px-4 py-3 rounded-xl"}):v.type==="image"?c.jsx("input",{type:"url",value:v.content,onChange:I=>y({...v,content:I.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"https://example.com/card.png"}):c.jsx("textarea",{value:v.content,onChange:I=>y({...v,content:I.target.value}),className:`w-full ios-input px-4 py-3 rounded-xl resize-none text-sm ${v.type==="data"?"h-48 font-mono":"h-32"}`,placeholder:v.type==="data"?`CODE-123456 -CODE-789012 -...`:"请输入每次发货时发送的固定文字"}),v.type==="data"&&c.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",c.jsx("span",{className:"font-bold text-[#0094f7]",children:v.content.split(` -`).filter(I=>I.trim()).length})," 条"]})]}),v.type==="api"&&c.jsxs("div",{className:"border-t border-gray-100 pt-5 space-y-4",children:[c.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求方法"}),c.jsxs("select",{value:v.api_method,onChange:I=>y({...v,api_method:I.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[c.jsx("option",{value:"GET",children:"GET"}),c.jsx("option",{value:"POST",children:"POST"})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"超时时间(秒)"}),c.jsx("input",{type:"number",min:"1",max:"60",value:v.api_timeout,onChange:I=>y({...v,api_timeout:parseInt(I.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),c.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求头(JSON)"}),c.jsx("textarea",{value:v.api_headers,onChange:I=>y({...v,api_headers:I.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"Authorization":"Bearer token"}'})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求参数(JSON)"}),c.jsx("textarea",{value:v.api_params,onChange:I=>y({...v,api_params:I.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"order_id":"{order_id}"}'})]})]})]}),c.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_180px] gap-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"描述"}),c.jsx("input",{value:v.description,onChange:I=>y({...v,description:I.target.value}),placeholder:"卡密用途描述(可选)",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"延时发货(秒)"}),c.jsx("input",{type:"number",value:v.delay_seconds,onChange:I=>y({...v,delay_seconds:parseInt(I.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"3600"})]})]})]})}),c.jsx("div",{className:"modal-footer",children:c.jsxs("div",{className:"flex gap-3 w-full",children:[c.jsx("button",{onClick:()=>s(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),c.jsxs("button",{onClick:R,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[c.jsx(ja,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),b&&It.createPortal(c.jsx("div",{className:"modal-overlay",children:c.jsxs("div",{className:"modal-container",style:{maxWidth:"40rem"},children:[c.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[c.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量导入卡密"}),c.jsx("button",{onClick:()=>w(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:c.jsx(Xt,{className:"w-5 h-5 text-gray-600"})})]}),c.jsxs("div",{className:"px-6 py-5 space-y-5",children:[c.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[c.jsxs("button",{onClick:()=>_("create"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${j==="create"?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[c.jsx(CM,{className:"w-4 h-4"}),"批量创建卡密组"]}),c.jsxs("button",{onClick:()=>_("append"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${j==="append"?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[c.jsx(tc,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),j==="create"?c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"rounded-xl bg-blue-50 border border-blue-100 p-4 text-xs text-blue-900 leading-5",children:["上传表格,每行一个卡密组。表头:",c.jsx("code",{className:"bg-blue-100/70 px-1.5 py-0.5 rounded",children:"名称,类型,内容,描述,启用,延迟秒,多规格,规格名,规格值"}),'。 类型填 text/data/image/api;data 类型的"内容"按行存卡密(CSV 单元格内换行需用引号包裹)。']}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("button",{onClick:ue,className:"px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text-sm transition-colors",children:[c.jsx(vM,{className:"w-4 h-4"}),"下载模板"]}),c.jsxs("label",{className:"flex-1 px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text-sm cursor-pointer transition-colors",children:[c.jsx(tc,{className:"w-4 h-4"}),S?S.name:"选择 .xlsx / .csv / .tsv",c.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv",className:"hidden",onChange:I=>{var he;return A(((he=I.target.files)==null?void 0:he[0])||null)}})]})]}),C&&!C.error&&c.jsxs("div",{className:"rounded-xl border border-gray-200 p-4 space-y-2",children:[c.jsxs("div",{className:"text-sm font-bold text-gray-900",children:["共 ",C.total," 行 · 成功 ",C.created," · 失败 ",C.failed]}),C.failed>0&&c.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:C.rows.filter(I=>!I.success).map(I=>c.jsxs("div",{className:"text-xs text-red-600",children:["第 ",I.row_no," 行「",I.name,"」:",I.error]},I.row_no))})]})]}):c.jsx("div",{className:"space-y-4",children:se.length===0?c.jsx("div",{className:"rounded-xl bg-amber-50 border border-amber-200 p-4 text-sm text-amber-800",children:"暂无 data(批量卡密)类型的卡密组,请先创建一个再充卡密。"}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"选择卡密组"}),c.jsx("select",{value:E,onChange:I=>$(I.target.value),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",children:se.map(I=>c.jsxs("option",{value:String(I.id),children:[I.name,"(ID: ",I.id,")"]},I.id))})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"卡密号(每行一个)"}),c.jsx("textarea",{value:U,onChange:I=>K(I.target.value),placeholder:`VIP-001 -VIP-002 -VIP-003`,className:"w-full ios-input px-4 py-3 rounded-xl text-sm font-mono h-40 resize-y"}),c.jsx("p",{className:"text-xs text-gray-500",children:"一行一个卡密号,空行自动忽略。会追加到该组现有库存末尾。"})]}),T&&c.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",T.added," 个卡密"]})]})})]}),c.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[c.jsx("button",{onClick:()=>w(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),j==="create"?c.jsxs("button",{onClick:P,disabled:!S||k,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[k?c.jsx(Yn,{className:"w-4 h-4 animate-spin"}):c.jsx(tc,{className:"w-4 h-4"}),k?"处理中...":"上传创建"]}):c.jsxs("button",{onClick:Q,disabled:!E||!U.trim()||k||se.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[k?c.jsx(Yn,{className:"w-4 h-4 animate-spin"}):c.jsx(ja,{className:"w-4 h-4"}),k?"处理中...":"追加卡密"]})]})]})}),document.body)]})},zQ=e=>{const t=String(e||"").trim();return t?/^[¥¥]/.test(t)?t:`¥${t}`:"-"},IQ=({onConfigureDelivery:e})=>{const[t,n]=x.useState([]),[r,l]=x.useState([]),[s,d]=x.useState([]),[f,m]=x.useState(""),[h,v]=x.useState(!1),[y,b]=x.useState(!1),[w,j]=x.useState(!1),[_,S]=x.useState(!1),[A,C]=x.useState(!1),[M,k]=x.useState(!1),[D,E]=x.useState(!1),[$,U]=x.useState("upload"),[K,T]=x.useState(null),[re,Z]=x.useState(null),[pe,fe]=x.useState(null),[ce,R]=x.useState(null),[z,G]=x.useState(null),[se,ue]=x.useState({}),[P,Q]=x.useState({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),[ne,I]=x.useState({cookie_id:"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),he=async()=>{const B=await Ns();n(B)},be=async()=>{l(await Rd())};x.useEffect(()=>{Promise.all([Fy(),Ns(),Rd()]).then(([B,Te,lt])=>{d(B),n(Te),l(lt)}).catch(B=>console.error("加载商品配置失败:",B))},[]),x.useEffect(()=>{if(!D||!(ce!=null&&ce.id)||ce.status!=="running")return;const B=window.setInterval(async()=>{try{const Te=await cd(ce.id);R(Te),Te.status!=="running"&&(U("done"),await he(),await be())}catch(Te){console.error("刷新批量铺货进度失败:",Te)}},3e3);return()=>window.clearInterval(B)},[D,ce==null?void 0:ce.id,ce==null?void 0:ce.status]);const _e=async()=>{if(!f)return alert("请先选择账号");v(!0);try{const B=await VD(f);await he(),alert((B==null?void 0:B.message)||"商品同步完成")}catch(B){console.error("同步商品失败:",B),alert((B==null?void 0:B.message)||"同步失败,请重试")}finally{v(!1)}},W=B=>{G(B),ue({...B}),S(!0)},V=async()=>{if(z)try{await tP(z.cookie_id,z.item_id,{item_title:se.item_title||"",item_description:se.item_description||"",item_category:se.item_category||"",item_price:se.item_price||"",item_detail:se.item_detail||z.item_detail||""}),await he(),await be(),S(!1),G(null)}catch(B){console.error("更新商品失败:",B),alert("更新失败,请重试")}},ye=async B=>{if(confirm(`确认删除商品"${B.item_title}"吗?`))try{await FD(B.cookie_id,B.item_id),n(Te=>Te.filter(lt=>!(lt.cookie_id===B.cookie_id&<.item_id===B.item_id)))}catch(Te){console.error("删除商品失败:",Te),alert("删除失败,请重试")}},xe=async()=>{try{if(!P.cookie_id||!P.item_id){alert("请选择账号并填写商品ID");return}await XD(P.cookie_id,{item_id:P.item_id,item_title:P.item_title,item_price:P.item_price,item_detail:P.item_image?JSON.stringify({item_image:P.item_image}):""}),await he(),C(!1),Q({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""})}catch(B){console.error("添加商品失败:",B),alert("添加失败,请重试")}},ae=async()=>{if(!ne.cookie_id)return alert("请选择发布账号");if(!ne.title.trim())return alert("请填写商品标题");if(!ne.price.trim())return alert("请填写商品价格");if(!ne.quantity||Number(ne.quantity)<=0)return alert("库存数量必须大于 0");if(ne.images.length===0)return alert("至少上传 1 张商品图片");if(ne.postage_mode==="fixed"&&!ne.postage.trim())return alert("请填写一口价邮费");b(!0);try{const B=await WD(ne);if(await he(),k(!1),I({cookie_id:f||"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),B!=null&&B.item_id){const Te={id:B.item_id,cookie_id:ne.cookie_id,item_id:B.item_id,item_title:B.item_title||ne.title,item_price:B.item_price||ne.price,item_image:B.item_image};e(Te),alert("商品发布成功,ID: "+B.item_id+",已为你打开发货规则配置")}else alert("商品发布成功")}catch(B){console.error("发布商品失败:",B);const Te=B==null?void 0:B.payload;if((Te==null?void 0:Te.code)==="stock_permission_missing"){alert("发布失败:该账号没有库存发布权限,无法按库存数量发布商品。请换账号或先在闲鱼确认库存能力。");return}alert((B==null?void 0:B.message)||"发布失败,请重试")}finally{b(!1)}},Le=()=>{U("upload"),fe(null),R(null),T(null),Z(null),E(!0)},Ce=async()=>{if(!K)return alert("请先上传商品表格");if(!f)return alert("请先选择默认发布账号");j(!0);try{const B=await ZD({file:K,imagesZip:re,defaultCookieId:f});fe(B),R(null),U("preview")}catch(B){console.error("批量铺货预检失败:",B),alert((B==null?void 0:B.message)||"预检失败,请检查表格和图片 zip")}finally{j(!1)}},Y=async()=>{if(pe!=null&&pe.preview_id){if(pe.valid<=0)return alert("没有可发布的商品行");j(!0);try{const B=await QD(pe.preview_id),Te=await cd(B.batch_id||pe.preview_id);R(Te),U(Te.status==="running"?"running":"done")}catch(B){console.error("启动批量铺货失败:",B),alert((B==null?void 0:B.message)||"启动发布任务失败")}finally{j(!1)}}},ge=async()=>{if(ce!=null&&ce.id&&confirm("确认取消当前批量铺货任务吗?正在发布的单个商品可能会继续完成。")){j(!0);try{await JD(ce.id),R(await cd(ce.id)),U("done")}catch(B){alert((B==null?void 0:B.message)||"取消失败")}finally{j(!1)}}},Pe=async()=>{if(ce!=null&&ce.id){j(!0);try{await eP(ce.id),R(await cd(ce.id)),U("running")}catch(B){alert((B==null?void 0:B.message)||"重试失败")}finally{j(!1)}}},Be=()=>{const lt=[["账号ID","标题","描述","价格","原价","库存","邮费模式","邮费","图片","付款发货启用","付款发货内容","评价赠品启用","评价赠品内容","求评价启用","求评价等待小时","求评价文案","求评价最多次数"],...[["","会员组合包自动发货","下单后发送主卡和附赠卡。","19.90","29.90","10","free","","images/bundle-1.jpg;images/bundle-2.jpg","是","101:1;102:1","是","201:1;202:2","是","72","亲,满意的话麻烦给个评价,谢谢~","1"],["","普通商品","仅发布商品,不创建自动化规则。","49.90","","10","fixed","8.00","https://example.com/product.jpg","否","","否","","否","","",""]]].map(wi=>wi.map(xl=>`"${String(xl).replace(/"/g,'""')}"`).join(",")).join(` -`),Zr=new Blob(["\uFEFF"+lt],{type:"text/csv;charset=utf-8"}),Qn=URL.createObjectURL(Zr),$n=document.createElement("a");$n.href=Qn,$n.download="批量铺货模板.csv",document.body.appendChild($n),$n.click(),$n.remove(),URL.revokeObjectURL(Qn)},Ve=()=>{Q(B=>({...B,cookie_id:f||B.cookie_id})),C(!0)},Dt=()=>{I(B=>({...B,cookie_id:f||B.cookie_id})),k(!0)},ie=B=>r.filter(Te=>Te.cookie_id===B.cookie_id&&Te.item_id===B.item_id),De=B=>{switch(B){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"canceled":return"已取消";default:return B||"-"}},Ue=B=>{switch(B){case"success":case"completed":return"bg-emerald-50 text-emerald-700 border-emerald-100";case"failed":return"bg-red-50 text-red-700 border-red-100";case"running":return"bg-blue-50 text-blue-700 border-blue-100";case"canceled":return"bg-gray-100 text-gray-600 border-gray-200";default:return"bg-amber-50 text-amber-700 border-amber-100"}};return c.jsxs("div",{className:"space-y-6 animate-fade-in",children:[c.jsxs("div",{className:"flex justify-between items-center",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"商品管理"}),c.jsx("p",{className:"text-gray-500 mt-2 text-sm",children:"监控并管理所有账号下的闲鱼商品。"})]}),c.jsxs("div",{className:"flex gap-3",children:[c.jsxs("select",{className:"ios-input px-4 py-3 rounded-xl text-sm",value:f,onChange:B=>m(B.target.value),children:[c.jsx("option",{value:"",children:"选择账号以同步"}),s.map(B=>c.jsx("option",{value:B.id,children:B.nickname},B.id))]}),c.jsxs("button",{onClick:_e,disabled:h||!f,className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:[c.jsx(pr,{className:`w-4 h-4 ${h?"animate-spin":""}`}),"同步商品"]}),c.jsxs("button",{onClick:Ve,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-lg",children:[c.jsx(ja,{className:"w-4 h-4"}),"添加商品"]}),c.jsxs("button",{onClick:Dt,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-600 text-white hover:bg-emerald-700 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[c.jsx(Zp,{className:"w-4 h-4"}),"发布商品"]}),c.jsxs("button",{onClick:Le,className:"px-5 py-3 rounded-2xl font-bold bg-blue-600 text-white hover:bg-blue-700 transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[c.jsx(od,{className:"w-4 h-4"}),"批量铺货"]})]})]}),c.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:[t.map(B=>{const Te=ie(B),lt=Te.length>0;return c.jsxs("div",{className:"ios-card p-3 rounded-2xl hover:shadow-lg transition-all group relative flex flex-col",children:[c.jsxs("div",{className:"absolute top-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:[c.jsx("button",{onClick:()=>W(B),className:"p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md text-gray-600 hover:bg-[#0094f7] hover:text-white transition-colors",title:"编辑",children:c.jsx(bs,{className:"w-3.5 h-3.5"})}),c.jsx("button",{onClick:()=>ye(B),className:"p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md hover:bg-red-100 text-red-500 transition-colors",title:"删除",children:c.jsx(xa,{className:"w-3.5 h-3.5"})})]}),c.jsxs("div",{className:"aspect-square bg-gray-100 rounded-xl mb-2.5 overflow-hidden relative",children:[B.item_image?c.jsx("img",{src:B.item_image,alt:"",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}):c.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300",children:c.jsx(sA,{className:"w-8 h-8"})}),c.jsx("div",{className:"absolute top-1.5 left-1.5 bg-black/50 backdrop-blur-md text-white text-[10px] font-bold px-1.5 py-0.5 rounded-md",children:zQ(B.item_price)})]}),c.jsx("h3",{className:"font-bold text-gray-900 line-clamp-2 text-xs mb-1.5 h-8 leading-4",children:B.item_title}),c.jsxs("div",{className:"flex justify-between items-center text-[10px] text-gray-500 mb-2",children:[c.jsxs("span",{className:"bg-gray-100 px-1.5 py-0.5 rounded truncate max-w-[80px]",children:["ID: ",B.item_id]}),c.jsxs("span",{className:`inline-flex items-center gap-1 font-bold ${lt?"text-emerald-600":"text-amber-600"}`,children:[lt?c.jsx(oA,{className:"w-3 h-3"}):c.jsx(eM,{className:"w-3 h-3"}),lt?`${Te.length} 规则`:"未配置"]})]}),c.jsx("div",{className:"space-y-2 mt-auto",children:c.jsxs("button",{onClick:()=>e(B),className:`w-full flex items-center justify-between gap-1 px-2.5 py-2 rounded-lg text-[11px] font-extrabold transition-all ${lt?"bg-gray-900 text-white hover:bg-black":"bg-[#0094f7] text-white hover:bg-[#0071e3] shadow-md shadow-blue-100"}`,children:[c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(EM,{className:"w-3.5 h-3.5"}),lt?"查看发货规则":"关联发货规则"]}),c.jsx(Rv,{className:"w-3.5 h-3.5"})]})})]},`${B.cookie_id}-${B.item_id}`)}),t.length===0&&c.jsxs("div",{className:"col-span-full py-20 text-center text-gray-400",children:[c.jsx(pA,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),"暂无商品数据,请选择账号进行同步"]})]}),_&&z&&It.createPortal(c.jsx("div",{className:"modal-overlay-centered",children:c.jsxs("div",{className:"modal-container",style:{maxWidth:"560px"},children:[c.jsxs("div",{className:"modal-header flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"编辑商品"}),c.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["ID: ",z.item_id]})]}),c.jsx("button",{onClick:()=>S(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:c.jsx(Xt,{className:"w-5 h-5 text-gray-500"})})]}),c.jsxs("div",{className:"modal-body space-y-4",children:[c.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"商品标题",value:se.item_title||"",onChange:B=>ue({...se,item_title:B.target.value})}),c.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"价格",value:se.item_price||"",onChange:B=>ue({...se,item_price:B.target.value})}),c.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"分类",value:se.item_category||"",onChange:B=>ue({...se,item_category:B.target.value})}),c.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述",value:se.item_description||"",onChange:B=>ue({...se,item_description:B.target.value})})]}),c.jsx("div",{className:"modal-footer",children:c.jsxs("button",{onClick:V,className:"w-full ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[c.jsx(Sa,{className:"w-4 h-4"}),"保存"]})})]})}),document.body),A&&It.createPortal(c.jsx("div",{className:"modal-overlay-centered",children:c.jsxs("div",{className:"modal-container",style:{maxWidth:"720px"},children:[c.jsxs("div",{className:"modal-header flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"添加商品"}),c.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"手动建立商品与自动发货规则的关联"})]}),c.jsx("button",{onClick:()=>C(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:c.jsx(Xt,{className:"w-5 h-5 text-gray-500"})})]}),c.jsxs("div",{className:"modal-body space-y-5",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"所属账号"}),c.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:P.cookie_id,onChange:B=>Q({...P,cookie_id:B.target.value}),children:[c.jsx("option",{value:"",children:"选择账号"}),s.map(B=>c.jsx("option",{value:B.id,children:B.nickname||B.remark||B.id},B.id))]})]}),c.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品 ID"}),c.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"输入闲鱼商品 ID",value:P.item_id,onChange:B=>Q({...P,item_id:B.target.value})})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品价格"}),c.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如 99.00",value:P.item_price,onChange:B=>Q({...P,item_price:B.target.value})})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品标题"}),c.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"输入商品标题",value:P.item_title,onChange:B=>Q({...P,item_title:B.target.value})})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"图片 URL"}),c.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"https://...",value:P.item_image,onChange:B=>Q({...P,item_image:B.target.value})})]})]}),c.jsx("div",{className:"modal-footer",children:c.jsxs("button",{onClick:xe,className:"w-full ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[c.jsx(ja,{className:"w-4 h-4"}),"添加商品"]})})]})}),document.body),M&&It.createPortal(c.jsx("div",{className:"modal-overlay-centered",children:c.jsxs("div",{className:"modal-container",style:{maxWidth:"820px"},children:[c.jsxs("div",{className:"modal-header flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"发布商品到闲鱼"}),c.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"普通单规格发布;库存数量会写入闲鱼发布参数,用于判断账号库存能力。"})]}),c.jsx("button",{onClick:()=>k(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:c.jsx(Xt,{className:"w-5 h-5 text-gray-500"})})]}),c.jsxs("div",{className:"modal-body space-y-5",children:[c.jsx("div",{className:"rounded-2xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-800 leading-6",children:"发布时必须填写库存。若账号没有库存发布能力,后端会返回明确的“库存权限不足”错误,不会误报为普通发布失败。"}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"发布账号"}),c.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:ne.cookie_id,onChange:B=>I({...ne,cookie_id:B.target.value}),children:[c.jsx("option",{value:"",children:"选择账号"}),s.map(B=>c.jsx("option",{value:B.id,children:B.nickname||B.remark||B.id},B.id))]})]}),c.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品标题"}),c.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:会员月卡自动发货",value:ne.title,onChange:B=>I({...ne,title:B.target.value})})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"库存数量"}),c.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",type:"number",min:"1",placeholder:"必须大于 0",value:ne.quantity,onChange:B=>I({...ne,quantity:B.target.value})})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品描述"}),c.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述会用于自动识别类目;留空时使用标题",value:ne.description,onChange:B=>I({...ne,description:B.target.value})})]}),c.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"售价"}),c.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"99.00",value:ne.price,onChange:B=>I({...ne,price:B.target.value})})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"原价(可选)"}),c.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"129.00",value:ne.original_price,onChange:B=>I({...ne,original_price:B.target.value})})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"运费方式"}),c.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:ne.postage_mode,onChange:B=>I({...ne,postage_mode:B.target.value}),children:[c.jsx("option",{value:"free",children:"包邮"}),c.jsx("option",{value:"distance",children:"按距离计费"}),c.jsx("option",{value:"fixed",children:"一口价邮费"}),c.jsx("option",{value:"none",children:"无需邮寄"})]})]})]}),ne.postage_mode==="fixed"&&c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"一口价邮费"}),c.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如 8.00",value:ne.postage,onChange:B=>I({...ne,postage:B.target.value})})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品图片(1-9 张)"}),c.jsxs("label",{className:"flex min-h-[120px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-emerald-300 hover:bg-emerald-50/50 transition-colors",children:[c.jsx(od,{className:"w-8 h-8 text-emerald-600 mb-2"}),c.jsx("span",{className:"text-sm font-bold text-gray-800",children:"选择图片"}),c.jsx("span",{className:"text-xs text-gray-500 mt-1",children:ne.images.length?"已选择 "+ne.images.length+" 张":"支持 JPG / PNG / GIF"}),c.jsx("input",{className:"hidden",type:"file",accept:"image/*",multiple:!0,onChange:B=>I({...ne,images:Array.from(B.target.files||[]).slice(0,9)})})]}),ne.images.length>0&&c.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-3",children:ne.images.map((B,Te)=>c.jsx("div",{className:"aspect-square rounded-xl bg-gray-100 overflow-hidden border border-gray-100",children:c.jsx("img",{src:URL.createObjectURL(B),alt:"",className:"w-full h-full object-cover"})},B.name+Te))})]})]}),c.jsx("div",{className:"modal-footer",children:c.jsxs("button",{disabled:y,onClick:ae,className:"w-full bg-emerald-600 hover:bg-emerald-700 disabled:opacity-60 text-white px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[c.jsx(Zp,{className:"w-4 h-4"}),y?"正在发布...":"发布到闲鱼"]})})]})}),document.body),D&&It.createPortal(c.jsx("div",{className:"modal-overlay-centered",children:c.jsxs("div",{className:"modal-container",style:{maxWidth:"980px"},children:[c.jsxs("div",{className:"modal-header flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量铺货"}),c.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"上传商品表格和图片 zip,先预检,再逐条发布到闲鱼。"})]}),c.jsx("button",{onClick:()=>E(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:c.jsx(Xt,{className:"w-5 h-5 text-gray-500"})})]}),c.jsxs("div",{className:"modal-body space-y-5",children:[c.jsx("div",{className:"grid grid-cols-4 gap-2",children:[["upload","1 上传"],["preview","2 预检"],["running","3 发布"],["done","4 结果"]].map(([B,Te])=>c.jsx("div",{className:`rounded-xl px-3 py-2 text-center text-xs font-extrabold border ${$===B?"bg-blue-600 text-white border-blue-600":"bg-gray-50 text-gray-500 border-gray-100"}`,children:Te},B))}),$==="upload"&&c.jsxs("div",{className:"space-y-5",children:[c.jsx("div",{className:"rounded-2xl border border-blue-100 bg-blue-50 p-4 text-sm text-blue-900 leading-6",children:c.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-3",children:[c.jsxs("div",{children:[c.jsx("div",{className:"font-extrabold",children:"先下载模板,再按字段填写。"}),c.jsxs("div",{children:["图片字段写 zip 内相对路径,多个图片用英文分号分隔,例如 ",c.jsx("span",{className:"font-mono font-bold",children:"images/a.jpg;images/b.jpg"}),"。也支持直接填写图片 URL。"]})]}),c.jsx("button",{type:"button",onClick:Be,className:"shrink-0 rounded-xl bg-blue-600 px-4 py-2 text-sm font-extrabold text-white hover:bg-blue-700",children:"下载CSV模板"})]})}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"默认发布账号"}),c.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:f,onChange:B=>m(B.target.value),children:[c.jsx("option",{value:"",children:"选择账号"}),s.map(B=>c.jsx("option",{value:B.id,children:B.nickname||B.remark||B.id},B.id))]}),c.jsx("p",{className:"text-xs text-gray-500",children:"表格中“账号ID”为空时,会使用这里选择的账号。"})]}),c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[c.jsxs("label",{className:"flex min-h-[150px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-blue-300 hover:bg-blue-50 transition-colors",children:[c.jsx(od,{className:"w-9 h-9 text-blue-600 mb-3"}),c.jsx("span",{className:"text-sm font-extrabold text-gray-900",children:"上传商品表格"}),c.jsx("span",{className:"text-xs text-gray-500 mt-1",children:K?K.name:"支持 .xlsx / .csv / .tsv"}),c.jsx("input",{className:"hidden",type:"file",accept:".xlsx,.csv,.tsv",onChange:B=>{var Te;return T(((Te=B.target.files)==null?void 0:Te[0])||null)}})]}),c.jsxs("label",{className:"flex min-h-[150px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-emerald-300 hover:bg-emerald-50 transition-colors",children:[c.jsx(od,{className:"w-9 h-9 text-emerald-600 mb-3"}),c.jsx("span",{className:"text-sm font-extrabold text-gray-900",children:"上传图片 zip(可选)"}),c.jsx("span",{className:"text-xs text-gray-500 mt-1",children:re?re.name:"表格图片字段使用 zip 内相对路径"}),c.jsx("input",{className:"hidden",type:"file",accept:".zip",onChange:B=>{var Te;return Z(((Te=B.target.files)==null?void 0:Te[0])||null)}})]})]}),c.jsxs("div",{className:"rounded-2xl bg-gray-50 border border-gray-100 p-4 space-y-3",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"字段说明"}),c.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"照着下面的“什么时候填写”处理即可。预检发现问题时,会指出具体哪一行需要修改。"})]}),c.jsxs("div",{className:"rounded-xl border border-blue-100 bg-blue-50 p-4 text-xs text-blue-950",children:[c.jsx("div",{className:"text-sm font-extrabold",children:"“付款后发送的卡密”怎么填"}),c.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-3 lg:grid-cols-3",children:[c.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[c.jsx("code",{className:"font-bold text-blue-700",children:"101"}),c.jsx("p",{className:"mt-1 leading-5",children:"从卡密组 101 立即发送 1 份。卡密组 ID 可以在“卡密库存”页面查看。"})]}),c.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[c.jsx("code",{className:"font-bold text-blue-700",children:"101:2"}),c.jsx("p",{className:"mt-1 leading-5",children:"每购买 1 件,就从卡密组 101 发送 2 份。买家购买 3 件时会发送 6 份。"})]}),c.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[c.jsx("code",{className:"font-bold text-blue-700",children:"101:1:0;102:2:3"}),c.jsx("p",{className:"mt-1 leading-5",children:"先立即发送卡密组 101 的 1 份,再等待 3 秒发送卡密组 102 的 2 份。"})]})]}),c.jsxs("p",{className:"mt-3 leading-5 text-blue-800",children:["每一组依次写“卡密组 ID : 每件发送几份 : 等待几秒”。份数不写时按 1 份处理,等待时间不写时立即发送。需要发送多种卡密时,用英文分号 ",c.jsx("code",{className:"font-bold",children:";"})," 隔开。"]})]}),c.jsx("div",{className:"overflow-x-auto rounded-xl border border-gray-100 bg-white",children:c.jsxs("table",{className:"w-full text-left text-xs",children:[c.jsx("thead",{className:"bg-gray-50 text-gray-500",children:c.jsxs("tr",{children:[c.jsx("th",{className:"px-3 py-2",children:"字段"}),c.jsx("th",{className:"px-3 py-2",children:"什么时候填写"}),c.jsx("th",{className:"px-3 py-2",children:"填写方法"})]})}),c.jsx("tbody",{className:"divide-y divide-gray-50 text-gray-700",children:[["账号ID","没有在上方选择默认账号时填写","填写账号 ID;已经选择默认账号时可以留空"],["标题","每个商品都要填","填写买家能看到的商品标题"],["描述","可以留空","留空时会使用商品标题作为描述"],["价格","每个商品都要填","只填数字,例如 19.90"],["原价","可以留空","需要展示划线原价时填写,例如 29.90"],["库存","可以留空","留空按 1 件处理;填写时必须大于 0"],["邮费模式","可以留空","留空表示包邮;包邮填 free,固定邮费填 fixed"],["邮费","邮费模式填 fixed 时填写","只填数字,例如 8.00"],["图片","每个商品都要填","填写 zip 内图片路径或图片网址;多张图片用英文分号隔开"],["付款后自动发货","需要付款后自动发货时填写","填“是”表示开启;不需要时填“否”或留空"],["付款后发送的卡密","“付款后自动发货”填“是”时填写","从“卡密库存”页面取得卡密组 ID,按上方示例填写"],["评价后发送赠品","需要评价赠品时填写","填“是”表示开启;不需要时填“否”或留空"],["评价后发送的卡密","“评价后发送赠品”填“是”时填写","格式和付款后发送的卡密相同,也可以同时发送多个卡密组"],["超时未评价时提醒","需要自动求评价时填写","填“是”表示开启;不需要时填“否”或留空"],["发货几小时后提醒","“超时未评价时提醒”填“是”时填写","填写等待小时数;留空按 72 小时处理"],["提醒内容","“超时未评价时提醒”填“是”时填写","填写要发送给买家的求评价消息"],["最多提醒几次","可以留空","留空只提醒 1 次"]].map(([B,Te,lt])=>c.jsxs("tr",{children:[c.jsx("td",{className:"px-3 py-2 font-bold text-gray-900 whitespace-nowrap",children:B}),c.jsx("td",{className:`px-3 py-2 min-w-[210px] font-bold ${Te==="每个商品都要填"?"text-red-600":Te==="可以留空"?"text-gray-500":"text-amber-700"}`,children:Te}),c.jsx("td",{className:"px-3 py-2 min-w-[260px]",children:lt})]},B))})]})})]})]}),$==="preview"&&pe&&c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[c.jsxs("div",{className:"rounded-2xl bg-gray-50 p-4 border border-gray-100",children:[c.jsx("div",{className:"text-xs font-bold text-gray-500",children:"总行数"}),c.jsx("div",{className:"text-2xl font-extrabold text-gray-900 mt-1",children:pe.total})]}),c.jsxs("div",{className:"rounded-2xl bg-emerald-50 p-4 border border-emerald-100",children:[c.jsx("div",{className:"text-xs font-bold text-emerald-700",children:"可发布"}),c.jsx("div",{className:"text-2xl font-extrabold text-emerald-700 mt-1",children:pe.valid})]}),c.jsxs("div",{className:"rounded-2xl bg-red-50 p-4 border border-red-100",children:[c.jsx("div",{className:"text-xs font-bold text-red-700",children:"有问题"}),c.jsx("div",{className:"text-2xl font-extrabold text-red-700 mt-1",children:pe.invalid})]})]}),c.jsx("div",{className:"max-h-[380px] overflow-y-auto rounded-2xl border border-gray-100",children:c.jsxs("table",{className:"w-full text-left text-sm",children:[c.jsx("thead",{className:"sticky top-0 bg-white text-xs text-gray-400 border-b border-gray-100",children:c.jsxs("tr",{children:[c.jsx("th",{className:"px-4 py-3",children:"行号"}),c.jsx("th",{className:"px-4 py-3",children:"状态"}),c.jsx("th",{className:"px-4 py-3",children:"标题"}),c.jsx("th",{className:"px-4 py-3",children:"价格/库存"}),c.jsx("th",{className:"px-4 py-3",children:"图片"}),c.jsx("th",{className:"px-4 py-3",children:"问题"})]})}),c.jsx("tbody",{className:"divide-y divide-gray-50",children:pe.rows.map(B=>{var Te,lt;return c.jsxs("tr",{className:"hover:bg-gray-50",children:[c.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:B.row_no}),c.jsx("td",{className:"px-4 py-3",children:c.jsx("span",{className:`inline-flex px-2 py-1 rounded-lg border text-xs font-extrabold ${B.valid?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-red-50 text-red-700 border-red-100"}`,children:B.valid?"可发布":"需修正"})}),c.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[240px] truncate",children:B.title||"-"}),c.jsxs("td",{className:"px-4 py-3 text-gray-600",children:["¥",B.price||"-"," / ",B.quantity||1]}),c.jsxs("td",{className:"px-4 py-3 text-gray-600",children:[((Te=B.images)==null?void 0:Te.length)||0," 张"]}),c.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[280px]",children:((lt=B.errors)==null?void 0:lt.join(";"))||"-"})]},B.row_no)})})]})})]}),($==="running"||$==="done")&&ce&&c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[c.jsxs("div",{className:`rounded-2xl p-4 border ${Ue(ce.status)}`,children:[c.jsx("div",{className:"text-xs font-bold opacity-70",children:"任务状态"}),c.jsx("div",{className:"text-xl font-extrabold mt-1",children:De(ce.status)})]}),c.jsxs("div",{className:"rounded-2xl bg-gray-50 p-4 border border-gray-100",children:[c.jsx("div",{className:"text-xs font-bold text-gray-500",children:"总数"}),c.jsx("div",{className:"text-xl font-extrabold text-gray-900 mt-1",children:ce.total})]}),c.jsxs("div",{className:"rounded-2xl bg-emerald-50 p-4 border border-emerald-100",children:[c.jsx("div",{className:"text-xs font-bold text-emerald-700",children:"成功"}),c.jsx("div",{className:"text-xl font-extrabold text-emerald-700 mt-1",children:ce.success})]}),c.jsxs("div",{className:"rounded-2xl bg-red-50 p-4 border border-red-100",children:[c.jsx("div",{className:"text-xs font-bold text-red-700",children:"失败"}),c.jsx("div",{className:"text-xl font-extrabold text-red-700 mt-1",children:ce.failed})]}),c.jsxs("div",{className:"rounded-2xl bg-blue-50 p-4 border border-blue-100",children:[c.jsx("div",{className:"text-xs font-bold text-blue-700",children:"等待"}),c.jsx("div",{className:"text-xl font-extrabold text-blue-700 mt-1",children:ce.pending})]})]}),c.jsx("div",{className:"max-h-[420px] overflow-y-auto rounded-2xl border border-gray-100",children:c.jsxs("table",{className:"w-full text-left text-sm",children:[c.jsx("thead",{className:"sticky top-0 bg-white text-xs text-gray-400 border-b border-gray-100",children:c.jsxs("tr",{children:[c.jsx("th",{className:"px-4 py-3",children:"行号"}),c.jsx("th",{className:"px-4 py-3",children:"状态"}),c.jsx("th",{className:"px-4 py-3",children:"标题"}),c.jsx("th",{className:"px-4 py-3",children:"商品ID"}),c.jsx("th",{className:"px-4 py-3",children:"错误原因"})]})}),c.jsx("tbody",{className:"divide-y divide-gray-50",children:ce.rows.map(B=>c.jsxs("tr",{className:"hover:bg-gray-50",children:[c.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:B.row_no}),c.jsx("td",{className:"px-4 py-3",children:c.jsx("span",{className:`inline-flex px-2 py-1 rounded-lg border text-xs font-extrabold ${Ue(B.status)}`,children:De(B.status)})}),c.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[260px] truncate",children:B.title}),c.jsx("td",{className:"px-4 py-3 text-xs font-mono",children:B.item_url?c.jsx("a",{href:B.item_url,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline",children:B.item_id}):B.item_id||"-"}),c.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[340px]",children:B.error_message||"-"})]},B.id))})]})})]})]}),c.jsxs("div",{className:"modal-footer",children:[$==="upload"&&c.jsxs("button",{disabled:w||!K||!f,onClick:Ce,className:"w-full ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2 disabled:opacity-50",children:[c.jsx(pr,{className:`w-4 h-4 ${w?"animate-spin":""}`}),w?"正在预检...":"开始预检"]}),$==="preview"&&pe&&c.jsxs("div",{className:"flex gap-3 w-full",children:[c.jsx("button",{disabled:w,onClick:()=>U("upload"),className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold",children:"返回修改"}),c.jsxs("button",{disabled:w||pe.valid<=0,onClick:Y,className:"flex-1 ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2 disabled:opacity-50",children:[c.jsx(Zp,{className:"w-4 h-4"}),w?"启动中...":`确认发布 ${pe.valid} 个商品`]})]}),($==="running"||$==="done")&&ce&&c.jsxs("div",{className:"flex gap-3 w-full",children:[ce.status==="running"?c.jsx("button",{disabled:w,onClick:ge,className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"取消任务"}):c.jsx("button",{onClick:()=>window.open(`/items/publish-batches/${ce.id}/result.csv`,"_blank"),className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"下载结果"}),ce.failed>0&&ce.status!=="running"&&c.jsxs("button",{disabled:w,onClick:Pe,className:"flex-1 ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[c.jsx(pr,{className:`w-4 h-4 ${w?"animate-spin":""}`}),"重试失败项"]}),ce.status!=="running"&&c.jsx("button",{onClick:()=>{E(!1),he(),be()},className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold",children:"完成"})]})]})]})}),document.body)]})},eA="https://dashscope.aliyuncs.com/compatible-mode/v1",$Q=()=>{const[e,t]=x.useState(null),[n,r]=x.useState(!1),[l,s]=x.useState(!1),[d,f]=x.useState([]),[m,h]=x.useState(!1),[v,y]=x.useState(""),[b,w]=x.useState(!1),j=x.useRef(null),[_,S]=x.useState(!1),[A,C]=x.useState(!1),[M,k]=x.useState(!1),[D,E]=x.useState(!1),[$,U]=x.useState(null),[K,T]=x.useState({new_username:"",current_password:"",new_password:"",confirm_password:""});x.useEffect(()=>{Z(),gA().then(z=>{z.username&&T(G=>({...G,new_username:z.username||""}))}).catch(()=>{})},[]),x.useEffect(()=>{const z=G=>{var se;(se=j.current)!=null&&se.contains(G.target)||w(!1)};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]);const re=async(z,G=!1)=>{const se=z||e,ue=(se==null?void 0:se.ai_api_url)||(se==null?void 0:se.ai_base_url)||eA;h(!0),y("");try{const P=await cP(ue,(se==null?void 0:se.ai_api_key)||"");f(P),w(G&&P.length>0),!(se!=null&&se.ai_model)&&P.length>0&&t(Q=>Q&&{...Q,ai_model:P[0]})}catch(P){f([]),w(!1),y(P.message||"读取模型失败")}finally{h(!1)}},Z=()=>{r(!0),bA().then(z=>{t(z),re(z)}).finally(()=>r(!1))},pe=async()=>{if(e){s(!0);try{const{smtp_server:z,smtp_port:G,smtp_user:se,smtp_password:ue,smtp_from:P,...Q}=e;await wA(Q),alert("系统配置已保存")}catch(z){alert("保存失败:"+z.message)}finally{s(!1)}}},fe=async z=>{z.preventDefault(),U(null);const G=K.new_username.trim();if(G.length<3){U({type:"error",text:"用户名至少需要 3 个字符"});return}if(!K.current_password){U({type:"error",text:"请输入当前密码确认身份"});return}if(K.new_password&&K.new_password.length<8){U({type:"error",text:"新密码至少需要 8 个字符"});return}if(K.new_password!==K.confirm_password){U({type:"error",text:"两次输入的新密码不一致"});return}E(!0);try{const se=await bD({current_password:K.current_password,new_username:G,new_password:K.new_password||void 0});if(!se.success){U({type:"error",text:se.message||"登录凭据更新失败"});return}U({type:"success",text:se.message||"登录凭据已更新"}),window.setTimeout(()=>window.location.reload(),1400)}catch(se){U({type:"error",text:se.message||"登录凭据更新失败"})}finally{E(!1)}};if(!e)return c.jsx("div",{className:"p-8 text-center text-gray-400",children:"加载配置中..."});const ce=e.ai_model||"",R=d;return c.jsxs("div",{className:"max-w-6xl mx-auto space-y-8 animate-fade-in pb-24",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsx("div",{className:"w-12 h-12 bg-gray-100 rounded-2xl flex items-center justify-center",children:c.jsx(Gy,{className:"w-6 h-6 text-gray-600"})}),c.jsxs("div",{children:[c.jsx("h2",{className:"text-3xl font-extrabold text-gray-900",children:"系统设置"}),c.jsx("p",{className:"text-gray-500 mt-1 text-sm font-medium",children:"配置全局自动化规则与系统参数"})]})]}),c.jsxs("button",{onClick:Z,className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[c.jsx(pr,{className:"w-4 h-4"}),"刷新"]})]}),c.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[c.jsxs("div",{className:"space-y-8",children:[c.jsxs("section",{className:"space-y-4",children:[c.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[c.jsx("div",{className:"p-1.5 rounded-lg bg-gray-100 text-gray-600",children:c.jsx(cM,{className:"w-4 h-4"})}),"基础设置"]}),c.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[c.jsxs("div",{children:[c.jsx("div",{className:"font-bold text-gray-900",children:"允许用户注册"}),c.jsx("div",{className:"text-xs text-gray-500 mt-1",children:"开启后允许新用户注册账号"})]}),c.jsx("button",{onClick:()=>t({...e,registration_enabled:!e.registration_enabled}),className:`w-14 h-8 rounded-full transition-all relative ${e.registration_enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:c.jsx("div",{className:`w-6 h-6 bg-white rounded-full absolute top-1 transition-all shadow-md ${e.registration_enabled?"left-7":"left-1"}`})})]}),c.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[c.jsxs("div",{children:[c.jsx("div",{className:"font-bold text-gray-900",children:"显示默认登录信息"}),c.jsx("div",{className:"text-xs text-gray-500 mt-1",children:"登录页面显示默认账号密码提示"})]}),c.jsx("button",{onClick:()=>t({...e,show_default_login_info:!e.show_default_login_info}),className:`w-14 h-8 rounded-full transition-all relative ${e.show_default_login_info?"bg-[#0094f7]":"bg-gray-300"}`,children:c.jsx("div",{className:`w-6 h-6 bg-white rounded-full absolute top-1 transition-all shadow-md ${e.show_default_login_info?"left-7":"left-1"}`})})]}),c.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[c.jsxs("div",{children:[c.jsx("div",{className:"font-bold text-gray-900",children:"登录滑动验证码"}),c.jsx("div",{className:"text-xs text-gray-500 mt-1",children:"开启后账号密码登录需要完成滑动验证"})]}),c.jsx("button",{onClick:()=>t({...e,login_captcha_enabled:!e.login_captcha_enabled}),className:`w-14 h-8 rounded-full transition-all relative ${e.login_captcha_enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:c.jsx("div",{className:`w-6 h-6 bg-white rounded-full absolute top-1 transition-all shadow-md ${e.login_captcha_enabled?"left-7":"left-1"}`})})]}),c.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[c.jsxs("div",{children:[c.jsx("div",{className:"font-bold text-gray-900",children:"启用商品自动同步"}),c.jsx("div",{className:"text-xs text-gray-500 mt-1",children:"定时自动获取商品信息到本地数据库"})]}),c.jsx("button",{onClick:()=>t({...e,item_sync_enabled:!e.item_sync_enabled}),className:`w-14 h-8 rounded-full transition-all relative ${e.item_sync_enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:c.jsx("div",{className:`w-6 h-6 bg-white rounded-full absolute top-1 transition-all shadow-md ${e.item_sync_enabled?"left-7":"left-1"}`})})]}),c.jsxs("div",{className:"space-y-3 px-4",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"商品同步间隔(分钟)"}),c.jsx("input",{type:"number",value:Math.round((e.item_sync_interval||600)/60),onChange:z=>{const G=parseInt(z.target.value)||10;t({...e,item_sync_interval:G*60})},className:"w-full ios-input px-4 py-3 rounded-xl",min:"1",max:"1440"}),c.jsx("p",{className:"text-xs text-gray-500",children:"建议:10-60分钟"})]}),c.jsxs("div",{className:"space-y-3 px-4",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"每次最多同步页数"}),c.jsx("input",{type:"number",value:e.item_sync_max_pages||5,onChange:z=>t({...e,item_sync_max_pages:parseInt(z.target.value)||5}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"1",max:"50"}),c.jsx("p",{className:"text-xs text-gray-500",children:"每页20个商品"})]})]})]}),c.jsxs("section",{className:"space-y-4",children:[c.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[c.jsx("div",{className:"p-1.5 rounded-lg bg-[#0094f7] text-white",children:c.jsx(vA,{className:"w-4 h-4"})}),"AI 智能回复配置"]}),c.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-6",children:[c.jsxs("div",{className:"space-y-3",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"API 地址"}),c.jsx("input",{type:"text",value:e.ai_api_url||eA,onChange:z=>t({...e,ai_api_url:z.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"https://api.openai.com/v1"}),c.jsx("p",{className:"text-xs text-gray-500",children:"无需补全 /chat/completions"})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"API Key"}),c.jsxs("div",{className:"relative",children:[c.jsx("input",{type:_?"text":"password",value:e.ai_api_key||"",onChange:z=>t({...e,ai_api_key:z.target.value}),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl font-mono text-sm",placeholder:"sk-..."}),c.jsx("button",{type:"button",onClick:()=>S(!_),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:_?c.jsx(ic,{className:"w-4 h-4"}):c.jsx(xs,{className:"w-4 h-4"})})]})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"模型"}),c.jsxs("div",{ref:j,className:"relative flex flex-col sm:flex-row gap-2",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsx("input",{value:ce,onFocus:()=>d.length>0&&w(!0),onChange:z=>{t({...e,ai_model:z.target.value}),d.length>0&&w(!0)},onKeyDown:z=>{z.key==="Escape"&&w(!1),z.key==="ArrowDown"&&d.length>0&&w(!0)},className:"w-full ios-input px-4 py-3 pr-10 rounded-xl",placeholder:"从接口读取或手动输入模型名"}),c.jsx("button",{type:"button",onClick:()=>d.length>0&&w(z=>!z),disabled:d.length===0,className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 disabled:opacity-30","aria-label":"展开模型列表",children:c.jsx(GT,{className:`w-4 h-4 transition-transform ${b?"rotate-180":""}`})}),b&&c.jsx("div",{className:"absolute left-0 right-0 top-[calc(100%+6px)] z-40 max-h-64 overflow-y-auto rounded-xl border border-gray-200 bg-white shadow-xl shadow-gray-200/70 py-1",children:R.length>0?R.map(z=>c.jsxs("button",{type:"button",onClick:()=>{t({...e,ai_model:z}),w(!1)},className:"w-full px-4 py-2.5 text-left text-sm text-gray-700 hover:bg-blue-50 hover:text-[#0094f7] flex items-center justify-between gap-3",children:[c.jsx("span",{className:"truncate",children:z}),z===ce&&c.jsx(ci,{className:"w-4 h-4 shrink-0 text-[#0094f7]"})]},z)):c.jsx("div",{className:"px-4 py-3 text-sm text-gray-400",children:"没有匹配的模型"})})]}),c.jsxs("button",{type:"button",onClick:()=>re(void 0,!0),disabled:m,className:"px-4 py-3 rounded-xl bg-gray-100 text-gray-700 hover:bg-gray-200 disabled:opacity-60 font-bold flex items-center justify-center gap-2 whitespace-nowrap",children:[c.jsx(pr,{className:`w-4 h-4 ${m?"animate-spin":""}`}),"读取模型"]})]}),v?c.jsx("p",{className:"text-xs text-red-500",children:v}):c.jsx("p",{className:"text-xs text-gray-500",children:d.length>0?`已从当前 API 地址读取到 ${d.length} 个模型`:"模型列表从当前 API 地址读取,也可以手动输入模型名"})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"默认自动回复内容"}),c.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl min-h-[100px] text-sm resize-none",value:e.default_reply||"",onChange:z=>t({...e,default_reply:z.target.value}),placeholder:"设置默认的自动回复内容..."})]}),c.jsxs("div",{className:"p-3 bg-blue-50 rounded-xl text-xs text-blue-700",children:[c.jsx("strong",{children:"常见 AI 服务:"}),c.jsxs("ul",{className:"list-disc list-inside mt-1 space-y-0.5",children:[c.jsx("li",{children:"阿里云通义千问: https://dashscope.aliyuncs.com/compatible-mode/v1"}),c.jsx("li",{children:"OpenAI: https://api.openai.com/v1"})]})]})]})]})]}),c.jsx("div",{className:"space-y-8",children:c.jsxs("section",{className:"space-y-4",children:[c.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[c.jsx("div",{className:"p-1.5 rounded-lg bg-gray-900 text-white",children:c.jsx(pj,{className:"w-4 h-4"})}),"登录凭据"]}),c.jsxs("form",{onSubmit:fe,className:"ios-card rounded-xl p-6 bg-white space-y-5",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"登录用户名"}),c.jsxs("div",{className:"relative",children:[c.jsx(uD,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),c.jsx("input",{type:"text",value:K.new_username,onChange:z=>T({...K,new_username:z.target.value}),className:"w-full ios-input pl-11 pr-4 py-3 rounded-xl text-sm",autoComplete:"username"})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"当前密码"}),c.jsxs("div",{className:"relative",children:[c.jsx("input",{type:A?"text":"password",value:K.current_password,onChange:z=>T({...K,current_password:z.target.value}),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm",placeholder:"用于确认当前身份",autoComplete:"current-password"}),c.jsx("button",{type:"button",onClick:()=>C(!A),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:A?"隐藏密码":"显示密码",children:A?c.jsx(ic,{className:"w-4 h-4"}):c.jsx(xs,{className:"w-4 h-4"})})]})]}),c.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"新密码"}),c.jsxs("div",{className:"relative",children:[c.jsx("input",{type:M?"text":"password",value:K.new_password,onChange:z=>T({...K,new_password:z.target.value}),className:"w-full ios-input px-4 py-3 pr-11 rounded-xl text-sm",placeholder:"不修改则留空",autoComplete:"new-password"}),c.jsx("button",{type:"button",onClick:()=>k(!M),className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:M?"隐藏密码":"显示密码",children:M?c.jsx(ic,{className:"w-4 h-4"}):c.jsx(xs,{className:"w-4 h-4"})})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"确认新密码"}),c.jsx("input",{type:M?"text":"password",value:K.confirm_password,onChange:z=>T({...K,confirm_password:z.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"再次输入新密码",autoComplete:"new-password"})]})]}),$&&c.jsxs("div",{className:`flex items-start gap-2 rounded-xl px-3 py-2.5 text-sm font-medium ${$.type==="success"?"bg-green-50 text-green-700":"bg-red-50 text-red-700"}`,children:[c.jsx(hA,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),c.jsx("span",{children:$.text})]}),c.jsxs("button",{type:"submit",disabled:D||!K.new_username||!K.current_password,className:"w-full bg-gray-900 hover:bg-black text-white px-5 py-3 rounded-xl font-bold text-sm flex items-center justify-center gap-2 transition-colors disabled:opacity-40",children:[c.jsx(pj,{className:"w-4 h-4"}),D?"正在更新...":"更新登录凭据"]})]})]})})]}),c.jsx("div",{className:"fixed bottom-10 right-10 z-30",children:c.jsxs("button",{onClick:pe,disabled:l,className:"ios-btn-primary px-10 py-5 rounded-xl text-lg shadow-2xl shadow-blue-200 flex items-center gap-3 transform hover:scale-105 active:scale-95 transition-all disabled:opacity-70",children:[c.jsx(Sa,{className:"w-6 h-6"}),l?"保存中...":"保存所有配置"]})})]})},Vi={order_paid:{label:"付款后自动发货",shortLabel:"自动发货",description:"闲鱼付款系统卡片进入自动化中心后,先发送卡密,成功后再确认发货。",flow:["付款系统卡片","匹配商品/规格","发送卡密","确认发货"],accent:"blue",icon:uc},buyer_reviewed:{label:"评价后发送赠品",shortLabel:"评价赠品",description:"闲鱼评价系统卡片进入自动化中心后,给买家发送赠品卡密。",flow:["评价系统卡片","匹配商品/规格","发送赠品"],accent:"emerald",icon:xM},review_missing_timeout:{label:"超时未评价求评价",shortLabel:"求评价",description:"计划任务扫描已发货未评价订单,到期后发送求评价文案。",flow:["计划任务扫描","已发货未评价","达到等待时间","发送提醒"],accent:"amber",icon:cA}},$v=["order_paid","buyer_reviewed","review_missing_timeout"],RQ="亲,商品使用满意的话,麻烦给个评价,谢谢~",Qo=()=>({spec_name:"",spec_value:"",card_id:0,delivery_count:1,enabled:!0}),a5=e=>{if(!e)return{};try{const t=JSON.parse(e);return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}},fs=(e,t={})=>{const n=a5(e);return JSON.stringify({after_shipped_hours:Number(n.after_shipped_hours||72),max_attempts:Number(n.max_attempts||1),...t})},Jo=(e,t)=>{var r;const n=((r=Vi[e])==null?void 0:r.label)||"自动化规则";return t?`${n} - ${t}`:n},tA=e=>{const t=(e||"").trim();return t?Object.values(Vi).some(n=>t===n.label||t.startsWith(`${n.label} -`)):!0},ec=(e,t=0)=>{if(e==="review_missing_timeout")return[{action_type:"send_text",message_template:RQ,enabled:!0,sort_order:1}];const n={action_type:"send_card",card_id:t,delivery_count:1,enabled:!0,sort_order:1};return e==="order_paid"?[n,{action_type:"confirm_shipment",enabled:!0,sort_order:2}]:[n]},LQ=e=>{var n,r;if(e.trigger_type==="review_missing_timeout")return((r=(n=e.actions)==null?void 0:n.find(l=>l.action_type==="send_text"))==null?void 0:r.message_template)||"发送求评价文案";const t=(e.actions||[]).filter(l=>l.action_type==="send_card");return t.length?t.map(l=>l.card_name||`卡密 ${l.card_id}`).join(" / "):"未配置卡密库存"},nA=(e,t=!1)=>{const n={blue:t?"border-blue-500 bg-blue-50 text-blue-700":"border-blue-100 bg-blue-50/60 text-blue-700 hover:border-blue-300",emerald:t?"border-emerald-500 bg-emerald-50 text-emerald-700":"border-emerald-100 bg-emerald-50/60 text-emerald-700 hover:border-emerald-300",amber:t?"border-amber-500 bg-amber-50 text-amber-700":"border-amber-100 bg-amber-50/60 text-amber-700 hover:border-amber-300"};return n[e]||n.blue},BQ=e=>e?"bg-emerald-100 text-emerald-700":"bg-gray-200 text-gray-500",kd=e=>(e==null?void 0:e.nickname)||(e==null?void 0:e.remark)||(e==null?void 0:e.id)||"未知账号",UQ=e=>e===!0||e===1||e==="1",HQ=({initialDeliveryTarget:e,onDeliveryTargetHandled:t})=>{var $n,wi,xl;const[n,r]=x.useState("automation"),[l,s]=x.useState([]),[d,f]=x.useState([]),[m,h]=x.useState({}),[v,y]=x.useState([]),[b,w]=x.useState([]),[j,_]=x.useState([]),[S,A]=x.useState(!1),[C,M]=x.useState(""),[k,D]=x.useState(!1),[E,$]=x.useState(!1),[U,K]=x.useState(!1),[T,re]=x.useState(null),[Z,pe]=x.useState(null),[fe,ce]=x.useState({cookie_id:"",enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""});v.find(q=>q.id===C);const R=x.useCallback(async()=>{const[q,ve,we,$e]=await Promise.all([Fy(),va(),Ns(),Nj()]);y(q),w(ve),_(we),h($e),M(We=>{var Jt;return We||((Jt=q[0])==null?void 0:Jt.id)||""})},[]),z=x.useCallback(async()=>{s(await Rd())},[]),G=x.useCallback(async()=>{if(!C){f([]);return}f(await aP(C))},[C]),se=x.useCallback(async()=>{h(await Nj())},[]),ue=x.useCallback(async()=>{A(!0);try{n==="automation"?await z():n==="reply"?await G():await se()}finally{A(!1)}},[n,z,se,G]);x.useEffect(()=>{R()},[R]),x.useEffect(()=>{ue()},[ue]);const P=x.useMemo(()=>l.filter(q=>!C||q.cookie_id===C),[l,C]),Q=x.useMemo(()=>v.filter(q=>!C||q.id===C),[v,C]),ne=x.useMemo(()=>{var ve;const q={order_paid:[],buyer_reviewed:[],review_missing_timeout:[]};for(const we of P)(ve=q[we.trigger_type])==null||ve.push(we);return q},[P]),I=x.useMemo(()=>{const q=(T==null?void 0:T.cookie_id)||C;return j.filter(ve=>ve.cookie_id===q)},[T==null?void 0:T.cookie_id,j,C]),he=x.useMemo(()=>{if(!(!(T!=null&&T.cookie_id)||!(T!=null&&T.item_id)))return j.find(q=>q.cookie_id===T.cookie_id&&q.item_id===T.item_id)},[T==null?void 0:T.cookie_id,T==null?void 0:T.item_id,j]),be=UQ(he==null?void 0:he.is_multi_spec),_e=(T==null?void 0:T.trigger_type)||"order_paid",W=Vi[_e],V=a5(T==null?void 0:T.config_json),ye=x.useCallback((q="order_paid",ve=C,we="")=>{const $e=j.find(Jt=>Jt.cookie_id===ve&&Jt.item_id===we),We=($e==null?void 0:$e.item_title)||we;return{name:Jo(q,We),trigger_type:q,cookie_id:ve,item_id:we,item_title:($e==null?void 0:$e.item_title)||"",item_keyword:We,card_group_id:0,priority:100,enabled:!0,config_json:q==="review_missing_timeout"?fs():"{}",actions:ec(q),variants:q==="review_missing_timeout"?[]:[Qo()]}},[j,C]),xe=x.useCallback(q=>{var we,$e;const ve=q.trigger_type||"order_paid";re({...q,trigger_type:ve,config_json:ve==="review_missing_timeout"?fs(q.config_json):q.config_json||"{}",actions:(we=q.actions)!=null&&we.length?q.actions.map(We=>({...We})):ec(ve,q.card_group_id),variants:($e=q.variants)!=null&&$e.length?q.variants.map(We=>({...We})):ve==="review_missing_timeout"?[]:[Qo()]}),D(!0)},[]);x.useEffect(()=>{if(!e)return;let q=!1;return(async()=>{r("automation"),M(e.cookieId),A(!0);try{const[we,$e,We]=await Promise.all([Rd(),Ns(),va().catch(jt=>(console.warn("加载卡密库存失败,不阻断打开自动化规则",jt),[]))]);if(q)return;s(we),_($e),w(We);const Jt=we.find(jt=>jt.cookie_id===e.cookieId&&jt.item_id===e.itemId&&jt.trigger_type==="order_paid");if(Jt)xe(Jt);else{const jt=$e.find(Cr=>Cr.cookie_id===e.cookieId&&Cr.item_id===e.itemId);re({...ye("order_paid",e.cookieId,e.itemId),item_title:(jt==null?void 0:jt.item_title)||"",item_keyword:(jt==null?void 0:jt.item_title)||e.itemId,name:Jo("order_paid",(jt==null?void 0:jt.item_title)||e.itemId)}),D(!0)}}catch(we){console.error("打开商品自动化规则失败",we),alert("无法加载该商品的自动化规则")}finally{q||(A(!1),t==null||t())}})(),()=>{q=!0}},[ye,e,t,xe]);const ae=(q="order_paid")=>{if(!C){alert("请先选择账号");return}re(ye(q)),D(!0)},Le=q=>{var $e,We,Jt,jt,Cr;if(!T)return;const ve=((We=($e=T.variants)==null?void 0:$e.find(_t=>_t.card_id))==null?void 0:We.card_id)||((jt=(Jt=T.actions)==null?void 0:Jt.find(_t=>_t.action_type==="send_card"))==null?void 0:jt.card_id)||T.card_group_id||0,we=(he==null?void 0:he.item_title)||T.item_title||T.item_id||"";re({...T,trigger_type:q,name:tA(T.name)?Jo(q,we):T.name,card_group_id:ve,config_json:q==="review_missing_timeout"?fs(T.config_json):"{}",actions:ec(q,ve),variants:q==="review_missing_timeout"?[]:(Cr=T.variants)!=null&&Cr.length?T.variants:[{...Qo(),card_id:ve}]})},Ce=q=>{if(!T)return;const ve=j.find($e=>$e.cookie_id===(T.cookie_id||C)&&$e.item_id===q),we=(ve==null?void 0:ve.item_title)||q;re({...T,item_id:q,item_title:(ve==null?void 0:ve.item_title)||"",item_keyword:we,name:tA(T.name)?Jo(_e,we):T.name})},Y=($n=T==null?void 0:T.variants)!=null&&$n.length?T.variants:[Qo()],ge=(q,ve)=>{var $e;if(!T)return;const we=Y.map((We,Jt)=>Jt===q?{...We,...ve}:We);re({...T,variants:we,card_group_id:(($e=we[0])==null?void 0:$e.card_id)||0})},Pe=()=>{if(!T)return;const q=Y[Y.length-1];re({...T,variants:[...Y,{...Qo(),spec_name:be&&(q==null?void 0:q.spec_name)||"",spec_value:be&&(q==null?void 0:q.spec_value)||""}]})},Be=async()=>{var $e,We,Jt,jt,Cr;if(!T)return;const q=T.trigger_type||"order_paid";if(!T.cookie_id){alert("请选择账号");return}const ve=($e=T.variants)!=null&&$e.length?T.variants:[];if(q!=="review_missing_timeout"){if(!ve.length||ve.some(_t=>!_t.card_id)){alert(q==="buyer_reviewed"?"请选择评价赠品卡密库存":"请选择发货卡密库存");return}if(be&&ve.some(_t=>!_t.spec_name.trim()||!_t.spec_value.trim())){alert("多规格商品必须填写每一行的规格名称和规格值");return}}if(q==="review_missing_timeout"&&!(((Jt=(We=T.actions)==null?void 0:We.find(bl=>bl.action_type==="send_text"))==null?void 0:Jt.message_template)||"").trim()){alert("请填写求评价文案");return}const we=q==="review_missing_timeout"?[]:ve.map(_t=>({..._t,spec_name:be?_t.spec_name.trim():"",spec_value:be?_t.spec_value.trim():"",delivery_count:Math.max(1,Number(_t.delivery_count)||1),enabled:_t.enabled!==!1}));try{await jj({...T,trigger_type:q,name:(T.name||"").trim()||Jo(q,(he==null?void 0:he.item_title)||T.item_id||""),config_json:q==="review_missing_timeout"?fs(T.config_json):T.config_json||"{}",actions:(jt=T.actions)!=null&&jt.length?T.actions:ec(q,((Cr=we[0])==null?void 0:Cr.card_id)||T.card_group_id||0),variants:we}),D(!1),await Promise.all([z(),R()]),alert("保存成功")}catch(_t){console.error("保存自动化规则失败:",_t),alert("保存失败:"+_t.message)}},Ve=async q=>{if(confirm("确定删除该自动化规则吗?"))try{await rP(q),await z(),alert("删除成功")}catch(ve){alert("删除失败:"+ve.message)}},Dt=async q=>{try{await jj({...q,enabled:!q.enabled}),await z()}catch(ve){alert("操作失败:"+ve.message)}},ie=()=>{if(!C){alert("请先选择账号");return}pe({keyword:"",reply_content:"",match_type:"exact",enabled:!0}),$(!0)},De=async()=>{var q,ve;if(!(!Z||!C)){if(!((q=Z.keyword)!=null&&q.trim())||!((ve=Z.reply_content)!=null&&ve.trim())){alert("请填写关键词和回复内容");return}try{await iP({...Z,match_type:Z.match_type||"exact",enabled:!0},C),$(!1),await G(),alert("保存成功")}catch(we){alert("保存失败:"+we.message)}}},Ue=async q=>{if(!(!C||!confirm("确定删除该回复规则吗?")))try{await lP(q,C),await G(),alert("删除成功")}catch(ve){alert("删除失败:"+ve.message)}},B=async(q=C)=>{if(!q){alert("请先选择账号");return}try{const ve=await pP(q);ce({cookie_id:q,enabled:ve.enabled,reply_content:ve.reply_content,reply_once:ve.reply_once,reply_image_url:ve.reply_image_url||""})}catch{ce({cookie_id:q,enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""})}K(!0)},Te=async()=>{if(!fe.cookie_id){alert("请先选择账号");return}if(fe.enabled&&!fe.reply_content.trim()&&!fe.reply_image_url.trim()){alert("启用默认回复时,请填写回复内容或图片 URL");return}try{await vP(fe.cookie_id,{enabled:fe.enabled,reply_content:fe.reply_content,reply_once:fe.reply_once,reply_image_url:fe.reply_image_url}),K(!1),await se(),alert("保存成功")}catch(q){alert("保存失败:"+q.message)}},lt=async q=>{if(confirm("确定删除该账号默认回复吗?"))try{await yP(q),await se(),alert("删除成功")}catch(ve){alert("删除失败:"+ve.message)}},Zr=async q=>{if(confirm("确定清空该账号的默认回复记录吗?清空后可重新对所有会话使用“只回复一次”。"))try{await gP(q),alert("清空成功")}catch(ve){alert("清空失败:"+ve.message)}},Qn=n==="automation"?"新建自动化":n==="reply"?"新增关键词":"编辑默认回复";return c.jsxs("div",{className:"space-y-8 animate-fade-in",children:[c.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"自动化规则"}),c.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"系统通知卡片只进入自动化判断;买家消息进入关键词、默认或 AI 回复。"})]}),c.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[c.jsxs("select",{value:C,onChange:q=>M(q.target.value),className:"ios-input px-4 py-3 rounded-2xl text-sm min-w-64",children:[c.jsx("option",{value:"",children:"全部账号"}),v.map(q=>c.jsx("option",{value:q.id,children:kd(q)},q.id))]}),c.jsxs("button",{onClick:ue,className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 hover:bg-gray-200 text-gray-700 flex items-center justify-center gap-2 transition-colors",children:[c.jsx(pr,{className:`w-4 h-4 ${S?"animate-spin":""}`}),"刷新"]}),c.jsxs("button",{onClick:n==="automation"?()=>ae("order_paid"):n==="reply"?ie:()=>void B(),disabled:!C,className:"ios-btn-primary px-5 py-3 rounded-2xl text-sm font-extrabold flex items-center justify-center gap-2 disabled:opacity-50",children:[c.jsx(ja,{className:"w-4 h-4"}),Qn]})]})]}),c.jsx("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[{id:"automation",label:"交易自动化",icon:Uv},{id:"reply",label:"关键词回复",icon:Cd},{id:"default",label:"账号默认回复",icon:ps}].map(q=>{const ve=q.icon;return c.jsxs("button",{onClick:()=>r(q.id),className:`inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${n===q.id?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:[c.jsx(ve,{className:"w-4 h-4"}),q.label]},q.id)})}),n==="automation"&&c.jsxs("div",{className:"grid grid-cols-1 2xl:grid-cols-[360px_1fr] gap-6",children:[c.jsxs("aside",{className:"space-y-4",children:[c.jsxs("div",{className:"bg-white rounded-xl p-5 border border-gray-100 shadow-sm",children:[c.jsx("h3",{className:"font-black text-gray-900 mb-1",children:"新建规则"}),c.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"先选自动化类型,再配置对应动作。"}),c.jsx("div",{className:"space-y-3",children:$v.map(q=>{const ve=Vi[q],we=ve.icon;return c.jsx("button",{type:"button",onClick:()=>ae(q),className:`w-full text-left rounded-2xl border p-4 transition-colors ${nA(ve.accent)}`,children:c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/80 flex items-center justify-center shrink-0",children:c.jsx(we,{className:"w-5 h-5"})}),c.jsxs("div",{children:[c.jsx("div",{className:"font-extrabold",children:ve.label}),c.jsx("div",{className:"text-xs opacity-75 mt-1 leading-5",children:ve.description})]})]})},q)})})]}),c.jsxs("div",{className:"bg-white rounded-xl p-5 border border-gray-100 shadow-sm",children:[c.jsx("h3",{className:"font-black text-gray-900 mb-4",children:"规则概览"}),c.jsx("div",{className:"space-y-3",children:$v.map(q=>{const ve=Vi[q],we=ve.icon;return c.jsxs("div",{className:"flex items-center justify-between rounded-2xl bg-gray-50 p-3",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(we,{className:"w-4 h-4 text-gray-500"}),c.jsx("span",{className:"text-sm font-bold text-gray-700",children:ve.shortLabel})]}),c.jsx("span",{className:"text-sm font-black text-gray-900",children:ne[q].length})]},q)})})]})]}),c.jsx("section",{className:"space-y-4",children:P.length===0?c.jsxs("div",{className:"bg-white rounded-xl border border-dashed border-gray-200 p-16 text-center",children:[c.jsx(Uv,{className:"w-12 h-12 text-gray-300 mx-auto mb-4"}),c.jsx("h3",{className:"text-xl font-black text-gray-900",children:"还没有自动化规则"}),c.jsx("p",{className:"text-gray-500 mt-2",children:"从左侧选择一个模板开始配置。"})]}):P.map(q=>{const ve=Vi[q.trigger_type],we=ve.icon;return c.jsx("article",{className:"bg-white rounded-xl border border-gray-100 p-5 shadow-sm hover:shadow-lg transition-all",children:c.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-4",children:[c.jsxs("div",{className:"flex items-start gap-4 min-w-0",children:[c.jsx("div",{className:`w-12 h-12 rounded-2xl flex items-center justify-center shrink-0 ${nA(ve.accent,!0)}`,children:c.jsx(we,{className:"w-5 h-5"})}),c.jsxs("div",{className:"min-w-0",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[c.jsx("h3",{className:"text-lg font-black text-gray-900 truncate",children:q.name}),c.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-bold ${BQ(q.enabled)}`,children:q.enabled?"已启用":"已禁用"})]}),c.jsxs("div",{className:"flex flex-wrap gap-2 text-xs font-bold",children:[c.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-gray-100 text-gray-600",children:ve.label}),c.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-gray-100 text-gray-600",children:q.item_title||q.item_id||"账号级规则"}),c.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-blue-50 text-blue-700",children:LQ(q)})]})]})]}),c.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[c.jsxs("button",{onClick:()=>xe(q),className:"px-4 py-2 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-700 text-sm font-bold flex items-center gap-2",children:[c.jsx(bs,{className:"w-4 h-4"}),"编辑"]}),c.jsx("button",{onClick:()=>Dt(q),className:`px-4 py-2 rounded-xl text-sm font-bold ${q.enabled?"bg-amber-50 text-amber-700 hover:bg-amber-100":"bg-emerald-50 text-emerald-700 hover:bg-emerald-100"}`,children:q.enabled?"禁用":"启用"}),c.jsx("button",{onClick:()=>Ve(q.id),className:"p-2.5 rounded-xl text-red-500 hover:bg-red-50",title:"删除",children:c.jsx(xa,{className:"w-4 h-4"})})]})]})},q.id)})})]}),n==="reply"&&c.jsxs("section",{className:"bg-white rounded-xl border border-gray-100 p-6 shadow-sm",children:[c.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-700 bg-blue-50 px-4 py-2 rounded-xl mb-5 w-fit",children:[c.jsx($d,{className:"w-4 h-4"}),"这里只处理买家用户消息;系统通知不会进入关键词或 AI 回复。"]}),c.jsxs("div",{className:"space-y-3",children:[d.map(q=>c.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border border-gray-100 bg-[#F7F8FA] hover:bg-white hover:shadow-lg transition-all gap-4",children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[c.jsx("span",{className:"px-3 py-1 bg-black text-white rounded-lg text-xs font-bold",children:q.match_type==="exact"?"精确匹配":"模糊包含"}),c.jsxs("h3",{className:"font-bold text-gray-900",children:["“",q.keyword,"”"]})]}),c.jsx("div",{className:"bg-white p-3 rounded-xl border border-gray-100 text-sm text-gray-600 leading-relaxed",children:q.reply_content})]}),c.jsxs("div",{className:"flex items-center gap-3 border-t md:border-t-0 md:border-l border-gray-200 pt-4 md:pt-0 md:pl-6",children:[c.jsx("button",{onClick:()=>{pe({...q}),$(!0)},className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:c.jsx(bs,{className:"w-4 h-4"})}),c.jsx("button",{onClick:()=>Ue(q.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:c.jsx(xa,{className:"w-5 h-5"})})]})]},q.id)),d.length===0&&c.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无关键词回复规则"})]})]}),n==="default"&&c.jsxs("section",{className:"bg-white rounded-xl border border-gray-100 p-6 shadow-sm",children:[c.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-700 bg-blue-50 px-4 py-2 rounded-xl mb-5 w-fit",children:[c.jsx($d,{className:"w-4 h-4"}),"默认回复只处理买家用户消息;关键词未命中且 AI 未接管时才会使用。"]}),c.jsxs("div",{className:"space-y-3",children:[Q.map(q=>{const ve=m[q.id],we=!!(ve!=null&&ve.enabled);return c.jsxs("div",{className:`flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border transition-all gap-4 ${we?"border-purple-100 bg-purple-50/50 hover:bg-white hover:shadow-lg":"border-gray-100 bg-[#F7F8FA] hover:bg-white hover:shadow-lg"}`,children:[c.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[c.jsx("div",{className:`w-12 h-12 rounded-2xl flex items-center justify-center ${we?"bg-purple-600 text-white":"bg-gray-200 text-gray-400"}`,children:c.jsx(ps,{className:"w-5 h-5"})}),c.jsxs("div",{className:"min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[c.jsx("h3",{className:"font-bold text-gray-900 text-lg truncate",children:kd(q)}),c.jsx("span",{className:`px-2 py-0.5 rounded-lg text-xs font-bold ${we?"bg-green-100 text-green-700":"bg-gray-200 text-gray-500"}`,children:we?"已启用":"未启用"}),(ve==null?void 0:ve.reply_once)&&c.jsx("span",{className:"px-2 py-0.5 rounded-lg text-xs font-bold bg-purple-100 text-purple-700",children:"只回复一次"})]}),c.jsx("div",{className:"text-sm text-gray-600 line-clamp-2",children:we?ve.reply_content||ve.reply_image_url||"已配置默认回复":"未配置默认回复"})]})]}),c.jsxs("div",{className:"flex items-center gap-3 border-t md:border-t-0 md:border-l border-gray-200 pt-4 md:pt-0 md:pl-6",children:[c.jsx("button",{onClick:()=>void B(q.id),className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:c.jsx(bs,{className:"w-4 h-4"})}),we&&c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:()=>void Zr(q.id),className:"px-3 py-2 text-xs font-bold text-blue-600 hover:bg-blue-50 rounded-xl transition-colors",children:"清空记录"}),c.jsx("button",{onClick:()=>void lt(q.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:c.jsx(xa,{className:"w-5 h-5"})})]})]})]},q.id)}),Q.length===0&&c.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无账号"})]})]}),k&&T&&It.createPortal(c.jsx("div",{className:"modal-overlay",children:c.jsxs("div",{className:"modal-container",style:{maxWidth:"72rem",maxHeight:"92vh"},children:[c.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-2xl font-black text-gray-900",children:T.id?"编辑自动化规则":"新建自动化规则"}),c.jsx("p",{className:"text-sm text-gray-500 mt-1",children:W.description})]}),c.jsx("button",{onClick:()=>D(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",title:"关闭",children:c.jsx(Xt,{className:"w-5 h-5 text-gray-600"})})]}),c.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[320px_1fr] min-h-0",children:[c.jsxs("aside",{className:"bg-slate-900 text-white p-5 overflow-y-auto",children:[c.jsx("div",{className:"text-xs font-bold text-slate-400 mb-3",children:"选择自动化类型"}),c.jsx("div",{className:"space-y-3",children:$v.map(q=>{const ve=Vi[q],we=ve.icon,$e=_e===q;return c.jsx("button",{type:"button",onClick:()=>Le(q),className:`w-full rounded-2xl p-4 text-left border transition-all ${$e?"bg-white text-slate-950 border-white":"bg-white/5 text-white border-white/10 hover:bg-white/10"}`,children:c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx(we,{className:`w-5 h-5 mt-0.5 ${$e?"text-[#0094f7]":"text-white"}`}),c.jsxs("div",{children:[c.jsx("div",{className:"font-black",children:ve.label}),c.jsx("div",{className:`text-xs mt-1 leading-5 ${$e?"text-gray-500":"text-gray-400"}`,children:ve.description})]})]})},q)})}),c.jsxs("div",{className:"mt-6 rounded-2xl bg-white/5 border border-white/10 p-4",children:[c.jsx("div",{className:"text-xs font-bold text-slate-400 mb-3",children:"执行流程"}),c.jsx("div",{className:"space-y-3",children:W.flow.map((q,ve)=>c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-6 h-6 rounded-full bg-white text-slate-950 text-xs font-black flex items-center justify-center",children:ve+1}),c.jsx("span",{className:"text-sm font-bold text-gray-100",children:q})]},q))})]})]}),c.jsx("div",{className:"p-6 overflow-y-auto bg-[#F7F8FA]",children:c.jsxs("div",{className:"space-y-5",children:[c.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[c.jsx(oA,{className:"w-5 h-5 text-[#0094f7]"}),c.jsx("h4",{className:"font-black text-gray-900",children:"生效范围"})]}),c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[c.jsxs("div",{className:"md:col-span-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"规则名称"}),c.jsx("input",{type:"text",value:T.name||"",onChange:q=>re({...T,name:q.target.value}),placeholder:"不填时按类型和商品自动生成",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"闲鱼账号"}),c.jsxs("select",{value:T.cookie_id||"",onChange:q=>re({...T,cookie_id:q.target.value,item_id:"",item_title:"",item_keyword:""}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[c.jsx("option",{value:"",children:"选择账号"}),v.map(q=>c.jsx("option",{value:q.id,children:kd(q)},q.id))]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关联商品"}),c.jsxs("select",{value:T.item_id||"",onChange:q=>Ce(q.target.value),className:"w-full ios-input px-4 py-3 rounded-xl",children:[c.jsx("option",{value:"",children:"账号级规则(不限定商品)"}),I.map(q=>c.jsx("option",{value:q.item_id,children:q.item_title||q.item_id},`${q.cookie_id}-${q.item_id}`))]})]})]}),he&&_e!=="review_missing_timeout"&&c.jsxs("div",{className:"mt-4 rounded-2xl bg-gray-50 border border-gray-100 p-4",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[c.jsx("span",{className:"px-3 py-1.5 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:he.item_title||he.item_id}),c.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${be?"bg-blue-50 text-blue-700":"bg-gray-100 text-gray-500"}`,children:be?"多规格商品":"普通商品"}),c.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs font-bold bg-emerald-50 text-emerald-700",children:"按订单购买数量自动发货"})]}),c.jsx("p",{className:"text-xs leading-5 text-gray-500",children:"多规格状态来自闲鱼商品本身,发布后不能在这里修改;系统会在买家付款后读取订单详情,按实际购买规格和数量匹配下面的发货规则。"})]})]}),_e!=="review_missing_timeout"?c.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[c.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(NM,{className:"w-5 h-5 text-[#0094f7]"}),c.jsx("h4",{className:"font-black text-gray-900",children:_e==="buyer_reviewed"?"赠品库存":"发货库存"})]}),c.jsx("p",{className:"text-sm text-gray-500 mt-1",children:be?"每条发货内容绑定一个订单规格;同一规格可添加多条内容并全部发送。":"可添加多条发货内容,买家付款后会按顺序全部发送。"})]}),c.jsxs("button",{type:"button",onClick:Pe,className:"px-3 py-2 rounded-xl bg-gray-900 text-white text-xs font-bold hover:bg-black flex items-center gap-1.5",children:[c.jsx(ja,{className:"w-3.5 h-3.5"}),"添加发货内容"]})]}),c.jsx("div",{className:"space-y-3",children:Y.map((q,ve)=>c.jsxs("div",{className:`grid grid-cols-1 gap-3 items-end rounded-2xl border border-gray-200 p-4 ${be?"md:grid-cols-[1fr_1fr_1.4fr_110px_40px]":"md:grid-cols-[1.4fr_110px_40px]"}`,children:[be&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"规格名称"}),c.jsx("input",{value:q.spec_name,onChange:we=>ge(ve,{spec_name:we.target.value}),className:"w-full ios-input px-3 py-2.5 rounded-lg",placeholder:"例如:套餐"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"规格值"}),c.jsx("input",{value:q.spec_value,onChange:we=>ge(ve,{spec_value:we.target.value}),className:"w-full ios-input px-3 py-2.5 rounded-lg",placeholder:"例如:30天"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"卡密库存"}),c.jsxs("select",{value:q.card_id||"",onChange:we=>ge(ve,{card_id:Number(we.target.value)}),className:"w-full ios-input px-3 py-2.5 rounded-lg",children:[c.jsx("option",{value:"",children:"请选择卡密库存"}),b.filter(we=>we.enabled).map(we=>c.jsx("option",{value:we.id,children:we.name},we.id))]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"每件份数"}),c.jsx("input",{type:"number",min:"1",max:"100",value:q.delivery_count,onChange:we=>ge(ve,{delivery_count:Math.max(1,Number(we.target.value)||1)}),className:"w-full ios-input px-3 py-2.5 rounded-lg"})]}),c.jsx("button",{type:"button",disabled:Y.length===1,onClick:()=>re({...T,variants:Y.filter((we,$e)=>$e!==ve)}),className:"w-10 h-10 flex items-center justify-center rounded-lg text-red-500 hover:bg-red-50 disabled:opacity-25",title:"删除发货内容",children:c.jsx(xa,{className:"w-4 h-4"})})]},q.id||ve))})]}):c.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[c.jsx(cA,{className:"w-5 h-5 text-amber-600"}),c.jsx("h4",{className:"font-black text-gray-900",children:"求评价计划"})]}),c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"发货后等待小时"}),c.jsx("input",{type:"number",min:"1",value:Number(V.after_shipped_hours||72),onChange:q=>re({...T,config_json:fs(T.config_json,{after_shipped_hours:Math.max(1,Number(q.target.value)||72)})}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最多求评次数"}),c.jsx("input",{type:"number",min:"1",value:Number(V.max_attempts||1),onChange:q=>re({...T,config_json:fs(T.config_json,{max_attempts:Math.max(1,Number(q.target.value)||1)})}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),c.jsxs("div",{className:"md:col-span-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"求评价文案"}),c.jsx("textarea",{value:((xl=(wi=T.actions)==null?void 0:wi.find(q=>q.action_type==="send_text"))==null?void 0:xl.message_template)||"",onChange:q=>{var ve;return re({...T,actions:((ve=T.actions)!=null&&ve.length?T.actions:ec("review_missing_timeout")).map(we=>we.action_type==="send_text"?{...we,message_template:q.target.value}:we)})},className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none"})]})]})]}),c.jsx("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-[180px_1fr] gap-4 items-end",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"优先级"}),c.jsx("input",{type:"number",value:T.priority||100,onChange:q=>re({...T,priority:Number(q.target.value)||100}),min:"1",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),c.jsxs("label",{className:"h-[48px] flex items-center gap-3 px-4 bg-gray-50 rounded-xl text-sm font-bold text-gray-800",children:[c.jsx("input",{type:"checkbox",checked:T.enabled!==!1,onChange:q=>re({...T,enabled:q.target.checked}),className:"w-4 h-4 rounded"}),"启用规则"]})]})})]})})]}),c.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 bg-white flex gap-3",children:[c.jsx("button",{onClick:()=>D(!1),className:"flex-1 px-6 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200",children:"取消"}),c.jsxs("button",{onClick:Be,className:"flex-1 ios-btn-primary px-6 py-3 rounded-2xl font-bold flex items-center justify-center gap-2",children:[c.jsx(Sa,{className:"w-4 h-4"}),"保存自动化规则"]})]})]})}),document.body),E&&Z&&It.createPortal(c.jsx("div",{className:"modal-overlay",children:c.jsxs("div",{className:"modal-container",children:[c.jsx("div",{className:"modal-header",children:c.jsxs("div",{className:"flex items-center justify-between w-full",children:[c.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:Z.id?"编辑回复规则":"新增回复规则"}),c.jsx("button",{onClick:()=>$(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:c.jsx(Xt,{className:"w-5 h-5 text-gray-600"})})]})}),c.jsxs("div",{className:"modal-body space-y-5",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关键词"}),c.jsx("input",{type:"text",value:Z.keyword||"",onChange:q=>pe({...Z,keyword:q.target.value}),placeholder:"买家发送的关键词",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复内容"}),c.jsx("textarea",{value:Z.reply_content||"",onChange:q=>pe({...Z,reply_content:q.target.value}),placeholder:"自动回复的内容",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"匹配类型"}),c.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[c.jsx("button",{type:"button",onClick:()=>pe({...Z,match_type:"exact"}),className:`p-3 rounded-xl font-bold transition-all ${Z.match_type!=="fuzzy"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600"}`,children:"精确匹配"}),c.jsx("button",{type:"button",onClick:()=>pe({...Z,match_type:"fuzzy"}),className:`p-3 rounded-xl font-bold transition-all ${Z.match_type==="fuzzy"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600"}`,children:"模糊包含"})]})]}),c.jsxs("div",{className:"flex gap-3 pt-4",children:[c.jsx("button",{onClick:()=>$(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),c.jsxs("button",{onClick:De,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[c.jsx(Yy,{className:"w-4 h-4"}),"保存规则"]})]})]})]})}),document.body),U&&It.createPortal(c.jsx("div",{className:"modal-overlay",children:c.jsxs("div",{className:"modal-container",children:[c.jsx("div",{className:"modal-header",children:c.jsxs("div",{className:"flex items-center justify-between w-full",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"账号默认回复"}),c.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"关键词和 AI 都未处理时,才会使用默认回复。"})]}),c.jsx("button",{onClick:()=>K(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",title:"关闭",children:c.jsx(Xt,{className:"w-5 h-5 text-gray-600"})})]})}),c.jsxs("div",{className:"modal-body space-y-5",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"闲鱼账号"}),c.jsxs("select",{value:fe.cookie_id,onChange:q=>ce({...fe,cookie_id:q.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[c.jsx("option",{value:"",children:"选择账号"}),v.map(q=>c.jsx("option",{value:q.id,children:kd(q)},q.id))]})]}),c.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[c.jsxs("div",{children:[c.jsx("div",{className:"font-bold text-gray-900",children:"启用默认回复"}),c.jsx("div",{className:"text-xs text-gray-500 mt-1",children:"启用后,未命中关键词时自动发送"})]}),c.jsx("button",{type:"button",onClick:()=>ce({...fe,enabled:!fe.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${fe.enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:c.jsx("span",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${fe.enabled?"translate-x-7":"translate-x-1"}`})})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复内容"}),c.jsx("textarea",{value:fe.reply_content,onChange:q=>ce({...fe,reply_content:q.target.value}),placeholder:"输入默认回复内容",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复图片 URL(可选)"}),c.jsx("input",{type:"text",value:fe.reply_image_url,onChange:q=>ce({...fe,reply_image_url:q.target.value}),placeholder:"https://example.com/image.jpg",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),c.jsxs("label",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl text-sm font-bold text-gray-800",children:[c.jsxs("span",{children:["只回复一次",c.jsx("span",{className:"block text-xs text-gray-500 font-medium mt-1",children:"同一会话只发送一次默认回复"})]}),c.jsx("input",{type:"checkbox",checked:fe.reply_once,onChange:q=>ce({...fe,reply_once:q.target.checked}),className:"w-4 h-4 rounded"})]}),c.jsxs("div",{className:"flex gap-3 pt-4",children:[c.jsx("button",{onClick:()=>K(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),c.jsxs("button",{onClick:Te,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[c.jsx(Sa,{className:"w-4 h-4"}),"保存默认回复"]})]})]})]})}),document.body)]})},ms={bark:{label:"Bark",icon:gs,fields:[{key:"server_url",label:"Bark 服务器",placeholder:"https://api.day.app",required:!0},{key:"device_key",label:"Device Key",placeholder:"你的 Bark 设备 Key",required:!0},{key:"title",label:"标题(可选)",placeholder:"闲鱼助手"},{key:"sound",label:"铃声(可选)",placeholder:"default"},{key:"group",label:"分组(可选)",placeholder:"xianyu"}],guide:{steps:["App Store 搜索并安装 Bark(免费)","打开 Bark App,首页会显示一条测试 URL,形如 https://api.day.app//这是测试推送内容","URL 路径里 那一段就是 Device Key,复制填入","服务器地址默认 https://api.day.app,自建服务端则填自建域名"],urlFormat:"https://api.day.app/<你的key>/测试内容",note:"不需要 secret,Device Key 本身就是唯一凭证。"}},dingtalk:{label:"钉钉机器人",icon:Cd,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://oapi.dingtalk.com/robot/send?access_token=...",required:!0},{key:"secret",label:"加签密钥",placeholder:"SEC...",help:"安全设置勾选「加签」后生成,SEC 开头"}],guide:{steps:["钉钉进入一个群(可建单人群)→ 右上角 群设置","机器人 → 添加机器人 → 选择「自定义机器人」","安全设置勾选「加签」","完成页同时展示 Webhook 地址和 SEC 开头的 Secret,两个都复制","Webhook URL 填上面,Secret 填加签密钥"],urlFormat:"https://oapi.dingtalk.com/robot/send?access_token=XXX",note:"加签密钥可选,但强烈建议启用,否则机器人可能被滥用。"}},feishu:{label:"飞书机器人",icon:Cd,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",required:!0},{key:"secret",label:"签名校验密钥",placeholder:"sec-...",help:"安全设置选「签名校验」后生成"}],guide:{steps:["飞书进入目标群 → 右上角 更多 → 设置","群机器人 → 添加机器人 → 自定义机器人","安全设置选择「签名校验」,复制生成的秘钥","完成会给 Webhook 地址,复制","Webhook URL 填上面,秘钥填签名校验密钥"],urlFormat:"https://open.feishu.cn/open-apis/bot/v2/hook/xxx",note:"签名密钥可选,建议启用。频率限制:单机器人 100 次/分钟。"}},wechat:{label:"企业微信机器人",icon:Cd,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=...",required:!0}],guide:{steps:["企业微信进入一个内部群 → 右上角 … → 群设置","找到「群机器人」(新版可能叫「消息推送」)","添加 → 选择自定义机器人","完成给 Webhook 地址(含 ?key=),复制填入"],urlFormat:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXX",note:"不需要 secret,URL 里的 key 就是唯一凭证,注意不要泄露。频率限制 20 条/分钟。"}},webhook:{label:"自定义 Webhook",icon:hD,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://your-server/notify",required:!0}],guide:{steps:["仅适用于自己有服务器的用户:在你自己的机器上起一个 HTTP 接口收 JSON","系统会 POST 这个 URL,Content-Type: application/json","请求体固定为右侧 JSON 格式,按需解析 message 字段"],urlFormat:'{"message":"告警正文","timestamp":"2026-07-05 12:00:00","source":"xianyu-auto-reply"}',note:"若用 Server酱 / PushPlus 等第三方推送服务,格式不兼容,需写中间脚本转发,或改用对应专用渠道。"}},telegram:{label:"Telegram",icon:Yy,fields:[{key:"bot_token",label:"Bot Token",placeholder:"123456:ABC-DEF...",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"-1001234567890 或你的用户 ID",required:!0}],guide:{steps:["在 Telegram 搜索 @BotFather,发送 /newbot,按提示创建机器人,拿到 Bot Token","把你的 Bot 拉进一个群,或私聊它发一条消息","浏览器访问 https://api.telegram.org/bot<你的Token>/getUpdates",'从返回 JSON 里找 "chat":{"id":xxx},xxx 就是 Chat ID(群是负数,私聊是正数)'],urlFormat:"Bot Token: 123456:ABC-DEF... Chat ID: -1001234567890",note:"群聊需先把 Bot 设为管理员才能发消息。"}},email:{label:"邮件",icon:dA,fields:[{key:"smtp_server",label:"SMTP 服务器",placeholder:"smtp.qq.com",required:!0},{key:"smtp_port",label:"SMTP 端口",placeholder:"587",type:"number",required:!0},{key:"smtp_user",label:"发件邮箱",placeholder:"you@qq.com",required:!0},{key:"smtp_password",label:"密码 / 授权码",type:"password",required:!0},{key:"from",label:"收件邮箱(可选)",placeholder:"留空则发给自己"}],guide:{steps:["QQ 邮箱:服务器 smtp.qq.com,端口 587,发件邮箱填你的 QQ 邮箱","QQ 邮箱密码栏填「授权码」不是 QQ 密码:QQ 邮箱设置 → 账号 → 开启 SMTP → 生成授权码","163 邮箱:smtp.163.com:587,同样使用授权码","Gmail:smtp.gmail.com:587,密码用「应用专用密码」"],note:"收件邮箱留空时,邮件会发到发件邮箱自己。"}}},qQ=()=>{const[e,t]=x.useState([]),[n,r]=x.useState(!0),[l,s]=x.useState(!1),[d,f]=x.useState(null),[m,h]=x.useState(!1),[v,y]=x.useState(""),[b,w]=x.useState(null),[j,_]=x.useState({}),[S,A]=x.useState(!1),[C,M]=x.useState(!1),[k,D]=x.useState({name:"",type:"bark",enabled:!0,config:{}}),E=async()=>{r(!0);try{const z=await jA();t(z.data||[])}catch(z){console.error("加载通知渠道失败",z)}finally{r(!1)}},$=async()=>{try{const z=await bA();_(z||{})}catch(z){console.error("加载 SMTP 配置失败",z)}},U=async()=>{A(!0);try{await wA({smtp_server:j.smtp_server||"",smtp_port:j.smtp_port||587,smtp_user:j.smtp_user||"",smtp_password:j.smtp_password||"",smtp_from:j.smtp_from||""}),K("success","SMTP 配置已保存")}catch(z){K("error",(z==null?void 0:z.message)||"保存失败")}finally{A(!1)}};x.useEffect(()=>{E(),$()},[]);const K=(z,G)=>{w({type:z,text:G}),window.setTimeout(()=>w(null),3e3)},T=()=>{f(null),D({name:"",type:"bark",enabled:!0,config:{}}),s(!0)},re=z=>{f(z),D({name:z.name,type:z.type,enabled:z.enabled,config:{...z.config||{}}}),s(!0)},Z=async()=>{const z=ms[k.type];for(const G of z.fields)if(G.required&&!String(k.config[G.key]||"").trim()){K("error",`请填写 ${G.label}`);return}if(!k.name.trim()){K("error","请填写渠道名称");return}h(!0);try{const G={name:k.name.trim(),type:k.type,config:k.config,enabled:k.enabled};d?await _j(d.id,G):await uP(G),s(!1),await E(),K("success",d?"已更新":"已创建")}catch(G){console.error("保存失败",G),K("error",(G==null?void 0:G.message)||"保存失败")}finally{h(!1)}},pe=async z=>{if(confirm(`确认删除渠道「${z.name}」吗?已绑定该渠道的账号会自动解绑。`))try{await dP(z.id),await E(),K("success","已删除")}catch(G){K("error",(G==null?void 0:G.message)||"删除失败")}},fe=async z=>{try{await _j(z.id,{name:z.name,type:z.type,config:z.config||{},enabled:!z.enabled}),t(G=>G.map(se=>se.id===z.id?{...se,enabled:!se.enabled}:se))}catch(G){K("error",(G==null?void 0:G.message)||"切换失败")}},ce=async z=>{y(z.id);try{await hP(z.id),K("success","测试通知已发送,请检查对应渠道")}catch(G){K("error",(G==null?void 0:G.message)||"发送失败")}finally{y("")}},R=ms[k.type];return c.jsxs("div",{className:"space-y-8 animate-fade-in",children:[c.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"通知设置"}),c.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"配置通知渠道,账号异常时主动推送告警"})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("button",{onClick:E,className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[c.jsx(pr,{className:"w-4 h-4"}),"刷新"]}),c.jsxs("button",{onClick:T,className:"ios-btn-primary px-5 py-2.5 rounded-xl font-bold flex items-center gap-2",children:[c.jsx(ja,{className:"w-4 h-4"}),"新建渠道"]})]})]}),c.jsx("div",{className:"ios-card rounded-xl p-5 bg-blue-50/50 border border-blue-100",children:c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx(gs,{className:"w-5 h-5 text-[#0094f7] mt-0.5 flex-shrink-0"}),c.jsxs("div",{className:"text-sm text-gray-700 leading-6",children:["配置通知渠道并在「账号管理 → 编辑」里绑定后,以下事件会主动推送到该账号绑定的渠道:",c.jsxs("ul",{className:"mt-2 space-y-1 text-gray-600",children:[c.jsxs("li",{children:["• ",c.jsx("strong",{children:"账号 session 失效"}),":系统正在尝试自动恢复(警告)"]}),c.jsxs("li",{children:["• ",c.jsx("strong",{children:"自动恢复失败"}),":账号已停止,需人工处理(严重)"]}),c.jsxs("li",{children:["• ",c.jsx("strong",{children:"触发风控验证"}),":可能需要扫码完成验证(警告)"]})]})]})]})}),n?c.jsx("div",{className:"flex justify-center py-20",children:c.jsx(Yn,{className:"w-8 h-8 text-[#0094f7] animate-spin"})}):e.length===0?c.jsxs("div",{className:"ios-card rounded-xl p-12 bg-white text-center",children:[c.jsx(gs,{className:"w-12 h-12 text-gray-300 mx-auto mb-4"}),c.jsx("p",{className:"text-gray-500 font-medium",children:"还没有配置任何通知渠道"}),c.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"点击右上角「新建渠道」开始配置"})]}):c.jsx("div",{className:"space-y-3",children:e.map(z=>{const G=ms[z.type]||ms.webhook,se=G.icon;return c.jsxs("div",{className:"ios-card rounded-xl p-5 bg-white flex items-center gap-4",children:[c.jsx("div",{className:"w-11 h-11 rounded-xl bg-gray-100 flex items-center justify-center flex-shrink-0",children:c.jsx(se,{className:"w-5 h-5 text-gray-600"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"font-bold text-gray-900 truncate",children:z.name}),c.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 text-gray-600 font-medium",children:G.label}),!z.enabled&&c.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 text-gray-400 font-medium",children:"已停用"})]}),c.jsx("div",{className:"text-xs text-gray-500 mt-1 truncate",children:G.fields.map(ue=>{var P;return(P=z.config)==null?void 0:P[ue.key]}).filter(Boolean).map((ue,P)=>c.jsx("span",{className:"mr-3",children:String(ue).length>40?String(ue).slice(0,40)+"…":String(ue)},P))})]}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c.jsx("button",{onClick:()=>fe(z),className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-colors ${z.enabled?"bg-green-50 text-green-700 hover:bg-green-100":"bg-gray-100 text-gray-500 hover:bg-gray-200"}`,children:z.enabled?"启用中":"已停用"}),c.jsxs("button",{onClick:()=>ce(z),disabled:v===z.id,className:"px-3 py-1.5 rounded-lg text-xs font-bold bg-blue-50 text-[#0094f7] hover:bg-blue-100 transition-colors flex items-center gap-1 disabled:opacity-50",children:[v===z.id?c.jsx(Yn,{className:"w-3 h-3 animate-spin"}):c.jsx(Yy,{className:"w-3 h-3"}),"测试"]}),c.jsx("button",{onClick:()=>re(z),className:"w-8 h-8 rounded-lg bg-gray-100 hover:bg-gray-200 flex items-center justify-center text-gray-600 transition-colors",title:"编辑",children:c.jsx(mA,{className:"w-4 h-4"})}),c.jsx("button",{onClick:()=>pe(z),className:"w-8 h-8 rounded-lg bg-red-50 hover:bg-red-100 flex items-center justify-center text-red-500 transition-colors",title:"删除",children:c.jsx(xa,{className:"w-4 h-4"})})]})]},z.id)})}),c.jsxs("section",{className:"ios-card rounded-xl p-6 bg-white space-y-5",children:[c.jsxs("div",{className:"flex items-start justify-between",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-lg font-extrabold text-gray-800",children:"SMTP 邮件配置"}),c.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"系统级邮件发送服务,用于注册验证码等邮件通知"})]}),c.jsx("div",{className:"p-2 rounded-xl bg-blue-50 text-blue-600",children:c.jsx(dA,{className:"w-5 h-5"})})]}),c.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"SMTP 服务器"}),c.jsx("input",{type:"text",value:j.smtp_server||"",onChange:z=>_({...j,smtp_server:z.target.value}),placeholder:"smtp.qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"SMTP 端口"}),c.jsx("input",{type:"number",value:j.smtp_port||587,onChange:z=>_({...j,smtp_port:parseInt(z.target.value)||587}),placeholder:"587",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件邮箱"}),c.jsx("input",{type:"email",value:j.smtp_user||"",onChange:z=>_({...j,smtp_user:z.target.value}),placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"邮箱密码 / 授权码"}),c.jsxs("div",{className:"relative",children:[c.jsx("input",{type:C?"text":"password",value:j.smtp_password||"",onChange:z=>_({...j,smtp_password:z.target.value}),placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),c.jsx("button",{type:"button",onClick:()=>M(!C),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:C?c.jsx(ic,{className:"w-4 h-4"}):c.jsx(xs,{className:"w-4 h-4"})})]}),c.jsx("p",{className:"text-xs text-gray-500",children:"QQ 邮箱需使用授权码(QQ 邮箱设置 → 账号 → 开启 SMTP → 生成授权码)"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件人显示名(可选)"}),c.jsx("input",{type:"text",value:j.smtp_from||"",onChange:z=>_({...j,smtp_from:z.target.value}),placeholder:"闲鱼自动回复系统",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),c.jsxs("button",{onClick:U,disabled:S,className:"ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[S?c.jsx(Yn,{className:"w-4 h-4 animate-spin"}):c.jsx(Sa,{className:"w-4 h-4"}),S?"保存中...":"保存 SMTP 配置"]})]}),l&&It.createPortal(c.jsx("div",{className:"modal-overlay",children:c.jsxs("div",{className:"modal-container",style:{maxWidth:"36rem"},children:[c.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[c.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:d?"编辑通知渠道":"新建通知渠道"}),c.jsx("button",{onClick:()=>s(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:c.jsx(Xt,{className:"w-5 h-5 text-gray-600"})})]}),c.jsxs("div",{className:"px-6 py-5 space-y-5 overflow-y-auto flex-1 min-h-0",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"渠道名称"}),c.jsx("input",{type:"text",value:k.name,onChange:z=>D({...k,name:z.target.value}),placeholder:"例如:我的 Bark",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"渠道类型"}),c.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-2",children:Object.keys(ms).map(z=>{const G=ms[z],se=G.icon,ue=k.type===z;return c.jsxs("button",{type:"button",onClick:()=>D({...k,type:z,config:{}}),className:`p-3 rounded-xl border-2 flex flex-col items-center gap-1.5 transition-all ${ue?"border-[#0094f7] bg-blue-50":"border-gray-100 hover:border-gray-300"}`,children:[c.jsx(se,{className:`w-5 h-5 ${ue?"text-[#0094f7]":"text-gray-500"}`}),c.jsx("span",{className:`text-xs font-bold ${ue?"text-[#0094f7]":"text-gray-600"}`,children:G.label})]},z)})})]}),c.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-200 p-4 space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(gs,{className:"w-4 h-4 text-amber-600"}),c.jsxs("span",{className:"text-sm font-bold text-amber-800",children:["如何获取 ",R.label," 配置?"]})]}),c.jsx("ol",{className:"space-y-1.5 text-xs text-amber-900/90 leading-5 list-decimal pl-5",children:R.guide.steps.map((z,G)=>c.jsx("li",{children:z},G))}),R.guide.urlFormat&&c.jsxs("div",{className:"text-xs text-amber-900/90",children:[c.jsx("span",{className:"font-bold",children:"格式示例:"}),c.jsx("code",{className:"mt-1 block bg-amber-100/70 px-2.5 py-1.5 rounded-lg break-all font-mono text-[11px]",children:R.guide.urlFormat})]}),R.guide.note&&c.jsxs("p",{className:"text-xs text-amber-800/80 leading-5 pt-1",children:["💡 ",R.guide.note]})]}),c.jsx("div",{className:"space-y-3",children:R.fields.map(z=>c.jsxs("div",{className:"space-y-2",children:[c.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:[z.label,z.required&&c.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),c.jsx("input",{type:z.type==="password"?"password":z.type==="number"?"number":"text",value:String(k.config[z.key]||""),onChange:G=>D({...k,config:{...k.config,[z.key]:G.target.value}}),placeholder:z.placeholder,className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),z.help&&c.jsx("p",{className:"text-xs text-gray-500",children:z.help})]},z.key))}),c.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[c.jsx("button",{type:"button",onClick:()=>D({...k,enabled:!k.enabled}),className:`relative w-11 h-6 rounded-full transition-colors ${k.enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:c.jsx("span",{className:`absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform ${k.enabled?"translate-x-5":""}`})}),c.jsx("span",{className:"text-sm font-bold text-gray-800",children:"启用此渠道"})]})]}),c.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[c.jsx("button",{onClick:()=>s(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"取消"}),c.jsxs("button",{onClick:Z,disabled:m,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[m?c.jsx(Yn,{className:"w-4 h-4 animate-spin"}):c.jsx(ci,{className:"w-4 h-4"}),m?"保存中...":"保存"]})]})]})}),document.body),b&&c.jsxs("div",{className:"fixed bottom-8 left-1/2 -translate-x-1/2 z-[10000] px-5 py-3 rounded-xl shadow-lg font-bold text-sm flex items-center gap-2 animate-fade-in",style:{background:b.type==="success"?"#10b981":"#ef4444",color:"white"},children:[b.type==="success"?c.jsx(ci,{className:"w-4 h-4"}):c.jsx(Xt,{className:"w-4 h-4"}),b.text]})]})},i5={"/app/dashboard":"dashboard","/app/accounts":"accounts","/app/orders":"orders","/app/cards":"cards","/app/items":"items","/app/rules":"rules","/app/notifications":"notifications","/app/settings":"settings"},KQ=Object.fromEntries(Object.entries(i5).map(([e,t])=>[t,e])),rA=()=>i5[window.location.pathname]||"dashboard",YQ=/Win/i.test(navigator.platform||navigator.userAgent),GQ=()=>{const[e,t]=x.useState(!1),[n,r]=x.useState(rA),[l,s]=x.useState(!0),[d,f]=x.useState(!1),[m,h]=x.useState(""),[v,y]=x.useState(""),[b,w]=x.useState(!1),[j,_]=x.useState(""),[S,A]=x.useState(),C=D=>{const E=KQ[D];E&&E!==window.location.pathname&&window.history.pushState({},"",E),r(D)};x.useEffect(()=>{const D=()=>r(rA());return window.addEventListener("popstate",D),()=>window.removeEventListener("popstate",D)},[]),x.useEffect(()=>{gA().then(E=>{if((E==null?void 0:E.initialized)===!1){f(!0),t(!1);return}f(!1),E!=null&&E.authenticated&&t(!0)}).catch(()=>t(!1)).finally(()=>s(!1));const D=()=>t(!1);return window.addEventListener("auth:logout",D),()=>window.removeEventListener("auth:logout",D)},[]);const M=async D=>{D.preventDefault(),w(!0),_("");try{const E=await xD({username:m,password:v});E.success?t(!0):_(E.message||"登录失败")}catch(E){const $=E instanceof Error?E.message:String(E);_($||"登录失败")}finally{w(!1)}};if(l)return c.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[#f5f5f7]",children:c.jsx(Yn,{className:"w-8 h-8 text-[#0094f7] animate-spin"})});if(d)return c.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-[#F4F5F7] p-4 relative overflow-hidden font-sans",children:[c.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[60%] h-[60%] bg-blue-200/40 rounded-full blur-[120px] animate-pulse"}),c.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[60%] h-[60%] bg-blue-200/30 rounded-full blur-[120px] animate-pulse",style:{animationDelay:"2s"}}),c.jsxs("div",{className:"bg-white/80 backdrop-blur-3xl p-8 md:p-12 rounded-xl shadow-[0_20px_60px_-15px_rgba(0,0,0,0.05)] w-full max-w-xl border border-white relative z-10 animate-fade-in",children:[c.jsxs("div",{className:"text-center mb-8",children:[c.jsx("div",{className:"w-24 h-24 bg-[#0094f7] squircle flex items-center justify-center mx-auto mb-6 transition-all duration-500 p-4",style:{filter:"drop-shadow(0 8px 20px rgba(0,148,247,0.3))"},children:c.jsx("img",{src:"/static/ydisks-logo.svg",alt:"Ydisks",className:"w-full h-full"})}),c.jsx("h2",{className:"text-3xl font-extrabold text-gray-900 mb-2 tracking-tight",children:"系统尚未初始化"}),c.jsx("p",{className:"text-gray-600 font-medium",children:"为避免默认口令风险,管理员必须通过服务器本机 CLI 初始化。"})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"p-4 rounded-2xl bg-gray-50 border border-gray-100",children:[c.jsx("div",{className:"text-sm font-bold text-gray-900 mb-2",children:"请在服务器上执行:"}),c.jsx("pre",{className:"text-xs bg-black text-white p-4 rounded-2xl overflow-x-auto",children:YQ?'.\\xianyu-server.exe -init-admin -db data\\xianyu_data.db -admin-password "请设置密码"':"./xianyu-server -init-admin -db data/xianyu_data.db -admin-password '请设置密码'"}),c.jsx("div",{className:"text-xs text-gray-500 mt-2",children:"完成后刷新页面即可进入登录。"})]}),c.jsxs("button",{type:"button",onClick:()=>window.location.reload(),className:"w-full ios-btn-primary h-14 rounded-2xl text-lg shadow-xl shadow-blue-200 mt-2 flex items-center justify-center gap-2 group",children:["我已初始化,刷新 ",c.jsx(Rv,{className:"w-5 h-5 group-hover:translate-x-1 transition-transform"})]})]}),c.jsx("div",{className:"mt-8 pt-6 border-t border-gray-100 text-center",children:c.jsx("span",{className:"text-xs text-gray-400 font-medium tracking-widest uppercase",children:"Secure Bootstrap"})})]})]});if(!e)return c.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-[#F4F5F7] p-4 relative overflow-hidden font-sans",children:[c.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[60%] h-[60%] bg-blue-200/40 rounded-full blur-[120px] animate-pulse"}),c.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[60%] h-[60%] bg-blue-200/30 rounded-full blur-[120px] animate-pulse",style:{animationDelay:"2s"}}),c.jsxs("div",{className:"bg-white/80 backdrop-blur-3xl p-8 md:p-12 rounded-xl shadow-[0_20px_60px_-15px_rgba(0,0,0,0.05)] w-full max-w-lg border border-white relative z-10 animate-fade-in",children:[c.jsxs("div",{className:"text-center mb-10",children:[c.jsx("div",{className:"w-24 h-24 bg-[#0094f7] squircle flex items-center justify-center mx-auto mb-6 transition-all duration-500 cursor-pointer group p-4",style:{filter:"drop-shadow(0 8px 20px rgba(0,148,247,0.3))"},children:c.jsx("img",{src:"/static/ydisks-logo.svg",alt:"Ydisks",className:"w-full h-full group-hover:scale-110 transition-transform"})}),c.jsx("h2",{className:"text-3xl font-extrabold text-gray-900 mb-2 tracking-tight",children:"欢迎回来"}),c.jsx("p",{className:"text-gray-500 font-medium",children:"Ydisks闲鱼助手 · 自动发货与管家系统"})]}),c.jsxs("form",{onSubmit:M,className:"space-y-5",children:[c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"relative group",children:[c.jsx(Bv,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 group-focus-within:text-black transition-colors"}),c.jsx("input",{type:"text",placeholder:"管理员账号",value:m,onChange:D=>h(D.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]}),c.jsxs("div",{className:"relative group",children:[c.jsx(PM,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 group-focus-within:text-black transition-colors"}),c.jsx("input",{type:"password",placeholder:"密码",value:v,onChange:D=>y(D.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]})]}),j&&c.jsxs("div",{className:"p-3 rounded-xl bg-red-50 text-red-500 text-sm text-center font-bold flex items-center justify-center gap-2",children:[c.jsx(hA,{className:"w-4 h-4"})," ",j]}),c.jsx("button",{type:"submit",disabled:b,className:"w-full ios-btn-primary h-14 rounded-2xl text-lg shadow-xl shadow-blue-200 mt-2 flex items-center justify-center gap-2 group disabled:opacity-70",children:b?c.jsx(Yn,{className:"w-5 h-5 animate-spin"}):c.jsxs(c.Fragment,{children:["立即登录 ",c.jsx(Rv,{className:"w-5 h-5 group-hover:translate-x-1 transition-transform"})]})})]}),c.jsx("div",{className:"mt-8 pt-6 border-t border-gray-100",children:c.jsx("div",{className:"mt-6 text-center",children:c.jsx("span",{className:"text-xs text-gray-400 font-medium tracking-widest uppercase",children:"Ydisks闲鱼助手 v1.0"})})})]})]});const k=()=>{switch(n){case"dashboard":return c.jsx(ZS,{});case"accounts":return c.jsx(MQ,{});case"orders":return c.jsx(DQ,{});case"cards":return c.jsx(PQ,{});case"items":return c.jsx(IQ,{onConfigureDelivery:D=>{A({cookieId:D.cookie_id,itemId:D.item_id,requestId:Date.now()}),C("rules")}});case"rules":return c.jsx(HQ,{initialDeliveryTarget:S,onDeliveryTargetHandled:()=>A(void 0)});case"notifications":return c.jsx(qQ,{});case"settings":return c.jsx($Q,{});default:return c.jsx(ZS,{})}};return c.jsxs("div",{className:"flex min-h-screen bg-[#F4F5F7] text-[#111]",children:[c.jsx(yD,{activeTab:n,onNavigate:C,onLogout:()=>{t(!1)}}),c.jsxs("main",{className:"flex-1 ml-64 p-8 md:p-12 overflow-y-auto h-screen relative scroll-smooth",children:[c.jsx("div",{className:"fixed top-0 right-0 w-[800px] h-[800px] bg-gradient-to-bl from-blue-50 to-transparent rounded-full blur-[120px] pointer-events-none -z-10 opacity-60"}),c.jsx("div",{className:"max-w-[1400px] mx-auto pb-10",children:k()})]})]})},l5=document.getElementById("root");if(!l5)throw new Error("Could not find root element to mount to");const VQ=DT.createRoot(l5);VQ.render(c.jsx(aA.StrictMode,{children:c.jsx(GQ,{})})); diff --git a/internal/webui/static/assets/index-CjhArDrm.css b/internal/webui/static/assets/index-DgV81f94.css similarity index 70% rename from internal/webui/static/assets/index-CjhArDrm.css rename to internal/webui/static/assets/index-DgV81f94.css index 600cf20..ed893d7 100644 --- a/internal/webui/static/assets/index-CjhArDrm.css +++ b/internal/webui/static/assets/index-DgV81f94.css @@ -1 +1 @@ -*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.pointer-events-none{pointer-events:none}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.-bottom-1{bottom:-.25rem}.-right-1{right:-.25rem}.-right-6{right:-1.5rem}.-top-6{top:-1.5rem}.bottom-10{bottom:2.5rem}.bottom-8{bottom:2rem}.bottom-\[-10\%\]{bottom:-10%}.left-0{left:0}.left-0\.5{left:.125rem}.left-1{left:.25rem}.left-1\.5{left:.375rem}.left-1\/2{left:50%}.left-4{left:1rem}.left-5{left:1.25rem}.left-7{left:1.75rem}.left-\[-10\%\]{left:-10%}.right-0{right:0}.right-10{right:2.5rem}.right-2{right:.5rem}.right-3{right:.75rem}.right-4{right:1rem}.right-\[-10\%\]{right:-10%}.top-0{top:0}.top-0\.5{top:.125rem}.top-1{top:.25rem}.top-1\.5{top:.375rem}.top-1\/2{top:50%}.top-2{top:.5rem}.top-4{top:1rem}.top-\[-10\%\]{top:-10%}.top-\[calc\(100\%\+6px\)\]{top:calc(100% + 6px)}.-z-10{z-index:-10}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-\[10000\]{z-index:10000}.col-span-2{grid-column:span 2 / span 2}.col-span-full{grid-column:1 / -1}.mx-auto{margin-left:auto;margin-right:auto}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-10{margin-bottom:2.5rem}.mb-12{margin-bottom:3rem}.mb-2{margin-bottom:.5rem}.mb-2\.5{margin-bottom:.625rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-5{margin-bottom:1.25rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-64{margin-left:16rem}.mr-2{margin-right:.5rem}.mr-3{margin-right:.75rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.mt-auto{margin-top:auto}.line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.contents{display:contents}.hidden{display:none}.aspect-square{aspect-ratio:1 / 1}.h-10{height:2.5rem}.h-11{height:2.75rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-2\.5{height:.625rem}.h-20{height:5rem}.h-24{height:6rem}.h-28{height:7rem}.h-3{height:.75rem}.h-3\.5{height:.875rem}.h-32{height:8rem}.h-4{height:1rem}.h-40{height:10rem}.h-48{height:12rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-64{height:16rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-80{height:20rem}.h-9{height:2.25rem}.h-\[280px\]{height:280px}.h-\[300px\]{height:300px}.h-\[350px\]{height:350px}.h-\[48px\]{height:48px}.h-\[60\%\]{height:60%}.h-\[800px\]{height:800px}.h-full{height:100%}.h-screen{height:100vh}.max-h-48{max-height:12rem}.max-h-64{max-height:16rem}.max-h-\[380px\]{max-height:380px}.max-h-\[400px\]{max-height:400px}.max-h-\[420px\]{max-height:420px}.min-h-0{min-height:0px}.min-h-\[100px\]{min-height:100px}.min-h-\[120px\]{min-height:120px}.min-h-\[150px\]{min-height:150px}.min-h-\[400px\]{min-height:400px}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-2\.5{width:.625rem}.w-20{width:5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-3\.5{width:.875rem}.w-32{width:8rem}.w-4{width:1rem}.w-48{width:12rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-8{width:2rem}.w-9{width:2.25rem}.w-\[10\%\]{width:10%}.w-\[12\%\]{width:12%}.w-\[18\%\]{width:18%}.w-\[22\%\]{width:22%}.w-\[60\%\]{width:60%}.w-\[800px\]{width:800px}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-64{min-width:16rem}.min-w-\[210px\]{min-width:210px}.min-w-\[260px\]{min-width:260px}.max-w-6xl{max-width:72rem}.max-w-\[1400px\]{max-width:1400px}.max-w-\[200px\]{max-width:200px}.max-w-\[210px\]{max-width:210px}.max-w-\[240px\]{max-width:240px}.max-w-\[260px\]{max-width:260px}.max-w-\[280px\]{max-width:280px}.max-w-\[340px\]{max-width:340px}.max-w-\[80px\]{max-width:80px}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.table-fixed{table-layout:fixed}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-0{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-5{--tw-translate-x: 1.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-6{--tw-translate-x: 1.5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-7{--tw-translate-x: 1.75rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-\[1\.02\]{--tw-scale-x: 1.02;--tw-scale-y: 1.02;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}@keyframes spin{to{transform:rotate(360deg)}}.cursor-pointer{cursor:pointer}.resize-none{resize:none}.resize-y{resize:vertical}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-5{gap:1.25rem}.gap-6{gap:1.5rem}.gap-8{gap:2rem}.space-y-0\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.125rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.125rem * var(--tw-space-y-reverse))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-gray-50>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(249 250 251 / var(--tw-divide-opacity, 1))}.self-end{align-self:flex-end}.self-center{align-self:center}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.scroll-smooth{scroll-behavior:smooth}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.rounded{border-radius:6px}.rounded-2xl,.rounded-3xl{border-radius:10px}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:7px}.rounded-md{border-radius:6px}.rounded-xl{border-radius:8px}.border{border-width:1px}.border-0{border-width:0px}.border-2{border-width:2px}.border-4{border-width:4px}.border-b{border-bottom-width:1px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-none{border-style:none}.border-\[\#0094f7\]{--tw-border-opacity: 1;border-color:rgb(0 148 247 / var(--tw-border-opacity, 1))}.border-amber-100{--tw-border-opacity: 1;border-color:rgb(254 243 199 / var(--tw-border-opacity, 1))}.border-amber-200{--tw-border-opacity: 1;border-color:rgb(253 230 138 / var(--tw-border-opacity, 1))}.border-amber-500{--tw-border-opacity: 1;border-color:rgb(245 158 11 / var(--tw-border-opacity, 1))}.border-blue-100{--tw-border-opacity: 1;border-color:rgb(219 234 254 / var(--tw-border-opacity, 1))}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(191 219 254 / var(--tw-border-opacity, 1))}.border-blue-500{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.border-blue-600{--tw-border-opacity: 1;border-color:rgb(37 99 235 / var(--tw-border-opacity, 1))}.border-emerald-100{--tw-border-opacity: 1;border-color:rgb(209 250 229 / var(--tw-border-opacity, 1))}.border-emerald-500{--tw-border-opacity: 1;border-color:rgb(16 185 129 / var(--tw-border-opacity, 1))}.border-gray-100{--tw-border-opacity: 1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.border-gray-50{--tw-border-opacity: 1;border-color:rgb(249 250 251 / var(--tw-border-opacity, 1))}.border-green-200{--tw-border-opacity: 1;border-color:rgb(187 247 208 / var(--tw-border-opacity, 1))}.border-purple-100{--tw-border-opacity: 1;border-color:rgb(243 232 255 / var(--tw-border-opacity, 1))}.border-red-100{--tw-border-opacity: 1;border-color:rgb(254 226 226 / var(--tw-border-opacity, 1))}.border-white{--tw-border-opacity: 1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1))}.border-white\/10{border-color:#ffffff1a}.bg-\[\#0094f7\]{--tw-bg-opacity: 1;background-color:rgb(0 148 247 / var(--tw-bg-opacity, 1))}.bg-\[\#F4F5F7\]{--tw-bg-opacity: 1;background-color:rgb(244 245 247 / var(--tw-bg-opacity, 1))}.bg-\[\#F7F8FA\]{--tw-bg-opacity: 1;background-color:rgb(247 248 250 / var(--tw-bg-opacity, 1))}.bg-\[\#FAFAFA\]{--tw-bg-opacity: 1;background-color:rgb(250 250 250 / var(--tw-bg-opacity, 1))}.bg-\[\#f5f5f7\]{--tw-bg-opacity: 1;background-color:rgb(245 245 247 / var(--tw-bg-opacity, 1))}.bg-amber-100{--tw-bg-opacity: 1;background-color:rgb(254 243 199 / var(--tw-bg-opacity, 1))}.bg-amber-100\/70{background-color:#fef3c7b3}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(255 251 235 / var(--tw-bg-opacity, 1))}.bg-amber-50\/60{background-color:#fffbeb99}.bg-amber-500{--tw-bg-opacity: 1;background-color:rgb(245 158 11 / var(--tw-bg-opacity, 1))}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.bg-black\/50{background-color:#00000080}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.bg-blue-100\/70{background-color:#dbeafeb3}.bg-blue-200\/30{background-color:#bfdbfe4d}.bg-blue-200\/40{background-color:#bfdbfe66}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(96 165 250 / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.bg-blue-50\/50{background-color:#eff6ff80}.bg-blue-50\/60{background-color:#eff6ff99}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity, 1))}.bg-emerald-100{--tw-bg-opacity: 1;background-color:rgb(209 250 229 / var(--tw-bg-opacity, 1))}.bg-emerald-50{--tw-bg-opacity: 1;background-color:rgb(236 253 245 / var(--tw-bg-opacity, 1))}.bg-emerald-50\/60{background-color:#ecfdf599}.bg-emerald-600{--tw-bg-opacity: 1;background-color:rgb(5 150 105 / var(--tw-bg-opacity, 1))}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.bg-gray-100\/50{background-color:#f3f4f680}.bg-gray-200{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.bg-gray-200\/50{background-color:#e5e7eb80}.bg-gray-300{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity, 1))}.bg-gray-400{--tw-bg-opacity: 1;background-color:rgb(156 163 175 / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.bg-gray-900{--tw-bg-opacity: 1;background-color:rgb(17 24 39 / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-orange-100{--tw-bg-opacity: 1;background-color:rgb(255 237 213 / var(--tw-bg-opacity, 1))}.bg-orange-500{--tw-bg-opacity: 1;background-color:rgb(249 115 22 / var(--tw-bg-opacity, 1))}.bg-pink-50{--tw-bg-opacity: 1;background-color:rgb(253 242 248 / var(--tw-bg-opacity, 1))}.bg-purple-100{--tw-bg-opacity: 1;background-color:rgb(243 232 255 / var(--tw-bg-opacity, 1))}.bg-purple-50{--tw-bg-opacity: 1;background-color:rgb(250 245 255 / var(--tw-bg-opacity, 1))}.bg-purple-50\/50{background-color:#faf5ff80}.bg-purple-500{--tw-bg-opacity: 1;background-color:rgb(168 85 247 / var(--tw-bg-opacity, 1))}.bg-purple-600{--tw-bg-opacity: 1;background-color:rgb(147 51 234 / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-slate-900{--tw-bg-opacity: 1;background-color:rgb(15 23 42 / var(--tw-bg-opacity, 1))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-white\/5{background-color:#ffffff0d}.bg-white\/80{background-color:#fffc}.bg-white\/90{background-color:#ffffffe6}.bg-white\/95{background-color:#fffffff2}.bg-opacity-10{--tw-bg-opacity: .1}.bg-gradient-to-bl{background-image:linear-gradient(to bottom left,var(--tw-gradient-stops))}.from-blue-50{--tw-gradient-from: #eff6ff var(--tw-gradient-from-position);--tw-gradient-to: rgb(239 246 255 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.to-transparent{--tw-gradient-to: transparent var(--tw-gradient-to-position)}.object-cover{-o-object-fit:cover;object-fit:cover}.p-0{padding:0}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-12{padding:3rem}.p-16{padding:4rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-20{padding:5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-5{padding:1.25rem}.p-6{padding:1.5rem}.p-8{padding:2rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-10{padding-left:2.5rem;padding-right:2.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-20{padding-top:5rem;padding-bottom:5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-3\.5{padding-top:.875rem;padding-bottom:.875rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-10{padding-bottom:2.5rem}.pb-24{padding-bottom:6rem}.pl-10{padding-left:2.5rem}.pl-11{padding-left:2.75rem}.pl-14{padding-left:3.5rem}.pl-2{padding-left:.5rem}.pl-4{padding-left:1rem}.pl-5{padding-left:1.25rem}.pr-10{padding-right:2.5rem}.pr-11{padding-right:2.75rem}.pr-12{padding-right:3rem}.pr-2{padding-right:.5rem}.pr-4{padding-right:1rem}.pr-6{padding-right:1.5rem}.pt-1{padding-top:.25rem}.pt-4{padding-top:1rem}.pt-5{padding-top:1.25rem}.pt-6{padding-top:1.5rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.font-sans{font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-black{font-weight:900}.font-bold{font-weight:700}.font-extrabold{font-weight:800}.font-medium{font-weight:500}.uppercase{text-transform:uppercase}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-6{line-height:1.5rem}.leading-relaxed{line-height:1.625}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.tracking-widest{letter-spacing:.1em}.text-\[\#0094f7\]{--tw-text-opacity: 1;color:rgb(0 148 247 / var(--tw-text-opacity, 1))}.text-\[\#111\]{--tw-text-opacity: 1;color:rgb(17 17 17 / var(--tw-text-opacity, 1))}.text-amber-600{--tw-text-opacity: 1;color:rgb(217 119 6 / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(180 83 9 / var(--tw-text-opacity, 1))}.text-amber-800{--tw-text-opacity: 1;color:rgb(146 64 14 / var(--tw-text-opacity, 1))}.text-amber-800\/80{color:#92400ecc}.text-amber-900\/90{color:#78350fe6}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.text-blue-500{--tw-text-opacity: 1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.text-blue-900{--tw-text-opacity: 1;color:rgb(30 58 138 / var(--tw-text-opacity, 1))}.text-blue-950{--tw-text-opacity: 1;color:rgb(23 37 84 / var(--tw-text-opacity, 1))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(5 150 105 / var(--tw-text-opacity, 1))}.text-emerald-700{--tw-text-opacity: 1;color:rgb(4 120 87 / var(--tw-text-opacity, 1))}.text-gray-100{--tw-text-opacity: 1;color:rgb(243 244 246 / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.text-gray-700{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.text-gray-900{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(21 128 61 / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.text-orange-700{--tw-text-opacity: 1;color:rgb(194 65 12 / var(--tw-text-opacity, 1))}.text-pink-600{--tw-text-opacity: 1;color:rgb(219 39 119 / var(--tw-text-opacity, 1))}.text-purple-500{--tw-text-opacity: 1;color:rgb(168 85 247 / var(--tw-text-opacity, 1))}.text-purple-600{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity, 1))}.text-purple-700{--tw-text-opacity: 1;color:rgb(126 34 206 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.text-slate-400{--tw-text-opacity: 1;color:rgb(148 163 184 / var(--tw-text-opacity, 1))}.text-slate-950{--tw-text-opacity: 1;color:rgb(2 6 23 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-white\/30{color:#ffffff4d}.opacity-0{opacity:0}.opacity-10{opacity:.1}.opacity-20{opacity:.2}.opacity-30{opacity:.3}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.shadow-2xl{--tw-shadow: 0 25px 50px -12px rgb(0 0 0 / .25);--tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[0_20px_60px_-15px_rgba\(0\,0\,0\,0\.05\)\]{--tw-shadow: 0 20px 60px -15px rgba(0,0,0,.05);--tw-shadow-colored: 0 20px 60px -15px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[4px_0_24px_rgba\(0\,0\,0\,0\.02\)\]{--tw-shadow: 4px 0 24px rgba(0,0,0,.02);--tw-shadow-colored: 4px 0 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-inner{--tw-shadow: inset 0 2px 4px 0 rgb(0 0 0 / .05);--tw-shadow-colored: inset 0 2px 4px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-blue-100{--tw-shadow-color: #dbeafe;--tw-shadow: var(--tw-shadow-colored)}.shadow-blue-200{--tw-shadow-color: #bfdbfe;--tw-shadow: var(--tw-shadow-colored)}.shadow-emerald-100{--tw-shadow-color: #d1fae5;--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200{--tw-shadow-color: #e5e7eb;--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200\/70{--tw-shadow-color: rgb(229 231 235 / .7);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.ring-4{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-white{--tw-ring-opacity: 1;--tw-ring-color: rgb(255 255 255 / var(--tw-ring-opacity, 1))}.blur-2xl{--tw-blur: blur(40px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.blur-\[120px\]{--tw-blur: blur(120px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.drop-shadow{--tw-drop-shadow: drop-shadow(0 1px 2px rgb(0 0 0 / .1)) drop-shadow(0 1px 1px rgb(0 0 0 / .06));filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur{--tw-backdrop-blur: blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-3xl{--tw-backdrop-blur: blur(64px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-md{--tw-backdrop-blur: blur(12px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-sm{--tw-backdrop-blur: blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}.duration-500{transition-duration:.5s}.squircle{-webkit-mask-image:url(/static/squircle.svg);mask-image:url(/static/squircle.svg);-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center;border-radius:0}*{box-sizing:border-box;margin:0;padding:0}html,body,#root{height:100%;width:100%}body{font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif;background-color:#f4f5f7;color:#fff;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ios-card{background:#fff;border-radius:8px;border:1px solid rgba(0,0,0,.02);box-shadow:0 8px 24px #0000000a;transition:transform .2s ease,box-shadow .2s ease}.ios-card:hover{box-shadow:0 12px 32px #0000000f}.ios-input{background:#f7f8fa;border:1px solid transparent;transition:all .3s cubic-bezier(.25,.8,.25,1);color:#111;font-weight:500}.ios-input:focus{background:#fff;border-color:#0094f7;box-shadow:0 0 0 4px #0094f74d;outline:none}.ios-input::-moz-placeholder{color:#9ca3af;font-weight:400}.ios-input::placeholder{color:#9ca3af;font-weight:400}.ios-btn-primary{background:#0094f7;color:#fff;font-weight:700;border:none;transition:all .2s cubic-bezier(.25,.8,.25,1);cursor:pointer}.ios-btn-primary:hover:not(:disabled){background:#0071e3;transform:translateY(-1px);box-shadow:0 8px 20px #0094f74d}.ios-btn-primary:active:not(:disabled){transform:translateY(1px);box-shadow:0 2px 8px #0094f733}.ios-btn-primary:disabled{background:#f0f0f0;color:#aaa;box-shadow:none;transform:none;cursor:not-allowed}.ios-btn-secondary{background:#f7f8fa;color:#fff;font-weight:600;border:1px solid transparent;transition:all .2s ease;cursor:pointer}.ios-btn-secondary:hover{background:#e5e7eb;border-color:#d1d5db}.ios-btn-danger{background:#fee2e2;color:#dc2626;font-weight:600;border:1px solid transparent;transition:all .2s ease;cursor:pointer}.ios-btn-danger:hover{background:#fecaca;border-color:#fca5a5}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:#0000001a;border-radius:10px}::-webkit-scrollbar-thumb:hover{background:#0003}@keyframes fadeIn{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}.animate-fade-in{animation:fadeIn .5s cubic-bezier(.16,1,.3,1) forwards}@keyframes slideUp{0%{opacity:0;transform:translateY(30px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}.animate-slide-up{animation:slideUp .3s cubic-bezier(.16,1,.3,1) forwards}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}@keyframes pulse{0%,to{opacity:1}50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}::-moz-selection{background:#0094f7;color:#fff}::selection{background:#0094f7;color:#fff}.text-brand{color:#0094f7}.bg-brand{background-color:#0094f7}.border-brand{border-color:#0094f7}.status-badge{display:inline-flex;align-items:center;padding:4px 12px;border-radius:9999px;font-size:12px;font-weight:600}.status-badge-success{background-color:#d1fae5;color:#065f46}.status-badge-warning{background-color:#fef3c7;color:#92400e}.status-badge-error{background-color:#fee2e2;color:#991b1b}.status-badge-info{background-color:#dbeafe;color:#1e40af}.loading-skeleton{background:linear-gradient(90deg,#f3f4f6,#e5e7eb,#f3f4f6);background-size:200% 100%;animation:loading 1.5s ease-in-out infinite}@keyframes loading{0%{background-position:200% 0}to{background-position:-200% 0}}.modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background-color:#0006;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);padding:1rem;overflow-y:auto}.modal-container{position:relative;width:100%;max-width:42rem;max-height:85vh;margin:auto;display:flex;flex-direction:column;background-color:#fff;border-radius:10px;box-shadow:0 25px 50px -12px #00000040;overflow:hidden}.modal-header{flex-shrink:0;padding:2rem 2rem 1.5rem;border-bottom:1px solid #F3F4F6;background-color:#fff;z-index:10}.modal-body{flex:1 1 auto;overflow-y:auto;overflow-x:hidden;padding:2rem}.modal-footer{flex-shrink:0;padding:1.5rem 2rem 2rem;border-top:1px solid #F3F4F6;background-color:#fff;z-index:10}.modal-container-lg{max-width:64rem}.modal-overlay-centered{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;justify-content:center;background-color:#0006;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);padding:1rem;overflow-y:auto}.modal-overlay-centered .modal-container{position:relative;width:100%;max-width:42rem;max-height:85vh;margin:auto 0;display:flex;flex-direction:column;background-color:#fff;border-radius:10px;box-shadow:0 25px 50px -12px #00000040;overflow:hidden}@media(max-width:768px){.ios-card{border-radius:6px}.ios-input{font-size:16px}.modal-container{max-width:calc(100% - 2rem);max-height:90vh;border-radius:8px}.modal-header,.modal-body,.modal-footer{padding-left:1.5rem;padding-right:1.5rem}}.hover\:translate-y-\[-4px\]:hover{--tw-translate-y: -4px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:scale-105:hover{--tw-scale-x: 1.05;--tw-scale-y: 1.05;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:border-\[\#0094f7\]:hover{--tw-border-opacity: 1;border-color:rgb(0 148 247 / var(--tw-border-opacity, 1))}.hover\:border-amber-300:hover{--tw-border-opacity: 1;border-color:rgb(252 211 77 / var(--tw-border-opacity, 1))}.hover\:border-blue-300:hover{--tw-border-opacity: 1;border-color:rgb(147 197 253 / var(--tw-border-opacity, 1))}.hover\:border-emerald-300:hover{--tw-border-opacity: 1;border-color:rgb(110 231 183 / var(--tw-border-opacity, 1))}.hover\:border-gray-300:hover{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.hover\:border-gray-400:hover{--tw-border-opacity: 1;border-color:rgb(156 163 175 / var(--tw-border-opacity, 1))}.hover\:bg-\[\#0071e3\]:hover{--tw-bg-opacity: 1;background-color:rgb(0 113 227 / var(--tw-bg-opacity, 1))}.hover\:bg-\[\#0094f7\]:hover{--tw-bg-opacity: 1;background-color:rgb(0 148 247 / var(--tw-bg-opacity, 1))}.hover\:bg-\[\#FFFDE7\]\/50:hover{background-color:#fffde780}.hover\:bg-amber-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 243 199 / var(--tw-bg-opacity, 1))}.hover\:bg-black:hover{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-100:hover{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-50:hover{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-700:hover{--tw-bg-opacity: 1;background-color:rgb(29 78 216 / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-100:hover{--tw-bg-opacity: 1;background-color:rgb(209 250 229 / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50:hover{--tw-bg-opacity: 1;background-color:rgb(236 253 245 / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50\/50:hover{background-color:#ecfdf580}.hover\:bg-emerald-700:hover{--tw-bg-opacity: 1;background-color:rgb(4 120 87 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-200:hover{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-300:hover{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-800:hover{--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.hover\:bg-green-100:hover{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.hover\:bg-green-50:hover{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.hover\:bg-purple-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 232 255 / var(--tw-bg-opacity, 1))}.hover\:bg-red-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.hover\:bg-red-50:hover{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.hover\:bg-white:hover{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.hover\:bg-white\/10:hover{background-color:#ffffff1a}.hover\:text-\[\#0094f7\]:hover{--tw-text-opacity: 1;color:rgb(0 148 247 / var(--tw-text-opacity, 1))}.hover\:text-black:hover{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.hover\:text-blue-600:hover{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.hover\:text-gray-600:hover{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.hover\:text-gray-700:hover{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.hover\:text-gray-900:hover{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.hover\:text-green-600:hover{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.hover\:text-red-500:hover{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.hover\:text-white:hover{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:shadow-lg:hover{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.focus\:border-blue-400:focus{--tw-border-opacity: 1;border-color:rgb(96 165 250 / var(--tw-border-opacity, 1))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-0:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-\[\#0094f7\]:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(0 148 247 / var(--tw-ring-opacity, 1))}.active\:scale-95:active{--tw-scale-x: .95;--tw-scale-y: .95;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-25:disabled{opacity:.25}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.disabled\:opacity-60:disabled{opacity:.6}.disabled\:opacity-70:disabled{opacity:.7}.group:focus-within .group-focus-within\:text-\[\#0094f7\]{--tw-text-opacity: 1;color:rgb(0 148 247 / var(--tw-text-opacity, 1))}.group:focus-within .group-focus-within\:text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.group:hover .group-hover\:translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:scale-105{--tw-scale-x: 1.05;--tw-scale-y: 1.05;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:scale-110{--tw-scale-x: 1.1;--tw-scale-y: 1.1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:scale-125{--tw-scale-x: 1.25;--tw-scale-y: 1.25;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.group:hover .group-hover\:text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.group:hover .group-hover\:opacity-100{opacity:1}@media(min-width:640px){.sm\:w-72{width:18rem}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.sm\:grid-cols-\[1fr_180px\]{grid-template-columns:1fr 180px}.sm\:flex-row{flex-direction:row}.sm\:gap-8{gap:2rem}}@media(min-width:768px){.md\:col-span-2{grid-column:span 2 / span 2}.md\:w-auto{width:auto}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.md\:grid-cols-\[1\.4fr_110px_40px\]{grid-template-columns:1.4fr 110px 40px}.md\:grid-cols-\[180px_1fr\]{grid-template-columns:180px 1fr}.md\:grid-cols-\[1fr_1fr_1\.4fr_110px_40px\]{grid-template-columns:1fr 1fr 1.4fr 110px 40px}.md\:flex-row{flex-direction:row}.md\:items-end{align-items:flex-end}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:border-l{border-left-width:1px}.md\:border-t-0{border-top-width:0px}.md\:p-12{padding:3rem}.md\:pl-6{padding-left:1.5rem}.md\:pt-0{padding-top:0}}@media(min-width:1024px){.lg\:col-span-2{grid-column:span 2 / span 2}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-\[320px_1fr\]{grid-template-columns:320px 1fr}.lg\:flex-row{flex-direction:row}.lg\:items-center{align-items:center}.lg\:self-auto{align-self:auto}}@media(min-width:1280px){.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.xl\:flex-row{flex-direction:row}.xl\:items-end{align-items:flex-end}.xl\:justify-between{justify-content:space-between}}@media(min-width:1536px){.\32xl\:grid-cols-\[360px_1fr\]{grid-template-columns:360px 1fr}} +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.pointer-events-none{pointer-events:none}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.-bottom-1{bottom:-.25rem}.-right-1{right:-.25rem}.-right-6{right:-1.5rem}.-top-6{top:-1.5rem}.bottom-10{bottom:2.5rem}.bottom-8{bottom:2rem}.bottom-\[-10\%\]{bottom:-10%}.left-0{left:0}.left-0\.5{left:.125rem}.left-1{left:.25rem}.left-1\.5{left:.375rem}.left-1\/2{left:50%}.left-4{left:1rem}.left-5{left:1.25rem}.left-7{left:1.75rem}.left-\[-10\%\]{left:-10%}.right-0{right:0}.right-10{right:2.5rem}.right-2{right:.5rem}.right-3{right:.75rem}.right-4{right:1rem}.right-\[-10\%\]{right:-10%}.top-0{top:0}.top-0\.5{top:.125rem}.top-1{top:.25rem}.top-1\.5{top:.375rem}.top-1\/2{top:50%}.top-2{top:.5rem}.top-4{top:1rem}.top-\[-10\%\]{top:-10%}.top-\[calc\(100\%\+6px\)\]{top:calc(100% + 6px)}.-z-10{z-index:-10}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-\[10000\]{z-index:10000}.col-span-2{grid-column:span 2 / span 2}.col-span-full{grid-column:1 / -1}.mx-auto{margin-left:auto;margin-right:auto}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-10{margin-bottom:2.5rem}.mb-12{margin-bottom:3rem}.mb-2{margin-bottom:.5rem}.mb-2\.5{margin-bottom:.625rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-5{margin-bottom:1.25rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-64{margin-left:16rem}.mr-2{margin-right:.5rem}.mr-3{margin-right:.75rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.mt-auto{margin-top:auto}.line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.contents{display:contents}.hidden{display:none}.aspect-square{aspect-ratio:1 / 1}.h-10{height:2.5rem}.h-11{height:2.75rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-2\.5{height:.625rem}.h-20{height:5rem}.h-24{height:6rem}.h-28{height:7rem}.h-3{height:.75rem}.h-3\.5{height:.875rem}.h-32{height:8rem}.h-4{height:1rem}.h-40{height:10rem}.h-48{height:12rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-64{height:16rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-80{height:20rem}.h-9{height:2.25rem}.h-\[280px\]{height:280px}.h-\[300px\]{height:300px}.h-\[350px\]{height:350px}.h-\[48px\]{height:48px}.h-\[60\%\]{height:60%}.h-\[800px\]{height:800px}.h-full{height:100%}.h-screen{height:100vh}.max-h-48{max-height:12rem}.max-h-64{max-height:16rem}.max-h-\[380px\]{max-height:380px}.max-h-\[400px\]{max-height:400px}.max-h-\[420px\]{max-height:420px}.min-h-0{min-height:0px}.min-h-\[100px\]{min-height:100px}.min-h-\[120px\]{min-height:120px}.min-h-\[150px\]{min-height:150px}.min-h-\[400px\]{min-height:400px}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-2\.5{width:.625rem}.w-20{width:5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-3\.5{width:.875rem}.w-32{width:8rem}.w-4{width:1rem}.w-48{width:12rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-8{width:2rem}.w-9{width:2.25rem}.w-\[10\%\]{width:10%}.w-\[12\%\]{width:12%}.w-\[18\%\]{width:18%}.w-\[22\%\]{width:22%}.w-\[60\%\]{width:60%}.w-\[800px\]{width:800px}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-64{min-width:16rem}.min-w-\[210px\]{min-width:210px}.min-w-\[260px\]{min-width:260px}.max-w-6xl{max-width:72rem}.max-w-\[1400px\]{max-width:1400px}.max-w-\[200px\]{max-width:200px}.max-w-\[210px\]{max-width:210px}.max-w-\[240px\]{max-width:240px}.max-w-\[260px\]{max-width:260px}.max-w-\[280px\]{max-width:280px}.max-w-\[340px\]{max-width:340px}.max-w-\[80px\]{max-width:80px}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.table-fixed{table-layout:fixed}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-0{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-5{--tw-translate-x: 1.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-6{--tw-translate-x: 1.5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-7{--tw-translate-x: 1.75rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-\[1\.02\]{--tw-scale-x: 1.02;--tw-scale-y: 1.02;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}@keyframes spin{to{transform:rotate(360deg)}}.cursor-pointer{cursor:pointer}.resize-none{resize:none}.resize-y{resize:vertical}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-5{gap:1.25rem}.gap-6{gap:1.5rem}.gap-8{gap:2rem}.space-y-0\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.125rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.125rem * var(--tw-space-y-reverse))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-gray-50>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(249 250 251 / var(--tw-divide-opacity, 1))}.self-end{align-self:flex-end}.self-center{align-self:center}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.scroll-smooth{scroll-behavior:smooth}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.rounded{border-radius:6px}.rounded-2xl,.rounded-3xl{border-radius:10px}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:7px}.rounded-md{border-radius:6px}.rounded-xl{border-radius:8px}.border{border-width:1px}.border-0{border-width:0px}.border-2{border-width:2px}.border-4{border-width:4px}.border-b{border-bottom-width:1px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-none{border-style:none}.border-\[\#0094f7\]{--tw-border-opacity: 1;border-color:rgb(0 148 247 / var(--tw-border-opacity, 1))}.border-amber-100{--tw-border-opacity: 1;border-color:rgb(254 243 199 / var(--tw-border-opacity, 1))}.border-amber-200{--tw-border-opacity: 1;border-color:rgb(253 230 138 / var(--tw-border-opacity, 1))}.border-amber-500{--tw-border-opacity: 1;border-color:rgb(245 158 11 / var(--tw-border-opacity, 1))}.border-blue-100{--tw-border-opacity: 1;border-color:rgb(219 234 254 / var(--tw-border-opacity, 1))}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(191 219 254 / var(--tw-border-opacity, 1))}.border-blue-500{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.border-blue-600{--tw-border-opacity: 1;border-color:rgb(37 99 235 / var(--tw-border-opacity, 1))}.border-emerald-100{--tw-border-opacity: 1;border-color:rgb(209 250 229 / var(--tw-border-opacity, 1))}.border-emerald-500{--tw-border-opacity: 1;border-color:rgb(16 185 129 / var(--tw-border-opacity, 1))}.border-gray-100{--tw-border-opacity: 1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.border-gray-50{--tw-border-opacity: 1;border-color:rgb(249 250 251 / var(--tw-border-opacity, 1))}.border-green-200{--tw-border-opacity: 1;border-color:rgb(187 247 208 / var(--tw-border-opacity, 1))}.border-purple-100{--tw-border-opacity: 1;border-color:rgb(243 232 255 / var(--tw-border-opacity, 1))}.border-red-100{--tw-border-opacity: 1;border-color:rgb(254 226 226 / var(--tw-border-opacity, 1))}.border-white{--tw-border-opacity: 1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1))}.border-white\/10{border-color:#ffffff1a}.bg-\[\#0094f7\]{--tw-bg-opacity: 1;background-color:rgb(0 148 247 / var(--tw-bg-opacity, 1))}.bg-\[\#F4F5F7\]{--tw-bg-opacity: 1;background-color:rgb(244 245 247 / var(--tw-bg-opacity, 1))}.bg-\[\#F7F8FA\]{--tw-bg-opacity: 1;background-color:rgb(247 248 250 / var(--tw-bg-opacity, 1))}.bg-\[\#FAFAFA\]{--tw-bg-opacity: 1;background-color:rgb(250 250 250 / var(--tw-bg-opacity, 1))}.bg-\[\#f5f5f7\]{--tw-bg-opacity: 1;background-color:rgb(245 245 247 / var(--tw-bg-opacity, 1))}.bg-amber-100{--tw-bg-opacity: 1;background-color:rgb(254 243 199 / var(--tw-bg-opacity, 1))}.bg-amber-100\/70{background-color:#fef3c7b3}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(255 251 235 / var(--tw-bg-opacity, 1))}.bg-amber-50\/60{background-color:#fffbeb99}.bg-amber-500{--tw-bg-opacity: 1;background-color:rgb(245 158 11 / var(--tw-bg-opacity, 1))}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.bg-black\/50{background-color:#00000080}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.bg-blue-100\/70{background-color:#dbeafeb3}.bg-blue-200\/30{background-color:#bfdbfe4d}.bg-blue-200\/40{background-color:#bfdbfe66}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(96 165 250 / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.bg-blue-50\/50{background-color:#eff6ff80}.bg-blue-50\/60{background-color:#eff6ff99}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity, 1))}.bg-emerald-100{--tw-bg-opacity: 1;background-color:rgb(209 250 229 / var(--tw-bg-opacity, 1))}.bg-emerald-50{--tw-bg-opacity: 1;background-color:rgb(236 253 245 / var(--tw-bg-opacity, 1))}.bg-emerald-50\/60{background-color:#ecfdf599}.bg-emerald-600{--tw-bg-opacity: 1;background-color:rgb(5 150 105 / var(--tw-bg-opacity, 1))}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.bg-gray-100\/50{background-color:#f3f4f680}.bg-gray-200{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.bg-gray-200\/50{background-color:#e5e7eb80}.bg-gray-300{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity, 1))}.bg-gray-400{--tw-bg-opacity: 1;background-color:rgb(156 163 175 / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.bg-gray-900{--tw-bg-opacity: 1;background-color:rgb(17 24 39 / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-orange-100{--tw-bg-opacity: 1;background-color:rgb(255 237 213 / var(--tw-bg-opacity, 1))}.bg-orange-500{--tw-bg-opacity: 1;background-color:rgb(249 115 22 / var(--tw-bg-opacity, 1))}.bg-pink-50{--tw-bg-opacity: 1;background-color:rgb(253 242 248 / var(--tw-bg-opacity, 1))}.bg-purple-100{--tw-bg-opacity: 1;background-color:rgb(243 232 255 / var(--tw-bg-opacity, 1))}.bg-purple-50{--tw-bg-opacity: 1;background-color:rgb(250 245 255 / var(--tw-bg-opacity, 1))}.bg-purple-50\/50{background-color:#faf5ff80}.bg-purple-500{--tw-bg-opacity: 1;background-color:rgb(168 85 247 / var(--tw-bg-opacity, 1))}.bg-purple-600{--tw-bg-opacity: 1;background-color:rgb(147 51 234 / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-slate-900{--tw-bg-opacity: 1;background-color:rgb(15 23 42 / var(--tw-bg-opacity, 1))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-white\/5{background-color:#ffffff0d}.bg-white\/80{background-color:#fffc}.bg-white\/90{background-color:#ffffffe6}.bg-white\/95{background-color:#fffffff2}.bg-opacity-10{--tw-bg-opacity: .1}.bg-gradient-to-bl{background-image:linear-gradient(to bottom left,var(--tw-gradient-stops))}.from-blue-50{--tw-gradient-from: #eff6ff var(--tw-gradient-from-position);--tw-gradient-to: rgb(239 246 255 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.to-transparent{--tw-gradient-to: transparent var(--tw-gradient-to-position)}.object-cover{-o-object-fit:cover;object-fit:cover}.p-0{padding:0}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-12{padding:3rem}.p-16{padding:4rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-20{padding:5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-5{padding:1.25rem}.p-6{padding:1.5rem}.p-8{padding:2rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-10{padding-left:2.5rem;padding-right:2.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-20{padding-top:5rem;padding-bottom:5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-3\.5{padding-top:.875rem;padding-bottom:.875rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-10{padding-bottom:2.5rem}.pb-24{padding-bottom:6rem}.pl-10{padding-left:2.5rem}.pl-11{padding-left:2.75rem}.pl-14{padding-left:3.5rem}.pl-2{padding-left:.5rem}.pl-4{padding-left:1rem}.pl-5{padding-left:1.25rem}.pr-10{padding-right:2.5rem}.pr-11{padding-right:2.75rem}.pr-12{padding-right:3rem}.pr-2{padding-right:.5rem}.pr-4{padding-right:1rem}.pr-6{padding-right:1.5rem}.pt-1{padding-top:.25rem}.pt-4{padding-top:1rem}.pt-5{padding-top:1.25rem}.pt-6{padding-top:1.5rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.font-sans{font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-black{font-weight:900}.font-bold{font-weight:700}.font-extrabold{font-weight:800}.font-medium{font-weight:500}.uppercase{text-transform:uppercase}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-6{line-height:1.5rem}.leading-relaxed{line-height:1.625}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.tracking-widest{letter-spacing:.1em}.text-\[\#0094f7\]{--tw-text-opacity: 1;color:rgb(0 148 247 / var(--tw-text-opacity, 1))}.text-\[\#111\]{--tw-text-opacity: 1;color:rgb(17 17 17 / var(--tw-text-opacity, 1))}.text-amber-600{--tw-text-opacity: 1;color:rgb(217 119 6 / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(180 83 9 / var(--tw-text-opacity, 1))}.text-amber-800{--tw-text-opacity: 1;color:rgb(146 64 14 / var(--tw-text-opacity, 1))}.text-amber-800\/80{color:#92400ecc}.text-amber-900\/90{color:#78350fe6}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.text-blue-500{--tw-text-opacity: 1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.text-blue-900{--tw-text-opacity: 1;color:rgb(30 58 138 / var(--tw-text-opacity, 1))}.text-blue-950{--tw-text-opacity: 1;color:rgb(23 37 84 / var(--tw-text-opacity, 1))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(5 150 105 / var(--tw-text-opacity, 1))}.text-emerald-700{--tw-text-opacity: 1;color:rgb(4 120 87 / var(--tw-text-opacity, 1))}.text-gray-100{--tw-text-opacity: 1;color:rgb(243 244 246 / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.text-gray-700{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.text-gray-900{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(21 128 61 / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.text-orange-700{--tw-text-opacity: 1;color:rgb(194 65 12 / var(--tw-text-opacity, 1))}.text-pink-600{--tw-text-opacity: 1;color:rgb(219 39 119 / var(--tw-text-opacity, 1))}.text-purple-500{--tw-text-opacity: 1;color:rgb(168 85 247 / var(--tw-text-opacity, 1))}.text-purple-600{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity, 1))}.text-purple-700{--tw-text-opacity: 1;color:rgb(126 34 206 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.text-slate-400{--tw-text-opacity: 1;color:rgb(148 163 184 / var(--tw-text-opacity, 1))}.text-slate-950{--tw-text-opacity: 1;color:rgb(2 6 23 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-white\/30{color:#ffffff4d}.opacity-0{opacity:0}.opacity-10{opacity:.1}.opacity-20{opacity:.2}.opacity-30{opacity:.3}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.shadow-2xl{--tw-shadow: 0 25px 50px -12px rgb(0 0 0 / .25);--tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[0_20px_60px_-15px_rgba\(0\,0\,0\,0\.05\)\]{--tw-shadow: 0 20px 60px -15px rgba(0,0,0,.05);--tw-shadow-colored: 0 20px 60px -15px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[4px_0_24px_rgba\(0\,0\,0\,0\.02\)\]{--tw-shadow: 4px 0 24px rgba(0,0,0,.02);--tw-shadow-colored: 4px 0 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-inner{--tw-shadow: inset 0 2px 4px 0 rgb(0 0 0 / .05);--tw-shadow-colored: inset 0 2px 4px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-blue-100{--tw-shadow-color: #dbeafe;--tw-shadow: var(--tw-shadow-colored)}.shadow-blue-200{--tw-shadow-color: #bfdbfe;--tw-shadow: var(--tw-shadow-colored)}.shadow-emerald-100{--tw-shadow-color: #d1fae5;--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200{--tw-shadow-color: #e5e7eb;--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200\/70{--tw-shadow-color: rgb(229 231 235 / .7);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.ring-4{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-white{--tw-ring-opacity: 1;--tw-ring-color: rgb(255 255 255 / var(--tw-ring-opacity, 1))}.blur-2xl{--tw-blur: blur(40px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.blur-\[120px\]{--tw-blur: blur(120px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.drop-shadow{--tw-drop-shadow: drop-shadow(0 1px 2px rgb(0 0 0 / .1)) drop-shadow(0 1px 1px rgb(0 0 0 / .06));filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur{--tw-backdrop-blur: blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-3xl{--tw-backdrop-blur: blur(64px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-md{--tw-backdrop-blur: blur(12px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-sm{--tw-backdrop-blur: blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}.duration-500{transition-duration:.5s}.squircle{-webkit-mask-image:url(/static/assets/squircle-rb6SKa34.svg);mask-image:url(/static/assets/squircle-rb6SKa34.svg);-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center;border-radius:0}*{box-sizing:border-box;margin:0;padding:0}html,body,#root{height:100%;width:100%}body{font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif;background-color:#f4f5f7;color:#fff;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ios-card{background:#fff;border-radius:8px;border:1px solid rgba(0,0,0,.02);box-shadow:0 8px 24px #0000000a;transition:transform .2s ease,box-shadow .2s ease}.ios-card:hover{box-shadow:0 12px 32px #0000000f}.ios-input{background:#f7f8fa;border:1px solid transparent;transition:all .3s cubic-bezier(.25,.8,.25,1);color:#111;font-weight:500}.ios-input:focus{background:#fff;border-color:#0094f7;box-shadow:0 0 0 4px #0094f74d;outline:none}.ios-input::-moz-placeholder{color:#9ca3af;font-weight:400}.ios-input::placeholder{color:#9ca3af;font-weight:400}.ios-btn-primary{background:#0094f7;color:#fff;font-weight:700;border:none;transition:all .2s cubic-bezier(.25,.8,.25,1);cursor:pointer}.ios-btn-primary:hover:not(:disabled){background:#0071e3;transform:translateY(-1px);box-shadow:0 8px 20px #0094f74d}.ios-btn-primary:active:not(:disabled){transform:translateY(1px);box-shadow:0 2px 8px #0094f733}.ios-btn-primary:disabled{background:#f0f0f0;color:#aaa;box-shadow:none;transform:none;cursor:not-allowed}.ios-btn-secondary{background:#f7f8fa;color:#fff;font-weight:600;border:1px solid transparent;transition:all .2s ease;cursor:pointer}.ios-btn-secondary:hover{background:#e5e7eb;border-color:#d1d5db}.ios-btn-danger{background:#fee2e2;color:#dc2626;font-weight:600;border:1px solid transparent;transition:all .2s ease;cursor:pointer}.ios-btn-danger:hover{background:#fecaca;border-color:#fca5a5}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:#0000001a;border-radius:10px}::-webkit-scrollbar-thumb:hover{background:#0003}@keyframes fadeIn{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}.animate-fade-in{animation:fadeIn .5s cubic-bezier(.16,1,.3,1) forwards}@keyframes slideUp{0%{opacity:0;transform:translateY(30px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}.animate-slide-up{animation:slideUp .3s cubic-bezier(.16,1,.3,1) forwards}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}@keyframes pulse{0%,to{opacity:1}50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}::-moz-selection{background:#0094f7;color:#fff}::selection{background:#0094f7;color:#fff}.text-brand{color:#0094f7}.bg-brand{background-color:#0094f7}.border-brand{border-color:#0094f7}.status-badge{display:inline-flex;align-items:center;padding:4px 12px;border-radius:9999px;font-size:12px;font-weight:600}.status-badge-success{background-color:#d1fae5;color:#065f46}.status-badge-warning{background-color:#fef3c7;color:#92400e}.status-badge-error{background-color:#fee2e2;color:#991b1b}.status-badge-info{background-color:#dbeafe;color:#1e40af}.loading-skeleton{background:linear-gradient(90deg,#f3f4f6,#e5e7eb,#f3f4f6);background-size:200% 100%;animation:loading 1.5s ease-in-out infinite}@keyframes loading{0%{background-position:200% 0}to{background-position:-200% 0}}.modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background-color:#0006;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);padding:1rem;overflow-y:auto}.modal-container{position:relative;width:100%;max-width:42rem;max-height:85vh;margin:auto;display:flex;flex-direction:column;background-color:#fff;border-radius:10px;box-shadow:0 25px 50px -12px #00000040;overflow:hidden}.modal-header{flex-shrink:0;padding:2rem 2rem 1.5rem;border-bottom:1px solid #F3F4F6;background-color:#fff;z-index:10}.modal-body{flex:1 1 auto;overflow-y:auto;overflow-x:hidden;padding:2rem}.modal-footer{flex-shrink:0;padding:1.5rem 2rem 2rem;border-top:1px solid #F3F4F6;background-color:#fff;z-index:10}.modal-container-lg{max-width:64rem}.modal-overlay-centered{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;justify-content:center;background-color:#0006;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);padding:1rem;overflow-y:auto}.modal-overlay-centered .modal-container{position:relative;width:100%;max-width:42rem;max-height:85vh;margin:auto 0;display:flex;flex-direction:column;background-color:#fff;border-radius:10px;box-shadow:0 25px 50px -12px #00000040;overflow:hidden}@media(max-width:768px){.ios-card{border-radius:6px}.ios-input{font-size:16px}.modal-container{max-width:calc(100% - 2rem);max-height:90vh;border-radius:8px}.modal-header,.modal-body,.modal-footer{padding-left:1.5rem;padding-right:1.5rem}}.hover\:translate-y-\[-4px\]:hover{--tw-translate-y: -4px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:scale-105:hover{--tw-scale-x: 1.05;--tw-scale-y: 1.05;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:border-\[\#0094f7\]:hover{--tw-border-opacity: 1;border-color:rgb(0 148 247 / var(--tw-border-opacity, 1))}.hover\:border-amber-300:hover{--tw-border-opacity: 1;border-color:rgb(252 211 77 / var(--tw-border-opacity, 1))}.hover\:border-blue-300:hover{--tw-border-opacity: 1;border-color:rgb(147 197 253 / var(--tw-border-opacity, 1))}.hover\:border-emerald-300:hover{--tw-border-opacity: 1;border-color:rgb(110 231 183 / var(--tw-border-opacity, 1))}.hover\:border-gray-300:hover{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.hover\:border-gray-400:hover{--tw-border-opacity: 1;border-color:rgb(156 163 175 / var(--tw-border-opacity, 1))}.hover\:bg-\[\#0071e3\]:hover{--tw-bg-opacity: 1;background-color:rgb(0 113 227 / var(--tw-bg-opacity, 1))}.hover\:bg-\[\#0094f7\]:hover{--tw-bg-opacity: 1;background-color:rgb(0 148 247 / var(--tw-bg-opacity, 1))}.hover\:bg-\[\#FFFDE7\]\/50:hover{background-color:#fffde780}.hover\:bg-amber-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 243 199 / var(--tw-bg-opacity, 1))}.hover\:bg-black:hover{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-100:hover{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-50:hover{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-700:hover{--tw-bg-opacity: 1;background-color:rgb(29 78 216 / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-100:hover{--tw-bg-opacity: 1;background-color:rgb(209 250 229 / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50:hover{--tw-bg-opacity: 1;background-color:rgb(236 253 245 / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50\/50:hover{background-color:#ecfdf580}.hover\:bg-emerald-700:hover{--tw-bg-opacity: 1;background-color:rgb(4 120 87 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-200:hover{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-300:hover{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-800:hover{--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.hover\:bg-green-100:hover{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.hover\:bg-green-50:hover{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.hover\:bg-purple-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 232 255 / var(--tw-bg-opacity, 1))}.hover\:bg-red-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.hover\:bg-red-50:hover{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.hover\:bg-white:hover{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.hover\:bg-white\/10:hover{background-color:#ffffff1a}.hover\:text-\[\#0094f7\]:hover{--tw-text-opacity: 1;color:rgb(0 148 247 / var(--tw-text-opacity, 1))}.hover\:text-black:hover{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.hover\:text-blue-600:hover{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.hover\:text-gray-600:hover{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.hover\:text-gray-700:hover{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.hover\:text-gray-900:hover{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.hover\:text-green-600:hover{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.hover\:text-red-500:hover{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.hover\:text-white:hover{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:shadow-lg:hover{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.focus\:border-blue-400:focus{--tw-border-opacity: 1;border-color:rgb(96 165 250 / var(--tw-border-opacity, 1))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-0:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-\[\#0094f7\]:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(0 148 247 / var(--tw-ring-opacity, 1))}.active\:scale-95:active{--tw-scale-x: .95;--tw-scale-y: .95;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-25:disabled{opacity:.25}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.disabled\:opacity-60:disabled{opacity:.6}.disabled\:opacity-70:disabled{opacity:.7}.group:focus-within .group-focus-within\:text-\[\#0094f7\]{--tw-text-opacity: 1;color:rgb(0 148 247 / var(--tw-text-opacity, 1))}.group:focus-within .group-focus-within\:text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.group:hover .group-hover\:translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:scale-105{--tw-scale-x: 1.05;--tw-scale-y: 1.05;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:scale-110{--tw-scale-x: 1.1;--tw-scale-y: 1.1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:scale-125{--tw-scale-x: 1.25;--tw-scale-y: 1.25;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.group:hover .group-hover\:text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.group:hover .group-hover\:opacity-100{opacity:1}@media(min-width:640px){.sm\:w-72{width:18rem}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.sm\:grid-cols-\[1fr_180px\]{grid-template-columns:1fr 180px}.sm\:flex-row{flex-direction:row}.sm\:gap-8{gap:2rem}}@media(min-width:768px){.md\:col-span-2{grid-column:span 2 / span 2}.md\:w-auto{width:auto}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.md\:grid-cols-\[1\.4fr_110px_40px\]{grid-template-columns:1.4fr 110px 40px}.md\:grid-cols-\[180px_1fr\]{grid-template-columns:180px 1fr}.md\:grid-cols-\[1fr_1fr_1\.4fr_110px_40px\]{grid-template-columns:1fr 1fr 1.4fr 110px 40px}.md\:flex-row{flex-direction:row}.md\:items-end{align-items:flex-end}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:border-l{border-left-width:1px}.md\:border-t-0{border-top-width:0px}.md\:p-12{padding:3rem}.md\:pl-6{padding-left:1.5rem}.md\:pt-0{padding-top:0}}@media(min-width:1024px){.lg\:col-span-2{grid-column:span 2 / span 2}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-\[320px_1fr\]{grid-template-columns:320px 1fr}.lg\:flex-row{flex-direction:row}.lg\:items-center{align-items:center}.lg\:self-auto{align-self:auto}}@media(min-width:1280px){.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.xl\:flex-row{flex-direction:row}.xl\:items-end{align-items:flex-end}.xl\:justify-between{justify-content:space-between}}@media(min-width:1536px){.\32xl\:grid-cols-\[360px_1fr\]{grid-template-columns:360px 1fr}} diff --git a/internal/webui/static/assets/react-vendor-DZnRGM0-.js b/internal/webui/static/assets/react-vendor-DZnRGM0-.js new file mode 100644 index 0000000..3407eba --- /dev/null +++ b/internal/webui/static/assets/react-vendor-DZnRGM0-.js @@ -0,0 +1,49 @@ +function ws(M,Sl){for(var W=0;Wo[al]})}}}return Object.freeze(Object.defineProperty(M,Symbol.toStringTag,{value:"Module"}))}function E1(M){return M&&M.__esModule&&Object.prototype.hasOwnProperty.call(M,"default")?M.default:M}var ai={exports:{}},ge={};/** + * @license React + * react-jsx-runtime.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var m1;function Ws(){if(m1)return ge;m1=1;var M=Symbol.for("react.transitional.element"),Sl=Symbol.for("react.fragment");function W(o,al,vl){var Ol=null;if(vl!==void 0&&(Ol=""+vl),al.key!==void 0&&(Ol=""+al.key),"key"in al){vl={};for(var Rl in al)Rl!=="key"&&(vl[Rl]=al[Rl])}else vl=al;return al=vl.ref,{$$typeof:M,type:o,key:Ol,ref:al!==void 0?al:null,props:vl}}return ge.Fragment=Sl,ge.jsx=W,ge.jsxs=W,ge}var s1;function $s(){return s1||(s1=1,ai.exports=Ws()),ai.exports}var ed=$s(),ei={exports:{}},C={};/** + * @license React + * react.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var d1;function Fs(){if(d1)return C;d1=1;var M=Symbol.for("react.transitional.element"),Sl=Symbol.for("react.portal"),W=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),al=Symbol.for("react.profiler"),vl=Symbol.for("react.consumer"),Ol=Symbol.for("react.context"),Rl=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),A=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),R=Symbol.for("react.activity"),il=Symbol.iterator;function wl(v){return v===null||typeof v!="object"?null:(v=il&&v[il]||v["@@iterator"],typeof v=="function"?v:null)}var Bl={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ql=Object.assign,Ut={};function Wl(v,E,O){this.props=v,this.context=E,this.refs=Ut,this.updater=O||Bl}Wl.prototype.isReactComponent={},Wl.prototype.setState=function(v,E){if(typeof v!="object"&&typeof v!="function"&&v!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,v,E,"setState")},Wl.prototype.forceUpdate=function(v){this.updater.enqueueForceUpdate(this,v,"forceUpdate")};function wt(){}wt.prototype=Wl.prototype;function Nl(v,E,O){this.props=v,this.context=E,this.refs=Ut,this.updater=O||Bl}var nt=Nl.prototype=new wt;nt.constructor=Nl,ql(nt,Wl.prototype),nt.isPureReactComponent=!0;var Tt=Array.isArray;function Gl(){}var x={H:null,A:null,T:null,S:null},Xl=Object.prototype.hasOwnProperty;function Et(v,E,O){var U=O.ref;return{$$typeof:M,type:v,key:E,ref:U!==void 0?U:null,props:O}}function Qu(v,E){return Et(v.type,E,v.props)}function At(v){return typeof v=="object"&&v!==null&&v.$$typeof===M}function Ql(v){var E={"=":"=0",":":"=2"};return"$"+v.replace(/[=:]/g,function(O){return E[O]})}var zu=/\/+/g;function rt(v,E){return typeof v=="object"&&v!==null&&v.key!=null?Ql(""+v.key):E.toString(36)}function St(v){switch(v.status){case"fulfilled":return v.value;case"rejected":throw v.reason;default:switch(typeof v.status=="string"?v.then(Gl,Gl):(v.status="pending",v.then(function(E){v.status==="pending"&&(v.status="fulfilled",v.value=E)},function(E){v.status==="pending"&&(v.status="rejected",v.reason=E)})),v.status){case"fulfilled":return v.value;case"rejected":throw v.reason}}throw v}function b(v,E,O,U,Y){var X=typeof v;(X==="undefined"||X==="boolean")&&(v=null);var F=!1;if(v===null)F=!0;else switch(X){case"bigint":case"string":case"number":F=!0;break;case"object":switch(v.$$typeof){case M:case Sl:F=!0;break;case $:return F=v._init,b(F(v._payload),E,O,U,Y)}}if(F)return Y=Y(v),F=U===""?"."+rt(v,0):U,Tt(Y)?(O="",F!=null&&(O=F.replace(zu,"$&/")+"/"),b(Y,E,O,"",function(Oa){return Oa})):Y!=null&&(At(Y)&&(Y=Qu(Y,O+(Y.key==null||v&&v.key===Y.key?"":(""+Y.key).replace(zu,"$&/")+"/")+F)),E.push(Y)),1;F=0;var Cl=U===""?".":U+":";if(Tt(v))for(var dl=0;dl>>1,el=b[P];if(0>>1;Pal(O,q))Ual(Y,O)?(b[P]=Y,b[U]=q,P=U):(b[P]=O,b[E]=q,P=E);else if(Ual(Y,q))b[P]=Y,b[U]=q,P=U;else break l}}return _}function al(b,_){var q=b.sortIndex-_.sortIndex;return q!==0?q:b.id-_.id}if(M.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var vl=performance;M.unstable_now=function(){return vl.now()}}else{var Ol=Date,Rl=Ol.now();M.unstable_now=function(){return Ol.now()-Rl}}var N=[],A=[],$=1,R=null,il=3,wl=!1,Bl=!1,ql=!1,Ut=!1,Wl=typeof setTimeout=="function"?setTimeout:null,wt=typeof clearTimeout=="function"?clearTimeout:null,Nl=typeof setImmediate<"u"?setImmediate:null;function nt(b){for(var _=W(A);_!==null;){if(_.callback===null)o(A);else if(_.startTime<=b)o(A),_.sortIndex=_.expirationTime,Sl(N,_);else break;_=W(A)}}function Tt(b){if(ql=!1,nt(b),!Bl)if(W(N)!==null)Bl=!0,Gl||(Gl=!0,Ql());else{var _=W(A);_!==null&&St(Tt,_.startTime-b)}}var Gl=!1,x=-1,Xl=5,Et=-1;function Qu(){return Ut?!0:!(M.unstable_now()-Etb&&Qu());){var P=R.callback;if(typeof P=="function"){R.callback=null,il=R.priorityLevel;var el=P(R.expirationTime<=b);if(b=M.unstable_now(),typeof el=="function"){R.callback=el,nt(b),_=!0;break t}R===W(N)&&o(N),nt(b)}else o(N);R=W(N)}if(R!==null)_=!0;else{var v=W(A);v!==null&&St(Tt,v.startTime-b),_=!1}}break l}finally{R=null,il=q,wl=!1}_=void 0}}finally{_?Ql():Gl=!1}}}var Ql;if(typeof Nl=="function")Ql=function(){Nl(At)};else if(typeof MessageChannel<"u"){var zu=new MessageChannel,rt=zu.port2;zu.port1.onmessage=At,Ql=function(){rt.postMessage(null)}}else Ql=function(){Wl(At,0)};function St(b,_){x=Wl(function(){b(M.unstable_now())},_)}M.unstable_IdlePriority=5,M.unstable_ImmediatePriority=1,M.unstable_LowPriority=4,M.unstable_NormalPriority=3,M.unstable_Profiling=null,M.unstable_UserBlockingPriority=2,M.unstable_cancelCallback=function(b){b.callback=null},M.unstable_forceFrameRate=function(b){0>b||125P?(b.sortIndex=q,Sl(A,b),W(N)===null&&b===W(A)&&(ql?(wt(x),x=-1):ql=!0,St(Tt,q-P))):(b.sortIndex=el,Sl(N,b),Bl||wl||(Bl=!0,Gl||(Gl=!0,Ql()))),b},M.unstable_shouldYield=Qu,M.unstable_wrapCallback=function(b){var _=il;return function(){var q=il;il=_;try{return b.apply(this,arguments)}finally{il=q}}}})(ci)),ci}var S1;function Ps(){return S1||(S1=1,fi.exports=Is()),fi.exports}var ii={exports:{}},pl={};/** + * @license React + * react-dom.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var g1;function ld(){if(g1)return pl;g1=1;var M=yi();function Sl(N){var A="https://react.dev/errors/"+N;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(M)}catch(Sl){console.error(Sl)}}return M(),ii.exports=ld(),ii.exports}/** + * @license React + * react-dom-client.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var z1;function td(){if(z1)return be;z1=1;var M=Ps(),Sl=yi(),W=_1();function o(l){var t="https://react.dev/errors/"+l;if(1el||(l.current=P[el],P[el]=null,el--)}function O(l,t){el++,P[el]=l.current,l.current=t}var U=v(null),Y=v(null),X=v(null),F=v(null);function Cl(l,t){switch(O(X,t),O(Y,l),O(U,null),t.nodeType){case 9:case 11:l=(l=t.documentElement)&&(l=l.namespaceURI)?Cv(l):0;break;default:if(l=t.tagName,t=t.namespaceURI)t=Cv(t),l=Yv(t,l);else switch(l){case"svg":l=1;break;case"math":l=2;break;default:l=0}}E(U),O(U,l)}function dl(){E(U),E(Y),E(X)}function Oa(l){l.memoizedState!==null&&O(F,l);var t=U.current,u=Yv(t,l.type);t!==u&&(O(Y,l),O(U,u))}function ze(l){Y.current===l&&(E(U),E(Y)),F.current===l&&(E(F),de._currentValue=q)}var Xn,vi;function Tu(l){if(Xn===void 0)try{throw Error()}catch(u){var t=u.stack.trim().match(/\n( *(at )?)/);Xn=t&&t[1]||"",vi=-1)":-1e||i[a]!==d[e]){var g=` +`+i[a].replace(" at new "," at ");return l.displayName&&g.includes("")&&(g=g.replace("",l.displayName)),g}while(1<=a&&0<=e);break}}}finally{Qn=!1,Error.prepareStackTrace=u}return(u=l?l.displayName||l.name:"")?Tu(u):""}function O1(l,t){switch(l.tag){case 26:case 27:case 5:return Tu(l.type);case 16:return Tu("Lazy");case 13:return l.child!==t&&t!==null?Tu("Suspense Fallback"):Tu("Suspense");case 19:return Tu("SuspenseList");case 0:case 15:return jn(l.type,!1);case 11:return jn(l.type.render,!1);case 1:return jn(l.type,!0);case 31:return Tu("Activity");default:return""}}function mi(l){try{var t="",u=null;do t+=O1(l,u),u=l,l=l.return;while(l);return t}catch(a){return` +Error generating stack: `+a.message+` +`+a.stack}}var Zn=Object.prototype.hasOwnProperty,Vn=M.unstable_scheduleCallback,xn=M.unstable_cancelCallback,M1=M.unstable_shouldYield,D1=M.unstable_requestPaint,$l=M.unstable_now,U1=M.unstable_getCurrentPriorityLevel,si=M.unstable_ImmediatePriority,di=M.unstable_UserBlockingPriority,Te=M.unstable_NormalPriority,r1=M.unstable_LowPriority,hi=M.unstable_IdlePriority,H1=M.log,N1=M.unstable_setDisableYieldValue,Ma=null,Fl=null;function Wt(l){if(typeof H1=="function"&&N1(l),Fl&&typeof Fl.setStrictMode=="function")try{Fl.setStrictMode(Ma,l)}catch{}}var kl=Math.clz32?Math.clz32:q1,p1=Math.log,R1=Math.LN2;function q1(l){return l>>>=0,l===0?32:31-(p1(l)/R1|0)|0}var Ee=256,Ae=262144,_e=4194304;function Eu(l){var t=l&42;if(t!==0)return t;switch(l&-l){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return l&261888;case 262144:case 524288:case 1048576:case 2097152:return l&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return l&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return l}}function Oe(l,t,u){var a=l.pendingLanes;if(a===0)return 0;var e=0,n=l.suspendedLanes,f=l.pingedLanes;l=l.warmLanes;var c=a&134217727;return c!==0?(a=c&~n,a!==0?e=Eu(a):(f&=c,f!==0?e=Eu(f):u||(u=c&~l,u!==0&&(e=Eu(u))))):(c=a&~n,c!==0?e=Eu(c):f!==0?e=Eu(f):u||(u=a&~l,u!==0&&(e=Eu(u)))),e===0?0:t!==0&&t!==e&&(t&n)===0&&(n=e&-e,u=t&-t,n>=u||n===32&&(u&4194048)!==0)?t:e}function Da(l,t){return(l.pendingLanes&~(l.suspendedLanes&~l.pingedLanes)&t)===0}function C1(l,t){switch(l){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function oi(){var l=_e;return _e<<=1,(_e&62914560)===0&&(_e=4194304),l}function Ln(l){for(var t=[],u=0;31>u;u++)t.push(l);return t}function Ua(l,t){l.pendingLanes|=t,t!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function Y1(l,t,u,a,e,n){var f=l.pendingLanes;l.pendingLanes=u,l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0,l.expiredLanes&=u,l.entangledLanes&=u,l.errorRecoveryDisabledLanes&=u,l.shellSuspendCounter=0;var c=l.entanglements,i=l.expirationTimes,d=l.hiddenUpdates;for(u=f&~u;0"u")return null;try{return l.activeElement||l.body}catch{return l.body}}var Z1=/[\n"\\]/g;function ct(l){return l.replace(Z1,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Fn(l,t,u,a,e,n,f,c){l.name="",f!=null&&typeof f!="function"&&typeof f!="symbol"&&typeof f!="boolean"?l.type=f:l.removeAttribute("type"),t!=null?f==="number"?(t===0&&l.value===""||l.value!=t)&&(l.value=""+ft(t)):l.value!==""+ft(t)&&(l.value=""+ft(t)):f!=="submit"&&f!=="reset"||l.removeAttribute("value"),t!=null?kn(l,f,ft(t)):u!=null?kn(l,f,ft(u)):a!=null&&l.removeAttribute("value"),e==null&&n!=null&&(l.defaultChecked=!!n),e!=null&&(l.checked=e&&typeof e!="function"&&typeof e!="symbol"),c!=null&&typeof c!="function"&&typeof c!="symbol"&&typeof c!="boolean"?l.name=""+ft(c):l.removeAttribute("name")}function ri(l,t,u,a,e,n,f,c){if(n!=null&&typeof n!="function"&&typeof n!="symbol"&&typeof n!="boolean"&&(l.type=n),t!=null||u!=null){if(!(n!=="submit"&&n!=="reset"||t!=null)){$n(l);return}u=u!=null?""+ft(u):"",t=t!=null?""+ft(t):u,c||t===l.value||(l.value=t),l.defaultValue=t}a=a??e,a=typeof a!="function"&&typeof a!="symbol"&&!!a,l.checked=c?l.checked:!!a,l.defaultChecked=!!a,f!=null&&typeof f!="function"&&typeof f!="symbol"&&typeof f!="boolean"&&(l.name=f),$n(l)}function kn(l,t,u){t==="number"&&Ue(l.ownerDocument)===l||l.defaultValue===""+u||(l.defaultValue=""+u)}function Ku(l,t,u,a){if(l=l.options,t){t={};for(var e=0;e"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),uf=!1;if(pt)try{var pa={};Object.defineProperty(pa,"passive",{get:function(){uf=!0}}),window.addEventListener("test",pa,pa),window.removeEventListener("test",pa,pa)}catch{uf=!1}var Ft=null,af=null,He=null;function Yi(){if(He)return He;var l,t=af,u=t.length,a,e="value"in Ft?Ft.value:Ft.textContent,n=e.length;for(l=0;l=Ca),Zi=" ",Vi=!1;function xi(l,t){switch(l){case"keyup":return om.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Li(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var $u=!1;function gm(l,t){switch(l){case"compositionend":return Li(t);case"keypress":return t.which!==32?null:(Vi=!0,Zi);case"textInput":return l=t.data,l===Zi&&Vi?null:l;default:return null}}function bm(l,t){if($u)return l==="compositionend"||!yf&&xi(l,t)?(l=Yi(),He=af=Ft=null,$u=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:u,offset:t-l};l=a}l:{for(;u;){if(u.nextSibling){u=u.nextSibling;break l}u=u.parentNode}u=void 0}u=Ii(u)}}function l0(l,t){return l&&t?l===t?!0:l&&l.nodeType===3?!1:t&&t.nodeType===3?l0(l,t.parentNode):"contains"in l?l.contains(t):l.compareDocumentPosition?!!(l.compareDocumentPosition(t)&16):!1:!1}function t0(l){l=l!=null&&l.ownerDocument!=null&&l.ownerDocument.defaultView!=null?l.ownerDocument.defaultView:window;for(var t=Ue(l.document);t instanceof l.HTMLIFrameElement;){try{var u=typeof t.contentWindow.location.href=="string"}catch{u=!1}if(u)l=t.contentWindow;else break;t=Ue(l.document)}return t}function sf(l){var t=l&&l.nodeName&&l.nodeName.toLowerCase();return t&&(t==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||t==="textarea"||l.contentEditable==="true")}var Dm=pt&&"documentMode"in document&&11>=document.documentMode,Fu=null,df=null,Xa=null,hf=!1;function u0(l,t,u){var a=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;hf||Fu==null||Fu!==Ue(a)||(a=Fu,"selectionStart"in a&&sf(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),Xa&&Ga(Xa,a)||(Xa=a,a=_n(df,"onSelect"),0>=f,e-=f,_t=1<<32-kl(t)+e|u<G?(V=r,r=null):V=r.sibling;var J=h(m,r,s[G],z);if(J===null){r===null&&(r=V);break}l&&r&&J.alternate===null&&t(m,r),y=n(J,y,G),K===null?H=J:K.sibling=J,K=J,r=V}if(G===s.length)return u(m,r),L&&qt(m,G),H;if(r===null){for(;GG?(V=r,r=null):V=r.sibling;var bu=h(m,r,J.value,z);if(bu===null){r===null&&(r=V);break}l&&r&&bu.alternate===null&&t(m,r),y=n(bu,y,G),K===null?H=bu:K.sibling=bu,K=bu,r=V}if(J.done)return u(m,r),L&&qt(m,G),H;if(r===null){for(;!J.done;G++,J=s.next())J=T(m,J.value,z),J!==null&&(y=n(J,y,G),K===null?H=J:K.sibling=J,K=J);return L&&qt(m,G),H}for(r=a(r);!J.done;G++,J=s.next())J=S(r,m,G,J.value,z),J!==null&&(l&&J.alternate!==null&&r.delete(J.key===null?G:J.key),y=n(J,y,G),K===null?H=J:K.sibling=J,K=J);return l&&r.forEach(function(Js){return t(m,Js)}),L&&qt(m,G),H}function ul(m,y,s,z){if(typeof s=="object"&&s!==null&&s.type===ql&&s.key===null&&(s=s.props.children),typeof s=="object"&&s!==null){switch(s.$$typeof){case wl:l:{for(var H=s.key;y!==null;){if(y.key===H){if(H=s.type,H===ql){if(y.tag===7){u(m,y.sibling),z=e(y,s.props.children),z.return=m,m=z;break l}}else if(y.elementType===H||typeof H=="object"&&H!==null&&H.$$typeof===Xl&&Ru(H)===y.type){u(m,y.sibling),z=e(y,s.props),La(z,s),z.return=m,m=z;break l}u(m,y);break}else t(m,y);y=y.sibling}s.type===ql?(z=Uu(s.props.children,m.mode,z,s.key),z.return=m,m=z):(z=Qe(s.type,s.key,s.props,null,m.mode,z),La(z,s),z.return=m,m=z)}return f(m);case Bl:l:{for(H=s.key;y!==null;){if(y.key===H)if(y.tag===4&&y.stateNode.containerInfo===s.containerInfo&&y.stateNode.implementation===s.implementation){u(m,y.sibling),z=e(y,s.children||[]),z.return=m,m=z;break l}else{u(m,y);break}else t(m,y);y=y.sibling}z=Ef(s,m.mode,z),z.return=m,m=z}return f(m);case Xl:return s=Ru(s),ul(m,y,s,z)}if(St(s))return D(m,y,s,z);if(Ql(s)){if(H=Ql(s),typeof H!="function")throw Error(o(150));return s=H.call(s),p(m,y,s,z)}if(typeof s.then=="function")return ul(m,y,Je(s),z);if(s.$$typeof===Nl)return ul(m,y,Ve(m,s),z);we(m,s)}return typeof s=="string"&&s!==""||typeof s=="number"||typeof s=="bigint"?(s=""+s,y!==null&&y.tag===6?(u(m,y.sibling),z=e(y,s),z.return=m,m=z):(u(m,y),z=Tf(s,m.mode,z),z.return=m,m=z),f(m)):u(m,y)}return function(m,y,s,z){try{xa=0;var H=ul(m,y,s,z);return ca=null,H}catch(r){if(r===fa||r===Le)throw r;var K=Pl(29,r,null,m.mode);return K.lanes=z,K.return=m,K}finally{}}}var Cu=M0(!0),D0=M0(!1),tu=!1;function qf(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Cf(l,t){l=l.updateQueue,t.updateQueue===l&&(t.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,callbacks:null})}function uu(l){return{lane:l,tag:0,payload:null,callback:null,next:null}}function au(l,t,u){var a=l.updateQueue;if(a===null)return null;if(a=a.shared,(w&2)!==0){var e=a.pending;return e===null?t.next=t:(t.next=e.next,e.next=t),a.pending=t,t=Xe(l),y0(l,null,u),t}return Ge(l,a,t,u),Xe(l)}function Ka(l,t,u){if(t=t.updateQueue,t!==null&&(t=t.shared,(u&4194048)!==0)){var a=t.lanes;a&=l.pendingLanes,u|=a,t.lanes=u,gi(l,u)}}function Yf(l,t){var u=l.updateQueue,a=l.alternate;if(a!==null&&(a=a.updateQueue,u===a)){var e=null,n=null;if(u=u.firstBaseUpdate,u!==null){do{var f={lane:u.lane,tag:u.tag,payload:u.payload,callback:null,next:null};n===null?e=n=f:n=n.next=f,u=u.next}while(u!==null);n===null?e=n=t:n=n.next=t}else e=n=t;u={baseState:a.baseState,firstBaseUpdate:e,lastBaseUpdate:n,shared:a.shared,callbacks:a.callbacks},l.updateQueue=u;return}l=u.lastBaseUpdate,l===null?u.firstBaseUpdate=t:l.next=t,u.lastBaseUpdate=t}var Bf=!1;function Ja(){if(Bf){var l=na;if(l!==null)throw l}}function wa(l,t,u,a){Bf=!1;var e=l.updateQueue;tu=!1;var n=e.firstBaseUpdate,f=e.lastBaseUpdate,c=e.shared.pending;if(c!==null){e.shared.pending=null;var i=c,d=i.next;i.next=null,f===null?n=d:f.next=d,f=i;var g=l.alternate;g!==null&&(g=g.updateQueue,c=g.lastBaseUpdate,c!==f&&(c===null?g.firstBaseUpdate=d:c.next=d,g.lastBaseUpdate=i))}if(n!==null){var T=e.baseState;f=0,g=d=i=null,c=n;do{var h=c.lane&-536870913,S=h!==c.lane;if(S?(Z&h)===h:(a&h)===h){h!==0&&h===ea&&(Bf=!0),g!==null&&(g=g.next={lane:0,tag:c.tag,payload:c.payload,callback:null,next:null});l:{var D=l,p=c;h=t;var ul=u;switch(p.tag){case 1:if(D=p.payload,typeof D=="function"){T=D.call(ul,T,h);break l}T=D;break l;case 3:D.flags=D.flags&-65537|128;case 0:if(D=p.payload,h=typeof D=="function"?D.call(ul,T,h):D,h==null)break l;T=R({},T,h);break l;case 2:tu=!0}}h=c.callback,h!==null&&(l.flags|=64,S&&(l.flags|=8192),S=e.callbacks,S===null?e.callbacks=[h]:S.push(h))}else S={lane:h,tag:c.tag,payload:c.payload,callback:c.callback,next:null},g===null?(d=g=S,i=T):g=g.next=S,f|=h;if(c=c.next,c===null){if(c=e.shared.pending,c===null)break;S=c,c=S.next,S.next=null,e.lastBaseUpdate=S,e.shared.pending=null}}while(!0);g===null&&(i=T),e.baseState=i,e.firstBaseUpdate=d,e.lastBaseUpdate=g,n===null&&(e.shared.lanes=0),iu|=f,l.lanes=f,l.memoizedState=T}}function U0(l,t){if(typeof l!="function")throw Error(o(191,l));l.call(t)}function r0(l,t){var u=l.callbacks;if(u!==null)for(l.callbacks=null,l=0;ln?n:8;var f=b.T,c={};b.T=c,tc(l,!1,t,u);try{var i=e(),d=b.S;if(d!==null&&d(c,i),i!==null&&typeof i=="object"&&typeof i.then=="function"){var g=Ym(i,a);Fa(l,t,g,et(l))}else Fa(l,t,a,et(l))}catch(T){Fa(l,t,{then:function(){},status:"rejected",reason:T},et())}finally{_.p=n,f!==null&&c.types!==null&&(f.types=c.types),b.T=f}}function Zm(){}function Pf(l,t,u,a){if(l.tag!==5)throw Error(o(476));var e=fy(l).queue;ny(l,e,t,q,u===null?Zm:function(){return cy(l),u(a)})}function fy(l){var t=l.memoizedState;if(t!==null)return t;t={memoizedState:q,baseState:q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gt,lastRenderedState:q},next:null};var u={};return t.next={memoizedState:u,baseState:u,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gt,lastRenderedState:u},next:null},l.memoizedState=t,l=l.alternate,l!==null&&(l.memoizedState=t),t}function cy(l){var t=fy(l);t.next===null&&(t=l.alternate.memoizedState),Fa(l,t.next.queue,{},et())}function lc(){return Ul(de)}function iy(){return ol().memoizedState}function yy(){return ol().memoizedState}function Vm(l){for(var t=l.return;t!==null;){switch(t.tag){case 24:case 3:var u=et();l=uu(u);var a=au(t,l,u);a!==null&&(Jl(a,t,u),Ka(a,t,u)),t={cache:Hf()},l.payload=t;return}t=t.return}}function xm(l,t,u){var a=et();u={lane:a,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},an(l)?my(t,u):(u=bf(l,t,u,a),u!==null&&(Jl(u,l,a),sy(u,t,a)))}function vy(l,t,u){var a=et();Fa(l,t,u,a)}function Fa(l,t,u,a){var e={lane:a,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null};if(an(l))my(t,e);else{var n=l.alternate;if(l.lanes===0&&(n===null||n.lanes===0)&&(n=t.lastRenderedReducer,n!==null))try{var f=t.lastRenderedState,c=n(f,u);if(e.hasEagerState=!0,e.eagerState=c,Il(c,f))return Ge(l,t,e,0),nl===null&&Be(),!1}catch{}finally{}if(u=bf(l,t,e,a),u!==null)return Jl(u,l,a),sy(u,t,a),!0}return!1}function tc(l,t,u,a){if(a={lane:2,revertLane:qc(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},an(l)){if(t)throw Error(o(479))}else t=bf(l,u,a,2),t!==null&&Jl(t,l,2)}function an(l){var t=l.alternate;return l===B||t!==null&&t===B}function my(l,t){ya=Fe=!0;var u=l.pending;u===null?t.next=t:(t.next=u.next,u.next=t),l.pending=t}function sy(l,t,u){if((u&4194048)!==0){var a=t.lanes;a&=l.pendingLanes,u|=a,t.lanes=u,gi(l,u)}}var ka={readContext:Ul,use:Pe,useCallback:ml,useContext:ml,useEffect:ml,useImperativeHandle:ml,useLayoutEffect:ml,useInsertionEffect:ml,useMemo:ml,useReducer:ml,useRef:ml,useState:ml,useDebugValue:ml,useDeferredValue:ml,useTransition:ml,useSyncExternalStore:ml,useId:ml,useHostTransitionStatus:ml,useFormState:ml,useActionState:ml,useOptimistic:ml,useMemoCache:ml,useCacheRefresh:ml};ka.useEffectEvent=ml;var dy={readContext:Ul,use:Pe,useCallback:function(l,t){return Yl().memoizedState=[l,t===void 0?null:t],l},useContext:Ul,useEffect:F0,useImperativeHandle:function(l,t,u){u=u!=null?u.concat([l]):null,tn(4194308,4,ly.bind(null,t,l),u)},useLayoutEffect:function(l,t){return tn(4194308,4,l,t)},useInsertionEffect:function(l,t){tn(4,2,l,t)},useMemo:function(l,t){var u=Yl();t=t===void 0?null:t;var a=l();if(Yu){Wt(!0);try{l()}finally{Wt(!1)}}return u.memoizedState=[a,t],a},useReducer:function(l,t,u){var a=Yl();if(u!==void 0){var e=u(t);if(Yu){Wt(!0);try{u(t)}finally{Wt(!1)}}}else e=t;return a.memoizedState=a.baseState=e,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:e},a.queue=l,l=l.dispatch=xm.bind(null,B,l),[a.memoizedState,l]},useRef:function(l){var t=Yl();return l={current:l},t.memoizedState=l},useState:function(l){l=Wf(l);var t=l.queue,u=vy.bind(null,B,t);return t.dispatch=u,[l.memoizedState,u]},useDebugValue:kf,useDeferredValue:function(l,t){var u=Yl();return If(u,l,t)},useTransition:function(){var l=Wf(!1);return l=ny.bind(null,B,l.queue,!0,!1),Yl().memoizedState=l,[!1,l]},useSyncExternalStore:function(l,t,u){var a=B,e=Yl();if(L){if(u===void 0)throw Error(o(407));u=u()}else{if(u=t(),nl===null)throw Error(o(349));(Z&127)!==0||C0(a,t,u)}e.memoizedState=u;var n={value:u,getSnapshot:t};return e.queue=n,F0(B0.bind(null,a,n,l),[l]),a.flags|=2048,ma(9,{destroy:void 0},Y0.bind(null,a,n,u,t),null),u},useId:function(){var l=Yl(),t=nl.identifierPrefix;if(L){var u=Ot,a=_t;u=(a&~(1<<32-kl(a)-1)).toString(32)+u,t="_"+t+"R_"+u,u=ke++,0<\/script>",n=n.removeChild(n.firstChild);break;case"select":n=typeof a.is=="string"?f.createElement("select",{is:a.is}):f.createElement("select"),a.multiple?n.multiple=!0:a.size&&(n.size=a.size);break;default:n=typeof a.is=="string"?f.createElement(e,{is:a.is}):f.createElement(e)}}n[Ml]=t,n[jl]=a;l:for(f=t.child;f!==null;){if(f.tag===5||f.tag===6)n.appendChild(f.stateNode);else if(f.tag!==4&&f.tag!==27&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===t)break l;for(;f.sibling===null;){if(f.return===null||f.return===t)break l;f=f.return}f.sibling.return=f.return,f=f.sibling}t.stateNode=n;l:switch(Hl(n,e,a),e){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break l;case"img":a=!0;break l;default:a=!1}a&&Qt(t)}}return cl(t),oc(t,t.type,l===null?null:l.memoizedProps,t.pendingProps,u),null;case 6:if(l&&t.stateNode!=null)l.memoizedProps!==a&&Qt(t);else{if(typeof a!="string"&&t.stateNode===null)throw Error(o(166));if(l=X.current,ua(t)){if(l=t.stateNode,u=t.memoizedProps,a=null,e=Dl,e!==null)switch(e.tag){case 27:case 5:a=e.memoizedProps}l[Ml]=t,l=!!(l.nodeValue===u||a!==null&&a.suppressHydrationWarning===!0||Rv(l.nodeValue,u)),l||Pt(t,!0)}else l=On(l).createTextNode(a),l[Ml]=t,t.stateNode=l}return cl(t),null;case 31:if(u=t.memoizedState,l===null||l.memoizedState!==null){if(a=ua(t),u!==null){if(l===null){if(!a)throw Error(o(318));if(l=t.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(o(557));l[Ml]=t}else ru(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;cl(t),l=!1}else u=Mf(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=u),l=!0;if(!l)return t.flags&256?(tt(t),t):(tt(t),null);if((t.flags&128)!==0)throw Error(o(558))}return cl(t),null;case 13:if(a=t.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(e=ua(t),a!==null&&a.dehydrated!==null){if(l===null){if(!e)throw Error(o(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));e[Ml]=t}else ru(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;cl(t),e=!1}else e=Mf(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=e),e=!0;if(!e)return t.flags&256?(tt(t),t):(tt(t),null)}return tt(t),(t.flags&128)!==0?(t.lanes=u,t):(u=a!==null,l=l!==null&&l.memoizedState!==null,u&&(a=t.child,e=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(e=a.alternate.memoizedState.cachePool.pool),n=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(n=a.memoizedState.cachePool.pool),n!==e&&(a.flags|=2048)),u!==l&&u&&(t.child.flags|=8192),yn(t,t.updateQueue),cl(t),null);case 4:return dl(),l===null&&Gc(t.stateNode.containerInfo),cl(t),null;case 10:return Yt(t.type),cl(t),null;case 19:if(E(hl),a=t.memoizedState,a===null)return cl(t),null;if(e=(t.flags&128)!==0,n=a.rendering,n===null)if(e)Pa(a,!1);else{if(sl!==0||l!==null&&(l.flags&128)!==0)for(l=t.child;l!==null;){if(n=$e(l),n!==null){for(t.flags|=128,Pa(a,!1),l=n.updateQueue,t.updateQueue=l,yn(t,l),t.subtreeFlags=0,l=u,u=t.child;u!==null;)v0(u,l),u=u.sibling;return O(hl,hl.current&1|2),L&&qt(t,a.treeForkCount),t.child}l=l.sibling}a.tail!==null&&$l()>hn&&(t.flags|=128,e=!0,Pa(a,!1),t.lanes=4194304)}else{if(!e)if(l=$e(n),l!==null){if(t.flags|=128,e=!0,l=l.updateQueue,t.updateQueue=l,yn(t,l),Pa(a,!0),a.tail===null&&a.tailMode==="hidden"&&!n.alternate&&!L)return cl(t),null}else 2*$l()-a.renderingStartTime>hn&&u!==536870912&&(t.flags|=128,e=!0,Pa(a,!1),t.lanes=4194304);a.isBackwards?(n.sibling=t.child,t.child=n):(l=a.last,l!==null?l.sibling=n:t.child=n,a.last=n)}return a.tail!==null?(l=a.tail,a.rendering=l,a.tail=l.sibling,a.renderingStartTime=$l(),l.sibling=null,u=hl.current,O(hl,e?u&1|2:u&1),L&&qt(t,a.treeForkCount),l):(cl(t),null);case 22:case 23:return tt(t),Xf(),a=t.memoizedState!==null,l!==null?l.memoizedState!==null!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?(u&536870912)!==0&&(t.flags&128)===0&&(cl(t),t.subtreeFlags&6&&(t.flags|=8192)):cl(t),u=t.updateQueue,u!==null&&yn(t,u.retryQueue),u=null,l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(u=l.memoizedState.cachePool.pool),a=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),a!==u&&(t.flags|=2048),l!==null&&E(pu),null;case 24:return u=null,l!==null&&(u=l.memoizedState.cache),t.memoizedState.cache!==u&&(t.flags|=2048),Yt(gl),cl(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function Wm(l,t){switch(_f(t),t.tag){case 1:return l=t.flags,l&65536?(t.flags=l&-65537|128,t):null;case 3:return Yt(gl),dl(),l=t.flags,(l&65536)!==0&&(l&128)===0?(t.flags=l&-65537|128,t):null;case 26:case 27:case 5:return ze(t),null;case 31:if(t.memoizedState!==null){if(tt(t),t.alternate===null)throw Error(o(340));ru()}return l=t.flags,l&65536?(t.flags=l&-65537|128,t):null;case 13:if(tt(t),l=t.memoizedState,l!==null&&l.dehydrated!==null){if(t.alternate===null)throw Error(o(340));ru()}return l=t.flags,l&65536?(t.flags=l&-65537|128,t):null;case 19:return E(hl),null;case 4:return dl(),null;case 10:return Yt(t.type),null;case 22:case 23:return tt(t),Xf(),l!==null&&E(pu),l=t.flags,l&65536?(t.flags=l&-65537|128,t):null;case 24:return Yt(gl),null;case 25:return null;default:return null}}function Gy(l,t){switch(_f(t),t.tag){case 3:Yt(gl),dl();break;case 26:case 27:case 5:ze(t);break;case 4:dl();break;case 31:t.memoizedState!==null&&tt(t);break;case 13:tt(t);break;case 19:E(hl);break;case 10:Yt(t.type);break;case 22:case 23:tt(t),Xf(),l!==null&&E(pu);break;case 24:Yt(gl)}}function le(l,t){try{var u=t.updateQueue,a=u!==null?u.lastEffect:null;if(a!==null){var e=a.next;u=e;do{if((u.tag&l)===l){a=void 0;var n=u.create,f=u.inst;a=n(),f.destroy=a}u=u.next}while(u!==e)}}catch(c){I(t,t.return,c)}}function fu(l,t,u){try{var a=t.updateQueue,e=a!==null?a.lastEffect:null;if(e!==null){var n=e.next;a=n;do{if((a.tag&l)===l){var f=a.inst,c=f.destroy;if(c!==void 0){f.destroy=void 0,e=t;var i=u,d=c;try{d()}catch(g){I(e,i,g)}}}a=a.next}while(a!==n)}}catch(g){I(t,t.return,g)}}function Xy(l){var t=l.updateQueue;if(t!==null){var u=l.stateNode;try{r0(t,u)}catch(a){I(l,l.return,a)}}}function Qy(l,t,u){u.props=Bu(l.type,l.memoizedProps),u.state=l.memoizedState;try{u.componentWillUnmount()}catch(a){I(l,t,a)}}function te(l,t){try{var u=l.ref;if(u!==null){switch(l.tag){case 26:case 27:case 5:var a=l.stateNode;break;case 30:a=l.stateNode;break;default:a=l.stateNode}typeof u=="function"?l.refCleanup=u(a):u.current=a}}catch(e){I(l,t,e)}}function Mt(l,t){var u=l.ref,a=l.refCleanup;if(u!==null)if(typeof a=="function")try{a()}catch(e){I(l,t,e)}finally{l.refCleanup=null,l=l.alternate,l!=null&&(l.refCleanup=null)}else if(typeof u=="function")try{u(null)}catch(e){I(l,t,e)}else u.current=null}function jy(l){var t=l.type,u=l.memoizedProps,a=l.stateNode;try{l:switch(t){case"button":case"input":case"select":case"textarea":u.autoFocus&&a.focus();break l;case"img":u.src?a.src=u.src:u.srcSet&&(a.srcset=u.srcSet)}}catch(e){I(l,l.return,e)}}function Sc(l,t,u){try{var a=l.stateNode;Ss(a,l.type,u,t),a[jl]=t}catch(e){I(l,l.return,e)}}function Zy(l){return l.tag===5||l.tag===3||l.tag===26||l.tag===27&&du(l.type)||l.tag===4}function gc(l){l:for(;;){for(;l.sibling===null;){if(l.return===null||Zy(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.tag===27&&du(l.type)||l.flags&2||l.child===null||l.tag===4)continue l;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function bc(l,t,u){var a=l.tag;if(a===5||a===6)l=l.stateNode,t?(u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u).insertBefore(l,t):(t=u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u,t.appendChild(l),u=u._reactRootContainer,u!=null||t.onclick!==null||(t.onclick=Nt));else if(a!==4&&(a===27&&du(l.type)&&(u=l.stateNode,t=null),l=l.child,l!==null))for(bc(l,t,u),l=l.sibling;l!==null;)bc(l,t,u),l=l.sibling}function vn(l,t,u){var a=l.tag;if(a===5||a===6)l=l.stateNode,t?u.insertBefore(l,t):u.appendChild(l);else if(a!==4&&(a===27&&du(l.type)&&(u=l.stateNode),l=l.child,l!==null))for(vn(l,t,u),l=l.sibling;l!==null;)vn(l,t,u),l=l.sibling}function Vy(l){var t=l.stateNode,u=l.memoizedProps;try{for(var a=l.type,e=t.attributes;e.length;)t.removeAttributeNode(e[0]);Hl(t,a,u),t[Ml]=l,t[jl]=u}catch(n){I(l,l.return,n)}}var jt=!1,Tl=!1,zc=!1,xy=typeof WeakSet=="function"?WeakSet:Set,_l=null;function $m(l,t){if(l=l.containerInfo,jc=pn,l=t0(l),sf(l)){if("selectionStart"in l)var u={start:l.selectionStart,end:l.selectionEnd};else l:{u=(u=l.ownerDocument)&&u.defaultView||window;var a=u.getSelection&&u.getSelection();if(a&&a.rangeCount!==0){u=a.anchorNode;var e=a.anchorOffset,n=a.focusNode;a=a.focusOffset;try{u.nodeType,n.nodeType}catch{u=null;break l}var f=0,c=-1,i=-1,d=0,g=0,T=l,h=null;t:for(;;){for(var S;T!==u||e!==0&&T.nodeType!==3||(c=f+e),T!==n||a!==0&&T.nodeType!==3||(i=f+a),T.nodeType===3&&(f+=T.nodeValue.length),(S=T.firstChild)!==null;)h=T,T=S;for(;;){if(T===l)break t;if(h===u&&++d===e&&(c=f),h===n&&++g===a&&(i=f),(S=T.nextSibling)!==null)break;T=h,h=T.parentNode}T=S}u=c===-1||i===-1?null:{start:c,end:i}}else u=null}u=u||{start:0,end:0}}else u=null;for(Zc={focusedElem:l,selectionRange:u},pn=!1,_l=t;_l!==null;)if(t=_l,l=t.child,(t.subtreeFlags&1028)!==0&&l!==null)l.return=t,_l=l;else for(;_l!==null;){switch(t=_l,n=t.alternate,l=t.flags,t.tag){case 0:if((l&4)!==0&&(l=t.updateQueue,l=l!==null?l.events:null,l!==null))for(u=0;u title"))),Hl(n,a,u),n[Ml]=l,Al(n),a=n;break l;case"link":var f=$v("link","href",e).get(a+(u.href||""));if(f){for(var c=0;cul&&(f=ul,ul=p,p=f);var m=Pi(c,p),y=Pi(c,ul);if(m&&y&&(S.rangeCount!==1||S.anchorNode!==m.node||S.anchorOffset!==m.offset||S.focusNode!==y.node||S.focusOffset!==y.offset)){var s=T.createRange();s.setStart(m.node,m.offset),S.removeAllRanges(),p>ul?(S.addRange(s),S.extend(y.node,y.offset)):(s.setEnd(y.node,y.offset),S.addRange(s))}}}}for(T=[],S=c;S=S.parentNode;)S.nodeType===1&&T.push({element:S,left:S.scrollLeft,top:S.scrollTop});for(typeof c.focus=="function"&&c.focus(),c=0;cu?32:u,b.T=null,u=Dc,Dc=null;var n=vu,f=Kt;if(El=0,Sa=vu=null,Kt=0,(w&6)!==0)throw Error(o(331));var c=w;if(w|=4,lv(n.current),ky(n,n.current,f,u),w=c,ce(0,!1),Fl&&typeof Fl.onPostCommitFiberRoot=="function")try{Fl.onPostCommitFiberRoot(Ma,n)}catch{}return!0}finally{_.p=e,b.T=a,bv(l,t)}}function Tv(l,t,u){t=yt(u,t),t=nc(l.stateNode,t,2),l=au(l,t,2),l!==null&&(Ua(l,2),Dt(l))}function I(l,t,u){if(l.tag===3)Tv(l,l,u);else for(;t!==null;){if(t.tag===3){Tv(t,l,u);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(yu===null||!yu.has(a))){l=yt(u,l),u=Ey(2),a=au(t,u,2),a!==null&&(Ay(u,a,t,l),Ua(a,2),Dt(a));break}}t=t.return}}function Nc(l,t,u){var a=l.pingCache;if(a===null){a=l.pingCache=new Im;var e=new Set;a.set(t,e)}else e=a.get(t),e===void 0&&(e=new Set,a.set(t,e));e.has(u)||(Ac=!0,e.add(u),l=as.bind(null,l,t,u),t.then(l,l))}function as(l,t,u){var a=l.pingCache;a!==null&&a.delete(t),l.pingedLanes|=l.suspendedLanes&u,l.warmLanes&=~u,nl===l&&(Z&u)===u&&(sl===4||sl===3&&(Z&62914560)===Z&&300>$l()-dn?(w&2)===0&&ga(l,0):_c|=u,oa===Z&&(oa=0)),Dt(l)}function Ev(l,t){t===0&&(t=oi()),l=Du(l,t),l!==null&&(Ua(l,t),Dt(l))}function es(l){var t=l.memoizedState,u=0;t!==null&&(u=t.retryLane),Ev(l,u)}function ns(l,t){var u=0;switch(l.tag){case 31:case 13:var a=l.stateNode,e=l.memoizedState;e!==null&&(u=e.retryLane);break;case 19:a=l.stateNode;break;case 22:a=l.stateNode._retryCache;break;default:throw Error(o(314))}a!==null&&a.delete(t),Ev(l,u)}function fs(l,t){return Vn(l,t)}var Tn=null,za=null,pc=!1,En=!1,Rc=!1,su=0;function Dt(l){l!==za&&l.next===null&&(za===null?Tn=za=l:za=za.next=l),En=!0,pc||(pc=!0,is())}function ce(l,t){if(!Rc&&En){Rc=!0;do for(var u=!1,a=Tn;a!==null;){if(l!==0){var e=a.pendingLanes;if(e===0)var n=0;else{var f=a.suspendedLanes,c=a.pingedLanes;n=(1<<31-kl(42|l)+1)-1,n&=e&~(f&~c),n=n&201326741?n&201326741|1:n?n|2:0}n!==0&&(u=!0,Mv(a,n))}else n=Z,n=Oe(a,a===nl?n:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(n&3)===0||Da(a,n)||(u=!0,Mv(a,n));a=a.next}while(u);Rc=!1}}function cs(){Av()}function Av(){En=pc=!1;var l=0;su!==0&&bs()&&(l=su);for(var t=$l(),u=null,a=Tn;a!==null;){var e=a.next,n=_v(a,t);n===0?(a.next=null,u===null?Tn=e:u.next=e,e===null&&(za=u)):(u=a,(l!==0||(n&3)!==0)&&(En=!0)),a=e}El!==0&&El!==5||ce(l),su!==0&&(su=0)}function _v(l,t){for(var u=l.suspendedLanes,a=l.pingedLanes,e=l.expirationTimes,n=l.pendingLanes&-62914561;0c)break;var g=i.transferSize,T=i.initiatorType;g&&qv(T)&&(i=i.responseEnd,f+=g*(i"u"?null:document;function Kv(l,t,u){var a=Ta;if(a&&typeof t=="string"&&t){var e=ct(t);e='link[rel="'+l+'"][href="'+e+'"]',typeof u=="string"&&(e+='[crossorigin="'+u+'"]'),Lv.has(e)||(Lv.add(e),l={rel:l,crossOrigin:u,href:t},a.querySelector(e)===null&&(t=a.createElement("link"),Hl(t,"link",l),Al(t),a.head.appendChild(t)))}}function Us(l){Jt.D(l),Kv("dns-prefetch",l,null)}function rs(l,t){Jt.C(l,t),Kv("preconnect",l,t)}function Hs(l,t,u){Jt.L(l,t,u);var a=Ta;if(a&&l&&t){var e='link[rel="preload"][as="'+ct(t)+'"]';t==="image"&&u&&u.imageSrcSet?(e+='[imagesrcset="'+ct(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(e+='[imagesizes="'+ct(u.imageSizes)+'"]')):e+='[href="'+ct(l)+'"]';var n=e;switch(t){case"style":n=Ea(l);break;case"script":n=Aa(l)}ot.has(n)||(l=R({rel:"preload",href:t==="image"&&u&&u.imageSrcSet?void 0:l,as:t},u),ot.set(n,l),a.querySelector(e)!==null||t==="style"&&a.querySelector(me(n))||t==="script"&&a.querySelector(se(n))||(t=a.createElement("link"),Hl(t,"link",l),Al(t),a.head.appendChild(t)))}}function Ns(l,t){Jt.m(l,t);var u=Ta;if(u&&l){var a=t&&typeof t.as=="string"?t.as:"script",e='link[rel="modulepreload"][as="'+ct(a)+'"][href="'+ct(l)+'"]',n=e;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":n=Aa(l)}if(!ot.has(n)&&(l=R({rel:"modulepreload",href:l},t),ot.set(n,l),u.querySelector(e)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(se(n)))return}a=u.createElement("link"),Hl(a,"link",l),Al(a),u.head.appendChild(a)}}}function ps(l,t,u){Jt.S(l,t,u);var a=Ta;if(a&&l){var e=xu(a).hoistableStyles,n=Ea(l);t=t||"default";var f=e.get(n);if(!f){var c={loading:0,preload:null};if(f=a.querySelector(me(n)))c.loading=5;else{l=R({rel:"stylesheet",href:l,"data-precedence":t},u),(u=ot.get(n))&&Wc(l,u);var i=f=a.createElement("link");Al(i),Hl(i,"link",l),i._p=new Promise(function(d,g){i.onload=d,i.onerror=g}),i.addEventListener("load",function(){c.loading|=1}),i.addEventListener("error",function(){c.loading|=2}),c.loading|=4,Dn(f,t,a)}f={type:"stylesheet",instance:f,count:1,state:c},e.set(n,f)}}}function Rs(l,t){Jt.X(l,t);var u=Ta;if(u&&l){var a=xu(u).hoistableScripts,e=Aa(l),n=a.get(e);n||(n=u.querySelector(se(e)),n||(l=R({src:l,async:!0},t),(t=ot.get(e))&&$c(l,t),n=u.createElement("script"),Al(n),Hl(n,"link",l),u.head.appendChild(n)),n={type:"script",instance:n,count:1,state:null},a.set(e,n))}}function qs(l,t){Jt.M(l,t);var u=Ta;if(u&&l){var a=xu(u).hoistableScripts,e=Aa(l),n=a.get(e);n||(n=u.querySelector(se(e)),n||(l=R({src:l,async:!0,type:"module"},t),(t=ot.get(e))&&$c(l,t),n=u.createElement("script"),Al(n),Hl(n,"link",l),u.head.appendChild(n)),n={type:"script",instance:n,count:1,state:null},a.set(e,n))}}function Jv(l,t,u,a){var e=(e=X.current)?Mn(e):null;if(!e)throw Error(o(446));switch(l){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(t=Ea(u.href),u=xu(e).hoistableStyles,a=u.get(t),a||(a={type:"style",instance:null,count:0,state:null},u.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){l=Ea(u.href);var n=xu(e).hoistableStyles,f=n.get(l);if(f||(e=e.ownerDocument||e,f={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},n.set(l,f),(n=e.querySelector(me(l)))&&!n._p&&(f.instance=n,f.state.loading=5),ot.has(l)||(u={rel:"preload",as:"style",href:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.referrerPolicy},ot.set(l,u),n||Cs(e,l,u,f.state))),t&&a===null)throw Error(o(528,""));return f}if(t&&a!==null)throw Error(o(529,""));return null;case"script":return t=u.async,u=u.src,typeof u=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Aa(u),u=xu(e).hoistableScripts,a=u.get(t),a||(a={type:"script",instance:null,count:0,state:null},u.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,l))}}function Ea(l){return'href="'+ct(l)+'"'}function me(l){return'link[rel="stylesheet"]['+l+"]"}function wv(l){return R({},l,{"data-precedence":l.precedence,precedence:null})}function Cs(l,t,u,a){l.querySelector('link[rel="preload"][as="style"]['+t+"]")?a.loading=1:(t=l.createElement("link"),a.preload=t,t.addEventListener("load",function(){return a.loading|=1}),t.addEventListener("error",function(){return a.loading|=2}),Hl(t,"link",u),Al(t),l.head.appendChild(t))}function Aa(l){return'[src="'+ct(l)+'"]'}function se(l){return"script[async]"+l}function Wv(l,t,u){if(t.count++,t.instance===null)switch(t.type){case"style":var a=l.querySelector('style[data-href~="'+ct(u.href)+'"]');if(a)return t.instance=a,Al(a),a;var e=R({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return a=(l.ownerDocument||l).createElement("style"),Al(a),Hl(a,"style",e),Dn(a,u.precedence,l),t.instance=a;case"stylesheet":e=Ea(u.href);var n=l.querySelector(me(e));if(n)return t.state.loading|=4,t.instance=n,Al(n),n;a=wv(u),(e=ot.get(e))&&Wc(a,e),n=(l.ownerDocument||l).createElement("link"),Al(n);var f=n;return f._p=new Promise(function(c,i){f.onload=c,f.onerror=i}),Hl(n,"link",a),t.state.loading|=4,Dn(n,u.precedence,l),t.instance=n;case"script":return n=Aa(u.src),(e=l.querySelector(se(n)))?(t.instance=e,Al(e),e):(a=u,(e=ot.get(n))&&(a=R({},u),$c(a,e)),l=l.ownerDocument||l,e=l.createElement("script"),Al(e),Hl(e,"link",a),l.head.appendChild(e),t.instance=e);case"void":return null;default:throw Error(o(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(a=t.instance,t.state.loading|=4,Dn(a,u.precedence,l));return t.instance}function Dn(l,t,u){for(var a=u.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),e=a.length?a[a.length-1]:null,n=e,f=0;f title"):null)}function Ys(l,t,u){if(u===1||t.itemProp!=null)return!1;switch(l){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return l=t.disabled,typeof t.precedence=="string"&&l==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function kv(l){return!(l.type==="stylesheet"&&(l.state.loading&3)===0)}function Bs(l,t,u,a){if(u.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var e=Ea(a.href),n=t.querySelector(me(e));if(n){t=n._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(l.count++,l=rn.bind(l),t.then(l,l)),u.state.loading|=4,u.instance=n,Al(n);return}n=t.ownerDocument||t,a=wv(a),(e=ot.get(e))&&Wc(a,e),n=n.createElement("link"),Al(n);var f=n;f._p=new Promise(function(c,i){f.onload=c,f.onerror=i}),Hl(n,"link",a),u.instance=n}l.stylesheets===null&&(l.stylesheets=new Map),l.stylesheets.set(u,t),(t=u.state.preload)&&(u.state.loading&3)===0&&(l.count++,u=rn.bind(l),t.addEventListener("load",u),t.addEventListener("error",u))}}var Fc=0;function Gs(l,t){return l.stylesheets&&l.count===0&&Nn(l,l.stylesheets),0Fc?50:800)+t);return l.unsuspend=u,function(){l.unsuspend=null,clearTimeout(a),clearTimeout(e)}}:null}function rn(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Nn(this,this.stylesheets);else if(this.unsuspend){var l=this.unsuspend;this.unsuspend=null,l()}}}var Hn=null;function Nn(l,t){l.stylesheets=null,l.unsuspend!==null&&(l.count++,Hn=new Map,t.forEach(Xs,l),Hn=null,rn.call(l))}function Xs(l,t){if(!(t.state.loading&4)){var u=Hn.get(l);if(u)var a=u.get(null);else{u=new Map,Hn.set(l,u);for(var e=l.querySelectorAll("link[data-precedence],style[data-precedence]"),n=0;n"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(M)}catch(Sl){console.error(Sl)}}return M(),ni.exports=td(),ni.exports}var ad=ud();const fd=E1(ad);var cd=_1();export{nd as R,yi as a,cd as b,fd as c,ks as d,E1 as g,ed as j,A1 as r}; diff --git a/internal/webui/static/squircle.svg b/internal/webui/static/assets/squircle-rb6SKa34.svg similarity index 100% rename from internal/webui/static/squircle.svg rename to internal/webui/static/assets/squircle-rb6SKa34.svg diff --git a/internal/webui/static/assets/vendor-w5t2K9ux.js b/internal/webui/static/assets/vendor-w5t2K9ux.js new file mode 100644 index 0000000..e49d4a5 --- /dev/null +++ b/internal/webui/static/assets/vendor-w5t2K9ux.js @@ -0,0 +1,33 @@ +var Yn=Object.defineProperty;var Gn=(e,t,r)=>t in e?Yn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Oe=(e,t,r)=>Gn(e,typeof t!="symbol"?t+"":t,r);import{a as qt,r as K,g as Xn}from"./react-vendor-DZnRGM0-.js";function qr(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;tObject.prototype.propertyIsEnumerable.call(e,t))}function Ht(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const ei="[object RegExp]",Hr="[object String]",Kr="[object Number]",Zr="[object Boolean]",Jr="[object Arguments]",ti="[object Symbol]",ri="[object Date]",ni="[object Map]",ii="[object Set]",si="[object Array]",oi="[object ArrayBuffer]",fi="[object Object]",ui="[object DataView]",ci="[object Uint8Array]",ai="[object Uint8ClampedArray]",li="[object Uint16Array]",di="[object Uint32Array]",hi="[object Int8Array]",pi="[object Int16Array]",yi="[object Int32Array]",mi="[object Float32Array]",_i="[object Float64Array]",sr=typeof globalThis=="object"&&globalThis||typeof window=="object"&&window||typeof self=="object"&&self||typeof global=="object"&&global||(function(){return this})();function gi(e){return typeof sr.Buffer<"u"&&sr.Buffer.isBuffer(e)}function wi(e,t){return te(e,void 0,e,new Map,t)}function te(e,t,r,n=new Map,i=void 0){const s=i==null?void 0:i(e,t,r,n);if(s!==void 0)return s;if(Pt(e))return e;if(n.has(e))return n.get(e);if(Array.isArray(e)){const o=new Array(e.length);n.set(e,o);for(let f=0;f{}):Ot(e,t,function n(i,s,o,f,u,a){const c=r(i,s,o,f,u,a);return c!==void 0?!!c:Ot(i,s,n,a,!1)},new Map,!0)}function Ot(e,t,r,n,i=!1){if(t===e)return!0;switch(typeof t){case"object":return Si(e,t,r,n);case"function":return Object.keys(t).length>0?Ot(e,{...t},r,n,i):De(e,t);default:return Vr(e)&&i?typeof t=="string"?t==="":!0:De(e,t)}}function Si(e,t,r,n){if(t==null)return!0;if(Array.isArray(t))return en(e,t,r,n);if(t instanceof Map)return vi(e,t,r,n);if(t instanceof Set)return Ai(e,t,r,n);const i=Object.keys(t);if(e==null||Pt(e))return i.length===0;if(i.length===0)return!0;if(n!=null&&n.has(t))return n.get(t)===e;n==null||n.set(t,e);try{for(let s=0;s{})}function Pi(e){return e=Ei(e),t=>tn(t,e)}function Oi(e,t){return wi(e,(r,n,i,s)=>{if(typeof e=="object"){if(Ht(e)==="[object Object]"&&typeof e.constructor!="function"){const o={};return s.set(e,o),j(o,e,i,s),o}switch(Object.prototype.toString.call(e)){case Kr:case Hr:case Zr:{const o=new e.constructor(e==null?void 0:e.valueOf());return j(o,e),o}case Jr:{const o={};return j(o,e),o.length=e.length,o[Symbol.iterator]=e[Symbol.iterator],o}default:return}}})}function Ri(e){return Oi(e)}const Mi=/^(?:0|[1-9]\d*)$/;function rn(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&e=0}function nn(e){return e!=null&&typeof e!="function"&&$i(e.length)}function ki(e){return typeof e=="object"&&e!==null}function Ci(e){return ki(e)&&nn(e)}function Bo(e,t=Xr){return Ci(e)?Kn(Array.from(e),Zn(Di(t),1)):[]}var ft={exports:{}},ut={},ct={exports:{}},at={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var or;function Li(){if(or)return at;or=1;var e=qt();function t(l,m){return l===m&&(l!==0||1/l===1/m)||l!==l&&m!==m}var r=typeof Object.is=="function"?Object.is:t,n=e.useState,i=e.useEffect,s=e.useLayoutEffect,o=e.useDebugValue;function f(l,m){var h=m(),y=n({inst:{value:h,getSnapshot:m}}),d=y[0].inst,p=y[1];return s(function(){d.value=h,d.getSnapshot=m,u(d)&&p({inst:d})},[l,h,m]),i(function(){return u(d)&&p({inst:d}),l(function(){u(d)&&p({inst:d})})},[l]),o(h),h}function u(l){var m=l.getSnapshot;l=l.value;try{var h=m();return!r(l,h)}catch{return!0}}function a(l,m){return m()}var c=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?a:f;return at.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:c,at}var fr;function Fi(){return fr||(fr=1,ct.exports=Li()),ct.exports}/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var ur;function Ti(){if(ur)return ut;ur=1;var e=qt(),t=Fi();function r(a,c){return a===c&&(a!==0||1/a===1/c)||a!==a&&c!==c}var n=typeof Object.is=="function"?Object.is:r,i=t.useSyncExternalStore,s=e.useRef,o=e.useEffect,f=e.useMemo,u=e.useDebugValue;return ut.useSyncExternalStoreWithSelector=function(a,c,l,m,h){var y=s(null);if(y.current===null){var d={hasValue:!1,value:null};y.current=d}else d=y.current;y=f(function(){function g(v){if(!S){if(S=!0,E=v,v=m(v),h!==void 0&&d.hasValue){var A=d.value;if(h(A,v))return w=A}return w=v}if(A=w,n(E,v))return A;var D=m(v);return h!==void 0&&h(A,D)?(E=v,A):(E=v,w=D)}var S=!1,E,w,b=l===void 0?null:l;return[function(){return g(c())},b===null?void 0:function(){return g(b())}]},[c,l,m,h]);var p=i(a,y[0],y[1]);return o(function(){d.hasValue=!0,d.value=p},[p]),u(p),p},ut}var cr;function zi(){return cr||(cr=1,ft.exports=Ti()),ft.exports}var jo=zi();function Ui(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function Bi(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(r=>typeof r=="function")){const r=e.map(n=>typeof n=="function"?`function ${n.name||"unnamed"}()`:typeof n).join(", ");throw new TypeError(`${t}[${r}]`)}}var ar=e=>Array.isArray(e)?e:[e];function ji(e){const t=Array.isArray(e[0])?e[0]:e;return Bi(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function Wi(e,t){const r=[],{length:n}=e;for(let i=0;itypeof WeakRef>"u"?qi:WeakRef,sn=Yi(),Gi=0,lr=1;function Re(){return{s:Gi,v:void 0,o:null,p:null}}function Xi(e){return e instanceof sn?e.deref():e}function on(e,t={}){let r=Re();const{resultEqualityCheck:n}=t;let i,s=0;function o(){let f=r;const{length:u}=arguments;for(let l=0,m=u;l{r=Re(),o.resetResultsCount()},o.resultsCount=()=>s,o.resetResultsCount=()=>{s=0},o}function Hi(e,...t){const r=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,n=(...i)=>{let s=0,o=0,f,u={},a=i.pop();typeof a=="object"&&(u=a,a=i.pop()),Ui(a,`createSelector expects an output function after the inputs, but received: [${typeof a}]`);const c={...r,...u},{memoize:l,memoizeOptions:m=[],argsMemoize:h=on,argsMemoizeOptions:y=[]}=c,d=ar(m),p=ar(y),g=ji(i),S=l(function(){return s++,a.apply(null,arguments)},...d),E=h(function(){o++;const b=Wi(g,arguments);return f=S.apply(null,b),f},...p);return Object.assign(E,{resultFunc:a,memoizedResultFunc:S,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>f,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:l,argsMemoize:h})};return Object.assign(n,{withTypes:()=>n}),n}var Wo=Hi(on);function Ki(e,t=1){const r=[],n=Math.floor(t),i=(s,o)=>{for(let f=0;f{if(e!==t){const n=dr(e),i=dr(t);if(n===i&&n===0){if(et)return r==="desc"?-1:1}return r==="desc"?i-n:n-i}return 0};function fn(e){return typeof e=="symbol"||e instanceof Symbol}const Ji=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Vi=/^\w*$/;function Qi(e,t){return Array.isArray(e)?!1:typeof e=="number"||typeof e=="boolean"||e==null||fn(e)?!0:typeof e=="string"&&(Vi.test(e)||!Ji.test(e))||t!=null}function es(e,t,r,n){if(e==null)return[];r=r,Array.isArray(e)||(e=Object.values(e)),Array.isArray(t)||(t=t==null?[null]:[t]),t.length===0&&(t=[null]),Array.isArray(r)||(r=r==null?[]:[r]),r=r.map(f=>String(f));const i=(f,u)=>{let a=f;for(let c=0;cu==null||f==null?u:typeof f=="object"&&"key"in f?Object.hasOwn(u,f.key)?u[f.key]:i(u,f.path):typeof f=="function"?f(u):Array.isArray(f)?i(u,f):typeof u=="object"?u[f]:u,o=t.map(f=>(Array.isArray(f)&&f.length===1&&(f=f[0]),f==null||typeof f=="function"||Array.isArray(f)||Qi(f)?f:{key:f,path:Gt(f)}));return e.map(f=>({original:f,criteria:o.map(u=>s(u,f))})).slice().sort((f,u)=>{for(let a=0;af.original)}function qo(e,...t){const r=t.length;return r>1&&Rt(e,t[0],t[1])?t=[]:r>2&&Rt(t[0],t[1],t[2])&&(t=[t[0]]),es(e,Ki(t),["asc"])}function k(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var ts=typeof Symbol=="function"&&Symbol.observable||"@@observable",hr=ts,lt=()=>Math.random().toString(36).substring(7).split("").join("."),rs={INIT:`@@redux/INIT${lt()}`,REPLACE:`@@redux/REPLACE${lt()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${lt()}`},Ce=rs;function Kt(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function un(e,t,r){if(typeof e!="function")throw new Error(k(2));if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(k(0));if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(k(1));return r(un)(e,t)}let n=e,i=t,s=new Map,o=s,f=0,u=!1;function a(){o===s&&(o=new Map,s.forEach((p,g)=>{o.set(g,p)}))}function c(){if(u)throw new Error(k(3));return i}function l(p){if(typeof p!="function")throw new Error(k(4));if(u)throw new Error(k(5));let g=!0;a();const S=f++;return o.set(S,p),function(){if(g){if(u)throw new Error(k(6));g=!1,a(),o.delete(S),s=null}}}function m(p){if(!Kt(p))throw new Error(k(7));if(typeof p.type>"u")throw new Error(k(8));if(typeof p.type!="string")throw new Error(k(17));if(u)throw new Error(k(9));try{u=!0,i=n(i,p)}finally{u=!1}return(s=o).forEach(S=>{S()}),p}function h(p){if(typeof p!="function")throw new Error(k(10));n=p,m({type:Ce.REPLACE})}function y(){const p=l;return{subscribe(g){if(typeof g!="object"||g===null)throw new Error(k(11));function S(){const w=g;w.next&&w.next(c())}return S(),{unsubscribe:p(S)}},[hr](){return this}}}return m({type:Ce.INIT}),{dispatch:m,subscribe:l,getState:c,replaceReducer:h,[hr]:y}}function ns(e){Object.keys(e).forEach(t=>{const r=e[t];if(typeof r(void 0,{type:Ce.INIT})>"u")throw new Error(k(12));if(typeof r(void 0,{type:Ce.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(k(13))})}function is(e){const t=Object.keys(e),r={};for(let s=0;s"u")throw f&&f.type,new Error(k(14));a[l]=y,u=u||y!==h}return u=u||n.length!==Object.keys(o).length,u?a:o}}function Le(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,r)=>(...n)=>t(r(...n)))}function ss(...e){return t=>(r,n)=>{const i=t(r,n);let s=()=>{throw new Error(k(15))};const o={getState:i.getState,dispatch:(u,...a)=>s(u,...a)},f=e.map(u=>u(o));return s=Le(...f)(i.dispatch),{...i,dispatch:s}}}function cn(e){return Kt(e)&&"type"in e&&typeof e.type=="string"}var an=Symbol.for("immer-nothing"),pr=Symbol.for("immer-draftable"),C=Symbol.for("immer-state");function W(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var F=Object,ae=F.getPrototypeOf,Fe="constructor",Ke="prototype",Mt="configurable",Te="enumerable",$e="writable",me="value",J=e=>!!e&&!!e[C];function Y(e){var t;return e?ln(e)||Je(e)||!!e[pr]||!!((t=e[Fe])!=null&&t[pr])||Ve(e)||Qe(e):!1}var os=F[Ke][Fe].toString(),yr=new WeakMap;function ln(e){if(!e||!Zt(e))return!1;const t=ae(e);if(t===null||t===F[Ke])return!0;const r=F.hasOwnProperty.call(t,Fe)&&t[Fe];if(r===Object)return!0;if(!ue(r))return!1;let n=yr.get(r);return n===void 0&&(n=Function.toString.call(r),yr.set(r,n)),n===os}function Ze(e,t,r=!0){ve(e)===0?(r?Reflect.ownKeys(e):F.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((n,i)=>t(i,n,e))}function ve(e){const t=e[C];return t?t.type_:Je(e)?1:Ve(e)?2:Qe(e)?3:0}var mr=(e,t,r=ve(e))=>r===2?e.has(t):F[Ke].hasOwnProperty.call(e,t),Nt=(e,t,r=ve(e))=>r===2?e.get(t):e[t],ze=(e,t,r,n=ve(e))=>{n===2?e.set(t,r):n===3?e.add(r):e[t]=r};function fs(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Je=Array.isArray,Ve=e=>e instanceof Map,Qe=e=>e instanceof Set,Zt=e=>typeof e=="object",ue=e=>typeof e=="function",dt=e=>typeof e=="boolean";function us(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var H=e=>e.copy_||e.base_,Jt=e=>e.modified_?e.copy_:e.base_;function It(e,t){if(Ve(e))return new Map(e);if(Qe(e))return new Set(e);if(Je(e))return Array[Ke].slice.call(e);const r=ln(e);if(t===!0||t==="class_only"&&!r){const n=F.getOwnPropertyDescriptors(e);delete n[C];let i=Reflect.ownKeys(n);for(let s=0;s1&&F.defineProperties(e,{set:Me,add:Me,clear:Me,delete:Me}),F.freeze(e),t&&Ze(e,(r,n)=>{Vt(n,!0)},!1)),e}function cs(){W(2)}var Me={[me]:cs};function et(e){return e===null||!Zt(e)?!0:F.isFrozen(e)}var Ue="MapSet",xt="Patches",_r="ArrayMethods",dn={};function ie(e){const t=dn[e];return t||W(0,e),t}var gr=e=>!!dn[e],_e,hn=()=>_e,as=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:gr(Ue)?ie(Ue):void 0,arrayMethodsPlugin_:gr(_r)?ie(_r):void 0});function wr(e,t){t&&(e.patchPlugin_=ie(xt),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Dt(e){$t(e),e.drafts_.forEach(ls),e.drafts_=null}function $t(e){e===_e&&(_e=e.parent_)}var br=e=>_e=as(_e,e);function ls(e){const t=e[C];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Er(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];if(e!==void 0&&e!==r){r[C].modified_&&(Dt(t),W(4)),Y(e)&&(e=Sr(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(r[C].base_,e,t)}else e=Sr(t,r);return ds(t,e,!0),Dt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==an?e:void 0}function Sr(e,t){if(et(t))return t;const r=t[C];if(!r)return Be(t,e.handledSet_,e);if(!tt(r,e))return t;if(!r.modified_)return r.base_;if(!r.finalized_){const{callbacks_:n}=r;if(n)for(;n.length>0;)n.pop()(e);mn(r,e)}return r.copy_}function ds(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Vt(t,r)}function pn(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var tt=(e,t)=>e.scope_===t,hs=[];function yn(e,t,r,n){const i=H(e),s=e.type_;if(n!==void 0&&Nt(i,n,s)===t){ze(i,n,r,s);return}if(!e.draftLocations_){const f=e.draftLocations_=new Map;Ze(i,(u,a)=>{if(J(a)){const c=f.get(a)||[];c.push(u),f.set(a,c)}})}const o=e.draftLocations_.get(t)??hs;for(const f of o)ze(i,f,r,s)}function ps(e,t,r){e.callbacks_.push(function(i){var f;const s=t;if(!s||!tt(s,i))return;(f=i.mapSetPlugin_)==null||f.fixSetContents(s);const o=Jt(s);yn(e,s.draft_??s,o,r),mn(s,i)})}function mn(e,t){var n;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((n=e.assigned_)==null?void 0:n.size)??0)>0)){const{patchPlugin_:i}=t;if(i){const s=i.getPath(e);s&&i.generatePatches_(e,s,t)}pn(e)}}function ys(e,t,r){const{scope_:n}=e;if(J(r)){const i=r[C];tt(i,n)&&i.callbacks_.push(function(){ke(e);const o=Jt(i);yn(e,r,o,t)})}else Y(r)&&e.callbacks_.push(function(){const s=H(e);e.type_===3?s.has(r)&&Be(r,n.handledSet_,n):Nt(s,t,e.type_)===r&&n.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Be(Nt(e.copy_,t,e.type_),n.handledSet_,n)})}function Be(e,t,r){return!r.immer_.autoFreeze_&&r.unfinalizedDrafts_<1||J(e)||t.has(e)||!Y(e)||et(e)||(t.add(e),Ze(e,(n,i)=>{if(J(i)){const s=i[C];if(tt(s,r)){const o=Jt(s);ze(e,n,o,e.type_),pn(s)}}else Y(i)&&Be(i,t,r)})),e}function ms(e,t){const r=Je(e),n={type_:r?1:0,scope_:t?t.scope_:hn(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=n,s=je;r&&(i=[n],s=ge);const{revoke:o,proxy:f}=Proxy.revocable(i,s);return n.draft_=f,n.revoke_=o,[f,n]}var je={get(e,t){if(t===C)return e;let r=e.scope_.arrayMethodsPlugin_;const n=e.type_===1&&typeof t=="string";if(n&&r!=null&&r.isArrayOperationMethod(t))return r.createMethodInterceptor(e,t);const i=H(e);if(!mr(i,t,e.type_))return _s(e,i,t);const s=i[t];if(e.finalized_||!Y(s)||n&&e.operationMethod&&(r!=null&&r.isMutatingArrayMethod(e.operationMethod))&&us(t))return s;if(s===ht(e.base_,t)){ke(e);const o=e.type_===1?+t:t,f=Ct(e.scope_,s,e,o);return e.copy_[o]=f}return s},has(e,t){return t in H(e)},ownKeys(e){return Reflect.ownKeys(H(e))},set(e,t,r){const n=_n(H(e),t);if(n!=null&&n.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const i=ht(H(e),t),s=i==null?void 0:i[C];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_.set(t,!1),!0;if(fs(r,i)&&(r!==void 0||mr(e.base_,t,e.type_)))return!0;ke(e),kt(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_.set(t,!0),ys(e,t,r)),!0},deleteProperty(e,t){return ke(e),ht(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),kt(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=H(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{[$e]:!0,[Mt]:e.type_!==1||t!=="length",[Te]:n[Te],[me]:r[t]}},defineProperty(){W(11)},getPrototypeOf(e){return ae(e.base_)},setPrototypeOf(){W(12)}},ge={};for(let e in je){let t=je[e];ge[e]=function(){const r=arguments;return r[0]=r[0][0],t.apply(this,r)}}ge.deleteProperty=function(e,t){return ge.set.call(this,e,t,void 0)};ge.set=function(e,t,r){return je.set.call(this,e[0],t,r,e[0])};function ht(e,t){const r=e[C];return(r?H(r):e)[t]}function _s(e,t,r){var i;const n=_n(t,r);return n?me in n?n[me]:(i=n.get)==null?void 0:i.call(e.draft_):void 0}function _n(e,t){if(!(t in e))return;let r=ae(e);for(;r;){const n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=ae(r)}}function kt(e){e.modified_||(e.modified_=!0,e.parent_&&kt(e.parent_))}function ke(e){e.copy_||(e.assigned_=new Map,e.copy_=It(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var gs=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(r,n,i)=>{if(ue(r)&&!ue(n)){const o=n;n=r;const f=this;return function(a=o,...c){return f.produce(a,l=>n.call(this,l,...c))}}ue(n)||W(6),i!==void 0&&!ue(i)&&W(7);let s;if(Y(r)){const o=br(this),f=Ct(o,r,void 0);let u=!0;try{s=n(f),u=!1}finally{u?Dt(o):$t(o)}return wr(o,i),Er(s,o)}else if(!r||!Zt(r)){if(s=n(r),s===void 0&&(s=r),s===an&&(s=void 0),this.autoFreeze_&&Vt(s,!0),i){const o=[],f=[];ie(xt).generateReplacementPatches_(r,s,{patches_:o,inversePatches_:f}),i(o,f)}return s}else W(1,r)},this.produceWithPatches=(r,n)=>{if(ue(r))return(f,...u)=>this.produceWithPatches(f,a=>r(a,...u));let i,s;return[this.produce(r,n,(f,u)=>{i=f,s=u}),i,s]},dt(t==null?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),dt(t==null?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),dt(t==null?void 0:t.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){Y(t)||W(8),J(t)&&(t=ws(t));const r=br(this),n=Ct(r,t,void 0);return n[C].isManual_=!0,$t(r),n}finishDraft(t,r){const n=t&&t[C];(!n||!n.isManual_)&&W(9);const{scope_:i}=n;return wr(i,r),Er(void 0,i)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,r){let n;for(n=r.length-1;n>=0;n--){const s=r[n];if(s.path.length===0&&s.op==="replace"){t=s.value;break}}n>-1&&(r=r.slice(n+1));const i=ie(xt).applyPatches_;return J(t)?i(t,r):this.produce(t,s=>i(s,r))}};function Ct(e,t,r,n){const[i,s]=Ve(t)?ie(Ue).proxyMap_(t,r):Qe(t)?ie(Ue).proxySet_(t,r):ms(t,r);return((r==null?void 0:r.scope_)??hn()).drafts_.push(i),s.callbacks_=(r==null?void 0:r.callbacks_)??[],s.key_=n,r&&n!==void 0?ps(r,s,n):s.callbacks_.push(function(u){var c;(c=u.mapSetPlugin_)==null||c.fixSetContents(s);const{patchPlugin_:a}=u;s.modified_&&a&&a.generatePatches_(s,[],u)}),i}function ws(e){return J(e)||W(10,e),gn(e)}function gn(e){if(!Y(e)||et(e))return e;const t=e[C];let r,n=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=It(e,t.scope_.immer_.useStrictShallowCopy_),n=t.scope_.immer_.shouldUseStrictIteration()}else r=It(e,!0);return Ze(r,(i,s)=>{ze(r,i,gn(s))},n),t&&(t.finalized_=!1),r}var bs=new gs,wn=bs.produce;function bn(e){return({dispatch:r,getState:n})=>i=>s=>typeof s=="function"?s(r,n,e):i(s)}var Es=bn(),Ss=bn,vs=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Le:Le.apply(null,arguments)};function le(e,t){function r(...n){if(t){let i=t(...n);if(!i)throw new Error(T(0));return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:n[0]}}return r.toString=()=>`${e}`,r.type=e,r.match=n=>cn(n)&&n.type===e,r}var En=class ye extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,ye.prototype)}static get[Symbol.species](){return ye}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new ye(...t[0].concat(this)):new ye(...t.concat(this))}};function vr(e){return Y(e)?wn(e,()=>{}):e}function Ne(e,t,r){return e.has(t)?e.get(t):e.set(t,r(t)).get(t)}function As(e){return typeof e=="boolean"}var Ps=()=>function(t){const{thunk:r=!0,immutableCheck:n=!0,serializableCheck:i=!0,actionCreatorCheck:s=!0}=t??{};let o=new En;return r&&(As(r)?o.push(Es):o.push(Ss(r.extraArgument))),o},Sn="RTK_autoBatch",Go=()=>e=>({payload:e,meta:{[Sn]:!0}}),Ar=e=>t=>{setTimeout(t,e)},Os=(e,t)=>r=>{let n=!1;const i=()=>{n||(n=!0,cancelAnimationFrame(s),clearTimeout(o),r())},s=e(i),o=setTimeout(i,t)},Rs=(e={type:"raf"})=>t=>(...r)=>{const n=t(...r);let i=!0,s=!1,o=!1;const f=new Set,u=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?Os(window.requestAnimationFrame,100):Ar(10):e.type==="callback"?e.queueNotification:Ar(e.timeout),a=()=>{o=!1,s&&(s=!1,f.forEach(c=>c()))};return Object.assign({},n,{subscribe(c){const l=()=>i&&c(),m=n.subscribe(l);return f.add(c),()=>{m(),f.delete(c)}},dispatch(c){var l;try{return i=!((l=c==null?void 0:c.meta)!=null&&l[Sn]),s=!i,s&&(o||(o=!0,u(a))),n.dispatch(c)}finally{i=!0}}})},Ms=e=>function(r){const{autoBatch:n=!0}=r??{};let i=new En(e);return n&&i.push(Rs(typeof n=="object"?n:void 0)),i};function Xo(e){const t=Ps(),{reducer:r=void 0,middleware:n,devTools:i=!0,preloadedState:s=void 0,enhancers:o=void 0}=e||{};let f;if(typeof r=="function")f=r;else if(Kt(r))f=is(r);else throw new Error(T(1));let u;typeof n=="function"?u=n(t):u=t();let a=Le;i&&(a=vs({trace:!1,...typeof i=="object"&&i}));const c=ss(...u),l=Ms(c);let m=typeof o=="function"?o(l):l();const h=a(...m);return un(f,s,h)}function vn(e){const t={},r=[];let n;const i={addCase(s,o){const f=typeof s=="string"?s:s.type;if(!f)throw new Error(T(28));if(f in t)throw new Error(T(29));return t[f]=o,i},addAsyncThunk(s,o){return o.pending&&(t[s.pending.type]=o.pending),o.rejected&&(t[s.rejected.type]=o.rejected),o.fulfilled&&(t[s.fulfilled.type]=o.fulfilled),o.settled&&r.push({matcher:s.settled,reducer:o.settled}),i},addMatcher(s,o){return r.push({matcher:s,reducer:o}),i},addDefaultCase(s){return n=s,i}};return e(i),[t,r,n]}function Ns(e){return typeof e=="function"}function Is(e,t){let[r,n,i]=vn(t),s;if(Ns(e))s=()=>vr(e());else{const f=vr(e);s=()=>f}function o(f=s(),u){let a=[r[u.type],...n.filter(({matcher:c})=>c(u)).map(({reducer:c})=>c)];return a.filter(c=>!!c).length===0&&(a=[i]),a.reduce((c,l)=>{if(l)if(J(c)){const h=l(c,u);return h===void 0?c:h}else{if(Y(c))return wn(c,m=>l(m,u));{const m=l(c,u);if(m===void 0){if(c===null)return c;throw Error("A case reducer on a non-draftable value must not return undefined")}return m}}return c},f)}return o.getInitialState=s,o}var xs="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Ds=(e=21)=>{let t="",r=e;for(;r--;)t+=xs[Math.random()*64|0];return t},$s=Symbol.for("rtk-slice-createasyncthunk");function ks(e,t){return`${e}/${t}`}function Cs({creators:e}={}){var r;const t=(r=e==null?void 0:e.asyncThunk)==null?void 0:r[$s];return function(i){const{name:s,reducerPath:o=s}=i;if(!s)throw new Error(T(11));const f=(typeof i.reducers=="function"?i.reducers(Fs()):i.reducers)||{},u=Object.keys(f),a={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},c={addCase(w,b){const v=typeof w=="string"?w:w.type;if(!v)throw new Error(T(12));if(v in a.sliceCaseReducersByType)throw new Error(T(13));return a.sliceCaseReducersByType[v]=b,c},addMatcher(w,b){return a.sliceMatchers.push({matcher:w,reducer:b}),c},exposeAction(w,b){return a.actionCreators[w]=b,c},exposeCaseReducer(w,b){return a.sliceCaseReducersByName[w]=b,c}};u.forEach(w=>{const b=f[w],v={reducerName:w,type:ks(s,w),createNotation:typeof i.reducers=="function"};zs(b)?Bs(v,b,c,t):Ts(v,b,c)});function l(){const[w={},b=[],v=void 0]=typeof i.extraReducers=="function"?vn(i.extraReducers):[i.extraReducers],A={...w,...a.sliceCaseReducersByType};return Is(i.initialState,D=>{for(let x in A)D.addCase(x,A[x]);for(let x of a.sliceMatchers)D.addMatcher(x.matcher,x.reducer);for(let x of b)D.addMatcher(x.matcher,x.reducer);v&&D.addDefaultCase(v)})}const m=w=>w,h=new Map,y=new WeakMap;let d;function p(w,b){return d||(d=l()),d(w,b)}function g(){return d||(d=l()),d.getInitialState()}function S(w,b=!1){function v(D){let x=D[w];return typeof x>"u"&&b&&(x=Ne(y,v,g)),x}function A(D=m){const x=Ne(h,b,()=>new WeakMap);return Ne(x,D,()=>{const Pe={};for(const[U,N]of Object.entries(i.selectors??{}))Pe[U]=Ls(N,D,()=>Ne(y,D,g),b);return Pe})}return{reducerPath:w,getSelectors:A,get selectors(){return A(v)},selectSlice:v}}const E={name:s,reducer:p,actions:a.actionCreators,caseReducers:a.sliceCaseReducersByName,getInitialState:g,...S(o),injectInto(w,{reducerPath:b,...v}={}){const A=b??o;return w.inject({reducerPath:A,reducer:p},v),{...E,...S(A,!0)}}};return E}}function Ls(e,t,r,n){function i(s,...o){let f=t(s);return typeof f>"u"&&n&&(f=r()),e(f,...o)}return i.unwrapped=e,i}var Ho=Cs();function Fs(){function e(t,r){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...r}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...r){return t(...r)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,r){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:r}},asyncThunk:e}}function Ts({type:e,reducerName:t,createNotation:r},n,i){let s,o;if("reducer"in n){if(r&&!Us(n))throw new Error(T(17));s=n.reducer,o=n.prepare}else s=n;i.addCase(e,s).exposeCaseReducer(t,s).exposeAction(t,o?le(e,o):le(e))}function zs(e){return e._reducerDefinitionType==="asyncThunk"}function Us(e){return e._reducerDefinitionType==="reducerWithPrepare"}function Bs({type:e,reducerName:t},r,n,i){if(!i)throw new Error(T(18));const{payloadCreator:s,fulfilled:o,pending:f,rejected:u,settled:a,options:c}=r,l=i(e,s,c);n.exposeAction(t,l),o&&n.addCase(l.fulfilled,o),f&&n.addCase(l.pending,f),u&&n.addCase(l.rejected,u),a&&n.addMatcher(l.settled,a),n.exposeCaseReducer(t,{fulfilled:o||Ie,pending:f||Ie,rejected:u||Ie,settled:a||Ie})}function Ie(){}var js="task",An="listener",Pn="completed",Qt="cancelled",Ws=`task-${Qt}`,qs=`task-${Pn}`,Lt=`${An}-${Qt}`,Ys=`${An}-${Pn}`,rt=class{constructor(e){Oe(this,"code");Oe(this,"name","TaskAbortError");Oe(this,"message");this.code=e,this.message=`${js} ${Qt} (reason: ${e})`}},er=(e,t)=>{if(typeof e!="function")throw new TypeError(T(32))},We=()=>{},On=(e,t=We)=>(e.catch(t),e),Rn=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),re=e=>{if(e.aborted)throw new rt(e.reason)};function Mn(e,t){let r=We;return new Promise((n,i)=>{const s=()=>i(new rt(e.reason));if(e.aborted){s();return}r=Rn(e,s),t.finally(()=>r()).then(n,i)}).finally(()=>{r=We})}var Gs=async(e,t)=>{try{return await Promise.resolve(),{status:"ok",value:await e()}}catch(r){return{status:r instanceof rt?"cancelled":"rejected",error:r}}finally{t==null||t()}},qe=e=>t=>On(Mn(e,t).then(r=>(re(e),r))),Nn=e=>{const t=qe(e);return r=>t(new Promise(n=>setTimeout(n,r)))},{assign:ce}=Object,Pr={},nt="listenerMiddleware",Xs=(e,t)=>{const r=n=>Rn(e,()=>n.abort(e.reason));return(n,i)=>{er(n);const s=new AbortController;r(s);const o=Gs(async()=>{re(e),re(s.signal);const f=await n({pause:qe(s.signal),delay:Nn(s.signal),signal:s.signal});return re(s.signal),f},()=>s.abort(qs));return i!=null&&i.autoJoin&&t.push(o.catch(We)),{result:qe(e)(o),cancel(){s.abort(Ws)}}}},Hs=(e,t)=>{const r=async(n,i)=>{re(t);let s=()=>{};const f=[new Promise((u,a)=>{let c=e({predicate:n,effect:(l,m)=>{m.unsubscribe(),u([l,m.getState(),m.getOriginalState()])}});s=()=>{c(),a()}})];i!=null&&f.push(new Promise(u=>setTimeout(u,i,null)));try{const u=await Mn(t,Promise.race(f));return re(t),u}finally{s()}};return((n,i)=>On(r(n,i)))},In=e=>{let{type:t,actionCreator:r,matcher:n,predicate:i,effect:s}=e;if(t)i=le(t).match;else if(r)t=r.type,i=r.match;else if(n)i=n;else if(!i)throw new Error(T(21));return er(s),{predicate:i,type:t,effect:s}},xn=ce(e=>{const{type:t,predicate:r,effect:n}=In(e);return{id:Ds(),effect:n,type:t,predicate:r,pending:new Set,unsubscribe:()=>{throw new Error(T(22))}}},{withTypes:()=>xn}),Or=(e,t)=>{const{type:r,effect:n,predicate:i}=In(t);return Array.from(e.values()).find(s=>(typeof r=="string"?s.type===r:s.predicate===i)&&s.effect===n)},Ft=e=>{e.pending.forEach(t=>{t.abort(Lt)})},Ks=(e,t)=>()=>{for(const r of t.keys())Ft(r);e.clear()},Rr=(e,t,r)=>{try{e(t,r)}catch(n){setTimeout(()=>{throw n},0)}},Dn=ce(le(`${nt}/add`),{withTypes:()=>Dn}),Zs=le(`${nt}/removeAll`),$n=ce(le(`${nt}/remove`),{withTypes:()=>$n}),Js=(...e)=>{console.error(`${nt}/error`,...e)},Ko=(e={})=>{const t=new Map,r=new Map,n=h=>{const y=r.get(h)??0;r.set(h,y+1)},i=h=>{const y=r.get(h)??1;y===1?r.delete(h):r.set(h,y-1)},{extra:s,onError:o=Js}=e;er(o);const f=h=>(h.unsubscribe=()=>t.delete(h.id),t.set(h.id,h),y=>{h.unsubscribe(),y!=null&&y.cancelActive&&Ft(h)}),u=(h=>{const y=Or(t,h)??xn(h);return f(y)});ce(u,{withTypes:()=>u});const a=h=>{const y=Or(t,h);return y&&(y.unsubscribe(),h.cancelActive&&Ft(y)),!!y};ce(a,{withTypes:()=>a});const c=async(h,y,d,p)=>{const g=new AbortController,S=Hs(u,g.signal),E=[];try{h.pending.add(g),n(h),await Promise.resolve(h.effect(y,ce({},d,{getOriginalState:p,condition:(w,b)=>S(w,b).then(Boolean),take:S,delay:Nn(g.signal),pause:qe(g.signal),extra:s,signal:g.signal,fork:Xs(g.signal,E),unsubscribe:h.unsubscribe,subscribe:()=>{t.set(h.id,h)},cancelActiveListeners:()=>{h.pending.forEach((w,b,v)=>{w!==g&&(w.abort(Lt),v.delete(w))})},cancel:()=>{g.abort(Lt),h.pending.delete(g)},throwIfCancelled:()=>{re(g.signal)}})))}catch(w){w instanceof rt||Rr(o,w,{raisedBy:"effect"})}finally{await Promise.all(E),g.abort(Ys),i(h),h.pending.delete(g)}},l=Ks(t,r);return{middleware:h=>y=>d=>{if(!cn(d))return y(d);if(Dn.match(d))return u(d.payload);if(Zs.match(d)){l();return}if($n.match(d))return a(d.payload);let p=h.getState();const g=()=>{if(p===Pr)throw new Error(T(23));return p};let S;try{if(S=y(d),t.size>0){const E=h.getState(),w=Array.from(t.values());for(const b of w){let v=!1;try{v=b.predicate(d,E,p)}catch(A){v=!1,Rr(o,A,{raisedBy:"predicate"})}v&&c(b,d,h,g)}}}finally{p=Pr}return S},startListening:u,stopListening:a,clearListeners:l}};function T(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}function Vs(e,t,{signal:r,edges:n}={}){let i,s=null;const o=n!=null&&n.includes("leading"),f=n==null||n.includes("trailing"),u=()=>{s!==null&&(e.apply(i,s),i=void 0,s=null)},a=()=>{f&&u(),h()};let c=null;const l=()=>{c!=null&&clearTimeout(c),c=setTimeout(()=>{c=null,a()},t)},m=()=>{c!==null&&(clearTimeout(c),c=null)},h=()=>{m(),i=void 0,s=null},y=()=>{u()},d=function(...p){if(r!=null&&r.aborted)return;i=this,s=p;const g=c==null;l(),o&&g&&u()};return d.schedule=l,d.cancel=h,d.flush=y,r==null||r.addEventListener("abort",h,{once:!0}),d}function Qs(e,t=0,r={}){typeof r!="object"&&(r={});const{leading:n=!1,trailing:i=!0,maxWait:s}=r,o=Array(2);n&&(o[0]="leading"),i&&(o[1]="trailing");let f,u=null;const a=Vs(function(...m){f=e.apply(this,m),u=null},t,{edges:o}),c=function(...m){return s!=null&&(u===null&&(u=Date.now()),Date.now()-u>=s)?(f=e.apply(this,m),u=Date.now(),a.cancel(),a.schedule(),f):(a.apply(this,m),f)},l=()=>(a.flush(),f);return c.cancel=a.cancel,c.flush=l,c}function Zo(e,t=0,r={}){const{leading:n=!0,trailing:i=!0}=r;return Qs(e,t,{leading:n,maxWait:t,trailing:i})}var kn=Symbol.for("immer-nothing"),Mr=Symbol.for("immer-draftable"),z=Symbol.for("immer-state");function q(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var we=Object.getPrototypeOf;function de(e){return!!e&&!!e[z]}function se(e){var t;return e?Cn(e)||Array.isArray(e)||!!e[Mr]||!!((t=e.constructor)!=null&&t[Mr])||Ae(e)||st(e):!1}var eo=Object.prototype.constructor.toString(),Nr=new WeakMap;function Cn(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(r===Object)return!0;if(typeof r!="function")return!1;let n=Nr.get(r);return n===void 0&&(n=Function.toString.call(r),Nr.set(r,n)),n===eo}function Ye(e,t,r=!0){it(e)===0?(r?Reflect.ownKeys(e):Object.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((n,i)=>t(i,n,e))}function it(e){const t=e[z];return t?t.type_:Array.isArray(e)?1:Ae(e)?2:st(e)?3:0}function Tt(e,t){return it(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ln(e,t,r){const n=it(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function to(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Ae(e){return e instanceof Map}function st(e){return e instanceof Set}function Q(e){return e.copy_||e.base_}function zt(e,t){if(Ae(e))return new Map(e);if(st(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const r=Cn(e);if(t===!0||t==="class_only"&&!r){const n=Object.getOwnPropertyDescriptors(e);delete n[z];let i=Reflect.ownKeys(n);for(let s=0;s1&&Object.defineProperties(e,{set:xe,add:xe,clear:xe,delete:xe}),Object.freeze(e),t&&Object.values(e).forEach(r=>tr(r,!0))),e}function ro(){q(2)}var xe={value:ro};function ot(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var no={};function oe(e){const t=no[e];return t||q(0,e),t}var be;function Fn(){return be}function io(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ir(e,t){t&&(oe("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ut(e){Bt(e),e.drafts_.forEach(so),e.drafts_=null}function Bt(e){e===be&&(be=e.parent_)}function xr(e){return be=io(be,e)}function so(e){const t=e[z];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Dr(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];return e!==void 0&&e!==r?(r[z].modified_&&(Ut(t),q(4)),se(e)&&(e=Ge(t,e),t.parent_||Xe(t,e)),t.patches_&&oe("Patches").generateReplacementPatches_(r[z].base_,e,t.patches_,t.inversePatches_)):e=Ge(t,r,[]),Ut(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==kn?e:void 0}function Ge(e,t,r){if(ot(t))return t;const n=e.immer_.shouldUseStrictIteration(),i=t[z];if(!i)return Ye(t,(s,o)=>$r(e,i,t,s,o,r),n),t;if(i.scope_!==e)return t;if(!i.modified_)return Xe(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const s=i.copy_;let o=s,f=!1;i.type_===3&&(o=new Set(s),s.clear(),f=!0),Ye(o,(u,a)=>$r(e,i,s,u,a,r,f),n),Xe(e,s,!1),r&&e.patches_&&oe("Patches").generatePatches_(i,r,e.patches_,e.inversePatches_)}return i.copy_}function $r(e,t,r,n,i,s,o){if(i==null||typeof i!="object"&&!o)return;const f=ot(i);if(!(f&&!o)){if(de(i)){const u=s&&t&&t.type_!==3&&!Tt(t.assigned_,n)?s.concat(n):void 0,a=Ge(e,i,u);if(Ln(r,n,a),de(a))e.canAutoFreeze_=!1;else return}else o&&r.add(i);if(se(i)&&!f){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[n]===i&&f)return;Ge(e,i),(!t||!t.scope_.parent_)&&typeof n!="symbol"&&(Ae(r)?r.has(n):Object.prototype.propertyIsEnumerable.call(r,n))&&Xe(e,i)}}}function Xe(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&tr(t,r)}function oo(e,t){const r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:Fn(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=n,s=rr;r&&(i=[n],s=Ee);const{revoke:o,proxy:f}=Proxy.revocable(i,s);return n.draft_=f,n.revoke_=o,f}var rr={get(e,t){if(t===z)return e;const r=Q(e);if(!Tt(r,t))return fo(e,r,t);const n=r[t];return e.finalized_||!se(n)?n:n===pt(e.base_,t)?(yt(e),e.copy_[t]=Wt(n,e)):n},has(e,t){return t in Q(e)},ownKeys(e){return Reflect.ownKeys(Q(e))},set(e,t,r){const n=Tn(Q(e),t);if(n!=null&&n.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const i=pt(Q(e),t),s=i==null?void 0:i[z];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(to(r,i)&&(r!==void 0||Tt(e.base_,t)))return!0;yt(e),jt(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return pt(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,yt(e),jt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=Q(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty(){q(11)},getPrototypeOf(e){return we(e.base_)},setPrototypeOf(){q(12)}},Ee={};Ye(rr,(e,t)=>{Ee[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Ee.deleteProperty=function(e,t){return Ee.set.call(this,e,t,void 0)};Ee.set=function(e,t,r){return rr.set.call(this,e[0],t,r,e[0])};function pt(e,t){const r=e[z];return(r?Q(r):e)[t]}function fo(e,t,r){var i;const n=Tn(t,r);return n?"value"in n?n.value:(i=n.get)==null?void 0:i.call(e.draft_):void 0}function Tn(e,t){if(!(t in e))return;let r=we(e);for(;r;){const n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=we(r)}}function jt(e){e.modified_||(e.modified_=!0,e.parent_&&jt(e.parent_))}function yt(e){e.copy_||(e.copy_=zt(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var uo=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,r,n)=>{if(typeof t=="function"&&typeof r!="function"){const s=r;r=t;const o=this;return function(u=s,...a){return o.produce(u,c=>r.call(this,c,...a))}}typeof r!="function"&&q(6),n!==void 0&&typeof n!="function"&&q(7);let i;if(se(t)){const s=xr(this),o=Wt(t,void 0);let f=!0;try{i=r(o),f=!1}finally{f?Ut(s):Bt(s)}return Ir(s,n),Dr(i,s)}else if(!t||typeof t!="object"){if(i=r(t),i===void 0&&(i=t),i===kn&&(i=void 0),this.autoFreeze_&&tr(i,!0),n){const s=[],o=[];oe("Patches").generateReplacementPatches_(t,i,s,o),n(s,o)}return i}else q(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(o,...f)=>this.produceWithPatches(o,u=>t(u,...f));let n,i;return[this.produce(t,r,(o,f)=>{n=o,i=f}),n,i]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof(e==null?void 0:e.useStrictIteration)=="boolean"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){se(e)||q(8),de(e)&&(e=co(e));const t=xr(this),r=Wt(e,void 0);return r[z].isManual_=!0,Bt(t),r}finishDraft(e,t){const r=e&&e[z];(!r||!r.isManual_)&&q(9);const{scope_:n}=r;return Ir(n,t),Dr(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const i=t[r];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}r>-1&&(t=t.slice(r+1));const n=oe("Patches").applyPatches_;return de(e)?n(e,t):this.produce(e,i=>n(i,t))}};function Wt(e,t){const r=Ae(e)?oe("MapSet").proxyMap_(e,t):st(e)?oe("MapSet").proxySet_(e,t):oo(e,t);return(t?t.scope_:Fn()).drafts_.push(r),r}function co(e){return de(e)||q(10,e),zn(e)}function zn(e){if(!se(e)||ot(e))return e;const t=e[z];let r,n=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=zt(e,t.scope_.immer_.useStrictShallowCopy_),n=t.scope_.immer_.shouldUseStrictIteration()}else r=zt(e,!0);return Ye(r,(i,s)=>{Ln(r,i,zn(s))},n),t&&(t.finalized_=!1),r}var ao=new uo;ao.produce;function Jo(e){return e}var mt={exports:{}},_t={};/** + * @license React + * use-sync-external-store-with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var kr;function lo(){if(kr)return _t;kr=1;var e=qt();function t(u,a){return u===a&&(u!==0||1/u===1/a)||u!==u&&a!==a}var r=typeof Object.is=="function"?Object.is:t,n=e.useSyncExternalStore,i=e.useRef,s=e.useEffect,o=e.useMemo,f=e.useDebugValue;return _t.useSyncExternalStoreWithSelector=function(u,a,c,l,m){var h=i(null);if(h.current===null){var y={hasValue:!1,value:null};h.current=y}else y=h.current;h=o(function(){function p(b){if(!g){if(g=!0,S=b,b=l(b),m!==void 0&&y.hasValue){var v=y.value;if(m(v,b))return E=v}return E=b}if(v=E,r(S,b))return v;var A=l(b);return m!==void 0&&m(v,A)?(S=b,v):(S=b,E=A)}var g=!1,S,E,w=c===void 0?null:c;return[function(){return p(a())},w===null?void 0:function(){return p(w())}]},[a,c,l,m]);var d=n(u,h[0],h[1]);return s(function(){y.hasValue=!0,y.value=d},[d]),f(d),d},_t}var Cr;function ho(){return Cr||(Cr=1,mt.exports=lo()),mt.exports}ho();function po(e){e()}function yo(){let e=null,t=null;return{clear(){e=null,t=null},notify(){po(()=>{let r=e;for(;r;)r.callback(),r=r.next})},get(){const r=[];let n=e;for(;n;)r.push(n),n=n.next;return r},subscribe(r){let n=!0;const i=t={callback:r,next:null,prev:t};return i.prev?i.prev.next=i:e=i,function(){!n||e===null||(n=!1,i.next?i.next.prev=i.prev:t=i.prev,i.prev?i.prev.next=i.next:e=i.next)}}}}var Lr={notify(){},get:()=>[]};function mo(e,t){let r,n=Lr,i=0,s=!1;function o(d){c();const p=n.subscribe(d);let g=!1;return()=>{g||(g=!0,p(),l())}}function f(){n.notify()}function u(){y.onStateChange&&y.onStateChange()}function a(){return s}function c(){i++,r||(r=e.subscribe(u),n=yo())}function l(){i--,r&&i===0&&(r(),r=void 0,n.clear(),n=Lr)}function m(){s||(s=!0,c())}function h(){s&&(s=!1,l())}const y={addNestedSub:o,notifyNestedSubs:f,handleChangeWrapper:u,isSubscribed:a,trySubscribe:m,tryUnsubscribe:h,getListeners:()=>n};return y}var _o=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",go=_o(),wo=()=>typeof navigator<"u"&&navigator.product==="ReactNative",bo=wo(),Eo=()=>go||bo?K.useLayoutEffect:K.useEffect,So=Eo();function Fr(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function Vo(e,t){if(Fr(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i=0;i{const u=mo(i);return{store:i,subscription:u,getServerState:n?()=>n:void 0}},[i,n]),o=K.useMemo(()=>i.getState(),[i]);So(()=>{const{subscription:u}=s;return u.onStateChange=u.notifyNestedSubs,u.trySubscribe(),o!==i.getState()&&u.notifyNestedSubs(),()=>{u.tryUnsubscribe(),u.onStateChange=void 0}},[s,o]);const f=r||Ao;return K.createElement(f.Provider,{value:s},t)}var Qo=Po;function Oo(e){return fn(e)?NaN:Number(e)}function bt(e){return e?(e=Oo(e),e===1/0||e===-1/0?(e<0?-1:1)*Number.MAX_VALUE:e===e?e:0):e===0?e:0}function ef(e,t,r){r&&typeof r!="number"&&Rt(e,t,r)&&(t=r=void 0),e=bt(e),t===void 0?(t=e,e=0):t=bt(t),r=r===void 0?ee.e^s.s<0?1:-1;for(n=s.d.length,i=e.d.length,t=0,r=ne.d[t]^s.s<0?1:-1;return n===i?0:n>i^s.s<0?1:-1};_.decimalPlaces=_.dp=function(){var e=this,t=e.d.length-1,r=(t-e.e)*R;if(t=e.d[t],t)for(;t%10==0;t/=10)r--;return r<0?0:r};_.dividedBy=_.div=function(e){return Z(this,new this.constructor(e))};_.dividedToIntegerBy=_.idiv=function(e){var t=this,r=t.constructor;return O(Z(t,new r(e),0,1),r.precision)};_.equals=_.eq=function(e){return!this.cmp(e)};_.exponent=function(){return I(this)};_.greaterThan=_.gt=function(e){return this.cmp(e)>0};_.greaterThanOrEqualTo=_.gte=function(e){return this.cmp(e)>=0};_.isInteger=_.isint=function(){return this.e>this.d.length-2};_.isNegative=_.isneg=function(){return this.s<0};_.isPositive=_.ispos=function(){return this.s>0};_.isZero=function(){return this.s===0};_.lessThan=_.lt=function(e){return this.cmp(e)<0};_.lessThanOrEqualTo=_.lte=function(e){return this.cmp(e)<1};_.logarithm=_.log=function(e){var t,r=this,n=r.constructor,i=n.precision,s=i+5;if(e===void 0)e=new n(10);else if(e=new n(e),e.s<1||e.eq(L))throw Error(B+"NaN");if(r.s<1)throw Error(B+(r.s?"NaN":"-Infinity"));return r.eq(L)?new n(0):(M=!1,t=Z(Se(r,s),Se(e,s),s),M=!0,O(t,i))};_.minus=_.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?Wn(t,e):Bn(t,(e.s=-e.s,e))};_.modulo=_.mod=function(e){var t,r=this,n=r.constructor,i=n.precision;if(e=new n(e),!e.s)throw Error(B+"NaN");return r.s?(M=!1,t=Z(r,e,0,1).times(e),M=!0,r.minus(t)):O(new n(r),i)};_.naturalExponential=_.exp=function(){return jn(this)};_.naturalLogarithm=_.ln=function(){return Se(this)};_.negated=_.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};_.plus=_.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?Bn(t,e):Wn(t,(e.s=-e.s,e))};_.precision=_.sd=function(e){var t,r,n,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(ne+e);if(t=I(i)+1,n=i.d.length-1,r=n*R+1,n=i.d[n],n){for(;n%10==0;n/=10)r--;for(n=i.d[0];n>=10;n/=10)r++}return e&&t>r?t:r};_.squareRoot=_.sqrt=function(){var e,t,r,n,i,s,o,f=this,u=f.constructor;if(f.s<1){if(!f.s)return new u(0);throw Error(B+"NaN")}for(e=I(f),M=!1,i=Math.sqrt(+f),i==0||i==1/0?(t=G(f.d),(t.length+e)%2==0&&(t+="0"),i=Math.sqrt(t),e=pe((e+1)/2)-(e<0||e%2),i==1/0?t="5e"+e:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),n=new u(t)):n=new u(i.toString()),r=u.precision,i=o=r+3;;)if(s=n,n=s.plus(Z(f,s,o+2)).times(.5),G(s.d).slice(0,o)===(t=G(n.d)).slice(0,o)){if(t=t.slice(o-3,o+1),i==o&&t=="4999"){if(O(s,r+1,0),s.times(s).eq(f)){n=s;break}}else if(t!="9999")break;o+=4}return M=!0,O(n,r)};_.times=_.mul=function(e){var t,r,n,i,s,o,f,u,a,c=this,l=c.constructor,m=c.d,h=(e=new l(e)).d;if(!c.s||!e.s)return new l(0);for(e.s*=c.s,r=c.e+e.e,u=m.length,a=h.length,u=0;){for(t=0,i=u+n;i>n;)f=s[i]+h[n]*m[i-n-1]+t,s[i--]=f%$|0,t=f/$|0;s[i]=(s[i]+t)%$|0}for(;!s[--o];)s.pop();return t?++r:s.shift(),e.d=s,e.e=r,M?O(e,l.precision):e};_.toDecimalPlaces=_.todp=function(e,t){var r=this,n=r.constructor;return r=new n(r),e===void 0?r:(X(e,0,he),t===void 0?t=n.rounding:X(t,0,8),O(r,e+I(r)+1,t))};_.toExponential=function(e,t){var r,n=this,i=n.constructor;return e===void 0?r=fe(n,!0):(X(e,0,he),t===void 0?t=i.rounding:X(t,0,8),n=O(new i(n),e+1,t),r=fe(n,!0,e+1)),r};_.toFixed=function(e,t){var r,n,i=this,s=i.constructor;return e===void 0?fe(i):(X(e,0,he),t===void 0?t=s.rounding:X(t,0,8),n=O(new s(i),e+I(i)+1,t),r=fe(n.abs(),!1,e+I(n)+1),i.isneg()&&!i.isZero()?"-"+r:r)};_.toInteger=_.toint=function(){var e=this,t=e.constructor;return O(new t(e),I(e)+1,t.rounding)};_.toNumber=function(){return+this};_.toPower=_.pow=function(e){var t,r,n,i,s,o,f=this,u=f.constructor,a=12,c=+(e=new u(e));if(!e.s)return new u(L);if(f=new u(f),!f.s){if(e.s<1)throw Error(B+"Infinity");return f}if(f.eq(L))return f;if(n=u.precision,e.eq(L))return O(f,n);if(t=e.e,r=e.d.length-1,o=t>=r,s=f.s,o){if((r=c<0?-c:c)<=Un){for(i=new u(L),t=Math.ceil(n/R+4),M=!1;r%2&&(i=i.times(f),zr(i.d,t)),r=pe(r/2),r!==0;)f=f.times(f),zr(f.d,t);return M=!0,e.s<0?new u(L).div(i):O(i,n)}}else if(s<0)throw Error(B+"NaN");return s=s<0&&e.d[Math.max(t,r)]&1?-1:1,f.s=1,M=!1,i=e.times(Se(f,n+a)),M=!0,i=jn(i),i.s=s,i};_.toPrecision=function(e,t){var r,n,i=this,s=i.constructor;return e===void 0?(r=I(i),n=fe(i,r<=s.toExpNeg||r>=s.toExpPos)):(X(e,1,he),t===void 0?t=s.rounding:X(t,0,8),i=O(new s(i),e,t),r=I(i),n=fe(i,e<=r||r<=s.toExpNeg,e)),n};_.toSignificantDigits=_.tosd=function(e,t){var r=this,n=r.constructor;return e===void 0?(e=n.precision,t=n.rounding):(X(e,1,he),t===void 0?t=n.rounding:X(t,0,8)),O(new n(r),e,t)};_.toString=_.valueOf=_.val=_.toJSON=_[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,t=I(e),r=e.constructor;return fe(e,t<=r.toExpNeg||t>=r.toExpPos)};function Bn(e,t){var r,n,i,s,o,f,u,a,c=e.constructor,l=c.precision;if(!e.s||!t.s)return t.s||(t=new c(e)),M?O(t,l):t;if(u=e.d,a=t.d,o=e.e,i=t.e,u=u.slice(),s=o-i,s){for(s<0?(n=u,s=-s,f=a.length):(n=a,i=o,f=u.length),o=Math.ceil(l/R),f=o>f?o+1:f+1,s>f&&(s=f,n.length=1),n.reverse();s--;)n.push(0);n.reverse()}for(f=u.length,s=a.length,f-s<0&&(s=f,n=a,a=u,u=n),r=0;s;)r=(u[--s]=u[s]+a[s]+r)/$|0,u[s]%=$;for(r&&(u.unshift(r),++i),f=u.length;u[--f]==0;)u.pop();return t.d=u,t.e=i,M?O(t,l):t}function X(e,t,r){if(e!==~~e||er)throw Error(ne+e)}function G(e){var t,r,n,i=e.length-1,s="",o=e[0];if(i>0){for(s+=o,t=1;to?1:-1;else for(f=u=0;fi[f]?1:-1;break}return u}function r(n,i,s){for(var o=0;s--;)n[s]-=o,o=n[s]1;)n.shift()}return function(n,i,s,o){var f,u,a,c,l,m,h,y,d,p,g,S,E,w,b,v,A,D,x=n.constructor,Pe=n.s==i.s?1:-1,U=n.d,N=i.d;if(!n.s)return new x(n);if(!i.s)throw Error(B+"Division by zero");for(u=n.e-i.e,A=N.length,b=U.length,h=new x(Pe),y=h.d=[],a=0;N[a]==(U[a]||0);)++a;if(N[a]>(U[a]||0)&&--u,s==null?S=s=x.precision:o?S=s+(I(n)-I(i))+1:S=s,S<0)return new x(0);if(S=S/R+2|0,a=0,A==1)for(c=0,N=N[0],S++;(a1&&(N=e(N,c),U=e(U,c),A=N.length,b=U.length),w=A,d=U.slice(0,A),p=d.length;p=$/2&&++v;do c=0,f=t(N,d,A,p),f<0?(g=d[0],A!=p&&(g=g*$+(d[1]||0)),c=g/v|0,c>1?(c>=$&&(c=$-1),l=e(N,c),m=l.length,p=d.length,f=t(l,d,m,p),f==1&&(c--,r(l,A16)throw Error(nr+I(e));if(!e.s)return new c(L);for(M=!1,f=l,o=new c(.03125);e.abs().gte(.1);)e=e.times(o),a+=5;for(n=Math.log(ee(2,a))/Math.LN10*2+5|0,f+=n,r=i=s=new c(L),c.precision=f;;){if(i=O(i.times(e),f),r=r.times(++u),o=s.plus(Z(i,r,f)),G(o.d).slice(0,f)===G(s.d).slice(0,f)){for(;a--;)s=O(s.times(s),f);return c.precision=l,t==null?(M=!0,O(s,l)):s}s=o}}function I(e){for(var t=e.e*R,r=e.d[0];r>=10;r/=10)t++;return t}function Et(e,t,r){if(t>e.LN10.sd())throw M=!0,r&&(e.precision=r),Error(B+"LN10 precision limit exceeded");return O(new e(e.LN10),t)}function V(e){for(var t="";e--;)t+="0";return t}function Se(e,t){var r,n,i,s,o,f,u,a,c,l=1,m=10,h=e,y=h.d,d=h.constructor,p=d.precision;if(h.s<1)throw Error(B+(h.s?"NaN":"-Infinity"));if(h.eq(L))return new d(0);if(t==null?(M=!1,a=p):a=t,h.eq(10))return t==null&&(M=!0),Et(d,a);if(a+=m,d.precision=a,r=G(y),n=r.charAt(0),s=I(h),Math.abs(s)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)h=h.times(e),r=G(h.d),n=r.charAt(0),l++;s=I(h),n>1?(h=new d("0."+r),s++):h=new d(n+"."+r.slice(1))}else return u=Et(d,a+2,p).times(s+""),h=Se(new d(n+"."+r.slice(1)),a-m).plus(u),d.precision=p,t==null?(M=!0,O(h,p)):h;for(f=o=h=Z(h.minus(L),h.plus(L),a),c=O(h.times(h),a),i=3;;){if(o=O(o.times(c),a),u=f.plus(Z(o,new d(i),a)),G(u.d).slice(0,a)===G(f.d).slice(0,a))return f=f.times(2),s!==0&&(f=f.plus(Et(d,a+2,p).times(s+""))),f=Z(f,new d(l),a),d.precision=p,t==null?(M=!0,O(f,p)):f;f=u,i+=2}}function Tr(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;t.charCodeAt(n)===48;)++n;for(i=t.length;t.charCodeAt(i-1)===48;)--i;if(t=t.slice(n,i),t){if(i-=n,r=r-n-1,e.e=pe(r/R),e.d=[],n=(r+1)%R,r<0&&(n+=R),nHe||e.e<-He))throw Error(nr+r)}else e.s=0,e.e=0,e.d=[0];return e}function O(e,t,r){var n,i,s,o,f,u,a,c,l=e.d;for(o=1,s=l[0];s>=10;s/=10)o++;if(n=t-o,n<0)n+=R,i=t,a=l[c=0];else{if(c=Math.ceil((n+1)/R),s=l.length,c>=s)return e;for(a=s=l[c],o=1;s>=10;s/=10)o++;n%=R,i=n-R+o}if(r!==void 0&&(s=ee(10,o-i-1),f=a/s%10|0,u=t<0||l[c+1]!==void 0||a%s,u=r<4?(f||u)&&(r==0||r==(e.s<0?3:2)):f>5||f==5&&(r==4||u||r==6&&(n>0?i>0?a/ee(10,o-i):0:l[c-1])%10&1||r==(e.s<0?8:7))),t<1||!l[0])return u?(s=I(e),l.length=1,t=t-s-1,l[0]=ee(10,(R-t%R)%R),e.e=pe(-t/R)||0):(l.length=1,l[0]=e.e=e.s=0),e;if(n==0?(l.length=c,s=1,c--):(l.length=c+1,s=ee(10,R-n),l[c]=i>0?(a/ee(10,o-i)%ee(10,i)|0)*s:0),u)for(;;)if(c==0){(l[0]+=s)==$&&(l[0]=1,++e.e);break}else{if(l[c]+=s,l[c]!=$)break;l[c--]=0,s=1}for(n=l.length;l[--n]===0;)l.pop();if(M&&(e.e>He||e.e<-He))throw Error(nr+I(e));return e}function Wn(e,t){var r,n,i,s,o,f,u,a,c,l,m=e.constructor,h=m.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new m(e),M?O(t,h):t;if(u=e.d,l=t.d,n=t.e,a=e.e,u=u.slice(),o=a-n,o){for(c=o<0,c?(r=u,o=-o,f=l.length):(r=l,n=a,f=u.length),i=Math.max(Math.ceil(h/R),f)+2,o>i&&(o=i,r.length=1),r.reverse(),i=o;i--;)r.push(0);r.reverse()}else{for(i=u.length,f=l.length,c=i0;--i)u[f++]=0;for(i=l.length;i>o;){if(u[--i]0?s=s.charAt(0)+"."+s.slice(1)+V(n):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i<0?"e":"e+")+i):i<0?(s="0."+V(-i-1)+s,r&&(n=r-o)>0&&(s+=V(n))):i>=o?(s+=V(i+1-o),r&&(n=r-i-1)>0&&(s=s+"."+V(n))):((n=i+1)0&&(i+1===o&&(s+="."),s+=V(n))),e.s<0?"-"+s:s}function zr(e,t){if(e.length>t)return e.length=t,!0}function qn(e){var t,r,n;function i(s){var o=this;if(!(o instanceof i))return new i(s);if(o.constructor=i,s instanceof i){o.s=s.s,o.e=s.e,o.d=(s=s.d)?s.slice():s;return}if(typeof s=="number"){if(s*0!==0)throw Error(ne+s);if(s>0)o.s=1;else if(s<0)s=-s,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(s===~~s&&s<1e7){o.e=0,o.d=[s];return}return Tr(o,s.toString())}else if(typeof s!="string")throw Error(ne+s);if(s.charCodeAt(0)===45?(s=s.slice(1),o.s=-1):o.s=1,Mo.test(s))Tr(o,s);else throw Error(ne+s)}if(i.prototype=_,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=qn,i.config=i.set=No,e===void 0&&(e={}),e)for(n=["precision","rounding","toExpNeg","toExpPos","LN10"],t=0;t=i[t+1]&&n<=i[t+2])this[r]=n;else throw Error(ne+r+": "+n);if((n=e[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(ne+r+": "+n);return this}var ir=qn(Ro);L=new ir(1);const tf=ir;class rf extends Map{constructor(t,r=Do){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:r}}),t!=null)for(const[n,i]of t)this.set(n,i)}get(t){return super.get(Ur(this,t))}has(t){return super.has(Ur(this,t))}set(t,r){return super.set(Io(this,t),r)}delete(t){return super.delete(xo(this,t))}}function Ur({_intern:e,_key:t},r){const n=t(r);return e.has(n)?e.get(n):r}function Io({_intern:e,_key:t},r){const n=t(r);return e.has(n)?e.get(n):(e.set(n,r),r)}function xo({_intern:e,_key:t},r){const n=t(r);return e.has(n)&&(r=e.get(n),e.delete(n)),r}function Do(e){return e!==null&&typeof e=="object"?e.valueOf():e}var St={exports:{}},Br;function $o(){return Br||(Br=1,(function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(r=!1));function i(u,a,c){this.fn=u,this.context=a,this.once=c||!1}function s(u,a,c,l,m){if(typeof c!="function")throw new TypeError("The listener must be a function");var h=new i(c,l||u,m),y=r?r+a:a;return u._events[y]?u._events[y].fn?u._events[y]=[u._events[y],h]:u._events[y].push(h):(u._events[y]=h,u._eventsCount++),u}function o(u,a){--u._eventsCount===0?u._events=new n:delete u._events[a]}function f(){this._events=new n,this._eventsCount=0}f.prototype.eventNames=function(){var a=[],c,l;if(this._eventsCount===0)return a;for(l in c=this._events)t.call(c,l)&&a.push(r?l.slice(1):l);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(c)):a},f.prototype.listeners=function(a){var c=r?r+a:a,l=this._events[c];if(!l)return[];if(l.fn)return[l.fn];for(var m=0,h=l.length,y=new Array(h);m Ydisks闲鱼助手 - 自动发货与管家系统 - - + + + + + +
diff --git a/internal/xianyu/cookierefresh/cookies.go b/internal/xianyu/cookierefresh/cookies.go new file mode 100644 index 0000000..8739635 --- /dev/null +++ b/internal/xianyu/cookierefresh/cookies.go @@ -0,0 +1,243 @@ +package cookierefresh + +import ( + "encoding/json" + "sort" + "strings" +) + +const ( + metadataSnapshotKey = "cookies_refresh_snapshot" + legacyMetadataSnapshot = "cookie_refresh_snapshot" +) + +// BrowserCookie 保存浏览器返回的完整 Cookie 属性。 +type BrowserCookie struct { + Name string `json:"name"` + Value string `json:"value"` + Domain string `json:"domain,omitempty"` + Path string `json:"path,omitempty"` + Expires float64 `json:"expires,omitempty"` + HTTPOnly bool `json:"httpOnly,omitempty"` + Secure bool `json:"secure,omitempty"` + SameSite string `json:"sameSite,omitempty"` +} + +// ParseCookieString 把 Cookie 头解析为 name -> value。 +func ParseCookieString(s string) map[string]string { + out := make(map[string]string) + for _, part := range strings.Split(s, ";") { + part = strings.TrimSpace(part) + if part == "" { + continue + } + eq := strings.Index(part, "=") + if eq <= 0 { + continue + } + out[strings.TrimSpace(part[:eq])] = strings.TrimSpace(part[eq+1:]) + } + return out +} + +// MarshalCookieString 以稳定顺序把 Cookie map 拼回 Cookie 头。 +func MarshalCookieString(m map[string]string) string { + if len(m) == 0 { + return "" + } + keys := make([]string, 0, len(m)) + for k := range m { + if strings.TrimSpace(k) != "" { + keys = append(keys, k) + } + } + sort.Strings(keys) + parts := make([]string, 0, len(keys)) + for _, k := range keys { + parts = append(parts, k+"="+m[k]) + } + return strings.Join(parts, "; ") +} + +// MergeSetCookies 将 Set-Cookie 响应头合并进原 Cookie 字符串。 +func MergeSetCookies(original string, setCookies []string) string { + m := ParseCookieString(original) + for _, raw := range setCookies { + first := strings.TrimSpace(strings.Split(raw, ";")[0]) + eq := strings.Index(first, "=") + if eq <= 0 { + continue + } + name := strings.TrimSpace(first[:eq]) + if name == "" { + continue + } + m[name] = strings.TrimSpace(first[eq+1:]) + } + return MarshalCookieString(m) +} + +// ChangedCookieNames 返回两个 Cookie 字符串之间发生变化的字段名。 +func ChangedCookieNames(before, after string) []string { + a := ParseCookieString(before) + b := ParseCookieString(after) + seen := make(map[string]struct{}, len(a)+len(b)) + for k := range a { + seen[k] = struct{}{} + } + for k := range b { + seen[k] = struct{}{} + } + names := make([]string, 0, len(seen)) + for k := range seen { + if a[k] != b[k] { + names = append(names, k) + } + } + sort.Strings(names) + return names +} + +// ChangedSnapshotLabels 返回完整浏览器 Cookie 快照变化标签,格式 name@domain/path。 +func ChangedSnapshotLabels(before, after []BrowserCookie) []string { + key := func(c BrowserCookie) string { + path := c.Path + if path == "" { + path = "/" + } + return c.Name + "|" + c.Domain + "|" + path + } + label := func(c BrowserCookie) string { + path := c.Path + if path == "" { + path = "/" + } + if c.Domain != "" { + return c.Name + "@" + c.Domain + path + } + return c.Name + } + oldMap := make(map[string]BrowserCookie) + newMap := make(map[string]BrowserCookie) + for _, c := range NormalizeSnapshot(before) { + oldMap[key(c)] = c + } + for _, c := range NormalizeSnapshot(after) { + newMap[key(c)] = c + } + seen := make(map[string]struct{}, len(oldMap)+len(newMap)) + for k := range oldMap { + seen[k] = struct{}{} + } + for k := range newMap { + seen[k] = struct{}{} + } + labels := make([]string, 0, len(seen)) + for k := range seen { + old := oldMap[k] + newCookie := newMap[k] + if old == newCookie { + continue + } + if newCookie.Name != "" { + labels = append(labels, label(newCookie)) + } else if old.Name != "" { + labels = append(labels, label(old)) + } + } + sort.Strings(labels) + return labels +} + +// CookieStringFromSnapshot 将浏览器 Cookie 快照压成请求 Cookie 字符串。 +func CookieStringFromSnapshot(cookies []BrowserCookie) string { + m := make(map[string]string, len(cookies)) + for _, c := range cookies { + if c.Name == "" { + continue + } + m[c.Name] = c.Value + } + return MarshalCookieString(m) +} + +// MergeOriginalFields 补回浏览器未返回但原 Cookie 中存在的字段。 +func MergeOriginalFields(original, browserCookieString string) string { + m := ParseCookieString(original) + for k, v := range ParseCookieString(browserCookieString) { + m[k] = v + } + return MarshalCookieString(m) +} + +// NormalizeSnapshot 排序并补齐默认 path,保证 metadata 稳定。 +func NormalizeSnapshot(cookies []BrowserCookie) []BrowserCookie { + out := make([]BrowserCookie, 0, len(cookies)) + for _, c := range cookies { + if c.Name == "" { + continue + } + if c.Path == "" { + c.Path = "/" + } + out = append(out, c) + } + sort.Slice(out, func(i, j int) bool { + if out[i].Domain != out[j].Domain { + return out[i].Domain < out[j].Domain + } + if out[i].Path != out[j].Path { + return out[i].Path < out[j].Path + } + return out[i].Name < out[j].Name + }) + return out +} + +// SnapshotFromMetadata 从 cookies.metadata_json 中读取浏览器 Cookie 快照。 +func SnapshotFromMetadata(metadata string) []BrowserCookie { + var m map[string]json.RawMessage + if err := json.Unmarshal([]byte(strings.TrimSpace(metadata)), &m); err != nil { + return nil + } + var out []BrowserCookie + if raw := m[metadataSnapshotKey]; len(raw) > 0 { + _ = json.Unmarshal(raw, &out) + } else if raw := m[legacyMetadataSnapshot]; len(raw) > 0 { + _ = json.Unmarshal(raw, &out) + } + return NormalizeSnapshot(out) +} + +// MetadataWithSnapshot 写入浏览器 Cookie 快照,保留 metadata 中的其他键。 +func MetadataWithSnapshot(metadata string, cookies []BrowserCookie) string { + m := make(map[string]any) + if strings.TrimSpace(metadata) != "" { + _ = json.Unmarshal([]byte(metadata), &m) + } + delete(m, legacyMetadataSnapshot) + m[metadataSnapshotKey] = NormalizeSnapshot(cookies) + b, err := json.Marshal(m) + if err != nil { + return metadata + } + return string(b) +} + +// MetadataWithoutSnapshot 清除浏览器 Cookie 快照。 +func MetadataWithoutSnapshot(metadata string) string { + if strings.TrimSpace(metadata) == "" { + return "" + } + m := make(map[string]any) + if err := json.Unmarshal([]byte(metadata), &m); err != nil { + return metadata + } + delete(m, metadataSnapshotKey) + delete(m, legacyMetadataSnapshot) + b, err := json.Marshal(m) + if err != nil { + return metadata + } + return string(b) +} diff --git a/internal/xianyu/cookierefresh/cookies_test.go b/internal/xianyu/cookierefresh/cookies_test.go new file mode 100644 index 0000000..10e4889 --- /dev/null +++ b/internal/xianyu/cookierefresh/cookies_test.go @@ -0,0 +1,27 @@ +package cookierefresh + +import "testing" + +func TestMetadataSnapshotKeyCompatibility(t *testing.T) { + oldMeta := `{"cookie_refresh_snapshot":[{"name":"a","value":"1","domain":".goofish.com","path":"/"}]}` + snapshot := SnapshotFromMetadata(oldMeta) + if len(snapshot) != 1 || snapshot[0].Name != "a" { + t.Fatalf("旧 key 快照读取失败: %+v", snapshot) + } + newMeta := MetadataWithSnapshot(oldMeta, []BrowserCookie{{Name: "b", Value: "2", Domain: ".taobao.com", Path: "/"}}) + if SnapshotFromMetadata(newMeta)[0].Name != "b" { + t.Fatalf("新 key 快照写入失败: %s", newMeta) + } + if got := MetadataWithoutSnapshot(newMeta); len(SnapshotFromMetadata(got)) != 0 { + t.Fatalf("快照应被清除: %s", got) + } +} + +func TestChangedSnapshotLabels(t *testing.T) { + before := []BrowserCookie{{Name: "a", Value: "1", Domain: ".goofish.com", Path: "/"}} + after := []BrowserCookie{{Name: "a", Value: "2", Domain: ".goofish.com", Path: "/"}} + got := ChangedSnapshotLabels(before, after) + if len(got) != 1 || got[0] != "a@.goofish.com/" { + t.Fatalf("ChangedSnapshotLabels=%v", got) + } +} diff --git a/internal/xianyu/mtop/token.go b/internal/xianyu/mtop/token.go index ffbbe33..c71ad3e 100644 --- a/internal/xianyu/mtop/token.go +++ b/internal/xianyu/mtop/token.go @@ -14,6 +14,8 @@ import ( "xianyu-go/internal/xianyu/protocol" ) +const tokenRetryGap = 500 * time.Millisecond + // RefreshToken 调用 mtop.taobao.idlemessage.pc.login.token 获取 accessToken。 // 遇到 mtop 签名 token 过期时,仅在响应下发了新 Cookie 后低频重试一次。 func (c *ClientImpl) RefreshToken(cookiesStr string) (*RefreshResult, error) { @@ -50,7 +52,7 @@ func (c *ClientImpl) RefreshTokenWithDeviceIDContext(ctx context.Context, cookie return &RefreshResult{UpdatedCookies: updatedCookies}, fmt.Errorf("token API 登录凭证已失效: ret=%v (status=%d)", ret, status) } currentCookies = updatedCookies - if err := sleepCtx(ctx, MTopRetryGap); err != nil { + if err := sleepCtx(ctx, tokenRetryGap); err != nil { return &RefreshResult{UpdatedCookies: currentCookies}, err } } diff --git a/internal/xianyu/renew/service.go b/internal/xianyu/renew/service.go index 20c7bd2..753b343 100644 --- a/internal/xianyu/renew/service.go +++ b/internal/xianyu/renew/service.go @@ -7,9 +7,11 @@ package renew import ( "context" + cryptorand "crypto/rand" "encoding/json" "fmt" "io" + "math/big" "net/http" "net/url" "sort" @@ -17,7 +19,6 @@ import ( "strings" "time" - "xianyu-go/internal/xianyu" "xianyu-go/internal/xianyu/protocol" ) @@ -27,6 +28,9 @@ const ( SetLoginSettingsURL = "https://passport.goofish.com/ac/account/setLoginSettings.do" defaultRequestTimout = 20 * time.Second maxRenewBodyBytes = 2 << 20 + renewUA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36" + hasLoginSecChUA = `"Chromium";v="145", "Not:A-Brand";v="99"` + settingSecChUA = `"Google Chrome";v="146", "Not=A?Brand";v="8"` ) // Service 是 Cookie 接口续期服务。零值可用;测试可覆盖 URL 和 HTTPClient。 @@ -35,6 +39,7 @@ type Service struct { HasLoginURL string SilentHasLoginURL string SetLoginSettingsURL string + RetryDelay time.Duration } // Result 描述一次接口续期的完整结果。 @@ -45,6 +50,8 @@ type Result struct { UpdatedCookieNames []string StepDetails []StepResult Message string + ResponseText string + NeedPasswordLogin bool } // StepResult 是单个续期接口的执行结果,便于上层记录日志和定位失败点。 @@ -62,9 +69,38 @@ type StepResult struct { func (s Service) RenewAPIFirst(ctx context.Context, cookiesStr string) (*Result, error) { cookiesStr = strings.TrimSpace(cookiesStr) if cookiesStr == "" { - return &Result{RenewMethod: "none", Message: "Cookie为空,无法续期"}, nil + return &Result{RenewMethod: "none", Message: "Cookie为空,无法续期", NeedPasswordLogin: true}, nil } - return s.renewOnce(ctx, cookiesStr) + res, err := s.renewOnce(ctx, cookiesStr) + if err != nil || res == nil || res.Success { + return res, err + } + if s.RetryDelay < 0 { + return res, nil + } + delay := s.RetryDelay + if delay == 0 { + delay = 2 * time.Second + } + if delay > 0 { + timer := time.NewTimer(delay) + select { + case <-ctx.Done(): + timer.Stop() + return res, ctx.Err() + case <-timer.C: + } + } + retry, err := s.renewOnce(ctx, res.NewCookies) + if err != nil { + return res, err + } + if retry == nil { + return res, nil + } + retry.StepDetails = append(res.StepDetails, retry.StepDetails...) + retry.UpdatedCookieNames = ChangedCookieNames(cookiesStr, retry.NewCookies) + return retry, nil } func (s Service) renewOnce(ctx context.Context, original string) (*Result, error) { @@ -101,7 +137,10 @@ func (s Service) renewOnce(ctx context.Context, original string) (*Result, error allSetCookies = append(allSetCookies, settings.SetCookies...) } - newCookies := MergeSetCookies(original, allSetCookies) + newCookies := original + if len(allSetCookies) > 0 { + newCookies = MergeSetCookies(original, allSetCookies) + } updated := ChangedCookieNames(original, newCookies) success := len(settings.SetCookies) > 0 method := "none" @@ -117,6 +156,8 @@ func (s Service) renewOnce(ctx context.Context, original string) (*Result, error UpdatedCookieNames: updated, StepDetails: steps, Message: msg, + ResponseText: string(silent.Body), + NeedPasswordLogin: !success, }, nil } @@ -149,14 +190,15 @@ func (s Service) callHasLogin(ctx context.Context, cookiesStr string) (callResul form.Set("documentReferer", "https://www.goofish.com/") form.Set("defaultView", "hasLogin") form.Set("umidTag", "SERVER") - form.Set("pageTraceId", "21504"+strconv.FormatInt(time.Now().UnixMilli(), 10)) + form.Set("returnUrl", "") + form.Set("deviceId", "") + form.Set("pageTraceId", "21504"+strconv.FormatInt(time.Now().UnixMilli(), 10)+randomDigits(6)) req, err := http.NewRequestWithContext(ctx, http.MethodPost, s.urlOrDefault(s.HasLoginURL, HasLoginURL), strings.NewReader(form.Encode())) if err != nil { return callResult{}, err } - setPassportHeaders(req, cookiesStr) - req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + setHasLoginHeaders(req, cookiesStr, miniLoginReferer()) if xsrf := cookies["XSRF-TOKEN"]; xsrf != "" { req.Header.Set("x-xsrf-token", xsrf) } @@ -179,21 +221,21 @@ func (s Service) callSilentHasLogin(ctx context.Context, cookiesStr string) (cal q.Set("fromSite", "0") q.Set("ltl", "true") req.URL.RawQuery = q.Encode() - setPassportHeaders(req, cookiesStr) + setSilentHasLoginHeaders(req, cookiesStr) return s.doRenewRequest(req, "silentHasLogin") } func (s Service) callSetLoginSettings(ctx context.Context, cookiesStr string) (callResult, error) { - form := url.Values{} - form.Set("appName", "xianyu") - form.Set("fromSite", "77") - form.Set("keepLogin", "true") - req, err := http.NewRequestWithContext(ctx, http.MethodPost, s.urlOrDefault(s.SetLoginSettingsURL, SetLoginSettingsURL), strings.NewReader(form.Encode())) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, s.urlOrDefault(s.SetLoginSettingsURL, SetLoginSettingsURL), strings.NewReader("status=0")) if err != nil { return callResult{}, err } - setPassportHeaders(req, cookiesStr) - req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + q := req.URL.Query() + q.Set("fromSite", "77") + q.Set("appName", "xianyu") + q.Set("bizEntrance", "web") + req.URL.RawQuery = q.Encode() + setLoginSettingsHeaders(req, cookiesStr) return s.doRenewRequest(req, "setLoginSettings") } @@ -202,7 +244,11 @@ func (s Service) doRenewRequest(req *http.Request, name string) (callResult, err if hc == nil { hc = &http.Client{Timeout: defaultRequestTimout} } - resp, err := hc.Do(req) + client := *hc + client.CheckRedirect = func(*http.Request, []*http.Request) error { + return http.ErrUseLastResponse + } + resp, err := client.Do(req) if err != nil { return callResult{}, fmt.Errorf("%s 请求失败: %w", name, err) } @@ -211,7 +257,7 @@ func (s Service) doRenewRequest(req *http.Request, name string) (callResult, err if err != nil { return callResult{}, fmt.Errorf("%s 响应读取失败: %w", name, err) } - setCookies := resp.Header.Values("Set-Cookie") + setCookies := filterValidSetCookies(resp.Header.Values("Set-Cookie")) step := StepResult{ Name: name, HTTPStatus: resp.StatusCode, @@ -246,20 +292,54 @@ func renewBusinessOK(body []byte) bool { return ok } -func setPassportHeaders(req *http.Request, cookiesStr string) { +func setHasLoginHeaders(req *http.Request, cookiesStr, referer string) { req.Header.Set("Accept", "application/json, text/plain, */*") - req.Header.Set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8") - req.Header.Set("Cache-Control", "no-cache") - req.Header.Set("Pragma", "no-cache") - req.Header.Set("Origin", "https://passport.goofish.com") - req.Header.Set("Referer", "https://passport.goofish.com/") - req.Header.Set("User-Agent", xianyu.BrowserUA) - req.Header.Set("sec-ch-ua", xianyu.SecChUA) + req.Header.Set("Accept-Language", "zh-CN") + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + req.Header.Set("Referer", referer) + req.Header.Set("User-Agent", renewUA) + req.Header.Set("bx-v", "2.5.31") + req.Header.Set("sec-ch-ua", hasLoginSecChUA) req.Header.Set("sec-ch-ua-mobile", "?0") req.Header.Set("sec-ch-ua-platform", `"Windows"`) req.Header.Set("Cookie", strings.ReplaceAll(strings.ReplaceAll(cookiesStr, "\n", ""), "\r", "")) } +func setSilentHasLoginHeaders(req *http.Request, cookiesStr string) { + req.Header.Set("Accept", "*/*") + req.Header.Set("Accept-Language", "en,zh-CN;q=0.9,zh;q=0.8,ru;q=0.7") + req.Header.Set("Cache-Control", "no-cache") + req.Header.Set("Pragma", "no-cache") + req.Header.Set("Priority", "u=1, i") + req.Header.Set("Referer", "https://www.goofish.com/") + req.Header.Set("User-Agent", renewUA) + req.Header.Set("sec-ch-ua", `"Google Chrome";v="146", "Not=A?Brand";v="8", "Not/A)Brand";v="146"`) + req.Header.Set("sec-ch-ua-arch", `"x86"`) + req.Header.Set("sec-ch-ua-bitness", `"64"`) + req.Header.Set("sec-ch-ua-mobile", "?0") + req.Header.Set("sec-ch-ua-platform", `"Win32"`) + req.Header.Set("sec-ch-ua-platform-version", `"10.0.0"`) + req.Header.Set("sec-fetch-dest", "empty") + req.Header.Set("sec-fetch-mode", "cors") + req.Header.Set("sec-fetch-site", "same-site") + req.Header.Set("Cookie", strings.ReplaceAll(strings.ReplaceAll(cookiesStr, "\n", ""), "\r", "")) +} + +func setLoginSettingsHeaders(req *http.Request, cookiesStr string) { + req.Header.Set("Accept", "application/json, text/plain, */*") + req.Header.Set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8") + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + req.Header.Set("Referer", "https://www.goofish.com/") + req.Header.Set("User-Agent", renewUA) + req.Header.Set("sec-ch-ua", settingSecChUA) + req.Header.Set("sec-ch-ua-mobile", "?0") + req.Header.Set("sec-ch-ua-platform", `"Windows"`) + req.Header.Set("sec-fetch-dest", "empty") + req.Header.Set("sec-fetch-mode", "cors") + req.Header.Set("sec-fetch-site", "same-site") + req.Header.Set("Cookie", strings.ReplaceAll(strings.ReplaceAll(cookiesStr, "\n", ""), "\r", "")) +} + func (s Service) urlOrDefault(v, fallback string) string { if strings.TrimSpace(v) != "" { return v @@ -287,6 +367,48 @@ func firstNonEmpty(values ...string) string { return "" } +func miniLoginReferer() string { + return "https://passport.goofish.com/mini_login.htm?lang=zh_cn&appName=xianyu&appEntrance=web&styleType=vertical&bizParams=¬LoadSsoView=false¬KeepLogin=false&isMobile=false&qrCodeFirst=false&stie=77&rnd=" + randomFraction() +} + +func randomDigits(n int) string { + if n <= 0 { + return "" + } + min := 1 + for i := 1; i < n; i++ { + min *= 10 + } + max := min * 9 + v, err := cryptorand.Int(cryptorand.Reader, big.NewInt(int64(max))) + if err != nil { + return strings.Repeat("0", n) + } + return strconv.Itoa(min + int(v.Int64())) +} + +func randomFraction() string { + v, err := cryptorand.Int(cryptorand.Reader, big.NewInt(1_000_000_000)) + if err != nil { + return "0.0" + } + return "0." + fmt.Sprintf("%09d", v.Int64()) +} + +func filterValidSetCookies(setCookies []string) []string { + if len(setCookies) == 0 { + return nil + } + out := make([]string, 0, len(setCookies)) + for _, sc := range setCookies { + if strings.Contains(sc, "Max-Age=0") || strings.Contains(sc, "1970") { + continue + } + out = append(out, sc) + } + return out +} + // MergeSetCookies 将 Set-Cookie 头合并到 Cookie 头字符串。只保留 name=value, // 忽略 Path/Domain/Expires 等属性,因为后续出站请求只需要 Cookie header。 func MergeSetCookies(original string, setCookies []string) string { diff --git a/internal/xianyu/renew/service_test.go b/internal/xianyu/renew/service_test.go index 840c67f..751c546 100644 --- a/internal/xianyu/renew/service_test.go +++ b/internal/xianyu/renew/service_test.go @@ -3,10 +3,14 @@ package renew import ( "context" "fmt" + "io" "net/http" "net/http/httptest" + "net/url" + "regexp" "strings" "testing" + "time" ) func TestMergeSetCookies(t *testing.T) { @@ -35,6 +39,13 @@ func TestRenewAPIFirstSuccess(t *testing.T) { _, _ = w.Write([]byte(`{"content":{"success":true}}`)) case "/setLoginSettings.do": // 只有这个接口返回 Set-Cookie 才代表长登录续期真正成功。 + body, _ := io.ReadAll(r.Body) + if string(body) != "status=0" { + t.Fatalf("setLoginSettings body=%q, want status=0", string(body)) + } + if r.URL.Query().Get("bizEntrance") != "web" { + t.Fatalf("setLoginSettings query=%s", r.URL.RawQuery) + } http.SetCookie(w, &http.Cookie{Name: "havana_lgc2_77", Value: "lgc"}) _, _ = w.Write([]byte(`{"content":{"success":true}}`)) default: @@ -48,6 +59,7 @@ func TestRenewAPIFirstSuccess(t *testing.T) { HasLoginURL: srv.URL + "/hasLogin.do", SilentHasLoginURL: srv.URL + "/silentHasLogin.do", SetLoginSettingsURL: srv.URL + "/setLoginSettings.do", + RetryDelay: -1, } res, err := svc.RenewAPIFirst(context.Background(), "unb=1; cookie2=c2; _tb_token_=csrf") if err != nil { @@ -63,6 +75,171 @@ func TestRenewAPIFirstSuccess(t *testing.T) { } } +func TestRenewAPIFirstMatchesReferenceRequestShape(t *testing.T) { + var hasLoginBody string + var hasLoginReferer string + var hasLoginBXV string + var hasLoginHeaders http.Header + var silentHeaders http.Header + var silentQuery url.Values + var settingBody string + var settingHeaders http.Header + var settingQuery url.Values + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/hasLogin.do": + body, _ := io.ReadAll(r.Body) + hasLoginBody = string(body) + hasLoginReferer = r.Header.Get("Referer") + hasLoginBXV = r.Header.Get("bx-v") + hasLoginHeaders = r.Header.Clone() + _, _ = w.Write([]byte(`{"content":{"success":true}}`)) + case "/silentHasLogin.do": + silentHeaders = r.Header.Clone() + silentQuery = r.URL.Query() + _, _ = w.Write([]byte(`{"content":{"success":true},"marker":"silent"}`)) + case "/setLoginSettings.do": + body, _ := io.ReadAll(r.Body) + settingBody = string(body) + settingHeaders = r.Header.Clone() + settingQuery = r.URL.Query() + http.SetCookie(w, &http.Cookie{Name: "havana_lgc2_77", Value: "lgc"}) + _, _ = w.Write([]byte(`{"content":{"success":true},"marker":"settings"}`)) + default: + http.NotFound(w, r) + } + })) + defer srv.Close() + + svc := Service{ + HTTPClient: srv.Client(), + HasLoginURL: srv.URL + "/hasLogin.do", + SilentHasLoginURL: srv.URL + "/silentHasLogin.do", + SetLoginSettingsURL: srv.URL + "/setLoginSettings.do", + RetryDelay: -1, + } + res, err := svc.RenewAPIFirst(context.Background(), "unb=1; cookie2=c2; _tb_token_=csrf; _uab_collina=umid; XSRF-TOKEN=xsrf") + if err != nil { + t.Fatalf("RenewAPIFirst: %v", err) + } + if !strings.Contains(res.ResponseText, `"marker":"silent"`) || strings.Contains(res.ResponseText, `"marker":"settings"`) { + t.Fatalf("ResponseText 应来自 silentHasLogin 响应,got %q", res.ResponseText) + } + values, err := url.ParseQuery(hasLoginBody) + if err != nil { + t.Fatalf("hasLogin body parse: %v", err) + } + for _, key := range []string{"hid", "ltl", "appName", "appEntrance", "_csrf_token", "umidToken", "hsiz", "bizParams", "mainPage", "isMobile", "lang", "returnUrl", "fromSite", "isIframe", "documentReferer", "defaultView", "umidTag", "deviceId", "pageTraceId"} { + if _, ok := values[key]; !ok { + t.Fatalf("hasLogin body missing %s: %s", key, hasLoginBody) + } + } + if !regexp.MustCompile(`^21504\d{19}$`).MatchString(values.Get("pageTraceId")) { + t.Fatalf("pageTraceId=%q", values.Get("pageTraceId")) + } + if !strings.Contains(hasLoginReferer, "mini_login.htm") || !strings.Contains(hasLoginReferer, "rnd=") { + t.Fatalf("hasLogin Referer=%q", hasLoginReferer) + } + if hasLoginBXV != "2.5.31" { + t.Fatalf("hasLogin bx-v=%q", hasLoginBXV) + } + if got := hasLoginHeaders.Get("Accept-Language"); got != "zh-CN" { + t.Fatalf("hasLogin Accept-Language=%q", got) + } + if got := hasLoginHeaders.Get("sec-ch-ua"); got != hasLoginSecChUA { + t.Fatalf("hasLogin sec-ch-ua=%q", got) + } + if got := hasLoginHeaders.Get("x-xsrf-token"); got != "xsrf" { + t.Fatalf("hasLogin x-xsrf-token=%q", got) + } + if silentQuery.Get("documentReferer") != "https://www.goofish.com/" || + silentQuery.Get("appEntrance") != "xianyu_sdkSilent" || + silentQuery.Get("fromSite") != "0" { + t.Fatalf("silentHasLogin query=%s", silentQuery.Encode()) + } + if got := silentHeaders.Get("Accept"); got != "*/*" { + t.Fatalf("silentHasLogin Accept=%q", got) + } + if got := silentHeaders.Get("sec-ch-ua-platform"); got != `"Win32"` { + t.Fatalf("silentHasLogin sec-ch-ua-platform=%q", got) + } + if got := silentHeaders.Get("sec-fetch-site"); got != "same-site" { + t.Fatalf("silentHasLogin sec-fetch-site=%q", got) + } + if settingBody != "status=0" { + t.Fatalf("setLoginSettings body=%q", settingBody) + } + if settingQuery.Get("fromSite") != "77" || settingQuery.Get("appName") != "xianyu" || settingQuery.Get("bizEntrance") != "web" { + t.Fatalf("setLoginSettings query=%s", settingQuery.Encode()) + } + if got := settingHeaders.Get("Content-Type"); got != "application/x-www-form-urlencoded" { + t.Fatalf("setLoginSettings Content-Type=%q", got) + } + if got := settingHeaders.Get("sec-ch-ua"); got != settingSecChUA { + t.Fatalf("setLoginSettings sec-ch-ua=%q", got) + } + for name, headers := range map[string]http.Header{ + "hasLogin": hasLoginHeaders, + "silentHasLogin": silentHeaders, + "setLoginSettings": settingHeaders, + } { + if got := headers.Get("Origin"); got != "" { + t.Fatalf("%s Origin should be empty, got %q", name, got) + } + if got := headers.Get("Cookie"); strings.ContainsAny(got, "\r\n") { + t.Fatalf("%s Cookie 未清理换行: %q", name, got) + } + } +} + +func TestRenewAPIFirstDoesNotFollowRedirects(t *testing.T) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/hasLogin.do": + w.Header().Set("Location", "/unexpected") + w.WriteHeader(http.StatusFound) + _, _ = w.Write([]byte(`{"content":{"success":true}}`)) + case "/silentHasLogin.do": + _, _ = w.Write([]byte(`{"content":{"success":true}}`)) + case "/setLoginSettings.do": + http.SetCookie(w, &http.Cookie{Name: "havana_lgc2_77", Value: "lgc"}) + _, _ = w.Write([]byte(`{"content":{"success":true}}`)) + default: + t.Fatalf("request followed redirect to %s", r.URL.Path) + } + })) + defer srv.Close() + + svc := Service{ + HTTPClient: srv.Client(), + HasLoginURL: srv.URL + "/hasLogin.do", + SilentHasLoginURL: srv.URL + "/silentHasLogin.do", + SetLoginSettingsURL: srv.URL + "/setLoginSettings.do", + RetryDelay: -1, + } + res, err := svc.RenewAPIFirst(context.Background(), "unb=1; cookie2=c2") + if err != nil { + t.Fatalf("RenewAPIFirst: %v", err) + } + if !res.Success { + t.Fatalf("RenewAPIFirst should continue after 302 without redirect: %#v", res) + } +} + +func TestMergeSetCookiesIgnoresDeletionCookies(t *testing.T) { + got := MergeSetCookies("old=a", filterValidSetCookies([]string{ + "old=; Max-Age=0; Path=/", + "gone=x; Expires=Thu, 01 Jan 1970 00:00:00 GMT", + "new=b; Path=/", + })) + if strings.Contains(got, "gone=") || strings.Contains(got, "old=") && !strings.Contains(got, "old=a") { + t.Fatalf("deletion cookies should be ignored: %q", got) + } + if !strings.Contains(got, "old=a") || !strings.Contains(got, "new=b") { + t.Fatalf("valid cookies missing: %q", got) + } +} + func TestRenewAPIFirstKeepsPartialCookiesWhenLongLoginFails(t *testing.T) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { @@ -85,6 +262,7 @@ func TestRenewAPIFirstKeepsPartialCookiesWhenLongLoginFails(t *testing.T) { HasLoginURL: srv.URL + "/hasLogin.do", SilentHasLoginURL: srv.URL + "/silentHasLogin.do", SetLoginSettingsURL: srv.URL + "/setLoginSettings.do", + RetryDelay: -1, } res, err := svc.RenewAPIFirst(context.Background(), "unb=1; cookie2=c2") if err != nil { @@ -98,6 +276,32 @@ func TestRenewAPIFirstKeepsPartialCookiesWhenLongLoginFails(t *testing.T) { } } +func TestRenewAPIFirstKeepsOriginalStringWhenNoSetCookies(t *testing.T) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + _, _ = w.Write([]byte(`{"content":{"success":true}}`)) + })) + defer srv.Close() + + svc := Service{ + HTTPClient: srv.Client(), + HasLoginURL: srv.URL + "/hasLogin.do", + SilentHasLoginURL: srv.URL + "/silentHasLogin.do", + SetLoginSettingsURL: srv.URL + "/setLoginSettings.do", + RetryDelay: -1, + } + original := "unb=1; cookie2=c2" + res, err := svc.RenewAPIFirst(context.Background(), original) + if err != nil { + t.Fatalf("RenewAPIFirst: %v", err) + } + if res.Success { + t.Fatalf("setLoginSettings 无 Set-Cookie 不应成功: %#v", res) + } + if res.NewCookies != original || len(res.UpdatedCookieNames) != 0 { + t.Fatalf("无 Set-Cookie 时不应重排/标记更新: %#v", res) + } +} + func TestRenewAPIFirstSkipsHasLoginWithoutUNB(t *testing.T) { calls := 0 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -111,6 +315,7 @@ func TestRenewAPIFirstSkipsHasLoginWithoutUNB(t *testing.T) { HasLoginURL: srv.URL + "/hasLogin.do", SilentHasLoginURL: srv.URL + "/silentHasLogin.do", SetLoginSettingsURL: srv.URL + "/setLoginSettings.do", + RetryDelay: -1, } _, err := svc.RenewAPIFirst(context.Background(), "cookie2=c2") if err != nil { @@ -120,3 +325,37 @@ func TestRenewAPIFirstSkipsHasLoginWithoutUNB(t *testing.T) { t.Fatalf("缺少 unb 时 hasLogin 应跳过,只调用后两步,calls=%d", calls) } } + +func TestRenewAPIFirstRetriesLongLoginOnce(t *testing.T) { + setCalls := 0 + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/hasLogin.do", "/silentHasLogin.do": + _, _ = w.Write([]byte(`{"content":{"success":true}}`)) + case "/setLoginSettings.do": + setCalls++ + if setCalls == 2 { + http.SetCookie(w, &http.Cookie{Name: "havana_lgc2_77", Value: "lgc"}) + } + _, _ = w.Write([]byte(`{"content":{"success":true}}`)) + default: + http.NotFound(w, r) + } + })) + defer srv.Close() + + svc := Service{ + HTTPClient: srv.Client(), + HasLoginURL: srv.URL + "/hasLogin.do", + SilentHasLoginURL: srv.URL + "/silentHasLogin.do", + SetLoginSettingsURL: srv.URL + "/setLoginSettings.do", + RetryDelay: time.Nanosecond, + } + res, err := svc.RenewAPIFirst(context.Background(), "unb=1; cookie2=c2") + if err != nil { + t.Fatalf("RenewAPIFirst: %v", err) + } + if !res.Success || setCalls != 2 || !strings.Contains(res.NewCookies, "havana_lgc2_77=lgc") { + t.Fatalf("retry result=%#v setCalls=%d", res, setCalls) + } +}