@puddle-code/cli 0.4.9 → 0.4.11

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 (94) hide show
  1. package/CHANGELOG.md +8 -47
  2. package/README.md +1 -1
  3. package/dist/host-control.mjs +13 -6
  4. package/dist/index.js +25 -9
  5. package/dist/public/assets/App-Btf7WD40.js +26 -0
  6. package/dist/public/assets/{CompilationCommandForm-CipGdjjH.js → CompilationCommandForm-DQjUhaHj.js} +1 -1
  7. package/dist/public/assets/Dashboard-CEjiJV52.js +1 -0
  8. package/dist/public/assets/EditorTabClose-CQnXn4Ha.js +1 -0
  9. package/dist/public/assets/FindWidget-Bh_7yWNg.js +1 -0
  10. package/dist/public/assets/LazyTerminal-Bw9C4Swp.js +2 -0
  11. package/dist/public/assets/{NotebookWidget-Bcavj7Lb.js → NotebookWidget-C25iz3Cj.js} +1 -1
  12. package/dist/public/assets/PaneEditorBody-BdoKPslR.js +284 -0
  13. package/dist/public/assets/{PdfViewer-Cr5306nr.js → PdfViewer-BH-FXEVV.js} +1 -1
  14. package/dist/public/assets/{ReleaseNotesDialog-CbFYKoYM.js → ReleaseNotesDialog-Pa1yagZd.js} +1 -1
  15. package/dist/public/assets/Ripple-DAeJ5ylo.css +1 -0
  16. package/dist/public/assets/Ripple-sD2osFo9.js +7 -0
  17. package/dist/public/assets/SettingsDialog-2WaxsH3h.js +8 -0
  18. package/dist/public/assets/Terminal-D8s2Y67v.js +65 -0
  19. package/dist/public/assets/Workspace-B8WZOpOl.js +20 -0
  20. package/dist/public/assets/{Workspace-Bf0VMnaa.css → Workspace-CuAYZ1-B.css} +1 -1
  21. package/dist/public/assets/{_virtual_notebook-widget-runtime-Dro422xS.js → _virtual_notebook-widget-runtime-CVsZLTbL.js} +88 -88
  22. package/dist/public/assets/{api-B90WKMKj.js → api-CULxlzTe.js} +1 -1
  23. package/dist/public/assets/archive-i9DnVa-v.js +1 -0
  24. package/dist/public/assets/arrow-down-CtYa-Aya.js +1 -0
  25. package/dist/public/assets/{auth-CdosKReE.js → auth-C3ruG3fE.js} +1 -1
  26. package/dist/public/assets/button-DtByPSFL.js +1 -0
  27. package/dist/public/assets/client-settings-BdKglwtW.js +1 -0
  28. package/dist/public/assets/command-CN8HRRWf.js +1 -0
  29. package/dist/public/assets/{context-CG70lLa4.js → context-D1MuDP6X.js} +1 -1
  30. package/dist/public/assets/desktop-Bl69_YmL.js +1 -0
  31. package/dist/public/assets/dialog-DtvE8ATK.js +41 -0
  32. package/dist/public/assets/{dist-Dge3wHdO.js → dist-BeQvHdsz.js} +1 -1
  33. package/dist/public/assets/dist-DZg8Dwbr.js +1 -0
  34. package/dist/public/assets/dist-KPX-s1ou.js +1 -0
  35. package/dist/public/assets/dist-a682-VMb.js +1 -0
  36. package/dist/public/assets/{errors-tuvbq1a_.js → errors-efDAjyqa.js} +1 -1
  37. package/dist/public/assets/expanding-content-DOZTeXd_.js +1 -0
  38. package/dist/public/assets/forward-link-CAXhnLYS.js +1 -0
  39. package/dist/public/assets/{index-Doe7MhnI.js → index-BuNmxuXx.js} +3 -3
  40. package/dist/public/assets/index-CHGSBAX2.css +2 -0
  41. package/dist/public/assets/link-buffer-CsjuZOHH.js +1 -0
  42. package/dist/public/assets/{markdown-CMSzQtLp.js → markdown-BlvTv1jG.js} +1 -1
  43. package/dist/public/assets/media-refresh-store-DCt4XZrY.js +1 -0
  44. package/dist/public/assets/motion-Bd_MB9cH.js +1 -0
  45. package/dist/public/assets/notification-delivery-BkhZwpcS.js +1 -0
  46. package/dist/public/assets/popover-4DSuF34m.js +1 -0
  47. package/dist/public/assets/preferences-CbkHsty9.js +1 -0
  48. package/dist/public/assets/{protocol-support-TSI4Ig6W.js → protocol-support-BwRR1kRO.js} +1 -1
  49. package/dist/public/assets/render-rich-content-DF6NaC_6.js +4 -0
  50. package/dist/public/assets/{scroll-restoration-6GVbekSz.js → scroll-restoration-wdDB8mmu.js} +1 -1
  51. package/dist/public/assets/select-D099Wd2u.js +1 -0
  52. package/dist/public/assets/session-order-s2zUuZaO.js +1 -0
  53. package/dist/public/assets/square-terminal-CIkfNq3I.js +1 -0
  54. package/dist/public/assets/switch-AY03lzhq.js +1 -0
  55. package/dist/public/assets/use-ui-state-BpnVbZPm.js +1 -0
  56. package/dist/public/assets/{view-state-store-DbQ7YOPe.js → view-state-store-DVvLMbeY.js} +1 -1
  57. package/dist/public/assets/waves-horizontal-CLDJf7Dd.js +1 -0
  58. package/dist/public/assets/whole-word-BJjKpISQ.js +1 -0
  59. package/dist/public/assets/ws-CS9chtfK.js +1 -0
  60. package/dist/public/assets/x-DV6-RYI2.js +1 -0
  61. package/dist/public/index.html +4 -4
  62. package/dist/pudl.js +13 -6
  63. package/package.json +1 -1
  64. package/dist/public/assets/App-UQXXCAJF.js +0 -65
  65. package/dist/public/assets/Dashboard-6pSi_1fH.js +0 -1
  66. package/dist/public/assets/EditorTabClose-TixDVxvl.js +0 -1
  67. package/dist/public/assets/FindWidget-DG1YP6Zx.js +0 -1
  68. package/dist/public/assets/LazyTerminal-B88WIvyh.js +0 -2
  69. package/dist/public/assets/NewProjectDialog-C1TVzOvJ.js +0 -1
  70. package/dist/public/assets/PaneEditorBody-DRA4WG0A.js +0 -284
  71. package/dist/public/assets/SettingsDialog-BvaE3Ue8.js +0 -8
  72. package/dist/public/assets/Terminal-Bo8hyZj7.js +0 -67
  73. package/dist/public/assets/Workspace-Bf2zQC6v.js +0 -20
  74. package/dist/public/assets/button-C_Rvtcwg.js +0 -1
  75. package/dist/public/assets/chevron-right-BEy-IXEZ.js +0 -1
  76. package/dist/public/assets/client-settings-DhfHheKR.js +0 -1
  77. package/dist/public/assets/command-BV8ZEhQz.js +0 -1
  78. package/dist/public/assets/context-menu-D3ZhKA9s.js +0 -1
  79. package/dist/public/assets/dialog-D-Axqpzg.js +0 -41
  80. package/dist/public/assets/dist-BmSuHjIq.js +0 -1
  81. package/dist/public/assets/dist-Cq-O0n8n.js +0 -1
  82. package/dist/public/assets/forward-link-BspnTVuc.js +0 -1
  83. package/dist/public/assets/index-4XrK4Fes.css +0 -2
  84. package/dist/public/assets/media-refresh-store-CiyvSvEu.js +0 -1
  85. package/dist/public/assets/motion-OSLfKoC0.js +0 -1
  86. package/dist/public/assets/notification-delivery-CegOQxcZ.js +0 -1
  87. package/dist/public/assets/popover-D-jcaKGN.js +0 -1
  88. package/dist/public/assets/select-p5KTVHbg.js +0 -1
  89. package/dist/public/assets/selection-actions-CvYaucrm.js +0 -1
  90. package/dist/public/assets/session-order-CiDVvIU5.js +0 -1
  91. package/dist/public/assets/switch-oBD5uCTu.js +0 -1
  92. package/dist/public/assets/use-ui-state-D4FsRK2R.js +0 -1
  93. package/dist/public/assets/ws-Cp1eCJaM.js +0 -1
  94. package/dist/public/assets/x-Dq6POV20.js +0 -1
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pdf-EQHMWEbX.js","assets/preload-helper-Czpn1I53.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{M as n}from"./auth-CdosKReE.js";import{t as r}from"./jsx-runtime-By8HlURe.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{n as a}from"./api-B90WKMKj.js";import{n as o}from"./dist-BOS6OKSE.js";import{t as s}from"./createLucideIcon-C9A1vLE-.js";import{t as c}from"./control-tray-c9uXOo-i.js";import{r as l,t as u}from"./view-state-store-DbQ7YOPe.js";import{t as d}from"./scroll-restoration-6GVbekSz.js";var f=s(`zoom-in`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`,key:`1vmskp`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),p=s(`zoom-out`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),m=e(t(),1),h=r();function g({page:e,scale:t}){let n=(0,m.useRef)(null),r=(0,m.useRef)(null),a=(0,m.useRef)(t);return a.current=t,(0,m.useLayoutEffect)(()=>{r.current?.update({viewport:e.getViewport({scale:t})})},[e,t]),(0,m.useEffect)(()=>{let t=n.current;if(!t)return;let o=!1,s=null;return i(async()=>{let{TextLayer:e}=await import(`./pdf-EQHMWEbX.js`);return{TextLayer:e}},__vite__mapDeps([0,1])).then(async({TextLayer:n})=>{o||(s=new n({textContentSource:e.streamTextContent(),container:t,viewport:e.getViewport({scale:a.current})}),await s.render(),!o&&(s.update({viewport:e.getViewport({scale:a.current})}),r.current=s))}).catch(e=>{o||(t.replaceChildren(),console.warn(`Couldn’t render PDF text`,e))}),()=>{o=!0,s?.cancel(),r.current=null,t.replaceChildren()}},[e]),(0,h.jsx)(`div`,{ref:n,className:`pdf-text-layer`,style:{"--total-scale-factor":t*e.userUnit}})}function _(e,t){let n=e.getBoundingClientRect(),r=t?.clientX??n.left+e.clientWidth/2,i=t?.clientY??n.top+e.clientHeight/2,a=null,o=1/0;for(let t of e.querySelectorAll(`[data-pdf-page]`)){let e=t.getBoundingClientRect(),n=Math.max(e.top-i,i-e.bottom,0);n<o&&(a=t,o=n)}if(!a)return null;let s=a.getBoundingClientRect();return!s.width||!s.height?null:{page:a,clientX:r,clientY:i,x:(r-s.left)/s.width,y:(i-s.top)/s.height}}function v(e,t){if(!e.contains(t.page))return;let n=t.page.getBoundingClientRect();e.scrollLeft+=n.left+t.x*n.width-t.clientX,e.scrollTop+=n.top+t.y*n.height-t.clientY}var y=[.5,.75,1,1.25,1.5,2,3],b=y[0],x=y.at(-1);function S(e){return k(e,b,x)}function C(e,t){return S(e*Math.exp(-t*.01))}function w(e,t,n){return S(t<=0||n<=0?e:n/t*e)}function T(e){let t=Math.round(S(e)*1e3)/10;return`${Number.isInteger(t)?t.toFixed(0):t.toFixed(1)}%`}function E(e,t){return t===`in`?y.find(t=>t>e+2**-52)??y.at(-1):[...y].reverse().find(t=>t<e-2**-52)??y[0]}function D(e,t,n,r=12e6){let i=Math.max(1,Math.min(n||1,2.5)),a=e*t;return a<=0||r<=0?1:Math.max(.25,Math.min(i,Math.sqrt(r/a)))}function O(e,t,n,r,i){if(n.width<=0||n.height<=0||r<=0||i<=0)return null;let a=k(e-n.left,0,n.width),o=k(t-n.top,0,n.height);return{x:a/n.width*r,y:o/n.height*i}}function k(e,t,n){return Math.min(n,Math.max(t,e))}var A=null,j=new u;function M({blob:e,session:t,path:r,root:i,onRevealSource:s,onDownload:c}){let u=l(`pdf`,[t,i,r]),f=(0,m.useRef)(null),p=(0,m.useRef)(null),g=(0,m.useRef)(null),y=(0,m.useRef)(null),[T,D]=(0,m.useState)(()=>j.get(u)??1),O=(0,m.useRef)(T),k=(0,m.useRef)(!1),[A,M]=(0,m.useState)(null),[R,U]=(0,m.useState)(!1),W=z(f);(0,m.useLayoutEffect)(()=>{let e=f.current,t=p.current;if(!e||!t||!A)return;let n=d(e,t,u,()=>t.isConnected&&!k.current&&t.querySelectorAll(`[data-scroll-ready="true"]`).length===A.numPages);return g.current=n,()=>{n.dispose(),g.current=null}},[A,u,W!==null]),(0,m.useLayoutEffect)(()=>{let e=f.current,t=y.current;e&&t&&v(e,t),y.current=null,k.current=!1,t&&g.current?.capture()},[T]);let G=(0,m.useCallback)((e,t)=>{let n=S(e);if(Math.abs(n-O.current)<2**-52)return;let r=f.current;y.current=r?_(r,t):null,O.current=n,j.set(u,n),k.current=!0,D(n)},[u]);(0,m.useEffect)(()=>{let e=f.current;if(!e)return;let t=null,n=t=>{if(!t.ctrlKey)return;t.preventDefault();let n=P(t,e.clientHeight);G(C(O.current,n),t)},r=e=>{if(e.touches.length!==2){t=null;return}t={distance:F(e.touches),zoom:O.current}},i=e=>{!t||e.touches.length!==2||(e.preventDefault(),G(w(t.zoom,t.distance,F(e.touches)),I(e.touches)))},a=e=>{e.touches.length<2&&(t=null)};return e.addEventListener(`wheel`,n,{passive:!1}),e.addEventListener(`touchstart`,r,{passive:!0}),e.addEventListener(`touchmove`,i,{passive:!1}),e.addEventListener(`touchend`,a,{passive:!0}),e.addEventListener(`touchcancel`,a,{passive:!0}),()=>{e.removeEventListener(`wheel`,n),e.removeEventListener(`touchstart`,r),e.removeEventListener(`touchmove`,i),e.removeEventListener(`touchend`,a),e.removeEventListener(`touchcancel`,a)}},[G]),(0,m.useEffect)(()=>{let t=!1,n=null,r=null;return M(null),U(!1),Promise.all([H(),e.arrayBuffer()]).then(([e,r])=>t?null:(n=e.getDocument({data:r}),n.promise)).then(e=>{if(e){if(r=e,t){n?.destroy();return}M(e)}}).catch(e=>{!t&&!V(e)&&U(!0)}),()=>{t=!0,M(null),r&&r.cleanup(),n&&n.destroy()}},[e]);let K=(0,m.useCallback)(async(e,c,l)=>{if(s)try{let o=await a(`POST`,`/api/latex/synctex`,{session:t,path:r,root:i,page:e,x:c,y:l});s(n.parse(o))}catch(e){o.error(e instanceof Error?e.message:`Couldn’t locate the TeX source`)}},[s,r,i,t]);return R?(0,h.jsxs)(B,{children:[(0,h.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Couldn’t display this PDF.`}),c&&(0,h.jsx)(`button`,{type:`button`,onClick:c,className:`rounded-md bg-elevated px-3 py-1.5 text-sm text-fg transition-colors hover:bg-border/70`,children:`Download`})]}):(0,h.jsxs)(`div`,{className:`relative h-full w-full bg-ground`,children:[(0,h.jsx)(`div`,{ref:f,role:`region`,"aria-label":`PDF document`,className:`h-full w-full overflow-auto`,children:!A||W===null?(0,h.jsx)(B,{children:(0,h.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Loading PDF…`})}):(0,h.jsx)(`div`,{ref:p,className:`flex min-h-full w-max min-w-full flex-col items-center gap-4 p-4`,children:Array.from({length:A.numPages},(e,t)=>(0,h.jsx)(L,{document:A,pageNumber:t+1,availableWidth:W*T,scrollRoot:f.current,inverseSearch:s?K:void 0},t+1))})}),A&&W!==null&&(0,h.jsx)(N,{zoom:T,minimum:b,maximum:x,onZoomOut:()=>G(E(T,`out`)),onReset:()=>G(1),onZoomIn:()=>G(E(T,`in`))})]})}function N({zoom:e,minimum:t,maximum:n,onZoomOut:r,onReset:i,onZoomIn:a}){let o=T(e);return(0,h.jsxs)(c,{variant:`overlay`,label:`PDF zoom`,className:`absolute right-3 top-3 z-10 shadow-sm`,children:[(0,h.jsx)(`button`,{type:`button`,disabled:e<=t,onClick:r,className:`cursor-pointer rounded-sm p-1 text-fg-muted transition-colors hover:bg-elevated hover:text-fg disabled:cursor-default disabled:opacity-40`,"aria-label":`Zoom out`,title:`Zoom out`,children:(0,h.jsx)(p,{className:`size-3.5`})}),(0,h.jsx)(`button`,{type:`button`,onClick:i,className:`min-w-12 cursor-pointer rounded-sm px-1.5 py-1 font-mono text-[11px] tabular-nums text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,"aria-label":`Zoom ${o}; reset to fit width`,title:`Reset to fit width`,children:o}),(0,h.jsx)(`button`,{type:`button`,disabled:e>=n,onClick:a,className:`cursor-pointer rounded-sm p-1 text-fg-muted transition-colors hover:bg-elevated hover:text-fg disabled:cursor-default disabled:opacity-40`,"aria-label":`Zoom in`,title:`Zoom in`,children:(0,h.jsx)(f,{className:`size-3.5`})})]})}function P(e,t){return e.deltaMode===WheelEvent.DOM_DELTA_LINE?e.deltaY*16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*t:e.deltaY}function F(e){let t=e.item(0),n=e.item(1);return!t||!n?0:Math.hypot(n.clientX-t.clientX,n.clientY-t.clientY)}function I(e){let t=e.item(0),n=e.item(1);if(!(!t||!n))return{clientX:(t.clientX+n.clientX)/2,clientY:(t.clientY+n.clientY)/2}}function L({document:e,pageNumber:t,availableWidth:n,scrollRoot:r,inverseSearch:i}){let a=(0,m.useRef)(null),o=(0,m.useRef)(null),s=(0,m.useRef)(null),[c,l]=(0,m.useState)(null),[u,d]=(0,m.useState)(null),[f,p]=(0,m.useState)(!1),_=R(a,r,t<=2);(0,m.useEffect)(()=>{let n=!1,r=null;return l(null),d(null),p(!1),e.getPage(t).then(e=>{if(r=e,n){e.cleanup();return}let t=e.getViewport({scale:1});d({width:t.width,height:t.height}),l(e)}).catch(e=>{!n&&!V(e)&&p(!0)}),()=>{n=!0,s.current?.cancel(),s.current=null,r?.cleanup()}},[e,t]),(0,m.useEffect)(()=>{let e=o.current;if(!e||!c||!u||!_)return;let t=n/u.width,r=c.getViewport({scale:t}),i=D(r.width,r.height,window.devicePixelRatio||1),a=c.getViewport({scale:t*i});s.current?.cancel(),e.width=Math.max(1,Math.floor(a.width)),e.height=Math.max(1,Math.floor(a.height)),e.style.width=`${r.width}px`,e.style.height=`${r.height}px`;let l=c.render({canvas:e,viewport:a});return s.current=l,l.promise.catch(e=>{V(e)||p(!0)}).finally(()=>{s.current===l&&(s.current=null)}),()=>{l.cancel(),s.current===l&&(s.current=null)}},[n,c,u,_]);let v=e=>{if(!e.metaKey&&!e.ctrlKey||!i||!u)return;let n=O(e.clientX,e.clientY,e.currentTarget.getBoundingClientRect(),u.width,u.height);n&&(e.preventDefault(),i(t,n.x,n.y))};if(f)return(0,h.jsxs)(`p`,{"data-scroll-ready":`true`,className:`py-8 text-xs text-fg-muted`,children:[`Couldn’t render page `,t,`.`]});let y=Math.round(u?n/u.width*u.height:n*1.3);return(0,h.jsxs)(`div`,{ref:a,"data-scroll-ready":u!==null,"data-pdf-page":t,className:`relative shrink-0 bg-elevated shadow-sm`,style:{width:n,height:y},"aria-label":`PDF page ${t}`,onClick:v,title:i?`Command-click to open the corresponding TeX source`:void 0,children:[(0,h.jsx)(`canvas`,{ref:o,className:`block`}),c&&u&&_&&(0,h.jsx)(g,{page:c,scale:n/u.width})]})}function R(e,t,n){let[r,i]=(0,m.useState)(n);return(0,m.useEffect)(()=>{if(r)return;let n=e.current;if(!n)return;let a=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(i(!0),a.disconnect())},{root:t,rootMargin:`100% 0px`});return a.observe(n),()=>a.disconnect()},[r,e,t]),r}function z(e){let[t,n]=(0,m.useState)(null);return(0,m.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=0,i=()=>{cancelAnimationFrame(r),r=requestAnimationFrame(()=>{t.clientWidth>32&&n(t.clientWidth-32)})};i();let a=new ResizeObserver(i);return a.observe(t),()=>{cancelAnimationFrame(r),a.disconnect()}},[e]),t}function B({children:e}){return(0,h.jsx)(`div`,{className:`flex h-full min-h-32 w-full flex-col items-center justify-center gap-3 p-4`,children:e})}function V(e){return e instanceof Error&&(e.name===`RenderingCancelledException`||e.name===`AbortException`)}async function H(){return A??=Promise.all([i(()=>import(`./pdf-EQHMWEbX.js`),__vite__mapDeps([0,1])),i(()=>import(`./pdf.worker.min-C8Ts8bNu.js`),[])]).then(([e,t])=>(e.GlobalWorkerOptions.workerSrc=t.default,e)).catch(e=>{throw A=null,e}),A}export{M as PdfViewer};
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{M as n}from"./auth-C3ruG3fE.js";import{t as r}from"./jsx-runtime-By8HlURe.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{n as a}from"./api-CULxlzTe.js";import{t as o}from"./createLucideIcon-C9A1vLE-.js";import{n as s}from"./dist-BOS6OKSE.js";import{t as c}from"./control-tray-c9uXOo-i.js";import{r as l,t as u}from"./view-state-store-DVvLMbeY.js";import{t as d}from"./scroll-restoration-wdDB8mmu.js";var f=o(`zoom-in`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`,key:`1vmskp`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),p=o(`zoom-out`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),m=e(t(),1),h=r();function g({page:e,scale:t}){let n=(0,m.useRef)(null),r=(0,m.useRef)(null),a=(0,m.useRef)(t);return a.current=t,(0,m.useLayoutEffect)(()=>{r.current?.update({viewport:e.getViewport({scale:t})})},[e,t]),(0,m.useEffect)(()=>{let t=n.current;if(!t)return;let o=!1,s=null;return i(async()=>{let{TextLayer:e}=await import(`./pdf-EQHMWEbX.js`);return{TextLayer:e}},__vite__mapDeps([0,1])).then(async({TextLayer:n})=>{o||(s=new n({textContentSource:e.streamTextContent(),container:t,viewport:e.getViewport({scale:a.current})}),await s.render(),!o&&(s.update({viewport:e.getViewport({scale:a.current})}),r.current=s))}).catch(e=>{o||(t.replaceChildren(),console.warn(`Couldn’t render PDF text`,e))}),()=>{o=!0,s?.cancel(),r.current=null,t.replaceChildren()}},[e]),(0,h.jsx)(`div`,{ref:n,className:`pdf-text-layer`,style:{"--total-scale-factor":t*e.userUnit}})}function _(e,t){let n=e.getBoundingClientRect(),r=t?.clientX??n.left+e.clientWidth/2,i=t?.clientY??n.top+e.clientHeight/2,a=null,o=1/0;for(let t of e.querySelectorAll(`[data-pdf-page]`)){let e=t.getBoundingClientRect(),n=Math.max(e.top-i,i-e.bottom,0);n<o&&(a=t,o=n)}if(!a)return null;let s=a.getBoundingClientRect();return!s.width||!s.height?null:{page:a,clientX:r,clientY:i,x:(r-s.left)/s.width,y:(i-s.top)/s.height}}function v(e,t){if(!e.contains(t.page))return;let n=t.page.getBoundingClientRect();e.scrollLeft+=n.left+t.x*n.width-t.clientX,e.scrollTop+=n.top+t.y*n.height-t.clientY}var y=[.5,.75,1,1.25,1.5,2,3],b=y[0],x=y.at(-1);function S(e){return k(e,b,x)}function C(e,t){return S(e*Math.exp(-t*.01))}function w(e,t,n){return S(t<=0||n<=0?e:n/t*e)}function T(e){let t=Math.round(S(e)*1e3)/10;return`${Number.isInteger(t)?t.toFixed(0):t.toFixed(1)}%`}function E(e,t){return t===`in`?y.find(t=>t>e+2**-52)??y.at(-1):[...y].reverse().find(t=>t<e-2**-52)??y[0]}function D(e,t,n,r=12e6){let i=Math.max(1,Math.min(n||1,2.5)),a=e*t;return a<=0||r<=0?1:Math.max(.25,Math.min(i,Math.sqrt(r/a)))}function O(e,t,n,r,i){if(n.width<=0||n.height<=0||r<=0||i<=0)return null;let a=k(e-n.left,0,n.width),o=k(t-n.top,0,n.height);return{x:a/n.width*r,y:o/n.height*i}}function k(e,t,n){return Math.min(n,Math.max(t,e))}var A=null,j=new u;function M({blob:e,session:t,path:r,root:i,onRevealSource:o,onDownload:c}){let u=l(`pdf`,[t,i,r]),f=(0,m.useRef)(null),p=(0,m.useRef)(null),g=(0,m.useRef)(null),y=(0,m.useRef)(null),[T,D]=(0,m.useState)(()=>j.get(u)??1),O=(0,m.useRef)(T),k=(0,m.useRef)(!1),[A,M]=(0,m.useState)(null),[R,U]=(0,m.useState)(!1),W=z(f);(0,m.useLayoutEffect)(()=>{let e=f.current,t=p.current;if(!e||!t||!A)return;let n=d(e,t,u,()=>t.isConnected&&!k.current&&t.querySelectorAll(`[data-scroll-ready="true"]`).length===A.numPages);return g.current=n,()=>{n.dispose(),g.current=null}},[A,u,W!==null]),(0,m.useLayoutEffect)(()=>{let e=f.current,t=y.current;e&&t&&v(e,t),y.current=null,k.current=!1,t&&g.current?.capture()},[T]);let G=(0,m.useCallback)((e,t)=>{let n=S(e);if(Math.abs(n-O.current)<2**-52)return;let r=f.current;y.current=r?_(r,t):null,O.current=n,j.set(u,n),k.current=!0,D(n)},[u]);(0,m.useEffect)(()=>{let e=f.current;if(!e)return;let t=null,n=t=>{if(!t.ctrlKey)return;t.preventDefault();let n=P(t,e.clientHeight);G(C(O.current,n),t)},r=e=>{if(e.touches.length!==2){t=null;return}t={distance:F(e.touches),zoom:O.current}},i=e=>{!t||e.touches.length!==2||(e.preventDefault(),G(w(t.zoom,t.distance,F(e.touches)),I(e.touches)))},a=e=>{e.touches.length<2&&(t=null)};return e.addEventListener(`wheel`,n,{passive:!1}),e.addEventListener(`touchstart`,r,{passive:!0}),e.addEventListener(`touchmove`,i,{passive:!1}),e.addEventListener(`touchend`,a,{passive:!0}),e.addEventListener(`touchcancel`,a,{passive:!0}),()=>{e.removeEventListener(`wheel`,n),e.removeEventListener(`touchstart`,r),e.removeEventListener(`touchmove`,i),e.removeEventListener(`touchend`,a),e.removeEventListener(`touchcancel`,a)}},[G]),(0,m.useEffect)(()=>{let t=!1,n=null,r=null;return M(null),U(!1),Promise.all([H(),e.arrayBuffer()]).then(([e,r])=>t?null:(n=e.getDocument({data:r}),n.promise)).then(e=>{if(e){if(r=e,t){n?.destroy();return}M(e)}}).catch(e=>{!t&&!V(e)&&U(!0)}),()=>{t=!0,M(null),r&&r.cleanup(),n&&n.destroy()}},[e]);let K=(0,m.useCallback)(async(e,c,l)=>{if(o)try{let s=await a(`POST`,`/api/latex/synctex`,{session:t,path:r,root:i,page:e,x:c,y:l});o(n.parse(s))}catch(e){s.error(e instanceof Error?e.message:`Couldn’t locate the TeX source`)}},[o,r,i,t]);return R?(0,h.jsxs)(B,{children:[(0,h.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Couldn’t display this PDF.`}),c&&(0,h.jsx)(`button`,{type:`button`,onClick:c,className:`rounded-md bg-elevated px-3 py-1.5 text-sm text-fg transition-colors hover:bg-border/70`,children:`Download`})]}):(0,h.jsxs)(`div`,{className:`relative h-full w-full bg-ground`,children:[(0,h.jsx)(`div`,{ref:f,role:`region`,"aria-label":`PDF document`,className:`h-full w-full overflow-auto`,children:!A||W===null?(0,h.jsx)(B,{children:(0,h.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Loading PDF…`})}):(0,h.jsx)(`div`,{ref:p,className:`flex min-h-full w-max min-w-full flex-col items-center gap-4 p-4`,children:Array.from({length:A.numPages},(e,t)=>(0,h.jsx)(L,{document:A,pageNumber:t+1,availableWidth:W*T,scrollRoot:f.current,inverseSearch:o?K:void 0},t+1))})}),A&&W!==null&&(0,h.jsx)(N,{zoom:T,minimum:b,maximum:x,onZoomOut:()=>G(E(T,`out`)),onReset:()=>G(1),onZoomIn:()=>G(E(T,`in`))})]})}function N({zoom:e,minimum:t,maximum:n,onZoomOut:r,onReset:i,onZoomIn:a}){let o=T(e);return(0,h.jsxs)(c,{variant:`overlay`,label:`PDF zoom`,className:`absolute right-3 top-3 z-10 shadow-sm`,children:[(0,h.jsx)(`button`,{type:`button`,disabled:e<=t,onClick:r,className:`cursor-pointer rounded-sm p-1 text-fg-muted transition-colors hover:bg-elevated hover:text-fg disabled:cursor-default disabled:opacity-40`,"aria-label":`Zoom out`,title:`Zoom out`,children:(0,h.jsx)(p,{className:`size-3.5`})}),(0,h.jsx)(`button`,{type:`button`,onClick:i,className:`min-w-12 cursor-pointer rounded-sm px-1.5 py-1 font-mono text-[11px] tabular-nums text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,"aria-label":`Zoom ${o}; reset to fit width`,title:`Reset to fit width`,children:o}),(0,h.jsx)(`button`,{type:`button`,disabled:e>=n,onClick:a,className:`cursor-pointer rounded-sm p-1 text-fg-muted transition-colors hover:bg-elevated hover:text-fg disabled:cursor-default disabled:opacity-40`,"aria-label":`Zoom in`,title:`Zoom in`,children:(0,h.jsx)(f,{className:`size-3.5`})})]})}function P(e,t){return e.deltaMode===WheelEvent.DOM_DELTA_LINE?e.deltaY*16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*t:e.deltaY}function F(e){let t=e.item(0),n=e.item(1);return!t||!n?0:Math.hypot(n.clientX-t.clientX,n.clientY-t.clientY)}function I(e){let t=e.item(0),n=e.item(1);if(!(!t||!n))return{clientX:(t.clientX+n.clientX)/2,clientY:(t.clientY+n.clientY)/2}}function L({document:e,pageNumber:t,availableWidth:n,scrollRoot:r,inverseSearch:i}){let a=(0,m.useRef)(null),o=(0,m.useRef)(null),s=(0,m.useRef)(null),[c,l]=(0,m.useState)(null),[u,d]=(0,m.useState)(null),[f,p]=(0,m.useState)(!1),_=R(a,r,t<=2);(0,m.useEffect)(()=>{let n=!1,r=null;return l(null),d(null),p(!1),e.getPage(t).then(e=>{if(r=e,n){e.cleanup();return}let t=e.getViewport({scale:1});d({width:t.width,height:t.height}),l(e)}).catch(e=>{!n&&!V(e)&&p(!0)}),()=>{n=!0,s.current?.cancel(),s.current=null,r?.cleanup()}},[e,t]),(0,m.useEffect)(()=>{let e=o.current;if(!e||!c||!u||!_)return;let t=n/u.width,r=c.getViewport({scale:t}),i=D(r.width,r.height,window.devicePixelRatio||1),a=c.getViewport({scale:t*i});s.current?.cancel(),e.width=Math.max(1,Math.floor(a.width)),e.height=Math.max(1,Math.floor(a.height)),e.style.width=`${r.width}px`,e.style.height=`${r.height}px`;let l=c.render({canvas:e,viewport:a});return s.current=l,l.promise.catch(e=>{V(e)||p(!0)}).finally(()=>{s.current===l&&(s.current=null)}),()=>{l.cancel(),s.current===l&&(s.current=null)}},[n,c,u,_]);let v=e=>{if(!e.metaKey&&!e.ctrlKey||!i||!u)return;let n=O(e.clientX,e.clientY,e.currentTarget.getBoundingClientRect(),u.width,u.height);n&&(e.preventDefault(),i(t,n.x,n.y))};if(f)return(0,h.jsxs)(`p`,{"data-scroll-ready":`true`,className:`py-8 text-xs text-fg-muted`,children:[`Couldn’t render page `,t,`.`]});let y=Math.round(u?n/u.width*u.height:n*1.3);return(0,h.jsxs)(`div`,{ref:a,"data-scroll-ready":u!==null,"data-pdf-page":t,className:`relative shrink-0 bg-elevated shadow-sm`,style:{width:n,height:y},"aria-label":`PDF page ${t}`,onClick:v,title:i?`Command-click to open the corresponding TeX source`:void 0,children:[(0,h.jsx)(`canvas`,{ref:o,className:`block`}),c&&u&&_&&(0,h.jsx)(g,{page:c,scale:n/u.width})]})}function R(e,t,n){let[r,i]=(0,m.useState)(n);return(0,m.useEffect)(()=>{if(r)return;let n=e.current;if(!n)return;let a=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(i(!0),a.disconnect())},{root:t,rootMargin:`100% 0px`});return a.observe(n),()=>a.disconnect()},[r,e,t]),r}function z(e){let[t,n]=(0,m.useState)(null);return(0,m.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=0,i=()=>{cancelAnimationFrame(r),r=requestAnimationFrame(()=>{t.clientWidth>32&&n(t.clientWidth-32)})};i();let a=new ResizeObserver(i);return a.observe(t),()=>{cancelAnimationFrame(r),a.disconnect()}},[e]),t}function B({children:e}){return(0,h.jsx)(`div`,{className:`flex h-full min-h-32 w-full flex-col items-center justify-center gap-3 p-4`,children:e})}function V(e){return e instanceof Error&&(e.name===`RenderingCancelledException`||e.name===`AbortException`)}async function H(){return A??=Promise.all([i(()=>import(`./pdf-EQHMWEbX.js`),__vite__mapDeps([0,1])),i(()=>import(`./pdf.worker.min-C8Ts8bNu.js`),[])]).then(([e,t])=>(e.GlobalWorkerOptions.workerSrc=t.default,e)).catch(e=>{throw A=null,e}),A}export{M as PdfViewer};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-By8HlURe.js";import{t as r}from"./purify.es-D8QhFVkO.js";import{i,o as a,r as o,s,t as c}from"./dialog-D-Axqpzg.js";import{a as l,i as u,n as d}from"./queue-BlrQxHDl.js";import{t as f}from"./markdown-CMSzQtLp.js";var p=e(t(),1),m=n();function h({markdown:e}){let t=(0,p.useId)().replace(/[^A-Za-z0-9_-]/g,``),n=(0,p.useMemo)(()=>{let n=r.sanitize(f(e,t),{RETURN_DOM_FRAGMENT:!0,USE_PROFILES:{html:!0},FORBID_TAGS:[`img`,`video`,`audio`,`source`,`iframe`,`object`,`embed`,`style`,`form`],FORBID_ATTR:[`style`,`src`,`srcset`,`poster`,`action`]});for(let e of n.querySelectorAll(`a`)){let t=e.getAttribute(`href`)??``;/^https?:\/\//i.test(t)?(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`)):t.startsWith(`#`)||e.removeAttribute(`href`)}let i=document.createElement(`div`);return i.append(n),{__html:i.innerHTML}},[e,t]);return(0,m.jsx)(`div`,{className:`md-preview text-sm text-fg-secondary`,onClick:e=>{let t=e.target.closest(`a`)?.getAttribute(`href`);if(t?.startsWith(`#`)){e.preventDefault();try{e.currentTarget.closest(`[role="dialog"]`)?.querySelector(`#${CSS.escape(decodeURIComponent(t.slice(1)))}`)?.scrollIntoView({block:`nearest`})}catch{}}},dangerouslySetInnerHTML:n})}function g(){let[e,t]=(0,p.useState)(!1);return(0,p.useLayoutEffect)(()=>{let e=()=>{let e=Array.from(document.querySelectorAll(`[role="dialog"], [role="alertdialog"], dialog[open]`)).some(e=>!e.hasAttribute(`data-release-notes`)&&!e.hidden&&e.getAttribute(`data-state`)!==`closed`);t(!e)},n=new MutationObserver(e);return n.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-state`,`hidden`,`open`,`role`]}),e(),()=>n.disconnect()},[]),e}function _({group:e}){return(0,p.useEffect)(()=>d.presented(e),[e]),null}function v({current:e}){let t=g(),n=l.flatMap(t=>{let n=e.entries.find(e=>e.component===t);return n?[n]:[]});return t?(0,m.jsx)(c,{open:!0,onOpenChange:t=>{t||d.dismiss(e)},children:(0,m.jsxs)(o,{wide:!0,className:`gap-6`,"data-release-notes":``,children:[(0,m.jsx)(_,{group:e}),(0,m.jsxs)(a,{children:[(0,m.jsxs)(s,{children:[`What’s new in `,e.version]}),(0,m.jsxs)(i,{children:[n.map(e=>u[e.component]).join(` · `),` release notes`]})]}),(0,m.jsx)(`nav`,{"aria-label":`Release note sections`,className:`flex flex-wrap gap-x-5 gap-y-2 text-sm`,children:n.map(e=>(0,m.jsx)(`a`,{className:`text-fg-muted hover:text-fg`,href:`#${e.component}`,onClick:t=>{t.preventDefault(),t.currentTarget.closest(`[role="dialog"]`)?.querySelector(`#${e.component}`)?.scrollIntoView({block:`nearest`})},children:u[e.component]},e.component))}),n.map(e=>(0,m.jsx)(`section`,{id:e.component,"aria-label":u[e.component],children:(0,m.jsx)(h,{markdown:e.markdown})},e.component))]})}):null}export{v as ReleaseNotesDialog};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-By8HlURe.js";import{t as r}from"./purify.es-D8QhFVkO.js";import{i,o as a,r as o,s,t as c}from"./dialog-DtvE8ATK.js";import{a as l,i as u,n as d}from"./queue-BlrQxHDl.js";import{t as f}from"./markdown-BlvTv1jG.js";var p=e(t(),1),m=n();function h({markdown:e}){let t=(0,p.useId)().replace(/[^A-Za-z0-9_-]/g,``),n=(0,p.useMemo)(()=>{let n=r.sanitize(f(e,t),{RETURN_DOM_FRAGMENT:!0,USE_PROFILES:{html:!0},FORBID_TAGS:[`img`,`video`,`audio`,`source`,`iframe`,`object`,`embed`,`style`,`form`],FORBID_ATTR:[`style`,`src`,`srcset`,`poster`,`action`]});for(let e of n.querySelectorAll(`a`)){let t=e.getAttribute(`href`)??``;/^https?:\/\//i.test(t)?(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`)):t.startsWith(`#`)||e.removeAttribute(`href`)}let i=document.createElement(`div`);return i.append(n),{__html:i.innerHTML}},[e,t]);return(0,m.jsx)(`div`,{className:`md-preview text-sm text-fg-secondary`,onClick:e=>{let t=e.target.closest(`a`)?.getAttribute(`href`);if(t?.startsWith(`#`)){e.preventDefault();try{e.currentTarget.closest(`[role="dialog"]`)?.querySelector(`#${CSS.escape(decodeURIComponent(t.slice(1)))}`)?.scrollIntoView({block:`nearest`})}catch{}}},dangerouslySetInnerHTML:n})}function g(){let[e,t]=(0,p.useState)(!1);return(0,p.useLayoutEffect)(()=>{let e=()=>{let e=Array.from(document.querySelectorAll(`[role="dialog"], [role="alertdialog"], dialog[open]`)).some(e=>!e.hasAttribute(`data-release-notes`)&&!e.hidden&&e.getAttribute(`data-state`)!==`closed`);t(!e)},n=new MutationObserver(e);return n.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-state`,`hidden`,`open`,`role`]}),e(),()=>n.disconnect()},[]),e}function _({group:e}){return(0,p.useEffect)(()=>d.presented(e),[e]),null}function v({current:e}){let t=g(),n=l.flatMap(t=>{let n=e.entries.find(e=>e.component===t);return n?[n]:[]});return t?(0,m.jsx)(c,{open:!0,onOpenChange:t=>{t||d.dismiss(e)},children:(0,m.jsxs)(o,{wide:!0,className:`gap-6`,"data-release-notes":``,children:[(0,m.jsx)(_,{group:e}),(0,m.jsxs)(a,{children:[(0,m.jsxs)(s,{children:[`What’s new in `,e.version]}),(0,m.jsxs)(i,{children:[n.map(e=>u[e.component]).join(` · `),` release notes`]})]}),(0,m.jsx)(`nav`,{"aria-label":`Release note sections`,className:`flex flex-wrap gap-x-5 gap-y-2 text-sm`,children:n.map(e=>(0,m.jsx)(`a`,{className:`text-fg-muted hover:text-fg`,href:`#${e.component}`,onClick:t=>{t.preventDefault(),t.currentTarget.closest(`[role="dialog"]`)?.querySelector(`#${e.component}`)?.scrollIntoView({block:`nearest`})},children:u[e.component]},e.component))}),n.map(e=>(0,m.jsx)(`section`,{id:e.component,"aria-label":u[e.component],children:(0,m.jsx)(h,{markdown:e.markdown})},e.component))]})}):null}export{v as ReleaseNotesDialog};
@@ -0,0 +1 @@
1
+ .puddle-terminal-ripple{flex-direction:column;gap:.75rem;min-height:0;display:flex}.puddle-terminal-ripple>.ripple-native{flex:0 0 38%;min-height:0;position:relative}.puddle-terminal-ripple:has(.ripple[data-alternate=true])>.ripple-native{flex:1}.ripple{min-height:0;color:var(--text-primary);font-family:var(--font-sans);flex-direction:column;flex:1;display:flex;position:relative}.ripple[data-alternate=true]{flex:none}.ripple-toolbar{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:.25rem;padding:.25rem .75rem;display:flex}.ripple-scroll{overscroll-behavior:contain;scrollbar-gutter:stable;overflow-anchor:none;flex:1;min-height:0;overflow:auto}.ripple-content{overflow-wrap:anywhere;max-width:48rem;margin-inline:auto;padding:1.25rem clamp(1rem,4%,3rem) 2.5rem;line-height:1.7}.ripple-note{color:var(--text-muted);margin-block:0 1.25rem;font-size:.75rem}.ripple-text{display:contents}.ripple-rich-display{margin-block:1rem;display:block;overflow-x:auto}.ripple-rich-display svg{max-width:100%;height:auto;margin-inline:auto;display:block}.ripple-prose .katex{font-size:1.1em}.ripple-prose .katex-error,.ripple-prose .mermaid-error{color:var(--danger)}.ripple-prose :is(p,ul,ol,pre,blockquote,table){margin-block:0 1rem}.ripple-prose :is(h1,h2,h3,h4,h5,h6){margin-block:1.5rem .75rem;font-weight:600;line-height:1.4}.ripple-prose h1{font-size:1.5em}.ripple-prose h2{font-size:1.25em}.ripple-prose ul{padding-left:1.5rem;list-style:outside}.ripple-prose ol{padding-left:1.5rem;list-style:decimal}.ripple-prose blockquote{color:var(--text-secondary);padding-left:1rem}.ripple-prose a{color:var(--text-gold);cursor:pointer;text-decoration:underline}.ripple-prose code{font-family:var(--font-mono);font-size:.85em}.ripple-prose pre{white-space:pre;line-height:1.5;overflow:auto}.ripple-prose th,.ripple-prose td{text-align:left;padding:.25rem .75rem}.ripple-prose hr{border:0;margin-block:1.5rem}.ripple-latest{position:absolute;bottom:.5rem;left:50%;transform:translate(-50%)}
@@ -0,0 +1,7 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{r as n,s as r}from"./theme-swfNLod9.js";import{t as i}from"./jsx-runtime-By8HlURe.js";import{t as a}from"./purify.es-D8QhFVkO.js";import"./katex.min-ZqdHjttS.js";import{n as o}from"./forward-link-CAXhnLYS.js";import{t as s}from"./button-DtByPSFL.js";import{t as c}from"./arrow-down-CtYa-Aya.js";import{t as l}from"./square-terminal-CIkfNq3I.js";import{t as u}from"./waves-horizontal-CLDJf7Dd.js";import{t as d}from"./control-tray-c9uXOo-i.js";import{n as f}from"./errors-efDAjyqa.js";import{n as p}from"./markdown-BlvTv1jG.js";import{n as m,r as h}from"./link-buffer-CsjuZOHH.js";import{n as g,r as _,t as v}from"./render-rich-content-DF6NaC_6.js";var y=e(t(),1),b=32768;function x(e,t){if(e.type===`alternate`)return{text:``,truncated:!1,alternate:!0,parts:[]};let n=e.length,r=Math.min(600,Math.floor(b/(t+1))),i=Math.max(0,n-r);for(;i<n&&e.getLine(i)?.isWrapped;)i++;let a=[],o=new Map,s=0,c=0;for(let r=i;r<n;r++){let n=m(e,r,t);if(!n)break;let i=!1,l=n.text.split(``).map((t,a)=>{let o=n.cells[a];return e.getLine(r)?.getCell(o.col)?.isInvisible?.()?(i=!0,` `):t}).join(``),u=e.getLine(r+1)?.isWrapped?l:l.trimEnd();if(s+u.length+1>32768)break;s+=u.length+1,!n.isWrapped&&a.length&&c++,o.set(r,{offset:c,cells:n.cells,length:u.length,concealed:i}),c+=u.length,n.isWrapped&&a.length?a[a.length-1]+=u:a.push(u)}let l=a.join(`
2
+ `).trimEnd(),u=[],d=0;for(let r of g(e,t,i,n-i)){let e=o.get(r.start.row),t=o.get(r.end.row);if(!e||!t||[...o.entries()].some(([e,t])=>e>=r.start.row&&e<=r.end.row&&t.concealed))continue;let n=e.cells.findIndex(e=>e.col>=r.start.col),i=t.cells.findLastIndex(e=>e.col<=r.end.col)+1;if(n<0||i===0)continue;let a=e.offset+Math.min(e.length,n),s=Math.min(l.length,t.offset+Math.min(t.length,i));a<d||s<=a||(a>d&&u.push({kind:`text`,source:l.slice(d,a)}),u.push({kind:r.kind,source:r.source,display:r.display}),d=s)}return d<l.length&&u.push({kind:`text`,source:l.slice(d)}),{text:l,truncated:i>0,alternate:!1,parts:u}}function S(e,t=!1,n=!1){let r=e.split(`
3
+ `),i=[],a=[],o=()=>{a.length&&i.push(p(a.join(`
4
+ `))),a=[]};for(let e=0;e<r.length;e++){let t=r[e],n=/^\s*(`{3,}|~{3,})(.*)$/.exec(t);if(n){o();let a=[t],s=!1;for(;++e<r.length;){let t=r[e];a.push(t);let i=/^\s*(`{3,}|~{3,})\s*$/.exec(t);if(i&&i[1][0]===n[1][0]&&i[1].length>=n[1].length){s=!0;break}}i.push(s?p(a.join(`
5
+ `)):C(a.join(`
6
+ `)))}else if(/^(?: {4}|\t)|[\u2500-\u257f]|\S {2,}\S/.test(t)){o();let n=[t];for(;e+1<r.length&&/^(?: {4}|\t)|[\u2500-\u257f]|\S {2,}\S/.test(r[e+1]);)n.push(r[++e]);i.push(C(n.join(`
7
+ `)))}else a.push(t)}o();let s=i.join(``);return t&&(s=s.replace(/^<p>([\s\S]*?)<\/p>\n?/,`$1`)),n&&(s=s.replace(/<p>((?:(?!<p>)[\s\S])*)<\/p>\n?$/,`$1`)),t&&/^\s/.test(e)&&(s=` ${s}`),n&&/\s$/.test(e)&&(s+=` `),s}function C(e){return`<pre><code>${e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}</code></pre>`}var w=i();function T({part:e,theme:t,active:n}){let r=(0,y.useRef)(null),{kind:i,source:a,display:o}=e;return(0,y.useEffect)(()=>{let e=r.current;if(!e||!n)return;let s=new AbortController;return e.textContent=a,v(e,{kind:i,source:a,display:o},t,s.signal).catch(()=>{s.signal.aborted||(e.textContent=a)}),()=>s.abort()},[a,i,o,t,n]),(0,w.jsx)(`span`,{ref:r,"data-ripple-rich":i,className:o?`ripple-rich-display`:void 0})}function E({terminal:e,stream:t,active:i,onDisable:p}){let[m,g]=(0,y.useState)(()=>x(e.buffer.active,e.cols)),v=(0,y.useRef)(null),b=(0,y.useRef)(!0),C=(0,y.useRef)(0),[E,D]=(0,y.useState)(!0),O=(0,y.useSyncExternalStore)(r,n,n);(0,y.useEffect)(()=>{if(!i)return;let t,n=()=>{clearTimeout(t),t=void 0;let n=window.getSelection(),r=n&&!n.isCollapsed&&v.current?.contains(n.anchorNode);if(e.buffer.active.type===`normal`&&(!b.current||r))return;let i=x(e.buffer.active,e.cols);g(e=>e.text===i.text&&e.truncated===i.truncated&&e.alternate===i.alternate?e:i)},r=()=>{t??=setTimeout(n,120)},a=[e.onWriteParsed(r),e.onResize(r),e.buffer.onBufferChange(()=>{b.current=!0,D(!0),n()})];return document.addEventListener(`selectionchange`,r),n(),()=>{clearTimeout(t),document.removeEventListener(`selectionchange`,r),a.forEach(e=>e.dispose())}},[e,i]);let k=(0,y.useMemo)(()=>m.parts.map((e,t)=>{let n=m.parts[t-1],r=m.parts[t+1];return e.kind===`text`?{__html:a.sanitize(S(e.source,n?.kind===`math`&&!n.display,r?.kind===`math`&&!r.display))}:null}),[m.parts]);return(0,y.useLayoutEffect)(()=>{let e=v.current,t=e?.firstElementChild;if(!e||!t||!i)return;let n=()=>{b.current&&(e.scrollTop=e.scrollHeight)},r=new ResizeObserver(n);return r.observe(t),n(),()=>r.disconnect()},[m,i]),(0,w.jsxs)(`section`,{className:`ripple`,"data-alternate":m.alternate,"aria-label":`Ripple reading view`,children:[(0,w.jsxs)(`div`,{className:`ripple-toolbar`,children:[(0,w.jsxs)(`span`,{className:`flex items-center gap-2 text-sm`,children:[(0,w.jsx)(u,{className:`size-4`}),` Ripple`,` `,(0,w.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Experimental`})]}),(0,w.jsxs)(d,{label:`Ripple controls`,children:[(0,w.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>e.focus(),children:`Type in CLI`}),(0,w.jsxs)(s,{variant:`ghost`,size:`sm`,onClick:p,children:[(0,w.jsx)(l,{}),` CLI only`]})]})]}),m.alternate?(0,w.jsx)(`p`,{className:`px-4 pb-3 text-xs text-fg-muted`,children:`This full-screen CLI needs the native terminal.`}):(0,w.jsx)(`div`,{ref:v,className:`ripple-scroll`,tabIndex:0,"aria-label":`Readable terminal output`,onWheel:()=>{C.current=Date.now()+1e3},onPointerDown:()=>{C.current=Date.now()+1e3},onPointerMove:e=>{e.buttons&&(C.current=Date.now()+1e3)},onKeyDown:e=>{[`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `].includes(e.key)&&(C.current=Date.now()+1e3)},onScroll:t=>{let n=t.currentTarget,r=b.current,i=n.scrollHeight-n.scrollTop-n.clientHeight<32;(i||Date.now()<C.current)&&(b.current=i),D(b.current),!r&&b.current&&g(x(e.buffer.active,e.cols))},onClick:e=>{let n=e.target.closest(`a`);if(!n)return;e.preventDefault();let r=n.getAttribute(`href`);r&&/^https?:\/\//i.test(r)&&o(_(r,t,h()!==null)).catch(f)},children:(0,w.jsxs)(`div`,{className:`ripple-content`,children:[m.truncated&&(0,w.jsx)(`p`,{className:`ripple-note`,children:`Recent output · Full history is available in the CLI.`}),m.text?(0,w.jsx)(`div`,{className:`ripple-prose`,children:m.parts.map((e,t)=>e.kind===`text`?(0,w.jsx)(`div`,{className:`ripple-text`,dangerouslySetInnerHTML:k[t]},t):(0,w.jsx)(T,{part:e,theme:O,active:i},t))}):(0,w.jsx)(`p`,{className:`ripple-note`,children:`Agent output will appear here. Type and approve requests in the CLI below.`})]})}),!m.alternate&&!E&&(0,w.jsxs)(s,{className:`ripple-latest`,variant:`secondary`,size:`sm`,onClick:()=>{b.current=!0,D(!0),g(x(e.buffer.active,e.cols)),v.current&&(v.current.scrollTop=v.current.scrollHeight)},children:[(0,w.jsx)(c,{}),` Latest output`]})]})}export{E as Ripple};
@@ -0,0 +1,8 @@
1
+ import{r as e,t}from"./rolldown-runtime-QTnfLwEv.js";import{t as n}from"./react-CZI7_Jkm.js";import{$ as r,A as i,B as a,Et as o,F as s,H as c,J as l,K as u,P as d,T as f,U as p,Y as m,Z as h,_t as g,at as _,ft as v,it as y,k as b,kt as x,lt as S,n as C,nt as w,o as T,st as ee,tt as E,u as te,ut as ne,vt as re}from"./protocol-support-BwRR1kRO.js";import{B as ie,G as ae,H as oe,Q as se,U as ce,V as le,_ as ue,g as de,h as fe,q as pe,v as me,y as he}from"./auth-C3ruG3fE.js";import{c as ge,i as _e,l as ve,r as ye,u as be}from"./LazyTerminal-Bw9C4Swp.js";import{A as xe,C as Se,E as Ce,M as we,O as Te,P as Ee,S as De,_ as Oe,a as ke,b as Ae,c as je,d as Me,f as Ne,i as Pe,k as Fe,l as Ie,m as Le,n as Re,o as ze,r as Be,s as Ve,t as He,u as Ue,v as We,x as Ge,y as Ke}from"./notification-delivery-BkhZwpcS.js";import{a as qe,i as Je,r as D,t as Ye}from"./client-settings-BdKglwtW.js";import{c as Xe,t as Ze}from"./theme-swfNLod9.js";import{t as Qe}from"./jsx-runtime-By8HlURe.js";import{r as $e}from"./index-BuNmxuXx.js";import{n as et,t as tt}from"./api-CULxlzTe.js";import{t as nt}from"./desktop-Bl69_YmL.js";import{n as O,t as k}from"./createLucideIcon-C9A1vLE-.js";import{a as A,i as j,n as rt,o as it,r as M,s as N,t as P}from"./dialog-DtvE8ATK.js";import{n as F}from"./dist-BOS6OKSE.js";import{a as at,i as I}from"./dist-a682-VMb.js";import{n as ot,r as st}from"./dist-BeQvHdsz.js";import{t as L}from"./button-DtByPSFL.js";import{a as ct,c as lt,i as ut,l as dt,n as ft,o as pt,r as mt,t as R,u as ht}from"./switch-AY03lzhq.js";import{a as z,i as B,n as V,r as H,t as U}from"./select-D099Wd2u.js";import{t as gt}from"./code-Cf4ftdOa.js";import{t as _t}from"./rotate-ccw-BI2k_h3A.js";import{t as vt}from"./x-DV6-RYI2.js";import{a as yt,g as bt,n as xt,o as St,p as Ct,r as wt,v as W}from"./ws-CS9chtfK.js";import{t as Tt}from"./control-tray-c9uXOo-i.js";import{n as G}from"./errors-efDAjyqa.js";import{t as Et}from"./use-debounced-value-C86N-mOK.js";import{n as Dt,r as Ot,t as kt}from"./popover-4DSuF34m.js";import{a as At,o as jt,r as Mt,t as Nt,u as Pt}from"./CompilationCommandForm-DQjUhaHj.js";var Ft=k(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),It=k(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),Lt=k(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Rt=k(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),zt=k(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),Bt=k(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),K=e(n(),1),q=Qe();function J({id:e,value:t,min:n,max:r,step:i,className:a,onCommit:o}){let[s,c]=(0,K.useState)(String(t));return(0,K.useEffect)(()=>c(String(t)),[t]),(0,q.jsx)(I,{id:e,type:`number`,min:n,max:r,step:i,className:a,value:s,onChange:e=>c(e.target.value),onBlur:()=>{let e=Number(s);if(s.trim()===``||!Number.isFinite(e)){c(String(t));return}let i=Math.min(r??e,Math.max(n??e,e));c(String(i)),i!==t&&o(i)},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}function Y({label:e,description:t,descriptionClassName:n,htmlFor:r,children:i,className:a}){return(0,q.jsxs)(`div`,{className:O(`flex items-center gap-4 py-2.5`,a),children:[(0,q.jsxs)(`label`,{htmlFor:r,className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`text-sm text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:O(`text-xs text-fg-muted`,n),children:t})]}),(0,q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:i})]})}function X({children:e,note:t}){return(0,q.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function Vt(){let e=Je(),[t,n]=(0,K.useState)(Xe());return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Appearance`}),(0,q.jsx)(Y,{label:`Theme`,children:(0,q.jsxs)(U,{value:t,onValueChange:e=>{n(e),Ze(e)},children:[(0,q.jsx)(B,{className:`w-32`,children:(0,q.jsx)(z,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(H,{value:`dark`,children:`Dark`}),(0,q.jsx)(H,{value:`light`,children:`Light`}),(0,q.jsx)(H,{value:`system`,children:`System`})]})]})}),(0,q.jsx)(Y,{label:`Cursor style`,children:(0,q.jsxs)(U,{value:e.cursorPackage,onValueChange:e=>D({cursorPackage:e}),children:[(0,q.jsx)(B,{className:`w-36`,children:(0,q.jsx)(z,{})}),(0,q.jsx)(V,{children:qe.map(e=>(0,q.jsx)(H,{value:e.id,children:e.label},e.id))})]})}),(0,q.jsx)(Y,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,q.jsx)(J,{id:`ui-font-size`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onCommit:e=>D({uiFontSize:e})})}),(0,q.jsx)(Y,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,q.jsx)(J,{id:`terminal-font-size`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onCommit:e=>D({terminalFontSize:e})})}),(0,q.jsx)(Y,{label:`Editor font size`,htmlFor:`editor-font-size`,children:(0,q.jsx)(J,{id:`editor-font-size`,min:9,max:32,step:.5,className:`w-20 tabular-nums`,value:e.editorFontSize,onCommit:e=>D({editorFontSize:e})})}),(0,q.jsx)(Y,{label:`Ripple (experimental)`,description:`Open agent sessions with a spacious reading view above the native CLI. Right-click a session to override this default.`,htmlFor:`ripple-enabled`,children:(0,q.jsx)(R,{id:`ripple-enabled`,checked:e.rippleEnabled===!0,onCheckedChange:e=>D({rippleEnabled:e})})}),(0,q.jsx)(Y,{label:`Density`,children:(0,q.jsxs)(U,{value:e.density,onValueChange:e=>D({density:e}),children:[(0,q.jsx)(B,{className:`w-36`,children:(0,q.jsx)(z,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(H,{value:`compact`,children:`Compact`}),(0,q.jsx)(H,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,q.jsx)(Y,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,q.jsx)(R,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>D({projectBasedLayout:e})})}),(0,q.jsx)(Y,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,q.jsx)(R,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>D({showAllProjectSessions:e})})}),(0,q.jsx)(Y,{label:`Reduced animation and motion`,htmlFor:`reduce-motion`,children:(0,q.jsx)(R,{id:`reduce-motion`,checked:e.reduceMotion,onCheckedChange:e=>D({reduceMotion:e})})}),(0,q.jsx)(Y,{label:`Show host when returning to the window`,description:`Briefly show the host icon and name when this window or browser tab regains focus.`,htmlFor:`show-host-on-focus`,children:(0,q.jsx)(R,{id:`show-host-on-focus`,checked:e.showHostOnFocus,onCheckedChange:e=>D({showHostOnFocus:e})})})]})}function Ht({profile:e}){let t=y(),[n,r]=(0,K.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>G(e)}),r(!1)},a=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>G(e)});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Icon`,children:(0,q.jsxs)(kt,{open:n,onOpenChange:r,children:[(0,q.jsx)(Ot,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,className:`flex size-9 items-center justify-center rounded-md text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(Fe,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,q.jsx)(Dt,{align:`end`,className:`w-72`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,title:`Default`,onClick:()=>i(null),className:O(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,!e.icon&&`bg-elevated text-fg`),children:(0,q.jsx)(Fe,{icon:null,colour:null,className:`size-4`})}),xe.map(({name:t,Icon:n})=>(0,q.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:O(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,e.icon===t&&`bg-elevated text-fg`),children:(0,q.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,q.jsx)(Y,{label:`Icon colour`,children:(0,q.jsx)(_e,{onCustomChange:a,value:e.icon_colour,onChange:a,label:`Icon colour`})})]})}var Ut=`__none__`;function Wt(){let e=W(),t=ne().data?.find(t=>t.id===e),n=b(e??void 0),r=S(e??void 0),i=y(),a=_(e??``),o=u(),[s,c]=(0,K.useState)(``),[l,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(!1),[m,h]=(0,K.useState)(``);if((0,K.useEffect)(()=>{t&&(c(t.name),d(t.branch_prefix))},[t]),!t)return null;let g=r.data?.default_account_id;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Profile`}),(0,q.jsxs)(Y,{label:`Name`,description:`Letters, digits, dot, underscore and hyphen.`,htmlFor:`profile-name`,children:[(0,q.jsx)(I,{id:`profile-name`,value:s,onChange:e=>c(e.target.value),className:`w-44`}),(0,q.jsx)(L,{size:`sm`,variant:`secondary`,disabled:s===t.name||s.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:s},{onError:e=>G(e)}),children:`Save`})]}),(0,q.jsxs)(Y,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,q.jsx)(I,{id:`branch-prefix`,value:l,onChange:e=>d(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,q.jsx)(L,{size:`sm`,variant:`secondary`,disabled:l===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:l},{onError:e=>G(e)}),children:`Save`})]}),(0,q.jsx)(Ht,{profile:t}),(0,q.jsx)(Y,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,q.jsxs)(U,{value:typeof g==`number`?String(g):Ut,onValueChange:e=>a.mutate({default_account_id:e===Ut?null:Number(e)},{onError:e=>G(e)}),children:[(0,q.jsx)(B,{className:`w-56`,children:(0,q.jsx)(z,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(H,{value:Ut,children:`First available`}),n.data?.map(e=>(0,q.jsx)(H,{value:String(e.id),children:(0,q.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,q.jsx)(Y,{label:`Delete profile`,description:`Non-archived sessions block deletion.`,className:`mt-4`,children:(0,q.jsx)(L,{variant:`danger`,size:`sm`,onClick:()=>p(!0),children:`Delete…`})}),(0,q.jsx)(P,{open:f,onOpenChange:e=>{e||(p(!1),h(``))},children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(it,{children:[(0,q.jsxs)(N,{children:[`Delete profile `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,q.jsx)(j,{children:`Everything this profile owns goes with it: projects, workspace layouts, accounts and their credential directories, and archived session history. Branches, repositories, and terminal logs on disk are untouched. This cannot be undone.`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(be,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,q.jsx)(I,{id:`delete-confirm-name`,value:m,onChange:e=>h(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(A,{children:[(0,q.jsx)(L,{variant:`ghost`,onClick:()=>{p(!1),h(``)},children:`Cancel`}),(0,q.jsx)(L,{variant:`danger`,disabled:m!==t.name||o.isPending,onClick:()=>o.mutate(t.id,{onSuccess:()=>{mt(),bt.set(null)},onError:e=>{p(!1),h(``),G(e)}}),children:`Delete profile`})]})]})})]})}function Gt({agent:e,profileId:t,onClose:n,onCreated:r}){let i=s(),[a,o]=(0,K.useState)(``),[c,u]=(0,K.useState)(``),d=l(Et(c,150)),f=c.trim(),p=f===``||f.startsWith(`/`)||f.startsWith(`~`),m=a.trim()!==``&&p,h=()=>{!m||i.isPending||i.mutate({profile_id:t,agent_type:e.id,label:a.trim(),...f===``?{}:{import_dir:f}},{onSuccess:e=>{n(),r(e,f!==``)},onError:e=>G(e)})};return(0,q.jsx)(P,{open:!0,onOpenChange:e=>!e&&n(),children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(it,{children:[(0,q.jsxs)(N,{children:[`Add a `,e.display_name,` account`]}),(0,q.jsxs)(j,{children:[`Accounts are isolated config dirs under this profile. Naming one is enough — Puddle creates it and takes you straight to `,e.display_name,`’s login. To reuse an account you already have on this machine, give its config directory: it is copied in and the original is never touched.`]})]}),(0,q.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),h()},children:[(0,q.jsx)(I,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,q.jsx)(ye,{value:c,onValueChange:u,placeholder:`(optional) existing config dir, e.g. ~/.claude`,hints:(d.data?.entries??[]).map(e=>({value:e.path,label:e.name}))})]}),(0,q.jsxs)(A,{children:[(0,q.jsx)(L,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,q.jsxs)(L,{disabled:!m||i.isPending,onClick:h,children:[(0,q.jsx)(st,{}),`Add account`]})]})]})})}function Kt({account:e,gateOpen:t,installed:n}){let i=r(),a=E(),o=p(),[s,c]=(0,K.useState)(null),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(e.label),m=(0,K.useRef)(null);return(0,K.useEffect)(()=>f(e.label),[e.label]),(0,q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`input`,{ref:m,value:d,onChange:e=>f(e.target.value),onBlur:()=>{let t=d.trim();if(t!==e.label){if(t===``){f(e.label);return}a.mutate({id:e.id,label:t},{onError:t=>{G(t),f(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(f(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full min-w-0 truncate rounded-sm bg-transparent px-1 py-0.5 text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,q.jsxs)(`button`,{type:`button`,title:`Rename account`,onClick:()=>{m.current?.focus(),m.current?.select()},className:`shrink-0 rounded-sm p-0.5 text-fg-muted transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(ge,{className:`size-3`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Rename account`})]})]}),(0,q.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-success`:`text-warning`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,q.jsx)(R,{checked:e.skip_permissions_default,onCheckedChange:t=>a.mutate({id:e.id,skip_permissions_default:t},{onError:e=>G(e)})})]}),(0,q.jsxs)(L,{size:`sm`,variant:`secondary`,disabled:i.isPending||!n,onClick:()=>i.mutate(e.id,{onSuccess:e=>c({stream:e.stream,hint:e.hint}),onError:e=>G(e)}),children:[(0,q.jsx)(Ee,{}),e.logged_in?`Re-login`:`Login`]}),(0,q.jsxs)(L,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>u(!0),children:[(0,q.jsx)(ot,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),s&&(0,q.jsx)(Se,{stream:s.stream,hint:s.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>c(null)}),(0,q.jsx)(P,{open:l,onOpenChange:u,children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(it,{children:[(0,q.jsxs)(N,{children:[`Delete `,(0,q.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,q.jsx)(j,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,q.jsxs)(A,{children:[(0,q.jsx)(L,{variant:`ghost`,onClick:()=>u(!1),children:`Cancel`}),(0,q.jsx)(L,{variant:`danger`,disabled:o.isPending,onClick:()=>o.mutate(e.id,{onSuccess:()=>u(!1),onError:e=>{u(!1),G(e)}}),children:`Delete account`})]})]})})]})}function qt(){let e=W(),t=i(),n=b(e??void 0),a=S(e??void 0),o=r(),[s,c]=(0,K.useState)(null),[l,u]=(0,K.useState)(null),d=a.data?.allowSkipPermissions===!0;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[],r=e.available!==!1;return(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(Y,{label:e.display_name,description:r?`Accounts are initialised in config dirs owned by this profile.`:`No ${e.binary??e.id} on the daemon’s PATH. Install it or add its directory to the agent search path in Sessions.`,className:`py-1`,children:(0,q.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.id})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,q.jsx)(Kt,{account:t,gateOpen:d&&e.capabilities.skip_permissions,installed:r},t.id)),(0,q.jsx)(`div`,{className:`flex`,children:(0,q.jsxs)(L,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>u(e),children:[(0,q.jsx)(st,{}),`Add account`]})})]})]},e.id)}),s&&(0,q.jsx)(Se,{stream:s.stream,label:s.label,hint:s.hint,onClose:()=>c(null)}),l!==null&&e!==null&&(0,q.jsx)(Gt,{agent:l,profileId:e,onClose:()=>u(null),onCreated:(e,t)=>{if(t){e.logged_in||F.info(`Imported without credentials — press Login to authenticate.`);return}o.mutate(e.id,{onSuccess:t=>c({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>G(e)})}})]})}function Jt(){let e=d(),t=w(),[n,r]=(0,K.useState)(``);return(0,K.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,q.jsx)(Y,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH; helps find agent CLIs like claude (e.g. ~/.local/bin).`,htmlFor:`agent-path`,children:(0,q.jsx)(I,{id:`agent-path`,type:`text`,className:`w-64 text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function Yt({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=Pt(e,n),o=n.sessionDefaults??{},[s,c]=(0,K.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,q.jsx)(Y,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,q.jsx)(I,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,q.jsx)(Y,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,q.jsx)(R,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,q.jsx)(Y,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`Start on working copy of the selected branch instead of sharing one directory.`,htmlFor:`${e}-default-dir`,children:(0,q.jsx)(R,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function Xt(){return(0,q.jsx)(Y,{label:`Terminal scrollback`,htmlFor:`scrollback`,children:(0,q.jsx)(J,{id:`scrollback`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:Je().terminalScrollback,onCommit:e=>D({terminalScrollback:e})})})}function Zt({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,K.useState)(r);return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,q.jsx)(at,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(L,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,q.jsx)(L,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var Qt={id:`4f3c2b1a-7e6d-5c4b-3a2f-1e0d9c8b7a6f`,title:null,agent_title:`Refactor the auth flow`,osc_title:`claude`,branch:`alice/refactor-auth`,worktree_path:`/home/alice/code/app--refactor-auth`,status:`waiting_input`,agent_type:`claude-code`};function $t({initial:e,onSave:t,pending:n}){let[r,i]=(0,K.useState)(e),a=r.length>0?r:ce;return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`tab-title-template`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Template`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Compose the label from the parts below. Empty falls back to the default.`})]}),(0,q.jsx)(I,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:ce}),(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,q.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:ft(Qt,a)})]}),(0,q.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:ae.map(([e,t])=>(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-24 shrink-0 font-mono text-fg-secondary`,children:`\${${e}}`}),(0,q.jsx)(`dd`,{className:`text-fg-muted`,children:t})]},e))}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(L,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,q.jsx)(L,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(ce),t(ce)},children:`Reset to default`})]})]})}function en(){let e=W(),t=ne().data?.find(t=>t.id===e),n=S(e??void 0),r=_(e??``),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(``),c=n.data?.allowSkipPermissions===!0,l=e=>r.mutate({allowSkipPermissions:e},{onSuccess:()=>{a(!1),s(``)},onError:e=>G(e)}),u=e=>t=>r.mutate({[e]:t},{onError:e=>G(e)});return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sessions`}),(0,q.jsx)(Y,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,q.jsx)(R,{id:`gate`,checked:c,onCheckedChange:e=>{e?a(!0):l(!1)}})}),(0,q.jsx)(Y,{label:`Capture exported env variables`,description:n.data?.captureSessionEnv===!1?`No variables are captured or injected; already-captured variabless are kept for when this is re-enabled.`:`Variables exported in a session persist and are re-injected upon terminal and agent restarts.`,htmlFor:`capture-env`,children:(0,q.jsx)(R,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:r.isPending,onCheckedChange:e=>r.mutate({captureSessionEnv:e},{onError:e=>G(e)})})}),(0,q.jsx)(Jt,{}),(0,q.jsx)(Xt,{}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`New session defaults`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Yt,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>G(e)}),pending:r.isPending},`${e}:agent-seed`),(0,q.jsx)(Yt,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>G(e)}),pending:r.isPending},`${e}:terminal-seed`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{note:`Sent to agent as opening message when a session (re)starts. You can make this empty.`,children:`Launch text`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Zt,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??le,defaultText:le,onSave:u(`onboardingTemplate`),pending:r.isPending},`${e}:onboarding`),(0,q.jsx)(Zt,{id:`concurrent-template`,label:`Existing / shared worktree`,description:`For a session joining a worktree other agents may already be working in.`,initial:n.data.concurrentTemplate??ie,defaultText:ie,onSave:u(`concurrentTemplate`),pending:r.isPending},`${e}:concurrent`),(0,q.jsx)(Zt,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??oe,defaultText:oe,onSave:u(`restartTemplate`),pending:r.isPending},`${e}:restart`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`Tab title`}),n.data&&(0,q.jsx)($t,{initial:n.data.tabTitleTemplate||"${name}",onSave:u(`tabTitleTemplate`),pending:r.isPending},`${e}:tab-title`)]}),(0,q.jsx)(P,{open:i,onOpenChange:e=>{e||(a(!1),s(``))},children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(it,{children:[(0,q.jsxs)(N,{className:`flex items-center gap-2`,children:[(0,q.jsx)(Lt,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,q.jsx)(j,{asChild:!0,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,q.jsx)(`p`,{children:`A prompt-free agent acts unattended, with your credentials, inside its worktree — and nothing technically stops a shell command from reaching outside it. It can:`}),(0,q.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,q.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,q.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,q.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,q.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,q.jsx)(`p`,{children:`Only open this gate if every account you opt in runs work you would trust a colleague to run unsupervised on this machine.`}),(0,q.jsx)(`p`,{className:`text-fg-muted`,children:`Opening it also records the agent’s own bypass-permissions acceptance for this profile’s accounts, so the skip actually takes effect.`})]})})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(be,{htmlFor:`confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,q.jsx)(I,{id:`confirm-name`,value:o,onChange:e=>s(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(A,{children:[(0,q.jsx)(L,{variant:`ghost`,onClick:()=>{a(!1),s(``)},children:`Cancel`}),(0,q.jsx)(L,{variant:`danger`,disabled:o!==t?.name||r.isPending,onClick:()=>l(!0),children:`Open the gate`})]})]})})]})}var tn=se.parse({});function nn(){let[e,t]=(0,K.useState)(Pe);return(0,K.useEffect)(()=>{let e=()=>t(Pe());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(Pe())]}function rn({permission:e,onRequest:t}){return e===`granted`||e===`unverified`?null:(0,q.jsxs)(`p`,{className:`pb-2 text-xs text-warning`,children:[e==="default"&&(0,q.jsxs)(q.Fragment,{children:[`The browser has not been asked for permission yet, so nothing will show —`,` `,(0,q.jsx)(`button`,{type:`button`,onClick:t,className:`underline underline-offset-2 transition-colors hover:text-fg`,children:`request it now`}),`.`]}),e===`denied`&&`Blocked by the browser — allow notifications for this site in its site settings, then return here.`,e===`unsupported`&&`This browser cannot show desktop notifications.`]})}function an(){let e=W(),t=S(e??void 0),n=_(e??``),r=v(e??void 0),[i,a]=nn(),o=Be(),[s,c]=(0,K.useState)(!1);(0,K.useEffect)(()=>{Re();let e=()=>void Re();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]);let l=se.catch(tn).parse(t.data?.notifications??{}),u=e=>n.mutate({notifications:e},{onError:e=>G(e)}),d=()=>{nt()?.showNotification||typeof Notification>`u`||Notification.requestPermission().then(a)};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Notifications`}),(0,q.jsx)(Y,{label:`Agent notifications`,htmlFor:`notify-desktop`,children:(0,q.jsx)(R,{id:`notify-desktop`,checked:l.desktop,onCheckedChange:e=>{e&&d(),u({...l,desktop:e})}})}),l.desktop&&(0,q.jsx)(rn,{permission:i,onRequest:d}),(0,q.jsx)(Y,{label:`Notify while interacting with a session`,htmlFor:`notify-focused`,description:`When off, typing or clicking in a session silences its desktop alerts for five seconds. Mobile Web Push is configured separately on each device.`,children:(0,q.jsx)(R,{id:`notify-focused`,checked:l.when_focused,onCheckedChange:e=>u({...l,when_focused:e})})}),(0,q.jsx)(Y,{label:`Test delivery`,description:`Send a notification to check this device’s permissions.`,children:(0,q.jsx)(L,{variant:`ghost`,disabled:s,onClick:()=>{c(!0),(async()=>{!nt()?.showNotification&&typeof Notification<`u`&&Notification.permission==="default"&&(await Notification.requestPermission(),a()),await He({id:`puddle-test`,title:`Puddle`,body:`Notifications are working on this device.`},()=>{})})().catch(G).finally(()=>c(!1))},children:s?`Sending…`:`Send test`})}),(0,q.jsx)(`p`,{role:`status`,className:`pb-2 text-xs text-fg-muted`,children:o.state===`shown`?`The system accepted the notification. Banner visibility also depends on Focus / Do Not Disturb.`:o.message??`Delivery has not been tested on this device.`}),(0,q.jsx)(Y,{label:`Sound`,htmlFor:`notify-sound`,children:(0,q.jsx)(R,{id:`notify-sound`,checked:l.sound,onCheckedChange:e=>u({...l,sound:e})})}),(0,q.jsx)(Y,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,q.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[l.muted_projects.length,` muted`]})}),(0,q.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.data?.map(e=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,q.jsx)(R,{checked:l.muted_projects.includes(e.id),onCheckedChange:t=>u({...l,muted_projects:t?[...l.muted_projects,e.id]:l.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function on(){let e=W(),t=C(c().data?.protocol),n=At(t&&e!==null),[r,i]=(0,K.useState)(null),a=n.data?.providers??[],o=a.find(e=>e.id===r)??a[0];return!t||!e?null:(0,q.jsxs)(`div`,{className:`mt-8`,children:[(0,q.jsx)(X,{note:`Defaults for this profile on the connected host. Individual files can override them from their tab menu.`,children:`Compilation & running code`}),n.isLoading?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Loading languages…`}):n.isError?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:`Couldn’t load languages.`}):o?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Language`,htmlFor:`compilation-language`,children:(0,q.jsxs)(U,{value:o.id,onValueChange:i,children:[(0,q.jsx)(B,{id:`compilation-language`,className:`w-48`,children:(0,q.jsx)(z,{})}),(0,q.jsx)(V,{children:a.map(e=>(0,q.jsx)(H,{value:e.id,detail:e.available?void 0:`Not installed`,children:e.display_name},e.id))})]})}),!o.available&&(0,q.jsxs)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:[`No supported `,o.display_name,` tool is installed on this host. Saved commands apply when a supported tool is available.`]}),(0,q.jsx)(sn,{request:{profile_id:e,provider:o.id}},`${e}:${o.id}`)]}):(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No languages advertised by this host.`})]})}function sn({request:e}){let t=jt(e),n=x();return t.isLoading?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Loading commands…`}):t.isError?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t.error instanceof Error?t.error.message:`Couldn’t load commands`}):t.data?(0,q.jsx)(Nt,{settings:t.data,onSave:async t=>{for(let r of t){let t=await Mt({...e,...r});n.setQueryData([`compilation-defaults`,e],t),await n.invalidateQueries({queryKey:[`compilation-settings`]})}}}):null}function cn(){let e=Je();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Editor`}),(0,q.jsx)(Y,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,q.jsx)(J,{id:`tab-size`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onCommit:e=>D({editorTabSize:e})})}),(0,q.jsx)(Y,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,q.jsx)(R,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>D({editorWordWrap:e})})}),(0,q.jsx)(Y,{label:`SSH host for editor links`,description:`Used for vscode:// and cursor:// remote links until the CLI supplies it automatically.`,htmlFor:`editor-link-host`,children:(0,q.jsx)(I,{id:`editor-link-host`,type:`text`,placeholder:$e.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>D({editorLinkSshHost:e.target.value})})}),(0,q.jsx)(on,{})]})}function ln({value:e,isDefault:t,onRecord:n,onReset:r}){let[i,a]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`button`,{type:`button`,"data-hotkey-recording":i||void 0,onClick:()=>a(!0),onBlur:()=>a(!1),onKeyDown:e=>{if(!i)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){a(!1);return}let t=yt(e.nativeEvent);t&&(n(t),a(!1))},className:O(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,i?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:i?`Press keys…`:St(e)}),!t&&(0,q.jsxs)(`button`,{type:`button`,title:`Reset to default`,onClick:r,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(_t,{className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function un(){let e=W(),t=S(e??void 0),n=_(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of xt){let t=i(e.id,Ct(e));a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>G(e)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>G(e)})};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Hotkeys`}),(0,q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed.`}),(0,q.jsx)(Y,{label:`App shortcuts in terminals`,description:t.data?.terminalAppShortcuts===!1?`A focused terminal receives these keys instead.`:`The shortcuts below work while a terminal is focused.`,htmlFor:`terminal-app-shortcuts`,className:`mb-4`,children:(0,q.jsx)(R,{id:`terminal-app-shortcuts`,checked:t.data?.terminalAppShortcuts!==!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({terminalAppShortcuts:e},{onError:e=>G(e)})})}),wt.map(e=>{let t=xt.filter(t=>t.group===e);return t.length===0?null:(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(`div`,{className:`mb-1 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e}),t.map(e=>{let t=i(e.id,Ct(e)),n=(a.get(t)??0)>1?`Conflicts with another shortcut.`:void 0;return(0,q.jsx)(Y,{label:e.label,description:n,descriptionClassName:n?`text-interrupted`:void 0,children:(0,q.jsx)(ln,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(e.id)})},e.id)})]},e)})]})}var dn=e=>[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);function fn(e,t){let[n,r]=(0,K.useState)(null),[i,a]=(0,K.useState)(!0),[o,s]=(0,K.useState)(``),c=(0,K.useRef)(0),l=(0,K.useRef)(null);(0,K.useEffect)(()=>()=>{c.current+=1},[]),(0,K.useEffect)(()=>{if(n)return;let e=!0;return l.current=null,a(!0),(async()=>{try{let t=dn(crypto.getRandomValues(new Uint8Array(32))),n=dn(new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(t))));e&&(l.current={code:t,challenge:n})}catch(t){e&&s(t instanceof Error?t.message:`Could not prepare sign-in.`)}finally{e&&a(!1)}})(),()=>{e=!1,l.current=null}},[n]);let u=(0,K.useRef)(t);return(0,K.useEffect)(()=>{u.current=t},[t]),(0,K.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>{c.current+=1,r(null),s(`Sign-in expired. Try again.`)},Math.max(0,n.request.expires-Date.now()));return()=>clearTimeout(e)},[n]),(0,K.useEffect)(()=>{if(!n||e)return;let t=c.current,i=!1,a,o=async()=>{try{if(n.request.expires<=Date.now())throw Error(`Sign-in expired. Try again.`);let{ready:e}=ue.parse(await et(`POST`,`/cockpit/remote/registration`,{service:n.request.service,code:n.code}));if(i||t!==c.current)return;if(n.request.expires<=Date.now())throw Error(`Sign-in expired. Try again.`);e?(r(null),await u.current({t:`enable`,registration:{service:n.request.service,app:n.request.app,code:n.code}})):a=setTimeout(()=>void o(),2e3)}catch(e){if(i||t!==c.current)return;r(null),s(e instanceof Error?e.message:`Sign-in failed. Try again.`)}};return a=setTimeout(()=>void o(),2e3),()=>{i=!0,clearTimeout(a)}},[n,e]),{attempt:n,preparing:i,error:o,begin:(t,n,i)=>{if(!(e||!l.current)){s(``);try{let{code:e,challenge:a}=l.current,o=de.safeParse({service:t.trim(),app:n.trim(),label:i.trim(),challenge:a,expires:Date.now()+me.invitationMs});if(!o.success)throw Error(`Enter a host name and exact HTTPS application and relay origins.`);let s=o.data,u=`${s.app}/#register=${encodeURIComponent(JSON.stringify(s))}`;c.current+=1,l.current=null,r({request:s,code:e,url:u}),window.open(u,`_blank`,`noopener,noreferrer`)}catch(e){s(e instanceof Error?e.message:`Could not start sign-in.`)}}},cancel:()=>{c.current+=1,l.current=null,a(!0),r(null)}}}function pn({service:e=`https://charles.waddlelabs.ai`,app:t=`https://puddle.waddlelabs.ai`,hostName:n,busy:r,disabled:i,enable:a,cancel:o}){let[s,c]=(0,K.useState)(e),[l,u]=(0,K.useState)(t),[d,f]=(0,K.useState)(n),p=fn(i,a),m=i||p.preparing||!!p.attempt;return(0,q.jsxs)(`form`,{className:`mt-4 space-y-4`,onSubmit:e=>{e.preventDefault(),m||p.begin(s,l,d)},children:[(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Application origin`,(0,q.jsx)(I,{type:`url`,required:!0,value:l,onChange:e=>u(e.target.value),placeholder:`https://app.example.com`,autoComplete:`off`,disabled:m})]}),(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Relay origin`,(0,q.jsx)(I,{type:`url`,required:!0,value:s,onChange:e=>c(e.target.value),placeholder:`https://relay.example.com`,autoComplete:`off`,disabled:m})]}),(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Host name`,(0,q.jsx)(I,{required:!0,maxLength:80,value:d,onChange:e=>f(e.target.value),disabled:m})]}),o&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Saving a new registration revokes existing browser approvals and invitations.`}),p.error&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:p.error}),p.attempt?(0,q.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,q.jsxs)(`p`,{role:`status`,children:[`Confirm this host in your browser. Match request`,` `,(0,q.jsx)(`strong`,{className:`font-mono`,children:p.attempt.request.challenge.slice(0,8).toUpperCase()}),`. Sign-in expires in five minutes.`]}),(0,q.jsx)(`a`,{href:p.attempt.url,target:`_blank`,rel:`noreferrer`,className:`text-accent hover:opacity-80`,children:`Continue in browser ↗`}),(0,q.jsx)(L,{type:`button`,variant:`ghost`,onClick:p.cancel,children:`Cancel sign-in`})]}):(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(L,{type:`submit`,disabled:m||!d.trim()||!s||!l,children:r?`Enabling…`:p.preparing?`Preparing sign-in…`:`Sign in and enable`}),o&&(0,q.jsx)(L,{type:`button`,variant:`ghost`,disabled:m,onClick:o,children:`Cancel`})]})]})}var mn=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),Z=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),hn=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),gn=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),_n=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),vn=t((e=>{var t=Z().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),yn=t((e=>{var t=Z().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),bn=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),xn=t((e=>{var t=hn(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),Sn=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Cn=t((e=>{var t=Sn();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),wn=t(((e,t)=>{var n=Cn();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),Tn=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),En=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
2
+ ]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^[0-9]+$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),Q=t((e=>{var t=Tn(),n=En();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),Dn=t((e=>{var t=Z(),n=xn(),r=hn(),i=Q(),a=Tn(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),On=t((e=>{var t=Z(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),kn=t(((e,t)=>{var n=Q();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),An=t(((e,t)=>{var n=Q(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),jn=t(((e,t)=>{var n=Q();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),Mn=t(((e,t)=>{var n=Q(),r=Z();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
3
+ Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),Nn=t(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),Pn=t((e=>{var t=Q(),n=kn(),r=An(),i=jn(),a=Mn(),o=En(),s=Z(),c=Nn();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
4
+ Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),Fn=t((e=>{var t=Z(),n=hn(),r=gn(),i=_n(),a=vn(),o=yn(),s=bn(),c=xn(),l=wn(),u=Dn(),d=On(),f=Q(),p=Pn();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
5
+ The chosen QR Code version cannot contain this amount of data.
6
+ Minimum version required to store current data is: `+c+`.
7
+ `);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),In=t((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||={};let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[+!!a[t*i+r]]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),Ln=t((e=>{var t=In();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),Rn=t((e=>{var t=In();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
8
+ `;return typeof a==`function`&&a(null,p),p}})),zn=e(t((e=>{var t=mn(),n=Fn(),r=Ln(),i=Rn();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1);function Bn({value:e,label:t}){let n=(0,K.useMemo)(()=>{try{let{modules:t}=zn.create(e),n=[];for(let e=0;e<t.size;e+=1)for(let r=0;r<t.size;r+=1)t.get(e,r)&&n.push(`M${r+4} ${e+4}h1v1h-1z`);return{size:t.size+8,path:n.join(``)}}catch{return null}},[e]);return n?(0,q.jsx)(`svg`,{role:`img`,"aria-label":t,"data-theme":`light`,className:`block h-auto max-w-full rounded-lg bg-paper text-fg`,xmlns:`http://www.w3.org/2000/svg`,width:280,height:280,viewBox:`0 0 ${n.size} ${n.size}`,shapeRendering:`crispEdges`,children:(0,q.jsx)(`path`,{fill:`currentColor`,d:n.path})}):(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`QR code unavailable. Use the pairing link.`})}function Vn({url:e,expires:t,dismiss:n}){let[r,i]=(0,K.useState)(``);return(0,K.useEffect)(()=>{let e=setTimeout(n,Math.max(0,t-Date.now()));return()=>clearTimeout(e)},[t,n]),(0,q.jsxs)(`section`,{className:`mt-5 space-y-3`,"aria-label":`Pairing invitation`,children:[(0,q.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`Scan or open this link on the new browser, then approve its exact identity below. Expires`,` `,new Date(t).toLocaleTimeString(),`.`]}),(0,q.jsx)(Bn,{value:e,label:`Pairing invitation QR code`}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(L,{variant:`secondary`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>i(`Pairing link copied.`)).catch(()=>i(`Could not copy. Open the pairing link or scan the QR code.`))},children:`Copy pairing link`}),(0,q.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`px-2 text-sm text-fg hover:opacity-80`,children:`Open pairing link ↗`}),(0,q.jsx)(L,{variant:`ghost`,onClick:n,children:`Hide invitation`})]}),r&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,role:`status`,children:r})]})}function Hn({devices:e,now:t,currentDevice:n,...r}){let i=e.filter(e=>e.status!==`revoked`).sort((e,t)=>Number(t.status===`pending`)-Number(e.status===`pending`));return(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[i.length===0&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`No browsers yet. Create a pairing invitation to add one.`}),i.map(e=>(0,q.jsx)(Un,{device:e,now:t,current:e.id===n,...r},e.id))]})}function Un({device:e,now:t,current:n,busy:r,approve:i,revoke:a,maintenance:o}){let s=e.status===`pending`,c=e.status===`approved`?Math.min(e.expires,e.lastUsed+me.idleMs):e.expires,l=c<=t,u=l?`Expired`:s?`Awaiting approval`:`Approved`,d=(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`p`,{className:`truncate text-sm text-fg`,title:e.label,children:e.label}),(0,q.jsxs)(`p`,{className:O(`text-2xs`,l?`text-fg-muted`:s?`text-warning`:`text-success`),children:[u,n&&(0,q.jsx)(`span`,{className:`text-fg-muted`,children:` · this browser`})]})]}),f=(0,q.jsxs)(`div`,{className:`mt-2 space-y-1 text-2xs text-fg-muted`,children:[(0,q.jsx)(`code`,{className:`block break-all text-fg-secondary`,children:e.peer}),(0,q.jsxs)(`p`,{children:[l?`Expired`:`Expires`,` `,new Date(c).toLocaleString()]})]});return(0,q.jsxs)(`article`,{"aria-label":e.label,className:`min-w-0 rounded-[var(--ui-radius)] bg-ground px-3 py-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[s?d:(0,q.jsx)(pt,{className:`min-w-0 flex-1`,summary:d,summaryClassName:`flex-row-reverse gap-2 [&>svg]:m-2`,children:f}),s&&!l&&(0,q.jsxs)(L,{variant:`secondary`,size:`sm`,disabled:r,onClick:()=>i(e.id),"aria-label":`Approve ${e.label}`,children:[(0,q.jsx)(Rt,{}),` Approve`]}),(0,q.jsx)(L,{variant:`ghost`,size:`icon`,className:`shrink-0 text-fg-muted`,disabled:r,"aria-label":`Revoke ${e.label}`,title:`Revoke browser`,onClick:()=>a(e.id),children:(0,q.jsx)(ot,{})})]}),s&&f,!s&&!l&&o&&(0,q.jsx)(L,{variant:`ghost`,size:`sm`,className:`mt-2`,disabled:r,onClick:()=>o(e.id,!e.maintenance),"aria-label":`${e.maintenance?`Revoke`:`Allow`} host maintenance for ${e.label}`,children:e.maintenance?`Revoke host maintenance`:`Allow host maintenance`})]})}function Wn({devices:e,now:t,busy:n,act:r,canManageMaintenance:i}){return(0,q.jsx)(pt,{className:`mt-6 text-sm`,summary:`Connected browsers`,summaryClassName:`py-2`,children:(0,q.jsxs)(`section`,{className:`space-y-3 pt-2`,"aria-label":`Browsers`,children:[(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Approval grants terminal control of this host. Compare the identity with the browser requesting access.`}),(0,q.jsx)(Hn,{devices:e,now:t,busy:n,approve:e=>void r({t:`approve`,id:e}),revoke:e=>void r({t:`revoke`,id:e}),maintenance:i?(e,t)=>void r({t:`maintenance`,id:e,enabled:t}):void 0}),(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Revocation detaches viewers; agents continue running. Browsers expire after 30 days of inactivity or 90 days overall.`}),i&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Host maintenance separately allows daemon and runtime software updates. Updates can affect every profile on this host. Pairing alone does not grant it or permission to restart other profiles' runtimes.`})]})})}function Gn({open:e,busy:t,error:n,onOpenChange:r,onConfirm:i}){return(0,q.jsx)(P,{open:e,onOpenChange:e=>!t&&r(e),children:(0,q.jsxs)(M,{children:[(0,q.jsx)(N,{children:`Delete this profile’s remote registration?`}),(0,q.jsx)(j,{children:`Disable remote access, remove the saved registration for this profile and revoke its browser approval and invitation. Agents keep running. Connecting again requires a new registration code and fresh browser approvals.`}),(0,q.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`This also removes this registration from its account’s remote host list. If the service is unavailable, removal finishes when it reconnects.`}),n&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:n}),(0,q.jsxs)(A,{children:[(0,q.jsx)(L,{variant:`ghost`,disabled:t,onClick:()=>r(!1),children:`Cancel`}),(0,q.jsx)(L,{variant:`danger`,disabled:t,onClick:i,children:t?`Deleting…`:`Delete registration`})]})]})})}function Kn(){let e=x(),t=h(),n=W(),r=ne().data?.find(e=>e.id===n)?.name??`this profile`,i=`/cockpit/remote?profile=${encodeURIComponent(n??``)}`,[a,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)(``),[u,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(!1),[m,g]=(0,K.useState)(!1),[_,v]=(0,K.useState)(!1),[y,b]=(0,K.useState)(null),S=(0,K.useCallback)(()=>b(null),[]),C=o({queryKey:[`cockpit-remote`,n],queryFn:async()=>fe.parse(await et(`GET`,i)),refetchInterval:!a&&5e3,refetchOnWindowFocus:!a,refetchOnReconnect:!a,retry:!1,gcTime:0,enabled:!!n}),w=async t=>{if(a||!n)return!1;s(!0),d(``),l(``);try{if(e.isFetching({queryKey:[`cockpit-remote`,n],exact:!0})){let e=await C.refetch({cancelRefetch:!1});if(e.isError)throw e.error}let r=he.parse(await et(`POST`,i,t));return t.t===`pair`&&r.url&&r.invitation?b({url:r.url,expires:r.invitation.expires}):(l({enable:`Remote access enabled.`,approve:`Browser approved.`,revoke:`Browser revoked.`,disable:`Remote access disabled. Agents continue running.`,delete_registration:`Registration deleted from this host. Agents continue running.`,reset:`Host identity rotated and all browsers revoked. Enable access and pair again.`,status:`Status refreshed.`,devices:`Browsers refreshed.`,pair:`Invitation created.`,maintenance:t.t===`maintenance`&&t.enabled?`Host maintenance allowed for this browser.`:`Host maintenance revoked for this browser.`}[t.t]),(t.t===`disable`||t.t===`reset`||t.t===`enable`||t.t===`delete_registration`)&&S()),(t.t===`enable`||t.t===`delete_registration`)&&p(!1),g(!1),v(!1),await C.refetch(),!0}catch(e){return d(e instanceof Error?e.message:`Host operation failed. Refresh status before retrying.`),await C.refetch(),!1}finally{s(!1)}},T=C.data,ee=C.error instanceof tt&&C.error.status===404,E=a||C.isError;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{note:`${r} on ${t.data?.displayName||t.data?.hostname||`this host`} · only this profile’s projects and sessions`,children:`Remote access`}),(0,q.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-3`,children:[(0,q.jsx)(`span`,{role:`status`,className:`text-sm font-medium`,children:C.isError?`Status unavailable`:T?T.availability===`ready`?T.configured?T.enabled?T.connected?`Connected to relay`:`Enabled · relay disconnected`:`Disabled`:`Not configured`:`Daemon upgrade required`:`Checking remote access…`}),(0,q.jsxs)(L,{variant:`ghost`,size:`sm`,disabled:a,onClick:()=>void C.refetch({cancelRefetch:!1}),children:[(0,q.jsx)(dt,{}),`Refresh status`]})]}),C.isError&&(0,q.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:ee?`This cockpit does not provide remote controls. Update Puddle and reopen this window.`:C.error.message}),u&&!_&&(0,q.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:u}),c&&(0,q.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-fg-secondary`,children:c}),T?.availability!==void 0&&T.availability!==`ready`&&(0,q.jsx)(`p`,{className:`mt-3 text-sm text-fg-secondary`,children:`Update the daemon on this host, then refresh status to set up mobile access.`}),T?.availability===`ready`&&(0,q.jsxs)(q.Fragment,{children:[!T.enabled&&T.supervisor&&(!T.configured||f)?(0,q.jsx)(pn,{service:T.service,app:T.app,hostName:`${t.data?.displayName||t.data?.hostname||`My host`} · ${r}`,busy:a,disabled:E,enable:w,cancel:T.configured?()=>p(!1):void 0},T.host??`new`):T.configured?(0,q.jsxs)(`dl`,{className:`mt-4 space-y-2 text-xs text-fg-secondary`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{className:`text-fg-muted`,children:`Application`}),(0,q.jsx)(`dd`,{className:`break-all`,children:(0,q.jsxs)(`a`,{href:T.app,target:`_blank`,rel:`noreferrer`,className:`hover:text-fg`,children:[T.app,` ↗`]})})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{className:`text-fg-muted`,children:`Relay`}),(0,q.jsx)(`dd`,{className:`break-all`,children:T.service})]}),T.peer&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{className:`text-fg-muted`,children:`Host identity`}),(0,q.jsx)(`dd`,{className:`break-all font-mono`,children:T.peer})]})]}):null,!T.enabled&&!T.supervisor&&(0,q.jsx)(`p`,{className:`mt-4 text-sm text-fg-secondary`,children:`This host needs persistent systemd or launchd supervision before access can be enabled here. For another supervisor, configure both the daemon and connector using the remote CLI commands.`}),T.configured&&(0,q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,role:`group`,"aria-label":`Registration actions`,children:[!T.enabled&&T.supervisor&&!f&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(L,{disabled:E,onClick:()=>void w({t:`enable`}),children:`Enable remote access`}),(0,q.jsx)(L,{variant:`ghost`,disabled:E,onClick:()=>p(!0),children:`Change registration`})]}),T.enabled&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(L,{disabled:E,onClick:()=>void w({t:`pair`}),children:`Pair a browser`}),(0,q.jsx)(L,{variant:`ghost`,disabled:E,onClick:()=>void w({t:`disable`}),children:`Disable remote access`})]}),T.canDeleteRegistration&&(0,q.jsx)(L,{variant:`ghost`,disabled:E,onClick:()=>{d(``),v(!0)},children:`Delete registration`})]}),y&&T.enabled&&(0,q.jsx)(Vn,{...y,dismiss:S}),T.configured&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Wn,{devices:T.devices,now:C.dataUpdatedAt,busy:E,act:w,canManageMaintenance:T.canManageMaintenance===!0}),(0,q.jsxs)(pt,{className:`text-sm`,summary:`Host identity recovery`,summaryClassName:`py-2`,children:[(0,q.jsx)(`p`,{className:`my-3 text-xs text-fg-muted`,children:`Rotate a lost or compromised host identity. This profile’s browser approvals and invitations will be revoked.`}),(0,q.jsx)(L,{variant:`ghost`,disabled:E,onClick:()=>g(!0),children:`Reset host identity…`})]})]})]}),(0,q.jsx)(P,{open:m,onOpenChange:e=>!a&&g(e),children:(0,q.jsxs)(M,{children:[(0,q.jsx)(N,{children:`Reset this profile’s remote identity?`}),(0,q.jsx)(j,{children:`Disable remote access, rotate the host identity and revoke this profile’s paired browsers and invitation. Agents keep running. Enable access and pair each browser again afterwards.`}),(0,q.jsxs)(A,{children:[(0,q.jsx)(L,{variant:`ghost`,disabled:a,onClick:()=>g(!1),children:`Cancel`}),(0,q.jsx)(L,{variant:`danger`,disabled:a,onClick:()=>void w({t:`reset`}),children:`Reset host identity`})]})]})}),(0,q.jsx)(Gn,{open:_,busy:a,error:u,onOpenChange:v,onConfirm:()=>void w({t:`delete_registration`})})]})}var qn=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,$=65,Jn=Object.fromEntries([...qn].map((e,t)=>[e,t])),Yn=`H`,Xn=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let n=t;for(let e=0;e<8;e+=1)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function Zn(e){let t=4294967295;for(let n of e)t=Xn[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function Qn(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function $n(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}async function er(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function tr(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function nr(e,t){let n=(t%$+$)%$,r=``;for(let t of e){let e=Jn[t];r+=e===void 0?t:qn[(e+n)%$]}return r}async function rr(e){let t=await er(JSON.stringify(e));return nr(Qn(t)+Zn(t),1+Math.floor(Math.random()*($-1)))}async function ir(e){let t=e.trim(),n=t[0];if(!n||Jn[n]===void 0)throw Error(`Not a settings export.`);let r=nr(t,-((Jn[n]-Jn[Yn]+$)%$));if(r.length<9||r[0]!==Yn)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=$n(i);if(Zn(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await tr(o))}var ar=`puddle.sync-selection`;function or(){try{let e=JSON.parse(localStorage.getItem(ar)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return je.map(e=>e.id)}function sr({selected:e,onToggle:t}){return(0,q.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:je.map(n=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(R,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function cr(){let e=W(),t=S(e??void 0),n=ne().data?.find(t=>t.id===e),r=re(e??void 0,void 0),i=_(e??``),o=y(),s=a(),c=ze(),l=Ve(),[u,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(``),[m,h]=(0,K.useState)(!1),[g,v]=(0,K.useState)(or),b=n&&c.data?ke(c.data.file,n.name):void 0,x=b?.enabled===!0,C=x&&b?b.groups:g,w=()=>({client:Ye(),theme:Xe(),profileSettings:t.data??{},profile:n??{},scratchpad:r.data??[]}),T={setClient:e=>D(e),setTheme:e=>{typeof e==`string`&&Ze(e)},patchProfileSettings:e=>i.mutate(e,{onError:e=>G(e)}),patchProfileColumns:t=>{e&&o.mutate({id:e,...t},{onError:e=>G(e)})},createScratchpad:t=>{if(e)for(let n of t)s.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},ee=(e,t)=>{n&&l.mutate({profile:n.name,entry:{enabled:e.enabled??x,groups:t,doc:Ue(t,w()),updatedAt:new Date().toISOString()}},{onError:e=>G(e)})},E=(e,t)=>{let n=t?[...C,e]:C.filter(t=>t!==e);v(n),localStorage.setItem(ar,JSON.stringify(n)),x&&ee({},n)},te=async()=>{h(!0);try{let e=Ie(await ir(u.trim()),T,{profileSettings:t.data??{},scratchpad:r.data??[]});e.length===0?F.error(`Nothing recognised to import.`):(F.success(`Imported ${e.join(`, `)}.`),d(``))}catch(e){F.error(e.message)}finally{h(!1)}},ie=async()=>{h(!0);try{let e=await rr(Ue(C,w()));p(e),await navigator.clipboard?.writeText(e),F.success(`Copied to clipboard`)}finally{h(!1)}};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sync`}),(0,q.jsx)(`p`,{className:`mb-5 text-xs text-fg-muted`,children:`Carry your settings between machines. Accounts, repositories, and anything host-specific are never included. Applies to this profile.`}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Sync locally`}),c.data?.available===!1?(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:`Not available in this cockpit — start the UI with the Puddle CLI to sync across windows.`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:[`Sync selected groups through this machine’s`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:`~/.puddle`}),`, so every Puddle window stays in step for profiles named`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:n?.name??`…`}),`.`]}),(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(R,{checked:x,disabled:!n||c.isLoading||l.isPending,onCheckedChange:e=>ee({enabled:e},C)}),`Sync locally`]})]})]}),(0,q.jsx)(pt,{className:`mb-6`,summary:`Choose what to sync`,summaryClassName:`text-xs`,children:(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(sr,{selected:C,onToggle:E})})}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,q.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:`Builds a Puddle magic string that encodes settings from the checklist above.`}),(0,q.jsx)(L,{size:`sm`,disabled:m,onClick:()=>void ie(),children:`Export & copy`}),f&&(0,q.jsx)(at,{readOnly:!0,value:f,rows:3,spellCheck:!1,onFocus:e=>e.currentTarget.select(),className:`mt-2 resize-y font-mono text-xs`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Import`}),(0,q.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:`Paste a Puddle magic string to import its settings.`}),(0,q.jsx)(at,{value:u,onChange:e=>d(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:`Paste a settings export…`,rows:3,spellCheck:!1,className:`resize-y font-mono text-xs`}),(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(L,{size:`sm`,disabled:!u.trim()||m,onClick:()=>void te(),children:`Import`})})]})]})}function lr(){return(0,q.jsxs)(`div`,{className:`space-y-8`,children:[(0,q.jsx)(Kn,{},W()),(0,q.jsx)(cr,{})]})}function ur({repo:e}){let t=ee(),n=m(),r=te(c().data?.protocol),[i,a]=(0,K.useState)(e.default_base_branch),[o,s]=(0,K.useState)(e.onboarding_notes??``),l=e=>G(e);return(0,q.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.path}),(0,q.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted tabular-nums`,children:e.last_fetched_at?`fetched ${new Date(e.last_fetched_at).toLocaleString()}`:`never fetched`}),(0,q.jsxs)(L,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>F.success(`Fetched.`),onError:l}),children:[(0,q.jsx)(dt,{}),`Fetch now`]})]}),(0,q.jsxs)(Y,{label:`Default base branch`,description:r?`Blank = the branch checked out at the clone location when each agent or terminal is created.`:`Choose a branch. Update the host to allow a blank default that follows the clone.`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,q.jsx)(I,{id:`base-${e.id}`,placeholder:r?`current clone branch`:void 0,value:i,onChange:e=>a(e.target.value),className:`w-40`}),(0,q.jsx)(L,{size:`sm`,variant:`secondary`,disabled:i.trim()===e.default_base_branch||t.isPending||!r&&!i.trim(),onClick:()=>t.mutate({id:e.id,default_base_branch:i.trim()},{onError:l,onSuccess:()=>a(i.trim())}),children:`Save`})]}),(0,q.jsx)(Y,{label:`Periodic fetch`,description:`Fetched on open and on the daemon's interval while sessions are active.`,htmlFor:`fetch-${e.id}`,className:`py-1.5`,children:(0,q.jsx)(R,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:l})})}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`notes-${e.id}`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Onboarding notes`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Standing setup rules, injected into every fresh worktree. Agents update them via .puddle/onboarding-notes.md.`})]}),(0,q.jsx)(at,{id:`notes-${e.id}`,value:o,onChange:e=>s(e.target.value),rows:4}),(0,q.jsx)(`div`,{children:(0,q.jsx)(L,{size:`sm`,variant:`secondary`,disabled:o===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:o},{onError:l}),children:`Save notes`})})]}),e.orphan_worktrees.length>0&&(0,q.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,q.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Orphan worktrees — directories no session claims. Puddle never deletes these automatically; remove them by hand if unwanted.`}),(0,q.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,q.jsx)(`li`,{className:`truncate text-2xs text-fg-muted`,children:e},e))})]})]})}function dr(){let e=g();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Projects`}),e.data?.length===0&&(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No projects yet — create one from the dashboard, pointing at a repository.`}),e.data?.map(e=>(0,q.jsx)(ur,{repo:e},e.id))]})}function fr(){let e=W(),t=c(),n=S(e??void 0),r=_(e??``),[i,a]=(0,K.useState)(!1);if(!e||!n.data)return null;let o=n.data.hostIcon,s=n.data.hostColour,l=e=>{r.mutate({hostIcon:e},{onError:G}),a(!1)},u=e=>r.mutate({hostColour:e},{onError:G});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Icon`,children:(0,q.jsxs)(kt,{open:i,onOpenChange:a,children:[(0,q.jsx)(Ot,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,"data-host-colour":s??void 0,className:`host-identity flex size-9 items-center justify-center rounded-md transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(Ce,{icon:o,className:`size-5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Choose a host icon`})]})}),(0,q.jsx)(Dt,{align:`end`,className:`w-72`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,title:`Default host icon`,"aria-pressed":!o,onClick:()=>l(null),className:O(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,!o&&`bg-nav-selection text-nav-selection-ink`),children:(0,q.jsx)(Ce,{icon:null,className:`size-4`})}),Te.map(({name:e,Icon:t})=>(0,q.jsx)(`button`,{type:`button`,title:e,"aria-pressed":o===e,onClick:()=>l(e),className:O(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,o===e&&`bg-nav-selection text-nav-selection-ink`),children:(0,q.jsx)(t,{className:`size-4`})},e))]})})]})}),(0,q.jsx)(Y,{label:`Accent`,children:(0,q.jsx)(_e,{onCustomChange:T(t.data?.protocol)?u:void 0,value:s,onChange:u,label:`Host accent`})})]})}function pr({status:e,reply:t,disabled:n,offlineDisabled:r,act:i}){let a=e.result?.operation;if(!a)return null;let o={id:a.id,revision:a.revision},s=Ge(e,t),c=Ke(e),l=t?.ok&&t.operation?.id===a.id&&t.operation.revision===a.revision?t.review:void 0,u=pe(a.phase);return(0,q.jsxs)(`div`,{className:`mt-5 space-y-3 text-sm`,children:[(0,q.jsxs)(`p`,{role:`status`,className:`font-medium`,children:[e.observation===`recorded`&&`Recorded status: `,Ae[a.phase]]}),e.observation===`recorded`&&(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Last recorded change: `,new Date(a.updated_at).toLocaleString(),`. This record does not confirm current service health or runtime adoption.`]}),(0,q.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:a.targets.map(({component:e,version:t})=>`${e===`daemon`?`Daemon`:`Runtime software`} ${t}`).join(` · `)}),a.message&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.message}),s&&(0,q.jsxs)(`p`,{className:`text-xs text-fg-secondary`,children:[`Existing persistent runtimes keep running.`,` `,a.targets.some(({component:e})=>e===`daemon`)?`This window briefly reconnects while the daemon is replaced.`:`New runtimes will use the updated software.`]}),l&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`text-xs text-fg-secondary`,children:[`Daemon-owned work affected: `,l.affected.terminals,` terminals,`,` `,l.affected.notebooks,` notebook kernels, `,l.affected.compilation,` compilation jobs/watchers, `,l.affected.programmes,` programmes.`]}),l.interruption_fingerprint&&(0,q.jsx)(`p`,{className:`text-xs text-warning`,children:`Applying interrupts the listed work. Shell jobs and in-memory kernel state will be lost; interrupted programmes are not replayed.`}),l.blockers.filter(({code:e})=>e!==`interruption_approval_required`).map(({code:e},t)=>(0,q.jsx)(`p`,{className:`text-xs text-warning`,children:e===`runtime_lifetime_unverified`?`A runtime has a limited or unverified host lifetime. Daemon replacement is blocked while it runs. Updating also requires a supported host service manager.`:`Check failed: ${e.replaceAll(`_`,` `)}`},`${e}-${t}`)),l.more_blockers>0&&(0,q.jsxs)(`p`,{className:`text-xs text-warning`,children:[l.more_blockers,` additional checks failed.`]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[c&&(0,q.jsx)(L,{size:`sm`,disabled:r,onClick:()=>i(c),children:`Continue recovery on host`}),We(a)&&(0,q.jsx)(L,{variant:`ghost`,size:`sm`,disabled:n,onClick:()=>i({action:`inspect`,reference:o}),children:l?`Check again`:`Review impact`}),s&&(0,q.jsx)(L,{size:`sm`,variant:s.interruption_approval?`danger`:`default`,disabled:n,onClick:()=>i(s),children:s.interruption_approval?`Interrupt listed work and apply`:`Apply update`}),!u&&!a.dispatched&&(0,q.jsx)(L,{variant:`ghost`,size:`sm`,disabled:n,onClick:()=>i({action:`cancel`,reference:o}),children:`Cancel update`}),!u&&a.dispatched&&e.capabilities.verify_completion&&(0,q.jsx)(L,{variant:`ghost`,size:`sm`,disabled:n,onClick:()=>i({action:`recover`,reference:o,strategy:`verify-completion`}),children:`Verify completion`}),a.phase===`recovery_required`&&e.capabilities.continue_recovery&&(0,q.jsx)(L,{size:`sm`,disabled:n,onClick:()=>i({action:`recover`,reference:o,strategy:`continue`}),children:`Continue recovery`})]}),c&&(0,q.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Recovery checks this update on the host before continuing unfinished steps. Keep this window open until the host accepts the request; accepted recovery runs independently.`}),a.dispatched&&!u&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`The host accepted this operation. Status will refresh as it reconnects. Recovery actions are explicit; applying is never repeated automatically.`})]})}function mr(){let e=Le(),t=Me(),n=Ne(),r=f(h().data)??`this host`;if(!t)return null;let i=e.data,a=i?.catalogue,o=a?.releases,s=Oe(i),c=e.error instanceof tt&&e.error.status===404,l=n.busy||e.isError||i?.availability!==`ready`,u=n.data&&!n.data.ok?n.data:i?.result&&!i.result.ok?i.result:null;return(0,q.jsxs)(`section`,{className:`mb-8`,"aria-label":`Host updates`,children:[(0,q.jsx)(X,{note:`Updates run on ${r}`,children:`Updates`}),(0,q.jsx)(Y,{label:`Daemon`,description:i?.observation===`recorded`?i.daemon_version?`Last connected version: ${i.daemon_version}`:`Version unavailable`:a?.daemon_version??i?.daemon_version??`Version unavailable`,children:(0,q.jsx)(L,{variant:`ghost`,size:`sm`,disabled:e.isFetching,onClick:()=>void e.refetch({cancelRefetch:!1}),children:e.isFetching?`Refreshing…`:`Refresh status`})}),a&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Default runtime software`,description:`New runtimes use this build. Existing runtimes retain their current build.`,children:(0,q.jsx)(`span`,{className:`text-xs tabular-nums`,children:a.runtime_default?.version??`Unavailable`})}),a.runtimes.versions.length>0&&(0,q.jsxs)(`div`,{className:`my-3 space-y-1 text-xs text-fg-secondary`,children:[(0,q.jsx)(`p`,{className:`font-medium`,children:`Existing runtimes`}),a.runtimes.versions.map(e=>(0,q.jsxs)(`p`,{children:[e.version,`: `,e.running,` connected · `,e.starting,` starting ·`,` `,e.unavailable,` unavailable`]},`${e.version}-${e.protocol.major}-${e.protocol.minor}`))]}),!a.runtimes.complete&&(0,q.jsx)(`p`,{className:`my-2 text-xs text-warning`,children:`Runtime inventory is incomplete. Update review checks compatibility separately.`})]}),!i&&!e.isError&&(0,q.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:`Checking host updates…`}),e.isError&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-warning`,children:c?`Update this cockpit and reopen the window to manage host updates.`:`Host status is unavailable. The last observation may be out of date. Refresh status before another action.`}),i?.availability===`upgrade_required`&&(0,q.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`This daemon needs an upgrade before cockpit update controls are available.`}),i?.availability===`unavailable`&&(0,q.jsxs)(`p`,{role:`status`,className:`text-sm text-fg-secondary`,children:[i.observation===`recorded`?`The daemon is unavailable. Showing the update record from this host.`:`Waiting for the daemon to reconnect.`,` `,`No update action will be repeated.`]}),o&&(0,q.jsxs)(`div`,{className:`my-4 space-y-1 text-xs text-fg-secondary`,children:[(0,q.jsx)(`p`,{children:o.state===`unconfigured`?`No release source is configured on this host.`:o.state===`checking`?`Checking for releases…`:o.state===`failed`?`Release check failed. Showing the last known result.`:`Release check completed.`}),o.latest&&(0,q.jsxs)(`p`,{children:[`Latest known release: `,o.latest.version,!o.components&&!o.latest.host_asset&&` · No package available for this host`]}),o.components&&(0,q.jsxs)(`p`,{children:[`Latest daemon: `,o.components.daemon.version,!o.components.daemon.host_asset&&` (unavailable for this host)`,` · `,`Runtime: `,o.components.runtime.version,!o.components.runtime.host_asset&&` (unavailable for this host)`]}),o.succeeded_at!==null&&(0,q.jsxs)(`p`,{children:[`Last successful check: `,new Date(o.succeeded_at).toLocaleString()]})]}),s.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[s.map(e=>(0,q.jsxs)(L,{size:`sm`,disabled:l||De(i),onClick:()=>n.act({action:`prepare`,targets:[e]}),children:[`Prepare `,e.component===`daemon`?`daemon`:`runtime software`,` `,e.version]},e.component)),s.length>1&&(0,q.jsx)(L,{size:`sm`,variant:`ghost`,disabled:l||De(i),onClick:()=>n.act({action:`prepare`,targets:s}),children:`Prepare both`})]}),s.length>0&&(0,q.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:`Preparation downloads and verifies the release. Review its impact before applying.`}),n.busy&&(0,q.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-fg-secondary`,children:n.variables?.action===`prepare`?`Preparing update…`:`Waiting for the host…`}),n.isError&&(0,q.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-warning`,children:`The response was lost or unavailable. Status is being checked; the action has not been repeated.`}),u&&(0,q.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-warning`,children:u.code===`conflict`?`The host changed since review. Refresh status and review again.`:`The host could not complete the request (${u.code}). Refresh status before another action.`}),i&&(0,q.jsx)(pr,{status:i,reply:n.data,disabled:l,offlineDisabled:n.busy||e.isError,act:n.act})]})}function hr({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=w();return(0,q.jsx)(Y,{label:e,description:t,htmlFor:`host-${n}`,children:(0,q.jsx)(I,{id:`host-${n}`,type:`number`,min:i,step:a,className:`w-32 tabular-nums`,defaultValue:r[n],onBlur:e=>{if(e.target.value.trim()===``){e.target.value=String(r[n]);return}let t=Number(e.target.value);Number.isFinite(t)&&t!==r[n]&&o.mutate({[n]:t},{onError:e=>G(e)})}})})}function gr(){let e=d(),t=w(),n=h(),r=c().data?.protocol,i=r&&(r.major>25||r.major===25&&r.minor>=6);return e.data?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(mr,{}),(0,q.jsx)(X,{note:`Icon and accent are per profile and not synced; other settings affect all profiles.`,children:`Host`}),(0,q.jsx)(Y,{label:`Display name`,description:`Shown in place of the hostname across the UI. Leave blank for the hostname.`,htmlFor:`host-displayName`,children:(0,q.jsx)(I,{id:`host-displayName`,type:`text`,maxLength:64,className:`w-48`,placeholder:n.data?.hostname,defaultValue:e.data.displayName,onBlur:n=>{let r=n.target.value.trim();r!==e.data.displayName&&t.mutate({displayName:r},{onError:e=>G(e)})}})}),(0,q.jsx)(fr,{}),(0,q.jsx)(hr,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,q.jsx)(hr,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),i&&(0,q.jsx)(hr,{label:`Bulk log retention (days)`,description:`Older inactive terminal logs keep only their replay tail. Archived restoration and shell history are preserved. Set 0 to disable age-based cleanup.`,field:`logRetentionDays`,config:e.data,min:0}),(0,q.jsx)(hr,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,q.jsx)(hr,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,q.jsx)(Y,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,q.jsx)(R,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>G(e)})})})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(fr,{}),(0,q.jsx)(mr,{})]})}var _r=[{id:`appearance`,label:`Appearance`,icon:ht,render:()=>(0,q.jsx)(Vt,{})},{id:`profile`,label:`Profile`,icon:lt,render:()=>(0,q.jsx)(Wt,{})},{id:`accounts`,label:`Accounts`,icon:Bt,render:()=>(0,q.jsx)(qt,{})},{id:`sessions`,label:`Sessions`,icon:zt,render:()=>(0,q.jsx)(en,{})},{id:`editor`,label:`Editor`,icon:gt,render:()=>(0,q.jsx)(cn,{})},{id:`hotkeys`,label:`Hotkeys`,icon:It,render:()=>(0,q.jsx)(un,{})},{id:`notifications`,label:`Notifications`,icon:Ft,render:()=>(0,q.jsx)(an,{})},{id:`projects`,label:`Projects`,icon:ve,render:()=>(0,q.jsx)(dr,{})},{id:`host`,label:`Host`,icon:we,render:()=>(0,q.jsx)(gr,{})},{id:`remote-sync`,label:`Remote & Sync`,icon:dt,render:()=>(0,q.jsx)(lr,{})}],vr={terminal:`sessions`,repositories:`projects`,remote:`remote-sync`,sync:`remote-sync`};function yr(){let e=ct(),t=e===null?null:vr[e]??e,n=_r.find(e=>e.id===t)??_r[0];return(0,q.jsx)(P,{open:e!==null,onOpenChange:e=>!e&&mt(),children:(0,q.jsxs)(M,{wide:!0,surface:!1,showCloseButton:!1,className:`grid h-[34rem] grid-cols-[14rem_minmax(0,1fr)] items-start gap-[var(--ui-surface-gap)] overflow-visible p-0`,children:[(0,q.jsx)(`nav`,{className:`max-h-full min-h-0 overflow-y-auto rounded-[var(--ui-surface-radius)] shadow-2xl`,children:(0,q.jsxs)(Tt,{label:`Settings sections`,variant:`selection`,vertical:!0,className:`settings-navigation`,children:[(0,q.jsxs)(`div`,{className:`flex w-full items-center justify-between px-2.5 py-1.5`,children:[(0,q.jsx)(N,{className:`text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),(0,q.jsxs)(rt,{className:`flex items-center rounded-md p-1.5 text-fg transition-colors hover:bg-ground`,children:[(0,q.jsx)(vt,{className:`size-4`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]}),_r.map(({id:e,label:t,icon:r})=>(0,q.jsxs)(`button`,{type:`button`,"data-tray-slot":!0,"aria-current":e===n.id?`page`:void 0,onClick:()=>ut(e),className:`text-left text-sm transition-colors`,children:[(0,q.jsx)(r,{className:`size-4 shrink-0`}),t]},e))]})}),(0,q.jsx)(`div`,{className:`island-outline h-full min-h-0 overflow-y-auto rounded-[var(--ui-surface-radius)] bg-surface p-5 shadow-2xl`,children:n.render()})]})})}export{yr as SettingsDialog};