@testver/testver 1.3.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/bin/testver.js +8 -1
  2. package/dist/index.js +1309 -781
  3. package/dist/py-agent/__pycache__/testver_appium.cpython-313.pyc +0 -0
  4. package/package.json +7 -6
  5. package/src/ui/static/assets/AIPanel-D09Ni3a4.js +32 -0
  6. package/src/ui/static/assets/AIRecordPanel-DZtUZnRe.js +40 -0
  7. package/src/ui/static/assets/AIStreamUI-BsxKziYG.js +9 -0
  8. package/src/ui/static/assets/AITestGenPage-Cg21-P1W.js +5 -0
  9. package/src/ui/static/assets/APITestingPage-Cdc8EZz2.js +19 -0
  10. package/src/ui/static/assets/AboutPage-yJLCr2_q.js +1 -0
  11. package/src/ui/static/assets/AdvancedPage-DB-6sJ6s.js +3 -0
  12. package/src/ui/static/assets/AnalyticsPage-gTPFsiLZ.js +1 -0
  13. package/src/ui/static/assets/AuditLogPage-DE45E_PV.js +1 -0
  14. package/src/ui/static/assets/ChangesSummary-C-7oi_sx.js +2 -0
  15. package/src/ui/static/assets/CodeMapPage-DgU6ZYBO.js +3 -0
  16. package/src/ui/static/assets/ConfirmDialog-DNU3qoAP.js +1 -0
  17. package/src/ui/static/assets/CoveragePage-BpTjgcdV.js +2 -0
  18. package/src/ui/static/assets/CronBuilder-DsnX-vRr.js +1 -0
  19. package/src/ui/static/assets/Dashboard-DRWbVyTb.js +1 -0
  20. package/src/ui/static/assets/DefectsPage-BtMNbq6Z.js +72 -0
  21. package/src/ui/static/assets/DiffViewer-DPglzjPH.js +2 -0
  22. package/src/ui/static/assets/EmptyState-BH_aDO0P.js +1 -0
  23. package/src/ui/static/assets/ExportButton-Ce_MxnM1.js +1 -0
  24. package/src/ui/static/assets/FileViewer-iYL0lxyY.js +18 -0
  25. package/src/ui/static/assets/GitPage-CQqV8JBC.js +12 -0
  26. package/src/ui/static/assets/ImportExportPage-DXk7Koaq.js +36 -0
  27. package/src/ui/static/assets/JiraPushDialog-CqftoLh8.js +1 -0
  28. package/src/ui/static/assets/LiveExecutionView-BD0wE8sz.js +1 -0
  29. package/src/ui/static/assets/ManagePage-B8iG6Q0B.js +1 -0
  30. package/src/ui/static/assets/MediaModal-DiSINwmh.js +1 -0
  31. package/src/ui/static/assets/MobileRunPicker-BNs2lZFf.js +1 -0
  32. package/src/ui/static/assets/MobileRunTarget-D2Nqcj10.js +6 -0
  33. package/src/ui/static/assets/ModuleExplorer-BmkoQrHb.js +1 -0
  34. package/src/ui/static/assets/OutputPage-Dcsr7cmr.js +1 -0
  35. package/src/ui/static/assets/PipelinesPanel-CMMXCSda.js +1 -0
  36. package/src/ui/static/assets/ProfilePage-ByshrcwC.js +1 -0
  37. package/src/ui/static/assets/ProjectExplorer-B9B___ij.js +1 -0
  38. package/src/ui/static/assets/RemoteFileStrip-DbPnaZ-v.js +1 -0
  39. package/src/ui/static/assets/ReportCard-BbNfk85h.js +2 -0
  40. package/src/ui/static/assets/ReportFullView-Cg1rggho.js +1 -0
  41. package/src/ui/static/assets/ReportsPage-CFv3OAhe.js +48 -0
  42. package/src/ui/static/assets/ResultsPage-B4LwZH-R.js +115 -0
  43. package/src/ui/static/assets/RunTargets-C7Vqd4TU.js +1 -0
  44. package/src/ui/static/assets/ScriptMappingPage-BrANeHv0.js +1 -0
  45. package/src/ui/static/assets/SearchableDevicePicker-CFJ_DUAA.js +1 -0
  46. package/src/ui/static/assets/SettingsPage-BwOiebKG.js +83 -0
  47. package/src/ui/static/assets/SharedReportView-BAbW1WOs.js +1 -0
  48. package/src/ui/static/assets/SourcesPage-C_QVQwiA.js +14 -0
  49. package/src/ui/static/assets/TestExplorerPage-BRRWtwde.js +7 -0
  50. package/src/ui/static/assets/TestManagementPage-Ch4PthuU.js +10 -0
  51. package/src/ui/static/assets/TestPlansPage-Bno2vpGd.js +5 -0
  52. package/src/ui/static/assets/TestverCreditsDetail-cSW0SpNx.js +1 -0
  53. package/src/ui/static/assets/TestverCreditsRing-CUsMGEe3.js +1 -0
  54. package/src/ui/static/assets/UncommittedDiffViewer-B5HSURk8.js +2 -0
  55. package/src/ui/static/assets/UserManagementPage-BjY3ftxf.js +10 -0
  56. package/src/ui/static/assets/WorkflowsPage-BUu-LjZ8.js +83 -0
  57. package/src/ui/static/assets/aiHandoff-vhtR29Fh.js +1 -0
  58. package/src/ui/static/assets/ansiToHtml-DYRzYQV1.js +1 -0
  59. package/src/ui/static/assets/dark-logo-DCPcGDyT.svg +1 -0
  60. package/src/ui/static/assets/excel-BrxuVus5.js +1 -0
  61. package/src/ui/static/assets/formatDate-T65-Y6Mi.js +1 -0
  62. package/src/ui/static/assets/formatTestName-BKd2Uqhs.js +1 -0
  63. package/src/ui/static/assets/hiddenLlmProviders-setxgY_B.js +1 -0
  64. package/src/ui/static/assets/index-B0klHYbO.css +1 -0
  65. package/src/ui/static/assets/index-DpQhqcHv.js +11 -0
  66. package/src/ui/static/assets/index-DtBWNlVD.js +47 -0
  67. package/src/ui/static/assets/logo-C7ltqfpq.svg +1 -0
  68. package/src/ui/static/assets/runSelected-WlgnZcSF.js +1 -0
  69. package/src/ui/static/assets/sandboxStorage-BrzaG3ny.js +1 -0
  70. package/src/ui/static/assets/simpleMarkdown-kWs-10D8.js +5 -0
  71. package/src/ui/static/assets/useChartTheme-BFz2QcND.js +1 -0
  72. package/src/ui/static/assets/useDebouncedValue-BsHptIvX.js +1 -0
  73. package/src/ui/static/assets/useFeatureFlags-DqhngqgG.js +1 -0
  74. package/src/ui/static/assets/useJiraConnector-TM1Rfj1s.js +1 -0
  75. package/src/ui/static/assets/useOwnership-eW6Egd7X.js +1 -0
  76. package/src/ui/static/assets/useSuites-CvtMGakZ.js +1 -0
  77. package/src/ui/static/assets/useTabParam-ChbOedP1.js +1 -0
  78. package/src/ui/static/assets/useTestExplorer-HqvURJAc.js +1 -0
  79. package/src/ui/static/assets/useTestLifecycle-CL7-zz0Q.js +1 -0
  80. package/src/ui/static/assets/useTestManagement-ZTA1_VUm.js +2 -0
  81. package/src/ui/static/assets/useTestResults-Bm-JyMhB.js +1 -0
  82. package/src/ui/static/assets/vendor-charts-DWFQlmCz.js +73 -0
  83. package/src/ui/static/assets/vendor-excel-BFHGVHVC.js +24 -0
  84. package/src/ui/static/assets/vendor-flow-BnuhLJ6X.css +1 -0
  85. package/src/ui/static/assets/vendor-flow-YGpC9U9I.js +23 -0
  86. package/src/ui/static/assets/vendor-icons-B0wLOBoh.js +1421 -0
  87. package/src/ui/static/assets/vendor-query-BrzmPFT3.js +1 -0
  88. package/src/ui/static/assets/vendor-quill-CTpA5PSA.css +7 -0
  89. package/src/ui/static/assets/{index-Dy7b6SNH.js → vendor-quill-W-RoQfb6.js} +1 -1
  90. package/src/ui/static/assets/vendor-react-CTbHBddL.js +61 -0
  91. package/src/ui/static/assets/visibleInterval-BKsLfJZ3.js +1 -0
  92. package/src/ui/static/dark-logo.svg +1 -1
  93. package/src/ui/static/index.html +5 -2
  94. package/src/ui/static/logo.svg +1 -1
  95. package/src/ui/static/assets/dark-logo-BddlJH8z.svg +0 -1
  96. package/src/ui/static/assets/index-Bt4_s1e0.css +0 -7
  97. package/src/ui/static/assets/index-C9pBWd6z.js +0 -2250
  98. package/src/ui/static/assets/logo-DwQCjTm_.svg +0 -1
