lantern-harness 0.1.11 → 0.1.13

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 (119) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/builtin/session/lh-nav-groups.mjs +55 -17
  3. package/cli/server.mjs +2 -0
  4. package/config/app.defaults.json +1 -0
  5. package/dist/500.html +52 -4
  6. package/dist/_astro/Base.UUIdmKid.css +1 -0
  7. package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.CvbRi7Tl.js → Base.astro_astro_type_script_index_0_lang.DSWudA4D.js} +1 -1
  8. package/dist/_astro/{CaseExecBoard.Dttqp0wg.js → CaseExecBoard.D8K4NzrB.js} +1 -1
  9. package/dist/_astro/CaseGenerateApp.bZ_K72NQ.js +9 -0
  10. package/dist/_astro/{CasesLibrary.8aMUUGp_.js → CasesLibrary.Dhg2pdwU.js} +1 -1
  11. package/dist/_astro/ChatApp.B6I3gGKI.js +221 -0
  12. package/dist/_astro/{ConfirmDialog.BZzZWDci.js → ConfirmDialog.CsMwWevK.js} +1 -1
  13. package/dist/_astro/{DashboardBoard.CkSbhEDI.js → DashboardBoard.uPjTYpJZ.js} +1 -1
  14. package/dist/_astro/{DocsFileBrowser.MKVCfZrE.js → DocsFileBrowser.DvBPLCEp.js} +1 -1
  15. package/dist/_astro/{DocsPager.DJY4foYL.js → DocsPager.EPT5-oEx.js} +1 -1
  16. package/dist/_astro/{DrawerField.CHRg77LG.js → DrawerField.DqvXFCFh.js} +1 -1
  17. package/dist/_astro/{ExcelFieldTags.DXMeaDa5.js → ExcelFieldTags.De-C3dqn.js} +1 -1
  18. package/dist/_astro/{KnowledgeLibrary.B-p1aoQN.js → KnowledgeLibrary.BzFTmNwA.js} +1 -1
  19. package/dist/_astro/{NamePromptDialog.Wa9O530a.js → NamePromptDialog.CS1pTTVl.js} +1 -1
  20. package/dist/_astro/{NavLibraries.C6LImMO_.js → NavLibraries.CVdolwYy.js} +1 -1
  21. package/dist/_astro/PluginsPage.B8U4uvD2.js +39 -0
  22. package/dist/_astro/{PluginsPage.DkmRPfbU.js → PluginsPage.v6afs984.js} +1 -1
  23. package/dist/_astro/{PmBugsBoard.CMT4-eoB.js → PmBugsBoard.CSIGq0wz.js} +1 -1
  24. package/dist/_astro/{PmIterationsBoard.BQM_dzdZ.js → PmIterationsBoard.BmBc90as.js} +1 -1
  25. package/dist/_astro/{PmProjectDetail.CzU80pat.js → PmProjectDetail.BDKXOQJD.js} +1 -1
  26. package/dist/_astro/{PmProjectsBoard.Cxsa7SYQ.js → PmProjectsBoard.DIVs_xJu.js} +1 -1
  27. package/dist/_astro/{PmRequirementsBoard.4_JMDDN0.js → PmRequirementsBoard.DcLiUhBe.js} +1 -1
  28. package/dist/_astro/PmRequirementsBoard.N0LM5jHo.js +1 -0
  29. package/dist/_astro/PmShared.D69sPvec.js +1 -0
  30. package/dist/_astro/PromptsLibrary.B1RVZqj8.js +1 -0
  31. package/dist/_astro/{ReportsPage.Fh5DRKLT.js → ReportsPage.N1EaH8E-.js} +1 -1
  32. package/dist/_astro/ReqAnalysisBoard.BIIUqGVh.js +25 -0
  33. package/dist/_astro/{RequirementsLibrary.CBkuWE8X.js → RequirementsLibrary.BZhxG9VU.js} +1 -1
  34. package/dist/_astro/SearchableSelect.BIjXzTPD.js +1 -0
  35. package/dist/_astro/SelectDropdown.B3-XpBpn.js +1 -0
  36. package/dist/_astro/{SettingsDialog.CVB5Gtk4.js → SettingsDialog.DILea5eO.js} +1 -1
  37. package/dist/_astro/SlideOverDrawer.HqVYaIjP.js +1 -0
  38. package/dist/_astro/{SpaceSwitcher.BVQLt_tL.js → SpaceSwitcher.BeCumAuj.js} +1 -1
  39. package/dist/_astro/{TasksBoard.Bu-fpIZ7.js → TasksBoard.B3SzQ5bR.js} +1 -1
  40. package/dist/_astro/{TemplatesLibrary.DSylQGlN.js → TemplatesLibrary.Ci3yHQTr.js} +1 -1
  41. package/dist/_astro/{TestStatsBoard.CPyKW4wc.js → TestStatsBoard.CgVvwMzN.js} +1 -1
  42. package/dist/_astro/{TodosBoard.8kvRTEW-.js → TodosBoard.BNDF1iVZ.js} +1 -1
  43. package/dist/_astro/UiAutoBoard.BNLRrunE.js +9 -0
  44. package/dist/_astro/app-config.Cq_F8I0l.js +1 -0
  45. package/dist/_astro/dialog.DZHZCe_T.js +1 -0
  46. package/dist/_astro/{hydrate-cache.BXX604Bw.js → hydrate-cache.zljz1n5X.js} +1 -1
  47. package/dist/_astro/i18n.DPw-aTIZ.js +7 -0
  48. package/dist/_astro/index.astro_astro_type_script_index_0_lang.B9YrqBHf.js +1 -0
  49. package/dist/_astro/{lib.CgXLzMMd.js → lib.BQbwbnfE.js} +1 -1
  50. package/dist/_astro/listbox.DNxAJmEo.js +1 -0
  51. package/dist/_astro/menu.Dnrpz489.js +1 -0
  52. package/dist/_astro/{open-docs-in-session.CyFNgh1I.js → open-docs-in-session.LWVC43xp.js} +1 -1
  53. package/dist/_astro/{plugins.C2BMfzv1.js → plugins.CKkgnq4r.js} +1 -1
  54. package/dist/_astro/{portal.C0hAhXDF.js → portal.Chh6O5xk.js} +2 -2
  55. package/dist/_astro/prompts-meta.D_2wiFiH.js +2 -0
  56. package/dist/_astro/req-analysis.C1uUndMm.js +6 -0
  57. package/dist/_astro/{settings.Ceefeil5.js → settings.HM3DiNh0.js} +2 -2
  58. package/dist/_astro/{spaces-client.BocUabwy.js → spaces-client.CWqBZccW.js} +1 -1
  59. package/dist/_astro/ui-auto-prompt.B09MVaTI.js +4 -0
  60. package/dist/_astro/{update.CtF8vsag.js → update.BSnBvaFF.js} +1 -1
  61. package/dist/_astro/{use-text-value.DBQvHeNl.js → use-text-value.B3mOiuGb.js} +1 -1
  62. package/dist/_astro/{view-prefs.BEAZRcxF.js → view-prefs.7wGuDpzi.js} +1 -1
  63. package/dist/case-exec/index.html +83 -5
  64. package/dist/cases/generate/index.html +53 -5
  65. package/dist/cases/library/index.html +83 -5
  66. package/dist/dashboard/index.html +83 -5
  67. package/dist/docs/changelog/index.html +86 -5
  68. package/dist/docs/install/index.html +52 -4
  69. package/dist/docs/manual/index.html +82 -6
  70. package/dist/index.html +1 -1
  71. package/dist/knowledge/index.html +83 -5
  72. package/dist/knowledge//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/347/274/226/345/206/231/350/247/204/350/214/203/index.html +52 -4
  73. package/dist/plugins/index.html +53 -5
  74. package/dist/pm/bugs/index.html +83 -5
  75. package/dist/pm/iterations/index.html +83 -5
  76. package/dist/pm/projects/detail/index.html +83 -5
  77. package/dist/pm/projects/index.html +83 -5
  78. package/dist/pm/requirements/index.html +83 -5
  79. package/dist/prompts/index.html +83 -5
  80. package/dist/reports/index.html +83 -5
  81. package/dist/requirement-analysis/index.html +795 -0
  82. package/dist/requirements/index.html +83 -5
  83. package/dist/tasks/index.html +83 -5
  84. package/dist/templates/index.html +83 -5
  85. package/dist/templates//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +52 -4
  86. package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +52 -4
  87. package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +52 -4
  88. package/dist/templates//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +52 -4
  89. package/dist/templates//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +52 -4
  90. package/dist/test-automation/index.html +83 -5
  91. package/dist/test-stats/index.html +83 -5
  92. package/dist/todos/index.html +83 -5
  93. package/dist/workbench/index.html +53 -5
  94. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +24 -2
  95. package/lh-plugins/lh-req-analysis.mjs +672 -0
  96. package/lh-plugins/plugin-prompts.mjs +2 -0
  97. package/lh-plugins/req-analysis-prompt.mjs +118 -0
  98. package/package.json +1 -1
  99. package/dist/_astro/Base.Bgxs1QQl.css +0 -1
  100. package/dist/_astro/CaseGenerateApp.DqW_nWMc.js +0 -9
  101. package/dist/_astro/ChatApp.BLxf0h1d.js +0 -219
  102. package/dist/_astro/PluginsPage.-97n3x2U.js +0 -39
  103. package/dist/_astro/PmRequirementsBoard.B8HL07cw.js +0 -1
  104. package/dist/_astro/PmShared.Ca2Ao7v_.js +0 -1
  105. package/dist/_astro/PromptsLibrary.C9BcIxKK.js +0 -1
  106. package/dist/_astro/SearchableSelect.DnjoSslK.js +0 -1
  107. package/dist/_astro/SelectDropdown.CuuDHa8s.js +0 -1
  108. package/dist/_astro/SlideOverDrawer.B7B5Wu8I.js +0 -1
  109. package/dist/_astro/UiAutoBoard.DFTiDqCp.js +0 -9
  110. package/dist/_astro/active-element-history.CED-m1Zp.js +0 -1
  111. package/dist/_astro/app-config.BUPzGl9f.js +0 -1
  112. package/dist/_astro/dialog.BAPTk9a_.js +0 -1
  113. package/dist/_astro/i18n.BGPnP1Bg.js +0 -7
  114. package/dist/_astro/index.astro_astro_type_script_index_0_lang.LPL9mPQY.js +0 -1
  115. package/dist/_astro/listbox.C96OCanh.js +0 -1
  116. package/dist/_astro/menu.IPWdRoNM.js +0 -1
  117. package/dist/_astro/prompts-meta.Bua-j14I.js +0 -2
  118. package/dist/_astro/ui-auto-prompt.CX8fju7r.js +0 -3
  119. package/dist/_astro/use-tree-walker.DFU2AaAP.js +0 -1
