codeharden 2026.1122.2133 → 2026.1122.2302

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 (108) hide show
  1. package/README.md +48 -3
  2. package/dist/{args-B0i5tyjE.js → args-BJ0ric8X.js} +5 -5
  3. package/dist/args-BJ0ric8X.js.map +1 -0
  4. package/dist/cli.js +2 -2
  5. package/dist/{commands-CvAvyECH.js → commands-BPobEsBP.js} +33 -14
  6. package/dist/commands-BPobEsBP.js.map +1 -0
  7. package/dist/{env-wDgRchH9.js → env-CMkse2o0.js} +2 -2
  8. package/dist/{env-wDgRchH9.js.map → env-CMkse2o0.js.map} +1 -1
  9. package/dist/{harden-channel-2IT0Y7p3.js → harden-channel-D7h06kQ_.js} +41 -3
  10. package/dist/harden-channel-D7h06kQ_.js.map +1 -0
  11. package/dist/{launcher-D17oQovS.js → launcher-CvQZcEIC.js} +3 -3
  12. package/dist/launcher-CvQZcEIC.js.map +1 -0
  13. package/dist/{lock-DxXcNd2w.js → lock-iovTSSb0.js} +2 -2
  14. package/dist/{lock-DxXcNd2w.js.map → lock-iovTSSb0.js.map} +1 -1
  15. package/dist/{main-BRHfJHGf.js → main-BFo94KOF.js} +6 -6
  16. package/dist/{main-BRHfJHGf.js.map → main-BFo94KOF.js.map} +1 -1
  17. package/dist/{main-CJdbWeA_.js → main-B_ui4G93.js} +3 -3
  18. package/dist/{main-CJdbWeA_.js.map → main-B_ui4G93.js.map} +1 -1
  19. package/dist/{mediaType-e66mt7Cb.js → mediaType-DHbUOwRj.js} +2 -2
  20. package/dist/{mediaType-e66mt7Cb.js.map → mediaType-DHbUOwRj.js.map} +1 -1
  21. package/dist/{runner-CKo8zFVx.js → runner-agAgr2qn.js} +5 -5
  22. package/dist/{runner-CKo8zFVx.js.map → runner-agAgr2qn.js.map} +1 -1
  23. package/dist/{runner-link-CGefyJ5U.js → runner-link-B7SsTYaz.js} +3 -3
  24. package/dist/{runner-link-CGefyJ5U.js.map → runner-link-B7SsTYaz.js.map} +1 -1
  25. package/dist/runner.js +1 -1
  26. package/dist/{server-test-aa-ENBUk.js → server-test-Cad_bM68.js} +4 -4
  27. package/dist/{server-test-aa-ENBUk.js.map → server-test-Cad_bM68.js.map} +1 -1
  28. package/dist/{src-CwV8i4Mj.js → src-BPcdaWEw.js} +4 -6
  29. package/dist/{src-CwV8i4Mj.js.map → src-BPcdaWEw.js.map} +1 -1
  30. package/dist/web/assets/{add-project-dialog-VBi3WXnh.js → add-project-dialog-BHbgORVh.js} +1 -1
  31. package/dist/web/assets/{agent-tabs-BNgrQWDq.js → agent-tabs-B6uUKAXD.js} +1 -1
  32. package/dist/web/assets/{agents-Ir1aHz-I.js → agents-NbcZbVrc.js} +1 -1
  33. package/dist/web/assets/{api-jkvqht5P.js → api-B9OffDXw.js} +1 -1
  34. package/dist/web/assets/{api-B620HpC2.js → api-yvn34iKU.js} +27 -27
  35. package/dist/web/assets/{archived-sessions-D4fJHB37.js → archived-sessions-C1-stU7x.js} +1 -1
  36. package/dist/web/assets/{automation-B91XTDIM.js → automation-Co7V1tcW.js} +1 -1
  37. package/dist/web/assets/{automation-new-CN7YhryW.js → automation-new-hCV8HoK1.js} +1 -1
  38. package/dist/web/assets/{automations-CLzVG-zc.js → automations-7GJxGbPp.js} +1 -1
  39. package/dist/web/assets/{composer-Dd8joSgj.js → composer-B1tdNGSi.js} +1 -1
  40. package/dist/web/assets/{conflict-card-BN9kNMVL.js → conflict-card-Bx8tT_d5.js} +1 -1
  41. package/dist/web/assets/{dialog-Dyw3b_Tu.js → dialog-Cvj_lHPY.js} +1 -1
  42. package/dist/web/assets/{diff-panel-CQ2XZMk2.js → diff-panel-BHhM9z93.js} +1 -1
  43. package/dist/web/assets/{draft-BmnE6-7J.js → draft-JkaN3nCS.js} +1 -1
  44. package/dist/web/assets/{dropdown-menu-C4XI7F63.js → dropdown-menu-Bflkx6wY.js} +1 -1
  45. package/dist/web/assets/{engines-Chq2ih3x.js → engines-pLQJYIu_.js} +1 -1
  46. package/dist/web/assets/{factory-BBYEYI9i.js → factory-DVCs5zxg.js} +1 -1
  47. package/dist/web/assets/{factory-columns-CtJOpFim.js → factory-columns-DExb6gW2.js} +1 -1
  48. package/dist/web/assets/{factory-item-BjydL6AH.js → factory-item-efMFkxnv.js} +1 -1
  49. package/dist/web/assets/{factory-view-BU2AKcD8.js → factory-view-Cot7flHA.js} +1 -1
  50. package/dist/web/assets/{files-panel-B6_6pSo9.js → files-panel-BIkR_seN.js} +1 -1
  51. package/dist/web/assets/{floor-scene-DCpEq0j7.js → floor-scene-DGy8i_5R.js} +1 -1
  52. package/dist/web/assets/{form-bits-BSfnSmQ7.js → form-bits-5XojWhBG.js} +1 -1
  53. package/dist/web/assets/{format-D1ma_o2D.js → format-D3kairnQ.js} +1 -1
  54. package/dist/web/assets/{home-_m_Aihwv.js → home-BtFPGjza.js} +1 -1
  55. package/dist/web/assets/{inbox-FDD5FMWW.js → inbox-CUPkJ4WC.js} +1 -1
  56. package/dist/web/assets/{index-BkpVvQrC.js → index-C0C9GyeX.js} +4 -4
  57. package/dist/web/assets/{item-parts-BhDFWsT1.js → item-parts-DZ3TQad4.js} +1 -1
  58. package/dist/web/assets/{kill-switch-Dvqaozhz.js → kill-switch-BDAFCjui.js} +1 -1
  59. package/dist/web/assets/{label-DcWfyglU.js → label-Bm_8Eqe2.js} +1 -1
  60. package/dist/web/assets/{local-whisper-test-DPTOEA1M.js → local-whisper-test-CqGlAOvK.js} +1 -1
  61. package/dist/web/assets/{markdown-ad2jia51.js → markdown-DGHfubu-.js} +1 -1
  62. package/dist/web/assets/{mobile-nav-D8FZcJzG.js → mobile-nav-CrjrDJZ5.js} +1 -1
  63. package/dist/web/assets/{model-picker-4yoJPkRY.js → model-picker-DnKv2cbc.js} +1 -1
  64. package/dist/web/assets/{new-session-ddLbjOoZ.js → new-session-Bc93-xJK.js} +1 -1
  65. package/dist/web/assets/{new-session-GpxXZWbB.js → new-session-CUpOffXI.js} +1 -1
  66. package/dist/web/assets/{new-session-CwbgcYzY.js → new-session-DVYesr8z.js} +1 -1
  67. package/dist/web/assets/{now-next-D-6j1g_S.js → now-next-x8fwFm7p.js} +1 -1
  68. package/dist/web/assets/{on-demand-Cvu5D9uT.js → on-demand-Cvi90jRi.js} +2 -2
  69. package/dist/web/assets/{open-pr-controls--EtUvzD2.js → open-pr-controls-CYypJCKQ.js} +1 -1
  70. package/dist/web/assets/{orchestration-pknfiYFr.js → orchestration-BZj0HlxR.js} +1 -1
  71. package/dist/web/assets/{page-header-BqPf-jRo.js → page-header-t9HzSrxd.js} +1 -1
  72. package/dist/web/assets/{pm-fMuSJMPP.js → pm-DJfHcB90.js} +1 -1
  73. package/dist/web/assets/{popover-OrzLEhHL.js → popover-BqwWmyWQ.js} +1 -1
  74. package/dist/web/assets/{pr-details-BBVM9Kll.js → pr-details-1hhbiFWa.js} +1 -1
  75. package/dist/web/assets/{project-ws85aDq4.js → project-dy2_DT0H.js} +1 -1
  76. package/dist/web/assets/{question-card-4aNx5IRX.js → question-card-ldxLXNS_.js} +1 -1
  77. package/dist/web/assets/{remote-check-BAPXUznK.js → remote-check-CQktPgyp.js} +2 -2
  78. package/dist/web/assets/{reports-BZj5_wsp.js → reports-D0GAsXFv.js} +1 -1
  79. package/dist/web/assets/{role-chat-CeJXMsYB.js → role-chat-nIyzM-vQ.js} +1 -1
  80. package/dist/web/assets/{run-conflict-CPr9OWa3.js → run-conflict-BlgKVpOG.js} +1 -1
  81. package/dist/web/assets/{runs-table-DpBJ4ZeQ.js → runs-table-DMPF5_D6.js} +1 -1
  82. package/dist/web/assets/{search-BFTvT67N.js → search-gwjIEGis.js} +1 -1
  83. package/dist/web/assets/{search-Da3B5-lr.js → search-hK5b8Xwb.js} +1 -1
  84. package/dist/web/assets/{select-B4LGxZQI.js → select-B1ES0hhy.js} +1 -1
  85. package/dist/web/assets/{session-_62x2rSZ.js → session-CPUTlq1O.js} +1 -1
  86. package/dist/web/assets/{settings-CUYuBL-5.js → settings-DRd0b0Kz.js} +1 -1
  87. package/dist/web/assets/{settings-ui-Ux8rPFol.js → settings-ui-Bc6ymtc_.js} +1 -1
  88. package/dist/web/assets/{setup-BKOOV6vX.js → setup-Bn2CFYAt.js} +1 -1
  89. package/dist/web/assets/{shallow-CbfSRfYC.js → shallow-BUNpybIA.js} +1 -1
  90. package/dist/web/assets/{spec-approval-9S-jPMrI.js → spec-approval-CmC6QBSh.js} +1 -1
  91. package/dist/web/assets/{spot-check-actions-5CmYjt8A.js → spot-check-actions-DzMUED1O.js} +1 -1
  92. package/dist/web/assets/{spot-checks-BadmkHuG.js → spot-checks-CDZxwwu0.js} +1 -1
  93. package/dist/web/assets/{storeys-OlWmOmqA.js → storeys-BEgFUsix.js} +1 -1
  94. package/dist/web/assets/{switch-DuBpF2_h.js → switch-BHplnCdo.js} +1 -1
  95. package/dist/web/assets/{terminal-view-ChO1pNp0.js → terminal-view-WNT8FI6K.js} +1 -1
  96. package/dist/web/assets/{theme-DsW-i9mD.js → theme-3eeE0sp4.js} +1 -1
  97. package/dist/web/assets/{thread-view-CPlJsMhl.js → thread-view-AQKzJlKb.js} +1 -1
  98. package/dist/web/assets/{update-banner-CNYd8gAf.js → update-banner-CZGRgiG8.js} +1 -1
  99. package/dist/web/assets/{updates-CQZDqpFF.js → updates-4l7pwDq1.js} +1 -1
  100. package/dist/web/assets/{use-retry-item-CWwb3JGo.js → use-retry-item-3n4BD_3J.js} +1 -1
  101. package/dist/web/assets/{vision-7gkgZ-Ap.js → vision-Z1sLHr_c.js} +1 -1
  102. package/dist/web/assets/{wip-chip-D5-cZcfN.js → wip-chip-DXwuAo3A.js} +1 -1
  103. package/dist/web/index.html +34 -34
  104. package/package.json +1 -1
  105. package/dist/args-B0i5tyjE.js.map +0 -1
  106. package/dist/commands-CvAvyECH.js.map +0 -1
  107. package/dist/harden-channel-2IT0Y7p3.js.map +0 -1
  108. package/dist/launcher-D17oQovS.js.map +0 -1
