@minimaxclaw/cli 1.0.44 → 1.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +17 -19
  2. package/package.json +9 -9
  3. package/web/dist/assets/{AssistantsView-Y4TXobGE.js → AssistantsView-Y3nFezhd.js} +1 -1
  4. package/web/dist/assets/AutomationView-bf7_zU_p.js +4 -0
  5. package/web/dist/assets/Button-B43HsIQ3.js +1 -0
  6. package/web/dist/assets/{ChannelConfigView-WJ-zUV8p.js → ChannelConfigView---Dwl3Fk.js} +3 -3
  7. package/web/dist/assets/ChartsView-Dw6G-jf3.js +1 -0
  8. package/web/dist/assets/{ConnectorsView-DaHmxnGE.js → ConnectorsView-BWvdrpyK.js} +2 -2
  9. package/web/dist/assets/{DiffPreview-D8tIj_aF.js → DiffPreview-WQihq3bK.js} +57 -56
  10. package/web/dist/assets/{FileContextMenu-C5WYeBNu.js → FileContextMenu-CyjXlSHp.js} +1 -1
  11. package/web/dist/assets/FileTreeView-Cafy33nT.js +1 -0
  12. package/web/dist/assets/HookConfigView-D-lASVju.js +2 -0
  13. package/web/dist/assets/InboxView-BWajw-Yx.js +1 -0
  14. package/web/dist/assets/InputArea-CSqaA55j.js +31 -0
  15. package/web/dist/assets/Install-ClEm4oGX.js +2 -0
  16. package/web/dist/assets/MemoryView-DLri75dm.js +1 -0
  17. package/web/dist/assets/ModelsView-BBLUMzR5.js +1 -0
  18. package/web/dist/assets/PluginsView-C-fnbDGZ.js +1 -0
  19. package/web/dist/assets/ProjectsView-BruI2W_l.js +1 -0
  20. package/web/dist/assets/{SessionGrid-BQSrCDqQ.js → SessionGrid-7GLpwn6d.js} +4 -4
  21. package/web/dist/assets/SettingsModal-cc9Qu2QU.js +4 -0
  22. package/web/dist/assets/SkillsView-Bf-2-U_q.js +1 -0
  23. package/web/dist/assets/TemplatesTab-CKul8nbL.js +2 -0
  24. package/web/dist/assets/{ToolsView-CjdYiaNz.js → ToolsView-D_aluOsK.js} +1 -1
  25. package/web/dist/assets/WorkspaceDirPicker-Z42YqE4a.js +5 -0
  26. package/web/dist/assets/{agentIconSet-CDeMxTHf.js → agentIconSet-Cqhm4UOl.js} +1 -1
  27. package/web/dist/assets/api-BW4-5gtM.js +1 -0
  28. package/web/dist/assets/chatStore-D8Zzr1hE.js +242 -0
  29. package/web/dist/assets/cn-CoHJgTJ5.js +1 -0
  30. package/web/dist/assets/{common-CPZxdYLs.js → common-CP2UB8TN.js} +99 -99
  31. package/web/dist/assets/icons-CittejKL.js +1 -0
  32. package/web/dist/assets/imageUrl-BVgcEm7e.js +2 -0
  33. package/web/dist/assets/index-CEUbTcNL.css +1 -0
  34. package/web/dist/assets/index-CxrzleFg.js +122 -0
  35. package/web/dist/assets/{markdown-Cps-36Z5.js → markdown-DZQBOzWk.js} +1 -1
  36. package/web/dist/assets/{panels-DCwx2Pbu.js → panels-CuDz4aqU.js} +1 -1
  37. package/web/dist/assets/projectsStore-B7fdKRzl.js +1 -0
  38. package/web/dist/assets/{react-vendor-CXI113IS.js → react-vendor-BEA-EtI-.js} +1 -1
  39. package/web/dist/assets/{settingsStore-BSdi9gNd.js → settingsStore-DYqiXodu.js} +1 -1
  40. package/web/dist/assets/src-55YckF5W.js +2 -0
  41. package/web/dist/assets/{state-pOTP5BEk.js → state-A4wJ8QgR.js} +1 -1
  42. package/web/dist/assets/{statusAxesRefresh--2evRuAU.js → statusAxesRefresh-BBqszCp-.js} +1 -1
  43. package/web/dist/assets/sttLanguages-jnSk4aqg.js +6 -0
  44. package/web/dist/assets/threadStore-CQi4OzSe.js +1 -0
  45. package/web/dist/assets/useConfirm-kTv3x0H6.js +1 -0
  46. package/web/dist/assets/{useTranslation-gGKZZfux.js → useTranslation-2BGEBvJE.js} +1 -1
  47. package/web/dist/assets/websocket-DCs7f54y.js +1 -0
  48. package/web/dist/assets/whatsNewStore-DoCQvcMq.js +1 -0
  49. package/web/dist/index.html +27 -23
  50. package/web/dist/assets/AutomationView-DfAF2L92.js +0 -3
  51. package/web/dist/assets/Button-D-g7PgYh.js +0 -1
  52. package/web/dist/assets/ChartsView-CSAfGqTC.js +0 -1
  53. package/web/dist/assets/FileTreeView-B7IN0KmE.js +0 -1
  54. package/web/dist/assets/HookConfigView-9gqvrRhQ.js +0 -2
  55. package/web/dist/assets/InboxView-BcEfijbj.js +0 -1
  56. package/web/dist/assets/InputArea-D5F91Uwk.js +0 -14
  57. package/web/dist/assets/Install-Cuelo0If.js +0 -2
  58. package/web/dist/assets/MemoryView-BvZSh5-T.js +0 -1
  59. package/web/dist/assets/ModelsView-BgvMN8xv.js +0 -1
  60. package/web/dist/assets/PluginsView-C3d6e8vV.js +0 -1
  61. package/web/dist/assets/ProjectsView-CM7GOsoK.js +0 -1
  62. package/web/dist/assets/SettingsModal-BvGXq5EE.js +0 -4
  63. package/web/dist/assets/SkillsView-87kGRliE.js +0 -1
  64. package/web/dist/assets/TemplatesTab-8MLwVNwV.js +0 -1
  65. package/web/dist/assets/api-ZQf0Ys8y.js +0 -1
  66. package/web/dist/assets/icons-B8Ngx6rM.js +0 -1
  67. package/web/dist/assets/imageUrl-CrQM4gmf.js +0 -74
  68. package/web/dist/assets/index-Bm7r92T3.css +0 -1
  69. package/web/dist/assets/index-STsyoFCk.js +0 -145
  70. package/web/dist/assets/src-BK8SoTFV.js +0 -1
  71. package/web/dist/assets/sttLanguages-BPcOF0nQ.js +0 -2
  72. package/web/dist/assets/useConfirm-CQjBnYuP.js +0 -1
  73. package/web/dist/assets/websocket-CeKJTCdp.js +0 -1
  74. package/web/dist/assets/whatsNewStore-C0hbStfc.js +0 -1
  75. package/web/dist/assets/workspaceSemantics-CW8ytHq2.js +0 -3
package/README.md CHANGED
@@ -1166,33 +1166,31 @@ reader's own language instead of being translated on the fly.
1166
1166
 
1167
1167
  ## What's New · 更新日志
1168
1168
 
1169
- ### 1.0.44 — 2026-11-05
1169
+ ### 1.0.45 — 2026-11-10
1170
1170
 
1171
- 世界与全息产物、通知流水、工具操作凭据与连接器接线
1171
+ 会话订阅、审批挂起恢复、OpenClaw 插件与离线记忆整理
1172
1172
 
1173
- Physics worlds and holograms, a persistent notification feed, operation receipts and connectors wired back
1173
+ Session subscriptions, approvals that resume, OpenClaw plugins and offline memory dreaming
1174
1174
 
1175
1175
  **English**
1176
1176
 
1177
- - Two new artifact types you can actually handle: a **world** where dragging a body and releasing applies an impulse (gravity and damping sliders, play/pause/reset) and a **hologram** whose explode slider pulls parts apart along their declared vectors; both stop rendering when nothing moves. The charts wall also ships five ready-made dashboards (runtime, token usage, memory write/recall, memory ledger, orbit world), and an artifact that fails to load offers "let AI fix it" with the path and the original error pre-filled.
1178
- - A **notification feed** now keeps what used to vanish with the toast: disconnects, finished background jobs and newly delivered inbox messages stay in a bell list with an unread count and one-click clear, so nothing is lost to a 10-second toast.
1179
- - Mobile and right-panel rework: on portrait phones the horizontal session tabs become a left rail with a status ring and a "waiting on what" badge per session, and the docked project rail is gone — threads and the library are right-panel cards you can collapse, close, pin, rename and reorder, remembered across restarts.
1180
- - Tools now write an **operation receipt** (`~/.agent/operations/`) before they run: a reconnect replay, a post-restart resume or a retry collision reuses the recorded result for the same callId, so a `git push`, an email or a file deletion that already happened is never repeated.
1181
- - Chinese recall and mojibake: when recall is untrustworthy (no word tokens, all-zero scores) memories are re-ranked locally over up to 120 candidates, and memories stored as `æ¯`-style mojibake are restored losslessly while plain Western text is never touched. On session restore only the newest reminder of each family (board, plan, fact, context, scene plan) is kept, so a long session stops reloading a dozen contradictory snapshots.
1182
- - The server reconnects several loose ends: a `/api/inbox` surface (list, ingest, drain, complete, touch, delete), an hourly `/api/memory/metrics` ledger, `DELETE /api/logs` by file name or age (a missing parameter is a 400, never "delete everything"), four IM channel factories registered at startup under `DEEPSEEKCODE_CHANNELS_IM=1` (Telegram, Discord, Slack, WeChat), provider image settings persisted as endpoint / model / key with the key reported only as a boolean, and `clear_history` clearing the screen while keeping the session model.
1183
- - CLI and tool fixes: pasted prompts carrying zero-width characters no longer swallow Enter (invisible code points are stripped before submit), `read_file` returns a `snippet_id` that narrows `edit_file` to the lines you actually read (and refuses if the file changed since), Bash no longer hangs to the timeout when a grandchild holds the output pipe, and a new read-only `list_sessions` tool answers "what is running" instead of a goal list.
1184
- - Channels and connectors: DBHub now ships inside the install tree and runs offline when a recent Node is present, falling back to a global install otherwise; ```viz fences are downgraded to readable plain text for text-only IMs like WeChat, Feishu and Telegram instead of raw JSON; and "where does a scheduled run deliver" collapses into one rule that records a reason instead of creating an empty session when there is no peer.
1177
+ - Sessions can now **subscribe to a condition** and be woken only when it comes true: a file appears, matches a pattern or disappears, or a command exits with the expected code (or prints the expected line), and the wake-up carries what was observed at that moment. Subscriptions are per session, bounded by attempt and expiry limits, and cancellable at any time — watching a build, a deploy or a log no longer needs a human polling it.
1178
+ - An approval or a question that waits too long no longer holds the turn hostage: the turn is **suspended** and the decision stays with you. Come back, press allow, and that call is replayed and actually runs. `enable_tools`, `request_secret` and `ask_user_question` all share the path, so the same thing is never asked twice and "I allowed it but nothing happened" no longer occurs.
1179
+ - Third-party **OpenClaw plugins** now install and stop cleanly: the host fills in the compatibility-layer gaps on demand, install/disable/uninstall are all recorded, and the market blacklist blocks installation too. A plugin keeps its own config (including a search API key) in `~/.agent/plugins.json`, and `web_search` prefers a plugin-provided provider, falling back to Bing → Baidu only when it returns nothing.
1180
+ - Memory gains an **offline pass (dreaming)** that corrects stored memories against real transcripts, supersedes outdated entries and derives indexes. Every operation must carry a quote that matches the original text; a quote that cannot be verified drops the whole operation — fewer changes rather than invented ones. Triggering passes four gates (short/long-term thresholds, quiet hours, idleness, cooldown plus a daily cap), with a switch in Settings.
1181
+ - A finished workflow now hands over **every branch's output** instead of only the last node's, and node details fall back to a per-node snapshot: after a disconnect, a refresh or a new tab, expanding a node still shows what it actually said. Nodes are also no longer cut off by an iteration cap.
1182
+ - **adb now ships with the release**, so `phone_use` works out of the box without installing the Android SDK platform tools separately.
1183
+ - A session id mentioned in a message is now a clickable chip that jumps to that session (unknown ids stay plain text), and the rarely used bookmark feature was removed.
1185
1184
 
1186
1185
  **中文**
1187
1186
 
1188
- - 视觉产物新增两种可动手的形态:**世界**(拖住小球往一个方向松手就是一次施力,重力与阻尼可调,播放 / 暂停 / 复位)与**全息**(一根拆解滑杆把零件沿各自向量炸开);两者静止时自动停帧,不再空转烧电。图表大屏同时内置五张现成看板(本机运行时 / Token 用量 / 记忆写入与召回 / 内存账本 / 轨道世界),产物读不出来时红字旁直接给「让 AI 解决」,路径与原始报错已预填进新会话。
1189
- - 新增**通知流水**:右下角铃铛里留下一份不随提示过期的历史 —— 连接断开、后台任务完成、收件箱新消息都记在里面,带未读计数与一键清空。此前 toast 到期即删,回来只看到「刚才好像发生过什么」。
1190
- - 移动端与右栏重排:竖屏手机的横向会话标签条改成左侧常驻会话轨,每条带状态环与「在等什么」徽标;项目页那道停靠栏撤掉,「线程」和「库」变成右栏卡片,可折叠 / 关闭 / 置顶 / 改名 / 排序,且偏好重启后仍在。
1191
- - 工具执行前先落**操作凭据**(`~/.agent/operations/`):断线重放、进程重启续跑或恢复与重试撞车时,同一个 callId 直接复用上次结果 —— 已经发生的 `git push`、发信、删文件不会再做一遍。
1192
- - 中文记忆召回与乱码:召回结果不可信(中文整串切不出词元、命中分数恒为 0)时改用本地分词重排最多 120 条候选;此前被写成 `æ¯` 形态的中文记忆可无损还原,判定保守到不含汉字的西文一律不动。会话恢复时同一族提醒(黑板 / 计划 / 事实 / 上下文 / 场景图)只留最后一条,长会话不会把十几份互相矛盾的旧快照读回上下文。
1193
- - 服务端把几条断掉的线接回来:`/api/inbox` 一组接口(查询 / 投递 / 抽干 / 回写 / 人物触碰 / 删除)、`/api/memory/metrics` 小时级账本、`DELETE /api/logs` 按文件名或按天清理(缺参数一律 400,绝不当「删全部」);`DEEPSEEKCODE_CHANNELS_IM=1` 启动即注册 Telegram / Discord / Slack / 微信四个 IM 工厂;provider 生图配置的 endpoint / model / apiKey 三态落盘,读回时 key 只回布尔;`clear_history` 擦屏但保留该会话挑的模型。
1194
- - CLI 与工具几处扎手的:从网页 / Figma 粘进来的提示词带零宽字符时,屏幕上空着却按不动回车 —— 现在提交前统一清洗不可见码位;`read_file` 返回 `snippet_id`,`edit_file` 带上它就只在读过的行区间里找,文件在此期间被改过则直接拒绝并要求重读;命令已退出但后台孙进程还攥着输出管道时,Bash 不再一路挂到超时,而是按真实退出码结账并提示输出可能不完整;新增只读工具 `list_sessions`,「现在在跑什么」问它而不是问目标列表。
1195
- - 频道与连接器:DBHub 的文件随安装包一起铺进安装树,机器上有够新的 Node 就离线跑副本、没有才退回全局安装;回复里的 ```viz 图在微信 / 飞书 / Telegram 这类纯文本频道中降级成可读的结构化文本而不是一坨 JSON;定时任务结果投到「哪个频道 / 哪个会话」收敛成唯一判据,没对端或频道下没会话时如实记原因、不建空壳会话。
1187
+ - 新增**会话订阅**:可以让模型「先盯着,条件成立再叫醒我」——文件出现 / 内容匹配 / 消失、命令的退出码或输出匹配都算条件,命中时把会话叫回现场并带上当时看到的那一段。订阅按会话隔离,有次数与过期上限,随时可撤;跑构建、等部署、盯日志不用再靠人守着轮询。
1188
+ - 审批与提问等太久不再占住整轮:到时限就把这一轮**挂起**,把决定权留给你;回头点「允许」,那次调用会被重放并真的执行。`enable_tools` / `request_secret` / `ask_user_question` 走同一套,不会为同一件事问第二遍,也不会出现「点了允许但工具其实没跑」。
1189
+ - 第三方 **OpenClaw 插件**装得上也停得掉:宿主按需补齐兼容层缺口,装 / 停 / 卸载都有记录,市场黑名单连安装一起拦。插件自己的配置(含搜索 API key)落进 `~/.agent/plugins.json`;`web_search` 优先使用插件贡献的 provider,取不到结果才回落 Bing → Baidu。
1190
+ - 记忆多了一层**离线整理(dreaming)**:拿会话记录校正已有记忆、合并被取代的条目、派生索引;每条改动都必须带能对上原文的引文,核对不上整条丢弃 —— 宁可少改,也不编。触发有四道闸门(短期 / 长期阈值、安静时段、空闲、冷却与日上限),设置页新增开关。
1191
+ - 工作流终态把**每一路产出**都交出来(此前只读得到最后一个节点的 output),节点详情用逐节点快照兜底 —— 断线、刷新、换标签页回来,展开节点仍看得到它当初说了什么;节点也不再被轮次上限截断。
1192
+ - **内置 adb** 随发布包分发:`phone_use` 开箱可用,不必再单独安装 Android SDK 的平台工具。
1193
+ - 正文里出现的会话 id 变成可点芯片,点了直接跳到那个会话(未知会话回落纯文本);「收藏(书签)」按实际使用情况删除。
1196
1194
 
1197
1195
  _Earlier releases: see the version list on this package page, or `CHANGELOG.md` in the repository (generated from the same source)._
1198
1196
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minimaxclaw/cli",
3
- "version": "1.0.44",
3
+ "version": "1.0.45",
4
4
  "description": "DeepSeekCode — local-first AI coding agent for your terminal: one local runtime with a TUI, a web UI and an API, a permission/approval layer, read-only plan mode, and any OpenAI-compatible model.",
5
5
  "keywords": [
6
6
  "deepseekcode",
@@ -36,14 +36,14 @@
36
36
  "xterm": "5.3.0"
37
37
  },
38
38
  "optionalDependencies": {
39
- "@minimaxclaw/cli-darwin-arm64": "1.0.44",
40
- "@minimaxclaw/cli-darwin-x64": "1.0.44",
41
- "@minimaxclaw/cli-linux-x64": "1.0.44",
42
- "@minimaxclaw/cli-linux-arm64": "1.0.44",
43
- "@minimaxclaw/cli-linux-x64-musl": "1.0.44",
44
- "@minimaxclaw/cli-linux-arm64-musl": "1.0.44",
45
- "@minimaxclaw/cli-win32-x64": "1.0.44",
46
- "@minimaxclaw/cli-win32-arm64": "1.0.44"
39
+ "@minimaxclaw/cli-darwin-arm64": "1.0.45",
40
+ "@minimaxclaw/cli-darwin-x64": "1.0.45",
41
+ "@minimaxclaw/cli-linux-x64": "1.0.45",
42
+ "@minimaxclaw/cli-linux-arm64": "1.0.45",
43
+ "@minimaxclaw/cli-linux-x64-musl": "1.0.45",
44
+ "@minimaxclaw/cli-linux-arm64-musl": "1.0.45",
45
+ "@minimaxclaw/cli-win32-x64": "1.0.45",
46
+ "@minimaxclaw/cli-win32-arm64": "1.0.45"
47
47
  },