@@ -0,0 +1,25 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.Cq_F8I0l.js";import{s as r}from"./plugins.CKkgnq4r.js";import{a as i,n as a,o,r as s}from"./view-prefs.7wGuDpzi.js";import{t as c}from"./jsx-runtime.DUg_B_vD.js";import{t as l}from"./ConfirmDialog.CsMwWevK.js";import{t as u}from"./SelectDropdown.B3-XpBpn.js";import{s as d}from"./llm.BZEzE0x2.js";import{f,l as p,p as m}from"./settings.HM3DiNh0.js";import{showToast as h}from"./Toast.R8_2OWRX.js";import{E as g,S as _,T as ee,_ as v,a as te,b as ne,c as re,d as ie,f as ae,g as oe,h as se,i as ce,l as le,m as y,n as ue,o as de,p as fe,r as b,s as pe,t as me,u as he,v as ge,w as _e,x as ve,y as ye}from"./req-analysis.C1uUndMm.js";import{t as be}from"./hydrate-cache.zljz1n5X.js";import{O as xe,S as x,_ as Se,g as Ce,m as S,u as C}from"./PmShared.D69sPvec.js";var w=e(t(),1),we=`可用工具(只调用这些,不要自己编工具名):
2
+ - req_set_outline:提交本批「需求条目」,返回每个条目的 id。
3
+ - req_set_stories:提交「用户故事」;补写时提交合并后的完整故事集(带原 id 原地更新)。
4
+ - req_save_check:提交体检结果(缺口清单 + 结论)。
5
+
6
+ 提交后不要重复提交同样的内容;工具返回 ok 之后再写最终回答。`,Te=[`missing-scenario`,`missing-dimension`,`untestable-acceptance`,`conflict`,`over-split`,`other`];function Ee(e){try{let t=JSON.parse(e||`{}`);return t&&typeof t==`object`?t:{}}catch{return{}}}function T(e,t=500){return typeof e==`string`?e.trim().slice(0,t):``}function E(e){return String(e??``).toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``)}function De(e){let t=T(e,10);return t===`high`||t===`medium`||t===`low`?t:`medium`}function Oe(e){let t=T(e,40);return Te.includes(t)?t:`other`}var ke=[{type:`function`,function:{name:`req_set_outline`,description:`提交本批从原始需求里抽出的需求条目(一条 = 一个可独立验收的能力点)。返回每个条目的 id,供 sourceRefs 引用。`,parameters:{type:`object`,properties:{items:{type:`array`,items:{type:`object`,properties:{title:{type:`string`,description:`一句话概括`},quote:{type:`string`,description:`原文关键句,不超过 80 字`}},required:[`title`]}}},required:[`items`]}}},{type:`function`,function:{name:`req_set_stories`,description:`提交用户故事。拆解时只提交这一批新故事;补写时提交合并后的完整故事集(带原 id 的原地更新,新故事不带 id)。`,parameters:{type:`object`,properties:{stories:{type:`array`,items:{type:`object`,properties:{id:{type:`string`,description:`已有故事才带(US-001 这种)`},title:{type:`string`,description:`一句话说明这条故事做什么`},role:{type:`string`,description:`角色(来自原文;推断的要在 value 里注明)`},goal:{type:`string`,description:`用户想达成的目标`},value:{type:`string`,description:`业务价值 / 补充说明(角色为推断时写在这里)`},sourceRefs:{type:`array`,items:{type:`string`},description:`对应的需求条目 id(req_set_outline 返回的真实 id)`},priority:{type:`string`,enum:[`P0`,`P1`,`P2`]},preconditions:{type:`array`,items:{type:`string`}},mainFlow:{type:`array`,items:{type:`object`,properties:{actor:{type:`string`},action:{type:`string`,description:`动词开头的一步`},result:{type:`string`,description:`用户能看到的变化`}},required:[`action`]}},altFlows:{type:`array`,items:{type:`object`,properties:{name:{type:`string`},trigger:{type:`string`,description:`什么情况下走这条替代路径`},steps:{type:`array`,items:{type:`string`}}},required:[`name`,`trigger`]}},exceptions:{type:`array`,items:{type:`object`,properties:{scenario:{type:`string`,description:`异常场景`},expected:{type:`string`,description:`系统应有的表现`}},required:[`scenario`,`expected`]}},postconditions:{type:`array`,items:{type:`string`}},acceptance:{type:`array`,items:{type:`object`,properties:{given:{type:`string`},when:{type:`string`},then:{type:`string`,description:`必须可判定`}},required:[`given`,`when`,`then`]}},dimensions:{type:`array`,items:{type:`string`},description:`权限 / 边界值 / 并发与幂等 / 空数据 / 超时与失败 / 国际化与时区`}},required:[`title`,`role`,`mainFlow`,`acceptance`]}}},required:[`stories`]}}},{type:`function`,function:{name:`req_save_check`,description:`提交需求体检结果:语义类缺口清单 + 两三句话结论。只出问题,不改写故事。`,parameters:{type:`object`,properties:{summary:{type:`string`,description:`整体结论,两三句话`},gaps:{type:`array`,items:{type:`object`,properties:{storyTitle:{type:`string`,description:`相关故事标题;全局问题填空串`},type:{type:`string`,enum:Te},severity:{type:`string`,enum:[`high`,`medium`,`low`]},title:{type:`string`},detail:{type:`string`,description:`位置 + 原因`},suggestion:{type:`string`,description:`建议补写什么`}},required:[`title`,`detail`]}}},required:[`gaps`]}}}];async function Ae(e,t,n){let r=Ee(t),i=n.getDoc();if(!i)return JSON.stringify({ok:!1,error:`当前还没有打开分析文档`});if(e===`req_set_outline`){let e=Array.isArray(r.items)?r.items:[];if(!e.length)return JSON.stringify({ok:!0,added:0,total:i.outline.length,items:i.outline.map(({id:e,title:t})=>({id:e,title:t})),note:`没有提交新条目,需求条目保持不变。`});let t=i.outline,a=new Set(t.map(e=>E(e.title))),o=new Set(t.map(e=>e.id)),s=[];for(let t of e){let e=t&&typeof t==`object`?t:{},r=T(e.title,200)||T(e.quote,200);if(!r||a.has(E(r)))continue;a.add(E(r));let i=`RO-${n.batch+1}-${s.length+1}`,c=i,l=1;for(;o.has(c);)c=`${i}-${l++}`;o.add(c),s.push({id:c,title:r,quote:T(e.quote,500)})}let c=[...t,...s],l=await n.saveOutline(c);return JSON.stringify({ok:!0,added:s.length,total:l.length,items:l.map(({id:e,title:t})=>({id:e,title:t})),note:s.length>0?`条目已保存。接下来用 req_set_stories 提交故事,sourceRefs 只能引用上面返回的 id。`:`这些条目已经存在,没有重复写入;继续提交故事即可。`})}if(e===`req_set_stories`){let e=Array.isArray(r.stories)?r.stories:[];if(!e.length)return JSON.stringify({ok:!0,added:0,total:i.stories.length,note:`没有提交故事,故事集保持不变。`});let t=i.stories.length,a=ge(i.stories,e),o=await n.saveStories(a),s=new Set(i.outline.map(e=>e.id)),c=o.stories.flatMap(e=>e.sourceRefs).filter(e=>!s.has(e));return JSON.stringify({ok:!0,added:Math.max(0,o.stories.length-t),total:o.stories.length,stories:o.stories.map(({id:e,title:t,priority:n})=>({id:e,title:t,priority:n})),danglingSourceRefs:Array.from(new Set(c)).slice(0,10),note:c.length>0?`有些 sourceRefs 不在需求条目里,覆盖率会算不到;需要的话用真实条目 id 修正。`:`故事已保存。`})}if(e===`req_save_check`){let e=re(i),t=new Map(i.stories.filter(e=>e.title).map(e=>[E(e.title),e.id])),a=new Set(i.stories.map(e=>e.id)),o=Array.isArray(r.gaps)?r.gaps:[],s=[];for(let e of o){let n=e&&typeof e==`object`?e:{},r=T(n.title,200);if(!r)continue;let i=T(n.storyId,20),o=a.has(i)&&i||t.get(E(T(n.storyTitle,200)))||``,c=Oe(n.type);s.push({id:y(c,o,r),storyId:o,type:c,severity:De(n.severity),title:r,detail:T(n.detail,1e3),suggestion:T(n.suggestion,1e3),origin:`model`,selected:!1})}let c=v(e.gaps,s),l=T(r.summary,1500)||e.summary;return await n.saveCheck({...e,summary:l,gaps:c}),JSON.stringify({ok:!0,gaps:c.length,high:c.filter(e=>e.severity===`high`).length,coverage:e.coverage,dimensions:e.dimensions.map(e=>({label:e.label,covered:e.covered})),note:`体检报告已保存:整体 ${c.length} 个缺口(高 ${c.filter(e=>e.severity===`high`).length} 个),覆盖率 ${Math.round(e.coverage.rate*100)}%。用户可以在页面上勾选缺口补写。`})}return JSON.stringify({ok:!1,error:`未知工具:${e}`})}function D(e){let t=[],n=/```json\s*([\s\S]*?)```/gi,r;for(;(r=n.exec(e))!==null;)r[1]?.trim()&&t.push(r[1].trim());return t}function je(e){let t=D(String(e??``));for(let e of t)try{let t=JSON.parse(e),n=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.stories)?t.stories:null;if(!n?.length)continue;let r=n.filter(e=>!!(e&&typeof e==`object`&&typeof e.title==`string`));if(r.length)return r}catch{}return[]}var O=c(),k=`text-xs font-semibold tracking-wide text-stone-500`,Me={high:0,medium:1,low:2};function Ne({check:e,stories:t,busy:n,onToggleGap:r,onToggleAll:i,onFix:a,onAudit:o}){if(!e)return(0,O.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-dashed border-stone-200 px-4 py-16 text-center`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有体检`}),(0,O.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`体检会先用固定规则核对覆盖率与字段完整性,再让模型补语义缺口(场景遗漏、替代流程不成立、验收不可测)。`}),(0,O.jsx)(`button`,{type:`button`,className:`mt-4 h-9 rounded-md bg-[#3370ff] px-4 text-sm font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-50`,disabled:n||!t.length,onClick:o,children:`开始体检`})]});let s=[...e.gaps].sort((e,t)=>Me[e.severity]-Me[t.severity]),c=s.filter(e=>e.selected).length,l=e.coverage.total?Math.round(e.coverage.rate*100):0,u=new Map(t.map(e=>[e.id,e.title]));return(0,O.jsxs)(`div`,{className:`space-y-4`,children:[(0,O.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:k,children:`需求条目覆盖率`}),(0,O.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.coverage.covered,(0,O.jsxs)(`span`,{className:`text-sm font-normal text-stone-400`,children:[` / `,e.coverage.total]}),(0,O.jsxs)(`span`,{className:`ml-2 text-sm font-normal text-stone-500`,children:[l,`%`]})]})]}),(0,O.jsxs)(`div`,{className:`min-w-[160px] flex-1`,children:[(0,O.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-stone-100`,children:(0,O.jsx)(`div`,{className:`h-full rounded-full transition-all ${l>=90?`bg-emerald-500`:l>=60?`bg-amber-500`:`bg-red-500`}`,style:{width:`${Math.max(l,e.coverage.total?2:0)}%`}})}),(0,O.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:e.coverage.total?`有故事引用的条目算覆盖;sourceRefs 为空的故事不会计入`:`还没有需求条目,先做一次拆解`})]}),(0,O.jsxs)(`div`,{className:`text-right`,children:[(0,O.jsx)(`p`,{className:k,children:`缺口`}),(0,O.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[s.length,(0,O.jsxs)(`span`,{className:`ml-1 text-xs font-normal text-stone-400`,children:[`高 `,s.filter(e=>e.severity===`high`).length]})]})]})]}),e.summary?(0,O.jsx)(`p`,{className:`mt-3 border-t border-stone-100 pt-2 text-xs leading-relaxed text-stone-500`,children:e.summary}):null]}),(0,O.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,O.jsx)(`p`,{className:k,children:`维度覆盖`}),(0,O.jsx)(`div`,{className:`mt-2 grid gap-1.5 sm:grid-cols-2 lg:grid-cols-3`,children:e.dimensions.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border px-2.5 py-1.5 text-xs ${e.covered?`border-emerald-200 bg-emerald-50/60 text-emerald-800`:`border-stone-200 bg-stone-50 text-stone-500`}`,children:[(0,O.jsx)(`span`,{"aria-hidden":`true`,children:e.covered?`✓`:`—`}),(0,O.jsx)(`span`,{className:`font-medium`,children:e.label}),e.stories.length?(0,O.jsx)(`span`,{className:`truncate text-[11px] text-stone-400`,children:e.stories.join(`, `)}):null]},e.key))})]}),(0,O.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-stone-100 px-4 py-2.5`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium text-stone-700`,children:`缺口清单`}),(0,O.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`已选 `,c,` 条`]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,className:`h-7 rounded-md border border-stone-200 px-2 text-xs text-stone-600 transition-colors hover:bg-stone-50`,onClick:()=>i(c!==s.length),children:c===s.length&&s.length?`清空选择`:`全选`}),(0,O.jsx)(`button`,{type:`button`,className:`h-7 rounded-md bg-[#3370ff] px-2.5 text-xs font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-50`,disabled:n||!c,onClick:a,children:`补写选中缺口`})]})]}),s.length?(0,O.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:s.map(e=>(0,O.jsxs)(`li`,{className:`flex items-start gap-2.5 px-4 py-2.5`,children:[(0,O.jsx)(`input`,{type:`checkbox`,className:`mt-1 h-3.5 w-3.5 shrink-0 accent-[#3370ff]`,checked:e.selected,onChange:t=>r(e.id,t.target.checked)}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,O.jsx)(x,{tone:ue[e.severity],children:me[e.severity]}),(0,O.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 text-[11px] text-stone-500`,children:b[e.type]}),e.storyId?(0,O.jsxs)(`span`,{className:`font-mono text-[11px] text-stone-400`,children:[e.storyId,u.get(e.storyId)?` · ${u.get(e.storyId)}`:``]}):(0,O.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`全局`}),(0,O.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:e.origin===`model`?`模型`:`规则`})]}),(0,O.jsx)(`p`,{className:`mt-0.5 text-sm text-stone-800`,children:e.title}),e.detail?(0,O.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-stone-500`,children:e.detail}):null,e.suggestion?(0,O.jsxs)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-amber-700`,children:[`建议:`,e.suggestion]}):null]})]},e.id))}):(0,O.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-stone-400`,children:`没有发现缺口。覆盖率与维度都过了,可以再人工过一遍验收标准。`})]})]})}var Pe=[{value:`P0`,label:`P0 · 必须做`},{value:`P1`,label:`P1 · 应该做`},{value:`P2`,label:`P2 · 可以做`}],A=`h-9 w-full rounded-md border border-stone-200 bg-white px-2 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`,j=`w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`,M=`text-xs font-semibold tracking-wide text-stone-500`;function N(e){return e.split(`
7
+ `).map(e=>e.trim()).filter(Boolean)}function P({label:e,value:t,placeholder:n,onChange:r}){return(0,O.jsxs)(`label`,{className:`block`,children:[(0,O.jsxs)(`span`,{className:M,children:[e,`(一行一条)`]}),(0,O.jsx)(`textarea`,{className:`${j} mt-1 min-h-[64px]`,value:t.join(`
8
+ `),placeholder:n,onChange:e=>r(N(e.target.value))})]})}function F({value:e,onChange:t}){return(0,O.jsxs)(`label`,{className:`block`,children:[(0,O.jsx)(`span`,{className:M,children:`主流程(一行一步:动作 -> 结果)`}),(0,O.jsx)(`textarea`,{className:`${j} mt-1 min-h-[80px]`,value:e.map(e=>e.result?`${e.action} -> ${e.result}`:e.action).join(`
9
+ `),placeholder:`填写申请单 -> 进入待审批`,onChange:e=>t(N(e.target.value).map(e=>{let t=e.indexOf(`->`)>=0?e.indexOf(`->`):e.indexOf(`→`);return t<0?{action:e}:{action:e.slice(0,t).trim(),result:e.slice(t+(e.startsWith(`->`,t)?2:1)).trim()}}))})]})}function I({value:e,onChange:t}){let n=e.map(e=>[`${e.name} | ${e.trigger}`,...e.steps.map((e,t)=>`${t+1}. ${e}`)].join(`
10
+ `)).join(`
11
+
12
+ `);return(0,O.jsxs)(`label`,{className:`block`,children:[(0,O.jsx)(`span`,{className:M,children:`替代流程(空行分段:名称 | 触发条件,下面写步骤)`}),(0,O.jsx)(`textarea`,{className:`${j} mt-1 min-h-[80px]`,value:n,placeholder:`转人工审批 | 金额超过 5 万
13
+ 1. 提交后进入人工队列
14
+ 2. 审批通过再继续`,onChange:e=>t(e.target.value.split(/\n{2,}/).map(e=>{let t=e.split(`
15
+ `).map(e=>e.trim()).filter(Boolean),[n,r]=(t.shift()??``).split(`|`);return{name:(n??``).trim()||`替代流程`,trigger:(r??``).trim(),steps:t.map(e=>e.replace(/^\d+[.、)]\s*/,``))}}).filter(e=>e.name!==`替代流程`||e.steps.length||e.trigger))})]})}function L({value:e,onChange:t}){return(0,O.jsxs)(`label`,{className:`block`,children:[(0,O.jsx)(`span`,{className:M,children:`异常场景(一行一条:场景 -> 预期)`}),(0,O.jsx)(`textarea`,{className:`${j} mt-1 min-h-[80px]`,value:e.map(e=>e.expected?`${e.scenario} -> ${e.expected}`:e.scenario).join(`
16
+ `),placeholder:`提交时网络中断 -> 提示重试并保留草稿`,onChange:e=>t(N(e.target.value).map(e=>{let t=e.indexOf(`->`)>=0?e.indexOf(`->`):e.indexOf(`→`);return t<0?{scenario:e,expected:``}:{scenario:e.slice(0,t).trim(),expected:e.slice(t+(e.startsWith(`->`,t)?2:1)).trim()}}))})]})}function R({value:e,onChange:t}){return(0,O.jsxs)(`label`,{className:`block`,children:[(0,O.jsx)(`span`,{className:M,children:`验收标准(一行一条:Given | When | Then)`}),(0,O.jsx)(`textarea`,{className:`${j} mt-1 min-h-[80px]`,value:e.map(e=>`${e.given} | ${e.when} | ${e.then}`).join(`
17
+ `),placeholder:`已登录且有权限 | 提交申请单 | 列表里出现一条待审批记录`,onChange:e=>t(N(e.target.value).map(e=>{let[t=``,n=``,r=``]=e.split(`|`).map(e=>e.trim());return{given:t,when:n,then:r}}))})]})}function Fe({story:e,index:t,total:n,gaps:r,busy:i,onSave:a,onDelete:o,onMove:s,domId:c}){let[l,d]=(0,w.useState)(!1),[f,p]=(0,w.useState)(!1),[m,h]=(0,w.useState)(e),g=()=>{h({...e}),p(!0),d(!0)},_=e=>h(t=>({...t,...e})),ee=r.filter(e=>e.severity===`high`).length;return(0,O.jsxs)(`li`,{id:c,className:`tw-pm-card rounded-xl border border-stone-200 bg-white`,children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-2 px-4 py-3`,children:[(0,O.jsx)(`button`,{type:`button`,className:`mt-0.5 shrink-0 rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,"aria-label":l?`收起`:`展开`,onClick:()=>d(e=>!e),children:(0,O.jsx)(S,{name:`chevronRight`,size:14,className:l?`rotate-90 transition-transform`:`transition-transform`})}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 font-mono text-[11px] text-stone-500`,children:e.id||`待编号`}),(0,O.jsx)(x,{tone:de[e.priority],children:e.priority}),(0,O.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:e.title}),r.length>0?(0,O.jsxs)(x,{tone:ee?`red`:`amber`,children:[r.length,` 个缺口`,ee?` · 高 ${ee}`:``]}):null]}),(0,O.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-stone-500`,children:[e.role&&`角色:${e.role}`,e.goal&&`目标:${e.goal}`].filter(Boolean).join(` · `)||`还没有写角色与目标`})]}),(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,O.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-30`,"aria-label":`上移`,disabled:i||t===0,onClick:()=>s(-1),children:(0,O.jsx)(S,{name:`chevronRight`,size:14,className:`-rotate-90`})}),(0,O.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-30`,"aria-label":`下移`,disabled:i||t>=n-1,onClick:()=>s(1),children:(0,O.jsx)(S,{name:`chevronRight`,size:14,className:`rotate-90`})}),(0,O.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,"aria-label":f?`取消编辑`:`编辑`,onClick:()=>f?p(!1):g(),children:(0,O.jsx)(S,{name:`pencil`,size:14})}),(0,O.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-red-50 hover:text-red-500 disabled:opacity-30`,"aria-label":`删除`,disabled:i,onClick:o,children:(0,O.jsx)(S,{name:`trash`,size:14})})]})]}),f?(0,O.jsxs)(`div`,{className:`space-y-3 border-t border-stone-100 px-4 py-3`,children:[(0,O.jsxs)(`label`,{className:`block`,children:[(0,O.jsx)(`span`,{className:M,children:`标题`}),(0,O.jsx)(`input`,{className:`${A} mt-1`,value:m.title,onChange:e=>_({title:e.target.value})})]}),(0,O.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,O.jsxs)(`label`,{className:`block`,children:[(0,O.jsx)(`span`,{className:M,children:`角色`}),(0,O.jsx)(`input`,{className:`${A} mt-1`,value:m.role,onChange:e=>_({role:e.target.value})})]}),(0,O.jsxs)(`label`,{className:`block`,children:[(0,O.jsx)(`span`,{className:M,children:`优先级`}),(0,O.jsx)(`div`,{className:`mt-1`,children:(0,O.jsx)(u,{options:Pe,value:m.priority,onChange:e=>_({priority:e}),ariaLabel:`优先级`,flat:!0})})]})]}),(0,O.jsxs)(`label`,{className:`block`,children:[(0,O.jsx)(`span`,{className:M,children:`目标`}),(0,O.jsx)(`input`,{className:`${A} mt-1`,value:m.goal,onChange:e=>_({goal:e.target.value})})]}),(0,O.jsxs)(`label`,{className:`block`,children:[(0,O.jsx)(`span`,{className:M,children:`价值 / 备注`}),(0,O.jsx)(`input`,{className:`${A} mt-1`,value:m.value,onChange:e=>_({value:e.target.value})})]}),(0,O.jsx)(P,{label:`前置条件`,value:m.preconditions,placeholder:`已登录且拥有申请权限`,onChange:e=>_({preconditions:e})}),(0,O.jsx)(F,{value:m.mainFlow,onChange:e=>_({mainFlow:e})}),(0,O.jsx)(I,{value:m.altFlows,onChange:e=>_({altFlows:e})}),(0,O.jsx)(L,{value:m.exceptions,onChange:e=>_({exceptions:e})}),(0,O.jsx)(P,{label:`后置条件`,value:m.postconditions,placeholder:`申请单状态变为待审批`,onChange:e=>_({postconditions:e})}),(0,O.jsx)(R,{value:m.acceptance,onChange:e=>_({acceptance:e})}),(0,O.jsx)(P,{label:`覆盖维度`,value:m.dimensions,placeholder:`权限、边界值、超时与失败`,onChange:e=>_({dimensions:e})}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,O.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`来源条目:`,e.sourceRefs.join(`、`)||`(未关联)`]}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,className:`h-8 rounded-md border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,onClick:()=>p(!1),children:`取消`}),(0,O.jsx)(`button`,{type:`button`,className:`h-8 rounded-md bg-[#3370ff] px-3 text-xs font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-50`,disabled:i||!m.title.trim(),onClick:()=>{a(m),p(!1)},children:`保存`})]})]})]}):null,l&&!f?(0,O.jsxs)(`div`,{className:`space-y-3 border-t border-stone-100 px-4 py-3 text-sm text-stone-700`,children:[e.value?(0,O.jsxs)(`p`,{className:`text-xs text-stone-500`,children:[`价值 / 备注:`,e.value]}):null,e.preconditions.length?(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:M,children:`前置条件`}),(0,O.jsx)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-5 text-sm`,children:e.preconditions.map((e,t)=>(0,O.jsx)(`li`,{children:e},t))})]}):null,e.mainFlow.length?(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:M,children:`主流程`}),(0,O.jsx)(`ol`,{className:`mt-1 list-decimal space-y-0.5 pl-5 text-sm`,children:e.mainFlow.map((e,t)=>(0,O.jsxs)(`li`,{children:[e.actor?`${e.actor}:`:``,e.action,e.result?(0,O.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.result]}):null]},t))})]}):null,e.altFlows.length?(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:M,children:`替代流程`}),(0,O.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm`,children:e.altFlows.map((e,t)=>(0,O.jsxs)(`li`,{children:[(0,O.jsx)(`span`,{className:`font-medium`,children:e.name}),e.trigger?(0,O.jsxs)(`span`,{className:`text-stone-500`,children:[`(触发:`,e.trigger,`)`]}):null,(0,O.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-5 text-stone-600`,children:e.steps.map((e,t)=>(0,O.jsx)(`li`,{children:e},t))})]},t))})]}):null,e.exceptions.length?(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:M,children:`异常场景`}),(0,O.jsx)(`ul`,{className:`mt-1 space-y-0.5 text-sm`,children:e.exceptions.map((e,t)=>(0,O.jsxs)(`li`,{children:[e.scenario,e.expected?(0,O.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.expected]}):null]},t))})]}):null,e.postconditions.length?(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:M,children:`后置条件`}),(0,O.jsx)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-5 text-sm`,children:e.postconditions.map((e,t)=>(0,O.jsx)(`li`,{children:e},t))})]}):null,e.acceptance.length?(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:M,children:`验收标准`}),(0,O.jsx)(`ul`,{className:`mt-1 space-y-0.5 text-sm`,children:e.acceptance.map((e,t)=>(0,O.jsxs)(`li`,{children:[(0,O.jsx)(`span`,{className:`text-stone-400`,children:`Given`}),` `,e.given||`—`,` `,(0,O.jsx)(`span`,{className:`text-stone-400`,children:`When`}),` `,e.when||`—`,` `,(0,O.jsx)(`span`,{className:`text-stone-400`,children:`Then`}),` `,(0,O.jsx)(`span`,{className:e.then?`text-stone-700`:`text-red-500`,children:e.then||`(未写)`})]},t))})]}):null,e.dimensions.length?(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,O.jsx)(`span`,{className:M,children:`覆盖维度`}),e.dimensions.map(e=>(0,O.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 text-[11px] text-stone-500`,children:e},e))]}):null,(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 text-[11px] text-stone-400`,children:[(0,O.jsx)(`span`,{children:`来源条目`}),e.sourceRefs.length?e.sourceRefs.map(e=>(0,O.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 font-mono text-stone-500`,children:e},e)):(0,O.jsx)(`span`,{className:`text-amber-600`,children:`未关联(覆盖率会算不到)`})]}),r.length?(0,O.jsxs)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50/60 px-3 py-2`,children:[(0,O.jsx)(`p`,{className:`text-xs font-medium text-amber-900`,children:`体检发现的问题`}),(0,O.jsx)(`ul`,{className:`mt-1 space-y-1`,children:r.map(e=>(0,O.jsxs)(`li`,{className:`flex flex-wrap items-center gap-1.5 text-xs`,children:[(0,O.jsx)(x,{tone:ue[e.severity],children:me[e.severity]}),(0,O.jsx)(`span`,{className:`text-stone-500`,children:b[e.type]}),(0,O.jsx)(`span`,{className:`text-stone-700`,children:e.title})]},e.id))})]}):null]}):null]})}var Ie=`reqanalysis.doc`,Le=`reqanalysis.listmode`,z=/\.[a-z0-9]+$/i,Re={md:`Markdown`,markdown:`Markdown`,txt:`文本`,csv:`CSV`,docx:`Word`,xlsx:`Excel`,xls:`Excel`,doc:`Word(旧版)`,pdf:`PDF`,ppt:`PPT`,pptx:`PPT`},ze=`inline-flex h-9 items-center justify-center gap-1.5 rounded-md bg-[#3370ff] px-3.5 text-sm font-medium text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,Be=`inline-flex h-9 items-center justify-center gap-1.5 rounded-md border border-stone-200 bg-white px-3 text-sm text-stone-700 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`,B=`text-xs font-semibold tracking-wide text-stone-500`;function Ve(e){return e.split(`/`).pop()||e}function He(e){return e.replace(z,``)}function Ue(e){return(e.format||Ve(e.path).split(`.`).pop()||``).toLowerCase()}function We(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return`—`;let n=e=>String(e).padStart(2,`0`),r=`${n(t.getMonth()+1)}/${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`;return t.getFullYear()===new Date().getFullYear()?r:`${t.getFullYear()}/${r}`}function Ge(e){return[...e].sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))}function Ke(){let e=xe(`reqAnalysis`),[t,c]=(0,w.useState)(null),[v,y]=(0,w.useState)([]),[ue,de]=(0,w.useState)(``),[b,me]=(0,w.useState)(null),[Te,Ee]=(0,w.useState)([]),[T,E]=(0,w.useState)(``),[De,Oe]=(0,w.useState)(``),[D,k]=(0,w.useState)(null),[Me,Pe]=(0,w.useState)(null),[A,j]=(0,w.useState)(null),[M,N]=(0,w.useState)([]),[P,F]=(0,w.useState)(``),[I,L]=(0,w.useState)(``),[R,z]=(0,w.useState)(`stories`),[Ke,qe]=(0,w.useState)(`list`),[Je,Ye]=(0,w.useState)(()=>a(Le,[`doc`,`story`],`doc`)),[V,Xe]=(0,w.useState)(``),[H,Ze]=(0,w.useState)(null),[Qe,$e]=(0,w.useState)([]),et=(0,w.useRef)(``),[tt,nt]=(0,w.useState)(``),[rt,it]=(0,w.useState)(!1),[at,ot]=(0,w.useState)(!1),U=(0,w.useRef)(null),W=(0,w.useRef)(null),st=(0,w.useRef)(0),ct=(0,w.useRef)(null),lt=(0,w.useRef)(null),ut=(0,w.useMemo)(()=>{let e=e=>+!e.supported;return[...Te].sort((t,n)=>e(t)-e(n)||t.path.localeCompare(n.path,`zh`)).map(e=>{let t=Ue(e),n=Re[t]??t.toUpperCase();return{value:e.path,label:e.path,secondary:e.supported?t:`${n} · 暂不支持,请另存为 .docx / .xlsx / .md`,disabled:!e.supported}})},[Te]),G=(0,w.useCallback)(e=>{U.current=e,me(e),y(t=>Ge(t.map(t=>t.id===e.id?e:t)))},[]),K=(0,w.useCallback)((e,t=`info`)=>{st.current+=1,N(n=>[...n,{id:st.current,kind:t,text:e,at:new Date().toISOString()}])},[]),q=(0,w.useCallback)(e=>{U.current=e,me(e),de(e?.id??``),o(Ie,e?.id??``),e?.sourcePath&&E(e.sourcePath)},[]),J=(0,w.useCallback)((e,t=`stories`)=>{q(e),z(t),qe(`work`),be(`req-analysis`)},[q]),dt=(0,w.useCallback)((e,t)=>{et.current=t,J(e,`stories`)},[J]);(0,w.useEffect)(()=>{if(Ke!==`work`||!et.current)return;let e=et.current;et.current=``;let t=0,n=requestAnimationFrame(()=>{let n=document.getElementById(`req-story-${e}`);n&&(n.scrollIntoView({block:`center`,behavior:`smooth`}),n.classList.add(`tw-req-story-focus`),t=window.setTimeout(()=>n.classList.remove(`tw-req-story-focus`),1600))});return()=>{cancelAnimationFrame(n),t&&window.clearTimeout(t)}},[Ke,b?.id]);let ft=(0,w.useMemo)(()=>v.flatMap(e=>e.stories.map(t=>({doc:e,story:t}))),[v]),pt=ft.length,mt=(0,w.useMemo)(()=>{let e=V.trim().toLowerCase(),t=t=>String(t??``).toLowerCase().includes(e),n=e?ft.filter(({doc:e,story:n})=>t(n.id)||t(n.title)||t(n.role)||t(n.goal)||t(e.title)):ft,r=[],i=new Map;for(let e of n){let t=i.get(e.doc.id);t===void 0?(i.set(e.doc.id,r.length),r.push({doc:e.doc,rows:[e]})):r[t].rows.push(e)}return r.sort((e,t)=>t.doc.updatedAt.localeCompare(e.doc.updatedAt))},[ft,V]),ht=(0,w.useMemo)(()=>new Set(H?.ids??[]),[H]),gt=(0,w.useCallback)((e,t)=>{Ze(n=>{if(!n||n.docId!==e)return{docId:e,ids:[t]};let r=n.ids.includes(t)?n.ids.filter(e=>e!==t):[...n.ids,t];return r.length?{docId:e,ids:r}:null})},[]),_t=(0,w.useCallback)((e,t)=>{Ze(n=>n?.docId===e&&t.every(e=>n.ids.includes(e))?null:t.length?{docId:e,ids:t}:null)},[]),vt=(0,w.useCallback)(e=>{Ye(e),i(Le,e)},[]);(0,w.useEffect)(()=>{let e=!0;(async()=>{if(await n(),!e)return;k(p());let t=await ae();if(e&&(c(t),t))try{let[t,n]=await Promise.all([se(),fe()]);if(!e)return;let r=n;if((!n.exists||!n.decompose.trim())&&(await _e(!0).catch(()=>void 0),r=await fe()),!e)return;Pe(r);let i=Ge(t);y(i);let a=s(Ie,``),o=i.find(e=>e.id===a)??i[0]??null;q(o)}catch(t){e&&L(t instanceof Error?t.message:String(t))}})();let t=f(()=>k(p()));return()=>{e=!1,t()}},[q]),(0,w.useEffect)(()=>{if(!t)return;let e=!0;return oe().then(t=>{e&&Ee(t)}).catch(t=>{e&&Oe(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[t]),(0,w.useEffect)(()=>{let e=b?.sourcePath;if(!e){nt(``);return}let t=!0;return ne(e).then(e=>{t&&nt(ve(e))}).catch(()=>{t&&nt(``)}),()=>{t=!1}},[b?.sourcePath,b?.sourceHash]),(0,w.useEffect)(()=>{let e=ct.current;e&&(e.scrollTop=e.scrollHeight)},[M]);let yt=!!(b?.sourceHash&&tt&&b.sourceHash!==tt),bt=(0,w.useMemo)(()=>new Set((b?.stories??[]).flatMap(e=>e.sourceRefs)),[b?.stories]),Y=Me??null,xt=!!Y?.decompose.trim(),St=(0,w.useMemo)(()=>(b?.check?.gaps??[]).filter(e=>e.selected).length,[b?.check]),X=(0,w.useCallback)(async(e,t)=>{let n=t??U.current;if(!n)throw Error(`还没有分析文档`);let r=await g(n.id,e);return G(r),r},[G]),Ct=(0,w.useCallback)(()=>{lt.current&&window.clearTimeout(lt.current),lt.current=window.setTimeout(()=>{let e=U.current;e?.check&&g(e.id,{check:e.check}).catch(()=>void 0)},600)},[]),wt=(0,w.useCallback)(async e=>{if(!e)return null;let t=v.find(t=>t.sourcePath===e);if(t)return J(t,`stories`),t;try{let t=await ne(e),n=Ve(e),r=await le({sourcePath:e,sourceTitle:n,sourceHash:ve(t),title:He(n)});return y(e=>Ge([r,...e])),J(r,`stories`),K(`新建分析:${r.title}`),r}catch(e){let t=e instanceof Error?e.message:String(e);return L(t),h(t,`error`),E(U.current?.sourcePath??``),null}},[v,J,K]),Z=!!(D?.baseURL&&D.apiKey&&D.model),Tt=(0,w.useCallback)(()=>!Z||!D?(h(`请先在设置里配置模型`,`error`),m(`model`),null):D,[Z,D]),Q=(0,w.useCallback)((e,t)=>({getDoc:()=>U.current,batch:t,saveOutline:async t=>{let n=await g(e.id,{outline:t});return G(n),n.outline},saveStories:async t=>{let n=await g(e.id,{stories:t});return G(n),K(`已写入 ${n.stories.length} 个用户故事`),n},saveCheck:async t=>{let n=U.current?.check,r={...t,gaps:ye(n?.gaps??[],t.gaps)},i=await g(e.id,{check:r,status:`checked`});return G(i),i}}),[G,K]),Et=(0,w.useCallback)(async()=>{let e=U.current,t=Tt();if(!e||!t)return;let n=Y?.decompose.trim()??``;if(!n){h(`没有读到「${te}」的「## 拆解」段落`,`error`);return}L(``),F(``),N([]),j(`decompose`);let r=new AbortController;W.current=r;try{let i=await ne(e.sourcePath);if(!i.trim())throw Error(`来源文档是空的`);let a=_(i);if(!a.length)throw Error(`来源文档没有可拆解的内容`);K(a.length>1?`来源 ${i.length} 字,已分 ${a.length} 批拆解`:`来源 ${i.length} 字,单批拆解`);let o=await g(e.id,{replaceStories:!0,stories:[],outline:[],check:null,status:`draft`,sourceHash:ve(i)});G(o);for(let i of a){if(r.signal.aborted)break;let o=U.current?.stories.length??0,s=[n,``,we,``,`## 已抽取的需求条目(sourceRefs 只能引用这些 id)`,(U.current?.outline??[]).map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
18
+ `)||`(本批还没有条目,先调用 req_set_outline)`].join(`
19
+ `),c=[`这一批是原始需求的第 ${i.index+1}/${a.length} 段${i.title?`(章节:${i.title})`:``}。只处理这一段的条目与故事,已完成的部分不要重写。`,``,`## 原始需求`,``,i.text].join(`
20
+ `);await X({progress:{stage:`stories`,done:i.index,total:a.length,message:`正在拆第 ${i.index+1}/${a.length} 批`,at:new Date().toISOString()}},U.current).catch(()=>void 0);let l=``;for await(let n of d(t,[{role:`system`,content:s},{role:`user`,content:c}],r.signal,{tools:ke,maxToolRounds:20,runTool:(t,n)=>Ae(t,n,Q(e,i.index))}))n.type===`content`?(l+=n.delta,F(e=>e+n.delta)):n.type===`tool`&&n.status===`running`&&K(`调用 ${n.name}`,`tool`);if((U.current?.stories.length??0)===o){let t=je(l);if(t.length){let n=ge(U.current?.stories??[],t),r=await g(e.id,{stories:n});G(r),K(`模型没调工具,已从回答里兜底解析 ${t.length} 个故事`,`info`)}else K(`第 ${i.index+1} 批没有拿到结构化故事`,`error`)}}if(r.signal.aborted){K(`已中断:已经写入的故事保留`,`info`);return}let s=await g(e.id,{status:`decomposed`,progress:{stage:`done`,done:a.length,total:a.length,message:`拆解完成`,at:new Date().toISOString()}});G(s),K(`拆解完成:${s.outline.length} 条需求条目、${s.stories.length} 个用户故事`,`done`),z(`stories`),h(`拆解完成,建议接着跑一次体检`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);r.signal.aborted?K(`已中断:已经写入的故事保留`,`info`):(L(t),K(`拆解失败:${t}`,`error`))}finally{j(null),W.current=null}},[Q,G,K,Y,Tt,X]),Dt=(0,w.useCallback)(async()=>{let e=U.current;if(!e)return;if(!e.stories.length){h(`还没有用户故事,先做一次拆解`,`info`);return}L(``),F(``),N([]),j(`audit`);let t=new AbortController;W.current=t;try{let n=re(e),r=await g(e.id,{check:{...n,gaps:ye(e.check?.gaps??[],n.gaps)},status:`checked`,progress:{stage:`audit`,done:0,total:1,message:`规则体检完成,等待模型评审`,at:new Date().toISOString()}});G(r),K(`规则体检:覆盖率 ${Math.round(n.coverage.rate*100)}%,${n.gaps.length} 个缺口`);let i=Y?.audit.trim()??``,a=Z?D:null;if(!a||!i){K(a?`体检提示词为空,只保留规则结果`:`没有配置模型,只保留规则结果`,`info`),z(`check`);return}let o=!1,s=Q(e,90),c=s.saveCheck;s.saveCheck=async e=>{o=!0;let t=await c(e);return K(`模型体检:整体 ${t.check?.gaps.length??0} 个缺口`,`done`),t};let l=U.current??r,u=[`## 需求条目`,l.outline.length?l.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
21
+ `):`(无)`,``,`## 用户故事(${l.stories.length} 条)`,"```json",JSON.stringify(l.stories,null,2),"```"].join(`
22
+ `);for await(let e of d(a,[{role:`system`,content:`${i}\n\n${we}`},{role:`user`,content:u}],t.signal,{tools:ke.filter(e=>e.function.name===`req_save_check`),maxToolRounds:8,runTool:(e,t)=>Ae(e,t,s)}))e.type===`content`?F(t=>t+e.delta):e.type===`tool`&&e.status===`running`&&K(`调用 ${e.name}`,`tool`);o||(K(`模型没有提交体检结果,当前只保留规则结果`,`error`),h(`模型没有提交体检结果,只保留了规则检查`,`error`)),z(`check`)}catch(e){let n=e instanceof Error?e.message:String(e);t.signal.aborted?K(`已中断:规则体检结果已保留`,`info`):(L(n),K(`体检失败:${n}`,`error`))}finally{j(null),W.current=null}},[Q,Z,G,K,Y,D]),Ot=(0,w.useCallback)(async()=>{let e=U.current,t=Tt();if(!e||!t)return;let n=(e.check?.gaps??[]).filter(e=>e.selected);if(!n.length){h(`先在缺口清单里勾选要补写的条目`,`info`);return}let r=Y?.fix.trim()??``;if(!r){h(`「需求分析提示词.md」缺少「## 补写」段落`,`error`);return}L(``),F(``),N([]),j(`fix`);let i=new AbortController;W.current=i;try{K(`按 ${n.length} 个勾选缺口补写`,`info`);let a=new Map(e.stories.map(e=>[e.id,e.title])),o=[`## 当前故事集(${e.stories.length} 条,没被点名的必须原样保留)`,"```json",JSON.stringify(e.stories,null,2),"```",``,`## 勾选待补写的缺口`,n.map(e=>{let t=e.storyId?`${e.storyId} ${a.get(e.storyId)??``}`:`全局问题`;return[`- [${e.severity}] ${t}|${e.title}`,e.detail?` 原因:${e.detail}`:``,e.suggestion?` 建议:${e.suggestion}`:``].filter(Boolean).join(`
23
+ `)}).join(`
24
+ `)].join(`
25
+ `),s=Q(e,90),c=!1,l=s.saveStories;s.saveStories=async e=>(c=!0,l(e));for await(let e of d(t,[{role:`system`,content:`${r}\n\n${we}`},{role:`user`,content:o}],i.signal,{tools:ke.filter(e=>e.function.name===`req_set_stories`),maxToolRounds:10,runTool:(e,t)=>Ae(e,t,s)}))e.type===`content`?F(t=>t+e.delta):e.type===`tool`&&e.status===`running`&&K(`调用 ${e.name}`,`tool`);if(!c){K(`模型没有提交补写结果,故事集保持不变`,`error`),h(`模型没有提交补写结果`,`error`);return}let u=U.current;if(u){let e=re(u),t=await g(u.id,{check:e,status:`decomposed`});G(t)}K(`补写完成,已按规则重算覆盖率;建议再跑一次体检`,`done`),z(`check`),h(`补写完成,建议再跑一次体检`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);i.signal.aborted?K(`已中断:已经写入的改动保留`,`info`):(L(t),K(`补写失败:${t}`,`error`))}finally{j(null),W.current=null}},[Q,G,K,Y,Tt]),$=(0,w.useCallback)(async e=>{let t=U.current;if(t)try{await X({stories:e},t)}catch(e){h(`保存失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[X]),kt=(0,w.useCallback)((e,t)=>{let n=U.current;if(!n)return;let r=n.stories.map((n,r)=>r===e?{...t,id:n.id}:n);$(r)},[$]),At=(0,w.useCallback)(e=>{let t=U.current;t&&$(t.stories.filter((t,n)=>n!==e))},[$]),jt=(0,w.useCallback)((e,t)=>{let n=U.current;if(!n)return;let r=e+t;if(r<0||r>=n.stories.length)return;let i=[...n.stories],a=i[e],o=i[r];a&&o&&(i[e]=o,i[r]=a,$(i))},[$]),Mt=(0,w.useCallback)((e,t)=>{let n=U.current;if(!n?.check)return;let r={...n,check:{...n.check,gaps:n.check.gaps.map(n=>n.id===e?{...n,selected:t}:n)}};G(r),Ct()},[G,Ct]),Nt=(0,w.useCallback)(e=>{let t=U.current;if(!t?.check)return;let n={...t,check:{...t.check,gaps:t.check.gaps.map(t=>({...t,selected:e}))}};G(n),Ct()},[G,Ct]),Pt=(0,w.useCallback)(e=>{let t=U.current,n=e.trim();t&&n&&n!==t.title&&X({title:n},t).catch(()=>void 0)},[X]),Ft=(0,w.useCallback)(async()=>{let e=U.current;if(e)try{await he(e.id);let t=v.filter(t=>t.id!==e.id);y(t),q(t[0]??null),qe(`list`),h(`已删除分析记录`,`success`)}catch(e){h(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}finally{it(!1)}},[v,q]),It=(0,w.useCallback)(()=>{let e=U.current;if(!e)return;let t=new Blob([ee(e)],{type:`text/markdown;charset=utf-8`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=ie(e),document.body.appendChild(r),r.click(),r.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),1e3),h(`已导出 Markdown`,`success`)},[]),Lt=(0,w.useCallback)(()=>{W.current?.abort()},[]);if(!e.ready)return(0,O.jsx)(Ce,{label:`正在读取插件开关`});if(!e.on)return(0,O.jsx)(Se,{children:r(`reqAnalysis`)});if(t===null)return(0,O.jsx)(Ce,{label:`正在连接需求分析服务`});if(!t)return(0,O.jsx)(Se,{children:"需求分析需要本地服务,当前未就绪:确认服务已升级到最新版本并重启(`lantern` 一体服务或 `npm run dev`),静态部署的页面用不了。"});let Rt=b?.outline.filter(e=>bt.has(e.id)).length??0,zt=b?.check?.gaps??[],Bt=b?.progress,Vt=(0,O.jsx)(u,{options:ut,value:T,onChange:e=>{E(e),e&&wt(e)},triggerTitle:T||`选择来源需求文档…`,ariaLabel:`选择来源需求文档`,searchable:!0,searchPlaceholder:`搜索文件名或路径…`,flat:!0}),Ht=(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3`,children:[(0,O.jsxs)(`section`,{className:`shrink-0 rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,O.jsxs)(`div`,{className:`min-w-[240px] flex-1`,children:[(0,O.jsx)(`p`,{className:B,children:`新建分析`}),(0,O.jsx)(`div`,{className:`mt-1.5 max-w-[440px]`,children:Vt})]}),(0,O.jsxs)(`span`,{className:`pb-1 text-[11px] text-stone-400`,children:[`共 `,v.length,` 份分析`]})]}),(0,O.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-stone-400`,children:`选一份需求文档就新建分析(同一份来源再选一次会回到已有记录),随后进「用户故事」拆解。支持 Word(.docx)/ Excel(.xlsx / .xls)/ Markdown / txt / csv,读取时抽成文本,不改原文件。`}),De?(0,O.jsxs)(`p`,{className:`mt-2 text-xs leading-relaxed text-amber-700`,children:[`读不到需求文档库:`,De,(0,O.jsx)(`br`,{}),`请先启用「需求文档库」插件,或确认 `,ce,` 之外的内容目录没有被移动。`]}):null]}),I?(0,O.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:[(0,O.jsx)(`span`,{className:`break-all`,children:I}),(0,O.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>L(``),children:`✕`})]}):null,(0,O.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,O.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-3 py-2`,children:[(0,O.jsxs)(`div`,{className:`inline-flex rounded-lg border border-stone-200 bg-stone-50 p-0.5`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>vt(`doc`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${Je===`doc`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按需求说明书`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>vt(`story`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${Je===`story`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按用户故事`})]}),Je===`story`?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`label`,{className:`relative block`,children:[(0,O.jsx)(S,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,O.jsx)(`input`,{value:V,onChange:e=>Xe(e.target.value),placeholder:`搜索编号 / 标题 / 角色…`,className:`h-8 w-52 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-xs text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,O.jsxs)(`span`,{className:`text-[11px] text-stone-400`,children:[pt,` 个故事`,H?` · 已选 ${H.ids.length}`:``]}),(0,O.jsx)(`button`,{type:`button`,disabled:!H,onClick:()=>{if(!H)return;let e=new URLSearchParams({plugin:`caseGen`,reqDoc:H.docId,stories:H.ids.join(`,`)});window.location.href=`/workbench/?${e.toString()}`},className:`${ze} ml-auto h-8 text-xs`,children:`用选中故事生成用例`})]}):(0,O.jsxs)(`span`,{className:`ml-auto text-[11px] text-stone-400`,children:[v.length,` 份分析 · `,pt,` 个故事`]})]}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:Je===`doc`?v.length?(0,O.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:v.map(e=>{let t=pe[e.status];return(0,O.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3 transition-colors hover:bg-stone-50`,children:[(0,O.jsx)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center text-left`,onClick:()=>J(e,`stories`),children:(0,O.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:e.title}),(0,O.jsx)(x,{tone:t.tone,children:t.label})]}),(0,O.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-stone-400`,children:[(0,O.jsx)(`span`,{className:`truncate`,children:e.sourcePath||`(未指定来源)`}),(0,O.jsxs)(`span`,{children:[`用户故事 `,e.stories.length]}),(0,O.jsxs)(`span`,{children:[`需求条目 `,e.outline.length]}),(0,O.jsx)(`span`,{children:We(e.updatedAt)})]})]})}),(0,O.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 shrink-0 items-center gap-1 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-700 transition-colors hover:border-[#3370ff] hover:text-[#3370ff]`,onClick:()=>J(e,`stories`),children:[`用户故事`,(0,O.jsx)(S,{name:`chevronRight`,size:13})]}),(0,O.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-red-50 hover:text-red-600`,onClick:()=>{q(e),it(!0)},children:(0,O.jsx)(S,{name:`trash`,size:14})})]},e.id)})}):(0,O.jsx)(C,{icon:`file`,title:`还没有分析记录`,hint:`上面选一份需求文档,系统会新建一份分析并进入用户故事拆解。`}):mt.length?(0,O.jsx)(`div`,{className:`divide-y divide-stone-100`,children:mt.map(({doc:e,rows:t})=>{let n=Qe.includes(e.id),r=t.map(e=>e.story.id),i=H?.docId===e.id&&r.length>0&&r.every(e=>ht.has(e));return(0,O.jsxs)(`section`,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/70 px-3 py-1.5`,children:[(0,O.jsx)(`input`,{type:`checkbox`,"aria-label":`选中 ${e.title} 的全部故事`,checked:i,onChange:()=>_t(e.id,r)}),(0,O.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>$e(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id]),children:[(0,O.jsx)(S,{name:n?`chevronRight`:`chevronDown`,size:13,className:`shrink-0 text-stone-400`}),(0,O.jsx)(`span`,{className:`truncate text-xs font-medium text-stone-700`,children:e.title}),(0,O.jsxs)(`span`,{className:`shrink-0 text-[11px] text-stone-400`,children:[t.length,` 个故事 · `,We(e.updatedAt)]})]}),(0,O.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] text-[#3370ff] hover:underline`,onClick:()=>J(e,`stories`),children:`打开拆解`})]}),n?null:(0,O.jsx)(`ul`,{className:`divide-y divide-stone-50`,children:t.map(({story:t})=>(0,O.jsxs)(`li`,{className:`flex items-start gap-2 px-4 py-2 transition-colors hover:bg-stone-50`,children:[(0,O.jsx)(`input`,{type:`checkbox`,className:`mt-1`,"aria-label":`选中 ${t.id}`,checked:ht.has(t.id)&&H?.docId===e.id,onChange:()=>gt(e.id,t.id)}),(0,O.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left`,onClick:()=>dt(e,t.id),children:[(0,O.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-stone-400`,children:t.id}),(0,O.jsx)(`span`,{className:`truncate text-sm text-stone-800`,children:t.title})]}),(0,O.jsxs)(`span`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2.5 gap-y-0.5 text-[11px] text-stone-400`,children:[t.role?(0,O.jsxs)(`span`,{children:[`角色:`,t.role]}):null,(0,O.jsxs)(`span`,{children:[`优先级 `,t.priority]}),(0,O.jsxs)(`span`,{children:[`验收 `,t.acceptance.length]}),(0,O.jsxs)(`span`,{children:[`异常 `,t.exceptions.length]}),(0,O.jsxs)(`span`,{children:[`维度 `,t.dimensions.length]})]})]})]},`${e.id}-${t.id}`))})]},e.id)})}):(0,O.jsx)(C,{icon:`file`,title:V?`没有匹配的用户故事`:`还没有用户故事`,hint:V?`换个编号、标题或角色再试。`:`先按「需求说明书」选中一份文档拆解,故事会自动出现在这里。`})})]})]});return(0,O.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col`,children:[Ke===`list`?Ht:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`mb-2 flex shrink-0 items-center gap-2`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 items-center gap-1 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-600 transition-colors hover:border-stone-300 hover:text-stone-800`,onClick:()=>{E(``),L(``),qe(`list`)},children:[(0,O.jsx)(S,{name:`arrowLeft`,size:14}),`返回列表`]}),(0,O.jsx)(`span`,{className:`min-w-0 truncate text-xs text-stone-400`,children:b?.title?`用户故事 · ${b.title}`:`用户故事`})]}),(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-4`,children:[(0,O.jsxs)(`aside`,{className:`flex w-[272px] shrink-0 flex-col gap-3 overflow-y-auto pb-1`,children:[(0,O.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-3`,children:[(0,O.jsx)(`p`,{className:B,children:`来源需求文档`}),(0,O.jsx)(`div`,{className:`mt-2`,children:Vt}),(0,O.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-stone-400`,children:`支持 Word(.docx)/ Excel(.xlsx / .xls)/ Markdown / txt / csv,读取时抽成文本,不改原文件。`}),b?(0,O.jsxs)(`div`,{className:`mt-2 space-y-1 text-[11px] text-stone-400`,children:[(0,O.jsxs)(`p`,{className:`break-all`,children:[`当前:`,b.sourcePath||`(未指定)`]}),yt?(0,O.jsx)(`p`,{className:`rounded bg-amber-50 px-2 py-1 text-amber-700`,children:`源文档已更新,建议重新拆解`}):null]}):null]}),(0,O.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(`p`,{className:B,children:`分析记录`}),(0,O.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:v.length})]}),v.length?(0,O.jsx)(`ul`,{className:`mt-2 space-y-1`,children:v.map(e=>{let t=e.id===ue,n=pe[e.status];return(0,O.jsx)(`li`,{children:(0,O.jsx)(`button`,{type:`button`,className:`flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors ${t?`bg-[#eef3ff]`:`hover:bg-stone-50`}`,onClick:()=>q(e),children:(0,O.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`span`,{className:`block truncate text-xs font-medium text-stone-700`,children:e.title}),(0,O.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 text-[11px] text-stone-400`,children:[(0,O.jsx)(x,{tone:n.tone,children:n.label}),(0,O.jsxs)(`span`,{children:[e.stories.length,` 个故事`]})]})]})})},e.id)})}):(0,O.jsx)(`p`,{className:`mt-2 text-xs text-stone-400`,children:`还没有分析记录,选一份来源文档开始。`})]}),(0,O.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-3`,children:[(0,O.jsx)(`p`,{className:B,children:`提示词`}),(0,O.jsx)(`p`,{className:`mt-1 break-all text-xs text-stone-500`,children:te}),(0,O.jsx)(`p`,{className:`mt-1 text-[11px] ${xt?`text-emerald-600`:`text-amber-700`}`,children:xt?`拆解 / 体检 / 补写三段已就绪`:`没有读到「## 拆解」段落:去「提示词管理」补上,或关闭再打开插件重新生成`}),(0,O.jsx)(`p`,{className:`mt-1 text-[11px] ${Z?`text-stone-400`:`text-amber-700`}`,children:Z?`模型:${D?.model}`:`还没配置模型`})]}),(0,O.jsxs)(`section`,{className:`space-y-2 rounded-xl border border-stone-200 bg-white p-3`,children:[(0,O.jsx)(`p`,{className:B,children:`动作`}),(0,O.jsx)(`button`,{type:`button`,className:`${ze} w-full`,disabled:!b||!!A||!b.sourcePath,onClick:()=>{b?.stories.length?ot(!0):Et()},children:A===`decompose`?`拆解中…`:b?.stories.length?`重新拆解`:`开始拆解`}),(0,O.jsx)(`button`,{type:`button`,className:`${Be} w-full`,disabled:!b||!!A||!b.stories.length,onClick:()=>void Dt(),children:A===`audit`?`体检中…`:`体检`}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,className:`${Be} flex-1`,disabled:!b,onClick:It,children:`导出 Markdown`}),A?(0,O.jsx)(`button`,{type:`button`,className:`${Be} flex-1`,onClick:Lt,children:`中断`}):null]}),b?(0,O.jsx)(`button`,{type:`button`,className:`h-8 w-full rounded-md text-xs text-stone-400 transition-colors hover:bg-red-50 hover:text-red-500`,onClick:()=>it(!0),children:`删除这份分析`}):null]}),(0,O.jsxs)(`section`,{className:`min-h-[120px] rounded-xl border border-stone-200 bg-white p-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(`p`,{className:B,children:`活动日志`}),M.length?(0,O.jsx)(`button`,{type:`button`,className:`text-[11px] text-stone-400 hover:text-stone-600`,onClick:()=>N([]),children:`清空`}):null]}),(0,O.jsx)(`div`,{ref:ct,className:`mt-2 max-h-[240px] space-y-1 overflow-y-auto pr-1`,children:M.length?M.map(e=>(0,O.jsxs)(`p`,{className:`flex gap-1.5 text-[11px] leading-relaxed`,children:[(0,O.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${e.kind===`error`?`bg-red-500`:e.kind===`done`?`bg-emerald-500`:e.kind===`tool`?`bg-[#3370ff]`:`bg-stone-300`}`,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:e.kind===`error`?`text-red-600`:`text-stone-500`,children:e.text})]},e.id)):(0,O.jsx)(`p`,{className:`text-[11px] text-stone-400`,children:`拆解 / 体检的过程会记在这里。`})})]})]}),(0,O.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[I?(0,O.jsxs)(`div`,{className:`mb-2 flex items-start justify-between gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:[(0,O.jsx)(`span`,{className:`break-all`,children:I}),(0,O.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>L(``),children:`✕`})]}):null,b?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`header`,{className:`shrink-0 rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsx)(`input`,{className:`min-w-0 flex-1 rounded-md border border-transparent bg-transparent px-1 py-0.5 text-base font-semibold text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`,defaultValue:b.title,"aria-label":`分析标题`,onBlur:e=>Pt(e.target.value)},b.id),(0,O.jsx)(x,{tone:pe[b.status].tone,children:pe[b.status].label}),A?(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-stone-500`,children:[(0,O.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`}),Bt?.message||(A===`decompose`?`拆解中`:A===`audit`?`体检中`:`补写中`)]}):null]}),(0,O.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-5 gap-y-1 text-xs text-stone-400`,children:[(0,O.jsxs)(`span`,{children:[`故事`,` `,(0,O.jsx)(`span`,{className:`font-medium text-stone-600`,children:b.stories.length})]}),(0,O.jsxs)(`span`,{children:[`需求条目`,` `,(0,O.jsxs)(`span`,{className:`font-medium text-stone-600`,children:[Rt,`/`,b.outline.length]}),` `,`覆盖`]}),(0,O.jsxs)(`span`,{children:[`缺口 `,(0,O.jsx)(`span`,{className:`font-medium text-stone-600`,children:zt.length}),St?` · 已选 ${St}`:``]}),b.check?(0,O.jsxs)(`span`,{children:[`覆盖率`,` `,(0,O.jsx)(`span`,{className:`font-medium text-stone-600`,children:b.check.coverage.total?`${Math.round(b.check.coverage.rate*100)}%`:`—`})]}):null,(0,O.jsxs)(`span`,{className:`truncate`,children:[`来源:`,b.sourcePath]})]}),(0,O.jsx)(`div`,{className:`mt-3 flex items-center gap-1 border-b border-stone-100`,children:[{id:`stories`,label:`用户故事 ${b.stories.length}`},{id:`check`,label:`体检结果 ${zt.length}`},{id:`outline`,label:`需求条目 ${b.outline.length}`}].map(e=>(0,O.jsx)(`button`,{type:`button`,className:`-mb-px border-b-2 px-3 py-1.5 text-xs transition-colors ${R===e.id?`border-[#3370ff] font-medium text-[#3370ff]`:`border-transparent text-stone-500 hover:text-stone-700`}`,onClick:()=>z(e.id),children:e.label},e.id))})]}),(0,O.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 overflow-y-auto pr-1`,children:[R===`stories`?b.stories.length?(0,O.jsx)(`ul`,{className:`space-y-2`,children:b.stories.map((e,t)=>(0,O.jsx)(Fe,{story:e,index:t,total:b.stories.length,gaps:zt.filter(t=>t.storyId===e.id),busy:!!A,onSave:e=>kt(t,e),onDelete:()=>At(t),onMove:e=>jt(t,e),domId:e.id?`req-story-${e.id}`:void 0},`${e.id}-${t}`))}):(0,O.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,O.jsx)(C,{icon:`file`,title:`还没有用户故事`,hint:`点左侧「开始拆解」,会先抽需求条目再拆故事。`})}):null,R===`check`?(0,O.jsx)(Ne,{check:b.check,stories:b.stories,busy:!!A,onToggleGap:Mt,onToggleAll:Nt,onFix:()=>void Ot(),onAudit:()=>void Dt()}):null,R===`outline`?b.outline.length?(0,O.jsx)(`ul`,{className:`space-y-2`,children:b.outline.map(e=>{let t=bt.has(e.id);return(0,O.jsx)(`li`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-2.5`,children:(0,O.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,O.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${t?`bg-emerald-500`:`bg-amber-400`}`,"aria-hidden":`true`}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`p`,{className:`text-sm text-stone-800`,children:[(0,O.jsx)(`span`,{className:`mr-1.5 rounded bg-stone-100 px-1.5 py-0.5 font-mono text-[11px] text-stone-500`,children:e.id}),e.title]}),e.quote?(0,O.jsx)(`p`,{className:`mt-1 border-l-2 border-stone-200 pl-2 text-xs leading-relaxed text-stone-400`,children:e.quote}):null]}),(0,O.jsx)(`span`,{className:`shrink-0 text-[11px] ${t?`text-emerald-600`:`text-amber-600`}`,children:t?`已覆盖`:`未覆盖`})]})},e.id)})}):(0,O.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,O.jsx)(C,{icon:`file`,title:`还没有需求条目`,hint:`拆解时模型会先抽条目,覆盖率按条目统计。`})}):null]}),P?(0,O.jsxs)(`details`,{className:`mt-2 shrink-0 rounded-xl border border-stone-200 bg-white px-3 py-2`,children:[(0,O.jsx)(`summary`,{className:`cursor-pointer text-xs text-stone-500`,children:`模型说明(本轮)`}),(0,O.jsx)(`pre`,{className:`mt-1 max-h-[180px] overflow-y-auto whitespace-pre-wrap break-words text-[11px] leading-relaxed text-stone-600`,children:P})]}):null]}):(0,O.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,O.jsx)(C,{icon:`file`,title:`还没有选来源`,hint:`左侧选一份「需求文档库」里的 Word / Excel / Markdown / txt,系统会新建一份分析。`})})]})]})]}),(0,O.jsx)(l,{open:rt,title:`删除分析记录`,message:`确认删除「${b?.title??``}」?故事、需求条目与体检报告都会一起删掉,来源需求文档不受影响。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>it(!1),onConfirm:()=>void Ft()}),(0,O.jsx)(l,{open:at,title:`重新拆解`,message:`重新拆解会用模型结果替换当前 ${b?.stories.length??0} 个用户故事,旧体检报告与需求条目也会一起清掉,编号从 US-001 重新开始。`,confirmLabel:`重新拆解`,onClose:()=>ot(!1),onConfirm:()=>void Et()})]})}export{Ke as default};
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.BUPzGl9f.js";import{i as r,o as i,s as a}from"./plugins.C2BMfzv1.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./ConfirmDialog.BZzZWDci.js";import{n as c,t as ee}from"./DocsPager.DJY4foYL.js";import{a as te,c as ne,f as l,h as u,i as re,l as ie,m as ae,n as oe,o as d,p as se,r as ce,s as f,t as le,u as ue}from"./project-docs.Cd2gKPKh.js";import{n as de}from"./doc-roots.DAJP9Svr.js";import{t as fe}from"./useListAnim.BoerpmsB.js";import{t as p}from"./NamePromptDialog.Wa9O530a.js";var m=e(t(),1),h=o(),pe=5;function g({className:e=`w-4 h-4`,open:t=!1}){return(0,h.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,h.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,h.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function _({className:e=`w-3 h-3`}){return(0,h.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,h.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,h.jsx)(`path`,{d:`m15 5 4 4`})]})}function v({className:e=`w-3 h-3`}){return(0,h.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,h.jsx)(`path`,{d:`M3 6h18`}),(0,h.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,h.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,h.jsx)(`path`,{d:`M10 11v6`}),(0,h.jsx)(`path`,{d:`M14 11v6`})]})}function y({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,h.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,h.jsx)(g,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,h.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,h.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,h.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,h.jsx)(y,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function me(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function b(){let[e,t]=(0,m.useState)(()=>r(`requirements`)),[o,b]=(0,m.useState)(!1),[x,he]=(0,m.useState)(null),[S,ge]=(0,m.useState)([]),[_e,ve]=(0,m.useState)(0),[C,w]=(0,m.useState)(`.`),[T,E]=(0,m.useState)([]),[ye,D]=(0,m.useState)({}),[O,be]=(0,m.useState)(!0),[k,A]=(0,m.useState)(null),[j,M]=(0,m.useState)(!1),[N,P]=(0,m.useState)(null),[F,I]=(0,m.useState)(!1),[L,R]=(0,m.useState)(null),[z,B]=(0,m.useState)(null),[xe,V]=(0,m.useState)(1),[H,Se]=c(pe),[Ce,U]=(0,m.useState)(null),W=(0,m.useRef)(null),{cls:we,play:G}=fe(),K=(0,m.useCallback)(async()=>{let e=await re(`requirements`);ge(e.tree),ve(e.totalFiles)},[]),q=(0,m.useCallback)(async(e=C)=>{A(null);try{let[t]=await Promise.all([f(`requirements`,e),K()]);E(t.entries),w(t.path)}catch(e){A(e instanceof Error?e.message:String(e))}},[C,K]);(0,m.useEffect)(()=>{let e=i(e=>t(!!e.requirements));return n().then(()=>{t(r(`requirements`)),b(!0)}),e},[]),(0,m.useEffect)(()=>{o&&e&&(async()=>{let e=await ce(`requirements`);if(he(e),e)try{let[e]=await Promise.all([f(`requirements`,`.`),K()]);E(e.entries),w(e.path)}catch(e){A(e instanceof Error?e.message:String(e))}})()},[o,e,K]);function Te(){be(e=>!e),D({})}async function J(e){G(),w(e),V(1),P(null),U(null),A(null);try{let t=await f(`requirements`,e);E(t.entries)}catch(e){A(e instanceof Error?e.message:String(e))}}async function Ee(e){I(!1),M(!0),A(null);try{await ne(`requirements`,C,e),await q(C)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}async function De(e){if(e.type===`file`){M(!0),A(null);try{await ie(`requirements`,e.path)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}async function Oe(e){if(e?.length){M(!0),A(null);try{for(let t of Array.from(e))await u(`requirements`,C,t);await q(C)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1),W.current&&(W.current.value=``)}}}function ke(e){let t=te(S,e.path),n=t?.fileCount??0,r=t?le(t):0;R({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function Ae(e){R({name:e.name,path:e.path,isDir:!1})}function Y(e,t){B({...e,isDir:t})}async function je(){let e=L;if(e&&(R(null),!e.blocked)){M(!0),A(null);try{await oe(`requirements`,e.path),N&&d(N.path,e.path)&&P(null);let t=d(C,e.path)?ue(e.path):C;await q(t)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}async function Me(e){let t=z;if(t&&(B(null),e!==t.name)){M(!0),A(null);try{let n=await ae(`requirements`,t.path,e);await q(se(C,t.path,n))}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}let Ne=(()=>{if(!L)return``;if(!L.isDir)return`删除文件「${L.name}」?将移入系统废纸篓,可随时找回。`;if(L.blocked){let e=[];return L.files&&e.push(`${L.files} 个文件`),L.dirs&&e.push(`${L.dirs} 个子文件夹`),`文件夹「${L.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${L.name}」?将移入系统废纸篓。`})();async function Pe(e){if(e.type!==`file`)return;let t=e.name.toLowerCase();if(!t.endsWith(`.md`)&&!t.endsWith(`.txt`))A(`仅 .md / .txt 支持就地预览;docx 请双击用本机程序打开。`);else{M(!0),A(null);try{let t=await l(`requirements`,e.path);P({path:t.path,content:t.content})}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}if(!o)return(0,h.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,h.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,h.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:a(`requirements`)});if(x===null)return(0,h.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,h.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!x)return(0,h.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`需求文档库需要本地文档服务,当前未就绪。`});let X=T.filter(e=>e.type===`file`),Z=T.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/H)),$=Math.min(xe,Q),Fe=X.slice(($-1)*H,$*H);function Ie(e){G(),Se(e),V(1)}return(0,h.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,h.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,h.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>I(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,h.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,h.jsx)(`div`,{className:`group flex items-center rounded-md ${C===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{J(`.`),Te()},"aria-expanded":O,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${C===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,h.jsx)(g,{open:O,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部需求`}),(0,h.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,_e,`)`]})]})}),(0,h.jsx)(`div`,{className:`tw-collapse ${O?`is-open`:``}`,children:(0,h.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:S.map(e=>(0,h.jsx)(y,{node:e,depth:0,activePath:C,expanded:ye,globalOpen:O,onToggle:e=>D(t=>({...t,[e]:!(t[e]??O)})),onSelect:e=>void J(e)},e.path))})})]})]}),(0,h.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,h.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,h.jsx)(`span`,{className:`text-stone-400`,children:de(`requirements`)}),C===`.`?``:C]}),(0,h.jsx)(`input`,{ref:W,type:`file`,multiple:!0,accept:`.md,.txt,.docx,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document`,className:`hidden`,onChange:e=>void Oe(e.target.files)}),(0,h.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>W.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),k?(0,h.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:k}):null,(0,h.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,h.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,h.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void J(e.path),children:[(0,h.jsx)(g,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,h.jsx)(_,{className:`w-3.5 h-3.5`})}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>ke({name:e.name,path:e.path}),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,h.jsx)(v,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,h.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加需求文档(.md / .txt / .docx)`}):(0,h.jsx)(`ul`,{className:`${we}space-y-1`,children:Fe.map(e=>{let t=Ce===e.path;return(0,h.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors ${t?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,onClick:()=>{U(e.path),Pe(e)},onDoubleClick:t=>{t.preventDefault(),De(e)},children:[(0,h.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,h.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:me(e.size)})]}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,h.jsx)(_,{className:`w-3.5 h-3.5`})}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>Ae(e),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,h.jsx)(v,{className:`w-3.5 h-3.5`})})]},e.path)})})]}),N?(0,h.jsxs)(`div`,{className:`rounded-lg border border-stone-200 overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-3 py-2 bg-stone-50 border-b border-stone-200 flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs text-stone-500 truncate`,children:N.path}),(0,h.jsx)(`button`,{type:`button`,className:`text-xs text-stone-500 hover:text-stone-800`,onClick:()=>P(null),children:`关闭预览`})]}),(0,h.jsx)(`pre`,{className:`max-h-80 overflow-auto p-4 text-xs leading-5 text-stone-700 whitespace-pre-wrap bg-white`,children:N.content})]}):null]}),X.length>0?(0,h.jsx)(ee,{page:$,totalPages:Q,pageSize:H,busy:j,onPage:e=>{G(),V(e)},onPageSize:Ie}):null]}),(0,h.jsx)(p,{open:F,title:`新建文件夹`,onClose:()=>I(!1),onConfirm:e=>void Ee(e)}),(0,h.jsx)(p,{open:z!=null,title:z?.isDir?`重命名文件夹`:`重命名文件`,label:z?.isDir?`文件夹名称`:`文件名称`,initialValue:z?.name??``,lockExtension:z!=null&&!z.isDir,confirmLabel:`保存`,onClose:()=>B(null),onConfirm:e=>void Me(e)}),(0,h.jsx)(s,{open:L!=null,title:L?.blocked?`无法删除文件夹`:L?.isDir?`删除文件夹`:`删除需求文件`,message:Ne,confirmLabel:L?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!L?.blocked,hideCancel:!!L?.blocked,onClose:()=>R(null),onConfirm:()=>void je()})]})}export{b as default};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.Cq_F8I0l.js";import{i as r,o as i,s as a}from"./plugins.CKkgnq4r.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./ConfirmDialog.CsMwWevK.js";import{n as c,t as ee}from"./DocsPager.EPT5-oEx.js";import{a as te,c as ne,f as l,h as u,i as re,l as ie,m as ae,n as oe,o as d,p as se,r as ce,s as f,t as le,u as ue}from"./project-docs.Cd2gKPKh.js";import{n as de}from"./doc-roots.DAJP9Svr.js";import{t as fe}from"./useListAnim.BoerpmsB.js";import{t as p}from"./NamePromptDialog.CS1pTTVl.js";var m=e(t(),1),h=o(),pe=5;function g({className:e=`w-4 h-4`,open:t=!1}){return(0,h.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,h.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,h.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function _({className:e=`w-3 h-3`}){return(0,h.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,h.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,h.jsx)(`path`,{d:`m15 5 4 4`})]})}function v({className:e=`w-3 h-3`}){return(0,h.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,h.jsx)(`path`,{d:`M3 6h18`}),(0,h.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,h.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,h.jsx)(`path`,{d:`M10 11v6`}),(0,h.jsx)(`path`,{d:`M14 11v6`})]})}function y({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,h.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,h.jsx)(g,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,h.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,h.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,h.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,h.jsx)(y,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function me(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function b(){let[e,t]=(0,m.useState)(()=>r(`requirements`)),[o,b]=(0,m.useState)(!1),[x,he]=(0,m.useState)(null),[S,ge]=(0,m.useState)([]),[_e,ve]=(0,m.useState)(0),[C,w]=(0,m.useState)(`.`),[T,E]=(0,m.useState)([]),[ye,D]=(0,m.useState)({}),[O,be]=(0,m.useState)(!0),[k,A]=(0,m.useState)(null),[j,M]=(0,m.useState)(!1),[N,P]=(0,m.useState)(null),[F,I]=(0,m.useState)(!1),[L,R]=(0,m.useState)(null),[z,B]=(0,m.useState)(null),[xe,V]=(0,m.useState)(1),[H,Se]=c(pe),[Ce,U]=(0,m.useState)(null),W=(0,m.useRef)(null),{cls:we,play:G}=fe(),K=(0,m.useCallback)(async()=>{let e=await re(`requirements`);ge(e.tree),ve(e.totalFiles)},[]),q=(0,m.useCallback)(async(e=C)=>{A(null);try{let[t]=await Promise.all([f(`requirements`,e),K()]);E(t.entries),w(t.path)}catch(e){A(e instanceof Error?e.message:String(e))}},[C,K]);(0,m.useEffect)(()=>{let e=i(e=>t(!!e.requirements));return n().then(()=>{t(r(`requirements`)),b(!0)}),e},[]),(0,m.useEffect)(()=>{o&&e&&(async()=>{let e=await ce(`requirements`);if(he(e),e)try{let[e]=await Promise.all([f(`requirements`,`.`),K()]);E(e.entries),w(e.path)}catch(e){A(e instanceof Error?e.message:String(e))}})()},[o,e,K]);function Te(){be(e=>!e),D({})}async function J(e){G(),w(e),V(1),P(null),U(null),A(null);try{let t=await f(`requirements`,e);E(t.entries)}catch(e){A(e instanceof Error?e.message:String(e))}}async function Ee(e){I(!1),M(!0),A(null);try{await ne(`requirements`,C,e),await q(C)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}async function De(e){if(e.type===`file`){M(!0),A(null);try{await ie(`requirements`,e.path)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}async function Oe(e){if(e?.length){M(!0),A(null);try{for(let t of Array.from(e))await u(`requirements`,C,t);await q(C)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1),W.current&&(W.current.value=``)}}}function ke(e){let t=te(S,e.path),n=t?.fileCount??0,r=t?le(t):0;R({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function Ae(e){R({name:e.name,path:e.path,isDir:!1})}function Y(e,t){B({...e,isDir:t})}async function je(){let e=L;if(e&&(R(null),!e.blocked)){M(!0),A(null);try{await oe(`requirements`,e.path),N&&d(N.path,e.path)&&P(null);let t=d(C,e.path)?ue(e.path):C;await q(t)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}async function Me(e){let t=z;if(t&&(B(null),e!==t.name)){M(!0),A(null);try{let n=await ae(`requirements`,t.path,e);await q(se(C,t.path,n))}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}let Ne=(()=>{if(!L)return``;if(!L.isDir)return`删除文件「${L.name}」?将移入系统废纸篓,可随时找回。`;if(L.blocked){let e=[];return L.files&&e.push(`${L.files} 个文件`),L.dirs&&e.push(`${L.dirs} 个子文件夹`),`文件夹「${L.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${L.name}」?将移入系统废纸篓。`})();async function Pe(e){if(e.type!==`file`)return;let t=e.name.toLowerCase();if(!t.endsWith(`.md`)&&!t.endsWith(`.txt`))A(`仅 .md / .txt 支持就地预览;docx 请双击用本机程序打开。`);else{M(!0),A(null);try{let t=await l(`requirements`,e.path);P({path:t.path,content:t.content})}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}if(!o)return(0,h.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,h.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,h.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:a(`requirements`)});if(x===null)return(0,h.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,h.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!x)return(0,h.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`需求文档库需要本地文档服务,当前未就绪。`});let X=T.filter(e=>e.type===`file`),Z=T.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/H)),$=Math.min(xe,Q),Fe=X.slice(($-1)*H,$*H);function Ie(e){G(),Se(e),V(1)}return(0,h.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,h.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,h.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>I(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,h.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,h.jsx)(`div`,{className:`group flex items-center rounded-md ${C===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{J(`.`),Te()},"aria-expanded":O,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${C===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,h.jsx)(g,{open:O,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部需求`}),(0,h.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,_e,`)`]})]})}),(0,h.jsx)(`div`,{className:`tw-collapse ${O?`is-open`:``}`,children:(0,h.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:S.map(e=>(0,h.jsx)(y,{node:e,depth:0,activePath:C,expanded:ye,globalOpen:O,onToggle:e=>D(t=>({...t,[e]:!(t[e]??O)})),onSelect:e=>void J(e)},e.path))})})]})]}),(0,h.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,h.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,h.jsx)(`span`,{className:`text-stone-400`,children:de(`requirements`)}),C===`.`?``:C]}),(0,h.jsx)(`input`,{ref:W,type:`file`,multiple:!0,accept:`.md,.txt,.docx,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document`,className:`hidden`,onChange:e=>void Oe(e.target.files)}),(0,h.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>W.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),k?(0,h.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:k}):null,(0,h.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,h.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,h.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void J(e.path),children:[(0,h.jsx)(g,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,h.jsx)(_,{className:`w-3.5 h-3.5`})}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>ke({name:e.name,path:e.path}),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,h.jsx)(v,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,h.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加需求文档(.md / .txt / .docx)`}):(0,h.jsx)(`ul`,{className:`${we}space-y-1`,children:Fe.map(e=>{let t=Ce===e.path;return(0,h.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors ${t?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,onClick:()=>{U(e.path),Pe(e)},onDoubleClick:t=>{t.preventDefault(),De(e)},children:[(0,h.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,h.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:me(e.size)})]}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,h.jsx)(_,{className:`w-3.5 h-3.5`})}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>Ae(e),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,h.jsx)(v,{className:`w-3.5 h-3.5`})})]},e.path)})})]}),N?(0,h.jsxs)(`div`,{className:`rounded-lg border border-stone-200 overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-3 py-2 bg-stone-50 border-b border-stone-200 flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs text-stone-500 truncate`,children:N.path}),(0,h.jsx)(`button`,{type:`button`,className:`text-xs text-stone-500 hover:text-stone-800`,onClick:()=>P(null),children:`关闭预览`})]}),(0,h.jsx)(`pre`,{className:`max-h-80 overflow-auto p-4 text-xs leading-5 text-stone-700 whitespace-pre-wrap bg-white`,children:N.content})]}):null]}),X.length>0?(0,h.jsx)(ee,{page:$,totalPages:Q,pageSize:H,busy:j,onPage:e=>{G(),V(e)},onPageSize:Ie}):null]}),(0,h.jsx)(p,{open:F,title:`新建文件夹`,onClose:()=>I(!1),onConfirm:e=>void Ee(e)}),(0,h.jsx)(p,{open:z!=null,title:z?.isDir?`重命名文件夹`:`重命名文件`,label:z?.isDir?`文件夹名称`:`文件名称`,initialValue:z?.name??``,lockExtension:z!=null&&!z.isDir,confirmLabel:`保存`,onClose:()=>B(null),onConfirm:e=>void Me(e)}),(0,h.jsx)(s,{open:L!=null,title:L?.blocked?`无法删除文件夹`:L?.isDir?`删除文件夹`:`删除需求文件`,message:Ne,confirmLabel:L?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!L?.blocked,hideCancel:!!L?.blocked,onClose:()=>R(null),onConfirm:()=>void je()})]})}export{b as default};
@@ -0,0 +1 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{G as n,J as r,K as i,p as a,q as o,r as s,t as c,u as l}from"./app-config.Cq_F8I0l.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./OverflowHint.D6v4Uj2N.js";import{t as f}from"./SelectDropdown.B3-XpBpn.js";n.map(e=>({value:e.id,label:e.label,casesFolder:e.casesFolder,templateFolder:e.templateFolder}));function p(){let e=s().caseTypes;return e?.length?e.map(e=>({...e})):n.map(e=>({...e}))}function m(e){let t=p();return t.find(t=>t.id===e)??t[0]??n[0]}function h(e){let t=r(e);return l({caseTypes:t}),c(),t}function g(e){let t=e.trim();if(!t)throw Error(`类型名称不能为空`);if(t.length>40)throw Error(`类型名称过长(最多 40 字)`);let n=p();if(n.some(e=>e.label===t))throw Error(`已存在「${t}」`);let r=i(t),a={id:o(),label:t,...r};return h([...n,a]),a}function _(e,t){let n=t.trim();if(!n)throw Error(`类型名称不能为空`);if(n.length>40)throw Error(`类型名称过长(最多 40 字)`);let r=p(),a=r.findIndex(t=>t.id===e);if(a<0)throw Error(`类型不存在`);if(r.some(t=>t.id!==e&&t.label===n))throw Error(`已存在「${n}」`);let o=i(n),s={...r[a],label:n,...o},c=[...r];return c[a]=s,h(c),s}function v(e){let t=p();if(t.length<=1)throw Error(`至少保留一个用例类型`);if(!t.some(t=>t.id===e))throw Error(`类型不存在`);return h(t.filter(t=>t.id!==e))}var y=`/__tb_case_sessions`,b=`tw.case.sessions.v1`,x=!1;function S(){return`csess_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function C(e){if(typeof e==`string`&&e.trim()){let t=e.trim();return p().some(e=>e.id===t),t}return p()[0]?.id??`functional`}function w(e){if(!e||!Array.isArray(e.sessions))return{sessions:[],activeId:``};let t=e.sessions.filter(e=>e&&typeof e==`object`&&e.id).map(e=>({...e,caseType:C(e.caseType)})),n=typeof e.activeId==`string`?e.activeId:``;return t.length&&!t.some(e=>e.id===n)&&(n=t[0].id),t.length||(n=``),{sessions:t,activeId:n}}function T(){try{let e=localStorage.getItem(a(b));return e?w(JSON.parse(e)):{sessions:[],activeId:``}}catch{return{sessions:[],activeId:``}}}function E(e){try{localStorage.setItem(a(b),JSON.stringify(e))}catch{}}async function D(){try{let e=await fetch(y,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json();x=!0;let n=w(t.store);return E(n),n}}catch{}return x=!1,T()}function O(){return T()}async function k(e){if(E(e),x)try{await fetch(y,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({store:e})})}catch{}}function A(e){E(e),k(e)}function j(e){let t=Date.now(),n={id:S(),title:e.title?.trim()||`用例生成`,createdAt:t,updatedAt:t,caseType:e.caseType,outputFormat:e.outputFormat,reqPaths:e.reqPaths,templateId:e.templateId,templateTitle:e.templateTitle,promptPath:e.promptPath,knowledgePaths:e.knowledgePaths?.length?[...e.knowledgePaths]:void 0,messages:[]};return A({sessions:[n,...T().sessions],activeId:n.id}),n}function M(e,t){let n=T(),r=n.sessions.map(n=>n.id===e?{...n,...t,updatedAt:Date.now()}:n),i={...n,sessions:r};return A(i),i}var N=e(t(),1),P=u();function F({options:e,values:t,onChange:n,placeholder:r=`选择…`,disabled:i=!1}){let[a,o]=(0,N.useState)(!1),s=(0,N.useRef)(null);(0,N.useEffect)(()=>{if(!a)return;function e(e){s.current?.contains(e.target)||o(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]);let c=e.filter(e=>t.includes(e.value)).map(e=>e.label),l=i||c.length===0?r:c.length<=2?c.join(`、`):`已选 ${c.length} 项`;function u(e){t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e])}return(0,P.jsxs)(`div`,{className:`relative mt-1`,ref:s,children:[(0,P.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>o(e=>!e),className:i?`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-stone-50 px-3 text-sm text-left text-stone-400 cursor-not-allowed`:`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`,children:[(0,P.jsx)(`span`,{className:`truncate ${i||c.length?``:`text-stone-400`}`,children:l}),(0,P.jsx)(`svg`,{className:`w-4 h-4 text-stone-400 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,P.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})]}),a?(0,P.jsx)(`div`,{className:`tw-select-menu tw-popover-anim absolute z-80 mt-1 max-h-56 w-full overflow-auto rounded-lg p-1 shadow-lg ring-1 ring-stone-200`,children:e.length===0?(0,P.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`暂无可选项`}):e.map(e=>{let n=t.includes(e.value);return(0,P.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-3 py-2 text-sm text-stone-700 cursor-pointer hover:bg-stone-50`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>u(e.value),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,P.jsx)(`span`,{className:`truncate`,children:e.label})]},e.value)})}):null]})}function I({options:e,value:t,onChange:n,placeholder:r=`搜索并选择…`,disabled:i=!1,allowEmpty:a=!0,emptyLabel:o=`不选择`}){let s=(0,N.useMemo)(()=>{let t=e.map(e=>({value:e.value,label:e.label}));return a?[{value:``,label:o,muted:!0},...t]:t},[e,a,o]),c=t?s.find(e=>e.value===t):void 0;return(0,P.jsx)(f,{options:s,value:t,onChange:n,disabled:i,searchable:!0,searchPlaceholder:r,dimWhenOpen:!0,renderTrigger:(e,{open:t})=>c?(0,P.jsx)(`span`,{className:`min-w-0 flex-1 ${t?`text-stone-400`:``}`,children:(0,P.jsx)(d,{text:c.label,className:`block truncate`})}):(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-stone-400`,children:r})})}export{O as a,g as c,v as d,_ as f,D as i,m as l,F as n,A as o,j as r,M as s,I as t,p as u};
@@ -0,0 +1 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,n as r,r as i,t as a}from"./listbox.DNxAJmEo.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./OverflowHint.D6v4Uj2N.js";var c=e(t(),1),l=o();function u({className:e=`w-4 h-4 text-stone-400 shrink-0`}){return(0,l.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,l.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})}function d({value:e,onChange:t,placeholder:n,ariaLabel:r}){let i=(0,c.useRef)(null);return(0,c.useEffect)(()=>{let e=i.current;if(!e)return;e.focus();let t=requestAnimationFrame(()=>e.focus());return()=>cancelAnimationFrame(t)},[]),(0,l.jsx)(`div`,{className:`sticky top-0 z-10 -mx-1 -mt-1 mb-1 border-b border-stone-100 bg-white px-1 pb-1.5 pt-1`,children:(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsxs)(`svg`,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-stone-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,l.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,l.jsx)(`path`,{d:`m16.5 16.5 4 4`})]}),(0,l.jsx)(`input`,{ref:i,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{[`Escape`,`Enter`,`ArrowDown`,`ArrowUp`].includes(e.key)||e.stopPropagation()},placeholder:n,"aria-label":r,spellCheck:!1,className:`h-8 w-full rounded-md border border-stone-200 bg-stone-50 pl-7 pr-2 text-sm text-stone-700 outline-none transition-colors placeholder:text-stone-400 focus:border-[#4176e6]`})]})})}function f(){return(0,l.jsx)(`svg`,{className:`w-4 h-4 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":!0,children:(0,l.jsx)(`path`,{fillRule:`evenodd`,d:`M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z`,clipRule:`evenodd`})})}function p({options:e,value:t,onChange:o,disabled:p=!1,className:m=``,compact:h=!1,ariaLabel:g,showCheck:_=!1,centerContent:v=!1,unstyled:y=!1,triggerClassName:b=``,hideChevron:x=!1,flat:S=!1,menuMinWidth:C,menuMatchTrigger:w=!0,renderTrigger:T,renderOptionPrefix:E,renderOptionAction:D,searchable:O=!1,searchPlaceholder:k=`搜索…`,triggerTitle:A,hideTriggerHint:j=!1,dimWhenOpen:M=!1}){let N=e.find(e=>e.value===t),[P,F]=(0,c.useState)(``),I=(0,c.useMemo)(()=>{let t=P.trim().toLowerCase();return t?e.filter(e=>e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)):e},[e,P]),L=v?`relative justify-center`:`justify-between`,R=v?`w-4 h-4 text-stone-400 shrink-0 absolute right-2.5`:void 0,z=y?`w-full flex items-center cursor-pointer outline-none disabled:cursor-not-allowed`:h?`w-full h-8 flex items-center gap-1.5 rounded-lg border border-stone-300 bg-white px-2.5 text-sm text-left text-stone-700 outline-none cursor-pointer hover:border-stone-400 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`:S?`w-full h-9 flex items-center gap-2 rounded-lg border border-stone-200 bg-white px-2.5 text-sm text-left text-stone-700 outline-none cursor-pointer hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`:`w-full h-9 flex items-center gap-2 rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none cursor-pointer hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`;return(0,l.jsx)(i,{value:t,onChange:e=>{F(``),o(e)},disabled:p,children:({open:e})=>(0,l.jsxs)(`div`,{className:`relative ${y?``:h?`inline-block`:S?``:`mt-1`} ${m}`,children:[(0,l.jsxs)(n,{"aria-label":g,onClick:()=>{O&&F(``)},className:`${z} ${L} ${b} ${M&&e?`text-stone-400`:``}`,children:[T?T(N,{open:e}):(0,l.jsx)(s,{text:A??N?.label??t,className:`min-w-0 flex-1 truncate`,disabled:j}),x?null:(0,l.jsx)(u,{className:R})]}),(0,l.jsxs)(a,{transition:!0,anchor:{to:`bottom start`,gap:4,padding:12},style:!w&&C?{minWidth:C}:void 0,className:`tw-select-menu tw-menu-anim z-80 max-h-64 space-y-1 overflow-auto rounded-lg p-1 pb-2 shadow-lg ring-1 ring-stone-200 [--anchor-max-height:16rem] focus:outline-none ${w?`w-max min-w-(--button-width) max-w-[360px]`:`w-max min-w-[150px] max-w-[360px]`}`,children:[O?(0,l.jsx)(d,{value:P,onChange:F,placeholder:k,ariaLabel:g?`${g}搜索`:`搜索选项`}):null,O&&I.length===0?(0,l.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`无匹配项`}):null,I.map(e=>(0,l.jsxs)(r,{value:e.value,disabled:e.disabled,className:`group flex select-none items-center gap-2 rounded-md px-3 py-2 text-sm leading-5 data-[focus]:bg-stone-50 data-[selected]:bg-(--tw-accent-soft) ${e.disabled?`cursor-not-allowed text-stone-300 data-[focus]:bg-transparent data-[selected]:bg-transparent data-[selected]:font-normal`:`cursor-pointer`} ${_?`text-stone-700 data-[selected]:text-stone-900`:`data-[selected]:text-(--tw-accent) data-[selected]:font-medium`} ${e.muted?`text-stone-400 data-[selected]:text-stone-500`:``} ${v&&!_&&!E?`justify-center px-2`:``}`,children:[_?(0,l.jsx)(`span`,{className:`w-4 shrink-0 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100`,children:(0,l.jsx)(f,{})}):E?(0,l.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:E(e)}):null,(0,l.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,l.jsx)(s,{text:e.label,className:`min-w-0 w-full truncate`}),e.secondary?(0,l.jsx)(s,{text:e.secondary,className:`min-w-0 w-full truncate font-mono text-[10px] font-normal leading-4 text-stone-400`}):null]}),D?(0,l.jsx)(`span`,{className:`ml-0.5 flex shrink-0 items-center`,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),e.preventDefault()},children:D(e)}):null]},e.value))]})]})})}export{p as t};
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,i as r,n as i,r as ee,s as te}from"./app-config.BUPzGl9f.js";import{i as ne,n as re,r as ie,t as ae}from"./listbox.C96OCanh.js";import{a as oe,o as se}from"./dialog.BAPTk9a_.js";import{t as a}from"./jsx-runtime.DUg_B_vD.js";import{t as ce}from"./ConfirmDialog.BZzZWDci.js";import{i as le}from"./llm.BZEzE0x2.js";import{_ as ue,a as de,c as fe,d as pe,g as me,h as he,i as ge,l as o,n as s,o as _e,r as ve,s as ye,t as be,u as xe,v as Se}from"./settings.Ceefeil5.js";import{n as c}from"./i18n.BGPnP1Bg.js";import{n as Ce,r as we,t as l}from"./update.CtF8vsag.js";var u=e(t(),1),d=a();function Te(e){try{return new URL(e).host}catch{return``}}var Ee=[{value:`zh-CN`,label:`中文`},{value:`en`,label:`English`}],f=`w-full px-3 py-2 text-sm border border-stone-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-[#4176e6]/35 focus:border-[#4176e6] transition-colors`,p=`inline-flex items-center gap-1.5 h-9 min-w-30 px-3 rounded-lg bg-stone-100 text-sm text-stone-700 hover:bg-stone-200/80 transition-colors outline-none focus:outline-none`;function De({className:e=`w-3.5 h-3.5`}){return(0,d.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,d.jsx)(`path`,{d:`M6 8l4 4 4-4`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function Oe({className:e=`w-4 h-4`}){return(0,d.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,d.jsx)(`path`,{d:`M5 10.5l3.5 3.5L15 6.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function ke({className:e=`w-4 h-4`}){return(0,d.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,d.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,d.jsx)(`path`,{d:`M12 1v2M12 21v2M4.2 4.2l1.4 1.4M18.4 18.4l1.4 1.4M1 12h2M21 12h2M4.2 19.8l1.4-1.4M18.4 5.6l1.4-1.4`})]})}function Ae({className:e=`w-4 h-4`}){return(0,d.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,d.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,d.jsx)(`path`,{d:`M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5`}),(0,d.jsx)(`path`,{d:`M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]})}function je({kind:e}){let t=`w-5 h-5`;return e===`sun`?(0,d.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,d.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,d.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}):e===`moon`?(0,d.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,d.jsx)(`path`,{d:`M21 14.5A8.5 8.5 0 1 1 9.5 3a7 7 0 0 0 11.5 11.5z`})}):(0,d.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,d.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,d.jsx)(`path`,{d:`M8 20h8M12 16v4`})]})}function m({title:e,description:t,control:n}){return(0,d.jsxs)(`div`,{className:`flex items-center gap-4 py-4 border-b border-stone-100 last:border-b-0`,children:[(0,d.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,d.jsx)(`div`,{className:`text-sm font-medium text-stone-800`,children:e}),t?(0,d.jsx)(`div`,{className:`mt-0.5 text-xs text-stone-400 leading-5`,children:t}):null]}),(0,d.jsx)(`div`,{className:`shrink-0`,children:n})]})}function h({value:e,options:t,onChange:n}){let r=t.find(t=>t.value===e)?.label??e;return(0,d.jsxs)(ie,{value:e,onChange:n,children:[(0,d.jsxs)(ne,{className:p,children:[(0,d.jsx)(`span`,{className:`flex-1 text-left truncate`,children:r}),(0,d.jsx)(De,{className:`w-3.5 h-3.5 text-stone-400 shrink-0`})]}),(0,d.jsx)(ae,{transition:!0,anchor:{to:`bottom end`,gap:6},className:`tw-select-menu tw-menu-anim z-60 min-w-40 rounded-xl py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:t.map(e=>(0,d.jsxs)(re,{value:e.value,className:`group cursor-pointer select-none flex items-center justify-between gap-3 px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:text-stone-900`,children:[(0,d.jsx)(`span`,{children:e.label}),(0,d.jsx)(Oe,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0`})]},e.value))})]})}function g(){let[e,t]=(0,u.useState)(!1),[a,p]=(0,u.useState)(`general`),[g,Me]=(0,u.useState)(()=>ee().model.providers),[Ne,_]=(0,u.useState)(()=>ee().model.activeId),[v,y]=(0,u.useState)(null),[b,x]=(0,u.useState)(``),[Pe,Fe]=(0,u.useState)(`DeepSeek`),[S,C]=(0,u.useState)(``),[w,T]=(0,u.useState)(``),[E,D]=(0,u.useState)(``),[O,Ie]=(0,u.useState)([]),[k,A]=(0,u.useState)(`idle`),[Le,j]=(0,u.useState)(!1),[Re,M]=(0,u.useState)(`readonly`),[ze,Be]=(0,u.useState)(!1),[Ve,N]=(0,u.useState)(!1),[He,P]=(0,u.useState)(null),[F,I]=(0,u.useState)({language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``}),[Ue,L]=(0,u.useState)(`14`),We=(0,u.useRef)(0),[R,Ge]=(0,u.useState)(null),[z,Ke]=(0,u.useState)(!1),[qe,Je]=(0,u.useState)(!1),[Ye,B]=(0,u.useState)(!1),[Xe,V]=(0,u.useState)(``),H=(0,u.useRef)(null),U=(0,u.useRef)(!1),W=v!==null,G=F.language,K=g.find(e=>e.id===Ne),q=(K?.name||``).trim(),J=R?.status??null,Ze=J?.phase===`done`&&!!J.to&&J.to===R?.current&&we!==R?.current&&Date.now()-Date.parse(J.finishedAt||``)<864e5,Qe=J?.phase===`failed`?J.error:``,Y=Ye||J?.phase===`installing`||J?.phase===`restarting`,$e=(J?.to||R?.latest||``).replace(/^v/,``),X=Qe||Xe,et=R?.checkedAt&&!Y?new Date(R.checkedAt).toLocaleTimeString():``,tt=z?``:Y?J?.phase===`restarting`?c(`settings.updateRestarting`,void 0,G):c(`settings.updateInstalling`,{v:$e},G):X?`${c(`settings.updateFailed`,void 0,G)}:${X}`:Ze?c(`settings.updateDone`,{v:J?.to||``},G):R?.mode===`dev`&&R?.hasUpdate?c(`settings.updateDevMode`,void 0,G):R?.error?`${c(`settings.updateUnavailable`,void 0,G)}:${R.error}`:R?.hasUpdate?R.mode===`npx`?c(`settings.updateNpxHint`,void 0,G):``:R?`${c(`settings.updateLatest`,void 0,G)}${et?` · ${c(`settings.updateCheckedAt`,{time:et},G)}`:``}`:qe?c(`settings.updateUnavailable`,void 0,G):``,nt=q||(G===`en`?`No model`:`未配置`),rt=q?K?.model?.trim()?`${q} · ${K.model.trim()}`:q:G===`en`?`No model configured`:`未配置模型`;function it(e=`general`){p(e),r().then(()=>{at(),t(!0)})}function at(){Be(n()),Me(fe()),_(de()),N(!!o()),I(ye()),ve(ye()),M(_e()),y(null)}function Z(){H.current!==null&&(window.clearInterval(H.current),H.current=null)}async function ot(e=!0){Ke(!0);try{let t=await l(e);t&&(Ge(t),V(``))}finally{Ke(!1),Je(!0)}}function st(e){Z();let t=Date.now()+18e4;H.current=window.setInterval(async()=>{if(!U.current){U.current=!0;try{let n=await l(!0);if(n){Ge(n);let t=n.status;if(t?.phase===`failed`){Z(),B(!1),V(t.error||c(`settings.updateFailed`,void 0,G));return}if(t?.phase===`done`||e&&n.current!==e){Z(),B(!1);return}}Date.now()>t&&(Z(),B(!1),V(c(`settings.updateTimeout`,void 0,G)))}finally{U.current=!1}}},1500)}async function ct(){let e=R?.latest||``;V(``),B(!0);let t=R?.current||we,n=await Ce(e||void 0);n.ok?st(t):(B(!1),V(n.error||c(`settings.updateFailed`,void 0,G)))}function lt(e){if(!e){let e=te();y(e),x(`DeepSeek`),Fe(`DeepSeek`),C(`https://api.deepseek.com/v1`),T(``),D(``),Ie([]),A(`idle`),j(!1);return}y(e.id),x(e.name),C(e.baseURL);let t=e.apiKey?.trim()||(e.id===de()?i().trim():``)||``;T(t),D(e.model),Ie(e.availableModels??[]),A(e.availableModels?.length?`ok`:`idle`),Fe(s.find(t=>t.baseURL===e.baseURL)?.label??`自定义`),j(!1)}(0,u.useEffect)(()=>{r().then(()=>at());let e=e=>{let n=e.detail;p(n?.tab===`model`?`model`:`general`),r().then(()=>{at(),t(!0)})};window.addEventListener(be,e);let n=pe(e=>I(e)),i=xe(e=>M(e));return()=>{window.removeEventListener(be,e),n(),i()}},[]),(0,u.useEffect)(()=>{if(e)return(async()=>{let e=await l(!1);if(Je(!0),!e)return;Ge(e);let t=e.status;(t?.phase===`installing`||t?.phase===`restarting`)&&(B(!0),st(t.from||e.current))})(),Z},[e]),(0,u.useEffect)(()=>{if(!e||a!==`model`||!W)return;let t=S.trim(),n=w.trim();if(!t||!n){A(e=>e===`ok`?`ok`:`idle`);return}A(`loading`);let r=++We.current,i=setTimeout(()=>{le(t,n).then(e=>{r===We.current&&(Ie(e),A(`ok`))}).catch(()=>{r===We.current&&A(`fail`)})},800);return()=>clearTimeout(i)},[e,a,W,S,w]);function ut(e){Fe(e);let t=s.find(t=>t.label===e);t&&(t.baseURL&&C(t.baseURL),(!b.trim()||s.some(e=>e.label===b))&&x(t.label)),D(``)}function Q(e){I(me(e))}(0,u.useEffect)(()=>{L(String(F.sessionFontSize))},[F.sessionFontSize]);function dt(){let e=Number(Ue);if(!Ue.trim()||!Number.isFinite(e)){L(String(F.sessionFontSize));return}let t=me({sessionFontSize:Math.round(e)});I(t),L(String(t.sessionFontSize))}let ft=!!(b.trim()&&S.trim()&&w.trim()&&E.trim()),$=O.length>0;function pt(){if(!ft||!v)return;let e=Se({id:v,name:b.trim(),baseURL:S.trim(),apiKey:w.trim(),model:E.trim(),availableModels:$?O:void 0},{activate:!0});Me(e),_(v),y(null),N(!!o())}function mt(e){P(e)}function ht(){let e=He;if(!e)return;P(null);let t=ge(e);Me(t),_(de()),v===e&&y(null),N(!!o())}function gt(e){ue(e),_(e),N(!!o())}let _t=[{value:`readonly`,label:c(`settings.access.readonly`,void 0,G)},{value:`readwrite`,label:c(`settings.access.readwrite`,void 0,G)},{value:`full`,label:c(`settings.access.full`,void 0,G)}],vt=[{value:`concise`,label:c(`settings.step.concise`,void 0,G)},{value:`standard`,label:c(`settings.step.standard`,void 0,G)},{value:`detailed`,label:c(`settings.step.detailed`,void 0,G)},{value:`full`,label:c(`settings.step.full`,void 0,G)}],yt=[{value:`queue`,label:c(`settings.busySend.queue`,void 0,G)},{value:`interrupt`,label:c(`settings.busySend.interrupt`,void 0,G)}],bt=[{value:`light`,label:c(`settings.appear.light`,void 0,G),icon:`sun`},{value:`dark`,label:c(`settings.appear.dark`,void 0,G),icon:`moon`},{value:`system`,label:c(`settings.appear.system`,void 0,G),icon:`monitor`}],xt=[{id:`general`,label:c(`settings.general`,void 0,G),icon:(0,d.jsx)(ke,{})},{id:`model`,label:c(`settings.model`,void 0,G),icon:(0,d.jsx)(Ae,{})}],St=a===`general`?c(`settings.general`,void 0,G):W?g.some(e=>e.id===v)?c(`settings.editProvider`,void 0,G):c(`settings.addProviderTitle`,void 0,G):c(`settings.model`,void 0,G);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`tw-nav-foot-row`,children:[(0,d.jsxs)(`button`,{type:`button`,onClick:()=>it(`general`),className:`tw-nav-settings-btn`,"data-hint":Ve?`设置(已配置模型)`:`设置`,children:[(0,d.jsxs)(`svg`,{className:`tw-nav-ico w-4.5 h-4.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":`true`,children:[(0,d.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,d.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.2.6.7 1 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]}),(0,d.jsx)(`span`,{"data-i18n":`nav.settings`,children:c(`nav.settings`,void 0,G)})]}),(0,d.jsxs)(`button`,{type:`button`,className:`tw-nav-provider-chip${q?``:` is-empty`}`,"data-hint":rt,onClick:()=>it(`model`),children:[(0,d.jsx)(`span`,{className:`tw-nav-provider-dot`,"aria-hidden":`true`}),(0,d.jsx)(`span`,{className:`tw-nav-provider-name`,children:nt})]})]}),(0,d.jsx)(oe,{show:e,children:(0,d.jsxs)(`div`,{className:`fixed inset-0 z-110 flex items-center justify-center p-4`,children:[(0,d.jsx)(se,{children:(0,d.jsx)(`div`,{className:`tw-dialog-backdrop-anim absolute inset-0 bg-stone-950/45`,onClick:()=>t(!1),"aria-hidden":`true`})}),(0,d.jsx)(se,{children:(0,d.jsxs)(`div`,{className:`tw-settings-dialog tw-dialog-panel-anim relative bg-white rounded-2xl shadow-2xl w-full max-w-3xl h-[min(92vh,720px)] overflow-hidden flex flex-col`,children:[(0,d.jsxs)(`div`,{className:`shrink-0 h-12 px-4 flex items-center justify-between border-b border-stone-100 bg-white`,children:[(0,d.jsx)(`h2`,{className:`text-sm font-semibold text-stone-800 truncate pr-3`,children:St}),(0,d.jsx)(`button`,{type:`button`,"aria-label":c(`settings.close`,void 0,G),onClick:()=>t(!1),className:`w-8 h-8 inline-flex items-center justify-center rounded-lg text-stone-400 hover:text-stone-700 hover:bg-stone-100 transition-colors`,children:(0,d.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,d.jsx)(`path`,{d:`M5 5l10 10M15 5L5 15`,strokeLinecap:`round`})})})]}),(0,d.jsxs)(`div`,{className:`flex-1 min-h-0 flex`,children:[(0,d.jsx)(`aside`,{className:`w-38 shrink-0 border-r border-stone-100 bg-[#f4f5f7] py-3 px-2 space-y-0.5`,children:xt.map(e=>{let t=a===e.id;return(0,d.jsxs)(`button`,{type:`button`,onClick:()=>{p(e.id),e.id===`model`&&y(null)},className:`w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-sm transition-colors ${t?`bg-[#e8f0fe] text-[#4176e6] font-medium`:`text-stone-600 hover:bg-white/70 hover:text-stone-800`}`,children:[(0,d.jsx)(`span`,{className:t?`text-[#4176e6]`:`text-stone-400`,children:e.icon}),e.label]},e.id)})}),(0,d.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0 bg-white`,children:a===`general`?(0,d.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,d.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-1`,children:[(0,d.jsx)(m,{title:c(`settings.access`,void 0,G),description:c(`settings.accessDesc`,void 0,G),control:(0,d.jsx)(h,{value:Re,options:_t,onChange:e=>{M(e),he(e)}})}),(0,d.jsx)(m,{title:c(`settings.language`,void 0,G),control:(0,d.jsx)(h,{value:F.language,options:Ee,onChange:e=>Q({language:e})})}),(0,d.jsxs)(`div`,{className:`py-4 border-b border-stone-100`,children:[(0,d.jsx)(`div`,{className:`text-sm font-medium text-stone-800 mb-3`,children:c(`settings.appearance`,void 0,G)}),(0,d.jsx)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:bt.map(e=>{let t=F.appearance===e.value;return(0,d.jsxs)(`button`,{type:`button`,onClick:()=>Q({appearance:e.value}),className:`flex flex-col items-center justify-center gap-2 h-19 rounded-xl border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] text-[#4176e6] ring-1 ring-[#4176e6]/30`:`border-stone-200 text-stone-500 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,d.jsx)(je,{kind:e.icon}),(0,d.jsx)(`span`,{className:`text-xs font-medium`,children:e.label})]},e.value)})})]}),(0,d.jsx)(m,{title:c(`settings.fontSize`,void 0,G),description:c(`settings.fontSizeDesc`,void 0,G),control:(0,d.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,d.jsx)(`input`,{type:`number`,min:12,max:22,value:Ue,onChange:e=>L(e.target.value),onBlur:dt,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:`w-14 h-9 px-2 text-sm text-center rounded-lg bg-stone-100 border-0 outline-none focus:ring-2 focus:ring-[#4176e6]/30`}),(0,d.jsx)(`span`,{className:`text-sm text-stone-400`,children:`px`})]})}),(0,d.jsx)(m,{title:c(`settings.toolSteps`,void 0,G),description:c(`settings.toolStepsDesc`,void 0,G),control:(0,d.jsx)(h,{value:F.toolStepDetail,options:vt,onChange:e=>Q({toolStepDetail:e})})}),(0,d.jsx)(m,{title:c(`settings.busySend`,void 0,G),description:c(`settings.busySendDesc`,void 0,G),control:(0,d.jsx)(h,{value:F.busySendBehavior,options:yt,onChange:e=>Q({busySendBehavior:e})})}),(0,d.jsx)(m,{title:c(`settings.subagentModel`,void 0,G),description:c(`settings.subagentModelDesc`,void 0,G),control:(0,d.jsx)(h,{value:F.subagentModel?.trim()?F.subagentModel:`inherit`,options:[{value:`inherit`,label:c(`settings.subagentModel.inherit`,void 0,G)},...Array.from(new Set([...K?.availableModels??[],...K?.model?[K.model]:[]])).filter(Boolean).map(e=>({value:e,label:e}))],onChange:e=>Q({subagentModel:e===`inherit`?``:e})})})]}),(0,d.jsxs)(`div`,{className:`shrink-0 px-6 py-3 border-t border-stone-100`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,d.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,d.jsx)(`span`,{className:`text-sm text-stone-700 whitespace-nowrap`,children:c(`settings.platformVersion`,void 0,G)}),(0,d.jsxs)(`span`,{className:`text-sm tabular-nums text-stone-500`,children:[`v`,we]}),R?.hasUpdate&&!Y&&!Ze?(0,d.jsx)(`span`,{className:`inline-flex items-center h-[18px] px-1.5 rounded-full bg-[#edf3fe] text-[11px] font-medium text-[#4176e6] tabular-nums whitespace-nowrap`,children:`${c(`settings.updateAvailable`,void 0,G)} v${(R.latest||``).replace(/^v/,``)}`}):null]}),(0,d.jsx)(`div`,{className:`shrink-0 flex items-center gap-2`,children:Y?(0,d.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-lg text-xs text-stone-500 bg-stone-100 whitespace-nowrap`,children:[(0,d.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-stone-300 border-t-[#4176e6] animate-spin`}),c(`settings.updateWorking`,void 0,G)]}):Ze?(0,d.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`h-8 px-3 rounded-lg text-xs font-medium text-[#4176e6] bg-[#edf3fe] hover:bg-[#e2ecfd] whitespace-nowrap`,children:c(`settings.updateReload`,void 0,G)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`button`,{type:`button`,disabled:z,onClick:()=>void ot(!0),className:`inline-flex items-center justify-center min-w-[76px] h-8 px-3 rounded-lg text-xs font-medium text-stone-600 bg-stone-100 hover:bg-stone-200 disabled:opacity-70 disabled:cursor-default whitespace-nowrap`,children:z?(0,d.jsxs)(d.Fragment,{children:[c(`settings.updateChecking`,void 0,G),(0,d.jsxs)(`span`,{className:`tw-dots`,"aria-hidden":`true`,children:[(0,d.jsx)(`i`,{}),(0,d.jsx)(`i`,{}),(0,d.jsx)(`i`,{})]})]}):c(`settings.updateCheck`,void 0,G)}),R?.hasUpdate?(0,d.jsx)(`button`,{type:`button`,disabled:R.mode===`dev`,onClick:()=>void ct(),className:`h-8 px-3 rounded-lg text-xs font-semibold text-white bg-[#4176e6] hover:bg-[#3566d6] disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap`,children:c(`settings.updateNow`,void 0,G)}):null]})})]}),tt?(0,d.jsx)(`div`,{className:`mt-1 text-[11px] leading-relaxed ${X?`text-red-500`:`text-stone-400`}`,children:tt}):null,X&&R?.logPath?(0,d.jsx)(`div`,{className:`mt-0.5 text-[11px] leading-relaxed text-stone-400 break-all`,children:c(`settings.updateLog`,{path:R.logPath},G)}):null]})]}):W?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`shrink-0 px-5 pt-3 pb-2 flex items-center gap-2 border-b border-stone-100`,children:(0,d.jsx)(`button`,{type:`button`,onClick:()=>y(null),className:`text-sm text-stone-500 hover:text-stone-800`,children:c(`settings.back`,void 0,G)})}),(0,d.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:c(`settings.displayName`,void 0,G)}),(0,d.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:`DeepSeek`,className:f})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:c(`settings.preset`,void 0,G)}),(0,d.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:s.map(e=>{let t=Pe===e.label;return(0,d.jsxs)(`button`,{type:`button`,onClick:()=>ut(e.label),className:`text-left px-3 py-2 rounded-lg border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] ring-1 ring-[#4176e6]/30`:`border-stone-200 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,d.jsx)(`div`,{className:`text-sm ${t?`text-[#3565c7] font-medium`:`text-stone-700`}`,children:e.label}),(0,d.jsx)(`div`,{className:`text-[11px] text-stone-400 truncate`,children:e.baseURL?Te(e.baseURL):`OpenAI compatible`})]},e.label)})})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:c(`settings.baseUrl`,void 0,G)}),(0,d.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`https://api.deepseek.com/v1`,className:f})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:c(`settings.apiKey`,void 0,G)}),(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(`input`,{type:Le?`text`:`password`,value:w,onChange:e=>T(e.target.value),placeholder:`sk-...`,className:`${f} pr-14`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>j(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-[11px] text-stone-400 hover:text-stone-600 px-1.5 py-1`,children:Le?G===`en`?`Hide`:`隐藏`:G===`en`?`Show`:`显示`})]}),ze?(0,d.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-5`,children:c(`settings.keyHint`,void 0,G)}):null]}),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,d.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:c(`settings.modelField`,void 0,G)}),k===`loading`&&(0,d.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:c(`settings.recognizing`,void 0,G)}),$&&k===`ok`&&(0,d.jsx)(`span`,{className:`text-[11px] text-emerald-600`,children:c(`settings.recognized`,{n:O.length},G)}),k===`fail`&&!$&&(0,d.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:c(`settings.recognizeFail`,void 0,G)}),k===`fail`&&$&&(0,d.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:c(`settings.recognizeKeep`,void 0,G)})]}),$?(0,d.jsxs)(ie,{value:E,onChange:D,children:[(0,d.jsxs)(ne,{className:`${f} flex items-center justify-between text-left hover:border-stone-400 cursor-pointer`,children:[(0,d.jsx)(`span`,{className:`truncate text-stone-800`,children:E||(G===`en`?`Select a model`:`请选择模型`)}),(0,d.jsx)(De,{className:`w-4 h-4 shrink-0 ml-2 text-stone-400`})]}),(0,d.jsx)(ae,{transition:!0,anchor:{to:`bottom start`,gap:6},className:`tw-select-menu tw-menu-anim z-60 w-(--button-width) max-h-60 overflow-auto rounded-lg py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:O.map(e=>(0,d.jsxs)(re,{value:e,className:`group cursor-pointer select-none flex items-center justify-between px-3 py-2 text-sm text-stone-700 data-[focus]:bg-[#edf3fe] data-[selected]:text-[#3565c7] data-[selected]:font-medium`,children:[(0,d.jsx)(`span`,{className:`truncate`,children:e}),(0,d.jsx)(Oe,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0 ml-2`})]},e))})]}):(0,d.jsx)(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:c(`settings.modelPlaceholder`,void 0,G),className:f})]})]}),(0,d.jsxs)(`div`,{className:`shrink-0 px-5 py-3.5 bg-stone-50 border-t border-stone-100 flex justify-end gap-2`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>y(null),className:`px-3.5 py-1.5 text-sm text-stone-600 hover:bg-stone-200/60 rounded-lg`,children:c(`settings.cancel`,void 0,G)}),(0,d.jsx)(`button`,{type:`button`,onClick:pt,disabled:!ft,className:`px-3.5 py-1.5 text-sm font-medium text-white bg-[#4176e6] hover:bg-[#3565c7] rounded-lg disabled:opacity-40 disabled:cursor-not-allowed`,children:c(`settings.save`,void 0,G)})]})]}):(0,d.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5 bg-[#f4f5f7]`,children:[(0,d.jsx)(`p`,{className:`text-sm text-stone-500`,children:c(`settings.modelIntro`,void 0,G)}),(0,d.jsxs)(`div`,{className:`mt-5 space-y-2.5`,children:[g.map(e=>{let t=!!(e.apiKey?.trim()&&e.baseURL.trim()&&e.model.trim()),n=e.id===Ne;return(0,d.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-stone-200/90 bg-white px-4 py-3.5 shadow-[0_1px_0_rgba(15,23,42,0.02)]`,children:[(0,d.jsxs)(`button`,{type:`button`,"data-hint":n?G===`en`?`Active`:`当前使用`:G===`en`?`Set active`:`设为当前`,onClick:()=>gt(e.id),className:`flex-1 min-w-0 flex items-center gap-2 text-left`,children:[(0,d.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:e.name}),t?(0,d.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 bg-emerald-500`}):null]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>lt(e),className:`h-8 px-3 text-sm text-stone-700 rounded-lg border border-stone-200 bg-white hover:bg-stone-50`,children:c(`settings.edit`,void 0,G)}),g.length>1?(0,d.jsx)(`button`,{type:`button`,onClick:()=>mt(e.id),className:`h-8 px-3 text-sm text-red-600 rounded-lg hover:bg-red-50`,children:c(`settings.delete`,void 0,G)}):null]})]},e.id)}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>lt(null),className:`w-full h-12 rounded-xl border border-dashed border-stone-300 bg-white/60 text-sm text-stone-600 hover:border-[#4176e6] hover:text-[#4176e6] hover:bg-[#edf3fe]/50 transition-colors`,children:c(`settings.addProvider`,void 0,G)})]})]})})]})]})})]})}),(0,d.jsx)(ce,{open:He!=null,title:c(`settings.delete`,void 0,G),message:c(`settings.deleteConfirm`,void 0,G),confirmLabel:c(`settings.delete`,void 0,G),cancelLabel:G===`en`?`Cancel`:`取消`,danger:!0,onClose:()=>P(null),onConfirm:ht})]})}export{g as default};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,i as r,n as i,r as ee,s as te}from"./app-config.Cq_F8I0l.js";import{i as ne,n as re,r as ie,t as ae}from"./listbox.DNxAJmEo.js";import{a as oe,o as se}from"./dialog.DZHZCe_T.js";import{t as a}from"./jsx-runtime.DUg_B_vD.js";import{t as ce}from"./ConfirmDialog.CsMwWevK.js";import{i as le}from"./llm.BZEzE0x2.js";import{_ as ue,a as de,c as fe,d as pe,g as me,h as he,i as ge,l as o,n as s,o as _e,r as ve,s as ye,t as be,u as xe,v as Se}from"./settings.HM3DiNh0.js";import{n as c}from"./i18n.DPw-aTIZ.js";import{n as Ce,r as we,t as l}from"./update.BSnBvaFF.js";var u=e(t(),1),d=a();function Te(e){try{return new URL(e).host}catch{return``}}var Ee=[{value:`zh-CN`,label:`中文`},{value:`en`,label:`English`}],f=`w-full px-3 py-2 text-sm border border-stone-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-[#4176e6]/35 focus:border-[#4176e6] transition-colors`,p=`inline-flex items-center gap-1.5 h-9 min-w-30 px-3 rounded-lg bg-stone-100 text-sm text-stone-700 hover:bg-stone-200/80 transition-colors outline-none focus:outline-none`;function De({className:e=`w-3.5 h-3.5`}){return(0,d.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,d.jsx)(`path`,{d:`M6 8l4 4 4-4`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function Oe({className:e=`w-4 h-4`}){return(0,d.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,d.jsx)(`path`,{d:`M5 10.5l3.5 3.5L15 6.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function ke({className:e=`w-4 h-4`}){return(0,d.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,d.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,d.jsx)(`path`,{d:`M12 1v2M12 21v2M4.2 4.2l1.4 1.4M18.4 18.4l1.4 1.4M1 12h2M21 12h2M4.2 19.8l1.4-1.4M18.4 5.6l1.4-1.4`})]})}function Ae({className:e=`w-4 h-4`}){return(0,d.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,d.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,d.jsx)(`path`,{d:`M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5`}),(0,d.jsx)(`path`,{d:`M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]})}function je({kind:e}){let t=`w-5 h-5`;return e===`sun`?(0,d.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,d.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,d.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}):e===`moon`?(0,d.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,d.jsx)(`path`,{d:`M21 14.5A8.5 8.5 0 1 1 9.5 3a7 7 0 0 0 11.5 11.5z`})}):(0,d.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,d.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,d.jsx)(`path`,{d:`M8 20h8M12 16v4`})]})}function m({title:e,description:t,control:n}){return(0,d.jsxs)(`div`,{className:`flex items-center gap-4 py-4 border-b border-stone-100 last:border-b-0`,children:[(0,d.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,d.jsx)(`div`,{className:`text-sm font-medium text-stone-800`,children:e}),t?(0,d.jsx)(`div`,{className:`mt-0.5 text-xs text-stone-400 leading-5`,children:t}):null]}),(0,d.jsx)(`div`,{className:`shrink-0`,children:n})]})}function h({value:e,options:t,onChange:n}){let r=t.find(t=>t.value===e)?.label??e;return(0,d.jsxs)(ie,{value:e,onChange:n,children:[(0,d.jsxs)(ne,{className:p,children:[(0,d.jsx)(`span`,{className:`flex-1 text-left truncate`,children:r}),(0,d.jsx)(De,{className:`w-3.5 h-3.5 text-stone-400 shrink-0`})]}),(0,d.jsx)(ae,{transition:!0,anchor:{to:`bottom end`,gap:6},className:`tw-select-menu tw-menu-anim z-60 min-w-40 rounded-xl py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:t.map(e=>(0,d.jsxs)(re,{value:e.value,className:`group cursor-pointer select-none flex items-center justify-between gap-3 px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:text-stone-900`,children:[(0,d.jsx)(`span`,{children:e.label}),(0,d.jsx)(Oe,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0`})]},e.value))})]})}function g(){let[e,t]=(0,u.useState)(!1),[a,p]=(0,u.useState)(`general`),[g,Me]=(0,u.useState)(()=>ee().model.providers),[Ne,_]=(0,u.useState)(()=>ee().model.activeId),[v,y]=(0,u.useState)(null),[b,x]=(0,u.useState)(``),[Pe,Fe]=(0,u.useState)(`DeepSeek`),[S,C]=(0,u.useState)(``),[w,T]=(0,u.useState)(``),[E,D]=(0,u.useState)(``),[O,Ie]=(0,u.useState)([]),[k,A]=(0,u.useState)(`idle`),[Le,j]=(0,u.useState)(!1),[Re,M]=(0,u.useState)(`readonly`),[ze,Be]=(0,u.useState)(!1),[Ve,N]=(0,u.useState)(!1),[He,P]=(0,u.useState)(null),[F,I]=(0,u.useState)({language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``}),[Ue,L]=(0,u.useState)(`14`),We=(0,u.useRef)(0),[R,Ge]=(0,u.useState)(null),[z,Ke]=(0,u.useState)(!1),[qe,Je]=(0,u.useState)(!1),[Ye,B]=(0,u.useState)(!1),[Xe,V]=(0,u.useState)(``),H=(0,u.useRef)(null),U=(0,u.useRef)(!1),W=v!==null,G=F.language,K=g.find(e=>e.id===Ne),q=(K?.name||``).trim(),J=R?.status??null,Ze=J?.phase===`done`&&!!J.to&&J.to===R?.current&&we!==R?.current&&Date.now()-Date.parse(J.finishedAt||``)<864e5,Qe=J?.phase===`failed`?J.error:``,Y=Ye||J?.phase===`installing`||J?.phase===`restarting`,$e=(J?.to||R?.latest||``).replace(/^v/,``),X=Qe||Xe,et=R?.checkedAt&&!Y?new Date(R.checkedAt).toLocaleTimeString():``,tt=z?``:Y?J?.phase===`restarting`?c(`settings.updateRestarting`,void 0,G):c(`settings.updateInstalling`,{v:$e},G):X?`${c(`settings.updateFailed`,void 0,G)}:${X}`:Ze?c(`settings.updateDone`,{v:J?.to||``},G):R?.mode===`dev`&&R?.hasUpdate?c(`settings.updateDevMode`,void 0,G):R?.error?`${c(`settings.updateUnavailable`,void 0,G)}:${R.error}`:R?.hasUpdate?R.mode===`npx`?c(`settings.updateNpxHint`,void 0,G):``:R?`${c(`settings.updateLatest`,void 0,G)}${et?` · ${c(`settings.updateCheckedAt`,{time:et},G)}`:``}`:qe?c(`settings.updateUnavailable`,void 0,G):``,nt=q||(G===`en`?`No model`:`未配置`),rt=q?K?.model?.trim()?`${q} · ${K.model.trim()}`:q:G===`en`?`No model configured`:`未配置模型`;function it(e=`general`){p(e),r().then(()=>{at(),t(!0)})}function at(){Be(n()),Me(fe()),_(de()),N(!!o()),I(ye()),ve(ye()),M(_e()),y(null)}function Z(){H.current!==null&&(window.clearInterval(H.current),H.current=null)}async function ot(e=!0){Ke(!0);try{let t=await l(e);t&&(Ge(t),V(``))}finally{Ke(!1),Je(!0)}}function st(e){Z();let t=Date.now()+18e4;H.current=window.setInterval(async()=>{if(!U.current){U.current=!0;try{let n=await l(!0);if(n){Ge(n);let t=n.status;if(t?.phase===`failed`){Z(),B(!1),V(t.error||c(`settings.updateFailed`,void 0,G));return}if(t?.phase===`done`||e&&n.current!==e){Z(),B(!1);return}}Date.now()>t&&(Z(),B(!1),V(c(`settings.updateTimeout`,void 0,G)))}finally{U.current=!1}}},1500)}async function ct(){let e=R?.latest||``;V(``),B(!0);let t=R?.current||we,n=await Ce(e||void 0);n.ok?st(t):(B(!1),V(n.error||c(`settings.updateFailed`,void 0,G)))}function lt(e){if(!e){let e=te();y(e),x(`DeepSeek`),Fe(`DeepSeek`),C(`https://api.deepseek.com/v1`),T(``),D(``),Ie([]),A(`idle`),j(!1);return}y(e.id),x(e.name),C(e.baseURL);let t=e.apiKey?.trim()||(e.id===de()?i().trim():``)||``;T(t),D(e.model),Ie(e.availableModels??[]),A(e.availableModels?.length?`ok`:`idle`),Fe(s.find(t=>t.baseURL===e.baseURL)?.label??`自定义`),j(!1)}(0,u.useEffect)(()=>{r().then(()=>at());let e=e=>{let n=e.detail;p(n?.tab===`model`?`model`:`general`),r().then(()=>{at(),t(!0)})};window.addEventListener(be,e);let n=pe(e=>I(e)),i=xe(e=>M(e));return()=>{window.removeEventListener(be,e),n(),i()}},[]),(0,u.useEffect)(()=>{if(e)return(async()=>{let e=await l(!1);if(Je(!0),!e)return;Ge(e);let t=e.status;(t?.phase===`installing`||t?.phase===`restarting`)&&(B(!0),st(t.from||e.current))})(),Z},[e]),(0,u.useEffect)(()=>{if(!e||a!==`model`||!W)return;let t=S.trim(),n=w.trim();if(!t||!n){A(e=>e===`ok`?`ok`:`idle`);return}A(`loading`);let r=++We.current,i=setTimeout(()=>{le(t,n).then(e=>{r===We.current&&(Ie(e),A(`ok`))}).catch(()=>{r===We.current&&A(`fail`)})},800);return()=>clearTimeout(i)},[e,a,W,S,w]);function ut(e){Fe(e);let t=s.find(t=>t.label===e);t&&(t.baseURL&&C(t.baseURL),(!b.trim()||s.some(e=>e.label===b))&&x(t.label)),D(``)}function Q(e){I(me(e))}(0,u.useEffect)(()=>{L(String(F.sessionFontSize))},[F.sessionFontSize]);function dt(){let e=Number(Ue);if(!Ue.trim()||!Number.isFinite(e)){L(String(F.sessionFontSize));return}let t=me({sessionFontSize:Math.round(e)});I(t),L(String(t.sessionFontSize))}let ft=!!(b.trim()&&S.trim()&&w.trim()&&E.trim()),$=O.length>0;function pt(){if(!ft||!v)return;let e=Se({id:v,name:b.trim(),baseURL:S.trim(),apiKey:w.trim(),model:E.trim(),availableModels:$?O:void 0},{activate:!0});Me(e),_(v),y(null),N(!!o())}function mt(e){P(e)}function ht(){let e=He;if(!e)return;P(null);let t=ge(e);Me(t),_(de()),v===e&&y(null),N(!!o())}function gt(e){ue(e),_(e),N(!!o())}let _t=[{value:`readonly`,label:c(`settings.access.readonly`,void 0,G)},{value:`readwrite`,label:c(`settings.access.readwrite`,void 0,G)},{value:`full`,label:c(`settings.access.full`,void 0,G)}],vt=[{value:`concise`,label:c(`settings.step.concise`,void 0,G)},{value:`standard`,label:c(`settings.step.standard`,void 0,G)},{value:`detailed`,label:c(`settings.step.detailed`,void 0,G)},{value:`full`,label:c(`settings.step.full`,void 0,G)}],yt=[{value:`queue`,label:c(`settings.busySend.queue`,void 0,G)},{value:`interrupt`,label:c(`settings.busySend.interrupt`,void 0,G)}],bt=[{value:`light`,label:c(`settings.appear.light`,void 0,G),icon:`sun`},{value:`dark`,label:c(`settings.appear.dark`,void 0,G),icon:`moon`},{value:`system`,label:c(`settings.appear.system`,void 0,G),icon:`monitor`}],xt=[{id:`general`,label:c(`settings.general`,void 0,G),icon:(0,d.jsx)(ke,{})},{id:`model`,label:c(`settings.model`,void 0,G),icon:(0,d.jsx)(Ae,{})}],St=a===`general`?c(`settings.general`,void 0,G):W?g.some(e=>e.id===v)?c(`settings.editProvider`,void 0,G):c(`settings.addProviderTitle`,void 0,G):c(`settings.model`,void 0,G);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`tw-nav-foot-row`,children:[(0,d.jsxs)(`button`,{type:`button`,onClick:()=>it(`general`),className:`tw-nav-settings-btn`,"data-hint":Ve?`设置(已配置模型)`:`设置`,children:[(0,d.jsxs)(`svg`,{className:`tw-nav-ico w-4.5 h-4.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":`true`,children:[(0,d.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,d.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.2.6.7 1 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]}),(0,d.jsx)(`span`,{"data-i18n":`nav.settings`,children:c(`nav.settings`,void 0,G)})]}),(0,d.jsxs)(`button`,{type:`button`,className:`tw-nav-provider-chip${q?``:` is-empty`}`,"data-hint":rt,onClick:()=>it(`model`),children:[(0,d.jsx)(`span`,{className:`tw-nav-provider-dot`,"aria-hidden":`true`}),(0,d.jsx)(`span`,{className:`tw-nav-provider-name`,children:nt})]})]}),(0,d.jsx)(oe,{show:e,children:(0,d.jsxs)(`div`,{className:`fixed inset-0 z-110 flex items-center justify-center p-4`,children:[(0,d.jsx)(se,{children:(0,d.jsx)(`div`,{className:`tw-dialog-backdrop-anim absolute inset-0 bg-stone-950/45`,onClick:()=>t(!1),"aria-hidden":`true`})}),(0,d.jsx)(se,{children:(0,d.jsxs)(`div`,{className:`tw-settings-dialog tw-dialog-panel-anim relative bg-white rounded-2xl shadow-2xl w-full max-w-3xl h-[min(92vh,720px)] overflow-hidden flex flex-col`,children:[(0,d.jsxs)(`div`,{className:`shrink-0 h-12 px-4 flex items-center justify-between border-b border-stone-100 bg-white`,children:[(0,d.jsx)(`h2`,{className:`text-sm font-semibold text-stone-800 truncate pr-3`,children:St}),(0,d.jsx)(`button`,{type:`button`,"aria-label":c(`settings.close`,void 0,G),onClick:()=>t(!1),className:`w-8 h-8 inline-flex items-center justify-center rounded-lg text-stone-400 hover:text-stone-700 hover:bg-stone-100 transition-colors`,children:(0,d.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,d.jsx)(`path`,{d:`M5 5l10 10M15 5L5 15`,strokeLinecap:`round`})})})]}),(0,d.jsxs)(`div`,{className:`flex-1 min-h-0 flex`,children:[(0,d.jsx)(`aside`,{className:`w-38 shrink-0 border-r border-stone-100 bg-[#f4f5f7] py-3 px-2 space-y-0.5`,children:xt.map(e=>{let t=a===e.id;return(0,d.jsxs)(`button`,{type:`button`,onClick:()=>{p(e.id),e.id===`model`&&y(null)},className:`w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-sm transition-colors ${t?`bg-[#e8f0fe] text-[#4176e6] font-medium`:`text-stone-600 hover:bg-white/70 hover:text-stone-800`}`,children:[(0,d.jsx)(`span`,{className:t?`text-[#4176e6]`:`text-stone-400`,children:e.icon}),e.label]},e.id)})}),(0,d.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0 bg-white`,children:a===`general`?(0,d.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,d.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-1`,children:[(0,d.jsx)(m,{title:c(`settings.access`,void 0,G),description:c(`settings.accessDesc`,void 0,G),control:(0,d.jsx)(h,{value:Re,options:_t,onChange:e=>{M(e),he(e)}})}),(0,d.jsx)(m,{title:c(`settings.language`,void 0,G),control:(0,d.jsx)(h,{value:F.language,options:Ee,onChange:e=>Q({language:e})})}),(0,d.jsxs)(`div`,{className:`py-4 border-b border-stone-100`,children:[(0,d.jsx)(`div`,{className:`text-sm font-medium text-stone-800 mb-3`,children:c(`settings.appearance`,void 0,G)}),(0,d.jsx)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:bt.map(e=>{let t=F.appearance===e.value;return(0,d.jsxs)(`button`,{type:`button`,onClick:()=>Q({appearance:e.value}),className:`flex flex-col items-center justify-center gap-2 h-19 rounded-xl border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] text-[#4176e6] ring-1 ring-[#4176e6]/30`:`border-stone-200 text-stone-500 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,d.jsx)(je,{kind:e.icon}),(0,d.jsx)(`span`,{className:`text-xs font-medium`,children:e.label})]},e.value)})})]}),(0,d.jsx)(m,{title:c(`settings.fontSize`,void 0,G),description:c(`settings.fontSizeDesc`,void 0,G),control:(0,d.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,d.jsx)(`input`,{type:`number`,min:12,max:22,value:Ue,onChange:e=>L(e.target.value),onBlur:dt,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:`w-14 h-9 px-2 text-sm text-center rounded-lg bg-stone-100 border-0 outline-none focus:ring-2 focus:ring-[#4176e6]/30`}),(0,d.jsx)(`span`,{className:`text-sm text-stone-400`,children:`px`})]})}),(0,d.jsx)(m,{title:c(`settings.toolSteps`,void 0,G),description:c(`settings.toolStepsDesc`,void 0,G),control:(0,d.jsx)(h,{value:F.toolStepDetail,options:vt,onChange:e=>Q({toolStepDetail:e})})}),(0,d.jsx)(m,{title:c(`settings.busySend`,void 0,G),description:c(`settings.busySendDesc`,void 0,G),control:(0,d.jsx)(h,{value:F.busySendBehavior,options:yt,onChange:e=>Q({busySendBehavior:e})})}),(0,d.jsx)(m,{title:c(`settings.subagentModel`,void 0,G),description:c(`settings.subagentModelDesc`,void 0,G),control:(0,d.jsx)(h,{value:F.subagentModel?.trim()?F.subagentModel:`inherit`,options:[{value:`inherit`,label:c(`settings.subagentModel.inherit`,void 0,G)},...Array.from(new Set([...K?.availableModels??[],...K?.model?[K.model]:[]])).filter(Boolean).map(e=>({value:e,label:e}))],onChange:e=>Q({subagentModel:e===`inherit`?``:e})})})]}),(0,d.jsxs)(`div`,{className:`shrink-0 px-6 py-3 border-t border-stone-100`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,d.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,d.jsx)(`span`,{className:`text-sm text-stone-700 whitespace-nowrap`,children:c(`settings.platformVersion`,void 0,G)}),(0,d.jsxs)(`span`,{className:`text-sm tabular-nums text-stone-500`,children:[`v`,we]}),R?.hasUpdate&&!Y&&!Ze?(0,d.jsx)(`span`,{className:`inline-flex items-center h-[18px] px-1.5 rounded-full bg-[#edf3fe] text-[11px] font-medium text-[#4176e6] tabular-nums whitespace-nowrap`,children:`${c(`settings.updateAvailable`,void 0,G)} v${(R.latest||``).replace(/^v/,``)}`}):null]}),(0,d.jsx)(`div`,{className:`shrink-0 flex items-center gap-2`,children:Y?(0,d.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-lg text-xs text-stone-500 bg-stone-100 whitespace-nowrap`,children:[(0,d.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-stone-300 border-t-[#4176e6] animate-spin`}),c(`settings.updateWorking`,void 0,G)]}):Ze?(0,d.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`h-8 px-3 rounded-lg text-xs font-medium text-[#4176e6] bg-[#edf3fe] hover:bg-[#e2ecfd] whitespace-nowrap`,children:c(`settings.updateReload`,void 0,G)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`button`,{type:`button`,disabled:z,onClick:()=>void ot(!0),className:`inline-flex items-center justify-center min-w-[76px] h-8 px-3 rounded-lg text-xs font-medium text-stone-600 bg-stone-100 hover:bg-stone-200 disabled:opacity-70 disabled:cursor-default whitespace-nowrap`,children:z?(0,d.jsxs)(d.Fragment,{children:[c(`settings.updateChecking`,void 0,G),(0,d.jsxs)(`span`,{className:`tw-dots`,"aria-hidden":`true`,children:[(0,d.jsx)(`i`,{}),(0,d.jsx)(`i`,{}),(0,d.jsx)(`i`,{})]})]}):c(`settings.updateCheck`,void 0,G)}),R?.hasUpdate?(0,d.jsx)(`button`,{type:`button`,disabled:R.mode===`dev`,onClick:()=>void ct(),className:`h-8 px-3 rounded-lg text-xs font-semibold text-white bg-[#4176e6] hover:bg-[#3566d6] disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap`,children:c(`settings.updateNow`,void 0,G)}):null]})})]}),tt?(0,d.jsx)(`div`,{className:`mt-1 text-[11px] leading-relaxed ${X?`text-red-500`:`text-stone-400`}`,children:tt}):null,X&&R?.logPath?(0,d.jsx)(`div`,{className:`mt-0.5 text-[11px] leading-relaxed text-stone-400 break-all`,children:c(`settings.updateLog`,{path:R.logPath},G)}):null]})]}):W?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`shrink-0 px-5 pt-3 pb-2 flex items-center gap-2 border-b border-stone-100`,children:(0,d.jsx)(`button`,{type:`button`,onClick:()=>y(null),className:`text-sm text-stone-500 hover:text-stone-800`,children:c(`settings.back`,void 0,G)})}),(0,d.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:c(`settings.displayName`,void 0,G)}),(0,d.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:`DeepSeek`,className:f})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:c(`settings.preset`,void 0,G)}),(0,d.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:s.map(e=>{let t=Pe===e.label;return(0,d.jsxs)(`button`,{type:`button`,onClick:()=>ut(e.label),className:`text-left px-3 py-2 rounded-lg border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] ring-1 ring-[#4176e6]/30`:`border-stone-200 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,d.jsx)(`div`,{className:`text-sm ${t?`text-[#3565c7] font-medium`:`text-stone-700`}`,children:e.label}),(0,d.jsx)(`div`,{className:`text-[11px] text-stone-400 truncate`,children:e.baseURL?Te(e.baseURL):`OpenAI compatible`})]},e.label)})})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:c(`settings.baseUrl`,void 0,G)}),(0,d.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`https://api.deepseek.com/v1`,className:f})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:c(`settings.apiKey`,void 0,G)}),(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(`input`,{type:Le?`text`:`password`,value:w,onChange:e=>T(e.target.value),placeholder:`sk-...`,className:`${f} pr-14`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>j(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-[11px] text-stone-400 hover:text-stone-600 px-1.5 py-1`,children:Le?G===`en`?`Hide`:`隐藏`:G===`en`?`Show`:`显示`})]}),ze?(0,d.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-5`,children:c(`settings.keyHint`,void 0,G)}):null]}),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,d.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:c(`settings.modelField`,void 0,G)}),k===`loading`&&(0,d.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:c(`settings.recognizing`,void 0,G)}),$&&k===`ok`&&(0,d.jsx)(`span`,{className:`text-[11px] text-emerald-600`,children:c(`settings.recognized`,{n:O.length},G)}),k===`fail`&&!$&&(0,d.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:c(`settings.recognizeFail`,void 0,G)}),k===`fail`&&$&&(0,d.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:c(`settings.recognizeKeep`,void 0,G)})]}),$?(0,d.jsxs)(ie,{value:E,onChange:D,children:[(0,d.jsxs)(ne,{className:`${f} flex items-center justify-between text-left hover:border-stone-400 cursor-pointer`,children:[(0,d.jsx)(`span`,{className:`truncate text-stone-800`,children:E||(G===`en`?`Select a model`:`请选择模型`)}),(0,d.jsx)(De,{className:`w-4 h-4 shrink-0 ml-2 text-stone-400`})]}),(0,d.jsx)(ae,{transition:!0,anchor:{to:`bottom start`,gap:6},className:`tw-select-menu tw-menu-anim z-60 w-(--button-width) max-h-60 overflow-auto rounded-lg py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:O.map(e=>(0,d.jsxs)(re,{value:e,className:`group cursor-pointer select-none flex items-center justify-between px-3 py-2 text-sm text-stone-700 data-[focus]:bg-[#edf3fe] data-[selected]:text-[#3565c7] data-[selected]:font-medium`,children:[(0,d.jsx)(`span`,{className:`truncate`,children:e}),(0,d.jsx)(Oe,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0 ml-2`})]},e))})]}):(0,d.jsx)(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:c(`settings.modelPlaceholder`,void 0,G),className:f})]})]}),(0,d.jsxs)(`div`,{className:`shrink-0 px-5 py-3.5 bg-stone-50 border-t border-stone-100 flex justify-end gap-2`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>y(null),className:`px-3.5 py-1.5 text-sm text-stone-600 hover:bg-stone-200/60 rounded-lg`,children:c(`settings.cancel`,void 0,G)}),(0,d.jsx)(`button`,{type:`button`,onClick:pt,disabled:!ft,className:`px-3.5 py-1.5 text-sm font-medium text-white bg-[#4176e6] hover:bg-[#3565c7] rounded-lg disabled:opacity-40 disabled:cursor-not-allowed`,children:c(`settings.save`,void 0,G)})]})]}):(0,d.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5 bg-[#f4f5f7]`,children:[(0,d.jsx)(`p`,{className:`text-sm text-stone-500`,children:c(`settings.modelIntro`,void 0,G)}),(0,d.jsxs)(`div`,{className:`mt-5 space-y-2.5`,children:[g.map(e=>{let t=!!(e.apiKey?.trim()&&e.baseURL.trim()&&e.model.trim()),n=e.id===Ne;return(0,d.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-stone-200/90 bg-white px-4 py-3.5 shadow-[0_1px_0_rgba(15,23,42,0.02)]`,children:[(0,d.jsxs)(`button`,{type:`button`,"data-hint":n?G===`en`?`Active`:`当前使用`:G===`en`?`Set active`:`设为当前`,onClick:()=>gt(e.id),className:`flex-1 min-w-0 flex items-center gap-2 text-left`,children:[(0,d.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:e.name}),t?(0,d.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 bg-emerald-500`}):null]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>lt(e),className:`h-8 px-3 text-sm text-stone-700 rounded-lg border border-stone-200 bg-white hover:bg-stone-50`,children:c(`settings.edit`,void 0,G)}),g.length>1?(0,d.jsx)(`button`,{type:`button`,onClick:()=>mt(e.id),className:`h-8 px-3 text-sm text-red-600 rounded-lg hover:bg-red-50`,children:c(`settings.delete`,void 0,G)}):null]})]},e.id)}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>lt(null),className:`w-full h-12 rounded-xl border border-dashed border-stone-300 bg-white/60 text-sm text-stone-600 hover:border-[#4176e6] hover:text-[#4176e6] hover:bg-[#edf3fe]/50 transition-colors`,children:c(`settings.addProvider`,void 0,G)})]})]})})]})]})})]})}),(0,d.jsx)(ce,{open:He!=null,title:c(`settings.delete`,void 0,G),message:c(`settings.deleteConfirm`,void 0,G),confirmLabel:c(`settings.delete`,void 0,G),cancelLabel:G===`en`?`Cancel`:`取消`,danger:!0,onClose:()=>P(null),onConfirm:ht})]})}export{g as default};
@@ -0,0 +1 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./react-dom.DLW9pGCF.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";var i=e(t(),1),a=e(n(),1),o=r(),s=220;function c({open:e,onClose:t,title:n,closeAriaLabel:r=`关闭面板`,widthClass:c=`max-w-md`,escDisabled:l=!1,children:u,footer:d}){let[f,p]=(0,i.useState)(e),[m,h]=(0,i.useState)(!1);if((0,i.useEffect)(()=>{if(e){p(!0);let e=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>h(!0))});return()=>window.cancelAnimationFrame(e)}h(!1);let t=window.setTimeout(()=>p(!1),s);return()=>window.clearTimeout(t)},[e]),(0,i.useEffect)(()=>{if(!e||l)return;function n(e){e.key===`Escape`&&(document.querySelector(`[aria-haspopup="listbox"][aria-expanded="true"]`)||(e.preventDefault(),e.stopPropagation(),t()))}return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t,l]),!f)return null;let g=(0,o.jsxs)(`div`,{className:`fixed inset-0 z-60 flex justify-end`,role:`dialog`,"aria-modal":`true`,children:[(0,o.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-stone-900/30 transition-opacity duration-200 ease-out ${m?`opacity-100`:`opacity-0`}`,"aria-label":r,onClick:t}),(0,o.jsxs)(`aside`,{className:`tw-slide-over relative w-full ${c} h-full shadow-2xl border-l border-stone-200 flex flex-col transition-transform duration-200 ease-out will-change-transform ${m?`translate-x-0`:`translate-x-full`}`,children:[(0,o.jsxs)(`header`,{className:`shrink-0 h-12 px-4 border-b border-stone-100 flex items-center gap-2`,children:[(0,o.jsx)(`h2`,{className:`tw-slide-over-title text-sm font-semibold text-stone-800 flex-1`,children:n}),(0,o.jsx)(`button`,{type:`button`,onClick:t,className:`tw-icon-btn w-8 h-8 rounded-lg`,"data-hint":`关闭(Esc)`,children:`✕`})]}),(0,o.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 space-y-4`,children:u}),d]})]});return typeof document>`u`?g:(0,a.createPortal)(g,document.body)}export{c as t};
@@ -1,4 +1,4 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{E as n,f as r,i}from"./app-config.BUPzGl9f.js";import{c as a}from"./plugins.C2BMfzv1.js";import{i as o,n as s,r as c,t as l}from"./dialog.BAPTk9a_.js";import{i as ee,n as u,r as d,t as f}from"./menu.IPWdRoNM.js";import{t as p}from"./jsx-runtime.DUg_B_vD.js";import{t as m}from"./ConfirmDialog.BZzZWDci.js";import{n as h}from"./llm.BZEzE0x2.js";import{f as te}from"./project-docs.Cd2gKPKh.js";import{t as g}from"./prompts-meta.Bua-j14I.js";import{l as _}from"./settings.Ceefeil5.js";import{n as v}from"./i18n.BGPnP1Bg.js";import{a as y,c as ne,d as re,f as b,i as ie,l as ae,m as oe,n as se,o as x,p as ce,r as le,s as ue,t as de,u as fe}from"./spaces-client.BocUabwy.js";var S=e(t(),1),pe=`你是提示词作者。根据用户对这个数据空间的要求,写一份「默认提示词」正文(Markdown 纯文本,不要用代码围栏)。
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{E as n,f as r,i}from"./app-config.Cq_F8I0l.js";import{c as a}from"./plugins.CKkgnq4r.js";import{i as o,n as s,r as c,t as l}from"./dialog.DZHZCe_T.js";import{i as ee,n as u,r as d,t as f}from"./menu.Dnrpz489.js";import{t as p}from"./jsx-runtime.DUg_B_vD.js";import{t as m}from"./ConfirmDialog.CsMwWevK.js";import{n as h}from"./llm.BZEzE0x2.js";import{f as te}from"./project-docs.Cd2gKPKh.js";import{t as g}from"./prompts-meta.D_2wiFiH.js";import{l as _}from"./settings.HM3DiNh0.js";import{n as v}from"./i18n.DPw-aTIZ.js";import{a as y,c as ne,d as re,f as b,i as ie,l as ae,m as oe,n as se,o as x,p as ce,r as le,s as ue,t as de,u as fe}from"./spaces-client.CWqBZccW.js";var S=e(t(),1),pe=`你是提示词作者。根据用户对这个数据空间的要求,写一份「默认提示词」正文(Markdown 纯文本,不要用代码围栏)。
2
2
  这份提示词将作为 Lantern Harness 该空间里 AI 助手的默认人设与回答原则。
3
3
  要求:
4
4
  - 用「你是…」起头设定角色;
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.BUPzGl9f.js";import{i as r,o as i,s as ee}from"./plugins.C2BMfzv1.js";import{a,n as o,o as s,r as c}from"./view-prefs.BEAZRcxF.js";import{i as l,n as u,r as d,t as f}from"./dialog.BAPTk9a_.js";import{t as p}from"./jsx-runtime.DUg_B_vD.js";import{t as m}from"./ConfirmDialog.BZzZWDci.js";import{n as h,t as g}from"./ColumnResize.BEkEW7qw.js";import{t as _}from"./DatePicker.Bkl71M49.js";import{t as v}from"./SelectDropdown.CuuDHa8s.js";import{A as y,C as b,D as x,P as te,a as S,b as C,c as w,f as ne,g as T,h as re,i as E,m as D,n as O,o as ie,p as ae,r as oe,s as se,t as k,u as ce}from"./tasks.otRBFydq.js";import{a as A,l as j,n as M,o as N,r as P,s as F,t as I}from"./DrawerField.CHRg77LG.js";var L=e(t(),1),R=p(),le=8e3,z=[{key:`title`,min:200},{key:`status`,width:104,min:80},{key:`priority`,width:104,min:88},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`cycle`,width:76,min:60},{key:`todos`,width:84,min:68},{key:`progress`,width:132,min:104},{key:`note`,width:140,min:88},{key:`action`,width:56,min:52}],ue={pool:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,closed:`bg-stone-100 text-stone-400`,cancelled:`bg-stone-100 text-stone-400 line-through`},de={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},B={pending:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},V={pool:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,closed:`bg-stone-300`,cancelled:`bg-stone-300`},H={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},U=oe.map(e=>({value:e,label:E[e]})),fe=[{value:``,label:`未设置`},...k.map(e=>({value:e,label:O[e]}))],pe=[{value:`all`,label:`全部优先级`},...k.map(e=>({value:e,label:O[e]}))],me=[{value:`all`,label:`全部`},{value:`pool`,label:`任务池`},{value:`in_progress`,label:`进行中`},{value:`done`,label:`已完成`},{value:`closed`,label:`已关闭`},{value:`cancelled`,label:`已取消`}],he=[`all`,`pool`,`in_progress`,`done`,`closed`,`cancelled`],ge=`tasks.status-tab`,_e=`tasks.priority-filter`,ve=`tasks.search`,ye=pe.map(e=>e.value);function W(e){return(0,R.jsxs)(`div`,{"data-tone":e.tone,className:`tw-stat-card flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-3 ${e.tone===`urgent`?`border-red-100 bg-red-50/60`:`border-stone-200 bg-white`}`,children:[(0,R.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums ${e.tone===`urgent`?`text-[#c02a26]`:`text-stone-900`}`,children:e.value}),(0,R.jsx)(`span`,{className:`truncate text-xs text-stone-500`,children:e.label})]})}function be(e){let{open:t,task:n,todos:r,onClose:i,onSaved:ee}=e,[a,o]=(0,L.useState)({title:``}),[s,c]=(0,L.useState)(``),[p,m]=(0,L.useState)(!1);(0,L.useEffect)(()=>{t&&(c(``),m(!1),o(n?{title:n.title,status:n.status,priority:n.priority,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pool`,priority:``,startDate:y(),dueDate:y()}))},[t,n]);function h(e){o(t=>({...t,...e}))}let g=D({startDate:a.startDate??``,dueDate:a.dueDate??``}),v=n?r.filter(e=>e.taskId===n.id):[],x=v.filter(e=>e.status===`done`).length,te=v.length?Math.round(x/v.length*100):0;async function w(){let e=(a.title??``).trim();if(!e)c(`请填写任务名称`);else if(a.startDate&&a.dueDate&&a.dueDate<a.startDate)c(`截止日期不能早于开始日期`);else{m(!0),c(``);try{n?await T(n.id,a):await S([{...a,title:e}],{mode:`manual`}),await ee(),i()}catch(e){c(e instanceof Error?e.message:String(e))}finally{m(!1)}}}return(0,R.jsxs)(d,{open:t,onClose:i,transition:!0,className:`relative z-100`,children:[(0,R.jsx)(f,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,R.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,R.jsxs)(l,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,R.jsx)(u,{className:`text-base font-semibold text-stone-900`,children:n?`任务详情`:`新建任务`}),(0,R.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,R.jsx)(M,{icon:(0,R.jsx)(j,{}),label:`任务名称`,children:(0,R.jsx)(`input`,{autoFocus:!0,value:a.title,onChange:e=>h({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),w())},placeholder:`请输入内容`,className:I})}),(0,R.jsx)(M,{icon:(0,R.jsx)(F,{}),label:`任务状态`,children:(0,R.jsx)(P,{ariaLabel:`任务状态`,menuMinWidth:140,options:U,value:a.status??`pool`,onChange:e=>h({status:e}),label:E[a.status??`pool`],optionDotClassName:e=>V[e]})}),(0,R.jsx)(M,{icon:(0,R.jsx)(F,{}),label:`紧急程度`,children:(0,R.jsx)(P,{ariaLabel:`紧急程度`,menuMinWidth:140,options:fe,value:a.priority??``,onChange:e=>h({priority:e}),label:a.priority?O[a.priority]:`未设置`,optionDotClassName:e=>H[e]})}),(0,R.jsx)(M,{icon:(0,R.jsx)(A,{}),label:`开始日期`,children:(0,R.jsx)(_,{value:a.startDate??``,onChange:e=>h({startDate:e}),className:`${I} tabular-nums`})}),(0,R.jsx)(M,{icon:(0,R.jsx)(A,{}),label:`截止日期`,children:(0,R.jsx)(_,{value:a.dueDate??``,onChange:e=>h({dueDate:e}),className:`${I} tabular-nums`})}),(0,R.jsx)(M,{icon:(0,R.jsx)(N,{}),label:`任务周期`,children:(0,R.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:g===null?`—`:`${g} 天`})}),(0,R.jsx)(M,{icon:(0,R.jsx)(N,{}),label:`待办进度`,children:(0,R.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:v.length?`${x}/${v.length} · ${te}%`:`还没有关联待办`})}),(0,R.jsx)(M,{icon:(0,R.jsx)(j,{}),label:`备注`,children:(0,R.jsx)(`textarea`,{value:a.note??``,onChange:e=>h({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),n&&v.length?(0,R.jsxs)(`div`,{className:`mx-6 mt-2 rounded-lg border border-stone-100 bg-stone-50/60 px-3 py-2`,children:[(0,R.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-stone-500`,children:`关联待办`}),(0,R.jsx)(`ul`,{className:`space-y-1.5`,children:v.map(e=>{let t=b(e,y());return(0,R.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-stone-700`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,R.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${B[t]}`,children:C[t]})]},e.id)})})]}):null,s?(0,R.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:s}):null]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:i,disabled:p,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void w(),disabled:p,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:p?`保存中…`:n?`保存`:`新建`})]})]})})]})}function xe(){let[e,t]=(0,L.useState)(!1),[l,u]=(0,L.useState)(!0),[d,f]=(0,L.useState)(!0),[p,y]=(0,L.useState)(null),[b,S]=(0,L.useState)([]),[C,oe]=(0,L.useState)([]),[k,A]=(0,L.useState)(null),[j,M]=(0,L.useState)(!1),[N,P]=(0,L.useState)(()=>c(ve)),[F,I]=(0,L.useState)(()=>o(ge,he,`all`)),[B,xe]=(0,L.useState)(()=>o(_e,ye,`all`)),[Se,G]=(0,L.useState)(null),[K,q]=(0,L.useState)(null);function Ce(e){a(ge,e),I(e)}function we(e){s(ve,e),P(e)}function Te(e){a(_e,e),xe(e)}let J=(0,L.useRef)(!0),Y=h(`lh:tasks:cols:v1`,z);(0,L.useEffect)(()=>(J.current=!0,()=>{J.current=!1}),[]);let X=(0,L.useCallback)(async()=>{try{let[e,t]=await Promise.all([ce(),d?x().catch(()=>[]):Promise.resolve([])]);if(!J.current)return;S(e),oe(t),A(null)}catch(e){if(!J.current)return;A(e instanceof Error?e.message:String(e))}},[d]);(0,L.useEffect)(()=>{let e=i(e=>{u(!!e.tasks),f(!!e.todos)});return n().then(()=>{u(r(`tasks`)),f(r(`todos`)),t(!0)}),e},[]),(0,L.useEffect)(()=>{e&&l&&(async()=>{let e=await se();J.current&&(e?(await X(),J.current&&y(!0)):y(!1))})()},[e,l,X]),(0,L.useEffect)(()=>{if(p!==!0)return;let e=window.setInterval(()=>void X(),le),t=()=>void X();return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[p,X]);let Ee=(0,L.useMemo)(()=>re(C),[C]),Z=(0,L.useMemo)(()=>ae(b),[b]),De=(0,L.useMemo)(()=>w(b,{status:F,priority:B,keyword:N}),[b,F,B,N]),Q=(0,L.useMemo)(()=>ne(De),[De]);async function $(e,t){S(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await T(e,t);if(!J.current)return;S(t=>t.map(t=>t.id===e?n:t)),A(null)}catch(e){A(e instanceof Error?e.message:String(e)),await X()}}async function Oe(){let e=K;if(e){q(null),M(!0);try{await ie([e.id]),await Promise.all(C.filter(t=>t.taskId===e.id).map(e=>te(e.id,{taskId:``,linkedTask:``}).catch(()=>null))),await X()}catch(e){A(e instanceof Error?e.message:String(e))}finally{J.current&&M(!1)}}}return e?l?p===null?(0,R.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接任务服务`,children:(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,R.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):p?(0,R.jsxs)(`section`,{className:`flex min-h-0 flex-col gap-4`,children:[(0,R.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-7`,children:[(0,R.jsx)(W,{label:`全部任务`,value:Z.total}),(0,R.jsx)(W,{label:`任务池`,value:Z.pool}),(0,R.jsx)(W,{label:`进行中`,value:Z.in_progress}),(0,R.jsx)(W,{label:`已完成`,value:Z.done}),(0,R.jsx)(W,{label:`已关闭`,value:Z.closed}),(0,R.jsx)(W,{label:`已取消`,value:Z.cancelled}),(0,R.jsx)(W,{label:`需要紧急`,value:Z.urgent,tone:`urgent`})]}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-4 py-3`,children:[(0,R.jsx)(`input`,{value:N,onChange:e=>we(e.target.value),placeholder:`搜索任务…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,R.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:me.map(e=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>Ce(e.value),className:`h-8 rounded-md px-3 text-sm transition-colors ${F===e.value?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:e.label},e.value))}),(0,R.jsx)(v,{flat:!0,className:`w-[136px]`,ariaLabel:`优先级筛选`,options:pe,value:B,onChange:e=>Te(e)}),(0,R.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>void X(),"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800`,children:(0,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,R.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,R.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,R.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>G({task:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建任务`})]})]}),k?(0,R.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1`,children:k}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>A(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,R.jsxs)(`table`,{className:`tw-task-table w-full table-fixed border-collapse text-sm`,style:Y.tableStyle,children:[(0,R.jsx)(`colgroup`,{children:z.map(e=>(0,R.jsx)(`col`,{style:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,R.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsxs)(`th`,{className:`relative px-3 py-2 text-left font-medium whitespace-nowrap`,children:[`任务描述`,(0,R.jsx)(g,{...Y.resizeProps(0)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务状态`,(0,R.jsx)(g,{...Y.resizeProps(1)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,R.jsx)(g,{...Y.resizeProps(2)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,R.jsx)(g,{...Y.resizeProps(3)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,R.jsx)(g,{...Y.resizeProps(4)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务周期`,(0,R.jsx)(g,{...Y.resizeProps(5)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办数量`,(0,R.jsx)(g,{...Y.resizeProps(6)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`完成进度`,(0,R.jsx)(g,{...Y.resizeProps(7)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,R.jsx)(g,{...Y.resizeProps(8)})]}),(0,R.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,R.jsxs)(`tbody`,{children:[Q.map(e=>{let t=D(e),n=Ee[e.id]??{total:0,done:0,percent:0};return(0,R.jsxs)(`tr`,{className:`group/row border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,R.jsx)(`td`,{className:`px-3 py-1 align-middle`,children:(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.source===`ai`?(0,R.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,children:`AI`}):null,(0,R.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),className:`min-w-0 truncate rounded-md px-1.5 py-1 text-left text-sm text-stone-800 hover:bg-stone-100`,children:e.title})]})}),(0,R.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,R.jsx)(v,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:U,value:e.status,onChange:t=>void $(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ue[e.status]}`,renderTrigger:()=>(0,R.jsx)(`span`,{className:`w-full truncate text-center`,children:E[e.status]}),renderOptionPrefix:e=>(0,R.jsx)(`span`,{className:`h-2 w-2 rounded-full ${V[e.value]}`})})}),(0,R.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,R.jsx)(v,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:fe,value:e.priority,onChange:t=>void $(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${de[e.priority]}`,renderTrigger:()=>(0,R.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?O[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,R.jsx)(`span`,{className:`h-2 w-2 rounded-full ${H[e.value]}`})})}),(0,R.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,R.jsx)(_,{value:e.startDate,onChange:t=>void $(e.id,{startDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,R.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,R.jsx)(_,{value:e.dueDate,onChange:t=>void $(e.id,{dueDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,R.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:t===null?`—`:`${t} 天`}),(0,R.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-500 tabular-nums`,children:d?n.total?`${n.total} 条`:`0`:(0,R.jsx)(`span`,{className:`whitespace-nowrap text-stone-400`,children:`待办事项未启用`})}),(0,R.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:d?(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,R.jsx)(`span`,{className:`block h-full rounded-full bg-[#3370ff] transition-[width]`,style:{width:`${n.percent}%`}})}),(0,R.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs text-stone-500 tabular-nums`,children:[n.percent,`%`]})]}):(0,R.jsx)(`span`,{className:`whitespace-nowrap text-xs text-stone-400`,children:`待办事项未启用`})}),(0,R.jsx)(`td`,{className:`truncate px-2 py-1 align-middle text-xs text-stone-500`,children:e.note||`—`}),(0,R.jsx)(`td`,{className:`px-1 py-1 text-right align-middle`,children:(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,R.jsx)(`path`,{d:`M14 4h6v6`}),(0,R.jsx)(`path`,{d:`M20 4 13 11`}),(0,R.jsx)(`path`,{d:`M10 20H4v-6`}),(0,R.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,R.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>q(e),"aria-label":`删除 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:(0,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,R.jsx)(`path`,{d:`M3 6h18`}),(0,R.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,R.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,R.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),Q.length===0?(0,R.jsx)(`tr`,{children:(0,R.jsx)(`td`,{colSpan:10,className:`px-3 py-16 text-center text-sm text-stone-400`,children:b.length===0?`还没有任务`:`没有匹配的任务,试试调整搜索或筛选`})}):null]})]})}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,R.jsxs)(`span`,{children:[`共 `,Q.length,` 条`]}),(0,R.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`任务下关联的待办可直接在「待办事项」里维护`})]})]}),(0,R.jsx)(be,{open:Se!==null,task:Se?.task??null,todos:C,onClose:()=>G(null),onSaved:X}),(0,R.jsx)(m,{open:K!=null,title:`删除任务`,message:`删除「${K?.title??``}」?已关联的待办会保留,但不再挂在该任务下。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>q(null),onConfirm:()=>void Oe()})]}):(0,R.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`任务管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,R.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:ee(`tasks`)}):(0,R.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,R.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{xe as default};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.Cq_F8I0l.js";import{i as r,o as i,s as ee}from"./plugins.CKkgnq4r.js";import{a,n as o,o as s,r as c}from"./view-prefs.7wGuDpzi.js";import{i as l,n as u,r as d,t as f}from"./dialog.DZHZCe_T.js";import{t as p}from"./jsx-runtime.DUg_B_vD.js";import{t as m}from"./ConfirmDialog.CsMwWevK.js";import{n as h,t as g}from"./ColumnResize.BEkEW7qw.js";import{t as _}from"./DatePicker.Bkl71M49.js";import{t as v}from"./SelectDropdown.B3-XpBpn.js";import{A as y,C as b,D as x,P as te,a as S,b as C,c as w,f as ne,g as T,h as re,i as E,m as D,n as O,o as ie,p as ae,r as oe,s as se,t as k,u as ce}from"./tasks.otRBFydq.js";import{a as A,l as j,n as M,o as N,r as P,s as F,t as I}from"./DrawerField.DqvXFCFh.js";var L=e(t(),1),R=p(),le=8e3,z=[{key:`title`,min:200},{key:`status`,width:104,min:80},{key:`priority`,width:104,min:88},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`cycle`,width:76,min:60},{key:`todos`,width:84,min:68},{key:`progress`,width:132,min:104},{key:`note`,width:140,min:88},{key:`action`,width:56,min:52}],ue={pool:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,closed:`bg-stone-100 text-stone-400`,cancelled:`bg-stone-100 text-stone-400 line-through`},de={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},B={pending:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},V={pool:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,closed:`bg-stone-300`,cancelled:`bg-stone-300`},H={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},U=oe.map(e=>({value:e,label:E[e]})),fe=[{value:``,label:`未设置`},...k.map(e=>({value:e,label:O[e]}))],pe=[{value:`all`,label:`全部优先级`},...k.map(e=>({value:e,label:O[e]}))],me=[{value:`all`,label:`全部`},{value:`pool`,label:`任务池`},{value:`in_progress`,label:`进行中`},{value:`done`,label:`已完成`},{value:`closed`,label:`已关闭`},{value:`cancelled`,label:`已取消`}],he=[`all`,`pool`,`in_progress`,`done`,`closed`,`cancelled`],ge=`tasks.status-tab`,_e=`tasks.priority-filter`,ve=`tasks.search`,ye=pe.map(e=>e.value);function W(e){return(0,R.jsxs)(`div`,{"data-tone":e.tone,className:`tw-stat-card flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-3 ${e.tone===`urgent`?`border-red-100 bg-red-50/60`:`border-stone-200 bg-white`}`,children:[(0,R.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums ${e.tone===`urgent`?`text-[#c02a26]`:`text-stone-900`}`,children:e.value}),(0,R.jsx)(`span`,{className:`truncate text-xs text-stone-500`,children:e.label})]})}function be(e){let{open:t,task:n,todos:r,onClose:i,onSaved:ee}=e,[a,o]=(0,L.useState)({title:``}),[s,c]=(0,L.useState)(``),[p,m]=(0,L.useState)(!1);(0,L.useEffect)(()=>{t&&(c(``),m(!1),o(n?{title:n.title,status:n.status,priority:n.priority,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pool`,priority:``,startDate:y(),dueDate:y()}))},[t,n]);function h(e){o(t=>({...t,...e}))}let g=D({startDate:a.startDate??``,dueDate:a.dueDate??``}),v=n?r.filter(e=>e.taskId===n.id):[],x=v.filter(e=>e.status===`done`).length,te=v.length?Math.round(x/v.length*100):0;async function w(){let e=(a.title??``).trim();if(!e)c(`请填写任务名称`);else if(a.startDate&&a.dueDate&&a.dueDate<a.startDate)c(`截止日期不能早于开始日期`);else{m(!0),c(``);try{n?await T(n.id,a):await S([{...a,title:e}],{mode:`manual`}),await ee(),i()}catch(e){c(e instanceof Error?e.message:String(e))}finally{m(!1)}}}return(0,R.jsxs)(d,{open:t,onClose:i,transition:!0,className:`relative z-100`,children:[(0,R.jsx)(f,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,R.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,R.jsxs)(l,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,R.jsx)(u,{className:`text-base font-semibold text-stone-900`,children:n?`任务详情`:`新建任务`}),(0,R.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,R.jsx)(M,{icon:(0,R.jsx)(j,{}),label:`任务名称`,children:(0,R.jsx)(`input`,{autoFocus:!0,value:a.title,onChange:e=>h({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),w())},placeholder:`请输入内容`,className:I})}),(0,R.jsx)(M,{icon:(0,R.jsx)(F,{}),label:`任务状态`,children:(0,R.jsx)(P,{ariaLabel:`任务状态`,menuMinWidth:140,options:U,value:a.status??`pool`,onChange:e=>h({status:e}),label:E[a.status??`pool`],optionDotClassName:e=>V[e]})}),(0,R.jsx)(M,{icon:(0,R.jsx)(F,{}),label:`紧急程度`,children:(0,R.jsx)(P,{ariaLabel:`紧急程度`,menuMinWidth:140,options:fe,value:a.priority??``,onChange:e=>h({priority:e}),label:a.priority?O[a.priority]:`未设置`,optionDotClassName:e=>H[e]})}),(0,R.jsx)(M,{icon:(0,R.jsx)(A,{}),label:`开始日期`,children:(0,R.jsx)(_,{value:a.startDate??``,onChange:e=>h({startDate:e}),className:`${I} tabular-nums`})}),(0,R.jsx)(M,{icon:(0,R.jsx)(A,{}),label:`截止日期`,children:(0,R.jsx)(_,{value:a.dueDate??``,onChange:e=>h({dueDate:e}),className:`${I} tabular-nums`})}),(0,R.jsx)(M,{icon:(0,R.jsx)(N,{}),label:`任务周期`,children:(0,R.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:g===null?`—`:`${g} 天`})}),(0,R.jsx)(M,{icon:(0,R.jsx)(N,{}),label:`待办进度`,children:(0,R.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:v.length?`${x}/${v.length} · ${te}%`:`还没有关联待办`})}),(0,R.jsx)(M,{icon:(0,R.jsx)(j,{}),label:`备注`,children:(0,R.jsx)(`textarea`,{value:a.note??``,onChange:e=>h({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),n&&v.length?(0,R.jsxs)(`div`,{className:`mx-6 mt-2 rounded-lg border border-stone-100 bg-stone-50/60 px-3 py-2`,children:[(0,R.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-stone-500`,children:`关联待办`}),(0,R.jsx)(`ul`,{className:`space-y-1.5`,children:v.map(e=>{let t=b(e,y());return(0,R.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-stone-700`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,R.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${B[t]}`,children:C[t]})]},e.id)})})]}):null,s?(0,R.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:s}):null]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:i,disabled:p,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void w(),disabled:p,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:p?`保存中…`:n?`保存`:`新建`})]})]})})]})}function xe(){let[e,t]=(0,L.useState)(!1),[l,u]=(0,L.useState)(!0),[d,f]=(0,L.useState)(!0),[p,y]=(0,L.useState)(null),[b,S]=(0,L.useState)([]),[C,oe]=(0,L.useState)([]),[k,A]=(0,L.useState)(null),[j,M]=(0,L.useState)(!1),[N,P]=(0,L.useState)(()=>c(ve)),[F,I]=(0,L.useState)(()=>o(ge,he,`all`)),[B,xe]=(0,L.useState)(()=>o(_e,ye,`all`)),[Se,G]=(0,L.useState)(null),[K,q]=(0,L.useState)(null);function Ce(e){a(ge,e),I(e)}function we(e){s(ve,e),P(e)}function Te(e){a(_e,e),xe(e)}let J=(0,L.useRef)(!0),Y=h(`lh:tasks:cols:v1`,z);(0,L.useEffect)(()=>(J.current=!0,()=>{J.current=!1}),[]);let X=(0,L.useCallback)(async()=>{try{let[e,t]=await Promise.all([ce(),d?x().catch(()=>[]):Promise.resolve([])]);if(!J.current)return;S(e),oe(t),A(null)}catch(e){if(!J.current)return;A(e instanceof Error?e.message:String(e))}},[d]);(0,L.useEffect)(()=>{let e=i(e=>{u(!!e.tasks),f(!!e.todos)});return n().then(()=>{u(r(`tasks`)),f(r(`todos`)),t(!0)}),e},[]),(0,L.useEffect)(()=>{e&&l&&(async()=>{let e=await se();J.current&&(e?(await X(),J.current&&y(!0)):y(!1))})()},[e,l,X]),(0,L.useEffect)(()=>{if(p!==!0)return;let e=window.setInterval(()=>void X(),le),t=()=>void X();return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[p,X]);let Ee=(0,L.useMemo)(()=>re(C),[C]),Z=(0,L.useMemo)(()=>ae(b),[b]),De=(0,L.useMemo)(()=>w(b,{status:F,priority:B,keyword:N}),[b,F,B,N]),Q=(0,L.useMemo)(()=>ne(De),[De]);async function $(e,t){S(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await T(e,t);if(!J.current)return;S(t=>t.map(t=>t.id===e?n:t)),A(null)}catch(e){A(e instanceof Error?e.message:String(e)),await X()}}async function Oe(){let e=K;if(e){q(null),M(!0);try{await ie([e.id]),await Promise.all(C.filter(t=>t.taskId===e.id).map(e=>te(e.id,{taskId:``,linkedTask:``}).catch(()=>null))),await X()}catch(e){A(e instanceof Error?e.message:String(e))}finally{J.current&&M(!1)}}}return e?l?p===null?(0,R.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接任务服务`,children:(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,R.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):p?(0,R.jsxs)(`section`,{className:`flex min-h-0 flex-col gap-4`,children:[(0,R.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-7`,children:[(0,R.jsx)(W,{label:`全部任务`,value:Z.total}),(0,R.jsx)(W,{label:`任务池`,value:Z.pool}),(0,R.jsx)(W,{label:`进行中`,value:Z.in_progress}),(0,R.jsx)(W,{label:`已完成`,value:Z.done}),(0,R.jsx)(W,{label:`已关闭`,value:Z.closed}),(0,R.jsx)(W,{label:`已取消`,value:Z.cancelled}),(0,R.jsx)(W,{label:`需要紧急`,value:Z.urgent,tone:`urgent`})]}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-4 py-3`,children:[(0,R.jsx)(`input`,{value:N,onChange:e=>we(e.target.value),placeholder:`搜索任务…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,R.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:me.map(e=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>Ce(e.value),className:`h-8 rounded-md px-3 text-sm transition-colors ${F===e.value?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:e.label},e.value))}),(0,R.jsx)(v,{flat:!0,className:`w-[136px]`,ariaLabel:`优先级筛选`,options:pe,value:B,onChange:e=>Te(e)}),(0,R.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>void X(),"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800`,children:(0,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,R.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,R.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,R.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>G({task:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建任务`})]})]}),k?(0,R.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1`,children:k}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>A(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,R.jsxs)(`table`,{className:`tw-task-table w-full table-fixed border-collapse text-sm`,style:Y.tableStyle,children:[(0,R.jsx)(`colgroup`,{children:z.map(e=>(0,R.jsx)(`col`,{style:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,R.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsxs)(`th`,{className:`relative px-3 py-2 text-left font-medium whitespace-nowrap`,children:[`任务描述`,(0,R.jsx)(g,{...Y.resizeProps(0)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务状态`,(0,R.jsx)(g,{...Y.resizeProps(1)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,R.jsx)(g,{...Y.resizeProps(2)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,R.jsx)(g,{...Y.resizeProps(3)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,R.jsx)(g,{...Y.resizeProps(4)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务周期`,(0,R.jsx)(g,{...Y.resizeProps(5)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办数量`,(0,R.jsx)(g,{...Y.resizeProps(6)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`完成进度`,(0,R.jsx)(g,{...Y.resizeProps(7)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,R.jsx)(g,{...Y.resizeProps(8)})]}),(0,R.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,R.jsxs)(`tbody`,{children:[Q.map(e=>{let t=D(e),n=Ee[e.id]??{total:0,done:0,percent:0};return(0,R.jsxs)(`tr`,{className:`group/row border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,R.jsx)(`td`,{className:`px-3 py-1 align-middle`,children:(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.source===`ai`?(0,R.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,children:`AI`}):null,(0,R.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),className:`min-w-0 truncate rounded-md px-1.5 py-1 text-left text-sm text-stone-800 hover:bg-stone-100`,children:e.title})]})}),(0,R.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,R.jsx)(v,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:U,value:e.status,onChange:t=>void $(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ue[e.status]}`,renderTrigger:()=>(0,R.jsx)(`span`,{className:`w-full truncate text-center`,children:E[e.status]}),renderOptionPrefix:e=>(0,R.jsx)(`span`,{className:`h-2 w-2 rounded-full ${V[e.value]}`})})}),(0,R.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,R.jsx)(v,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:fe,value:e.priority,onChange:t=>void $(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${de[e.priority]}`,renderTrigger:()=>(0,R.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?O[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,R.jsx)(`span`,{className:`h-2 w-2 rounded-full ${H[e.value]}`})})}),(0,R.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,R.jsx)(_,{value:e.startDate,onChange:t=>void $(e.id,{startDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,R.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,R.jsx)(_,{value:e.dueDate,onChange:t=>void $(e.id,{dueDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,R.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:t===null?`—`:`${t} 天`}),(0,R.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-500 tabular-nums`,children:d?n.total?`${n.total} 条`:`0`:(0,R.jsx)(`span`,{className:`whitespace-nowrap text-stone-400`,children:`待办事项未启用`})}),(0,R.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:d?(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,R.jsx)(`span`,{className:`block h-full rounded-full bg-[#3370ff] transition-[width]`,style:{width:`${n.percent}%`}})}),(0,R.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs text-stone-500 tabular-nums`,children:[n.percent,`%`]})]}):(0,R.jsx)(`span`,{className:`whitespace-nowrap text-xs text-stone-400`,children:`待办事项未启用`})}),(0,R.jsx)(`td`,{className:`truncate px-2 py-1 align-middle text-xs text-stone-500`,children:e.note||`—`}),(0,R.jsx)(`td`,{className:`px-1 py-1 text-right align-middle`,children:(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,R.jsx)(`path`,{d:`M14 4h6v6`}),(0,R.jsx)(`path`,{d:`M20 4 13 11`}),(0,R.jsx)(`path`,{d:`M10 20H4v-6`}),(0,R.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,R.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>q(e),"aria-label":`删除 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:(0,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,R.jsx)(`path`,{d:`M3 6h18`}),(0,R.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,R.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,R.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),Q.length===0?(0,R.jsx)(`tr`,{children:(0,R.jsx)(`td`,{colSpan:10,className:`px-3 py-16 text-center text-sm text-stone-400`,children:b.length===0?`还没有任务`:`没有匹配的任务,试试调整搜索或筛选`})}):null]})]})}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,R.jsxs)(`span`,{children:[`共 `,Q.length,` 条`]}),(0,R.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`任务下关联的待办可直接在「待办事项」里维护`})]})]}),(0,R.jsx)(be,{open:Se!==null,task:Se?.task??null,todos:C,onClose:()=>G(null),onSaved:X}),(0,R.jsx)(m,{open:K!=null,title:`删除任务`,message:`删除「${K?.title??``}」?已关联的待办会保留,但不再挂在该任务下。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>q(null),onConfirm:()=>void Oe()})]}):(0,R.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`任务管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,R.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:ee(`tasks`)}):(0,R.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,R.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{xe as default};
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.BUPzGl9f.js";import{i as r,o as i,s as a}from"./plugins.C2BMfzv1.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./ConfirmDialog.BZzZWDci.js";import{n as c,t as ee}from"./DocsPager.DJY4foYL.js";import{a as l,i as u,r as d,t as te}from"./ExcelFieldTags.DXMeaDa5.js";import{a as ne,c as re,d as f,f as p,h as ie,i as ae,l as oe,m as se,n as ce,o as le,p as ue,r as de,s as m,t as fe,u as pe}from"./project-docs.Cd2gKPKh.js";import{n as me}from"./doc-roots.DAJP9Svr.js";import{t as he}from"./useListAnim.BoerpmsB.js";import{t as h}from"./NamePromptDialog.Wa9O530a.js";var g=e(t(),1),_=o(),ge=5;async function _e(e){let t=e.name.toLowerCase();try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await f(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64)return l(t.contentBase64).headers}else if(t.endsWith(`.csv`)){let t=await p(`templates`,e.path);return d(t.content).headers}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await p(`templates`,e.path);return u(t.content).headers}}catch{}return[]}function v({className:e=`w-4 h-4`,open:t=!1}){return(0,_.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,_.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,_.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function y({className:e=`w-3 h-3`}){return(0,_.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,_.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,_.jsx)(`path`,{d:`m15 5 4 4`})]})}function b({className:e=`w-3 h-3`}){return(0,_.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,_.jsx)(`path`,{d:`M3 6h18`}),(0,_.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,_.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,_.jsx)(`path`,{d:`M10 11v6`}),(0,_.jsx)(`path`,{d:`M14 11v6`})]})}function x({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,_.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,_.jsx)(v,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,_.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,_.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,_.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,_.jsx)(x,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function S(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function C(){let[e,t]=(0,g.useState)(()=>r(`templates`)),[o,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)([]),[C,ve]=(0,g.useState)(0),[w,T]=(0,g.useState)(`.`),[E,D]=(0,g.useState)([]),[ye,be]=(0,g.useState)({}),[xe,O]=(0,g.useState)({}),[k,Se]=(0,g.useState)(!0),[A,j]=(0,g.useState)(null),[M,N]=(0,g.useState)(!1),[Ce,P]=(0,g.useState)(!1),[F,I]=(0,g.useState)(null),[L,R]=(0,g.useState)(null),[we,z]=(0,g.useState)(1),[B,Te]=c(ge),[Ee,V]=(0,g.useState)(null),H=(0,g.useRef)(null),{cls:De,play:U}=he(),W=(0,g.useCallback)(async e=>{let t={};await Promise.all(e.map(async e=>{let n=await _e(e);n.length&&(t[e.path]=n)})),be(t)},[]),G=(0,g.useCallback)(async()=>{let e=await ae(`templates`);p(e.tree),ve(e.totalFiles)},[]),K=(0,g.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([m(`templates`,e),G()]);D(t.entries),T(t.path);let n=t.entries.filter(e=>e.type===`file`);await W(n)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,W,G]);(0,g.useEffect)(()=>{let e=i(e=>t(!!e.templates));return n().then(()=>{t(r(`templates`)),l(!0)}),e},[]),(0,g.useEffect)(()=>{o&&e&&(async()=>{let e=await de(`templates`);if(d(e),e)try{let[e]=await Promise.all([m(`templates`,`.`),G()]);D(e.entries),T(e.path),await W(e.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}})()},[o,e,W,G]);function Oe(){Se(e=>!e),O({})}async function q(e){U(),T(e),z(1),V(null),j(null);try{let t=await m(`templates`,e);D(t.entries),await W(t.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}}async function ke(e){P(!1),N(!0),j(null);try{await re(`templates`,w,e),await K(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}async function Ae(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await ie(`templates`,w,t);await K(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1),H.current&&(H.current.value=``)}}}async function je(e){if(e.type===`file`){N(!0),j(null);try{await oe(`templates`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}function Me(e){let t=ne(f,e.path),n=t?.fileCount??0,r=t?fe(t):0;I({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function Ne(e){I({name:e.name,path:e.path,isDir:!1})}function J(e,t){R({...e,isDir:t})}async function Y(){let e=F;if(e&&(I(null),!e.blocked)){N(!0),j(null);try{await ce(`templates`,e.path);let t=le(w,e.path)?pe(e.path):w;await K(t)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function Pe(e){let t=L;if(t&&(R(null),e!==t.name)){N(!0),j(null);try{let n=await se(`templates`,t.path,e);await K(ue(w,t.path,n))}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}let Fe=(()=>{if(!F)return``;if(!F.isDir)return`删除文件「${F.name}」?将移入系统废纸篓,可随时找回。`;if(F.blocked){let e=[];return F.files&&e.push(`${F.files} 个文件`),F.dirs&&e.push(`${F.dirs} 个子文件夹`),`文件夹「${F.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${F.name}」?将移入系统废纸篓。`})();if(!o)return(0,_.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,_.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,_.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:a(`templates`)});if(u===null)return(0,_.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,_.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!u)return(0,_.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`模板库需要本地文档服务,当前未就绪。`});let X=E.filter(e=>e.type===`file`),Z=E.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/B)),$=Math.min(we,Q),Ie=X.slice(($-1)*B,$*B);function Le(e){U(),Te(e),z(1)}return(0,_.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,_.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,_.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,_.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>P(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,_.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{q(`.`),Oe()},"aria-expanded":k,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${w===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,_.jsx)(v,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部模板`}),(0,_.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,C,`)`]})]})}),(0,_.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,_.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:f.map(e=>(0,_.jsx)(x,{node:e,depth:0,activePath:w,expanded:xe,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void q(e)},e.path))})})]})]}),(0,_.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,_.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,_.jsx)(`span`,{className:`text-stone-400`,children:me(`templates`)}),w===`.`?``:w]}),(0,_.jsx)(`input`,{ref:H,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,className:`hidden`,onChange:e=>void Ae(e.target.files)}),(0,_.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>H.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),A?(0,_.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:A}):null,(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,_.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,_.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void q(e.path),children:[(0,_.jsx)(v,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>J({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,_.jsx)(y,{className:`w-3.5 h-3.5`})}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Me({name:e.name,path:e.path}),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,_.jsx)(b,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,_.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加模板(.md / .xlsx / .docx 等)`}):(0,_.jsx)(`ul`,{className:`${De}space-y-1`,children:Ie.map(e=>{let t=ye[e.path]??[],n=Ee===e.path;return(0,_.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2 rounded-lg border transition-colors ${n?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,disabled:M,onClick:()=>V(e.path),onDoubleClick:()=>void je(e),children:[(0,_.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,_.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:S(e.size)}),t.length>0?(0,_.jsx)(te,{fields:t}):null]}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>J({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40 shrink-0 mt-0.5`,children:(0,_.jsx)(y,{className:`w-3.5 h-3.5`})}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Ne(e),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40 shrink-0 mt-0.5`,children:(0,_.jsx)(b,{className:`w-3.5 h-3.5`})})]},e.path)})})]})]}),X.length>0?(0,_.jsx)(ee,{page:$,totalPages:Q,pageSize:B,busy:M,onPage:e=>{U(),z(e)},onPageSize:Le}):null]}),(0,_.jsx)(h,{open:Ce,title:`新建文件夹`,onClose:()=>P(!1),onConfirm:e=>void ke(e)}),(0,_.jsx)(h,{open:L!=null,title:L?.isDir?`重命名文件夹`:`重命名文件`,label:L?.isDir?`文件夹名称`:`文件名称`,initialValue:L?.name??``,lockExtension:L!=null&&!L.isDir,confirmLabel:`保存`,onClose:()=>R(null),onConfirm:e=>void Pe(e)}),(0,_.jsx)(s,{open:F!=null,title:F?.blocked?`无法删除文件夹`:F?.isDir?`删除文件夹`:`删除模板`,message:Fe,confirmLabel:F?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!F?.blocked,hideCancel:!!F?.blocked,onClose:()=>I(null),onConfirm:()=>void Y()})]})}export{C as default};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.Cq_F8I0l.js";import{i as r,o as i,s as a}from"./plugins.CKkgnq4r.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./ConfirmDialog.CsMwWevK.js";import{n as c,t as ee}from"./DocsPager.EPT5-oEx.js";import{a as l,i as u,r as d,t as te}from"./ExcelFieldTags.De-C3dqn.js";import{a as ne,c as re,d as f,f as p,h as ie,i as ae,l as oe,m as se,n as ce,o as le,p as ue,r as de,s as m,t as fe,u as pe}from"./project-docs.Cd2gKPKh.js";import{n as me}from"./doc-roots.DAJP9Svr.js";import{t as he}from"./useListAnim.BoerpmsB.js";import{t as h}from"./NamePromptDialog.CS1pTTVl.js";var g=e(t(),1),_=o(),ge=5;async function _e(e){let t=e.name.toLowerCase();try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await f(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64)return l(t.contentBase64).headers}else if(t.endsWith(`.csv`)){let t=await p(`templates`,e.path);return d(t.content).headers}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await p(`templates`,e.path);return u(t.content).headers}}catch{}return[]}function v({className:e=`w-4 h-4`,open:t=!1}){return(0,_.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,_.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,_.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function y({className:e=`w-3 h-3`}){return(0,_.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,_.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,_.jsx)(`path`,{d:`m15 5 4 4`})]})}function b({className:e=`w-3 h-3`}){return(0,_.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,_.jsx)(`path`,{d:`M3 6h18`}),(0,_.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,_.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,_.jsx)(`path`,{d:`M10 11v6`}),(0,_.jsx)(`path`,{d:`M14 11v6`})]})}function x({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,_.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,_.jsx)(v,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,_.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,_.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,_.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,_.jsx)(x,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function S(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function C(){let[e,t]=(0,g.useState)(()=>r(`templates`)),[o,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)([]),[C,ve]=(0,g.useState)(0),[w,T]=(0,g.useState)(`.`),[E,D]=(0,g.useState)([]),[ye,be]=(0,g.useState)({}),[xe,O]=(0,g.useState)({}),[k,Se]=(0,g.useState)(!0),[A,j]=(0,g.useState)(null),[M,N]=(0,g.useState)(!1),[Ce,P]=(0,g.useState)(!1),[F,I]=(0,g.useState)(null),[L,R]=(0,g.useState)(null),[we,z]=(0,g.useState)(1),[B,Te]=c(ge),[Ee,V]=(0,g.useState)(null),H=(0,g.useRef)(null),{cls:De,play:U}=he(),W=(0,g.useCallback)(async e=>{let t={};await Promise.all(e.map(async e=>{let n=await _e(e);n.length&&(t[e.path]=n)})),be(t)},[]),G=(0,g.useCallback)(async()=>{let e=await ae(`templates`);p(e.tree),ve(e.totalFiles)},[]),K=(0,g.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([m(`templates`,e),G()]);D(t.entries),T(t.path);let n=t.entries.filter(e=>e.type===`file`);await W(n)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,W,G]);(0,g.useEffect)(()=>{let e=i(e=>t(!!e.templates));return n().then(()=>{t(r(`templates`)),l(!0)}),e},[]),(0,g.useEffect)(()=>{o&&e&&(async()=>{let e=await de(`templates`);if(d(e),e)try{let[e]=await Promise.all([m(`templates`,`.`),G()]);D(e.entries),T(e.path),await W(e.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}})()},[o,e,W,G]);function Oe(){Se(e=>!e),O({})}async function q(e){U(),T(e),z(1),V(null),j(null);try{let t=await m(`templates`,e);D(t.entries),await W(t.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}}async function ke(e){P(!1),N(!0),j(null);try{await re(`templates`,w,e),await K(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}async function Ae(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await ie(`templates`,w,t);await K(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1),H.current&&(H.current.value=``)}}}async function je(e){if(e.type===`file`){N(!0),j(null);try{await oe(`templates`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}function Me(e){let t=ne(f,e.path),n=t?.fileCount??0,r=t?fe(t):0;I({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function Ne(e){I({name:e.name,path:e.path,isDir:!1})}function J(e,t){R({...e,isDir:t})}async function Y(){let e=F;if(e&&(I(null),!e.blocked)){N(!0),j(null);try{await ce(`templates`,e.path);let t=le(w,e.path)?pe(e.path):w;await K(t)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function Pe(e){let t=L;if(t&&(R(null),e!==t.name)){N(!0),j(null);try{let n=await se(`templates`,t.path,e);await K(ue(w,t.path,n))}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}let Fe=(()=>{if(!F)return``;if(!F.isDir)return`删除文件「${F.name}」?将移入系统废纸篓,可随时找回。`;if(F.blocked){let e=[];return F.files&&e.push(`${F.files} 个文件`),F.dirs&&e.push(`${F.dirs} 个子文件夹`),`文件夹「${F.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${F.name}」?将移入系统废纸篓。`})();if(!o)return(0,_.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,_.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,_.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:a(`templates`)});if(u===null)return(0,_.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,_.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!u)return(0,_.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`模板库需要本地文档服务,当前未就绪。`});let X=E.filter(e=>e.type===`file`),Z=E.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/B)),$=Math.min(we,Q),Ie=X.slice(($-1)*B,$*B);function Le(e){U(),Te(e),z(1)}return(0,_.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,_.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,_.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,_.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>P(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,_.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{q(`.`),Oe()},"aria-expanded":k,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${w===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,_.jsx)(v,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部模板`}),(0,_.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,C,`)`]})]})}),(0,_.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,_.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:f.map(e=>(0,_.jsx)(x,{node:e,depth:0,activePath:w,expanded:xe,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void q(e)},e.path))})})]})]}),(0,_.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,_.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,_.jsx)(`span`,{className:`text-stone-400`,children:me(`templates`)}),w===`.`?``:w]}),(0,_.jsx)(`input`,{ref:H,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,className:`hidden`,onChange:e=>void Ae(e.target.files)}),(0,_.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>H.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),A?(0,_.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:A}):null,(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,_.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,_.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void q(e.path),children:[(0,_.jsx)(v,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>J({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,_.jsx)(y,{className:`w-3.5 h-3.5`})}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Me({name:e.name,path:e.path}),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,_.jsx)(b,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,_.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加模板(.md / .xlsx / .docx 等)`}):(0,_.jsx)(`ul`,{className:`${De}space-y-1`,children:Ie.map(e=>{let t=ye[e.path]??[],n=Ee===e.path;return(0,_.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2 rounded-lg border transition-colors ${n?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,disabled:M,onClick:()=>V(e.path),onDoubleClick:()=>void je(e),children:[(0,_.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,_.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:S(e.size)}),t.length>0?(0,_.jsx)(te,{fields:t}):null]}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>J({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40 shrink-0 mt-0.5`,children:(0,_.jsx)(y,{className:`w-3.5 h-3.5`})}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Ne(e),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40 shrink-0 mt-0.5`,children:(0,_.jsx)(b,{className:`w-3.5 h-3.5`})})]},e.path)})})]})]}),X.length>0?(0,_.jsx)(ee,{page:$,totalPages:Q,pageSize:B,busy:M,onPage:e=>{U(),z(e)},onPageSize:Le}):null]}),(0,_.jsx)(h,{open:Ce,title:`新建文件夹`,onClose:()=>P(!1),onConfirm:e=>void ke(e)}),(0,_.jsx)(h,{open:L!=null,title:L?.isDir?`重命名文件夹`:`重命名文件`,label:L?.isDir?`文件夹名称`:`文件名称`,initialValue:L?.name??``,lockExtension:L!=null&&!L.isDir,confirmLabel:`保存`,onClose:()=>R(null),onConfirm:e=>void Pe(e)}),(0,_.jsx)(s,{open:F!=null,title:F?.blocked?`无法删除文件夹`:F?.isDir?`删除文件夹`:`删除模板`,message:Fe,confirmLabel:F?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!F?.blocked,hideCancel:!!F?.blocked,onClose:()=>I(null),onConfirm:()=>void Y()})]})}export{C as default};