@@ -1 +1 @@
1
- import{i as e}from"./api-B620HpC2.js";import{t}from"./jsx-runtime-C3cWAN_r.js";import{F as n}from"./useQuery-VSotSwry.js";import{j as r,m as i,yt as a}from"./format-D1ma_o2D.js";import{y as o}from"./dropdown-menu-C4XI7F63.js";import{C as s,F as c,I as l,R as u,S as d,T as f,_ as p,b as m,v as h,w as g,x as _,y as v}from"./mobile-nav-D8FZcJzG.js";import{d as y}from"./switch-DuBpF2_h.js";import{Cr as b,Fn as x,Kn as S,Zt as C,h as w,n as T}from"./icons-COCLuOtb.js";import{t as E}from"./conflict-card-BN9kNMVL.js";var D=t();function O({item:e}){let t=e.automation.createdBy;return(0,D.jsxs)(D.Fragment,{children:[e.readOnly&&(0,D.jsxs)(c,{children:[(0,D.jsx)(u,{asChild:!0,children:(0,D.jsxs)(`span`,{className:`flex items-center gap-1 rounded bg-muted px-1.5 py-px text-3xs text-muted-foreground`,"data-testid":`from-file-badge`,children:[(0,D.jsx)(x,{className:`size-3`}),` From file`]})}),(0,D.jsxs)(l,{className:`font-mono`,children:[e.path??`Built in`,` · edit the file, or duplicate it to edit here`]})]}),t===`pm`&&(0,D.jsxs)(`span`,{className:`flex items-center gap-1 rounded bg-primary/10 px-1.5 py-px text-3xs text-primary`,children:[(0,D.jsx)(b,{className:`size-3`}),` Created by the PM`]}),t===`import`&&(0,D.jsxs)(`span`,{className:`flex items-center gap-1 rounded bg-muted px-1.5 py-px text-3xs text-muted-foreground`,children:[(0,D.jsx)(C,{className:`size-3`}),` Imported`]})]})}function k({item:t,projectId:c}){let l=e(),u=n(),b=y(),x=t.automation,C=e=>void b({to:`/projects/$projectId/automations/$automationId`,params:{projectId:c,automationId:e}}),T=a({mutationFn:()=>l.automations.duplicate(x.id,x.target.type===`project`?{projectId:c}:{}),onSuccess:e=>{u.invalidateQueries({queryKey:o.all}),r.success(`${e.automation.name} created, off`),C(e.automation.id)},onError:e=>r.error(`Couldn't duplicate`,{description:e.message})}),E=a({mutationFn:()=>l.automations.remove(x.id),onSuccess:()=>{u.invalidateQueries({queryKey:o.all}),r.success(`${x.name} deleted`),b({to:`/projects/$projectId/automations`,params:{projectId:c}})},onError:e=>r.error(`Couldn't delete`,{description:e.message})});return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(i,{size:`sm`,variant:t.readOnly?`default`:`ghost`,onClick:()=>T.mutate(),disabled:T.isPending,children:[(0,D.jsx)(S,{}),` `,t.readOnly?`Duplicate to edit`:`Duplicate`]}),!t.readOnly&&(0,D.jsxs)(p,{children:[(0,D.jsx)(f,{asChild:!0,children:(0,D.jsx)(i,{size:`icon-sm`,variant:`ghost`,"aria-label":`Delete ${x.name}`,children:(0,D.jsx)(w,{})})}),(0,D.jsxs)(m,{children:[(0,D.jsxs)(s,{children:[(0,D.jsxs)(g,{children:[`Delete `,x.name,`?`]}),(0,D.jsx)(_,{children:`It stops running and disappears from every project. Its past runs and their sessions stay. Export it first if you may want it back.`})]}),(0,D.jsxs)(d,{children:[(0,D.jsx)(v,{children:`Cancel`}),(0,D.jsx)(h,{variant:`destructive`,onClick:()=>E.mutate(),children:`Delete`})]})]})]})]})}function A({conflict:t,projectId:n,onClose:r}){let a=e(),o={id:`run:${t.automationId}`,projectId:n,request:{purpose:`Run ${t.name} now`,workKey:t.workKey,startedBy:{kind:`user`}},existing:t.existing,start:null,status:`open`,resolution:null,outcome:null,createdAt:new Date().toISOString(),resolvedAt:null};return(0,D.jsxs)(`div`,{className:`space-y-1`,"data-testid":`run-conflict`,children:[(0,D.jsx)(E,{conflict:o,decideWith:async e=>{let r=await a.automations.run(t.automationId,{projectId:n,conflict:e});if(r.status===`conflict`)throw Error(`Matching work is still running`);return{status:r.status,sessionId:`sessionId`in r?r.sessionId:null}},onResolved:r}),(0,D.jsxs)(i,{size:`xs`,variant:`ghost`,className:`text-muted-foreground`,"aria-label":`Dismiss conflict`,onClick:r,children:[(0,D.jsx)(T,{}),` Not now`]})]})}export{k as n,O as r,A as t};
1
+ import{i as e}from"./api-yvn34iKU.js";import{t}from"./jsx-runtime-C3cWAN_r.js";import{F as n}from"./useQuery-VSotSwry.js";import{j as r,m as i,yt as a}from"./format-D3kairnQ.js";import{y as o}from"./dropdown-menu-Bflkx6wY.js";import{C as s,F as c,I as l,R as u,S as d,T as f,_ as p,b as m,v as h,w as g,x as _,y as v}from"./mobile-nav-CrjrDJZ5.js";import{d as y}from"./switch-BHplnCdo.js";import{Cr as b,Fn as x,Kn as S,Zt as C,h as w,n as T}from"./icons-COCLuOtb.js";import{t as E}from"./conflict-card-Bx8tT_d5.js";var D=t();function O({item:e}){let t=e.automation.createdBy;return(0,D.jsxs)(D.Fragment,{children:[e.readOnly&&(0,D.jsxs)(c,{children:[(0,D.jsx)(u,{asChild:!0,children:(0,D.jsxs)(`span`,{className:`flex items-center gap-1 rounded bg-muted px-1.5 py-px text-3xs text-muted-foreground`,"data-testid":`from-file-badge`,children:[(0,D.jsx)(x,{className:`size-3`}),` From file`]})}),(0,D.jsxs)(l,{className:`font-mono`,children:[e.path??`Built in`,` · edit the file, or duplicate it to edit here`]})]}),t===`pm`&&(0,D.jsxs)(`span`,{className:`flex items-center gap-1 rounded bg-primary/10 px-1.5 py-px text-3xs text-primary`,children:[(0,D.jsx)(b,{className:`size-3`}),` Created by the PM`]}),t===`import`&&(0,D.jsxs)(`span`,{className:`flex items-center gap-1 rounded bg-muted px-1.5 py-px text-3xs text-muted-foreground`,children:[(0,D.jsx)(C,{className:`size-3`}),` Imported`]})]})}function k({item:t,projectId:c}){let l=e(),u=n(),b=y(),x=t.automation,C=e=>void b({to:`/projects/$projectId/automations/$automationId`,params:{projectId:c,automationId:e}}),T=a({mutationFn:()=>l.automations.duplicate(x.id,x.target.type===`project`?{projectId:c}:{}),onSuccess:e=>{u.invalidateQueries({queryKey:o.all}),r.success(`${e.automation.name} created, off`),C(e.automation.id)},onError:e=>r.error(`Couldn't duplicate`,{description:e.message})}),E=a({mutationFn:()=>l.automations.remove(x.id),onSuccess:()=>{u.invalidateQueries({queryKey:o.all}),r.success(`${x.name} deleted`),b({to:`/projects/$projectId/automations`,params:{projectId:c}})},onError:e=>r.error(`Couldn't delete`,{description:e.message})});return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(i,{size:`sm`,variant:t.readOnly?`default`:`ghost`,onClick:()=>T.mutate(),disabled:T.isPending,children:[(0,D.jsx)(S,{}),` `,t.readOnly?`Duplicate to edit`:`Duplicate`]}),!t.readOnly&&(0,D.jsxs)(p,{children:[(0,D.jsx)(f,{asChild:!0,children:(0,D.jsx)(i,{size:`icon-sm`,variant:`ghost`,"aria-label":`Delete ${x.name}`,children:(0,D.jsx)(w,{})})}),(0,D.jsxs)(m,{children:[(0,D.jsxs)(s,{children:[(0,D.jsxs)(g,{children:[`Delete `,x.name,`?`]}),(0,D.jsx)(_,{children:`It stops running and disappears from every project. Its past runs and their sessions stay. Export it first if you may want it back.`})]}),(0,D.jsxs)(d,{children:[(0,D.jsx)(v,{children:`Cancel`}),(0,D.jsx)(h,{variant:`destructive`,onClick:()=>E.mutate(),children:`Delete`})]})]})]})]})}function A({conflict:t,projectId:n,onClose:r}){let a=e(),o={id:`run:${t.automationId}`,projectId:n,request:{purpose:`Run ${t.name} now`,workKey:t.workKey,startedBy:{kind:`user`}},existing:t.existing,start:null,status:`open`,resolution:null,outcome:null,createdAt:new Date().toISOString(),resolvedAt:null};return(0,D.jsxs)(`div`,{className:`space-y-1`,"data-testid":`run-conflict`,children:[(0,D.jsx)(E,{conflict:o,decideWith:async e=>{let r=await a.automations.run(t.automationId,{projectId:n,conflict:e});if(r.status===`conflict`)throw Error(`Matching work is still running`);return{status:r.status,sessionId:`sessionId`in r?r.sessionId:null}},onResolved:r}),(0,D.jsxs)(i,{size:`xs`,variant:`ghost`,className:`text-muted-foreground`,"aria-label":`Dismiss conflict`,onClick:r,children:[(0,D.jsx)(T,{}),` Not now`]})]})}export{k as n,O as r,A as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t}from"./api-B620HpC2.js";import{n,t as r}from"./jsx-runtime-C3cWAN_r.js";import{i,j as a,m as o,n as s,yt as c}from"./format-D1ma_o2D.js";import{D as l,L as u,T as d,i as f,l as p,r as m,t as h}from"./dropdown-menu-C4XI7F63.js";import{O as g,d as _,f as v,p as y}from"./mobile-nav-D8FZcJzG.js";import{a as b,o as x}from"./switch-DuBpF2_h.js";import{t as S}from"./dist-wxbqfqV1.js";import{I as C,J as w,Ln as T,Or as E,Qn as D,Wn as O,fr as k,n as A}from"./icons-COCLuOtb.js";import{t as j}from"./bits-B2GRjm37.js";import{a as M,c as N,o as P}from"./meta-CSV1Er3C.js";var F=r();function I(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function L({automationId:e}){let n=t(),r=c({mutationFn:async t=>{let r=await n.automations.exportOne(e);if(t===`download`)v(r.fileName,r.markdown);else{let e=await x.writeClipboard(r.markdown);return e||b(),{how:t,file:r,copied:e}}return{how:t,file:r,copied:!1}},onSuccess:({how:e,file:t,copied:n})=>{e===`download`?a.success(`Downloaded ${t.fileName}`):n&&a.success(`Copied as Markdown`)},onError:e=>a.error(`Couldn't export`,{description:e.message})});return(0,F.jsxs)(h,{children:[(0,F.jsx)(p,{asChild:!0,children:(0,F.jsxs)(o,{size:`sm`,variant:`outline`,children:[(0,F.jsx)(C,{}),` Export `,(0,F.jsx)(k,{className:`opacity-60`})]})}),(0,F.jsxs)(m,{align:`end`,className:`w-56`,"data-testid":`export-menu`,children:[(0,F.jsxs)(f,{onSelect:()=>r.mutate(`download`),children:[(0,F.jsx)(O,{}),` Download .md`]}),(0,F.jsxs)(f,{onSelect:()=>r.mutate(`copy`),children:[(0,F.jsx)(D,{}),` Copy as Markdown`]})]})]})}function R({projectId:e}){let n=t(),r=c({mutationFn:()=>n.automations.exportAll(e),onSuccess:e=>{e.count===0?a.info(`Nothing to export yet`):(_(e.fileName,new Blob([I(e.zipBase64)],{type:`application/zip`})),a.success(`Exported ${e.count} automation${e.count===1?``:`s`}`))},onError:e=>a.error(`Couldn't export`,{description:e.message})});return(0,F.jsxs)(o,{size:`sm`,variant:`ghost`,onClick:()=>r.mutate(),disabled:r.isPending,children:[(0,F.jsx)(T,{}),` Export all`]})}var z=e(n(),1),B=[{id:`all`,label:`All`},{id:`running`,label:`Running`},{id:`queued`,label:`Queued`},{id:`skipped`,label:`Skipped`},{id:`failed`,label:`Failed`}];function V({run:e,name:t,projectId:n,onCancel:r,showAutomation:a}){let c=M[e.status],l=e.finishedAt&&e.status!==`skipped`?i(Date.parse(e.finishedAt)-Date.parse(e.startedAt)):null;return(0,F.jsxs)(`div`,{className:S(`grid items-center gap-3 border-b border-border px-3.5 py-2 text-[13px] last:border-0`,a?`grid-cols-[100px_minmax(0,1fr)_90px_80px_92px]`:`grid-cols-[80px_minmax(0,1fr)_auto] [&>[data-wide]]:hidden`),"data-testid":`run-row`,"data-status":e.status,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-2 text-2xs`,children:[(0,F.jsx)(g,{tone:c.tone}),c.label]}),(0,F.jsxs)(`span`,{className:`min-w-0`,children:[a&&(0,F.jsx)(u,{to:`/projects/$projectId/automations/$automationId`,params:{projectId:n,automationId:e.automationId},className:`block truncate font-medium hover:underline`,children:t}),(0,F.jsx)(`span`,{className:`block truncate text-2xs text-muted-foreground`,children:e.skipReason?(0,F.jsx)(`span`,{className:`text-status-waiting`,children:P[e.skipReason]}):e.error?(0,F.jsx)(`span`,{className:`text-status-failed`,children:e.error.message}):e.progress?.text??(e.purpose===t?e.workKey:e.purpose)}),!a&&(0,F.jsxs)(`span`,{className:`block text-3xs text-muted-foreground/80`,children:[N[e.triggeredBy],` · `,s(e.startedAt),l&&` · ${l}`]})]}),(0,F.jsx)(`span`,{"data-wide":!0,className:`text-2xs text-muted-foreground`,children:N[e.triggeredBy]}),(0,F.jsxs)(`span`,{"data-wide":!0,className:`text-2xs text-muted-foreground tabular-nums`,title:e.startedAt,children:[s(e.startedAt),l&&(0,F.jsx)(`span`,{className:`block text-3xs`,children:l})]}),(0,F.jsx)(`span`,{className:`flex justify-end`,children:e.status===`queued`?(0,F.jsxs)(o,{size:`xs`,variant:`ghost`,className:`text-muted-foreground`,onClick:r,children:[(0,F.jsx)(A,{}),` Cancel`]}):e.sessionId?(0,F.jsxs)(u,{to:`/sessions/$sessionId`,params:{sessionId:e.sessionId},className:`flex items-center gap-0.5 text-2xs text-primary hover:underline`,"data-testid":`run-session-link`,children:[`Session `,(0,F.jsx)(E,{className:`size-3`})]}):null})]})}function H({projectId:e,automationId:t,limit:n=100}){let[r,i]=(0,z.useState)(`all`),a=d({projectId:e,automationId:t,limit:n,...r===`all`?{}:{status:r}}),{data:o}=l(e),s=y(e),c=e=>o?.automations.find(t=>t.automation.id===e)?.automation.name??e,u=a.data??[];return(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`div`,{className:S(`flex w-fit items-center gap-1 rounded-lg border border-border bg-card/50 p-0.5 text-xs`,t&&`hidden`),children:B.map(e=>(0,F.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),className:S(`h-6 rounded-md px-2.5 text-muted-foreground transition-colors hover:text-foreground`,r===e.id&&`bg-accent text-foreground`),children:e.label},e.id))}),u.length===0&&!a.isLoading?(0,F.jsx)(`div`,{className:`rounded-xl border border-dashed border-border`,children:(0,F.jsx)(j,{icon:(0,F.jsx)(w,{}),title:`No runs yet`,children:`Runs appear here when a schedule, an event or Run now fires, including skipped ones with the reason.`})}):(0,F.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-card`,"data-testid":`runs`,children:u.map(n=>(0,F.jsx)(V,{run:n,name:c(n.automationId),projectId:e,showAutomation:!t,onCancel:()=>s.cancelRun.mutate(n.id)},n.id))})]})}export{R as n,L as r,H as t};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t}from"./api-yvn34iKU.js";import{n,t as r}from"./jsx-runtime-C3cWAN_r.js";import{i,j as a,m as o,n as s,yt as c}from"./format-D3kairnQ.js";import{D as l,L as u,T as d,i as f,l as p,r as m,t as h}from"./dropdown-menu-Bflkx6wY.js";import{O as g,d as _,f as v,p as y}from"./mobile-nav-CrjrDJZ5.js";import{a as b,o as x}from"./switch-BHplnCdo.js";import{t as S}from"./dist-wxbqfqV1.js";import{I as C,J as w,Ln as T,Or as E,Qn as D,Wn as O,fr as k,n as A}from"./icons-COCLuOtb.js";import{t as j}from"./bits-B2GRjm37.js";import{a as M,c as N,o as P}from"./meta-CSV1Er3C.js";var F=r();function I(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function L({automationId:e}){let n=t(),r=c({mutationFn:async t=>{let r=await n.automations.exportOne(e);if(t===`download`)v(r.fileName,r.markdown);else{let e=await x.writeClipboard(r.markdown);return e||b(),{how:t,file:r,copied:e}}return{how:t,file:r,copied:!1}},onSuccess:({how:e,file:t,copied:n})=>{e===`download`?a.success(`Downloaded ${t.fileName}`):n&&a.success(`Copied as Markdown`)},onError:e=>a.error(`Couldn't export`,{description:e.message})});return(0,F.jsxs)(h,{children:[(0,F.jsx)(p,{asChild:!0,children:(0,F.jsxs)(o,{size:`sm`,variant:`outline`,children:[(0,F.jsx)(C,{}),` Export `,(0,F.jsx)(k,{className:`opacity-60`})]})}),(0,F.jsxs)(m,{align:`end`,className:`w-56`,"data-testid":`export-menu`,children:[(0,F.jsxs)(f,{onSelect:()=>r.mutate(`download`),children:[(0,F.jsx)(O,{}),` Download .md`]}),(0,F.jsxs)(f,{onSelect:()=>r.mutate(`copy`),children:[(0,F.jsx)(D,{}),` Copy as Markdown`]})]})]})}function R({projectId:e}){let n=t(),r=c({mutationFn:()=>n.automations.exportAll(e),onSuccess:e=>{e.count===0?a.info(`Nothing to export yet`):(_(e.fileName,new Blob([I(e.zipBase64)],{type:`application/zip`})),a.success(`Exported ${e.count} automation${e.count===1?``:`s`}`))},onError:e=>a.error(`Couldn't export`,{description:e.message})});return(0,F.jsxs)(o,{size:`sm`,variant:`ghost`,onClick:()=>r.mutate(),disabled:r.isPending,children:[(0,F.jsx)(T,{}),` Export all`]})}var z=e(n(),1),B=[{id:`all`,label:`All`},{id:`running`,label:`Running`},{id:`queued`,label:`Queued`},{id:`skipped`,label:`Skipped`},{id:`failed`,label:`Failed`}];function V({run:e,name:t,projectId:n,onCancel:r,showAutomation:a}){let c=M[e.status],l=e.finishedAt&&e.status!==`skipped`?i(Date.parse(e.finishedAt)-Date.parse(e.startedAt)):null;return(0,F.jsxs)(`div`,{className:S(`grid items-center gap-3 border-b border-border px-3.5 py-2 text-[13px] last:border-0`,a?`grid-cols-[100px_minmax(0,1fr)_90px_80px_92px]`:`grid-cols-[80px_minmax(0,1fr)_auto] [&>[data-wide]]:hidden`),"data-testid":`run-row`,"data-status":e.status,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-2 text-2xs`,children:[(0,F.jsx)(g,{tone:c.tone}),c.label]}),(0,F.jsxs)(`span`,{className:`min-w-0`,children:[a&&(0,F.jsx)(u,{to:`/projects/$projectId/automations/$automationId`,params:{projectId:n,automationId:e.automationId},className:`block truncate font-medium hover:underline`,children:t}),(0,F.jsx)(`span`,{className:`block truncate text-2xs text-muted-foreground`,children:e.skipReason?(0,F.jsx)(`span`,{className:`text-status-waiting`,children:P[e.skipReason]}):e.error?(0,F.jsx)(`span`,{className:`text-status-failed`,children:e.error.message}):e.progress?.text??(e.purpose===t?e.workKey:e.purpose)}),!a&&(0,F.jsxs)(`span`,{className:`block text-3xs text-muted-foreground/80`,children:[N[e.triggeredBy],` · `,s(e.startedAt),l&&` · ${l}`]})]}),(0,F.jsx)(`span`,{"data-wide":!0,className:`text-2xs text-muted-foreground`,children:N[e.triggeredBy]}),(0,F.jsxs)(`span`,{"data-wide":!0,className:`text-2xs text-muted-foreground tabular-nums`,title:e.startedAt,children:[s(e.startedAt),l&&(0,F.jsx)(`span`,{className:`block text-3xs`,children:l})]}),(0,F.jsx)(`span`,{className:`flex justify-end`,children:e.status===`queued`?(0,F.jsxs)(o,{size:`xs`,variant:`ghost`,className:`text-muted-foreground`,onClick:r,children:[(0,F.jsx)(A,{}),` Cancel`]}):e.sessionId?(0,F.jsxs)(u,{to:`/sessions/$sessionId`,params:{sessionId:e.sessionId},className:`flex items-center gap-0.5 text-2xs text-primary hover:underline`,"data-testid":`run-session-link`,children:[`Session `,(0,F.jsx)(E,{className:`size-3`})]}):null})]})}function H({projectId:e,automationId:t,limit:n=100}){let[r,i]=(0,z.useState)(`all`),a=d({projectId:e,automationId:t,limit:n,...r===`all`?{}:{status:r}}),{data:o}=l(e),s=y(e),c=e=>o?.automations.find(t=>t.automation.id===e)?.automation.name??e,u=a.data??[];return(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`div`,{className:S(`flex w-fit items-center gap-1 rounded-lg border border-border bg-card/50 p-0.5 text-xs`,t&&`hidden`),children:B.map(e=>(0,F.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),className:S(`h-6 rounded-md px-2.5 text-muted-foreground transition-colors hover:text-foreground`,r===e.id&&`bg-accent text-foreground`),children:e.label},e.id))}),u.length===0&&!a.isLoading?(0,F.jsx)(`div`,{className:`rounded-xl border border-dashed border-border`,children:(0,F.jsx)(j,{icon:(0,F.jsx)(w,{}),title:`No runs yet`,children:`Runs appear here when a schedule, an event or Run now fires, including skipped ones with the reason.`})}):(0,F.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-card`,"data-testid":`runs`,children:u.map(n=>(0,F.jsx)(V,{run:n,name:c(n.automationId),projectId:e,showAutomation:!t,onCancel:()=>s.cancelRun.mutate(n.id)},n.id))})]})}export{R as n,L as r,H as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{L as t}from"./dropdown-menu-C4XI7F63.js";import{d as n,t as r}from"./switch-DuBpF2_h.js";import{H as i,Lt as a,_ as o}from"./icons-COCLuOtb.js";import{n as s,t as c}from"./jsx-runtime-C3cWAN_r.js";import{t as l}from"./bits-B2GRjm37.js";import{O as u}from"./mobile-nav-D8FZcJzG.js";import{a as d,c as f,i as p,n as m,r as h,s as g,t as _}from"./search-Da3B5-lr.js";import{D as v,S as y,m as b,n as x,y as S}from"./format-D1ma_o2D.js";import{t as C}from"./input-CPpbtC2H.js";import{a as w,i as T,n as E,r as D,t as O}from"./select-B4LGxZQI.js";import{t as k}from"./skeleton-D8Sbd2jT.js";import{t as A}from"./page-header-BqPf-jRo.js";var j=e(s(),1),M=c(),N=50,P=`all`,F=[{value:`agent`,label:`Agents`},{value:`pm`,label:`PMs`},{value:`orchestrator`,label:`Orchestrator`}];function I({children:e}){return(0,M.jsx)(`span`,{className:`shrink-0 rounded-sm border border-border px-1 text-3xs text-muted-foreground`,children:e})}function L({hit:e}){let n=y(e.sessionId),r=S(n?.projectId);return(0,M.jsxs)(t,{to:`/sessions/$sessionId`,params:{sessionId:e.sessionId},search:h(e),className:`block rounded-lg px-3 py-2.5 transition-colors hover:bg-accent/50 focus-visible:bg-accent/50 focus-visible:outline-none`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-[13px]`,children:[n&&(0,M.jsx)(u,{status:n.status}),(0,M.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:n?n.title??n.purpose:`Session`}),r&&(0,M.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:r.name}),(0,M.jsx)(I,{children:(n&&p(n.role))??`Agent`}),n?.archivedAt&&(0,M.jsx)(I,{children:`Archived`}),(0,M.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 text-2xs text-muted-foreground`,title:e.ts,children:x(e.ts)})]}),(0,M.jsxs)(`div`,{className:`mt-1 flex min-w-0 gap-2 text-xs leading-relaxed`,children:[(0,M.jsx)(`span`,{className:`w-16 shrink-0 text-muted-foreground/70`,children:m(e)}),(0,M.jsx)(f,{parts:e.snippet,className:`line-clamp-2 text-muted-foreground`})]})]})}function R({q:e,filters:t}){let{hits:n,query:r,error:s,searching:c,hasMore:u,loadingMore:d,loadMore:f}=g(e,{...t,limit:N});return e.trim()?_(e)?s?(0,M.jsx)(l,{icon:(0,M.jsx)(i,{}),title:`Couldn't search transcripts`,className:`py-16`,children:s.message}):n?n.length===0&&!u?(0,M.jsxs)(l,{icon:(0,M.jsx)(i,{}),title:`No matches`,className:`py-16`,children:[`Nothing in`,` `,t.projectId||t.role||t.includeArchived===!1?`these sessions`:`any transcript`,` `,`contains every word of “`,r,`”.`]}):(0,M.jsxs)(`div`,{className:c?`opacity-70 transition-opacity`:void 0,children:[(0,M.jsx)(`div`,{className:`divide-y divide-border/60`,children:n.map(e=>(0,M.jsx)(L,{hit:e},`${e.sessionId}:${e.itemId}`))}),u&&(0,M.jsx)(`div`,{className:`flex justify-center pt-4`,children:(0,M.jsxs)(b,{variant:`outline`,size:`sm`,onClick:f,disabled:d,children:[d&&(0,M.jsx)(a,{className:`animate-spin`}),n.length===0?`Search older transcripts`:`Load more`]})})]}):(0,M.jsx)(`div`,{className:`space-y-4 px-3 pt-2`,children:[0,1,2].map(e=>(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(k,{className:`h-4 w-1/2`}),(0,M.jsx)(k,{className:`h-3 w-5/6`})]},e))}):(0,M.jsx)(l,{icon:(0,M.jsx)(o,{}),title:`Keep typing`,className:`py-16`,children:`Search needs a word of at least 3 characters.`}):(0,M.jsx)(l,{icon:(0,M.jsx)(o,{}),title:`Search every transcript`,className:`py-16`,children:`Find what was asked, answered or run in any session, archived ones included: a message, a command, a file path.`})}function z(e,t){return{q:e||void 0,project:t.projectId,role:t.role,archived:t.includeArchived!==!1&&void 0}}function B({filters:e,onChange:t}){let n=v(e=>e.projects,[]);return(0,M.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,M.jsxs)(O,{value:e.projectId??P,onValueChange:n=>t({...e,projectId:n===P?void 0:n}),children:[(0,M.jsx)(T,{size:`sm`,className:`w-44`,"aria-label":`Project`,children:(0,M.jsx)(w,{})}),(0,M.jsxs)(E,{children:[(0,M.jsx)(D,{value:P,children:`All projects`}),n.map(e=>(0,M.jsx)(D,{value:e.id,children:e.name},e.id))]})]}),(0,M.jsxs)(O,{value:e.role??P,onValueChange:n=>t({...e,role:n===P?void 0:n}),children:[(0,M.jsx)(T,{size:`sm`,className:`w-36`,"aria-label":`Role`,children:(0,M.jsx)(w,{})}),(0,M.jsxs)(E,{children:[(0,M.jsx)(D,{value:P,children:`All roles`}),F.map(e=>(0,M.jsx)(D,{value:e.value,children:e.label},e.value))]})]}),(0,M.jsxs)(`span`,{className:`ml-1 flex items-center gap-2`,children:[(0,M.jsx)(r,{id:`search-archived`,checked:e.includeArchived!==!1,onCheckedChange:n=>t({...e,includeArchived:n})}),(0,M.jsx)(`label`,{htmlFor:`search-archived`,className:`text-xs text-muted-foreground`,children:`Archived sessions`})]})]})}function V({q:e,filters:t}){let r=n(),[i,a]=(0,j.useState)(e),s=d(i,250),c=(0,j.useRef)(s);return(0,j.useEffect)(()=>{s!==c.current&&(c.current=s,s.trim()!==e&&r({to:`/search`,search:z(s.trim(),t),replace:!0}))},[s,e,t,r]),(0,j.useEffect)(()=>{e!==i.trim()&&a(e)},[e]),(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(A,{icon:(0,M.jsx)(o,{}),title:`Search transcripts`,meta:`Messages, replies, commands and file paths across every session, newest first`}),(0,M.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto scroll-thin`,children:(0,M.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl px-4 py-5 sm:px-6 sm:py-6`,children:[(0,M.jsxs)(`div`,{className:`relative mb-3`,children:[(0,M.jsx)(o,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,M.jsx)(C,{autoFocus:!0,type:`search`,value:i,onChange:e=>a(e.target.value),placeholder:`webhook retry, prisma migrate, src/cart…`,"aria-label":`Search transcripts`,className:`h-10 pl-9`})]}),(0,M.jsx)(B,{filters:t,onChange:t=>r({to:`/search`,search:z(e,t),replace:!0})}),(0,M.jsx)(R,{q:e,filters:t})]})})]})}export{V as SearchPage};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{L as t}from"./dropdown-menu-Bflkx6wY.js";import{d as n,t as r}from"./switch-BHplnCdo.js";import{H as i,Lt as a,_ as o}from"./icons-COCLuOtb.js";import{n as s,t as c}from"./jsx-runtime-C3cWAN_r.js";import{t as l}from"./bits-B2GRjm37.js";import{O as u}from"./mobile-nav-CrjrDJZ5.js";import{a as d,c as f,i as p,n as m,r as h,s as g,t as _}from"./search-hK5b8Xwb.js";import{D as v,S as y,m as b,n as x,y as S}from"./format-D3kairnQ.js";import{t as C}from"./input-CPpbtC2H.js";import{a as w,i as T,n as E,r as D,t as O}from"./select-B1ES0hhy.js";import{t as k}from"./skeleton-D8Sbd2jT.js";import{t as A}from"./page-header-t9HzSrxd.js";var j=e(s(),1),M=c(),N=50,P=`all`,F=[{value:`agent`,label:`Agents`},{value:`pm`,label:`PMs`},{value:`orchestrator`,label:`Orchestrator`}];function I({children:e}){return(0,M.jsx)(`span`,{className:`shrink-0 rounded-sm border border-border px-1 text-3xs text-muted-foreground`,children:e})}function L({hit:e}){let n=y(e.sessionId),r=S(n?.projectId);return(0,M.jsxs)(t,{to:`/sessions/$sessionId`,params:{sessionId:e.sessionId},search:h(e),className:`block rounded-lg px-3 py-2.5 transition-colors hover:bg-accent/50 focus-visible:bg-accent/50 focus-visible:outline-none`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-[13px]`,children:[n&&(0,M.jsx)(u,{status:n.status}),(0,M.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:n?n.title??n.purpose:`Session`}),r&&(0,M.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:r.name}),(0,M.jsx)(I,{children:(n&&p(n.role))??`Agent`}),n?.archivedAt&&(0,M.jsx)(I,{children:`Archived`}),(0,M.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 text-2xs text-muted-foreground`,title:e.ts,children:x(e.ts)})]}),(0,M.jsxs)(`div`,{className:`mt-1 flex min-w-0 gap-2 text-xs leading-relaxed`,children:[(0,M.jsx)(`span`,{className:`w-16 shrink-0 text-muted-foreground/70`,children:m(e)}),(0,M.jsx)(f,{parts:e.snippet,className:`line-clamp-2 text-muted-foreground`})]})]})}function R({q:e,filters:t}){let{hits:n,query:r,error:s,searching:c,hasMore:u,loadingMore:d,loadMore:f}=g(e,{...t,limit:N});return e.trim()?_(e)?s?(0,M.jsx)(l,{icon:(0,M.jsx)(i,{}),title:`Couldn't search transcripts`,className:`py-16`,children:s.message}):n?n.length===0&&!u?(0,M.jsxs)(l,{icon:(0,M.jsx)(i,{}),title:`No matches`,className:`py-16`,children:[`Nothing in`,` `,t.projectId||t.role||t.includeArchived===!1?`these sessions`:`any transcript`,` `,`contains every word of “`,r,`”.`]}):(0,M.jsxs)(`div`,{className:c?`opacity-70 transition-opacity`:void 0,children:[(0,M.jsx)(`div`,{className:`divide-y divide-border/60`,children:n.map(e=>(0,M.jsx)(L,{hit:e},`${e.sessionId}:${e.itemId}`))}),u&&(0,M.jsx)(`div`,{className:`flex justify-center pt-4`,children:(0,M.jsxs)(b,{variant:`outline`,size:`sm`,onClick:f,disabled:d,children:[d&&(0,M.jsx)(a,{className:`animate-spin`}),n.length===0?`Search older transcripts`:`Load more`]})})]}):(0,M.jsx)(`div`,{className:`space-y-4 px-3 pt-2`,children:[0,1,2].map(e=>(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(k,{className:`h-4 w-1/2`}),(0,M.jsx)(k,{className:`h-3 w-5/6`})]},e))}):(0,M.jsx)(l,{icon:(0,M.jsx)(o,{}),title:`Keep typing`,className:`py-16`,children:`Search needs a word of at least 3 characters.`}):(0,M.jsx)(l,{icon:(0,M.jsx)(o,{}),title:`Search every transcript`,className:`py-16`,children:`Find what was asked, answered or run in any session, archived ones included: a message, a command, a file path.`})}function z(e,t){return{q:e||void 0,project:t.projectId,role:t.role,archived:t.includeArchived!==!1&&void 0}}function B({filters:e,onChange:t}){let n=v(e=>e.projects,[]);return(0,M.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,M.jsxs)(O,{value:e.projectId??P,onValueChange:n=>t({...e,projectId:n===P?void 0:n}),children:[(0,M.jsx)(T,{size:`sm`,className:`w-44`,"aria-label":`Project`,children:(0,M.jsx)(w,{})}),(0,M.jsxs)(E,{children:[(0,M.jsx)(D,{value:P,children:`All projects`}),n.map(e=>(0,M.jsx)(D,{value:e.id,children:e.name},e.id))]})]}),(0,M.jsxs)(O,{value:e.role??P,onValueChange:n=>t({...e,role:n===P?void 0:n}),children:[(0,M.jsx)(T,{size:`sm`,className:`w-36`,"aria-label":`Role`,children:(0,M.jsx)(w,{})}),(0,M.jsxs)(E,{children:[(0,M.jsx)(D,{value:P,children:`All roles`}),F.map(e=>(0,M.jsx)(D,{value:e.value,children:e.label},e.value))]})]}),(0,M.jsxs)(`span`,{className:`ml-1 flex items-center gap-2`,children:[(0,M.jsx)(r,{id:`search-archived`,checked:e.includeArchived!==!1,onCheckedChange:n=>t({...e,includeArchived:n})}),(0,M.jsx)(`label`,{htmlFor:`search-archived`,className:`text-xs text-muted-foreground`,children:`Archived sessions`})]})]})}function V({q:e,filters:t}){let r=n(),[i,a]=(0,j.useState)(e),s=d(i,250),c=(0,j.useRef)(s);return(0,j.useEffect)(()=>{s!==c.current&&(c.current=s,s.trim()!==e&&r({to:`/search`,search:z(s.trim(),t),replace:!0}))},[s,e,t,r]),(0,j.useEffect)(()=>{e!==i.trim()&&a(e)},[e]),(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(A,{icon:(0,M.jsx)(o,{}),title:`Search transcripts`,meta:`Messages, replies, commands and file paths across every session, newest first`}),(0,M.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto scroll-thin`,children:(0,M.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl px-4 py-5 sm:px-6 sm:py-6`,children:[(0,M.jsxs)(`div`,{className:`relative mb-3`,children:[(0,M.jsx)(o,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,M.jsx)(C,{autoFocus:!0,type:`search`,value:i,onChange:e=>a(e.target.value),placeholder:`webhook retry, prisma migrate, src/cart…`,"aria-label":`Search transcripts`,className:`h-10 pl-9`})]}),(0,M.jsx)(B,{filters:t,onChange:t=>r({to:`/search`,search:z(e,t),replace:!0})}),(0,M.jsx)(R,{q:e,filters:t})]})})]})}export{V as SearchPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t}from"./api-B620HpC2.js";import{n,t as r}from"./jsx-runtime-C3cWAN_r.js";import{t as i,w as a}from"./useQuery-VSotSwry.js";import{t as o}from"./useInfiniteQuery-CoCb1Ya8.js";import{t as s}from"./dist-wxbqfqV1.js";var c=r();function l({parts:e,className:t}){return(0,c.jsx)(`span`,{className:s(`min-w-0`,t),children:e.map((e,t)=>e.match?(0,c.jsx)(`mark`,{className:`rounded-[3px] bg-primary/15 px-px text-foreground`,children:e.text},t):(0,c.jsx)(`span`,{children:e.text},t))})}var u=e(n(),1);function d(e){return e.trim().split(/\s+/).some(e=>[...e].length>=3)}function f(e,t){let[n,r]=(0,u.useState)(e);return(0,u.useEffect)(()=>{if(t<=0){r(e);return}let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),t<=0?e:n}function p(e,n={}){let r=t(),o=f(e.trim(),n.debounceMs??200),s=d(o),{limit:c,projectId:l,role:u,includeArchived:p}=n,m=i({queryKey:[`search`,`transcripts`,o,c,l,u,p],queryFn:()=>r.searchTranscripts({q:o,limit:c,projectId:l,role:u,includeArchived:p}),enabled:s,placeholderData:a,staleTime:1e4});return{data:s?m.data:void 0,error:m.error,searching:d(e)&&(e.trim()!==o||m.isFetching)}}function m(e,n){let r=t(),i=e.trim(),s=d(i),{limit:c,projectId:l,role:u,includeArchived:f}=n,p=o({queryKey:[`search`,`transcripts`,`pages`,i,c,l,u,f],queryFn:({pageParam:e})=>r.searchTranscripts({q:i,limit:c,projectId:l,role:u,includeArchived:f,cursor:e}),initialPageParam:void 0,getNextPageParam:e=>e.nextCursor??void 0,enabled:s,placeholderData:a,staleTime:1e4}),m=s?p.data?.pages:void 0;return{hits:m?.flatMap(e=>e.hits),query:m?.[0]?.query??i,error:p.error,searching:p.isFetching&&!p.isFetchingNextPage,hasMore:!!p.hasNextPage,loadingMore:p.isFetchingNextPage,loadMore:()=>void p.fetchNextPage()}}function h(e){return e.anchorItemId===e.itemId?{item:e.itemId}:{item:e.anchorItemId,thread:e.threadId,threadItem:e.itemId}}function g(e){switch(e.kind){case`user_message`:return`Prompt`;case`assistant_message`:return`Reply`;case`plan`:return`Plan`;case`subagent`:return`Subagent`;case`user_question`:return`Question`;case`approval_request`:return`Approval`;case`notice`:return`Notice`;case`hook_run`:return`Hook`;case`error`:return`Error`;case`tool_call`:return _[e.toolKind??`other`]??`Tool`;default:return`Item`}}var _={command:`Command`,file_edit:`Edit`,file_read:`Read`,search:`Search`,web:`Web`,mcp:`Tool`,browser:`Browser`,other:`Tool`};function v(e){return e===`pm`?`PM`:e===`orchestrator`?`Orchestrator`:null}export{f as a,l as c,v as i,g as n,p as o,h as r,m as s,d as t};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t}from"./api-yvn34iKU.js";import{n,t as r}from"./jsx-runtime-C3cWAN_r.js";import{t as i,w as a}from"./useQuery-VSotSwry.js";import{t as o}from"./useInfiniteQuery-CoCb1Ya8.js";import{t as s}from"./dist-wxbqfqV1.js";var c=r();function l({parts:e,className:t}){return(0,c.jsx)(`span`,{className:s(`min-w-0`,t),children:e.map((e,t)=>e.match?(0,c.jsx)(`mark`,{className:`rounded-[3px] bg-primary/15 px-px text-foreground`,children:e.text},t):(0,c.jsx)(`span`,{children:e.text},t))})}var u=e(n(),1);function d(e){return e.trim().split(/\s+/).some(e=>[...e].length>=3)}function f(e,t){let[n,r]=(0,u.useState)(e);return(0,u.useEffect)(()=>{if(t<=0){r(e);return}let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),t<=0?e:n}function p(e,n={}){let r=t(),o=f(e.trim(),n.debounceMs??200),s=d(o),{limit:c,projectId:l,role:u,includeArchived:p}=n,m=i({queryKey:[`search`,`transcripts`,o,c,l,u,p],queryFn:()=>r.searchTranscripts({q:o,limit:c,projectId:l,role:u,includeArchived:p}),enabled:s,placeholderData:a,staleTime:1e4});return{data:s?m.data:void 0,error:m.error,searching:d(e)&&(e.trim()!==o||m.isFetching)}}function m(e,n){let r=t(),i=e.trim(),s=d(i),{limit:c,projectId:l,role:u,includeArchived:f}=n,p=o({queryKey:[`search`,`transcripts`,`pages`,i,c,l,u,f],queryFn:({pageParam:e})=>r.searchTranscripts({q:i,limit:c,projectId:l,role:u,includeArchived:f,cursor:e}),initialPageParam:void 0,getNextPageParam:e=>e.nextCursor??void 0,enabled:s,placeholderData:a,staleTime:1e4}),m=s?p.data?.pages:void 0;return{hits:m?.flatMap(e=>e.hits),query:m?.[0]?.query??i,error:p.error,searching:p.isFetching&&!p.isFetchingNextPage,hasMore:!!p.hasNextPage,loadingMore:p.isFetchingNextPage,loadMore:()=>void p.fetchNextPage()}}function h(e){return e.anchorItemId===e.itemId?{item:e.itemId}:{item:e.anchorItemId,thread:e.threadId,threadItem:e.itemId}}function g(e){switch(e.kind){case`user_message`:return`Prompt`;case`assistant_message`:return`Reply`;case`plan`:return`Plan`;case`subagent`:return`Subagent`;case`user_question`:return`Question`;case`approval_request`:return`Approval`;case`notice`:return`Notice`;case`hook_run`:return`Hook`;case`error`:return`Error`;case`tool_call`:return _[e.toolKind??`other`]??`Tool`;default:return`Item`}}var _={command:`Command`,file_edit:`Edit`,file_read:`Read`,search:`Search`,web:`Web`,mcp:`Tool`,browser:`Browser`,other:`Tool`};function v(e){return e===`pm`?`PM`:e===`orchestrator`?`Orchestrator`:null}export{f as a,l as c,v as i,g as n,p as o,h as r,m as s,d as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./dist-wxbqfqV1.js";import{fr as n,lr as r,pr as i}from"./icons-COCLuOtb.js";import{n as a,t as o}from"./jsx-runtime-C3cWAN_r.js";import{n as s}from"./clsx-BxLRjTE8.js";import{c,l}from"./switch-DuBpF2_h.js";import{F as u,I as d,J as f,M as p,N as m,X as h,Y as g,Z as _,at as v,ct as y,dt as b,gt as x,it as S,lt as C,nt as w,ot as T,pt as E,q as D,rt as ee,st as O,tt as k,ut as A}from"./format-D1ma_o2D.js";var j=e(a(),1),M=e(s(),1),N=o(),P=Object.defineProperty,F=(e,t)=>P(e,`name`,{value:t,configurable:!0}),te={ItemAligned:`item-aligned`,Popper:`popper`},ne={LTR:`ltr`,RTL:`rtl`},I=[` `,`Enter`,`ArrowUp`,`ArrowDown`],L=[` `,`Enter`],R=`Select`,[z,B,V]=y(R),[H,U]=A(R,[V,d]),W=d(),[G,K]=H(R),[q,re]=H(R);function J(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:m,form:h,internal_do_not_use_render:g}=e,_=W(t),[v,y]=j.useState(null),[b,x]=j.useState(null),[C,w]=j.useState(!1),E=ee(l),[D,O]=T({prop:r,defaultProp:i??!1,onChange:a,caller:R}),[k,A]=T({prop:o,defaultProp:s,onChange:c,caller:R}),M=j.useRef(null),P=j.useRef(!1),[te,ne]=j.useState(null),I=F(e=>{ne({value:e,hasConsumerStoppedPropagation:P.current}),A(e)},`handleUserSelect`),L=j.useRef(k);j.useEffect(()=>{let e=h?v?.ownerDocument.getElementById(h):v?.form;if(e instanceof HTMLFormElement){let t=F(()=>A(L.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[h,v,A]);let B=!v||!!h||!!v.closest(`form`),[V,H]=j.useState(new Set),U=S(),K=Array.from(V).map(e=>e.props.value).join(`;`),re=j.useCallback(e=>{H(t=>new Set(t).add(e))},[]),J=j.useCallback(e=>{H(t=>{let n=new Set(t);return n.delete(e),n})},[]),Y={required:m,trigger:v,onTriggerChange:y,valueNode:b,onValueNodeChange:x,valueNodeHasChildren:C,onValueNodeHasChildrenChange:w,contentId:U,value:k,onValueChange:A,hasConsumerStoppedPropagationRef:P,userSelection:te,onUserSelect:I,open:D,onOpenChange:O,dir:E,triggerPointerDownPosRef:M,disabled:f,name:u,autoComplete:d,form:h,nativeOptions:V,nativeSelectKey:K,isFormControl:B};return(0,N.jsx)(p,{..._,children:(0,N.jsx)(G,{scope:t,...Y,children:(0,N.jsx)(z.Provider,{scope:t,children:(0,N.jsx)(q,{scope:t,onNativeOptionAdd:re,onNativeOptionRemove:J,children:Be(g)?g(Y):n})})})})}F(J,`SelectProvider`);var Y=F(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,N.jsx)(J,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,N.jsxs)(N.Fragment,{children:[n,e?(0,N.jsx)(ze,{__scopeSelect:t}):null]})})},`Select`),ie=`SelectTrigger`,ae=j.forwardRef(F(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=W(n),o=K(ie,n),s=o.disabled||r,c=x(t,o.onTriggerChange),l=B(n),u=j.useRef(`touch`),[d,f,p]=Ve(e=>{let t=l().filter(e=>!e.disabled),n=He(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onUserSelect(n.value)}),h=F(e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,N.jsx)(m,{asChild:!0,...a,children:(0,N.jsx)(b.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":$(o.value)?``:void 0,...i,ref:c,onClick:O(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&h(e)}),onPointerDown:O(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(h(e),e.preventDefault())}),onKeyDown:O(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&(o.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),f(e.key)),t&&e.key===` `||I.includes(e.key)&&(h(),e.preventDefault())})})})},`SelectTrigger`)),oe=`SelectValue`,se=j.forwardRef(F(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=K(oe,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=x(t,c.onValueNodeChange);C(()=>{l(u)},[l,u]);let f=$(c.value);return(0,N.jsx)(b.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,N.jsx)(j.Fragment,{children:f?o:a},f?`placeholder`:`value`)})},`SelectValue`)),ce=j.forwardRef(F(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,N.jsx)(b.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[le,ue]=H(`SelectPortal`,{forceMount:void 0}),de=F(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,N.jsx)(le,{scope:e.__scopeSelect,forceMount:n,children:(0,N.jsx)(h,{asChild:!0,...r})})},`SelectPortal`),X=`SelectContent`,fe=j.forwardRef(F(function(e,t){let n=ue(X,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=K(X,e.__scopeSelect),[o,s]=j.useState();return C(()=>{s(new DocumentFragment)},[]),(0,N.jsx)(v,{present:r||a.open,children:({present:e})=>e?(0,N.jsx)(ge,{...i,ref:t}):(0,N.jsx)(pe,{...i,fragment:o})})},`SelectContent`)),pe=j.forwardRef(F(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?M.createPortal((0,N.jsx)(me,{scope:n,children:(0,N.jsx)(z.Slot,{scope:n,children:(0,N.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),Z=10,[me,Q]=H(X),he=E(`SelectContent.RemoveScroll`),ge=j.forwardRef(F(function(e,t){let{__scopeSelect:n}=e,{position:r=te.ItemAligned,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:v,avoidCollisions:y,...b}=e,S=K(X,n),[C,w]=j.useState(null),[T,E]=j.useState(null),ee=x(t,w),[A,M]=j.useState(null),[P,ne]=j.useState(null),I=B(n),[L,R]=j.useState(!1),z=j.useRef(!1),V=j.useRef(!1),H=j.useRef(!1);j.useEffect(()=>{if(C)return D(C)},[C]),g();let U=j.useCallback(e=>{let[t,...n]=I().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&T&&(T.scrollTop=0),n===r&&T&&(T.scrollTop=T.scrollHeight),n?.focus(),document.activeElement!==i))return},[I,T]),W=j.useCallback(()=>U([A,C]),[U,A,C]);j.useEffect(()=>{L&&W()},[L,W]);let{onOpenChange:G,triggerPointerDownPosRef:q}=S;j.useEffect(()=>{if(C){let e={x:0,y:0},t=F(t=>{e={x:Math.abs(Math.round(t.pageX)-(q.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(q.current?.y??0))}},`handlePointerMove`),n=F(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(C)||G(!1),document.removeEventListener(`pointermove`,t),q.current=null},`handlePointerUp`);return q.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[C,G,q]),j.useEffect(()=>{let e=F(()=>G(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[G]);let[re,J]=Ve(e=>{let t=I().filter(e=>!e.disabled),n=He(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),Y=j.useCallback((e,t,n)=>{let r=!V.current;r&&(V.current=!0);let i=!z.current&&!n;S.value!==void 0&&S.value===t||i?(M(e),i&&(z.current=!0)):r&&M(e)},[S.value]),ie=j.useCallback(()=>C?.focus(),[C]),ae=j.useCallback((e,t,n)=>{if(!e)return;let r=!H.current;r&&(H.current=!0);let i=!z.current&&!n;(S.value!==void 0&&S.value===t||i||r)&&ne(e)},[S.value]),oe=r===te.Popper?ve:_e,se=oe===ve?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:v,avoidCollisions:y}:{};return(0,N.jsx)(me,{scope:n,content:C,viewport:T,onViewportChange:E,itemRefCallback:Y,selectedItem:A,onItemLeave:ie,itemTextRefCallback:ae,focusSelectedItem:W,selectedItemText:P,position:r,isPositioned:L,searchRef:re,children:(0,N.jsx)(f,{as:he,allowPinchZoom:!0,children:(0,N.jsx)(_,{asChild:!0,trapped:S.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:O(i,e=>{S.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,N.jsx)(k,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>S.onOpenChange(!1),children:(0,N.jsx)(oe,{role:`listbox`,id:S.contentId,"data-state":S.open?`open`:`closed`,dir:S.dir,onContextMenu:e=>e.preventDefault(),...b,...se,onPlaced:()=>R(!0),ref:ee,style:{display:`flex`,flexDirection:`column`,outline:`none`,...b.style},onKeyDown:O(b.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&J(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=I().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>U(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),_e=j.forwardRef(F(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=K(X,n),o=Q(X,n),[s,l]=j.useState(null),[u,d]=j.useState(null),f=x(t,d),p=B(n),m=j.useRef(!1),h=j.useRef(!0),{viewport:g,selectedItem:_,selectedItemText:v,focusSelectedItem:y}=o,S=j.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&u&&g&&_&&v){let e=a.trigger.getBoundingClientRect(),t=u.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=v.getBoundingClientRect();if(a.dir!==ne.RTL){let r=i.left-t.left,a=n.left-r,o=e.left-a,l=e.width+o,u=Math.max(l,t.width),d=window.innerWidth-Z,f=c(a,[Z,Math.max(Z,d-u)]);s.style.minWidth=l+`px`,s.style.left=f+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,l=e.width+o,u=Math.max(l,t.width),d=window.innerWidth-Z,f=c(a,[Z,Math.max(Z,d-u)]);s.style.minWidth=l+`px`,s.style.right=f+`px`}let o=p(),l=window.innerHeight-Z*2,d=g.scrollHeight,f=window.getComputedStyle(u),h=parseInt(f.borderTopWidth,10),y=parseInt(f.paddingTop,10),b=parseInt(f.borderBottomWidth,10),x=parseInt(f.paddingBottom,10),S=h+y+d+x+b,C=Math.min(_.offsetHeight*5,S),w=window.getComputedStyle(g),T=parseInt(w.paddingTop,10),E=parseInt(w.paddingBottom,10),D=e.top+e.height/2-Z,ee=l-D,O=_.offsetHeight/2,k=_.offsetTop+O,A=h+y+k,j=S-A;if(A<=D){let e=o.length>0&&_===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=u.clientHeight-g.offsetTop-g.offsetHeight,n=A+Math.max(ee,O+(e?E:0)+t+b);s.style.height=n+`px`}else{let e=o.length>0&&_===o[0].ref.current;s.style.top=`0px`;let t=Math.max(D,h+g.offsetTop+(e?T:0)+O)+j;s.style.height=t+`px`,g.scrollTop=A-D+g.offsetTop}s.style.margin=`${Z}px 0`,s.style.minHeight=C+`px`,s.style.maxHeight=l+`px`,r?.(),requestAnimationFrame(()=>m.current=!0)}},[p,a.trigger,a.valueNode,s,u,g,_,v,a.dir,r]);C(()=>S(),[S]);let[w,T]=j.useState();C(()=>{u&&T(window.getComputedStyle(u).zIndex)},[u]);let E=j.useCallback(e=>{e&&h.current===!0&&(S(),y?.(),h.current=!1)},[S,y]);return(0,N.jsx)(ye,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:m,onScrollButtonChange:E,children:(0,N.jsx)(`div`,{ref:l,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:w},children:(0,N.jsx)(b.div,{...i,ref:f,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),ve=j.forwardRef(F(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Z,...a}=e,o=W(n);return(0,N.jsx)(u,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[ye,be]=H(X,{}),xe=`SelectViewport`,Se=j.forwardRef(F(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=Q(xe,n),o=be(xe,n),s=x(t,a.onViewportChange),c=j.useRef(0);return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,N.jsx)(z.Slot,{scope:n,children:(0,N.jsx)(b.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:O(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-Z*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})},`SelectViewport`)),[Ce,we]=H(`SelectGroup`),Te=`SelectItem`,[Ee,De]=H(Te),Oe=j.forwardRef(F(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=K(Te,n),c=Q(Te,n),l=s.value===r,[u,d]=j.useState(a??``),[f,p]=j.useState(!1),m=w(e=>c.itemRefCallback?.(e,r,i)),h=x(t,m),g=S(),_=j.useRef(`touch`);function v(e){s.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),s.onUserSelect(r),s.onOpenChange(!1)}return F(v,`handleSelect`),(0,N.jsx)(Ee,{scope:n,value:r,disabled:i,textId:g,isSelected:l,onItemTextChange:j.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,N.jsx)(z.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,N.jsx)(b.div,{role:`option`,"aria-labelledby":g,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:h,onFocus:O(o.onFocus,()=>p(!0)),onBlur:O(o.onBlur,()=>p(!1)),onClick:O(o.onClick,e=>{i||_.current!==`mouse`&&v(e)}),onPointerUp:O(o.onPointerUp,e=>{i||_.current===`mouse`&&v(e)}),onPointerDown:O(o.onPointerDown,e=>{_.current=e.pointerType}),onPointerMove:O(o.onPointerMove,e=>{_.current=e.pointerType,i?c.onItemLeave?.():_.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:O(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:O(o.onKeyDown,e=>{i||e.target!==e.currentTarget||(c.searchRef?.current===``||e.key!==` `)&&(L.includes(e.key)&&v(e),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),ke=`SelectItemText`,Ae=j.forwardRef(F(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,o=K(ke,n),s=Q(ke,n),c=De(ke,n),l=re(ke,n),[u,d]=j.useState(null),f=w(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=x(t,d,c.onItemTextChange,f),m=u?.textContent,h=j.useMemo(()=>(0,N.jsx)(`option`,{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:_}=l;return C(()=>(g(h),()=>_(h)),[g,_,h]),(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(b.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!$(o.value)?M.createPortal(a.children,o.valueNode):null]})},`SelectItemText`)),je=`SelectItemIndicator`,Me=j.forwardRef(F(function(e,t){let{__scopeSelect:n,...r}=e;return De(je,n).isSelected?(0,N.jsx)(b.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),Ne=`SelectScrollUpButton`,Pe=j.forwardRef(F(function(e,t){let n=Q(Ne,e.__scopeSelect),r=be(Ne,e.__scopeSelect),[i,a]=j.useState(!1),o=x(t,r.onScrollButtonChange);return C(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};F(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,N.jsx)(Le,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),Fe=`SelectScrollDownButton`,Ie=j.forwardRef(F(function(e,t){let n=Q(Fe,e.__scopeSelect),r=be(Fe,e.__scopeSelect),[i,a]=j.useState(!1),o=x(t,r.onScrollButtonChange);return C(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};F(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,N.jsx)(Le,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),Le=j.forwardRef(F(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Q(`SelectScrollButton`,n),o=j.useRef(null),s=B(n),c=j.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return j.useEffect(()=>()=>c(),[c]),C(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,N.jsx)(b.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:O(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:O(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:O(i.onPointerLeave,()=>{c()})})},`SelectScrollButtonImpl`)),Re=`SelectBubbleInput`,ze=j.forwardRef(F(function({__scopeSelect:e,...t},n){let r=K(Re,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:u,form:d,userSelection:f}=r,{nativeOptions:p,nativeSelectKey:m}=r,h=j.useRef(null),g=x(n,h),_=i??``,v=j.useRef(_),y=j.useRef(f),S=j.useRef(!1),C=Array.from(p).some(e=>(e.props.value??``)===``);return j.useEffect(()=>{let e=h.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set,r=f!==null&&f!==y.current;y.current=f;let i=v.current!==_;v.current=_;let a=r&&i;if(r&&!i&&f.value!==_&&!f.hasConsumerStoppedPropagation&&n){S.current=!0;try{n.call(e,f.value),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}finally{S.current=!1,n.call(e,_)}return}let o=a&&!f.hasConsumerStoppedPropagation;if(i&&n){let t=new Event(`change`,{bubbles:o});n.call(e,_),e.dispatchEvent(t)}},[_,f]),(0,N.jsxs)(b.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:u,disabled:s,form:d,onChange:e=>{S.current||a(e.target.value)},...t,style:{...l,...t.style},ref:g,defaultValue:_,children:[$(i)&&!C?(0,N.jsx)(`option`,{value:``}):null,Array.from(p)]},m)},`SelectBubbleInput`));function Be(e){return typeof e==`function`}F(Be,`isFunction`);function $(e){return e===``||e===void 0}F($,`shouldShowPlaceholder`);function Ve(e){let t=w(e),n=j.useRef(``),r=j.useRef(0),i=j.useCallback(e=>{let i=n.current+e;t(i);function a(e){n.current=e,window.clearTimeout(r.current),e!==``&&(r.current=window.setTimeout(()=>a(``),1e3))}F(a,`updateSearch`),a(i)},[t]),a=j.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return j.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}F(Ve,`useTypeaheadSearch`);function He(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Ue(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}F(He,`findNextItem`);function Ue(e,t){return e.map((n,r)=>e[(t+r)%e.length])}F(Ue,`wrapArray`);function We({...e}){return(0,N.jsx)(Y,{"data-slot":`select`,...e})}function Ge({...e}){return(0,N.jsx)(se,{"data-slot":`select-value`,...e})}function Ke({className:e,size:r=`default`,children:i,...a}){return(0,N.jsxs)(ae,{"data-slot":`select-trigger`,"data-size":r,className:t(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...a,children:[i,(0,N.jsx)(ce,{asChild:!0,children:(0,N.jsx)(n,{className:`pointer-events-none size-4 text-muted-foreground`})})]})}function qe({className:e,children:n,position:r=`item-aligned`,align:i=`center`,...a}){return(0,N.jsx)(de,{children:(0,N.jsxs)(fe,{"data-slot":`select-content`,"data-align-trigger":r===`item-aligned`,className:t(`relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,r===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:r,align:i,...a,children:[(0,N.jsx)(Ye,{}),(0,N.jsx)(Se,{"data-position":r,className:t(`data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)`,r===`popper`&&``),children:n}),(0,N.jsx)(Xe,{})]})})}function Je({className:e,children:n,...r}){return(0,N.jsxs)(Oe,{"data-slot":`select-item`,className:t(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...r,children:[(0,N.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`,children:(0,N.jsx)(Me,{children:(0,N.jsx)(i,{className:`pointer-events-none`})})}),(0,N.jsx)(Ae,{children:n})]})}function Ye({className:e,...n}){return(0,N.jsx)(Pe,{"data-slot":`select-scroll-up-button`,className:t(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:(0,N.jsx)(r,{})})}function Xe({className:e,...r}){return(0,N.jsx)(Ie,{"data-slot":`select-scroll-down-button`,className:t(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:(0,N.jsx)(n,{})})}export{Ge as a,Ke as i,qe as n,Je as r,We as t};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./dist-wxbqfqV1.js";import{fr as n,lr as r,pr as i}from"./icons-COCLuOtb.js";import{n as a,t as o}from"./jsx-runtime-C3cWAN_r.js";import{n as s}from"./clsx-BxLRjTE8.js";import{c,l}from"./switch-BHplnCdo.js";import{F as u,I as d,J as f,M as p,N as m,X as h,Y as g,Z as _,at as v,ct as y,dt as b,gt as x,it as S,lt as C,nt as w,ot as T,pt as E,q as D,rt as ee,st as O,tt as k,ut as A}from"./format-D3kairnQ.js";var j=e(a(),1),M=e(s(),1),N=o(),P=Object.defineProperty,F=(e,t)=>P(e,`name`,{value:t,configurable:!0}),te={ItemAligned:`item-aligned`,Popper:`popper`},ne={LTR:`ltr`,RTL:`rtl`},I=[` `,`Enter`,`ArrowUp`,`ArrowDown`],L=[` `,`Enter`],R=`Select`,[z,B,V]=y(R),[H,U]=A(R,[V,d]),W=d(),[G,K]=H(R),[q,re]=H(R);function J(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:m,form:h,internal_do_not_use_render:g}=e,_=W(t),[v,y]=j.useState(null),[b,x]=j.useState(null),[C,w]=j.useState(!1),E=ee(l),[D,O]=T({prop:r,defaultProp:i??!1,onChange:a,caller:R}),[k,A]=T({prop:o,defaultProp:s,onChange:c,caller:R}),M=j.useRef(null),P=j.useRef(!1),[te,ne]=j.useState(null),I=F(e=>{ne({value:e,hasConsumerStoppedPropagation:P.current}),A(e)},`handleUserSelect`),L=j.useRef(k);j.useEffect(()=>{let e=h?v?.ownerDocument.getElementById(h):v?.form;if(e instanceof HTMLFormElement){let t=F(()=>A(L.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[h,v,A]);let B=!v||!!h||!!v.closest(`form`),[V,H]=j.useState(new Set),U=S(),K=Array.from(V).map(e=>e.props.value).join(`;`),re=j.useCallback(e=>{H(t=>new Set(t).add(e))},[]),J=j.useCallback(e=>{H(t=>{let n=new Set(t);return n.delete(e),n})},[]),Y={required:m,trigger:v,onTriggerChange:y,valueNode:b,onValueNodeChange:x,valueNodeHasChildren:C,onValueNodeHasChildrenChange:w,contentId:U,value:k,onValueChange:A,hasConsumerStoppedPropagationRef:P,userSelection:te,onUserSelect:I,open:D,onOpenChange:O,dir:E,triggerPointerDownPosRef:M,disabled:f,name:u,autoComplete:d,form:h,nativeOptions:V,nativeSelectKey:K,isFormControl:B};return(0,N.jsx)(p,{..._,children:(0,N.jsx)(G,{scope:t,...Y,children:(0,N.jsx)(z.Provider,{scope:t,children:(0,N.jsx)(q,{scope:t,onNativeOptionAdd:re,onNativeOptionRemove:J,children:Be(g)?g(Y):n})})})})}F(J,`SelectProvider`);var Y=F(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,N.jsx)(J,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,N.jsxs)(N.Fragment,{children:[n,e?(0,N.jsx)(ze,{__scopeSelect:t}):null]})})},`Select`),ie=`SelectTrigger`,ae=j.forwardRef(F(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=W(n),o=K(ie,n),s=o.disabled||r,c=x(t,o.onTriggerChange),l=B(n),u=j.useRef(`touch`),[d,f,p]=Ve(e=>{let t=l().filter(e=>!e.disabled),n=He(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onUserSelect(n.value)}),h=F(e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,N.jsx)(m,{asChild:!0,...a,children:(0,N.jsx)(b.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":$(o.value)?``:void 0,...i,ref:c,onClick:O(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&h(e)}),onPointerDown:O(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(h(e),e.preventDefault())}),onKeyDown:O(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&(o.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),f(e.key)),t&&e.key===` `||I.includes(e.key)&&(h(),e.preventDefault())})})})},`SelectTrigger`)),oe=`SelectValue`,se=j.forwardRef(F(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=K(oe,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=x(t,c.onValueNodeChange);C(()=>{l(u)},[l,u]);let f=$(c.value);return(0,N.jsx)(b.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,N.jsx)(j.Fragment,{children:f?o:a},f?`placeholder`:`value`)})},`SelectValue`)),ce=j.forwardRef(F(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,N.jsx)(b.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[le,ue]=H(`SelectPortal`,{forceMount:void 0}),de=F(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,N.jsx)(le,{scope:e.__scopeSelect,forceMount:n,children:(0,N.jsx)(h,{asChild:!0,...r})})},`SelectPortal`),X=`SelectContent`,fe=j.forwardRef(F(function(e,t){let n=ue(X,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=K(X,e.__scopeSelect),[o,s]=j.useState();return C(()=>{s(new DocumentFragment)},[]),(0,N.jsx)(v,{present:r||a.open,children:({present:e})=>e?(0,N.jsx)(ge,{...i,ref:t}):(0,N.jsx)(pe,{...i,fragment:o})})},`SelectContent`)),pe=j.forwardRef(F(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?M.createPortal((0,N.jsx)(me,{scope:n,children:(0,N.jsx)(z.Slot,{scope:n,children:(0,N.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),Z=10,[me,Q]=H(X),he=E(`SelectContent.RemoveScroll`),ge=j.forwardRef(F(function(e,t){let{__scopeSelect:n}=e,{position:r=te.ItemAligned,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:v,avoidCollisions:y,...b}=e,S=K(X,n),[C,w]=j.useState(null),[T,E]=j.useState(null),ee=x(t,w),[A,M]=j.useState(null),[P,ne]=j.useState(null),I=B(n),[L,R]=j.useState(!1),z=j.useRef(!1),V=j.useRef(!1),H=j.useRef(!1);j.useEffect(()=>{if(C)return D(C)},[C]),g();let U=j.useCallback(e=>{let[t,...n]=I().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&T&&(T.scrollTop=0),n===r&&T&&(T.scrollTop=T.scrollHeight),n?.focus(),document.activeElement!==i))return},[I,T]),W=j.useCallback(()=>U([A,C]),[U,A,C]);j.useEffect(()=>{L&&W()},[L,W]);let{onOpenChange:G,triggerPointerDownPosRef:q}=S;j.useEffect(()=>{if(C){let e={x:0,y:0},t=F(t=>{e={x:Math.abs(Math.round(t.pageX)-(q.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(q.current?.y??0))}},`handlePointerMove`),n=F(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(C)||G(!1),document.removeEventListener(`pointermove`,t),q.current=null},`handlePointerUp`);return q.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[C,G,q]),j.useEffect(()=>{let e=F(()=>G(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[G]);let[re,J]=Ve(e=>{let t=I().filter(e=>!e.disabled),n=He(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),Y=j.useCallback((e,t,n)=>{let r=!V.current;r&&(V.current=!0);let i=!z.current&&!n;S.value!==void 0&&S.value===t||i?(M(e),i&&(z.current=!0)):r&&M(e)},[S.value]),ie=j.useCallback(()=>C?.focus(),[C]),ae=j.useCallback((e,t,n)=>{if(!e)return;let r=!H.current;r&&(H.current=!0);let i=!z.current&&!n;(S.value!==void 0&&S.value===t||i||r)&&ne(e)},[S.value]),oe=r===te.Popper?ve:_e,se=oe===ve?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:v,avoidCollisions:y}:{};return(0,N.jsx)(me,{scope:n,content:C,viewport:T,onViewportChange:E,itemRefCallback:Y,selectedItem:A,onItemLeave:ie,itemTextRefCallback:ae,focusSelectedItem:W,selectedItemText:P,position:r,isPositioned:L,searchRef:re,children:(0,N.jsx)(f,{as:he,allowPinchZoom:!0,children:(0,N.jsx)(_,{asChild:!0,trapped:S.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:O(i,e=>{S.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,N.jsx)(k,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>S.onOpenChange(!1),children:(0,N.jsx)(oe,{role:`listbox`,id:S.contentId,"data-state":S.open?`open`:`closed`,dir:S.dir,onContextMenu:e=>e.preventDefault(),...b,...se,onPlaced:()=>R(!0),ref:ee,style:{display:`flex`,flexDirection:`column`,outline:`none`,...b.style},onKeyDown:O(b.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&J(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=I().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>U(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),_e=j.forwardRef(F(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=K(X,n),o=Q(X,n),[s,l]=j.useState(null),[u,d]=j.useState(null),f=x(t,d),p=B(n),m=j.useRef(!1),h=j.useRef(!0),{viewport:g,selectedItem:_,selectedItemText:v,focusSelectedItem:y}=o,S=j.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&u&&g&&_&&v){let e=a.trigger.getBoundingClientRect(),t=u.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=v.getBoundingClientRect();if(a.dir!==ne.RTL){let r=i.left-t.left,a=n.left-r,o=e.left-a,l=e.width+o,u=Math.max(l,t.width),d=window.innerWidth-Z,f=c(a,[Z,Math.max(Z,d-u)]);s.style.minWidth=l+`px`,s.style.left=f+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,l=e.width+o,u=Math.max(l,t.width),d=window.innerWidth-Z,f=c(a,[Z,Math.max(Z,d-u)]);s.style.minWidth=l+`px`,s.style.right=f+`px`}let o=p(),l=window.innerHeight-Z*2,d=g.scrollHeight,f=window.getComputedStyle(u),h=parseInt(f.borderTopWidth,10),y=parseInt(f.paddingTop,10),b=parseInt(f.borderBottomWidth,10),x=parseInt(f.paddingBottom,10),S=h+y+d+x+b,C=Math.min(_.offsetHeight*5,S),w=window.getComputedStyle(g),T=parseInt(w.paddingTop,10),E=parseInt(w.paddingBottom,10),D=e.top+e.height/2-Z,ee=l-D,O=_.offsetHeight/2,k=_.offsetTop+O,A=h+y+k,j=S-A;if(A<=D){let e=o.length>0&&_===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=u.clientHeight-g.offsetTop-g.offsetHeight,n=A+Math.max(ee,O+(e?E:0)+t+b);s.style.height=n+`px`}else{let e=o.length>0&&_===o[0].ref.current;s.style.top=`0px`;let t=Math.max(D,h+g.offsetTop+(e?T:0)+O)+j;s.style.height=t+`px`,g.scrollTop=A-D+g.offsetTop}s.style.margin=`${Z}px 0`,s.style.minHeight=C+`px`,s.style.maxHeight=l+`px`,r?.(),requestAnimationFrame(()=>m.current=!0)}},[p,a.trigger,a.valueNode,s,u,g,_,v,a.dir,r]);C(()=>S(),[S]);let[w,T]=j.useState();C(()=>{u&&T(window.getComputedStyle(u).zIndex)},[u]);let E=j.useCallback(e=>{e&&h.current===!0&&(S(),y?.(),h.current=!1)},[S,y]);return(0,N.jsx)(ye,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:m,onScrollButtonChange:E,children:(0,N.jsx)(`div`,{ref:l,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:w},children:(0,N.jsx)(b.div,{...i,ref:f,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),ve=j.forwardRef(F(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Z,...a}=e,o=W(n);return(0,N.jsx)(u,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[ye,be]=H(X,{}),xe=`SelectViewport`,Se=j.forwardRef(F(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=Q(xe,n),o=be(xe,n),s=x(t,a.onViewportChange),c=j.useRef(0);return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,N.jsx)(z.Slot,{scope:n,children:(0,N.jsx)(b.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:O(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-Z*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})},`SelectViewport`)),[Ce,we]=H(`SelectGroup`),Te=`SelectItem`,[Ee,De]=H(Te),Oe=j.forwardRef(F(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=K(Te,n),c=Q(Te,n),l=s.value===r,[u,d]=j.useState(a??``),[f,p]=j.useState(!1),m=w(e=>c.itemRefCallback?.(e,r,i)),h=x(t,m),g=S(),_=j.useRef(`touch`);function v(e){s.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),s.onUserSelect(r),s.onOpenChange(!1)}return F(v,`handleSelect`),(0,N.jsx)(Ee,{scope:n,value:r,disabled:i,textId:g,isSelected:l,onItemTextChange:j.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,N.jsx)(z.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,N.jsx)(b.div,{role:`option`,"aria-labelledby":g,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:h,onFocus:O(o.onFocus,()=>p(!0)),onBlur:O(o.onBlur,()=>p(!1)),onClick:O(o.onClick,e=>{i||_.current!==`mouse`&&v(e)}),onPointerUp:O(o.onPointerUp,e=>{i||_.current===`mouse`&&v(e)}),onPointerDown:O(o.onPointerDown,e=>{_.current=e.pointerType}),onPointerMove:O(o.onPointerMove,e=>{_.current=e.pointerType,i?c.onItemLeave?.():_.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:O(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:O(o.onKeyDown,e=>{i||e.target!==e.currentTarget||(c.searchRef?.current===``||e.key!==` `)&&(L.includes(e.key)&&v(e),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),ke=`SelectItemText`,Ae=j.forwardRef(F(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,o=K(ke,n),s=Q(ke,n),c=De(ke,n),l=re(ke,n),[u,d]=j.useState(null),f=w(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=x(t,d,c.onItemTextChange,f),m=u?.textContent,h=j.useMemo(()=>(0,N.jsx)(`option`,{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:_}=l;return C(()=>(g(h),()=>_(h)),[g,_,h]),(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(b.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!$(o.value)?M.createPortal(a.children,o.valueNode):null]})},`SelectItemText`)),je=`SelectItemIndicator`,Me=j.forwardRef(F(function(e,t){let{__scopeSelect:n,...r}=e;return De(je,n).isSelected?(0,N.jsx)(b.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),Ne=`SelectScrollUpButton`,Pe=j.forwardRef(F(function(e,t){let n=Q(Ne,e.__scopeSelect),r=be(Ne,e.__scopeSelect),[i,a]=j.useState(!1),o=x(t,r.onScrollButtonChange);return C(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};F(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,N.jsx)(Le,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),Fe=`SelectScrollDownButton`,Ie=j.forwardRef(F(function(e,t){let n=Q(Fe,e.__scopeSelect),r=be(Fe,e.__scopeSelect),[i,a]=j.useState(!1),o=x(t,r.onScrollButtonChange);return C(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};F(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,N.jsx)(Le,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),Le=j.forwardRef(F(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Q(`SelectScrollButton`,n),o=j.useRef(null),s=B(n),c=j.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return j.useEffect(()=>()=>c(),[c]),C(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,N.jsx)(b.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:O(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:O(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:O(i.onPointerLeave,()=>{c()})})},`SelectScrollButtonImpl`)),Re=`SelectBubbleInput`,ze=j.forwardRef(F(function({__scopeSelect:e,...t},n){let r=K(Re,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:u,form:d,userSelection:f}=r,{nativeOptions:p,nativeSelectKey:m}=r,h=j.useRef(null),g=x(n,h),_=i??``,v=j.useRef(_),y=j.useRef(f),S=j.useRef(!1),C=Array.from(p).some(e=>(e.props.value??``)===``);return j.useEffect(()=>{let e=h.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set,r=f!==null&&f!==y.current;y.current=f;let i=v.current!==_;v.current=_;let a=r&&i;if(r&&!i&&f.value!==_&&!f.hasConsumerStoppedPropagation&&n){S.current=!0;try{n.call(e,f.value),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}finally{S.current=!1,n.call(e,_)}return}let o=a&&!f.hasConsumerStoppedPropagation;if(i&&n){let t=new Event(`change`,{bubbles:o});n.call(e,_),e.dispatchEvent(t)}},[_,f]),(0,N.jsxs)(b.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:u,disabled:s,form:d,onChange:e=>{S.current||a(e.target.value)},...t,style:{...l,...t.style},ref:g,defaultValue:_,children:[$(i)&&!C?(0,N.jsx)(`option`,{value:``}):null,Array.from(p)]},m)},`SelectBubbleInput`));function Be(e){return typeof e==`function`}F(Be,`isFunction`);function $(e){return e===``||e===void 0}F($,`shouldShowPlaceholder`);function Ve(e){let t=w(e),n=j.useRef(``),r=j.useRef(0),i=j.useCallback(e=>{let i=n.current+e;t(i);function a(e){n.current=e,window.clearTimeout(r.current),e!==``&&(r.current=window.setTimeout(()=>a(``),1e3))}F(a,`updateSearch`),a(i)},[t]),a=j.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return j.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}F(Ve,`useTypeaheadSearch`);function He(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Ue(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}F(He,`findNextItem`);function Ue(e,t){return e.map((n,r)=>e[(t+r)%e.length])}F(Ue,`wrapArray`);function We({...e}){return(0,N.jsx)(Y,{"data-slot":`select`,...e})}function Ge({...e}){return(0,N.jsx)(se,{"data-slot":`select-value`,...e})}function Ke({className:e,size:r=`default`,children:i,...a}){return(0,N.jsxs)(ae,{"data-slot":`select-trigger`,"data-size":r,className:t(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...a,children:[i,(0,N.jsx)(ce,{asChild:!0,children:(0,N.jsx)(n,{className:`pointer-events-none size-4 text-muted-foreground`})})]})}function qe({className:e,children:n,position:r=`item-aligned`,align:i=`center`,...a}){return(0,N.jsx)(de,{children:(0,N.jsxs)(fe,{"data-slot":`select-content`,"data-align-trigger":r===`item-aligned`,className:t(`relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,r===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:r,align:i,...a,children:[(0,N.jsx)(Ye,{}),(0,N.jsx)(Se,{"data-position":r,className:t(`data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)`,r===`popper`&&``),children:n}),(0,N.jsx)(Xe,{})]})})}function Je({className:e,children:n,...r}){return(0,N.jsxs)(Oe,{"data-slot":`select-item`,className:t(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...r,children:[(0,N.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`,children:(0,N.jsx)(Me,{children:(0,N.jsx)(i,{className:`pointer-events-none`})})}),(0,N.jsx)(Ae,{children:n})]})}function Ye({className:e,...n}){return(0,N.jsx)(Pe,{"data-slot":`select-scroll-up-button`,className:t(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:(0,N.jsx)(r,{})})}function Xe({className:e,...r}){return(0,N.jsx)(Ie,{"data-slot":`select-scroll-down-button`,className:t(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:(0,N.jsx)(n,{})})}export{Ge as a,Ke as i,qe as n,Je as r,We as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{L as t,d as n,f as r,p as i,v as a}from"./dropdown-menu-C4XI7F63.js";import{Ar as o,Ot as s,U as c,dn as l}from"./icons-COCLuOtb.js";import{n as u,t as d}from"./jsx-runtime-C3cWAN_r.js";import{t as f}from"./bits-B2GRjm37.js";import{t as p}from"./thread-view-CPlJsMhl.js";import{S as m}from"./format-D1ma_o2D.js";var h=e(u(),1),g=d();function _({origin:e}){let a=e.sessionId,s=m(a),{upTo:u}=n(e);return i(e)?(0,g.jsxs)(f,{icon:(0,g.jsx)(c,{}),title:`Review session`,className:`flex-1`,children:[`Reviews the changes of`,` `,(0,g.jsx)(t,{to:`/sessions/$sessionId`,params:{sessionId:a},className:`font-medium text-foreground underline-offset-2 hover:underline`,children:s?s.title??s.purpose:`another session`}),`, read-only, in its own worktree with that session's code. Once the worktree is ready, CodeDen sends the agent a review brief as its first message. The original session is unchanged.`]}):r(e)?(0,g.jsxs)(f,{icon:(0,g.jsx)(o,{}),title:`Handed-off session`,className:`flex-1`,children:[`Continues`,` `,(0,g.jsx)(t,{to:`/sessions/$sessionId`,params:{sessionId:a},className:`font-medium text-foreground underline-offset-2 hover:underline`,children:s?s.title??s.purpose:`another session`}),` `,`with its code so far, in its own worktree and branch. Once the worktree is ready, CodeDen sends the agent a brief of the work as its first message. The original session is unchanged.`]}):(0,g.jsxs)(f,{icon:(0,g.jsx)(l,{}),title:`Forked session`,className:`flex-1`,children:[`Forked from`,` `,(0,g.jsx)(t,{to:`/sessions/$sessionId`,params:{sessionId:a},className:`font-medium text-foreground underline-offset-2 hover:underline`,children:s?s.title??s.purpose:`another session`}),`. The agent has the conversation and the code `,u,`, in its own worktree and branch. Send a message to continue; the original session is unchanged.`]})}function v({sessionId:e,focusItemId:t,focusThread:n}){let r=m(e)?.forkedFrom,i=a(e=>e.openChildThread),o=n?.threadId,c=n?.itemId;return(0,h.useEffect)(()=>{o&&c&&i(e,o,c)},[e,o,c,i]),(0,g.jsx)(p,{sessionId:e,focusItemId:t,empty:r?(0,g.jsx)(_,{origin:r}):(0,g.jsx)(f,{icon:(0,g.jsx)(s,{}),title:`No messages yet`,className:`flex-1`,children:`Describe the task. The agent works in its own worktree and branch.`})},e)}export{v as SessionPage};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{L as t,d as n,f as r,p as i,v as a}from"./dropdown-menu-Bflkx6wY.js";import{Ar as o,Ot as s,U as c,dn as l}from"./icons-COCLuOtb.js";import{n as u,t as d}from"./jsx-runtime-C3cWAN_r.js";import{t as f}from"./bits-B2GRjm37.js";import{t as p}from"./thread-view-AQKzJlKb.js";import{S as m}from"./format-D3kairnQ.js";var h=e(u(),1),g=d();function _({origin:e}){let a=e.sessionId,s=m(a),{upTo:u}=n(e);return i(e)?(0,g.jsxs)(f,{icon:(0,g.jsx)(c,{}),title:`Review session`,className:`flex-1`,children:[`Reviews the changes of`,` `,(0,g.jsx)(t,{to:`/sessions/$sessionId`,params:{sessionId:a},className:`font-medium text-foreground underline-offset-2 hover:underline`,children:s?s.title??s.purpose:`another session`}),`, read-only, in its own worktree with that session's code. Once the worktree is ready, CodeDen sends the agent a review brief as its first message. The original session is unchanged.`]}):r(e)?(0,g.jsxs)(f,{icon:(0,g.jsx)(o,{}),title:`Handed-off session`,className:`flex-1`,children:[`Continues`,` `,(0,g.jsx)(t,{to:`/sessions/$sessionId`,params:{sessionId:a},className:`font-medium text-foreground underline-offset-2 hover:underline`,children:s?s.title??s.purpose:`another session`}),` `,`with its code so far, in its own worktree and branch. Once the worktree is ready, CodeDen sends the agent a brief of the work as its first message. The original session is unchanged.`]}):(0,g.jsxs)(f,{icon:(0,g.jsx)(l,{}),title:`Forked session`,className:`flex-1`,children:[`Forked from`,` `,(0,g.jsx)(t,{to:`/sessions/$sessionId`,params:{sessionId:a},className:`font-medium text-foreground underline-offset-2 hover:underline`,children:s?s.title??s.purpose:`another session`}),`. The agent has the conversation and the code `,u,`, in its own worktree and branch. Send a message to continue; the original session is unchanged.`]})}function v({sessionId:e,focusItemId:t,focusThread:n}){let r=m(e)?.forkedFrom,i=a(e=>e.openChildThread),o=n?.threadId,c=n?.itemId;return(0,h.useEffect)(()=>{o&&c&&i(e,o,c)},[e,o,c,i]),(0,g.jsx)(p,{sessionId:e,focusItemId:t,empty:r?(0,g.jsx)(_,{origin:r}):(0,g.jsx)(f,{icon:(0,g.jsx)(s,{}),title:`No messages yet`,className:`flex-1`,children:`Describe the task. The agent works in its own worktree and branch.`})},e)}export{v as SessionPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{H as t,O as n,i as r,k as i}from"./api-B620HpC2.js";import{L as a}from"./dropdown-menu-C4XI7F63.js";import{d as o,i as s,n as c,o as l,t as u}from"./switch-DuBpF2_h.js";import{A as d,Bn as f,Cr as p,Er as m,F as h,Gn as g,Ir as ee,Jt as te,Kn as ne,Lt as re,Nt as ie,O as ae,Qt as oe,St as se,Tr as ce,X as le,Yt as ue,a as de,cn as fe,h as pe,ir as me,k as he,n as ge,pr as _e,q as ve,qt as ye,s as be,sr as xe,tt as Se,vt as Ce,wn as we,z as Te,zn as Ee}from"./icons-COCLuOtb.js";import{a as De}from"./bits-B2GRjm37.js";import{t as _}from"./number-field-Bzzs0k9i.js";import{n as Oe}from"./footer-BFGvnowz.js";import{c as ke,d as v,h as Ae,n as je,o as Me,p as Ne,r as Pe,s as Fe,t as Ie}from"./model-picker-4yoJPkRY.js";import{t as Le}from"./kill-switch-Dvqaozhz.js";import{t as Re}from"./autonomy-Bx33JDEO.js";import{D as y,E as ze,j as b,m as x,n as S,yt as C}from"./format-D1ma_o2D.js";import{t as w}from"./dist-wxbqfqV1.js";import{i as Be}from"./theme-DsW-i9mD.js";import{t as Ve}from"./skeleton-D8Sbd2jT.js";import{E as He,O as Ue}from"./mobile-nav-D8FZcJzG.js";import{i as T,n as E,r as D,t as O}from"./settings-ui-Ux8rPFol.js";import{n as We,t as Ge}from"./jsx-runtime-C3cWAN_r.js";import{t as k}from"./input-CPpbtC2H.js";import{F as A,t as j}from"./useQuery-VSotSwry.js";import{a as Ke,c as qe,i as Je,n as Ye,r as Xe,t as Ze}from"./dialog-Dyw3b_Tu.js";import{a as M,i as N,n as P,r as F,t as I}from"./select-B4LGxZQI.js";import{c as Qe,i as $e,s as et}from"./updates-CQZDqpFF.js";import{l as tt,n as nt,r as rt,s as it,u as at}from"./update-banner-CNYd8gAf.js";import{i as L,n as ot,t as st}from"./engines-Chq2ih3x.js";import{i as ct,n as lt,r as ut,t as dt}from"./local-whisper-test-DPTOEA1M.js";import{t as ft}from"./page-header-BqPf-jRo.js";var R=Ge();function pt(){let e=ze().data?.projects,{setAgentCiEnv:t}=He();return(0,R.jsx)(D,{title:`Agent environment`,description:`Agent sessions run with CI=true, so installs and other commands never stop at a prompt nobody can answer. Your project's tools then act as they do in CI: Playwright won't reuse a running dev server, fails on test.only and retries failing tests; Yarn won't update the lockfile; Create React App fails the build on warnings. Turn it off for a project whose tools get in the way. Applies to agent sessions opened after the change; your terminals never get it.`,children:e===void 0?(0,R.jsx)(`div`,{className:`px-4 py-3.5`,role:`status`,"aria-label":`Loading projects`,children:(0,R.jsx)(Ve,{className:`h-4 w-1/3`})}):e.length===0?(0,R.jsx)(`p`,{className:`px-4 py-3.5 text-2xs text-muted-foreground`,children:`Add a project to choose this per project.`}):e.map(e=>(0,R.jsx)(E,{label:e.name,help:e.agentCiEnv?`Agent sessions run with CI=true.`:(0,R.jsxs)(R.Fragment,{children:[`Agent sessions run without CI. pnpm may then stop to ask before reinstalling`,` `,(0,R.jsx)(`code`,{children:`node_modules`}),`: set `,(0,R.jsx)(`code`,{children:`confirmModulesPurge: false`}),` in the project's `,(0,R.jsx)(`code`,{children:`pnpm-workspace.yaml`}),`.`]}),children:(0,R.jsx)(u,{"aria-label":`Run ${e.name}'s agent sessions with CI=true`,checked:e.agentCiEnv,onCheckedChange:n=>void t(e,n)})},e.id))})}var z=e(We(),1);function mt({provider:e,custom:t,onChange:n}){let r=t[e.id]??[],[i,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(``),[c,l]=(0,z.useState)(null);return(0,R.jsx)(E,{label:e.displayName,help:r.length?`${r.length} custom`:`None yet`,stacked:!0,children:(0,R.jsxs)(`div`,{className:`space-y-2`,"data-testid":`custom-models-${e.id}`,children:[r.length>0&&(0,R.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:r.map(t=>(0,R.jsxs)(`li`,{className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-border px-2 text-xs`,children:[(0,R.jsx)(`span`,{children:t.label??t.id}),t.label&&(0,R.jsx)(`span`,{className:`font-mono text-2xs text-muted-foreground`,children:t.id}),(0,R.jsx)(`button`,{type:`button`,"aria-label":`Remove ${t.label??t.id}`,onClick:()=>n(e.id,ke(r,t.id)),className:`rounded text-muted-foreground hover:text-foreground`,children:(0,R.jsx)(ge,{className:`size-3`,"aria-hidden":!0})})]},t.id))}),(0,R.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let c=Fe(r,e,{id:i,label:o});`error`in c?l(c.error):(n(e.id,c.list),a(``),s(``),l(null))},className:`flex flex-wrap items-center gap-1.5`,children:[(0,R.jsx)(k,{value:i,onChange:e=>{a(e.target.value),l(null)},placeholder:`Model id`,"aria-label":`${e.displayName} custom model id`,"aria-invalid":c?!0:void 0,className:`h-7 w-56 font-mono text-xs`}),(0,R.jsx)(k,{value:o,onChange:e=>s(e.target.value),placeholder:`Label (optional)`,"aria-label":`${e.displayName} custom model label`,className:`h-7 w-44 text-xs`}),(0,R.jsxs)(x,{type:`submit`,variant:`outline`,size:`sm`,className:`h-7 gap-1 text-xs`,children:[(0,R.jsx)(Se,{className:`size-3`,"aria-hidden":!0}),`Add`]})]}),c&&(0,R.jsx)(`p`,{role:`alert`,className:`text-2xs text-destructive`,children:c})]})})}function ht(){let e=y(e=>e.runner.providers,[]),{custom:t,set:n}=je();return e.length===0?null:(0,R.jsx)(D,{title:`Custom models`,description:`Add a model id a provider doesn't list yet, such as a new model. It is sent to the provider as is; if the provider doesn't know it, the turn fails with the provider's error. Its effort levels are those of the provider's default model.`,children:e.map(e=>(0,R.jsx)(mt,{provider:e,custom:t,onChange:n},e.id))})}function gt(){let e=y(e=>e.runner.providers,[]),{hidden:t,toggle:n}=Pe();return e.length===0?null:(0,R.jsx)(D,{title:`Models in the picker`,description:`Hide models you don't use. A hidden model still shows wherever it is already chosen.`,children:e.map(e=>{let r=e.models.filter(n=>Me(t,e.id,n.id)).length;return(0,R.jsx)(E,{label:e.displayName,help:`${e.models.length-r} of ${e.models.length} shown`,stacked:!0,children:(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,"data-testid":`model-visibility-${e.id}`,children:e.models.map(r=>{let i=!Me(t,e.id,r.id);return(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":i,"aria-label":`Show ${r.label} in the picker`,title:r.description,onClick:()=>n(e.id,r.id),className:w(`inline-flex h-7 items-center gap-1.5 rounded-md border px-2 text-xs transition-colors`,i?`border-border bg-background text-foreground hover:bg-accent`:`border-dashed border-border text-muted-foreground line-through hover:bg-accent`),children:[i?(0,R.jsx)(Ee,{className:`size-3`,"aria-hidden":!0}):(0,R.jsx)(f,{className:`size-3`,"aria-hidden":!0}),r.label]},r.id)})})},e.id)})})}var B=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function _t(){let e=y(e=>e.runner.providers,[]).filter(e=>e.capabilities.vendorHistory);return e.length===0?null:(0,R.jsx)(D,{title:`Provider apps`,description:`Some providers' own apps list every conversation on this machine as yours. CodeDen keeps the sessions it starts out of those lists.`,children:e.map(e=>(0,R.jsx)(vt,{provider:e},e.id))})}function vt({provider:e}){let[t,n]=(0,z.useState)(!1);return(0,R.jsxs)(E,{label:`Hide CodeDen's sessions from the ${e.displayName} app`,help:`New sessions are hidden when each turn ends. This hides the ones from before: only sessions CodeDen started, never your own. They are archived, not deleted, and CodeDen can still resume them.`,children:[(0,R.jsxs)(x,{size:`xs`,variant:`outline`,onClick:()=>n(!0),children:[(0,R.jsx)(f,{}),` Review`]}),t&&(0,R.jsx)(yt,{provider:e,onClose:()=>n(!1)})]})}function yt({provider:e,onClose:t}){let n=r(),i=`the ${e.displayName} app`,a=j({queryKey:[`provider-history`,e.id],queryFn:()=>n.getProviderHistory(e.id),gcTime:0,retry:!1}),o=C({mutationFn:()=>n.hideProviderHistory(e.id)}),s=a.data?.entries??[],c=o.data;return(0,R.jsx)(Ze,{open:!0,onOpenChange:e=>!e&&t(),children:(0,R.jsxs)(Ye,{className:`sm:max-w-xl`,"data-testid":`hide-provider-history`,children:[(0,R.jsxs)(Ke,{children:[(0,R.jsxs)(qe,{children:[`Hide CodeDen's sessions from `,i]}),(0,R.jsxs)(Xe,{children:[`Only sessions CodeDen started, found by its own record of them. They are archived in`,` `,i,`, not deleted.`]})]}),c?(0,R.jsxs)(`div`,{className:`space-y-1 text-[13px]`,"data-testid":`hide-provider-history-result`,children:[(0,R.jsxs)(`p`,{children:[`Hid `,B(c.hidden.length,`session`),` from `,i,`.`]}),c.missing.length>0&&(0,R.jsxs)(`p`,{className:`text-2xs text-muted-foreground`,children:[B(c.missing.length,`session`),` had already gone from it.`]}),c.failed.length>0&&(0,R.jsxs)(`p`,{className:`text-2xs text-status-failed`,children:[B(c.failed.length,`session`),` couldn't be hidden:`,` `,c.failed[0]?.message]})]}):a.isPending?(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-[13px] text-muted-foreground`,children:[(0,R.jsx)(re,{className:`size-4 animate-spin`}),` Looking for CodeDen's sessions in `,i,`...`]}):a.isError?(0,R.jsx)(`p`,{className:`text-[13px] text-status-failed`,children:a.error.message}):s.length===0?(0,R.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[`None of CodeDen's sessions are listed in `,i,`.`]}):(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsxs)(`p`,{className:`text-[13px]`,children:[B(s.length,`session`),` CodeDen started`,` `,s.length===1?`is`:`are`,` listed in `,i,`:`]}),(0,R.jsx)(`ul`,{className:`max-h-72 overflow-y-auto rounded-lg border border-border`,"data-testid":`hide-provider-history-list`,children:s.map(e=>(0,R.jsxs)(`li`,{className:`border-b border-border px-3 py-2 last:border-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,R.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:e.sessionTitle??(e.preview||e.resumeToken)}),e.updatedAt&&(0,R.jsx)(`span`,{className:`shrink-0 text-3xs text-muted-foreground`,children:S(e.updatedAt)})]}),e.sessionTitle&&e.preview&&(0,R.jsx)(`p`,{className:`truncate text-2xs text-muted-foreground`,children:e.preview})]},e.resumeToken))})]}),o.isError&&(0,R.jsx)(`p`,{className:`text-2xs text-status-failed`,children:o.error.message}),(0,R.jsxs)(Je,{children:[(0,R.jsx)(x,{variant:`ghost`,size:`sm`,onClick:t,children:c?`Close`:`Cancel`}),!c&&(0,R.jsxs)(x,{size:`sm`,disabled:s.length===0||o.isPending,onClick:()=>o.mutate(),children:[o.isPending&&(0,R.jsx)(re,{className:`animate-spin`}),`Hide `,B(s.length,`session`)]})]})]})})}var bt={off:`Never asks the npm registry for new versions.`,notify:`Asks the npm registry for the latest version on start and every 6 hours (nothing else is sent) and offers a one-click update.`,auto:`Also downloads new versions in the background; they start the next time you open CodeDen.`},xt={off:`Never asks GitHub Releases for new versions.`,notify:`Asks GitHub Releases for the latest version on start and every 6 hours (nothing else is sent) and offers a one-click update.`,auto:`Also downloads new versions in the background; they install when you quit CodeDen.`};function St(e,t){return(t===`desktop`?xt:bt)[e]}function Ct(){let{settings:e,update:t}=T(),{data:n}=Qe(),r=e.updates.mode;return(0,R.jsx)(E,{label:`Updates`,help:St(r,n?.source),children:(0,R.jsxs)(I,{value:r,onValueChange:e=>t({updates:{mode:e}}),children:[(0,R.jsx)(N,{size:`sm`,className:`w-44`,"data-testid":`update-mode`,children:(0,R.jsx)(M,{})}),(0,R.jsxs)(P,{children:[(0,R.jsx)(F,{value:`off`,children:`Off`}),(0,R.jsx)(F,{value:`notify`,children:`Notify me`}),(0,R.jsx)(F,{value:`auto`,children:`Install automatically`})]})]})})}function wt(){let{settings:e,update:t}=T(),n=Be(e=>e.preference),r=Be(e=>e.setPreference);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(D,{title:`Appearance`,children:(0,R.jsx)(E,{label:`Theme`,help:`Dark is the default; light mirrors it.`,children:(0,R.jsx)(O,{value:n,onChange:e=>{r(e),t({appearance:{theme:e}})},options:[{value:`dark`,label:`Dark`},{value:`light`,label:`Light`},{value:`system`,label:`System`}]})})}),(0,R.jsxs)(D,{title:`Follow-up prompts`,description:`Suggested next prompts appear as chips when a turn completes.`,children:[(0,R.jsx)(E,{label:`Show follow-up chips`,children:(0,R.jsx)(u,{checked:e.followups.enabled,onCheckedChange:e=>t({followups:{enabled:e}})})}),(0,R.jsx)(E,{label:`Send on click`,help:`Off: a click fills the composer so you can edit first.`,children:(0,R.jsx)(u,{checked:e.followups.sendOnClick,onCheckedChange:e=>t({followups:{sendOnClick:e}})})})]}),(0,R.jsxs)(D,{title:`Agent sessions`,description:`What CodeDen does by itself to keep agent sessions going.`,children:[(0,R.jsx)(E,{label:`Pass on pull request feedback`,help:`In sessions you start, tells the agent when its pull request's checks fail, a reviewer requests changes or it has merge conflicts. Once per commit, up to three times per pull request. The project manager follows up on work it started.`,children:(0,R.jsx)(u,{checked:e.sessions.prFeedback,onCheckedChange:e=>t({sessions:{prFeedback:e}})})}),(0,R.jsx)(E,{label:`Retry after passing failures`,help:`When a turn fails because the API was overloaded or the connection dropped, continue after 20 s, 90 s and 5 min; after a usage limit, continue once it resets. Applies to every agent session.`,children:(0,R.jsx)(u,{checked:e.sessions.autoRetry,onCheckedChange:e=>t({sessions:{autoRetry:e}})})})]}),(0,R.jsx)(pt,{}),(0,R.jsxs)(D,{title:`Background work`,children:[(0,R.jsx)(E,{label:`Automations`,help:`Master switch. Each automation is still off until you enable it.`,children:(0,R.jsx)(u,{checked:e.automations.enabled,onCheckedChange:e=>t({automations:{enabled:e}})})}),(0,R.jsx)(E,{label:`Global factory kill switch`,help:e.factory.killSwitch?`On: no project's factory loop runs.`:`Stops every project's factory loop and all factory sessions at once.`,children:(0,R.jsx)(Le,{scope:`global`,on:e.factory.killSwitch,size:`xs`})}),(0,R.jsx)(Ct,{})]}),(0,R.jsxs)(D,{title:`Worktrees`,description:`Archiving a session removes its worktree unless it has uncommitted changes. Branches and checkpoints are kept, and a cleaned-up worktree is recreated when you message the session again.`,children:[(0,R.jsx)(E,{label:`Clean up inactive worktrees`,help:`Skips sessions with an open pull request and worktrees with uncommitted changes.`,children:(0,R.jsx)(u,{checked:e.worktrees.cleanup,onCheckedChange:e=>t({worktrees:{cleanup:e}})})}),(0,R.jsx)(E,{label:`Inactive for`,help:`Days without activity before cleanup.`,children:(0,R.jsxs)(`div`,{className:`flex items-baseline gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(_,{min:1,max:365,"aria-label":`Days before cleanup`,disabled:!e.worktrees.cleanup,value:e.worktrees.afterDays,onChange:e=>t({worktrees:{afterDays:e}}),wrapperClassName:`w-20`,className:`h-8 text-xs`}),`days`]})})]})]})}var Tt=[{role:`orchestrator`,label:`Orchestrator`,help:`Your front door across projects.`},{role:`pm`,label:`Project managers`,help:`Triage, planning and follow-up per project.`},{role:`agent`,label:`Agent sessions`,help:`Default for new coding sessions.`}];function Et(){let{settings:e,update:t}=T(),n=y(e=>e.runner.providers,[]);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(D,{title:`Installed providers`,description:`Detected on this machine and reused with their own logins.`,children:n.map(e=>(0,R.jsx)(E,{label:e.displayName,help:`${e.models.length} models · ${Object.entries(e.capabilities).filter(([,e])=>e).length} capabilities`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(De,{provider:e.id,className:`size-5`}),(0,R.jsx)(`span`,{className:`rounded-full bg-status-done/12 px-2 py-0.5 text-2xs text-status-done`,children:`Ready`})]})},e.id))}),(0,R.jsx)(D,{title:`Defaults per role`,description:`Each role can run on any provider. Changing the provider of the orchestrator or of project managers starts a fresh conversation for them on their next message.`,children:Tt.map(({role:r,label:i,help:a})=>{let o=e.providers[r],s=o.provider===`auto`;return(0,R.jsx)(E,{label:i,help:a,children:(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-1 py-0.5`,children:(0,R.jsx)(Ie,{providers:n,align:`end`,placeholder:`Auto`,value:s?null:{provider:o.provider,model:o.model,effort:o.effort},onChange:e=>t({providers:{[r]:e}}),footer:e=>(0,R.jsx)(Oe,{active:s,onClick:()=>{t({providers:{[r]:{provider:`auto`,model:null,effort:null}}}),e()},children:`Auto: the first ready provider and its default model`})})})},r)})}),(0,R.jsx)(gt,{}),(0,R.jsx)(ht,{}),(0,R.jsx)(_t,{})]})}function Dt(){let{settings:e,update:t}=T();return(0,R.jsxs)(D,{title:`Default permissions`,description:`From Read-only to Full, mapped onto each provider's native enforcement. Override per project, per session and per automation.`,children:[(0,R.jsx)(`div`,{className:`grid gap-2 p-3`,children:Object.keys(Re).map(n=>{let r=Re[n],i=e.autonomy.default===n;return(0,R.jsxs)(`button`,{type:`button`,onClick:()=>t({autonomy:{default:n}}),className:w(`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors`,i?`border-primary/50 bg-primary/[0.06]`:`border-border hover:bg-accent/40`),children:[(0,R.jsx)(r.icon,{className:w(`mt-0.5 size-4`,r.tone)}),(0,R.jsxs)(`span`,{children:[(0,R.jsxs)(`span`,{className:`block text-[13.5px] font-medium`,children:[r.label,n===`auto`&&(0,R.jsx)(`span`,{className:`ml-2 text-2xs font-normal text-muted-foreground`,children:`recommended`})]}),(0,R.jsx)(`span`,{className:`block text-2xs text-muted-foreground`,children:r.description})]})]},n)})}),(0,R.jsx)(E,{label:`Risky actions`,help:`Writes outside the worktree, force pushes, deleting branches, global installs, unlisted network hosts and secrets access always go to your inbox in Auto.`,children:(0,R.jsx)(`span`,{className:`text-2xs text-muted-foreground`,children:`Always ask`})})]})}function Ot(){let{settings:e,update:t}=T(),n=y(e=>e.runner.providers,[]),r=[[`followups`,`Follow-up suggestions`,`When the agent didn't suggest any itself.`],[`sessionTitles`,`Session titles`,`Short titles from the first message.`],[`noticeSummaries`,`Notice summaries`,`One-line summaries in PM wake-ups.`],[`handoffSummaries`,`Handoff summaries`,`What a session did, in the brief of a handoff. Off: its last reply.`]],i=e.utilityModel.provider===`auto`;return(0,R.jsxs)(D,{title:`Utility model`,description:`One small, cheap model for side jobs. Runs through an installed provider, no extra API key. It also writes read-aloud TL;DRs, chosen in Voice.`,children:[(0,R.jsx)(E,{label:`Model`,children:(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-1 py-0.5`,children:(0,R.jsx)(Ie,{providers:n,align:`end`,effort:!1,placeholder:`Auto (smallest available)`,value:i?null:{provider:e.utilityModel.provider,model:e.utilityModel.model,effort:null},onChange:e=>t({utilityModel:{provider:e.provider,model:e.model}}),footer:e=>(0,R.jsx)(Oe,{active:i,onClick:()=>{t({utilityModel:{provider:`auto`,model:null}}),e()},children:`Auto: the smallest available model`})})})}),r.map(([n,r,i])=>(0,R.jsx)(E,{label:r,help:i,children:(0,R.jsx)(u,{checked:e.utilityModel.jobs[n],onCheckedChange:e=>t({utilityModel:{jobs:{[n]:e}}})})},n))]})}function kt(){let{settings:e,update:t}=T(),{data:n=!1}=j({queryKey:[`platform`,`launch-at-login`],queryFn:()=>l.launchAtLoginSupported(),staleTime:1/0}),r=e.desktop;return(0,R.jsxs)(D,{title:`App`,description:`How CodeDen behaves as an app on this computer.`,children:[(0,R.jsx)(E,{label:`Open at login`,help:n?`Start CodeDen in the tray when you log in, so agents and automations are ready.`:`Not available for this kind of install.`,children:(0,R.jsx)(u,{"data-testid":`launch-at-login`,checked:r.launchAtLogin,disabled:!n,onCheckedChange:e=>t({desktop:{launchAtLogin:e}})})}),(0,R.jsx)(E,{label:`Keep running in the tray`,help:`Closing the window leaves CodeDen in the tray (menu bar on macOS). Quit from its menu.`,children:(0,R.jsx)(u,{checked:r.closeToTray,onCheckedChange:e=>t({desktop:{closeToTray:e}})})}),(0,R.jsx)(E,{label:`Keep the computer awake`,help:`Prevent sleep while an agent is running. The display can still turn off.`,children:(0,R.jsx)(u,{checked:r.keepAwake,onCheckedChange:e=>t({desktop:{keepAwake:e}})})}),l.capabilities.nativeBrowser&&(0,R.jsx)(E,{label:`Native browser`,help:`Show session browsers as real browser views in the panel: native scrolling, text selection and DevTools. Off uses the streamed view. Applies to browsers opened from now on.`,children:(0,R.jsx)(u,{"data-testid":`native-browser`,checked:r.nativeBrowser,onCheckedChange:e=>t({desktop:{nativeBrowser:e}})})})]})}function At(){let e=r(),t=y(e=>e.projects,[]),{data:n,isFetching:i,refetch:a,error:o}=j({queryKey:[`github`,`connection`],queryFn:()=>e.github.connection()}),s=n?.connected??!1;return(0,R.jsxs)(D,{title:`GitHub`,description:"Issues, pull requests, checks and evidence use the token from the GitHub CLI (`gh auth token`), read at runtime and never stored.",children:[(0,R.jsx)(E,{label:`Connection`,help:o?o.message:s?`Signed in${n?.login?` as ${n.login}`:``} via ${n?.source===`keychain`?`the OS keychain`:`the GitHub CLI`}.`:n?.message??`Checking…`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`github-connection`,children:[(0,R.jsxs)(`span`,{className:w(`inline-flex items-center gap-1 text-xs`,s?`text-status-done`:`text-status-waiting`),children:[s?(0,R.jsx)(xe,{className:`size-3.5`}):(0,R.jsx)(me,{className:`size-3.5`}),n?s?`Connected`:`Not connected`:`…`]}),(0,R.jsxs)(x,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:i,children:[(0,R.jsx)(le,{className:w(i&&`animate-spin`)}),` Re-check`]})]})}),t.map(e=>(0,R.jsx)(E,{label:e.name,help:e.kind===`github`?`${e.github.owner}/${e.github.repo}`:`No GitHub remote`,children:(0,R.jsx)(`span`,{className:`text-2xs text-muted-foreground`,children:e.kind===`github`?`Issue and PR flow`:`Local only`})},e.id))]})}var jt=[{value:`auto`,label:`Auto`},{value:`codex`,label:`Codex (your login)`},{value:`gemini`,label:`Gemini image models`},{value:`openai`,label:`OpenAI Images`},{value:`none`,label:`None (hide the tool)`}];function Mt({value:e,onChange:t,inherit:n,label:r}){return(0,R.jsxs)(I,{value:e,onValueChange:e=>t(e),children:[(0,R.jsx)(N,{size:`sm`,className:`w-48`,"aria-label":r,children:(0,R.jsx)(M,{})}),(0,R.jsxs)(P,{children:[n&&(0,R.jsx)(F,{value:`inherit`,children:`Same as global`}),jt.map(e=>(0,R.jsx)(F,{value:e.value,children:e.label},e.value))]})]})}function Nt({result:e,pending:t,onTest:n}){let i=r();return(0,R.jsxs)(`div`,{className:`space-y-3`,"data-testid":`image-test`,children:[(0,R.jsxs)(x,{size:`sm`,variant:`outline`,onClick:n,disabled:t,children:[(0,R.jsx)(we,{}),` `,t?`Generating…`:`Test`]}),e&&!e.ok&&(0,R.jsx)(`p`,{className:`text-2xs text-status-failed`,children:e.error?.message??`The test failed.`}),e?.ok&&(0,R.jsxs)(`div`,{className:`flex items-start gap-3`,children:[e.artifact&&(0,R.jsx)(`img`,{src:i.artifactUrl(e.artifact.id),alt:`Generated test`,className:`size-40 rounded-lg border border-border object-cover`}),(0,R.jsxs)(`div`,{className:`text-2xs text-muted-foreground`,children:[(0,R.jsxs)(`div`,{className:`font-medium text-foreground`,children:[`Generated with `,e.engine]}),e.model&&(0,R.jsx)(`div`,{className:`font-mono`,children:e.model}),(0,R.jsxs)(`div`,{children:[(e.durationMs/1e3).toFixed(1),`s`]})]})]})]})}var Pt=[`secrets`];function Ft(){let e=r();return j({queryKey:Pt,queryFn:()=>e.secrets.status()})}function V({secret:e,label:t,onChange:n}){let i=r(),a=A(),o=Ft(),s=o.data?.keys.find(t=>t.key===e)?.set??!1,[c,l]=(0,z.useState)(``),u=()=>{a.invalidateQueries({queryKey:Pt}),n?.()},d=C({mutationFn:()=>i.secrets.set(e,c.trim()),onSuccess:()=>{l(``),u(),b.success(`${t} saved`,{description:o.data?.backend===`memory`?`No OS keychain is available, so it lasts until the server restarts.`:`Stored in the OS keychain.`})},onError:e=>b.error(`${t} not saved`,{description:e.message})}),f=C({mutationFn:()=>i.secrets.remove(e),onSuccess:()=>{u(),b.success(`${t} removed`)}});return(0,R.jsxs)(`div`,{className:`flex w-80 items-center gap-2`,children:[(0,R.jsx)(k,{type:`password`,autoComplete:`off`,"aria-label":t,value:c,onChange:e=>l(e.target.value),placeholder:s?`•••••••• stored in keychain`:`Paste key`,className:`h-8 font-mono text-xs`}),(0,R.jsxs)(x,{size:`sm`,variant:`outline`,disabled:!c.trim()||d.isPending,onClick:()=>d.mutate(),children:[(0,R.jsx)(te,{}),` Save`]}),s&&(0,R.jsx)(x,{size:`icon-sm`,variant:`ghost`,"aria-label":`Remove ${t}`,onClick:()=>f.mutate(),children:(0,R.jsx)(pe,{})})]})}function It(){let e=r(),t=A(),{settings:n,update:i}=T(),a=n.imageGeneration,o=y(e=>e.projects,[]),[s,c]=(0,z.useState)(``),l=j({queryKey:[`image-engines`,s,a],queryFn:()=>e.images.engines(s||null)}),u=()=>void t.invalidateQueries({queryKey:[`image-engines`]}),[d,f]=(0,z.useState)(null),p=C({mutationFn:()=>e.images.test({projectId:s||void 0}),onMutate:()=>f(null),onSuccess:e=>{f(e),u()},onError:e=>f({ok:!1,engine:null,durationMs:0,error:{code:`error`,message:e.message}})}),m=s?a.projects[s]:void 0,h=async t=>{let n=e=>({imageGeneration:{projects:{[s]:e}}}),r=t===null?{}:{...m,...t};for(let e of Object.keys(r))r[e]===void 0&&delete r[e];let i=t!==null&&Object.values(t).some(e=>e===void 0);(t===null||i||Object.keys(r).length===0)&&await e.updateSettings(n(null)),Object.keys(r).length>0&&await e.updateSettings(n(r))},g=l.data?.active;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(D,{title:`Image generation`,description:`Every agent gets one generate_image tool, routed to the engine you pick here.`,children:[(0,R.jsxs)(`div`,{className:`grid gap-2 p-4 sm:grid-cols-3`,"data-testid":`image-engines`,children:[(l.data?.engines??[]).map(e=>(0,R.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/40 p-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-medium`,children:[(0,R.jsx)(Ue,{tone:e.available?`done`:`idle`}),` `,e.label,g?.engine===e.id&&(0,R.jsx)(`span`,{className:`ml-auto rounded-full bg-primary/12 px-1.5 text-3xs text-primary`,children:`active`})]}),(0,R.jsx)(`div`,{className:`mt-1 text-2xs text-muted-foreground`,children:e.reason??(e.available?`Ready`:`Unavailable`)}),(0,R.jsx)(`div`,{className:`mt-1 font-mono text-3xs text-muted-foreground/80`,children:e.defaultModel})]},e.id)),l.isLoading&&(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Checking engines…`})]}),(0,R.jsx)(E,{label:`Engine`,help:g?g.engine?`Agents use ${l.data?.engines.find(e=>e.id===g.engine)?.label??g.engine}.`:g.reason??`No engine is available, so the tool is hidden from agents.`:`Auto uses Codex when it's signed in. None hides the tool from agents.`,children:(0,R.jsx)(Mt,{label:`Global image engine`,value:a.engine,onChange:e=>e!==`inherit`&&i({imageGeneration:{engine:e}})})}),(0,R.jsx)(E,{label:`Default size`,children:(0,R.jsx)(O,{value:a.defaultSize,onChange:e=>i({imageGeneration:{defaultSize:e}}),options:[{value:`1024x1024`,label:`Square`},{value:`1536x1024`,label:`Landscape`},{value:`1024x1536`,label:`Portrait`}]})}),(0,R.jsx)(E,{label:`Quality`,children:(0,R.jsx)(O,{value:a.quality,onChange:e=>i({imageGeneration:{quality:e}}),options:[{value:`auto`,label:`Auto`},{value:`low`,label:`Low`},{value:`medium`,label:`Medium`},{value:`high`,label:`High`}]})}),(0,R.jsx)(E,{label:`Daily cap`,help:l.data?`${l.data.usage.total} generated today · 0 turns generation off.`:`Maximum images per day across all agents. 0 turns generation off.`,children:(0,R.jsx)(_,{min:0,"aria-label":`Daily image cap`,value:a.dailyCap,onChange:e=>i({imageGeneration:{dailyCap:e}}),wrapperClassName:`w-24`,className:`h-8 text-xs`})}),(0,R.jsx)(E,{label:`Gemini API key`,help:`For Gemini image models. Stored in the OS keychain.`,children:(0,R.jsx)(V,{secret:`gemini.apiKey`,label:`Gemini key`,onChange:u})}),(0,R.jsx)(E,{label:`OpenAI API key`,help:`For OpenAI Images (also used for OpenAI dictation).`,children:(0,R.jsx)(V,{secret:`openai.apiKey`,label:`OpenAI key`,onChange:u})}),(0,R.jsx)(E,{label:`Test the active engine`,help:`Generates one small image. It counts toward today's cap.`,stacked:!0,children:(0,R.jsx)(Nt,{result:d,pending:p.isPending,onTest:()=>p.mutate()})})]}),(0,R.jsxs)(D,{title:`Per-project override`,description:`A project can use its own engine and cap; unset fields follow the global settings.`,children:[(0,R.jsx)(E,{label:`Project`,children:(0,R.jsxs)(I,{value:s||`none`,onValueChange:e=>c(e===`none`?``:e),children:[(0,R.jsx)(N,{size:`sm`,className:`w-48`,"aria-label":`Override project`,children:(0,R.jsx)(M,{})}),(0,R.jsxs)(P,{children:[(0,R.jsx)(F,{value:`none`,children:`Choose a project`}),o.map(e=>(0,R.jsx)(F,{value:e.id,children:e.name},e.id))]})]})}),s&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(E,{label:`Engine for this project`,children:(0,R.jsx)(Mt,{label:`Project image engine`,inherit:!0,value:m?.engine??`inherit`,onChange:e=>void h({engine:e===`inherit`?void 0:e})})}),(0,R.jsx)(E,{label:`Project daily cap`,help:l.data?`Effective cap: ${l.data.dailyCap} · ${l.data.usage.byProject[s]??0} today`:void 0,children:(0,R.jsx)(_,{optional:!0,min:0,"aria-label":`Project daily cap`,placeholder:`global`,value:m?.dailyCap,onChange:e=>void h({dailyCap:e??void 0}),wrapperClassName:`w-24`,className:`h-8 text-xs`})}),(0,R.jsx)(E,{label:`Remove the override`,children:(0,R.jsx)(x,{size:`sm`,variant:`outline`,disabled:!m,onClick:()=>void h(null),children:`Use global settings`})})]})]})]})}var Lt=[{id:`needs_you`,label:`Needs you`,help:`PRs only a person can merge, factory decisions it flagged for you, conflicts, budget alerts.`},{id:`failure`,label:`Failures`,help:`Your sessions' failed runs, a paused factory loop, a regression, a worktree that couldn't be removed.`},{id:`factory`,label:`Factory activity`,help:`What the factory handles itself: its decisions, the PRs it reviews and merges, its sessions' failures, the daily digest.`},{id:`automation`,label:`Automations`,help:`Automation results and triage decisions.`}];function Rt(){let{settings:e,update:t}=T(),[n,r]=(0,z.useState)(l.notificationPermission()),i=e.notifications.categories;return(0,R.jsxs)(D,{title:`Notifications`,description:`How CodeDen tells you something is waiting.`,children:[(0,R.jsx)(E,{label:`Toasts`,help:`In-app toasts for new inbox items in the categories below. Several at once become one toast.`,children:(0,R.jsx)(u,{checked:e.notifications.toasts,onCheckedChange:e=>t({notifications:{toasts:e}})})}),(0,R.jsx)(E,{label:`Notify me about`,help:`For toasts and desktop notifications. Approvals and questions always notify; everything still lands in the inbox.`,stacked:!0,children:(0,R.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:Lt.map(e=>(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-lg border border-border px-3 py-2.5`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`text-[13px] font-medium`,children:e.label}),(0,R.jsx)(`div`,{className:`mt-0.5 text-2xs leading-relaxed text-muted-foreground`,children:e.help})]}),(0,R.jsx)(u,{"aria-label":e.label,checked:i[e.id],onCheckedChange:n=>t({notifications:{categories:{...i,[e.id]:n}}})})]},e.id))})}),(0,R.jsx)(E,{label:`Sound when an agent needs you`,help:`A short chime when an approval or a question arrives, even in the background.`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(x,{size:`sm`,variant:`outline`,onClick:()=>{it.unlock(),it.play()},children:[(0,R.jsx)(be,{}),` Test`]}),(0,R.jsx)(u,{"aria-label":`Sound when an agent needs you`,checked:e.notifications.sound,onCheckedChange:e=>t({notifications:{sound:e}})})]})}),(0,R.jsx)(E,{label:l.capabilities.osIntegration?`System notifications`:`Browser notifications`,help:n===`denied`?`Blocked in your browser settings.`:l.capabilities.osIntegration?`Shown when the CodeDen window isn't focused.`:`Shown when the CodeDen tab isn't focused.`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n!==`granted`&&n!==`unsupported`&&(0,R.jsxs)(x,{size:`sm`,variant:`outline`,onClick:async()=>r(await l.requestNotificationPermission()),children:[(0,R.jsx)(m,{}),` Allow`]}),(0,R.jsx)(u,{checked:e.notifications.browser,disabled:n===`unsupported`,onCheckedChange:e=>t({notifications:{browser:e}})})]})}),(0,R.jsx)(E,{label:`Send a test notification`,children:(0,R.jsx)(x,{size:`sm`,variant:`outline`,onClick:()=>{b(`Approval needed`,{description:`Force push to codeden/fix-checkout-flake`}),l.notify(`Approval needed`,{body:`Force push to codeden/fix-checkout-flake`})},children:`Test`})})]})}var H=(e=>(e[e.Border=-1]=`Border`,e[e.Data=0]=`Data`,e[e.Function=1]=`Function`,e[e.Position=2]=`Position`,e[e.Timing=3]=`Timing`,e[e.Alignment=4]=`Alignment`,e))(H||{}),zt=[0,1],Bt=[1,0],Vt=[2,3],Ht=[3,2],Ut={L:zt,M:Bt,Q:Vt,H:Ht},Wt=/^\d*$/,Gt=/^[A-Z0-9 $%*+./:-]*$/,U=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,W=1,G=40,Kt=3,qt=3,K=40,Jt=10,Yt=[[-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]],Xt=[[-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]],Zt=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,e<W||e>G)throw RangeError(`Version value out of range`);if(r<-1||r>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let i=Array.from({length:this.size}).fill(!1);for(let e=0;e<this.size;e++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let a=this.addEccAndInterleave(n);if(this.drawCodewords(a),r===-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}size;mask;modules=[];types=[];getModule(e,t){return e>=0&&e<this.size&&t>=0&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0,H.Timing),this.setFunctionModule(e,6,e%2==0,H.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n===0&&r===0||n===0&&r===t-1||n===t-1&&r===0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.ecc[1]<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;for(let e=0;e<=5;e++)this.setFunctionModule(8,e,J(r,e));this.setFunctionModule(8,7,J(r,6)),this.setFunctionModule(8,8,J(r,7)),this.setFunctionModule(7,8,J(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,J(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,J(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,J(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let e=0;e<18;e++){let n=J(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;a>=0&&a<this.size&&o>=0&&o<this.size&&this.setFunctionModule(a,o,i!==2&&i!==4,H.Position)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1,H.Alignment)}setFunctionModule(e,t,n,r=H.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==Z(t,n))throw RangeError(`Invalid argument`);let r=Xt[n[0]][t],i=Yt[n[0]][t],a=Math.floor(X(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=dn(i);for(let t=0,n=0;t<r;t++){let r=e.slice(n,n+s-i+(t<o?0:1));n+=r.length;let a=fn(r,l);t<o&&r.push(0),c.push(r.concat(a))}let u=[];for(let e=0;e<c[0].length;e++)c.forEach((t,n)=>{(e!==s-i||n>=o)&&u.push(t[e])});return u}drawCodewords(e){if(e.length!==Math.floor(X(this.version)/8))throw RangeError(`Invalid argument`);let t=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=n-i,o=n+1&2?r:this.size-1-r;!this.types[o][a]&&t<e.length*8&&(this.modules[o][a]=J(e[t>>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.types[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[t][a]===n?(r++,r===5?e+=Kt:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*K),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*K}for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][t]===n?(r++,r===5?e+=Kt:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*K),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*K}for(let t=0;t<this.size-1;t++)for(let n=0;n<this.size-1;n++){let r=this.modules[t][n];r===this.modules[t][n+1]&&r===this.modules[t+1][n]&&r===this.modules[t+1][n+1]&&(e+=qt)}let t=0;for(let e of this.modules)t=e.reduce((e,t)=>e+ +!!t,t);let n=this.size*this.size,r=Math.ceil(Math.abs(t*20-n*10)/n)-1;return e+=r*Jt,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(e){let t=e[1],n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function q(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function J(e,t){return!!(e>>>t&1)}var Y=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}},Qt=[1,10,12,14],$t=[2,9,11,13],en=[4,8,16,16];function tn(e,t){return e[Math.floor((t+7)/17)+1]}function nn(e){let t=[];for(let n of e)q(n,8,t);return new Y(en,e.length,t)}function rn(e){if(!sn(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let n=0;n<e.length;){let r=Math.min(e.length-n,3);q(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new Y(Qt,e.length,t)}function an(e){if(!cn(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n=0;for(;n+2<=e.length;n+=2){let r=U.indexOf(e.charAt(n))*45;r+=U.indexOf(e.charAt(n+1)),q(r,11,t)}return n<e.length&&q(U.indexOf(e.charAt(n)),6,t),new Y($t,e.length,t)}function on(e){return e===``?[]:sn(e)?[rn(e)]:cn(e)?[an(e)]:[nn(un(e))]}function sn(e){return Wt.test(e)}function cn(e){return Gt.test(e)}function ln(e,t){let n=0;for(let r of e){let e=tn(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function un(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)===`%`?(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}function X(e){if(e<W||e>G)throw RangeError(`Version number out of range`);let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function Z(e,t){return Math.floor(X(e)/8)-Yt[t[0]][e]*Xt[t[0]][e]}function dn(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let t=[];for(let n=0;n<e-1;n++)t.push(0);t.push(1);let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=Q(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=Q(n,2)}return t}function fn(e,t){let n=t.map(e=>0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=Q(t,e))}return n}function Q(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function pn(e,t,n=1,r=40,i=-1,a=!0){if(!(W<=n&&n<=r&&r<=G)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=Z(o,t)*8,i=ln(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[Bt,Vt,Ht])a&&s<=Z(o,e)*8&&(t=e);let c=[];for(let t of e){q(t.mode[0],4,c),q(t.numChars,tn(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=Z(o,t)*8;q(0,Math.min(4,l-c.length),c),q(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)q(e,8,c);let u=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((e,t)=>u[t>>>3]|=e<<7-(t&7)),new Zt(o,t,u,i)}function mn(e,t){let{ecc:n=`L`,boostEcc:r=!1,minVersion:i=1,maxVersion:a=40,maskPattern:o=-1,border:s=1}=t||{},c=typeof e==`string`?on(e):Array.isArray(e)?[nn(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=pn(c,Ut[n],i,a,o,r),u=hn({version:l.version,maskPattern:l.mask,size:l.size,data:l.modules,types:l.types},s);return t?.invert&&(u.data=u.data.map(e=>e.map(e=>!e))),t?.onEncoded?.(u),u}function hn(e,t=1){if(!t)return e;let{size:n}=e,r=n+t*2;e.size=r,e.data.forEach(e=>{for(let n=0;n<t;n++)e.unshift(!1),e.push(!1)});for(let n=0;n<t;n++)e.data.unshift(Array.from({length:r},e=>!1)),e.data.push(Array.from({length:r},e=>!1));let i=H.Border;e.types.forEach(e=>{for(let n=0;n<t;n++)e.unshift(i),e.push(i)});for(let n=0;n<t;n++)e.types.unshift(Array.from({length:r},e=>i)),e.types.push(Array.from({length:r},e=>i));return e}function gn(e){let{data:t,size:n}=mn(e,{ecc:`M`,border:2}),r=``;for(let e=0;e<n;e++)for(let i=0;i<n;i++)t[e]?.[i]&&(r+=`M${i} ${e}h1v1h-1z`);return{d:r,size:n}}function _n({value:e,label:t,className:n}){let{d:r,size:i}=(0,z.useMemo)(()=>gn(e),[e]);return(0,R.jsx)(`svg`,{viewBox:`0 0 ${i} ${i}`,role:`img`,"aria-label":t,shapeRendering:`crispEdges`,className:w(`rounded-md bg-white`,n),"data-testid":`qr-code`,"data-value":e,children:(0,R.jsx)(`path`,{d:r,fill:`#000`})})}var vn=[`network`];function yn({value:e,onDone:t}){let[n,r]=(0,z.useState)(!1);return(0,R.jsxs)(`div`,{className:`rounded-lg border border-primary/30 bg-primary/[0.06] p-3`,"data-testid":`generated-password`,children:[(0,R.jsx)(`div`,{className:`text-2xs font-medium text-primary`,children:`Your new password (shown once)`}),(0,R.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`code`,{className:`min-w-0 flex-1 font-mono text-[15px] break-all select-all`,children:e}),(0,R.jsxs)(x,{size:`sm`,variant:`outline`,onClick:()=>void s(e,`Password copied`).then(e=>r(e)),children:[n?(0,R.jsx)(_e,{}):(0,R.jsx)(ne,{}),` `,n?`Copied`:`Copy`]})]}),(0,R.jsxs)(`p`,{className:`mt-2 text-2xs text-muted-foreground`,children:[`Save it in your password manager now: CodeDen keeps only a scrambled copy and can't show it again.`,` `,(0,R.jsx)(`button`,{type:`button`,className:`underline underline-offset-2`,onClick:t,children:`I've saved it`})]})]})}function bn({passwordSet:e}){let t=r(),i=A(),[a,o]=(0,z.useState)(``),[s,c]=(0,z.useState)(null),l=a?n(a):null,u=C({mutationFn:e=>t.network.setPassword(e),onSuccess:t=>{i.setQueryData(vn,t.status),o(``),c(t.generated),b.success(e?`Password changed, every device signed out`:`Password set`)},onError:e=>b.error(`Password not saved`,{description:e.message})});function d(e){e.preventDefault(),a&&!l&&u.mutate({password:a})}return(0,R.jsxs)(`div`,{className:`space-y-3`,children:[s&&(0,R.jsx)(yn,{value:s,onDone:()=>c(null)}),(0,R.jsxs)(`form`,{onSubmit:d,className:`flex flex-col gap-2 sm:flex-row`,children:[(0,R.jsx)(k,{type:`password`,autoComplete:`new-password`,placeholder:e?`New password`:`Choose a password`,value:a,onChange:e=>o(e.target.value),"aria-label":`Network access password`,"aria-invalid":l?!0:void 0,className:`sm:flex-1`,"data-testid":`network-password-input`}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsxs)(x,{type:`submit`,className:`flex-1 sm:flex-none`,disabled:!a||!!l||u.isPending,children:[(0,R.jsx)(te,{}),` `,e?`Change`:`Set password`]}),(0,R.jsxs)(x,{type:`button`,variant:`outline`,className:`flex-1 sm:flex-none`,disabled:u.isPending,onClick:()=>u.mutate({generate:!0}),children:[(0,R.jsx)(ae,{}),` Generate`]})]})]}),(0,R.jsxs)(`p`,{className:l?`text-2xs text-destructive`:`text-2xs text-muted-foreground`,role:l?`alert`:void 0,children:[l??`Use at least 15 characters. A short sentence or a few random words works well. Very common passwords, repeated characters and simple sequences such as abcdef… or 12345… are refused.`,!l&&e&&` Changing it signs out every phone and tablet.`]})]})}var xn={local:`This computer`,lan:`Local network`,vpn:`VPN`};function Sn(e){let t=e.toLowerCase(),n=t.includes(`iphone`)?`iPhone`:t.includes(`ipad`)?`iPad`:t.includes(`android`)?t.includes(`mobile`)?`Android phone`:`Android tablet`:t.includes(`mac os`)?`Mac`:t.includes(`windows`)?`Windows`:t.includes(`linux`)?`Linux`:`Device`,r=t.includes(`edg/`)?`Edge`:t.includes(`firefox`)||t.includes(`fxios`)?`Firefox`:t.includes(`chrome`)||t.includes(`crios`)?`Chrome`:t.includes(`safari`)?`Safari`:null;return r?`${n} · ${r}`:n}function Cn({address:e,live:t}){let n=e.kind!==`local`;return(0,R.jsxs)(`div`,{className:w(`flex items-center gap-4 px-4 py-3.5`,!t&&`opacity-60`),"data-testid":`network-address`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-[13.5px] font-medium`,children:e.label}),e.kind!==`local`&&(0,R.jsx)(`span`,{className:`rounded border border-border px-1.5 py-px text-3xs text-muted-foreground`,children:xn[e.kind]})]}),(0,R.jsxs)(`button`,{type:`button`,className:`mt-1 flex max-w-full items-center gap-1.5 font-mono text-[12.5px] text-muted-foreground hover:text-foreground pointer-coarse:min-h-10`,onClick:()=>void s(e.url,`Address copied`),title:`Copy address`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.url}),(0,R.jsx)(ne,{className:`size-3 shrink-0`})]}),e.kind===`local`&&(0,R.jsx)(`p`,{className:`mt-1 text-2xs text-muted-foreground`,children:`Only works on this computer.`})]}),n&&(0,R.jsx)(_n,{value:e.url,label:`QR code for ${e.url}`,className:`size-28 shrink-0 p-1 sm:size-32`})]})}function wn({device:e,onSignOut:t,pending:n}){let r=/iphone|ipad|android/i.test(e.label)?he:Ce;return(0,R.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,"data-testid":`network-device`,children:[(0,R.jsx)(r,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`truncate text-[13.5px] font-medium`,title:e.label,children:[Sn(e.label),e.current&&(0,R.jsx)(`span`,{className:`ml-2 text-2xs text-primary`,children:`This device`})]}),(0,R.jsxs)(`div`,{className:`truncate text-2xs text-muted-foreground`,children:[e.address??`Unknown address`,` · seen `,S(e.lastSeenAt),` · signed in`,` `,S(e.createdAt)]})]}),(0,R.jsxs)(x,{size:`sm`,variant:`outline`,onClick:t,disabled:n,children:[(0,R.jsx)(ie,{}),` Sign out`]})]})}function Tn(){let e=r(),t=A(),{data:n,error:i}=j({queryKey:vn,queryFn:()=>e.network.status(),refetchInterval:15e3}),a=e=>t.setQueryData(vn,e),o=C({mutationFn:t=>e.network.setEnabled(t),onSuccess:e=>{a(e),b.success(e.enabled?`Network access is on`:`Network access is off`)},onError:e=>b.error(`Network access not changed`,{description:e.message})}),s=C({mutationFn:t=>t?e.network.signOutDevice(t):e.network.signOutAll(),onSuccess:a,onError:e=>b.error(`Not signed out`,{description:e.message})});if(i)return(0,R.jsx)(D,{title:`Network access`,children:(0,R.jsx)(`p`,{className:`p-4 text-[13px] text-muted-foreground`,children:`This CodeDen server doesn't offer network access yet. Update CodeDen to use it.`})});if(!n)return null;let c=n.remote,l=n.enabled?n.addresses:n.candidates;return(0,R.jsxs)(`div`,{"data-testid":`network-settings`,children:[(0,R.jsxs)(D,{title:`Network access`,description:`Open CodeDen from your phone or tablet on the same Wi-Fi, or from anywhere over your own VPN such as Tailscale. Off by default.`,children:[(0,R.jsx)(E,{label:`Allow network access`,help:c?`Change this on the computer running CodeDen.`:n.enabled?`Devices on your network can open CodeDen after signing in with the password.`:n.passwordSet?`CodeDen only answers on this computer (127.0.0.1).`:`Set a password below first.`,children:(0,R.jsx)(u,{"aria-label":`Allow network access`,"data-testid":`network-toggle`,checked:n.enabled,disabled:c||!n.passwordSet||o.isPending,onCheckedChange:e=>o.mutate(e)})}),!c&&(0,R.jsx)(E,{label:`Password`,stacked:!0,help:n.passwordSetAt?`Set ${S(n.passwordSetAt)}. Phones and tablets sign in with it once.`:`Phones and tablets sign in with it once. CodeDen stores only a scrambled copy.`,children:(0,R.jsx)(bn,{passwordSet:n.passwordSet})})]}),(0,R.jsxs)(D,{title:`Addresses`,description:n.enabled?`Scan a code with your phone's camera, or type the address into its browser.`:`Where CodeDen will answer once network access is on.`,children:[l.map(e=>(0,R.jsx)(Cn,{address:e,live:n.enabled||e.kind===`local`},e.url)),n.candidates.length===1&&(0,R.jsxs)(`p`,{className:`flex items-center gap-2 px-4 py-3 text-2xs text-muted-foreground`,children:[(0,R.jsx)(de,{className:`size-3.5`}),` This computer isn't on a network right now.`]}),(0,R.jsx)(`p`,{className:`px-4 py-3 text-2xs leading-relaxed text-muted-foreground`,children:`Away from home, use your own VPN (Tailscale, WireGuard): its address shows up here and needs nothing else. These are plain http addresses, so phones won't allow notifications or the microphone on them. Tip: open CodeDen on your phone and use Add to Home Screen.`})]}),(0,R.jsx)(D,{title:`Signed-in devices`,description:`Each device stays signed in for 90 days, or until you sign it out.`,children:n.devices.length===0?(0,R.jsx)(`p`,{className:`px-4 py-3.5 text-[13px] text-muted-foreground`,children:`No devices signed in.`}):(0,R.jsxs)(R.Fragment,{children:[n.devices.map(e=>(0,R.jsx)(wn,{device:e,pending:s.isPending,onSignOut:()=>s.mutate(e.id)},e.id)),(0,R.jsx)(`div`,{className:`flex justify-end px-4 py-3`,children:(0,R.jsxs)(x,{size:`sm`,variant:`destructive`,onClick:()=>s.mutate(null),disabled:s.isPending,children:[(0,R.jsx)(ie,{}),` Sign out all`]})})]})})]})}function En(){let{settings:e,update:t}=T(),n=e.voice.dictation,r=ct(),i=r.data?.models.find(e=>e.id===n.local.model);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(E,{label:`Whisper model`,help:r.error?`Couldn't read the local engine: ${r.error.message}`:`Models are downloaded once into ${r.data?.location??`the CodeDen folder`} and run on this machine.`,stacked:!0,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsx)(lt,{status:r.data,value:n.local.model,onChange:e=>t({voice:{dictation:{local:{model:e}}}})}),(0,R.jsx)(ut,{status:r.data,modelId:n.local.model})]})}),(0,R.jsx)(E,{label:`Try it`,help:`Say a sentence after pressing Test.`,stacked:!0,children:(0,R.jsx)(dt,{disabled:i?.state!==`installed`,language:n.language})})]})}function Dn(e){if([`Control`,`Shift`,`Alt`,`Meta`].includes(e.key))return null;let t=[];(e.ctrlKey||e.metaKey)&&t.push(`mod`),e.altKey&&t.push(`alt`),e.shiftKey&&t.push(`shift`);let n=e.key===` `?`space`:(e.key.length,e.key.toLowerCase());return t.push(n),t.join(`+`)}function On({value:e,onChange:t}){let[n,r]=(0,z.useState)(!1),i=n===`keys`?`Press keys…`:n===`needsModifier`?`Add ${v(`mod`)} or ${v(`alt`)}…`:e?v(e):`Not set`;return(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(x,{size:`sm`,variant:`outline`,"aria-label":`Push-to-talk shortcut`,className:`min-w-36 font-mono text-xs`,onClick:()=>r(`keys`),onBlur:()=>r(!1),onKeyDown:e=>{if(!n)return;if(e.preventDefault(),e.key===`Escape`)return r(!1);let i=Dn(e);if(i){if(!Ne(i))return r(`needsModifier`);t(i),r(!1)}},children:[(0,R.jsx)(ye,{}),` `,i]}),e&&(0,R.jsx)(x,{size:`icon-sm`,variant:`ghost`,"aria-label":`Clear push-to-talk`,onClick:()=>t(null),children:(0,R.jsx)(ge,{})})]})}function kn(){let{settings:e,update:t}=T(),n=e.voice.readAloud.quietHours,r=e=>n&&t({voice:{readAloud:{quietHours:{...n,...e}}}});return(0,R.jsx)(E,{label:`Quiet hours`,help:`Nothing is spoken in this window.`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(u,{"aria-label":`Quiet hours`,checked:n!==null,onCheckedChange:e=>t({voice:{readAloud:{quietHours:e?{start:`22:00`,end:`07:00`}:null}}})}),(0,R.jsx)(k,{type:`time`,"aria-label":`Quiet hours start`,disabled:!n,value:n?.start??`22:00`,onChange:e=>r({start:e.target.value}),className:`h-8 w-24 text-xs`}),(0,R.jsx)(`span`,{className:`text-2xs text-muted-foreground`,children:`to`}),(0,R.jsx)(k,{type:`time`,"aria-label":`Quiet hours end`,disabled:!n,value:n?.end??`07:00`,onChange:e=>r({end:e.target.value}),className:`h-8 w-24 text-xs`})]})})}var An=[`auto`,`en-US`,`en-GB`,`en-ZA`,`de-DE`,`fr-FR`,`es-ES`,`nl-NL`];function jn(){let[e,t]=(0,z.useState)(()=>L.voices());return(0,z.useEffect)(()=>{if(typeof window>`u`||!window.speechSynthesis)return;let e=()=>t(L.voices());return window.speechSynthesis.addEventListener(`voiceschanged`,e),e(),()=>window.speechSynthesis.removeEventListener(`voiceschanged`,e)},[]),e}function Mn(){let e=r(),{settings:n,update:i}=T(),a=n.voice,o=jn(),s=Ft(),c=e=>s.data?.keys.some(t=>t.key===e&&t.set)??!1,l=a.readAloud.engine===`elevenlabs`,d=j({queryKey:[`eleven-voices`,c(`elevenlabs.apiKey`)],queryFn:()=>e.voice.voices(),enabled:l&&c(`elevenlabs.apiKey`),retry:!1}),f=l?(d.data?.voices??[]).map(e=>({id:e.id,label:e.name})):o.map(e=>({id:e.id,label:`${e.label} (${e.lang})`})),p=C({mutationFn:async()=>at.playNow({key:`test-${Date.now()}`,play:()=>tt(e,n,`The checkout flake is fixed and verified with fifty green runs.`).catch(e=>{b.error(`Couldn't play the voice`,{description:e.message})})})}),m=a.dictation.engine===`openai`?`openai.apiKey`:`elevenlabs.apiKey`,h=st()===`available`;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(D,{title:`Dictation`,description:`Speech to text in the composer. Toggle with ${v(Ae(`dictate`).combo)}, or hold a push-to-talk shortcut.`,children:[(0,R.jsx)(E,{label:`Engine`,help:a.dictation.engine===`browser`?h?`The browser engine works in Chrome and Edge.`:(0,R.jsxs)(`span`,{"data-testid":`browser-stt-unavailable`,children:[`Speech recognition isn't available here.`,` `,(0,R.jsx)(`button`,{type:`button`,className:`text-foreground underline underline-offset-2`,onClick:()=>i({voice:{dictation:{engine:`local`}}}),children:`Use Local (Whisper)`}),`, which runs on this machine, or a cloud engine.`]}):a.dictation.engine===`local`?`Runs Whisper on this machine through the CodeDen server; audio never leaves it.`:c(m)?`Transcribes each phrase through the CodeDen server as you pause, so text appears while you speak.`:`Add the ${a.dictation.engine===`openai`?`OpenAI`:`ElevenLabs`} key below to use this engine.`,children:(0,R.jsx)(O,{value:a.dictation.engine,onChange:e=>{e===`browser`&&ot(),i({voice:{dictation:{engine:e}}})},options:[{value:`browser`,label:h||a.dictation.engine===`browser`?`Browser`:`Browser (unavailable)`},{value:`local`,label:`Local (Whisper)`},{value:`elevenlabs`,label:`ElevenLabs`},{value:`openai`,label:`OpenAI`}]})}),a.dictation.engine===`local`&&(0,R.jsx)(En,{}),(0,R.jsx)(E,{label:`Language`,help:a.dictation.engine===`browser`?`Leave on auto to follow the browser language.`:`Auto detects the spoken language. English-only Whisper models always use English.`,children:(0,R.jsxs)(I,{value:a.dictation.language??`auto`,onValueChange:e=>i({voice:{dictation:{language:e===`auto`?null:e}}}),children:[(0,R.jsx)(N,{size:`sm`,className:`w-40`,"aria-label":`Dictation language`,children:(0,R.jsx)(M,{})}),(0,R.jsx)(P,{children:An.map(e=>(0,R.jsx)(F,{value:e,children:e===`auto`?`Auto`:e},e))})]})}),(0,R.jsx)(E,{label:`Push-to-talk`,help:`Hold to dictate, release to stop. Click, then press a key with ${v(`mod`)} or ${v(`alt`)} (or an F key).`,children:(0,R.jsx)(On,{value:a.dictation.pushToTalkShortcut,onChange:e=>i({voice:{dictation:{pushToTalkShortcut:e}}})})}),a.dictation.engine===`openai`&&(0,R.jsx)(E,{label:`OpenAI API key`,help:`Shared with OpenAI Images. Stored in the OS keychain.`,children:(0,R.jsx)(V,{secret:`openai.apiKey`,label:`OpenAI key`})})]}),(0,R.jsxs)(D,{title:`Read aloud`,description:`Speaks an agent's final message when any session finishes a turn, with code and markdown stripped.`,children:[(0,R.jsx)(E,{label:`Read final messages aloud`,help:`Messages play one after another; switching this off stops the current one. Mute single sessions from their Details tab.`,children:(0,R.jsx)(u,{"aria-label":`Read final messages aloud`,checked:a.readAloud.enabled,onCheckedChange:e=>{e||at.clear(),i({voice:{readAloud:{enabled:e}}})}})}),(0,R.jsx)(E,{label:`What to read`,help:a.readAloud.content===`summary`?`A one or two sentence TL;DR from the utility model: what was done and whether it needs you.`:`The whole final message, up to ${t.toLocaleString(`en-US`)} characters (about five minutes).`,children:(0,R.jsx)(O,{value:a.readAloud.content,onChange:e=>i({voice:{readAloud:{content:e}}}),options:[{value:`summary`,label:`TL;DR`},{value:`full`,label:`Full message`}]})}),(0,R.jsx)(E,{label:`Say who's speaking`,help:`Starts each message with who it's from, such as the project manager or a session's title.`,children:(0,R.jsx)(u,{"aria-label":`Say who's speaking`,checked:a.readAloud.announceSpeaker,onCheckedChange:e=>i({voice:{readAloud:{announceSpeaker:e}}})})}),(0,R.jsx)(E,{label:`Engine`,children:(0,R.jsx)(O,{value:a.readAloud.engine,onChange:e=>i({voice:{readAloud:{engine:e,voice:null}}}),options:[{value:`browser`,label:`Browser (free)`},{value:`elevenlabs`,label:`ElevenLabs`}]})}),(0,R.jsx)(E,{label:`Voice`,help:l&&!c(`elevenlabs.apiKey`)?`Add your ElevenLabs key below to load its voices.`:d.error?d.error.message:void 0,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(I,{value:a.readAloud.voice??`default`,onValueChange:e=>i({voice:{readAloud:{voice:e==="default"?null:e}}}),children:[(0,R.jsx)(N,{size:`sm`,className:`w-56`,"aria-label":`Read-aloud voice`,children:(0,R.jsx)(M,{})}),(0,R.jsxs)(P,{children:[(0,R.jsx)(F,{value:`default`,children:l?`Default voice`:`System default`}),f.slice(0,60).map(e=>(0,R.jsx)(F,{value:e.id,children:e.label},e.id))]})]}),(0,R.jsxs)(x,{size:`sm`,variant:`outline`,disabled:(l?!c(`elevenlabs.apiKey`):!L.supported)||p.isPending,onClick:()=>p.mutate(),children:[(0,R.jsx)(be,{}),` Test`]})]})}),(0,R.jsx)(E,{label:`Only when the tab isn't focused`,children:(0,R.jsx)(u,{"aria-label":`Only when the tab isn't focused`,checked:a.readAloud.onlyWhenUnfocused,onCheckedChange:e=>i({voice:{readAloud:{onlyWhenUnfocused:e}}})})}),(0,R.jsx)(kn,{}),(0,R.jsx)(E,{label:`ElevenLabs API key`,help:`Optional, for ElevenLabs voices and dictation. Stored in the OS keychain.`,children:(0,R.jsx)(V,{secret:`elevenlabs.apiKey`,label:`ElevenLabs key`})})]})]})}function Nn(){let e=r(),t=A(),{data:n}=Qe(),i=et(),a=C({mutationFn:()=>e.getUpdates({refresh:!0}),onSuccess:e=>t.setQueryData($e,e)});if(!n)return null;let o=n.state===`installing`||n.state===`restarting`,s;s=n.enabled?n.state===`installing`?`Installing ${n.target}...`:n.state===`restarting`?`Restarting into ${n.target}...`:n.state===`installed`?`Version ${n.target} is installed.`:n.updateAvailable?`Version ${n.latest} is available.`:n.error?`Couldn't check for updates: ${n.error}`:n.latest?`You're on the latest version.`:`Not checked yet.`:`Update checks are off (Settings > General).`;let c=n.rollbackTo?`Roll back to ${n.rollbackTo}`:`Roll back to the previous version`,l=n.updateAvailable&&nt(n)&&n.state===`idle`;return(0,R.jsxs)(`div`,{className:`mt-2 space-y-1.5 text-2xs`,"data-testid":`update-check`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:n.updateAvailable?`text-status-waiting`:`text-muted-foreground`,children:s}),(l||n.enabled)&&(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[l&&(0,R.jsx)(x,{size:`xs`,onClick:()=>i.install.mutate(),disabled:o,children:`Update now`}),n.enabled&&(0,R.jsxs)(x,{size:`xs`,variant:`ghost`,onClick:()=>a.mutate(),disabled:a.isPending,children:[(0,R.jsx)(le,{className:a.isPending?`animate-spin`:void 0}),` Check now`]})]})]}),n.source===`source`?(0,R.jsxs)(`p`,{className:`text-muted-foreground`,children:[`You're running from source: pull and rebuild to update (`,(0,R.jsx)(`code`,{className:`font-mono`,children:`git pull && pnpm install && pnpm build`}),`).`]}):n.installed.length>0&&(0,R.jsxs)(`p`,{className:`text-muted-foreground`,"data-testid":`installed-versions`,children:[`Installed:`,` `,n.installed.map(e=>`${e.version}${e.current?` (current)`:``}${e.valid?``:` (broken)`}`).join(`, `)]}),n.state===`failed`&&n.installError&&(0,R.jsxs)(`p`,{className:`text-status-failed`,children:[`Last update failed: `,n.installError]}),n.warning&&(0,R.jsx)(`p`,{className:`text-status-failed`,children:n.warning}),n.canRollback&&(0,R.jsxs)(x,{size:`xs`,variant:`outline`,disabled:o||i.rollback.isPending,onClick:()=>i.rollback.mutate(),children:[(0,R.jsx)(ve,{}),` `,c]}),i.rollback.error&&(0,R.jsx)(`p`,{className:`text-status-failed`,children:i.rollback.error.message})]})}function Pn(){let e=i(ze().data);return(0,R.jsx)(D,{title:`About`,children:(0,R.jsx)(`div`,{className:`@container`,children:(0,R.jsxs)(`div`,{className:`flex flex-col items-start gap-3 p-5 @[30rem]:flex-row @[30rem]:items-center @[30rem]:gap-4`,children:[(0,R.jsx)(c,{className:`size-10 @[30rem]:size-12`}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`text-[15px] font-semibold`,"data-testid":`version-line`,children:e}),(0,R.jsx)(`p`,{className:`mt-0.5 text-[13px] text-muted-foreground`,children:`A local-first harness for coding agents. Open source under the MIT license. No accounts, no telemetry.`}),(0,R.jsx)(Nn,{}),!1]})]})})})}var $=[{id:`general`,label:`General`,icon:Te,render:()=>(0,R.jsx)(wt,{})},{id:`providers`,label:`Providers`,icon:p,render:()=>(0,R.jsx)(Et,{})},{id:`autonomy`,label:`Autonomy`,icon:h,render:()=>(0,R.jsx)(Dt,{})},{id:`github`,label:`GitHub`,icon:fe,render:()=>(0,R.jsx)(At,{})},{id:`voice`,label:`Voice`,icon:se,render:()=>(0,R.jsx)(Mn,{})},{id:`images`,label:`Image generation`,icon:oe,render:()=>(0,R.jsx)(It,{})},{id:`utility`,label:`Utility model`,icon:g,render:()=>(0,R.jsx)(Ot,{})},{id:`notifications`,label:`Notifications`,icon:ce,render:()=>(0,R.jsx)(Rt,{})},{id:`network`,label:`Network access`,icon:he,render:()=>(0,R.jsx)(Tn,{})},...l.capabilities.osIntegration?[{id:`desktop`,label:`App`,icon:ee,render:()=>(0,R.jsx)(kt,{})}]:[],{id:`shortcuts`,label:`Keyboard shortcuts`,icon:ye,render:()=>(0,R.jsx)(rt,{})},{id:`about`,label:`About`,icon:ue,render:()=>(0,R.jsx)(Pn,{})}];function Fn({section:e}){let t=$.find(t=>t.id===e)??$[0],n=o();return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(ft,{icon:(0,R.jsx)(Te,{}),title:`Settings`,meta:t?.label}),(0,R.jsx)(`div`,{className:`shrink-0 border-b border-border px-4 py-2 md:hidden`,children:(0,R.jsx)(`select`,{"aria-label":`Settings section`,className:`h-10 w-full rounded-lg border border-border bg-background px-3 text-[13px]`,value:t?.id,onChange:e=>void n({to:`/settings/$section`,params:{section:e.target.value}}),"data-testid":`settings-section-picker`,children:$.map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.label},e.id))})}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsxs)(`nav`,{className:`hidden w-56 shrink-0 space-y-0.5 border-r border-border p-3 md:block`,children:[$.map(e=>(0,R.jsxs)(a,{to:`/settings/$section`,params:{section:e.id},className:w(`flex h-8 items-center gap-2.5 rounded-md px-2.5 text-[13px] text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground pointer-coarse:h-10`,e.id===t?.id&&`bg-accent text-foreground`),children:[(0,R.jsx)(e.icon,{className:w(`size-4`,e.id===t?.id&&`text-primary`)}),e.label]},e.id)),(0,R.jsx)(`div`,{className:`my-2 h-px bg-border`}),(0,R.jsxs)(a,{to:`/agents`,className:`flex h-8 items-center gap-2.5 rounded-md px-2.5 text-[13px] text-muted-foreground hover:bg-accent/60 hover:text-foreground`,children:[(0,R.jsx)(d,{className:`size-4`}),` Agent configuration`]}),(0,R.jsxs)(a,{to:`/setup`,className:`flex h-8 items-center gap-2.5 rounded-md px-2.5 text-[13px] text-muted-foreground hover:bg-accent/60 hover:text-foreground`,children:[(0,R.jsx)(ae,{className:`size-4`}),` First-run setup`]})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto scroll-thin`,children:(0,R.jsx)(`div`,{className:`mx-auto w-full max-w-3xl px-4 py-6 sm:px-8 sm:py-8`,children:t?.render()})})]})]})}export{Fn as SettingsPage};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{H as t,O as n,i as r,k as i}from"./api-yvn34iKU.js";import{L as a}from"./dropdown-menu-Bflkx6wY.js";import{d as o,i as s,n as c,o as l,t as u}from"./switch-BHplnCdo.js";import{A as d,Bn as f,Cr as p,Er as m,F as h,Gn as g,Ir as ee,Jt as te,Kn as ne,Lt as re,Nt as ie,O as ae,Qt as oe,St as se,Tr as ce,X as le,Yt as ue,a as de,cn as fe,h as pe,ir as me,k as he,n as ge,pr as _e,q as ve,qt as ye,s as be,sr as xe,tt as Se,vt as Ce,wn as we,z as Te,zn as Ee}from"./icons-COCLuOtb.js";import{a as De}from"./bits-B2GRjm37.js";import{t as _}from"./number-field-Bzzs0k9i.js";import{n as Oe}from"./footer-BFGvnowz.js";import{c as ke,d as v,h as Ae,n as je,o as Me,p as Ne,r as Pe,s as Fe,t as Ie}from"./model-picker-DnKv2cbc.js";import{t as Le}from"./kill-switch-BDAFCjui.js";import{t as Re}from"./autonomy-Bx33JDEO.js";import{D as y,E as ze,j as b,m as x,n as S,yt as C}from"./format-D3kairnQ.js";import{t as w}from"./dist-wxbqfqV1.js";import{i as Be}from"./theme-3eeE0sp4.js";import{t as Ve}from"./skeleton-D8Sbd2jT.js";import{E as He,O as Ue}from"./mobile-nav-CrjrDJZ5.js";import{i as T,n as E,r as D,t as O}from"./settings-ui-Bc6ymtc_.js";import{n as We,t as Ge}from"./jsx-runtime-C3cWAN_r.js";import{t as k}from"./input-CPpbtC2H.js";import{F as A,t as j}from"./useQuery-VSotSwry.js";import{a as Ke,c as qe,i as Je,n as Ye,r as Xe,t as Ze}from"./dialog-Cvj_lHPY.js";import{a as M,i as N,n as P,r as F,t as I}from"./select-B1ES0hhy.js";import{c as Qe,i as $e,s as et}from"./updates-4l7pwDq1.js";import{l as tt,n as nt,r as rt,s as it,u as at}from"./update-banner-CZGRgiG8.js";import{i as L,n as ot,t as st}from"./engines-pLQJYIu_.js";import{i as ct,n as lt,r as ut,t as dt}from"./local-whisper-test-CqGlAOvK.js";import{t as ft}from"./page-header-t9HzSrxd.js";var R=Ge();function pt(){let e=ze().data?.projects,{setAgentCiEnv:t}=He();return(0,R.jsx)(D,{title:`Agent environment`,description:`Agent sessions run with CI=true, so installs and other commands never stop at a prompt nobody can answer. Your project's tools then act as they do in CI: Playwright won't reuse a running dev server, fails on test.only and retries failing tests; Yarn won't update the lockfile; Create React App fails the build on warnings. Turn it off for a project whose tools get in the way. Applies to agent sessions opened after the change; your terminals never get it.`,children:e===void 0?(0,R.jsx)(`div`,{className:`px-4 py-3.5`,role:`status`,"aria-label":`Loading projects`,children:(0,R.jsx)(Ve,{className:`h-4 w-1/3`})}):e.length===0?(0,R.jsx)(`p`,{className:`px-4 py-3.5 text-2xs text-muted-foreground`,children:`Add a project to choose this per project.`}):e.map(e=>(0,R.jsx)(E,{label:e.name,help:e.agentCiEnv?`Agent sessions run with CI=true.`:(0,R.jsxs)(R.Fragment,{children:[`Agent sessions run without CI. pnpm may then stop to ask before reinstalling`,` `,(0,R.jsx)(`code`,{children:`node_modules`}),`: set `,(0,R.jsx)(`code`,{children:`confirmModulesPurge: false`}),` in the project's `,(0,R.jsx)(`code`,{children:`pnpm-workspace.yaml`}),`.`]}),children:(0,R.jsx)(u,{"aria-label":`Run ${e.name}'s agent sessions with CI=true`,checked:e.agentCiEnv,onCheckedChange:n=>void t(e,n)})},e.id))})}var z=e(We(),1);function mt({provider:e,custom:t,onChange:n}){let r=t[e.id]??[],[i,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(``),[c,l]=(0,z.useState)(null);return(0,R.jsx)(E,{label:e.displayName,help:r.length?`${r.length} custom`:`None yet`,stacked:!0,children:(0,R.jsxs)(`div`,{className:`space-y-2`,"data-testid":`custom-models-${e.id}`,children:[r.length>0&&(0,R.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:r.map(t=>(0,R.jsxs)(`li`,{className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-border px-2 text-xs`,children:[(0,R.jsx)(`span`,{children:t.label??t.id}),t.label&&(0,R.jsx)(`span`,{className:`font-mono text-2xs text-muted-foreground`,children:t.id}),(0,R.jsx)(`button`,{type:`button`,"aria-label":`Remove ${t.label??t.id}`,onClick:()=>n(e.id,ke(r,t.id)),className:`rounded text-muted-foreground hover:text-foreground`,children:(0,R.jsx)(ge,{className:`size-3`,"aria-hidden":!0})})]},t.id))}),(0,R.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let c=Fe(r,e,{id:i,label:o});`error`in c?l(c.error):(n(e.id,c.list),a(``),s(``),l(null))},className:`flex flex-wrap items-center gap-1.5`,children:[(0,R.jsx)(k,{value:i,onChange:e=>{a(e.target.value),l(null)},placeholder:`Model id`,"aria-label":`${e.displayName} custom model id`,"aria-invalid":c?!0:void 0,className:`h-7 w-56 font-mono text-xs`}),(0,R.jsx)(k,{value:o,onChange:e=>s(e.target.value),placeholder:`Label (optional)`,"aria-label":`${e.displayName} custom model label`,className:`h-7 w-44 text-xs`}),(0,R.jsxs)(x,{type:`submit`,variant:`outline`,size:`sm`,className:`h-7 gap-1 text-xs`,children:[(0,R.jsx)(Se,{className:`size-3`,"aria-hidden":!0}),`Add`]})]}),c&&(0,R.jsx)(`p`,{role:`alert`,className:`text-2xs text-destructive`,children:c})]})})}function ht(){let e=y(e=>e.runner.providers,[]),{custom:t,set:n}=je();return e.length===0?null:(0,R.jsx)(D,{title:`Custom models`,description:`Add a model id a provider doesn't list yet, such as a new model. It is sent to the provider as is; if the provider doesn't know it, the turn fails with the provider's error. Its effort levels are those of the provider's default model.`,children:e.map(e=>(0,R.jsx)(mt,{provider:e,custom:t,onChange:n},e.id))})}function gt(){let e=y(e=>e.runner.providers,[]),{hidden:t,toggle:n}=Pe();return e.length===0?null:(0,R.jsx)(D,{title:`Models in the picker`,description:`Hide models you don't use. A hidden model still shows wherever it is already chosen.`,children:e.map(e=>{let r=e.models.filter(n=>Me(t,e.id,n.id)).length;return(0,R.jsx)(E,{label:e.displayName,help:`${e.models.length-r} of ${e.models.length} shown`,stacked:!0,children:(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,"data-testid":`model-visibility-${e.id}`,children:e.models.map(r=>{let i=!Me(t,e.id,r.id);return(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":i,"aria-label":`Show ${r.label} in the picker`,title:r.description,onClick:()=>n(e.id,r.id),className:w(`inline-flex h-7 items-center gap-1.5 rounded-md border px-2 text-xs transition-colors`,i?`border-border bg-background text-foreground hover:bg-accent`:`border-dashed border-border text-muted-foreground line-through hover:bg-accent`),children:[i?(0,R.jsx)(Ee,{className:`size-3`,"aria-hidden":!0}):(0,R.jsx)(f,{className:`size-3`,"aria-hidden":!0}),r.label]},r.id)})})},e.id)})})}var B=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function _t(){let e=y(e=>e.runner.providers,[]).filter(e=>e.capabilities.vendorHistory);return e.length===0?null:(0,R.jsx)(D,{title:`Provider apps`,description:`Some providers' own apps list every conversation on this machine as yours. CodeDen keeps the sessions it starts out of those lists.`,children:e.map(e=>(0,R.jsx)(vt,{provider:e},e.id))})}function vt({provider:e}){let[t,n]=(0,z.useState)(!1);return(0,R.jsxs)(E,{label:`Hide CodeDen's sessions from the ${e.displayName} app`,help:`New sessions are hidden when each turn ends. This hides the ones from before: only sessions CodeDen started, never your own. They are archived, not deleted, and CodeDen can still resume them.`,children:[(0,R.jsxs)(x,{size:`xs`,variant:`outline`,onClick:()=>n(!0),children:[(0,R.jsx)(f,{}),` Review`]}),t&&(0,R.jsx)(yt,{provider:e,onClose:()=>n(!1)})]})}function yt({provider:e,onClose:t}){let n=r(),i=`the ${e.displayName} app`,a=j({queryKey:[`provider-history`,e.id],queryFn:()=>n.getProviderHistory(e.id),gcTime:0,retry:!1}),o=C({mutationFn:()=>n.hideProviderHistory(e.id)}),s=a.data?.entries??[],c=o.data;return(0,R.jsx)(Ze,{open:!0,onOpenChange:e=>!e&&t(),children:(0,R.jsxs)(Ye,{className:`sm:max-w-xl`,"data-testid":`hide-provider-history`,children:[(0,R.jsxs)(Ke,{children:[(0,R.jsxs)(qe,{children:[`Hide CodeDen's sessions from `,i]}),(0,R.jsxs)(Xe,{children:[`Only sessions CodeDen started, found by its own record of them. They are archived in`,` `,i,`, not deleted.`]})]}),c?(0,R.jsxs)(`div`,{className:`space-y-1 text-[13px]`,"data-testid":`hide-provider-history-result`,children:[(0,R.jsxs)(`p`,{children:[`Hid `,B(c.hidden.length,`session`),` from `,i,`.`]}),c.missing.length>0&&(0,R.jsxs)(`p`,{className:`text-2xs text-muted-foreground`,children:[B(c.missing.length,`session`),` had already gone from it.`]}),c.failed.length>0&&(0,R.jsxs)(`p`,{className:`text-2xs text-status-failed`,children:[B(c.failed.length,`session`),` couldn't be hidden:`,` `,c.failed[0]?.message]})]}):a.isPending?(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-[13px] text-muted-foreground`,children:[(0,R.jsx)(re,{className:`size-4 animate-spin`}),` Looking for CodeDen's sessions in `,i,`...`]}):a.isError?(0,R.jsx)(`p`,{className:`text-[13px] text-status-failed`,children:a.error.message}):s.length===0?(0,R.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[`None of CodeDen's sessions are listed in `,i,`.`]}):(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsxs)(`p`,{className:`text-[13px]`,children:[B(s.length,`session`),` CodeDen started`,` `,s.length===1?`is`:`are`,` listed in `,i,`:`]}),(0,R.jsx)(`ul`,{className:`max-h-72 overflow-y-auto rounded-lg border border-border`,"data-testid":`hide-provider-history-list`,children:s.map(e=>(0,R.jsxs)(`li`,{className:`border-b border-border px-3 py-2 last:border-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,R.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:e.sessionTitle??(e.preview||e.resumeToken)}),e.updatedAt&&(0,R.jsx)(`span`,{className:`shrink-0 text-3xs text-muted-foreground`,children:S(e.updatedAt)})]}),e.sessionTitle&&e.preview&&(0,R.jsx)(`p`,{className:`truncate text-2xs text-muted-foreground`,children:e.preview})]},e.resumeToken))})]}),o.isError&&(0,R.jsx)(`p`,{className:`text-2xs text-status-failed`,children:o.error.message}),(0,R.jsxs)(Je,{children:[(0,R.jsx)(x,{variant:`ghost`,size:`sm`,onClick:t,children:c?`Close`:`Cancel`}),!c&&(0,R.jsxs)(x,{size:`sm`,disabled:s.length===0||o.isPending,onClick:()=>o.mutate(),children:[o.isPending&&(0,R.jsx)(re,{className:`animate-spin`}),`Hide `,B(s.length,`session`)]})]})]})})}var bt={off:`Never asks the npm registry for new versions.`,notify:`Asks the npm registry for the latest version on start and every 6 hours (nothing else is sent) and offers a one-click update.`,auto:`Also downloads new versions in the background; they start the next time you open CodeDen.`},xt={off:`Never asks GitHub Releases for new versions.`,notify:`Asks GitHub Releases for the latest version on start and every 6 hours (nothing else is sent) and offers a one-click update.`,auto:`Also downloads new versions in the background; they install when you quit CodeDen.`};function St(e,t){return(t===`desktop`?xt:bt)[e]}function Ct(){let{settings:e,update:t}=T(),{data:n}=Qe(),r=e.updates.mode;return(0,R.jsx)(E,{label:`Updates`,help:St(r,n?.source),children:(0,R.jsxs)(I,{value:r,onValueChange:e=>t({updates:{mode:e}}),children:[(0,R.jsx)(N,{size:`sm`,className:`w-44`,"data-testid":`update-mode`,children:(0,R.jsx)(M,{})}),(0,R.jsxs)(P,{children:[(0,R.jsx)(F,{value:`off`,children:`Off`}),(0,R.jsx)(F,{value:`notify`,children:`Notify me`}),(0,R.jsx)(F,{value:`auto`,children:`Install automatically`})]})]})})}function wt(){let{settings:e,update:t}=T(),n=Be(e=>e.preference),r=Be(e=>e.setPreference);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(D,{title:`Appearance`,children:(0,R.jsx)(E,{label:`Theme`,help:`Dark is the default; light mirrors it.`,children:(0,R.jsx)(O,{value:n,onChange:e=>{r(e),t({appearance:{theme:e}})},options:[{value:`dark`,label:`Dark`},{value:`light`,label:`Light`},{value:`system`,label:`System`}]})})}),(0,R.jsxs)(D,{title:`Follow-up prompts`,description:`Suggested next prompts appear as chips when a turn completes.`,children:[(0,R.jsx)(E,{label:`Show follow-up chips`,children:(0,R.jsx)(u,{checked:e.followups.enabled,onCheckedChange:e=>t({followups:{enabled:e}})})}),(0,R.jsx)(E,{label:`Send on click`,help:`Off: a click fills the composer so you can edit first.`,children:(0,R.jsx)(u,{checked:e.followups.sendOnClick,onCheckedChange:e=>t({followups:{sendOnClick:e}})})})]}),(0,R.jsxs)(D,{title:`Agent sessions`,description:`What CodeDen does by itself to keep agent sessions going.`,children:[(0,R.jsx)(E,{label:`Pass on pull request feedback`,help:`In sessions you start, tells the agent when its pull request's checks fail, a reviewer requests changes or it has merge conflicts. Once per commit, up to three times per pull request. The project manager follows up on work it started.`,children:(0,R.jsx)(u,{checked:e.sessions.prFeedback,onCheckedChange:e=>t({sessions:{prFeedback:e}})})}),(0,R.jsx)(E,{label:`Retry after passing failures`,help:`When a turn fails because the API was overloaded or the connection dropped, continue after 20 s, 90 s and 5 min; after a usage limit, continue once it resets. Applies to every agent session.`,children:(0,R.jsx)(u,{checked:e.sessions.autoRetry,onCheckedChange:e=>t({sessions:{autoRetry:e}})})})]}),(0,R.jsx)(pt,{}),(0,R.jsxs)(D,{title:`Background work`,children:[(0,R.jsx)(E,{label:`Automations`,help:`Master switch. Each automation is still off until you enable it.`,children:(0,R.jsx)(u,{checked:e.automations.enabled,onCheckedChange:e=>t({automations:{enabled:e}})})}),(0,R.jsx)(E,{label:`Global factory kill switch`,help:e.factory.killSwitch?`On: no project's factory loop runs.`:`Stops every project's factory loop and all factory sessions at once.`,children:(0,R.jsx)(Le,{scope:`global`,on:e.factory.killSwitch,size:`xs`})}),(0,R.jsx)(Ct,{})]}),(0,R.jsxs)(D,{title:`Worktrees`,description:`Archiving a session removes its worktree unless it has uncommitted changes. Branches and checkpoints are kept, and a cleaned-up worktree is recreated when you message the session again.`,children:[(0,R.jsx)(E,{label:`Clean up inactive worktrees`,help:`Skips sessions with an open pull request and worktrees with uncommitted changes.`,children:(0,R.jsx)(u,{checked:e.worktrees.cleanup,onCheckedChange:e=>t({worktrees:{cleanup:e}})})}),(0,R.jsx)(E,{label:`Inactive for`,help:`Days without activity before cleanup.`,children:(0,R.jsxs)(`div`,{className:`flex items-baseline gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(_,{min:1,max:365,"aria-label":`Days before cleanup`,disabled:!e.worktrees.cleanup,value:e.worktrees.afterDays,onChange:e=>t({worktrees:{afterDays:e}}),wrapperClassName:`w-20`,className:`h-8 text-xs`}),`days`]})})]})]})}var Tt=[{role:`orchestrator`,label:`Orchestrator`,help:`Your front door across projects.`},{role:`pm`,label:`Project managers`,help:`Triage, planning and follow-up per project.`},{role:`agent`,label:`Agent sessions`,help:`Default for new coding sessions.`}];function Et(){let{settings:e,update:t}=T(),n=y(e=>e.runner.providers,[]);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(D,{title:`Installed providers`,description:`Detected on this machine and reused with their own logins.`,children:n.map(e=>(0,R.jsx)(E,{label:e.displayName,help:`${e.models.length} models · ${Object.entries(e.capabilities).filter(([,e])=>e).length} capabilities`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(De,{provider:e.id,className:`size-5`}),(0,R.jsx)(`span`,{className:`rounded-full bg-status-done/12 px-2 py-0.5 text-2xs text-status-done`,children:`Ready`})]})},e.id))}),(0,R.jsx)(D,{title:`Defaults per role`,description:`Each role can run on any provider. Changing the provider of the orchestrator or of project managers starts a fresh conversation for them on their next message.`,children:Tt.map(({role:r,label:i,help:a})=>{let o=e.providers[r],s=o.provider===`auto`;return(0,R.jsx)(E,{label:i,help:a,children:(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-1 py-0.5`,children:(0,R.jsx)(Ie,{providers:n,align:`end`,placeholder:`Auto`,value:s?null:{provider:o.provider,model:o.model,effort:o.effort},onChange:e=>t({providers:{[r]:e}}),footer:e=>(0,R.jsx)(Oe,{active:s,onClick:()=>{t({providers:{[r]:{provider:`auto`,model:null,effort:null}}}),e()},children:`Auto: the first ready provider and its default model`})})})},r)})}),(0,R.jsx)(gt,{}),(0,R.jsx)(ht,{}),(0,R.jsx)(_t,{})]})}function Dt(){let{settings:e,update:t}=T();return(0,R.jsxs)(D,{title:`Default permissions`,description:`From Read-only to Full, mapped onto each provider's native enforcement. Override per project, per session and per automation.`,children:[(0,R.jsx)(`div`,{className:`grid gap-2 p-3`,children:Object.keys(Re).map(n=>{let r=Re[n],i=e.autonomy.default===n;return(0,R.jsxs)(`button`,{type:`button`,onClick:()=>t({autonomy:{default:n}}),className:w(`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors`,i?`border-primary/50 bg-primary/[0.06]`:`border-border hover:bg-accent/40`),children:[(0,R.jsx)(r.icon,{className:w(`mt-0.5 size-4`,r.tone)}),(0,R.jsxs)(`span`,{children:[(0,R.jsxs)(`span`,{className:`block text-[13.5px] font-medium`,children:[r.label,n===`auto`&&(0,R.jsx)(`span`,{className:`ml-2 text-2xs font-normal text-muted-foreground`,children:`recommended`})]}),(0,R.jsx)(`span`,{className:`block text-2xs text-muted-foreground`,children:r.description})]})]},n)})}),(0,R.jsx)(E,{label:`Risky actions`,help:`Writes outside the worktree, force pushes, deleting branches, global installs, unlisted network hosts and secrets access always go to your inbox in Auto.`,children:(0,R.jsx)(`span`,{className:`text-2xs text-muted-foreground`,children:`Always ask`})})]})}function Ot(){let{settings:e,update:t}=T(),n=y(e=>e.runner.providers,[]),r=[[`followups`,`Follow-up suggestions`,`When the agent didn't suggest any itself.`],[`sessionTitles`,`Session titles`,`Short titles from the first message.`],[`noticeSummaries`,`Notice summaries`,`One-line summaries in PM wake-ups.`],[`handoffSummaries`,`Handoff summaries`,`What a session did, in the brief of a handoff. Off: its last reply.`]],i=e.utilityModel.provider===`auto`;return(0,R.jsxs)(D,{title:`Utility model`,description:`One small, cheap model for side jobs. Runs through an installed provider, no extra API key. It also writes read-aloud TL;DRs, chosen in Voice.`,children:[(0,R.jsx)(E,{label:`Model`,children:(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-1 py-0.5`,children:(0,R.jsx)(Ie,{providers:n,align:`end`,effort:!1,placeholder:`Auto (smallest available)`,value:i?null:{provider:e.utilityModel.provider,model:e.utilityModel.model,effort:null},onChange:e=>t({utilityModel:{provider:e.provider,model:e.model}}),footer:e=>(0,R.jsx)(Oe,{active:i,onClick:()=>{t({utilityModel:{provider:`auto`,model:null}}),e()},children:`Auto: the smallest available model`})})})}),r.map(([n,r,i])=>(0,R.jsx)(E,{label:r,help:i,children:(0,R.jsx)(u,{checked:e.utilityModel.jobs[n],onCheckedChange:e=>t({utilityModel:{jobs:{[n]:e}}})})},n))]})}function kt(){let{settings:e,update:t}=T(),{data:n=!1}=j({queryKey:[`platform`,`launch-at-login`],queryFn:()=>l.launchAtLoginSupported(),staleTime:1/0}),r=e.desktop;return(0,R.jsxs)(D,{title:`App`,description:`How CodeDen behaves as an app on this computer.`,children:[(0,R.jsx)(E,{label:`Open at login`,help:n?`Start CodeDen in the tray when you log in, so agents and automations are ready.`:`Not available for this kind of install.`,children:(0,R.jsx)(u,{"data-testid":`launch-at-login`,checked:r.launchAtLogin,disabled:!n,onCheckedChange:e=>t({desktop:{launchAtLogin:e}})})}),(0,R.jsx)(E,{label:`Keep running in the tray`,help:`Closing the window leaves CodeDen in the tray (menu bar on macOS). Quit from its menu.`,children:(0,R.jsx)(u,{checked:r.closeToTray,onCheckedChange:e=>t({desktop:{closeToTray:e}})})}),(0,R.jsx)(E,{label:`Keep the computer awake`,help:`Prevent sleep while an agent is running. The display can still turn off.`,children:(0,R.jsx)(u,{checked:r.keepAwake,onCheckedChange:e=>t({desktop:{keepAwake:e}})})}),l.capabilities.nativeBrowser&&(0,R.jsx)(E,{label:`Native browser`,help:`Show session browsers as real browser views in the panel: native scrolling, text selection and DevTools. Off uses the streamed view. Applies to browsers opened from now on.`,children:(0,R.jsx)(u,{"data-testid":`native-browser`,checked:r.nativeBrowser,onCheckedChange:e=>t({desktop:{nativeBrowser:e}})})})]})}function At(){let e=r(),t=y(e=>e.projects,[]),{data:n,isFetching:i,refetch:a,error:o}=j({queryKey:[`github`,`connection`],queryFn:()=>e.github.connection()}),s=n?.connected??!1;return(0,R.jsxs)(D,{title:`GitHub`,description:"Issues, pull requests, checks and evidence use the token from the GitHub CLI (`gh auth token`), read at runtime and never stored.",children:[(0,R.jsx)(E,{label:`Connection`,help:o?o.message:s?`Signed in${n?.login?` as ${n.login}`:``} via ${n?.source===`keychain`?`the OS keychain`:`the GitHub CLI`}.`:n?.message??`Checking…`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`github-connection`,children:[(0,R.jsxs)(`span`,{className:w(`inline-flex items-center gap-1 text-xs`,s?`text-status-done`:`text-status-waiting`),children:[s?(0,R.jsx)(xe,{className:`size-3.5`}):(0,R.jsx)(me,{className:`size-3.5`}),n?s?`Connected`:`Not connected`:`…`]}),(0,R.jsxs)(x,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:i,children:[(0,R.jsx)(le,{className:w(i&&`animate-spin`)}),` Re-check`]})]})}),t.map(e=>(0,R.jsx)(E,{label:e.name,help:e.kind===`github`?`${e.github.owner}/${e.github.repo}`:`No GitHub remote`,children:(0,R.jsx)(`span`,{className:`text-2xs text-muted-foreground`,children:e.kind===`github`?`Issue and PR flow`:`Local only`})},e.id))]})}var jt=[{value:`auto`,label:`Auto`},{value:`codex`,label:`Codex (your login)`},{value:`gemini`,label:`Gemini image models`},{value:`openai`,label:`OpenAI Images`},{value:`none`,label:`None (hide the tool)`}];function Mt({value:e,onChange:t,inherit:n,label:r}){return(0,R.jsxs)(I,{value:e,onValueChange:e=>t(e),children:[(0,R.jsx)(N,{size:`sm`,className:`w-48`,"aria-label":r,children:(0,R.jsx)(M,{})}),(0,R.jsxs)(P,{children:[n&&(0,R.jsx)(F,{value:`inherit`,children:`Same as global`}),jt.map(e=>(0,R.jsx)(F,{value:e.value,children:e.label},e.value))]})]})}function Nt({result:e,pending:t,onTest:n}){let i=r();return(0,R.jsxs)(`div`,{className:`space-y-3`,"data-testid":`image-test`,children:[(0,R.jsxs)(x,{size:`sm`,variant:`outline`,onClick:n,disabled:t,children:[(0,R.jsx)(we,{}),` `,t?`Generating…`:`Test`]}),e&&!e.ok&&(0,R.jsx)(`p`,{className:`text-2xs text-status-failed`,children:e.error?.message??`The test failed.`}),e?.ok&&(0,R.jsxs)(`div`,{className:`flex items-start gap-3`,children:[e.artifact&&(0,R.jsx)(`img`,{src:i.artifactUrl(e.artifact.id),alt:`Generated test`,className:`size-40 rounded-lg border border-border object-cover`}),(0,R.jsxs)(`div`,{className:`text-2xs text-muted-foreground`,children:[(0,R.jsxs)(`div`,{className:`font-medium text-foreground`,children:[`Generated with `,e.engine]}),e.model&&(0,R.jsx)(`div`,{className:`font-mono`,children:e.model}),(0,R.jsxs)(`div`,{children:[(e.durationMs/1e3).toFixed(1),`s`]})]})]})]})}var Pt=[`secrets`];function Ft(){let e=r();return j({queryKey:Pt,queryFn:()=>e.secrets.status()})}function V({secret:e,label:t,onChange:n}){let i=r(),a=A(),o=Ft(),s=o.data?.keys.find(t=>t.key===e)?.set??!1,[c,l]=(0,z.useState)(``),u=()=>{a.invalidateQueries({queryKey:Pt}),n?.()},d=C({mutationFn:()=>i.secrets.set(e,c.trim()),onSuccess:()=>{l(``),u(),b.success(`${t} saved`,{description:o.data?.backend===`memory`?`No OS keychain is available, so it lasts until the server restarts.`:`Stored in the OS keychain.`})},onError:e=>b.error(`${t} not saved`,{description:e.message})}),f=C({mutationFn:()=>i.secrets.remove(e),onSuccess:()=>{u(),b.success(`${t} removed`)}});return(0,R.jsxs)(`div`,{className:`flex w-80 items-center gap-2`,children:[(0,R.jsx)(k,{type:`password`,autoComplete:`off`,"aria-label":t,value:c,onChange:e=>l(e.target.value),placeholder:s?`•••••••• stored in keychain`:`Paste key`,className:`h-8 font-mono text-xs`}),(0,R.jsxs)(x,{size:`sm`,variant:`outline`,disabled:!c.trim()||d.isPending,onClick:()=>d.mutate(),children:[(0,R.jsx)(te,{}),` Save`]}),s&&(0,R.jsx)(x,{size:`icon-sm`,variant:`ghost`,"aria-label":`Remove ${t}`,onClick:()=>f.mutate(),children:(0,R.jsx)(pe,{})})]})}function It(){let e=r(),t=A(),{settings:n,update:i}=T(),a=n.imageGeneration,o=y(e=>e.projects,[]),[s,c]=(0,z.useState)(``),l=j({queryKey:[`image-engines`,s,a],queryFn:()=>e.images.engines(s||null)}),u=()=>void t.invalidateQueries({queryKey:[`image-engines`]}),[d,f]=(0,z.useState)(null),p=C({mutationFn:()=>e.images.test({projectId:s||void 0}),onMutate:()=>f(null),onSuccess:e=>{f(e),u()},onError:e=>f({ok:!1,engine:null,durationMs:0,error:{code:`error`,message:e.message}})}),m=s?a.projects[s]:void 0,h=async t=>{let n=e=>({imageGeneration:{projects:{[s]:e}}}),r=t===null?{}:{...m,...t};for(let e of Object.keys(r))r[e]===void 0&&delete r[e];let i=t!==null&&Object.values(t).some(e=>e===void 0);(t===null||i||Object.keys(r).length===0)&&await e.updateSettings(n(null)),Object.keys(r).length>0&&await e.updateSettings(n(r))},g=l.data?.active;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(D,{title:`Image generation`,description:`Every agent gets one generate_image tool, routed to the engine you pick here.`,children:[(0,R.jsxs)(`div`,{className:`grid gap-2 p-4 sm:grid-cols-3`,"data-testid":`image-engines`,children:[(l.data?.engines??[]).map(e=>(0,R.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/40 p-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-medium`,children:[(0,R.jsx)(Ue,{tone:e.available?`done`:`idle`}),` `,e.label,g?.engine===e.id&&(0,R.jsx)(`span`,{className:`ml-auto rounded-full bg-primary/12 px-1.5 text-3xs text-primary`,children:`active`})]}),(0,R.jsx)(`div`,{className:`mt-1 text-2xs text-muted-foreground`,children:e.reason??(e.available?`Ready`:`Unavailable`)}),(0,R.jsx)(`div`,{className:`mt-1 font-mono text-3xs text-muted-foreground/80`,children:e.defaultModel})]},e.id)),l.isLoading&&(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Checking engines…`})]}),(0,R.jsx)(E,{label:`Engine`,help:g?g.engine?`Agents use ${l.data?.engines.find(e=>e.id===g.engine)?.label??g.engine}.`:g.reason??`No engine is available, so the tool is hidden from agents.`:`Auto uses Codex when it's signed in. None hides the tool from agents.`,children:(0,R.jsx)(Mt,{label:`Global image engine`,value:a.engine,onChange:e=>e!==`inherit`&&i({imageGeneration:{engine:e}})})}),(0,R.jsx)(E,{label:`Default size`,children:(0,R.jsx)(O,{value:a.defaultSize,onChange:e=>i({imageGeneration:{defaultSize:e}}),options:[{value:`1024x1024`,label:`Square`},{value:`1536x1024`,label:`Landscape`},{value:`1024x1536`,label:`Portrait`}]})}),(0,R.jsx)(E,{label:`Quality`,children:(0,R.jsx)(O,{value:a.quality,onChange:e=>i({imageGeneration:{quality:e}}),options:[{value:`auto`,label:`Auto`},{value:`low`,label:`Low`},{value:`medium`,label:`Medium`},{value:`high`,label:`High`}]})}),(0,R.jsx)(E,{label:`Daily cap`,help:l.data?`${l.data.usage.total} generated today · 0 turns generation off.`:`Maximum images per day across all agents. 0 turns generation off.`,children:(0,R.jsx)(_,{min:0,"aria-label":`Daily image cap`,value:a.dailyCap,onChange:e=>i({imageGeneration:{dailyCap:e}}),wrapperClassName:`w-24`,className:`h-8 text-xs`})}),(0,R.jsx)(E,{label:`Gemini API key`,help:`For Gemini image models. Stored in the OS keychain.`,children:(0,R.jsx)(V,{secret:`gemini.apiKey`,label:`Gemini key`,onChange:u})}),(0,R.jsx)(E,{label:`OpenAI API key`,help:`For OpenAI Images (also used for OpenAI dictation).`,children:(0,R.jsx)(V,{secret:`openai.apiKey`,label:`OpenAI key`,onChange:u})}),(0,R.jsx)(E,{label:`Test the active engine`,help:`Generates one small image. It counts toward today's cap.`,stacked:!0,children:(0,R.jsx)(Nt,{result:d,pending:p.isPending,onTest:()=>p.mutate()})})]}),(0,R.jsxs)(D,{title:`Per-project override`,description:`A project can use its own engine and cap; unset fields follow the global settings.`,children:[(0,R.jsx)(E,{label:`Project`,children:(0,R.jsxs)(I,{value:s||`none`,onValueChange:e=>c(e===`none`?``:e),children:[(0,R.jsx)(N,{size:`sm`,className:`w-48`,"aria-label":`Override project`,children:(0,R.jsx)(M,{})}),(0,R.jsxs)(P,{children:[(0,R.jsx)(F,{value:`none`,children:`Choose a project`}),o.map(e=>(0,R.jsx)(F,{value:e.id,children:e.name},e.id))]})]})}),s&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(E,{label:`Engine for this project`,children:(0,R.jsx)(Mt,{label:`Project image engine`,inherit:!0,value:m?.engine??`inherit`,onChange:e=>void h({engine:e===`inherit`?void 0:e})})}),(0,R.jsx)(E,{label:`Project daily cap`,help:l.data?`Effective cap: ${l.data.dailyCap} · ${l.data.usage.byProject[s]??0} today`:void 0,children:(0,R.jsx)(_,{optional:!0,min:0,"aria-label":`Project daily cap`,placeholder:`global`,value:m?.dailyCap,onChange:e=>void h({dailyCap:e??void 0}),wrapperClassName:`w-24`,className:`h-8 text-xs`})}),(0,R.jsx)(E,{label:`Remove the override`,children:(0,R.jsx)(x,{size:`sm`,variant:`outline`,disabled:!m,onClick:()=>void h(null),children:`Use global settings`})})]})]})]})}var Lt=[{id:`needs_you`,label:`Needs you`,help:`PRs only a person can merge, factory decisions it flagged for you, conflicts, budget alerts.`},{id:`failure`,label:`Failures`,help:`Your sessions' failed runs, a paused factory loop, a regression, a worktree that couldn't be removed.`},{id:`factory`,label:`Factory activity`,help:`What the factory handles itself: its decisions, the PRs it reviews and merges, its sessions' failures, the daily digest.`},{id:`automation`,label:`Automations`,help:`Automation results and triage decisions.`}];function Rt(){let{settings:e,update:t}=T(),[n,r]=(0,z.useState)(l.notificationPermission()),i=e.notifications.categories;return(0,R.jsxs)(D,{title:`Notifications`,description:`How CodeDen tells you something is waiting.`,children:[(0,R.jsx)(E,{label:`Toasts`,help:`In-app toasts for new inbox items in the categories below. Several at once become one toast.`,children:(0,R.jsx)(u,{checked:e.notifications.toasts,onCheckedChange:e=>t({notifications:{toasts:e}})})}),(0,R.jsx)(E,{label:`Notify me about`,help:`For toasts and desktop notifications. Approvals and questions always notify; everything still lands in the inbox.`,stacked:!0,children:(0,R.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:Lt.map(e=>(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-lg border border-border px-3 py-2.5`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`text-[13px] font-medium`,children:e.label}),(0,R.jsx)(`div`,{className:`mt-0.5 text-2xs leading-relaxed text-muted-foreground`,children:e.help})]}),(0,R.jsx)(u,{"aria-label":e.label,checked:i[e.id],onCheckedChange:n=>t({notifications:{categories:{...i,[e.id]:n}}})})]},e.id))})}),(0,R.jsx)(E,{label:`Sound when an agent needs you`,help:`A short chime when an approval or a question arrives, even in the background.`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(x,{size:`sm`,variant:`outline`,onClick:()=>{it.unlock(),it.play()},children:[(0,R.jsx)(be,{}),` Test`]}),(0,R.jsx)(u,{"aria-label":`Sound when an agent needs you`,checked:e.notifications.sound,onCheckedChange:e=>t({notifications:{sound:e}})})]})}),(0,R.jsx)(E,{label:l.capabilities.osIntegration?`System notifications`:`Browser notifications`,help:n===`denied`?`Blocked in your browser settings.`:l.capabilities.osIntegration?`Shown when the CodeDen window isn't focused.`:`Shown when the CodeDen tab isn't focused.`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n!==`granted`&&n!==`unsupported`&&(0,R.jsxs)(x,{size:`sm`,variant:`outline`,onClick:async()=>r(await l.requestNotificationPermission()),children:[(0,R.jsx)(m,{}),` Allow`]}),(0,R.jsx)(u,{checked:e.notifications.browser,disabled:n===`unsupported`,onCheckedChange:e=>t({notifications:{browser:e}})})]})}),(0,R.jsx)(E,{label:`Send a test notification`,children:(0,R.jsx)(x,{size:`sm`,variant:`outline`,onClick:()=>{b(`Approval needed`,{description:`Force push to codeden/fix-checkout-flake`}),l.notify(`Approval needed`,{body:`Force push to codeden/fix-checkout-flake`})},children:`Test`})})]})}var H=(e=>(e[e.Border=-1]=`Border`,e[e.Data=0]=`Data`,e[e.Function=1]=`Function`,e[e.Position=2]=`Position`,e[e.Timing=3]=`Timing`,e[e.Alignment=4]=`Alignment`,e))(H||{}),zt=[0,1],Bt=[1,0],Vt=[2,3],Ht=[3,2],Ut={L:zt,M:Bt,Q:Vt,H:Ht},Wt=/^\d*$/,Gt=/^[A-Z0-9 $%*+./:-]*$/,U=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,W=1,G=40,Kt=3,qt=3,K=40,Jt=10,Yt=[[-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]],Xt=[[-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]],Zt=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,e<W||e>G)throw RangeError(`Version value out of range`);if(r<-1||r>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let i=Array.from({length:this.size}).fill(!1);for(let e=0;e<this.size;e++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let a=this.addEccAndInterleave(n);if(this.drawCodewords(a),r===-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}size;mask;modules=[];types=[];getModule(e,t){return e>=0&&e<this.size&&t>=0&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0,H.Timing),this.setFunctionModule(e,6,e%2==0,H.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n===0&&r===0||n===0&&r===t-1||n===t-1&&r===0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.ecc[1]<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;for(let e=0;e<=5;e++)this.setFunctionModule(8,e,J(r,e));this.setFunctionModule(8,7,J(r,6)),this.setFunctionModule(8,8,J(r,7)),this.setFunctionModule(7,8,J(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,J(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,J(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,J(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let e=0;e<18;e++){let n=J(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;a>=0&&a<this.size&&o>=0&&o<this.size&&this.setFunctionModule(a,o,i!==2&&i!==4,H.Position)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1,H.Alignment)}setFunctionModule(e,t,n,r=H.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==Z(t,n))throw RangeError(`Invalid argument`);let r=Xt[n[0]][t],i=Yt[n[0]][t],a=Math.floor(X(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=dn(i);for(let t=0,n=0;t<r;t++){let r=e.slice(n,n+s-i+(t<o?0:1));n+=r.length;let a=fn(r,l);t<o&&r.push(0),c.push(r.concat(a))}let u=[];for(let e=0;e<c[0].length;e++)c.forEach((t,n)=>{(e!==s-i||n>=o)&&u.push(t[e])});return u}drawCodewords(e){if(e.length!==Math.floor(X(this.version)/8))throw RangeError(`Invalid argument`);let t=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=n-i,o=n+1&2?r:this.size-1-r;!this.types[o][a]&&t<e.length*8&&(this.modules[o][a]=J(e[t>>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.types[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[t][a]===n?(r++,r===5?e+=Kt:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*K),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*K}for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][t]===n?(r++,r===5?e+=Kt:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*K),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*K}for(let t=0;t<this.size-1;t++)for(let n=0;n<this.size-1;n++){let r=this.modules[t][n];r===this.modules[t][n+1]&&r===this.modules[t+1][n]&&r===this.modules[t+1][n+1]&&(e+=qt)}let t=0;for(let e of this.modules)t=e.reduce((e,t)=>e+ +!!t,t);let n=this.size*this.size,r=Math.ceil(Math.abs(t*20-n*10)/n)-1;return e+=r*Jt,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(e){let t=e[1],n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function q(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function J(e,t){return!!(e>>>t&1)}var Y=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}},Qt=[1,10,12,14],$t=[2,9,11,13],en=[4,8,16,16];function tn(e,t){return e[Math.floor((t+7)/17)+1]}function nn(e){let t=[];for(let n of e)q(n,8,t);return new Y(en,e.length,t)}function rn(e){if(!sn(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let n=0;n<e.length;){let r=Math.min(e.length-n,3);q(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new Y(Qt,e.length,t)}function an(e){if(!cn(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n=0;for(;n+2<=e.length;n+=2){let r=U.indexOf(e.charAt(n))*45;r+=U.indexOf(e.charAt(n+1)),q(r,11,t)}return n<e.length&&q(U.indexOf(e.charAt(n)),6,t),new Y($t,e.length,t)}function on(e){return e===``?[]:sn(e)?[rn(e)]:cn(e)?[an(e)]:[nn(un(e))]}function sn(e){return Wt.test(e)}function cn(e){return Gt.test(e)}function ln(e,t){let n=0;for(let r of e){let e=tn(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function un(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)===`%`?(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}function X(e){if(e<W||e>G)throw RangeError(`Version number out of range`);let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function Z(e,t){return Math.floor(X(e)/8)-Yt[t[0]][e]*Xt[t[0]][e]}function dn(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let t=[];for(let n=0;n<e-1;n++)t.push(0);t.push(1);let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=Q(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=Q(n,2)}return t}function fn(e,t){let n=t.map(e=>0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=Q(t,e))}return n}function Q(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function pn(e,t,n=1,r=40,i=-1,a=!0){if(!(W<=n&&n<=r&&r<=G)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=Z(o,t)*8,i=ln(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[Bt,Vt,Ht])a&&s<=Z(o,e)*8&&(t=e);let c=[];for(let t of e){q(t.mode[0],4,c),q(t.numChars,tn(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=Z(o,t)*8;q(0,Math.min(4,l-c.length),c),q(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)q(e,8,c);let u=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((e,t)=>u[t>>>3]|=e<<7-(t&7)),new Zt(o,t,u,i)}function mn(e,t){let{ecc:n=`L`,boostEcc:r=!1,minVersion:i=1,maxVersion:a=40,maskPattern:o=-1,border:s=1}=t||{},c=typeof e==`string`?on(e):Array.isArray(e)?[nn(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=pn(c,Ut[n],i,a,o,r),u=hn({version:l.version,maskPattern:l.mask,size:l.size,data:l.modules,types:l.types},s);return t?.invert&&(u.data=u.data.map(e=>e.map(e=>!e))),t?.onEncoded?.(u),u}function hn(e,t=1){if(!t)return e;let{size:n}=e,r=n+t*2;e.size=r,e.data.forEach(e=>{for(let n=0;n<t;n++)e.unshift(!1),e.push(!1)});for(let n=0;n<t;n++)e.data.unshift(Array.from({length:r},e=>!1)),e.data.push(Array.from({length:r},e=>!1));let i=H.Border;e.types.forEach(e=>{for(let n=0;n<t;n++)e.unshift(i),e.push(i)});for(let n=0;n<t;n++)e.types.unshift(Array.from({length:r},e=>i)),e.types.push(Array.from({length:r},e=>i));return e}function gn(e){let{data:t,size:n}=mn(e,{ecc:`M`,border:2}),r=``;for(let e=0;e<n;e++)for(let i=0;i<n;i++)t[e]?.[i]&&(r+=`M${i} ${e}h1v1h-1z`);return{d:r,size:n}}function _n({value:e,label:t,className:n}){let{d:r,size:i}=(0,z.useMemo)(()=>gn(e),[e]);return(0,R.jsx)(`svg`,{viewBox:`0 0 ${i} ${i}`,role:`img`,"aria-label":t,shapeRendering:`crispEdges`,className:w(`rounded-md bg-white`,n),"data-testid":`qr-code`,"data-value":e,children:(0,R.jsx)(`path`,{d:r,fill:`#000`})})}var vn=[`network`];function yn({value:e,onDone:t}){let[n,r]=(0,z.useState)(!1);return(0,R.jsxs)(`div`,{className:`rounded-lg border border-primary/30 bg-primary/[0.06] p-3`,"data-testid":`generated-password`,children:[(0,R.jsx)(`div`,{className:`text-2xs font-medium text-primary`,children:`Your new password (shown once)`}),(0,R.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`code`,{className:`min-w-0 flex-1 font-mono text-[15px] break-all select-all`,children:e}),(0,R.jsxs)(x,{size:`sm`,variant:`outline`,onClick:()=>void s(e,`Password copied`).then(e=>r(e)),children:[n?(0,R.jsx)(_e,{}):(0,R.jsx)(ne,{}),` `,n?`Copied`:`Copy`]})]}),(0,R.jsxs)(`p`,{className:`mt-2 text-2xs text-muted-foreground`,children:[`Save it in your password manager now: CodeDen keeps only a scrambled copy and can't show it again.`,` `,(0,R.jsx)(`button`,{type:`button`,className:`underline underline-offset-2`,onClick:t,children:`I've saved it`})]})]})}function bn({passwordSet:e}){let t=r(),i=A(),[a,o]=(0,z.useState)(``),[s,c]=(0,z.useState)(null),l=a?n(a):null,u=C({mutationFn:e=>t.network.setPassword(e),onSuccess:t=>{i.setQueryData(vn,t.status),o(``),c(t.generated),b.success(e?`Password changed, every device signed out`:`Password set`)},onError:e=>b.error(`Password not saved`,{description:e.message})});function d(e){e.preventDefault(),a&&!l&&u.mutate({password:a})}return(0,R.jsxs)(`div`,{className:`space-y-3`,children:[s&&(0,R.jsx)(yn,{value:s,onDone:()=>c(null)}),(0,R.jsxs)(`form`,{onSubmit:d,className:`flex flex-col gap-2 sm:flex-row`,children:[(0,R.jsx)(k,{type:`password`,autoComplete:`new-password`,placeholder:e?`New password`:`Choose a password`,value:a,onChange:e=>o(e.target.value),"aria-label":`Network access password`,"aria-invalid":l?!0:void 0,className:`sm:flex-1`,"data-testid":`network-password-input`}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsxs)(x,{type:`submit`,className:`flex-1 sm:flex-none`,disabled:!a||!!l||u.isPending,children:[(0,R.jsx)(te,{}),` `,e?`Change`:`Set password`]}),(0,R.jsxs)(x,{type:`button`,variant:`outline`,className:`flex-1 sm:flex-none`,disabled:u.isPending,onClick:()=>u.mutate({generate:!0}),children:[(0,R.jsx)(ae,{}),` Generate`]})]})]}),(0,R.jsxs)(`p`,{className:l?`text-2xs text-destructive`:`text-2xs text-muted-foreground`,role:l?`alert`:void 0,children:[l??`Use at least 15 characters. A short sentence or a few random words works well. Very common passwords, repeated characters and simple sequences such as abcdef… or 12345… are refused.`,!l&&e&&` Changing it signs out every phone and tablet.`]})]})}var xn={local:`This computer`,lan:`Local network`,vpn:`VPN`};function Sn(e){let t=e.toLowerCase(),n=t.includes(`iphone`)?`iPhone`:t.includes(`ipad`)?`iPad`:t.includes(`android`)?t.includes(`mobile`)?`Android phone`:`Android tablet`:t.includes(`mac os`)?`Mac`:t.includes(`windows`)?`Windows`:t.includes(`linux`)?`Linux`:`Device`,r=t.includes(`edg/`)?`Edge`:t.includes(`firefox`)||t.includes(`fxios`)?`Firefox`:t.includes(`chrome`)||t.includes(`crios`)?`Chrome`:t.includes(`safari`)?`Safari`:null;return r?`${n} · ${r}`:n}function Cn({address:e,live:t}){let n=e.kind!==`local`;return(0,R.jsxs)(`div`,{className:w(`flex items-center gap-4 px-4 py-3.5`,!t&&`opacity-60`),"data-testid":`network-address`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-[13.5px] font-medium`,children:e.label}),e.kind!==`local`&&(0,R.jsx)(`span`,{className:`rounded border border-border px-1.5 py-px text-3xs text-muted-foreground`,children:xn[e.kind]})]}),(0,R.jsxs)(`button`,{type:`button`,className:`mt-1 flex max-w-full items-center gap-1.5 font-mono text-[12.5px] text-muted-foreground hover:text-foreground pointer-coarse:min-h-10`,onClick:()=>void s(e.url,`Address copied`),title:`Copy address`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.url}),(0,R.jsx)(ne,{className:`size-3 shrink-0`})]}),e.kind===`local`&&(0,R.jsx)(`p`,{className:`mt-1 text-2xs text-muted-foreground`,children:`Only works on this computer.`})]}),n&&(0,R.jsx)(_n,{value:e.url,label:`QR code for ${e.url}`,className:`size-28 shrink-0 p-1 sm:size-32`})]})}function wn({device:e,onSignOut:t,pending:n}){let r=/iphone|ipad|android/i.test(e.label)?he:Ce;return(0,R.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,"data-testid":`network-device`,children:[(0,R.jsx)(r,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`truncate text-[13.5px] font-medium`,title:e.label,children:[Sn(e.label),e.current&&(0,R.jsx)(`span`,{className:`ml-2 text-2xs text-primary`,children:`This device`})]}),(0,R.jsxs)(`div`,{className:`truncate text-2xs text-muted-foreground`,children:[e.address??`Unknown address`,` · seen `,S(e.lastSeenAt),` · signed in`,` `,S(e.createdAt)]})]}),(0,R.jsxs)(x,{size:`sm`,variant:`outline`,onClick:t,disabled:n,children:[(0,R.jsx)(ie,{}),` Sign out`]})]})}function Tn(){let e=r(),t=A(),{data:n,error:i}=j({queryKey:vn,queryFn:()=>e.network.status(),refetchInterval:15e3}),a=e=>t.setQueryData(vn,e),o=C({mutationFn:t=>e.network.setEnabled(t),onSuccess:e=>{a(e),b.success(e.enabled?`Network access is on`:`Network access is off`)},onError:e=>b.error(`Network access not changed`,{description:e.message})}),s=C({mutationFn:t=>t?e.network.signOutDevice(t):e.network.signOutAll(),onSuccess:a,onError:e=>b.error(`Not signed out`,{description:e.message})});if(i)return(0,R.jsx)(D,{title:`Network access`,children:(0,R.jsx)(`p`,{className:`p-4 text-[13px] text-muted-foreground`,children:`This CodeDen server doesn't offer network access yet. Update CodeDen to use it.`})});if(!n)return null;let c=n.remote,l=n.enabled?n.addresses:n.candidates;return(0,R.jsxs)(`div`,{"data-testid":`network-settings`,children:[(0,R.jsxs)(D,{title:`Network access`,description:`Open CodeDen from your phone or tablet on the same Wi-Fi, or from anywhere over your own VPN such as Tailscale. Off by default.`,children:[(0,R.jsx)(E,{label:`Allow network access`,help:c?`Change this on the computer running CodeDen.`:n.enabled?`Devices on your network can open CodeDen after signing in with the password.`:n.passwordSet?`CodeDen only answers on this computer (127.0.0.1).`:`Set a password below first.`,children:(0,R.jsx)(u,{"aria-label":`Allow network access`,"data-testid":`network-toggle`,checked:n.enabled,disabled:c||!n.passwordSet||o.isPending,onCheckedChange:e=>o.mutate(e)})}),!c&&(0,R.jsx)(E,{label:`Password`,stacked:!0,help:n.passwordSetAt?`Set ${S(n.passwordSetAt)}. Phones and tablets sign in with it once.`:`Phones and tablets sign in with it once. CodeDen stores only a scrambled copy.`,children:(0,R.jsx)(bn,{passwordSet:n.passwordSet})})]}),(0,R.jsxs)(D,{title:`Addresses`,description:n.enabled?`Scan a code with your phone's camera, or type the address into its browser.`:`Where CodeDen will answer once network access is on.`,children:[l.map(e=>(0,R.jsx)(Cn,{address:e,live:n.enabled||e.kind===`local`},e.url)),n.candidates.length===1&&(0,R.jsxs)(`p`,{className:`flex items-center gap-2 px-4 py-3 text-2xs text-muted-foreground`,children:[(0,R.jsx)(de,{className:`size-3.5`}),` This computer isn't on a network right now.`]}),(0,R.jsx)(`p`,{className:`px-4 py-3 text-2xs leading-relaxed text-muted-foreground`,children:`Away from home, use your own VPN (Tailscale, WireGuard): its address shows up here and needs nothing else. These are plain http addresses, so phones won't allow notifications or the microphone on them. Tip: open CodeDen on your phone and use Add to Home Screen.`})]}),(0,R.jsx)(D,{title:`Signed-in devices`,description:`Each device stays signed in for 90 days, or until you sign it out.`,children:n.devices.length===0?(0,R.jsx)(`p`,{className:`px-4 py-3.5 text-[13px] text-muted-foreground`,children:`No devices signed in.`}):(0,R.jsxs)(R.Fragment,{children:[n.devices.map(e=>(0,R.jsx)(wn,{device:e,pending:s.isPending,onSignOut:()=>s.mutate(e.id)},e.id)),(0,R.jsx)(`div`,{className:`flex justify-end px-4 py-3`,children:(0,R.jsxs)(x,{size:`sm`,variant:`destructive`,onClick:()=>s.mutate(null),disabled:s.isPending,children:[(0,R.jsx)(ie,{}),` Sign out all`]})})]})})]})}function En(){let{settings:e,update:t}=T(),n=e.voice.dictation,r=ct(),i=r.data?.models.find(e=>e.id===n.local.model);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(E,{label:`Whisper model`,help:r.error?`Couldn't read the local engine: ${r.error.message}`:`Models are downloaded once into ${r.data?.location??`the CodeDen folder`} and run on this machine.`,stacked:!0,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsx)(lt,{status:r.data,value:n.local.model,onChange:e=>t({voice:{dictation:{local:{model:e}}}})}),(0,R.jsx)(ut,{status:r.data,modelId:n.local.model})]})}),(0,R.jsx)(E,{label:`Try it`,help:`Say a sentence after pressing Test.`,stacked:!0,children:(0,R.jsx)(dt,{disabled:i?.state!==`installed`,language:n.language})})]})}function Dn(e){if([`Control`,`Shift`,`Alt`,`Meta`].includes(e.key))return null;let t=[];(e.ctrlKey||e.metaKey)&&t.push(`mod`),e.altKey&&t.push(`alt`),e.shiftKey&&t.push(`shift`);let n=e.key===` `?`space`:(e.key.length,e.key.toLowerCase());return t.push(n),t.join(`+`)}function On({value:e,onChange:t}){let[n,r]=(0,z.useState)(!1),i=n===`keys`?`Press keys…`:n===`needsModifier`?`Add ${v(`mod`)} or ${v(`alt`)}…`:e?v(e):`Not set`;return(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(x,{size:`sm`,variant:`outline`,"aria-label":`Push-to-talk shortcut`,className:`min-w-36 font-mono text-xs`,onClick:()=>r(`keys`),onBlur:()=>r(!1),onKeyDown:e=>{if(!n)return;if(e.preventDefault(),e.key===`Escape`)return r(!1);let i=Dn(e);if(i){if(!Ne(i))return r(`needsModifier`);t(i),r(!1)}},children:[(0,R.jsx)(ye,{}),` `,i]}),e&&(0,R.jsx)(x,{size:`icon-sm`,variant:`ghost`,"aria-label":`Clear push-to-talk`,onClick:()=>t(null),children:(0,R.jsx)(ge,{})})]})}function kn(){let{settings:e,update:t}=T(),n=e.voice.readAloud.quietHours,r=e=>n&&t({voice:{readAloud:{quietHours:{...n,...e}}}});return(0,R.jsx)(E,{label:`Quiet hours`,help:`Nothing is spoken in this window.`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(u,{"aria-label":`Quiet hours`,checked:n!==null,onCheckedChange:e=>t({voice:{readAloud:{quietHours:e?{start:`22:00`,end:`07:00`}:null}}})}),(0,R.jsx)(k,{type:`time`,"aria-label":`Quiet hours start`,disabled:!n,value:n?.start??`22:00`,onChange:e=>r({start:e.target.value}),className:`h-8 w-24 text-xs`}),(0,R.jsx)(`span`,{className:`text-2xs text-muted-foreground`,children:`to`}),(0,R.jsx)(k,{type:`time`,"aria-label":`Quiet hours end`,disabled:!n,value:n?.end??`07:00`,onChange:e=>r({end:e.target.value}),className:`h-8 w-24 text-xs`})]})})}var An=[`auto`,`en-US`,`en-GB`,`en-ZA`,`de-DE`,`fr-FR`,`es-ES`,`nl-NL`];function jn(){let[e,t]=(0,z.useState)(()=>L.voices());return(0,z.useEffect)(()=>{if(typeof window>`u`||!window.speechSynthesis)return;let e=()=>t(L.voices());return window.speechSynthesis.addEventListener(`voiceschanged`,e),e(),()=>window.speechSynthesis.removeEventListener(`voiceschanged`,e)},[]),e}function Mn(){let e=r(),{settings:n,update:i}=T(),a=n.voice,o=jn(),s=Ft(),c=e=>s.data?.keys.some(t=>t.key===e&&t.set)??!1,l=a.readAloud.engine===`elevenlabs`,d=j({queryKey:[`eleven-voices`,c(`elevenlabs.apiKey`)],queryFn:()=>e.voice.voices(),enabled:l&&c(`elevenlabs.apiKey`),retry:!1}),f=l?(d.data?.voices??[]).map(e=>({id:e.id,label:e.name})):o.map(e=>({id:e.id,label:`${e.label} (${e.lang})`})),p=C({mutationFn:async()=>at.playNow({key:`test-${Date.now()}`,play:()=>tt(e,n,`The checkout flake is fixed and verified with fifty green runs.`).catch(e=>{b.error(`Couldn't play the voice`,{description:e.message})})})}),m=a.dictation.engine===`openai`?`openai.apiKey`:`elevenlabs.apiKey`,h=st()===`available`;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(D,{title:`Dictation`,description:`Speech to text in the composer. Toggle with ${v(Ae(`dictate`).combo)}, or hold a push-to-talk shortcut.`,children:[(0,R.jsx)(E,{label:`Engine`,help:a.dictation.engine===`browser`?h?`The browser engine works in Chrome and Edge.`:(0,R.jsxs)(`span`,{"data-testid":`browser-stt-unavailable`,children:[`Speech recognition isn't available here.`,` `,(0,R.jsx)(`button`,{type:`button`,className:`text-foreground underline underline-offset-2`,onClick:()=>i({voice:{dictation:{engine:`local`}}}),children:`Use Local (Whisper)`}),`, which runs on this machine, or a cloud engine.`]}):a.dictation.engine===`local`?`Runs Whisper on this machine through the CodeDen server; audio never leaves it.`:c(m)?`Transcribes each phrase through the CodeDen server as you pause, so text appears while you speak.`:`Add the ${a.dictation.engine===`openai`?`OpenAI`:`ElevenLabs`} key below to use this engine.`,children:(0,R.jsx)(O,{value:a.dictation.engine,onChange:e=>{e===`browser`&&ot(),i({voice:{dictation:{engine:e}}})},options:[{value:`browser`,label:h||a.dictation.engine===`browser`?`Browser`:`Browser (unavailable)`},{value:`local`,label:`Local (Whisper)`},{value:`elevenlabs`,label:`ElevenLabs`},{value:`openai`,label:`OpenAI`}]})}),a.dictation.engine===`local`&&(0,R.jsx)(En,{}),(0,R.jsx)(E,{label:`Language`,help:a.dictation.engine===`browser`?`Leave on auto to follow the browser language.`:`Auto detects the spoken language. English-only Whisper models always use English.`,children:(0,R.jsxs)(I,{value:a.dictation.language??`auto`,onValueChange:e=>i({voice:{dictation:{language:e===`auto`?null:e}}}),children:[(0,R.jsx)(N,{size:`sm`,className:`w-40`,"aria-label":`Dictation language`,children:(0,R.jsx)(M,{})}),(0,R.jsx)(P,{children:An.map(e=>(0,R.jsx)(F,{value:e,children:e===`auto`?`Auto`:e},e))})]})}),(0,R.jsx)(E,{label:`Push-to-talk`,help:`Hold to dictate, release to stop. Click, then press a key with ${v(`mod`)} or ${v(`alt`)} (or an F key).`,children:(0,R.jsx)(On,{value:a.dictation.pushToTalkShortcut,onChange:e=>i({voice:{dictation:{pushToTalkShortcut:e}}})})}),a.dictation.engine===`openai`&&(0,R.jsx)(E,{label:`OpenAI API key`,help:`Shared with OpenAI Images. Stored in the OS keychain.`,children:(0,R.jsx)(V,{secret:`openai.apiKey`,label:`OpenAI key`})})]}),(0,R.jsxs)(D,{title:`Read aloud`,description:`Speaks an agent's final message when any session finishes a turn, with code and markdown stripped.`,children:[(0,R.jsx)(E,{label:`Read final messages aloud`,help:`Messages play one after another; switching this off stops the current one. Mute single sessions from their Details tab.`,children:(0,R.jsx)(u,{"aria-label":`Read final messages aloud`,checked:a.readAloud.enabled,onCheckedChange:e=>{e||at.clear(),i({voice:{readAloud:{enabled:e}}})}})}),(0,R.jsx)(E,{label:`What to read`,help:a.readAloud.content===`summary`?`A one or two sentence TL;DR from the utility model: what was done and whether it needs you.`:`The whole final message, up to ${t.toLocaleString(`en-US`)} characters (about five minutes).`,children:(0,R.jsx)(O,{value:a.readAloud.content,onChange:e=>i({voice:{readAloud:{content:e}}}),options:[{value:`summary`,label:`TL;DR`},{value:`full`,label:`Full message`}]})}),(0,R.jsx)(E,{label:`Say who's speaking`,help:`Starts each message with who it's from, such as the project manager or a session's title.`,children:(0,R.jsx)(u,{"aria-label":`Say who's speaking`,checked:a.readAloud.announceSpeaker,onCheckedChange:e=>i({voice:{readAloud:{announceSpeaker:e}}})})}),(0,R.jsx)(E,{label:`Engine`,children:(0,R.jsx)(O,{value:a.readAloud.engine,onChange:e=>i({voice:{readAloud:{engine:e,voice:null}}}),options:[{value:`browser`,label:`Browser (free)`},{value:`elevenlabs`,label:`ElevenLabs`}]})}),(0,R.jsx)(E,{label:`Voice`,help:l&&!c(`elevenlabs.apiKey`)?`Add your ElevenLabs key below to load its voices.`:d.error?d.error.message:void 0,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(I,{value:a.readAloud.voice??`default`,onValueChange:e=>i({voice:{readAloud:{voice:e==="default"?null:e}}}),children:[(0,R.jsx)(N,{size:`sm`,className:`w-56`,"aria-label":`Read-aloud voice`,children:(0,R.jsx)(M,{})}),(0,R.jsxs)(P,{children:[(0,R.jsx)(F,{value:`default`,children:l?`Default voice`:`System default`}),f.slice(0,60).map(e=>(0,R.jsx)(F,{value:e.id,children:e.label},e.id))]})]}),(0,R.jsxs)(x,{size:`sm`,variant:`outline`,disabled:(l?!c(`elevenlabs.apiKey`):!L.supported)||p.isPending,onClick:()=>p.mutate(),children:[(0,R.jsx)(be,{}),` Test`]})]})}),(0,R.jsx)(E,{label:`Only when the tab isn't focused`,children:(0,R.jsx)(u,{"aria-label":`Only when the tab isn't focused`,checked:a.readAloud.onlyWhenUnfocused,onCheckedChange:e=>i({voice:{readAloud:{onlyWhenUnfocused:e}}})})}),(0,R.jsx)(kn,{}),(0,R.jsx)(E,{label:`ElevenLabs API key`,help:`Optional, for ElevenLabs voices and dictation. Stored in the OS keychain.`,children:(0,R.jsx)(V,{secret:`elevenlabs.apiKey`,label:`ElevenLabs key`})})]})]})}function Nn(){let e=r(),t=A(),{data:n}=Qe(),i=et(),a=C({mutationFn:()=>e.getUpdates({refresh:!0}),onSuccess:e=>t.setQueryData($e,e)});if(!n)return null;let o=n.state===`installing`||n.state===`restarting`,s;s=n.enabled?n.state===`installing`?`Installing ${n.target}...`:n.state===`restarting`?`Restarting into ${n.target}...`:n.state===`installed`?`Version ${n.target} is installed.`:n.updateAvailable?`Version ${n.latest} is available.`:n.error?`Couldn't check for updates: ${n.error}`:n.latest?`You're on the latest version.`:`Not checked yet.`:`Update checks are off (Settings > General).`;let c=n.rollbackTo?`Roll back to ${n.rollbackTo}`:`Roll back to the previous version`,l=n.updateAvailable&&nt(n)&&n.state===`idle`;return(0,R.jsxs)(`div`,{className:`mt-2 space-y-1.5 text-2xs`,"data-testid":`update-check`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:n.updateAvailable?`text-status-waiting`:`text-muted-foreground`,children:s}),(l||n.enabled)&&(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[l&&(0,R.jsx)(x,{size:`xs`,onClick:()=>i.install.mutate(),disabled:o,children:`Update now`}),n.enabled&&(0,R.jsxs)(x,{size:`xs`,variant:`ghost`,onClick:()=>a.mutate(),disabled:a.isPending,children:[(0,R.jsx)(le,{className:a.isPending?`animate-spin`:void 0}),` Check now`]})]})]}),n.source===`source`?(0,R.jsxs)(`p`,{className:`text-muted-foreground`,children:[`You're running from source: pull and rebuild to update (`,(0,R.jsx)(`code`,{className:`font-mono`,children:`git pull && pnpm install && pnpm build`}),`).`]}):n.installed.length>0&&(0,R.jsxs)(`p`,{className:`text-muted-foreground`,"data-testid":`installed-versions`,children:[`Installed:`,` `,n.installed.map(e=>`${e.version}${e.current?` (current)`:``}${e.valid?``:` (broken)`}`).join(`, `)]}),n.state===`failed`&&n.installError&&(0,R.jsxs)(`p`,{className:`text-status-failed`,children:[`Last update failed: `,n.installError]}),n.warning&&(0,R.jsx)(`p`,{className:`text-status-failed`,children:n.warning}),n.canRollback&&(0,R.jsxs)(x,{size:`xs`,variant:`outline`,disabled:o||i.rollback.isPending,onClick:()=>i.rollback.mutate(),children:[(0,R.jsx)(ve,{}),` `,c]}),i.rollback.error&&(0,R.jsx)(`p`,{className:`text-status-failed`,children:i.rollback.error.message})]})}function Pn(){let e=i(ze().data);return(0,R.jsx)(D,{title:`About`,children:(0,R.jsx)(`div`,{className:`@container`,children:(0,R.jsxs)(`div`,{className:`flex flex-col items-start gap-3 p-5 @[30rem]:flex-row @[30rem]:items-center @[30rem]:gap-4`,children:[(0,R.jsx)(c,{className:`size-10 @[30rem]:size-12`}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`text-[15px] font-semibold`,"data-testid":`version-line`,children:e}),(0,R.jsx)(`p`,{className:`mt-0.5 text-[13px] text-muted-foreground`,children:`A local-first harness for coding agents. Open source under the MIT license. No accounts, no telemetry.`}),(0,R.jsx)(Nn,{}),!1]})]})})})}var $=[{id:`general`,label:`General`,icon:Te,render:()=>(0,R.jsx)(wt,{})},{id:`providers`,label:`Providers`,icon:p,render:()=>(0,R.jsx)(Et,{})},{id:`autonomy`,label:`Autonomy`,icon:h,render:()=>(0,R.jsx)(Dt,{})},{id:`github`,label:`GitHub`,icon:fe,render:()=>(0,R.jsx)(At,{})},{id:`voice`,label:`Voice`,icon:se,render:()=>(0,R.jsx)(Mn,{})},{id:`images`,label:`Image generation`,icon:oe,render:()=>(0,R.jsx)(It,{})},{id:`utility`,label:`Utility model`,icon:g,render:()=>(0,R.jsx)(Ot,{})},{id:`notifications`,label:`Notifications`,icon:ce,render:()=>(0,R.jsx)(Rt,{})},{id:`network`,label:`Network access`,icon:he,render:()=>(0,R.jsx)(Tn,{})},...l.capabilities.osIntegration?[{id:`desktop`,label:`App`,icon:ee,render:()=>(0,R.jsx)(kt,{})}]:[],{id:`shortcuts`,label:`Keyboard shortcuts`,icon:ye,render:()=>(0,R.jsx)(rt,{})},{id:`about`,label:`About`,icon:ue,render:()=>(0,R.jsx)(Pn,{})}];function Fn({section:e}){let t=$.find(t=>t.id===e)??$[0],n=o();return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(ft,{icon:(0,R.jsx)(Te,{}),title:`Settings`,meta:t?.label}),(0,R.jsx)(`div`,{className:`shrink-0 border-b border-border px-4 py-2 md:hidden`,children:(0,R.jsx)(`select`,{"aria-label":`Settings section`,className:`h-10 w-full rounded-lg border border-border bg-background px-3 text-[13px]`,value:t?.id,onChange:e=>void n({to:`/settings/$section`,params:{section:e.target.value}}),"data-testid":`settings-section-picker`,children:$.map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.label},e.id))})}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsxs)(`nav`,{className:`hidden w-56 shrink-0 space-y-0.5 border-r border-border p-3 md:block`,children:[$.map(e=>(0,R.jsxs)(a,{to:`/settings/$section`,params:{section:e.id},className:w(`flex h-8 items-center gap-2.5 rounded-md px-2.5 text-[13px] text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground pointer-coarse:h-10`,e.id===t?.id&&`bg-accent text-foreground`),children:[(0,R.jsx)(e.icon,{className:w(`size-4`,e.id===t?.id&&`text-primary`)}),e.label]},e.id)),(0,R.jsx)(`div`,{className:`my-2 h-px bg-border`}),(0,R.jsxs)(a,{to:`/agents`,className:`flex h-8 items-center gap-2.5 rounded-md px-2.5 text-[13px] text-muted-foreground hover:bg-accent/60 hover:text-foreground`,children:[(0,R.jsx)(d,{className:`size-4`}),` Agent configuration`]}),(0,R.jsxs)(a,{to:`/setup`,className:`flex h-8 items-center gap-2.5 rounded-md px-2.5 text-[13px] text-muted-foreground hover:bg-accent/60 hover:text-foreground`,children:[(0,R.jsx)(ae,{className:`size-4`}),` First-run setup`]})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto scroll-thin`,children:(0,R.jsx)(`div`,{className:`mx-auto w-full max-w-3xl px-4 py-6 sm:px-8 sm:py-8`,children:t?.render()})})]})]})}export{Fn as SettingsPage};
@@ -1 +1 @@
1
- import{U as e,i as t}from"./api-B620HpC2.js";import{D as n,j as r,yt as i}from"./format-D1ma_o2D.js";import{t as a}from"./dist-wxbqfqV1.js";import{t as o}from"./jsx-runtime-C3cWAN_r.js";var s=o(),c=e();function l(){let e=t(),a=n(e=>e.settings,c),o=i({mutationFn:t=>e.updateSettings(t),onError:e=>r.error(`Setting not saved`,{description:e.message})});return{settings:a,update:e=>o.mutate(e)}}function u({title:e,description:t,children:n}){return(0,s.jsxs)(`section`,{className:`mb-10`,children:[(0,s.jsx)(`h2`,{className:`text-[15px] font-semibold tracking-tight`,children:e}),t&&(0,s.jsx)(`p`,{className:`mt-1 text-[13px] text-muted-foreground`,children:t}),(0,s.jsx)(`div`,{className:`mt-4 divide-y divide-border rounded-xl border border-border bg-card`,children:n})]})}function d({label:e,help:t,children:n,stacked:r=!1}){return(0,s.jsxs)(`div`,{className:a(`gap-4 px-4 py-3.5`,r?`space-y-3`:`flex items-center justify-between`),children:[(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`div`,{className:`text-[13.5px] font-medium`,children:e}),t&&(0,s.jsx)(`div`,{className:`mt-0.5 text-2xs leading-relaxed text-muted-foreground`,children:t})]}),(0,s.jsx)(`div`,{className:a(!r&&`shrink-0`),children:n})]})}function f({value:e,options:t,onChange:n}){return(0,s.jsx)(`div`,{className:`inline-flex h-8 items-center rounded-lg border border-border bg-background/50 p-0.5`,children:t.map(t=>(0,s.jsx)(`button`,{type:`button`,"aria-pressed":e===t.value,disabled:t.disabled,title:t.title,onClick:()=>n(t.value),className:a(`h-full rounded-md px-2.5 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:text-muted-foreground`,e===t.value&&`bg-accent text-foreground shadow-xs`),children:t.label},t.value))})}export{l as i,d as n,u as r,f as t};
1
+ import{U as e,i as t}from"./api-yvn34iKU.js";import{D as n,j as r,yt as i}from"./format-D3kairnQ.js";import{t as a}from"./dist-wxbqfqV1.js";import{t as o}from"./jsx-runtime-C3cWAN_r.js";var s=o(),c=e();function l(){let e=t(),a=n(e=>e.settings,c),o=i({mutationFn:t=>e.updateSettings(t),onError:e=>r.error(`Setting not saved`,{description:e.message})});return{settings:a,update:e=>o.mutate(e)}}function u({title:e,description:t,children:n}){return(0,s.jsxs)(`section`,{className:`mb-10`,children:[(0,s.jsx)(`h2`,{className:`text-[15px] font-semibold tracking-tight`,children:e}),t&&(0,s.jsx)(`p`,{className:`mt-1 text-[13px] text-muted-foreground`,children:t}),(0,s.jsx)(`div`,{className:`mt-4 divide-y divide-border rounded-xl border border-border bg-card`,children:n})]})}function d({label:e,help:t,children:n,stacked:r=!1}){return(0,s.jsxs)(`div`,{className:a(`gap-4 px-4 py-3.5`,r?`space-y-3`:`flex items-center justify-between`),children:[(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`div`,{className:`text-[13.5px] font-medium`,children:e}),t&&(0,s.jsx)(`div`,{className:`mt-0.5 text-2xs leading-relaxed text-muted-foreground`,children:t})]}),(0,s.jsx)(`div`,{className:a(!r&&`shrink-0`),children:n})]})}function f({value:e,options:t,onChange:n}){return(0,s.jsx)(`div`,{className:`inline-flex h-8 items-center rounded-lg border border-border bg-background/50 p-0.5`,children:t.map(t=>(0,s.jsx)(`button`,{type:`button`,"aria-pressed":e===t.value,disabled:t.disabled,title:t.title,onClick:()=>n(t.value),className:a(`h-full rounded-md px-2.5 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:text-muted-foreground`,e===t.value&&`bg-accent text-foreground shadow-xs`),children:t.label},t.value))})}export{l as i,d as n,u as r,f as t};