48
48
  "files": [
49
49
  "bin/",
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{$ as t,It as n,Tt as r,V as i,_t as a,at as o,d as s,dt as c,f as l,it as u,kr as d,n as f,ni as p,v as m,z as h,zr as g}from"./icons-B8Ngx6rM.js";import{t as _}from"./useTranslation-gGKZZfux.js";import{t as v}from"./Button-D-g7PgYh.js";import"./src-BK8SoTFV.js";import{n as y}from"./sessionKind-CZ1kQQII.js";import{t as b}from"./api-ZQf0Ys8y.js";import{I as x}from"./markdown-Cps-36Z5.js";import{t as S}from"./useConfirm-CQjBnYuP.js";import{f as C,r as w}from"./common-CPZxdYLs.js";import{n as T,t as E}from"./channelMeta-BO645sjD.js";import{r as D}from"./index-STsyoFCk.js";var O=e(p(),1),k=x(),A=(0,O.memo)(function({selectedSessionId:e,onSelectionChange:t,onOpenSession:n,onNavigate:i,onCollapse:a,onDeleted:o}){let{t:s}=_(),[l,d]=(0,O.useState)([]),[f,p]=(0,O.useState)(!0),[m,h]=(0,O.useState)(null),[v,y]=(0,O.useState)(null),[x,w]=(0,O.useState)(null),[T,E]=(0,O.useState)(!1),[D,A]=(0,O.useState)(null),[j,N]=(0,O.useState)(null),P=(0,O.useCallback)(async()=>{try{let e=await b.assistants.list();e.success&&Array.isArray(e.data)?(d(e.data),h(null)):h(e.error||s(`assistants.loadFailed`))}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}},[s]);(0,O.useEffect)(()=>{P();let e=window.setInterval(()=>{P()},8e3);return()=>window.clearInterval(e)},[P]);let F=(0,O.useCallback)(async(e,t)=>{(await b.assistants.update(e,t)).success&&P()},[P]),I=(0,O.useCallback)(async()=>{E(!0),N(null);try{let e=await b.assistants.create({title:s(`assistants.newAssistantTitle`)});e.success&&e.data?(await P(),t(e.data),w(e.data.sessionId)):N(e.error||s(`assistants.createFailed`))}catch(e){N(e instanceof Error?e.message:String(e))}finally{E(!1)}},[P,t,s]),L=(0,O.useCallback)(async(e,t)=>{N(null);try{let n=await b.assistants.rename(e,t);n.success?(w(null),await P()):N(n.error||s(`assistants.renameFailed`))}catch(e){N(e instanceof Error?e.message:String(e))}},[P,s]),[R,z]=S(),B=(0,O.useCallback)(async(t,n)=>{if(await z({message:s(`assistants.deleteConfirm`,{title:n}),variant:`danger`})){N(null),A(t);try{let n=await b.assistants.remove(t);n.success?(x===t&&w(null),e===t&&o?.(t),await P()):N(n.error||s(`assistants.deleteFailed`))}catch(e){N(e instanceof Error?e.message:String(e))}finally{A(null)}}},[x,e,o,P,z,s]);return(0,O.useEffect)(()=>{if(!e)return;let n=l.find(t=>t.sessionId===e);n&&t(n)},[l,e,t]),(0,k.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[R,(0,k.jsxs)(`div`,{className:`flex items-center justify-between border-b border-dark-border px-4 py-2.5`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(g,{size:16,className:`text-accent-blue`,"aria-hidden":`true`}),(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-dark-text`,children:s(`assistants.title`)}),!f&&(0,k.jsx)(`span`,{className:`rounded-full bg-dark-hover px-1.5 py-0.5 text-badge text-dark-muted`,children:l.length})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>void I(),disabled:T,className:`flex items-center gap-1 rounded px-2 py-1 text-xs text-accent-blue hover:bg-dark-hover disabled:opacity-50`,title:s(`assistants.newAssistantHint`),"data-testid":`assistants-create`,children:[(0,k.jsx)(c,{size:12,"aria-hidden":`true`}),s(`assistants.newAssistant`)]}),(0,k.jsxs)(`button`,{type:`button`,onClick:()=>void P(),className:`flex items-center gap-1 rounded px-2 py-1 text-xs text-dark-muted hover:bg-dark-hover hover:text-dark-text`,title:s(`common.refresh`),children:[(0,k.jsx)(u,{size:12,className:f?`animate-spin`:``,"aria-hidden":`true`}),s(`common.refresh`)]}),a&&(0,k.jsx)(`button`,{type:`button`,onClick:a,className:`rounded p-1 text-dark-muted hover:bg-dark-hover hover:text-dark-text`,title:s(`assistants.collapseList`),"aria-label":s(`assistants.collapseList`),"aria-expanded":!0,"data-testid":`assistants-list-collapse`,children:(0,k.jsx)(r,{size:13,"aria-hidden":`true`})})]})]}),j&&(0,k.jsx)(`div`,{className:`border-b border-dark-border px-4 py-1.5 text-meta text-accent-red`,role:`alert`,children:j}),(0,k.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-2`,children:f&&l.length===0?(0,k.jsx)(`div`,{className:`py-2`,role:`status`,"aria-label":s(`assistants.loading`),children:(0,k.jsx)(C,{count:4})}):m&&l.length===0?(0,k.jsx)(`div`,{className:`py-8 text-center text-xs text-accent-red`,children:m}):l.length===0?(0,k.jsxs)(`div`,{className:`py-10 text-center text-xs text-dark-muted`,children:[(0,k.jsx)(g,{size:24,className:`mx-auto mb-2 text-dark-muted`,"aria-hidden":`true`}),(0,k.jsx)(`p`,{children:s(`assistants.empty`)}),(0,k.jsx)(`p`,{className:`mt-1 text-meta`,children:s(`assistants.emptyHint`)}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>i(`channels`),className:`mt-3 rounded border border-dark-border px-2.5 py-1 text-meta text-dark-text hover:bg-dark-hover`,children:s(`assistants.goChannels`)})]}):(0,k.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map(r=>(0,k.jsx)(M,{assistant:r,selected:e===r.sessionId,onSelect:()=>t(r),expanded:v===r.sessionId,onToggleExpand:()=>y(v===r.sessionId?null:r.sessionId),onOpen:()=>n(r.sessionId,r.title),onUpdate:e=>void F(r.sessionId,e),editing:x===r.sessionId,onStartRename:()=>w(r.sessionId),onCancelRename:()=>w(null),onRename:e=>void L(r.sessionId,e),deleting:D===r.sessionId,onDelete:()=>void B(r.sessionId,r.title)},r.sessionId))})})]})});function j(e){if(e===`running`)return`running`;if(e===`paused`)return`waiting`;if(e===`error`)return`failed`}var M=(0,O.memo)(function({assistant:e,selected:t,onSelect:r,expanded:c,onToggleExpand:u,onOpen:d,onUpdate:f,editing:p,onStartRename:v,onCancelRename:b,onRename:x,deleting:S,onDelete:C}){let{t:O}=_(),A=e.channel?.peerKind===`group`,M=e.channel?.peerId===y,I=e.kind===`home`;return(0,k.jsxs)(`div`,{className:`rounded-lg border bg-dark-surface transition-colors ${t?`border-accent-blue/60 ring-1 ring-accent-blue/30`:`border-dark-border`}`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:r,"aria-current":t?`true`:void 0,className:`flex w-full items-center gap-2 rounded-t-lg px-3 py-2 text-start focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent-blue/60 ${t?`bg-accent-blue/5`:`hover:bg-dark-hover/40`}`,children:[(0,k.jsx)(w,{sessionId:e.sessionId,status:j(e.status),signal:e.status===`paused`?`paused`:void 0,size:40}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e.channel?(0,k.jsx)(`span`,{className:`text-base leading-none`,"aria-hidden":`true`,children:E(e.channel.type)}):(0,k.jsx)(g,{size:14,className:`shrink-0 text-dark-muted`,"aria-hidden":`true`}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-dark-text`,title:e.title,children:e.title}),(0,k.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${D(e.status)}`,title:O(`assistants.status.${e.status}`,{defaultValue:e.status})}),e.channel&&(M?(0,k.jsx)(o,{size:11,className:`shrink-0 text-dark-muted`,"aria-label":O(`assistants.channelLevelLabel`)}):A?(0,k.jsx)(s,{size:11,className:`shrink-0 text-dark-muted`,"aria-label":O(`assistants.group`)}):(0,k.jsx)(l,{size:11,className:`shrink-0 text-dark-muted`,"aria-label":O(`assistants.dm`)}))]}),(0,k.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1.5 text-badge text-dark-muted`,children:[(0,k.jsx)(`span`,{className:`shrink-0`,children:e.channel?T(e.channel.type):O(I?`assistants.homeLabel`:`assistants.localLabel`)}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.channel?.peerId,children:e.channel?M?O(`assistants.channelLevelHint`):e.channel.peerId:O(I?`assistants.homeHint`:`assistants.localHint`)}),e.stats.unread>0&&(0,k.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent-red/15 px-1.5 text-avatar font-medium text-accent-fg`,children:e.stats.unread})]}),e.preview&&(0,k.jsx)(`p`,{className:`mt-1 line-clamp-2 text-meta leading-snug text-dark-muted`,title:e.preview,children:e.preview})]}),(0,k.jsx)(P,{mode:e.mode}),e.trust.level===`owner`?(0,k.jsx)(h,{size:12,className:`shrink-0 text-accent-green`,"aria-label":O(`assistants.trust.owner`)}):e.trust.level===`public`?(0,k.jsx)(i,{size:12,className:`shrink-0 text-accent-yellow`,"aria-label":O(`assistants.trust.public`)}):(0,k.jsx)(h,{size:12,className:`shrink-0 text-accent-blue`,"aria-label":O(`assistants.trust.team`)})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 border-t border-dark-border px-3 py-1.5`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:d,className:`flex items-center gap-1 rounded px-2 py-0.5 text-meta text-accent-blue hover:bg-dark-hover`,children:[(0,k.jsx)(n,{size:11,"aria-hidden":`true`}),O(`assistants.openSession`)]}),(0,k.jsx)(`button`,{type:`button`,onClick:u,className:`flex items-center gap-1 rounded px-2 py-0.5 text-meta text-dark-muted hover:bg-dark-hover hover:text-dark-text`,children:O(`assistants.policy`)}),!I&&(0,k.jsx)(`button`,{type:`button`,onClick:p?b:v,className:`flex items-center gap-1 rounded px-2 py-0.5 text-meta text-dark-muted hover:bg-dark-hover hover:text-dark-text`,title:O(`assistants.rename`),"aria-label":O(`assistants.rename`),"aria-pressed":p,"data-testid":`assistant-rename-${e.sessionId}`,children:(0,k.jsx)(a,{size:11,"aria-hidden":`true`})}),!I&&(0,k.jsx)(`button`,{type:`button`,onClick:C,disabled:S,className:`flex items-center gap-1 rounded px-2 py-0.5 text-meta text-dark-muted hover:bg-accent-red/10 hover:text-accent-red disabled:opacity-50`,title:O(`assistants.deleteHint`),"aria-label":O(`assistants.delete`),"data-testid":`assistant-delete-${e.sessionId}`,children:(0,k.jsx)(m,{size:11,"aria-hidden":`true`})}),(0,k.jsx)(`span`,{className:`flex-1`}),(0,k.jsx)(`span`,{className:`text-badge text-dark-muted`,children:O(`assistants.groupPolicy`,{mention:String(A?e.policy.mentionRequired:!1)})})]}),c&&(0,k.jsx)(F,{assistant:e,isGroup:A,onUpdate:f}),p&&(0,k.jsx)(N,{initial:e.title,onSubmit:x,onCancel:b})]})});function N({initial:e,onSubmit:t,onCancel:n}){let{t:r}=_(),[i,a]=(0,O.useState)(e),o=()=>{let r=i.trim();!r||r===e?n():t(r)};return(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 border-t border-dark-border px-3 py-1.5`,children:[(0,k.jsx)(`input`,{autoFocus:!0,type:`text`,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),o()):e.key===`Escape`&&(e.preventDefault(),n())},"aria-label":r(`assistants.renameLabel`),"data-testid":`assistant-rename-input`,className:`min-w-0 flex-1 rounded border border-dark-border bg-dark-surface px-1.5 py-0.5 text-meta text-dark-text`}),(0,k.jsx)(`button`,{type:`button`,onClick:o,className:`rounded p-1 text-accent-blue hover:bg-dark-hover`,title:r(`common.save`),"aria-label":r(`common.save`),"data-testid":`assistant-rename-save`,children:(0,k.jsx)(d,{size:12,"aria-hidden":`true`})}),(0,k.jsx)(`button`,{type:`button`,onClick:n,className:`rounded p-1 text-dark-muted hover:bg-dark-hover hover:text-dark-text`,title:r(`common.cancel`),"aria-label":r(`common.cancel`),children:(0,k.jsx)(f,{size:12,"aria-hidden":`true`})})]})}function P({mode:e}){let{t}=_();return(0,k.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-0.5 text-avatar font-medium ${e===`delegate`?`bg-accent-blue/15 text-accent-blue`:`bg-dark-hover text-dark-muted`}`,children:t(`assistants.mode.${e}`)})}function F({assistant:e,isGroup:n,onUpdate:r}){let{t:i}=_(),[a,o]=(0,O.useState)(e.mode),[s,c]=(0,O.useState)(e.policy.mentionRequired),[l,u]=(0,O.useState)(String(e.policy.cooldownSeconds)),[d,f]=(0,O.useState)((e.policy.keywords??[]).join(`, `)),[p,m]=(0,O.useState)(!1);return(0,k.jsxs)(`div`,{className:`border-t border-dark-border px-3 py-2.5 text-meta`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,k.jsxs)(`label`,{className:`flex items-center gap-1.5 text-dark-muted`,children:[i(`assistants.mode.label`),(0,k.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),className:`rounded border border-dark-border bg-dark-surface px-1.5 py-0.5 text-dark-text`,children:[(0,k.jsx)(`option`,{value:`delegate`,children:i(`assistants.mode.delegate`)}),(0,k.jsx)(`option`,{value:`direct`,children:i(`assistants.mode.direct`)})]})]}),n&&(0,k.jsxs)(`label`,{className:`flex items-center gap-1.5 text-dark-muted`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked)}),i(`assistants.mentionRequired`)]}),(0,k.jsxs)(`label`,{className:`flex items-center gap-1.5 text-dark-muted`,children:[i(`assistants.cooldown`),(0,k.jsx)(`input`,{type:`number`,min:0,value:l,onChange:e=>u(e.target.value),className:`w-14 rounded border border-dark-border bg-dark-surface px-1.5 py-0.5 text-dark-text`}),`s`]})]}),(0,k.jsxs)(`label`,{className:`mt-2 flex items-center gap-1.5 text-dark-muted`,children:[i(`assistants.keywords`),(0,k.jsx)(`input`,{type:`text`,value:d,placeholder:i(`assistants.keywordsPlaceholder`)??``,onChange:e=>f(e.target.value),className:`min-w-0 flex-1 rounded border border-dark-border bg-dark-surface px-1.5 py-0.5 text-dark-text`})]}),(0,k.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,k.jsx)(v,{size:`sm`,variant:`accent`,onClick:()=>{m(!0),r({mode:a,policy:{mentionRequired:n?s:!1,cooldownSeconds:Math.max(0,Number(l)||0),...d.trim()?{keywords:d.split(/[,,]/).map(e=>e.trim()).filter(Boolean)}:{}}}),window.setTimeout(()=>m(!1),600)},loading:p,leftIcon:(0,k.jsx)(t,{size:11,"aria-hidden":`true`}),children:i(`common.save`)})})]})}export{A as AssistantsView};
1
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{$ as t,Lt as n,Tt as r,V as i,Vr as a,_t as o,at as s,d as c,dt as l,f as u,ii as d,it as f,jr as p,n as m,v as h,z as g}from"./icons-CittejKL.js";import{t as _}from"./useTranslation-2BGEBvJE.js";import{t as v}from"./Button-B43HsIQ3.js";import"./src-55YckF5W.js";import{n as y}from"./sessionKind-CZ1kQQII.js";import{t as b}from"./api-BW4-5gtM.js";import{I as x}from"./markdown-DZQBOzWk.js";import{d as S,p as C}from"./common-CP2UB8TN.js";import{t as w}from"./useConfirm-kTv3x0H6.js";import{n as T,t as E}from"./channelMeta-BO645sjD.js";import{r as D}from"./index-CxrzleFg.js";var O=e(d(),1),k=x(),A=(0,O.memo)(function({selectedSessionId:e,onSelectionChange:t,onOpenSession:n,onNavigate:i,onCollapse:o,onDeleted:s}){let{t:c}=_(),[u,d]=(0,O.useState)([]),[p,m]=(0,O.useState)(!0),[h,g]=(0,O.useState)(null),[v,y]=(0,O.useState)(null),[x,C]=(0,O.useState)(null),[T,E]=(0,O.useState)(!1),[D,A]=(0,O.useState)(null),[j,N]=(0,O.useState)(null),P=(0,O.useCallback)(async()=>{try{let e=await b.assistants.list();e.success&&Array.isArray(e.data)?(d(e.data),g(null)):g(e.error||c(`assistants.loadFailed`))}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}},[c]);(0,O.useEffect)(()=>{P();let e=window.setInterval(()=>{P()},8e3);return()=>window.clearInterval(e)},[P]);let F=(0,O.useCallback)(async(e,t)=>{(await b.assistants.update(e,t)).success&&P()},[P]),I=(0,O.useCallback)(async()=>{E(!0),N(null);try{let e=await b.assistants.create({title:c(`assistants.newAssistantTitle`)});e.success&&e.data?(await P(),t(e.data),C(e.data.sessionId)):N(e.error||c(`assistants.createFailed`))}catch(e){N(e instanceof Error?e.message:String(e))}finally{E(!1)}},[P,t,c]),L=(0,O.useCallback)(async(e,t)=>{N(null);try{let n=await b.assistants.rename(e,t);n.success?(C(null),await P()):N(n.error||c(`assistants.renameFailed`))}catch(e){N(e instanceof Error?e.message:String(e))}},[P,c]),[R,z]=w(),B=(0,O.useCallback)(async(t,n)=>{if(await z({message:c(`assistants.deleteConfirm`,{title:n}),variant:`danger`})){N(null),A(t);try{let n=await b.assistants.remove(t);n.success?(x===t&&C(null),e===t&&s?.(t),await P()):N(n.error||c(`assistants.deleteFailed`))}catch(e){N(e instanceof Error?e.message:String(e))}finally{A(null)}}},[x,e,s,P,z,c]);return(0,O.useEffect)(()=>{if(!e)return;let n=u.find(t=>t.sessionId===e);n&&t(n)},[u,e,t]),(0,k.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[R,(0,k.jsxs)(`div`,{className:`flex items-center justify-between border-b border-dark-border px-4 py-2.5`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(a,{size:16,className:`text-accent-blue`,"aria-hidden":`true`}),(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-dark-text`,children:c(`assistants.title`)}),!p&&(0,k.jsx)(`span`,{className:`rounded-full bg-dark-hover px-1.5 py-0.5 text-badge text-dark-muted`,children:u.length})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>void I(),disabled:T,className:`flex items-center gap-1 rounded px-2 py-1 text-xs text-accent-blue hover:bg-dark-hover disabled:opacity-50`,title:c(`assistants.newAssistantHint`),"data-testid":`assistants-create`,children:[(0,k.jsx)(l,{size:12,"aria-hidden":`true`}),c(`assistants.newAssistant`)]}),(0,k.jsxs)(`button`,{type:`button`,onClick:()=>void P(),className:`flex items-center gap-1 rounded px-2 py-1 text-xs text-dark-muted hover:bg-dark-hover hover:text-dark-text`,title:c(`common.refresh`),children:[(0,k.jsx)(f,{size:12,className:p?`animate-spin`:``,"aria-hidden":`true`}),c(`common.refresh`)]}),o&&(0,k.jsx)(`button`,{type:`button`,onClick:o,className:`rounded p-1 text-dark-muted hover:bg-dark-hover hover:text-dark-text`,title:c(`assistants.collapseList`),"aria-label":c(`assistants.collapseList`),"aria-expanded":!0,"data-testid":`assistants-list-collapse`,children:(0,k.jsx)(r,{size:13,"aria-hidden":`true`})})]})]}),j&&(0,k.jsx)(`div`,{className:`border-b border-dark-border px-4 py-1.5 text-meta text-accent-red`,role:`alert`,children:j}),(0,k.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-2`,children:p&&u.length===0?(0,k.jsx)(`div`,{className:`py-2`,role:`status`,"aria-label":c(`assistants.loading`),children:(0,k.jsx)(S,{count:4})}):h&&u.length===0?(0,k.jsx)(`div`,{className:`py-8 text-center text-xs text-accent-red`,children:h}):u.length===0?(0,k.jsxs)(`div`,{className:`py-10 text-center text-xs text-dark-muted`,children:[(0,k.jsx)(a,{size:24,className:`mx-auto mb-2 text-dark-muted`,"aria-hidden":`true`}),(0,k.jsx)(`p`,{children:c(`assistants.empty`)}),(0,k.jsx)(`p`,{className:`mt-1 text-meta`,children:c(`assistants.emptyHint`)}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>i(`channels`),className:`mt-3 rounded border border-dark-border px-2.5 py-1 text-meta text-dark-text hover:bg-dark-hover`,children:c(`assistants.goChannels`)})]}):(0,k.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map(r=>(0,k.jsx)(M,{assistant:r,selected:e===r.sessionId,onSelect:()=>t(r),expanded:v===r.sessionId,onToggleExpand:()=>y(v===r.sessionId?null:r.sessionId),onOpen:()=>n(r.sessionId,r.title),onUpdate:e=>void F(r.sessionId,e),editing:x===r.sessionId,onStartRename:()=>C(r.sessionId),onCancelRename:()=>C(null),onRename:e=>void L(r.sessionId,e),deleting:D===r.sessionId,onDelete:()=>void B(r.sessionId,r.title)},r.sessionId))})})]})});function j(e){if(e===`running`)return`running`;if(e===`paused`)return`waiting`;if(e===`error`)return`failed`}var M=(0,O.memo)(function({assistant:e,selected:t,onSelect:r,expanded:l,onToggleExpand:d,onOpen:f,onUpdate:p,editing:m,onStartRename:v,onCancelRename:b,onRename:x,deleting:S,onDelete:w}){let{t:O}=_(),A=e.channel?.peerKind===`group`,M=e.channel?.peerId===y,I=e.kind===`home`;return(0,k.jsxs)(`div`,{className:`rounded-lg border bg-dark-surface transition-colors ${t?`border-accent-blue/60 ring-1 ring-accent-blue/30`:`border-dark-border`}`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:r,"aria-current":t?`true`:void 0,className:`flex w-full items-center gap-2 rounded-t-lg px-3 py-2 text-start focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent-blue/60 ${t?`bg-accent-blue/5`:`hover:bg-dark-hover/40`}`,children:[(0,k.jsx)(C,{sessionId:e.sessionId,status:j(e.status),signal:e.status===`paused`?`paused`:void 0,size:40}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e.channel?(0,k.jsx)(`span`,{className:`text-base leading-none`,"aria-hidden":`true`,children:E(e.channel.type)}):(0,k.jsx)(a,{size:14,className:`shrink-0 text-dark-muted`,"aria-hidden":`true`}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-dark-text`,title:e.title,children:e.title}),(0,k.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${D(e.status)}`,title:O(`assistants.status.${e.status}`,{defaultValue:e.status})}),e.channel&&(M?(0,k.jsx)(s,{size:11,className:`shrink-0 text-dark-muted`,"aria-label":O(`assistants.channelLevelLabel`)}):A?(0,k.jsx)(c,{size:11,className:`shrink-0 text-dark-muted`,"aria-label":O(`assistants.group`)}):(0,k.jsx)(u,{size:11,className:`shrink-0 text-dark-muted`,"aria-label":O(`assistants.dm`)}))]}),(0,k.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1.5 text-badge text-dark-muted`,children:[(0,k.jsx)(`span`,{className:`shrink-0`,children:e.channel?T(e.channel.type):O(I?`assistants.homeLabel`:`assistants.localLabel`)}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.channel?.peerId,children:e.channel?M?O(`assistants.channelLevelHint`):e.channel.peerId:O(I?`assistants.homeHint`:`assistants.localHint`)}),e.stats.unread>0&&(0,k.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent-red/15 px-1.5 text-avatar font-medium text-accent-fg`,children:e.stats.unread})]}),e.preview&&(0,k.jsx)(`p`,{className:`mt-1 line-clamp-2 text-meta leading-snug text-dark-muted`,title:e.preview,children:e.preview})]}),(0,k.jsx)(P,{mode:e.mode}),e.trust.level===`owner`?(0,k.jsx)(g,{size:12,className:`shrink-0 text-accent-green`,"aria-label":O(`assistants.trust.owner`)}):e.trust.level===`public`?(0,k.jsx)(i,{size:12,className:`shrink-0 text-accent-yellow`,"aria-label":O(`assistants.trust.public`)}):(0,k.jsx)(g,{size:12,className:`shrink-0 text-accent-blue`,"aria-label":O(`assistants.trust.team`)})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 border-t border-dark-border px-3 py-1.5`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:f,className:`flex items-center gap-1 rounded px-2 py-0.5 text-meta text-accent-blue hover:bg-dark-hover`,children:[(0,k.jsx)(n,{size:11,"aria-hidden":`true`}),O(`assistants.openSession`)]}),(0,k.jsx)(`button`,{type:`button`,onClick:d,className:`flex items-center gap-1 rounded px-2 py-0.5 text-meta text-dark-muted hover:bg-dark-hover hover:text-dark-text`,children:O(`assistants.policy`)}),!I&&(0,k.jsx)(`button`,{type:`button`,onClick:m?b:v,className:`flex items-center gap-1 rounded px-2 py-0.5 text-meta text-dark-muted hover:bg-dark-hover hover:text-dark-text`,title:O(`assistants.rename`),"aria-label":O(`assistants.rename`),"aria-pressed":m,"data-testid":`assistant-rename-${e.sessionId}`,children:(0,k.jsx)(o,{size:11,"aria-hidden":`true`})}),!I&&(0,k.jsx)(`button`,{type:`button`,onClick:w,disabled:S,className:`flex items-center gap-1 rounded px-2 py-0.5 text-meta text-dark-muted hover:bg-accent-red/10 hover:text-accent-red disabled:opacity-50`,title:O(`assistants.deleteHint`),"aria-label":O(`assistants.delete`),"data-testid":`assistant-delete-${e.sessionId}`,children:(0,k.jsx)(h,{size:11,"aria-hidden":`true`})}),(0,k.jsx)(`span`,{className:`flex-1`}),(0,k.jsx)(`span`,{className:`text-badge text-dark-muted`,children:O(`assistants.groupPolicy`,{mention:String(A?e.policy.mentionRequired:!1)})})]}),l&&(0,k.jsx)(F,{assistant:e,isGroup:A,onUpdate:p}),m&&(0,k.jsx)(N,{initial:e.title,onSubmit:x,onCancel:b})]})});function N({initial:e,onSubmit:t,onCancel:n}){let{t:r}=_(),[i,a]=(0,O.useState)(e),o=()=>{let r=i.trim();!r||r===e?n():t(r)};return(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 border-t border-dark-border px-3 py-1.5`,children:[(0,k.jsx)(`input`,{autoFocus:!0,type:`text`,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),o()):e.key===`Escape`&&(e.preventDefault(),n())},"aria-label":r(`assistants.renameLabel`),"data-testid":`assistant-rename-input`,className:`min-w-0 flex-1 rounded border border-dark-border bg-dark-surface px-1.5 py-0.5 text-meta text-dark-text`}),(0,k.jsx)(`button`,{type:`button`,onClick:o,className:`rounded p-1 text-accent-blue hover:bg-dark-hover`,title:r(`common.save`),"aria-label":r(`common.save`),"data-testid":`assistant-rename-save`,children:(0,k.jsx)(p,{size:12,"aria-hidden":`true`})}),(0,k.jsx)(`button`,{type:`button`,onClick:n,className:`rounded p-1 text-dark-muted hover:bg-dark-hover hover:text-dark-text`,title:r(`common.cancel`),"aria-label":r(`common.cancel`),children:(0,k.jsx)(m,{size:12,"aria-hidden":`true`})})]})}function P({mode:e}){let{t}=_();return(0,k.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-0.5 text-avatar font-medium ${e===`delegate`?`bg-accent-blue/15 text-accent-blue`:`bg-dark-hover text-dark-muted`}`,children:t(`assistants.mode.${e}`)})}function F({assistant:e,isGroup:n,onUpdate:r}){let{t:i}=_(),[a,o]=(0,O.useState)(e.mode),[s,c]=(0,O.useState)(e.policy.mentionRequired),[l,u]=(0,O.useState)(String(e.policy.cooldownSeconds)),[d,f]=(0,O.useState)((e.policy.keywords??[]).join(`, `)),[p,m]=(0,O.useState)(!1);return(0,k.jsxs)(`div`,{className:`border-t border-dark-border px-3 py-2.5 text-meta`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,k.jsxs)(`label`,{className:`flex items-center gap-1.5 text-dark-muted`,children:[i(`assistants.mode.label`),(0,k.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),className:`rounded border border-dark-border bg-dark-surface px-1.5 py-0.5 text-dark-text`,children:[(0,k.jsx)(`option`,{value:`delegate`,children:i(`assistants.mode.delegate`)}),(0,k.jsx)(`option`,{value:`direct`,children:i(`assistants.mode.direct`)})]})]}),n&&(0,k.jsxs)(`label`,{className:`flex items-center gap-1.5 text-dark-muted`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked)}),i(`assistants.mentionRequired`)]}),(0,k.jsxs)(`label`,{className:`flex items-center gap-1.5 text-dark-muted`,children:[i(`assistants.cooldown`),(0,k.jsx)(`input`,{type:`number`,min:0,value:l,onChange:e=>u(e.target.value),className:`w-14 rounded border border-dark-border bg-dark-surface px-1.5 py-0.5 text-dark-text`}),`s`]})]}),(0,k.jsxs)(`label`,{className:`mt-2 flex items-center gap-1.5 text-dark-muted`,children:[i(`assistants.keywords`),(0,k.jsx)(`input`,{type:`text`,value:d,placeholder:i(`assistants.keywordsPlaceholder`)??``,onChange:e=>f(e.target.value),className:`min-w-0 flex-1 rounded border border-dark-border bg-dark-surface px-1.5 py-0.5 text-dark-text`})]}),(0,k.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,k.jsx)(v,{size:`sm`,variant:`accent`,onClick:()=>{m(!0),r({mode:a,policy:{mentionRequired:n?s:!1,cooldownSeconds:Math.max(0,Number(l)||0),...d.trim()?{keywords:d.split(/[,,]/).map(e=>e.trim()).filter(Boolean)}:{}}}),window.setTimeout(()=>m(!1),600)},loading:p,leftIcon:(0,k.jsx)(t,{size:11,"aria-hidden":`true`}),children:i(`common.save`)})})]})}export{A as AssistantsView};
@@ -0,0 +1,4 @@
1
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{A as t,Cn as n,En as r,Fr as i,Ir as a,Jr as o,Jt as s,Kr as c,Lr as l,Or as u,S as d,_t as f,br as p,c as m,dt as h,er as g,ft as _,g as v,i as y,ii as b,it as ee,kr as te,lr as x,lt as ne,n as S,pn as re,pt as ie,qt as ae,v as oe,xt as se,z as ce}from"./icons-CittejKL.js";import{r as le}from"./react-vendor-BEA-EtI-.js";import{t as C}from"./useTranslation-2BGEBvJE.js";import{n as ue,r as w,t as de}from"./Button-B43HsIQ3.js";import{t as T}from"./api-BW4-5gtM.js";import{I as fe}from"./markdown-DZQBOzWk.js";import"./common-CP2UB8TN.js";import{t as pe}from"./useConfirm-kTv3x0H6.js";import{G as E,J as D,K as O,U as k,W as A,X as me,q as j,u as he}from"./index-CxrzleFg.js";function M(e,t,n){let r=j(e,n?.in);return isNaN(t)?D(n?.in||e,NaN):(t&&r.setDate(r.getDate()+t),r)}function ge(e,t,n){let r=j(e,n?.in);if(isNaN(t))return D(n?.in||e,NaN);if(!t)return r;let i=r.getDate(),a=D(n?.in||e,r.getTime());return a.setMonth(r.getMonth()+t+1,0),i>=a.getDate()?a:(r.setFullYear(a.getFullYear(),a.getMonth(),i),r)}function _e(e,t,n){return M(e,t*7,n)}function ve(e){return D(e,Date.now())}function N(e,t,n){let[r,i]=E(n?.in,e,t);return+A(r)==+A(i)}function P(e,t){let n=j(e,t?.in);return n.setHours(23,59,59,999),n}function F(e,t){let[n,r]=E(e,t.start,t.end);return{start:n,end:r}}function ye(e,t){let{start:n,end:r}=F(t?.in,e),i=+n>+r,a=i?+n:+r,o=i?r:n;o.setHours(0,0,0,0);let s=t?.step??1;if(!s)return[];s<0&&(s=-s,i=!i);let c=[];for(;+o<=a;)c.push(D(n,o)),o.setDate(o.getDate()+s),o.setHours(0,0,0,0);return i?c.reverse():c}function be(e,t){let n=j(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function xe(e,t,n){let[r,i]=E(n?.in,e,t);return+O(r,n)==+O(i,n)}function Se(e,t,n){let[r,i]=E(n?.in,e,t);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()}function Ce(e,t){return N(D(t?.in||e,e),ve(t?.in||e))}var I=e(b(),1),we=le(),Te=2e3;function Ee(e){return`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}`}function L(e,t,n){return Number.isInteger(e)&&e>=t&&e<=n}function R(e,t,n){let r=e.trim();if(!r)return null;let i=new Set;for(let e of r.split(`,`)){let r=e.trim();if(!r)return null;if(r===`*`||r===`?`){for(let e=t;e<=n;e++)i.add(e);continue}let a=r.match(/^(\*|\d+|\d+-\d+)\/(\d+)$/);if(a){let e=parseInt(a[2]??``,10);if(!L(e,1,n))return null;let r=a[1]??``,o,s;if(r===`*`)o=t,s=n;else if(r.includes(`-`)){let[e,t]=r.split(`-`).map(Number);o=e??NaN,s=t??NaN}else o=Number(r),s=n;if(!L(o,t,n)||!L(s,t,n)||o>s)return null;for(let t=o;t<=s;t+=e)i.add(t);continue}let o=r.match(/^(\d+)-(\d+)$/);if(o){let e=parseInt(o[1]??``,10),r=parseInt(o[2]??``,10);if(!L(e,t,n)||!L(r,t,n)||e>r)return null;for(let t=e;t<=r;t++)i.add(t);continue}let s=Number(r);if(!L(s,t,n))return null;i.add(s)}return i.size>0?[...i].sort((e,t)=>e-t):null}function De(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let n=R(t[0]??``,0,59),r=R(t[1]??``,0,23),i=R(t[2]??``,1,31),a=R(t[3]??``,1,12),o=R(t[4]??``,0,7);return!n||!r||!i||!a||!o?null:{minutes:n,hours:r,daysOfMonth:i,months:a,daysOfWeek:[...new Set(o.map(e=>e===7?0:e))].sort((e,t)=>e-t)}}function Oe(e,t){return e.months.includes(t.getMonth()+1)&&e.daysOfMonth.includes(t.getDate())&&e.daysOfWeek.includes(t.getDay())}function ke(e,t){if(e.kind===`once`){if(!e.fireAt)return[];let n=new Date(e.fireAt);return Number.isNaN(n.getTime())?[]:N(n,t)?[n]:[]}let n=De(e.cron??``);if(!n||!Oe(n,t))return[];let r=[];for(let e of n.hours)for(let i of n.minutes)r.push(new Date(t.getFullYear(),t.getMonth(),t.getDate(),e,i,0,0));return r}function Ae(e,t,n){let r=A(t),i=P(n);if(r.getTime()>i.getTime())return[];let a=[],o=ye({start:r,end:i});for(let t of e){let e=0;for(let n of o){if(e>=Te)break;for(let o of ke(t.schedule,n))if(!(o.getTime()<r.getTime()||o.getTime()>i.getTime())&&(a.push({key:`${t.id}@${o.toISOString()}`,automationId:t.id,at:o,automation:t}),e+=1,e>=Te))break}}return a.sort((e,t)=>e.at.getTime()-t.at.getTime()||e.automation.name.localeCompare(t.automation.name)),a}var z=e=>e===`*`||e===`?`;function je(e,t){let n=e.schedule;if(n.kind===`once`){let e=n.fireAt?new Date(n.fireAt):null;if(!e||Number.isNaN(e.getTime()))return{ok:!1,reason:`unparsable`};if(N(e,t))return{ok:!1,reason:`noop-day`};let r=new Date(t.getFullYear(),t.getMonth(),t.getDate(),e.getHours(),e.getMinutes(),0,0);return{ok:!0,schedule:{...n,kind:`once`,fireAt:r.toISOString()}}}let r=(n.cron??``).trim().split(/\s+/);if(r.length!==5)return{ok:!1,reason:`unparsable`};let i=r[2]??``,a=r[3]??``,o=r[4]??``;if(!z(i)||!z(a))return{ok:!1,reason:`locked-cron`};let s=t.getDay();if(!z(o)){if(/^\d+$/.test(o)){if(Number(o)%7===s)return{ok:!1,reason:`noop-day`}}else if(o===`1-5`){if(s>=1&&s<=5)return{ok:!1,reason:`noop-day`}}else return{ok:!1,reason:`locked-cron`}}let c=[...r];return c[4]=String(s),{ok:!0,schedule:{...n,kind:`cron`,cron:c.join(` `)}}}function Me(e){return Ee(e)}function Ne(e){let t=new Map;for(let n of e){let e=Ee(n.at),r=t.get(e);r?r.push(n):t.set(e,[n])}return t}var B=[`automation.dow.monday`,`automation.dow.tuesday`,`automation.dow.wednesday`,`automation.dow.thursday`,`automation.dow.friday`,`automation.dow.saturday`,`automation.dow.sunday`],Pe=e=>(e.getDay()+6)%7;function Fe(e){let t=be(e),n=O(t,{weekStartsOn:1});return Array.from({length:42},(e,t)=>M(n,t))}function Ie(e){let t=O(e,{weekStartsOn:1});return Array.from({length:7},(e,n)=>M(t,n))}var V=fe(),H=3,U=e=>k(e,`HH:mm`),W=e=>`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}`;function Le(e){return e.status===`enabled`?e.schedule.kind===`once`?`once`:`enabled`:`disabled`}var Re={enabled:`border-accent-blue bg-accent-blue/10 text-dark-text`,once:`border-accent-yellow bg-accent-yellow/10 text-dark-text`,disabled:`border-dark-border bg-dark-hover text-dark-muted`};function G({occurrence:e,onSelectDay:t,extra:n,onUnpack:r,onDragStart:i,onDragEnd:a}){let{t:o}=C(),s=n=>{n.stopPropagation(),r?r():t(e.at)},c=!!i,l=c?o(`automation.dragHint`):r?o(`automation.unpackHint`):``;return(0,V.jsxs)(`button`,{type:`button`,onClick:s,draggable:c,onDragStart:t=>{i&&(t.stopPropagation(),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.key)),i(e))},onDragEnd:()=>a?.(),title:`${U(e.at)} ${e.automation.name}${l?` · ${l}`:``}`,className:`flex w-full items-center gap-1 truncate rounded border-s-2 px-1.5 py-[3px] text-start text-badge hover:brightness-110 ${Re[Le(e.automation)]} ${c?`cursor-grab active:cursor-grabbing`:``}`,children:[(0,V.jsx)(`span`,{className:`shrink-0 tabular-nums opacity-70`,children:U(e.at)}),(0,V.jsx)(`span`,{className:`truncate`,children:e.automation.name}),n!==void 0&&n>0&&(0,V.jsx)(`span`,{className:`shrink-0 opacity-70`,children:o(`automation.moreCount`,{count:n})})]})}function ze({anchor:e,selectedDay:t,byDay:n,onSelectDay:r,onFocusSlot:i,onMoveOccurrence:a}){let{t:o}=C(),s=(0,I.useMemo)(()=>Fe(e),[e]),[c,l]=(0,I.useState)(null),[u,d]=(0,I.useState)(null),f=()=>{l(null),d(null)};return(0,V.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-dark-border bg-dark-surface max-md:overflow-x-auto`,children:[(0,V.jsx)(`div`,{className:`grid grid-cols-7 border-b border-dark-border bg-dark-hover/40 max-md:min-w-[42rem]`,children:B.map(e=>(0,V.jsx)(`div`,{className:`px-2 py-2 text-center text-meta font-medium text-dark-muted`,children:o(e)},e))}),(0,V.jsx)(`div`,{className:`grid grid-cols-7 max-md:min-w-[42rem]`,children:s.map((s,p)=>{let m=W(s),h=n.get(m)??[],g=K(h),_=g.slice(0,H),v=g.slice(H).reduce((e,t)=>e+t.items.length,0),y=Se(s,e),b=N(s,t),ee=Ce(s),te=u===m;return(0,V.jsxs)(`div`,{"data-day":m,role:`button`,tabIndex:0,onClick:()=>r(s),onDragOver:e=>{c&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),d(m))},onDragLeave:()=>d(e=>e===m?null:e),onDrop:e=>{if(!c)return;e.preventDefault();let t=c;f(),a?.(t,s)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r(s))},className:[`flex min-h-28 cursor-pointer flex-col gap-1 border-b border-e border-dark-border p-1.5`,p%7==6?`border-e-0`:``,p>=35?`border-b-0`:``,y?`bg-dark-surface`:`bg-dark-bg/50`,te?`bg-accent-blue/10 ring-2 ring-inset ring-accent-blue/70`:b?`ring-1 ring-inset ring-accent-blue/50`:`hover:bg-dark-hover/40`].join(` `),children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(`span`,{className:[`flex h-5 w-5 items-center justify-center rounded-full text-meta tabular-nums`,ee?`bg-accent-blue font-semibold text-accent-fg`:y?`text-dark-text`:`text-dark-muted/60`].join(` `),children:s.getDate()}),h.length>0&&(0,V.jsx)(`span`,{className:`text-badge tabular-nums text-dark-muted/50`,children:h.length})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[_.map(e=>{let t=e.items[0],n=e.items.length>1;return(0,V.jsx)(G,{occurrence:t,onSelectDay:r,extra:e.items.length-1,onDragStart:a&&!n?l:void 0,onDragEnd:f,onUnpack:n&&i?()=>i(s,U(e.at)):void 0},`${m}-${U(e.at)}`)}),v>0&&(0,V.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r(s)},className:`px-1 text-start text-badge text-dark-muted hover:text-accent-blue`,children:o(`automation.moreCount`,{count:v})})]})]},s.toISOString())})})]})}function K(e){let t=new Map;for(let n of e){let e=U(n.at),r=t.get(e);r?r.items.push(n):t.set(e,{at:n.at,items:[n]})}return[...t.values()].sort((e,t)=>e.at.getTime()-t.at.getTime())}function Be({anchor:e,selectedDay:t,byDay:n,onSelectDay:r,onFocusSlot:i,onMoveOccurrence:a}){let{t:o}=C(),s=(0,I.useMemo)(()=>Ie(e),[e]),c=(0,I.useMemo)(()=>Array.from({length:24},(e,t)=>t),[]),[l,u]=(0,I.useState)(null),[d,f]=(0,I.useState)(null),p=()=>{u(null),f(null)};return(0,V.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-dark-border bg-dark-surface`,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-[3rem_repeat(7,minmax(0,1fr))] border-b border-dark-border bg-dark-hover/40`,children:[(0,V.jsx)(`div`,{}),s.map(e=>{let n=Ce(e),i=N(e,t);return(0,V.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:[`border-s border-dark-border px-1 py-1.5 text-center`,i?`bg-accent-blue/10`:`hover:bg-dark-hover/60`].join(` `),children:[(0,V.jsx)(`div`,{className:`text-meta text-dark-muted`,children:o(B[Pe(e)]??``)}),(0,V.jsx)(`div`,{className:[`mx-auto mt-0.5 flex h-5 w-5 items-center justify-center rounded-full text-meta tabular-nums`,n?`bg-accent-blue font-semibold text-accent-fg`:`text-dark-text`].join(` `),children:e.getDate()})]},e.toISOString())})]}),(0,V.jsxs)(`div`,{className:`custom-scrollbar grid max-h-[62vh] grid-cols-[3rem_repeat(7,minmax(0,1fr))] overflow-y-auto`,children:[(0,V.jsx)(`div`,{className:`relative`,style:{height:`72rem`},children:c.map(e=>(0,V.jsx)(`div`,{className:`absolute end-1 -translate-y-1/2 text-badge tabular-nums text-dark-muted`,style:{top:`${e/24*100}%`},children:e===0?``:`${String(e).padStart(2,`0`)}:00`},e))}),s.map(e=>{let o=W(e),s=K(n.get(o)??[]),m=N(e,t);return(0,V.jsxs)(`div`,{"data-day":o,onDragOver:e=>{l&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),f(o))},onDragLeave:()=>f(e=>e===o?null:e),onDrop:t=>{if(!l)return;t.preventDefault();let n=l;p(),a?.(n,e)},className:[`relative border-s border-dark-border`,d===o?`bg-accent-blue/15 ring-2 ring-inset ring-accent-blue/70`:m?`bg-accent-blue/5`:``].join(` `),style:{height:`72rem`},children:[c.map(e=>(0,V.jsx)(`div`,{className:`absolute inset-x-0 border-t ${e===0?`border-transparent`:`border-dark-border/60`}`,style:{top:`${e/24*100}%`}},e)),s.map(t=>{let n=t.items[0],o=t.at.getHours()*60+t.at.getMinutes();return(0,V.jsx)(`div`,{className:`absolute inset-x-0.5 z-10`,style:{top:`${o/1440*100}%`},children:(0,V.jsx)(G,{occurrence:n,onSelectDay:r,extra:t.items.length-1,onDragStart:a&&t.items.length===1?u:void 0,onDragEnd:p,onUnpack:i&&t.items.length>1?()=>i(e,U(t.at)):void 0})},`${e.toISOString()}-${U(t.at)}`)})]},e.toISOString())})]})]})}var q=e=>k(e,`HH:mm`);function Ve({day:e,occurrences:t,focusSlot:n,onClearFocus:r,onEdit:i,onRun:a,onToggle:o,onDelete:s,onCreate:c}){let{t:u}=C(),d=n??null,p=d?t.filter(e=>q(e.at)===d).length:0,m=d?t.findIndex(e=>q(e.at)===d):-1,g=(0,I.useRef)(null);return(0,I.useEffect)(()=>{d&&g.current?.scrollIntoView?.({block:`nearest`})},[d]),(0,V.jsxs)(`aside`,{className:`flex w-full shrink-0 flex-col overflow-hidden rounded-xl border border-dark-border bg-dark-surface lg:w-72`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-2 border-b border-dark-border px-3 py-2.5`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(`div`,{className:`truncate text-sm font-semibold`,children:[u(B[Pe(e)]??``),` · `,k(e,`yyyy-MM-dd`)]}),(0,V.jsxs)(`div`,{className:`text-meta text-dark-muted`,children:[u(`automation.tasksCount`,{count:t.length}),Ce(e)?` · ${u(`automation.today`)}`:``]})]}),(0,V.jsx)(`button`,{type:`button`,onClick:c,title:u(`automation.new`),className:`rounded-lg p-1.5 text-dark-muted hover:bg-dark-hover hover:text-dark-text`,children:(0,V.jsx)(h,{size:15})})]}),d&&(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-dark-border bg-accent-blue/10 px-3 py-1.5 text-meta`,children:[(0,V.jsx)(`span`,{className:`shrink-0 font-medium tabular-nums`,children:d}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-dark-muted`,children:u(`automation.slotFocus`,{count:p})}),r&&(0,V.jsx)(`button`,{type:`button`,onClick:r,title:u(`automation.clearFocus`),className:`rounded p-0.5 text-dark-muted hover:bg-dark-hover hover:text-dark-text`,children:(0,V.jsx)(S,{size:12})})]}),(0,V.jsx)(`div`,{className:`custom-scrollbar flex-1 overflow-y-auto p-2.5`,children:t.length===0?(0,V.jsxs)(`div`,{className:`flex flex-col items-center gap-1 px-2 py-8 text-center`,children:[(0,V.jsx)(l,{size:22,className:`text-dark-muted`}),(0,V.jsx)(`p`,{className:`text-xs text-dark-muted`,children:u(`automation.dayEmpty`)}),(0,V.jsx)(`p`,{className:`text-meta text-dark-muted/70`,children:u(`automation.dayEmptyHint`)})]}):(0,V.jsx)(`div`,{className:`space-y-2`,children:t.map((e,t)=>{let n=e.automation,r=n.status===`enabled`,c=d!==null&&q(e.at)===d;return(0,V.jsxs)(`div`,{ref:t===m?g:void 0,"data-focus-slot":c?d:void 0,className:[`rounded-lg border bg-dark-bg/50 px-2.5 py-2`,c?`border-accent-blue/60 ring-1 ring-inset ring-accent-blue/50`:`border-dark-border`].join(` `),children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`shrink-0 text-meta font-medium tabular-nums text-dark-muted`,children:q(e.at)}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium`,title:n.name,children:n.name}),(0,V.jsx)(`span`,{className:`shrink-0 rounded px-1 py-0.5 text-badge ${r?`bg-accent-green/20 text-accent-green`:`bg-dark-hover text-dark-muted`}`,children:u(r?`automation.enabled`:`automation.disabled`)})]}),(0,V.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[n.nextRunAt&&(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-badge tabular-nums text-dark-muted`,children:[u(`automation.nextRun`),` `,k(new Date(n.nextRunAt),`MM-dd HH:mm`)]}),(0,V.jsxs)(`div`,{className:`ms-auto flex shrink-0 items-center gap-1`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:()=>i(n),title:u(`automation.edit`),className:`rounded p-1.5 text-dark-muted hover:bg-dark-hover hover:text-dark-text`,children:(0,V.jsx)(f,{size:14})}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>o(n),title:u(r?`automation.disable`:`automation.enable`),className:`rounded p-1.5 text-dark-muted hover:bg-dark-hover hover:text-dark-text`,children:(0,V.jsx)(ne,{size:14})}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>a(n.id),title:u(`automation.runNow`),className:`rounded p-1.5 text-accent-green hover:bg-dark-hover`,children:(0,V.jsx)(ie,{size:14})}),s&&(0,V.jsx)(`button`,{type:`button`,onClick:()=>s(n),title:u(`automation.delete`),className:`rounded p-1.5 text-dark-muted hover:bg-accent-red/10 hover:text-accent-red`,children:(0,V.jsx)(oe,{size:14})})]})]})]},e.key)})})})]})}var J={name:``,instructions:``,jobKind:`agent`,workflowTemplate:``,freq:`daily`,time:`09:00`,dow:`1`,onceAt:``,cron:`0 9 * * *`,modelRef:``,connectorIds:[],channelIds:[],workspaceDir:``,readAutoAllow:!0,runSessionMode:`home`,runSessionId:``,budgetUsd:``};function He(e){let t=e.trim();if(!t)return null;let n=Number(t);return!Number.isFinite(n)||n<=0?null:String(Math.round(n*100))}var Ue=`.agent/automation-attachments`,We=`workflow:`;function Ge(e){return/^[a-z0-9][a-z0-9_-]*$/.test(e)}function Ke(e){let t=e??``;if(!t.startsWith(We))return``;let n=t.slice(9).trim();return Ge(n)?n:``}var Y=`deepseekcode:automation-view`,qe=[{id:`month`,key:`automation.viewMonth`,Icon:a},{id:`week`,key:`automation.viewWeek`,Icon:i},{id:`list`,key:`automation.viewList`,Icon:s}];function Je(){try{let e=localStorage.getItem(Y);if(e===`month`||e===`week`||e===`list`)return e}catch{}return`month`}function Ye(e){try{localStorage.setItem(Y,e)}catch{}}var X=e=>String(e).padStart(2,`0`);function Xe(e){let t=e.schedule,n=Ke(e.name),r={modelRef:e.modelRef??``,connectorIds:Array.isArray(e.connectorIds)?[...e.connectorIds]:[],channelIds:Array.isArray(e.notificationChannelIds)?[...e.notificationChannelIds]:[],workspaceDir:e.workspaceDir??``,readAutoAllow:e.readAutoAllow,runSessionMode:e.runSessionMode??`home`,runSessionId:e.runSessionId??``,budgetUsd:e.budgetCents?String(Number(e.budgetCents)/100):``,workflowTemplate:n,jobKind:n?`workflow`:`agent`};if(t.kind===`once`&&t.fireAt){let n=new Date(t.fireAt);return{...J,name:e.name,instructions:e.instructions,freq:`once`,time:`${X(n.getHours())}:${X(n.getMinutes())}`,onceAt:`${n.getFullYear()}-${X(n.getMonth()+1)}-${X(n.getDate())}T${X(n.getHours())}:${X(n.getMinutes())}`,...r}}let i=(t.cron||``).trim().split(/\s+/),a={...J,name:e.name,instructions:e.instructions,...r};if(i.length===5){let e=i[0]??``,t=i[1]??``,n=i[4]??``,r=`${X(parseInt(t,10)||0)}:${X(parseInt(e,10)||0)}`;if(n===`*`)return{...a,freq:`daily`,time:r};if(n===`1-5`)return{...a,freq:`weekdays`,time:r};if(/^\d+$/.test(n))return{...a,freq:`weekly`,time:r,dow:n}}return{...a,freq:`custom`,cron:t.cron||``}}function Ze(e){let[t,n]=e.time.split(`:`),r=parseInt(t??``,10),i=parseInt(n??``,10);switch(e.freq){case`daily`:return Number.isInteger(r)&&Number.isInteger(i)?{kind:`cron`,cron:`${i} ${r} * * *`}:null;case`weekdays`:return Number.isInteger(r)&&Number.isInteger(i)?{kind:`cron`,cron:`${i} ${r} * * 1-5`}:null;case`weekly`:return Number.isInteger(r)&&Number.isInteger(i)?{kind:`cron`,cron:`${i} ${r} * * ${e.dow}`}:null;case`once`:return e.onceAt?{kind:`once`,fireAt:new Date(e.onceAt).toISOString()}:null;case`custom`:return e.cron.trim()?{kind:`cron`,cron:e.cron.trim()}:null}}function Z(e,t){if(e.kind===`once`&&e.fireAt){let n=new Date(e.fireAt);return`${t(`automation.badgeOnce`)} ${n.toLocaleString()}`}let n=(e.cron||``).trim().split(/\s+/);if(n.length!==5)return e.cron||``;let r=n[0]??``,i=n[1]??``,a=n[4]??``,o=`${X(parseInt(i,10)||0)}:${X(parseInt(r,10)||0)}`;return a===`*`?t(`automation.badgeDaily`,{time:o}):a===`1-5`?t(`automation.badgeWeekdays`,{time:o}):/^\d+$/.test(a)?t(`automation.badgeWeekly`,{day:t(`automation.dow.${[`sunday`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`][parseInt(a,10)%7]}`),time:o}):e.cron||``}var Qe=[{value:`1`,key:`automation.dow.monday`},{value:`2`,key:`automation.dow.tuesday`},{value:`3`,key:`automation.dow.wednesday`},{value:`4`,key:`automation.dow.thursday`},{value:`5`,key:`automation.dow.friday`},{value:`6`,key:`automation.dow.saturday`},{value:`0`,key:`automation.dow.sunday`}];function $e(e){let t=e.replace(/[\\/]+$/,``),n=Math.max(t.lastIndexOf(`\\`),t.lastIndexOf(`/`));return n===-1?t:t.slice(n+1)}function et({isOpen:e,initial:t,onClose:i,onConfirm:a}){let{t:s}=C(),{visible:c,phase:l}=ue(e),[u,d]=(0,I.useState)(t),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)([]),[g,_]=(0,I.useState)(!1),[v,y]=(0,I.useState)(``),[b,ee]=(0,I.useState)(t),te=(0,I.useRef)(null),x=async e=>{_(!0),y(``);try{let t=await T.dirs.list(e);if(!t.success||!t.data){y(t.error||`加载目录失败`);return}d(t.data.path),p(t.data.parent),h(t.data.dirs||[]),ee(t.data.path)}catch(e){y(e instanceof Error?e.message:`加载目录失败`)}finally{_(!1)}};return(0,I.useEffect)(()=>{e&&x(t)},[e,t]),(0,I.useEffect)(()=>{te.current?.focus()},[]),(0,I.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i())};return document.addEventListener(`keydown`,t),document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,t),document.body.style.overflow=``}},[e,i]),c?(0,V.jsxs)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center overflow-hidden p-4 max-md:p-0`,role:`dialog`,"aria-modal":`true`,children:[(0,V.jsx)(`div`,{className:`absolute inset-0 ui-scrim ui-overlay-backdrop`,"data-phase":l,onClick:i}),(0,V.jsxs)(`div`,{className:`relative w-full max-w-lg mx-4 bg-dark-overlay ui-surface-overlay border border-dark-border rounded-xl shadow-pop flex flex-col max-h-[70vh] ui-overlay-panel max-md:mx-0 max-md:max-w-none max-md:rounded-none max-md:max-h-[85vh]`,"data-phase":l,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2.5 border-b border-dark-border shrink-0`,children:[(0,V.jsxs)(`span`,{className:`flex items-center gap-2 text-compact font-semibold text-dark-text`,children:[(0,V.jsx)(r,{size:15,className:`text-accent-blue`}),s(`automation.workspacePick`)]}),(0,V.jsx)(`button`,{type:`button`,onClick:i,className:`rounded p-1 text-dark-muted hover:bg-dark-hover`,children:(0,V.jsx)(S,{size:15})})]}),(0,V.jsxs)(`div`,{className:`p-4 flex flex-col gap-3 min-h-0 flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsxs)(`div`,{className:`relative flex-1`,children:[(0,V.jsx)(re,{size:13,className:`absolute start-2.5 top-1/2 -translate-y-1/2 text-dark-muted/60`}),(0,V.jsx)(`input`,{ref:te,value:b,onChange:e=>ee(e.target.value),onKeyDown:e=>{e.key===`Enter`&&x(b.trim())},spellCheck:!1,className:`w-full rounded-lg border border-dark-border bg-dark-surface ps-8 pe-2.5 py-1.5 text-xs font-mono focus:outline-none focus:border-accent-blue/50`})]}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>void x(b.trim()),disabled:g||!b.trim(),className:`shrink-0 rounded-lg border border-dark-border px-2.5 py-1.5 text-xs text-dark-muted hover:bg-dark-hover disabled:opacity-40`,children:s(`chat.dirPickerGo`)})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`flex-1 truncate font-mono text-meta text-dark-muted bg-dark-surface rounded-md px-2 py-1 border border-dark-border`,title:u,children:u||`—`}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>f&&void x(f),disabled:g||!f,className:`shrink-0 flex items-center gap-1 rounded-md border border-dark-border px-2 py-1 text-meta text-dark-muted hover:bg-dark-hover disabled:opacity-40`,children:[(0,V.jsx)(o,{size:12}),s(`chat.dirPickerUp`)]})]}),(0,V.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto rounded-lg border border-dark-border bg-dark-surface divide-y divide-dark-border/60`,children:g?(0,V.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-6 text-xs text-dark-muted`,children:[(0,V.jsx)(ae,{size:14,className:`animate-spin`}),s(`chat.loading`)]}):v?(0,V.jsx)(`div`,{className:`px-3 py-4 text-xs text-accent-red`,children:v}):m.length===0?(0,V.jsx)(`div`,{className:`px-3 py-4 text-xs text-dark-muted/60 text-center`,children:`—`}):m.map(e=>{let t=u.includes(`\\`)?`\\`:`/`,r=u.endsWith(t)?u+e:u+t+e;return(0,V.jsxs)(`button`,{type:`button`,onClick:()=>void x(r),className:`w-full flex items-center gap-2 px-3 py-1.5 text-start text-xs text-dark-text hover:bg-dark-hover`,children:[(0,V.jsx)(n,{size:13,className:`shrink-0 text-accent-yellow/80`}),(0,V.jsx)(`span`,{className:`truncate`,children:e})]},e)})}),(0,V.jsx)(de,{variant:`accent`,className:`w-full`,onClick:()=>a(u),disabled:!u,loading:g,children:s(`chat.dirPickerConfirm`)})]})]})]}):null}function tt(){let{t:e}=C(),{automations:n,runsByAutomation:i,fetchAutomations:a,createAutomation:o,updateAutomation:s,deleteAutomation:b,toggleAutomation:le,runAutomation:fe,fetchRuns:E,error:D}=he(),[O,A]=(0,I.useState)(!1),{visible:j,phase:M}=ue(O),[ve,N]=(0,I.useState)(null),[P,F]=(0,I.useState)(J),[ye,be]=(0,I.useState)(null),[Ce,Te]=(0,I.useState)(``),[Ee,L]=(0,I.useState)(!1),[R,De]=pe(),Oe=async t=>{await De({message:e(`automation.deleteConfirm`,{name:t.name}),variant:`danger`})&&await b(t.id)},[ke,z]=(0,I.useState)(!1),[B,Pe]=(0,I.useState)(Je),[H,U]=(0,I.useState)(()=>new Date),[W,Le]=(0,I.useState)(()=>new Date),[Re,G]=(0,I.useState)(null),K=e=>{Le(e),G(null)};(0,I.useEffect)(()=>{Ye(B)},[B]);let q=(0,I.useMemo)(()=>{if(B===`month`){let e=Fe(H);return{from:e[0],to:e[e.length-1]}}if(B===`week`){let e=Ie(H);return{from:e[0],to:e[e.length-1]}}return null},[B,H]),Ge=(0,I.useMemo)(()=>q?Ae(n,q.from,q.to):[],[n,q]),Y=(0,I.useMemo)(()=>Ne(Ge),[Ge]),X=(0,I.useMemo)(()=>Y.get(Me(W))??[],[Y,W]),tt=e=>{let t=B===`week`?_e(H,e):ge(H,e);U(t),(B===`week`?xe(W,t,{weekStartsOn:1}):Se(W,t))||K(t)},nt=()=>{let e=new Date;U(e),K(e)},rt=async(t,n)=>{let r=je(t.automation,n);if(!r.ok){r.reason===`noop-day`?w.info(e(`automation.dragNoop`)):w.warning(e(`automation.dragLocked`));return}let i=Z(t.automation.schedule,e);await s(t.automation.id,{schedule:r.schedule})&&(K(n),w.success(e(`automation.dragMoved`,{name:t.automation.name,from:i,to:Z(r.schedule,e)})))},it=(0,I.useMemo)(()=>{if(B===`week`){let e=Ie(H);return`${k(e[0],`yyyy-MM-dd`)} → ${k(e[e.length-1],`MM-dd`)}`}return k(H,`yyyy-MM`)},[B,H]),[at,ot]=(0,I.useState)([]),[st,ct]=(0,I.useState)([]),[lt,ut]=(0,I.useState)([]),[dt,ft]=(0,I.useState)([]),[pt,mt]=(0,I.useState)(!1),[ht,gt]=(0,I.useState)([]),[_t,vt]=(0,I.useState)(!1),[yt,bt]=(0,I.useState)(!1),xt=async()=>{if(_t)return;vt(!0);let e=await T.sessions.list().catch(()=>({success:!1,data:void 0}));e.success&&Array.isArray(e.data)&&gt(e.data.filter(e=>!e.id.startsWith(`__automation_run__`)))},[St,Q]=(0,I.useState)([]),Ct=(0,I.useRef)(null);(0,I.useEffect)(()=>{a()},[a]);let $=async e=>{N(null),F(e?{...e.form}:{...J}),Q([]),A(!0),await Et()},wt=async e=>{N(e.id),F(Xe(e)),Q((e.attachments??[]).map((e,t)=>({id:`existing-${t}-${e}`,name:$e(e),file:null,uploading:!1,path:e}))),A(!0),await Et(),e.runSessionMode===`fixed`&&xt()},Tt=()=>{A(!1),N(null),F(J),Q([]),z(!1)},Et=async()=>{bt(!0);try{let e=T.templates?.list?T.templates.list().catch(()=>({success:!1,data:void 0})):Promise.resolve({success:!1,data:void 0}),[t,n,r,i]=await Promise.all([T.models.list().catch(()=>({success:!1,data:void 0})),T.connectors.list().catch(()=>({success:!1,data:void 0})),T.channels.list().catch(()=>({success:!1,data:void 0})),e]);t.success&&t.data?.models?ot(t.data.models.filter(e=>e.enabled!==!1)):ot([]),n.success&&n.data?.connectors?ct(n.data.connectors.filter(e=>e.installed)):ct([]),r.success&&Array.isArray(r.data)?ut(r.data):ut([]),i.success&&Array.isArray(i.data)?ft(i.data):ft([]),mt(!0)}finally{bt(!1)}},Dt=e=>{F(t=>{if(t.jobKind===e)return t;let n=e===`agent`&&!Ke(t.name);return{...t,jobKind:e,workflowTemplate:``,instructions:``,name:n?t.name:``}})},Ot=()=>{let e=dt.find(e=>e.id===P.workflowTemplate),t={};for(let n of e?.inputs??[])t[n.name]=n.default===void 0?``:n.default;F(e=>({...e,instructions:JSON.stringify(t,null,2)}))},kt=async()=>{let t=Ze(P);if(!t)return;let n=P.jobKind===`workflow`;if(n&&!P.workflowTemplate)return;if(n){let t=P.instructions.trim();if(t){let n;try{n=JSON.parse(t)}catch{w.warning(e(`automation.workflowJsonInvalid`));return}if(!n||typeof n!=`object`||Array.isArray(n)){w.warning(e(`automation.workflowJsonNotObject`));return}}}else if(!P.name.trim()||!P.instructions.trim())return;if(St.some(e=>e.uploading)){w.warning(`附件上传中,请稍候…`);return}let r=St.filter(e=>e.error).map(e=>e.name);if(r.length>0){w.warning(`附件上传失败:${r.join(`, `)}`);return}L(!0);let i={name:n?`${We}${P.workflowTemplate}`:P.name.trim(),instructions:P.instructions.trim(),schedule:t,workspaceDir:P.workspaceDir.trim(),readAutoAllow:P.readAutoAllow,modelRef:P.modelRef.trim()||null,attachments:St.map(e=>e.path).filter(e=>!!e),connectorIds:[...P.connectorIds],notificationChannelIds:[...P.channelIds],runSessionMode:P.runSessionMode,runSessionId:P.runSessionMode===`fixed`&&P.runSessionId.trim()||null,budgetCents:He(P.budgetUsd)},a=ve?await s(ve,i):await o(i)!==null;L(!1),a&&Tt()},At=async e=>{let t=Ce.trim();if(!t)return;let[n,...r]=t.split(/\s+/),i=r.join(` `);n&&i&&(await fetch(`/api/automations/${encodeURIComponent(e)}/permissions`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({tool:n,target:i})})).ok&&(Te(``),await a())},jt=async(e,t)=>{(await fetch(`/api/automations/${encodeURIComponent(e)}/permissions`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify({entry:t})})).ok&&await a()},Mt=async e=>{let t=ye===e?null:e;be(t),t&&await E(e)},Nt=()=>{let t=n.slice(0,20).map(t=>{let n=i[t.id]?.[0],r=[t.name,Z(t.schedule,e),t.status,t.lastRunAt?`${t.lastStatus??`?`}@${t.lastRunAt}`:`never-run`];return n?.error&&r.push(`error: ${n.error}`),`- ${r.join(` | `)}`}).join(`
2
+ `);me(e(`automation.aiAssistPrompt`,{count:n.length,tasks:t||e(`automation.aiAssistNoTasks`)}))},Pt=async e=>{if(!e||e.length===0)return;let t=Array.from(e).map(e=>({id:`f-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:e.name,file:e,uploading:!0}));Q(e=>[...e,...t]);for(let e of t){let t=`${Ue}/${e.name}`;try{let n=await T.files.upload(e.file,t);if(n.success&&n.data?.path){let t=n.data.path.replace(/\\/g,`/`);Q(n=>n.map(n=>n.id===e.id?{...n,uploading:!1,path:t}:n))}else Q(t=>t.map(t=>t.id===e.id?{...t,uploading:!1,error:n.error||`upload failed`}:t))}catch(t){let n=t instanceof Error?t.message:`upload failed`;Q(t=>t.map(t=>t.id===e.id?{...t,uploading:!1,error:n}:t))}}},Ft=e=>{Q(t=>t.filter(t=>t.id!==e))},It=[{id:`movie`,nameKey:`automation.tplMovieName`,descKey:`automation.tplMovieDesc`,form:{...J,name:e(`automation.tplMovieName`),instructions:e(`automation.tplMovieInstr`),freq:`daily`,time:`20:00`}},{id:`health`,nameKey:`automation.tplHealthName`,descKey:`automation.tplHealthDesc`,form:{...J,name:e(`automation.tplHealthName`),instructions:e(`automation.tplHealthInstr`),freq:`daily`,time:`14:00`}},{id:`why`,nameKey:`automation.tplWhyName`,descKey:`automation.tplWhyDesc`,form:{...J,name:e(`automation.tplWhyName`),instructions:e(`automation.tplWhyInstr`),freq:`daily`,time:`16:00`}},{id:`git`,nameKey:`automation.tplGitName`,descKey:`automation.tplGitDesc`,form:{...J,name:e(`automation.tplGitName`),instructions:e(`automation.tplGitInstr`),freq:`weekdays`,time:`09:00`}}],Lt=dt.find(e=>e.id===P.workflowTemplate),Rt=(P.jobKind===`workflow`?!!P.workflowTemplate:!!(P.name.trim()&&P.instructions.trim()))&&(P.freq===`custom`?!!P.cron.trim():P.freq!==`once`||!!P.onceAt);return(0,V.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-y-auto p-6 max-md:p-3`,children:[R,(0,V.jsxs)(`div`,{className:`max-w-7xl w-full mx-auto`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between mb-1`,children:[(0,V.jsxs)(`h2`,{className:`text-xl font-semibold flex items-center gap-2`,children:[(0,V.jsx)(x,{size:20,className:`text-accent-blue`}),e(`automation.title`)]}),(0,V.jsx)(`button`,{onClick:()=>void a(),className:`p-2 rounded-lg hover:bg-dark-hover text-dark-muted`,title:e(`automation.refresh`),children:(0,V.jsx)(ee,{size:16})})]}),(0,V.jsx)(`p`,{className:`text-sm text-dark-muted mb-4`,children:e(`automation.subtitle`)}),(0,V.jsx)(`div`,{className:`mb-4`,children:n.length===0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,V.jsx)(t,{size:15,className:`text-accent-yellow`}),(0,V.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`automation.recommendedTitle`)})]}),(0,V.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-4`,children:It.map(t=>(0,V.jsxs)(`button`,{onClick:()=>void $(t),className:`flex flex-col gap-1 rounded-xl border border-dark-border bg-dark-surface p-2.5 text-start transition-colors hover:border-accent-blue/60 hover:bg-dark-hover/50`,children:[(0,V.jsx)(`span`,{className:`text-xs font-semibold`,children:e(t.nameKey)}),(0,V.jsx)(`span`,{className:`text-meta leading-relaxed text-dark-muted line-clamp-1`,children:e(t.descKey)}),(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 self-start rounded bg-dark-hover px-1.5 py-0.5 text-badge text-dark-muted`,children:[(0,V.jsx)(x,{size:11}),` `,Z(Ze(t.form),e)]})]},t.id))})]}):(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,V.jsxs)(`span`,{className:`flex items-center gap-1.5 pe-1 text-meta font-medium text-dark-muted`,children:[(0,V.jsx)(t,{size:13,className:`text-accent-yellow`}),e(`automation.recommendedTitle`)]}),It.map(t=>(0,V.jsxs)(`button`,{onClick:()=>void $(t),title:e(t.descKey),className:`flex items-center gap-1.5 rounded-lg border border-dark-border bg-dark-surface px-2 py-1 text-meta text-dark-muted transition-colors hover:border-accent-blue/60 hover:text-dark-text`,children:[(0,V.jsx)(h,{size:11}),e(t.nameKey),(0,V.jsx)(`span`,{className:`text-badge tabular-nums opacity-60`,children:Z(Ze(t.form),e)})]},t.id))]})}),D&&(0,V.jsxs)(`div`,{className:`mb-4 p-3 rounded-lg bg-accent-red/10 text-accent-red text-sm flex items-center gap-2`,children:[(0,V.jsx)(v,{size:16}),` `,D]}),(0,V.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(`div`,{className:`flex items-center rounded-lg border border-dark-border bg-dark-surface p-0.5`,children:qe.map(({id:t,key:n,Icon:r})=>(0,V.jsxs)(`button`,{onClick:()=>Pe(t),"aria-pressed":B===t,className:`flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${B===t?`bg-accent-blue/15 text-accent-blue font-medium`:`text-dark-muted hover:text-dark-text`}`,children:[(0,V.jsx)(r,{size:13}),` `,e(n)]},t))}),B!==`list`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(`button`,{onClick:()=>tt(-1),title:e(`automation.prevPeriod`),className:`rounded-lg border border-dark-border bg-dark-surface p-1.5 text-dark-muted hover:text-dark-text`,children:(0,V.jsx)(te,{size:14})}),(0,V.jsx)(`button`,{onClick:nt,className:`rounded-lg border border-dark-border bg-dark-surface px-2 py-1.5 text-xs text-dark-muted hover:text-dark-text`,children:e(`automation.today`)}),(0,V.jsx)(`button`,{onClick:()=>tt(1),title:e(`automation.nextPeriod`),className:`rounded-lg border border-dark-border bg-dark-surface p-1.5 text-dark-muted hover:text-dark-text`,children:(0,V.jsx)(u,{size:14})})]}),(0,V.jsx)(`span`,{className:`text-sm font-medium tabular-nums`,children:it})]}),(0,V.jsxs)(`div`,{className:`ms-auto flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`text-xs text-dark-muted`,children:e(`automation.tasksCount`,{count:n.length})}),(0,V.jsxs)(`button`,{type:`button`,"data-testid":`automation-ai-assist`,onClick:Nt,title:e(`automation.aiAssistHint`),className:`flex items-center gap-1 rounded-lg border border-accent-blue/40 bg-accent-blue/10 px-2.5 py-1.5 text-xs font-medium text-accent-blue transition-colors hover:bg-accent-blue/20`,children:[(0,V.jsx)(t,{size:13}),` `,e(`automation.aiAssist`)]}),(0,V.jsxs)(`button`,{onClick:()=>void $(),className:`flex items-center gap-1 rounded-lg bg-accent-blue px-3 py-1.5 text-xs font-medium text-accent-fg hover:brightness-110`,children:[(0,V.jsx)(h,{size:14}),` `,e(`automation.new`)]})]})]}),B!==`list`&&(0,V.jsxs)(`div`,{className:`mb-6 flex flex-col gap-4 lg:flex-row lg:items-start`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[B===`month`?(0,V.jsx)(ze,{anchor:H,selectedDay:W,byDay:Y,onSelectDay:K,onFocusSlot:(e,t)=>{Le(e),G(t)},onMoveOccurrence:(e,t)=>void rt(e,t)}):(0,V.jsx)(Be,{anchor:H,selectedDay:W,byDay:Y,onSelectDay:K,onFocusSlot:(e,t)=>{Le(e),G(t)},onMoveOccurrence:(e,t)=>void rt(e,t)}),n.length===0&&(0,V.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 rounded-lg border border-dashed border-dark-border px-3 py-2 text-xs text-dark-muted`,children:[(0,V.jsx)(l,{size:14}),e(`automation.emptyTitle`),` · `,e(`automation.emptyDesc`)]})]}),(0,V.jsx)(Ve,{day:W,occurrences:X,focusSlot:Re,onClearFocus:()=>G(null),onEdit:e=>void wt(e),onRun:e=>void fe(e),onToggle:e=>void le(e.id,e.status!==`enabled`),onDelete:e=>void Oe(e),onCreate:()=>void $()})]}),B===`list`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`automation.mineTitle`)}),(0,V.jsx)(`span`,{className:`text-xs text-dark-muted`,children:n.length})]}),n.length===0?(0,V.jsxs)(`div`,{className:`rounded-xl border border-dashed border-dark-border py-12 flex flex-col items-center gap-2 text-center`,children:[(0,V.jsx)(l,{size:32,className:`text-dark-muted`}),(0,V.jsx)(`p`,{className:`text-sm font-medium`,children:e(`automation.emptyTitle`)}),(0,V.jsx)(`p`,{className:`text-xs text-dark-muted`,children:e(`automation.emptyDesc`)}),(0,V.jsxs)(`button`,{onClick:()=>void $(),className:`mt-2 flex items-center gap-1 px-4 py-1.5 rounded-lg border border-dark-border bg-dark-surface hover:bg-dark-hover text-sm font-medium`,children:[(0,V.jsx)(h,{size:15}),` `,e(`automation.new`)]})]}):(0,V.jsx)(`div`,{className:`space-y-2`,children:n.map(t=>(0,V.jsxs)(`div`,{className:`rounded-xl border border-dark-border bg-dark-surface`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between p-3`,children:[(0,V.jsxs)(`button`,{onClick:()=>void Mt(t.id),className:`flex items-center gap-2 min-w-0 text-start`,children:[(0,V.jsx)(x,{size:16,className:`text-accent-blue shrink-0`}),(0,V.jsx)(`span`,{className:`font-medium text-sm truncate`,children:t.name}),(0,V.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded shrink-0 ${t.status===`enabled`?`bg-accent-green/20 text-accent-green`:`bg-dark-hover text-dark-muted`}`,children:t.status===`enabled`?e(`automation.enabled`):e(`automation.disabled`)}),(0,V.jsx)(`span`,{className:`text-xs text-dark-muted shrink-0 hidden md:inline`,children:Z(t.schedule,e)})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[t.nextRunAt&&(0,V.jsxs)(`span`,{className:`text-xs text-dark-muted hidden lg:inline me-1`,children:[e(`automation.nextRun`),`: `,new Date(t.nextRunAt).toLocaleString()]}),(0,V.jsx)(`button`,{onClick:()=>void wt(t),className:`p-1.5 rounded-lg hover:bg-dark-hover text-dark-muted`,title:e(`automation.edit`),children:(0,V.jsx)(f,{size:15})}),(0,V.jsx)(`button`,{onClick:()=>void le(t.id,t.status!==`enabled`),className:`p-1.5 rounded-lg hover:bg-dark-hover text-dark-muted`,title:t.status===`enabled`?e(`automation.disable`):e(`automation.enable`),children:(0,V.jsx)(ne,{size:15})}),(0,V.jsx)(`button`,{onClick:()=>void fe(t.id),className:`p-1.5 rounded-lg hover:bg-dark-hover text-accent-green`,title:e(`automation.runNow`),children:(0,V.jsx)(ie,{size:15})}),(0,V.jsx)(`button`,{onClick:()=>void Oe(t),className:`p-1.5 rounded-lg hover:bg-dark-hover text-accent-red`,title:e(`automation.delete`),children:(0,V.jsx)(oe,{size:15})})]})]}),ye===t.id&&(0,V.jsxs)(`div`,{className:`px-3 pb-3 space-y-3 border-t border-dark-border pt-3`,children:[Ke(t.name)?(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsxs)(`p`,{className:`text-xs text-dark-muted flex items-center gap-1.5`,children:[(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-accent-blue/10 text-accent-blue`,children:[(0,V.jsx)(y,{size:11}),` `,e(`automation.jobKindWorkflow`)]}),(0,V.jsx)(`code`,{children:Ke(t.name)})]}),t.instructions.trim()&&(0,V.jsx)(`pre`,{className:`text-badge text-dark-muted whitespace-pre-wrap font-mono`,children:t.instructions})]}):(0,V.jsx)(`p`,{className:`text-xs text-dark-muted whitespace-pre-wrap`,children:t.instructions}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`h4`,{className:`text-xs font-semibold text-dark-muted mb-1 flex items-center gap-1`,children:[(0,V.jsx)(d,{size:12}),` `,e(`automation.historyTitle`)]}),(i[t.id]||[]).length===0&&(0,V.jsx)(`p`,{className:`text-xs text-dark-muted`,children:e(`automation.noRuns`)}),(i[t.id]||[]).slice(0,10).map(e=>(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-xs py-1`,children:[(0,V.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded flex items-center gap-1 ${e.status===`ok`?`bg-accent-green/20 text-accent-green`:e.status===`error`?`bg-accent-red/20 text-accent-red`:`bg-accent-yellow/20 text-accent-yellow`}`,children:[e.status===`ok`&&(0,V.jsx)(p,{size:11}),e.status]}),(0,V.jsx)(`span`,{className:`text-dark-muted`,children:new Date(e.startedAt).toLocaleString()}),(0,V.jsxs)(`span`,{className:`text-dark-muted truncate flex-1`,children:[`#`,e.id.slice(0,8),` · `,e.trigger]})]},e.id))]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-xs font-semibold text-dark-muted mb-1`,children:e(`automation.permissionsTitle`)}),t.permissions.length===0&&(0,V.jsx)(`p`,{className:`text-xs text-dark-muted`,children:e(`automation.permissionsEmpty`)}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:t.permissions.map(e=>(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded bg-accent-blue/10 text-accent-blue text-xs`,children:[e,(0,V.jsx)(`button`,{onClick:()=>void jt(t.id,e),className:`hover:text-accent-red`,children:(0,V.jsx)(S,{size:12})})]},e))}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(`input`,{value:Ce,onChange:e=>Te(e.target.value),placeholder:e(`automation.permissionPlaceholder`),className:`flex-1 px-2 py-1.5 rounded-lg bg-dark-bg border border-dark-border text-xs focus:outline-none focus:border-accent-blue`}),(0,V.jsx)(`button`,{onClick:()=>void At(t.id),className:`px-3 py-1.5 rounded-lg bg-dark-hover text-dark-muted hover:text-dark-text text-xs`,children:e(`automation.add`)})]})]})]})]},t.id))})]})]}),j&&(0,V.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4 max-md:p-0`,onClick:Tt,children:[(0,V.jsx)(`div`,{className:`absolute inset-0 ui-scrim ui-overlay-backdrop`,"data-phase":M,"aria-hidden":`true`}),(0,V.jsxs)(`div`,{className:`relative w-full max-w-2xl rounded-xl border border-dark-border bg-dark-overlay ui-surface-overlay p-5 space-y-4 shadow-pop max-h-[90vh] overflow-y-auto custom-scrollbar ui-overlay-panel max-md:max-w-none max-md:rounded-none max-md:p-4`,"data-phase":M,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-base font-semibold`,children:e(ve?`automation.editTitle`:`automation.createTitle`)}),(0,V.jsx)(`p`,{className:`text-xs text-dark-muted mt-0.5`,children:e(`automation.subtitle`)})]}),(0,V.jsx)(`button`,{onClick:Tt,className:`p-1.5 rounded-lg hover:bg-dark-hover text-dark-muted`,children:(0,V.jsx)(S,{size:16})})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-xs font-medium text-dark-muted mb-1.5`,children:e(`automation.jobKindLabel`)}),(0,V.jsx)(`div`,{className:`flex gap-1.5`,children:[{id:`agent`,label:e(`automation.jobKindAgent`),hint:e(`automation.jobKindAgentHint`)},{id:`workflow`,label:e(`automation.jobKindWorkflow`),hint:e(`automation.jobKindWorkflowHint`)}].map(e=>{let n=P.jobKind===e.id;return(0,V.jsxs)(`button`,{type:`button`,title:e.hint,onClick:()=>Dt(e.id),className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 ${n?`border-accent-blue bg-accent-blue/10 text-accent-blue`:`border-dark-border bg-dark-surface text-dark-muted hover:bg-dark-hover`}`,children:[e.id===`workflow`?(0,V.jsx)(y,{size:13}):(0,V.jsx)(t,{size:13}),e.label]},e.id)})})]}),P.jobKind===`workflow`&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-xs font-medium text-dark-muted mb-1.5`,children:e(`automation.workflowTemplateLabel`)}),(0,V.jsxs)(`select`,{value:P.workflowTemplate,onChange:e=>{let t=e.target.value;F(e=>({...e,workflowTemplate:t,name:t?`${We}${t}`:``}))},className:`w-full px-3 py-2 rounded-lg bg-dark-surface border border-dark-border text-sm focus:outline-none focus:border-accent-blue`,children:[(0,V.jsx)(`option`,{value:``,children:e(`automation.workflowTemplateNone`)}),dt.map(e=>(0,V.jsx)(`option`,{value:e.id,children:(e.nameOverride||e.name||e.id)+(e.category?` · ${e.category}`:``)},e.id))]}),pt&&dt.length===0&&(0,V.jsx)(`p`,{className:`text-badge text-dark-muted/70 mt-1`,children:e(`automation.workflowTemplateEmpty`)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-xs font-medium text-dark-muted mb-1.5`,children:e(`automation.nameLabel`)}),(0,V.jsx)(`input`,{autoFocus:P.jobKind===`agent`,value:P.name,onChange:e=>F(t=>({...t,name:e.target.value})),placeholder:e(`automation.namePlaceholder`),disabled:P.jobKind===`workflow`,className:`w-full px-3 py-2 rounded-lg bg-dark-surface border border-dark-border text-sm focus:outline-none focus:border-accent-blue disabled:opacity-60`}),P.jobKind===`workflow`&&(0,V.jsx)(`p`,{className:`text-badge text-dark-muted/70 mt-1`,children:e(`automation.workflowNameHint`)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-xs font-medium text-dark-muted mb-1.5`,children:e(`automation.scheduleLabel`)}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsxs)(`select`,{value:P.freq,onChange:e=>F(t=>({...t,freq:e.target.value})),className:`px-2.5 py-2 rounded-lg bg-dark-surface border border-dark-border text-sm focus:outline-none focus:border-accent-blue`,children:[(0,V.jsx)(`option`,{value:`daily`,children:e(`automation.freqDaily`)}),(0,V.jsx)(`option`,{value:`weekly`,children:e(`automation.freqWeekly`)}),(0,V.jsx)(`option`,{value:`weekdays`,children:e(`automation.freqWeekdays`)}),(0,V.jsx)(`option`,{value:`once`,children:e(`automation.freqOnce`)}),(0,V.jsx)(`option`,{value:`custom`,children:e(`automation.freqCustom`)})]}),P.freq===`weekly`&&(0,V.jsx)(`select`,{value:P.dow,onChange:e=>F(t=>({...t,dow:e.target.value})),className:`px-2.5 py-2 rounded-lg bg-dark-surface border border-dark-border text-sm focus:outline-none focus:border-accent-blue`,children:Qe.map(t=>(0,V.jsx)(`option`,{value:t.value,children:e(t.key)},t.value))}),(P.freq===`daily`||P.freq===`weekly`||P.freq===`weekdays`)&&(0,V.jsx)(`input`,{type:`time`,value:P.time,onChange:e=>F(t=>({...t,time:e.target.value})),className:`flex-1 px-3 py-2 rounded-lg bg-dark-surface border border-dark-border text-sm focus:outline-none focus:border-accent-blue`}),P.freq===`once`&&(0,V.jsx)(`input`,{type:`datetime-local`,value:P.onceAt,onChange:e=>F(t=>({...t,onceAt:e.target.value})),className:`flex-1 px-3 py-2 rounded-lg bg-dark-surface border border-dark-border text-sm focus:outline-none focus:border-accent-blue`}),P.freq===`custom`&&(0,V.jsx)(`input`,{value:P.cron,onChange:e=>F(t=>({...t,cron:e.target.value})),placeholder:`*/30 * * * *`,className:`flex-1 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm font-mono focus:outline-none focus:border-accent-blue`})]})]}),P.jobKind===`agent`?(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-xs font-medium text-dark-muted mb-1.5`,children:e(`automation.instructionLabel`)}),(0,V.jsx)(`textarea`,{value:P.instructions,onChange:e=>F(t=>({...t,instructions:e.target.value})),placeholder:e(`automation.instructionsPlaceholder`),rows:4,className:`w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue resize-none`})]}):(0,V.jsxs)(`div`,{className:`rounded-lg border border-dark-border bg-dark-surface/40 p-3 space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsx)(`label`,{className:`text-xs font-medium text-dark-muted`,children:e(`automation.workflowInputsLabel`)}),(Lt?.inputs.length??0)>0&&(0,V.jsx)(`button`,{type:`button`,onClick:Ot,className:`text-badge text-accent-blue hover:underline`,children:e(`automation.workflowInputsFillDefaults`)})]}),Lt&&Lt.inputs.length>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`ul`,{className:`space-y-0.5`,children:Lt.inputs.map(e=>(0,V.jsxs)(`li`,{className:`text-badge text-dark-muted`,children:[(0,V.jsx)(`code`,{className:`text-accent-blue`,children:e.name}),e.label&&(0,V.jsx)(`span`,{className:`ms-1`,children:e.label}),e.required&&(0,V.jsx)(`span`,{className:`ms-1 text-accent-red`,children:`*`}),e.description&&(0,V.jsxs)(`span`,{className:`ms-1 text-dark-muted/60`,children:[`— `,e.description]})]},e.name))}),(0,V.jsx)(`textarea`,{value:P.instructions,onChange:e=>F(t=>({...t,instructions:e.target.value})),placeholder:`{
3
+ "key": "value"
4
+ }`,rows:4,className:`w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-xs font-mono focus:outline-none focus:border-accent-blue resize-none`}),(0,V.jsx)(`p`,{className:`text-badge text-dark-muted/70`,children:e(`automation.workflowInputsHint`)})]}):(0,V.jsx)(`p`,{className:`text-xs text-dark-muted/70`,children:e(`automation.workflowNoInputs`)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5`,children:[(0,V.jsx)(se,{size:12}),` `,e(`automation.attachmentsLabel`)]}),(0,V.jsx)(`p`,{className:`text-badge text-dark-muted/70 mb-1.5`,children:e(`automation.attachmentsHint`)}),St.length===0?(0,V.jsx)(`div`,{className:`text-xs text-dark-muted/60 italic`,children:e(`automation.attachmentsEmpty`)}):(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-2`,children:St.map(e=>(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded-md text-xs ${e.error?`bg-accent-red/10 text-accent-red`:e.uploading?`bg-dark-hover text-dark-muted`:`bg-accent-blue/10 text-accent-blue`}`,title:e.path??e.error,children:[(0,V.jsx)(se,{size:11}),(0,V.jsx)(`span`,{className:`truncate max-w-[180px]`,children:e.name}),e.uploading&&(0,V.jsx)(ae,{size:11,className:`animate-spin`}),e.error&&(0,V.jsx)(v,{size:11}),(0,V.jsx)(`button`,{onClick:()=>Ft(e.id),className:`hover:text-accent-red ms-0.5`,children:(0,V.jsx)(S,{size:11})})]},e.id))}),(0,V.jsx)(`input`,{ref:Ct,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{Pt(e.target.files),e.target.value=``}}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>Ct.current?.click(),className:`inline-flex items-center gap-1 px-2.5 py-1 rounded-lg border border-dashed border-dark-border text-xs text-dark-muted hover:border-accent-blue/60 hover:text-accent-blue`,children:[(0,V.jsx)(h,{size:12}),` `,e(`automation.attachmentsAdd`)]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5`,children:[(0,V.jsx)(g,{size:12}),` `,e(`automation.modelLabel`)]}),(0,V.jsxs)(`select`,{value:P.modelRef,onChange:e=>F(t=>({...t,modelRef:e.target.value})),className:`w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue disabled:opacity-50 disabled:cursor-not-allowed`,disabled:yt||P.runSessionMode!==`new`,children:[(0,V.jsx)(`option`,{value:``,children:e(`automation.modelAuto`)}),at.map(e=>(0,V.jsxs)(`option`,{value:`${e.provider}:${e.id}`,children:[e.name,` · `,e.provider]},`${e.provider}:${e.id}`))]}),P.runSessionMode!==`new`&&(0,V.jsx)(`p`,{className:`text-badge text-dark-muted/70 mt-1`,children:e(`automation.modelFollowsSession`)}),!yt&&at.length===0&&(0,V.jsx)(`p`,{className:`text-badge text-dark-muted/70 mt-1`,children:e(`automation.modelNoModels`)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5`,children:[(0,V.jsx)(re,{size:12}),` `,e(`automation.runSessionLabel`)]}),(0,V.jsxs)(`select`,{value:P.runSessionMode,onChange:e=>{let t=e.target.value;F(e=>({...e,runSessionMode:t})),t===`fixed`&&xt()},className:`w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue`,children:[(0,V.jsx)(`option`,{value:`home`,children:e(`automation.runSessionHome`)}),(0,V.jsx)(`option`,{value:`new`,children:e(`automation.runSessionNew`)}),(0,V.jsx)(`option`,{value:`fixed`,children:e(`automation.runSessionFixed`)})]}),P.runSessionMode===`fixed`&&(0,V.jsxs)(`select`,{value:P.runSessionId,onChange:e=>F(t=>({...t,runSessionId:e.target.value})),className:`mt-2 w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue`,disabled:yt,children:[(0,V.jsx)(`option`,{value:``,children:e(`automation.runSessionPick`)}),ht.map(e=>(0,V.jsx)(`option`,{value:e.id,children:e.title||e.id},e.id))]}),(0,V.jsx)(`p`,{className:`text-badge text-dark-muted/70 mt-1`,children:e(`automation.runSessionHint`)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5`,children:[(0,V.jsx)(m,{size:12}),` `,e(`automation.budgetLabel`)]}),(0,V.jsx)(`input`,{type:`text`,inputMode:`decimal`,value:P.budgetUsd,onChange:e=>F(t=>({...t,budgetUsd:e.target.value})),placeholder:e(`automation.budgetPlaceholder`),className:`w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue`}),(0,V.jsx)(`p`,{className:`text-badge text-dark-muted/70 mt-1`,children:e(`automation.budgetHint`)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5`,children:[(0,V.jsx)(_,{size:12}),` `,e(`automation.connectorsLabel`)]}),(0,V.jsx)(`p`,{className:`text-badge text-dark-muted/70 mb-1.5`,children:e(`automation.connectorsHint`)}),(0,V.jsx)(`p`,{className:`text-badge text-accent-yellow/90 mb-1.5`,children:e(`automation.connectorsUnwired`)}),st.length===0?(0,V.jsx)(`div`,{className:`text-xs text-dark-muted/60 italic`,children:e(`automation.connectorsEmpty`)}):(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5 opacity-50`,children:st.map(t=>{let n=P.connectorIds.includes(t.id);return(0,V.jsxs)(`button`,{type:`button`,disabled:!0,"aria-disabled":!0,title:e(`automation.connectorsUnwired`),className:`inline-flex items-center gap-1 px-2 py-1 rounded-md text-xs border cursor-not-allowed ${n?`bg-accent-blue/15 text-accent-blue border-accent-blue/40`:`bg-dark-bg text-dark-muted border-dark-border`}`,children:[(0,V.jsx)(_,{size:11}),t.name]},t.id)})})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5`,children:[(0,V.jsx)(c,{size:12}),` `,e(`automation.channelsLabel`)]}),(0,V.jsx)(`p`,{className:`text-badge text-dark-muted/70 mb-1.5`,children:e(`automation.channelsHint`)}),lt.length===0?(0,V.jsx)(`div`,{className:`text-xs text-dark-muted/60 italic`,children:e(`automation.channelsEmpty`)}):(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:lt.map(e=>{let t=P.channelIds.includes(e.id);return(0,V.jsxs)(`button`,{type:`button`,disabled:!e.enabled,onClick:()=>F(n=>({...n,channelIds:t?n.channelIds.filter(t=>t!==e.id):[...n.channelIds,e.id]})),className:`inline-flex items-center gap-1 px-2 py-1 rounded-md text-xs transition-colors ${t?`bg-accent-blue/15 text-accent-blue border border-accent-blue/40`:e.enabled?`bg-dark-bg text-dark-muted border border-dark-border hover:border-accent-blue/40 hover:text-accent-blue`:`bg-dark-bg text-dark-muted/50 border border-dark-border opacity-60 cursor-not-allowed`}`,children:[(0,V.jsx)(c,{size:11}),e.name,!e.enabled&&(0,V.jsx)(`span`,{className:`text-avatar`,children:`·off`})]},e.id)})})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5`,children:[(0,V.jsx)(r,{size:12}),` `,e(`automation.workspaceLabel`)]}),(0,V.jsx)(`p`,{className:`text-badge text-dark-muted/70 mb-1.5`,children:e(`automation.workspaceHint`)}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(`input`,{value:P.workspaceDir,onChange:e=>F(t=>({...t,workspaceDir:e.target.value})),placeholder:`留空使用当前工作目录`,className:`flex-1 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm font-mono focus:outline-none focus:border-accent-blue`}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>z(!0),className:`shrink-0 inline-flex items-center gap-1 px-3 py-2 rounded-lg border border-dark-border text-xs text-dark-muted hover:bg-dark-hover hover:text-dark-text`,children:[(0,V.jsx)(r,{size:12}),` `,e(`automation.workspacePick`)]}),P.workspaceDir&&(0,V.jsx)(`button`,{type:`button`,onClick:()=>F(e=>({...e,workspaceDir:``})),className:`shrink-0 inline-flex items-center gap-1 px-2 py-2 rounded-lg border border-dark-border text-xs text-dark-muted hover:bg-dark-hover hover:text-accent-red`,title:e(`automation.workspaceClear`),children:(0,V.jsx)(S,{size:12})})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5`,children:[(0,V.jsx)(ce,{size:12}),` `,e(`automation.permissionAccess`)]}),(0,V.jsxs)(`div`,{className:`flex items-start gap-2 p-2.5 rounded-lg border border-dark-border bg-dark-bg`,children:[(0,V.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":P.readAutoAllow,onClick:()=>F(e=>({...e,readAutoAllow:!e.readAutoAllow})),className:`relative shrink-0 mt-0.5 inline-flex h-5 w-9 items-center rounded-full transition-colors ${P.readAutoAllow?`bg-accent-blue`:`bg-dark-hover`}`,children:(0,V.jsx)(`span`,{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${P.readAutoAllow?`translate-x-4`:`translate-x-0.5`}`})}),(0,V.jsxs)(`div`,{className:`flex-1`,children:[(0,V.jsx)(`div`,{className:`text-xs font-medium text-dark-text`,children:e(`automation.fullAccessLabel`)}),(0,V.jsx)(`p`,{className:`text-badge text-dark-muted/80 mt-0.5`,children:e(`automation.fullAccessHint`)})]})]})]}),(0,V.jsxs)(`div`,{className:`flex justify-end gap-2 pt-1`,children:[(0,V.jsx)(`button`,{onClick:Tt,className:`px-4 py-2 rounded-lg bg-dark-hover text-dark-muted hover:text-dark-text text-sm`,children:e(`automation.cancel`)}),(0,V.jsx)(de,{variant:`accent`,onClick:()=>void kt(),disabled:!Rt,loading:Ee,children:e(`automation.save`)})]})]})]}),(0,we.createPortal)((0,V.jsx)(et,{isOpen:ke&&O,initial:P.workspaceDir||``,onClose:()=>z(!1),onConfirm:e=>{F(t=>({...t,workspaceDir:e})),z(!1)}}),document.body)]})}export{tt as AutomationView};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{ii as t,qt as n}from"./icons-CittejKL.js";import{n as r}from"./state-A4wJ8QgR.js";import{I as i}from"./markdown-DZQBOzWk.js";import{t as a}from"./cn-CoHJgTJ5.js";var o=4e3,s=new Map;function c(e,t){let n=s.get(e);n&&clearTimeout(n),!(t<=0)&&s.set(e,setTimeout(()=>{s.delete(e),l.setState(t=>({toasts:t.toasts.filter(t=>t.id!==e)}))},t))}var l=r(e=>({toasts:[],addToast:(t,n,r,i,a)=>{let s=r??o,l=e=>e.dedupeKey??`${e.type}\u0000${e.message}`,u=a??`${t}\u0000${n}`;e(e=>{let r=e.toasts.find(e=>l(e)===u);if(r)return c(r.id,s),{toasts:e.toasts.map(e=>e.id===r.id?{...e,count:e.count+1,createdAt:Date.now(),action:i??e.action}:e)};let o=`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`;c(o,s);let d={id:o,type:t,message:n,duration:s,createdAt:Date.now(),count:1,action:i,...a?{dedupeKey:a}:{}};return{toasts:[...e.toasts,d].slice(-10)}})},dismissToast:t=>{let n=s.get(t);n&&(clearTimeout(n),s.delete(t)),e(e=>({toasts:e.toasts.filter(e=>e.id!==t)}))},clearAll:()=>{for(let e of s.values())clearTimeout(e);s.clear(),e({toasts:[]})}})),u={info:(e,t)=>l.getState().addToast(`info`,e,t),success:(e,t)=>l.getState().addToast(`success`,e,t),warning:(e,t)=>l.getState().addToast(`warning`,e,t),error:(e,t)=>l.getState().addToast(`error`,e,t??6e3),infoWithAction:(e,t,n,r)=>l.getState().addToast(`info`,e,n,t,r)},d=e(t(),1),f=20;function p(){if(typeof window>`u`||typeof getComputedStyle!=`function`)return 220;let e=getComputedStyle(document.documentElement).getPropertyValue(`--dur-base`).trim(),t=Number.parseFloat(e);return!Number.isFinite(t)||t<=0?220:(e.endsWith(`ms`)?t:t*1e3)+f}function m(e){let[t,n]=(0,d.useState)(e),[r,i]=(0,d.useState)(!1),a=(0,d.useRef)(e);return a.current!==e&&(a.current=e,e?(n(!0),i(!1)):t&&i(!0)),(0,d.useEffect)(()=>{if(!r)return;let e=window.setTimeout(()=>{i(!1),n(!1)},p());return()=>window.clearTimeout(e)},[r]),{visible:t,phase:r?`exit`:`enter`}}var h=i(),g={primary:`btn-primary`,accent:`btn-accent`,secondary:`btn-secondary`,ghost:`btn-ghost`,danger:`btn-danger`},_={sm:`btn-sm`,lg:`btn-lg`},v={sm:13,md:15,lg:17};function y({variant:e=`secondary`,size:t=`md`,shape:r=`default`,loading:i=!1,leftIcon:o,rightIcon:s,type:c=`button`,disabled:l,className:u,children:d,ref:f,...p}){return(0,h.jsxs)(`button`,{ref:f,type:c,disabled:l||i,"aria-busy":i||void 0,className:a(`btn`,g[e],t!==`md`&&_[t],r===`pill`&&`btn-pill`,u),...p,children:[i?(0,h.jsx)(n,{size:v[t],className:`shrink-0 animate-spin`,"aria-hidden":`true`}):o,d,!i&&s]})}export{l as i,m as n,u as r,y as t};
@@ -1,12 +1,12 @@
1
- import{i as e,t}from"./rolldown-runtime-COiEfhsA.js";import{$ as n,A as r,Dn as i,a,dt as o,ft as s,g as c,it as l,ni as u,o as d,st as f,ti as p,v as m,zr as h}from"./icons-B8Ngx6rM.js";import{t as g}from"./useTranslation-gGKZZfux.js";import{i as _,t as v}from"./Button-D-g7PgYh.js";import{t as y}from"./api-ZQf0Ys8y.js";import{I as b}from"./markdown-Cps-36Z5.js";import{r as x,t as S}from"./useConfirm-CQjBnYuP.js";import"./common-CPZxdYLs.js";import{n as C,r as w,t as T}from"./channelMeta-BO645sjD.js";import{ft as E,v as D}from"./index-STsyoFCk.js";import{n as O}from"./installDiagnosis-ZYUVgJIJ.js";var k=e(u(),1),A=b(),j=[{labelKey:`im`,types:[`wechat`,`weixin-im`,`feishu`,`dingtalk`]},{labelKey:`international`,types:[`telegram`,`telegram-im`,`discord`,`discord-im`,`slack`,`slack-im`,`signal`,`whatsapp`]},{labelKey:`eastAsia`,types:[`line`,`qqbot`]},{labelKey:`collaboration`,types:[`matrix`,`mattermost`,`msteams`,`googlechat`]},{labelKey:`classic`,types:[`irc`,`imessage`,`sms`]},{labelKey:`other`,types:[`nextcloud-talk`,`nostr`,`synology-chat`,`tlon`,`twitch`,`zalo`,`zalouser`]},{labelKey:`builtin`,types:[`clickclack`,`raft`,`qa-channel`]}];function M(){let{t:e}=g(),{channels:t,availableTypes:n,typesLoaded:r,selectedType:i,selectType:a,loadTypes:o}=D();(0,k.useEffect)(()=>{o()},[o]);let s=(0,k.useMemo)(()=>{if(n.length===0)return[];let e=new Set(n),t=j.map(t=>({...t,types:t.types.filter(t=>e.has(t))})).filter(e=>e.types.length>0),r=new Set(j.flatMap(e=>e.types)),i=n.filter(e=>!r.has(e));return i.length>0?[...t,{labelKey:`plugins`,types:i}]:t},[n]),c=(0,k.useMemo)(()=>{let e=new Map;for(let n of t){let t=e.get(n.type)??{count:0,connected:0};e.set(n.type,{count:t.count+1,connected:t.connected+ +!!n.connected})}return e},[t]),l=n.length>0,u=(0,k.useMemo)(()=>l?t.filter(e=>n.includes(e.type)):[],[l,t,n]);return(0,A.jsxs)(`div`,{className:`flex flex-col h-full min-h-0 border-e border-dark-border bg-dark-surface`,children:[(0,A.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-dark-border`,children:[(0,A.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-dark-muted`,children:e(`channels.sidebar.title`)}),(0,A.jsx)(`p`,{className:`text-meta text-dark-muted mt-0.5`,children:u.length>0?e(`channels.sidebar.configuredCount`,{n:u.length}):e(l?`channels.sidebar.clickToConfigure`:`channels.sidebar.emptyHint`)})]}),(0,A.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:[r&&!l&&(0,A.jsxs)(`div`,{className:`px-4 py-10 text-center`,children:[(0,A.jsx)(`p`,{className:`text-xs text-dark-muted`,children:e(`channels.sidebar.empty`)}),(0,A.jsx)(`p`,{className:`text-meta text-dark-muted/70 mt-1.5 leading-relaxed`,children:e(`channels.sidebar.emptyHint`)})]}),s.map(t=>{let n=t.types.filter(e=>c.has(e));return n.length===0?null:(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:`sticky top-0 bg-dark-surface/95 backdrop-blur px-4 py-1.5 text-badge font-semibold uppercase tracking-wider text-dark-muted/60`,children:e(`channels.categories.${t.labelKey}`)}),n.map(e=>{let t=c.get(e);return(0,A.jsx)(N,{label:C(e),icon:T(e),isSelected:i===e,experimental:w(e),info:t,onClick:()=>a(e)},e)})]},t.labelKey)}),(()=>{let t=s.flatMap(e=>e.types).filter(e=>!c.has(e));return t.length===0?null:(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:`sticky top-0 bg-dark-surface/95 backdrop-blur px-4 py-1.5 text-badge font-semibold uppercase tracking-wider text-dark-muted/60`,children:e(`channels.sidebar.unconfigured`)}),t.map(e=>(0,A.jsx)(N,{label:C(e),icon:T(e),isSelected:i===e,experimental:w(e),onClick:()=>a(e)},e))]})})()]})]})}function N({label:e,icon:t,isSelected:n,experimental:r,info:o,onClick:s}){let{t:c}=g();return(0,A.jsxs)(`button`,{onClick:s,className:`w-full flex items-center gap-2.5 px-4 py-2.5 text-start transition-colors hover:bg-dark-hover ${n?`bg-accent-blue/10 border-s-2 border-accent-blue`:`border-s-2 border-transparent`}`,children:[(0,A.jsx)(`span`,{className:`text-lg shrink-0 w-7 h-7 flex items-center justify-center rounded-md bg-dark-bg`,children:t}),(0,A.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(`span`,{className:`text-sm font-medium text-dark-text truncate`,children:e}),r&&(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-avatar text-accent-yellow bg-accent-yellow/15 px-1 py-0.5 rounded shrink-0`,title:c(`channels.experimentalTip`),children:[(0,A.jsx)(i,{className:`w-2.5 h-2.5`}),` `,c(`channels.experimentalShort`)]}),o&&(0,A.jsx)(`span`,{className:`text-badge text-dark-muted bg-dark-hover px-1.5 py-0.5 rounded shrink-0`,children:o.count})]}),(0,A.jsx)(`div`,{className:`flex items-center gap-1 mt-0.5`,children:o?o.connected>0?(0,A.jsxs)(`span`,{className:`flex items-center gap-1 text-meta text-accent-green`,children:[(0,A.jsx)(a,{className:`w-3 h-3`}),o.connected===o.count?c(`channels.status.connected`):c(`channels.sidebar.partialConnected`,{connected:o.connected,count:o.count})]}):(0,A.jsxs)(`span`,{className:`flex items-center gap-1 text-meta text-dark-muted`,children:[(0,A.jsx)(d,{className:`w-3 h-3`}),c(`channels.status.disconnected`)]}):(0,A.jsx)(`span`,{className:`text-meta text-dark-muted`,children:c(`channels.sidebar.unconfigured`)})})]})]})}function P({result:e}){let{t}=g(),[n,r]=(0,k.useState)(!1),i=e.logs?.length?e.logs:[...e.message?[e.message]:[],...typeof e.probed==`boolean`?[`probed=${e.probed}`]:[],`connected=${e.connected}`,...typeof e.latencyMs==`number`?[`latencyMs=${e.latencyMs}`]:[]];return i.length===0?null:(0,A.jsxs)(`details`,{open:!e.ok,className:`mt-1`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer select-none text-meta text-dark-muted hover:text-dark-text`,children:[t(`channels.actions.debugLogs`),` · `,i.length]}),(0,A.jsxs)(`div`,{className:`mt-1 rounded-md border border-dark-border bg-dark-bg`,children:[(0,A.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap break-all p-2 font-mono text-meta leading-relaxed text-dark-muted`,children:i.join(`
1
+ import{i as e,t}from"./rolldown-runtime-COiEfhsA.js";import{$ as n,A as r,Vr as i,a,dt as o,ft as s,g as c,ii as l,it as u,kn as d,o as f,ri as p,st as m,v as h}from"./icons-CittejKL.js";import{t as g}from"./useTranslation-2BGEBvJE.js";import{r as _,t as v}from"./Button-B43HsIQ3.js";import{t as y}from"./api-BW4-5gtM.js";import{I as b}from"./markdown-DZQBOzWk.js";import"./common-CP2UB8TN.js";import{r as x,t as S}from"./useConfirm-kTv3x0H6.js";import{n as C,r as w,t as T}from"./channelMeta-BO645sjD.js";import{C as E,X as D}from"./index-CxrzleFg.js";import{n as O}from"./installDiagnosis-ZYUVgJIJ.js";var k=e(l(),1),A=b(),j=[{labelKey:`international`,types:[`telegram`,`telegram-im`,`discord`,`discord-im`,`slack`,`slack-im`,`signal`,`whatsapp`]},{labelKey:`collaboration`,types:[`matrix`,`mattermost`,`msteams`,`googlechat`]},{labelKey:`classic`,types:[`irc`,`imessage`,`sms`]},{labelKey:`other`,types:[`nextcloud-talk`,`nostr`,`synology-chat`,`tlon`,`twitch`,`zalo`,`zalouser`]},{labelKey:`builtin`,types:[`clickclack`,`raft`,`qa-channel`]},{labelKey:`eastAsia`,types:[`line`,`qqbot`]},{labelKey:`im`,types:[`wechat`,`weixin-im`,`feishu`,`dingtalk`]}];function M(){let{t:e}=g(),{channels:t,availableTypes:n,typesLoaded:r,selectedType:i,selectType:a,loadTypes:o}=E();(0,k.useEffect)(()=>{o()},[o]);let s=(0,k.useMemo)(()=>{if(n.length===0)return[];let e=new Set(n),t=j.map(t=>({...t,types:t.types.filter(t=>e.has(t))})).filter(e=>e.types.length>0),r=new Set(j.flatMap(e=>e.types)),i=n.filter(e=>!r.has(e));return i.length>0?[...t,{labelKey:`plugins`,types:i}]:t},[n]),c=(0,k.useMemo)(()=>{let e=new Map;for(let n of t){let t=e.get(n.type)??{count:0,connected:0};e.set(n.type,{count:t.count+1,connected:t.connected+ +!!n.connected})}return e},[t]),l=n.length>0,u=(0,k.useMemo)(()=>l?t.filter(e=>n.includes(e.type)):[],[l,t,n]);return(0,A.jsxs)(`div`,{className:`flex flex-col h-full min-h-0 border-e border-dark-border bg-dark-surface`,children:[(0,A.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-dark-border`,children:[(0,A.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-dark-muted`,children:e(`channels.sidebar.title`)}),(0,A.jsx)(`p`,{className:`text-meta text-dark-muted mt-0.5`,children:u.length>0?e(`channels.sidebar.configuredCount`,{n:u.length}):e(l?`channels.sidebar.clickToConfigure`:`channels.sidebar.emptyHint`)})]}),(0,A.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:[r&&!l&&(0,A.jsxs)(`div`,{className:`px-4 py-10 text-center`,children:[(0,A.jsx)(`p`,{className:`text-xs text-dark-muted`,children:e(`channels.sidebar.empty`)}),(0,A.jsx)(`p`,{className:`text-meta text-dark-muted/70 mt-1.5 leading-relaxed`,children:e(`channels.sidebar.emptyHint`)})]}),s.map(t=>{let n=t.types.filter(e=>c.has(e));return n.length===0?null:(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:`sticky top-0 bg-dark-surface/95 backdrop-blur px-4 py-1.5 text-badge font-semibold uppercase tracking-wider text-dark-muted/60`,children:e(`channels.categories.${t.labelKey}`)}),n.map(e=>{let t=c.get(e);return(0,A.jsx)(N,{label:C(e),icon:T(e),isSelected:i===e,experimental:w(e),info:t,onClick:()=>a(e)},e)})]},t.labelKey)}),(()=>{let t=s.flatMap(e=>e.types).filter(e=>!c.has(e));return t.length===0?null:(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:`sticky top-0 bg-dark-surface/95 backdrop-blur px-4 py-1.5 text-badge font-semibold uppercase tracking-wider text-dark-muted/60`,children:e(`channels.sidebar.unconfigured`)}),t.map(e=>(0,A.jsx)(N,{label:C(e),icon:T(e),isSelected:i===e,experimental:w(e),onClick:()=>a(e)},e))]})})()]})]})}function N({label:e,icon:t,isSelected:n,experimental:r,info:i,onClick:o}){let{t:s}=g();return(0,A.jsxs)(`button`,{onClick:o,className:`w-full flex items-center gap-2.5 px-4 py-2.5 text-start transition-colors hover:bg-dark-hover ${n?`bg-accent-blue/10 border-s-2 border-accent-blue`:`border-s-2 border-transparent`}`,children:[(0,A.jsx)(`span`,{className:`text-lg shrink-0 w-7 h-7 flex items-center justify-center rounded-md bg-dark-bg`,children:t}),(0,A.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(`span`,{className:`text-sm font-medium text-dark-text truncate`,children:e}),r&&(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-avatar text-accent-yellow bg-accent-yellow/15 px-1 py-0.5 rounded shrink-0`,title:s(`channels.experimentalTip`),children:[(0,A.jsx)(d,{className:`w-2.5 h-2.5`}),` `,s(`channels.experimentalShort`)]}),i&&(0,A.jsx)(`span`,{className:`text-badge text-dark-muted bg-dark-hover px-1.5 py-0.5 rounded shrink-0`,children:i.count})]}),(0,A.jsx)(`div`,{className:`flex items-center gap-1 mt-0.5`,children:i?i.connected>0?(0,A.jsxs)(`span`,{className:`flex items-center gap-1 text-meta text-accent-green`,children:[(0,A.jsx)(a,{className:`w-3 h-3`}),i.connected===i.count?s(`channels.status.connected`):s(`channels.sidebar.partialConnected`,{connected:i.connected,count:i.count})]}):(0,A.jsxs)(`span`,{className:`flex items-center gap-1 text-meta text-dark-muted`,children:[(0,A.jsx)(f,{className:`w-3 h-3`}),s(`channels.status.disconnected`)]}):(0,A.jsx)(`span`,{className:`text-meta text-dark-muted`,children:s(`channels.sidebar.unconfigured`)})})]})]})}function P({result:e}){let{t}=g(),[n,r]=(0,k.useState)(!1),i=e.logs?.length?e.logs:[...e.message?[e.message]:[],...typeof e.probed==`boolean`?[`probed=${e.probed}`]:[],`connected=${e.connected}`,...typeof e.latencyMs==`number`?[`latencyMs=${e.latencyMs}`]:[]];return i.length===0?null:(0,A.jsxs)(`details`,{open:!e.ok,className:`mt-1`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer select-none text-meta text-dark-muted hover:text-dark-text`,children:[t(`channels.actions.debugLogs`),` · `,i.length]}),(0,A.jsxs)(`div`,{className:`mt-1 rounded-md border border-dark-border bg-dark-bg`,children:[(0,A.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap break-all p-2 font-mono text-meta leading-relaxed text-dark-muted`,children:i.join(`
2
2
  `)}),(0,A.jsx)(`div`,{className:`flex justify-end border-t border-dark-border px-2 py-1`,children:(0,A.jsx)(`button`,{onClick:async()=>{try{await navigator.clipboard.writeText(i.join(`
3
3
  `)),r(!0),window.setTimeout(()=>r(!1),1500)}catch{}},className:`text-meta text-accent-blue hover:underline`,children:t(n?`channels.actions.copied`:`channels.actions.copyLog`)})})]})]})}var F={IMPLEMENTED:`IMPLEMENTED(收发双向)`,OUTBOUND_ONLY:`OUTBOUND_ONLY(只能发出,收不到入站消息)`,TEMPLATE:`TEMPLATE(骨架实现,功能未完成)`},I=60;function L({channel:e,result:t,pluginMissing:n,typeLabel:r}){let i=r?`${e.type}(${r})`:e.type,a=t.detail||t.message||`(服务端没有给出错误信息)`,o=[`频道测试连接失败了,帮我定位并修好。`,``,`- 频道:${e.name}`,`- 类型:${i}`,`- AppID:${e.appId||`(没配)`}`,`- 启用:${e.enabled?`是`:`否`}`];return e.implementationStatus&&o.push(`- 能力档位:${F[e.implementationStatus]??e.implementationStatus}`),n&&o.push(`- 插件:该类型的适配器**没有注册**(插件未安装或未激活)`),o.push(``),o.push(`【测试结论】`),o.push(`- ok=${t.ok},connected=${t.connected}`),o.push(t.probed?`- probed=true:服务端真的拿凭据敲了平台,上面的结论可信`:`- probed=false:适配器没有 probe 实现,服务端只看了本地状态,**没有真的验证凭据**`),typeof t.latencyMs==`number`&&o.push(`- 耗时:${t.latencyMs}ms`),o.push(`- 错误:${a}`),o.push(``),t.logs&&t.logs.length>0&&o.push(`【最近 ${Math.min(t.logs.length,I)} 行诊断日志】`,O(t.logs),``),o.push(`请先判断属于哪一类:凭据不匹配(AppID / AppSecret / token / EncodingAESKey 填错或过期) / 适配器没有 probe 实现(probed=false,结论不可信) / 频道插件未安装或未激活 / 适配器没启动、入站回调地址没配置 / 平台侧权限或 IP 白名单 / 网络不通。`,`然后给出最小修复动作:能改配置的,说清改哪一项、去哪里改;要改代码的,指出文件与函数。`,`最后说明改完之后该怎么重测。`,``,`需要读代码时:判定逻辑在 packages/server/src/channelTestDiagnostics.ts,适配器实现在 packages/plugins/channels/${e.type}/。`),o.join(`
4
4
  `)}var R={slack:{entry:`https://api.slack.com/apps(打开后停住等我在浏览器里登录,然后进应用 → OAuth & Permissions)`,credentials:[`token:Bot User OAuth Token(xoxb- 开头,OAuth & Permissions 页;收发消息都靠它)`,`extra.app_token:App-Level Token(xapp- 开头,收消息才需要;Basic settings → App-Level Tokens)`]},telegram:{entry:`Telegram 的凭据不走浏览器:找 @BotFather 发 /mybots → API Token 获取(你把话术准备好,我复制 token 给你)`,credentials:[`token:bot token(形如 123456789:AAEx…)`]},discord:{entry:`https://discord.com/developers/applications(停在登录页等我登录)`,credentials:[`token:Developer Portal → 应用 → Bot → Reset Token(只在生成时显示一次,当场复制)`]},line:{entry:`https://developers.line.biz/console/(停在登录页等我登录)`,credentials:[`token:Messaging API 频道 → Messaging API 设定 → Channel access token 点 Issue`]},whatsapp:{entry:`https://developers.facebook.com/(停在登录页等我登录)`,credentials:[`token:应用 → WhatsApp → API Setup 页的 access_token(临时 token 24h 过期)`,`extra.phone_number_id:同页的 Phone number ID`]},dingtalk:{entry:`https://open-dev.dingtalk.com/(停在登录页等我登录)`,credentials:[`appId:AppKey`,`appSecret:AppSecret(应用详情 → 凭据与基础信息)`]},feishu:{entry:`https://open.feishu.cn/app(停在登录页等我登录)`,credentials:[`appId / appSecret:开发者后台 → 应用 → 凭据与基础信息`]},mattermost:{entry:`用频道配置里 extra.server 的站点地址登录(停在登录页等我输入)`,credentials:[`token:个人访问令牌(账户设置 → 安全 → 个人访问令牌)`]},msteams:{entry:`Teams 网页版/客户端里操作:频道名 → ⋯ → 连接 → Incoming Webhook → 创建`,credentials:[`extra.webhook_url:创建后生成的完整地址`]},matrix:{entry:`用家服务器的 Web 客户端(如 Element)登录(停在登录页等我输入)`,credentials:[`token:access_token(Element → 所有设置 → 帮助与关于 → 高级)`,`extra.homeserver:家服务器地址`,`extra.user_id:完整用户 ID(@user:server)`]},qqbot:{entry:`https://q.qq.com/(停在登录页等我登录)`,credentials:[`appId / token / appSecret:机器人管理台 → 开发设置`]},wechat:{entry:`微信不需要浏览器:走本应用频道面板上的「扫码绑定」入口`,credentials:[`无固定凭据:扫码即完成绑定`]}};function z(e,t){let n=t?`${e.type}(${t})`:e.type,r=R[e.type]??{entry:`(该平台没有固定的后台入口,按平台文档定位凭据页面)`,credentials:[`按平台文档确认需要哪些凭据`]},i=[`- appId:${e.appId?`已填`:`未填`}`,`- appSecret:${e.appSecret?`已填`:`未填`}`,`- token:${e.token?`已填`:`未填`}`],a=Object.keys(e.extra??{});i.push(`- extra:${a.length?a.join(`、`):`空`}`);let o=[`帮我自动配置频道「${e.name}」(${n})。用「人机接力」的方式:`,`你负责打开页面、导航、定位和填表;**账号密码和验证码由我在浏览器里亲手输入**——`,`你不要读取、记录或代填任何密码;登录页出现时停下来等我。`,``,`【流程】`,`1. 打开平台后台:${r.entry}`,`2. 我登录完成后,你定位并复制下面的凭据。`,`3. 把凭据写回本应用:频道配置存在本机 channels.json(凭据是 enc: 密文落盘的),`,` **不要直接改文件**——调本地 server 的 HTTP 接口 PUT /api/channels/:id,`,` body 传明文,服务端会自己加密;本仓库就是 server 源码,server 在本机运行。`,` ⚠️ 拿到的 token 不要在回复里明文回显,写进配置即可。`,`4. 保存后适配器会自动重启。然后 POST /api/channels/:id/test 跑一次测试连接,`,` 把 ok / probed / detail / 诊断日志原样带回来给我。`,`5. 测试失败就按 packages/server/src/channelTestDiagnostics.ts 的分类定位,`,` 先区分「凭据没配置」和「凭据无效」,别一上来就让我换 token。`,``,`【该平台需要哪些凭据、去哪拿】`,...r.credentials.map(e=>`- ${e}`),``,`【已知现场(只报有无,不含值)】`,`- 频道:${e.name}`,`- 类型:${n}`,`- 启用:${e.enabled?`是`:`否`}`,...i];return e.implementationStatus&&o.push(`- 能力档位:${F[e.implementationStatus]??e.implementationStatus}`),o.join(`
5
- `)}var B={name:``,type:`wechat`,appId:``,appSecret:``,token:``,encodingAESKey:``,enabled:!0};function V(){let{t:e}=g(),[t,n]=S(),{channels:r,selectedType:a,availableTypes:l,create:u,update:d,remove:p,toggle:m,error:h,clearError:_,openQr:y,load:b,test:x,testResult:E,testing:O}=D(),j=(0,k.useMemo)(()=>l.length>0&&!!a&&!l.includes(a),[l,a]),M=(0,k.useMemo)(()=>a?r.filter(e=>e.type===a):[],[r,a]),[N,P]=(0,k.useState)(``),[F,I]=(0,k.useState)(B),[L,R]=(0,k.useState)(!1),z=N===`__new__`,V=(0,k.useMemo)(()=>z?null:M.find(e=>e.id===N)??null,[M,N,z]);(0,k.useEffect)(()=>{P(``),I(B),R(!1),_()},[a]),(0,k.useEffect)(()=>{a===`wechat`&&M.length===0&&!j&&y(null)},[a,M.length,j,y]),(0,k.useEffect)(()=>{V?I({name:V.name,type:V.type,appId:V.appId||``,appSecret:``,token:``,encodingAESKey:V.encodingAESKey||``,enabled:V.enabled}):z&&I(e=>({...e,type:a}))},[N]);let H=(e,t)=>{_(),I(n=>({...n,[e]:t}))},U=e=>{P(e),_()},W=()=>{P(`__new__`),I({...B,type:a}),_()},G=()=>{P(``),I(B),_()},K=async()=>{if(!F.name.trim())return;R(!0);let e=V?await d(V.id,F):await u(F);R(!1),e&&(P(``),I(B))},q=async t=>{await n({message:e(`channels.actions.deleteConfirmShort`),variant:`danger`})&&await p(t)&&N===t&&(P(``),I(B))},J=(e,t)=>{m(e,t)};return a?(0,A.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-hidden`,children:[t,(0,A.jsx)(`div`,{className:`shrink-0 px-6 py-4 border-b border-dark-border`,children:(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`text-2xl`,children:T(a)}),(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h2`,{className:`font-semibold text-base text-dark-text`,children:C(a)}),w(a)&&(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-badge text-accent-yellow bg-accent-yellow/15 px-1.5 py-0.5 rounded`,title:e(`channels.experimentalTip`),children:[(0,A.jsx)(i,{className:`w-3 h-3`}),` `,e(`channels.experimentalLabel`)]})]}),(0,A.jsx)(`p`,{className:`text-xs text-dark-muted mt-0.5`,children:M.length>0?e(`channels.instancesCount`,{n:M.length}):e(`channels.notConfiguredYet`)}),w(a)&&(0,A.jsx)(`p`,{className:`text-badge text-accent-yellow mt-1`,children:e(`channels.experimentalDesc`)})]})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`button`,{onClick:()=>b(),className:`text-xs px-3 py-1.5 rounded-lg border border-dark-border text-dark-muted hover:text-dark-text hover:bg-dark-hover transition-colors`,children:e(`channels.actions.refresh`)}),(0,A.jsx)(v,{size:`sm`,variant:`accent`,onClick:W,leftIcon:(0,A.jsx)(o,{className:`w-3.5 h-3.5`}),children:e(`channels.createInstance`)})]})]})}),h&&(0,A.jsxs)(`div`,{className:`shrink-0 mx-6 mt-3 bg-accent-red/15 border border-accent-red text-accent-red px-3 py-2 rounded-lg text-sm flex justify-between items-center`,children:[(0,A.jsx)(`span`,{children:h}),(0,A.jsx)(`button`,{onClick:_,className:`text-accent-red hover:text-accent-red`,children:(0,A.jsx)(`span`,{className:`w-4 h-4 inline-flex items-center justify-center`,children:`×`})})]}),j&&(0,A.jsxs)(`div`,{className:`shrink-0 mx-6 mt-3 flex items-start gap-2 bg-accent-yellow/15 border border-accent-yellow text-accent-yellow px-3 py-2 rounded-lg text-xs`,children:[(0,A.jsx)(c,{className:`w-3.5 h-3.5 mt-0.5 shrink-0`}),(0,A.jsx)(`span`,{children:e(`channels.pluginMissingWarning`,{name:a===`wechat`?` WeChat Channel`:` ${C(a)}`})})]}),(0,A.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar p-6`,children:[M.length>1&&!z&&(0,A.jsxs)(`div`,{className:`mb-4`,children:[(0,A.jsx)(`label`,{className:`block text-xs text-dark-muted mb-1.5`,children:e(`channels.selectInstance`)}),(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[M.map(e=>(0,A.jsxs)(`button`,{onClick:()=>U(e.id),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs border transition-colors ${N===e.id?`bg-accent-blue/10 border-accent-blue/40 text-accent-blue`:`border-dark-border text-dark-muted hover:text-dark-text hover:bg-dark-hover`}`,children:[(0,A.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${e.connected?`bg-accent-green`:`bg-dark-muted`}`}),e.name]},e.id)),(0,A.jsxs)(`button`,{onClick:W,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs border border-dashed border-dark-border text-dark-muted hover:text-dark-text hover:bg-dark-hover transition-colors`,children:[(0,A.jsx)(o,{className:`w-3 h-3`}),` `,e(`channels.createShort`)]})]})]}),M.length===0&&N===``&&(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-center`,children:[(0,A.jsx)(`div`,{className:`text-4xl mb-3`,children:T(a)}),(0,A.jsx)(`p`,{className:`text-dark-text font-medium`,children:e(`channels.emptyWithType`,{type:C(a)})}),(0,A.jsx)(`p`,{className:`text-sm text-dark-muted mt-1 mb-4`,children:e(a===`wechat`?`channels.wechatBindHint`:`channels.startWithCreate`)}),a===`wechat`&&(0,A.jsxs)(`button`,{onClick:()=>y(null),className:`flex items-center gap-1.5 text-sm px-4 py-2 rounded-lg bg-accent-green/15 hover:bg-accent-green/15 text-accent-green border border-accent-green transition-colors mb-3`,children:[(0,A.jsx)(f,{className:`w-4 h-4`}),` `,e(`channels.scanToBind`)]}),(0,A.jsx)(v,{variant:`accent`,onClick:W,leftIcon:(0,A.jsx)(o,{className:`w-4 h-4`}),children:e(`channels.createInstance`)})]}),M.length===1&&N===``&&M[0]&&(0,A.jsx)(ee,{channel:M[0],onEdit:()=>U(M[0].id),onDelete:()=>q(M[0].id),onToggle:e=>J(M[0].id,e),onQr:()=>y(M[0]),onTest:()=>x(M[0].id),testResult:E[M[0].id],testing:O===M[0].id,pluginMissing:j}),M.length>1&&N===``&&(0,A.jsx)(`div`,{className:`space-y-3`,children:M.map(e=>(0,A.jsx)(ee,{channel:e,onEdit:()=>U(e.id),onDelete:()=>q(e.id),onToggle:t=>J(e.id,t),onQr:()=>y(e),onTest:()=>x(e.id),testResult:E[e.id],testing:O===e.id,pluginMissing:j},e.id))}),N!==``&&(z||V)&&(0,A.jsx)(te,{form:F,upd:H,saving:L,editing:!!V,channel:V??void 0,onSave:K,onCancel:G,onDelete:V?()=>q(V.id):void 0,onQr:V?()=>y(V):void 0})]})]}):(0,A.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,A.jsxs)(`div`,{className:`text-center`,children:[(0,A.jsx)(s,{className:`w-12 h-12 mx-auto mb-3 text-dark-muted/40`}),(0,A.jsx)(`p`,{className:`text-dark-muted text-sm`,children:e(`channels.selectTypeHint`)})]})})}function ee({channel:e,onEdit:t,onDelete:n,onToggle:i,onQr:o,onTest:s,testResult:l,testing:u,pluginMissing:_}){let{t:v}=g();return(0,A.jsxs)(`div`,{className:`border border-dark-border rounded-lg bg-dark-surface overflow-hidden`,children:[(0,A.jsx)(`div`,{className:`p-5`,children:(0,A.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`font-medium text-dark-text`,children:e.name}),(0,A.jsxs)(`div`,{className:`flex items-center gap-3 mt-2`,children:[(0,A.jsx)(`span`,{className:`flex items-center gap-1 text-xs ${e.connected?`text-accent-green`:`text-dark-muted`}`,children:e.connected?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(a,{className:`w-3 h-3`}),` `,v(`channels.status.connected`)]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(d,{className:`w-3 h-3`}),` `,v(`channels.status.disconnected`)]})}),(0,A.jsxs)(`span`,{className:`text-xs text-dark-muted`,children:[`AppID: `,e.appId||`—`]}),e.implementationStatus===`OUTBOUND_ONLY`&&(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-badge text-accent-yellow bg-accent-yellow/15 px-1.5 py-0.5 rounded`,title:v(`channels.outboundOnlyTip`),children:[(0,A.jsx)(c,{className:`w-3 h-3`}),` `,v(`channels.outboundOnlyLabel`)]})]}),l&&(0,A.jsxs)(`div`,{className:`mt-1.5`,children:[(0,A.jsxs)(`p`,{className:`text-xs ${l.ok?`text-accent-green`:`text-accent-red`}`,children:[l.detail??(l.ok?v(`channels.actions.testPassed`):l.message??v(`channels.actions.testFailed`)),typeof l.latencyMs==`number`&&l.ok?` · ${l.latencyMs}ms`:``]}),(0,A.jsx)(P,{result:l}),!l.ok&&(0,A.jsxs)(`button`,{type:`button`,"data-testid":`channel-ask-ai`,onClick:()=>E(L({channel:e,result:l,pluginMissing:_,typeLabel:C(e.type)})),className:`mt-1 inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-accent-blue/40 bg-accent-blue/10 text-meta text-accent-blue hover:bg-accent-blue/20 transition-colors`,children:[(0,A.jsx)(r,{className:`w-3 h-3`}),` `,v(`channels.actions.askAiFix`)]})]})]}),(0,A.jsx)(`button`,{onClick:()=>i(!e.enabled),className:`w-9 h-5 rounded-full relative transition-colors shrink-0 ${e.enabled?`bg-accent-green`:`bg-dark-muted`}`,children:(0,A.jsx)(`span`,{className:`absolute top-0.5 w-4 h-4 bg-white rounded-full transition-all ${e.enabled?`start-[18px]`:`start-0.5`}`})})]})}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1 px-5 py-2.5 bg-dark-bg/50 border-t border-dark-border`,children:[e.type===`wechat`&&(0,A.jsxs)(`button`,{onClick:o,className:`flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-accent-green hover:bg-accent-green/15 transition-colors`,children:[(0,A.jsx)(f,{className:`w-3.5 h-3.5`}),` `,v(`channels.actions.qrLogin`)]}),(0,A.jsxs)(`button`,{onClick:t,className:`flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-accent-blue hover:bg-accent-blue/10 transition-colors`,children:[(0,A.jsx)(`span`,{className:`w-3.5 h-3.5 inline-flex items-center justify-center`,children:`✎`}),` `,v(`channels.actions.edit`)]}),e.enabled&&s&&(0,A.jsxs)(`button`,{onClick:s,disabled:u,className:`flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-accent-blue hover:bg-accent-blue/10 transition-colors disabled:opacity-50`,children:[(0,A.jsx)(p,{className:`w-3.5 h-3.5`}),` `,v(`channels.actions.test`)]}),(0,A.jsxs)(`button`,{type:`button`,"data-testid":`channel-ask-ai-setup`,onClick:()=>E(z(e,C(e.type))),className:`flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-accent-blue hover:bg-accent-blue/10 transition-colors`,children:[(0,A.jsx)(h,{className:`w-3.5 h-3.5`}),` `,v(`channels.actions.askAiSetup`)]}),(0,A.jsxs)(`button`,{onClick:n,className:`flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-accent-red hover:bg-accent-red/15 transition-colors ms-auto`,children:[(0,A.jsx)(m,{className:`w-3.5 h-3.5`}),` `,v(`channels.actions.delete`)]})]})]})}function te({form:e,upd:t,saving:r,editing:i,channel:a,onSave:o,onCancel:s,onDelete:c,onQr:l}){let{t:u}=g(),d=e.type===`slack`,p=d?`xapp-… · ${u(`channels.form.optionalShort`)}`:u(i?`channels.form.leaveBlankUnchanged`:`channels.form.appSecretValue`),h=d?i?`xoxb-… · ${u(`channels.form.leaveBlankUnchanged`)}`:`xoxb-…`:u(i?`channels.form.leaveBlankUnchanged`:`channels.form.tokenCallback`);return(0,A.jsxs)(`div`,{className:`border border-dark-border rounded-lg bg-dark-surface overflow-hidden`,children:[(0,A.jsx)(`div`,{className:`px-5 py-4 border-b border-dark-border`,children:(0,A.jsx)(`h3`,{className:`font-medium text-dark-text`,children:u(i?`channels.editConfig`:`channels.createConfig`)})}),(0,A.jsxs)(`div`,{className:`p-5 space-y-4`,children:[(0,A.jsx)(H,{label:u(`channels.form.name`),required:!0,children:(0,A.jsx)(`input`,{value:e.name,onChange:e=>t(`name`,e.target.value),placeholder:u(`channels.form.namePlaceholderDev`),className:U})}),(0,A.jsxs)(H,{label:u(`channels.form.credentials`),children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-badge text-dark-muted mb-1`,children:u(`channels.form.appId`)}),(0,A.jsx)(`input`,{value:e.appId,onChange:e=>t(`appId`,e.target.value),placeholder:`AppID`,className:U})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-badge text-dark-muted mb-1`,children:`AppSecret`}),(0,A.jsx)(`input`,{type:`password`,value:e.appSecret,onChange:e=>t(`appSecret`,e.target.value),placeholder:p,className:U})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-badge text-dark-muted mb-1`,children:`Token`}),(0,A.jsx)(`input`,{value:e.token,onChange:e=>t(`token`,e.target.value),placeholder:h,className:U})]}),e.type===`wechat`&&(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-badge text-dark-muted mb-1`,children:`EncodingAESKey`}),(0,A.jsx)(`input`,{value:e.encodingAESKey,onChange:e=>t(`encodingAESKey`,e.target.value),placeholder:u(`channels.form.optionalShort`),className:U})]})]}),e.type===`wechat`&&(0,A.jsx)(`p`,{className:`text-xs text-dark-muted mt-2`,children:u(`channels.form.wechatIlinkHint`)})]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-dark-border px-3 py-2.5`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`text-sm text-dark-text`,children:u(`channels.form.enabled`)}),(0,A.jsx)(`p`,{className:`text-xs text-dark-muted`,children:u(`channels.form.enabledOffHint`)})]}),(0,A.jsx)(`button`,{onClick:()=>t(`enabled`,!e.enabled),className:`w-9 h-5 rounded-full relative transition-colors shrink-0 ${e.enabled?`bg-accent-green`:`bg-dark-muted`}`,children:(0,A.jsx)(`span`,{className:`absolute top-0.5 w-4 h-4 bg-white rounded-full transition-all ${e.enabled?`start-[18px]`:`start-0.5`}`})})]}),i&&a?.type===`wechat`&&l&&(0,A.jsxs)(`button`,{onClick:l,className:`w-full flex items-center justify-center gap-2 text-sm bg-accent-green/15 hover:bg-accent-green/15 text-accent-green border border-accent-green px-3 py-2.5 rounded-lg transition-colors`,children:[(0,A.jsx)(f,{className:`w-4 h-4`}),` `,u(`channels.qrLoginReauth`)]})]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 bg-dark-bg/50 border-t border-dark-border`,children:[(0,A.jsx)(`div`,{children:i&&c&&(0,A.jsxs)(`button`,{onClick:c,className:`flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-accent-red hover:bg-accent-red/15 transition-colors`,children:[(0,A.jsx)(m,{className:`w-3.5 h-3.5`}),` `,u(`channels.actions.delete`)]})}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`button`,{onClick:s,className:`px-4 py-2 text-sm text-dark-muted hover:text-dark-text transition-colors`,children:u(`channels.actions.cancel`)}),(0,A.jsx)(v,{variant:`accent`,onClick:o,loading:r,disabled:!e.name.trim(),leftIcon:(0,A.jsx)(n,{className:`w-3.5 h-3.5`}),children:u(`channels.save`)})]})]})]})}function H({label:e,required:t,children:n}){return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`label`,{className:`block text-xs text-dark-muted mb-1.5`,children:[e,t&&(0,A.jsx)(`span`,{className:`text-accent-red ms-0.5`,children:`*`})]}),n]})}var U=`w-full bg-dark-bg border border-dark-border rounded-lg px-3 py-2 text-sm text-dark-text placeholder-dark-muted/60 focus:outline-none focus:border-accent-blue transition-colors`,W=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),G=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),K=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),q=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),J=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),ne=t((e=>{var t=G().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),re=t((e=>{var t=G().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),ie=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),Y=t((e=>{var t=K(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),ae=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),oe=t((e=>{var t=ae();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),se=t(((e,t)=>{var n=oe();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),X=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),Z=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
5
+ `)}var B={name:``,type:`wechat`,appId:``,appSecret:``,token:``,encodingAESKey:``,enabled:!0};function V(){let{t:e}=g(),[t,n]=S(),{channels:r,selectedType:i,availableTypes:a,create:l,update:u,remove:f,toggle:p,error:h,clearError:_,openQr:y,load:b,test:x,testResult:D,testing:O}=E(),j=(0,k.useMemo)(()=>a.length>0&&!!i&&!a.includes(i),[a,i]),M=(0,k.useMemo)(()=>i?r.filter(e=>e.type===i):[],[r,i]),[N,P]=(0,k.useState)(``),[F,I]=(0,k.useState)(B),[L,R]=(0,k.useState)(!1),z=N===`__new__`,V=(0,k.useMemo)(()=>z?null:M.find(e=>e.id===N)??null,[M,N,z]);(0,k.useEffect)(()=>{P(``),I(B),R(!1),_()},[i]),(0,k.useEffect)(()=>{i===`wechat`&&M.length===0&&!j&&y(null)},[i,M.length,j,y]),(0,k.useEffect)(()=>{V?I({name:V.name,type:V.type,appId:V.appId||``,appSecret:``,token:``,encodingAESKey:V.encodingAESKey||``,enabled:V.enabled}):z&&I(e=>({...e,type:i}))},[N]);let H=(e,t)=>{_(),I(n=>({...n,[e]:t}))},U=e=>{P(e),_()},W=()=>{P(`__new__`),I({...B,type:i}),_()},G=()=>{P(``),I(B),_()},K=async()=>{if(!F.name.trim())return;R(!0);let e=V?await u(V.id,F):await l(F);R(!1),e&&(P(``),I(B))},q=async t=>{await n({message:e(`channels.actions.deleteConfirmShort`),variant:`danger`})&&await f(t)&&N===t&&(P(``),I(B))},J=(e,t)=>{p(e,t)};return i?(0,A.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-hidden`,children:[t,(0,A.jsx)(`div`,{className:`shrink-0 px-6 py-4 border-b border-dark-border`,children:(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`text-2xl`,children:T(i)}),(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h2`,{className:`font-semibold text-base text-dark-text`,children:C(i)}),w(i)&&(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-badge text-accent-yellow bg-accent-yellow/15 px-1.5 py-0.5 rounded`,title:e(`channels.experimentalTip`),children:[(0,A.jsx)(d,{className:`w-3 h-3`}),` `,e(`channels.experimentalLabel`)]})]}),(0,A.jsx)(`p`,{className:`text-xs text-dark-muted mt-0.5`,children:M.length>0?e(`channels.instancesCount`,{n:M.length}):e(`channels.notConfiguredYet`)}),w(i)&&(0,A.jsx)(`p`,{className:`text-badge text-accent-yellow mt-1`,children:e(`channels.experimentalDesc`)})]})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`button`,{onClick:()=>b(),className:`text-xs px-3 py-1.5 rounded-lg border border-dark-border text-dark-muted hover:text-dark-text hover:bg-dark-hover transition-colors`,children:e(`channels.actions.refresh`)}),(0,A.jsx)(v,{size:`sm`,variant:`accent`,onClick:W,leftIcon:(0,A.jsx)(o,{className:`w-3.5 h-3.5`}),children:e(`channels.createInstance`)})]})]})}),h&&(0,A.jsxs)(`div`,{className:`shrink-0 mx-6 mt-3 bg-accent-red/15 border border-accent-red text-accent-red px-3 py-2 rounded-lg text-sm flex justify-between items-center`,children:[(0,A.jsx)(`span`,{children:h}),(0,A.jsx)(`button`,{onClick:_,className:`text-accent-red hover:text-accent-red`,children:(0,A.jsx)(`span`,{className:`w-4 h-4 inline-flex items-center justify-center`,children:`×`})})]}),j&&(0,A.jsxs)(`div`,{className:`shrink-0 mx-6 mt-3 flex items-start gap-2 bg-accent-yellow/15 border border-accent-yellow text-accent-yellow px-3 py-2 rounded-lg text-xs`,children:[(0,A.jsx)(c,{className:`w-3.5 h-3.5 mt-0.5 shrink-0`}),(0,A.jsx)(`span`,{children:e(`channels.pluginMissingWarning`,{name:i===`wechat`?` WeChat Channel`:` ${C(i)}`})})]}),(0,A.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar p-6`,children:[M.length>1&&!z&&(0,A.jsxs)(`div`,{className:`mb-4`,children:[(0,A.jsx)(`label`,{className:`block text-xs text-dark-muted mb-1.5`,children:e(`channels.selectInstance`)}),(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[M.map(e=>(0,A.jsxs)(`button`,{onClick:()=>U(e.id),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs border transition-colors ${N===e.id?`bg-accent-blue/10 border-accent-blue/40 text-accent-blue`:`border-dark-border text-dark-muted hover:text-dark-text hover:bg-dark-hover`}`,children:[(0,A.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${e.connected?`bg-accent-green`:`bg-dark-muted`}`}),e.name]},e.id)),(0,A.jsxs)(`button`,{onClick:W,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs border border-dashed border-dark-border text-dark-muted hover:text-dark-text hover:bg-dark-hover transition-colors`,children:[(0,A.jsx)(o,{className:`w-3 h-3`}),` `,e(`channels.createShort`)]})]})]}),M.length===0&&N===``&&(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-center`,children:[(0,A.jsx)(`div`,{className:`text-4xl mb-3`,children:T(i)}),(0,A.jsx)(`p`,{className:`text-dark-text font-medium`,children:e(`channels.emptyWithType`,{type:C(i)})}),(0,A.jsx)(`p`,{className:`text-sm text-dark-muted mt-1 mb-4`,children:e(i===`wechat`?`channels.wechatBindHint`:`channels.startWithCreate`)}),i===`wechat`&&(0,A.jsxs)(`button`,{onClick:()=>y(null),className:`flex items-center gap-1.5 text-sm px-4 py-2 rounded-lg bg-accent-green/15 hover:bg-accent-green/15 text-accent-green border border-accent-green transition-colors mb-3`,children:[(0,A.jsx)(m,{className:`w-4 h-4`}),` `,e(`channels.scanToBind`)]}),(0,A.jsx)(v,{variant:`accent`,onClick:W,leftIcon:(0,A.jsx)(o,{className:`w-4 h-4`}),children:e(`channels.createInstance`)})]}),M.length===1&&N===``&&M[0]&&(0,A.jsx)(ee,{channel:M[0],onEdit:()=>U(M[0].id),onDelete:()=>q(M[0].id),onToggle:e=>J(M[0].id,e),onQr:()=>y(M[0]),onTest:()=>x(M[0].id),testResult:D[M[0].id],testing:O===M[0].id,pluginMissing:j}),M.length>1&&N===``&&(0,A.jsx)(`div`,{className:`space-y-3`,children:M.map(e=>(0,A.jsx)(ee,{channel:e,onEdit:()=>U(e.id),onDelete:()=>q(e.id),onToggle:t=>J(e.id,t),onQr:()=>y(e),onTest:()=>x(e.id),testResult:D[e.id],testing:O===e.id,pluginMissing:j},e.id))}),N!==``&&(z||V)&&(0,A.jsx)(te,{form:F,upd:H,saving:L,editing:!!V,channel:V??void 0,onSave:K,onCancel:G,onDelete:V?()=>q(V.id):void 0,onQr:V?()=>y(V):void 0})]})]}):(0,A.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,A.jsxs)(`div`,{className:`text-center`,children:[(0,A.jsx)(s,{className:`w-12 h-12 mx-auto mb-3 text-dark-muted/40`}),(0,A.jsx)(`p`,{className:`text-dark-muted text-sm`,children:e(`channels.selectTypeHint`)})]})})}function ee({channel:e,onEdit:t,onDelete:n,onToggle:o,onQr:s,onTest:l,testResult:u,testing:d,pluginMissing:_}){let{t:v}=g();return(0,A.jsxs)(`div`,{className:`border border-dark-border rounded-lg bg-dark-surface overflow-hidden`,children:[(0,A.jsx)(`div`,{className:`p-5`,children:(0,A.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`font-medium text-dark-text`,children:e.name}),(0,A.jsxs)(`div`,{className:`flex items-center gap-3 mt-2`,children:[(0,A.jsx)(`span`,{className:`flex items-center gap-1 text-xs ${e.connected?`text-accent-green`:`text-dark-muted`}`,children:e.connected?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(a,{className:`w-3 h-3`}),` `,v(`channels.status.connected`)]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(f,{className:`w-3 h-3`}),` `,v(`channels.status.disconnected`)]})}),(0,A.jsxs)(`span`,{className:`text-xs text-dark-muted`,children:[`AppID: `,e.appId||`—`]}),e.implementationStatus===`OUTBOUND_ONLY`&&(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-badge text-accent-yellow bg-accent-yellow/15 px-1.5 py-0.5 rounded`,title:v(`channels.outboundOnlyTip`),children:[(0,A.jsx)(c,{className:`w-3 h-3`}),` `,v(`channels.outboundOnlyLabel`)]})]}),u&&(0,A.jsxs)(`div`,{className:`mt-1.5`,children:[(0,A.jsxs)(`p`,{className:`text-xs ${u.ok?`text-accent-green`:`text-accent-red`}`,children:[u.detail??(u.ok?v(`channels.actions.testPassed`):u.message??v(`channels.actions.testFailed`)),typeof u.latencyMs==`number`&&u.ok?` · ${u.latencyMs}ms`:``]}),(0,A.jsx)(P,{result:u}),!u.ok&&(0,A.jsxs)(`button`,{type:`button`,"data-testid":`channel-ask-ai`,onClick:()=>D(L({channel:e,result:u,pluginMissing:_,typeLabel:C(e.type)})),className:`mt-1 inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-accent-blue/40 bg-accent-blue/10 text-meta text-accent-blue hover:bg-accent-blue/20 transition-colors`,children:[(0,A.jsx)(r,{className:`w-3 h-3`}),` `,v(`channels.actions.askAiFix`)]})]})]}),(0,A.jsx)(`button`,{onClick:()=>o(!e.enabled),className:`w-9 h-5 rounded-full relative transition-colors shrink-0 ${e.enabled?`bg-accent-green`:`bg-dark-muted`}`,children:(0,A.jsx)(`span`,{className:`absolute top-0.5 w-4 h-4 bg-white rounded-full transition-all ${e.enabled?`start-[18px]`:`start-0.5`}`})})]})}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1 px-5 py-2.5 bg-dark-bg/50 border-t border-dark-border`,children:[e.type===`wechat`&&(0,A.jsxs)(`button`,{onClick:s,className:`flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-accent-green hover:bg-accent-green/15 transition-colors`,children:[(0,A.jsx)(m,{className:`w-3.5 h-3.5`}),` `,v(`channels.actions.qrLogin`)]}),(0,A.jsxs)(`button`,{onClick:t,className:`flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-accent-blue hover:bg-accent-blue/10 transition-colors`,children:[(0,A.jsx)(`span`,{className:`w-3.5 h-3.5 inline-flex items-center justify-center`,children:`✎`}),` `,v(`channels.actions.edit`)]}),e.enabled&&l&&(0,A.jsxs)(`button`,{onClick:l,disabled:d,className:`flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-accent-blue hover:bg-accent-blue/10 transition-colors disabled:opacity-50`,children:[(0,A.jsx)(p,{className:`w-3.5 h-3.5`}),` `,v(`channels.actions.test`)]}),(0,A.jsxs)(`button`,{type:`button`,"data-testid":`channel-ask-ai-setup`,onClick:()=>D(z(e,C(e.type))),className:`flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-accent-blue hover:bg-accent-blue/10 transition-colors`,children:[(0,A.jsx)(i,{className:`w-3.5 h-3.5`}),` `,v(`channels.actions.askAiSetup`)]}),(0,A.jsxs)(`button`,{onClick:n,className:`flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-accent-red hover:bg-accent-red/15 transition-colors ms-auto`,children:[(0,A.jsx)(h,{className:`w-3.5 h-3.5`}),` `,v(`channels.actions.delete`)]})]})]})}function te({form:e,upd:t,saving:r,editing:i,channel:a,onSave:o,onCancel:s,onDelete:c,onQr:l}){let{t:u}=g(),d=e.type===`slack`,f=d?`xapp-… · ${u(`channels.form.optionalShort`)}`:u(i?`channels.form.leaveBlankUnchanged`:`channels.form.appSecretValue`),p=d?i?`xoxb-… · ${u(`channels.form.leaveBlankUnchanged`)}`:`xoxb-…`:u(i?`channels.form.leaveBlankUnchanged`:`channels.form.tokenCallback`);return(0,A.jsxs)(`div`,{className:`border border-dark-border rounded-lg bg-dark-surface overflow-hidden`,children:[(0,A.jsx)(`div`,{className:`px-5 py-4 border-b border-dark-border`,children:(0,A.jsx)(`h3`,{className:`font-medium text-dark-text`,children:u(i?`channels.editConfig`:`channels.createConfig`)})}),(0,A.jsxs)(`div`,{className:`p-5 space-y-4`,children:[(0,A.jsx)(H,{label:u(`channels.form.name`),required:!0,children:(0,A.jsx)(`input`,{value:e.name,onChange:e=>t(`name`,e.target.value),placeholder:u(`channels.form.namePlaceholderDev`),className:U})}),(0,A.jsxs)(H,{label:u(`channels.form.credentials`),children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-badge text-dark-muted mb-1`,children:u(`channels.form.appId`)}),(0,A.jsx)(`input`,{value:e.appId,onChange:e=>t(`appId`,e.target.value),placeholder:`AppID`,className:U})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-badge text-dark-muted mb-1`,children:`AppSecret`}),(0,A.jsx)(`input`,{type:`password`,value:e.appSecret,onChange:e=>t(`appSecret`,e.target.value),placeholder:f,className:U})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-badge text-dark-muted mb-1`,children:`Token`}),(0,A.jsx)(`input`,{value:e.token,onChange:e=>t(`token`,e.target.value),placeholder:p,className:U})]}),e.type===`wechat`&&(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-badge text-dark-muted mb-1`,children:`EncodingAESKey`}),(0,A.jsx)(`input`,{value:e.encodingAESKey,onChange:e=>t(`encodingAESKey`,e.target.value),placeholder:u(`channels.form.optionalShort`),className:U})]})]}),e.type===`wechat`&&(0,A.jsx)(`p`,{className:`text-xs text-dark-muted mt-2`,children:u(`channels.form.wechatIlinkHint`)})]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-dark-border px-3 py-2.5`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`text-sm text-dark-text`,children:u(`channels.form.enabled`)}),(0,A.jsx)(`p`,{className:`text-xs text-dark-muted`,children:u(`channels.form.enabledOffHint`)})]}),(0,A.jsx)(`button`,{onClick:()=>t(`enabled`,!e.enabled),className:`w-9 h-5 rounded-full relative transition-colors shrink-0 ${e.enabled?`bg-accent-green`:`bg-dark-muted`}`,children:(0,A.jsx)(`span`,{className:`absolute top-0.5 w-4 h-4 bg-white rounded-full transition-all ${e.enabled?`start-[18px]`:`start-0.5`}`})})]}),i&&a?.type===`wechat`&&l&&(0,A.jsxs)(`button`,{onClick:l,className:`w-full flex items-center justify-center gap-2 text-sm bg-accent-green/15 hover:bg-accent-green/15 text-accent-green border border-accent-green px-3 py-2.5 rounded-lg transition-colors`,children:[(0,A.jsx)(m,{className:`w-4 h-4`}),` `,u(`channels.qrLoginReauth`)]})]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 bg-dark-bg/50 border-t border-dark-border`,children:[(0,A.jsx)(`div`,{children:i&&c&&(0,A.jsxs)(`button`,{onClick:c,className:`flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-accent-red hover:bg-accent-red/15 transition-colors`,children:[(0,A.jsx)(h,{className:`w-3.5 h-3.5`}),` `,u(`channels.actions.delete`)]})}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`button`,{onClick:s,className:`px-4 py-2 text-sm text-dark-muted hover:text-dark-text transition-colors`,children:u(`channels.actions.cancel`)}),(0,A.jsx)(v,{variant:`accent`,onClick:o,loading:r,disabled:!e.name.trim(),leftIcon:(0,A.jsx)(n,{className:`w-3.5 h-3.5`}),children:u(`channels.save`)})]})]})]})}function H({label:e,required:t,children:n}){return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`label`,{className:`block text-xs text-dark-muted mb-1.5`,children:[e,t&&(0,A.jsx)(`span`,{className:`text-accent-red ms-0.5`,children:`*`})]}),n]})}var U=`w-full bg-dark-bg border border-dark-border rounded-lg px-3 py-2 text-sm text-dark-text placeholder-dark-muted/60 focus:outline-none focus:border-accent-blue transition-colors`,W=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),G=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),K=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),q=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),J=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),ne=t((e=>{var t=G().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),re=t((e=>{var t=G().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),ie=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),Y=t((e=>{var t=K(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),ae=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),oe=t((e=>{var t=ae();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),se=t(((e,t)=>{var n=oe();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),X=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),Z=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
6
6
  ]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^[0-9]+$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),Q=t((e=>{var t=X(),n=Z();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),ce=t((e=>{var t=G(),n=Y(),r=K(),i=Q(),a=X(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),le=t((e=>{var t=G(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),ue=t(((e,t)=>{var n=Q();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),de=t(((e,t)=>{var n=Q(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t=0;for(;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),fe=t(((e,t)=>{var n=Q();function r(e){this.mode=n.BYTE,this.data=typeof e==`string`?new TextEncoder().encode(e):new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),pe=t(((e,t)=>{var n=Q(),r=G();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t=0;for(;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
7
7
  Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),me=t(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),he=t((e=>{var t=Q(),n=ue(),r=de(),i=fe(),a=pe(),o=Z(),s=G(),c=me();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
8
8
  Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),ge=t((e=>{var t=G(),n=K(),r=q(),i=J(),a=ne(),o=re(),s=ie(),c=Y(),l=se(),u=ce(),d=le(),f=Q(),p=he();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
9
9
  The chosen QR Code version cannot contain this amount of data.
10
10
  Minimum version required to store current data is: `+c+`.
11
11
  `);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),$=t((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||(e.color={});let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[+!!a[t*i+r]]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),_e=t((e=>{var t=$();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o!==void 0||i&&i.getContext||(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i!==void 0||n&&n.getContext||(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),ve=t((e=>{var t=$();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
12
- `;return typeof a==`function`&&a(null,p),p}})),ye=e(t((e=>{var t=W(),n=ge(),r=_e(),i=ve();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1),be=2e3,xe=5;function Se({channel:e,onClose:t}){let{t:n}=g(),[r,i]=(0,k.useState)(`loading`),[a,o]=(0,k.useState)(null),[s,c]=(0,k.useState)(null),[l,u]=(0,k.useState)(``),d=(0,k.useRef)(null),f=(0,k.useRef)(0),p=(0,k.useRef)(null),m=(0,k.useRef)(!1),h=()=>{p.current&&=(clearTimeout(p.current),null),m.current=!0},v=async e=>{if(d.current)try{await ye.toCanvas(d.current,e,{width:240,margin:2,color:{dark:`#000000ff`,light:`#ffffffff`}})}catch(e){console.warn(`[WechatQr] Canvas QR generation failed, falling back to URL:`,e)}},b=async()=>{if(!m.current&&s)try{let r=await y.channels.weixin.bindStatus(s),a=r?.data??r,o=a?.status??``;if(f.current=0,o===`confirmed`){if(!a?.channel_id){i(`error`),u(n(`channels.bindNoInstance`)),_.error(n(`channels.bindNoInstance`));return}i(`confirmed`),_.success(e?n(`channels.toastReauthSuccess`,{name:e.name}):n(`channels.toastBindSuccess`)),setTimeout(t,2400);return}if(o===`scaned`)i(`scanned`);else if(o===`expired`){i(`expired`);return}m.current||(p.current=setTimeout(b,be))}catch(e){if(f.current++,console.warn(`[WechatQr] poll error (`+f.current+`/5)`,e),f.current>=xe)i(`error`),u(n(`channels.pollFailedRefresh`)),_.error(n(`channels.pollFailedToast`));else if(!m.current){let e=Math.min(1e3*2**f.current,1e4);p.current=setTimeout(b,e)}}},S=()=>{h(),m.current=!1,f.current=0,p.current=setTimeout(b,1e3)},C=async()=>{i(`loading`),o(null),c(null),u(``),f.current=0;try{let e=await y.channels.weixin.bind(),t=e?.data??e,r=t?.qrcode_img_content??``,a=t?.qrcode??``;if(!r||!a){i(`error`),u(n(`channels.qrDataMissing`,{data:JSON.stringify(t)}));return}o(r),c(a),await v(r),i(`waiting`)}catch(e){i(`error`);let t=String(e?.message??e);u(t),_.error(n(`channels.fetchWechatQrFailed`,{error:t}))}},w=()=>{C()};return(0,k.useEffect)(()=>(C(),h),[]),(0,k.useEffect)(()=>(s&&S(),h),[s]),(0,A.jsx)(x,{isOpen:!0,onClose:t,title:n(`channels.bindTitle`,{name:e?.name??n(`channels.typeLabels.wechat`)}),size:`sm`,children:(0,A.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-2`,children:[(0,A.jsxs)(`div`,{className:`relative w-60 h-60 rounded-lg bg-white flex items-center justify-center overflow-hidden`,children:[r===`loading`&&(0,A.jsx)(`span`,{className:`text-dark-muted text-sm`,children:n(`channels.qr.generating`)}),r!==`error`&&r!==`expired`&&(0,A.jsx)(`canvas`,{ref:d,width:240,height:240,className:`w-full h-full object-contain ${r===`waiting`?``:`opacity-30`}`}),r===`scanned`&&(0,A.jsxs)(`div`,{className:`absolute inset-0 bg-black/70 flex flex-col items-center justify-center text-overlay-fg gap-1`,children:[(0,A.jsx)(`span`,{className:`text-2xl`,children:`✓`}),(0,A.jsx)(`span`,{className:`text-sm`,children:n(`channels.qr.scanned`)})]}),r===`confirmed`&&(0,A.jsxs)(`div`,{className:`absolute inset-0 bg-accent-green/15 flex flex-col items-center justify-center text-accent-fg gap-2 px-4 text-center`,children:[(0,A.jsx)(`span`,{className:`text-2xl`,children:`🎉`}),(0,A.jsx)(`span`,{className:`text-sm font-medium`,children:n(`channels.bindSuccess`)}),(0,A.jsx)(`span`,{className:`text-xs opacity-90`,children:e?n(`channels.connectedReady`,{name:e.name}):n(`channels.createdConnectedReady`)}),(0,A.jsx)(`button`,{onClick:t,className:`mt-1 text-xs bg-white/20 hover:bg-white/30 px-3 py-1.5 rounded-md transition-colors`,children:n(`channels.startUsing`)})]}),r===`expired`&&(0,A.jsxs)(`div`,{className:`absolute inset-0 bg-black/80 flex flex-col items-center justify-center text-overlay-fg gap-2`,children:[(0,A.jsx)(`span`,{className:`text-sm`,children:n(`channels.qr.expired`)}),(0,A.jsx)(`button`,{onClick:w,className:`text-xs bg-accent-green hover:bg-accent-green px-3 py-1 rounded`,children:n(`channels.clickToRefresh`)})]}),r===`error`&&(0,A.jsxs)(`div`,{className:`absolute inset-0 bg-black/80 flex flex-col items-center justify-center text-accent-red gap-2 px-4 text-center`,children:[(0,A.jsx)(`span`,{className:`text-xs`,children:l||n(`channels.unknownError`)}),(0,A.jsx)(`button`,{onClick:w,className:`text-xs bg-accent-blue hover:bg-accent-blue px-3 py-1 rounded text-accent-fg`,children:n(`channels.retry`)})]})]}),(0,A.jsxs)(`p`,{className:`text-sm text-dark-muted text-center`,children:[r===`waiting`&&n(`channels.waitingAuthorize`),r===`scanned`&&n(`channels.scannedConfirming`),r===`confirmed`&&n(`channels.confirmedClosing`),r===`loading`&&n(`channels.connectingIlink`),(r===`expired`||r===`error`)&&(r===`expired`?n(`channels.qr.expired`):``)]}),a&&r===`waiting`&&(0,A.jsxs)(`button`,{onClick:()=>window.open(a,`_blank`,`width=480,height=600,noopener`),className:`w-full flex items-center justify-center gap-2 text-sm bg-accent-green/15 hover:bg-accent-green/15 text-accent-green border border-accent-green px-3 py-2.5 rounded-lg transition-colors`,children:[(0,A.jsx)(`span`,{children:`🔔`}),` `,n(`channels.openInNewTabFallback`)]})]})})}function Ce(){let{t:e}=g(),{load:t,loading:n,qrOpen:r,qrChannel:i,closeQr:a}=D();return(0,k.useEffect)(()=>{t()},[]),(0,A.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-dark-bg text-dark-text`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-dark-border shrink-0`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{className:`font-semibold text-base`,children:e(`channels.title`)}),(0,A.jsx)(`p`,{className:`text-xs text-dark-muted mt-0.5`,children:e(`channels.viewSubtitle`)})]}),(0,A.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,A.jsx)(`button`,{onClick:()=>t(),title:e(`channels.actions.refresh`),className:`p-2 rounded-lg text-dark-muted hover:text-dark-text hover:bg-dark-hover transition-colors`,children:(0,A.jsx)(l,{className:`w-4 h-4 ${n?`animate-spin`:``}`})})})]}),(0,A.jsxs)(`div`,{className:`flex-1 flex min-h-0 overflow-hidden max-md:flex-col`,children:[(0,A.jsx)(`div`,{className:`w-[260px] shrink-0 max-md:w-full max-md:max-h-[30vh] max-md:overflow-y-auto custom-scrollbar`,children:(0,A.jsx)(M,{})}),(0,A.jsx)(`div`,{className:`flex-1 min-w-0 max-md:min-h-0`,children:(0,A.jsx)(V,{})})]}),r&&(0,A.jsx)(Se,{channel:i,onClose:a})]})}export{Ce as ChannelConfigView};
12
+ `;return typeof a==`function`&&a(null,p),p}})),ye=e(t((e=>{var t=W(),n=ge(),r=_e(),i=ve();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1),be=2e3,xe=5;function Se({channel:e,onClose:t}){let{t:n}=g(),[r,i]=(0,k.useState)(`loading`),[a,o]=(0,k.useState)(null),[s,c]=(0,k.useState)(null),[l,u]=(0,k.useState)(``),d=(0,k.useRef)(null),f=(0,k.useRef)(0),p=(0,k.useRef)(null),m=(0,k.useRef)(!1),h=()=>{p.current&&=(clearTimeout(p.current),null),m.current=!0},v=async e=>{if(d.current)try{await ye.toCanvas(d.current,e,{width:240,margin:2,color:{dark:`#000000ff`,light:`#ffffffff`}})}catch(e){console.warn(`[WechatQr] Canvas QR generation failed, falling back to URL:`,e)}},b=async()=>{if(!m.current&&s)try{let r=await y.channels.weixin.bindStatus(s),a=r?.data??r,o=a?.status??``;if(f.current=0,o===`confirmed`){if(!a?.channel_id){i(`error`),u(n(`channels.bindNoInstance`)),_.error(n(`channels.bindNoInstance`));return}i(`confirmed`),_.success(e?n(`channels.toastReauthSuccess`,{name:e.name}):n(`channels.toastBindSuccess`)),setTimeout(t,2400);return}if(o===`scaned`)i(`scanned`);else if(o===`expired`){i(`expired`);return}m.current||(p.current=setTimeout(b,be))}catch(e){if(f.current++,console.warn(`[WechatQr] poll error (`+f.current+`/5)`,e),f.current>=xe)i(`error`),u(n(`channels.pollFailedRefresh`)),_.error(n(`channels.pollFailedToast`));else if(!m.current){let e=Math.min(1e3*2**f.current,1e4);p.current=setTimeout(b,e)}}},S=()=>{h(),m.current=!1,f.current=0,p.current=setTimeout(b,1e3)},C=async()=>{i(`loading`),o(null),c(null),u(``),f.current=0;try{let e=await y.channels.weixin.bind(),t=e?.data??e,r=t?.qrcode_img_content??``,a=t?.qrcode??``;if(!r||!a){i(`error`),u(n(`channels.qrDataMissing`,{data:JSON.stringify(t)}));return}o(r),c(a),await v(r),i(`waiting`)}catch(e){i(`error`);let t=String(e?.message??e);u(t),_.error(n(`channels.fetchWechatQrFailed`,{error:t}))}},w=()=>{C()};return(0,k.useEffect)(()=>(C(),h),[]),(0,k.useEffect)(()=>(s&&S(),h),[s]),(0,A.jsx)(x,{isOpen:!0,onClose:t,title:n(`channels.bindTitle`,{name:e?.name??n(`channels.typeLabels.wechat`)}),size:`sm`,children:(0,A.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-2`,children:[(0,A.jsxs)(`div`,{className:`relative w-60 h-60 rounded-lg bg-white flex items-center justify-center overflow-hidden`,children:[r===`loading`&&(0,A.jsx)(`span`,{className:`text-dark-muted text-sm`,children:n(`channels.qr.generating`)}),r!==`error`&&r!==`expired`&&(0,A.jsx)(`canvas`,{ref:d,width:240,height:240,className:`w-full h-full object-contain ${r===`waiting`?``:`opacity-30`}`}),r===`scanned`&&(0,A.jsxs)(`div`,{className:`absolute inset-0 bg-black/70 flex flex-col items-center justify-center text-overlay-fg gap-1`,children:[(0,A.jsx)(`span`,{className:`text-2xl`,children:`✓`}),(0,A.jsx)(`span`,{className:`text-sm`,children:n(`channels.qr.scanned`)})]}),r===`confirmed`&&(0,A.jsxs)(`div`,{className:`absolute inset-0 bg-accent-green/15 flex flex-col items-center justify-center text-accent-fg gap-2 px-4 text-center`,children:[(0,A.jsx)(`span`,{className:`text-2xl`,children:`🎉`}),(0,A.jsx)(`span`,{className:`text-sm font-medium`,children:n(`channels.bindSuccess`)}),(0,A.jsx)(`span`,{className:`text-xs opacity-90`,children:e?n(`channels.connectedReady`,{name:e.name}):n(`channels.createdConnectedReady`)}),(0,A.jsx)(`button`,{onClick:t,className:`mt-1 text-xs bg-white/20 hover:bg-white/30 px-3 py-1.5 rounded-md transition-colors`,children:n(`channels.startUsing`)})]}),r===`expired`&&(0,A.jsxs)(`div`,{className:`absolute inset-0 bg-black/80 flex flex-col items-center justify-center text-overlay-fg gap-2`,children:[(0,A.jsx)(`span`,{className:`text-sm`,children:n(`channels.qr.expired`)}),(0,A.jsx)(`button`,{onClick:w,className:`text-xs bg-accent-green hover:bg-accent-green px-3 py-1 rounded`,children:n(`channels.clickToRefresh`)})]}),r===`error`&&(0,A.jsxs)(`div`,{className:`absolute inset-0 bg-black/80 flex flex-col items-center justify-center text-accent-red gap-2 px-4 text-center`,children:[(0,A.jsx)(`span`,{className:`text-xs`,children:l||n(`channels.unknownError`)}),(0,A.jsx)(`button`,{onClick:w,className:`text-xs bg-accent-blue hover:bg-accent-blue px-3 py-1 rounded text-accent-fg`,children:n(`channels.retry`)})]})]}),(0,A.jsxs)(`p`,{className:`text-sm text-dark-muted text-center`,children:[r===`waiting`&&n(`channels.waitingAuthorize`),r===`scanned`&&n(`channels.scannedConfirming`),r===`confirmed`&&n(`channels.confirmedClosing`),r===`loading`&&n(`channels.connectingIlink`),(r===`expired`||r===`error`)&&(r===`expired`?n(`channels.qr.expired`):``)]}),a&&r===`waiting`&&(0,A.jsxs)(`button`,{onClick:()=>window.open(a,`_blank`,`width=480,height=600,noopener`),className:`w-full flex items-center justify-center gap-2 text-sm bg-accent-green/15 hover:bg-accent-green/15 text-accent-green border border-accent-green px-3 py-2.5 rounded-lg transition-colors`,children:[(0,A.jsx)(`span`,{children:`🔔`}),` `,n(`channels.openInNewTabFallback`)]})]})})}function Ce(){let{t:e}=g(),{load:t,loading:n,qrOpen:r,qrChannel:i,closeQr:a}=E();return(0,k.useEffect)(()=>{t()},[]),(0,A.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-dark-bg text-dark-text`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-dark-border shrink-0`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{className:`font-semibold text-base`,children:e(`channels.title`)}),(0,A.jsx)(`p`,{className:`text-xs text-dark-muted mt-0.5`,children:e(`channels.viewSubtitle`)})]}),(0,A.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,A.jsx)(`button`,{onClick:()=>t(),title:e(`channels.actions.refresh`),className:`p-2 rounded-lg text-dark-muted hover:text-dark-text hover:bg-dark-hover transition-colors`,children:(0,A.jsx)(u,{className:`w-4 h-4 ${n?`animate-spin`:``}`})})})]}),(0,A.jsxs)(`div`,{className:`flex-1 flex min-h-0 overflow-hidden max-md:flex-col`,children:[(0,A.jsx)(`div`,{className:`w-[260px] shrink-0 max-md:w-full max-md:max-h-[30vh] max-md:overflow-y-auto custom-scrollbar`,children:(0,A.jsx)(M,{})}),(0,A.jsx)(`div`,{className:`flex-1 min-w-0 max-md:min-h-0`,children:(0,A.jsx)(V,{})})]}),r&&(0,A.jsx)(Se,{channel:i,onClose:a})]})}export{Ce as ChannelConfigView};