@testver/testver 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/testver.js +8 -1
- package/dist/index.js +1414 -793
- package/dist/py-agent/__pycache__/testver_appium.cpython-313.pyc +0 -0
- package/package.json +7 -6
- package/src/ui/static/assets/AIPanel-D09Ni3a4.js +32 -0
- package/src/ui/static/assets/AIRecordPanel-DZtUZnRe.js +40 -0
- package/src/ui/static/assets/AIStreamUI-BsxKziYG.js +9 -0
- package/src/ui/static/assets/AITestGenPage-Cg21-P1W.js +5 -0
- package/src/ui/static/assets/APITestingPage-Cdc8EZz2.js +19 -0
- package/src/ui/static/assets/AboutPage-yJLCr2_q.js +1 -0
- package/src/ui/static/assets/AdvancedPage-DB-6sJ6s.js +3 -0
- package/src/ui/static/assets/AnalyticsPage-gTPFsiLZ.js +1 -0
- package/src/ui/static/assets/AuditLogPage-DE45E_PV.js +1 -0
- package/src/ui/static/assets/ChangesSummary-C-7oi_sx.js +2 -0
- package/src/ui/static/assets/CodeMapPage-DgU6ZYBO.js +3 -0
- package/src/ui/static/assets/ConfirmDialog-DNU3qoAP.js +1 -0
- package/src/ui/static/assets/CoveragePage-BpTjgcdV.js +2 -0
- package/src/ui/static/assets/CronBuilder-DsnX-vRr.js +1 -0
- package/src/ui/static/assets/Dashboard-DRWbVyTb.js +1 -0
- package/src/ui/static/assets/DefectsPage-BtMNbq6Z.js +72 -0
- package/src/ui/static/assets/DiffViewer-DPglzjPH.js +2 -0
- package/src/ui/static/assets/EmptyState-BH_aDO0P.js +1 -0
- package/src/ui/static/assets/ExportButton-Ce_MxnM1.js +1 -0
- package/src/ui/static/assets/FileViewer-iYL0lxyY.js +18 -0
- package/src/ui/static/assets/GitPage-CQqV8JBC.js +12 -0
- package/src/ui/static/assets/ImportExportPage-DXk7Koaq.js +36 -0
- package/src/ui/static/assets/JiraPushDialog-CqftoLh8.js +1 -0
- package/src/ui/static/assets/LiveExecutionView-BD0wE8sz.js +1 -0
- package/src/ui/static/assets/ManagePage-B8iG6Q0B.js +1 -0
- package/src/ui/static/assets/MediaModal-DiSINwmh.js +1 -0
- package/src/ui/static/assets/MobileRunPicker-BNs2lZFf.js +1 -0
- package/src/ui/static/assets/MobileRunTarget-D2Nqcj10.js +6 -0
- package/src/ui/static/assets/ModuleExplorer-BmkoQrHb.js +1 -0
- package/src/ui/static/assets/OutputPage-Dcsr7cmr.js +1 -0
- package/src/ui/static/assets/PipelinesPanel-CMMXCSda.js +1 -0
- package/src/ui/static/assets/ProfilePage-ByshrcwC.js +1 -0
- package/src/ui/static/assets/ProjectExplorer-B9B___ij.js +1 -0
- package/src/ui/static/assets/RemoteFileStrip-DbPnaZ-v.js +1 -0
- package/src/ui/static/assets/ReportCard-BbNfk85h.js +2 -0
- package/src/ui/static/assets/ReportFullView-Cg1rggho.js +1 -0
- package/src/ui/static/assets/ReportsPage-CFv3OAhe.js +48 -0
- package/src/ui/static/assets/ResultsPage-B4LwZH-R.js +115 -0
- package/src/ui/static/assets/RunTargets-C7Vqd4TU.js +1 -0
- package/src/ui/static/assets/ScriptMappingPage-BrANeHv0.js +1 -0
- package/src/ui/static/assets/SearchableDevicePicker-CFJ_DUAA.js +1 -0
- package/src/ui/static/assets/SettingsPage-BwOiebKG.js +83 -0
- package/src/ui/static/assets/SharedReportView-BAbW1WOs.js +1 -0
- package/src/ui/static/assets/SourcesPage-C_QVQwiA.js +14 -0
- package/src/ui/static/assets/TestExplorerPage-BRRWtwde.js +7 -0
- package/src/ui/static/assets/TestManagementPage-Ch4PthuU.js +10 -0
- package/src/ui/static/assets/TestPlansPage-Bno2vpGd.js +5 -0
- package/src/ui/static/assets/TestverCreditsDetail-cSW0SpNx.js +1 -0
- package/src/ui/static/assets/TestverCreditsRing-CUsMGEe3.js +1 -0
- package/src/ui/static/assets/UncommittedDiffViewer-B5HSURk8.js +2 -0
- package/src/ui/static/assets/UserManagementPage-BjY3ftxf.js +10 -0
- package/src/ui/static/assets/WorkflowsPage-BUu-LjZ8.js +83 -0
- package/src/ui/static/assets/aiHandoff-vhtR29Fh.js +1 -0
- package/src/ui/static/assets/ansiToHtml-DYRzYQV1.js +1 -0
- package/src/ui/static/assets/dark-logo-DCPcGDyT.svg +1 -0
- package/src/ui/static/assets/excel-BrxuVus5.js +1 -0
- package/src/ui/static/assets/formatDate-T65-Y6Mi.js +1 -0
- package/src/ui/static/assets/formatTestName-BKd2Uqhs.js +1 -0
- package/src/ui/static/assets/hiddenLlmProviders-setxgY_B.js +1 -0
- package/src/ui/static/assets/index-B0klHYbO.css +1 -0
- package/src/ui/static/assets/index-DpQhqcHv.js +11 -0
- package/src/ui/static/assets/index-DtBWNlVD.js +47 -0
- package/src/ui/static/assets/logo-C7ltqfpq.svg +1 -0
- package/src/ui/static/assets/runSelected-WlgnZcSF.js +1 -0
- package/src/ui/static/assets/sandboxStorage-BrzaG3ny.js +1 -0
- package/src/ui/static/assets/simpleMarkdown-kWs-10D8.js +5 -0
- package/src/ui/static/assets/useChartTheme-BFz2QcND.js +1 -0
- package/src/ui/static/assets/useDebouncedValue-BsHptIvX.js +1 -0
- package/src/ui/static/assets/useFeatureFlags-DqhngqgG.js +1 -0
- package/src/ui/static/assets/useJiraConnector-TM1Rfj1s.js +1 -0
- package/src/ui/static/assets/useOwnership-eW6Egd7X.js +1 -0
- package/src/ui/static/assets/useSuites-CvtMGakZ.js +1 -0
- package/src/ui/static/assets/useTabParam-ChbOedP1.js +1 -0
- package/src/ui/static/assets/useTestExplorer-HqvURJAc.js +1 -0
- package/src/ui/static/assets/useTestLifecycle-CL7-zz0Q.js +1 -0
- package/src/ui/static/assets/useTestManagement-ZTA1_VUm.js +2 -0
- package/src/ui/static/assets/useTestResults-Bm-JyMhB.js +1 -0
- package/src/ui/static/assets/vendor-charts-DWFQlmCz.js +73 -0
- package/src/ui/static/assets/vendor-excel-BFHGVHVC.js +24 -0
- package/src/ui/static/assets/vendor-flow-BnuhLJ6X.css +1 -0
- package/src/ui/static/assets/vendor-flow-YGpC9U9I.js +23 -0
- package/src/ui/static/assets/vendor-icons-B0wLOBoh.js +1421 -0
- package/src/ui/static/assets/vendor-query-BrzmPFT3.js +1 -0
- package/src/ui/static/assets/vendor-quill-CTpA5PSA.css +7 -0
- package/src/ui/static/assets/{index-xlbWNOlh.js → vendor-quill-W-RoQfb6.js} +1 -1
- package/src/ui/static/assets/vendor-react-CTbHBddL.js +61 -0
- package/src/ui/static/assets/visibleInterval-BKsLfJZ3.js +1 -0
- package/src/ui/static/dark-logo.svg +1 -1
- package/src/ui/static/index.html +5 -2
- package/src/ui/static/logo.svg +1 -1
- package/src/ui/static/assets/dark-logo-BddlJH8z.svg +0 -1
- package/src/ui/static/assets/index-8gWK1fNb.js +0 -2250
- package/src/ui/static/assets/index-DMd4ynKJ.css +0 -7
- package/src/ui/static/assets/logo-DwQCjTm_.svg +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{r as h,b as ee,j as e}from"./vendor-react-CTbHBddL.js";import{u as te}from"./vendor-query-BrzmPFT3.js";import{gH as re,a1 as U}from"./index-DtBWNlVD.js";import{aj as se,X as ne,a3 as ae,_ as ie,aE as oe,ag as K,dk as le,a as J,ae as de,bL as ce,F as xe,v as me,K as ue,g as pe}from"./vendor-icons-B0wLOBoh.js";function he({run:t,file:s,onClose:i}){const{data:n,isLoading:l,error:r}=te({queryKey:["explore-run-file",t,s],queryFn:()=>re(t,s),staleTime:3e4});h.useEffect(()=>{const a=c=>{c.key==="Escape"&&i()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[i]);const o=/\.(md|markdown)$/i.test(s);return ee.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[80] flex items-center justify-center p-4","data-testid":"run-file-viewer",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:i}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":`Exploration ${t} — ${s}`,className:"relative w-full max-w-3xl max-h-[85vh] flex flex-col rounded-2xl border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-2xl",children:[e.jsxs("div",{className:"flex items-start gap-3 px-5 pt-4 pb-3 border-b border-gray-200 dark:border-white/5",children:[e.jsx("span",{className:"mt-0.5 rounded-lg bg-emerald-500/10 p-2 text-emerald-600 dark:text-emerald-400",children:e.jsx(se,{size:16})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100 break-all",children:s}),e.jsxs("p",{className:"text-[13px] text-gray-500 dark:text-gray-400 break-all",children:["Exploration run ",t," · read-only, credentials masked"]})]}),e.jsx("button",{type:"button",onClick:i,className:"p-1 rounded-md text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",title:"Close","aria-label":"Close",children:e.jsx(ne,{size:16})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 text-[13px]",children:[l&&e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[e.jsx(ae,{size:14,className:"animate-spin"})," Reading the file…"]}),r&&e.jsxs("p",{className:"text-red-600 dark:text-red-400",children:["This file could not be opened: ",r.message]}),n&&(o?e.jsx("div",{className:"text-gray-800 dark:text-gray-200",children:e.jsx(Y,{text:n.content})}):e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-[12px] text-gray-800 dark:text-gray-200",children:n.content}))]})]})]}),document.body)}const A=/\[\[cite\|([^|\]]*)\|([^|\]]*)\|([^|\]]*)(?:\|([^\]]*))?\]\]/g,ge=/\[\[cite\\?\|[^\]]*\]\]/g;function fe(t){return t.replace(/\\(?=[|[\]])/g,"")}function Fe(t){return t.replace(ge,fe)}function W(t){const s=t.trim().toLowerCase();return s==="observed"||s==="reported"||s==="asserted"||s==="automated"||s==="stated"?s:"stated"}function _(t,s,i){return`${W(t)}|${s.trim()||i.trim()||"source"}`}function be(t){const s=new Map;for(const i of t.matchAll(A)){const n=i[1]||"",l=(i[2]||"").trim(),r=(i[3]||"").trim(),o=_(n,l,r);s.has(o)||s.set(o,{index:s.size+1,tier:W(n),ref:l||r||"source",detail:l?r:"",kind:(i[4]||"").trim()||void 0})}return[...s.values()]}function Oe(t){return t.replace(A,"").replace(/[ \t]+([.,;:!?])/g,"$1")}function C(t){return t.kind||X[t.tier]}function De(t){const s=be(t),i=new Map(s.map(r=>[_(r.tier,r.ref,""),r])),n=t.replace(A,(r,o,a,c)=>{const p=i.get(_(o,a.trim()||c.trim(),""));return p?` [${p.index}]`:""}).replace(/[ \t]+(\[\d+\])/g," $1");if(s.length===0)return n;const l=s.map(r=>`[${r.index}] ${C(r)} · ${r.ref}${r.detail?` — ${r.detail}`:""}`);return`${n}
|
|
2
|
+
|
|
3
|
+
Sources:
|
|
4
|
+
${l.join(`
|
|
5
|
+
`)}`}const M=h.createContext(null);function Be({citations:t,children:s}){const i=`src-${h.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,n=new Map(t.map(l=>[_(l.tier,l.ref,""),l]));return e.jsx(M.Provider,{value:{map:n,listId:i},children:s})}const Q={observed:"text-emerald-600 dark:text-emerald-400 border-emerald-500/30 bg-emerald-500/10",reported:"text-rose-600 dark:text-rose-400 border-rose-500/30 bg-rose-500/10",asserted:"text-blue-600 dark:text-blue-400 border-blue-500/30 bg-blue-500/10",automated:"text-violet-600 dark:text-violet-400 border-violet-500/30 bg-violet-500/10",stated:"text-amber-600 dark:text-amber-400 border-amber-500/30 bg-amber-500/10"},ye={observed:"Observed — the app was watched doing this",reported:"Reported — a tester logged this as a defect",asserted:"Asserted — a test case says so",automated:"Automated — a test in the repository checks this",stated:"Stated — written in a document"},X={observed:"Exploration",reported:"Defect",asserted:"Test case",automated:"Automated test",stated:"Document"},ke="relative -top-[3px] mx-[3px] inline-flex items-center justify-center min-w-[14px] h-[14px] px-[3px] rounded-[4px] border text-[9px] leading-none font-semibold tabular-nums align-baseline";function je(t,s){const i=document.getElementById(t);if(!i)return;i.open=!0;const n=document.getElementById(`${t}-${s}`);n==null||n.scrollIntoView({block:"nearest",behavior:"smooth"}),n==null||n.focus({preventScroll:!0})}function we({tier:t,refId:s,detail:i,kind:n}){const l=h.useContext(M),r=l==null?void 0:l.map.get(_(t,s,i)),o=W((r==null?void 0:r.tier)??t),a=(r==null?void 0:r.ref)??(s||i||"source"),c=r?String(r.index):a,p=(r==null?void 0:r.kind)||n||X[o],b=`${p} · ${a}
|
|
6
|
+
${ye[o]}${r!=null&&r.detail||i?`
|
|
7
|
+
${(r==null?void 0:r.detail)||i}`:""}`;return e.jsx("button",{type:"button",title:b,"aria-label":`Source ${c}: ${p} ${a}`,onClick:()=>{l&&r&&je(l.listId,r.index)},className:`${ke} cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-cyan-400/60 ${Q[o]}`,children:c})}function ve(t){var l;const s=t.ref.split(" · ")[0].trim();if(!s)return null;const i=(r,o)=>({kind:"page",href:`${r}?${new URLSearchParams(o).toString()}`});if(t.kind==="Defect register")return{kind:"page",href:"/defects"};if(t.kind==="Defect"||t.tier==="reported")return i("/defects",{defectId:s});if(t.kind==="Test run")return i("/results",{runId:s});if(t.tier==="asserted")return i("/test-cases",{tcId:s});if(t.kind==="Automation library")return{kind:"page",href:"/tests"};if(t.tier==="automated"&&t.kind==="Method"){const r=/^(.+?) · (.+):(\d+)$/.exec(t.ref.trim());if(!r)return null;const o=r[1].lastIndexOf("."),a=o>0?r[1].slice(0,o):"-",c=o>0?r[1].slice(o+1):r[1];return i("/code-map",{symbol:`${r[2]}::${a}::${c}::${r[3]}`,name:c})}if(t.tier==="automated"){const r=t.ref.indexOf(" :: ");return r<0?null:i("/tests",{file:t.ref.slice(0,r),test:t.ref.slice(r+4)})}if(t.tier==="stated"&&/^SRC-/i.test(s)){const r=t.kind==="Jira ticket"?"jira":t.kind==="Requirement"?"requirement":t.kind==="Note"?"nlp":"document";return i("/sources",{tab:r,sourceId:s})}if(t.tier==="stated"&&/^REQ-/i.test(s))return i("/coverage",{tab:"requirements",reqId:s});const n=(l=/\brun ([\w.-]+)/.exec(t.detail))==null?void 0:l[1];return t.tier==="observed"&&n&&/\.(md|markdown|txt|json)$/i.test(s)?{kind:"run-file",run:n,file:s}:null}function Ne(t,s){const i=t.split(" ").map(n=>n==="Jira"?n:n.toLowerCase()).join(" ");return`${s} ${s===1?i:`${i}s`}`}function He({citations:t}){const s=h.useContext(M),[i,n]=h.useState(null);if(t.length===0)return null;const l=a=>{a.kind==="run-file"?n({run:a.run,file:a.file}):window.open(a.href,"_blank","noopener")},r=new Map;for(const a of t){const c=C(a);r.set(c,(r.get(c)??0)+1)}const o=[...r.entries()].map(([a,c])=>Ne(a,c)).join(" · ");return e.jsxs("details",{id:s==null?void 0:s.listId,className:"group mt-3.5 rounded-xl border border-black/[0.07] dark:border-white/[0.08] bg-black/[0.015] dark:bg-white/[0.02] overflow-hidden",children:[e.jsxs("summary",{className:"flex items-center gap-2 cursor-pointer select-none px-3.5 py-2.5 list-none [&::-webkit-details-marker]:hidden hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-gray-400 dark:text-gray-500 transition-transform duration-150 group-open:rotate-90 flex-shrink-0","aria-hidden":"true",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),e.jsx("span",{className:"text-[12px] font-semibold text-gray-700 dark:text-gray-300",children:"Sources"}),e.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-500",children:o})]}),e.jsx("div",{className:"border-t border-black/[0.06] dark:border-white/[0.06]",children:t.map(a=>e.jsxs("div",{id:s?`${s.listId}-${a.index}`:void 0,tabIndex:-1,className:"flex items-start gap-2.5 px-3.5 py-2.5 border-b last:border-b-0 border-black/[0.04] dark:border-white/[0.04] focus:outline-none focus:bg-cyan-500/[0.06]",children:[e.jsx("span",{className:`mt-[1px] inline-flex items-center justify-center min-w-[16px] h-[16px] px-[3px] rounded-[4px] border text-[9.5px] leading-none font-semibold tabular-nums flex-shrink-0 ${Q[a.tier]}`,children:a.index}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsxs("span",{className:"block text-[12px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-gray-700 dark:text-gray-300",children:C(a)}),a.ref!==C(a)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-400 dark:text-gray-600",children:" · "}),e.jsx("span",{className:"font-mono text-[11.5px] text-gray-800 dark:text-gray-200 break-all",children:a.ref})]})]}),a.detail&&e.jsx("span",{className:"block mt-0.5 text-[11px] leading-relaxed text-gray-500 dark:text-gray-500 break-words",children:a.detail})]}),(()=>{const c=ve(a);return c?e.jsxs("button",{type:"button",onClick:()=>l(c),title:c.kind==="run-file"?"Read this file of the exploration run":`Open ${C(a).toLowerCase()} ${a.ref.split(" · ")[0]} in a new tab`,"aria-label":`Open ${C(a)} ${a.ref}`,"data-testid":"source-open",className:"flex-shrink-0 inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] font-medium text-cyan-700 dark:text-cyan-400 hover:bg-cyan-500/10 focus:outline-none focus-visible:ring-2 focus-visible:ring-cyan-400/60",children:["Open ",e.jsx(ie,{size:11})]}):null})()]},`${a.tier}|${a.ref}`))}),i&&e.jsx(he,{run:i.run,file:i.file,onClose:()=>n(null)})]})}function Ue(t){if(!t)return null;const s=[...t.matchAll(/(?:#{1,4}\s*)?(?:\*\*)?Attempt\s+(\d+)\s*(?:of|\/)\s*(\d+)(?:\*\*)?/gi)];if(s.length===0)return null;const i=s[s.length-1],n=parseInt(i[1],10),l=parseInt(i[2],10),r=t.lastIndexOf(i[0]),o=t.slice(r);return/\*\*Test Result:?\*\*\s*:?\s*PASS/i.test(o)||/\ball\s+\d+\s+(tests?\s+)?passed/i.test(o)||/test(s)?\s+(run\s+)?pass(ed)?/i.test(o)?{current:n,total:l,status:"pass"}:/\*\*Test Result:?\*\*\s*:?\s*FAIL/i.test(o)||/test(s)?\s+(still\s+)?fail(ed|ing)?/i.test(o)||/\d+\s+fail(ed|ing|ure)/i.test(o)?{current:n,total:l,status:"fail"}:{current:n,total:l,status:"running"}}function $e(t){return t==="read_file"?e.jsx(de,{size:12,className:"text-sky-400"}):t==="write_file"||t==="edit_file"||t==="find_replace"?e.jsx(ce,{size:12,className:"text-amber-400"}):t==="run_command"||t==="run_tests"?e.jsx(J,{size:12,className:"text-emerald-400"}):t==="create_directory"||t==="list_directory"?e.jsx(xe,{size:12,className:"text-purple-400"}):t==="glob_search"||t==="grep"?e.jsx(me,{size:12,className:"text-indigo-400"}):t.startsWith("browser_")?e.jsx(ue,{size:12,className:"text-pink-400"}):e.jsx(pe,{size:12,className:"text-gray-400"})}function Ce(t){return t==="start"?"text-sky-400":t==="complete"?"text-emerald-400":t==="error"?"text-red-400":t==="denied"?"text-amber-400":"text-gray-400"}function V(t){return t==="start"?"Running":t==="complete"?"Done":t==="error"?"Failed":t==="denied"?"Denied":t}function Ee({events:t,label:s}){const i=h.useRef(null);if(h.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[t]),t.length===0)return null;const n=[],l=new Map;for(const r of t)if(r.phase==="start")l.set(r.toolName+"-"+r.id,r),n.push(r);else if(r.phase==="complete"){const o=r.toolName+"-"+r.id,a=l.get(o);if(a){const c=n.indexOf(a);c>=0&&(n[c]={...a,phase:"complete",result:r.result})}else n.push(r)}else n.push(r);return e.jsxs("div",{className:"mb-3 space-y-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx(J,{size:11,className:"text-gray-500"}),e.jsx("span",{className:"text-[10px] font-medium text-gray-500 uppercase tracking-wider",children:s||"Tool Activity"})]}),e.jsx("div",{ref:i,className:"max-h-[240px] overflow-y-auto rounded-lg bg-black/20 border border-white/5",children:n.map((r,o)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-white/[0.03] last:border-b-0 hover:bg-white/[0.02] transition-colors",children:[$e(r.toolName),e.jsxs("span",{className:"text-xs text-gray-300 font-mono truncate flex-1",children:[r.toolName,r.args&&e.jsx("span",{className:"text-gray-500 ml-1",children:r.args})]}),e.jsx("span",{className:`text-[10px] font-medium ${Ce(r.phase)}`,children:r.phase==="start"?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-sky-400 animate-pulse"}),V(r.phase)]}):V(r.phase)})]},o))})]})}function Ke({permission:t,onRespond:s}){return e.jsxs("div",{className:"mb-3 rounded-xl border border-amber-500/30 bg-amber-500/5 p-4 animate-in fade-in",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(oe,{size:16,className:"text-amber-400"}),e.jsx("span",{className:"text-sm font-semibold text-amber-300",children:"Permission Required"})]}),e.jsxs("div",{className:"mb-3",children:[e.jsxs("p",{className:"text-sm text-gray-300",children:["AI wants to execute: ",e.jsx("span",{className:"font-mono text-amber-300",children:t.toolName})]}),t.args&&e.jsx("p",{className:"text-xs text-gray-500 font-mono mt-1 truncate",children:t.args})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>s(t.permissionId,!0),className:"flex items-center gap-1.5 px-4 py-2 rounded-lg bg-emerald-500/20 text-emerald-300 text-sm font-medium hover:bg-emerald-500/30 transition-colors border border-emerald-500/20",children:[e.jsx(K,{size:14}),"Allow"]}),e.jsxs("button",{onClick:()=>s(t.permissionId,!0,!0),className:"flex items-center gap-1.5 px-4 py-2 rounded-lg bg-sky-500/20 text-sky-300 text-sm font-medium hover:bg-sky-500/30 transition-colors border border-sky-500/20",children:[e.jsx(K,{size:14}),"Always Allow"]}),e.jsxs("button",{onClick:()=>s(t.permissionId,!1),className:"flex items-center gap-1.5 px-4 py-2 rounded-lg bg-red-500/20 text-red-300 text-sm font-medium hover:bg-red-500/30 transition-colors border border-red-500/20",children:[e.jsx(le,{size:14}),"Deny"]})]})]})}const Y=h.memo(function({text:s}){var z,F,O,D,B,H;const i=[];let n=s;const l=/EMAIL_PREVIEW_START\n([\s\S]*?)EMAIL_PREVIEW_END/g;let r;for(;(r=l.exec(s))!==null;){const u=r[1]||"",d=u.match(/^To:\s*(.+)/m),y=u.match(/^CC:\s*(.+)/m),k=u.match(/^From:\s*(.+)/m),j=u.match(/^Subject:\s*(.+)/m),w=u.match(/---BODY---\n([\s\S]*?)---END_BODY---/);i.push({to:((z=d==null?void 0:d[1])==null?void 0:z.trim())||"",cc:(F=y==null?void 0:y[1])==null?void 0:F.trim(),from:((O=k==null?void 0:k[1])==null?void 0:O.trim())||"",subject:((D=j==null?void 0:j[1])==null?void 0:D.trim())||"",body:((B=w==null?void 0:w[1])==null?void 0:B.trim())||""}),n=n.replace(r[0],`__EMAIL_PREVIEW_${i.length-1}__`)}const o=n.split(`
|
|
8
|
+
`),a=[];let c=!1,p="",b=[],m=[],x=0;const N=(u=!1)=>{if(b.length>0){const d=b.join(`
|
|
9
|
+
`);a.push(e.jsxs("div",{className:"my-2",children:[p&&e.jsxs("div",{className:"text-[10px] text-gray-500 bg-black/30 px-3 py-1 rounded-t-lg border border-b-0 border-white/5 font-mono flex items-center gap-2",children:[e.jsx("span",{children:p}),u&&e.jsx("span",{className:"text-[9px] text-gray-600 italic",children:"(streaming...)"})]}),e.jsx("pre",{className:`bg-black/30 border border-white/5 ${p?"rounded-b-lg":"rounded-lg"} p-3 text-xs text-gray-300 font-mono overflow-x-auto whitespace-pre-wrap max-h-[500px] overflow-y-auto`,children:d})]},x++)),b=[],p=""}},L=u=>{const d=[];return u.replace(/\[\[cite\\?\|[^\]]*\]\]/g,k=>(d.push(k.replace(/\\(?=[|[\]])/g,"")),`\0${d.length-1}\0`)).replace(/\\\|/g,"").replace(/^\|/,"").replace(/\|$/,"").split("|").map(k=>k.trim().replace(/\u0001/g,"|").replace(/\u0000(\d+)\u0000/g,(j,w)=>d[Number(w)]??""))},Z=u=>/^\|[\s:]*-{2,}[\s:]*(\|[\s:]*-{2,}[\s:]*)*\|?$/.test(u.trim()),I=()=>{if(m.length===0)return;const u=m.map(L);let d=null,y=[];m.length>=2&&Z(m[1])?(d=u[0],y=u.slice(2)):y=u,a.push(e.jsx(_e,{headers:d,rows:y},x++)),m=[]};for(const u of o){if(u.trimStart().startsWith("```")){I(),c?(c=!1,N()):(c=!0,p=u.trimStart().slice(3).trim());continue}if(c){b.push(u);continue}const d=u.trim();if(d.startsWith("|")){m.push(d);continue}if(I(),!d){a.push(e.jsx("div",{className:"h-2"},x++));continue}const y=d.match(/^__EMAIL_PREVIEW_(\d+)__$/);if(y){const $=parseInt(y[1],10),g=i[$];g&&a.push(e.jsxs("div",{className:"my-3 rounded-xl border border-blue-500/20 bg-blue-50/60 dark:bg-blue-500/5 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 bg-blue-500/10 border-b border-blue-500/10",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-blue-500 dark:text-blue-400 shrink-0",children:[e.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),e.jsx("span",{className:"text-sm font-semibold text-blue-700 dark:text-blue-300",children:"Email Preview"})]}),e.jsxs("div",{className:"px-4 py-3 space-y-1.5 border-b border-gray-200 dark:border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-gray-500 w-16 shrink-0",children:"To:"}),e.jsx("span",{className:"text-gray-800 dark:text-gray-200 font-medium",children:g.to})]}),g.cc&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-gray-500 w-16 shrink-0",children:"CC:"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:g.cc})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-gray-500 w-16 shrink-0",children:"From:"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:g.from})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-gray-500 w-16 shrink-0",children:"Subject:"}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100 font-medium",children:g.subject})]})]}),e.jsx("div",{className:"px-4 py-3 max-h-[300px] overflow-y-auto",children:e.jsx("div",{className:"text-xs text-gray-700 dark:text-gray-300 whitespace-pre-wrap leading-relaxed",children:g.body})}),e.jsx("div",{className:"px-4 py-2 bg-gray-50 dark:bg-white/[0.02] border-t border-gray-200 dark:border-white/5",children:e.jsx("span",{className:"text-[10px] text-gray-500 italic",children:"Confirm to send this email"})})]},x++));continue}const k=d.match(/((?:https?:\/\/[^\s/]+)?\/api\/documents\/download\/([^\s)\]"']+\.(?:png|svg|jpg|jpeg)))/);if(k){const $=U(k[1]),g=decodeURIComponent(k[2]||"").replace(/^\d+-/,"");a.push(e.jsxs("div",{className:"my-3 w-full max-w-[640px] rounded-xl border border-gray-200 dark:border-white/10 overflow-hidden bg-white dark:bg-black/20",children:[e.jsx("img",{src:$,alt:g,className:"w-full h-auto max-h-[500px] object-contain block",loading:"lazy"}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-t border-gray-100 dark:border-white/5 bg-gray-50 dark:bg-white/[0.02]",children:[e.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400 truncate",children:g}),e.jsxs("button",{onClick:()=>{fetch($).then(E=>E.blob()).then(E=>{const T=URL.createObjectURL(E),v=document.createElement("a");v.href=T,v.download=g,document.body.appendChild(v),v.click(),document.body.removeChild(v),URL.revokeObjectURL(T)}).catch(()=>window.open($,"_blank"))},className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-white dark:bg-white/5 border border-gray-200 dark:border-white/10 hover:bg-gray-100 dark:hover:bg-white/10 transition-colors text-xs text-gray-700 dark:text-gray-300 cursor-pointer",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Save"]})]})]},x++));continue}const j=d.match(/\[([^\]]*)\]\(((?:https?:\/\/[^)\s/]+)?\/api\/documents\/download\/([^)]+))\)/),w=j?null:d.match(/((?:https?:\/\/[^\s/]+)?\/api\/documents\/download\/(\S+))/),S=j?{url:j[2],file:j[3]}:w?{url:w[1],file:w[2]}:null;if(S){const $=U(S.url||""),g=decodeURIComponent(S.file||"document").replace(/^\d+-/,""),E=((H=g.split(".").pop())==null?void 0:H.toLowerCase())||"",v={docx:{color:"text-blue-500",label:"Word Document"},doc:{color:"text-blue-500",label:"Word Document"},pdf:{color:"text-rose-500",label:"PDF Document"},xlsx:{color:"text-emerald-500",label:"Excel Spreadsheet"},xls:{color:"text-emerald-500",label:"Excel Spreadsheet"},csv:{color:"text-gray-500",label:"CSV File"}}[E]||{color:"text-gray-500",label:"Document"};a.push(e.jsxs("a",{href:$,download:g,className:"flex items-center gap-3 p-3 my-2 rounded-xl border border-gray-200 dark:border-white/10 bg-transparent hover:bg-gray-50 dark:hover:bg-white/[0.03] transition-colors cursor-pointer no-underline group",children:[e.jsx("div",{className:"w-11 h-11 rounded-lg flex items-center justify-center shrink-0",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",className:v.color,children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-800 dark:text-gray-200 truncate",children:g}),e.jsx("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:v.label})]}),e.jsxs("div",{className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-gray-200 dark:border-white/10 group-hover:bg-gray-100 dark:group-hover:bg-white/5 transition-colors shrink-0 ${v.color}`,children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),e.jsx("span",{className:"text-xs font-medium",children:"Download"})]})]},x++));continue}if(/^[-*_]{3,}$/.test(d)){a.push(e.jsx("hr",{className:"border-white/5 my-3"},x++));continue}if(d.startsWith("#### ")){a.push(e.jsx("h5",{className:"text-[13px] font-semibold text-gray-200 mt-2.5 mb-1",children:f(d.slice(5))},x++));continue}if(d.startsWith("### ")){a.push(e.jsx("h4",{className:"text-sm font-semibold text-gray-200 mt-3 mb-1",children:f(d.slice(4))},x++));continue}if(d.startsWith("## ")){a.push(e.jsx("h3",{className:"text-base font-semibold text-gray-100 mt-4 mb-1",children:f(d.slice(3))},x++));continue}if(d.startsWith("# ")){a.push(e.jsx("h2",{className:"text-lg font-bold text-gray-100 mt-4 mb-1.5",children:f(d.slice(2))},x++));continue}const R=d.match(/^(\d+)\.\s+(.+)/);if(R){a.push(e.jsxs("div",{className:"flex gap-2 text-sm text-gray-300 leading-relaxed ml-2",children:[e.jsxs("span",{className:"text-gray-500 flex-shrink-0 w-4 text-right",children:[R[1],"."]}),e.jsx("span",{children:f(R[2])})]},x++));continue}if(d.startsWith("- ")||d.startsWith("* ")){a.push(e.jsxs("div",{className:"flex gap-2 text-sm text-gray-300 leading-relaxed ml-2",children:[e.jsx("span",{className:"text-gray-500 flex-shrink-0",children:"•"}),e.jsx("span",{children:f(d.slice(2))})]},x++));continue}if(d.startsWith("**")){a.push(e.jsx("p",{className:"text-sm text-gray-200 mt-2",children:f(d)},x++));continue}a.push(e.jsx("p",{className:"text-sm text-gray-300 leading-relaxed",children:f(d)},x++))}return c&&N(!0),I(),e.jsx("div",{className:"space-y-0.5",children:a})});function _e({headers:t,rows:s,alignNumbers:i=!1}){const n=t?t.findIndex(Te):-1,l=o=>o===n?" text-center w-px whitespace-nowrap":"",r=o=>i&&/^[-+]?[\d,]+(\.\d+)?\s*(%|ms|s)?$/.test(o.trim());return e.jsx("div",{className:"my-2.5 rounded-[10px] border border-gray-200 dark:border-[#2c2d36] overflow-hidden","data-testid":"ai-table",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse text-[13px] text-gray-700 dark:text-gray-300 tabular-nums",children:[t&&e.jsx("thead",{children:e.jsx("tr",{children:t.map((o,a)=>e.jsx("th",{className:`bg-[#f7f8fa] dark:bg-[#22232a] border-b border-gray-200 dark:border-[#2c2d36] px-3.5 py-[9px] text-left text-[11.5px] font-semibold uppercase tracking-[0.05em] text-gray-500 dark:text-gray-400 whitespace-nowrap${l(a)}`,children:f(o,!0)},a))})}),e.jsxs("tbody",{children:[s.map((o,a)=>e.jsx("tr",{className:"group/row",children:o.map((c,p)=>{var b;return e.jsx("td",{className:`px-3.5 py-2.5 align-middle border-b border-[#eef0f3] dark:border-[#25262d] group-last/row:border-b-0 group-hover/row:bg-[#f5f7fa] dark:group-hover/row:bg-[#23242b]${p===0?" font-medium text-gray-800 dark:text-gray-200":""}${(b=G(c))!=null&&b.rest?" min-w-[13rem]":Le(c)}${l(p)}${r(c)?" text-right":""}`,children:Ae(c)},p)})},a)),s.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:Math.max(1,(t==null?void 0:t.length)??1),className:"px-3.5 py-6 text-center text-gray-400 dark:text-gray-500",children:"No rows"})})]})]})})})}const P=/\[\[cite\|[^\]]*\]\]/g;function Le(t){const s=t.replace(P,"").replace(/[`*]/g,"").trim().length;return s<=18?" whitespace-nowrap":s>40?" min-w-[16rem]":""}const Ie=/^(passed|pass|failed|fail|error|skipped|blocked|flaky|open|in progress|resolved|closed|fixed|rejected)(\s*\((?:error|fixed)\))?(?:\s*[—–-]\s+([\s\S]+))?$/i,Se={passed:"ok",pass:"ok",resolved:"ok",closed:"ok",fixed:"ok",failed:"bad",fail:"bad",error:"bad",blocked:"bad",open:"bad",skipped:"warn",flaky:"warn","in progress":"warn",rejected:"neutral"},Re={bad:"text-red-700 bg-red-50 dark:text-red-400 dark:bg-red-500/[0.12]",ok:"text-emerald-700 bg-emerald-50 dark:text-emerald-400 dark:bg-emerald-500/[0.12]",warn:"text-amber-700 bg-amber-50 dark:text-amber-400 dark:bg-amber-500/[0.12]",neutral:"text-gray-600 bg-gray-100 dark:text-gray-300 dark:bg-white/[0.08]"};function G(t){const s=Ie.exec(t.replace(P,"").trim());return s?{label:`${s[1]}${s[2]??""}`.trim(),tone:Se[s[1].toLowerCase()]??"neutral",rest:(s[3]??"").trim()}:null}function Te(t){return/^sources?$/i.test((t??"").replace(/\*/g,"").trim())}function q(t){const s=t.split(/\s→\s/);return s.length===1?f(t,!0):s.map((i,n)=>e.jsxs("span",{children:[n>0&&e.jsx("span",{className:"px-1 text-[#9ca3af] dark:text-gray-500",children:"→"}),f(i,!0)]},n))}function Ae(t){const s=G(t);if(!s)return q(t);const i=(t.match(P)??[]).join(" ");return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:`inline-flex items-center gap-[5px] rounded-full px-2 py-0.5 text-[11.5px] font-semibold whitespace-nowrap ${Re[s.tone]}`,children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current","aria-hidden":"true"}),s.label]}),i&&e.jsxs(e.Fragment,{children:[" ",f(i,!0)]}),s.rest&&e.jsx("span",{className:"mt-[3px] block text-[12px] text-gray-500 dark:text-gray-400",children:q(s.rest)})]})}function f(t,s=!1){const i=t.split(/(\*\*[^*]+\*\*|`[^`]+`|\[\[cite\|[^\]]*\]\]|\*[^\s*][^*\n]*[^\s*]\*|\*[^\s*]\*)/g);return i.length===1?t:e.jsx(e.Fragment,{children:i.map((n,l)=>{if(n.startsWith("[[cite|")){const r=/^\[\[cite\|([^|\]]*)\|([^|\]]*)\|([^|\]]*)(?:\|([^\]]*))?\]\]$/.exec(n);return r?e.jsx(we,{tier:r[1]||"",refId:(r[2]||"").trim(),detail:(r[3]||"").trim(),kind:(r[4]||"").trim()||void 0},l):null}return n.startsWith("**")&&n.endsWith("**")?e.jsx("strong",{className:"font-semibold text-gray-200",children:f(n.slice(2,-2),s)},l):n.startsWith("`[[cite|")&&n.endsWith("]]`")?e.jsx("span",{children:f(n.slice(1,-1),s)},l):n.startsWith("`")&&n.endsWith("`")?e.jsx("code",{className:s?"bg-gray-100 text-gray-700 dark:bg-white/[0.08] dark:text-gray-200 px-[5px] py-px rounded text-[0.86em] font-mono whitespace-nowrap":"bg-white/5 text-amber-300 px-1 py-0.5 rounded text-xs font-mono",children:n.slice(1,-1)},l):n.length>2&&n.startsWith("*")&&n.endsWith("*")?e.jsx("em",{className:"italic",children:f(n.slice(1,-1),s)},l):e.jsx("span",{children:n},l)})})}function Ve({state:t,panelRef:s,label:i,icon:n,emptyMessage:l}){const r=h.useRef(null),o=s??r,a=h.useRef(null),c=h.useRef(!0);h.useEffect(()=>{const m=o.current;if(!m)return;const x=()=>{const N=m.scrollHeight-m.scrollTop-m.clientHeight<32;c.current=N};return m.addEventListener("scroll",x,{passive:!0}),()=>m.removeEventListener("scroll",x)},[o]);const p=h.useRef(!0);h.useEffect(()=>{const m=()=>{const x=document.scrollingElement||document.documentElement;if(!x)return;const N=x.scrollHeight-x.scrollTop-x.clientHeight<120;p.current=N};return window.addEventListener("scroll",m,{passive:!0}),()=>window.removeEventListener("scroll",m)},[]),h.useEffect(()=>{const m=o.current,x=requestAnimationFrame(()=>{m&&c.current&&(m.scrollTop=m.scrollHeight),p.current&&a.current&&a.current.scrollIntoView({block:"end",behavior:"smooth"})});return()=>cancelAnimationFrame(x)},[t.content,t.toolEvents.length,t.status,o]);const b=(()=>{if(t.status!=="streaming"||t.content)return null;const m=t.toolEvents.filter(L=>L.phase==="start");if(m.length===0)return null;const x=m[m.length-1];return{read_file:"Reading file",write_file:"Writing file",edit_file:"Editing file",find_replace:"Editing file",run_command:"Running command",run_tests:"Running tests",glob_search:"Searching files",grep:"Searching code",create_directory:"Creating directory",list_directory:"Listing directory",browser_launch:"Launching browser",browser_navigate:"Navigating",browser_click:"Clicking element",browser_type:"Typing text",browser_inspect:"Inspecting page",browser_screenshot:"Taking screenshot",browser_get_text:"Reading page text"}[x.toolName]||`Running ${x.toolName}`})();return e.jsxs(e.Fragment,{children:[t.toolEvents.length>0&&e.jsx(Ee,{events:t.toolEvents,label:i==="AI Fix"?"Analysis Activity":"Implementation Activity"}),e.jsxs("div",{ref:o,className:"bg-surface-1 rounded-lg border border-white/5 p-4 max-h-[600px] overflow-y-auto",children:[t.status==="error"&&e.jsxs("div",{className:"text-sm text-red-400",children:[e.jsxs("p",{children:["Failed: ",t.error]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"If this mentions your AI provider or connection, check Settings → LLM and verify the provider is connected."})]}),t.content?e.jsx(Y,{text:t.content}):t.status==="streaming"?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-purple-400 border-t-transparent rounded-full animate-spin"}),e.jsxs("div",{children:[e.jsx("span",{children:t.statusMessage||b||l}),t.toolEvents.length>0&&!b&&e.jsxs("span",{className:"text-gray-600 ml-1",children:["(",t.toolEvents.length," tools executed)"]})]})]}):null,t.status==="streaming"&&t.content&&e.jsx("span",{className:"inline-block w-2 h-4 bg-purple-400 animate-pulse ml-0.5 align-text-bottom"})]}),e.jsx("div",{ref:a,"aria-hidden":"true"})]})}export{Y as A,Be as C,Ke as P,He as S,Ve as a,_e as b,De as c,be as e,Ue as p,Oe as s,Fe as u};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{r as d,j as e,b as Ye,u as $a}from"./vendor-react-CTbHBddL.js";import{a as Ta,u as qs}from"./vendor-query-BrzmPFT3.js";import{J as Ia,ah as Ea,ai as Da,ab as Ma}from"./useTestManagement-ZTA1_VUm.js";import{gw as Fa,x as Ga,gx as Pa,gy as _s,D as za,gz as As,gA as La,gB as Rs,gC as Oa,gD as Ba,gE as $s}from"./index-DtBWNlVD.js";import{o as de,f as Et,r as Xe,S as Ze,X as pe,a3 as le,b4 as Ja,I as Ua,b as Ft,ar as Gt,v as Ts,dj as Ka,ak as Is,y as Dt,t as Mt,aK as Es,Z as Qa,b2 as Ds}from"./vendor-icons-B0wLOBoh.js";import{h as Ha}from"./aiHandoff-vhtR29Fh.js";import{J as Wa}from"./JiraPushDialog-CqftoLh8.js";import"./useJiraConnector-TM1Rfj1s.js";const Ms=["happy-path","negative","boundary","equivalence","error-handling","security","performance","accessibility","compatibility","integration","data-validation"],Va={"happy-path":"HP",negative:"NEG",boundary:"BND",equivalence:"EQ","error-handling":"ERR",security:"SEC",performance:"PRF",accessibility:"A11Y",compatibility:"CMP",integration:"INT","data-validation":"DV"},Ya={critical:"text-red-300 bg-red-500/10",high:"text-orange-300 bg-orange-500/10",medium:"text-amber-300 bg-amber-500/10",low:"text-gray-400 bg-gray-500/10"};function Za({requirements:C,tests:G,depth:Q}){const I=j=>j.effectiveStrategies&&j.effectiveStrategies.length>0?j.effectiveStrategies:j.applicableStrategies||[],q=Q!=="high-level",Y=d.useMemo(()=>{const j=new Map;for(const _ of G){const D=_==null?void 0:_._requirementId,R=_==null?void 0:_._strategy;if(!D)continue;j.has(D)||j.set(D,new Map);const T=j.get(D),H=R||"unknown";T.set(H,(T.get(H)||0)+1)}return j},[G]),g=d.useMemo(()=>C.map(j=>{const _=Y.get(j.id)||new Map,D=Array.from(_.values()).reduce((f,N)=>f+N,0),R=I(j),T=R.filter(f=>(_.get(f)||0)>0).length,H=R.length>0?Math.round(T/R.length*100):100,v=q?R.filter(f=>!_.get(f)):[];return{req:j,inner:_,total:D,score:H,missing:v}}),[C,Y]),E=d.useMemo(()=>{const j=g.reduce((R,T)=>R+I(T.req).filter(H=>(T.inner.get(H)||0)>0).length,0),_=g.reduce((R,T)=>R+I(T.req).length,0),D=_>0?Math.round(j/_*100):100;return{requirementCount:C.length,testCount:G.length,coverageScore:D,gappedRequirements:g.filter(R=>R.missing.length>0).length}},[g,C.length,G.length]);return C.length===0?null:e.jsxs("details",{className:"bg-surface-1 rounded-xl border border-white/5 group",open:!0,children:[e.jsxs("summary",{className:"flex items-center justify-between px-4 py-3 cursor-pointer select-none hover:bg-surface-2 rounded-xl transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Traceability Matrix"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[E.requirementCount," req · ",E.testCount," tests · ",E.coverageScore,"%"," ",q?"strategy coverage":"of strategies touched (high-level)"]}),E.gappedRequirements>0&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-amber-300 px-2 py-0.5 bg-amber-500/10 rounded",children:[e.jsx(de,{size:11}),E.gappedRequirements," req with gaps"]})]}),e.jsx("span",{className:"text-xs text-gray-500 group-open:hidden",children:"click to expand"}),e.jsx("span",{className:"text-xs text-gray-500 hidden group-open:inline",children:"click to collapse"})]}),e.jsxs("div",{className:"overflow-x-auto px-4 pb-4",children:[e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-gray-500 border-b border-white/5",children:[e.jsx("th",{className:"text-left font-medium px-2 py-2 sticky left-0 bg-surface-1 z-10",children:"Requirement"}),e.jsx("th",{className:"text-left font-medium px-2 py-2",children:"Priority"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Tests"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Coverage"}),e.jsx("th",{className:"text-left font-medium px-2 py-2",children:"Personas"}),Ms.map(j=>e.jsx("th",{className:"text-center font-medium px-1.5 py-2",title:j,children:Va[j]||j},j))]})}),e.jsx("tbody",{children:g.map(({req:j,inner:_,total:D,score:R,missing:T})=>{const H=new Set(I(j)),v=new Set((j.applicableStrategies||[]).filter(f=>!H.has(f)));return e.jsxs("tr",{className:"border-b border-white/5 hover:bg-surface-2/40",children:[e.jsxs("td",{className:"px-2 py-2 sticky left-0 bg-surface-1 z-10 max-w-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-mono text-brand-300 text-xs",children:j.id}),T.length>0&&e.jsx("span",{className:"text-amber-400",title:`Missing: ${T.join(", ")}`,children:e.jsx(de,{size:11})})]}),e.jsx("div",{className:"text-gray-300 truncate",title:j.title,children:j.title}),j.sourceTitle&&e.jsx("div",{className:"text-[10px] text-gray-600 truncate",title:j.sourceTitle,children:j.sourceTitle})]}),e.jsx("td",{className:"px-2 py-2",children:e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${Ya[j.priority]??"text-gray-400"}`,children:j.priority})}),e.jsx("td",{className:"px-2 py-2 text-right tabular-nums text-gray-300",children:D}),e.jsx("td",{className:"px-2 py-2 text-right tabular-nums",children:e.jsxs("span",{className:R>=100?"text-emerald-400":R>=75?"text-amber-300":R>=50?"text-orange-300":"text-red-400",children:[R,"%"]})}),e.jsx("td",{className:"px-2 py-2",children:(()=>{const f=j.applicablePersonas??[];if(f.length===0)return e.jsx("span",{className:"text-gray-600 text-[10px]",children:"—"});const N=new Map;for(const k of G){if((k==null?void 0:k._requirementId)!==j.id)continue;const $=k==null?void 0:k._persona;typeof $=="string"&&N.set($,(N.get($)||0)+1)}return e.jsx("div",{className:"flex flex-wrap gap-1 max-w-[200px]",children:f.map(k=>{const $=N.get(k)||0;return e.jsxs("span",{title:`${$} test${$===1?"":"s"} for ${k}`,className:`text-[10px] px-1.5 py-0.5 rounded ${$>0?"bg-emerald-500/15 text-emerald-300":"bg-gray-500/15 text-gray-400"}`,children:[k," ",$>0?`(${$})`:""]},k)})})})()}),Ms.map(f=>{const N=_.get(f)||0,k=H.has(f);if(!k&&N===0){const $=v.has(f);return e.jsx("td",{className:"px-1.5 py-2 text-center text-gray-700",title:$?`${f} applies, but high-level coverage does not attempt it — use Deepen for this requirement`:`${f} not applicable to this requirement`,children:e.jsx(Et,{size:8,className:"inline"})},f)}return k&&N===0?q?e.jsx("td",{className:"px-1.5 py-2 text-center text-red-400 font-bold",title:`${f} required but not generated`,children:"✕"},f):e.jsx("td",{className:"px-1.5 py-2 text-center text-gray-600",title:`${f} applies, but a high-level run does not cover every strategy — use Deepen on this requirement for full coverage`,children:e.jsx(Et,{size:8,className:"inline"})},f):e.jsx("td",{className:"px-1.5 py-2 text-center",children:e.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[e.jsx(Xe,{size:10,className:"text-emerald-400"}),e.jsx("span",{className:"text-gray-300 tabular-nums",children:N})]})},f)})]},j.id)})})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-3 text-[10px] text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Xe,{size:10,className:"text-emerald-400"})," covered"]}),q&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-red-400 font-bold",children:"✕"})," required but missing"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Et,{size:8,className:"text-gray-700"}),q?"not applicable":"not applicable, or not attempted at this depth"]})]})]})]})}const Fs=10;function Xa({cases:C,requirementTitle:G,onApply:Q,onClose:I}){const[q,Y]=d.useState(null),[g,E]=d.useState(new Set),[j,_]=d.useState(null),[D,R]=d.useState(0);d.useEffect(()=>{let f=!0;return(async()=>{const N=[],k=(S,W)=>String(S??"").slice(0,W);let $=null;for(let S=0;S<C.length;S+=Fs){const W=C.slice(S,S+Fs);try{const{fixed:ge}=await Fa(W.map(se=>{var fe;return{title:k(se.title,2e3),preconditions:k(se.preconditions,1e4),requirement:(fe=G(se))==null?void 0:fe.slice(0,4e3),steps:(Array.isArray(se.steps)?se.steps:[]).slice(0,40).map(J=>({action:k(J==null?void 0:J.action,5e3),expectedResult:k(J==null?void 0:J.expectedResult,5e3),testData:k(J==null?void 0:J.testData,5e3)})),issues:se._critique.slice(0,10).map(J=>({kind:k(J.kind,40),message:k(J.message,1e3),suggestion:J.suggestion?k(J.suggestion,2e3):void 0}))}}));N.push(...W.map((se,fe)=>ge[fe]??null))}catch(ge){$=(ge==null?void 0:ge.message)||"The AI could not fix some of these cases.",N.push(...W.map(()=>null))}if(!f)return;R(N.length)}f&&($&&_(`${$} Those cases are left as they are.`),Y(N),E(new Set(N.map((S,W)=>S?W:-1).filter(S=>S>=0))))})(),()=>{f=!1}},[]),d.useEffect(()=>{const f=N=>{N.key==="Escape"&&I()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[I]);const T=q?q.filter(Boolean).length:0;function H(){if(!q)return;const f=new Map;q.forEach((N,k)=>{N&&g.has(k)&&f.set(C[k],N)}),Q(f)}const v=f=>f.map((N,k)=>e.jsxs("li",{className:"leading-relaxed",children:[N.action,N.expectedResult?e.jsxs("span",{className:"text-gray-500",children:[" → ",N.expectedResult]}):null,N.testData?e.jsxs("span",{className:"text-gray-500",children:[" [",N.testData,"]"]}):null]},k));return Ye.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",role:"dialog","aria-modal":"true","aria-labelledby":"fix-cases-title",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:I}),e.jsxs("div",{className:"relative w-full max-w-4xl max-h-[88vh] flex flex-col rounded-xl bg-surface-1 border border-white/10 shadow-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 p-5 border-b border-white/5",children:[e.jsxs("div",{children:[e.jsxs("h3",{id:"fix-cases-title",className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(Ze,{className:"w-4 h-4 text-brand-300"})," Fix ",C.length," case",C.length===1?"":"s"," with AI"]}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Each case is rewritten to resolve its review notes only. Pick the changes to keep — nothing is saved until you save the cases."})]}),e.jsx("button",{onClick:I,"aria-label":"Close",className:"text-gray-500 hover:text-gray-300",children:e.jsx(pe,{size:16})})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-5 space-y-4",children:[j&&e.jsx("p",{className:"text-sm text-red-400",role:"alert",children:j}),!q&&!j&&e.jsxs("p",{className:"text-sm text-gray-400 flex items-center gap-2",role:"status",children:[e.jsx(le,{className:"w-4 h-4 animate-spin"})," Rewriting… ",D," of ",C.length]}),q==null?void 0:q.map((f,N)=>{const k=C[N];return e.jsxs("div",{className:"rounded-lg border border-white/10 bg-surface-2/40",children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 border-b border-white/5 text-sm",children:[e.jsx("input",{type:"checkbox",disabled:!f,checked:g.has(N),onChange:$=>E(S=>{const W=new Set(S);return $.target.checked?W.add(N):W.delete(N),W}),className:"mt-0.5"}),e.jsx("span",{className:"text-gray-200",children:f?f.changes||"Rewritten":"The AI returned nothing usable for this case — it stays as it is."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 p-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wider text-gray-500 mb-1",children:"Before"}),e.jsx("p",{className:"text-gray-200 font-medium",children:k.title}),e.jsx("ol",{className:"list-decimal ml-4 mt-1 text-gray-400 space-y-0.5",children:v(k.steps??[])})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wider text-gray-500 mb-1",children:"After"}),f?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-gray-100 font-medium",children:f.title}),f.preconditions&&f.preconditions!==(k.preconditions??"")&&e.jsxs("p",{className:"text-gray-400 mt-1",children:["Preconditions: ",f.preconditions]}),e.jsx("ol",{className:"list-decimal ml-4 mt-1 text-gray-300 space-y-0.5",children:v(f.steps)})]}):e.jsx("p",{className:"text-gray-500",children:"—"})]})]})]},N)})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 p-4 border-t border-white/5",children:[e.jsx("button",{onClick:I,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:"Cancel"}),e.jsxs("button",{onClick:H,disabled:!q||g.size===0,className:"px-4 py-2 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium disabled:opacity-50",children:["Use ",g.size," of ",T," fix",T===1?"":"es"]})]})]})]}),document.body)}const me={grounded:{label:"grounded",cls:"bg-emerald-500/20 text-emerald-300",title:"Every step maps to a control an exploration run observed."},partial:{label:"partly grounded",cls:"bg-amber-500/20 text-amber-300",title:"Some steps were never observed — those are the lines to check first."},ungrounded:{label:"navigation invented",cls:"bg-gray-500/20 text-gray-300",title:"No explored page backs these steps. The assertions still come from the requirement."}},ne={yes:{label:"automatable",cls:"bg-cyan-500/20 text-cyan-300"},"needs-setup":{label:"needs setup",cls:"bg-violet-500/20 text-violet-300"},manual:{label:"manual",cls:"bg-gray-500/20 text-gray-300"}},er={cyan:{active:"bg-cyan-500/20 text-cyan-200 border-cyan-400/40",idle:"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"},amber:{active:"bg-amber-500/20 text-amber-200 border-amber-400/40",idle:"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"},violet:{active:"bg-violet-500/20 text-violet-200 border-violet-400/40",idle:"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"},emerald:{active:"bg-emerald-500/20 text-emerald-200 border-emerald-400/40",idle:"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"},gray:{active:"bg-white/10 text-gray-100 border-white/25",idle:"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"}};function he({label:C,active:G,onToggle:Q,color:I="cyan"}){const q=er[I];return e.jsx("button",{type:"button","aria-pressed":G,onClick:Q,className:`text-xs px-2.5 py-1 rounded-full border transition-colors ${G?q.active:q.idle}`,children:C})}function Ve(C){return!!(C!=null&&C._dupOf||C!=null&&C._dupOfRun)}const tr=[{id:"sources",label:"From Sources",icon:e.jsx(Ft,{className:"w-4 h-4"}),description:"Generate from requirements, notes & documents"},{id:"reverse",label:"Reverse Engineer",icon:e.jsx(Gt,{className:"w-4 h-4"}),description:"Extract test cases from automation scripts"}],sr={critical:"bg-red-500/20 text-red-300",high:"bg-orange-500/20 text-orange-300",medium:"bg-amber-500/20 text-amber-300",low:"bg-emerald-500/20 text-emerald-300"},ar={functional:"bg-sky-500/20 text-sky-300",regression:"bg-violet-500/20 text-violet-300",smoke:"bg-amber-500/20 text-amber-300",integration:"bg-teal-500/20 text-teal-300",e2e:"bg-indigo-500/20 text-indigo-300",api:"bg-cyan-500/20 text-cyan-300",performance:"bg-rose-500/20 text-rose-300",security:"bg-red-500/20 text-red-300"};function Gs(C,G=0){var I;const Q=[];for(const q of C)Q.push({id:q.id,name:q.name,depth:G}),(I=q.children)!=null&&I.length&&Q.push(...Gs(q.children,G+1));return Q}function rr({tc:C,onSave:G,onCancel:Q}){const[I,q]=d.useState(C.title||""),[Y,g]=d.useState(C.priority||"medium"),[E,j]=d.useState(Array.isArray(C.preconditions)?C.preconditions.join(`
|
|
2
|
+
`):C.preconditions||""),[_,D]=d.useState((C.steps??[]).map(v=>({action:String((v==null?void 0:v.action)??(v==null?void 0:v.description)??(typeof v=="string"?v:"")),expectedResult:String((v==null?void 0:v.expectedResult)??""),testData:String((v==null?void 0:v.testData)??"")}))),R=(v,f,N)=>D(k=>k.map(($,S)=>S===v?{...$,[f]:N}:$)),T="w-full rounded-lg bg-surface-2 border border-white/10 px-3 py-2 text-sm text-gray-200 focus:outline-none focus:border-brand-500/60",H=I.trim().length>0;return e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider",children:"Title"}),e.jsx("input",{className:`${T} mt-1`,value:I,onChange:v=>q(v.target.value)})]}),e.jsxs("label",{className:"block w-48",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider",children:"Priority"}),e.jsx("select",{className:`${T} mt-1`,value:Y,onChange:v=>g(v.target.value),children:["critical","high","medium","low"].map(v=>e.jsx("option",{value:v,children:v},v))})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider",children:"Preconditions"}),e.jsx("textarea",{className:`${T} mt-1`,rows:2,value:E,onChange:v=>j(v.target.value)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider",children:"Steps"}),e.jsxs("div",{className:"space-y-2 mt-1",children:[_.map((v,f)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx("span",{className:"text-brand-400 font-mono text-xs w-6 pt-2.5 text-right shrink-0",children:f+1}),e.jsxs("div",{className:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2",children:[e.jsx("input",{className:T,"aria-label":`Step ${f+1} action`,placeholder:"Action",value:v.action,onChange:N=>R(f,"action",N.target.value)}),e.jsx("input",{className:T,"aria-label":`Step ${f+1} expected result`,placeholder:"Expected result",value:v.expectedResult,onChange:N=>R(f,"expectedResult",N.target.value)}),e.jsx("input",{className:T,"aria-label":`Step ${f+1} test data`,placeholder:"Test data",value:v.testData,onChange:N=>R(f,"testData",N.target.value)})]}),e.jsx("button",{type:"button",onClick:()=>D(N=>N.filter((k,$)=>$!==f)),"aria-label":`Remove step ${f+1}`,className:"p-2 rounded-lg text-gray-500 hover:text-red-300 hover:bg-white/5",children:e.jsx(pe,{className:"w-4 h-4"})})]},f)),e.jsx("button",{type:"button",onClick:()=>D(v=>[...v,{action:"",expectedResult:"",testData:""}]),className:"text-xs text-brand-300 hover:text-brand-200",children:"+ Add step"})]})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:Q,className:"px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:"Cancel"}),e.jsx("button",{type:"button",disabled:!H,onClick:()=>G({title:I.trim(),priority:Y,preconditions:E.trim(),steps:_.filter(v=>v.action.trim())}),className:"px-3 py-1.5 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white disabled:opacity-40",children:"Done editing"})]})]})}function kr(){var Cs;const C=$a(),{mode:G}=Ga(),Q=G==="mobile"?"mobile":"web",I=Q==="mobile"?"Mobile mode":"Web mode",[q,Y]=d.useState("sources"),[g,E]=d.useState(null),[j,_]=d.useState(new Set),[D,R]=d.useState(null),T=d.useRef(!1),[H,v]=d.useState(!1),[f,N]=d.useState(null),[k,$]=d.useState(new Set),[S,W]=d.useState(!1),[ge,se]=d.useState(null),[fe,J]=d.useState(null),[ht,et]=d.useState(null),[Z,we]=d.useState(null),[L,ie]=d.useState(null),[M,tt]=d.useState([]),[Pt,zt]=d.useState([]),[st,Lt]=d.useState([]),[at,Ot]=d.useState(""),[Se,Bt]=d.useState(new Set),[ke,Jt]=d.useState(new Set),[Ce,Ut]=d.useState(new Set),[B,qe]=d.useState(new Set),[ae,Ps]=d.useState("requirement"),[Kt,pt]=d.useState(new Set),rt=d.useRef(null),Fe=d.useRef(null),Ge=d.useRef(null),gt=d.useRef(null),ft=d.useRef([]),Pe=Ta(),[_e,bt]=d.useState(null),[U,nt]=d.useState(null);d.useEffect(()=>{let s=!0;return Pa().then(({job:n})=>{s&&n&&nt(n)}).catch(()=>{}),()=>{s=!1}},[]);const yt=d.useRef(!1);d.useEffect(()=>(yt.current=!1,()=>{var s,n;yt.current=!0,(s=rt.current)==null||s.abort(),(n=Fe.current)==null||n.abort()}),[]);const Qt=!_e&&(S||((g==null?void 0:g.length)??0)>0);d.useEffect(()=>{if(!Qt)return;const s=n=>{n.preventDefault(),n.returnValue=""};return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[Qt]);const Ht=d.useRef(null);d.useEffect(()=>{var s;S&&(!g||g.length===0||(s=Ht.current)==null||s.scrollIntoView({behavior:"smooth",block:"end"}))},[S,g==null?void 0:g.length]);const[lr,ir]=d.useState(""),[or,cr]=d.useState(""),[dr,xr]=d.useState(10),[ur,mr]=d.useState(""),[be,lt]=d.useState(new Set),[jt,zs]=d.useState(""),[Ls,Wt]=d.useState(new Set),[ye,Vt]=d.useState(""),[it,Os]=d.useState(!1),[te,Nt]=d.useState("high-level"),[je,Yt]=d.useState(null),[vt,Zt]=d.useState(new Set),[Bs,ze]=d.useState(!1),[wt,Js]=d.useState(null),[Us,Le]=d.useState(!1),[Oe,St]=d.useState(!1),[Be,Ks]=d.useState(!0),[Ae,Ne]=d.useState("select"),[K,kt]=d.useState(null),[xe,Re]=d.useState(new Set),[Ct,Je]=d.useState({}),[Qs,Xt]=d.useState(!1),[Hs,es]=d.useState({}),[F,ts]=d.useState(null),[ss,as]=d.useState(null),[P,rs]=d.useState(new Set),[ns,$e]=d.useState(null),[O,ot]=d.useState(null),ct=d.useRef("sources"),[ls,Ws]=d.useState(!1),[hr,pr]=d.useState(!1),[is,X]=d.useState(null),[dt,os]=d.useState("all"),[xt,qt]=d.useState(""),{data:Ue}=Ia(),{data:z}=Ea({status:"active"}),_t=d.useMemo(()=>Array.from(P).sort(),[P]),At=Ae==="select"&&M.length>0&&!S?xe.size:void 0,{data:A}=qs({queryKey:["tm-ai-estimate",_t,te,At??null],queryFn:()=>_s({sourceIds:_t,depth:te,chosenRequirements:At}),enabled:_t.length>0,staleTime:6e4}),Te=Da(),Ie=S||je!==null||Te.isPending,{data:Ee,isLoading:Vs}=qs({queryKey:["test-explorer"],queryFn:za}),{data:ue}=Ma(),cs=Array.isArray(ue)?ue:(ue==null?void 0:ue.testCases)||(ue==null?void 0:ue.mappings)||[],{mappedKeys:Ys,mappedFileTestNames:Zs}=d.useMemo(()=>{const s=new Set,n=new Map;return cs.forEach(r=>{var c,a;const l=((c=r.mapping)==null?void 0:c.scriptPath)||r.scriptPath||"",u=((a=r.mapping)==null?void 0:a.testName)||r.testName||"";l&&(s.add(`${l}::${u}`.toLowerCase()),n.has(l.toLowerCase())||n.set(l.toLowerCase(),new Set),n.get(l.toLowerCase()).add(u.toLowerCase()))}),{mappedKeys:s,mappedFileTestNames:n}},[cs]),Xs=(Ee==null?void 0:Ee.suites)||[],ea=(s,n)=>{if(Ys.has(`${s}::${n}`.toLowerCase()))return!0;const r=Zs.get(s.toLowerCase());if(!r)return!1;const l=Xs.find(c=>{var a;return((a=c.file)==null?void 0:a.toLowerCase())===s.toLowerCase()}),u=new Set(((l==null?void 0:l.tests)||[]).map(c=>(c.name||"").toLowerCase()));for(const c of r)if(c&&!u.has(c))return!0;return!1},ds=Array.isArray(Ue)?Ue:(Ue==null?void 0:Ue.tree)??[],ta=ds.length?Gs(ds):[],oe=S||H,Ke=d.useMemo(()=>(g??[]).some(s=>s==null?void 0:s._grounding),[g]),ve=d.useMemo(()=>{const s=(g??[]).map((r,l)=>({tc:r,idx:l})),n=at.trim().toLowerCase();return s.filter(({tc:r})=>{var l,u;if(Se.size>0){const c=r==null?void 0:r._strategy;if(typeof c!="string"||!Se.has(c))return!1}if(ke.size>0&&!ke.has((r==null?void 0:r.priority)??""))return!1;if(Ce.size>0){const c=r==null?void 0:r._persona;if(typeof c!="string"||!Ce.has(c))return!1}if(B.size>0){const c=r==null?void 0:r._grounding,a=r==null?void 0:r._automatable,x=c&&c!=="grounded"||!!((l=r==null?void 0:r._specDrift)!=null&&l.appDoes)||((r==null?void 0:r.steps)??[]).some(m=>(m==null?void 0:m._grounded)===!1);if(Ke&&B.has("grounded")&&c!=="grounded"||B.has("automatable")&&a!=="yes"||B.has("duplicates")&&!Ve(r)||B.has("review-notes")&&!(((u=r==null?void 0:r._critique)==null?void 0:u.length)>0)||Ke&&B.has("needs-a-look")&&!x)return!1}return!(n&&![(r==null?void 0:r.title)??"",(r==null?void 0:r.preconditions)??"",((r==null?void 0:r.tags)??[]).join(" "),((r==null?void 0:r.steps)??[]).map(a=>`${(a==null?void 0:a.action)??""} ${(a==null?void 0:a.expectedResult)??""} ${(a==null?void 0:a.testData)??""}`).join(" ")].join(" ").toLowerCase().includes(n))})},[g,at,Se,ke,Ce,B,Ke]),De=d.useMemo(()=>{const s=new Set,n=new Set,r=new Set;for(const l of g??[]){const u=l==null?void 0:l._strategy;typeof u=="string"&&s.add(u),typeof(l==null?void 0:l.priority)=="string"&&n.add(l.priority);const c=l==null?void 0:l._persona;typeof c=="string"&&r.add(c)}return{strategies:s,priorities:n,personas:r}},[g]),xs=d.useMemo(()=>{if(ae==="flat")return[{key:"all",label:"",items:ve}];const s=new Map;for(const r of ve){const l=r.tc;let u,c;if(ae==="requirement"){u=(l==null?void 0:l._requirementId)||"ungrouped";const a=M.find(x=>x.id===u);c=a?`${a.id} — ${a.title}`:u==="ungrouped"?"Ungrouped":u}else ae==="strategy"?(u=(l==null?void 0:l._strategy)||"unspecified",c=u):(u=(l==null?void 0:l.priority)||"unset",c=u);s.has(u)||s.set(u,{key:u,label:c,items:[]}),s.get(u).items.push(r)}const n=Array.from(s.values());if(ae==="requirement")n.sort((r,l)=>{const u=parseInt(r.key.replace(/^\D+/,""),10),c=parseInt(l.key.replace(/^\D+/,""),10);return Number.isFinite(u)&&Number.isFinite(c)?u-c:r.key.localeCompare(l.key)});else if(ae==="priority"){const r={critical:0,high:1,medium:2,low:3,unset:4};n.sort((l,u)=>(r[l.key]??99)-(r[u.key]??99))}else n.sort((r,l)=>r.key.localeCompare(l.key));return n},[ve,ae,M]),us=ve.length,ms=(g==null?void 0:g.length)??0,hs=Se.size>0||ke.size>0||Ce.size>0||B.size>0||at.trim().length>0,Qe=d.useRef(null);function He(s,n){Qe.current&&clearTimeout(Qe.current),Qe.current=null,X(s),n&&(Qe.current=setTimeout(()=>{X(null),Qe.current=null},n))}function ps(s){as(s)}function gs(s){$(n=>{const r=new Set(n);return r.has(s)?r.delete(s):r.add(s),r})}function sa(s){_(n=>{const r=new Set(n);return r.has(s)?r.delete(s):r.add(s),r})}function aa(){if(!g)return;const s=ve.map(r=>r.idx);if(s.length>0&&s.every(r=>j.has(r))){const r=new Set(j);for(const l of s)r.delete(l);_(r)}else{const r=new Set(j);for(const l of s)r.add(l);_(r)}}async function We(s,n,r,l){var h;const u=new AbortController;rt.current=u,bt((l==null?void 0:l.resumeJobId)??null),nt(null),gt.current={sourceIds:Array.isArray(n==null?void 0:n.sourceIds)?n.sourceIds.filter(i=>typeof i=="string"):[]},kt(null),X(null),E([]),_(new Set),$(new Set),se(Date.now()),J(r),et(null),we(null),ie(null),l!=null&&l.keepRequirements||(tt([]),Re(new Set),Je({})),zt([]),Lt([]),Zt(new Set),Js((n==null?void 0:n.depth)??null),Ws((n==null?void 0:n.stopAfterExtraction)===!0),W(!0);let c=!1,a=[],x=[];const m=[];try{for await(const i of Rs(s,n,u.signal,l!=null&&l.resumeJobId?"GET":"POST")){if(i.event==="job"){bt(i.data.jobId);continue}if(i.event==="job-ended"){i.data.status==="cancelled"&&He("The run was cancelled. The cases it made before that are below.",1e4);continue}if(i.event==="testcase")typeof i.data.index=="number"&&i.data.data&&typeof i.data.data=="object"&&(i.data.data._runIndex=i.data.index),m.push(i.data.data),E(t=>{const o=Array.isArray(t)?t.slice():[];return o.push(i.data.data),o});else if(i.event==="script-start")et(t=>{var o;return{done:(t==null?void 0:t.done)??0,total:(t==null?void 0:t.total)??((o=n==null?void 0:n.scriptPaths)==null?void 0:o.length)??1}});else if(i.event==="script-done")et(t=>{var o;return{done:((t==null?void 0:t.done)??0)+1,total:(t==null?void 0:t.total)??((o=n==null?void 0:n.scriptPaths)==null?void 0:o.length)??1}});else if(i.event==="script-error"){const t=String(i.data.filePath??"").split(/[\\/]/).pop()||"a script";He(`Could not reverse-engineer ${t}: ${i.data.error}. The other scripts are below.`,12e3)}else if(i.event==="start"&&i.data.totalSources)we({sourceIndex:0,sourceTitle:"",sourcesDone:0,totalSources:i.data.totalSources??1,chunksDone:0,totalChunks:i.data.totalChunks??1});else if(i.event==="source-start")we(t=>t?{...t,sourceIndex:i.data.sourceIndex,sourceTitle:i.data.sourceTitle}:null);else if(i.event==="source-done")we(t=>t?{...t,sourcesDone:t.sourcesDone+1}:null);else if(i.event==="chunk-done")we(t=>t?{...t,chunksDone:t.chunksDone+1}:null);else if(i.event==="phase")ie(t=>({phase:i.data.phase,phaseLabel:i.data.label,totalRequirements:i.data.totalRequirements??(t==null?void 0:t.totalRequirements)??0,currentRequirement:(t==null?void 0:t.currentRequirement)??null,requirementsDone:(t==null?void 0:t.requirementsDone)??0,coverageGaps:(t==null?void 0:t.coverageGaps)??0,critiqueIssues:(t==null?void 0:t.critiqueIssues)??0}));else if(i.event==="requirements-extracted")l!=null&&l.keepRequirements||(ft.current=i.data.requirements),tt(i.data.requirements),Re(new Set(i.data.requirements.map(t=>t.id))),ia(i.data.requirements),ie(t=>t?{...t,totalRequirements:i.data.count}:null);else if(i.event==="critique-done"){ie(o=>o?{...o,critiqueIssues:i.data.total}:null);const t=Array.isArray(i.data.issues)?i.data.issues:[];if(t.length>0){const o=new Map;for(const p of t)o.set(p.testIndex,[...o.get(p.testIndex)??[],p]);for(const p of m){const b=o.get(p==null?void 0:p._runIndex);b&&(p._critique=[...Array.isArray(p._critique)?p._critique:[],...b])}E(p=>p&&p.slice())}}else i.event==="requirement-start"?ie(t=>t?{...t,currentRequirement:{id:i.data.requirementId,title:i.data.gapFill?`Filling gap: ${i.data.title}`:i.data.title,strategies:i.data.applicableStrategies}}:null):i.event==="requirement-done"?i.data.gapFill||ie(t=>t?{...t,requirementsDone:t.requirementsDone+1}:null):i.event==="requirement-skipped"?(Lt(t=>t.some(o=>o.id===i.data.requirementId)?t:[...t,{id:i.data.requirementId,title:i.data.title,reason:i.data.reason}]),ie(t=>t?{...t,requirementsDone:t.requirementsDone+1}:null)):i.event==="app-model"?ts({summary:i.data.summary,isEmpty:!i.data.runs,pageCount:i.data.pages??0,roles:Array.isArray(i.data.roles)?i.data.roles:[],authedRoles:Array.isArray(i.data.authedRoles)?i.data.authedRoles:[],problems:Array.isArray(i.data.problems)?i.data.problems:[]}):i.event==="domain-detected"?(zt(t=>[...t,{sourceTitle:i.data.sourceTitle,primary:i.data.primary,description:i.data.description,concerns:i.data.concerns}]),es(t=>({...t,[i.data.sourceId??""]:{primary:i.data.primary,description:i.data.description,concerns:i.data.concerns}}))):i.event==="coverage-gaps"?ie(t=>t?{...t,coverageGaps:i.data.significant}:null):i.event==="saved"?(c=!0,Array.isArray(i.data.saved)&&i.data.saved.length>0&&(a=[...a,...i.data.saved]),Array.isArray(i.data.failed)&&(x=[...x,...i.data.failed])):i.event==="save-error"?X(String(((h=i.data)==null?void 0:h.error)||"Auto Save failed.")):i.event==="error"?He(`Generation failed: ${i.data.error}`):i.event==="parse-error"?He(i.data.message,1e4):i.event}!c&&m.length>0&&(n==null?void 0:n.stopAfterExtraction)!==!0&&js(m),c&&(Pe.invalidateQueries({queryKey:["tm-test-cases"]}),Pe.invalidateQueries({queryKey:["tm-stats"]}),Pe.invalidateQueries({queryKey:["tm-sources"]}),a.length>0?Tt(m,m.map((i,t)=>t),a,x,m,!0):x.length>0&&X(`Auto Save saved nothing: ${x[0].error} The cases are still here.`))}catch(i){(i==null?void 0:i.name)==="AbortError"||(console.error("Streaming generation failed:",i),He(`Generation failed: ${(i==null?void 0:i.message)||"Unknown error"}`)),a.length>0&&!yt.current&&(Pe.invalidateQueries({queryKey:["tm-test-cases"]}),Pe.invalidateQueries({queryKey:["tm-sources"]}),Tt(m,m.map((t,o)=>o),a,x,m,!0))}finally{W(!1),rt.current=null,se(null),J(null),we(null),et(null),ie(null)}}function ra(){Le(!0)}function na(){var s;_e&&La(_e).catch(()=>{}),(s=rt.current)==null||s.abort(),Le(!1)}function Rt(){_e&&As(_e).catch(()=>{}),bt(null)}function la(s){nt(null),Y("sources"),rs(new Set(s.sourceIds)),Nt(s.depth),Ne(s.stopAfterExtraction?"select":"review"),We(`/api/tm/ai/jobs/${encodeURIComponent(s.id)}/stream`,{sourceIds:s.sourceIds,depth:s.depth,stopAfterExtraction:s.stopAfterExtraction,autoSave:s.autoSave},null,{resumeJobId:s.id})}async function ia(s){if(s.length!==0){Xt(!0),Oa().then(n=>ts({summary:n.summary,isEmpty:n.isEmpty,pageCount:n.pageCount,roles:n.roles,authedRoles:n.authedRoles,problems:n.problems})).catch(()=>{});try{const n=await Ba({requirements:s.map(l=>({id:l.id,title:l.title,description:l.description,acceptanceCriteria:l.acceptanceCriteria})),sourceIds:Array.from(P)}),r={};for(const l of n.requirements)r[l.id]=l;Je(r)}catch(n){console.warn("Grounding lookup failed (non-fatal):",n)}finally{Xt(!1)}}}function oa(){ut({extractOnly:!0},"extract",ca)}function ca(){const r=(Array.isArray(z==null?void 0:z.sources)?z.sources:[]).filter(l=>P.has(l.id)).map(l=>l.title).join(", ")||"Extract requirements from selected sources";Ne("select"),Je({}),es({}),We("/api/tm/ai/generate/requirements/stream",{requirements:r,sourceIds:Array.from(P),depth:te,useAppKnowledge:Be,stopAfterExtraction:!0},null)}function da(){const s=M.filter(n=>xe.has(n.id));s.length!==0&&ut({chosen:s.length},"generate",xa)}function xa(){if(M.filter(r=>xe.has(r.id)).length===0)return;const n=fs();if(n.length>0&&!Oe){ct.current="chosen",$e(n);return}$t(Oe)}function $t(s){const n=M.filter(c=>xe.has(c.id));if(n.length===0)return;const u=(Array.isArray(z==null?void 0:z.sources)?z.sources:[]).filter(c=>P.has(c.id)).map(c=>c.title).join(", ")||"Generate from chosen requirements";Ne("review"),We("/api/tm/ai/generate/requirements/stream",{requirements:u,folderId:ye||void 0,autoSave:it,sourceIds:Array.from(P),depth:te,useAppKnowledge:Be,selectedRequirements:n,domains:Hs,mode:s?"incremental":"full"},null,{keepRequirements:!0})}async function ut(s,n,r){if(T.current||S)return;T.current=!0,v(!0);let l=null;try{l=await _s({sourceIds:Array.from(P),depth:te,chosenRequirements:s.chosen})}catch{}finally{T.current=!1,v(!1)}if(!l){r();return}(s.extractOnly?l.extractionCalls>40:l.confirm)&&!l.tooLarge?ot({est:s.extractOnly?{...l,totalCalls:{low:l.extractionCalls,high:l.extractionCalls}}:l,what:n,proceed:r}):r()}function fs(){return(Array.isArray(z==null?void 0:z.sources)?z.sources:[]).filter(n=>P.has(n.id)).map(n=>({id:n.id,title:n.title,count:n.linkedTestCaseCount??0})).filter(n=>n.count>0)}function ua(){P.size!==0&&ut({},"generate",ma)}function ma(){const s=fs();if(s.length>0&&!Oe){ct.current="sources",$e(s);return}mt(Oe)}function mt(s){Ne("review");const l=(Array.isArray(z==null?void 0:z.sources)?z.sources:[]).filter(u=>P.has(u.id)).map(u=>u.title).join(", ")||"Generate from selected sources";We("/api/tm/ai/generate/requirements/stream",{requirements:l,folderId:ye||void 0,autoSave:it,sourceIds:Array.from(P),mode:s?"incremental":"full",depth:te,useAppKnowledge:Be},null)}function ha(){if(be.size===0)return;const s=new Set,n={};be.forEach(r=>{const l=r.indexOf("::"),u=l>=0?r.slice(0,l):r,c=l>=0?r.slice(l+2):"";u&&(s.add(u),c&&(n[u]??(n[u]=[])).push(c))}),We("/api/tm/ai/generate/reverse-engineer/stream",{scriptPaths:Array.from(s),scriptTests:n,folderId:ye||void 0,autoSave:it},null)}async function pa(s){if(je||S||s.length===0)return;const n={stop:!1};Ge.current=n;try{for(const r of s){if(n.stop)break;await bs(r,!0)}}finally{Ge.current===n&&(Ge.current=null)}}function ga(){var s;Ge.current&&(Ge.current.stop=!0),(s=Fe.current)==null||s.abort()}async function bs(s,n=!1){var c;if(!n&&je||S||vt.has(s.id))return;Yt(s.id),X(null);const r=new AbortController;Fe.current=r;let l=0;const u=[];try{const a=(g??[]).filter(m=>(m==null?void 0:m._requirementId)===s.id&&typeof(m==null?void 0:m.title)=="string").map(m=>m.title),x=((c=gt.current)==null?void 0:c.sourceIds)??[];for await(const m of Rs("/api/tm/ai/generate/requirement/deepen/stream",{requirement:s,sourceIds:x.length>0?x:void 0,folderId:ye||void 0,autoSave:!1,existingTitles:a,useAppKnowledge:Be},r.signal))m.event==="testcase"?(l++,u.push(m.data.data),E(h=>[...h??[],m.data.data])):m.event==="error"&&X(m.data.error||"Deepen failed");l>0&&(Zt(m=>new Set(m).add(s.id)),js(u,g??[]))}catch(a){(a==null?void 0:a.name)!=="AbortError"&&X(String((a==null?void 0:a.message)||a))}finally{Fe.current===r&&(Fe.current=null),Yt(null)}}function Tt(s,n,r,l,u,c=!1){const a=r.filter(t=>Number.isInteger(t==null?void 0:t.index)&&t.index>=0&&t.index<s.length).map(t=>({id:t.id,title:t.title,tc:s[t.index],requirementId:t.requirementId??null}));if(a.length===0){X(`Nothing was saved${l[0]?`: ${l[0].error}`:"."} Your cases are still here.`);return}const x=new Set(a.length?r.map(t=>n[t.index]):[]),m=u.filter((t,o)=>!x.has(o));kt(t=>[...t??[],...a]),_(new Set),$(new Set);const h=c?"Auto-saved":"Saved",i=l.length>0?` ${l.length} could not be saved (${l[0].error||"unknown error"}).`:"";if(m.length===0)E(null),Ne("accept"),Rt(),ps(`${h} ${a.length} test case${a.length===1?"":"s"}.`);else{E(m);const t=l.length>0?`${h} ${a.length} of ${s.length} test case${s.length===1?"":"s"}.`:`${h} ${a.length} test case${a.length===1?"":"s"}.`;ps(`${t}${i} ${m.length} still here to save.`)}}function fa(s){if(s.length===0)return;const n=`
|
|
3
|
+
`,r=s.map(u=>`- ${u.id}: ${u.title}`).join(n),l=[`Automate these ${s.length} test case${s.length===1?"":"s"} from Test Management:`,"",r,"","For each one: read the case from Test Management, write the test, run it scoped until it passes twice,","and map the script back onto the case so the Test Management entry shows its automation.","The steps were grounded in exploration — use the page and control names exactly as the case gives them."].join(n);Ha(C,{prompt:l,mode:Q})}function ys(s){(g??[]).filter(r=>!s(r)).length===0&&(Rt(),((K==null?void 0:K.length)??0)>0&&Ne("accept")),E(r=>{const l=(r??[]).filter(u=>!s(u));return l.length>0?l:null}),_(new Set),$(new Set)}async function js(s,n=[]){const r=a=>a&&typeof a.title=="string"&&a.title.trim(),l=s.filter(r);if(l.length===0)return;const u=n.filter(r).filter(a=>!l.includes(a)),c=a=>({title:a.title,steps:(a.steps??[]).slice(0,200).map(x=>`${(x==null?void 0:x.action)??""} ${(x==null?void 0:x.expectedResult)??""}`),data:(a.steps??[]).slice(0,200).map(x=>String((x==null?void 0:x.testData)??"")).filter(Boolean)});try{const a=new Map,x=new Map;if(u.length+l.length<=2e3){const m=[...u,...l],{matches:h,within:i}=await $s(m.map(c),{within:!0,from:u.length});l.forEach((t,o)=>{var b;h[o]&&a.set(t,h[o]);const p=i==null?void 0:i[o];p&&x.set(t,{title:((b=m[p.index])==null?void 0:b.title)??p.title,score:p.score})})}else for(let m=0;m<l.length;m+=1e3){const h=l.slice(m,m+1e3),{matches:i}=await $s(h.map(c));h.forEach((t,o)=>{i[o]&&a.set(t,i[o])})}if(a.size===0&&x.size===0)return;E(m=>m&&m.map(h=>(a.has(h)?Object.assign(h,{_dupOf:a.get(h)}):x.has(h)&&Object.assign(h,{_dupOfRun:x.get(h)}),h)).slice())}catch{}}function Ns(s){var c;const n=g??[],r=s.filter(a=>n[a]!=null),l=r.map(a=>n[a]);if(l.length===0)return;const u=((c=gt.current)==null?void 0:c.sourceIds)??[];X(null),Te.mutate({testCases:l,folderId:ye||void 0,sourceIds:u.length>0?u:void 0,requirements:u.length>0&&ft.current.length>0?ft.current:void 0},{onSuccess:a=>Tt(l,r,Array.isArray(a==null?void 0:a.saved)?a.saved:[],Array.isArray(a==null?void 0:a.failed)?a.failed:[],n),onError:a=>X(`Save failed: ${(a==null?void 0:a.message)||"Unknown error"} Your cases are still here.`)})}function ba(){Ns((g??[]).map((s,n)=>n))}function ya(){Ns([...j].sort((s,n)=>s-n))}function vs(){return e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"",children:"No folder (root)"}),ta.map(s=>e.jsxs("option",{value:s.id,children:[" ".repeat(s.depth),s.depth>0?"└ ":"",s.name]},s.id))]})}function ws(){return e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1.5",htmlFor:"ai-gen-target-folder",children:"Target Folder"}),e.jsx("select",{id:"ai-gen-target-folder",value:ye,onChange:s=>Vt(s.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 text-sm focus:outline-none focus:ring-1 focus:ring-brand-500",children:vs()})]})}function ja(){const s=Ae==="select"&&M.length>0&&!S&&((g==null?void 0:g.length)??0)===0,n=Ae==="accept"?4:Ae==="review"||S||((g==null?void 0:g.length)??0)>0?3:s?2:1,r=[{n:1,label:"Choose a source",hint:"then Generate, or Choose requirements"},{n:2,label:"Choose requirements",hint:"optional"},{n:3,label:"Review the cases",hint:"edit, discard, fix"},{n:4,label:"Saved",hint:"automate or push to Jira"}];return e.jsx("ol",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs","aria-label":"AI Test Gen steps",children:r.map((l,u)=>{const c=l.n<n&&!(l.n===2&&!s&&n>2&&!ls),a=l.n===n;return e.jsxs("li",{className:"flex items-center gap-2","aria-current":a?"step":void 0,children:[e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full border ${a?"border-brand-500/40 bg-brand-500/15 text-brand-200":c?"border-emerald-500/25 text-emerald-300":"border-white/10 text-gray-500"}`,children:[e.jsx("span",{className:"font-semibold",children:c?"✓":l.n}),e.jsx("span",{children:l.label}),e.jsxs("span",{className:a?"text-brand-300/80":"text-gray-600",children:["· ",l.hint]})]}),u<r.length-1&&e.jsx("span",{className:"text-gray-600","aria-hidden":!0,children:"→"})]},l.n)})})}function Na(){return e.jsxs("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[e.jsx("span",{className:"text-sm text-gray-300",children:"Coverage:"}),e.jsxs("div",{className:"inline-flex rounded-lg border border-white/10 bg-surface-2 p-0.5 text-sm",children:[e.jsx("button",{type:"button",onClick:()=>Nt("high-level"),className:`px-3 py-1 rounded-md transition-colors ${te==="high-level"?"bg-brand-600 text-white":"text-gray-400 hover:text-gray-200"}`,title:"Functional coverage — fewer, higher-level tests (major + medium). Fast and lean.",children:"High-level"}),e.jsx("button",{type:"button",onClick:()=>{te!=="detailed"&&ze(!0)},className:`px-3 py-1 rounded-md transition-colors ${te==="detailed"?"bg-brand-600 text-white":"text-gray-400 hover:text-gray-200"}`,title:"Exhaustive — adds edge, boundary & security detail and per-persona variants (major + medium + low).",children:"Detailed"})]})]})}function Ss(s=!1){return e.jsxs("div",{className:"flex flex-wrap gap-x-5 gap-y-2 items-center",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-300 cursor-pointer select-none whitespace-nowrap",children:[e.jsx("input",{type:"checkbox",checked:it,onChange:n=>Os(n.target.checked),className:"rounded border-white/20 bg-surface-2 text-brand-500 focus:ring-brand-500 focus:ring-offset-0"}),"Auto Save"]}),s&&e.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-300 cursor-pointer select-none whitespace-nowrap",title:"Skip requirements that already have test cases (matched by source-quote fingerprint). Useful after editing a source document.",children:[e.jsx("input",{type:"checkbox",checked:Oe,onChange:n=>St(n.target.checked),className:"rounded border-white/20 bg-surface-2 text-brand-500 focus:ring-brand-500 focus:ring-offset-0"}),"Incremental mode ",e.jsx("span",{className:"text-xs text-gray-500",children:"(skip already-covered)"})]}),s&&e.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-300 cursor-pointer select-none whitespace-nowrap",title:"Use what exploration observed for page names, control labels and role access. Requirements still decide every expected result.",children:[e.jsx("input",{type:"checkbox",checked:Be,onChange:n=>Ks(n.target.checked),className:"rounded border-white/20 bg-surface-2 text-brand-500 focus:ring-brand-500 focus:ring-offset-0"}),"Use app knowledge",e.jsx("span",{className:"text-xs text-gray-500",children:F?F.isEmpty?"(nothing explored yet)":`(${F.summary})`:"(navigation from exploration)"})]})]})}function va(){return ss?e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 rounded-lg bg-emerald-500/15 border border-emerald-500/30 text-emerald-300 text-sm animate-in fade-in",children:[e.jsx(Xe,{className:"w-4 h-4 shrink-0"}),e.jsx("span",{children:ss}),e.jsx("button",{onClick:()=>as(null),className:"ml-auto text-emerald-400 hover:text-emerald-200",children:e.jsx(pe,{className:"w-4 h-4"})})]}):null}function wa(){return is?e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 rounded-lg bg-red-500/15 border border-red-500/30 text-red-300 text-sm animate-in fade-in",children:[e.jsx(de,{className:"w-4 h-4 shrink-0"}),e.jsx("span",{children:is}),e.jsx("button",{onClick:()=>X(null),className:"ml-auto text-red-400 hover:text-red-200",children:e.jsx(pe,{className:"w-4 h-4"})})]}):null}function ks(){const s=(g==null?void 0:g.length)??0;return e.jsxs("div",{className:"flex items-center justify-between gap-4 p-4 bg-surface-1 border border-brand-500/30 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:"absolute inset-0 bg-brand-500/20 rounded-full blur-md animate-pulse"}),e.jsx(le,{className:"w-5 h-5 text-brand-400 animate-spin relative"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm text-gray-200",children:[s===0?"Contacting AI…":"Generating test cases",fe?e.jsxs("span",{className:"text-gray-500",children:[" — ",s," of ~",fe]}):s>0&&e.jsxs("span",{className:"text-gray-500",children:[" — ",s," so far"]}),ht&&e.jsxs("span",{className:"text-gray-500",children:[" · script ",ht.done,"/",ht.total]}),Z&&Z.totalSources>1&&e.jsxs("span",{className:"text-gray-500",children:[" ","· source ",Z.sourcesDone+1,"/",Z.totalSources]}),Z&&Z.totalChunks>1&&e.jsxs("span",{className:"text-gray-500",children:[" ","· section ",Z.chunksDone+1,"/",Z.totalChunks]}),L&&e.jsxs("span",{className:"text-gray-500",children:[" ","· ",L.phaseLabel,L.totalRequirements>0&&L.phase==="generating"&&e.jsxs(e.Fragment,{children:[" (",L.requirementsDone,"/",L.totalRequirements,")"]}),L.critiqueIssues>0&&L.phase!=="critiquing"&&e.jsxs("span",{className:"ml-2 text-amber-300",children:["⚠ ",L.critiqueIssues," quality issue",L.critiqueIssues===1?"":"s"]})]})]}),Z&&Z.sourceTitle&&e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5 truncate",title:Z.sourceTitle,children:["Reading: ",Z.sourceTitle]}),(L==null?void 0:L.currentRequirement)&&e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5 truncate",title:`${L.currentRequirement.id} — ${L.currentRequirement.title}`,children:[e.jsx("span",{className:"font-mono text-brand-300",children:L.currentRequirement.id}),e.jsx("span",{className:"mx-1",children:"—"}),L.currentRequirement.title,L.currentRequirement.strategies.length>0&&e.jsxs("span",{className:"ml-2 text-gray-600",children:["[",L.currentRequirement.strategies.join(", "),"]"]})]}),e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["Elapsed ",e.jsx(nr,{startedAt:ge,active:S}),". Results appear above as each test case is completed."]})]})]}),e.jsxs("button",{onClick:ra,className:"flex-shrink-0 flex items-center gap-1.5 px-3 py-1.5 bg-surface-2 hover:bg-surface-3 text-gray-300 hover:text-red-300 border border-white/10 rounded-md text-xs transition-colors",title:"Cancel generation (partial results will be kept)",children:[e.jsx(pe,{className:"w-3.5 h-3.5"}),"Cancel"]})]})}function Sa(){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 bg-brand-500/20 rounded-full blur-xl animate-pulse"}),e.jsx(le,{className:"w-10 h-10 text-brand-400 animate-spin relative"})]}),e.jsx("p",{className:"text-gray-300 text-sm",children:"AI is generating test cases..."}),e.jsx("p",{className:"text-gray-500 text-xs",children:"This may take a moment depending on complexity"})]})}function ka(){if(oe&&!S)return Sa();if(!S&&!g)return null;if(!S&&g&&g.length===0)return ls?null:e.jsxs("div",{className:"text-center py-12 text-gray-400",children:[e.jsx(de,{className:"w-8 h-8 mx-auto mb-3 text-amber-400"}),e.jsx("p",{children:"No test cases were generated. Try refining your input."})]});if(S&&(!g||g.length===0))return e.jsx("div",{className:"space-y-4",children:ks()});const s=g,n=()=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Xe,{className:"w-5 h-5 text-emerald-400"}),e.jsxs("span",{className:"text-gray-200 font-medium",children:["Generated ",s.length," test case",s.length!==1?"s":""]}),(()=>{const t=s.filter(w=>(w==null?void 0:w._grounding)==="grounded").length,o=s.filter(w=>(w==null?void 0:w._automatable)==="yes").length;if(!s.some(w=>(w==null?void 0:w._grounding)||(w==null?void 0:w._automatable)))return null;const b=s.some(w=>w==null?void 0:w._grounding);return e.jsxs("span",{className:"text-xs text-gray-500",children:["·"," ",b?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-emerald-300",children:t})," grounded"]}):e.jsx("span",{title:"No exploration run has recorded this app, so the navigation in these steps was not checked against anything. The requirement still decided every expected result.",children:"nothing explored"})," ","· ",e.jsx("span",{className:"text-cyan-300",children:o})," automatable"]})})()]}),e.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{if(je)return e.jsx("button",{onClick:ga,className:"text-xs text-rose-300 hover:text-rose-200 transition-colors",children:"Stop deepening"});if(wt!=="high-level")return null;const t=new Set((g??[]).map(p=>p==null?void 0:p._requirementId).filter(Boolean)),o=M.filter(p=>t.has(p.id)&&!vt.has(p.id));return o.length<2?null:e.jsxs("button",{onClick:()=>void pa(o),disabled:Ie,title:`Generate detailed tests (edge, boundary, security) for all ${o.length} requirements — about ${o.length} AI calls`,className:"text-xs text-brand-300 hover:text-brand-200 transition-colors disabled:opacity-40",children:["Deepen all ",o.length]})})(),(()=>{const t=(g??[]).filter(o=>{var p;return((p=o==null?void 0:o._critique)==null?void 0:p.length)>0});return t.length===0?null:e.jsxs("button",{onClick:()=>N(t),disabled:Ie,title:"Have the AI rewrite the cases its review flagged — you see each change before it is used",className:"text-xs text-brand-300 hover:text-brand-200 transition-colors disabled:opacity-40",children:["Fix ",t.length," with AI"]})})(),(()=>{const t=(g??[]).filter(Ve).length;return t===0?null:e.jsxs("button",{onClick:()=>ys(Ve),disabled:Ie,title:"Take the cases that look like existing ones off this list (nothing is deleted from Test Cases)",className:"text-xs text-amber-300 hover:text-amber-200 transition-colors disabled:opacity-40",children:["Discard ",t," possible duplicate",t===1?"":"s"]})})(),e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-gray-400",children:[e.jsx("span",{children:"Save to"}),e.jsx("select",{"aria-label":"Folder to save into",value:ye,onChange:t=>Vt(t.target.value),className:"max-w-[12rem] bg-surface-2 border border-white/10 rounded-md px-2 py-1 text-gray-200 text-xs focus:outline-none focus:ring-1 focus:ring-brand-500",children:vs()})]}),(()=>{const t=ve.map(b=>b.idx),o=t.length>0&&t.every(b=>j.has(b)),p=hs?o?"Deselect Visible":`Select Visible (${t.length})`:j.size===s.length?"Deselect All":"Select All";return e.jsx("button",{onClick:aa,className:"text-xs text-gray-400 hover:text-gray-200 transition-colors",children:p})})(),e.jsxs("button",{onClick:ya,disabled:j.size===0||Te.isPending||S||je!==null,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[Te.isPending?e.jsx(le,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Ds,{className:"w-3.5 h-3.5"}),"Save Selected (",j.size,")"]}),e.jsxs("button",{onClick:ba,disabled:Te.isPending||S||je!==null,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-gradient-to-r from-purple-600 to-brand-600 hover:from-purple-500 hover:to-brand-500 text-white disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[Te.isPending?e.jsx(le,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Ds,{className:"w-3.5 h-3.5"}),"Save All"]})]})]}),r=(t,o,p)=>{const b=new Set(t);b.has(o)?b.delete(o):b.add(o),p(b)},l=t=>{const o=new Set(Kt);o.has(t)?o.delete(t):o.add(t),pt(o)},u=()=>pt(new Set),c=()=>pt(new Set(xs.map(t=>t.key))),a=()=>{Ot(""),Bt(new Set),Jt(new Set),Ut(new Set),qe(new Set)},x=(t,o)=>{E(p=>p&&p.map(b=>{if(b!==t)return b;const w=Array.isArray(b.steps)?b.steps:[],re=o.steps.map((ce,V)=>{const y=w[V];return y&&typeof y=="object"&&String(y.action??"")===ce.action?{...y,...ce}:{...ce}});return{...b,title:o.title,priority:o.priority,preconditions:o.preconditions,steps:re,_edited:!0}})),R(null)},m=(t,o)=>{E(p=>{if(!p)return p;const b=[...p],w=b[t];return w?(b[t]={...w,_automatable:o,_automatableReason:"set by a reviewer"},b):p})},h=(t,o)=>{var p,b,w,re,ce,V;return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsx("input",{type:"checkbox",checked:j.has(o),onChange:()=>sa(o),className:"rounded border-white/20 bg-surface-2 text-brand-500 focus:ring-brand-500 focus:ring-offset-0"}),e.jsx("button",{onClick:()=>gs(o),className:"text-gray-400 hover:text-gray-200 transition-colors",children:k.has(o)?e.jsx(Dt,{className:"w-4 h-4"}):e.jsx(Mt,{className:"w-4 h-4"})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("button",{onClick:()=>gs(o),className:"text-left w-full text-gray-200 font-medium text-sm hover:text-white transition-colors truncate",children:t.title||t.name||`Test Case ${o+1}`})}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t._edited&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-brand-500/20 text-brand-300",title:"You changed this case",children:"edited"}),t._dupOf&&e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-amber-500/20 text-amber-300",title:`Looks like ${t._dupOf.id}: "${t._dupOf.title}" (${Math.round(t._dupOf.score*100)}% alike) — already in Test Cases.`,children:["possible duplicate of ",t._dupOf.id]}),!t._dupOf&&t._dupOfRun&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-amber-500/20 text-amber-300",title:`Does what "${t._dupOfRun.title}" (earlier in this list) does — ${Math.round(t._dupOfRun.score*100)}% alike. That one is kept.`,children:"repeats a case above"}),((p=t._critique)==null?void 0:p.length)>0&&e.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full ${t._critique.some(y=>y.severity==="major")?"bg-rose-500/20 text-rose-300":"bg-amber-500/20 text-amber-300"}`,title:t._critique.map(y=>`${y.kind}: ${y.message}`).join(`
|
|
4
|
+
`),children:[t._critique.length," review note",t._critique.length===1?"":"s"]}),t._fixedNote&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-emerald-500/20 text-emerald-300",title:t._fixedNote,children:"fixed"}),t._strategy&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-cyan-500/15 text-cyan-300 font-mono",title:`Test strategy: ${t._strategy}`,children:t._strategy}),t.priority&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${sr[t.priority]??"bg-gray-500/20 text-gray-300"}`,children:t.priority}),t.type&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${ar[t.type]??"bg-gray-500/20 text-gray-300"}`,children:t.type}),t._persona&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-violet-500/15 text-violet-300",title:`Persona: ${t._persona}`,children:t._persona}),t._grounding&&me[t._grounding]&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${me[t._grounding].cls}`,title:me[t._grounding].title,children:me[t._grounding].label}),t._automatable&&ne[t._automatable]&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${ne[t._automatable].cls}`,title:t._automatableReason||"",children:ne[t._automatable].label}),t._sourceScriptName&&e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-purple-500/15 text-purple-300 border border-purple-500/20 flex items-center gap-1",title:t._sourceScript,children:[e.jsx(Es,{className:"w-3 h-3"}),t._sourceScriptName]})]})]}),k.has(o)&&e.jsxs("div",{className:"px-4 pb-4 border-t border-white/5",children:[D!==t&&e.jsxs("div",{className:"flex justify-end gap-2 mt-3",children:[e.jsx("button",{type:"button",onClick:()=>R(t),disabled:Ie,className:"text-xs px-2.5 py-1 rounded-md border border-white/10 text-gray-300 hover:text-white hover:border-white/20 disabled:opacity-40",children:"Edit"}),e.jsx("button",{type:"button",onClick:()=>ys(y=>y===t),disabled:Ie,title:"Take this case off the list — it will not be saved",className:"text-xs px-2.5 py-1 rounded-md border border-white/10 text-gray-400 hover:text-red-300 hover:border-red-500/30 disabled:opacity-40",children:"Discard"})]}),D===t&&e.jsx(rr,{tc:t,onSave:y=>x(t,y),onCancel:()=>R(null)}),D!==t&&((b=t._critique)==null?void 0:b.length)>0&&e.jsxs("div",{className:"mt-3 rounded-lg border border-amber-500/25 bg-amber-500/10 p-3 space-y-1.5",children:[e.jsx("p",{className:"text-xs font-medium text-amber-200",children:"The AI review found"}),t._critique.map((y,ee)=>e.jsxs("p",{className:"text-xs text-gray-300 leading-relaxed",children:[e.jsx("span",{className:y.severity==="major"?"text-rose-300":"text-amber-300",children:y.kind})," — ",y.message,y.suggestion?e.jsxs("span",{className:"text-gray-500",children:[" Suggested: ",y.suggestion]}):null]},ee))]}),D!==t&&t._fixedNote&&e.jsxs("p",{className:"mt-3 text-xs text-emerald-300",children:["Fixed by AI: ",t._fixedNote]}),D!==t&&t.description&&e.jsx("p",{className:"text-gray-400 text-sm mt-3 mb-3",children:t.description}),D!==t&&((w=t.tags)==null?void 0:w.length)>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-3",children:t.tags.map((y,ee)=>e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-brand-500/15 text-brand-300",children:y},ee))}),D!==t&&t.preconditions&&e.jsxs("div",{className:"mb-3",children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-1",children:"Preconditions"}),e.jsx("p",{className:"text-sm text-gray-300",children:t.preconditions})]}),D!==t&&((re=t.steps)==null?void 0:re.length)>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-2",children:"Steps"}),e.jsx("div",{className:"space-y-2",children:t.steps.map((y,ee)=>e.jsxs("div",{className:"flex gap-3 text-sm",children:[e.jsx("span",{className:"text-brand-400 font-mono text-xs w-6 pt-0.5 text-right shrink-0",children:ee+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-gray-200",children:y.action||y.description||y}),y.expectedResult&&e.jsxs("p",{className:"text-gray-400 text-xs mt-0.5",children:[e.jsx("span",{className:"text-emerald-400 font-medium",children:"Expected:"})," ",y.expectedResult]}),y.testData&&e.jsxs("p",{className:"text-gray-400 text-xs mt-0.5",children:[e.jsx("span",{className:"text-blue-400 font-medium",children:"Data:"})," ",y.testData]}),typeof y._grounded=="boolean"&&e.jsxs("p",{className:"text-xs mt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${y._grounded?"bg-emerald-400":"bg-gray-500"}`}),e.jsx("span",{className:y._grounded?"text-emerald-400":"text-gray-500",children:y._grounded?"observed":"not observed"}),y._pageRef&&e.jsx("span",{className:"text-gray-600 font-mono",children:y._pageRef})]})]})]},ee))})]}),Array.isArray(t._groundingRefs)&&t._groundingRefs.length>0&&e.jsxs("div",{className:"mt-3 rounded-lg bg-surface-2/60 border border-white/5 px-3 py-2",children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-1.5",children:"Grounded by"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t._groundingRefs.map((y,ee)=>e.jsx("span",{className:"text-xs font-mono px-2 py-0.5 rounded bg-emerald-500/20 text-emerald-300",children:y},ee)),t._requirementId&&e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-500/20 text-amber-300",title:"Supplies the expected results",children:[t._requirementId," — expected results"]})]})]}),t._automatable&&ne[t._automatable]&&e.jsxs("div",{className:"mt-3 rounded-lg bg-surface-2/60 border border-white/5 px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider",children:"Automation"}),e.jsx("span",{className:"flex-1"}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${ne[t._automatable].cls}`,children:ne[t._automatable].label})]}),t._automatableReason&&e.jsx("p",{className:"text-xs text-gray-400 mt-1.5 leading-relaxed",children:t._automatableReason}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:["yes","needs-setup","manual"].filter(y=>y!==t._automatable).map(y=>e.jsxs("button",{onClick:()=>m(o,y),className:"text-xs px-2 py-1 rounded-md border border-white/10 text-gray-400 hover:text-gray-200 hover:border-white/20 transition-colors",children:["Mark ",ne[y].label]},y))})]}),((ce=t._specDrift)==null?void 0:ce.requirementSays)&&((V=t._specDrift)==null?void 0:V.appDoes)&&e.jsxs("div",{className:"mt-3 rounded-lg bg-rose-500/10 border border-rose-500/25 px-3 py-2",children:[e.jsx("h4",{className:"text-xs font-medium text-rose-300 uppercase tracking-wider mb-1.5",children:"Possible spec drift"}),e.jsxs("p",{className:"text-xs text-gray-300 leading-relaxed",children:[e.jsx("span",{className:"text-gray-400",children:"The requirement says"})," ",t._specDrift.requirementSays]}),e.jsxs("p",{className:"text-xs text-gray-300 leading-relaxed mt-1",children:[e.jsx("span",{className:"text-gray-400",children:"Exploration saw"})," ",t._specDrift.appDoes,t._specDrift.citation&&e.jsx("span",{className:"text-gray-600 font-mono ml-1.5",children:t._specDrift.citation})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1.5 leading-relaxed",children:"This case asserts the requirement, so it is expected to fail until the disagreement is settled."})]})]})]},o)},i=t=>{const o=new Map;for(const{tc:b}of t){const w=b==null?void 0:b._strategy;typeof w=="string"&&o.set(w,(o.get(w)||0)+1)}const p=Array.from(o.entries()).map(([b,w])=>`${b}: ${w}`);return p.length>0?`${t.length} tests · ${p.join(", ")}`:`${t.length} tests`};return e.jsxs("div",{className:"space-y-4",children:[n(),!S&&((g==null?void 0:g.length)??0)>0&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-3 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"flex-1 min-w-[200px]",children:e.jsx("input",{type:"text",value:at,onChange:t=>Ot(t.target.value),placeholder:"Search test titles, steps, tags…",className:"w-full px-3 py-1.5 text-sm rounded-lg bg-surface-2 border border-white/5 text-gray-200 placeholder-gray-500 focus:outline-none focus:ring-1 focus:ring-brand-500"})}),e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-gray-400",children:[e.jsx("span",{children:"Group by:"}),e.jsxs("select",{value:ae,onChange:t=>Ps(t.target.value),className:"px-2 py-1 rounded bg-surface-2 border border-white/5 text-gray-200 focus:outline-none focus:ring-1 focus:ring-brand-500",children:[e.jsx("option",{value:"requirement",children:"Requirement"}),e.jsx("option",{value:"strategy",children:"Strategy"}),e.jsx("option",{value:"priority",children:"Priority"}),e.jsx("option",{value:"flat",children:"Flat (no grouping)"})]})]}),ae!=="flat"&&e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsx("button",{onClick:u,className:"px-2 py-1 rounded bg-surface-2 hover:bg-surface-3 text-gray-400 hover:text-gray-200 transition-colors",children:"Expand all"}),e.jsx("button",{onClick:c,className:"px-2 py-1 rounded bg-surface-2 hover:bg-surface-3 text-gray-400 hover:text-gray-200 transition-colors",children:"Collapse all"})]})]}),(g??[]).some(t=>{var o;return(t==null?void 0:t._grounding)||(t==null?void 0:t._automatable)||Ve(t)||((o=t==null?void 0:t._critique)==null?void 0:o.length)})&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-xs text-gray-500 mr-1",children:"Quality:"}),Ke&&e.jsx(he,{label:"grounded",active:B.has("grounded"),onToggle:()=>r(B,"grounded",qe),color:"emerald"}),e.jsx(he,{label:"automatable",active:B.has("automatable"),onToggle:()=>r(B,"automatable",qe),color:"cyan"}),(g??[]).some(Ve)&&e.jsx(he,{label:"possible duplicates",active:B.has("duplicates"),onToggle:()=>r(B,"duplicates",qe),color:"amber"}),(g??[]).some(t=>{var o;return(o=t==null?void 0:t._critique)==null?void 0:o.length})&&e.jsx(he,{label:"review notes",active:B.has("review-notes"),onToggle:()=>r(B,"review-notes",qe),color:"amber"}),Ke&&e.jsx(he,{label:"needs a look",active:B.has("needs-a-look"),onToggle:()=>r(B,"needs-a-look",qe),color:"gray"})]}),De.strategies.size>0&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-xs text-gray-500 mr-1",children:"Strategy:"}),Array.from(De.strategies).sort().map(t=>e.jsx(he,{label:t,active:Se.has(t),onToggle:()=>r(Se,t,Bt),color:"cyan"},t))]}),De.priorities.size>0&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-xs text-gray-500 mr-1",children:"Priority:"}),["critical","high","medium","low"].filter(t=>De.priorities.has(t)).map(t=>e.jsx(he,{label:t,active:ke.has(t),onToggle:()=>r(ke,t,Jt),color:"amber"},t))]}),De.personas.size>0&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-xs text-gray-500 mr-1",children:"Persona:"}),Array.from(De.personas).sort().map(t=>e.jsx(he,{label:t,active:Ce.has(t),onToggle:()=>r(Ce,t,Ut),color:"violet"},t))]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500",children:[e.jsxs("span",{children:["Showing ",e.jsx("span",{className:"text-gray-300",children:us})," of ",e.jsx("span",{className:"text-gray-300",children:ms})," tests"]}),hs&&e.jsx("button",{onClick:a,className:"text-brand-400 hover:text-brand-300 transition-colors",children:"Clear filters"})]})]}),us===0&&ms>0?e.jsxs("div",{className:"text-center py-12 text-gray-400 bg-surface-1 rounded-xl border border-white/5",children:[e.jsx(de,{className:"w-8 h-8 mx-auto mb-3 text-amber-400"}),e.jsx("p",{children:"No test cases match the current filters."}),e.jsx("button",{onClick:a,className:"mt-3 text-sm text-brand-400 hover:text-brand-300",children:"Clear filters"})]}):ae==="flat"?ve.map(({tc:t,idx:o})=>h(t,o)):xs.map(t=>{const o=Kt.has(t.key);return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>l(t.key),className:"flex-1 min-w-0 flex items-center gap-2 px-3 py-2 bg-surface-2 hover:bg-surface-3 rounded-lg text-left transition-colors",children:[o?e.jsx(Mt,{className:"w-4 h-4 text-gray-400 flex-shrink-0"}):e.jsx(Dt,{className:"w-4 h-4 text-gray-400 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-gray-200 text-sm flex-1 truncate",children:t.label}),e.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:i(t.items)})]}),wt==="high-level"&&ae==="requirement"&&t.key!=="ungrouped"&&(()=>{const p=M.find(re=>re.id===t.key);if(!p)return null;const b=je===t.key,w=vt.has(t.key);return e.jsxs("button",{onClick:()=>bs(p),disabled:Ie||w,className:`flex-shrink-0 flex items-center gap-1 px-2.5 py-2 text-xs rounded-lg border whitespace-nowrap disabled:cursor-not-allowed ${w?"bg-emerald-500/10 text-emerald-300 border-emerald-500/20 disabled:opacity-100":"bg-brand-500/15 text-brand-300 border-brand-500/20 hover:bg-brand-500/25 disabled:opacity-50"}`,title:w?"Detailed tests already generated for this requirement":"Generate exhaustive detailed tests (edge, boundary, security) for this requirement and add them here",children:[b?e.jsx(le,{className:"w-3 h-3 animate-spin"}):w?e.jsx(Xe,{className:"w-3 h-3"}):e.jsx(Ze,{className:"w-3 h-3"}),b?"Deepening…":w?"Deepened":"Deepen"]})})()]}),!o&&e.jsx("div",{className:"space-y-2 pl-2",children:t.items.map(({tc:p,idx:b})=>h(p,b))})]},t.key)}),!1,S&&ks(),!S&&Pt.length>0&&e.jsxs("div",{className:"w-full bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Detected Application Domain"}),e.jsx("div",{className:"grid gap-3 grid-cols-1",children:Pt.map((t,o)=>e.jsxs("div",{className:"w-full bg-surface-2 rounded-lg p-4 border border-white/5",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3 mb-2",children:[e.jsx("span",{className:"text-sm font-mono font-medium text-brand-300 bg-brand-500/10 px-2 py-0.5 rounded",children:t.primary}),e.jsx("span",{className:"text-xs text-gray-500 truncate max-w-[240px]",title:t.sourceTitle,children:t.sourceTitle})]}),t.description&&e.jsx("p",{className:"text-sm text-gray-300 mb-3 leading-relaxed",children:t.description}),t.concerns.length>0&&e.jsx("ul",{className:"text-sm text-gray-400 space-y-1 list-disc list-inside marker:text-brand-400/60",children:t.concerns.slice(0,5).map((p,b)=>e.jsx("li",{className:"leading-relaxed",children:p},b))})]},o))})]}),!S&&st.length>0&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-amber-500/20 p-4",children:[e.jsxs("h3",{className:"text-sm font-semibold text-amber-300 mb-2",children:[st.length," requirement",st.length===1?"":"s"," skipped (already covered)"]}),e.jsx("ul",{className:"text-xs text-gray-400 space-y-1 max-h-40 overflow-y-auto",children:st.map(t=>e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"font-mono text-amber-400 flex-shrink-0",children:t.id}),e.jsx("span",{className:"truncate",title:t.title,children:t.title})]},t.id))})]}),!S&&M.length>0&&e.jsx(Za,{requirements:M,tests:s,depth:wt}),!S&&n(),e.jsx("div",{ref:Ht,"aria-hidden":!0})]})}function Ca(){return e.jsxs("div",{className:"space-y-6",children:[U&&!S&&U.id!==_e&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-4 py-3 rounded-lg bg-brand-500/10 border border-brand-500/25 text-sm",role:"status",children:[e.jsx(Ze,{className:"w-4 h-4 text-brand-300 shrink-0"}),e.jsx("span",{className:"text-gray-200",children:U.status==="running"?e.jsxs(e.Fragment,{children:["A generation is still running — from ",e.jsx("b",{children:U.label||"your source"}),U.cases>0?e.jsxs(e.Fragment,{children:[", ",U.cases," test case",U.cases===1?"":"s"," so far"]}):null,"."]}):U.stopAfterExtraction?e.jsxs(e.Fragment,{children:["Requirements extracted from ",e.jsx("b",{children:U.label||"your source"})," are ready to choose from."]}):e.jsxs(e.Fragment,{children:["A generation from ",e.jsx("b",{children:U.label||"your source"})," finished with ",U.cases," test case",U.cases===1?"":"s",U.saved>0?e.jsxs(e.Fragment,{children:[" (",U.saved," auto-saved)"]}):null,"."]})}),e.jsxs("span",{className:"ml-auto flex gap-2",children:[e.jsx("button",{onClick:()=>la(U),className:"px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white text-xs font-medium",children:U.status==="running"?"Follow it":"Show it"}),e.jsx("button",{onClick:()=>{As(U.id).catch(()=>{}),nt(null)},className:"px-3 py-1.5 rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 text-xs",children:"Dismiss"})]})]}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:tr.map(s=>e.jsxs("button",{onClick:()=>Y(s.id),className:`flex flex-col items-start gap-2 p-4 rounded-xl border transition-all text-left ${q===s.id?"bg-brand-500/10 border-brand-500/30 shadow-lg shadow-brand-500/5":"bg-surface-1 border-white/5 hover:border-white/10"}`,children:[e.jsx("div",{className:`p-2 rounded-lg ${q===s.id?"bg-brand-500/20 text-brand-300":"bg-surface-2 text-gray-400"}`,children:s.icon}),e.jsxs("div",{children:[e.jsx("p",{className:`text-sm font-medium ${q===s.id?"text-brand-300":"text-gray-200"}`,children:s.label}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:s.description})]})]},s.id))}),q==="sources"&&ja(),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-6",children:[q==="sources"&&qa(),q==="reverse"&&Ra()]}),_a(),Aa(),va(),wa(),ka()]})}function qa(){const s=Array.isArray(z==null?void 0:z.sources)?z.sources:[],n={requirement:"📋",nlp:"💬",jira:"🎫",document:"📎"},r={requirement:"Requirement",nlp:"Note",jira:"JIRA Ticket",document:"Document"},l=["all","requirement","nlp","jira","document"],u=xt.trim().toLowerCase(),c=s.filter(a=>dt!=="all"&&a.type!==dt?!1:u?`${a.title||""} ${a.content||""}`.toLowerCase().includes(u):!0);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 gap-3 flex-wrap",children:[e.jsx("label",{className:"text-sm font-medium text-gray-300",children:"Select Source for Test Generation"}),e.jsx("div",{className:"flex items-center gap-1.5",children:l.map(a=>{var x;return e.jsx("button",{onClick:()=>os(a),className:`px-2.5 py-1 rounded-md text-[11px] font-medium transition-colors border ${dt===a?"bg-brand-600 hover:bg-brand-500 text-white border-brand-500":"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200 hover:bg-surface-3"}`,children:a==="all"?"All":((x=r[a])==null?void 0:x.split(" ")[0])||a},a)})})]}),e.jsxs("div",{className:"relative mb-3",children:[e.jsx(Ts,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-500 pointer-events-none"}),e.jsx("input",{type:"text",value:xt,onChange:a=>qt(a.target.value),placeholder:"Search sources by title or content…",className:"w-full pl-9 pr-9 py-2 text-sm rounded-lg bg-surface-2 border border-white/10 text-gray-200 placeholder-gray-500 focus:outline-none focus:ring-1 focus:ring-brand-500"}),xt&&e.jsx("button",{onClick:()=>qt(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded text-gray-500 hover:text-gray-300 hover:bg-surface-3 transition-colors",title:"Clear search",children:e.jsx(pe,{className:"w-3.5 h-3.5"})})]}),c.length>0?e.jsxs("div",{className:"bg-surface-2 rounded-xl border border-white/10 overflow-hidden max-h-[300px] overflow-y-auto",children:[e.jsx("div",{className:"px-4 py-2 bg-surface-2 border-b border-white/10 sticky top-0 z-10 backdrop-blur supports-[backdrop-filter]:bg-surface-2/95",children:e.jsx("span",{className:"text-xs text-gray-400",children:"Select one source to generate test cases from"})}),c.map(a=>{const x=a.linkedTestCaseCount??0,m=P.has(a.id);return e.jsxs("label",{className:`flex items-start gap-3 px-4 py-3 border-b border-white/5 last:border-b-0 cursor-pointer transition-colors ${m?"bg-brand-500/5":"hover:bg-white/[0.02]"}`,children:[e.jsx("input",{type:"radio",name:"ai-test-gen-source-main",checked:m,onChange:()=>rs(new Set([a.id])),className:"mt-0.5 border-white/20 bg-surface-1 text-brand-500 focus:ring-brand-500 focus:ring-offset-0"}),e.jsx("span",{className:"text-base flex-shrink-0",children:n[a.type]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 font-medium",children:a.title}),a.content&&e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5 line-clamp-2",children:[a.content.substring(0,120),a.content.length>120?"...":""]})]}),e.jsxs("span",{className:`flex-shrink-0 px-2 py-0.5 rounded text-[10px] font-medium ${x>0?"bg-emerald-500/15 text-emerald-300 border border-emerald-500/20":"bg-surface-1 text-gray-500 border border-white/5"}`,title:x>0?`${x} test case${x===1?"":"s"} already generated for this source`:"No test cases generated yet",children:[x," TC",x===1?"":"s"]}),(a.staleCases??0)>0&&e.jsxs("span",{className:"flex-shrink-0 px-2 py-0.5 rounded text-[10px] font-medium bg-amber-500/20 text-amber-300",title:"The source's text changed after these test cases were generated",children:[a.staleCases," to review"]}),e.jsx("span",{className:"flex-shrink-0 px-2 py-0.5 rounded text-[10px] font-medium bg-surface-1 text-gray-400 border border-white/5",children:r[a.type]||a.type})]},a.id)})]}):e.jsxs("div",{className:"text-center py-10 bg-surface-2 rounded-xl border border-white/10",children:[e.jsx(Ft,{size:28,className:"mx-auto mb-2 text-gray-500 opacity-50"}),(xt||dt!=="all")&&s.length>0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-gray-400 mb-1",children:"No sources match your search"}),e.jsx("button",{onClick:()=>{qt(""),os("all")},className:"text-xs text-brand-400 hover:text-brand-300",children:"Clear search and filters"})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-gray-400 mb-1",children:"No sources available"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["Add requirements, notes, or documents in the ",e.jsx("a",{href:"/sources",className:"text-brand-400 hover:text-brand-300 underline",children:"Sources"})," page first"]})]})]})]}),(()=>{const a=s.filter(m=>P.has(m.id)&&(m.staleCases??0)>0);if(a.length===0)return null;const x=a.reduce((m,h)=>m+(h.staleCases??0),0);return e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-4 py-3 rounded-lg bg-amber-500/10 border border-amber-500/25 text-sm",role:"status",children:[e.jsx(de,{className:"w-4 h-4 text-amber-300 shrink-0"}),e.jsxs("span",{className:"text-gray-200 flex-1 min-w-[16rem]",children:[e.jsx("b",{children:a[0].title})," changed after its test cases were generated — ",x," case",x===1?"":"s"," need",x===1?"s":""," review (Test Cases shows what changed). Regenerating with Incremental mode makes cases only for the requirements whose text changed."]}),e.jsx("button",{onClick:()=>{St(!0),ut({},"generate",()=>mt(!0))},disabled:oe,className:"px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white text-xs font-medium disabled:opacity-50",children:"Regenerate changed requirements"})]})})(),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[ws(),e.jsx("div",{className:"flex items-end sm:col-span-1 lg:col-span-2",children:Ss(!0)})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-2",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-4",children:Na()}),e.jsxs("div",{className:"flex items-center gap-2",children:[A&&P.size>0&&(A.tooLarge?e.jsx("span",{className:"text-xs text-amber-300 mr-1",title:"One run reads up to about 400,000 characters",children:"Too large for one run — split the source"}):e.jsxs("span",{className:"text-xs text-gray-500 mr-1",title:`${A.extractionCalls} call(s) to read the document in ${A.chunks} part(s), then about one per requirement (${A.requirements.low}–${A.requirements.high} requirements)`,children:["About ",A.totalCalls.low===A.totalCalls.high?A.totalCalls.low:`${A.totalCalls.low}–${A.totalCalls.high}`," AI calls"]})),A&&P.size>0&&!A.tooLarge&&A.cases&&A.cases.high>0&&e.jsxs("span",{className:"text-xs text-gray-500 mr-1",title:te==="detailed"?"Detailed makes about one data-driven case per test type for each requirement":"High-level makes 1–3 focused cases per requirement",children:["· ",A.cases.low===A.cases.high?A.cases.low:`${A.cases.low}–${A.cases.high}`," test cases"]}),e.jsxs("button",{onClick:oa,disabled:P.size===0||oe,className:"flex items-center gap-2 px-4 py-2.5 rounded-lg bg-surface-2 border border-white/10 hover:border-white/20 text-gray-200 font-medium text-sm disabled:opacity-40 disabled:cursor-not-allowed transition-all",title:"Extract the requirements first and choose which ones to generate from. Shows how much of each would be guesswork.",children:[oe?e.jsx(le,{className:"w-4 h-4 animate-spin"}):e.jsx(Ft,{className:"w-4 h-4"}),"Choose requirements"]}),e.jsxs("button",{onClick:ua,disabled:P.size===0||oe,className:"flex items-center gap-2 px-5 py-2.5 rounded-lg bg-gradient-to-r from-purple-600 to-brand-600 hover:from-purple-500 hover:to-brand-500 text-white font-medium text-sm disabled:opacity-40 disabled:cursor-not-allowed transition-all shadow-lg shadow-brand-500/20",children:[oe?e.jsx(le,{className:"w-4 h-4 animate-spin"}):e.jsx(Ze,{className:"w-4 h-4"}),"Generate from ",P.size," Source",P.size!==1?"s":""]})]})]})]})}function _a(){if(Ae!=="select"||M.length===0||S)return null;const s=M.filter(c=>xe.has(c.id)),n=M.filter(c=>{var a;return(((a=Ct[c.id])==null?void 0:a.pagesMatched)??0)>0}).length,r=xe.size===M.length,l=((F==null?void 0:F.isEmpty)??!1)||n===0,u=c=>{Re(a=>{const x=new Set(a);return x.has(c)?x.delete(c):x.add(c),x})};return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:[e.jsxs("div",{className:"flex items-start gap-4 px-5 py-4 border-b border-white/5",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100",children:[M.length," requirement",M.length===1?"":"s"," found"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Pick what to generate from. The grounding column says whether exploration has reached that part of the app — it does not block anything, it tells you how much of the result will be guesswork."})]}),e.jsx("button",{onClick:()=>{tt([]),Re(new Set),Je({})},className:"text-sm text-gray-400 hover:text-gray-200 transition-colors shrink-0",children:"Back to sources"})]}),e.jsxs("div",{className:"flex",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 py-2.5 border-b border-white/5 bg-surface-2/40",children:[e.jsx("input",{type:"checkbox",checked:r,onChange:()=>Re(r?new Set:new Set(M.map(c=>c.id))),className:"rounded border-white/20 bg-surface-2 text-brand-500 focus:ring-brand-500 focus:ring-offset-0"}),e.jsxs("span",{className:"text-xs text-gray-400 flex-1",children:[xe.size," of ",M.length," selected"]}),e.jsx("span",{className:"text-xs text-gray-500 uppercase tracking-wider w-40 shrink-0",children:"Grounding"})]}),e.jsx("div",{className:"max-h-[420px] overflow-y-auto",children:M.map(c=>{const a=Ct[c.id],x=xe.has(c.id);return e.jsxs("div",{className:`flex items-start gap-3 px-5 py-3 border-b border-white/5 transition-colors ${x?"bg-brand-500/10":""}`,children:[e.jsx("input",{type:"checkbox",checked:x,onChange:()=>u(c.id),className:"mt-1 rounded border-white/20 bg-surface-2 text-brand-500 focus:ring-brand-500 focus:ring-offset-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:`text-sm ${x?"text-gray-100":"text-gray-400"}`,children:[e.jsx("span",{className:"font-mono text-xs text-gray-500 mr-2",children:c.id}),c.title]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1",children:[e.jsx("span",{className:"text-[11px] text-gray-500",children:c.category}),e.jsx("span",{className:"text-[11px] text-gray-600",children:"·"}),e.jsx("span",{className:"text-[11px] text-gray-500",children:c.priority}),c.sourceTitle&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[11px] text-gray-600",children:"·"}),e.jsx("span",{className:"text-[11px] text-gray-500 truncate max-w-[180px]",children:c.sourceTitle})]})]}),(a==null?void 0:a.priorDrift)&&e.jsxs("p",{className:"text-[11px] text-rose-300 mt-1.5 leading-relaxed",children:["Disagreed before — ",a.priorDrift.testCaseId," recorded that the app ",a.priorDrift.appDoes]})]}),e.jsx("div",{className:"w-40 shrink-0 pt-0.5",children:Qs&&!a?e.jsx("span",{className:"text-xs text-gray-600",children:"checking…"}):((a==null?void 0:a.pagesMatched)??0)>0?e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-emerald-500/20 text-emerald-300 cursor-help",title:a.pages.map(m=>`${m.template} (${m.citation})`).join(`
|
|
5
|
+
`),children:[a.pagesMatched," page",a.pagesMatched===1?"":"s"," explored"]}):e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-500/20 text-gray-300",children:"not explored"})})]},c.id)})})]}),e.jsxs("div",{className:"w-72 shrink-0 border-l border-white/5 p-4 space-y-4",children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider",children:"Grounding"}),e.jsxs("div",{className:`rounded-lg border p-3 ${F&&!F.isEmpty?"border-emerald-500/25 bg-emerald-500/10":"border-white/10 bg-surface-2/40"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${F&&!F.isEmpty?"bg-emerald-400":"bg-gray-500"}`}),e.jsx("span",{className:"text-sm text-gray-200 font-medium",children:"App knowledge"})]}),e.jsx("p",{className:"text-xs text-gray-400 mt-1.5 leading-relaxed",children:F?F.isEmpty?"Nothing explored yet — navigation will be invented.":F.summary:"Not checked yet."}),F&&F.roles.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:F.roles.map(c=>e.jsx("span",{className:`text-[11px] px-1.5 py-0.5 rounded ${F.authedRoles.includes(c)?"bg-surface-2 text-gray-200":"bg-white/5 text-gray-500"}`,title:F.authedRoles.includes(c)?"Session saved — replays without a person":"No saved session",children:c},c))})]}),e.jsx("div",{className:"rounded-lg border border-white/10 bg-surface-2/40 p-3",children:l?e.jsx("p",{className:"text-xs text-gray-400 leading-relaxed",children:"These still get tests. The requirement decides every expected result either way — what is missing is the real page and control names, so the steps will name plausible ones instead."}):e.jsxs("p",{className:"text-xs text-gray-400 leading-relaxed",children:[e.jsx("span",{className:"text-gray-200",children:n})," of ",M.length," requirements land on a page exploration has seen. The rest still get tests — the requirement decides every expected result either way."]})}),F&&F.problems.length>0&&e.jsx("div",{className:"rounded-lg border border-amber-500/25 bg-amber-500/10 p-3",children:e.jsxs("p",{className:"text-xs text-amber-300 leading-relaxed",children:[F.problems.length," exploration file could not be read. Grounding is thinner than it should be, not absent."]})})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-4 border-t border-white/5",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:[s.length===0?"Nothing selected":l?`${s.length} requirement${s.length===1?"":"s"} selected`:`${s.length} requirement${s.length===1?"":"s"} · ${s.filter(c=>{var a;return(((a=Ct[c.id])==null?void 0:a.pagesMatched)??0)>0}).length} grounded`,s.length>0&&(A==null?void 0:A.cases)&&At===s.length&&e.jsxs(e.Fragment,{children:[" · about ",A.cases.low===A.cases.high?A.cases.low:`${A.cases.low}–${A.cases.high}`," test cases (",te==="detailed"?"Detailed":"High-level",")"]})]}),e.jsxs("button",{onClick:da,disabled:s.length===0||oe,className:"flex items-center gap-2 px-5 py-2.5 rounded-lg bg-gradient-to-r from-purple-600 to-brand-600 hover:from-purple-500 hover:to-brand-500 text-white font-medium text-sm disabled:opacity-40 disabled:cursor-not-allowed transition-all shadow-lg shadow-brand-500/20",children:[e.jsx(Ze,{className:"w-4 h-4"}),"Generate cases for ",s.length," requirement",s.length===1?"":"s"]})]})]})}function Aa(){if(Ae!=="accept"||!K||K.length===0)return null;const s=K.filter(a=>{var x;return((x=a.tc)==null?void 0:x._automatable)==="yes"}),n=K.filter(a=>{var x;return((x=a.tc)==null?void 0:x._automatable)&&a.tc._automatable!=="yes"}),r=K.filter(a=>{var x,m;return(m=(x=a.tc)==null?void 0:x._specDrift)==null?void 0:m.appDoes}),l=new Set(K.map(a=>{var x;return(x=a.tc)==null?void 0:x._requirementId}).filter(Boolean)),u=[...l].filter(a=>K.filter(x=>{var m;return((m=x.tc)==null?void 0:m._requirementId)===a}).every(x=>{var m;return((m=x.tc)==null?void 0:m._automatable)==="yes"})),c=[...new Set(K.filter(a=>{var x;return((x=a.tc)==null?void 0:x._grounding)==="ungrounded"}).map(a=>{var x,m;return((x=a.tc)==null?void 0:x._sourceTitle)||((m=a.tc)==null?void 0:m._requirementId)}).filter(Boolean))];return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:[e.jsxs("div",{className:"flex items-start gap-4 px-5 py-4 border-b border-white/5",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100",children:[K.length," case",K.length===1?"":"s"," added to Test Management"]}),e.jsxs("p",{className:"text-sm text-gray-400 mt-1",children:["Each carries its steps and a link back to the requirement it verifies. Nothing is automated yet — that happens in ",I,", and comes back here as a script mapping. They are saved as ",e.jsx("em",{children:"In review"})," — approve or reject them on Test Cases."]})]}),e.jsx("button",{onClick:()=>{kt(null),Ne("select"),Rt(),tt([]),Re(new Set),Je({})},className:"text-sm text-gray-400 hover:text-gray-200 transition-colors shrink-0",children:"Done"})]}),e.jsxs("div",{className:"max-h-[360px] overflow-y-auto",children:[e.jsxs("div",{className:"grid grid-cols-[90px_1fr_100px_130px_130px] gap-0 px-5 py-2 border-b border-white/5 bg-surface-2/40 text-[11px] uppercase tracking-wider text-gray-500",children:[e.jsx("span",{children:"Case"}),e.jsx("span",{children:"Title"}),e.jsx("span",{children:"Req"}),e.jsx("span",{children:"Grounding"}),e.jsx("span",{children:"Automation"})]}),K.map(a=>{var x,m,h;return e.jsxs("div",{className:"grid grid-cols-[90px_1fr_100px_130px_130px] gap-0 items-start px-5 py-2.5 border-b border-white/5 text-sm",children:[e.jsx("span",{className:"font-mono text-xs text-gray-300 pt-0.5",children:a.id}),e.jsx("span",{className:"text-gray-200 pr-4",children:a.title}),e.jsx("span",{className:"text-xs text-gray-400 pt-0.5",children:a.requirementId||((x=a.tc)==null?void 0:x._requirementId)||"—"}),e.jsx("span",{className:"pt-0.5",children:(m=a.tc)!=null&&m._grounding&&me[a.tc._grounding]?e.jsx("span",{className:`text-[11px] px-2 py-0.5 rounded-full ${me[a.tc._grounding].cls}`,title:me[a.tc._grounding].title,children:me[a.tc._grounding].label}):e.jsx("span",{className:"text-xs text-gray-600",children:"—"})}),e.jsx("span",{className:"pt-0.5",children:(h=a.tc)!=null&&h._automatable&&ne[a.tc._automatable]?e.jsx("span",{className:`text-[11px] px-2 py-0.5 rounded-full ${ne[a.tc._automatable].cls}`,title:a.tc._automatableReason||"",children:ne[a.tc._automatable].label}):e.jsx("span",{className:"text-xs text-gray-600",children:"—"})})]},a.id)})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-3 p-5",children:[e.jsxs("div",{className:"rounded-lg border border-cyan-500/25 bg-cyan-500/10 p-4 flex flex-col gap-2",children:[e.jsxs("h4",{className:"text-sm font-semibold text-gray-100",children:[s.length," of ",K.length," can be automated"]}),e.jsxs("p",{className:"text-xs text-gray-400 leading-relaxed",children:[I," writes each test, runs it scoped until it is green twice, and maps the script back onto the case."]}),e.jsxs("button",{onClick:()=>fa(s),disabled:s.length===0,className:"self-start mt-auto flex items-center gap-2 px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium text-sm disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[e.jsx(Qa,{className:"w-3.5 h-3.5"}),"Automate ",s.length," in ",I]})]}),e.jsxs("div",{className:"rounded-lg border border-white/10 bg-surface-2/40 p-4 flex flex-col gap-2",children:[e.jsxs("h4",{className:"text-sm font-semibold text-gray-100",children:[n.length," held back"]}),n.length===0?e.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"Nothing is waiting on setup or a person."}):e.jsxs("div",{className:"space-y-1.5",children:[n.slice(0,4).map(a=>e.jsxs("p",{className:"text-xs text-gray-400 leading-relaxed flex gap-2",children:[e.jsx("span",{className:`mt-1.5 w-1.5 h-1.5 rounded-full shrink-0 ${a.tc._automatable==="needs-setup"?"bg-violet-400":"bg-gray-500"}`}),e.jsxs("span",{children:[e.jsxs("span",{className:"text-gray-300",children:[a.id," ",a.tc._automatable==="needs-setup"?"needs setup":"is manual"]}),a.tc._automatableReason?` — ${a.tc._automatableReason}`:""]})]},a.id)),n.length>4&&e.jsxs("p",{className:"text-xs text-gray-600",children:["and ",n.length-4," more"]})]}),e.jsx("p",{className:"text-xs text-gray-600 leading-relaxed mt-auto pt-1",children:"They stay in Test Management as manual cases, with the reason recorded."})]}),e.jsxs("div",{className:`rounded-lg border p-4 flex flex-col gap-2 ${r.length>0?"border-rose-500/25 bg-rose-500/10":"border-white/10 bg-surface-2/40"}`,children:[e.jsxs("h4",{className:`text-sm font-semibold ${r.length>0?"text-rose-300":"text-gray-100"}`,children:[r.length," expected to fail"]}),r.length===0?e.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"No case contradicts what exploration observed."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-1.5",children:r.slice(0,3).map(a=>e.jsxs("p",{className:"text-xs text-gray-300 leading-relaxed",children:[e.jsx("span",{className:"text-gray-200",children:a.id})," asserts the requirement; the app"," ",a.tc._specDrift.appDoes]},a.id))}),e.jsx("p",{className:"text-xs text-gray-500 leading-relaxed mt-auto pt-1",children:"Automating these is deliberate: the red result names a real disagreement, not a broken script."})]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-6 px-5 py-4 border-t border-white/5 bg-white/[0.02]",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wider text-gray-500",children:"Requirement coverage"}),e.jsxs("p",{className:"text-sm font-semibold text-gray-200 mt-0.5",children:[l.size," ",e.jsx("span",{className:"text-xs font-normal text-gray-500",children:"linked to a case"})]})]}),e.jsx("div",{className:"w-px h-8 bg-white/10"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wider text-gray-500",children:"Automated coverage"}),e.jsxs("p",{className:"text-sm font-semibold text-gray-200 mt-0.5",children:[u.length," of ",l.size," ",e.jsx("span",{className:"text-xs font-normal text-gray-500",children:"once these run"})]})]}),c.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-8 bg-white/10"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wider text-gray-500",children:"Still unexplored"}),e.jsxs("p",{className:"text-sm text-gray-300 mt-0.5 truncate",title:c.join(", "),children:[c.slice(0,2).join(", "),e.jsx("span",{className:"text-xs text-gray-500",children:" — navigation invented"})]})]})]}),e.jsx("span",{className:"ml-auto",children:e.jsx(Wa,{ids:K.map(a=>a.id),label:`Push ${K.length} to Jira`})})]})]})}function Ra(){const n=((Ee==null?void 0:Ee.suites)||[]).map(h=>{const i=(h.tests||[]).map(b=>({...b,_mapped:ea(h.file,b.name),_key:`${h.file}::${b.name}`})),t=i.filter(b=>b._mapped).length,o=i.length>0&&t===i.length,p=t>0&&t<i.length;return{...h,tests:i,isMapped:o,partiallyMapped:p,mappedTestCount:t}}).filter(h=>{if(jt){const i=jt.toLowerCase(),t=(h.file||"").toLowerCase().includes(i),o=(h.tests||[]).some(p=>(p.name||"").toLowerCase().includes(i));return t||o}return!0}),r=be.size,l=h=>{lt(i=>{const t=new Set(i),o=(h.tests||[]).filter(b=>!b._mapped);return o.every(b=>t.has(b._key))?o.forEach(b=>t.delete(b._key)):o.forEach(b=>t.add(b._key)),t})},u=h=>{lt(i=>{const t=new Set(i);return t.has(h)?t.delete(h):t.add(h),t})},c=h=>{const i=(h.tests||[]).filter(t=>!t._mapped);return i.length>0&&i.every(t=>be.has(t._key))},a=h=>{const i=(h.tests||[]).filter(o=>!o._mapped),t=i.filter(o=>be.has(o._key)).length;return t>0&&t<i.length},x=()=>{const h=new Set;n.forEach(i=>{(i.tests||[]).filter(t=>!t._mapped).forEach(t=>h.add(t._key))}),lt(h)},m=()=>lt(new Set);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 flex items-start gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0 mt-0.5",children:e.jsx(Gt,{className:"w-4 h-4 text-purple-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-200",children:"Reverse Engineer Test Cases from Scripts"}),e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:"Select individual test scenarios or entire script files to generate manual test cases. Use the file checkbox to select all tests in a file, or expand and pick specific scenarios."})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Ts,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),e.jsx("input",{type:"text",value:jt,onChange:h=>zs(h.target.value),placeholder:"Search scripts or tests...",className:"w-full bg-surface-2 border border-white/10 rounded-lg pl-9 pr-3 py-2 text-gray-200 text-sm placeholder:text-gray-600 focus:outline-none focus:ring-1 focus:ring-brand-500"})]}),e.jsx("button",{onClick:x,className:"text-xs text-brand-400 hover:text-brand-300 whitespace-nowrap",children:"Select All Unmapped"}),e.jsx("button",{onClick:m,className:"text-xs text-gray-500 hover:text-gray-300 whitespace-nowrap",children:"Deselect All"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[r," test",r!==1?"s":""," selected"]})]}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 max-h-[450px] overflow-y-auto",children:Vs?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(le,{className:"w-5 h-5 text-brand-400 animate-spin"}),e.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"Loading scripts..."})]}):n.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[e.jsx(Ka,{className:"w-8 h-8 text-gray-500 mb-2"}),e.jsx("p",{className:"text-sm text-gray-400 text-center",children:"No test scripts discovered yet."}),e.jsx("p",{className:"text-xs text-gray-500 text-center mt-1",children:"Run your test framework first so Testver can discover test suites."})]}):e.jsx("div",{className:"divide-y divide-white/5",children:n.map((h,i)=>{const t=h.file||`suite-${i}`,o=Ls.has(t),p=h.tests||[],b=t.split(/[/\\]/).pop()||t,w=c(h),re=a(h),ce=p.filter(V=>!V._mapped).length;return e.jsxs("div",{children:[e.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 transition-colors ${w?"bg-brand-500/10":re?"bg-brand-500/5":"hover:bg-white/[0.03]"} ${h.isMapped?"opacity-40":""}`,children:[e.jsx("button",{onClick:()=>!h.isMapped&&l(h),disabled:h.isMapped,className:`w-5 h-5 rounded border flex items-center justify-center shrink-0 transition-colors ${h.isMapped?"border-gray-700 cursor-not-allowed":w?"bg-brand-500 border-brand-500 text-white":re?"bg-brand-500/50 border-brand-500 text-white":"border-gray-600 hover:border-gray-400 cursor-pointer"}`,children:(w||re)&&e.jsx(Is,{className:"w-3 h-3"})}),e.jsx("button",{onClick:()=>{Wt(V=>{const y=new Set(V);return y.has(t)?y.delete(t):y.add(t),y})},className:"text-gray-500 hover:text-gray-300",children:o?e.jsx(Dt,{className:"w-4 h-4"}):e.jsx(Mt,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:()=>{Wt(V=>{const y=new Set(V);return y.has(t)?y.delete(t):y.add(t),y})},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Es,{className:"w-4 h-4 text-brand-400 shrink-0"}),e.jsx("span",{className:"text-sm text-gray-200 truncate font-medium",children:b}),e.jsxs("span",{className:"text-xs text-gray-500",children:[p.length," test",p.length!==1?"s":""]}),h.isMapped&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:"All Mapped"}),h.partiallyMapped&&!h.isMapped&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20",children:[h.mappedTestCount,"/",p.length," Mapped"]}),ce>0&&!h.isMapped&&e.jsxs("span",{className:"text-[10px] text-gray-500",children:[ce," available"]})]}),e.jsx("p",{className:"text-xs text-gray-500 truncate mt-0.5",children:t})]})]}),o&&p.length>0&&e.jsx("div",{className:"border-t border-white/[0.03] bg-surface-2/30",children:p.map((V,y)=>{const ee=V._key,It=be.has(ee),Me=V._mapped;return e.jsxs("div",{className:`flex items-center gap-3 pl-14 pr-4 py-2 transition-colors ${It?"bg-brand-500/10":"hover:bg-white/[0.02]"} ${Me?"opacity-40":""}`,children:[e.jsx("button",{onClick:()=>!Me&&u(ee),disabled:Me,className:`w-4 h-4 rounded border flex items-center justify-center shrink-0 transition-colors ${Me?"border-gray-700 cursor-not-allowed":It?"bg-brand-500 border-brand-500 text-white":"border-gray-600 hover:border-gray-400 cursor-pointer"}`,children:It&&e.jsx(Is,{className:"w-2.5 h-2.5"})}),e.jsx("span",{className:`text-xs truncate flex-1 ${Me?"text-gray-600":"text-gray-300"}`,children:V.name||`Test ${y+1}`}),Me&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 shrink-0",children:"Mapped"})]},y)})})]},t)})})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[ws(),e.jsx("div",{className:"flex items-end",children:Ss()})]}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsxs("button",{onClick:ha,disabled:be.size===0||oe,className:"flex items-center gap-2 px-5 py-2.5 rounded-lg bg-gradient-to-r from-purple-600 to-brand-600 hover:from-purple-500 hover:to-brand-500 text-white font-medium text-sm disabled:opacity-40 disabled:cursor-not-allowed transition-all shadow-lg shadow-brand-500/20",children:[oe?e.jsx(le,{className:"w-4 h-4 animate-spin"}):e.jsx(Gt,{className:"w-4 h-4"}),"Reverse Engineer ",r>0&&`(${r} test${r>1?"s":""})`]})})]})}return e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200",children:[e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-6",children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(Ja,{size:24,className:"text-brand-300"}),"AI-Powered Test Case Generation"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Generate, review, and optimize test cases with artificial intelligence"})]})}),e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 py-8",children:Ca()}),f&&e.jsx(Xa,{cases:f,requirementTitle:s=>{const n=M.find(r=>r.id===(s==null?void 0:s._requirementId));return n?`${n.id}: ${n.title}`:void 0},onClose:()=>N(null),onApply:s=>{E(n=>n&&n.map(r=>{const l=s.get(r);return l?{...r,title:l.title,preconditions:l.preconditions,steps:l.steps.map(u=>({...u})),_critique:void 0,_fixedNote:l.changes||"Rewritten by AI",_edited:!0}:r})),N(null)}}),O&&Ye.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",role:"dialog","aria-modal":"true","aria-labelledby":"ai-gen-cost-title",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:()=>ot(null)}),e.jsxs("div",{className:"relative w-full max-w-md rounded-xl bg-surface-1 border border-white/10 p-5 shadow-2xl",children:[e.jsx("h3",{id:"ai-gen-cost-title",className:"text-base font-semibold text-gray-100",children:"This is a big run"}),e.jsx("p",{className:"text-sm text-gray-400 mt-2 leading-relaxed",children:O.what==="extract"?e.jsxs(e.Fragment,{children:["Reading this source takes about ",e.jsx("b",{className:"text-gray-200",children:O.est.totalCalls.high})," AI calls (",O.est.chunks," part",O.est.chunks===1?"":"s",")."]}):e.jsxs(e.Fragment,{children:["This run makes about ",e.jsxs("b",{className:"text-gray-200",children:[O.est.totalCalls.low,"–",O.est.totalCalls.high]})," AI calls",O.est.chunks>0&&e.jsxs(e.Fragment,{children:[" — ",O.est.extractionCalls," to read the source in ",O.est.chunks," part",O.est.chunks===1?"":"s",", then about one per requirement (",O.est.requirements.low,"–",O.est.requirements.high," requirements)"]}),"."]})}),O.what!=="extract"&&((Cs=O.est.cases)==null?void 0:Cs.high)>0&&e.jsxs("p",{className:"text-sm text-gray-400 mt-2 leading-relaxed",children:["Expect about ",e.jsxs("b",{className:"text-gray-200",children:[O.est.cases.low,"–",O.est.cases.high]})," test cases to review."]}),e.jsxs("p",{className:"text-xs text-gray-500 mt-2 leading-relaxed",children:["Each call uses AI credits. To spend less: use High-level coverage, or ",e.jsx("b",{children:"Choose requirements"})," and generate for the ones that matter."]}),e.jsxs("div",{className:"flex gap-2 justify-end mt-4",children:[e.jsx("button",{onClick:()=>ot(null),className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:"Cancel"}),e.jsx("button",{autoFocus:!0,onClick:()=>{const s=O.proceed;ot(null),s()},className:"px-4 py-2 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium",children:O.what==="extract"?"Read the source":"Generate"})]})]})]}),document.body),ns&&Ye.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:()=>$e(null)}),e.jsxs("div",{className:"relative bg-surface-1 rounded-xl border border-white/10 p-6 w-[560px] max-w-[92vw] animate-fade-in",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-500/15 flex items-center justify-center flex-shrink-0",children:e.jsx(de,{size:20,className:"text-amber-400"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-100",children:"This source already has generated test cases"}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Running a full regeneration will likely produce duplicate steps for requirements that are already covered."})]})]}),e.jsx("div",{className:"bg-surface-2 rounded-lg border border-white/5 px-3 py-2 mb-4 max-h-32 overflow-y-auto",children:e.jsx("ul",{className:"space-y-1 text-xs",children:ns.map(s=>e.jsxs("li",{className:"flex items-center justify-between gap-2 text-gray-300",children:[e.jsx("span",{className:"truncate",children:s.title}),e.jsxs("span",{className:"text-gray-500 flex-shrink-0",children:[s.count," test case",s.count===1?"":"s"]})]},s.id))})}),e.jsx("div",{className:"rounded-lg border border-brand-500/20 bg-brand-500/5 p-3 mb-5",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ua,{size:14,className:"text-brand-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-xs text-gray-300 leading-relaxed",children:[e.jsx("p",{className:"font-medium text-gray-100 mb-1",children:"Recommended: Incremental Mode"}),e.jsxs("p",{children:["The AI will ",e.jsx("span",{className:"text-brand-300",children:"skip requirements that already have matching test cases"})," and only generate for new or changed content. Use this when the source has been edited and you want coverage for the diff — without re-paying for what's already covered."]})]})]})}),e.jsxs("div",{className:"flex gap-2 justify-end flex-wrap",children:[e.jsx("button",{onClick:()=>$e(null),className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:"Cancel"}),e.jsx("button",{onClick:()=>{$e(null),ct.current==="chosen"?$t(!1):mt(!1)},className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",title:"Skip the recommendation and regenerate everything (may produce duplicates)",children:"Generate Anyway"}),e.jsx("button",{onClick:()=>{St(!0),$e(null),ct.current==="chosen"?$t(!0):mt(!0)},className:"px-4 py-2 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium",children:"Use Incremental Mode"})]})]})]}),document.body),Bs&&Ye.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:()=>ze(!1)}),e.jsxs("div",{className:"relative bg-surface-1 rounded-xl border border-white/10 p-6 w-[560px] max-w-[92vw] animate-fade-in",children:[e.jsx("button",{onClick:()=>ze(!1),className:"absolute top-3 right-3 text-gray-500 hover:text-gray-300 transition-colors","aria-label":"Close",children:e.jsx(pe,{size:18})}),e.jsxs("div",{className:"flex items-start gap-3 mb-4 pr-6",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-500/15 flex items-center justify-center flex-shrink-0",children:e.jsx(de,{size:20,className:"text-amber-400"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-100",children:"Switch to Detailed coverage?"}),e.jsxs("p",{className:"text-sm text-gray-400 mt-1 leading-relaxed",children:["Detailed mode generates ",e.jsx("span",{className:"text-gray-200",children:"thorough"})," test cases for ",e.jsx("span",{className:"text-gray-200",children:"every requirement"})," — covering positive (happy-path), negative, boundary-value, data-validation, integration, security, performance and accessibility scenarios, plus role checks where a role changes the outcome. Each test type gets one data-driven case that tries every value, not one case per value."]})]})]}),e.jsx("div",{className:"rounded-lg border border-amber-500/20 bg-amber-500/5 p-3 mb-5",children:e.jsxs("p",{className:"text-xs text-gray-300 leading-relaxed",children:["This produces ",e.jsx("span",{className:"text-amber-300 font-medium",children:"many more test cases"})," and takes noticeably longer to generate. If you only need broad functional coverage, stay on High-level — you can always use ",e.jsx("span",{className:"text-amber-300 font-medium",children:"Deepen"})," to expand individual requirements on demand."]})}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:()=>ze(!1),className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:"Cancel"}),e.jsx("button",{onClick:()=>{Nt("detailed"),ze(!1)},className:"px-4 py-2 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium",children:"Switch to Detailed"})]})]})]}),document.body),Us&&Ye.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:()=>Le(!1)}),e.jsxs("div",{className:"relative bg-surface-1 rounded-xl border border-white/10 p-6 w-[520px] max-w-[92vw] animate-fade-in",children:[e.jsx("button",{onClick:()=>Le(!1),className:"absolute top-3 right-3 text-gray-500 hover:text-gray-300 transition-colors","aria-label":"Close",children:e.jsx(pe,{size:18})}),e.jsxs("div",{className:"flex items-start gap-3 mb-5 pr-6",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-500/15 flex items-center justify-center flex-shrink-0",children:e.jsx(de,{size:20,className:"text-amber-400"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-100",children:"Cancel test generation?"}),e.jsxs("p",{className:"text-sm text-gray-400 mt-1 leading-relaxed",children:["The test cases generated so far will be ",e.jsx("span",{className:"text-gray-200",children:"kept"}),", but the remaining requirements ",e.jsx("span",{className:"text-gray-200",children:"won't be generated"}),". This run can't be resumed — you'd need to start generation again to complete the rest."]})]})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:()=>Le(!1),className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:"Keep generating"}),e.jsx("button",{onClick:na,className:"px-4 py-2 text-sm rounded-lg bg-red-600 hover:bg-red-500 text-white font-medium",children:"Yes, cancel"})]})]})]}),document.body)]})}function nr({startedAt:C,active:G}){const[,Q]=d.useState(0);d.useEffect(()=>{if(!G)return;const E=setInterval(()=>Q(j=>j+1),1e3);return()=>clearInterval(E)},[G]);const I=C?Date.now()-C:0,q=Math.floor(I/1e3),Y=Math.floor(q/60),g=(q%60).toString().padStart(2,"0");return e.jsx(e.Fragment,{children:Y>0?`${Y}m ${g}s`:`${q}s`})}export{kr as AITestGenPage};
|