lantern-harness 0.1.14 → 0.1.15
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.
- package/CHANGELOG.md +30 -0
- package/builtin/session/lh-nav-groups.mjs +3 -0
- package/cli/server.mjs +3 -0
- package/config/app.defaults.json +2 -0
- package/dist/500.html +4 -4
- package/dist/_astro/Base.VCz1UVxQ.css +1 -0
- package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.BS3Daz5F.js → Base.astro_astro_type_script_index_0_lang.CpzwEBjx.js} +1 -1
- package/dist/_astro/CaseExecBoard.cBdsZU9e.js +1 -0
- package/dist/_astro/CaseGenerateApp.D2ftaUXT.js +9 -0
- package/dist/_astro/CasesLibrary.DWXEje9u.js +19 -0
- package/dist/_astro/ChatApp.7piDha-y.js +226 -0
- package/dist/_astro/ColumnResize.BgYkV9Iy.js +1 -0
- package/dist/_astro/{DashboardBoard.BKtXwr_n.js → DashboardBoard.BIP9es-t.js} +1 -1
- package/dist/_astro/DocsFileBrowser.-dkkxR4X.js +1 -0
- package/dist/_astro/{DocsPager.C6R2nQ60.js → DocsPager.v4kQH163.js} +1 -1
- package/dist/_astro/{DrawerField.BXWvezBs.js → DrawerField.C0ehOlDt.js} +1 -1
- package/dist/_astro/ExcelFieldTags.ytbpKt-Z.js +5 -0
- package/dist/_astro/{KnowledgeLibrary.fYr4VQkZ.js → KnowledgeLibrary.Dw-IX3Zt.js} +1 -1
- package/dist/_astro/{NavLibraries.CpnreEwA.js → NavLibraries.D1J9BwYo.js} +1 -1
- package/dist/_astro/OverflowHint.pvo2Xc8R.js +1 -0
- package/dist/_astro/PluginsPage.DMTsFl_R.js +7 -0
- package/dist/_astro/PluginsPage.DMxVKmiY.js +1 -0
- package/dist/_astro/{PmBugsBoard.ifLSqDOs.js → PmBugsBoard.BTtm1lki.js} +1 -1
- package/dist/_astro/{PmIterationsBoard.CVjphcgB.js → PmIterationsBoard.Dm67iXe_.js} +1 -1
- package/dist/_astro/{PmProjectDetail.Dudm02Xv.js → PmProjectDetail.B7oWL7y-.js} +1 -1
- package/dist/_astro/{PmProjectsBoard.CKWUrQHF.js → PmProjectsBoard.8QI44RlE.js} +1 -1
- package/dist/_astro/PmRequirementsBoard.DMJVLCqz.js +1 -0
- package/dist/_astro/PmRequirementsBoard.X98441HZ.js +1 -0
- package/dist/_astro/{PmShared.BwVlCk92.js → PmShared.DbDseTcc.js} +1 -1
- package/dist/_astro/PromptMountDialog.YH2odDZx.js +58 -0
- package/dist/_astro/PromptsLibrary.B_qFbQGi.js +1 -0
- package/dist/_astro/{ReportsPage.BKcIJsLn.js → ReportsPage.BjcajHR6.js} +1 -1
- package/dist/_astro/ReqAnalysisBoard.hwNqRyim.js +28 -0
- package/dist/_astro/{RequirementsLibrary.D5iItFfK.js → RequirementsLibrary.CGCNnQQG.js} +1 -1
- package/dist/_astro/SearchableSelect.mvcBwegf.js +1 -0
- package/dist/_astro/{SelectDropdown.DqKxIust.js → SelectDropdown.Cb-QtC-D.js} +1 -1
- package/dist/_astro/{SettingsDialog.a99Y08tE.js → SettingsDialog.CnBZRaWE.js} +1 -1
- package/dist/_astro/{SpaceSwitcher.DDGfnQBp.js → SpaceSwitcher.DMoqOVpS.js} +1 -1
- package/dist/_astro/TasksBoard.DvfyDL76.js +1 -0
- package/dist/_astro/{TemplatesLibrary.C3mqFIB0.js → TemplatesLibrary.B5KmjjFw.js} +1 -1
- package/dist/_astro/TestStatsBoard.EIDxmU_8.js +1 -0
- package/dist/_astro/TodosBoard.7IptYUFY.js +1 -0
- package/dist/_astro/UiAutoBoard.DJljpjXT.js +9 -0
- package/dist/_astro/{app-config.Bm4oN4YP.js → app-config.CF1xVPmo.js} +1 -1
- package/dist/_astro/app-version.YyNOCGCb.js +1 -0
- package/dist/_astro/case-review.DYyZat83.js +3 -0
- package/dist/_astro/case-types.DS1EQ5yP.js +1 -0
- package/dist/_astro/composer-task.DJmluzPT.js +5 -0
- package/dist/_astro/export.joBT53eb.js +148 -0
- package/dist/_astro/{hydrate-cache.BJ2nzhRq.js → hydrate-cache.CmC22o_H.js} +1 -1
- package/dist/_astro/{i18n.m5rqL3-h.js → i18n.B3BVhlok.js} +1 -1
- package/dist/_astro/index.astro_astro_type_script_index_0_lang.CM78W1qz.js +1 -0
- package/dist/_astro/{open-docs-in-session.DPCjFUcv.js → open-docs-in-session.B6uyOxPn.js} +1 -1
- package/dist/_astro/{plugins.CCqu2gnf.js → plugins.DYyAjBXb.js} +1 -1
- package/dist/_astro/prompts-meta.C_MeYq8G.js +2 -0
- package/dist/_astro/req-analysis.CkLx8c9E.js +6 -0
- package/dist/_astro/{settings.DNkAyQxA.js → settings.BvxRxdqa.js} +2 -2
- package/dist/_astro/{spaces-client.D4EmN6SH.js → spaces-client.Dy3tSPta.js} +1 -1
- package/dist/_astro/story-review.CGcusNKf.js +10 -0
- package/dist/_astro/{view-prefs.Do8yjl1I.js → view-prefs.D1snIG5o.js} +1 -1
- package/dist/case-exec/index.html +5 -5
- package/dist/cases/generate/index.html +5 -5
- package/dist/cases/library/index.html +5 -5
- package/dist/dashboard/index.html +5 -5
- package/dist/docs/changelog/index.html +33 -5
- package/dist/docs/install/index.html +4 -4
- package/dist/docs/manual/index.html +85 -49
- package/dist/index.html +1 -1
- package/dist/knowledge/index.html +5 -5
- 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 +4 -4
- package/dist/plugins/index.html +5 -5
- package/dist/pm/bugs/index.html +5 -5
- package/dist/pm/iterations/index.html +5 -5
- package/dist/pm/projects/detail/index.html +5 -5
- package/dist/pm/projects/index.html +5 -5
- package/dist/pm/requirements/index.html +5 -5
- package/dist/prompts/index.html +5 -5
- package/dist/reports/index.html +5 -5
- package/dist/requirement-analysis/index.html +5 -5
- package/dist/requirements/index.html +5 -5
- package/dist/tasks/index.html +5 -5
- package/dist/templates/index.html +5 -5
- 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 +4 -4
- 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 +4 -4
- 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 +4 -4
- 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 +4 -4
- 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 +4 -4
- package/dist/test-automation/index.html +5 -5
- package/dist/test-stats/index.html +5 -5
- package/dist/todos/index.html +5 -5
- package/dist/workbench/index.html +5 -5
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +47 -30
- package/lh-plugins/case-review-prompt.mjs +181 -0
- package/lh-plugins/lh-case-review.mjs +627 -0
- package/lh-plugins/lh-req-analysis.mjs +1 -1
- package/lh-plugins/plugin-prompts.mjs +4 -0
- package/package.json +1 -1
- package/dist/_astro/Base.XN4RkAyb.css +0 -1
- package/dist/_astro/CaseExecBoard.6RFYgAq5.js +0 -1
- package/dist/_astro/CaseGenerateApp.BwvNF4eM.js +0 -9
- package/dist/_astro/CasesLibrary.LnLh6m6G.js +0 -1
- package/dist/_astro/ChatApp.bMYcVMLe.js +0 -226
- package/dist/_astro/ColumnResize.BEkEW7qw.js +0 -1
- package/dist/_astro/DocsFileBrowser.nSAGUo3l.js +0 -1
- package/dist/_astro/ExcelFieldTags.CaD64a2w.js +0 -152
- package/dist/_astro/OverflowHint.DI-tZ2fv.js +0 -1
- package/dist/_astro/PluginsPage.B56V66Kk.js +0 -7
- package/dist/_astro/PluginsPage.DaLeNTSR.js +0 -1
- package/dist/_astro/PmRequirementsBoard.CB33kbaD.js +0 -1
- package/dist/_astro/PmRequirementsBoard.CJFck3LB.js +0 -1
- package/dist/_astro/PromptMountDialog.D_94WQc3.js +0 -58
- package/dist/_astro/PromptsLibrary.Bn5Y9KTB.js +0 -1
- package/dist/_astro/ReqAnalysisBoard.D1UGCxJd.js +0 -28
- package/dist/_astro/SearchableSelect.BzNQ6oXG.js +0 -1
- package/dist/_astro/TasksBoard.BniGtf89.js +0 -1
- package/dist/_astro/TestStatsBoard.CyWsC1tC.js +0 -1
- package/dist/_astro/TodosBoard.Z4Ev2O0M.js +0 -1
- package/dist/_astro/UiAutoBoard.DOYiz3km.js +0 -9
- package/dist/_astro/app-version.6yGkRTiD.js +0 -1
- package/dist/_astro/index.astro_astro_type_script_index_0_lang.CPKr56B1.js +0 -1
- package/dist/_astro/prompts-meta.BiymOMAE.js +0 -2
- package/dist/_astro/story-review.a7qZTroW.js +0 -15
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{s as r}from"./plugins.DYyAjBXb.js";import{a as i,i as a,n as o,o as s,r as c,t as l}from"./view-prefs.D1snIG5o.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./ConfirmDialog.CsMwWevK.js";import{t as f}from"./OverflowHint.pvo2Xc8R.js";import{t as ee}from"./SelectDropdown.Cb-QtC-D.js";import{showToast as p}from"./Toast.BO2NFckG.js";import{s as te}from"./llm.BZEzE0x2.js";import{f as ne,l as re,p as ie}from"./settings.BvxRxdqa.js";import{E as m,S as ae,T as oe,_ as se,a as ce,b as le,c as ue,d as de,f as fe,g as pe,h as me,i as he,l as ge,m as h,n as g,o as _,p as _e,r as ve,s as ye,t as v,u as be,v as xe,w as Se,x as Ce,y as we}from"./req-analysis.CkLx8c9E.js";import{_ as Te,a as Ee,c as De,d as Oe,f as ke,g as Ae,h as je,i as Me,l as y,m as Ne,n as Pe,o as Fe,p as Ie,r as Le,s as Re,u as b}from"./story-review.CGcusNKf.js";import{t as ze}from"./hydrate-cache.CmC22o_H.js";import{O as Be,S as x,_ as Ve,g as He,m as S,u as Ue}from"./PmShared.DbDseTcc.js";var C=e(t(),1),We=`可用工具(只调用这些,不要自己编工具名):
|
|
2
|
+
- req_set_outline:提交本批「需求条目」,返回每个条目的 id。
|
|
3
|
+
- req_set_stories:提交「用户故事」;补写时提交合并后的完整故事集(带原 id 原地更新)。
|
|
4
|
+
- req_save_check:提交体检结果(缺口清单 + 结论)。
|
|
5
|
+
- req_save_test_points:提交测试点(功能 / 边界值 / 异常 / 业务规则 / 非功能五维,P0–P3)。
|
|
6
|
+
|
|
7
|
+
提交后不要重复提交同样的内容;工具返回 ok 之后再写最终回答。`,Ge=[`missing-scenario`,`missing-dimension`,`untestable-acceptance`,`conflict`,`over-split`,`other`];function Ke(e){try{let t=JSON.parse(e||`{}`);return t&&typeof t==`object`?t:{}}catch{return{}}}function w(e,t=500){return typeof e==`string`?e.trim().slice(0,t):``}function T(e){return String(e??``).toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``)}function qe(e){let t=w(e,10);return t===`high`||t===`medium`||t===`low`?t:`medium`}function E(e){let t=w(e,40);return Ge.includes(t)?t:`other`}var D=[`functional`,`boundary`,`exception`,`business`,`nonfunctional`];function O(e){let t=w(e,40);if(D.includes(t))return t;let n=w(e,20);return D.find(e=>Re[e]===n)??`functional`}function k(e){let t=w(e,4).toUpperCase();return b.includes(t)?t:`P1`}function A(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=w(n.title,200);if(!r)return null;let i=w(n.storyId,20);return{id:``,storyId:t.has(i)?i:``,dimension:O(n.dimension),priority:k(n.priority),title:r,precondition:w(n.precondition,1e3),steps:Array.isArray(n.steps)?n.steps.map(e=>w(e,500)).filter(Boolean).slice(0,20):[],expected:w(n.expected,1e3)}}var Je=[{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:Ge},severity:{type:`string`,enum:[`high`,`medium`,`low`]},title:{type:`string`},detail:{type:`string`,description:`位置 + 原因`},suggestion:{type:`string`,description:`建议补写什么`}},required:[`title`,`detail`]}}},required:[`gaps`]}}},{type:`function`,function:{name:`req_save_test_points`,description:`提交基于用户故事拆出的测试点:功能 / 边界值 / 异常 / 业务规则 / 非功能五个维度全覆盖,每条标 P0–P3。一次提交全部,不要分多次。`,parameters:{type:`object`,properties:{summary:{type:`string`,description:`整体结论:几条、五维覆盖情况、最该先测什么`},points:{type:`array`,items:{type:`object`,properties:{storyId:{type:`string`,description:`对应故事 id(US-001 这种);全局测试点填空串`},dimension:{type:`string`,enum:D,description:`functional 功能 / boundary 边界值 / exception 异常 / business 业务规则 / nonfunctional 非功能`},priority:{type:`string`,enum:b},title:{type:`string`,description:`一句话说清测什么(动词开头,带条件)`},precondition:{type:`string`,description:`执行前需要的数据 / 角色 / 状态`},steps:{type:`array`,items:{type:`string`},description:`可执行步骤,一步一个动作`},expected:{type:`string`,description:`可判定的预期结果,有阈值写具体数值`}},required:[`dimension`,`priority`,`title`]}}},required:[`points`]}}}];async function Ye(e,t,n){let r=Ke(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=>T(e.title))),o=new Set(t.map(e=>e.id)),s=[];for(let t of e){let e=t&&typeof t==`object`?t:{},r=w(e.title,200)||w(e.quote,200);if(!r||a.has(T(r)))continue;a.add(T(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:w(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=xe(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=ue(i),t=new Map(i.stories.filter(e=>e.title).map(e=>[T(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=w(n.title,200);if(!r)continue;let i=w(n.storyId,20),o=a.has(i)&&i||t.get(T(w(n.storyTitle,200)))||``,c=E(n.type);s.push({id:h(c,o,r),storyId:o,type:c,severity:qe(n.severity),title:r,detail:w(n.detail,1e3),suggestion:w(n.suggestion,1e3),origin:`model`,selected:!1})}let c=se(e.gaps,s),l=w(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)}%。用户可以在页面上勾选缺口补写。`})}if(e===`req_save_test_points`){let e=Array.isArray(r.points)?r.points:[];if(!e.length)return JSON.stringify({ok:!0,total:i.testPoints?.points.length??0,note:`没有提交测试点,原结果保持不变。`});if(typeof n.saveTestPoints!=`function`)return JSON.stringify({ok:!1,error:`当前上下文不支持保存测试点`});let t=new Set(i.stories.map(e=>e.id)),a=e.slice(0,500).map(e=>A(e,t)).filter(e=>e!==null);if(!a.length)return JSON.stringify({ok:!1,error:`测试点都缺少标题,没有保存`});let o=(await n.saveTestPoints({at:new Date().toISOString(),summary:w(r.summary,2e3),points:a})).testPoints?.points??a,s=D.map(e=>({dimension:Re[e],count:o.filter(t=>t.dimension===e).length})),c=b.map(e=>({priority:e,count:o.filter(t=>t.priority===e).length})),l=s.filter(e=>e.count===0).map(e=>e.dimension);return JSON.stringify({ok:!0,total:o.length,byDimension:s,byPriority:c,uncoveredDimensions:l,note:l.length>0?`测试点已保存:整体 ${o.length} 条。${l.join(`、`)}还没有测试点,如确实不适用请在回答里说明。`:`测试点已保存:整体 ${o.length} 条,五个维度都有覆盖。`})}return JSON.stringify({ok:!1,error:`未知工具:${e}`})}function j(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 Xe(e){let t=j(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[]}function Ze(e,t=[]){let n=new Set(t),r=j(String(e??``));for(let e of r)try{let t=JSON.parse(e),r=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.points)?t.points:null;if(!r?.length)continue;let i=r.map(e=>A(e,n)).filter(e=>e!==null);if(!i.length)continue;let a=t&&typeof t==`object`&&!Array.isArray(t)?w(t.summary,2e3):``;return{at:new Date().toISOString(),summary:a,points:i}}catch{}return null}var M=u(),N=`text-xs font-semibold tracking-wide text-stone-500`,P=`inline-flex h-7 items-center justify-center rounded-md bg-[#3370ff] px-2.5 text-xs font-medium text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,Qe=`inline-flex h-7 items-center justify-center rounded-md border border-stone-200 bg-white px-2 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`;function $e({check:e,stories:t,busy:n,onToggleGap:r,onToggleAll:i,onFix:a,onReview:o,onExport:s}){if(!e)return(0,M.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,M.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有审查结果`}),(0,M.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`审查会先用固定规则核对覆盖率与字段完整性,再让模型专查场景遗漏与维度缺失(替代流程不成立、验收不可测也会一并报)。`}),(0,M.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 c=Ee(e.gaps),l=e.gaps.filter(e=>e.selected).length,u=e.coverage.total?Math.round(e.coverage.rate*100):0,d=Pe(e.gaps),ee=new Map(t.map(e=>[e.id,e.title]));return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:N,children:`需求条目覆盖率`}),(0,M.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.coverage.covered,(0,M.jsxs)(`span`,{className:`text-sm font-normal text-stone-400`,children:[` / `,e.coverage.total]}),(0,M.jsxs)(`span`,{className:`ml-2 text-sm font-normal text-stone-500`,children:[u,`%`]})]})]}),(0,M.jsxs)(`div`,{className:`min-w-[160px] flex-1`,children:[(0,M.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-stone-100`,children:(0,M.jsx)(`div`,{className:`h-full rounded-full transition-all ${u>=90?`bg-emerald-500`:u>=60?`bg-amber-500`:`bg-red-500`}`,style:{width:`${Math.max(u,e.coverage.total?2:0)}%`}})}),(0,M.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:e.coverage.total?`有故事引用的条目算覆盖;sourceRefs 为空的故事不会计入`:`还没有需求条目,先回「需求分析」做一次拆解`})]}),(0,M.jsxs)(`div`,{className:`text-right`,children:[(0,M.jsx)(`p`,{className:N,children:`缺口`}),(0,M.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.gaps.length,(0,M.jsxs)(`span`,{className:`ml-1.5 text-xs font-normal text-stone-400`,children:[`高 `,d.high,` · 中 `,d.medium,` · 低 `,d.low]})]})]})]}),e.summary?(0,M.jsx)(`p`,{className:`mt-3 border-t border-stone-100 pt-2 text-xs leading-relaxed text-stone-500`,children:e.summary}):null]}),(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,M.jsx)(`p`,{className:N,children:`维度覆盖`}),(0,M.jsx)(`div`,{className:`mt-2 grid gap-1.5 sm:grid-cols-2 lg:grid-cols-3`,children:e.dimensions.map(e=>{let t=e.stories.join(`, `);return(0,M.jsxs)(`div`,{"data-hint-width":!0,className:`min-w-0 rounded-lg border px-2.5 py-1.5 text-xs ${e.covered?`border-emerald-200 bg-emerald-50/60`:`border-stone-200 bg-stone-50`}`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,M.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 ${e.covered?`text-emerald-600`:`text-stone-400`}`,children:e.covered?`✓`:`—`}),(0,M.jsx)(`span`,{className:`shrink-0 whitespace-nowrap font-medium ${e.covered?`text-emerald-800`:`text-stone-500`}`,children:e.label}),(0,M.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] tabular-nums text-stone-400`,children:e.stories.length?`${e.stories.length} 条`:`未覆盖`})]}),(0,M.jsx)(`div`,{className:`mt-0.5 min-w-0 pl-[18px]`,children:t?(0,M.jsx)(f,{text:t,matchAnchorWidth:!0,className:`block truncate text-[11px] text-stone-400`}):(0,M.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:`没有故事覆盖`})})]},e.key)})})]}),(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-stone-100 px-4 py-2.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-stone-700`,children:`缺口清单`}),(0,M.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`已选 `,l,` 条`]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,className:Qe,onClick:s,children:`导出 Markdown`}),(0,M.jsx)(`button`,{type:`button`,className:Qe,onClick:()=>i(l!==e.gaps.length),children:l===e.gaps.length&&e.gaps.length?`清空选择`:`全选`}),(0,M.jsx)(`button`,{type:`button`,className:P,disabled:n||!l,onClick:a,children:`补写选中缺口`})]})]}),c.length?(0,M.jsx)(`div`,{className:`divide-y divide-stone-100`,children:c.map(e=>(0,M.jsxs)(`section`,{children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/60 px-4 py-1.5`,children:[(0,M.jsx)(`p`,{className:`text-xs font-semibold text-stone-600`,children:e.label}),(0,M.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-stone-500`,children:e.gaps.length}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:e.hint})]}),(0,M.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:e.gaps.map(e=>(0,M.jsx)(F,{gap:e,storyTitle:ee.get(e.storyId)??``,onToggle:r},e.id))})]},e.key))}):(0,M.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-stone-400`,children:`没有发现缺口。覆盖率与维度都过了,可以再人工过一遍验收标准。`})]})]})}function F({gap:e,storyTitle:t,onToggle:n}){return(0,M.jsxs)(`li`,{className:`flex items-start gap-2.5 px-4 py-2.5`,children:[(0,M.jsx)(`input`,{type:`checkbox`,className:`mt-1 h-3.5 w-3.5 shrink-0 accent-[#3370ff]`,checked:e.selected,onChange:t=>n(e.id,t.target.checked)}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,M.jsx)(x,{tone:g[e.severity],children:v[e.severity]}),(0,M.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 text-[11px] text-stone-500`,children:ve[e.type]}),e.storyId?(0,M.jsxs)(`span`,{className:`font-mono text-[11px] text-stone-400`,children:[e.storyId,t?` · ${t}`:``]}):(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`全局`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:e.origin===`model`?`模型`:`规则`})]}),(0,M.jsx)(`p`,{className:`mt-0.5 text-sm text-stone-800`,children:e.title}),e.detail?(0,M.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-stone-500`,children:e.detail}):null,e.suggestion?(0,M.jsxs)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-amber-700`,children:[`建议:`,e.suggestion]}):null]})]})}var I=`inline-flex h-7 items-center justify-center rounded-md border border-stone-200 bg-white px-2 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`,L=`text-xs font-semibold tracking-wide text-stone-500`;function R({point:e}){return(0,M.jsxs)(`div`,{className:`space-y-1 text-[11px] leading-relaxed text-stone-500`,children:[e.precondition?(0,M.jsxs)(`p`,{children:[(0,M.jsx)(`span`,{className:`text-stone-400`,children:`前置:`}),e.precondition]}):null,e.steps.length?(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-stone-400`,children:`步骤:`}),(0,M.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-4`,children:e.steps.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})]}):null,e.expected?(0,M.jsxs)(`p`,{children:[(0,M.jsx)(`span`,{className:`text-stone-400`,children:`预期:`}),e.expected]}):null]})}function z({doc:e}){let t=Ae(e.testPoints);return(0,M.jsx)(`div`,{className:`overflow-x-auto pb-1`,children:(0,M.jsxs)(`div`,{className:`min-w-[860px]`,children:[(0,M.jsx)(`div`,{className:`flex justify-center`,children:(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-2.5 text-center shadow-sm`,children:[(0,M.jsx)(`p`,{className:`text-sm font-semibold text-stone-800`,children:e.title||`未命名分析`}),(0,M.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-stone-400`,children:[`测试点 `,e.testPoints?.points.length??0,` 条 · 五维覆盖`]})]})}),(0,M.jsx)(`div`,{className:`mx-auto h-4 w-px bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`relative`,children:[(0,M.jsx)(`div`,{className:`absolute top-0 right-[10%] left-[10%] h-px bg-stone-200`,"aria-hidden":`true`}),(0,M.jsx)(`div`,{className:`grid grid-cols-5 gap-3`,children:t.map(e=>{let t=De[e.key];return(0,M.jsxs)(`div`,{className:`flex flex-col`,children:[(0,M.jsx)(`div`,{className:`mx-auto h-4 w-px bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-1 border-b border-stone-100 px-2.5 py-2`,children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,M.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${t.accent}`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`truncate text-xs font-medium text-stone-700`,children:t.label})]}),(0,M.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-stone-400`,children:e.points.length})]}),(0,M.jsx)(`div`,{className:`space-y-1.5 px-2 py-2`,children:e.points.length?e.points.map(e=>(0,M.jsxs)(`div`,{className:`rounded-lg border border-stone-100 bg-stone-50/60 px-2 py-1.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,M.jsx)(x,{tone:y[e.priority].tone,children:e.priority}),(0,M.jsx)(`p`,{className:`min-w-0 flex-1 text-[11px] leading-snug text-stone-700`,children:e.title})]}),(0,M.jsx)(f,{text:`${e.storyId||`全局`}${e.expected?` · ${e.expected}`:``}`,className:`mt-1 block truncate text-[10px] text-stone-400`})]},e.id)):(0,M.jsx)(`p`,{className:`py-2 text-center text-[11px] text-stone-300`,children:`无`})})]})]},e.key)})})]}),(0,M.jsx)(`p`,{className:`mt-3 text-center text-[11px] text-stone-400`,children:`分支 = 五个维度,叶子 = 测试点;左侧标签为优先级。需要完整结构可导出 XMind。`})]})})}function et({doc:e}){let t=Ae(e.testPoints);return(0,M.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>(0,M.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-stone-100 px-3.5 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${De[e.key].accent}`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`text-sm font-medium text-stone-700`,children:e.label}),(0,M.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-stone-400`,children:e.hint})]}),(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] tabular-nums text-stone-400`,children:e.points.length})]}),e.points.length?(0,M.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:e.points.map(e=>(0,M.jsx)(`li`,{children:(0,M.jsxs)(`details`,{className:`group px-3.5 py-2`,children:[(0,M.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-start gap-2`,children:[(0,M.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:(0,M.jsx)(x,{tone:y[e.priority].tone,children:e.priority})}),(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`span`,{className:`block text-sm text-stone-800`,children:e.title}),(0,M.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1.5 text-[11px] text-stone-400`,children:[(0,M.jsx)(`span`,{className:`font-mono`,children:e.storyId||`全局`}),(0,M.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,M.jsxs)(`span`,{children:[e.steps.length,` 步`]}),e.expected?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,M.jsx)(f,{text:e.expected,className:`min-w-0 flex-1 truncate`})]}):null]})]}),(0,M.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[11px] text-stone-300 group-open:hidden`,children:`展开`}),(0,M.jsx)(`span`,{className:`mt-0.5 hidden shrink-0 text-[11px] text-stone-300 group-open:inline`,children:`收起`})]}),(0,M.jsx)(`div`,{className:`mt-1.5 border-l-2 border-stone-100 pl-2.5`,children:(0,M.jsx)(R,{point:e})})]})},e.id))}):(0,M.jsx)(`p`,{className:`px-3.5 py-3 text-xs text-stone-400`,children:`本维度没有测试点。`})]},e.key))})}function tt({doc:e,generating:t,busy:n,promptReady:r,onGenerate:i,onExportXmind:a,onExportMarkdown:o}){let[s,c]=(0,C.useState)(`map`),l=e.testPoints,u=ke(l);if(!l){let n=e.stories.length?r?``:`「测试点生成提示词.md」还没就绪,重新打开插件会自动补齐`:`还没有用户故事,先做一次拆解`;return(0,M.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,M.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有测试点`}),(0,M.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`基于拆好的用户故事,按功能 / 边界值 / 异常 / 业务规则 / 非功能五个维度拆测试点,每条标 P0–P3;结果可看导图、可下载 XMind。`}),n?(0,M.jsx)(`p`,{className:`mt-2 text-xs text-amber-700`,children:n}):null,(0,M.jsx)(`p`,{className:`mt-3 text-xs text-stone-400`,children:t?`正在生成测试点,完成后会自动出现在这里。`:`用左栏的「生成测试点」开始拆。`})]})}return(0,M.jsxs)(`div`,{className:`space-y-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-xl border border-stone-200 bg-white px-3.5 py-2`,children:[(0,M.jsxs)(`span`,{className:`text-xs text-stone-500`,children:[`共 `,(0,M.jsx)(`span`,{className:`font-medium text-stone-700`,children:u.total}),` 条`]}),(0,M.jsx)(`span`,{className:`flex items-center gap-1`,children:b.map(e=>(0,M.jsxs)(x,{tone:y[e].tone,children:[e,` `,u.byPriority[e]]},e))}),(0,M.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`维度覆盖 `,u.coveredDimensions,`/5`]}),(0,M.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,M.jsx)(`span`,{className:`flex overflow-hidden rounded-md border border-stone-200`,children:[{id:`map`,label:`导图`},{id:`list`,label:`列表`}].map(e=>(0,M.jsx)(`button`,{type:`button`,className:`h-7 px-2.5 text-xs transition-colors ${s===e.id?`bg-[#eef3ff] font-medium text-[#1f4fd8]`:`bg-white text-stone-500 hover:bg-stone-50`}`,onClick:()=>c(e.id),children:e.label},e.id))}),(0,M.jsx)(`button`,{type:`button`,className:I,disabled:n,onClick:i,children:t?`生成中…`:`重新生成`}),(0,M.jsx)(`button`,{type:`button`,className:I,disabled:n,onClick:a,children:`导出 XMind`}),(0,M.jsx)(`button`,{type:`button`,className:I,disabled:n,onClick:o,children:`导出 Markdown`})]})]}),s===`map`?(0,M.jsx)(z,{doc:e}):(0,M.jsx)(et,{doc:e}),(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-3.5 py-2.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsx)(`p`,{className:L,children:`生成说明`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:l.at})]}),(0,M.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs leading-relaxed text-stone-600`,children:l.summary||`(模型没有给整体结论)`})]})]})}var nt=[{value:`P0`,label:`P0 · 必须做`},{value:`P1`,label:`P1 · 应该做`},{value:`P2`,label:`P2 · 可以做`}],B=`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`,V=`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`,H=`text-xs font-semibold tracking-wide text-stone-500`,rt=`text-[11px] font-medium tracking-wide text-stone-400`,it={P0:`bg-red-400`,P1:`bg-amber-400`,P2:`bg-stone-300`};function U({label:e,children:t}){return(0,M.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-[88px_minmax(0,1fr)] sm:gap-3`,children:[(0,M.jsx)(`p`,{className:`${rt} pt-0.5`,children:e}),(0,M.jsx)(`div`,{className:`min-w-0 text-[13px] leading-relaxed text-stone-700`,children:t})]})}function at(e){return e.split(`
|
|
8
|
+
`).map(e=>e.trim()).filter(Boolean)}function W({label:e,value:t,placeholder:n,onChange:r}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsxs)(`span`,{className:H,children:[e,`(一行一条)`]}),(0,M.jsx)(`textarea`,{className:`${V} mt-1 min-h-[64px]`,value:t.join(`
|
|
9
|
+
`),placeholder:n,onChange:e=>r(at(e.target.value))})]})}function ot({value:e,onChange:t}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`主流程(一行一步:动作 -> 结果)`}),(0,M.jsx)(`textarea`,{className:`${V} mt-1 min-h-[80px]`,value:e.map(e=>e.result?`${e.action} -> ${e.result}`:e.action).join(`
|
|
10
|
+
`),placeholder:`填写申请单 -> 进入待审批`,onChange:e=>t(at(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 st({value:e,onChange:t}){let n=e.map(e=>[`${e.name} | ${e.trigger}`,...e.steps.map((e,t)=>`${t+1}. ${e}`)].join(`
|
|
11
|
+
`)).join(`
|
|
12
|
+
|
|
13
|
+
`);return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`替代流程(空行分段:名称 | 触发条件,下面写步骤)`}),(0,M.jsx)(`textarea`,{className:`${V} mt-1 min-h-[80px]`,value:n,placeholder:`转人工审批 | 金额超过 5 万
|
|
14
|
+
1. 提交后进入人工队列
|
|
15
|
+
2. 审批通过再继续`,onChange:e=>t(e.target.value.split(/\n{2,}/).map(e=>{let t=e.split(`
|
|
16
|
+
`).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 ct({value:e,onChange:t}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`异常场景(一行一条:场景 -> 预期)`}),(0,M.jsx)(`textarea`,{className:`${V} mt-1 min-h-[80px]`,value:e.map(e=>e.expected?`${e.scenario} -> ${e.expected}`:e.scenario).join(`
|
|
17
|
+
`),placeholder:`提交时网络中断 -> 提示重试并保留草稿`,onChange:e=>t(at(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 lt({value:e,onChange:t}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`验收标准(一行一条:Given | When | Then)`}),(0,M.jsx)(`textarea`,{className:`${V} mt-1 min-h-[80px]`,value:e.map(e=>`${e.given} | ${e.when} | ${e.then}`).join(`
|
|
18
|
+
`),placeholder:`已登录且有权限 | 提交申请单 | 列表里出现一条待审批记录`,onChange:e=>t(at(e.target.value).map(e=>{let[t=``,n=``,r=``]=e.split(`|`).map(e=>e.trim());return{given:t,when:n,then:r}}))})]})}function ut({story:e,index:t,total:n,gaps:r,busy:i,onSave:a,onDelete:o,onMove:s,domId:c}){let[l,u]=(0,C.useState)(!1),[d,f]=(0,C.useState)(!1),[p,te]=(0,C.useState)(e),[ne,re]=(0,C.useState)(!1);(0,C.useEffect)(()=>{if(l||d){re(!0);return}let e=window.setTimeout(()=>re(!1),200);return()=>window.clearTimeout(e)},[l,d]);let ie=()=>{te({...e}),f(!0),u(!0)},m=e=>te(t=>({...t,...e})),ae=r.filter(e=>e.severity===`high`).length;return(0,M.jsxs)(`li`,{id:c,className:`overflow-hidden rounded-xl border bg-white transition-colors ${l||d?`border-stone-200 shadow-sm`:`border-stone-200 hover:border-stone-300`}`,children:[(0,M.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":l,"aria-label":l?`收起 ${e.id}`:`展开 ${e.id}`,className:`flex cursor-pointer items-start gap-3 px-3.5 py-3 outline-none transition-colors hover:bg-stone-50/70 focus-visible:bg-stone-50/70`,onClick:()=>u(e=>!e),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u(e=>!e))},children:[(0,M.jsx)(`span`,{className:`mt-1 h-9 w-[3px] shrink-0 rounded-full ${it[e.priority]}`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 font-mono text-[11px] text-stone-500`,children:e.id||`待编号`}),(0,M.jsx)(x,{tone:_[e.priority],children:e.priority}),(0,M.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:e.title}),r.length>0?(0,M.jsxs)(x,{tone:ae?`red`:`amber`,children:[r.length,` 个缺口`,ae?` · 高 ${ae}`:``]}):null]}),(0,M.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(` · `)||`还没有写角色与目标`}),l?null:(0,M.jsxs)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:[`验收 `,e.acceptance.length,` · 异常 `,e.exceptions.length,` · 维度`,` `,e.dimensions.length]})]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,M.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,M.jsx)(S,{name:`chevronRight`,size:14,className:`-rotate-90`})}),(0,M.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,M.jsx)(S,{name:`chevronRight`,size:14,className:`rotate-90`})}),(0,M.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,"aria-label":d?`取消编辑`:`编辑`,onClick:()=>d?f(!1):ie(),children:(0,M.jsx)(S,{name:`pencil`,size:14})}),(0,M.jsx)(`button`,{type:`button`,className:`tw-icon-danger rounded p-1`,"aria-label":`删除`,disabled:i,onClick:o,children:(0,M.jsx)(S,{name:`trash`,size:14})}),(0,M.jsx)(S,{name:`chevronRight`,size:14,className:`ml-1 text-stone-300 transition-transform duration-150 ${l||d?`rotate-90`:``}`})]})]}),(0,M.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none ${l||d?`grid-rows-[1fr]`:`grid-rows-[0fr]`}`,children:(0,M.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[ne&&d?(0,M.jsxs)(`div`,{className:`space-y-3 border-t border-stone-100 px-4 py-3`,children:[(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`标题`}),(0,M.jsx)(`input`,{className:`${B} mt-1`,value:p.title,onChange:e=>m({title:e.target.value})})]}),(0,M.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`角色`}),(0,M.jsx)(`input`,{className:`${B} mt-1`,value:p.role,onChange:e=>m({role:e.target.value})})]}),(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`优先级`}),(0,M.jsx)(`div`,{className:`mt-1`,children:(0,M.jsx)(ee,{options:nt,value:p.priority,onChange:e=>m({priority:e}),ariaLabel:`优先级`,flat:!0})})]})]}),(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`目标`}),(0,M.jsx)(`input`,{className:`${B} mt-1`,value:p.goal,onChange:e=>m({goal:e.target.value})})]}),(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`价值 / 备注`}),(0,M.jsx)(`input`,{className:`${B} mt-1`,value:p.value,onChange:e=>m({value:e.target.value})})]}),(0,M.jsx)(W,{label:`前置条件`,value:p.preconditions,placeholder:`已登录且拥有申请权限`,onChange:e=>m({preconditions:e})}),(0,M.jsx)(ot,{value:p.mainFlow,onChange:e=>m({mainFlow:e})}),(0,M.jsx)(st,{value:p.altFlows,onChange:e=>m({altFlows:e})}),(0,M.jsx)(ct,{value:p.exceptions,onChange:e=>m({exceptions:e})}),(0,M.jsx)(W,{label:`后置条件`,value:p.postconditions,placeholder:`申请单状态变为待审批`,onChange:e=>m({postconditions:e})}),(0,M.jsx)(lt,{value:p.acceptance,onChange:e=>m({acceptance:e})}),(0,M.jsx)(W,{label:`覆盖维度`,value:p.dimensions,placeholder:`权限、边界值、超时与失败`,onChange:e=>m({dimensions:e})}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`来源条目:`,e.sourceRefs.join(`、`)||`(未关联)`]}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.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:()=>f(!1),children:`取消`}),(0,M.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||!p.title.trim(),onClick:()=>{a(p),f(!1)},children:`保存`})]})]})]}):null,ne&&!d?(0,M.jsxs)(`div`,{className:`border-t border-stone-100 bg-stone-50/50 px-3.5 py-3.5`,children:[(0,M.jsxs)(`div`,{className:`space-y-3.5`,children:[e.value?(0,M.jsx)(U,{label:`价值`,children:e.value}):null,e.preconditions.length?(0,M.jsx)(U,{label:`前置条件`,children:(0,M.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.preconditions.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})}):null,e.mainFlow.length?(0,M.jsx)(U,{label:`主流程`,children:(0,M.jsx)(`ol`,{className:`list-decimal space-y-0.5 pl-4`,children:e.mainFlow.map((e,t)=>(0,M.jsxs)(`li`,{children:[e.actor?(0,M.jsxs)(`span`,{className:`text-stone-500`,children:[e.actor,`:`]}):null,e.action,e.result?(0,M.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.result]}):null]},t))})}):null,e.altFlows.length?(0,M.jsx)(U,{label:`替代流程`,children:(0,M.jsx)(`ul`,{className:`space-y-1.5`,children:e.altFlows.map((e,t)=>(0,M.jsxs)(`li`,{children:[(0,M.jsxs)(`p`,{className:`font-medium text-stone-700`,children:[e.name,e.trigger?(0,M.jsxs)(`span`,{className:`font-normal text-stone-500`,children:[`(触发:`,e.trigger,`)`]}):null]}),(0,M.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-4 text-stone-600`,children:e.steps.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})]},t))})}):null,e.exceptions.length?(0,M.jsx)(U,{label:`异常场景`,children:(0,M.jsx)(`ul`,{className:`space-y-0.5`,children:e.exceptions.map((e,t)=>(0,M.jsxs)(`li`,{children:[e.scenario,e.expected?(0,M.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.expected]}):null]},t))})}):null,e.postconditions.length?(0,M.jsx)(U,{label:`后置条件`,children:(0,M.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.postconditions.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})}):null,e.acceptance.length?(0,M.jsx)(U,{label:`验收标准`,children:(0,M.jsx)(`ul`,{className:`space-y-1`,children:e.acceptance.map((e,t)=>(0,M.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5 rounded-md bg-white px-2 py-1 ring-1 ring-stone-100`,children:[(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`Given`}),(0,M.jsx)(`span`,{children:e.given||`—`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`When`}),(0,M.jsx)(`span`,{children:e.when||`—`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`Then`}),(0,M.jsx)(`span`,{className:e.then?`text-stone-800`:`text-red-500`,children:e.then||`(未写)`})]},t))})}):null,e.dimensions.length?(0,M.jsx)(U,{label:`覆盖维度`,children:(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.dimensions.map(e=>(0,M.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-stone-500 ring-1 ring-stone-100`,children:e},e))})}):null,(0,M.jsx)(U,{label:`来源条目`,children:(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.sourceRefs.length?e.sourceRefs.map(e=>(0,M.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 font-mono text-[11px] text-stone-500 ring-1 ring-stone-100`,children:e},e)):(0,M.jsx)(`span`,{className:`text-amber-600`,children:`未关联(覆盖率会算不到)`})})})]}),r.length?(0,M.jsxs)(`div`,{className:`mt-3 rounded-lg border border-amber-200 bg-amber-50/70 px-3 py-2`,children:[(0,M.jsx)(`p`,{className:`text-xs font-medium text-amber-900`,children:`审查发现的问题`}),(0,M.jsx)(`ul`,{className:`mt-1 space-y-1`,children:r.map(e=>(0,M.jsxs)(`li`,{className:`flex flex-wrap items-center gap-1.5 text-xs`,children:[(0,M.jsx)(x,{tone:g[e.severity],children:v[e.severity]}),(0,M.jsx)(`span`,{className:`text-stone-500`,children:ve[e.type]}),(0,M.jsx)(`span`,{className:`text-stone-700`,children:e.title})]},e.id))})]}):null]}):null]})})]})}var dt=`reqanalysis.doc`,ft=`reqanalysis.listmode`,pt=`reqanalysis.view`,mt=`reqanalysis.tab`,ht=`reqanalysis.storykeyword`,gt=[`list`,`work`],_t=[`stories`,`check`,`outline`,`points`],vt=`reqanalysis.activity`,yt=[`info`,`tool`,`done`,`error`];function bt(e){return`${vt}.${e}`}function xt(e){if(!e)return[];let t=l(bt(e),[]);return Array.isArray(t)?t.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`number`&&typeof t.text==`string`&&typeof t.at==`string`&&yt.includes(t.kind)}).slice(-200):[]}var St=/\.[a-z0-9]+$/i,Ct={md:`Markdown`,markdown:`Markdown`,txt:`文本`,csv:`CSV`,docx:`Word`,xlsx:`Excel`,xls:`Excel`,doc:`Word(旧版)`,pdf:`PDF`,ppt:`PPT`,pptx:`PPT`},wt=`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`,Tt=`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`,Et=`text-xs font-semibold tracking-wide text-stone-500`;function Dt(e){return e.split(`/`).pop()||e}function Ot(e){return e.replace(St,``)}function kt(e){return(e.format||Dt(e.path).split(`.`).pop()||``).toLowerCase()}function At(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 jt(e){return[...e].sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))}function Mt({name:e,ready:t}){return(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(f,{text:e,className:`min-w-0 flex-1 truncate text-xs text-stone-500`}),(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] ${t?`text-emerald-600`:`text-stone-400`}`,children:t?`已就绪`:`未就绪`})]})}function Nt(){let e=Be(`reqAnalysis`),t=Be(`storyReview`),l=Be(`testPoints`),[u,se]=(0,C.useState)(null),[h,g]=(0,C.useState)([]),[_,ve]=(0,C.useState)(``),[v,Ee]=(0,C.useState)(null),[De,ke]=(0,C.useState)([]),[Ae,y]=(0,C.useState)(``),[Pe,Re]=(0,C.useState)(``),[b,Ge]=(0,C.useState)(null),[Ke,w]=(0,C.useState)(null),[T,qe]=(0,C.useState)(null),[E,D]=(0,C.useState)(null),[O,k]=(0,C.useState)(null),[A,j]=(0,C.useState)(null),[N,P]=(0,C.useState)([]),[Qe,F]=(0,C.useState)(``),[I,L]=(0,C.useState)(``),[R,z]=(0,C.useState)(()=>o(mt,_t,`stories`));(0,C.useEffect)(()=>{i(mt,R)},[R]);let[et,nt]=(0,C.useState)(`list`),B=(0,C.useRef)(o(pt,gt,`list`)),[V,H]=(0,C.useState)(()=>B.current===`work`),[rt,it]=(0,C.useState)(()=>o(ft,[`doc`,`story`],`doc`)),[U,at]=(0,C.useState)(()=>c(ht,``));(0,C.useEffect)(()=>{s(ht,U)},[U]);let[W,ot]=(0,C.useState)(null),[st,ct]=(0,C.useState)([]),lt=(0,C.useRef)(``),[vt,yt]=(0,C.useState)(``),[St,Nt]=(0,C.useState)(!1),[Pt,Ft]=(0,C.useState)(!1),G=(0,C.useRef)(null),K=(0,C.useRef)(null),It=(0,C.useRef)(0),Lt=(0,C.useRef)(null),Rt=(0,C.useRef)(null),zt=(0,C.useCallback)(e=>t.on||e!==`checked`&&e!==`accepted`?ye[e]:ye.decomposed,[t.on]),Bt=(0,C.useMemo)(()=>{let e=e=>+!e.supported;return[...De].sort((t,n)=>e(t)-e(n)||t.path.localeCompare(n.path,`zh`)).map(e=>{let t=kt(e),n=Ct[t]??t.toUpperCase();return{value:e.path,label:e.path,secondary:e.supported?t:`${n} · 暂不支持,请另存为 .docx / .xlsx / .md`,disabled:!e.supported}})},[De]),q=(0,C.useCallback)(e=>{G.current=e,Ee(e),g(t=>jt(t.map(t=>t.id===e.id?e:t)))},[]),J=(0,C.useCallback)((e,t=`info`)=>{It.current+=1,P(n=>[...n,{id:It.current,kind:t,text:e,at:new Date().toISOString()}])},[]),Vt=(0,C.useRef)(!1);(0,C.useEffect)(()=>{if(!_){Vt.current=!0,P([]);return}let e=xt(_);It.current=e.reduce((e,t)=>Math.max(e,t.id),0),Vt.current=!0,P(e)},[_]),(0,C.useEffect)(()=>{Vt.current?Vt.current=!1:_&&a(bt(_),N.slice(-200))},[N,_]);let Y=(0,C.useCallback)(e=>{G.current=e,Ee(e),ve(e?.id??``),s(dt,e?.id??``),e?.sourcePath&&y(e.sourcePath)},[]),X=(0,C.useCallback)(e=>{nt(e),i(pt,e)},[]),Z=(0,C.useCallback)((e,t=`stories`)=>{Y(e),z(t),X(`work`),ze(`req-analysis`)},[X,Y]),Ht=(0,C.useCallback)((e,t)=>{lt.current=t,Z(e,`stories`)},[Z]);(0,C.useEffect)(()=>{if(et!==`work`||!lt.current)return;let e=lt.current;lt.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)}},[et,v?.id]);let Ut=(0,C.useMemo)(()=>h.flatMap(e=>e.stories.map(t=>({doc:e,story:t}))),[h]),Wt=Ut.length,Gt=(0,C.useMemo)(()=>{let e=U.trim().toLowerCase(),t=t=>String(t??``).toLowerCase().includes(e),n=e?Ut.filter(({doc:e,story:n})=>t(n.id)||t(n.title)||t(n.role)||t(n.goal)||t(e.title)):Ut,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))},[Ut,U]),Kt=(0,C.useMemo)(()=>new Set(W?.ids??[]),[W]),qt=(0,C.useCallback)((e,t)=>{ot(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})},[]),Jt=(0,C.useCallback)((e,t)=>{ot(n=>n?.docId===e&&t.every(e=>n.ids.includes(e))?null:t.length?{docId:e,ids:t}:null)},[]),Yt=(0,C.useCallback)(e=>{it(e),i(ft,e)},[]);(0,C.useEffect)(()=>{let e=!0;(async()=>{if(await n(),!e)return;Ge(re());let t=await fe();if(e&&(se(t),t))try{let[t,n,r,i]=await Promise.all([me(),_e(),Me(),je()]);if(!e)return;let a=n;if((!n.exists||!n.decompose.trim())&&(await Se(!0).catch(()=>void 0),a=await _e()),!e)return;w(a);let o=r;if((!r.exists||!r.review.trim())&&(await Fe(!0).catch(()=>void 0),o=await Me()),!e)return;o.exists&&qe(o),i.exists&&D(i);let s=jt(t);g(s);let l=c(dt,``),u=s.find(e=>e.id===l)??s[0]??null;Y(u);let d=B.current;B.current=`list`,d===`work`&&u&&l&&u.id===l&&(X(`work`),ze(`req-analysis`)),H(!1)}catch(t){e&&(H(!1),L(t instanceof Error?t.message:String(t)))}})();let t=ne(()=>Ge(re()));return()=>{e=!1,t()}},[X,Y]),(0,C.useEffect)(()=>{if(!t.ready)return;if(!t.on){qe(null),z(e=>e===`check`?`stories`:e);return}if(!u||T!==null)return;let e=!0;return(async()=>{let t=await Me();(!t.exists||!t.review.trim())&&(await Fe(!0).catch(()=>void 0),t=await Me()),e&&qe(t)})(),()=>{e=!1}},[t.ready,t.on,u,T]),(0,C.useEffect)(()=>{if(!l.ready)return;if(!l.on){D(null),z(e=>e===`points`?`stories`:e);return}if(!u||E!==null)return;let e=!0;return(async()=>{let t=await je();(!t.exists||!t.generate.trim())&&(await Te(!0).catch(()=>void 0),t=await je()),e&&D(t)})(),()=>{e=!1}},[l.ready,l.on,u,E]),(0,C.useEffect)(()=>{if(!u)return;let e=!0;return pe().then(t=>{e&&ke(t)}).catch(t=>{e&&Re(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[u]),(0,C.useEffect)(()=>{let e=v?.sourcePath;if(!e){yt(``);return}let t=!0;return le(e).then(e=>{t&&yt(Ce(e))}).catch(()=>{t&&yt(``)}),()=>{t=!1}},[v?.sourcePath,v?.sourceHash]),(0,C.useEffect)(()=>{let e=Lt.current;e&&(e.scrollTop=e.scrollHeight)},[N]);let Xt=!!(v?.sourceHash&&vt&&v.sourceHash!==vt),Zt=(0,C.useMemo)(()=>new Set((v?.stories??[]).flatMap(e=>e.sourceRefs)),[v?.stories]),Qt=Ke??null,$t=!!Qt?.decompose.trim(),en=(0,C.useMemo)(()=>(v?.check?.gaps??[]).filter(e=>e.selected).length,[v?.check]),Q=(0,C.useCallback)(async(e,t)=>{let n=t??G.current;if(!n)throw Error(`还没有分析文档`);let r=await m(n.id,e);return q(r),r},[q]),tn=(0,C.useCallback)(()=>{Rt.current&&window.clearTimeout(Rt.current),Rt.current=window.setTimeout(()=>{let e=G.current;e?.check&&m(e.id,{check:e.check}).catch(()=>void 0)},600)},[]),nn=(0,C.useCallback)(async e=>{if(!e)return null;let t=h.find(t=>t.sourcePath===e);if(t)return Z(t,`stories`),t;try{let t=await le(e),n=Dt(e),r=await ge({sourcePath:e,sourceTitle:n,sourceHash:Ce(t),title:Ot(n)});return g(e=>jt([r,...e])),Z(r,`stories`),J(`新建分析:${r.title}`),r}catch(e){let t=e instanceof Error?e.message:String(e);return L(t),p(t,`error`),y(G.current?.sourcePath??``),null}},[h,Z,J]),rn=!!(b?.baseURL&&b.apiKey&&b.model),an=(0,C.useCallback)(()=>!rn||!b?(p(`请先在设置里配置模型`,`error`),ie(`model`),null):b,[rn,b]),$=(0,C.useCallback)((e,t)=>({getDoc:()=>G.current,batch:t,saveOutline:async t=>{let n=await m(e.id,{outline:t});return q(n),n.outline},saveStories:async t=>{let n=await m(e.id,{stories:t});return q(n),J(`已写入 ${n.stories.length} 个用户故事`),n},saveCheck:async t=>{let n=G.current?.check,r={...t,gaps:we(n?.gaps??[],t.gaps)},i=await m(e.id,{check:r,status:`checked`});return q(i),i},saveTestPoints:async t=>{let n=await m(e.id,{testPoints:t});return q(n),n}}),[q,J]),on=(0,C.useCallback)(async()=>{let e=G.current,n=an();if(!e||!n)return;let r=Qt?.decompose.trim()??``;if(!r){p(`没有读到「${ce}」的「## 拆解」段落`,`error`);return}L(``),F(``),P([]),k(`decompose`),j({label:`拆解`,done:0,total:0,message:`正在读取来源文档`});let i=new AbortController;K.current=i;try{let a=await m(e.id,{status:`draft`,progress:{stage:`stories`,done:0,total:0,message:`正在读取来源文档`,at:new Date().toISOString()}});q(a);let o=await le(e.sourcePath);if(!o.trim())throw Error(`来源文档是空的`);let s=ae(o);if(!s.length)throw Error(`来源文档没有可拆解的内容`);j({label:`拆解`,done:0,total:s.length,message:`共 ${s.length} 批,准备拆第 1 批`}),J(s.length>1?`来源 ${o.length} 字,已分 ${s.length} 批拆解`:`来源 ${o.length} 字,单批拆解`);let c=await m(e.id,{replaceStories:!0,stories:[],outline:[],check:null,status:`draft`,sourceHash:Ce(o)});q(c);for(let t of s){if(i.signal.aborted)break;let a=G.current?.stories.length??0,o=[r,``,We,``,`## 已抽取的需求条目(sourceRefs 只能引用这些 id)`,(G.current?.outline??[]).map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
|
|
19
|
+
`)||`(本批还没有条目,先调用 req_set_outline)`].join(`
|
|
20
|
+
`),c=[`这一批是原始需求的第 ${t.index+1}/${s.length} 段${t.title?`(章节:${t.title})`:``}。只处理这一段的条目与故事,已完成的部分不要重写。`,``,`## 原始需求`,``,t.text].join(`
|
|
21
|
+
`);await Q({progress:{stage:`stories`,done:t.index,total:s.length,message:`正在拆第 ${t.index+1}/${s.length} 批`,at:new Date().toISOString()}},G.current).catch(()=>void 0),j({label:`拆解`,done:t.index,total:s.length,message:`正在拆第 ${t.index+1}/${s.length} 批`});let l=``;for await(let r of te(n,[{role:`system`,content:o},{role:`user`,content:c}],i.signal,{tools:Je,maxToolRounds:20,runTool:(n,r)=>Ye(n,r,$(e,t.index))}))r.type===`content`?(l+=r.delta,F(e=>e+r.delta)):r.type===`tool`&&r.status===`running`&&J(`调用 ${r.name}`,`tool`);if((G.current?.stories.length??0)===a){let n=Xe(l);if(n.length){let t=xe(G.current?.stories??[],n),r=await m(e.id,{stories:t});q(r),J(`模型没调工具,已从回答里兜底解析 ${n.length} 个故事`,`info`)}else J(`第 ${t.index+1} 批没有拿到结构化故事`,`error`)}j({label:`拆解`,done:t.index+1,total:s.length,message:`第 ${t.index+1}/${s.length} 批已写入`})}if(i.signal.aborted){J(`已中断:已经写入的故事保留`,`info`);return}let l=await m(e.id,{status:`decomposed`,progress:{stage:`done`,done:s.length,total:s.length,message:`拆解完成`,at:new Date().toISOString()}});q(l),J(`拆解完成:${l.outline.length} 条需求条目、${l.stories.length} 个用户故事`,`done`),z(`stories`),t.on&&!i.signal.aborted?(p(`拆解完成,接着做用户故事审查`,`success`),await cn.current?.(!0)):p(`拆解完成`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);i.signal.aborted?J(`已中断:已经写入的故事保留`,`info`):(L(t),J(`拆解失败:${t}`,`error`))}finally{k(null),j(null),K.current=null}},[$,q,J,Qt,an,t.on,Q]),sn=(0,C.useCallback)(async(e=!1)=>{let t=G.current;if(!t)return;if(!t.stories.length){e||p(`还没有用户故事,先做一次拆解`,`info`);return}L(``),e||(F(``),P([])),k(`audit`),j({label:`审查用户故事`,done:0,total:2,message:`正在跑规则体检`});let n=new AbortController;K.current=n;try{let e=ue(t),r=await m(t.id,{check:{...e,gaps:we(t.check?.gaps??[],e.gaps)},status:`checked`,progress:{stage:`audit`,done:0,total:1,message:`规则体检完成,等待模型评审`,at:new Date().toISOString()}});q(r),J(`规则体检:覆盖率 ${Math.round(e.coverage.rate*100)}%,${e.gaps.length} 个缺口`),j({label:`审查用户故事`,done:1,total:2,message:`规则体检完成,等待模型评审`});let i=T?.review.trim()??``,a=rn?b:null;if(!a||!i){J(a?`「用户故事审查提示词.md」缺少「## 审查」段落,只保留规则结果`:`没有配置模型,只保留规则结果`,`info`),z(`check`);return}let o=!1,s=$(t,90),c=s.saveCheck;s.saveCheck=async e=>{o=!0;let t=await c(e);return J(`模型体检:整体 ${t.check?.gaps.length??0} 个缺口`,`done`),t};let l=G.current??r,u=[`## 需求条目`,l.outline.length?l.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
|
|
22
|
+
`):`(无)`,``,`## 用户故事(${l.stories.length} 条)`,"```json",JSON.stringify(l.stories,null,2),"```"].join(`
|
|
23
|
+
`);for await(let e of te(a,[{role:`system`,content:`${i}\n\n${We}`},{role:`user`,content:u}],n.signal,{tools:Je.filter(e=>e.function.name===`req_save_check`),maxToolRounds:8,runTool:(e,t)=>Ye(e,t,s)}))e.type===`content`?F(t=>t+e.delta):e.type===`tool`&&e.status===`running`&&J(`调用 ${e.name}`,`tool`);o||(J(`模型没有提交体检结果,当前只保留规则结果`,`error`),p(`模型没有提交体检结果,只保留了规则检查`,`error`)),j({label:`审查用户故事`,done:2,total:2,message:o?`模型评审完成`:`已保留规则结果`}),z(`check`)}catch(e){let t=e instanceof Error?e.message:String(e);n.signal.aborted?J(`已中断:规则体检结果已保留`,`info`):(L(t),J(`体检失败:${t}`,`error`))}finally{k(null),j(null),K.current=null}},[$,rn,q,J,T,b]),cn=(0,C.useRef)(null);cn.current=sn;let ln=(0,C.useCallback)(async()=>{let e=G.current,t=an();if(!e||!t)return;let n=(e.check?.gaps??[]).filter(e=>e.selected);if(!n.length){p(`先在缺口清单里勾选要补写的条目`,`info`);return}let r=T?.fix.trim()??``;if(!r){p(`「用户故事审查提示词.md」缺少「## 补写」段落`,`error`);return}L(``),F(``),P([]),k(`fix`);let i=new AbortController;K.current=i;try{J(`按 ${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(`
|
|
24
|
+
`)}).join(`
|
|
25
|
+
`)].join(`
|
|
26
|
+
`),s=$(e,90),c=!1,l=s.saveStories;s.saveStories=async e=>(c=!0,l(e));for await(let e of te(t,[{role:`system`,content:`${r}\n\n${We}`},{role:`user`,content:o}],i.signal,{tools:Je.filter(e=>e.function.name===`req_set_stories`),maxToolRounds:10,runTool:(e,t)=>Ye(e,t,s)}))e.type===`content`?F(t=>t+e.delta):e.type===`tool`&&e.status===`running`&&J(`调用 ${e.name}`,`tool`);if(!c){J(`模型没有提交补写结果,故事集保持不变`,`error`),p(`模型没有提交补写结果`,`error`);return}let u=G.current;if(u){let e=ue(u),t=await m(u.id,{check:e,status:`decomposed`});q(t)}J(`补写完成,已按规则重算覆盖率;建议再跑一次体检`,`done`),z(`check`),p(`补写完成,建议再跑一次体检`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);i.signal.aborted?J(`已中断:已经写入的改动保留`,`info`):(L(t),J(`补写失败:${t}`,`error`))}finally{k(null),K.current=null}},[$,q,J,an,T]),un=(0,C.useCallback)(async()=>{let e=G.current,t=an();if(!e||!t)return;if(!e.stories.length){p(`还没有用户故事,先做一次拆解`,`info`);return}let n=E?.generate.trim()??``;if(!n){p(`没有读到「${Oe}」的「## 生成」段落`,`error`);return}L(``),F(``),P([]),k(`testpoints`),z(`points`),j({label:`生成测试点`,done:0,total:2,message:`正在整理用户故事,等待模型生成`}),await Q({progress:{stage:`points`,done:0,total:2,message:`正在生成测试点`,at:new Date().toISOString()}},e).catch(()=>void 0),J(`开始生成测试点(五维覆盖,P0–P3)`,`info`);let r=new AbortController;K.current=r;try{let i=$(e,90),a=!1,o=i.saveTestPoints;i.saveTestPoints=async e=>{a=!0,j({label:`生成测试点`,done:1,total:2,message:`正在写入测试点`});let t=await o(e);return J(`测试点已写入:${t.testPoints?.points.length??0} 条`,`done`),t};let s=[`## 分析标题\n${e.title||`未命名分析`}`,``,`## 需求条目`,e.outline.length?e.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
|
|
27
|
+
`):`(无)`,``,`## 用户故事(${e.stories.length} 条)`,"```json",JSON.stringify(e.stories,null,2),"```"].join(`
|
|
28
|
+
`),c=``;for await(let e of te(t,[{role:`system`,content:`${n}\n\n${We}`},{role:`user`,content:s}],r.signal,{tools:Je.filter(e=>e.function.name===`req_save_test_points`),maxToolRounds:8,runTool:(e,t)=>Ye(e,t,i)}))e.type===`content`?(c+=e.delta,F(t=>t+e.delta)):e.type===`tool`&&e.status===`running`&&J(`调用 ${e.name}`,`tool`);if(!a){let t=Ze(c,e.stories.map(e=>e.id));t&&(await i.saveTestPoints(t),a=!0,J(`模型没调工具,已从回答里兜底解析 ${t.points.length} 条`,`info`))}if(!a)J(`模型没有提交测试点,原结果保持不变`,`error`),p(`模型没有提交测试点,原结果保持不变`,`error`);else{let e=G.current?.testPoints?.points??[],t=t=>e.filter(e=>e.priority===t).length;J(`测试点完成:${e.length} 条(P0 ${t(`P0`)} / P1 ${t(`P1`)} / P2 ${t(`P2`)} / P3 ${t(`P3`)})`,`done`),j({label:`生成测试点`,done:2,total:2,message:`已生成 ${e.length} 条`}),await Q({progress:{stage:`done`,done:2,total:2,message:`测试点已生成 ${e.length} 条`,at:new Date().toISOString()}},G.current).catch(()=>void 0),p(`测试点已生成`,`success`)}}catch(e){let t=e instanceof Error?e.message:String(e);r.signal.aborted?J(`已中断:已经生成的测试点保留`,`info`):(L(t),J(`生成测试点失败:${t}`,`error`))}finally{k(null),j(null),K.current=null}},[$,J,an,Q,E]),dn=(0,C.useCallback)(async()=>{let e=G.current;if(!e?.testPoints)p(`还没有测试点可导出`,`info`);else try{let t=await Ne(e);J(`已导出 ${t}`,`done`)}catch(e){p(`导出失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[J]),fn=(0,C.useCallback)(()=>{let e=G.current;if(!e?.testPoints){p(`还没有测试点可导出`,`info`);return}let t=Ie(e);J(`已导出 ${t}`,`done`)},[J]),pn=(0,C.useCallback)(async e=>{let t=G.current;if(t)try{await Q({stories:e},t)}catch(e){p(`保存失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[Q]),mn=(0,C.useCallback)((e,t)=>{let n=G.current;if(!n)return;let r=n.stories.map((n,r)=>r===e?{...t,id:n.id}:n);pn(r)},[pn]),hn=(0,C.useCallback)(e=>{let t=G.current;t&&pn(t.stories.filter((t,n)=>n!==e))},[pn]),gn=(0,C.useCallback)((e,t)=>{let n=G.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,pn(i))},[pn]),_n=(0,C.useCallback)((e,t)=>{let n=G.current;if(!n?.check)return;let r={...n,check:{...n.check,gaps:n.check.gaps.map(n=>n.id===e?{...n,selected:t}:n)}};q(r),tn()},[q,tn]),vn=(0,C.useCallback)(e=>{let t=G.current;if(!t?.check)return;let n={...t,check:{...t.check,gaps:t.check.gaps.map(t=>({...t,selected:e}))}};q(n),tn()},[q,tn]),yn=(0,C.useCallback)(e=>{let t=G.current,n=e.trim();t&&n&&n!==t.title&&Q({title:n},t).catch(()=>void 0)},[Q]),bn=(0,C.useCallback)(async()=>{let e=G.current;if(e)try{await be(e.id);let t=h.filter(t=>t.id!==e.id);g(t),Y(t[0]??null),X(`list`),p(`已删除分析记录`,`success`)}catch(e){p(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}finally{Nt(!1)}},[X,h,Y]),xn=(0,C.useCallback)(()=>{let e=G.current;if(!e)return;let t=new Blob([oe(e)],{type:`text/markdown;charset=utf-8`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=de(e),document.body.appendChild(r),r.click(),r.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),1e3),p(`已导出 Markdown`,`success`)},[]),Sn=(0,C.useCallback)(()=>{let e=G.current;if(!e?.check)return;let t=Le(e,e.check);p(`已导出 ${t}`,`success`)},[]),Cn=(0,C.useCallback)(()=>{K.current?.abort()},[]);if(!e.ready)return(0,M.jsx)(He,{label:`正在读取插件开关`});if(!e.on)return(0,M.jsx)(Ve,{children:r(`reqAnalysis`)});if(u===null)return(0,M.jsx)(He,{label:`正在连接需求分析服务`});if(!u)return(0,M.jsx)(Ve,{children:"需求分析需要本地服务,当前未就绪:确认服务已升级到最新版本并重启(`lantern` 一体服务或 `npm run dev`),静态部署的页面用不了。"});if(V)return(0,M.jsx)(He,{label:`正在回到上次的分析`});let wn=v?.outline.filter(e=>Zt.has(e.id)).length??0,Tn=v?.check?.gaps??[],En=(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3`,children:[(0,M.jsxs)(`section`,{className:`shrink-0 rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,M.jsxs)(`div`,{className:`min-w-[240px] flex-1`,children:[(0,M.jsx)(`p`,{className:Et,children:`新建分析`}),(0,M.jsx)(`div`,{className:`mt-1.5 max-w-[440px]`,children:(0,M.jsx)(ee,{options:Bt,value:Ae,onChange:e=>{y(e),e&&nn(e)},triggerTitle:Ae||`选择来源需求文档…`,ariaLabel:`选择来源需求文档`,searchable:!0,searchPlaceholder:`搜索文件名或路径…`,flat:!0})})]}),(0,M.jsxs)(`span`,{className:`pb-1 text-[11px] text-stone-400`,children:[`共 `,h.length,` 份分析`]})]}),Pe?(0,M.jsxs)(`p`,{className:`mt-2 text-xs leading-relaxed text-amber-700`,children:[`读不到需求文档库:`,Pe,(0,M.jsx)(`br`,{}),`请先启用「需求文档库」插件,或确认 `,he,` 之外的内容目录没有被移动。`]}):null]}),I?(0,M.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,M.jsx)(`span`,{className:`break-all`,children:I}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>L(``),children:`✕`})]}):null,(0,M.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-3 py-2`,children:[(0,M.jsxs)(`div`,{className:`inline-flex rounded-lg border border-stone-200 bg-stone-50 p-0.5`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:()=>Yt(`doc`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${rt===`doc`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按需求说明书`}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>Yt(`story`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${rt===`story`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按用户故事`})]}),rt===`story`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`label`,{className:`relative block`,children:[(0,M.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,M.jsx)(`input`,{value:U,onChange:e=>at(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,M.jsxs)(`span`,{className:`text-[11px] text-stone-400`,children:[Wt,` 个故事`,W?` · 已选 ${W.ids.length}`:``]}),(0,M.jsx)(`button`,{type:`button`,disabled:!W,onClick:()=>{if(!W)return;let e=new URLSearchParams({plugin:`caseGen`,reqDoc:W.docId,stories:W.ids.join(`,`)});window.location.href=`/workbench/?${e.toString()}`},className:`${wt} ml-auto h-8 text-xs`,children:`用选中故事生成用例`})]}):(0,M.jsxs)(`span`,{className:`ml-auto text-[11px] text-stone-400`,children:[h.length,` 份分析 · `,Wt,` 个故事`]})]}),(0,M.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:rt===`doc`?h.length?(0,M.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:h.map(e=>{let t=zt(e.status);return(0,M.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3 transition-colors hover:bg-stone-50`,children:[(0,M.jsx)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center text-left`,onClick:()=>Z(e,`stories`),children:(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:e.title}),(0,M.jsx)(x,{tone:t.tone,children:t.label})]}),(0,M.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-stone-400`,children:[(0,M.jsx)(`span`,{className:`truncate`,children:e.sourcePath||`(未指定来源)`}),(0,M.jsxs)(`span`,{children:[`用户故事 `,e.stories.length]}),(0,M.jsxs)(`span`,{children:[`需求条目 `,e.outline.length]}),(0,M.jsx)(`span`,{children:At(e.updatedAt)})]})]})}),(0,M.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:()=>Z(e,`stories`),children:[`用户故事`,(0,M.jsx)(S,{name:`chevronRight`,size:13})]}),(0,M.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,className:`tw-icon-danger flex h-8 w-8 shrink-0 items-center justify-center rounded-md`,onClick:()=>{Y(e),Nt(!0)},children:(0,M.jsx)(S,{name:`trash`,size:14})})]},e.id)})}):(0,M.jsx)(Ue,{icon:`file`,title:`还没有分析记录`,hint:`上面选一份需求文档,系统会新建一份分析并进入用户故事拆解。`}):Gt.length?(0,M.jsx)(`div`,{className:`divide-y divide-stone-100`,children:Gt.map(({doc:e,rows:t})=>{let n=st.includes(e.id),r=t.map(e=>e.story.id),i=W?.docId===e.id&&r.length>0&&r.every(e=>Kt.has(e));return(0,M.jsxs)(`section`,{children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/70 px-3 py-1.5`,children:[(0,M.jsx)(`input`,{type:`checkbox`,"aria-label":`选中 ${e.title} 的全部故事`,checked:i,onChange:()=>Jt(e.id,r)}),(0,M.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>ct(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id]),children:[(0,M.jsx)(S,{name:n?`chevronRight`:`chevronDown`,size:13,className:`shrink-0 text-stone-400`}),(0,M.jsx)(`span`,{className:`truncate text-xs font-medium text-stone-700`,children:e.title}),(0,M.jsxs)(`span`,{className:`shrink-0 text-[11px] text-stone-400`,children:[t.length,` 个故事 · `,At(e.updatedAt)]})]}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] text-[#3370ff] hover:underline`,onClick:()=>Z(e,`stories`),children:`打开拆解`})]}),n?null:(0,M.jsx)(`ul`,{className:`divide-y divide-stone-50`,children:t.map(({story:t})=>(0,M.jsxs)(`li`,{className:`flex items-start gap-2 px-4 py-2 transition-colors hover:bg-stone-50`,children:[(0,M.jsx)(`input`,{type:`checkbox`,className:`mt-1`,"aria-label":`选中 ${t.id}`,checked:Kt.has(t.id)&&W?.docId===e.id,onChange:()=>qt(e.id,t.id)}),(0,M.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left`,onClick:()=>Ht(e,t.id),children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-stone-400`,children:t.id}),(0,M.jsx)(`span`,{className:`truncate text-sm text-stone-800`,children:t.title})]}),(0,M.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,M.jsxs)(`span`,{children:[`角色:`,t.role]}):null,(0,M.jsxs)(`span`,{children:[`优先级 `,t.priority]}),(0,M.jsxs)(`span`,{children:[`验收 `,t.acceptance.length]}),(0,M.jsxs)(`span`,{children:[`异常 `,t.exceptions.length]}),(0,M.jsxs)(`span`,{children:[`维度 `,t.dimensions.length]})]})]})]},`${e.id}-${t.id}`))})]},e.id)})}):(0,M.jsx)(Ue,{icon:`file`,title:U?`没有匹配的用户故事`:`还没有用户故事`,hint:U?`换个编号、标题或角色再试。`:`先按「需求说明书」选中一份文档拆解,故事会自动出现在这里。`})})]})]});return(0,M.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col p-3`,children:[et===`list`?En:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`mb-2 flex shrink-0 items-center gap-2`,children:[(0,M.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:()=>{y(``),L(``),X(`list`)},children:[(0,M.jsx)(S,{name:`arrowLeft`,size:14}),`返回列表`]}),(0,M.jsx)(`span`,{className:`min-w-0 truncate text-xs text-stone-400`,children:v?.title?`用户故事 · ${v.title}`:`用户故事`})]}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-4`,children:[(0,M.jsxs)(`aside`,{className:`flex w-[280px] shrink-0 flex-col gap-3 overflow-y-auto pb-1`,children:[(0,M.jsxs)(`section`,{"data-hint-width":!0,className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between border-b border-stone-100 px-3.5 py-2.5`,children:[(0,M.jsx)(`p`,{className:Et,children:`分析记录`}),(0,M.jsx)(`span`,{className:`text-[11px] tabular-nums text-stone-400`,children:h.length})]}),(0,M.jsx)(`div`,{className:`px-2 py-2`,children:h.length?(0,M.jsx)(`ul`,{className:`space-y-0.5`,children:h.map(e=>{let t=e.id===_,n=zt(e.status);return(0,M.jsx)(`li`,{children:(0,M.jsx)(`button`,{type:`button`,className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition-colors ${t?`bg-[#eef3ff]`:`hover:bg-stone-50`}`,onClick:()=>Y(e),children:(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(f,{text:e.title,matchAnchorWidth:!0,className:`block truncate text-xs ${t?`font-medium text-[#1f4fd8]`:`text-stone-700`}`}),(0,M.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 text-[11px] text-stone-400`,children:[(0,M.jsx)(x,{tone:n.tone,children:n.label}),(0,M.jsxs)(`span`,{children:[e.stories.length,` 个故事`]})]})]})})},e.id)})}):(0,M.jsx)(`p`,{className:`px-1.5 py-1 text-xs text-stone-400`,children:`还没有分析记录,选一份来源文档开始。`})})]}),(0,M.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsx)(`div`,{className:`border-b border-stone-100 px-3.5 py-2.5`,children:(0,M.jsx)(`p`,{className:Et,children:`提示词`})}),(0,M.jsxs)(`div`,{className:`px-3.5 py-3`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(Mt,{name:ce,ready:$t}),(0,M.jsx)(Mt,{name:T?.file??`用户故事审查提示词.md`,ready:t.on&&!!T?.review.trim()&&!!T?.fix.trim()}),(0,M.jsx)(Mt,{name:Oe,ready:l.on&&!!E?.generate.trim()})]}),(0,M.jsx)(`p`,{className:`mt-2 text-[11px] ${rn?`text-stone-400`:`text-amber-700`}`,children:rn?`模型:${b?.model}`:`还没配置模型`})]})]}),(0,M.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsx)(`div`,{className:`border-b border-stone-100 px-3.5 py-2.5`,children:(0,M.jsx)(`p`,{className:Et,children:`动作`})}),(0,M.jsxs)(`div`,{className:`space-y-2 px-3.5 py-3`,children:[(0,M.jsx)(`button`,{type:`button`,className:`${wt} w-full`,disabled:!v||!!O||!v.sourcePath,onClick:()=>{v?.stories.length?Ft(!0):on()},children:O===`decompose`?`拆解中…`:v?.stories.length?`重新拆解`:`开始拆解`}),t.on?(0,M.jsx)(`button`,{type:`button`,className:`${Tt} w-full`,disabled:!v||!!O||!v.stories.length,onClick:()=>void sn(),children:O===`audit`?`审查中…`:v?.check?`重新审查用户故事`:`用户故事审查`}):null,l.on?(0,M.jsx)(`button`,{type:`button`,className:`${Tt} w-full`,disabled:!v||!!O||!v.stories.length,onClick:()=>void un(),children:O===`testpoints`?`生成中…`:v?.testPoints?`重新生成测试点`:`生成测试点`}):null,O?(0,M.jsx)(`button`,{type:`button`,className:`${Tt} w-full`,onClick:Cn,children:`中断`}):(0,M.jsx)(`button`,{type:`button`,className:`${Tt} w-full`,disabled:!v,onClick:xn,children:`导出 Markdown`}),v&&!O?(0,M.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:()=>Nt(!0),children:`删除这份分析`}):null]})]}),(0,M.jsxs)(`section`,{className:`flex min-h-[140px] flex-1 flex-col rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-stone-100 px-3.5 py-2.5`,children:[(0,M.jsx)(`p`,{className:Et,children:`活动日志`}),N.length?(0,M.jsx)(`button`,{type:`button`,className:`text-[11px] text-stone-400 transition-colors hover:text-stone-600`,onClick:()=>P([]),children:`清空`}):null]}),(0,M.jsx)(`div`,{ref:Lt,className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-3.5 py-2.5`,children:N.length?N.map(e=>(0,M.jsxs)(`p`,{className:`flex gap-1.5 text-[11px] leading-relaxed`,children:[(0,M.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,M.jsx)(`span`,{className:e.kind===`error`?`text-red-600`:`text-stone-500`,children:e.text})]},e.id)):(0,M.jsx)(`p`,{className:`text-[11px] leading-relaxed text-stone-400`,children:`拆解 / 审查的过程会记在这里:抽取需求条目、写故事、跑审查与补写。`})})]})]}),(0,M.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[I?(0,M.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,M.jsx)(`span`,{className:`break-all`,children:I}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>L(``),children:`✕`})]}):null,v?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`header`,{className:`shrink-0 rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`px-4 pt-3`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`input`,{className:`min-w-0 flex-1 rounded-md border border-transparent bg-transparent px-1 py-0.5 text-[15px] font-semibold text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`,defaultValue:v.title,"aria-label":`分析标题`,onBlur:e=>yn(e.target.value)},v.id),O?(0,M.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-xs text-stone-500`,children:[(0,M.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`}),A?A.message:O===`decompose`?`拆解中`:O===`audit`?`审查中`:O===`testpoints`?`生成测试点中`:O===`fix`?`补写中`:`处理中`,A&&A.total>0?(0,M.jsxs)(`span`,{className:`tabular-nums text-stone-400`,children:[Math.round(Math.min(A.done,A.total)/A.total*100),`%`]}):null]}):null,(0,M.jsx)(x,{tone:zt(v.status).tone,children:zt(v.status).label})]}),O?(0,M.jsx)(`div`,{className:`mt-2`,children:(0,M.jsx)(`div`,{className:`tw-run-track`,role:`progressbar`,"aria-label":`${A?.label??`任务`}进度`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":A&&A.total>0?Math.round(Math.min(A.done,A.total)/A.total*100):void 0,children:(0,M.jsx)(`div`,{className:A&&A.total>0?`tw-run-fill`:`tw-run-fill tw-run-fill--indeterminate`,style:A&&A.total>0?{width:`${Math.round(Math.min(A.done,A.total)/A.total*100)}%`}:void 0})})}):null,(0,M.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-2.5 text-[11px] text-stone-400`,children:[(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`故事`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:v.stories.length})]}),(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`条目`,` `,(0,M.jsxs)(`span`,{className:`font-medium text-stone-600`,children:[wn,`/`,v.outline.length]}),` `,`覆盖`]}),t.on?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`缺口`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:Tn.length}),en?` · 已选 ${en}`:``]}),v.check?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`覆盖率`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:v.check.coverage.total?`${Math.round(v.check.coverage.rate*100)}%`:`—`})]})]}):null]}):null,l.on?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`测试点`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:v.testPoints?.points.length??0})]})]}):null,(0,M.jsxs)(`span`,{className:`ml-auto min-w-0 truncate pl-2`,children:[`来源:`,v.sourcePath]}),Xt?(0,M.jsx)(`span`,{className:`shrink-0 rounded bg-amber-50 px-1.5 py-0.5 text-[10px] text-amber-700`,children:`源文档已更新`}):null]})]}),(0,M.jsx)(`div`,{role:`tablist`,"aria-label":`需求分析视图`,className:`mt-2.5 flex items-center gap-1 border-b border-stone-100 px-2`,children:[{id:`stories`,label:`用户故事`,count:v.stories.length},{id:`check`,label:`审查结果`,count:Tn.length},{id:`outline`,label:`需求条目`,count:v.outline.length},{id:`points`,label:`测试点`,count:v.testPoints?.points.length??0}].filter(e=>(e.id!==`check`||t.on)&&(e.id!==`points`||l.on)).map(e=>{let t=R===e.id;return(0,M.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,className:`-mb-px flex items-center gap-1.5 border-b-2 px-3 py-2 text-xs transition-colors ${t?`border-[#3370ff] font-medium text-[#3370ff]`:`border-transparent text-stone-500 hover:text-stone-800`}`,onClick:()=>z(e.id),children:[e.label,(0,M.jsx)(`span`,{className:`rounded-full px-1.5 text-[10px] leading-4 tabular-nums ${t?`bg-[#eaf1ff] text-[#3370ff]`:`bg-stone-100 text-stone-400`}`,children:e.count})]},e.id)})})]}),(0,M.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 overflow-y-auto pr-1`,children:[R===`stories`?v.stories.length?(0,M.jsx)(`ul`,{className:`space-y-2`,children:v.stories.map((e,t)=>(0,M.jsx)(ut,{story:e,index:t,total:v.stories.length,gaps:Tn.filter(t=>t.storyId===e.id),busy:!!O,onSave:e=>mn(t,e),onDelete:()=>hn(t),onMove:e=>gn(t,e),domId:e.id?`req-story-${e.id}`:void 0},`${e.id}-${t}`))}):(0,M.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,M.jsx)(Ue,{icon:`file`,title:`还没有用户故事`,hint:`点左侧「开始拆解」,会先抽需求条目再拆故事。`})}):null,R===`check`&&t.on?(0,M.jsx)($e,{check:v.check,stories:v.stories,busy:!!O,onToggleGap:_n,onToggleAll:vn,onFix:()=>void ln(),onReview:()=>void sn(),onExport:Sn}):null,R===`points`&&l.on?(0,M.jsx)(tt,{doc:v,generating:O===`testpoints`,busy:!!O,promptReady:!!E?.generate.trim(),onGenerate:()=>void un(),onExportXmind:()=>void dn(),onExportMarkdown:fn}):null,R===`outline`?v.outline.length?(0,M.jsx)(`ul`,{className:`space-y-2`,children:v.outline.map(e=>{let t=Zt.has(e.id);return(0,M.jsx)(`li`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-2.5`,children:(0,M.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,M.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,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`p`,{className:`text-sm text-stone-800`,children:[(0,M.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,M.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,M.jsx)(`span`,{className:`shrink-0 text-[11px] ${t?`text-emerald-600`:`text-amber-600`}`,children:t?`已覆盖`:`未覆盖`})]})},e.id)})}):(0,M.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,M.jsx)(Ue,{icon:`file`,title:`还没有需求条目`,hint:`拆解时模型会先抽条目,覆盖率按条目统计。`})}):null]}),Qe?(0,M.jsxs)(`details`,{className:`mt-2 shrink-0 rounded-xl border border-stone-200 bg-white px-3 py-2`,children:[(0,M.jsx)(`summary`,{className:`cursor-pointer text-xs text-stone-500`,children:`模型说明(本轮)`}),(0,M.jsx)(`pre`,{className:`mt-1 max-h-[180px] overflow-y-auto whitespace-pre-wrap break-words text-[11px] leading-relaxed text-stone-600`,children:Qe})]}):null]}):(0,M.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,M.jsx)(Ue,{icon:`file`,title:`还没有选来源`,hint:`左侧选一份「需求文档库」里的 Word / Excel / Markdown / txt,系统会新建一份分析。`})})]})]})]}),(0,M.jsx)(d,{open:St,title:`删除分析记录`,message:`确认删除「${v?.title??``}」?故事、需求条目、体检报告与测试点都会一起删掉,来源需求文档不受影响。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>Nt(!1),onConfirm:()=>void bn()}),(0,M.jsx)(d,{open:Pt,title:`重新拆解`,message:`重新拆解会用模型结果替换当前 ${v?.stories.length??0} 个用户故事,旧体检报告、测试点与需求条目也会一起清掉,编号从 US-001 重新开始。`,confirmLabel:`重新拆解`,onClose:()=>Ft(!1),onConfirm:()=>{Ft(!1),on()}})]})}export{Nt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.Bm4oN4YP.js";import{i as r,o as i,s as a}from"./plugins.CCqu2gnf.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.C6R2nQ60.js";import{showToast as l}from"./Toast.BO2NFckG.js";import{a as u,c as te,f as ne,h as re,i as ie,l as ae,m as oe,n as se,o as d,p as ce,r as f,s as p,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 m}from"./NamePromptDialog.CS1pTTVl.js";var h=e(t(),1),g=o(),pe=5;function _({className:e=`w-4 h-4`,open:t=!1}){return(0,g.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,g.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,g.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 v({className:e=`w-3 h-3`}){return(0,g.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,g.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,g.jsx)(`path`,{d:`m15 5 4 4`})]})}function y({className:e=`w-3 h-3`}){return(0,g.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,g.jsx)(`path`,{d:`M3 6h18`}),(0,g.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,g.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,g.jsx)(`path`,{d:`M10 11v6`}),(0,g.jsx)(`path`,{d:`M14 11v6`})]})}function b({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,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,g.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,g.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,g.jsx)(_,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,g.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,g.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,g.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,g.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,g.jsx)(b,{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 x(){let[e,t]=(0,h.useState)(()=>r(`requirements`)),[o,x]=(0,h.useState)(!1),[S,he]=(0,h.useState)(null),[C,ge]=(0,h.useState)([]),[_e,ve]=(0,h.useState)(0),[w,T]=(0,h.useState)(`.`),[E,D]=(0,h.useState)([]),[ye,O]=(0,h.useState)({}),[k,be]=(0,h.useState)(!0),[A,j]=(0,h.useState)(null),[M,N]=(0,h.useState)(!1),[P,F]=(0,h.useState)(null),[xe,I]=(0,h.useState)(!1),[L,R]=(0,h.useState)(null),[z,B]=(0,h.useState)(null),[Se,V]=(0,h.useState)(1),[H,Ce]=c(pe),[we,U]=(0,h.useState)(null),W=(0,h.useRef)(null),{cls:Te,play:G}=fe(),K=(0,h.useCallback)(async()=>{let e=await ie(`requirements`);ge(e.tree),ve(e.totalFiles)},[]),q=(0,h.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([p(`requirements`,e),K()]);D(t.entries),T(t.path)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,K]);(0,h.useEffect)(()=>{let e=i(e=>t(!!e.requirements));return n().then(()=>{t(r(`requirements`)),x(!0)}),e},[]),(0,h.useEffect)(()=>{o&&e&&(async()=>{let e=await f(`requirements`);if(he(e),e)try{let[e]=await Promise.all([p(`requirements`,`.`),K()]);D(e.entries),T(e.path)}catch(e){j(e instanceof Error?e.message:String(e))}})()},[o,e,K]);function Ee(){be(e=>!e),O({})}async function J(e){G(),T(e),V(1),F(null),U(null),j(null);try{let t=await p(`requirements`,e);D(t.entries)}catch(e){j(e instanceof Error?e.message:String(e))}}async function De(e){I(!1),N(!0),j(null);try{await te(`requirements`,w,e),await q(w),l(`已新建文件夹「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`新建文件夹失败:${t}`,`error`)}finally{N(!1)}}async function Oe(e){if(e.type===`file`){N(!0),j(null);try{await ae(`requirements`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function ke(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await re(`requirements`,w,t);await q(w),l(`已上传 ${e.length} 个文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`上传失败:${t}`,`error`)}finally{N(!1),W.current&&(W.current.value=``)}}}function Ae(e){let t=u(C,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 je(e){R({name:e.name,path:e.path,isDir:!1})}function Y(e,t){B({...e,isDir:t})}async function Me(){let e=L;if(e&&(R(null),!e.blocked)){N(!0),j(null);try{await se(`requirements`,e.path),P&&d(P.path,e.path)&&F(null);let t=d(w,e.path)?ue(e.path):w;await q(t),l(`已删除「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`删除失败:${t}`,`error`)}finally{N(!1)}}}async function Ne(e){let t=z;if(t&&(B(null),e!==t.name)){N(!0),j(null);try{let n=await oe(`requirements`,t.path,e);await q(ce(w,t.path,n)),l(`已重命名为「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`重命名失败:${t}`,`error`)}finally{N(!1)}}}let Pe=(()=>{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 Fe(e){if(e.type!==`file`)return;let t=e.name.toLowerCase();if(!t.endsWith(`.md`)&&!t.endsWith(`.txt`))j(`仅 .md / .txt 支持就地预览;docx / xlsx / csv 请双击用本机程序打开。`);else{N(!0),j(null);try{let t=await ne(`requirements`,e.path);F({path:t.path,content:t.content})}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}if(!o)return(0,g.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,g.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,g.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(S===null)return(0,g.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,g.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!S)return(0,g.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/H)),$=Math.min(Se,Q),Ie=X.slice(($-1)*H,$*H);function Le(e){G(),Ce(e),V(1)}return(0,g.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,g.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,g.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,g.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>I(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,g.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,g.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,g.jsxs)(`button`,{type:`button`,onClick:()=>{J(`.`),Ee()},"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,g.jsx)(_,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,g.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部需求`}),(0,g.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,_e,`)`]})]})}),(0,g.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,g.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:C.map(e=>(0,g.jsx)(b,{node:e,depth:0,activePath:w,expanded:ye,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void J(e)},e.path))})})]})]}),(0,g.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,g.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,g.jsx)(`span`,{className:`text-stone-400`,children:de(`requirements`)}),w===`.`?``:w]}),(0,g.jsx)(`input`,{ref:W,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,text/csv,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel`,className:`hidden`,onChange:e=>void ke(e.target.files)}),(0,g.jsx)(`button`,{type:`button`,disabled:M,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:`上传文件`})]}),A?(0,g.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,g.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,g.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,g.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,g.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,g.jsx)(_,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,g.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"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,g.jsx)(v,{className:`w-3.5 h-3.5`})}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Ae({name:e.name,path:e.path}),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,g.jsx)(y,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,g.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加需求文档(.md / .txt / .docx / .xlsx / .csv)`}):(0,g.jsx)(`ul`,{className:`${Te}space-y-1`,children:Ie.map(e=>{let t=we===e.path;return(0,g.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,g.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,onClick:()=>{U(e.path),Fe(e)},onDoubleClick:t=>{t.preventDefault(),Oe(e)},children:[(0,g.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,g.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:me(e.size)})]}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"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,g.jsx)(v,{className:`w-3.5 h-3.5`})}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>je(e),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,g.jsx)(y,{className:`w-3.5 h-3.5`})})]},e.path)})})]}),P?(0,g.jsxs)(`div`,{className:`rounded-lg border border-stone-200 overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`px-3 py-2 bg-stone-50 border-b border-stone-200 flex items-center justify-between`,children:[(0,g.jsx)(`span`,{className:`text-xs text-stone-500 truncate`,children:P.path}),(0,g.jsx)(`button`,{type:`button`,className:`text-xs text-stone-500 hover:text-stone-800`,onClick:()=>F(null),children:`关闭预览`})]}),(0,g.jsx)(`pre`,{className:`max-h-80 overflow-auto p-4 text-xs leading-5 text-stone-700 whitespace-pre-wrap bg-white`,children:P.content})]}):null]}),X.length>0?(0,g.jsx)(ee,{page:$,totalPages:Q,pageSize:H,busy:M,onPage:e=>{G(),V(e)},onPageSize:Le}):null]}),(0,g.jsx)(m,{open:xe,title:`新建文件夹`,onClose:()=>I(!1),onConfirm:e=>void De(e)}),(0,g.jsx)(m,{open:z!=null,title:z?.isDir?`重命名文件夹`:`重命名文件`,label:z?.isDir?`文件夹名称`:`文件名称`,initialValue:z?.name??``,lockExtension:z!=null&&!z.isDir,confirmLabel:`保存`,onClose:()=>B(null),onConfirm:e=>void Ne(e)}),(0,g.jsx)(s,{open:L!=null,title:L?.blocked?`无法删除文件夹`:L?.isDir?`删除文件夹`:`删除需求文件`,message:Pe,confirmLabel:L?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!L?.blocked,hideCancel:!!L?.blocked,onClose:()=>R(null),onConfirm:()=>void Me()})]})}export{x as default};
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{i as r,o as i,s as a}from"./plugins.DYyAjBXb.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.v4kQH163.js";import{showToast as l}from"./Toast.BO2NFckG.js";import{a as u,c as te,f as ne,h as re,i as ie,l as ae,m as oe,n as se,o as d,p as ce,r as f,s as p,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 m}from"./NamePromptDialog.CS1pTTVl.js";var h=e(t(),1),g=o(),pe=5;function _({className:e=`w-4 h-4`,open:t=!1}){return(0,g.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,g.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,g.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 v({className:e=`w-3 h-3`}){return(0,g.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,g.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,g.jsx)(`path`,{d:`m15 5 4 4`})]})}function y({className:e=`w-3 h-3`}){return(0,g.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,g.jsx)(`path`,{d:`M3 6h18`}),(0,g.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,g.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,g.jsx)(`path`,{d:`M10 11v6`}),(0,g.jsx)(`path`,{d:`M14 11v6`})]})}function b({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,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,g.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,g.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,g.jsx)(_,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,g.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,g.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,g.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,g.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,g.jsx)(b,{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 x(){let[e,t]=(0,h.useState)(()=>r(`requirements`)),[o,x]=(0,h.useState)(!1),[S,he]=(0,h.useState)(null),[C,ge]=(0,h.useState)([]),[_e,ve]=(0,h.useState)(0),[w,T]=(0,h.useState)(`.`),[E,D]=(0,h.useState)([]),[ye,O]=(0,h.useState)({}),[k,be]=(0,h.useState)(!0),[A,j]=(0,h.useState)(null),[M,N]=(0,h.useState)(!1),[P,F]=(0,h.useState)(null),[xe,I]=(0,h.useState)(!1),[L,R]=(0,h.useState)(null),[z,B]=(0,h.useState)(null),[Se,V]=(0,h.useState)(1),[H,Ce]=c(pe),[we,U]=(0,h.useState)(null),W=(0,h.useRef)(null),{cls:Te,play:G}=fe(),K=(0,h.useCallback)(async()=>{let e=await ie(`requirements`);ge(e.tree),ve(e.totalFiles)},[]),q=(0,h.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([p(`requirements`,e),K()]);D(t.entries),T(t.path)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,K]);(0,h.useEffect)(()=>{let e=i(e=>t(!!e.requirements));return n().then(()=>{t(r(`requirements`)),x(!0)}),e},[]),(0,h.useEffect)(()=>{o&&e&&(async()=>{let e=await f(`requirements`);if(he(e),e)try{let[e]=await Promise.all([p(`requirements`,`.`),K()]);D(e.entries),T(e.path)}catch(e){j(e instanceof Error?e.message:String(e))}})()},[o,e,K]);function Ee(){be(e=>!e),O({})}async function J(e){G(),T(e),V(1),F(null),U(null),j(null);try{let t=await p(`requirements`,e);D(t.entries)}catch(e){j(e instanceof Error?e.message:String(e))}}async function De(e){I(!1),N(!0),j(null);try{await te(`requirements`,w,e),await q(w),l(`已新建文件夹「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`新建文件夹失败:${t}`,`error`)}finally{N(!1)}}async function Oe(e){if(e.type===`file`){N(!0),j(null);try{await ae(`requirements`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function ke(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await re(`requirements`,w,t);await q(w),l(`已上传 ${e.length} 个文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`上传失败:${t}`,`error`)}finally{N(!1),W.current&&(W.current.value=``)}}}function Ae(e){let t=u(C,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 je(e){R({name:e.name,path:e.path,isDir:!1})}function Y(e,t){B({...e,isDir:t})}async function Me(){let e=L;if(e&&(R(null),!e.blocked)){N(!0),j(null);try{await se(`requirements`,e.path),P&&d(P.path,e.path)&&F(null);let t=d(w,e.path)?ue(e.path):w;await q(t),l(`已删除「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`删除失败:${t}`,`error`)}finally{N(!1)}}}async function Ne(e){let t=z;if(t&&(B(null),e!==t.name)){N(!0),j(null);try{let n=await oe(`requirements`,t.path,e);await q(ce(w,t.path,n)),l(`已重命名为「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`重命名失败:${t}`,`error`)}finally{N(!1)}}}let Pe=(()=>{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 Fe(e){if(e.type!==`file`)return;let t=e.name.toLowerCase();if(!t.endsWith(`.md`)&&!t.endsWith(`.txt`))j(`仅 .md / .txt 支持就地预览;docx / xlsx / csv 请双击用本机程序打开。`);else{N(!0),j(null);try{let t=await ne(`requirements`,e.path);F({path:t.path,content:t.content})}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}if(!o)return(0,g.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,g.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,g.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(S===null)return(0,g.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,g.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!S)return(0,g.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/H)),$=Math.min(Se,Q),Ie=X.slice(($-1)*H,$*H);function Le(e){G(),Ce(e),V(1)}return(0,g.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,g.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,g.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,g.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>I(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,g.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,g.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,g.jsxs)(`button`,{type:`button`,onClick:()=>{J(`.`),Ee()},"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,g.jsx)(_,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,g.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部需求`}),(0,g.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,_e,`)`]})]})}),(0,g.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,g.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:C.map(e=>(0,g.jsx)(b,{node:e,depth:0,activePath:w,expanded:ye,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void J(e)},e.path))})})]})]}),(0,g.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,g.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,g.jsx)(`span`,{className:`text-stone-400`,children:de(`requirements`)}),w===`.`?``:w]}),(0,g.jsx)(`input`,{ref:W,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,text/csv,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel`,className:`hidden`,onChange:e=>void ke(e.target.files)}),(0,g.jsx)(`button`,{type:`button`,disabled:M,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:`上传文件`})]}),A?(0,g.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,g.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,g.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,g.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,g.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,g.jsx)(_,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,g.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"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,g.jsx)(v,{className:`w-3.5 h-3.5`})}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Ae({name:e.name,path:e.path}),className:`tw-icon-danger p-1.5 rounded`,children:(0,g.jsx)(y,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,g.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加需求文档(.md / .txt / .docx / .xlsx / .csv)`}):(0,g.jsx)(`ul`,{className:`${Te}space-y-1`,children:Ie.map(e=>{let t=we===e.path;return(0,g.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,g.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,onClick:()=>{U(e.path),Fe(e)},onDoubleClick:t=>{t.preventDefault(),Oe(e)},children:[(0,g.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,g.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:me(e.size)})]}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"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,g.jsx)(v,{className:`w-3.5 h-3.5`})}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>je(e),className:`tw-icon-danger p-1.5 rounded`,children:(0,g.jsx)(y,{className:`w-3.5 h-3.5`})})]},e.path)})})]}),P?(0,g.jsxs)(`div`,{className:`rounded-lg border border-stone-200 overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`px-3 py-2 bg-stone-50 border-b border-stone-200 flex items-center justify-between`,children:[(0,g.jsx)(`span`,{className:`text-xs text-stone-500 truncate`,children:P.path}),(0,g.jsx)(`button`,{type:`button`,className:`text-xs text-stone-500 hover:text-stone-800`,onClick:()=>F(null),children:`关闭预览`})]}),(0,g.jsx)(`pre`,{className:`max-h-80 overflow-auto p-4 text-xs leading-5 text-stone-700 whitespace-pre-wrap bg-white`,children:P.content})]}):null]}),X.length>0?(0,g.jsx)(ee,{page:$,totalPages:Q,pageSize:H,busy:M,onPage:e=>{G(),V(e)},onPageSize:Le}):null]}),(0,g.jsx)(m,{open:xe,title:`新建文件夹`,onClose:()=>I(!1),onConfirm:e=>void De(e)}),(0,g.jsx)(m,{open:z!=null,title:z?.isDir?`重命名文件夹`:`重命名文件`,label:z?.isDir?`文件夹名称`:`文件名称`,initialValue:z?.name??``,lockExtension:z!=null&&!z.isDir,confirmLabel:`保存`,onClose:()=>B(null),onConfirm:e=>void Ne(e)}),(0,g.jsx)(s,{open:L!=null,title:L?.blocked?`无法删除文件夹`:L?.isDir?`删除文件夹`:`删除需求文件`,message:Pe,confirmLabel:L?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!L?.blocked,hideCancel:!!L?.blocked,onClose:()=>R(null),onConfirm:()=>void Me()})]})}export{x as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{p as n}from"./app-config.CF1xVPmo.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./OverflowHint.pvo2Xc8R.js";import{t as a}from"./SelectDropdown.Cb-QtC-D.js";import{i as o}from"./case-types.DS1EQ5yP.js";var s=`/__tb_case_sessions`,c=`tw.case.sessions.v1`,l=!1;function u(){return`csess_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function d(e){if(typeof e==`string`&&e.trim()){let t=e.trim();return o().some(e=>e.id===t),t}return o()[0]?.id??`functional`}function f(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:d(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 p(){try{let e=localStorage.getItem(n(c));return e?f(JSON.parse(e)):{sessions:[],activeId:``}}catch{return{sessions:[],activeId:``}}}function m(e){try{localStorage.setItem(n(c),JSON.stringify(e))}catch{}}async function h(){try{let e=await fetch(s,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json();l=!0;let n=f(t.store);return m(n),n}}catch{}return l=!1,p()}function g(){return p()}async function _(e){if(m(e),l)try{await fetch(s,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({store:e})})}catch{}}function v(e){m(e),_(e)}function y(e){let t=Date.now(),n={id:u(),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 v({sessions:[n,...p().sessions],activeId:n.id}),n}function b(e,t){let n=p(),r=n.sessions.map(n=>n.id===e?{...n,...t,updatedAt:Date.now()}:n),i={...n,sessions:r};return v(i),i}var x=e(t(),1),S=r();function C({options:e,values:t,onChange:n,placeholder:r=`选择…`,disabled:a=!1}){let[o,s]=(0,x.useState)(!1),c=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!o)return;function e(e){c.current?.contains(e.target)||s(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]);let l=e.filter(e=>t.includes(e.value)).map(e=>e.label),u=a||l.length===0?r:l.length<=2?l.join(`、`):`已选 ${l.length} 项`;function d(e){t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e])}return(0,S.jsxs)(`div`,{className:`relative mt-1`,ref:c,children:[(0,S.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>s(e=>!e),className:a?`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`:`tw-field-trigger 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,S.jsx)(i,{text:u,className:`min-w-0 flex-1 truncate ${a||l.length?``:`text-stone-400`}`}),(0,S.jsx)(`svg`,{className:`w-4 h-4 text-stone-400 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,S.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`})})]}),o?(0,S.jsx)(`div`,{className:`tw-select-menu tw-dsh-scroll tw-popover-anim absolute z-80 mt-1 max-h-72 w-full overflow-auto rounded-lg p-1 shadow-lg ring-1 ring-stone-200`,children:e.length===0?(0,S.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`暂无可选项`}):e.map(e=>{let n=t.includes(e.value);return(0,S.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,S.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>d(e.value),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,S.jsx)(i,{text:e.label,className:`min-w-0 flex-1 truncate`})]},e.value)})}):null]})}function w({options:e,value:t,onChange:n,placeholder:r=`搜索并选择…`,disabled:o=!1,allowEmpty:s=!0,emptyLabel:c=`不选择`}){let l=(0,x.useMemo)(()=>{let t=e.map(e=>({value:e.value,label:e.label}));return s?[{value:``,label:c,muted:!0},...t]:t},[e,s,c]),u=t?l.find(e=>e.value===t):void 0;return(0,S.jsx)(a,{options:l,value:t,onChange:n,disabled:o,searchable:!0,searchPlaceholder:r,dimWhenOpen:!0,renderTrigger:(e,{open:t})=>u?(0,S.jsx)(`span`,{className:`min-w-0 flex-1 ${t?`text-stone-400`:``}`,children:(0,S.jsx)(i,{text:u.label,className:`block truncate`})}):(0,S.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-stone-400`,children:r})})}export{g as a,h as i,C as n,v as o,y as r,b as s,w as t};
|
|
@@ -1 +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.
|
|
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.pvo2Xc8R.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:`shrink-0 border-b border-stone-100 bg-white px-1.5 py-1.5`,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?`tw-field-trigger 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?`tw-field-trigger 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`:`tw-field-trigger 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 flex max-h-64 flex-col overflow-hidden rounded-lg 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,(0,l.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-auto p-1 pb-2`,children:[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};
|