@opentig/cli 0.1.7 → 0.1.8

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 (114) hide show
  1. package/dist/bin.mjs +1 -4
  2. package/dist/chunks/{cli-DCPhUVBb.mjs → cli-BgNif2D1.mjs} +1 -1
  3. package/dist/client/assets/App-9EfSdZB8.js +74 -0
  4. package/dist/client/assets/CreatePullRequestDialog-BgVrWdkH.js +2 -0
  5. package/dist/client/assets/DiffWorkspace-Ca2ZUlVn.js +26 -0
  6. package/dist/client/assets/EditableFileViewer-85aEeMBK.js +1 -0
  7. package/dist/client/assets/File-DTtWrbYf.js +1 -0
  8. package/dist/client/assets/{FilesView-BUAz46Qa.js → FilesView-rT5hzb7y.js} +1 -1
  9. package/dist/client/assets/{GitHubAvatar-Depnd_JA.js → GitHubAvatar-EO1TD_1z.js} +1 -1
  10. package/dist/client/assets/{HistoryView-Dd4Kr4KN.js → HistoryView-C4c0CqMC.js} +1 -1
  11. package/dist/client/assets/{HtmlFileViewer-C3Qylr9B.js → HtmlFileViewer-bL6T57PQ.js} +1 -1
  12. package/dist/client/assets/{IconEdit-BHqlqze_.js → IconEdit-DePJMGIi.js} +1 -1
  13. package/dist/client/assets/{IconFolderPlus-BJIo1hfe.js → IconFolderPlus-ByGyA0Di.js} +1 -1
  14. package/dist/client/assets/{ImageFileViewer-BJy0ptmR.js → ImageFileViewer-DJaHH3hJ.js} +1 -1
  15. package/dist/client/assets/{LocalRefsDialog-C1MWMkv1.js → LocalRefsDialog-D9wYZWBg.js} +1 -1
  16. package/dist/client/assets/MarkdownFileViewer-BNPb9v8u.js +2 -0
  17. package/dist/client/assets/{PairingPage-DOPAXy3a.js → PairingPage-D9oguvKU.js} +1 -1
  18. package/dist/client/assets/PierreDiffViewer-8wTLYd5-.js +1 -0
  19. package/dist/client/assets/{PierreEditBoundary-mxtF7x3F.js → PierreEditBoundary-KzU3HDc2.js} +2 -2
  20. package/dist/client/assets/{PierreWorkerPool-B_NFnwU-.js → PierreWorkerPool-DH2jp9oe.js} +18 -18
  21. package/dist/client/assets/{PullRequestDiff-Bcu8Gmrf.js → PullRequestDiff-DK-m07ZP.js} +1 -1
  22. package/dist/client/assets/{PullRequestViewer-oeDoq-3g.js → PullRequestViewer-CpLwq4o2.js} +2 -2
  23. package/dist/client/assets/{PullRequestsView-DpTtagTX.js → PullRequestsView-DnvXaJ4t.js} +1 -1
  24. package/dist/client/assets/{QuickOpenDialog-rjeV0l_J.js → QuickOpenDialog-DIWjfUkt.js} +1 -1
  25. package/dist/client/assets/RepositoryProjectsDialog-BsQn5Yjr.js +1 -0
  26. package/dist/client/assets/{SearchView-C-c6oCil.js → SearchView-D-91dtSv.js} +1 -1
  27. package/dist/client/assets/SettingsDialog-dJUYk2cP.js +9 -0
  28. package/dist/client/assets/{Viewer-B6qUr83C.js → Viewer-GH-5bJW4.js} +2 -2
  29. package/dist/client/assets/{abnfDiagram-N423BO3Z-BxGW6tGd.js → abnfDiagram-N423BO3Z-CkHOGdAl.js} +1 -1
  30. package/dist/client/assets/{arc-CphVLv_F.js → arc-Dj8F8CO5.js} +1 -1
  31. package/dist/client/assets/{architectureDiagram-T3A2C74G-D9IDzZ6u.js → architectureDiagram-T3A2C74G-g87Y5LXk.js} +1 -1
  32. package/dist/client/assets/{blockDiagram-VBNYF7ZC-CzCatff9.js → blockDiagram-VBNYF7ZC-D6efB7jD.js} +1 -1
  33. package/dist/client/assets/{c4Diagram-5PPSVZJV-jvC7ACDE.js → c4Diagram-5PPSVZJV-DoZEC2xg.js} +1 -1
  34. package/dist/client/assets/channel-Dsy2VD23.js +1 -0
  35. package/dist/client/assets/{checkbox-DDpujnre.js → checkbox-DYwmgDPS.js} +1 -1
  36. package/dist/client/assets/{chunk-2GRJ4B5K-CNRn3w2y.js → chunk-2GRJ4B5K-Dr44hDNV.js} +1 -1
  37. package/dist/client/assets/{chunk-2Q5K7J3B-CnTjXDS8.js → chunk-2Q5K7J3B-YIEyVOOL.js} +1 -1
  38. package/dist/client/assets/{chunk-5RXB4S5H-8QZZSU3J.js → chunk-5RXB4S5H-gjmGBtkE.js} +1 -1
  39. package/dist/client/assets/{chunk-5VM5RSS4-B2MFN1L0.js → chunk-5VM5RSS4-DCOQko4g.js} +1 -1
  40. package/dist/client/assets/{chunk-6Q2QTUOP-BRGuFKSr.js → chunk-6Q2QTUOP-DfGlvPVm.js} +1 -1
  41. package/dist/client/assets/{chunk-GF5L2VYU-CWTKyD7U.js → chunk-GF5L2VYU-CCWOLPVL.js} +1 -1
  42. package/dist/client/assets/{chunk-JWPE2WC7-rGurufZY.js → chunk-JWPE2WC7-CFRTGh8r.js} +1 -1
  43. package/dist/client/assets/{chunk-KBJHAD2P-DOwIHyo0.js → chunk-KBJHAD2P-By3wsJVD.js} +1 -1
  44. package/dist/client/assets/{chunk-RYQCIY6F-qrVd0AV3.js → chunk-RYQCIY6F-C0wmsHmy.js} +1 -1
  45. package/dist/client/assets/{chunk-XXDRQBXY-BGvaybJK.js → chunk-XXDRQBXY-t3SnJvV_.js} +1 -1
  46. package/dist/client/assets/classDiagram-JCYQIIEL-BBQJgoWd.js +1 -0
  47. package/dist/client/assets/classDiagram-v2-OCEON4UE-BBQJgoWd.js +1 -0
  48. package/dist/client/assets/{vb-D17OF-Vu.js → cmd-BW5THilD.js} +1 -1
  49. package/dist/client/assets/{cose-bilkent-JH36ORCC-CHgOt-vq.js → cose-bilkent-JH36ORCC-D3VltoVk.js} +1 -1
  50. package/dist/client/assets/{cynefin-VYW2F7L2-DX7Kb3Ft.js → cynefin-VYW2F7L2-DwLwbeoe.js} +1 -1
  51. package/dist/client/assets/{cynefinDiagram-MW4NZA55-B4MgYgbV.js → cynefinDiagram-MW4NZA55-B23kuaQF.js} +1 -1
  52. package/dist/client/assets/{dagre-VZM6K2ZE-xG9l95NU.js → dagre-VZM6K2ZE-SgMrTr2p.js} +1 -1
  53. package/dist/client/assets/{diagram-7IWD3JNH-BQKb8ivh.js → diagram-7IWD3JNH-C7cQN4aD.js} +1 -1
  54. package/dist/client/assets/{diagram-B4RE2ZJO-CyIMrtDr.js → diagram-B4RE2ZJO-CzeI3yOw.js} +1 -1
  55. package/dist/client/assets/{diagram-LBJQPF4R-WuCMu4WW.js → diagram-LBJQPF4R-DhKm4hlI.js} +1 -1
  56. package/dist/client/assets/{diagram-Q27KOJAE--Oi1nRrR.js → diagram-Q27KOJAE-BXlU6Wp3.js} +1 -1
  57. package/dist/client/assets/{diagram-UB23O5K3-CP1DXsa_.js → diagram-UB23O5K3-BOwY_YwR.js} +1 -1
  58. package/dist/client/assets/{ebnfDiagram-BXEA7PRR-C-7jJg9C.js → ebnfDiagram-BXEA7PRR-CuIQuYPa.js} +1 -1
  59. package/dist/client/assets/{erDiagram-JOGREHBK-FSyqgO_9.js → erDiagram-JOGREHBK-d45NhKfk.js} +1 -1
  60. package/dist/client/assets/{flowDiagram-UKHOOZJN-y2e2HZHu.js → flowDiagram-UKHOOZJN-Dzq-6qo7.js} +1 -1
  61. package/dist/client/assets/{ganttDiagram-PKOTCBZU-kZ3m3wwW.js → ganttDiagram-PKOTCBZU-RVlL9mX2.js} +1 -1
  62. package/dist/client/assets/{gh-utils-DxPHIkD8.js → gh-utils-LsOSydCg.js} +1 -1
  63. package/dist/client/assets/{gitGraphDiagram-DS77QQ5N-3Z9e4WPi.js → gitGraphDiagram-DS77QQ5N-8kEJVUFH.js} +1 -1
  64. package/dist/client/assets/{index-DDbUjVD9.js → index-BzmFkR37.js} +1 -1
  65. package/dist/client/assets/{index-ChKJF4C_.js → index-CQcx9aRt.js} +4 -4
  66. package/dist/client/assets/index-DMbFAH51.css +1 -0
  67. package/dist/client/assets/{infoDiagram-6WML65LV-TfCo0Rhw.js → infoDiagram-6WML65LV-Co21Ql9M.js} +1 -1
  68. package/dist/client/assets/{ishikawaDiagram-WSZJBQD7-DaXI89rw.js → ishikawaDiagram-WSZJBQD7-BvPB_G97.js} +1 -1
  69. package/dist/client/assets/{journeyDiagram-NVQOT4AX-C4jS6BVn.js → journeyDiagram-NVQOT4AX-k7x89IE9.js} +1 -1
  70. package/dist/client/assets/{kanban-definition-27J2QSJJ-bwOtQiC8.js → kanban-definition-27J2QSJJ-BjrgN30t.js} +1 -1
  71. package/dist/client/assets/{linear-DfZM9J6Z.js → linear-m158kske.js} +1 -1
  72. package/dist/client/assets/{mermaid.core-B-iLnCqi.js → mermaid.core-C0FKucv-.js} +4 -4
  73. package/dist/client/assets/{mindmap-definition-FAOFIHXS-DAdKdypB.js → mindmap-definition-FAOFIHXS-CF8noycK.js} +1 -1
  74. package/dist/client/assets/{pegDiagram-VL7TDLO6-Bl95_ELH.js → pegDiagram-VL7TDLO6-_y7nfJFV.js} +1 -1
  75. package/dist/client/assets/{pieDiagram-7S7Q4E2Y-DXf4GTLI.js → pieDiagram-7S7Q4E2Y-DhdWHi45.js} +1 -1
  76. package/dist/client/assets/{platform-BMNQ8V5r.js → platform-Bqt97_Jr.js} +2 -2
  77. package/dist/client/assets/{quadrantDiagram-CIZ2JOQS-CDiwouFY.js → quadrantDiagram-CIZ2JOQS-BRvEIECQ.js} +1 -1
  78. package/dist/client/assets/{railroadDiagram-AXF67PYL-CZAR7rja.js → railroadDiagram-AXF67PYL-BgLZ8XU1.js} +1 -1
  79. package/dist/client/assets/render-markdown-2GjhuGA-.js +280 -0
  80. package/dist/client/assets/repository-grammars-ixqpb0uW.js +1 -0
  81. package/dist/client/assets/{requirementDiagram-LRYGKXZP-BklWtcnl.js → requirementDiagram-LRYGKXZP-CX-gxyGF.js} +1 -1
  82. package/dist/client/assets/{sankeyDiagram-W5VNT64P-CpD7cM5j.js → sankeyDiagram-W5VNT64P-CLSjSU_X.js} +1 -1
  83. package/dist/client/assets/{sequenceDiagram-SI44F4Z6-BnHPNl9l.js → sequenceDiagram-SI44F4Z6-dGlHyZRB.js} +1 -1
  84. package/dist/client/assets/{sizeCapture-X5ZJPWSS-D1eo0r-2.js → sizeCapture-X5ZJPWSS-BH3qO9T3.js} +1 -1
  85. package/dist/client/assets/{stateDiagram-OKZ733FA-ClTacl-d.js → stateDiagram-OKZ733FA-FXxo1iIM.js} +1 -1
  86. package/dist/client/assets/{stateDiagram-v2-UEYNNEHI-DAo7Tfh9.js → stateDiagram-v2-UEYNNEHI-DqxQ14yP.js} +1 -1
  87. package/dist/client/assets/{swimlanes-SLNWSIFB-_PLbkM5u.js → swimlanes-SLNWSIFB-VJGIuM4S.js} +2 -2
  88. package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-No0dCAkd.js +8 -0
  89. package/dist/client/assets/{timeline-definition-Z64GVDOM-C9U6VikV.js → timeline-definition-Z64GVDOM-BXNTAanY.js} +1 -1
  90. package/dist/client/assets/{vennDiagram-T6HMQDX7-Desj7KFU.js → vennDiagram-T6HMQDX7-D9nXAts5.js} +1 -1
  91. package/dist/client/assets/{viewer-tabs-BwMhis6Q.js → viewer-tabs-DkLmDzFg.js} +1 -1
  92. package/dist/client/assets/{wardleyDiagram-T6FBY63Y-rlMEd5tV.js → wardleyDiagram-T6FBY63Y-D89EaEfa.js} +1 -1
  93. package/dist/client/assets/{xychartDiagram-ELKLHX3M-CzFgA0NM.js → xychartDiagram-ELKLHX3M-B_xFDiIh.js} +1 -1
  94. package/dist/client/index.html +2 -2
  95. package/dist/dev.mjs +1 -4
  96. package/dist/manifest.json +1 -1
  97. package/dist/server.mjs +295 -2351
  98. package/dist/utility.mjs +0 -3
  99. package/package.json +1 -1
  100. package/dist/client/assets/App-CGiS2z40.js +0 -74
  101. package/dist/client/assets/CreatePullRequestDialog-dNbTTo9i.js +0 -2
  102. package/dist/client/assets/DiffWorkspace-XS025gbZ.js +0 -26
  103. package/dist/client/assets/EditableFileViewer-Cve4V9RS.js +0 -1
  104. package/dist/client/assets/File-BJuBDans.js +0 -1
  105. package/dist/client/assets/MarkdownFileViewer-pagMxv2y.js +0 -2
  106. package/dist/client/assets/PierreDiffViewer-FmgbHdls.js +0 -1
  107. package/dist/client/assets/RepositoryProjectsDialog-QYXEt7Lg.js +0 -1
  108. package/dist/client/assets/SettingsDialog-DHmWkKYV.js +0 -9
  109. package/dist/client/assets/channel-BGbncBYv.js +0 -1
  110. package/dist/client/assets/classDiagram-JCYQIIEL-BoYriqPM.js +0 -1
  111. package/dist/client/assets/classDiagram-v2-OCEON4UE-BoYriqPM.js +0 -1
  112. package/dist/client/assets/index-WwGOu_aM.css +0 -1
  113. package/dist/client/assets/render-markdown-BiKX2Zdv.js +0 -280
  114. package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-DHeOpgR_.js +0 -8
