@ai-sdet/test-manager 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +312 -0
  2. package/dist/cli.js +16455 -0
  3. package/dist/client/assets/AIView-BYoeRnLC.js +73 -0
  4. package/dist/client/assets/AdminSettingsView-JqCQI3K1.js +1 -0
  5. package/dist/client/assets/ChatSection-rpiFyFcg.js +8 -0
  6. package/dist/client/assets/MilestonesView-CTJ8r67W.js +1 -0
  7. package/dist/client/assets/ReportsView-DJ8KPr1J.js +1 -0
  8. package/dist/client/assets/RunExecution-BJnn0cq7.js +1 -0
  9. package/dist/client/assets/RunsView-oDa9JyRq.js +1 -0
  10. package/dist/client/assets/SettingsView-BVCLWqOk.js +1 -0
  11. package/dist/client/assets/SpaceView-BxtPCtW1.js +1 -0
  12. package/dist/client/assets/TestEditor-Dthst0HS.js +63 -0
  13. package/dist/client/assets/TestMuImportDialog-B2yx7BdF.js +5 -0
  14. package/dist/client/assets/TrashView-B5uFN2Ua.js +1 -0
  15. package/dist/client/assets/UserGroupsView-MGu6frpT.js +1 -0
  16. package/dist/client/assets/UsersView-DwWeOblN.js +1 -0
  17. package/dist/client/assets/comments-section-CHZSUoK5.js +53 -0
  18. package/dist/client/assets/hooks-BItXZ0yP.js +1 -0
  19. package/dist/client/assets/hooks-BM-wcPhm.js +4 -0
  20. package/dist/client/assets/icons-J9gKYxTz.js +41 -0
  21. package/dist/client/assets/index-CYPrMEmp.css +1 -0
  22. package/dist/client/assets/index-a9kCDHqT.js +7 -0
  23. package/dist/client/assets/markdown-YKl4gdXq.js +29 -0
  24. package/dist/client/assets/radix-ui-Cxk3sw_C.js +41 -0
  25. package/dist/client/assets/react-D-pHAthU.js +40 -0
  26. package/dist/client/assets/tiptap-Ch64zYGz.js +167 -0
  27. package/dist/client/index.html +62 -0
  28. package/dist/index.js +12990 -0
  29. package/dist/server/index.js +16195 -0
  30. package/package.json +124 -0