@@ -0,0 +1,12 @@
1
+ import{r as g,j as e,b as Hs,e as Vs}from"./vendor-react-CTbHBddL.js";import{eO as ps,b as Se,O as Ie,d1 as qs,N as ss,eP as ts,eQ as Ns,eR as Xs,eS as Qs,h as Cs,P as ze,d3 as R,ao as Qe,eT as Zs,eU as Js,eV as We,eW as et,eX as st,u as $s,eY as Ps,eZ as tt,e_ as at,e$ as nt,f0 as rt,f1 as it,f2 as ot,f3 as Ss,f4 as lt,f5 as ct,f6 as dt,f7 as ht,f8 as mt,f9 as xt,fa as zs,fb as ut,fc as gt,fd as pt,f as ft,fe as bt,ff as yt,fg as jt,fh as wt,fi as kt,fj as vt,a3 as Nt,fk as fs,fl as Ct,fm as $t,fn as Pt,d4 as St}from"./index-DtBWNlVD.js";import{Q as Ts,X as ue,y as Te,t as as,r as xe,I as zt,ae as Ze,ad as Tt,c$ as Ft,R as U,ac as Je,p as Lt,G as we,s as ge,b9 as De,d0 as bs,o as ce,bs as Oe,a$ as Me,n as ke,u as Fs,d1 as At,q as Fe,d2 as Ls,a2 as As,a3 as Rt,a9 as Bt,d3 as Gt,b6 as Rs,bL as ys,a4 as Dt,a_ as _e,m as Ot,A as Mt,aU as It,k as Ut,g as Et}from"./vendor-icons-B0wLOBoh.js";import{C as de}from"./ConfirmDialog-DNU3qoAP.js";import{d as Kt}from"./useTestResults-Bm-JyMhB.js";import{U as Yt}from"./UncommittedDiffViewer-B5HSURk8.js";import{f as Ge}from"./formatDate-T65-Y6Mi.js";import"./vendor-query-BrzmPFT3.js";const ye={merge:"merge",rebase:"rebase","cherry-pick":"cherry-pick",revert:"revert"},ae=(t,s,l=`${s}s`)=>`${t} ${t===1?s:l}`;function Wt(t){var N,C;const{status:s,remote:l,act:n,busy:r}=t,d=((N=s.conflictedPaths)==null?void 0:N.length)??0,o=s.operation??(s.mergeInProgress?{kind:"merge"}:void 0),x=s.pendingStash,i=s.stagedCount??0,m=((C=s.uncommittedChanges)==null?void 0:C.length)??0,p=s.remotes,w=!p||p.length>0,j=s.ahead??0,z=s.behind??0;if(o&&d>0)return o.kind==="merge"?{key:`resolve-merge-${d}`,title:`Resolve ${ae(d,"conflict")}`,message:e.jsxs(e.Fragment,{children:["Git couldn't combine the changes in ",ae(d,"file")," because both sides edited the same lines. Click a file in the red list to open the resolver, pick which version to keep (or both, or edit it), and mark it resolved — that stages it. When every file is done you commit the merge. ",e.jsx("b",{children:"Abort merge"})," in the orange banner goes back to before the pull or merge."]})}:{key:`resolve-${o.kind}-${d}`,title:`Resolve ${ae(d,"conflict")}, then Continue`,message:e.jsxs(e.Fragment,{children:["The ",ye[o.kind]," stopped because a commit clashes with the code it lands on. Resolve each file in the red list, then press ",e.jsx("b",{children:"Continue"})," — the ",ye[o.kind]," carries on with the next commit (it may stop again). ",e.jsx("b",{children:"Abort"})," goes back to before it started.",o.kind==="rebase"&&e.jsxs(e.Fragment,{children:[" In a rebase, ",e.jsx("b",{children:"“theirs” is your own commit"})," and “ours” is the incoming code — the resolver marks your side."]})]})};if((o==null?void 0:o.kind)==="merge")return{key:"commit-merge",title:"Commit the merge",message:e.jsx(e.Fragment,{children:"Every conflict is resolved and staged. A merge is finished by a commit that joins both histories — the Commit panel already has a message. After it lands, Push shares it."}),actions:[{label:"Go to Commit",onClick:n.goToCommit,primary:!0}]};if(o&&i===0&&(s.unstagedCount??0)===0)return{key:`skip-${o.kind}`,title:"Skip this commit",message:e.jsxs(e.Fragment,{children:["Your resolution keeps the code exactly as it already is, so this ",ye[o.kind]," step has nothing to commit — git can only leave that commit out. ",e.jsx("b",{children:"Skip this commit"})," carries on with the rest (nothing in your files changes); ",e.jsx("b",{children:"Abort"})," goes back to before the ",ye[o.kind]," started."]}),actions:[{label:"Skip this commit",onClick:n.skipStep,primary:!0,disabled:r}]};if(o)return{key:`continue-${o.kind}`,title:`Continue the ${ye[o.kind]}`,message:e.jsxs(e.Fragment,{children:["The conflicts are resolved. ",e.jsx("b",{children:"Continue"})," carries on with the remaining commits; ",e.jsx("b",{children:"Abort"})," goes back to before the ",ye[o.kind]," started."]}),actions:[{label:"Continue",onClick:n.continueOp,primary:!0,disabled:r}]};if(d>0&&x)return{key:`resolve-stash-${d}`,title:`Resolve ${ae(d,"file")} from your stash`,message:e.jsxs(e.Fragment,{children:["Your stashed changes (“",x.message,"”) came back, but clash with newer commits in ",ae(d,"file"),". Resolve each one in the red list — the stash is kept until you're done, so nothing is lost. Changed your mind? ",e.jsx("b",{children:"Back out"})," returns those files to the last commit and keeps the stash to try again later."]}),actions:[{label:"Back out",onClick:n.backOutStash,disabled:r}]};if(d>0)return{key:`resolve-${d}`,title:`Resolve ${ae(d,"conflict")}`,message:e.jsx(e.Fragment,{children:"Some files have conflicts. Click each one in the red list, choose which version to keep (or both, or edit it), and mark it resolved — that stages it."})};if(x)return{key:`drop-stash-${x.sha}`,title:"Done — drop the stash",message:e.jsxs(e.Fragment,{children:["Everything from “",x.message,"” is back in your files and the conflicts are resolved. The stash is still in the list as a copy; dropping it removes that copy so it can't be applied twice by mistake."]}),actions:[{label:"Drop the stash",onClick:n.dropStash,primary:!0,disabled:r}],tone:"green"};if(s.detached)return{key:"detached",title:"Create a branch to keep this work",message:e.jsxs(e.Fragment,{children:["HEAD is on a commit, not on a branch — commits made here belong to no branch and are easy to lose. Click ",e.jsx("b",{children:"+ Branch"})," in the toolbar to create one right here, or pick a branch in the branch list to go back to it."]})};if(!s.lastCommit&&m>0)return{key:"first-commit",title:"Make your first commit",message:e.jsxs(e.Fragment,{children:["This repository has no commits yet. Open the changes, ",e.jsx("b",{children:"Stage"})," the files that belong in it, write a short message and ",e.jsx("b",{children:"Commit"})," — that first snapshot is what everything else builds on."]}),actions:[{label:"Show changes",onClick:n.showChanges,primary:!0}]};if(i>0)return{key:`commit-${i}`,title:`Commit ${ae(i,"staged file")}`,message:e.jsxs(e.Fragment,{children:["Staged files go into the next commit; anything unstaged stays out. Write a message that says what changed and why, then ",e.jsx("b",{children:"Commit"})," (Ctrl+Enter). Commit small, related changes together."]}),actions:[{label:"Go to Commit",onClick:n.goToCommit,primary:!0}]};if(m>0)return{key:`stage-${m}`,title:"Choose what to commit",message:e.jsxs(e.Fragment,{children:["You have ",ae(m,"changed file"),". Open the changes to review them, then ",e.jsx("b",{children:"Stage"})," the ones that belong together (",e.jsx("b",{children:"Stage All"})," for everything). ",e.jsx("b",{children:"Discard"})," throws an edit away for good; ",e.jsx("b",{children:"Stash"})," puts everything aside for later."]}),actions:[{label:"Show changes",onClick:n.showChanges,primary:!0}]};if((l==null?void 0:l.verdict)==="rewritten"||t.opError)return null;if(w&&!!p&&!s.upstream&&!!s.branch&&!!s.lastCommit){const K=p!=null&&p.includes("origin")?"origin":p==null?void 0:p[0];return{key:`publish-${s.branch}`,title:`Publish ${s.branch}`,message:e.jsxs(e.Fragment,{children:["This branch exists only on this machine. Publishing pushes it to ",K," and connects the two, so Push and Pull work for it from then on — and teammates can see it."]}),actions:[{label:"Publish",onClick:n.push,primary:!0,disabled:r}]}}return j>0&&z>0?{key:`diverged-${j}-${z}`,title:"Pull first, then push",message:e.jsxs(e.Fragment,{children:["Your branch and the remote have both moved on: ",ae(j,"local commit"),", ",ae(z,"commit")," on the remote. The remote refuses a push until you have its commits — Pull to bring them in (resolving any conflicts), then Push."]}),actions:[{label:"Pull",onClick:n.pull,primary:!0,disabled:r}]}:j>0?{key:`push-${j}`,title:`Push ${ae(j,"commit")}`,message:e.jsx(e.Fragment,{children:"Your commits are only on this machine. Push sends them to the remote so teammates — and CI — get them."}),actions:[{label:"Push",onClick:n.push,primary:!0,disabled:r}]}:!w&&s.lastCommit?{key:"no-remote",title:"Connect a remote to share your work",message:e.jsxs(e.Fragment,{children:["This repository has no remote, so there is nowhere to push to. Add one in a terminal (",e.jsx("code",{className:"font-mono",children:"git remote add origin <url>"}),"), then Publish your branch here."]})}:z>0?l!=null&&l.ok&&!l.skipped&&l.behind>0?null:{key:`pull-${z}`,title:`Pull ${ae(z,"commit")}`,message:e.jsxs(e.Fragment,{children:["The remote has ",ae(z,"commit")," you don't have yet. Pull brings them into your branch and updates your files."]}),actions:[{label:"Pull",onClick:n.pull,primary:!0,disabled:r}]}:s.lastCommit?{key:`caught-up-${s.lastCommit.sha}`,title:"All caught up",message:e.jsxs(e.Fragment,{children:["Everything is committed",s.upstream?e.jsxs(e.Fragment,{children:[" and in sync with ",e.jsx("span",{className:"font-mono",children:s.upstream})]}):"",t.hiddenTestver?e.jsx(e.Fragment,{children:" (changes in Testver's own .testver folder are hidden and stay out of commits)"}):"",". Testver keeps checking the remote and tells you when new commits arrive."]}),tone:"green"}:null}function _t({step:t,onDismiss:s}){const l=t.tone==="green";return e.jsx("div",{className:`${l?"bg-emerald-500/10 border-emerald-500/40":"bg-sky-500/10 dark:bg-sky-500/10 border-sky-500/40"} border rounded-xl p-4`,role:"status",children:e.jsxs("div",{className:"flex items-start gap-3",children:[l?e.jsx(xe,{size:18,className:"text-emerald-600 dark:text-emerald-400 mt-0.5 shrink-0"}):e.jsx(zt,{size:18,className:"text-sky-600 dark:text-sky-400 mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:`text-sm font-semibold ${l?"text-emerald-700 dark:text-emerald-300":"text-sky-700 dark:text-sky-300"}`,children:["Next step — ",t.title]}),e.jsx("p",{className:"text-xs text-gray-700 dark:text-gray-300 mt-1 leading-relaxed",children:t.message}),t.actions&&t.actions.length>0&&e.jsx("div",{className:"flex items-center gap-2 mt-2.5 flex-wrap",children:t.actions.map(n=>e.jsx("button",{onClick:n.onClick,disabled:n.disabled,className:`px-3 py-1.5 rounded-lg text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${n.primary?l?"bg-emerald-600 hover:bg-emerald-500 text-white":"bg-sky-600 hover:bg-sky-500 text-white":"bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/10"}`,children:n.label},n.label))})]}),e.jsx("button",{onClick:s,className:`p-1 rounded shrink-0 ${l?"hover:bg-emerald-500/20 text-emerald-700 dark:text-emerald-300":"hover:bg-sky-500/20 text-sky-700 dark:text-sky-300"}`,title:"Dismiss","aria-label":"Dismiss",children:e.jsx(ue,{size:14})})]})})}const Ht=[{group:"Record your work",items:[["Show Diffs","Opens the list of changed files, split into Staged (going into the next commit) and Unstaged. Click a file to see its added (+) and removed (−) lines."],["Stage / Stage All","Puts a file's changes into the next commit. Only staged changes are committed, so you can commit related changes together and leave the rest for later."],["Unstage / Unstage All","Takes a file out of the next commit. Your edits stay in the file."],["Discard","Throws away a file's unstaged edits (an untracked file is deleted). This can't be undone — stash instead if you might want them back."],["Commit","Saves the staged changes as a snapshot with your message. Ctrl+Enter in the message box does the same."],["Amend last commit","Replaces the latest commit instead of adding one — to fix its message or add a forgotten file. Avoid it once the commit is pushed."],["Include .testver changes","Testver's own .testver folder (its settings, results and caches) is hidden and left out of commits so you can't overwrite your team's Testver data by accident. Turn this on — after a warning — only to share Testver configuration; it lasts for this browser tab."]]},{group:"Share and update",items:[["Fetch","Downloads the remote's new commits without changing your files, so you can see what's new before bringing it in."],["Pull","Brings the remote's new commits into your branch and updates your files. If both sides changed the same lines, you resolve the conflicts."],["Push","Sends your local commits to the remote so teammates and CI get them. The remote refuses it until you've pulled its newer commits."],["Publish","The first Push of a new branch: creates it on the remote and connects the two, so Push and Pull work from then on."],["Check again","Asks the remote right now whether there are new commits (Testver also checks on its own every few minutes)."],["Stash, pull & re-apply","For when new commits touch files you are editing: puts your edits aside, pulls, then puts them back. A clash opens the resolver and the stash is kept until you finish."],["Remind me later","Hides the new-commits banner for a while. The header and sidebar still show the count."]]},{group:"Branches",items:[["Branch list","Switches to another branch. Picking a remote branch (origin/…) creates a local branch that follows it the first time."],["+ Branch","Creates a new branch from where you are and switches to it — a safe place to try something without touching the main line."],["Save my commits on a branch & match","Only after the remote's history was rewritten: keeps your commits on a backup branch, then moves your branch to the remote's version."],["Delete my local branch","Offered when the remote branch was deleted. Removes your local copy — only when its commits are merged, so nothing is lost."]]},{group:"Stash — put work aside",items:[["Stash","Puts all your uncommitted changes aside so the files match the last commit. Testver's own .testver folder is never stashed."],["Pop","Brings back the newest stash and removes it from the list. If it clashes with newer commits, the stash is kept and you resolve the conflicts."],["Drop","Deletes a stash from the list for good."],["Back out","After a stash came back with conflicts: returns those files to the last commit and keeps the stash, to try again later."]]},{group:"Conflicts",items:[["Resolve (click a file in the red list)","Opens the resolver for one file. Each conflict shows your version (ours) and the incoming one (theirs)."],["Use ours / Use theirs / Both / Edit","Keeps your lines, the incoming lines, both, or lets you type the result yourself — per conflict, or for all at once."],["Mark resolved & stage","Writes the result into the file and stages it. Enabled once every conflict has a choice."],["Keep the file / Delete the file","When one side deleted the file and the other changed it."],["Keep yours / Keep incoming","For files that can't be merged line by line (images, spreadsheets): keeps one version whole."],["Ours / theirs","Ours is the branch you are on and theirs the change coming in — except in a rebase (ours = the incoming code, theirs = your own commit) and a stash being put back (theirs = your stashed edits). The resolver names each side and marks yours."],["Continue","Carries on with a rebase, cherry-pick or revert after its conflicts are resolved."],["Skip this commit","When your resolution kept the code exactly as it was, that step has nothing to commit: Skip leaves the commit out and carries on."],["Abort","Goes back to how things were before the merge, rebase, cherry-pick or revert started."]]}];function Vt({onClose:t}){const[s,l]=g.useState({"Record your work":!0});return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Ts,{size:18,className:"text-brand-400"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-200 flex-1",children:"Git actions explained"}),e.jsx("button",{onClick:t,className:"p-1.5 rounded hover:bg-white/5 text-gray-500","aria-label":"Close guide",title:"Close",children:e.jsx(ue,{size:15})})]}),e.jsxs("p",{className:"text-sm text-gray-500 mb-3",children:["What each button on this page does, in plain words. The blue ",e.jsx("b",{children:"Next step"})," banner always names the one thing to do now."]}),e.jsx("div",{className:"space-y-2",children:Ht.map(n=>e.jsxs("div",{className:"rounded-lg border border-white/5",children:[e.jsxs("button",{onClick:()=>l(r=>({...r,[n.group]:!r[n.group]})),"aria-expanded":!!s[n.group],className:"w-full flex items-center gap-2 px-3 py-2 text-sm font-semibold text-gray-200 text-left",children:[s[n.group]?e.jsx(Te,{size:14}):e.jsx(as,{size:14}),n.group]}),s[n.group]&&e.jsx("dl",{className:"px-3 pb-3 grid grid-cols-1 md:grid-cols-[14rem_1fr] gap-x-4 gap-y-2 text-sm",children:n.items.map(([r,d])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"font-medium text-gray-300",children:r}),e.jsx("dd",{className:"text-gray-500",children:d})]},r))})]},n.group))})]})}function qt({include:t,hidden:s,folder:l}){const[n,r]=g.useState(!1),[d,o]=g.useState(!1),x=l.replace(/\/$/,""),i=()=>{r(!1),o(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`mt-4 flex items-start gap-3 rounded-lg border px-3 py-2.5 text-xs ${t?"border-amber-500/40 bg-amber-500/10 text-amber-800 dark:text-amber-300":"border-white/5 bg-surface-2/60 text-gray-500"}`,children:[t?e.jsx(Ze,{size:14,className:"mt-0.5 shrink-0"}):e.jsx(Tt,{size:14,className:"mt-0.5 shrink-0"}),e.jsx("p",{className:"flex-1 leading-relaxed",children:t?e.jsxs(e.Fragment,{children:["Changes in ",e.jsx("span",{className:"font-mono",children:x})," are shown and can be staged and committed. Anything you commit there is shared with everyone who pulls this branch."]}):e.jsxs(e.Fragment,{children:[s," change",s===1?"":"s"," in ",e.jsx("span",{className:"font-mono",children:x}),", Testver's own working data, ",s===1?"is":"are"," hidden and left out of commits."]})}),e.jsxs("label",{className:"flex items-center gap-2 shrink-0 cursor-pointer select-none font-medium text-gray-700 dark:text-gray-300",title:t?"Hide the .testver folder again and keep it out of commits":"Show the .testver folder's changes so you can review and commit them",children:[e.jsx("span",{children:"Include .testver changes"}),e.jsx("button",{type:"button",role:"switch","aria-checked":t,onClick:()=>t?ps(!1):r(!0),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${t?"bg-amber-500":"bg-gray-400/50"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 rounded-full bg-white shadow transition-transform ${t?"translate-x-4":"translate-x-0.5"}`})})]})]}),e.jsxs(de,{open:n,title:"Include Testver's own files in commits?",description:`The ${x} folder is where Testver keeps its working data for this project. It is hidden and left out of commits so that work on your machine can't overwrite the tool's data for your team by accident.`,confirmLabel:"Show and allow committing",icon:Ft,size:"lg",confirmDisabled:!d,onCancel:i,onConfirm:()=>{ps(!0),i()},children:[e.jsxs("ul",{className:"mt-3 space-y-1.5 text-sm text-gray-400 list-disc pl-5",children:[e.jsx("li",{children:"It holds settings, run history and results, caches and the state of features in progress — data that belongs to this machine."}),e.jsxs("li",{children:["Once committed and pushed, everyone who pulls the branch gets your copy: their Testver settings and results can be ",e.jsx("b",{className:"text-gray-300",children:"replaced by yours"}),", and their next commit can overwrite yours just as easily."]}),e.jsx("li",{children:"Changes there are hard to review — most files are machine-written and change every time Testver runs."}),e.jsx("li",{children:"Sign-in data (accounts, passwords, keys) stays protected either way: Testver keeps it out of git on its own, and Settings warns you if any of it is already tracked."})]}),e.jsx("p",{className:"mt-3 text-sm text-gray-400",children:"Only turn this on when you mean to share Testver configuration with your team. It applies to this browser tab until you turn it off or close the tab."}),e.jsxs("label",{className:"mt-3 flex items-start gap-2 text-sm text-gray-300 cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:m=>o(m.target.checked),className:"mt-0.5"}),e.jsxs("span",{children:["I understand that committing ",x," shares Testver's data with everyone who pulls this branch."]})]})]})]})}const ne={primary:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-emerald-600 hover:bg-emerald-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",secondary:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",ghost:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-sm text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",amber:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-amber-600 hover:bg-amber-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",orange:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-orange-600 hover:bg-orange-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",red:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-red-600 hover:bg-red-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed"},Xt={sky:["bg-sky-500/10 border border-sky-500/40","text-sky-600 dark:text-sky-400","text-sky-700 dark:text-sky-300"],amber:["bg-amber-500/10 border border-amber-500/40","text-amber-600 dark:text-amber-400","text-amber-700 dark:text-amber-300"],orange:["bg-orange-500/10 dark:bg-orange-500/10 border border-orange-500/40","text-orange-600 dark:text-orange-400","text-orange-700 dark:text-orange-300"],red:["bg-red-500/10 dark:bg-red-500/10 border border-red-500/40","text-red-600 dark:text-red-400","text-red-700 dark:text-red-300"],gray:["bg-surface-1 border border-white/10","text-gray-500","text-gray-200"]};function je({tone:t,icon:s,title:l,sub:n,children:r,actions:d,onDismiss:o}){const[x,i,m]=Xt[t];return e.jsx("div",{className:`${x} rounded-xl p-4`,role:"status",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:`${i} mt-0.5 shrink-0`,children:s}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:`text-sm font-semibold ${m}`,children:l}),n&&e.jsx("p",{className:"text-xs text-gray-700 dark:text-gray-300 mt-1 leading-relaxed",children:n}),r,d&&e.jsx("div",{className:"flex items-center gap-2 mt-3 flex-wrap",children:d})]}),o&&e.jsx("button",{onClick:o,className:"p-1 rounded hover:bg-white/5 text-gray-500 shrink-0",title:"Hide","aria-label":"Hide",children:e.jsx(ue,{size:14})})]})})}function He({check:t,flag:s=[]}){const l=t.incoming.slice(0,5);return e.jsxs("div",{className:"mt-3 rounded-lg border border-white/10 bg-surface-1 px-1.5 py-1",children:[l.map(n=>e.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 rounded-lg text-sm",children:[e.jsx("span",{className:"font-mono text-brand-400 w-16 flex-shrink-0",children:n.shortSha}),e.jsx("span",{className:"text-gray-200 truncate flex-1 min-w-0",children:n.message}),n.files.some(r=>s.includes(r.path))&&e.jsx("span",{className:"text-[11px] px-2 py-0.5 rounded-full font-medium bg-amber-500/15 text-amber-600 dark:text-amber-300 flex-shrink-0",children:"touches a file you edited"}),e.jsxs("span",{className:"flex items-center gap-1 text-xs text-gray-400 flex-shrink-0 max-w-[10rem]",children:[e.jsx(Fe,{size:12,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:n.author})]}),e.jsx("span",{className:"text-xs text-gray-500 w-20 text-right flex-shrink-0",children:ze(n.timestamp)}),e.jsx("span",{className:"text-xs text-gray-500 w-14 text-right flex-shrink-0",children:R(n.files.length,"file")})]},n.sha)),t.behind>l.length&&e.jsxs("p",{className:"px-2 py-1 text-xs text-gray-500",children:["…and ",t.behind-l.length," more — View incoming changes"]})]})}function Qt({tone:t,children:s}){const l=t==="green"?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300";return e.jsxs("div",{className:`mt-3 flex items-start gap-2 rounded-lg border ${l} px-3 py-2 text-xs leading-relaxed`,children:[t==="green"?e.jsx(xe,{size:14,className:"mt-0.5 shrink-0"}):e.jsx(ce,{size:14,className:"mt-0.5 shrink-0"}),e.jsx("span",{children:s})]})}function Zt({sha:t}){const[s,l]=g.useState(!1);return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{className:ne.ghost,onClick:()=>l(n=>!n),"aria-expanded":s,children:[e.jsx(At,{size:14})," Remind me later ",e.jsx(Te,{size:12})]}),s&&e.jsx("div",{className:"absolute left-0 top-full mt-1 w-56 bg-surface-1 border border-white/10 rounded-lg z-50 py-1 shadow-2xl",children:[[60,"In 1 hour"],[240,"In 4 hours"],[1440*365,"When newer commits arrive"]].map(([n,r])=>e.jsx("button",{onClick:()=>{et(t,n),l(!1)},className:"w-full text-left px-3 py-1.5 text-sm text-gray-300 hover:bg-white/5",children:r},r))})]})}const Ve=({at:t})=>t?e.jsxs("span",{className:"text-[11px] text-gray-500 ml-auto flex items-center gap-1",children:[e.jsx(Fs,{size:11})," Checked ",ze(t)]}):null;function Jt({state:t,onViewIncoming:s,onStashPull:l,onPulled:n,onError:r,onConflicts:d}){var S,q,te,I,X,O,se,re,H,b,L;const{toast:o}=Se(),x=Ie(),i=qs(),m=ss(),p=ts(),w=Ns(),j=Xs(),z=Qs(),[M,N]=g.useState(null),[C,K]=g.useState(!1),[_,Y]=g.useState(!1),[,T]=g.useState(0);g.useEffect(()=>{const f=()=>T(k=>k+1);return window.addEventListener("testver-remote-snooze",f),()=>window.removeEventListener("testver-remote-snooze",f)},[]);const c=t==null?void 0:t.check;if(!c||c.skipped)return null;const F=Cs(c),P=`${c.verdict}:${c.upstreamSha??""}:${((S=c.error)==null?void 0:S.kind)??""}`;if(M===P)return null;const B=()=>i.mutate(void 0,{onSuccess:f=>{var v;const k=f.check;k&&!k.ok?r("Check",((v=k.error)==null?void 0:v.message)??"The remote could not be checked."):o(k&&k.behind>0?"info":"success",k&&k.behind>0?`${R(k.behind,"new commit")} on ${F}`:`Up to date with ${F}`)},onError:f=>r("Check",f.message)}),D=()=>m.mutate(void 0,{onSuccess:f=>{var k;if(f.conflicts&&((k=f.conflictedPaths)!=null&&k.length)){d(f.conflictedPaths),o("error",`Pull stopped on ${R(f.conflictedPaths.length,"conflict")} — resolve them below`);return}n==null||n(),o("success",`Pulled ${R(c.behind,"commit")} from ${F}`)},onError:f=>r("Pull",f.message)}),W=e.jsxs("button",{className:ne.secondary,onClick:B,disabled:x,children:[e.jsx(U,{size:14,className:i.isPending?"animate-spin":""})," Check again"]}),Z=e.jsxs("button",{className:ne.secondary,onClick:s,children:[e.jsx(Ze,{size:14})," View incoming changes"]});if(!c.ok){const f=((q=c.error)==null?void 0:q.kind)==="auth"?`${F} asked for a sign-in, and background checks never pop up a password prompt.`:((te=c.error)==null?void 0:te.kind)==="network"?`${F} couldn't be reached (no network, or the server is down).`:"Git reported an error.";return e.jsx(je,{tone:"gray",icon:((I=c.error)==null?void 0:I.kind)==="auth"?e.jsx(Je,{size:18}):e.jsx(Lt,{size:18}),title:`Couldn't check ${F} for new commits`,sub:e.jsxs(e.Fragment,{children:[f," ",t!=null&&t.lastSuccessAt?`Last successful check: ${ze(t.lastSuccessAt)}.`:"",((X=c.error)==null?void 0:X.kind)==="auth"&&" Click Check now and sign in once — tick “Remember for this session” and the checks carry on by themselves."]}),actions:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:ne.secondary,onClick:B,disabled:x,children:[e.jsx(U,{size:14,className:i.isPending?"animate-spin":""})," Check now"]}),((O=c.error)==null?void 0:O.kind)==="other"&&e.jsx("span",{className:"text-[11px] text-gray-500 truncate max-w-[40rem]",title:c.error.message,children:c.error.message})]}),onDismiss:()=>N(P)})}if(c.verdict==="deleted"){const f=(se=c.deleted)==null?void 0:se.defaultBranch,k=f?f.slice(f.indexOf("/")+1):void 0;return e.jsxs(e.Fragment,{children:[e.jsx(je,{tone:"amber",icon:e.jsx(we,{size:18}),title:`${c.upstream} was deleted on ${F}`,sub:e.jsxs(e.Fragment,{children:["The remote branch ",e.jsx("span",{className:"font-mono",children:c.branch})," tracks is gone — usually because its pull request was merged.",(re=c.deleted)!=null&&re.allMerged&&f?` All your commits are already in ${f}.`:""]}),actions:e.jsxs(e.Fragment,{children:[f&&e.jsxs("button",{className:ne.primary,disabled:x,onClick:()=>w.mutate(f,{onSuccess:()=>m.mutate(void 0,{onSuccess:v=>{var ie;v.conflicts&&((ie=v.conflictedPaths)!=null&&ie.length)?d(v.conflictedPaths):o("success",`Switched to ${k} and pulled`)},onError:v=>r("Pull",v.message)}),onError:v=>r("Switch branch",v.message)}),children:[e.jsx(we,{size:14})," Switch to ",k," & pull"]}),e.jsxs("button",{className:ne.secondary,disabled:x,onClick:()=>p.mutate(void 0,{onSuccess:()=>o("success",`Published ${c.branch} again`),onError:v=>r("Publish",v.message)}),children:[e.jsx(ge,{size:14,className:"rotate-180"})," Publish it again"]}),f&&e.jsxs("button",{className:ne.secondary,disabled:x,onClick:()=>Y(!0),children:[e.jsx(De,{size:14})," Delete my local branch"]}),e.jsx(Ve,{at:c.checkedAt})]}),onDismiss:()=>N(P)}),e.jsx(de,{open:_,title:`Delete ${c.branch}?`,description:`Testver switches to ${k} first, then deletes your local ${c.branch}. Git refuses if it has commits that aren't merged anywhere, so nothing is lost.`,confirmLabel:"Switch & delete",onCancel:()=>Y(!1),onConfirm:()=>{Y(!1);const v=c.branch;w.mutate(f,{onSuccess:()=>j.mutate(v,{onSuccess:()=>o("success",`Deleted ${v}`),onError:ie=>r("Delete branch",ie.message)}),onError:ie=>r("Switch branch",ie.message)})}})]})}if(c.verdict==="rewritten"){const f=((H=c.rewritten)==null?void 0:H.lost)??[],k=`${c.branch}-before-${new Date().toISOString().slice(0,10)}`;return e.jsxs(e.Fragment,{children:[e.jsx(je,{tone:"red",icon:e.jsx(ce,{size:18}),title:`${c.upstream} was rewritten on ${F} (force-pushed)`,sub:e.jsxs(e.Fragment,{children:[F,"'s ",(b=c.upstream)==null?void 0:b.slice(c.upstream.indexOf("/")+1)," no longer contains ",R(((L=c.rewritten)==null?void 0:L.lostCommits)??0,"commit")," that your ",c.branch," has",f.length?e.jsxs(e.Fragment,{children:[" (",e.jsxs("span",{className:"font-mono",children:[f.slice(0,3).join(", "),f.length>3?", …":""]}),")"]}):null,c.behind?e.jsxs(e.Fragment,{children:[", and has ",R(c.behind,"new one")," instead"]}):null,". A normal Pull would mix the old and new history, so Testver won't offer it."]}),actions:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:ne.secondary,onClick:s,children:[e.jsx(Ze,{size:14})," Compare the two histories"]}),e.jsxs("button",{className:ne.red,disabled:x,onClick:()=>K(!0),children:[e.jsx(bs,{size:14})," Save my commits on a branch & match ",F]}),e.jsx(Ve,{at:c.checkedAt})]}),onDismiss:()=>N(P),children:e.jsxs("div",{className:"mt-3 rounded-lg border border-white/10 bg-surface-1 px-3 py-2.5 text-xs text-gray-700 dark:text-gray-300 leading-relaxed space-y-1",children:[e.jsxs("div",{children:[e.jsx("b",{className:"text-gray-200",children:"Usually:"})," someone cleaned up history on purpose — ask them first."]}),e.jsxs("div",{children:[e.jsxs("b",{className:"text-gray-200",children:["Match ",F,":"]})," keeps your commits safe on a new branch ",e.jsx("span",{className:"font-mono",children:k}),", then moves ",c.branch," to ",F,"'s version. Nothing is deleted."]})]})}),e.jsx(de,{open:C,title:`Match ${F}'s ${c.upstream}?`,description:`Your current ${c.branch} is saved as a new branch (${k}), then ${c.branch} is moved to ${c.upstream}. Uncommitted changes must be committed or stashed first.`,confirmLabel:"Save & match",icon:bs,onCancel:()=>K(!1),onConfirm:()=>{K(!1),z.mutate(void 0,{onSuccess:v=>o("success",`Your commits are on ${v.backup}; ${c.branch} now matches ${F}`),onError:v=>r("Match remote",v.message)})}})]})}if(!Qe(c)||Zs(c.upstreamSha))return null;const V=Js(c),ee=e.jsxs(e.Fragment,{children:[R(c.stats.files,"file")," · ",e.jsxs("span",{className:"text-emerald-600",children:["+",c.stats.additions]})," ",e.jsxs("span",{className:"text-red-600",children:["−",c.stats.deletions]})]}),J=c.prediction==="estimate"?"may":"will",y=e.jsxs(e.Fragment,{children:[Z,W,e.jsx(Zt,{sha:c.upstreamSha}),e.jsx(Ve,{at:c.checkedAt})]});if(c.verdict==="uncommitted_overlap"){const f=c.conflictFiles.length;return e.jsxs(je,{tone:"amber",icon:e.jsx(ce,{size:18}),title:`${R(c.behind,"new commit")} on ${F} — and ${c.overlapFiles.length===1?"1 of them changes a file":"they change files"} you are editing`,sub:e.jsxs(e.Fragment,{children:[V," changed ",e.jsx("b",{className:"font-mono",children:We(c.overlapFiles)}),", which ",c.overlapFiles.length===1?"has":"have"," your uncommitted edits. Git won't pull over uncommitted changes to the same file."]}),actions:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:ne.amber,disabled:x,onClick:l,children:[e.jsx(Oe,{size:14})," Stash, pull & re-apply"]}),e.jsxs("button",{className:ne.secondary,onClick:()=>{var k;return(k=document.getElementById("git-commit-panel"))==null?void 0:k.scrollIntoView({behavior:"smooth",block:"center"})},children:[e.jsx(Me,{size:14})," Commit my changes first"]}),y]}),onDismiss:()=>N(P),children:[e.jsx(He,{check:c,flag:c.overlapFiles}),e.jsxs("div",{className:"mt-3 rounded-lg border border-white/10 bg-surface-1 px-3 py-2.5 text-xs text-gray-700 dark:text-gray-300 leading-relaxed",children:[e.jsx("div",{className:"font-semibold text-gray-200 mb-1",children:"What “Stash, pull & re-apply” does"}),e.jsxs("ol",{className:"list-decimal pl-5 space-y-0.5",children:[e.jsxs("li",{children:["Puts your ",R(c.dirtyFiles.length,"changed file")," aside on a stash (nothing is lost)."]}),e.jsxs("li",{children:["Pulls the ",R(c.behind,"commit"),"."]}),e.jsxs("li",{children:["Puts your changes back. ",f>0?e.jsxs("span",{className:"text-amber-600 dark:text-amber-300",children:["Your edits and the new commits touch the same lines in ",We(c.conflictFiles),", so this ",J," need you to resolve ",R(f,"conflict")," — the editor opens for ",f===1?"it":"them",", and the stash is kept until you're done."]}):e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-300",children:["Your edits ",c.prediction==="estimate"?"should":"will"," go back cleanly."]})]})]})]})]})}if(c.verdict==="will_conflict"){const f=c.conflictFiles.length,k=c.incomingFiles.filter(v=>!c.conflictFiles.includes(v));return e.jsxs(je,{tone:"orange",icon:e.jsx(ke,{size:18}),title:`${R(c.behind,"new commit")} on ${F} — pulling ${J} need you to resolve ${R(f,"file")}`,sub:e.jsxs(e.Fragment,{children:["Your ",R(c.ahead,"local commit")," and ",V,"'s commits changed the same lines.",c.prediction==="exact"?" Testver test-merged them without touching your files:":" These files changed on both sides:"]}),actions:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:ne.orange,disabled:x,onClick:D,children:[e.jsx(ge,{size:14})," Pull & resolve"]}),y]}),onDismiss:()=>N(P),children:[e.jsx(He,{check:c}),e.jsxs("div",{className:"mt-3 rounded-lg border border-orange-500/30 bg-surface-1 px-3 py-2 text-xs",children:[c.conflictFiles.slice(0,8).map(v=>e.jsxs("div",{className:"flex items-center gap-2 py-1",children:[e.jsx(ke,{size:13,className:"text-orange-500"}),e.jsx("span",{className:"font-mono text-gray-200 flex-1 truncate",children:v})]},v)),k.length>0&&e.jsxs("div",{className:"flex items-center gap-2 py-1 text-emerald-600 dark:text-emerald-300",children:[e.jsx(xe,{size:13}),e.jsxs("span",{className:"flex-1",children:[We(k)," merge cleanly"]})]})]})]})}return e.jsxs(je,{tone:"sky",icon:e.jsx(ge,{size:18}),title:`${R(c.behind,"new commit")} on ${F} — ${c.upstream}`,sub:e.jsxs(e.Fragment,{children:[V," pushed ",R(c.behind,"commit")," since you last pulled · ",ee,". Your files don't change until you pull."]}),actions:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:ne.primary,disabled:x,onClick:D,children:[e.jsx(ge,{size:14,className:m.isPending?"animate-pulse":""})," Pull now"]}),y]}),onDismiss:()=>N(P),children:[e.jsx(He,{check:c}),e.jsxs(Qt,{tone:"green",children:[e.jsx("b",{children:"Pulls cleanly."})," ",c.ahead>0?`Your ${R(c.ahead,"local commit")} and the incoming ones don't touch the same lines.`:"None of the incoming files clash with your uncommitted changes."]})]})}function ea({sha:t,path:s,additions:l,deletions:n,edited:r}){var p,w;const[d,o]=g.useState(!1),{data:x,isLoading:i}=$s(d?t:null),m=(w=(p=x==null?void 0:x.files)==null?void 0:p.find(j=>j.path===s))==null?void 0:w.patch;return e.jsxs("div",{className:"rounded border border-white/5 bg-surface-1/50",children:[e.jsxs("button",{className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-left",onClick:()=>o(j=>!j),"aria-expanded":d,children:[e.jsx("span",{className:"text-gray-500",children:d?e.jsx(Te,{size:13}):e.jsx(as,{size:13})}),e.jsx("span",{className:"text-gray-200 font-mono truncate flex-1",children:s}),r&&e.jsx("span",{className:"text-[11px] px-2 py-0.5 rounded-full font-medium bg-amber-500/15 text-amber-600 dark:text-amber-300 flex-shrink-0",children:"you have uncommitted edits here"}),e.jsxs("span",{className:"text-emerald-500 text-sm",children:["+",l]}),e.jsxs("span",{className:"text-red-500 text-sm",children:["-",n]})]}),d&&(i?e.jsxs("div",{className:"px-3 py-2 text-xs text-gray-500 flex items-center gap-1.5 border-t border-white/5",children:[e.jsx(U,{size:10,className:"animate-spin"})," Loading diff…"]}):m?e.jsx("pre",{className:"px-3 py-2 text-sm text-gray-300 overflow-x-auto border-t border-white/5 font-mono whitespace-pre leading-relaxed max-h-96 overflow-y-auto",children:m.split(`
2
+ `).map((j,z)=>e.jsx("div",{className:j.startsWith("+")&&!j.startsWith("+++")?"text-emerald-500":j.startsWith("-")&&!j.startsWith("---")?"text-red-500":j.startsWith("@@")?"text-brand-400":"",children:j||" "},z))}):e.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 border-t border-white/5",children:"No text diff for this file (binary, or too large)."}))]})}function js({c:t,dirty:s}){return e.jsxs("div",{className:"rounded-lg border border-white/5 bg-surface-2/40 p-3",children:[e.jsxs("div",{className:"flex items-center gap-3 text-sm mb-2",children:[e.jsx("span",{className:"font-mono text-brand-400",children:t.shortSha}),e.jsx("span",{className:"text-gray-200 flex-1 truncate",children:t.message}),e.jsxs("span",{className:"flex items-center gap-1 text-xs text-gray-400",children:[e.jsx(Fe,{size:12})," ",t.author]}),e.jsx("span",{className:"text-xs text-gray-500",children:ze(t.timestamp)})]}),e.jsx("div",{className:"space-y-1.5",children:t.files.map(l=>e.jsx(ea,{sha:t.sha,path:l.path,additions:l.additions,deletions:l.deletions,edited:s.has(l.path)},l.path))})]})}function sa({check:t,onClose:s,onPull:l,pullDisabled:n}){const{data:r,isLoading:d}=st(!0),o=new Set(t.dirtyFiles),x=Cs(t),i=(r==null?void 0:r.incoming)??[],m=(r==null?void 0:r.outgoing)??[],p=t.verdict==="rewritten";return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ge,{size:18,className:"text-sky-600"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-200 flex-1",children:p?`${t.branch} and ${t.upstream}`:`Incoming from ${t.upstream}`}),l&&!p&&e.jsxs("button",{onClick:l,disabled:n,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-emerald-600 hover:bg-emerald-500 text-white transition-colors disabled:opacity-50",children:[e.jsx(ge,{size:14})," Pull now"]}),e.jsx("button",{onClick:s,className:"p-1.5 rounded hover:bg-white/5 text-gray-500","aria-label":"Close",title:"Close",children:e.jsx(ue,{size:15})})]}),e.jsx("p",{className:"text-sm text-gray-500 mb-4",children:p?`${x} rewrote ${t.upstream}. Below: what only ${x} has, and what only your ${t.branch} has (those are kept on a backup branch if you match ${x}).`:e.jsxs(e.Fragment,{children:[R(t.behind,"commit")," · ",R(t.stats.files,"file")," · ",e.jsxs("span",{className:"text-emerald-500",children:["+",t.stats.additions]})," ",e.jsxs("span",{className:"text-red-500",children:["−",t.stats.deletions]})," — what Pull would bring into your files."]})}),d?e.jsxs("div",{className:"py-6 text-sm text-gray-500 flex items-center gap-2 justify-center",children:[e.jsx(U,{size:14,className:"animate-spin"})," Loading commits…"]}):e.jsxs("div",{className:"space-y-3",children:[p&&e.jsxs("h4",{className:"text-xs font-semibold uppercase text-gray-500 flex items-center gap-1.5",children:[e.jsx(ge,{size:12})," Only on ",x]}),i.length===0&&e.jsx("p",{className:"text-sm text-gray-500",children:"Nothing incoming."}),i.map(w=>e.jsx(js,{c:w,dirty:o},w.sha)),i.length>=50&&e.jsx("p",{className:"text-xs text-gray-500",children:"Showing the newest 50."}),(p||m.length>0)&&e.jsxs(e.Fragment,{children:[e.jsxs("h4",{className:"text-xs font-semibold uppercase text-gray-500 flex items-center gap-1.5 pt-2",children:[e.jsx(Ls,{size:12})," Only in your ",t.branch]}),m.length===0&&e.jsx("p",{className:"text-sm text-gray-500",children:"Nothing."}),m.map(w=>e.jsx(js,{c:w,dirty:o},w.sha))]})]})]})}function qe({state:t,title:s,detail:l}){const n=t==="done"?e.jsx(xe,{size:18,className:"text-emerald-500"}):t==="warn"?e.jsx(ce,{size:18,className:"text-amber-500"}):t==="fail"?e.jsx(As,{size:18,className:"text-red-500"}):t==="busy"?e.jsx(Rt,{size:18,className:"text-sky-500 animate-spin"}):e.jsx("span",{className:"w-[18px] h-[18px] rounded-full border-2 border-white/10 inline-block"});return e.jsxs("div",{className:"flex items-start gap-3 py-2",children:[e.jsx("span",{className:"mt-0.5 shrink-0",children:n}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-200",children:s}),l&&e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:l})]})]})}function ta({upstream:t,dirtyCount:s,behind:l,running:n,result:r,error:d,onClose:o,onResolve:x}){const i=r,m=i?i.conflictedPaths[0]??i.pullConflicts[0]:void 0;return Hs.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:n?void 0:o}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"stash-pull-title",className:"relative bg-surface-1 rounded-xl border border-white/10 p-6 w-[640px] max-w-[90vw] animate-fade-in",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-500/15 flex items-center justify-center flex-shrink-0 text-amber-500",children:e.jsx(Oe,{size:20})}),e.jsxs("div",{children:[e.jsx("h3",{id:"stash-pull-title",className:"text-base font-semibold text-gray-100",children:"Stash, pull & re-apply"}),e.jsxs("p",{className:"text-sm text-gray-400 mt-1",children:["Bringing in ",R(l,"commit")," from ",t," around your ",R(s,"changed file"),"."]})]})]}),e.jsxs("div",{className:"divide-y divide-white/5 border-y border-white/5 my-4",children:[e.jsx(qe,{state:n&&!i?"busy":i?(i.stashed,"done"):d?"fail":"idle",title:i?i.stashed?"Your changes are stashed":"Nothing needed stashing":"Stashing your changes",detail:i!=null&&i.stashed?e.jsxs(e.Fragment,{children:[R(i.cleanFiles.length+i.conflictedPaths.length||s,"file")," set aside as “",i.stashMessage,"”."]}):void 0}),e.jsx(qe,{state:i?i.pullConflicts.length?"warn":"done":n?"idle":d?"fail":"idle",title:i?i.pullConflicts.length?`Pulled — ${R(i.pullConflicts.length,"file")} need${i.pullConflicts.length===1?"s":""} resolving`:`Pulled ${R(i.commitsPulled||l,"commit")}`:`Pulling from ${t}`,detail:i&&!i.pullConflicts.length?`${t.split("/").slice(1).join("/")||"The branch"} is now up to date${i.head?` (${i.head.slice(0,7)})`:""}.`:i!=null&&i.pullConflicts.length?"Your local commits and the incoming ones clash. Resolve them and commit the merge; your stashed edits wait until then.":void 0}),e.jsx(qe,{state:i?i.reapplied==="clean"?"done":i.reapplied==="conflicts"?"warn":i.reapplied==="failed"?"fail":"idle":"idle",title:i?i.reapplied==="clean"?"Your changes are back":i.reapplied==="conflicts"?`Your changes are back — ${R(i.conflictedPaths.length,"file")} need${i.conflictedPaths.length===1?"s":""} resolving`:i.reapplied==="failed"?"Your changes could not be put back":i.stashKept?"Your changes wait in the stash":"Nothing to put back":"Putting your changes back",detail:i?i.reapplied==="conflicts"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono",children:i.conflictedPaths.join(", ")}),": your edits and the new commits touch the same lines.",i.cleanFiles.length?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"font-mono",children:i.cleanFiles.join(", ")})," came back cleanly."]}):null," The stash is kept until you finish."]}):i.reapplied==="failed"?i.message:i.reapplied==="clean"&&i.stashed?"The stash was removed.":i.message:void 0})]}),d&&e.jsx("p",{className:"mb-4 text-sm text-red-600 dark:text-red-400 whitespace-pre-wrap break-words",children:d}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:o,disabled:n,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 disabled:opacity-50",children:m?"Later":"Close"}),m&&e.jsxs("button",{onClick:()=>x(m),className:"px-4 py-2 text-sm rounded-lg bg-orange-600 hover:bg-orange-500 text-white font-medium flex items-center gap-1.5",children:[e.jsx(ke,{size:14})," Resolve ",m]})]})]})]}),document.body)}function aa({onConflicts:t,onError:s,onSuccessClearError:l}){var be;const{toast:n}=Se(),{data:r}=Ps(),{data:d}=tt(),{data:o}=at(),x=nt(),i=ss(),m=ts(),p=rt(),w=Ns(),j=it(),z=ot(),M=Ss(),[N,C]=g.useState(!1),[K,_]=g.useState(""),[Y,T]=g.useState(0),c=()=>{ct().then(({count:h})=>T(h)).catch(()=>{})};g.useEffect(()=>{c();const h=()=>c();return window.addEventListener("askpass-cache-changed",h),()=>window.removeEventListener("askpass-cache-changed",h)},[]);const[F,P]=g.useState(!1),[B,D]=g.useState(""),[W,Z]=g.useState(null),[V,ee]=g.useState(null),[J,y]=g.useState(!1),S=(r==null?void 0:r.ahead)||0,q=(r==null?void 0:r.behind)||0,te=(r==null?void 0:r.isClean)??!0,I=r==null?void 0:r.remotes,X=I===void 0||I.length>0,O=I!=null&&I.includes("origin")?"origin":(I==null?void 0:I[0])??"origin",se=!!I&&X&&!(r!=null&&r.upstream)&&!!(r!=null&&r.branch)&&!(r!=null&&r.detached)&&!!(r!=null&&r.lastCommit),re=!!(r!=null&&r.detached),H=(o==null?void 0:o.stashes)||[],b=H.length>0,L=()=>{x.mutate(void 0,{onSuccess:()=>{l==null||l(),n("success","Fetch complete")},onError:h=>s==null?void 0:s("Fetch",h.message)})},f=()=>{i.mutate(void 0,{onSuccess:h=>{var he;if(h.conflicts&&h.conflictedPaths&&h.conflictedPaths.length>0){t==null||t(h.conflictedPaths),l==null||l(),n("error",`Pull produced ${h.conflictedPaths.length} conflict${h.conflictedPaths.length===1?"":"s"} — resolve before continuing`);return}l==null||l();const $=((he=h.files)==null?void 0:he.length)||0;n("success",$>0?`Pulled ${$} file${$!==1?"s":""}`:"Already up to date")},onError:h=>s==null?void 0:s("Pull",h.message)})},k=()=>{m.mutate(void 0,{onSuccess:h=>{l==null||l(),n("success",h.published?`Published ${(r==null?void 0:r.branch)??"branch"} to ${h.published}`:"Push complete")},onError:h=>s==null?void 0:s("Push",h.message)})},v=h=>{if(!(!h||h===(d==null?void 0:d.current))){if(!te){Z(h);return}ie(h)}},ie=h=>{w.mutate(h,{onSuccess:$=>n("success",$.created?`Created ${$.branch}, tracking ${$.tracking}`:$.tracking?`Switched to your local ${$.branch} — Pull to bring in ${$.tracking}`:`Switched to ${$.branch}`),onError:$=>s==null?void 0:s("Switch branch",$.message)})},ve=()=>{const h=K.trim();h&&p.mutate({name:h,checkout:!0},{onSuccess:()=>{n("success",`Created and switched to ${h}`),_(""),C(!1)},onError:$=>s==null?void 0:s("Create branch",$.message)})},Ae=()=>{const h=B.trim()||void 0;j.mutate({message:h,includeUntracked:!0},{onSuccess:$=>{n($.saved?"success":"info",$.message),D(""),P(!1)},onError:$=>s==null?void 0:s("Stash",$.message)})},Ne=()=>{var h;b&&z.mutate({ref:"stash@{0}",sha:(h=H[0])==null?void 0:h.sha},{onSuccess:$=>{if($.conflicts){t==null||t($.conflictedPaths??[]),n("info",$.message);return}l==null||l(),n("success",$.message)},onError:$=>s==null?void 0:s("Stash pop",$.message)})},Ue=()=>{if(!V)return;const h=`stash@{${V.index}}`,$=V.sha;ee(null),M.mutate({ref:h,sha:$},{onSuccess:he=>n("success",he.message),onError:he=>s==null?void 0:s("Drop stash",he.message)})},oe=Ie(),Ce=(d==null?void 0:d.branches)||[],fe=(d==null?void 0:d.remoteBranches)||[];return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{onClick:L,disabled:x.isPending||oe||!X,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/5 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:X?"Fetch — download the remote's new commits without changing your files, to see what's new before pulling":"This repository has no remote configured",children:[x.isPending?e.jsx(U,{size:12,className:"animate-spin"}):e.jsx(Bt,{size:12}),"Fetch"]}),e.jsxs("button",{onClick:f,disabled:i.isPending||oe||!X||se||re,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/5 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:X?re?"Not on a branch — switch to a branch to pull":se?"This branch is not published yet — there is nothing to pull":"Pull — bring the remote's new commits into this branch and update your files (you resolve any conflicts)":"This repository has no remote configured",children:[i.isPending?e.jsx(U,{size:12,className:"animate-spin"}):e.jsx(ge,{size:12}),"Pull",q>0&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold bg-amber-500/20 text-amber-400",children:q})]}),e.jsxs("button",{onClick:k,disabled:m.isPending||oe||!X||re||!se&&S===0,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/5 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:X?re?"Not on a branch — switch to a branch to push":r!=null&&r.lastCommit?se?`Publish — push ${r==null?void 0:r.branch} to ${O} for the first time and connect them, so Push and Pull work from then on`:S===0?"Nothing to push":q>0?`The remote has ${q} commit${q===1?"":"s"} you don't have — pull first, then push`:"Push — send your local commits to the remote so teammates and CI get them":"Nothing to push yet — make a first commit":"This repository has no remote configured",children:[m.isPending?e.jsx(U,{size:12,className:"animate-spin"}):e.jsx(Ls,{size:12}),se?"Publish":"Push",S>0&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold bg-emerald-500/20 text-emerald-400",children:S})]})]}),Y>0&&e.jsxs("button",{onClick:()=>y(!0),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-surface-2 hover:bg-surface-3 text-amber-400 border border-amber-500/20 transition-colors",title:`Forget ${Y} remembered credential${Y===1?"":"s"}`,children:[e.jsx(Je,{size:12}),"Clear saved credentials",e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-amber-500/20 text-amber-300 font-semibold",children:Y})]}),e.jsx("div",{className:"w-px h-5 bg-white/10 mx-1"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[F?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"text",value:B,onChange:h=>D(h.target.value),onKeyDown:h=>{h.key==="Enter"&&Ae(),h.key==="Escape"&&(P(!1),D(""))},placeholder:"Optional stash message",className:"bg-surface-2 border border-white/10 rounded px-2 py-1 text-sm text-gray-200 w-48 focus:outline-none focus:border-violet-500/50",autoFocus:!0}),e.jsx("button",{onClick:Ae,disabled:j.isPending,className:"px-2 py-1 rounded text-xs bg-violet-600 hover:bg-violet-500 text-white disabled:opacity-50",children:j.isPending?e.jsx(U,{size:10,className:"animate-spin"}):"Save"}),e.jsx("button",{onClick:()=>{P(!1),D("")},className:"p-1 rounded hover:bg-surface-3 text-gray-500",title:"Cancel","aria-label":"Cancel stash",children:e.jsx(ue,{size:12})})]}):e.jsxs("button",{onClick:()=>P(!0),disabled:te||oe,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/5 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:te?"Nothing to stash":"Stash — put all your uncommitted changes aside so the files match the last commit; Pop brings them back",children:[e.jsx(Oe,{size:12})," Stash",H.length>0&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold bg-violet-500/20 text-violet-300",children:H.length})]}),b&&e.jsxs("button",{onClick:Ne,disabled:oe,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-surface-2 hover:bg-surface-3 text-violet-300 border border-white/5 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:`Pop — bring back the newest stash (${((be=H[0])==null?void 0:be.message)||""}) and remove it from the list; if it clashes with newer commits it is kept and you resolve the conflicts`,children:[z.isPending?e.jsx(U,{size:12,className:"animate-spin"}):e.jsx(Gt,{size:12}),"Pop"]})]}),e.jsx("div",{className:"w-px h-5 bg-white/10 mx-1"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(we,{size:13,className:"text-sky-400"}),e.jsxs("select",{value:(d==null?void 0:d.current)||"",onChange:h=>v(h.target.value),disabled:w.isPending||oe,className:"bg-surface-2 border border-white/5 rounded-lg px-2 py-1.5 text-sm text-gray-200 disabled:opacity-50 cursor-pointer focus:outline-none focus:border-sky-500/50 max-w-[260px]",children:[(d==null?void 0:d.detached)&&e.jsxs("option",{value:"",children:[d.detached," (current)"]}),Ce.length>0&&e.jsx("optgroup",{label:"Local",children:Ce.map(h=>e.jsxs("option",{value:h.name,children:[h.name,h.current?" (current)":""]},h.name))}),fe.length>0&&e.jsx("optgroup",{label:"Remote tracking",children:fe.map(h=>e.jsx("option",{value:h.name,children:h.name},h.name))}),Ce.length===0&&fe.length===0&&e.jsx("option",{value:"",children:(r==null?void 0:r.branch)||"No branches"})]}),N?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"text",value:K,onChange:h=>_(h.target.value),onKeyDown:h=>{h.key==="Enter"&&ve(),h.key==="Escape"&&(C(!1),_(""))},placeholder:"branch-name",className:"bg-surface-2 border border-white/10 rounded px-2 py-1 text-sm text-gray-200 w-40 focus:outline-none focus:border-sky-500/50",autoFocus:!0}),e.jsx("button",{onClick:ve,disabled:!K.trim()||oe,className:"px-2 py-1 rounded text-xs bg-sky-600 hover:bg-sky-500 text-white disabled:opacity-50 disabled:cursor-not-allowed",children:p.isPending?e.jsx(U,{size:10,className:"animate-spin"}):"Create"}),e.jsx("button",{onClick:()=>{C(!1),_("")},className:"p-1 rounded hover:bg-surface-3 text-gray-500",title:"Cancel","aria-label":"Cancel new branch",children:e.jsx(ue,{size:12})})]}):e.jsxs("button",{onClick:()=>C(!0),disabled:oe,className:"flex items-center gap-1 px-2 py-1.5 rounded-lg text-xs text-sky-400 hover:text-sky-300 hover:bg-surface-2 border border-transparent hover:border-white/5 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"New branch — create a branch from where you are and switch to it, a safe place to try something",children:[e.jsx(Rs,{size:12})," Branch"]})]})]}),H.length>0&&e.jsxs("details",{className:"mt-3 border-t border-white/5 pt-3",children:[e.jsxs("summary",{className:"cursor-pointer text-sm text-gray-400 hover:text-gray-200 select-none flex items-center gap-1.5 font-medium",children:[e.jsx(Oe,{size:13})," ",H.length," stash",H.length===1?"":"es"," — click to expand"]}),e.jsx("div",{className:"mt-2 space-y-1",children:H.map(h=>e.jsxs("div",{className:"flex items-center gap-2 text-sm px-2 py-1.5 rounded hover:bg-surface-2/50",children:[e.jsxs("span",{className:"font-mono text-violet-300 shrink-0",children:["stash@",`{${h.index}}`]}),e.jsx("span",{className:"text-gray-300 truncate flex-1",children:h.message}),e.jsx("button",{onClick:()=>ee({index:h.index,sha:h.sha,message:h.message}),disabled:oe,className:"p-1.5 rounded hover:bg-red-500/15 text-gray-500 hover:text-red-500 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Drop — delete this stash for good","aria-label":`Drop stash ${h.message}`,children:e.jsx(De,{size:13})})]},h.index))})]}),e.jsx(de,{open:!!W,title:"Switch branches with uncommitted changes?",description:`You have uncommitted changes. Git carries them over to "${W||""}" when they don't clash with it — otherwise it refuses to switch and nothing changes. To leave them behind on this branch, stash them first.`,confirmLabel:"Switch anyway",icon:ce,onCancel:()=>Z(null),onConfirm:()=>{const h=W;Z(null),h&&ie(h)}}),e.jsx(de,{open:!!V,title:"Drop this stash?",description:`"${(V==null?void 0:V.message)||""}" will be permanently removed. You can't recover it from git.`,confirmLabel:"Drop",onCancel:()=>ee(null),onConfirm:Ue}),e.jsx(de,{open:J,title:"Clear saved credentials?",description:`Forget ${Y} remembered credential${Y===1?"":"s"} for this session. The next push, pull, or fetch that needs authentication will prompt you again. This cannot be undone.`,confirmLabel:"Clear",icon:Je,onCancel:()=>y(!1),onConfirm:async()=>{y(!1);try{const{count:h}=await lt();c(),n("success",`Cleared ${h} saved credential${h===1?"":"s"}`)}catch(h){n("error",`Clear failed: ${h.message}`)}}})]})}function na({stagedCount:t,mergeInProgress:s,suggestedMergeMessage:l,hasCommits:n=!0,clean:r=!1,onError:d}){const{toast:o}=Se(),[x,i]=g.useState(""),[m,p]=g.useState(!1),[w,j]=g.useState(!1),z=dt(),M=Ie(),{data:N}=ht(),{data:C}=mt(m),K=g.useRef(!1);g.useEffect(()=>{if(!s){K.current=!1;return}!K.current&&l&&(K.current=!0,i(B=>B||l))},[s,l]);const _=n&&!s;g.useEffect(()=>{!_&&m&&p(!1)},[_,m]),g.useEffect(()=>{m&&!x&&(C!=null&&C.message)&&i(C.message)},[m,C==null?void 0:C.message]);const Y=B=>{p(B),!B&&(C!=null&&C.message)&&x===C.message&&i("")},T=(t>0||m||s)&&x.trim().length>0&&!z.isPending&&!M,c=m&&!!(C!=null&&C.pushed),F=B=>{z.mutate({message:x.trim(),amend:m,confirmPushedAmend:B},{onSuccess:D=>{var W;if(o("success",`${m?"Amended":"Committed"} ${D.commit||""} on ${D.branch||"branch"}`),(W=D.testverLeftOut)!=null&&W.length){const Z=D.testverLeftOut.length;o("info",`${Z} file${Z===1?"":"s"} from Testver's own .testver folder ${Z===1?"was":"were"} left out of the commit and unstaged`)}i(""),p(!1)},onError:D=>{if(D.code==="amend_pushed"){j(!0);return}d?d(m?"Amend":"Commit",D.message):o("error",`Commit failed: ${D.message}`)}})},P=()=>{if(T){if(c){j(!0);return}F(!1)}};return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Me,{size:16,className:"text-gray-400"}),e.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Commit"}),t>0&&e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-emerald-500/20 text-emerald-400 font-medium",children:[t," staged"]}),s&&e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-orange-500/20 text-orange-600 dark:text-orange-300 inline-flex items-center gap-1 font-medium",children:[e.jsx(ke,{size:11})," Finishing merge"]}),t===0&&!m&&!s&&e.jsx("span",{className:"text-xs text-gray-500",children:r&&n?"Nothing to commit — tick Amend last commit to change its message":"No staged files"}),m&&e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-amber-500/20 text-amber-300 inline-flex items-center gap-1 font-medium",children:[e.jsx(ys,{size:11})," Amending last commit"]}),e.jsxs("label",{className:`ml-auto flex items-center gap-1.5 text-sm text-gray-300 select-none ${_?"cursor-pointer":"opacity-50 cursor-not-allowed"}`,title:n?s?"Finish the merge with a new commit":"Amend — replace the most recent commit instead of adding one, to fix its message or add a forgotten file. Avoid it once the commit is pushed":"There is no commit to amend yet",children:[e.jsx("input",{type:"checkbox",checked:m,disabled:!_,onChange:B=>Y(B.target.checked),className:"rounded border-white/20 bg-surface-2 text-amber-500 focus:ring-amber-500 focus:ring-offset-0"}),"Amend last commit"]})]}),c&&e.jsxs("div",{className:"mb-3 flex items-start gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-300",children:[e.jsx(ce,{size:13,className:"mt-0.5 shrink-0"}),e.jsx("span",{children:"The last commit is already pushed. Amending replaces it with a new commit, so your branch and the remote will disagree and Push will be refused (Testver never force-pushes). Prefer a new commit unless you know no one else has it."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("textarea",{value:x,onChange:B=>i(B.target.value),onKeyDown:B=>{B.key==="Enter"&&(B.ctrlKey||B.metaKey)&&(B.preventDefault(),P())},placeholder:m?"Edit commit message… (Ctrl+Enter to amend)":"Enter commit message... (Ctrl+Enter to commit)",rows:2,className:"flex-1 bg-surface-2 border border-white/10 rounded-lg px-3 py-2.5 text-sm text-gray-200 placeholder-gray-500 resize-none focus:outline-none focus:border-sky-500/50 font-mono"}),e.jsxs("button",{onClick:P,disabled:!T,className:`self-end px-5 py-2.5 rounded-lg text-sm font-medium text-white disabled:opacity-40 disabled:cursor-not-allowed flex items-center gap-1.5 transition-colors ${m?"bg-amber-600 hover:bg-amber-500":"bg-emerald-600 hover:bg-emerald-500"}`,children:[z.isPending?e.jsx(U,{size:14,className:"animate-spin"}):m?e.jsx(ys,{size:14}):e.jsx(Me,{size:14}),m?"Amend":"Commit"]})]}),(N==null?void 0:N.available)&&(N.as||N.warning)&&e.jsxs("p",{className:"mt-2 text-xs text-gray-500 flex items-center gap-1.5",children:[e.jsx(Fe,{size:11,className:"shrink-0"}),m?e.jsx("span",{children:"An amend keeps the original commit's author."}):N.as?e.jsxs("span",{children:["Committing as"," ",e.jsxs("span",{className:"text-gray-300",children:[N.as.name," <",N.as.email,">"]})," — ",N.source==="testver"?"from your Testver profile":"the repository's git identity"]}):e.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:N.warning})]}),e.jsx(de,{open:w,title:"Amend a commit that is already pushed?",description:"The remote already has this commit. Amending replaces it locally, so the next Push will be refused — Testver never force-pushes, so you would need to resolve that outside Testver. A new commit avoids all of this.",confirmLabel:"Amend anyway",icon:ce,onCancel:()=>j(!1),onConfirm:()=>{j(!1),F(!0)}})]})}const Le=t=>t.replace(/\r$/,""),ws=t=>/^<{7}(?: |$)/.test(Le(t)),ra=t=>/^\|{7}(?: |$)/.test(Le(t)),ia=t=>/^={7}$/.test(Le(t)),oa=t=>/^>{7}(?: |$)/.test(Le(t)),ks=t=>Le(t).slice(8).trim();function la(t){const s=t.split(`
3
+ `),l=[],n=[];let r=[];const d=()=>{r.length&&n.push({kind:"text",lines:r}),r=[]};let o=0;for(;o<s.length;){const x=s[o];if(!ws(x)){r.push(x),o++;continue}let i=-1,m=-1,p=-1;for(let j=o+1;j<s.length;j++){const z=s[j];if(ws(z))break;if(m<0&&i<0&&ra(z)){i=j;continue}if(m<0&&ia(z)){m=j;continue}if(m>=0&&oa(z)){p=j;break}}if(m<0||p<0){r.push(x),o++;continue}d();const w=i>=0?i:m;l.push({startLine:o,endLine:p,oursLines:s.slice(o+1,w),baseLines:i>=0?s.slice(i+1,m):[],theirsLines:s.slice(m+1,p),oursLabel:ks(x),theirsLabel:ks(s[p]),rawLines:s.slice(o,p+1),decision:null,manualText:s.slice(o+1,w).join(`
4
+ `)}),n.push({kind:"hunk",index:l.length-1}),o=p+1}return d(),{hunks:l,segments:n}}function ca(t){switch(t.decision){case"ours":return t.oursLines;case"theirs":return t.theirsLines;case"both":return[...t.oursLines,...t.theirsLines];case"manual":return t.manualText===""?[]:t.manualText.split(`
5
+ `);default:return t.rawLines}}function da(t,s){const l=[];for(const n of t)n.kind==="text"?l.push(...n.lines):l.push(...ca(s[n.index]));return l.join(`
6
+ `)}function ha(t){return t.every(s=>s.decision!==null)}function ma({path:t,onClose:s,onResolved:l}){const{toast:n}=Se(),r=xt(),d=zs(),[o,x]=g.useState(null),[i,m]=g.useState(!0),[p,w]=g.useState(null),[j,z]=g.useState(0),[M,N]=g.useState([]),[C,K]=g.useState([]),[_,Y]=g.useState(!1),[T,c]=g.useState(!1),F=g.useRef(null),P=r.isPending;g.useEffect(()=>{let b=!1;return m(!0),w(null),ut(t).then(L=>{if(b)return;x(L);const f=la(L.working||"");N(f.hunks),K(f.segments),m(!1)}).catch(L=>{b||(x(null),w(L.message),m(!1))}),()=>{b=!0}},[t,j]);const B=M.some(b=>b.decision!==null),D=g.useCallback(()=>{B&&!P?c(!0):s()},[B,P,s]);g.useEffect(()=>{var b;(b=F.current)==null||b.focus()},[]),g.useEffect(()=>{const b=L=>{L.key==="Escape"&&!T&&(L.preventDefault(),D())};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[D,T]);const W=(b,L)=>{N(f=>f.map((k,v)=>v===b?{...k,...L}:k))},Z=b=>{N(L=>L.map(f=>({...f,decision:b})))},V=g.useMemo(()=>da(C,M),[C,M]),ee=ha(M),J=M.filter(b=>b.decision!==null).length,y=!!o&&!o.resolved&&!o.notText&&!p,S=o==null?void 0:o.sides,q=(S==null?void 0:S.ours.title)??"Ours (current branch)",te=(S==null?void 0:S.theirs.title)??"Theirs (incoming)",I=b=>b==="ours"?q:te,X=S?S.kind==="rebase"?e.jsxs(e.Fragment,{children:["During a rebase git replays ",e.jsx("b",{children:"your commits"})," on top of the incoming code, so ",e.jsx("b",{children:"“ours” is the incoming code"})," and ",e.jsx("b",{children:"“theirs” is your own commit"}),"."]}):S.kind==="stash"?e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"“Ours”"})," is the code as last committed (including anything just pulled); ",e.jsx("b",{children:"“theirs”"})," is ",e.jsx("b",{children:"your stashed edits"}),"."]}):S.kind==="merge"?e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"“Ours”"})," is your branch; ",e.jsx("b",{children:"“theirs”"})," is the change coming in."]}):S.kind==="cherry-pick"?e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"“Ours”"})," is your branch; ",e.jsx("b",{children:"“theirs”"})," is the commit being picked."]}):S.kind==="revert"?e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"“Ours”"})," is your branch; ",e.jsx("b",{children:"“theirs”"})," is the undo of the commit being reverted."]}):null:null,O=o!=null&&o.stages?!o.stages.ours&&!o.stages.theirs?"both":o.stages.ours?o.stages.theirs?null:"theirs":"ours":null,se=()=>{P||!ee||!y||r.mutate({path:t,content:V},{onSuccess:b=>l(t,(b==null?void 0:b.remainingConflicts)??[]),onError:b=>n("error",`Resolve failed: ${b.message}`)})},re=()=>{P||!o||o.resolved||r.mutate({path:t,deleteFile:!0},{onSuccess:b=>l(t,(b==null?void 0:b.remainingConflicts)??[]),onError:b=>n("error",`Resolve failed: ${b.message}`)})},H=b=>{P||!o||o.resolved||r.mutate({path:t,side:b},{onSuccess:L=>l(t,(L==null?void 0:L.remainingConflicts)??[]),onError:L=>n("error",`Resolve failed: ${L.message}`)})};return e.jsxs("div",{className:"fixed inset-0 z-[1000] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",children:[e.jsxs("div",{ref:F,role:"dialog","aria-modal":"true","aria-labelledby":"conflict-dialog-title",tabIndex:-1,className:"bg-surface-1 rounded-xl border border-white/10 shadow-2xl w-full max-w-6xl max-h-[92vh] flex flex-col overflow-hidden focus:outline-none",children:[e.jsxs("div",{className:"flex items-center gap-2 px-5 py-3 border-b border-white/10 bg-surface-2/50 shrink-0",children:[e.jsx(ke,{size:16,className:"text-orange-500 dark:text-orange-400"}),e.jsxs("h3",{id:"conflict-dialog-title",className:"text-base font-semibold text-gray-800 dark:text-gray-100 flex-1 truncate",children:["Resolve conflict — ",e.jsx("span",{className:"font-mono text-sm",children:t})]}),e.jsx("button",{onClick:D,className:"p-1 rounded hover:bg-white/5 text-gray-500 hover:text-gray-300 transition-colors",title:"Close","aria-label":"Close",children:e.jsx(ue,{size:16})})]}),!i&&X&&!(o!=null&&o.resolved)&&e.jsx("div",{className:"px-5 py-2 border-b border-white/5 text-xs text-gray-700 dark:text-gray-300 bg-sky-500/5 shrink-0",children:X}),!i&&M.length>0&&e.jsxs("div",{className:"flex items-center gap-2 px-5 py-2 border-b border-white/5 bg-surface-2/30 shrink-0",children:[e.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:[M.length," conflict ",M.length===1?"hunk":"hunks"," — apply to all:"]}),e.jsx("button",{onClick:()=>Z("ours"),title:`Keep ${q} in every conflict`,className:"px-2.5 py-1 rounded text-xs font-medium bg-sky-500/10 text-sky-700 dark:text-sky-300 border border-sky-500/30 hover:bg-sky-500/20 transition-colors",children:"Use ours"}),e.jsx("button",{onClick:()=>Z("theirs"),title:`Keep ${te} in every conflict`,className:"px-2.5 py-1 rounded text-xs font-medium bg-emerald-500/10 text-emerald-700 dark:text-emerald-300 border border-emerald-500/30 hover:bg-emerald-500/20 transition-colors",children:"Use theirs"}),e.jsx("button",{onClick:()=>Z("both"),className:"px-2.5 py-1 rounded text-xs font-medium bg-amber-500/10 text-amber-700 dark:text-amber-300 border border-amber-500/30 hover:bg-amber-500/20 transition-colors",children:"Keep both"}),e.jsx("div",{className:"ml-auto",children:e.jsxs("button",{onClick:()=>Y(b=>!b),className:"flex items-center gap-1 px-2.5 py-1 rounded text-xs font-medium text-gray-700 dark:text-gray-300 hover:bg-white/5 transition-colors",children:[_?e.jsx(Dt,{size:12}):e.jsx(Te,{size:12}),_?"Hide":"Show"," full preview"]})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-3",children:[i&&e.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500 dark:text-gray-400 text-sm gap-2",children:[e.jsx(U,{size:14,className:"animate-spin"})," Loading conflict…"]}),!i&&p&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-700 dark:text-gray-300 gap-2",children:[e.jsx(ce,{size:28,className:"text-red-500"}),e.jsx("p",{className:"text-sm font-medium",children:"The conflict could not be loaded"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 max-w-md text-center break-words",children:p}),e.jsxs("button",{onClick:()=>z(b=>b+1),className:"mt-2 px-4 py-2 rounded-lg text-sm font-medium bg-surface-2 hover:bg-surface-3 text-gray-200 border border-white/10 transition-colors flex items-center gap-1.5",children:[e.jsx(U,{size:14})," Try again"]})]}),!i&&(o==null?void 0:o.resolved)&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-700 dark:text-gray-300 gap-2",children:[e.jsx(xe,{size:28,className:"text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium",children:"This file is no longer in conflict"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 max-w-md text-center",children:"It was resolved since the list was shown (here, in a terminal or by the AI). Nothing to do."}),e.jsx("button",{onClick:()=>{d(),s()},className:"mt-2 px-4 py-2 rounded-lg text-sm font-medium bg-surface-2 hover:bg-surface-3 text-gray-200 border border-white/10 transition-colors",children:"Close"})]}),!i&&(o==null?void 0:o.notText)&&!o.resolved&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-700 dark:text-gray-300 gap-2",children:[e.jsx(_e,{size:28,className:"text-amber-500"}),e.jsxs("p",{className:"text-sm font-medium",children:[o.notText==="binary"?"This file isn't text":"This file isn't UTF-8 text",", so it can't be merged line by line here"]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 max-w-md text-center",children:O==="both"?"Both branches deleted it — delete it to finish resolving.":O?`${I(O)} deleted it and ${I(O==="ours"?"theirs":"ours")} changed it — keep the changed version or delete the file.`:`Keep one version whole: ours — ${q} — or theirs — ${te}.`}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap justify-center",children:[O!=="ours"&&O!=="both"&&e.jsxs("button",{onClick:()=>H("ours"),disabled:P,className:"px-4 py-2 rounded-lg text-sm font-medium bg-sky-600 hover:bg-sky-500 text-white disabled:opacity-50 transition-colors",children:["Keep ours — ",q,(S==null?void 0:S.mine)==="ours"?" (your work)":""]}),O!=="theirs"&&O!=="both"&&e.jsxs("button",{onClick:()=>H("theirs"),disabled:P,className:"px-4 py-2 rounded-lg text-sm font-medium bg-emerald-600 hover:bg-emerald-500 text-white disabled:opacity-50 transition-colors",children:["Keep theirs — ",te,(S==null?void 0:S.mine)==="theirs"?" (your work)":""]}),O&&e.jsxs("button",{onClick:re,disabled:P,className:"px-4 py-2 rounded-lg text-sm font-medium bg-red-600 hover:bg-red-500 text-white disabled:opacity-50 transition-colors flex items-center gap-1.5",children:[e.jsx(De,{size:14})," Delete the file"]})]})]}),!i&&y&&M.length===0&&O&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-700 dark:text-gray-300 gap-2",children:[e.jsx(_e,{size:28,className:"text-amber-500"}),e.jsx("p",{className:"text-sm font-medium",children:O==="both"?"Both branches deleted this file":`${I(O)} deleted this file; ${I(O==="ours"?"theirs":"ours")} changed it`}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 max-w-md text-center",children:O==="both"?"Delete it to finish resolving.":"Keep the changed version, or delete the file. The file on disk is the changed version."}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[O!=="both"&&e.jsxs("button",{onClick:se,disabled:P,className:"px-4 py-2 rounded-lg text-sm font-medium bg-emerald-600 hover:bg-emerald-500 text-white disabled:opacity-50 transition-colors flex items-center gap-1.5",children:[e.jsx(xe,{size:14})," Keep the file"]}),e.jsxs("button",{onClick:re,disabled:P,className:"px-4 py-2 rounded-lg text-sm font-medium bg-red-600 hover:bg-red-500 text-white disabled:opacity-50 transition-colors flex items-center gap-1.5",children:[e.jsx(De,{size:14})," Delete the file"]})]})]}),!i&&y&&M.length===0&&!O&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-700 dark:text-gray-300 gap-2",children:[e.jsx(xe,{size:28,className:"text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium",children:"No conflict markers found"}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 max-w-md text-center",children:["The file is in the unmerged state but its working-tree contents have no"," ",e.jsx("code",{children:"<<<<<<<"})," markers. Mark resolved to stage the file as-is."]}),e.jsxs("button",{onClick:se,disabled:P,className:"mt-2 px-4 py-2 rounded-lg text-sm font-medium bg-emerald-600 hover:bg-emerald-500 text-white disabled:opacity-50 transition-colors flex items-center gap-1.5",children:[e.jsx(xe,{size:14})," Mark resolved"]})]}),!i&&y&&M.map((b,L)=>e.jsx(xa,{index:L,hunk:b,onChange:f=>W(L,f),sides:S},L)),_&&!i&&y&&e.jsxs("div",{className:"rounded-lg border border-white/10 overflow-hidden",children:[e.jsx("div",{className:"px-3 py-2 text-xs font-semibold text-gray-700 dark:text-gray-300 bg-surface-2/50 border-b border-white/5",children:"Resolved file preview"}),e.jsx("pre",{className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap text-gray-800 dark:text-gray-200 max-h-96 overflow-y-auto bg-black/20",children:V})]})]}),e.jsxs("div",{className:"flex items-center gap-2 px-5 py-3 border-t border-white/10 bg-surface-2/30 shrink-0",children:[y&&M.length>0&&e.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-400 flex items-center gap-1.5",children:[e.jsx(_e,{size:12,className:"text-amber-500"}),ee?e.jsxs(e.Fragment,{children:["Saving will write the resolved file and ",e.jsx("code",{className:"font-mono",children:"git add"})," it."]}):e.jsxs(e.Fragment,{children:["Choose a side for every conflict — ",J," of ",M.length," decided."]})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsx("button",{onClick:D,className:"px-3 py-1.5 rounded-lg text-sm text-gray-700 dark:text-gray-300 hover:bg-white/5 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:se,disabled:P||i||!y||!ee||M.length===0&&!!O,title:ee?void 0:"Choose a side for every conflict first",className:"px-4 py-1.5 rounded-lg text-sm font-medium bg-emerald-600 hover:bg-emerald-500 text-white disabled:opacity-40 disabled:cursor-not-allowed flex items-center gap-1.5 transition-colors",children:[P?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(xe,{size:14}),"Mark resolved & stage"]})]})]})]}),e.jsx(de,{open:T,title:"Close without resolving?",description:"The choices and edits you made in this dialog are thrown away. The file stays in conflict.",confirmLabel:"Close",onCancel:()=>c(!1),onConfirm:()=>{c(!1),s()}})]})}function xa({index:t,hunk:s,onChange:l,sides:n}){const r=(n==null?void 0:n.ours.title)??"Ours (current branch)",d=(n==null?void 0:n.theirs.title)??"Theirs (incoming)",o=e.jsx("span",{className:"ml-1 px-1.5 py-px rounded-full text-[10px] font-semibold bg-violet-500/15 text-violet-700 dark:text-violet-300 border border-violet-500/30",children:"your work"}),x={ours:`Keep ${r}`,theirs:`Keep ${d}`,both:"Keep both sides — ours first, then theirs",manual:"Type the result yourself"},i=(m,p,w)=>e.jsx("button",{onClick:()=>l({decision:p}),title:p?x[p]:void 0,className:`px-2.5 py-1 rounded text-xs font-medium border transition-colors ${s.decision===p?`${w} ring-1 ring-current`:"text-gray-600 dark:text-gray-400 border-white/10 hover:bg-white/5"}`,children:m});return e.jsxs("div",{className:"rounded-lg border border-white/10 bg-surface-2/30 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-white/5 bg-surface-2/50",children:[e.jsxs("span",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300",children:["Conflict #",t+1]}),e.jsxs("span",{className:"text-[11px] text-gray-500",children:["(lines ",s.startLine+1,"–",s.endLine+1,")"]}),s.decision===null&&e.jsx("span",{className:"text-[11px] font-medium text-amber-600 dark:text-amber-400",children:"Not decided"}),e.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[i("Use ours","ours","bg-sky-500/15 text-sky-700 dark:text-sky-300 border-sky-500/40"),i("Use theirs","theirs","bg-emerald-500/15 text-emerald-700 dark:text-emerald-300 border-emerald-500/40"),i("Both","both","bg-amber-500/15 text-amber-700 dark:text-amber-300 border-amber-500/40"),i("Edit","manual","bg-purple-500/15 text-purple-700 dark:text-purple-300 border-purple-500/40")]})]}),s.decision==="manual"?e.jsx("div",{className:"p-3",children:e.jsx("textarea",{value:s.manualText,onChange:m=>l({manualText:m.target.value}),rows:Math.min(20,Math.max(4,s.manualText.split(`
7
+ `).length)),className:"w-full bg-black/20 border border-white/10 rounded px-3 py-2 text-xs font-mono text-gray-800 dark:text-gray-100 focus:outline-none focus:border-sky-500/50 resize-y",spellCheck:!1})}):e.jsxs(e.Fragment,{children:[s.baseLines.length>0&&e.jsxs("details",{className:"px-3 py-2 border-b border-white/5",children:[e.jsx("summary",{className:"text-[11px] font-semibold text-gray-600 dark:text-gray-400 cursor-pointer select-none",children:"Common ancestor (before either change)"}),e.jsx("pre",{className:"mt-1.5 px-2 py-1.5 text-xs font-mono whitespace-pre-wrap text-gray-700 dark:text-gray-300 bg-black/10 rounded border border-white/5 max-h-40 overflow-y-auto",children:s.baseLines.join(`
8
+ `)})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 divide-y md:divide-y-0 md:divide-x divide-white/5",children:[e.jsxs("div",{className:`p-2 ${s.decision==="ours"||s.decision==="both"?"bg-sky-500/5":""}`,children:[e.jsxs("div",{className:"text-[11px] font-semibold text-sky-700 dark:text-sky-300 mb-1.5 px-1 flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-sky-500"}),"Ours — ",r,(n==null?void 0:n.mine)==="ours"&&o]}),e.jsx("div",{className:"text-[10px] text-gray-500 mb-1 px-1 truncate",title:(n==null?void 0:n.ours.detail)??s.oursLabel,children:(n==null?void 0:n.ours.detail)??s.oursLabel}),e.jsx("pre",{className:"px-2 py-1.5 text-xs font-mono whitespace-pre-wrap text-gray-800 dark:text-gray-200 bg-black/10 rounded border border-white/5 max-h-60 overflow-y-auto",children:s.oursLines.join(`
9
+ `)||e.jsx("span",{className:"text-gray-500 italic",children:"(empty)"})})]}),e.jsxs("div",{className:`p-2 ${s.decision==="theirs"||s.decision==="both"?"bg-emerald-500/5":""}`,children:[e.jsxs("div",{className:"text-[11px] font-semibold text-emerald-700 dark:text-emerald-300 mb-1.5 px-1 flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500"}),"Theirs — ",d,(n==null?void 0:n.mine)==="theirs"&&o]}),e.jsx("div",{className:"text-[10px] text-gray-500 mb-1 px-1 truncate",title:(n==null?void 0:n.theirs.detail)??s.theirsLabel,children:(n==null?void 0:n.theirs.detail)??s.theirsLabel}),e.jsx("pre",{className:"px-2 py-1.5 text-xs font-mono whitespace-pre-wrap text-gray-800 dark:text-gray-200 bg-black/10 rounded border border-white/5 max-h-60 overflow-y-auto",children:s.theirsLines.join(`
10
+ `)||e.jsx("span",{className:"text-gray-500 italic",children:"(empty)"})})]})]})]})]})}const Xe=30,ua=50,Q={merge:"Merge",rebase:"Rebase","cherry-pick":"Cherry-pick",revert:"Revert"};function Na(){var cs,ds,hs,ms,xs,us,gs;const{toast:t}=Se(),{data:s,isLoading:l,refetch:n}=Ps(),r=gt(),[d,o]=g.useState(Xe),{data:x,isLoading:i,isFetching:m}=pt(d),{data:p}=Kt(ua),w=(x==null?void 0:x.commits)||[],j=(p==null?void 0:p.runs)||[],[z,M]=g.useState(null),[N,C]=g.useState(!1),{data:K,isLoading:_}=ft(void 0,N),Y=s==null?void 0:s.testverPrefix,T=g.useMemo(()=>{if(!K||r||!Y)return K;const a=K.files.filter(u=>!bt(u.path,Y));return{...K,files:a,stagedCount:a.filter(u=>u.staged).length,unstagedCount:a.filter(u=>!u.staged).length}},[K,r,Y]),c=yt(),F=jt(),P=wt(),B=kt(),D=vt(),W=Ie(),Z=zs(),[V,ee]=g.useState(!1),{data:J}=Nt(),y=(J==null?void 0:J.check)??null,[S,q]=Vs(),[te,I]=g.useState(!1);g.useEffect(()=>{if(S.get("incoming")){I(!0);const a=new URLSearchParams(S);a.delete("incoming"),q(a,{replace:!0})}},[S,q]),g.useEffect(()=>{const a=()=>I(!0);return window.addEventListener(fs,a),()=>window.removeEventListener(fs,a)},[]);const X=Ct(),O=ss(),se=ts(),re=Ss(),H=$t(),b=Pt(),[L,f]=g.useState(!1),[k,v]=g.useState(!1),[ie,ve]=g.useState(!1),[Ae,Ne]=g.useState(!1),[Ue,oe]=g.useState(null),[Ce,fe]=g.useState(null),[be,h]=g.useState({upstream:"",dirty:0,behind:0}),$=()=>{h({upstream:(y==null?void 0:y.upstream)??"the remote",dirty:(y==null?void 0:y.dirtyFiles.length)??0,behind:(y==null?void 0:y.behind)??0}),oe(null),fe(null),Ne(!0),X.mutate(void 0,{onSuccess:a=>{oe(a),(a.conflictedPaths.length||a.pullConflicts.length)&&pe(null)},onError:a=>fe(a.message)})},he=()=>O.mutate(void 0,{onSuccess:a=>{var u;if(a.conflicts&&((u=a.conflictedPaths)!=null&&u.length)){pe(null),t("error",`Pull stopped on ${R(a.conflictedPaths.length,"conflict")} — resolve them below`);return}I(!1),t("success","Pulled")},onError:a=>E({op:"Pull",message:a.message})}),me=(s==null?void 0:s.conflictedPaths)??[],ns=me.join(`
11
+ `),[Bs,pe]=g.useState(null),Gs=me.length>0&&Bs!==ns,[Re,E]=g.useState(null),[rs,Be]=g.useState(null),[Ds,is]=g.useState(null),[le,Ee]=g.useState(null),Os=a=>{c.mutate([a],{onSuccess:u=>u.note?t("info",u.note):t("success",`Staged ${a}`),onError:u=>E({op:"Stage",message:u.message})})},Ms=a=>{F.mutate([a],{onSuccess:()=>t("success",`Unstaged ${a}`),onError:u=>E({op:"Unstage",message:u.message})})},Is=()=>{var u;const a=((u=T==null?void 0:T.files)==null?void 0:u.filter(G=>!G.staged).map(G=>G.path))||[];a.length!==0&&c.mutate(a,{onSuccess:G=>{var Pe;const $e=((Pe=G.staged)==null?void 0:Pe.length)??a.length;t("success",`Staged ${$e} file${$e!==1?"s":""}`),G.note&&t("info",G.note)},onError:G=>E({op:"Stage all",message:G.message})})},Us=()=>{var u;const a=((u=T==null?void 0:T.files)==null?void 0:u.filter(G=>G.staged).map(G=>G.path))||[];a.length!==0&&F.mutate(a,{onSuccess:()=>t("success",`Unstaged ${a.length} file${a.length!==1?"s":""}`),onError:G=>E({op:"Unstage all",message:G.message})})},Es=()=>{if(!le)return;const a=le;Ee(null),P.mutate({files:[a.path],scope:"unstaged"},{onSuccess:()=>{t("success",`Discarded changes to ${a.path}`),n()},onError:u=>E({op:"Discard",message:u.message})})},Ks=()=>{ee(!1),B.mutate(void 0,{onSuccess:a=>{E(null),t("success",`${Q[a.aborted]} aborted — back to where you were before it`)},onError:a=>E({op:"Abort",message:a.message})})},os=()=>{D.mutate(void 0,{onSuccess:a=>{E(null),a.conflictedPaths.length>0?(pe(null),t("info",`${Q[a.continued]} stopped again on ${a.conflictedPaths.length} conflict${a.conflictedPaths.length===1?"":"s"} — resolve them, then Continue`)):a.operation?t("success",`${Q[a.continued]} continued`):t("success",`${Q[a.continued]} finished`)},onError:a=>E({op:"Continue",message:a.message})})},Ys=()=>{b.mutate(void 0,{onSuccess:a=>{E(null),a.conflictedPaths.length>0?(pe(null),t("info",`Skipped — the ${Q[a.skipped].toLowerCase()} stopped again on ${a.conflictedPaths.length} conflict${a.conflictedPaths.length===1?"":"s"}`)):t("success",a.operation?"Skipped that commit — carrying on":`Skipped that commit — ${Q[a.skipped].toLowerCase()} finished`)},onError:a=>E({op:"Skip",message:a.message})})},Ws=(s==null?void 0:s.stagedCount)??(T==null?void 0:T.stagedCount)??0,Ke=[];for(const a of j){const u=typeof a.gitCommitSha=="string"?a.gitCommitSha:"";!u||Ke.some(G=>G.sha===u)||Ke.push({sha:u,badge:{passed:((cs=a.summary)==null?void 0:cs.passed)||0,failed:((ds=a.summary)==null?void 0:ds.failed)||0,total:((hs=a.summary)==null?void 0:hs.total)||0,when:a.timestamp??a.startTime}})}const _s=a=>{var u;return(u=Ke.find(G=>a.sha.startsWith(G.sha)||G.sha.startsWith(a.sha)))==null?void 0:u.badge};if(!(s!=null&&s.available)&&!l){const a=s==null?void 0:s.reason;return e.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:e.jsxs("div",{className:"text-center max-w-lg",children:[e.jsx(we,{size:48,className:"text-gray-700 mx-auto mb-4"}),e.jsx("h2",{className:"text-lg font-semibold text-gray-300 mb-2",children:"Git Not Available"}),a==="git_missing"?e.jsx("p",{className:"text-sm text-gray-500",children:"Git isn't installed on the machine running Testver (or isn't on its PATH). Install git, then restart Testver."}):a==="unsafe_directory"?e.jsxs("p",{className:"text-sm text-gray-500",children:[`Git refuses this repository because it belongs to another user account (git's "safe.directory" check) — common when Testver runs as a different user or the project is on a network or external drive. Mark it as safe on the server with`," ",e.jsx("code",{className:"text-gray-400 bg-surface-2 px-1.5 py-0.5 rounded break-all",children:"git config --global --add safe.directory <project folder>"}),"."]}):a==="error"?e.jsx("p",{className:"text-sm text-gray-500",children:"Git could not read this repository."}):e.jsxs("p",{className:"text-sm text-gray-500",children:["This project is not inside a git repository. Initialize a repository with"," ",e.jsx("code",{className:"text-gray-400 bg-surface-2 px-1.5 py-0.5 rounded",children:"git init"})," ","to enable git integration features."]}),(s==null?void 0:s.detail)&&a!=="not_repo"&&e.jsx("pre",{className:"mt-3 text-left text-xs text-gray-500 bg-surface-2 rounded-lg px-3 py-2 whitespace-pre-wrap break-words max-h-40 overflow-y-auto",children:s.detail}),e.jsxs("button",{onClick:()=>n(),className:"mt-4 inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/10 transition-colors",children:[e.jsx(U,{size:13})," Check again"]})]})})}const A=s==null?void 0:s.operation,Ye=!!A&&A.kind!=="merge"&&me.length===0&&((s==null?void 0:s.stagedCount)??0)===0&&((s==null?void 0:s.unstagedCount)??0)===0,ls=!!(s!=null&&s.lastCommit);return e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200",children:[e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3 flex-1",children:[e.jsx(we,{size:26,className:"text-brand-300"}),"Git Integration"]}),e.jsxs("button",{onClick:()=>ve(a=>!a),"aria-expanded":ie,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/5 transition-colors",title:"What every action on this page does, in plain words",children:[e.jsx(Ts,{size:13})," Guide"]}),e.jsxs("button",{onClick:()=>Z(),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/5 transition-colors",title:"Read the repository again — picks up commits, branches and stashes made in a terminal or by the AI",children:[e.jsx(U,{size:13,className:l||m?"animate-spin":""})," Refresh"]})]}),e.jsx("p",{className:"text-base text-gray-400 mt-1",children:"Branch info, commit history, and repository management"})]})}),e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-8 space-y-4",children:[(s==null?void 0:s.available)&&e.jsx(Jt,{state:J,onViewIncoming:()=>I(!0),onStashPull:$,onError:(a,u)=>E({op:a,message:u}),onConflicts:()=>{pe(null),n()}}),te&&y&&(Qe(y)||y.verdict==="rewritten")&&e.jsx(sa,{check:y,onClose:()=>I(!1),onPull:y.verdict==="uncommitted_overlap"?$:he,pullDisabled:W}),ie&&e.jsx(Vt,{onClose:()=>ve(!1)}),(s==null?void 0:s.available)&&(()=>{const a=Wt({status:s,remote:y,opError:!!Re,busy:W,hiddenTestver:s.hiddenTestver,act:{showChanges:()=>{C(!0),setTimeout(()=>{var u;return(u=document.getElementById("git-changes"))==null?void 0:u.scrollIntoView({behavior:"smooth",block:"start"})},50)},goToCommit:()=>{var u;return(u=document.getElementById("git-commit-panel"))==null?void 0:u.scrollIntoView({behavior:"smooth",block:"center"})},push:()=>se.mutate(void 0,{onSuccess:u=>{E(null),t("success",u.published?`Published to ${u.published}`:"Push complete")},onError:u=>E({op:"Push",message:u.message})}),pull:he,continueOp:os,skipStep:()=>f(!0),dropStash:()=>{const u=s.pendingStash;u&&re.mutate({ref:u.ref,sha:u.sha},{onSuccess:()=>t("success","Stash dropped — your changes are in the files"),onError:G=>E({op:"Drop stash",message:G.message})})},backOutStash:()=>v(!0)}});return!a||Ds===a.key?null:e.jsx(_t,{step:a,onDismiss:()=>is(a.key)})})(),Re&&e.jsx("div",{className:"bg-red-500/10 dark:bg-red-500/10 border border-red-500/40 rounded-xl p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ce,{size:18,className:"text-red-600 dark:text-red-400 mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"text-sm font-semibold text-red-700 dark:text-red-300",children:[Re.op," failed"]}),e.jsx("pre",{className:"mt-1 text-xs text-red-800 dark:text-red-200/90 font-mono whitespace-pre-wrap break-words leading-relaxed max-h-60 overflow-y-auto",children:Re.message})]}),e.jsx("button",{onClick:()=>E(null),className:"p-1 rounded hover:bg-red-500/20 text-red-700 dark:text-red-300 shrink-0",title:"Dismiss","aria-label":"Dismiss",children:e.jsx(ue,{size:14})})]})}),(s==null?void 0:s.available)&&e.jsx(aa,{onConflicts:()=>{pe(null),n()},onError:(a,u)=>E({op:a,message:u}),onSuccessClearError:()=>E(null)}),A&&e.jsx("div",{className:"bg-orange-500/10 dark:bg-orange-500/10 border border-orange-500/40 rounded-xl p-4",children:e.jsxs("div",{className:"flex items-start gap-3 flex-wrap",children:[e.jsx(ke,{size:18,className:"text-orange-600 dark:text-orange-400 mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-[16rem]",children:[e.jsxs("h3",{className:"text-sm font-semibold text-orange-700 dark:text-orange-300",children:[Q[A.kind]," in progress",A.branch?` — ${A.branch}`:""]}),e.jsx("p",{className:"text-xs text-gray-700 dark:text-gray-300 mt-1 leading-relaxed",children:A.kind==="merge"?"Finish it as the next step says — or abort it to go back to before the pull or merge.":me.length>0?`Resolve the conflicted files below, then press Continue. Abort goes back to before the ${Q[A.kind].toLowerCase()} started.`:Ye?`Your resolution keeps the code exactly as it already is, so this step has nothing to commit. Skip this commit to carry on (your files stay exactly as they are), or Abort to go back to before the ${Q[A.kind].toLowerCase()} started.`:`The conflicts are resolved — press Continue to carry on. Abort goes back to before the ${Q[A.kind].toLowerCase()} started.`})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[A.kind!=="merge"&&Ye&&e.jsxs("button",{onClick:()=>f(!0),disabled:W,title:"Leave out the commit this step stopped on — its changes are already in the code",className:"px-3 py-1.5 rounded-lg text-sm font-medium bg-emerald-600 hover:bg-emerald-500 text-white disabled:opacity-40 disabled:cursor-not-allowed transition-colors flex items-center gap-1.5",children:[b.isPending&&e.jsx(U,{size:13,className:"animate-spin"}),"Skip this commit"]}),A.kind!=="merge"&&!Ye&&e.jsxs("button",{onClick:os,disabled:W||me.length>0,title:me.length>0?"Resolve every conflicted file first":`Continue the ${Q[A.kind].toLowerCase()}`,className:"px-3 py-1.5 rounded-lg text-sm font-medium bg-emerald-600 hover:bg-emerald-500 text-white disabled:opacity-40 disabled:cursor-not-allowed transition-colors flex items-center gap-1.5",children:[D.isPending&&e.jsx(U,{size:13,className:"animate-spin"}),"Continue"]}),e.jsxs("button",{onClick:()=>ee(!0),disabled:W,className:"px-3 py-1.5 rounded-lg text-sm font-medium bg-surface-2 hover:bg-surface-3 text-red-600 dark:text-red-400 border border-red-500/30 disabled:opacity-40 disabled:cursor-not-allowed transition-colors flex items-center gap-1.5",children:[B.isPending&&e.jsx(U,{size:13,className:"animate-spin"}),"Abort ",Q[A.kind].toLowerCase()]})]})]})}),Gs&&e.jsx("div",{className:"bg-red-500/10 dark:bg-red-500/10 border border-red-500/40 rounded-xl p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ce,{size:18,className:"text-red-600 dark:text-red-400 mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"text-sm font-semibold text-red-700 dark:text-red-300",children:[s!=null&&s.pendingStash&&!A?"Stash conflict":A&&A.kind!=="merge"?`${Q[A.kind]} conflict`:"Merge conflict"," — ",me.length," file",me.length===1?" needs":"s need"," resolving"]}),e.jsx("p",{className:"text-xs text-gray-700 dark:text-gray-400 mt-1 leading-relaxed",children:s!=null&&s.pendingStash&&!A?e.jsxs(e.Fragment,{children:["Your stashed changes came back, but these files were also changed by newer commits. Click a file name below to resolve it — the stash is kept until you finish, or ",e.jsx("b",{children:"Back out"})," to return these files to the last commit and keep the stash."]}):e.jsx(e.Fragment,{children:'These files were changed on both sides, so git could not combine them. Click a file name below to resolve it in a side-by-side editor — choose "ours", "theirs", both, or hand-edit each conflict, then mark resolved.'})}),(s==null?void 0:s.pendingStash)&&!A&&e.jsx("button",{onClick:()=>v(!0),disabled:W,className:"mt-2 px-3 py-1.5 rounded-lg text-xs font-medium bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/10 disabled:opacity-50",children:"Back out"}),e.jsx("ul",{className:"mt-2 space-y-0.5 max-h-40 overflow-y-auto",children:me.map(a=>e.jsxs("li",{className:"text-xs font-mono flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-600 dark:bg-red-400 shrink-0"}),e.jsx("button",{onClick:()=>Be(a),className:"text-red-700 dark:text-red-200 hover:text-red-900 dark:hover:text-red-100 hover:underline truncate text-left",title:"Click to resolve in editor",children:a})]},a))})]}),e.jsx("button",{onClick:()=>pe(ns),className:"p-1 rounded hover:bg-red-500/20 text-red-700 dark:text-red-300 shrink-0",title:"Dismiss","aria-label":"Dismiss",children:e.jsx(ue,{size:14})})]})}),s&&s.available&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-200 mb-4 flex items-center gap-2",children:[e.jsx(we,{size:18,className:"text-brand-400"}),"Repository Status"]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-gray-500 uppercase font-semibold tracking-wide",children:"Branch"}),s.detached?e.jsxs("p",{className:"text-base text-amber-500 font-mono",title:"HEAD is on a commit, not a branch — commits made here belong to no branch. Switch to a branch (or create one) to keep working.",children:["Detached at ",((ms=s.lastCommit)==null?void 0:ms.shortSha)??"HEAD"]}):e.jsx("p",{className:"text-base text-brand-400 font-mono",children:s.branch||"—"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-gray-500 uppercase font-semibold tracking-wide",children:"Status"}),e.jsx("p",{className:`text-base ${s.isClean?"text-emerald-500":"text-amber-500"}`,children:s.isClean?"Clean":`${((xs=s.uncommittedChanges)==null?void 0:xs.length)||0} change${(((us=s.uncommittedChanges)==null?void 0:us.length)||0)===1?"":"s"}`})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-gray-500 uppercase font-semibold tracking-wide",children:"Sync"}),e.jsxs("div",{className:"flex items-center gap-2 text-base",children:[(s.ahead||0)>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-emerald-500",children:[e.jsx(Ot,{size:14})," ",s.ahead]}),(s.behind||0)>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-red-500",children:[e.jsx(Mt,{size:14})," ",s.behind]}),s.detached?e.jsx("span",{className:"text-gray-500",title:"Not on a branch, so there is nothing to sync",children:"—"}):s.lastCommit?s.remotes&&s.remotes.length===0?e.jsx("span",{className:"text-gray-500",children:"No remote"}):s.remotes&&!s.upstream&&s.branch&&!s.detached?e.jsx("span",{className:"text-amber-500 text-sm",title:"This branch has never been pushed",children:"Not published"}):!s.ahead&&!s.behind&&e.jsx("span",{className:"text-gray-500",children:"Up to date"}):e.jsx("span",{className:"text-gray-500",children:"No commits yet"})]}),y&&y.ok&&!y.skipped&&e.jsxs("div",{className:"text-xs text-gray-500 leading-relaxed",children:[Qe(y)&&y.verdict!=="rewritten"&&e.jsxs("div",{children:["Incoming: ",e.jsx("b",{className:"text-gray-300",children:R(y.behind,"commit")})," · ",R(y.stats.files,"file")," · ",e.jsxs("span",{className:"text-emerald-500",children:["+",y.stats.additions]})," ",e.jsxs("span",{className:"text-red-500",children:["−",y.stats.deletions]})]}),e.jsxs("div",{title:J!=null&&J.nextCheckAt?`Next check ${St(J.nextCheckAt)}`:"Background checks are off (Settings → Remote updates)",children:["Checked ",ze(y.checkedAt)]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-gray-500 uppercase font-semibold tracking-wide",children:"Last Commit"}),s.lastCommit?e.jsxs("div",{className:"text-base",children:[e.jsx("span",{className:"font-mono text-brand-400",children:s.lastCommit.shortSha}),e.jsx("span",{className:"text-gray-400 ml-1.5",children:s.lastCommit.author}),e.jsx("span",{className:"text-gray-500 ml-1.5 text-sm",title:Ge(s.lastCommit.timestamp),children:es(s.lastCommit.timestamp)})]}):e.jsx("p",{className:"text-base text-gray-500",children:"—"})]})]}),s.testverPrefix&&(r||(s.hiddenTestver??0)>0)&&e.jsx(qt,{include:r,hidden:s.hiddenTestver??0,folder:s.testverPrefix}),s.uncommittedChanges&&s.uncommittedChanges.length>0&&e.jsxs("div",{id:"git-changes",className:"mt-4 pt-3 border-t border-white/5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("p",{className:"text-xs text-gray-500 uppercase font-semibold tracking-wide",children:["Uncommitted Changes (",s.uncommittedChanges.length,")"]}),e.jsxs("button",{onClick:()=>C(!N),className:"flex items-center gap-1 text-xs text-brand-400 hover:text-brand-300 transition-colors",children:[e.jsx(It,{size:11}),N?"Hide Diffs":"Show Diffs"]})]}),!N&&e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1 max-h-32 overflow-y-auto",children:[s.uncommittedChanges.slice(0,20).map(a=>e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",title:`${a.path} — ${a.status}`,children:[e.jsx("span",{"aria-label":a.status,className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${a.status==="modified"?"bg-amber-400":a.status==="added"||a.status==="untracked"?"bg-emerald-400":a.status==="deleted"?"bg-red-400":"bg-gray-400"}`}),e.jsx("span",{className:"text-gray-400 truncate font-mono",children:a.path})]},`${a.status}:${a.path}`)),s.uncommittedChanges.length>20&&e.jsxs("button",{onClick:()=>C(!0),className:"sm:col-span-2 text-left text-xs text-brand-400 hover:text-brand-300",children:["+",s.uncommittedChanges.length-20," more — Show Diffs to see them all"]})]}),N&&(_?e.jsxs("div",{className:"py-3 text-xs text-gray-500 flex items-center gap-1.5 justify-center",children:[e.jsx(U,{size:10,className:"animate-spin"})," Loading diffs..."]}):T!=null&&T.files&&T.files.length>0?e.jsxs(e.Fragment,{children:[T.truncated&&e.jsx("p",{className:"mb-2 text-xs text-amber-600 dark:text-amber-400",children:"The changes are too large to show in full — some files' diffs are cut off."}),e.jsx(Yt,{files:T.files,showGroups:!0,busy:W,onStageFile:Os,onUnstageFile:Ms,onStageAll:Is,onUnstageAll:Us,onDiscardFile:a=>Ee(a)})]}):e.jsx("p",{className:"text-xs text-gray-500 py-2",children:"No diff data available."}))]})]}),(s==null?void 0:s.available)&&(!A||A.kind==="merge")&&(!(s!=null&&s.isClean)||(s==null?void 0:s.mergeInProgress)||ls)&&e.jsx("div",{id:"git-commit-panel",children:e.jsx(na,{stagedCount:Ws,mergeInProgress:s==null?void 0:s.mergeInProgress,hasCommits:ls,clean:!!(s!=null&&s.isClean)&&!(s!=null&&s.mergeInProgress),onError:(a,u)=>E({op:a,message:u}),suggestedMergeMessage:s!=null&&s.mergeInProgress?`Merge${s.branch?` into ${s.branch}`:""}`:void 0})}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-200 mb-4 flex items-center gap-2",children:[e.jsx(Me,{size:18,className:"text-gray-400"}),"Recent Commits (",w.length,")"]}),i&&e.jsxs("div",{className:"flex items-center gap-2 py-4 text-gray-400 text-sm justify-center",children:[e.jsx(U,{size:14,className:"animate-spin"})," Loading commits..."]}),!i&&w.length===0&&e.jsx("p",{className:"text-sm text-gray-400 py-4 text-center",children:"No commits found."}),e.jsx("div",{className:"space-y-0.5",children:w.map(a=>{const u=_s(a);return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>M(z===a.sha?null:a.sha),"aria-expanded":z===a.sha,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-surface-2 transition-colors text-left group",children:[e.jsx("span",{className:"text-gray-500 flex-shrink-0",children:z===a.sha?e.jsx(Te,{size:14}):e.jsx(as,{size:14})}),e.jsx("span",{className:"font-mono text-brand-400 text-sm w-20 flex-shrink-0",children:a.shortSha}),e.jsx("span",{className:"text-sm text-gray-200 truncate flex-1 min-w-0",children:a.message}),e.jsxs("span",{className:"flex items-center gap-1 text-xs text-gray-400 min-w-0 max-w-[10rem] shrink",title:a.author,children:[e.jsx(Fe,{size:12,className:"shrink-0"})," ",e.jsx("span",{className:"truncate",children:a.author})]}),e.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0 w-16 text-right",title:Ge(a.timestamp),children:es(a.timestamp)}),u&&e.jsx("span",{className:"flex items-center gap-1 flex-shrink-0 ml-1",title:`Latest test run on this commit: ${u.passed} passed, ${u.failed} failed of ${u.total}${u.when?` — ${Ge(u.when)}`:""}`,children:u.failed>0?e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-red-500",children:[e.jsx(As,{size:12})," ",u.failed]}):e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-emerald-500",children:[e.jsx(Ut,{size:12})," ",u.passed]})})]}),z===a.sha&&e.jsx(ga,{sha:a.sha})]},a.sha)})}),!i&&w.length>=d&&d>=((x==null?void 0:x.maxLimit)??1/0)&&e.jsxs("p",{className:"mt-3 pt-3 border-t border-white/5 text-center text-xs text-gray-500",children:["Showing the latest ",w.length.toLocaleString()," commits — use ",e.jsx("code",{children:"git log"})," in a terminal for older history."]}),!i&&w.length>=d&&d<((x==null?void 0:x.maxLimit)??1/0)&&e.jsx("div",{className:"flex justify-center mt-3 pt-3 border-t border-white/5",children:e.jsxs("button",{onClick:()=>o(d+Xe),disabled:m,className:"flex items-center gap-1.5 px-4 py-2 rounded-lg text-sm font-medium bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/10 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[m?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(Rs,{size:14}),"Load ",Xe," more commits"]})})]})]}),e.jsx(de,{open:!!le,title:`Discard changes to "${(le==null?void 0:le.path)??""}"?`,description:(()=>{var G,$e;const a=(le==null?void 0:le.path)??"",u=($e=(G=T==null?void 0:T.files)==null?void 0:G.find(Pe=>Pe.staged&&Pe.path===a))==null?void 0:$e.status;return(le==null?void 0:le.status)==="untracked"?`"${a}" is untracked — confirming will delete the file from disk. This cannot be undone.`:u?`The unstaged edits to "${a}" will be lost permanently. What you staged for this file stays staged.`:`"${a}" will be restored to its last committed state. Any uncommitted edits will be lost permanently — git keeps no history of discarded changes.`})(),confirmLabel:"Discard",onConfirm:Es,onCancel:()=>Ee(null)}),Ae&&e.jsx(ta,{upstream:be.upstream,dirtyCount:be.dirty,behind:be.behind,running:X.isPending,result:Ue,error:Ce,onClose:()=>Ne(!1),onResolve:a=>{Ne(!1),Be(a)}}),e.jsx(de,{open:L,title:"Skip this commit?",description:`Your resolution kept the code exactly as it already is, so the commit this ${A?Q[A.kind].toLowerCase():"operation"} stopped on would change nothing. Skipping leaves it out and carries on with the rest — nothing in your files changes.`,confirmLabel:"Skip this commit",variant:"primary",onCancel:()=>f(!1),onConfirm:()=>{f(!1),Ys()}}),e.jsx(de,{open:k,title:"Back out the stash?",description:`The files your stash touched go back to the last commit, and the stash ("${((gs=s==null?void 0:s.pendingStash)==null?void 0:gs.message)??""}") is kept — Pop it again whenever you're ready. Any resolving you did in those files is thrown away.`,confirmLabel:"Back out",icon:ce,onCancel:()=>v(!1),onConfirm:()=>{v(!1),H.mutate(void 0,{onSuccess:a=>{E(null),t("success",`Backed out — ${a.restored.length} file${a.restored.length===1?"":"s"} back to the last commit; the stash is kept`)},onError:a=>E({op:"Back out",message:a.message})})}}),e.jsx(de,{open:V,title:`Abort the ${A?Q[A.kind].toLowerCase():"operation"}?`,description:`Your branch goes back to how it was before the ${A?Q[A.kind].toLowerCase():"operation"} started. Conflicts you already resolved are thrown away.`,confirmLabel:"Abort",icon:ce,onCancel:()=>ee(!1),onConfirm:Ks}),rs&&e.jsx(ma,{path:rs,onClose:()=>Be(null),onResolved:(a,u)=>{Be(null),C(!0),is(null),n(),t("success",u.length===0?`Resolved ${a} — all conflicts done, commit to finish merge`:`Resolved ${a} — ${u.length} conflict${u.length===1?"":"s"} left`)}})]})}const vs=50;function ga({sha:t}){const{data:s,isLoading:l}=$s(t),[n,r]=g.useState({});return l?e.jsxs("div",{className:"ml-10 px-3 py-2 text-xs text-gray-500 flex items-center gap-1.5",children:[e.jsx(U,{size:10,className:"animate-spin"})," Loading diff..."]}):!(s!=null&&s.files)||s.files.length===0?e.jsx("div",{className:"ml-10 px-3 py-2 text-xs text-gray-500",children:"No file changes found for this commit."}):e.jsxs("div",{className:"ml-10 mr-3 mb-2 rounded-lg bg-surface-2/50 border border-white/5 p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400 mb-2",children:[e.jsx(Fe,{size:13})," ",s.author,e.jsx("span",{className:"text-gray-500",children:"•"}),e.jsx(Fs,{size:13}),e.jsx("span",{title:Ge(s.timestamp),children:es(s.timestamp)}),e.jsx("span",{className:"text-gray-500",children:"•"}),e.jsx(Et,{size:13})," ",s.files.length," file",s.files.length!==1?"s":""," changed"]}),s.truncated&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:"This commit is too large to show in full — later files may be missing."}),s.files.map(d=>{const o=d.patch?d.patch.split(`
12
+ `):[],x=n[d.path]??!1,i=x?o:o.slice(0,vs),m=o.length-i.length;return e.jsxs("div",{className:"rounded border border-white/5 bg-surface-1/50",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm",children:[e.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${d.status==="added"?"bg-emerald-500":d.status==="deleted"?"bg-red-500":d.status==="renamed"?"bg-sky-500":"bg-amber-500"}`}),e.jsx("span",{className:"text-gray-200 font-mono truncate flex-1",children:d.path}),e.jsxs("span",{className:"text-emerald-500 text-sm",children:["+",d.additions]}),e.jsxs("span",{className:"text-red-500 text-sm",children:["-",d.deletions]})]}),d.patch&&e.jsxs(e.Fragment,{children:[e.jsx("pre",{className:`px-3 py-2 text-sm text-gray-300 overflow-x-auto border-t border-white/5 font-mono whitespace-pre leading-relaxed ${x?"":"max-h-64 overflow-y-auto"}`,children:i.map((p,w)=>e.jsx("div",{className:p.startsWith("+")&&!p.startsWith("+++")?"text-emerald-500":p.startsWith("-")&&!p.startsWith("---")?"text-red-500":p.startsWith("@@")?"text-brand-400":"",children:p},w))}),m>0&&e.jsxs("button",{onClick:()=>r(p=>({...p,[d.path]:!0})),className:"w-full px-3 py-2 text-xs font-medium text-brand-400 hover:text-brand-300 hover:bg-brand-500/5 border-t border-white/5 transition-colors",children:["Show all ",o.length," lines (",m," hidden)"]}),x&&o.length>vs&&e.jsx("button",{onClick:()=>r(p=>({...p,[d.path]:!1})),className:"w-full px-3 py-2 text-xs font-medium text-gray-400 hover:text-gray-200 hover:bg-white/5 border-t border-white/5 transition-colors",children:"Collapse"}),d.truncated&&e.jsx("p",{className:"px-3 py-1.5 text-xs text-amber-600 dark:text-amber-400 border-t border-white/5",children:"This file's diff is too large to show in full — the rest is cut off."})]})]},d.path)})]})}function es(t){try{const s=Date.now(),l=new Date(t).getTime(),n=s-l,r=Math.floor(n/6e4);if(r<1)return"now";if(r<60)return`${r}m`;const d=Math.floor(r/60);if(d<24)return`${d}h`;const o=Math.floor(d/24);if(o<30)return`${o}d`;const x=Math.floor(o/7);return o<90?`${x}w`:`${Math.floor(o/30)}mo`}catch{return""}}export{Na as GitPage};
@@ -0,0 +1,36 @@
1
+ import{r as z,j as e,u as Ke}from"./vendor-react-CTbHBddL.js";import{r as Qe,w as Ye}from"./excel-BrxuVus5.js";import{au as et,av as tt,J as st}from"./useTestManagement-ZTA1_VUm.js";import{b as rt}from"./index-DtBWNlVD.js";import{h as ot}from"./aiHandoff-vhtR29Fh.js";import{a9 as te,a3 as ve,al as it,be as se,aK as ze,r as G,a2 as Te,ca as $e,g as Me,ap as nt,S as Ne}from"./vendor-icons-B0wLOBoh.js";import"./vendor-excel-BFHGVHVC.js";import"./vendor-query-BrzmPFT3.js";const de=[{id:"json",label:"JSON",ext:"json",mime:"application/json",hint:"Everything, re-importable into Testver"},{id:"csv",label:"CSV",ext:"csv",mime:"text/csv",hint:"One row per case, re-importable into Testver"},{id:"xlsx",label:"Excel",ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",hint:"A Test cases sheet and a Steps sheet"},{id:"gherkin",label:"Gherkin",ext:"feature",mime:"text/plain",hint:"A BDD .feature file — Given / When / Then"},{id:"xray",label:"Xray CSV",ext:"csv",mime:"text/csv",hint:"Xray's Test Case Importer — one row per step"},{id:"testrail",label:"TestRail CSV",ext:"csv",mime:"text/csv",hint:"TestRail's CSV import — numbered steps"},{id:"zephyr",label:"Zephyr Scale CSV",ext:"csv",mime:"text/csv",hint:"Zephyr Scale's CSV import — one row per step"}];function at(n){return`"${String(n??"").replace(/\r\n?/g,`
2
+ `).replace(/"/g,'""')}"`}function oe(n){return n.map(o=>o.map(at).join(",")).join(`\r
3
+ `)}function Fe(n){const o=[];let i=[],t="",s=!1;const r=n.replace(/^/,""),a=()=>{i.push(t.trim()),t=""},d=()=>{a(),i.some(l=>l!=="")&&o.push(i),i=[]};for(let l=0;l<r.length;l++){const m=r[l];s?m==='"'?r[l+1]==='"'?(t+='"',l++):s=!1:t+=m:m==='"'&&t.trim()===""?s=!0:m===","?a():m===`
4
+ `||m==="\r"?(m==="\r"&&r[l+1]===`
5
+ `&&l++,d()):t+=m}return d(),o}const B=n=>String(n??"").replace(/\s*\r?\n\s*/g," ").trim(),ie=n=>(n.steps??[]).filter(o=>(o.action??"").trim()||(o.expectedResult??"").trim()),Re=n=>n.map((o,i)=>`${i+1}. ${B(o)}`).join(`
6
+ `),ee=n=>n.id?`${n.id}: ${n.title}`:n.title,Ee={critical:{jira:"Highest",testrail:"Critical",zephyr:"High"},high:{jira:"High",testrail:"High",zephyr:"High"},medium:{jira:"Medium",testrail:"Medium",zephyr:"Normal"},low:{jira:"Low",testrail:"Low",zephyr:"Low"}},he=(n,o)=>{var i;return((i=Ee[String(n??"medium").toLowerCase()])==null?void 0:i[o])??Ee.medium[o]},Oe=n=>n.trim().replace(/\s+/g,"_");function lt(n){const o=["Title","Priority","Type","Tags","Preconditions","Steps (Action)","Steps (Expected Result)","Steps (Test Data)","ID","Folder","Status","Review Status","Automation","Requirements","Sources","Strategy","Automatable","Automatable Reason","Grounding","Spec Drift"],i=n.map(t=>{const s=t.steps??[];return[t.title??"",t.priority??"",t.type??"",(t.tags??[]).join(", "),t.preconditions??"",s.map(r=>B(r.action)).join(" | "),s.map(r=>B(r.expectedResult)).join(" | "),s.map(r=>B(r.testData)).join(" | "),t.id??"",t.folder??"",t.status??"",t.reviewStatus??"",t.automationStatus??"",B((t.requirements??[]).map(ee).join("; ")),B((t.sources??[]).map(r=>r.title).join("; ")),t.strategy??"",t.automatable??"",B(t.automatableReason),t.grounding??"",t.specDrift?B(`Requirement says: ${t.specDrift.requirementSays} — app does: ${t.specDrift.appDoes}`):""]});return oe([o,...i])}function ct(n){const o=["Test ID","Summary","Description","Priority","Labels","Test Type","Action","Data","Expected Result"],i=[];return n.forEach((t,s)=>{const r=t.id||`T${s+1}`,a=[t.preconditions?`Preconditions: ${t.preconditions}`:"",...(t.requirements??[]).map(m=>`Verifies ${ee(m)}`)].filter(Boolean).join(`
7
+ `),d=[r,t.title,a,he(t.priority,"jira"),(t.tags??[]).map(Oe).join(" "),"Manual"],l=ie(t);if(l.length===0){i.push([...d,"","",""]);return}l.forEach((m,f)=>i.push([...f===0?d:[r,"","","","",""],m.action??"",m.testData??"",m.expectedResult??""]))}),oe([o,...i])}function pt(n){const o=["Title","Section","Type","Priority","Preconditions","Steps","Expected Result","References"],i=n.map(t=>{const s=ie(t);return[t.title,t.folder??"","Functional",he(t.priority,"testrail"),t.preconditions??"",Re(s.map(r=>r.testData?`${r.action} (data: ${B(r.testData)})`:r.action??"")),Re(s.map(r=>r.expectedResult??"")),(t.requirements??[]).map(r=>r.externalId||r.id||"").filter(Boolean).join(", ")]});return oe([o,...i])}function dt(n){const o=["Name","Objective","Precondition","Folder","Status","Priority","Labels","Test Script (Step-by-Step) - Step","Test Script (Step-by-Step) - Test Data","Test Script (Step-by-Step) - Expected Result"],i=[];for(const t of n){const s=(t.requirements??[]).map(l=>`Verifies ${ee(l)}`).join(`
8
+ `),r=t.folder?`/${t.folder.split(" / ").join("/")}`:"",a=[t.title,s,t.preconditions??"",r,"Draft",he(t.priority,"zephyr"),(t.tags??[]).map(Oe).join(",")],d=ie(t);if(d.length===0){i.push([...a,"","",""]);continue}d.forEach((l,m)=>i.push([...m===0?a:["","","","","","",""],l.action??"",l.testData??"",l.expectedResult??""]))}return oe([o,...i])}const me=n=>`@${n.trim().replace(/[\s@]+/g,"-").replace(/[^\p{L}\p{N}_\-.:]/gu,"")}`,Q=n=>B(n)||"(empty)";function mt(n,o="Test cases"){const i=[`Feature: ${Q(o)}`,""],t=new Map;for(const r of n){const a=r.folder??"";t.set(a,[...t.get(a)??[],r])}const s=t.size>1;for(const[r,a]of t){const d=s?" ":" ";s&&i.push(` Rule: ${r||"No folder"}`,"");for(const l of a){const m=[l.id?me(l.id):"",l.priority?me(`priority-${l.priority}`):"",...(l.tags??[]).map(me),l.automatable==="manual"?"@manual":""].filter(p=>p.length>1);m.length&&i.push(`${d}${[...new Set(m)].join(" ")}`),i.push(`${d}Scenario: ${Q(l.title)}`);for(const p of l.requirements??[])i.push(`${d} # Verifies ${B(ee(p))}`);let f="";const j=p=>{const h=f===p?"And":p;return f=p,h},b=String(l.preconditions??"").split(/\r?\n|;\s+/).map(p=>p.trim()).filter(Boolean);for(const p of b)i.push(`${d} ${j("Given")} ${Q(p)}`);for(const p of ie(l))(p.action??"").trim()&&(i.push(`${d} ${j("When")} ${Q(p.action)}`),(p.testData??"").trim()&&i.push(`${d} """`,...String(p.testData).split(/\r?\n/).map(h=>`${d} ${h.replace(/"""/g,'\\"\\"\\"')}`),`${d} """`)),(p.expectedResult??"").trim()&&i.push(`${d} ${j("Then")} ${Q(p.expectedResult)}`);i.push("")}}return i.join(`
9
+ `).replace(/\n+$/,`
10
+ `)}function ut(n){const o=["ID","Title","Folder","Priority","Type","Status","Review Status","Automation","Preconditions","Tags","Requirements","Sources","Strategy","Automatable","Automatable Reason","Grounding","Spec Drift","Steps"],i=n.map(s=>[s.id??"",s.title,s.folder??"",s.priority??"",s.type??"",s.status??"",s.reviewStatus??"",s.automationStatus??"",s.preconditions??"",(s.tags??[]).join(", "),(s.requirements??[]).map(ee).join(`
11
+ `),(s.sources??[]).map(r=>r.title).join(`
12
+ `),s.strategy??"",s.automatable??"",s.automatableReason??"",s.grounding??"",s.specDrift?`Requirement says: ${s.specDrift.requirementSays}
13
+ App does: ${s.specDrift.appDoes}`:"",(s.steps??[]).length]),t=[];for(const s of n)(s.steps??[]).forEach((r,a)=>t.push([s.id??"",s.title,r.stepNumber??a+1,r.action??"",r.expectedResult??"",r.testData??""]));return[{name:"Test cases",rows:[o,...i],widths:[10,48,24,10,12,10,14,12,36,20,36,24,14,12,36,12,36,7]},{name:"Steps",rows:[["Test case ID","Test case","Step","Action","Expected result","Test data"],...t],widths:[10,40,6,48,48,24]}]}function ue(n,o,i){switch(n){case"json":return JSON.stringify(o,null,2);case"csv":return lt(o);case"gherkin":return mt(o,i);case"xray":return ct(o);case"testrail":return pt(o);case"zephyr":return dt(o)}}function L(n){return n?n.replace(/<br\s*\/?>/gi,`
14
+ `).replace(/<\/li>/gi,`
15
+ `).replace(/<\/p>/gi,`
16
+ `).replace(/<\/div>/gi,`
17
+ `).replace(/<[^>]*>/g,"").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&nbsp;/g," ").replace(/\n{3,}/g,`
18
+
19
+ `).trim():""}function J(n){if(!n)return[];const o=L(n),i=o.split(/\n\s*(?:\d+[\.\)]\s*|Step\s+\d+[:\s])/i).map(r=>r.trim()).filter(Boolean),t=/^(?:1[.)]\s+|Step\s+1[:\s]\s*)/i;if(i.length>1)return i.map((r,a)=>a===0?r.replace(t,"").trim():r);const s=o.split(`
20
+ `).map(r=>r.trim()).filter(Boolean);return s.length===1?[s[0].replace(/^1[.)]\s+/,"").trim()].filter(Boolean):s}function Z(n){if(!n)return"medium";const o=String(n).toLowerCase().trim();return["1","p1","critical","blocker","highest"].includes(o)?"critical":["2","p2","high","major"].includes(o)?"high":["3","p3","medium","normal","moderate"].includes(o)?"medium":["4","p4","low","minor","trivial","lowest"].includes(o)?"low":"medium"}function Y(n){if(!n)return"functional";const o=n.toLowerCase().trim();return{functional:"functional",regression:"regression",smoke:"smoke",sanity:"sanity",e2e:"e2e","end-to-end":"e2e","end to end":"e2e",integration:"integration",performance:"performance",security:"security",accessibility:"accessibility",acceptance:"functional",automated:"functional",manual:"functional",exploratory:"functional",usability:"functional"}[o]||"functional"}function ne(n){const o=Fe(n);if(o.length<2)return{headers:[],rows:[]};const i=o[0].map(s=>s.replace(/^"|"$/g,"")),t=o.slice(1).map(s=>{const r={};return i.forEach((a,d)=>{r[a]=s[d]||""}),r});return{headers:i,rows:t}}function xe(n,o,i){var t,s;if(i)return{tool:i,format:o};if(o==="xml"){const r=n;if(r.includes("<suite")||r.includes("<sections")||r.includes("<cases>"))return{tool:"testrail",format:"xml"};if(r.includes("<testcase")||r.includes("<teststep"))return{tool:"zephyr",format:"xml"}}if(o==="csv"){const a=((t=n.split(`
21
+ `)[0])==null?void 0:t.toLowerCase())||"";if(a.includes("section")&&a.includes("title")&&(a.includes("suite")||a.includes("references")))return{tool:"testrail",format:"csv"};if(a.includes("summary")&&(a.includes("issue type")||a.includes("test type")||a.includes("manual test")))return{tool:"xray",format:"csv"};if(a.includes("name")&&a.includes("test script (step-by-step)"))return{tool:"zephyr",format:"csv"};if(a.includes("name")&&a.includes("steps")&&a.includes("expected"))return{tool:"practitest",format:"csv"}}if(o==="json")try{const a=JSON.parse(n),d=Array.isArray(a)?a:a.issues||a.tests||[];if(d.length>0&&((s=d[0].fields)!=null&&s.summary))return{tool:"xray",format:"json"}}catch{}return null}function xt(n){const o=n.map(i=>i.toLowerCase());return o.some(i=>i.includes("module"))&&o.some(i=>i.includes("test step"))?"qtest":o.some(i=>i.includes("folder"))||o.some(i=>i.includes("label"))?"zephyr":"qtest"}function fe(n){const{headers:o,rows:i}=ne(n),t=[],s={},r=x=>o.find(S=>x.some(R=>S.toLowerCase().includes(R.toLowerCase()))),a=r(["Title","Case Title","Name"])||"Title",d=r(["Priority"])||"Priority",l=r(["Type","Test Type"])||"Type",m=r(["Section","Suite","Folder"])||"Section",f=r(["Preconditions","Precondition"])||"Preconditions",j=r(["Steps","Test Steps","Steps (Actions)"])||"Steps",b=r(["Expected Result","Expected Results","Expected"])||"Expected Result",p=r(["References","Refs"])||"References";s[a]="title",s[d]="priority",s[l]="type",s[m]="tags (section)",s[f]="preconditions",s[j]="steps",s[b]="expectedResult";const h=i.filter(x=>{var S;return(S=x[a])==null?void 0:S.trim()}).map(x=>{var T;const S=[];x[m]&&S.push(x[m]),x[p]&&S.push(...x[p].split(",").map(P=>P.trim()).filter(Boolean));const R=x[j]||"",E=x[b]||"",u=J(R),v=J(E),N=u.length>0?u.map((P,g)=>({action:P,expectedResult:v[g]||""})):E?[{action:R.trim()||"See expected result",expectedResult:E.trim()}]:[];return{title:x[a].trim(),priority:Z(x[d]),type:Y(x[l]),preconditions:((T=x[f])==null?void 0:T.trim())||"",steps:N.length>0?N:void 0,tags:S.length>0?S:void 0}});return h.length===0&&t.push("No test cases found. Check if the CSV matches TestRail export format."),{testCases:h,detectedTool:"TestRail (CSV)",warnings:t,fieldMapping:s}}function De(n){const i=new DOMParser().parseFromString(n,"text/xml"),t=[],s=i.querySelector("parsererror");if(s)return{testCases:[],detectedTool:"TestRail (XML)",warnings:["Invalid XML: "+(s.textContent||"").slice(0,200)],fieldMapping:{}};const r={title:"title",priority_id:"priority",type:"type",preconds:"preconditions","steps_separated/step":"steps","section/name":"tags"},a=[];return i.querySelectorAll("case").forEach(l=>{var R,E,u,v,N,T,P,g,C;const m=(E=(R=l.querySelector("title"))==null?void 0:R.textContent)==null?void 0:E.trim();if(!m)return;const f=(u=l.querySelector("priority_id"))==null?void 0:u.textContent,j=(v=l.querySelector("type"))==null?void 0:v.textContent,b=((T=(N=l.querySelector("custom preconds"))==null?void 0:N.textContent)==null?void 0:T.trim())||"",p=l.closest("section"),h=(g=(P=p==null?void 0:p.querySelector(":scope > name"))==null?void 0:P.textContent)==null?void 0:g.trim(),x=[],S=l.querySelectorAll("custom steps_separated step");if(S.length>0)S.forEach(y=>{var O,q;const M=L(((O=y.querySelector("content"))==null?void 0:O.textContent)||""),$=L(((q=y.querySelector("expected"))==null?void 0:q.textContent)||"");M&&x.push({action:M,expectedResult:$})});else{const y=(C=l.querySelector("custom steps"))==null?void 0:C.textContent;y&&J(y).forEach(M=>x.push({action:M}))}a.push({title:m,priority:Z(f),type:Y(j||void 0),preconditions:L(b),steps:x.length>0?x:void 0,tags:h?[h]:void 0})}),a.length===0&&t.push("No <case> elements found in XML."),{testCases:a,detectedTool:"TestRail (XML)",warnings:t,fieldMapping:r}}function re(n,o){const i=o.toLowerCase(),t=n.getElementsByTagName?n.getElementsByTagName("*"):n.querySelectorAll("*"),s=[];for(let r=0;r<t.length;r++){const a=t[r];a.tagName.toLowerCase()===i&&s.push(a)}return s}function U(n,...o){const i=o.map(t=>t.toLowerCase());for(const t of Array.from(n.children))if(i.includes(t.tagName.toLowerCase()))return t;return null}function Ae(n){const i=new DOMParser().parseFromString(n,"text/xml"),t=[];if(i.querySelector("parsererror"))return{testCases:[],detectedTool:"Zephyr (XML)",warnings:["Invalid XML"],fieldMapping:{}};const r={name:"title",priority:"priority","labels/label | folder":"tags","testScript/steps/step/description":"steps.action","testScript/steps/step/expectedResult":"steps.expectedResult","testScript/steps/step/testData":"steps.testData","objective | precondition":"preconditions"},a=[];return re(i,"testCase").forEach(l=>{var v,N,T,P,g;const m=U(l,"name"),f=((v=m==null?void 0:m.textContent)==null?void 0:v.trim())||l.getAttribute("name")||"";if(!f)return;const j=U(l,"priority"),b=((N=j==null?void 0:j.textContent)==null?void 0:N.trim())||l.getAttribute("priority")||"",p=[],h=U(l,"folder");(T=h==null?void 0:h.textContent)!=null&&T.trim()&&p.push(h.textContent.trim());const x=U(l,"labels");if(x)for(const C of Array.from(x.children)){const y=(P=C.textContent)==null?void 0:P.trim();y&&p.push(y)}const S=L(((g=U(l,"precondition","preconditions","objective"))==null?void 0:g.textContent)||""),R=[],E=U(l,"testScript");let u=[];if(E){const C=U(E,"steps");C&&(u=Array.from(C.children).filter(y=>y.tagName.toLowerCase()==="step"))}u.length===0&&(u=re(l,"step").filter(C=>{var y;return l.contains(((y=C.parentElement)==null?void 0:y.parentElement)||null),!0}),u.length===0&&(u=[...re(l,"teststep"),...re(l,"test-step")])),u.forEach(C=>{var O,q,X,V;const y=L(((O=U(C,"description","action","step"))==null?void 0:O.textContent)||((q=C.querySelector("content"))==null?void 0:q.textContent)||""),M=L(((X=U(C,"expectedResult","expected","result"))==null?void 0:X.textContent)||""),$=L(((V=U(C,"testData","test-data","data"))==null?void 0:V.textContent)||"");y&&R.push({action:y,expectedResult:M,testData:$||void 0})}),a.push({title:f,priority:Z(b),preconditions:S,steps:R.length>0?R:void 0,tags:p.length>0?p:void 0})}),a.length===0&&t.push("No <testCase> elements found in XML. Expected a Zephyr Scale / TM4J export with <project><testCases><testCase>… structure."),{testCases:a,detectedTool:"Zephyr (XML)",warnings:t,fieldMapping:r}}function Pe(n,o){var R,E;const i=[],t=u=>n.find(v=>u.some(N=>v.toLowerCase().includes(N.toLowerCase()))),s=t(["Test Case Name","Test Case","Name","Title","Summary"])||n[0]||"Name",r=t(["Priority"])||"",a=t(["Folder","Component"])||"",d=t(["Label","Tag"])||"",l=t(["Objective"])||"",m=t(["Precondition"])||"",f=t(["Step Description","Test Step Description","Test Script (Step-by-Step) - Description","Step Action","Test Step","Action","Description","Step"])||"",j=t(["Expected Result","Expected Results","Step Expected Result","Test Script (Step-by-Step) - Expected Result","Expected"])||"",b=t(["Test Data","Step Test Data","Test Script (Step-by-Step) - Test Data","Data"])||"",p={[s]:"title"};r&&(p[r]="priority"),a&&(p[a]="tags (folder)"),d&&(p[d]="tags (labels)"),l&&(p[l]="preconditions (objective)"),m&&(p[m]="preconditions"),f&&(p[f]="steps.action"),j&&(p[j]="steps.expectedResult"),b&&(p[b]="steps.testData");const h=u=>{var P,g;const v=[],N=(P=u[a])==null?void 0:P.trim();N&&v.push(N);const T=(g=u[d])==null?void 0:g.trim();return T&&T.split(/[,;|]/).map(C=>C.trim()).filter(Boolean).forEach(C=>v.push(C)),v},x=f!==""&&o.some(u=>{var v,N,T;return!((v=u[s])!=null&&v.trim())&&(((N=u[f])==null?void 0:N.trim())||((T=u[j])==null?void 0:T.trim()))}),S=[];if(x){let u=null,v=[];const N=()=>{u&&(u.steps=v.length>0?v:void 0,S.push(u)),u=null,v=[]};for(const T of o){const P=(R=T[s])==null?void 0:R.trim();if(P){N(),u={title:P,priority:Z(T[r]),preconditions:L(T[m]||T[l]||""),steps:void 0,tags:void 0};const g=h(T);g.length>0&&(u.tags=g)}if(u){const g=L(T[f]||""),C=L(T[j]||""),y=L(T[b]||"");(g||C||y)&&v.push({action:g||"(no description)",expectedResult:C||void 0,testData:y||void 0})}}N()}else for(const u of o){const v=(E=u[s])==null?void 0:E.trim();if(!v)continue;const N=L(u[f]||""),T=L(u[j]||""),P=J(N),g=J(T),C=P.length>0?P.map((M,$)=>({action:M,expectedResult:g[$]||""})):N?[{action:N,expectedResult:T||void 0}]:[],y=h(u);S.push({title:v,priority:Z(u[r]),preconditions:L(u[m]||u[l]||""),steps:C.length>0?C:void 0,tags:y.length>0?y:void 0})}return S.length===0?i.push('No test cases parsed from the spreadsheet. Verify the export matches a Zephyr Scale / TM4J template (expected a "Name" column plus optional Test Script step columns).'):f===""&&i.push('No step column was detected — only titles were imported. Add columns like "Test Script (Step-by-Step) - Description" / "Expected Result" to capture steps.'),{testCases:S,detectedTool:"Zephyr (Excel)",warnings:i,fieldMapping:p}}function Le(n){var E,u,v,N,T,P;const{headers:o,rows:i}=ne(n),t=[],s=g=>o.find(C=>g.some(y=>C.toLowerCase().includes(y.toLowerCase()))),r=s(["Summary","Title","Name"])||"Summary",a=s(["Priority"])||"Priority",d=s(["Test Type","Issue Type","Type"])||"",l=s(["Manual Test Steps","Steps","Test Steps"])||"",m=s(["Expected Result","Expected Results"])||"",f=s(["Labels","Tags","Components"])||"",j=s(["Preconditions","Precondition","Description"])||"",b={[r]:"title",[a]:"priority"};d&&(b[d]="type"),l&&(b[l]="steps"),f&&(b[f]="tags");const p=o.find(g=>["action","step","step action"].includes(g.toLowerCase()))||"",h=o.find(g=>["data","test data","step data"].includes(g.toLowerCase()))||"",x=o.find(g=>["result","expected result","expected"].includes(g.toLowerCase()))||"",S=o.find(g=>["tcid","test id","issue id","test case identifier","id"].includes(g.toLowerCase()))||"";if(p&&S){const g=new Map;for(const y of i){const M=(E=y[S])==null?void 0:E.trim();if(!M)continue;let $=g.get(M);if(!$&&((u=y[r])!=null&&u.trim())){const V=y[f]?y[f].split(/[,;\s]+/).map(_=>_.trim()).filter(Boolean):[];$={title:y[r].trim(),priority:Z(y[a]),type:Y(y[d]),preconditions:((v=y[j])==null?void 0:v.trim())||"",tags:V.length>0?V:void 0},g.set(M,$)}if(!$)continue;const O=((N=y[p])==null?void 0:N.trim())||"",q=((T=y[x])==null?void 0:T.trim())||"",X=((P=y[h])==null?void 0:P.trim())||"";(O||q||X)&&($.steps=[...$.steps??[],{action:O||"(no description)",expectedResult:q,...X?{testData:X}:{}}])}const C=[...g.values()];return C.length===0&&t.push("No test cases found. Each test needs a row with its Summary."),{testCases:C,detectedTool:"Xray (CSV)",warnings:t,fieldMapping:{...b,[S]:"test id",[p]:"steps.action",...x?{[x]:"steps.expectedResult"}:{},...h?{[h]:"steps.testData"}:{}}}}return{testCases:i.filter(g=>{var C;return(C=g[r])==null?void 0:C.trim()}).map(g=>{var X;const C=g[f]?g[f].split(/[,;]/).map(V=>V.trim()).filter(Boolean):[],y=g[l]||"",M=g[m]||"",$=J(y),O=J(M),q=$.length>0?$.map((V,_)=>({action:V,expectedResult:O[_]||""})):[];return{title:g[r].trim(),priority:Z(g[a]),type:Y(g[d]),preconditions:((X=g[j])==null?void 0:X.trim())||"",steps:q.length>0?q:void 0,tags:C.length>0?C:void 0}}),detectedTool:"Xray (CSV)",warnings:t,fieldMapping:b}}function ft(n){const o=[];let i;try{i=JSON.parse(n)}catch{return{testCases:[],detectedTool:"Xray (JSON)",warnings:["Invalid JSON format"],fieldMapping:{}}}const t=Array.isArray(i)?i:i.issues||i.tests||[],s={"fields.summary":"title","fields.priority.name":"priority","fields.labels":"tags","fields.description":"preconditions"};return{testCases:t.filter(a=>{var d;return(d=a.fields)==null?void 0:d.summary}).map(a=>{var f,j;const d=a.fields,l=[];for(const[b,p]of Object.entries(d||{}))if(b.startsWith("customfield_")&&Array.isArray(p)){const h=p;if(h.length>0&&(h[0].action||h[0].step||h[0].content)){h.forEach(x=>{const S=L(x.action||x.step||x.content||""),R=L(x.result||x.expected||x.expectedResult||""),E=L(x.data||x.testData||"");S&&l.push({action:S,expectedResult:R,testData:E||void 0})}),s[b]="steps";break}}const m=Array.isArray(d.labels)?d.labels:[];return{title:d.summary,priority:Z(((f=d.priority)==null?void 0:f.name)||d.priority),type:Y((j=d.issuetype)==null?void 0:j.name),preconditions:L(d.description||""),steps:l.length>0?l:void 0,tags:m.length>0?m:void 0}}),detectedTool:"Xray (JSON)",warnings:o,fieldMapping:s}}function ke(n){const{headers:o,rows:i}=ne(n),t=[],s=p=>o.find(h=>p.some(x=>h.toLowerCase().includes(x.toLowerCase()))),r=s(["Name","Title","Test Name"])||o[0]||"Name",a=s(["Priority"])||"",d=s(["Steps","Test Steps","Step Description"])||"",l=s(["Expected Results","Expected Result","Expected"])||"",m=s(["Preconditions","Precondition"])||"",f=s(["Tags","Labels","Custom Fields"])||"",j={[r]:"title"};return a&&(j[a]="priority"),d&&(j[d]="steps"),l&&(j[l]="expectedResult"),{testCases:i.filter(p=>{var h;return(h=p[r])==null?void 0:h.trim()}).map(p=>{var E;const h=J(p[d]||""),x=J(p[l]||""),S=h.length>0?h.map((u,v)=>({action:u,expectedResult:x[v]||""})):[],R=p[f]?p[f].split(/[,;]/).map(u=>u.trim()).filter(Boolean):[];return{title:p[r].trim(),priority:Z(p[a]),preconditions:((E=p[m])==null?void 0:E.trim())||"",steps:S.length>0?S:void 0,tags:R.length>0?R:void 0}}),detectedTool:"PractiTest (CSV)",warnings:t,fieldMapping:j}}function Ie(n,o){const i=[],t=b=>n.find(p=>b.some(h=>p.toLowerCase().includes(h.toLowerCase()))),s=t(["Name","Test Case Name","Title","Summary"])||n[0]||"Name",r=t(["Priority"])||"",a=t(["Test Steps","Steps","Step Description","Test Step Description"])||"",d=t(["Expected Result","Expected Results","Expected"])||"",l=t(["Preconditions","Precondition","Pre-Conditions"])||"",m=t(["Module","Folder","Component"])||"",f={[s]:"title"};return r&&(f[r]="priority"),a&&(f[a]="steps"),d&&(f[d]="expectedResult"),m&&(f[m]="tags (module)"),{testCases:o.filter(b=>{var p;return(p=b[s])==null?void 0:p.trim()}).map(b=>{var u;const p=L(b[a]||""),h=L(b[d]||""),x=J(p),S=J(h),R=x.length>0?x.map((v,N)=>({action:v,expectedResult:S[N]||""})):[],E=[];return(u=b[m])!=null&&u.trim()&&E.push(b[m].trim()),{title:b[s].trim(),priority:Z(b[r]),preconditions:L(b[l]||""),steps:R.length>0?R:void 0,tags:E.length>0?E:void 0}}),detectedTool:"qTest (Excel)",warnings:i,fieldMapping:f}}async function ht(n,o,i){if(i=String(i||"").toLowerCase(),i==="xlsx"||i==="xls"){const s=await Qe(n);if(s.length===0)return{testCases:[],detectedTool:"Unknown",warnings:["Empty spreadsheet or no data rows found"],fieldMapping:{}};const r=Object.keys(s[0]),a=o||xt(r);return a==="qtest"?Ie(r,s):a==="zephyr"?Pe(r,s):Ie(r,s)}const t=n;if(i==="xml"){const s=xe(t,i,o||void 0);if((s==null?void 0:s.tool)==="testrail"||o==="testrail")return De(t);if((s==null?void 0:s.tool)==="zephyr"||o==="zephyr")return Ae(t);const r=De(t),a=Ae(t);return r.testCases.length>=a.testCases.length?r:a}if(i==="json")return ft(t);if(i==="csv"||i==="txt"){const s=xe(t,"csv",o||void 0);if((s==null?void 0:s.tool)==="zephyr"||o==="zephyr"){const{headers:a,rows:d}=ne(t);return{...Pe(a,d),detectedTool:"Zephyr (CSV)"}}if((s==null?void 0:s.tool)==="testrail"||o==="testrail")return fe(t);if((s==null?void 0:s.tool)==="xray"||o==="xray")return Le(t);if((s==null?void 0:s.tool)==="practitest"||o==="practitest")return ke(t);const r=xe(t,"csv");if(r){if(r.tool==="testrail")return fe(t);if(r.tool==="xray")return Le(t);if(r.tool==="practitest")return ke(t)}return fe(t)}return{testCases:[],detectedTool:"Unknown",warnings:[`Unsupported file format: .${i}`],fieldMapping:{}}}const gt=!1;function qe(n,o=0){var t;const i=[];for(const s of n)i.push({id:s.id,name:s.name,depth:o}),(t=s.children)!=null&&t.length&&i.push(...qe(s.children,o+1));return i}function Rt({embedded:n=!1}={}){var Ce,we;const[o,i]=z.useState(null),[t,s]=z.useState("json"),[r,a]=z.useState(""),[d,l]=z.useState(""),[m,f]=z.useState(null),[j,b]=z.useState("file"),[p,h]=z.useState(!1),[x,S]=z.useState("select"),[R,E]=z.useState(null),[u,v]=z.useState(null),[N,T]=z.useState(null),[P,g]=z.useState(!1),[C,y]=z.useState(!1),[M,$]=z.useState(""),{toast:O}=rt(),[q,X]=z.useState(!1),V=et(),_=tt(),{data:W}=st(),ge=Array.isArray(W)?W:(W==null?void 0:W.folders)??(W==null?void 0:W.tree)??[],ae=z.useMemo(()=>qe(ge),[ge]),ye=((Ce=ae.find(c=>c.id===d))==null?void 0:Ce.name)||"Test cases";function be(c){O("success",c)}function Ve(c){navigator.clipboard.writeText(c),X(!0),setTimeout(()=>X(!1),2e3)}async function Xe(c){try{const w=await V.mutateAsync(c||void 0);i(w),be("Export completed")}catch{}}function Be(c){const w=Fe(c);if(w.length<2)return[];const D=w[0].map(A=>A.trim().toLowerCase());return w.slice(1).map(A=>{const k={};D.forEach((I,Ge)=>{k[I]=A[Ge]||""});const F=k.title||k.name||k["test case"]||"",je=[],ce=(k["steps (action)"]||"").split("|").map(I=>I.trim()),pe=(k["steps (expected result)"]||"").split("|").map(I=>I.trim()),Se=(k["steps (test data)"]||"").split("|").map(I=>I.trim()),He=Math.max(ce.length,pe.length,Se.length);for(let I=0;I<He;I++)(ce[I]||pe[I])&&je.push({action:ce[I]||"",expectedResult:pe[I]||"",testData:Se[I]||""});return{title:F,priority:k.priority||"medium",type:k.type||"functional",tags:(k.tags||"").split(",").map(I=>I.trim()).filter(Boolean),preconditions:k.preconditions||"",steps:je}}).filter(A=>A.title)}function Je(c,w,D){const A=new Blob([c],{type:D}),k=URL.createObjectURL(A),F=document.createElement("a");F.href=k,F.download=w,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(k)}async function Ue(){if(!o)return;const c=(o==null?void 0:o.testCases)??(Array.isArray(o)?o:[]),w=de.find(A=>A.id===t),D=`test-cases-${w.id==="json"||w.id==="csv"||w.id==="xlsx"||w.id==="gherkin"?"export":w.id}-${Date.now()}.${w.ext}`;if(w.id==="xlsx"){try{const A=await Ye(ut(c)),k=URL.createObjectURL(A),F=document.createElement("a");F.href=k,F.download=D,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(k)}catch(A){O("error",`Could not build the Excel file: ${(A==null?void 0:A.message)||A}`)}return}Je(ue(w.id,c,ye),D,w.mime)}function Ze(c){var A;const w=(A=c.target.files)==null?void 0:A[0];if(!w)return;const D=new FileReader;D.onload=()=>{a(D.result)},D.readAsText(w),c.target.value=""}async function We(){if(r.trim())try{let c;const w=r.trim();if(w.startsWith("[")||w.startsWith("{")?(c=JSON.parse(w),Array.isArray(c)||(c=[c])):c=Be(w),!c.length){f({error:"No valid test cases found in input"});return}const D=await _.mutateAsync({testCases:c,folderId:d||void 0});f(D),be(`${(D==null?void 0:D.imported)??0} test cases imported`)}catch(c){f({error:c.message||"Import failed"})}}z.useCallback(async c=>{if(R){y(!0);try{const w=c.name.lastIndexOf("."),D=w>-1?c.name.slice(w+1).toLowerCase():"",k=D==="xlsx"||D==="xls"?await c.arrayBuffer():await c.text(),F=await ht(k,R,D);v(F),S("preview")}catch(w){v({detectedTool:R,testCases:[],fieldMapping:{},warnings:[w.message||"Failed to parse file"]}),S("preview")}finally{y(!1)}}},[R]);const K=o?(o==null?void 0:o.testCases)??(Array.isArray(o)?o:[]):[],le=de.find(c=>c.id===t),H=K.length>0?t==="xlsx"?ue("csv",K):ue(t,K,ye):null,_e=H?new Blob([H]).size:0;return e.jsx("div",{className:n?"text-gray-200":"min-h-screen bg-surface-0 text-gray-200",children:e.jsx("div",{className:n?"":"max-w-[1400px] mx-auto px-6 py-6",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-100 mb-1 flex items-center gap-2",children:[e.jsx(te,{size:20,className:"text-brand-300"}),"Export Test Cases"]}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Export test cases for backup, migration, or sharing"}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-end gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex-1 min-w-[180px] max-w-xs",children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Folder"}),e.jsxs("select",{value:d,onChange:c=>l(c.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 focus:outline-none focus:border-brand-500/50",children:[e.jsx("option",{value:"",children:"All Folders"}),ae.map(c=>e.jsx("option",{value:c.id,children:"  ".repeat(c.depth)+c.name},c.id))]})]}),e.jsxs("div",{className:"min-w-[200px]",children:[e.jsx("label",{htmlFor:"export-format",className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Format"}),e.jsx("select",{id:"export-format",value:t,onChange:c=>s(c.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 focus:outline-none focus:border-brand-500/50",children:de.map(c=>e.jsx("option",{value:c.id,children:c.label},c.id))}),e.jsx("p",{className:"text-[11px] text-gray-500 mt-1",children:le.hint})]}),e.jsxs("button",{onClick:()=>Xe(d||void 0),disabled:V.isPending,className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm font-medium flex items-center gap-2 transition-colors disabled:opacity-50",children:[V.isPending?e.jsx(ve,{size:16,className:"animate-spin"}):e.jsx(te,{size:16}),"Export"]})]}),H&&e.jsxs("div",{className:"space-y-3 border-t border-white/5 pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-gray-400",children:[K.length," test case",K.length!==1?"s":""," • ",t==="xlsx"?"preview of the Test cases sheet":`${(_e/1024).toFixed(1)} KB`," • ",le.label]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>Ve(H),className:"flex items-center gap-1.5 text-xs text-brand-300 hover:text-brand-200 transition-colors",children:[e.jsx(it,{size:12}),q?"Copied!":"Copy"]}),e.jsxs("button",{onClick:Ue,className:"flex items-center gap-1.5 text-xs bg-emerald-600 hover:bg-emerald-500 text-white px-3 py-1.5 rounded-lg font-medium transition-colors",children:[e.jsx(te,{size:12}),"Download ",le.label]})]})]}),e.jsxs("pre",{className:"bg-surface-0 border border-white/5 rounded-lg p-3 text-xs text-gray-300 font-mono max-h-64 overflow-auto whitespace-pre-wrap",children:[H.slice(0,5e3),H.length>5e3?`
22
+
23
+ ... (truncated preview)`:""]})]})]})]}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-100 mb-1 flex items-center gap-2",children:[e.jsx(se,{size:20,className:"text-brand-300"}),"Import Test Cases"]}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Import test cases from JSON or CSV files"}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center bg-surface-2 border border-white/10 rounded-lg p-0.5",children:[e.jsxs("button",{onClick:()=>b("file"),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center gap-1.5 ${j==="file"?"bg-brand-600 text-white":"text-gray-400 hover:text-gray-200"}`,children:[e.jsx(se,{size:13})," Upload File"]}),e.jsxs("button",{onClick:()=>b("paste"),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center gap-1.5 ${j==="paste"?"bg-brand-600 text-white":"text-gray-400 hover:text-gray-200"}`,children:[e.jsx(ze,{size:13})," Paste Data"]})]}),r&&e.jsxs("span",{className:"text-xs text-emerald-400 flex items-center gap-1",children:[e.jsx(G,{size:12}),r.trim().startsWith("[")||r.trim().startsWith("{")?"JSON":"CSV"," data loaded (",(new Blob([r]).size/1024).toFixed(1)," KB)"]})]}),j==="file"?e.jsx("div",{children:e.jsxs("label",{className:`flex flex-col items-center justify-center w-full h-40 border-2 border-dashed rounded-xl cursor-pointer transition-all duration-200 group ${p?"border-emerald-400 bg-emerald-500/10 scale-[1.01] shadow-lg shadow-emerald-500/10":"border-white/10 hover:border-emerald-500/40 bg-surface-2/50"}`,onDragOver:c=>{c.preventDefault(),c.stopPropagation(),h(!0)},onDragEnter:c=>{c.preventDefault(),c.stopPropagation(),h(!0)},onDragLeave:c=>{c.preventDefault(),c.stopPropagation(),h(!1)},onDrop:c=>{var A;c.preventDefault(),c.stopPropagation(),h(!1);const w=(A=c.dataTransfer.files)==null?void 0:A[0];if(!w)return;const D=new FileReader;D.onload=()=>{a(D.result)},D.readAsText(w)},children:[p?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-emerald-500/20 flex items-center justify-center mb-2 animate-pulse",children:e.jsx(te,{size:24,className:"text-emerald-300"})}),e.jsx("span",{className:"text-sm font-medium text-emerald-300",children:"Drop file here"})]}):e.jsxs(e.Fragment,{children:[e.jsx(se,{size:28,className:"text-gray-500 group-hover:text-brand-400 mb-2 transition-colors"}),e.jsxs("span",{className:"text-sm text-gray-400 group-hover:text-gray-300",children:["Click to upload ",e.jsx("span",{className:"font-medium text-brand-300",children:".json"})," or ",e.jsx("span",{className:"font-medium text-brand-300",children:".csv"})," file"]}),e.jsx("span",{className:"text-xs text-gray-600 mt-1",children:"or drag and drop"})]}),e.jsx("input",{type:"file",accept:".json,.csv,.txt",onChange:Ze,className:"hidden"})]})}):e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Paste JSON or CSV data"}),e.jsx("textarea",{value:r,onChange:c=>a(c.target.value),rows:10,placeholder:`Paste JSON array or CSV data...
24
+
25
+ JSON: [{ "title": "...", "steps": [...] }]
26
+ CSV: Title,Priority,Type,Steps (Action),Steps (Expected Result)`,className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder-gray-500 font-mono focus:outline-none focus:border-brand-500/50 resize-y"})]}),e.jsxs("div",{className:"flex items-end gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex-1 min-w-[180px] max-w-xs",children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Target Folder"}),e.jsxs("select",{value:d,onChange:c=>l(c.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 focus:outline-none focus:border-brand-500/50",children:[e.jsx("option",{value:"",children:"Root (No folder)"}),ae.map(c=>e.jsx("option",{value:c.id,children:" ".repeat(c.depth)+c.name},c.id))]})]}),e.jsxs("button",{onClick:We,disabled:_.isPending||!r.trim(),className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-5 py-2 text-sm font-medium flex items-center gap-2 transition-colors disabled:opacity-50",children:[_.isPending?e.jsx(ve,{size:16,className:"animate-spin"}):e.jsx(se,{size:16}),"Import Test Cases"]}),r&&e.jsx("button",{onClick:()=>{a(""),f(null)},className:"text-xs text-gray-500 hover:text-gray-300 transition-colors",children:"Clear"})]}),m&&e.jsx("div",{className:`rounded-lg p-3 text-sm ${m.error?"bg-red-500/10 border border-red-500/20 text-red-400":"bg-emerald-500/10 border border-emerald-500/20 text-emerald-400"}`,children:m.error?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Te,{size:16}),e.jsx("span",{children:m.error})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(G,{size:16}),e.jsxs("span",{className:"font-medium",children:[m.imported??m.count??0," test case",(m.imported??m.count??0)!==1?"s":""," imported successfully"]})]}),((we=m.errors)==null?void 0:we.length)>0&&e.jsx("ul",{className:"mt-2 space-y-1 text-xs text-red-400",children:m.errors.map((c,w)=>e.jsxs("li",{className:"flex items-start gap-1",children:[e.jsx(Te,{size:12,className:"mt-0.5 shrink-0"}),e.jsx("span",{children:typeof c=="string"?c:c.message??JSON.stringify(c)})]},w))})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"border border-white/5 rounded-lg p-3 bg-surface-0",children:[e.jsxs("p",{className:"text-xs text-gray-400 mb-2 font-bold flex items-center gap-1.5",children:[e.jsx($e,{size:12,className:"text-brand-300"})," JSON Format"]}),e.jsx("pre",{className:"text-[10px] text-gray-500 font-mono whitespace-pre-wrap leading-relaxed",children:`[{
27
+ "title": "Verify login",
28
+ "priority": "high",
29
+ "type": "functional",
30
+ "steps": [
31
+ { "action": "Go to login",
32
+ "expectedResult": "Page loads" }
33
+ ],
34
+ "tags": ["auth", "smoke"]
35
+ }]`})]}),e.jsxs("div",{className:"border border-white/5 rounded-lg p-3 bg-surface-0",children:[e.jsxs("p",{className:"text-xs text-gray-400 mb-2 font-bold flex items-center gap-1.5",children:[e.jsx(Me,{size:12,className:"text-brand-300"})," CSV Format"]}),e.jsx("pre",{className:"text-[10px] text-gray-500 font-mono whitespace-pre-wrap leading-relaxed",children:`Title,Priority,Type,Tags,Steps (Action),Steps (Expected Result),Steps (Test Data)
36
+ "Verify login","high","functional","auth, smoke","Go to login | Enter creds | Click submit","Page loads | Fields shown | Dashboard"," | user@test.com | "`}),e.jsxs("p",{className:"text-[10px] text-gray-600 mt-2",children:["Separate multiple steps with ",e.jsx("span",{className:"text-gray-400 font-medium",children:"|"})," (pipe)"]})]})]})]})]}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-100 mb-1 flex items-center gap-2",children:[e.jsx(nt,{size:20,className:"text-brand-300"}),"Import from Third-Party Tools or local files"]}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Import test cases exported from tools like TestRail, Zephyr, Xray, PractiTest, qTest — or from any other tool, or your own local test case files."}),e.jsx(yt,{}),gt]})]})})})}function yt(){const n=Ke(),o=()=>{ot(n,{prompt:"I want to import test cases from a third-party test management tool into Testver. I will upload an export file in the chat (CSV, XML, JSON, or Excel). Please read the file, extract every test case (title, priority, preconditions, steps, expected results, tags), normalize the values to match Testver's schema (priority: critical|high|medium|low; type: web|ui|api|mobile|database|integration|e2e|security|performance|usability|accessibility|compatibility|localization), and create them via the test-management tools. Report back with the count created and any rows that needed manual review.",mode:"api"})};return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-6",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-brand-500/15 flex items-center justify-center flex-shrink-0",children:e.jsx(Ne,{size:20,className:"text-brand-300"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100 mb-1",children:["Import via AI Assistant — works with any tool",e.jsx("span",{className:"ml-2 inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wider bg-brand-500/15 text-brand-300 border border-brand-500/30 align-middle",children:"API mode"})]}),e.jsxs("p",{className:"text-sm text-gray-400 leading-relaxed",children:["The AI Assistant can read an export file from tools like ",e.jsx("em",{className:"not-italic text-gray-300",children:"TestRail, Zephyr, Xray, PractiTest, qTest"})," — or from ",e.jsx("em",{className:"not-italic text-gray-300",children:"any other tool"}),", or your own local test case files — and create the test cases in Testver for you. Clicking the button below opens the AI Assistant in ",e.jsx("em",{className:"not-italic text-gray-300",children:"API mode"})," with a pre-filled prompt. Upload your export in the chat and the AI will parse the structure, map fields, and create everything in the right folder."]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mb-5",children:[e.jsxs("div",{className:"rounded-lg border border-white/5 bg-surface-2/50 p-3.5",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider font-semibold text-gray-500 mb-2",children:"Supported export formats"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:[{ext:"CSV",icon:e.jsx(Me,{size:11})},{ext:"XML",icon:e.jsx(ze,{size:11})},{ext:"JSON",icon:e.jsx($e,{size:11})}].map(i=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-md bg-white/[0.06] border border-white/10 text-[11px] text-gray-200 font-medium",children:[i.icon,i.ext]},i.ext))})]}),e.jsxs("div",{className:"rounded-lg border border-white/5 bg-surface-2/50 p-3.5",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider font-semibold text-gray-500 mb-2",children:"What the AI does for you"}),e.jsxs("ul",{className:"text-[12px] text-gray-300 space-y-1 leading-relaxed",children:[e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx(G,{size:11,className:"text-emerald-400 mt-0.5 flex-shrink-0"})," Detects the source tool's format automatically"]}),e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx(G,{size:11,className:"text-emerald-400 mt-0.5 flex-shrink-0"})," Maps fields (title, priority, steps, preconditions, tags)"]}),e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx(G,{size:11,className:"text-emerald-400 mt-0.5 flex-shrink-0"})," Normalizes priority and type to Testver's schema"]}),e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx(G,{size:11,className:"text-emerald-400 mt-0.5 flex-shrink-0"})," Reports per-row errors so nothing is silently dropped"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("button",{onClick:o,className:"flex items-center gap-2 bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2.5 text-sm font-semibold transition-colors shadow-sm",children:[e.jsx(Ne,{size:14})," Import with AI Assistant"]}),e.jsxs("span",{className:"text-xs text-gray-500",children:["Opens the AI Assistant in ",e.jsx("span",{className:"text-brand-300 font-medium",children:"API mode"})," with a pre-filled import prompt. Upload your export file there."]})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-white/5 text-[11px] text-gray-500 leading-relaxed",children:[e.jsx("strong",{className:"text-gray-400 font-medium",children:"Tip:"})," the AI works best when columns/tags are clearly named in your export (e.g. ",e.jsx("em",{className:"not-italic text-gray-400",children:"Test Case Name"}),", ",e.jsx("em",{className:"not-italic text-gray-400",children:"Priority"}),", ",e.jsx("em",{className:"not-italic text-gray-400",children:"Steps"}),"). For very large exports (1000+ test cases), split the file into chunks of ~500 per upload for the smoothest run."]})]})}export{Rt as ImportExportPage};
@@ -0,0 +1 @@
1
+ import{r as a,j as e,b as K}from"./vendor-react-CTbHBddL.js";import{a as q}from"./vendor-query-BrzmPFT3.js";import{u as C,d as M,e as Q}from"./useJiraConnector-TM1Rfj1s.js";import{gF as _}from"./index-DtBWNlVD.js";import{aa as S,X as B,a3 as R,_ as X}from"./vendor-icons-B0wLOBoh.js";const P=100;function V({ids:l,className:n,label:x}){const{isConfigured:o}=C(),[d,i]=a.useState(!1);return!o||l.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>i(!0),title:"Create a Jira issue for each selected test case",className:n??"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-blue-300 border border-white/10 transition-colors",children:[e.jsx(S,{size:14}),x??"Push to Jira"]}),d&&e.jsx(A,{ids:l,onClose:()=>i(!1)})]})}function A({ids:l,onClose:n}){var w;const x=q(),{connectorId:o,connector:d}=C(),{data:i,isLoading:E}=M(o),{data:m}=Q(o),J=(i==null?void 0:i.projects)??[],c=a.useMemo(()=>{const s=[...new Set(((m==null?void 0:m.types)??[]).filter(u=>!u.subtask).map(u=>String(u.name)))];return s.length?s:["Task"]},[m]),[h,L]=a.useState(((w=d==null?void 0:d.config)==null?void 0:w.defaultProject)??""),[p,g]=a.useState(""),[f,T]=a.useState(!1),[b,z]=a.useState(!1),[t,j]=a.useState(!1),[y,k]=a.useState(null),[r,F]=a.useState(null);a.useEffect(()=>{f||c.length===0||g(c.find(s=>s.toLowerCase()==="test")??c.find(s=>s.toLowerCase()==="task")??c[0])},[c,f]),a.useEffect(()=>{const s=u=>{u.key==="Escape"&&!t&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[t,n]);const N=l.length>P;async function I(){j(!0),k(null);try{const s=await _({ids:l,projectKey:h,issueType:p,connectorId:o??void 0,force:b});F(s),x.invalidateQueries({queryKey:["tm-test-cases"]}),x.invalidateQueries({queryKey:["tm-test-case"]})}catch(s){k((s==null?void 0:s.message)||"Push failed")}finally{j(!1)}}const v="w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 focus:outline-none focus:ring-1 focus:ring-brand-500";return K.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",role:"dialog","aria-modal":"true","aria-labelledby":"jira-push-title",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:()=>{t||n()}}),e.jsxs("div",{className:"relative w-full max-w-lg rounded-xl bg-surface-1 border border-white/10 p-5 shadow-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("h3",{id:"jira-push-title",className:"text-base font-semibold text-gray-100",children:["Push ",l.length," test case",l.length===1?"":"s"," to Jira"]}),e.jsx("button",{onClick:n,disabled:t,"aria-label":"Close",className:"text-gray-500 hover:text-gray-300",children:e.jsx(B,{size:16})})]}),r?e.jsxs("div",{className:"mt-3 space-y-3 text-sm",role:"status",children:[e.jsxs("p",{className:"text-gray-300",children:[r.pushed.length," created",r.skipped.length>0&&e.jsxs(e.Fragment,{children:[", ",r.skipped.length," already in Jira (skipped)"]}),r.failed.length>0&&e.jsxs(e.Fragment,{children:[", ",e.jsxs("span",{className:"text-red-400",children:[r.failed.length," failed"]})]}),"."]}),e.jsxs("ul",{className:"max-h-64 overflow-auto space-y-1",children:[[...r.pushed.map(s=>({...s,note:""})),...r.skipped.map(s=>({...s,note:"already pushed"}))].map(s=>e.jsxs("li",{className:"flex items-center gap-2 text-xs",children:[e.jsxs("a",{href:s.url,target:"_blank",rel:"noreferrer",className:"text-blue-300 hover:underline inline-flex items-center gap-1 font-mono shrink-0",children:[s.key,e.jsx(X,{size:11})]}),e.jsx("span",{className:"text-gray-400 truncate",children:s.title}),s.note&&e.jsxs("span",{className:"text-gray-500 shrink-0",children:["· ",s.note]})]},s.id)),r.failed.map(s=>e.jsxs("li",{className:"text-xs text-red-400",children:[s.title||s.id,": ",s.error]},s.id))]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{onClick:n,className:"px-4 py-2 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium",children:"Done"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-gray-400 mt-2 leading-relaxed",children:"Each case becomes one issue: its title as the summary, and its preconditions, steps and requirements in the description. The issue is linked back on the case."}),N&&e.jsxs("p",{className:"text-sm text-amber-300 mt-2",children:["Push up to ",P," at a time — select fewer cases."]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-xs text-gray-500 mb-1",children:"Project"}),e.jsxs("select",{value:h,onChange:s=>L(s.target.value),className:v,disabled:t,children:[e.jsx("option",{value:"",children:E?"Loading…":"Select a project…"}),J.map(s=>e.jsxs("option",{value:s.key,children:[s.key," — ",s.name]},s.key))]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-xs text-gray-500 mb-1",children:"Issue type"}),e.jsx("select",{value:p,onChange:s=>{g(s.target.value),T(!0)},className:v,disabled:t,children:c.map(s=>e.jsx("option",{value:s,children:s},s))})]})]}),e.jsxs("label",{className:"flex items-center gap-2 mt-3 text-xs text-gray-400",children:[e.jsx("input",{type:"checkbox",checked:b,onChange:s=>z(s.target.checked),disabled:t}),"Push cases that were pushed before again (creates new issues)"]}),y&&e.jsx("p",{className:"text-sm text-red-400 mt-3",role:"alert",children:y}),e.jsxs("div",{className:"flex gap-2 justify-end mt-4",children:[e.jsx("button",{onClick:n,disabled:t,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:"Cancel"}),e.jsxs("button",{onClick:I,disabled:t||!h||!p||N,className:"flex items-center gap-1.5 px-4 py-2 text-sm rounded-lg bg-blue-600 hover:bg-blue-500 text-white font-medium disabled:opacity-50",children:[t?e.jsx(R,{size:14,className:"animate-spin"}):e.jsx(S,{size:14}),t?"Pushing…":"Create issues"]})]})]})]})]}),document.body)}export{V as J};
@@ -0,0 +1 @@
1
+ import{r as a,j as e,L as M}from"./vendor-react-CTbHBddL.js";import{u as R}from"./vendor-query-BrzmPFT3.js";import{gr as V,dE as z}from"./index-DtBWNlVD.js";import{a3 as j,aW as F,X as O,ae as S,ba as B,ad as q}from"./vendor-icons-B0wLOBoh.js";function D(t,s=!0){return R({queryKey:["run-live",t],queryFn:()=>V(t),enabled:!!t&&s,refetchInterval:d=>{const r=d.state.data;return r&&(r.status!=="running"||r.provider!=="testver-grid")?!1:3e3},staleTime:2e3,retry:!1})}const G=8,w=new Set,v=new Set;function $(t){return w.has(t)?!0:w.size>=G?!1:(w.add(t),v.forEach(s=>s()),!0)}function T(t){w.delete(t)&&v.forEach(s=>s())}function K(t){return v.add(t),()=>{v.delete(t)}}const A="testver.liveView";function k(){try{return localStorage.getItem(A)!=="off"}catch{return!0}}function P(t){try{localStorage.setItem(A,t?"on":"off")}catch{}v.forEach(s=>s())}const C={chromium:"bg-emerald-400",firefox:"bg-orange-400",webkit:"bg-sky-400"};function _(t){if(!t)return"";const s=Math.max(0,Math.round((Date.now()-Date.parse(t))/1e3));return s<60?`${s}s`:`${Math.floor(s/60)}m ${s%60}s`}function L({session:t,index:s,compact:d=!1,onEnlarge:r}){const n=a.useRef(null),[u,o]=a.useState(!1),[x,f]=a.useState(document.visibilityState==="visible"),[i,m]=a.useState(!1),[h,y]=a.useState(!1),[l,g]=a.useState(0);a.useEffect(()=>{const c=n.current;if(!c)return;const b=new IntersectionObserver(([E])=>o(!!(E!=null&&E.isIntersecting)),{threshold:.2});return b.observe(c),()=>b.disconnect()},[]),a.useEffect(()=>{const c=()=>f(document.visibilityState==="visible");return document.addEventListener("visibilitychange",c),()=>document.removeEventListener("visibilitychange",c)},[]);const N=u&&x&&t.liveAvailable&&!h;a.useEffect(()=>{if(!N){m(!1);return}const c=$(t.sessionId);return m(c),()=>{c&&T(t.sessionId)}},[N,t.sessionId]),a.useEffect(()=>{const c=setInterval(()=>g(b=>b+1),1e3);return()=>clearInterval(c)},[]);const p=N&&i;return e.jsxs("div",{ref:n,className:`rounded-lg border border-white/5 bg-black/40 overflow-hidden flex flex-col ${d?"":"min-h-[180px]"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 bg-surface-2/60 border-b border-white/5 text-[11px]",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${C[t.browser]||"bg-gray-400"}`}),e.jsx("span",{className:"text-gray-200 capitalize font-medium",children:t.browser}),e.jsxs("span",{className:"text-gray-500",children:["worker ",s+1]}),e.jsxs("span",{className:"text-gray-600",children:["· ",t.provider==="hetzner"?"box":t.provider==="fly"?"Fly":""]}),t.liveAvailable?e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-emerald-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"})," LIVE ",_(t.startedAt??t.createdAt)]}):e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-amber-400",children:[e.jsx(j,{size:10,className:"animate-spin"})," starting"]}),r&&t.liveAvailable&&e.jsx("button",{onClick:()=>r(t),title:"Enlarge",className:"w-5 h-5 inline-flex items-center justify-center rounded text-gray-500 hover:text-gray-200 hover:bg-white/10",children:e.jsx(F,{size:11})})]}),e.jsx("div",{className:`relative flex-1 aspect-video bg-black ${r&&p?"cursor-zoom-in":""}`,onClick:()=>{r&&p&&r(t)},title:r&&p?"Click to enlarge":void 0,children:p?e.jsx("img",{src:z(t.sessionId),alt:`Live ${t.browser} session`,className:"absolute inset-0 w-full h-full object-contain",onError:()=>y(!0)}):e.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-[11px] text-gray-500 px-3 text-center",children:h?"Live view is not available for this session — no display on the machine (evidence off), or an older image.":t.liveAvailable?x?i?"Scroll into view to watch":"Stream limit reached — close another live view to watch this one":"Paused while this tab is in the background":"Browser is starting…"})})]})}function I({session:t,onClose:s}){const[d,r]=a.useState(!1);return a.useEffect(()=>{const n=$(`${t.sessionId}:modal`);return()=>{n&&T(`${t.sessionId}:modal`)}},[t.sessionId]),a.useEffect(()=>{const n=u=>{u.key==="Escape"&&s()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[s]),e.jsx("div",{className:"fixed inset-0 z-50 bg-black/80 flex items-center justify-center p-6",onClick:s,children:e.jsxs("div",{className:"w-full max-w-5xl rounded-xl border border-white/10 bg-surface-1 overflow-hidden",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-white/5 text-sm",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${C[t.browser]||"bg-gray-400"}`}),e.jsx("span",{className:"text-gray-200 capitalize font-medium",children:t.browser}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-emerald-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"})," LIVE"]}),e.jsx("button",{onClick:s,className:"ml-auto w-7 h-7 inline-flex items-center justify-center rounded text-gray-400 hover:text-gray-100 hover:bg-white/10",title:"Close",children:e.jsx(O,{size:15})})]}),e.jsx("div",{className:"bg-black aspect-video",children:d?e.jsx("div",{className:"h-full flex items-center justify-center text-sm text-gray-500",children:"The session has ended — closing."}):e.jsx("img",{src:z(t.sessionId),alt:"Live session",className:"w-full h-full object-contain",onError:()=>{r(!0),setTimeout(s,1200)}})})]})})}function Q({runId:t,layout:s="inline",className:d=""}){const{data:r}=D(t),[n,u]=a.useState(k()),[o,x]=a.useState(null);if(a.useEffect(()=>K(()=>u(k())),[]),a.useEffect(()=>{o&&!(r!=null&&r.sessions.some(l=>l.sessionId===o.sessionId&&l.liveAvailable))&&x(null)},[r,o]),!t||!r||r.provider!=="testver-grid")return null;const f=r.sessions,i=f.filter(l=>l.liveAvailable),m=r.status!=="running",h=()=>{P(!n),u(!n)};if(s==="strip")return m?null:e.jsxs("div",{className:`px-4 pb-2.5 pl-11 ${d}`,children:[n?i.length===0?e.jsxs("div",{className:"text-[11px] text-amber-400/90 inline-flex items-center gap-1.5",children:[e.jsx(j,{size:11,className:"animate-spin"})," Starting a browser on Testver Grid…"]}):e.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${Math.min(i.length,3)}, minmax(0, 240px))`},children:i.slice(0,3).map((l,g)=>e.jsx(L,{session:l,index:g,compact:!0,onEnlarge:x},l.sessionId))}):e.jsxs("button",{onClick:h,className:"text-[11px] text-gray-500 hover:text-gray-300 inline-flex items-center gap-1",children:[e.jsx(S,{size:11})," Show live browser"]}),o&&e.jsx(I,{session:o,onClose:()=>x(null)})]});const y=s==="panel"?i.length>1?2:1:Math.min(Math.max(i.length,1),2);return e.jsxs("div",{className:`${s==="panel"?"h-full flex flex-col":"rounded-xl border border-white/5 bg-surface-1 mb-3 w-full max-w-[560px]"} ${d}`,children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-white/5 flex-shrink-0",children:[e.jsx(B,{size:14,className:"text-emerald-400"}),e.jsx("span",{className:"text-sm font-medium text-gray-200",children:"Testver Grid"}),r.browser&&e.jsx("span",{className:"text-xs text-gray-500 capitalize",children:r.browser}),m?e.jsx("span",{className:"text-xs text-gray-500",children:"· run finished"}):i.length>0?e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-emerald-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"})," ",i.length," live browser",i.length===1?"":"s"]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-amber-400",children:[e.jsx(j,{size:12,className:"animate-spin"})," starting a browser"]}),e.jsx("button",{onClick:h,title:n?"Hide live view (remembered)":"Show live view (remembered)",className:"ml-auto inline-flex items-center gap-1 text-[11px] text-gray-500 hover:text-gray-200",children:n?e.jsxs(e.Fragment,{children:[e.jsx(q,{size:12})," Hide"]}):e.jsxs(e.Fragment,{children:[e.jsx(S,{size:12})," Show live view"]})})]}),n&&e.jsxs("div",{className:`${s==="panel"?"flex-1 overflow-y-auto":""} p-3`,children:[m?e.jsxs("div",{className:"text-xs text-gray-500 px-1 py-2",children:["The browsers for this run have been released. "," ",e.jsx(M,{to:`/results?runId=${encodeURIComponent(t)}`,className:"text-cyan-400 hover:text-cyan-300",children:"Video and command log are in Results."})]}):i.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-white/10 aspect-video flex flex-col items-center justify-center gap-2 text-center px-6",children:[e.jsx(j,{size:18,className:"text-amber-400 animate-spin"}),e.jsx("div",{className:"text-sm text-gray-300",children:"Starting a browser on Testver Grid"}),e.jsx("div",{className:"text-[11px] text-gray-500",children:"About 5 seconds on a ready machine, up to 40 seconds when a fresh one has to boot. The stream appears here the moment the browser is up."})]}):e.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:`repeat(${y}, minmax(0, 1fr))`},children:i.map((l,g)=>e.jsx(L,{session:l,index:g,onEnlarge:x},l.sessionId))}),!m&&f.length>i.length&&e.jsxs("div",{className:"mt-2 text-[11px] text-gray-500",children:[f.length-i.length," more worker",f.length-i.length===1?"":"s"," starting…"]})]}),o&&e.jsx(I,{session:o,onClose:()=>x(null)})]})}export{Q as L};
@@ -0,0 +1 @@
1
+ import{e as a,j as s,l as t}from"./vendor-react-CTbHBddL.js";function n(){const[r]=a(),e=r.get("tab");return e==="cicd"||e==="pipelines"?s.jsx(t,{to:"/pipelines",replace:!0}):e==="browser-sessions"?s.jsx(t,{to:"/settings?tab=browser-sessions",replace:!0}):s.jsx(t,{to:"/settings?tab=config",replace:!0})}export{n as ManagePage};
@@ -0,0 +1 @@
1
+ import{r as x,b as m,j as e}from"./vendor-react-CTbHBddL.js";import{X as p}from"./vendor-icons-B0wLOBoh.js";function b({title:s,subtitle:o,icon:d,toolbar:i,footer:a,onClose:r,children:l}){return x.useEffect(()=>{const t=c=>{c.key==="Escape"&&r()};window.addEventListener("keydown",t);const n=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",t),document.body.style.overflow=n}},[r]),m.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-3 sm:p-5",onClick:r,children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":s,className:"flex h-[92vh] w-[min(96vw,1680px)] flex-col overflow-hidden rounded-xl border border-white/10 bg-surface-1 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-white/5 px-4 py-2.5",children:[d,e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-200",title:s,children:s}),o&&e.jsx("p",{className:"truncate text-[11px] text-gray-500",children:o})]}),i,e.jsx("button",{onClick:r,title:"Close (Esc)","aria-label":"Close",className:"ml-1 rounded-lg p-1.5 text-gray-500 transition-colors hover:bg-white/10 hover:text-gray-200",children:e.jsx(p,{size:18})})]}),e.jsx("div",{className:"relative min-h-0 flex-1",children:l}),a&&e.jsx("div",{className:"border-t border-white/5 px-4 py-1.5 text-[11px] text-gray-500",children:a})]})}),document.body)}export{b as M};
@@ -0,0 +1 @@
1
+ import{r as o,j as t}from"./vendor-react-CTbHBddL.js";import{y as P,z as S,A as I}from"./index-DtBWNlVD.js";import{M as E}from"./MobileRunTarget-D2Nqcj10.js";import{J as N,a0 as C}from"./vendor-icons-B0wLOBoh.js";const L={browserstack:"BrowserStack",saucelabs:"Sauce Labs",lambdatest:"LambdaTest","local-appium":"Local Devices"};function $({disabled:p,initial:e,compact:u=!1,onChange:y}){const[c,x]=o.useState([]),[l,f]=o.useState(!1),[s,n]=o.useState((e==null?void 0:e.cloudProvider)||""),[a,j]=o.useState({deviceName:(e==null?void 0:e.deviceName)||"",platformName:(e==null?void 0:e.platformName)==="iOS"?"iOS":"Android",platformVersion:(e==null?void 0:e.platformVersion)||"",appId:(e==null?void 0:e.appId)||"",appPath:(e==null?void 0:e.appPath)||""}),[h,g]=o.useState();o.useEffect(()=>{P().then(r=>x(r.providers.filter(d=>d.enabled&&d.id!=="testver-grid"))).catch(()=>x([])),S().then(({config:r})=>f(!!r.enabled)).catch(()=>f(!1))},[]),o.useEffect(()=>{s||(l?n("local-appium"):c.length>0&&n(c[0].id))},[l,c,s]),o.useEffect(()=>{if(!s){g(void 0);return}let r=!1;const d=()=>{I().then(w=>{if(r)return;const m=w.ticket;g(m&&!m.claimed&&Date.now()<m.expiresAt?m.sessionId:void 0)}).catch(()=>{})};d();const k=window.setInterval(d,5e3);return()=>{r=!0,window.clearInterval(k)}},[s]);const b=c.length===0&&!l;if(o.useEffect(()=>{const r=!!s&&!!a.deviceName&&(!!a.appId||!!a.appPath.trim()),d=s?{cloudProvider:s,deviceName:a.deviceName,platformName:a.platformName,platformVersion:a.platformVersion,appId:a.appId,appPath:a.appPath,reuseSessionId:h}:null;y({payload:d,active:!!s,blocked:b,ready:r})},[s,a,h,b]),b)return t.jsxs("div",{className:"mt-3 flex items-start gap-2.5 px-3.5 py-3 rounded-xl border border-amber-500/25 bg-amber-500/10 text-sm text-amber-700 dark:text-amber-200",children:[t.jsx(N,{size:15,className:"mt-0.5 flex-shrink-0 text-amber-600 dark:text-amber-300"}),t.jsxs("span",{children:["No device target available. To run this test, connect a local device or enable a cloud device grid in ",t.jsx("span",{className:"font-semibold",children:"Connectors"}),"."]})]});const v=u?"flex items-center gap-1 px-2.5 py-1 text-xs rounded-lg border transition-colors":"flex items-center gap-1.5 px-2.5 h-8 text-xs rounded-lg border transition-colors",i=12;return t.jsxs("div",{className:u?"space-y-2":"mt-3 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:`${u?"text-xs":"text-sm"} text-gray-400`,children:"Run on:"}),t.jsxs("div",{className:"flex gap-1.5 flex-wrap",children:[c.map(r=>t.jsxs("button",{onClick:()=>n(r.id),disabled:p,className:`${v} ${s===r.id?"border-blue-500/50 bg-blue-500/10 text-blue-300 font-medium":"border-white/5 bg-surface-2 text-gray-400 hover:text-gray-300 hover:border-white/10"} disabled:opacity-50`,children:[t.jsx(C,{size:i}),L[r.id]||r.id]},r.id)),l&&t.jsxs("button",{onClick:()=>n("local-appium"),disabled:p,className:`${v} ${s==="local-appium"?"border-gray-300 dark:border-white/25 bg-gray-100/70 dark:bg-white/[0.08] text-gray-800 dark:text-gray-100 font-medium":"border-white/5 bg-surface-2 text-gray-400 hover:text-gray-300 hover:border-white/10"} disabled:opacity-50`,children:[t.jsx(N,{size:i}),"Local Devices"]})]})]}),s&&t.jsx(E,{providerId:s,disabled:p,value:a,onChange:j})]})}export{$ as M};
@@ -0,0 +1,6 @@
1
+ import{r as i,j as e}from"./vendor-react-CTbHBddL.js";import{T as O,bz as _,bA as V,U as B,S as E,X as H}from"./index-DtBWNlVD.js";import{J as M,_ as K,a3 as U,dg as X,y as J,ak as W,be as Y}from"./vendor-icons-B0wLOBoh.js";import{a as z}from"./formatDate-T65-Y6Mi.js";import{S as q,L as G}from"./SearchableDevicePicker-CFJ_DUAA.js";const P=1e3;function ae({testRunning:c,hideHeader:j=!1}){const[s,h]=i.useState(null),[x,A]=i.useState(null),[v,m]=i.useState(null),[N,w]=i.useState(null),[b,k]=i.useState(!1),[g,f]=i.useState(P),y=i.useRef(null),o=i.useRef(0),d=i.useRef(c);i.useEffect(()=>{d.current=c},[c]),i.useEffect(()=>{let l=!1;return O().then(p=>{l||h(p.session)}).catch(()=>{}),()=>{l=!0}},[]),i.useEffect(()=>{let l=!1;const p=async()=>{if(!l)try{const r=await _({timeoutMs:15e3,since:o.current||void 0});!l&&r.unchanged?m(null):l||(o.current=r.capturedAt||0,A(r.image),m(null),k(!!r.delayed),r.dashboardUrl&&w(r.dashboardUrl),f(d.current?500:P))}catch(r){!l&&V(r)?(m(null),f(P)):l||(m(r.message),f(Math.min(g*2,d.current?4e3:1e4)))}finally{l||(y.current=window.setTimeout(p,g))}};return p(),()=>{l=!0,y.current&&window.clearTimeout(y.current)}},[]);const S=!s;return e.jsxs("div",{className:"h-full flex flex-col bg-surface-1",children:[!j&&e.jsxs("div",{className:"px-3 py-2 border-b border-white/5 flex items-center gap-2",children:[e.jsx(M,{size:13,className:"text-indigo-300"}),e.jsx("span",{className:"text-xs font-medium text-gray-200",children:c?"Live Device — Execution view":"Live Device"}),s&&e.jsx("span",{className:"text-[10px] text-gray-500 truncate",children:s.device}),b&&x&&e.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400/80 border border-amber-500/20 flex-shrink-0",title:"Cloud preview frames are captured between test commands and are a few seconds behind the device. Use the provider link for their real-time view.",children:"~few sec behind"}),e.jsx("div",{className:"flex-1"}),((s==null?void 0:s.dashboardUrl)||N)&&e.jsxs("a",{href:(s==null?void 0:s.dashboardUrl)||N,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-indigo-300 hover:text-indigo-200",title:"Open the cloud provider's session view — their stream is real-time",children:["Live on provider ",e.jsx(K,{size:9})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden relative flex items-center justify-center bg-black/40",children:S&&!c?e.jsxs("div",{className:"text-center px-4 py-8",children:[e.jsx(M,{size:28,className:"text-gray-600 mx-auto mb-2"}),e.jsx("p",{className:"text-xs text-gray-400",children:"No active mobile session"}),e.jsx("p",{className:"text-[10px] text-gray-600 mt-1",children:"Click Run to start a test (a device session opens automatically), or connect a device in AI Assistant."}),v&&e.jsx("p",{className:"text-[10px] text-red-400 mt-2",children:v})]}):x?e.jsx("img",{src:`data:image/png;base64,${x}`,alt:"Live device",className:"max-h-full max-w-full object-contain",style:c?{filter:"saturate(0.85) brightness(0.95)"}:void 0}):e.jsxs("div",{className:"flex flex-col items-center gap-2 text-xs text-gray-500 px-4 py-8 text-center",children:[e.jsx(U,{size:14,className:"animate-spin"}),e.jsx("span",{children:"Waiting for the test's device session…"}),e.jsx("span",{className:"text-[10px] text-gray-600",children:"First frame appears within a few seconds of session creation."})]})})]})}function ie({providerId:c,disabled:j,value:s,onChange:h}){const[x,A]=i.useState([]),[v,m]=i.useState(!1),[N,w]=i.useState(null),[b,k]=i.useState([]),[g,f]=i.useState(null),[y,o]=i.useState(!1),[d,S]=i.useState(!1),[l,p]=i.useState(null),r=i.useRef(null);i.useEffect(()=>{let t=!1;return m(!0),w(null),B(c).then(a=>{t||A(a.devices||[])}).catch(a=>{t||w(a.message)}).finally(()=>{t||m(!1)}),()=>{t=!0}},[c]),i.useEffect(()=>{let t=!1;return E().then(a=>{t||k(a.apps||[])}).catch(a=>{t||f(a.message)}),()=>{t=!0}},[]);const $=i.useMemo(()=>{if(!s.deviceName)return"";const t=x.find(a=>(a.rawDeviceKey===s.deviceName||a.name===s.deviceName)&&a.os===s.platformVersion);return t?t.id:""},[x,s.deviceName,s.platformVersion]),n=i.useMemo(()=>b.find(t=>t.id===s.appId)??null,[b,s.appId]),L=n?n.label||n.filename:s.appPath.trim()?s.appPath.trim():"Pick app or upload…",D=(()=>{if(n){const t=(n.size/1048576).toFixed(1),a=n.kind==="ipa"?"iOS":"Android",u=n.uploadedAt?z(n.uploadedAt):"";return[n.label||n.filename,n.filename,`${a} · ${t} MB${u?` · uploaded ${u}`:""}`].join(`
2
+ `)}return s.appPath.trim()?s.appPath.trim():"Pick app or upload…"})(),C=t=>{h({...s,deviceName:c==="local-appium"?t.rawDeviceKey:t.name,platformName:t.platform==="ios"?"iOS":"Android",platformVersion:t.os})},I=t=>{h({...s,appId:t.id,appPath:""}),o(!1)},R=()=>{h({...s,appId:"",appPath:""}),o(!1)},T=async t=>{S(!0),f(null),p(0);try{const a=await H(t,void 0,F=>p(F)),u=await E();k(u.apps||[]),h({...s,appId:a.id,appPath:""}),o(!1)}catch(a){f(a.message)}finally{S(!1),p(null),r.current&&(r.current.value="")}};return e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap max-w-full min-w-0",children:[e.jsx("span",{title:"Mobile device target",className:"flex-shrink-0",children:e.jsx(M,{size:13,className:"text-indigo-400 dark:text-indigo-300"})}),e.jsx("div",{className:"flex-1 min-w-[13rem]",children:e.jsx(q,{devices:x,selectedId:$,onSelect:C,loading:v,disabled:j,errorText:N,placeholder:"Select a device…",emptyText:c==="local-appium"?G:void 0,variant:"compact"})}),e.jsxs("div",{className:"relative flex-1 min-w-[13rem]",children:[e.jsxs("button",{type:"button",disabled:j||d,onClick:()=>o(!y),title:`${D?D+`
3
+
4
+ `:""}Shared app library — apps uploaded in AI Assistant / AI Record appear here. Uploads are cached by SHA-256, so repeat runs skip re-upload.`,className:"w-full h-8 flex items-center justify-between gap-1.5 px-2.5 text-xs rounded-lg bg-white dark:bg-white/[0.04] border border-gray-200 dark:border-white/10 text-gray-800 dark:text-gray-200 hover:border-gray-300 dark:hover:border-white/20 transition-colors disabled:opacity-50",children:[e.jsxs("span",{className:"flex items-center gap-1.5 truncate min-w-0",children:[e.jsx(X,{size:11,className:`flex-shrink-0 ${n?"text-indigo-500 dark:text-indigo-300":"text-gray-500"}`}),e.jsx("span",{className:`truncate ${n||s.appPath.trim()?"":"text-gray-500"}`,children:d?`Uploading… ${l!==null?Math.round(l*100)+"%":""}`:L})]}),d?e.jsx(U,{size:11,className:"animate-spin flex-shrink-0 text-gray-500"}):e.jsx(J,{size:11,className:"flex-shrink-0 text-gray-500"})]}),y&&!d&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>o(!1)}),e.jsxs("div",{className:"absolute top-full left-0 mt-1 w-full max-h-72 bg-surface-1 border border-white/10 rounded-lg shadow-xl z-40 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[g&&e.jsx("div",{className:"px-3 py-2 text-xs text-red-300",children:g}),!g&&b.length===0&&e.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No apps in the library yet — upload an .apk or .ipa below."}),b.map(t=>{const a=t.id===s.appId;return e.jsxs("button",{onClick:()=>I(t),title:`${t.label||t.filename}
5
+ ${t.filename}
6
+ ${t.kind==="ipa"?"iOS":"Android"} · ${(t.size/1024/1024).toFixed(1)} MB${t.uploadedAt?` · uploaded ${z(t.uploadedAt)}`:""}`,className:`w-full flex items-center justify-between gap-2 px-3 py-1.5 text-xs transition-colors ${a?"bg-indigo-500/15 text-indigo-200":"text-gray-300 hover:bg-white/5"}`,children:[e.jsxs("span",{className:"flex items-center gap-1.5 truncate",children:[a&&e.jsx(W,{size:11,className:"text-indigo-300 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:t.label||t.filename})]}),e.jsxs("span",{className:"text-[10px] text-gray-500 flex-shrink-0",children:[t.kind," · ",(t.size/1024/1024).toFixed(1)," MB"]})]},t.id)}),s.appId&&e.jsx("button",{onClick:R,className:"w-full text-left px-3 py-1.5 text-xs text-gray-500 hover:bg-white/5 border-t border-white/5",children:"Clear selection"})]}),e.jsxs("div",{className:"border-t border-white/10 px-2 py-1.5 bg-surface-1/50",children:[e.jsxs("button",{type:"button",onClick:t=>{var a;t.stopPropagation(),(a=r.current)==null||a.click()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-[11px] rounded-md bg-indigo-500/10 text-indigo-300 hover:bg-indigo-500/20 transition-colors",children:[e.jsx(Y,{size:11})," ",e.jsx("span",{title:"Android: .apk or .aab · real iPhone / iPad: .ipa · iOS simulator: the .app zipped",children:"Upload app build"})]}),e.jsx("p",{className:"mt-1.5 px-1 text-[10px] text-gray-500 leading-relaxed",children:"Shared with AI Assistant + AI Record — apps uploaded there appear here. Uploads are cached by SHA-256, so repeat runs skip re-upload."})]})]})]})]}),e.jsx("input",{ref:r,type:"file",accept:".apk,.aab,.ipa,.zip,application/vnd.android.package-archive,application/zip,application/octet-stream",className:"hidden",onChange:t=>{var u;const a=(u=t.target.files)==null?void 0:u[0];a&&T(a)}})]})}export{ie as M,ae as R};