lantern-harness 0.1.42 → 0.1.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +2 -2
  3. package/builtin/session/lh-nav-groups.mjs +2 -0
  4. package/builtin/session/session-runs.mjs +179 -32
  5. package/cli/server.mjs +2 -0
  6. package/config/app.defaults.json +1 -0
  7. package/config/seeds//346/212/245/345/221/212/347/256/241/347/220/206//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/.gitkeep +0 -0
  8. package/config/seeds//346/212/245/345/221/212/347/256/241/347/220/206//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/.gitkeep +0 -0
  9. package/config/seeds//346/212/245/345/221/212/347/256/241/347/220/206//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/.gitkeep +0 -0
  10. package/config/seeds//346/217/220/347/244/272/350/257/215/347/256/241/347/220/206//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/217/220/347/244/272/350/257/215.md +18 -0
  11. package/config/seeds//346/217/220/347/244/272/350/257/215/347/256/241/347/220/206//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/217/220/347/244/272/350/257/215.md +18 -0
  12. package/config/seeds//346/217/220/347/244/272/350/257/215/347/256/241/347/220/206//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/217/220/347/244/272/350/257/215.md +18 -0
  13. package/dist/500.html +7 -4
  14. package/dist/_astro/Base.BnVp5Mf8.css +1 -0
  15. package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.BqOtiCPG.js → Base.astro_astro_type_script_index_0_lang.Chv7r8_9.js} +2 -2
  16. package/dist/_astro/{CaseExecBoard.1aCJ_MsC.js → CaseExecBoard.DUMjSunb.js} +1 -1
  17. package/dist/_astro/{CaseGenerateApp.DW0HJj-e.js → CaseGenerateApp.DtuOyQuv.js} +1 -1
  18. package/dist/_astro/{CasesLibrary.BNgrULER.js → CasesLibrary.B9o_jvXb.js} +1 -1
  19. package/dist/_astro/ChatApp.CKPGFibd.js +227 -0
  20. package/dist/_astro/{DashboardBoard.DW_kipSk.js → DashboardBoard.DEvgMoqo.js} +1 -1
  21. package/dist/_astro/{DocsFileBrowser.DceJyP9V.js → DocsFileBrowser.D66pN9rp.js} +1 -1
  22. package/dist/_astro/{DocsPager.D0TMvJ67.js → DocsPager.ceBEecmd.js} +1 -1
  23. package/dist/_astro/{KnowledgeLibrary.C-_UybI5.js → KnowledgeLibrary.DYqE2mRi.js} +1 -1
  24. package/dist/_astro/{LifeKrTasksBoard.DktIT_uO.js → LifeKrTasksBoard.B7UiEutA.js} +1 -1
  25. package/dist/_astro/{LifeKrTodosBoard.DVUmgRmh.js → LifeKrTodosBoard.VL7HdhNY.js} +1 -1
  26. package/dist/_astro/{LifeObjectivesBoard.Cjg3hCkJ.js → LifeObjectivesBoard.lLBPOHEZ.js} +1 -1
  27. package/dist/_astro/{LifePlanTypeSelect.C63oD8zZ.js → LifePlanTypeSelect.CdKQmlEK.js} +1 -1
  28. package/dist/_astro/{LifeReviewsBoard.Bj4otl26.js → LifeReviewsBoard.AjO4SbsR.js} +1 -1
  29. package/dist/_astro/{LifeShared.-pwCbSyP.js → LifeShared.CtdsQI43.js} +1 -1
  30. package/dist/_astro/{LifeStagesBoard.DJpc4f7A.js → LifeStagesBoard.Dl-kTZ6K.js} +1 -1
  31. package/dist/_astro/{LifeYearCycleSelect.CObXQA5s.js → LifeYearCycleSelect.BILJOKXK.js} +1 -1
  32. package/dist/_astro/{LifeYearPlansBoard.Bt6Hc8M9.js → LifeYearPlansBoard.BzJmi7Hw.js} +1 -1
  33. package/dist/_astro/{NavLibraries.D9EKoN80.js → NavLibraries.BnaL-km5.js} +1 -1
  34. package/dist/_astro/PluginsPage.CMW4hEFr.js +1 -0
  35. package/dist/_astro/{PluginsPage.DwmK_UF-.js → PluginsPage.D2OrUGY3.js} +2 -2
  36. package/dist/_astro/{PmBugsBoard.NUiKlz46.js → PmBugsBoard.BynUocbE.js} +1 -1
  37. package/dist/_astro/{PmIterationsBoard.C8F55feg.js → PmIterationsBoard.CvFblvfX.js} +1 -1
  38. package/dist/_astro/{PmProjectDetail.CMiWhGxn.js → PmProjectDetail.Dlm6flwk.js} +1 -1
  39. package/dist/_astro/{PmProjectsBoard.-g9KAiZJ.js → PmProjectsBoard.B5vaWuax.js} +1 -1
  40. package/dist/_astro/PmRequirementsBoard.B8KTeso8.js +1 -0
  41. package/dist/_astro/{PmRequirementsBoard.C5_NcAzj.js → PmRequirementsBoard.piRWjiYA.js} +1 -1
  42. package/dist/_astro/{PmShared.D6iq_Z9g.js → PmShared.86HEsdd_.js} +1 -1
  43. package/dist/_astro/PromptMountDialog.DYojFMok.js +1 -0
  44. package/dist/_astro/PromptsLibrary.GpNbBTj1.js +1 -0
  45. package/dist/_astro/ReportsPage.B-xhGVEU.js +16 -0
  46. package/dist/_astro/{ReqAnalysisBoard.LSxbIIWk.js → ReqAnalysisBoard.B3sAOuAq.js} +1 -1
  47. package/dist/_astro/{RequirementsLibrary.Dat8rP5c.js → RequirementsLibrary.BGys7DeN.js} +1 -1
  48. package/dist/_astro/{SettingsDialog.D21ojRGF.js → SettingsDialog.CEyjZuxq.js} +1 -1
  49. package/dist/_astro/{SpaceSwitcher.Bw13MkIw.js → SpaceSwitcher.DJqvw5Lw.js} +1 -1
  50. package/dist/_astro/{TableFieldConfig.C_NeWm8L.js → TableFieldConfig.D0v9S2g3.js} +1 -1
  51. package/dist/_astro/{TasksBoard.wGJOOJpR.js → TasksBoard.DZ9LLl_c.js} +1 -1
  52. package/dist/_astro/{TemplatesLibrary.YIgI089k.js → TemplatesLibrary.iyj_kFMO.js} +1 -1
  53. package/dist/_astro/TestReportsLibrary.B6pf0d7W.js +1 -0
  54. package/dist/_astro/{TestStatsBoard.ETea2KcX.js → TestStatsBoard.DS_2bqWI.js} +1 -1
  55. package/dist/_astro/{TodosBoard.OfBeAGWO.js → TodosBoard.CYAVDD1W.js} +1 -1
  56. package/dist/_astro/UiAutoBoard.DSsiMfx2.js +9 -0
  57. package/dist/_astro/{app-config.C4rpn1Ix.js → app-config.DwpFFa5D.js} +1 -1
  58. package/dist/_astro/app-version.Dabxyva-.js +1 -0
  59. package/dist/_astro/{bash-tools.RQcI4_42.js → bash-tools.CfNj2sh0.js} +1 -1
  60. package/dist/_astro/{case-gen-run.FzgC_1Ki.js → case-gen-run.nrr97yK3.js} +1 -1
  61. package/dist/_astro/{case-template.C-GBxgBC.js → case-template.Cd2xNbgy.js} +1 -1
  62. package/dist/_astro/{case-types.CprZTsyX.js → case-types.B51yDRdf.js} +1 -1
  63. package/dist/_astro/{doc-roots.DAJP9Svr.js → doc-roots.CO3IBiY6.js} +1 -1
  64. package/dist/_astro/{hydrate-cache.DI6vqM0o.js → hydrate-cache.CoD1FB3T.js} +1 -1
  65. package/dist/_astro/{i18n.BJeTr39S.js → i18n.vo2aElR9.js} +2 -2
  66. package/dist/_astro/llm.DN5S1KBK.js +7 -0
  67. package/dist/_astro/markdown-client.BS19nLL3.js +62 -0
  68. package/dist/_astro/open-docs-in-session.DJtuI1C4.js +1 -0
  69. package/dist/_astro/plugins.BmKRnp4a.js +1 -0
  70. package/dist/_astro/project-docs.CCjtiFjB.js +1 -0
  71. package/dist/_astro/prompts-meta.bF2q5SUy.js +2 -0
  72. package/dist/_astro/{req-analysis.BqvytN69.js → req-analysis.qmyv5cBw.js} +1 -1
  73. package/dist/_astro/{settings.NTeTjmxg.js → settings.CYERib3l.js} +2 -2
  74. package/dist/_astro/{spaces-client.CMGNsQJ-.js → spaces-client.DvIgFink.js} +1 -1
  75. package/dist/_astro/{story-review.D8FfhzAi.js → story-review.2UUlN3p-.js} +1 -1
  76. package/dist/_astro/test-reports.DPQ-FMsQ.js +19 -0
  77. package/dist/_astro/{ui-auto-prompt.l_EXfDs5.js → ui-auto-prompt.COBTt5Gd.js} +1 -1
  78. package/dist/_astro/{view-prefs.8MPl3A7e.js → view-prefs.GnvelRDj.js} +1 -1
  79. package/dist/case-exec/index.html +8 -5
  80. package/dist/cases/generate/index.html +8 -5
  81. package/dist/cases/library/index.html +8 -5
  82. package/dist/dashboard/index.html +8 -5
  83. package/dist/docs/changelog/index.html +64 -48
  84. package/dist/docs/install/index.html +7 -4
  85. package/dist/docs/manual/index.html +32 -11
  86. package/dist/knowledge/index.html +8 -5
  87. package/dist/life/kr-tasks/index.html +8 -5
  88. package/dist/life/kr-todos/index.html +8 -5
  89. package/dist/life/objectives/index.html +8 -5
  90. package/dist/life/reviews/index.html +8 -5
  91. package/dist/life/stages/index.html +8 -5
  92. package/dist/life/year-plans/index.html +8 -5
  93. package/dist/plugins/index.html +8 -5
  94. package/dist/pm/bugs/index.html +8 -5
  95. package/dist/pm/iterations/index.html +8 -5
  96. package/dist/pm/projects/detail/index.html +8 -5
  97. package/dist/pm/projects/index.html +8 -5
  98. package/dist/pm/requirements/index.html +8 -5
  99. package/dist/prompts/index.html +8 -5
  100. package/dist/reports/index.html +8 -5
  101. package/dist/requirement-analysis/index.html +8 -5
  102. package/dist/requirements/index.html +8 -5
  103. package/dist/tasks/index.html +8 -5
  104. package/dist/templates/index.html +8 -5
  105. package/dist/test-automation/index.html +8 -5
  106. package/dist/test-reports/index.html +924 -0
  107. package/dist/test-stats/index.html +8 -5
  108. package/dist/todos/index.html +8 -5
  109. package/dist/workbench/index.html +8 -5
  110. package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +1 -1
  111. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +17 -6
  112. package/lh-plugins/lh-project-docs.mjs +10 -0
  113. package/lh-plugins/plugin-prompts.mjs +3 -0
  114. package/package.json +1 -1
  115. package/dist/_astro/Base.C-vZfmS4.css +0 -1
  116. package/dist/_astro/ChatApp.DzYFE67-.js +0 -226
  117. package/dist/_astro/PluginsPage.DayC2eOs.js +0 -1
  118. package/dist/_astro/PmRequirementsBoard.C0_6ye63.js +0 -1
  119. package/dist/_astro/PromptMountDialog.CpTT6L0a.js +0 -62
  120. package/dist/_astro/PromptsLibrary.DspwabiJ.js +0 -1
  121. package/dist/_astro/ReportsPage.DFsDsjow.js +0 -1
  122. package/dist/_astro/UiAutoBoard.Df2ky1Cs.js +0 -9
  123. package/dist/_astro/app-version.BEerieT3.js +0 -1
  124. package/dist/_astro/llm.DyweO-KK.js +0 -7
  125. package/dist/_astro/open-docs-in-session.5cTowYAC.js +0 -1
  126. package/dist/_astro/plugins.C0NrHGZv.js +0 -1
  127. package/dist/_astro/project-docs.DAw9bzgk.js +0 -1
  128. package/dist/_astro/prompts-meta.Dnmq-SnF.js +0 -2
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.C4rpn1Ix.js";import{i as r,o as i,s as a}from"./plugins.C0NrHGZv.js";import{a as o,b as ee,c as te,d as ne,f as re,g as ie,h as ae,i as s,l as oe,m as se,n as ce,o as c,p as l,r as u,s as d,u as f,v as p,x as le,y as ue}from"./case-exec.BMNk9OyF.js";import{r as de,s as fe}from"./view-prefs.8MPl3A7e.js";import{t as pe}from"./jsx-runtime.DUg_B_vD.js";import{t as m}from"./ConfirmDialog.D5qXeML0.js";import{t as h}from"./DatePicker.Bkl71M49.js";import{n as me,t as he}from"./DocsPager.D0TMvJ67.js";import{E as g}from"./PmShared.D6iq_Z9g.js";import{n as _,r as ge,t as _e}from"./TableFieldConfig.C_NeWm8L.js";import{t as v}from"./TagSelect.UUXgkMqJ.js";import{showToast as y}from"./Toast.BO2NFckG.js";var b=e(t(),1),x=pe(),ve=8e3,S=600,ye=20,be=`tw.case-exec.page-size.v1`,xe=`case-exec.search`,C=[{key:`select`,width:`6%`},{key:`date`,width:`16%`},{key:`total`,width:`10%`},{key:`pending`,width:`10%`},{key:`executed`,width:`10%`},{key:`remaining`,width:`10%`},{key:`ratio`,width:`14%`},{key:`createdAt`,width:`12%`},{key:`updatedAt`,width:`12%`},{key:`action`,width:`6%`}],Se=new Set([`select`,`date`,`action`]),Ce=[{key:`total`,label:`用例总数`},{key:`pending`,label:`待执行用例`},{key:`executed`,label:`已执行用例`},{key:`remaining`,label:`当前剩余用例`},{key:`ratio`,label:`执行比例`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],we=`case-exec.fields`,w=`h-8 w-full min-w-0 rounded-md border border-transparent bg-transparent px-1.5 text-center text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300 tabular-nums`,T=`h-8 w-full rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`,E=`h-7 shrink-0 rounded-md border bg-white px-2 text-xs font-medium whitespace-nowrap disabled:opacity-40`,D=(0,x.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,x.jsx)(`path`,{d:`M3 6h18`}),(0,x.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,x.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,x.jsx)(`path`,{d:`M10 11v6M14 11v6`})]}),O=(0,x.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,x.jsx)(`path`,{d:`M6 9l6 6 6-6`})});function k(e){let[t,n]=(0,b.useState)(e.value?String(e.value):``),r=(0,b.useRef)(e.value),i=(0,b.useRef)(e.onCommit);i.current=e.onCommit,(0,b.useEffect)(()=>{e.value!==r.current&&(r.current=e.value,n(e.value?String(e.value):``))},[e.value]),(0,b.useEffect)(()=>{let e=t?p(t):0;if(e===r.current)return;let n=window.setTimeout(()=>{r.current=e,i.current(e)},S);return()=>window.clearTimeout(n)},[t]);function a(){let e=t?p(t):0;e!==r.current&&(r.current=e,i.current(e))}return(0,x.jsx)(`input`,{type:`text`,inputMode:`numeric`,"aria-label":e.ariaLabel,value:t,placeholder:e.placeholder??`0`,onChange:e=>n(e.target.value.replace(/[^\d]/g,``)),onBlur:a,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),t.currentTarget.blur()):t.key===`Escape`&&(t.preventDefault(),r.current=e.value,n(e.value?String(e.value):``),t.currentTarget.blur())},className:w})}function A(e){return e>=80?{text:`text-[#4176e6]`,bar:`bg-[#3370ff]`}:e>=40?{text:`text-[#a85b00]`,bar:`bg-[#f5a524]`}:{text:`text-stone-500`,bar:`bg-stone-400`}}function j(e){let t=o(e.item,e.baseline),n=l(e.item,e.baseline),r=u(e.item,e.baseline),i=A(t);return(0,x.jsxs)(`div`,{className:`flex flex-col justify-center gap-1.5 px-1.5`,children:[(0,x.jsxs)(`div`,{className:`flex items-baseline justify-between gap-1.5`,children:[(0,x.jsx)(`span`,{className:`shrink-0 text-[13px] font-semibold leading-none tabular-nums ${i.text}`,children:n}),(0,x.jsxs)(`span`,{className:`min-w-0 truncate text-right text-[10px] leading-none text-stone-400 tabular-nums`,children:[`已执行 `,r,` / `,e.baseline]})]}),(0,x.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-stone-200/70`,children:(0,x.jsx)(`div`,{className:`h-full rounded-full ${i.bar}`,style:{width:`${t}%`},"aria-hidden":`true`})})]})}function M(){let[e,t]=(0,b.useState)(!1),[o,c]=(0,b.useState)(!0),[l,u]=(0,b.useState)(null),[d,p]=(0,b.useState)([]),[pe,h]=(0,b.useState)([]),[g,_]=(0,b.useState)(null),[v,S]=(0,b.useState)(!1),[C,w]=(0,b.useState)(()=>de(xe)),[T,E]=(0,b.useState)({}),[D,O]=(0,b.useState)(1),[k,A]=me(ye,be),[j,M]=(0,b.useState)(null),[N,P]=(0,b.useState)({}),[F,I]=(0,b.useState)(null),[L,R]=(0,b.useState)(null);function z(e){fe(xe,e),w(e),O(1)}let B=(0,b.useRef)(!0),V=(0,b.useRef)(!1),H=ge(we,Ce,Se);(0,b.useEffect)(()=>(B.current=!0,()=>{B.current=!1}),[]);let U=(0,b.useCallback)(async()=>{try{let e=await ae();if(!B.current)return;p(e.items),h(e.projects),E(t=>{let n=new Set(e.items.map(e=>e.id)),r=!1,i={};for(let[e,a]of Object.entries(t))a&&(n.has(e)?i[e]=!0:r=!0);return r?i:t}),_(null)}catch(e){if(!B.current)return;_(e instanceof Error?e.message:String(e))}},[]);(0,b.useEffect)(()=>{let e=i(e=>c(!!e.caseExec));return n().then(()=>{c(r(`caseExec`)),t(!0)}),e},[]),(0,b.useEffect)(()=>{e&&o&&(async()=>{let e=await re();B.current&&(e?(await U(),B.current&&u(!0)):u(!1))})()},[e,o,U]),(0,b.useEffect)(()=>{if(l!==!0)return;let e=window.setInterval(()=>{V.current||U()},ve),t=()=>{V.current||U()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[l,U]);let W=ue(),G=(0,b.useMemo)(()=>ce(d),[d]),K=(0,b.useMemo)(()=>se(d,{keyword:C}),[d,C]),Ee=Math.max(1,Math.ceil(K.length/k)),q=Math.min(D,Ee),J=(0,b.useMemo)(()=>K.slice((q-1)*k,q*k),[K,q,k]),Y=(0,b.useMemo)(()=>J.flatMap(e=>N[e.key]?[]:e.items),[J,N]),X=(0,b.useMemo)(()=>d.filter(e=>T[e.id]),[d,T]),De=Y.length>0&&Y.every(e=>T[e.id]);function Oe(e){P(t=>{let n={...t};return n[e]?delete n[e]:n[e]=!0,n})}function ke(e){P(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})}function Z(e,t){E(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r})}function Q(e){if(!e.project){let t=e.items[0];return t?[t.id]:[]}return d.filter(t=>t.project===e.project).map(e=>e.id)}(0,b.useEffect)(()=>{if(!j)return;let e=K.findIndex(e=>e.items.some(e=>e.id===j));if(e<0)return;O(Math.floor(e/k)+1);let t=window.setTimeout(()=>M(null),2e3);return()=>window.clearTimeout(t)},[j,K,k]);async function Ae(){if(!v){S(!0),_(null),z(``);try{let e=await oe([{date:W,project:``,startDate:W,endDate:W}],{mode:`manual`});if(!B.current)return;let t=e.items[0];if(e.projects.length&&h(e.projects),await U(),!B.current||!t)return;M(t.id)}catch(e){B.current&&_(e instanceof Error?e.message:String(e))}finally{B.current&&S(!1)}}}async function je(e){if(!v&&e.project){S(!0),_(null);try{let t=await oe([{date:W,project:e.project,startDate:e.startDate,endDate:e.endDate}],{mode:`manual`});if(!B.current)return;let n=t.items[0];if(t.projects.length&&h(t.projects),ke(e.key),await U(),!B.current||!n)return;M(n.id)}catch(e){B.current&&_(e instanceof Error?e.message:String(e))}finally{B.current&&S(!1)}}}async function $(e,t){p(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let{item:n,projects:r}=await ee(e,t);if(!B.current)return;p(t=>t.map(t=>t.id===e?n:t)),h(r),_(null)}catch(e){if(!B.current)return;_(e instanceof Error?e.message:String(e)),await U()}}function Me(e,t){let n=t.startDate??e.startDate,r=t.endDate??e.endDate;if(n&&r&&r<n){y(`结束日期不能早于开始日期`,`error`);return}if(!e.project){let n=e.items[0];n&&$(n.id,t);return}let i=e.project;p(e=>e.map(e=>e.project===i?{...e,startDate:n,endDate:r}:e)),(async()=>{try{let e=await le(i,{startDate:n,endDate:r});if(!B.current)return;p(e.items),h(e.projects),_(null)}catch(e){if(!B.current)return;_(e instanceof Error?e.message:String(e)),y(`修改周期失败:${e instanceof Error?e.message:String(e)}`,`error`),await U()}})()}function Ne(e,t){let n=t.trim();if(n&&n!==e.project){if(e.project)Ie(e.project,n);else{let t=e.items[0];t&&$(t.id,{project:n})}}}function Pe(e,t){e.pending>0?$(e.id,{total:t,executed:s(t,e.pending)}):$(e.id,{total:t})}function Fe(e,t){$(e.id,{pending:t,executed:s(e.total,t)})}async function Ie(e,t){let n=t.trim();if(n&&n!==e)try{let t=await ie(e,n);if(!B.current)return;p(t.items),h(t.projects),_(null),y(t.replaced>0?`已重命名,同步了 ${t.replaced} 条记录`:`已重命名项目名称`,`success`)}catch(e){if(!B.current)return;y(`重命名失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function Le(e){let t=te(d,e);if(t>0)y(`还有 ${t} 条记录在用「${e}」,先改掉再删除`,`error`);else try{let t=await ne(e);if(!B.current)return;p(t.items),h(t.projects),_(null),y(`已删除项目名称「${e}」`,`success`)}catch(e){if(!B.current)return;y(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function Re(){let e=F;if(e&&e.length!==0){I(null),S(!0);try{if(await f(e.map(e=>e.id)),!B.current)return;E({}),_(null),await U(),y(e.length>1?`已删除 ${e.length} 条执行记录`:`已删除执行记录`,`success`)}catch(e){if(!B.current)return;let t=e instanceof Error?e.message:String(e);_(t),y(`删除失败:${t}`,`error`)}finally{B.current&&S(!1)}}}async function ze(){let e=L;if(!e)return;R(null);let t=Q(e);if(t.length){S(!0);try{if(await f(t),!B.current)return;Z(t,!1),_(null),await U(),y(e.project?`已删除「${e.project}」的 ${t.length} 条统计`:`已删除 ${t.length} 条执行记录`,`success`)}catch(e){if(!B.current)return;let t=e instanceof Error?e.message:String(e);_(t),y(`删除失败:${t}`,`error`)}finally{B.current&&S(!1)}}}return e?o?l===null?(0,x.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接用例执行统计服务`,children:(0,x.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,x.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):l?(0,x.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,x.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,x.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,x.jsx)(`span`,{className:`font-medium text-stone-800`,children:G.records}),` 条统计`,(0,x.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· `,G.projects,` 个项目 · 已执行 `,G.executed,` / `,G.baseline,` 个用例 · 整体执行率 `,G.percent.toFixed(2),`%`,X.length?` · 已选 ${X.length} 条`:``]})]}),(0,x.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,x.jsxs)(`label`,{className:`flex h-9 shrink-0 cursor-pointer items-center gap-1.5 whitespace-nowrap text-sm text-stone-600`,children:[(0,x.jsx)(`input`,{type:`checkbox`,"aria-label":`全选本页记录`,checked:De,disabled:Y.length===0,onChange:e=>Z(Y.map(e=>e.id),e.target.checked)}),`全选本页`]}),(0,x.jsx)(`input`,{value:C,onChange:e=>z(e.target.value),placeholder:`搜索项目 / 统计日期…`,className:`h-9 w-44 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,x.jsx)(`button`,{type:`button`,disabled:v||X.length===0,onClick:()=>I(X),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,x.jsx)(_e,{fields:H.fields,isVisible:H.isVisible,onToggle:H.toggle}),(0,x.jsx)(`button`,{type:`button`,disabled:v,onClick:()=>void Ae(),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 添加项目`})]})]}),g?(0,x.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,x.jsx)(`span`,{className:`min-w-0 flex-1`,children:g}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>_(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,x.jsxs)(`div`,{"data-case-exec":!0,className:`min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-4`,onFocusCapture:()=>{V.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{V.current=!!document.activeElement?.closest(`[data-case-exec]`)},0)},children:[K.length===0?(0,x.jsx)(`div`,{className:`rounded-lg border border-dashed border-stone-200 px-4 py-14 text-center text-sm text-stone-400`,children:`还没有用例执行统计记录,点右上角「+ 添加项目」开始。`}):null,J.map(e=>{let t=Q(e);return(0,x.jsx)(Te,{group:e,collapsed:!!N[e.key],groupSelected:t.length>0&&t.every(e=>!!T[e]),recordCount:t.length,projects:pe,addedId:j,selected:T,busy:v,isVisible:H.isVisible,onToggle:()=>Oe(e.key),onToggleGroupSelect:e=>Z(t,e),onToggleRow:(e,t)=>Z([e],t),onCommitProject:t=>Ne(e,t),onRenameProject:(e,t)=>void Ie(e,t),onRemoveProject:e=>void Le(e),onCommitCycle:t=>Me(e,t),onAddStatDate:()=>void je(e),onDeleteGroup:()=>R(e),onPatch:$,onCommitTotal:Pe,onCommitPending:Fe,onDeleteRow:e=>I([e])},e.key)})]}),K.length>0?(0,x.jsx)(he,{page:q,totalPages:Ee,pageSize:k,busy:v,unit:`个项目`,onPage:O,onPageSize:e=>{A(e),O(1)}}):(0,x.jsx)(`div`,{className:`pb-1`}),(0,x.jsx)(m,{open:F!==null,title:`删除用例执行统计`,message:F&&F.length>1?`确定删除选中的 ${F.length} 条记录吗?删除后不可恢复。`:`确定删除「${F?.[0]?.project??``} ${F?.[0]?.date??``}」这条记录吗?删除后不可恢复。`,confirmLabel:`删除`,danger:!0,onClose:()=>I(null),onConfirm:()=>void Re()}),(0,x.jsx)(m,{open:L!==null,title:`删除整个项目的统计`,message:L?.project?`确定删除「${L.project}」的全部 ${Q(L).length} 条统计吗?删除后不可恢复(项目名称仍保留在下拉里)。`:`确定删除这条占位记录吗?删除后不可恢复。`,confirmLabel:`删除整组`,danger:!0,onClose:()=>R(null),onConfirm:()=>void ze()})]}):(0,x.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`用例执行统计需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,x.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(`caseExec`)}):(0,x.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,x.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,x.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}function Te(e){let{group:t,isVisible:n}=e,r=A(t.percent),i=(0,b.useMemo)(()=>_(C,n),[n]);return(0,x.jsxs)(`article`,{className:`overflow-hidden rounded-lg border border-stone-200 bg-white`,children:[(0,x.jsxs)(`div`,{onClick:t=>{t.target.closest(`button, input, a, select, textarea, label, [role="button"], [role="combobox"]`)||window.getSelection()?.toString()||e.onToggle()},className:`cursor-pointer border-b border-stone-100 bg-[#fbfbfc] px-3 py-2`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1.5`,children:[(0,x.jsx)(`input`,{type:`checkbox`,"aria-label":`选择项目 ${t.project||`未命名`}`,checked:e.groupSelected,disabled:e.recordCount===0,onChange:t=>e.onToggleGroupSelect(t.target.checked)}),(0,x.jsx)(`button`,{type:`button`,"aria-expanded":!e.collapsed,"aria-label":`${e.collapsed?`展开`:`收起`} ${t.project||`未命名项目`}`,onClick:e.onToggle,className:`flex h-6 w-6 shrink-0 items-center justify-center rounded text-stone-400 transition-colors hover:bg-stone-200/70 hover:text-stone-700`,children:(0,x.jsx)(`span`,{className:`transition-transform ${e.collapsed?`-rotate-90`:``}`,"aria-hidden":`true`,children:O})}),(0,x.jsx)(`div`,{className:`w-52 shrink-0`,children:(0,x.jsx)(v,{compact:!0,ariaLabel:`项目名称`,options:e.projects,value:t.project,onChange:e.onCommitProject,onRenameOption:e.onRenameProject,onDeleteOption:e.onRemoveProject,placeholder:`选择或创建项目`})}),t.draft?(0,x.jsx)(`span`,{className:`text-xs text-stone-400`,children:`选好项目名称后就能在这条项目下按统计日期记录`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{className:`w-28 shrink-0`,children:(0,x.jsx)(h,{value:t.startDate,onChange:t=>e.onCommitCycle({startDate:t}),placeholder:`开始日期`,className:T})}),(0,x.jsx)(`span`,{className:`text-xs text-stone-400`,"aria-hidden":`true`,children:`~`}),(0,x.jsx)(`div`,{className:`w-28 shrink-0`,children:(0,x.jsx)(h,{value:t.endDate,onChange:t=>e.onCommitCycle({endDate:t}),placeholder:`结束日期`,className:T})})]}),(0,x.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,x.jsxs)(`span`,{className:`mr-1 whitespace-nowrap text-xs text-stone-400 tabular-nums`,children:[e.recordCount,` 条统计`]}),t.draft?null:(0,x.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:e.onAddStatDate,className:`${E} border-stone-200 text-stone-700 hover:border-[#3370ff] hover:text-[#3370ff]`,children:`添加统计`}),(0,x.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:e.onDeleteGroup,className:`${E} border-red-200 text-red-600 hover:bg-red-50`,children:`删除整组`})]})]}),t.draft?null:(0,x.jsxs)(`div`,{className:`mt-2`,children:[(0,x.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs text-stone-500 tabular-nums`,children:[(0,x.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`基线 `,(0,x.jsx)(`span`,{className:`font-medium text-stone-700`,children:t.baseline}),(0,x.jsx)(`span`,{className:`mx-1.5 text-stone-300`,children:`·`}),`已执行`,` `,(0,x.jsxs)(`span`,{className:`font-medium text-stone-700`,children:[t.executed,` / `,t.baseline]})]}),(0,x.jsxs)(`span`,{className:`shrink-0 text-[13px] font-semibold ${r.text}`,children:[t.percent.toFixed(2),`%`]})]}),(0,x.jsx)(`div`,{className:`mt-1.5 h-1.5 w-full overflow-hidden rounded-full bg-stone-200/70`,children:(0,x.jsx)(`div`,{className:`h-full rounded-full ${r.bar}`,style:{width:`${t.percent}%`},"aria-hidden":`true`})})]})]}),(0,x.jsx)(`div`,{className:`grid transition-[grid-template-rows,opacity] duration-200 ease-out ${e.collapsed?`grid-rows-[0fr] opacity-0`:`grid-rows-[1fr] opacity-100`}`,"aria-hidden":e.collapsed,children:(0,x.jsx)(`div`,{className:`min-h-0 overflow-hidden`,inert:e.collapsed,children:(0,x.jsx)(`div`,{className:`overflow-x-auto`,children:(0,x.jsxs)(`table`,{className:`w-full min-w-[980px] table-fixed text-sm`,children:[(0,x.jsx)(`colgroup`,{children:i.map(e=>(0,x.jsx)(`col`,{style:{width:e.width}},e.key))}),(0,x.jsx)(`thead`,{className:`bg-stone-50 text-xs text-stone-500`,children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,"aria-label":`选择`}),(0,x.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`统计日期`}),n(`total`)?(0,x.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`用例总数`}):null,n(`pending`)?(0,x.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`待执行用例`}):null,n(`executed`)?(0,x.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`已执行用例`}):null,n(`remaining`)?(0,x.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`当前剩余用例`}):null,n(`ratio`)?(0,x.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`执行比例`}):null,n(`createdAt`)?(0,x.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`创建日期`}):null,n(`updatedAt`)?(0,x.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`修改日期`}):null,(0,x.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,x.jsx)(`tbody`,{children:t.items.map(r=>(0,x.jsxs)(`tr`,{className:`border-t border-stone-100 first:border-t-0 ${r.id===e.addedId?`bg-[#f2f6ff]`:`hover:bg-[#f7f8fa]`}`,children:[(0,x.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,x.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${t.project} ${r.date}`,checked:!!e.selected[r.id],onChange:t=>e.onToggleRow(r.id,t.target.checked)})}),(0,x.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,x.jsx)(h,{value:r.date,onChange:t=>e.onPatch(r.id,{date:t}),placeholder:`选择日期`,className:T})}),n(`total`)?(0,x.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,x.jsx)(k,{value:r.total,ariaLabel:`用例总数`,onCommit:t=>e.onCommitTotal(r,t)})}):null,n(`pending`)?(0,x.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,x.jsx)(k,{value:r.pending,ariaLabel:`待执行用例`,onCommit:t=>e.onCommitPending(r,t)})}):null,n(`executed`)?(0,x.jsx)(`td`,{className:`px-2 py-1 text-center align-middle text-sm text-stone-800 tabular-nums`,children:d(r)}):null,n(`remaining`)?(0,x.jsx)(`td`,{className:`px-2 py-1 text-center align-middle text-xs text-stone-500 tabular-nums`,children:c(r)}):null,n(`ratio`)?(0,x.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,x.jsx)(j,{item:r,baseline:t.baseline||r.total})}):null,n(`createdAt`)?(0,x.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:g(r.createdAt)}):null,n(`updatedAt`)?(0,x.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:g(r.updatedAt)}):null,(0,x.jsx)(`td`,{className:`px-2 py-1 text-center align-middle`,children:(0,x.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:()=>e.onDeleteRow(r),"aria-label":`删除 ${t.project} ${r.date} 的记录`,className:`tw-icon-danger rounded p-1`,children:D})})]},r.id))})]})})})})]})}export{M as default};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.DwpFFa5D.js";import{i as r,o as i,s as a}from"./plugins.BmKRnp4a.js";import{a as o,b as ee,c as te,d as ne,f as re,g as ie,h as ae,i as s,l as oe,m as se,n as ce,o as c,p as l,r as u,s as d,u as f,v as p,x as le,y as ue}from"./case-exec.BMNk9OyF.js";import{r as de,s as fe}from"./view-prefs.GnvelRDj.js";import{t as pe}from"./jsx-runtime.DUg_B_vD.js";import{t as m}from"./ConfirmDialog.D5qXeML0.js";import{t as h}from"./DatePicker.Bkl71M49.js";import{n as me,t as he}from"./DocsPager.ceBEecmd.js";import{E as g}from"./PmShared.86HEsdd_.js";import{n as _,r as ge,t as _e}from"./TableFieldConfig.D0v9S2g3.js";import{t as v}from"./TagSelect.UUXgkMqJ.js";import{showToast as y}from"./Toast.BO2NFckG.js";var b=e(t(),1),x=pe(),ve=8e3,S=600,ye=20,be=`tw.case-exec.page-size.v1`,xe=`case-exec.search`,C=[{key:`select`,width:`6%`},{key:`date`,width:`16%`},{key:`total`,width:`10%`},{key:`pending`,width:`10%`},{key:`executed`,width:`10%`},{key:`remaining`,width:`10%`},{key:`ratio`,width:`14%`},{key:`createdAt`,width:`12%`},{key:`updatedAt`,width:`12%`},{key:`action`,width:`6%`}],Se=new Set([`select`,`date`,`action`]),Ce=[{key:`total`,label:`用例总数`},{key:`pending`,label:`待执行用例`},{key:`executed`,label:`已执行用例`},{key:`remaining`,label:`当前剩余用例`},{key:`ratio`,label:`执行比例`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],we=`case-exec.fields`,w=`h-8 w-full min-w-0 rounded-md border border-transparent bg-transparent px-1.5 text-center text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300 tabular-nums`,T=`h-8 w-full rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`,E=`h-7 shrink-0 rounded-md border bg-white px-2 text-xs font-medium whitespace-nowrap disabled:opacity-40`,D=(0,x.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,x.jsx)(`path`,{d:`M3 6h18`}),(0,x.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,x.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,x.jsx)(`path`,{d:`M10 11v6M14 11v6`})]}),O=(0,x.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,x.jsx)(`path`,{d:`M6 9l6 6 6-6`})});function k(e){let[t,n]=(0,b.useState)(e.value?String(e.value):``),r=(0,b.useRef)(e.value),i=(0,b.useRef)(e.onCommit);i.current=e.onCommit,(0,b.useEffect)(()=>{e.value!==r.current&&(r.current=e.value,n(e.value?String(e.value):``))},[e.value]),(0,b.useEffect)(()=>{let e=t?p(t):0;if(e===r.current)return;let n=window.setTimeout(()=>{r.current=e,i.current(e)},S);return()=>window.clearTimeout(n)},[t]);function a(){let e=t?p(t):0;e!==r.current&&(r.current=e,i.current(e))}return(0,x.jsx)(`input`,{type:`text`,inputMode:`numeric`,"aria-label":e.ariaLabel,value:t,placeholder:e.placeholder??`0`,onChange:e=>n(e.target.value.replace(/[^\d]/g,``)),onBlur:a,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),t.currentTarget.blur()):t.key===`Escape`&&(t.preventDefault(),r.current=e.value,n(e.value?String(e.value):``),t.currentTarget.blur())},className:w})}function A(e){return e>=80?{text:`text-[#4176e6]`,bar:`bg-[#3370ff]`}:e>=40?{text:`text-[#a85b00]`,bar:`bg-[#f5a524]`}:{text:`text-stone-500`,bar:`bg-stone-400`}}function j(e){let t=o(e.item,e.baseline),n=l(e.item,e.baseline),r=u(e.item,e.baseline),i=A(t);return(0,x.jsxs)(`div`,{className:`flex flex-col justify-center gap-1.5 px-1.5`,children:[(0,x.jsxs)(`div`,{className:`flex items-baseline justify-between gap-1.5`,children:[(0,x.jsx)(`span`,{className:`shrink-0 text-[13px] font-semibold leading-none tabular-nums ${i.text}`,children:n}),(0,x.jsxs)(`span`,{className:`min-w-0 truncate text-right text-[10px] leading-none text-stone-400 tabular-nums`,children:[`已执行 `,r,` / `,e.baseline]})]}),(0,x.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-stone-200/70`,children:(0,x.jsx)(`div`,{className:`h-full rounded-full ${i.bar}`,style:{width:`${t}%`},"aria-hidden":`true`})})]})}function M(){let[e,t]=(0,b.useState)(!1),[o,c]=(0,b.useState)(!0),[l,u]=(0,b.useState)(null),[d,p]=(0,b.useState)([]),[pe,h]=(0,b.useState)([]),[g,_]=(0,b.useState)(null),[v,S]=(0,b.useState)(!1),[C,w]=(0,b.useState)(()=>de(xe)),[T,E]=(0,b.useState)({}),[D,O]=(0,b.useState)(1),[k,A]=me(ye,be),[j,M]=(0,b.useState)(null),[N,P]=(0,b.useState)({}),[F,I]=(0,b.useState)(null),[L,R]=(0,b.useState)(null);function z(e){fe(xe,e),w(e),O(1)}let B=(0,b.useRef)(!0),V=(0,b.useRef)(!1),H=ge(we,Ce,Se);(0,b.useEffect)(()=>(B.current=!0,()=>{B.current=!1}),[]);let U=(0,b.useCallback)(async()=>{try{let e=await ae();if(!B.current)return;p(e.items),h(e.projects),E(t=>{let n=new Set(e.items.map(e=>e.id)),r=!1,i={};for(let[e,a]of Object.entries(t))a&&(n.has(e)?i[e]=!0:r=!0);return r?i:t}),_(null)}catch(e){if(!B.current)return;_(e instanceof Error?e.message:String(e))}},[]);(0,b.useEffect)(()=>{let e=i(e=>c(!!e.caseExec));return n().then(()=>{c(r(`caseExec`)),t(!0)}),e},[]),(0,b.useEffect)(()=>{e&&o&&(async()=>{let e=await re();B.current&&(e?(await U(),B.current&&u(!0)):u(!1))})()},[e,o,U]),(0,b.useEffect)(()=>{if(l!==!0)return;let e=window.setInterval(()=>{V.current||U()},ve),t=()=>{V.current||U()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[l,U]);let W=ue(),G=(0,b.useMemo)(()=>ce(d),[d]),K=(0,b.useMemo)(()=>se(d,{keyword:C}),[d,C]),Ee=Math.max(1,Math.ceil(K.length/k)),q=Math.min(D,Ee),J=(0,b.useMemo)(()=>K.slice((q-1)*k,q*k),[K,q,k]),Y=(0,b.useMemo)(()=>J.flatMap(e=>N[e.key]?[]:e.items),[J,N]),X=(0,b.useMemo)(()=>d.filter(e=>T[e.id]),[d,T]),De=Y.length>0&&Y.every(e=>T[e.id]);function Oe(e){P(t=>{let n={...t};return n[e]?delete n[e]:n[e]=!0,n})}function ke(e){P(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})}function Z(e,t){E(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r})}function Q(e){if(!e.project){let t=e.items[0];return t?[t.id]:[]}return d.filter(t=>t.project===e.project).map(e=>e.id)}(0,b.useEffect)(()=>{if(!j)return;let e=K.findIndex(e=>e.items.some(e=>e.id===j));if(e<0)return;O(Math.floor(e/k)+1);let t=window.setTimeout(()=>M(null),2e3);return()=>window.clearTimeout(t)},[j,K,k]);async function Ae(){if(!v){S(!0),_(null),z(``);try{let e=await oe([{date:W,project:``,startDate:W,endDate:W}],{mode:`manual`});if(!B.current)return;let t=e.items[0];if(e.projects.length&&h(e.projects),await U(),!B.current||!t)return;M(t.id)}catch(e){B.current&&_(e instanceof Error?e.message:String(e))}finally{B.current&&S(!1)}}}async function je(e){if(!v&&e.project){S(!0),_(null);try{let t=await oe([{date:W,project:e.project,startDate:e.startDate,endDate:e.endDate}],{mode:`manual`});if(!B.current)return;let n=t.items[0];if(t.projects.length&&h(t.projects),ke(e.key),await U(),!B.current||!n)return;M(n.id)}catch(e){B.current&&_(e instanceof Error?e.message:String(e))}finally{B.current&&S(!1)}}}async function $(e,t){p(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let{item:n,projects:r}=await ee(e,t);if(!B.current)return;p(t=>t.map(t=>t.id===e?n:t)),h(r),_(null)}catch(e){if(!B.current)return;_(e instanceof Error?e.message:String(e)),await U()}}function Me(e,t){let n=t.startDate??e.startDate,r=t.endDate??e.endDate;if(n&&r&&r<n){y(`结束日期不能早于开始日期`,`error`);return}if(!e.project){let n=e.items[0];n&&$(n.id,t);return}let i=e.project;p(e=>e.map(e=>e.project===i?{...e,startDate:n,endDate:r}:e)),(async()=>{try{let e=await le(i,{startDate:n,endDate:r});if(!B.current)return;p(e.items),h(e.projects),_(null)}catch(e){if(!B.current)return;_(e instanceof Error?e.message:String(e)),y(`修改周期失败:${e instanceof Error?e.message:String(e)}`,`error`),await U()}})()}function Ne(e,t){let n=t.trim();if(n&&n!==e.project){if(e.project)Ie(e.project,n);else{let t=e.items[0];t&&$(t.id,{project:n})}}}function Pe(e,t){e.pending>0?$(e.id,{total:t,executed:s(t,e.pending)}):$(e.id,{total:t})}function Fe(e,t){$(e.id,{pending:t,executed:s(e.total,t)})}async function Ie(e,t){let n=t.trim();if(n&&n!==e)try{let t=await ie(e,n);if(!B.current)return;p(t.items),h(t.projects),_(null),y(t.replaced>0?`已重命名,同步了 ${t.replaced} 条记录`:`已重命名项目名称`,`success`)}catch(e){if(!B.current)return;y(`重命名失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function Le(e){let t=te(d,e);if(t>0)y(`还有 ${t} 条记录在用「${e}」,先改掉再删除`,`error`);else try{let t=await ne(e);if(!B.current)return;p(t.items),h(t.projects),_(null),y(`已删除项目名称「${e}」`,`success`)}catch(e){if(!B.current)return;y(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function Re(){let e=F;if(e&&e.length!==0){I(null),S(!0);try{if(await f(e.map(e=>e.id)),!B.current)return;E({}),_(null),await U(),y(e.length>1?`已删除 ${e.length} 条执行记录`:`已删除执行记录`,`success`)}catch(e){if(!B.current)return;let t=e instanceof Error?e.message:String(e);_(t),y(`删除失败:${t}`,`error`)}finally{B.current&&S(!1)}}}async function ze(){let e=L;if(!e)return;R(null);let t=Q(e);if(t.length){S(!0);try{if(await f(t),!B.current)return;Z(t,!1),_(null),await U(),y(e.project?`已删除「${e.project}」的 ${t.length} 条统计`:`已删除 ${t.length} 条执行记录`,`success`)}catch(e){if(!B.current)return;let t=e instanceof Error?e.message:String(e);_(t),y(`删除失败:${t}`,`error`)}finally{B.current&&S(!1)}}}return e?o?l===null?(0,x.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接用例执行统计服务`,children:(0,x.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,x.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):l?(0,x.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,x.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,x.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,x.jsx)(`span`,{className:`font-medium text-stone-800`,children:G.records}),` 条统计`,(0,x.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· `,G.projects,` 个项目 · 已执行 `,G.executed,` / `,G.baseline,` 个用例 · 整体执行率 `,G.percent.toFixed(2),`%`,X.length?` · 已选 ${X.length} 条`:``]})]}),(0,x.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,x.jsxs)(`label`,{className:`flex h-9 shrink-0 cursor-pointer items-center gap-1.5 whitespace-nowrap text-sm text-stone-600`,children:[(0,x.jsx)(`input`,{type:`checkbox`,"aria-label":`全选本页记录`,checked:De,disabled:Y.length===0,onChange:e=>Z(Y.map(e=>e.id),e.target.checked)}),`全选本页`]}),(0,x.jsx)(`input`,{value:C,onChange:e=>z(e.target.value),placeholder:`搜索项目 / 统计日期…`,className:`h-9 w-44 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,x.jsx)(`button`,{type:`button`,disabled:v||X.length===0,onClick:()=>I(X),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,x.jsx)(_e,{fields:H.fields,isVisible:H.isVisible,onToggle:H.toggle}),(0,x.jsx)(`button`,{type:`button`,disabled:v,onClick:()=>void Ae(),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 添加项目`})]})]}),g?(0,x.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,x.jsx)(`span`,{className:`min-w-0 flex-1`,children:g}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>_(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,x.jsxs)(`div`,{"data-case-exec":!0,className:`min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-4`,onFocusCapture:()=>{V.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{V.current=!!document.activeElement?.closest(`[data-case-exec]`)},0)},children:[K.length===0?(0,x.jsx)(`div`,{className:`rounded-lg border border-dashed border-stone-200 px-4 py-14 text-center text-sm text-stone-400`,children:`还没有用例执行统计记录,点右上角「+ 添加项目」开始。`}):null,J.map(e=>{let t=Q(e);return(0,x.jsx)(Te,{group:e,collapsed:!!N[e.key],groupSelected:t.length>0&&t.every(e=>!!T[e]),recordCount:t.length,projects:pe,addedId:j,selected:T,busy:v,isVisible:H.isVisible,onToggle:()=>Oe(e.key),onToggleGroupSelect:e=>Z(t,e),onToggleRow:(e,t)=>Z([e],t),onCommitProject:t=>Ne(e,t),onRenameProject:(e,t)=>void Ie(e,t),onRemoveProject:e=>void Le(e),onCommitCycle:t=>Me(e,t),onAddStatDate:()=>void je(e),onDeleteGroup:()=>R(e),onPatch:$,onCommitTotal:Pe,onCommitPending:Fe,onDeleteRow:e=>I([e])},e.key)})]}),K.length>0?(0,x.jsx)(he,{page:q,totalPages:Ee,pageSize:k,busy:v,unit:`个项目`,onPage:O,onPageSize:e=>{A(e),O(1)}}):(0,x.jsx)(`div`,{className:`pb-1`}),(0,x.jsx)(m,{open:F!==null,title:`删除用例执行统计`,message:F&&F.length>1?`确定删除选中的 ${F.length} 条记录吗?删除后不可恢复。`:`确定删除「${F?.[0]?.project??``} ${F?.[0]?.date??``}」这条记录吗?删除后不可恢复。`,confirmLabel:`删除`,danger:!0,onClose:()=>I(null),onConfirm:()=>void Re()}),(0,x.jsx)(m,{open:L!==null,title:`删除整个项目的统计`,message:L?.project?`确定删除「${L.project}」的全部 ${Q(L).length} 条统计吗?删除后不可恢复(项目名称仍保留在下拉里)。`:`确定删除这条占位记录吗?删除后不可恢复。`,confirmLabel:`删除整组`,danger:!0,onClose:()=>R(null),onConfirm:()=>void ze()})]}):(0,x.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`用例执行统计需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,x.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(`caseExec`)}):(0,x.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,x.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,x.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}function Te(e){let{group:t,isVisible:n}=e,r=A(t.percent),i=(0,b.useMemo)(()=>_(C,n),[n]);return(0,x.jsxs)(`article`,{className:`overflow-hidden rounded-lg border border-stone-200 bg-white`,children:[(0,x.jsxs)(`div`,{onClick:t=>{t.target.closest(`button, input, a, select, textarea, label, [role="button"], [role="combobox"]`)||window.getSelection()?.toString()||e.onToggle()},className:`cursor-pointer border-b border-stone-100 bg-[#fbfbfc] px-3 py-2`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1.5`,children:[(0,x.jsx)(`input`,{type:`checkbox`,"aria-label":`选择项目 ${t.project||`未命名`}`,checked:e.groupSelected,disabled:e.recordCount===0,onChange:t=>e.onToggleGroupSelect(t.target.checked)}),(0,x.jsx)(`button`,{type:`button`,"aria-expanded":!e.collapsed,"aria-label":`${e.collapsed?`展开`:`收起`} ${t.project||`未命名项目`}`,onClick:e.onToggle,className:`flex h-6 w-6 shrink-0 items-center justify-center rounded text-stone-400 transition-colors hover:bg-stone-200/70 hover:text-stone-700`,children:(0,x.jsx)(`span`,{className:`transition-transform ${e.collapsed?`-rotate-90`:``}`,"aria-hidden":`true`,children:O})}),(0,x.jsx)(`div`,{className:`w-52 shrink-0`,children:(0,x.jsx)(v,{compact:!0,ariaLabel:`项目名称`,options:e.projects,value:t.project,onChange:e.onCommitProject,onRenameOption:e.onRenameProject,onDeleteOption:e.onRemoveProject,placeholder:`选择或创建项目`})}),t.draft?(0,x.jsx)(`span`,{className:`text-xs text-stone-400`,children:`选好项目名称后就能在这条项目下按统计日期记录`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{className:`w-28 shrink-0`,children:(0,x.jsx)(h,{value:t.startDate,onChange:t=>e.onCommitCycle({startDate:t}),placeholder:`开始日期`,className:T})}),(0,x.jsx)(`span`,{className:`text-xs text-stone-400`,"aria-hidden":`true`,children:`~`}),(0,x.jsx)(`div`,{className:`w-28 shrink-0`,children:(0,x.jsx)(h,{value:t.endDate,onChange:t=>e.onCommitCycle({endDate:t}),placeholder:`结束日期`,className:T})})]}),(0,x.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,x.jsxs)(`span`,{className:`mr-1 whitespace-nowrap text-xs text-stone-400 tabular-nums`,children:[e.recordCount,` 条统计`]}),t.draft?null:(0,x.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:e.onAddStatDate,className:`${E} border-stone-200 text-stone-700 hover:border-[#3370ff] hover:text-[#3370ff]`,children:`添加统计`}),(0,x.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:e.onDeleteGroup,className:`${E} border-red-200 text-red-600 hover:bg-red-50`,children:`删除整组`})]})]}),t.draft?null:(0,x.jsxs)(`div`,{className:`mt-2`,children:[(0,x.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs text-stone-500 tabular-nums`,children:[(0,x.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`基线 `,(0,x.jsx)(`span`,{className:`font-medium text-stone-700`,children:t.baseline}),(0,x.jsx)(`span`,{className:`mx-1.5 text-stone-300`,children:`·`}),`已执行`,` `,(0,x.jsxs)(`span`,{className:`font-medium text-stone-700`,children:[t.executed,` / `,t.baseline]})]}),(0,x.jsxs)(`span`,{className:`shrink-0 text-[13px] font-semibold ${r.text}`,children:[t.percent.toFixed(2),`%`]})]}),(0,x.jsx)(`div`,{className:`mt-1.5 h-1.5 w-full overflow-hidden rounded-full bg-stone-200/70`,children:(0,x.jsx)(`div`,{className:`h-full rounded-full ${r.bar}`,style:{width:`${t.percent}%`},"aria-hidden":`true`})})]})]}),(0,x.jsx)(`div`,{className:`grid transition-[grid-template-rows,opacity] duration-200 ease-out ${e.collapsed?`grid-rows-[0fr] opacity-0`:`grid-rows-[1fr] opacity-100`}`,"aria-hidden":e.collapsed,children:(0,x.jsx)(`div`,{className:`min-h-0 overflow-hidden`,inert:e.collapsed,children:(0,x.jsx)(`div`,{className:`overflow-x-auto`,children:(0,x.jsxs)(`table`,{className:`w-full min-w-[980px] table-fixed text-sm`,children:[(0,x.jsx)(`colgroup`,{children:i.map(e=>(0,x.jsx)(`col`,{style:{width:e.width}},e.key))}),(0,x.jsx)(`thead`,{className:`bg-stone-50 text-xs text-stone-500`,children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,"aria-label":`选择`}),(0,x.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`统计日期`}),n(`total`)?(0,x.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`用例总数`}):null,n(`pending`)?(0,x.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`待执行用例`}):null,n(`executed`)?(0,x.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`已执行用例`}):null,n(`remaining`)?(0,x.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`当前剩余用例`}):null,n(`ratio`)?(0,x.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`执行比例`}):null,n(`createdAt`)?(0,x.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`创建日期`}):null,n(`updatedAt`)?(0,x.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`修改日期`}):null,(0,x.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,x.jsx)(`tbody`,{children:t.items.map(r=>(0,x.jsxs)(`tr`,{className:`border-t border-stone-100 first:border-t-0 ${r.id===e.addedId?`bg-[#f2f6ff]`:`hover:bg-[#f7f8fa]`}`,children:[(0,x.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,x.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${t.project} ${r.date}`,checked:!!e.selected[r.id],onChange:t=>e.onToggleRow(r.id,t.target.checked)})}),(0,x.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,x.jsx)(h,{value:r.date,onChange:t=>e.onPatch(r.id,{date:t}),placeholder:`选择日期`,className:T})}),n(`total`)?(0,x.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,x.jsx)(k,{value:r.total,ariaLabel:`用例总数`,onCommit:t=>e.onCommitTotal(r,t)})}):null,n(`pending`)?(0,x.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,x.jsx)(k,{value:r.pending,ariaLabel:`待执行用例`,onCommit:t=>e.onCommitPending(r,t)})}):null,n(`executed`)?(0,x.jsx)(`td`,{className:`px-2 py-1 text-center align-middle text-sm text-stone-800 tabular-nums`,children:d(r)}):null,n(`remaining`)?(0,x.jsx)(`td`,{className:`px-2 py-1 text-center align-middle text-xs text-stone-500 tabular-nums`,children:c(r)}):null,n(`ratio`)?(0,x.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,x.jsx)(j,{item:r,baseline:t.baseline||r.total})}):null,n(`createdAt`)?(0,x.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:g(r.createdAt)}):null,n(`updatedAt`)?(0,x.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:g(r.updatedAt)}):null,(0,x.jsx)(`td`,{className:`px-2 py-1 text-center align-middle`,children:(0,x.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:()=>e.onDeleteRow(r),"aria-label":`删除 ${t.project} ${r.date} 的记录`,className:`tw-icon-danger rounded p-1`,children:D})})]},r.id))})]})})})})]})}export{M as default};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/lib.S37S0T6S.js","_astro/react.Blvh0GOs.js","_astro/jszip.min.Bh2Mgo40.js"])))=>i.map(i=>d[i]);
2
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.C4rpn1Ix.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./SelectDropdown.Dmk5n225.js";import{showToast as a}from"./Toast.BO2NFckG.js";import{i as o,r as s}from"./case-types.CprZTsyX.js";import{d as c,f as l,m as u,p as d,r as f,u as ee}from"./case-gen-run.FzgC_1Ki.js";import{a as p}from"./case-fields.CmePqYfh.js";import{_ as m,c as h,f as g,l as _,p as v,r as y,u as b,v as x}from"./project-docs.DAw9bzgk.js";import{a as S,i as C,n as w,o as te,r as T,s as ne,t as re}from"./case-template.C-GBxgBC.js";import{b as E,m as ie,p as ae,u as oe}from"./settings.NTeTjmxg.js";import{o as se}from"./llm.DyweO-KK.js";import{n as D}from"./doc-roots.DAJP9Svr.js";import{r as ce}from"./prompts-meta.Dnmq-SnF.js";import{t as le}from"./ExcelFieldTags.CXif3Ilh.js";import{t as ue}from"./MultiSelectDropdown.y8JMbCxO.js";import{t as O}from"./SearchableSelect.DFZBUFIs.js";var k=e(t(),1),A=r(),de=[{value:`md`,label:`Markdown 表格`},{value:`xlsx`,label:`Excel`},{value:`csv`,label:`CSV`}];function fe(e){let t=e.match(/```(?:json)?\s*([\s\S]*?)```/)?.[1]??e.match(/\{[\s\S]*\}/)?.[0]??e.match(/\[[\s\S]*\]/)?.[0];if(!t)return null;try{let e=JSON.parse(t);if(Array.isArray(e)&&e.length>0)return{docTitle:``,cases:e};if(e&&typeof e==`object`){let t=e,n=t.用例??t.cases??t.items;if(!Array.isArray(n)||n.length===0)return null;let r=t.需求名称??t.文档名称??t.docTitle??t.title;return{docTitle:typeof r==`string`?r.trim():``,cases:n}}}catch{return null}return null}function pe(e){return(e.split(`/`).pop()||e).replace(/\.[^.]+$/,``).trim()}function me(e){let t=e.match(/^#\s+(.+)$/m);if(t?.[1])return t[1].trim().slice(0,48);let n=e.match(/^标题[::]\s*(.+)$/m);return n?.[1]?n[1].trim().slice(0,48):``}function he(e,t){let n=[];if(!e.length)return n.push(`未生成任何用例`),n;for(let r of t){let t=e.filter(e=>!String(e[r]??``).trim()).length;t===e.length?n.push(`字段「${r}」全部为空`):t>Math.max(2,Math.floor(e.length*.3))&&n.push(`字段「${r}」有 ${t}/${e.length} 条为空`)}e.length<15&&n.push(`用例数量偏少(${e.length} 条),建议核对需求覆盖`);let r=e.map(e=>{for(let t of[`用例标题`,`标题`,`测试分项目`,`测试项目`])if(e[t]?.trim())return e[t].trim();return``}).filter(Boolean),i=new Set(r);return r.length>=4&&i.size<r.length*.6&&n.push(`用例标题/分项重复偏多,可能覆盖不足`),n}function ge(e){if(e==null||e<0)return`—`;if(e<1e3)return`${e} ms`;let t=e/1e3;if(t<60)return`${t.toFixed(1)} s`;let n=Math.floor(t/60);return`${n} 分 ${Math.round(t-n*60)} 秒`}function _e(e){if(!e)return`—`;try{return new Date(e).toLocaleString(`zh-CN`,{hour12:!1})}catch{return`—`}}async function ve(e){let t=s(e).templateFolder;try{let{entries:e}=await h(`templates`,t),n=e.filter(e=>e.type===`file`).sort((e,t)=>(t.mtime??0)-(e.mtime??0)),r=[];for(let e of n){let t=e.name.toLowerCase(),n=[...p],i=``;try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await g(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64){let e=C(t.contentBase64);n=e.headers,i=e.body}}else if(t.endsWith(`.csv`)){let t=await v(`templates`,e.path),r=w(t.content);n=r.headers,i=r.body}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await v(`templates`,e.path),r=T(t.content);n=r.headers,i=r.body}}catch{i=``}r.push({id:e.path,title:e.name.replace(/\.[^.]+$/,``),body:i,headers:n})}return r}catch{return[]}}async function j(t){let n=t.toLowerCase();if(n.endsWith(`.md`)||n.endsWith(`.txt`)||n.endsWith(`.csv`))return(await v(`requirements`,t)).content;if(n.endsWith(`.docx`)){let n=await g(`requirements`,t);if(n.encoding!==`base64`||!n.contentBase64)throw Error(`无法读取 docx`);let r=atob(n.contentBase64),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return((await(await E(()=>import(`./lib.S37S0T6S.js`).then(t=>e(t.default,1)),__vite__mapDeps([0,1,2]))).extractRawText({arrayBuffer:i.buffer})).value??``).trim()}throw Error(`该需求文件类型暂不支持正文提取`)}function M(){let[e,t]=(0,k.useState)(null),[r,g]=(0,k.useState)(!1),[C,w]=(0,k.useState)([]),[T,E]=(0,k.useState)(``),[M,N]=(0,k.useState)(`functional`),[P,ye]=(0,k.useState)([]),[be,F]=(0,k.useState)(``),[xe,Se]=(0,k.useState)([]),[I,L]=(0,k.useState)(``),[Ce,R]=(0,k.useState)(``),[we,Te]=(0,k.useState)([]),[z,B]=(0,k.useState)([]),[V,H]=(0,k.useState)(`md`),[U,Ee]=(0,k.useState)(``),[W,G]=(0,k.useState)(null),[K,De]=(0,k.useState)(!1),[Oe,q]=(0,k.useState)(null),[J,Y]=(0,k.useState)(null),X=(0,k.useRef)(null),ke=(0,k.useRef)(null),Z=(0,k.useMemo)(()=>P.find(e=>e.id===be)??P[0],[P,be]),Q=M,Ae=s(Q).label;(0,k.useEffect)(()=>{n().then(()=>t(oe()));let e=ae(()=>t(oe()));return(async()=>{await c();let e=await y(`requirements`),t=await y(`cases`),n=await y(`templates`),r=await y(`prompts`),i=await y(`knowledge`);g(e&&t&&n&&r);async function a(e,t,n){let{entries:r}=await h(e,t);for(let t of r)t.type===`file`?n.push(t):await a(e,t.path,n)}if(e)try{let e=[];await a(`requirements`,`.`,e),w(e)}catch{}if(i)try{let e=[];await a(`knowledge`,`.`,e),e.sort((e,t)=>(t.mtime??0)-(e.mtime??0)),Te(e)}catch{}if(r)try{let e=[];await a(`prompts`,`.`,e);let t=e.filter(e=>!ce(e.path));t.sort((e,t)=>(t.mtime??0)-(e.mtime??0)),Se(t);let n=t.find(e=>e.path.includes(`功能测试用例提示词`))?.path??t[0]?.path??``;L(e=>e&&!ce(e)&&t.some(t=>t.path===e)?e:n)}catch{}let s=new URLSearchParams(window.location.search),d=s.get(`session`),f=s.get(`path`),p=l();if(d){let e=p.sessions.find(e=>e.id===d);e&&(G(e),N(e.caseType),H(e.outputFormat),E(e.reqPaths[0]??``),e.templateId&&F(e.templateId),e.promptPath&&L(e.promptPath),e.knowledgePaths?.length&&B([...e.knowledgePaths]),e.linkedCasePath&&Y({path:e.linkedCasePath,count:0}))}else if(f){let e=p.sessions.find(e=>e.linkedCasePath===f);if(e)G(e),N(e.caseType),H(e.outputFormat),E(e.reqPaths[0]??``),e.templateId&&F(e.templateId),e.promptPath&&L(e.promptPath),e.knowledgePaths?.length&&B([...e.knowledgePaths]),e.linkedCasePath&&Y({path:e.linkedCasePath,count:0});else{let e=f.split(`.`).pop()?.toLowerCase(),t=e===`csv`?`csv`:e===`xlsx`||e===`xls`?`xlsx`:`md`,n=f.split(`/`)[0]??``,r=o().find(e=>e.casesFolder===n)?.id??o()[0]?.id??`functional`,i=ee({title:f.split(`/`).pop()?.replace(/\.[^.]+$/,``)||`用例续改`,caseType:r,outputFormat:t,reqPaths:[]}),a=u(i.id,{linkedCasePath:f}).sessions.find(e=>e.id===i.id)??null;G(a),N(r),H(t),Y({path:f,count:0})}}})(),e},[]),(0,k.useEffect)(()=>{if(!r)return;let e=!1;return ve(M).then(t=>{e||(ye(t),F(e=>e&&t.some(t=>t.id===e)?e:W?.templateId&&t.some(e=>e.id===W.templateId)?W.templateId:t[0]?.id??``))}),()=>{e=!0}},[r,M,W?.templateId]),(0,k.useEffect)(()=>{I?v(`prompts`,I).then(e=>{let t=e.content??``;R(t),t.trim()||a(`「提示词管理/${I}」是空的,生成前请先补上提示词内容。`,`error`)}).catch(e=>{R(``);let t=e instanceof Error?e.message:String(e);a(`没有读到「提示词管理/${I}」:${t}`,`error`)}):R(``)},[I]),(0,k.useEffect)(()=>{ke.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[W?.messages,K]);function $(e){if(!W)return;let t=u(W.id,e);G(t.sessions.find(e=>e.id===W.id)??W)}async function je(){let e=``;if(T)try{let t=await j(T);e+=`\n### 需求文档:${T}\n${t}\n`}catch{e+=`\n### 需求文档:${T}\n(无法读取正文)\n`}Z?.body?e+=`\n### 用例模板:${Z.title}\n${Z.body}\n`:Z&&(e+=`\n### 用例模板:${Z.title}\n字段:${(Z.headers.length?Z.headers:p).join(`、`)}\n`);for(let t of z)try{let n=await v(`knowledge`,t);e+=`\n### 知识库:${t}\n${n.content}\n`}catch{e+=`\n### 知识库:${t}\n(无法读取)\n`}return e}async function Me(e,t,n,r){let i=s(t.caseType),a=n||t.title||i.label,o=f(a,t.caseType),c=i.casesFolder;try{await _(`cases`,`.`,c)}catch{}let l=`${c}/${o}${t.outputFormat===`md`?`.md`:t.outputFormat===`csv`?`.csv`:`.xlsx`}`,u=r.length?r:[...p];return t.outputFormat===`md`?await x(`cases`,l,te(e,a,u)):t.outputFormat===`csv`?await x(`cases`,l,S(e,u)):await m(`cases`,l,await ne(e,u,i.label)),l}async function Ne(){if(!T)return``;let e=pe(T);try{return me(await j(T))||e}catch{return e}}async function Pe(t,n){if(!e){ie(`model`);return}if(!r){q(`本地文档服务未就绪,无法读写用例 / 需求 / 模板库`);return}let i=await Ne(),o=n;o?(u(o.id,{caseType:M,outputFormat:V,reqPaths:T?[T]:[],templateId:Z?.id,templateTitle:Z?.title,promptPath:I||void 0,knowledgePaths:z.length?[...z]:void 0}),o={...o,caseType:M,outputFormat:V,reqPaths:T?[T]:[],templateId:Z?.id,templateTitle:Z?.title,promptPath:I||void 0,knowledgePaths:z.length?[...z]:void 0}):(o=ee({title:i||t.slice(0,24)||`用例生成`,caseType:M,outputFormat:V,reqPaths:T?[T]:[],templateId:Z?.id,templateTitle:Z?.title,promptPath:I||void 0,knowledgePaths:z.length?[...z]:void 0}),G(o));let c=await je(),l=s(M).label,d=Z?.headers?.length?Z.headers:[...p],f=V===`md`?`最终结果将保存为 Markdown 表格文件`:V===`csv`?`最终结果将保存为 CSV 文件`:`最终结果将保存为 Excel 文件`,m=Ce.trim();if(!m){let e=I?`「提示词管理/${I}」没读到内容,请先在提示词管理里补上`:`请先选择提示词`;q(e),a(e,`error`);return}let h=`${m}
2
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.DwpFFa5D.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./SelectDropdown.Dmk5n225.js";import{showToast as a}from"./Toast.BO2NFckG.js";import{i as o,r as s}from"./case-types.B51yDRdf.js";import{d as c,f as l,m as u,p as d,r as f,u as ee}from"./case-gen-run.nrr97yK3.js";import{a as p}from"./case-fields.CmePqYfh.js";import{_ as m,c as h,f as g,l as _,p as v,r as y,u as b,v as x}from"./project-docs.CCjtiFjB.js";import{a as S,i as C,n as w,o as te,r as T,s as ne,t as re}from"./case-template.Cd2xNbgy.js";import{b as E,m as ie,p as ae,u as oe}from"./settings.CYERib3l.js";import{o as se}from"./llm.DN5S1KBK.js";import{n as D}from"./doc-roots.CO3IBiY6.js";import{r as ce}from"./prompts-meta.bF2q5SUy.js";import{t as le}from"./ExcelFieldTags.CXif3Ilh.js";import{t as ue}from"./MultiSelectDropdown.y8JMbCxO.js";import{t as O}from"./SearchableSelect.DFZBUFIs.js";var k=e(t(),1),A=r(),de=[{value:`md`,label:`Markdown 表格`},{value:`xlsx`,label:`Excel`},{value:`csv`,label:`CSV`}];function fe(e){let t=e.match(/```(?:json)?\s*([\s\S]*?)```/)?.[1]??e.match(/\{[\s\S]*\}/)?.[0]??e.match(/\[[\s\S]*\]/)?.[0];if(!t)return null;try{let e=JSON.parse(t);if(Array.isArray(e)&&e.length>0)return{docTitle:``,cases:e};if(e&&typeof e==`object`){let t=e,n=t.用例??t.cases??t.items;if(!Array.isArray(n)||n.length===0)return null;let r=t.需求名称??t.文档名称??t.docTitle??t.title;return{docTitle:typeof r==`string`?r.trim():``,cases:n}}}catch{return null}return null}function pe(e){return(e.split(`/`).pop()||e).replace(/\.[^.]+$/,``).trim()}function me(e){let t=e.match(/^#\s+(.+)$/m);if(t?.[1])return t[1].trim().slice(0,48);let n=e.match(/^标题[::]\s*(.+)$/m);return n?.[1]?n[1].trim().slice(0,48):``}function he(e,t){let n=[];if(!e.length)return n.push(`未生成任何用例`),n;for(let r of t){let t=e.filter(e=>!String(e[r]??``).trim()).length;t===e.length?n.push(`字段「${r}」全部为空`):t>Math.max(2,Math.floor(e.length*.3))&&n.push(`字段「${r}」有 ${t}/${e.length} 条为空`)}e.length<15&&n.push(`用例数量偏少(${e.length} 条),建议核对需求覆盖`);let r=e.map(e=>{for(let t of[`用例标题`,`标题`,`测试分项目`,`测试项目`])if(e[t]?.trim())return e[t].trim();return``}).filter(Boolean),i=new Set(r);return r.length>=4&&i.size<r.length*.6&&n.push(`用例标题/分项重复偏多,可能覆盖不足`),n}function ge(e){if(e==null||e<0)return`—`;if(e<1e3)return`${e} ms`;let t=e/1e3;if(t<60)return`${t.toFixed(1)} s`;let n=Math.floor(t/60);return`${n} 分 ${Math.round(t-n*60)} 秒`}function _e(e){if(!e)return`—`;try{return new Date(e).toLocaleString(`zh-CN`,{hour12:!1})}catch{return`—`}}async function ve(e){let t=s(e).templateFolder;try{let{entries:e}=await h(`templates`,t),n=e.filter(e=>e.type===`file`).sort((e,t)=>(t.mtime??0)-(e.mtime??0)),r=[];for(let e of n){let t=e.name.toLowerCase(),n=[...p],i=``;try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await g(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64){let e=C(t.contentBase64);n=e.headers,i=e.body}}else if(t.endsWith(`.csv`)){let t=await v(`templates`,e.path),r=w(t.content);n=r.headers,i=r.body}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await v(`templates`,e.path),r=T(t.content);n=r.headers,i=r.body}}catch{i=``}r.push({id:e.path,title:e.name.replace(/\.[^.]+$/,``),body:i,headers:n})}return r}catch{return[]}}async function j(t){let n=t.toLowerCase();if(n.endsWith(`.md`)||n.endsWith(`.txt`)||n.endsWith(`.csv`))return(await v(`requirements`,t)).content;if(n.endsWith(`.docx`)){let n=await g(`requirements`,t);if(n.encoding!==`base64`||!n.contentBase64)throw Error(`无法读取 docx`);let r=atob(n.contentBase64),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return((await(await E(()=>import(`./lib.S37S0T6S.js`).then(t=>e(t.default,1)),__vite__mapDeps([0,1,2]))).extractRawText({arrayBuffer:i.buffer})).value??``).trim()}throw Error(`该需求文件类型暂不支持正文提取`)}function M(){let[e,t]=(0,k.useState)(null),[r,g]=(0,k.useState)(!1),[C,w]=(0,k.useState)([]),[T,E]=(0,k.useState)(``),[M,N]=(0,k.useState)(`functional`),[P,ye]=(0,k.useState)([]),[be,F]=(0,k.useState)(``),[xe,Se]=(0,k.useState)([]),[I,L]=(0,k.useState)(``),[Ce,R]=(0,k.useState)(``),[we,Te]=(0,k.useState)([]),[z,B]=(0,k.useState)([]),[V,H]=(0,k.useState)(`md`),[U,Ee]=(0,k.useState)(``),[W,G]=(0,k.useState)(null),[K,De]=(0,k.useState)(!1),[Oe,q]=(0,k.useState)(null),[J,Y]=(0,k.useState)(null),X=(0,k.useRef)(null),ke=(0,k.useRef)(null),Z=(0,k.useMemo)(()=>P.find(e=>e.id===be)??P[0],[P,be]),Q=M,Ae=s(Q).label;(0,k.useEffect)(()=>{n().then(()=>t(oe()));let e=ae(()=>t(oe()));return(async()=>{await c();let e=await y(`requirements`),t=await y(`cases`),n=await y(`templates`),r=await y(`prompts`),i=await y(`knowledge`);g(e&&t&&n&&r);async function a(e,t,n){let{entries:r}=await h(e,t);for(let t of r)t.type===`file`?n.push(t):await a(e,t.path,n)}if(e)try{let e=[];await a(`requirements`,`.`,e),w(e)}catch{}if(i)try{let e=[];await a(`knowledge`,`.`,e),e.sort((e,t)=>(t.mtime??0)-(e.mtime??0)),Te(e)}catch{}if(r)try{let e=[];await a(`prompts`,`.`,e);let t=e.filter(e=>!ce(e.path));t.sort((e,t)=>(t.mtime??0)-(e.mtime??0)),Se(t);let n=t.find(e=>e.path.includes(`功能测试用例提示词`))?.path??t[0]?.path??``;L(e=>e&&!ce(e)&&t.some(t=>t.path===e)?e:n)}catch{}let s=new URLSearchParams(window.location.search),d=s.get(`session`),f=s.get(`path`),p=l();if(d){let e=p.sessions.find(e=>e.id===d);e&&(G(e),N(e.caseType),H(e.outputFormat),E(e.reqPaths[0]??``),e.templateId&&F(e.templateId),e.promptPath&&L(e.promptPath),e.knowledgePaths?.length&&B([...e.knowledgePaths]),e.linkedCasePath&&Y({path:e.linkedCasePath,count:0}))}else if(f){let e=p.sessions.find(e=>e.linkedCasePath===f);if(e)G(e),N(e.caseType),H(e.outputFormat),E(e.reqPaths[0]??``),e.templateId&&F(e.templateId),e.promptPath&&L(e.promptPath),e.knowledgePaths?.length&&B([...e.knowledgePaths]),e.linkedCasePath&&Y({path:e.linkedCasePath,count:0});else{let e=f.split(`.`).pop()?.toLowerCase(),t=e===`csv`?`csv`:e===`xlsx`||e===`xls`?`xlsx`:`md`,n=f.split(`/`)[0]??``,r=o().find(e=>e.casesFolder===n)?.id??o()[0]?.id??`functional`,i=ee({title:f.split(`/`).pop()?.replace(/\.[^.]+$/,``)||`用例续改`,caseType:r,outputFormat:t,reqPaths:[]}),a=u(i.id,{linkedCasePath:f}).sessions.find(e=>e.id===i.id)??null;G(a),N(r),H(t),Y({path:f,count:0})}}})(),e},[]),(0,k.useEffect)(()=>{if(!r)return;let e=!1;return ve(M).then(t=>{e||(ye(t),F(e=>e&&t.some(t=>t.id===e)?e:W?.templateId&&t.some(e=>e.id===W.templateId)?W.templateId:t[0]?.id??``))}),()=>{e=!0}},[r,M,W?.templateId]),(0,k.useEffect)(()=>{I?v(`prompts`,I).then(e=>{let t=e.content??``;R(t),t.trim()||a(`「提示词管理/${I}」是空的,生成前请先补上提示词内容。`,`error`)}).catch(e=>{R(``);let t=e instanceof Error?e.message:String(e);a(`没有读到「提示词管理/${I}」:${t}`,`error`)}):R(``)},[I]),(0,k.useEffect)(()=>{ke.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[W?.messages,K]);function $(e){if(!W)return;let t=u(W.id,e);G(t.sessions.find(e=>e.id===W.id)??W)}async function je(){let e=``;if(T)try{let t=await j(T);e+=`\n### 需求文档:${T}\n${t}\n`}catch{e+=`\n### 需求文档:${T}\n(无法读取正文)\n`}Z?.body?e+=`\n### 用例模板:${Z.title}\n${Z.body}\n`:Z&&(e+=`\n### 用例模板:${Z.title}\n字段:${(Z.headers.length?Z.headers:p).join(`、`)}\n`);for(let t of z)try{let n=await v(`knowledge`,t);e+=`\n### 知识库:${t}\n${n.content}\n`}catch{e+=`\n### 知识库:${t}\n(无法读取)\n`}return e}async function Me(e,t,n,r){let i=s(t.caseType),a=n||t.title||i.label,o=f(a,t.caseType),c=i.casesFolder;try{await _(`cases`,`.`,c)}catch{}let l=`${c}/${o}${t.outputFormat===`md`?`.md`:t.outputFormat===`csv`?`.csv`:`.xlsx`}`,u=r.length?r:[...p];return t.outputFormat===`md`?await x(`cases`,l,te(e,a,u)):t.outputFormat===`csv`?await x(`cases`,l,S(e,u)):await m(`cases`,l,await ne(e,u,i.label)),l}async function Ne(){if(!T)return``;let e=pe(T);try{return me(await j(T))||e}catch{return e}}async function Pe(t,n){if(!e){ie(`model`);return}if(!r){q(`本地文档服务未就绪,无法读写用例 / 需求 / 模板库`);return}let i=await Ne(),o=n;o?(u(o.id,{caseType:M,outputFormat:V,reqPaths:T?[T]:[],templateId:Z?.id,templateTitle:Z?.title,promptPath:I||void 0,knowledgePaths:z.length?[...z]:void 0}),o={...o,caseType:M,outputFormat:V,reqPaths:T?[T]:[],templateId:Z?.id,templateTitle:Z?.title,promptPath:I||void 0,knowledgePaths:z.length?[...z]:void 0}):(o=ee({title:i||t.slice(0,24)||`用例生成`,caseType:M,outputFormat:V,reqPaths:T?[T]:[],templateId:Z?.id,templateTitle:Z?.title,promptPath:I||void 0,knowledgePaths:z.length?[...z]:void 0}),G(o));let c=await je(),l=s(M).label,d=Z?.headers?.length?Z.headers:[...p],f=V===`md`?`最终结果将保存为 Markdown 表格文件`:V===`csv`?`最终结果将保存为 CSV 文件`:`最终结果将保存为 Excel 文件`,m=Ce.trim();if(!m){let e=I?`「提示词管理/${I}」没读到内容,请先在提示词管理里补上`:`请先选择提示词`;q(e),a(e,`error`);return}let h=`${m}
3
3
 
4
4
  【运行时约束】
5
5
  - 用例类型:${l}
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/case-fields.CmePqYfh.js","_astro/react.Blvh0GOs.js","_astro/lib.S37S0T6S.js","_astro/jszip.min.Bh2Mgo40.js"])))=>i.map(i=>d[i]);
2
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.C4rpn1Ix.js";import{i as r,o as i,s as a}from"./plugins.C0NrHGZv.js";import{n as o,o as s,r as c,s as l}from"./view-prefs.8MPl3A7e.js";import{i as u,n as d,r as f,t as p}from"./dialog.DZHZCe_T.js";import{t as m}from"./jsx-runtime.DUg_B_vD.js";import{t as h}from"./ConfirmDialog.D5qXeML0.js";import{n as g,t as _}from"./DocsPager.D0TMvJ67.js";import{t as v}from"./OverflowHint.pvo2Xc8R.js";import{t as y}from"./SelectDropdown.Dmk5n225.js";import{t as b}from"./SlideOverDrawer.C1IVOc_8.js";import{m as x}from"./PmShared.D6iq_Z9g.js";import{n as S,r as C,t as w}from"./TableFieldConfig.C_NeWm8L.js";import{showToast as T}from"./Toast.BO2NFckG.js";import{i as E,n as D,o as O}from"./case-gen-run.FzgC_1Ki.js";import{a as ee,i as k,r as A,t as j}from"./case-fields.CmePqYfh.js";import{c as M,d as te,f as N,g as P,h as ne,n as re,o as F,p as I,r as ie,u as ae}from"./project-docs.DAw9bzgk.js";import{c as oe}from"./case-template.C-GBxgBC.js";import{b as se,p as ce,s as le,u as ue}from"./settings.NTeTjmxg.js";import{M as de,v as fe,z as pe}from"./req-analysis.BqvytN69.js";import{s as me}from"./llm.DyweO-KK.js";import{n as he}from"./doc-roots.DAJP9Svr.js";import{i as ge,n as _e,r as ve,t as ye}from"./DocsFileBrowser.DceJyP9V.js";import{d as L,f as be,h as R,l as xe,n as Se,o as Ce,p as z,t as we,v as B}from"./open-docs-in-session.5cTowYAC.js";import{A as Te,C as V,D as Ee,E as H,M as De,N as Oe,O as U,P as ke,S as Ae,T as je,_ as Me,a as W,b as Ne,c as G,d as Pe,f as Fe,g as Ie,h as Le,j as Re,k as ze,l as Be,m as Ve,n as He,o as Ue,p as K,s as q,t as J,u as We,v as Ge,w as Ke,x as qe,y as Je}from"./case-review.TdDs1WFM.js";import{a as Ye,c as Xe,d as Ze,i as Qe,l as $e,n as et,o as tt,t as Y}from"./ColumnResize.CkE59sGq.js";import{t as nt}from"./NamePromptDialog.Csfnh5eM.js";import{o as rt,r as it,s as at,t as ot}from"./composer-task.DJmluzPT.js";var X=e(t(),1),st=`备份列表`;function ct(e){return String(e??``).replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()===st}function lt(e){let t=String(e??``).split(/[/\\]/).pop();return t?/\.bak(?:$|[-_.])/i.test(t):!1}var Z=m(),ut=40,dt=20,ft=`tw.case-backup.page-size.v1`,pt=[{key:`select`,width:ut,min:36},{key:`name`,width:280,min:140},{key:`kind`,width:100,min:72},{key:`mtime`,width:148,min:120},{key:`size`,width:88,min:64},{key:`filler`,filler:!0},{key:`action`,width:72,min:64}];async function mt(e=`.`){let{entries:t}=await M(`cases`,e),n=[];for(let e of t)e.type===`file`?(lt(e.name)||lt(e.path))&&n.push(e):!ct(e.name)&&!ct(e.path)&&n.push(...await mt(e.path));return n}function ht(e){return e===`folder`?`备份列表`:e===`sidecar`?`旁路`:`历史`}function gt(e){if(!Number.isFinite(e))return`—`;try{return new Date(e).toLocaleString(`zh-CN`,{hour12:!1})}catch{return`—`}}function _t(e){return e==null||!Number.isFinite(e)?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}async function vt(){let e=[];try{if(await je()){let t=await V();for(let n of t){let t=n.kind===`legacy`?`legacy`:`folder`,r=n.casesPath||(t===`folder`?n.path:``);e.push({id:`${t}:${n.name}:${n.mtime}`,kind:t,name:n.name,path:r||n.path,reviewName:t===`legacy`?n.name:void 0,mtime:n.mtime,size:n.size})}}}catch{}try{let t=await mt(`.`);for(let n of t){let t=typeof n.mtime==`number`?n.mtime:0;e.push({id:`sidecar:${n.path}`,kind:`sidecar`,name:n.name,path:n.path,mtime:t,size:n.size})}}catch{}return e.sort((e,t)=>t.mtime-e.mtime),e}function yt({open:e,onClose:t,onChanged:n}){let[r,i]=(0,X.useState)([]),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)({}),[p,m]=(0,X.useState)(null),[y,S]=(0,X.useState)(null),[C,w]=(0,X.useState)(``),[E,D]=(0,X.useState)(1),[O,ee]=g(dt,ft),k=$e(`lh:case-backup:cols:v4`,pt),A=Ze(`case-backup`),j=(0,X.useCallback)(async()=>{o(!0),u(null);try{let e=await vt();i(e),f(t=>{let n={};for(let r of e)t[r.id]&&(n[r.id]=!0);return n})}catch(e){u(e instanceof Error?e.message:String(e))}finally{o(!1)}},[]);(0,X.useEffect)(()=>{e&&(D(1),j())},[e,j]);let M=Math.max(1,Math.ceil(r.length/O)),N=Math.min(E,M),P=(0,X.useMemo)(()=>r.slice((N-1)*O,N*O),[r,N,O]),F=(0,X.useMemo)(()=>Object.keys(d).filter(e=>d[e]),[d]),I=P.length>0&&P.every(e=>d[e.id]);async function ie(e){c(!0),u(null);try{let t=e.filter(e=>e.kind===`folder`||e.kind===`sidecar`),r=e.filter(e=>e.kind===`legacy`);for(let e of t)await re(`cases`,e.path);r.length&&await Je(r.map(e=>e.reviewName||e.name)),T(e.length===1?`已删除「${e[0].name}」`:`已删除 ${e.length} 个备份`,`success`),await j(),n?.()}catch(e){let t=e instanceof Error?e.message:String(e);u(t),T(`删除失败:${t}`,`error`)}finally{c(!1)}}async function oe(){let e=p;if(m(null),!e)return;if(e.kind===`one`){await ie([e.row]);return}let t=new Map(r.map(e=>[e.id,e])),n=e.ids.map(e=>t.get(e)).filter(Boolean);n.length&&await ie(n)}async function se(e){if(e.kind!==`legacy`)try{await ae(`cases`,e.path)}catch(e){u(e instanceof Error?e.message:String(e))}}function ce(e){e.kind!==`legacy`&&(w(``),S(e))}async function le(e){let t=y;if(!t||t.kind===`legacy`)return;let i=e.trim();if(!i||i===t.name){S(null),w(``);return}let a=te(t.path),o=(a===`.`?i:`${a}/${i}`).toLowerCase(),s=r.find(e=>e.id!==t.id&&e.kind!==`legacy`&&e.path.toLowerCase()===o);if(s)w(`已存在同名文件「${s.name}」,换个名字再试`);else{c(!0),u(null),w(``);try{await ne(`cases`,t.path,i),S(null),T(`已重命名为「${i}」`,`success`),await j(),n?.()}catch(e){let t=e instanceof Error?e.message:String(e);w(t),T(`重命名失败:${t}`,`error`)}finally{c(!1)}}}let ue=p?.kind===`one`?`删除备份「${p.row.name}」?此操作不可恢复。`:p?.kind===`batch`?`确认删除已选中的 ${p.ids.length} 个备份?此操作不可恢复。`:``;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(b,{open:e,onClose:t,title:`备份列表`,closeAriaLabel:`关闭备份列表`,widthClass:`max-w-5xl`,bodyClassName:`flex flex-col gap-3 overflow-hidden`,escDisabled:!!p||y!=null,footer:(0,Z.jsxs)(`footer`,{className:`shrink-0 p-4 border-t border-stone-100 flex items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,disabled:s||F.length===0,onClick:()=>m({kind:`batch`,ids:F}),className:`h-9 px-3 text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:[`删除所选`,F.length?`(${F.length})`:``]}),(0,Z.jsx)(`div`,{className:`flex-1`}),(0,Z.jsx)(`button`,{type:`button`,disabled:s||a,onClick:()=>void j(),className:`h-9 px-3 text-sm font-medium text-stone-700 border border-stone-200 rounded-lg hover:bg-stone-50 disabled:opacity-40`,children:`刷新`}),(0,Z.jsx)(`button`,{type:`button`,onClick:t,className:`h-9 px-3 text-sm font-medium text-stone-700 border border-stone-200 rounded-lg hover:bg-stone-50`,children:`关闭`})]}),children:[(0,Z.jsxs)(`p`,{className:`shrink-0 text-xs text-stone-500 leading-5`,children:[`新备份在「用例管理/`,st,`/」(首次备份时自动创建,主列表不展示该文件夹)。历史旁路 .bak* 仍可在此查看。备份不会自动过期,请手动删除。`]}),l?(0,Z.jsx)(`div`,{className:`shrink-0 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:l}):null,(0,Z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 text-xs text-stone-500`,children:[(0,Z.jsxs)(`span`,{children:[`共 `,(0,Z.jsx)(`span`,{className:`font-medium text-stone-800`,children:r.length}),` 个`]}),a?(0,Z.jsx)(`span`,{children:`加载中…`}):null]}),r.length===0&&!a?(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 rounded-xl border border-dashed border-stone-200 px-4 py-10 flex items-center justify-center text-sm text-stone-400`,children:`暂无备份文件`}):(0,Z.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-hidden rounded-xl border border-stone-200 flex flex-col`,children:[(0,Z.jsx)(`div`,{ref:A,className:`tw-scroll-x flex-1 min-h-0 overflow-auto`,children:(0,Z.jsxs)(`table`,{className:`tw-data-table tw-sticky-table w-full table-fixed text-left text-sm`,style:k.tableStyle,children:[(0,Z.jsx)(`colgroup`,{children:pt.map(e=>(0,Z.jsx)(`col`,{style:k.widthOf(e.key)?{width:k.widthOf(e.key)}:void 0},e.key))}),(0,Z.jsx)(`thead`,{className:`bg-stone-50 text-xs text-stone-500`,children:(0,Z.jsxs)(`tr`,{children:[(0,Z.jsxs)(`th`,{className:`${Ye} relative`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:I,disabled:s||P.length===0,onChange:e=>{let t=e.target.checked;f(e=>{let n={...e};for(let e of P)t?n[e.id]=!0:delete n[e.id];return n})},"aria-label":`全选本页备份`}),(0,Z.jsx)(Y,{...k.resizeProps(`select`)})]}),(0,Z.jsxs)(`th`,{className:tt,style:{"--tw-sticky-left":`${ut}px`},children:[`文件名`,(0,Z.jsx)(Y,{...k.resizeProps(`name`)})]}),(0,Z.jsxs)(`th`,{className:`relative px-3 py-2 font-medium whitespace-nowrap`,children:[`类型`,(0,Z.jsx)(Y,{...k.resizeProps(`kind`)})]}),(0,Z.jsxs)(`th`,{className:`relative px-3 py-2 font-medium whitespace-nowrap`,children:[`备份时间`,(0,Z.jsx)(Y,{...k.resizeProps(`mtime`)})]}),(0,Z.jsxs)(`th`,{className:`relative px-3 py-2 font-medium whitespace-nowrap`,children:[`大小`,(0,Z.jsx)(Y,{...k.resizeProps(`size`)})]}),(0,Z.jsx)(`th`,{"aria-hidden":`true`}),(0,Z.jsx)(`th`,{className:Xe,children:`操作`})]})}),(0,Z.jsx)(`tbody`,{children:P.map(e=>(0,Z.jsxs)(`tr`,{className:`group border-t border-stone-100 ${e.kind===`legacy`?``:`cursor-pointer`}`,onDoubleClick:()=>{e.kind===`legacy`||s||se(e)},children:[(0,Z.jsx)(`td`,{className:et,onDoubleClick:e=>e.stopPropagation(),children:(0,Z.jsx)(`input`,{type:`checkbox`,checked:!!d[e.id],disabled:s,onChange:t=>f(n=>({...n,[e.id]:t.target.checked})),"aria-label":`选择 ${e.name}`})}),(0,Z.jsx)(`td`,{className:`${et} min-w-0 max-w-0`,style:{"--tw-sticky-left":`${ut}px`},children:(0,Z.jsxs)(`div`,{className:`inline-flex min-w-0 max-w-full items-center`,children:[(0,Z.jsx)(v,{text:e.name,className:`min-w-0 truncate font-medium text-stone-800`}),e.kind===`legacy`?null:(0,Z.jsx)(`span`,{className:`ml-0.5 mr-1 flex shrink-0 items-center opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100`,onDoubleClick:e=>e.stopPropagation(),children:(0,Z.jsx)(`button`,{type:`button`,disabled:s,"aria-label":`重命名 ${e.name}`,onClick:()=>ce(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,Z.jsx)(x,{name:`pencil`,size:12})})})]})}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 text-xs text-stone-600 whitespace-nowrap`,children:ht(e.kind)}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 text-xs text-stone-600 whitespace-nowrap`,children:gt(e.mtime)}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 text-xs text-stone-600 whitespace-nowrap tabular-nums`,children:_t(e.size)}),(0,Z.jsx)(`td`,{"aria-hidden":`true`}),(0,Z.jsx)(`td`,{className:Qe,onDoubleClick:e=>e.stopPropagation(),children:(0,Z.jsx)(`div`,{className:`flex items-center justify-center gap-1.5 whitespace-nowrap`,children:(0,Z.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>m({kind:`one`,row:e}),className:`h-7 px-2 text-xs font-medium text-red-600 rounded-md hover:bg-red-50 disabled:opacity-40`,children:`删除`})})})]},e.id))})]})}),r.length>0?(0,Z.jsx)(_,{page:N,totalPages:M,pageSize:O,busy:s||a,className:`shrink-0 !px-4 !py-2`,onPage:D,onPageSize:e=>{ee(e),D(1)}}):null]})]}),(0,Z.jsx)(h,{open:!!p,title:p?.kind===`batch`?`批量删除备份`:`删除备份`,message:ue,confirmLabel:`删除`,danger:!0,onClose:()=>m(null),onConfirm:()=>void oe()}),(0,Z.jsx)(nt,{open:y!=null,title:`重命名备份`,label:`文件名称`,placeholder:`请输入文件名`,initialValue:y?.name??``,lockExtension:!0,confirmLabel:`保存`,cancelLabel:`取消`,error:C,onClose:()=>{s||(S(null),w(``))},onConfirm:e=>void le(e)})]})}async function bt(e){let t=[...pe(e.outline??[]).entries()].sort((e,t)=>e[1]-t[1]).map(([e])=>e),n=new Map((e.stories??[]).map(e=>[e.id.toUpperCase(),e.sourceRefs??[]])),r=[];if(e.sourcePath)try{let t=await xt(e.sourcePath);r=fe(t)}catch{r=[]}return{outlineOrder:t,testPointIds:e.testPoints?.points?.map(e=>e.id)??void 0,idealOrder:r,storySourceRefs:n}}async function xt(t){let n=t.toLowerCase();if(n.endsWith(`.xlsx`)||n.endsWith(`.xls`)){let e=await N(`requirements`,t);if(e.encoding!==`base64`||!e.contentBase64)throw Error(`无法读取 Excel`);let n=await se(()=>import(`./case-fields.CmePqYfh.js`).then(e=>e.d),__vite__mapDeps([0,1])),r=n.read(e.contentBase64,{type:`base64`,cellDates:!0}),i=[];for(let e of r.SheetNames){let t=r.Sheets[e];if(!t)continue;let a=n.utils.sheet_to_csv(t,{blankrows:!1}).trim();a&&i.push(`## 工作表:${e}\n${a}`)}return i.join(`
2
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.DwpFFa5D.js";import{i as r,o as i,s as a}from"./plugins.BmKRnp4a.js";import{n as o,o as s,r as c,s as l}from"./view-prefs.GnvelRDj.js";import{i as u,n as d,r as f,t as p}from"./dialog.DZHZCe_T.js";import{t as m}from"./jsx-runtime.DUg_B_vD.js";import{t as h}from"./ConfirmDialog.D5qXeML0.js";import{n as g,t as _}from"./DocsPager.ceBEecmd.js";import{t as v}from"./OverflowHint.pvo2Xc8R.js";import{t as y}from"./SelectDropdown.Dmk5n225.js";import{t as b}from"./SlideOverDrawer.C1IVOc_8.js";import{m as x}from"./PmShared.86HEsdd_.js";import{n as S,r as C,t as w}from"./TableFieldConfig.D0v9S2g3.js";import{showToast as T}from"./Toast.BO2NFckG.js";import{i as E,n as D,o as O}from"./case-gen-run.nrr97yK3.js";import{a as ee,i as k,r as A,t as j}from"./case-fields.CmePqYfh.js";import{c as M,d as te,f as N,g as P,h as ne,n as re,o as F,p as I,r as ie,u as ae}from"./project-docs.CCjtiFjB.js";import{c as oe}from"./case-template.Cd2xNbgy.js";import{b as se,p as ce,s as le,u as ue}from"./settings.CYERib3l.js";import{M as de,v as fe,z as pe}from"./req-analysis.qmyv5cBw.js";import{s as me}from"./llm.DN5S1KBK.js";import{n as he}from"./doc-roots.CO3IBiY6.js";import{i as ge,n as _e,r as ve,t as ye}from"./DocsFileBrowser.D66pN9rp.js";import{d as L,f as be,h as R,l as xe,n as Se,o as Ce,p as z,t as we,v as B}from"./open-docs-in-session.DJtuI1C4.js";import{A as Te,C as V,D as Ee,E as H,M as De,N as Oe,O as U,P as ke,S as Ae,T as je,_ as Me,a as W,b as Ne,c as G,d as Pe,f as Fe,g as Ie,h as Le,j as Re,k as ze,l as Be,m as Ve,n as He,o as Ue,p as K,s as q,t as J,u as We,v as Ge,w as Ke,x as qe,y as Je}from"./case-review.TdDs1WFM.js";import{a as Ye,c as Xe,d as Ze,i as Qe,l as $e,n as et,o as tt,t as Y}from"./ColumnResize.CkE59sGq.js";import{t as nt}from"./NamePromptDialog.Csfnh5eM.js";import{o as rt,r as it,s as at,t as ot}from"./composer-task.DJmluzPT.js";var X=e(t(),1),st=`备份列表`;function ct(e){return String(e??``).replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()===st}function lt(e){let t=String(e??``).split(/[/\\]/).pop();return t?/\.bak(?:$|[-_.])/i.test(t):!1}var Z=m(),ut=40,dt=20,ft=`tw.case-backup.page-size.v1`,pt=[{key:`select`,width:ut,min:36},{key:`name`,width:280,min:140},{key:`kind`,width:100,min:72},{key:`mtime`,width:148,min:120},{key:`size`,width:88,min:64},{key:`filler`,filler:!0},{key:`action`,width:72,min:64}];async function mt(e=`.`){let{entries:t}=await M(`cases`,e),n=[];for(let e of t)e.type===`file`?(lt(e.name)||lt(e.path))&&n.push(e):!ct(e.name)&&!ct(e.path)&&n.push(...await mt(e.path));return n}function ht(e){return e===`folder`?`备份列表`:e===`sidecar`?`旁路`:`历史`}function gt(e){if(!Number.isFinite(e))return`—`;try{return new Date(e).toLocaleString(`zh-CN`,{hour12:!1})}catch{return`—`}}function _t(e){return e==null||!Number.isFinite(e)?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}async function vt(){let e=[];try{if(await je()){let t=await V();for(let n of t){let t=n.kind===`legacy`?`legacy`:`folder`,r=n.casesPath||(t===`folder`?n.path:``);e.push({id:`${t}:${n.name}:${n.mtime}`,kind:t,name:n.name,path:r||n.path,reviewName:t===`legacy`?n.name:void 0,mtime:n.mtime,size:n.size})}}}catch{}try{let t=await mt(`.`);for(let n of t){let t=typeof n.mtime==`number`?n.mtime:0;e.push({id:`sidecar:${n.path}`,kind:`sidecar`,name:n.name,path:n.path,mtime:t,size:n.size})}}catch{}return e.sort((e,t)=>t.mtime-e.mtime),e}function yt({open:e,onClose:t,onChanged:n}){let[r,i]=(0,X.useState)([]),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)({}),[p,m]=(0,X.useState)(null),[y,S]=(0,X.useState)(null),[C,w]=(0,X.useState)(``),[E,D]=(0,X.useState)(1),[O,ee]=g(dt,ft),k=$e(`lh:case-backup:cols:v4`,pt),A=Ze(`case-backup`),j=(0,X.useCallback)(async()=>{o(!0),u(null);try{let e=await vt();i(e),f(t=>{let n={};for(let r of e)t[r.id]&&(n[r.id]=!0);return n})}catch(e){u(e instanceof Error?e.message:String(e))}finally{o(!1)}},[]);(0,X.useEffect)(()=>{e&&(D(1),j())},[e,j]);let M=Math.max(1,Math.ceil(r.length/O)),N=Math.min(E,M),P=(0,X.useMemo)(()=>r.slice((N-1)*O,N*O),[r,N,O]),F=(0,X.useMemo)(()=>Object.keys(d).filter(e=>d[e]),[d]),I=P.length>0&&P.every(e=>d[e.id]);async function ie(e){c(!0),u(null);try{let t=e.filter(e=>e.kind===`folder`||e.kind===`sidecar`),r=e.filter(e=>e.kind===`legacy`);for(let e of t)await re(`cases`,e.path);r.length&&await Je(r.map(e=>e.reviewName||e.name)),T(e.length===1?`已删除「${e[0].name}」`:`已删除 ${e.length} 个备份`,`success`),await j(),n?.()}catch(e){let t=e instanceof Error?e.message:String(e);u(t),T(`删除失败:${t}`,`error`)}finally{c(!1)}}async function oe(){let e=p;if(m(null),!e)return;if(e.kind===`one`){await ie([e.row]);return}let t=new Map(r.map(e=>[e.id,e])),n=e.ids.map(e=>t.get(e)).filter(Boolean);n.length&&await ie(n)}async function se(e){if(e.kind!==`legacy`)try{await ae(`cases`,e.path)}catch(e){u(e instanceof Error?e.message:String(e))}}function ce(e){e.kind!==`legacy`&&(w(``),S(e))}async function le(e){let t=y;if(!t||t.kind===`legacy`)return;let i=e.trim();if(!i||i===t.name){S(null),w(``);return}let a=te(t.path),o=(a===`.`?i:`${a}/${i}`).toLowerCase(),s=r.find(e=>e.id!==t.id&&e.kind!==`legacy`&&e.path.toLowerCase()===o);if(s)w(`已存在同名文件「${s.name}」,换个名字再试`);else{c(!0),u(null),w(``);try{await ne(`cases`,t.path,i),S(null),T(`已重命名为「${i}」`,`success`),await j(),n?.()}catch(e){let t=e instanceof Error?e.message:String(e);w(t),T(`重命名失败:${t}`,`error`)}finally{c(!1)}}}let ue=p?.kind===`one`?`删除备份「${p.row.name}」?此操作不可恢复。`:p?.kind===`batch`?`确认删除已选中的 ${p.ids.length} 个备份?此操作不可恢复。`:``;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(b,{open:e,onClose:t,title:`备份列表`,closeAriaLabel:`关闭备份列表`,widthClass:`max-w-5xl`,bodyClassName:`flex flex-col gap-3 overflow-hidden`,escDisabled:!!p||y!=null,footer:(0,Z.jsxs)(`footer`,{className:`shrink-0 p-4 border-t border-stone-100 flex items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,disabled:s||F.length===0,onClick:()=>m({kind:`batch`,ids:F}),className:`h-9 px-3 text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:[`删除所选`,F.length?`(${F.length})`:``]}),(0,Z.jsx)(`div`,{className:`flex-1`}),(0,Z.jsx)(`button`,{type:`button`,disabled:s||a,onClick:()=>void j(),className:`h-9 px-3 text-sm font-medium text-stone-700 border border-stone-200 rounded-lg hover:bg-stone-50 disabled:opacity-40`,children:`刷新`}),(0,Z.jsx)(`button`,{type:`button`,onClick:t,className:`h-9 px-3 text-sm font-medium text-stone-700 border border-stone-200 rounded-lg hover:bg-stone-50`,children:`关闭`})]}),children:[(0,Z.jsxs)(`p`,{className:`shrink-0 text-xs text-stone-500 leading-5`,children:[`新备份在「用例管理/`,st,`/」(首次备份时自动创建,主列表不展示该文件夹)。历史旁路 .bak* 仍可在此查看。备份不会自动过期,请手动删除。`]}),l?(0,Z.jsx)(`div`,{className:`shrink-0 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:l}):null,(0,Z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 text-xs text-stone-500`,children:[(0,Z.jsxs)(`span`,{children:[`共 `,(0,Z.jsx)(`span`,{className:`font-medium text-stone-800`,children:r.length}),` 个`]}),a?(0,Z.jsx)(`span`,{children:`加载中…`}):null]}),r.length===0&&!a?(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 rounded-xl border border-dashed border-stone-200 px-4 py-10 flex items-center justify-center text-sm text-stone-400`,children:`暂无备份文件`}):(0,Z.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-hidden rounded-xl border border-stone-200 flex flex-col`,children:[(0,Z.jsx)(`div`,{ref:A,className:`tw-scroll-x flex-1 min-h-0 overflow-auto`,children:(0,Z.jsxs)(`table`,{className:`tw-data-table tw-sticky-table w-full table-fixed text-left text-sm`,style:k.tableStyle,children:[(0,Z.jsx)(`colgroup`,{children:pt.map(e=>(0,Z.jsx)(`col`,{style:k.widthOf(e.key)?{width:k.widthOf(e.key)}:void 0},e.key))}),(0,Z.jsx)(`thead`,{className:`bg-stone-50 text-xs text-stone-500`,children:(0,Z.jsxs)(`tr`,{children:[(0,Z.jsxs)(`th`,{className:`${Ye} relative`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:I,disabled:s||P.length===0,onChange:e=>{let t=e.target.checked;f(e=>{let n={...e};for(let e of P)t?n[e.id]=!0:delete n[e.id];return n})},"aria-label":`全选本页备份`}),(0,Z.jsx)(Y,{...k.resizeProps(`select`)})]}),(0,Z.jsxs)(`th`,{className:tt,style:{"--tw-sticky-left":`${ut}px`},children:[`文件名`,(0,Z.jsx)(Y,{...k.resizeProps(`name`)})]}),(0,Z.jsxs)(`th`,{className:`relative px-3 py-2 font-medium whitespace-nowrap`,children:[`类型`,(0,Z.jsx)(Y,{...k.resizeProps(`kind`)})]}),(0,Z.jsxs)(`th`,{className:`relative px-3 py-2 font-medium whitespace-nowrap`,children:[`备份时间`,(0,Z.jsx)(Y,{...k.resizeProps(`mtime`)})]}),(0,Z.jsxs)(`th`,{className:`relative px-3 py-2 font-medium whitespace-nowrap`,children:[`大小`,(0,Z.jsx)(Y,{...k.resizeProps(`size`)})]}),(0,Z.jsx)(`th`,{"aria-hidden":`true`}),(0,Z.jsx)(`th`,{className:Xe,children:`操作`})]})}),(0,Z.jsx)(`tbody`,{children:P.map(e=>(0,Z.jsxs)(`tr`,{className:`group border-t border-stone-100 ${e.kind===`legacy`?``:`cursor-pointer`}`,onDoubleClick:()=>{e.kind===`legacy`||s||se(e)},children:[(0,Z.jsx)(`td`,{className:et,onDoubleClick:e=>e.stopPropagation(),children:(0,Z.jsx)(`input`,{type:`checkbox`,checked:!!d[e.id],disabled:s,onChange:t=>f(n=>({...n,[e.id]:t.target.checked})),"aria-label":`选择 ${e.name}`})}),(0,Z.jsx)(`td`,{className:`${et} min-w-0 max-w-0`,style:{"--tw-sticky-left":`${ut}px`},children:(0,Z.jsxs)(`div`,{className:`inline-flex min-w-0 max-w-full items-center`,children:[(0,Z.jsx)(v,{text:e.name,className:`min-w-0 truncate font-medium text-stone-800`}),e.kind===`legacy`?null:(0,Z.jsx)(`span`,{className:`ml-0.5 mr-1 flex shrink-0 items-center opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100`,onDoubleClick:e=>e.stopPropagation(),children:(0,Z.jsx)(`button`,{type:`button`,disabled:s,"aria-label":`重命名 ${e.name}`,onClick:()=>ce(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,Z.jsx)(x,{name:`pencil`,size:12})})})]})}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 text-xs text-stone-600 whitespace-nowrap`,children:ht(e.kind)}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 text-xs text-stone-600 whitespace-nowrap`,children:gt(e.mtime)}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 text-xs text-stone-600 whitespace-nowrap tabular-nums`,children:_t(e.size)}),(0,Z.jsx)(`td`,{"aria-hidden":`true`}),(0,Z.jsx)(`td`,{className:Qe,onDoubleClick:e=>e.stopPropagation(),children:(0,Z.jsx)(`div`,{className:`flex items-center justify-center gap-1.5 whitespace-nowrap`,children:(0,Z.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>m({kind:`one`,row:e}),className:`h-7 px-2 text-xs font-medium text-red-600 rounded-md hover:bg-red-50 disabled:opacity-40`,children:`删除`})})})]},e.id))})]})}),r.length>0?(0,Z.jsx)(_,{page:N,totalPages:M,pageSize:O,busy:s||a,className:`shrink-0 !px-4 !py-2`,onPage:D,onPageSize:e=>{ee(e),D(1)}}):null]})]}),(0,Z.jsx)(h,{open:!!p,title:p?.kind===`batch`?`批量删除备份`:`删除备份`,message:ue,confirmLabel:`删除`,danger:!0,onClose:()=>m(null),onConfirm:()=>void oe()}),(0,Z.jsx)(nt,{open:y!=null,title:`重命名备份`,label:`文件名称`,placeholder:`请输入文件名`,initialValue:y?.name??``,lockExtension:!0,confirmLabel:`保存`,cancelLabel:`取消`,error:C,onClose:()=>{s||(S(null),w(``))},onConfirm:e=>void le(e)})]})}async function bt(e){let t=[...pe(e.outline??[]).entries()].sort((e,t)=>e[1]-t[1]).map(([e])=>e),n=new Map((e.stories??[]).map(e=>[e.id.toUpperCase(),e.sourceRefs??[]])),r=[];if(e.sourcePath)try{let t=await xt(e.sourcePath);r=fe(t)}catch{r=[]}return{outlineOrder:t,testPointIds:e.testPoints?.points?.map(e=>e.id)??void 0,idealOrder:r,storySourceRefs:n}}async function xt(t){let n=t.toLowerCase();if(n.endsWith(`.xlsx`)||n.endsWith(`.xls`)){let e=await N(`requirements`,t);if(e.encoding!==`base64`||!e.contentBase64)throw Error(`无法读取 Excel`);let n=await se(()=>import(`./case-fields.CmePqYfh.js`).then(e=>e.d),__vite__mapDeps([0,1])),r=n.read(e.contentBase64,{type:`base64`,cellDates:!0}),i=[];for(let e of r.SheetNames){let t=r.Sheets[e];if(!t)continue;let a=n.utils.sheet_to_csv(t,{blankrows:!1}).trim();a&&i.push(`## 工作表:${e}\n${a}`)}return i.join(`
3
3
 
4
4
  `).trim()}if(n.endsWith(`.docx`)){let n=await N(`requirements`,t);if(n.encoding!==`base64`||!n.contentBase64)throw Error(`无法读取 docx`);let r=atob(n.contentBase64),i=new Uint8Array(r.length);for(let e=0;e<r.length;e+=1)i[e]=r.charCodeAt(e);return((await(await se(()=>import(`./lib.S37S0T6S.js`).then(t=>e(t.default,1)),__vite__mapDeps([2,1,3]))).extractRawText({arrayBuffer:i.buffer})).value??``).trim()}return(await I(`requirements`,t)).content}async function St(){try{return await de()}catch{return[]}}function Ct(e,t){let n=A(t).no;return n?e.map((e,t)=>({...e,[n]:String(t+1)})):e}async function wt(e,t={}){let n=await oe(e),r=O(n.rows,n.headers,{outlineOrder:t.outlineOrder,testPointIds:t.testPointIds,idealOrder:t.idealOrder,storySourceRefs:t.storySourceRefs}),i=r.filter((e,t)=>e!==n.rows[t]).length,a=Ct(r,n.headers),o=A(n.headers),s=o.no,c=o.title,l=o.reqCite,u=a.slice(0,5).map(e=>({no:s?String(e[s]??``):``,title:c?String(e[c]??``):``,cite:l?String(e[l]??``):``}));return{casePath:e,headers:n.headers,rows:a,moved:i,total:a.length,preview:u}}async function Tt(e){let t=await Ge(e.casePath);return{backup:(await Re(e.casePath,e.headers,e.rows)).backup||t.backup}}var Et=`__none__`;function Dt({open:e,casePath:t,fileName:n,onClose:r,onDone:i,onError:a}){let[o,s]=(0,X.useState)([]),[c,l]=(0,X.useState)(Et),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(!1),[v,b]=(0,X.useState)(!1),[x,S]=(0,X.useState)(``);(0,X.useEffect)(()=>{if(!e)return;let t=!0;return l(Et),h(null),S(``),b(!1),(async()=>{try{let e=await St();if(!t)return;s(e)}catch{t&&s([])}})(),()=>{t=!1}},[e]);let C=(0,X.useCallback)(async()=>{if(c===Et)return{};let e=o.find(e=>e.id===c);if(!e)return{};try{return await bt(e)}catch{return{outlineOrder:void 0,testPointIds:e.testPoints?.points?.map(e=>e.id)}}},[c,o]);(0,X.useEffect)(()=>{if(!e||!t)return;let n=!0;return _(!0),S(``),(async()=>{try{let e=await wt(t,await C());n&&h(e)}catch(e){if(!n)return;h(null),S(e instanceof Error?e.message:String(e))}finally{n&&_(!1)}})(),()=>{n=!1}},[e,t,C]);let w=(0,X.useMemo)(()=>[{value:Et,label:`仅按引用编号(RO / TP)`,muted:!0},...o.map(e=>({value:e.id,label:e.title||e.sourceTitle||e.id,secondary:e.sourcePath}))],[o]);async function T(){if(m&&!v){if(m.moved===0)i(`用例顺序已是最终顺序,文件未改动`),r();else{b(!0),S(``);try{await Tt(m),i(`已重排 ${m.total} 条用例(移动 ${m.moved} 行),原文件已备份到「备份列表」`),r()}catch(e){let t=e instanceof Error?e.message:String(e);S(t),a(`重排失败:${t}`)}finally{b(!1)}}}}return(0,Z.jsxs)(f,{open:e,onClose:()=>v?void 0:r(),className:`relative z-110`,children:[(0,Z.jsx)(p,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,Z.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,Z.jsxs)(u,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim flex w-full max-w-lg flex-col rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,Z.jsx)(d,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:`按需求重排用例`}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-stone-500 break-all`,children:n}),(0,Z.jsxs)(`div`,{className:`mt-4`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:`需求来源`}),(0,Z.jsx)(y,{options:w,value:c,onChange:l,ariaLabel:`重排依据的需求分析记录`,className:`mt-1.5`,disabled:v}),(0,Z.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-stone-400`,children:`排序口径:需求条目(RO)→ 条目内测试点(TP)→ 原文件顺序;用例编号会按新顺序重编为 1…N。`})]}),(0,Z.jsx)(`div`,{className:`mt-4 rounded-lg border border-stone-200 bg-stone-50/60 p-3`,children:g?(0,Z.jsx)(`p`,{className:`text-xs text-stone-500`,children:`正在计算排序结果…`}):m?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`text-xs text-stone-600`,children:[`共 `,m.total,` 条用例,需要移动`,` `,(0,Z.jsx)(`span`,{className:`font-semibold tabular-nums`,children:m.moved}),` 行`,m.moved===0?`(已是最终顺序)`:``]}),m.preview.length?(0,Z.jsxs)(`table`,{className:`mt-2 w-full table-fixed border-collapse text-[11px]`,children:[(0,Z.jsx)(`thead`,{children:(0,Z.jsxs)(`tr`,{className:`text-stone-400`,children:[(0,Z.jsx)(`th`,{className:`w-10 pb-1 text-left font-normal`,children:`编号`}),(0,Z.jsx)(`th`,{className:`pb-1 text-left font-normal`,children:`用例标题`}),(0,Z.jsx)(`th`,{className:`w-40 pb-1 text-left font-normal`,children:`引用需求点`})]})}),(0,Z.jsx)(`tbody`,{children:m.preview.map((e,t)=>(0,Z.jsxs)(`tr`,{className:`align-top text-stone-600`,children:[(0,Z.jsx)(`td`,{className:`py-0.5 pr-2 tabular-nums`,children:e.no}),(0,Z.jsx)(`td`,{className:`truncate py-0.5 pr-2`,children:e.title}),(0,Z.jsx)(`td`,{className:`truncate py-0.5 text-stone-500`,children:e.cite})]},`${e.no}-${t}`))})]}):null]}):(0,Z.jsx)(`p`,{className:`text-xs text-stone-500`,children:`暂无可预览的行`})}),x?(0,Z.jsx)(`p`,{className:`mt-2 text-[11px] leading-relaxed text-red-600`,children:x}):null,(0,Z.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,disabled:v,onClick:r,className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg text-stone-600 hover:bg-stone-100 disabled:opacity-40 transition-colors`,children:`取消`}),(0,Z.jsx)(`button`,{type:`button`,disabled:v||g||!m,onClick:()=>void T(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:v?`重排中…`:`开始重排`})]})]})})]})}var Ot=[`all`,...Be,`ignored`],kt={blue:`text-sky-700`,purple:`text-violet-700`,green:`text-emerald-700`,amber:`text-amber-700`,yellow:`text-yellow-700`,red:`text-rose-700`,gray:`text-stone-600`,muted:`text-stone-500`},At={blue:`bg-sky-500`,purple:`bg-violet-500`,green:`bg-emerald-500`,amber:`bg-amber-500`,yellow:`bg-yellow-500`,red:`bg-rose-500`,gray:`bg-stone-400`,muted:`bg-stone-300`};function jt(e){return e>=85?`green`:e>=60?`amber`:`red`}function Mt(e){let t=Date.parse(e);if(!Number.isFinite(t))return`—`;let n=Math.max(0,Math.floor((Date.now()-t)/1e3));if(n<60)return`刚刚`;let r=Math.floor(n/60);if(r<60)return`${r} 分钟前`;let i=Math.floor(r/60);if(i<24)return`${i} 小时前`;let a=Math.floor(i/24);return a<30?`${a} 天前`:new Date(t).toLocaleDateString()}function Nt({review:e,running:t,modelReady:n,onRun:r,onStop:i,onFix:a,onFixBatch:u,onIgnore:d,onUnignore:f,autoFixedKeys:p,onExport:m}){let[h,g]=(0,X.useState)(()=>o(`caseReview.quality.filter`,[...Ot],`all`)),[_,v]=(0,X.useState)(()=>c(`caseReview.quality.search`)),[y,b]=(0,X.useState)({}),[x,S]=(0,X.useState)(!1),[C,w]=(0,X.useState)(()=>o(`caseReview.quality.worstFirst`,[`1`,`0`],`0`)===`1`),T=e=>{g(e),s(`caseReview.quality.filter`,e)},E=e=>{v(e),l(`caseReview.quality.search`,e)},D=e=>{w(e),s(`caseReview.quality.worstFirst`,e?`1`:`0`)},O=(0,X.useMemo)(()=>{let t=e?.cases??[];return p?.size?t.map(e=>{let t=K(e);return t&&p.has(t)?{...e,fixed:!0}:e}):t},[e,p]),ee=(0,X.useMemo)(()=>O.filter(e=>e.ignored).length,[O]),k=(0,X.useMemo)(()=>{let e={usable:0,revise:0,invalid:0};for(let t of O)t.ignored||(e[t.verdict]+=1);return e},[O]),A=(0,X.useMemo)(()=>{let e=_.trim().toLowerCase(),t=O.filter(t=>{if(h===`ignored`){if(!t.ignored)return!1}else if(t.ignored||h!==`all`&&t.verdict!==h)return!1;return!e||`${t.no} ${t.title}`.toLowerCase().includes(e)});return C?[...t].sort((e,t)=>e.score-t.score):t},[O,h,_,C]),j=h===`revise`||h===`invalid`,[M,te]=(0,X.useState)(()=>new Set);(0,X.useEffect)(()=>{te(new Set)},[h]);let N=(0,X.useMemo)(()=>A.filter(e=>!e.ignored&&e.verdict!==`usable`&&!e.fixed),[A]),P=(0,X.useMemo)(()=>N.filter(e=>{let t=K(e);return!!(t&&M.has(t))}),[N,M]),ne=N.length>0&&N.every(e=>{let t=K(e);return!!(t&&M.has(t))}),re=P.length?P:N,F=!j||N.length===0,I=e=>{e&&te(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[t?(0,Z.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 px-3 rounded-lg text-xs font-medium border border-rose-300 bg-rose-50 text-rose-700 hover:bg-rose-100`,children:`停止评审`}):(0,Z.jsx)(`button`,{type:`button`,onClick:r,className:`h-8 px-3 rounded-lg text-xs font-medium bg-stone-900 text-white hover:bg-stone-800`,children:e?`重新评审`:`开始评审`}),(0,Z.jsx)(`button`,{type:`button`,onClick:m,disabled:!e||t,className:`h-8 px-3 rounded-lg text-xs border border-stone-200 text-stone-700 hover:bg-stone-50 disabled:opacity-40`,children:`导出 Markdown`}),(0,Z.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:n?`规则 + 模型:语义问题与扣分原因由模型补`:`未配置模型:只跑规则判定`}),e?(0,Z.jsxs)(`span`,{className:`ml-auto flex items-center gap-2 text-[11px] text-stone-400`,children:[e.modelCovered!=null&&e.modelCovered<O.length?(0,Z.jsxs)(`span`,{className:`text-amber-700`,children:[`模型只评到 `,e.modelCovered,`/`,O.length,` 条,其余按规则分`]}):null,(0,Z.jsxs)(`span`,{children:[`上次评审:`,Mt(e.at)]})]}):null]}),e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-stone-50/60 px-3 py-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>S(e=>!e),className:`flex w-full items-center gap-2 text-left`,children:[(0,Z.jsx)(`h3`,{className:`text-xs font-semibold text-stone-700`,children:`看到结论后怎么处理`}),(0,Z.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:x?`收起`:`展开`})]}),x?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`ul`,{className:`mt-1.5 space-y-1 text-[11px] leading-relaxed text-stone-600`,children:[(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`mr-1 rounded border px-1 ${G.invalid.badge}`,children:`错误无效`}),`点这条右侧的「修改」,会带着编号、扣分原因与建议跳到工作台(用例绑定的会话,没有就新建), 让模型按建议改;跳转本身不标「已修改」。改完文件后回来,若正文相对上次评审有变,会自动标「已修改」。`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`mr-1 rounded border px-1 ${G.revise.badge}`,children:`待修改`}),`不影响执行,按建议补齐边界 / 异常 / 前置条件即可;改完回来自动识别,或批量改完再整体重评一次。`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`mr-1 rounded border border-stone-200 px-1 text-stone-600`,children:`忽略`}),`这条不再参与后续评审与「待修改」统计;点「忽略」后可在「忽略」筛选里「取消忽略」。`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`mr-1 rounded border border-stone-200 px-1 text-stone-600`,children:`批量修改`}),`切到「错误无效 / 待修改」,可勾选后点「批量修改」;未勾选时对本筛选下全部可改条生效。跳转不标已修改。`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`mr-1 rounded border px-1 ${G.usable.badge}`,children:`可用`}),`可直接执行或入库;这里只读,不会自动改你的用例文件。`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`mr-1 rounded border border-stone-200 px-1 text-stone-600`,children:`重新评审`}),`首次(无「已修改」)评全部未忽略条;有「已修改」时只重审这些条并按分数重判(未达可用仍为待修改 / 无效,不会因标过「已修改」就自动变可用),未改的保留上次判定;忽略的永远不送评。`]})]}),(0,Z.jsx)(`p`,{className:`mt-1.5 text-[10px] text-stone-400`,children:`改文件后报告会标「可能已过期」,重新评审即刷新;每次结果都存在「用例评审」目录里。`})]}):null]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-3 py-2.5`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] text-stone-500`,children:`总分`}),(0,Z.jsx)(`div`,{className:`text-xl font-semibold ${kt[jt(e.score)]}`,children:e.score}),(0,Z.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:e.modeled?`规则 + 模型`:`仅规则`})]}),Be.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-3 py-2.5`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] text-stone-500`,children:G[e].label}),(0,Z.jsx)(`div`,{className:`text-xl font-semibold ${kt[G[e].tone]}`,children:k[e]}),(0,Z.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:G[e].hint})]},e))]}),(0,Z.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-xs font-semibold text-stone-700`,children:`五维得分(整批平均)`}),(0,Z.jsx)(`span`,{className:`text-[10px] text-stone-400`,children:`每维 0–100 分;左侧百分比是权重,右侧数字才是这一维的得分`})]}),(0,Z.jsxs)(`div`,{className:`mt-2 mb-1 flex items-center gap-2 text-[10px] text-stone-400`,children:[(0,Z.jsx)(`span`,{className:`w-20 shrink-0`,children:`维度`}),(0,Z.jsx)(`span`,{className:`w-9 shrink-0 text-right`,children:`权重`}),(0,Z.jsx)(`span`,{className:`flex-1`}),(0,Z.jsx)(`span`,{className:`w-8 shrink-0 text-right`,children:`得分`})]}),(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.dimensions.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`w-20 shrink-0 text-[11px] text-stone-600`,children:e.label}),(0,Z.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-[11px] tabular-nums text-stone-400`,children:[e.weight,`%`]}),(0,Z.jsx)(`div`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,Z.jsx)(`div`,{className:`h-full ${At[W[e.key]?.tone??`gray`]}`,style:{width:`${e.score}%`}})}),(0,Z.jsx)(`span`,{className:`w-8 shrink-0 text-right text-[11px] tabular-nums text-stone-700`,children:e.score})]},e.key))}),(0,Z.jsxs)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-stone-400`,children:[`总分 `,e.score,` = 各维度得分 × 权重求和(不是右侧某个数字); ≥`,` `,We.usable,` 可用 · `,We.revise,`–`,We.usable-1,` 待修改 · < `,We.revise,` 错误无效。`]})]}),(0,Z.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-3`,children:[(0,Z.jsxs)(`h3`,{className:`mb-2 text-xs font-semibold text-stone-700`,children:[`量化指标`,(0,Z.jsx)(`span`,{className:`ml-1 font-normal text-stone-400`,children:`七项 + 硬伤条数`})]}),(0,Z.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:e.metrics.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg border border-stone-100 bg-stone-50/60 px-2.5 py-2`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] text-stone-500`,children:e.label}),(0,Z.jsx)(`div`,{className:`text-base font-semibold text-stone-800 tabular-nums`,children:e.text}),(0,Z.jsx)(`div`,{className:`text-[10px] leading-tight text-stone-400`,children:e.hint})]},e.key))})]}),e.summary?(0,Z.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-3`,children:[(0,Z.jsx)(`h3`,{className:`mb-1 text-xs font-semibold text-stone-700`,children:`整体结论`}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-stone-600 whitespace-pre-wrap`,children:e.summary})]}):null,(0,Z.jsx)(`div`,{className:`sticky -top-4 z-10 -mx-4 bg-white px-4 pt-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-xl border border-stone-200 bg-white px-3 py-2 shadow-sm`,children:[j?(0,Z.jsxs)(`label`,{className:`flex h-6 shrink-0 items-center gap-1.5 text-[11px] text-stone-600`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:ne,disabled:!N.length,onChange:()=>{if(ne){te(new Set);return}let e=new Set;for(let t of N){let n=K(t);n&&e.add(n)}te(e)},className:`rounded border-stone-300`}),`全选`]}):null,(0,Z.jsx)(`h3`,{className:`text-xs font-semibold text-stone-700`,children:`逐条明细`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsxs)(Pt,{active:h===`all`,onClick:()=>T(`all`),children:[`全部 `,O.length-ee]}),Be.map(e=>(0,Z.jsxs)(Pt,{active:h===e,onClick:()=>T(e),children:[G[e].label,` `,k[e]]},e)),(0,Z.jsxs)(Pt,{active:h===`ignored`,onClick:()=>T(`ignored`),children:[`忽略`,ee?` ${ee}`:``]})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>D(!C),className:`ml-auto h-6 shrink-0 rounded-md px-2 text-[11px] transition-colors ${C?`bg-stone-900 text-white`:`text-stone-500 hover:bg-stone-100`}`,children:`按分数升序`}),(0,Z.jsx)(`input`,{value:_,onChange:e=>E(e.target.value),placeholder:`搜编号 / 标题`,className:`h-7 w-40 rounded-lg border border-stone-200 px-2 text-xs outline-none focus:border-stone-400`}),(0,Z.jsxs)(`button`,{type:`button`,disabled:F,onClick:()=>u(re),className:`h-7 shrink-0 rounded-lg border border-stone-200 px-2 text-[11px] text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-40`,children:[`批量修改`,j&&P.length?` ${P.length}`:j&&N.length?` ${N.length}`:``]})]})}),(0,Z.jsx)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:(0,Z.jsxs)(`ul`,{className:`divide-y divide-stone-100`,children:[A.map((e,t)=>{let n=K(e),r=`${e.no}-${t}`,i=!e.ignored&&e.verdict!==`usable`&&!e.fixed;return(0,Z.jsx)(Ft,{item:e,open:y[r]===!0,onToggle:()=>b(e=>({...e,[r]:!e[r]})),onFix:()=>a(e),onIgnore:()=>d(e),onUnignore:()=>f(e),selectable:j&&i,checked:!!(n&&M.has(n)),onToggleSelect:n?()=>I(n):void 0},r)}),A.length?null:(0,Z.jsx)(`li`,{className:`px-3 py-8 text-center text-xs text-stone-400`,children:`没有符合条件的用例`})]})})]}):(0,Z.jsxs)(`div`,{className:`rounded-xl border border-dashed border-stone-200 px-6 py-12 text-center`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-stone-600`,children:`还没有评审结果`}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`评审按五维打分(需求覆盖 / 步骤可执行 / 预期可判定 / 数据与边界 / 规范完整), 算七项量化指标,并把每条判成「可用 / 待修改 / 错误无效」;只读不改用例。`})]})]})}function Pt({active:e,onClick:t,children:n}){return(0,Z.jsx)(`button`,{type:`button`,onClick:t,className:`h-6 rounded-md px-2 text-[11px] transition-colors ${e?`bg-stone-900 text-white`:`text-stone-500 hover:bg-stone-100`}`,children:n})}function Ft({item:e,open:t,onToggle:n,onFix:r,onIgnore:i,onUnignore:a,selectable:o,checked:s,onToggleSelect:c}){let l=G[e.verdict],u=!e.ignored&&e.verdict!==`usable`&&!e.fixed,d=Ve(e);return(0,Z.jsxs)(`li`,{className:`group px-3 py-2 ${e.fixed||e.ignored?`opacity-70`:``}`,children:[(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:n,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},className:`flex w-full items-center gap-2 text-left`,children:[o?(0,Z.jsx)(`input`,{type:`checkbox`,checked:!!s,onChange:()=>c?.(),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),className:`shrink-0 rounded border-stone-300`}):null,(0,Z.jsx)(`span`,{className:`inline-flex w-14 shrink-0 items-center justify-center rounded border px-1 py-0.5 text-[10px] leading-4 ${e.ignored?`border-stone-200 bg-stone-50 text-stone-500`:e.fixed?`border-emerald-200 bg-emerald-50 text-emerald-700`:l.badge}`,children:e.ignored?`已忽略`:e.fixed?`已修改`:l.label}),(0,Z.jsx)(`span`,{className:`w-16 shrink-0 truncate text-left text-[11px] tabular-nums leading-4 text-stone-500`,children:e.no||`—`}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-left text-xs leading-4 text-stone-800`,children:e.title||`(无标题)`}),e.ignored?(0,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a()},onKeyDown:e=>e.stopPropagation(),className:`h-5 shrink-0 rounded-md border border-stone-200 px-1.5 text-[10px] leading-none text-stone-600 opacity-0 transition-opacity hover:bg-stone-100 focus-visible:opacity-100 group-hover:opacity-100`,children:`取消忽略`}):u?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r()},onKeyDown:e=>e.stopPropagation(),className:`h-5 shrink-0 rounded-md border border-stone-200 px-1.5 text-[10px] leading-none text-stone-600 opacity-0 transition-opacity hover:bg-stone-100 focus-visible:opacity-100 group-hover:opacity-100`,children:`修改`}),(0,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),i()},onKeyDown:e=>e.stopPropagation(),className:`h-5 shrink-0 rounded-md border border-stone-200 px-1.5 text-[10px] leading-none text-stone-600 opacity-0 transition-opacity hover:bg-stone-100 focus-visible:opacity-100 group-hover:opacity-100`,children:`忽略`})]}):null]}),(0,Z.jsx)(`span`,{className:`w-7 shrink-0 text-right text-[11px] tabular-nums leading-4 text-stone-500`,children:e.score}),(0,Z.jsx)(`span`,{className:`flex h-5 w-8 shrink-0 items-center justify-center text-[10px] text-stone-400`,children:t?`收起`:`详情`})]}),t?(0,Z.jsxs)(`div`,{className:`mt-2 space-y-2 pl-1`,children:[e.hard?(0,Z.jsxs)(`p`,{className:`rounded-md border border-rose-200 bg-rose-50 px-2 py-1 text-[11px] text-rose-700`,children:[`硬伤:`,e.hard]}):null,(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Object.keys(W).map(t=>(0,Z.jsxs)(`span`,{className:`rounded-md border border-stone-100 bg-stone-50 px-2 py-0.5 text-[10px] text-stone-600`,children:[W[t].label,` `,e.dimensions[t]]},t))}),e.deductions.length?(0,Z.jsx)(`ul`,{className:`space-y-1.5`,children:e.deductions.map((e,t)=>(0,Z.jsxs)(`li`,{className:`rounded-md bg-stone-50 px-2 py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`text-[11px] text-stone-700`,children:[(0,Z.jsxs)(`span`,{className:`mr-1 font-medium text-stone-500`,children:[`[`,W[e.dimension]?.label??e.dimension,e.points?` −${e.points}`:``,`]`]}),e.reason]}),e.suggestion?(0,Z.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-emerald-700`,children:[`建议:`,e.suggestion]}):null]},t))}):d.length?(0,Z.jsx)(`ul`,{className:`space-y-1.5`,children:d.map((e,t)=>(0,Z.jsx)(`li`,{className:`rounded-md bg-stone-50 px-2 py-1.5 text-[11px] text-stone-500`,children:e},t))}):(0,Z.jsx)(`p`,{className:`text-[11px] text-stone-400`,children:`没有扣分项。`})]}):null]})}var It={blue:`border-sky-200 bg-sky-50 text-sky-700`,purple:`border-violet-200 bg-violet-50 text-violet-700`,green:`border-emerald-200 bg-emerald-50 text-emerald-700`,amber:`border-amber-200 bg-amber-50 text-amber-800`,yellow:`border-yellow-200 bg-yellow-50 text-yellow-800`,red:`border-rose-200 bg-rose-50 text-rose-700`,gray:`border-stone-200 bg-stone-50 text-stone-600`,muted:`border-stone-200 bg-white text-stone-400`};function Lt({report:e,loading:t,running:n,completing:r,modelReady:i,selected:a,onToggle:o,onToggleCategory:s,onDetect:c,onStop:l,onComplete:u,onWriteback:d,onExport:f}){let p=e?.items??[],m=(0,X.useMemo)(()=>p.filter(e=>!e.added),[p]),h=p.length-m.length,g=(0,X.useMemo)(()=>U(p),[p]),[_,v]=(0,X.useState)(new Set),y=(0,X.useMemo)(()=>m.map(e=>e.id),[m]),b=(0,X.useMemo)(()=>y.filter(e=>a.has(e)).length,[y,a]),x=y.length>0&&y.every(e=>a.has(e)),S=e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(`p`,{className:`rounded-lg border border-stone-200 bg-stone-50/60 px-3 py-2 text-[11px] leading-relaxed text-stone-500`,children:`用途:找出「需求里有、用例里没有」的场景(非功能、安全边界、兼容性、隐藏业务规则), 不是挑现有用例的毛病,而是补漏。流程:① 探测盲区 → ② 勾选要补的条目 → ③「补全选中」写全前置 / 步骤 / 预期 → ④「去工作台写回」跳到绑定会话,按归属需求插到对应分组最后一行之后(写前备份,不动原有行;对不上组才落到末尾)。写回后标「已修改」;重新探测会去掉已确认写回的场景。`}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:c,disabled:n||r,className:`h-8 px-3 rounded-lg text-xs font-medium bg-stone-900 text-white hover:bg-stone-800 disabled:opacity-50`,children:n?`探测中…`:e?`重新探测`:`探测盲区`}),n?(0,Z.jsx)(`button`,{type:`button`,onClick:l,className:`h-8 px-3 rounded-lg text-xs border border-rose-200 text-rose-600 hover:bg-rose-50`,children:`停止`}):null,(0,Z.jsx)(`button`,{type:`button`,onClick:u,disabled:!b||r||n,className:`h-8 px-3 rounded-lg text-xs border border-stone-200 text-stone-700 hover:bg-stone-50 disabled:opacity-40`,children:r?`补全中…`:`补全选中 ${b||``}`}),(0,Z.jsx)(`button`,{type:`button`,onClick:d,disabled:!b||n||t,className:`h-8 px-3 rounded-lg text-xs font-medium border border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 disabled:opacity-40`,children:`去工作台写回 ${b||``}`}),(0,Z.jsx)(`button`,{type:`button`,onClick:f,disabled:!e,className:`h-8 px-3 rounded-lg text-xs border border-stone-200 text-stone-700 hover:bg-stone-50 disabled:opacity-40`,children:`导出 Markdown`}),(0,Z.jsx)(`span`,{className:`ml-auto text-[11px] text-stone-400`,children:m.length?`已选 ${b} / 共 ${m.length}${h?` · 已修改 ${h}`:``}`:h?`已修改 ${h}`:``}),(0,Z.jsx)(`button`,{type:`button`,disabled:!y.length,onClick:()=>s(y,!x),className:`h-6 shrink-0 rounded-md px-2 text-[11px] text-stone-500 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:x?`清空`:`全选`})]}),i?null:(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-800`,children:`场景探测要靠模型推理,先在设置里配好模型。`}),t?(0,Z.jsx)(`p`,{className:`py-8 text-center text-xs text-stone-400`,children:`读取中…`}):!e||!e.items.length&&!n?(0,Z.jsxs)(`div`,{className:`rounded-xl border border-dashed border-stone-200 px-6 py-12 text-center`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-stone-600`,children:`还没有探测结果`}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`会从非功能、安全边界、兼容性与隐藏业务规则四个方向找现有用例的缺口。`})]}):(0,Z.jsxs)(Z.Fragment,{children:[e.summary?(0,Z.jsx)(`p`,{className:`rounded-lg border border-stone-200 bg-white px-3 py-2 text-xs leading-relaxed text-stone-600 whitespace-pre-wrap`,children:e.summary}):null,g.map(e=>{let t=J[e.key],n=e.items.filter(e=>!e.added).map(e=>e.id),r=n.length>0&&n.every(e=>a.has(e)),i=_.has(e.key),c=n.filter(e=>a.has(e)).length,l=e.items.filter(e=>e.added).length;return(0,Z.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,Z.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-stone-100 px-3 py-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>S(e.key),className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,Z.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] ${It[t.tone]}`,children:t.mark}),(0,Z.jsx)(`h3`,{className:`text-xs font-semibold text-stone-700`,children:t.label}),(0,Z.jsxs)(`span`,{className:`text-[11px] text-stone-400`,children:[e.items.length,` 条`,c?` · 已选 ${c}`:``,l?` · 已修改 ${l}`:``]}),(0,Z.jsx)(`span`,{className:`ml-auto text-[10px] text-stone-400`,children:i?`展开`:`收起`})]}),n.length?(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(n,!r),className:`h-6 shrink-0 rounded-md px-2 text-[11px] text-stone-500 transition-colors hover:bg-stone-100`,children:r?`取消本类`:`全选本类`}):null]}),i?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`px-3 pt-2 text-[11px] text-stone-400`,children:t.hint}),(0,Z.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:e.items.map(e=>(0,Z.jsx)(Rt,{item:e,checked:a.has(e.id),onToggle:()=>o(e.id)},e.id))})]})]},e.key)})]}),b?(0,Z.jsxs)(`p`,{className:`sticky bottom-0 rounded-lg border border-stone-200 bg-white/95 px-3 py-2 text-[11px] text-stone-500 shadow-sm backdrop-blur`,children:[`已选 `,b,` 条:可以先「补全选中」把字段写全,也可以直接「去工作台写回」—— 会按归属需求插到对应分组下面(不是整份追加到末尾),写前自动备份。`]}):null]})}function Rt({item:e,checked:t,onToggle:n}){let[r,i]=(0,X.useState)(!1),a=q[e.severity],o=e.added;return(0,Z.jsxs)(`li`,{className:`px-3 py-2 ${o?`opacity-70`:``}`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:t&&!o,disabled:o,onChange:n,className:`mt-1 h-3.5 w-3.5 shrink-0 accent-stone-900 disabled:opacity-40`,"aria-label":`选择 ${e.title}`}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex-1 min-w-0 text-left`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 rounded border px-1 py-0.5 text-[10px] ${It[a.tone]}`,children:a.label}),o?(0,Z.jsx)(`span`,{className:`shrink-0 rounded border border-emerald-200 bg-emerald-50 px-1 py-0.5 text-[10px] text-emerald-700`,children:`已修改`}):null,(0,Z.jsx)(`span`,{className:`flex-1 min-w-0 text-xs text-stone-800`,children:e.title}),(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px] text-stone-400`,children:e.priority})]}),e.reqAnchor?(0,Z.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-stone-400`,children:[`归属:`,e.reqAnchor]}):null,e.why?(0,Z.jsxs)(`p`,{className:`mt-0.5 text-[11px] leading-relaxed text-stone-500`,children:[`容易漏:`,e.why]}):null]})]}),r?(0,Z.jsxs)(`dl`,{className:`mt-2 space-y-1 rounded-md bg-stone-50 px-2 py-1.5 text-[11px] text-stone-600`,children:[(0,Z.jsx)(zt,{label:`归属需求`,value:e.reqAnchor}),(0,Z.jsx)(zt,{label:`前置条件`,value:e.precondition}),(0,Z.jsx)(zt,{label:`步骤`,value:e.steps.map((e,t)=>`${t+1}. ${e}`).join(` `)}),(0,Z.jsx)(zt,{label:`预期`,value:e.expected})]}):null]})}function zt({label:e,value:t}){return t?(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(`dt`,{className:`w-14 shrink-0 text-stone-400`,children:e}),(0,Z.jsx)(`dd`,{className:`flex-1 whitespace-pre-wrap`,children:t})]}):null}var Bt=[`module`,`type`,`priority`],Vt=[{key:`no`,width:84,min:72},{key:`title`,width:168,min:120},{key:`steps`,width:200,min:150},{key:`expected`,width:192,min:150},{key:`verdict`,width:112,min:104},{key:`suggestions`,width:220,min:200},{key:`filler`,filler:!0}],Ht=new Set([`no`,`title`,`filler`]),Ut=[{key:`steps`,label:`测试步骤`},{key:`expected`,label:`预期结果`},{key:`verdict`,label:`规则判定`},{key:`suggestions`,label:`修改建议`}],Wt=`case-review.fields`,Gt=`lh:case-review:cols:v1`;function Kt(e){return e.replace(/\.[A-Za-z0-9]+$/,``).trim().toLowerCase()}function qt({file:e,audit:t,review:n,fileName:r,autoFixedKeys:i}){let a=(0,X.useMemo)(()=>e?.rows??[],[e]),[u,d]=(0,X.useState)(()=>o(`caseReview.table.filter`,[`all`,...Be],`all`)),[f,p]=(0,X.useState)(()=>c(`caseReview.table.search`)),m=e=>{d(e),s(`caseReview.table.filter`,e)},h=e=>{p(e),l(`caseReview.table.search`,e)},g=C(Wt,Ut,Ht),_=(0,X.useMemo)(()=>S(Vt,g.isVisible),[g.isVisible]),y=$e(Gt,_),b=Ze(`case-review`),x=(0,X.useMemo)(()=>A(e?.headers??[]),[e]),T=(0,X.useMemo)(()=>{let e=new Map,r=new Map;for(let t of n?.cases??[]){let n=K(t),a=n&&i?.has(n)&&!t.fixed?{...t,fixed:!0}:t;a.no&&e.set(a.no.trim(),a),a.title&&r.set(a.title.trim(),a)}return a.map((n,i)=>{let a=String(n[x.no??j.no]??``).trim(),o=String(n[x.title??j.title]??``).trim();return(a?e.get(a):void 0)??(o?r.get(o):void 0)??t?.cases[i]??null})},[a,x,n,t,i]),E=(0,X.useMemo)(()=>{let e={usable:0,revise:0,invalid:0};for(let t of T)t&&(e[t.verdict]+=1);return e},[T]),D=(0,X.useMemo)(()=>a.map((e,t)=>{let n=T[t],i=t=>String(e[x[t]??j[t]]??``),a=r?Kt(r):``,o=Bt.map(i).map(e=>e.trim()).filter(e=>!!e&&(!a||Kt(e)!==a)).join(` · `);return{key:t,no:i(`no`),title:i(`title`),meta:o,steps:i(`steps`),expected:i(`expected`),verdict:n,suggestions:n?Ve(n):[]}}),[a,x,T,r]),O=(0,X.useMemo)(()=>{let e=f.trim().toLowerCase();return D.filter(t=>u!==`all`&&t.verdict?.verdict!==u?!1:!e||`${t.no} ${t.title}`.toLowerCase().includes(e))},[D,u,f]);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,style:{height:`calc(100vh - 9rem)`},children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:e?`${a.length} 条 · ${e.ext}`:`未读到用例文件`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsxs)(Jt,{active:u===`all`,onClick:()=>m(`all`),children:[`全部 `,D.length]}),Be.map(e=>(0,Z.jsxs)(Jt,{active:u===e,onClick:()=>m(e),children:[G[e].label,` `,E[e]]},e))]}),(0,Z.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{value:f,onChange:e=>h(e.target.value),placeholder:`搜编号 / 标题`,className:`h-7 w-40 rounded-lg border border-stone-200 px-2 text-xs outline-none focus:border-stone-400`}),(0,Z.jsx)(w,{fields:g.fields,isVisible:g.isVisible,onToggle:g.toggle})]})]}),(0,Z.jsxs)(`p`,{className:`shrink-0 text-[11px] text-stone-400`,children:[n?`只读对照:判定与「质量评审」一致;要改用例回「用例管理」,或在质量评审里点「修改」跳工作台。`:`只读对照:还没评审,先用规则体检结果;要改用例回「用例管理」。`,(0,Z.jsx)(`span`,{className:`ml-1 text-stone-300`,children:`拖动表头右边缘可调列宽,双击恢复默认。`})]}),a.length?(0,Z.jsx)(`div`,{ref:b,className:`tw-scroll-x min-h-0 flex-1 overflow-auto rounded-xl border border-stone-200 bg-white`,children:(0,Z.jsxs)(`table`,{className:`tw-sticky-table table-fixed text-left text-xs`,style:y.tableStyle,children:[(0,Z.jsx)(`colgroup`,{children:_.map(e=>(0,Z.jsx)(`col`,{style:y.widthOf(e.key)?{width:y.widthOf(e.key)}:void 0},e.key))}),(0,Z.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-[11px] text-stone-500`,children:(0,Z.jsxs)(`tr`,{children:[(0,Z.jsxs)(`th`,{className:tt,children:[`用例编号`,(0,Z.jsx)(Y,{...y.resizeProps(`no`)})]}),(0,Z.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium`,children:[`用例标题`,(0,Z.jsx)(Y,{...y.resizeProps(`title`)})]}),g.isVisible(`steps`)?(0,Z.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium`,children:[`测试步骤`,(0,Z.jsx)(Y,{...y.resizeProps(`steps`)})]}):null,g.isVisible(`expected`)?(0,Z.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium`,children:[`预期结果`,(0,Z.jsx)(Y,{...y.resizeProps(`expected`)})]}):null,g.isVisible(`verdict`)?(0,Z.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium whitespace-nowrap`,children:[`规则判定`,(0,Z.jsx)(Y,{...y.resizeProps(`verdict`)})]}):null,g.isVisible(`suggestions`)?(0,Z.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium`,children:[`修改建议`,(0,Z.jsx)(Y,{...y.resizeProps(`suggestions`)})]}):null,(0,Z.jsx)(`th`,{"aria-hidden":`true`})]})}),(0,Z.jsxs)(`tbody`,{children:[O.map(e=>{let t=e.verdict;return(0,Z.jsxs)(`tr`,{className:`align-top`,children:[(0,Z.jsx)(`td`,{className:`${et} tabular-nums text-stone-600`,children:(0,Z.jsx)(v,{text:e.no||`—`,className:`block truncate`})}),(0,Z.jsxs)(`td`,{className:`px-2.5 py-1.5`,children:[(0,Z.jsx)(v,{text:e.title||`(无标题)`,className:`block truncate text-stone-800`}),e.meta?(0,Z.jsx)(`div`,{className:`mt-0.5 truncate text-[10px] text-stone-400`,children:e.meta}):null]}),g.isVisible(`steps`)?(0,Z.jsx)(`td`,{className:`px-2.5 py-1.5 text-stone-700`,children:(0,Z.jsx)(v,{text:e.steps,clamp:`y`,className:`line-clamp-2 whitespace-pre-wrap break-words`})}):null,g.isVisible(`expected`)?(0,Z.jsx)(`td`,{className:`px-2.5 py-1.5 text-stone-700`,children:(0,Z.jsx)(v,{text:e.expected,clamp:`y`,className:`line-clamp-2 whitespace-pre-wrap break-words`})}):null,g.isVisible(`verdict`)?(0,Z.jsx)(`td`,{className:`px-2.5 py-1.5`,children:t?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[t.fixed?(0,Z.jsxs)(`span`,{className:`rounded border border-emerald-200 bg-emerald-50 px-1.5 py-0.5 text-[10px] text-emerald-700`,children:[`已修改 `,t.score]}):(0,Z.jsxs)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] ${G[t.verdict].badge}`,children:[G[t.verdict].label,` `,t.score]}),t.hard&&!t.fixed?(0,Z.jsx)(`span`,{className:`rounded border border-rose-200 bg-white px-1 py-0.5 text-[10px] text-rose-600`,children:`硬伤`}):null]}):(0,Z.jsx)(`span`,{className:`text-[10px] text-stone-300`,children:`—`})}):null,g.isVisible(`suggestions`)?(0,Z.jsx)(`td`,{className:`px-2.5 py-1.5`,children:e.suggestions.length?(0,Z.jsx)(v,{text:e.suggestions.map((e,t)=>`${t+1}. ${e}`).join(`
5
5
  `),clamp:`y`,className:`line-clamp-2 whitespace-pre-wrap break-words text-[11px] text-stone-600`}):(0,Z.jsx)(`span`,{className:`text-[10px] text-stone-300`,children:`—`})}):null,(0,Z.jsx)(`td`,{"aria-hidden":`true`})]},e.key)}),O.length?null:(0,Z.jsx)(`tr`,{children:(0,Z.jsx)(`td`,{colSpan:_.length,className:`px-3 py-10 text-center text-xs text-stone-400`,children:`没有符合条件的用例`})})]})]})}):(0,Z.jsx)(`p`,{className:`rounded-xl border border-dashed border-stone-200 px-6 py-12 text-center text-xs text-stone-400`,children:`没解析到用例行:确认第一行是表头,且有编号与标题列(也认「测试项目 / 用例名称」这类叫法)。支持 md 表格、csv、xlsx。`})]})}function Jt({active:e,onClick:t,children:n}){return(0,Z.jsx)(`button`,{type:`button`,onClick:t,className:`h-6 rounded-md px-2 text-[11px] transition-colors ${e?`bg-stone-900 text-white`:`text-stone-500 hover:bg-stone-100`}`,children:n})}var Yt=`可用工具(只调用这些,不要自己编工具名):