@@ -0,0 +1,73 @@
1
+ import{r as s,j as e}from"./react-D-pHAthU.js";import{b as V,v as ne,c as Ce,O as re,P as Ve,Q as Xe,z as fe,R as Ze,q as Re,S as pt,F as ut,T as ft,U as he,V as gt,W as et,Y as ht,Z as Ue,N as mt,y as me,_ as tt,o as yt,C as vt,$ as bt,a0 as rt,B as jt,A as St,x as kt,a1 as Ge,a2 as je,a3 as _e,a4 as He,a5 as Se,a6 as ge,J as wt,a7 as zt,f as Ct}from"./icons-J9gKYxTz.js";import{C as Rt}from"./ChatSection-rpiFyFcg.js";import{u as Te,a as st,B as $,b as I,S as H,C as Tt,L as te,I as Q,v as At}from"./index-a9kCDHqT.js";import{a as le,b as ke,c as Z,d as qe,e as It,i as Ft}from"./hooks-BM-wcPhm.js";import"./radix-ui-Cxk3sw_C.js";import"./comments-section-CHZSUoK5.js";import"./tiptap-Ch64zYGz.js";import"./markdown-YKl4gdXq.js";const Dt={pending:{label:"Pending",color:"var(--t-text-muted)"},cloning:{label:"Cloning…",color:"#f59e0b",spin:!0},indexing:{label:"Indexing…",color:"#f59e0b",spin:!0},ready:{label:"Ready",color:"var(--t-accent-success)"},syncing:{label:"Syncing…",color:"#f59e0b",spin:!0},error:{label:"Error",color:"var(--t-accent-danger)"},unknown:{label:"Unknown",color:"var(--t-text-muted)"},not_registered:{label:"Not registered",color:"var(--t-text-muted)"}},Wt={label:"Pending",color:"var(--t-text-muted)"};function Et({status:t}){const n=t&&Dt[t]||Wt,o=t==="ready"?he:t==="error"?re:n.spin?gt:et;return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,fontWeight:600,color:n.color},children:[e.jsx(o,{size:12,weight:t==="ready"||t==="error"?"fill":"regular",style:n.spin?{animation:"ai-spin 1s linear infinite"}:void 0}),n.label]})}function xe(t){try{return new URL(t.trim()).hostname.toLowerCase()}catch{return null}}function it(t){const n=new Set;return t.filter(o=>n.has(o.url)?!1:(n.add(o.url),!0))}function Pt({appId:t,existingRepos:n,onAdded:o,onClose:f,prefillRepo:p}){const d=!!p,[c,g]=s.useState((p==null?void 0:p.url)??""),[h,u]=s.useState(""),[m,i]=s.useState(""),[v,a]=s.useState(""),[k,C]=s.useState(!1),[M,L]=s.useState(""),[E,P]=s.useState(null),R=(()=>{const j=xe(c);return!j||d?[]:it(n.filter(A=>xe(A.url)===j&&A.url.trim()!==c.trim()))})(),D=j=>{if(g(j),E){const A=xe(j);(!A||xe(E.url)!==A)&&P(null)}},B=E!==null||h.trim().length>0,W=d?m.trim().length>0:c.trim().length>0&&B,w=async()=>{if(W){C(!0),L("");try{const j=await I.aiRepos.add(t,{url:c.trim(),gitToken:h.trim()||void 0,borrowTokenFrom:E==null?void 0:E.url,branch:m.trim()||void 0,name:d?p.name:v.trim()||void 0});o(j.repo)}catch(j){L(j.message)}finally{C(!1)}}};return e.jsx("div",{style:{position:"fixed",inset:0,zIndex:200,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.55)"},onClick:j=>{j.target===j.currentTarget&&f()},children:e.jsxs("div",{style:{width:d?400:480,background:"var(--t-bg-panel)",borderRadius:12,border:"1px solid var(--t-border-default)",boxShadow:"0 20px 60px rgba(0,0,0,0.4)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--t-border-subtle)"},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:600,fontSize:"var(--t-text-base)",color:"var(--t-text-primary)"},children:d?"Index another branch":"Register Repo"}),d&&e.jsx("p",{style:{margin:"2px 0 0",fontSize:11,color:"var(--t-text-muted)",fontFamily:"monospace"},children:p.name})]}),e.jsx("button",{onClick:f,style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",padding:4,borderRadius:4},children:e.jsx(V,{size:16})})]}),e.jsxs("div",{style:{padding:"20px",display:"flex",flexDirection:"column",gap:14},children:[d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs(te,{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:["Branch ",e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),e.jsx(Q,{value:m,onChange:j=>i(j.target.value),onKeyDown:j=>{j.key==="Enter"&&w()},placeholder:"e.g. feature/my-branch",autoFocus:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(te,{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:"Git Token"}),e.jsx(Q,{type:"password",value:h,onChange:j=>u(j.target.value),onKeyDown:j=>{j.key==="Enter"&&w()},placeholder:"Leave blank to reuse stored token",style:{fontFamily:"monospace",fontSize:"var(--t-text-sm)"}})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs(te,{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:["Repository URL ",e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),e.jsx(Q,{value:c,onChange:j=>D(j.target.value),placeholder:"https://github.com/org/repo",style:{fontFamily:"monospace",fontSize:"var(--t-text-sm)"},autoFocus:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs(te,{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:["Git Token"," ",!E&&e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),E?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderRadius:8,background:"rgba(34,197,94,0.06)",border:"1px solid rgba(34,197,94,0.25)",fontSize:"var(--t-text-sm)"},children:[e.jsx(he,{size:14,weight:"fill",style:{color:"var(--t-accent-success)",flexShrink:0}}),e.jsxs("span",{style:{flex:1,color:"var(--t-text-primary)"},children:["Using token from ",e.jsx("strong",{children:E.name})]}),e.jsx("button",{onClick:()=>P(null),style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",padding:2,borderRadius:3},title:"Clear — enter a different token",children:e.jsx(V,{size:13})})]}):e.jsx(Q,{type:"password",value:h,onChange:j=>u(j.target.value),placeholder:"Read-only access token",style:{fontFamily:"monospace",fontSize:"var(--t-text-sm)"}}),!E&&R.length>0&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx("p",{style:{margin:0,fontSize:11,color:"var(--t-text-muted)"},children:"Reuse a stored token from the same provider:"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:R.map(j=>e.jsxs("button",{onClick:()=>{P(j),u("")},style:{display:"flex",alignItems:"center",gap:5,padding:"4px 10px",borderRadius:20,border:"1px solid var(--t-border-default)",background:"var(--t-bg-elevated)",color:"var(--t-text-secondary)",fontSize:11,fontWeight:500,cursor:"pointer",transition:"border-color 0.15s, color 0.15s"},onMouseEnter:A=>{A.currentTarget.style.borderColor="var(--t-accent-primary)",A.currentTarget.style.color="var(--t-accent-primary)"},onMouseLeave:A=>{A.currentTarget.style.borderColor="var(--t-border-default)",A.currentTarget.style.color="var(--t-text-secondary)"},children:[e.jsx(ne,{size:10}),j.name]},j.url))})]}),!E&&R.length===0&&e.jsx("p",{style:{margin:0,fontSize:11,color:"var(--t-text-muted)",lineHeight:1.5},children:"Stored securely and reused for all future syncs."})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[e.jsx(te,{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:"Branch"}),e.jsx(Q,{value:m,onChange:j=>i(j.target.value),placeholder:"main"})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[e.jsx(te,{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:"Name"}),e.jsx(Q,{value:v,onChange:j=>a(j.target.value),placeholder:"Derived from URL"})]})]})]}),M&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderRadius:8,background:"rgba(229,72,77,0.08)",border:"1px solid rgba(229,72,77,0.2)",fontSize:"var(--t-text-sm)",color:"var(--t-accent-danger)"},children:[e.jsx(re,{size:13,weight:"fill"}),M]})]}),e.jsxs("div",{style:{padding:"14px 20px",borderTop:"1px solid var(--t-border-subtle)",display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx($,{variant:"outline",onClick:f,children:"Cancel"}),e.jsxs($,{disabled:!W||k,onClick:w,style:{gap:6},children:[e.jsx(fe,{size:14}),k?d?"Indexing…":"Registering…":d?"Index Branch":"Register"]})]})]})})}function Lt({appId:t,repoId:n,repoUrl:o,repoName:f,onDone:p,onClose:d}){const[c,g]=s.useState(""),[h,u]=s.useState(!1),[m,i]=s.useState(""),v=async()=>{if(c.trim()){u(!0),i("");try{await I.aiRepos.updateToken(t,{url:o,gitToken:c.trim()}),await I.aiRepos.sync(t,n,c.trim()),p()}catch(a){i(a.message)}finally{u(!1)}}};return e.jsx("div",{style:{position:"fixed",inset:0,zIndex:200,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.55)"},onClick:a=>{a.target===a.currentTarget&&d()},children:e.jsxs("div",{style:{width:400,background:"var(--t-bg-panel)",borderRadius:12,border:"1px solid var(--t-border-default)",boxShadow:"0 20px 60px rgba(0,0,0,0.4)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--t-border-subtle)"},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:600,fontSize:"var(--t-text-base)",color:"var(--t-text-primary)"},children:"Update Git Token"}),e.jsx("p",{style:{margin:"2px 0 0",fontSize:11,color:"var(--t-text-muted)",fontFamily:"monospace"},children:f})]}),e.jsx("button",{onClick:d,style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",padding:4,borderRadius:4},children:e.jsx(V,{size:16})})]}),e.jsxs("div",{style:{padding:"20px",display:"flex",flexDirection:"column",gap:14},children:[e.jsxs("p",{style:{margin:0,fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",lineHeight:1.5},children:["The new token will be applied to ",e.jsx("strong",{children:"all branches"})," of this repo."]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs(te,{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:["New Git Token ",e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),e.jsx(Q,{type:"password",value:c,onChange:a=>g(a.target.value),onKeyDown:a=>{a.key==="Enter"&&v()},placeholder:"Read-only access token",style:{fontFamily:"monospace",fontSize:"var(--t-text-sm)"},autoFocus:!0})]}),m&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderRadius:8,background:"rgba(229,72,77,0.08)",border:"1px solid rgba(229,72,77,0.2)",fontSize:"var(--t-text-sm)",color:"var(--t-accent-danger)"},children:[e.jsx(re,{size:13,weight:"fill"}),m]})]}),e.jsxs("div",{style:{padding:"14px 20px",borderTop:"1px solid var(--t-border-subtle)",display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx($,{variant:"outline",onClick:d,children:"Cancel"}),e.jsxs($,{disabled:!c.trim()||h,onClick:v,style:{gap:6},children:[e.jsx(ne,{size:14}),h?"Saving…":"Update Token"]})]})]})})}function Nt({appId:t,selectedRepos:n,onDone:o,onClose:f}){const p=it(n),[d,c]=s.useState(""),[g,h]=s.useState(!1),[u,m]=s.useState(null),i=async()=>{if(!d.trim())return;h(!0);const a=await Promise.all(p.map(async k=>{try{return await I.aiRepos.updateToken(t,{url:k.url,gitToken:d.trim()}),{url:k.url,name:k.name,ok:!0}}catch(C){return{url:k.url,name:k.name,ok:!1,error:C.message}}}));h(!1),m(a)},v=u==null?void 0:u.every(a=>a.ok);return e.jsx("div",{style:{position:"fixed",inset:0,zIndex:200,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.55)"},onClick:a=>{a.target===a.currentTarget&&!g&&f()},children:e.jsxs("div",{style:{width:440,background:"var(--t-bg-panel)",borderRadius:12,border:"1px solid var(--t-border-default)",boxShadow:"0 20px 60px rgba(0,0,0,0.4)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--t-border-subtle)"},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:600,fontSize:"var(--t-text-base)",color:"var(--t-text-primary)"},children:"Bulk Update Token"}),e.jsxs("p",{style:{margin:"2px 0 0",fontSize:11,color:"var(--t-text-muted)"},children:[p.length," repo",p.length!==1?"s":""," · all branches will be updated"]})]}),e.jsx("button",{onClick:f,disabled:g,style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",padding:4,borderRadius:4},children:e.jsx(V,{size:16})})]}),e.jsxs("div",{style:{padding:"20px",display:"flex",flexDirection:"column",gap:12},children:[e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,maxHeight:160,overflowY:"auto"},children:p.map(a=>{const k=u==null?void 0:u.find(C=>C.url===a.url);return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",borderRadius:6,background:"var(--t-bg-elevated)",fontSize:"var(--t-text-sm)"},children:[k?k.ok?e.jsx(he,{size:13,weight:"fill",style:{color:"var(--t-accent-success)",flexShrink:0}}):e.jsx(re,{size:13,weight:"fill",style:{color:"var(--t-accent-danger)",flexShrink:0}}):e.jsx(ne,{size:13,style:{color:"var(--t-text-muted)",flexShrink:0}}),e.jsx("span",{style:{flex:1,color:"var(--t-text-primary)",fontWeight:500},children:a.name}),e.jsx("span",{style:{fontSize:10,color:"var(--t-text-muted)",fontFamily:"monospace"},children:xe(a.url)??a.url}),k&&!k.ok&&e.jsx("span",{style:{fontSize:10,color:"var(--t-accent-danger)"},children:k.error})]},a.url)})}),!u&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs(te,{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:["New Git Token ",e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),e.jsx(Q,{type:"password",value:d,onChange:a=>c(a.target.value),onKeyDown:a=>{a.key==="Enter"&&i()},placeholder:"Read-only access token",style:{fontFamily:"monospace",fontSize:"var(--t-text-sm)"},autoFocus:!0})]}),u&&e.jsx("div",{style:{padding:"8px 12px",borderRadius:8,fontSize:"var(--t-text-sm)",background:v?"rgba(34,197,94,0.06)":"rgba(229,72,77,0.06)",border:`1px solid ${v?"rgba(34,197,94,0.25)":"rgba(229,72,77,0.2)"}`,color:v?"var(--t-accent-success)":"var(--t-text-secondary)"},children:v?`Token updated for all ${p.length} repo${p.length!==1?"s":""}.`:`${u.filter(a=>a.ok).length} of ${p.length} succeeded. Failed repos are highlighted above.`})]}),e.jsx("div",{style:{padding:"14px 20px",borderTop:"1px solid var(--t-border-subtle)",display:"flex",justifyContent:"flex-end",gap:8},children:u?e.jsx($,{onClick:o,children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx($,{variant:"outline",onClick:f,disabled:g,children:"Cancel"}),e.jsxs($,{disabled:!d.trim()||g,onClick:i,style:{gap:6},children:[e.jsx(ne,{size:14}),g?"Updating…":`Update ${p.length} Repo${p.length!==1?"s":""}`]})]})})]})})}function Mt({repo:t,canManage:n,syncing:o,bulkMode:f,selected:p,onToggle:d,onSync:c,onRemove:g,onAddBranch:h,onUpdateToken:u}){const m=o||["cloning","indexing","syncing"].includes(t.status??"");return e.jsxs("div",{onClick:f?()=>d(t.id):void 0,style:{padding:"14px 16px",borderRadius:8,border:`1px solid ${p?"var(--t-accent-primary)":"var(--t-border-subtle)"}`,background:p?"rgba(var(--t-accent-primary-rgb, 99,102,241), 0.04)":"var(--t-bg-surface)",display:"flex",flexDirection:"column",gap:10,cursor:f?"pointer":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[f?e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,flexShrink:0,marginTop:1,color:p?"var(--t-accent-primary)":"var(--t-text-muted)"},children:p?e.jsx(Ve,{size:20,weight:"fill"}):e.jsx(Xe,{size:20})}):e.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginTop:1},children:e.jsx(fe,{size:15,style:{color:"var(--t-text-secondary)"}})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontWeight:600,fontSize:"var(--t-text-base)",color:"var(--t-text-primary)"},children:t.name}),e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"1px 6px",borderRadius:4,background:"rgba(255,255,255,0.05)",border:"1px solid var(--t-border-default)",color:"var(--t-text-muted)",letterSpacing:"0.03em"},children:t.branch}),e.jsx(Et,{status:t.status})]}),e.jsx("span",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block"},children:t.url})]}),n&&!f&&e.jsxs("div",{style:{display:"flex",gap:4,flexShrink:0},children:[e.jsxs($,{variant:"outline",size:"sm",disabled:m,onClick:i=>{i.stopPropagation(),c(t)},title:t.status==="pending"?"Re-index with current embedding model":"Sync repo",style:{padding:"4px 8px",height:"auto",gap:4,fontSize:"var(--t-text-xs)"},children:[e.jsx(Ze,{size:12,style:o?{animation:"ai-spin 1s linear infinite"}:void 0}),o?"Starting…":"Sync"]}),e.jsxs($,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation(),h(t)},title:"Index another branch",style:{padding:"4px 8px",height:"auto",gap:4,fontSize:"var(--t-text-xs)"},children:[e.jsx(fe,{size:12}),"Branch"]}),e.jsxs($,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation(),u(t)},title:"Update git token for all branches of this repo",style:{padding:"4px 8px",height:"auto",gap:4,fontSize:"var(--t-text-xs)"},children:[e.jsx(ne,{size:12}),"Token"]}),e.jsx("button",{onClick:i=>{i.stopPropagation(),g(t.id)},title:"Remove repo",style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",padding:"4px 6px",borderRadius:4},onMouseEnter:i=>{i.currentTarget.style.color="var(--t-accent-danger)"},onMouseLeave:i=>{i.currentTarget.style.color="var(--t-text-muted)"},children:e.jsx(Re,{size:13})})]})]}),t.status==="indexing"&&t.progress!=null&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[e.jsx("div",{style:{height:4,borderRadius:99,background:"var(--t-border-subtle)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:99,background:"#f59e0b",width:`${t.progress.pct}%`,transition:"width 0.4s ease"}})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:10,color:"var(--t-text-muted)"},children:[e.jsxs("span",{children:[t.progress.chunks.toLocaleString()," / ",t.progress.total.toLocaleString()," ","chunks"]}),e.jsxs("span",{children:[t.progress.pct,"%"]})]})]}),t.status==="error"&&t.errorMessage&&e.jsx("div",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-accent-danger)",padding:"6px 10px",borderRadius:6,background:"rgba(229,72,77,0.06)",border:"1px solid rgba(229,72,77,0.15)"},children:t.errorMessage}),t.status==="ready"&&t.totalFiles!=null&&e.jsxs("div",{style:{display:"flex",gap:16,paddingTop:4,borderTop:"1px solid var(--t-border-subtle)"},children:[t.totalFiles!=null&&e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:11,color:"var(--t-text-muted)"},children:[e.jsx(pt,{size:11}),t.totalFiles.toLocaleString()," files"]}),t.totalChunks!=null&&e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:11,color:"var(--t-text-muted)"},children:[e.jsx(ut,{size:11}),t.totalChunks.toLocaleString()," chunks"]}),t.lastCommit&&e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:11,color:"var(--t-text-muted)",fontFamily:"monospace"},children:[e.jsx(ft,{size:11}),t.lastCommit.slice(0,8)]}),t.lastSyncedAt&&e.jsxs("span",{style:{fontSize:11,color:"var(--t-text-muted)",marginLeft:"auto"},children:["Synced ",new Date(t.lastSyncedAt).toLocaleDateString()]})]})]})}function Bt({appId:t,aiConfigured:n,onHeaderActions:o}){const{authUser:f}=Te(),{isAdmin:p}=st(t),d=p||(f==null?void 0:f.globalRole)==="super_admin",[c,g]=s.useState(()=>le.get(t)??[]),[h,u]=s.useState(()=>!le.has(t)),[m,i]=s.useState(""),[v,a]=s.useState(!1),[k,C]=s.useState(new Set),[M,L]=s.useState(null),[E,P]=s.useState(null),[R,D]=s.useState(null),[B,W]=s.useState(!1),[w,j]=s.useState(new Set),[A,q]=s.useState(!1),K=()=>{W(!1),j(new Set)};s.useEffect(()=>{if(!o||!d||!n){o==null||o(null);return}o(B?e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs($,{variant:"outline",onClick:K,style:{gap:6},children:[e.jsx(V,{size:14}),"Cancel"]}),e.jsxs($,{disabled:w.size===0,onClick:()=>q(!0),style:{gap:6},children:[e.jsx(ne,{size:14}),"Update Token",w.size>0?` (${w.size})`:""]})]}):e.jsxs("div",{style:{display:"flex",gap:8},children:[c.length>0&&e.jsxs($,{variant:"outline",onClick:()=>W(!0),style:{gap:6},children:[e.jsx(ne,{size:14}),"Update Tokens"]}),e.jsxs($,{onClick:()=>{P(null),a(!0)},style:{gap:6},children:[e.jsx(Ce,{size:14}),"Add Repo"]})]}))},[o,d,n,B,w.size,c.length]),s.useEffect(()=>()=>{o==null||o(null)},[o]);const y=S=>j(N=>{const U=new Set(N);return U.has(S)?U.delete(S):U.add(S),U}),_=()=>j(w.size===c.length?new Set:new Set(c.map(S=>S.id))),ae=c.filter(S=>w.has(S.id)),x=s.useRef(null),b=s.useCallback(async()=>{try{const S=await I.aiRepos.list(t);le.set(t,S.repos),g(S.repos),i("")}catch(S){i(S.message)}},[t]);s.useEffect(()=>{le.has(t)||u(!0),b().finally(()=>u(!1))},[b]),s.useEffect(()=>{const S=c.some(N=>N.status==="cloning"||N.status==="indexing"||N.status==="syncing");return S&&!x.current?x.current=setInterval(b,4e3):!S&&x.current&&(clearInterval(x.current),x.current=null),()=>{x.current&&(clearInterval(x.current),x.current=null)}},[c,b]);const F=S=>{g(N=>{const Y=N.findIndex(se=>se.id===S.id)>=0?N.map(se=>se.id===S.id?S:se):[S,...N];return le.set(t,Y),Y}),a(!1),P(null)},J=S=>{P({url:S.url,name:S.name}),a(!0)},O=S=>{D(S)},ye=async S=>{C(N=>new Set(N).add(S.id));try{await I.aiRepos.sync(t,S.id),await b()}catch(N){alert(N.message)}finally{C(N=>{const U=new Set(N);return U.delete(S.id),U})}},oe=S=>{const N=c.find(U=>U.id===S);N&&L(N)},pe=async()=>{if(!M)return;const S=M.id;L(null);try{await I.aiRepos.remove(t,S),g(N=>{const U=N.filter(Y=>Y.id!==S);return le.set(t,U),U})}catch(N){alert(N.message)}};return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
2
+ @keyframes ai-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
3
+ `}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"28px 32px",display:"flex",flexDirection:"column",gap:20},children:[!n&&e.jsxs("div",{style:{padding:"14px 16px",borderRadius:8,background:"rgba(180,83,9,0.06)",border:"1px solid rgba(180,83,9,0.2)",fontSize:"var(--t-text-sm)",color:"var(--t-accent-warning)"},children:["No AI connection is configured for this app. Set one in ",e.jsx("strong",{children:"AI → Settings"})," ","first."]}),n&&(h?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[0,1,2].map(S=>e.jsxs("div",{style:{padding:"14px 16px",borderRadius:8,border:"1px solid var(--t-border-subtle)",background:"var(--t-bg-surface)",display:"flex",gap:10},children:[e.jsx(H,{width:32,height:32,borderRadius:8,style:{flexShrink:0}}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[e.jsx(H,{height:12,width:`${40+S*12}%`,borderRadius:3}),e.jsx(H,{height:10,width:`${55+S*8}%`,borderRadius:3})]})]},S))}):m?e.jsxs("div",{style:{padding:"12px 16px",borderRadius:8,background:"rgba(229,72,77,0.06)",border:"1px solid rgba(229,72,77,0.2)",fontSize:"var(--t-text-sm)",color:"var(--t-accent-danger)",display:"flex",gap:8,alignItems:"center"},children:[e.jsx(re,{size:14,weight:"fill"}),m]}):c.length===0?e.jsxs("div",{style:{padding:"32px 16px",textAlign:"center",color:"var(--t-text-muted)",fontSize:"var(--t-text-sm)"},children:["No repos registered yet.",d?' Click "Add Repo" to get started.':""]}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[B&&e.jsxs("div",{onClick:_,style:{display:"flex",alignItems:"center",gap:8,padding:"6px 4px",cursor:"pointer",userSelect:"none"},children:[e.jsx("span",{style:{color:w.size===c.length?"var(--t-accent-primary)":"var(--t-text-muted)"},children:w.size===c.length?e.jsx(Ve,{size:18,weight:"fill"}):e.jsx(Xe,{size:18})}),e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:w.size===c.length?"Deselect all":"Select all"}),w.size>0&&e.jsxs("span",{style:{fontSize:11,color:"var(--t-text-muted)"},children:["— ",w.size," selected"]})]}),c.map(S=>e.jsx(Mt,{repo:S,canManage:d,syncing:k.has(S.id),bulkMode:B,selected:w.has(S.id),onToggle:y,onSync:ye,onRemove:oe,onAddBranch:J,onUpdateToken:O},S.id))]}))]}),v&&e.jsx(Pt,{appId:t,existingRepos:c,onAdded:F,onClose:()=>{a(!1),P(null)},prefillRepo:E??void 0}),R&&e.jsx(Lt,{appId:t,repoId:R.id,repoUrl:R.url,repoName:R.name,onDone:()=>{D(null),b()},onClose:()=>D(null)}),A&&e.jsx(Nt,{appId:t,selectedRepos:ae,onDone:()=>{q(!1),K()},onClose:()=>q(!1)}),e.jsx(Tt,{open:!!M,title:"Remove repo",description:`Remove "${M==null?void 0:M.name}" from the index? This cannot be undone.`,confirmLabel:"Remove",onConfirm:pe,onCancel:()=>L(null)})]})}const $t=[{id:"recent",label:"Recent"},{id:"inprogress",label:"In Progress"},{id:"filters",label:"Filters"},{id:"completed",label:"Completed"}],nt={"To Do":"var(--t-text-muted)","In Progress":"#f59e0b",Done:"var(--t-accent-success)"},Ot={Highest:"#ef4444",High:"#f97316",Medium:"#f59e0b",Low:"#60a5fa",Lowest:"var(--t-text-muted)"};function Ut({category:t}){const n=nt[t]??"var(--t-text-muted)",o=t==="Done"?he:t==="In Progress"?rt:et;return e.jsx(o,{size:13,weight:t==="Done"?"fill":"regular",style:{color:n,flexShrink:0}})}function Gt({ticket:t}){const n=t.priority?Ot[t.priority]??"var(--t-text-muted)":void 0,o=nt[t.statusCategory]??"var(--t-text-muted)";return e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none",display:"block"},children:e.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,border:"1px solid var(--t-border-subtle)",background:"var(--t-bg-surface)",display:"flex",flexDirection:"column",gap:6,transition:"border-color 0.15s",cursor:"pointer"},onMouseEnter:f=>{f.currentTarget.style.borderColor="var(--t-border-default)"},onMouseLeave:f=>{f.currentTarget.style.borderColor="var(--t-border-subtle)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:11,fontWeight:700,color:"var(--t-accent-primary)",fontFamily:"monospace",flexShrink:0},children:t.key}),e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"1px 6px",borderRadius:4,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",color:"var(--t-text-muted)",letterSpacing:"0.03em"},children:t.issueType}),t.priority&&e.jsx("span",{style:{fontSize:10,color:n,fontWeight:600,marginLeft:"auto"},children:t.priority})]}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-primary)",lineHeight:1.4},children:t.summary}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:11,color:o,fontWeight:500},children:[e.jsx(Ut,{category:t.statusCategory}),t.status]}),t.assignee&&e.jsx("span",{style:{fontSize:11,color:"var(--t-text-muted)"},children:t.assignee}),e.jsx("span",{style:{fontSize:11,color:"var(--t-text-muted)",marginLeft:"auto"},children:new Date(t.updated).toLocaleDateString()}),e.jsx(tt,{size:11,style:{color:"var(--t-text-muted)",flexShrink:0}})]})]})})}function _t({appId:t,canManage:n,jiraConnected:o}){const[f,p]=s.useState(()=>Z.get(t)??[]),[d,c]=s.useState(()=>!Z.has(t)),[g,h]=s.useState(()=>{var x,b;return((b=(x=Z.get(t))==null?void 0:x[0])==null?void 0:b.id)??null}),[u,m]=s.useState(!1),[i,v]=s.useState(""),[a,k]=s.useState(!1),[C,M]=s.useState(""),[L,E]=s.useState([]),[P,R]=s.useState(0),[D,B]=s.useState(!1),[W,w]=s.useState(""),[j,A]=s.useState(()=>{var x,b;return((b=(x=Z.get(t))==null?void 0:x[0])==null?void 0:b.name)??null});s.useEffect(()=>{if(!o){c(!1);return}Z.has(t)||c(!0),I.jiraTickets.listFilters(t).then(x=>{Z.set(t,x.filters),p(x.filters),x.filters.length&&(h(b=>b??x.filters[0].id),A(b=>b??x.filters[0].name??null))}).catch(()=>{}).finally(()=>c(!1))},[t,o]);const q=s.useCallback(async(x,b=!1)=>{const F=It(t,x),J=b?void 0:qe.get(F);J&&(E(J.tickets),R(J.total),A(J.filterName)),B(!J),w("");try{const O=await I.jiraTickets.getTickets(t,x);qe.set(F,{tickets:O.tickets,total:O.total,filterName:O.filterName}),E(O.tickets),R(O.total),A(O.filterName)}catch(O){w(O.message)}finally{B(!1)}},[t]);s.useEffect(()=>{g?q(g):(E([]),R(0))},[g,q]);const K=x=>{h(x.id),A(x.name??null)},y=async()=>{const x=i.trim();if(x){k(!0),M("");try{const F=(await I.jiraTickets.addFilter(t,x)).filter;p(J=>{const O=[...J,F];return Z.set(t,O),O}),h(F.id),A(F.name??null),v(""),m(!1)}catch(b){M(b.message)}finally{k(!1)}}},_=()=>{m(!1),v(""),M("")},ae=async x=>{try{await I.jiraTickets.removeFilter(t,x);const b=f.filter(F=>F.id!==x);if(Z.set(t,b),Ft(t,x),p(b),g===x){const F=b[0]??null;h((F==null?void 0:F.id)??null),A((F==null?void 0:F.name)??null)}}catch{}};return o?e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",gap:0},children:[u&&e.jsx("div",{style:{position:"fixed",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--t-overlay)"},onClick:x=>{x.target===x.currentTarget&&_()},children:e.jsxs("div",{style:{width:480,background:"var(--t-bg-panel)",borderRadius:12,border:"1px solid var(--t-border-default)",boxShadow:"var(--t-shadow-lg)",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"20px 24px 0",display:"flex",flexDirection:"column",gap:4},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(Ue,{size:16,style:{color:"var(--t-accent-primary)"}})}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-base)",fontWeight:600,color:"var(--t-text-primary)"},children:"Add Jira Filter"}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"Connect a saved Jira filter to view its tickets here"})]})]})}),e.jsxs("div",{style:{margin:"16px 24px",padding:"14px 16px",borderRadius:8,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-subtle)",display:"flex",flexDirection:"column",gap:10},children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",fontWeight:700,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"What is a Jira Filter?"}),e.jsxs("p",{style:{margin:0,fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.6},children:["A ",e.jsx("strong",{style:{color:"var(--t-text-primary)"},children:"Jira Filter"}),' is a saved JQL query in your Jira project. It lets you define a specific set of issues — for example "all open bugs assigned to me" or "current sprint tasks" — and save it with a name for reuse.']}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",fontWeight:600,color:"var(--t-text-secondary)"},children:"How to find the Filter ID:"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:["Go to your Jira project and open a saved filter","Look at the URL in your browser address bar","The number after ?filter= is your Filter ID"].map((x,b)=>e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"flex-start"},children:[e.jsx("span",{style:{width:16,height:16,borderRadius:"50%",background:"var(--t-border-default)",fontSize:10,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"var(--t-text-secondary)",marginTop:1},children:b+1}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",lineHeight:1.5},children:x})]},b))}),e.jsxs("div",{style:{marginTop:4,padding:"6px 10px",borderRadius:6,background:"var(--t-bg-panel)",border:"1px solid var(--t-border-default)",fontFamily:"monospace",fontSize:11,color:"var(--t-text-muted)"},children:["your-company.atlassian.net/issues/?filter=",e.jsx("strong",{style:{color:"var(--t-accent-primary)"},children:"12345"})]})]})]}),e.jsxs("div",{style:{padding:"0 24px",display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs("label",{style:{fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)"},children:["Filter ID ",e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),e.jsx(Q,{value:i,onChange:x=>v(x.target.value.replace(/\D/g,"")),onKeyDown:x=>{x.key==="Enter"&&y(),x.key==="Escape"&&_()},placeholder:"e.g. 12345",style:{fontFamily:"monospace"},autoFocus:!0}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"We'll automatically fetch the filter name from Jira."})]}),C&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderRadius:8,background:"rgba(229,72,77,0.08)",border:"1px solid rgba(229,72,77,0.2)",fontSize:"var(--t-text-sm)",color:"var(--t-accent-danger)"},children:[e.jsx(re,{size:13,weight:"fill",style:{flexShrink:0}}),C]})]}),e.jsxs("div",{style:{padding:"16px 24px 20px",display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx($,{variant:"outline",onClick:_,children:"Cancel"}),e.jsxs($,{onClick:y,disabled:!i.trim()||a,style:{gap:6},children:[e.jsx(mt,{size:14}),a?"Adding…":"Add Filter"]})]})]})}),e.jsxs("div",{style:{width:240,flexShrink:0,borderRight:"1px solid var(--t-border-subtle)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[n&&e.jsx("div",{style:{padding:"10px 12px",borderBottom:"1px solid var(--t-border-subtle)",flexShrink:0},children:e.jsxs($,{variant:"outline",onClick:()=>m(!0),style:{width:"100%",gap:6,justifyContent:"center"},children:[e.jsx(Ce,{size:13}),"Add Filter"]})}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"8px"},children:[d&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"4px 4px"},children:[0,1,2].map(x=>e.jsx(H,{height:40,borderRadius:6},x))}),!d&&f.length===0&&e.jsxs("p",{style:{padding:"12px 8px",margin:0,fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",lineHeight:1.5},children:["No filters yet.",n?" Add one above.":""]}),!d&&f.map(x=>{const b=x.id===g;return e.jsxs("div",{onClick:()=>K(x),style:{display:"flex",alignItems:"center",gap:8,padding:"7px 10px",borderRadius:6,cursor:"pointer",background:b?"var(--t-bg-elevated)":"transparent",marginBottom:2},onMouseEnter:F=>{b||(F.currentTarget.style.background="var(--t-bg-elevated)")},onMouseLeave:F=>{b||(F.currentTarget.style.background="transparent")},children:[e.jsx(Ue,{size:13,weight:b?"fill":"regular",style:{color:b?"var(--t-accent-primary)":"var(--t-text-muted)",flexShrink:0}}),e.jsx("div",{style:{flex:1,minWidth:0},children:x.name?e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",fontWeight:b?600:400,color:b?"var(--t-text-primary)":"var(--t-text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.name}),e.jsx("p",{style:{margin:0,fontSize:10,color:"var(--t-text-muted)",fontFamily:"monospace"},children:x.id})]}):e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",fontWeight:b?600:400,color:b?"var(--t-text-primary)":"var(--t-text-secondary)",fontFamily:"monospace"},children:x.id})}),n&&e.jsx("button",{onClick:F=>{F.stopPropagation(),ae(x.id)},style:{background:"none",border:"none",padding:2,cursor:"pointer",color:"var(--t-text-muted)",opacity:0,transition:"opacity 0.15s",borderRadius:4,display:"flex",alignItems:"center"},onMouseEnter:F=>{F.currentTarget.style.opacity="1",F.currentTarget.style.color="var(--t-accent-danger)"},onMouseLeave:F=>{F.currentTarget.style.opacity="0"},children:e.jsx(Re,{size:12})})]},x.id)})]})]}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:g?e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px",display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx("div",{children:j?e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-base)",fontWeight:600,color:"var(--t-text-primary)"},children:j}),e.jsxs("p",{style:{margin:0,fontSize:11,color:"var(--t-text-muted)",fontFamily:"monospace",marginTop:2},children:["filter/",g,P>0&&e.jsxs("span",{style:{marginLeft:8,fontFamily:"inherit"},children:["· ",P," issue",P!==1?"s":"",P>L.length?` (showing ${L.length})`:""]})]})]}):e.jsxs("p",{style:{margin:0,fontSize:"var(--t-text-base)",fontWeight:600,color:"var(--t-text-primary)",fontFamily:"monospace"},children:["filter/",g,P>0&&e.jsxs("span",{style:{marginLeft:8,fontSize:"var(--t-text-sm)",fontFamily:"inherit",fontWeight:400,color:"var(--t-text-muted)"},children:["· ",P," issue",P!==1?"s":""]})]})}),e.jsxs($,{variant:"outline",onClick:()=>q(g,!0),disabled:D,style:{gap:6,flexShrink:0},children:[e.jsx(Ze,{size:14,style:D?{animation:"jira-spin 1s linear infinite"}:void 0}),"Refresh"]})]}),D&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[0,1,2,3].map(x=>e.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,border:"1px solid var(--t-border-subtle)",background:"var(--t-bg-surface)",display:"flex",flexDirection:"column",gap:8},children:[e.jsx(H,{height:11,width:`${30+x*10}%`,borderRadius:3}),e.jsx(H,{height:13,width:`${60+x*8}%`,borderRadius:3}),e.jsx(H,{height:10,width:`${40+x*6}%`,borderRadius:3})]},x))}),!D&&W&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"12px 14px",borderRadius:8,background:"rgba(229,72,77,0.06)",border:"1px solid rgba(229,72,77,0.2)",fontSize:"var(--t-text-sm)",color:"var(--t-accent-danger)"},children:[e.jsx(re,{size:14,weight:"fill",style:{flexShrink:0}}),W]}),!D&&!W&&L.length===0&&e.jsxs("div",{style:{padding:"40px 16px",textAlign:"center",color:"var(--t-text-muted)"},children:[e.jsx(me,{size:28,style:{opacity:.3,display:"block",margin:"0 auto 10px"}}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)"},children:"No tickets found in this filter."})]}),!D&&!W&&L.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:L.map(x=>e.jsx(Gt,{ticket:x},x.key))})]}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("p",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)"},children:f.length===0?"Add a filter to get started.":"Select a filter to view tickets."})})})]}):e.jsxs("div",{style:{display:"flex",gap:12,padding:"16px 18px",borderRadius:10,border:"1px solid rgba(180,83,9,0.25)",background:"rgba(180,83,9,0.06)",alignItems:"flex-start"},children:[e.jsx(ht,{size:18,weight:"fill",style:{color:"var(--t-accent-warning)",flexShrink:0,marginTop:1}}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:"0 0 4px",fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-accent-warning)"},children:"Jira not connected"}),e.jsxs("p",{style:{margin:0,fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",lineHeight:1.5},children:["Configure your Jira credentials in"," ",e.jsx("strong",{style:{color:"var(--t-text-secondary)"},children:"Settings → Integrations"}),"."]})]})]})}function Ht(t){const n=Date.now()-new Date(t).getTime(),o=Math.floor(n/6e4);if(o<1)return"just now";if(o<60)return`${o}m ago`;const f=Math.floor(o/60);if(f<24)return`${f}h ago`;const p=Math.floor(f/24);return p<30?`${p}d ago`:new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Ke(t){window.history.pushState(t,"",At(t)),window.dispatchEvent(new PopStateEvent("popstate",{state:t}))}function we({label:t,status:n,icon:o,onClick:f}){const[p,d]=s.useState(!1),c=n==="published"?"var(--t-accent-success)":n==="archived"?"#f59e0b":"var(--t-text-muted)",g=n==="published"?p?"rgba(34,197,94,0.18)":"rgba(34,197,94,0.1)":n==="archived"?p?"rgba(245,158,11,0.18)":"rgba(245,158,11,0.1)":p?"var(--t-bg-muted)":"transparent",h=n==="published"?"rgba(34,197,94,0.3)":n==="archived"?"rgba(245,158,11,0.3)":"var(--t-border-subtle)";return e.jsxs("span",{onClick:f,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:4,fontSize:"var(--t-text-xs)",fontWeight:500,color:c,background:g,border:`1px solid ${h}`,cursor:f?"pointer":"default",transition:"background 0.1s",userSelect:"none"},children:[o,t]})}function qt({row:t,appId:n}){var g,h;const o=!!((g=t.plan)!=null&&g.planData),f=!!((h=t.plan)!=null&&h.testNotes),p=()=>{t.analysis&&Ke({type:"analysis-detail",appId:n,analysisId:t.analysis.id})},d=()=>{Ke({type:"plan-detail",appId:n,planId:t.plan.id})},c=e.jsx("span",{style:{fontSize:12,color:"var(--t-text-muted)"},children:"—"});return e.jsxs("tr",{style:{borderBottom:"1px solid var(--t-border-subtle)"},children:[e.jsx("td",{style:{padding:"10px 16px",whiteSpace:"nowrap"},children:e.jsx("code",{style:{fontSize:12,fontWeight:700,color:"var(--t-text-primary)",fontFamily:"monospace"},children:t.ticketId})}),e.jsx("td",{style:{padding:"10px 16px",maxWidth:320},children:e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:t.ticketSummary||"—"})}),e.jsx("td",{style:{padding:"10px 16px",whiteSpace:"nowrap"},children:t.analysis?e.jsx(we,{label:"Analysis",status:t.analysis.status,icon:e.jsx(yt,{size:11}),onClick:p}):c}),e.jsx("td",{style:{padding:"10px 16px",whiteSpace:"nowrap"},children:o?e.jsx(we,{label:"Test Plan",status:t.plan.status,icon:e.jsx(vt,{size:11}),onClick:d}):c}),e.jsx("td",{style:{padding:"10px 16px",whiteSpace:"nowrap"},children:f?e.jsx(we,{label:"Notes",status:t.plan.status,icon:e.jsx(bt,{size:11}),onClick:d}):c}),e.jsx("td",{style:{padding:"10px 16px",whiteSpace:"nowrap"},children:e.jsx("span",{style:{fontSize:12,color:"var(--t-text-muted)"},children:Ht(t.updatedAt)})})]})}function Kt({appId:t}){const[n,o]=s.useState([]),[f,p]=s.useState(!0),[d,c]=s.useState(null);return s.useEffect(()=>{p(!0),c(null),Promise.all([I.analyses.list(t).catch(()=>[]),I.plans.list(t).catch(()=>[])]).then(([g,h])=>{const u=new Map;for(const i of g){const v=u.get(i.ticketId);v?((!v.analysis||i.updatedAt>v.analysis.updatedAt)&&(v.analysis=i),i.updatedAt>v.updatedAt&&(v.updatedAt=i.updatedAt)):u.set(i.ticketId,{ticketId:i.ticketId,ticketSummary:i.ticketSummary,analysis:i,plan:null,updatedAt:i.updatedAt})}for(const i of h){const v=u.get(i.ticketId);v?((!v.plan||i.updatedAt>v.plan.updatedAt)&&(v.plan=i),i.updatedAt>v.updatedAt&&(v.updatedAt=i.updatedAt),v.ticketSummary||(v.ticketSummary=i.ticketSummary)):u.set(i.ticketId,{ticketId:i.ticketId,ticketSummary:i.ticketSummary,analysis:null,plan:i,updatedAt:i.updatedAt})}const m=[...u.values()].sort((i,v)=>v.updatedAt.localeCompare(i.updatedAt));o(m),p(!1)}).catch(()=>{c("Failed to load tickets"),p(!1)})},[t]),f?e.jsx("div",{style:{padding:"12px 16px",display:"flex",flexDirection:"column",gap:10},children:[0,1,2,3,4].map(g=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[e.jsx(H,{width:72,height:11,borderRadius:3}),e.jsx(H,{width:`${25+g*9}%`,height:10,borderRadius:3}),e.jsx(H,{width:60,height:16,borderRadius:4}),e.jsx(H,{width:52,height:10,borderRadius:3})]},g))}):d?e.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6,color:"var(--t-accent-danger)",fontSize:"var(--t-text-sm)"},children:[e.jsx(re,{size:15}),d]}):n.length===0?e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10,color:"var(--t-text-muted)",padding:"0 32px",textAlign:"center"},children:[e.jsx(me,{size:32,style:{opacity:.2}}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",maxWidth:320},children:"No tickets yet. Save an analysis or test plan from the chat window to see it here."})]}):e.jsx("div",{style:{flex:1,overflowY:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsx("tr",{style:{borderBottom:"1px solid var(--t-border-subtle)",background:"var(--t-bg-panel)"},children:["Ticket","Summary","Analysis","Test Plan","Notes","Updated"].map(g=>e.jsx("th",{style:{padding:"8px 16px",textAlign:"left",fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--t-text-muted)",whiteSpace:"nowrap"},children:g},g))})}),e.jsx("tbody",{children:n.map(g=>e.jsx(qt,{row:g,appId:t},g.ticketId))})]})})}function Je({label:t}){return e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10,color:"var(--t-text-muted)"},children:[e.jsx(me,{size:32,style:{opacity:.2}}),e.jsxs("p",{style:{margin:0,fontSize:"var(--t-text-sm)"},children:[t," — coming soon"]})]})}function Jt({appId:t,onHeaderActions:n}){const{authUser:o}=Te(),{isAdmin:f}=st(t),p=f||(o==null?void 0:o.globalRole)==="super_admin",[d,c]=s.useState(()=>{const a=new URLSearchParams(window.location.search).get("tab");return a==="recent"||a==="inprogress"||a==="filters"||a==="completed"?a:"recent"}),[g,h]=s.useState(()=>{const a=ke.get(t);return a!==void 0?a:"loading"});s.useEffect(()=>{I.integrations.list(t).then(a=>{const k=a.find(C=>C.type==="jira")??null;ke.set(t,k),h(k)}).catch(()=>{ke.has(t)||h(null)})},[t]),s.useEffect(()=>{n==null||n(null)},[n]),s.useEffect(()=>()=>{n==null||n(null)},[n]);const u=g==="loading",m=g!=="loading"?g:null,i=m?m.config:null,v=!!(m&&(i!=null&&i.host)&&(i!=null&&i.email)&&(i!=null&&i.token));return e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsx("style",{children:"@keyframes jira-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }"}),e.jsxs("div",{style:{display:"flex",flexShrink:0},children:[$t.map(a=>{const k=d===a.id;return e.jsx("button",{onClick:()=>{c(a.id);const C=new URLSearchParams(window.location.search);C.set("tab",a.id),window.history.replaceState(null,"",`${window.location.pathname}?${C.toString()}`)},style:{background:"none",border:"none",borderBottom:k?"2px solid var(--t-accent-primary)":"1px solid var(--t-border-subtle)",padding:k?"10px 16px":"10px 16px 11px",cursor:"pointer",fontSize:"var(--t-text-sm)",fontWeight:k?600:400,color:k?"var(--t-text-primary)":"var(--t-text-muted)",whiteSpace:"nowrap"},onMouseEnter:C=>{k||(C.currentTarget.style.color="var(--t-text-secondary)")},onMouseLeave:C=>{k||(C.currentTarget.style.color="var(--t-text-muted)")},children:a.label},a.id)}),e.jsx("div",{style:{flex:1,borderBottom:"1px solid var(--t-border-subtle)"}})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[u&&e.jsx("div",{style:{padding:"24px 32px",display:"flex",flexDirection:"column",gap:8},children:[0,1,2].map(a=>e.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,border:"1px solid var(--t-border-subtle)",background:"var(--t-bg-surface)"},children:[e.jsx(H,{height:12,width:`${40+a*15}%`,borderRadius:3,style:{marginBottom:8}}),e.jsx(H,{height:10,width:`${60+a*8}%`,borderRadius:3})]},a))}),!u&&d==="filters"&&e.jsx(_t,{appId:t,canManage:p,jiraConnected:v}),!u&&d==="recent"&&e.jsx(Kt,{appId:t}),!u&&d==="inprogress"&&e.jsx(Je,{label:"In Progress"}),!u&&d==="completed"&&e.jsx(Je,{label:"Completed"})]})]})}const Yt=`## Strategy
4
+ Who tests, how, and in what environment. Reference the user role and navigation path from the ticket.
5
+
6
+ ## Requirements to Test
7
+ Bulleted list of every acceptance criterion and requirement from the Jira ticket.
8
+
9
+ ## Functionality
10
+ What to test based on what the MR actually changed. Tie each test item to a changed file or AC.
11
+
12
+ ## Regressions
13
+ Areas that could regress as a side effect of the MR changes. Reference impacted files.
14
+
15
+ ## Non-Functional
16
+ Usability, accessibility (WCAG AA), performance, design consistency concerns.
17
+
18
+ ## Automation
19
+ What can be unit tested, integration tested, and E2E tested. Be specific about what layers.
20
+
21
+ ## Test Data
22
+ Required users, roles, content, permissions, or configurations.
23
+
24
+ ## Environments & Platforms
25
+ Which environments and browsers/devices to test on.
26
+
27
+ ## Blockers & Gaps
28
+ Any requirements not yet implemented, missing test data, or unclear specifications.
29
+
30
+ ## Important Notes
31
+ Caveats, gotchas, partial implementations, or out-of-scope items that look in-scope.`,Qt=`## Testing Focus
32
+ Brief 2–3 sentence summary of what this change is and what testing should focus on.
33
+
34
+ ## Priority
35
+
36
+ **P1 — Core Changes** _(must test before sign-off)_
37
+ - <test item tied directly to an AC or changed file>
38
+ - <test item>
39
+
40
+ **P2 — Impacted Areas** _(test for side effects)_
41
+ - <regression test item>
42
+ - <test item>
43
+
44
+ **P3 — Edge Cases & Regressions** _(test if time allows)_
45
+ - <edge case>
46
+ - <regression>
47
+
48
+ ## Risk Areas
49
+ - <specific risk from the MR changes>
50
+ - <risk>
51
+
52
+ ## Quick Smoke Test
53
+ 3–5 fast checks to verify the basics work after a deploy.`,ze=[{id:"builtin-agent-requirements-analyst",label:"Requirements Analyst",description:"Extracts explicit, implicit, missing, and ambiguous requirements.",guidance:`- explicit: direct, unambiguous requirements stated in the ticket. source = which field. If no formal requirements are written, derive from title and linked tickets.
54
+ - implicit: assumptions the ticket makes but does not state. ALWAYS include at minimum: behaviour when the feature/flag is OFF or disabled, error handling and fallback states, backwards compatibility for existing users, UX consistency with surrounding components, any auth/permission implications.
55
+ - missing: decisions that must be made before implementation begins but are not addressed. ALWAYS include at minimum: who owns the rollout decision, whether a feature flag or config value controls enablement, and any data migration or default-state concern.
56
+ - ambiguous: requirements that exist but are unclear. clarification = what specific question needs answering.`},{id:"builtin-agent-impact-analyst",label:"Impact Analyst",description:"Assesses impacted areas, dependency risks, edge cases, and regressions.",guidance:`- areas: each functional area touched. files = real file paths found in the Code Analysis.
57
+ - dependencyRisks: internal/external dependencies that could break. severity = high/medium/low.
58
+ - configConcerns: env vars, feature flags, config files that need changes.
59
+ - compatibilityIssues: breaking = true if the change breaks an existing contract.
60
+ - infrastructureConcerns: deployment, scaling, caching, CDN, queue, observability implications.
61
+ - hiddenEdgeCases: non-obvious scenarios not covered by acceptance criteria.
62
+ - testGaps: existing test files needing update OR areas with zero coverage.
63
+ - regressionRisks: parts most likely to regress as a side effect.`},{id:"builtin-agent-feasibility-analyst",label:"Feasibility Analyst",description:"Assesses complexity, testability, blockers, and technical risks.",guidance:`- complexity: Low / Medium / High / Very High based on scope, files touched, and dependency depth.
64
+ - complexityReason: explain the primary complexity drivers; cite specific files/patterns from the Code Analysis.
65
+ - testability.unit/integration/e2e: what can be meaningfully tested at each level.
66
+ - testability.difficult: what is genuinely hard to automate and why.
67
+ - blockers: hard blockers that must be resolved before work begins. unblockNeeded = what is required to resolve.
68
+ - risks: technical, integration, and delivery risks with likelihood, impact, and mitigation.`},{id:"builtin-agent-gaps-analyst",label:"Gaps & Unknowns Analyst",description:"Identifies confirmed facts, open unknowns, and working assumptions.",guidance:`- knownFacts: definitively confirmed from the ticket and codebase. ALWAYS include at minimum: what was confirmed in the codebase, which files are the entry points, what pattern the change follows.
69
+ - unknowns: open questions needing investigation or stakeholder decisions. ALWAYS include at minimum: rollout/rollback plan, monitoring and observability after the change, any behaviour the ticket does not specify.
70
+ - assumptions: statements treated as true but not verified from the ticket. ALWAYS include at minimum: scope assumptions (what is NOT changing), any environment or config assumptions, what could not be verified from codebase search results alone.`},{id:"builtin-agent-highlights-analyst",label:"Highlights Analyst",description:"Synthesises the most critical key points for engineers and QA leads.",guidance:`- 5–7 concise bullet strings covering the most critical things an engineer and QA lead must know.
71
+ - Prioritise blockers, high-severity risks, and non-obvious constraints.
72
+ - Each highlight must be specific and actionable — reference real file names, ticket fields, or decisions where possible.
73
+ - Do not repeat obvious facts already visible from the ticket title alone.`}],Vt={chat:{label:"Chat",subtitle:"Ask questions about your tests, code, or get AI assistance.",icon:e.jsx(kt,{size:20,weight:"fill"})},tickets:{label:"Tickets",subtitle:"Browse Jira filter tickets for context-aware AI analysis.",icon:e.jsx(me,{size:20,weight:"fill"})},repos:{label:"Repo Management",subtitle:"Register codebases for the AI to index and use as context.",icon:e.jsx(fe,{size:20,weight:"fill"})},commands:{label:"Custom Commands",subtitle:"Define reusable prompts and shortcuts for your team.",icon:e.jsx(St,{size:20,weight:"fill"})},settings:{label:"AI Settings",subtitle:"Configure AI preferences for this workspace.",icon:e.jsx(jt,{size:20,weight:"fill"})}};function Ye(t){return`noob-sdet:orchestrator:${t}`}function ur({appId:t,section:n="chat"}){const{user:o}=Te(),f=Vt[n],[p,d]=s.useState(!1),[c,g]=s.useState(null),[h,u]=s.useState(null),[m,i]=s.useState([]),[v,a]=s.useState(null),[k,C]=s.useState([]),[M,L]=s.useState(null);s.useEffect(()=>{t&&I.testCaseProfiles.list(t).then(R=>{C(R);const D=R.find(B=>B.isDefault)??R[0];D&&L(D.id)}).catch(()=>{})},[t]),s.useEffect(()=>{I.agents.list().then(R=>{var j;const D=R.filter(A=>A.type==="orchestrator"&&A.enabled);i(D);const B=o?localStorage.getItem(Ye(o.id)):null,W=B?D.find(A=>A.id===B):null,w=D.find(A=>A.isDefault)??D[0];a(((j=W??w)==null?void 0:j.id)??null)}).catch(()=>{})},[o]);const E=m.find(R=>R.id===v)??null;function P(R){a(R),o&&localStorage.setItem(Ye(o.id),R)}return e.jsxs("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",background:"var(--t-bg-base)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"0 16px 0 18px",minHeight:56,borderBottom:"1px solid var(--t-border-subtle)",background:"var(--t-bg-elevated)",flexShrink:0},children:[e.jsx("span",{style:{color:"var(--t-text-muted)",display:"flex",alignItems:"center",flexShrink:0},children:f.icon}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-base)",fontWeight:600,color:"var(--t-text-primary)",lineHeight:1.3},children:f.label}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",lineHeight:1.4,marginTop:2},children:f.subtitle})]}),n==="tickets"&&c,n==="repos"&&h,n==="chat"&&e.jsx("button",{onClick:()=>d(R=>!R),title:"Conversation history",style:{width:30,height:30,border:"none",borderRadius:6,background:p?"var(--t-bg-elevated)":"transparent",color:p?"var(--t-text-primary)":"var(--t-text-muted)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.1s, color 0.1s"},onMouseEnter:R=>{p||(R.currentTarget.style.background="var(--t-bg-elevated)",R.currentTarget.style.color="var(--t-text-secondary)")},onMouseLeave:R=>{p||(R.currentTarget.style.background="transparent",R.currentTarget.style.color="var(--t-text-muted)")},children:e.jsx(rt,{size:16})})]}),e.jsxs("div",{style:{flex:1,overflow:"hidden",display:"flex"},children:[n==="chat"&&e.jsx(Rt,{historyOpen:p,onCloseHistory:()=>d(!1),orchestratorId:v,orchestratorName:(E==null?void 0:E.name)??null,appId:t,userId:o==null?void 0:o.id,profiles:k,selectedProfileId:M,onProfileChange:L}),n==="settings"&&e.jsx(er,{appId:t,orchestrators:m,selectedOrchestratorId:v,onSelectOrchestrator:P,sharedProfiles:k,onProfilesChange:C,sharedChatProfileId:M,onChatProfileChange:L}),n==="repos"&&e.jsx(Bt,{appId:t,aiConfigured:!0,onHeaderActions:u}),n==="tickets"&&e.jsx(Jt,{appId:t,onHeaderActions:g}),n!=="chat"&&n!=="settings"&&n!=="repos"&&n!=="tickets"&&e.jsx(Xt,{section:n})]})]})}function Xt({section:t}){const n={tickets:"Tickets",repos:"Repo Management",commands:"Custom Commands"};return e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("p",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)"},children:[n[t]??t," — coming soon"]})})}function Zt({appId:t}){const[n,o]=s.useState(!1),[f,p]=s.useState(!1),d=async()=>{if(!n){o(!0);try{await I.conversations.deleteAll(t),p(!0),setTimeout(()=>p(!1),3e3)}catch{}finally{o(!1)}}};return e.jsxs("div",{children:[e.jsx("p",{style:{margin:"0 0 4px",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--t-text-muted)"},children:"Chat History"}),e.jsx("p",{style:{margin:"0 0 12px",fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",lineHeight:1.5},children:"Permanently delete all your saved AI chat conversations for this app. This cannot be undone."}),e.jsx("button",{onClick:()=>void d(),disabled:n,style:{padding:"7px 14px",borderRadius:6,border:"1px solid color-mix(in srgb, var(--t-accent-danger) 40%, transparent)",background:"color-mix(in srgb, var(--t-accent-danger) 6%, var(--t-bg-surface))",color:f?"var(--t-accent-success)":"var(--t-accent-danger)",fontSize:"var(--t-text-sm)",fontWeight:500,cursor:n?"not-allowed":"pointer",opacity:n?.6:1,transition:"color 0.2s"},children:f?"Cleared":n?"Clearing…":"Clear all my chat history"})]})}function er({appId:t,orchestrators:n,selectedOrchestratorId:o,onSelectOrchestrator:f,sharedProfiles:p,onProfilesChange:d,sharedChatProfileId:c,onChatProfileChange:g}){var Ne,Me,Be;const[h,u]=s.useState(!1),m=n.find(r=>r.id===o),[i,v]=s.useState(null),[a,k]=s.useState(!1),[C,M]=s.useState(""),[L,E]=s.useState(""),[P,R]=s.useState({}),[D,B]=s.useState(""),[W,w]=s.useState(null),[j,A]=s.useState(!1),[q,K]=s.useState(""),y=p,_=d,[ae,x]=s.useState(c);s.useEffect(()=>{c!==null&&ae===null&&x(c)},[c]);const b=ae??((Ne=y.find(r=>r.isDefault))==null?void 0:Ne.id)??((Me=y[0])==null?void 0:Me.id)??null,F=r=>{x(r),r!==null&&g(r)},[J,O]=s.useState(!1),[ye,oe]=s.useState(!1),[pe,S]=s.useState(""),[N,U]=s.useState(!1),[Y,se]=s.useState(!1),[ve,at]=s.useState([]),[ot,Ae]=s.useState(!1),[de,ue]=s.useState(null),[lt,X]=s.useState(null);s.useEffect(()=>{I.integrations.list(t).then(r=>{const z=r.find(T=>T.type==="jira");z&&v(z.config)}).catch(()=>{})},[t]),s.useEffect(()=>{I.appAiConfig.get(t).then(r=>{M(r.testPlanFormat??""),E(r.testNotesFormat??""),R(r.testAnalysisFormat??{}),B(r.confluenceSampleUrl??"")}).catch(()=>{}),I.aiRepos.list(t).then(({repos:r})=>{at(r.filter(z=>z.status==="ready"))}).catch(()=>{})},[t]);const be=async(r,z)=>{const T=z.trim()||null;r==="plan"?M(z):E(z),await I.appAiConfig.setPlanFormat(t,{testPlanFormat:r==="plan"?T:C.trim()||null,testNotesFormat:r==="notes"?T:L.trim()||null,testAnalysisFormat:P,confluenceSampleUrl:D.trim()||null})},Ie=async r=>{R(r),await I.appAiConfig.setPlanFormat(t,{testPlanFormat:C.trim()||null,testNotesFormat:L.trim()||null,testAnalysisFormat:r,confluenceSampleUrl:D.trim()||null})},l=y.find(r=>r.id===b)??null,Fe=(l==null?void 0:l.guidelines)??"",De=(l==null?void 0:l.navigation)??"",We=(l==null?void 0:l.assetActions)??"",Ee=(l==null?void 0:l.formats)??"",Pe=(l==null?void 0:l.bestPractices)??"",ie=async(r,z)=>{if(!b)return;const T=z.trim()||null,G={[r]:T},$e=await I.testCaseProfiles.update(t,b,G);_(y.map(Oe=>Oe.id===$e.id?$e:Oe))},ce=async(r,z)=>{const T=l==null?void 0:l.repoId;if(!T){alert('Select a repo first using the "Generate from repo" selector above the blocks.');return}ue(r);try{const{content:G}=await I.testCaseProfiles.generateBlock(t,T,r);X(G),w(z)}catch(G){alert(`Generate failed: ${G.message}`)}finally{ue(null)}},dt=async()=>{const r=l==null?void 0:l.repoId;if(!r){alert("Select a repo first.");return}const z=["guidelines","navigation","assetActions","formats","bestPractices"];se(!0);try{for(const T of z){ue(T);try{const{content:G}=await I.testCaseProfiles.generateBlock(t,r,T);await ie(T,G)}catch{}}}finally{ue(null),se(!1)}},Le=async()=>{const r=q.trim();B(r),A(!1),await I.appAiConfig.setPlanFormat(t,{testPlanFormat:C.trim()||null,testNotesFormat:L.trim()||null,confluenceSampleUrl:r||null})},ct=(r,z)=>{const T={...i??{},mrPrFieldId:r||void 0,mrPrFieldName:z||void 0};v(T),k(!1),I.integrations.upsert(t,"jira",T).catch(()=>{})},xt=()=>{const r={...i??{},mrPrFieldId:void 0,mrPrFieldName:void 0};v(r),I.integrations.upsert(t,"jira",r).catch(()=>{})};return e.jsx("div",{style:{flex:1,overflowY:"auto",width:"100%"},children:e.jsxs("div",{style:{padding:"28px 32px",display:"flex",flexDirection:"column",gap:20,maxWidth:760},children:[e.jsxs("div",{children:[e.jsx("p",{style:{margin:"0 0 4px",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--t-text-muted)"},children:"Orchestrator Agent"}),e.jsx("p",{style:{margin:"0 0 12px",fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",lineHeight:1.5},children:"The orchestrator receives your chat messages and routes them to the appropriate task agents. This preference is saved per user."}),n.length===0?e.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,border:"1px solid var(--t-border-subtle)",background:"var(--t-bg-surface)",fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)"},children:["No orchestrator agents configured. A super admin can create them in"," ",e.jsx("strong",{children:"Admin Settings → Global Agents"}),"."]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{onClick:()=>u(r=>!r),style:{width:"100%",display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:8,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)",cursor:"pointer",textAlign:"left",transition:"border-color 0.15s"},onMouseEnter:r=>r.currentTarget.style.borderColor="var(--t-border-strong)",onMouseLeave:r=>{h||(r.currentTarget.style.borderColor="var(--t-border-default)")},children:[e.jsx("div",{style:{width:30,height:30,borderRadius:6,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(Ge,{size:15,style:{color:"var(--t-text-secondary)"}})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(m==null?void 0:m.name)??"Select orchestrator…"}),(m==null?void 0:m.description)&&e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:1},children:m.description})]}),e.jsx(je,{size:14,style:{color:"var(--t-text-muted)",flexShrink:0}})]}),h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"fixed",inset:0,zIndex:49},onClick:()=>u(!1)}),e.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:50,background:"var(--t-bg-surface)",border:"1px solid var(--t-border-default)",borderRadius:8,boxShadow:"0 8px 24px rgba(0,0,0,0.14)",overflow:"hidden"},children:n.map(r=>{const z=r.id===o;return e.jsxs("button",{onClick:()=>{f(r.id),u(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:10,padding:"9px 12px",border:"none",background:z?"var(--t-bg-elevated)":"transparent",cursor:"pointer",textAlign:"left"},onMouseEnter:T=>{z||(T.currentTarget.style.background="var(--t-bg-panel)")},onMouseLeave:T=>{z||(T.currentTarget.style.background="transparent")},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("p",{style:{margin:0,fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[r.name,r.isDefault&&e.jsx("span",{style:{marginLeft:6,fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--t-text-muted)",verticalAlign:"middle"},children:"DEFAULT"})]}),r.description&&e.jsx("p",{style:{margin:"1px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.description})]}),z&&e.jsx(_e,{size:13,style:{color:"var(--t-accent-primary)",flexShrink:0},weight:"bold"})]},r.id)})})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:"0 0 4px",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--t-text-muted)"},children:"Jira MR/PR Field"}),e.jsx("p",{style:{margin:"0 0 12px",fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",lineHeight:1.5},children:"The Jira custom field that contains the MR/PR URL for a ticket. When set, the AI will automatically extract the MR/PR URL from here if you don't include it in your message."}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px",borderRadius:8,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)"},children:[e.jsx(He,{size:15,style:{color:i!=null&&i.mrPrFieldId?"var(--t-accent-primary)":"var(--t-text-muted)",flexShrink:0}}),e.jsx("div",{style:{flex:1,minWidth:0},children:i!=null&&i.mrPrFieldId?e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-primary)"},children:i.mrPrFieldName||i.mrPrFieldId}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",fontFamily:"monospace"},children:i.mrPrFieldId})]}):e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)"},children:"Not configured"})}),e.jsx("button",{onClick:()=>k(!0),style:{padding:"5px 10px",borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-elevated)",fontSize:"var(--t-text-xs)",fontWeight:500,color:"var(--t-text-secondary)",cursor:"pointer"},children:i!=null&&i.mrPrFieldId?"Change":"Configure"}),(i==null?void 0:i.mrPrFieldId)&&e.jsx("button",{onClick:xt,style:{padding:"5px 8px",borderRadius:6,border:"1px solid var(--t-border-default)",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center"},title:"Clear field",children:e.jsx(V,{size:13,style:{color:"var(--t-text-muted)"}})})]})]}),e.jsx(ee,{title:"Test Plan Format",description:"The structure the Test Plan agent follows when generating plans.",hasContent:!!C.trim(),onEdit:()=>w("plan"),onClear:()=>be("plan","")}),e.jsx(ee,{title:"Test Notes Format",description:"The structure the Test Notes agent follows when generating notes.",hasContent:!!L.trim(),onEdit:()=>w("notes"),onClear:()=>be("notes","")}),e.jsx(ee,{title:"Test Analysis Format",description:"The field guidance each Pre-Dev Analysis agent follows (Requirements, Impact, Feasibility, Gaps, Highlights).",hasContent:Object.values(P).some(r=>r.trim()),onEdit:()=>w("analysis"),onClear:()=>Ie({})}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:"0 0 4px",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--t-text-muted)"},children:"Test Case Writer Profiles"}),e.jsx("p",{style:{margin:"0 0 12px",fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",lineHeight:1.5},children:"Each profile holds five knowledge blocks the writer agent uses. Select a profile in the chat input or mention it by name. The default profile is used when no profile is specified."}),e.jsxs("div",{style:{background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",borderRadius:12,overflow:"visible",position:"relative"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"12px 14px"},children:[e.jsxs("div",{style:{position:"relative",flex:1,minWidth:0},children:[e.jsxs("button",{onClick:()=>O(r=>!r),style:{display:"flex",alignItems:"center",gap:6,background:"var(--t-bg-surface)",border:"1px solid var(--t-border-default)",borderRadius:7,padding:"5px 10px",cursor:"pointer",fontSize:"var(--t-text-sm)",color:"var(--t-text-primary)",maxWidth:220,minWidth:0},children:[(l==null?void 0:l.isDefault)&&e.jsx(Se,{size:11,weight:"fill",color:"var(--t-accent-primary)"}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(l==null?void 0:l.name)??"No profiles"}),e.jsx(je,{size:12,style:{flexShrink:0,marginLeft:2}})]}),J&&y.length>0&&e.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"var(--t-bg-surface)",border:"1px solid var(--t-border-default)",borderRadius:8,boxShadow:"0 8px 24px rgba(0,0,0,0.14)",minWidth:200,overflow:"hidden"},children:y.map(r=>e.jsxs("button",{onClick:()=>{F(r.id),O(!1)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px",border:"none",cursor:"pointer",textAlign:"left",fontSize:"var(--t-text-sm)",color:r.id===b?"var(--t-accent-primary)":"var(--t-text-primary)",background:r.id===b?"var(--t-accent-primary-subtle)":"transparent"},children:[r.isDefault&&e.jsx(Se,{size:11,weight:"fill",color:"var(--t-accent-primary)"}),e.jsx("span",{children:r.name}),r.id===b&&!r.isDefault&&e.jsx(_e,{size:12,style:{marginLeft:"auto"}})]},r.id))})]}),e.jsxs("button",{title:"New profile",onClick:async()=>{const r=await I.testCaseProfiles.create(t,{name:"New Profile"});_([...y,r]),F(r.id),oe(!0),S(r.name)},style:{display:"flex",alignItems:"center",gap:4,background:"none",border:"1px solid var(--t-border-default)",borderRadius:6,padding:"4px 9px",cursor:"pointer",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:[e.jsx(Ce,{size:13}),"New"]}),e.jsxs("button",{title:l!=null&&l.isDefault?"Already default":"Make default",disabled:!l||l.isDefault,onClick:async()=>{b&&(await I.testCaseProfiles.setDefault(t,b),_(y.map(r=>({...r,isDefault:r.id===b}))))},style:{display:"flex",alignItems:"center",gap:4,background:"none",border:"1px solid var(--t-border-default)",borderRadius:6,padding:"4px 9px",cursor:l!=null&&l.isDefault?"default":"pointer",fontSize:"var(--t-text-sm)",color:l!=null&&l.isDefault?"var(--t-accent-primary)":"var(--t-text-secondary)",opacity:l!=null&&l.isDefault?.6:1},children:[e.jsx(Se,{size:13,weight:l!=null&&l.isDefault?"fill":"regular"}),l!=null&&l.isDefault?"Default":"Make Default"]}),!(l!=null&&l.isDefault)&&e.jsx("button",{title:"Delete profile",onClick:async()=>{var r,z;if(b&&confirm(`Delete profile "${l==null?void 0:l.name}"?`)){U(!0);try{await I.testCaseProfiles.delete(t,b);const T=y.filter(G=>G.id!==b);_(T),F(((r=T.find(G=>G.isDefault))==null?void 0:r.id)??((z=T[0])==null?void 0:z.id)??null)}finally{U(!1)}}},style:{display:"flex",alignItems:"center",background:"none",border:"1px solid var(--t-border-default)",borderRadius:6,padding:"4px 8px",cursor:"pointer",color:"var(--t-text-muted)"},children:e.jsx(Re,{size:13})}),N&&e.jsx(ge,{size:14,style:{animation:"spin 1s linear infinite"}})]}),l&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px",background:"var(--t-bg-surface)"},children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.05em",flexShrink:0},children:"Profile name"}),ye?e.jsx("input",{autoFocus:!0,value:pe,onChange:r=>S(r.target.value),onBlur:async()=>{const r=pe.trim();if(r&&r!==l.name){const z=await I.testCaseProfiles.update(t,l.id,{name:r});_(y.map(T=>T.id===z.id?z:T))}oe(!1)},onKeyDown:r=>{r.key==="Enter"&&r.target.blur(),r.key==="Escape"&&(S(l.name),oe(!1))},style:{flex:1,background:"var(--t-bg-panel)",border:"1px solid var(--t-border-strong)",borderRadius:5,padding:"3px 8px",fontSize:"var(--t-text-sm)",color:"var(--t-text-primary)",outline:"none"}}):e.jsxs("button",{onClick:()=>{S(l.name),oe(!0)},style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",fontSize:"var(--t-text-sm)",color:"var(--t-text-primary)",display:"flex",alignItems:"center",gap:6},children:[l.name,e.jsx(wt,{size:12,color:"var(--t-text-muted)"})]})]}),l&&ve.length>0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px",background:"var(--t-bg-surface)",position:"relative"},children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.05em",flexShrink:0},children:"Generate from repo"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{onClick:()=>Ae(r=>!r),style:{display:"flex",alignItems:"center",gap:6,background:"var(--t-bg-panel)",border:"1px solid var(--t-border-default)",borderRadius:6,padding:"4px 10px",cursor:"pointer",fontSize:"var(--t-text-sm)",color:"var(--t-text-primary)",maxWidth:240},children:[e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l.repoId?((Be=ve.find(r=>r.id===l.repoId))==null?void 0:Be.name)??l.repoId:"Select repo…"}),e.jsx(je,{size:11,style:{flexShrink:0}})]}),ot&&e.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"var(--t-bg-surface)",border:"1px solid var(--t-border-default)",borderRadius:8,boxShadow:"0 8px 24px rgba(0,0,0,0.14)",minWidth:220,overflow:"hidden"},children:ve.map(r=>e.jsxs("button",{onClick:async()=>{Ae(!1);try{const z=await I.testCaseProfiles.update(t,l.id,{repoId:r.id});_(y.map(T=>T.id===z.id?z:T))}catch(z){alert(`Failed to save repo: ${z.message}`)}},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",border:"none",cursor:"pointer",textAlign:"left",fontSize:"var(--t-text-sm)",color:r.id===l.repoId?"var(--t-accent-primary)":"var(--t-text-primary)",background:r.id===l.repoId?"var(--t-accent-primary-subtle)":"transparent"},children:[e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.name}),e.jsx("span",{style:{fontSize:10,color:"var(--t-text-muted)",flexShrink:0},children:r.branch})]},r.id))})]}),e.jsx("span",{style:{fontSize:11,color:"var(--t-text-muted)"},children:"Select a repo, then click Generate on any block"}),e.jsxs("button",{onClick:Y?void 0:()=>void dt(),disabled:Y,style:{marginLeft:"auto",flexShrink:0,display:"flex",alignItems:"center",gap:5,padding:"5px 12px",borderRadius:6,border:"1px solid var(--t-accent-primary)",background:"var(--t-accent-primary-subtle)",fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-accent-primary)",cursor:Y?"not-allowed":"pointer",opacity:Y?.6:1},children:[e.jsx(ge,{size:12,style:{flexShrink:0}}),Y?"Generating…":"Generate all"]})]}),y.length===0?e.jsxs("div",{style:{padding:"24px",textAlign:"center",color:"var(--t-text-muted)",fontSize:"var(--t-text-sm)"},children:["No profiles yet."," ",e.jsx("button",{onClick:async()=>{const r=await I.testCaseProfiles.create(t,{name:"Default"});_([r]),F(r.id)},style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-accent-primary)",textDecoration:"underline",fontSize:"inherit"},children:"Create one"})]}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",padding:"4px 0 8px"},children:[l&&!l.isComplete&&(()=>{const r={guidelines:"Key Guidelines",navigation:"Navigation Patterns",assetActions:"Action Flows",formats:"Test Formats",bestPractices:"Best Practices"},z=["guidelines","navigation","assetActions","formats","bestPractices"].filter(T=>{var G;return!((G=l[T])!=null&&G.trim())}).map(T=>r[T]);return e.jsxs("div",{style:{margin:"4px 12px 4px",padding:"10px 14px",borderRadius:8,background:"color-mix(in srgb, var(--t-accent-warning, #f59e0b) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--t-accent-warning, #f59e0b) 35%, transparent)",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.5},children:[e.jsx("span",{style:{fontWeight:600,color:"var(--t-text-primary)"},children:"Profile incomplete"})," — test case generation is disabled until all blocks have content. Missing: ",e.jsx("span",{style:{fontWeight:500},children:z.join(", ")})]})})(),e.jsx(ee,{variant:"inset",title:"Key Guidelines",description:"Critical rules: login step, navigation requirement, application selection, action access, and documentation format.",hasContent:!!Fe.trim(),onEdit:()=>{X(null),w("tc-guidelines")},onClear:()=>ie("guidelines",""),onGenerate:()=>void ce("guidelines","tc-guidelines"),generating:de==="guidelines",blockKey:"guidelines"}),e.jsx(ee,{variant:"inset",title:"Navigation Patterns",description:"App navigation structures, sidebar menus, exact UI labels, and conditional sections per app context.",hasContent:!!De.trim(),onEdit:()=>{X(null),w("tc-navigation")},onClear:()=>ie("navigation",""),onGenerate:()=>void ce("navigation","tc-navigation"),generating:de==="navigation",blockKey:"navigation"}),e.jsx(ee,{variant:"inset",title:"Action Flows",description:"An interaction pattern catalog that maps exactly how to access and trigger actions on content items across app contexts — hover sequences, nested sub-menus, content-type-specific action sets, and bulk vs. single-item patterns — so tests always specify the precise gesture chain, never vaguely say 'perform the action'.",hasContent:!!We.trim(),onEdit:()=>{X(null),w("tc-asset-actions")},onClear:()=>ie("assetActions",""),onGenerate:()=>void ce("assetActions","tc-asset-actions"),generating:de==="assetActions",blockKey:"assetActions"}),e.jsx(ee,{variant:"inset",title:"Test Formats",description:"Traditional and BDD scenario format templates, structure, and format selection guidelines.",hasContent:!!Ee.trim(),onEdit:()=>{X(null),w("tc-formats")},onClear:()=>ie("formats",""),onGenerate:()=>void ce("formats","tc-formats"),generating:de==="formats",blockKey:"formats"}),e.jsx(ee,{variant:"inset",title:"Best Practices",description:"Navigation clarity, application context, asset actions clarity, test data, error scenarios, and essential checklist.",hasContent:!!Pe.trim(),onEdit:()=>{X(null),w("tc-best-practices")},onClear:()=>ie("bestPractices",""),onGenerate:()=>void ce("bestPractices","tc-best-practices"),generating:de==="bestPractices",blockKey:"bestPractices"})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:"0 0 4px",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--t-text-muted)"},children:"Template Confluence Test Plan Page"}),e.jsx("p",{style:{margin:"0 0 12px",fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",lineHeight:1.5},children:"Optional. URL of a Confluence page that represents how your test plans should look. Used as a formatting reference when exporting generated plans to Confluence."}),j?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("input",{type:"url",value:q,onChange:r=>K(r.target.value),onKeyDown:r=>{r.key==="Enter"&&Le(),r.key==="Escape"&&A(!1)},placeholder:"https://your-org.atlassian.net/wiki/spaces/QA/pages/123456/Sample",spellCheck:!1,autoFocus:!0,style:{flex:1,minWidth:0,padding:"9px 12px",borderRadius:8,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)",color:"var(--t-text-primary)",fontSize:"var(--t-text-sm)",boxSizing:"border-box",outline:"none"}}),e.jsx("button",{onClick:Le,style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--t-accent-primary)",fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-bg-base)",cursor:"pointer",flexShrink:0},children:"Save"}),e.jsx("button",{onClick:()=>A(!1),style:{padding:"8px 14px",borderRadius:6,border:"1px solid var(--t-border-default)",background:"transparent",fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-muted)",cursor:"pointer",flexShrink:0},children:"Cancel"})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px",borderRadius:8,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)"},children:[e.jsx(He,{size:15,style:{color:D?"var(--t-accent-primary)":"var(--t-text-muted)",flexShrink:0}}),e.jsx("div",{style:{flex:1,minWidth:0},children:D?e.jsx("a",{href:D,target:"_blank",rel:"noreferrer",style:{fontSize:"var(--t-text-sm)",color:"var(--t-accent-primary)",textDecoration:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block"},children:D}):e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)"},children:"Not configured"})}),e.jsx("button",{onClick:()=>{K(D),A(!0)},style:{padding:"6px 14px",borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-elevated)",fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)",cursor:"pointer",flexShrink:0},children:"Edit"})]})]}),a&&e.jsx(sr,{appId:t,currentFieldId:(i==null?void 0:i.mrPrFieldId)??"",currentFieldName:(i==null?void 0:i.mrPrFieldName)??"",onClose:()=>k(!1),onSave:ct}),(W==="plan"||W==="notes")&&e.jsx(Qe,{title:W==="plan"?"Edit Test Plan Format":"Edit Test Notes Format",value:W==="plan"?C:L,initialTemplate:W==="plan"?Yt:Qt,onClose:()=>w(null),onSave:async r=>{await be(W,r),w(null)}}),W==="analysis"&&e.jsx(rr,{value:P,onClose:()=>w(null),onSave:async r=>{await Ie(r),w(null)}}),(W==="tc-guidelines"||W==="tc-navigation"||W==="tc-asset-actions"||W==="tc-formats"||W==="tc-best-practices")&&(()=>{const z={"tc-guidelines":{title:"Edit Key Guidelines",block:"guidelines",value:Fe},"tc-navigation":{title:"Edit Navigation Patterns",block:"navigation",value:De},"tc-asset-actions":{title:"Edit Action Flows",block:"assetActions",value:We},"tc-formats":{title:"Edit Test Formats",block:"formats",value:Ee},"tc-best-practices":{title:"Edit Best Practices",block:"bestPractices",value:Pe}}[W];return e.jsx(Qe,{title:z.title,value:lt??z.value,onClose:()=>{w(null),X(null)},onSave:async T=>{await ie(z.block,T),w(null),X(null)}})})(),e.jsxs("div",{style:{display:"flex",gap:14,padding:"16px 18px",borderRadius:10,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)",alignItems:"flex-start"},children:[e.jsx("div",{style:{width:34,height:34,borderRadius:8,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(Ge,{size:16,style:{color:"var(--t-text-secondary)"}})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("p",{style:{margin:"0 0 4px",fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)"},children:"Global AI Configuration"}),e.jsx("p",{style:{margin:"0 0 10px",fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",lineHeight:1.6},children:"LLM and Vector DB providers, models, and API keys are configured once by a super admin and shared across all workspaces."}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:[e.jsx(tt,{size:12}),"Manage in"," ",e.jsx("strong",{style:{color:"var(--t-text-secondary)"},children:"Admin Settings → AI Settings"})]})]})]}),e.jsx(Zt,{appId:t})]})})}const tr={guidelines:{what:"A style guide that tells the AI the hard constraints every test case must follow — regardless of what feature is being tested.",why:"Keeps AI-generated test cases consistent, executable by a real tester without ambiguity, and decoupled from the underlying DOM implementation.",rules:[{title:"Rigid step ordering",detail:"Every test must start with Login (Step 0) then Navigation (Step 1). No skipping — prevents assumptions about app state."},{title:"Role-awareness",detail:"Login steps must name the user type/role explicitly, so tests are clear about which permissions and feature flags are required."},{title:"App disambiguation",detail:"Tests must declare which app context they target (e.g. the end-user app, admin panel, or any other portal). The same action can behave differently across contexts."},{title:"UI interaction specificity",detail:"Actions follow the app's established patterns (hover menus, ellipsis menus, inline buttons). Tests spell out the exact interaction path, not shorthand."},{title:"Human-readable selectors only",detail:"No CSS, XPath, or data-test-ids. Tests are written as a human would describe them, not as automation scripts."}]},navigation:{what:"A reference map of every navigation path in the app — sidebar items, tabs, sub-menus — with exact UI labels and clickability status.",why:"Eliminates navigation ambiguity in test steps. The AI uses this to write precise click paths without guessing label names or assuming every item is clickable.",rules:[{title:"Exact label strings",detail:'Uses the precise text shown in the UI, not paraphrases. "Content" is different from "Library" — guessing breaks tests.'},{title:"Clickability declared",detail:"Section headers that are visual organizers (not links) are marked explicitly so tests don't include a step that can't be executed."},{title:"Context-separated",detail:"Navigation differs between app contexts. Each context gets its own section to avoid cross-contamination."},{title:"Conditional items noted",detail:"Items that only appear for certain roles or feature flags are flagged, so tests can set up the right preconditions."}]},assetActions:{what:"A lookup table for how testers interact with content items — which menus appear, what actions they contain, and how nested menus work.",why:"Content actions are the most interaction-heavy part of the app. Without this, the AI invents action paths that don't exist or misses the correct trigger pattern.",rules:[{title:"Trigger pattern first",detail:"Starts with how actions are revealed (hover, click icon, inline button) before listing what those actions are."},{title:"Exact action labels",detail:'Uses the exact text of each menu item. "Move to" and "Move" are different actions — precision matters.'},{title:"Nested menus spelled out",detail:"Sub-menus are listed with their parent so the full interaction path is unambiguous (e.g. a sub-menu containing Rename, Copy, Upload New Version)."},{title:"Context variations",detail:"The same item type may have different actions in different views. Each variation is listed separately to avoid incorrect assumptions."}]},formats:{what:"The schema the AI must use when writing test cases — defines the exact field structure, naming conventions, and examples for both Traditional and BDD formats.",why:"Without a strict format contract, AI-generated tests are inconsistent and can't be parsed or imported reliably. This block is the single source of formatting truth.",rules:[{title:"Two format modes",detail:"Traditional (step-by-step with expected results) and BDD (Given/When/Then). The AI picks based on the ticket type."},{title:"Mandatory fields",detail:"Title, preconditions, steps, and expected results are always required. Optional fields are explicitly marked."},{title:"Title naming convention",detail:"Titles follow a strict pattern (e.g. [App] Section - Action - Role) so tests are scannable and sortable without reading the body."},{title:"Concrete examples included",detail:"Each format includes a filled-in example so the AI has a precise target to match, not just an abstract schema."}]},bestPractices:{what:"A per-section quality checklist the AI applies to every test it writes — covering navigation clarity, context declarations, action specificity, test data, and error coverage.",why:"Acts as an automated review layer. Baking best practices into the prompt block catches common omissions before output — missing error scenarios, vague selectors, assumed state.",rules:[{title:"Navigation clarity",detail:'Every test must spell out the full navigation path. "Go to Settings" is not acceptable — the exact menu path is required.'},{title:"Application context",detail:"Each test must explicitly state which app context it operates in. No implicit assumptions about which portal the tester is in."},{title:"Action specificity",detail:"Interaction steps must follow the established action patterns from the Asset Actions block — no abbreviated or invented shortcuts."},{title:"Test data explicitness",detail:'Tests must specify what data state is required (e.g. "a published asset exists"), not assume the tester will figure it out.'},{title:"Error scenario coverage",detail:"Happy path alone is not enough. Each test should include at least one negative or boundary case."}]}};function ee({title:t,description:n,hasContent:o,onEdit:f,onClear:p,onGenerate:d,generating:c,variant:g="default",blockKey:h}){const[u,m]=s.useState(!1),i=s.useRef(null),v=h?tr[h]:void 0;return s.useEffect(()=>{if(!u)return;function a(k){i.current&&!i.current.contains(k.target)&&m(!1)}return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[u]),e.jsxs("div",{style:g==="inset"?{display:"flex",alignItems:"center",gap:16,padding:"12px 18px",borderTop:"1px solid var(--t-border-subtle)",background:"transparent"}:{display:"flex",alignItems:"center",gap:16,padding:"16px 18px",borderRadius:10,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)"},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)"},children:t}),v&&e.jsxs("div",{ref:i,style:{position:"relative",display:"inline-flex"},children:[e.jsx("button",{onClick:()=>m(a=>!a),title:"Block info",style:{display:"inline-flex",alignItems:"center",background:"none",border:"none",padding:0,cursor:"pointer",color:u?"var(--t-accent-primary)":"var(--t-text-muted)",lineHeight:1},children:e.jsx(zt,{size:14,weight:u?"fill":"regular"})}),u&&e.jsxs("div",{style:{position:"absolute",top:"calc(100% + 8px)",left:0,zIndex:100,width:320,borderRadius:10,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)",boxShadow:"0 8px 24px rgba(0,0,0,0.12)",padding:"14px 16px",fontSize:"var(--t-text-sm)"},children:[e.jsx("p",{style:{margin:"0 0 6px",color:"var(--t-text-secondary)",lineHeight:1.5},children:v.what}),e.jsx("p",{style:{margin:"0 0 10px",color:"var(--t-text-muted)",lineHeight:1.5,fontStyle:"italic",fontSize:12},children:v.why}),e.jsx("p",{style:{margin:"0 0 6px",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--t-text-muted)"},children:"Core rules"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:v.rules.map((a,k)=>e.jsxs("div",{children:[e.jsxs("span",{style:{fontWeight:600,color:"var(--t-text-primary)",fontSize:12},children:[a.title," —"," "]}),e.jsx("span",{style:{color:"var(--t-text-secondary)",fontSize:12,lineHeight:1.5},children:a.detail})]},k))})]})]})]}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",lineHeight:1.5},children:n})]}),e.jsxs("div",{style:{display:"flex",gap:8,flexShrink:0},children:[d&&e.jsxs("button",{onClick:c?void 0:d,disabled:c,title:c?"Generating…":"Generate this block from the selected repo",style:{padding:"6px 12px",borderRadius:6,border:"1px solid var(--t-accent-primary)",background:"var(--t-accent-primary-subtle)",fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-accent-primary)",cursor:c?"wait":"pointer",display:"flex",alignItems:"center",gap:5,opacity:c?.7:1},children:[e.jsx(ge,{size:12,style:{flexShrink:0,...c?{animation:"spin 1s linear infinite"}:{}}}),c?"Generating…":"Generate"]}),e.jsx("button",{onClick:f,style:{padding:"6px 14px",borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-elevated)",fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)",cursor:"pointer"},children:"Edit"}),o&&e.jsx("button",{onClick:p,style:{padding:"6px 14px",borderRadius:6,border:"1px solid var(--t-border-default)",background:"transparent",fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-muted)",cursor:"pointer"},children:"Clear"})]})]})}function Qe({title:t,value:n,initialTemplate:o="",onClose:f,onSave:p,onGenerate:d}){const[c,g]=s.useState(n.trim()?n:o),[h,u]=s.useState(!1),m=async()=>{u(!0);try{await p(c)}finally{u(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"fixed",inset:0,zIndex:199,background:"rgba(0,0,0,0.45)"},onClick:f}),e.jsxs("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:200,background:"var(--t-bg-base)",border:"1px solid var(--t-border-default)",borderRadius:12,width:"min(900px, calc(100vw - 48px))",height:"min(80vh, 800px)",display:"flex",flexDirection:"column",boxShadow:"0 16px 48px rgba(0,0,0,0.3)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--t-border-subtle)",flexShrink:0},children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)"},children:t}),e.jsx("button",{onClick:f,style:{background:"transparent",border:"none",cursor:"pointer",padding:2,display:"flex",borderRadius:4},children:e.jsx(V,{size:16,style:{color:"var(--t-text-muted)"}})})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",padding:"16px 20px",gap:10,minHeight:0},children:[e.jsxs("p",{style:{margin:0,fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",lineHeight:1.5},children:["Edit, amend, or append to the format below. Use markdown with"," ",e.jsx("code",{style:{fontFamily:"monospace",fontSize:"0.9em"},children:"##"})," headings for each section."]}),e.jsx("textarea",{value:c,onChange:i=>g(i.target.value),spellCheck:!1,style:{flex:1,width:"100%",resize:"none",padding:"12px 14px",borderRadius:8,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)",color:"var(--t-text-primary)",fontSize:"var(--t-text-sm)",fontFamily:"monospace",lineHeight:1.6,boxSizing:"border-box"}})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",padding:"14px 20px",borderTop:"1px solid var(--t-border-subtle)",flexShrink:0},children:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:f,style:{padding:"7px 14px",borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-elevated)",fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)",cursor:"pointer"},children:"Cancel"}),e.jsx("button",{onClick:m,disabled:h,style:{padding:"7px 18px",borderRadius:6,border:"none",background:"var(--t-accent-primary)",fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-bg-base)",cursor:h?"default":"pointer",opacity:h?.7:1},children:h?"Saving…":"Save"})]})})]})]})}function rr({value:t,onClose:n,onSave:o}){const[f,p]=s.useState(()=>{var u;const h={};for(const m of ze)h[m.id]=(u=t[m.id])!=null&&u.trim()?t[m.id]:m.guidance;return h}),[d,c]=s.useState(!1),g=async()=>{c(!0);try{const h={};for(const u of ze){const m=f[u.id]??"";m.trim()&&(h[u.id]=m)}await o(h)}finally{c(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"fixed",inset:0,zIndex:199,background:"rgba(0,0,0,0.45)"},onClick:n}),e.jsxs("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:200,background:"var(--t-bg-base)",border:"1px solid var(--t-border-default)",borderRadius:12,width:"min(900px, calc(100vw - 48px))",height:"min(85vh, 900px)",display:"flex",flexDirection:"column",boxShadow:"0 16px 48px rgba(0,0,0,0.3)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--t-border-subtle)",flexShrink:0},children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)"},children:"Edit Test Analysis Format"}),e.jsx("button",{onClick:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:2,display:"flex",borderRadius:4},children:e.jsx(V,{size:16,style:{color:"var(--t-text-muted)"}})})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px",display:"flex",flexDirection:"column",gap:20,minHeight:0},children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",lineHeight:1.5},children:"Edit the field guidance each analysis agent follows. The JSON output structure is fixed and cannot be changed here — only the guidance describing what each field should contain."}),ze.map(h=>{const u=f[h.id]??"";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)"},children:h.label}),e.jsx("p",{style:{margin:"2px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:h.description})]}),e.jsx("textarea",{value:u,onChange:m=>p(i=>({...i,[h.id]:m.target.value})),spellCheck:!1,rows:6,style:{width:"100%",resize:"vertical",padding:"12px 14px",borderRadius:8,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)",color:"var(--t-text-primary)",fontSize:"var(--t-text-sm)",fontFamily:"monospace",lineHeight:1.6,boxSizing:"border-box"}})]},h.id)})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",padding:"14px 20px",borderTop:"1px solid var(--t-border-subtle)",flexShrink:0},children:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:n,style:{padding:"7px 14px",borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-elevated)",fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)",cursor:"pointer"},children:"Cancel"}),e.jsx("button",{onClick:g,disabled:d,style:{padding:"7px 18px",borderRadius:6,border:"none",background:"var(--t-accent-primary)",fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-bg-base)",cursor:d?"default":"pointer",opacity:d?.7:1},children:d?"Saving…":"Save"})]})})]})]})}function sr({appId:t,currentFieldId:n,currentFieldName:o,onClose:f,onSave:p}){const[d,c]=s.useState(n?"manual":"discover"),[g,h]=s.useState(""),[u,m]=s.useState(!1),[i,v]=s.useState([]),[a,k]=s.useState(""),[C,M]=s.useState(""),[L,E]=s.useState(""),[P,R]=s.useState(n),[D,B]=s.useState(o),[W,w]=s.useState(!1),j=s.useRef(null);s.useEffect(()=>{var y;(y=j.current)==null||y.focus()},[d]);const A=async()=>{if(g.trim()){m(!0),k(""),v([]),M("");try{const y=await I.integrations.discoverMrField(t,g.trim());y.candidates.length===0?k("No MR/PR URL fields found in this ticket. Try a different ticket or use manual entry."):(v(y.candidates),M(y.candidates[0].fieldId),E(y.candidates[0].fieldName))}catch(y){k(y.message||"Failed to fetch Jira ticket")}finally{m(!1)}}},q=async()=>{w(!0),d==="discover"?p(C,L):p(P.trim(),D.trim()),w(!1)},K=d==="discover"?!!C:!!P.trim();return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"fixed",inset:0,zIndex:199,background:"rgba(0,0,0,0.45)"},onClick:f}),e.jsxs("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:200,background:"var(--t-bg-base)",border:"1px solid var(--t-border-default)",borderRadius:12,width:480,maxWidth:"calc(100vw - 32px)",boxShadow:"0 16px 48px rgba(0,0,0,0.3)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--t-border-subtle)"},children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)"},children:"Configure Jira MR/PR Field"}),e.jsx("button",{onClick:f,style:{background:"transparent",border:"none",cursor:"pointer",padding:2,display:"flex",borderRadius:4},children:e.jsx(V,{size:16,style:{color:"var(--t-text-muted)"}})})]}),e.jsx("div",{style:{display:"flex",borderBottom:"1px solid var(--t-border-subtle)"},children:["discover","manual"].map(y=>e.jsx("button",{onClick:()=>c(y),style:{flex:1,padding:"10px 0",border:"none",borderBottom:`2px solid ${d===y?"var(--t-accent-primary)":"transparent"}`,background:"transparent",cursor:"pointer",fontSize:"var(--t-text-sm)",fontWeight:d===y?600:400,color:d===y?"var(--t-text-primary)":"var(--t-text-muted)"},children:y==="discover"?"Auto-Discover":"Manual Entry"},y))}),e.jsx("div",{style:{padding:"20px"},children:d==="discover"?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",lineHeight:1.5},children:"Enter a Jira ticket that has the MR/PR URL filled in. The system will fetch all fields and identify the one containing the URL."}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("input",{ref:j,value:g,onChange:y=>h(y.target.value),onKeyDown:y=>y.key==="Enter"&&A(),placeholder:"e.g. SP-12345",style:{flex:1,padding:"8px 10px",borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)",fontSize:"var(--t-text-sm)",color:"var(--t-text-primary)",outline:"none"}}),e.jsxs("button",{onClick:A,disabled:!g.trim()||u,style:{padding:"8px 12px",borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-elevated)",cursor:g.trim()&&!u?"pointer":"not-allowed",display:"flex",alignItems:"center",gap:6,fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)",opacity:!g.trim()||u?.5:1},children:[u?e.jsx(ge,{size:14,style:{animation:"spin 1s linear infinite"}}):e.jsx(Ct,{size:14}),"Find"]})]}),a&&e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-status-fail)",lineHeight:1.5},children:a}),i.length>0&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs("p",{style:{margin:0,fontSize:"var(--t-text-xs)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--t-text-muted)"},children:["Found ",i.length," field",i.length!==1?"s":""]}),i.map(y=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"10px 12px",borderRadius:8,border:`1px solid ${C===y.fieldId?"var(--t-accent-primary)":"var(--t-border-default)"}`,background:C===y.fieldId?"var(--t-bg-elevated)":"var(--t-bg-surface)",cursor:"pointer"},children:[e.jsx("input",{type:"radio",name:"mrfield",value:y.fieldId,checked:C===y.fieldId,onChange:()=>{M(y.fieldId),E(y.fieldName)},style:{marginTop:2,flexShrink:0}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-primary)"},children:y.fieldName}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",fontFamily:"monospace"},children:y.fieldId}),e.jsx("p",{style:{margin:"3px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y.value})]})]},y.fieldId))]})]}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsxs("p",{style:{margin:0,fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",lineHeight:1.5},children:["Enter the Jira field ID directly. Custom fields usually look like"," ",e.jsx("code",{children:"customfield_10200"}),"."]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx("label",{style:{fontSize:"var(--t-text-xs)",fontWeight:600,color:"var(--t-text-secondary)"},children:"Field ID"}),e.jsx("input",{ref:j,value:P,onChange:y=>R(y.target.value),placeholder:"e.g. customfield_10200",style:{padding:"8px 10px",borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)",fontSize:"var(--t-text-sm)",color:"var(--t-text-primary)",outline:"none",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("label",{style:{fontSize:"var(--t-text-xs)",fontWeight:600,color:"var(--t-text-secondary)"},children:["Display Name"," ",e.jsx("span",{style:{fontWeight:400,color:"var(--t-text-muted)"},children:"(optional)"})]}),e.jsx("input",{value:D,onChange:y=>B(y.target.value),placeholder:"e.g. GitLab MR URL",style:{padding:"8px 10px",borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)",fontSize:"var(--t-text-sm)",color:"var(--t-text-primary)",outline:"none"}})]})]})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,padding:"12px 20px",borderTop:"1px solid var(--t-border-subtle)"},children:[e.jsx("button",{onClick:f,style:{padding:"7px 14px",borderRadius:6,border:"1px solid var(--t-border-default)",background:"transparent",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",cursor:"pointer"},children:"Cancel"}),e.jsx("button",{onClick:q,disabled:!K||W,style:{padding:"7px 14px",borderRadius:6,border:"none",background:K&&!W?"var(--t-accent-primary)":"var(--t-bg-elevated)",color:K&&!W?"#fff":"var(--t-text-muted)",fontSize:"var(--t-text-sm)",fontWeight:500,cursor:K&&!W?"pointer":"not-allowed"},children:"Save Field"})]})]})]})}export{ur as AIView};