From 22656c20f182b38bf17b57798b8ffb6a52d31482 Mon Sep 17 00:00:00 2001 From: Christ Date: Sat, 15 Aug 2026 02:31:07 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B6=E6=AE=B5=E4=B8=83=EF=BC=9A=E5=AE=8C?= =?UTF-8?q?=E6=88=90React=20feature=E4=BE=9D=E8=B5=96=E9=97=A8=E7=A6=81?= =?UTF-8?q?=E4=B8=8E=E6=97=A7=E5=85=A5=E5=8F=A3=E7=98=A6=E8=BA=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .commentlint/frontend-baseline.json | 2514 ++++++++--------- docs/architecture/refactoring-master-plan.md | 1 + frontend/App.tsx | 2 +- .../features/accounts/runtime.test.ts} | 35 +- frontend/app/features/accounts/state.test.ts | 59 + .../app/features/cards/batchState.test.ts | 6 + .../app/features/rules/issueState.test.ts | 50 + frontend/app/features/session/api.ts | 2 + frontend/app/features/system/api.ts | 3 + frontend/app/features/system/types.ts | 7 + frontend/components/Sidebar.tsx | 12 +- frontend/components/accountEdit.test.ts | 62 - frontend/components/accountEdit.ts | 8 - frontend/components/accountPause.test.ts | 17 - frontend/components/accountPause.ts | 2 - frontend/components/accountRuntimeState.ts | 2 - .../components/automationIssueState.test.ts | 43 - frontend/components/automationIssueState.ts | 8 - frontend/components/cardListState.test.ts | 19 - frontend/components/cardListState.ts | 7 - .../components/itemPublishBatchState.test.ts | 10 - frontend/components/itemPublishBatchState.ts | 3 - frontend/components/orderImportState.ts | 8 - frontend/featureArchitecture.test.ts | 79 + frontend/services/api.test.ts | 12 +- frontend/services/api.ts | 5 + .../{index-jRlHx8b7.js => index-D15oV9g9.js} | 14 +- .../webui/static/assets/index-DFFQFH9n.css | 1 - .../webui/static/assets/index-Dptuvwg-.css | 1 + internal/webui/static/index.html | 4 +- 30 files changed, 1485 insertions(+), 1511 deletions(-) rename frontend/{components/accountRuntimeState.test.ts => app/features/accounts/runtime.test.ts} (51%) create mode 100644 frontend/app/features/rules/issueState.test.ts create mode 100644 frontend/app/features/session/api.ts create mode 100644 frontend/app/features/system/api.ts create mode 100644 frontend/app/features/system/types.ts delete mode 100644 frontend/components/accountEdit.test.ts delete mode 100644 frontend/components/accountEdit.ts delete mode 100644 frontend/components/accountPause.test.ts delete mode 100644 frontend/components/accountPause.ts delete mode 100644 frontend/components/accountRuntimeState.ts delete mode 100644 frontend/components/automationIssueState.test.ts delete mode 100644 frontend/components/automationIssueState.ts delete mode 100644 frontend/components/cardListState.test.ts delete mode 100644 frontend/components/cardListState.ts delete mode 100644 frontend/components/itemPublishBatchState.test.ts delete mode 100644 frontend/components/itemPublishBatchState.ts delete mode 100644 frontend/components/orderImportState.ts create mode 100644 frontend/featureArchitecture.test.ts rename internal/webui/static/assets/{index-jRlHx8b7.js => index-D15oV9g9.js} (70%) delete mode 100644 internal/webui/static/assets/index-DFFQFH9n.css create mode 100644 internal/webui/static/assets/index-Dptuvwg-.css diff --git a/.commentlint/frontend-baseline.json b/.commentlint/frontend-baseline.json index 39198e3..d3c1c05 100644 --- a/.commentlint/frontend-baseline.json +++ b/.commentlint/frontend-baseline.json @@ -479,6 +479,36 @@ "kind": "variable", "name": "controller" }, + { + "file": "app/features/accounts/runtime.test.ts", + "line": 14, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "app/features/accounts/runtime.test.ts", + "line": 15, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "app/features/accounts/runtime.test.ts", + "line": 34, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "app/features/accounts/runtime.test.ts", + "line": 41, + "kind": "variable", + "name": "result" + }, + { + "file": "app/features/accounts/runtime.test.ts", + "line": 54, + "kind": "function-expression", + "name": "anonymous" + }, { "file": "app/features/accounts/state.test.ts", "line": 32, @@ -1895,6 +1925,54 @@ "kind": "function-expression", "name": "anonymous" }, + { + "file": "app/features/rules/issueState.test.ts", + "line": 22, + "kind": "variable", + "name": "invalid" + }, + { + "file": "app/features/rules/issueState.test.ts", + "line": 31, + "kind": "variable", + "name": "visible" + }, + { + "file": "app/features/rules/issueState.test.ts", + "line": 36, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "app/features/rules/issueState.test.ts", + "line": 42, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "app/features/rules/issueState.test.ts", + "line": 43, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "app/features/rules/issueState.test.ts", + "line": 44, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "app/features/rules/issueState.test.ts", + "line": 45, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "app/features/rules/issueState.test.ts", + "line": 46, + "kind": "function-expression", + "name": "anonymous" + }, { "file": "app/features/settings/hooks.ts", "line": 105, @@ -2465,66 +2543,6 @@ "kind": "variable", "name": "shouldSaveNotificationBindings" }, - { - "file": "components/accountEdit.test.ts", - "line": 16, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/accountEdit.test.ts", - "line": 17, - "kind": "variable", - "name": "payload" - }, - { - "file": "components/accountEdit.test.ts", - "line": 29, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/accountEdit.test.ts", - "line": 30, - "kind": "variable", - "name": "payload" - }, - { - "file": "components/accountEdit.test.ts", - "line": 38, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/accountEdit.test.ts", - "line": 39, - "kind": "variable", - "name": "payload" - }, - { - "file": "components/accountEdit.test.ts", - "line": 4, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/accountEdit.test.ts", - "line": 5, - "kind": "variable", - "name": "payload" - }, - { - "file": "components/accountEdit.test.ts", - "line": 51, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/accountEdit.test.ts", - "line": 52, - "kind": "variable", - "name": "payload" - }, { "file": "components/AccountList.tsx", "line": 151, @@ -2795,162 +2813,6 @@ "kind": "function-expression", "name": "anonymous" }, - { - "file": "components/accountPause.test.ts", - "line": 13, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/accountPause.test.ts", - "line": 4, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/accountPause.test.ts", - "line": 5, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/accountPause.test.ts", - "line": 9, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/accountRuntimeState.test.ts", - "line": 13, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/accountRuntimeState.test.ts", - "line": 14, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/accountRuntimeState.test.ts", - "line": 15, - "kind": "variable", - "name": "result" - }, - { - "file": "components/accountRuntimeState.test.ts", - "line": 39, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/accountRuntimeState.test.ts", - "line": 40, - "kind": "variable", - "name": "current" - }, - { - "file": "components/accountRuntimeState.test.ts", - "line": 45, - "kind": "variable", - "name": "result" - }, - { - "file": "components/accountRuntimeState.test.ts", - "line": 5, - "kind": "variable", - "name": "account" - }, - { - "file": "components/accountRuntimeState.test.ts", - "line": 58, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/accountRuntimeState.test.ts", - "line": 59, - "kind": "variable", - "name": "current" - }, - { - "file": "components/automationIssueState.test.ts", - "line": 18, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/automationIssueState.test.ts", - "line": 19, - "kind": "variable", - "name": "invalid" - }, - { - "file": "components/automationIssueState.test.ts", - "line": 25, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/automationIssueState.test.ts", - "line": 26, - "kind": "variable", - "name": "visible" - }, - { - "file": "components/automationIssueState.test.ts", - "line": 31, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/automationIssueState.test.ts", - "line": 32, - "kind": "variable", - "name": "receivedRules" - }, - { - "file": "components/automationIssueState.test.ts", - "line": 33, - "kind": "variable", - "name": "errors" - }, - { - "file": "components/automationIssueState.test.ts", - "line": 35, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/automationIssueState.test.ts", - "line": 36, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/automationIssueState.test.ts", - "line": 37, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/automationIssueState.test.ts", - "line": 38, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/automationIssueState.test.ts", - "line": 39, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/automationIssueState.test.ts", - "line": 5, - "kind": "variable", - "name": "issue" - }, { "file": "components/CardList.tsx", "line": 107, @@ -3425,30 +3287,6 @@ "kind": "variable", "name": "updateData" }, - { - "file": "components/cardListState.test.ts", - "line": 11, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/cardListState.test.ts", - "line": 12, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/cardListState.test.ts", - "line": 16, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/cardListState.test.ts", - "line": 5, - "kind": "variable", - "name": "cards" - }, { "file": "components/Chat.tsx", "line": 122, @@ -4823,12 +4661,6 @@ "kind": "function-expression", "name": "anonymous" }, - { - "file": "components/itemPublishBatchState.test.ts", - "line": 4, - "kind": "function-expression", - "name": "anonymous" - }, { "file": "components/latestRequest.test.ts", "line": 4, @@ -7151,138 +6983,114 @@ "kind": "function-expression", "name": "anonymous" }, - { - "file": "components/Sidebar.tsx", - "line": 10, - "kind": "member", - "name": "isAdmin" - }, - { - "file": "components/Sidebar.tsx", - "line": 11, - "kind": "member", - "name": "collapsed" - }, { "file": "components/Sidebar.tsx", "line": 12, "kind": "member", - "name": "onToggleCollapsed" + "name": "activeTab" }, { "file": "components/Sidebar.tsx", "line": 13, "kind": "member", - "name": "onNavigate" + "name": "isAdmin" }, { "file": "components/Sidebar.tsx", "line": 14, "kind": "member", + "name": "collapsed" + }, + { + "file": "components/Sidebar.tsx", + "line": 15, + "kind": "member", + "name": "onToggleCollapsed" + }, + { + "file": "components/Sidebar.tsx", + "line": 16, + "kind": "member", + "name": "onNavigate" + }, + { + "file": "components/Sidebar.tsx", + "line": 17, + "kind": "member", "name": "onLogout" }, { "file": "components/Sidebar.tsx", - "line": 18, - "kind": "member", - "name": "version" - }, - { - "file": "components/Sidebar.tsx", - "line": 19, - "kind": "member", - "name": "commit" - }, - { - "file": "components/Sidebar.tsx", - "line": 22, + "line": 20, "kind": "variable", "name": "Sidebar" }, { "file": "components/Sidebar.tsx", - "line": 25, + "line": 23, "kind": "variable", "name": "[buildInfo, setBuildInfo]" }, { "file": "components/Sidebar.tsx", - "line": 27, + "line": 25, "kind": "function-expression", "name": "anonymous" }, { "file": "components/Sidebar.tsx", - "line": 28, - "kind": "variable", - "name": "controller" - }, - { - "file": "components/Sidebar.tsx", - "line": 30, + "line": 29, "kind": "function-expression", "name": "anonymous" }, { "file": "components/Sidebar.tsx", - "line": 31, + "line": 33, "kind": "function-expression", "name": "anonymous" }, { "file": "components/Sidebar.tsx", - "line": 35, + "line": 36, "kind": "function-expression", "name": "anonymous" }, { "file": "components/Sidebar.tsx", - "line": 38, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/Sidebar.tsx", - "line": 41, + "line": 39, "kind": "variable", "name": "menuItems" }, { "file": "components/Sidebar.tsx", - "line": 52, + "line": 50, "kind": "variable", "name": "displayVersion" }, { "file": "components/Sidebar.tsx", - "line": 69, + "line": 67, "kind": "function-expression", "name": "anonymous" }, { "file": "components/Sidebar.tsx", - "line": 70, + "line": 68, "kind": "variable", "name": "Icon" }, { "file": "components/Sidebar.tsx", - "line": 71, + "line": 69, "kind": "variable", "name": "active" }, { "file": "components/Sidebar.tsx", - "line": 79, + "line": 77, "kind": "function-expression", "name": "anonymous" }, - { - "file": "components/Sidebar.tsx", - "line": 9, - "kind": "member", - "name": "activeTab" - }, { "file": "components/sidebarState.test.ts", "line": 10, @@ -7637,6 +7445,120 @@ "kind": "variable", "name": "date" }, + { + "file": "featureArchitecture.test.ts", + "line": 21, + "kind": "member", + "name": "relativePath" + }, + { + "file": "featureArchitecture.test.ts", + "line": 21, + "kind": "member", + "name": "source" + }, + { + "file": "featureArchitecture.test.ts", + "line": 22, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "featureArchitecture.test.ts", + "line": 23, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "featureArchitecture.test.ts", + "line": 28, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "featureArchitecture.test.ts", + "line": 29, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "featureArchitecture.test.ts", + "line": 32, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "featureArchitecture.test.ts", + "line": 33, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "featureArchitecture.test.ts", + "line": 34, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "featureArchitecture.test.ts", + "line": 39, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "featureArchitecture.test.ts", + "line": 42, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "featureArchitecture.test.ts", + "line": 43, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "featureArchitecture.test.ts", + "line": 48, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "featureArchitecture.test.ts", + "line": 51, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "featureArchitecture.test.ts", + "line": 52, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "featureArchitecture.test.ts", + "line": 53, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "featureArchitecture.test.ts", + "line": 58, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "featureArchitecture.test.ts", + "line": 70, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "featureArchitecture.test.ts", + "line": 9, + "kind": "function-expression", + "name": "anonymous" + }, { "file": "index.tsx", "line": 11, @@ -8827,19 +8749,25 @@ }, { "file": "services/api.test.ts", - "line": 112, + "line": 108, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 121, - "kind": "variable", - "name": "settings" + "line": 109, + "kind": "function-expression", + "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 130, + "line": 109, + "kind": "variable", + "name": "fetchMock" + }, + { + "file": "services/api.test.ts", + "line": 122, "kind": "function-expression", "name": "anonymous" }, @@ -8847,19 +8775,7 @@ "file": "services/api.test.ts", "line": 131, "kind": "variable", - "name": "fetchMock" - }, - { - "file": "services/api.test.ts", - "line": 137, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.test.ts", - "line": 138, - "kind": "variable", - "name": "fetchMock" + "name": "settings" }, { "file": "services/api.test.ts", @@ -8867,6 +8783,24 @@ "kind": "function-expression", "name": "anonymous" }, + { + "file": "services/api.test.ts", + "line": 141, + "kind": "variable", + "name": "fetchMock" + }, + { + "file": "services/api.test.ts", + "line": 147, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.test.ts", + "line": 148, + "kind": "variable", + "name": "fetchMock" + }, { "file": "services/api.test.ts", "line": 150, @@ -8875,13 +8809,7 @@ }, { "file": "services/api.test.ts", - "line": 151, - "kind": "variable", - "name": "fetchMock" - }, - { - "file": "services/api.test.ts", - "line": 159, + "line": 160, "kind": "function-expression", "name": "anonymous" }, @@ -8889,17 +8817,11 @@ "file": "services/api.test.ts", "line": 161, "kind": "variable", - "name": "result" + "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 165, - "kind": "variable", - "name": "jsonResponse" - }, - { - "file": "services/api.test.ts", - "line": 170, + "line": 169, "kind": "function-expression", "name": "anonymous" }, @@ -8907,20 +8829,26 @@ "file": "services/api.test.ts", "line": 171, "kind": "variable", - "name": "fetchMock" - }, - { - "file": "services/api.test.ts", - "line": 176, - "kind": "variable", "name": "result" }, { "file": "services/api.test.ts", - "line": 182, + "line": 175, + "kind": "variable", + "name": "jsonResponse" + }, + { + "file": "services/api.test.ts", + "line": 180, "kind": "function-expression", "name": "anonymous" }, + { + "file": "services/api.test.ts", + "line": 181, + "kind": "variable", + "name": "fetchMock" + }, { "file": "services/api.test.ts", "line": 186, @@ -8929,100 +8857,100 @@ }, { "file": "services/api.test.ts", - "line": 190, + "line": 192, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 204, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.test.ts", - "line": 224, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.test.ts", - "line": 244, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.test.ts", - "line": 264, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.test.ts", - "line": 265, + "line": 196, "kind": "variable", - "name": "fetchMock" + "name": "result" + }, + { + "file": "services/api.test.ts", + "line": 200, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.test.ts", + "line": 214, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.test.ts", + "line": 234, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.test.ts", + "line": 254, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.test.ts", + "line": 274, + "kind": "function-expression", + "name": "anonymous" }, { "file": "services/api.test.ts", "line": 275, "kind": "variable", - "name": "result" - }, - { - "file": "services/api.test.ts", - "line": 298, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.test.ts", - "line": 299, - "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 304, + "line": 285, "kind": "variable", "name": "result" }, { "file": "services/api.test.ts", - "line": 313, + "line": 308, "kind": "function-expression", "name": "anonymous" }, + { + "file": "services/api.test.ts", + "line": 309, + "kind": "variable", + "name": "fetchMock" + }, { "file": "services/api.test.ts", "line": 314, "kind": "variable", - "name": "fetchMock" - }, - { - "file": "services/api.test.ts", - "line": 321, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.test.ts", - "line": 323, - "kind": "variable", "name": "result" }, { "file": "services/api.test.ts", - "line": 327, + "line": 323, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 328, + "line": 324, "kind": "variable", "name": "fetchMock" }, + { + "file": "services/api.test.ts", + "line": 331, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.test.ts", + "line": 333, + "kind": "variable", + "name": "result" + }, { "file": "services/api.test.ts", "line": 337, @@ -9049,73 +8977,85 @@ }, { "file": "services/api.test.ts", - "line": 359, + "line": 357, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.test.ts", + "line": 358, + "kind": "variable", + "name": "fetchMock" + }, + { + "file": "services/api.test.ts", + "line": 369, "kind": "variable", "name": "body" }, { "file": "services/api.test.ts", - "line": 363, + "line": 373, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 378, + "line": 388, "kind": "variable", "name": "items" }, { "file": "services/api.test.ts", - "line": 393, + "line": 403, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 394, + "line": 404, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 405, + "line": 415, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 411, + "line": 421, "kind": "variable", "name": "settings" }, { "file": "services/api.test.ts", - "line": 416, + "line": 426, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 417, + "line": 427, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 428, + "line": 438, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 429, + "line": 439, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 429, + "line": 439, "kind": "variable", "name": "fetchMock" }, @@ -9127,46 +9067,46 @@ }, { "file": "services/api.test.ts", - "line": 455, + "line": 465, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 456, + "line": 466, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 470, + "line": 480, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 484, + "line": 494, "kind": "variable", "name": "accounts" }, - { - "file": "services/api.test.ts", - "line": 495, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.test.ts", - "line": 496, - "kind": "variable", - "name": "fetchMock" - }, { "file": "services/api.test.ts", "line": 50, "kind": "function-expression", "name": "anonymous" }, + { + "file": "services/api.test.ts", + "line": 505, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.test.ts", + "line": 506, + "kind": "variable", + "name": "fetchMock" + }, { "file": "services/api.test.ts", "line": 51, @@ -9175,64 +9115,58 @@ }, { "file": "services/api.test.ts", - "line": 510, + "line": 520, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 511, + "line": 521, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 522, + "line": 532, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 523, + "line": 533, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 536, + "line": 546, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 537, + "line": 547, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 554, + "line": 564, "kind": "variable", "name": "status" }, { "file": "services/api.test.ts", - "line": 562, + "line": 572, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 569, + "line": 579, "kind": "variable", "name": "controller" }, - { - "file": "services/api.test.ts", - "line": 580, - "kind": "function-expression", - "name": "anonymous" - }, { "file": "services/api.test.ts", "line": 59, @@ -9241,61 +9175,49 @@ }, { "file": "services/api.test.ts", - "line": 60, - "kind": "variable", - "name": "fetchMock" - }, - { - "file": "services/api.test.ts", - "line": 603, - "kind": "variable", - "name": "rules" - }, - { - "file": "services/api.test.ts", - "line": 617, + "line": 590, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 618, + "line": 613, "kind": "variable", - "name": "fetchMock" + "name": "rules" }, { "file": "services/api.test.ts", "line": 627, - "kind": "variable", - "name": "rules" - }, - { - "file": "services/api.test.ts", - "line": 63, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 639, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.test.ts", - "line": 640, + "line": 628, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 655, + "line": 63, + "kind": "variable", + "name": "controller" + }, + { + "file": "services/api.test.ts", + "line": 637, + "kind": "variable", + "name": "rules" + }, + { + "file": "services/api.test.ts", + "line": 649, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 656, + "line": 650, "kind": "variable", "name": "fetchMock" }, @@ -9313,261 +9235,249 @@ }, { "file": "services/api.test.ts", - "line": 677, + "line": 675, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 678, + "line": 676, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 693, + "line": 687, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.test.ts", + "line": 688, + "kind": "variable", + "name": "fetchMock" + }, + { + "file": "services/api.test.ts", + "line": 69, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.test.ts", + "line": 70, + "kind": "variable", + "name": "fetchMock" + }, + { + "file": "services/api.test.ts", + "line": 703, "kind": "variable", "name": "body" }, { "file": "services/api.test.ts", - "line": 701, + "line": 711, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 702, + "line": 712, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 713, + "line": 723, "kind": "variable", "name": "body" }, { "file": "services/api.test.ts", - "line": 720, + "line": 73, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 721, + "line": 730, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.test.ts", + "line": 731, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 735, + "line": 745, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 736, + "line": 746, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 75, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.test.ts", - "line": 757, + "line": 767, "kind": "variable", "name": "body" }, { "file": "services/api.test.ts", - "line": 773, + "line": 783, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 774, + "line": 784, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 802, + "line": 812, "kind": "variable", "name": "body" }, { "file": "services/api.test.ts", - "line": 826, + "line": 836, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 827, + "line": 837, "kind": "variable", "name": "fetchMock" }, - { - "file": "services/api.test.ts", - "line": 839, - "kind": "variable", - "name": "body" - }, - { - "file": "services/api.test.ts", - "line": 840, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.test.ts", - "line": 840, - "kind": "member", - "name": "action_type" - }, - { - "file": "services/api.test.ts", - "line": 848, - "kind": "function-expression", - "name": "anonymous" - }, { "file": "services/api.test.ts", "line": 849, "kind": "variable", - "name": "fetchMock" - }, - { - "file": "services/api.test.ts", - "line": 866, - "kind": "variable", "name": "body" }, { "file": "services/api.test.ts", - "line": 98, + "line": 85, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 99, + "line": 850, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 99, + "line": 850, + "kind": "member", + "name": "action_type" + }, + { + "file": "services/api.test.ts", + "line": 858, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.test.ts", + "line": 859, "kind": "variable", "name": "fetchMock" }, { - "file": "services/api.ts", - "line": 100, + "file": "services/api.test.ts", + "line": 876, "kind": "variable", - "name": "getAccountTaskSettings" + "name": "body" }, { "file": "services/api.ts", - "line": 1001, + "line": 1006, "kind": "variable", "name": "setMessageNotification" }, { "file": "services/api.ts", - "line": 1005, + "line": 1010, "kind": "variable", "name": "deleteMessageNotification" }, { "file": "services/api.ts", - "line": 1009, + "line": 1014, "kind": "variable", "name": "deleteAccountNotifications" }, { "file": "services/api.ts", - "line": 1015, + "line": 1020, "kind": "variable", "name": "result" }, { "file": "services/api.ts", - "line": 1019, + "line": 1024, "kind": "variable", "name": "setAccountBindings" }, { "file": "services/api.ts", - "line": 1029, + "line": 1034, "kind": "variable", "name": "getDefaultReplies" }, { "file": "services/api.ts", - "line": 103, - "kind": "variable", - "name": "updateAccountTaskSettings" - }, - { - "file": "services/api.ts", - "line": 1033, + "line": 1038, "kind": "variable", "name": "getDefaultReply" }, { "file": "services/api.ts", - "line": 1034, + "line": 1039, "kind": "variable", "name": "result" }, { "file": "services/api.ts", - "line": 1044, + "line": 1049, "kind": "variable", "name": "updateDefaultReply" }, { "file": "services/api.ts", - "line": 1053, + "line": 105, + "kind": "variable", + "name": "getAccountTaskSettings" + }, + { + "file": "services/api.ts", + "line": 1058, "kind": "variable", "name": "deleteDefaultReply" }, { "file": "services/api.ts", - "line": 1057, + "line": 1062, "kind": "variable", "name": "clearDefaultReplyRecords" }, { "file": "services/api.ts", - "line": 106, + "line": 108, "kind": "variable", - "name": "runAccountTask" - }, - { - "file": "services/api.ts", - "line": 109, - "kind": "member", - "name": "has_more" - }, - { - "file": "services/api.ts", - "line": 109, - "kind": "member", - "name": "next_cursor" - }, - { - "file": "services/api.ts", - "line": 109, - "kind": "member", - "name": "sessions" + "name": "updateAccountTaskSettings" }, { "file": "services/api.ts", @@ -9579,19 +9489,37 @@ "file": "services/api.ts", "line": 111, "kind": "variable", - "name": "getChatSessionPage" + "name": "runAccountTask" }, { "file": "services/api.ts", - "line": 112, + "line": 114, + "kind": "member", + "name": "has_more" + }, + { + "file": "services/api.ts", + "line": 114, + "kind": "member", + "name": "next_cursor" + }, + { + "file": "services/api.ts", + "line": 114, + "kind": "member", + "name": "sessions" + }, + { + "file": "services/api.ts", + "line": 116, "kind": "variable", - "name": "result" + "name": "getChatSessionPage" }, { "file": "services/api.ts", "line": 117, "kind": "variable", - "name": "getChatSessions" + "name": "result" }, { "file": "services/api.ts", @@ -9601,111 +9529,63 @@ }, { "file": "services/api.ts", - "line": 121, + "line": 122, + "kind": "variable", + "name": "getChatSessions" + }, + { + "file": "services/api.ts", + "line": 126, "kind": "member", "name": "messages" }, { "file": "services/api.ts", - "line": 122, + "line": 127, "kind": "member", "name": "has_more" }, { "file": "services/api.ts", - "line": 123, + "line": 128, "kind": "member", "name": "next_cursor" }, { "file": "services/api.ts", - "line": 124, + "line": 129, "kind": "member", "name": "session" }, { "file": "services/api.ts", - "line": 127, + "line": 132, "kind": "variable", "name": "getChatMessagePage" }, { "file": "services/api.ts", - "line": 128, + "line": 133, "kind": "variable", "name": "result" }, { "file": "services/api.ts", - "line": 134, + "line": 139, "kind": "variable", "name": "getChatMessages" }, - { - "file": "services/api.ts", - "line": 137, - "kind": "variable", - "name": "sendChatMessage" - }, - { - "file": "services/api.ts", - "line": 138, - "kind": "member", - "name": "account_id" - }, - { - "file": "services/api.ts", - "line": 138, - "kind": "member", - "name": "buyer_id" - }, - { - "file": "services/api.ts", - "line": 138, - "kind": "member", - "name": "buyer_name" - }, - { - "file": "services/api.ts", - "line": 138, - "kind": "member", - "name": "chat_id" - }, - { - "file": "services/api.ts", - "line": 139, - "kind": "member", - "name": "item_id" - }, - { - "file": "services/api.ts", - "line": 139, - "kind": "member", - "name": "item_title" - }, - { - "file": "services/api.ts", - "line": 139, - "kind": "member", - "name": "text" - }, { "file": "services/api.ts", "line": 14, "kind": "variable", "name": "parsed" }, - { - "file": "services/api.ts", - "line": 140, - "kind": "member", - "name": "message" - }, { "file": "services/api.ts", "line": 142, "kind": "variable", - "name": "sendChatImage" + "name": "sendChatMessage" }, { "file": "services/api.ts", @@ -9731,18 +9611,6 @@ "kind": "member", "name": "chat_id" }, - { - "file": "services/api.ts", - "line": 144, - "kind": "member", - "name": "buyer_avatar_url" - }, - { - "file": "services/api.ts", - "line": 144, - "kind": "member", - "name": "image" - }, { "file": "services/api.ts", "line": 144, @@ -9755,120 +9623,174 @@ "kind": "member", "name": "item_title" }, + { + "file": "services/api.ts", + "line": 144, + "kind": "member", + "name": "text" + }, { "file": "services/api.ts", "line": 145, "kind": "member", "name": "message" }, - { - "file": "services/api.ts", - "line": 146, - "kind": "variable", - "name": "form" - }, { "file": "services/api.ts", "line": 147, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 151, "kind": "variable", - "name": "markChatRead" + "name": "sendChatImage" }, { "file": "services/api.ts", - "line": 155, + "line": 148, "kind": "member", - "name": "state" + "name": "account_id" }, { "file": "services/api.ts", - "line": 156, + "line": 148, + "kind": "member", + "name": "buyer_id" + }, + { + "file": "services/api.ts", + "line": 148, + "kind": "member", + "name": "buyer_name" + }, + { + "file": "services/api.ts", + "line": 148, + "kind": "member", + "name": "chat_id" + }, + { + "file": "services/api.ts", + "line": 149, + "kind": "member", + "name": "buyer_avatar_url" + }, + { + "file": "services/api.ts", + "line": 149, + "kind": "member", + "name": "image" + }, + { + "file": "services/api.ts", + "line": 149, + "kind": "member", + "name": "item_id" + }, + { + "file": "services/api.ts", + "line": 149, + "kind": "member", + "name": "item_title" + }, + { + "file": "services/api.ts", + "line": 150, "kind": "member", "name": "message" }, { "file": "services/api.ts", - "line": 157, + "line": 151, + "kind": "variable", + "name": "form" + }, + { + "file": "services/api.ts", + "line": 152, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.ts", + "line": 156, + "kind": "variable", + "name": "markChatRead" + }, + { + "file": "services/api.ts", + "line": 160, + "kind": "member", + "name": "state" + }, + { + "file": "services/api.ts", + "line": 161, + "kind": "member", + "name": "message" + }, + { + "file": "services/api.ts", + "line": 162, "kind": "member", "name": "connected" }, { "file": "services/api.ts", - "line": 158, + "line": 163, "kind": "member", "name": "failures" }, { "file": "services/api.ts", - "line": 159, + "line": 164, "kind": "member", "name": "updated_at" }, { "file": "services/api.ts", - "line": 162, + "line": 167, "kind": "variable", "name": "getAccountRuntimeStatuses" }, { "file": "services/api.ts", - "line": 166, + "line": 171, "kind": "variable", "name": "generateQRLogin" }, { "file": "services/api.ts", - "line": 171, + "line": 176, "kind": "variable", "name": "checkQRLoginStatus" }, { "file": "services/api.ts", - "line": 175, + "line": 180, "kind": "variable", "name": "completeQRVerification" }, { "file": "services/api.ts", - "line": 189, + "line": 194, "kind": "variable", "name": "updateAccountStatus" }, { "file": "services/api.ts", - "line": 193, + "line": 198, "kind": "variable", "name": "deleteAccount" }, { "file": "services/api.ts", - "line": 197, + "line": 202, "kind": "variable", "name": "updateAccountRemark" }, { "file": "services/api.ts", - "line": 201, + "line": 206, "kind": "variable", "name": "updateAccountAutoConfirm" }, - { - "file": "services/api.ts", - "line": 205, - "kind": "variable", - "name": "updateAccountPauseDuration" - }, - { - "file": "services/api.ts", - "line": 209, - "kind": "variable", - "name": "updateAccountCookie" - }, { "file": "services/api.ts", "line": 21, @@ -9899,114 +9821,114 @@ "kind": "variable", "name": "login" }, + { + "file": "services/api.ts", + "line": 210, + "kind": "variable", + "name": "updateAccountPauseDuration" + }, { "file": "services/api.ts", "line": 214, - "kind": "member", - "name": "cookie" - }, - { - "file": "services/api.ts", - "line": 215, - "kind": "member", - "name": "remark" - }, - { - "file": "services/api.ts", - "line": 216, - "kind": "member", - "name": "auto_confirm" - }, - { - "file": "services/api.ts", - "line": 217, - "kind": "member", - "name": "pause_duration" - }, - { - "file": "services/api.ts", - "line": 218, - "kind": "member", - "name": "username" + "kind": "variable", + "name": "updateAccountCookie" }, { "file": "services/api.ts", "line": 219, "kind": "member", - "name": "login_password" + "name": "cookie" }, { "file": "services/api.ts", "line": 220, "kind": "member", - "name": "clear_password" + "name": "remark" }, { "file": "services/api.ts", "line": 221, "kind": "member", - "name": "show_browser" + "name": "auto_confirm" }, { "file": "services/api.ts", "line": 222, "kind": "member", - "name": "channel_ids" + "name": "pause_duration" + }, + { + "file": "services/api.ts", + "line": 223, + "kind": "member", + "name": "username" + }, + { + "file": "services/api.ts", + "line": 224, + "kind": "member", + "name": "login_password" }, { "file": "services/api.ts", "line": 225, + "kind": "member", + "name": "clear_password" + }, + { + "file": "services/api.ts", + "line": 226, + "kind": "member", + "name": "show_browser" + }, + { + "file": "services/api.ts", + "line": 227, + "kind": "member", + "name": "channel_ids" + }, + { + "file": "services/api.ts", + "line": 230, "kind": "variable", "name": "updateAccountSettings" }, { "file": "services/api.ts", - "line": 230, + "line": 235, "kind": "member", "name": "can_open_long_login" }, { "file": "services/api.ts", - "line": 231, + "line": 236, "kind": "member", "name": "enabled" }, { "file": "services/api.ts", - "line": 234, + "line": 239, "kind": "variable", "name": "getLongLoginSettings" }, { "file": "services/api.ts", - "line": 238, + "line": 243, "kind": "variable", "name": "setLongLoginSettings" }, { "file": "services/api.ts", - "line": 243, + "line": 248, "kind": "member", "name": "success" }, { "file": "services/api.ts", - "line": 244, + "line": 249, "kind": "member", "name": "session_id" }, - { - "file": "services/api.ts", - "line": 245, - "kind": "member", - "name": "status" - }, - { - "file": "services/api.ts", - "line": 246, - "kind": "member", - "name": "message" - }, { "file": "services/api.ts", "line": 25, @@ -10025,132 +9947,126 @@ "kind": "member", "name": "message" }, - { - "file": "services/api.ts", - "line": 252, - "kind": "member", - "name": "account_id" - }, - { - "file": "services/api.ts", - "line": 253, - "kind": "member", - "name": "is_new_account" - }, - { - "file": "services/api.ts", - "line": 254, - "kind": "member", - "name": "cookie_count" - }, { "file": "services/api.ts", "line": 255, "kind": "member", - "name": "verification_url" + "name": "status" }, { "file": "services/api.ts", "line": 256, "kind": "member", - "name": "screenshot_path" + "name": "message" }, { "file": "services/api.ts", "line": 257, "kind": "member", - "name": "qr_code_url" + "name": "account_id" }, { "file": "services/api.ts", "line": 258, "kind": "member", - "name": "error" + "name": "is_new_account" }, { "file": "services/api.ts", "line": 259, "kind": "member", - "name": "reason" + "name": "cookie_count" + }, + { + "file": "services/api.ts", + "line": 260, + "kind": "member", + "name": "verification_url" + }, + { + "file": "services/api.ts", + "line": 261, + "kind": "member", + "name": "screenshot_path" }, { "file": "services/api.ts", "line": 262, - "kind": "variable", - "name": "passwordLogin" + "kind": "member", + "name": "qr_code_url" }, { "file": "services/api.ts", "line": 263, "kind": "member", - "name": "account_id" + "name": "error" }, { "file": "services/api.ts", "line": 264, "kind": "member", + "name": "reason" + }, + { + "file": "services/api.ts", + "line": 267, + "kind": "variable", + "name": "passwordLogin" + }, + { + "file": "services/api.ts", + "line": 268, + "kind": "member", + "name": "account_id" + }, + { + "file": "services/api.ts", + "line": 269, + "kind": "member", "name": "account" }, { "file": "services/api.ts", - "line": 265, + "line": 270, "kind": "member", "name": "password" }, { "file": "services/api.ts", - "line": 266, + "line": 271, "kind": "member", "name": "show_browser" }, { "file": "services/api.ts", - "line": 271, + "line": 276, "kind": "variable", "name": "checkPasswordLoginStatus" }, { "file": "services/api.ts", - "line": 275, + "line": 280, "kind": "variable", "name": "cancelPasswordLogin" }, { "file": "services/api.ts", - "line": 279, + "line": 284, "kind": "variable", "name": "refreshAccountProfile" }, { "file": "services/api.ts", - "line": 283, + "line": 288, "kind": "variable", "name": "updateAccountLoginInfo" }, { "file": "services/api.ts", - "line": 284, + "line": 289, "kind": "member", "name": "username" }, - { - "file": "services/api.ts", - "line": 285, - "kind": "member", - "name": "login_password" - }, - { - "file": "services/api.ts", - "line": 286, - "kind": "member", - "name": "clear_password" - }, - { - "file": "services/api.ts", - "line": 287, - "kind": "member", - "name": "show_browser" - }, { "file": "services/api.ts", "line": 29, @@ -10187,495 +10103,513 @@ "kind": "variable", "name": "verifySession" }, + { + "file": "services/api.ts", + "line": 290, + "kind": "member", + "name": "login_password" + }, + { + "file": "services/api.ts", + "line": 291, + "kind": "member", + "name": "clear_password" + }, { "file": "services/api.ts", "line": 292, - "kind": "variable", - "name": "getAllAISettings" + "kind": "member", + "name": "show_browser" }, { "file": "services/api.ts", "line": 297, "kind": "variable", + "name": "getAllAISettings" + }, + { + "file": "services/api.ts", + "line": 302, + "kind": "variable", "name": "normalizeOrderStatus" }, { "file": "services/api.ts", - "line": 298, + "line": 303, "kind": "variable", "name": "status" }, { "file": "services/api.ts", - "line": 305, + "line": 310, "kind": "variable", "name": "getOrders" }, { "file": "services/api.ts", - "line": 313, + "line": 318, "kind": "variable", "name": "params" }, { "file": "services/api.ts", - "line": 318, + "line": 323, "kind": "variable", "name": "res" }, { "file": "services/api.ts", - "line": 321, + "line": 326, "kind": "variable", "name": "rawOrders" }, { "file": "services/api.ts", - "line": 322, + "line": 327, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 322, + "line": 327, "kind": "variable", "name": "orders" }, { "file": "services/api.ts", - "line": 33, - "kind": "variable", - "name": "logout" + "line": 34, + "kind": "member", + "name": "commit" }, { "file": "services/api.ts", - "line": 338, + "line": 34, + "kind": "member", + "name": "version" + }, + { + "file": "services/api.ts", + "line": 343, "kind": "member", "name": "data" }, { "file": "services/api.ts", - "line": 338, + "line": 343, "kind": "member", "name": "success" }, { "file": "services/api.ts", - "line": 338, + "line": 343, "kind": "variable", "name": "getOrderDetail" }, { "file": "services/api.ts", - "line": 339, + "line": 344, "kind": "variable", "name": "result" }, { "file": "services/api.ts", - "line": 346, + "line": 351, "kind": "variable", "name": "updateOrder" }, { "file": "services/api.ts", - "line": 350, + "line": 355, "kind": "variable", "name": "deleteOrder" }, { "file": "services/api.ts", - "line": 354, + "line": 359, "kind": "variable", "name": "syncOrders" }, { "file": "services/api.ts", - "line": 355, + "line": 360, "kind": "variable", "name": "formData" }, { "file": "services/api.ts", - "line": 362, + "line": 367, "kind": "variable", "name": "syncSingleOrder" }, { "file": "services/api.ts", - "line": 366, + "line": 371, "kind": "variable", "name": "manualShipOrder" }, { "file": "services/api.ts", - "line": 37, - "kind": "variable", - "name": "changePassword" - }, - { - "file": "services/api.ts", - "line": 373, + "line": 378, "kind": "variable", "name": "importOrders" }, { "file": "services/api.ts", - "line": 374, + "line": 379, "kind": "variable", "name": "isFormData" }, { "file": "services/api.ts", - "line": 379, + "line": 38, + "kind": "variable", + "name": "logout" + }, + { + "file": "services/api.ts", + "line": 384, "kind": "variable", "name": "getAdminStats" }, { "file": "services/api.ts", - "line": 383, + "line": 388, "kind": "variable", "name": "getDashboardStats" }, { "file": "services/api.ts", - "line": 387, + "line": 392, "kind": "member", "name": "end_date" }, { "file": "services/api.ts", - "line": 387, + "line": 392, "kind": "member", "name": "start_date" }, - { - "file": "services/api.ts", - "line": 387, - "kind": "variable", - "name": "getOrderAnalytics" - }, - { - "file": "services/api.ts", - "line": 388, - "kind": "member", - "name": "end_date" - }, - { - "file": "services/api.ts", - "line": 388, - "kind": "member", - "name": "start_date" - }, - { - "file": "services/api.ts", - "line": 388, - "kind": "variable", - "name": "params" - }, - { - "file": "services/api.ts", - "line": 391, - "kind": "variable", - "name": "endDate" - }, { "file": "services/api.ts", "line": 392, "kind": "variable", - "name": "startDate" + "name": "getOrderAnalytics" }, { "file": "services/api.ts", - "line": 409, - "kind": "member", - "name": "orders" - }, - { - "file": "services/api.ts", - "line": 41, - "kind": "variable", - "name": "updateLoginCredentials" - }, - { - "file": "services/api.ts", - "line": 410, - "kind": "member", - "name": "total" - }, - { - "file": "services/api.ts", - "line": 411, - "kind": "member", - "name": "truncated" - }, - { - "file": "services/api.ts", - "line": 414, + "line": 393, "kind": "member", "name": "end_date" }, { "file": "services/api.ts", - "line": 414, + "line": 393, "kind": "member", "name": "start_date" }, + { + "file": "services/api.ts", + "line": 393, + "kind": "variable", + "name": "params" + }, + { + "file": "services/api.ts", + "line": 396, + "kind": "variable", + "name": "endDate" + }, + { + "file": "services/api.ts", + "line": 397, + "kind": "variable", + "name": "startDate" + }, { "file": "services/api.ts", "line": 414, + "kind": "member", + "name": "orders" + }, + { + "file": "services/api.ts", + "line": 415, + "kind": "member", + "name": "total" + }, + { + "file": "services/api.ts", + "line": 416, + "kind": "member", + "name": "truncated" + }, + { + "file": "services/api.ts", + "line": 419, + "kind": "member", + "name": "end_date" + }, + { + "file": "services/api.ts", + "line": 419, + "kind": "member", + "name": "start_date" + }, + { + "file": "services/api.ts", + "line": 419, "kind": "variable", "name": "getValidOrders" }, - { - "file": "services/api.ts", - "line": 415, - "kind": "variable", - "name": "res" - }, { "file": "services/api.ts", "line": 42, - "kind": "member", - "name": "current_password" + "kind": "variable", + "name": "changePassword" }, { "file": "services/api.ts", "line": 420, "kind": "variable", + "name": "res" + }, + { + "file": "services/api.ts", + "line": 425, + "kind": "variable", "name": "orders" }, { "file": "services/api.ts", - "line": 421, + "line": 426, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 421, + "line": 426, "kind": "variable", "name": "normalized" }, { "file": "services/api.ts", - "line": 43, - "kind": "member", - "name": "new_username" - }, - { - "file": "services/api.ts", - "line": 435, + "line": 440, "kind": "variable", "name": "normalizeCard" }, { "file": "services/api.ts", - "line": 436, + "line": 441, "kind": "variable", "name": "apiConfig" }, { "file": "services/api.ts", - "line": 44, - "kind": "member", - "name": "new_password" - }, - { - "file": "services/api.ts", - "line": 447, + "line": 452, "kind": "variable", "name": "cardPayload" }, { "file": "services/api.ts", - "line": 45, - "kind": "member", - "name": "requires_relogin" - }, - { - "file": "services/api.ts", - "line": 452, + "line": 457, "kind": "variable", "name": "getCards" }, { "file": "services/api.ts", - "line": 453, + "line": 458, "kind": "variable", "name": "res" }, { "file": "services/api.ts", - "line": 454, + "line": 459, "kind": "variable", "name": "cards" }, { "file": "services/api.ts", - "line": 458, + "line": 46, + "kind": "variable", + "name": "updateLoginCredentials" + }, + { + "file": "services/api.ts", + "line": 463, "kind": "variable", "name": "createCard" }, { "file": "services/api.ts", - "line": 462, + "line": 467, "kind": "variable", "name": "updateCard" }, { "file": "services/api.ts", - "line": 466, - "kind": "variable", - "name": "deleteCard" - }, - { - "file": "services/api.ts", - "line": 470, - "kind": "variable", - "name": "getCardDetails" + "line": 47, + "kind": "member", + "name": "current_password" }, { "file": "services/api.ts", "line": 471, "kind": "variable", + "name": "deleteCard" + }, + { + "file": "services/api.ts", + "line": 475, + "kind": "variable", + "name": "getCardDetails" + }, + { + "file": "services/api.ts", + "line": 476, + "kind": "variable", "name": "card" }, { "file": "services/api.ts", - "line": 494, - "kind": "variable", - "name": "normalizeBooleanFlag" + "line": 48, + "kind": "member", + "name": "new_username" }, { "file": "services/api.ts", - "line": 497, - "kind": "variable", - "name": "getItems" - }, - { - "file": "services/api.ts", - "line": 498, - "kind": "variable", - "name": "res" + "line": 49, + "kind": "member", + "name": "new_password" }, { "file": "services/api.ts", "line": 499, "kind": "variable", - "name": "items" + "name": "normalizeBooleanFlag" }, { "file": "services/api.ts", "line": 50, - "kind": "variable", - "name": "addAccount" + "kind": "member", + "name": "requires_relogin" }, { "file": "services/api.ts", - "line": 500, + "line": 502, + "kind": "variable", + "name": "getItems" + }, + { + "file": "services/api.ts", + "line": 503, + "kind": "variable", + "name": "res" + }, + { + "file": "services/api.ts", + "line": 504, + "kind": "variable", + "name": "items" + }, + { + "file": "services/api.ts", + "line": 505, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 509, + "line": 514, "kind": "variable", "name": "syncItemsFromAccount" }, { "file": "services/api.ts", - "line": 513, + "line": 518, "kind": "variable", "name": "deleteItem" }, { "file": "services/api.ts", - "line": 517, + "line": 522, "kind": "variable", "name": "createItem" }, { "file": "services/api.ts", - "line": 521, + "line": 526, "kind": "variable", "name": "publishItem" }, { "file": "services/api.ts", - "line": 522, + "line": 527, "kind": "member", "name": "cookie_id" }, { "file": "services/api.ts", - "line": 523, + "line": 528, "kind": "member", "name": "title" }, { "file": "services/api.ts", - "line": 524, + "line": 529, "kind": "member", "name": "description" }, { "file": "services/api.ts", - "line": 525, + "line": 530, "kind": "member", "name": "price" }, { "file": "services/api.ts", - "line": 526, + "line": 531, "kind": "member", "name": "original_price" }, { "file": "services/api.ts", - "line": 527, + "line": 532, "kind": "member", "name": "quantity" }, { "file": "services/api.ts", - "line": 528, + "line": 533, "kind": "member", "name": "postage_mode" }, { "file": "services/api.ts", - "line": 529, + "line": 534, "kind": "member", "name": "postage" }, { "file": "services/api.ts", - "line": 530, + "line": 535, "kind": "member", "name": "images" }, { "file": "services/api.ts", - "line": 531, + "line": 536, "kind": "member", "name": "location" }, { "file": "services/api.ts", - "line": 533, + "line": 538, "kind": "variable", "name": "body" }, { "file": "services/api.ts", - "line": 54, - "kind": "variable", - "name": "accountAvatarURL" - }, - { - "file": "services/api.ts", - "line": 543, + "line": 548, "kind": "variable", "name": "file" }, @@ -10683,125 +10617,125 @@ "file": "services/api.ts", "line": 55, "kind": "variable", - "name": "raw" - }, - { - "file": "services/api.ts", - "line": 550, - "kind": "member", - "name": "area" - }, - { - "file": "services/api.ts", - "line": 551, - "kind": "member", - "name": "city" - }, - { - "file": "services/api.ts", - "line": 552, - "kind": "member", - "name": "division_id" - }, - { - "file": "services/api.ts", - "line": 553, - "kind": "member", - "name": "longitude" - }, - { - "file": "services/api.ts", - "line": 554, - "kind": "member", - "name": "latitude" + "name": "addAccount" }, { "file": "services/api.ts", "line": 555, "kind": "member", - "name": "poi_id" + "name": "area" }, { "file": "services/api.ts", "line": 556, "kind": "member", - "name": "poi_name" + "name": "city" }, { "file": "services/api.ts", "line": 557, "kind": "member", - "name": "province" + "name": "division_id" + }, + { + "file": "services/api.ts", + "line": 558, + "kind": "member", + "name": "longitude" + }, + { + "file": "services/api.ts", + "line": 559, + "kind": "member", + "name": "latitude" }, { "file": "services/api.ts", "line": 560, + "kind": "member", + "name": "poi_id" + }, + { + "file": "services/api.ts", + "line": 561, + "kind": "member", + "name": "poi_name" + }, + { + "file": "services/api.ts", + "line": 562, + "kind": "member", + "name": "province" + }, + { + "file": "services/api.ts", + "line": 565, "kind": "variable", "name": "recommendPublishCategory" }, { "file": "services/api.ts", - "line": 572, + "line": 577, "kind": "variable", "name": "previewItemPublishBatch" }, { "file": "services/api.ts", - "line": 573, + "line": 578, "kind": "member", "name": "file" }, { "file": "services/api.ts", - "line": 574, + "line": 579, "kind": "member", "name": "imagesZip" }, { "file": "services/api.ts", - "line": 575, + "line": 580, "kind": "member", "name": "defaultCookieId" }, { "file": "services/api.ts", - "line": 576, + "line": 581, "kind": "member", "name": "fallbackCategory" }, { "file": "services/api.ts", - "line": 577, + "line": 582, "kind": "member", "name": "catId" }, { "file": "services/api.ts", - "line": 578, + "line": 583, "kind": "member", "name": "catName" }, { "file": "services/api.ts", - "line": 579, + "line": 584, "kind": "member", "name": "channelCatId" }, { "file": "services/api.ts", - "line": 580, + "line": 585, "kind": "member", "name": "tbCatId" }, { "file": "services/api.ts", - "line": 582, + "line": 587, "kind": "member", "name": "location" }, { "file": "services/api.ts", - "line": 584, + "line": 589, "kind": "variable", "name": "body" }, @@ -10809,71 +10743,65 @@ "file": "services/api.ts", "line": 59, "kind": "variable", - "name": "url" + "name": "accountAvatarURL" }, { "file": "services/api.ts", - "line": 596, + "line": 60, + "kind": "variable", + "name": "raw" + }, + { + "file": "services/api.ts", + "line": 601, "kind": "variable", "name": "startItemPublishBatch" }, { "file": "services/api.ts", - "line": 600, + "line": 605, "kind": "variable", "name": "getItemPublishBatch" }, { "file": "services/api.ts", - "line": 604, + "line": 609, "kind": "variable", "name": "getItemPublishBatches" }, { "file": "services/api.ts", - "line": 605, + "line": 610, "kind": "variable", "name": "res" }, { "file": "services/api.ts", - "line": 609, + "line": 614, "kind": "variable", "name": "deleteItemPublishBatch" }, { "file": "services/api.ts", - "line": 613, + "line": 618, "kind": "variable", "name": "cancelItemPublishBatch" }, { "file": "services/api.ts", - "line": 617, + "line": 622, "kind": "variable", "name": "retryFailedItemPublishBatch" }, { "file": "services/api.ts", - "line": 621, + "line": 626, "kind": "variable", "name": "updateItem" }, { "file": "services/api.ts", - "line": 626, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 634, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 635, + "line": 631, "kind": "function-expression", "name": "anonymous" }, @@ -10885,733 +10813,751 @@ }, { "file": "services/api.ts", - "line": 652, + "line": 64, + "kind": "variable", + "name": "url" + }, + { + "file": "services/api.ts", + "line": 640, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 653, + "line": 644, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 654, + "line": 657, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.ts", + "line": 658, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.ts", + "line": 659, "kind": "variable", "name": "cfg" }, { "file": "services/api.ts", - "line": 671, + "line": 676, "kind": "variable", "name": "getShippingRules" }, { "file": "services/api.ts", - "line": 672, + "line": 677, "kind": "variable", "name": "res" }, { "file": "services/api.ts", - "line": 673, + "line": 678, "kind": "variable", "name": "rules" }, - { - "file": "services/api.ts", - "line": 678, - "kind": "member", - "name": "cookieId" - }, - { - "file": "services/api.ts", - "line": 679, - "kind": "member", - "name": "triggerType" - }, - { - "file": "services/api.ts", - "line": 680, - "kind": "member", - "name": "enabled" - }, - { - "file": "services/api.ts", - "line": 681, - "kind": "member", - "name": "search" - }, - { - "file": "services/api.ts", - "line": 682, - "kind": "member", - "name": "page" - }, { "file": "services/api.ts", "line": 683, "kind": "member", - "name": "pageSize" + "name": "cookieId" + }, + { + "file": "services/api.ts", + "line": 684, + "kind": "member", + "name": "triggerType" + }, + { + "file": "services/api.ts", + "line": 685, + "kind": "member", + "name": "enabled" }, { "file": "services/api.ts", "line": 686, + "kind": "member", + "name": "search" + }, + { + "file": "services/api.ts", + "line": 687, + "kind": "member", + "name": "page" + }, + { + "file": "services/api.ts", + "line": 688, + "kind": "member", + "name": "pageSize" + }, + { + "file": "services/api.ts", + "line": 691, "kind": "variable", "name": "getShippingRulesPage" }, { "file": "services/api.ts", - "line": 69, - "kind": "variable", - "name": "getAccountDetails" - }, - { - "file": "services/api.ts", - "line": 694, + "line": 699, "kind": "variable", "name": "res" }, { "file": "services/api.ts", - "line": 70, - "kind": "variable", - "name": "data" - }, - { - "file": "services/api.ts", - "line": 702, + "line": 707, "kind": "variable", "name": "rules" }, { "file": "services/api.ts", - "line": 71, - "kind": "variable", - "name": "avatarVersion" - }, - { - "file": "services/api.ts", - "line": 711, + "line": 716, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 716, + "line": 721, "kind": "variable", "name": "orderAutomationActions" }, { "file": "services/api.ts", - "line": 718, + "line": 723, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 72, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 720, + "line": 725, "kind": "variable", "name": "sendCards" }, - { - "file": "services/api.ts", - "line": 721, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 722, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 723, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 723, - "kind": "variable", - "name": "others" - }, { "file": "services/api.ts", "line": 726, "kind": "function-expression", "name": "anonymous" }, + { + "file": "services/api.ts", + "line": 727, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.ts", + "line": 728, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.ts", + "line": 728, + "kind": "variable", + "name": "others" + }, { "file": "services/api.ts", "line": 731, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.ts", + "line": 736, "kind": "variable", "name": "updateShippingRule" }, { "file": "services/api.ts", - "line": 732, + "line": 737, "kind": "variable", "name": "triggerType" }, { "file": "services/api.ts", - "line": 733, + "line": 738, "kind": "variable", "name": "triggerName" }, { "file": "services/api.ts", - "line": 738, + "line": 74, "kind": "variable", - "name": "generatedName" - }, - { - "file": "services/api.ts", - "line": 742, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 742, - "kind": "variable", - "name": "preservedNonCardActions" + "name": "getAccountDetails" }, { "file": "services/api.ts", "line": 743, "kind": "variable", - "name": "baseActions" + "name": "generatedName" }, { "file": "services/api.ts", - "line": 744, + "line": 747, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 764, + "line": 747, + "kind": "variable", + "name": "preservedNonCardActions" + }, + { + "file": "services/api.ts", + "line": 748, + "kind": "variable", + "name": "baseActions" + }, + { + "file": "services/api.ts", + "line": 749, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.ts", + "line": 75, + "kind": "variable", + "name": "data" + }, + { + "file": "services/api.ts", + "line": 76, + "kind": "variable", + "name": "avatarVersion" + }, + { + "file": "services/api.ts", + "line": 769, "kind": "variable", "name": "actions" }, { "file": "services/api.ts", - "line": 765, - "kind": "variable", - "name": "payload" - }, - { - "file": "services/api.ts", - "line": 773, + "line": 77, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 787, + "line": 770, + "kind": "variable", + "name": "payload" + }, + { + "file": "services/api.ts", + "line": 778, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.ts", + "line": 792, "kind": "variable", "name": "deleteShippingRule" }, - { - "file": "services/api.ts", - "line": 790, - "kind": "member", - "name": "id" - }, - { - "file": "services/api.ts", - "line": 791, - "kind": "member", - "name": "cookie_id" - }, - { - "file": "services/api.ts", - "line": 792, - "kind": "member", - "name": "order_id" - }, - { - "file": "services/api.ts", - "line": 793, - "kind": "member", - "name": "trigger_type" - }, - { - "file": "services/api.ts", - "line": 794, - "kind": "member", - "name": "error_message" - }, { "file": "services/api.ts", "line": 795, "kind": "member", - "name": "issue_kind" + "name": "id" }, { "file": "services/api.ts", "line": 796, "kind": "member", - "name": "allowed_resolutions" + "name": "cookie_id" }, { "file": "services/api.ts", "line": 797, "kind": "member", - "name": "action_cursor" + "name": "order_id" }, { "file": "services/api.ts", "line": 798, "kind": "member", - "name": "sent_count" + "name": "trigger_type" }, { "file": "services/api.ts", "line": 799, "kind": "member", - "name": "updated_at" + "name": "error_message" + }, + { + "file": "services/api.ts", + "line": 800, + "kind": "member", + "name": "issue_kind" + }, + { + "file": "services/api.ts", + "line": 801, + "kind": "member", + "name": "allowed_resolutions" + }, + { + "file": "services/api.ts", + "line": 802, + "kind": "member", + "name": "action_cursor" }, { "file": "services/api.ts", "line": 803, "kind": "member", - "name": "id" + "name": "sent_count" }, { "file": "services/api.ts", "line": 804, "kind": "member", - "name": "cookie_id" - }, - { - "file": "services/api.ts", - "line": 805, - "kind": "member", - "name": "trigger_type" - }, - { - "file": "services/api.ts", - "line": 806, - "kind": "member", - "name": "error_message" - }, - { - "file": "services/api.ts", - "line": 807, - "kind": "member", - "name": "attempt_count" + "name": "updated_at" }, { "file": "services/api.ts", "line": 808, "kind": "member", - "name": "updated_at" + "name": "id" + }, + { + "file": "services/api.ts", + "line": 809, + "kind": "member", + "name": "cookie_id" + }, + { + "file": "services/api.ts", + "line": 810, + "kind": "member", + "name": "trigger_type" }, { "file": "services/api.ts", "line": 811, "kind": "member", + "name": "error_message" + }, + { + "file": "services/api.ts", + "line": 812, + "kind": "member", + "name": "attempt_count" + }, + { + "file": "services/api.ts", + "line": 813, + "kind": "member", + "name": "updated_at" + }, + { + "file": "services/api.ts", + "line": 816, + "kind": "member", "name": "pending_tasks" }, { "file": "services/api.ts", - "line": 811, + "line": 816, "kind": "member", "name": "runs" }, { "file": "services/api.ts", - "line": 811, + "line": 816, "kind": "variable", "name": "getAutomationIssues" }, { "file": "services/api.ts", - "line": 812, + "line": 817, "kind": "variable", "name": "result" }, { "file": "services/api.ts", - "line": 819, + "line": 824, "kind": "variable", "name": "resolveAutomationRun" }, { "file": "services/api.ts", - "line": 822, + "line": 827, "kind": "variable", "name": "resolveDeferredAutomationTask" }, { "file": "services/api.ts", - "line": 827, + "line": 832, "kind": "member", "name": "id" }, { "file": "services/api.ts", - "line": 828, + "line": 833, "kind": "member", "name": "keyword" }, { "file": "services/api.ts", - "line": 829, + "line": 834, "kind": "member", "name": "reply" }, { "file": "services/api.ts", - "line": 830, + "line": 835, "kind": "member", "name": "item_id" }, { "file": "services/api.ts", - "line": 831, + "line": 836, "kind": "member", "name": "type" }, { "file": "services/api.ts", - "line": 832, + "line": 837, "kind": "member", "name": "image_url" }, { "file": "services/api.ts", - "line": 835, + "line": 840, "kind": "variable", "name": "normalizeKeywordRow" }, { "file": "services/api.ts", - "line": 844, + "line": 849, "kind": "variable", "name": "getKeywordRowsWithType" }, { "file": "services/api.ts", - "line": 845, + "line": 850, "kind": "variable", "name": "existing" }, { "file": "services/api.ts", - "line": 849, + "line": 854, "kind": "variable", "name": "getReplyRules" }, { "file": "services/api.ts", - "line": 851, + "line": 856, "kind": "variable", "name": "keywords" }, { "file": "services/api.ts", - "line": 852, + "line": 857, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 864, + "line": 869, "kind": "variable", "name": "updateReplyRule" }, { "file": "services/api.ts", - "line": 865, + "line": 870, "kind": "variable", "name": "type" }, { "file": "services/api.ts", - "line": 866, + "line": 871, "kind": "variable", "name": "payload" }, - { - "file": "services/api.ts", - "line": 878, - "kind": "variable", - "name": "deleteReplyRule" - }, { "file": "services/api.ts", "line": 883, "kind": "variable", - "name": "getSystemSettings" - }, - { - "file": "services/api.ts", - "line": 884, - "kind": "member", - "name": "data" - }, - { - "file": "services/api.ts", - "line": 884, - "kind": "variable", - "name": "res" + "name": "deleteReplyRule" }, { "file": "services/api.ts", "line": 888, "kind": "variable", - "name": "updateSystemSettings" + "name": "getSystemSettings" + }, + { + "file": "services/api.ts", + "line": 889, + "kind": "member", + "name": "data" }, { "file": "services/api.ts", "line": 889, "kind": "variable", + "name": "res" + }, + { + "file": "services/api.ts", + "line": 893, + "kind": "variable", + "name": "updateSystemSettings" + }, + { + "file": "services/api.ts", + "line": 894, + "kind": "variable", "name": "payload" }, { "file": "services/api.ts", - "line": 890, + "line": 895, "kind": "function-expression", "name": "anonymous" }, - { - "file": "services/api.ts", - "line": 895, - "kind": "variable", - "name": "getAccountAISettings" - }, - { - "file": "services/api.ts", - "line": 899, - "kind": "variable", - "name": "updateAccountAISettings" - }, { "file": "services/api.ts", "line": 900, "kind": "variable", + "name": "getAccountAISettings" + }, + { + "file": "services/api.ts", + "line": 904, + "kind": "variable", + "name": "updateAccountAISettings" + }, + { + "file": "services/api.ts", + "line": 905, + "kind": "variable", "name": "payload" }, { "file": "services/api.ts", - "line": 910, + "line": 915, "kind": "variable", "name": "fetchAIModels" }, { "file": "services/api.ts", - "line": 911, + "line": 916, "kind": "variable", "name": "result" }, { "file": "services/api.ts", - "line": 919, + "line": 924, "kind": "variable", "name": "parseNotificationEventTypes" }, { "file": "services/api.ts", - "line": 923, + "line": 928, "kind": "variable", "name": "parsed" }, { "file": "services/api.ts", - "line": 928, + "line": 933, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 931, + "line": 936, "kind": "variable", "name": "stringifyNotificationEventTypes" }, { "file": "services/api.ts", - "line": 932, + "line": 937, "kind": "variable", "name": "clean" }, { "file": "services/api.ts", - "line": 936, + "line": 941, "kind": "member", "name": "data" }, { "file": "services/api.ts", - "line": 936, + "line": 941, "kind": "member", "name": "success" }, { "file": "services/api.ts", - "line": 936, + "line": 941, "kind": "variable", "name": "getNotificationChannels" }, { "file": "services/api.ts", - "line": 937, + "line": 942, "kind": "variable", "name": "result" }, { "file": "services/api.ts", - "line": 938, + "line": 943, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 938, + "line": 943, "kind": "variable", "name": "channels" }, { "file": "services/api.ts", - "line": 939, + "line": 944, "kind": "variable", "name": "parsedConfig" }, { "file": "services/api.ts", - "line": 959, + "line": 964, "kind": "member", "name": "config" }, { "file": "services/api.ts", - "line": 959, + "line": 964, "kind": "member", "name": "enabled" }, { "file": "services/api.ts", - "line": 959, + "line": 964, "kind": "member", "name": "event_types" }, { "file": "services/api.ts", - "line": 959, + "line": 964, "kind": "member", "name": "name" }, { "file": "services/api.ts", - "line": 959, + "line": 964, "kind": "member", "name": "type" }, { "file": "services/api.ts", - "line": 959, + "line": 964, "kind": "variable", "name": "createNotificationChannel" }, { "file": "services/api.ts", - "line": 967, + "line": 972, "kind": "member", "name": "config" }, { "file": "services/api.ts", - "line": 967, + "line": 972, "kind": "member", "name": "enabled" }, { "file": "services/api.ts", - "line": 967, + "line": 972, "kind": "member", "name": "event_types" }, { "file": "services/api.ts", - "line": 967, + "line": 972, "kind": "member", "name": "name" }, { "file": "services/api.ts", - "line": 967, + "line": 972, "kind": "member", "name": "type" }, { "file": "services/api.ts", - "line": 967, + "line": 972, "kind": "variable", "name": "updateNotificationChannel" }, { "file": "services/api.ts", - "line": 968, + "line": 973, "kind": "variable", "name": "payload" }, { "file": "services/api.ts", - "line": 978, + "line": 983, "kind": "variable", "name": "deleteNotificationChannel" }, { "file": "services/api.ts", - "line": 983, + "line": 988, "kind": "member", "name": "data" }, { "file": "services/api.ts", - "line": 983, + "line": 988, "kind": "member", "name": "success" }, { "file": "services/api.ts", - "line": 983, + "line": 988, "kind": "variable", "name": "getMessageNotifications" }, { "file": "services/api.ts", - "line": 984, + "line": 989, "kind": "variable", "name": "result" }, { "file": "services/api.ts", - "line": 985, + "line": 990, "kind": "variable", "name": "notifications" }, { "file": "services/api.ts", - "line": 986, + "line": 991, "kind": "variable", "name": "[cookieId, channelList]" }, { "file": "services/api.ts", - "line": 988, + "line": 993, "kind": "variable", "name": "item" }, diff --git a/docs/architecture/refactoring-master-plan.md b/docs/architecture/refactoring-master-plan.md index 7087ec3..2be053a 100644 --- a/docs/architecture/refactoring-master-plan.md +++ b/docs/architecture/refactoring-master-plan.md @@ -609,3 +609,4 @@ npm --prefix frontend run build | 2026-08-15 | 完成阶段 7 第九个 PR 切片“React Chat feature 化与会话消息行为边界” | 按 `app/features/chat` 提取聊天 API、会话筛选/消息合并状态、账号/会话/消息分页 Hook;会话切换、联系人分页和消息加载支持取消与请求代次保护,文本/图片发送支持失败重试,WebSocket 和滚动语义保持不变;新增会话筛选、消息去重、分页过期响应、发送取消与 API 取消信号测试,保留旧页面入口和 API 路径 | 阶段 7:React AccountAutomation feature 化与任务设置行为边界 | | 2026-08-15 | 完成阶段 7 第十个 PR 切片“React AccountAutomation feature 化与任务设置行为边界” | 按 `app/features/accountAutomation` 提取账号任务 API、默认设置与重复执行状态模型、任务设置 Hook;账号切换支持取消和请求代次保护,保存/立即执行支持重复提交阻断、失败重试和结果刷新;新增默认值、动作门禁、API 取消信号测试,保留旧弹窗入口和 API 路径 | 阶段 7:React AccountList 子模块收口与页面组合边界 | | 2026-08-15 | 完成阶段 7 第十一个 PR 切片“React AccountList 子模块收口与页面组合边界” | 新增 `useAccountSubmodules`,集中管理账号编辑、长登录、通知绑定、AI 设置和密码登录状态;编辑弹窗仅保留页面组合与二维码/删除职责,子模块请求支持并行加载、取消和账号/代次隔离;新增跨子模块过期响应、密码登录取消信号和路由边界测试;前端类型检查、全量测试和构建门禁通过并合并为一个可回滚提交 | 阶段 7:React feature 依赖门禁与旧页面入口瘦身 | +| 2026-08-15 | 完成阶段 7 第十二个 PR 切片“React feature 依赖门禁与旧页面入口瘦身” | 新增 feature 依赖架构测试,禁止生产页面绕过 API 适配层直接使用共享网络客户端或 `fetch`;会话与健康检查纳入 `session/system` feature API,Sidebar 和 App 不再直接访问共享网络层;账号、卡密、订单和规则的旧 `components/*State` 转发入口及其测试迁移/删除,状态测试归属各自 feature;前端类型检查、184 个测试、注释门禁和构建门禁通过 | 阶段 8:DB 与事务治理第一批窄 repository 边界 | diff --git a/frontend/App.tsx b/frontend/App.tsx index ace8469..520e462 100644 --- a/frontend/App.tsx +++ b/frontend/App.tsx @@ -11,7 +11,7 @@ import Notifications from './components/Notifications'; import Chat from './components/Chat'; import { readSidebarCollapsed, writeSidebarCollapsed } from './components/sidebarState'; import { YdisksBrandIcon } from './components/YdisksLogo'; -import { initializeAdmin, login, logout, verifySession } from './services/api'; +import { initializeAdmin, login, logout, verifySession } from './app/features/session/api'; import { ShieldCheck, ArrowRight, Loader2, User, Lock } from 'lucide-react'; interface DeliveryRuleTarget { diff --git a/frontend/components/accountRuntimeState.test.ts b/frontend/app/features/accounts/runtime.test.ts similarity index 51% rename from frontend/components/accountRuntimeState.test.ts rename to frontend/app/features/accounts/runtime.test.ts index ca1901c..5292f1f 100644 --- a/frontend/components/accountRuntimeState.test.ts +++ b/frontend/app/features/accounts/runtime.test.ts @@ -1,7 +1,8 @@ import { describe, expect, test } from 'vitest'; -import type { AccountDetail } from '../types'; -import { mergeAccountRuntimeStatuses } from './accountRuntimeState'; +import type { AccountDetail } from '../../../types'; +import { mergeAccountRuntimeStatuses } from './runtime'; +// account 创建运行状态测试使用的最小账号对象。 const account = (overrides: Partial = {}): AccountDetail => ({ id: 'account-1', cookie: 'cookie', @@ -10,15 +11,14 @@ const account = (overrides: Partial = {}): AccountDetail => ({ ...overrides, }); -describe('mergeAccountRuntimeStatuses', () => { - test('用最新在线状态替换风控恢复中的旧提示', () => { - const result = mergeAccountRuntimeStatuses([ - account({ - runtime_state: 'connecting', - runtime_message: 'token 风控验证已处理,正在重新获取登录凭证', - runtime_updated_at: '2026-07-13T13:16:00+08:00', - }), - ], { +describe('Accounts runtime state', () => { + test('最新在线状态替换风控恢复中的旧提示', () => { + // result 是合并当前运行状态后的账号列表。 + const result = mergeAccountRuntimeStatuses([account({ + runtime_state: 'connecting', + runtime_message: 'token 风控验证已处理,正在重新获取登录凭证', + runtime_updated_at: '2026-07-13T13:16:00+08:00', + })], { 'account-1': { state: 'online', message: '消息服务连接正常', @@ -28,15 +28,11 @@ describe('mergeAccountRuntimeStatuses', () => { }, }); - expect(result[0]).toMatchObject({ - runtime_state: 'online', - runtime_message: '消息服务连接正常', - runtime_connected: true, - runtime_updated_at: '2026-07-13T13:16:02+08:00', - }); + expect(result[0]).toMatchObject({ runtime_state: 'online', runtime_message: '消息服务连接正常', runtime_connected: true }); }); - test('忽略晚到达的旧状态响应', () => { + test('晚到达的旧状态响应不会覆盖当前账号状态', () => { + // current 是当前页面已经展示的较新账号状态。 const current = account({ runtime_state: 'online', runtime_message: '消息服务连接正常', @@ -55,7 +51,8 @@ describe('mergeAccountRuntimeStatuses', () => { expect(result[0]).toBe(current); }); - test('缺少对应运行时状态时保留账号对象', () => { + test('缺少对应运行状态时保留原账号对象', () => { + // current 是没有新运行状态可合并的账号对象。 const current = account(); expect(mergeAccountRuntimeStatuses([current], {})[0]).toBe(current); }); diff --git a/frontend/app/features/accounts/state.test.ts b/frontend/app/features/accounts/state.test.ts index 88f2f8a..7a15cfa 100644 --- a/frontend/app/features/accounts/state.test.ts +++ b/frontend/app/features/accounts/state.test.ts @@ -80,3 +80,62 @@ test('密码登录风控和失败状态统一转换且不暴露验证链接', qrCodeUrl: '', }); }); + +test('登录字段更新不会用空白密码覆盖已有凭证', + // 账号或浏览器开关变化时只提交真正变化的非敏感字段。 + () => { + expect(buildAccountLoginInfoUpdate(account({ username: 'old-user', show_browser: true }), { + username: 'new-user', + login_password: '', + show_browser: false, + })).toEqual({ username: 'new-user', show_browser: false }); + }); + +test('登录字段更新只在用户输入新密码时提交密码', + // 用户输入新密码后才允许将密码字段写入设置补丁。 + () => { + expect(buildAccountLoginInfoUpdate(account(), { + username: 'old-user', + login_password: 'new-secret', + show_browser: false, + })).toEqual({ username: 'old-user', login_password: 'new-secret', show_browser: false }); + }); + +test('登录字段没有变化时不生成更新补丁', + // 没有任何登录字段变化时避免发起无意义的设置请求。 + () => { + expect(buildAccountLoginInfoUpdate(account(), { + username: 'old-user', + login_password: '', + show_browser: false, + })).toBeNull(); + }); + +test('登录字段支持明确清空密码', + // 清空密码必须由用户显式勾选,不能由空白输入隐式触发。 + () => { + expect(buildAccountLoginInfoUpdate(account(), { + username: 'old-user', + login_password: '', + show_browser: false, + clear_password: true, + })).toEqual({ username: 'old-user', show_browser: false, clear_password: true }); + }); + +test('明确清空密码优先于同时输入的新密码', + // 同时存在清空和输入时遵循显式清空意图,避免写入新密码。 + () => { + expect(buildAccountLoginInfoUpdate(account(), { + username: 'old-user', + login_password: 'new-secret', + show_browser: false, + clear_password: true, + })).toEqual({ username: 'old-user', show_browser: false, clear_password: true }); + }); + +test('暂停时长相同不会重新启动账号暂停', + // 暂停时长没有变化时保持当前状态,避免重复写入暂停记录。 + () => { + expect(shouldUpdateAccountPause(60, { pause_duration: 60, paused: false })).toBe(false); + expect(shouldUpdateAccountPause(60, { pause_duration: 60, paused: true })).toBe(false); + }); diff --git a/frontend/app/features/cards/batchState.test.ts b/frontend/app/features/cards/batchState.test.ts index 75ad906..33172ae 100644 --- a/frontend/app/features/cards/batchState.test.ts +++ b/frontend/app/features/cards/batchState.test.ts @@ -32,3 +32,9 @@ test('追加目标切换后拒绝旧请求响应和旧代次响应', expect(isCurrentCardRequest(2, 3, '2', '2')).toBe(false); expect(isCurrentCardRequest(3, 3, '2', '3')).toBe(false); }); + +test('卡密筛选忽略名称周围空白并支持大小写无关匹配', + // 用户输入的名称关键字会先裁剪空白,再进行不区分大小写的匹配。 + () => { + expect(filterCards(cards, '', ' ppt ')).toEqual([cards[0], cards[2]]); + }); diff --git a/frontend/app/features/rules/issueState.test.ts b/frontend/app/features/rules/issueState.test.ts new file mode 100644 index 0000000..f1c94e7 --- /dev/null +++ b/frontend/app/features/rules/issueState.test.ts @@ -0,0 +1,50 @@ +import { expect, test } from 'vitest'; +import type { AutomationRunIssue } from './api'; +import { canResolveAutomationIssue, filterAutomationIssues, loadAutomationPageData } from './issueState'; + +// issue 创建规则异常测试使用的最小异常对象。 +const issue = (cookieID: string, allowed: AutomationRunIssue['allowed_resolutions']): AutomationRunIssue => ({ + id: cookieID === 'a' ? 1 : 2, + cookie_id: cookieID, + order_id: 'o', + trigger_type: 'buyer_reviewed', + error_message: 'error', + issue_kind: 'invalid_snapshot', + allowed_resolutions: allowed, + action_cursor: 0, + sent_count: 0, + updated_at: '', +}); + +test('规则异常处理动作遵循后端允许列表', + // 只有后端明确允许的人工动作才能被页面提交。 + () => { + const invalid = issue('a', ['cancel']); + expect(canResolveAutomationIssue(invalid, 'cancel')).toBe(true); + expect(canResolveAutomationIssue(invalid, 'continue')).toBe(false); + expect(canResolveAutomationIssue(invalid, 'retry')).toBe(false); + }); + +test('规则异常按账号筛选后再决定是否展示面板', + // 异常面板只展示当前账号的运行异常和延迟任务。 + () => { + const visible = filterAutomationIssues({ runs: [issue('a', ['cancel']), issue('b', ['retry', 'cancel'])], pending_tasks: [] }, 'missing'); + expect(visible.runs).toEqual([]); + expect(visible.pending_tasks).toEqual([]); + }); + +test('规则列表不因异常接口失败而停止加载', async () => { + // receivedRules 保存主规则列表加载器收到的结果。 + const receivedRules: string[][] = []; + // errors 保存异常接口失败后的错误回调。 + const errors: unknown[] = []; + await loadAutomationPageData({ + loadRules: async () => ['rule'], + loadIssues: async () => { throw new Error('issues unavailable'); }, + onRules: rules => receivedRules.push(rules), + onIssues: () => { throw new Error('must not receive issues'); }, + onIssuesError: error => errors.push(error), + }); + expect(receivedRules).toEqual([['rule']]); + expect(errors).toHaveLength(1); +}); diff --git a/frontend/app/features/session/api.ts b/frontend/app/features/session/api.ts new file mode 100644 index 0000000..91b4ec4 --- /dev/null +++ b/frontend/app/features/session/api.ts @@ -0,0 +1,2 @@ +// Session feature 只通过本适配层访问会话相关网络接口。 +export { initializeAdmin, login, logout, verifySession } from '../../../services/api'; diff --git a/frontend/app/features/system/api.ts b/frontend/app/features/system/api.ts new file mode 100644 index 0000000..f18a2b4 --- /dev/null +++ b/frontend/app/features/system/api.ts @@ -0,0 +1,3 @@ +// System feature 只通过本适配层访问服务健康检查接口。 +export { getHealth } from '../../../services/api'; +export type { BuildInfo } from './types'; diff --git a/frontend/app/features/system/types.ts b/frontend/app/features/system/types.ts new file mode 100644 index 0000000..93f8aca --- /dev/null +++ b/frontend/app/features/system/types.ts @@ -0,0 +1,7 @@ +// BuildInfo 描述健康检查接口返回的构建版本信息。 +export interface BuildInfo { + // version 是当前服务构建版本。 + version: string; + // commit 是当前服务对应的提交标识。 + commit: string; +} diff --git a/frontend/components/Sidebar.tsx b/frontend/components/Sidebar.tsx index 1e65f4e..ba4fad4 100644 --- a/frontend/components/Sidebar.tsx +++ b/frontend/components/Sidebar.tsx @@ -4,7 +4,10 @@ import { GitCommitHorizontal, LogOut, MessageCircleMore, Settings, ShoppingBag, Users, Zap, } from 'lucide-react'; import { YdisksBrandIcon } from './YdisksLogo'; +import { getHealth } from '../app/features/system/api'; +import type { BuildInfo } from '../app/features/system/types'; +// SidebarProps 描述侧边栏所需的导航和会话回调。 interface SidebarProps { activeTab: string; isAdmin?: boolean; @@ -14,20 +17,15 @@ interface SidebarProps { onLogout: () => void; } -interface BuildInfo { - version: string; - commit: string; -} - const Sidebar: React.FC = ({ activeTab, isAdmin = false, collapsed, onToggleCollapsed, onNavigate, onLogout, }) => { const [buildInfo, setBuildInfo] = useState({ version: 'dev', commit: 'unknown' }); useEffect(() => { + // controller 控制健康检查请求的取消。 const controller = new AbortController(); - fetch('/health', { signal: controller.signal }) - .then(response => response.ok ? response.json() : Promise.reject(new Error('health request failed'))) + getHealth({ signal: controller.signal }) .then(data => setBuildInfo({ version: String(data.version || 'dev'), commit: String(data.commit || 'unknown'), diff --git a/frontend/components/accountEdit.test.ts b/frontend/components/accountEdit.test.ts deleted file mode 100644 index b491125..0000000 --- a/frontend/components/accountEdit.test.ts +++ /dev/null @@ -1,62 +0,0 @@ -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(); -}); - -test('buildAccountLoginInfoUpdate sends explicit clear password flag', () => { - const payload = buildAccountLoginInfoUpdate( - { id: 'acc1', enabled: true, auto_confirm: true, username: 'old-user', show_browser: false }, - { username: 'old-user', login_password: '', show_browser: false, clear_password: true }, - ); - - expect(payload).toEqual({ - username: 'old-user', - show_browser: false, - clear_password: true, - }); -}); - -test('buildAccountLoginInfoUpdate prefers clear password over typed password', () => { - 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, clear_password: true }, - ); - - expect(payload).toEqual({ - username: 'old-user', - show_browser: false, - clear_password: true, - }); -}); diff --git a/frontend/components/accountEdit.ts b/frontend/components/accountEdit.ts deleted file mode 100644 index 03ad4e8..0000000 --- a/frontend/components/accountEdit.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 旧目录保留兼容入口,实际登录字段构造逻辑已归入 accounts feature。 -export { - buildAccountLoginInfoUpdate, -} from '../app/features/accounts/state'; -export type { - AccountLoginEditFields as AccountLoginEditForm, - AccountLoginInfoPayload, -} from '../app/features/accounts/state'; diff --git a/frontend/components/accountPause.test.ts b/frontend/components/accountPause.test.ts deleted file mode 100644 index 4721145..0000000 --- a/frontend/components/accountPause.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { describe, expect, it } from 'vitest'; -import { shouldUpdateAccountPause } from './accountPause'; - -describe('shouldUpdateAccountPause', () => { - it('does not silently reapply the same duration after a pause has expired', () => { - expect(shouldUpdateAccountPause(60, { pause_duration: 60, paused: false })).toBe(false); - }); - - it('does not restart an active unchanged pause', () => { - expect(shouldUpdateAccountPause(60, { pause_duration: 60, paused: true })).toBe(false); - }); - - it('sends changed values including explicit resume', () => { - expect(shouldUpdateAccountPause(30, { pause_duration: 60, paused: true })).toBe(true); - expect(shouldUpdateAccountPause(0, { pause_duration: 60, paused: true })).toBe(true); - }); -}); diff --git a/frontend/components/accountPause.ts b/frontend/components/accountPause.ts deleted file mode 100644 index 51c1034..0000000 --- a/frontend/components/accountPause.ts +++ /dev/null @@ -1,2 +0,0 @@ -// 旧目录保留兼容入口,实际暂停时长门禁已归入 accounts feature。 -export { shouldUpdateAccountPause } from '../app/features/accounts/state'; diff --git a/frontend/components/accountRuntimeState.ts b/frontend/components/accountRuntimeState.ts deleted file mode 100644 index f3972c6..0000000 --- a/frontend/components/accountRuntimeState.ts +++ /dev/null @@ -1,2 +0,0 @@ -// 旧目录保留兼容入口,实际运行状态合并逻辑已归入 accounts feature。 -export { mergeAccountRuntimeStatuses } from '../app/features/accounts/runtime'; diff --git a/frontend/components/automationIssueState.test.ts b/frontend/components/automationIssueState.test.ts deleted file mode 100644 index 436db39..0000000 --- a/frontend/components/automationIssueState.test.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { expect, test } from 'vitest'; -import type { AutomationRunIssue } from '../services/api'; -import { canResolveAutomationIssue, filterAutomationIssues, loadAutomationPageData } from './automationIssueState'; - -const issue = (cookieID: string, allowed: AutomationRunIssue['allowed_resolutions']): AutomationRunIssue => ({ - id: cookieID === 'a' ? 1 : 2, - cookie_id: cookieID, - order_id: 'o', - trigger_type: 'buyer_reviewed', - error_message: 'error', - issue_kind: 'invalid_snapshot', - allowed_resolutions: allowed, - action_cursor: 0, - sent_count: 0, - updated_at: '', -}); - -test('automation issue actions follow the backend policy', () => { - const invalid = issue('a', ['cancel']); - expect(canResolveAutomationIssue(invalid, 'cancel')).toBe(true); - expect(canResolveAutomationIssue(invalid, 'continue')).toBe(false); - expect(canResolveAutomationIssue(invalid, 'retry')).toBe(false); -}); - -test('automation issues are filtered before deciding whether to show the panel', () => { - const visible = filterAutomationIssues({ runs: [issue('a', ['cancel']), issue('b', ['retry', 'cancel'])], pending_tasks: [] }, 'missing'); - expect(visible.runs).toEqual([]); - expect(visible.pending_tasks).toEqual([]); -}); - -test('automation rules still load when the diagnostic issue request fails', async () => { - const receivedRules: string[][] = []; - const errors: unknown[] = []; - await loadAutomationPageData({ - loadRules: async () => ['rule'], - loadIssues: async () => { throw new Error('issues unavailable'); }, - onRules: rules => receivedRules.push(rules), - onIssues: () => { throw new Error('must not receive issues'); }, - onIssuesError: error => errors.push(error), - }); - expect(receivedRules).toEqual([['rule']]); - expect(errors).toHaveLength(1); -}); diff --git a/frontend/components/automationIssueState.ts b/frontend/components/automationIssueState.ts deleted file mode 100644 index 34eedcd..0000000 --- a/frontend/components/automationIssueState.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 旧目录保留兼容入口,实际实现统一归属 Rules feature。 -export { - automationIssueKindLabel, - canResolveAutomationIssue, - filterAutomationIssues, - loadAutomationPageData, -} from '../app/features/rules/issueState'; -export type { AutomationResolution } from '../app/features/rules/issueState'; diff --git a/frontend/components/cardListState.test.ts b/frontend/components/cardListState.test.ts deleted file mode 100644 index 0ba6a07..0000000 --- a/frontend/components/cardListState.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { describe, expect, test } from 'vitest'; -import type { Card } from '../types'; -import { filterCards } from './cardListState'; - -const cards = [ - { id: 1, name: '年终总结 PPT', type: 'text' }, - { id: 2, name: '年终总结兑换码', type: 'data' }, - { id: 3, name: '产品介绍 PPT', type: 'text' }, -] as Card[]; - -describe('filterCards', () => { - test('combines type and name filters with AND semantics', () => { - expect(filterCards(cards, 'text', '年终')).toEqual([cards[0]]); - }); - - test('matches names case-insensitively and ignores surrounding whitespace', () => { - expect(filterCards(cards, '', ' ppt ')).toEqual([cards[0], cards[2]]); - }); -}); diff --git a/frontend/components/cardListState.ts b/frontend/components/cardListState.ts deleted file mode 100644 index 2857fb0..0000000 --- a/frontend/components/cardListState.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 旧目录保留兼容入口,实际卡密筛选和批量状态逻辑已归入 cards feature。 -export { - canSubmitAppend, - filterCards, - isCurrentCardRequest, - previewAppendContent, -} from '../app/features/cards/batchState'; diff --git a/frontend/components/itemPublishBatchState.test.ts b/frontend/components/itemPublishBatchState.test.ts deleted file mode 100644 index 4edee84..0000000 --- a/frontend/components/itemPublishBatchState.test.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { expect, test } from 'vitest'; -import { selectActivePublishBatch } from './itemPublishBatchState'; - -test('completed history does not replace the new batch upload flow', () => { - expect(selectActivePublishBatch([{ id: 'done', status: 'completed' }])).toBeUndefined(); - expect(selectActivePublishBatch([ - { id: 'done', status: 'completed' }, - { id: 'active', status: 'running' }, - ])?.id).toBe('active'); -}); diff --git a/frontend/components/itemPublishBatchState.ts b/frontend/components/itemPublishBatchState.ts deleted file mode 100644 index 8aed1a0..0000000 --- a/frontend/components/itemPublishBatchState.ts +++ /dev/null @@ -1,3 +0,0 @@ -// 旧目录保留兼容入口,实际批量状态模型统一归属 ItemList feature。 -export { selectActivePublishBatch } from '../app/features/items/batchState'; -export type { PublishBatchSummary } from '../app/features/items/batchState'; diff --git a/frontend/components/orderImportState.ts b/frontend/components/orderImportState.ts deleted file mode 100644 index 83b8cd7..0000000 --- a/frontend/components/orderImportState.ts +++ /dev/null @@ -1,8 +0,0 @@ -export { - failedOrderImportRows, - normalizeOrderImportResult, -} from '../app/features/orders/state'; -export type { - OrderImportResult, - OrderImportRowResult, -} from '../app/features/orders/types'; diff --git a/frontend/featureArchitecture.test.ts b/frontend/featureArchitecture.test.ts new file mode 100644 index 0000000..daffd5e --- /dev/null +++ b/frontend/featureArchitecture.test.ts @@ -0,0 +1,79 @@ +import { readdirSync, readFileSync } from 'node:fs'; +import { resolve, relative } from 'node:path'; +import { describe, expect, test } from 'vitest'; + +// sourceRoot 是前端源码根目录,所有架构规则都基于生产源码扫描。 +const sourceRoot = resolve(__dirname); + +// collectSourceFiles 递归收集指定目录下的 TypeScript/TSX 源文件。 +const collectSourceFiles = (directory: string): string[] => readdirSync(directory, { withFileTypes: true }).flatMap(entry => { + // entry 是当前目录中的文件或子目录条目。 + // filePath 是当前目录项的绝对路径。 + const filePath = resolve(directory, entry.name); + if (entry.isDirectory()) { + if (['node_modules', 'dist', 'coverage'].includes(entry.name)) return []; + return collectSourceFiles(filePath); + } + return /\.(ts|tsx)$/.test(entry.name) ? [filePath] : []; +}); + +// productionSources 返回排除测试文件后的生产源码及其相对路径。 +const productionSources = (): Array<{ relativePath: string; source: string }> => collectSourceFiles(sourceRoot) + .filter(filePath => !filePath.endsWith('.test.ts') && !filePath.endsWith('.test.tsx')) + .map(filePath => ({ + relativePath: relative(sourceRoot, filePath).split('/').join('/'), + source: readFileSync(filePath, 'utf8'), + })); + +describe('React feature dependency boundaries', () => { + test('network clients are only imported by feature API adapters', () => { + // violations 保存页面、组件或非 API feature 文件中的共享网络客户端依赖。 + const violations = productionSources() + .filter(file => file.source.includes("from './services/api'") || file.source.includes("from '../services/api'") || file.source.includes("from '../../../services/api'")) + .filter(file => file.relativePath !== 'services/api.ts' && !file.relativePath.endsWith('/api.ts')) + .map(file => file.relativePath); + + expect(violations).toEqual([]); + }); + + test('production React code does not call fetch or axios outside the request boundary', () => { + // violations 保存页面或组件中直接发起网络请求的源码路径。 + const violations = productionSources() + .filter(file => file.relativePath !== 'request.ts' && /\bfetch\s*\(|\baxios\b/.test(file.source)) + .map(file => file.relativePath); + + expect(violations).toEqual([]); + }); + + test('feature API adapters are the only feature files allowed to depend on shared API', () => { + // violations 保存 feature 内部绕过 API 适配层的共享服务依赖。 + const violations = productionSources() + .filter(file => file.relativePath.startsWith('app/features/') && file.source.includes("from '../../../services/api'")) + .filter(file => !file.relativePath.endsWith('/api.ts')) + .map(file => file.relativePath); + + expect(violations).toEqual([]); + }); + + test('legacy component state compatibility entrypoints have been removed', () => { + // legacyEntrypoints 是不应重新引入页面层状态转发文件的旧路径。 + const legacyEntrypoints = [ + 'components/accountEdit.ts', + 'components/accountPause.ts', + 'components/accountRuntimeState.ts', + 'components/cardListState.ts', + 'components/itemPublishBatchState.ts', + 'components/orderImportState.ts', + 'components/automationIssueState.ts', + ]; + + expect(legacyEntrypoints.filter(entry => { + try { + readFileSync(resolve(sourceRoot, entry)); + return true; + } catch { + return false; + } + })).toEqual([]); + }); +}); diff --git a/frontend/services/api.test.ts b/frontend/services/api.test.ts index 1aeaa0d..cc47a90 100644 --- a/frontend/services/api.test.ts +++ b/frontend/services/api.test.ts @@ -16,7 +16,7 @@ import { getReplyRules, getDefaultReplies, getDefaultReply, updateDefaultReply, deleteDefaultReply, clearDefaultReplyRecords, getShippingRules, getShippingRulesPage, - getSystemSettings, getCards, createCard, updateCard, deleteCard, getCardDetails, batchCreateCards, appendCardData, + getSystemSettings, getHealth, getCards, createCard, updateCard, deleteCard, getCardDetails, batchCreateCards, appendCardData, getValidOrders, publishItem, recommendPublishCategory, previewItemPublishBatch, logout, @@ -56,6 +56,16 @@ test('updateSystemSettings uses one atomic bulk request', async () => { expect(JSON.parse(fetchMock.mock.calls[0][1].body)).toEqual({ theme_color: 'blue', renewal_log_retention_days: 15 }); }); +test('health API exposes build metadata through the request boundary', async () => { + // fetchMock 是健康检查 API 的请求替身。 + const fetchMock = vi.fn().mockResolvedValue(jsonResponse({ version: '1.2.3', commit: 'abc123' })); + vi.stubGlobal('fetch', fetchMock); + const controller = new AbortController(); + + await expect(getHealth({ signal: controller.signal })).resolves.toEqual({ version: '1.2.3', commit: 'abc123' }); + expect(fetchMock).toHaveBeenCalledWith('/health', expect.objectContaining({ method: 'GET', signal: expect.any(AbortSignal) })); +}); + test('chat APIs preserve account and conversation scope', async () => { const fetchMock = vi.fn() .mockResolvedValueOnce(jsonResponse({ sessions: [{ account_id: 'a1', chat_id: 'c1' }] })) diff --git a/frontend/services/api.ts b/frontend/services/api.ts index eb0ee4b..819e43b 100644 --- a/frontend/services/api.ts +++ b/frontend/services/api.ts @@ -30,6 +30,11 @@ export const verifySession = async (options?: RequestControlOptions): Promise<{ return get('/api/v1/session', undefined, options); }; +// getHealth 读取服务健康检查和构建版本信息。 +export const getHealth = async (options?: RequestControlOptions): Promise<{ version?: string; commit?: string }> => { + return get('/health', undefined, options); +}; + export const logout = async (): Promise => { return post('/api/v1/session/logout', {}); }; diff --git a/internal/webui/static/assets/index-jRlHx8b7.js b/internal/webui/static/assets/index-D15oV9g9.js similarity index 70% rename from internal/webui/static/assets/index-jRlHx8b7.js rename to internal/webui/static/assets/index-D15oV9g9.js index 5cbe1d1..e93a8a5 100644 --- a/internal/webui/static/assets/index-jRlHx8b7.js +++ b/internal/webui/static/assets/index-D15oV9g9.js @@ -1,13 +1,13 @@ -import{j as e,r,c as Is,b as Oe,d as ir}from"./react-vendor-C_od1ZSF.js";import{L as or,U as Na,M as ys,C as Os,B as va,S as _a,Z as js,a as Rt,b as Ps,G as Bs,c as Ts,d as Es,e as cr,f as wa,g as ut,A as Fs,D as dr,P as ka,h as Bt,E as Ca,T as xr,i as mr,j as _e,X as ke,k as ur,l as pr,m as Ds,n as Sa,o as lt,p as Ye,q as La,K as hr,r as bt,s as mt,Q as rs,t as yt,u as wt,v as $t,R as We,w as Ra,x as gr,y as Ze,z as St,F as Mt,H as nt,I as zs,J as kt,N as br,O as fr,V as yr,W as Aa,Y as Ia,_ as Oa,$ as jr,a0 as Nr,a1 as ls,a2 as Wt,a3 as Ns,a4 as vr,a5 as _r,a6 as vs,a7 as Us,a8 as wr,a9 as kr,aa as qt,ab as Ws,ac as Zt,ad as Pa,ae as Cr,af as Sr,ag as ss,ah as Ta,ai as Lr,aj as Rr,ak as Ar,al as Ir,am as Or,an as Pr,ao as Js}from"./icons-vendor-i_74xDZy.js";import{R as Yt,B as Tr,X as Gs,Y as Vs,T as Xt,a as Er,C as _s,A as Dr,b as $r,c as Mr,P as Qs,d as Ks,L as qr}from"./charts-vendor-BxxJOyEX.js";import"./vendor-D-Edl3pr.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))l(n);new MutationObserver(n=>{for(const c of n)if(c.type==="childList")for(const u of c.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&l(u)}).observe(document,{childList:!0,subtree:!0});function a(n){const c={};return n.integrity&&(c.integrity=n.integrity),n.referrerPolicy&&(c.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?c.credentials="include":n.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function l(n){if(n.ep)return;n.ep=!0;const c=a(n);fetch(n.href,c)}})();const Br=({className:t="w-full h-full text-white"})=>e.jsx("svg",{className:t,viewBox:"0 0 256 256","aria-hidden":"true",children:e.jsx("g",{stroke:"none",fill:"none",fillRule:"evenodd",children:e.jsx("path",{d:"M121.73,57.0003 C138.901,57.0003 154.897,65.5053 164.52,79.7493 C166.029,81.9823 165.441,85.0143 163.209,86.5233 C160.976,88.0323 157.944,87.4433 156.436,85.2113 C148.629,73.6553 135.655,66.7563 121.73,66.7563 C104.076789,66.7563 88.6201962,77.6596007 82.5581814,93.8184545 C83.9120803,93.7133631 85.2800264,93.66 86.6602,93.66 C111.537727,93.66 132.442611,110.997575 137.926382,134.224255 L162.5425,92.109 L162.615557,91.9879406 L162.756884,91.77367 L162.911804,91.5639102 L162.98657,91.4716759 C163.351845,91.025169 163.786059,90.6571744 164.264191,90.3738733 L164.550153,90.2178351 L164.729252,90.1315693 L164.989203,90.021723 L165.230265,89.9354653 L165.542393,89.8445739 C165.666021,89.8126706 165.790834,89.7857324 165.916565,89.7637431 L166.116517,89.7342499 C166.29505,89.7098142 166.475001,89.6957386 166.655596,89.6918808 L166.7539,89.693 C196.8909,89.693 221.4079,114.21 221.4079,144.347 C221.4079,174.482 196.8909,199 166.7539,199 L125.0869,199 C122.3919,199 120.2079,196.815 120.2079,194.122 C120.2079,191.429 122.3919,189.244 125.0869,189.244 L166.7539,189.244 C191.5109,189.244 211.6519,169.104 211.6519,144.347 C211.6519,120.513406 192.985349,100.957891 169.504046,99.5322548 L112.7745,196.584 C111.8995,198.08 110.2965,199 108.5635,199 L86.6602,199 C57.6182,199 33.9902,175.373 33.9902,146.33 C33.9902,122.475163 49.9316132,102.273061 71.7206298,95.817503 L71.9446339,94.967678 C78.0600632,72.5405324 98.33054,57.0003 121.73,57.0003 Z M86.6602,103.417 C62.9972,103.417 43.7462,122.667 43.7462,146.33 C43.7462,169.992 62.9972,189.244 86.6602,189.244 L105.7645,189.244 L129.869462,148.004782 C129.678439,147.482425 129.5742,146.918336 129.5742,146.33 C129.5742,122.667 110.3232,103.417 86.6602,103.417 Z",fill:"currentColor"})})}),ws=({sizeClass:t="w-12 h-12",logoClassName:s="w-full h-full text-white"})=>e.jsxs("div",{className:"relative z-10 flex items-center justify-center",children:[e.jsx("div",{className:"absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25"}),e.jsxs("div",{className:`relative ${t} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`,children:[e.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 120 120","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"login-squircle-gradient",x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"rgb(var(--color-brand))"}),e.jsx("stop",{offset:"100%",stopColor:"rgb(var(--color-brand-light))"})]})}),e.jsx("path",{d:"M 114.00 60.00 L 113.83 71.48 L 113.31 78.16 L 112.44 83.67 L 111.22 88.46 L 109.66 92.71 L 107.75 96.49 L 105.48 99.87 L 102.86 102.86 L 99.87 105.48 L 96.49 107.75 L 92.71 109.66 L 88.46 111.22 L 83.67 112.44 L 78.16 113.31 L 71.48 113.83 L 60.00 114.00 L 48.52 113.83 L 41.84 113.31 L 36.33 112.44 L 31.54 111.22 L 27.29 109.66 L 23.51 107.75 L 20.13 105.48 L 17.14 102.86 L 14.52 99.87 L 12.25 96.49 L 10.34 92.71 L 8.78 88.46 L 7.56 83.67 L 6.69 78.16 L 6.17 71.48 L 6.00 60.00 L 6.17 48.52 L 6.69 41.84 L 7.56 36.33 L 8.78 31.54 L 10.34 27.29 L 12.25 23.51 L 14.52 20.13 L 17.14 17.14 L 20.13 14.52 L 23.51 12.25 L 27.29 10.34 L 31.54 8.78 L 36.33 7.56 L 41.84 6.69 L 48.52 6.17 L 60.00 6.00 L 71.48 6.17 L 78.16 6.69 L 83.67 7.56 L 88.46 8.78 L 92.71 10.34 L 96.49 12.25 L 99.87 14.52 L 102.86 17.14 L 105.48 20.13 L 107.75 23.51 L 109.66 27.29 L 111.22 31.54 L 112.44 36.33 L 113.31 41.84 L 113.83 48.52 Z",fill:"url(#login-squircle-gradient)"})]}),e.jsx("div",{className:"relative z-10 flex items-center justify-center w-full h-full",children:e.jsx(Br,{className:s})})]})]}),Fr=({activeTab:t,isAdmin:s=!1,collapsed:a,onToggleCollapsed:l,onNavigate:n,onLogout:c})=>{const[u,h]=r.useState({version:"dev",commit:"unknown"});r.useEffect(()=>{const x=new AbortController;return fetch("/health",{signal:x.signal}).then(p=>p.ok?p.json():Promise.reject(new Error("health request failed"))).then(p=>h({version:String(p.version||"dev"),commit:String(p.commit||"unknown")})).catch(p=>{p instanceof DOMException&&p.name}),()=>x.abort()},[]);const m=[{id:"dashboard",icon:or,label:"仪表盘"},{id:"accounts",icon:Na,label:"账号管理"},{id:"chat",icon:ys,label:"在线聊天"},{id:"cards",icon:Os,label:"卡密库存"},{id:"items",icon:va,label:"商品列表"},{id:"orders",icon:_a,label:"订单管理"},{id:"rules",icon:js,label:"自动化规则"},{id:"notifications",icon:Rt,label:"通知设置"},...s?[{id:"settings",icon:Ps,label:"系统与AI"}]:[]],N=/^\d+\.\d+\.\d+$/.test(u.version)?`v${u.version}`:u.version;return e.jsxs("aside",{className:`fixed inset-y-0 left-0 z-20 flex flex-col border-r border-slate-200/80 bg-white/95 shadow-sidebar backdrop-blur-xl transition-[width] duration-300 ${a?"w-16":"w-64"}`,children:[e.jsxs("div",{className:`flex h-20 items-center border-b border-slate-100 ${a?"justify-center px-2":"gap-3 px-5"}`,children:[e.jsx(ws,{sizeClass:"h-10 w-10"}),!a&&e.jsxs("div",{className:"min-w-0 leading-tight",children:[e.jsx("div",{className:"truncate text-base font-black tracking-tight text-slate-950",children:"Ydisks 闲鱼助手"}),e.jsx("div",{className:"mt-1 text-[10px] font-extrabold uppercase tracking-[0.22em] text-sky-600",children:"Operations"})]})]}),e.jsx("nav",{className:`flex-1 space-y-1.5 overflow-y-auto pt-5 ${a?"px-2":"px-3"}`,"aria-label":"主导航",children:m.map(x=>{const p=x.icon,_=t===x.id;return e.jsx(Is.Fragment,{children:e.jsxs("button",{type:"button",title:a?x.label:void 0,"aria-label":x.label,"aria-current":_?"page":void 0,onClick:()=>n(x.id),className:`group relative flex h-11 w-full items-center rounded-xl transition-colors ${a?"justify-center":"gap-3 px-3.5"} ${_?"bg-brand text-white shadow-brand-active":"text-slate-500 hover:bg-slate-100 hover:text-slate-900"}`,children:[e.jsx(p,{className:`h-[19px] w-[19px] shrink-0 ${_?"text-white":"text-slate-400 group-hover:text-slate-700"}`}),!a&&e.jsx("span",{className:"truncate text-sm font-bold",children:x.label}),_&&!a&&e.jsx("span",{className:"ml-auto h-1.5 w-1.5 rounded-full bg-white/90"})]})},x.id)})}),e.jsxs("div",{children:[e.jsx("div",{title:a?`版本 ${u.version} · ${u.commit}`:void 0,className:`border-y border-slate-100 bg-slate-50/70 py-2.5 ${a?"flex justify-center px-1":"px-6"}`,children:a?e.jsx(Bs,{className:"h-[18px] w-[18px] text-slate-400","aria-label":`版本 ${u.version}`}):e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-extrabold uppercase tracking-[0.18em] text-slate-400",children:[e.jsx(Bs,{className:"h-3.5 w-3.5"}),"运行版本"]}),e.jsxs("div",{className:"mt-1 flex items-baseline gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs font-bold text-slate-700",children:N}),e.jsx("span",{className:"truncate font-mono text-[10px] text-slate-400",children:u.commit})]})]})}),e.jsxs("div",{className:`space-y-2 p-2 ${a?"":"p-3"}`,children:[e.jsxs("button",{type:"button",onClick:l,title:a?"展开侧边栏":"收起侧边栏","aria-label":a?"展开侧边栏":"收起侧边栏",className:`flex h-10 w-full items-center rounded-xl text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-900 ${a?"justify-center":"gap-3 px-3"}`,children:[a?e.jsx(Ts,{className:"h-5 w-5"}):e.jsx(Es,{className:"h-5 w-5"}),!a&&e.jsx("span",{className:"text-sm font-bold",children:"收起侧边栏"})]}),e.jsxs("button",{type:"button",onClick:c,title:a?"退出登录":void 0,"aria-label":"退出登录",className:`flex h-10 w-full items-center rounded-xl text-slate-500 transition-colors hover:bg-red-50 hover:text-red-600 ${a?"justify-center":"gap-3 px-3"}`,children:[e.jsx(cr,{className:"h-5 w-5"}),!a&&e.jsx("span",{className:"text-sm font-bold",children:"退出登录"})]})]})]})]})},es=t=>{const s=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0");return`${s}-${a}-${l}`},$s=(t,s)=>{const a=new Date(t);return a.setHours(12,0,0,0),a.setDate(a.getDate()+s),a},ks=(t,s)=>({startDate:es($s(t,-(s-1))),endDate:es(t)}),Ea=(t,s=new Date,a="",l="")=>{if(t==="custom"&&a&&l){if(a>l)throw new Error("开始日期不能晚于结束日期");return{startDate:a,endDate:l}}return t==="yesterday"?ks($s(s,-1),1):ks(s,t==="3days"?3:t==="30days"?30:t==="today"?1:7)},zr=t=>{const s=new Date(`${t.startDate}T12:00:00`),a=new Date(`${t.endDate}T12:00:00`),l=Math.round((a.getTime()-s.getTime())/864e5)+1,n=$s(s,-1);return ks(n,l)},It=t=>String(t).padStart(2,"0"),Cs=t=>{if(t==null||t==="")return"-";const s=t instanceof Date?t:new Date(t);return Number.isNaN(s.getTime())?"-":[s.getFullYear(),It(s.getMonth()+1),It(s.getDate())].join("-")+" "+[It(s.getHours()),It(s.getMinutes()),It(s.getSeconds())].join(":")},Ur=t=>{const s={};return t.forEach(a=>{s[a.item_id]=a.item_title||a.item_id}),s},Wr=t=>{var s;return((s=t.daily_stats)==null?void 0:s.map(a=>({name:a.date.slice(5),amount:a.amount,orders:a.order_count,avgAmount:a.order_count>0?(a.amount/a.order_count).toFixed(2):0})))||[]},Jr=(t,s)=>(t.item_stats||[]).map(a=>{const l=s[a.item_id]||a.item_id;return{name:l.length>12?`${l.substring(0,12)}...`:l,sales:a.order_count}}).sort((a,l)=>l.sales-a.sales).slice(0,10),Gr=(t,s,a)=>{const l=t.revenue_stats.total_orders||0;return(t.item_stats||[]).map(n=>{const c=s[n.item_id]||n.item_id;return{name:c.length>10?`${c.substring(0,10)}...`:c,value:n.order_count,percent:l>0?n.order_count/l*100:0}}).sort((n,c)=>c.value-n.value).slice(0,6).map((n,c)=>({...n,color:a[c%a.length]}))},Vr=(t,s,a)=>{const l=t.revenue_stats.total_amount||0;return(t.item_stats||[]).map(n=>{const c=s[n.item_id]||n.item_id;return{name:c.length>12?`${c.substring(0,12)}...`:c,value:n.total_amount,orderCount:n.order_count,percentage:l>0?n.total_amount/l*100:0}}).sort((n,c)=>c.value-n.value).slice(0,5).map((n,c)=>({...n,color:a[c%a.length],percentage:n.percentage.toFixed(1)}))},Qr=(t,s)=>{if(!t||!s)return null;const a=t.revenue_stats.total_amount,l=s.revenue_stats.total_amount;if(l===0)return a>0?"+100%":"0%";const n=(a-l)/l*100;return`${n>=0?"+":""}${n.toFixed(1)}%`},Kr=t=>({today:"今天",yesterday:"昨天","3days":"三天内","7days":"7天内","30days":"一个月内",custom:"自定义"})[t.range]||"所选范围",Hr=t=>Math.max(...t.map(s=>s.sales),1),Hs=(t,s,a)=>t===s&&!a.aborted,Zr=3e4,Yr=10*6e4;let ns=!1;const Da=()=>{ns||typeof window>"u"||(ns=!0,window.dispatchEvent(new Event("auth:logout")),queueMicrotask(()=>{ns=!1}))},Xr=t=>{if(!t)return"";const s=new URLSearchParams;for(const[l,n]of Object.entries(t))n!=null&&s.set(l,String(n));const a=s.toString();return a?`?${a}`:""},as=async(t,s,a={})=>{var N;const l=Xr(a.params),n=`${s}${l}`,c=$a(a.signal,a.timeoutMs??Zr);let u;try{u=await fetch(n,{method:t,credentials:"include",signal:c.signal,headers:{...a.body===void 0?{}:{"Content-Type":"application/json"}},body:a.body===void 0?void 0:JSON.stringify(a.body)})}catch(x){throw c.signal.aborted?new Error((N=a.signal)!=null&&N.aborted?"请求已取消":"请求超时,请稍后重试"):x}finally{c.cleanup()}const m=(u.headers.get("content-type")||"").includes("application/json");if(!u.ok){u.status===401&&!a.skipAuthLogout&&Da();const x=m?await u.json().catch(()=>{}):await u.text().catch(()=>{}),p=Ma(x,u.status);throw new Error(p)}return m?await u.json():await u.text()},Ne=async(t,s,a)=>as("GET",t,{params:s,...a}),ye=async(t,s,a)=>as("POST",t,{body:s,...a}),ze=async(t,s,a)=>as("PUT",t,{body:s,...a}),et=async(t,s,a)=>as("DELETE",t,{params:s,...a}),At=async(t,s,a={})=>{var m;const l=$a(a.signal,a.timeoutMs??Yr);let n;try{n=await fetch(t,{method:"POST",credentials:"include",signal:l.signal,body:s})}catch(N){throw l.signal.aborted?new Error((m=a.signal)!=null&&m.aborted?"请求已取消":"上传超时,请稍后重试"):N}finally{l.cleanup()}const h=(n.headers.get("content-type")||"").includes("application/json")?await n.json().catch(()=>{}):await n.text().catch(()=>{});if(!n.ok){n.status===401&&Da();const N=Ma(h,n.status),x=new Error(N);throw x.payload=h,x}return h},$a=(t,s)=>{const a=new AbortController,l=()=>a.abort(t==null?void 0:t.reason);t!=null&&t.aborted?l():t==null||t.addEventListener("abort",l,{once:!0});const n=globalThis.setTimeout(()=>a.abort(new DOMException("timeout","TimeoutError")),Math.max(1,s));return{signal:a.signal,cleanup:()=>{globalThis.clearTimeout(n),t==null||t.removeEventListener("abort",l)}}},el=t=>{if(typeof t!="object"||t===null)return!1;const s=t;return typeof s.code=="string"&&typeof s.message=="string"},Ma=(t,s)=>typeof t=="string"?t:el(t)?t.message:`请求失败: ${s}`,tl=t=>{const s={...t};if("renewal_log_retention_days"in s){const a=Number(s.renewal_log_retention_days);s.renewal_log_retention_days=Number.isFinite(a)?a:10}return s},sl=async t=>ye("/api/v1/session/login",t,{skipAuthLogout:!0}),al=async t=>ye("/api/v1/session/initialize",{password:t},{skipAuthLogout:!0}),qa=async t=>Ne("/api/v1/session",void 0,t),rl=async()=>ye("/api/v1/session/logout",{}),ll=async(t,s)=>ze("/api/v1/session/credentials",t,s),nl=(t,s)=>{const a=t.avatar_url||"";if(!a)return"";try{const l=new URL(a,window.location.origin);return l.hostname.endsWith("alicdn.com")&&l.searchParams.set("_v",s),l.toString()}catch{return a}},Ft=async t=>{const s=await Ne("/api/v1/accounts/details",void 0,t),a=Date.now().toString();return s.map(l=>({id:l.id,value:"",cookie:"",enabled:l.enabled,auto_confirm:l.auto_confirm,remark:l.remark,note:l.remark,pause_duration:l.pause_duration,paused_until:Number(l.paused_until||0),paused:l.paused===!0,username:l.username||"",login_password:"",show_browser:l.show_browser===!0||l.show_browser===1||l.show_browser==="1"||l.show_browser==="true",nickname:l.nickname||l.remark||`账号 ${l.id.substring(0,6)}`,avatar_url:nl(l,a),profile_error:l.profile_error||"",ai_enabled:!1,auto_rate_enabled:l.auto_rate_enabled,rate_content:l.rate_content||"不错的买家,交易愉快",auto_polish_enabled:l.auto_polish_enabled,polish_time:l.polish_time||"03:00",last_rate_scan_at:Number(l.last_rate_scan_at||0),last_polish_date:l.last_polish_date||"",last_polish_at:Number(l.last_polish_at||0)}))},Zs=async(t,s)=>Ne(`/api/v1/account-tasks/${t}`,void 0,s),Ys=async(t,s,a)=>ze(`/api/v1/account-tasks/${t}`,s,a),il=async(t,s,a)=>ye(`/api/v1/account-tasks/${t}/run`,{task_type:s},{timeoutMs:12e4,...a}),is=async(t,s,a,l=!1)=>{const n=await Ne("/api/v1/chat/sessions",{account_id:t,cursor:s,refresh:l?1:void 0},l?{timeoutMs:6e4,...a}:a);return{sessions:n.sessions||[],has_more:n.has_more===!0,next_cursor:n.next_cursor}},Xs=async(t,s,a,l,n)=>{const c=await Ne("/api/v1/chat/messages",{account_id:t,chat_id:s,cursor:a,before_id:l},n);return{messages:c.messages||[],has_more:c.has_more===!0,next_cursor:c.next_cursor,session:c.session}},ol=async(t,s)=>ye("/api/v1/chat/messages",t,s),cl=async(t,s)=>{const a=new FormData;return Object.entries(t).forEach(([l,n])=>a.append(l,n)),At("/api/v1/chat/images",a,{timeoutMs:12e4,...s})},ea=async(t,s,a)=>ye("/api/v1/chat/read",{account_id:t,chat_id:s},a),Ss=async t=>Ne("/api/v1/accounts/runtime-status",void 0,t),dl=async t=>ye("/api/v1/qr-login/generate",void 0,{...t,timeoutMs:(t==null?void 0:t.timeoutMs)??13e4}),xl=async(t,s)=>Ne(`/api/v1/qr-login/check/${t}`,void 0,{signal:s,timeoutMs:1e4}),ml=async(t,s)=>ye(`/api/v1/qr-login/complete-verification/${t}`,{target_account_id:s||""}),ul=async(t,s)=>ze(`/api/v1/accounts/${t}/status`,{enabled:s}),pl=async t=>et(`/api/v1/accounts/${t}`),hl=async(t,s,a)=>ze(`/api/v1/accounts/${t}/pause-duration`,{pause_duration:s},a),gl=async(t,s,a)=>ze(`/api/v1/accounts/${t}/settings`,s,a),bl=async(t,s)=>Ne(`/api/v1/accounts/${t}/long-login`,void 0,s),fl=async(t,s,a)=>ze(`/api/v1/accounts/${t}/long-login`,{enabled:s},a),yl=async(t,s)=>ye("/api/v1/password-login",t,s),jl=async(t,s)=>Ne(`/api/v1/password-login/check/${t}`,void 0,{signal:s,timeoutMs:1e4}),Nl=async(t,s)=>et(`/api/v1/password-login/cancel/${t}`,void 0,s),vl=async t=>ye(`/api/v1/accounts/${t}/refresh-profile`,{}),_l=async t=>Ne("/api/v1/settings/ai-reply",void 0,t),Ba=t=>{const s=String(t||"");return s==="paid"?"pending_ship":["processing","pending_ship","shipped","completed","cancelled","refunding"].includes(s)?s:"unknown"},wl=async(t,s,a=1,l=20,n,c)=>{const u={page:a,page_size:l};t&&(u.cookie_id=t),s&&s!=="all"&&(u.status=s),n!=null&&n.trim()&&(u.search=n.trim());const h=await Ne("/api/v1/orders",u,c),N=(h.orders||h.data||[]).map(x=>({...x,id:x.id||x.order_id,status:Ba(x.status||x.order_status),quantity:Number(x.quantity||1)}));return{success:!0,data:N,total:h.total||N.length,page:h.page||a,page_size:h.page_size||l,total_pages:h.total_pages||1}},kl=async(t,s)=>ze(`/api/v1/orders/${t}`,s),Cl=async t=>et(`/api/v1/orders/${t}`),Sl=async(t,s)=>{const a=new FormData;return t&&a.append("cookie_id",t),s&&a.append("status",s),At("/api/v1/orders/refresh",a)},Ll=async t=>ye(`/api/v1/orders/${t}/refresh`),Rl=async(t,s)=>ye("/api/v1/orders/manual-ship",{order_ids:t,ship_mode:s}),Al=async(t,s)=>t instanceof FormData?At("/api/v1/orders/import",t,s):ye("/api/v1/orders/import",t,s),Il=async t=>Ne("/api/v1/analytics/dashboard",void 0,t),ta=async(t=7,s)=>{let a;if(typeof t=="number"){const l=new Date,n=new Date;n.setDate(n.getDate()-t),a={start_date:es(n),end_date:es(l)}}else a=t;return Ne("/api/v1/analytics/orders",{...a,timezone_offset_minutes:-new Date().getTimezoneOffset()},s)},Ol=async(t,s)=>{const a=await Ne("/api/v1/analytics/orders/valid",{start_date:t.start_date,end_date:t.end_date,timezone_offset_minutes:-new Date().getTimezoneOffset()},s),n=(Array.isArray(a)?a:a.orders||[]).map(c=>({...c,id:c.id||c.order_id,status:Ba(c.status||c.order_status),quantity:Number(c.quantity||1)}));return{orders:n,total:Array.isArray(a)?n.length:Number(a.total??n.length),truncated:Array.isArray(a)?!1:a.truncated===!0}},Pl=t=>{let s=t.api_config;if(typeof s=="string"&&s.trim())try{s=JSON.parse(s)}catch{s=void 0}return{...t,api_config:s||void 0}},Fa=t=>({...t,api_config:t.api_config?JSON.stringify(t.api_config):""}),Ms=async t=>{const s=await Ne("/api/v1/cards",void 0,t);return(Array.isArray(s)?s:s.cards||[]).map(Pl)},Tl=async t=>ye("/api/v1/cards",Fa(t)),sa=async(t,s)=>ze(`/api/v1/cards/${t}`,Fa(s)),El=async t=>et(`/api/v1/cards/${t}`),Dl=async(t,s)=>{const a=new FormData;return a.append("file",t),At("/api/v1/cards/batch",a,s)},$l=async(t,s,a)=>ye(`/api/v1/cards/${t}/append-data`,{content:s},a),os=t=>t===!0||t===1||t==="1",Lt=async(t,s)=>{const a=await Ne("/api/v1/items",void 0,s);return(Array.isArray(a)?a:a.items||[]).map(n=>({...n,id:n.id||`${n.cookie_id}-${n.item_id}`,is_multi_spec:os(n.is_multi_spec),is_multi_qty_ship:os(n.is_multi_qty_ship??n.multi_quantity_delivery),multi_quantity_delivery:os(n.multi_quantity_delivery??n.is_multi_qty_ship)}))},Ml=async t=>ye("/api/v1/items/get-all-from-account",{cookie_id:t}),ql=async(t,s)=>et(`/api/v1/items/${t}/${s}`),Bl=async(t,s)=>ye(`/api/v1/items/${t}`,s),Fl=async t=>{const s=new FormData;s.set("cookie_id",t.cookie_id),s.set("title",t.title),s.set("description",t.description),s.set("price",t.price),s.set("original_price",t.original_price||""),s.set("quantity",String(t.quantity)),s.set("postage_mode",t.postage_mode),s.set("postage",t.postage||""),t.location&&s.set("location",JSON.stringify(t.location));for(const a of t.images)s.append("images",a);return At("/api/v1/items/publish",s)},zl=async(t,s)=>ye("/api/v1/items/publish-categories/recommend",{cookie_id:t,keyword:s}),Ul=async t=>{const s=new FormData;return s.set("file",t.file),t.imagesZip&&s.set("images_zip",t.imagesZip),t.defaultCookieId&&s.set("default_cookie_id",t.defaultCookieId),s.set("fallback_category_id",t.fallbackCategory.catId),s.set("fallback_category_name",t.fallbackCategory.catName),s.set("fallback_channel_category_id",t.fallbackCategory.channelCatId||""),s.set("fallback_tb_category_id",t.fallbackCategory.tbCatId||""),t.location&&s.set("location",JSON.stringify(t.location)),At("/api/v1/items/publish-batches/preview",s)},Wl=async t=>ye("/api/v1/items/publish-batches",{preview_id:t}),Nt=async t=>Ne(`/api/v1/items/publish-batches/${t}`),za=async(t=20)=>{const s=await Ne("/api/v1/items/publish-batches",{limit:t});return Array.isArray(s)?s:s.batches||[]},Jl=async t=>et(`/api/v1/items/publish-batches/${t}`),Gl=async t=>ye(`/api/v1/items/publish-batches/${t}/cancel`,{}),Vl=async t=>ye(`/api/v1/items/publish-batches/${t}/retry-failed`,{}),Ql=async(t,s,a)=>ze(`/api/v1/items/${t}/${s}`,a),Ua=t=>t.map(s=>{var a,l;return{id:String(s.id),name:s.name||"",trigger_type:s.trigger_type||"order_paid",item_keyword:s.item_title||s.item_id||"",cookie_id:s.cookie_id||"",item_id:s.item_id||"",item_title:s.item_title||"",card_group_id:Number(((a=(s.actions||[]).find(n=>n.action_type==="send_card"))==null?void 0:a.card_id)||0),card_group_name:((l=(s.actions||[]).find(n=>n.action_type==="send_card"))==null?void 0:l.card_name)||"",priority:s.priority||100,enabled:s.enabled||!1,config_json:s.config_json||"{}",actions:(s.actions||[]).map(n=>({id:n.id?String(n.id):void 0,action_type:n.action_type,card_id:Number(n.card_id||0),card_name:n.card_name||"",delivery_count:Number(n.delivery_count||1),message_template:n.message_template||"",delay_seconds:Number(n.delay_seconds||0),config_json:n.config_json||"{}",enabled:n.enabled!==!1,sort_order:Number(n.sort_order||0)})),variants:(s.actions||[]).filter(n=>n.action_type==="send_card").map(n=>{let c={};try{c=JSON.parse(n.config_json||"{}")}catch{}return{id:n.id?String(n.id):void 0,spec_name:c.spec_name||"",spec_value:c.spec_value||"",card_id:Number(n.card_id||0),card_name:n.card_name||"",delivery_count:Number(n.delivery_count||1),enabled:n.enabled!==!1,delay_override:c.delay_override===!0,delay_seconds:Number(n.delay_seconds||0),config_json:n.config_json||"{}"}})}}),Ls=async()=>{const t=await Ne("/api/v1/automation-rules"),s=Array.isArray(t)?t:t.data||[];return Ua(s)},Kl=async({cookieId:t,triggerType:s,enabled:a,search:l,page:n=1,pageSize:c=10}={})=>{const u=await Ne("/api/v1/automation-rules",{page:n,page_size:c,cookie_id:t||void 0,trigger_type:s||void 0,enabled:a,search:(l==null?void 0:l.trim())||void 0}),h=Ua(Array.isArray(u)?u:u.data||[]);return{success:!0,data:h,total:Number(Array.isArray(u)?h.length:u.total??h.length),page:Number(Array.isArray(u)?n:u.page??n),page_size:Number(Array.isArray(u)?c:u.page_size??c),total_pages:Number(Array.isArray(u)?h.length?1:0:u.total_pages??(h.length?1:0)),trigger_counts:Object.fromEntries(Object.entries(Array.isArray(u)?{}:u.trigger_counts||{}).map(([m,N])=>[m,Number(N)]))}},Hl=(t,s)=>{if(t!=="order_paid")return s.map((n,c)=>({...n,sort_order:n.sort_order||c+1}));const a=s.filter(n=>n.action_type==="send_card").map((n,c)=>({...n,sort_order:c+1})),l=s.filter(n=>n.action_type!=="send_card"&&n.action_type!=="confirm_shipment");return[...a,...l.map((n,c)=>({...n,sort_order:a.length+c+1})),{action_type:"confirm_shipment",enabled:!0,sort_order:a.length+l.length+1}]},aa=async t=>{const s=t.trigger_type||"order_paid",l=[{order_paid:"付款后自动发货",buyer_reviewed:"评价后发送赠品",review_missing_timeout:"超时未评价求评价"}[s]||"自动化规则",t.item_title||t.item_id||t.cookie_id||""].filter(Boolean).join(" - "),n=(t.actions||[]).filter(m=>m.action_type!=="send_card"&&m.action_type!=="confirm_shipment"),c=t.variants&&t.variants.length>0?[...t.variants.map((m,N)=>({action_type:"send_card",card_id:m.card_id,delivery_count:m.delivery_count||1,enabled:m.enabled!==!1,sort_order:N+1,delay_seconds:m.delay_seconds||0,config_json:JSON.stringify({spec_name:m.spec_name||"",spec_value:m.spec_value||"",delay_override:m.delay_override===!0})})),...n]:t.actions&&t.actions.length>0?t.actions:[{action_type:"send_card",card_id:t.card_group_id||0,delivery_count:1,enabled:!0,sort_order:1}],u=Hl(s,c),h={cookie_id:t.cookie_id||"",item_id:t.item_id||"",name:(t.name||"").trim()||l||"自动化规则",trigger_type:s,enabled:t.enabled??!0,priority:t.priority||100,config_json:t.config_json||"{}",actions:u.map((m,N)=>({action_type:m.action_type,card_id:m.card_id||0,delivery_count:m.delivery_count||1,message_template:m.message_template||"",delay_seconds:m.delay_seconds||0,config_json:m.config_json||"{}",enabled:m.enabled!==!1,sort_order:m.sort_order||N+1}))};return t.id?ze(`/api/v1/automation-rules/${t.id}`,h):ye("/api/v1/automation-rules",h)},Zl=async t=>et(`/api/v1/automation-rules/${t}`),Yl=async()=>{const t=await Ne("/api/v1/automation-issues");return{runs:Array.isArray(t==null?void 0:t.runs)?t.runs:[],pending_tasks:Array.isArray(t==null?void 0:t.pending_tasks)?t.pending_tasks:[]}},Xl=async(t,s)=>ye(`/api/v1/automation-runs/${t}/resolve`,{resolution:s}),en=async(t,s)=>ye(`/api/v1/automation-pending-tasks/${t}/resolve`,{resolution:s}),tn=t=>({id:String((t==null?void 0:t.id)||""),keyword:(t==null?void 0:t.keyword)||"",reply:(t==null?void 0:t.reply)||"",item_id:(t==null?void 0:t.item_id)||"",type:(t==null?void 0:t.type)==="image"?"image":"text",image_url:(t==null?void 0:t.image_url)||""}),sn=async t=>{const s=await Ne(`/api/v1/reply-rules/${t}/typed`);return Array.isArray(s)?s.map(tn):[]},an=async t=>t?(await sn(t)).map(a=>({id:a.id,keyword:a.keyword||"",reply_content:a.reply||"",match_type:"fuzzy",enabled:!0,item_id:a.item_id||"",type:a.type==="image"?"image":"text",image_url:a.image_url||""})):[],rn=async(t,s)=>{const a=t.type||"text",l={keyword:t.keyword||"",reply:a==="text"&&t.reply_content||"",item_id:t.item_id||"",type:a,image_url:a==="image"&&t.image_url||""};return t.id?ze(`/api/v1/reply-rules/${s}/typed/${t.id}`,l):ye(`/api/v1/reply-rules/${s}/items`,l)},ln=async(t,s)=>et(`/api/v1/reply-rules/${s}/typed/${t}`),Wa=async t=>{const s=await Ne("/api/v1/settings/system",void 0,t);return tl(s.data||s)},Ja=async(t,s)=>{const a=Object.fromEntries(Object.entries(t).filter(([,l])=>l!=null));return ze("/api/v1/settings/system",a,s)},nn=async(t,s)=>Ne(`/api/v1/settings/ai-reply/${t}`,void 0,s),on=async(t,s,a)=>{const l={ai_enabled:s.ai_enabled??!1,max_discount_percent:s.max_discount_percent??10,max_discount_amount:s.max_discount_amount??100,max_bargain_rounds:s.max_bargain_rounds??3,custom_prompts:s.custom_prompts??""};return ze(`/api/v1/settings/ai-reply/${t}`,l,a)},cn=async(t,s="",a)=>(await ye("/api/v1/settings/ai-models",{base_url:t,api_key:s},a)).models||[],dn=t=>{if(Array.isArray(t))return t.filter(Boolean);if(typeof t!="string"||!t.trim())return[];try{const s=JSON.parse(t);if(Array.isArray(s))return s.filter(Boolean)}catch{}return t.split(/[,\s;]+/).map(s=>s.trim()).filter(Boolean)},Ga=t=>{const s=Array.from(new Set((t||[]).filter(Boolean)));return s.length>0?JSON.stringify(s):""},Va=async t=>({success:!0,data:(await Ne("/api/v1/notifications/channels",void 0,t)||[]).map(l=>{let n;try{n=typeof l.config=="string"?JSON.parse(l.config):l.config}catch{n={}}return{id:String(l.id),name:l.name,type:l.type==="ding_talk"?"dingtalk":l.type==="lark"?"feishu":l.type,config:n,event_types:dn(l.event_types),enabled:l.enabled,created_at:l.created_at,updated_at:l.updated_at}})}),xn=async(t,s)=>ye("/api/v1/notifications/channels",{...t,config:JSON.stringify(t.config),event_types:Ga(t.event_types)},s),ra=async(t,s,a)=>{const l={...s};return"config"in s&&(l.config=JSON.stringify(s.config)),"event_types"in s&&(l.event_types=Ga(s.event_types)),ze(`/api/v1/notifications/channels/${t}`,l,a)},mn=async(t,s)=>et(`/api/v1/notifications/channels/${t}`,void 0,s),un=async(t,s)=>{const a=await Ne(`/api/v1/notifications/accounts/${t}/bindings`,void 0,s);return(a==null?void 0:a.channel_ids)||[]},pn=async(t,s)=>ye(`/api/v1/notifications/channels/${t}/test`,{},s),la=async()=>Ne("/api/v1/default-replies"),hn=async t=>{const s=await Ne(`/api/v1/default-replies/${t}`);return{cookie_id:t,enabled:s.enabled||!1,reply_content:s.reply_content||"",reply_once:s.reply_once||!1,reply_image_url:s.reply_image_url||""}},gn=async(t,s)=>ze(`/api/v1/default-replies/${t}`,{enabled:s.enabled??!1,reply_content:s.reply_content||"",reply_once:s.reply_once??!1,reply_image_url:s.reply_image_url||""}),bn=async t=>et(`/api/v1/default-replies/${t}`),fn=async t=>ye(`/api/v1/default-replies/${t}/clear-records`,{}),na=t=>t instanceof Error&&t.message==="请求已取消",cs=(t,s)=>t instanceof Error?t.message:s,yn=t=>{const{range:s,customStartDate:a,customEndDate:l,customRangeVersion:n}=t,[c,u]=r.useState(null),[h,m]=r.useState(null),[N,x]=r.useState({overview:"idle",range:"idle",error:""}),[p,_]=r.useState(0),S=r.useRef(0),q=r.useMemo(()=>({range:s,customStartDate:a,customEndDate:l}),[l,a,s]),w=r.useCallback(()=>_(F=>F+1),[]);r.useEffect(()=>{const F=new AbortController;return x(d=>({...d,overview:"loading",error:""})),Promise.all([Il({signal:F.signal}),Lt(void 0,{signal:F.signal})]).then(([d,B])=>{F.signal.aborted||(u({stats:d,items:B,itemNames:Ur(B)}),x(Z=>({...Z,overview:"success"})))}).catch(d=>{F.signal.aborted||na(d)||x(B=>({...B,overview:"error",error:cs(d,"概览加载失败")}))}),()=>F.abort()},[p]),r.useEffect(()=>{let F;try{F=Ea(s,new Date,a,l)}catch(M){x(b=>({...b,range:"error",error:cs(M,"日期范围无效")}));return}const d=zr(F),B=++S.current,Z=new AbortController;return x(M=>({...M,range:"loading",error:""})),Promise.all([ta({start_date:F.startDate,end_date:F.endDate},{signal:Z.signal}),ta({start_date:d.startDate,end_date:d.endDate},{signal:Z.signal}),Ol({start_date:F.startDate,end_date:F.endDate},{signal:Z.signal})]).then(([M,b,k])=>{Hs(S.current,B,Z.signal)&&(m({analytics:M,previousAnalytics:b,validOrders:k,dateRange:F}),x(D=>({...D,range:"success"})))}).catch(M=>{!Hs(S.current,B,Z.signal)||na(M)||x(b=>({...b,range:"error",error:cs(M,"经营数据加载失败")}))}),()=>Z.abort()},[n,s,p]);const P=r.useMemo(()=>c&&h?{...c,...h}:null,[c,h]),A=(c==null?void 0:c.itemNames)||{},G=(h==null?void 0:h.analytics)||null,H=r.useMemo(()=>G?Wr(G):[],[G]),X=r.useMemo(()=>G?Jr(G,A):[],[G,A]),f=r.useMemo(()=>["rgb(var(--color-brand))","rgb(var(--color-brand-highlight))","rgb(var(--color-success-500))","rgb(var(--color-warning-500))","rgb(var(--color-accent-500))"],[]),y=r.useMemo(()=>G?Gr(G,A,f):[],[G,f,A]),z=r.useMemo(()=>G?Vr(G,A,f):[],[G,f,A]),O=r.useMemo(()=>Hr(X),[X]);return{data:P,status:N,chartData:H,productSalesData:X,sourceData:y,categoryData:z,maxProductSales:O,trendPercent:Qr(G,(P==null?void 0:P.previousAnalytics)||null),selectedRangeLabel:Kr(q),refresh:w}},Ce=(t,s)=>s===void 0?`rgb(var(--color-${t}))`:`rgb(var(--color-${t}) / ${s})`,jn=({chartData:t,selectedRangeLabel:s,totalAmount:a})=>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:[s,"的销售额走势"]})]}),e.jsx("div",{className:"dashboard-revenue-chart h-[350px] w-full",children:t.length===0||a===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(wa,{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:"所选时间范围内暂无订单记录"})]}):t.length<=2?e.jsx(Yt,{width:"100%",height:"100%",children:e.jsxs(Tr,{data:t,margin:{top:30,right:20,left:0,bottom:30},barCategoryGap:"45%",children:[e.jsx(Gs,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:Ce("neutral-700"),fontSize:14,fontWeight:600},dy:10}),e.jsx(Vs,{axisLine:!1,tickLine:!1,tick:{fill:Ce("neutral-400"),fontSize:13,fontWeight:500},tickFormatter:(l=>`¥${l}`)}),e.jsx(Xt,{contentStyle:{backgroundColor:Ce("white"),borderRadius:"8px",border:`1px solid ${Ce("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:Ce("neutral-500"),fontWeight:500},itemStyle:{color:Ce("brand"),fontWeight:600},cursor:{fill:Ce("brand",.08)},formatter:(l=>[`¥${Number(l).toFixed(2)}`,"营收"])}),e.jsx(Er,{dataKey:"amount",fill:Ce("brand"),maxBarSize:72,radius:[12,12,0,0],activeBar:!1,stroke:"none",strokeWidth:0,children:t.map((l,n)=>e.jsx(_s,{fill:Ce("brand"),stroke:"none",strokeWidth:0},`cell-${n}`))})]})}):e.jsx(Yt,{width:"100%",height:"100%",children:e.jsxs(Dr,{data:t,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:Ce("brand"),stopOpacity:.5}),e.jsx("stop",{offset:"95%",stopColor:Ce("brand"),stopOpacity:0})]})}),e.jsx(Gs,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:Ce("neutral-400"),fontSize:13,fontWeight:500},dy:15}),e.jsx(Vs,{axisLine:!1,tickLine:!1,tick:{fill:Ce("neutral-400"),fontSize:13,fontWeight:500}}),e.jsx($r,{vertical:!1,stroke:Ce("neutral-100"),strokeDasharray:"3 3"}),e.jsx(Xt,{contentStyle:{backgroundColor:Ce("white"),borderRadius:"8px",border:`1px solid ${Ce("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:Ce("neutral-500"),fontWeight:500},itemStyle:{color:Ce("brand"),fontWeight:600},cursor:{stroke:Ce("brand"),strokeWidth:2,strokeDasharray:"4 4"}}),e.jsx(Mr,{type:"monotone",dataKey:"amount",stroke:Ce("brand"),strokeWidth:4,fillOpacity:1,fill:"url(#colorAmount)",activeDot:{r:8,fill:Ce("white"),stroke:Ce("brand"),strokeWidth:2}})]})})})]}),Xe=(t,s)=>`rgb(var(--color-${t}))`,Nn=({status:t})=>{const s={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-brand 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",unknown:"bg-gray-100 text-gray-500"},a={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`inline-flex items-center justify-center whitespace-nowrap px-3 py-1.5 rounded-lg text-xs leading-none font-bold ${s[t]||s.cancelled}`,children:a[t]||t})},Jt=({title:t,value:s,icon:a,colorClass:l,trend:n})=>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 ${l} 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 ${l} bg-opacity-10 backdrop-blur-sm`,children:e.jsx(a,{className:`w-6 h-6 ${l.replace("bg-","text-")}`})}),n&&e.jsxs("span",{className:"text-xs font-bold text-white bg-brand px-3 py-1.5 rounded-full flex items-center gap-1 shadow-sm",children:[e.jsx(xr,{className:"w-3 h-3"})," ",n]})]}),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:s}),e.jsx("p",{className:"text-gray-500 text-sm font-medium mt-1",children:t})]})]}),ds=()=>{const[t,s]=r.useState("7days"),[a,l]=r.useState(""),[n,c]=r.useState(""),[u,h]=r.useState(""),[m,N]=r.useState(0),x=yn({range:t,customStartDate:a,customEndDate:n,customRangeVersion:m}),{data:p,status:_,chartData:S,productSalesData:q,sourceData:w,categoryData:P,maxProductSales:A,trendPercent:G,selectedRangeLabel:H,refresh:X}=x,f=(p==null?void 0:p.stats)||null,y=(p==null?void 0:p.analytics)||null;p!=null&&p.previousAnalytics;const z=(p==null?void 0:p.validOrders.orders)||[],O=(p==null?void 0:p.validOrders.total)||0,F=(p==null?void 0:p.validOrders.truncated)||!1,d=_.range==="loading",B=_.error,Z=[Xe("brand"),Xe("brand-highlight"),Xe("success-500"),Xe("warning-500"),Xe("accent-500")],M=v=>`¥${Number(v||0).toLocaleString("zh-CN",{maximumFractionDigits:2})}`;if(B&&(!f||!y))return e.jsxs("div",{className:"p-8 flex flex-col items-center gap-3 text-red-600",children:[e.jsx(ut,{className:"w-8 h-8"}),e.jsx("span",{children:B}),e.jsx("button",{type:"button",className:"ios-btn-primary px-4 py-2 rounded-xl",onClick:X,children:"重新加载"})]});if(!f||!y)return e.jsx("div",{className:"p-8 flex justify-center text-gray-400",children:e.jsx(Fs,{className:"w-8 h-8 animate-spin text-brand"})});const b=y.revenue_stats.total_orders||0,k=y.revenue_stats.total_amount||0,D=[{key:"today",label:"今天"},{key:"yesterday",label:"昨天"},{key:"3days",label:"三天内"},{key:"7days",label:"7天内"},{key:"30days",label:"一个月内"},{key:"custom",label:"自定义"}];let C;try{C=Ea(t,new Date,a,n)}catch{C={startDate:a,endDate:n}}const W=u.trim().toLowerCase(),V=z.filter(v=>{var ee,be,U,ae;return((ee=v.order_id)==null?void 0:ee.toLowerCase().includes(W))||((be=v.item_id)==null?void 0:be.toLowerCase().includes(W))||((U=v.item_title)==null?void 0:U.toLowerCase().includes(W))||((ae=v.buyer_id)==null?void 0:ae.toLowerCase().includes(W))});return e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[B&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm text-red-700",children:[e.jsx("span",{children:B}),e.jsx("button",{type:"button",className:"font-bold underline",onClick:X,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(v=>e.jsx("button",{onClick:()=>s(v.key),className:`px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${t===v.key?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:v.label},v.key)),t==="custom"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"date",value:a,onChange:v=>l(v.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-brand"}),e.jsx("span",{className:"self-center text-gray-400",children:"-"}),e.jsx("input",{type:"date",value:n,onChange:v=>c(v.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-brand"}),e.jsx("button",{onClick:()=>N(v=>v+1),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(Jt,{title:"累计营收 (CNY)",value:`¥${y.revenue_stats.total_amount.toLocaleString("zh-CN",{minimumFractionDigits:2})}`,icon:dr,colorClass:"bg-blue-400",trend:G||void 0}),e.jsx(Jt,{title:"活跃账号 / 总数",value:`${f.active_cookies} / ${f.total_cookies}`,icon:Na,colorClass:"bg-blue-500"}),e.jsx(Jt,{title:"订单数",value:y.revenue_stats.total_orders.toLocaleString(),icon:wa,colorClass:"bg-blue-500"}),e.jsx(Jt,{title:"库存卡密余量",value:f.available_card_stock,icon:ka,colorClass:"bg-purple-500"})]}),e.jsx(jn,{chartData:S,selectedRangeLabel:H,totalAmount:k}),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:q.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:q.map((v,ee)=>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 ${ee<3?"bg-blue-600 text-white":"bg-gray-100 text-gray-500"}`,children:ee+1}),e.jsx("span",{className:"font-bold text-gray-800 text-sm truncate",children:v.name})]}),e.jsxs("span",{className:"font-mono text-sm font-extrabold text-gray-900",children:[v.sales," 单"]})]}),e.jsx("div",{className:"h-3 rounded-full bg-gray-100 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-brand",style:{width:`${Math.max(8,v.sales/A*100)}%`}})})]},`${v.name}-${ee}`))})})]}),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:"dashboard-pie-chart h-[280px] relative",role:"img","aria-label":`商品下单占比,共 ${b} 单`,children:w.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:"暂无数据"}):e.jsxs(e.Fragment,{children:[e.jsx(Yt,{width:"100%",height:"100%",children:e.jsxs(Qs,{accessibilityLayer:!1,children:[e.jsx(Ks,{data:w,cx:"50%",cy:"45%",innerRadius:60,outerRadius:90,paddingAngle:2,dataKey:"value",activeShape:{outerRadius:96,stroke:"none",strokeWidth:0},rootTabIndex:-1,label:!1,labelLine:!1,children:w.map((v,ee)=>e.jsx(_s,{fill:v.color},`cell-${ee}`))}),e.jsx(Xt,{formatter:v=>`${Number(v||0)} 单`,wrapperStyle:{zIndex:30,outline:"none"},contentStyle:{backgroundColor:Xe("white"),border:`1px solid ${Xe("neutral-200")}`,borderRadius:"10px",boxShadow:"var(--shadow-md)"}}),e.jsx(qr,{verticalAlign:"bottom",height:36,iconType:"circle",formatter:v=>e.jsx("span",{style:{color:Xe("neutral-500"),fontWeight:500},children:v})})]})}),e.jsxs("div",{className:"pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center pb-9",children:[e.jsx("span",{className:"text-2xl font-extrabold text-gray-900 tabular-nums",children:b}),e.jsx("span",{className:"text-xs font-medium text-gray-400 mt-0.5",children:"总订单"})]})]})})]})]}),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-surface-muted",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900",children:"参与统计的订单"}),F&&e.jsxs("p",{className:"text-xs text-amber-700 mt-1",children:["当前显示最近 ",z.length," / ",O," 条,搜索仅覆盖已加载明细。"]})]}),e.jsx("div",{className:"relative",children:e.jsx("input",{placeholder:"搜索订单号/商品/买家...",value:u,onChange:v=>h(v.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:d?e.jsxs("div",{className:"flex items-center justify-center py-20 text-gray-400",children:[e.jsx(Fs,{className:"w-6 h-6 animate-spin mr-2"}),"加载中..."]}):V.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(Bt,{className:"w-7 h-7 text-gray-300"})}),W?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:["当前共有 ",z.length," 单参与统计,但没有订单号、商品、买家匹配“",u,"”。"]})]}):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:["日期范围:",C.startDate," 至 ",C.endDate,"; 统计口径:待发货、已发货、已完成,且订单金额不为空。 当前统计卡片订单数:",y.revenue_stats.total_orders," 单。"]})]})]}):e.jsxs("table",{className:"w-full min-w-[760px] 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 whitespace-nowrap",children:"状态"}),e.jsx("th",{className:"px-6 py-4 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:V.map(v=>e.jsxs("tr",{className:"hover:bg-warning-50/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(Bt,{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:v.item_title||v.item_id||"未知商品"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 font-mono",children:v.order_id}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",v.quantity||1]})]})]})}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"text-sm font-bold text-gray-800",children:v.buyer_id}),v.created_at&&e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:Cs(v.created_at)})]}),e.jsxs("td",{className:"px-6 py-4 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:["¥",v.amount||"0.00"]}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx(Nn,{status:v.status||v.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=${v.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(Ca,{className:"w-4 h-4"})})})]},v.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)"}),P.length===0?e.jsx("div",{className:"flex items-center justify-center h-[300px] text-gray-400",children:"暂无数据"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"dashboard-pie-chart h-[280px] relative",role:"img","aria-label":`商品金额分析,总金额 ${M(k)}`,children:[e.jsx(Yt,{width:"100%",height:"100%",children:e.jsxs(Qs,{accessibilityLayer:!1,children:[e.jsx(Ks,{data:P,cx:"50%",cy:"50%",innerRadius:60,outerRadius:92,paddingAngle:2,dataKey:"value",activeShape:{outerRadius:98,stroke:"none",strokeWidth:0},rootTabIndex:-1,label:!1,labelLine:!1,children:P.map((v,ee)=>e.jsx(_s,{fill:v.color||Z[ee%Z.length]},`cell-${ee}`))}),e.jsx(Xt,{wrapperStyle:{zIndex:30,outline:"none"},contentStyle:{backgroundColor:Xe("white"),border:`1px solid ${Xe("neutral-200")}`,borderRadius:"6px",boxShadow:"var(--shadow-md)"},formatter:v=>`¥${Number(v||0).toLocaleString()}`})]})}),e.jsxs("div",{className:"pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-lg font-extrabold text-gray-900 tabular-nums",children:M(k)}),e.jsx("span",{className:"text-xs font-medium text-gray-400 mt-0.5",children:"总金额"})]})]}),e.jsx("div",{className:"space-y-3 mt-4",children:P.map(v=>e.jsxs("div",{className:"flex justify-between items-center gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:v.color||Z[P.indexOf(v)%Z.length]}}),e.jsx("span",{className:"text-gray-600 font-medium truncate",title:v.name,children:v.name})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0 whitespace-nowrap",children:[e.jsxs("span",{className:"font-bold text-gray-900",children:["¥",v.value.toLocaleString()]}),e.jsxs("span",{className:"text-xs text-gray-500 bg-gray-100 px-2 py-0.5 rounded",children:[v.percentage,"%"]})]})]},v.name))})]})]})]})]})},vn=new Set(["expired","cancelled","error","not_found"]),_n=()=>{let t=0;return{next:()=>(t+=1,t),cancel:()=>{t+=1},isCurrent:s=>s===t}},wn=(t={setInterval:globalThis.setInterval.bind(globalThis),clearInterval:globalThis.clearInterval.bind(globalThis)})=>{let s=null,a=null,l=-1,n=0;const c=()=>{n+=1,a==null||a.abort(),a=null,s!==null&&(t.clearInterval(s),s=null)};return{start:(h,m,N,x=2e3)=>{c();const p=n;a=new AbortController;const _=a.signal;s=t.setInterval(()=>{l===p||p!==n||(l=p,(async()=>{var S,q;try{const w=await m(h,_);if(w.status==="success"){c(),await N.onSuccess(w);return}if(w.status==="scanned"){(S=N.onScanned)==null||S.call(N,w);return}if(w.status==="verification_required"){(q=N.onVerificationRequired)==null||q.call(N,w);return}w.status&&vn.has(w.status)&&(c(),N.onTerminalError(w))}catch(w){if(_.aborted||p!==n)return;c(),N.onPollError(w)}finally{l===p&&(l=-1)}})())},x)},stop:c,isActive:()=>s!==null}},kn=({faceQrUrl:t,verificationScreenshot:s})=>e.jsxs("div",{className:"w-full min-w-0 max-h-[min(64vh,28rem)] overflow-y-auto overscroll-contain px-1 py-2 text-center",children:[e.jsx("div",{className:"mx-auto mb-2 flex h-10 w-10 items-center justify-center rounded-full bg-amber-100 text-amber-700",children:e.jsx(mr,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("h4",{className:"break-words text-base font-extrabold leading-6 text-amber-900",children:"需要完成安全风控验证"}),e.jsx("p",{className:"mx-auto mt-1 max-w-[15rem] break-words text-xs leading-5 text-amber-800",children:"当前账号触发了闲鱼平台风控。请使用手机闲鱼 App 扫描下方二维码,并按 App 提示完成人脸识别。"}),e.jsx("div",{className:"mx-auto mt-3 flex min-h-36 w-full max-w-[12rem] items-center justify-center overflow-hidden rounded-xl border border-amber-200 bg-white p-2 shadow-sm",children:t?e.jsx("img",{src:t,alt:"闲鱼安全风控验证二维码",className:"block max-h-44 w-full object-contain"}):s?e.jsx("img",{src:s,alt:"闲鱼风控验证页面",className:"block max-h-44 w-full object-contain"}):e.jsxs("div",{className:"flex flex-col items-center gap-2 text-amber-700",children:[e.jsx(_e,{className:"h-6 w-6 animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"text-xs font-bold",children:"正在准备风控二维码…"})]})}),e.jsx("p",{className:"mx-auto mt-2 max-w-[15rem] break-words text-[11px] leading-4 text-gray-500",children:"请勿在浏览器中打开验证链接。完成验证后系统会自动检测并刷新登录状态,无需手动确认。"})]}),Qa=({src:t,alt:s,className:a=""})=>e.jsx("img",{src:t,alt:s,className:`block aspect-square h-auto w-full object-contain ${a}`.trim()}),ia=t=>({account_id:t.id,auto_rate_enabled:t.auto_rate_enabled===!0,rate_content:t.rate_content||"不错的买家,交易愉快",auto_polish_enabled:t.auto_polish_enabled===!0,polish_time:t.polish_time||"03:00",last_rate_scan_at:t.last_rate_scan_at,last_polish_date:t.last_polish_date,last_polish_at:t.last_polish_at}),at=(t,s,a)=>t===s&&!a.aborted,xs=(t,s)=>t instanceof Error?t.message:s,ms=t=>t instanceof Error&&t.message==="请求已取消",oa=(t,s)=>!t&&s==="",Cn=({account:t,onSaved:s})=>{const[a,l]=r.useState(()=>ia(t)),[n,c]=r.useState(!0),[u,h]=r.useState(!1),[m,N]=r.useState(""),[x,p]=r.useState(""),[_,S]=r.useState(null),[q,w]=r.useState(null),P=r.useRef(0),A=r.useRef(null);r.useEffect(()=>{var z;const f=++P.current;(z=A.current)==null||z.abort();const y=new AbortController;return A.current=y,l(ia(t)),S(null),p(""),h(!1),N(""),w(null),c(!0),Zs(t.id,{signal:y.signal}).then(O=>{at(P.current,f,y.signal)&&l(O)}).catch(O=>{at(P.current,f,y.signal)&&!ms(O)&&p(xs(O,"加载任务设置失败"))}).finally(()=>{at(P.current,f,y.signal)&&c(!1)}),()=>y.abort()},[t.id]),r.useEffect(()=>()=>{var f;return(f=A.current)==null?void 0:f.abort()},[]);const G=r.useCallback(async()=>{var z;if(!oa(u,m))return;const f=++P.current;(z=A.current)==null||z.abort();const y=new AbortController;A.current=y,h(!0),p(""),w(null);try{const O=await Ys(t.id,a,{signal:y.signal});if(!at(P.current,f,y.signal))return;l(O),s(O)}catch(O){at(P.current,f,y.signal)&&!ms(O)&&(p(xs(O,"保存失败")),w(()=>G))}finally{at(P.current,f,y.signal)&&h(!1)}},[t.id,a,s,m,u]),H=r.useCallback(async f=>{var O;if(!oa(u,m)||!t.enabled)return;const y=++P.current;(O=A.current)==null||O.abort();const z=new AbortController;A.current=z,N(f),p(""),S(null),w(null);try{await Ys(t.id,a,{signal:z.signal});const F=await il(t.id,f,{signal:z.signal}),d=await Zs(t.id,{signal:z.signal});if(!at(P.current,y,z.signal))return;S(F.summary),l(d),s(d)}catch(F){at(P.current,y,z.signal)&&!ms(F)&&(p(xs(F,"任务执行失败")),w(()=>()=>H(f)))}finally{at(P.current,y,z.signal)&&N("")}},[t.enabled,t.id,a,s,m,u]),X=r.useCallback(async()=>{q&&await q()},[q]);return{form:a,loading:n,saving:u,running:m,summary:_,error:x,retryAvailable:q!==null,setForm:l,save:G,run:H,retry:X}},ca=({checked:t,onChange:s,label:a})=>e.jsx("button",{type:"button","aria-label":a,"aria-pressed":t,onClick:s,className:`relative h-8 w-14 shrink-0 rounded-full transition-colors ${t?"bg-sky-500":"bg-slate-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 h-6 w-6 rounded-full bg-white shadow-sm transition-transform ${t?"translate-x-6":""}`})}),Sn=({account:t,onClose:s,onSaved:a})=>{const{form:l,loading:n,saving:c,running:u,error:h,summary:m,retryAvailable:N,setForm:x,save:p,run:_,retry:S}=Cn({account:t,onSaved:a});return e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"640px"},role:"dialog","aria-modal":"true","aria-labelledby":"account-task-title",children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"account-task-title",className:"text-2xl font-extrabold text-slate-950",children:"账号自动任务"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:t.nickname||t.remark||t.id})]}),e.jsx("button",{type:"button",onClick:s,className:"rounded-xl p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700","aria-label":"关闭",children:e.jsx(ke,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[n&&e.jsx("div",{className:"rounded-xl bg-slate-50 px-4 py-3 text-sm text-slate-500",children:"正在读取任务设置..."}),e.jsx("section",{className:"rounded-2xl border border-slate-200 bg-white p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-emerald-50 text-emerald-600",children:e.jsx(ur,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-black text-slate-900",children:"自动评价"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-slate-500",children:"持续扫描待评价订单,按订单执行;不是每日任务。"})]}),e.jsx(ca,{checked:l.auto_rate_enabled,onChange:()=>x(q=>({...q,auto_rate_enabled:!q.auto_rate_enabled})),label:"自动评价"})]}),e.jsx("label",{className:"mt-4 block text-xs font-extrabold text-slate-600",children:"统一好评文案"}),e.jsx("textarea",{"aria-label":"统一好评文案",value:l.rate_content,maxLength:500,onChange:q=>x(w=>({...w,rate_content:q.target.value})),className:"mt-2 h-24 w-full resize-none rounded-xl border border-slate-200 bg-slate-50 px-3 py-2.5 text-sm leading-6 text-slate-800 placeholder:text-slate-400 outline-none focus:border-sky-400 focus:ring-2 focus:ring-sky-100"}),e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"text-xs text-slate-400",children:["最近扫描:",l.last_rate_scan_at?new Date(l.last_rate_scan_at*1e3).toLocaleString("zh-CN"):"尚未执行"]}),e.jsxs("button",{type:"button",disabled:u!==""||!t.enabled,onClick:()=>void _("auto_rate"),className:"flex items-center gap-2 rounded-xl bg-emerald-50 px-3 py-2 text-xs font-extrabold text-emerald-700 hover:bg-emerald-100 disabled:opacity-50",children:[u==="auto_rate"?e.jsx(_e,{className:"h-4 w-4 animate-spin"}):e.jsx(pr,{className:"h-4 w-4"}),"立即评价"]})]})]})]})}),e.jsx("section",{className:"rounded-2xl border border-slate-200 bg-white p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-amber-50 text-amber-600",children:e.jsx(Ds,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-black text-slate-900",children:"每日自动擦亮"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-slate-500",children:"每个账号每天最多执行一次,按北京时间判断。"})]}),e.jsx(ca,{checked:l.auto_polish_enabled,onChange:()=>x(q=>({...q,auto_polish_enabled:!q.auto_polish_enabled})),label:"每日自动擦亮"})]}),e.jsxs("div",{className:"mt-4 flex items-end justify-between gap-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-extrabold text-slate-600",children:"每日执行时间"}),e.jsx("input",{type:"time",value:l.polish_time,onChange:q=>x(w=>({...w,polish_time:q.target.value})),className:"mt-2 block rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-bold text-slate-800 outline-none focus:border-sky-400"})]}),e.jsxs("button",{type:"button",disabled:u!==""||!t.enabled,onClick:()=>void _("auto_polish"),className:"flex items-center gap-2 rounded-xl bg-amber-50 px-3 py-2 text-xs font-extrabold text-amber-700 hover:bg-amber-100 disabled:opacity-50",children:[u==="auto_polish"?e.jsx(_e,{className:"h-4 w-4 animate-spin"}):e.jsx(Sa,{className:"h-4 w-4"}),"立即擦亮"]})]}),e.jsxs("div",{className:"mt-3 text-xs text-slate-400",children:["上次完成:",l.last_polish_at?new Date(l.last_polish_at*1e3).toLocaleString("zh-CN"):"尚未执行"]})]})]})}),m&&e.jsxs("div",{className:"rounded-xl border border-sky-100 bg-sky-50 px-4 py-3 text-sm text-sky-900",children:["本次发现 ",m.found," 项,成功 ",m.success,",失败 ",m.failed,",跳过 ",m.skipped,"。",m.message||""]}),h&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm font-medium text-red-700",children:[e.jsx("span",{children:h}),N&&e.jsx("button",{type:"button",className:"font-bold underline",onClick:()=>void S(),children:"重试"})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex w-full gap-3",children:[e.jsx("button",{type:"button",onClick:s,disabled:c||u!=="",className:"flex-1 rounded-xl bg-gray-100 px-6 py-3 font-bold text-gray-700 transition-colors hover:bg-gray-200 disabled:opacity-50",children:"关闭"}),e.jsxs("button",{type:"button",onClick:()=>void p(),disabled:c||u!==""||l.auto_rate_enabled&&!l.rate_content.trim(),className:"ios-btn-primary flex flex-1 items-center justify-center gap-2 rounded-xl px-6 py-3 font-bold disabled:opacity-50",children:[c?e.jsx(_e,{className:"h-4 w-4 animate-spin"}):e.jsx(lt,{className:"h-4 w-4"}),"保存"]})]})})]})})},Ln=({account:t,editForm:s,setEditForm:a,saving:l,onClose:n,onSave:c,onRestartPause:u,longLogin:h,onToggleLongLogin:m,passwordLoginView:N,onPasswordLogin:x,onCancelPasswordLogin:p,notifChannels:_,selectedChannelIds:S,bindingsLoaded:q,bindingsLoading:w,bindingsLoadError:P,onRetryBindings:A,onToggleChannel:G,onSettingsDirty:H})=>{const X=(U,ae)=>{a(ge=>({...ge,[U]:ae}))},f=()=>void n(),y=()=>void c(),z=U=>X("remark",U.target.value),O=U=>X("cookie",U.target.value),F=()=>X("auto_confirm",!s.auto_confirm),d=U=>X("pause_duration",parseInt(U.target.value,10)||0),B=()=>void u(),Z=()=>void m(),M=U=>X("username",U.target.value),b=U=>a(ae=>({...ae,login_password:U.target.value,clear_password:!1})),k=()=>X("showLoginPassword",!s.showLoginPassword),D=U=>a(ae=>({...ae,clear_password:U.target.checked,login_password:U.target.checked?"":ae.login_password})),C=()=>X("show_browser",!s.show_browser),W=()=>void p(),V=()=>void x(),v=()=>void A(),ee=U=>{q&&(G(U),H())},be=U=>{const ae=S.includes(Number(U.id)),ge=()=>ee(Number(U.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:ge,disabled:!q,className:`w-5 h-5 rounded-md border-2 flex items-center justify-center transition-colors flex-shrink-0 ${ae?"bg-brand border-brand":"bg-white border-gray-300"}`,children:ae&&e.jsx(Ye,{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:U.name}),e.jsxs("div",{className:"text-xs text-gray-500",children:[U.type,U.enabled?"":" · 已停用"]})]})]},U.id)};return Oe.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:t.nickname||t.remark||t.id})]}),e.jsx("button",{onClick:f,className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(ke,{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:t.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:s.remark,onChange:z,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:s.cookie,onChange:O,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长度: ",s.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(Ye,{className:"w-4 h-4 text-green-500"}),"自动确认发货"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"自动将闲鱼订单标记为已发货"})]}),e.jsx("button",{type:"button",onClick:F,className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${s.auto_confirm?"bg-brand":"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 ${s.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(La,{className:"w-4 h-4 text-blue-500"}),"暂停处理时长(分钟)"]}),e.jsx("input",{type:"number",value:s.pause_duration,onChange:d,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:"设置后会暂停处理该账号的订单,到时间后自动恢复"}),s.pause_duration>0&&!t.paused&&s.pause_duration===(t.pause_duration||0)&&e.jsx("button",{type:"button",disabled:l,onClick:B,className:"mt-3 px-4 py-2 rounded-xl bg-amber-50 text-amber-700 hover:bg-amber-100 text-sm font-bold disabled:opacity-50",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(hr,{className:"w-5 h-5 text-blue-500"}),"登录信息"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl bg-blue-50 p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"保存登录信息"}),e.jsx("div",{className:"mt-1 text-xs text-gray-500",children:"状态直接读取并修改闲鱼官方长登录设置"}),h.error&&e.jsx("div",{className:"mt-1 text-xs text-red-600",children:h.error})]}),e.jsx("button",{type:"button","aria-label":"保存登录信息",disabled:h.loading||h.saving||!h.canOpen,onClick:Z,className:`relative h-8 w-14 flex-shrink-0 rounded-full transition-colors ${h.enabled?"bg-brand":"bg-gray-300"} disabled:cursor-not-allowed disabled:opacity-50`,children:e.jsx("span",{className:`absolute left-1 top-1 h-6 w-6 rounded-full bg-white shadow-md transition-transform ${h.enabled?"translate-x-6":"translate-x-0"}`})})]}),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:s.username,onChange:M,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:s.showLoginPassword?"text":"password",value:s.login_password,onChange:b,placeholder:"用于自动登录",className:"w-full ios-input px-4 py-3 rounded-xl pr-12"}),e.jsx("button",{type:"button",onClick:k,className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:s.showLoginPassword?e.jsx(bt,{className:"w-5 h-5"}):e.jsx(mt,{className:"w-5 h-5"})})]}),e.jsxs("label",{className:"mt-3 flex items-center gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.clear_password,onChange:D,className:"w-4 h-4 accent-brand"}),e.jsx("span",{className:"text-sm font-bold text-gray-700",children:"清空已保存密码"})]})]}),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,className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${s.show_browser?"bg-brand":"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 ${s.show_browser?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{className:"rounded-xl border border-blue-100 bg-blue-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-blue-950",children:"立即执行账号密码登录"}),e.jsx("div",{className:"text-xs text-blue-700 mt-1",children:"需要在上方重新输入本次登录密码;成功后后端会更新 Cookie 和保存的登录信息。"})]}),N.status==="processing"||N.status==="verification_required"?e.jsx("button",{type:"button",onClick:W,className:"px-4 py-2 rounded-xl bg-white text-red-600 font-bold text-sm border border-red-100",children:"取消登录"}):e.jsx("button",{type:"button",onClick:V,className:"px-4 py-2 rounded-xl bg-blue-600 text-white font-bold text-sm whitespace-nowrap",children:"密码登录刷新授权"})]}),N.message&&e.jsx("div",{className:`text-sm font-medium ${N.status==="failed"?"text-red-700":N.status==="success"?"text-green-700":"text-blue-800"}`,children:N.message}),N.status==="verification_required"&&e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50 p-3 text-amber-900",children:[e.jsx("div",{className:"font-extrabold",children:"账号已触发平台风控,需要完成人脸识别"}),e.jsx("div",{className:"text-xs mt-1 leading-5",children:"请在闲鱼 App 或已打开的登录浏览器中按提示完成验证。本页面不会提供可直接打开的风控链接。"}),N.qrCodeUrl&&e.jsx("div",{className:"mt-3 aspect-square w-48 overflow-hidden rounded-xl border bg-white",children:e.jsx(Qa,{src:N.qrCodeUrl,alt:"密码登录风控二维码",className:"p-2"})})]})]})]})]}),(_.length>0||w||P)&&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(Rt,{className:"w-5 h-5 text-blue-500"}),"通知渠道绑定"]}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"勾选后,该账号的 token 失效、自动恢复失败、风控验证等事件会推送到这些渠道"}),w&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(_e,{className:"w-4 h-4 animate-spin"}),"正在加载通知绑定"]}),P&&!w&&e.jsxs("div",{className:"mb-3 rounded-xl bg-amber-50 p-3 text-sm text-amber-800 flex items-center justify-between gap-3",children:[e.jsx("span",{children:P}),e.jsx("button",{type:"button",className:"font-bold whitespace-nowrap",onClick:v,children:"重试"})]}),e.jsx("div",{className:"space-y-2",children:_.map(be)})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:f,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:l,children:"取消"}),e.jsxs("button",{onClick:y,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:l,children:[l?e.jsx(_e,{className:"w-4 h-4 animate-spin"}):e.jsx(Ye,{className:"w-4 h-4"}),l?"保存中...":"保存"]})]})})]})}),document.body)},Rn=(t,s)=>{if(!t||!s)return!1;const a=Date.parse(t),l=Date.parse(s);return Number.isFinite(a)&&Number.isFinite(l)&&lt.map(a=>{const l=s[a.id];return!l||Rn(a.runtime_updated_at,l.updated_at)?a:{...a,runtime_state:l.state,runtime_message:l.message||"",runtime_connected:l.connected,runtime_updated_at:l.updated_at}}),In=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"}}},On=(t,s)=>t.map(a=>{var l,n,c,u,h;return{...a,ai_enabled:((l=s[a.id])==null?void 0:l.ai_enabled)??!1,max_discount_percent:((n=s[a.id])==null?void 0:n.max_discount_percent)??10,max_discount_amount:((c=s[a.id])==null?void 0:c.max_discount_amount)??100,max_bargain_rounds:((u=s[a.id])==null?void 0:u.max_bargain_rounds)??3,custom_prompts:((h=s[a.id])==null?void 0:h.custom_prompts)??""}}),Pn=()=>{const[t,s]=r.useState([]),[a,l]=r.useState(!0),n=r.useRef(0),c=r.useRef(null),u=r.useCallback(async()=>{var N;const h=++n.current;(N=c.current)==null||N.abort();const m=new AbortController;c.current=m,l(!0);try{const x={signal:m.signal},[p,_]=await Promise.allSettled([Ft(x),_l(x)]);if(h!==n.current)return;if(p.status==="rejected")throw p.reason;const S=_.status==="fulfilled"?_.value:{};_.status==="rejected"&&console.error("加载 AI 设置失败:",_.reason),s(On(p.value,S))}catch(x){h===n.current&&!m.signal.aborted&&console.error("加载账号失败:",x)}finally{h===n.current&&l(!1)}},[]);return r.useEffect(()=>{let h=!1,m=null;const N=new AbortController,x=async()=>{try{const _=await Ss({signal:N.signal,timeoutMs:1e4});h||s(S=>An(S,_))}catch(_){h||console.error("加载账号运行状态失败:",_)}finally{h||(m=window.setTimeout(()=>void x(),2e3))}};return u().finally(()=>{h||x()}),()=>{var _;h=!0,N.abort(),n.current+=1,(_=c.current)==null||_.abort(),m!==null&&window.clearTimeout(m)}},[u]),{accounts:t,setAccounts:s,loading:a,loadAccounts:u}},Tn=(t,s)=>t!==(s.pause_duration||0),En=(t,s)=>{const a=s.username!==(t.username||""),l=s.show_browser!==(t.show_browser||!1),n=s.login_password!=="",c=s.clear_password===!0;if(!a&&!l&&!n&&!c)return null;const u={username:s.username,show_browser:s.show_browser};return c?u.clear_password=!0:n&&(u.login_password=s.login_password),u},dt=(t,s,a,l)=>t===s&&a===l,Dn=t=>t.status==="success"?{sessionId:"",status:"success",message:t.message||"账号密码登录成功,授权信息已更新",qrCodeUrl:""}:t.status==="processing"||t.status==="verification_required"?{sessionId:"",status:t.status,message:t.message||(t.status==="verification_required"?"账号触发风控,需要完成人脸识别":"登录处理中"),qrCodeUrl:t.qr_code_url||""}:{sessionId:"",status:"failed",message:t.error||t.message||"密码登录失败,请检查账号信息后重试",qrCodeUrl:""},$n=(t,s)=>t&&s,Mn=({editingAccount:t,setEditingAccount:s,setActiveModal:a,editForm:l,setEditForm:n,loadAccounts:c})=>{const[u,h]=r.useState({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:""}),[m,N]=r.useState([]),[x,p]=r.useState([]),[_,S]=r.useState(!1),[q,w]=r.useState(!1),[P,A]=r.useState(!1),[G,H]=r.useState(""),[X,f]=r.useState({ai_enabled:!1,max_discount_percent:10,max_discount_amount:100,max_bargain_rounds:3,custom_prompts:""}),[y,z]=r.useState(!1),[O,F]=r.useState({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),d=r.useRef(0),B=r.useRef(null),Z=r.useRef(0),M=r.useRef(null),b=r.useRef(0),k=r.useRef(null),D=r.useRef(0),C=r.useRef(""),W=r.useRef(null),V=r.useRef(null),v=r.useCallback(()=>{V.current!==null&&(window.clearTimeout(V.current),V.current=null)},[]),ee=r.useCallback(async T=>{var de;const g=++d.current;(de=B.current)==null||de.abort();const le=new AbortController;B.current=le,w(!0),S(!1),A(!1),H("");const[oe,ne]=await Promise.allSettled([Va({signal:le.signal}),un(T,{signal:le.signal})]);dt(g,d.current,T,T)&&(oe.status==="fulfilled"?N(oe.value.data||[]):(N([]),H("通知渠道列表加载失败,请重试")),ne.status==="fulfilled"?(p(ne.value||[]),S(!0)):(p([]),H("通知绑定加载失败;本次保存不会修改现有绑定")),w(!1))},[]),be=r.useCallback(T=>{p(g=>g.includes(T)?g.filter(le=>le!==T):[...g,T]),A(!0)},[]),U=r.useCallback(async T=>{var ne,de;const g=++Z.current;(ne=M.current)==null||ne.abort();const le=new AbortController;M.current=le,D.current+=1,C.current=T.id,(de=W.current)==null||de.abort(),v(),F({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),s(T),n({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,clear_password:!1}),a("edit"),h({loading:!0,saving:!1,canOpen:!1,enabled:!1,error:""});const[,oe]=await Promise.allSettled([ee(T.id),bl(T.id,{signal:le.signal})]);g===Z.current&&(oe.status==="fulfilled"?h({loading:!1,saving:!1,canOpen:oe.value.can_open_long_login,enabled:oe.value.enabled,error:""}):h({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:"无法读取闲鱼保存登录信息状态"}))},[v,ee,a,n,s]),ae=r.useCallback(async()=>{if(!t||u.loading||u.saving||!u.canOpen)return;const T=!u.enabled;h(g=>({...g,saving:!0,error:""}));try{const g=await fl(t.id,T);h({loading:!1,saving:!1,canOpen:g.can_open_long_login,enabled:g.enabled,error:""})}catch(g){h(le=>({...le,saving:!1,error:g instanceof Error?g.message:"保存登录信息设置失败"}))}},[t,u]),ge=r.useCallback(async T=>{var oe;const g=++b.current;(oe=k.current)==null||oe.abort();const le=new AbortController;k.current=le,s(T),a("ai-settings"),z(!0);try{const ne=await nn(T.id,{signal:le.signal});if(!dt(g,b.current,T.id,T.id))return;f({ai_enabled:ne.ai_enabled??!1,max_discount_percent:ne.max_discount_percent??10,max_discount_amount:ne.max_discount_amount??100,max_bargain_rounds:ne.max_bargain_rounds??3,custom_prompts:ne.custom_prompts??""})}catch(ne){dt(g,b.current,T.id,T.id)&&console.error("加载 AI 设置失败:",ne)}finally{dt(g,b.current,T.id,T.id)&&z(!1)}},[a,s]),$=r.useCallback(async()=>{if(!(!t||y)){z(!0);try{await on(t.id,X),a(null),await c()}catch(T){console.error("更新 AI 设置失败:",T)}finally{z(!1)}}},[X,t,c,y,a]),L=r.useCallback(async()=>{if(!(!t||y)){z(!0);try{const T={};l.remark!==(t.remark||t.note||"")&&(T.remark=l.remark),l.cookie&&l.cookie!==(t.cookie||t.value||"")&&(T.cookie=l.cookie),l.auto_confirm!==t.auto_confirm&&(T.auto_confirm=l.auto_confirm),Tn(l.pause_duration,t)&&(T.pause_duration=l.pause_duration);const g=En(t,l);g&&Object.assign(T,g),$n(_,P)&&(T.channel_ids=x),Object.keys(T).length>0&&await gl(t.id,T),a(null),await c()}catch(T){console.error("更新账号失败:",T)}finally{z(!1)}}},[P,_,l,t,c,x,y,a]),Q=r.useCallback(async()=>{if(!(!t||l.pause_duration<=0||y)){z(!0);try{const T=await hl(t.id,l.pause_duration);s(g=>g&&{...g,pause_duration:l.pause_duration,paused:(T==null?void 0:T.paused)===!0,paused_until:Number((T==null?void 0:T.paused_until)||0)}),await c()}catch(T){console.error("重新暂停失败:",T)}finally{z(!1)}}},[l.pause_duration,t,c,y,s]),Y=r.useCallback(async(T,g,le)=>{var ne;(ne=W.current)==null||ne.abort();const oe=new AbortController;W.current=oe;try{const de=await jl(T,oe.signal);if(!dt(g,D.current,le,C.current))return;const Se={...Dn(de),sessionId:T};if(de.status==="success"){v(),F(Se),n(Ee=>({...Ee,login_password:"",showLoginPassword:!1})),await c();return}if(de.status==="processing"||de.status==="verification_required"){F(Se),v(),V.current=window.setTimeout(()=>void Y(T,g,le),1500);return}v(),F(Se)}catch(de){if(!dt(g,D.current,le,C.current))return;v(),F({sessionId:T,status:"failed",message:de instanceof Error?de.message:"查询密码登录状态失败",qrCodeUrl:""})}},[v,c,n]),re=r.useCallback(async()=>{var oe;if(!t)return;const T=l.username.trim();if(!T||!l.login_password)return;v(),(oe=W.current)==null||oe.abort();const g=++D.current;C.current=t.id;const le=new AbortController;W.current=le,F({sessionId:"",status:"processing",message:"正在启动密码登录…",qrCodeUrl:""});try{const ne=await yl({account_id:t.id,account:T,password:l.login_password,show_browser:l.show_browser},{signal:le.signal});if(!dt(g,D.current,t.id,C.current))return;if(!ne.success||!ne.session_id)throw new Error(ne.message||"无法启动密码登录");F({sessionId:ne.session_id,status:"processing",message:ne.message||"登录处理中",qrCodeUrl:""}),await Y(ne.session_id,g,t.id)}catch(ne){if(!dt(g,D.current,t.id,C.current))return;F({sessionId:"",status:"failed",message:ne instanceof Error?ne.message:"启动密码登录失败",qrCodeUrl:""})}},[v,l.login_password,l.show_browser,l.username,t,Y]),ue=r.useCallback(async()=>{var g;const T=O.sessionId;D.current+=1,C.current="",(g=W.current)==null||g.abort(),v(),T&&await Nl(T).catch(()=>{}),F({sessionId:"",status:"idle",message:"",qrCodeUrl:""})},[v,O.sessionId]),je=r.useCallback(async()=>{var T,g,le;(T=B.current)==null||T.abort(),Z.current+=1,(g=M.current)==null||g.abort(),(le=k.current)==null||le.abort(),(O.status==="processing"||O.status==="verification_required")&&await ue(),a(null)},[ue,O.status,a]),R=r.useCallback(()=>{var T;b.current+=1,(T=k.current)==null||T.abort(),a(null)},[a]);return r.useEffect(()=>()=>{var T,g,le,oe;(T=B.current)==null||T.abort(),(g=M.current)==null||g.abort(),(le=k.current)==null||le.abort(),(oe=W.current)==null||oe.abort(),v()},[v]),{longLogin:u,notifChannels:m,selectedChannelIds:x,bindingsLoaded:_,bindingsLoading:q,bindingsDirty:P,bindingsLoadError:G,aiSettings:X,saving:y,passwordLoginView:O,setAiSettings:f,setBindingsDirty:A,setEditForm:n,openEditModal:U,closeEditModal:je,openAIModal:ge,closeAIModal:R,loadNotificationBindings:ee,toggleNotificationChannel:be,handleLongLoginToggle:ae,handleSaveAISettings:$,handleSaveEdit:L,handleRestartPause:Q,handlePasswordLogin:re,handleCancelPasswordLogin:ue}},qn=()=>{const{accounts:t,setAccounts:s,loading:a,loadAccounts:l}=Pn(),[n,c]=r.useState(""),[u,h]=r.useState(""),[m,N]=r.useState(""),[x,p]=r.useState(null),[_,S]=r.useState(""),[q,w]=r.useState(!1),[P,A]=r.useState(""),[G,H]=r.useState("pending"),[X,f]=r.useState(""),[y,z]=r.useState(""),[O,F]=r.useState(""),[d,B]=r.useState(null),[Z,M]=r.useState(null),[b,k]=r.useState(null),[D,C]=r.useState(null),[W,V]=r.useState({remark:"",cookie:"",auto_confirm:!1,pause_duration:0,username:"",login_password:"",show_browser:!1,showLoginPassword:!1,clear_password:!1}),v=Mn({editingAccount:b,setEditingAccount:k,setActiveModal:M,editForm:W,setEditForm:V,loadAccounts:l}),{longLogin:ee,notifChannels:be,selectedChannelIds:U,bindingsLoaded:ae,bindingsLoading:ge,bindingsLoadError:$,aiSettings:L,saving:Q,passwordLoginView:Y,setAiSettings:re,setBindingsDirty:ue,openEditModal:je,closeEditModal:R,openAIModal:T,closeAIModal:g,loadNotificationBindings:le,toggleNotificationChannel:oe,handleLongLoginToggle:ne,handleSaveAISettings:de,handleSaveEdit:Se,handleRestartPause:Ee,handlePasswordLogin:Te,handleCancelPasswordLogin:Ue}=v,Me=r.useRef(null),Be=r.useRef(null),Je=r.useRef(null),He=r.useRef(null);Me.current===null&&(Me.current=wn()),Be.current===null&&(Be.current=_n());const we=()=>{He.current!==null&&(window.clearTimeout(He.current),He.current=null)},pe=()=>{var j;(j=Me.current)==null||j.stop()},Ve=()=>{var j,E;(j=Je.current)==null||j.abort(),(E=Be.current)==null||E.cancel(),pe(),we(),w(!1)},it=()=>{we(),He.current=window.setTimeout(()=>{He.current=null,w(!1),l()},1e3)};r.useEffect(()=>()=>{var j,E;pe(),(j=Be.current)==null||j.cancel(),(E=Je.current)==null||E.abort(),we()},[]);const tt=async(j,E)=>{await ul(j,!E),l()},Qe=j=>{m||(S(""),p(j))},Ge=()=>{m||(S(""),p(null))},ot=async()=>{const j=x;if(!(!j||m)){N(j.id),S("");try{await pl(j.id),s(E=>E.filter(se=>se.id!==j.id)),p(null)}catch(E){console.error("删除账号失败:",E),S((E==null?void 0:E.message)||"删除账号失败,请稍后重试")}finally{N("")}}},pt=async j=>{h(j.id);try{const E=await vl(j.id);E!=null&&E.profile_error&&alert("资料刷新失败:"+E.profile_error),await l()}catch(E){console.error("刷新账号资料失败:",E),alert((E==null?void 0:E.message)||"刷新账号资料失败,请先重新授权该账号")}finally{h("")}},ht=async(j,E)=>{const se=await ml(j,E==null?void 0:E.id);if(!se.success||!se.account_id)throw new Error(se.message||"保存扫码授权失败");return se.account_id},J=async j=>{var fe,De,ve,Pe;pe(),(fe=Je.current)==null||fe.abort();const E=new AbortController;Je.current=E;const se=Be.current.next();we();const ce=j||null;B(ce),w(!0),H("loading"),f(""),A(""),z(""),F("");try{const me=await dl({signal:E.signal});if(!((De=Be.current)!=null&&De.isCurrent(se)))return;if(!me.success||!me.qr_code_url||!me.session_id)throw new Error(me.message||"闲鱼未返回可用的登录二维码");if(me.success&&me.qr_code_url&&me.session_id){const o=me.session_id;A(me.qr_code_url),H("waiting"),(ve=Me.current)==null||ve.start(o,xl,{onSuccess:async()=>{try{if(!await ht(o,ce)){H("error");return}}catch(K){console.error("保存扫码授权失败",K),H("error");return}H("success"),it()},onScanned:()=>{H("waiting")},onTerminalError:()=>{H("error")},onPollError:K=>{console.error("轮询扫码状态失败",K),H("error")},onVerificationRequired:K=>{H("verification"),K.face_qr_url&&F(K.face_qr_url),K.verification_screenshot&&z(K.verification_screenshot)}})}}catch(me){if(!((Pe=Be.current)!=null&&Pe.isCurrent(se)))return;f(me instanceof Error?me.message:"二维码获取失败,请稍后重试"),H("error")}finally{Je.current===E&&(Je.current=null)}};if(a)return e.jsx("div",{className:"p-20 flex justify-center",children:e.jsx(_e,{className:"w-8 h-8 text-brand animate-spin"})});const ie=t.filter(j=>{const E=n.trim().toLowerCase();return E?[j.id,j.nickname,j.remark,j.note,j.username,j.runtime_message].some(se=>(se||"").toLowerCase().includes(E)):!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:n,onChange:j=>c(j.target.value),placeholder:"搜索昵称 / 备注 / 账号ID",className:"ios-input px-4 py-3 rounded-2xl text-sm w-full sm:w-72"}),e.jsxs("button",{onClick:()=>J(),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(rs,{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:["当前显示 ",ie.length," / ",t.length," 个账号"]}),e.jsx("div",{className:"text-blue-700",children:"如果某个账号只显示 ID,点该账号右侧“刷新资料”;若刷新失败,先点二维码重新授权。"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6",children:[ie.map(j=>{const E=In(j),se=j.runtime_state==="auth_expired"||j.runtime_state==="verification_required";return e.jsx("div",{className:"ios-card rounded-xl p-6 group transition-all duration-300 hover:border-brand",children:e.jsxs("div",{className:"flex min-w-0 items-start gap-5 sm:gap-8",children:[e.jsxs("div",{className:"relative",children:[j.avatar_url?e.jsx("img",{src:j.avatar_url,alt:j.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(yt,{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 ${E.dot}`,children:j.runtime_state==="online"&&e.jsx(Ye,{className:"w-3 h-3 text-white"})})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 mb-1",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900 break-words",children:j.nickname||j.remark||`账号 ${j.id.substring(0,6)}...`}),e.jsx("span",{className:`px-2.5 py-0.5 rounded-lg text-xs font-bold ${E.badge}`,children:E.label}),j.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(wt,{className:"w-3 h-3"})," AI"]}),j.auto_rate_enabled&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-emerald-100 px-2.5 py-0.5 text-xs font-bold text-emerald-700",children:[e.jsx($t,{className:"h-3 w-3"})," 自动评价"]}),j.auto_polish_enabled&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-amber-100 px-2.5 py-0.5 text-xs font-bold text-amber-700",children:[e.jsx(Ds,{className:"h-3 w-3"})," 每日擦亮"]}),j.auto_confirm&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-blue-50 px-2.5 py-0.5 text-xs font-bold text-blue-700",children:[e.jsx(Ye,{className:"h-3 w-3"})," 自动确认发货"]}),j.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:j.profile_error,children:[e.jsx(ut,{className:"w-3 h-3"})," 资料未同步"]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"text-sm font-medium text-gray-500",children:[e.jsx("p",{children:j.remark||j.note||"暂无备注"}),e.jsxs("p",{className:"font-mono text-xs text-gray-400",children:["ID: ",j.id]})]}),j.runtime_message&&j.runtime_state!=="online"&&j.runtime_state!=="disabled"&&e.jsxs("div",{className:`mb-3 flex flex-wrap items-center gap-2 text-sm font-medium ${se?"text-red-700":"text-amber-700"}`,children:[e.jsx(ut,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{children:j.runtime_message}),se&&e.jsxs("button",{type:"button",onClick:()=>J(j),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(rs,{className:"w-3.5 h-3.5"})," 重新授权"]})]}),j.paused&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-lg bg-blue-50 px-3 py-1.5 text-xs font-bold text-blue-700",children:[e.jsx(La,{className:"h-3 w-3"})," 暂停处理中"]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>pt(j),disabled:u===j.id,className:"p-3 rounded-xl transition-colors text-gray-600 hover:bg-gray-100 disabled:opacity-50",title:"刷新昵称和头像",children:e.jsx(We,{className:`w-5 h-5 ${u===j.id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>J(j),className:`p-3 rounded-xl transition-colors ${se?"text-red-600 bg-red-50 hover:bg-red-100":"text-blue-600 hover:bg-blue-50"}`,title:"重新扫码授权当前账号",children:e.jsx(rs,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>je(j),className:"p-3 rounded-xl hover:bg-gray-100 transition-colors text-gray-600",title:"编辑账号",children:e.jsx(Ra,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>T(j),className:"p-3 rounded-xl hover:bg-purple-100 transition-colors text-purple-600",title:"AI设置",children:e.jsx(wt,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>C(j),className:"p-3 rounded-xl hover:bg-amber-100 transition-colors text-amber-600",title:"自动评价与每日擦亮",children:e.jsx(Sa,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>tt(j.id,j.enabled),className:`p-3 rounded-xl transition-colors ${j.enabled?"text-green-600 hover:bg-green-50":"text-gray-400 hover:bg-gray-100"}`,title:j.enabled?"停用账号":"启用账号",children:e.jsx(gr,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>Qe(j),disabled:m!=="",className:"p-3 rounded-xl hover:bg-red-100 transition-colors text-red-500 disabled:cursor-not-allowed disabled:opacity-40",title:m===j.id?"删除中…":`删除账号 ${j.nickname||j.remark||j.id}`,children:m===j.id?e.jsx(_e,{className:"w-5 h-5 animate-spin"}):e.jsx(Ze,{className:"w-5 h-5"})})]})]})]})]})},j.id)}),t.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(yt,{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:"请点击右上角扫码添加您的闲鱼账号"})]}),t.length>0&&ie.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。"})]})]}),D&&Oe.createPortal(e.jsx(Sn,{account:D,onClose:()=>C(null),onSaved:j=>{s(E=>E.map(se=>se.id===D.id?{...se,auto_rate_enabled:j.auto_rate_enabled,rate_content:j.rate_content,auto_polish_enabled:j.auto_polish_enabled,polish_time:j.polish_time,last_rate_scan_at:j.last_rate_scan_at,last_polish_date:j.last_polish_date,last_polish_at:j.last_polish_at}:se))}}),document.body),x&&Oe.createPortal(e.jsx("div",{className:"modal-overlay-centered",role:"presentation",children:e.jsxs("div",{className:"h-fit w-full max-w-[400px] self-center overflow-hidden rounded-2xl border border-white/80 bg-white shadow-modal",role:"dialog","aria-modal":"true","aria-labelledby":"delete-account-title","aria-describedby":"delete-account-description",children:[e.jsxs("div",{className:"relative overflow-hidden border-b border-red-100 bg-gradient-to-br from-red-50 via-white to-orange-50 px-5 py-5",children:[e.jsx("div",{className:"absolute -right-12 -top-16 h-36 w-36 rounded-full bg-red-200/35 blur-2xl"}),e.jsxs("div",{className:"relative flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl bg-red-600 text-white shadow-md shadow-red-200",children:e.jsx(Ze,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{id:"delete-account-title",className:"text-lg font-extrabold tracking-tight text-gray-950",children:"删除这个账号?"}),e.jsx("p",{id:"delete-account-description",className:"mt-1 text-xs leading-5 text-gray-600",children:"删除后,该账号的关联配置也会一并清理,此操作无法撤销。"})]}),e.jsx("button",{type:"button",onClick:Ge,disabled:m!=="",className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-white hover:text-gray-700 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"关闭删除确认",children:e.jsx(ke,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"rounded-xl border border-gray-100 bg-gray-50/80 px-4 py-3",children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:x.nickname||x.remark||"未命名账号"}),x.remark&&x.nickname&&e.jsxs("div",{className:"mt-1 text-sm text-gray-500",children:["备注:",x.remark]}),e.jsxs("div",{className:"mt-1.5 break-all font-mono text-[11px] text-gray-400",children:["ID: ",x.id]})]}),m===x.id&&e.jsxs("div",{className:"mt-4 flex items-center gap-3 rounded-xl border border-blue-100 bg-blue-50 px-4 py-3",role:"progressbar","aria-label":"正在删除账号",children:[e.jsx(_e,{className:"h-5 w-5 flex-shrink-0 animate-spin text-brand"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-blue-950",children:"正在删除账号"}),e.jsx("div",{className:"mt-0.5 text-xs text-blue-700",children:"正在清理关联数据,请保持页面打开…"})]})]}),_&&e.jsxs("div",{className:"mt-4 flex items-start gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3",role:"alert",children:[e.jsx(ut,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-red-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-red-800",children:"删除失败"}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-red-700",children:_})]})]})]}),e.jsxs("div",{className:"flex gap-3 border-t border-gray-100 bg-gray-50/70 px-5 py-4",children:[e.jsx("button",{type:"button",onClick:Ge,disabled:m!=="",className:"flex-1 rounded-xl bg-white px-5 py-3 text-sm font-extrabold text-gray-700 ring-1 ring-gray-200 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",children:"取消"}),e.jsx("button",{type:"button",onClick:()=>void ot(),disabled:m!=="",className:"flex flex-1 items-center justify-center gap-2 rounded-xl bg-red-600 px-5 py-3 text-sm font-extrabold text-white shadow-lg shadow-red-200 transition-colors hover:bg-red-700 disabled:cursor-not-allowed disabled:bg-red-400",children:m===x.id?e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"h-4 w-4 animate-spin"}),"处理中"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ze,{className:"h-4 w-4"}),"确认删除"]})})]})]})}),document.body),q&&Oe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container relative",style:{maxWidth:"26rem"},children:[e.jsx("button",{onClick:Ve,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(ke,{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:d?"重新授权账号":"扫码添加账号"}),e.jsx("p",{className:"text-gray-500 mb-8 font-medium",children:d?`请用闲鱼APP扫码,为「${d.nickname||d.remark||d.id}」刷新授权`:"请打开闲鱼APP扫描下方二维码"}),e.jsxs("div",{className:`w-full bg-surface-subtle rounded-xl mx-auto flex items-center justify-center overflow-hidden border-4 border-white shadow-inner mb-6 relative ${G==="verification"?"max-w-72 min-h-64 h-auto p-2":"max-w-64 aspect-square"}`,children:[G==="loading"&&e.jsx(_e,{className:"w-10 h-10 text-brand animate-spin"}),G==="waiting"&&e.jsx(Qa,{src:P,alt:"闲鱼登录二维码",className:"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(Ye,{className:"w-8 h-8"})}),e.jsx("span",{className:"font-bold text-lg",children:"登录成功"})]}),G==="error"&&e.jsxs("div",{className:"px-5 text-center",children:[e.jsx("span",{className:"block text-red-600 font-bold",children:"二维码获取失败"}),e.jsx("span",{className:"mt-2 block text-xs leading-5 text-gray-500",children:X||"请关闭窗口后重新发起扫码登录。"})]}),G==="verification"&&e.jsx(kn,{faceQrUrl:O,verificationScreenshot:y})]}),G!=="verification"&&e.jsx("p",{className:"text-xs text-gray-400 font-medium bg-gray-50 py-2 rounded-xl",children:"二维码有效期为5分钟,请尽快扫码。"})]})})]})}),document.body),Z==="edit"&&b&&e.jsx(Ln,{account:b,editForm:W,setEditForm:V,saving:Q,onClose:R,onSave:Se,onRestartPause:Ee,longLogin:ee,onToggleLongLogin:ne,passwordLoginView:Y,onPasswordLogin:Te,onCancelPasswordLogin:Ue,notifChannels:be,selectedChannelIds:U,bindingsLoaded:ae,bindingsLoading:ge,bindingsLoadError:$,onRetryBindings:()=>le(b.id),onToggleChannel:oe,onSettingsDirty:()=>ue(!0)}),Z==="ai-settings"&&b&&Oe.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(wt,{className:"w-6 h-6 text-purple-500"}),"AI助手设置"]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:b.nickname||b.remark||b.id})]}),e.jsx("button",{onClick:g,className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(ke,{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(wt,{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:()=>re({...L,ai_enabled:!L.ai_enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${L.ai_enabled?"bg-brand":"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 ${L.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:L.max_discount_percent,onChange:j=>re({...L,max_discount_percent:parseInt(j.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%;设为 0 表示不允许降价"})]}),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:L.max_discount_amount,onChange:j=>re({...L,max_discount_amount:parseInt(j.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 元;设为 0 表示不允许降价"})]}),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:L.max_bargain_rounds,onChange:j=>re({...L,max_bargain_rounds:parseInt(j.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:L.custom_prompts,onChange:j=>re({...L,custom_prompts:j.target.value}),placeholder:`输入自定义的AI回复规则或风格指引... +import{j as e,r,c as Is,b as Oe,d as ir}from"./react-vendor-C_od1ZSF.js";import{L as or,U as Na,M as ys,C as Os,B as va,S as _a,Z as js,a as Rt,b as Ps,G as Bs,c as Ts,d as Es,e as cr,f as wa,g as ut,A as Fs,D as dr,P as ka,h as Bt,E as Ca,T as xr,i as mr,j as _e,X as ke,k as ur,l as pr,m as Ds,n as Sa,o as lt,p as Ye,q as La,K as hr,r as bt,s as mt,Q as rs,t as yt,u as wt,v as $t,R as We,w as Ra,x as gr,y as Ze,z as St,F as Mt,H as nt,I as zs,J as kt,N as br,O as fr,V as yr,W as Aa,Y as Ia,_ as Oa,$ as jr,a0 as Nr,a1 as ls,a2 as Wt,a3 as Ns,a4 as vr,a5 as _r,a6 as vs,a7 as Us,a8 as wr,a9 as kr,aa as qt,ab as Ws,ac as Zt,ad as Pa,ae as Cr,af as Sr,ag as ss,ah as Ta,ai as Lr,aj as Rr,ak as Ar,al as Ir,am as Or,an as Pr,ao as Js}from"./icons-vendor-i_74xDZy.js";import{R as Yt,B as Tr,X as Gs,Y as Vs,T as Xt,a as Er,C as _s,A as Dr,b as $r,c as Mr,P as Qs,d as Ks,L as qr}from"./charts-vendor-BxxJOyEX.js";import"./vendor-D-Edl3pr.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))l(n);new MutationObserver(n=>{for(const c of n)if(c.type==="childList")for(const u of c.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&l(u)}).observe(document,{childList:!0,subtree:!0});function a(n){const c={};return n.integrity&&(c.integrity=n.integrity),n.referrerPolicy&&(c.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?c.credentials="include":n.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function l(n){if(n.ep)return;n.ep=!0;const c=a(n);fetch(n.href,c)}})();const Br=({className:t="w-full h-full text-white"})=>e.jsx("svg",{className:t,viewBox:"0 0 256 256","aria-hidden":"true",children:e.jsx("g",{stroke:"none",fill:"none",fillRule:"evenodd",children:e.jsx("path",{d:"M121.73,57.0003 C138.901,57.0003 154.897,65.5053 164.52,79.7493 C166.029,81.9823 165.441,85.0143 163.209,86.5233 C160.976,88.0323 157.944,87.4433 156.436,85.2113 C148.629,73.6553 135.655,66.7563 121.73,66.7563 C104.076789,66.7563 88.6201962,77.6596007 82.5581814,93.8184545 C83.9120803,93.7133631 85.2800264,93.66 86.6602,93.66 C111.537727,93.66 132.442611,110.997575 137.926382,134.224255 L162.5425,92.109 L162.615557,91.9879406 L162.756884,91.77367 L162.911804,91.5639102 L162.98657,91.4716759 C163.351845,91.025169 163.786059,90.6571744 164.264191,90.3738733 L164.550153,90.2178351 L164.729252,90.1315693 L164.989203,90.021723 L165.230265,89.9354653 L165.542393,89.8445739 C165.666021,89.8126706 165.790834,89.7857324 165.916565,89.7637431 L166.116517,89.7342499 C166.29505,89.7098142 166.475001,89.6957386 166.655596,89.6918808 L166.7539,89.693 C196.8909,89.693 221.4079,114.21 221.4079,144.347 C221.4079,174.482 196.8909,199 166.7539,199 L125.0869,199 C122.3919,199 120.2079,196.815 120.2079,194.122 C120.2079,191.429 122.3919,189.244 125.0869,189.244 L166.7539,189.244 C191.5109,189.244 211.6519,169.104 211.6519,144.347 C211.6519,120.513406 192.985349,100.957891 169.504046,99.5322548 L112.7745,196.584 C111.8995,198.08 110.2965,199 108.5635,199 L86.6602,199 C57.6182,199 33.9902,175.373 33.9902,146.33 C33.9902,122.475163 49.9316132,102.273061 71.7206298,95.817503 L71.9446339,94.967678 C78.0600632,72.5405324 98.33054,57.0003 121.73,57.0003 Z M86.6602,103.417 C62.9972,103.417 43.7462,122.667 43.7462,146.33 C43.7462,169.992 62.9972,189.244 86.6602,189.244 L105.7645,189.244 L129.869462,148.004782 C129.678439,147.482425 129.5742,146.918336 129.5742,146.33 C129.5742,122.667 110.3232,103.417 86.6602,103.417 Z",fill:"currentColor"})})}),ws=({sizeClass:t="w-12 h-12",logoClassName:s="w-full h-full text-white"})=>e.jsxs("div",{className:"relative z-10 flex items-center justify-center",children:[e.jsx("div",{className:"absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25"}),e.jsxs("div",{className:`relative ${t} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`,children:[e.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 120 120","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"login-squircle-gradient",x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"rgb(var(--color-brand))"}),e.jsx("stop",{offset:"100%",stopColor:"rgb(var(--color-brand-light))"})]})}),e.jsx("path",{d:"M 114.00 60.00 L 113.83 71.48 L 113.31 78.16 L 112.44 83.67 L 111.22 88.46 L 109.66 92.71 L 107.75 96.49 L 105.48 99.87 L 102.86 102.86 L 99.87 105.48 L 96.49 107.75 L 92.71 109.66 L 88.46 111.22 L 83.67 112.44 L 78.16 113.31 L 71.48 113.83 L 60.00 114.00 L 48.52 113.83 L 41.84 113.31 L 36.33 112.44 L 31.54 111.22 L 27.29 109.66 L 23.51 107.75 L 20.13 105.48 L 17.14 102.86 L 14.52 99.87 L 12.25 96.49 L 10.34 92.71 L 8.78 88.46 L 7.56 83.67 L 6.69 78.16 L 6.17 71.48 L 6.00 60.00 L 6.17 48.52 L 6.69 41.84 L 7.56 36.33 L 8.78 31.54 L 10.34 27.29 L 12.25 23.51 L 14.52 20.13 L 17.14 17.14 L 20.13 14.52 L 23.51 12.25 L 27.29 10.34 L 31.54 8.78 L 36.33 7.56 L 41.84 6.69 L 48.52 6.17 L 60.00 6.00 L 71.48 6.17 L 78.16 6.69 L 83.67 7.56 L 88.46 8.78 L 92.71 10.34 L 96.49 12.25 L 99.87 14.52 L 102.86 17.14 L 105.48 20.13 L 107.75 23.51 L 109.66 27.29 L 111.22 31.54 L 112.44 36.33 L 113.31 41.84 L 113.83 48.52 Z",fill:"url(#login-squircle-gradient)"})]}),e.jsx("div",{className:"relative z-10 flex items-center justify-center w-full h-full",children:e.jsx(Br,{className:s})})]})]}),Fr=3e4,zr=10*6e4;let ns=!1;const Ea=()=>{ns||typeof window>"u"||(ns=!0,window.dispatchEvent(new Event("auth:logout")),queueMicrotask(()=>{ns=!1}))},Ur=t=>{if(!t)return"";const s=new URLSearchParams;for(const[l,n]of Object.entries(t))n!=null&&s.set(l,String(n));const a=s.toString();return a?`?${a}`:""},as=async(t,s,a={})=>{var N;const l=Ur(a.params),n=`${s}${l}`,c=Da(a.signal,a.timeoutMs??Fr);let u;try{u=await fetch(n,{method:t,credentials:"include",signal:c.signal,headers:{...a.body===void 0?{}:{"Content-Type":"application/json"}},body:a.body===void 0?void 0:JSON.stringify(a.body)})}catch(x){throw c.signal.aborted?new Error((N=a.signal)!=null&&N.aborted?"请求已取消":"请求超时,请稍后重试"):x}finally{c.cleanup()}const m=(u.headers.get("content-type")||"").includes("application/json");if(!u.ok){u.status===401&&!a.skipAuthLogout&&Ea();const x=m?await u.json().catch(()=>{}):await u.text().catch(()=>{}),p=$a(x,u.status);throw new Error(p)}return m?await u.json():await u.text()},ye=async(t,s,a)=>as("GET",t,{params:s,...a}),je=async(t,s,a)=>as("POST",t,{body:s,...a}),ze=async(t,s,a)=>as("PUT",t,{body:s,...a}),et=async(t,s,a)=>as("DELETE",t,{params:s,...a}),At=async(t,s,a={})=>{var m;const l=Da(a.signal,a.timeoutMs??zr);let n;try{n=await fetch(t,{method:"POST",credentials:"include",signal:l.signal,body:s})}catch(N){throw l.signal.aborted?new Error((m=a.signal)!=null&&m.aborted?"请求已取消":"上传超时,请稍后重试"):N}finally{l.cleanup()}const h=(n.headers.get("content-type")||"").includes("application/json")?await n.json().catch(()=>{}):await n.text().catch(()=>{});if(!n.ok){n.status===401&&Ea();const N=$a(h,n.status),x=new Error(N);throw x.payload=h,x}return h},Da=(t,s)=>{const a=new AbortController,l=()=>a.abort(t==null?void 0:t.reason);t!=null&&t.aborted?l():t==null||t.addEventListener("abort",l,{once:!0});const n=globalThis.setTimeout(()=>a.abort(new DOMException("timeout","TimeoutError")),Math.max(1,s));return{signal:a.signal,cleanup:()=>{globalThis.clearTimeout(n),t==null||t.removeEventListener("abort",l)}}},Wr=t=>{if(typeof t!="object"||t===null)return!1;const s=t;return typeof s.code=="string"&&typeof s.message=="string"},$a=(t,s)=>typeof t=="string"?t:Wr(t)?t.message:`请求失败: ${s}`,es=t=>{const s=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0");return`${s}-${a}-${l}`},$s=(t,s)=>{const a=new Date(t);return a.setHours(12,0,0,0),a.setDate(a.getDate()+s),a},ks=(t,s)=>({startDate:es($s(t,-(s-1))),endDate:es(t)}),Ma=(t,s=new Date,a="",l="")=>{if(t==="custom"&&a&&l){if(a>l)throw new Error("开始日期不能晚于结束日期");return{startDate:a,endDate:l}}return t==="yesterday"?ks($s(s,-1),1):ks(s,t==="3days"?3:t==="30days"?30:t==="today"?1:7)},Jr=t=>{const s=new Date(`${t.startDate}T12:00:00`),a=new Date(`${t.endDate}T12:00:00`),l=Math.round((a.getTime()-s.getTime())/864e5)+1,n=$s(s,-1);return ks(n,l)},Gr=t=>{const s={...t};if("renewal_log_retention_days"in s){const a=Number(s.renewal_log_retention_days);s.renewal_log_retention_days=Number.isFinite(a)?a:10}return s},Vr=async t=>je("/api/v1/session/login",t,{skipAuthLogout:!0}),Qr=async t=>je("/api/v1/session/initialize",{password:t},{skipAuthLogout:!0}),qa=async t=>ye("/api/v1/session",void 0,t),Kr=async t=>ye("/health",void 0,t),Hr=async()=>je("/api/v1/session/logout",{}),Zr=async(t,s)=>ze("/api/v1/session/credentials",t,s),Yr=(t,s)=>{const a=t.avatar_url||"";if(!a)return"";try{const l=new URL(a,window.location.origin);return l.hostname.endsWith("alicdn.com")&&l.searchParams.set("_v",s),l.toString()}catch{return a}},Ft=async t=>{const s=await ye("/api/v1/accounts/details",void 0,t),a=Date.now().toString();return s.map(l=>({id:l.id,value:"",cookie:"",enabled:l.enabled,auto_confirm:l.auto_confirm,remark:l.remark,note:l.remark,pause_duration:l.pause_duration,paused_until:Number(l.paused_until||0),paused:l.paused===!0,username:l.username||"",login_password:"",show_browser:l.show_browser===!0||l.show_browser===1||l.show_browser==="1"||l.show_browser==="true",nickname:l.nickname||l.remark||`账号 ${l.id.substring(0,6)}`,avatar_url:Yr(l,a),profile_error:l.profile_error||"",ai_enabled:!1,auto_rate_enabled:l.auto_rate_enabled,rate_content:l.rate_content||"不错的买家,交易愉快",auto_polish_enabled:l.auto_polish_enabled,polish_time:l.polish_time||"03:00",last_rate_scan_at:Number(l.last_rate_scan_at||0),last_polish_date:l.last_polish_date||"",last_polish_at:Number(l.last_polish_at||0)}))},Hs=async(t,s)=>ye(`/api/v1/account-tasks/${t}`,void 0,s),Zs=async(t,s,a)=>ze(`/api/v1/account-tasks/${t}`,s,a),Xr=async(t,s,a)=>je(`/api/v1/account-tasks/${t}/run`,{task_type:s},{timeoutMs:12e4,...a}),is=async(t,s,a,l=!1)=>{const n=await ye("/api/v1/chat/sessions",{account_id:t,cursor:s,refresh:l?1:void 0},l?{timeoutMs:6e4,...a}:a);return{sessions:n.sessions||[],has_more:n.has_more===!0,next_cursor:n.next_cursor}},Ys=async(t,s,a,l,n)=>{const c=await ye("/api/v1/chat/messages",{account_id:t,chat_id:s,cursor:a,before_id:l},n);return{messages:c.messages||[],has_more:c.has_more===!0,next_cursor:c.next_cursor,session:c.session}},el=async(t,s)=>je("/api/v1/chat/messages",t,s),tl=async(t,s)=>{const a=new FormData;return Object.entries(t).forEach(([l,n])=>a.append(l,n)),At("/api/v1/chat/images",a,{timeoutMs:12e4,...s})},Xs=async(t,s,a)=>je("/api/v1/chat/read",{account_id:t,chat_id:s},a),Cs=async t=>ye("/api/v1/accounts/runtime-status",void 0,t),sl=async t=>je("/api/v1/qr-login/generate",void 0,{...t,timeoutMs:(t==null?void 0:t.timeoutMs)??13e4}),al=async(t,s)=>ye(`/api/v1/qr-login/check/${t}`,void 0,{signal:s,timeoutMs:1e4}),rl=async(t,s)=>je(`/api/v1/qr-login/complete-verification/${t}`,{target_account_id:s||""}),ll=async(t,s)=>ze(`/api/v1/accounts/${t}/status`,{enabled:s}),nl=async t=>et(`/api/v1/accounts/${t}`),il=async(t,s,a)=>ze(`/api/v1/accounts/${t}/pause-duration`,{pause_duration:s},a),ol=async(t,s,a)=>ze(`/api/v1/accounts/${t}/settings`,s,a),cl=async(t,s)=>ye(`/api/v1/accounts/${t}/long-login`,void 0,s),dl=async(t,s,a)=>ze(`/api/v1/accounts/${t}/long-login`,{enabled:s},a),xl=async(t,s)=>je("/api/v1/password-login",t,s),ml=async(t,s)=>ye(`/api/v1/password-login/check/${t}`,void 0,{signal:s,timeoutMs:1e4}),ul=async(t,s)=>et(`/api/v1/password-login/cancel/${t}`,void 0,s),pl=async t=>je(`/api/v1/accounts/${t}/refresh-profile`,{}),hl=async t=>ye("/api/v1/settings/ai-reply",void 0,t),Ba=t=>{const s=String(t||"");return s==="paid"?"pending_ship":["processing","pending_ship","shipped","completed","cancelled","refunding"].includes(s)?s:"unknown"},gl=async(t,s,a=1,l=20,n,c)=>{const u={page:a,page_size:l};t&&(u.cookie_id=t),s&&s!=="all"&&(u.status=s),n!=null&&n.trim()&&(u.search=n.trim());const h=await ye("/api/v1/orders",u,c),N=(h.orders||h.data||[]).map(x=>({...x,id:x.id||x.order_id,status:Ba(x.status||x.order_status),quantity:Number(x.quantity||1)}));return{success:!0,data:N,total:h.total||N.length,page:h.page||a,page_size:h.page_size||l,total_pages:h.total_pages||1}},bl=async(t,s)=>ze(`/api/v1/orders/${t}`,s),fl=async t=>et(`/api/v1/orders/${t}`),yl=async(t,s)=>{const a=new FormData;return t&&a.append("cookie_id",t),s&&a.append("status",s),At("/api/v1/orders/refresh",a)},jl=async t=>je(`/api/v1/orders/${t}/refresh`),Nl=async(t,s)=>je("/api/v1/orders/manual-ship",{order_ids:t,ship_mode:s}),vl=async(t,s)=>t instanceof FormData?At("/api/v1/orders/import",t,s):je("/api/v1/orders/import",t,s),_l=async t=>ye("/api/v1/analytics/dashboard",void 0,t),ea=async(t=7,s)=>{let a;if(typeof t=="number"){const l=new Date,n=new Date;n.setDate(n.getDate()-t),a={start_date:es(n),end_date:es(l)}}else a=t;return ye("/api/v1/analytics/orders",{...a,timezone_offset_minutes:-new Date().getTimezoneOffset()},s)},wl=async(t,s)=>{const a=await ye("/api/v1/analytics/orders/valid",{start_date:t.start_date,end_date:t.end_date,timezone_offset_minutes:-new Date().getTimezoneOffset()},s),n=(Array.isArray(a)?a:a.orders||[]).map(c=>({...c,id:c.id||c.order_id,status:Ba(c.status||c.order_status),quantity:Number(c.quantity||1)}));return{orders:n,total:Array.isArray(a)?n.length:Number(a.total??n.length),truncated:Array.isArray(a)?!1:a.truncated===!0}},kl=t=>{let s=t.api_config;if(typeof s=="string"&&s.trim())try{s=JSON.parse(s)}catch{s=void 0}return{...t,api_config:s||void 0}},Fa=t=>({...t,api_config:t.api_config?JSON.stringify(t.api_config):""}),Ms=async t=>{const s=await ye("/api/v1/cards",void 0,t);return(Array.isArray(s)?s:s.cards||[]).map(kl)},Cl=async t=>je("/api/v1/cards",Fa(t)),ta=async(t,s)=>ze(`/api/v1/cards/${t}`,Fa(s)),Sl=async t=>et(`/api/v1/cards/${t}`),Ll=async(t,s)=>{const a=new FormData;return a.append("file",t),At("/api/v1/cards/batch",a,s)},Rl=async(t,s,a)=>je(`/api/v1/cards/${t}/append-data`,{content:s},a),os=t=>t===!0||t===1||t==="1",Lt=async(t,s)=>{const a=await ye("/api/v1/items",void 0,s);return(Array.isArray(a)?a:a.items||[]).map(n=>({...n,id:n.id||`${n.cookie_id}-${n.item_id}`,is_multi_spec:os(n.is_multi_spec),is_multi_qty_ship:os(n.is_multi_qty_ship??n.multi_quantity_delivery),multi_quantity_delivery:os(n.multi_quantity_delivery??n.is_multi_qty_ship)}))},Al=async t=>je("/api/v1/items/get-all-from-account",{cookie_id:t}),Il=async(t,s)=>et(`/api/v1/items/${t}/${s}`),Ol=async(t,s)=>je(`/api/v1/items/${t}`,s),Pl=async t=>{const s=new FormData;s.set("cookie_id",t.cookie_id),s.set("title",t.title),s.set("description",t.description),s.set("price",t.price),s.set("original_price",t.original_price||""),s.set("quantity",String(t.quantity)),s.set("postage_mode",t.postage_mode),s.set("postage",t.postage||""),t.location&&s.set("location",JSON.stringify(t.location));for(const a of t.images)s.append("images",a);return At("/api/v1/items/publish",s)},Tl=async(t,s)=>je("/api/v1/items/publish-categories/recommend",{cookie_id:t,keyword:s}),El=async t=>{const s=new FormData;return s.set("file",t.file),t.imagesZip&&s.set("images_zip",t.imagesZip),t.defaultCookieId&&s.set("default_cookie_id",t.defaultCookieId),s.set("fallback_category_id",t.fallbackCategory.catId),s.set("fallback_category_name",t.fallbackCategory.catName),s.set("fallback_channel_category_id",t.fallbackCategory.channelCatId||""),s.set("fallback_tb_category_id",t.fallbackCategory.tbCatId||""),t.location&&s.set("location",JSON.stringify(t.location)),At("/api/v1/items/publish-batches/preview",s)},Dl=async t=>je("/api/v1/items/publish-batches",{preview_id:t}),Nt=async t=>ye(`/api/v1/items/publish-batches/${t}`),za=async(t=20)=>{const s=await ye("/api/v1/items/publish-batches",{limit:t});return Array.isArray(s)?s:s.batches||[]},$l=async t=>et(`/api/v1/items/publish-batches/${t}`),Ml=async t=>je(`/api/v1/items/publish-batches/${t}/cancel`,{}),ql=async t=>je(`/api/v1/items/publish-batches/${t}/retry-failed`,{}),Bl=async(t,s,a)=>ze(`/api/v1/items/${t}/${s}`,a),Ua=t=>t.map(s=>{var a,l;return{id:String(s.id),name:s.name||"",trigger_type:s.trigger_type||"order_paid",item_keyword:s.item_title||s.item_id||"",cookie_id:s.cookie_id||"",item_id:s.item_id||"",item_title:s.item_title||"",card_group_id:Number(((a=(s.actions||[]).find(n=>n.action_type==="send_card"))==null?void 0:a.card_id)||0),card_group_name:((l=(s.actions||[]).find(n=>n.action_type==="send_card"))==null?void 0:l.card_name)||"",priority:s.priority||100,enabled:s.enabled||!1,config_json:s.config_json||"{}",actions:(s.actions||[]).map(n=>({id:n.id?String(n.id):void 0,action_type:n.action_type,card_id:Number(n.card_id||0),card_name:n.card_name||"",delivery_count:Number(n.delivery_count||1),message_template:n.message_template||"",delay_seconds:Number(n.delay_seconds||0),config_json:n.config_json||"{}",enabled:n.enabled!==!1,sort_order:Number(n.sort_order||0)})),variants:(s.actions||[]).filter(n=>n.action_type==="send_card").map(n=>{let c={};try{c=JSON.parse(n.config_json||"{}")}catch{}return{id:n.id?String(n.id):void 0,spec_name:c.spec_name||"",spec_value:c.spec_value||"",card_id:Number(n.card_id||0),card_name:n.card_name||"",delivery_count:Number(n.delivery_count||1),enabled:n.enabled!==!1,delay_override:c.delay_override===!0,delay_seconds:Number(n.delay_seconds||0),config_json:n.config_json||"{}"}})}}),Ss=async()=>{const t=await ye("/api/v1/automation-rules"),s=Array.isArray(t)?t:t.data||[];return Ua(s)},Fl=async({cookieId:t,triggerType:s,enabled:a,search:l,page:n=1,pageSize:c=10}={})=>{const u=await ye("/api/v1/automation-rules",{page:n,page_size:c,cookie_id:t||void 0,trigger_type:s||void 0,enabled:a,search:(l==null?void 0:l.trim())||void 0}),h=Ua(Array.isArray(u)?u:u.data||[]);return{success:!0,data:h,total:Number(Array.isArray(u)?h.length:u.total??h.length),page:Number(Array.isArray(u)?n:u.page??n),page_size:Number(Array.isArray(u)?c:u.page_size??c),total_pages:Number(Array.isArray(u)?h.length?1:0:u.total_pages??(h.length?1:0)),trigger_counts:Object.fromEntries(Object.entries(Array.isArray(u)?{}:u.trigger_counts||{}).map(([m,N])=>[m,Number(N)]))}},zl=(t,s)=>{if(t!=="order_paid")return s.map((n,c)=>({...n,sort_order:n.sort_order||c+1}));const a=s.filter(n=>n.action_type==="send_card").map((n,c)=>({...n,sort_order:c+1})),l=s.filter(n=>n.action_type!=="send_card"&&n.action_type!=="confirm_shipment");return[...a,...l.map((n,c)=>({...n,sort_order:a.length+c+1})),{action_type:"confirm_shipment",enabled:!0,sort_order:a.length+l.length+1}]},sa=async t=>{const s=t.trigger_type||"order_paid",l=[{order_paid:"付款后自动发货",buyer_reviewed:"评价后发送赠品",review_missing_timeout:"超时未评价求评价"}[s]||"自动化规则",t.item_title||t.item_id||t.cookie_id||""].filter(Boolean).join(" - "),n=(t.actions||[]).filter(m=>m.action_type!=="send_card"&&m.action_type!=="confirm_shipment"),c=t.variants&&t.variants.length>0?[...t.variants.map((m,N)=>({action_type:"send_card",card_id:m.card_id,delivery_count:m.delivery_count||1,enabled:m.enabled!==!1,sort_order:N+1,delay_seconds:m.delay_seconds||0,config_json:JSON.stringify({spec_name:m.spec_name||"",spec_value:m.spec_value||"",delay_override:m.delay_override===!0})})),...n]:t.actions&&t.actions.length>0?t.actions:[{action_type:"send_card",card_id:t.card_group_id||0,delivery_count:1,enabled:!0,sort_order:1}],u=zl(s,c),h={cookie_id:t.cookie_id||"",item_id:t.item_id||"",name:(t.name||"").trim()||l||"自动化规则",trigger_type:s,enabled:t.enabled??!0,priority:t.priority||100,config_json:t.config_json||"{}",actions:u.map((m,N)=>({action_type:m.action_type,card_id:m.card_id||0,delivery_count:m.delivery_count||1,message_template:m.message_template||"",delay_seconds:m.delay_seconds||0,config_json:m.config_json||"{}",enabled:m.enabled!==!1,sort_order:m.sort_order||N+1}))};return t.id?ze(`/api/v1/automation-rules/${t.id}`,h):je("/api/v1/automation-rules",h)},Ul=async t=>et(`/api/v1/automation-rules/${t}`),Wl=async()=>{const t=await ye("/api/v1/automation-issues");return{runs:Array.isArray(t==null?void 0:t.runs)?t.runs:[],pending_tasks:Array.isArray(t==null?void 0:t.pending_tasks)?t.pending_tasks:[]}},Jl=async(t,s)=>je(`/api/v1/automation-runs/${t}/resolve`,{resolution:s}),Gl=async(t,s)=>je(`/api/v1/automation-pending-tasks/${t}/resolve`,{resolution:s}),Vl=t=>({id:String((t==null?void 0:t.id)||""),keyword:(t==null?void 0:t.keyword)||"",reply:(t==null?void 0:t.reply)||"",item_id:(t==null?void 0:t.item_id)||"",type:(t==null?void 0:t.type)==="image"?"image":"text",image_url:(t==null?void 0:t.image_url)||""}),Ql=async t=>{const s=await ye(`/api/v1/reply-rules/${t}/typed`);return Array.isArray(s)?s.map(Vl):[]},Kl=async t=>t?(await Ql(t)).map(a=>({id:a.id,keyword:a.keyword||"",reply_content:a.reply||"",match_type:"fuzzy",enabled:!0,item_id:a.item_id||"",type:a.type==="image"?"image":"text",image_url:a.image_url||""})):[],Hl=async(t,s)=>{const a=t.type||"text",l={keyword:t.keyword||"",reply:a==="text"&&t.reply_content||"",item_id:t.item_id||"",type:a,image_url:a==="image"&&t.image_url||""};return t.id?ze(`/api/v1/reply-rules/${s}/typed/${t.id}`,l):je(`/api/v1/reply-rules/${s}/items`,l)},Zl=async(t,s)=>et(`/api/v1/reply-rules/${s}/typed/${t}`),Wa=async t=>{const s=await ye("/api/v1/settings/system",void 0,t);return Gr(s.data||s)},Ja=async(t,s)=>{const a=Object.fromEntries(Object.entries(t).filter(([,l])=>l!=null));return ze("/api/v1/settings/system",a,s)},Yl=async(t,s)=>ye(`/api/v1/settings/ai-reply/${t}`,void 0,s),Xl=async(t,s,a)=>{const l={ai_enabled:s.ai_enabled??!1,max_discount_percent:s.max_discount_percent??10,max_discount_amount:s.max_discount_amount??100,max_bargain_rounds:s.max_bargain_rounds??3,custom_prompts:s.custom_prompts??""};return ze(`/api/v1/settings/ai-reply/${t}`,l,a)},en=async(t,s="",a)=>(await je("/api/v1/settings/ai-models",{base_url:t,api_key:s},a)).models||[],tn=t=>{if(Array.isArray(t))return t.filter(Boolean);if(typeof t!="string"||!t.trim())return[];try{const s=JSON.parse(t);if(Array.isArray(s))return s.filter(Boolean)}catch{}return t.split(/[,\s;]+/).map(s=>s.trim()).filter(Boolean)},Ga=t=>{const s=Array.from(new Set((t||[]).filter(Boolean)));return s.length>0?JSON.stringify(s):""},Va=async t=>({success:!0,data:(await ye("/api/v1/notifications/channels",void 0,t)||[]).map(l=>{let n;try{n=typeof l.config=="string"?JSON.parse(l.config):l.config}catch{n={}}return{id:String(l.id),name:l.name,type:l.type==="ding_talk"?"dingtalk":l.type==="lark"?"feishu":l.type,config:n,event_types:tn(l.event_types),enabled:l.enabled,created_at:l.created_at,updated_at:l.updated_at}})}),sn=async(t,s)=>je("/api/v1/notifications/channels",{...t,config:JSON.stringify(t.config),event_types:Ga(t.event_types)},s),aa=async(t,s,a)=>{const l={...s};return"config"in s&&(l.config=JSON.stringify(s.config)),"event_types"in s&&(l.event_types=Ga(s.event_types)),ze(`/api/v1/notifications/channels/${t}`,l,a)},an=async(t,s)=>et(`/api/v1/notifications/channels/${t}`,void 0,s),rn=async(t,s)=>{const a=await ye(`/api/v1/notifications/accounts/${t}/bindings`,void 0,s);return(a==null?void 0:a.channel_ids)||[]},ln=async(t,s)=>je(`/api/v1/notifications/channels/${t}/test`,{},s),ra=async()=>ye("/api/v1/default-replies"),nn=async t=>{const s=await ye(`/api/v1/default-replies/${t}`);return{cookie_id:t,enabled:s.enabled||!1,reply_content:s.reply_content||"",reply_once:s.reply_once||!1,reply_image_url:s.reply_image_url||""}},on=async(t,s)=>ze(`/api/v1/default-replies/${t}`,{enabled:s.enabled??!1,reply_content:s.reply_content||"",reply_once:s.reply_once??!1,reply_image_url:s.reply_image_url||""}),cn=async t=>et(`/api/v1/default-replies/${t}`),dn=async t=>je(`/api/v1/default-replies/${t}/clear-records`,{}),xn=({activeTab:t,isAdmin:s=!1,collapsed:a,onToggleCollapsed:l,onNavigate:n,onLogout:c})=>{const[u,h]=r.useState({version:"dev",commit:"unknown"});r.useEffect(()=>{const x=new AbortController;return Kr({signal:x.signal}).then(p=>h({version:String(p.version||"dev"),commit:String(p.commit||"unknown")})).catch(p=>{p instanceof DOMException&&p.name}),()=>x.abort()},[]);const m=[{id:"dashboard",icon:or,label:"仪表盘"},{id:"accounts",icon:Na,label:"账号管理"},{id:"chat",icon:ys,label:"在线聊天"},{id:"cards",icon:Os,label:"卡密库存"},{id:"items",icon:va,label:"商品列表"},{id:"orders",icon:_a,label:"订单管理"},{id:"rules",icon:js,label:"自动化规则"},{id:"notifications",icon:Rt,label:"通知设置"},...s?[{id:"settings",icon:Ps,label:"系统与AI"}]:[]],N=/^\d+\.\d+\.\d+$/.test(u.version)?`v${u.version}`:u.version;return e.jsxs("aside",{className:`fixed inset-y-0 left-0 z-20 flex flex-col border-r border-slate-200/80 bg-white/95 shadow-sidebar backdrop-blur-xl transition-[width] duration-300 ${a?"w-16":"w-64"}`,children:[e.jsxs("div",{className:`flex h-20 items-center border-b border-slate-100 ${a?"justify-center px-2":"gap-3 px-5"}`,children:[e.jsx(ws,{sizeClass:"h-10 w-10"}),!a&&e.jsxs("div",{className:"min-w-0 leading-tight",children:[e.jsx("div",{className:"truncate text-base font-black tracking-tight text-slate-950",children:"Ydisks 闲鱼助手"}),e.jsx("div",{className:"mt-1 text-[10px] font-extrabold uppercase tracking-[0.22em] text-sky-600",children:"Operations"})]})]}),e.jsx("nav",{className:`flex-1 space-y-1.5 overflow-y-auto pt-5 ${a?"px-2":"px-3"}`,"aria-label":"主导航",children:m.map(x=>{const p=x.icon,_=t===x.id;return e.jsx(Is.Fragment,{children:e.jsxs("button",{type:"button",title:a?x.label:void 0,"aria-label":x.label,"aria-current":_?"page":void 0,onClick:()=>n(x.id),className:`group relative flex h-11 w-full items-center rounded-xl transition-colors ${a?"justify-center":"gap-3 px-3.5"} ${_?"bg-brand text-white shadow-brand-active":"text-slate-500 hover:bg-slate-100 hover:text-slate-900"}`,children:[e.jsx(p,{className:`h-[19px] w-[19px] shrink-0 ${_?"text-white":"text-slate-400 group-hover:text-slate-700"}`}),!a&&e.jsx("span",{className:"truncate text-sm font-bold",children:x.label}),_&&!a&&e.jsx("span",{className:"ml-auto h-1.5 w-1.5 rounded-full bg-white/90"})]})},x.id)})}),e.jsxs("div",{children:[e.jsx("div",{title:a?`版本 ${u.version} · ${u.commit}`:void 0,className:`border-y border-slate-100 bg-slate-50/70 py-2.5 ${a?"flex justify-center px-1":"px-6"}`,children:a?e.jsx(Bs,{className:"h-[18px] w-[18px] text-slate-400","aria-label":`版本 ${u.version}`}):e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-extrabold uppercase tracking-[0.18em] text-slate-400",children:[e.jsx(Bs,{className:"h-3.5 w-3.5"}),"运行版本"]}),e.jsxs("div",{className:"mt-1 flex items-baseline gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs font-bold text-slate-700",children:N}),e.jsx("span",{className:"truncate font-mono text-[10px] text-slate-400",children:u.commit})]})]})}),e.jsxs("div",{className:`space-y-2 p-2 ${a?"":"p-3"}`,children:[e.jsxs("button",{type:"button",onClick:l,title:a?"展开侧边栏":"收起侧边栏","aria-label":a?"展开侧边栏":"收起侧边栏",className:`flex h-10 w-full items-center rounded-xl text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-900 ${a?"justify-center":"gap-3 px-3"}`,children:[a?e.jsx(Ts,{className:"h-5 w-5"}):e.jsx(Es,{className:"h-5 w-5"}),!a&&e.jsx("span",{className:"text-sm font-bold",children:"收起侧边栏"})]}),e.jsxs("button",{type:"button",onClick:c,title:a?"退出登录":void 0,"aria-label":"退出登录",className:`flex h-10 w-full items-center rounded-xl text-slate-500 transition-colors hover:bg-red-50 hover:text-red-600 ${a?"justify-center":"gap-3 px-3"}`,children:[e.jsx(cr,{className:"h-5 w-5"}),!a&&e.jsx("span",{className:"text-sm font-bold",children:"退出登录"})]})]})]})]})},It=t=>String(t).padStart(2,"0"),Ls=t=>{if(t==null||t==="")return"-";const s=t instanceof Date?t:new Date(t);return Number.isNaN(s.getTime())?"-":[s.getFullYear(),It(s.getMonth()+1),It(s.getDate())].join("-")+" "+[It(s.getHours()),It(s.getMinutes()),It(s.getSeconds())].join(":")},mn=t=>{const s={};return t.forEach(a=>{s[a.item_id]=a.item_title||a.item_id}),s},un=t=>{var s;return((s=t.daily_stats)==null?void 0:s.map(a=>({name:a.date.slice(5),amount:a.amount,orders:a.order_count,avgAmount:a.order_count>0?(a.amount/a.order_count).toFixed(2):0})))||[]},pn=(t,s)=>(t.item_stats||[]).map(a=>{const l=s[a.item_id]||a.item_id;return{name:l.length>12?`${l.substring(0,12)}...`:l,sales:a.order_count}}).sort((a,l)=>l.sales-a.sales).slice(0,10),hn=(t,s,a)=>{const l=t.revenue_stats.total_orders||0;return(t.item_stats||[]).map(n=>{const c=s[n.item_id]||n.item_id;return{name:c.length>10?`${c.substring(0,10)}...`:c,value:n.order_count,percent:l>0?n.order_count/l*100:0}}).sort((n,c)=>c.value-n.value).slice(0,6).map((n,c)=>({...n,color:a[c%a.length]}))},gn=(t,s,a)=>{const l=t.revenue_stats.total_amount||0;return(t.item_stats||[]).map(n=>{const c=s[n.item_id]||n.item_id;return{name:c.length>12?`${c.substring(0,12)}...`:c,value:n.total_amount,orderCount:n.order_count,percentage:l>0?n.total_amount/l*100:0}}).sort((n,c)=>c.value-n.value).slice(0,5).map((n,c)=>({...n,color:a[c%a.length],percentage:n.percentage.toFixed(1)}))},bn=(t,s)=>{if(!t||!s)return null;const a=t.revenue_stats.total_amount,l=s.revenue_stats.total_amount;if(l===0)return a>0?"+100%":"0%";const n=(a-l)/l*100;return`${n>=0?"+":""}${n.toFixed(1)}%`},fn=t=>({today:"今天",yesterday:"昨天","3days":"三天内","7days":"7天内","30days":"一个月内",custom:"自定义"})[t.range]||"所选范围",yn=t=>Math.max(...t.map(s=>s.sales),1),la=(t,s,a)=>t===s&&!a.aborted,na=t=>t instanceof Error&&t.message==="请求已取消",cs=(t,s)=>t instanceof Error?t.message:s,jn=t=>{const{range:s,customStartDate:a,customEndDate:l,customRangeVersion:n}=t,[c,u]=r.useState(null),[h,m]=r.useState(null),[N,x]=r.useState({overview:"idle",range:"idle",error:""}),[p,_]=r.useState(0),S=r.useRef(0),q=r.useMemo(()=>({range:s,customStartDate:a,customEndDate:l}),[l,a,s]),w=r.useCallback(()=>_(F=>F+1),[]);r.useEffect(()=>{const F=new AbortController;return x(d=>({...d,overview:"loading",error:""})),Promise.all([_l({signal:F.signal}),Lt(void 0,{signal:F.signal})]).then(([d,B])=>{F.signal.aborted||(u({stats:d,items:B,itemNames:mn(B)}),x(Z=>({...Z,overview:"success"})))}).catch(d=>{F.signal.aborted||na(d)||x(B=>({...B,overview:"error",error:cs(d,"概览加载失败")}))}),()=>F.abort()},[p]),r.useEffect(()=>{let F;try{F=Ma(s,new Date,a,l)}catch(M){x(b=>({...b,range:"error",error:cs(M,"日期范围无效")}));return}const d=Jr(F),B=++S.current,Z=new AbortController;return x(M=>({...M,range:"loading",error:""})),Promise.all([ea({start_date:F.startDate,end_date:F.endDate},{signal:Z.signal}),ea({start_date:d.startDate,end_date:d.endDate},{signal:Z.signal}),wl({start_date:F.startDate,end_date:F.endDate},{signal:Z.signal})]).then(([M,b,k])=>{la(S.current,B,Z.signal)&&(m({analytics:M,previousAnalytics:b,validOrders:k,dateRange:F}),x(D=>({...D,range:"success"})))}).catch(M=>{!la(S.current,B,Z.signal)||na(M)||x(b=>({...b,range:"error",error:cs(M,"经营数据加载失败")}))}),()=>Z.abort()},[n,s,p]);const P=r.useMemo(()=>c&&h?{...c,...h}:null,[c,h]),A=(c==null?void 0:c.itemNames)||{},G=(h==null?void 0:h.analytics)||null,H=r.useMemo(()=>G?un(G):[],[G]),X=r.useMemo(()=>G?pn(G,A):[],[G,A]),f=r.useMemo(()=>["rgb(var(--color-brand))","rgb(var(--color-brand-highlight))","rgb(var(--color-success-500))","rgb(var(--color-warning-500))","rgb(var(--color-accent-500))"],[]),y=r.useMemo(()=>G?hn(G,A,f):[],[G,f,A]),z=r.useMemo(()=>G?gn(G,A,f):[],[G,f,A]),O=r.useMemo(()=>yn(X),[X]);return{data:P,status:N,chartData:H,productSalesData:X,sourceData:y,categoryData:z,maxProductSales:O,trendPercent:bn(G,(P==null?void 0:P.previousAnalytics)||null),selectedRangeLabel:fn(q),refresh:w}},Ce=(t,s)=>s===void 0?`rgb(var(--color-${t}))`:`rgb(var(--color-${t}) / ${s})`,Nn=({chartData:t,selectedRangeLabel:s,totalAmount:a})=>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:[s,"的销售额走势"]})]}),e.jsx("div",{className:"dashboard-revenue-chart h-[350px] w-full",children:t.length===0||a===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(wa,{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:"所选时间范围内暂无订单记录"})]}):t.length<=2?e.jsx(Yt,{width:"100%",height:"100%",children:e.jsxs(Tr,{data:t,margin:{top:30,right:20,left:0,bottom:30},barCategoryGap:"45%",children:[e.jsx(Gs,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:Ce("neutral-700"),fontSize:14,fontWeight:600},dy:10}),e.jsx(Vs,{axisLine:!1,tickLine:!1,tick:{fill:Ce("neutral-400"),fontSize:13,fontWeight:500},tickFormatter:(l=>`¥${l}`)}),e.jsx(Xt,{contentStyle:{backgroundColor:Ce("white"),borderRadius:"8px",border:`1px solid ${Ce("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:Ce("neutral-500"),fontWeight:500},itemStyle:{color:Ce("brand"),fontWeight:600},cursor:{fill:Ce("brand",.08)},formatter:(l=>[`¥${Number(l).toFixed(2)}`,"营收"])}),e.jsx(Er,{dataKey:"amount",fill:Ce("brand"),maxBarSize:72,radius:[12,12,0,0],activeBar:!1,stroke:"none",strokeWidth:0,children:t.map((l,n)=>e.jsx(_s,{fill:Ce("brand"),stroke:"none",strokeWidth:0},`cell-${n}`))})]})}):e.jsx(Yt,{width:"100%",height:"100%",children:e.jsxs(Dr,{data:t,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:Ce("brand"),stopOpacity:.5}),e.jsx("stop",{offset:"95%",stopColor:Ce("brand"),stopOpacity:0})]})}),e.jsx(Gs,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:Ce("neutral-400"),fontSize:13,fontWeight:500},dy:15}),e.jsx(Vs,{axisLine:!1,tickLine:!1,tick:{fill:Ce("neutral-400"),fontSize:13,fontWeight:500}}),e.jsx($r,{vertical:!1,stroke:Ce("neutral-100"),strokeDasharray:"3 3"}),e.jsx(Xt,{contentStyle:{backgroundColor:Ce("white"),borderRadius:"8px",border:`1px solid ${Ce("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:Ce("neutral-500"),fontWeight:500},itemStyle:{color:Ce("brand"),fontWeight:600},cursor:{stroke:Ce("brand"),strokeWidth:2,strokeDasharray:"4 4"}}),e.jsx(Mr,{type:"monotone",dataKey:"amount",stroke:Ce("brand"),strokeWidth:4,fillOpacity:1,fill:"url(#colorAmount)",activeDot:{r:8,fill:Ce("white"),stroke:Ce("brand"),strokeWidth:2}})]})})})]}),Xe=(t,s)=>`rgb(var(--color-${t}))`,vn=({status:t})=>{const s={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-brand 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",unknown:"bg-gray-100 text-gray-500"},a={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`inline-flex items-center justify-center whitespace-nowrap px-3 py-1.5 rounded-lg text-xs leading-none font-bold ${s[t]||s.cancelled}`,children:a[t]||t})},Jt=({title:t,value:s,icon:a,colorClass:l,trend:n})=>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 ${l} 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 ${l} bg-opacity-10 backdrop-blur-sm`,children:e.jsx(a,{className:`w-6 h-6 ${l.replace("bg-","text-")}`})}),n&&e.jsxs("span",{className:"text-xs font-bold text-white bg-brand px-3 py-1.5 rounded-full flex items-center gap-1 shadow-sm",children:[e.jsx(xr,{className:"w-3 h-3"})," ",n]})]}),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:s}),e.jsx("p",{className:"text-gray-500 text-sm font-medium mt-1",children:t})]})]}),ds=()=>{const[t,s]=r.useState("7days"),[a,l]=r.useState(""),[n,c]=r.useState(""),[u,h]=r.useState(""),[m,N]=r.useState(0),x=jn({range:t,customStartDate:a,customEndDate:n,customRangeVersion:m}),{data:p,status:_,chartData:S,productSalesData:q,sourceData:w,categoryData:P,maxProductSales:A,trendPercent:G,selectedRangeLabel:H,refresh:X}=x,f=(p==null?void 0:p.stats)||null,y=(p==null?void 0:p.analytics)||null;p!=null&&p.previousAnalytics;const z=(p==null?void 0:p.validOrders.orders)||[],O=(p==null?void 0:p.validOrders.total)||0,F=(p==null?void 0:p.validOrders.truncated)||!1,d=_.range==="loading",B=_.error,Z=[Xe("brand"),Xe("brand-highlight"),Xe("success-500"),Xe("warning-500"),Xe("accent-500")],M=v=>`¥${Number(v||0).toLocaleString("zh-CN",{maximumFractionDigits:2})}`;if(B&&(!f||!y))return e.jsxs("div",{className:"p-8 flex flex-col items-center gap-3 text-red-600",children:[e.jsx(ut,{className:"w-8 h-8"}),e.jsx("span",{children:B}),e.jsx("button",{type:"button",className:"ios-btn-primary px-4 py-2 rounded-xl",onClick:X,children:"重新加载"})]});if(!f||!y)return e.jsx("div",{className:"p-8 flex justify-center text-gray-400",children:e.jsx(Fs,{className:"w-8 h-8 animate-spin text-brand"})});const b=y.revenue_stats.total_orders||0,k=y.revenue_stats.total_amount||0,D=[{key:"today",label:"今天"},{key:"yesterday",label:"昨天"},{key:"3days",label:"三天内"},{key:"7days",label:"7天内"},{key:"30days",label:"一个月内"},{key:"custom",label:"自定义"}];let C;try{C=Ma(t,new Date,a,n)}catch{C={startDate:a,endDate:n}}const W=u.trim().toLowerCase(),V=z.filter(v=>{var ee,be,U,ae;return((ee=v.order_id)==null?void 0:ee.toLowerCase().includes(W))||((be=v.item_id)==null?void 0:be.toLowerCase().includes(W))||((U=v.item_title)==null?void 0:U.toLowerCase().includes(W))||((ae=v.buyer_id)==null?void 0:ae.toLowerCase().includes(W))});return e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[B&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm text-red-700",children:[e.jsx("span",{children:B}),e.jsx("button",{type:"button",className:"font-bold underline",onClick:X,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(v=>e.jsx("button",{onClick:()=>s(v.key),className:`px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${t===v.key?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:v.label},v.key)),t==="custom"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"date",value:a,onChange:v=>l(v.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-brand"}),e.jsx("span",{className:"self-center text-gray-400",children:"-"}),e.jsx("input",{type:"date",value:n,onChange:v=>c(v.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-brand"}),e.jsx("button",{onClick:()=>N(v=>v+1),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(Jt,{title:"累计营收 (CNY)",value:`¥${y.revenue_stats.total_amount.toLocaleString("zh-CN",{minimumFractionDigits:2})}`,icon:dr,colorClass:"bg-blue-400",trend:G||void 0}),e.jsx(Jt,{title:"活跃账号 / 总数",value:`${f.active_cookies} / ${f.total_cookies}`,icon:Na,colorClass:"bg-blue-500"}),e.jsx(Jt,{title:"订单数",value:y.revenue_stats.total_orders.toLocaleString(),icon:wa,colorClass:"bg-blue-500"}),e.jsx(Jt,{title:"库存卡密余量",value:f.available_card_stock,icon:ka,colorClass:"bg-purple-500"})]}),e.jsx(Nn,{chartData:S,selectedRangeLabel:H,totalAmount:k}),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:q.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:q.map((v,ee)=>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 ${ee<3?"bg-blue-600 text-white":"bg-gray-100 text-gray-500"}`,children:ee+1}),e.jsx("span",{className:"font-bold text-gray-800 text-sm truncate",children:v.name})]}),e.jsxs("span",{className:"font-mono text-sm font-extrabold text-gray-900",children:[v.sales," 单"]})]}),e.jsx("div",{className:"h-3 rounded-full bg-gray-100 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-brand",style:{width:`${Math.max(8,v.sales/A*100)}%`}})})]},`${v.name}-${ee}`))})})]}),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:"dashboard-pie-chart h-[280px] relative",role:"img","aria-label":`商品下单占比,共 ${b} 单`,children:w.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:"暂无数据"}):e.jsxs(e.Fragment,{children:[e.jsx(Yt,{width:"100%",height:"100%",children:e.jsxs(Qs,{accessibilityLayer:!1,children:[e.jsx(Ks,{data:w,cx:"50%",cy:"45%",innerRadius:60,outerRadius:90,paddingAngle:2,dataKey:"value",activeShape:{outerRadius:96,stroke:"none",strokeWidth:0},rootTabIndex:-1,label:!1,labelLine:!1,children:w.map((v,ee)=>e.jsx(_s,{fill:v.color},`cell-${ee}`))}),e.jsx(Xt,{formatter:v=>`${Number(v||0)} 单`,wrapperStyle:{zIndex:30,outline:"none"},contentStyle:{backgroundColor:Xe("white"),border:`1px solid ${Xe("neutral-200")}`,borderRadius:"10px",boxShadow:"var(--shadow-md)"}}),e.jsx(qr,{verticalAlign:"bottom",height:36,iconType:"circle",formatter:v=>e.jsx("span",{style:{color:Xe("neutral-500"),fontWeight:500},children:v})})]})}),e.jsxs("div",{className:"pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center pb-9",children:[e.jsx("span",{className:"text-2xl font-extrabold text-gray-900 tabular-nums",children:b}),e.jsx("span",{className:"text-xs font-medium text-gray-400 mt-0.5",children:"总订单"})]})]})})]})]}),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-surface-muted",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900",children:"参与统计的订单"}),F&&e.jsxs("p",{className:"text-xs text-amber-700 mt-1",children:["当前显示最近 ",z.length," / ",O," 条,搜索仅覆盖已加载明细。"]})]}),e.jsx("div",{className:"relative",children:e.jsx("input",{placeholder:"搜索订单号/商品/买家...",value:u,onChange:v=>h(v.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:d?e.jsxs("div",{className:"flex items-center justify-center py-20 text-gray-400",children:[e.jsx(Fs,{className:"w-6 h-6 animate-spin mr-2"}),"加载中..."]}):V.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(Bt,{className:"w-7 h-7 text-gray-300"})}),W?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:["当前共有 ",z.length," 单参与统计,但没有订单号、商品、买家匹配“",u,"”。"]})]}):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:["日期范围:",C.startDate," 至 ",C.endDate,"; 统计口径:待发货、已发货、已完成,且订单金额不为空。 当前统计卡片订单数:",y.revenue_stats.total_orders," 单。"]})]})]}):e.jsxs("table",{className:"w-full min-w-[760px] 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 whitespace-nowrap",children:"状态"}),e.jsx("th",{className:"px-6 py-4 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:V.map(v=>e.jsxs("tr",{className:"hover:bg-warning-50/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(Bt,{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:v.item_title||v.item_id||"未知商品"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 font-mono",children:v.order_id}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",v.quantity||1]})]})]})}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"text-sm font-bold text-gray-800",children:v.buyer_id}),v.created_at&&e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:Ls(v.created_at)})]}),e.jsxs("td",{className:"px-6 py-4 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:["¥",v.amount||"0.00"]}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx(vn,{status:v.status||v.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=${v.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(Ca,{className:"w-4 h-4"})})})]},v.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)"}),P.length===0?e.jsx("div",{className:"flex items-center justify-center h-[300px] text-gray-400",children:"暂无数据"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"dashboard-pie-chart h-[280px] relative",role:"img","aria-label":`商品金额分析,总金额 ${M(k)}`,children:[e.jsx(Yt,{width:"100%",height:"100%",children:e.jsxs(Qs,{accessibilityLayer:!1,children:[e.jsx(Ks,{data:P,cx:"50%",cy:"50%",innerRadius:60,outerRadius:92,paddingAngle:2,dataKey:"value",activeShape:{outerRadius:98,stroke:"none",strokeWidth:0},rootTabIndex:-1,label:!1,labelLine:!1,children:P.map((v,ee)=>e.jsx(_s,{fill:v.color||Z[ee%Z.length]},`cell-${ee}`))}),e.jsx(Xt,{wrapperStyle:{zIndex:30,outline:"none"},contentStyle:{backgroundColor:Xe("white"),border:`1px solid ${Xe("neutral-200")}`,borderRadius:"6px",boxShadow:"var(--shadow-md)"},formatter:v=>`¥${Number(v||0).toLocaleString()}`})]})}),e.jsxs("div",{className:"pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-lg font-extrabold text-gray-900 tabular-nums",children:M(k)}),e.jsx("span",{className:"text-xs font-medium text-gray-400 mt-0.5",children:"总金额"})]})]}),e.jsx("div",{className:"space-y-3 mt-4",children:P.map(v=>e.jsxs("div",{className:"flex justify-between items-center gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:v.color||Z[P.indexOf(v)%Z.length]}}),e.jsx("span",{className:"text-gray-600 font-medium truncate",title:v.name,children:v.name})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0 whitespace-nowrap",children:[e.jsxs("span",{className:"font-bold text-gray-900",children:["¥",v.value.toLocaleString()]}),e.jsxs("span",{className:"text-xs text-gray-500 bg-gray-100 px-2 py-0.5 rounded",children:[v.percentage,"%"]})]})]},v.name))})]})]})]})]})},_n=new Set(["expired","cancelled","error","not_found"]),wn=()=>{let t=0;return{next:()=>(t+=1,t),cancel:()=>{t+=1},isCurrent:s=>s===t}},kn=(t={setInterval:globalThis.setInterval.bind(globalThis),clearInterval:globalThis.clearInterval.bind(globalThis)})=>{let s=null,a=null,l=-1,n=0;const c=()=>{n+=1,a==null||a.abort(),a=null,s!==null&&(t.clearInterval(s),s=null)};return{start:(h,m,N,x=2e3)=>{c();const p=n;a=new AbortController;const _=a.signal;s=t.setInterval(()=>{l===p||p!==n||(l=p,(async()=>{var S,q;try{const w=await m(h,_);if(w.status==="success"){c(),await N.onSuccess(w);return}if(w.status==="scanned"){(S=N.onScanned)==null||S.call(N,w);return}if(w.status==="verification_required"){(q=N.onVerificationRequired)==null||q.call(N,w);return}w.status&&_n.has(w.status)&&(c(),N.onTerminalError(w))}catch(w){if(_.aborted||p!==n)return;c(),N.onPollError(w)}finally{l===p&&(l=-1)}})())},x)},stop:c,isActive:()=>s!==null}},Cn=({faceQrUrl:t,verificationScreenshot:s})=>e.jsxs("div",{className:"w-full min-w-0 max-h-[min(64vh,28rem)] overflow-y-auto overscroll-contain px-1 py-2 text-center",children:[e.jsx("div",{className:"mx-auto mb-2 flex h-10 w-10 items-center justify-center rounded-full bg-amber-100 text-amber-700",children:e.jsx(mr,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("h4",{className:"break-words text-base font-extrabold leading-6 text-amber-900",children:"需要完成安全风控验证"}),e.jsx("p",{className:"mx-auto mt-1 max-w-[15rem] break-words text-xs leading-5 text-amber-800",children:"当前账号触发了闲鱼平台风控。请使用手机闲鱼 App 扫描下方二维码,并按 App 提示完成人脸识别。"}),e.jsx("div",{className:"mx-auto mt-3 flex min-h-36 w-full max-w-[12rem] items-center justify-center overflow-hidden rounded-xl border border-amber-200 bg-white p-2 shadow-sm",children:t?e.jsx("img",{src:t,alt:"闲鱼安全风控验证二维码",className:"block max-h-44 w-full object-contain"}):s?e.jsx("img",{src:s,alt:"闲鱼风控验证页面",className:"block max-h-44 w-full object-contain"}):e.jsxs("div",{className:"flex flex-col items-center gap-2 text-amber-700",children:[e.jsx(_e,{className:"h-6 w-6 animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"text-xs font-bold",children:"正在准备风控二维码…"})]})}),e.jsx("p",{className:"mx-auto mt-2 max-w-[15rem] break-words text-[11px] leading-4 text-gray-500",children:"请勿在浏览器中打开验证链接。完成验证后系统会自动检测并刷新登录状态,无需手动确认。"})]}),Qa=({src:t,alt:s,className:a=""})=>e.jsx("img",{src:t,alt:s,className:`block aspect-square h-auto w-full object-contain ${a}`.trim()}),ia=t=>({account_id:t.id,auto_rate_enabled:t.auto_rate_enabled===!0,rate_content:t.rate_content||"不错的买家,交易愉快",auto_polish_enabled:t.auto_polish_enabled===!0,polish_time:t.polish_time||"03:00",last_rate_scan_at:t.last_rate_scan_at,last_polish_date:t.last_polish_date,last_polish_at:t.last_polish_at}),at=(t,s,a)=>t===s&&!a.aborted,xs=(t,s)=>t instanceof Error?t.message:s,ms=t=>t instanceof Error&&t.message==="请求已取消",oa=(t,s)=>!t&&s==="",Sn=({account:t,onSaved:s})=>{const[a,l]=r.useState(()=>ia(t)),[n,c]=r.useState(!0),[u,h]=r.useState(!1),[m,N]=r.useState(""),[x,p]=r.useState(""),[_,S]=r.useState(null),[q,w]=r.useState(null),P=r.useRef(0),A=r.useRef(null);r.useEffect(()=>{var z;const f=++P.current;(z=A.current)==null||z.abort();const y=new AbortController;return A.current=y,l(ia(t)),S(null),p(""),h(!1),N(""),w(null),c(!0),Hs(t.id,{signal:y.signal}).then(O=>{at(P.current,f,y.signal)&&l(O)}).catch(O=>{at(P.current,f,y.signal)&&!ms(O)&&p(xs(O,"加载任务设置失败"))}).finally(()=>{at(P.current,f,y.signal)&&c(!1)}),()=>y.abort()},[t.id]),r.useEffect(()=>()=>{var f;return(f=A.current)==null?void 0:f.abort()},[]);const G=r.useCallback(async()=>{var z;if(!oa(u,m))return;const f=++P.current;(z=A.current)==null||z.abort();const y=new AbortController;A.current=y,h(!0),p(""),w(null);try{const O=await Zs(t.id,a,{signal:y.signal});if(!at(P.current,f,y.signal))return;l(O),s(O)}catch(O){at(P.current,f,y.signal)&&!ms(O)&&(p(xs(O,"保存失败")),w(()=>G))}finally{at(P.current,f,y.signal)&&h(!1)}},[t.id,a,s,m,u]),H=r.useCallback(async f=>{var O;if(!oa(u,m)||!t.enabled)return;const y=++P.current;(O=A.current)==null||O.abort();const z=new AbortController;A.current=z,N(f),p(""),S(null),w(null);try{await Zs(t.id,a,{signal:z.signal});const F=await Xr(t.id,f,{signal:z.signal}),d=await Hs(t.id,{signal:z.signal});if(!at(P.current,y,z.signal))return;S(F.summary),l(d),s(d)}catch(F){at(P.current,y,z.signal)&&!ms(F)&&(p(xs(F,"任务执行失败")),w(()=>()=>H(f)))}finally{at(P.current,y,z.signal)&&N("")}},[t.enabled,t.id,a,s,m,u]),X=r.useCallback(async()=>{q&&await q()},[q]);return{form:a,loading:n,saving:u,running:m,summary:_,error:x,retryAvailable:q!==null,setForm:l,save:G,run:H,retry:X}},ca=({checked:t,onChange:s,label:a})=>e.jsx("button",{type:"button","aria-label":a,"aria-pressed":t,onClick:s,className:`relative h-8 w-14 shrink-0 rounded-full transition-colors ${t?"bg-sky-500":"bg-slate-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 h-6 w-6 rounded-full bg-white shadow-sm transition-transform ${t?"translate-x-6":""}`})}),Ln=({account:t,onClose:s,onSaved:a})=>{const{form:l,loading:n,saving:c,running:u,error:h,summary:m,retryAvailable:N,setForm:x,save:p,run:_,retry:S}=Sn({account:t,onSaved:a});return e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"640px"},role:"dialog","aria-modal":"true","aria-labelledby":"account-task-title",children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"account-task-title",className:"text-2xl font-extrabold text-slate-950",children:"账号自动任务"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:t.nickname||t.remark||t.id})]}),e.jsx("button",{type:"button",onClick:s,className:"rounded-xl p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700","aria-label":"关闭",children:e.jsx(ke,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[n&&e.jsx("div",{className:"rounded-xl bg-slate-50 px-4 py-3 text-sm text-slate-500",children:"正在读取任务设置..."}),e.jsx("section",{className:"rounded-2xl border border-slate-200 bg-white p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-emerald-50 text-emerald-600",children:e.jsx(ur,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-black text-slate-900",children:"自动评价"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-slate-500",children:"持续扫描待评价订单,按订单执行;不是每日任务。"})]}),e.jsx(ca,{checked:l.auto_rate_enabled,onChange:()=>x(q=>({...q,auto_rate_enabled:!q.auto_rate_enabled})),label:"自动评价"})]}),e.jsx("label",{className:"mt-4 block text-xs font-extrabold text-slate-600",children:"统一好评文案"}),e.jsx("textarea",{"aria-label":"统一好评文案",value:l.rate_content,maxLength:500,onChange:q=>x(w=>({...w,rate_content:q.target.value})),className:"mt-2 h-24 w-full resize-none rounded-xl border border-slate-200 bg-slate-50 px-3 py-2.5 text-sm leading-6 text-slate-800 placeholder:text-slate-400 outline-none focus:border-sky-400 focus:ring-2 focus:ring-sky-100"}),e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"text-xs text-slate-400",children:["最近扫描:",l.last_rate_scan_at?new Date(l.last_rate_scan_at*1e3).toLocaleString("zh-CN"):"尚未执行"]}),e.jsxs("button",{type:"button",disabled:u!==""||!t.enabled,onClick:()=>void _("auto_rate"),className:"flex items-center gap-2 rounded-xl bg-emerald-50 px-3 py-2 text-xs font-extrabold text-emerald-700 hover:bg-emerald-100 disabled:opacity-50",children:[u==="auto_rate"?e.jsx(_e,{className:"h-4 w-4 animate-spin"}):e.jsx(pr,{className:"h-4 w-4"}),"立即评价"]})]})]})]})}),e.jsx("section",{className:"rounded-2xl border border-slate-200 bg-white p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-amber-50 text-amber-600",children:e.jsx(Ds,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-black text-slate-900",children:"每日自动擦亮"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-slate-500",children:"每个账号每天最多执行一次,按北京时间判断。"})]}),e.jsx(ca,{checked:l.auto_polish_enabled,onChange:()=>x(q=>({...q,auto_polish_enabled:!q.auto_polish_enabled})),label:"每日自动擦亮"})]}),e.jsxs("div",{className:"mt-4 flex items-end justify-between gap-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-extrabold text-slate-600",children:"每日执行时间"}),e.jsx("input",{type:"time",value:l.polish_time,onChange:q=>x(w=>({...w,polish_time:q.target.value})),className:"mt-2 block rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-bold text-slate-800 outline-none focus:border-sky-400"})]}),e.jsxs("button",{type:"button",disabled:u!==""||!t.enabled,onClick:()=>void _("auto_polish"),className:"flex items-center gap-2 rounded-xl bg-amber-50 px-3 py-2 text-xs font-extrabold text-amber-700 hover:bg-amber-100 disabled:opacity-50",children:[u==="auto_polish"?e.jsx(_e,{className:"h-4 w-4 animate-spin"}):e.jsx(Sa,{className:"h-4 w-4"}),"立即擦亮"]})]}),e.jsxs("div",{className:"mt-3 text-xs text-slate-400",children:["上次完成:",l.last_polish_at?new Date(l.last_polish_at*1e3).toLocaleString("zh-CN"):"尚未执行"]})]})]})}),m&&e.jsxs("div",{className:"rounded-xl border border-sky-100 bg-sky-50 px-4 py-3 text-sm text-sky-900",children:["本次发现 ",m.found," 项,成功 ",m.success,",失败 ",m.failed,",跳过 ",m.skipped,"。",m.message||""]}),h&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm font-medium text-red-700",children:[e.jsx("span",{children:h}),N&&e.jsx("button",{type:"button",className:"font-bold underline",onClick:()=>void S(),children:"重试"})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex w-full gap-3",children:[e.jsx("button",{type:"button",onClick:s,disabled:c||u!=="",className:"flex-1 rounded-xl bg-gray-100 px-6 py-3 font-bold text-gray-700 transition-colors hover:bg-gray-200 disabled:opacity-50",children:"关闭"}),e.jsxs("button",{type:"button",onClick:()=>void p(),disabled:c||u!==""||l.auto_rate_enabled&&!l.rate_content.trim(),className:"ios-btn-primary flex flex-1 items-center justify-center gap-2 rounded-xl px-6 py-3 font-bold disabled:opacity-50",children:[c?e.jsx(_e,{className:"h-4 w-4 animate-spin"}):e.jsx(lt,{className:"h-4 w-4"}),"保存"]})]})})]})})},Rn=({account:t,editForm:s,setEditForm:a,saving:l,onClose:n,onSave:c,onRestartPause:u,longLogin:h,onToggleLongLogin:m,passwordLoginView:N,onPasswordLogin:x,onCancelPasswordLogin:p,notifChannels:_,selectedChannelIds:S,bindingsLoaded:q,bindingsLoading:w,bindingsLoadError:P,onRetryBindings:A,onToggleChannel:G,onSettingsDirty:H})=>{const X=(U,ae)=>{a(ge=>({...ge,[U]:ae}))},f=()=>void n(),y=()=>void c(),z=U=>X("remark",U.target.value),O=U=>X("cookie",U.target.value),F=()=>X("auto_confirm",!s.auto_confirm),d=U=>X("pause_duration",parseInt(U.target.value,10)||0),B=()=>void u(),Z=()=>void m(),M=U=>X("username",U.target.value),b=U=>a(ae=>({...ae,login_password:U.target.value,clear_password:!1})),k=()=>X("showLoginPassword",!s.showLoginPassword),D=U=>a(ae=>({...ae,clear_password:U.target.checked,login_password:U.target.checked?"":ae.login_password})),C=()=>X("show_browser",!s.show_browser),W=()=>void p(),V=()=>void x(),v=()=>void A(),ee=U=>{q&&(G(U),H())},be=U=>{const ae=S.includes(Number(U.id)),ge=()=>ee(Number(U.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:ge,disabled:!q,className:`w-5 h-5 rounded-md border-2 flex items-center justify-center transition-colors flex-shrink-0 ${ae?"bg-brand border-brand":"bg-white border-gray-300"}`,children:ae&&e.jsx(Ye,{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:U.name}),e.jsxs("div",{className:"text-xs text-gray-500",children:[U.type,U.enabled?"":" · 已停用"]})]})]},U.id)};return Oe.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:t.nickname||t.remark||t.id})]}),e.jsx("button",{onClick:f,className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(ke,{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:t.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:s.remark,onChange:z,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:s.cookie,onChange:O,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长度: ",s.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(Ye,{className:"w-4 h-4 text-green-500"}),"自动确认发货"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"自动将闲鱼订单标记为已发货"})]}),e.jsx("button",{type:"button",onClick:F,className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${s.auto_confirm?"bg-brand":"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 ${s.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(La,{className:"w-4 h-4 text-blue-500"}),"暂停处理时长(分钟)"]}),e.jsx("input",{type:"number",value:s.pause_duration,onChange:d,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:"设置后会暂停处理该账号的订单,到时间后自动恢复"}),s.pause_duration>0&&!t.paused&&s.pause_duration===(t.pause_duration||0)&&e.jsx("button",{type:"button",disabled:l,onClick:B,className:"mt-3 px-4 py-2 rounded-xl bg-amber-50 text-amber-700 hover:bg-amber-100 text-sm font-bold disabled:opacity-50",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(hr,{className:"w-5 h-5 text-blue-500"}),"登录信息"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl bg-blue-50 p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"保存登录信息"}),e.jsx("div",{className:"mt-1 text-xs text-gray-500",children:"状态直接读取并修改闲鱼官方长登录设置"}),h.error&&e.jsx("div",{className:"mt-1 text-xs text-red-600",children:h.error})]}),e.jsx("button",{type:"button","aria-label":"保存登录信息",disabled:h.loading||h.saving||!h.canOpen,onClick:Z,className:`relative h-8 w-14 flex-shrink-0 rounded-full transition-colors ${h.enabled?"bg-brand":"bg-gray-300"} disabled:cursor-not-allowed disabled:opacity-50`,children:e.jsx("span",{className:`absolute left-1 top-1 h-6 w-6 rounded-full bg-white shadow-md transition-transform ${h.enabled?"translate-x-6":"translate-x-0"}`})})]}),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:s.username,onChange:M,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:s.showLoginPassword?"text":"password",value:s.login_password,onChange:b,placeholder:"用于自动登录",className:"w-full ios-input px-4 py-3 rounded-xl pr-12"}),e.jsx("button",{type:"button",onClick:k,className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:s.showLoginPassword?e.jsx(bt,{className:"w-5 h-5"}):e.jsx(mt,{className:"w-5 h-5"})})]}),e.jsxs("label",{className:"mt-3 flex items-center gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.clear_password,onChange:D,className:"w-4 h-4 accent-brand"}),e.jsx("span",{className:"text-sm font-bold text-gray-700",children:"清空已保存密码"})]})]}),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,className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${s.show_browser?"bg-brand":"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 ${s.show_browser?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{className:"rounded-xl border border-blue-100 bg-blue-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-blue-950",children:"立即执行账号密码登录"}),e.jsx("div",{className:"text-xs text-blue-700 mt-1",children:"需要在上方重新输入本次登录密码;成功后后端会更新 Cookie 和保存的登录信息。"})]}),N.status==="processing"||N.status==="verification_required"?e.jsx("button",{type:"button",onClick:W,className:"px-4 py-2 rounded-xl bg-white text-red-600 font-bold text-sm border border-red-100",children:"取消登录"}):e.jsx("button",{type:"button",onClick:V,className:"px-4 py-2 rounded-xl bg-blue-600 text-white font-bold text-sm whitespace-nowrap",children:"密码登录刷新授权"})]}),N.message&&e.jsx("div",{className:`text-sm font-medium ${N.status==="failed"?"text-red-700":N.status==="success"?"text-green-700":"text-blue-800"}`,children:N.message}),N.status==="verification_required"&&e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50 p-3 text-amber-900",children:[e.jsx("div",{className:"font-extrabold",children:"账号已触发平台风控,需要完成人脸识别"}),e.jsx("div",{className:"text-xs mt-1 leading-5",children:"请在闲鱼 App 或已打开的登录浏览器中按提示完成验证。本页面不会提供可直接打开的风控链接。"}),N.qrCodeUrl&&e.jsx("div",{className:"mt-3 aspect-square w-48 overflow-hidden rounded-xl border bg-white",children:e.jsx(Qa,{src:N.qrCodeUrl,alt:"密码登录风控二维码",className:"p-2"})})]})]})]})]}),(_.length>0||w||P)&&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(Rt,{className:"w-5 h-5 text-blue-500"}),"通知渠道绑定"]}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"勾选后,该账号的 token 失效、自动恢复失败、风控验证等事件会推送到这些渠道"}),w&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(_e,{className:"w-4 h-4 animate-spin"}),"正在加载通知绑定"]}),P&&!w&&e.jsxs("div",{className:"mb-3 rounded-xl bg-amber-50 p-3 text-sm text-amber-800 flex items-center justify-between gap-3",children:[e.jsx("span",{children:P}),e.jsx("button",{type:"button",className:"font-bold whitespace-nowrap",onClick:v,children:"重试"})]}),e.jsx("div",{className:"space-y-2",children:_.map(be)})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:f,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:l,children:"取消"}),e.jsxs("button",{onClick:y,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:l,children:[l?e.jsx(_e,{className:"w-4 h-4 animate-spin"}):e.jsx(Ye,{className:"w-4 h-4"}),l?"保存中...":"保存"]})]})})]})}),document.body)},An=(t,s)=>{if(!t||!s)return!1;const a=Date.parse(t),l=Date.parse(s);return Number.isFinite(a)&&Number.isFinite(l)&&lt.map(a=>{const l=s[a.id];return!l||An(a.runtime_updated_at,l.updated_at)?a:{...a,runtime_state:l.state,runtime_message:l.message||"",runtime_connected:l.connected,runtime_updated_at:l.updated_at}}),On=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"}}},Pn=(t,s)=>t.map(a=>{var l,n,c,u,h;return{...a,ai_enabled:((l=s[a.id])==null?void 0:l.ai_enabled)??!1,max_discount_percent:((n=s[a.id])==null?void 0:n.max_discount_percent)??10,max_discount_amount:((c=s[a.id])==null?void 0:c.max_discount_amount)??100,max_bargain_rounds:((u=s[a.id])==null?void 0:u.max_bargain_rounds)??3,custom_prompts:((h=s[a.id])==null?void 0:h.custom_prompts)??""}}),Tn=()=>{const[t,s]=r.useState([]),[a,l]=r.useState(!0),n=r.useRef(0),c=r.useRef(null),u=r.useCallback(async()=>{var N;const h=++n.current;(N=c.current)==null||N.abort();const m=new AbortController;c.current=m,l(!0);try{const x={signal:m.signal},[p,_]=await Promise.allSettled([Ft(x),hl(x)]);if(h!==n.current)return;if(p.status==="rejected")throw p.reason;const S=_.status==="fulfilled"?_.value:{};_.status==="rejected"&&console.error("加载 AI 设置失败:",_.reason),s(Pn(p.value,S))}catch(x){h===n.current&&!m.signal.aborted&&console.error("加载账号失败:",x)}finally{h===n.current&&l(!1)}},[]);return r.useEffect(()=>{let h=!1,m=null;const N=new AbortController,x=async()=>{try{const _=await Cs({signal:N.signal,timeoutMs:1e4});h||s(S=>In(S,_))}catch(_){h||console.error("加载账号运行状态失败:",_)}finally{h||(m=window.setTimeout(()=>void x(),2e3))}};return u().finally(()=>{h||x()}),()=>{var _;h=!0,N.abort(),n.current+=1,(_=c.current)==null||_.abort(),m!==null&&window.clearTimeout(m)}},[u]),{accounts:t,setAccounts:s,loading:a,loadAccounts:u}},En=(t,s)=>t!==(s.pause_duration||0),Dn=(t,s)=>{const a=s.username!==(t.username||""),l=s.show_browser!==(t.show_browser||!1),n=s.login_password!=="",c=s.clear_password===!0;if(!a&&!l&&!n&&!c)return null;const u={username:s.username,show_browser:s.show_browser};return c?u.clear_password=!0:n&&(u.login_password=s.login_password),u},dt=(t,s,a,l)=>t===s&&a===l,$n=t=>t.status==="success"?{sessionId:"",status:"success",message:t.message||"账号密码登录成功,授权信息已更新",qrCodeUrl:""}:t.status==="processing"||t.status==="verification_required"?{sessionId:"",status:t.status,message:t.message||(t.status==="verification_required"?"账号触发风控,需要完成人脸识别":"登录处理中"),qrCodeUrl:t.qr_code_url||""}:{sessionId:"",status:"failed",message:t.error||t.message||"密码登录失败,请检查账号信息后重试",qrCodeUrl:""},Mn=(t,s)=>t&&s,qn=({editingAccount:t,setEditingAccount:s,setActiveModal:a,editForm:l,setEditForm:n,loadAccounts:c})=>{const[u,h]=r.useState({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:""}),[m,N]=r.useState([]),[x,p]=r.useState([]),[_,S]=r.useState(!1),[q,w]=r.useState(!1),[P,A]=r.useState(!1),[G,H]=r.useState(""),[X,f]=r.useState({ai_enabled:!1,max_discount_percent:10,max_discount_amount:100,max_bargain_rounds:3,custom_prompts:""}),[y,z]=r.useState(!1),[O,F]=r.useState({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),d=r.useRef(0),B=r.useRef(null),Z=r.useRef(0),M=r.useRef(null),b=r.useRef(0),k=r.useRef(null),D=r.useRef(0),C=r.useRef(""),W=r.useRef(null),V=r.useRef(null),v=r.useCallback(()=>{V.current!==null&&(window.clearTimeout(V.current),V.current=null)},[]),ee=r.useCallback(async T=>{var de;const g=++d.current;(de=B.current)==null||de.abort();const le=new AbortController;B.current=le,w(!0),S(!1),A(!1),H("");const[oe,ne]=await Promise.allSettled([Va({signal:le.signal}),rn(T,{signal:le.signal})]);dt(g,d.current,T,T)&&(oe.status==="fulfilled"?N(oe.value.data||[]):(N([]),H("通知渠道列表加载失败,请重试")),ne.status==="fulfilled"?(p(ne.value||[]),S(!0)):(p([]),H("通知绑定加载失败;本次保存不会修改现有绑定")),w(!1))},[]),be=r.useCallback(T=>{p(g=>g.includes(T)?g.filter(le=>le!==T):[...g,T]),A(!0)},[]),U=r.useCallback(async T=>{var ne,de;const g=++Z.current;(ne=M.current)==null||ne.abort();const le=new AbortController;M.current=le,D.current+=1,C.current=T.id,(de=W.current)==null||de.abort(),v(),F({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),s(T),n({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,clear_password:!1}),a("edit"),h({loading:!0,saving:!1,canOpen:!1,enabled:!1,error:""});const[,oe]=await Promise.allSettled([ee(T.id),cl(T.id,{signal:le.signal})]);g===Z.current&&(oe.status==="fulfilled"?h({loading:!1,saving:!1,canOpen:oe.value.can_open_long_login,enabled:oe.value.enabled,error:""}):h({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:"无法读取闲鱼保存登录信息状态"}))},[v,ee,a,n,s]),ae=r.useCallback(async()=>{if(!t||u.loading||u.saving||!u.canOpen)return;const T=!u.enabled;h(g=>({...g,saving:!0,error:""}));try{const g=await dl(t.id,T);h({loading:!1,saving:!1,canOpen:g.can_open_long_login,enabled:g.enabled,error:""})}catch(g){h(le=>({...le,saving:!1,error:g instanceof Error?g.message:"保存登录信息设置失败"}))}},[t,u]),ge=r.useCallback(async T=>{var oe;const g=++b.current;(oe=k.current)==null||oe.abort();const le=new AbortController;k.current=le,s(T),a("ai-settings"),z(!0);try{const ne=await Yl(T.id,{signal:le.signal});if(!dt(g,b.current,T.id,T.id))return;f({ai_enabled:ne.ai_enabled??!1,max_discount_percent:ne.max_discount_percent??10,max_discount_amount:ne.max_discount_amount??100,max_bargain_rounds:ne.max_bargain_rounds??3,custom_prompts:ne.custom_prompts??""})}catch(ne){dt(g,b.current,T.id,T.id)&&console.error("加载 AI 设置失败:",ne)}finally{dt(g,b.current,T.id,T.id)&&z(!1)}},[a,s]),$=r.useCallback(async()=>{if(!(!t||y)){z(!0);try{await Xl(t.id,X),a(null),await c()}catch(T){console.error("更新 AI 设置失败:",T)}finally{z(!1)}}},[X,t,c,y,a]),L=r.useCallback(async()=>{if(!(!t||y)){z(!0);try{const T={};l.remark!==(t.remark||t.note||"")&&(T.remark=l.remark),l.cookie&&l.cookie!==(t.cookie||t.value||"")&&(T.cookie=l.cookie),l.auto_confirm!==t.auto_confirm&&(T.auto_confirm=l.auto_confirm),En(l.pause_duration,t)&&(T.pause_duration=l.pause_duration);const g=Dn(t,l);g&&Object.assign(T,g),Mn(_,P)&&(T.channel_ids=x),Object.keys(T).length>0&&await ol(t.id,T),a(null),await c()}catch(T){console.error("更新账号失败:",T)}finally{z(!1)}}},[P,_,l,t,c,x,y,a]),Q=r.useCallback(async()=>{if(!(!t||l.pause_duration<=0||y)){z(!0);try{const T=await il(t.id,l.pause_duration);s(g=>g&&{...g,pause_duration:l.pause_duration,paused:(T==null?void 0:T.paused)===!0,paused_until:Number((T==null?void 0:T.paused_until)||0)}),await c()}catch(T){console.error("重新暂停失败:",T)}finally{z(!1)}}},[l.pause_duration,t,c,y,s]),Y=r.useCallback(async(T,g,le)=>{var ne;(ne=W.current)==null||ne.abort();const oe=new AbortController;W.current=oe;try{const de=await ml(T,oe.signal);if(!dt(g,D.current,le,C.current))return;const Se={...$n(de),sessionId:T};if(de.status==="success"){v(),F(Se),n(Ee=>({...Ee,login_password:"",showLoginPassword:!1})),await c();return}if(de.status==="processing"||de.status==="verification_required"){F(Se),v(),V.current=window.setTimeout(()=>void Y(T,g,le),1500);return}v(),F(Se)}catch(de){if(!dt(g,D.current,le,C.current))return;v(),F({sessionId:T,status:"failed",message:de instanceof Error?de.message:"查询密码登录状态失败",qrCodeUrl:""})}},[v,c,n]),re=r.useCallback(async()=>{var oe;if(!t)return;const T=l.username.trim();if(!T||!l.login_password)return;v(),(oe=W.current)==null||oe.abort();const g=++D.current;C.current=t.id;const le=new AbortController;W.current=le,F({sessionId:"",status:"processing",message:"正在启动密码登录…",qrCodeUrl:""});try{const ne=await xl({account_id:t.id,account:T,password:l.login_password,show_browser:l.show_browser},{signal:le.signal});if(!dt(g,D.current,t.id,C.current))return;if(!ne.success||!ne.session_id)throw new Error(ne.message||"无法启动密码登录");F({sessionId:ne.session_id,status:"processing",message:ne.message||"登录处理中",qrCodeUrl:""}),await Y(ne.session_id,g,t.id)}catch(ne){if(!dt(g,D.current,t.id,C.current))return;F({sessionId:"",status:"failed",message:ne instanceof Error?ne.message:"启动密码登录失败",qrCodeUrl:""})}},[v,l.login_password,l.show_browser,l.username,t,Y]),ue=r.useCallback(async()=>{var g;const T=O.sessionId;D.current+=1,C.current="",(g=W.current)==null||g.abort(),v(),T&&await ul(T).catch(()=>{}),F({sessionId:"",status:"idle",message:"",qrCodeUrl:""})},[v,O.sessionId]),Ne=r.useCallback(async()=>{var T,g,le;(T=B.current)==null||T.abort(),Z.current+=1,(g=M.current)==null||g.abort(),(le=k.current)==null||le.abort(),(O.status==="processing"||O.status==="verification_required")&&await ue(),a(null)},[ue,O.status,a]),R=r.useCallback(()=>{var T;b.current+=1,(T=k.current)==null||T.abort(),a(null)},[a]);return r.useEffect(()=>()=>{var T,g,le,oe;(T=B.current)==null||T.abort(),(g=M.current)==null||g.abort(),(le=k.current)==null||le.abort(),(oe=W.current)==null||oe.abort(),v()},[v]),{longLogin:u,notifChannels:m,selectedChannelIds:x,bindingsLoaded:_,bindingsLoading:q,bindingsDirty:P,bindingsLoadError:G,aiSettings:X,saving:y,passwordLoginView:O,setAiSettings:f,setBindingsDirty:A,setEditForm:n,openEditModal:U,closeEditModal:Ne,openAIModal:ge,closeAIModal:R,loadNotificationBindings:ee,toggleNotificationChannel:be,handleLongLoginToggle:ae,handleSaveAISettings:$,handleSaveEdit:L,handleRestartPause:Q,handlePasswordLogin:re,handleCancelPasswordLogin:ue}},Bn=()=>{const{accounts:t,setAccounts:s,loading:a,loadAccounts:l}=Tn(),[n,c]=r.useState(""),[u,h]=r.useState(""),[m,N]=r.useState(""),[x,p]=r.useState(null),[_,S]=r.useState(""),[q,w]=r.useState(!1),[P,A]=r.useState(""),[G,H]=r.useState("pending"),[X,f]=r.useState(""),[y,z]=r.useState(""),[O,F]=r.useState(""),[d,B]=r.useState(null),[Z,M]=r.useState(null),[b,k]=r.useState(null),[D,C]=r.useState(null),[W,V]=r.useState({remark:"",cookie:"",auto_confirm:!1,pause_duration:0,username:"",login_password:"",show_browser:!1,showLoginPassword:!1,clear_password:!1}),v=qn({editingAccount:b,setEditingAccount:k,setActiveModal:M,editForm:W,setEditForm:V,loadAccounts:l}),{longLogin:ee,notifChannels:be,selectedChannelIds:U,bindingsLoaded:ae,bindingsLoading:ge,bindingsLoadError:$,aiSettings:L,saving:Q,passwordLoginView:Y,setAiSettings:re,setBindingsDirty:ue,openEditModal:Ne,closeEditModal:R,openAIModal:T,closeAIModal:g,loadNotificationBindings:le,toggleNotificationChannel:oe,handleLongLoginToggle:ne,handleSaveAISettings:de,handleSaveEdit:Se,handleRestartPause:Ee,handlePasswordLogin:Te,handleCancelPasswordLogin:Ue}=v,Me=r.useRef(null),Be=r.useRef(null),Je=r.useRef(null),He=r.useRef(null);Me.current===null&&(Me.current=kn()),Be.current===null&&(Be.current=wn());const we=()=>{He.current!==null&&(window.clearTimeout(He.current),He.current=null)},pe=()=>{var j;(j=Me.current)==null||j.stop()},Ve=()=>{var j,E;(j=Je.current)==null||j.abort(),(E=Be.current)==null||E.cancel(),pe(),we(),w(!1)},it=()=>{we(),He.current=window.setTimeout(()=>{He.current=null,w(!1),l()},1e3)};r.useEffect(()=>()=>{var j,E;pe(),(j=Be.current)==null||j.cancel(),(E=Je.current)==null||E.abort(),we()},[]);const tt=async(j,E)=>{await ll(j,!E),l()},Qe=j=>{m||(S(""),p(j))},Ge=()=>{m||(S(""),p(null))},ot=async()=>{const j=x;if(!(!j||m)){N(j.id),S("");try{await nl(j.id),s(E=>E.filter(se=>se.id!==j.id)),p(null)}catch(E){console.error("删除账号失败:",E),S((E==null?void 0:E.message)||"删除账号失败,请稍后重试")}finally{N("")}}},pt=async j=>{h(j.id);try{const E=await pl(j.id);E!=null&&E.profile_error&&alert("资料刷新失败:"+E.profile_error),await l()}catch(E){console.error("刷新账号资料失败:",E),alert((E==null?void 0:E.message)||"刷新账号资料失败,请先重新授权该账号")}finally{h("")}},ht=async(j,E)=>{const se=await rl(j,E==null?void 0:E.id);if(!se.success||!se.account_id)throw new Error(se.message||"保存扫码授权失败");return se.account_id},J=async j=>{var fe,De,ve,Pe;pe(),(fe=Je.current)==null||fe.abort();const E=new AbortController;Je.current=E;const se=Be.current.next();we();const ce=j||null;B(ce),w(!0),H("loading"),f(""),A(""),z(""),F("");try{const me=await sl({signal:E.signal});if(!((De=Be.current)!=null&&De.isCurrent(se)))return;if(!me.success||!me.qr_code_url||!me.session_id)throw new Error(me.message||"闲鱼未返回可用的登录二维码");if(me.success&&me.qr_code_url&&me.session_id){const o=me.session_id;A(me.qr_code_url),H("waiting"),(ve=Me.current)==null||ve.start(o,al,{onSuccess:async()=>{try{if(!await ht(o,ce)){H("error");return}}catch(K){console.error("保存扫码授权失败",K),H("error");return}H("success"),it()},onScanned:()=>{H("waiting")},onTerminalError:()=>{H("error")},onPollError:K=>{console.error("轮询扫码状态失败",K),H("error")},onVerificationRequired:K=>{H("verification"),K.face_qr_url&&F(K.face_qr_url),K.verification_screenshot&&z(K.verification_screenshot)}})}}catch(me){if(!((Pe=Be.current)!=null&&Pe.isCurrent(se)))return;f(me instanceof Error?me.message:"二维码获取失败,请稍后重试"),H("error")}finally{Je.current===E&&(Je.current=null)}};if(a)return e.jsx("div",{className:"p-20 flex justify-center",children:e.jsx(_e,{className:"w-8 h-8 text-brand animate-spin"})});const ie=t.filter(j=>{const E=n.trim().toLowerCase();return E?[j.id,j.nickname,j.remark,j.note,j.username,j.runtime_message].some(se=>(se||"").toLowerCase().includes(E)):!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:n,onChange:j=>c(j.target.value),placeholder:"搜索昵称 / 备注 / 账号ID",className:"ios-input px-4 py-3 rounded-2xl text-sm w-full sm:w-72"}),e.jsxs("button",{onClick:()=>J(),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(rs,{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:["当前显示 ",ie.length," / ",t.length," 个账号"]}),e.jsx("div",{className:"text-blue-700",children:"如果某个账号只显示 ID,点该账号右侧“刷新资料”;若刷新失败,先点二维码重新授权。"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6",children:[ie.map(j=>{const E=On(j),se=j.runtime_state==="auth_expired"||j.runtime_state==="verification_required";return e.jsx("div",{className:"ios-card rounded-xl p-6 group transition-all duration-300 hover:border-brand",children:e.jsxs("div",{className:"flex min-w-0 items-start gap-5 sm:gap-8",children:[e.jsxs("div",{className:"relative",children:[j.avatar_url?e.jsx("img",{src:j.avatar_url,alt:j.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(yt,{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 ${E.dot}`,children:j.runtime_state==="online"&&e.jsx(Ye,{className:"w-3 h-3 text-white"})})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 mb-1",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900 break-words",children:j.nickname||j.remark||`账号 ${j.id.substring(0,6)}...`}),e.jsx("span",{className:`px-2.5 py-0.5 rounded-lg text-xs font-bold ${E.badge}`,children:E.label}),j.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(wt,{className:"w-3 h-3"})," AI"]}),j.auto_rate_enabled&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-emerald-100 px-2.5 py-0.5 text-xs font-bold text-emerald-700",children:[e.jsx($t,{className:"h-3 w-3"})," 自动评价"]}),j.auto_polish_enabled&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-amber-100 px-2.5 py-0.5 text-xs font-bold text-amber-700",children:[e.jsx(Ds,{className:"h-3 w-3"})," 每日擦亮"]}),j.auto_confirm&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-blue-50 px-2.5 py-0.5 text-xs font-bold text-blue-700",children:[e.jsx(Ye,{className:"h-3 w-3"})," 自动确认发货"]}),j.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:j.profile_error,children:[e.jsx(ut,{className:"w-3 h-3"})," 资料未同步"]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"text-sm font-medium text-gray-500",children:[e.jsx("p",{children:j.remark||j.note||"暂无备注"}),e.jsxs("p",{className:"font-mono text-xs text-gray-400",children:["ID: ",j.id]})]}),j.runtime_message&&j.runtime_state!=="online"&&j.runtime_state!=="disabled"&&e.jsxs("div",{className:`mb-3 flex flex-wrap items-center gap-2 text-sm font-medium ${se?"text-red-700":"text-amber-700"}`,children:[e.jsx(ut,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{children:j.runtime_message}),se&&e.jsxs("button",{type:"button",onClick:()=>J(j),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(rs,{className:"w-3.5 h-3.5"})," 重新授权"]})]}),j.paused&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-lg bg-blue-50 px-3 py-1.5 text-xs font-bold text-blue-700",children:[e.jsx(La,{className:"h-3 w-3"})," 暂停处理中"]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>pt(j),disabled:u===j.id,className:"p-3 rounded-xl transition-colors text-gray-600 hover:bg-gray-100 disabled:opacity-50",title:"刷新昵称和头像",children:e.jsx(We,{className:`w-5 h-5 ${u===j.id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>J(j),className:`p-3 rounded-xl transition-colors ${se?"text-red-600 bg-red-50 hover:bg-red-100":"text-blue-600 hover:bg-blue-50"}`,title:"重新扫码授权当前账号",children:e.jsx(rs,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>Ne(j),className:"p-3 rounded-xl hover:bg-gray-100 transition-colors text-gray-600",title:"编辑账号",children:e.jsx(Ra,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>T(j),className:"p-3 rounded-xl hover:bg-purple-100 transition-colors text-purple-600",title:"AI设置",children:e.jsx(wt,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>C(j),className:"p-3 rounded-xl hover:bg-amber-100 transition-colors text-amber-600",title:"自动评价与每日擦亮",children:e.jsx(Sa,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>tt(j.id,j.enabled),className:`p-3 rounded-xl transition-colors ${j.enabled?"text-green-600 hover:bg-green-50":"text-gray-400 hover:bg-gray-100"}`,title:j.enabled?"停用账号":"启用账号",children:e.jsx(gr,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>Qe(j),disabled:m!=="",className:"p-3 rounded-xl hover:bg-red-100 transition-colors text-red-500 disabled:cursor-not-allowed disabled:opacity-40",title:m===j.id?"删除中…":`删除账号 ${j.nickname||j.remark||j.id}`,children:m===j.id?e.jsx(_e,{className:"w-5 h-5 animate-spin"}):e.jsx(Ze,{className:"w-5 h-5"})})]})]})]})]})},j.id)}),t.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(yt,{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:"请点击右上角扫码添加您的闲鱼账号"})]}),t.length>0&&ie.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。"})]})]}),D&&Oe.createPortal(e.jsx(Ln,{account:D,onClose:()=>C(null),onSaved:j=>{s(E=>E.map(se=>se.id===D.id?{...se,auto_rate_enabled:j.auto_rate_enabled,rate_content:j.rate_content,auto_polish_enabled:j.auto_polish_enabled,polish_time:j.polish_time,last_rate_scan_at:j.last_rate_scan_at,last_polish_date:j.last_polish_date,last_polish_at:j.last_polish_at}:se))}}),document.body),x&&Oe.createPortal(e.jsx("div",{className:"modal-overlay-centered",role:"presentation",children:e.jsxs("div",{className:"h-fit w-full max-w-[400px] self-center overflow-hidden rounded-2xl border border-white/80 bg-white shadow-modal",role:"dialog","aria-modal":"true","aria-labelledby":"delete-account-title","aria-describedby":"delete-account-description",children:[e.jsxs("div",{className:"relative overflow-hidden border-b border-red-100 bg-gradient-to-br from-red-50 via-white to-orange-50 px-5 py-5",children:[e.jsx("div",{className:"absolute -right-12 -top-16 h-36 w-36 rounded-full bg-red-200/35 blur-2xl"}),e.jsxs("div",{className:"relative flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl bg-red-600 text-white shadow-md shadow-red-200",children:e.jsx(Ze,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{id:"delete-account-title",className:"text-lg font-extrabold tracking-tight text-gray-950",children:"删除这个账号?"}),e.jsx("p",{id:"delete-account-description",className:"mt-1 text-xs leading-5 text-gray-600",children:"删除后,该账号的关联配置也会一并清理,此操作无法撤销。"})]}),e.jsx("button",{type:"button",onClick:Ge,disabled:m!=="",className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-white hover:text-gray-700 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"关闭删除确认",children:e.jsx(ke,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"rounded-xl border border-gray-100 bg-gray-50/80 px-4 py-3",children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:x.nickname||x.remark||"未命名账号"}),x.remark&&x.nickname&&e.jsxs("div",{className:"mt-1 text-sm text-gray-500",children:["备注:",x.remark]}),e.jsxs("div",{className:"mt-1.5 break-all font-mono text-[11px] text-gray-400",children:["ID: ",x.id]})]}),m===x.id&&e.jsxs("div",{className:"mt-4 flex items-center gap-3 rounded-xl border border-blue-100 bg-blue-50 px-4 py-3",role:"progressbar","aria-label":"正在删除账号",children:[e.jsx(_e,{className:"h-5 w-5 flex-shrink-0 animate-spin text-brand"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-blue-950",children:"正在删除账号"}),e.jsx("div",{className:"mt-0.5 text-xs text-blue-700",children:"正在清理关联数据,请保持页面打开…"})]})]}),_&&e.jsxs("div",{className:"mt-4 flex items-start gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3",role:"alert",children:[e.jsx(ut,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-red-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-red-800",children:"删除失败"}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-red-700",children:_})]})]})]}),e.jsxs("div",{className:"flex gap-3 border-t border-gray-100 bg-gray-50/70 px-5 py-4",children:[e.jsx("button",{type:"button",onClick:Ge,disabled:m!=="",className:"flex-1 rounded-xl bg-white px-5 py-3 text-sm font-extrabold text-gray-700 ring-1 ring-gray-200 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",children:"取消"}),e.jsx("button",{type:"button",onClick:()=>void ot(),disabled:m!=="",className:"flex flex-1 items-center justify-center gap-2 rounded-xl bg-red-600 px-5 py-3 text-sm font-extrabold text-white shadow-lg shadow-red-200 transition-colors hover:bg-red-700 disabled:cursor-not-allowed disabled:bg-red-400",children:m===x.id?e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"h-4 w-4 animate-spin"}),"处理中"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ze,{className:"h-4 w-4"}),"确认删除"]})})]})]})}),document.body),q&&Oe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container relative",style:{maxWidth:"26rem"},children:[e.jsx("button",{onClick:Ve,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(ke,{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:d?"重新授权账号":"扫码添加账号"}),e.jsx("p",{className:"text-gray-500 mb-8 font-medium",children:d?`请用闲鱼APP扫码,为「${d.nickname||d.remark||d.id}」刷新授权`:"请打开闲鱼APP扫描下方二维码"}),e.jsxs("div",{className:`w-full bg-surface-subtle rounded-xl mx-auto flex items-center justify-center overflow-hidden border-4 border-white shadow-inner mb-6 relative ${G==="verification"?"max-w-72 min-h-64 h-auto p-2":"max-w-64 aspect-square"}`,children:[G==="loading"&&e.jsx(_e,{className:"w-10 h-10 text-brand animate-spin"}),G==="waiting"&&e.jsx(Qa,{src:P,alt:"闲鱼登录二维码",className:"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(Ye,{className:"w-8 h-8"})}),e.jsx("span",{className:"font-bold text-lg",children:"登录成功"})]}),G==="error"&&e.jsxs("div",{className:"px-5 text-center",children:[e.jsx("span",{className:"block text-red-600 font-bold",children:"二维码获取失败"}),e.jsx("span",{className:"mt-2 block text-xs leading-5 text-gray-500",children:X||"请关闭窗口后重新发起扫码登录。"})]}),G==="verification"&&e.jsx(Cn,{faceQrUrl:O,verificationScreenshot:y})]}),G!=="verification"&&e.jsx("p",{className:"text-xs text-gray-400 font-medium bg-gray-50 py-2 rounded-xl",children:"二维码有效期为5分钟,请尽快扫码。"})]})})]})}),document.body),Z==="edit"&&b&&e.jsx(Rn,{account:b,editForm:W,setEditForm:V,saving:Q,onClose:R,onSave:Se,onRestartPause:Ee,longLogin:ee,onToggleLongLogin:ne,passwordLoginView:Y,onPasswordLogin:Te,onCancelPasswordLogin:Ue,notifChannels:be,selectedChannelIds:U,bindingsLoaded:ae,bindingsLoading:ge,bindingsLoadError:$,onRetryBindings:()=>le(b.id),onToggleChannel:oe,onSettingsDirty:()=>ue(!0)}),Z==="ai-settings"&&b&&Oe.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(wt,{className:"w-6 h-6 text-purple-500"}),"AI助手设置"]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:b.nickname||b.remark||b.id})]}),e.jsx("button",{onClick:g,className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(ke,{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(wt,{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:()=>re({...L,ai_enabled:!L.ai_enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${L.ai_enabled?"bg-brand":"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 ${L.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:L.max_discount_percent,onChange:j=>re({...L,max_discount_percent:parseInt(j.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%;设为 0 表示不允许降价"})]}),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:L.max_discount_amount,onChange:j=>re({...L,max_discount_amount:parseInt(j.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 元;设为 0 表示不允许降价"})]}),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:L.max_bargain_rounds,onChange:j=>re({...L,max_bargain_rounds:parseInt(j.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:L.custom_prompts,onChange:j=>re({...L,custom_prompts:j.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(Ps,{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:g,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:de,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(lt,{className:"w-4 h-4"}),Q?"保存中...":"保存"]})]})})]})}),document.body)]})},Bn=[{key:"all",label:"全部"},{key:"processing",label:"处理中"},{key:"shipped",label:"已发货"},{key:"pending_ship",label:"待发货"},{key:"completed",label:"已完成"},{key:"cancelled",label:"已取消"},{key:"refunding",label:"退款中"}],Fn=t=>{const s=typeof t=="object"&&t!==null?t:{},a=Array.isArray(s.results)?s.results:[];return{total:Number(s.total||0),success_count:Number(s.success_count||0),failed_count:Number(s.failed_count||0),results:a.map(zn)}},zn=t=>{const s=typeof t=="object"&&t!==null?t:{};return{order_id:String(s.order_id||"unknown"),success:s.success===!0,message:String(s.message||"")}},Un=t=>(t==null?void 0:t.results.filter(Wn))||[],Wn=t=>!t.success,Jn=(t,s)=>t!==null&&!s,Gn=t=>{if(!t)return"请选择订单文件";const s=t.name.toLowerCase().split(".").pop()||"";return["xlsx","csv","tsv","json"].includes(s)?"":"仅支持 .xlsx、.csv、.tsv、.json 格式"},ft=(t,s)=>t===s,Vn=(t,s)=>t instanceof Error&&t.message?t.message:s,Qn=({filter:t,onFilterChange:s,accountFilter:a,onAccountFilterChange:l,accounts:n,accountName:c,searchText:u,onSearchChange:h})=>{const m=p=>s(p.currentTarget.dataset.status||"all"),N=p=>l(p.target.value),x=p=>h(p.target.value);return e.jsxs("div",{className:"p-4 border-b border-gray-50 flex flex-col md:flex-row gap-4 justify-between items-center bg-surface-muted",children:[e.jsx("div",{className:"flex gap-1 p-1 bg-gray-200/50 rounded-xl overflow-x-auto max-w-full",children:Bn.map(p=>e.jsx("button",{"data-status":p.key,onClick:m,className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${t===p.key?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:p.label},p.key))}),e.jsxs("div",{className:"flex w-full md:w-auto flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(yt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{"aria-label":"按账号筛选订单",value:a,onChange:N,className:"ios-input pl-10 pr-9 py-2.5 rounded-xl w-full sm:w-56 bg-white border-none shadow-sm",children:[e.jsx("option",{value:"",children:"全部账号"}),n.map(p=>e.jsx("option",{value:p.id,children:c(p.id)},p.id))]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(St,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 group-focus-within:text-brand transition-colors"}),e.jsx("input",{type:"text",placeholder:"搜索订单号/商品/买家...",value:u,onChange:x,className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]})},Kn=t=>{const s=c=>{var u;t.setImportFile(((u=c.target.files)==null?void 0:u[0])||null)},a=()=>t.closeImportModal(),l=()=>void t.handleImportOrders(),n=()=>void t.handleRetryImport();return t.showImportModal?Oe.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:a,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(ke,{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:s,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 格式"})]}),t.importFile&&e.jsx("div",{className:"p-3 bg-blue-50 rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mt,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"text-sm font-medium text-blue-900",children:t.importFile.name})]})}),t.importError&&e.jsxs("div",{className:"rounded-xl bg-red-50 border border-red-100 p-3 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:t.importError}),e.jsx("button",{type:"button",onClick:n,disabled:t.importing||!t.importFile,className:"font-bold whitespace-nowrap",children:"重试"})]}),t.importResult&&t.importResult.failed_count>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-100 p-3 text-sm font-bold text-amber-800",children:["导入完成:成功 ",t.importResult.success_count," 条,失败 ",t.importResult.failed_count," 条"]}),e.jsx("div",{className:"max-h-64 overflow-y-auto rounded-xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-gray-50 text-gray-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"订单ID"}),e.jsx("th",{className:"px-3 py-2",children:"失败原因"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:Un(t.importResult).map((c,u)=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-mono",children:c.order_id}),e.jsx("td",{className:"px-3 py-2 text-red-600",children:c.message||"导入失败"})]},`${c.order_id}-${u}`))})]})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:a,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:l,disabled:!t.importFile||t.importing,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:t.importing?"正在导入…":"导入订单"})]})})]})}),document.body):null},Hn=(t={pageSize:20})=>{const[s,a]=r.useState([]),[l,n]=r.useState([]),[c,u]=r.useState([]),[h,m]=r.useState("all"),[N,x]=r.useState(""),[p,_]=r.useState(""),[S,q]=r.useState(""),[w,P]=r.useState(1),[A,G]=r.useState(1),[H,X]=r.useState(!1),f=r.useRef(0),y=r.useRef(null),z=r.useRef(null),O=r.useCallback(async()=>{var D;const b=++f.current;(D=y.current)==null||D.abort();const k=new AbortController;y.current=k,X(!0);try{const C=await wl(N||void 0,h,w,t.pageSize,S,{signal:k.signal});if(!ft(b,f.current))return;a(C.data),G(C.total_pages)}catch(C){ft(b,f.current)&&!k.signal.aborted&&console.error("加载订单失败:",C)}finally{ft(b,f.current)&&X(!1)}},[N,S,h,t.pageSize,w]);r.useEffect(()=>{const b=window.setTimeout(()=>{P(1),q(p.trim())},300);return(()=>window.clearTimeout(b))},[p]),r.useEffect(()=>(O(),(()=>{var b;f.current+=1,(b=y.current)==null||b.abort()})),[O]),r.useEffect(()=>{var k;const b=new AbortController;return(k=z.current)==null||k.abort(),z.current=b,Promise.all([Ft({signal:b.signal}),Lt(void 0,{signal:b.signal})]).then(([D,C])=>{b.signal.aborted||(u(D),n(C))}).catch(D=>{b.signal.aborted||console.error("加载订单辅助数据失败:",D)}),(()=>b.abort())},[]);const F=r.useMemo(()=>new Map(c.map(b=>[b.id,b])),[c]),d=r.useMemo(()=>{const b={};return l.forEach(k=>{k.item_id&&(b[`${k.cookie_id}:${k.item_id}`]=k.item_title||k.item_id)}),b},[l]),B=r.useCallback(b=>{const k=F.get(b),D=(k==null?void 0:k.remark)||(k==null?void 0:k.nickname);return D?`${D} · ${b.slice(0,6)}`:`账号 ${b.slice(0,8)}`},[F]),Z=r.useCallback(b=>{const k=F.get(b);return(k==null?void 0:k.remark)||(k==null?void 0:k.nickname)||"未命名账号"},[F]),M=r.useCallback((b,k,D)=>{if(D!=null&&D.trim())return D;const C=d[`${b}:${k}`];if(C)return C;const W=l.find(V=>{if(!D||!V.item_title)return!1;const v=D.toLowerCase(),ee=V.item_title.toLowerCase();return ee.includes(v)||v.includes(ee)});return(W==null?void 0:W.item_title)||"未知商品"},[d,l]);return{orders:s,items:l,accounts:c,filter:h,setFilter:m,accountFilter:N,setAccountFilter:x,searchText:p,setSearchText:_,page:w,setPage:P,totalPages:A,loading:H,loadOrders:O,accountName:B,accountNickname:Z,getItemNameById:M}},Zn=t=>{const[s,a]=r.useState(!1),[l,n]=r.useState(null),[c,u]=r.useState(null),[h,m]=r.useState(!1),[N,x]=r.useState(""),p=r.useRef(0),_=r.useRef(null),S=r.useCallback(()=>{n(null),u(null),x(""),a(!0)},[]),q=r.useCallback(()=>{var A;p.current+=1,(A=_.current)==null||A.abort(),m(!1),a(!1),n(null),u(null),x("")},[]),w=r.useCallback(async()=>{var f;if(!Jn(l,h))return;const A=l;if(!A)return;const G=Gn(A);if(G){x(G);return}const H=++p.current;(f=_.current)==null||f.abort();const X=new AbortController;_.current=X,m(!0),u(null),x("");try{const y=new FormData;y.append("file",A);const z=Fn(await Al(y,{signal:X.signal}));if(!ft(H,p.current))return;u(z),n(null),await t(),z.failed_count===0&&ft(H,p.current)&&(alert(`订单导入成功,共 ${z.success_count} 条`),a(!1),u(null))}catch(y){ft(H,p.current)&&!X.signal.aborted&&x(Vn(y,"导入失败,请检查文件格式"))}finally{ft(H,p.current)&&m(!1)}},[l,h,t]),P=r.useCallback(async()=>{await w()},[w]);return{showImportModal:s,importFile:l,setImportFile:n,importResult:c,importing:h,importError:N,openImportModal:S,closeImportModal:q,handleImportOrders:w,handleRetryImport:P}},da=({status:t})=>{const s={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-brand 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",unknown:"bg-gray-100 text-gray-500"},a={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${s[t]||s.cancelled}`,children:a[t]||t})},Yn=()=>{const t=Hn(),s=Zn(t.loadOrders),{orders:a,accounts:l,filter:n,setFilter:c,accountFilter:u,setAccountFilter:h,searchText:m,setSearchText:N,page:x,setPage:p,totalPages:_,loading:S,loadOrders:q,accountName:w,accountNickname:P,getItemNameById:A}=t,[G,H]=r.useState(!1),[X,f]=r.useState(!1),[y,z]=r.useState(null),[O,F]=r.useState(null),[d,B]=r.useState(!1),[Z,M]=r.useState(""),[b,k]=r.useState(!1),[D,C]=r.useState(null),[W,V]=r.useState(null),[v,ee]=r.useState(null),be=R=>{c(R),p(1),N("")},U=R=>{h(R),p(1)},ae=R=>{N(R),p(1)},ge=async()=>{try{const R=await Sl(u||void 0,n);await q(),R!=null&&R.message&&alert(R.message)}catch(R){console.error("同步订单失败:",R),alert((R==null?void 0:R.message)||"同步失败,请重试")}},$=R=>{M(R),C(null),B(!0)},L=async R=>{var T;k(!0),C(null);try{const g=await Rl([Z],R),le=(T=g==null?void 0:g.results)==null?void 0:T[0];le!=null&&le.success?(C({success:!0,message:le.message}),q()):C({success:!1,message:(le==null?void 0:le.message)||"发货失败"})}catch(g){C({success:!1,message:(g==null?void 0:g.message)||"请求失败"})}finally{k(!1)}},Q=R=>{z(R),H(!0)},Y=R=>{F({...R}),f(!0)},re=async()=>{if(!(!O||!O.order_id))try{const R={};O.status!==void 0&&(R.order_status=O.status),O.buyer_id!==void 0&&(R.buyer_id=O.buyer_id),O.amount!==void 0&&(R.amount=O.amount),O.receiver_name!==void 0&&(R.receiver_name=O.receiver_name),O.receiver_phone!==void 0&&(R.receiver_phone=O.receiver_phone),O.receiver_address!==void 0&&(R.receiver_address=O.receiver_address),O.item_id!==void 0&&(R.item_id=O.item_id),O.quantity!==void 0&&(R.quantity=O.quantity),O.item_title!==void 0&&(R.item_title=O.item_title),await kl(O.order_id,R),f(!1),F(null),q()}catch(R){console.error("更新订单失败:",R),alert("更新失败,请重试")}},ue=async R=>{V(R);try{const T=await Ll(R);T.success?await q():alert(T.message||"同步失败")}catch(T){console.error("同步订单失败:",T),alert((T==null?void 0:T.message)||"同步失败,请重试")}finally{V(null)}},je=async R=>{if(confirm("确认删除该订单吗?删除后无法恢复。")){ee(R);try{await Cl(R),a.length===1&&x>1?p(T=>T-1):await q()}catch(T){console.error("删除订单失败:",T),alert((T==null?void 0:T.message)||"删除失败,请重试"),await q()}finally{ee(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:q,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(We,{className:`w-5 h-5 ${S?"animate-spin":""}`})}),e.jsxs("button",{onClick:s.openImportModal,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(nt,{className:"w-4 h-4"}),"插入订单"]}),e.jsxs("button",{onClick:ge,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(zs,{className:"w-5 h-5"}),"一键同步订单"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsx(Qn,{filter:n,onFilterChange:be,accountFilter:u,onAccountFilterChange:U,accounts:l,accountName:w,searchText:m,onSearchChange:ae}),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:a.map(R=>e.jsxs("tr",{className:"hover:bg-warning-50/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:R.item_image?e.jsx("img",{src:R.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(Bt,{})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 line-clamp-1 text-sm",children:A(R.cookie_id,R.item_id,R.item_title)}),e.jsxs("div",{className:"mt-1 flex w-fit min-w-0 max-w-full items-center gap-1 rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700",title:P(R.cookie_id),children:[e.jsx(yt,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:P(R.cookie_id)})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1 font-medium",children:["订单ID: ",R.order_id]}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",R.quantity," • ",Cs(R.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:R.buyer_id}),R.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:R.receiver_name})]}),R.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:R.receiver_phone})]}),R.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:R.receiver_address})]})]})}),e.jsx("td",{className:"px-6 py-5 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:R.amount?`¥${R.amount}`:e.jsx("span",{className:"text-xs text-amber-600 font-bold",children:"待获取"})}),e.jsx("td",{className:"px-6 py-5",children:e.jsx(da,{status:R.status})}),e.jsxs("td",{className:"px-6 py-5 text-right",children:[R.status==="pending_ship"&&e.jsx("button",{onClick:()=>$(R.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=${R.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(Ca,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Q(R),className:"mr-2 text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看详情",children:e.jsx(mt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Y(R),className:"mr-2 text-gray-400 hover:text-black p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"编辑订单",children:e.jsx(kt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>ue(R.order_id),disabled:W===R.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(We,{className:`w-4 h-4 ${W===R.order_id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>je(R.order_id),disabled:v===R.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(Ze,{className:"w-4 h-4"})})]})]},R.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:["第 ",x," 页 / 共 ",_," 页"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{disabled:x<=1,onClick:()=>p(R=>R-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(Es,{className:"w-5 h-5"})}),e.jsx("button",{disabled:x>=_,onClick:()=>p(R=>R+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(Ts,{className:"w-5 h-5"})})]})]})]}),G&&y&&Oe.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:()=>H(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(ke,{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:y.order_id})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"所属账号"}),e.jsx("div",{className:"truncate whitespace-nowrap text-sm font-bold text-blue-700",title:P(y.cookie_id),children:P(y.cookie_id)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"状态"}),e.jsx(da,{status:y.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:y.amount?`¥${y.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:y.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:Cs(y.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:[y.item_image&&e.jsx("img",{src:y.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:A(y.cookie_id,y.item_id,y.item_title)}),e.jsxs("div",{className:"text-sm text-gray-500",children:["商品ID: ",y.item_id]}),y.item_price&&e.jsxs("div",{className:"text-sm text-gray-500 mt-1",children:["标价: ¥",y.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:y.buyer_id})]}),y.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:y.receiver_name})]}),y.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:y.receiver_phone})]}),y.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:y.receiver_address})]})]})]})]}),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 bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"关闭"}),y.status==="pending_ship"&&e.jsx("button",{onClick:()=>{H(!1),$(y.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.jsx(Kn,{...s}),d&&Oe.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:()=>{B(!1),C(null)},className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(ke,{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:()=>L("status_only"),disabled:b,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(zs,{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:()=>L("full_delivery"),disabled:b,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-brand 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(Bt,{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:"自动匹配发货规则、获取卡券、发送卡券信息给买家,并修改发货状态。 适用于订单既没有发送卡券给买家、也没有修改发货状态的情况。"})]})]})}),b&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[e.jsx(We,{className:"w-4 h-4 animate-spin text-gray-500"}),e.jsx("span",{className:"text-sm text-gray-500",children:"正在处理中..."})]}),D&&e.jsxs("div",{className:`p-3 rounded-xl text-sm ${D.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:[D.success?"✓ ":"✗ ",D.message]})]}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{onClick:()=>{B(!1),C(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:D!=null&&D.success?"完成":"取消"})})]})}),document.body),X&&O&&Oe.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(ke,{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:O.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:O.status,onChange:R=>F({...O,status:R.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:O.buyer_id,onChange:R=>F({...O,buyer_id:R.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:O.amount,onChange:R=>F({...O,amount:R.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:O.receiver_name||"",onChange:R=>F({...O,receiver_name:R.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:O.receiver_phone||"",onChange:R=>F({...O,receiver_phone:R.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:O.receiver_address||"",onChange:R=>F({...O,receiver_address:R.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:O.item_title||"",onChange:R=>F({...O,item_title:R.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:re,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(lt,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body)]})},Xn=({dataCards:t,downloadCardTemplate:s,...a})=>{var w;const l=P=>{var A;a.setBatchFile(((A=P.target.files)==null?void 0:A[0])||null)},n=P=>{a.setAppendContent(P.target.value)},c=P=>{a.setAppendTargetId(P.target.value)},u=()=>a.closeBatchModal(),h=()=>a.setBatchTab("create"),m=()=>a.setBatchTab("append"),N=()=>void a.handleRetryBatchCreate(),x=()=>void a.handleRetryBatchAppend(),p=a.batchResult&&"rows"in a.batchResult?a.batchResult:null,_=P=>e.jsxs("option",{value:String(P.id),children:[P.name,"(ID: ",P.id,")"]},P.id),S=()=>void a.handleBatchCreate(),q=()=>void a.handleBatchAppend();return a.showBatchModal?Oe.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:u,className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(ke,{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:h,className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${a.batchTab==="create"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(br,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:m,className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${a.batchTab==="append"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(Mt,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),a.batchTab==="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;data 类型的“内容”按行存卡密(CSV 单元格内换行需用引号包裹)。"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:s,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(fr,{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(Mt,{className:"w-4 h-4"}),a.batchFile?a.batchFile.name:"选择 .xlsx / .csv / .tsv",e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv",className:"hidden",onChange:l})]})]}),((w=a.batchResult)==null?void 0:w.error)&&e.jsxs("div",{className:"rounded-xl border border-red-200 bg-red-50 p-4 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:a.batchResult.error}),e.jsx("button",{type:"button",onClick:N,disabled:!a.batchFile||a.batchBusy,className:"font-bold whitespace-nowrap",children:"重试"})]}),p&&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:["共 ",p.total," 行 · 成功 ",p.created," · 失败 ",p.failed]}),p.failed>0&&e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:p.rows.filter(P=>!P.success).map(P=>e.jsxs("div",{className:"text-xs text-red-600",children:["第 ",P.row_no," 行「",P.name,"」:",P.error]},P.row_no))})]})]}):e.jsx("div",{className:"space-y-4",children:t.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:a.appendTargetId,onChange:c,className:"w-full ios-input px-4 py-3 rounded-xl text-sm",children:t.map(_)})]}),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.appendContent,onChange:n,placeholder:`VIP-001 +例如:回复时保持礼貌专业、使用简洁的语言、强调产品质量等`,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(Ps,{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:g,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:de,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(lt,{className:"w-4 h-4"}),Q?"保存中...":"保存"]})]})})]})}),document.body)]})},Fn=[{key:"all",label:"全部"},{key:"processing",label:"处理中"},{key:"shipped",label:"已发货"},{key:"pending_ship",label:"待发货"},{key:"completed",label:"已完成"},{key:"cancelled",label:"已取消"},{key:"refunding",label:"退款中"}],zn=t=>{const s=typeof t=="object"&&t!==null?t:{},a=Array.isArray(s.results)?s.results:[];return{total:Number(s.total||0),success_count:Number(s.success_count||0),failed_count:Number(s.failed_count||0),results:a.map(Un)}},Un=t=>{const s=typeof t=="object"&&t!==null?t:{};return{order_id:String(s.order_id||"unknown"),success:s.success===!0,message:String(s.message||"")}},Wn=t=>(t==null?void 0:t.results.filter(Jn))||[],Jn=t=>!t.success,Gn=(t,s)=>t!==null&&!s,Vn=t=>{if(!t)return"请选择订单文件";const s=t.name.toLowerCase().split(".").pop()||"";return["xlsx","csv","tsv","json"].includes(s)?"":"仅支持 .xlsx、.csv、.tsv、.json 格式"},ft=(t,s)=>t===s,Qn=(t,s)=>t instanceof Error&&t.message?t.message:s,Kn=({filter:t,onFilterChange:s,accountFilter:a,onAccountFilterChange:l,accounts:n,accountName:c,searchText:u,onSearchChange:h})=>{const m=p=>s(p.currentTarget.dataset.status||"all"),N=p=>l(p.target.value),x=p=>h(p.target.value);return e.jsxs("div",{className:"p-4 border-b border-gray-50 flex flex-col md:flex-row gap-4 justify-between items-center bg-surface-muted",children:[e.jsx("div",{className:"flex gap-1 p-1 bg-gray-200/50 rounded-xl overflow-x-auto max-w-full",children:Fn.map(p=>e.jsx("button",{"data-status":p.key,onClick:m,className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${t===p.key?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:p.label},p.key))}),e.jsxs("div",{className:"flex w-full md:w-auto flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(yt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{"aria-label":"按账号筛选订单",value:a,onChange:N,className:"ios-input pl-10 pr-9 py-2.5 rounded-xl w-full sm:w-56 bg-white border-none shadow-sm",children:[e.jsx("option",{value:"",children:"全部账号"}),n.map(p=>e.jsx("option",{value:p.id,children:c(p.id)},p.id))]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(St,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 group-focus-within:text-brand transition-colors"}),e.jsx("input",{type:"text",placeholder:"搜索订单号/商品/买家...",value:u,onChange:x,className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]})},Hn=t=>{const s=c=>{var u;t.setImportFile(((u=c.target.files)==null?void 0:u[0])||null)},a=()=>t.closeImportModal(),l=()=>void t.handleImportOrders(),n=()=>void t.handleRetryImport();return t.showImportModal?Oe.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:a,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(ke,{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:s,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 格式"})]}),t.importFile&&e.jsx("div",{className:"p-3 bg-blue-50 rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mt,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"text-sm font-medium text-blue-900",children:t.importFile.name})]})}),t.importError&&e.jsxs("div",{className:"rounded-xl bg-red-50 border border-red-100 p-3 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:t.importError}),e.jsx("button",{type:"button",onClick:n,disabled:t.importing||!t.importFile,className:"font-bold whitespace-nowrap",children:"重试"})]}),t.importResult&&t.importResult.failed_count>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-100 p-3 text-sm font-bold text-amber-800",children:["导入完成:成功 ",t.importResult.success_count," 条,失败 ",t.importResult.failed_count," 条"]}),e.jsx("div",{className:"max-h-64 overflow-y-auto rounded-xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-gray-50 text-gray-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"订单ID"}),e.jsx("th",{className:"px-3 py-2",children:"失败原因"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:Wn(t.importResult).map((c,u)=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-mono",children:c.order_id}),e.jsx("td",{className:"px-3 py-2 text-red-600",children:c.message||"导入失败"})]},`${c.order_id}-${u}`))})]})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:a,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:l,disabled:!t.importFile||t.importing,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:t.importing?"正在导入…":"导入订单"})]})})]})}),document.body):null},Zn=(t={pageSize:20})=>{const[s,a]=r.useState([]),[l,n]=r.useState([]),[c,u]=r.useState([]),[h,m]=r.useState("all"),[N,x]=r.useState(""),[p,_]=r.useState(""),[S,q]=r.useState(""),[w,P]=r.useState(1),[A,G]=r.useState(1),[H,X]=r.useState(!1),f=r.useRef(0),y=r.useRef(null),z=r.useRef(null),O=r.useCallback(async()=>{var D;const b=++f.current;(D=y.current)==null||D.abort();const k=new AbortController;y.current=k,X(!0);try{const C=await gl(N||void 0,h,w,t.pageSize,S,{signal:k.signal});if(!ft(b,f.current))return;a(C.data),G(C.total_pages)}catch(C){ft(b,f.current)&&!k.signal.aborted&&console.error("加载订单失败:",C)}finally{ft(b,f.current)&&X(!1)}},[N,S,h,t.pageSize,w]);r.useEffect(()=>{const b=window.setTimeout(()=>{P(1),q(p.trim())},300);return(()=>window.clearTimeout(b))},[p]),r.useEffect(()=>(O(),(()=>{var b;f.current+=1,(b=y.current)==null||b.abort()})),[O]),r.useEffect(()=>{var k;const b=new AbortController;return(k=z.current)==null||k.abort(),z.current=b,Promise.all([Ft({signal:b.signal}),Lt(void 0,{signal:b.signal})]).then(([D,C])=>{b.signal.aborted||(u(D),n(C))}).catch(D=>{b.signal.aborted||console.error("加载订单辅助数据失败:",D)}),(()=>b.abort())},[]);const F=r.useMemo(()=>new Map(c.map(b=>[b.id,b])),[c]),d=r.useMemo(()=>{const b={};return l.forEach(k=>{k.item_id&&(b[`${k.cookie_id}:${k.item_id}`]=k.item_title||k.item_id)}),b},[l]),B=r.useCallback(b=>{const k=F.get(b),D=(k==null?void 0:k.remark)||(k==null?void 0:k.nickname);return D?`${D} · ${b.slice(0,6)}`:`账号 ${b.slice(0,8)}`},[F]),Z=r.useCallback(b=>{const k=F.get(b);return(k==null?void 0:k.remark)||(k==null?void 0:k.nickname)||"未命名账号"},[F]),M=r.useCallback((b,k,D)=>{if(D!=null&&D.trim())return D;const C=d[`${b}:${k}`];if(C)return C;const W=l.find(V=>{if(!D||!V.item_title)return!1;const v=D.toLowerCase(),ee=V.item_title.toLowerCase();return ee.includes(v)||v.includes(ee)});return(W==null?void 0:W.item_title)||"未知商品"},[d,l]);return{orders:s,items:l,accounts:c,filter:h,setFilter:m,accountFilter:N,setAccountFilter:x,searchText:p,setSearchText:_,page:w,setPage:P,totalPages:A,loading:H,loadOrders:O,accountName:B,accountNickname:Z,getItemNameById:M}},Yn=t=>{const[s,a]=r.useState(!1),[l,n]=r.useState(null),[c,u]=r.useState(null),[h,m]=r.useState(!1),[N,x]=r.useState(""),p=r.useRef(0),_=r.useRef(null),S=r.useCallback(()=>{n(null),u(null),x(""),a(!0)},[]),q=r.useCallback(()=>{var A;p.current+=1,(A=_.current)==null||A.abort(),m(!1),a(!1),n(null),u(null),x("")},[]),w=r.useCallback(async()=>{var f;if(!Gn(l,h))return;const A=l;if(!A)return;const G=Vn(A);if(G){x(G);return}const H=++p.current;(f=_.current)==null||f.abort();const X=new AbortController;_.current=X,m(!0),u(null),x("");try{const y=new FormData;y.append("file",A);const z=zn(await vl(y,{signal:X.signal}));if(!ft(H,p.current))return;u(z),n(null),await t(),z.failed_count===0&&ft(H,p.current)&&(alert(`订单导入成功,共 ${z.success_count} 条`),a(!1),u(null))}catch(y){ft(H,p.current)&&!X.signal.aborted&&x(Qn(y,"导入失败,请检查文件格式"))}finally{ft(H,p.current)&&m(!1)}},[l,h,t]),P=r.useCallback(async()=>{await w()},[w]);return{showImportModal:s,importFile:l,setImportFile:n,importResult:c,importing:h,importError:N,openImportModal:S,closeImportModal:q,handleImportOrders:w,handleRetryImport:P}},da=({status:t})=>{const s={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-brand 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",unknown:"bg-gray-100 text-gray-500"},a={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${s[t]||s.cancelled}`,children:a[t]||t})},Xn=()=>{const t=Zn(),s=Yn(t.loadOrders),{orders:a,accounts:l,filter:n,setFilter:c,accountFilter:u,setAccountFilter:h,searchText:m,setSearchText:N,page:x,setPage:p,totalPages:_,loading:S,loadOrders:q,accountName:w,accountNickname:P,getItemNameById:A}=t,[G,H]=r.useState(!1),[X,f]=r.useState(!1),[y,z]=r.useState(null),[O,F]=r.useState(null),[d,B]=r.useState(!1),[Z,M]=r.useState(""),[b,k]=r.useState(!1),[D,C]=r.useState(null),[W,V]=r.useState(null),[v,ee]=r.useState(null),be=R=>{c(R),p(1),N("")},U=R=>{h(R),p(1)},ae=R=>{N(R),p(1)},ge=async()=>{try{const R=await yl(u||void 0,n);await q(),R!=null&&R.message&&alert(R.message)}catch(R){console.error("同步订单失败:",R),alert((R==null?void 0:R.message)||"同步失败,请重试")}},$=R=>{M(R),C(null),B(!0)},L=async R=>{var T;k(!0),C(null);try{const g=await Nl([Z],R),le=(T=g==null?void 0:g.results)==null?void 0:T[0];le!=null&&le.success?(C({success:!0,message:le.message}),q()):C({success:!1,message:(le==null?void 0:le.message)||"发货失败"})}catch(g){C({success:!1,message:(g==null?void 0:g.message)||"请求失败"})}finally{k(!1)}},Q=R=>{z(R),H(!0)},Y=R=>{F({...R}),f(!0)},re=async()=>{if(!(!O||!O.order_id))try{const R={};O.status!==void 0&&(R.order_status=O.status),O.buyer_id!==void 0&&(R.buyer_id=O.buyer_id),O.amount!==void 0&&(R.amount=O.amount),O.receiver_name!==void 0&&(R.receiver_name=O.receiver_name),O.receiver_phone!==void 0&&(R.receiver_phone=O.receiver_phone),O.receiver_address!==void 0&&(R.receiver_address=O.receiver_address),O.item_id!==void 0&&(R.item_id=O.item_id),O.quantity!==void 0&&(R.quantity=O.quantity),O.item_title!==void 0&&(R.item_title=O.item_title),await bl(O.order_id,R),f(!1),F(null),q()}catch(R){console.error("更新订单失败:",R),alert("更新失败,请重试")}},ue=async R=>{V(R);try{const T=await jl(R);T.success?await q():alert(T.message||"同步失败")}catch(T){console.error("同步订单失败:",T),alert((T==null?void 0:T.message)||"同步失败,请重试")}finally{V(null)}},Ne=async R=>{if(confirm("确认删除该订单吗?删除后无法恢复。")){ee(R);try{await fl(R),a.length===1&&x>1?p(T=>T-1):await q()}catch(T){console.error("删除订单失败:",T),alert((T==null?void 0:T.message)||"删除失败,请重试"),await q()}finally{ee(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:q,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(We,{className:`w-5 h-5 ${S?"animate-spin":""}`})}),e.jsxs("button",{onClick:s.openImportModal,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(nt,{className:"w-4 h-4"}),"插入订单"]}),e.jsxs("button",{onClick:ge,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(zs,{className:"w-5 h-5"}),"一键同步订单"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsx(Kn,{filter:n,onFilterChange:be,accountFilter:u,onAccountFilterChange:U,accounts:l,accountName:w,searchText:m,onSearchChange:ae}),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:a.map(R=>e.jsxs("tr",{className:"hover:bg-warning-50/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:R.item_image?e.jsx("img",{src:R.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(Bt,{})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 line-clamp-1 text-sm",children:A(R.cookie_id,R.item_id,R.item_title)}),e.jsxs("div",{className:"mt-1 flex w-fit min-w-0 max-w-full items-center gap-1 rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700",title:P(R.cookie_id),children:[e.jsx(yt,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:P(R.cookie_id)})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1 font-medium",children:["订单ID: ",R.order_id]}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",R.quantity," • ",Ls(R.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:R.buyer_id}),R.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:R.receiver_name})]}),R.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:R.receiver_phone})]}),R.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:R.receiver_address})]})]})}),e.jsx("td",{className:"px-6 py-5 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:R.amount?`¥${R.amount}`:e.jsx("span",{className:"text-xs text-amber-600 font-bold",children:"待获取"})}),e.jsx("td",{className:"px-6 py-5",children:e.jsx(da,{status:R.status})}),e.jsxs("td",{className:"px-6 py-5 text-right",children:[R.status==="pending_ship"&&e.jsx("button",{onClick:()=>$(R.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=${R.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(Ca,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Q(R),className:"mr-2 text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看详情",children:e.jsx(mt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Y(R),className:"mr-2 text-gray-400 hover:text-black p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"编辑订单",children:e.jsx(kt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>ue(R.order_id),disabled:W===R.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(We,{className:`w-4 h-4 ${W===R.order_id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>Ne(R.order_id),disabled:v===R.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(Ze,{className:"w-4 h-4"})})]})]},R.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:["第 ",x," 页 / 共 ",_," 页"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{disabled:x<=1,onClick:()=>p(R=>R-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(Es,{className:"w-5 h-5"})}),e.jsx("button",{disabled:x>=_,onClick:()=>p(R=>R+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(Ts,{className:"w-5 h-5"})})]})]})]}),G&&y&&Oe.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:()=>H(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(ke,{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:y.order_id})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"所属账号"}),e.jsx("div",{className:"truncate whitespace-nowrap text-sm font-bold text-blue-700",title:P(y.cookie_id),children:P(y.cookie_id)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"状态"}),e.jsx(da,{status:y.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:y.amount?`¥${y.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:y.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:Ls(y.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:[y.item_image&&e.jsx("img",{src:y.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:A(y.cookie_id,y.item_id,y.item_title)}),e.jsxs("div",{className:"text-sm text-gray-500",children:["商品ID: ",y.item_id]}),y.item_price&&e.jsxs("div",{className:"text-sm text-gray-500 mt-1",children:["标价: ¥",y.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:y.buyer_id})]}),y.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:y.receiver_name})]}),y.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:y.receiver_phone})]}),y.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:y.receiver_address})]})]})]})]}),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 bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"关闭"}),y.status==="pending_ship"&&e.jsx("button",{onClick:()=>{H(!1),$(y.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.jsx(Hn,{...s}),d&&Oe.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:()=>{B(!1),C(null)},className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(ke,{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:()=>L("status_only"),disabled:b,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(zs,{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:()=>L("full_delivery"),disabled:b,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-brand 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(Bt,{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:"自动匹配发货规则、获取卡券、发送卡券信息给买家,并修改发货状态。 适用于订单既没有发送卡券给买家、也没有修改发货状态的情况。"})]})]})}),b&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[e.jsx(We,{className:"w-4 h-4 animate-spin text-gray-500"}),e.jsx("span",{className:"text-sm text-gray-500",children:"正在处理中..."})]}),D&&e.jsxs("div",{className:`p-3 rounded-xl text-sm ${D.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:[D.success?"✓ ":"✗ ",D.message]})]}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{onClick:()=>{B(!1),C(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:D!=null&&D.success?"完成":"取消"})})]})}),document.body),X&&O&&Oe.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(ke,{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:O.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:O.status,onChange:R=>F({...O,status:R.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:O.buyer_id,onChange:R=>F({...O,buyer_id:R.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:O.amount,onChange:R=>F({...O,amount:R.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:O.receiver_name||"",onChange:R=>F({...O,receiver_name:R.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:O.receiver_phone||"",onChange:R=>F({...O,receiver_phone:R.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:O.receiver_address||"",onChange:R=>F({...O,receiver_address:R.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:O.item_title||"",onChange:R=>F({...O,item_title:R.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:re,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(lt,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body)]})},ei=({dataCards:t,downloadCardTemplate:s,...a})=>{var w;const l=P=>{var A;a.setBatchFile(((A=P.target.files)==null?void 0:A[0])||null)},n=P=>{a.setAppendContent(P.target.value)},c=P=>{a.setAppendTargetId(P.target.value)},u=()=>a.closeBatchModal(),h=()=>a.setBatchTab("create"),m=()=>a.setBatchTab("append"),N=()=>void a.handleRetryBatchCreate(),x=()=>void a.handleRetryBatchAppend(),p=a.batchResult&&"rows"in a.batchResult?a.batchResult:null,_=P=>e.jsxs("option",{value:String(P.id),children:[P.name,"(ID: ",P.id,")"]},P.id),S=()=>void a.handleBatchCreate(),q=()=>void a.handleBatchAppend();return a.showBatchModal?Oe.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:u,className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(ke,{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:h,className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${a.batchTab==="create"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(br,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:m,className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${a.batchTab==="append"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(Mt,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),a.batchTab==="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;data 类型的“内容”按行存卡密(CSV 单元格内换行需用引号包裹)。"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:s,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(fr,{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(Mt,{className:"w-4 h-4"}),a.batchFile?a.batchFile.name:"选择 .xlsx / .csv / .tsv",e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv",className:"hidden",onChange:l})]})]}),((w=a.batchResult)==null?void 0:w.error)&&e.jsxs("div",{className:"rounded-xl border border-red-200 bg-red-50 p-4 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:a.batchResult.error}),e.jsx("button",{type:"button",onClick:N,disabled:!a.batchFile||a.batchBusy,className:"font-bold whitespace-nowrap",children:"重试"})]}),p&&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:["共 ",p.total," 行 · 成功 ",p.created," · 失败 ",p.failed]}),p.failed>0&&e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:p.rows.filter(P=>!P.success).map(P=>e.jsxs("div",{className:"text-xs text-red-600",children:["第 ",P.row_no," 行「",P.name,"」:",P.error]},P.row_no))})]})]}):e.jsx("div",{className:"space-y-4",children:t.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:a.appendTargetId,onChange:c,className:"w-full ios-input px-4 py-3 rounded-xl text-sm",children:t.map(_)})]}),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.appendContent,onChange:n,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.jsxs("p",{className:"text-xs text-gray-500",children:["预览:",a.appendPreview.length," 个有效卡密,空行自动忽略。"]})]}),a.appendError&&e.jsxs("div",{className:"rounded-xl bg-red-50 border border-red-200 p-3 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:a.appendError}),e.jsx("button",{type:"button",onClick:x,disabled:a.batchBusy,className:"font-bold whitespace-nowrap",children:"重试"})]}),a.appendResult&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",a.appendResult.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:u,className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),a.batchTab==="create"?e.jsxs("button",{onClick:S,disabled:!a.batchFile||a.batchBusy,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[a.batchBusy?e.jsx(_e,{className:"w-4 h-4 animate-spin"}):e.jsx(Mt,{className:"w-4 h-4"}),a.batchBusy?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:q,disabled:!a.appendTargetId||a.appendPreview.length===0||a.batchBusy||t.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[a.batchBusy?e.jsx(_e,{className:"w-4 h-4 animate-spin"}):e.jsx(nt,{className:"w-4 h-4"}),a.batchBusy?"处理中...":"追加卡密"]})]})]})}),document.body):null},ei=({type:t})=>{switch(t){case"text":return e.jsx(Ia,{className:"w-5 h-5 text-blue-500"});case"image":return e.jsx(Aa,{className:"w-5 h-5 text-purple-500"});case"api":return e.jsx(yr,{className:"w-5 h-5 text-blue-500"});default:return e.jsx(Os,{className:"w-5 h-5 text-gray-500"})}},ti=(t,s,a)=>{const l=a.trim().toLocaleLowerCase();return t.filter(n=>(!s||n.type===s)&&(!l||n.name.toLocaleLowerCase().includes(l)))},Ka=t=>t.split(` -`).map(s=>s.trim()).filter(Boolean),si=(t,s,a)=>!!(t&&Ka(s).length>0&&!a),vt=(t,s,a,l)=>t===s&&a===l,ai=()=>{const[t,s]=r.useState([]),[a,l]=r.useState(!0),n=r.useRef(0),c=r.useRef(null),u=r.useCallback(async()=>{var N;const h=++n.current;(N=c.current)==null||N.abort();const m=new AbortController;c.current=m,l(!0);try{const x=await Ms({signal:m.signal});if(h!==n.current)return;s(x)}catch(x){h===n.current&&!m.signal.aborted&&console.error("加载卡密库存失败:",x)}finally{h===n.current&&l(!1)}},[]);return r.useEffect(()=>(u(),()=>{var m;n.current+=1,(m=c.current)==null||m.abort()}),[u]),{cards:t,setCards:s,loading:a,loadCards:u}},ri=t=>{const s=t.dataCards,a=t.loadCards,[l,n]=r.useState(!1),[c,u]=r.useState("create"),[h,m]=r.useState(null),[N,x]=r.useState(null),[p,_]=r.useState(!1),[S,q]=r.useState(""),[w,P]=r.useState(""),[A,G]=r.useState(null),[H,X]=r.useState(""),f=r.useRef(0),y=r.useRef(null),z=r.useRef(""),O=r.useMemo(()=>Ka(w),[w]),F=r.useCallback(()=>{var k;u("create"),m(null),x(null),q((k=s[0])!=null&&k.id?String(s[0].id):""),P(""),G(null),X(""),n(!0)},[s]),d=r.useCallback(()=>{var k;f.current+=1,(k=y.current)==null||k.abort(),_(!1),n(!1)},[]),B=r.useCallback(async()=>{var C;if(!h||p)return;const k=++f.current;(C=y.current)==null||C.abort();const D=new AbortController;y.current=D,_(!0),x(null);try{const W=await Dl(h,{signal:D.signal});if(!vt(k,f.current,"",""))return;x(W),W.created>0&&await a()}catch(W){if(!vt(k,f.current,"",""))return;x({error:(W==null?void 0:W.message)||"上传失败"})}finally{vt(k,f.current,"","")&&_(!1)}},[p,h,a]),Z=r.useCallback(async()=>{var W;if(!si(S,w,p))return;const k=S,D=++f.current;z.current=k,(W=y.current)==null||W.abort();const C=new AbortController;y.current=C,_(!0),G(null),X("");try{const V=await $l(k,w,{signal:C.signal});if(!vt(D,f.current,k,S))return;G({added:V.added}),P(""),await a()}catch(V){if(!vt(D,f.current,k,S))return;X((V==null?void 0:V.message)||"追加失败")}finally{vt(D,f.current,k,S)&&_(!1)}},[w,S,p,a]),M=r.useCallback(async()=>{await B()},[B]),b=r.useCallback(async()=>{z.current&&S!==z.current||await Z()},[S,Z]);return{showBatchModal:l,setShowBatchModal:n,batchTab:c,setBatchTab:u,batchFile:h,setBatchFile:m,batchResult:N,batchBusy:p,appendTargetId:S,setAppendTargetId:q,appendContent:w,setAppendContent:P,appendResult:A,appendError:H,appendPreview:O,openBatchModal:F,closeBatchModal:d,handleBatchCreate:B,handleBatchAppend:Z,handleRetryBatchCreate:M,handleRetryBatchAppend:b}},xa=()=>({name:"",type:"data",content:"",description:"",enabled:!0,delay_seconds:0,api_method:"GET",api_timeout:10,api_headers:"",api_params:""}),li=()=>{const{cards:t,loadCards:s}=ai(),[a,l]=r.useState(!1),[n,c]=r.useState(!1),[u,h]=r.useState(null),[m,N]=r.useState({}),[x,p]=r.useState(xa),[_,S]=r.useState(""),[q,w]=r.useState(""),P=r.useMemo(()=>t.filter(d=>d.type==="data"),[t]),A=ri({dataCards:P,loadCards:s}),G=d=>{var B,Z,M,b,k;h(d),N({id:d.id,name:d.name||"",type:d.type||"text",api_url:((B=d.api_config)==null?void 0:B.url)||"",api_method:((Z=d.api_config)==null?void 0:Z.method)||"GET",api_timeout:((M=d.api_config)==null?void 0:M.timeout)||10,api_headers:((b=d.api_config)==null?void 0:b.headers)||"",api_params:((k=d.api_config)==null?void 0:k.params)||"",text_content:d.text_content||"",data_content:d.data_content||"",image_url:d.image_url||"",delay_seconds:d.delay_seconds||0,description:d.description||"",enabled:d.enabled}),l(!0)},H=async()=>{var d,B,Z,M,b,k,D,C;if(u){if(!((d=m.name)!=null&&d.trim())){alert("请输入卡密名称");return}if(!m.type){alert("请选择卡密类型");return}try{const W={name:m.name.trim(),type:m.type,description:(B=m.description)==null?void 0:B.trim(),delay_seconds:m.delay_seconds||0,enabled:m.enabled??!0};m.type==="api"?W.api_config={url:((Z=m.api_url)==null?void 0:Z.trim())||"",method:m.api_method,timeout:m.api_timeout||10,headers:((M=m.api_headers)==null?void 0:M.trim())||void 0,params:((b=m.api_params)==null?void 0:b.trim())||void 0}:m.type==="text"?W.text_content=((k=m.text_content)==null?void 0:k.trim())||"":m.type==="data"?W.data_content=((D=m.data_content)==null?void 0:D.trim())||"":m.type==="image"&&(W.image_url=((C=m.image_url)==null?void 0:C.trim())||""),await sa(u.id,W),l(!1),await s()}catch(W){console.error("更新卡密失败:",W),alert("更新失败,请重试")}}},X=async d=>{if(confirm("确认删除该卡密吗?"))try{await El(d),await s()}catch(B){console.error("删除卡密失败:",B),alert("删除失败,请重试")}},f=async()=>{if(!x.name.trim()){alert("请输入卡密名称");return}if(!x.content.trim()){alert(x.type==="api"?"请输入 API 地址":"请输入卡密内容");return}try{const d={name:x.name.trim(),type:x.type,description:x.description.trim(),enabled:x.enabled,delay_seconds:x.delay_seconds};x.type==="text"&&(d.text_content=x.content.trim()),x.type==="data"&&(d.data_content=x.content.trim()),x.type==="image"&&(d.image_url=x.content.trim()),x.type==="api"&&(d.api_config={url:x.content.trim(),method:x.api_method,timeout:x.api_timeout,headers:x.api_headers.trim()||void 0,params:x.api_params.trim()||void 0}),await Tl(d),c(!1),p(xa()),await s()}catch(d){console.error("添加卡密失败:",d),alert("添加失败,请重试")}},y=async d=>{try{await sa(d.id,{...d,enabled:!d.enabled}),await s()}catch(B){console.error("切换状态失败:",B)}},z=async d=>{try{await navigator.clipboard.writeText(String(d)),alert(`已复制卡密组ID:${d}`)}catch{prompt("复制卡密组ID",String(d))}},O=r.useMemo(()=>ti(t,_,q),[t,q,_]),F=()=>{const Z=[["名称","类型","内容","描述","启用","延迟秒","多规格","规格名","规格值"],...[["VIP月卡","data",`VIP-MONTH-001 +VIP-003`,className:"w-full ios-input px-4 py-3 rounded-xl text-sm font-mono h-40 resize-y"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["预览:",a.appendPreview.length," 个有效卡密,空行自动忽略。"]})]}),a.appendError&&e.jsxs("div",{className:"rounded-xl bg-red-50 border border-red-200 p-3 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:a.appendError}),e.jsx("button",{type:"button",onClick:x,disabled:a.batchBusy,className:"font-bold whitespace-nowrap",children:"重试"})]}),a.appendResult&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",a.appendResult.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:u,className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),a.batchTab==="create"?e.jsxs("button",{onClick:S,disabled:!a.batchFile||a.batchBusy,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[a.batchBusy?e.jsx(_e,{className:"w-4 h-4 animate-spin"}):e.jsx(Mt,{className:"w-4 h-4"}),a.batchBusy?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:q,disabled:!a.appendTargetId||a.appendPreview.length===0||a.batchBusy||t.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[a.batchBusy?e.jsx(_e,{className:"w-4 h-4 animate-spin"}):e.jsx(nt,{className:"w-4 h-4"}),a.batchBusy?"处理中...":"追加卡密"]})]})]})}),document.body):null},ti=({type:t})=>{switch(t){case"text":return e.jsx(Ia,{className:"w-5 h-5 text-blue-500"});case"image":return e.jsx(Aa,{className:"w-5 h-5 text-purple-500"});case"api":return e.jsx(yr,{className:"w-5 h-5 text-blue-500"});default:return e.jsx(Os,{className:"w-5 h-5 text-gray-500"})}},si=(t,s,a)=>{const l=a.trim().toLocaleLowerCase();return t.filter(n=>(!s||n.type===s)&&(!l||n.name.toLocaleLowerCase().includes(l)))},Ka=t=>t.split(` +`).map(s=>s.trim()).filter(Boolean),ai=(t,s,a)=>!!(t&&Ka(s).length>0&&!a),vt=(t,s,a,l)=>t===s&&a===l,ri=()=>{const[t,s]=r.useState([]),[a,l]=r.useState(!0),n=r.useRef(0),c=r.useRef(null),u=r.useCallback(async()=>{var N;const h=++n.current;(N=c.current)==null||N.abort();const m=new AbortController;c.current=m,l(!0);try{const x=await Ms({signal:m.signal});if(h!==n.current)return;s(x)}catch(x){h===n.current&&!m.signal.aborted&&console.error("加载卡密库存失败:",x)}finally{h===n.current&&l(!1)}},[]);return r.useEffect(()=>(u(),()=>{var m;n.current+=1,(m=c.current)==null||m.abort()}),[u]),{cards:t,setCards:s,loading:a,loadCards:u}},li=t=>{const s=t.dataCards,a=t.loadCards,[l,n]=r.useState(!1),[c,u]=r.useState("create"),[h,m]=r.useState(null),[N,x]=r.useState(null),[p,_]=r.useState(!1),[S,q]=r.useState(""),[w,P]=r.useState(""),[A,G]=r.useState(null),[H,X]=r.useState(""),f=r.useRef(0),y=r.useRef(null),z=r.useRef(""),O=r.useMemo(()=>Ka(w),[w]),F=r.useCallback(()=>{var k;u("create"),m(null),x(null),q((k=s[0])!=null&&k.id?String(s[0].id):""),P(""),G(null),X(""),n(!0)},[s]),d=r.useCallback(()=>{var k;f.current+=1,(k=y.current)==null||k.abort(),_(!1),n(!1)},[]),B=r.useCallback(async()=>{var C;if(!h||p)return;const k=++f.current;(C=y.current)==null||C.abort();const D=new AbortController;y.current=D,_(!0),x(null);try{const W=await Ll(h,{signal:D.signal});if(!vt(k,f.current,"",""))return;x(W),W.created>0&&await a()}catch(W){if(!vt(k,f.current,"",""))return;x({error:(W==null?void 0:W.message)||"上传失败"})}finally{vt(k,f.current,"","")&&_(!1)}},[p,h,a]),Z=r.useCallback(async()=>{var W;if(!ai(S,w,p))return;const k=S,D=++f.current;z.current=k,(W=y.current)==null||W.abort();const C=new AbortController;y.current=C,_(!0),G(null),X("");try{const V=await Rl(k,w,{signal:C.signal});if(!vt(D,f.current,k,S))return;G({added:V.added}),P(""),await a()}catch(V){if(!vt(D,f.current,k,S))return;X((V==null?void 0:V.message)||"追加失败")}finally{vt(D,f.current,k,S)&&_(!1)}},[w,S,p,a]),M=r.useCallback(async()=>{await B()},[B]),b=r.useCallback(async()=>{z.current&&S!==z.current||await Z()},[S,Z]);return{showBatchModal:l,setShowBatchModal:n,batchTab:c,setBatchTab:u,batchFile:h,setBatchFile:m,batchResult:N,batchBusy:p,appendTargetId:S,setAppendTargetId:q,appendContent:w,setAppendContent:P,appendResult:A,appendError:H,appendPreview:O,openBatchModal:F,closeBatchModal:d,handleBatchCreate:B,handleBatchAppend:Z,handleRetryBatchCreate:M,handleRetryBatchAppend:b}},xa=()=>({name:"",type:"data",content:"",description:"",enabled:!0,delay_seconds:0,api_method:"GET",api_timeout:10,api_headers:"",api_params:""}),ni=()=>{const{cards:t,loadCards:s}=ri(),[a,l]=r.useState(!1),[n,c]=r.useState(!1),[u,h]=r.useState(null),[m,N]=r.useState({}),[x,p]=r.useState(xa),[_,S]=r.useState(""),[q,w]=r.useState(""),P=r.useMemo(()=>t.filter(d=>d.type==="data"),[t]),A=li({dataCards:P,loadCards:s}),G=d=>{var B,Z,M,b,k;h(d),N({id:d.id,name:d.name||"",type:d.type||"text",api_url:((B=d.api_config)==null?void 0:B.url)||"",api_method:((Z=d.api_config)==null?void 0:Z.method)||"GET",api_timeout:((M=d.api_config)==null?void 0:M.timeout)||10,api_headers:((b=d.api_config)==null?void 0:b.headers)||"",api_params:((k=d.api_config)==null?void 0:k.params)||"",text_content:d.text_content||"",data_content:d.data_content||"",image_url:d.image_url||"",delay_seconds:d.delay_seconds||0,description:d.description||"",enabled:d.enabled}),l(!0)},H=async()=>{var d,B,Z,M,b,k,D,C;if(u){if(!((d=m.name)!=null&&d.trim())){alert("请输入卡密名称");return}if(!m.type){alert("请选择卡密类型");return}try{const W={name:m.name.trim(),type:m.type,description:(B=m.description)==null?void 0:B.trim(),delay_seconds:m.delay_seconds||0,enabled:m.enabled??!0};m.type==="api"?W.api_config={url:((Z=m.api_url)==null?void 0:Z.trim())||"",method:m.api_method,timeout:m.api_timeout||10,headers:((M=m.api_headers)==null?void 0:M.trim())||void 0,params:((b=m.api_params)==null?void 0:b.trim())||void 0}:m.type==="text"?W.text_content=((k=m.text_content)==null?void 0:k.trim())||"":m.type==="data"?W.data_content=((D=m.data_content)==null?void 0:D.trim())||"":m.type==="image"&&(W.image_url=((C=m.image_url)==null?void 0:C.trim())||""),await ta(u.id,W),l(!1),await s()}catch(W){console.error("更新卡密失败:",W),alert("更新失败,请重试")}}},X=async d=>{if(confirm("确认删除该卡密吗?"))try{await Sl(d),await s()}catch(B){console.error("删除卡密失败:",B),alert("删除失败,请重试")}},f=async()=>{if(!x.name.trim()){alert("请输入卡密名称");return}if(!x.content.trim()){alert(x.type==="api"?"请输入 API 地址":"请输入卡密内容");return}try{const d={name:x.name.trim(),type:x.type,description:x.description.trim(),enabled:x.enabled,delay_seconds:x.delay_seconds};x.type==="text"&&(d.text_content=x.content.trim()),x.type==="data"&&(d.data_content=x.content.trim()),x.type==="image"&&(d.image_url=x.content.trim()),x.type==="api"&&(d.api_config={url:x.content.trim(),method:x.api_method,timeout:x.api_timeout,headers:x.api_headers.trim()||void 0,params:x.api_params.trim()||void 0}),await Cl(d),c(!1),p(xa()),await s()}catch(d){console.error("添加卡密失败:",d),alert("添加失败,请重试")}},y=async d=>{try{await ta(d.id,{...d,enabled:!d.enabled}),await s()}catch(B){console.error("切换状态失败:",B)}},z=async d=>{try{await navigator.clipboard.writeText(String(d)),alert(`已复制卡密组ID:${d}`)}catch{prompt("复制卡密组ID",String(d))}},O=r.useMemo(()=>si(t,_,q),[t,q,_]),F=()=>{const Z=[["名称","类型","内容","描述","启用","延迟秒","多规格","规格名","规格值"],...[["VIP月卡","data",`VIP-MONTH-001 VIP-MONTH-002 VIP-MONTH-003`,"按行消费的卡密队列","是","0","否","",""],["感谢文案","text","感谢购买,如有问题联系客服~","固定文本","是","0","否","",""],["教程图","image","https://cdn.example.com/tutorial.jpg","图片URL","是","0","否","",""]]].map(D=>D.map(C=>`"${String(C).replace(/"/g,'""')}"`).join(",")).join(` `),M=new Blob(["\uFEFF"+Z],{type:"text/csv;charset=utf-8"}),b=URL.createObjectURL(M),k=document.createElement("a");k.href=b,k.download="卡密组批量导入模板.csv",document.body.appendChild(k),k.click(),k.remove(),URL.revokeObjectURL(b)};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:A.openBatchModal,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(Mt,{className:"w-5 h-5"}),"批量导入"]}),e.jsxs("button",{onClick:()=>c(!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(nt,{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:"flex flex-col gap-3 border-b border-gray-50 bg-surface-muted p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative sm:w-48",children:[e.jsx(Oa,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按卡密类型筛选",value:_,onChange:d=>S(d.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部类型"}),e.jsx("option",{value:"data",children:"批量卡密"}),e.jsx("option",{value:"text",children:"文本"}),e.jsx("option",{value:"api",children:"API"}),e.jsx("option",{value:"image",children:"图片"})]})]}),e.jsxs("div",{className:"relative w-full sm:max-w-sm",children:[e.jsx(St,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"按卡密名称搜索",placeholder:"搜索卡密名称...",value:q,onChange:d=>w(d.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]})]}),e.jsxs("div",{className:"whitespace-nowrap px-1 text-xs font-bold text-gray-400",children:["显示 ",O.length," / ",t.length," 组"]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full table-fixed 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:"w-[23%] px-5 py-5",children:"卡密名称"}),e.jsx("th",{className:"w-[8%] px-3 py-5",children:"卡密组ID"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"类型"}),e.jsx("th",{className:"w-[27%] px-5 py-5",children:"内容/库存"}),e.jsx("th",{className:"w-[19%] px-5 py-5",children:"描述"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"状态"}),e.jsx("th",{className:"w-[9%] px-3 py-5 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:O.map(d=>{let B="";return d.type==="data"&&d.data_content?B=`库存: ${d.data_content.split(` -`).filter(M=>M.trim()).length} 条`:d.type==="text"&&d.text_content?B=d.text_content:d.type==="api"&&d.api_config?B=d.api_config.url:d.type==="image"&&d.image_url&&(B="图片链接"),e.jsxs("tr",{className:"hover:bg-warning-50/50 transition-colors group",children:[e.jsx("td",{className:"px-5 py-5 align-middle",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"shrink-0 rounded-xl bg-gray-50 p-2 transition-colors group-hover:bg-white",children:e.jsx(ei,{type:d.type})}),e.jsx("span",{className:"line-clamp-3 min-w-0 text-[13px] font-bold leading-5 text-gray-900",title:d.name,children:d.name})]})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("button",{onClick:()=>z(d.id),className:"inline-flex max-w-full items-center gap-1 rounded-lg bg-gray-100 px-2 py-1.5 font-mono text-[11px] font-extrabold text-gray-700 transition-colors hover:bg-gray-200",title:"复制卡密组ID,用于批量铺货表格",children:[e.jsx("span",{className:"truncate",children:d.id}),e.jsx(jr,{className:"h-3 w-3 shrink-0"})]})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("span",{className:`inline-flex rounded-md px-2 py-1 text-[11px] font-bold ${d.type==="text"?"bg-blue-50 text-blue-600":d.type==="data"?"bg-purple-50 text-purple-600":d.type==="api"?"bg-blue-50 text-blue-600":"bg-pink-50 text-pink-600"}`,children:d.type==="text"?"文本":d.type==="data"?"批量":d.type==="api"?"API":"图片"})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"line-clamp-3 break-all font-mono text-sm leading-5 text-gray-600",title:B,children:B})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"block truncate text-sm text-gray-500",title:d.description||"-",children:d.description||"-"})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("button",{onClick:()=>y(d),className:`w-12 h-8 rounded-full relative transition-colors ${d.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 ${d.enabled?"left-5":"left-1"}`})})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[e.jsx("button",{onClick:()=>G(d),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-black",title:"编辑",children:e.jsx(kt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>X(d.id),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500",children:e.jsx(Ze,{className:"h-4 w-4"})})]})})]},d.id)})})]})}),O.length===0&&e.jsxs("div",{className:"py-20 text-center text-gray-400",children:[e.jsx(ka,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:t.length===0?"暂无卡密配置,请点击右上角添加。":"没有符合当前筛选条件的卡密组。"})]})]}),a&&u&&Oe.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:()=>l(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(ke,{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:m.name||"",onChange:d=>N({...m,name:d.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:m.type||"text",onChange:d=>N({...m,type:d.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:"批量数据"}),(u==null?void 0:u.type)==="api"&&e.jsx("option",{value:"api",children:"API接口(仅保留现有配置)"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),m.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:m.api_url||"",onChange:d=>N({...m,api_url:d.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:m.api_method||"GET",onChange:d=>N({...m,api_method:d.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:m.api_timeout||10,onChange:d=>N({...m,api_timeout:parseInt(d.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:m.api_headers||"",onChange:d=>N({...m,api_headers:d.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:m.api_params||"",onChange:d=>N({...m,api_params:d.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"&&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:m.text_content||"",onChange:d=>N({...m,text_content:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none",placeholder:"请输入要发送的固定文字内容..."})]})]}),m.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:m.data_content||"",onChange:d=>N({...m,data_content:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-80 resize-none font-mono text-sm",placeholder:`请输入数据,每行一个: +`).filter(M=>M.trim()).length} 条`:d.type==="text"&&d.text_content?B=d.text_content:d.type==="api"&&d.api_config?B=d.api_config.url:d.type==="image"&&d.image_url&&(B="图片链接"),e.jsxs("tr",{className:"hover:bg-warning-50/50 transition-colors group",children:[e.jsx("td",{className:"px-5 py-5 align-middle",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"shrink-0 rounded-xl bg-gray-50 p-2 transition-colors group-hover:bg-white",children:e.jsx(ti,{type:d.type})}),e.jsx("span",{className:"line-clamp-3 min-w-0 text-[13px] font-bold leading-5 text-gray-900",title:d.name,children:d.name})]})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("button",{onClick:()=>z(d.id),className:"inline-flex max-w-full items-center gap-1 rounded-lg bg-gray-100 px-2 py-1.5 font-mono text-[11px] font-extrabold text-gray-700 transition-colors hover:bg-gray-200",title:"复制卡密组ID,用于批量铺货表格",children:[e.jsx("span",{className:"truncate",children:d.id}),e.jsx(jr,{className:"h-3 w-3 shrink-0"})]})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("span",{className:`inline-flex rounded-md px-2 py-1 text-[11px] font-bold ${d.type==="text"?"bg-blue-50 text-blue-600":d.type==="data"?"bg-purple-50 text-purple-600":d.type==="api"?"bg-blue-50 text-blue-600":"bg-pink-50 text-pink-600"}`,children:d.type==="text"?"文本":d.type==="data"?"批量":d.type==="api"?"API":"图片"})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"line-clamp-3 break-all font-mono text-sm leading-5 text-gray-600",title:B,children:B})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"block truncate text-sm text-gray-500",title:d.description||"-",children:d.description||"-"})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("button",{onClick:()=>y(d),className:`w-12 h-8 rounded-full relative transition-colors ${d.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 ${d.enabled?"left-5":"left-1"}`})})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[e.jsx("button",{onClick:()=>G(d),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-black",title:"编辑",children:e.jsx(kt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>X(d.id),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500",children:e.jsx(Ze,{className:"h-4 w-4"})})]})})]},d.id)})})]})}),O.length===0&&e.jsxs("div",{className:"py-20 text-center text-gray-400",children:[e.jsx(ka,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:t.length===0?"暂无卡密配置,请点击右上角添加。":"没有符合当前筛选条件的卡密组。"})]})]}),a&&u&&Oe.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:()=>l(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(ke,{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:m.name||"",onChange:d=>N({...m,name:d.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:m.type||"text",onChange:d=>N({...m,type:d.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:"批量数据"}),(u==null?void 0:u.type)==="api"&&e.jsx("option",{value:"api",children:"API接口(仅保留现有配置)"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),m.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:m.api_url||"",onChange:d=>N({...m,api_url:d.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:m.api_method||"GET",onChange:d=>N({...m,api_method:d.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:m.api_timeout||10,onChange:d=>N({...m,api_timeout:parseInt(d.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:m.api_headers||"",onChange:d=>N({...m,api_headers:d.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:m.api_params||"",onChange:d=>N({...m,api_params:d.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"&&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:m.text_content||"",onChange:d=>N({...m,text_content:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none",placeholder:"请输入要发送的固定文字内容..."})]})]}),m.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:m.data_content||"",onChange:d=>N({...m,data_content:d.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 或者 @@ -16,5 +16,5 @@ VIP-MONTH-003`,"按行消费的卡密队列","是","0","否","",""],["感谢文 `).filter(d=>d.trim()).length:0})," 条"]})]})]}),m.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:m.image_url||"",onChange:d=>N({...m,image_url:d.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 地址"})]}),m.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:m.image_url,alt:"预览",className:"max-w-full max-h-48 rounded-xl border border-gray-200",onError:d=>{d.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:m.delay_seconds||0,onChange:d=>N({...m,delay_seconds:parseInt(d.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:m.description||"",onChange:d=>N({...m,description:d.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:()=>N({...m,enabled:!m.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${m.enabled?"bg-brand":"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 ${m.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:()=>l(!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:H,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(lt,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body),n&&Oe.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:()=>c(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",title:"关闭",children:e.jsx(ke,{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:x.name,onChange:d=>p({...x,name:d.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-3 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>p({...x,type:"data",content:""}),className:`p-3 rounded-xl font-bold transition-all ${x.type==="data"?"bg-brand text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[e.jsx(Os,{className:"w-5 h-5 mx-auto mb-1"}),"批量库存"]}),e.jsxs("button",{type:"button",onClick:()=>p({...x,type:"text",content:""}),className:`p-3 rounded-xl font-bold transition-all ${x.type==="text"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(Ia,{className:"w-5 h-5 mx-auto mb-1"}),"文本"]}),e.jsxs("button",{type:"button",onClick:()=>p({...x,type:"image",content:""}),className:`p-3 rounded-xl font-bold transition-all ${x.type==="image"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(Aa,{className:"w-5 h-5 mx-auto mb-1"}),"图片"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:x.type==="data"?"库存内容(一行一个)":x.type==="text"?"固定回复内容":x.type==="image"?"图片 URL":"API 地址"}),x.type==="api"?e.jsx("input",{type:"url",value:x.content,onChange:d=>p({...x,content:d.target.value}),placeholder:"https://api.example.com/get-code",className:"w-full ios-input px-4 py-3 rounded-xl"}):x.type==="image"?e.jsx("input",{type:"url",value:x.content,onChange:d=>p({...x,content:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"https://example.com/card.png"}):e.jsx("textarea",{value:x.content,onChange:d=>p({...x,content:d.target.value}),className:`w-full ios-input px-4 py-3 rounded-xl resize-none text-sm ${x.type==="data"?"h-48 font-mono":"h-32"}`,placeholder:x.type==="data"?`CODE-123456 CODE-789012 ...`:"请输入每次发货时发送的固定文字"}),x.type==="data"&&e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-brand",children:x.content.split(` -`).filter(d=>d.trim()).length})," 条"]})]}),x.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:x.api_method,onChange:d=>p({...x,api_method:d.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:x.api_timeout,onChange:d=>p({...x,api_timeout:parseInt(d.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:x.api_headers,onChange:d=>p({...x,api_headers:d.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:x.api_params,onChange:d=>p({...x,api_params:d.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:x.description,onChange:d=>p({...x,description:d.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:x.delay_seconds,onChange:d=>p({...x,delay_seconds:parseInt(d.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:()=>c(!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:f,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(nt,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),e.jsx(Xn,{dataCards:P,downloadCardTemplate:F,...A})]})},ma="ydisks-amap-js-api",ni="c9b68d4ce9a2a97f22a4a439404488ca";let Ot=null;const ii=()=>ni,oi=()=>window.AMap?Promise.resolve(window.AMap):Ot||(Ot=new Promise((t,s)=>{const a=document.getElementById(ma),l=a||document.createElement("script"),n=()=>{window.__ydisksAmapLoaded=void 0,window.clearTimeout(u)},c=()=>{window.AMap?(n(),t(window.AMap)):(n(),s(new Error("高德地图 API 加载完成但未找到 AMap 对象")))},u=window.setTimeout(()=>{n(),s(new Error("高德地图 API 加载超时,请检查网络或 VITE_AMAP_JS_KEY 配置"))},15e3);window.__ydisksAmapLoaded=c,l.id=ma,l.async=!0,l.src=`https://webapi.amap.com/maps?v=2.0&key=${encodeURIComponent(ii())}&plugin=AMap.PlaceSearch&callback=__ydisksAmapLoaded`,l.onerror=()=>{n(),s(new Error("高德地图 API 加载失败,请检查网络或 VITE_AMAP_JS_KEY 配置"))},a||document.head.appendChild(l)}).catch(t=>{throw Ot=null,t}),Ot),ts=t=>Number.isFinite(t)&&t!==0,ci=t=>{var n,c;const s=Number((n=t.location)==null?void 0:n.lng),a=Number((c=t.location)==null?void 0:c.lat),l={area:String(t.adname||"").trim(),city:String(t.cityname||"").trim(),division_id:String(t.adcode||"").trim(),longitude:s,latitude:a,poi_id:String(t.id||"").trim(),poi_name:String(t.name||"").trim(),province:String(t.pname||"").trim()};return!l.division_id||!l.province||!l.city||!l.poi_id||!l.poi_name||!ts(s)||!ts(a)||s<-180||s>180||a<-90||a>90?null:l},di=async(t,s)=>{if(!ts(t)||!ts(s)||t<-180||t>180||s<-90||s>90)throw new Error("经纬度无效");const a=await oi();return new Promise((l,n)=>{new a.PlaceSearch({extensions:"all",pageSize:10}).searchNearBy("",[t,s],1e3,(u,h)=>{var N;if(u!=="complete"){if(u==="no_data"){l([]);return}n(new Error("高德地图附近地址查询失败,请稍后重试"));return}const m=(((N=h==null?void 0:h.poiList)==null?void 0:N.pois)||[]).map(ci).filter(x=>x!==null);l(m)})})},xi=t=>t.find(s=>s.status==="running"||s.status==="canceling"),Rs=t=>t==="running"||t==="canceling",mi=t=>!!(t!=null&&t.preview_id&&Number(t.valid||0)>0),ui=t=>!!(t!=null&&t.id&&Number(t.retryable||0)>0&&!Rs(t.status)),pi=(t,s)=>t===s,ua=t=>{switch(t){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"canceling":return"正在安全取消";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"partially_failed":return"部分失败";case"canceled":return"已取消";default:return t||"-"}},pa=t=>{switch(t){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"}},hi=t=>{const[s,a]=r.useState(!1),[l,n]=r.useState("upload"),[c,u]=r.useState(null),[h,m]=r.useState(null),[N,x]=r.useState(""),[p,_]=r.useState(!1),[S,q]=r.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[w,P]=r.useState(null),[A,G]=r.useState(null),[H,X]=r.useState(null),[f,y]=r.useState([]),[z,O]=r.useState(null),[F,d]=r.useState(!1),B=r.useRef(!1),Z=r.useRef(0),M=r.useCallback(async()=>{n("upload"),P(null),G(null),u(null),m(null),x(""),q({catId:"",catName:"",channelCatId:"",tbCatId:""}),y([]),O(null),a(!0),d(!0);try{const U=await za(20),ae=xi(U);if(ae!=null&&ae.id){const ge=await Nt(ae.id);X(ge),G(ge),n(["running","canceling"].includes(ge.status)?"running":"done")}}catch(U){console.error("恢复最近批量铺货任务失败:",U)}finally{d(!1)}},[]),b=r.useCallback(async()=>{const U=N.trim();if(!t.selectedAccount){alert("请先选择默认发布账号");return}if(!U){alert("请输入类目关键词");return}_(!0);try{const ge=(await zl(t.selectedAccount,U)).category;q({catId:ge.cat_id,catName:ge.cat_name,channelCatId:ge.channel_cat_id,tbCatId:ge.tb_cat_id||""})}catch(ae){console.error("获取推荐类目失败:",ae),alert((ae==null?void 0:ae.message)||"没有匹配到类目,请换一个更具体的关键词")}finally{_(!1)}},[N,t.selectedAccount]),k=r.useCallback(async()=>{if(H!=null&&H.id){d(!0),a(!0);try{const U=await Nt(H.id);G(U),n(["running","canceling"].includes(U.status)?"running":"done")}catch(U){console.error("加载最近批量铺货结果失败:",U)}finally{d(!1)}}},[H==null?void 0:H.id]),D=r.useCallback(async()=>{if(!c){alert("请先上传商品表格");return}if(!t.selectedAccount){alert("请先选择默认发布账号");return}d(!0);try{const U=await Ul({file:c,imagesZip:h,defaultCookieId:t.selectedAccount,fallbackCategory:S,location:z||void 0});P(U),G(null),n("preview")}catch(U){console.error("批量铺货预检失败:",U),alert((U==null?void 0:U.message)||"预检失败,请检查表格和图片 zip")}finally{d(!1)}},[S,c,h,z,t.selectedAccount]),C=r.useCallback(async()=>{if(w!=null&&w.preview_id){if(!mi(w)){alert("没有可发布的商品行");return}d(!0);try{const U=await Wl(w.preview_id),ae=await Nt(U.batch_id||w.preview_id);G(ae),X(ae),n(ae.status==="running"?"running":"done")}catch(U){console.error("启动批量铺货失败:",U),alert((U==null?void 0:U.message)||"启动发布任务失败")}finally{d(!1)}}},[w]),W=r.useCallback(async()=>{if(A!=null&&A.id&&confirm("确认取消当前批量铺货任务吗?正在发布的单个商品可能会继续完成。")){d(!0);try{const U=await Gl(A.id),ae=await Nt(A.id);G(ae),n((U==null?void 0:U.status)==="canceling"||ae.status==="canceling"?"running":"done")}catch(U){alert((U==null?void 0:U.message)||"取消失败")}finally{d(!1)}}},[A==null?void 0:A.id]),V=r.useCallback(async()=>{const U=w==null?void 0:w.preview_id;if(U&&l==="preview")try{await Jl(U)}catch(ae){console.error("清理批量铺货预检失败:",ae)}P(null),n("upload")},[l,w==null?void 0:w.preview_id]),v=r.useCallback(async()=>{await V(),a(!1)},[V]),ee=r.useCallback(async()=>{if(!(!(A!=null&&A.id)||!ui(A))){d(!0);try{await Vl(A.id),G(await Nt(A.id)),n("running")}catch(U){alert((U==null?void 0:U.message)||"重试失败")}finally{d(!1)}}},[A==null?void 0:A.id]);return r.useEffect(()=>{if(!s||!(A!=null&&A.id)||!Rs(A.status))return;const U=++Z.current,ae=async()=>{if(!B.current){B.current=!0;try{const $=await Nt(A.id);if(!pi(U,Z.current))return;G($),X($),Rs($.status)||(n("done"),await Promise.all([t.loadItems(),t.loadShippingRules()]))}catch($){console.error("刷新批量铺货进度失败:",$)}finally{B.current=!1}}},ge=window.setInterval(()=>void ae(),3e3);return(()=>{window.clearInterval(ge),Z.current+=1})},[A==null?void 0:A.id,A==null?void 0:A.status,t.loadItems,t.loadShippingRules,s]),{showBatchModal:s,setShowBatchModal:a,batchLoading:F,batchPhase:l,setBatchPhase:n,batchFile:c,setBatchFile:u,batchImagesZip:h,setBatchImagesZip:m,batchCategoryKeyword:N,setBatchCategoryKeyword:x,batchCategoryLoading:p,batchFallbackCategory:S,setBatchFallbackCategory:q,batchPreview:w,setBatchPreview:P,batchDetail:A,setBatchDetail:G,recentBatch:H,setRecentBatch:X,batchLocations:f,batchLocation:z,setBatchLocations:y,setBatchLocation:O,openBatchModal:M,handleRecommendBatchCategory:b,openRecentBatchResult:k,handlePreviewBatch:D,handleStartBatch:C,handleCancelBatch:W,abandonBatchPreview:V,closeBatchModal:v,handleRetryBatchFailed:ee}},gi=({phase:t})=>{const s=[["upload","1 上传"],["preview","2 预检"],["running","3 发布"],["done","4 结果"]];return e.jsx("div",{className:"grid grid-cols-4 gap-2",children:s.map(([a,l])=>e.jsx("div",{className:`rounded-xl px-3 py-2 text-center text-xs font-extrabold border ${t===a?"bg-blue-600 text-white border-blue-600":"bg-gray-50 text-gray-500 border-gray-100"}`,children:l},a))})},bi=t=>{const s=String(t||"").trim();return s?/^[¥¥]/.test(s)?s:`¥${s}`:"-"},fi=({onConfigureDelivery:t})=>{const[s,a]=r.useState([]),[l,n]=r.useState([]),[c,u]=r.useState([]),[h,m]=r.useState(""),[N,x]=r.useState(""),[p,_]=r.useState(!1),[S,q]=r.useState(!1),[w,P]=r.useState(!1),[A,G]=r.useState(!1),[H,X]=r.useState(!1),[f,y]=r.useState(!1),[z,O]=r.useState([]),[F,d]=r.useState(null),[B,Z]=r.useState(null),[M,b]=r.useState({}),[k,D]=r.useState({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),[C,W]=r.useState({cookie_id:"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),[V,v]=r.useState([]),ee=r.useCallback(async()=>{const o=await Lt();a(o)},[]),be=r.useCallback(async()=>{n(await Ls())},[]),U=hi({selectedAccount:h,loadItems:ee,loadShippingRules:be}),{showBatchModal:ae,setShowBatchModal:ge,batchLoading:$,batchPhase:L,batchFile:Q,setBatchFile:Y,batchImagesZip:re,setBatchImagesZip:ue,batchCategoryKeyword:je,setBatchCategoryKeyword:R,batchCategoryLoading:T,batchFallbackCategory:g,setBatchFallbackCategory:le,batchPreview:oe,batchDetail:ne,recentBatch:de,setRecentBatch:Se,batchLocations:Ee,batchLocation:Te,setBatchLocations:Ue,setBatchLocation:Me,openBatchModal:Be,handleRecommendBatchCategory:Je,openRecentBatchResult:He,handlePreviewBatch:we,handleStartBatch:pe,handleCancelBatch:Ve,abandonBatchPreview:it,closeBatchModal:tt,handleRetryBatchFailed:Qe}=U;r.useEffect(()=>{if(!H||C.images.length===0){v([]);return}const o=C.images.map((K,xe)=>({key:K.name+xe,url:URL.createObjectURL(K)}));return v(o),()=>{o.forEach(K=>URL.revokeObjectURL(K.url))}},[H,C.images]),r.useEffect(()=>{Promise.all([Ft(),Lt(),Ls(),za(20)]).then(([o,K,xe,Le])=>{u(o),a(K),n(xe);const st=Le.find(Ke=>["running","canceling"].includes(Ke.status))||Le.find(Ke=>Ke.status!=="preview");Se(st||null)}).catch(o=>console.error("加载商品配置失败:",o))},[]);const Ge=async()=>{if(!h)return alert("请先选择账号");_(!0);try{const o=await Ml(h);await ee(),alert((o==null?void 0:o.message)||"商品同步完成")}catch(o){console.error("同步商品失败:",o),alert((o==null?void 0:o.message)||"同步失败,请重试")}finally{_(!1)}},ot=o=>{Z(o),b({...o}),P(!0)},pt=async()=>{if(B)try{await Ql(B.cookie_id,B.item_id,{item_title:M.item_title||"",item_description:M.item_description||"",item_category:M.item_category||"",item_price:M.item_price||"",item_detail:M.item_detail||B.item_detail||""}),await ee(),await be(),P(!1),Z(null)}catch(o){console.error("更新商品失败:",o),alert("更新失败,请重试")}},ht=async o=>{if(confirm(`确认删除商品"${o.item_title}"吗?`))try{await ql(o.cookie_id,o.item_id),a(K=>K.filter(xe=>!(xe.cookie_id===o.cookie_id&&xe.item_id===o.item_id)))}catch(K){console.error("删除商品失败:",K),alert("删除失败,请重试")}},J=async()=>{try{if(!k.cookie_id||!k.item_id){alert("请选择账号并填写商品ID");return}await Bl(k.cookie_id,{item_id:k.item_id,item_title:k.item_title,item_price:k.item_price,item_detail:k.item_image?JSON.stringify({item_image:k.item_image}):""}),await ee(),G(!1),D({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""})}catch(o){console.error("添加商品失败:",o),alert("添加失败,请重试")}},ie=async()=>{if(!C.cookie_id)return alert("请选择发布账号");if(!C.title.trim())return alert("请填写商品标题");if(!C.price.trim())return alert("请填写商品价格");if(!C.quantity||Number(C.quantity)<=0)return alert("库存数量必须大于 0");if(C.images.length===0)return alert("至少上传 1 张商品图片");if(C.postage_mode==="fixed"&&!C.postage.trim())return alert("请填写一口价邮费");q(!0);try{const o=await Fl({...C,location:F||void 0});if(await ee(),X(!1),W({cookie_id:h||"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),O([]),d(null),o!=null&&o.item_id){const K={id:o.item_id,cookie_id:C.cookie_id,item_id:o.item_id,item_title:o.item_title||C.title,item_price:o.item_price||C.price,item_image:o.item_image};t(K),alert("商品发布成功,ID: "+o.item_id+",已为你打开发货规则配置")}else alert("商品发布成功")}catch(o){console.error("发布商品失败:",o);const K=o==null?void 0:o.payload;if((K==null?void 0:K.code)==="stock_permission_missing"){alert("发布失败:该账号没有库存发布权限,无法按库存数量发布商品。请换账号或先在闲鱼确认库存能力。");return}alert((o==null?void 0:o.message)||"发布失败,请重试")}finally{q(!1)}},j=()=>{const xe=[["账号ID","标题","描述","价格","原价","库存","邮费模式","邮费","图片","类目ID","类目名称","频道类目ID","淘宝类目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(zt=>zt.map(Ut=>`"${String(Ut).replace(/"/g,'""')}"`).join(",")).join(` -`),Le=new Blob(["\uFEFF"+xe],{type:"text/csv;charset=utf-8"}),st=URL.createObjectURL(Le),Ke=document.createElement("a");Ke.href=st,Ke.download="批量铺货模板.csv",document.body.appendChild(Ke),Ke.click(),Ke.remove(),URL.revokeObjectURL(st)},E=()=>{D(o=>({...o,cookie_id:h||o.cookie_id})),G(!0)},se=()=>{W(o=>({...o,cookie_id:h||o.cookie_id})),X(!0)},ce=async o=>{if(!(o?h:C.cookie_id))return alert("请先选择发布账号");if(!navigator.geolocation)return alert("当前浏览器不支持定位");y(!0),navigator.geolocation.getCurrentPosition(async xe=>{try{const Le=await di(xe.coords.longitude,xe.coords.latitude);if(!Le.length)throw new Error("当前位置附近没有可用的高德发货地,请稍后重试");o?(Ue(Le),Me(Le[0])):(O(Le),d(Le[0]))}catch(Le){alert((Le==null?void 0:Le.message)||"获取发货地失败")}finally{y(!1)}},xe=>{y(!1),alert(xe.code===xe.PERMISSION_DENIED?"定位权限被拒绝,请在浏览器设置中允许定位":"无法获取当前位置,请稍后重试")},{enableHighAccuracy:!0,timeout:15e3,maximumAge:6e4})},fe=o=>l.filter(K=>K.cookie_id===o.cookie_id&&K.item_id===o.item_id).length>0?l.filter(K=>K.cookie_id===o.cookie_id&&K.item_id===o.item_id):l.filter(K=>K.cookie_id===o.cookie_id&&!K.item_id),De=r.useMemo(()=>new Map(c.map(o=>[o.id,o])),[c]),ve=r.useMemo(()=>N?s.filter(o=>o.cookie_id===N):s,[N,s]),Pe=o=>{const K=De.get(o),xe=(K==null?void 0:K.remark)||(K==null?void 0:K.nickname);return xe?`${xe} · ${o.slice(0,6)}`:`账号 ${o.slice(0,8)}`},me=o=>{const K=De.get(o);return(K==null?void 0:K.remark)||(K==null?void 0:K.nickname)||"未命名账号"};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-center gap-4",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 flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-account-filter",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"商品列表筛选"}),e.jsxs("div",{className:"relative",children:[e.jsx(Nr,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-account-filter","aria-label":"按账号筛选商品列表",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:N,onChange:o=>x(o.target.value),children:[e.jsx("option",{value:"",children:"全部账号"}),c.map(o=>e.jsx("option",{value:o.id,children:Pe(o.id)},o.id))]})]})]}),e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-sync-account",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"同步商品账号"}),e.jsxs("div",{className:"relative",children:[e.jsx(yt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-sync-account","aria-label":"选择要同步商品的账号",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:h,onChange:o=>m(o.target.value),children:[e.jsx("option",{value:"",children:"请选择账号"}),c.map(o=>e.jsx("option",{value:o.id,children:Pe(o.id)},o.id))]})]})]}),e.jsxs("button",{onClick:Ge,disabled:p||!h,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(We,{className:`w-4 h-4 ${p?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:E,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(nt,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:se,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-500 text-white hover:bg-emerald-600 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(ls,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:()=>void Be(),className:"px-5 py-3 rounded-2xl font-bold bg-brand text-white hover:bg-brand-highlight transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx(Wt,{className:"w-4 h-4"}),de&&["running","canceling"].includes(de.status)?"继续批量任务":"批量铺货"]}),de&&!["running","canceling"].includes(de.status)&&e.jsx("button",{onClick:()=>void He(),className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"最近批次结果"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:[ve.map(o=>{const K=fe(o),xe=K.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:()=>ot(o),className:"p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md text-gray-600 hover:bg-brand hover:text-white transition-colors",title:"编辑",children:e.jsx(kt,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>ht(o),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(Ze,{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:[o.item_image?e.jsx("img",{src:o.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(va,{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:bi(o.item_price)})]}),e.jsx("h3",{className:"font-bold text-gray-900 line-clamp-2 text-xs mb-1.5 h-8 leading-4",children:o.item_title}),e.jsxs("div",{className:"mb-2 inline-flex min-w-0 max-w-full items-center gap-1 self-start rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700",title:me(o.cookie_id),children:[e.jsx(yt,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:me(o.cookie_id)})]}),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: ",o.item_id]}),e.jsxs("span",{className:`inline-flex items-center gap-1 font-bold ${xe?"text-emerald-600":"text-amber-600"}`,children:[xe?e.jsx(Ns,{className:"w-3 h-3"}):e.jsx(vr,{className:"w-3 h-3"}),xe?`${K.length} 规则`:"未配置"]})]}),e.jsx("div",{className:"space-y-2 mt-auto",children:e.jsxs("button",{onClick:()=>t(o),className:`w-full flex items-center justify-between gap-1 px-2.5 py-2 rounded-lg text-[11px] font-extrabold transition-all ${xe?"bg-gray-900 text-white hover:bg-black":"bg-brand text-white hover:bg-brand-highlight shadow-md shadow-blue-100"}`,children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(_r,{className:"w-3.5 h-3.5"}),xe?"查看发货规则":"关联发货规则"]}),e.jsx(vs,{className:"w-3.5 h-3.5"})]})})]},`${o.cookie_id}-${o.item_id}`)}),ve.length===0&&e.jsxs("div",{className:"col-span-full py-20 text-center text-gray-400",children:[e.jsx(_a,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),N?"该账号暂无商品数据":"暂无商品数据,请选择账号进行同步"]})]}),w&&B&&Oe.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: ",B.item_id]})]}),e.jsx("button",{onClick:()=>P(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(ke,{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:M.item_title||"",onChange:o=>b({...M,item_title:o.target.value})}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"价格",value:M.item_price||"",onChange:o=>b({...M,item_price:o.target.value})}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"分类",value:M.item_category||"",onChange:o=>b({...M,item_category:o.target.value})}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述",value:M.item_description||"",onChange:o=>b({...M,item_description:o.target.value})})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:pt,className:"w-full ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(lt,{className:"w-4 h-4"}),"保存"]})})]})}),document.body),A&&Oe.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:()=>G(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(ke,{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:k.cookie_id,onChange:o=>D({...k,cookie_id:o.target.value}),children:[e.jsx("option",{value:"",children:"选择账号"}),c.map(o=>e.jsx("option",{value:o.id,children:Pe(o.id)},o.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:k.item_id,onChange:o=>D({...k,item_id:o.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:k.item_price,onChange:o=>D({...k,item_price:o.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:k.item_title,onChange:o=>D({...k,item_title:o.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:k.item_image,onChange:o=>D({...k,item_image:o.target.value})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:J,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(nt,{className:"w-4 h-4"}),"添加商品"]})})]})}),document.body),H&&Oe.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:()=>X(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(ke,{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:C.cookie_id,onChange:o=>{W({...C,cookie_id:o.target.value}),O([]),d(null)},children:[e.jsx("option",{value:"",children:"选择账号"}),c.map(o=>e.jsx("option",{value:o.id,children:Pe(o.id)},o.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:C.title,onChange:o=>W({...C,title:o.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:C.quantity,onChange:o=>W({...C,quantity:o.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:C.description,onChange:o=>W({...C,description:o.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:C.price,onChange:o=>W({...C,price:o.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:C.original_price,onChange:o=>W({...C,original_price:o.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:C.postage_mode,onChange:o=>W({...C,postage_mode:o.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:"无需邮寄"})]})]})]}),C.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:C.postage,onChange:o=>W({...C,postage:o.target.value})})]}),e.jsxs("div",{className:"rounded-2xl border border-sky-200 bg-sky-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"发货地(可选)"}),e.jsx("p",{className:"mt-1 text-xs text-sky-800",children:"虚拟商品无需发货地;发布失败时可再定位并作为补充信息提交。"})]}),e.jsxs("button",{type:"button",disabled:f||!C.cookie_id,onClick:()=>void ce(!1),className:"ios-btn-primary flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-bold disabled:opacity-50",children:[e.jsx(Us,{className:"h-4 w-4"}),f?"定位中...":"获取当前位置"]})]}),z.length>0&&e.jsx("select",{className:"w-full ios-input rounded-xl bg-white px-4 py-3",value:String(Math.max(0,z.indexOf(F))),onChange:o=>d(z[Number(o.target.value)]||null),children:z.map((o,K)=>e.jsx("option",{value:String(K),children:[o.province,o.city,o.area,o.poi_name].filter(Boolean).join(" ")},`${o.division_id}-${o.poi_id}-${K}`))})]}),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(Wt,{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:C.images.length?"已选择 "+C.images.length+" 张":"支持 JPG / PNG / GIF"}),e.jsx("input",{className:"hidden",type:"file",accept:"image/*",multiple:!0,onChange:o=>W({...C,images:Array.from(o.target.files||[]).slice(0,9)})})]}),V.length>0&&e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-3",children:V.map(o=>e.jsx("div",{className:"aspect-square rounded-xl bg-gray-100 overflow-hidden border border-gray-100",children:e.jsx("img",{src:o.url,alt:"",className:"w-full h-full object-cover"})},o.key))})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{disabled:S,onClick:ie,className:"w-full bg-emerald-500 hover:bg-emerald-600 disabled:opacity-60 text-white px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ls,{className:"w-4 h-4"}),S?"正在发布...":"发布到闲鱼"]})})]})}),document.body),ae&&Oe.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:()=>void tt(),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(ke,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx(gi,{phase:L}),L==="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:j,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:h,onChange:o=>{m(o.target.value),Ue([]),Me(null)},children:[e.jsx("option",{value:"",children:"选择账号"}),c.map(o=>e.jsx("option",{value:o.id,children:Pe(o.id)},o.id))]}),e.jsx("p",{className:"text-xs text-gray-500",children:"表格中“账号ID”为空时,会使用这里选择的账号。"})]}),e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50/70 p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-extrabold text-gray-900",children:["默认类目 ",e.jsx("span",{className:"font-medium text-gray-500",children:"(可为空)"})]}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-amber-800",children:"填写后优先使用该类目;留空时由闲鱼根据每件商品自动识别。仍无法识别时,系统最终使用“电子资料”兜底。"})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsxs("label",{className:"relative flex-1",children:[e.jsx("span",{className:"sr-only",children:"类目关键词"}),e.jsx(St,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{className:"w-full ios-input rounded-xl bg-white py-2.5 pl-10 pr-3",placeholder:"输入关键词,例如:课程资料、设计素材",value:je,onChange:o=>R(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),Je())}})]}),e.jsxs("button",{type:"button",disabled:!h||!je.trim()||T,onClick:()=>void Je(),className:"ios-btn-primary flex min-h-[42px] items-center justify-center gap-2 rounded-xl px-4 text-sm font-bold disabled:opacity-50",children:[e.jsx(St,{className:"h-4 w-4"}),T?"匹配中...":"获取类目"]})]}),g.catId?e.jsxs("div",{className:"flex min-h-[46px] items-center justify-between gap-3 border-t border-amber-200 pt-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-bold text-gray-900",children:[e.jsx(Ns,{className:"h-4 w-4 shrink-0 text-emerald-600"}),e.jsx("span",{className:"truncate",children:g.catName})]}),e.jsxs("div",{className:"mt-1 font-mono text-xs text-gray-500",children:["类目 ",g.catId," · 频道 ",g.channelCatId]})]}),e.jsx("button",{type:"button",title:"清除默认类目",onClick:()=>le({catId:"",catName:"",channelCatId:"",tbCatId:""}),className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-gray-500 hover:bg-white hover:text-gray-900",children:e.jsx(ke,{className:"h-4 w-4"})})]}):null]}),e.jsxs("div",{className:"rounded-xl border border-sky-200 bg-sky-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"批次发货地(可选)"}),e.jsx("p",{className:"mt-1 text-xs text-sky-800",children:"虚拟商品可留空;填写后整个批次使用同一个发货地,并随任务保存用于恢复和重试。"})]}),e.jsxs("button",{type:"button",disabled:f||!h,onClick:()=>void ce(!0),className:"ios-btn-primary flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-bold disabled:opacity-50",children:[e.jsx(Us,{className:"h-4 w-4"}),f?"定位中...":"获取当前位置"]})]}),Ee.length>0&&e.jsx("select",{className:"w-full ios-input rounded-xl bg-white px-4 py-3",value:String(Math.max(0,Ee.indexOf(Te))),onChange:o=>Me(Ee[Number(o.target.value)]||null),children:Ee.map((o,K)=>e.jsx("option",{value:String(K),children:[o.province,o.city,o.area,o.poi_name].filter(Boolean).join(" ")},`${o.division_id}-${o.poi_id}-${K}`))})]}),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(Wt,{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:Q?Q.name:"支持 .xlsx / .csv / .tsv"}),e.jsx("input",{className:"hidden",type:"file",accept:".xlsx,.csv,.tsv",onChange:o=>{var K;return Y(((K=o.target.files)==null?void 0:K[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(Wt,{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:re?re.name:"表格图片字段使用 zip 内相对路径"}),e.jsx("input",{className:"hidden",type:"file",accept:".zip",onChange:o=>{var K;return ue(((K=o.target.files)==null?void 0:K[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","需要覆盖默认账号时填写","上方默认发布账号为必选;本列留空时使用默认账号,填写后仅覆盖当前行"],["标题","每个商品都要填","填写买家能看到的商品标题"],["描述","可以留空","留空时会使用商品标题作为描述"],["价格","每个商品都要填","只填数字,例如 19.90"],["原价","可以留空","需要展示划线原价时填写,例如 29.90"],["库存","可以留空","留空按 1 件处理;填写时必须大于 0"],["邮费模式","可以留空","留空表示包邮;包邮填 free,固定邮费填 fixed"],["邮费","邮费模式填 fixed 时填写","只填数字,例如 8.00"],["图片","每个商品都要填","填写 zip 内图片路径或图片网址;多张图片用英文分号隔开"],["类目ID","需要指定当前行默认类目时填写","必须和“类目名称、频道类目ID”同时填写;优先于自动识别"],["类目名称","填写了“类目ID”时必填","填写该 ID 对应的准确类目名称"],["频道类目ID","覆盖类目时必填","必须填写闲鱼返回的准确频道类目 ID"],["淘宝类目ID","按闲鱼返回填写","“电子资料”无淘宝类目 ID,保持为空"],["付款发货启用","需要付款后自动发货时填写","填“是”表示开启;不需要时填“否”或留空"],["付款发货内容","“付款发货启用”填“是”时填写","从“卡密库存”页面取得卡密组 ID,按上方示例填写"],["评价赠品启用","需要评价赠品时填写","填“是”表示开启;不需要时填“否”或留空"],["评价赠品内容","“评价赠品启用”填“是”时填写","格式和付款发货内容相同,也可以同时发送多个卡密组"],["求评价启用","需要自动求评价时填写","填“是”表示开启;不需要时填“否”或留空"],["求评价等待小时","“求评价启用”填“是”时填写","填写等待小时数;留空按 72 小时处理"],["求评价文案","“求评价启用”填“是”时填写","填写要发送给买家的求评价消息"],["求评价最多次数","可以留空","留空只提醒 1 次"]].map(([o,K,xe])=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-bold text-gray-900 whitespace-nowrap",children:o}),e.jsx("td",{className:`px-3 py-2 min-w-[210px] font-bold ${K==="每个商品都要填"?"text-red-600":K==="可以留空"?"text-gray-500":"text-amber-700"}`,children:K}),e.jsx("td",{className:"px-3 py-2 min-w-[260px]",children:xe})]},o))})]})})]})]}),L==="preview"&&oe&&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:oe.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:oe.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:oe.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("th",{className:"px-4 py-3",children:"问题"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:oe.rows.map(o=>{var K,xe,Le,st;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:o.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 ${o.valid?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-red-50 text-red-700 border-red-100"}`,children:o.valid?"可发布":"需修正"})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[240px] truncate",children:o.title||"-"}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:["¥",o.price||"-"," / ",o.quantity||1]}),e.jsxs("td",{className:"px-4 py-3 text-xs text-gray-600 min-w-[150px]",children:[e.jsx("div",{className:"font-bold text-gray-800",children:((K=o.category)==null?void 0:K.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((xe=o.category)==null?void 0:xe.cat_id)||"失败后使用电子资料"})]}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:[((Le=o.images)==null?void 0:Le.length)||0," 张"]}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[280px]",children:((st=o.errors)==null?void 0:st.join(";"))||"-"})]},o.row_no)})})]})})]}),(L==="running"||L==="done")&&ne&&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 ${pa(ne.status)}`,children:[e.jsx("div",{className:"text-xs font-bold opacity-70",children:"任务状态"}),e.jsx("div",{className:"text-xl font-extrabold mt-1",children:ua(ne.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:ne.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:ne.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:ne.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:ne.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:"类目策略"}),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:ne.rows.map(o=>{var K,xe;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:o.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 ${pa(o.status)}`,children:ua(o.status)})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[260px] truncate",children:o.title}),e.jsxs("td",{className:"px-4 py-3 text-xs text-gray-600 min-w-[150px]",children:[e.jsx("div",{className:"font-bold text-gray-800",children:((K=o.category)==null?void 0:K.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((xe=o.category)==null?void 0:xe.cat_id)||"失败后使用电子资料"})]}),e.jsx("td",{className:"px-4 py-3 text-xs font-mono",children:o.item_url?e.jsx("a",{href:o.item_url,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline",children:o.item_id}):o.item_id||"-"}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[340px]",children:o.error_message||"-"})]},o.id)})})]})})]})]}),e.jsxs("div",{className:"modal-footer",children:[L==="upload"&&e.jsxs("button",{disabled:$||!Q||!h,onClick:we,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(We,{className:`w-4 h-4 ${$?"animate-spin":""}`}),$?"正在预检...":"开始预检"]}),L==="preview"&&oe&&e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{disabled:$,onClick:()=>void it(),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:$||oe.valid<=0,onClick:pe,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(ls,{className:"w-4 h-4"}),$?"启动中...":`确认发布 ${oe.valid} 个商品`]})]}),(L==="running"||L==="done")&&ne&&e.jsxs("div",{className:"flex gap-3 w-full",children:[ne.status==="running"?e.jsx("button",{disabled:$,onClick:Ve,className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"取消任务"}):ne.status==="canceling"?e.jsx("button",{disabled:!0,className:"flex-1 px-6 py-3.5 rounded-xl bg-amber-100 text-amber-800 font-bold",children:"正在保存远端结果并安全取消…"}):e.jsx("button",{onClick:()=>window.open(`/api/v1/items/publish-batches/${ne.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:"下载结果"}),ne.retryable>0&&!["running","canceling"].includes(ne.status)&&e.jsxs("button",{disabled:$,onClick:Qe,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(We,{className:`w-4 h-4 ${$?"animate-spin":""}`}),"重试失败项"]}),!["running","canceling"].includes(ne.status)&&e.jsx("button",{onClick:()=>{ge(!1),ee(),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)]})},Ha="https://dashscope.aliyuncs.com/compatible-mode/v1",yi=[{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warn"},{value:"error",label:"Error"}],ji=new Set(["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from","smtp_from_name","smtp_from_address","registration_enabled","show_default_login_info","login_captcha_enabled","item_sync_enabled","item_sync_interval","item_sync_max_pages","default_reply"]),Ni=t=>Object.fromEntries(Object.entries(t).filter(([s,a])=>!ji.has(s)&&a!==void 0&&a!==null)),vi=t=>t.new_username.trim().length<3?"用户名至少需要 3 个字符":t.current_password?t.new_password&&t.new_password.length<8?"新密码至少需要 8 个字符":t.new_password!==t.confirm_password?"两次输入的新密码不一致":"":"请输入当前密码确认身份",rt=(t,s,a)=>t===s&&!a.aborted,Gt=t=>t instanceof Error&&t.message==="请求已取消",Vt=(t,s)=>t instanceof Error?t.message:s,_i=(t="")=>({new_username:t,current_password:"",new_password:"",confirm_password:""}),Qt=(t,s)=>({type:t,text:s}),wi=()=>{const[t,s]=r.useState(null),[a,l]=r.useState(!1),[n,c]=r.useState(""),[u,h]=r.useState(!1),[m,N]=r.useState(""),[x,p]=r.useState([]),[_,S]=r.useState(!1),[q,w]=r.useState(""),[P,A]=r.useState(!1),[G,H]=r.useState(!1),[X,f]=r.useState(!1),[y,z]=r.useState(!1),[O,F]=r.useState(!1),[d,B]=r.useState(!1),[Z,M]=r.useState(null),[b,k]=r.useState(()=>_i()),[D,C]=r.useState("idle"),W=r.useRef(null),V=r.useRef(null),v=r.useRef(0),ee=r.useRef(null);V.current=t;const be=r.useCallback(()=>{var Q;(Q=ee.current)==null||Q.abort();const L=new AbortController;return ee.current=L,v.current+=1,{controller:L,sequence:v.current}},[]),U=r.useCallback(async(L,Q=!1,Y)=>{const re=L||V.current,ue=(re==null?void 0:re.ai_api_url)||(re==null?void 0:re.ai_base_url)||Ha;S(!0),w("");try{const je=await cn(ue,(re==null?void 0:re.ai_api_key)||"",{signal:Y});if(Y!=null&&Y.aborted)return;p(je),A(Q&&je.length>0),!(re!=null&&re.ai_model)&&je.length>0&&s(R=>R&&{...R,ai_model:je[0]})}catch(je){if(Y!=null&&Y.aborted||Gt(je))return;p([]),A(!1),w(Vt(je,"读取模型失败"))}finally{Y!=null&&Y.aborted||S(!1)}},[]),ae=r.useCallback(()=>{const{controller:L,sequence:Q}=be();l(!0),C("loading"),c(""),Promise.all([Wa({signal:L.signal}),qa({signal:L.signal})]).then(([Y,re])=>{rt(v.current,Q,L.signal)&&(s(Y),re.username&&k(ue=>({...ue,new_username:re.username||""})),U(Y,!1,L.signal),C("success"))}).catch(Y=>{!rt(v.current,Q,L.signal)||Gt(Y)||(s(null),c(Vt(Y,"加载配置失败")),C("error"))}).finally(()=>{rt(v.current,Q,L.signal)&&l(!1)})},[be,U]);r.useEffect(()=>(ae(),()=>{var L;return(L=ee.current)==null?void 0:L.abort()}),[ae]),r.useEffect(()=>{const L=Q=>{var Y;(Y=W.current)!=null&&Y.contains(Q.target)||A(!1)};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[]);const ge=r.useCallback(async()=>{if(!t||u)return;const{controller:L,sequence:Q}=be();h(!0),N("");try{if(await Ja(Ni(t),{signal:L.signal}),!rt(v.current,Q,L.signal))return;window.alert("系统配置已保存")}catch(Y){if(!rt(v.current,Q,L.signal)||Gt(Y))return;N(Vt(Y,"保存配置失败"))}finally{rt(v.current,Q,L.signal)&&h(!1)}},[be,u,t]),$=r.useCallback(async L=>{L.preventDefault(),M(null);const Q=vi(b);if(Q){M(Qt("error",Q));return}const{controller:Y,sequence:re}=be();B(!0);try{const ue=await ll({current_password:b.current_password,new_username:b.new_username.trim(),new_password:b.new_password||void 0},{signal:Y.signal});if(!rt(v.current,re,Y.signal))return;if(!ue.success){M(Qt("error",ue.message||"登录凭据更新失败"));return}M(Qt("success",ue.message||"登录凭据已更新")),window.setTimeout(()=>window.location.reload(),1400)}catch(ue){if(!rt(v.current,re,Y.signal)||Gt(ue))return;M(Qt("error",Vt(ue,"登录凭据更新失败")))}finally{rt(v.current,re,Y.signal)&&B(!1)}},[be,b]);return{settings:t,loading:a,loadError:n,saving:u,saveError:m,aiModels:x,modelsLoading:_,modelError:q,modelDropdownOpen:P,showApiKey:G,showCaptchaSecret:X,showCurrentPassword:y,showNewPassword:O,credentialsSaving:d,credentialsMessage:Z,credentials:b,requestStatus:D,modelPickerRef:W,loadSettings:ae,loadAIModels:(L,Q)=>void U(L,Q),handleSave:ge,handleCredentialsSave:$,setSettings:s,setModelDropdownOpen:A,setShowApiKey:H,setShowCaptchaSecret:f,setShowCurrentPassword:z,setShowNewPassword:F,setCredentials:k,setCredentialsMessage:M}},ki=()=>{const{settings:t,loading:s,loadError:a,saving:l,saveError:n,aiModels:c,modelsLoading:u,modelError:h,modelDropdownOpen:m,showApiKey:N,showCaptchaSecret:x,showCurrentPassword:p,showNewPassword:_,credentialsSaving:S,credentialsMessage:q,credentials:w,modelPickerRef:P,loadSettings:A,loadAIModels:G,handleSave:H,handleCredentialsSave:X,setSettings:f,setModelDropdownOpen:y,setShowApiKey:z,setShowCaptchaSecret:O,setShowCurrentPassword:F,setShowNewPassword:d,setCredentials:B}=wi();if(!t)return e.jsxs("div",{className:"p-8 text-center text-gray-400 space-y-3",children:[a||(s?"加载配置中...":"暂无配置"),!s&&a&&e.jsx("div",{children:e.jsx("button",{type:"button",className:"ios-btn-primary px-4 py-2 rounded-xl",onClick:A,children:"重新加载"})})]});const Z=t.ai_model||"",M=c;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(Ps,{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:A,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(We,{className:"w-4 h-4"}),"刷新"]})]}),n&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm text-red-700",children:[e.jsx("span",{children:n}),e.jsx("button",{type:"button",className:"font-bold underline",onClick:()=>{},children:"重试保存"})]}),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(wr,{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:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"日志输出等级"}),e.jsx("select",{value:t.log_level||"info",onChange:b=>f({...t,log_level:b.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:yi.map(b=>e.jsx("option",{value:b.value,children:b.label},b.value))}),e.jsx("p",{className:"text-xs text-gray-500",children:"等级越低输出越详细,Debug 适合排查问题"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"日志输出格式"}),e.jsxs("select",{value:t.log_format||"text",onChange:b=>f({...t,log_format:b.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"text",children:"Text"}),e.jsx("option",{value:"json",children:"JSON"})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"JSON 适合接入集中式日志系统,保存后需重启服务生效"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"续期日志保留天数"}),e.jsx("input",{type:"number",value:t.renewal_log_retention_days??10,onChange:b=>f({...t,renewal_log_retention_days:parseInt(b.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"365"}),e.jsx("p",{className:"text-xs text-gray-500",children:"0 表示不自动清理续期日志"})]})]})]}),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-brand text-white",children:e.jsx(Ds,{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:t.ai_api_url||Ha,onChange:b=>f({...t,ai_api_url:b.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:N?"text":"password",value:t.ai_api_key||"",onChange:b=>f({...t,ai_api_key:b.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:()=>z(!N),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:N?e.jsx(bt,{className:"w-4 h-4"}):e.jsx(mt,{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:P,className:"relative flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("input",{value:Z,onFocus:()=>c.length>0&&y(!0),onChange:b=>{f({...t,ai_model:b.target.value}),c.length>0&&y(!0)},onKeyDown:b=>{b.key==="Escape"&&y(!1),b.key==="ArrowDown"&&c.length>0&&y(!0)},className:"w-full ios-input px-4 py-3 pr-10 rounded-xl",placeholder:"从接口读取或手动输入模型名"}),e.jsx("button",{type:"button",onClick:()=>c.length>0&&y(b=>!b),disabled:c.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(kr,{className:`w-4 h-4 transition-transform ${m?"rotate-180":""}`})}),m&&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:M.length>0?M.map(b=>e.jsxs("button",{type:"button",onClick:()=>{f({...t,ai_model:b}),y(!1)},className:"w-full px-4 py-2.5 text-left text-sm text-gray-700 hover:bg-blue-50 hover:text-brand flex items-center justify-between gap-3",children:[e.jsx("span",{className:"truncate",children:b}),b===Z&&e.jsx(Ye,{className:"w-4 h-4 shrink-0 text-brand"})]},b)):e.jsx("div",{className:"px-4 py-3 text-sm text-gray-400",children:"没有匹配的模型"})})]}),e.jsxs("button",{type:"button",onClick:()=>G(void 0,!0),disabled:u,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(We,{className:`w-4 h-4 ${u?"animate-spin":""}`}),"读取模型"]})]}),h?e.jsx("p",{className:"text-xs text-red-500",children:h}):e.jsx("p",{className:"text-xs text-gray-500",children:c.length>0?`已从当前 API 地址读取到 ${c.length} 个模型`:"模型列表从当前 API 地址读取,也可以手动输入模型名"})]}),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.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-amber-500 text-white",children:e.jsx(qt,{className:"w-4 h-4"})}),"远程过滑块配置"]}),e.jsxs("div",{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.jsx("input",{type:"url",value:t["captcha.remote_service_url"]||"",onChange:b=>f({...t,"captcha.remote_service_url":b.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"https://example.com/internal/captcha/solve"})]}),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:x?"text":"password",value:t["captcha.remote_secret_key"]||"",onChange:b=>f({...t,"captcha.remote_secret_key":b.target.value}),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl font-mono text-sm",autoComplete:"off"}),e.jsx("button",{type:"button",onClick:()=>O(!x),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:x?"隐藏秘钥":"显示秘钥",children:x?e.jsx(bt,{className:"w-4 h-4"}):e.jsx(mt,{className:"w-4 h-4"})})]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-xl bg-amber-50 p-4 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:String(t["captcha.remote_pass_cookies"]||"").toLowerCase()==="true",onChange:b=>f({...t,"captcha.remote_pass_cookies":b.target.checked}),className:"mt-0.5 w-4 h-4 rounded border-gray-300"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-bold text-amber-900",children:"允许向远程服务传递账号 Cookie"}),e.jsx("span",{className:"block mt-1 text-xs text-amber-700",children:"默认关闭。仅在信任远程服务且需要由其自动重取过期验证链接时开启。"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",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(Ws,{className:"w-4 h-4"})}),"登录凭据"]}),e.jsxs("form",{onSubmit:X,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(Zt,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",value:w.new_username,onChange:b=>B({...w,new_username:b.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:p?"text":"password",value:w.current_password,onChange:b=>B({...w,current_password:b.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:()=>F(!p),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:p?"隐藏密码":"显示密码",children:p?e.jsx(bt,{className:"w-4 h-4"}):e.jsx(mt,{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:_?"text":"password",value:w.new_password,onChange:b=>B({...w,new_password:b.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:()=>d(!_),className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:_?"隐藏密码":"显示密码",children:_?e.jsx(bt,{className:"w-4 h-4"}):e.jsx(mt,{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:_?"text":"password",value:w.confirm_password,onChange:b=>B({...w,confirm_password:b.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(qt,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:q.text})]}),e.jsxs("button",{type:"submit",disabled:S||!w.new_username||!w.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(Ws,{className:"w-4 h-4"}),S?"正在更新...":"更新登录凭据"]})]})]})]})]}),e.jsx("div",{className:"fixed bottom-10 right-10 z-30",children:e.jsxs("button",{onClick:H,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:[e.jsx(lt,{className:"w-6 h-6"}),l?"保存中...":"保存所有配置"]})})]})},us=(t,s)=>t.allowed_resolutions.includes(s),Ci=(t,s)=>({runs:t.runs.filter(a=>!s||a.cookie_id===s),pending_tasks:t.pending_tasks.filter(a=>!s||a.cookie_id===s)}),Si=t=>({external_result_unknown:"外部动作结果未知",invalid_snapshot:"历史数据无法恢复",rule_unavailable:"规则不可用",partial_failure:"部分动作失败",execution_failed:"动作执行失败"})[t]||"自动化异常",Li=({runs:t,pendingTasks:s,onResolveRun:a,onResolveDeferredTask:l})=>e.jsxs("section",{className:"rounded-2xl border border-red-200 bg-red-50 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ut,{className:"w-5 h-5 text-red-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-black text-red-900",children:"需要人工处理的自动化任务"}),e.jsx("p",{className:"text-sm text-red-700 mt-1",children:"请先在闲鱼聊天、订单或商品列表中核对真实结果,再选择继续或重试。"})]})]}),e.jsxs("div",{className:"space-y-3",children:[t.map(n=>e.jsxs("div",{className:"rounded-xl border border-red-100 bg-white p-4 flex flex-col lg:flex-row lg:items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-bold text-gray-900",children:["账号 ",n.cookie_id," · 订单 ",n.order_id||"-"," · 已记录发送 ",n.sent_count," 条"]}),e.jsx("div",{className:"text-xs font-bold text-red-800 mt-1",children:Si(n.issue_kind)}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:n.error_message})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 shrink-0",children:[us(n,"continue")&&e.jsx("button",{onClick:(()=>a(n.id,"continue")),className:"px-3 py-2 rounded-lg bg-emerald-100 text-emerald-800 text-xs font-bold",children:"已执行,继续下一步"}),us(n,"retry")&&e.jsx("button",{onClick:(()=>a(n.id,"retry")),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"未执行,安全重试"}),us(n,"cancel")&&e.jsx("button",{onClick:(()=>a(n.id,"cancel")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"终止"})]})]},`run-${n.id}`)),s.map(n=>e.jsxs("div",{className:"rounded-xl border border-red-100 bg-white p-4 flex flex-col lg:flex-row lg:items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-bold text-gray-900",children:["账号 ",n.cookie_id," · 延迟任务重试已达 ",n.attempt_count," 次"]}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:n.error_message})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[e.jsx("button",{onClick:(()=>l(n.id,"retry")),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"重新入队"}),e.jsx("button",{onClick:(()=>l(n.id,"dismiss")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"忽略"})]})]},`task-${n.id}`))]})]}),ps=()=>({submitting:!1,result:"idle"}),hs=t=>t.submitting?t:{submitting:!0,result:"idle"},gs=(t,s)=>({submitting:!1,result:s?"success":"failure"}),ha=t=>t+1,bs=(t,s,a,l)=>t===s&&a===l,Ri=t=>{const[s,a]=r.useState([]),[l,n]=r.useState({runs:[],pending_tasks:[]}),[c,u]=r.useState([]),[h,m]=r.useState({}),[N,x]=r.useState([]),[p,_]=r.useState([]),[S,q]=r.useState([]),[w,P]=r.useState(!1),A=r.useRef(0),G=r.useRef(0),[H,X]=r.useState(0),[f,y]=r.useState(0),[z,O]=r.useState({}),F=r.useCallback(async()=>{const k=Promise.all([Ft(),Ms(),Lt(),la()]),[D,C,W,V]=await k;x(D),_(C),q(W),m(V),t.setSelectedAccountId(v=>{var ee;return v||((ee=D[0])==null?void 0:ee.id)||""})},[t.setSelectedAccountId]),d=r.useCallback(async()=>{var V;const k=ha(A.current);A.current=k;const D=Yl().catch(v=>(console.warn("加载自动化异常列表失败,不阻断规则展示",v),null)),C=await Kl({cookieId:t.selectedAccountId||void 0,triggerType:t.automationTriggerFilter,enabled:t.automationStatusFilter==="all"?void 0:t.automationStatusFilter==="enabled",search:t.debouncedAutomationSearch,page:t.automationPage,pageSize:t.automationPageSize});if(!bs(k,A.current,t.selectedAccountId,t.selectedAccountId))return;a(C.data),X(C.total),y(C.total_pages),O(C.trigger_counts||{}),C.page!==t.automationPage&&((V=t.onAutomationPageChange)==null||V.call(t,C.page));const W=await D;bs(k,A.current,t.selectedAccountId,t.selectedAccountId)&&W&&n(W)},[t.automationPage,t.automationPageSize,t.automationStatusFilter,t.automationTriggerFilter,t.debouncedAutomationSearch,t.onAutomationPageChange,t.selectedAccountId]),B=r.useCallback(async()=>{const k=ha(G.current);G.current=k;const D=t.selectedAccountId;if(u([]),!D)return;const C=await an(D);bs(k,G.current,D,t.selectedAccountId)&&u(C)},[t.selectedAccountId]),Z=r.useCallback(async()=>{m(await la())},[]),M=r.useCallback(async()=>{P(!0);try{t.activeTab==="automation"?await d():t.activeTab==="reply"?await B():await Z()}finally{P(!1)}},[d,Z,B,t.activeTab]);return{automationRules:s,automationIssues:l,replyRules:c,defaultReplies:h,accounts:N,cards:p,items:S,automationTotal:H,automationTotalPages:f,automationTriggerCounts:z,loading:w,setLoading:P,setAutomationRules:a,setCards:_,setItems:q,loadReferenceData:F,loadAutomationRules:d,loadReplyRules:B,loadDefaultReplies:Z,refresh:M}},xt={order_paid:{label:"付款后自动发货",shortLabel:"自动发货",description:"闲鱼付款系统卡片进入自动化中心后,先发送卡密,成功后再确认发货。",flow:["付款系统卡片","匹配商品/规格","发送卡密","确认发货"],accent:"blue",icon:Bt},buyer_reviewed:{label:"评价后发送赠品",shortLabel:"评价赠品",description:"闲鱼评价系统卡片进入自动化中心后,给买家发送赠品卡密。",flow:["评价系统卡片","匹配商品/规格","发送赠品"],accent:"emerald",icon:Cr},review_missing_timeout:{label:"超时未评价求评价",shortLabel:"求评价",description:"计划任务扫描已发货未评价订单,到期后发送求评价文案。",flow:["计划任务扫描","已发货未评价","达到等待时间","发送提醒"],accent:"amber",icon:Pa}},Kt=["order_paid","buyer_reviewed","review_missing_timeout"],Ai="亲,商品使用满意的话,麻烦给个评价,谢谢~",Pt=()=>({spec_name:"",spec_value:"",card_id:0,delivery_count:1,enabled:!0,delay_override:!1,delay_seconds:0}),Za=t=>{if(!t)return{};try{const s=JSON.parse(t);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}},gt=(t,s={})=>{const a=Za(t);return JSON.stringify({after_shipped_hours:Number(a.after_shipped_hours||72),repeat_interval_hours:Number(a.repeat_interval_hours||24),max_attempts:Number(a.max_attempts||1),...s})},Tt=(t,s)=>{var l;const a=((l=xt[t])==null?void 0:l.label)||"自动化规则";return s?`${a} - ${s}`:a},ga=t=>{const s=(t||"").trim();return s?Object.values(xt).some(a=>s===a.label||s.startsWith(`${a.label} -`)):!0},Et=(t,s=0)=>{if(t==="review_missing_timeout")return[{action_type:"send_text",message_template:Ai,enabled:!0,sort_order:1}];const a={action_type:"send_card",card_id:s,delivery_count:1,enabled:!0,sort_order:1};return t==="order_paid"?[a,{action_type:"confirm_shipment",enabled:!0,sort_order:2}]:[a]},Ii=t=>{var a,l;if(t.trigger_type==="review_missing_timeout")return((l=(a=t.actions)==null?void 0:a.find(n=>n.action_type==="send_text"))==null?void 0:l.message_template)||"发送求评价文案";const s=(t.actions||[]).filter(n=>n.action_type==="send_card");return s.length?s.map(n=>n.card_name||`卡密 ${n.card_id}`).join(" / "):"未配置卡密库存"},ba=(t,s=!1)=>{const a={blue:s?"border-blue-500 bg-blue-50 text-blue-700":"border-blue-100 bg-blue-50/60 text-blue-700 hover:border-blue-300",emerald:s?"border-emerald-500 bg-emerald-50 text-emerald-700":"border-emerald-100 bg-emerald-50/60 text-emerald-700 hover:border-emerald-300",amber:s?"border-amber-500 bg-amber-50 text-amber-700":"border-amber-100 bg-amber-50/60 text-amber-700 hover:border-amber-300"};return a[t]||a.blue},Oi=t=>t?"bg-emerald-100 text-emerald-700":"bg-gray-200 text-gray-500",Ht=t=>(t==null?void 0:t.nickname)||(t==null?void 0:t.remark)||(t==null?void 0:t.id)||"未知账号",Pi=t=>t===!0||t===1||t==="1",Ti=({initialDeliveryTarget:t,onDeliveryTargetHandled:s})=>{var Ke,zt,Ut;const[a,l]=r.useState("automation"),[n,c]=r.useState(""),[u,h]=r.useState(""),[m,N]=r.useState(""),[x,p]=r.useState(""),[_,S]=r.useState("all"),[q,w]=r.useState(1),[P,A]=r.useState(10),G=Ri({activeTab:a,selectedAccountId:n,automationTriggerFilter:x,automationStatusFilter:_,debouncedAutomationSearch:m,automationPage:q,automationPageSize:P,setSelectedAccountId:c,onAutomationPageChange:w}),{automationRules:H,automationIssues:X,replyRules:f,defaultReplies:y,accounts:z,cards:O,items:F,loading:d,setLoading:B,automationTotal:Z,automationTotalPages:M,automationTriggerCounts:b,setAutomationRules:k,setCards:D,setItems:C,loadReferenceData:W,loadAutomationRules:V,loadReplyRules:v,loadDefaultReplies:ee,refresh:be}=G,[U,ae]=r.useState(!1),[ge,$]=r.useState(!1),[L,Q]=r.useState(!1),[Y,re]=r.useState(ps),[ue,je]=r.useState(ps),[R,T]=r.useState(ps),[g,le]=r.useState(null),[oe,ne]=r.useState(null),[de,Se]=r.useState({cookie_id:"",enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""});z.find(i=>i.id===n),r.useEffect(()=>{const i=window.setTimeout(()=>{w(1),N(u.trim())},300);return()=>window.clearTimeout(i)},[u]),r.useEffect(()=>{W().catch(i=>console.error("加载规则参考数据失败",i))},[W]),r.useEffect(()=>{be().catch(i=>console.error("刷新规则页面失败",i))},[be]);const Ee=r.useMemo(()=>H.filter(i=>!n||i.cookie_id===n),[H,n]),Te=r.useMemo(()=>Ci(X,n),[X,n]),Ue=r.useMemo(()=>z.filter(i=>!n||i.id===n),[z,n]),Me=r.useMemo(()=>{if(M<=1)return[];const i=Math.max(1,Math.min(q-2,M-4)),I=Math.min(M,i+4);return Array.from({length:I-i+1},(te,he)=>i+he)},[q,M]),Be=!!(u.trim()||x||_!=="all"),Je=()=>{h(""),N(""),p(""),S("all"),w(1)},He=r.useMemo(()=>{const i=(g==null?void 0:g.cookie_id)||n;return F.filter(I=>I.cookie_id===i)},[g==null?void 0:g.cookie_id,F,n]),we=r.useMemo(()=>{if(!(!(g!=null&&g.cookie_id)||!(g!=null&&g.item_id)))return F.find(i=>i.cookie_id===g.cookie_id&&i.item_id===g.item_id)},[g==null?void 0:g.cookie_id,g==null?void 0:g.item_id,F]),pe=Pi(we==null?void 0:we.is_multi_spec),Ve=(g==null?void 0:g.trigger_type)||"order_paid",it=xt[Ve],tt=Za(g==null?void 0:g.config_json),Qe=r.useCallback((i="order_paid",I=n,te="")=>{const he=F.find($e=>$e.cookie_id===I&&$e.item_id===te),Ae=(he==null?void 0:he.item_title)||te;return{name:Tt(i,Ae),trigger_type:i,cookie_id:I,item_id:te,item_title:(he==null?void 0:he.item_title)||"",item_keyword:Ae,card_group_id:0,priority:100,enabled:!0,config_json:i==="review_missing_timeout"?gt():"{}",actions:Et(i),variants:i==="review_missing_timeout"?[]:[Pt()]}},[F,n]),Ge=r.useCallback(i=>{var te,he;const I=i.trigger_type||"order_paid";le({...i,trigger_type:I,config_json:I==="review_missing_timeout"?gt(i.config_json):i.config_json||"{}",actions:(te=i.actions)!=null&&te.length?i.actions.map(Ae=>({...Ae})):Et(I,i.card_group_id),variants:(he=i.variants)!=null&&he.length?i.variants.map(Ae=>({...Ae})):I==="review_missing_timeout"?[]:[Pt()]}),ae(!0)},[]);r.useEffect(()=>{if(!t)return;let i=!1;return(async()=>{l("automation"),c(t.cookieId),B(!0);try{const[te,he,Ae]=await Promise.all([Ls(),Lt(),Ms().catch(Re=>(console.warn("加载卡密库存失败,不阻断打开自动化规则",Re),[]))]);if(i)return;k(te),C(he),D(Ae);const $e=te.find(Re=>Re.cookie_id===t.cookieId&&Re.item_id===t.itemId&&Re.trigger_type==="order_paid");if($e)Ge($e);else{const Re=he.find(ct=>ct.cookie_id===t.cookieId&&ct.item_id===t.itemId);le({...Qe("order_paid",t.cookieId,t.itemId),item_title:(Re==null?void 0:Re.item_title)||"",item_keyword:(Re==null?void 0:Re.item_title)||t.itemId,name:Tt("order_paid",(Re==null?void 0:Re.item_title)||t.itemId)}),ae(!0)}}catch(te){console.error("打开商品自动化规则失败",te),alert("无法加载该商品的自动化规则")}finally{i||(B(!1),s==null||s())}})(),()=>{i=!0}},[Qe,t,s,Ge]);const ot=(i="order_paid")=>{if(!n){alert("请先选择账号");return}le(Qe(i)),ae(!0)},pt=i=>{var he,Ae,$e,Re,ct;if(!g)return;const I=((Ae=(he=g.variants)==null?void 0:he.find(jt=>jt.card_id))==null?void 0:Ae.card_id)||((Re=($e=g.actions)==null?void 0:$e.find(jt=>jt.action_type==="send_card"))==null?void 0:Re.card_id)||g.card_group_id||0,te=(we==null?void 0:we.item_title)||g.item_title||g.item_id||"";le({...g,trigger_type:i,name:ga(g.name)?Tt(i,te):g.name,card_group_id:I,config_json:i==="review_missing_timeout"?gt(g.config_json):"{}",actions:Et(i,I),variants:i==="review_missing_timeout"?[]:(ct=g.variants)!=null&&ct.length?g.variants:[{...Pt(),card_id:I}]})},ht=i=>{if(!g)return;const I=F.find(he=>he.cookie_id===(g.cookie_id||n)&&he.item_id===i),te=(I==null?void 0:I.item_title)||i;le({...g,item_id:i,item_title:(I==null?void 0:I.item_title)||"",item_keyword:te,name:ga(g.name)?Tt(Ve,te):g.name})},J=(Ke=g==null?void 0:g.variants)!=null&&Ke.length?g.variants:[Pt()],ie=(i,I)=>{var he;if(!g)return;const te=J.map((Ae,$e)=>$e===i?{...Ae,...I}:Ae);le({...g,variants:te,card_group_id:((he=te[0])==null?void 0:he.card_id)||0})},j=()=>{if(!g)return;const i=J[J.length-1];le({...g,variants:[...J,{...Pt(),spec_name:pe&&(i==null?void 0:i.spec_name)||"",spec_value:pe&&(i==null?void 0:i.spec_value)||""}]})},E=async()=>{var Ae,$e,Re,ct,jt;if(!g||Y.submitting)return;const i=g.trigger_type||"order_paid";if(!g.cookie_id){alert("请选择账号");return}const I=(Ae=g.variants)!=null&&Ae.length?g.variants:[];if(i!=="review_missing_timeout"){if(!I.length||I.some(qe=>!qe.card_id)){alert(i==="buyer_reviewed"?"请选择评价赠品卡密库存":"请选择发货卡密库存");return}if(pe&&I.some(qe=>!qe.spec_name.trim()||!qe.spec_value.trim())){alert("多规格商品必须填写每一行的规格名称和规格值");return}}if(i==="review_missing_timeout"&&!(((Re=($e=g.actions)==null?void 0:$e.find(nr=>nr.action_type==="send_text"))==null?void 0:Re.message_template)||"").trim()){alert("请填写求评价文案");return}const te=i==="review_missing_timeout"?[]:I.map(qe=>({...qe,spec_name:pe?qe.spec_name.trim():"",spec_value:pe?qe.spec_value.trim():"",delivery_count:Math.max(1,Number(qe.delivery_count)||1),enabled:qe.enabled!==!1}));re(hs(Y));let he=!1;try{await aa({...g,trigger_type:i,name:(g.name||"").trim()||Tt(i,(we==null?void 0:we.item_title)||g.item_id||""),config_json:i==="review_missing_timeout"?gt(g.config_json):g.config_json||"{}",actions:(ct=g.actions)!=null&&ct.length?g.actions:Et(i,((jt=te[0])==null?void 0:jt.card_id)||g.card_group_id||0),variants:te}),ae(!1),await Promise.all([V(),W()]),alert("保存成功"),he=!0}catch(qe){console.error("保存自动化规则失败:",qe),alert("保存失败:"+qe.message)}finally{re(qe=>gs(qe,he))}},se=async i=>{if(confirm("确定删除该自动化规则吗?"))try{await Zl(i),await V(),alert("删除成功")}catch(I){alert("删除失败:"+I.message)}},ce=async i=>{try{await aa({...i,enabled:!i.enabled}),await V()}catch(I){alert("操作失败:"+I.message)}},fe=async(i,I)=>{if(confirm(I==="continue"?"确认外部动作已经执行成功,并跳到下一步吗?":I==="retry"?"确认外部动作没有执行,可以安全重试吗?错误判断可能造成重复发送。":"确认终止该自动化运行吗?"))try{await Xl(i,I),await V()}catch(he){alert("处理失败:"+he.message)}},De=async(i,I)=>{if(confirm(I==="retry"?"确认重新执行该任务吗?":"确认忽略并删除该异常任务吗?"))try{await en(i,I),await V()}catch(te){alert("处理失败:"+te.message)}},ve=()=>{if(!n){alert("请先选择账号");return}ne({keyword:"",reply_content:"",image_url:"",item_id:"",type:"text",match_type:"fuzzy",enabled:!0}),$(!0)},Pe=async()=>{var te,he,Ae;if(!oe||!n||ue.submitting)return;const i=oe.type==="image"?!!((te=oe.image_url)!=null&&te.trim()):!!((he=oe.reply_content)!=null&&he.trim());if(!((Ae=oe.keyword)!=null&&Ae.trim())||!i){alert("请填写关键词和回复内容");return}je(hs(ue));let I=!1;try{await rn({...oe,match_type:"fuzzy",enabled:!0},n),$(!1),await v(),alert("保存成功"),I=!0}catch($e){alert("保存失败:"+$e.message)}finally{je($e=>gs($e,I))}},me=async i=>{if(!(!n||!confirm("确定删除该回复规则吗?")))try{await ln(i,n),await v(),alert("删除成功")}catch(I){alert("删除失败:"+I.message)}},o=async(i=n)=>{if(!i){alert("请先选择账号");return}try{const I=await hn(i);Se({cookie_id:i,enabled:I.enabled,reply_content:I.reply_content,reply_once:I.reply_once,reply_image_url:I.reply_image_url||""})}catch{Se({cookie_id:i,enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""})}Q(!0)},K=async()=>{if(R.submitting)return;if(!de.cookie_id){alert("请先选择账号");return}if(de.enabled&&!de.reply_content.trim()&&!de.reply_image_url.trim()){alert("启用默认回复时,请填写回复内容或图片 URL");return}T(hs(R));let i=!1;try{await gn(de.cookie_id,{enabled:de.enabled,reply_content:de.reply_content,reply_once:de.reply_once,reply_image_url:de.reply_image_url}),Q(!1),await ee(),alert("保存成功"),i=!0}catch(I){alert("保存失败:"+I.message)}finally{T(I=>gs(I,i))}},xe=async i=>{if(confirm("确定删除该账号默认回复吗?"))try{await bn(i),await ee(),alert("删除成功")}catch(I){alert("删除失败:"+I.message)}},Le=async i=>{if(confirm("确定清空该账号的默认回复记录吗?清空后可重新对所有会话使用“只回复一次”。"))try{await fn(i),alert("清空成功")}catch(I){alert("清空失败:"+I.message)}},st=a==="automation"?"新建自动化":a==="reply"?"新增关键词":"编辑默认回复";return e.jsxs("div",{className:"min-w-0 space-y-8 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row 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:"系统通知卡片只进入自动化判断;买家消息进入关键词、默认或 AI 回复。"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:flex-wrap gap-3",children:[e.jsxs("select",{value:n,onChange:i=>{c(i.target.value),w(1)},className:"ios-input w-full px-4 py-3 rounded-2xl text-sm sm:w-64",children:[e.jsx("option",{value:"",children:"全部账号"}),z.map(i=>e.jsx("option",{value:i.id,children:Ht(i)},i.id))]}),e.jsxs("button",{onClick:be,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 whitespace-nowrap transition-colors",children:[e.jsx(We,{className:`w-4 h-4 ${d?"animate-spin":""}`}),"刷新"]}),e.jsxs("button",{onClick:a==="automation"?()=>ot("order_paid"):a==="reply"?ve:()=>void o(),disabled:!n,className:"ios-btn-primary px-5 py-3 rounded-2xl text-sm font-extrabold flex items-center justify-center gap-2 whitespace-nowrap disabled:opacity-50",children:[e.jsx(nt,{className:"w-4 h-4"}),st]})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[{id:"automation",label:"交易自动化",icon:js},{id:"reply",label:"关键词回复",icon:$t},{id:"default",label:"账号默认回复",icon:wt}].map(i=>{const I=i.icon;return e.jsxs("button",{onClick:()=>l(i.id),className:`inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${a===i.id?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:[e.jsx(I,{className:"w-4 h-4"}),i.label]},i.id)})}),a==="automation"&&(Te.runs.length>0||Te.pending_tasks.length>0)&&e.jsx(Li,{runs:Te.runs,pendingTasks:Te.pending_tasks,onResolveRun:(i,I)=>void fe(i,I),onResolveDeferredTask:(i,I)=>void De(i,I)}),a==="automation"&&e.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-6 xl:grid-cols-[minmax(270px,0.72fr)_minmax(0,1.28fr)]",children:[e.jsxs("aside",{className:"min-w-0 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:Kt.map(i=>{const I=xt[i],te=I.icon;return e.jsx("button",{type:"button",onClick:()=>ot(i),className:`w-full text-left rounded-2xl border p-4 transition-colors ${ba(I.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(te,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-extrabold",children:I.label}),e.jsx("div",{className:"text-xs opacity-75 mt-1 leading-5",children:I.description})]})]})},i)})})]}),e.jsxs("div",{className:"bg-white rounded-xl p-5 border border-gray-100 shadow-sm",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"font-black text-gray-900",children:"筛选结果构成"}),e.jsxs("span",{className:"text-xs font-bold text-gray-400",children:["共 ",Z," 条"]})]}),e.jsx("div",{className:"space-y-3",children:Kt.map(i=>{const I=xt[i],te=I.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(te,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{className:"text-sm font-bold text-gray-700",children:I.shortLabel})]}),e.jsx("span",{className:"text-sm font-black text-gray-900",children:b[i]||0})]},i)})})]})]}),e.jsxs("section",{className:"min-w-0 space-y-4",children:[e.jsxs("div",{className:"rounded-xl border border-gray-100 bg-surface-muted p-4 shadow-sm",children:[e.jsxs("div",{className:"flex flex-col gap-3 xl:flex-row xl:items-center",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(St,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"搜索自动化规则",placeholder:"搜索规则名、商品名或商品 ID...",value:u,onChange:i=>{h(i.target.value),w(1)},className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]}),e.jsxs("div",{className:"relative xl:w-52",children:[e.jsx(Oa,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按自动化类型筛选",value:x,onChange:i=>{p(i.target.value),w(1)},className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部自动化类型"}),Kt.map(i=>e.jsx("option",{value:i,children:xt[i].shortLabel},i))]})]}),e.jsxs("select",{"aria-label":"按启用状态筛选",value:_,onChange:i=>{S(i.target.value),w(1)},className:"ios-input rounded-xl border-none bg-white px-4 py-2.5 text-sm shadow-sm xl:w-36",children:[e.jsx("option",{value:"all",children:"全部状态"}),e.jsx("option",{value:"enabled",children:"已启用"}),e.jsx("option",{value:"disabled",children:"已禁用"})]}),Be&&e.jsx("button",{type:"button",onClick:Je,className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-white text-gray-500 shadow-sm transition-colors hover:bg-gray-100 hover:text-gray-900",title:"清除筛选","aria-label":"清除筛选",children:e.jsx(ke,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between text-xs font-bold text-gray-400",children:[e.jsxs("span",{children:["找到 ",Z," 条规则"]}),d&&e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(We,{className:"h-3.5 w-3.5 animate-spin"}),"正在更新"]})]})]}),d&&Ee.length===0?e.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-xl border border-gray-100 bg-white text-sm font-bold text-gray-400",children:[e.jsx(We,{className:"mr-2 h-4 w-4 animate-spin"}),"正在加载规则"]}):Ee.length===0?e.jsxs("div",{className:"bg-white rounded-xl border border-dashed border-gray-200 p-16 text-center",children:[e.jsx(js,{className:"w-12 h-12 text-gray-300 mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-black text-gray-900",children:Be?"没有匹配的自动化规则":"还没有自动化规则"}),e.jsx("p",{className:"text-gray-500 mt-2",children:Be?"调整或清除筛选条件后再试。":"从左侧选择一个模板开始配置。"})]}):Ee.map(i=>{const I=xt[i.trigger_type],te=I.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 ${ba(I.accent,!0)}`,children:e.jsx(te,{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:i.name}),e.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-bold ${Oi(i.enabled)}`,children:i.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:I.label}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-gray-100 text-gray-600",children:i.item_title||i.item_id||"账号级规则"}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-blue-50 text-blue-700",children:Ii(i)})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{onClick:()=>Ge(i),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(kt,{className:"w-4 h-4"}),"编辑"]}),e.jsx("button",{onClick:()=>ce(i),className:`px-4 py-2 rounded-xl text-sm font-bold ${i.enabled?"bg-amber-50 text-amber-700 hover:bg-amber-100":"bg-emerald-50 text-emerald-700 hover:bg-emerald-100"}`,children:i.enabled?"禁用":"启用"}),e.jsx("button",{onClick:()=>se(i.id),className:"p-2.5 rounded-xl text-red-500 hover:bg-red-50",title:"删除",children:e.jsx(Ze,{className:"w-4 h-4"})})]})]})},i.id)}),Z>0&&e.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-gray-100 bg-white px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 text-sm font-medium text-gray-500",children:[e.jsxs("span",{children:["第 ",q," / ",Math.max(M,1)," 页"]}),e.jsx("span",{className:"h-4 w-px bg-gray-200"}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"sr-only",children:"每页显示数量"}),e.jsx("select",{value:P,onChange:i=>{A(Number(i.target.value)),w(1)},className:"ios-input rounded-lg border-none bg-gray-50 px-2.5 py-2 text-sm",children:[10,20,50].map(i=>e.jsxs("option",{value:i,children:[i," 条/页"]},i))})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",disabled:q<=1||d,onClick:()=>w(i=>Math.max(1,i-1)),className:"flex h-9 w-9 items-center justify-center rounded-lg bg-gray-50 text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"上一页",title:"上一页",children:e.jsx(Es,{className:"h-4 w-4"})}),Me.map(i=>e.jsx("button",{type:"button",disabled:d,onClick:()=>w(i),className:`h-9 min-w-9 rounded-lg px-2 text-sm font-bold transition-colors ${i===q?"bg-brand text-white":"bg-gray-50 text-gray-600 hover:bg-gray-100"} disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":`第 ${i} 页`,"aria-current":i===q?"page":void 0,children:i},i)),e.jsx("button",{type:"button",disabled:q>=M||d,onClick:()=>w(i=>Math.min(M,i+1)),className:"flex h-9 w-9 items-center justify-center rounded-lg bg-gray-50 text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"下一页",title:"下一页",children:e.jsx(Ts,{className:"h-4 w-4"})})]})]})]})]}),a==="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(ut,{className:"w-4 h-4"}),"这里只处理买家用户消息;系统通知不会进入关键词或 AI 回复。"]}),e.jsxs("div",{className:"space-y-3",children:[f.map(i=>e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border border-gray-100 bg-surface-subtle 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:"包含匹配"}),e.jsxs("h3",{className:"font-bold text-gray-900",children:["“",i.keyword,"”"]})]}),e.jsx("div",{className:"bg-white p-3 rounded-xl border border-gray-100 text-sm text-gray-600 leading-relaxed",children:i.type==="image"&&i.image_url?i.image_url:i.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:()=>{ne({...i}),$(!0)},className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(kt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>me(i.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Ze,{className:"w-5 h-5"})})]})]},i.id)),f.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无关键词回复规则"})]})]}),a==="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(ut,{className:"w-4 h-4"}),"默认回复只处理买家用户消息;关键词未命中且 AI 未接管时才会使用。"]}),e.jsxs("div",{className:"space-y-3",children:[Ue.map(i=>{const I=y[i.id],te=!!(I!=null&&I.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 ${te?"border-purple-100 bg-purple-50/50 hover:bg-white hover:shadow-lg":"border-gray-100 bg-surface-subtle 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 ${te?"bg-purple-600 text-white":"bg-gray-200 text-gray-400"}`,children:e.jsx(wt,{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:Ht(i)}),e.jsx("span",{className:`px-2 py-0.5 rounded-lg text-xs font-bold ${te?"bg-green-100 text-green-700":"bg-gray-200 text-gray-500"}`,children:te?"已启用":"未启用"}),(I==null?void 0:I.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:te?I.reply_content||I.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 o(i.id),className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(kt,{className:"w-4 h-4"})}),te&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>void Le(i.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 xe(i.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Ze,{className:"w-5 h-5"})})]})]})]},i.id)}),Ue.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无账号"})]})]}),U&&g&&Oe.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:g.id?"编辑自动化规则":"新建自动化规则"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:it.description})]}),e.jsx("button",{onClick:()=>ae(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",title:"关闭",children:e.jsx(ke,{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:Kt.map(i=>{const I=xt[i],te=I.icon,he=Ve===i;return e.jsx("button",{type:"button",onClick:()=>pt(i),className:`w-full rounded-2xl p-4 text-left border transition-all ${he?"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(te,{className:`w-5 h-5 mt-0.5 ${he?"text-brand":"text-white"}`}),e.jsxs("div",{children:[e.jsx("div",{className:"font-black",children:I.label}),e.jsx("div",{className:`text-xs mt-1 leading-5 ${he?"text-gray-500":"text-gray-400"}`,children:I.description})]})]})},i)})}),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:it.flow.map((i,I)=>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:I+1}),e.jsx("span",{className:"text-sm font-bold text-gray-100",children:i})]},i))})]})]}),e.jsx("div",{className:"p-6 overflow-y-auto bg-surface-subtle",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(Ns,{className:"w-5 h-5 text-brand"}),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:g.name||"",onChange:i=>le({...g,name:i.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:g.cookie_id||"",onChange:i=>le({...g,cookie_id:i.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:"选择账号"}),z.map(i=>e.jsx("option",{value:i.id,children:Ht(i)},i.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关联商品"}),e.jsxs("select",{value:g.item_id||"",onChange:i=>ht(i.target.value),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级规则(不限定商品)"}),He.map(i=>e.jsx("option",{value:i.item_id,children:i.item_title||i.item_id},`${i.cookie_id}-${i.item_id}`))]})]})]}),we&&Ve!=="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:we.item_title||we.item_id}),e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${pe?"bg-blue-50 text-blue-700":"bg-gray-100 text-gray-500"}`,children:pe?"多规格商品":"普通商品"}),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:"多规格状态来自闲鱼商品本身,发布后不能在这里修改;系统会在买家付款后读取订单详情,按实际购买规格和数量匹配下面的发货规则。"})]})]}),Ve!=="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(Sr,{className:"w-5 h-5 text-brand"}),e.jsx("h4",{className:"font-black text-gray-900",children:Ve==="buyer_reviewed"?"赠品库存":"发货库存"})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:pe?"每条发货内容绑定一个订单规格;同一规格可添加多条内容并全部发送。":"可添加多条发货内容,买家付款后会按顺序全部发送。"})]}),e.jsxs("button",{type:"button",onClick:j,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(nt,{className:"w-3.5 h-3.5"}),"添加发货内容"]})]}),e.jsx("div",{className:"space-y-3",children:J.map((i,I)=>e.jsxs("div",{className:`grid grid-cols-1 gap-3 items-end rounded-2xl border border-gray-200 p-4 ${pe?"md:grid-cols-[1fr_1fr_1.4fr_110px_40px]":"md:grid-cols-[1.4fr_110px_40px]"}`,children:[pe&&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:i.spec_name,onChange:te=>ie(I,{spec_name:te.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:i.spec_value,onChange:te=>ie(I,{spec_value:te.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:i.card_id||"",onChange:te=>ie(I,{card_id:Number(te.target.value)}),className:"w-full ios-input px-3 py-2.5 rounded-lg",children:[e.jsx("option",{value:"",children:"请选择卡密库存"}),O.filter(te=>te.enabled&&te.type!=="api").map(te=>e.jsx("option",{value:te.id,children:te.name},te.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:i.delivery_count,onChange:te=>ie(I,{delivery_count:Math.max(1,Number(te.target.value)||1)}),className:"w-full ios-input px-3 py-2.5 rounded-lg"})]}),e.jsxs("div",{className:"md:col-span-full flex flex-wrap items-center gap-3 rounded-xl bg-gray-50 px-3 py-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs font-bold text-gray-600 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:i.delay_override===!0,onChange:te=>ie(I,{delay_override:te.target.checked}),className:"accent-brand"}),"覆盖卡密默认延时"]}),i.delay_override&&e.jsx("input",{type:"number",min:"0",max:"3600",value:i.delay_seconds||0,onChange:te=>ie(I,{delay_seconds:Math.max(0,Number(te.target.value)||0)}),className:"w-28 ios-input px-2 py-1.5 rounded-lg text-xs","aria-label":"动作延时秒数"}),e.jsx("span",{className:"text-xs text-gray-500",children:i.delay_override?`本动作延时 ${i.delay_seconds||0} 秒`:"使用卡密默认延时"})]}),e.jsx("button",{type:"button",disabled:J.length===1,onClick:()=>le({...g,variants:J.filter((te,he)=>he!==I)}),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(Ze,{className:"w-4 h-4"})})]},i.id||I))})]}):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(Pa,{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-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",min:"1",value:Number(tt.after_shipped_hours||72),onChange:i=>le({...g,config_json:gt(g.config_json,{after_shipped_hours:Math.max(1,Number(i.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(tt.repeat_interval_hours||24),onChange:i=>le({...g,config_json:gt(g.config_json,{repeat_interval_hours:Math.max(1,Number(i.target.value)||24)})}),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(tt.max_attempts||1),onChange:i=>le({...g,config_json:gt(g.config_json,{max_attempts:Math.max(1,Number(i.target.value)||1)})}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"md:col-span-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"求评价文案"}),e.jsx("textarea",{value:((Ut=(zt=g.actions)==null?void 0:zt.find(i=>i.action_type==="send_text"))==null?void 0:Ut.message_template)||"",onChange:i=>{var I;return le({...g,actions:((I=g.actions)!=null&&I.length?g.actions:Et("review_missing_timeout")).map(te=>te.action_type==="send_text"?{...te,message_template:i.target.value}:te)})},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("p",{className:"text-xs text-gray-500 mb-2",children:"数字越小优先级越高;同一账号、商品和触发条件只执行优先级最高的一条规则。"}),e.jsx("input",{type:"number",value:g.priority||100,onChange:i=>le({...g,priority:Number(i.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:g.enabled!==!1,onChange:i=>le({...g,enabled:i.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:()=>ae(!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:E,className:"flex-1 ios-btn-primary px-6 py-3 rounded-2xl font-bold flex items-center justify-center gap-2",children:[e.jsx(lt,{className:"w-4 h-4"}),"保存自动化规则"]})]})]})}),document.body),ge&&oe&&Oe.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:oe.id?"编辑回复规则":"新增回复规则"}),e.jsx("button",{onClick:()=>$(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(ke,{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-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.jsxs("select",{value:oe.item_id||"",onChange:i=>ne({...oe,item_id:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级回复"}),F.filter(i=>!n||i.cookie_id===n).map(i=>e.jsx("option",{value:i.item_id,children:i.item_title||i.item_id},`${i.cookie_id}-${i.item_id}`))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复类型"}),e.jsxs("select",{value:oe.type||"text",onChange:i=>{const I=i.target.value;ne({...oe,type:I,reply_content:I==="text"?oe.reply_content:"",image_url:I==="image"?oe.image_url:""})},className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"text",children:"文字"}),e.jsx("option",{value:"image",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:oe.keyword||"",onChange:i=>ne({...oe,keyword:i.target.value}),placeholder:"买家发送的关键词",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),oe.type==="image"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),e.jsx("input",{value:oe.image_url||"",onChange:i=>ne({...oe,image_url:i.target.value}),placeholder:"https://...",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:oe.reply_content||"",onChange:i=>ne({...oe,reply_content:i.target.value}),placeholder:"自动回复的内容",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none"})]}),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:Pe,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ss,{className:"w-4 h-4"}),"保存规则"]})]})]})]})}),document.body),L&&Oe.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:()=>Q(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",title:"关闭",children:e.jsx(ke,{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:de.cookie_id,onChange:i=>Se({...de,cookie_id:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"选择账号"}),z.map(i=>e.jsx("option",{value:i.id,children:Ht(i)},i.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:()=>Se({...de,enabled:!de.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${de.enabled?"bg-brand":"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 ${de.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:de.reply_content,onChange:i=>Se({...de,reply_content:i.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:de.reply_image_url,onChange:i=>Se({...de,reply_image_url:i.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:de.reply_once,onChange:i=>Se({...de,reply_once:i.target.checked}),className:"w-4 h-4 rounded"})]}),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: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(lt,{className:"w-4 h-4"}),"保存默认回复"]})]})]})]})}),document.body)]})},qs=["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from_name","smtp_from_address","smtp_use_tls","smtp_use_ssl"],As=(t,s)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(["true","1","yes","on"].includes(t.toLowerCase()))return!0;if(["false","0","no","off"].includes(t.toLowerCase()))return!1}return s},Ya=t=>{const s=Object.prototype.hasOwnProperty.call(t,"use_custom_smtp"),a=qs.some(l=>String(t[l]??"").trim()!=="");return{...t,use_custom_smtp:s?As(t.use_custom_smtp,!1):a}},Xa=(t,s)=>{const a={...t,use_custom_smtp:!0};for(const l of qs)String(a[l]??"").trim()===""&&s[l]!==void 0&&(a[l]=s[l]);return a.smtp_port||(a.smtp_port=587),a.smtp_from_address||(a.smtp_from_address=a.smtp_user||""),a.smtp_use_tls=As(a.smtp_use_tls,!0),a.smtp_use_ssl=As(a.smtp_use_ssl,!1),a},er=t=>{const s=Ya(t),a={to_email:String(s.to_email??"").trim(),use_custom_smtp:s.use_custom_smtp===!0};if(a.use_custom_smtp)for(const l of qs)a[l]=s[l];return a},Ct={bark:{label:"Bark",icon:Rt,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:"Ydisks闲鱼助手"},{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:$t,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:$t,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:$t,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:Lr,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:ss,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:Ta,fields:[{key:"to_email",label:"收件邮箱",placeholder:"receiver@example.com",required:!0}],guide:{steps:["通常先保存页面中的系统 SMTP 配置","邮件渠道只需填写收件邮箱,即可完整继承系统 SMTP","只有确实需要另一套发件服务时,才开启“使用独立 SMTP”并填写整套配置"],note:"继承和独立 SMTP 是互斥模式,不会再混用两套配置中的部分字段。"}}},tr=[{value:"account_offline",label:"掉线通知",description:"账号过期、断线或登录态失效"},{value:"account_recovered",label:"恢复通知",description:"自动恢复成功并重新在线"},{value:"account_disabled",label:"禁用通知",description:"连续失败、账密错误等导致账号停用"},{value:"security_verification",label:"风控验证",description:"滑块、人脸、扫码验证等安全校验"},{value:"delivery_result",label:"交易通知",description:"订单发货、卡密发送等交易结果"},{value:"token_renewal",label:"续期通知",description:"Cookie/token 续期和自动恢复过程"},{value:"system_error",label:"系统错误",description:"后台任务或系统级异常"}],fa=()=>({name:"",type:"bark",enabled:!0,config:{},event_types:[]}),Ei=t=>!t||t.length===0?"全部事件":t.map(s=>{var a;return((a=tr.find(l=>l.value===s))==null?void 0:a.label)||s}).join("、"),Di=(t,s)=>{const a=t.type==="email"?Ya({...t.config||{}}):null,l=a?a.use_custom_smtp===!0?Xa(a,s):a:{...t.config||{}};return{name:t.name,type:t.type,enabled:t.enabled,config:l,event_types:t.event_types||[]}},$i=t=>{const a=Ct[t.type].fields.find(l=>l.required&&!String(t.config[l.key]||"").trim());if(a)return`请填写 ${a.label}`;if(!t.name.trim())return"请填写渠道名称";if(t.type==="email"){const l=er(t.config);if(l.use_custom_smtp){const c=[["smtp_server","独立 SMTP 服务器"],["smtp_port","独立 SMTP 端口"],["smtp_user","独立 SMTP 登录邮箱"],["smtp_password","独立 SMTP 密码 / 授权码"],["smtp_from_address","独立 SMTP 发件地址"]].find(([u])=>!String(l[u]||"").trim());if(c)return`请填写 ${c[1]}`}}return""},Mi=t=>({name:t.name.trim(),type:t.type,config:t.type==="email"?er(t.config):t.config,event_types:t.event_types,enabled:t.enabled}),Ie=(t,s)=>t===s,Dt=(t,s)=>t instanceof Error&&t.message?t.message:s,qi=({channels:t,testingId:s,onEdit:a,onDelete:l,onToggleEnabled:n,onTest:c})=>{const u=_=>t.find(S=>S.id===_.currentTarget.dataset.channelId)||null,h=_=>{const S=u(_);S&&n(S)},m=_=>{const S=u(_);S&&c(S)},N=_=>{const S=u(_);S&&a(S)},x=_=>{const S=u(_);S&&l(S)},p=_=>{const S=Ct[_.type]||Ct.webhook,q=S.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(q,{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:_.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 text-gray-600 font-medium",children:S.label}),!_.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:S.fields.map(w=>{var P;return(P=_.config)==null?void 0:P[w.key]}).filter(Boolean).map((w,P)=>e.jsx("span",{className:"mr-3",children:String(w).length>40?`${String(w).slice(0,40)}…`:String(w)},P))}),e.jsxs("div",{className:"text-xs text-gray-400 mt-1 truncate",children:["订阅:",Ei(_.event_types)]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("button",{"data-channel-id":_.id,onClick:h,className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-colors ${_.enabled?"bg-green-50 text-green-700 hover:bg-green-100":"bg-gray-100 text-gray-500 hover:bg-gray-200"}`,children:_.enabled?"启用中":"已停用"}),e.jsxs("button",{"data-channel-id":_.id,onClick:m,disabled:s===_.id,className:"px-3 py-1.5 rounded-lg text-xs font-bold bg-blue-50 text-brand hover:bg-blue-100 transition-colors flex items-center gap-1 disabled:opacity-50",children:[s===_.id?e.jsx(_e,{className:"w-3 h-3 animate-spin"}):e.jsx(ss,{className:"w-3 h-3"}),"测试"]}),e.jsx("button",{"data-channel-id":_.id,onClick:N,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(Ra,{className:"w-4 h-4"})}),e.jsx("button",{"data-channel-id":_.id,onClick:x,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(Ze,{className:"w-4 h-4"})})]})]},_.id)};return t.length===0?e.jsxs("div",{className:"ios-card rounded-xl p-12 bg-white text-center",children:[e.jsx(Rt,{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:t.map(p)})},Bi=({selectedEvents:t,onToggleEvent:s})=>{const a=l=>{const n=l.currentTarget.dataset.event;n&&s(n)};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"通知内容"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"不选择表示接收全部通知;选择后仅接收勾选类型。"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:tr.map(l=>{const n=t.includes(l.value);return e.jsxs("button",{type:"button","data-event":l.value,onClick:a,className:`text-left rounded-xl border px-3 py-2.5 transition-colors ${n?"border-brand bg-blue-50":"border-gray-100 hover:border-gray-300"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-4 h-4 rounded border flex items-center justify-center ${n?"bg-brand border-brand":"border-gray-300"}`,children:n&&e.jsx(Ye,{className:"w-3 h-3 text-white"})}),e.jsx("span",{className:`text-sm font-bold ${n?"text-brand":"text-gray-800"}`,children:l.label})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 pl-6 leading-5",children:l.description})]},l.value)})})]})},Fi=({showModal:t,editing:s,form:a,setForm:l,smtp:n,showChannelSmtpPassword:c,setShowChannelSmtpPassword:u,saving:h,onClose:m,onSave:N})=>{const x=Ct[a.type],p=f=>l(y=>({...y,name:f.target.value})),_=f=>{const y=f.currentTarget.dataset.type;y&&l(z=>({...z,type:y,config:{}}))},S=f=>{const y=f.currentTarget.dataset.field;y&&l(z=>({...z,config:{...z.config,[y]:f.target.value}}))},q=()=>l(f=>({...f,config:f.config.use_custom_smtp===!0?{...f.config,use_custom_smtp:!1}:Xa(f.config,n)})),w=f=>l(y=>({...y,config:{...y.config,smtp_use_tls:f.target.checked,smtp_use_ssl:f.target.checked?!1:y.config.smtp_use_ssl}})),P=f=>l(y=>({...y,config:{...y.config,smtp_use_ssl:f.target.checked,smtp_use_tls:f.target.checked?!1:y.config.smtp_use_tls}})),A=f=>l(y=>({...y,event_types:y.event_types.includes(f)?y.event_types.filter(z=>z!==f):[...y.event_types,f]})),G=()=>l(f=>({...f,enabled:!f.enabled})),H=()=>u(f=>!f),X=(f,y)=>e.jsx("li",{children:f},y);return t?Oe.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:s?"编辑通知渠道":"新建通知渠道"}),e.jsx("button",{onClick:m,className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(ke,{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:a.name,onChange:p,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(Ct).map(f=>{const y=Ct[f],z=y.icon,O=a.type===f;return e.jsxs("button",{"data-type":f,type:"button",onClick:_,className:`p-3 rounded-xl border-2 flex flex-col items-center gap-1.5 transition-all ${O?"border-brand bg-blue-50":"border-gray-100 hover:border-gray-300"}`,children:[e.jsx(z,{className:`w-5 h-5 ${O?"text-brand":"text-gray-500"}`}),e.jsx("span",{className:`text-xs font-bold ${O?"text-brand":"text-gray-600"}`,children:y.label})]},f)})})]}),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(Rt,{className:"w-4 h-4 text-amber-600"}),e.jsxs("span",{className:"text-sm font-bold text-amber-800",children:["如何获取 ",x.label," 配置?"]})]}),e.jsx("ol",{className:"space-y-1.5 text-xs text-amber-900/90 leading-5 list-decimal pl-5",children:x.guide.steps.map(X)}),x.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:x.guide.urlFormat})]}),x.guide.note&&e.jsxs("p",{className:"text-xs text-amber-800/80 leading-5 pt-1",children:["💡 ",x.guide.note]})]}),e.jsx("div",{className:"space-y-3",children:x.fields.map(f=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:[f.label,f.required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),e.jsx("input",{"data-field":f.key,type:f.type==="password"?"password":f.type==="number"?"number":"text",value:String(a.config[f.key]||""),onChange:S,placeholder:f.placeholder,className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),f.help&&e.jsx("p",{className:"text-xs text-gray-500",children:f.help})]},f.key))}),a.type==="email"&&e.jsxs("div",{className:"overflow-hidden rounded-2xl border border-blue-100 bg-blue-50/40",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"SMTP 来源"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-gray-500",children:a.config.use_custom_smtp===!0?"当前渠道使用一套完整、独立的发件配置。":"当前渠道完整继承系统 SMTP,只单独设置收件邮箱。"})]}),e.jsx("button",{type:"button",onClick:q,className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${a.config.use_custom_smtp===!0?"bg-brand":"bg-gray-300"}`,"aria-label":"使用独立 SMTP",children:e.jsx("span",{className:`absolute left-1 top-1 h-5 w-5 rounded-full bg-white shadow-sm transition-transform ${a.config.use_custom_smtp===!0?"translate-x-5":""}`})})]}),a.config.use_custom_smtp===!0&&e.jsxs("div",{className:"space-y-4 border-t border-blue-100 bg-white/80 p-4",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["SMTP 服务器 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{"data-field":"smtp_server",type:"text",value:String(a.config.smtp_server||""),onChange:S,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.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["SMTP 端口 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{"data-field":"smtp_port",type:"number",value:String(a.config.smtp_port||587),onChange:S,placeholder:"587",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["登录邮箱 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{"data-field":"smtp_user",type:"email",value:String(a.config.smtp_user||""),onChange:S,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.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["密码 / 授权码 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{"data-field":"smtp_password",type:c?"text":"password",value:String(a.config.smtp_password||""),onChange:S,placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:H,className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",children:c?e.jsx(bt,{className:"w-4 h-4"}):e.jsx(mt,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",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",{"data-field":"smtp_from_name",type:"text",value:String(a.config.smtp_from_name||""),onChange:S,placeholder:"闲鱼自动回复系统",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["发件邮箱地址 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{"data-field":"smtp_from_address",type:"email",value:String(a.config.smtp_from_address||""),onChange:S,placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-3 text-xs font-bold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:a.config.smtp_use_tls!==!1,onChange:w}),"STARTTLS(常用于 587)"]}),e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-3 text-xs font-bold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:a.config.smtp_use_ssl===!0,onChange:P}),"SSL/TLS 直连(常用于 465)"]})]})]})]}),e.jsx(Bi,{selectedEvents:a.event_types,onToggleEvent:A}),e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx("button",{type:"button",onClick:G,className:`relative w-11 h-6 rounded-full transition-colors ${a.enabled?"bg-brand":"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 ${a.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,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:N,disabled:h,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[h?e.jsx(_e,{className:"w-4 h-4 animate-spin"}):e.jsx(Ye,{className:"w-4 h-4"}),h?"保存中...":"保存"]})]})]})}),document.body):null},zi=({smtp:t,setSmtp:s,smtpSaving:a,showPassword:l,setShowPassword:n,onSave:c})=>{const u=_=>{const S=_.currentTarget.dataset.field;S&&s(q=>({...q,[S]:_.target.value}))},h=_=>{s(S=>({...S,smtp_port:parseInt(_.target.value,10)||587}))},m=_=>{s(S=>({...S,smtp_use_tls:_.target.checked,smtp_use_ssl:_.target.checked?!1:S.smtp_use_ssl}))},N=_=>{s(S=>({...S,smtp_use_ssl:_.target.checked,smtp_use_tls:_.target.checked?!1:S.smtp_use_tls}))},x=_=>{s(S=>({...S,smtp_password:_.target.value}))},p=()=>n(_=>!_);return 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(Ta,{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",{"data-field":"smtp_server",type:"text",value:t.smtp_server||"",onChange:u,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:t.smtp_port||587,onChange:h,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",{"data-field":"smtp_user",type:"email",value:t.smtp_user||"",onChange:u,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:l?"text":"password",value:t.smtp_password||"",onChange:x,placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:p,className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:l?e.jsx(bt,{className:"w-4 h-4"}):e.jsx(mt,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"QQ 邮箱需使用授权码(QQ 邮箱设置 → 账号 → 开启 SMTP → 生成授权码)"})]}),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.jsx("input",{"data-field":"smtp_from_name",type:"text",value:t.smtp_from_name||"",onChange:u,placeholder:"闲鱼自动回复系统",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",{"data-field":"smtp_from_address",type:"email",value:t.smtp_from_address||t.smtp_user||"",onChange:u,placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-4 text-sm font-semibold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:t.smtp_use_tls!==!1,onChange:m}),"STARTTLS(常用于 587 端口)"]}),e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-4 text-sm font-semibold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:t.smtp_use_ssl===!0,onChange:N}),"SSL/TLS 直连(常用于 465 端口)"]})]}),e.jsxs("button",{onClick:c,disabled:a,className:"ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[a?e.jsx(_e,{className:"w-4 h-4 animate-spin"}):e.jsx(lt,{className:"w-4 h-4"}),a?"保存中...":"保存 SMTP 配置"]})]})},Ui=t=>{const[s,a]=r.useState([]),[l,n]=r.useState(!0),[c,u]=r.useState(!1),[h,m]=r.useState(null),[N,x]=r.useState(!1),[p,_]=r.useState(""),[S,q]=r.useState(null),[w,P]=r.useState({}),[A,G]=r.useState(!1),[H,X]=r.useState(!1),[f,y]=r.useState(!1),[z,O]=r.useState(fa),F=r.useRef(0),d=r.useRef(null),B=r.useRef(0),Z=r.useRef(null),M=r.useRef(0),b=r.useRef(null),k=r.useRef(null),D=r.useCallback((L,Q)=>{q({type:L,text:Q}),k.current!==null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>{k.current=null,q(null)},3e3)},[]),C=r.useCallback(async()=>{var Y;const L=++F.current;(Y=d.current)==null||Y.abort();const Q=new AbortController;d.current=Q,n(!0);try{const re=await Va({signal:Q.signal});if(!Ie(L,F.current))return;a(re.data||[])}catch(re){Ie(L,F.current)&&!Q.signal.aborted&&console.error("加载通知渠道失败",re)}finally{Ie(L,F.current)&&n(!1)}},[]),W=r.useCallback(async()=>{var Y;const L=++B.current;(Y=Z.current)==null||Y.abort();const Q=new AbortController;Z.current=Q;try{const re=await Wa({signal:Q.signal});Ie(L,B.current)&&P(re||{})}catch(re){Ie(L,B.current)&&!Q.signal.aborted&&console.error("加载 SMTP 配置失败",re)}},[]);r.useEffect(()=>{var L;return C(),t?W():(B.current+=1,(L=Z.current)==null||L.abort(),P({})),(()=>{var Q,Y;F.current+=1,(Q=d.current)==null||Q.abort(),B.current+=1,(Y=Z.current)==null||Y.abort()})},[t,C,W]),r.useEffect(()=>(()=>{k.current!==null&&window.clearTimeout(k.current)}),[]);const V=r.useCallback(()=>{m(null),O(fa()),y(!1),u(!0)},[]),v=r.useCallback(L=>{m(L),O(Di(L,w)),y(!1),u(!0)},[w]),ee=r.useCallback(()=>{var L;M.current+=1,(L=b.current)==null||L.abort(),x(!1),u(!1)},[]),be=r.useCallback(async()=>{var re;const L=$i(z);if(L){D("error",L);return}const Q=++M.current;(re=b.current)==null||re.abort();const Y=new AbortController;b.current=Y,x(!0);try{const ue=Mi(z);if(h?await ra(h.id,ue,{signal:Y.signal}):await xn(ue,{signal:Y.signal}),!Ie(Q,M.current)||(u(!1),await C(),!Ie(Q,M.current)))return;D("success",h?"已更新":"已创建")}catch(ue){Ie(Q,M.current)&&!Y.signal.aborted&&D("error",Dt(ue,"保存失败"))}finally{Ie(Q,M.current)&&x(!1)}},[h,z,C,D]),U=r.useCallback(async L=>{var re;if(!confirm(`确认删除渠道「${L.name}」吗?已绑定该渠道的账号会自动解绑。`))return;const Q=++M.current;(re=b.current)==null||re.abort();const Y=new AbortController;b.current=Y;try{if(await mn(L.id,{signal:Y.signal}),!Ie(Q,M.current)||(await C(),!Ie(Q,M.current)))return;D("success","已删除")}catch(ue){Ie(Q,M.current)&&!Y.signal.aborted&&D("error",Dt(ue,"删除失败"))}},[C,D]),ae=r.useCallback(async L=>{var re;const Q=++M.current;(re=b.current)==null||re.abort();const Y=new AbortController;b.current=Y;try{if(await ra(L.id,{enabled:!L.enabled},{signal:Y.signal}),!Ie(Q,M.current))return;a(ue=>ue.map(je=>je.id===L.id?{...je,enabled:!je.enabled}:je))}catch(ue){Ie(Q,M.current)&&!Y.signal.aborted&&D("error",Dt(ue,"切换失败"))}},[D]),ge=r.useCallback(async L=>{var re;_(L.id);const Q=++M.current;(re=b.current)==null||re.abort();const Y=new AbortController;b.current=Y;try{await pn(L.id,{signal:Y.signal}),Ie(Q,M.current)&&D("success","测试通知已发送,请检查对应渠道")}catch(ue){Ie(Q,M.current)&&!Y.signal.aborted&&D("error",Dt(ue,"发送失败"))}finally{Ie(Q,M.current)&&_("")}},[D]),$=r.useCallback(async()=>{var Y;const L=++B.current;(Y=Z.current)==null||Y.abort();const Q=new AbortController;Z.current=Q,G(!0);try{await Ja({smtp_server:w.smtp_server||"",smtp_port:w.smtp_port||587,smtp_user:w.smtp_user||"",smtp_password:w.smtp_password||"",smtp_from_name:w.smtp_from_name||"",smtp_from_address:w.smtp_from_address||w.smtp_user||"",smtp_use_tls:w.smtp_use_tls!==!1,smtp_use_ssl:w.smtp_use_ssl===!0},{signal:Q.signal}),Ie(L,B.current)&&D("success","SMTP 配置已保存")}catch(re){Ie(L,B.current)&&!Q.signal.aborted&&D("error",Dt(re,"保存失败"))}finally{Ie(L,B.current)&&G(!1)}},[D,w]);return{channels:s,loading:l,showModal:c,editing:h,saving:N,testingId:p,toast:S,smtp:w,smtpSaving:A,showSmtpPassword:H,showChannelSmtpPassword:f,form:z,setForm:O,setSmtp:P,setShowSmtpPassword:X,setShowChannelSmtpPassword:y,loadChannels:C,openCreate:V,openEdit:v,closeModal:ee,showToast:D,handleSave:be,handleDelete:U,handleToggleEnabled:ae,handleTest:ge,handleSaveSmtp:$}},Wi=({isAdmin:t=!1})=>{const s=Ui(t);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:s.loadChannels,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(We,{className:"w-4 h-4"}),"刷新"]}),e.jsxs("button",{onClick:s.openCreate,className:"ios-btn-primary px-5 py-2.5 rounded-xl font-bold flex items-center gap-2",children:[e.jsx(nt,{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(Rt,{className:"w-5 h-5 text-brand 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:"触发风控验证"}),":可能需要扫码完成验证(警告)"]})]})]})]})}),s.loading?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx(_e,{className:"w-8 h-8 text-brand animate-spin"})}):e.jsx(qi,{channels:s.channels,testingId:s.testingId,onEdit:s.openEdit,onDelete:s.handleDelete,onToggleEnabled:s.handleToggleEnabled,onTest:s.handleTest}),t&&e.jsx(zi,{smtp:s.smtp,setSmtp:s.setSmtp,smtpSaving:s.smtpSaving,showPassword:s.showSmtpPassword,setShowPassword:s.setShowSmtpPassword,onSave:s.handleSaveSmtp}),e.jsx(Fi,{showModal:s.showModal,editing:s.editing,form:s.form,setForm:s.setForm,smtp:s.smtp,showChannelSmtpPassword:s.showChannelSmtpPassword,setShowChannelSmtpPassword:s.setShowChannelSmtpPassword,saving:s.saving,onClose:s.closeModal,onSave:s.handleSave}),s.toast&&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 text-white ${s.toast.type==="success"?"bg-success-500":"bg-danger-500"}`,children:[s.toast.type==="success"?e.jsx(Ye,{className:"w-4 h-4"}):e.jsx(ke,{className:"w-4 h-4"}),s.toast.text]})]})},sr=[["尊嘟假嘟","https://img.alicdn.com/imgextra/i2/O1CN01hWzOgD1KcmFEIaGwE_!!6000000001185-2-tps-64-64.png_110x10000.jpg_.webp"],["鸡哔你","https://img.alicdn.com/imgextra/i1/O1CN01P9TVJl1JCqCZcQIdW_!!6000000000993-2-tps-64-64.png_110x10000.jpg_.webp"],["谁懂啊","https://img.alicdn.com/imgextra/i1/O1CN01r9qUnx1g3tcrtSmcs_!!6000000004087-2-tps-64-64.png_110x10000.jpg_.webp"],["吗喽","https://img.alicdn.com/imgextra/i4/O1CN01dTynZh1LnbIYTHI1D_!!6000000001344-2-tps-64-64.png_110x10000.jpg_.webp"],["功德+1","https://img.alicdn.com/imgextra/i1/O1CN01l1G5pS1IVn37pfQJi_!!6000000000899-2-tps-64-64.png_110x10000.jpg_.webp"],["city不city啊","https://img.alicdn.com/imgextra/i2/O1CN01zRjPTR29lWHqabmDA_!!6000000008108-2-tps-64-64.png_110x10000.jpg_.webp"],["激推","https://img.alicdn.com/imgextra/i3/O1CN01ADTJ6u1khypfxbfnQ_!!6000000004716-2-tps-64-64.png_110x10000.jpg_.webp"],["微笑","https://img.alicdn.com/imgextra/i1/O1CN017b61R51wRk2lVV7vx_!!6000000006305-2-tps-980-980.png_110x10000.jpg_.webp"],["龇牙","https://img.alicdn.com/imgextra/i2/O1CN01nmOh4S22Yxz8IdEVf_!!6000000007133-2-tps-980-980.png_110x10000.jpg_.webp"],["流泪","https://img.alicdn.com/imgextra/i2/O1CN01Ec1EaL1zqQETcM2dX_!!6000000006765-2-tps-980-980.png_110x10000.jpg_.webp"],["尴尬","https://img.alicdn.com/imgextra/i2/O1CN01UrWH7a1ZVBrgRYXlc_!!6000000003199-2-tps-980-980.png_110x10000.jpg_.webp"],["撇嘴","https://img.alicdn.com/imgextra/i2/O1CN01Sr7o2b1lUWg5KfOD8_!!6000000004822-2-tps-980-980.png_110x10000.jpg_.webp"],["破涕为笑","https://img.alicdn.com/imgextra/i4/O1CN01pPetah1gkwndfn7Fs_!!6000000004181-2-tps-980-980.png_110x10000.jpg_.webp"],["捂脸哭","https://img.alicdn.com/imgextra/i2/O1CN0170KgpE1dE1TuQgd66_!!6000000003703-2-tps-980-980.png_110x10000.jpg_.webp"],["害羞","https://img.alicdn.com/imgextra/i3/O1CN01ZoB0Lb1ps7XpqP8PQ_!!6000000005415-2-tps-980-980.png_110x10000.jpg_.webp"],["感动","https://img.alicdn.com/imgextra/i2/O1CN01wqD4ly29yndR3Qp3A_!!6000000008137-2-tps-980-980.png_110x10000.jpg_.webp"],["滴泪","https://img.alicdn.com/imgextra/i1/O1CN01MpkJ3L1oUTTqfryOn_!!6000000005228-2-tps-980-980.png_110x10000.jpg_.webp"],["暗中观察","https://img.alicdn.com/imgextra/i1/O1CN010LO9yj272W07GlLls_!!6000000007739-2-tps-980-980.png_110x10000.jpg_.webp"],["偷笑","https://img.alicdn.com/imgextra/i4/O1CN01vJtO031g818IuYO7x_!!6000000004096-2-tps-980-980.png_110x10000.jpg_.webp"],["ok","https://img.alicdn.com/imgextra/i3/O1CN01QRkqDF25tz0WcANje_!!6000000007585-2-tps-980-980.png_110x10000.jpg_.webp"],["送花","https://img.alicdn.com/imgextra/i2/O1CN01PpzBNX1JNpeJBWnvr_!!6000000001017-2-tps-980-980.png_110x10000.jpg_.webp"],["大哭","https://img.alicdn.com/imgextra/i4/O1CN014TiaNb1ViEgNvRrTB_!!6000000002686-2-tps-980-980.png_110x10000.jpg_.webp"],["色","https://img.alicdn.com/imgextra/i2/O1CN01840t1B1JaCLGvHnBK_!!6000000001044-2-tps-980-980.png_110x10000.jpg_.webp"],["惊慌","https://img.alicdn.com/imgextra/i1/O1CN01mnqO7G1LAfUnfAN2U_!!6000000001259-2-tps-980-980.png_110x10000.jpg_.webp"],["惊讶","https://img.alicdn.com/imgextra/i3/O1CN0127IeyS1Kw0p0P4jzI_!!6000000001227-2-tps-980-980.png_110x10000.jpg_.webp"],["得意","https://img.alicdn.com/imgextra/i4/O1CN018QUnFv1WpOUES9POZ_!!6000000002837-2-tps-980-980.png_110x10000.jpg_.webp"],["睡","https://img.alicdn.com/imgextra/i2/O1CN01RprGZl1lqVgnEJLCx_!!6000000004870-2-tps-980-980.png_110x10000.jpg_.webp"],["不好意思","https://img.alicdn.com/imgextra/i3/O1CN01rMJJgn1SUXzuVpUhO_!!6000000002250-2-tps-980-980.png_110x10000.jpg_.webp"],["托腮","https://img.alicdn.com/imgextra/i1/O1CN01w3reBU1d3wlgOBtyZ_!!6000000003681-2-tps-980-980.png_110x10000.jpg_.webp"],["发怒","https://img.alicdn.com/imgextra/i2/O1CN013Wzy8d2A8PxGJZPpT_!!6000000008158-2-tps-980-980.png_110x10000.jpg_.webp"],["难过","https://img.alicdn.com/imgextra/i2/O1CN01zcwaSh1G9gZCFuFal_!!6000000000580-2-tps-980-980.png_110x10000.jpg_.webp"],["调皮","https://img.alicdn.com/imgextra/i3/O1CN01Zd1YHi1TI0lwpBe8c_!!6000000002358-2-tps-980-980.png_110x10000.jpg_.webp"],["愉快","https://img.alicdn.com/imgextra/i2/O1CN0145wDk21SWpyjTvsvA_!!6000000002255-2-tps-980-980.png_110x10000.jpg_.webp"],["白眼","https://img.alicdn.com/imgextra/i4/O1CN01nexGth1hwEAT1SHO2_!!6000000004341-2-tps-980-980.png_110x10000.jpg_.webp"],["拒绝","https://img.alicdn.com/imgextra/i2/O1CN01nqusqS1uHXzoUcpXr_!!6000000006012-2-tps-980-980.png_110x10000.jpg_.webp"],["期待","https://img.alicdn.com/imgextra/i3/O1CN01M44QY11Oh8Q5PdMIx_!!6000000001736-2-tps-980-980.png_110x10000.jpg_.webp"],["困","https://img.alicdn.com/imgextra/i4/O1CN01J4hFFz1Y9pmNdBq76_!!6000000003017-2-tps-980-980.png_110x10000.jpg_.webp"],["流汗","https://img.alicdn.com/imgextra/i4/O1CN01BU3NZ21gdcSjkqnST_!!6000000004165-2-tps-980-980.png_110x10000.jpg_.webp"],["憨笑","https://img.alicdn.com/imgextra/i2/O1CN01Pee9Ql1SJ661eH9By_!!6000000002225-2-tps-980-980.png_110x10000.jpg_.webp"],["耶","https://img.alicdn.com/imgextra/i2/O1CN01pFicsL1ipBhIqzcgs_!!6000000004461-2-tps-980-980.png_110x10000.jpg_.webp"],["奋斗","https://img.alicdn.com/imgextra/i3/O1CN01ZhQ4AV25xBmTK3CnF_!!6000000007592-2-tps-980-980.png_110x10000.jpg_.webp"],["咒骂","https://img.alicdn.com/imgextra/i3/O1CN01r1Zh9927QKb4pnf7k_!!6000000007791-2-tps-980-980.png_110x10000.jpg_.webp"],["疑问","https://img.alicdn.com/imgextra/i4/O1CN01UZqbzt29MmlNctCQS_!!6000000008054-2-tps-980-980.png_110x10000.jpg_.webp"],["嘘","https://img.alicdn.com/imgextra/i1/O1CN01qBlYkM1ojaYF75On5_!!6000000005261-2-tps-980-980.png_110x10000.jpg_.webp"],["晕","https://img.alicdn.com/imgextra/i2/O1CN014zhM2h1wPuSUFoMwV_!!6000000006301-2-tps-980-980.png_110x10000.jpg_.webp"],["开心到模糊","https://img.alicdn.com/imgextra/i1/O1CN01T1Dy271j6akZWo7Vr_!!6000000004499-2-tps-980-980.png_110x10000.jpg_.webp"],["衰","https://img.alicdn.com/imgextra/i1/O1CN01aOXsNr1LmgMvtyzOO_!!6000000001342-2-tps-980-980.png_110x10000.jpg_.webp"],["委屈","https://img.alicdn.com/imgextra/i2/O1CN013J0bMk1QNYih3UFTk_!!6000000001964-2-tps-980-980.png_110x10000.jpg_.webp"],["再见","https://img.alicdn.com/imgextra/i2/O1CN01IHKsQx1UdpFgeTHcA_!!6000000002541-2-tps-980-980.png_110x10000.jpg_.webp"],["鼓掌","https://img.alicdn.com/imgextra/i4/O1CN01DHxB5s1G1RRBxekIu_!!6000000000562-2-tps-980-980.png_110x10000.jpg_.webp"],["吐","https://img.alicdn.com/imgextra/i1/O1CN01xyVxH21LNUaMgW4hh_!!6000000001287-2-tps-980-980.png_110x10000.jpg_.webp"],["坏笑","https://img.alicdn.com/imgextra/i1/O1CN01zV7opv1bIU6iI8OhM_!!6000000003442-2-tps-980-980.png_110x10000.jpg_.webp"],["抠鼻","https://img.alicdn.com/imgextra/i1/O1CN01QOanju1sNqCrtYstu_!!6000000005755-2-tps-980-980.png_110x10000.jpg_.webp"],["叹气","https://img.alicdn.com/imgextra/i3/O1CN01RElx7R1QD1c8ZN07f_!!6000000001941-2-tps-980-980.png_110x10000.jpg_.webp"],["无聊","https://img.alicdn.com/imgextra/i2/O1CN01d91LnZ1UJDQjKCouC_!!6000000002496-2-tps-980-980.png_110x10000.jpg_.webp"],["思考","https://img.alicdn.com/imgextra/i2/O1CN01wQjg2f1tO84ZWitn9_!!6000000005891-2-tps-980-980.png_110x10000.jpg_.webp"],["呆","https://img.alicdn.com/imgextra/i1/O1CN01GLqBWC1DGbhqmpD2L_!!6000000000189-2-tps-980-980.png_110x10000.jpg_.webp"],["哇哦","https://img.alicdn.com/imgextra/i2/O1CN01MtLpS21qRO2bnAA5k_!!6000000005492-2-tps-980-980.png_110x10000.jpg_.webp"],["飞吻","https://img.alicdn.com/imgextra/i4/O1CN01q1WpFE25ljsNKjvHX_!!6000000007567-2-tps-980-980.png_110x10000.jpg_.webp"],["好喜欢","https://img.alicdn.com/imgextra/i2/O1CN01mD4iQM1O57XyQ5SHD_!!6000000001653-2-tps-980-980.png_110x10000.jpg_.webp"],["拜托","https://img.alicdn.com/imgextra/i4/O1CN01SQgrTH1dzCH3pIyRN_!!6000000003806-2-tps-980-980.png_110x10000.jpg_.webp"],["真棒","https://img.alicdn.com/imgextra/i2/O1CN017fcAmd1SCgYCj9Upk_!!6000000002211-2-tps-980-980.png_110x10000.jpg_.webp"],["流鼻血","https://img.alicdn.com/imgextra/i3/O1CN0139JscY1rC6RS9GR4j_!!6000000005594-2-tps-980-980.png_110x10000.jpg_.webp"],["费解","https://img.alicdn.com/imgextra/i1/O1CN01FqAVvR1tyJMPj13ie_!!6000000005970-2-tps-980-980.png_110x10000.jpg_.webp"],["秃头","https://img.alicdn.com/imgextra/i4/O1CN01ZF4bV11thMhqm2Z1h_!!6000000005933-2-tps-980-980.png_110x10000.jpg_.webp"],["嘿哈","https://img.alicdn.com/imgextra/i4/O1CN01ObcOw61FOVlvQg7Mw_!!6000000000477-2-tps-980-980.png_110x10000.jpg_.webp"],["吃土","https://img.alicdn.com/imgextra/i3/O1CN01Z6nJ1b1ZYr22YseHN_!!6000000003207-2-tps-980-980.png_110x10000.jpg_.webp"],["机智","https://img.alicdn.com/imgextra/i1/O1CN01rfKY351zDUZJlBiir_!!6000000006680-2-tps-980-980.png_110x10000.jpg_.webp"],["举杯","https://img.alicdn.com/imgextra/i4/O1CN01R2tn4F1mn8NuEIE8J_!!6000000004998-2-tps-980-980.png_110x10000.jpg_.webp"],["握手","https://img.alicdn.com/imgextra/i4/O1CN01NDcA251JDkvuFhSDb_!!6000000000995-2-tps-980-980.png_110x10000.jpg_.webp"],["挥手","https://img.alicdn.com/imgextra/i4/O1CN01iVN0ht1TmEuSwauGt_!!6000000002424-2-tps-980-980.png_110x10000.jpg_.webp"],["yeah","https://img.alicdn.com/imgextra/i3/O1CN01opt7hh27Wk8omjR4t_!!6000000007805-2-tps-980-980.png_110x10000.jpg_.webp"],["666","https://img.alicdn.com/imgextra/i3/O1CN01YRWDPF1OjQOpXeuTC_!!6000000001741-2-tps-980-980.png_110x10000.jpg_.webp"],["棒","https://img.alicdn.com/imgextra/i3/O1CN01agprvs1HU7rPRxOnB_!!6000000000760-2-tps-980-980.png_110x10000.jpg_.webp"],["爱你","https://img.alicdn.com/imgextra/i1/O1CN01SzxgcH1GSSo6Lwmwk_!!6000000000621-2-tps-980-980.png_110x10000.jpg_.webp"],["比心","https://img.alicdn.com/imgextra/i1/O1CN01YHZ39t1DeQIeb0TWQ_!!6000000000241-2-tps-980-980.png_110x10000.jpg_.webp"],["感谢","https://img.alicdn.com/imgextra/i3/O1CN01ywacF81baLYNeyK1n_!!6000000003481-2-tps-980-980.png_110x10000.jpg_.webp"],["拍手","https://img.alicdn.com/imgextra/i4/O1CN01wbj4wv1K7ArD9AU44_!!6000000001116-2-tps-980-980.png_110x10000.jpg_.webp"],["拉钩","https://img.alicdn.com/imgextra/i1/O1CN01dePkKH1HOd6ivAcu8_!!6000000000748-2-tps-980-980.png_110x10000.jpg_.webp"],["没钱","https://img.alicdn.com/imgextra/i3/O1CN01qhxGjp1zD2AfqmWx5_!!6000000006679-2-tps-980-980.png_110x10000.jpg_.webp"],["小刀","https://img.alicdn.com/imgextra/i3/O1CN01tFVx5Y1T2thPjhR6b_!!6000000002325-2-tps-980-980.png_110x10000.jpg_.webp"],["不刀","https://img.alicdn.com/imgextra/i4/O1CN01zTxff61clcvOcTS3n_!!6000000003641-2-tps-980-980.png_110x10000.jpg_.webp"],["同出","https://img.alicdn.com/imgextra/i3/O1CN01URKas6249R8ozS98O_!!6000000007348-2-tps-980-980.png_110x10000.jpg_.webp"],["递钱","https://img.alicdn.com/imgextra/i4/O1CN01PzhgV51FLlOaZHZ6n_!!6000000000471-2-tps-980-980.png_110x10000.jpg_.webp"],["数钱","https://img.alicdn.com/imgextra/i3/O1CN01CzXXvp23khkljToQH_!!6000000007294-2-tps-980-980.png_110x10000.jpg_.webp"],["打call","https://img.alicdn.com/imgextra/i1/O1CN01X7VUVm1il48IYv8Qw_!!6000000004452-2-tps-980-980.png_110x10000.jpg_.webp"],["号外","https://img.alicdn.com/imgextra/i2/O1CN01vg6xSM1Vxo9EKyfjR_!!6000000002720-2-tps-980-980.png_110x10000.jpg_.webp"],["包邮","https://img.alicdn.com/imgextra/i3/O1CN01yVS7ys24jA22oVZ2T_!!6000000007426-2-tps-980-980.png_110x10000.jpg_.webp"],["求赞","https://img.alicdn.com/imgextra/i1/O1CN01Xwqi5A1giCQMRcX6N_!!6000000004175-2-tps-980-980.png_110x10000.jpg_.webp"],["非主流","https://img.alicdn.com/imgextra/i1/O1CN013wyI1j1hlEfDUoATI_!!6000000004317-2-tps-980-980.png_110x10000.jpg_.webp"],["吃瓜","https://img.alicdn.com/imgextra/i1/O1CN01LLOFsh1UUCw0deZba_!!6000000002520-2-tps-980-980.png_110x10000.jpg_.webp"],["种草","https://img.alicdn.com/imgextra/i2/O1CN01ooeRC81hA8a4x9S3q_!!6000000004236-2-tps-980-980.png_110x10000.jpg_.webp"],["佛系","https://img.alicdn.com/imgextra/i4/O1CN01BYXEe321GMHMZ9w66_!!6000000006957-2-tps-980-980.png_110x10000.jpg_.webp"],["超便宜","https://img.alicdn.com/imgextra/i4/O1CN01mqgSZi1Er4rOIDiP7_!!6000000000404-2-tps-980-980.png_110x10000.jpg_.webp"],["拥抱","https://img.alicdn.com/imgextra/i1/O1CN01yuGD9c1hJkttfKHAm_!!6000000004257-2-tps-980-980.png_110x10000.jpg_.webp"],["摊手","https://img.alicdn.com/imgextra/i2/O1CN014AiIqE1o9repE6STR_!!6000000005183-2-tps-980-980.png_110x10000.jpg_.webp"],["举手","https://img.alicdn.com/imgextra/i1/O1CN01xizuHZ1WPkJCogbuj_!!6000000002781-2-tps-980-980.png_110x10000.jpg_.webp"],["蹲","https://img.alicdn.com/imgextra/i3/O1CN01Midjjn1FrMj2CWer6_!!6000000000540-2-tps-980-980.png_110x10000.jpg_.webp"],["跪了","https://img.alicdn.com/imgextra/i3/O1CN01F2y52j24E16L6RIjF_!!6000000007358-2-tps-980-980.png_110x10000.jpg_.webp"],["拜","https://img.alicdn.com/imgextra/i4/O1CN01Jldd1G1oXDrEHH2qr_!!6000000005234-2-tps-980-980.png_110x10000.jpg_.webp"],["排","https://img.alicdn.com/imgextra/i3/O1CN01uSUmYD1jD0IJf0UVU_!!6000000004513-2-tps-980-980.png_110x10000.jpg_.webp"],["旺财","https://img.alicdn.com/imgextra/i3/O1CN01A25Mv01DKjGseAmuP_!!6000000000198-2-tps-980-980.png_110x10000.jpg_.webp"],["招财猫","https://img.alicdn.com/imgextra/i3/O1CN01WmJ7Sr20EhDyp86Bd_!!6000000006818-2-tps-980-980.png_110x10000.jpg_.webp"],["酸了","https://img.alicdn.com/imgextra/i3/O1CN01UFgjn61JJi5Iqxdk7_!!6000000001008-2-tps-980-980.png_110x10000.jpg_.webp"],["鸭鸭","https://img.alicdn.com/imgextra/i3/O1CN01pHSCSQ1deaS8WDiqG_!!6000000003761-2-tps-980-980.png_110x10000.jpg_.webp"],["方了","https://img.alicdn.com/imgextra/i3/O1CN01br7g711whlu8xOPUt_!!6000000006340-2-tps-980-980.png_110x10000.jpg_.webp"],["白菜","https://img.alicdn.com/imgextra/i1/O1CN01KABFLt24WKwXjVp08_!!6000000007398-2-tps-980-980.png_110x10000.jpg_.webp"],["桃子","https://img.alicdn.com/imgextra/i1/O1CN01CQhhPH1vJfRjDGBv5_!!6000000006152-2-tps-980-980.png_110x10000.jpg_.webp"],["打包","https://img.alicdn.com/imgextra/i3/O1CN01oYOkUI1VT7c0ivZHV_!!6000000002653-2-tps-980-980.png_110x10000.jpg_.webp"],["沙发","https://img.alicdn.com/imgextra/i4/O1CN018qUFaE1DGbhqpMIit_!!6000000000189-2-tps-980-980.png_110x10000.jpg_.webp"],["南","https://img.alicdn.com/imgextra/i1/O1CN01ZSA6wg1PEZKf4h99R_!!6000000001809-2-tps-980-980.png_110x10000.jpg_.webp"],["盯","https://img.alicdn.com/imgextra/i4/O1CN01OWB1Gx1s01bzBhHN6_!!6000000005703-2-tps-980-980.png_110x10000.jpg_.webp"],["hot","https://img.alicdn.com/imgextra/i4/O1CN01DDD9uA22cAl7VDH7d_!!6000000007140-2-tps-980-980.png_110x10000.jpg_.webp"],["new","https://img.alicdn.com/imgextra/i3/O1CN01rRJXJo1qwzN4YnOHX_!!6000000005561-2-tps-980-980.png_110x10000.jpg_.webp"],["cool","https://img.alicdn.com/imgextra/i4/O1CN013bUubF2855qb2Qt5l_!!6000000007880-2-tps-980-980.png_110x10000.jpg_.webp"],["1","https://img.alicdn.com/imgextra/i1/O1CN01U8XG5y1Ie22frQHCQ_!!6000000000917-2-tps-980-980.png_110x10000.jpg_.webp"],["可","https://img.alicdn.com/imgextra/i2/O1CN01SMjtPG1iJaN17p94N_!!6000000004392-2-tps-980-980.png_110x10000.jpg_.webp"],["搬砖","https://img.alicdn.com/imgextra/i1/O1CN01GbqW6G1LOrm0Gllcb_!!6000000001290-2-tps-980-980.png_110x10000.jpg_.webp"],["菜狗","https://img.alicdn.com/imgextra/i2/O1CN01VtN0t91USNLmvfmol_!!6000000002516-2-tps-980-980.png_110x10000.jpg_.webp"],["开心面具","https://img.alicdn.com/imgextra/i3/O1CN017elkpk22EoYlBPKd3_!!6000000007089-2-tps-980-980.png_110x10000.jpg_.webp"],["快递","https://img.alicdn.com/imgextra/i2/O1CN01AmUZXk1d3wle5O8IJ_!!6000000003681-2-tps-980-980.png_110x10000.jpg_.webp"],["裂开","https://img.alicdn.com/imgextra/i1/O1CN01BihwvO1a5N9bFt0LU_!!6000000003278-2-tps-980-980.png_110x10000.jpg_.webp"],["啤酒","https://img.alicdn.com/imgextra/i4/O1CN01jDkgEj1WvLdXUVBDx_!!6000000002850-2-tps-980-980.png_110x10000.jpg_.webp"],["瑞思拜","https://img.alicdn.com/imgextra/i4/O1CN011gR0Um1K3VgpYjPOi_!!6000000001108-2-tps-980-980.png_110x10000.jpg_.webp"],["小丑","https://img.alicdn.com/imgextra/i3/O1CN01jMikhO1NJUM15XKTf_!!6000000001549-2-tps-980-980.png_110x10000.jpg_.webp"],["爱心","https://img.alicdn.com/imgextra/i1/O1CN015RVSWf23s25eETJqO_!!6000000007310-2-tps-980-980.png_110x10000.jpg_.webp"]],Ji=t=>t,Gi=new Map(sr.map(([t,s])=>[t,s])),Vi=t=>t.split(/(\[[^\]]+\])/g).map((s,a)=>{const l=s.startsWith("[")?Gi.get(s.slice(1,-1)):void 0;return l?e.jsx("img",{src:l,alt:s,title:s,className:"mx-0.5 inline-block h-7 w-7 align-middle"},a):e.jsx(Is.Fragment,{children:s},a)}),Qi=(t,s,a)=>{const l=s.trim().toLowerCase();return t.filter(n=>a&&n.unread_count<=0?!1:l?[n.buyer_name,n.buyer_id,n.item_title,n.last_message].some(c=>(c||"").toLowerCase().includes(l)):!0)},Ki=(t,s)=>{const a=new Set(t.map(l=>l.message_key));return[...s.filter(l=>!a.has(l.message_key)),...t]},fs=(t,s)=>{const a=t.findIndex(l=>l.message_key===s.message_key);return a<0?[...t,s]:t.map((l,n)=>n===a?s:l)},Fe=(t,s,a)=>t===s&&!a.aborted,_t=t=>t instanceof Error&&t.message==="请求已取消",Hi=t=>{if(!t)return"";const s=new Date(t<1e10?t*1e3:t),a=new Date;return s.toDateString()===a.toDateString()?s.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hour12:!1}):s.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit"})},Zi=t=>new Date(t<1e10?t*1e3:t).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}),Yi=()=>{const[t,s]=r.useState([]),[a,l]=r.useState(""),[n,c]=r.useState({}),[u,h]=r.useState(""),[m,N]=r.useState([]),[x,p]=r.useState(""),[_,S]=r.useState(!1),[q,w]=r.useState(""),[P,A]=r.useState(!0),[G,H]=r.useState(!1),[X,f]=r.useState(!1),[y,z]=r.useState(!1),[O,F]=r.useState(),[d,B]=r.useState({}),[Z,M]=r.useState({}),[b,k]=r.useState(!1),[D,C]=r.useState(!1),[W,V]=r.useState(!1),[v,ee]=r.useState(""),[be,U]=r.useState("connecting"),[ae,ge]=r.useState(null),[$,L]=r.useState(null),Q=r.useRef(""),Y=r.useRef(""),re=r.useRef(null),ue=r.useRef({accountID:"",chatID:""}),je=r.useRef(!0),R=r.useRef(!1),T=r.useRef(null),g=r.useRef(new Set),le=r.useRef(0),oe=r.useRef(null),ne=r.useRef(0),de=r.useRef(null),Se=r.useRef(0),Ee=r.useRef(null),Te=r.useRef(0),Ue=r.useRef(null);r.useEffect(()=>{Q.current=a},[a]),r.useEffect(()=>{Y.current=u},[u]);const Me=r.useCallback(async J=>{var E;const ie=++le.current;(E=oe.current)==null||E.abort();const j=new AbortController;oe.current=j;try{const se=await is(J,void 0,{signal:j.signal},!0);return Fe(le.current,ie,j.signal)?(c(ce=>({...ce,[J]:se.sessions})),B(ce=>({...ce,[J]:se.next_cursor})),M(ce=>({...ce,[J]:se.has_more})),se.sessions):[]}catch(se){return Fe(le.current,ie,j.signal)&&!_t(se)&&ee(se instanceof Error?se.message:"同步会话失败"),[]}},[]);r.useEffect(()=>{const J=new AbortController;return(async()=>{var j;A(!0);try{const[E,se]=await Promise.all([Ft({signal:J.signal}),Ss({signal:J.signal})]),fe=E.map(me=>{var o,K;return{...me,runtime_state:((o=se[me.id])==null?void 0:o.state)||(me.enabled?"connecting":"disabled"),runtime_connected:((K=se[me.id])==null?void 0:K.connected)===!0}}).filter(me=>me.enabled),De=await Promise.all(fe.map(async me=>[me.id,await is(me.id,void 0,{signal:J.signal})]));if(J.signal.aborted)return;s(fe),c(Object.fromEntries(De.map(([me,o])=>[me,o.sessions]))),B(Object.fromEntries(De.map(([me,o])=>[me,o.next_cursor]))),M(Object.fromEntries(De.map(([me,o])=>[me,o.has_more])));const ve=window.localStorage.getItem("ydisks.chat.account.v1")||"",Pe=fe.some(me=>me.id===ve)?ve:((j=fe[0])==null?void 0:j.id)||"";l(Pe)}catch(E){J.signal.aborted||ee(E instanceof Error?E.message:"加载聊天数据失败")}finally{J.signal.aborted||A(!1)}})(),()=>J.abort()},[]),r.useEffect(()=>{let J=!1,ie=0,j=null;const E=async()=>{j=new AbortController;try{const se=await Ss({signal:j.signal,timeoutMs:1e4});J||s(ce=>ce.map(fe=>{var De,ve;return{...fe,runtime_state:((De=se[fe.id])==null?void 0:De.state)||fe.runtime_state,runtime_connected:((ve=se[fe.id])==null?void 0:ve.connected)??fe.runtime_connected}}))}catch{}finally{J||(ie=window.setTimeout(E,3e3))}};return ie=window.setTimeout(E,3e3),()=>{J=!0,window.clearTimeout(ie),j==null||j.abort()}},[]),r.useEffect(()=>{if(!a)return;window.localStorage.setItem("ydisks.chat.account.v1",a);const J=n[a]||[];h(ie=>{var j;return J.some(E=>E.chat_id===ie)?ie:((j=J[0])==null?void 0:j.chat_id)||""})},[a,n]),r.useEffect(()=>{!a||g.current.has(a)||(g.current.add(a),Me(a))},[a,Me]),r.useEffect(()=>{var j;if(!a||!u){N([]);return}const J=++ne.current;(j=de.current)==null||j.abort();const ie=new AbortController;return de.current=ie,H(!0),Promise.all([Xs(a,u,void 0,void 0,{signal:ie.signal}),ea(a,u,{signal:ie.signal})]).then(([E])=>{Fe(ne.current,J,ie.signal)&&(N(E.messages),z(E.has_more),F(E.next_cursor),E.session&&c(se=>({...se,[a]:(se[a]||[]).map(ce=>{var fe;return ce.chat_id===((fe=E.session)==null?void 0:fe.chat_id)?E.session:ce})})),c(se=>({...se,[a]:(se[a]||[]).map(ce=>ce.chat_id===u?{...ce,unread_count:0}:ce)})))}).catch(E=>{Fe(ne.current,J,ie.signal)&&!_t(E)&&ee(E instanceof Error?E.message:"加载消息失败")}).finally(()=>{Fe(ne.current,J,ie.signal)&&H(!1)}),()=>ie.abort()},[a,u]),r.useEffect(()=>{var J;(J=Ee.current)==null||J.abort(),Se.current+=1},[a]),r.useEffect(()=>{var J;(J=Ue.current)==null||J.abort(),Te.current+=1},[a,u]),r.useEffect(()=>()=>{var J,ie,j,E;(J=oe.current)==null||J.abort(),(ie=de.current)==null||ie.abort(),(j=Ee.current)==null||j.abort(),(E=Ue.current)==null||E.abort()},[]);const Be=r.useCallback(async()=>{var se;if(!a||!u||X||!y)return;const J=re.current,ie=(J==null?void 0:J.scrollHeight)||0,j=ne.current,E=new AbortController;R.current=!0,f(!0),ee("");try{const ce=(se=m[0])==null?void 0:se.id,fe=await Xs(a,u,O,ce,{signal:E.signal});if(!Fe(ne.current,j,E.signal))return;N(De=>Ki(De,fe.messages)),z(fe.has_more),F(fe.next_cursor),requestAnimationFrame(()=>{J&&(J.scrollTop+=J.scrollHeight-ie)})}catch(ce){R.current=!1,_t(ce)||ee(ce instanceof Error?ce.message:"加载历史消息失败")}finally{f(!1)}},[a,u,y,O,m,X]);r.useEffect(()=>{let J=!1,ie=0,j=0,E=null;const se=()=>{if(J)return;U("connecting");const ce=window.location.protocol==="https:"?"wss:":"ws:";E=new WebSocket(`${ce}//${window.location.host}/api/v1/chat/ws`),E.onopen=()=>{j=0,U("online")},E.onmessage=fe=>{try{const ve=JSON.parse(fe.data).message;if(!ve)return;const Pe=ve.account_id;c(me=>{const o=me[Pe]||[];return o.some(xe=>xe.chat_id===ve.chat_id)?{...me,[Pe]:o.map(xe=>xe.chat_id===ve.chat_id?{...xe,last_message:ve.content,last_message_at:ve.sent_at,unread_count:ve.direction==="incoming"&&(Q.current!==Pe||Y.current!==ve.chat_id)?xe.unread_count+1:xe.unread_count}:xe).sort((xe,Le)=>Le.last_message_at-xe.last_message_at)}:(Me(Pe),me)}),Q.current===Pe&&Y.current===ve.chat_id&&(N(me=>fs(me,ve)),ve.direction==="incoming"&&ea(Pe,ve.chat_id))}catch{}},E.onclose=()=>{if(J)return;U("offline");const fe=Math.min(15e3,1e3*2**Math.min(j++,4));ie=window.setTimeout(se,fe)},E.onerror=()=>E==null?void 0:E.close()};return se(),()=>{J=!0,window.clearTimeout(ie),E==null||E.close()}},[Me]);const Je=r.useCallback(()=>{const J=re.current;if(!J)return;const ie=J.scrollHeight-J.scrollTop-J.clientHeight;je.current=ie<=48},[]);r.useLayoutEffect(()=>{const J=ue.current.accountID!==a||ue.current.chatID!==u;ue.current={accountID:a,chatID:u},J&&(je.current=!0);const ie=re.current;if(ie){if(R.current){R.current=!1;return}(G||je.current)&&(ie.scrollTop=ie.scrollHeight)}},[a,u,m,G]);const He=t.find(J=>J.id===a),we=n[a]||[],pe=we.find(J=>J.chat_id===u),Ve=r.useMemo(()=>Qi(we,x,_),[we,x,_]),it=r.useCallback(J=>(n[J]||[]).reduce((ie,j)=>ie+j.unread_count,0),[n]),tt=r.useCallback(async()=>{var E;if(!a||b||!Z[a])return;const J=++Se.current;(E=Ee.current)==null||E.abort();const ie=new AbortController;Ee.current=ie;const j=a;k(!0),ee("");try{const se=await is(j,d[j],{signal:ie.signal},!0);if(!Fe(Se.current,J,ie.signal))return;c(ce=>({...ce,[j]:se.sessions})),B(ce=>({...ce,[j]:se.next_cursor})),M(ce=>({...ce,[j]:se.has_more}))}catch(se){Fe(Se.current,J,ie.signal)&&!_t(se)&&ee(se instanceof Error?se.message:"加载历史联系人失败")}finally{Fe(Se.current,J,ie.signal)&&k(!1)}},[a,d,b,Z]),Qe=r.useCallback(async(J,ie)=>{var se;if(!pe||!a||W)return;const j=++Te.current;(se=Ue.current)==null||se.abort();const E=new AbortController;Ue.current=E,V(!0),ee("");try{const ce=await ol({account_id:a,chat_id:pe.chat_id,buyer_id:pe.buyer_id,buyer_name:pe.buyer_name,item_id:pe.item_id,item_title:pe.item_title,text:J},{signal:E.signal});if(!Fe(Te.current,j,E.signal))return;w(""),ge(null),N(fe=>fs(fe,ce.message))}catch(ce){Fe(Te.current,j,E.signal)&&(ie&&ge(J),_t(ce)||ee(ce instanceof Error?ce.message:"消息发送失败"))}finally{Fe(Te.current,j,E.signal)&&V(!1)}},[a,pe,W]),Ge=r.useCallback(async(J,ie)=>{var se;if(!pe||!a||W)return;const j=++Te.current;(se=Ue.current)==null||se.abort();const E=new AbortController;Ue.current=E,V(!0),ee("");try{const ce=await cl({account_id:a,chat_id:pe.chat_id,buyer_id:pe.buyer_id,buyer_name:pe.buyer_name,buyer_avatar_url:pe.buyer_avatar_url,item_id:pe.item_id,item_title:pe.item_title,image:J},{signal:E.signal});if(!Fe(Te.current,j,E.signal))return;L(null),N(fe=>fs(fe,ce.message))}catch(ce){Fe(Te.current,j,E.signal)&&(ie&&L(J),_t(ce)||ee(ce instanceof Error?ce.message:"图片发送失败"))}finally{Fe(Te.current,j,E.signal)&&(V(!1),T.current&&(T.current.value=""))}},[a,pe,W]),ot=r.useCallback(async()=>{const J=q.trim();!J||!pe||!a||W||await Qe(J,!0)},[a,q,pe,Qe,W]),pt=r.useCallback(async J=>{!J||!pe||!a||W||await Ge(J,!0)},[a,pe,Ge,W]),ht=r.useCallback(async()=>{ae?await Qe(ae,!1):$&&await Ge($,!1)},[$,ae,Ge,Qe]);return{accounts:t,activeAccountID:a,activeSessions:we,selectedSession:pe,activeAccount:He,messages:m,search:x,unreadOnly:_,draft:q,loading:P,messagesLoading:G,olderLoading:X,hasOlder:y,contactsLoading:b,hasMoreContacts:Z[a]===!0,emojiOpen:D,sending:W,error:v,liveState:be,activeChatID:u,filteredSessions:Ve,scrollRef:re,imageInputRef:T,setActiveAccountID:l,setActiveChatID:h,setSearch:p,setUnreadOnly:S,setDraft:w,setEmojiOpen:C,reloadSessions:Me,loadMoreContacts:tt,loadOlderMessages:Be,handleMessageScroll:Je,handleSend:ot,handleImage:pt,retrySend:ht,retryAvailable:!!(ae||$),unreadForAccount:it,emojiURL:Ji,xianyuEmojis:sr,renderXianyuText:Vi,formatClock:Hi,messageTime:Zi}},Xi=()=>{const{accounts:t,activeAccountID:s,activeChatID:a,activeAccount:l,selectedSession:n,filteredSessions:c,messages:u,search:h,unreadOnly:m,draft:N,loading:x,messagesLoading:p,olderLoading:_,hasOlder:S,contactsLoading:q,hasMoreContacts:w,emojiOpen:P,sending:A,error:G,liveState:H,scrollRef:X,imageInputRef:f,setActiveAccountID:y,setActiveChatID:z,setSearch:O,setUnreadOnly:F,setDraft:d,setEmojiOpen:B,reloadSessions:Z,loadMoreContacts:M,loadOlderMessages:b,handleMessageScroll:k,handleSend:D,handleImage:C,retrySend:W,retryAvailable:V,unreadForAccount:v,emojiURL:ee,xianyuEmojis:be,renderXianyuText:U,formatClock:ae,messageTime:ge}=Yi();return x?e.jsx("div",{className:"flex h-[calc(100vh-4rem)] items-center justify-center",children:e.jsx(_e,{className:"h-8 w-8 animate-spin text-sky-500"})}):e.jsxs("section",{className:"flex h-[calc(100vh-4rem)] min-h-[560px] flex-col overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-chat",children:[e.jsxs("header",{className:"border-b border-slate-200 bg-slate-50/70 px-5 pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-black tracking-tight text-slate-950",children:"在线聊天"}),e.jsx("p",{className:"mt-0.5 text-xs font-medium text-slate-500",children:"复用账号实时连接,消息按账号完全隔离"})]}),e.jsxs("div",{className:`flex items-center gap-2 rounded-full px-3 py-1.5 text-xs font-bold ${H==="online"?"bg-emerald-50 text-emerald-700":H==="connecting"?"bg-amber-50 text-amber-700":"bg-red-50 text-red-700"}`,children:[H==="online"?e.jsx(Rr,{className:"h-3.5 w-3.5"}):e.jsx(Ar,{className:"h-3.5 w-3.5"}),H==="online"?"实时同步中":H==="connecting"?"正在连接":"连接已断开"]})]}),e.jsx("div",{className:"flex gap-1 overflow-x-auto pb-0",role:"tablist","aria-label":"聊天账号",children:t.map($=>{const L=$.id===s,Q=v($.id),Y=$.runtime_state==="online";return e.jsxs("button",{type:"button",role:"tab","aria-selected":L,onClick:()=>y($.id),className:`relative flex h-11 shrink-0 items-center gap-2 border-b-2 px-3 text-sm font-extrabold transition-colors ${L?"border-sky-500 text-sky-700":"border-transparent text-slate-500 hover:text-slate-900"}`,children:[e.jsx("span",{className:`h-2 w-2 rounded-full ${Y?"bg-emerald-500":"bg-slate-300"}`}),e.jsx("span",{className:"max-w-36 truncate",children:$.nickname||$.remark||$.id}),Q>0&&e.jsx("span",{className:"min-w-5 rounded-full bg-red-500 px-1.5 py-0.5 text-[10px] text-white",children:Q>99?"99+":Q})]},$.id)})})]}),t.length===0?e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-center",children:[e.jsx(ys,{className:"h-12 w-12 text-slate-300"}),e.jsx("h3",{className:"mt-4 font-black text-slate-800",children:"暂无启用账号"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"先在账号管理中启用账号,聊天会话会自动出现。"})]}):e.jsxs("div",{className:"grid min-h-0 flex-1 overflow-hidden grid-cols-[320px_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"flex min-h-0 flex-col border-r border-slate-200 bg-slate-50/40",children:[e.jsxs("div",{className:"space-y-3 border-b border-slate-200 p-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(St,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),e.jsx("input",{value:h,onChange:$=>O($.target.value),placeholder:"搜索用户、商品或消息",className:"h-10 w-full rounded-xl border border-slate-200 bg-white pl-9 pr-3 text-sm outline-none transition focus:border-sky-400 focus:ring-2 focus:ring-sky-100"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("button",{type:"button",onClick:()=>F($=>!$),className:`rounded-lg px-2.5 py-1.5 text-xs font-bold ${m?"bg-sky-100 text-sky-700":"text-slate-500 hover:bg-slate-100"}`,children:m?"只看未读":"全部会话"}),e.jsx("button",{type:"button",title:"刷新会话",onClick:()=>void Z(s),className:"rounded-lg p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700",children:e.jsx(We,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[c.map($=>e.jsxs("button",{type:"button",onClick:()=>z($.chat_id),className:`flex w-full gap-3 border-b border-slate-100 p-4 text-left transition-colors ${$.chat_id===a?"bg-white shadow-chat-active":"hover:bg-white/80"}`,children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-full bg-slate-200 text-slate-500",children:$.buyer_avatar_url?e.jsx("img",{src:$.buyer_avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx(Zt,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-extrabold text-slate-900",children:$.buyer_name||`用户 ${$.buyer_id}`}),e.jsx("span",{className:"ml-auto shrink-0 text-[10px] font-medium text-slate-400",children:ae($.last_message_at)})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-xs text-slate-500",children:$.last_message||"暂无消息"}),$.unread_count>0&&e.jsx("span",{className:"ml-auto min-w-5 shrink-0 rounded-full bg-red-500 px-1.5 py-0.5 text-center text-[10px] font-bold text-white",children:$.unread_count})]}),$.item_title&&e.jsxs("div",{className:"mt-1.5 truncate text-[10px] font-medium text-sky-700",children:["商品 · ",$.item_title]})]})]},$.chat_id)),c.length===0&&e.jsx("div",{className:"px-6 py-16 text-center text-sm text-slate-400",children:"当前账号暂无匹配会话"}),w&&!h&&!m&&e.jsx("div",{className:"flex justify-center p-4",children:e.jsxs("button",{type:"button",onClick:()=>void M(),disabled:q,className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-2 text-xs font-bold text-slate-500 shadow-sm hover:border-sky-200 hover:text-sky-600 disabled:opacity-50",children:[q&&e.jsx(_e,{className:"h-3.5 w-3.5 animate-spin"}),q?"正在加载":"加载更多历史联系人"]})})]})]}),e.jsx("main",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-surface-subtle",children:n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-16 shrink-0 items-center border-b border-slate-200 bg-white px-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-black text-slate-950",children:n.buyer_name||n.buyer_id}),e.jsxs("div",{className:"mt-0.5 truncate text-xs text-slate-500",children:["用户 ID:",n.buyer_id]})]}),e.jsx("span",{className:`ml-auto rounded-full px-2.5 py-1 text-[10px] font-bold ${(l==null?void 0:l.runtime_state)==="online"?"bg-emerald-50 text-emerald-700":"bg-slate-100 text-slate-500"}`,children:(l==null?void 0:l.runtime_state)==="online"?"账号在线":"账号离线"})]}),e.jsx("div",{ref:X,onScroll:k,className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5",children:p?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(_e,{className:"h-6 w-6 animate-spin text-sky-500"})}):e.jsxs(e.Fragment,{children:[S&&e.jsx("div",{className:"flex justify-center pb-1",children:e.jsxs("button",{type:"button",onClick:()=>void b(),disabled:_,className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-1.5 text-xs font-bold text-slate-500 shadow-sm transition hover:border-sky-200 hover:text-sky-600 disabled:opacity-50",children:[_&&e.jsx(_e,{className:"h-3.5 w-3.5 animate-spin"}),_?"正在加载":"加载更早消息"]})}),u.map($=>{const L=$.direction==="outgoing";return $.message_type==="system"?e.jsx("div",{className:"flex justify-center py-1",children:e.jsxs("div",{className:"max-w-[82%] rounded-xl border border-slate-200 bg-slate-100 px-4 py-2 text-center text-xs leading-5 text-slate-500",children:[U($.content),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:ge($.sent_at)})]})},$.message_key):e.jsxs("div",{className:`flex items-end gap-2.5 ${L?"justify-end":"justify-start"}`,children:[!L&&e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-slate-200 ring-2 ring-white",children:n.buyer_avatar_url?e.jsx("img",{src:n.buyer_avatar_url,alt:n.buyer_name||"用户",className:"h-full w-full object-cover"}):e.jsx(Zt,{className:"m-2 h-5 w-5 text-slate-500"})}),e.jsxs("div",{className:`max-w-[72%] ${L?"items-end":"items-start"} flex flex-col`,children:[e.jsx("div",{className:"mb-1 px-1 text-[10px] font-semibold text-slate-400",children:L?(l==null?void 0:l.nickname)||(l==null?void 0:l.remark)||"我":n.buyer_name||$.sender_name||n.buyer_id}),$.message_type==="image"?e.jsx("a",{href:$.content,target:"_blank",rel:"noreferrer",className:`block overflow-hidden rounded-2xl border bg-white p-1 shadow-sm ${L?"rounded-br-md border-sky-200":"rounded-bl-md border-slate-200"}`,children:e.jsx("img",{src:$.content,alt:"聊天图片",className:"max-h-80 max-w-full rounded-xl object-contain"})}):$.message_type==="video"?e.jsx("video",{src:$.content,controls:!0,preload:"metadata",className:"max-h-80 max-w-full rounded-2xl bg-black"}):e.jsx("div",{className:`rounded-2xl px-4 py-2.5 text-sm leading-6 shadow-sm ${L?"rounded-br-md bg-sky-500 text-white":"rounded-bl-md border border-slate-200 bg-white text-slate-800"}`,children:U($.content)}),e.jsxs("div",{className:"mt-1 flex items-center gap-1 text-[10px] text-slate-400",children:[ge($.sent_at),L&&($.status==="failed"?e.jsx(ut,{className:"h-3 w-3 text-red-500"}):$.status==="sent"?e.jsx(Ir,{className:"h-3 w-3 text-sky-500"}):e.jsx(Ye,{className:"h-3 w-3"}))]})]}),L&&e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-sky-100 ring-2 ring-white",children:l!=null&&l.avatar_url?e.jsx("img",{src:l.avatar_url,alt:"我",className:"h-full w-full object-cover"}):e.jsx(Zt,{className:"m-2 h-5 w-5 text-sky-600"})})]},$.message_key)})]})}),G&&e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-red-100 bg-red-50 px-5 py-2 text-xs font-medium text-red-700",children:[e.jsx("span",{children:G}),V&&e.jsx("button",{type:"button",className:"font-bold underline",onClick:()=>void W(),children:"重试发送"})]}),e.jsxs("div",{className:"relative z-10 shrink-0 border-t border-slate-200 bg-white p-4 shadow-chat-input",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-1",children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",onClick:()=>B($=>!$),disabled:A||(l==null?void 0:l.runtime_state)!=="online",className:"rounded-lg p-2 text-slate-500 hover:bg-sky-50 hover:text-sky-600 disabled:opacity-40",title:"闲鱼表情",children:e.jsx(Or,{className:"h-5 w-5"})}),P&&e.jsxs("div",{className:"absolute bottom-11 left-0 z-30 w-[360px] rounded-2xl border border-slate-200 bg-white p-3 shadow-2xl",children:[e.jsx("div",{className:"mb-2 text-xs font-bold text-slate-500",children:"全部表情"}),e.jsx("div",{className:"grid max-h-72 grid-cols-8 gap-1 overflow-y-auto",children:be.map(([$,L])=>e.jsx("button",{type:"button",title:`[${$}]`,onClick:()=>{d(Q=>Q+`[${$}]`),B(!1)},className:"flex h-10 w-10 items-center justify-center rounded-lg hover:bg-slate-100",children:e.jsx("img",{src:ee(L),alt:`[${$}]`,className:"h-8 w-8 object-contain"})},$))})]})]}),e.jsx("input",{ref:f,type:"file",accept:"image/*",className:"hidden",onChange:$=>{var L;return void C((L=$.target.files)==null?void 0:L[0])}}),e.jsx("button",{type:"button",onClick:()=>{var $;return($=f.current)==null?void 0:$.click()},disabled:A||(l==null?void 0:l.runtime_state)!=="online",className:"rounded-lg p-2 text-slate-500 transition hover:bg-sky-50 hover:text-sky-600 disabled:opacity-40",title:"发送图片(最大 10MB)",children:e.jsx(Pr,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"flex items-end gap-3 rounded-2xl border border-slate-200 bg-slate-50 p-2 transition focus-within:border-sky-400 focus-within:ring-2 focus-within:ring-sky-100",children:[e.jsx("textarea",{value:N,onChange:$=>d($.target.value),rows:2,maxLength:2e3,onKeyDown:$=>{$.key==="Enter"&&!$.shiftKey&&($.preventDefault(),D())},disabled:(l==null?void 0:l.runtime_state)!=="online",placeholder:(l==null?void 0:l.runtime_state)==="online"?"输入消息,Enter 发送,Shift + Enter 换行":"账号离线,暂时无法发送",className:"max-h-32 min-h-12 flex-1 resize-none bg-transparent px-2 py-2 text-sm leading-6 outline-none disabled:cursor-not-allowed"}),e.jsx("button",{type:"button",onClick:()=>void D(),disabled:!N.trim()||A||(l==null?void 0:l.runtime_state)!=="online",className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-sky-500 text-white shadow-md shadow-sky-100 transition hover:bg-sky-600 disabled:cursor-not-allowed disabled:bg-slate-300 disabled:shadow-none","aria-label":"发送消息",children:A?e.jsx(_e,{className:"h-4 w-4 animate-spin"}):e.jsx(ss,{className:"h-4 w-4"})})]})]})]}):e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-center",children:[e.jsx(ys,{className:"h-12 w-12 text-slate-300"}),e.jsx("h3",{className:"mt-4 font-black text-slate-700",children:"选择一个用户开始聊天"}),e.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"该账号的新消息会实时出现在左侧列表。"})]})})]})]})},ar="ydisks.sidebar.v1",eo=()=>{try{return window.localStorage.getItem(ar)==="collapsed"}catch{return!1}},to=t=>{try{window.localStorage.setItem(ar,t?"collapsed":"expanded")}catch{}},rr={"/app/dashboard":"dashboard","/app/accounts":"accounts","/app/chat":"chat","/app/orders":"orders","/app/cards":"cards","/app/items":"items","/app/rules":"rules","/app/notifications":"notifications","/app/settings":"settings"},ya=Object.fromEntries(Object.entries(rr).map(([t,s])=>[s,t])),ja=()=>rr[window.location.pathname]||"dashboard",so=()=>{const[t,s]=r.useState(!1),[a,l]=r.useState(!1),[n,c]=r.useState(ja),[u,h]=r.useState(!0),[m,N]=r.useState(!1),[x,p]=r.useState(""),[_,S]=r.useState(""),[q,w]=r.useState(!1),[P,A]=r.useState(""),[G,H]=r.useState(""),[X,f]=r.useState(""),[y,z]=r.useState(!1),[O,F]=r.useState(""),[d,B]=r.useState(),[Z,M]=r.useState(eo),b=V=>{const v=V==="settings"&&!a?"dashboard":V,ee=ya[v];ee&&ee!==window.location.pathname&&window.history.pushState({},"",ee),c(v)};r.useEffect(()=>{const V=()=>c(ja());return window.addEventListener("popstate",V),()=>window.removeEventListener("popstate",V)},[]),r.useEffect(()=>{qa().then(v=>{if((v==null?void 0:v.initialized)===!1){N(!0),s(!1),l(!1);return}N(!1),v!=null&&v.authenticated?(s(!0),l(v.is_admin===!0)):l(!1)}).catch(()=>{s(!1),l(!1)}).finally(()=>h(!1));const V=()=>{s(!1),l(!1)};return window.addEventListener("auth:logout",V),()=>window.removeEventListener("auth:logout",V)},[]),r.useEffect(()=>{!u&&t&&!a&&n==="settings"&&(window.history.replaceState({},"",ya.dashboard),c("dashboard"))},[u,t,a,n]);const k=async V=>{V.preventDefault(),w(!0),A("");try{const v=await sl({username:x,password:_});v.success?(s(!0),l(v.is_admin===!0)):A(v.message||"登录失败")}catch(v){const ee=v instanceof Error?v.message:String(v);A(ee||"登录失败")}finally{w(!1)}},D=async V=>{if(V.preventDefault(),F(""),G.length<8){F("密码至少需要 8 个字符");return}if(G!==X){F("两次输入的密码不一致");return}z(!0);try{const v=await al(G);if(!v.success){F(v.message||"初始化失败,请重试");return}N(!1),s(!0),l(v.is_admin===!0),H(""),f("")}catch(v){const ee=v instanceof Error?v.message:String(v);F(ee||"初始化失败,请重试")}finally{z(!1)}},C=async()=>{try{await rl()}catch(V){console.error("退出登录失败",V)}finally{s(!1),l(!1)}};if(u)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-surface",children:e.jsx(_e,{className:"w-8 h-8 text-brand animate-spin"})});if(m)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-canvas 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-panel 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:"mx-auto mb-6 flex justify-center",children:e.jsx(ws,{sizeClass:"w-24 h-24"})}),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:"设置完成后会自动进入系统,管理员账号为 admin。"})]}),e.jsxs("form",{onSubmit:D,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx(Js,{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:"设置管理员密码(至少 8 个字符)",value:G,onChange:V=>H(V.target.value),autoFocus:!0,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(qt,{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:X,onChange:V=>f(V.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]})]}),O&&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(qt,{className:"w-4 h-4"})," ",O]}),e.jsx("button",{type:"submit",disabled:y,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:y?e.jsx(_e,{className:"w-5 h-5 animate-spin"}):e.jsxs(e.Fragment,{children:["设置密码并进入系统 ",e.jsx(vs,{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(!t)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-canvas 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-panel 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:"group mx-auto mb-6 flex cursor-pointer justify-center",children:e.jsx(ws,{sizeClass:"w-24 h-24",logoClassName:"w-full h-full text-white 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:k,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx(yt,{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:x,onChange:V=>p(V.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(Js,{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:_,onChange:V=>S(V.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]})]}),P&&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(qt,{className:"w-4 h-4"})," ",P]}),e.jsx("button",{type:"submit",disabled:q,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:q?e.jsx(_e,{className:"w-5 h-5 animate-spin"}):e.jsxs(e.Fragment,{children:["立即登录 ",e.jsx(vs,{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 W=()=>{switch(n){case"dashboard":return e.jsx(ds,{});case"accounts":return e.jsx(qn,{});case"chat":return e.jsx(Xi,{});case"orders":return e.jsx(Yn,{});case"cards":return e.jsx(li,{});case"items":return e.jsx(fi,{onConfigureDelivery:V=>{B({cookieId:V.cookie_id,itemId:V.item_id,requestId:Date.now()}),b("rules")}});case"rules":return e.jsx(Ti,{initialDeliveryTarget:d,onDeliveryTargetHandled:()=>B(void 0)});case"notifications":return e.jsx(Wi,{isAdmin:a});case"settings":return a?e.jsx(ki,{}):e.jsx(ds,{});default:return e.jsx(ds,{})}};return e.jsxs("div",{className:"flex min-h-screen bg-canvas text-ink",children:[e.jsx(Fr,{activeTab:n,isAdmin:a,collapsed:Z,onToggleCollapsed:()=>M(V=>{const v=!V;return to(v),v}),onNavigate:b,onLogout:C}),e.jsxs("main",{className:`h-screen min-w-0 flex-1 overflow-x-hidden overflow-y-auto scroll-smooth transition-[margin] duration-300 ${Z?"ml-16":"ml-64"} ${n==="chat"?"p-4 md:p-6":"p-8 md:p-12"}`,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:`${n==="chat"?"mx-auto max-w-[1680px]":"mx-auto max-w-[1400px] pb-10"}`,children:W()})]})]})},lr=document.getElementById("root");if(!lr)throw new Error("Could not find root element to mount to");const ao=ir.createRoot(lr);ao.render(e.jsx(Is.StrictMode,{children:e.jsx(so,{})})); +`).filter(d=>d.trim()).length})," 条"]})]}),x.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:x.api_method,onChange:d=>p({...x,api_method:d.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:x.api_timeout,onChange:d=>p({...x,api_timeout:parseInt(d.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:x.api_headers,onChange:d=>p({...x,api_headers:d.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:x.api_params,onChange:d=>p({...x,api_params:d.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:x.description,onChange:d=>p({...x,description:d.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:x.delay_seconds,onChange:d=>p({...x,delay_seconds:parseInt(d.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:()=>c(!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:f,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(nt,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),e.jsx(ei,{dataCards:P,downloadCardTemplate:F,...A})]})},ma="ydisks-amap-js-api",ii="c9b68d4ce9a2a97f22a4a439404488ca";let Ot=null;const oi=()=>ii,ci=()=>window.AMap?Promise.resolve(window.AMap):Ot||(Ot=new Promise((t,s)=>{const a=document.getElementById(ma),l=a||document.createElement("script"),n=()=>{window.__ydisksAmapLoaded=void 0,window.clearTimeout(u)},c=()=>{window.AMap?(n(),t(window.AMap)):(n(),s(new Error("高德地图 API 加载完成但未找到 AMap 对象")))},u=window.setTimeout(()=>{n(),s(new Error("高德地图 API 加载超时,请检查网络或 VITE_AMAP_JS_KEY 配置"))},15e3);window.__ydisksAmapLoaded=c,l.id=ma,l.async=!0,l.src=`https://webapi.amap.com/maps?v=2.0&key=${encodeURIComponent(oi())}&plugin=AMap.PlaceSearch&callback=__ydisksAmapLoaded`,l.onerror=()=>{n(),s(new Error("高德地图 API 加载失败,请检查网络或 VITE_AMAP_JS_KEY 配置"))},a||document.head.appendChild(l)}).catch(t=>{throw Ot=null,t}),Ot),ts=t=>Number.isFinite(t)&&t!==0,di=t=>{var n,c;const s=Number((n=t.location)==null?void 0:n.lng),a=Number((c=t.location)==null?void 0:c.lat),l={area:String(t.adname||"").trim(),city:String(t.cityname||"").trim(),division_id:String(t.adcode||"").trim(),longitude:s,latitude:a,poi_id:String(t.id||"").trim(),poi_name:String(t.name||"").trim(),province:String(t.pname||"").trim()};return!l.division_id||!l.province||!l.city||!l.poi_id||!l.poi_name||!ts(s)||!ts(a)||s<-180||s>180||a<-90||a>90?null:l},xi=async(t,s)=>{if(!ts(t)||!ts(s)||t<-180||t>180||s<-90||s>90)throw new Error("经纬度无效");const a=await ci();return new Promise((l,n)=>{new a.PlaceSearch({extensions:"all",pageSize:10}).searchNearBy("",[t,s],1e3,(u,h)=>{var N;if(u!=="complete"){if(u==="no_data"){l([]);return}n(new Error("高德地图附近地址查询失败,请稍后重试"));return}const m=(((N=h==null?void 0:h.poiList)==null?void 0:N.pois)||[]).map(di).filter(x=>x!==null);l(m)})})},mi=t=>t.find(s=>s.status==="running"||s.status==="canceling"),Rs=t=>t==="running"||t==="canceling",ui=t=>!!(t!=null&&t.preview_id&&Number(t.valid||0)>0),pi=t=>!!(t!=null&&t.id&&Number(t.retryable||0)>0&&!Rs(t.status)),hi=(t,s)=>t===s,ua=t=>{switch(t){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"canceling":return"正在安全取消";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"partially_failed":return"部分失败";case"canceled":return"已取消";default:return t||"-"}},pa=t=>{switch(t){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"}},gi=t=>{const[s,a]=r.useState(!1),[l,n]=r.useState("upload"),[c,u]=r.useState(null),[h,m]=r.useState(null),[N,x]=r.useState(""),[p,_]=r.useState(!1),[S,q]=r.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[w,P]=r.useState(null),[A,G]=r.useState(null),[H,X]=r.useState(null),[f,y]=r.useState([]),[z,O]=r.useState(null),[F,d]=r.useState(!1),B=r.useRef(!1),Z=r.useRef(0),M=r.useCallback(async()=>{n("upload"),P(null),G(null),u(null),m(null),x(""),q({catId:"",catName:"",channelCatId:"",tbCatId:""}),y([]),O(null),a(!0),d(!0);try{const U=await za(20),ae=mi(U);if(ae!=null&&ae.id){const ge=await Nt(ae.id);X(ge),G(ge),n(["running","canceling"].includes(ge.status)?"running":"done")}}catch(U){console.error("恢复最近批量铺货任务失败:",U)}finally{d(!1)}},[]),b=r.useCallback(async()=>{const U=N.trim();if(!t.selectedAccount){alert("请先选择默认发布账号");return}if(!U){alert("请输入类目关键词");return}_(!0);try{const ge=(await Tl(t.selectedAccount,U)).category;q({catId:ge.cat_id,catName:ge.cat_name,channelCatId:ge.channel_cat_id,tbCatId:ge.tb_cat_id||""})}catch(ae){console.error("获取推荐类目失败:",ae),alert((ae==null?void 0:ae.message)||"没有匹配到类目,请换一个更具体的关键词")}finally{_(!1)}},[N,t.selectedAccount]),k=r.useCallback(async()=>{if(H!=null&&H.id){d(!0),a(!0);try{const U=await Nt(H.id);G(U),n(["running","canceling"].includes(U.status)?"running":"done")}catch(U){console.error("加载最近批量铺货结果失败:",U)}finally{d(!1)}}},[H==null?void 0:H.id]),D=r.useCallback(async()=>{if(!c){alert("请先上传商品表格");return}if(!t.selectedAccount){alert("请先选择默认发布账号");return}d(!0);try{const U=await El({file:c,imagesZip:h,defaultCookieId:t.selectedAccount,fallbackCategory:S,location:z||void 0});P(U),G(null),n("preview")}catch(U){console.error("批量铺货预检失败:",U),alert((U==null?void 0:U.message)||"预检失败,请检查表格和图片 zip")}finally{d(!1)}},[S,c,h,z,t.selectedAccount]),C=r.useCallback(async()=>{if(w!=null&&w.preview_id){if(!ui(w)){alert("没有可发布的商品行");return}d(!0);try{const U=await Dl(w.preview_id),ae=await Nt(U.batch_id||w.preview_id);G(ae),X(ae),n(ae.status==="running"?"running":"done")}catch(U){console.error("启动批量铺货失败:",U),alert((U==null?void 0:U.message)||"启动发布任务失败")}finally{d(!1)}}},[w]),W=r.useCallback(async()=>{if(A!=null&&A.id&&confirm("确认取消当前批量铺货任务吗?正在发布的单个商品可能会继续完成。")){d(!0);try{const U=await Ml(A.id),ae=await Nt(A.id);G(ae),n((U==null?void 0:U.status)==="canceling"||ae.status==="canceling"?"running":"done")}catch(U){alert((U==null?void 0:U.message)||"取消失败")}finally{d(!1)}}},[A==null?void 0:A.id]),V=r.useCallback(async()=>{const U=w==null?void 0:w.preview_id;if(U&&l==="preview")try{await $l(U)}catch(ae){console.error("清理批量铺货预检失败:",ae)}P(null),n("upload")},[l,w==null?void 0:w.preview_id]),v=r.useCallback(async()=>{await V(),a(!1)},[V]),ee=r.useCallback(async()=>{if(!(!(A!=null&&A.id)||!pi(A))){d(!0);try{await ql(A.id),G(await Nt(A.id)),n("running")}catch(U){alert((U==null?void 0:U.message)||"重试失败")}finally{d(!1)}}},[A==null?void 0:A.id]);return r.useEffect(()=>{if(!s||!(A!=null&&A.id)||!Rs(A.status))return;const U=++Z.current,ae=async()=>{if(!B.current){B.current=!0;try{const $=await Nt(A.id);if(!hi(U,Z.current))return;G($),X($),Rs($.status)||(n("done"),await Promise.all([t.loadItems(),t.loadShippingRules()]))}catch($){console.error("刷新批量铺货进度失败:",$)}finally{B.current=!1}}},ge=window.setInterval(()=>void ae(),3e3);return(()=>{window.clearInterval(ge),Z.current+=1})},[A==null?void 0:A.id,A==null?void 0:A.status,t.loadItems,t.loadShippingRules,s]),{showBatchModal:s,setShowBatchModal:a,batchLoading:F,batchPhase:l,setBatchPhase:n,batchFile:c,setBatchFile:u,batchImagesZip:h,setBatchImagesZip:m,batchCategoryKeyword:N,setBatchCategoryKeyword:x,batchCategoryLoading:p,batchFallbackCategory:S,setBatchFallbackCategory:q,batchPreview:w,setBatchPreview:P,batchDetail:A,setBatchDetail:G,recentBatch:H,setRecentBatch:X,batchLocations:f,batchLocation:z,setBatchLocations:y,setBatchLocation:O,openBatchModal:M,handleRecommendBatchCategory:b,openRecentBatchResult:k,handlePreviewBatch:D,handleStartBatch:C,handleCancelBatch:W,abandonBatchPreview:V,closeBatchModal:v,handleRetryBatchFailed:ee}},bi=({phase:t})=>{const s=[["upload","1 上传"],["preview","2 预检"],["running","3 发布"],["done","4 结果"]];return e.jsx("div",{className:"grid grid-cols-4 gap-2",children:s.map(([a,l])=>e.jsx("div",{className:`rounded-xl px-3 py-2 text-center text-xs font-extrabold border ${t===a?"bg-blue-600 text-white border-blue-600":"bg-gray-50 text-gray-500 border-gray-100"}`,children:l},a))})},fi=t=>{const s=String(t||"").trim();return s?/^[¥¥]/.test(s)?s:`¥${s}`:"-"},yi=({onConfigureDelivery:t})=>{const[s,a]=r.useState([]),[l,n]=r.useState([]),[c,u]=r.useState([]),[h,m]=r.useState(""),[N,x]=r.useState(""),[p,_]=r.useState(!1),[S,q]=r.useState(!1),[w,P]=r.useState(!1),[A,G]=r.useState(!1),[H,X]=r.useState(!1),[f,y]=r.useState(!1),[z,O]=r.useState([]),[F,d]=r.useState(null),[B,Z]=r.useState(null),[M,b]=r.useState({}),[k,D]=r.useState({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),[C,W]=r.useState({cookie_id:"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),[V,v]=r.useState([]),ee=r.useCallback(async()=>{const o=await Lt();a(o)},[]),be=r.useCallback(async()=>{n(await Ss())},[]),U=gi({selectedAccount:h,loadItems:ee,loadShippingRules:be}),{showBatchModal:ae,setShowBatchModal:ge,batchLoading:$,batchPhase:L,batchFile:Q,setBatchFile:Y,batchImagesZip:re,setBatchImagesZip:ue,batchCategoryKeyword:Ne,setBatchCategoryKeyword:R,batchCategoryLoading:T,batchFallbackCategory:g,setBatchFallbackCategory:le,batchPreview:oe,batchDetail:ne,recentBatch:de,setRecentBatch:Se,batchLocations:Ee,batchLocation:Te,setBatchLocations:Ue,setBatchLocation:Me,openBatchModal:Be,handleRecommendBatchCategory:Je,openRecentBatchResult:He,handlePreviewBatch:we,handleStartBatch:pe,handleCancelBatch:Ve,abandonBatchPreview:it,closeBatchModal:tt,handleRetryBatchFailed:Qe}=U;r.useEffect(()=>{if(!H||C.images.length===0){v([]);return}const o=C.images.map((K,xe)=>({key:K.name+xe,url:URL.createObjectURL(K)}));return v(o),()=>{o.forEach(K=>URL.revokeObjectURL(K.url))}},[H,C.images]),r.useEffect(()=>{Promise.all([Ft(),Lt(),Ss(),za(20)]).then(([o,K,xe,Le])=>{u(o),a(K),n(xe);const st=Le.find(Ke=>["running","canceling"].includes(Ke.status))||Le.find(Ke=>Ke.status!=="preview");Se(st||null)}).catch(o=>console.error("加载商品配置失败:",o))},[]);const Ge=async()=>{if(!h)return alert("请先选择账号");_(!0);try{const o=await Al(h);await ee(),alert((o==null?void 0:o.message)||"商品同步完成")}catch(o){console.error("同步商品失败:",o),alert((o==null?void 0:o.message)||"同步失败,请重试")}finally{_(!1)}},ot=o=>{Z(o),b({...o}),P(!0)},pt=async()=>{if(B)try{await Bl(B.cookie_id,B.item_id,{item_title:M.item_title||"",item_description:M.item_description||"",item_category:M.item_category||"",item_price:M.item_price||"",item_detail:M.item_detail||B.item_detail||""}),await ee(),await be(),P(!1),Z(null)}catch(o){console.error("更新商品失败:",o),alert("更新失败,请重试")}},ht=async o=>{if(confirm(`确认删除商品"${o.item_title}"吗?`))try{await Il(o.cookie_id,o.item_id),a(K=>K.filter(xe=>!(xe.cookie_id===o.cookie_id&&xe.item_id===o.item_id)))}catch(K){console.error("删除商品失败:",K),alert("删除失败,请重试")}},J=async()=>{try{if(!k.cookie_id||!k.item_id){alert("请选择账号并填写商品ID");return}await Ol(k.cookie_id,{item_id:k.item_id,item_title:k.item_title,item_price:k.item_price,item_detail:k.item_image?JSON.stringify({item_image:k.item_image}):""}),await ee(),G(!1),D({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""})}catch(o){console.error("添加商品失败:",o),alert("添加失败,请重试")}},ie=async()=>{if(!C.cookie_id)return alert("请选择发布账号");if(!C.title.trim())return alert("请填写商品标题");if(!C.price.trim())return alert("请填写商品价格");if(!C.quantity||Number(C.quantity)<=0)return alert("库存数量必须大于 0");if(C.images.length===0)return alert("至少上传 1 张商品图片");if(C.postage_mode==="fixed"&&!C.postage.trim())return alert("请填写一口价邮费");q(!0);try{const o=await Pl({...C,location:F||void 0});if(await ee(),X(!1),W({cookie_id:h||"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),O([]),d(null),o!=null&&o.item_id){const K={id:o.item_id,cookie_id:C.cookie_id,item_id:o.item_id,item_title:o.item_title||C.title,item_price:o.item_price||C.price,item_image:o.item_image};t(K),alert("商品发布成功,ID: "+o.item_id+",已为你打开发货规则配置")}else alert("商品发布成功")}catch(o){console.error("发布商品失败:",o);const K=o==null?void 0:o.payload;if((K==null?void 0:K.code)==="stock_permission_missing"){alert("发布失败:该账号没有库存发布权限,无法按库存数量发布商品。请换账号或先在闲鱼确认库存能力。");return}alert((o==null?void 0:o.message)||"发布失败,请重试")}finally{q(!1)}},j=()=>{const xe=[["账号ID","标题","描述","价格","原价","库存","邮费模式","邮费","图片","类目ID","类目名称","频道类目ID","淘宝类目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(zt=>zt.map(Ut=>`"${String(Ut).replace(/"/g,'""')}"`).join(",")).join(` +`),Le=new Blob(["\uFEFF"+xe],{type:"text/csv;charset=utf-8"}),st=URL.createObjectURL(Le),Ke=document.createElement("a");Ke.href=st,Ke.download="批量铺货模板.csv",document.body.appendChild(Ke),Ke.click(),Ke.remove(),URL.revokeObjectURL(st)},E=()=>{D(o=>({...o,cookie_id:h||o.cookie_id})),G(!0)},se=()=>{W(o=>({...o,cookie_id:h||o.cookie_id})),X(!0)},ce=async o=>{if(!(o?h:C.cookie_id))return alert("请先选择发布账号");if(!navigator.geolocation)return alert("当前浏览器不支持定位");y(!0),navigator.geolocation.getCurrentPosition(async xe=>{try{const Le=await xi(xe.coords.longitude,xe.coords.latitude);if(!Le.length)throw new Error("当前位置附近没有可用的高德发货地,请稍后重试");o?(Ue(Le),Me(Le[0])):(O(Le),d(Le[0]))}catch(Le){alert((Le==null?void 0:Le.message)||"获取发货地失败")}finally{y(!1)}},xe=>{y(!1),alert(xe.code===xe.PERMISSION_DENIED?"定位权限被拒绝,请在浏览器设置中允许定位":"无法获取当前位置,请稍后重试")},{enableHighAccuracy:!0,timeout:15e3,maximumAge:6e4})},fe=o=>l.filter(K=>K.cookie_id===o.cookie_id&&K.item_id===o.item_id).length>0?l.filter(K=>K.cookie_id===o.cookie_id&&K.item_id===o.item_id):l.filter(K=>K.cookie_id===o.cookie_id&&!K.item_id),De=r.useMemo(()=>new Map(c.map(o=>[o.id,o])),[c]),ve=r.useMemo(()=>N?s.filter(o=>o.cookie_id===N):s,[N,s]),Pe=o=>{const K=De.get(o),xe=(K==null?void 0:K.remark)||(K==null?void 0:K.nickname);return xe?`${xe} · ${o.slice(0,6)}`:`账号 ${o.slice(0,8)}`},me=o=>{const K=De.get(o);return(K==null?void 0:K.remark)||(K==null?void 0:K.nickname)||"未命名账号"};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-center gap-4",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 flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-account-filter",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"商品列表筛选"}),e.jsxs("div",{className:"relative",children:[e.jsx(Nr,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-account-filter","aria-label":"按账号筛选商品列表",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:N,onChange:o=>x(o.target.value),children:[e.jsx("option",{value:"",children:"全部账号"}),c.map(o=>e.jsx("option",{value:o.id,children:Pe(o.id)},o.id))]})]})]}),e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-sync-account",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"同步商品账号"}),e.jsxs("div",{className:"relative",children:[e.jsx(yt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-sync-account","aria-label":"选择要同步商品的账号",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:h,onChange:o=>m(o.target.value),children:[e.jsx("option",{value:"",children:"请选择账号"}),c.map(o=>e.jsx("option",{value:o.id,children:Pe(o.id)},o.id))]})]})]}),e.jsxs("button",{onClick:Ge,disabled:p||!h,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(We,{className:`w-4 h-4 ${p?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:E,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(nt,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:se,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-500 text-white hover:bg-emerald-600 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(ls,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:()=>void Be(),className:"px-5 py-3 rounded-2xl font-bold bg-brand text-white hover:bg-brand-highlight transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx(Wt,{className:"w-4 h-4"}),de&&["running","canceling"].includes(de.status)?"继续批量任务":"批量铺货"]}),de&&!["running","canceling"].includes(de.status)&&e.jsx("button",{onClick:()=>void He(),className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"最近批次结果"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:[ve.map(o=>{const K=fe(o),xe=K.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:()=>ot(o),className:"p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md text-gray-600 hover:bg-brand hover:text-white transition-colors",title:"编辑",children:e.jsx(kt,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>ht(o),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(Ze,{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:[o.item_image?e.jsx("img",{src:o.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(va,{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:fi(o.item_price)})]}),e.jsx("h3",{className:"font-bold text-gray-900 line-clamp-2 text-xs mb-1.5 h-8 leading-4",children:o.item_title}),e.jsxs("div",{className:"mb-2 inline-flex min-w-0 max-w-full items-center gap-1 self-start rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700",title:me(o.cookie_id),children:[e.jsx(yt,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:me(o.cookie_id)})]}),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: ",o.item_id]}),e.jsxs("span",{className:`inline-flex items-center gap-1 font-bold ${xe?"text-emerald-600":"text-amber-600"}`,children:[xe?e.jsx(Ns,{className:"w-3 h-3"}):e.jsx(vr,{className:"w-3 h-3"}),xe?`${K.length} 规则`:"未配置"]})]}),e.jsx("div",{className:"space-y-2 mt-auto",children:e.jsxs("button",{onClick:()=>t(o),className:`w-full flex items-center justify-between gap-1 px-2.5 py-2 rounded-lg text-[11px] font-extrabold transition-all ${xe?"bg-gray-900 text-white hover:bg-black":"bg-brand text-white hover:bg-brand-highlight shadow-md shadow-blue-100"}`,children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(_r,{className:"w-3.5 h-3.5"}),xe?"查看发货规则":"关联发货规则"]}),e.jsx(vs,{className:"w-3.5 h-3.5"})]})})]},`${o.cookie_id}-${o.item_id}`)}),ve.length===0&&e.jsxs("div",{className:"col-span-full py-20 text-center text-gray-400",children:[e.jsx(_a,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),N?"该账号暂无商品数据":"暂无商品数据,请选择账号进行同步"]})]}),w&&B&&Oe.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: ",B.item_id]})]}),e.jsx("button",{onClick:()=>P(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(ke,{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:M.item_title||"",onChange:o=>b({...M,item_title:o.target.value})}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"价格",value:M.item_price||"",onChange:o=>b({...M,item_price:o.target.value})}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"分类",value:M.item_category||"",onChange:o=>b({...M,item_category:o.target.value})}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述",value:M.item_description||"",onChange:o=>b({...M,item_description:o.target.value})})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:pt,className:"w-full ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(lt,{className:"w-4 h-4"}),"保存"]})})]})}),document.body),A&&Oe.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:()=>G(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(ke,{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:k.cookie_id,onChange:o=>D({...k,cookie_id:o.target.value}),children:[e.jsx("option",{value:"",children:"选择账号"}),c.map(o=>e.jsx("option",{value:o.id,children:Pe(o.id)},o.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:k.item_id,onChange:o=>D({...k,item_id:o.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:k.item_price,onChange:o=>D({...k,item_price:o.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:k.item_title,onChange:o=>D({...k,item_title:o.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:k.item_image,onChange:o=>D({...k,item_image:o.target.value})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:J,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(nt,{className:"w-4 h-4"}),"添加商品"]})})]})}),document.body),H&&Oe.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:()=>X(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(ke,{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:C.cookie_id,onChange:o=>{W({...C,cookie_id:o.target.value}),O([]),d(null)},children:[e.jsx("option",{value:"",children:"选择账号"}),c.map(o=>e.jsx("option",{value:o.id,children:Pe(o.id)},o.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:C.title,onChange:o=>W({...C,title:o.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:C.quantity,onChange:o=>W({...C,quantity:o.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:C.description,onChange:o=>W({...C,description:o.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:C.price,onChange:o=>W({...C,price:o.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:C.original_price,onChange:o=>W({...C,original_price:o.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:C.postage_mode,onChange:o=>W({...C,postage_mode:o.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:"无需邮寄"})]})]})]}),C.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:C.postage,onChange:o=>W({...C,postage:o.target.value})})]}),e.jsxs("div",{className:"rounded-2xl border border-sky-200 bg-sky-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"发货地(可选)"}),e.jsx("p",{className:"mt-1 text-xs text-sky-800",children:"虚拟商品无需发货地;发布失败时可再定位并作为补充信息提交。"})]}),e.jsxs("button",{type:"button",disabled:f||!C.cookie_id,onClick:()=>void ce(!1),className:"ios-btn-primary flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-bold disabled:opacity-50",children:[e.jsx(Us,{className:"h-4 w-4"}),f?"定位中...":"获取当前位置"]})]}),z.length>0&&e.jsx("select",{className:"w-full ios-input rounded-xl bg-white px-4 py-3",value:String(Math.max(0,z.indexOf(F))),onChange:o=>d(z[Number(o.target.value)]||null),children:z.map((o,K)=>e.jsx("option",{value:String(K),children:[o.province,o.city,o.area,o.poi_name].filter(Boolean).join(" ")},`${o.division_id}-${o.poi_id}-${K}`))})]}),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(Wt,{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:C.images.length?"已选择 "+C.images.length+" 张":"支持 JPG / PNG / GIF"}),e.jsx("input",{className:"hidden",type:"file",accept:"image/*",multiple:!0,onChange:o=>W({...C,images:Array.from(o.target.files||[]).slice(0,9)})})]}),V.length>0&&e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-3",children:V.map(o=>e.jsx("div",{className:"aspect-square rounded-xl bg-gray-100 overflow-hidden border border-gray-100",children:e.jsx("img",{src:o.url,alt:"",className:"w-full h-full object-cover"})},o.key))})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{disabled:S,onClick:ie,className:"w-full bg-emerald-500 hover:bg-emerald-600 disabled:opacity-60 text-white px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ls,{className:"w-4 h-4"}),S?"正在发布...":"发布到闲鱼"]})})]})}),document.body),ae&&Oe.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:()=>void tt(),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(ke,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx(bi,{phase:L}),L==="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:j,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:h,onChange:o=>{m(o.target.value),Ue([]),Me(null)},children:[e.jsx("option",{value:"",children:"选择账号"}),c.map(o=>e.jsx("option",{value:o.id,children:Pe(o.id)},o.id))]}),e.jsx("p",{className:"text-xs text-gray-500",children:"表格中“账号ID”为空时,会使用这里选择的账号。"})]}),e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50/70 p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-extrabold text-gray-900",children:["默认类目 ",e.jsx("span",{className:"font-medium text-gray-500",children:"(可为空)"})]}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-amber-800",children:"填写后优先使用该类目;留空时由闲鱼根据每件商品自动识别。仍无法识别时,系统最终使用“电子资料”兜底。"})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsxs("label",{className:"relative flex-1",children:[e.jsx("span",{className:"sr-only",children:"类目关键词"}),e.jsx(St,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{className:"w-full ios-input rounded-xl bg-white py-2.5 pl-10 pr-3",placeholder:"输入关键词,例如:课程资料、设计素材",value:Ne,onChange:o=>R(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),Je())}})]}),e.jsxs("button",{type:"button",disabled:!h||!Ne.trim()||T,onClick:()=>void Je(),className:"ios-btn-primary flex min-h-[42px] items-center justify-center gap-2 rounded-xl px-4 text-sm font-bold disabled:opacity-50",children:[e.jsx(St,{className:"h-4 w-4"}),T?"匹配中...":"获取类目"]})]}),g.catId?e.jsxs("div",{className:"flex min-h-[46px] items-center justify-between gap-3 border-t border-amber-200 pt-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-bold text-gray-900",children:[e.jsx(Ns,{className:"h-4 w-4 shrink-0 text-emerald-600"}),e.jsx("span",{className:"truncate",children:g.catName})]}),e.jsxs("div",{className:"mt-1 font-mono text-xs text-gray-500",children:["类目 ",g.catId," · 频道 ",g.channelCatId]})]}),e.jsx("button",{type:"button",title:"清除默认类目",onClick:()=>le({catId:"",catName:"",channelCatId:"",tbCatId:""}),className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-gray-500 hover:bg-white hover:text-gray-900",children:e.jsx(ke,{className:"h-4 w-4"})})]}):null]}),e.jsxs("div",{className:"rounded-xl border border-sky-200 bg-sky-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"批次发货地(可选)"}),e.jsx("p",{className:"mt-1 text-xs text-sky-800",children:"虚拟商品可留空;填写后整个批次使用同一个发货地,并随任务保存用于恢复和重试。"})]}),e.jsxs("button",{type:"button",disabled:f||!h,onClick:()=>void ce(!0),className:"ios-btn-primary flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-bold disabled:opacity-50",children:[e.jsx(Us,{className:"h-4 w-4"}),f?"定位中...":"获取当前位置"]})]}),Ee.length>0&&e.jsx("select",{className:"w-full ios-input rounded-xl bg-white px-4 py-3",value:String(Math.max(0,Ee.indexOf(Te))),onChange:o=>Me(Ee[Number(o.target.value)]||null),children:Ee.map((o,K)=>e.jsx("option",{value:String(K),children:[o.province,o.city,o.area,o.poi_name].filter(Boolean).join(" ")},`${o.division_id}-${o.poi_id}-${K}`))})]}),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(Wt,{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:Q?Q.name:"支持 .xlsx / .csv / .tsv"}),e.jsx("input",{className:"hidden",type:"file",accept:".xlsx,.csv,.tsv",onChange:o=>{var K;return Y(((K=o.target.files)==null?void 0:K[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(Wt,{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:re?re.name:"表格图片字段使用 zip 内相对路径"}),e.jsx("input",{className:"hidden",type:"file",accept:".zip",onChange:o=>{var K;return ue(((K=o.target.files)==null?void 0:K[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","需要覆盖默认账号时填写","上方默认发布账号为必选;本列留空时使用默认账号,填写后仅覆盖当前行"],["标题","每个商品都要填","填写买家能看到的商品标题"],["描述","可以留空","留空时会使用商品标题作为描述"],["价格","每个商品都要填","只填数字,例如 19.90"],["原价","可以留空","需要展示划线原价时填写,例如 29.90"],["库存","可以留空","留空按 1 件处理;填写时必须大于 0"],["邮费模式","可以留空","留空表示包邮;包邮填 free,固定邮费填 fixed"],["邮费","邮费模式填 fixed 时填写","只填数字,例如 8.00"],["图片","每个商品都要填","填写 zip 内图片路径或图片网址;多张图片用英文分号隔开"],["类目ID","需要指定当前行默认类目时填写","必须和“类目名称、频道类目ID”同时填写;优先于自动识别"],["类目名称","填写了“类目ID”时必填","填写该 ID 对应的准确类目名称"],["频道类目ID","覆盖类目时必填","必须填写闲鱼返回的准确频道类目 ID"],["淘宝类目ID","按闲鱼返回填写","“电子资料”无淘宝类目 ID,保持为空"],["付款发货启用","需要付款后自动发货时填写","填“是”表示开启;不需要时填“否”或留空"],["付款发货内容","“付款发货启用”填“是”时填写","从“卡密库存”页面取得卡密组 ID,按上方示例填写"],["评价赠品启用","需要评价赠品时填写","填“是”表示开启;不需要时填“否”或留空"],["评价赠品内容","“评价赠品启用”填“是”时填写","格式和付款发货内容相同,也可以同时发送多个卡密组"],["求评价启用","需要自动求评价时填写","填“是”表示开启;不需要时填“否”或留空"],["求评价等待小时","“求评价启用”填“是”时填写","填写等待小时数;留空按 72 小时处理"],["求评价文案","“求评价启用”填“是”时填写","填写要发送给买家的求评价消息"],["求评价最多次数","可以留空","留空只提醒 1 次"]].map(([o,K,xe])=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-bold text-gray-900 whitespace-nowrap",children:o}),e.jsx("td",{className:`px-3 py-2 min-w-[210px] font-bold ${K==="每个商品都要填"?"text-red-600":K==="可以留空"?"text-gray-500":"text-amber-700"}`,children:K}),e.jsx("td",{className:"px-3 py-2 min-w-[260px]",children:xe})]},o))})]})})]})]}),L==="preview"&&oe&&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:oe.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:oe.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:oe.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("th",{className:"px-4 py-3",children:"问题"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:oe.rows.map(o=>{var K,xe,Le,st;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:o.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 ${o.valid?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-red-50 text-red-700 border-red-100"}`,children:o.valid?"可发布":"需修正"})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[240px] truncate",children:o.title||"-"}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:["¥",o.price||"-"," / ",o.quantity||1]}),e.jsxs("td",{className:"px-4 py-3 text-xs text-gray-600 min-w-[150px]",children:[e.jsx("div",{className:"font-bold text-gray-800",children:((K=o.category)==null?void 0:K.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((xe=o.category)==null?void 0:xe.cat_id)||"失败后使用电子资料"})]}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:[((Le=o.images)==null?void 0:Le.length)||0," 张"]}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[280px]",children:((st=o.errors)==null?void 0:st.join(";"))||"-"})]},o.row_no)})})]})})]}),(L==="running"||L==="done")&&ne&&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 ${pa(ne.status)}`,children:[e.jsx("div",{className:"text-xs font-bold opacity-70",children:"任务状态"}),e.jsx("div",{className:"text-xl font-extrabold mt-1",children:ua(ne.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:ne.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:ne.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:ne.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:ne.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:"类目策略"}),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:ne.rows.map(o=>{var K,xe;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:o.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 ${pa(o.status)}`,children:ua(o.status)})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[260px] truncate",children:o.title}),e.jsxs("td",{className:"px-4 py-3 text-xs text-gray-600 min-w-[150px]",children:[e.jsx("div",{className:"font-bold text-gray-800",children:((K=o.category)==null?void 0:K.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((xe=o.category)==null?void 0:xe.cat_id)||"失败后使用电子资料"})]}),e.jsx("td",{className:"px-4 py-3 text-xs font-mono",children:o.item_url?e.jsx("a",{href:o.item_url,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline",children:o.item_id}):o.item_id||"-"}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[340px]",children:o.error_message||"-"})]},o.id)})})]})})]})]}),e.jsxs("div",{className:"modal-footer",children:[L==="upload"&&e.jsxs("button",{disabled:$||!Q||!h,onClick:we,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(We,{className:`w-4 h-4 ${$?"animate-spin":""}`}),$?"正在预检...":"开始预检"]}),L==="preview"&&oe&&e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{disabled:$,onClick:()=>void it(),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:$||oe.valid<=0,onClick:pe,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(ls,{className:"w-4 h-4"}),$?"启动中...":`确认发布 ${oe.valid} 个商品`]})]}),(L==="running"||L==="done")&&ne&&e.jsxs("div",{className:"flex gap-3 w-full",children:[ne.status==="running"?e.jsx("button",{disabled:$,onClick:Ve,className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"取消任务"}):ne.status==="canceling"?e.jsx("button",{disabled:!0,className:"flex-1 px-6 py-3.5 rounded-xl bg-amber-100 text-amber-800 font-bold",children:"正在保存远端结果并安全取消…"}):e.jsx("button",{onClick:()=>window.open(`/api/v1/items/publish-batches/${ne.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:"下载结果"}),ne.retryable>0&&!["running","canceling"].includes(ne.status)&&e.jsxs("button",{disabled:$,onClick:Qe,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(We,{className:`w-4 h-4 ${$?"animate-spin":""}`}),"重试失败项"]}),!["running","canceling"].includes(ne.status)&&e.jsx("button",{onClick:()=>{ge(!1),ee(),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)]})},Ha="https://dashscope.aliyuncs.com/compatible-mode/v1",ji=[{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warn"},{value:"error",label:"Error"}],Ni=new Set(["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from","smtp_from_name","smtp_from_address","registration_enabled","show_default_login_info","login_captcha_enabled","item_sync_enabled","item_sync_interval","item_sync_max_pages","default_reply"]),vi=t=>Object.fromEntries(Object.entries(t).filter(([s,a])=>!Ni.has(s)&&a!==void 0&&a!==null)),_i=t=>t.new_username.trim().length<3?"用户名至少需要 3 个字符":t.current_password?t.new_password&&t.new_password.length<8?"新密码至少需要 8 个字符":t.new_password!==t.confirm_password?"两次输入的新密码不一致":"":"请输入当前密码确认身份",rt=(t,s,a)=>t===s&&!a.aborted,Gt=t=>t instanceof Error&&t.message==="请求已取消",Vt=(t,s)=>t instanceof Error?t.message:s,wi=(t="")=>({new_username:t,current_password:"",new_password:"",confirm_password:""}),Qt=(t,s)=>({type:t,text:s}),ki=()=>{const[t,s]=r.useState(null),[a,l]=r.useState(!1),[n,c]=r.useState(""),[u,h]=r.useState(!1),[m,N]=r.useState(""),[x,p]=r.useState([]),[_,S]=r.useState(!1),[q,w]=r.useState(""),[P,A]=r.useState(!1),[G,H]=r.useState(!1),[X,f]=r.useState(!1),[y,z]=r.useState(!1),[O,F]=r.useState(!1),[d,B]=r.useState(!1),[Z,M]=r.useState(null),[b,k]=r.useState(()=>wi()),[D,C]=r.useState("idle"),W=r.useRef(null),V=r.useRef(null),v=r.useRef(0),ee=r.useRef(null);V.current=t;const be=r.useCallback(()=>{var Q;(Q=ee.current)==null||Q.abort();const L=new AbortController;return ee.current=L,v.current+=1,{controller:L,sequence:v.current}},[]),U=r.useCallback(async(L,Q=!1,Y)=>{const re=L||V.current,ue=(re==null?void 0:re.ai_api_url)||(re==null?void 0:re.ai_base_url)||Ha;S(!0),w("");try{const Ne=await en(ue,(re==null?void 0:re.ai_api_key)||"",{signal:Y});if(Y!=null&&Y.aborted)return;p(Ne),A(Q&&Ne.length>0),!(re!=null&&re.ai_model)&&Ne.length>0&&s(R=>R&&{...R,ai_model:Ne[0]})}catch(Ne){if(Y!=null&&Y.aborted||Gt(Ne))return;p([]),A(!1),w(Vt(Ne,"读取模型失败"))}finally{Y!=null&&Y.aborted||S(!1)}},[]),ae=r.useCallback(()=>{const{controller:L,sequence:Q}=be();l(!0),C("loading"),c(""),Promise.all([Wa({signal:L.signal}),qa({signal:L.signal})]).then(([Y,re])=>{rt(v.current,Q,L.signal)&&(s(Y),re.username&&k(ue=>({...ue,new_username:re.username||""})),U(Y,!1,L.signal),C("success"))}).catch(Y=>{!rt(v.current,Q,L.signal)||Gt(Y)||(s(null),c(Vt(Y,"加载配置失败")),C("error"))}).finally(()=>{rt(v.current,Q,L.signal)&&l(!1)})},[be,U]);r.useEffect(()=>(ae(),()=>{var L;return(L=ee.current)==null?void 0:L.abort()}),[ae]),r.useEffect(()=>{const L=Q=>{var Y;(Y=W.current)!=null&&Y.contains(Q.target)||A(!1)};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[]);const ge=r.useCallback(async()=>{if(!t||u)return;const{controller:L,sequence:Q}=be();h(!0),N("");try{if(await Ja(vi(t),{signal:L.signal}),!rt(v.current,Q,L.signal))return;window.alert("系统配置已保存")}catch(Y){if(!rt(v.current,Q,L.signal)||Gt(Y))return;N(Vt(Y,"保存配置失败"))}finally{rt(v.current,Q,L.signal)&&h(!1)}},[be,u,t]),$=r.useCallback(async L=>{L.preventDefault(),M(null);const Q=_i(b);if(Q){M(Qt("error",Q));return}const{controller:Y,sequence:re}=be();B(!0);try{const ue=await Zr({current_password:b.current_password,new_username:b.new_username.trim(),new_password:b.new_password||void 0},{signal:Y.signal});if(!rt(v.current,re,Y.signal))return;if(!ue.success){M(Qt("error",ue.message||"登录凭据更新失败"));return}M(Qt("success",ue.message||"登录凭据已更新")),window.setTimeout(()=>window.location.reload(),1400)}catch(ue){if(!rt(v.current,re,Y.signal)||Gt(ue))return;M(Qt("error",Vt(ue,"登录凭据更新失败")))}finally{rt(v.current,re,Y.signal)&&B(!1)}},[be,b]);return{settings:t,loading:a,loadError:n,saving:u,saveError:m,aiModels:x,modelsLoading:_,modelError:q,modelDropdownOpen:P,showApiKey:G,showCaptchaSecret:X,showCurrentPassword:y,showNewPassword:O,credentialsSaving:d,credentialsMessage:Z,credentials:b,requestStatus:D,modelPickerRef:W,loadSettings:ae,loadAIModels:(L,Q)=>void U(L,Q),handleSave:ge,handleCredentialsSave:$,setSettings:s,setModelDropdownOpen:A,setShowApiKey:H,setShowCaptchaSecret:f,setShowCurrentPassword:z,setShowNewPassword:F,setCredentials:k,setCredentialsMessage:M}},Ci=()=>{const{settings:t,loading:s,loadError:a,saving:l,saveError:n,aiModels:c,modelsLoading:u,modelError:h,modelDropdownOpen:m,showApiKey:N,showCaptchaSecret:x,showCurrentPassword:p,showNewPassword:_,credentialsSaving:S,credentialsMessage:q,credentials:w,modelPickerRef:P,loadSettings:A,loadAIModels:G,handleSave:H,handleCredentialsSave:X,setSettings:f,setModelDropdownOpen:y,setShowApiKey:z,setShowCaptchaSecret:O,setShowCurrentPassword:F,setShowNewPassword:d,setCredentials:B}=ki();if(!t)return e.jsxs("div",{className:"p-8 text-center text-gray-400 space-y-3",children:[a||(s?"加载配置中...":"暂无配置"),!s&&a&&e.jsx("div",{children:e.jsx("button",{type:"button",className:"ios-btn-primary px-4 py-2 rounded-xl",onClick:A,children:"重新加载"})})]});const Z=t.ai_model||"",M=c;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(Ps,{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:A,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(We,{className:"w-4 h-4"}),"刷新"]})]}),n&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm text-red-700",children:[e.jsx("span",{children:n}),e.jsx("button",{type:"button",className:"font-bold underline",onClick:()=>{},children:"重试保存"})]}),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(wr,{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:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"日志输出等级"}),e.jsx("select",{value:t.log_level||"info",onChange:b=>f({...t,log_level:b.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:ji.map(b=>e.jsx("option",{value:b.value,children:b.label},b.value))}),e.jsx("p",{className:"text-xs text-gray-500",children:"等级越低输出越详细,Debug 适合排查问题"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"日志输出格式"}),e.jsxs("select",{value:t.log_format||"text",onChange:b=>f({...t,log_format:b.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"text",children:"Text"}),e.jsx("option",{value:"json",children:"JSON"})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"JSON 适合接入集中式日志系统,保存后需重启服务生效"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"续期日志保留天数"}),e.jsx("input",{type:"number",value:t.renewal_log_retention_days??10,onChange:b=>f({...t,renewal_log_retention_days:parseInt(b.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"365"}),e.jsx("p",{className:"text-xs text-gray-500",children:"0 表示不自动清理续期日志"})]})]})]}),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-brand text-white",children:e.jsx(Ds,{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:t.ai_api_url||Ha,onChange:b=>f({...t,ai_api_url:b.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:N?"text":"password",value:t.ai_api_key||"",onChange:b=>f({...t,ai_api_key:b.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:()=>z(!N),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:N?e.jsx(bt,{className:"w-4 h-4"}):e.jsx(mt,{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:P,className:"relative flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("input",{value:Z,onFocus:()=>c.length>0&&y(!0),onChange:b=>{f({...t,ai_model:b.target.value}),c.length>0&&y(!0)},onKeyDown:b=>{b.key==="Escape"&&y(!1),b.key==="ArrowDown"&&c.length>0&&y(!0)},className:"w-full ios-input px-4 py-3 pr-10 rounded-xl",placeholder:"从接口读取或手动输入模型名"}),e.jsx("button",{type:"button",onClick:()=>c.length>0&&y(b=>!b),disabled:c.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(kr,{className:`w-4 h-4 transition-transform ${m?"rotate-180":""}`})}),m&&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:M.length>0?M.map(b=>e.jsxs("button",{type:"button",onClick:()=>{f({...t,ai_model:b}),y(!1)},className:"w-full px-4 py-2.5 text-left text-sm text-gray-700 hover:bg-blue-50 hover:text-brand flex items-center justify-between gap-3",children:[e.jsx("span",{className:"truncate",children:b}),b===Z&&e.jsx(Ye,{className:"w-4 h-4 shrink-0 text-brand"})]},b)):e.jsx("div",{className:"px-4 py-3 text-sm text-gray-400",children:"没有匹配的模型"})})]}),e.jsxs("button",{type:"button",onClick:()=>G(void 0,!0),disabled:u,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(We,{className:`w-4 h-4 ${u?"animate-spin":""}`}),"读取模型"]})]}),h?e.jsx("p",{className:"text-xs text-red-500",children:h}):e.jsx("p",{className:"text-xs text-gray-500",children:c.length>0?`已从当前 API 地址读取到 ${c.length} 个模型`:"模型列表从当前 API 地址读取,也可以手动输入模型名"})]}),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.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-amber-500 text-white",children:e.jsx(qt,{className:"w-4 h-4"})}),"远程过滑块配置"]}),e.jsxs("div",{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.jsx("input",{type:"url",value:t["captcha.remote_service_url"]||"",onChange:b=>f({...t,"captcha.remote_service_url":b.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"https://example.com/internal/captcha/solve"})]}),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:x?"text":"password",value:t["captcha.remote_secret_key"]||"",onChange:b=>f({...t,"captcha.remote_secret_key":b.target.value}),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl font-mono text-sm",autoComplete:"off"}),e.jsx("button",{type:"button",onClick:()=>O(!x),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:x?"隐藏秘钥":"显示秘钥",children:x?e.jsx(bt,{className:"w-4 h-4"}):e.jsx(mt,{className:"w-4 h-4"})})]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-xl bg-amber-50 p-4 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:String(t["captcha.remote_pass_cookies"]||"").toLowerCase()==="true",onChange:b=>f({...t,"captcha.remote_pass_cookies":b.target.checked}),className:"mt-0.5 w-4 h-4 rounded border-gray-300"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-bold text-amber-900",children:"允许向远程服务传递账号 Cookie"}),e.jsx("span",{className:"block mt-1 text-xs text-amber-700",children:"默认关闭。仅在信任远程服务且需要由其自动重取过期验证链接时开启。"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",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(Ws,{className:"w-4 h-4"})}),"登录凭据"]}),e.jsxs("form",{onSubmit:X,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(Zt,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",value:w.new_username,onChange:b=>B({...w,new_username:b.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:p?"text":"password",value:w.current_password,onChange:b=>B({...w,current_password:b.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:()=>F(!p),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:p?"隐藏密码":"显示密码",children:p?e.jsx(bt,{className:"w-4 h-4"}):e.jsx(mt,{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:_?"text":"password",value:w.new_password,onChange:b=>B({...w,new_password:b.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:()=>d(!_),className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:_?"隐藏密码":"显示密码",children:_?e.jsx(bt,{className:"w-4 h-4"}):e.jsx(mt,{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:_?"text":"password",value:w.confirm_password,onChange:b=>B({...w,confirm_password:b.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(qt,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:q.text})]}),e.jsxs("button",{type:"submit",disabled:S||!w.new_username||!w.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(Ws,{className:"w-4 h-4"}),S?"正在更新...":"更新登录凭据"]})]})]})]})]}),e.jsx("div",{className:"fixed bottom-10 right-10 z-30",children:e.jsxs("button",{onClick:H,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:[e.jsx(lt,{className:"w-6 h-6"}),l?"保存中...":"保存所有配置"]})})]})},us=(t,s)=>t.allowed_resolutions.includes(s),Si=(t,s)=>({runs:t.runs.filter(a=>!s||a.cookie_id===s),pending_tasks:t.pending_tasks.filter(a=>!s||a.cookie_id===s)}),Li=t=>({external_result_unknown:"外部动作结果未知",invalid_snapshot:"历史数据无法恢复",rule_unavailable:"规则不可用",partial_failure:"部分动作失败",execution_failed:"动作执行失败"})[t]||"自动化异常",Ri=({runs:t,pendingTasks:s,onResolveRun:a,onResolveDeferredTask:l})=>e.jsxs("section",{className:"rounded-2xl border border-red-200 bg-red-50 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ut,{className:"w-5 h-5 text-red-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-black text-red-900",children:"需要人工处理的自动化任务"}),e.jsx("p",{className:"text-sm text-red-700 mt-1",children:"请先在闲鱼聊天、订单或商品列表中核对真实结果,再选择继续或重试。"})]})]}),e.jsxs("div",{className:"space-y-3",children:[t.map(n=>e.jsxs("div",{className:"rounded-xl border border-red-100 bg-white p-4 flex flex-col lg:flex-row lg:items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-bold text-gray-900",children:["账号 ",n.cookie_id," · 订单 ",n.order_id||"-"," · 已记录发送 ",n.sent_count," 条"]}),e.jsx("div",{className:"text-xs font-bold text-red-800 mt-1",children:Li(n.issue_kind)}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:n.error_message})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 shrink-0",children:[us(n,"continue")&&e.jsx("button",{onClick:(()=>a(n.id,"continue")),className:"px-3 py-2 rounded-lg bg-emerald-100 text-emerald-800 text-xs font-bold",children:"已执行,继续下一步"}),us(n,"retry")&&e.jsx("button",{onClick:(()=>a(n.id,"retry")),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"未执行,安全重试"}),us(n,"cancel")&&e.jsx("button",{onClick:(()=>a(n.id,"cancel")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"终止"})]})]},`run-${n.id}`)),s.map(n=>e.jsxs("div",{className:"rounded-xl border border-red-100 bg-white p-4 flex flex-col lg:flex-row lg:items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-bold text-gray-900",children:["账号 ",n.cookie_id," · 延迟任务重试已达 ",n.attempt_count," 次"]}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:n.error_message})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[e.jsx("button",{onClick:(()=>l(n.id,"retry")),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"重新入队"}),e.jsx("button",{onClick:(()=>l(n.id,"dismiss")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"忽略"})]})]},`task-${n.id}`))]})]}),ps=()=>({submitting:!1,result:"idle"}),hs=t=>t.submitting?t:{submitting:!0,result:"idle"},gs=(t,s)=>({submitting:!1,result:s?"success":"failure"}),ha=t=>t+1,bs=(t,s,a,l)=>t===s&&a===l,Ai=t=>{const[s,a]=r.useState([]),[l,n]=r.useState({runs:[],pending_tasks:[]}),[c,u]=r.useState([]),[h,m]=r.useState({}),[N,x]=r.useState([]),[p,_]=r.useState([]),[S,q]=r.useState([]),[w,P]=r.useState(!1),A=r.useRef(0),G=r.useRef(0),[H,X]=r.useState(0),[f,y]=r.useState(0),[z,O]=r.useState({}),F=r.useCallback(async()=>{const k=Promise.all([Ft(),Ms(),Lt(),ra()]),[D,C,W,V]=await k;x(D),_(C),q(W),m(V),t.setSelectedAccountId(v=>{var ee;return v||((ee=D[0])==null?void 0:ee.id)||""})},[t.setSelectedAccountId]),d=r.useCallback(async()=>{var V;const k=ha(A.current);A.current=k;const D=Wl().catch(v=>(console.warn("加载自动化异常列表失败,不阻断规则展示",v),null)),C=await Fl({cookieId:t.selectedAccountId||void 0,triggerType:t.automationTriggerFilter,enabled:t.automationStatusFilter==="all"?void 0:t.automationStatusFilter==="enabled",search:t.debouncedAutomationSearch,page:t.automationPage,pageSize:t.automationPageSize});if(!bs(k,A.current,t.selectedAccountId,t.selectedAccountId))return;a(C.data),X(C.total),y(C.total_pages),O(C.trigger_counts||{}),C.page!==t.automationPage&&((V=t.onAutomationPageChange)==null||V.call(t,C.page));const W=await D;bs(k,A.current,t.selectedAccountId,t.selectedAccountId)&&W&&n(W)},[t.automationPage,t.automationPageSize,t.automationStatusFilter,t.automationTriggerFilter,t.debouncedAutomationSearch,t.onAutomationPageChange,t.selectedAccountId]),B=r.useCallback(async()=>{const k=ha(G.current);G.current=k;const D=t.selectedAccountId;if(u([]),!D)return;const C=await Kl(D);bs(k,G.current,D,t.selectedAccountId)&&u(C)},[t.selectedAccountId]),Z=r.useCallback(async()=>{m(await ra())},[]),M=r.useCallback(async()=>{P(!0);try{t.activeTab==="automation"?await d():t.activeTab==="reply"?await B():await Z()}finally{P(!1)}},[d,Z,B,t.activeTab]);return{automationRules:s,automationIssues:l,replyRules:c,defaultReplies:h,accounts:N,cards:p,items:S,automationTotal:H,automationTotalPages:f,automationTriggerCounts:z,loading:w,setLoading:P,setAutomationRules:a,setCards:_,setItems:q,loadReferenceData:F,loadAutomationRules:d,loadReplyRules:B,loadDefaultReplies:Z,refresh:M}},xt={order_paid:{label:"付款后自动发货",shortLabel:"自动发货",description:"闲鱼付款系统卡片进入自动化中心后,先发送卡密,成功后再确认发货。",flow:["付款系统卡片","匹配商品/规格","发送卡密","确认发货"],accent:"blue",icon:Bt},buyer_reviewed:{label:"评价后发送赠品",shortLabel:"评价赠品",description:"闲鱼评价系统卡片进入自动化中心后,给买家发送赠品卡密。",flow:["评价系统卡片","匹配商品/规格","发送赠品"],accent:"emerald",icon:Cr},review_missing_timeout:{label:"超时未评价求评价",shortLabel:"求评价",description:"计划任务扫描已发货未评价订单,到期后发送求评价文案。",flow:["计划任务扫描","已发货未评价","达到等待时间","发送提醒"],accent:"amber",icon:Pa}},Kt=["order_paid","buyer_reviewed","review_missing_timeout"],Ii="亲,商品使用满意的话,麻烦给个评价,谢谢~",Pt=()=>({spec_name:"",spec_value:"",card_id:0,delivery_count:1,enabled:!0,delay_override:!1,delay_seconds:0}),Za=t=>{if(!t)return{};try{const s=JSON.parse(t);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}},gt=(t,s={})=>{const a=Za(t);return JSON.stringify({after_shipped_hours:Number(a.after_shipped_hours||72),repeat_interval_hours:Number(a.repeat_interval_hours||24),max_attempts:Number(a.max_attempts||1),...s})},Tt=(t,s)=>{var l;const a=((l=xt[t])==null?void 0:l.label)||"自动化规则";return s?`${a} - ${s}`:a},ga=t=>{const s=(t||"").trim();return s?Object.values(xt).some(a=>s===a.label||s.startsWith(`${a.label} -`)):!0},Et=(t,s=0)=>{if(t==="review_missing_timeout")return[{action_type:"send_text",message_template:Ii,enabled:!0,sort_order:1}];const a={action_type:"send_card",card_id:s,delivery_count:1,enabled:!0,sort_order:1};return t==="order_paid"?[a,{action_type:"confirm_shipment",enabled:!0,sort_order:2}]:[a]},Oi=t=>{var a,l;if(t.trigger_type==="review_missing_timeout")return((l=(a=t.actions)==null?void 0:a.find(n=>n.action_type==="send_text"))==null?void 0:l.message_template)||"发送求评价文案";const s=(t.actions||[]).filter(n=>n.action_type==="send_card");return s.length?s.map(n=>n.card_name||`卡密 ${n.card_id}`).join(" / "):"未配置卡密库存"},ba=(t,s=!1)=>{const a={blue:s?"border-blue-500 bg-blue-50 text-blue-700":"border-blue-100 bg-blue-50/60 text-blue-700 hover:border-blue-300",emerald:s?"border-emerald-500 bg-emerald-50 text-emerald-700":"border-emerald-100 bg-emerald-50/60 text-emerald-700 hover:border-emerald-300",amber:s?"border-amber-500 bg-amber-50 text-amber-700":"border-amber-100 bg-amber-50/60 text-amber-700 hover:border-amber-300"};return a[t]||a.blue},Pi=t=>t?"bg-emerald-100 text-emerald-700":"bg-gray-200 text-gray-500",Ht=t=>(t==null?void 0:t.nickname)||(t==null?void 0:t.remark)||(t==null?void 0:t.id)||"未知账号",Ti=t=>t===!0||t===1||t==="1",Ei=({initialDeliveryTarget:t,onDeliveryTargetHandled:s})=>{var Ke,zt,Ut;const[a,l]=r.useState("automation"),[n,c]=r.useState(""),[u,h]=r.useState(""),[m,N]=r.useState(""),[x,p]=r.useState(""),[_,S]=r.useState("all"),[q,w]=r.useState(1),[P,A]=r.useState(10),G=Ai({activeTab:a,selectedAccountId:n,automationTriggerFilter:x,automationStatusFilter:_,debouncedAutomationSearch:m,automationPage:q,automationPageSize:P,setSelectedAccountId:c,onAutomationPageChange:w}),{automationRules:H,automationIssues:X,replyRules:f,defaultReplies:y,accounts:z,cards:O,items:F,loading:d,setLoading:B,automationTotal:Z,automationTotalPages:M,automationTriggerCounts:b,setAutomationRules:k,setCards:D,setItems:C,loadReferenceData:W,loadAutomationRules:V,loadReplyRules:v,loadDefaultReplies:ee,refresh:be}=G,[U,ae]=r.useState(!1),[ge,$]=r.useState(!1),[L,Q]=r.useState(!1),[Y,re]=r.useState(ps),[ue,Ne]=r.useState(ps),[R,T]=r.useState(ps),[g,le]=r.useState(null),[oe,ne]=r.useState(null),[de,Se]=r.useState({cookie_id:"",enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""});z.find(i=>i.id===n),r.useEffect(()=>{const i=window.setTimeout(()=>{w(1),N(u.trim())},300);return()=>window.clearTimeout(i)},[u]),r.useEffect(()=>{W().catch(i=>console.error("加载规则参考数据失败",i))},[W]),r.useEffect(()=>{be().catch(i=>console.error("刷新规则页面失败",i))},[be]);const Ee=r.useMemo(()=>H.filter(i=>!n||i.cookie_id===n),[H,n]),Te=r.useMemo(()=>Si(X,n),[X,n]),Ue=r.useMemo(()=>z.filter(i=>!n||i.id===n),[z,n]),Me=r.useMemo(()=>{if(M<=1)return[];const i=Math.max(1,Math.min(q-2,M-4)),I=Math.min(M,i+4);return Array.from({length:I-i+1},(te,he)=>i+he)},[q,M]),Be=!!(u.trim()||x||_!=="all"),Je=()=>{h(""),N(""),p(""),S("all"),w(1)},He=r.useMemo(()=>{const i=(g==null?void 0:g.cookie_id)||n;return F.filter(I=>I.cookie_id===i)},[g==null?void 0:g.cookie_id,F,n]),we=r.useMemo(()=>{if(!(!(g!=null&&g.cookie_id)||!(g!=null&&g.item_id)))return F.find(i=>i.cookie_id===g.cookie_id&&i.item_id===g.item_id)},[g==null?void 0:g.cookie_id,g==null?void 0:g.item_id,F]),pe=Ti(we==null?void 0:we.is_multi_spec),Ve=(g==null?void 0:g.trigger_type)||"order_paid",it=xt[Ve],tt=Za(g==null?void 0:g.config_json),Qe=r.useCallback((i="order_paid",I=n,te="")=>{const he=F.find($e=>$e.cookie_id===I&&$e.item_id===te),Ae=(he==null?void 0:he.item_title)||te;return{name:Tt(i,Ae),trigger_type:i,cookie_id:I,item_id:te,item_title:(he==null?void 0:he.item_title)||"",item_keyword:Ae,card_group_id:0,priority:100,enabled:!0,config_json:i==="review_missing_timeout"?gt():"{}",actions:Et(i),variants:i==="review_missing_timeout"?[]:[Pt()]}},[F,n]),Ge=r.useCallback(i=>{var te,he;const I=i.trigger_type||"order_paid";le({...i,trigger_type:I,config_json:I==="review_missing_timeout"?gt(i.config_json):i.config_json||"{}",actions:(te=i.actions)!=null&&te.length?i.actions.map(Ae=>({...Ae})):Et(I,i.card_group_id),variants:(he=i.variants)!=null&&he.length?i.variants.map(Ae=>({...Ae})):I==="review_missing_timeout"?[]:[Pt()]}),ae(!0)},[]);r.useEffect(()=>{if(!t)return;let i=!1;return(async()=>{l("automation"),c(t.cookieId),B(!0);try{const[te,he,Ae]=await Promise.all([Ss(),Lt(),Ms().catch(Re=>(console.warn("加载卡密库存失败,不阻断打开自动化规则",Re),[]))]);if(i)return;k(te),C(he),D(Ae);const $e=te.find(Re=>Re.cookie_id===t.cookieId&&Re.item_id===t.itemId&&Re.trigger_type==="order_paid");if($e)Ge($e);else{const Re=he.find(ct=>ct.cookie_id===t.cookieId&&ct.item_id===t.itemId);le({...Qe("order_paid",t.cookieId,t.itemId),item_title:(Re==null?void 0:Re.item_title)||"",item_keyword:(Re==null?void 0:Re.item_title)||t.itemId,name:Tt("order_paid",(Re==null?void 0:Re.item_title)||t.itemId)}),ae(!0)}}catch(te){console.error("打开商品自动化规则失败",te),alert("无法加载该商品的自动化规则")}finally{i||(B(!1),s==null||s())}})(),()=>{i=!0}},[Qe,t,s,Ge]);const ot=(i="order_paid")=>{if(!n){alert("请先选择账号");return}le(Qe(i)),ae(!0)},pt=i=>{var he,Ae,$e,Re,ct;if(!g)return;const I=((Ae=(he=g.variants)==null?void 0:he.find(jt=>jt.card_id))==null?void 0:Ae.card_id)||((Re=($e=g.actions)==null?void 0:$e.find(jt=>jt.action_type==="send_card"))==null?void 0:Re.card_id)||g.card_group_id||0,te=(we==null?void 0:we.item_title)||g.item_title||g.item_id||"";le({...g,trigger_type:i,name:ga(g.name)?Tt(i,te):g.name,card_group_id:I,config_json:i==="review_missing_timeout"?gt(g.config_json):"{}",actions:Et(i,I),variants:i==="review_missing_timeout"?[]:(ct=g.variants)!=null&&ct.length?g.variants:[{...Pt(),card_id:I}]})},ht=i=>{if(!g)return;const I=F.find(he=>he.cookie_id===(g.cookie_id||n)&&he.item_id===i),te=(I==null?void 0:I.item_title)||i;le({...g,item_id:i,item_title:(I==null?void 0:I.item_title)||"",item_keyword:te,name:ga(g.name)?Tt(Ve,te):g.name})},J=(Ke=g==null?void 0:g.variants)!=null&&Ke.length?g.variants:[Pt()],ie=(i,I)=>{var he;if(!g)return;const te=J.map((Ae,$e)=>$e===i?{...Ae,...I}:Ae);le({...g,variants:te,card_group_id:((he=te[0])==null?void 0:he.card_id)||0})},j=()=>{if(!g)return;const i=J[J.length-1];le({...g,variants:[...J,{...Pt(),spec_name:pe&&(i==null?void 0:i.spec_name)||"",spec_value:pe&&(i==null?void 0:i.spec_value)||""}]})},E=async()=>{var Ae,$e,Re,ct,jt;if(!g||Y.submitting)return;const i=g.trigger_type||"order_paid";if(!g.cookie_id){alert("请选择账号");return}const I=(Ae=g.variants)!=null&&Ae.length?g.variants:[];if(i!=="review_missing_timeout"){if(!I.length||I.some(qe=>!qe.card_id)){alert(i==="buyer_reviewed"?"请选择评价赠品卡密库存":"请选择发货卡密库存");return}if(pe&&I.some(qe=>!qe.spec_name.trim()||!qe.spec_value.trim())){alert("多规格商品必须填写每一行的规格名称和规格值");return}}if(i==="review_missing_timeout"&&!(((Re=($e=g.actions)==null?void 0:$e.find(nr=>nr.action_type==="send_text"))==null?void 0:Re.message_template)||"").trim()){alert("请填写求评价文案");return}const te=i==="review_missing_timeout"?[]:I.map(qe=>({...qe,spec_name:pe?qe.spec_name.trim():"",spec_value:pe?qe.spec_value.trim():"",delivery_count:Math.max(1,Number(qe.delivery_count)||1),enabled:qe.enabled!==!1}));re(hs(Y));let he=!1;try{await sa({...g,trigger_type:i,name:(g.name||"").trim()||Tt(i,(we==null?void 0:we.item_title)||g.item_id||""),config_json:i==="review_missing_timeout"?gt(g.config_json):g.config_json||"{}",actions:(ct=g.actions)!=null&&ct.length?g.actions:Et(i,((jt=te[0])==null?void 0:jt.card_id)||g.card_group_id||0),variants:te}),ae(!1),await Promise.all([V(),W()]),alert("保存成功"),he=!0}catch(qe){console.error("保存自动化规则失败:",qe),alert("保存失败:"+qe.message)}finally{re(qe=>gs(qe,he))}},se=async i=>{if(confirm("确定删除该自动化规则吗?"))try{await Ul(i),await V(),alert("删除成功")}catch(I){alert("删除失败:"+I.message)}},ce=async i=>{try{await sa({...i,enabled:!i.enabled}),await V()}catch(I){alert("操作失败:"+I.message)}},fe=async(i,I)=>{if(confirm(I==="continue"?"确认外部动作已经执行成功,并跳到下一步吗?":I==="retry"?"确认外部动作没有执行,可以安全重试吗?错误判断可能造成重复发送。":"确认终止该自动化运行吗?"))try{await Jl(i,I),await V()}catch(he){alert("处理失败:"+he.message)}},De=async(i,I)=>{if(confirm(I==="retry"?"确认重新执行该任务吗?":"确认忽略并删除该异常任务吗?"))try{await Gl(i,I),await V()}catch(te){alert("处理失败:"+te.message)}},ve=()=>{if(!n){alert("请先选择账号");return}ne({keyword:"",reply_content:"",image_url:"",item_id:"",type:"text",match_type:"fuzzy",enabled:!0}),$(!0)},Pe=async()=>{var te,he,Ae;if(!oe||!n||ue.submitting)return;const i=oe.type==="image"?!!((te=oe.image_url)!=null&&te.trim()):!!((he=oe.reply_content)!=null&&he.trim());if(!((Ae=oe.keyword)!=null&&Ae.trim())||!i){alert("请填写关键词和回复内容");return}Ne(hs(ue));let I=!1;try{await Hl({...oe,match_type:"fuzzy",enabled:!0},n),$(!1),await v(),alert("保存成功"),I=!0}catch($e){alert("保存失败:"+$e.message)}finally{Ne($e=>gs($e,I))}},me=async i=>{if(!(!n||!confirm("确定删除该回复规则吗?")))try{await Zl(i,n),await v(),alert("删除成功")}catch(I){alert("删除失败:"+I.message)}},o=async(i=n)=>{if(!i){alert("请先选择账号");return}try{const I=await nn(i);Se({cookie_id:i,enabled:I.enabled,reply_content:I.reply_content,reply_once:I.reply_once,reply_image_url:I.reply_image_url||""})}catch{Se({cookie_id:i,enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""})}Q(!0)},K=async()=>{if(R.submitting)return;if(!de.cookie_id){alert("请先选择账号");return}if(de.enabled&&!de.reply_content.trim()&&!de.reply_image_url.trim()){alert("启用默认回复时,请填写回复内容或图片 URL");return}T(hs(R));let i=!1;try{await on(de.cookie_id,{enabled:de.enabled,reply_content:de.reply_content,reply_once:de.reply_once,reply_image_url:de.reply_image_url}),Q(!1),await ee(),alert("保存成功"),i=!0}catch(I){alert("保存失败:"+I.message)}finally{T(I=>gs(I,i))}},xe=async i=>{if(confirm("确定删除该账号默认回复吗?"))try{await cn(i),await ee(),alert("删除成功")}catch(I){alert("删除失败:"+I.message)}},Le=async i=>{if(confirm("确定清空该账号的默认回复记录吗?清空后可重新对所有会话使用“只回复一次”。"))try{await dn(i),alert("清空成功")}catch(I){alert("清空失败:"+I.message)}},st=a==="automation"?"新建自动化":a==="reply"?"新增关键词":"编辑默认回复";return e.jsxs("div",{className:"min-w-0 space-y-8 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row 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:"系统通知卡片只进入自动化判断;买家消息进入关键词、默认或 AI 回复。"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:flex-wrap gap-3",children:[e.jsxs("select",{value:n,onChange:i=>{c(i.target.value),w(1)},className:"ios-input w-full px-4 py-3 rounded-2xl text-sm sm:w-64",children:[e.jsx("option",{value:"",children:"全部账号"}),z.map(i=>e.jsx("option",{value:i.id,children:Ht(i)},i.id))]}),e.jsxs("button",{onClick:be,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 whitespace-nowrap transition-colors",children:[e.jsx(We,{className:`w-4 h-4 ${d?"animate-spin":""}`}),"刷新"]}),e.jsxs("button",{onClick:a==="automation"?()=>ot("order_paid"):a==="reply"?ve:()=>void o(),disabled:!n,className:"ios-btn-primary px-5 py-3 rounded-2xl text-sm font-extrabold flex items-center justify-center gap-2 whitespace-nowrap disabled:opacity-50",children:[e.jsx(nt,{className:"w-4 h-4"}),st]})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[{id:"automation",label:"交易自动化",icon:js},{id:"reply",label:"关键词回复",icon:$t},{id:"default",label:"账号默认回复",icon:wt}].map(i=>{const I=i.icon;return e.jsxs("button",{onClick:()=>l(i.id),className:`inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${a===i.id?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:[e.jsx(I,{className:"w-4 h-4"}),i.label]},i.id)})}),a==="automation"&&(Te.runs.length>0||Te.pending_tasks.length>0)&&e.jsx(Ri,{runs:Te.runs,pendingTasks:Te.pending_tasks,onResolveRun:(i,I)=>void fe(i,I),onResolveDeferredTask:(i,I)=>void De(i,I)}),a==="automation"&&e.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-6 xl:grid-cols-[minmax(270px,0.72fr)_minmax(0,1.28fr)]",children:[e.jsxs("aside",{className:"min-w-0 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:Kt.map(i=>{const I=xt[i],te=I.icon;return e.jsx("button",{type:"button",onClick:()=>ot(i),className:`w-full text-left rounded-2xl border p-4 transition-colors ${ba(I.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(te,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-extrabold",children:I.label}),e.jsx("div",{className:"text-xs opacity-75 mt-1 leading-5",children:I.description})]})]})},i)})})]}),e.jsxs("div",{className:"bg-white rounded-xl p-5 border border-gray-100 shadow-sm",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"font-black text-gray-900",children:"筛选结果构成"}),e.jsxs("span",{className:"text-xs font-bold text-gray-400",children:["共 ",Z," 条"]})]}),e.jsx("div",{className:"space-y-3",children:Kt.map(i=>{const I=xt[i],te=I.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(te,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{className:"text-sm font-bold text-gray-700",children:I.shortLabel})]}),e.jsx("span",{className:"text-sm font-black text-gray-900",children:b[i]||0})]},i)})})]})]}),e.jsxs("section",{className:"min-w-0 space-y-4",children:[e.jsxs("div",{className:"rounded-xl border border-gray-100 bg-surface-muted p-4 shadow-sm",children:[e.jsxs("div",{className:"flex flex-col gap-3 xl:flex-row xl:items-center",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(St,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"搜索自动化规则",placeholder:"搜索规则名、商品名或商品 ID...",value:u,onChange:i=>{h(i.target.value),w(1)},className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]}),e.jsxs("div",{className:"relative xl:w-52",children:[e.jsx(Oa,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按自动化类型筛选",value:x,onChange:i=>{p(i.target.value),w(1)},className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部自动化类型"}),Kt.map(i=>e.jsx("option",{value:i,children:xt[i].shortLabel},i))]})]}),e.jsxs("select",{"aria-label":"按启用状态筛选",value:_,onChange:i=>{S(i.target.value),w(1)},className:"ios-input rounded-xl border-none bg-white px-4 py-2.5 text-sm shadow-sm xl:w-36",children:[e.jsx("option",{value:"all",children:"全部状态"}),e.jsx("option",{value:"enabled",children:"已启用"}),e.jsx("option",{value:"disabled",children:"已禁用"})]}),Be&&e.jsx("button",{type:"button",onClick:Je,className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-white text-gray-500 shadow-sm transition-colors hover:bg-gray-100 hover:text-gray-900",title:"清除筛选","aria-label":"清除筛选",children:e.jsx(ke,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between text-xs font-bold text-gray-400",children:[e.jsxs("span",{children:["找到 ",Z," 条规则"]}),d&&e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(We,{className:"h-3.5 w-3.5 animate-spin"}),"正在更新"]})]})]}),d&&Ee.length===0?e.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-xl border border-gray-100 bg-white text-sm font-bold text-gray-400",children:[e.jsx(We,{className:"mr-2 h-4 w-4 animate-spin"}),"正在加载规则"]}):Ee.length===0?e.jsxs("div",{className:"bg-white rounded-xl border border-dashed border-gray-200 p-16 text-center",children:[e.jsx(js,{className:"w-12 h-12 text-gray-300 mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-black text-gray-900",children:Be?"没有匹配的自动化规则":"还没有自动化规则"}),e.jsx("p",{className:"text-gray-500 mt-2",children:Be?"调整或清除筛选条件后再试。":"从左侧选择一个模板开始配置。"})]}):Ee.map(i=>{const I=xt[i.trigger_type],te=I.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 ${ba(I.accent,!0)}`,children:e.jsx(te,{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:i.name}),e.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-bold ${Pi(i.enabled)}`,children:i.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:I.label}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-gray-100 text-gray-600",children:i.item_title||i.item_id||"账号级规则"}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-blue-50 text-blue-700",children:Oi(i)})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{onClick:()=>Ge(i),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(kt,{className:"w-4 h-4"}),"编辑"]}),e.jsx("button",{onClick:()=>ce(i),className:`px-4 py-2 rounded-xl text-sm font-bold ${i.enabled?"bg-amber-50 text-amber-700 hover:bg-amber-100":"bg-emerald-50 text-emerald-700 hover:bg-emerald-100"}`,children:i.enabled?"禁用":"启用"}),e.jsx("button",{onClick:()=>se(i.id),className:"p-2.5 rounded-xl text-red-500 hover:bg-red-50",title:"删除",children:e.jsx(Ze,{className:"w-4 h-4"})})]})]})},i.id)}),Z>0&&e.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-gray-100 bg-white px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 text-sm font-medium text-gray-500",children:[e.jsxs("span",{children:["第 ",q," / ",Math.max(M,1)," 页"]}),e.jsx("span",{className:"h-4 w-px bg-gray-200"}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"sr-only",children:"每页显示数量"}),e.jsx("select",{value:P,onChange:i=>{A(Number(i.target.value)),w(1)},className:"ios-input rounded-lg border-none bg-gray-50 px-2.5 py-2 text-sm",children:[10,20,50].map(i=>e.jsxs("option",{value:i,children:[i," 条/页"]},i))})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",disabled:q<=1||d,onClick:()=>w(i=>Math.max(1,i-1)),className:"flex h-9 w-9 items-center justify-center rounded-lg bg-gray-50 text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"上一页",title:"上一页",children:e.jsx(Es,{className:"h-4 w-4"})}),Me.map(i=>e.jsx("button",{type:"button",disabled:d,onClick:()=>w(i),className:`h-9 min-w-9 rounded-lg px-2 text-sm font-bold transition-colors ${i===q?"bg-brand text-white":"bg-gray-50 text-gray-600 hover:bg-gray-100"} disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":`第 ${i} 页`,"aria-current":i===q?"page":void 0,children:i},i)),e.jsx("button",{type:"button",disabled:q>=M||d,onClick:()=>w(i=>Math.min(M,i+1)),className:"flex h-9 w-9 items-center justify-center rounded-lg bg-gray-50 text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"下一页",title:"下一页",children:e.jsx(Ts,{className:"h-4 w-4"})})]})]})]})]}),a==="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(ut,{className:"w-4 h-4"}),"这里只处理买家用户消息;系统通知不会进入关键词或 AI 回复。"]}),e.jsxs("div",{className:"space-y-3",children:[f.map(i=>e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border border-gray-100 bg-surface-subtle 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:"包含匹配"}),e.jsxs("h3",{className:"font-bold text-gray-900",children:["“",i.keyword,"”"]})]}),e.jsx("div",{className:"bg-white p-3 rounded-xl border border-gray-100 text-sm text-gray-600 leading-relaxed",children:i.type==="image"&&i.image_url?i.image_url:i.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:()=>{ne({...i}),$(!0)},className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(kt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>me(i.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Ze,{className:"w-5 h-5"})})]})]},i.id)),f.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无关键词回复规则"})]})]}),a==="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(ut,{className:"w-4 h-4"}),"默认回复只处理买家用户消息;关键词未命中且 AI 未接管时才会使用。"]}),e.jsxs("div",{className:"space-y-3",children:[Ue.map(i=>{const I=y[i.id],te=!!(I!=null&&I.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 ${te?"border-purple-100 bg-purple-50/50 hover:bg-white hover:shadow-lg":"border-gray-100 bg-surface-subtle 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 ${te?"bg-purple-600 text-white":"bg-gray-200 text-gray-400"}`,children:e.jsx(wt,{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:Ht(i)}),e.jsx("span",{className:`px-2 py-0.5 rounded-lg text-xs font-bold ${te?"bg-green-100 text-green-700":"bg-gray-200 text-gray-500"}`,children:te?"已启用":"未启用"}),(I==null?void 0:I.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:te?I.reply_content||I.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 o(i.id),className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(kt,{className:"w-4 h-4"})}),te&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>void Le(i.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 xe(i.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Ze,{className:"w-5 h-5"})})]})]})]},i.id)}),Ue.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无账号"})]})]}),U&&g&&Oe.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:g.id?"编辑自动化规则":"新建自动化规则"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:it.description})]}),e.jsx("button",{onClick:()=>ae(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",title:"关闭",children:e.jsx(ke,{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:Kt.map(i=>{const I=xt[i],te=I.icon,he=Ve===i;return e.jsx("button",{type:"button",onClick:()=>pt(i),className:`w-full rounded-2xl p-4 text-left border transition-all ${he?"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(te,{className:`w-5 h-5 mt-0.5 ${he?"text-brand":"text-white"}`}),e.jsxs("div",{children:[e.jsx("div",{className:"font-black",children:I.label}),e.jsx("div",{className:`text-xs mt-1 leading-5 ${he?"text-gray-500":"text-gray-400"}`,children:I.description})]})]})},i)})}),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:it.flow.map((i,I)=>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:I+1}),e.jsx("span",{className:"text-sm font-bold text-gray-100",children:i})]},i))})]})]}),e.jsx("div",{className:"p-6 overflow-y-auto bg-surface-subtle",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(Ns,{className:"w-5 h-5 text-brand"}),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:g.name||"",onChange:i=>le({...g,name:i.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:g.cookie_id||"",onChange:i=>le({...g,cookie_id:i.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:"选择账号"}),z.map(i=>e.jsx("option",{value:i.id,children:Ht(i)},i.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关联商品"}),e.jsxs("select",{value:g.item_id||"",onChange:i=>ht(i.target.value),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级规则(不限定商品)"}),He.map(i=>e.jsx("option",{value:i.item_id,children:i.item_title||i.item_id},`${i.cookie_id}-${i.item_id}`))]})]})]}),we&&Ve!=="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:we.item_title||we.item_id}),e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${pe?"bg-blue-50 text-blue-700":"bg-gray-100 text-gray-500"}`,children:pe?"多规格商品":"普通商品"}),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:"多规格状态来自闲鱼商品本身,发布后不能在这里修改;系统会在买家付款后读取订单详情,按实际购买规格和数量匹配下面的发货规则。"})]})]}),Ve!=="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(Sr,{className:"w-5 h-5 text-brand"}),e.jsx("h4",{className:"font-black text-gray-900",children:Ve==="buyer_reviewed"?"赠品库存":"发货库存"})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:pe?"每条发货内容绑定一个订单规格;同一规格可添加多条内容并全部发送。":"可添加多条发货内容,买家付款后会按顺序全部发送。"})]}),e.jsxs("button",{type:"button",onClick:j,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(nt,{className:"w-3.5 h-3.5"}),"添加发货内容"]})]}),e.jsx("div",{className:"space-y-3",children:J.map((i,I)=>e.jsxs("div",{className:`grid grid-cols-1 gap-3 items-end rounded-2xl border border-gray-200 p-4 ${pe?"md:grid-cols-[1fr_1fr_1.4fr_110px_40px]":"md:grid-cols-[1.4fr_110px_40px]"}`,children:[pe&&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:i.spec_name,onChange:te=>ie(I,{spec_name:te.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:i.spec_value,onChange:te=>ie(I,{spec_value:te.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:i.card_id||"",onChange:te=>ie(I,{card_id:Number(te.target.value)}),className:"w-full ios-input px-3 py-2.5 rounded-lg",children:[e.jsx("option",{value:"",children:"请选择卡密库存"}),O.filter(te=>te.enabled&&te.type!=="api").map(te=>e.jsx("option",{value:te.id,children:te.name},te.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:i.delivery_count,onChange:te=>ie(I,{delivery_count:Math.max(1,Number(te.target.value)||1)}),className:"w-full ios-input px-3 py-2.5 rounded-lg"})]}),e.jsxs("div",{className:"md:col-span-full flex flex-wrap items-center gap-3 rounded-xl bg-gray-50 px-3 py-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs font-bold text-gray-600 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:i.delay_override===!0,onChange:te=>ie(I,{delay_override:te.target.checked}),className:"accent-brand"}),"覆盖卡密默认延时"]}),i.delay_override&&e.jsx("input",{type:"number",min:"0",max:"3600",value:i.delay_seconds||0,onChange:te=>ie(I,{delay_seconds:Math.max(0,Number(te.target.value)||0)}),className:"w-28 ios-input px-2 py-1.5 rounded-lg text-xs","aria-label":"动作延时秒数"}),e.jsx("span",{className:"text-xs text-gray-500",children:i.delay_override?`本动作延时 ${i.delay_seconds||0} 秒`:"使用卡密默认延时"})]}),e.jsx("button",{type:"button",disabled:J.length===1,onClick:()=>le({...g,variants:J.filter((te,he)=>he!==I)}),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(Ze,{className:"w-4 h-4"})})]},i.id||I))})]}):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(Pa,{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-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",min:"1",value:Number(tt.after_shipped_hours||72),onChange:i=>le({...g,config_json:gt(g.config_json,{after_shipped_hours:Math.max(1,Number(i.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(tt.repeat_interval_hours||24),onChange:i=>le({...g,config_json:gt(g.config_json,{repeat_interval_hours:Math.max(1,Number(i.target.value)||24)})}),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(tt.max_attempts||1),onChange:i=>le({...g,config_json:gt(g.config_json,{max_attempts:Math.max(1,Number(i.target.value)||1)})}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"md:col-span-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"求评价文案"}),e.jsx("textarea",{value:((Ut=(zt=g.actions)==null?void 0:zt.find(i=>i.action_type==="send_text"))==null?void 0:Ut.message_template)||"",onChange:i=>{var I;return le({...g,actions:((I=g.actions)!=null&&I.length?g.actions:Et("review_missing_timeout")).map(te=>te.action_type==="send_text"?{...te,message_template:i.target.value}:te)})},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("p",{className:"text-xs text-gray-500 mb-2",children:"数字越小优先级越高;同一账号、商品和触发条件只执行优先级最高的一条规则。"}),e.jsx("input",{type:"number",value:g.priority||100,onChange:i=>le({...g,priority:Number(i.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:g.enabled!==!1,onChange:i=>le({...g,enabled:i.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:()=>ae(!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:E,className:"flex-1 ios-btn-primary px-6 py-3 rounded-2xl font-bold flex items-center justify-center gap-2",children:[e.jsx(lt,{className:"w-4 h-4"}),"保存自动化规则"]})]})]})}),document.body),ge&&oe&&Oe.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:oe.id?"编辑回复规则":"新增回复规则"}),e.jsx("button",{onClick:()=>$(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(ke,{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-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.jsxs("select",{value:oe.item_id||"",onChange:i=>ne({...oe,item_id:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级回复"}),F.filter(i=>!n||i.cookie_id===n).map(i=>e.jsx("option",{value:i.item_id,children:i.item_title||i.item_id},`${i.cookie_id}-${i.item_id}`))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复类型"}),e.jsxs("select",{value:oe.type||"text",onChange:i=>{const I=i.target.value;ne({...oe,type:I,reply_content:I==="text"?oe.reply_content:"",image_url:I==="image"?oe.image_url:""})},className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"text",children:"文字"}),e.jsx("option",{value:"image",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:oe.keyword||"",onChange:i=>ne({...oe,keyword:i.target.value}),placeholder:"买家发送的关键词",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),oe.type==="image"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),e.jsx("input",{value:oe.image_url||"",onChange:i=>ne({...oe,image_url:i.target.value}),placeholder:"https://...",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:oe.reply_content||"",onChange:i=>ne({...oe,reply_content:i.target.value}),placeholder:"自动回复的内容",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none"})]}),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:Pe,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ss,{className:"w-4 h-4"}),"保存规则"]})]})]})]})}),document.body),L&&Oe.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:()=>Q(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",title:"关闭",children:e.jsx(ke,{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:de.cookie_id,onChange:i=>Se({...de,cookie_id:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"选择账号"}),z.map(i=>e.jsx("option",{value:i.id,children:Ht(i)},i.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:()=>Se({...de,enabled:!de.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${de.enabled?"bg-brand":"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 ${de.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:de.reply_content,onChange:i=>Se({...de,reply_content:i.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:de.reply_image_url,onChange:i=>Se({...de,reply_image_url:i.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:de.reply_once,onChange:i=>Se({...de,reply_once:i.target.checked}),className:"w-4 h-4 rounded"})]}),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: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(lt,{className:"w-4 h-4"}),"保存默认回复"]})]})]})]})}),document.body)]})},qs=["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from_name","smtp_from_address","smtp_use_tls","smtp_use_ssl"],As=(t,s)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(["true","1","yes","on"].includes(t.toLowerCase()))return!0;if(["false","0","no","off"].includes(t.toLowerCase()))return!1}return s},Ya=t=>{const s=Object.prototype.hasOwnProperty.call(t,"use_custom_smtp"),a=qs.some(l=>String(t[l]??"").trim()!=="");return{...t,use_custom_smtp:s?As(t.use_custom_smtp,!1):a}},Xa=(t,s)=>{const a={...t,use_custom_smtp:!0};for(const l of qs)String(a[l]??"").trim()===""&&s[l]!==void 0&&(a[l]=s[l]);return a.smtp_port||(a.smtp_port=587),a.smtp_from_address||(a.smtp_from_address=a.smtp_user||""),a.smtp_use_tls=As(a.smtp_use_tls,!0),a.smtp_use_ssl=As(a.smtp_use_ssl,!1),a},er=t=>{const s=Ya(t),a={to_email:String(s.to_email??"").trim(),use_custom_smtp:s.use_custom_smtp===!0};if(a.use_custom_smtp)for(const l of qs)a[l]=s[l];return a},Ct={bark:{label:"Bark",icon:Rt,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:"Ydisks闲鱼助手"},{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:$t,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:$t,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:$t,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:Lr,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:ss,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:Ta,fields:[{key:"to_email",label:"收件邮箱",placeholder:"receiver@example.com",required:!0}],guide:{steps:["通常先保存页面中的系统 SMTP 配置","邮件渠道只需填写收件邮箱,即可完整继承系统 SMTP","只有确实需要另一套发件服务时,才开启“使用独立 SMTP”并填写整套配置"],note:"继承和独立 SMTP 是互斥模式,不会再混用两套配置中的部分字段。"}}},tr=[{value:"account_offline",label:"掉线通知",description:"账号过期、断线或登录态失效"},{value:"account_recovered",label:"恢复通知",description:"自动恢复成功并重新在线"},{value:"account_disabled",label:"禁用通知",description:"连续失败、账密错误等导致账号停用"},{value:"security_verification",label:"风控验证",description:"滑块、人脸、扫码验证等安全校验"},{value:"delivery_result",label:"交易通知",description:"订单发货、卡密发送等交易结果"},{value:"token_renewal",label:"续期通知",description:"Cookie/token 续期和自动恢复过程"},{value:"system_error",label:"系统错误",description:"后台任务或系统级异常"}],fa=()=>({name:"",type:"bark",enabled:!0,config:{},event_types:[]}),Di=t=>!t||t.length===0?"全部事件":t.map(s=>{var a;return((a=tr.find(l=>l.value===s))==null?void 0:a.label)||s}).join("、"),$i=(t,s)=>{const a=t.type==="email"?Ya({...t.config||{}}):null,l=a?a.use_custom_smtp===!0?Xa(a,s):a:{...t.config||{}};return{name:t.name,type:t.type,enabled:t.enabled,config:l,event_types:t.event_types||[]}},Mi=t=>{const a=Ct[t.type].fields.find(l=>l.required&&!String(t.config[l.key]||"").trim());if(a)return`请填写 ${a.label}`;if(!t.name.trim())return"请填写渠道名称";if(t.type==="email"){const l=er(t.config);if(l.use_custom_smtp){const c=[["smtp_server","独立 SMTP 服务器"],["smtp_port","独立 SMTP 端口"],["smtp_user","独立 SMTP 登录邮箱"],["smtp_password","独立 SMTP 密码 / 授权码"],["smtp_from_address","独立 SMTP 发件地址"]].find(([u])=>!String(l[u]||"").trim());if(c)return`请填写 ${c[1]}`}}return""},qi=t=>({name:t.name.trim(),type:t.type,config:t.type==="email"?er(t.config):t.config,event_types:t.event_types,enabled:t.enabled}),Ie=(t,s)=>t===s,Dt=(t,s)=>t instanceof Error&&t.message?t.message:s,Bi=({channels:t,testingId:s,onEdit:a,onDelete:l,onToggleEnabled:n,onTest:c})=>{const u=_=>t.find(S=>S.id===_.currentTarget.dataset.channelId)||null,h=_=>{const S=u(_);S&&n(S)},m=_=>{const S=u(_);S&&c(S)},N=_=>{const S=u(_);S&&a(S)},x=_=>{const S=u(_);S&&l(S)},p=_=>{const S=Ct[_.type]||Ct.webhook,q=S.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(q,{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:_.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 text-gray-600 font-medium",children:S.label}),!_.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:S.fields.map(w=>{var P;return(P=_.config)==null?void 0:P[w.key]}).filter(Boolean).map((w,P)=>e.jsx("span",{className:"mr-3",children:String(w).length>40?`${String(w).slice(0,40)}…`:String(w)},P))}),e.jsxs("div",{className:"text-xs text-gray-400 mt-1 truncate",children:["订阅:",Di(_.event_types)]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("button",{"data-channel-id":_.id,onClick:h,className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-colors ${_.enabled?"bg-green-50 text-green-700 hover:bg-green-100":"bg-gray-100 text-gray-500 hover:bg-gray-200"}`,children:_.enabled?"启用中":"已停用"}),e.jsxs("button",{"data-channel-id":_.id,onClick:m,disabled:s===_.id,className:"px-3 py-1.5 rounded-lg text-xs font-bold bg-blue-50 text-brand hover:bg-blue-100 transition-colors flex items-center gap-1 disabled:opacity-50",children:[s===_.id?e.jsx(_e,{className:"w-3 h-3 animate-spin"}):e.jsx(ss,{className:"w-3 h-3"}),"测试"]}),e.jsx("button",{"data-channel-id":_.id,onClick:N,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(Ra,{className:"w-4 h-4"})}),e.jsx("button",{"data-channel-id":_.id,onClick:x,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(Ze,{className:"w-4 h-4"})})]})]},_.id)};return t.length===0?e.jsxs("div",{className:"ios-card rounded-xl p-12 bg-white text-center",children:[e.jsx(Rt,{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:t.map(p)})},Fi=({selectedEvents:t,onToggleEvent:s})=>{const a=l=>{const n=l.currentTarget.dataset.event;n&&s(n)};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"通知内容"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"不选择表示接收全部通知;选择后仅接收勾选类型。"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:tr.map(l=>{const n=t.includes(l.value);return e.jsxs("button",{type:"button","data-event":l.value,onClick:a,className:`text-left rounded-xl border px-3 py-2.5 transition-colors ${n?"border-brand bg-blue-50":"border-gray-100 hover:border-gray-300"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-4 h-4 rounded border flex items-center justify-center ${n?"bg-brand border-brand":"border-gray-300"}`,children:n&&e.jsx(Ye,{className:"w-3 h-3 text-white"})}),e.jsx("span",{className:`text-sm font-bold ${n?"text-brand":"text-gray-800"}`,children:l.label})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 pl-6 leading-5",children:l.description})]},l.value)})})]})},zi=({showModal:t,editing:s,form:a,setForm:l,smtp:n,showChannelSmtpPassword:c,setShowChannelSmtpPassword:u,saving:h,onClose:m,onSave:N})=>{const x=Ct[a.type],p=f=>l(y=>({...y,name:f.target.value})),_=f=>{const y=f.currentTarget.dataset.type;y&&l(z=>({...z,type:y,config:{}}))},S=f=>{const y=f.currentTarget.dataset.field;y&&l(z=>({...z,config:{...z.config,[y]:f.target.value}}))},q=()=>l(f=>({...f,config:f.config.use_custom_smtp===!0?{...f.config,use_custom_smtp:!1}:Xa(f.config,n)})),w=f=>l(y=>({...y,config:{...y.config,smtp_use_tls:f.target.checked,smtp_use_ssl:f.target.checked?!1:y.config.smtp_use_ssl}})),P=f=>l(y=>({...y,config:{...y.config,smtp_use_ssl:f.target.checked,smtp_use_tls:f.target.checked?!1:y.config.smtp_use_tls}})),A=f=>l(y=>({...y,event_types:y.event_types.includes(f)?y.event_types.filter(z=>z!==f):[...y.event_types,f]})),G=()=>l(f=>({...f,enabled:!f.enabled})),H=()=>u(f=>!f),X=(f,y)=>e.jsx("li",{children:f},y);return t?Oe.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:s?"编辑通知渠道":"新建通知渠道"}),e.jsx("button",{onClick:m,className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(ke,{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:a.name,onChange:p,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(Ct).map(f=>{const y=Ct[f],z=y.icon,O=a.type===f;return e.jsxs("button",{"data-type":f,type:"button",onClick:_,className:`p-3 rounded-xl border-2 flex flex-col items-center gap-1.5 transition-all ${O?"border-brand bg-blue-50":"border-gray-100 hover:border-gray-300"}`,children:[e.jsx(z,{className:`w-5 h-5 ${O?"text-brand":"text-gray-500"}`}),e.jsx("span",{className:`text-xs font-bold ${O?"text-brand":"text-gray-600"}`,children:y.label})]},f)})})]}),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(Rt,{className:"w-4 h-4 text-amber-600"}),e.jsxs("span",{className:"text-sm font-bold text-amber-800",children:["如何获取 ",x.label," 配置?"]})]}),e.jsx("ol",{className:"space-y-1.5 text-xs text-amber-900/90 leading-5 list-decimal pl-5",children:x.guide.steps.map(X)}),x.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:x.guide.urlFormat})]}),x.guide.note&&e.jsxs("p",{className:"text-xs text-amber-800/80 leading-5 pt-1",children:["💡 ",x.guide.note]})]}),e.jsx("div",{className:"space-y-3",children:x.fields.map(f=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:[f.label,f.required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),e.jsx("input",{"data-field":f.key,type:f.type==="password"?"password":f.type==="number"?"number":"text",value:String(a.config[f.key]||""),onChange:S,placeholder:f.placeholder,className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),f.help&&e.jsx("p",{className:"text-xs text-gray-500",children:f.help})]},f.key))}),a.type==="email"&&e.jsxs("div",{className:"overflow-hidden rounded-2xl border border-blue-100 bg-blue-50/40",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"SMTP 来源"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-gray-500",children:a.config.use_custom_smtp===!0?"当前渠道使用一套完整、独立的发件配置。":"当前渠道完整继承系统 SMTP,只单独设置收件邮箱。"})]}),e.jsx("button",{type:"button",onClick:q,className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${a.config.use_custom_smtp===!0?"bg-brand":"bg-gray-300"}`,"aria-label":"使用独立 SMTP",children:e.jsx("span",{className:`absolute left-1 top-1 h-5 w-5 rounded-full bg-white shadow-sm transition-transform ${a.config.use_custom_smtp===!0?"translate-x-5":""}`})})]}),a.config.use_custom_smtp===!0&&e.jsxs("div",{className:"space-y-4 border-t border-blue-100 bg-white/80 p-4",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["SMTP 服务器 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{"data-field":"smtp_server",type:"text",value:String(a.config.smtp_server||""),onChange:S,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.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["SMTP 端口 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{"data-field":"smtp_port",type:"number",value:String(a.config.smtp_port||587),onChange:S,placeholder:"587",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["登录邮箱 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{"data-field":"smtp_user",type:"email",value:String(a.config.smtp_user||""),onChange:S,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.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["密码 / 授权码 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{"data-field":"smtp_password",type:c?"text":"password",value:String(a.config.smtp_password||""),onChange:S,placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:H,className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",children:c?e.jsx(bt,{className:"w-4 h-4"}):e.jsx(mt,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",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",{"data-field":"smtp_from_name",type:"text",value:String(a.config.smtp_from_name||""),onChange:S,placeholder:"闲鱼自动回复系统",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["发件邮箱地址 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{"data-field":"smtp_from_address",type:"email",value:String(a.config.smtp_from_address||""),onChange:S,placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-3 text-xs font-bold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:a.config.smtp_use_tls!==!1,onChange:w}),"STARTTLS(常用于 587)"]}),e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-3 text-xs font-bold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:a.config.smtp_use_ssl===!0,onChange:P}),"SSL/TLS 直连(常用于 465)"]})]})]})]}),e.jsx(Fi,{selectedEvents:a.event_types,onToggleEvent:A}),e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx("button",{type:"button",onClick:G,className:`relative w-11 h-6 rounded-full transition-colors ${a.enabled?"bg-brand":"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 ${a.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,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:N,disabled:h,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[h?e.jsx(_e,{className:"w-4 h-4 animate-spin"}):e.jsx(Ye,{className:"w-4 h-4"}),h?"保存中...":"保存"]})]})]})}),document.body):null},Ui=({smtp:t,setSmtp:s,smtpSaving:a,showPassword:l,setShowPassword:n,onSave:c})=>{const u=_=>{const S=_.currentTarget.dataset.field;S&&s(q=>({...q,[S]:_.target.value}))},h=_=>{s(S=>({...S,smtp_port:parseInt(_.target.value,10)||587}))},m=_=>{s(S=>({...S,smtp_use_tls:_.target.checked,smtp_use_ssl:_.target.checked?!1:S.smtp_use_ssl}))},N=_=>{s(S=>({...S,smtp_use_ssl:_.target.checked,smtp_use_tls:_.target.checked?!1:S.smtp_use_tls}))},x=_=>{s(S=>({...S,smtp_password:_.target.value}))},p=()=>n(_=>!_);return 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(Ta,{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",{"data-field":"smtp_server",type:"text",value:t.smtp_server||"",onChange:u,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:t.smtp_port||587,onChange:h,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",{"data-field":"smtp_user",type:"email",value:t.smtp_user||"",onChange:u,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:l?"text":"password",value:t.smtp_password||"",onChange:x,placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:p,className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:l?e.jsx(bt,{className:"w-4 h-4"}):e.jsx(mt,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"QQ 邮箱需使用授权码(QQ 邮箱设置 → 账号 → 开启 SMTP → 生成授权码)"})]}),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.jsx("input",{"data-field":"smtp_from_name",type:"text",value:t.smtp_from_name||"",onChange:u,placeholder:"闲鱼自动回复系统",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",{"data-field":"smtp_from_address",type:"email",value:t.smtp_from_address||t.smtp_user||"",onChange:u,placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-4 text-sm font-semibold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:t.smtp_use_tls!==!1,onChange:m}),"STARTTLS(常用于 587 端口)"]}),e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-4 text-sm font-semibold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:t.smtp_use_ssl===!0,onChange:N}),"SSL/TLS 直连(常用于 465 端口)"]})]}),e.jsxs("button",{onClick:c,disabled:a,className:"ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[a?e.jsx(_e,{className:"w-4 h-4 animate-spin"}):e.jsx(lt,{className:"w-4 h-4"}),a?"保存中...":"保存 SMTP 配置"]})]})},Wi=t=>{const[s,a]=r.useState([]),[l,n]=r.useState(!0),[c,u]=r.useState(!1),[h,m]=r.useState(null),[N,x]=r.useState(!1),[p,_]=r.useState(""),[S,q]=r.useState(null),[w,P]=r.useState({}),[A,G]=r.useState(!1),[H,X]=r.useState(!1),[f,y]=r.useState(!1),[z,O]=r.useState(fa),F=r.useRef(0),d=r.useRef(null),B=r.useRef(0),Z=r.useRef(null),M=r.useRef(0),b=r.useRef(null),k=r.useRef(null),D=r.useCallback((L,Q)=>{q({type:L,text:Q}),k.current!==null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>{k.current=null,q(null)},3e3)},[]),C=r.useCallback(async()=>{var Y;const L=++F.current;(Y=d.current)==null||Y.abort();const Q=new AbortController;d.current=Q,n(!0);try{const re=await Va({signal:Q.signal});if(!Ie(L,F.current))return;a(re.data||[])}catch(re){Ie(L,F.current)&&!Q.signal.aborted&&console.error("加载通知渠道失败",re)}finally{Ie(L,F.current)&&n(!1)}},[]),W=r.useCallback(async()=>{var Y;const L=++B.current;(Y=Z.current)==null||Y.abort();const Q=new AbortController;Z.current=Q;try{const re=await Wa({signal:Q.signal});Ie(L,B.current)&&P(re||{})}catch(re){Ie(L,B.current)&&!Q.signal.aborted&&console.error("加载 SMTP 配置失败",re)}},[]);r.useEffect(()=>{var L;return C(),t?W():(B.current+=1,(L=Z.current)==null||L.abort(),P({})),(()=>{var Q,Y;F.current+=1,(Q=d.current)==null||Q.abort(),B.current+=1,(Y=Z.current)==null||Y.abort()})},[t,C,W]),r.useEffect(()=>(()=>{k.current!==null&&window.clearTimeout(k.current)}),[]);const V=r.useCallback(()=>{m(null),O(fa()),y(!1),u(!0)},[]),v=r.useCallback(L=>{m(L),O($i(L,w)),y(!1),u(!0)},[w]),ee=r.useCallback(()=>{var L;M.current+=1,(L=b.current)==null||L.abort(),x(!1),u(!1)},[]),be=r.useCallback(async()=>{var re;const L=Mi(z);if(L){D("error",L);return}const Q=++M.current;(re=b.current)==null||re.abort();const Y=new AbortController;b.current=Y,x(!0);try{const ue=qi(z);if(h?await aa(h.id,ue,{signal:Y.signal}):await sn(ue,{signal:Y.signal}),!Ie(Q,M.current)||(u(!1),await C(),!Ie(Q,M.current)))return;D("success",h?"已更新":"已创建")}catch(ue){Ie(Q,M.current)&&!Y.signal.aborted&&D("error",Dt(ue,"保存失败"))}finally{Ie(Q,M.current)&&x(!1)}},[h,z,C,D]),U=r.useCallback(async L=>{var re;if(!confirm(`确认删除渠道「${L.name}」吗?已绑定该渠道的账号会自动解绑。`))return;const Q=++M.current;(re=b.current)==null||re.abort();const Y=new AbortController;b.current=Y;try{if(await an(L.id,{signal:Y.signal}),!Ie(Q,M.current)||(await C(),!Ie(Q,M.current)))return;D("success","已删除")}catch(ue){Ie(Q,M.current)&&!Y.signal.aborted&&D("error",Dt(ue,"删除失败"))}},[C,D]),ae=r.useCallback(async L=>{var re;const Q=++M.current;(re=b.current)==null||re.abort();const Y=new AbortController;b.current=Y;try{if(await aa(L.id,{enabled:!L.enabled},{signal:Y.signal}),!Ie(Q,M.current))return;a(ue=>ue.map(Ne=>Ne.id===L.id?{...Ne,enabled:!Ne.enabled}:Ne))}catch(ue){Ie(Q,M.current)&&!Y.signal.aborted&&D("error",Dt(ue,"切换失败"))}},[D]),ge=r.useCallback(async L=>{var re;_(L.id);const Q=++M.current;(re=b.current)==null||re.abort();const Y=new AbortController;b.current=Y;try{await ln(L.id,{signal:Y.signal}),Ie(Q,M.current)&&D("success","测试通知已发送,请检查对应渠道")}catch(ue){Ie(Q,M.current)&&!Y.signal.aborted&&D("error",Dt(ue,"发送失败"))}finally{Ie(Q,M.current)&&_("")}},[D]),$=r.useCallback(async()=>{var Y;const L=++B.current;(Y=Z.current)==null||Y.abort();const Q=new AbortController;Z.current=Q,G(!0);try{await Ja({smtp_server:w.smtp_server||"",smtp_port:w.smtp_port||587,smtp_user:w.smtp_user||"",smtp_password:w.smtp_password||"",smtp_from_name:w.smtp_from_name||"",smtp_from_address:w.smtp_from_address||w.smtp_user||"",smtp_use_tls:w.smtp_use_tls!==!1,smtp_use_ssl:w.smtp_use_ssl===!0},{signal:Q.signal}),Ie(L,B.current)&&D("success","SMTP 配置已保存")}catch(re){Ie(L,B.current)&&!Q.signal.aborted&&D("error",Dt(re,"保存失败"))}finally{Ie(L,B.current)&&G(!1)}},[D,w]);return{channels:s,loading:l,showModal:c,editing:h,saving:N,testingId:p,toast:S,smtp:w,smtpSaving:A,showSmtpPassword:H,showChannelSmtpPassword:f,form:z,setForm:O,setSmtp:P,setShowSmtpPassword:X,setShowChannelSmtpPassword:y,loadChannels:C,openCreate:V,openEdit:v,closeModal:ee,showToast:D,handleSave:be,handleDelete:U,handleToggleEnabled:ae,handleTest:ge,handleSaveSmtp:$}},Ji=({isAdmin:t=!1})=>{const s=Wi(t);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:s.loadChannels,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(We,{className:"w-4 h-4"}),"刷新"]}),e.jsxs("button",{onClick:s.openCreate,className:"ios-btn-primary px-5 py-2.5 rounded-xl font-bold flex items-center gap-2",children:[e.jsx(nt,{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(Rt,{className:"w-5 h-5 text-brand 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:"触发风控验证"}),":可能需要扫码完成验证(警告)"]})]})]})]})}),s.loading?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx(_e,{className:"w-8 h-8 text-brand animate-spin"})}):e.jsx(Bi,{channels:s.channels,testingId:s.testingId,onEdit:s.openEdit,onDelete:s.handleDelete,onToggleEnabled:s.handleToggleEnabled,onTest:s.handleTest}),t&&e.jsx(Ui,{smtp:s.smtp,setSmtp:s.setSmtp,smtpSaving:s.smtpSaving,showPassword:s.showSmtpPassword,setShowPassword:s.setShowSmtpPassword,onSave:s.handleSaveSmtp}),e.jsx(zi,{showModal:s.showModal,editing:s.editing,form:s.form,setForm:s.setForm,smtp:s.smtp,showChannelSmtpPassword:s.showChannelSmtpPassword,setShowChannelSmtpPassword:s.setShowChannelSmtpPassword,saving:s.saving,onClose:s.closeModal,onSave:s.handleSave}),s.toast&&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 text-white ${s.toast.type==="success"?"bg-success-500":"bg-danger-500"}`,children:[s.toast.type==="success"?e.jsx(Ye,{className:"w-4 h-4"}):e.jsx(ke,{className:"w-4 h-4"}),s.toast.text]})]})},sr=[["尊嘟假嘟","https://img.alicdn.com/imgextra/i2/O1CN01hWzOgD1KcmFEIaGwE_!!6000000001185-2-tps-64-64.png_110x10000.jpg_.webp"],["鸡哔你","https://img.alicdn.com/imgextra/i1/O1CN01P9TVJl1JCqCZcQIdW_!!6000000000993-2-tps-64-64.png_110x10000.jpg_.webp"],["谁懂啊","https://img.alicdn.com/imgextra/i1/O1CN01r9qUnx1g3tcrtSmcs_!!6000000004087-2-tps-64-64.png_110x10000.jpg_.webp"],["吗喽","https://img.alicdn.com/imgextra/i4/O1CN01dTynZh1LnbIYTHI1D_!!6000000001344-2-tps-64-64.png_110x10000.jpg_.webp"],["功德+1","https://img.alicdn.com/imgextra/i1/O1CN01l1G5pS1IVn37pfQJi_!!6000000000899-2-tps-64-64.png_110x10000.jpg_.webp"],["city不city啊","https://img.alicdn.com/imgextra/i2/O1CN01zRjPTR29lWHqabmDA_!!6000000008108-2-tps-64-64.png_110x10000.jpg_.webp"],["激推","https://img.alicdn.com/imgextra/i3/O1CN01ADTJ6u1khypfxbfnQ_!!6000000004716-2-tps-64-64.png_110x10000.jpg_.webp"],["微笑","https://img.alicdn.com/imgextra/i1/O1CN017b61R51wRk2lVV7vx_!!6000000006305-2-tps-980-980.png_110x10000.jpg_.webp"],["龇牙","https://img.alicdn.com/imgextra/i2/O1CN01nmOh4S22Yxz8IdEVf_!!6000000007133-2-tps-980-980.png_110x10000.jpg_.webp"],["流泪","https://img.alicdn.com/imgextra/i2/O1CN01Ec1EaL1zqQETcM2dX_!!6000000006765-2-tps-980-980.png_110x10000.jpg_.webp"],["尴尬","https://img.alicdn.com/imgextra/i2/O1CN01UrWH7a1ZVBrgRYXlc_!!6000000003199-2-tps-980-980.png_110x10000.jpg_.webp"],["撇嘴","https://img.alicdn.com/imgextra/i2/O1CN01Sr7o2b1lUWg5KfOD8_!!6000000004822-2-tps-980-980.png_110x10000.jpg_.webp"],["破涕为笑","https://img.alicdn.com/imgextra/i4/O1CN01pPetah1gkwndfn7Fs_!!6000000004181-2-tps-980-980.png_110x10000.jpg_.webp"],["捂脸哭","https://img.alicdn.com/imgextra/i2/O1CN0170KgpE1dE1TuQgd66_!!6000000003703-2-tps-980-980.png_110x10000.jpg_.webp"],["害羞","https://img.alicdn.com/imgextra/i3/O1CN01ZoB0Lb1ps7XpqP8PQ_!!6000000005415-2-tps-980-980.png_110x10000.jpg_.webp"],["感动","https://img.alicdn.com/imgextra/i2/O1CN01wqD4ly29yndR3Qp3A_!!6000000008137-2-tps-980-980.png_110x10000.jpg_.webp"],["滴泪","https://img.alicdn.com/imgextra/i1/O1CN01MpkJ3L1oUTTqfryOn_!!6000000005228-2-tps-980-980.png_110x10000.jpg_.webp"],["暗中观察","https://img.alicdn.com/imgextra/i1/O1CN010LO9yj272W07GlLls_!!6000000007739-2-tps-980-980.png_110x10000.jpg_.webp"],["偷笑","https://img.alicdn.com/imgextra/i4/O1CN01vJtO031g818IuYO7x_!!6000000004096-2-tps-980-980.png_110x10000.jpg_.webp"],["ok","https://img.alicdn.com/imgextra/i3/O1CN01QRkqDF25tz0WcANje_!!6000000007585-2-tps-980-980.png_110x10000.jpg_.webp"],["送花","https://img.alicdn.com/imgextra/i2/O1CN01PpzBNX1JNpeJBWnvr_!!6000000001017-2-tps-980-980.png_110x10000.jpg_.webp"],["大哭","https://img.alicdn.com/imgextra/i4/O1CN014TiaNb1ViEgNvRrTB_!!6000000002686-2-tps-980-980.png_110x10000.jpg_.webp"],["色","https://img.alicdn.com/imgextra/i2/O1CN01840t1B1JaCLGvHnBK_!!6000000001044-2-tps-980-980.png_110x10000.jpg_.webp"],["惊慌","https://img.alicdn.com/imgextra/i1/O1CN01mnqO7G1LAfUnfAN2U_!!6000000001259-2-tps-980-980.png_110x10000.jpg_.webp"],["惊讶","https://img.alicdn.com/imgextra/i3/O1CN0127IeyS1Kw0p0P4jzI_!!6000000001227-2-tps-980-980.png_110x10000.jpg_.webp"],["得意","https://img.alicdn.com/imgextra/i4/O1CN018QUnFv1WpOUES9POZ_!!6000000002837-2-tps-980-980.png_110x10000.jpg_.webp"],["睡","https://img.alicdn.com/imgextra/i2/O1CN01RprGZl1lqVgnEJLCx_!!6000000004870-2-tps-980-980.png_110x10000.jpg_.webp"],["不好意思","https://img.alicdn.com/imgextra/i3/O1CN01rMJJgn1SUXzuVpUhO_!!6000000002250-2-tps-980-980.png_110x10000.jpg_.webp"],["托腮","https://img.alicdn.com/imgextra/i1/O1CN01w3reBU1d3wlgOBtyZ_!!6000000003681-2-tps-980-980.png_110x10000.jpg_.webp"],["发怒","https://img.alicdn.com/imgextra/i2/O1CN013Wzy8d2A8PxGJZPpT_!!6000000008158-2-tps-980-980.png_110x10000.jpg_.webp"],["难过","https://img.alicdn.com/imgextra/i2/O1CN01zcwaSh1G9gZCFuFal_!!6000000000580-2-tps-980-980.png_110x10000.jpg_.webp"],["调皮","https://img.alicdn.com/imgextra/i3/O1CN01Zd1YHi1TI0lwpBe8c_!!6000000002358-2-tps-980-980.png_110x10000.jpg_.webp"],["愉快","https://img.alicdn.com/imgextra/i2/O1CN0145wDk21SWpyjTvsvA_!!6000000002255-2-tps-980-980.png_110x10000.jpg_.webp"],["白眼","https://img.alicdn.com/imgextra/i4/O1CN01nexGth1hwEAT1SHO2_!!6000000004341-2-tps-980-980.png_110x10000.jpg_.webp"],["拒绝","https://img.alicdn.com/imgextra/i2/O1CN01nqusqS1uHXzoUcpXr_!!6000000006012-2-tps-980-980.png_110x10000.jpg_.webp"],["期待","https://img.alicdn.com/imgextra/i3/O1CN01M44QY11Oh8Q5PdMIx_!!6000000001736-2-tps-980-980.png_110x10000.jpg_.webp"],["困","https://img.alicdn.com/imgextra/i4/O1CN01J4hFFz1Y9pmNdBq76_!!6000000003017-2-tps-980-980.png_110x10000.jpg_.webp"],["流汗","https://img.alicdn.com/imgextra/i4/O1CN01BU3NZ21gdcSjkqnST_!!6000000004165-2-tps-980-980.png_110x10000.jpg_.webp"],["憨笑","https://img.alicdn.com/imgextra/i2/O1CN01Pee9Ql1SJ661eH9By_!!6000000002225-2-tps-980-980.png_110x10000.jpg_.webp"],["耶","https://img.alicdn.com/imgextra/i2/O1CN01pFicsL1ipBhIqzcgs_!!6000000004461-2-tps-980-980.png_110x10000.jpg_.webp"],["奋斗","https://img.alicdn.com/imgextra/i3/O1CN01ZhQ4AV25xBmTK3CnF_!!6000000007592-2-tps-980-980.png_110x10000.jpg_.webp"],["咒骂","https://img.alicdn.com/imgextra/i3/O1CN01r1Zh9927QKb4pnf7k_!!6000000007791-2-tps-980-980.png_110x10000.jpg_.webp"],["疑问","https://img.alicdn.com/imgextra/i4/O1CN01UZqbzt29MmlNctCQS_!!6000000008054-2-tps-980-980.png_110x10000.jpg_.webp"],["嘘","https://img.alicdn.com/imgextra/i1/O1CN01qBlYkM1ojaYF75On5_!!6000000005261-2-tps-980-980.png_110x10000.jpg_.webp"],["晕","https://img.alicdn.com/imgextra/i2/O1CN014zhM2h1wPuSUFoMwV_!!6000000006301-2-tps-980-980.png_110x10000.jpg_.webp"],["开心到模糊","https://img.alicdn.com/imgextra/i1/O1CN01T1Dy271j6akZWo7Vr_!!6000000004499-2-tps-980-980.png_110x10000.jpg_.webp"],["衰","https://img.alicdn.com/imgextra/i1/O1CN01aOXsNr1LmgMvtyzOO_!!6000000001342-2-tps-980-980.png_110x10000.jpg_.webp"],["委屈","https://img.alicdn.com/imgextra/i2/O1CN013J0bMk1QNYih3UFTk_!!6000000001964-2-tps-980-980.png_110x10000.jpg_.webp"],["再见","https://img.alicdn.com/imgextra/i2/O1CN01IHKsQx1UdpFgeTHcA_!!6000000002541-2-tps-980-980.png_110x10000.jpg_.webp"],["鼓掌","https://img.alicdn.com/imgextra/i4/O1CN01DHxB5s1G1RRBxekIu_!!6000000000562-2-tps-980-980.png_110x10000.jpg_.webp"],["吐","https://img.alicdn.com/imgextra/i1/O1CN01xyVxH21LNUaMgW4hh_!!6000000001287-2-tps-980-980.png_110x10000.jpg_.webp"],["坏笑","https://img.alicdn.com/imgextra/i1/O1CN01zV7opv1bIU6iI8OhM_!!6000000003442-2-tps-980-980.png_110x10000.jpg_.webp"],["抠鼻","https://img.alicdn.com/imgextra/i1/O1CN01QOanju1sNqCrtYstu_!!6000000005755-2-tps-980-980.png_110x10000.jpg_.webp"],["叹气","https://img.alicdn.com/imgextra/i3/O1CN01RElx7R1QD1c8ZN07f_!!6000000001941-2-tps-980-980.png_110x10000.jpg_.webp"],["无聊","https://img.alicdn.com/imgextra/i2/O1CN01d91LnZ1UJDQjKCouC_!!6000000002496-2-tps-980-980.png_110x10000.jpg_.webp"],["思考","https://img.alicdn.com/imgextra/i2/O1CN01wQjg2f1tO84ZWitn9_!!6000000005891-2-tps-980-980.png_110x10000.jpg_.webp"],["呆","https://img.alicdn.com/imgextra/i1/O1CN01GLqBWC1DGbhqmpD2L_!!6000000000189-2-tps-980-980.png_110x10000.jpg_.webp"],["哇哦","https://img.alicdn.com/imgextra/i2/O1CN01MtLpS21qRO2bnAA5k_!!6000000005492-2-tps-980-980.png_110x10000.jpg_.webp"],["飞吻","https://img.alicdn.com/imgextra/i4/O1CN01q1WpFE25ljsNKjvHX_!!6000000007567-2-tps-980-980.png_110x10000.jpg_.webp"],["好喜欢","https://img.alicdn.com/imgextra/i2/O1CN01mD4iQM1O57XyQ5SHD_!!6000000001653-2-tps-980-980.png_110x10000.jpg_.webp"],["拜托","https://img.alicdn.com/imgextra/i4/O1CN01SQgrTH1dzCH3pIyRN_!!6000000003806-2-tps-980-980.png_110x10000.jpg_.webp"],["真棒","https://img.alicdn.com/imgextra/i2/O1CN017fcAmd1SCgYCj9Upk_!!6000000002211-2-tps-980-980.png_110x10000.jpg_.webp"],["流鼻血","https://img.alicdn.com/imgextra/i3/O1CN0139JscY1rC6RS9GR4j_!!6000000005594-2-tps-980-980.png_110x10000.jpg_.webp"],["费解","https://img.alicdn.com/imgextra/i1/O1CN01FqAVvR1tyJMPj13ie_!!6000000005970-2-tps-980-980.png_110x10000.jpg_.webp"],["秃头","https://img.alicdn.com/imgextra/i4/O1CN01ZF4bV11thMhqm2Z1h_!!6000000005933-2-tps-980-980.png_110x10000.jpg_.webp"],["嘿哈","https://img.alicdn.com/imgextra/i4/O1CN01ObcOw61FOVlvQg7Mw_!!6000000000477-2-tps-980-980.png_110x10000.jpg_.webp"],["吃土","https://img.alicdn.com/imgextra/i3/O1CN01Z6nJ1b1ZYr22YseHN_!!6000000003207-2-tps-980-980.png_110x10000.jpg_.webp"],["机智","https://img.alicdn.com/imgextra/i1/O1CN01rfKY351zDUZJlBiir_!!6000000006680-2-tps-980-980.png_110x10000.jpg_.webp"],["举杯","https://img.alicdn.com/imgextra/i4/O1CN01R2tn4F1mn8NuEIE8J_!!6000000004998-2-tps-980-980.png_110x10000.jpg_.webp"],["握手","https://img.alicdn.com/imgextra/i4/O1CN01NDcA251JDkvuFhSDb_!!6000000000995-2-tps-980-980.png_110x10000.jpg_.webp"],["挥手","https://img.alicdn.com/imgextra/i4/O1CN01iVN0ht1TmEuSwauGt_!!6000000002424-2-tps-980-980.png_110x10000.jpg_.webp"],["yeah","https://img.alicdn.com/imgextra/i3/O1CN01opt7hh27Wk8omjR4t_!!6000000007805-2-tps-980-980.png_110x10000.jpg_.webp"],["666","https://img.alicdn.com/imgextra/i3/O1CN01YRWDPF1OjQOpXeuTC_!!6000000001741-2-tps-980-980.png_110x10000.jpg_.webp"],["棒","https://img.alicdn.com/imgextra/i3/O1CN01agprvs1HU7rPRxOnB_!!6000000000760-2-tps-980-980.png_110x10000.jpg_.webp"],["爱你","https://img.alicdn.com/imgextra/i1/O1CN01SzxgcH1GSSo6Lwmwk_!!6000000000621-2-tps-980-980.png_110x10000.jpg_.webp"],["比心","https://img.alicdn.com/imgextra/i1/O1CN01YHZ39t1DeQIeb0TWQ_!!6000000000241-2-tps-980-980.png_110x10000.jpg_.webp"],["感谢","https://img.alicdn.com/imgextra/i3/O1CN01ywacF81baLYNeyK1n_!!6000000003481-2-tps-980-980.png_110x10000.jpg_.webp"],["拍手","https://img.alicdn.com/imgextra/i4/O1CN01wbj4wv1K7ArD9AU44_!!6000000001116-2-tps-980-980.png_110x10000.jpg_.webp"],["拉钩","https://img.alicdn.com/imgextra/i1/O1CN01dePkKH1HOd6ivAcu8_!!6000000000748-2-tps-980-980.png_110x10000.jpg_.webp"],["没钱","https://img.alicdn.com/imgextra/i3/O1CN01qhxGjp1zD2AfqmWx5_!!6000000006679-2-tps-980-980.png_110x10000.jpg_.webp"],["小刀","https://img.alicdn.com/imgextra/i3/O1CN01tFVx5Y1T2thPjhR6b_!!6000000002325-2-tps-980-980.png_110x10000.jpg_.webp"],["不刀","https://img.alicdn.com/imgextra/i4/O1CN01zTxff61clcvOcTS3n_!!6000000003641-2-tps-980-980.png_110x10000.jpg_.webp"],["同出","https://img.alicdn.com/imgextra/i3/O1CN01URKas6249R8ozS98O_!!6000000007348-2-tps-980-980.png_110x10000.jpg_.webp"],["递钱","https://img.alicdn.com/imgextra/i4/O1CN01PzhgV51FLlOaZHZ6n_!!6000000000471-2-tps-980-980.png_110x10000.jpg_.webp"],["数钱","https://img.alicdn.com/imgextra/i3/O1CN01CzXXvp23khkljToQH_!!6000000007294-2-tps-980-980.png_110x10000.jpg_.webp"],["打call","https://img.alicdn.com/imgextra/i1/O1CN01X7VUVm1il48IYv8Qw_!!6000000004452-2-tps-980-980.png_110x10000.jpg_.webp"],["号外","https://img.alicdn.com/imgextra/i2/O1CN01vg6xSM1Vxo9EKyfjR_!!6000000002720-2-tps-980-980.png_110x10000.jpg_.webp"],["包邮","https://img.alicdn.com/imgextra/i3/O1CN01yVS7ys24jA22oVZ2T_!!6000000007426-2-tps-980-980.png_110x10000.jpg_.webp"],["求赞","https://img.alicdn.com/imgextra/i1/O1CN01Xwqi5A1giCQMRcX6N_!!6000000004175-2-tps-980-980.png_110x10000.jpg_.webp"],["非主流","https://img.alicdn.com/imgextra/i1/O1CN013wyI1j1hlEfDUoATI_!!6000000004317-2-tps-980-980.png_110x10000.jpg_.webp"],["吃瓜","https://img.alicdn.com/imgextra/i1/O1CN01LLOFsh1UUCw0deZba_!!6000000002520-2-tps-980-980.png_110x10000.jpg_.webp"],["种草","https://img.alicdn.com/imgextra/i2/O1CN01ooeRC81hA8a4x9S3q_!!6000000004236-2-tps-980-980.png_110x10000.jpg_.webp"],["佛系","https://img.alicdn.com/imgextra/i4/O1CN01BYXEe321GMHMZ9w66_!!6000000006957-2-tps-980-980.png_110x10000.jpg_.webp"],["超便宜","https://img.alicdn.com/imgextra/i4/O1CN01mqgSZi1Er4rOIDiP7_!!6000000000404-2-tps-980-980.png_110x10000.jpg_.webp"],["拥抱","https://img.alicdn.com/imgextra/i1/O1CN01yuGD9c1hJkttfKHAm_!!6000000004257-2-tps-980-980.png_110x10000.jpg_.webp"],["摊手","https://img.alicdn.com/imgextra/i2/O1CN014AiIqE1o9repE6STR_!!6000000005183-2-tps-980-980.png_110x10000.jpg_.webp"],["举手","https://img.alicdn.com/imgextra/i1/O1CN01xizuHZ1WPkJCogbuj_!!6000000002781-2-tps-980-980.png_110x10000.jpg_.webp"],["蹲","https://img.alicdn.com/imgextra/i3/O1CN01Midjjn1FrMj2CWer6_!!6000000000540-2-tps-980-980.png_110x10000.jpg_.webp"],["跪了","https://img.alicdn.com/imgextra/i3/O1CN01F2y52j24E16L6RIjF_!!6000000007358-2-tps-980-980.png_110x10000.jpg_.webp"],["拜","https://img.alicdn.com/imgextra/i4/O1CN01Jldd1G1oXDrEHH2qr_!!6000000005234-2-tps-980-980.png_110x10000.jpg_.webp"],["排","https://img.alicdn.com/imgextra/i3/O1CN01uSUmYD1jD0IJf0UVU_!!6000000004513-2-tps-980-980.png_110x10000.jpg_.webp"],["旺财","https://img.alicdn.com/imgextra/i3/O1CN01A25Mv01DKjGseAmuP_!!6000000000198-2-tps-980-980.png_110x10000.jpg_.webp"],["招财猫","https://img.alicdn.com/imgextra/i3/O1CN01WmJ7Sr20EhDyp86Bd_!!6000000006818-2-tps-980-980.png_110x10000.jpg_.webp"],["酸了","https://img.alicdn.com/imgextra/i3/O1CN01UFgjn61JJi5Iqxdk7_!!6000000001008-2-tps-980-980.png_110x10000.jpg_.webp"],["鸭鸭","https://img.alicdn.com/imgextra/i3/O1CN01pHSCSQ1deaS8WDiqG_!!6000000003761-2-tps-980-980.png_110x10000.jpg_.webp"],["方了","https://img.alicdn.com/imgextra/i3/O1CN01br7g711whlu8xOPUt_!!6000000006340-2-tps-980-980.png_110x10000.jpg_.webp"],["白菜","https://img.alicdn.com/imgextra/i1/O1CN01KABFLt24WKwXjVp08_!!6000000007398-2-tps-980-980.png_110x10000.jpg_.webp"],["桃子","https://img.alicdn.com/imgextra/i1/O1CN01CQhhPH1vJfRjDGBv5_!!6000000006152-2-tps-980-980.png_110x10000.jpg_.webp"],["打包","https://img.alicdn.com/imgextra/i3/O1CN01oYOkUI1VT7c0ivZHV_!!6000000002653-2-tps-980-980.png_110x10000.jpg_.webp"],["沙发","https://img.alicdn.com/imgextra/i4/O1CN018qUFaE1DGbhqpMIit_!!6000000000189-2-tps-980-980.png_110x10000.jpg_.webp"],["南","https://img.alicdn.com/imgextra/i1/O1CN01ZSA6wg1PEZKf4h99R_!!6000000001809-2-tps-980-980.png_110x10000.jpg_.webp"],["盯","https://img.alicdn.com/imgextra/i4/O1CN01OWB1Gx1s01bzBhHN6_!!6000000005703-2-tps-980-980.png_110x10000.jpg_.webp"],["hot","https://img.alicdn.com/imgextra/i4/O1CN01DDD9uA22cAl7VDH7d_!!6000000007140-2-tps-980-980.png_110x10000.jpg_.webp"],["new","https://img.alicdn.com/imgextra/i3/O1CN01rRJXJo1qwzN4YnOHX_!!6000000005561-2-tps-980-980.png_110x10000.jpg_.webp"],["cool","https://img.alicdn.com/imgextra/i4/O1CN013bUubF2855qb2Qt5l_!!6000000007880-2-tps-980-980.png_110x10000.jpg_.webp"],["1","https://img.alicdn.com/imgextra/i1/O1CN01U8XG5y1Ie22frQHCQ_!!6000000000917-2-tps-980-980.png_110x10000.jpg_.webp"],["可","https://img.alicdn.com/imgextra/i2/O1CN01SMjtPG1iJaN17p94N_!!6000000004392-2-tps-980-980.png_110x10000.jpg_.webp"],["搬砖","https://img.alicdn.com/imgextra/i1/O1CN01GbqW6G1LOrm0Gllcb_!!6000000001290-2-tps-980-980.png_110x10000.jpg_.webp"],["菜狗","https://img.alicdn.com/imgextra/i2/O1CN01VtN0t91USNLmvfmol_!!6000000002516-2-tps-980-980.png_110x10000.jpg_.webp"],["开心面具","https://img.alicdn.com/imgextra/i3/O1CN017elkpk22EoYlBPKd3_!!6000000007089-2-tps-980-980.png_110x10000.jpg_.webp"],["快递","https://img.alicdn.com/imgextra/i2/O1CN01AmUZXk1d3wle5O8IJ_!!6000000003681-2-tps-980-980.png_110x10000.jpg_.webp"],["裂开","https://img.alicdn.com/imgextra/i1/O1CN01BihwvO1a5N9bFt0LU_!!6000000003278-2-tps-980-980.png_110x10000.jpg_.webp"],["啤酒","https://img.alicdn.com/imgextra/i4/O1CN01jDkgEj1WvLdXUVBDx_!!6000000002850-2-tps-980-980.png_110x10000.jpg_.webp"],["瑞思拜","https://img.alicdn.com/imgextra/i4/O1CN011gR0Um1K3VgpYjPOi_!!6000000001108-2-tps-980-980.png_110x10000.jpg_.webp"],["小丑","https://img.alicdn.com/imgextra/i3/O1CN01jMikhO1NJUM15XKTf_!!6000000001549-2-tps-980-980.png_110x10000.jpg_.webp"],["爱心","https://img.alicdn.com/imgextra/i1/O1CN015RVSWf23s25eETJqO_!!6000000007310-2-tps-980-980.png_110x10000.jpg_.webp"]],Gi=t=>t,Vi=new Map(sr.map(([t,s])=>[t,s])),Qi=t=>t.split(/(\[[^\]]+\])/g).map((s,a)=>{const l=s.startsWith("[")?Vi.get(s.slice(1,-1)):void 0;return l?e.jsx("img",{src:l,alt:s,title:s,className:"mx-0.5 inline-block h-7 w-7 align-middle"},a):e.jsx(Is.Fragment,{children:s},a)}),Ki=(t,s,a)=>{const l=s.trim().toLowerCase();return t.filter(n=>a&&n.unread_count<=0?!1:l?[n.buyer_name,n.buyer_id,n.item_title,n.last_message].some(c=>(c||"").toLowerCase().includes(l)):!0)},Hi=(t,s)=>{const a=new Set(t.map(l=>l.message_key));return[...s.filter(l=>!a.has(l.message_key)),...t]},fs=(t,s)=>{const a=t.findIndex(l=>l.message_key===s.message_key);return a<0?[...t,s]:t.map((l,n)=>n===a?s:l)},Fe=(t,s,a)=>t===s&&!a.aborted,_t=t=>t instanceof Error&&t.message==="请求已取消",Zi=t=>{if(!t)return"";const s=new Date(t<1e10?t*1e3:t),a=new Date;return s.toDateString()===a.toDateString()?s.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hour12:!1}):s.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit"})},Yi=t=>new Date(t<1e10?t*1e3:t).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}),Xi=()=>{const[t,s]=r.useState([]),[a,l]=r.useState(""),[n,c]=r.useState({}),[u,h]=r.useState(""),[m,N]=r.useState([]),[x,p]=r.useState(""),[_,S]=r.useState(!1),[q,w]=r.useState(""),[P,A]=r.useState(!0),[G,H]=r.useState(!1),[X,f]=r.useState(!1),[y,z]=r.useState(!1),[O,F]=r.useState(),[d,B]=r.useState({}),[Z,M]=r.useState({}),[b,k]=r.useState(!1),[D,C]=r.useState(!1),[W,V]=r.useState(!1),[v,ee]=r.useState(""),[be,U]=r.useState("connecting"),[ae,ge]=r.useState(null),[$,L]=r.useState(null),Q=r.useRef(""),Y=r.useRef(""),re=r.useRef(null),ue=r.useRef({accountID:"",chatID:""}),Ne=r.useRef(!0),R=r.useRef(!1),T=r.useRef(null),g=r.useRef(new Set),le=r.useRef(0),oe=r.useRef(null),ne=r.useRef(0),de=r.useRef(null),Se=r.useRef(0),Ee=r.useRef(null),Te=r.useRef(0),Ue=r.useRef(null);r.useEffect(()=>{Q.current=a},[a]),r.useEffect(()=>{Y.current=u},[u]);const Me=r.useCallback(async J=>{var E;const ie=++le.current;(E=oe.current)==null||E.abort();const j=new AbortController;oe.current=j;try{const se=await is(J,void 0,{signal:j.signal},!0);return Fe(le.current,ie,j.signal)?(c(ce=>({...ce,[J]:se.sessions})),B(ce=>({...ce,[J]:se.next_cursor})),M(ce=>({...ce,[J]:se.has_more})),se.sessions):[]}catch(se){return Fe(le.current,ie,j.signal)&&!_t(se)&&ee(se instanceof Error?se.message:"同步会话失败"),[]}},[]);r.useEffect(()=>{const J=new AbortController;return(async()=>{var j;A(!0);try{const[E,se]=await Promise.all([Ft({signal:J.signal}),Cs({signal:J.signal})]),fe=E.map(me=>{var o,K;return{...me,runtime_state:((o=se[me.id])==null?void 0:o.state)||(me.enabled?"connecting":"disabled"),runtime_connected:((K=se[me.id])==null?void 0:K.connected)===!0}}).filter(me=>me.enabled),De=await Promise.all(fe.map(async me=>[me.id,await is(me.id,void 0,{signal:J.signal})]));if(J.signal.aborted)return;s(fe),c(Object.fromEntries(De.map(([me,o])=>[me,o.sessions]))),B(Object.fromEntries(De.map(([me,o])=>[me,o.next_cursor]))),M(Object.fromEntries(De.map(([me,o])=>[me,o.has_more])));const ve=window.localStorage.getItem("ydisks.chat.account.v1")||"",Pe=fe.some(me=>me.id===ve)?ve:((j=fe[0])==null?void 0:j.id)||"";l(Pe)}catch(E){J.signal.aborted||ee(E instanceof Error?E.message:"加载聊天数据失败")}finally{J.signal.aborted||A(!1)}})(),()=>J.abort()},[]),r.useEffect(()=>{let J=!1,ie=0,j=null;const E=async()=>{j=new AbortController;try{const se=await Cs({signal:j.signal,timeoutMs:1e4});J||s(ce=>ce.map(fe=>{var De,ve;return{...fe,runtime_state:((De=se[fe.id])==null?void 0:De.state)||fe.runtime_state,runtime_connected:((ve=se[fe.id])==null?void 0:ve.connected)??fe.runtime_connected}}))}catch{}finally{J||(ie=window.setTimeout(E,3e3))}};return ie=window.setTimeout(E,3e3),()=>{J=!0,window.clearTimeout(ie),j==null||j.abort()}},[]),r.useEffect(()=>{if(!a)return;window.localStorage.setItem("ydisks.chat.account.v1",a);const J=n[a]||[];h(ie=>{var j;return J.some(E=>E.chat_id===ie)?ie:((j=J[0])==null?void 0:j.chat_id)||""})},[a,n]),r.useEffect(()=>{!a||g.current.has(a)||(g.current.add(a),Me(a))},[a,Me]),r.useEffect(()=>{var j;if(!a||!u){N([]);return}const J=++ne.current;(j=de.current)==null||j.abort();const ie=new AbortController;return de.current=ie,H(!0),Promise.all([Ys(a,u,void 0,void 0,{signal:ie.signal}),Xs(a,u,{signal:ie.signal})]).then(([E])=>{Fe(ne.current,J,ie.signal)&&(N(E.messages),z(E.has_more),F(E.next_cursor),E.session&&c(se=>({...se,[a]:(se[a]||[]).map(ce=>{var fe;return ce.chat_id===((fe=E.session)==null?void 0:fe.chat_id)?E.session:ce})})),c(se=>({...se,[a]:(se[a]||[]).map(ce=>ce.chat_id===u?{...ce,unread_count:0}:ce)})))}).catch(E=>{Fe(ne.current,J,ie.signal)&&!_t(E)&&ee(E instanceof Error?E.message:"加载消息失败")}).finally(()=>{Fe(ne.current,J,ie.signal)&&H(!1)}),()=>ie.abort()},[a,u]),r.useEffect(()=>{var J;(J=Ee.current)==null||J.abort(),Se.current+=1},[a]),r.useEffect(()=>{var J;(J=Ue.current)==null||J.abort(),Te.current+=1},[a,u]),r.useEffect(()=>()=>{var J,ie,j,E;(J=oe.current)==null||J.abort(),(ie=de.current)==null||ie.abort(),(j=Ee.current)==null||j.abort(),(E=Ue.current)==null||E.abort()},[]);const Be=r.useCallback(async()=>{var se;if(!a||!u||X||!y)return;const J=re.current,ie=(J==null?void 0:J.scrollHeight)||0,j=ne.current,E=new AbortController;R.current=!0,f(!0),ee("");try{const ce=(se=m[0])==null?void 0:se.id,fe=await Ys(a,u,O,ce,{signal:E.signal});if(!Fe(ne.current,j,E.signal))return;N(De=>Hi(De,fe.messages)),z(fe.has_more),F(fe.next_cursor),requestAnimationFrame(()=>{J&&(J.scrollTop+=J.scrollHeight-ie)})}catch(ce){R.current=!1,_t(ce)||ee(ce instanceof Error?ce.message:"加载历史消息失败")}finally{f(!1)}},[a,u,y,O,m,X]);r.useEffect(()=>{let J=!1,ie=0,j=0,E=null;const se=()=>{if(J)return;U("connecting");const ce=window.location.protocol==="https:"?"wss:":"ws:";E=new WebSocket(`${ce}//${window.location.host}/api/v1/chat/ws`),E.onopen=()=>{j=0,U("online")},E.onmessage=fe=>{try{const ve=JSON.parse(fe.data).message;if(!ve)return;const Pe=ve.account_id;c(me=>{const o=me[Pe]||[];return o.some(xe=>xe.chat_id===ve.chat_id)?{...me,[Pe]:o.map(xe=>xe.chat_id===ve.chat_id?{...xe,last_message:ve.content,last_message_at:ve.sent_at,unread_count:ve.direction==="incoming"&&(Q.current!==Pe||Y.current!==ve.chat_id)?xe.unread_count+1:xe.unread_count}:xe).sort((xe,Le)=>Le.last_message_at-xe.last_message_at)}:(Me(Pe),me)}),Q.current===Pe&&Y.current===ve.chat_id&&(N(me=>fs(me,ve)),ve.direction==="incoming"&&Xs(Pe,ve.chat_id))}catch{}},E.onclose=()=>{if(J)return;U("offline");const fe=Math.min(15e3,1e3*2**Math.min(j++,4));ie=window.setTimeout(se,fe)},E.onerror=()=>E==null?void 0:E.close()};return se(),()=>{J=!0,window.clearTimeout(ie),E==null||E.close()}},[Me]);const Je=r.useCallback(()=>{const J=re.current;if(!J)return;const ie=J.scrollHeight-J.scrollTop-J.clientHeight;Ne.current=ie<=48},[]);r.useLayoutEffect(()=>{const J=ue.current.accountID!==a||ue.current.chatID!==u;ue.current={accountID:a,chatID:u},J&&(Ne.current=!0);const ie=re.current;if(ie){if(R.current){R.current=!1;return}(G||Ne.current)&&(ie.scrollTop=ie.scrollHeight)}},[a,u,m,G]);const He=t.find(J=>J.id===a),we=n[a]||[],pe=we.find(J=>J.chat_id===u),Ve=r.useMemo(()=>Ki(we,x,_),[we,x,_]),it=r.useCallback(J=>(n[J]||[]).reduce((ie,j)=>ie+j.unread_count,0),[n]),tt=r.useCallback(async()=>{var E;if(!a||b||!Z[a])return;const J=++Se.current;(E=Ee.current)==null||E.abort();const ie=new AbortController;Ee.current=ie;const j=a;k(!0),ee("");try{const se=await is(j,d[j],{signal:ie.signal},!0);if(!Fe(Se.current,J,ie.signal))return;c(ce=>({...ce,[j]:se.sessions})),B(ce=>({...ce,[j]:se.next_cursor})),M(ce=>({...ce,[j]:se.has_more}))}catch(se){Fe(Se.current,J,ie.signal)&&!_t(se)&&ee(se instanceof Error?se.message:"加载历史联系人失败")}finally{Fe(Se.current,J,ie.signal)&&k(!1)}},[a,d,b,Z]),Qe=r.useCallback(async(J,ie)=>{var se;if(!pe||!a||W)return;const j=++Te.current;(se=Ue.current)==null||se.abort();const E=new AbortController;Ue.current=E,V(!0),ee("");try{const ce=await el({account_id:a,chat_id:pe.chat_id,buyer_id:pe.buyer_id,buyer_name:pe.buyer_name,item_id:pe.item_id,item_title:pe.item_title,text:J},{signal:E.signal});if(!Fe(Te.current,j,E.signal))return;w(""),ge(null),N(fe=>fs(fe,ce.message))}catch(ce){Fe(Te.current,j,E.signal)&&(ie&&ge(J),_t(ce)||ee(ce instanceof Error?ce.message:"消息发送失败"))}finally{Fe(Te.current,j,E.signal)&&V(!1)}},[a,pe,W]),Ge=r.useCallback(async(J,ie)=>{var se;if(!pe||!a||W)return;const j=++Te.current;(se=Ue.current)==null||se.abort();const E=new AbortController;Ue.current=E,V(!0),ee("");try{const ce=await tl({account_id:a,chat_id:pe.chat_id,buyer_id:pe.buyer_id,buyer_name:pe.buyer_name,buyer_avatar_url:pe.buyer_avatar_url,item_id:pe.item_id,item_title:pe.item_title,image:J},{signal:E.signal});if(!Fe(Te.current,j,E.signal))return;L(null),N(fe=>fs(fe,ce.message))}catch(ce){Fe(Te.current,j,E.signal)&&(ie&&L(J),_t(ce)||ee(ce instanceof Error?ce.message:"图片发送失败"))}finally{Fe(Te.current,j,E.signal)&&(V(!1),T.current&&(T.current.value=""))}},[a,pe,W]),ot=r.useCallback(async()=>{const J=q.trim();!J||!pe||!a||W||await Qe(J,!0)},[a,q,pe,Qe,W]),pt=r.useCallback(async J=>{!J||!pe||!a||W||await Ge(J,!0)},[a,pe,Ge,W]),ht=r.useCallback(async()=>{ae?await Qe(ae,!1):$&&await Ge($,!1)},[$,ae,Ge,Qe]);return{accounts:t,activeAccountID:a,activeSessions:we,selectedSession:pe,activeAccount:He,messages:m,search:x,unreadOnly:_,draft:q,loading:P,messagesLoading:G,olderLoading:X,hasOlder:y,contactsLoading:b,hasMoreContacts:Z[a]===!0,emojiOpen:D,sending:W,error:v,liveState:be,activeChatID:u,filteredSessions:Ve,scrollRef:re,imageInputRef:T,setActiveAccountID:l,setActiveChatID:h,setSearch:p,setUnreadOnly:S,setDraft:w,setEmojiOpen:C,reloadSessions:Me,loadMoreContacts:tt,loadOlderMessages:Be,handleMessageScroll:Je,handleSend:ot,handleImage:pt,retrySend:ht,retryAvailable:!!(ae||$),unreadForAccount:it,emojiURL:Gi,xianyuEmojis:sr,renderXianyuText:Qi,formatClock:Zi,messageTime:Yi}},eo=()=>{const{accounts:t,activeAccountID:s,activeChatID:a,activeAccount:l,selectedSession:n,filteredSessions:c,messages:u,search:h,unreadOnly:m,draft:N,loading:x,messagesLoading:p,olderLoading:_,hasOlder:S,contactsLoading:q,hasMoreContacts:w,emojiOpen:P,sending:A,error:G,liveState:H,scrollRef:X,imageInputRef:f,setActiveAccountID:y,setActiveChatID:z,setSearch:O,setUnreadOnly:F,setDraft:d,setEmojiOpen:B,reloadSessions:Z,loadMoreContacts:M,loadOlderMessages:b,handleMessageScroll:k,handleSend:D,handleImage:C,retrySend:W,retryAvailable:V,unreadForAccount:v,emojiURL:ee,xianyuEmojis:be,renderXianyuText:U,formatClock:ae,messageTime:ge}=Xi();return x?e.jsx("div",{className:"flex h-[calc(100vh-4rem)] items-center justify-center",children:e.jsx(_e,{className:"h-8 w-8 animate-spin text-sky-500"})}):e.jsxs("section",{className:"flex h-[calc(100vh-4rem)] min-h-[560px] flex-col overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-chat",children:[e.jsxs("header",{className:"border-b border-slate-200 bg-slate-50/70 px-5 pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-black tracking-tight text-slate-950",children:"在线聊天"}),e.jsx("p",{className:"mt-0.5 text-xs font-medium text-slate-500",children:"复用账号实时连接,消息按账号完全隔离"})]}),e.jsxs("div",{className:`flex items-center gap-2 rounded-full px-3 py-1.5 text-xs font-bold ${H==="online"?"bg-emerald-50 text-emerald-700":H==="connecting"?"bg-amber-50 text-amber-700":"bg-red-50 text-red-700"}`,children:[H==="online"?e.jsx(Rr,{className:"h-3.5 w-3.5"}):e.jsx(Ar,{className:"h-3.5 w-3.5"}),H==="online"?"实时同步中":H==="connecting"?"正在连接":"连接已断开"]})]}),e.jsx("div",{className:"flex gap-1 overflow-x-auto pb-0",role:"tablist","aria-label":"聊天账号",children:t.map($=>{const L=$.id===s,Q=v($.id),Y=$.runtime_state==="online";return e.jsxs("button",{type:"button",role:"tab","aria-selected":L,onClick:()=>y($.id),className:`relative flex h-11 shrink-0 items-center gap-2 border-b-2 px-3 text-sm font-extrabold transition-colors ${L?"border-sky-500 text-sky-700":"border-transparent text-slate-500 hover:text-slate-900"}`,children:[e.jsx("span",{className:`h-2 w-2 rounded-full ${Y?"bg-emerald-500":"bg-slate-300"}`}),e.jsx("span",{className:"max-w-36 truncate",children:$.nickname||$.remark||$.id}),Q>0&&e.jsx("span",{className:"min-w-5 rounded-full bg-red-500 px-1.5 py-0.5 text-[10px] text-white",children:Q>99?"99+":Q})]},$.id)})})]}),t.length===0?e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-center",children:[e.jsx(ys,{className:"h-12 w-12 text-slate-300"}),e.jsx("h3",{className:"mt-4 font-black text-slate-800",children:"暂无启用账号"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"先在账号管理中启用账号,聊天会话会自动出现。"})]}):e.jsxs("div",{className:"grid min-h-0 flex-1 overflow-hidden grid-cols-[320px_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"flex min-h-0 flex-col border-r border-slate-200 bg-slate-50/40",children:[e.jsxs("div",{className:"space-y-3 border-b border-slate-200 p-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(St,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),e.jsx("input",{value:h,onChange:$=>O($.target.value),placeholder:"搜索用户、商品或消息",className:"h-10 w-full rounded-xl border border-slate-200 bg-white pl-9 pr-3 text-sm outline-none transition focus:border-sky-400 focus:ring-2 focus:ring-sky-100"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("button",{type:"button",onClick:()=>F($=>!$),className:`rounded-lg px-2.5 py-1.5 text-xs font-bold ${m?"bg-sky-100 text-sky-700":"text-slate-500 hover:bg-slate-100"}`,children:m?"只看未读":"全部会话"}),e.jsx("button",{type:"button",title:"刷新会话",onClick:()=>void Z(s),className:"rounded-lg p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700",children:e.jsx(We,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[c.map($=>e.jsxs("button",{type:"button",onClick:()=>z($.chat_id),className:`flex w-full gap-3 border-b border-slate-100 p-4 text-left transition-colors ${$.chat_id===a?"bg-white shadow-chat-active":"hover:bg-white/80"}`,children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-full bg-slate-200 text-slate-500",children:$.buyer_avatar_url?e.jsx("img",{src:$.buyer_avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx(Zt,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-extrabold text-slate-900",children:$.buyer_name||`用户 ${$.buyer_id}`}),e.jsx("span",{className:"ml-auto shrink-0 text-[10px] font-medium text-slate-400",children:ae($.last_message_at)})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-xs text-slate-500",children:$.last_message||"暂无消息"}),$.unread_count>0&&e.jsx("span",{className:"ml-auto min-w-5 shrink-0 rounded-full bg-red-500 px-1.5 py-0.5 text-center text-[10px] font-bold text-white",children:$.unread_count})]}),$.item_title&&e.jsxs("div",{className:"mt-1.5 truncate text-[10px] font-medium text-sky-700",children:["商品 · ",$.item_title]})]})]},$.chat_id)),c.length===0&&e.jsx("div",{className:"px-6 py-16 text-center text-sm text-slate-400",children:"当前账号暂无匹配会话"}),w&&!h&&!m&&e.jsx("div",{className:"flex justify-center p-4",children:e.jsxs("button",{type:"button",onClick:()=>void M(),disabled:q,className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-2 text-xs font-bold text-slate-500 shadow-sm hover:border-sky-200 hover:text-sky-600 disabled:opacity-50",children:[q&&e.jsx(_e,{className:"h-3.5 w-3.5 animate-spin"}),q?"正在加载":"加载更多历史联系人"]})})]})]}),e.jsx("main",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-surface-subtle",children:n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-16 shrink-0 items-center border-b border-slate-200 bg-white px-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-black text-slate-950",children:n.buyer_name||n.buyer_id}),e.jsxs("div",{className:"mt-0.5 truncate text-xs text-slate-500",children:["用户 ID:",n.buyer_id]})]}),e.jsx("span",{className:`ml-auto rounded-full px-2.5 py-1 text-[10px] font-bold ${(l==null?void 0:l.runtime_state)==="online"?"bg-emerald-50 text-emerald-700":"bg-slate-100 text-slate-500"}`,children:(l==null?void 0:l.runtime_state)==="online"?"账号在线":"账号离线"})]}),e.jsx("div",{ref:X,onScroll:k,className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5",children:p?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(_e,{className:"h-6 w-6 animate-spin text-sky-500"})}):e.jsxs(e.Fragment,{children:[S&&e.jsx("div",{className:"flex justify-center pb-1",children:e.jsxs("button",{type:"button",onClick:()=>void b(),disabled:_,className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-1.5 text-xs font-bold text-slate-500 shadow-sm transition hover:border-sky-200 hover:text-sky-600 disabled:opacity-50",children:[_&&e.jsx(_e,{className:"h-3.5 w-3.5 animate-spin"}),_?"正在加载":"加载更早消息"]})}),u.map($=>{const L=$.direction==="outgoing";return $.message_type==="system"?e.jsx("div",{className:"flex justify-center py-1",children:e.jsxs("div",{className:"max-w-[82%] rounded-xl border border-slate-200 bg-slate-100 px-4 py-2 text-center text-xs leading-5 text-slate-500",children:[U($.content),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:ge($.sent_at)})]})},$.message_key):e.jsxs("div",{className:`flex items-end gap-2.5 ${L?"justify-end":"justify-start"}`,children:[!L&&e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-slate-200 ring-2 ring-white",children:n.buyer_avatar_url?e.jsx("img",{src:n.buyer_avatar_url,alt:n.buyer_name||"用户",className:"h-full w-full object-cover"}):e.jsx(Zt,{className:"m-2 h-5 w-5 text-slate-500"})}),e.jsxs("div",{className:`max-w-[72%] ${L?"items-end":"items-start"} flex flex-col`,children:[e.jsx("div",{className:"mb-1 px-1 text-[10px] font-semibold text-slate-400",children:L?(l==null?void 0:l.nickname)||(l==null?void 0:l.remark)||"我":n.buyer_name||$.sender_name||n.buyer_id}),$.message_type==="image"?e.jsx("a",{href:$.content,target:"_blank",rel:"noreferrer",className:`block overflow-hidden rounded-2xl border bg-white p-1 shadow-sm ${L?"rounded-br-md border-sky-200":"rounded-bl-md border-slate-200"}`,children:e.jsx("img",{src:$.content,alt:"聊天图片",className:"max-h-80 max-w-full rounded-xl object-contain"})}):$.message_type==="video"?e.jsx("video",{src:$.content,controls:!0,preload:"metadata",className:"max-h-80 max-w-full rounded-2xl bg-black"}):e.jsx("div",{className:`rounded-2xl px-4 py-2.5 text-sm leading-6 shadow-sm ${L?"rounded-br-md bg-sky-500 text-white":"rounded-bl-md border border-slate-200 bg-white text-slate-800"}`,children:U($.content)}),e.jsxs("div",{className:"mt-1 flex items-center gap-1 text-[10px] text-slate-400",children:[ge($.sent_at),L&&($.status==="failed"?e.jsx(ut,{className:"h-3 w-3 text-red-500"}):$.status==="sent"?e.jsx(Ir,{className:"h-3 w-3 text-sky-500"}):e.jsx(Ye,{className:"h-3 w-3"}))]})]}),L&&e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-sky-100 ring-2 ring-white",children:l!=null&&l.avatar_url?e.jsx("img",{src:l.avatar_url,alt:"我",className:"h-full w-full object-cover"}):e.jsx(Zt,{className:"m-2 h-5 w-5 text-sky-600"})})]},$.message_key)})]})}),G&&e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-red-100 bg-red-50 px-5 py-2 text-xs font-medium text-red-700",children:[e.jsx("span",{children:G}),V&&e.jsx("button",{type:"button",className:"font-bold underline",onClick:()=>void W(),children:"重试发送"})]}),e.jsxs("div",{className:"relative z-10 shrink-0 border-t border-slate-200 bg-white p-4 shadow-chat-input",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-1",children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",onClick:()=>B($=>!$),disabled:A||(l==null?void 0:l.runtime_state)!=="online",className:"rounded-lg p-2 text-slate-500 hover:bg-sky-50 hover:text-sky-600 disabled:opacity-40",title:"闲鱼表情",children:e.jsx(Or,{className:"h-5 w-5"})}),P&&e.jsxs("div",{className:"absolute bottom-11 left-0 z-30 w-[360px] rounded-2xl border border-slate-200 bg-white p-3 shadow-2xl",children:[e.jsx("div",{className:"mb-2 text-xs font-bold text-slate-500",children:"全部表情"}),e.jsx("div",{className:"grid max-h-72 grid-cols-8 gap-1 overflow-y-auto",children:be.map(([$,L])=>e.jsx("button",{type:"button",title:`[${$}]`,onClick:()=>{d(Q=>Q+`[${$}]`),B(!1)},className:"flex h-10 w-10 items-center justify-center rounded-lg hover:bg-slate-100",children:e.jsx("img",{src:ee(L),alt:`[${$}]`,className:"h-8 w-8 object-contain"})},$))})]})]}),e.jsx("input",{ref:f,type:"file",accept:"image/*",className:"hidden",onChange:$=>{var L;return void C((L=$.target.files)==null?void 0:L[0])}}),e.jsx("button",{type:"button",onClick:()=>{var $;return($=f.current)==null?void 0:$.click()},disabled:A||(l==null?void 0:l.runtime_state)!=="online",className:"rounded-lg p-2 text-slate-500 transition hover:bg-sky-50 hover:text-sky-600 disabled:opacity-40",title:"发送图片(最大 10MB)",children:e.jsx(Pr,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"flex items-end gap-3 rounded-2xl border border-slate-200 bg-slate-50 p-2 transition focus-within:border-sky-400 focus-within:ring-2 focus-within:ring-sky-100",children:[e.jsx("textarea",{value:N,onChange:$=>d($.target.value),rows:2,maxLength:2e3,onKeyDown:$=>{$.key==="Enter"&&!$.shiftKey&&($.preventDefault(),D())},disabled:(l==null?void 0:l.runtime_state)!=="online",placeholder:(l==null?void 0:l.runtime_state)==="online"?"输入消息,Enter 发送,Shift + Enter 换行":"账号离线,暂时无法发送",className:"max-h-32 min-h-12 flex-1 resize-none bg-transparent px-2 py-2 text-sm leading-6 outline-none disabled:cursor-not-allowed"}),e.jsx("button",{type:"button",onClick:()=>void D(),disabled:!N.trim()||A||(l==null?void 0:l.runtime_state)!=="online",className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-sky-500 text-white shadow-md shadow-sky-100 transition hover:bg-sky-600 disabled:cursor-not-allowed disabled:bg-slate-300 disabled:shadow-none","aria-label":"发送消息",children:A?e.jsx(_e,{className:"h-4 w-4 animate-spin"}):e.jsx(ss,{className:"h-4 w-4"})})]})]})]}):e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-center",children:[e.jsx(ys,{className:"h-12 w-12 text-slate-300"}),e.jsx("h3",{className:"mt-4 font-black text-slate-700",children:"选择一个用户开始聊天"}),e.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"该账号的新消息会实时出现在左侧列表。"})]})})]})]})},ar="ydisks.sidebar.v1",to=()=>{try{return window.localStorage.getItem(ar)==="collapsed"}catch{return!1}},so=t=>{try{window.localStorage.setItem(ar,t?"collapsed":"expanded")}catch{}},rr={"/app/dashboard":"dashboard","/app/accounts":"accounts","/app/chat":"chat","/app/orders":"orders","/app/cards":"cards","/app/items":"items","/app/rules":"rules","/app/notifications":"notifications","/app/settings":"settings"},ya=Object.fromEntries(Object.entries(rr).map(([t,s])=>[s,t])),ja=()=>rr[window.location.pathname]||"dashboard",ao=()=>{const[t,s]=r.useState(!1),[a,l]=r.useState(!1),[n,c]=r.useState(ja),[u,h]=r.useState(!0),[m,N]=r.useState(!1),[x,p]=r.useState(""),[_,S]=r.useState(""),[q,w]=r.useState(!1),[P,A]=r.useState(""),[G,H]=r.useState(""),[X,f]=r.useState(""),[y,z]=r.useState(!1),[O,F]=r.useState(""),[d,B]=r.useState(),[Z,M]=r.useState(to),b=V=>{const v=V==="settings"&&!a?"dashboard":V,ee=ya[v];ee&&ee!==window.location.pathname&&window.history.pushState({},"",ee),c(v)};r.useEffect(()=>{const V=()=>c(ja());return window.addEventListener("popstate",V),()=>window.removeEventListener("popstate",V)},[]),r.useEffect(()=>{qa().then(v=>{if((v==null?void 0:v.initialized)===!1){N(!0),s(!1),l(!1);return}N(!1),v!=null&&v.authenticated?(s(!0),l(v.is_admin===!0)):l(!1)}).catch(()=>{s(!1),l(!1)}).finally(()=>h(!1));const V=()=>{s(!1),l(!1)};return window.addEventListener("auth:logout",V),()=>window.removeEventListener("auth:logout",V)},[]),r.useEffect(()=>{!u&&t&&!a&&n==="settings"&&(window.history.replaceState({},"",ya.dashboard),c("dashboard"))},[u,t,a,n]);const k=async V=>{V.preventDefault(),w(!0),A("");try{const v=await Vr({username:x,password:_});v.success?(s(!0),l(v.is_admin===!0)):A(v.message||"登录失败")}catch(v){const ee=v instanceof Error?v.message:String(v);A(ee||"登录失败")}finally{w(!1)}},D=async V=>{if(V.preventDefault(),F(""),G.length<8){F("密码至少需要 8 个字符");return}if(G!==X){F("两次输入的密码不一致");return}z(!0);try{const v=await Qr(G);if(!v.success){F(v.message||"初始化失败,请重试");return}N(!1),s(!0),l(v.is_admin===!0),H(""),f("")}catch(v){const ee=v instanceof Error?v.message:String(v);F(ee||"初始化失败,请重试")}finally{z(!1)}},C=async()=>{try{await Hr()}catch(V){console.error("退出登录失败",V)}finally{s(!1),l(!1)}};if(u)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-surface",children:e.jsx(_e,{className:"w-8 h-8 text-brand animate-spin"})});if(m)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-canvas 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-panel 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:"mx-auto mb-6 flex justify-center",children:e.jsx(ws,{sizeClass:"w-24 h-24"})}),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:"设置完成后会自动进入系统,管理员账号为 admin。"})]}),e.jsxs("form",{onSubmit:D,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx(Js,{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:"设置管理员密码(至少 8 个字符)",value:G,onChange:V=>H(V.target.value),autoFocus:!0,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(qt,{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:X,onChange:V=>f(V.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]})]}),O&&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(qt,{className:"w-4 h-4"})," ",O]}),e.jsx("button",{type:"submit",disabled:y,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:y?e.jsx(_e,{className:"w-5 h-5 animate-spin"}):e.jsxs(e.Fragment,{children:["设置密码并进入系统 ",e.jsx(vs,{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(!t)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-canvas 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-panel 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:"group mx-auto mb-6 flex cursor-pointer justify-center",children:e.jsx(ws,{sizeClass:"w-24 h-24",logoClassName:"w-full h-full text-white 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:k,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx(yt,{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:x,onChange:V=>p(V.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(Js,{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:_,onChange:V=>S(V.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]})]}),P&&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(qt,{className:"w-4 h-4"})," ",P]}),e.jsx("button",{type:"submit",disabled:q,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:q?e.jsx(_e,{className:"w-5 h-5 animate-spin"}):e.jsxs(e.Fragment,{children:["立即登录 ",e.jsx(vs,{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 W=()=>{switch(n){case"dashboard":return e.jsx(ds,{});case"accounts":return e.jsx(Bn,{});case"chat":return e.jsx(eo,{});case"orders":return e.jsx(Xn,{});case"cards":return e.jsx(ni,{});case"items":return e.jsx(yi,{onConfigureDelivery:V=>{B({cookieId:V.cookie_id,itemId:V.item_id,requestId:Date.now()}),b("rules")}});case"rules":return e.jsx(Ei,{initialDeliveryTarget:d,onDeliveryTargetHandled:()=>B(void 0)});case"notifications":return e.jsx(Ji,{isAdmin:a});case"settings":return a?e.jsx(Ci,{}):e.jsx(ds,{});default:return e.jsx(ds,{})}};return e.jsxs("div",{className:"flex min-h-screen bg-canvas text-ink",children:[e.jsx(xn,{activeTab:n,isAdmin:a,collapsed:Z,onToggleCollapsed:()=>M(V=>{const v=!V;return so(v),v}),onNavigate:b,onLogout:C}),e.jsxs("main",{className:`h-screen min-w-0 flex-1 overflow-x-hidden overflow-y-auto scroll-smooth transition-[margin] duration-300 ${Z?"ml-16":"ml-64"} ${n==="chat"?"p-4 md:p-6":"p-8 md:p-12"}`,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:`${n==="chat"?"mx-auto max-w-[1680px]":"mx-auto max-w-[1400px] pb-10"}`,children:W()})]})]})},lr=document.getElementById("root");if(!lr)throw new Error("Could not find root element to mount to");const ro=ir.createRoot(lr);ro.render(e.jsx(Is.StrictMode,{children:e.jsx(ao,{})})); diff --git a/internal/webui/static/assets/index-DFFQFH9n.css b/internal/webui/static/assets/index-DFFQFH9n.css deleted file mode 100644 index 75240fa..0000000 --- a/internal/webui/static/assets/index-DFFQFH9n.css +++ /dev/null @@ -1 +0,0 @@ -*,: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(147 197 253 / .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(147 197 253 / .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:rgb(var(--color-neutral-200) / 1)}: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:rgb(var(--color-neutral-400) / 1)}input::placeholder,textarea::placeholder{opacity:1;color:rgb(var(--color-neutral-400) / 1)}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}.container{width:100%}@media(min-width:640px){.container{max-width:640px}}@media(min-width:768px){.container{max-width:768px}}@media(min-width:1024px){.container{max-width:1024px}}@media(min-width:1280px){.container{max-width:1280px}}@media(min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.-inset-1{top:-.25rem;right:-.25rem;bottom:-.25rem;left:-.25rem}.inset-0{top:0;right:0;bottom:0;left:0}.inset-y-0{top:0;bottom:0}.-bottom-1{bottom:-.25rem}.-right-1{right:-.25rem}.-right-12{right:-3rem}.-right-6{right:-1.5rem}.-top-16{top:-4rem}.-top-6{top:-1.5rem}.bottom-10{bottom:2.5rem}.bottom-11{bottom:2.75rem}.bottom-8{bottom:2rem}.bottom-\[-10\%\]{bottom:-10%}.left-0{left:0}.left-1{left:.25rem}.left-1\.5{left:.375rem}.left-1\/2{left:50%}.left-3{left:.75rem}.left-4{left:1rem}.left-5{left:1.25rem}.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-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}.m-2{margin:.5rem}.mx-0\.5{margin-left:.125rem;margin-right:.125rem}.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-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-16{margin-left:4rem}.ml-64{margin-left:16rem}.ml-auto{margin-left:auto}.mr-2{margin-right:.5rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.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}.line-clamp-3{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.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-1\.5{height:.375rem}.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{height:.5rem}.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-36{height:9rem}.h-4{height:1rem}.h-40{height:10rem}.h-48{height:12rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-80{height:20rem}.h-9{height:2.25rem}.h-\[18px\]{height:18px}.h-\[19px\]{height:19px}.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-\[calc\(100vh-4rem\)\]{height:calc(100vh - 4rem)}.h-auto{height:auto}.h-fit{height:-moz-fit-content;height:fit-content}.h-full{height:100%}.h-screen{height:100vh}.max-h-32{max-height:8rem}.max-h-44{max-height:11rem}.max-h-48{max-height:12rem}.max-h-64{max-height:16rem}.max-h-72{max-height:18rem}.max-h-80{max-height:20rem}.max-h-\[380px\]{max-height:380px}.max-h-\[400px\]{max-height:400px}.max-h-\[420px\]{max-height:420px}.max-h-\[min\(64vh\,28rem\)\]{max-height:min(64vh,28rem)}.min-h-0{min-height:0px}.min-h-12{min-height:3rem}.min-h-36{min-height:9rem}.min-h-56{min-height:14rem}.min-h-64{min-height:16rem}.min-h-\[120px\]{min-height:120px}.min-h-\[150px\]{min-height:150px}.min-h-\[400px\]{min-height:400px}.min-h-\[42px\]{min-height:42px}.min-h-\[46px\]{min-height:46px}.min-h-\[560px\]{min-height:560px}.min-h-screen{min-height:100vh}.w-1\.5{width:.375rem}.w-10{width:2.5rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-2{width:.5rem}.w-2\.5{width:.625rem}.w-20{width:5rem}.w-24{width:6rem}.w-28{width:7rem}.w-3{width:.75rem}.w-3\.5{width:.875rem}.w-32{width:8rem}.w-36{width:9rem}.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-\[18px\]{width:18px}.w-\[19\%\]{width:19%}.w-\[19px\]{width:19px}.w-\[23\%\]{width:23%}.w-\[27\%\]{width:27%}.w-\[360px\]{width:360px}.w-\[60\%\]{width:60%}.w-\[7\%\]{width:7%}.w-\[8\%\]{width:8%}.w-\[800px\]{width:800px}.w-\[9\%\]{width:9%}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.w-px{width:1px}.min-w-0{min-width:0px}.min-w-5{min-width:1.25rem}.min-w-9{min-width:2.25rem}.min-w-\[150px\]{min-width:150px}.min-w-\[200px\]{min-width:200px}.min-w-\[210px\]{min-width:210px}.min-w-\[260px\]{min-width:260px}.min-w-\[760px\]{min-width:760px}.max-w-36{max-width:9rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-72{max-width:18rem}.max-w-\[12rem\]{max-width:12rem}.max-w-\[1400px\]{max-width:1400px}.max-w-\[15rem\]{max-width:15rem}.max-w-\[1680px\]{max-width:1680px}.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-\[400px\]{max-width:400px}.max-w-\[72\%\]{max-width:72%}.max-w-\[80px\]{max-width:80px}.max-w-\[82\%\]{max-width:82%}.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{flex-shrink:0}.shrink{flex-shrink:1}.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-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))}.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}.list-inside{list-style-position:inside}.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))}.grid-cols-8{grid-template-columns:repeat(8,minmax(0,1fr))}.grid-cols-\[320px_minmax\(0\,1fr\)\]{grid-template-columns:320px 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}.items-baseline{align-items:baseline}.justify-start{justify-content:flex-start}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-2\.5{gap:.625rem}.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(var(--color-neutral-50) / var(--tw-divide-opacity, 1))}.self-start{align-self:flex-start}.self-center{align-self:center}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overflow-x-hidden{overflow-x:hidden}.overscroll-contain{overscroll-behavior:contain}.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}.rounded-bl-md{border-bottom-left-radius:6px}.rounded-br-md{border-bottom-right-radius:6px}.border{border-width:1px}.border-0{border-width:0px}.border-2{border-width:2px}.border-4{border-width:4px}.border-y{border-top-width:1px;border-bottom-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-none{border-style:none}.border-amber-200{--tw-border-opacity: 1;border-color:rgb(var(--color-warning-200) / var(--tw-border-opacity, 1))}.border-blue-100{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-100) / var(--tw-border-opacity, 1))}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-200) / var(--tw-border-opacity, 1))}.border-emerald-100{--tw-border-opacity: 1;border-color:rgb(var(--color-success-100) / var(--tw-border-opacity, 1))}.border-gray-100{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-100) / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-200) / var(--tw-border-opacity, 1))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-300) / var(--tw-border-opacity, 1))}.border-gray-50{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-50) / var(--tw-border-opacity, 1))}.border-purple-100{--tw-border-opacity: 1;border-color:rgb(var(--color-accent-100) / var(--tw-border-opacity, 1))}.border-red-100{--tw-border-opacity: 1;border-color:rgb(var(--color-danger-100) / var(--tw-border-opacity, 1))}.border-sky-100{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-100) / var(--tw-border-opacity, 1))}.border-sky-200{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-200) / var(--tw-border-opacity, 1))}.border-sky-500{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-500) / var(--tw-border-opacity, 1))}.border-slate-100{--tw-border-opacity: 1;border-color:rgb(var(--color-slate-100) / var(--tw-border-opacity, 1))}.border-slate-200{--tw-border-opacity: 1;border-color:rgb(var(--color-slate-200) / var(--tw-border-opacity, 1))}.border-slate-200\/80{border-color:rgb(var(--color-slate-200) / .8)}.border-transparent{border-color:var(--color-transparent)}.border-white{--tw-border-opacity: 1;border-color:rgb(var(--color-white) / var(--tw-border-opacity, 1))}.border-white\/10{border-color:rgb(var(--color-white) / .1)}.border-white\/80{border-color:rgb(var(--color-white) / .8)}.bg-amber-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-100) / var(--tw-bg-opacity, 1))}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-50) / var(--tw-bg-opacity, 1))}.bg-amber-50\/70{background-color:rgb(var(--color-warning-50) / .7)}.bg-amber-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-500) / var(--tw-bg-opacity, 1))}.bg-black{--tw-bg-opacity: 1;background-color:rgb(var(--color-black) / var(--tw-bg-opacity, 1))}.bg-black\/50{background-color:rgb(var(--color-black) / .5)}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-100) / var(--tw-bg-opacity, 1))}.bg-blue-200\/30{background-color:rgb(var(--color-brand-200) / .3)}.bg-blue-200\/40{background-color:rgb(var(--color-brand-200) / .4)}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-400) / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.bg-blue-50\/50{background-color:rgb(var(--color-brand-50) / .5)}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-500) / var(--tw-bg-opacity, 1))}.bg-blue-500\/20{background-color:rgb(var(--color-brand-500) / .2)}.bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-600) / var(--tw-bg-opacity, 1))}.bg-brand{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand) / var(--tw-bg-opacity, 1))}.bg-canvas{--tw-bg-opacity: 1;background-color:rgb(var(--color-canvas) / var(--tw-bg-opacity, 1))}.bg-danger-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-500) / var(--tw-bg-opacity, 1))}.bg-emerald-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.bg-emerald-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-500) / var(--tw-bg-opacity, 1))}.bg-emerald-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-600) / var(--tw-bg-opacity, 1))}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-100) / var(--tw-bg-opacity, 1))}.bg-gray-100\/50{background-color:rgb(var(--color-neutral-100) / .5)}.bg-gray-200{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-200) / var(--tw-bg-opacity, 1))}.bg-gray-300{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-300) / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-50) / var(--tw-bg-opacity, 1))}.bg-gray-50\/70{background-color:rgb(var(--color-neutral-50) / .7)}.bg-gray-50\/80{background-color:rgb(var(--color-neutral-50) / .8)}.bg-gray-900{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-900) / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-500) / var(--tw-bg-opacity, 1))}.bg-pink-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-50) / var(--tw-bg-opacity, 1))}.bg-purple-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-100) / var(--tw-bg-opacity, 1))}.bg-purple-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-50) / var(--tw-bg-opacity, 1))}.bg-purple-50\/50{background-color:rgb(var(--color-accent-50) / .5)}.bg-purple-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-500) / var(--tw-bg-opacity, 1))}.bg-purple-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-600) / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-100) / var(--tw-bg-opacity, 1))}.bg-red-200\/35{background-color:rgb(var(--color-danger-200) / .35)}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-50) / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-500) / var(--tw-bg-opacity, 1))}.bg-red-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-600) / var(--tw-bg-opacity, 1))}.bg-sky-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-100) / var(--tw-bg-opacity, 1))}.bg-sky-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.bg-sky-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-500) / var(--tw-bg-opacity, 1))}.bg-slate-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-100) / var(--tw-bg-opacity, 1))}.bg-slate-200{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-200) / var(--tw-bg-opacity, 1))}.bg-slate-300{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-300) / var(--tw-bg-opacity, 1))}.bg-slate-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-50) / var(--tw-bg-opacity, 1))}.bg-slate-50\/40{background-color:rgb(var(--color-slate-50) / .4)}.bg-slate-50\/70{background-color:rgb(var(--color-slate-50) / .7)}.bg-slate-900{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-900) / var(--tw-bg-opacity, 1))}.bg-success-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-500) / var(--tw-bg-opacity, 1))}.bg-surface{--tw-bg-opacity: 1;background-color:rgb(var(--color-surface) / var(--tw-bg-opacity, 1))}.bg-surface-muted{--tw-bg-opacity: 1;background-color:rgb(var(--color-surface-muted) / var(--tw-bg-opacity, 1))}.bg-surface-subtle{--tw-bg-opacity: 1;background-color:rgb(var(--color-surface-subtle) / var(--tw-bg-opacity, 1))}.bg-transparent{background-color:var(--color-transparent)}.bg-white{--tw-bg-opacity: 1;background-color:rgb(var(--color-white) / var(--tw-bg-opacity, 1))}.bg-white\/5{background-color:rgb(var(--color-white) / .05)}.bg-white\/80{background-color:rgb(var(--color-white) / .8)}.bg-white\/90{background-color:rgb(var(--color-white) / .9)}.bg-white\/95{background-color:rgb(var(--color-white) / .95)}.bg-opacity-10{--tw-bg-opacity: .1}.bg-gradient-to-bl{background-image:linear-gradient(to bottom left,var(--tw-gradient-stops))}.bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--tw-gradient-stops))}.from-blue-50{--tw-gradient-from: rgb(var(--color-brand-50) / 1) var(--tw-gradient-from-position);--tw-gradient-to: rgb(var(--color-brand-50) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-red-50{--tw-gradient-from: rgb(var(--color-danger-50) / 1) var(--tw-gradient-from-position);--tw-gradient-to: rgb(var(--color-danger-50) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.via-white{--tw-gradient-to: rgb(var(--color-white) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), rgb(var(--color-white) / 1) var(--tw-gradient-via-position), var(--tw-gradient-to)}.to-orange-50{--tw-gradient-to: rgb(var(--color-warning-50) / 1) var(--tw-gradient-to-position)}.to-transparent{--tw-gradient-to: var(--color-transparent) var(--tw-gradient-to-position)}.object-contain{-o-object-fit:contain;object-fit:contain}.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{padding-left:.25rem;padding-right:.25rem}.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-3\.5{padding-left:.875rem;padding-right:.875rem}.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-12{padding-top:3rem;padding-bottom:3rem}.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-0{padding-bottom:0}.pb-1{padding-bottom:.25rem}.pb-10{padding-bottom:2.5rem}.pb-24{padding-bottom:6rem}.pb-9{padding-bottom:2.25rem}.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-9{padding-left:2.25rem}.pr-10{padding-right:2.5rem}.pr-11{padding-right:2.75rem}.pr-12{padding-right:3rem}.pr-2{padding-right:.5rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pr-6{padding-right:1.5rem}.pr-9{padding-right:2.25rem}.pt-3{padding-top:.75rem}.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}.align-middle{vertical-align:middle}.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-\[13px\]{font-size:13px}.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}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.tabular-nums{--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-6{line-height:1.5rem}.leading-none{line-height:1}.leading-relaxed{line-height:1.625}.leading-tight{line-height:1.25}.tracking-\[0\.18em\]{letter-spacing:.18em}.tracking-\[0\.22em\]{letter-spacing:.22em}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.tracking-widest{letter-spacing:.1em}.text-amber-600{--tw-text-opacity: 1;color:rgb(var(--color-warning-600) / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(var(--color-warning-700) / var(--tw-text-opacity, 1))}.text-amber-800{--tw-text-opacity: 1;color:rgb(var(--color-warning-800) / var(--tw-text-opacity, 1))}.text-amber-900{--tw-text-opacity: 1;color:rgb(var(--color-warning-900) / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(var(--color-brand-700) / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(var(--color-brand-800) / var(--tw-text-opacity, 1))}.text-blue-900{--tw-text-opacity: 1;color:rgb(var(--color-brand-900) / var(--tw-text-opacity, 1))}.text-blue-950{--tw-text-opacity: 1;color:rgb(var(--color-brand-950) / var(--tw-text-opacity, 1))}.text-brand{--tw-text-opacity: 1;color:rgb(var(--color-brand) / var(--tw-text-opacity, 1))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(var(--color-success-600) / var(--tw-text-opacity, 1))}.text-emerald-700{--tw-text-opacity: 1;color:rgb(var(--color-success-700) / var(--tw-text-opacity, 1))}.text-gray-100{--tw-text-opacity: 1;color:rgb(var(--color-neutral-100) / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(var(--color-neutral-300) / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(var(--color-neutral-400) / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(var(--color-neutral-500) / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(var(--color-neutral-600) / var(--tw-text-opacity, 1))}.text-gray-700{--tw-text-opacity: 1;color:rgb(var(--color-neutral-700) / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(var(--color-neutral-800) / var(--tw-text-opacity, 1))}.text-gray-900{--tw-text-opacity: 1;color:rgb(var(--color-neutral-900) / var(--tw-text-opacity, 1))}.text-gray-950{--tw-text-opacity: 1;color:rgb(var(--color-neutral-950) / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(var(--color-success-600) / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(var(--color-success-700) / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(var(--color-success-800) / var(--tw-text-opacity, 1))}.text-ink{--tw-text-opacity: 1;color:rgb(var(--color-ink) / var(--tw-text-opacity, 1))}.text-pink-600{--tw-text-opacity: 1;color:rgb(var(--color-accent-600) / var(--tw-text-opacity, 1))}.text-purple-500{--tw-text-opacity: 1;color:rgb(var(--color-accent-500) / var(--tw-text-opacity, 1))}.text-purple-600{--tw-text-opacity: 1;color:rgb(var(--color-accent-600) / var(--tw-text-opacity, 1))}.text-purple-700{--tw-text-opacity: 1;color:rgb(var(--color-accent-700) / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(var(--color-danger-500) / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(var(--color-danger-600) / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(var(--color-danger-700) / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(var(--color-danger-800) / var(--tw-text-opacity, 1))}.text-sky-500{--tw-text-opacity: 1;color:rgb(var(--color-brand-500) / var(--tw-text-opacity, 1))}.text-sky-600{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.text-sky-700{--tw-text-opacity: 1;color:rgb(var(--color-brand-700) / var(--tw-text-opacity, 1))}.text-sky-800{--tw-text-opacity: 1;color:rgb(var(--color-brand-800) / var(--tw-text-opacity, 1))}.text-sky-900{--tw-text-opacity: 1;color:rgb(var(--color-brand-900) / var(--tw-text-opacity, 1))}.text-slate-300{--tw-text-opacity: 1;color:rgb(var(--color-slate-300) / var(--tw-text-opacity, 1))}.text-slate-400{--tw-text-opacity: 1;color:rgb(var(--color-slate-400) / var(--tw-text-opacity, 1))}.text-slate-500{--tw-text-opacity: 1;color:rgb(var(--color-slate-500) / var(--tw-text-opacity, 1))}.text-slate-600{--tw-text-opacity: 1;color:rgb(var(--color-slate-600) / var(--tw-text-opacity, 1))}.text-slate-700{--tw-text-opacity: 1;color:rgb(var(--color-slate-700) / var(--tw-text-opacity, 1))}.text-slate-800{--tw-text-opacity: 1;color:rgb(var(--color-slate-800) / var(--tw-text-opacity, 1))}.text-slate-900{--tw-text-opacity: 1;color:rgb(var(--color-slate-900) / var(--tw-text-opacity, 1))}.text-slate-950{--tw-text-opacity: 1;color:rgb(var(--color-slate-950) / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(var(--color-white) / var(--tw-text-opacity, 1))}.underline{text-decoration-line:underline}.accent-brand{accent-color:rgb(var(--color-brand) / 1)}.opacity-0{opacity:0}.opacity-10{opacity:.1}.opacity-25{opacity:.25}.opacity-30{opacity:.3}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.shadow-2xl{--tw-shadow: var(--shadow-2xl);--tw-shadow-colored: var(--shadow-2xl);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-brand-active{--tw-shadow: var(--shadow-brand-active);--tw-shadow-colored: var(--shadow-brand-active);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-chat{--tw-shadow: var(--shadow-chat);--tw-shadow-colored: var(--shadow-chat);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-chat-active{--tw-shadow: var(--shadow-chat-active);--tw-shadow-colored: var(--shadow-chat-active);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-chat-input{--tw-shadow: var(--shadow-chat-input);--tw-shadow-colored: var(--shadow-chat-input);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-inner{--tw-shadow: var(--shadow-inner);--tw-shadow-colored: var(--shadow-inner);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: var(--shadow-lg);--tw-shadow-colored: var(--shadow-lg);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: var(--shadow-md);--tw-shadow-colored: var(--shadow-md);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-modal{--tw-shadow: var(--shadow-modal);--tw-shadow-colored: var(--shadow-modal);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-panel{--tw-shadow: var(--shadow-panel);--tw-shadow-colored: var(--shadow-panel);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sidebar{--tw-shadow: var(--shadow-sidebar);--tw-shadow-colored: var(--shadow-sidebar);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: var(--shadow-sm);--tw-shadow-colored: var(--shadow-sm);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: var(--shadow-xl);--tw-shadow-colored: var(--shadow-xl);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: rgb(var(--color-brand-100) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-blue-200{--tw-shadow-color: rgb(var(--color-brand-200) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-emerald-100{--tw-shadow-color: rgb(var(--color-success-100) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200{--tw-shadow-color: rgb(var(--color-neutral-200) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200\/70{--tw-shadow-color: rgb(var(--color-neutral-200) / .7);--tw-shadow: var(--tw-shadow-colored)}.shadow-red-200{--tw-shadow-color: rgb(var(--color-danger-200) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-sky-100{--tw-shadow-color: rgb(var(--color-brand-100) / 1);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.ring-1{--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(1px + 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-2{--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)}.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-gray-200{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-neutral-200) / var(--tw-ring-opacity, 1))}.ring-white{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-white) / var(--tw-ring-opacity, 1))}.blur{--tw-blur: blur(8px);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-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)}.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)}.backdrop-blur-xl{--tw-backdrop-blur: blur(24px);-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{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[margin\]{transition-property:margin;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[width\]{transition-property:width;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.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-300{transition-duration:.3s}.duration-500{transition-duration:.5s}:root{--color-transparent: transparent;--color-black: 0 0 0;--color-white: 255 255 255;--color-brand: 0 148 247;--color-brand-highlight: 0 113 227;--color-brand-light: 40 126 254;--color-ink: 29 29 31;--color-muted: 134 134 139;--color-line: 210 210 215;--color-canvas: 244 245 247;--color-surface: 255 255 255;--color-surface-subtle: 247 248 250;--color-surface-muted: 250 250 250;--color-neutral-50: 249 250 251;--color-neutral-100: 243 244 246;--color-neutral-200: 229 231 235;--color-neutral-300: 209 213 219;--color-neutral-400: 156 163 175;--color-neutral-500: 107 114 128;--color-neutral-600: 75 85 99;--color-neutral-700: 55 65 81;--color-neutral-800: 31 41 55;--color-neutral-900: 17 24 39;--color-neutral-950: 3 7 18;--color-slate-50: 248 250 252;--color-slate-100: 241 245 249;--color-slate-200: 226 232 240;--color-slate-300: 203 213 225;--color-slate-400: 148 163 184;--color-slate-500: 100 116 139;--color-slate-600: 71 85 105;--color-slate-700: 51 65 85;--color-slate-800: 30 41 59;--color-slate-900: 15 23 42;--color-slate-950: 2 6 23;--color-brand-50: 239 248 255;--color-brand-100: 223 241 255;--color-brand-200: 191 229 255;--color-brand-300: 143 210 255;--color-brand-400: 83 184 251;--color-brand-500: 0 148 247;--color-brand-600: 0 148 247;--color-brand-700: 0 113 227;--color-brand-800: 0 91 181;--color-brand-900: 0 75 147;--color-brand-950: 0 53 107;--color-success-50: 236 253 245;--color-success-100: 209 250 229;--color-success-200: 167 243 208;--color-success-300: 110 231 183;--color-success-400: 52 211 153;--color-success-500: 16 185 129;--color-success-600: 5 150 105;--color-success-700: 4 120 87;--color-success-800: 6 95 70;--color-success-900: 6 78 59;--color-success-950: 2 44 34;--color-warning-50: 255 251 235;--color-warning-100: 254 243 199;--color-warning-200: 253 230 138;--color-warning-300: 252 211 77;--color-warning-400: 251 191 36;--color-warning-500: 245 158 11;--color-warning-600: 217 119 6;--color-warning-700: 180 83 9;--color-warning-800: 146 64 14;--color-warning-900: 120 53 15;--color-warning-950: 69 26 3;--color-danger-50: 254 242 242;--color-danger-100: 254 226 226;--color-danger-200: 254 202 202;--color-danger-300: 252 165 165;--color-danger-400: 248 113 113;--color-danger-500: 239 68 68;--color-danger-600: 220 38 38;--color-danger-700: 185 28 28;--color-danger-800: 153 27 27;--color-danger-900: 127 29 29;--color-danger-950: 69 10 10;--color-info-50: 239 246 255;--color-info-100: 219 234 254;--color-info-200: 191 219 254;--color-info-300: 147 197 253;--color-info-400: 96 165 250;--color-info-500: 59 130 246;--color-info-600: 37 99 235;--color-info-700: 29 78 216;--color-info-800: 30 64 175;--color-info-900: 30 58 138;--color-info-950: 23 37 84;--color-accent-50: 250 245 255;--color-accent-100: 243 232 255;--color-accent-200: 233 213 255;--color-accent-300: 216 180 254;--color-accent-400: 192 132 252;--color-accent-500: 168 85 247;--color-accent-600: 147 51 234;--color-accent-700: 126 34 206;--color-accent-800: 107 33 168;--color-accent-900: 88 28 135;--color-accent-950: 59 7 100;--shadow-none: 0 0 0 var(--color-transparent);--shadow-default: 0 1px 3px 0 rgb(var(--color-black) / .1), 0 1px 2px -1px rgb(var(--color-black) / .1);--shadow-sm: 0 1px 2px 0 rgb(var(--color-black) / .05);--shadow-md: 0 4px 6px -1px rgb(var(--color-black) / .1), 0 2px 4px -2px rgb(var(--color-black) / .1);--shadow-lg: 0 10px 15px -3px rgb(var(--color-black) / .1), 0 4px 6px -4px rgb(var(--color-black) / .1);--shadow-xl: 0 20px 25px -5px rgb(var(--color-black) / .1), 0 8px 10px -6px rgb(var(--color-black) / .1);--shadow-2xl: 0 25px 50px -12px rgb(var(--color-black) / .25);--shadow-inner: inset 0 2px 4px 0 rgb(var(--color-black) / .05);--shadow-card: 0 8px 24px rgb(var(--color-black) / .04);--shadow-panel: 0 20px 60px -15px rgb(var(--color-black) / .05);--shadow-modal: 0 25px 50px -12px rgb(var(--color-black) / .25);--shadow-sidebar: 4px 0 24px rgb(var(--color-slate-900) / .035);--shadow-chat: 0 16px 45px rgb(var(--color-slate-900) / .06);--shadow-chat-input: 0 -8px 24px rgb(var(--color-slate-900) / .04);--shadow-chat-active: inset 3px 0 0 rgb(var(--color-brand));--shadow-brand-soft: 0 2px 8px rgb(var(--color-brand) / .2);--shadow-brand-active: 0 8px 18px rgb(var(--color-brand) / .2);--shadow-brand-strong: 0 8px 20px rgb(var(--color-brand) / .3)}*,:before,:after{--tw-ring-offset-color: rgb(var(--color-white));--tw-ring-color: rgb(var(--color-brand-400) / .5);--tw-ring-offset-shadow: 0 0 0 var(--color-transparent);--tw-ring-shadow: 0 0 0 var(--color-transparent);--tw-shadow: 0 0 0 var(--color-transparent);--tw-shadow-colored: 0 0 0 var(--color-transparent)}.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:rgb(var(--color-canvas));color:rgb(var(--color-ink));-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ios-card{background:rgb(var(--color-surface));border-radius:8px;border:1px solid rgb(var(--color-black) / .02);box-shadow:var(--shadow-card);transition:transform .2s ease,box-shadow .2s ease}.ios-card:hover{box-shadow:0 12px 32px rgb(var(--color-black) / .06)}.dashboard-pie-chart .recharts-surface:focus,.dashboard-pie-chart .recharts-pie:focus,.dashboard-pie-chart .recharts-pie-sector:focus,.dashboard-pie-chart .recharts-sector:focus{outline:none}.dashboard-revenue-chart .recharts-surface:focus,.dashboard-revenue-chart .recharts-bar-rectangle:focus,.dashboard-revenue-chart .recharts-rectangle:focus,.dashboard-revenue-chart .recharts-curve:focus,.dashboard-revenue-chart .recharts-dot:focus,.dashboard-revenue-chart [class*=recharts-zIndex-layer_]:focus{outline:none!important}.dashboard-revenue-chart .recharts-bar-rectangle,.dashboard-revenue-chart .recharts-rectangle{stroke:none!important}.ios-input{background:rgb(var(--color-surface-subtle));border:1px solid var(--color-transparent);transition:all .3s cubic-bezier(.25,.8,.25,1);color:rgb(var(--color-ink));font-weight:500}.ios-input:focus{background:rgb(var(--color-surface));border-color:rgb(var(--color-brand));box-shadow:0 0 0 4px rgb(var(--color-brand) / .3);outline:none}.ios-input::-moz-placeholder{color:rgb(var(--color-neutral-400));font-weight:400}.ios-input::placeholder{color:rgb(var(--color-neutral-400));font-weight:400}.ios-btn-primary{background:rgb(var(--color-brand));color:rgb(var(--color-white));font-weight:700;border:none;transition:all .2s cubic-bezier(.25,.8,.25,1);cursor:pointer}.ios-btn-primary:hover:not(:disabled){background:rgb(var(--color-brand-highlight));transform:translateY(-1px);box-shadow:var(--shadow-brand-strong)}.ios-btn-primary:active:not(:disabled){transform:translateY(1px);box-shadow:var(--shadow-brand-soft)}.ios-btn-primary:disabled{background:rgb(var(--color-neutral-100));color:rgb(var(--color-neutral-400));box-shadow:none;transform:none;cursor:not-allowed}.ios-btn-secondary{background:rgb(var(--color-surface-subtle));color:rgb(var(--color-ink));font-weight:600;border:1px solid var(--color-transparent);transition:all .2s ease;cursor:pointer}.ios-btn-secondary:hover{background:rgb(var(--color-neutral-200));border-color:rgb(var(--color-neutral-300))}.ios-btn-danger{background:rgb(var(--color-danger-100));color:rgb(var(--color-danger-600));font-weight:600;border:1px solid var(--color-transparent);transition:all .2s ease;cursor:pointer}.ios-btn-danger:hover{background:rgb(var(--color-danger-200));border-color:rgb(var(--color-danger-300))}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:var(--color-transparent)}::-webkit-scrollbar-thumb{background:rgb(var(--color-black) / .1);border-radius:10px}::-webkit-scrollbar-thumb:hover{background:rgb(var(--color-black) / .2)}@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:rgb(var(--color-brand));color:rgb(var(--color-white))}::selection{background:rgb(var(--color-brand));color:rgb(var(--color-white))}.text-brand{color:rgb(var(--color-brand))}.bg-brand{background-color:rgb(var(--color-brand))}.border-brand{border-color:rgb(var(--color-brand))}.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:rgb(var(--color-success-100));color:rgb(var(--color-success-800))}.status-badge-warning{background-color:rgb(var(--color-warning-100));color:rgb(var(--color-warning-800))}.status-badge-error{background-color:rgb(var(--color-danger-100));color:rgb(var(--color-danger-800))}.status-badge-info{background-color:rgb(var(--color-info-100));color:rgb(var(--color-info-800))}.loading-skeleton{background:linear-gradient(90deg,rgb(var(--color-neutral-100)),rgb(var(--color-neutral-200)),rgb(var(--color-neutral-100)));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:rgb(var(--color-black) / .4);-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:rgb(var(--color-white));border-radius:10px;box-shadow:var(--shadow-modal);overflow:hidden}.modal-header{flex-shrink:0;padding:2rem 2rem 1.5rem;border-bottom:1px solid rgb(var(--color-neutral-100));background-color:rgb(var(--color-white));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 rgb(var(--color-neutral-100));background-color:rgb(var(--color-white));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:rgb(var(--color-black) / .4);-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:rgb(var(--color-white));border-radius:10px;box-shadow:var(--shadow-modal);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}}.placeholder\:text-slate-400::-moz-placeholder{--tw-text-opacity: 1;color:rgb(var(--color-slate-400) / var(--tw-text-opacity, 1))}.placeholder\:text-slate-400::placeholder{--tw-text-opacity: 1;color:rgb(var(--color-slate-400) / var(--tw-text-opacity, 1))}.focus-within\:border-sky-400:focus-within{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-400) / var(--tw-border-opacity, 1))}.focus-within\:ring-2:focus-within{--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-within\:ring-sky-100:focus-within{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-brand-100) / var(--tw-ring-opacity, 1))}.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-blue-300:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-300) / var(--tw-border-opacity, 1))}.hover\:border-brand:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-brand) / var(--tw-border-opacity, 1))}.hover\:border-emerald-300:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-success-300) / var(--tw-border-opacity, 1))}.hover\:border-gray-400:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-400) / var(--tw-border-opacity, 1))}.hover\:border-sky-200:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-200) / var(--tw-border-opacity, 1))}.hover\:bg-amber-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-100) / var(--tw-bg-opacity, 1))}.hover\:bg-black:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-black) / var(--tw-bg-opacity, 1))}.hover\:bg-blue-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.hover\:bg-blue-700:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-700) / var(--tw-bg-opacity, 1))}.hover\:bg-brand:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand) / var(--tw-bg-opacity, 1))}.hover\:bg-brand-highlight:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-highlight) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50\/50:hover{background-color:rgb(var(--color-success-50) / .5)}.hover\:bg-emerald-600:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-600) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-700:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-700) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-100) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-200:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-200) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-50) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-800:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-800) / var(--tw-bg-opacity, 1))}.hover\:bg-green-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.hover\:bg-purple-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-100) / var(--tw-bg-opacity, 1))}.hover\:bg-red-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-100) / var(--tw-bg-opacity, 1))}.hover\:bg-red-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-50) / var(--tw-bg-opacity, 1))}.hover\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-700) / var(--tw-bg-opacity, 1))}.hover\:bg-sky-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.hover\:bg-sky-600:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-600) / var(--tw-bg-opacity, 1))}.hover\:bg-slate-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-100) / var(--tw-bg-opacity, 1))}.hover\:bg-warning-50\/50:hover{background-color:rgb(var(--color-warning-50) / .5)}.hover\:bg-white:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-white) / var(--tw-bg-opacity, 1))}.hover\:bg-white\/10:hover{background-color:rgb(var(--color-white) / .1)}.hover\:bg-white\/80:hover{background-color:rgb(var(--color-white) / .8)}.hover\:text-black:hover{--tw-text-opacity: 1;color:rgb(var(--color-black) / var(--tw-text-opacity, 1))}.hover\:text-blue-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.hover\:text-brand:hover{--tw-text-opacity: 1;color:rgb(var(--color-brand) / var(--tw-text-opacity, 1))}.hover\:text-gray-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-neutral-600) / var(--tw-text-opacity, 1))}.hover\:text-gray-700:hover{--tw-text-opacity: 1;color:rgb(var(--color-neutral-700) / var(--tw-text-opacity, 1))}.hover\:text-gray-900:hover{--tw-text-opacity: 1;color:rgb(var(--color-neutral-900) / var(--tw-text-opacity, 1))}.hover\:text-green-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-success-600) / var(--tw-text-opacity, 1))}.hover\:text-red-500:hover{--tw-text-opacity: 1;color:rgb(var(--color-danger-500) / var(--tw-text-opacity, 1))}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-danger-600) / var(--tw-text-opacity, 1))}.hover\:text-sky-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.hover\:text-slate-700:hover{--tw-text-opacity: 1;color:rgb(var(--color-slate-700) / var(--tw-text-opacity, 1))}.hover\:text-slate-900:hover{--tw-text-opacity: 1;color:rgb(var(--color-slate-900) / var(--tw-text-opacity, 1))}.hover\:text-white:hover{--tw-text-opacity: 1;color:rgb(var(--color-white) / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:shadow-lg:hover{--tw-shadow: var(--shadow-lg);--tw-shadow-colored: var(--shadow-lg);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(var(--color-brand-400) / var(--tw-border-opacity, 1))}.focus\:border-sky-400:focus{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-400) / var(--tw-border-opacity, 1))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.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-brand:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-brand) / var(--tw-ring-opacity, 1))}.focus\:ring-sky-100:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-brand-100) / 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\:bg-red-400:disabled{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-400) / var(--tw-bg-opacity, 1))}.disabled\:bg-slate-300:disabled{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-300) / var(--tw-bg-opacity, 1))}.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}.disabled\:shadow-none:disabled{--tw-shadow: var(--shadow-none);--tw-shadow-colored: var(--shadow-none);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.group:focus-within .group-focus-within\:text-black{--tw-text-opacity: 1;color:rgb(var(--color-black) / 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(var(--color-white) / var(--tw-bg-opacity, 1))}.group:hover .group-hover\:text-slate-700{--tw-text-opacity: 1;color:rgb(var(--color-slate-700) / var(--tw-text-opacity, 1))}.group:hover .group-hover\:opacity-100{opacity:1}@media(min-width:640px){.sm\:w-48{width:12rem}.sm\:w-64{width:16rem}.sm\:w-72{width:18rem}.sm\:max-w-sm{max-width:24rem}.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-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\:flex-wrap{flex-wrap:wrap}.sm\:items-center{align-items:center}.sm\:justify-between{justify-content:space-between}.sm\:gap-8{gap:2rem}}@media(min-width:768px){.md\:col-span-2{grid-column:span 2 / span 2}.md\:col-span-3{grid-column:span 3 / span 3}.md\:col-span-full{grid-column:1 / -1}.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\:p-6{padding:1.5rem}.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}}@media(min-width:1280px){.xl\:w-36{width:9rem}.xl\:w-52{width:13rem}.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.xl\:grid-cols-\[minmax\(270px\,0\.72fr\)_minmax\(0\,1\.28fr\)\]{grid-template-columns:minmax(270px,.72fr) minmax(0,1.28fr)}.xl\:flex-row{flex-direction:row}.xl\:items-end{align-items:flex-end}.xl\:items-center{align-items:center}.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/index-Dptuvwg-.css b/internal/webui/static/assets/index-Dptuvwg-.css new file mode 100644 index 0000000..27964a1 --- /dev/null +++ b/internal/webui/static/assets/index-Dptuvwg-.css @@ -0,0 +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(147 197 253 / .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(147 197 253 / .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:rgb(var(--color-neutral-200) / 1)}: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:rgb(var(--color-neutral-400) / 1)}input::placeholder,textarea::placeholder{opacity:1;color:rgb(var(--color-neutral-400) / 1)}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}.container{width:100%}@media(min-width:640px){.container{max-width:640px}}@media(min-width:768px){.container{max-width:768px}}@media(min-width:1024px){.container{max-width:1024px}}@media(min-width:1280px){.container{max-width:1280px}}@media(min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.-inset-1{top:-.25rem;right:-.25rem;bottom:-.25rem;left:-.25rem}.inset-0{top:0;right:0;bottom:0;left:0}.inset-y-0{top:0;bottom:0}.-bottom-1{bottom:-.25rem}.-right-1{right:-.25rem}.-right-12{right:-3rem}.-right-6{right:-1.5rem}.-top-16{top:-4rem}.-top-6{top:-1.5rem}.bottom-10{bottom:2.5rem}.bottom-11{bottom:2.75rem}.bottom-8{bottom:2rem}.bottom-\[-10\%\]{bottom:-10%}.left-0{left:0}.left-1{left:.25rem}.left-1\.5{left:.375rem}.left-1\/2{left:50%}.left-3{left:.75rem}.left-4{left:1rem}.left-5{left:1.25rem}.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-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}.m-2{margin:.5rem}.mx-0\.5{margin-left:.125rem;margin-right:.125rem}.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-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-16{margin-left:4rem}.ml-64{margin-left:16rem}.ml-auto{margin-left:auto}.mr-2{margin-right:.5rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.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}.line-clamp-3{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.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-1\.5{height:.375rem}.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{height:.5rem}.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-36{height:9rem}.h-4{height:1rem}.h-40{height:10rem}.h-48{height:12rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-80{height:20rem}.h-9{height:2.25rem}.h-\[18px\]{height:18px}.h-\[19px\]{height:19px}.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-\[calc\(100vh-4rem\)\]{height:calc(100vh - 4rem)}.h-auto{height:auto}.h-fit{height:-moz-fit-content;height:fit-content}.h-full{height:100%}.h-screen{height:100vh}.max-h-32{max-height:8rem}.max-h-44{max-height:11rem}.max-h-48{max-height:12rem}.max-h-64{max-height:16rem}.max-h-72{max-height:18rem}.max-h-80{max-height:20rem}.max-h-\[380px\]{max-height:380px}.max-h-\[400px\]{max-height:400px}.max-h-\[420px\]{max-height:420px}.max-h-\[min\(64vh\,28rem\)\]{max-height:min(64vh,28rem)}.min-h-0{min-height:0px}.min-h-12{min-height:3rem}.min-h-36{min-height:9rem}.min-h-56{min-height:14rem}.min-h-64{min-height:16rem}.min-h-\[120px\]{min-height:120px}.min-h-\[150px\]{min-height:150px}.min-h-\[400px\]{min-height:400px}.min-h-\[42px\]{min-height:42px}.min-h-\[46px\]{min-height:46px}.min-h-\[560px\]{min-height:560px}.min-h-screen{min-height:100vh}.w-1\.5{width:.375rem}.w-10{width:2.5rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-2{width:.5rem}.w-2\.5{width:.625rem}.w-20{width:5rem}.w-24{width:6rem}.w-28{width:7rem}.w-3{width:.75rem}.w-3\.5{width:.875rem}.w-32{width:8rem}.w-36{width:9rem}.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-\[18px\]{width:18px}.w-\[19\%\]{width:19%}.w-\[19px\]{width:19px}.w-\[23\%\]{width:23%}.w-\[27\%\]{width:27%}.w-\[360px\]{width:360px}.w-\[60\%\]{width:60%}.w-\[7\%\]{width:7%}.w-\[8\%\]{width:8%}.w-\[800px\]{width:800px}.w-\[9\%\]{width:9%}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.w-px{width:1px}.min-w-0{min-width:0px}.min-w-5{min-width:1.25rem}.min-w-9{min-width:2.25rem}.min-w-\[150px\]{min-width:150px}.min-w-\[200px\]{min-width:200px}.min-w-\[210px\]{min-width:210px}.min-w-\[260px\]{min-width:260px}.min-w-\[760px\]{min-width:760px}.max-w-36{max-width:9rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-72{max-width:18rem}.max-w-\[12rem\]{max-width:12rem}.max-w-\[1400px\]{max-width:1400px}.max-w-\[15rem\]{max-width:15rem}.max-w-\[1680px\]{max-width:1680px}.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-\[400px\]{max-width:400px}.max-w-\[72\%\]{max-width:72%}.max-w-\[80px\]{max-width:80px}.max-w-\[82\%\]{max-width:82%}.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{flex-shrink:0}.shrink{flex-shrink:1}.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-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))}.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}.list-inside{list-style-position:inside}.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))}.grid-cols-8{grid-template-columns:repeat(8,minmax(0,1fr))}.grid-cols-\[320px_minmax\(0\,1fr\)\]{grid-template-columns:320px 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}.items-baseline{align-items:baseline}.justify-start{justify-content:flex-start}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-2\.5{gap:.625rem}.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(var(--color-neutral-50) / var(--tw-divide-opacity, 1))}.self-start{align-self:flex-start}.self-center{align-self:center}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overflow-x-hidden{overflow-x:hidden}.overscroll-contain{overscroll-behavior:contain}.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}.rounded-bl-md{border-bottom-left-radius:6px}.rounded-br-md{border-bottom-right-radius:6px}.border{border-width:1px}.border-0{border-width:0px}.border-2{border-width:2px}.border-4{border-width:4px}.border-y{border-top-width:1px;border-bottom-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-none{border-style:none}.border-amber-200{--tw-border-opacity: 1;border-color:rgb(var(--color-warning-200) / var(--tw-border-opacity, 1))}.border-blue-100{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-100) / var(--tw-border-opacity, 1))}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-200) / var(--tw-border-opacity, 1))}.border-emerald-100{--tw-border-opacity: 1;border-color:rgb(var(--color-success-100) / var(--tw-border-opacity, 1))}.border-gray-100{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-100) / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-200) / var(--tw-border-opacity, 1))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-300) / var(--tw-border-opacity, 1))}.border-gray-50{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-50) / var(--tw-border-opacity, 1))}.border-purple-100{--tw-border-opacity: 1;border-color:rgb(var(--color-accent-100) / var(--tw-border-opacity, 1))}.border-red-100{--tw-border-opacity: 1;border-color:rgb(var(--color-danger-100) / var(--tw-border-opacity, 1))}.border-sky-100{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-100) / var(--tw-border-opacity, 1))}.border-sky-200{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-200) / var(--tw-border-opacity, 1))}.border-sky-500{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-500) / var(--tw-border-opacity, 1))}.border-slate-100{--tw-border-opacity: 1;border-color:rgb(var(--color-slate-100) / var(--tw-border-opacity, 1))}.border-slate-200{--tw-border-opacity: 1;border-color:rgb(var(--color-slate-200) / var(--tw-border-opacity, 1))}.border-slate-200\/80{border-color:rgb(var(--color-slate-200) / .8)}.border-transparent{border-color:var(--color-transparent)}.border-white{--tw-border-opacity: 1;border-color:rgb(var(--color-white) / var(--tw-border-opacity, 1))}.border-white\/10{border-color:rgb(var(--color-white) / .1)}.border-white\/80{border-color:rgb(var(--color-white) / .8)}.bg-amber-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-100) / var(--tw-bg-opacity, 1))}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-50) / var(--tw-bg-opacity, 1))}.bg-amber-50\/70{background-color:rgb(var(--color-warning-50) / .7)}.bg-amber-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-500) / var(--tw-bg-opacity, 1))}.bg-black{--tw-bg-opacity: 1;background-color:rgb(var(--color-black) / var(--tw-bg-opacity, 1))}.bg-black\/50{background-color:rgb(var(--color-black) / .5)}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-100) / var(--tw-bg-opacity, 1))}.bg-blue-200\/30{background-color:rgb(var(--color-brand-200) / .3)}.bg-blue-200\/40{background-color:rgb(var(--color-brand-200) / .4)}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-400) / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.bg-blue-50\/50{background-color:rgb(var(--color-brand-50) / .5)}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-500) / var(--tw-bg-opacity, 1))}.bg-blue-500\/20{background-color:rgb(var(--color-brand-500) / .2)}.bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-600) / var(--tw-bg-opacity, 1))}.bg-brand{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand) / var(--tw-bg-opacity, 1))}.bg-canvas{--tw-bg-opacity: 1;background-color:rgb(var(--color-canvas) / var(--tw-bg-opacity, 1))}.bg-danger-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-500) / var(--tw-bg-opacity, 1))}.bg-emerald-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.bg-emerald-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-500) / var(--tw-bg-opacity, 1))}.bg-emerald-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-600) / var(--tw-bg-opacity, 1))}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-100) / var(--tw-bg-opacity, 1))}.bg-gray-100\/50{background-color:rgb(var(--color-neutral-100) / .5)}.bg-gray-200{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-200) / var(--tw-bg-opacity, 1))}.bg-gray-300{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-300) / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-50) / var(--tw-bg-opacity, 1))}.bg-gray-50\/70{background-color:rgb(var(--color-neutral-50) / .7)}.bg-gray-50\/80{background-color:rgb(var(--color-neutral-50) / .8)}.bg-gray-900{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-900) / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-500) / var(--tw-bg-opacity, 1))}.bg-pink-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-50) / var(--tw-bg-opacity, 1))}.bg-purple-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-100) / var(--tw-bg-opacity, 1))}.bg-purple-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-50) / var(--tw-bg-opacity, 1))}.bg-purple-50\/50{background-color:rgb(var(--color-accent-50) / .5)}.bg-purple-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-500) / var(--tw-bg-opacity, 1))}.bg-purple-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-600) / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-100) / var(--tw-bg-opacity, 1))}.bg-red-200\/35{background-color:rgb(var(--color-danger-200) / .35)}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-50) / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-500) / var(--tw-bg-opacity, 1))}.bg-red-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-600) / var(--tw-bg-opacity, 1))}.bg-sky-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-100) / var(--tw-bg-opacity, 1))}.bg-sky-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.bg-sky-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-500) / var(--tw-bg-opacity, 1))}.bg-slate-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-100) / var(--tw-bg-opacity, 1))}.bg-slate-200{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-200) / var(--tw-bg-opacity, 1))}.bg-slate-300{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-300) / var(--tw-bg-opacity, 1))}.bg-slate-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-50) / var(--tw-bg-opacity, 1))}.bg-slate-50\/40{background-color:rgb(var(--color-slate-50) / .4)}.bg-slate-50\/70{background-color:rgb(var(--color-slate-50) / .7)}.bg-slate-900{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-900) / var(--tw-bg-opacity, 1))}.bg-success-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-500) / var(--tw-bg-opacity, 1))}.bg-surface{--tw-bg-opacity: 1;background-color:rgb(var(--color-surface) / var(--tw-bg-opacity, 1))}.bg-surface-muted{--tw-bg-opacity: 1;background-color:rgb(var(--color-surface-muted) / var(--tw-bg-opacity, 1))}.bg-surface-subtle{--tw-bg-opacity: 1;background-color:rgb(var(--color-surface-subtle) / var(--tw-bg-opacity, 1))}.bg-transparent{background-color:var(--color-transparent)}.bg-white{--tw-bg-opacity: 1;background-color:rgb(var(--color-white) / var(--tw-bg-opacity, 1))}.bg-white\/5{background-color:rgb(var(--color-white) / .05)}.bg-white\/80{background-color:rgb(var(--color-white) / .8)}.bg-white\/90{background-color:rgb(var(--color-white) / .9)}.bg-white\/95{background-color:rgb(var(--color-white) / .95)}.bg-opacity-10{--tw-bg-opacity: .1}.bg-gradient-to-bl{background-image:linear-gradient(to bottom left,var(--tw-gradient-stops))}.bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--tw-gradient-stops))}.from-blue-50{--tw-gradient-from: rgb(var(--color-brand-50) / 1) var(--tw-gradient-from-position);--tw-gradient-to: rgb(var(--color-brand-50) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-red-50{--tw-gradient-from: rgb(var(--color-danger-50) / 1) var(--tw-gradient-from-position);--tw-gradient-to: rgb(var(--color-danger-50) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.via-white{--tw-gradient-to: rgb(var(--color-white) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), rgb(var(--color-white) / 1) var(--tw-gradient-via-position), var(--tw-gradient-to)}.to-orange-50{--tw-gradient-to: rgb(var(--color-warning-50) / 1) var(--tw-gradient-to-position)}.to-transparent{--tw-gradient-to: var(--color-transparent) var(--tw-gradient-to-position)}.object-contain{-o-object-fit:contain;object-fit:contain}.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{padding-left:.25rem;padding-right:.25rem}.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-3\.5{padding-left:.875rem;padding-right:.875rem}.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-12{padding-top:3rem;padding-bottom:3rem}.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-0{padding-bottom:0}.pb-1{padding-bottom:.25rem}.pb-10{padding-bottom:2.5rem}.pb-24{padding-bottom:6rem}.pb-9{padding-bottom:2.25rem}.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-9{padding-left:2.25rem}.pr-10{padding-right:2.5rem}.pr-11{padding-right:2.75rem}.pr-12{padding-right:3rem}.pr-2{padding-right:.5rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pr-6{padding-right:1.5rem}.pr-9{padding-right:2.25rem}.pt-3{padding-top:.75rem}.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}.align-middle{vertical-align:middle}.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-\[13px\]{font-size:13px}.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}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.tabular-nums{--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-6{line-height:1.5rem}.leading-none{line-height:1}.leading-relaxed{line-height:1.625}.leading-tight{line-height:1.25}.tracking-\[0\.18em\]{letter-spacing:.18em}.tracking-\[0\.22em\]{letter-spacing:.22em}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.tracking-widest{letter-spacing:.1em}.text-amber-600{--tw-text-opacity: 1;color:rgb(var(--color-warning-600) / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(var(--color-warning-700) / var(--tw-text-opacity, 1))}.text-amber-800{--tw-text-opacity: 1;color:rgb(var(--color-warning-800) / var(--tw-text-opacity, 1))}.text-amber-900{--tw-text-opacity: 1;color:rgb(var(--color-warning-900) / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(var(--color-brand-700) / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(var(--color-brand-800) / var(--tw-text-opacity, 1))}.text-blue-900{--tw-text-opacity: 1;color:rgb(var(--color-brand-900) / var(--tw-text-opacity, 1))}.text-blue-950{--tw-text-opacity: 1;color:rgb(var(--color-brand-950) / var(--tw-text-opacity, 1))}.text-brand{--tw-text-opacity: 1;color:rgb(var(--color-brand) / var(--tw-text-opacity, 1))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(var(--color-success-600) / var(--tw-text-opacity, 1))}.text-emerald-700{--tw-text-opacity: 1;color:rgb(var(--color-success-700) / var(--tw-text-opacity, 1))}.text-gray-100{--tw-text-opacity: 1;color:rgb(var(--color-neutral-100) / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(var(--color-neutral-300) / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(var(--color-neutral-400) / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(var(--color-neutral-500) / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(var(--color-neutral-600) / var(--tw-text-opacity, 1))}.text-gray-700{--tw-text-opacity: 1;color:rgb(var(--color-neutral-700) / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(var(--color-neutral-800) / var(--tw-text-opacity, 1))}.text-gray-900{--tw-text-opacity: 1;color:rgb(var(--color-neutral-900) / var(--tw-text-opacity, 1))}.text-gray-950{--tw-text-opacity: 1;color:rgb(var(--color-neutral-950) / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(var(--color-success-600) / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(var(--color-success-700) / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(var(--color-success-800) / var(--tw-text-opacity, 1))}.text-ink{--tw-text-opacity: 1;color:rgb(var(--color-ink) / var(--tw-text-opacity, 1))}.text-pink-600{--tw-text-opacity: 1;color:rgb(var(--color-accent-600) / var(--tw-text-opacity, 1))}.text-purple-500{--tw-text-opacity: 1;color:rgb(var(--color-accent-500) / var(--tw-text-opacity, 1))}.text-purple-600{--tw-text-opacity: 1;color:rgb(var(--color-accent-600) / var(--tw-text-opacity, 1))}.text-purple-700{--tw-text-opacity: 1;color:rgb(var(--color-accent-700) / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(var(--color-danger-500) / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(var(--color-danger-600) / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(var(--color-danger-700) / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(var(--color-danger-800) / var(--tw-text-opacity, 1))}.text-sky-500{--tw-text-opacity: 1;color:rgb(var(--color-brand-500) / var(--tw-text-opacity, 1))}.text-sky-600{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.text-sky-700{--tw-text-opacity: 1;color:rgb(var(--color-brand-700) / var(--tw-text-opacity, 1))}.text-sky-800{--tw-text-opacity: 1;color:rgb(var(--color-brand-800) / var(--tw-text-opacity, 1))}.text-sky-900{--tw-text-opacity: 1;color:rgb(var(--color-brand-900) / var(--tw-text-opacity, 1))}.text-slate-300{--tw-text-opacity: 1;color:rgb(var(--color-slate-300) / var(--tw-text-opacity, 1))}.text-slate-400{--tw-text-opacity: 1;color:rgb(var(--color-slate-400) / var(--tw-text-opacity, 1))}.text-slate-500{--tw-text-opacity: 1;color:rgb(var(--color-slate-500) / var(--tw-text-opacity, 1))}.text-slate-600{--tw-text-opacity: 1;color:rgb(var(--color-slate-600) / var(--tw-text-opacity, 1))}.text-slate-700{--tw-text-opacity: 1;color:rgb(var(--color-slate-700) / var(--tw-text-opacity, 1))}.text-slate-800{--tw-text-opacity: 1;color:rgb(var(--color-slate-800) / var(--tw-text-opacity, 1))}.text-slate-900{--tw-text-opacity: 1;color:rgb(var(--color-slate-900) / var(--tw-text-opacity, 1))}.text-slate-950{--tw-text-opacity: 1;color:rgb(var(--color-slate-950) / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(var(--color-white) / var(--tw-text-opacity, 1))}.underline{text-decoration-line:underline}.accent-brand{accent-color:rgb(var(--color-brand) / 1)}.opacity-0{opacity:0}.opacity-10{opacity:.1}.opacity-25{opacity:.25}.opacity-30{opacity:.3}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.shadow-2xl{--tw-shadow: var(--shadow-2xl);--tw-shadow-colored: var(--shadow-2xl);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-brand-active{--tw-shadow: var(--shadow-brand-active);--tw-shadow-colored: var(--shadow-brand-active);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-chat{--tw-shadow: var(--shadow-chat);--tw-shadow-colored: var(--shadow-chat);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-chat-active{--tw-shadow: var(--shadow-chat-active);--tw-shadow-colored: var(--shadow-chat-active);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-chat-input{--tw-shadow: var(--shadow-chat-input);--tw-shadow-colored: var(--shadow-chat-input);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-inner{--tw-shadow: var(--shadow-inner);--tw-shadow-colored: var(--shadow-inner);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: var(--shadow-lg);--tw-shadow-colored: var(--shadow-lg);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: var(--shadow-md);--tw-shadow-colored: var(--shadow-md);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-modal{--tw-shadow: var(--shadow-modal);--tw-shadow-colored: var(--shadow-modal);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-panel{--tw-shadow: var(--shadow-panel);--tw-shadow-colored: var(--shadow-panel);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sidebar{--tw-shadow: var(--shadow-sidebar);--tw-shadow-colored: var(--shadow-sidebar);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: var(--shadow-sm);--tw-shadow-colored: var(--shadow-sm);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: var(--shadow-xl);--tw-shadow-colored: var(--shadow-xl);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: rgb(var(--color-brand-100) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-blue-200{--tw-shadow-color: rgb(var(--color-brand-200) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-emerald-100{--tw-shadow-color: rgb(var(--color-success-100) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200{--tw-shadow-color: rgb(var(--color-neutral-200) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200\/70{--tw-shadow-color: rgb(var(--color-neutral-200) / .7);--tw-shadow: var(--tw-shadow-colored)}.shadow-red-200{--tw-shadow-color: rgb(var(--color-danger-200) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-sky-100{--tw-shadow-color: rgb(var(--color-brand-100) / 1);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.ring-1{--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(1px + 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-2{--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)}.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-gray-200{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-neutral-200) / var(--tw-ring-opacity, 1))}.ring-white{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-white) / var(--tw-ring-opacity, 1))}.blur{--tw-blur: blur(8px);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-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)}.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)}.backdrop-blur-xl{--tw-backdrop-blur: blur(24px);-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{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[margin\]{transition-property:margin;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[width\]{transition-property:width;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.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-300{transition-duration:.3s}.duration-500{transition-duration:.5s}:root{--color-transparent: transparent;--color-black: 0 0 0;--color-white: 255 255 255;--color-brand: 0 148 247;--color-brand-highlight: 0 113 227;--color-brand-light: 40 126 254;--color-ink: 29 29 31;--color-muted: 134 134 139;--color-line: 210 210 215;--color-canvas: 244 245 247;--color-surface: 255 255 255;--color-surface-subtle: 247 248 250;--color-surface-muted: 250 250 250;--color-neutral-50: 249 250 251;--color-neutral-100: 243 244 246;--color-neutral-200: 229 231 235;--color-neutral-300: 209 213 219;--color-neutral-400: 156 163 175;--color-neutral-500: 107 114 128;--color-neutral-600: 75 85 99;--color-neutral-700: 55 65 81;--color-neutral-800: 31 41 55;--color-neutral-900: 17 24 39;--color-neutral-950: 3 7 18;--color-slate-50: 248 250 252;--color-slate-100: 241 245 249;--color-slate-200: 226 232 240;--color-slate-300: 203 213 225;--color-slate-400: 148 163 184;--color-slate-500: 100 116 139;--color-slate-600: 71 85 105;--color-slate-700: 51 65 85;--color-slate-800: 30 41 59;--color-slate-900: 15 23 42;--color-slate-950: 2 6 23;--color-brand-50: 239 248 255;--color-brand-100: 223 241 255;--color-brand-200: 191 229 255;--color-brand-300: 143 210 255;--color-brand-400: 83 184 251;--color-brand-500: 0 148 247;--color-brand-600: 0 148 247;--color-brand-700: 0 113 227;--color-brand-800: 0 91 181;--color-brand-900: 0 75 147;--color-brand-950: 0 53 107;--color-success-50: 236 253 245;--color-success-100: 209 250 229;--color-success-200: 167 243 208;--color-success-300: 110 231 183;--color-success-400: 52 211 153;--color-success-500: 16 185 129;--color-success-600: 5 150 105;--color-success-700: 4 120 87;--color-success-800: 6 95 70;--color-success-900: 6 78 59;--color-success-950: 2 44 34;--color-warning-50: 255 251 235;--color-warning-100: 254 243 199;--color-warning-200: 253 230 138;--color-warning-300: 252 211 77;--color-warning-400: 251 191 36;--color-warning-500: 245 158 11;--color-warning-600: 217 119 6;--color-warning-700: 180 83 9;--color-warning-800: 146 64 14;--color-warning-900: 120 53 15;--color-warning-950: 69 26 3;--color-danger-50: 254 242 242;--color-danger-100: 254 226 226;--color-danger-200: 254 202 202;--color-danger-300: 252 165 165;--color-danger-400: 248 113 113;--color-danger-500: 239 68 68;--color-danger-600: 220 38 38;--color-danger-700: 185 28 28;--color-danger-800: 153 27 27;--color-danger-900: 127 29 29;--color-danger-950: 69 10 10;--color-info-50: 239 246 255;--color-info-100: 219 234 254;--color-info-200: 191 219 254;--color-info-300: 147 197 253;--color-info-400: 96 165 250;--color-info-500: 59 130 246;--color-info-600: 37 99 235;--color-info-700: 29 78 216;--color-info-800: 30 64 175;--color-info-900: 30 58 138;--color-info-950: 23 37 84;--color-accent-50: 250 245 255;--color-accent-100: 243 232 255;--color-accent-200: 233 213 255;--color-accent-300: 216 180 254;--color-accent-400: 192 132 252;--color-accent-500: 168 85 247;--color-accent-600: 147 51 234;--color-accent-700: 126 34 206;--color-accent-800: 107 33 168;--color-accent-900: 88 28 135;--color-accent-950: 59 7 100;--shadow-none: 0 0 0 var(--color-transparent);--shadow-default: 0 1px 3px 0 rgb(var(--color-black) / .1), 0 1px 2px -1px rgb(var(--color-black) / .1);--shadow-sm: 0 1px 2px 0 rgb(var(--color-black) / .05);--shadow-md: 0 4px 6px -1px rgb(var(--color-black) / .1), 0 2px 4px -2px rgb(var(--color-black) / .1);--shadow-lg: 0 10px 15px -3px rgb(var(--color-black) / .1), 0 4px 6px -4px rgb(var(--color-black) / .1);--shadow-xl: 0 20px 25px -5px rgb(var(--color-black) / .1), 0 8px 10px -6px rgb(var(--color-black) / .1);--shadow-2xl: 0 25px 50px -12px rgb(var(--color-black) / .25);--shadow-inner: inset 0 2px 4px 0 rgb(var(--color-black) / .05);--shadow-card: 0 8px 24px rgb(var(--color-black) / .04);--shadow-panel: 0 20px 60px -15px rgb(var(--color-black) / .05);--shadow-modal: 0 25px 50px -12px rgb(var(--color-black) / .25);--shadow-sidebar: 4px 0 24px rgb(var(--color-slate-900) / .035);--shadow-chat: 0 16px 45px rgb(var(--color-slate-900) / .06);--shadow-chat-input: 0 -8px 24px rgb(var(--color-slate-900) / .04);--shadow-chat-active: inset 3px 0 0 rgb(var(--color-brand));--shadow-brand-soft: 0 2px 8px rgb(var(--color-brand) / .2);--shadow-brand-active: 0 8px 18px rgb(var(--color-brand) / .2);--shadow-brand-strong: 0 8px 20px rgb(var(--color-brand) / .3)}*,:before,:after{--tw-ring-offset-color: rgb(var(--color-white));--tw-ring-color: rgb(var(--color-brand-400) / .5);--tw-ring-offset-shadow: 0 0 0 var(--color-transparent);--tw-ring-shadow: 0 0 0 var(--color-transparent);--tw-shadow: 0 0 0 var(--color-transparent);--tw-shadow-colored: 0 0 0 var(--color-transparent)}.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:rgb(var(--color-canvas));color:rgb(var(--color-ink));-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ios-card{background:rgb(var(--color-surface));border-radius:8px;border:1px solid rgb(var(--color-black) / .02);box-shadow:var(--shadow-card);transition:transform .2s ease,box-shadow .2s ease}.ios-card:hover{box-shadow:0 12px 32px rgb(var(--color-black) / .06)}.dashboard-pie-chart .recharts-surface:focus,.dashboard-pie-chart .recharts-pie:focus,.dashboard-pie-chart .recharts-pie-sector:focus,.dashboard-pie-chart .recharts-sector:focus{outline:none}.dashboard-revenue-chart .recharts-surface:focus,.dashboard-revenue-chart .recharts-bar-rectangle:focus,.dashboard-revenue-chart .recharts-rectangle:focus,.dashboard-revenue-chart .recharts-curve:focus,.dashboard-revenue-chart .recharts-dot:focus,.dashboard-revenue-chart [class*=recharts-zIndex-layer_]:focus{outline:none!important}.dashboard-revenue-chart .recharts-bar-rectangle,.dashboard-revenue-chart .recharts-rectangle{stroke:none!important}.ios-input{background:rgb(var(--color-surface-subtle));border:1px solid var(--color-transparent);transition:all .3s cubic-bezier(.25,.8,.25,1);color:rgb(var(--color-ink));font-weight:500}.ios-input:focus{background:rgb(var(--color-surface));border-color:rgb(var(--color-brand));box-shadow:0 0 0 4px rgb(var(--color-brand) / .3);outline:none}.ios-input::-moz-placeholder{color:rgb(var(--color-neutral-400));font-weight:400}.ios-input::placeholder{color:rgb(var(--color-neutral-400));font-weight:400}.ios-btn-primary{background:rgb(var(--color-brand));color:rgb(var(--color-white));font-weight:700;border:none;transition:all .2s cubic-bezier(.25,.8,.25,1);cursor:pointer}.ios-btn-primary:hover:not(:disabled){background:rgb(var(--color-brand-highlight));transform:translateY(-1px);box-shadow:var(--shadow-brand-strong)}.ios-btn-primary:active:not(:disabled){transform:translateY(1px);box-shadow:var(--shadow-brand-soft)}.ios-btn-primary:disabled{background:rgb(var(--color-neutral-100));color:rgb(var(--color-neutral-400));box-shadow:none;transform:none;cursor:not-allowed}.ios-btn-secondary{background:rgb(var(--color-surface-subtle));color:rgb(var(--color-ink));font-weight:600;border:1px solid var(--color-transparent);transition:all .2s ease;cursor:pointer}.ios-btn-secondary:hover{background:rgb(var(--color-neutral-200));border-color:rgb(var(--color-neutral-300))}.ios-btn-danger{background:rgb(var(--color-danger-100));color:rgb(var(--color-danger-600));font-weight:600;border:1px solid var(--color-transparent);transition:all .2s ease;cursor:pointer}.ios-btn-danger:hover{background:rgb(var(--color-danger-200));border-color:rgb(var(--color-danger-300))}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:var(--color-transparent)}::-webkit-scrollbar-thumb{background:rgb(var(--color-black) / .1);border-radius:10px}::-webkit-scrollbar-thumb:hover{background:rgb(var(--color-black) / .2)}@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:rgb(var(--color-brand));color:rgb(var(--color-white))}::selection{background:rgb(var(--color-brand));color:rgb(var(--color-white))}.text-brand{color:rgb(var(--color-brand))}.bg-brand{background-color:rgb(var(--color-brand))}.border-brand{border-color:rgb(var(--color-brand))}.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:rgb(var(--color-success-100));color:rgb(var(--color-success-800))}.status-badge-warning{background-color:rgb(var(--color-warning-100));color:rgb(var(--color-warning-800))}.status-badge-error{background-color:rgb(var(--color-danger-100));color:rgb(var(--color-danger-800))}.status-badge-info{background-color:rgb(var(--color-info-100));color:rgb(var(--color-info-800))}.loading-skeleton{background:linear-gradient(90deg,rgb(var(--color-neutral-100)),rgb(var(--color-neutral-200)),rgb(var(--color-neutral-100)));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:rgb(var(--color-black) / .4);-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:rgb(var(--color-white));border-radius:10px;box-shadow:var(--shadow-modal);overflow:hidden}.modal-header{flex-shrink:0;padding:2rem 2rem 1.5rem;border-bottom:1px solid rgb(var(--color-neutral-100));background-color:rgb(var(--color-white));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 rgb(var(--color-neutral-100));background-color:rgb(var(--color-white));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:rgb(var(--color-black) / .4);-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:rgb(var(--color-white));border-radius:10px;box-shadow:var(--shadow-modal);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}}.placeholder\:text-slate-400::-moz-placeholder{--tw-text-opacity: 1;color:rgb(var(--color-slate-400) / var(--tw-text-opacity, 1))}.placeholder\:text-slate-400::placeholder{--tw-text-opacity: 1;color:rgb(var(--color-slate-400) / var(--tw-text-opacity, 1))}.focus-within\:border-sky-400:focus-within{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-400) / var(--tw-border-opacity, 1))}.focus-within\:ring-2:focus-within{--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-within\:ring-sky-100:focus-within{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-brand-100) / var(--tw-ring-opacity, 1))}.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-blue-300:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-300) / var(--tw-border-opacity, 1))}.hover\:border-brand:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-brand) / var(--tw-border-opacity, 1))}.hover\:border-emerald-300:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-success-300) / var(--tw-border-opacity, 1))}.hover\:border-gray-400:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-400) / var(--tw-border-opacity, 1))}.hover\:border-sky-200:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-200) / var(--tw-border-opacity, 1))}.hover\:bg-amber-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-100) / var(--tw-bg-opacity, 1))}.hover\:bg-black:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-black) / var(--tw-bg-opacity, 1))}.hover\:bg-blue-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.hover\:bg-blue-700:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-700) / var(--tw-bg-opacity, 1))}.hover\:bg-brand:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand) / var(--tw-bg-opacity, 1))}.hover\:bg-brand-highlight:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-highlight) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50\/50:hover{background-color:rgb(var(--color-success-50) / .5)}.hover\:bg-emerald-600:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-600) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-700:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-700) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-100) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-200:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-200) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-50) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-800:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-800) / var(--tw-bg-opacity, 1))}.hover\:bg-green-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.hover\:bg-purple-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-100) / var(--tw-bg-opacity, 1))}.hover\:bg-red-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-100) / var(--tw-bg-opacity, 1))}.hover\:bg-red-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-50) / var(--tw-bg-opacity, 1))}.hover\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-700) / var(--tw-bg-opacity, 1))}.hover\:bg-sky-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.hover\:bg-sky-600:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-600) / var(--tw-bg-opacity, 1))}.hover\:bg-slate-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-100) / var(--tw-bg-opacity, 1))}.hover\:bg-warning-50\/50:hover{background-color:rgb(var(--color-warning-50) / .5)}.hover\:bg-white:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-white) / var(--tw-bg-opacity, 1))}.hover\:bg-white\/10:hover{background-color:rgb(var(--color-white) / .1)}.hover\:bg-white\/80:hover{background-color:rgb(var(--color-white) / .8)}.hover\:text-black:hover{--tw-text-opacity: 1;color:rgb(var(--color-black) / var(--tw-text-opacity, 1))}.hover\:text-blue-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.hover\:text-brand:hover{--tw-text-opacity: 1;color:rgb(var(--color-brand) / var(--tw-text-opacity, 1))}.hover\:text-gray-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-neutral-600) / var(--tw-text-opacity, 1))}.hover\:text-gray-700:hover{--tw-text-opacity: 1;color:rgb(var(--color-neutral-700) / var(--tw-text-opacity, 1))}.hover\:text-gray-900:hover{--tw-text-opacity: 1;color:rgb(var(--color-neutral-900) / var(--tw-text-opacity, 1))}.hover\:text-green-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-success-600) / var(--tw-text-opacity, 1))}.hover\:text-red-500:hover{--tw-text-opacity: 1;color:rgb(var(--color-danger-500) / var(--tw-text-opacity, 1))}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-danger-600) / var(--tw-text-opacity, 1))}.hover\:text-sky-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.hover\:text-slate-700:hover{--tw-text-opacity: 1;color:rgb(var(--color-slate-700) / var(--tw-text-opacity, 1))}.hover\:text-slate-900:hover{--tw-text-opacity: 1;color:rgb(var(--color-slate-900) / var(--tw-text-opacity, 1))}.hover\:text-white:hover{--tw-text-opacity: 1;color:rgb(var(--color-white) / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:shadow-lg:hover{--tw-shadow: var(--shadow-lg);--tw-shadow-colored: var(--shadow-lg);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(var(--color-brand-400) / var(--tw-border-opacity, 1))}.focus\:border-sky-400:focus{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-400) / var(--tw-border-opacity, 1))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.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-brand:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-brand) / var(--tw-ring-opacity, 1))}.focus\:ring-sky-100:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-brand-100) / 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\:bg-red-400:disabled{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-400) / var(--tw-bg-opacity, 1))}.disabled\:bg-slate-300:disabled{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-300) / var(--tw-bg-opacity, 1))}.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}.disabled\:shadow-none:disabled{--tw-shadow: var(--shadow-none);--tw-shadow-colored: var(--shadow-none);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.group:focus-within .group-focus-within\:text-black{--tw-text-opacity: 1;color:rgb(var(--color-black) / 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(var(--color-white) / var(--tw-bg-opacity, 1))}.group:hover .group-hover\:text-slate-700{--tw-text-opacity: 1;color:rgb(var(--color-slate-700) / var(--tw-text-opacity, 1))}.group:hover .group-hover\:opacity-100{opacity:1}@media(min-width:640px){.sm\:w-48{width:12rem}.sm\:w-64{width:16rem}.sm\:w-72{width:18rem}.sm\:max-w-sm{max-width:24rem}.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-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\:flex-wrap{flex-wrap:wrap}.sm\:items-center{align-items:center}.sm\:justify-between{justify-content:space-between}.sm\:gap-8{gap:2rem}}@media(min-width:768px){.md\:col-span-2{grid-column:span 2 / span 2}.md\:col-span-3{grid-column:span 3 / span 3}.md\:col-span-full{grid-column:1 / -1}.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\:p-6{padding:1.5rem}.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}}@media(min-width:1280px){.xl\:w-36{width:9rem}.xl\:w-52{width:13rem}.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.xl\:grid-cols-\[minmax\(270px\,0\.72fr\)_minmax\(0\,1\.28fr\)\]{grid-template-columns:minmax(270px,.72fr) minmax(0,1.28fr)}.xl\:flex-row{flex-direction:row}.xl\:items-end{align-items:flex-end}.xl\:items-center{align-items:center}.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/index.html b/internal/webui/static/index.html index d970eaf..1915818 100644 --- a/internal/webui/static/index.html +++ b/internal/webui/static/index.html @@ -6,12 +6,12 @@ Ydisks闲鱼助手 - 自动发货与管家系统 - + - +