@@ -1 +1 @@
1
- import{r as d,j as e}from"./react-rd22PHbN.js";import{u as S}from"./tanstack-CtfgE41X.js";import{q as b,B as m,T,a as q,b as w,o as D}from"./index-ChKJF4C_.js";import{S as P,A as E,C as R,E as $,F as z,l as H,k as B,G as I}from"./App-CGiS2z40.js";import{D as K}from"./DiffWorkspace-XS025gbZ.js";import{P as L}from"./PierreWorkerPool-B_NFnwU-.js";import"./base-ui-DT3JsyND.js";import"./platform-BMNQ8V5r.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./EditContext-CvJWfVl1.js";import"./index-CtEztN1P.js";function Z({diff:n,prNumber:r,repositoryId:u,commits:l,diffView:g,themeType:j,wrapLines:v,onDiffViewChange:y,onWrapLinesChange:C,onClose:N}){const[o,p]=d.useState("all"),[x,k]=d.useState(l[0]?.oid??""),i=d.useMemo(()=>l.find(s=>s.oid===x)??l[0]??null,[l,x]),a=S({queryKey:b.pullRequestCommitDiff(u,i?.oid??""),queryFn:()=>D.github.getPullRequestCommitDiff(u,i.oid),enabled:o==="commit"&&i!==null}),h=a.error instanceof Error?a.error.message:a.error?"Could not load the commit diff.":null,t=e.jsxs("div",{className:"pr-code-scope",children:[e.jsxs("div",{className:"pr-code-mode",role:"group","aria-label":"Pull request code grouping",children:[e.jsx(m,{type:"button",variant:o==="all"?"secondary":"ghost",size:"xs","aria-pressed":o==="all",onClick:()=>p("all"),children:"All changes"}),e.jsx(m,{type:"button",variant:o==="commit"?"secondary":"ghost",size:"xs","aria-pressed":o==="commit",disabled:l.length===0,onClick:()=>p("commit"),children:"By commit"})]}),o==="commit"&&i&&e.jsxs(P,{value:i.oid,onValueChange:s=>{s&&k(s)},children:[e.jsxs(T,{children:[e.jsx(q,{render:e.jsx(R,{className:"pr-commit-select",size:"sm","aria-label":"Commit"}),children:e.jsxs(E,{children:[i.oid.slice(0,7)," · ",i.messageHeadline||"(no commit message)"]})}),e.jsxs(w,{children:[i.oid.slice(0,7)," · ",i.messageHeadline||"(no commit message)"]})]}),e.jsx($,{align:"start",alignItemWithTrigger:!1,className:"pr-commit-menu",children:l.map(s=>e.jsxs(z,{value:s.oid,label:`${s.oid.slice(0,7)} ${s.messageHeadline||"(no commit message)"}`,children:[e.jsx("span",{className:"shrink-0 self-start font-mono text-xs text-muted-foreground",children:s.oid.slice(0,7)}),e.jsx("span",{className:"min-w-0 whitespace-normal break-words",children:s.messageHeadline||"(no commit message)"})]},s.oid))})]})]}),c=o==="all"?n:a.data??null;return o==="commit"&&h?e.jsxs(f,{scopeControl:t,children:[e.jsx("p",{className:"text-destructive",children:h}),e.jsxs(m,{variant:"outline",size:"sm",onClick:()=>{a.refetch()},children:[e.jsx(H,{})," Try again"]})]}):c?c.patch?e.jsx(L,{children:e.jsx(K,{contentKey:o==="all"?`pull:${r}:all`:`pull:${r}:commit:${i?.oid??""}`,diff:c,diffView:g,themeType:j,wrapLines:v,initiallyCollapsed:!0,scopeControl:t,onDiffViewChange:y,onWrapLinesChange:C,onClose:N})}):e.jsx(f,{scopeControl:t,children:"No differences to show."}):e.jsxs(f,{scopeControl:t,children:[e.jsx(B,{className:"spinner"})," ",e.jsx(I,{text:"Loading commit diff…"})]})}function f({scopeControl:n,children:r}){return e.jsxs("div",{className:"diff-workspace",children:[e.jsx("div",{className:"diff-workspace-toolbar",children:e.jsx("div",{className:"diff-workspace-scope",children:n})}),e.jsx("div",{className:"viewer-message flex-col gap-3",children:r})]})}export{Z as default};
1
+ import{r as d,j as e}from"./react-rd22PHbN.js";import{u as S}from"./tanstack-CtfgE41X.js";import{q as b,B as m,T,a as q,b as w,o as D}from"./index-CQcx9aRt.js";import{S as P,A as E,C as R,E as $,F as z,l as H,k as B,G as I}from"./App-9EfSdZB8.js";import{D as K}from"./DiffWorkspace-Ca2ZUlVn.js";import{P as L}from"./PierreWorkerPool-DH2jp9oe.js";import"./base-ui-DT3JsyND.js";import"./platform-Bqt97_Jr.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./EditContext-CvJWfVl1.js";import"./index-CtEztN1P.js";function Z({diff:n,prNumber:r,repositoryId:u,commits:l,diffView:g,themeType:j,wrapLines:v,onDiffViewChange:y,onWrapLinesChange:C,onClose:N}){const[o,p]=d.useState("all"),[x,k]=d.useState(l[0]?.oid??""),i=d.useMemo(()=>l.find(s=>s.oid===x)??l[0]??null,[l,x]),a=S({queryKey:b.pullRequestCommitDiff(u,i?.oid??""),queryFn:()=>D.github.getPullRequestCommitDiff(u,i.oid),enabled:o==="commit"&&i!==null}),h=a.error instanceof Error?a.error.message:a.error?"Could not load the commit diff.":null,t=e.jsxs("div",{className:"pr-code-scope",children:[e.jsxs("div",{className:"pr-code-mode",role:"group","aria-label":"Pull request code grouping",children:[e.jsx(m,{type:"button",variant:o==="all"?"secondary":"ghost",size:"xs","aria-pressed":o==="all",onClick:()=>p("all"),children:"All changes"}),e.jsx(m,{type:"button",variant:o==="commit"?"secondary":"ghost",size:"xs","aria-pressed":o==="commit",disabled:l.length===0,onClick:()=>p("commit"),children:"By commit"})]}),o==="commit"&&i&&e.jsxs(P,{value:i.oid,onValueChange:s=>{s&&k(s)},children:[e.jsxs(T,{children:[e.jsx(q,{render:e.jsx(R,{className:"pr-commit-select",size:"sm","aria-label":"Commit"}),children:e.jsxs(E,{children:[i.oid.slice(0,7)," · ",i.messageHeadline||"(no commit message)"]})}),e.jsxs(w,{children:[i.oid.slice(0,7)," · ",i.messageHeadline||"(no commit message)"]})]}),e.jsx($,{align:"start",alignItemWithTrigger:!1,className:"pr-commit-menu",children:l.map(s=>e.jsxs(z,{value:s.oid,label:`${s.oid.slice(0,7)} ${s.messageHeadline||"(no commit message)"}`,children:[e.jsx("span",{className:"shrink-0 self-start font-mono text-xs text-muted-foreground",children:s.oid.slice(0,7)}),e.jsx("span",{className:"min-w-0 whitespace-normal break-words",children:s.messageHeadline||"(no commit message)"})]},s.oid))})]})]}),c=o==="all"?n:a.data??null;return o==="commit"&&h?e.jsxs(f,{scopeControl:t,children:[e.jsx("p",{className:"text-destructive",children:h}),e.jsxs(m,{variant:"outline",size:"sm",onClick:()=>{a.refetch()},children:[e.jsx(H,{})," Try again"]})]}):c?c.patch?e.jsx(L,{children:e.jsx(K,{contentKey:o==="all"?`pull:${r}:all`:`pull:${r}:commit:${i?.oid??""}`,diff:c,diffView:g,themeType:j,wrapLines:v,initiallyCollapsed:!0,scopeControl:t,onDiffViewChange:y,onWrapLinesChange:C,onClose:N})}):e.jsx(f,{scopeControl:t,children:"No differences to show."}):e.jsxs(f,{scopeControl:t,children:[e.jsx(B,{className:"spinner"})," ",e.jsx(I,{text:"Loading commit diff…"})]})}function f({scopeControl:n,children:r}){return e.jsxs("div",{className:"diff-workspace",children:[e.jsx("div",{className:"diff-workspace-toolbar",children:e.jsx("div",{className:"diff-workspace-scope",children:n})}),e.jsx("div",{className:"viewer-message flex-col gap-3",children:r})]})}export{Z as default};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PullRequestDiff-Bcu8Gmrf.js","assets/react-rd22PHbN.js","assets/tanstack-CtfgE41X.js","assets/base-ui-DT3JsyND.js","assets/index-ChKJF4C_.js","assets/index-WwGOu_aM.css","assets/App-CGiS2z40.js","assets/DiffWorkspace-XS025gbZ.js","assets/PierreWorkerPool-B_NFnwU-.js","assets/platform-BMNQ8V5r.js","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js","assets/index-CtEztN1P.js","assets/EditContext-CvJWfVl1.js","assets/render-markdown-BiKX2Zdv.js"])))=>i.map(i=>d[i]);
2
- import{c as D,B as k,T as H,a as F,b as M,_ as L,o as C,q}from"./index-ChKJF4C_.js";import{r as j,j as e}from"./react-rd22PHbN.js";import{G as T,P as V,I as $,a as O,b as B}from"./GitHubAvatar-Depnd_JA.js";import{u as R}from"./tanstack-CtfgE41X.js";import{l as z,k as h,G as p,B as _,h as K,t as Q,z as U}from"./App-CGiS2z40.js";import{V as X,a as J,b as x}from"./viewer-tabs-BwMhis6Q.js";import{p as W,r as Y,o as Z}from"./gh-utils-DxPHIkD8.js";/* empty css */import"./base-ui-DT3JsyND.js";const ee=[["path",{d:"M6.5 7.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592 -5.592a2.41 2.41 0 0 0 0 -3.408l-7.71 -7.71a2 2 0 0 0 -1.414 -.586h-5.172a3 3 0 0 0 -3 3",key:"svg-1"}]],se=D("outline","tag","Tag",ee),ae=j.lazy(()=>L(()=>import("./PullRequestDiff-Bcu8Gmrf.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])));function he({repositoryId:r,prNumber:i,diffView:n,themeType:d,wrapLines:l,onDiffViewChange:m,onWrapLinesChange:c,onClose:P,onSelectPullRequest:E}){const[v,S]=j.useState("summary"),t=R({queryKey:q.pullRequest(r,i),queryFn:async()=>{const a=await C.github.getPullRequest(r,i),A=a.body.trim()?await L(async()=>{const{renderMarkdown:u}=await import("./render-markdown-BiKX2Zdv.js").then(G=>G.a);return{renderMarkdown:u}},__vite__mapDeps([14,6,4,1,2,3,5,10,11])).then(({renderMarkdown:u})=>u(a.body)).catch(()=>"<p>Could not render the description.</p>"):"";return{details:a,bodyHtml:A}}}),s=t.data?.details??null,f=t.data?.bodyHtml??"",N=t.error instanceof Error?t.error.message:t.error?"Could not load the pull request.":null,o=R({queryKey:q.pullRequestDiff(r,i),queryFn:()=>C.github.getPullRequestDiff(r,i),enabled:v==="diff"&&s!==null}),b=o.data??null,g=o.error instanceof Error?o.error.message:o.error?"Could not load the diff.":null;if(N)return e.jsxs("div",{className:"viewer-message flex-col gap-3",children:[e.jsx("p",{className:"text-destructive",children:N}),e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>{t.refetch()},children:[e.jsx(z,{})," Try again"]})]});if(!s)return e.jsxs("div",{className:"viewer-message",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(p,{text:`Loading pull request #${i}…`})]});const w=W(s),y=Y(s.reviewDecision);return e.jsxs(X,{value:v,onValueChange:a=>S(a),className:"pr-viewer",children:[e.jsxs("header",{className:"pr-viewer-header",children:[e.jsxs("div",{className:"pr-viewer-overview",children:[e.jsxs("div",{className:"pr-viewer-title",children:[e.jsx(_,{variant:s.state==="OPEN"&&!s.isDraft?"default":"secondary",className:`pr-state-badge ${w.toLowerCase().replace(/\s+/g,"-")}`,children:w}),e.jsxs("h2",{children:[s.title||"(no title)"," ",e.jsxs("span",{className:"pr-number",children:["#",s.number]})]})]}),e.jsxs("div",{className:"pr-viewer-meta",children:[e.jsxs("span",{className:"pr-author-with-avatar",children:[e.jsx(T,{src:s.authorAvatarUrl,className:"pr-author-avatar"},s.authorAvatarUrl),e.jsx("span",{className:"pr-author",children:s.author})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:["updated ",I(s.updatedAt)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"pr-branches",children:[e.jsx(K,{"aria-hidden":"true"})," ",s.headRefName," → ",s.baseRefName]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"pr-counters",children:[s.changedFiles," ",s.changedFiles===1?"file":"files"," ",e.jsxs("span",{className:"add",children:["+",s.additions]})," ",e.jsxs("span",{className:"del",children:["−",s.deletions]})]}),e.jsx(re,{state:s.checksState}),y&&e.jsx(_,{variant:"outline",className:"pr-review-badge",children:y}),s.stack&&e.jsx(V,{repositoryId:r,number:i,membership:s.stack,onSelect:E}),e.jsx("span",{className:"pr-viewer-actions",children:e.jsxs(k,{variant:"outline",size:"xs",onClick:()=>Z(s.url),children:[e.jsx(Q,{})," Open on GitHub"]})})]}),s.labels.length>0&&e.jsxs("div",{className:"pr-labels","aria-label":"Pull request labels",children:[e.jsx(se,{"aria-hidden":"true"}),s.labels.map(a=>e.jsx("span",{className:"pr-label",style:{borderColor:`#${a.color}`,backgroundColor:`#${a.color}22`},children:a.name},`${a.name}-${a.color}`))]})]}),e.jsx(J,{label:"Pull request view",className:"markdown-viewer-tabs pr-viewer-tabs",items:[{value:"summary",label:"Summary"},{value:"timeline",label:"Timeline"},{value:"diff",label:"Code"}]})]}),e.jsx(x,{value:"summary",className:"markdown-preview-scroll pr-description-scroll",children:e.jsx("section",{className:"pr-summary-section",children:f?e.jsx("div",{className:"markdown-prose",dangerouslySetInnerHTML:{__html:f}}):e.jsx("p",{className:"pr-empty-description",children:"This pull request has no description."})})}),e.jsx(x,{value:"timeline",className:"markdown-preview-scroll pr-description-scroll",children:e.jsxs("section",{className:"pr-timeline standalone","aria-label":"Commit timeline",children:[e.jsxs("h3",{children:[e.jsx(U,{"aria-hidden":"true"})," Commits ",e.jsx("span",{children:s.commits.length})]}),s.commits.length?s.commits.map(a=>e.jsxs("article",{className:"pr-timeline-item",children:[e.jsx("span",{className:"pr-timeline-rail",children:e.jsx("span",{})}),e.jsx(T,{src:a.authorAvatarUrl,className:"pr-commit-avatar"}),e.jsxs("span",{className:"pr-commit-content",children:[e.jsx("strong",{children:a.messageHeadline||"(no commit message)"}),e.jsxs("span",{children:[e.jsx("b",{children:a.author})," committed ",I(a.authoredAt)]})]}),e.jsxs(H,{children:[e.jsx(F,{render:e.jsx("code",{}),children:a.oid.slice(0,7)}),e.jsx(M,{children:a.oid})]})]},a.oid)):e.jsx("p",{className:"pr-empty-description",children:"No commits were returned by GitHub."})]})}),e.jsx(x,{value:"diff",className:"pr-diff-panel",children:g?e.jsx("div",{className:"viewer-message text-destructive",children:g}):b?e.jsx(j.Suspense,{fallback:e.jsxs("div",{className:"viewer-message",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(p,{text:"Loading diff viewer…"})]}),children:e.jsx(ae,{diff:b,prNumber:s.number,repositoryId:r,commits:s.commits,diffView:n,themeType:d,wrapLines:l,onDiffViewChange:m,onWrapLinesChange:c,onClose:P})}):e.jsxs("div",{className:"viewer-message",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(p,{text:"Loading diff…"})]})})]})}function re({state:r}){if(r==="NONE")return null;const i=r==="PASSING"?$:r==="FAILING"?O:B,n=r==="PASSING"?"Checks passing":r==="FAILING"?"Checks failing":"Checks pending";return e.jsxs("span",{className:`pr-checks ${r.toLowerCase()}`,children:[e.jsx(i,{"aria-hidden":"true"})," ",n]})}function I(r){const i=Date.parse(r);if(!Number.isFinite(i))return r;const n=Math.round((i-Date.now())/1e3),d=[["year",31536e3],["month",2592e3],["week",604800],["day",86400],["hour",3600],["minute",60]],l=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});for(const[m,c]of d)if(Math.abs(n)>=c)return l.format(Math.round(n/c),m);return l.format(n,"second")}export{he as PullRequestViewer};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PullRequestDiff-DK-m07ZP.js","assets/react-rd22PHbN.js","assets/tanstack-CtfgE41X.js","assets/base-ui-DT3JsyND.js","assets/index-CQcx9aRt.js","assets/index-DMbFAH51.css","assets/App-9EfSdZB8.js","assets/DiffWorkspace-Ca2ZUlVn.js","assets/PierreWorkerPool-DH2jp9oe.js","assets/platform-Bqt97_Jr.js","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js","assets/index-CtEztN1P.js","assets/EditContext-CvJWfVl1.js","assets/render-markdown-2GjhuGA-.js"])))=>i.map(i=>d[i]);
2
+ import{c as D,B as k,T as H,a as F,b as M,_ as L,o as C,q}from"./index-CQcx9aRt.js";import{r as j,j as e}from"./react-rd22PHbN.js";import{G as T,P as V,I as $,a as O,b as B}from"./GitHubAvatar-EO1TD_1z.js";import{u as R}from"./tanstack-CtfgE41X.js";import{l as z,k as h,G as p,B as _,h as K,t as Q,z as U}from"./App-9EfSdZB8.js";import{V as X,a as J,b as x}from"./viewer-tabs-DkLmDzFg.js";import{p as W,r as Y,o as Z}from"./gh-utils-LsOSydCg.js";/* empty css */import"./base-ui-DT3JsyND.js";const ee=[["path",{d:"M6.5 7.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592 -5.592a2.41 2.41 0 0 0 0 -3.408l-7.71 -7.71a2 2 0 0 0 -1.414 -.586h-5.172a3 3 0 0 0 -3 3",key:"svg-1"}]],se=D("outline","tag","Tag",ee),ae=j.lazy(()=>L(()=>import("./PullRequestDiff-DK-m07ZP.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])));function he({repositoryId:r,prNumber:i,diffView:n,themeType:d,wrapLines:l,onDiffViewChange:m,onWrapLinesChange:c,onClose:P,onSelectPullRequest:E}){const[v,S]=j.useState("summary"),t=R({queryKey:q.pullRequest(r,i),queryFn:async()=>{const a=await C.github.getPullRequest(r,i),A=a.body.trim()?await L(async()=>{const{renderMarkdown:u}=await import("./render-markdown-2GjhuGA-.js").then(G=>G.a);return{renderMarkdown:u}},__vite__mapDeps([14,6,4,1,2,3,5,10,11])).then(({renderMarkdown:u})=>u(a.body)).catch(()=>"<p>Could not render the description.</p>"):"";return{details:a,bodyHtml:A}}}),s=t.data?.details??null,f=t.data?.bodyHtml??"",N=t.error instanceof Error?t.error.message:t.error?"Could not load the pull request.":null,o=R({queryKey:q.pullRequestDiff(r,i),queryFn:()=>C.github.getPullRequestDiff(r,i),enabled:v==="diff"&&s!==null}),b=o.data??null,g=o.error instanceof Error?o.error.message:o.error?"Could not load the diff.":null;if(N)return e.jsxs("div",{className:"viewer-message flex-col gap-3",children:[e.jsx("p",{className:"text-destructive",children:N}),e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>{t.refetch()},children:[e.jsx(z,{})," Try again"]})]});if(!s)return e.jsxs("div",{className:"viewer-message",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(p,{text:`Loading pull request #${i}…`})]});const w=W(s),y=Y(s.reviewDecision);return e.jsxs(X,{value:v,onValueChange:a=>S(a),className:"pr-viewer",children:[e.jsxs("header",{className:"pr-viewer-header",children:[e.jsxs("div",{className:"pr-viewer-overview",children:[e.jsxs("div",{className:"pr-viewer-title",children:[e.jsx(_,{variant:s.state==="OPEN"&&!s.isDraft?"default":"secondary",className:`pr-state-badge ${w.toLowerCase().replace(/\s+/g,"-")}`,children:w}),e.jsxs("h2",{children:[s.title||"(no title)"," ",e.jsxs("span",{className:"pr-number",children:["#",s.number]})]})]}),e.jsxs("div",{className:"pr-viewer-meta",children:[e.jsxs("span",{className:"pr-author-with-avatar",children:[e.jsx(T,{src:s.authorAvatarUrl,className:"pr-author-avatar"},s.authorAvatarUrl),e.jsx("span",{className:"pr-author",children:s.author})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:["updated ",I(s.updatedAt)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"pr-branches",children:[e.jsx(K,{"aria-hidden":"true"})," ",s.headRefName," → ",s.baseRefName]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"pr-counters",children:[s.changedFiles," ",s.changedFiles===1?"file":"files"," ",e.jsxs("span",{className:"add",children:["+",s.additions]})," ",e.jsxs("span",{className:"del",children:["−",s.deletions]})]}),e.jsx(re,{state:s.checksState}),y&&e.jsx(_,{variant:"outline",className:"pr-review-badge",children:y}),s.stack&&e.jsx(V,{repositoryId:r,number:i,membership:s.stack,onSelect:E}),e.jsx("span",{className:"pr-viewer-actions",children:e.jsxs(k,{variant:"outline",size:"xs",onClick:()=>Z(s.url),children:[e.jsx(Q,{})," Open on GitHub"]})})]}),s.labels.length>0&&e.jsxs("div",{className:"pr-labels","aria-label":"Pull request labels",children:[e.jsx(se,{"aria-hidden":"true"}),s.labels.map(a=>e.jsx("span",{className:"pr-label",style:{borderColor:`#${a.color}`,backgroundColor:`#${a.color}22`},children:a.name},`${a.name}-${a.color}`))]})]}),e.jsx(J,{label:"Pull request view",className:"markdown-viewer-tabs pr-viewer-tabs",items:[{value:"summary",label:"Summary"},{value:"timeline",label:"Timeline"},{value:"diff",label:"Code"}]})]}),e.jsx(x,{value:"summary",className:"markdown-preview-scroll pr-description-scroll",children:e.jsx("section",{className:"pr-summary-section",children:f?e.jsx("div",{className:"markdown-prose",dangerouslySetInnerHTML:{__html:f}}):e.jsx("p",{className:"pr-empty-description",children:"This pull request has no description."})})}),e.jsx(x,{value:"timeline",className:"markdown-preview-scroll pr-description-scroll",children:e.jsxs("section",{className:"pr-timeline standalone","aria-label":"Commit timeline",children:[e.jsxs("h3",{children:[e.jsx(U,{"aria-hidden":"true"})," Commits ",e.jsx("span",{children:s.commits.length})]}),s.commits.length?s.commits.map(a=>e.jsxs("article",{className:"pr-timeline-item",children:[e.jsx("span",{className:"pr-timeline-rail",children:e.jsx("span",{})}),e.jsx(T,{src:a.authorAvatarUrl,className:"pr-commit-avatar"}),e.jsxs("span",{className:"pr-commit-content",children:[e.jsx("strong",{children:a.messageHeadline||"(no commit message)"}),e.jsxs("span",{children:[e.jsx("b",{children:a.author})," committed ",I(a.authoredAt)]})]}),e.jsxs(H,{children:[e.jsx(F,{render:e.jsx("code",{}),children:a.oid.slice(0,7)}),e.jsx(M,{children:a.oid})]})]},a.oid)):e.jsx("p",{className:"pr-empty-description",children:"No commits were returned by GitHub."})]})}),e.jsx(x,{value:"diff",className:"pr-diff-panel",children:g?e.jsx("div",{className:"viewer-message text-destructive",children:g}):b?e.jsx(j.Suspense,{fallback:e.jsxs("div",{className:"viewer-message",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(p,{text:"Loading diff viewer…"})]}),children:e.jsx(ae,{diff:b,prNumber:s.number,repositoryId:r,commits:s.commits,diffView:n,themeType:d,wrapLines:l,onDiffViewChange:m,onWrapLinesChange:c,onClose:P})}):e.jsxs("div",{className:"viewer-message",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(p,{text:"Loading diff…"})]})})]})}function re({state:r}){if(r==="NONE")return null;const i=r==="PASSING"?$:r==="FAILING"?O:B,n=r==="PASSING"?"Checks passing":r==="FAILING"?"Checks failing":"Checks pending";return e.jsxs("span",{className:`pr-checks ${r.toLowerCase()}`,children:[e.jsx(i,{"aria-hidden":"true"})," ",n]})}function I(r){const i=Date.parse(r);if(!Number.isFinite(i))return r;const n=Math.round((i-Date.now())/1e3),d=[["year",31536e3],["month",2592e3],["week",604800],["day",86400],["hour",3600],["minute",60]],l=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});for(const[m,c]of d)if(Math.abs(n)>=c)return l.format(Math.round(n/c),m);return l.format(n,"second")}export{he as PullRequestViewer};
@@ -1 +1 @@
1
- import{j as e,r as v}from"./react-rd22PHbN.js";import{c as p,G as k,P as I,I as P,a as S,b as w}from"./GitHubAvatar-Depnd_JA.js";import{a as R}from"./tanstack-CtfgE41X.js";import{c as b,B as t,I as N,T as c,a as o,b as u}from"./index-ChKJF4C_.js";import{C as y}from"./checkbox-DDpujnre.js";import{k as h,G as x,l as j,Y as E,M as G,t as L}from"./App-CGiS2z40.js";import{o as O}from"./gh-utils-DxPHIkD8.js";import{P as D,f as T,g as q,h as z,i as M}from"./base-ui-DT3JsyND.js";const $=[["path",{d:"M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5",key:"svg-0"}]],d=b("outline","brand-github","BrandGithub",$);const A=[["path",{d:"M4 4h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v7l-6 2v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227",key:"svg-0"}]],H=b("outline","filter","Filter",A);function ae(s){return s.info===null?e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(x,{text:"Checking repository…"})]}):s.info.isGitHub?s.ghStatus===null?e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(x,{text:"Checking GitHub CLI…"})]}):s.ghStatus.installed?s.ghStatus.authStatus==="unauthenticated"?e.jsxs(m,{icon:e.jsx(d,{}),title:"Sign in to GitHub CLI",children:["Run ",e.jsx("code",{children:"gh auth login"})," in a terminal to authenticate, then check again.",e.jsxs("span",{className:"pulls-notice-actions",children:[e.jsxs(t,{variant:"outline",size:"sm",onClick:()=>s.onCopyCommand("gh auth login"),children:[e.jsx(N,{})," Copy command"]}),e.jsxs(t,{variant:"ghost",size:"sm",onClick:s.onRefresh,children:[e.jsx(j,{})," Check again"]})]})]}):e.jsx(F,{...s,nameWithOwner:s.info.nameWithOwner??""}):e.jsxs(m,{icon:e.jsx(d,{}),title:"GitHub CLI is required",children:["OpenTig uses your local ",e.jsx("code",{children:"gh"})," session to read and create pull requests. It does not copy or store credentials.",e.jsxs("span",{className:"pulls-notice-actions",children:[e.jsxs(t,{variant:"outline",size:"sm",onClick:()=>s.onCopyCommand("winget install GitHub.cli"),children:[e.jsx(N,{})," Copy install command"]}),e.jsxs(t,{variant:"ghost",size:"sm",onClick:s.onRefresh,children:[e.jsx(j,{})," Check again"]})]}),e.jsx("small",{children:"Download from cli.github.com, then check again."})]}):e.jsxs(m,{icon:e.jsx(d,{}),title:"Not a GitHub repository",children:["The ",e.jsx("code",{children:"origin"})," remote does not point to github.com, so pull requests are unavailable here."]})}function F(s){const a=v.useRef(null),l=s.pulls,i=R({count:l?.length??0,getScrollElement:()=>a.current,estimateSize:()=>68,getItemKey:n=>l?.[n]?.number??n,overscan:8});return e.jsxs("div",{className:"pulls-view",children:[e.jsxs("div",{className:"pulls-toolbar",children:[e.jsxs(c,{children:[e.jsxs(o,{render:e.jsx("span",{className:"pulls-repo"}),children:[e.jsx(d,{"aria-hidden":"true"})," ",s.nameWithOwner]}),e.jsx(u,{children:s.nameWithOwner})]}),e.jsxs(c,{children:[e.jsx(o,{render:e.jsx(t,{variant:"ghost",size:"icon-xs",className:"change-action-button",disabled:s.loading,onClick:s.onRefresh,"aria-label":"Refresh pull requests"}),children:s.loading?e.jsx(h,{className:"animate-spin"}):e.jsx(j,{})}),e.jsx(u,{children:"Refresh pull requests"})]}),e.jsxs(D,{children:[e.jsx(T,{render:e.jsx(t,{variant:f(s.states)?"ghost":"secondary",size:"icon-xs",className:"change-action-button","aria-label":"Filter pull requests","aria-pressed":!f(s.states)}),children:e.jsx(H,{})}),e.jsx(q,{children:e.jsx(z,{side:"bottom",align:"end",sideOffset:4,className:"isolate z-50 outline-none",children:e.jsxs(M,{className:"pulls-filter-popup",children:[e.jsx("span",{className:"pulls-filter-title",children:"State"}),["OPEN","CLOSED","MERGED"].map(n=>e.jsxs("label",{htmlFor:`pulls-state-${n.toLowerCase()}`,className:"pulls-filter-option",children:[e.jsx(y,{id:`pulls-state-${n.toLowerCase()}`,checked:s.states.includes(n),onCheckedChange:r=>s.onStateChange(n,r===!0)}),e.jsx(C,{state:n,className:n.toLowerCase()}),e.jsx("span",{children:n==="OPEN"?"Open":n==="CLOSED"?"Closed":"Merged"})]},n))]})})})]}),e.jsxs(c,{children:[e.jsxs(o,{render:e.jsx(t,{variant:"outline",size:"xs",disabled:!!s.createDisabledReason||s.loading,onClick:s.onCreate,"aria-label":"Create pull request"}),children:[e.jsx(E,{})," New"]}),e.jsx(u,{children:s.createDisabledReason??"Create a pull request from the current branch"})]})]}),s.error&&e.jsxs("div",{className:"pulls-error",role:"alert",children:[e.jsx("span",{children:s.error}),e.jsx(t,{variant:"ghost",size:"xs",onClick:s.onRefresh,children:"Retry"})]}),e.jsx("div",{ref:a,className:"pulls-scroll",role:"list","aria-label":`${s.states.map(g).join(", ")||"No"} pull requests`,children:l===null&&!s.error?e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(x,{text:"Loading pull requests…"})]}):l!==null&&l.length===0?e.jsx("p",{className:"empty-list",children:s.states.length?`No ${s.states.map(n=>g(n).toLowerCase()).join(", ")} pull requests.`:"Select at least one PR state."}):l!==null&&e.jsx("div",{className:"virtual-list",style:{height:i.getTotalSize()},children:i.getVirtualItems().map(n=>{const r=l[n.index];return e.jsx("div",{ref:i.measureElement,"data-index":n.index,className:"virtual-row",style:{transform:`translateY(${n.start}px)`},children:e.jsx(V,{repositoryId:s.repositoryId,pr:r,active:s.activeNumber===r.number,onSelect:s.onSelect})},n.key)})})})]})}function V({repositoryId:s,pr:a,active:l,onSelect:i}){const n=a.state.toLowerCase(),r=W(a.updatedAt);return e.jsxs("div",{className:`pull-item ${l?"active":""}`,role:"listitem",children:[e.jsxs("button",{className:"pull-main",onClick:()=>i(a.number),"aria-label":`View pull request #${a.number}`,children:[e.jsx("span",{className:`pull-state-icon ${n}${a.isDraft?" draft":""}`,"aria-label":a.isDraft?"Draft":g(a.state),children:e.jsx(C,{state:a.state})}),e.jsxs("span",{className:"pull-content",children:[e.jsx("span",{className:"pull-title",children:a.title||"(no title)"}),e.jsxs("span",{className:"pull-meta",children:[e.jsxs("span",{className:"pull-number",children:["#",a.number]}),e.jsx(k,{src:a.authorAvatarUrl,className:"pull-avatar"}),e.jsx("span",{className:"pull-author",children:a.author}),e.jsx(_,{state:a.checksState}),a.isDraft&&e.jsx("span",{className:"pull-draft-label",children:"Draft"})]})]}),e.jsxs("span",{className:"pull-row-aside",children:[r&&e.jsx("span",{children:r}),e.jsxs("span",{className:"pull-line-stats",children:[e.jsxs("span",{className:"add",children:["+",a.additions]})," ",e.jsxs("span",{className:"del",children:["−",a.deletions]})]})]})]}),a.stack&&e.jsx(I,{repositoryId:s,number:a.number,membership:a.stack,onSelect:i}),e.jsxs(c,{children:[e.jsx(o,{render:e.jsx(t,{variant:"ghost",size:"icon-xs",className:"change-action-button pull-open-external",onClick:()=>O(a.url),"aria-label":`Open #${a.number} on GitHub`}),children:e.jsx(L,{})}),e.jsx(u,{children:"Open on GitHub"})]})]})}function C({state:s,className:a}){return s==="MERGED"?e.jsx(p,{"aria-hidden":"true",className:a}):e.jsx(G,{"aria-hidden":"true",className:a})}function _({state:s}){if(s==="NONE")return null;const a=s==="PASSING"?"Checks passing":s==="FAILING"?"Checks failing":"Checks pending",l=s==="PASSING"?P:s==="FAILING"?S:w;return e.jsx("span",{className:`pull-checks ${s.toLowerCase()}`,"aria-label":a,children:e.jsx(l,{"aria-hidden":"true"})})}function g(s){return s==="OPEN"?"Open":s==="CLOSED"?"Closed":"Merged"}function f(s){return s.length===1&&s[0]==="OPEN"}function m({icon:s,title:a,children:l}){return e.jsxs("div",{className:"pulls-notice",children:[e.jsx("span",{className:"pulls-notice-icon","aria-hidden":"true",children:s}),e.jsx("strong",{children:a}),e.jsx("p",{children:l})]})}const B=new Intl.RelativeTimeFormat("en",{numeric:"auto"}),U=[["year",31536e3],["month",2592e3],["week",604800],["day",86400],["hour",3600],["minute",60]];function W(s){const a=new Date(s);if(Number.isNaN(a.getTime()))return null;const l=Math.round((a.getTime()-Date.now())/1e3);for(const[i,n]of U)if(Math.abs(l)>=n)return B.format(Math.trunc(l/n),i);return"right now"}export{ae as PullRequestsView};
1
+ import{j as e,r as v}from"./react-rd22PHbN.js";import{c as p,G as k,P as I,I as P,a as S,b as w}from"./GitHubAvatar-EO1TD_1z.js";import{a as R}from"./tanstack-CtfgE41X.js";import{c as b,B as t,I as N,T as c,a as o,b as u}from"./index-CQcx9aRt.js";import{C as y}from"./checkbox-DYwmgDPS.js";import{k as h,G as x,l as j,Z as E,M as G,t as L}from"./App-9EfSdZB8.js";import{o as O}from"./gh-utils-LsOSydCg.js";import{P as D,f as T,g as q,h as z,i as M}from"./base-ui-DT3JsyND.js";const $=[["path",{d:"M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5",key:"svg-0"}]],d=b("outline","brand-github","BrandGithub",$);const A=[["path",{d:"M4 4h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v7l-6 2v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227",key:"svg-0"}]],H=b("outline","filter","Filter",A);function ae(s){return s.info===null?e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(x,{text:"Checking repository…"})]}):s.info.isGitHub?s.ghStatus===null?e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(x,{text:"Checking GitHub CLI…"})]}):s.ghStatus.installed?s.ghStatus.authStatus==="unauthenticated"?e.jsxs(m,{icon:e.jsx(d,{}),title:"Sign in to GitHub CLI",children:["Run ",e.jsx("code",{children:"gh auth login"})," in a terminal to authenticate, then check again.",e.jsxs("span",{className:"pulls-notice-actions",children:[e.jsxs(t,{variant:"outline",size:"sm",onClick:()=>s.onCopyCommand("gh auth login"),children:[e.jsx(N,{})," Copy command"]}),e.jsxs(t,{variant:"ghost",size:"sm",onClick:s.onRefresh,children:[e.jsx(j,{})," Check again"]})]})]}):e.jsx(F,{...s,nameWithOwner:s.info.nameWithOwner??""}):e.jsxs(m,{icon:e.jsx(d,{}),title:"GitHub CLI is required",children:["OpenTig uses your local ",e.jsx("code",{children:"gh"})," session to read and create pull requests. It does not copy or store credentials.",e.jsxs("span",{className:"pulls-notice-actions",children:[e.jsxs(t,{variant:"outline",size:"sm",onClick:()=>s.onCopyCommand("winget install GitHub.cli"),children:[e.jsx(N,{})," Copy install command"]}),e.jsxs(t,{variant:"ghost",size:"sm",onClick:s.onRefresh,children:[e.jsx(j,{})," Check again"]})]}),e.jsx("small",{children:"Download from cli.github.com, then check again."})]}):e.jsxs(m,{icon:e.jsx(d,{}),title:"Not a GitHub repository",children:["The ",e.jsx("code",{children:"origin"})," remote does not point to github.com, so pull requests are unavailable here."]})}function F(s){const a=v.useRef(null),l=s.pulls,i=R({count:l?.length??0,getScrollElement:()=>a.current,estimateSize:()=>68,getItemKey:n=>l?.[n]?.number??n,overscan:8});return e.jsxs("div",{className:"pulls-view",children:[e.jsxs("div",{className:"pulls-toolbar",children:[e.jsxs(c,{children:[e.jsxs(o,{render:e.jsx("span",{className:"pulls-repo"}),children:[e.jsx(d,{"aria-hidden":"true"})," ",s.nameWithOwner]}),e.jsx(u,{children:s.nameWithOwner})]}),e.jsxs(c,{children:[e.jsx(o,{render:e.jsx(t,{variant:"ghost",size:"icon-xs",className:"change-action-button",disabled:s.loading,onClick:s.onRefresh,"aria-label":"Refresh pull requests"}),children:s.loading?e.jsx(h,{className:"animate-spin"}):e.jsx(j,{})}),e.jsx(u,{children:"Refresh pull requests"})]}),e.jsxs(D,{children:[e.jsx(T,{render:e.jsx(t,{variant:f(s.states)?"ghost":"secondary",size:"icon-xs",className:"change-action-button","aria-label":"Filter pull requests","aria-pressed":!f(s.states)}),children:e.jsx(H,{})}),e.jsx(q,{children:e.jsx(z,{side:"bottom",align:"end",sideOffset:4,className:"isolate z-50 outline-none",children:e.jsxs(M,{className:"pulls-filter-popup",children:[e.jsx("span",{className:"pulls-filter-title",children:"State"}),["OPEN","CLOSED","MERGED"].map(n=>e.jsxs("label",{htmlFor:`pulls-state-${n.toLowerCase()}`,className:"pulls-filter-option",children:[e.jsx(y,{id:`pulls-state-${n.toLowerCase()}`,checked:s.states.includes(n),onCheckedChange:r=>s.onStateChange(n,r===!0)}),e.jsx(C,{state:n,className:n.toLowerCase()}),e.jsx("span",{children:n==="OPEN"?"Open":n==="CLOSED"?"Closed":"Merged"})]},n))]})})})]}),e.jsxs(c,{children:[e.jsxs(o,{render:e.jsx(t,{variant:"outline",size:"xs",disabled:!!s.createDisabledReason||s.loading,onClick:s.onCreate,"aria-label":"Create pull request"}),children:[e.jsx(E,{})," New"]}),e.jsx(u,{children:s.createDisabledReason??"Create a pull request from the current branch"})]})]}),s.error&&e.jsxs("div",{className:"pulls-error",role:"alert",children:[e.jsx("span",{children:s.error}),e.jsx(t,{variant:"ghost",size:"xs",onClick:s.onRefresh,children:"Retry"})]}),e.jsx("div",{ref:a,className:"pulls-scroll",role:"list","aria-label":`${s.states.map(g).join(", ")||"No"} pull requests`,children:l===null&&!s.error?e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(x,{text:"Loading pull requests…"})]}):l!==null&&l.length===0?e.jsx("p",{className:"empty-list",children:s.states.length?`No ${s.states.map(n=>g(n).toLowerCase()).join(", ")} pull requests.`:"Select at least one PR state."}):l!==null&&e.jsx("div",{className:"virtual-list",style:{height:i.getTotalSize()},children:i.getVirtualItems().map(n=>{const r=l[n.index];return e.jsx("div",{ref:i.measureElement,"data-index":n.index,className:"virtual-row",style:{transform:`translateY(${n.start}px)`},children:e.jsx(V,{repositoryId:s.repositoryId,pr:r,active:s.activeNumber===r.number,onSelect:s.onSelect})},n.key)})})})]})}function V({repositoryId:s,pr:a,active:l,onSelect:i}){const n=a.state.toLowerCase(),r=W(a.updatedAt);return e.jsxs("div",{className:`pull-item ${l?"active":""}`,role:"listitem",children:[e.jsxs("button",{className:"pull-main",onClick:()=>i(a.number),"aria-label":`View pull request #${a.number}`,children:[e.jsx("span",{className:`pull-state-icon ${n}${a.isDraft?" draft":""}`,"aria-label":a.isDraft?"Draft":g(a.state),children:e.jsx(C,{state:a.state})}),e.jsxs("span",{className:"pull-content",children:[e.jsx("span",{className:"pull-title",children:a.title||"(no title)"}),e.jsxs("span",{className:"pull-meta",children:[e.jsxs("span",{className:"pull-number",children:["#",a.number]}),e.jsx(k,{src:a.authorAvatarUrl,className:"pull-avatar"}),e.jsx("span",{className:"pull-author",children:a.author}),e.jsx(_,{state:a.checksState}),a.isDraft&&e.jsx("span",{className:"pull-draft-label",children:"Draft"})]})]}),e.jsxs("span",{className:"pull-row-aside",children:[r&&e.jsx("span",{children:r}),e.jsxs("span",{className:"pull-line-stats",children:[e.jsxs("span",{className:"add",children:["+",a.additions]})," ",e.jsxs("span",{className:"del",children:["−",a.deletions]})]})]})]}),a.stack&&e.jsx(I,{repositoryId:s,number:a.number,membership:a.stack,onSelect:i}),e.jsxs(c,{children:[e.jsx(o,{render:e.jsx(t,{variant:"ghost",size:"icon-xs",className:"change-action-button pull-open-external",onClick:()=>O(a.url),"aria-label":`Open #${a.number} on GitHub`}),children:e.jsx(L,{})}),e.jsx(u,{children:"Open on GitHub"})]})]})}function C({state:s,className:a}){return s==="MERGED"?e.jsx(p,{"aria-hidden":"true",className:a}):e.jsx(G,{"aria-hidden":"true",className:a})}function _({state:s}){if(s==="NONE")return null;const a=s==="PASSING"?"Checks passing":s==="FAILING"?"Checks failing":"Checks pending",l=s==="PASSING"?P:s==="FAILING"?S:w;return e.jsx("span",{className:`pull-checks ${s.toLowerCase()}`,"aria-label":a,children:e.jsx(l,{"aria-hidden":"true"})})}function g(s){return s==="OPEN"?"Open":s==="CLOSED"?"Closed":"Merged"}function f(s){return s.length===1&&s[0]==="OPEN"}function m({icon:s,title:a,children:l}){return e.jsxs("div",{className:"pulls-notice",children:[e.jsx("span",{className:"pulls-notice-icon","aria-hidden":"true",children:s}),e.jsx("strong",{children:a}),e.jsx("p",{children:l})]})}const B=new Intl.RelativeTimeFormat("en",{numeric:"auto"}),U=[["year",31536e3],["month",2592e3],["week",604800],["day",86400],["hour",3600],["minute",60]];function W(s){const a=new Date(s);if(Number.isNaN(a.getTime()))return null;const l=Math.round((a.getTime()-Date.now())/1e3);for(const[i,n]of U)if(Math.abs(l)>=n)return B.format(Math.trunc(l/n),i);return"right now"}export{ae as PullRequestsView};
@@ -1 +1 @@
1
- import{r as f,j as e}from"./react-rd22PHbN.js";import{Z as y,_ as N,D as v,c as R,d as C,e as D,j as F,k as S,G as b,X as I}from"./App-CGiS2z40.js";import{c as M}from"./index-ChKJF4C_.js";import{A as q,j as w,k as z,l as L}from"./base-ui-DT3JsyND.js";import"./tanstack-CtfgE41X.js";const O=[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M12 21h-5a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v4.5",key:"svg-1"}],["path",{d:"M14 17.5a2.5 2.5 0 1 0 5 0a2.5 2.5 0 1 0 -5 0",key:"svg-2"}],["path",{d:"M18.5 19.5l2.5 2.5",key:"svg-3"}]],Q=M("outline","file-search","FileSearch",O);function E(t,s){const n=[],r=c=>{for(const i of c)i.type==="directory"?r(i.children):n.push({path:i.path,name:i.name,parentPath:N(i.path)})};return r(s?t:y(t)),n}function T(t,s,{includeIgnored:n,activePath:r=null,limit:c=100}){const i=E(t,n),h=x(s).trim(),l=Math.max(0,Math.floor(c));if(!h)return i.sort((a,p)=>a.path===r?-1:p.path===r?1:k(a.path,p.path)).slice(0,l);const u=h.replace(/\s+/g,"");return i.map(a=>{const p=x(a.name),m=x(a.path),o=A(p,m,h,u);return o?{...a,rank:o}:null}).filter(a=>a!==null).sort((a,p)=>P(a.rank,p.rank)||j(a.path)-j(p.path)||k(a.path,p.path)).slice(0,l).map(a=>({path:a.path,name:a.name,parentPath:a.parentPath}))}function A(t,s,n,r){if(t===n)return[0,0,0,0];if(t.startsWith(n))return[1,0,t.length-n.length,0];const c=t.indexOf(n);if(c>=0)return[2,c,t.length-n.length,0];const i=s.indexOf(n);if(i>=0)return[3,i,s.length-n.length,0];const h=g(t,r);if(h)return[4,...h];const l=g(s,r);return l?[5,...l]:null}function g(t,s){if(!s)return null;let n=-1,r=-1,c=0,i=0;for(const h of s){const l=t.indexOf(h,n+1);if(l<0)return null;r<0&&(r=l),n>=0&&(c+=l-n-1,l===n+1&&(i+=1)),n=l}return[c,-i,r,t.length-s.length]}function P(t,s){for(let n=0;n<Math.max(t.length,s.length);n+=1){const r=(t[n]??0)-(s[n]??0);if(r!==0)return r}return 0}function x(t){return t.replace(/\\/g,"/").toLocaleLowerCase()}function j(t){return t.split("/").length}function k(t,s){return t.localeCompare(s,void 0,{sensitivity:"base"})||t.localeCompare(s)}function U({open:t,files:s,includeIgnored:n,activePath:r,onOpenChange:c,onOpenFile:i}){const[h,l]=f.useState(""),u=f.useRef(null),a=f.useMemo(()=>s?T(s,h,{includeIgnored:n,activePath:r,limit:100}):[],[r,s,n,h]);f.useEffect(()=>{t&&(l(""),window.requestAnimationFrame(()=>u.current?.focus()))},[t]);const p=o=>{i(o)&&c(!1)},m=h.trim();return e.jsx(v,{open:t,onOpenChange:c,children:e.jsxs(R,{className:"quick-open-dialog top-[max(64px,12vh)] w-[min(640px,calc(100vw-2.5rem))] -translate-y-0",children:[e.jsx(C,{className:"sr-only",children:"Open file"}),e.jsx(D,{className:"sr-only",children:"Search files in the current repository."}),e.jsxs(q,{items:a,value:h,onValueChange:l,itemToStringValue:o=>o.path,mode:"none",inline:!0,open:t,autoHighlight:"always",onOpenChange:(o,d)=>{!o&&d.reason!=="item-press"&&c(!1)},children:[e.jsxs("div",{className:"quick-open-input-shell",children:[e.jsx(F,{"aria-hidden":"true"}),e.jsx(w,{ref:u,"aria-label":"Search files by name or path",autoComplete:"off",spellCheck:!1,placeholder:"Search files by name or path"})]}),e.jsx(z,{"aria-label":"Repository files",className:"quick-open-results",children:s===null?e.jsxs("div",{className:"quick-open-status loading",role:"status",children:[e.jsx(S,{className:"spinner","aria-hidden":"true"})," ",e.jsx(b,{text:"Loading files…"})]}):a.length===0?e.jsxs("div",{className:"quick-open-status",role:"status",children:[e.jsx(Q,{"aria-hidden":"true"}),e.jsx("strong",{children:"No matching files"}),e.jsx("p",{children:m?e.jsxs(e.Fragment,{children:["Nothing matches ",e.jsx("em",{children:m})," in this repository."]}):"This repository has no files to open."})]}):a.map((o,d)=>e.jsxs(L,{value:o,index:d,className:"quick-open-result",onClick:()=>p(o.path),children:[e.jsx("img",{className:"quick-open-icon",src:I(o.path),alt:"","aria-hidden":"true",draggable:!1}),e.jsx("span",{className:"quick-open-name",children:o.name}),e.jsx("span",{className:"quick-open-parent",children:o.parentPath||"Repository root"})]},o.path))})]}),e.jsxs("footer",{className:"quick-open-footer",children:[e.jsxs("span",{className:"quick-open-hints",children:[e.jsxs("span",{children:[e.jsx("kbd",{children:"↑"}),e.jsx("kbd",{children:"↓"})," navigate"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"↵"})," open"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"Esc"})," close"]})]}),s!==null&&e.jsx("span",{className:"quick-open-count",children:a.length===100?"Top 100 matches":`${a.length} ${a.length===1?"file":"files"}`})]})]})})}export{U as QuickOpenDialog};
1
+ import{r as f,j as e}from"./react-rd22PHbN.js";import{_ as y,$ as N,D as v,c as R,d as C,e as D,j as F,k as S,G as b,Y as I}from"./App-9EfSdZB8.js";import{c as M}from"./index-CQcx9aRt.js";import{A as q,j as w,k as z,l as L}from"./base-ui-DT3JsyND.js";import"./tanstack-CtfgE41X.js";const O=[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M12 21h-5a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v4.5",key:"svg-1"}],["path",{d:"M14 17.5a2.5 2.5 0 1 0 5 0a2.5 2.5 0 1 0 -5 0",key:"svg-2"}],["path",{d:"M18.5 19.5l2.5 2.5",key:"svg-3"}]],Q=M("outline","file-search","FileSearch",O);function E(t,s){const n=[],r=c=>{for(const i of c)i.type==="directory"?r(i.children):n.push({path:i.path,name:i.name,parentPath:N(i.path)})};return r(s?t:y(t)),n}function T(t,s,{includeIgnored:n,activePath:r=null,limit:c=100}){const i=E(t,n),h=x(s).trim(),l=Math.max(0,Math.floor(c));if(!h)return i.sort((a,p)=>a.path===r?-1:p.path===r?1:k(a.path,p.path)).slice(0,l);const u=h.replace(/\s+/g,"");return i.map(a=>{const p=x(a.name),m=x(a.path),o=A(p,m,h,u);return o?{...a,rank:o}:null}).filter(a=>a!==null).sort((a,p)=>P(a.rank,p.rank)||j(a.path)-j(p.path)||k(a.path,p.path)).slice(0,l).map(a=>({path:a.path,name:a.name,parentPath:a.parentPath}))}function A(t,s,n,r){if(t===n)return[0,0,0,0];if(t.startsWith(n))return[1,0,t.length-n.length,0];const c=t.indexOf(n);if(c>=0)return[2,c,t.length-n.length,0];const i=s.indexOf(n);if(i>=0)return[3,i,s.length-n.length,0];const h=g(t,r);if(h)return[4,...h];const l=g(s,r);return l?[5,...l]:null}function g(t,s){if(!s)return null;let n=-1,r=-1,c=0,i=0;for(const h of s){const l=t.indexOf(h,n+1);if(l<0)return null;r<0&&(r=l),n>=0&&(c+=l-n-1,l===n+1&&(i+=1)),n=l}return[c,-i,r,t.length-s.length]}function P(t,s){for(let n=0;n<Math.max(t.length,s.length);n+=1){const r=(t[n]??0)-(s[n]??0);if(r!==0)return r}return 0}function x(t){return t.replace(/\\/g,"/").toLocaleLowerCase()}function j(t){return t.split("/").length}function k(t,s){return t.localeCompare(s,void 0,{sensitivity:"base"})||t.localeCompare(s)}function U({open:t,files:s,includeIgnored:n,activePath:r,onOpenChange:c,onOpenFile:i}){const[h,l]=f.useState(""),u=f.useRef(null),a=f.useMemo(()=>s?T(s,h,{includeIgnored:n,activePath:r,limit:100}):[],[r,s,n,h]);f.useEffect(()=>{t&&(l(""),window.requestAnimationFrame(()=>u.current?.focus()))},[t]);const p=o=>{i(o)&&c(!1)},m=h.trim();return e.jsx(v,{open:t,onOpenChange:c,children:e.jsxs(R,{className:"quick-open-dialog top-[max(64px,12vh)] w-[min(640px,calc(100vw-2.5rem))] -translate-y-0",children:[e.jsx(C,{className:"sr-only",children:"Open file"}),e.jsx(D,{className:"sr-only",children:"Search files in the current repository."}),e.jsxs(q,{items:a,value:h,onValueChange:l,itemToStringValue:o=>o.path,mode:"none",inline:!0,open:t,autoHighlight:"always",onOpenChange:(o,d)=>{!o&&d.reason!=="item-press"&&c(!1)},children:[e.jsxs("div",{className:"quick-open-input-shell",children:[e.jsx(F,{"aria-hidden":"true"}),e.jsx(w,{ref:u,"aria-label":"Search files by name or path",autoComplete:"off",spellCheck:!1,placeholder:"Search files by name or path"})]}),e.jsx(z,{"aria-label":"Repository files",className:"quick-open-results",children:s===null?e.jsxs("div",{className:"quick-open-status loading",role:"status",children:[e.jsx(S,{className:"spinner","aria-hidden":"true"})," ",e.jsx(b,{text:"Loading files…"})]}):a.length===0?e.jsxs("div",{className:"quick-open-status",role:"status",children:[e.jsx(Q,{"aria-hidden":"true"}),e.jsx("strong",{children:"No matching files"}),e.jsx("p",{children:m?e.jsxs(e.Fragment,{children:["Nothing matches ",e.jsx("em",{children:m})," in this repository."]}):"This repository has no files to open."})]}):a.map((o,d)=>e.jsxs(L,{value:o,index:d,className:"quick-open-result",onClick:()=>p(o.path),children:[e.jsx("img",{className:"quick-open-icon",src:I(o.path),alt:"","aria-hidden":"true",draggable:!1}),e.jsx("span",{className:"quick-open-name",children:o.name}),e.jsx("span",{className:"quick-open-parent",children:o.parentPath||"Repository root"})]},o.path))})]}),e.jsxs("footer",{className:"quick-open-footer",children:[e.jsxs("span",{className:"quick-open-hints",children:[e.jsxs("span",{children:[e.jsx("kbd",{children:"↑"}),e.jsx("kbd",{children:"↓"})," navigate"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"↵"})," open"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"Esc"})," close"]})]}),s!==null&&e.jsx("span",{className:"quick-open-count",children:a.length===100?"Top 100 matches":`${a.length} ${a.length===1?"file":"files"}`})]})]})})}export{U as QuickOpenDialog};
@@ -0,0 +1 @@
1
+ import{r,j as e}from"./react-rd22PHbN.js";import{D as Y,c as q,d as Q,e as Z,g as I,I as ee,m as k,a0 as z,k as _,a1 as w,y as O,a2 as se,N as ne,a3 as ae}from"./App-9EfSdZB8.js";import{c as M,B as o,T as C,a as R,b as B,o as h}from"./index-CQcx9aRt.js";import{I as ie}from"./IconFolderPlus-ByGyA0Di.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";const oe=[["path",{d:"M3 21v-4a3 3 0 0 1 3 -3h5",key:"svg-0"}],["path",{d:"M8 17l3 -3l-3 -3",key:"svg-1"}],["path",{d:"M3 11v-5a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8",key:"svg-2"}]],re=M("outline","folder-symlink","FolderSymlink",oe);const te=[["path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4",key:"svg-0"}],["path",{d:"M13.5 6.5l4 4",key:"svg-1"}]],le=M("outline","pencil","Pencil",te),D="__opentig_no_project__";function ue({open:l,projects:c,repositories:v,onOpenChange:F,onOrganizationChange:L,onForgetRepository:A,onRelocateRepository:P}){const[G,u]=r.useState(null),[x,f]=r.useState(null),[b,$]=r.useState(""),[g,d]=r.useState(null),[N,T]=r.useState(""),[J,p]=r.useState(null),[n,y]=r.useState(null),[S,m]=r.useState(null),K=r.useMemo(()=>new Map(c.flatMap(s=>s.repositoryKeys.map(a=>[a,s.id]))),[c]);r.useEffect(()=>{l||(u(null),f(null),d(null),p(null),m(null))},[l]);const j=async(s,a)=>{y(s),m(null);try{const t=await a();return L(t),!0}catch(t){return m(E(t)),!1}finally{y(null)}},X=async s=>{s.preventDefault();const a=b.trim();!a||n||await j("create",()=>h.projects.create(a))&&$("")},H=async s=>{s.preventDefault();const a=N.trim();!g||!a||n||await j(`rename:${g}`,()=>h.projects.rename(g,a))&&d(null)},U=async s=>{n||await j(`remove:${s}`,()=>h.projects.remove(s))&&p(null)},V=async(s,a)=>{n||await j(`assign:${s}`,()=>h.projects.assign(s,a))},W=async s=>{if(!n){if(m(null),!window.opentigDesktop){f(s);return}y(`relocate:${s.key}`);try{const a=await h.repository.select(`Relocate ${s.name}`);a&&await P(s,a)}catch(a){m(E(a))}finally{y(null)}}};return e.jsxs(Y,{open:l,onOpenChange:s=>{n||F(s)},children:[e.jsxs(q,{className:"repository-projects-dialog w-[min(660px,calc(100vw-2.5rem))]",children:[e.jsxs("header",{className:"repository-projects-header",children:[e.jsxs("div",{children:[e.jsx(Q,{children:"Manage projects"}),e.jsx(Z,{children:"Group repositories, update their locations, or remove them from OpenTig. Files stay on disk."})]}),e.jsx(I,{render:e.jsx(o,{variant:"ghost",size:"icon-sm","aria-label":"Close project management",disabled:!!n}),children:e.jsx(ee,{})})]}),e.jsxs("div",{className:"repository-projects-body",children:[S&&e.jsxs("div",{className:"repository-projects-error",role:"alert",children:[e.jsx(k,{"aria-hidden":"true"}),e.jsx("span",{children:S})]}),e.jsxs("section",{className:"repository-projects-section","aria-labelledby":"projects-heading",children:[e.jsxs("div",{className:"repository-projects-section-heading",children:[e.jsxs("h3",{id:"projects-heading",children:["Projects ",e.jsx("span",{children:c.length})]}),e.jsxs("form",{className:"repository-project-create",onSubmit:s=>{X(s)},children:[e.jsx("label",{className:"sr-only",htmlFor:"new-project-name",children:"Project name"}),e.jsx("input",{id:"new-project-name",value:b,maxLength:z,onChange:s=>$(s.target.value),placeholder:"New project name",disabled:!!n}),e.jsxs(o,{type:"submit",size:"sm",disabled:!b.trim()||!!n,children:[n==="create"?e.jsx(_,{className:"animate-spin"}):e.jsx(ie,{})," Create"]})]})]}),e.jsxs("div",{className:"repository-project-list",children:[c.length===0&&e.jsx("p",{className:"repository-projects-empty",children:"No projects yet. Create one to group related repositories."}),c.map(s=>{const a=s.repositoryKeys.length,t=n===`rename:${s.id}`||n===`remove:${s.id}`;return e.jsx("div",{className:"repository-project-row","aria-busy":t||void 0,children:g===s.id?e.jsxs("form",{className:"repository-inline-form",onSubmit:i=>{H(i)},onKeyDown:i=>{i.key==="Escape"&&d(null)},children:[e.jsxs("label",{className:"sr-only",htmlFor:`rename-project-${s.id}`,children:["Rename ",s.name]}),e.jsx("input",{id:`rename-project-${s.id}`,autoFocus:!0,value:N,maxLength:z,onChange:i=>T(i.target.value),disabled:!!n}),e.jsx(o,{type:"submit",size:"xs",disabled:!N.trim()||!!n,children:"Save"}),e.jsx(o,{type:"button",variant:"ghost",size:"xs",onClick:()=>d(null),disabled:!!n,children:"Cancel"})]}):J===s.id?e.jsxs("div",{className:"repository-project-confirm",role:"alert",children:[e.jsx(k,{"aria-hidden":"true"}),e.jsxs("span",{children:["Delete ",e.jsx("strong",{children:s.name}),"? Its repositories stay available, just ungrouped."]}),e.jsx(o,{variant:"destructive",size:"xs",disabled:!!n,onClick:()=>{U(s.id)},children:"Delete"}),e.jsx(o,{variant:"ghost",size:"xs",disabled:!!n,onClick:()=>p(null),children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"repository-project-icon","aria-hidden":"true",children:e.jsx(w,{})}),e.jsxs("span",{className:"repository-project-copy",children:[e.jsx("strong",{children:s.name}),e.jsxs("small",{children:[a," ",a===1?"repository":"repositories"]})]}),e.jsxs("span",{className:"repository-row-actions",children:[e.jsx(o,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${s.name}`,disabled:!!n,onClick:()=>{d(s.id),T(s.name),p(null)},children:e.jsx(le,{})}),e.jsx(o,{variant:"ghost",size:"icon-sm",className:"repository-row-delete","aria-label":`Delete ${s.name}`,disabled:!!n,onClick:()=>{p(s.id),d(null)},children:e.jsx(O,{})})]})]})},s.id)})]})]}),e.jsxs("section",{className:"repository-projects-section","aria-labelledby":"repository-assignments-heading",children:[e.jsxs("div",{className:"repository-projects-section-heading",children:[e.jsxs("h3",{id:"repository-assignments-heading",children:["Repositories ",e.jsx("span",{children:v.length})]}),e.jsx("p",{children:"One project per repository"})]}),e.jsxs("div",{className:"repository-assignment-list",children:[v.length===0&&e.jsx("p",{className:"repository-projects-empty",children:"No recent repositories to assign yet."}),v.map(s=>{const a=K.get(s.key)??D,t=n?.endsWith(`:${s.key}`);return e.jsx("div",{className:"repository-assignment-row","aria-busy":t||void 0,children:G===s.key?e.jsxs("div",{className:"repository-project-confirm",role:"alert",children:[e.jsx(k,{"aria-hidden":"true"}),e.jsxs("span",{children:["Remove ",e.jsx("strong",{children:s.name})," and its worktrees from OpenTig? Their folders and files stay on disk. You can open them again later."]}),e.jsx(o,{variant:"destructive",size:"xs",disabled:!!n,onClick:()=>{j(`forget:${s.key}`,()=>A(s)).then(i=>{i&&u(null)})},children:"Remove"}),e.jsx(o,{variant:"ghost",size:"xs",disabled:!!n,onClick:()=>u(null),children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx(w,{"aria-hidden":"true"}),e.jsxs("span",{className:"repository-assignment-copy",children:[e.jsx("strong",{children:s.name}),e.jsxs(C,{children:[e.jsx(R,{render:e.jsx("small",{}),children:se(s.rootPath,4)}),e.jsx(B,{children:s.rootPath})]})]}),t&&e.jsx(_,{className:"repository-assignment-busy animate-spin","aria-hidden":"true"}),e.jsx(ne,{groups:[{id:"none",label:"",items:[{value:D,label:"No project",pinned:!0}]},{id:"projects",label:"Projects",items:c.map(i=>({value:i.id,label:i.name,icon:e.jsx(w,{})}))}],value:a,onValueChange:i=>{V(s.key,i===D?null:i)},label:`Project for ${s.name}`,triggerLabel:c.find(i=>i.id===a)?.name??"No project",placeholder:"Search projects…",disabled:!!n}),e.jsxs("span",{className:"repository-management-actions",children:[e.jsxs(C,{children:[e.jsx(R,{render:e.jsx(o,{variant:"ghost",size:"icon-sm","aria-label":`Relocate ${s.name}`,disabled:!!n,onClick:()=>{W(s)}}),children:e.jsx(re,{})}),e.jsx(B,{children:"Relocate repository"})]}),e.jsxs(C,{children:[e.jsx(R,{render:e.jsx(o,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${s.name} from OpenTig`,disabled:!!n,onClick:()=>{u(s.key),m(null)}}),children:e.jsx(O,{})}),e.jsx(B,{children:"Remove from OpenTig"})]})]})]})},s.key)})]})]})]}),e.jsx("footer",{className:"repository-projects-footer",children:e.jsx(I,{render:e.jsx(o,{variant:"outline",size:"sm",disabled:!!n}),children:"Done"})})]}),e.jsx(ae,{open:x!==null,onOpenChange:s=>{s||f(null)},title:"Relocate repository",description:`Choose the existing server folder for ${x?.name??"this repository"}. This updates its saved location; it does not move files.`,confirmLabel:"Use this folder",onBrowse:h.repository.browseDirectories,onOpen:async s=>{x&&await P(x,s)}})]})}function E(l){return l instanceof Error?l.message:String(l)}export{ue as RepositoryProjectsDialog};
@@ -1 +1 @@
1
- import{r as t,j as e}from"./react-rd22PHbN.js";import{a6 as pe,a7 as A,U as P,j as fe,G as Y,k as me}from"./App-CGiS2z40.js";import{u as xe,a as ve}from"./tanstack-CtfgE41X.js";import{c as x,B as k,T as W,a as D,b as O,s as m,o as J,q as je}from"./index-ChKJF4C_.js";import"./base-ui-DT3JsyND.js";const ye=[["path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828",key:"svg-0"}],["path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87",key:"svg-1"}],["path",{d:"M3 3l18 18",key:"svg-2"}]],X=x("outline","eye-off","EyeOff",ye);const ke=[["path",{d:"M14 15.5a3.5 3.5 0 1 0 7 0a3.5 3.5 0 1 0 -7 0",key:"svg-0"}],["path",{d:"M3 19v-10.5a3.5 3.5 0 0 1 7 0v10.5",key:"svg-1"}],["path",{d:"M3 13h7",key:"svg-2"}],["path",{d:"M21 12v7",key:"svg-3"}]],Me=x("outline","letter-case","LetterCase",ke);const Ne=[["path",{d:"M6.5 15a2.5 2.5 0 1 1 0 5a2.5 2.5 0 0 1 0 -5",key:"svg-0"}],["path",{d:"M17 7.875l3 -1.687",key:"svg-1"}],["path",{d:"M17 7.875v3.375",key:"svg-2"}],["path",{d:"M17 7.875l-3 -1.687",key:"svg-3"}],["path",{d:"M17 7.875l3 1.688",key:"svg-4"}],["path",{d:"M17 4.5v3.375",key:"svg-5"}],["path",{d:"M17 7.875l-3 1.688",key:"svg-6"}]],be=x("outline","regex","Regex",Ne);const we=[["path",{d:"M3 4a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",key:"svg-0"}],["path",{d:"M15 16a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",key:"svg-1"}],["path",{d:"M21 11v-3a2 2 0 0 0 -2 -2h-6l3 3m0 -6l-3 3",key:"svg-2"}],["path",{d:"M3 13v3a2 2 0 0 0 2 2h6l-3 -3m0 6l3 -3",key:"svg-3"}]],Z=x("outline","replace","Replace",we);const Se=[["path",{d:"M4 6l10 0",key:"svg-0"}],["path",{d:"M4 18l10 0",key:"svg-1"}],["path",{d:"M4 12h17l-3 -3m0 6l3 -3",key:"svg-2"}]],$e=x("outline","text-wrap-disabled","TextWrapDisabled",Se);const Re=[["path",{d:"M8 2h-4a2 2 0 0 0 -2 2v4a2 2 0 0 0 2 2h4a2 2 0 0 0 2 -2v-4a2 2 0 0 0 -2 -2z",key:"svg-0"}],["path",{d:"M20 14h-4a2 2 0 0 0 -2 2v4a2 2 0 0 0 2 2h4a2 2 0 0 0 2 -2v-4a2 2 0 0 0 -2 -2z",key:"svg-1"}],["path",{d:"M16.707 2.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.293 1.293h3.586a3 3 0 0 1 2.995 2.824l.005 .176v3a1 1 0 0 1 -1.993 .117l-.007 -.117v-3a1 1 0 0 0 -.883 -.993l-.117 -.007h-3.585l1.292 1.293a1 1 0 0 1 -1.32 1.497l-.094 -.083l-3 -3a.98 .98 0 0 1 -.28 -.872l.036 -.146l.04 -.104c.058 -.126 .14 -.24 .245 -.334l2.959 -2.958a1 1 0 0 1 1.414 0z",key:"svg-2"}],["path",{d:"M3 12a1 1 0 0 1 .993 .883l.007 .117v3a1 1 0 0 0 .883 .993l.117 .007h3.585l-1.292 -1.293a1 1 0 0 1 -.083 -1.32l.083 -.094a1 1 0 0 1 1.32 -.083l.094 .083l3 3a.98 .98 0 0 1 .28 .872l-.036 .146l-.04 .104a1.02 1.02 0 0 1 -.245 .334l-2.959 2.958a1 1 0 0 1 -1.497 -1.32l.083 -.094l1.291 -1.293h-3.584a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-3a1 1 0 0 1 1 -1z",key:"svg-3"}]],ee=x("filled","replace-filled","ReplaceFilled",Re);function Ce(l){return l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ie(l){if(!l.query)return null;const c=l.regex?l.query:Ce(l.query),i=l.wholeWord?`\\b(?:${c})\\b`:c;try{return new RegExp(i,l.matchCase?"g":"gi")}catch{return null}}const Te=250,Ee=28,_e=24;function He({repositoryId:l,active:c,revision:i,onOpenFile:h,unsavedPathsAmong:g,onReplaced:o}){const B=pe(),[f,ae]=t.useState(""),[M,se]=t.useState(!1),[N,te]=t.useState(!1),[b,le]=t.useState(!1),[p,ne]=t.useState(!1),[H,re]=t.useState(""),[w,ce]=t.useState(!1),[S,ie]=t.useState(!1),[$,G]=t.useState(!1),[oe,he]=t.useState(0),[L,Q]=t.useState(()=>new Set),K=t.useRef(null),U=t.useRef(null),R=t.useMemo(()=>({query:f,matchCase:M,wholeWord:N,regex:b,includeIgnored:w}),[f,M,N,b,w]),de=t.useMemo(()=>Ie(R),[R]),v=f.trim(),C=ze(v,Te),d=xe({queryKey:je.search(l,{query:C,matchCase:M,wholeWord:N,regex:b,includeIgnored:w,revision:i,replaceRevision:oe}),queryFn:()=>J.repository.search(l,{...R,query:C}),enabled:c&&C.length>0,placeholderData:(a,s)=>s?.queryKey[1]===l?a:void 0}),n=v?d.data??null:null,z=!!v&&(C!==v||d.isFetching),V=v&&d.error?d.error instanceof Error?d.error.message:"The search failed.":null;t.useEffect(()=>{c&&K.current?.focus()},[c]),t.useEffect(()=>{d.data&&Q(new Set(d.data.files.filter(a=>a.ignored).map(a=>a.path)))},[d.data]);const I=t.useMemo(()=>{if(!n)return[];const a=[];for(const s of n.files){const u=!L.has(s.path);if(a.push({kind:"file",file:s,open:u}),u)for(const E of s.matches)a.push({kind:"match",file:s,match:E})}return a},[L,n]),T=ve({count:I.length,getScrollElement:()=>U.current,estimateSize:a=>B?44:I[a]?.kind==="file"?Ee:_e,getItemKey:a=>{const s=I[a];return s?s.kind==="file"?`file:${s.file.path}`:`match:${s.file.path}:${s.match.line}:${s.match.column??1}`:a},overscan:12});t.useEffect(()=>{T.measure()},[T,B]);const ue=a=>Q(s=>{const u=new Set(s);return u.delete(a)||u.add(a),u}),j=n?.files.filter(a=>a.ignored).length??0,y=n?.files.filter(a=>!!a.revision&&(S||!a.ignored))??[],q=async a=>{if(!n||$)return;const s=a==="all"?{kind:"all",files:y.map(r=>({path:r.path,revision:r.revision}))}:"match"in a?{kind:"match",path:a.file.path,revision:a.file.revision,line:a.match.line,column:a.match.column}:{kind:"file",path:a.path,revision:a.revision};if(s.kind==="all"){if(n.truncated){m.info({title:"Narrow the search before replacing all",description:"The current result set is truncated."});return}const r=y.reduce((F,ge)=>F+ge.matches.length,0);if(!r||!window.confirm(`Replace ${r} ${r===1?"occurrence":"occurrences"} in ${y.length} ${y.length===1?"file":"files"}?`))return}else if(s.kind==="file"&&a!=="all"&&!("match"in a)&&a.truncatedMatches&&!window.confirm(`${a.path} has more matches than the ${a.matches.length} listed. Replace every occurrence in the file?`))return;const u=s.kind==="all"?s.files.map(r=>r.path):[s.path],E=g(u);if(E.length>0){m.error({title:"Save open files before replacing in them",description:E.join(", "),duration:1e4});return}G(!0);try{const r=await J.repository.replaceSearch(l,{options:{...R,query:f.trim()},replacement:H,scope:s});r.status==="stale"?m.error({title:"Files changed before replacement",description:"Search results were refreshed without overwriting anything."}):r.status==="no-match"?m.info({title:"No matching text to replace"}):(m.success({title:`Replaced ${r.replacements} ${r.replacements===1?"occurrence":"occurrences"}`,description:`${r.files.length} ${r.files.length===1?"file":"files"} changed`}),o(r.files)),he(F=>F+1)}catch(r){m.error({title:"Could not replace search results",description:r instanceof Error?r.message:"Unknown error",duration:1e4})}finally{G(!1)}};return e.jsxs("div",{className:"search-view",children:[e.jsxs("div",{className:"search-controls",children:[e.jsxs("div",{className:"search-query-row",children:[e.jsx(k,{variant:"ghost",size:"icon-xs",className:"search-replace-toggle","aria-label":p?"Hide replace":"Show replace","aria-expanded":p,onClick:()=>ne(a=>!a),children:p?e.jsx(A,{}):e.jsx(P,{})}),e.jsxs("div",{className:"search-input",children:[e.jsx(fe,{"aria-hidden":"true"}),e.jsx("input",{ref:K,type:"text",value:f,spellCheck:!1,placeholder:"Search in repository","aria-label":"Search in repository",onChange:a=>ae(a.target.value)}),e.jsxs("span",{className:"search-toggles",children:[e.jsx(_,{label:"Match case",active:M,onToggle:()=>se(a=>!a),children:e.jsx(Me,{})}),e.jsx(_,{label:"Match whole word",active:N,onToggle:()=>te(a=>!a),children:e.jsx($e,{})}),e.jsx(_,{label:"Use regular expression",active:b,onToggle:()=>le(a=>!a),children:e.jsx(be,{})}),e.jsx(_,{label:"Search Git-ignored files",active:w,onToggle:()=>ce(a=>!a),children:e.jsx(X,{})})]})]})]}),p&&e.jsxs("div",{className:"search-replace-row",children:[e.jsx(Z,{"aria-hidden":"true"}),e.jsx("input",{value:H,spellCheck:!1,placeholder:"Replace","aria-label":"Replace with",onChange:a=>re(a.target.value)}),e.jsxs(W,{children:[e.jsx(D,{render:e.jsx(k,{variant:"ghost",size:"icon-xs",disabled:$||y.length===0||!!n?.truncated,"aria-label":"Replace all search results",onClick:()=>{q("all")}}),children:e.jsx(ee,{})}),e.jsx(O,{children:n?.truncated?"Narrow the search to replace all":"Replace all"})]})]}),p&&j>0&&e.jsxs("label",{className:"search-include-ignored",children:[e.jsx("input",{type:"checkbox",checked:S,onChange:a=>ie(a.target.checked)})," Include ignored files when replacing"]}),f.trim()!==""&&(n!==null||!z)&&e.jsx("div",{className:"search-summary",children:z?e.jsx(Y,{text:"Searching…"}):V?e.jsx("span",{className:"search-error",children:V}):n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:n.totalMatches===0?"No results":`${n.totalMatches-n.ignoredMatches}${n.truncated?"+":""} ${n.totalMatches-n.ignoredMatches===1?"result":"results"} in ${n.files.length-j} ${n.files.length-j===1?"file":"files"}`}),n.ignoredMatches>0&&e.jsxs("span",{className:"search-summary-ignored",children:["· ",n.ignoredMatches," in ",j," ignored ",j===1?"file":"files"]})]})})]}),e.jsxs("div",{ref:U,className:"search-results",children:[z&&!n&&e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(me,{className:"spinner"})," ",e.jsx(Y,{text:"Searching…"})]}),e.jsx("div",{className:"search-rows virtual-list",style:{height:T.getTotalSize()},children:T.getVirtualItems().map(a=>{const s=I[a.index];return s?e.jsx("div",{className:"virtual-row",style:{height:a.size,transform:`translateY(${a.start}px)`},children:s.kind==="file"?e.jsxs("div",{className:`search-file-heading ${s.file.ignored?"ignored":""}`,children:[e.jsxs("button",{className:"search-file-toggle",onClick:()=>ue(s.file.path),"aria-expanded":s.open,children:[s.open?e.jsx(A,{}):e.jsx(P,{}),e.jsx("span",{className:"search-file-name",children:s.file.path}),s.file.ignored&&e.jsxs(W,{children:[e.jsx(D,{render:e.jsx("span",{className:"search-file-ignored-badge"}),children:e.jsx(X,{})}),e.jsx(O,{children:"Ignored by Git"})]}),e.jsx("span",{className:"search-file-count",children:s.file.matches.length})]}),p&&s.file.revision&&(!s.file.ignored||S)&&e.jsx(k,{variant:"ghost",size:"icon-xs",className:"search-replace-action",disabled:$,"aria-label":`Replace all in ${s.file.path}`,onClick:()=>{q(s.file)},children:e.jsx(ee,{})})]}):e.jsxs("div",{className:"search-match",children:[e.jsxs("button",{className:"search-match-open",onClick:()=>h(s.file.path),children:[e.jsxs("span",{className:"search-match-line",children:[s.match.line,":",s.match.column??1]}),e.jsx("span",{className:"search-match-text",children:qe(s.match.text,de)})]}),p&&s.file.revision&&s.match.column&&(!s.file.ignored||S)&&e.jsx(k,{variant:"ghost",size:"icon-xs",className:"search-replace-action",disabled:$,"aria-label":`Replace match on line ${s.match.line}`,onClick:()=>{q({file:s.file,match:s.match})},children:e.jsx(Z,{})})]})},a.key):null})})]})]})}function ze(l,c){const[i,h]=t.useState(l);return t.useEffect(()=>{const g=window.setTimeout(()=>h(l),c);return()=>window.clearTimeout(g)},[c,l]),i}function _({label:l,active:c,onToggle:i,children:h}){return e.jsxs(W,{children:[e.jsx(D,{render:e.jsx(k,{variant:"ghost",size:"icon-xs",className:"search-toggle","aria-label":l,"aria-pressed":c,onClick:i}),children:h}),e.jsx(O,{children:l})]})}function qe(l,c){const i=l.replace(/^\s+/,"");if(!c)return i;c.lastIndex=0;const h=[];let g=0;for(let o=c.exec(i);o!==null;o=c.exec(i)){if(o[0]===""){c.lastIndex+=1;continue}h.push(e.jsx(t.Fragment,{children:i.slice(g,o.index)},`${o.index}-plain`),e.jsx("mark",{children:o[0]},`${o.index}-hit`)),g=o.index+o[0].length}return h.length===0?i:(h.push(e.jsx(t.Fragment,{children:i.slice(g)},"tail")),h)}export{He as SearchView};
1
+ import{r as t,j as e}from"./react-rd22PHbN.js";import{a7 as pe,a8 as A,V as P,j as fe,G as Y,k as me}from"./App-9EfSdZB8.js";import{u as xe,a as ve}from"./tanstack-CtfgE41X.js";import{c as x,B as k,T as W,a as D,b as O,s as m,o as J,q as je}from"./index-CQcx9aRt.js";import"./base-ui-DT3JsyND.js";const ye=[["path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828",key:"svg-0"}],["path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87",key:"svg-1"}],["path",{d:"M3 3l18 18",key:"svg-2"}]],X=x("outline","eye-off","EyeOff",ye);const ke=[["path",{d:"M14 15.5a3.5 3.5 0 1 0 7 0a3.5 3.5 0 1 0 -7 0",key:"svg-0"}],["path",{d:"M3 19v-10.5a3.5 3.5 0 0 1 7 0v10.5",key:"svg-1"}],["path",{d:"M3 13h7",key:"svg-2"}],["path",{d:"M21 12v7",key:"svg-3"}]],Me=x("outline","letter-case","LetterCase",ke);const Ne=[["path",{d:"M6.5 15a2.5 2.5 0 1 1 0 5a2.5 2.5 0 0 1 0 -5",key:"svg-0"}],["path",{d:"M17 7.875l3 -1.687",key:"svg-1"}],["path",{d:"M17 7.875v3.375",key:"svg-2"}],["path",{d:"M17 7.875l-3 -1.687",key:"svg-3"}],["path",{d:"M17 7.875l3 1.688",key:"svg-4"}],["path",{d:"M17 4.5v3.375",key:"svg-5"}],["path",{d:"M17 7.875l-3 1.688",key:"svg-6"}]],be=x("outline","regex","Regex",Ne);const we=[["path",{d:"M3 4a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",key:"svg-0"}],["path",{d:"M15 16a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",key:"svg-1"}],["path",{d:"M21 11v-3a2 2 0 0 0 -2 -2h-6l3 3m0 -6l-3 3",key:"svg-2"}],["path",{d:"M3 13v3a2 2 0 0 0 2 2h6l-3 -3m0 6l3 -3",key:"svg-3"}]],Z=x("outline","replace","Replace",we);const Se=[["path",{d:"M4 6l10 0",key:"svg-0"}],["path",{d:"M4 18l10 0",key:"svg-1"}],["path",{d:"M4 12h17l-3 -3m0 6l3 -3",key:"svg-2"}]],$e=x("outline","text-wrap-disabled","TextWrapDisabled",Se);const Re=[["path",{d:"M8 2h-4a2 2 0 0 0 -2 2v4a2 2 0 0 0 2 2h4a2 2 0 0 0 2 -2v-4a2 2 0 0 0 -2 -2z",key:"svg-0"}],["path",{d:"M20 14h-4a2 2 0 0 0 -2 2v4a2 2 0 0 0 2 2h4a2 2 0 0 0 2 -2v-4a2 2 0 0 0 -2 -2z",key:"svg-1"}],["path",{d:"M16.707 2.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.293 1.293h3.586a3 3 0 0 1 2.995 2.824l.005 .176v3a1 1 0 0 1 -1.993 .117l-.007 -.117v-3a1 1 0 0 0 -.883 -.993l-.117 -.007h-3.585l1.292 1.293a1 1 0 0 1 -1.32 1.497l-.094 -.083l-3 -3a.98 .98 0 0 1 -.28 -.872l.036 -.146l.04 -.104c.058 -.126 .14 -.24 .245 -.334l2.959 -2.958a1 1 0 0 1 1.414 0z",key:"svg-2"}],["path",{d:"M3 12a1 1 0 0 1 .993 .883l.007 .117v3a1 1 0 0 0 .883 .993l.117 .007h3.585l-1.292 -1.293a1 1 0 0 1 -.083 -1.32l.083 -.094a1 1 0 0 1 1.32 -.083l.094 .083l3 3a.98 .98 0 0 1 .28 .872l-.036 .146l-.04 .104a1.02 1.02 0 0 1 -.245 .334l-2.959 2.958a1 1 0 0 1 -1.497 -1.32l.083 -.094l1.291 -1.293h-3.584a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-3a1 1 0 0 1 1 -1z",key:"svg-3"}]],ee=x("filled","replace-filled","ReplaceFilled",Re);function Ce(l){return l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ie(l){if(!l.query)return null;const c=l.regex?l.query:Ce(l.query),i=l.wholeWord?`\\b(?:${c})\\b`:c;try{return new RegExp(i,l.matchCase?"g":"gi")}catch{return null}}const Te=250,Ee=28,_e=24;function He({repositoryId:l,active:c,revision:i,onOpenFile:h,unsavedPathsAmong:g,onReplaced:o}){const B=pe(),[f,ae]=t.useState(""),[M,se]=t.useState(!1),[N,te]=t.useState(!1),[b,le]=t.useState(!1),[p,ne]=t.useState(!1),[H,re]=t.useState(""),[w,ce]=t.useState(!1),[S,ie]=t.useState(!1),[$,G]=t.useState(!1),[oe,he]=t.useState(0),[L,Q]=t.useState(()=>new Set),V=t.useRef(null),K=t.useRef(null),R=t.useMemo(()=>({query:f,matchCase:M,wholeWord:N,regex:b,includeIgnored:w}),[f,M,N,b,w]),de=t.useMemo(()=>Ie(R),[R]),v=f.trim(),C=ze(v,Te),d=xe({queryKey:je.search(l,{query:C,matchCase:M,wholeWord:N,regex:b,includeIgnored:w,revision:i,replaceRevision:oe}),queryFn:()=>J.repository.search(l,{...R,query:C}),enabled:c&&C.length>0,placeholderData:(a,s)=>s?.queryKey[1]===l?a:void 0}),n=v?d.data??null:null,z=!!v&&(C!==v||d.isFetching),U=v&&d.error?d.error instanceof Error?d.error.message:"The search failed.":null;t.useEffect(()=>{c&&V.current?.focus()},[c]),t.useEffect(()=>{d.data&&Q(new Set(d.data.files.filter(a=>a.ignored).map(a=>a.path)))},[d.data]);const I=t.useMemo(()=>{if(!n)return[];const a=[];for(const s of n.files){const u=!L.has(s.path);if(a.push({kind:"file",file:s,open:u}),u)for(const E of s.matches)a.push({kind:"match",file:s,match:E})}return a},[L,n]),T=ve({count:I.length,getScrollElement:()=>K.current,estimateSize:a=>B?44:I[a]?.kind==="file"?Ee:_e,getItemKey:a=>{const s=I[a];return s?s.kind==="file"?`file:${s.file.path}`:`match:${s.file.path}:${s.match.line}:${s.match.column??1}`:a},overscan:12});t.useEffect(()=>{T.measure()},[T,B]);const ue=a=>Q(s=>{const u=new Set(s);return u.delete(a)||u.add(a),u}),j=n?.files.filter(a=>a.ignored).length??0,y=n?.files.filter(a=>!!a.revision&&(S||!a.ignored))??[],q=async a=>{if(!n||$)return;const s=a==="all"?{kind:"all",files:y.map(r=>({path:r.path,revision:r.revision}))}:"match"in a?{kind:"match",path:a.file.path,revision:a.file.revision,line:a.match.line,column:a.match.column}:{kind:"file",path:a.path,revision:a.revision};if(s.kind==="all"){if(n.truncated){m.info({title:"Narrow the search before replacing all",description:"The current result set is truncated."});return}const r=y.reduce((F,ge)=>F+ge.matches.length,0);if(!r||!window.confirm(`Replace ${r} ${r===1?"occurrence":"occurrences"} in ${y.length} ${y.length===1?"file":"files"}?`))return}else if(s.kind==="file"&&a!=="all"&&!("match"in a)&&a.truncatedMatches&&!window.confirm(`${a.path} has more matches than the ${a.matches.length} listed. Replace every occurrence in the file?`))return;const u=s.kind==="all"?s.files.map(r=>r.path):[s.path],E=g(u);if(E.length>0){m.error({title:"Save open files before replacing in them",description:E.join(", "),duration:1e4});return}G(!0);try{const r=await J.repository.replaceSearch(l,{options:{...R,query:f.trim()},replacement:H,scope:s});r.status==="stale"?m.error({title:"Files changed before replacement",description:"Search results were refreshed without overwriting anything."}):r.status==="no-match"?m.info({title:"No matching text to replace"}):(m.success({title:`Replaced ${r.replacements} ${r.replacements===1?"occurrence":"occurrences"}`,description:`${r.files.length} ${r.files.length===1?"file":"files"} changed`}),o(r.files)),he(F=>F+1)}catch(r){m.error({title:"Could not replace search results",description:r instanceof Error?r.message:"Unknown error",duration:1e4})}finally{G(!1)}};return e.jsxs("div",{className:"search-view",children:[e.jsxs("div",{className:"search-controls",children:[e.jsxs("div",{className:"search-query-row",children:[e.jsx(k,{variant:"ghost",size:"icon-xs",className:"search-replace-toggle","aria-label":p?"Hide replace":"Show replace","aria-expanded":p,onClick:()=>ne(a=>!a),children:p?e.jsx(A,{}):e.jsx(P,{})}),e.jsxs("div",{className:"search-input",children:[e.jsx(fe,{"aria-hidden":"true"}),e.jsx("input",{ref:V,type:"text",value:f,spellCheck:!1,placeholder:"Search in repository","aria-label":"Search in repository",onChange:a=>ae(a.target.value)}),e.jsxs("span",{className:"search-toggles",children:[e.jsx(_,{label:"Match case",active:M,onToggle:()=>se(a=>!a),children:e.jsx(Me,{})}),e.jsx(_,{label:"Match whole word",active:N,onToggle:()=>te(a=>!a),children:e.jsx($e,{})}),e.jsx(_,{label:"Use regular expression",active:b,onToggle:()=>le(a=>!a),children:e.jsx(be,{})}),e.jsx(_,{label:"Search Git-ignored files",active:w,onToggle:()=>ce(a=>!a),children:e.jsx(X,{})})]})]})]}),p&&e.jsxs("div",{className:"search-replace-row",children:[e.jsx(Z,{"aria-hidden":"true"}),e.jsx("input",{value:H,spellCheck:!1,placeholder:"Replace","aria-label":"Replace with",onChange:a=>re(a.target.value)}),e.jsxs(W,{children:[e.jsx(D,{render:e.jsx(k,{variant:"ghost",size:"icon-xs",disabled:$||y.length===0||!!n?.truncated,"aria-label":"Replace all search results",onClick:()=>{q("all")}}),children:e.jsx(ee,{})}),e.jsx(O,{children:n?.truncated?"Narrow the search to replace all":"Replace all"})]})]}),p&&j>0&&e.jsxs("label",{className:"search-include-ignored",children:[e.jsx("input",{type:"checkbox",checked:S,onChange:a=>ie(a.target.checked)})," Include ignored files when replacing"]}),f.trim()!==""&&(n!==null||!z)&&e.jsx("div",{className:"search-summary",children:z?e.jsx(Y,{text:"Searching…"}):U?e.jsx("span",{className:"search-error",children:U}):n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:n.totalMatches===0?"No results":`${n.totalMatches-n.ignoredMatches}${n.truncated?"+":""} ${n.totalMatches-n.ignoredMatches===1?"result":"results"} in ${n.files.length-j} ${n.files.length-j===1?"file":"files"}`}),n.ignoredMatches>0&&e.jsxs("span",{className:"search-summary-ignored",children:["· ",n.ignoredMatches," in ",j," ignored ",j===1?"file":"files"]})]})})]}),e.jsxs("div",{ref:K,className:"search-results",children:[z&&!n&&e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(me,{className:"spinner"})," ",e.jsx(Y,{text:"Searching…"})]}),e.jsx("div",{className:"search-rows virtual-list",style:{height:T.getTotalSize()},children:T.getVirtualItems().map(a=>{const s=I[a.index];return s?e.jsx("div",{className:"virtual-row",style:{height:a.size,transform:`translateY(${a.start}px)`},children:s.kind==="file"?e.jsxs("div",{className:`search-file-heading ${s.file.ignored?"ignored":""}`,children:[e.jsxs("button",{className:"search-file-toggle",onClick:()=>ue(s.file.path),"aria-expanded":s.open,children:[s.open?e.jsx(A,{}):e.jsx(P,{}),e.jsx("span",{className:"search-file-name",children:s.file.path}),s.file.ignored&&e.jsxs(W,{children:[e.jsx(D,{render:e.jsx("span",{className:"search-file-ignored-badge"}),children:e.jsx(X,{})}),e.jsx(O,{children:"Ignored by Git"})]}),e.jsx("span",{className:"search-file-count",children:s.file.matches.length})]}),p&&s.file.revision&&(!s.file.ignored||S)&&e.jsx(k,{variant:"ghost",size:"icon-xs",className:"search-replace-action",disabled:$,"aria-label":`Replace all in ${s.file.path}`,onClick:()=>{q(s.file)},children:e.jsx(ee,{})})]}):e.jsxs("div",{className:"search-match",children:[e.jsxs("button",{className:"search-match-open",onClick:()=>h(s.file.path),children:[e.jsxs("span",{className:"search-match-line",children:[s.match.line,":",s.match.column??1]}),e.jsx("span",{className:"search-match-text",children:qe(s.match.text,de)})]}),p&&s.file.revision&&s.match.column&&(!s.file.ignored||S)&&e.jsx(k,{variant:"ghost",size:"icon-xs",className:"search-replace-action",disabled:$,"aria-label":`Replace match on line ${s.match.line}`,onClick:()=>{q({file:s.file,match:s.match})},children:e.jsx(Z,{})})]})},a.key):null})})]})]})}function ze(l,c){const[i,h]=t.useState(l);return t.useEffect(()=>{const g=window.setTimeout(()=>h(l),c);return()=>window.clearTimeout(g)},[c,l]),i}function _({label:l,active:c,onToggle:i,children:h}){return e.jsxs(W,{children:[e.jsx(D,{render:e.jsx(k,{variant:"ghost",size:"icon-xs",className:"search-toggle","aria-label":l,"aria-pressed":c,onClick:i}),children:h}),e.jsx(O,{children:l})]})}function qe(l,c){const i=l.replace(/^\s+/,"");if(!c)return i;c.lastIndex=0;const h=[];let g=0;for(let o=c.exec(i);o!==null;o=c.exec(i)){if(o[0]===""){c.lastIndex+=1;continue}h.push(e.jsx(t.Fragment,{children:i.slice(g,o.index)},`${o.index}-plain`),e.jsx("mark",{children:o[0]},`${o.index}-hit`)),g=o.index+o[0].length}return h.length===0?i:(h.push(e.jsx(t.Fragment,{children:i.slice(g)},"tail")),h)}export{He as SearchView};
@@ -0,0 +1,9 @@
1
+ import{r as m,j as e}from"./react-rd22PHbN.js";import{M as Cs,i as ge,u as qe,g as Xe,h as Ss,j as Ms,L as Es,k as Rs,l as Is,p as As,c as L,d as ne,o as oe,s as M,B as w,T as _,a as D,b as B,I as Le,w as $e,m as Pe}from"./index-CQcx9aRt.js";import{D as K,c as Y,d as q,e as X,k as Z,l as ue,y as Se,g as J,I as Me,G as Ee,B as te,az as Ts,aA as me,aB as Fe,W as Je,aC as Ze,aD as Qe,aE as Os,aF as ze,aG as Ls,aH as $s,m as Re,S as je,C as ve,A as be,E as ye,aI as Ps,F as we,aJ as ae,aK as Fs,i as zs,aL as _s,aM as Ds,aN as Bs,aO as Gs,P as Us,N as Hs,aP as Vs}from"./App-9EfSdZB8.js";import{b as es,t as ss,c as ts,r as ns,d as as}from"./tanstack-CtfgE41X.js";import{I as Ws}from"./IconEdit-DePJMGIi.js";import"./base-ui-DT3JsyND.js";function _e(s,t){if(typeof s=="function")return s(t);s!=null&&(s.current=t)}function Ks(...s){return t=>{let n=!1;const a=s.map(i=>{const o=_e(i,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<a.length;i++){const o=a[i];typeof o=="function"?o():_e(s[i],null)}}}}function Ys(...s){return m.useCallback(Ks(...s),s)}class qs extends m.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(ge(n)&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const a=n.offsetParent,i=ge(a)&&a.offsetWidth||0,o=ge(a)&&a.offsetHeight||0,r=getComputedStyle(n),c=this.props.sizeRef.current;c.height=parseFloat(r.height),c.width=parseFloat(r.width),c.top=n.offsetTop,c.left=n.offsetLeft,c.right=i-c.width-c.left,c.bottom=o-c.height-c.top,c.direction=r.direction}return null}componentDidUpdate(){}render(){return this.props.children}}function Xs({children:s,isPresent:t,anchorX:n,anchorY:a,root:i,pop:o}){const r=m.useId(),c=m.useRef(null),h=m.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:"ltr"}),{nonce:f}=m.useContext(Cs),p=o!==!1?s.props?.ref??s?.ref:void 0,g=Ys(c,p);return m.useInsertionEffect(()=>{const{width:l,height:x,top:j,left:b,right:y,bottom:E,direction:k}=h.current;if(t||o===!1||!c.current||!l||!x)return;const T=k==="rtl",C=n==="left"?T?`right: ${y}`:`left: ${b}`:T?`left: ${b}`:`right: ${y}`,I=a==="bottom"?`bottom: ${E}`:`top: ${j}`;c.current.dataset.motionPopId=r;const R=document.createElement("style");f&&(R.nonce=f);const $=i??document.head;return $.appendChild(R),R.sheet&&R.sheet.insertRule(`
2
+ [data-motion-pop-id="${r}"] {
3
+ position: absolute !important;
4
+ width: ${l}px !important;
5
+ height: ${x}px !important;
6
+ ${C}px !important;
7
+ ${I}px !important;
8
+ }
9
+ `),()=>{c.current?.removeAttribute("data-motion-pop-id"),$.contains(R)&&$.removeChild(R)}},[t]),e.jsx(qs,{isPresent:t,childRef:c,sizeRef:h,pop:o,children:o===!1?s:m.cloneElement(s,{ref:g})})}const Js=({children:s,initial:t,isPresent:n,onExitComplete:a,custom:i,presenceAffectsLayout:o,mode:r,anchorX:c,anchorY:h,root:f})=>{const p=qe(Zs),g=m.useId(),l=m.useRef(n),x=m.useRef(a);Xe(()=>{l.current=n,x.current=a});let j=!0,b=m.useMemo(()=>(j=!1,{id:g,initial:t,isPresent:n,custom:i,onExitComplete:y=>{p.set(y,!0);for(const E of p.values())if(!E)return;a&&a()},register:y=>(p.set(y,!1),()=>{p.delete(y),!l.current&&!p.size&&x.current?.()})}),[n,p,a]);return o&&j&&(b={...b}),m.useMemo(()=>{p.forEach((y,E)=>p.set(E,!1))},[n]),m.useEffect(()=>{!n&&!p.size&&a&&a()},[n]),s=e.jsx(Xs,{pop:r==="popLayout",isPresent:n,anchorX:c,anchorY:h,root:f,children:s}),e.jsx(Ss.Provider,{value:b,children:s})};function Zs(){return new Map}const re=s=>s.key||"";function De(s){const t=[];return m.Children.forEach(s,n=>{m.isValidElement(n)&&t.push(n)}),t}const Be=({children:s,custom:t,initial:n=!0,onExitComplete:a,presenceAffectsLayout:i=!0,mode:o="sync",propagate:r=!1,anchorX:c="left",anchorY:h="top",root:f})=>{const[p,g]=Ms(r),l=m.useMemo(()=>De(s),[s]),x=r&&!p?[]:l.map(re),j=m.useRef(!0),b=m.useRef(l),y=qe(()=>new Map),E=m.useRef(new Set),[k,T]=m.useState(l),[C,I]=m.useState(l);Xe(()=>{j.current=!1,b.current=l;for(let A=0;A<C.length;A++){const N=re(C[A]);x.includes(N)?(y.delete(N),E.current.delete(N)):y.get(N)!==!0&&y.set(N,!1)}},[C,x.length,x.join("-")]);const R=[];if(l!==k){let A=[...l];for(let N=0;N<C.length;N++){const P=C[N],d=re(P);x.includes(d)||(A.splice(N,0,P),R.push(P))}return o==="wait"&&R.length&&(A=R),I(De(A)),T(l),null}const{forceRender:$}=m.useContext(Es);return e.jsx(e.Fragment,{children:C.map(A=>{const N=re(A),P=r&&!p?!1:l===C||x.includes(N),d=()=>{if(E.current.has(N))return;if(y.has(N))E.current.add(N),y.set(N,!0);else return;let v=!0;y.forEach(S=>{S||(v=!1)}),v&&($?.(),I(b.current),r&&g?.(),a&&a())};return e.jsx(Js,{isPresent:P,initial:!j.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:o,root:f,onExitComplete:P?void 0:d,anchorX:c,anchorY:h,children:A},N)})})};function Qs(){!Rs.current&&Is();const[s]=m.useState(As.current);return s}const et=[["path",{d:"M3 9l4 -4l4 4m-4 -4v14",key:"svg-0"}],["path",{d:"M21 15l-4 4l-4 -4m4 4v-14",key:"svg-1"}]],is=L("outline","arrows-sort","ArrowsSort",et);const st=[["path",{d:"M4 8h16",key:"svg-0"}],["path",{d:"M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12",key:"svg-1"}],["path",{d:"M8 4v4",key:"svg-2"}]],tt=L("outline","browser","Browser",st);const nt=[["path",{d:"M3 5a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10",key:"svg-0"}],["path",{d:"M7 20h10",key:"svg-1"}],["path",{d:"M9 16v4",key:"svg-2"}],["path",{d:"M15 16v4",key:"svg-3"}]],os=L("outline","device-desktop","DeviceDesktop",nt);const at=[["path",{d:"M2 8a2 2 0 0 1 2 -2h16a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-16a2 2 0 0 1 -2 -2l0 -8",key:"svg-0"}],["path",{d:"M6 10l0 .01",key:"svg-1"}],["path",{d:"M10 10l0 .01",key:"svg-2"}],["path",{d:"M14 10l0 .01",key:"svg-3"}],["path",{d:"M18 10l0 .01",key:"svg-4"}],["path",{d:"M6 14l0 .01",key:"svg-5"}],["path",{d:"M18 14l0 .01",key:"svg-6"}],["path",{d:"M10 14l4 .01",key:"svg-7"}]],it=L("outline","keyboard","Keyboard",at);const ot=[["path",{d:"M9 15l6 -6",key:"svg-0"}],["path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464",key:"svg-1"}],["path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463",key:"svg-2"}]],rt=L("outline","link","Link",ot);const lt=[["path",{d:"M9 6l11 0",key:"svg-0"}],["path",{d:"M9 12l11 0",key:"svg-1"}],["path",{d:"M9 18l11 0",key:"svg-2"}],["path",{d:"M5 6l0 .01",key:"svg-3"}],["path",{d:"M5 12l0 .01",key:"svg-4"}],["path",{d:"M5 18l0 .01",key:"svg-5"}]],ct=L("outline","list","List",lt);const dt=[["path",{d:"M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454l0 .008",key:"svg-0"}]],ht=L("outline","moon","Moon",dt);const ut=[["path",{d:"M6 9a6 6 0 1 0 12 0a6 6 0 0 0 -12 0",key:"svg-0"}],["path",{d:"M12 3c1.333 .333 2 2.333 2 6s-.667 5.667 -2 6",key:"svg-1"}],["path",{d:"M12 3c-1.333 .333 -2 2.333 -2 6s.667 5.667 2 6",key:"svg-2"}],["path",{d:"M6 9h12",key:"svg-3"}],["path",{d:"M3 20h7",key:"svg-4"}],["path",{d:"M14 20h7",key:"svg-5"}],["path",{d:"M10 20a2 2 0 1 0 4 0a2 2 0 0 0 -4 0",key:"svg-6"}],["path",{d:"M12 15v3",key:"svg-7"}]],gt=L("outline","network","Network",ut);const mt=[["path",{d:"M4 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",key:"svg-0"}],["path",{d:"M7 17l0 .01",key:"svg-1"}],["path",{d:"M14 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",key:"svg-2"}],["path",{d:"M7 7l0 .01",key:"svg-3"}],["path",{d:"M4 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",key:"svg-4"}],["path",{d:"M17 7l0 .01",key:"svg-5"}],["path",{d:"M14 14l3 0",key:"svg-6"}],["path",{d:"M20 14l0 .01",key:"svg-7"}],["path",{d:"M14 14l0 3",key:"svg-8"}],["path",{d:"M14 20l3 0",key:"svg-9"}],["path",{d:"M17 17l3 0",key:"svg-10"}],["path",{d:"M20 17l0 3",key:"svg-11"}]],pt=L("outline","qrcode","Qrcode",mt);const ft=[["path",{d:"M12 3a12 12 0 0 0 8.5 3a12 12 0 0 1 -8.5 15a12 12 0 0 1 -8.5 -15a12 12 0 0 0 8.5 -3",key:"svg-0"}],["path",{d:"M11 11a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M12 12l0 2.5",key:"svg-2"}]],Ge=L("outline","shield-lock","ShieldLock",ft);const xt=[["path",{d:"M4 6l7 0",key:"svg-0"}],["path",{d:"M4 12l7 0",key:"svg-1"}],["path",{d:"M4 18l9 0",key:"svg-2"}],["path",{d:"M15 9l3 -3l3 3",key:"svg-3"}],["path",{d:"M18 6l0 12",key:"svg-4"}]],rs=L("outline","sort-ascending","SortAscending",xt);const jt=[["path",{d:"M4 6l9 0",key:"svg-0"}],["path",{d:"M4 12l7 0",key:"svg-1"}],["path",{d:"M4 18l7 0",key:"svg-2"}],["path",{d:"M15 15l3 3l3 -3",key:"svg-3"}],["path",{d:"M18 6l0 12",key:"svg-4"}]],ls=L("outline","sort-descending","SortDescending",jt);const vt=[["path",{d:"M16 18a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2m0 -12a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2m-7 12a6 6 0 0 1 6 -6a6 6 0 0 1 -6 -6a6 6 0 0 1 -6 6a6 6 0 0 1 6 6",key:"svg-0"}]],cs=L("outline","sparkles","Sparkles",vt);const bt=[["path",{d:"M8 12a4 4 0 1 0 8 0a4 4 0 1 0 -8 0",key:"svg-0"}],["path",{d:"M3 12h1m8 -9v1m8 8h1m-9 8v1m-6.4 -15.4l.7 .7m12.1 -.7l-.7 .7m0 11.4l.7 .7m-12.1 -.7l-.7 .7",key:"svg-1"}]],yt=L("outline","sun","Sun",bt);function ds({className:s,...t}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full",children:e.jsx("table",{"data-slot":"table",className:ne("w-full caption-bottom text-xs",s),...t})})}function hs({className:s,...t}){return e.jsx("thead",{"data-slot":"table-header",className:ne("[&_tr]:border-b",s),...t})}function us({className:s,...t}){return e.jsx("tbody",{"data-slot":"table-body",className:ne("[&_tr:last-child]:border-0",s),...t})}function he({className:s,...t}){return e.jsx("tr",{"data-slot":"table-row",className:ne("border-b border-border transition-colors hover:bg-muted/40 data-[state=selected]:bg-muted",s),...t})}function gs({className:s,...t}){return e.jsx("th",{"data-slot":"table-head",className:ne("h-8 whitespace-nowrap px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",s),...t})}function ms({className:s,...t}){return e.jsx("td",{"data-slot":"table-cell",className:ne("px-2 py-1.5 align-middle [&:has([role=checkbox])]:pr-0",s),...t})}const wt={"commit-message":"commit message","pull-request-draft":"pull request draft"};function H({column:s,label:t}){const n=s.getIsSorted();return e.jsxs("button",{type:"button",className:"ai-log-sort-button",onClick:()=>s.toggleSorting(n==="asc"),children:[t,n==="asc"&&e.jsx(rs,{size:13}),n==="desc"&&e.jsx(ls,{size:13}),!n&&e.jsx(is,{size:13,className:"ai-log-sort-idle"})]})}const kt=ss({rowSortingFeature:ns,sortedRowModel:as()}),F=ts(),Nt=F.columns([F.accessor("status",{header:({column:s})=>e.jsx(H,{column:s,label:"Status"}),cell:({getValue:s})=>{const t=s();return e.jsx(te,{variant:t==="success"?"secondary":t==="cancelled"?"outline":"destructive",children:t})}}),F.accessor("harness",{header:({column:s})=>e.jsx(H,{column:s,label:"Harness"}),cell:({getValue:s})=>e.jsx("strong",{children:s()})}),F.accessor("model",{header:({column:s})=>e.jsx(H,{column:s,label:"Model"}),cell:({getValue:s})=>e.jsx("span",{className:"ai-log-model",children:s()})}),F.accessor("operation",{header:({column:s})=>e.jsx(H,{column:s,label:"Task"}),cell:({getValue:s})=>wt[s()]}),F.accessor(s=>new Date(s.at).getTime(),{id:"at",header:({column:s})=>e.jsx(H,{column:s,label:"Date"}),cell:({row:s})=>e.jsx("time",{dateTime:s.original.at,children:new Date(s.original.at).toLocaleString()})}),F.accessor("durationMs",{header:({column:s})=>e.jsx(H,{column:s,label:"Duration"}),cell:({getValue:s})=>`${(s()/1e3).toFixed(1)}s`}),F.accessor(s=>(s.usage.inputTokens??0)+(s.usage.outputTokens??0),{id:"usage",header:({column:s})=>e.jsx(H,{column:s,label:"Usage"}),cell:({row:s})=>Mt(s.original)}),F.accessor("stagedFileCount",{header:({column:s})=>e.jsx(H,{column:s,label:"Staged"}),cell:({getValue:s})=>s()??"—"}),F.display({id:"notes",header:"Notes",cell:({row:s})=>{const t=s.original,n=[];return t.errorCode&&n.push({key:"error",text:t.errorCode,tone:"error"}),t.errorMessage&&n.push({key:"error-message",text:t.errorMessage,tone:"error",detail:t.errorMessage}),t.splitOffered===!0&&n.push({key:"split",text:`split: ${t.splitGroups} commits`}),t.splitRejectedReason&&n.push({key:"rejected",text:`split refused: ${t.splitRejectedReason}`,tone:"warn",detail:t.splitRejectedReason}),t.splitBlockedReason&&n.push({key:"blocked",text:`no split: ${t.splitBlockedReason}`,detail:t.splitBlockedReason}),t.contextTruncated===!0&&n.push({key:"truncated",text:"context trimmed"}),n.length===0?null:e.jsx("div",{className:"ai-log-row-notes",children:n.map(a=>e.jsx(St,{text:a.text,tone:a.tone,detail:a.detail},a.key))})}})]);function Ct({open:s,onOpenChange:t}){const[n,a]=m.useState([]),[i,o]=m.useState(!1),[r,c]=m.useState([]),h=m.useCallback(async()=>{o(!0);try{a(await oe.ai.log())}catch(l){M.error({title:"Could not read the AI history",description:He(l)})}finally{o(!1)}},[]);m.useEffect(()=>{s&&h()},[h,s]);const f=m.useMemo(()=>{const l=n.filter(x=>x.status==="failed").length;return{runs:n.length,failed:l,tokens:n.reduce((x,j)=>x+(j.usage.inputTokens??0)+(j.usage.outputTokens??0),0),cost:n.reduce((x,j)=>x+(j.usage.costUsd??0),0),costed:n.filter(x=>x.usage.costUsd!==null).length}},[n]),p=es({features:kt,data:n,columns:Nt,onSortingChange:c,state:{sorting:r}}),g=async()=>{if(window.confirm("Delete the whole AI history? This cannot be undone."))try{await oe.ai.clearLog(),a([])}catch(l){M.error({title:"Could not clear the AI history",description:He(l)})}};return e.jsx(K,{open:s,onOpenChange:t,children:e.jsxs(Y,{className:"ai-log-dialog",children:[e.jsxs("header",{className:"ai-log-header",children:[e.jsxs("div",{children:[e.jsx(q,{children:"AI history"}),e.jsx(X,{children:"Recent generations on this machine. Prompts and file contents are never recorded."})]}),e.jsxs("div",{className:"ai-log-header-actions",children:[e.jsxs(w,{variant:"outline",size:"sm",disabled:i,onClick:()=>{h()},children:[i?e.jsx(Z,{className:"animate-spin"}):e.jsx(ue,{})," Refresh"]}),e.jsxs(w,{variant:"ghost",size:"sm",disabled:n.length===0,onClick:()=>{g()},children:[e.jsx(Se,{})," Clear"]}),e.jsx(J,{render:e.jsx(w,{variant:"ghost",size:"icon-sm","aria-label":"Close AI history"}),children:e.jsx(Me,{})})]})]}),n.length>0&&e.jsxs("div",{className:"ai-log-totals",children:[e.jsxs("span",{children:[e.jsx("strong",{children:f.runs})," runs"]}),e.jsxs("span",{children:[e.jsx("strong",{children:f.failed})," failed"]}),e.jsxs("span",{children:[e.jsx("strong",{children:ke(f.tokens)})," tokens"]}),f.costed>0&&e.jsxs("span",{children:[e.jsxs("strong",{children:["$",f.cost.toFixed(4)]})," reported by ",f.costed," of ",f.runs]})]}),e.jsxs("div",{className:"ai-log-body",children:[i&&n.length===0&&e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(Z,{className:"spinner"})," ",e.jsx(Ee,{text:"Reading history…"})]}),!i&&n.length===0&&e.jsx("p",{className:"ai-log-empty",children:"No generations recorded yet. Generate a commit message and it will show up here."}),n.length>0&&e.jsx("div",{className:"ai-log-table-wrap",children:e.jsxs(ds,{children:[e.jsx(hs,{children:p.getHeaderGroups().map(l=>e.jsx(he,{children:l.headers.map(x=>e.jsx(gs,{children:x.isPlaceholder?null:e.jsx(p.FlexRender,{header:x})},x.id))},l.id))}),e.jsx(us,{children:p.getRowModel().rows.map(l=>e.jsx(he,{className:l.original.status==="failed"?"ai-log-row-failed":void 0,children:l.getAllCells().map(x=>e.jsx(ms,{children:e.jsx(p.FlexRender,{cell:x})},x.id))},l.id))})]})})]})]})})}const Ue=140;function St({text:s,tone:t,detail:n}){const[a,i]=m.useState(!1),o=s.length>Ue?`${s.slice(0,Ue-1)}…`:s,r=`ai-log-note ${t??""}`;return n?e.jsxs(e.Fragment,{children:[e.jsxs(_,{children:[e.jsx(D,{render:e.jsx("button",{type:"button",className:r,onClick:()=>i(!0),"aria-label":"Read generation details"}),children:o}),e.jsx(B,{className:"max-w-md",children:n})]}),e.jsx(K,{open:a,onOpenChange:i,children:e.jsx(Y,{className:"name-dialog",children:e.jsxs("div",{className:"name-dialog-content",children:[e.jsx(q,{children:"Generation details"}),e.jsx(X,{className:"whitespace-pre-wrap break-words",children:n}),e.jsx("div",{className:"name-dialog-actions",children:e.jsx(J,{render:e.jsx(w,{variant:"outline"}),children:"Close"})})]})})})]}):e.jsx("span",{className:r,children:o})}function Mt(s){const{inputTokens:t,outputTokens:n,costUsd:a}=s.usage;if(t===null&&n===null)return"no usage reported";const i=`${ke(t??0)} in · ${ke(n??0)} out`;return a===null?i:`${i} · $${a.toFixed(4)}`}function ke(s){return s>=1e3?`${(s/1e3).toFixed(1)}k`:String(s)}function He(s){return s instanceof Error?s.message:"An unexpected error occurred."}function ie({column:s,label:t}){const n=s.getIsSorted();return e.jsxs("button",{type:"button",className:"ai-log-sort-button",onClick:()=>s.toggleSorting(n==="asc"),children:[t,n==="asc"&&e.jsx(rs,{size:13}),n==="desc"&&e.jsx(ls,{size:13}),!n&&e.jsx(is,{size:13,className:"ai-log-sort-idle"})]})}const Et=ss({rowSortingFeature:ns,sortedRowModel:as()}),se=ts(),Rt=se.columns([se.accessor("level",{header:({column:s})=>e.jsx(ie,{column:s,label:"Level"}),cell:({getValue:s})=>{const t=s();return e.jsx(te,{variant:t==="warn"?"outline":"destructive",children:t})}}),se.accessor("operation",{header:({column:s})=>e.jsx(ie,{column:s,label:"Operation"}),cell:({getValue:s})=>e.jsx("strong",{children:s()})}),se.accessor("code",{header:({column:s})=>e.jsx(ie,{column:s,label:"Code"}),cell:({getValue:s})=>s()??"—"}),se.accessor(s=>new Date(s.at).getTime(),{id:"at",header:({column:s})=>e.jsx(ie,{column:s,label:"Date"}),cell:({row:s})=>e.jsx("time",{dateTime:s.original.at,children:new Date(s.original.at).toLocaleString()})}),se.accessor("message",{header:({column:s})=>e.jsx(ie,{column:s,label:"Message"}),cell:({getValue:s})=>e.jsx("span",{className:"ai-log-model",children:s()})})]);function Ve(s){return s instanceof Error?s.message:"An unexpected error occurred."}function It({open:s,onOpenChange:t}){const[n,a]=m.useState([]),[i,o]=m.useState(!1),[r,c]=m.useState([]),h=m.useCallback(async()=>{o(!0);try{a(await oe.diagnostics.list())}catch(l){M.error({title:"Could not read local problems",description:Ve(l)})}finally{o(!1)}},[]);m.useEffect(()=>{s&&h()},[h,s]);const f=m.useMemo(()=>({all:n.length,errors:n.filter(l=>l.level==="error").length}),[n]),p=es({features:Et,data:n,columns:Rt,onSortingChange:c,state:{sorting:r}}),g=async()=>{if(window.confirm("Delete the local problem history? This cannot be undone."))try{await oe.diagnostics.clear(),a([])}catch(l){M.error({title:"Could not clear local problems",description:Ve(l)})}};return e.jsx(K,{open:s,onOpenChange:t,children:e.jsxs(Y,{className:"ai-log-dialog",children:[e.jsxs("header",{className:"ai-log-header",children:[e.jsxs("div",{children:[e.jsx(q,{children:"Problem history"}),e.jsx(X,{children:"Recent local failures on this machine. Prompts and file contents are never recorded."})]}),e.jsxs("div",{className:"ai-log-header-actions",children:[e.jsxs(w,{variant:"outline",size:"sm",disabled:i,onClick:()=>{h()},children:[i?e.jsx(Z,{className:"animate-spin"}):e.jsx(ue,{})," Refresh"]}),e.jsxs(w,{variant:"ghost",size:"sm",disabled:n.length===0,onClick:()=>{g()},children:[e.jsx(Se,{})," Clear"]}),e.jsx(J,{render:e.jsx(w,{variant:"ghost",size:"icon-sm","aria-label":"Close problem history"}),children:e.jsx(Me,{})})]})]}),n.length>0&&e.jsxs("div",{className:"ai-log-totals",children:[e.jsxs("span",{children:[e.jsx("strong",{children:f.all})," recorded"]}),e.jsxs("span",{children:[e.jsx("strong",{children:f.errors})," errors"]})]}),e.jsxs("div",{className:"ai-log-body",children:[i&&n.length===0&&e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(Z,{className:"spinner"})," ",e.jsx(Ee,{text:"Reading problems…"})]}),!i&&n.length===0&&e.jsx("p",{className:"ai-log-empty",children:"No local problems recorded yet. Failed Git, file, and network operations will show up here."}),n.length>0&&e.jsx("div",{className:"ai-log-table-wrap",children:e.jsxs(ds,{children:[e.jsx(hs,{children:p.getHeaderGroups().map(l=>e.jsx(he,{children:l.headers.map(x=>e.jsx(gs,{children:x.isPlaceholder?null:e.jsx(p.FlexRender,{header:x})},x.id))},l.id))}),e.jsx(us,{children:p.getRowModel().rows.map(l=>e.jsx(he,{className:l.original.level==="error"?"ai-log-row-failed":void 0,children:l.getAllCells().map(x=>e.jsx(ms,{children:e.jsx(p.FlexRender,{cell:x})},x.id))},l.id))})]})})]})]})})}const At=new Set(["Control","Shift","Alt","Meta"]);function Tt({preferences:s,onPreference:t}){const n=m.useMemo(()=>Ts(s.shortcutOverrides),[s.shortcutOverrides]),[a,i]=m.useState(null),o=Object.keys(s.shortcutOverrides).length>0,r=m.useMemo(()=>["General","Commit","Editor","Tabs"].map(g=>({category:g,definitions:me.filter(l=>l.category===g)})),[]),c=m.useMemo(()=>[...new Set(Fe.map(g=>g.category))].map(g=>({category:g,items:Fe.filter(l=>l.category===g)})),[]),h=(p,g)=>{if(g===n[p]){i(null);return}const l=Os(p,g,n);if(l){const b=l==="reserved"?`${ze(g)} is reserved for a fixed shortcut.`:`${ze(g)} is already used by "${me.find(y=>y.id===l).label}".`;i({id:p,message:b});return}i(null);const x=me.find(b=>b.id===p),j={...s.shortcutOverrides};g===x.defaultCombo?delete j[p]:j[p]=g,t({shortcutOverrides:j})},f=p=>{i(null);const g={...s.shortcutOverrides};delete g[p],t({shortcutOverrides:g})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"settings-field settings-toggle-row",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Show and focus from anywhere"}),e.jsx("span",{children:"Double-tap Control to bring OpenTig to the front, even while another app is focused."})]}),e.jsx("button",{type:"button",role:"switch","aria-label":"Show and focus from anywhere","aria-checked":s.doubleControlShortcutEnabled,className:"settings-switch",onClick:()=>t({doubleControlShortcutEnabled:!s.doubleControlShortcutEnabled}),children:e.jsx("span",{})})]}),e.jsxs("div",{className:"settings-field settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Keyboard shortcuts"}),e.jsx("span",{children:"Click a shortcut, then press a new key combination. Press Escape to cancel."})]}),o&&e.jsxs(w,{variant:"outline",size:"sm",className:"shortcuts-reset-all",onClick:()=>{i(null),t({shortcutOverrides:{}})},children:[e.jsx(Je,{})," Reset all to defaults"]}),r.map(({category:p,definitions:g})=>e.jsxs("div",{className:"shortcuts-group",children:[e.jsx("div",{className:"shortcuts-group-heading",children:p}),g.map(l=>e.jsxs("div",{className:"shortcuts-row",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:l.label}),e.jsx("span",{children:l.description})]}),e.jsx(Ot,{combo:n[l.id],allowBare:l.allowBare,isCustom:s.shortcutOverrides[l.id]!==void 0,error:a?.id===l.id?a.message:null,onCapture:x=>h(l.id,x),onReset:()=>f(l.id)})]},l.id))]},p))]}),e.jsxs("div",{className:"settings-field settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Fixed shortcuts"}),e.jsx("span",{children:"These follow platform and file-manager conventions and cannot be changed."})]}),c.map(({category:p,items:g})=>e.jsxs("div",{className:"shortcuts-group",children:[e.jsx("div",{className:"shortcuts-group-heading",children:p}),g.map(l=>e.jsxs("div",{className:"shortcuts-fixed-row",children:[e.jsx("span",{children:l.label}),e.jsx(Ze,{children:l.combo.split(" / ").flatMap((x,j)=>[...j>0?[e.jsx("span",{className:"shortcuts-fixed-sep",children:" / "},`sep-${x}`)]:[],...x.split(" + ").map((b,y)=>e.jsx(Qe,{children:b},`${x}-${y}`))])})]},l.combo+l.label))]},p))]})]})}function Ot({combo:s,allowBare:t,isCustom:n,error:a,onCapture:i,onReset:o}){const[r,c]=m.useState(!1);return m.useEffect(()=>{if(!r)return;const h=f=>{if(f.preventDefault(),f.stopPropagation(),f.key==="Escape"){c(!1);return}if(At.has(f.key))return;const p=Ls(f);c(!1),p&&$s(p,t)&&i(p)};return window.addEventListener("keydown",h,!0),()=>window.removeEventListener("keydown",h,!0)},[r,t,i]),e.jsxs("div",{className:"shortcut-recorder",children:[a&&e.jsx("span",{className:"shortcut-recorder-error",children:a}),e.jsx("button",{type:"button",className:`shortcut-recorder-button ${r?"listening":""} ${a?"error":""}`,onClick:()=>c(!0),onBlur:()=>c(!1),children:r?"Press a key…":e.jsx(Ze,{children:s.split("+").map(h=>e.jsx(Qe,{children:h},h))})}),n&&e.jsxs(_,{children:[e.jsx(D,{render:e.jsx(w,{variant:"ghost",size:"icon-xs","aria-label":"Reset to default",onClick:o}),children:e.jsx(Je,{})}),e.jsx(B,{children:"Reset to default"})]})]})}var W=(s=>(s[s.Border=-1]="Border",s[s.Data=0]="Data",s[s.Function=1]="Function",s[s.Position=2]="Position",s[s.Timing=3]="Timing",s[s.Alignment=4]="Alignment",s))(W||{});const Lt=[0,1],ps=[1,0],fs=[2,3],xs=[3,2],$t={L:Lt,M:ps,Q:fs,H:xs},Pt=/^\d*$/,Ft=/^[A-Z0-9 $%*+./:-]*$/,pe="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Ie=1,Ae=40,We=3,zt=3,le=40,_t=10,js=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],vs=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]];class Dt{constructor(t,n,a,i){if(this.version=t,this.ecc=n,t<Ie||t>Ae)throw new RangeError("Version value out of range");if(i<-1||i>7)throw new RangeError("Mask value out of range");this.size=t*4+17;const o=Array.from({length:this.size}).fill(!1);for(let c=0;c<this.size;c++)this.modules.push(o.slice()),this.types.push(o.map(()=>0));this.drawFunctionPatterns();const r=this.addEccAndInterleave(a);if(this.drawCodewords(r),i===-1){let c=1e9;for(let h=0;h<8;h++){this.applyMask(h),this.drawFormatBits(h);const f=this.getPenaltyScore();f<c&&(i=h,c=f),this.applyMask(h)}}this.mask=i,this.applyMask(i),this.drawFormatBits(i)}size;mask;modules=[];types=[];getModule(t,n){return t>=0&&t<this.size&&n>=0&&n<this.size&&this.modules[n][t]}drawFunctionPatterns(){for(let a=0;a<this.size;a++)this.setFunctionModule(6,a,a%2===0,W.Timing),this.setFunctionModule(a,6,a%2===0,W.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const t=this.getAlignmentPatternPositions(),n=t.length;for(let a=0;a<n;a++)for(let i=0;i<n;i++)a===0&&i===0||a===0&&i===n-1||a===n-1&&i===0||this.drawAlignmentPattern(t[a],t[i]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const n=this.ecc[1]<<3|t;let a=n;for(let o=0;o<10;o++)a=a<<1^(a>>>9)*1335;const i=(n<<10|a)^21522;for(let o=0;o<=5;o++)this.setFunctionModule(8,o,z(i,o));this.setFunctionModule(8,7,z(i,6)),this.setFunctionModule(8,8,z(i,7)),this.setFunctionModule(7,8,z(i,8));for(let o=9;o<15;o++)this.setFunctionModule(14-o,8,z(i,o));for(let o=0;o<8;o++)this.setFunctionModule(this.size-1-o,8,z(i,o));for(let o=8;o<15;o++)this.setFunctionModule(8,this.size-15+o,z(i,o));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let a=0;a<12;a++)t=t<<1^(t>>>11)*7973;const n=this.version<<12|t;for(let a=0;a<18;a++){const i=z(n,a),o=this.size-11+a%3,r=Math.floor(a/3);this.setFunctionModule(o,r,i),this.setFunctionModule(r,o,i)}}drawFinderPattern(t,n){for(let a=-4;a<=4;a++)for(let i=-4;i<=4;i++){const o=Math.max(Math.abs(i),Math.abs(a)),r=t+i,c=n+a;r>=0&&r<this.size&&c>=0&&c<this.size&&this.setFunctionModule(r,c,o!==2&&o!==4,W.Position)}}drawAlignmentPattern(t,n){for(let a=-2;a<=2;a++)for(let i=-2;i<=2;i++)this.setFunctionModule(t+i,n+a,Math.max(Math.abs(i),Math.abs(a))!==1,W.Alignment)}setFunctionModule(t,n,a,i=W.Function){this.modules[n][t]=a,this.types[n][t]=i}addEccAndInterleave(t){const n=this.version,a=this.ecc;if(t.length!==de(n,a))throw new RangeError("Invalid argument");const i=vs[a[0]][n],o=js[a[0]][n],r=Math.floor(Ne(n)/8),c=i-r%i,h=Math.floor(r/i),f=[],p=qt(o);for(let l=0,x=0;l<i;l++){const j=t.slice(x,x+h-o+(l<c?0:1));x+=j.length;const b=Xt(j,p);l<c&&j.push(0),f.push(j.concat(b))}const g=[];for(let l=0;l<f[0].length;l++)f.forEach((x,j)=>{(l!==h-o||j>=c)&&g.push(x[l])});return g}drawCodewords(t){if(t.length!==Math.floor(Ne(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let a=this.size-1;a>=1;a-=2){a===6&&(a=5);for(let i=0;i<this.size;i++)for(let o=0;o<2;o++){const r=a-o,h=(a+1&2)===0?this.size-1-i:i;!this.types[h][r]&&n<t.length*8&&(this.modules[h][r]=z(t[n>>>3],7-(n&7)),n++)}}}applyMask(t){if(t<0||t>7)throw new RangeError("Mask value out of range");for(let n=0;n<this.size;n++)for(let a=0;a<this.size;a++){let i;switch(t){case 0:i=(a+n)%2===0;break;case 1:i=n%2===0;break;case 2:i=a%3===0;break;case 3:i=(a+n)%3===0;break;case 4:i=(Math.floor(a/3)+Math.floor(n/2))%2===0;break;case 5:i=a*n%2+a*n%3===0;break;case 6:i=(a*n%2+a*n%3)%2===0;break;case 7:i=((a+n)%2+a*n%3)%2===0;break;default:throw new Error("Unreachable")}!this.types[n][a]&&i&&(this.modules[n][a]=!this.modules[n][a])}}getPenaltyScore(){let t=0;for(let o=0;o<this.size;o++){let r=!1,c=0;const h=[0,0,0,0,0,0,0];for(let f=0;f<this.size;f++)this.modules[o][f]===r?(c++,c===5?t+=We:c>5&&t++):(this.finderPenaltyAddHistory(c,h),r||(t+=this.finderPenaltyCountPatterns(h)*le),r=this.modules[o][f],c=1);t+=this.finderPenaltyTerminateAndCount(r,c,h)*le}for(let o=0;o<this.size;o++){let r=!1,c=0;const h=[0,0,0,0,0,0,0];for(let f=0;f<this.size;f++)this.modules[f][o]===r?(c++,c===5?t+=We:c>5&&t++):(this.finderPenaltyAddHistory(c,h),r||(t+=this.finderPenaltyCountPatterns(h)*le),r=this.modules[f][o],c=1);t+=this.finderPenaltyTerminateAndCount(r,c,h)*le}for(let o=0;o<this.size-1;o++)for(let r=0;r<this.size-1;r++){const c=this.modules[o][r];c===this.modules[o][r+1]&&c===this.modules[o+1][r]&&c===this.modules[o+1][r+1]&&(t+=zt)}let n=0;for(const o of this.modules)n=o.reduce((r,c)=>r+(c?1:0),n);const a=this.size*this.size,i=Math.ceil(Math.abs(n*20-a*10)/a)-1;return t+=i*_t,t}getAlignmentPatternPositions(){if(this.version===1)return[];{const t=Math.floor(this.version/7)+2,n=this.version===32?26:Math.ceil((this.version*4+4)/(t*2-2))*2,a=[6];for(let i=this.size-7;a.length<t;i-=n)a.splice(1,0,i);return a}}finderPenaltyCountPatterns(t){const n=t[1],a=n>0&&t[2]===n&&t[3]===n*3&&t[4]===n&&t[5]===n;return(a&&t[0]>=n*4&&t[6]>=n?1:0)+(a&&t[6]>=n*4&&t[0]>=n?1:0)}finderPenaltyTerminateAndCount(t,n,a){return t&&(this.finderPenaltyAddHistory(n,a),n=0),n+=this.size,this.finderPenaltyAddHistory(n,a),this.finderPenaltyCountPatterns(a)}finderPenaltyAddHistory(t,n){n[0]===0&&(t+=this.size),n.pop(),n.unshift(t)}}function G(s,t,n){if(t<0||t>31||s>>>t)throw new RangeError("Value out of range");for(let a=t-1;a>=0;a--)n.push(s>>>a&1)}function z(s,t){return(s>>>t&1)!==0}class Te{constructor(t,n,a){if(this.mode=t,this.numChars=n,this.bitData=a,n<0)throw new RangeError("Invalid argument");this.bitData=a.slice()}getData(){return this.bitData.slice()}}const Bt=[1,10,12,14],Gt=[2,9,11,13],Ut=[4,8,16,16];function bs(s,t){return s[Math.floor((t+7)/17)+1]}function ys(s){const t=[];for(const n of s)G(n,8,t);return new Te(Ut,s.length,t)}function Ht(s){if(!ws(s))throw new RangeError("String contains non-numeric characters");const t=[];for(let n=0;n<s.length;){const a=Math.min(s.length-n,3);G(Number.parseInt(s.substring(n,n+a),10),a*3+1,t),n+=a}return new Te(Bt,s.length,t)}function Vt(s){if(!ks(s))throw new RangeError("String contains unencodable characters in alphanumeric mode");const t=[];let n;for(n=0;n+2<=s.length;n+=2){let a=pe.indexOf(s.charAt(n))*45;a+=pe.indexOf(s.charAt(n+1)),G(a,11,t)}return n<s.length&&G(pe.indexOf(s.charAt(n)),6,t),new Te(Gt,s.length,t)}function Wt(s){return s===""?[]:ws(s)?[Ht(s)]:ks(s)?[Vt(s)]:[ys(Yt(s))]}function ws(s){return Pt.test(s)}function ks(s){return Ft.test(s)}function Kt(s,t){let n=0;for(const a of s){const i=bs(a.mode,t);if(a.numChars>=1<<i)return Number.POSITIVE_INFINITY;n+=4+i+a.bitData.length}return n}function Yt(s){s=encodeURI(s);const t=[];for(let n=0;n<s.length;n++)s.charAt(n)!=="%"?t.push(s.charCodeAt(n)):(t.push(Number.parseInt(s.substring(n+1,n+3),16)),n+=2);return t}function Ne(s){if(s<Ie||s>Ae)throw new RangeError("Version number out of range");let t=(16*s+128)*s+64;if(s>=2){const n=Math.floor(s/7)+2;t-=(25*n-10)*n-55,s>=7&&(t-=36)}return t}function de(s,t){return Math.floor(Ne(s)/8)-js[t[0]][s]*vs[t[0]][s]}function qt(s){if(s<1||s>255)throw new RangeError("Degree out of range");const t=[];for(let a=0;a<s-1;a++)t.push(0);t.push(1);let n=1;for(let a=0;a<s;a++){for(let i=0;i<t.length;i++)t[i]=Ce(t[i],n),i+1<t.length&&(t[i]^=t[i+1]);n=Ce(n,2)}return t}function Xt(s,t){const n=t.map(a=>0);for(const a of s){const i=a^n.shift();n.push(0),t.forEach((o,r)=>n[r]^=Ce(o,i))}return n}function Ce(s,t){if(s>>>8||t>>>8)throw new RangeError("Byte out of range");let n=0;for(let a=7;a>=0;a--)n=n<<1^(n>>>7)*285,n^=(t>>>a&1)*s;return n}function Jt(s,t,n=1,a=40,i=-1,o=!0){if(!(Ie<=n&&n<=a&&a<=Ae)||i<-1||i>7)throw new RangeError("Invalid value");let r,c;for(r=n;;r++){const g=de(r,t)*8,l=Kt(s,r);if(l<=g){c=l;break}if(r>=a)throw new RangeError("Data too long")}for(const g of[ps,fs,xs])o&&c<=de(r,g)*8&&(t=g);const h=[];for(const g of s){G(g.mode[0],4,h),G(g.numChars,bs(g.mode,r),h);for(const l of g.getData())h.push(l)}const f=de(r,t)*8;G(0,Math.min(4,f-h.length),h),G(0,(8-h.length%8)%8,h);for(let g=236;h.length<f;g^=253)G(g,8,h);const p=Array.from({length:Math.ceil(h.length/8)},()=>0);return h.forEach((g,l)=>p[l>>>3]|=g<<7-(l&7)),new Dt(r,t,p,i)}function Zt(s,t){const{ecc:n="L",boostEcc:a=!1,minVersion:i=1,maxVersion:o=40,maskPattern:r=-1,border:c=1}=t||{},h=typeof s=="string"?Wt(s):Array.isArray(s)?[ys(s)]:void 0;if(!h)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof s}`);const f=Jt(h,$t[n],i,o,r,a),p=Qt({version:f.version,maskPattern:f.mask,size:f.size,data:f.modules,types:f.types},c);return t?.invert&&(p.data=p.data.map(g=>g.map(l=>!l))),t?.onEncoded?.(p),p}function Qt(s,t=1){if(!t)return s;const{size:n}=s,a=n+t*2;s.size=a,s.data.forEach(o=>{for(let r=0;r<t;r++)o.unshift(!1),o.push(!1)});for(let o=0;o<t;o++)s.data.unshift(Array.from({length:a},r=>!1)),s.data.push(Array.from({length:a},r=>!1));const i=W.Border;s.types.forEach(o=>{for(let r=0;r<t;r++)o.unshift(i),o.push(i)});for(let o=0;o<t;o++)s.types.unshift(Array.from({length:a},r=>i)),s.types.push(Array.from({length:a},r=>i));return s}function Ke(s){return s.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function en(s,t={}){const n=Zt(s,t),{pixelSize:a=10,whiteColor:i="white",blackColor:o="black"}=t,r=n.size*a,c=n.size*a;let h=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${c} ${r}">`;const f=[];for(let p=0;p<n.size;p++)for(let g=0;g<n.size;g++){const l=g*a,x=p*a;n.data[p][g]&&f.push(`M${l},${x}h${a}v${a}h-${a}z`)}return h+=`<rect fill="${Ke(i)}" width="${c}" height="${r}"/>`,h+=`<path fill="${Ke(o)}" d="${f.join("")}"/>`,h+="</svg>",h}async function sn(){const s=await fetch("/api/auth/sessions",{credentials:"include"});if(!s.ok)throw new Error(await Oe(s,"Could not load owner sessions."));const t=await s.json();if(!Array.isArray(t.sessions))throw new Error("OpenTig returned an invalid session list.");return t.sessions}async function tn(s){return Ns("/api/auth/sessions/revoke",{sessionId:s})}async function nn(){return Ns("/api/auth/sessions/revoke-all",{})}async function an(s,t){const n=await fetch("/api/auth/sessions/rename",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:s,clientName:t})});if(!n.ok)throw new Error(await Oe(n,"Could not rename the browser session."))}async function Ns(s,t){const n=await fetch(s,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(await Oe(n,"Could not revoke the browser session."));const a=await n.json();if(!Number.isSafeInteger(a.revokedCount)||Number(a.revokedCount)<0)throw new Error("OpenTig returned an invalid revocation result.");return Number(a.revokedCount)}async function Oe(s,t){try{const n=await s.json();return typeof n.error=="string"?n.error:t}catch{return t}}const on={starting:"Starting",ready:"Ready",restarting:"Restarting",failed:"Failed",stopped:"Stopped"};function rn(){const s=window.opentigDesktop?.webAccess,[t,n]=m.useState(null),[a,i]=m.useState([]),[o,r]=m.useState(null),[c,h]=m.useState(""),[f,p]=m.useState(!0),[g,l]=m.useState(null),[x,j]=m.useState(!1),[b,y]=m.useState(null),[E,k]=m.useState(null),[T,C]=m.useState(""),I=m.useCallback(async(u=!0)=>{const O=await Promise.allSettled([s?.getStatus()??Promise.resolve(null),sn()]);O[0].status==="fulfilled"?n(O[0].value):u&&M.error({title:"Could not read web access status",description:V(O[0].reason)}),O[1].status==="fulfilled"?i(O[1].value):u&&M.error({title:"Could not read owner sessions",description:V(O[1].reason)}),p(!1)},[s]);m.useEffect(()=>{I();const u=window.setInterval(()=>{I(!1)},2e3);return()=>window.clearInterval(u)},[I]),m.useEffect(()=>{t&&(t.pairingEndpoints.length?t.pairingEndpoints.includes(c)||h(t.pairingEndpoints[0]):h(""))},[c,t]);const R=m.useMemo(()=>o?`data:image/svg+xml;charset=UTF-8,${encodeURIComponent(en(o.url,{ecc:"M",border:2}))}`:null,[o]),$=m.useMemo(()=>o?new URLSearchParams(new URL(o.url).hash.slice(1)).get("token")??"":"",[o]);if(f&&(!s||!t)&&a.length===0)return e.jsxs("div",{className:"web-access-loading",role:"status",children:[e.jsx(Z,{className:"animate-spin"})," Loading web access…"]});const A=async u=>{if(s){l("toggle"),r(null);try{n(await s.setEnabled(u)),M.success({title:u?"LAN access enabled":"LAN access disabled"})}catch(O){M.error({title:"Could not restart web access",description:V(O)}),await I(!1)}finally{l(null),j(!1)}}},N=async()=>{if(s){l("pair");try{r(await s.createPairingLink(c))}catch(u){M.error({title:"Could not create pairing link",description:V(u)})}finally{l(null)}}},P=async()=>{if(o)try{await $e(o.url),M.success({title:"Pairing link copied"})}catch(u){M.error({title:"Could not copy pairing link",description:V(u)})}},d=async()=>{if($)try{await $e($),M.success({title:"Pairing code copied"})}catch(u){M.error({title:"Could not copy pairing code",description:V(u)})}},v=async()=>{const u=E,O=T.trim();if(!(!u||!O||O.length>64)){l(`rename:${u.id}`);try{await an(u.id,O),M.success({title:"Device renamed"}),await I(!1),k(null)}catch(ee){M.error({title:"Could not rename device",description:V(ee)})}finally{l(null)}}},S=async()=>{const u=b;if(!u)return;const O=u==="all"?"revoke-all":`revoke:${u.id}`;l(O);try{const ee=u==="all"?await nn():await tn(u.id);r(null),M.success({title:`${ee} browser ${ee===1?"session":"sessions"} revoked`}),await I(!1)}catch(ee){M.error({title:"Could not revoke session",description:V(ee)})}finally{l(null),y(null)}},U=t?.serverState==="ready",Q=a.filter(u=>u.kind!=="desktop");return e.jsxs("div",{className:"web-access-settings",children:[s&&t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"web-access-summary",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"LAN access"}),e.jsx("span",{children:"Listen on this computer's network interfaces for trusted local devices."})]}),e.jsx("button",{type:"button",role:"switch","aria-label":"LAN access","aria-checked":t.enabled,className:"settings-switch",disabled:g==="toggle"||!U,onClick:()=>t.enabled?void A(!1):j(!0),children:e.jsx("span",{})})]}),e.jsxs("div",{className:"web-access-facts","aria-live":"polite",children:[e.jsx(ce,{label:"Server status",children:e.jsx(te,{variant:U?"secondary":"outline",children:on[t.serverState]})}),e.jsx(ce,{label:"Actual port",children:e.jsx("code",{children:t.actualPort??"Unavailable"})}),e.jsx(ce,{label:"Local endpoint",children:e.jsx(Ye,{value:t.localEndpoint})}),e.jsx(ce,{label:"LAN endpoints",children:e.jsx("div",{className:"web-access-endpoints",children:t.networkEndpoints.length===0?e.jsx("span",{children:"None detected"}):t.networkEndpoints.map(u=>e.jsx(Ye,{value:u,muted:!t.enabled},u))})})]}),t.restartError&&e.jsxs("div",{className:"web-access-error",role:"alert",children:[e.jsx(Re,{})," ",e.jsx("span",{children:t.restartError})]}),e.jsxs("div",{className:"web-access-actions settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Pair a browser"}),e.jsx("span",{children:"Create a five-minute, one-use link for this computer or a LAN device. The pairing code also works through a same-machine HTTPS tunnel."})]}),e.jsxs(w,{size:"sm",onClick:()=>{N()},disabled:!U||!c||g!==null,children:[g==="pair"?e.jsx(Z,{className:"animate-spin"}):e.jsx(rt,{})," Create pairing link"]})]}),t.pairingEndpoints.length>0&&e.jsxs("div",{className:"web-access-endpoint-select",children:[e.jsx("label",{htmlFor:"web-access-endpoint",children:"Address to place in the pairing link"}),e.jsxs(je,{value:c,onValueChange:u=>{u&&(h(u),r(null))},disabled:g!==null,children:[e.jsx(ve,{id:"web-access-endpoint",className:"w-full",children:e.jsx(be,{children:c})}),e.jsx(ye,{alignItemWithTrigger:!1,children:e.jsx(Ps,{children:t.pairingEndpoints.map(u=>e.jsx(we,{value:u,children:u},u))})})]})]}),o&&e.jsxs("div",{className:"web-access-pairing",role:"status",children:[e.jsxs("div",{className:"web-access-pairing-copy",children:[e.jsx(pt,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Pairing link ready"}),e.jsxs("span",{children:["Expires ",new Date(o.expiresAt).toLocaleString(),"."]})]})]}),R&&e.jsx("img",{src:R,alt:"QR code for the one-use OpenTig pairing link"}),e.jsxs("div",{className:"web-access-link-row",children:[e.jsxs(_,{children:[e.jsx(D,{render:e.jsx("code",{className:"web-access-link"}),children:o.url}),e.jsx(B,{side:"bottom",children:"One-use link; do not share publicly"})]}),e.jsxs(_,{children:[e.jsx(D,{render:e.jsx(w,{variant:"outline",size:"icon-sm","aria-label":"Copy pairing link",onClick:()=>{P()}}),children:e.jsx(Le,{})}),e.jsx(B,{children:"Copy pairing link"})]})]}),e.jsxs("div",{className:"web-access-link-row",children:[e.jsxs(_,{children:[e.jsx(D,{render:e.jsx("code",{className:"web-access-link"}),children:$}),e.jsx(B,{side:"bottom",children:"Paste this code on any /pair page served by this OpenTig instance"})]}),e.jsxs(_,{children:[e.jsx(D,{render:e.jsx(w,{variant:"outline",size:"icon-sm","aria-label":"Copy pairing code",onClick:()=>{d()}}),children:e.jsx(Le,{})}),e.jsx(B,{children:"Copy pairing code"})]})]})]})]}),e.jsxs("div",{className:`web-access-session-heading ${s?"settings-field-separated":""}`,children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Owner sessions"}),e.jsx("span",{children:"Desktop authentication stays private. Paired browsers can be disconnected individually."})]}),e.jsxs(w,{variant:"destructive",size:"sm",onClick:()=>y("all"),disabled:Q.length===0||g!==null,children:[e.jsx(Ge,{})," Revoke browsers"]})]}),e.jsx("div",{className:"web-access-session-list","aria-live":"polite",children:a.length===0?e.jsx("div",{className:"web-access-empty-session",children:"No owner sessions found."}):a.map(u=>e.jsxs("div",{className:"web-access-session",children:[e.jsx("div",{className:`web-access-session-icon ${u.connected?"connected":""}`,children:u.kind==="desktop"?e.jsx(os,{}):e.jsx(tt,{})}),e.jsxs("div",{className:"web-access-session-copy",children:[e.jsxs("div",{children:[e.jsx("strong",{children:u.clientName}),u.current&&e.jsx(te,{variant:"secondary",children:"This session"}),u.kind==="desktop"&&e.jsx(te,{variant:"outline",children:"Desktop"})]}),e.jsxs("span",{children:[u.connected?`Connected${u.connectionCount>1?` (${u.connectionCount} tabs)`:""}`:u.lastConnectedAt?`Last connected ${ln(u.lastConnectedAt)}`:"Not yet connected"," · ",u.browser&&u.os?`${u.browser} on ${u.os}`:u.browser??u.os??cn(u.deviceType),u.viaProxy?" · Via proxy":"",u.remoteAddress?` · ${u.remoteAddress}`:""]})]}),u.kind!=="desktop"&&e.jsxs("div",{className:"web-access-session-controls",children:[e.jsxs(_,{children:[e.jsx(D,{render:e.jsx(w,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${u.clientName}`,onClick:()=>{k(u),C(u.clientName)},disabled:g!==null}),children:e.jsx(Ws,{})}),e.jsx(B,{children:"Rename this device"})]}),e.jsxs(_,{children:[e.jsx(D,{render:e.jsx(w,{variant:"ghost",size:"icon-sm","aria-label":`Revoke ${u.clientName} session`,onClick:()=>y(u),disabled:g!==null}),children:e.jsx(Se,{})}),e.jsx(B,{children:"Revoke this browser session"})]})]})]},u.id))}),!s&&e.jsx("p",{className:"web-access-hint",children:"Listener addresses and new pairing links are controlled by the OpenTig desktop app or CLI running the server."}),e.jsx(K,{open:x,onOpenChange:j,children:e.jsxs(Y,{className:"undo-commit-dialog",children:[e.jsxs("div",{className:"undo-commit-content",children:[e.jsx(q,{children:"Enable owner-level LAN access?"}),e.jsx(X,{children:"Any paired browser can edit or delete files and act with your OS user permissions. Use only a trusted LAN or VPN."})]}),e.jsxs("div",{className:"undo-commit-actions",children:[e.jsx(J,{render:e.jsx(w,{variant:"ghost"}),children:"Cancel"}),e.jsx(w,{onClick:()=>{A(!0)},disabled:g!==null,children:"Enable LAN access"})]})]})}),e.jsx(K,{open:b!==null,onOpenChange:u=>{u||y(null)},children:e.jsxs(Y,{className:"undo-commit-dialog",children:[e.jsxs("div",{className:"undo-commit-content",children:[e.jsx(q,{children:b==="all"?"Revoke all browser sessions?":"Revoke this browser session?"}),e.jsx(X,{children:b==="all"?"Every paired browser disconnects immediately. The private desktop session remains signed in.":b?.current?"This browser will disconnect immediately and require a new pairing link.":"That browser disconnects immediately and will require a new pairing link."}),b&&b!=="all"&&e.jsx("div",{className:"undo-commit-summary",children:e.jsx("strong",{children:b.clientName})})]}),e.jsxs("div",{className:"undo-commit-actions",children:[e.jsx(J,{render:e.jsx(w,{variant:"ghost"}),children:"Cancel"}),e.jsxs(w,{variant:"destructive",onClick:()=>{S()},disabled:g!==null,children:[e.jsx(Ge,{})," Revoke"]})]})]})}),e.jsx(K,{open:E!==null,onOpenChange:u=>{u||k(null)},children:e.jsxs(Y,{className:"undo-commit-dialog",children:[e.jsxs("div",{className:"undo-commit-content",children:[e.jsx(q,{children:"Rename paired device"}),e.jsx(X,{children:"Use a name that makes this browser easy to identify later."}),e.jsx("input",{className:"web-access-rename-input",value:T,onChange:u=>C(u.target.value),maxLength:64,"aria-label":"Device name",autoComplete:"off"})]}),e.jsxs("div",{className:"undo-commit-actions",children:[e.jsx(J,{render:e.jsx(w,{variant:"ghost"}),children:"Cancel"}),e.jsx(w,{onClick:()=>{v()},disabled:g!==null||!T.trim(),children:"Save"})]})]})})]})}function ce({label:s,children:t}){return e.jsxs("div",{className:"web-access-fact",children:[e.jsx("span",{children:s}),e.jsx("div",{children:t})]})}function Ye({value:s,muted:t=!1}){return s?e.jsxs(_,{children:[e.jsx(D,{render:e.jsx("code",{className:t?"muted":void 0}),children:s}),e.jsx(B,{side:"bottom",children:t?"Enable LAN access to use this endpoint":s})]}):e.jsx("span",{children:"Unavailable"})}function ln(s){const t=new Date(s);return Number.isNaN(t.getTime())?"unknown":t.toLocaleString()}function cn(s){return s==="desktop"?"Desktop browser":s==="mobile"?"Mobile browser":s==="tablet"?"Tablet browser":s==="bot"?"Automated client":"Unknown browser"}function V(s){return s instanceof Error?s.message:String(s)}const dn=[{id:"general",label:"General",icon:Fs},{id:"updates",label:"Updates",icon:ue},{id:"shortcuts",label:"Shortcuts",icon:it},{id:"ai",label:"AI assistance",icon:cs},{id:"diagnostics",label:"Diagnostics",icon:Re},{id:"webAccess",label:"Web access",icon:gt}],hn={updates:{title:"Updates",description:"Check, download, and install new OpenTig releases."},general:{title:"General",description:"OpenTig appearance and behavior."},shortcuts:{title:"Shortcuts",description:"Rebind commands or review the shortcuts that stay fixed."},ai:{title:"AI assistance",description:"Local harness and model used to suggest commit messages and pull-request drafts."},diagnostics:{title:"Diagnostics",description:"Recent local failures on this machine. Prompts and file contents are never recorded."}},un=[{value:"system",label:"System",icon:os},{value:"light",label:"Light",icon:yt},{value:"dark",label:"Dark",icon:ht}],fe=[{value:"geist",label:"Geist",family:"'Geist Variable', sans-serif"},{value:"plus-jakarta-sans",label:"Plus Jakarta Sans",family:"'Plus Jakarta Sans Variable', sans-serif"},{value:"space-grotesk",label:"Space Grotesk",family:"'Space Grotesk Variable', sans-serif"}],xe=[{value:"geist-mono",label:"Geist Mono",family:"'Geist Mono Variable', ui-monospace, monospace"},{value:"jetbrains-mono",label:"JetBrains Mono",family:"'JetBrains Mono Variable', ui-monospace, monospace"},{value:"inconsolata",label:"Inconsolata",family:"'Inconsolata Variable', ui-monospace, monospace"},{value:"departure",label:"Departure Mono",family:"'Departure Mono', ui-monospace, monospace"},{value:"space-grotesk",label:"Space Grotesk",family:"'Space Grotesk Variable', sans-serif"}],gn=[{value:"tree",label:"Tree",icon:zs},{value:"list",label:"List",icon:ct}];function Nn({preferences:s,onPreference:t,open:n,onOpenChange:a,section:i,onSectionChange:o}){const[r,c]=m.useState([]),[h,f]=m.useState(!1),[p,g]=m.useState(!1),[l,x]=m.useState(!1),j=m.useRef(null),b=Qs(),y=b?{duration:0}:{duration:.16,ease:[.22,1,.36,1]},E=m.useCallback(async(d=!1)=>{f(!0);try{c(await oe.ai.statuses(d))}catch(v){M.error({title:"Could not check local AI",description:xn(v)})}finally{f(!1)}},[]);m.useEffect(()=>{n&&i==="ai"&&r.length===0&&E()},[E,n,i,r.length]),m.useLayoutEffect(()=>{n&&j.current&&(j.current.scrollTop=0)},[n,i]);const k=s.commitMessageHarness,T=r.find(d=>d.id===k),C=s.commitMessageModels[k]??"default",I=T?.models??[{id:"default",label:"Default (CLI)"}],R=I.some(d=>d.id===C)?I:[...I,{id:C,label:`${C} (unavailable)`}],$=[];for(const d of R){const v=k==="opencode"?d.id.indexOf("/"):-1,S=v>0?d.id.slice(0,v):k,U=d.id==="default"?"default":`provider:${S}`;let Q=$.find(u=>u.id===U);Q||(Q={id:U,label:d.id==="default"?"":v>0?S:ae(k),items:[]},$.push(Q)),Q.items.push({value:d.id,label:v>0&&d.label===d.id?d.id.slice(v+1):d.label,search:d.id,tooltip:d.id==="default"||d.label===d.id?d.label:`${d.label} · ${d.id}`,pinned:d.id==="default",icon:e.jsx(cs,{})})}const A=R.find(d=>d.id===C)?.label??C,{title:N,description:P}=i==="webAccess"?{title:"Web access",description:window.opentigDesktop?"Connect trusted browsers locally, over your LAN, or through an HTTPS tunnel.":"Review and disconnect browsers authorised to use this OpenTig server."}:hn[i];return e.jsx(K,{open:n,onOpenChange:a,children:e.jsx(Y,{className:"settings-dialog",children:e.jsxs("div",{className:"settings-shell",children:[e.jsxs("aside",{className:"settings-nav",children:[e.jsx("div",{className:"settings-nav-title",children:"Settings"}),dn.map(({id:d,label:v,icon:S})=>e.jsxs("button",{className:`settings-nav-item ${i===d?"active":""}`,onClick:()=>o(d),"aria-current":i===d,children:[e.jsx(S,{})," ",v]},d))]}),e.jsxs("section",{className:"settings-panel",children:[e.jsxs("header",{className:"settings-panel-header",children:[e.jsx(Be,{initial:!1,mode:"wait",children:e.jsxs(Pe.div,{initial:b?!1:{opacity:0,y:4},animate:{opacity:1,y:0},exit:b?{opacity:1}:{opacity:0,y:-3},transition:y,children:[e.jsx(q,{children:N}),e.jsx(X,{children:P})]},i)}),e.jsx(J,{render:e.jsx(w,{variant:"ghost",size:"icon-sm","aria-label":"Close settings"}),children:e.jsx(Me,{})})]}),e.jsx("div",{ref:j,className:"settings-panel-body",children:e.jsx(Be,{initial:!1,mode:"wait",children:e.jsx(Pe.div,{className:"settings-panel-section",initial:b?!1:{opacity:0,y:7},animate:{opacity:1,y:0},exit:b?{opacity:1}:{opacity:0,y:-5},transition:y,children:i==="general"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"settings-field",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Theme"}),e.jsx("span",{children:"Choose a light, dark, or system appearance."})]}),e.jsx("div",{className:"settings-theme-options",role:"radiogroup","aria-label":"Theme",children:un.map(({value:d,label:v,icon:S})=>e.jsxs("button",{type:"button",role:"radio","aria-checked":s.theme===d,className:`settings-theme-option ${s.theme===d?"active":""}`,onClick:()=>t({theme:d}),children:[e.jsx(S,{})," ",e.jsx("span",{children:v})]},d))})]}),e.jsxs("div",{className:"settings-field settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Fonts"}),e.jsx("span",{children:"Interface chrome and code, chosen independently. Space Grotesk appears in both lists."})]}),e.jsxs("div",{className:"settings-font-pickers",children:[e.jsxs("label",{className:"settings-font-picker",children:[e.jsx("span",{children:"Interface"}),e.jsxs(je,{value:s.uiFont,onValueChange:d=>{const v=fe.find(S=>S.value===d);v&&t({uiFont:v.value})},children:[e.jsx(ve,{className:"settings-font-select","aria-label":"Interface font",style:{fontFamily:fe.find(d=>d.value===s.uiFont)?.family},children:e.jsx(be,{})}),e.jsx(ye,{align:"start",alignItemWithTrigger:!1,className:"w-max min-w-[16rem]",children:fe.map(d=>e.jsx(we,{value:d.value,children:e.jsx("span",{style:{fontFamily:d.family},children:d.label})},d.value))})]})]}),e.jsxs("label",{className:"settings-font-picker",children:[e.jsx("span",{children:"Code"}),e.jsxs(je,{value:s.monoFont,onValueChange:d=>{const v=xe.find(S=>S.value===d);v&&t({monoFont:v.value})},children:[e.jsx(ve,{className:"settings-font-select","aria-label":"Code font",style:{fontFamily:xe.find(d=>d.value===s.monoFont)?.family},children:e.jsx(be,{})}),e.jsx(ye,{align:"start",alignItemWithTrigger:!1,className:"w-max min-w-[16rem]",children:xe.map(d=>e.jsx(we,{value:d.value,children:e.jsx("span",{style:{fontFamily:d.family},children:d.label})},d.value))})]})]})]})]}),e.jsxs("div",{className:"settings-field settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Interface size"}),e.jsx("span",{children:"Adjust the zoom for text, icons, and the rest of the application."})]}),e.jsxs("div",{className:"settings-zoom-control",children:[e.jsx("input",{type:"range",min:"80",max:"130",step:"10",value:s.uiZoom,onChange:d=>t({uiZoom:Number(d.target.value)}),"aria-label":"Interface zoom"}),e.jsxs("output",{children:[s.uiZoom,"%"]})]})]}),e.jsxs("div",{className:"settings-field settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Changes layout"}),e.jsx("span",{children:"Group changed files by folder or show them as a flat list."})]}),e.jsx("div",{className:"settings-theme-options",role:"radiogroup","aria-label":"Changes layout",children:gn.map(({value:d,label:v,icon:S})=>e.jsxs("button",{type:"button",role:"radio","aria-checked":s.changesLayout===d,className:`settings-theme-option ${s.changesLayout===d?"active":""}`,onClick:()=>t({changesLayout:d}),children:[e.jsx(S,{})," ",e.jsx("span",{children:v})]},d))})]}),e.jsxs("div",{className:"settings-field settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Remote check interval"}),e.jsx("span",{children:"How often OpenTig fetches remotes so ahead and behind counts stay current. Set to Off to check only when you pull or push."})]}),e.jsxs("div",{className:"settings-zoom-control",children:[e.jsx("input",{type:"range",min:"0",max:Ds,step:_s,value:s.remoteFetchIntervalSeconds,onChange:d=>t({remoteFetchIntervalSeconds:Number(d.target.value)}),"aria-label":"Remote check interval"}),e.jsx("output",{children:Bs(s.remoteFetchIntervalSeconds)})]})]}),e.jsxs("div",{className:"settings-field settings-field-separated settings-toggle-row",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Wrap lines in viewer"}),e.jsx("span",{children:"Wrap long lines to fit the available width."})]}),e.jsx("button",{type:"button",role:"switch","aria-label":"Wrap lines in viewer","aria-checked":s.wrapLines,className:"settings-switch",onClick:()=>t({wrapLines:!s.wrapLines}),children:e.jsx("span",{})})]}),e.jsxs("div",{className:"settings-field settings-field-separated settings-toggle-row",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Show files ignored by Git"}),e.jsxs("span",{children:["Include files excluded by ",e.jsx("code",{children:".gitignore"})," rules in the Files view."]})]}),e.jsx("button",{type:"button",role:"switch","aria-label":"Show files ignored by Git","aria-checked":s.showDotEnvFiles,className:"settings-switch",onClick:()=>t({showDotEnvFiles:!s.showDotEnvFiles}),children:e.jsx("span",{})})]})]}):i==="updates"?e.jsx(Gs,{}):i==="shortcuts"?e.jsx(Tt,{preferences:s,onPreference:t}):i==="webAccess"?e.jsx(rn,{}):i==="diagnostics"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"settings-field",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Problem history"}),e.jsx("span",{children:"Failed Git, file, and network operations recorded locally. Prompts and file contents are never stored."})]}),e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>x(!0),children:[e.jsx(Re,{})," View problems"]})]}),e.jsx(It,{open:l,onOpenChange:x})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"ai-settings-heading",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Local harness"}),e.jsx("span",{children:"OpenTig uses the selected CLI session. It does not copy or store credentials."})]}),e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>{E(!0)},disabled:h,children:[h?e.jsx(Z,{className:"animate-spin"}):e.jsx(ue,{})," ",h?e.jsx(Ee,{text:"Checking…"}):"Check again"]})]}),e.jsx("div",{className:"ai-harness-list",role:"radiogroup","aria-label":"Harness for AI assistance",children:["codex","claude","opencode","grok"].map(d=>{const v=r.find(U=>U.id===d),S=k===d;return e.jsxs("button",{type:"button",role:"radio","aria-checked":S,className:`ai-harness-card ${S?"active":""}`,onClick:()=>t({commitMessageHarness:d}),children:[e.jsxs("span",{className:"ai-harness-card-main",children:[e.jsx(Us,{harness:d}),e.jsxs("span",{className:"ai-harness-card-copy",children:[e.jsx("strong",{children:ae(d)}),e.jsx("small",{children:h?"Checking…":v?.version||(v?v.installed?"Version unavailable":"Executable not found":"Status not checked")})]})]}),e.jsx(te,{variant:pn(v),className:`ai-status-badge ${v?.availability??"unknown"}`,children:mn(v)}),v?.message&&e.jsx("span",{className:"ai-harness-message",children:v.message})]},d)})}),e.jsxs("div",{className:"settings-field settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsxs("strong",{children:[ae(k)," model"]}),e.jsx("span",{children:k==="grok"?"Default uses Grok’s built-in default. Custom CLI models and configuration are not loaded.":"Default lets the CLI choose. OpenTig remembers a separate selection for each harness."})]}),e.jsx(Hs,{groups:$,value:C,onValueChange:d=>t({commitMessageModels:{...s.commitMessageModels,[k]:d}}),label:`${ae(k)} model`,triggerLabel:A,triggerClassName:"ai-model-select",contentClassName:"ai-model-picker",size:"default",align:"start",placeholder:"Search models…"},k),T?.authStatus==="unauthenticated"&&e.jsxs("p",{className:"ai-login-hint",children:["Sign in from a terminal with ",e.jsx("code",{children:fn(k,T.cliName)})," and check again."]}),T&&!T.installed&&e.jsxs("p",{className:"ai-login-hint",children:["Install ",ae(k)," and check its availability again."]})]}),e.jsxs("div",{className:"settings-field settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Generation history"}),e.jsx("span",{children:"Outcome, duration, tokens, and cost of recent runs, kept locally for diagnostics."})]}),e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>g(!0),children:[e.jsx(Vs,{})," View history"]})]}),e.jsx("p",{className:"ai-privacy-note",children:"Only the staged diff, its summary, the branch, and recent subjects are sent to the selected harness. The generated message always remains pending your review, and the history records metadata only."}),e.jsx(Ct,{open:p,onOpenChange:g})]})},i)})})]})]})})})}function mn(s){return s?s.installed?s.authStatus==="unauthenticated"?"Not authenticated":s.availability==="ready"?"Available":"Check":"Not installed":"Not checked"}function pn(s){return s?!s.installed||s.authStatus==="unauthenticated"||s.availability==="error"?"destructive":s.availability==="ready"?"default":"secondary":"outline"}function fn(s,t){return s==="codex"?"codex login":s==="claude"?"claude auth login":s==="grok"?"grok login":t==="opencode2"?"opencode2 auth login":"opencode auth login"}function xn(s){return s instanceof Error?s.message:"An unexpected error occurred."}export{Nn as SettingsDialog};
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PierreDiffViewer-FmgbHdls.js","assets/react-rd22PHbN.js","assets/PierreWorkerPool-B_NFnwU-.js","assets/platform-BMNQ8V5r.js","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js","assets/index-ChKJF4C_.js","assets/tanstack-CtfgE41X.js","assets/base-ui-DT3JsyND.js","assets/index-WwGOu_aM.css","assets/index-CtEztN1P.js","assets/File-BJuBDans.js","assets/EditContext-CvJWfVl1.js","assets/DiffWorkspace-XS025gbZ.js","assets/App-CGiS2z40.js","assets/PierreEditBoundary-mxtF7x3F.js","assets/edit-ready-context-D77R8XU8.js","assets/MarkdownFileViewer-pagMxv2y.js","assets/viewer-tabs-BwMhis6Q.js","assets/viewer-tabs-D8o-L3pM.css","assets/EditableFileViewer-Cve4V9RS.js","assets/EditableFileViewer-B2G3Xa33.css","assets/render-markdown-BiKX2Zdv.js","assets/markdown-BpzjXclZ.css","assets/PullRequestViewer-oeDoq-3g.js","assets/GitHubAvatar-Depnd_JA.js","assets/gh-utils-DxPHIkD8.js","assets/HtmlFileViewer-C3Qylr9B.js","assets/HtmlFileViewer-D6UPnZvW.css","assets/ImageFileViewer-BJy0ptmR.js","assets/ImageFileViewer-D8TdwFTO.css"])))=>i.map(i=>d[i]);
2
- import{o as _,B as J,_ as x,T as se,a as ae,b as le}from"./index-ChKJF4C_.js";import{r as l,j as t}from"./react-rd22PHbN.js";import{H as ne,J as re,K as oe,k as F,L as ue,G as Y}from"./App-CGiS2z40.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";class fe{constructor(e){if(this.options=e,!Number.isInteger(e.maxEntries)||e.maxEntries<1)throw new RangeError("maxEntries must be a positive integer.");if(!Number.isFinite(e.maxBytes)||e.maxBytes<1)throw new RangeError("maxBytes must be a positive number.")}options;entries=new Map;totalBytes=0;get size(){return this.entries.size}get bytes(){return this.totalBytes}get(e){const o=this.entries.get(e);if(o)return this.entries.delete(e),this.entries.set(e,o),o.value}set(e,o){const f=de(this.options.sizeOf(o)),v=this.entries.get(e);return v&&(this.entries.delete(e),this.totalBytes-=v.bytes),f>this.options.maxBytes?!1:(this.entries.set(e,{value:o,bytes:f}),this.totalBytes+=f,this.evictToBudget(),this.entries.has(e))}delete(e){const o=this.entries.get(e);return o?(this.entries.delete(e),this.totalBytes-=o.bytes,!0):!1}clear(){this.entries.clear(),this.totalBytes=0}evictToBudget(){for(;this.entries.size>this.options.maxEntries||this.totalBytes>this.options.maxBytes;){const e=this.entries.keys().next();if(e.done)break;this.delete(e.value)}}}function de(i){if(!Number.isFinite(i)||i<0)throw new RangeError("sizeOf must return a finite, non-negative number.");return Math.ceil(i)}const U=l.lazy(()=>x(()=>import("./PierreDiffViewer-FmgbHdls.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),ce=l.lazy(()=>x(()=>import("./PierreEditBoundary-mxtF7x3F.js"),__vite__mapDeps([15,6,1,7,8,9,12,16])).then(i=>({default:i.PierreEditBoundary}))),me=l.lazy(()=>x(()=>import("./MarkdownFileViewer-pagMxv2y.js"),__vite__mapDeps([17,1,6,7,8,9,14,18,19,20,2,3,4,5,10,11,12,16,21,22,23])).then(i=>({default:i.MarkdownFileViewer}))),he=l.lazy(()=>x(()=>import("./PullRequestViewer-oeDoq-3g.js"),__vite__mapDeps([24,6,1,7,8,9,25,14,18,19,26,23])).then(i=>({default:i.PullRequestViewer}))),pe=l.lazy(()=>x(()=>import("./EditableFileViewer-Cve4V9RS.js").then(i=>i.E),__vite__mapDeps([20,1,2,3,4,5,6,7,8,9,10,11,12,16,14,21])).then(i=>({default:i.EditableFileViewer}))),xe=l.lazy(()=>x(()=>import("./HtmlFileViewer-C3Qylr9B.js"),__vite__mapDeps([27,1,18,6,7,8,9,19,20,2,3,4,5,10,11,12,16,14,21,28])).then(i=>({default:i.HtmlFileViewer}))),ve=l.lazy(()=>x(()=>import("./ImageFileViewer-BJy0ptmR.js"),__vite__mapDeps([29,1,6,7,8,9,18,19,20,2,3,4,5,10,11,12,16,14,21,30])).then(i=>({default:i.ImageFileViewer}))),ye=l.lazy(()=>x(()=>import("./ImageFileViewer-BJy0ptmR.js"),__vite__mapDeps([29,1,6,7,8,9,18,19,20,2,3,4,5,10,11,12,16,14,21,30])).then(i=>({default:i.SvgFileViewer}))),R=new fe({maxEntries:8,maxBytes:16*1024*1024,sizeOf:i=>i.patch.length*2+i.path.length*2+256});let Q=null;function Se({repositoryId:i,selection:e,diffView:o,wrapLines:f,theme:v,revision:y,readOnly:g,commits:$,draftFor:E,onSelect:C,onOpenFile:Z,onDiffViewChange:K,onWrapLinesChange:M,onDraftChange:O,onDraftSaved:A,onUpdateConflict:W,onResolveConflict:I}){const[a,w]=l.useState(null),[ee,L]=l.useState(!1),[D,q]=l.useState(null),[P,H]=l.useState(!1),b=l.useRef(0),N=l.useRef(!1),c=je(i,e);l.useEffect(()=>{H(!1),N.current=!1},[e]),l.useEffect(()=>{Q!==i&&(R.clear(),Q=i);const s=++b.current;if(q(null),!e||e.type==="pull-request"){w(null),L(!1);return}L(!0),(async()=>{try{if(e.type==="file"||e.type==="conflict"){if(e.type==="file"&&ue(e.path)){const n=await _.repository.readImage(i,e.path);if(s!==b.current)return;w({docKey:c,type:"image",value:n});return}const u=await _.repository.readFile(i,e.path,e.type==="conflict"?!0:P);if(s!==b.current)return;if(e.type==="conflict"){w({docKey:c,type:"conflict",value:u});return}w(n=>n&&n.docKey===c&&n.type==="file"&&N.current||n&&n.docKey===c&&n.type==="file"&&n.value.content===u.content&&n.value.size===u.size&&n.value.binary===u.binary&&n.value.tooLarge===u.tooLarge?n:{docKey:c,type:"file",value:u})}else{const u=e.type!=="diff";let n=u?R.get(c):void 0;if(n||(n=e.type==="commit"?await _.diff.getCommit(i,e.oid):e.type==="commit-file"?await _.diff.getCommitFile(i,e.oid,e.path,e.oldPath):await _.diff.get({repositoryId:i,path:e.path,kind:e.kind}),u&&R.set(c,n)),s!==b.current)return;const p=n;w(d=>d&&d.docKey===c&&d.type==="diff"&&d.value.patch===p.patch&&d.value.binary===p.binary?d:{docKey:c,type:"diff",value:p})}}catch(u){s===b.current&&q(u instanceof Error?u.message:"Could not load the viewer.")}finally{s===b.current&&L(!1)}})()},[P,c,i,y,e]);const j=v==="system"?"system":v,te=f?"wrap":"scroll",S=l.useCallback(s=>{N.current=s},[]),B=l.useCallback(async(s,h,u)=>{const n=E(s),p=await _.repository.writeFile(i,s,h,n?.expectedContent??u);return p.status==="saved"&&(N.current=!1,A(s),w(d=>d?.type==="file"&&d.value.path===s?{...d,value:{...d.value,content:h,binary:!1,tooLarge:!1,size:p.size,mtimeMs:p.mtimeMs}}:d)),p},[E,A,i]),k=l.useCallback(s=>s.path,[]),z=l.useCallback(s=>E(s.path)?.content??s.content,[E]),T=l.useCallback(s=>h=>O(s.path,h,s.content,s.mtimeMs),[O]),ie=ee&&a!==null&&!D;let r,V=null;if(!e)r=t.jsx(we,{});else if(e.type==="pull-request")r=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(he,{repositoryId:i,prNumber:e.number,onSelectPullRequest:s=>C({type:"pull-request",number:s}),diffView:o,themeType:j,wrapLines:f,onDiffViewChange:K,onWrapLinesChange:M,onClose:()=>C(null)},`${i}:${e.number}`)});else if(D)r=t.jsx("div",{className:"viewer-message text-destructive",children:D});else if(!a)r=t.jsxs("div",{className:"viewer-message",children:[t.jsx(F,{className:"spinner"})," ",t.jsx(Y,{text:"Loading…"})]});else if(a.type==="image")r=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(ve,{image:a.value},`${a.value.path}:${a.value.mtimeMs}`)});else if(a.type!=="diff"&&a.value.binary)r=t.jsxs("div",{className:"viewer-message",children:["Binary file · ",X(a.value.size)]});else if(a.type==="file"&&a.value.tooLarge&&!P)r=t.jsxs("div",{className:"viewer-message flex-col gap-3",children:[t.jsxs("p",{children:["The file is ",X(a.value.size),". Preview is limited to protect performance."]}),t.jsx(J,{variant:"outline",onClick:()=>H(!0),children:"Load preview"})]});else if(a.type==="file"&&a.value.tooLarge)r=t.jsx("div",{className:"viewer-message text-destructive",children:"The file exceeds the built-in editor's 8 MB safety limit."});else if(a.type==="conflict"&&a.value.tooLarge)r=t.jsx("div",{className:"viewer-message text-destructive",children:"The conflicted file exceeds the viewer's safe limit. Open it in an external editor to resolve it."});else if(a.type==="conflict")r=null,V=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(U,{kind:"conflict",contentKey:a.docKey,file:a.value,themeType:j,overflow:te,onUpdate:W,onResolve:I})});else if(a.type==="file"&&ne(a.value.path)){const s=a.value;r=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(me,{file:s,initialContent:z(s),revision:y,themeType:j,wrapLines:f,readOnly:g||s.tooLarge,onOpenFile:Z,onDirtyChange:S,onDraftChange:T(s),onSave:B},k(s))})}else if(a.type==="file"&&re(a.value.path)){const s=a.value;r=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(ye,{file:s,initialContent:z(s),themeType:j,wrapLines:f,readOnly:g||s.tooLarge,onDirtyChange:S,onDraftChange:T(s),onSave:B},k(s))})}else if(a.type==="file"&&oe(a.value.path)){const s=a.value;r=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(xe,{file:s,initialContent:z(s),themeType:j,wrapLines:f,readOnly:g||s.tooLarge,onDirtyChange:S,onDraftChange:T(s),onSave:B},k(s))})}else if(a.type==="file"){const s=a.value;r=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(pe,{file:s,initialContent:z(s),themeType:j,wrapLines:f,readOnly:g,onDirtyChange:S,onDraftChange:T(s),onSave:B},k(s))})}else if(a.type==="diff"&&a.value.patch){const s=e.type==="commit"||e.type==="commit-file"?e:null,h=s?$.find(n=>n.oid===s.oid):void 0,u=e.type==="commit-file"?t.jsx(J,{type:"button",variant:"outline",size:"xs",onClick:()=>C({type:"commit",oid:e.oid,subject:h?.subject??e.oid.slice(0,8)}),children:"All files"}):void 0;r=null,V=t.jsxs("div",{className:s?"commit-diff-viewer":"standalone-diff-viewer",children:[s&&t.jsx(ge,{commit:h,fallbackSubject:"subject"in s?s.subject:""},s.oid),t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(U,{kind:"diff",contentKey:a.docKey,value:a.value,diffView:o,themeType:j,wrapLines:f,initiallyCollapsed:e.type==="commit",compact:e.type==="diff",scopeControl:u,onDiffViewChange:K,onWrapLinesChange:M,onClose:()=>C(null)})})]})}else a.type==="diff"?r=t.jsx("div",{className:"viewer-message",children:"No differences to show."}):r=t.jsx("div",{className:"viewer-message",children:"This file cannot be edited."});const G=t.jsxs(t.Fragment,{children:[V??t.jsx("div",{className:"viewer-transition",children:r},a?a.docKey:c),ie&&t.jsx("span",{className:"viewer-reloading","aria-hidden":"true",children:t.jsx(F,{className:"spinner"})})]});return a?.type!=="file"?G:t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(ce,{enabled:!0,children:G})})}function ge({commit:i,fallbackSubject:e}){const o=i?.date?new Date(i.date):null,[f,v]=l.useState(!1),y=i?.body??"",g=y.length>240||y.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PierreDiffViewer-8wTLYd5-.js","assets/react-rd22PHbN.js","assets/PierreWorkerPool-DH2jp9oe.js","assets/platform-Bqt97_Jr.js","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js","assets/index-CQcx9aRt.js","assets/tanstack-CtfgE41X.js","assets/base-ui-DT3JsyND.js","assets/index-DMbFAH51.css","assets/index-CtEztN1P.js","assets/File-DTtWrbYf.js","assets/EditContext-CvJWfVl1.js","assets/DiffWorkspace-Ca2ZUlVn.js","assets/App-9EfSdZB8.js","assets/PierreEditBoundary-KzU3HDc2.js","assets/edit-ready-context-D77R8XU8.js","assets/MarkdownFileViewer-BNPb9v8u.js","assets/viewer-tabs-DkLmDzFg.js","assets/viewer-tabs-D8o-L3pM.css","assets/EditableFileViewer-85aEeMBK.js","assets/EditableFileViewer-B2G3Xa33.css","assets/render-markdown-2GjhuGA-.js","assets/markdown-BpzjXclZ.css","assets/PullRequestViewer-CpLwq4o2.js","assets/GitHubAvatar-EO1TD_1z.js","assets/gh-utils-LsOSydCg.js","assets/HtmlFileViewer-bL6T57PQ.js","assets/HtmlFileViewer-D6UPnZvW.css","assets/ImageFileViewer-DJaHH3hJ.js","assets/ImageFileViewer-D8TdwFTO.css"])))=>i.map(i=>d[i]);
2
+ import{o as _,B as J,_ as x,T as se,a as ae,b as le}from"./index-CQcx9aRt.js";import{r as l,j as t}from"./react-rd22PHbN.js";import{H as ne,J as re,K as oe,k as F,L as ue,G as Y}from"./App-9EfSdZB8.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";class fe{constructor(e){if(this.options=e,!Number.isInteger(e.maxEntries)||e.maxEntries<1)throw new RangeError("maxEntries must be a positive integer.");if(!Number.isFinite(e.maxBytes)||e.maxBytes<1)throw new RangeError("maxBytes must be a positive number.")}options;entries=new Map;totalBytes=0;get size(){return this.entries.size}get bytes(){return this.totalBytes}get(e){const o=this.entries.get(e);if(o)return this.entries.delete(e),this.entries.set(e,o),o.value}set(e,o){const f=ce(this.options.sizeOf(o)),v=this.entries.get(e);return v&&(this.entries.delete(e),this.totalBytes-=v.bytes),f>this.options.maxBytes?!1:(this.entries.set(e,{value:o,bytes:f}),this.totalBytes+=f,this.evictToBudget(),this.entries.has(e))}delete(e){const o=this.entries.get(e);return o?(this.entries.delete(e),this.totalBytes-=o.bytes,!0):!1}clear(){this.entries.clear(),this.totalBytes=0}evictToBudget(){for(;this.entries.size>this.options.maxEntries||this.totalBytes>this.options.maxBytes;){const e=this.entries.keys().next();if(e.done)break;this.delete(e.value)}}}function ce(i){if(!Number.isFinite(i)||i<0)throw new RangeError("sizeOf must return a finite, non-negative number.");return Math.ceil(i)}const U=l.lazy(()=>x(()=>import("./PierreDiffViewer-8wTLYd5-.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),de=l.lazy(()=>x(()=>import("./PierreEditBoundary-KzU3HDc2.js"),__vite__mapDeps([15,6,1,7,8,9,12,16])).then(i=>({default:i.PierreEditBoundary}))),me=l.lazy(()=>x(()=>import("./MarkdownFileViewer-BNPb9v8u.js"),__vite__mapDeps([17,1,6,7,8,9,14,18,19,20,2,3,4,5,10,11,12,16,21,22,23])).then(i=>({default:i.MarkdownFileViewer}))),he=l.lazy(()=>x(()=>import("./PullRequestViewer-CpLwq4o2.js"),__vite__mapDeps([24,6,1,7,8,9,25,14,18,19,26,23])).then(i=>({default:i.PullRequestViewer}))),pe=l.lazy(()=>x(()=>import("./EditableFileViewer-85aEeMBK.js").then(i=>i.E),__vite__mapDeps([20,1,2,3,4,5,6,7,8,9,10,11,12,16,14,21])).then(i=>({default:i.EditableFileViewer}))),xe=l.lazy(()=>x(()=>import("./HtmlFileViewer-bL6T57PQ.js"),__vite__mapDeps([27,1,18,6,7,8,9,19,20,2,3,4,5,10,11,12,16,14,21,28])).then(i=>({default:i.HtmlFileViewer}))),ve=l.lazy(()=>x(()=>import("./ImageFileViewer-DJaHH3hJ.js"),__vite__mapDeps([29,1,6,7,8,9,18,19,20,2,3,4,5,10,11,12,16,14,21,30])).then(i=>({default:i.ImageFileViewer}))),ye=l.lazy(()=>x(()=>import("./ImageFileViewer-DJaHH3hJ.js"),__vite__mapDeps([29,1,6,7,8,9,18,19,20,2,3,4,5,10,11,12,16,14,21,30])).then(i=>({default:i.SvgFileViewer}))),R=new fe({maxEntries:8,maxBytes:16*1024*1024,sizeOf:i=>i.patch.length*2+i.path.length*2+256});let Q=null;function Se({repositoryId:i,selection:e,diffView:o,wrapLines:f,theme:v,revision:y,readOnly:g,commits:$,draftFor:E,onSelect:C,onOpenFile:Z,onDiffViewChange:K,onWrapLinesChange:M,onDraftChange:O,onDraftSaved:A,onUpdateConflict:W,onResolveConflict:I}){const[a,w]=l.useState(null),[ee,L]=l.useState(!1),[D,q]=l.useState(null),[P,H]=l.useState(!1),b=l.useRef(0),N=l.useRef(!1),d=je(i,e);l.useEffect(()=>{H(!1),N.current=!1},[e]),l.useEffect(()=>{Q!==i&&(R.clear(),Q=i);const s=++b.current;if(q(null),!e||e.type==="pull-request"){w(null),L(!1);return}L(!0),(async()=>{try{if(e.type==="file"||e.type==="conflict"){if(e.type==="file"&&ue(e.path)){const n=await _.repository.readImage(i,e.path);if(s!==b.current)return;w({docKey:d,type:"image",value:n});return}const u=await _.repository.readFile(i,e.path,e.type==="conflict"?!0:P);if(s!==b.current)return;if(e.type==="conflict"){w({docKey:d,type:"conflict",value:u});return}w(n=>n&&n.docKey===d&&n.type==="file"&&N.current||n&&n.docKey===d&&n.type==="file"&&n.value.content===u.content&&n.value.size===u.size&&n.value.binary===u.binary&&n.value.tooLarge===u.tooLarge?n:{docKey:d,type:"file",value:u})}else{const u=e.type!=="diff";let n=u?R.get(d):void 0;if(n||(n=e.type==="commit"?await _.diff.getCommit(i,e.oid):e.type==="commit-file"?await _.diff.getCommitFile(i,e.oid,e.path,e.oldPath):await _.diff.get({repositoryId:i,path:e.path,kind:e.kind}),u&&R.set(d,n)),s!==b.current)return;const p=n;w(c=>c&&c.docKey===d&&c.type==="diff"&&c.value.patch===p.patch&&c.value.binary===p.binary?c:{docKey:d,type:"diff",value:p})}}catch(u){s===b.current&&q(u instanceof Error?u.message:"Could not load the viewer.")}finally{s===b.current&&L(!1)}})()},[P,d,i,y,e]);const j=v==="system"?"system":v,te=f?"wrap":"scroll",S=l.useCallback(s=>{N.current=s},[]),B=l.useCallback(async(s,h,u)=>{const n=E(s),p=await _.repository.writeFile(i,s,h,n?.expectedContent??u);return p.status==="saved"&&(N.current=!1,A(s),w(c=>c?.type==="file"&&c.value.path===s?{...c,value:{...c.value,content:h,binary:!1,tooLarge:!1,size:p.size,mtimeMs:p.mtimeMs}}:c)),p},[E,A,i]),k=l.useCallback(s=>s.path,[]),z=l.useCallback(s=>E(s.path)?.content??s.content,[E]),T=l.useCallback(s=>h=>O(s.path,h,s.content,s.mtimeMs),[O]),ie=ee&&a!==null&&!D;let r,V=null;if(!e)r=t.jsx(we,{});else if(e.type==="pull-request")r=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(he,{repositoryId:i,prNumber:e.number,onSelectPullRequest:s=>C({type:"pull-request",number:s}),diffView:o,themeType:j,wrapLines:f,onDiffViewChange:K,onWrapLinesChange:M,onClose:()=>C(null)},`${i}:${e.number}`)});else if(D)r=t.jsx("div",{className:"viewer-message text-destructive",children:D});else if(!a)r=t.jsxs("div",{className:"viewer-message",children:[t.jsx(F,{className:"spinner"})," ",t.jsx(Y,{text:"Loading…"})]});else if(a.type==="image")r=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(ve,{image:a.value},`${a.value.path}:${a.value.mtimeMs}`)});else if(a.type!=="diff"&&a.value.binary)r=t.jsxs("div",{className:"viewer-message",children:["Binary file · ",X(a.value.size)]});else if(a.type==="file"&&a.value.tooLarge&&!P)r=t.jsxs("div",{className:"viewer-message flex-col gap-3",children:[t.jsxs("p",{children:["The file is ",X(a.value.size),". Preview is limited to protect performance."]}),t.jsx(J,{variant:"outline",onClick:()=>H(!0),children:"Load preview"})]});else if(a.type==="file"&&a.value.tooLarge)r=t.jsx("div",{className:"viewer-message text-destructive",children:"The file exceeds the built-in editor's 8 MB safety limit."});else if(a.type==="conflict"&&a.value.tooLarge)r=t.jsx("div",{className:"viewer-message text-destructive",children:"The conflicted file exceeds the viewer's safe limit. Open it in an external editor to resolve it."});else if(a.type==="conflict")r=null,V=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(U,{kind:"conflict",contentKey:a.docKey,file:a.value,themeType:j,overflow:te,onUpdate:W,onResolve:I})});else if(a.type==="file"&&ne(a.value.path)){const s=a.value;r=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(me,{repositoryId:i,file:s,initialContent:z(s),revision:y,themeType:j,wrapLines:f,readOnly:g||s.tooLarge,onOpenFile:Z,onDirtyChange:S,onDraftChange:T(s),onSave:B},k(s))})}else if(a.type==="file"&&re(a.value.path)){const s=a.value;r=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(ye,{file:s,initialContent:z(s),themeType:j,wrapLines:f,readOnly:g||s.tooLarge,onDirtyChange:S,onDraftChange:T(s),onSave:B},k(s))})}else if(a.type==="file"&&oe(a.value.path)){const s=a.value;r=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(xe,{file:s,initialContent:z(s),themeType:j,wrapLines:f,readOnly:g||s.tooLarge,onDirtyChange:S,onDraftChange:T(s),onSave:B},k(s))})}else if(a.type==="file"){const s=a.value;r=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(pe,{file:s,initialContent:z(s),themeType:j,wrapLines:f,readOnly:g,onDirtyChange:S,onDraftChange:T(s),onSave:B},k(s))})}else if(a.type==="diff"&&a.value.patch){const s=e.type==="commit"||e.type==="commit-file"?e:null,h=s?$.find(n=>n.oid===s.oid):void 0,u=e.type==="commit-file"?t.jsx(J,{type:"button",variant:"outline",size:"xs",onClick:()=>C({type:"commit",oid:e.oid,subject:h?.subject??e.oid.slice(0,8)}),children:"All files"}):void 0;r=null,V=t.jsxs("div",{className:s?"commit-diff-viewer":"standalone-diff-viewer",children:[s&&t.jsx(ge,{commit:h,fallbackSubject:"subject"in s?s.subject:""},s.oid),t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(U,{kind:"diff",contentKey:a.docKey,value:a.value,diffView:o,themeType:j,wrapLines:f,initiallyCollapsed:e.type==="commit",compact:e.type==="diff",scopeControl:u,onDiffViewChange:K,onWrapLinesChange:M,onClose:()=>C(null)})})]})}else a.type==="diff"?r=t.jsx("div",{className:"viewer-message",children:"No differences to show."}):r=t.jsx("div",{className:"viewer-message",children:"This file cannot be edited."});const G=t.jsxs(t.Fragment,{children:[V??t.jsx("div",{className:"viewer-transition",children:r},a?a.docKey:d),ie&&t.jsx("span",{className:"viewer-reloading","aria-hidden":"true",children:t.jsx(F,{className:"spinner"})})]});return a?.type!=="file"?G:t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(de,{enabled:!0,children:G})})}function ge({commit:i,fallbackSubject:e}){const o=i?.date?new Date(i.date):null,[f,v]=l.useState(!1),y=i?.body??"",g=y.length>240||y.split(`
3
3
  `).length>3;return t.jsxs("header",{className:"commit-diff-header",children:[t.jsx("h2",{children:i?.subject||e||"(no subject)"}),y&&t.jsxs("div",{className:"commit-diff-description-wrap",children:[t.jsx("p",{className:`commit-diff-description ${g&&!f?"collapsed":""}`,children:y}),g&&t.jsx("button",{type:"button",className:"commit-description-toggle","aria-expanded":f,onClick:()=>v($=>!$),children:f?"Show less":"Show full description"})]}),t.jsxs("div",{className:"commit-diff-meta",children:[t.jsx("code",{children:i?.shortOid??"commit"}),i?.author&&t.jsxs("span",{children:[i.author,i.email?` <${i.email}>`:""]}),o&&Number.isFinite(o.getTime())&&t.jsxs(se,{children:[t.jsx(ae,{render:t.jsx("time",{dateTime:i?.date}),children:o.toLocaleString()}),t.jsx(le,{children:o.toLocaleString()})]}),i?.parentCount&&i.parentCount>1?t.jsx("span",{children:"Merge commit"}):null,i?.upstreamState==="local-only"&&t.jsx("span",{className:"commit-local-label",children:"Local only"})]})]})}function je(i,e){return e?e.type==="pull-request"?`${i}:pull:${e.number}`:e.type==="commit"?`${i}:commit:${e.oid}`:e.type==="commit-file"?`${i}:commit-file:${e.oid}:${e.oldPath??""}:${e.path}`:e.type==="diff"?`${i}:diff:${e.kind}:${e.path}`:`${i}:${e.type}:${e.path}`:`${i}:empty`}function m(){return t.jsxs("div",{className:"viewer-message",children:[t.jsx(F,{className:"spinner"})," ",t.jsx(Y,{text:"Loading viewer…"})]})}function we(){return t.jsxs("div",{className:"viewer-empty",children:[t.jsx("h2",{children:"Nothing selected"}),t.jsx("p",{children:"Select a change, file, commit, or pull request."})]})}function X(i){return i?i<1024?`${i} B`:i<1024*1024?`${(i/1024).toFixed(1)} KB`:`${(i/1024/1024).toFixed(1)} MB`:"unknown size"}export{Se as default};
@@ -1 +1 @@
1
- import{g as p,r as u,d as a}from"./chunk-6Q2QTUOP-BRGuFKSr.js";import{p as f}from"./chunk-JWPE2WC7-rGurufZY.js";import{_ as n,l as s}from"./mermaid.core-B-iLnCqi.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-DX7Kb3Ft.js";import"./index-ChKJF4C_.js";import"./react-rd22PHbN.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";import"./render-markdown-BiKX2Zdv.js";import"./App-CGiS2z40.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,o]=e.split("*"),m=t?parseInt(t,10):0,l=o?parseInt(o,10):1/0;return{min:m,max:l}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:o}=b(e.repeat);return t===0&&o===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:o}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),s.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;s.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),s.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},$={parser:R,db:a,renderer:u,styles:p};export{$ as diagram};
1
+ import{g as p,r as u,d as a}from"./chunk-6Q2QTUOP-DfGlvPVm.js";import{p as f}from"./chunk-JWPE2WC7-CFRTGh8r.js";import{_ as n,l as s}from"./mermaid.core-C0FKucv-.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-DwLwbeoe.js";import"./index-CQcx9aRt.js";import"./react-rd22PHbN.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";import"./render-markdown-2GjhuGA-.js";import"./App-9EfSdZB8.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,o]=e.split("*"),m=t?parseInt(t,10):0,l=o?parseInt(o,10):1/0;return{min:m,max:l}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:o}=b(e.repeat);return t===0&&o===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:o}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),s.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;s.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),s.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},$={parser:R,db:a,renderer:u,styles:p};export{$ as diagram};
@@ -1 +1 @@
1
- import{G as ln,H as un,I as N,J as I,K as J,L as an,M as y,N as tn,O as j,P as _,Q as rn,R as o,S as on,T as sn,V as fn}from"./mermaid.core-B-iLnCqi.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,q,O,v,R,K,u){var D=q-l,i=O-h,n=K-v,d=u-R,a=d*D-n*i;if(!(a*a<y))return a=(n*(h-R)-d*(l-v))/a,[l+a*D,h+a*i]}function W(l,h,q,O,v,R,K){var u=l-q,D=h-O,i=(K?R:-R)/j(u*u+D*D),n=i*D,d=-i*u,a=l+n,s=h+d,f=q+n,c=O+d,L=(a+f)/2,t=(s+c)/2,m=f-a,g=c-s,A=m*m+g*g,T=v-R,P=a*c-f*s,E=(g<0?-1:1)*j(on(0,T*T*A-P*P)),G=(P*g-m*E)/A,H=(-P*m-g*E)/A,w=(P*g+m*E)/A,p=(-P*m+g*E)/A,x=G-L,e=H-t,r=w-L,M=p-t;return x*x+e*e>r*r+M*M&&(G=w,H=p),{cx:G,cy:H,x01:-n,y01:-d,x11:G*(v/T-1),y11:H*(v/T-1)}}function hn(){var l=cn,h=yn,q=J(0),O=null,v=gn,R=dn,K=mn,u=null,D=ln(i);function i(){var n,d,a=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=R.apply(this,arguments)-an,L=rn(c-f),t=c>f;if(u||(u=n=D()),s<a&&(d=s,s=a,a=d),!(s>y))u.moveTo(0,0);else if(L>tn-y)u.moveTo(s*N(f),s*I(f)),u.arc(0,0,s,f,c,!t),a>y&&(u.moveTo(a*N(c),a*I(c)),u.arc(0,0,a,c,f,t));else{var m=f,g=c,A=f,T=c,P=L,E=L,G=K.apply(this,arguments)/2,H=G>y&&(O?+O.apply(this,arguments):j(a*a+s*s)),w=_(rn(s-a)/2,+q.apply(this,arguments)),p=w,x=w,e,r;if(H>y){var M=sn(H/a*I(G)),z=sn(H/s*I(G));(P-=M*2)>y?(M*=t?1:-1,A+=M,T-=M):(P=0,A=T=(f+c)/2),(E-=z*2)>y?(z*=t?1:-1,m+=z,g-=z):(E=0,m=g=(f+c)/2)}var Q=s*N(m),V=s*I(m),B=a*N(T),C=a*I(T);if(w>y){var F=s*N(g),U=s*I(g),X=a*N(A),Y=a*I(A),S;if(L<un)if(S=pn(Q,V,X,Y,F,U,B,C)){var Z=Q-S[0],$=V-S[1],k=F-S[0],b=U-S[1],nn=1/I(fn((Z*k+$*b)/(j(Z*Z+$*$)*j(k*k+b*b)))/2),en=j(S[0]*S[0]+S[1]*S[1]);p=_(w,(a-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}E>y?x>y?(e=W(X,Y,Q,V,s,x,t),r=W(F,U,B,C,s,x,t),u.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),u.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(u.moveTo(Q,V),u.arc(0,0,s,m,g,!t)):u.moveTo(Q,V),!(a>y)||!(P>y)?u.lineTo(B,C):p>y?(e=W(B,C,F,U,a,-p,t),r=W(Q,V,X,Y,a,-p,t),u.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,a,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),u.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):u.arc(0,0,a,T,A,t)}if(u.closePath(),n)return u=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-un/2;return[N(d)*n,I(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:J(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:J(+n),i):h},i.cornerRadius=function(n){return arguments.length?(q=typeof n=="function"?n:J(+n),i):q},i.padRadius=function(n){return arguments.length?(O=n==null?null:typeof n=="function"?n:J(+n),i):O},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:J(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:J(+n),i):R},i.padAngle=function(n){return arguments.length?(K=typeof n=="function"?n:J(+n),i):K},i.context=function(n){return arguments.length?(u=n??null,i):u},i}export{hn as d};
1
+ import{G as ln,H as un,I as N,J as I,K as J,L as an,M as y,N as tn,O as j,P as _,Q as rn,R as o,S as on,T as sn,V as fn}from"./mermaid.core-C0FKucv-.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,q,O,v,R,K,u){var D=q-l,i=O-h,n=K-v,d=u-R,a=d*D-n*i;if(!(a*a<y))return a=(n*(h-R)-d*(l-v))/a,[l+a*D,h+a*i]}function W(l,h,q,O,v,R,K){var u=l-q,D=h-O,i=(K?R:-R)/j(u*u+D*D),n=i*D,d=-i*u,a=l+n,s=h+d,f=q+n,c=O+d,L=(a+f)/2,t=(s+c)/2,m=f-a,g=c-s,A=m*m+g*g,T=v-R,P=a*c-f*s,E=(g<0?-1:1)*j(on(0,T*T*A-P*P)),G=(P*g-m*E)/A,H=(-P*m-g*E)/A,w=(P*g+m*E)/A,p=(-P*m+g*E)/A,x=G-L,e=H-t,r=w-L,M=p-t;return x*x+e*e>r*r+M*M&&(G=w,H=p),{cx:G,cy:H,x01:-n,y01:-d,x11:G*(v/T-1),y11:H*(v/T-1)}}function hn(){var l=cn,h=yn,q=J(0),O=null,v=gn,R=dn,K=mn,u=null,D=ln(i);function i(){var n,d,a=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=R.apply(this,arguments)-an,L=rn(c-f),t=c>f;if(u||(u=n=D()),s<a&&(d=s,s=a,a=d),!(s>y))u.moveTo(0,0);else if(L>tn-y)u.moveTo(s*N(f),s*I(f)),u.arc(0,0,s,f,c,!t),a>y&&(u.moveTo(a*N(c),a*I(c)),u.arc(0,0,a,c,f,t));else{var m=f,g=c,A=f,T=c,P=L,E=L,G=K.apply(this,arguments)/2,H=G>y&&(O?+O.apply(this,arguments):j(a*a+s*s)),w=_(rn(s-a)/2,+q.apply(this,arguments)),p=w,x=w,e,r;if(H>y){var M=sn(H/a*I(G)),z=sn(H/s*I(G));(P-=M*2)>y?(M*=t?1:-1,A+=M,T-=M):(P=0,A=T=(f+c)/2),(E-=z*2)>y?(z*=t?1:-1,m+=z,g-=z):(E=0,m=g=(f+c)/2)}var Q=s*N(m),V=s*I(m),B=a*N(T),C=a*I(T);if(w>y){var F=s*N(g),U=s*I(g),X=a*N(A),Y=a*I(A),S;if(L<un)if(S=pn(Q,V,X,Y,F,U,B,C)){var Z=Q-S[0],$=V-S[1],k=F-S[0],b=U-S[1],nn=1/I(fn((Z*k+$*b)/(j(Z*Z+$*$)*j(k*k+b*b)))/2),en=j(S[0]*S[0]+S[1]*S[1]);p=_(w,(a-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}E>y?x>y?(e=W(X,Y,Q,V,s,x,t),r=W(F,U,B,C,s,x,t),u.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),u.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(u.moveTo(Q,V),u.arc(0,0,s,m,g,!t)):u.moveTo(Q,V),!(a>y)||!(P>y)?u.lineTo(B,C):p>y?(e=W(B,C,F,U,a,-p,t),r=W(Q,V,X,Y,a,-p,t),u.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,a,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),u.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):u.arc(0,0,a,T,A,t)}if(u.closePath(),n)return u=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-un/2;return[N(d)*n,I(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:J(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:J(+n),i):h},i.cornerRadius=function(n){return arguments.length?(q=typeof n=="function"?n:J(+n),i):q},i.padRadius=function(n){return arguments.length?(O=n==null?null:typeof n=="function"?n:J(+n),i):O},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:J(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:J(+n),i):R},i.padAngle=function(n){return arguments.length?(K=typeof n=="function"?n:J(+n),i):K},i.context=function(n){return arguments.length?(u=n??null,i):u},i}export{hn as d};