@a-t-h-i/bot-lobby 0.6.67 → 0.6.68
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.
- package/package.json +1 -1
- package/webui/dist/assets/{CodeSurface-DBSaDzAn.js → CodeSurface-CUNGWpkc.js} +1 -1
- package/webui/dist/assets/{TerminalView-e5ZKQJXF.js → TerminalView-qi3aVzXz.js} +1 -1
- package/webui/dist/assets/{index-BeEW-9QE.js → index-D3V8jczg.js} +10 -10
- package/webui/dist/assets/{index-CO_X-KbJ.css → index-tTm3L-a2.css} +1 -1
- package/webui/dist/build.json +4 -8
- package/webui/dist/index.html +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalView-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalView-qi3aVzXz.js","assets/rolldown-runtime-hePW80VL.js","assets/ccount-DQxSH8e6.js","assets/TerminalView-BrP-ENHg.css","assets/CodeSurface-CUNGWpkc.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{a as r,c as i,i as a,l as o,n as s,o as c,r as l,s as u,t as d}from"./ccount-DQxSH8e6.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var f=document.querySelector(`meta[property="csp-nonce"]`),p=f?.nonce||f?.content;p&&(window.__webpack_nonce__=p);var m=t(o(),1),h,g=new Set;function _(){for(let e of[...g])e()}typeof window<`u`&&(window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),h=e,_()}),window.addEventListener(`appinstalled`,()=>{h=void 0,_()}));function v(e){return g.add(e),()=>{g.delete(e)}}function y(){return{available:(0,m.useSyncExternalStore)(v,()=>h!==void 0,()=>!1),install:async()=>{let e=h;e&&(await e.prompt().catch(()=>void 0),await e.userChoice?.catch(()=>void 0),h=void 0,_())}}}function b(){let e=`(display-mode: fullscreen), (display-mode: standalone), (display-mode: minimal-ui)`,[t,n]=(0,m.useState)(()=>typeof window<`u`&&window.matchMedia(e).matches);return(0,m.useEffect)(()=>{let t=window.matchMedia(e),r=()=>n(t.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[]),t}function x(){let e=typeof document<`u`&&typeof document.documentElement.requestFullscreen==`function`,[t,n]=(0,m.useState)(()=>typeof document<`u`&&document.fullscreenElement!==null);return(0,m.useEffect)(()=>{let e=()=>n(document.fullscreenElement!==null);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]),{supported:e,on:t,toggle:async()=>{document.fullscreenElement?await document.exitFullscreen().catch(()=>void 0):await document.documentElement.requestFullscreen().catch(()=>void 0)}}}var S=[`background`,`foreground`,`card`,`card-foreground`,`popover`,`popover-foreground`,`primary`,`primary-foreground`,`secondary`,`secondary-foreground`,`muted`,`muted-foreground`,`accent`,`accent-foreground`,`destructive`,`border`,`input`,`ring`,`chart-1`,`chart-2`,`chart-3`,`chart-4`,`chart-5`],C=[`font-sans`,`font-mono`],w=new Set([...S,...C]),T=/^[\w\s#%.,()/+*'"-]{1,300}$/,E=/url\s*\(|expression|import|javascript|\\|<|>/i;function D(e){let t=e.replace(/!important/gi,``).trim();if(t&&T.test(t)&&!E.test(t))return t}function O(e,t,n){let r=e.replace(/^--/,``).toLowerCase();if(!w.has(r))return;let i=D(t);i&&(n[r]=i)}function k(e){let t={};for(let n of e.matchAll(/--([a-z0-9-]+)\s*:\s*([^;}]+)/gi))O(n[1],n[2],t);return t}function A(e){if(!e||typeof e!=`object`)return;let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&O(n,r,t);return Object.keys(t).length>0?t:void 0}function ee(e){let t=e.trim();if(!t)return{error:`Paste a theme first.`};if(t.length>2e5)return{error:`That file is too large to be a theme.`};let n={},r={},i;if(t.startsWith(`{`)){let e;try{e=JSON.parse(t)}catch{return{error:`That is not valid JSON or CSS.`}}let a=e,o=a.cssVars;if(!o||typeof o!=`object`)return{error:`That JSON has no cssVars. Copy the theme's CSS from tweakcn instead.`};let s=e=>{let t={};for(let[n,r]of Object.entries(e??{}))typeof r==`string`&&O(n,r,t);return t};n={...s(o.theme),...s(o.light)},r={...s(o.theme),...s(o.dark)},i=typeof a.title==`string`?a.title:typeof a.name==`string`?a.name:void 0}else for(let e of t.matchAll(/(?<=^|[}\s])((?::root|html|\.dark|:root\.dark|html\.dark)(?:\s*,\s*[^{]+)?)\s*\{([^}]*)\}/g)){let t=e[1].trim(),i=k(e[2]);/\.dark/.test(t)?r={...r,...i}:n={...n,...i}}let a=e=>Object.keys(e).filter(e=>S.includes(e)).length;return a(n)<5&&a(r)<5?{error:`No theme colours found. Copy the code from tweakcn's Code panel (the :root and .dark blocks).`}:{...a(n)>=5?{light:n}:{},...a(r)>=5?{dark:r}:{},...i?{name:i}:{}}}var j={"glass-border":`var(--border)`,typing:`var(--ring)`,"tab-active":`color-mix(in oklab, var(--primary) 14%, var(--background))`,you:`color-mix(in oklab, var(--primary) 9%, var(--card))`,heading:`var(--foreground)`,link:`var(--primary)`,bullet:`var(--primary)`},M=`"Inter Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`,te=`ui-monospace, "JetBrains Mono", "Cascadia Mono", "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace`;function ne(e,t){let n=[];for(let[e,r]of Object.entries(t))e===`font-sans`?n.push(`--app-font-sans:${r},${M};`):e===`font-mono`?n.push(`--app-font-mono:${r},${te};`):n.push(`--${e}:${r};`);for(let[e,r]of Object.entries(j))e in t||n.push(`--${e}:${r};`);return`${e}{${n.join(``)}}`}function N(e){let t=[];return e.light&&t.push(ne(`:root`,e.light)),e.dark&&t.push(ne(`.dark`,e.dark)),t.join(`
|
|
3
3
|
`)}var re=`mist`,ie=[{id:re,name:`Default`},{id:`blossom`,name:`Blossom`,light:{background:`oklch(0.982446 0.010114 325.653)`,foreground:`oklch(0.325698 0.116116 325.037)`,card:`oklch(0.971835 0.012884 321.894)`,"card-foreground":`oklch(0.325698 0.116116 325.037)`,popover:`oklch(1 0 0)`,"popover-foreground":`oklch(0.325698 0.116116 325.037)`,primary:`oklch(0.591646 0.217985 0.584)`,"primary-foreground":`oklch(1 0 0)`,secondary:`oklch(0.869588 0.06751 334.899)`,"secondary-foreground":`oklch(0.444777 0.134061 324.799)`,muted:`oklch(0.802407 0.090963 345.892)`,"muted-foreground":`oklch(0.428932 0.163929 354.332)`,accent:`oklch(0.939552 0.024286 321.664)`,"accent-foreground":`oklch(0.396296 0.025134 285.196)`,destructive:`oklch(0.627117 0.248974 7.734)`,border:`oklch(0.923531 0.021247 328.096)`,input:`oklch(0.851713 0.055822 336.6)`,ring:`oklch(0.591646 0.217985 0.584)`,"chart-1":`oklch(0.591646 0.217985 0.584)`},dark:{background:`oklch(0.22813 0.020366 307.469)`,foreground:`oklch(0.980735 0.004092 301.426)`,card:`oklch(0.267101 0.02016 311.799)`,"card-foreground":`oklch(0.980735 0.004092 301.426)`,popover:`oklch(0.154761 0.01316 338.901)`,"popover-foreground":`oklch(0.980735 0.004092 301.426)`,primary:`oklch(0.460685 0.185347 4.099)`,"primary-foreground":`oklch(0.901233 0.057189 343.694)`,secondary:`oklch(0.313674 0.030572 310.061)`,"secondary-foreground":`oklch(0.848252 0.038248 307.961)`,muted:`oklch(0.360924 0.021469 316.83)`,"muted-foreground":`oklch(0.880303 0.03077 342.696)`,accent:`oklch(0.364912 0.050794 308.491)`,"accent-foreground":`oklch(0.964695 0.009139 341.803)`,destructive:`oklch(0.458704 0.169677 3.815)`,border:`oklch(0.266943 0.015262 302.425)`,input:`oklch(0.266817 0.02897 344.461)`,ring:`oklch(0.591646 0.217985 0.584)`,"chart-1":`oklch(0.460685 0.185347 4.099)`}},{id:`grove`,name:`Grove`,light:{background:`oklch(0.972369 0.005497 157.15)`,foreground:`oklch(0.222003 0.03479 328.979)`,card:`oklch(0.972369 0.005497 157.15)`,"card-foreground":`oklch(0.222003 0.03479 328.979)`,popover:`oklch(0.932695 0.003778 160.944)`,"popover-foreground":`oklch(0.222003 0.03479 328.979)`,primary:`oklch(0.523295 0.112292 158.089)`,"primary-foreground":`oklch(0.990339 0.008411 325.64)`,secondary:`oklch(0.936464 0.014601 163.554)`,"secondary-foreground":`oklch(0.222003 0.03479 328.979)`,muted:`oklch(0.945455 0.012308 162.879)`,"muted-foreground":`oklch(0.527266 0.012309 320.683)`,accent:`oklch(0.909438 0.021521 164.612)`,"accent-foreground":`oklch(0.222003 0.03479 328.979)`,destructive:`oklch(0.637823 0.237287 25.436)`,border:`oklch(0.864831 0.01312 167.255)`,input:`oklch(0.829746 0.016084 168.234)`,ring:`oklch(0.523295 0.112292 158.089)`,"chart-1":`oklch(0.523295 0.112292 158.089)`},dark:{background:`oklch(0.260865 0.02152 162.75)`,foreground:`oklch(0.990339 0.008411 325.64)`,card:`oklch(0.260865 0.02152 162.75)`,"card-foreground":`oklch(0.990339 0.008411 325.64)`,popover:`oklch(0.411828 0.014378 166.627)`,"popover-foreground":`oklch(0.990339 0.008411 325.64)`,primary:`oklch(0.796228 0.133058 157.319)`,"primary-foreground":`oklch(0.222003 0.03479 328.979)`,secondary:`oklch(0.380487 0.048313 159.608)`,"secondary-foreground":`oklch(0.990339 0.008411 325.64)`,muted:`oklch(0.339728 0.039456 160.274)`,"muted-foreground":`oklch(0.715427 0.010896 171.428)`,accent:`oklch(0.437021 0.060312 158.962)`,"accent-foreground":`oklch(0.990339 0.008411 325.64)`,destructive:`oklch(0.655108 0.221148 23.473)`,border:`oklch(0.457475 0.044046 160.971)`,input:`oklch(0.519849 0.049896 160.863)`,ring:`oklch(0.796228 0.133058 157.319)`,"chart-1":`oklch(0.796228 0.133058 157.319)`}},{id:`ocean`,name:`Ocean`,light:{background:`oklch(0.974199 0.002856 241.597)`,foreground:`oklch(0.222003 0.03479 328.979)`,card:`oklch(0.974199 0.002856 241.597)`,"card-foreground":`oklch(0.222003 0.03479 328.979)`,popover:`oklch(0.934442 0.003181 269.1)`,"popover-foreground":`oklch(0.222003 0.03479 328.979)`,primary:`oklch(0.536684 0.120219 247.01)`,"primary-foreground":`oklch(0.990339 0.008411 325.64)`,secondary:`oklch(0.939254 0.01193 241.729)`,"secondary-foreground":`oklch(0.222003 0.03479 328.979)`,muted:`oklch(0.948004 0.009649 241.695)`,"muted-foreground":`oklch(0.528741 0.01828 313.823)`,accent:`oklch(0.91295 0.018827 241.836)`,"accent-foreground":`oklch(0.222003 0.03479 328.979)`,destructive:`oklch(0.637823 0.237287 25.436)`,border:`oklch(0.867646 0.013482 252.362)`,input:`oklch(0.832939 0.017389 252.598)`,ring:`oklch(0.536684 0.120219 247.01)`,"chart-1":`oklch(0.536684 0.120219 247.01)`},dark:{background:`oklch(0.242641 0.024125 250.573)`,foreground:`oklch(0.990339 0.008411 325.64)`,card:`oklch(0.242641 0.024125 250.573)`,"card-foreground":`oklch(0.990339 0.008411 325.64)`,popover:`oklch(0.398517 0.018232 255.72)`,"popover-foreground":`oklch(0.990339 0.008411 325.64)`,primary:`oklch(0.758933 0.105833 241.548)`,"primary-foreground":`oklch(0.222003 0.03479 328.979)`,secondary:`oklch(0.358725 0.043145 244.911)`,"secondary-foreground":`oklch(0.990339 0.008411 325.64)`,muted:`oklch(0.319287 0.036766 246.065)`,"muted-foreground":`oklch(0.691936 0.016294 261.588)`,accent:`oklch(0.413315 0.051874 243.855)`,"accent-foreground":`oklch(0.990339 0.008411 325.64)`,destructive:`oklch(0.655108 0.221148 23.473)`,border:`oklch(0.438653 0.039496 245.44)`,input:`oklch(0.500905 0.043574 244.781)`,ring:`oklch(0.758933 0.105833 241.548)`,"chart-1":`oklch(0.758933 0.105833 241.548)`}},{id:`ember`,name:`Ember`,light:{background:`oklch(0.976527 0.002685 60.725)`,foreground:`oklch(0.222003 0.03479 328.979)`,card:`oklch(0.976527 0.002685 60.725)`,"card-foreground":`oklch(0.222003 0.03479 328.979)`,popover:`oklch(0.936659 0.002879 29.96)`,"popover-foreground":`oklch(0.222003 0.03479 328.979)`,primary:`oklch(0.552831 0.129438 44.656)`,"primary-foreground":`oklch(0.990339 0.008411 325.64)`,secondary:`oklch(0.942267 0.01151 50.785)`,"secondary-foreground":`oklch(0.222003 0.03479 328.979)`,muted:`oklch(0.950842 0.009273 51.528)`,"muted-foreground":`oklch(0.530413 0.018453 341.181)`,accent:`oklch(0.916502 0.01832 49.597)`,"accent-foreground":`oklch(0.222003 0.03479 328.979)`,destructive:`oklch(0.637823 0.237287 25.436)`,border:`oklch(0.870631 0.013204 39.431)`,input:`oklch(0.836213 0.017153 38.661)`,ring:`oklch(0.552831 0.129438 44.656)`,"chart-1":`oklch(0.552831 0.129438 44.656)`},dark:{background:`oklch(0.245899 0.019144 42.044)`,foreground:`oklch(0.990339 0.008411 325.64)`,card:`oklch(0.245899 0.019144 42.044)`,"card-foreground":`oklch(0.990339 0.008411 325.64)`,popover:`oklch(0.401111 0.014308 34.896)`,"popover-foreground":`oklch(0.990339 0.008411 325.64)`,primary:`oklch(0.762174 0.124117 52.082)`,"primary-foreground":`oklch(0.222003 0.03479 328.979)`,secondary:`oklch(0.361499 0.044052 49.515)`,"secondary-foreground":`oklch(0.990339 0.008411 325.64)`,muted:`oklch(0.322144 0.03574 48.309)`,"muted-foreground":`oklch(0.692479 0.015227 30.963)`,accent:`oklch(0.416048 0.055354 50.484)`,"accent-foreground":`oklch(0.990339 0.008411 325.64)`,destructive:`oklch(0.655108 0.221148 23.473)`,border:`oklch(0.44099 0.040202 48.807)`,input:`oklch(0.503003 0.045721 49.44)`,ring:`oklch(0.762174 0.124117 52.082)`,"chart-1":`oklch(0.762174 0.124117 52.082)`}},{id:`iris`,name:`Iris`,light:{background:`oklch(0.976531 0.003855 303.226)`,foreground:`oklch(0.222003 0.03479 328.979)`,card:`oklch(0.976531 0.003855 303.226)`,"card-foreground":`oklch(0.222003 0.03479 328.979)`,popover:`oklch(0.936665 0.005041 310.132)`,"popover-foreground":`oklch(0.222003 0.03479 328.979)`,primary:`oklch(0.525348 0.15373 294.176)`,"primary-foreground":`oklch(0.990339 0.008411 325.64)`,secondary:`oklch(0.941387 0.014687 300.474)`,"secondary-foreground":`oklch(0.222003 0.03479 328.979)`,muted:`oklch(0.950194 0.011956 300.733)`,"muted-foreground":`oklch(0.529955 0.022319 321.556)`,accent:`oklch(0.914882 0.022965 299.986)`,"accent-foreground":`oklch(0.222003 0.03479 328.979)`,destructive:`oklch(0.637823 0.237287 25.436)`,border:`oklch(0.869608 0.018226 303.859)`,input:`oklch(0.834773 0.023405 303.676)`,ring:`oklch(0.525348 0.15373 294.176)`,"chart-1":`oklch(0.525348 0.15373 294.176)`},dark:{background:`oklch(0.225975 0.031062 293.741)`,foreground:`oklch(0.990339 0.008411 325.64)`,card:`oklch(0.225975 0.031062 293.741)`,"card-foreground":`oklch(0.990339 0.008411 325.64)`,popover:`oklch(0.386739 0.024023 297.509)`,"popover-foreground":`oklch(0.990339 0.008411 325.64)`,primary:`oklch(0.671712 0.169136 293.929)`,"primary-foreground":`oklch(0.222003 0.03479 328.979)`,secondary:`oklch(0.325405 0.063614 294.23)`,"secondary-foreground":`oklch(0.990339 0.008411 325.64)`,muted:`oklch(0.291515 0.05276 294.209)`,"muted-foreground":`oklch(0.663321 0.025932 301.862)`,accent:`oklch(0.372436 0.07841 294.204)`,"accent-foreground":`oklch(0.990339 0.008411 325.64)`,destructive:`oklch(0.655108 0.221148 23.473)`,border:`oklch(0.40874 0.058536 295.893)`,input:`oklch(0.46756 0.065775 296.265)`,ring:`oklch(0.671712 0.169136 293.929)`,"chart-1":`oklch(0.671712 0.169136 293.929)`}},{id:`slate`,name:`Slate`,light:{background:`#f5f7fa`,foreground:`#202b3b`,card:`#ffffff`,"card-foreground":`#202b3b`,popover:`#ffffff`,"popover-foreground":`#202b3b`,primary:`#465b78`,"primary-foreground":`#ffffff`,secondary:`#e7ecf2`,"secondary-foreground":`#202b3b`,muted:`#edf1f6`,"muted-foreground":`#526177`,accent:`#e0e7ef`,"accent-foreground":`#202b3b`,destructive:`#a52a34`,border:`#cad3df`,input:`#b9c5d4`,ring:`#465b78`,"chart-1":`#465b78`},dark:{background:`#141b26`,foreground:`#e8edf5`,card:`#1c2533`,"card-foreground":`#e8edf5`,popover:`#202b3b`,"popover-foreground":`#e8edf5`,primary:`#adc0dc`,"primary-foreground":`#141b26`,secondary:`#2a3648`,"secondary-foreground":`#e8edf5`,muted:`#243043`,"muted-foreground":`#afbdd0`,accent:`#33445d`,"accent-foreground":`#e8edf5`,destructive:`#fb8990`,border:`#43536a`,input:`#53647d`,ring:`#adc0dc`,"chart-1":`#adc0dc`}},{id:`sand`,name:`Sand`,light:{background:`#faf7f1`,foreground:`#352b22`,card:`#fffdf8`,"card-foreground":`#352b22`,popover:`#fffdf8`,"popover-foreground":`#352b22`,primary:`#765536`,"primary-foreground":`#ffffff`,secondary:`#eee6da`,"secondary-foreground":`#352b22`,muted:`#f2ece2`,"muted-foreground":`#6c5b49`,accent:`#e9ddcb`,"accent-foreground":`#352b22`,destructive:`#a52a34`,border:`#d9cbb8`,input:`#c9b79e`,ring:`#765536`,"chart-1":`#765536`},dark:{background:`#211c17`,foreground:`#f4ece0`,card:`#2c251e`,"card-foreground":`#f4ece0`,popover:`#352c23`,"popover-foreground":`#f4ece0`,primary:`#dcbc92`,"primary-foreground":`#211c17`,secondary:`#3c3227`,"secondary-foreground":`#f4ece0`,muted:`#352d24`,"muted-foreground":`#c9b9a5`,accent:`#4a3b2b`,"accent-foreground":`#f4ece0`,destructive:`#fb8990`,border:`#64503e`,input:`#79614b`,ring:`#dcbc92`,"chart-1":`#dcbc92`}},{id:`rosewood`,name:`Rosewood`,light:{background:`#fbf6f5`,foreground:`#3b262c`,card:`#fffafa`,"card-foreground":`#3b262c`,popover:`#fffafa`,"popover-foreground":`#3b262c`,primary:`#854252`,"primary-foreground":`#ffffff`,secondary:`#f0e2e5`,"secondary-foreground":`#3b262c`,muted:`#f5eaec`,"muted-foreground":`#76525d`,accent:`#edd6dd`,"accent-foreground":`#3b262c`,destructive:`#a52a34`,border:`#dfc5cc`,input:`#d0afb9`,ring:`#854252`,"chart-1":`#854252`},dark:{background:`#241a20`,foreground:`#f6e8ed`,card:`#30222a`,"card-foreground":`#f6e8ed`,popover:`#3a2932`,"popover-foreground":`#f6e8ed`,primary:`#e3a5b7`,"primary-foreground":`#241a20`,secondary:`#442e38`,"secondary-foreground":`#f6e8ed`,muted:`#3a2932`,"muted-foreground":`#d2b4c0`,accent:`#553441`,"accent-foreground":`#f6e8ed`,destructive:`#fb8990`,border:`#70505d`,input:`#856170`,ring:`#e3a5b7`,"chart-1":`#e3a5b7`}},{id:`aurora`,name:`Aurora`,light:{background:`#f2faf8`,foreground:`#193a37`,card:`#fafffe`,"card-foreground":`#193a37`,popover:`#fafffe`,"popover-foreground":`#193a37`,primary:`#216c63`,"primary-foreground":`#ffffff`,secondary:`#def0eb`,"secondary-foreground":`#193a37`,muted:`#e6f2ef`,"muted-foreground":`#456c66`,accent:`#eee5f6`,"accent-foreground":`#193a37`,destructive:`#a52a34`,border:`#bbd7d1`,input:`#a7c8c0`,ring:`#216c63`,"chart-1":`#216c63`},dark:{background:`#142321`,foreground:`#e1f5ef`,card:`#1d302d`,"card-foreground":`#e1f5ef`,popover:`#253d38`,"popover-foreground":`#e1f5ef`,primary:`#87d5c1`,"primary-foreground":`#142321`,secondary:`#29443e`,"secondary-foreground":`#e1f5ef`,muted:`#243c36`,"muted-foreground":`#a9cfc3`,accent:`#3d3352`,"accent-foreground":`#e1f5ef`,destructive:`#fb8990`,border:`#466b60`,input:`#568172`,ring:`#87d5c1`,"chart-1":`#87d5c1`}},{id:`midnight`,name:`Midnight`,light:{background:`#f5f6fb`,foreground:`#282e48`,card:`#fcfcff`,"card-foreground":`#282e48`,popover:`#fcfcff`,"popover-foreground":`#282e48`,primary:`#4f5f96`,"primary-foreground":`#ffffff`,secondary:`#e5e8f4`,"secondary-foreground":`#282e48`,muted:`#eceef7`,"muted-foreground":`#565f7d`,accent:`#dfe4f6`,"accent-foreground":`#282e48`,destructive:`#a52a34`,border:`#c7cee5`,input:`#b4bfdc`,ring:`#4f5f96`,"chart-1":`#4f5f96`},dark:{background:`#151a2b`,foreground:`#e8ecfa`,card:`#1f263b`,"card-foreground":`#e8ecfa`,popover:`#29314a`,"popover-foreground":`#e8ecfa`,primary:`#acbbed`,"primary-foreground":`#151a2b`,secondary:`#303954`,"secondary-foreground":`#e8ecfa`,muted:`#28314b`,"muted-foreground":`#b1bedf`,accent:`#3a466a`,"accent-foreground":`#e8ecfa`,destructive:`#fb8990`,border:`#48577d`,input:`#596990`,ring:`#acbbed`,"chart-1":`#acbbed`}},{id:`graphite`,name:`Graphite`,light:{background:`#fafafa`,foreground:`#222222`,card:`#fefefe`,"card-foreground":`#222222`,popover:`#fefefe`,"popover-foreground":`#222222`,primary:`#333333`,"primary-foreground":`#fcfcfc`,secondary:`#ebebeb`,"secondary-foreground":`#222222`,muted:`#f0f0f0`,"muted-foreground":`#5d5d5d`,accent:`#e8e8e8`,"accent-foreground":`#222222`,destructive:`#d02b31`,border:`#dedede`,input:`#cecece`,ring:`#333333`,"chart-1":`#333333`},dark:{background:`#121212`,foreground:`#eeeeee`,card:`#191919`,"card-foreground":`#eeeeee`,popover:`#202020`,"popover-foreground":`#eeeeee`,primary:`#e4e4e4`,"primary-foreground":`#121212`,secondary:`#292929`,"secondary-foreground":`#eeeeee`,muted:`#242424`,"muted-foreground":`#ababab`,accent:`#333333`,"accent-foreground":`#eeeeee`,destructive:`#f66c6d`,border:`#333333`,input:`#424242`,ring:`#e4e4e4`,"chart-1":`#e4e4e4`}},{id:`lagoon`,name:`Lagoon`,light:{background:`#f3fcfd`,foreground:`#0e2627`,card:`#fbffff`,"card-foreground":`#0e2627`,popover:`#fbffff`,"popover-foreground":`#0e2627`,primary:`#007780`,"primary-foreground":`#fcfcfc`,secondary:`#d5f2f3`,"secondary-foreground":`#0e2627`,muted:`#e3f4f5`,"muted-foreground":`#456466`,accent:`#c3f2f4`,"accent-foreground":`#0e2627`,destructive:`#d02b31`,border:`#cde3e4`,input:`#b8d4d5`,ring:`#007780`,"chart-1":`#007780`},dark:{background:`#041516`,foreground:`#e8f1f1`,card:`#091d1e`,"card-foreground":`#e8f1f1`,popover:`#102425`,"popover-foreground":`#e8f1f1`,primary:`#53c5cb`,"primary-foreground":`#041516`,secondary:`#162d2f`,"secondary-foreground":`#e8f1f1`,muted:`#152829`,"muted-foreground":`#9cafb0`,accent:`#0c3a3c`,"accent-foreground":`#e8f1f1`,destructive:`#f66c6d`,border:`#203839`,input:`#2f4749`,ring:`#53c5cb`,"chart-1":`#53c5cb`}},{id:`dune`,name:`Dune`,light:{background:`#fef9f3`,foreground:`#2b1f11`,card:`#fffefb`,"card-foreground":`#2b1f11`,popover:`#fffefb`,"popover-foreground":`#2b1f11`,primary:`#9d6300`,"primary-foreground":`#fcfcfc`,secondary:`#f9e8d6`,"secondary-foreground":`#2b1f11`,muted:`#f8eee4`,"muted-foreground":`#6b5a48`,accent:`#fde3c6`,"accent-foreground":`#2b1f11`,destructive:`#d02b31`,border:`#e9dccd`,input:`#dbcbb9`,ring:`#9d6300`,"chart-1":`#9d6300`},dark:{background:`#181006`,foreground:`#f3ede8`,card:`#21170c`,"card-foreground":`#f3ede8`,popover:`#291e12`,"popover-foreground":`#f3ede8`,primary:`#dba666`,"primary-foreground":`#181006`,secondary:`#322618`,"secondary-foreground":`#f3ede8`,muted:`#2c2217`,"muted-foreground":`#b4a99d`,accent:`#422e16`,"accent-foreground":`#f3ede8`,destructive:`#f66c6d`,border:`#3d3022`,input:`#4d4031`,ring:`#dba666`,"chart-1":`#dba666`}},{id:`plum`,name:`Plum`,light:{background:`#fef8ff`,foreground:`#291c2c`,card:`#fffdff`,"card-foreground":`#291c2c`,popover:`#fffdff`,"popover-foreground":`#291c2c`,primary:`#9553a4`,"primary-foreground":`#fcfcfc`,secondary:`#f6e4fa`,"secondary-foreground":`#291c2c`,muted:`#f7ecf9`,"muted-foreground":`#68566d`,accent:`#f9dcff`,"accent-foreground":`#291c2c`,destructive:`#d02b31`,border:`#e7d8ea`,input:`#d8c7dc`,ring:`#9553a4`,"chart-1":`#9553a4`},dark:{background:`#170d19`,foreground:`#f2ecf3`,card:`#201522`,"card-foreground":`#f2ecf3`,popover:`#271c2a`,"popover-foreground":`#f2ecf3`,primary:`#d398e0`,"primary-foreground":`#170d19`,secondary:`#312334`,"secondary-foreground":`#f2ecf3`,muted:`#2a202d`,"muted-foreground":`#b2a6b5`,accent:`#3f2945`,"accent-foreground":`#f2ecf3`,destructive:`#f66c6d`,border:`#3b2d3e`,input:`#4b3c4e`,ring:`#d398e0`,"chart-1":`#d398e0`}},{id:`moss`,name:`Moss`,light:{background:`#f8fcf6`,foreground:`#1c2517`,card:`#fdfffc`,"card-foreground":`#1c2517`,popover:`#fdfffc`,"popover-foreground":`#1c2517`,primary:`#4a7333`,"primary-foreground":`#fcfcfc`,secondary:`#e3f0dd`,"secondary-foreground":`#1c2517`,muted:`#ebf3e8`,"muted-foreground":`#56624f`,accent:`#dcefd2`,"accent-foreground":`#1c2517`,destructive:`#d02b31`,border:`#d8e2d3`,input:`#c6d2c0`,ring:`#4a7333`,"chart-1":`#4a7333`},dark:{background:`#0d140a`,foreground:`#ecf0ea`,card:`#151c11`,"card-foreground":`#ecf0ea`,popover:`#1b2317`,"popover-foreground":`#ecf0ea`,primary:`#97bf82`,"primary-foreground":`#0d140a`,secondary:`#232c1e`,"secondary-foreground":`#ecf0ea`,muted:`#1f271c`,"muted-foreground":`#a6aea1`,accent:`#293821`,"accent-foreground":`#ecf0ea`,destructive:`#f66c6d`,border:`#2d3628`,input:`#3c4637`,ring:`#97bf82`,"chart-1":`#97bf82`}},{id:`crimson`,name:`Crimson`,light:{background:`#fff7f6`,foreground:`#331919`,card:`#fffcfc`,"card-foreground":`#331919`,popover:`#fffcfc`,"popover-foreground":`#331919`,primary:`#c13a46`,"primary-foreground":`#fcfcfc`,secondary:`#ffe1df`,"secondary-foreground":`#331919`,muted:`#ffeae9`,"muted-foreground":`#785252`,accent:`#ffd7d5`,"accent-foreground":`#331919`,destructive:`#d02b31`,border:`#f4d6d5`,input:`#e9c3c2`,ring:`#c13a46`,"chart-1":`#c13a46`},dark:{background:`#1e0b0b`,foreground:`#f8ebeb`,card:`#281212`,"card-foreground":`#f8ebeb`,popover:`#301919`,"popover-foreground":`#f8ebeb`,primary:`#ff898b`,"primary-foreground":`#1e0b0b`,secondary:`#3b2020`,"secondary-foreground":`#f8ebeb`,muted:`#331d1d`,"muted-foreground":`#bea4a3`,accent:`#502324`,"accent-foreground":`#f8ebeb`,destructive:`#f66c6d`,border:`#462a2a`,input:`#573939`,ring:`#ff898b`,"chart-1":`#ff898b`}}],ae={light:{background:`#fcfcfc`,card:`#ffffff`,primary:`#1b4ed8`,accent:`#f4f4f5`},dark:{background:`#0a0a0a`,card:`#111111`,primary:`#346bf1`,accent:`#141414`}};function oe(e,t){let n=t?e.dark:e.light,r=ae[t?`dark`:`light`];return n?{background:n.background??r.background,card:n.card??r.card,primary:n.primary??r.primary,accent:n.primary?`color-mix(in oklab, ${n.primary} 18%, ${n.background??r.background})`:r.accent}:{...r}}var se={activity:400,thoughts:40,chat:100};function ce(e,t,n){let r=e??[],i=new Set(r.map(e=>e.id)),a=t.filter(e=>typeof e?.id==`number`&&!i.has(e.id));return[...r,...a].slice(-n)}var le=class{records=new Map;listeners=new Set;reads=new Map;used=new Set;reader;currentStatus={connection:`connecting`,signedOut:!1};get(e){let t=this.records.get(e);if(t)return t;let n={version:0,data:void 0,loading:!1,error:void 0,stale:!1};return this.records.set(e,n),n}status(){return{...this.currentStatus}}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}markUsed(e,t){this.reader=t;let n=e.filter(e=>!this.used.has(e));this.used=new Set(e);for(let e of n)this.read(e)}onHello(e){for(let t of this.used){let n=e[t];n!==void 0&&(this.get(t).version=n),this.read(t)}}onChanged(e,t){let n=this.get(e);n.version=t,this.used.has(e)?this.read(e):n.stale=!0,this.notify()}onFeedDelta(e){let t=this.get(`lobby`).data;t&&(this.get(`lobby`).data={...t,activity:ce(t.activity,e.activity??[],se.activity),thoughts:ce(t.thoughts,e.thoughts??[],se.thoughts),chat:ce(t.chat,e.chat??[],se.chat)},this.notify())}onReplyDelta(e){let t=this.get(`lobby`),n=t.data;n&&(t.data={...n,reply:e},this.notify())}onStatus(e){this.currentStatus={...this.currentStatus,...e},this.notify()}async read(e){let t=this.reader;if(!t)return;let n=(this.reads.get(e)??0)+1;this.reads.set(e,n);let r=this.get(e);r.loading=!0,r.error=void 0,this.notify();try{let i=await t(e);if(this.reads.get(e)!==n)return;this.apply(r,i)}catch(t){if(this.reads.get(e)!==n)return;r.loading=!1,r.error=t instanceof Error?t.message:String(t)}this.notify()}apply(e,t){e.data=t,e.loading=!1,e.stale=!1,e.error=void 0}notify(){for(let e of[...this.listeners])e()}};function ue(){return new le}var P=ue(),de=/^[a-f0-9]{32}$/;function fe(){return globalThis.location}function pe(){let e=fe()?.search??``,t=new URLSearchParams(e).getAll(`project`);if(t.length){if(t.length!==1||!de.test(t[0]))throw Error(`Invalid project ID. Choose a running project below.`);return t[0]}}function F(e){if(!e.startsWith(`/api/`)&&!e.startsWith(`/files/preview/`))return e;let t=pe();return t?`/projects/${t}${e}`:e}function I(e,t){if(!de.test(e))throw Error(`Invalid project ID.`);let n=fe();if(!n)throw Error(`Project switching requires a browser.`);let r=new URL(n.origin);r.pathname=n.pathname,r.searchParams.set(`project`,e),r.hash=`/${t}`,n.assign(r.href)}var me=`bot-lobby.projectFolders`,he=new Map;function ge(){try{return globalThis.sessionStorage}catch{return}}function _e(){try{let e=JSON.parse(ge()?.getItem(me)??`{}`);for(let[t,n]of Object.entries(e))de.test(t)&&typeof n==`string`&&he.set(t,n)}catch{}}function ve(e){_e();for(let t of e)de.test(t.id)&&he.set(t.id,t.cwd);try{ge()?.setItem(me,JSON.stringify(Object.fromEntries([...he].slice(-64))))}catch{}}function ye(e){return he.has(e)||_e(),he.get(e)}async function be(e){let t;try{t=pe()}catch{return!1}if(!t)return!1;let n=ye(t);if(!n)return!1;let{projects:r}=await e();if(ve(r),r.some(e=>e.id===t))return!1;let i=r.find(e=>e.cwd===n),a=fe(),o=globalThis.history;if(!i||!a||!o)return!1;let s=new URL(a.origin);return s.pathname=a.pathname,s.search=a.search,s.searchParams.set(`project`,i.id),s.hash=globalThis.location?.hash??``,o.replaceState(null,``,s.href),!0}var xe=class extends Error{code;status;constructor(e,t,n){super(e),this.name=`ApiError`,this.code=t,this.status=n}},Se={"Content-Type":`application/json`};async function L(e,t={}){let n=await fetch(e===`auth.login`||e.startsWith(`projects.`)?`/api/${e}`:F(`/api/${e}`),{method:`POST`,headers:Se,body:JSON.stringify(t),credentials:`same-origin`}),r=await n.json().catch(()=>void 0);if(!r)throw new xe(`the lobby answered ${n.status}`,`failed`,n.status);if(!r.ok)throw r.code===`unauthorized`&&P.onStatus({signedOut:!0}),new xe(r.error,r.code,n.status);return r.result}function Ce(){return globalThis.location}async function we(){let e=Ce(),t=e?new URLSearchParams(e.hash.replace(/^#/,``)).get(`token`):null;if(!t||!(await fetch(`/api/auth.login`,{method:`POST`,headers:Se,body:JSON.stringify({token:t}),credentials:`same-origin`}).catch(()=>void 0))?.ok)return!1;let n=globalThis.history;return n&&n.replaceState(null,``,e.pathname+e.search),P.onStatus({signedOut:!1}),!0}var Te=`bot-lobby.palette`,Ee=`bot-lobby-palette`,De=`custom`,Oe=new Set,ke=je();function Ae(e){let t=e;if(!t||typeof t.id!=`string`||typeof t.name!=`string`)return;let n=A(t.light),r=A(t.dark);if(n||r)return{id:t.id,name:t.name.slice(0,40),...n?{light:n}:{},...r?{dark:r}:{}}}function je(){try{let e=localStorage.getItem(Te);if(!e)return{id:re,saved:[]};let t=JSON.parse(e),n=(t.saved??[]).map(Ae).filter(e=>!!e),r=Ae(t.legacy??(t.custom?{...t.custom,id:De}:void 0)),i=new Set([...ie.map(e=>e.id),...n.map(e=>e.id),...r?[De]:[]]);return{id:t.id&&i.has(t.id)?t.id:re,saved:n,...r?{legacy:r}:{}}}catch{return{id:re,saved:[]}}}function Me(e){return[...ie,...e.saved,...e.legacy?[e.legacy]:[]]}function Ne(e){return Me(e).find(t=>t.id===e.id)??ie[0]}function Pe(){if(typeof document>`u`)return;let e=N(Ne(ke)),t=document.getElementById(Ee);if(!e){t?.remove();return}t||(t=document.createElement(`style`),t.id=Ee,document.head.appendChild(t)),t.textContent=e}function Fe(e){ke=e;try{localStorage.setItem(Te,JSON.stringify(e))}catch{}Pe();for(let e of[...Oe])e()}function Ie(e){let t=e.themes.map(e=>Ae(e)).filter(e=>!!e),{legacy:n}=ke;Fe({id:e.active??(ke.id===De&&n?De:`mist`),saved:t,...n?{legacy:n}:{}})}var Le,Re=Promise.resolve();function ze(e=!1){return Le&&!e||(Le=(async()=>{let e=await L(`themes.get`,{}),t=ke.legacy;if(t){let n=e.active??(ke.id===De?void 0:ke.id);e=await L(`themes.save`,{name:t.name,...t.light?{light:t.light}:{},...t.dark?{dark:t.dark}:{}}),n&&(e=await L(`themes.choose`,{id:n}));let{legacy:r,...i}=ke;ke=i}Ie(e)})().catch(()=>{Le=void 0})),Le}typeof window<`u`&&(Pe(),window.addEventListener(`storage`,e=>{if(e.key===Te){ke=je(),Pe();for(let e of[...Oe])e()}}),window.addEventListener(`focus`,()=>void ze(!0)));function Be(e){return Oe.add(e),()=>{Oe.delete(e)}}function Ve(){let e=(0,m.useSyncExternalStore)(Be,()=>ke,()=>ke),t=(0,m.useCallback)(e=>{Fe({...ke,id:e}),e!==De&&(Re=Re.then(()=>L(`themes.choose`,{id:e})).then(Ie,()=>{}))},[]),n=(0,m.useCallback)(async(e,t)=>(Ie(await L(`themes.save`,{name:t,...e.light?{light:e.light}:{},...e.dark?{dark:e.dark}:{}})),Ne(ke)),[]),r=(0,m.useCallback)(async(e,t)=>Ie(await L(`themes.rename`,{id:e,name:t})),[]),i=(0,m.useCallback)(async e=>Ie(await L(`themes.remove`,{id:e})),[]),a=e.legacy?[...e.saved,e.legacy]:e.saved;return{active:Ne(e),saved:a,all:Me(e),isSaved:e=>a.some(t=>t.id===e),choose:t,adopt:n,rename:r,remove:i}}var He=[{id:`theme`,label:`System`,help:`The system's own (or the colour theme's)`},{id:`inter`,label:`Inter`,help:`Neutral and very legible`},{id:`geist`,label:`Geist`,help:`Crisp and modern`},{id:`plex`,label:`IBM Plex Sans`,help:`Technical, with character`},{id:`manrope`,label:`Manrope`,help:`Round and friendly`},{id:`dm-sans`,label:`DM Sans`,help:`Geometric, low contrast`},{id:`jakarta`,label:`Plus Jakarta Sans`,help:`Polished product sans`},{id:`figtree`,label:`Figtree`,help:`Clean and approachable`},{id:`outfit`,label:`Outfit`,help:`Geometric display feel`},{id:`nunito`,label:`Nunito`,help:`Soft rounded terminals`},{id:`space-grotesk`,label:`Space Grotesk`,help:`Quirky, technical`},{id:`source-sans`,label:`Source Sans 3`,help:`Classic UI workhorse`}],Ue=[{id:`theme`,label:`System mono`,help:`The system's own (or the colour theme's)`},{id:`jetbrains`,label:`JetBrains Mono`,help:`Tall, made for code`},{id:`geist-mono`,label:`Geist Mono`,help:`Pairs with Geist`},{id:`fira-code`,label:`Fira Code`,help:`Ligatures for operators`},{id:`roboto-mono`,label:`Roboto Mono`,help:`Even and compact`},{id:`source-code`,label:`Source Code Pro`,help:`Open and readable`}],We={font:`bot-lobby.typeface`,mono:`bot-lobby.typeface-code`},Ge={font:He,mono:Ue},Ke={font:`theme`,mono:`theme`},qe=new Set;function Je(e){let t=null;try{t=localStorage.getItem(We[e])}catch{t=Ke[e]}return Ge[e].some(e=>e.id===t)?t:`theme`}function Ye(e,t){let n=document.documentElement;t===`theme`?delete n.dataset[e]:n.dataset[e]=t}function Xe(e,t){Ke[e]=t;try{localStorage.setItem(We[e],t)}catch{}Ye(e,t);for(let e of qe)e()}function Ze(e){return qe.add(e),()=>qe.delete(e)}function Qe(e){return(0,m.useSyncExternalStore)(Ze,()=>Je(e),()=>`theme`)}typeof document<`u`&&(Ye(`font`,Je(`font`)),Ye(`mono`,Je(`mono`)));var $e={inter:`"Inter Variable", system-ui, sans-serif`,geist:`"Geist Variable", system-ui, sans-serif`,plex:`"IBM Plex Sans Variable", system-ui, sans-serif`,manrope:`"Manrope Variable", system-ui, sans-serif`,jetbrains:`"JetBrains Mono Variable", ui-monospace, monospace`,"geist-mono":`"Geist Mono Variable", ui-monospace, monospace`,"dm-sans":`"DM Sans Variable", system-ui, sans-serif`,jakarta:`"Plus Jakarta Sans Variable", system-ui, sans-serif`,figtree:`"Figtree Variable", system-ui, sans-serif`,outfit:`"Outfit Variable", system-ui, sans-serif`,nunito:`"Nunito Variable", system-ui, sans-serif`,"space-grotesk":`"Space Grotesk Variable", system-ui, sans-serif`,"source-sans":`"Source Sans 3 Variable", system-ui, sans-serif`,"fira-code":`"Fira Code Variable", ui-monospace, monospace`,"roboto-mono":`"Roboto Mono Variable", ui-monospace, monospace`,"source-code":`"Source Code Pro Variable", ui-monospace, monospace`},et=(0,m.createContext)({});function tt(e){let t=(0,m.useRef)(null);return t.current===null&&(t.current=e()),t.current}var nt=typeof window<`u`?m.useLayoutEffect:m.useEffect,rt=(0,m.createContext)(null);function it(e,t){e.indexOf(t)===-1&&e.push(t)}function at(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var ot=(e,t,n)=>n>t?t:n<e?e:n,st={},ct=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),lt=e=>typeof e==`object`&&!!e,ut=e=>/^0[^.\s]+$/u.test(e);function dt(e){let t;return()=>(t===void 0&&(t=e()),t)}var ft=e=>e,pt=(...e)=>e.reduce((e,t)=>n=>t(e(n))),mt=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},ht=class{constructor(){this.subscriptions=[]}add(e){return it(this.subscriptions,e),()=>this.remove(e)}remove(e){at(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r){if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},gt=e=>e*1e3,_t=e=>e/1e3,vt=(e,t)=>t?1e3/t*e:0,yt=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,bt=1e-7,xt=12;function St(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=yt(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>bt&&++s<xt);return o}function Ct(e,t,n,r){if(e===t&&n===r)return ft;let i=t=>St(t,0,1,e,n);return e=>e===0||e===1?e:yt(i(e),t,r)}var wt=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Tt=e=>t=>1-e(1-t),Et=Ct(.33,1.53,.69,.99),Dt=Tt(Et),Ot=wt(Dt),kt=e=>e>=1?1:(e*=2)<1?.5*Dt(e):.5*(2-2**(-10*(e-1))),At=e=>1-Math.sin(Math.acos(e)),jt=Tt(At),Mt=wt(At),Nt=Ct(.42,0,1,1),Pt=Ct(0,0,.58,1),Ft=Ct(.42,0,.58,1),It=e=>Array.isArray(e)&&typeof e[0]!=`number`,Lt=e=>Array.isArray(e)&&typeof e[0]==`number`,Rt={linear:ft,easeIn:Nt,easeInOut:Ft,easeOut:Pt,circIn:At,circInOut:Mt,circOut:jt,backIn:Dt,backInOut:Ot,backOut:Et,anticipate:kt},zt=e=>typeof e==`string`,Bt=e=>{if(Lt(e)){e.length;let[t,n,r,i]=e;return Ct(t,n,r,i)}return zt(e)?(Rt[e],`${e}`,Rt[e]):e},Vt={delta:0,timestamp:0,isProcessing:!1},Ht;function Ut(){Ht=void 0}var Wt={now:()=>(Ht===void 0&&Wt.set(Vt.isProcessing||st.useManualTiming?Vt.timestamp:performance.now()),Ht),set:e=>{Ht=e,queueMicrotask(Ut)}},Gt=e=>Math.round(e*1e5)/1e5,Kt=e=>t=>typeof t==`string`&&t.startsWith(e),qt=Kt(`--`),Jt=Kt(`var(--`),Yt=e=>Jt(e)?Xt.test(e.split(`/*`)[0].trim()):!1,Xt=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Zt(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var Qt={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},$t={...Qt,transform:e=>ot(0,1,e)},en={...Qt,default:1},tn=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function nn(e){return e==null}var rn=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,an=(e,t)=>n=>!!(typeof n==`string`&&rn.test(n)&&n.startsWith(e)||t&&!nn(n)&&Object.prototype.hasOwnProperty.call(n,t)),on=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(tn);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},sn=e=>ot(0,255,e),cn={...Qt,transform:e=>Math.round(sn(e))},ln={test:an(`rgb`,`red`),parse:on(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+cn.transform(e)+`, `+cn.transform(t)+`, `+cn.transform(n)+`, `+Gt($t.transform(r))+`)`};function un(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var dn={test:an(`#`),parse:un,transform:ln.transform},fn=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),pn=fn(`deg`),mn=fn(`%`),R=fn(`px`),hn=fn(`vh`),gn=fn(`vw`),_n={...mn,parse:e=>mn.parse(e)/100,transform:e=>mn.transform(e*100)},vn={test:an(`hsl`,`hue`),parse:on(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+mn.transform(Gt(t))+`, `+mn.transform(Gt(n))+`, `+Gt($t.transform(r))+`)`},yn={test:e=>ln.test(e)||dn.test(e)||vn.test(e),parse:e=>ln.test(e)?ln.parse(e):vn.test(e)?vn.parse(e):dn.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?ln.transform(e):vn.transform(e),getAnimatableNone:e=>{let t=yn.parse(e);return t.alpha=0,yn.transform(t)}},bn=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,xn=new RegExp(tn.source),Sn=new RegExp(bn.source,`i`);function Cn(e){return isNaN(e)&&typeof e==`string`&&(xn.test(e)||Sn.test(e))}var wn=`number`,Tn=`color`,En=`var`,Dn=`var(`,On="${}",kn=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function An(e){let t=e.toString();return xn.test(t)||Sn.test(t)}function jn(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(kn,e=>(yn.test(e)?(r.color.push(a),i.push(Tn),n.push(yn.parse(e))):e.startsWith(Dn)?(r.var.push(a),i.push(En),n.push(e)):(r.number.push(a),i.push(wn),n.push(parseFloat(e))),++a,On)).split(On),indexes:r,types:i}}function Mn(e){return jn(e).values}function Nn({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];i+=e===wn?Gt(r[a]):e===Tn?yn.transform(r[a]):r[a]}return i}}function Pn(e){return Nn(jn(e))}var Fn=e=>typeof e==`number`?0:yn.test(e)?yn.getAnimatableNone(e):e,In=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:Fn(e);function Ln(e){let t=jn(e);return Nn(t)(t.values.map((e,n)=>In(e,t.split[n])))}var Rn={test:Cn,parse:Mn,createTransformer:Pn,getAnimatableNone:Ln};function zn(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Bn({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=zn(s,r,e+1/3),a=zn(s,r,e),o=zn(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function Vn(e,t){return n=>n>0?t:e}var Hn=(e,t,n)=>e+(t-e)*n,Un=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},Wn=[dn,ln,vn],Gn=e=>Wn.find(t=>t.test(e));function Kn(e){let t=Gn(e);if(!t)return`${e}`,!1;let n=t.parse(e);return t===vn&&(n=Bn(n)),n}var qn=(e,t)=>{let n=Kn(e),r=Kn(t);if(!n||!r)return Vn(e,t);let i={...n};return e=>(i.red=Un(n.red,r.red,e),i.green=Un(n.green,r.green,e),i.blue=Un(n.blue,r.blue,e),i.alpha=Hn(n.alpha,r.alpha,e),ln.transform(i))},Jn=new Set([`none`,`hidden`]);function Yn(e,t){return Jn.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Xn(e,t){return n=>Hn(e,t,n)}function Zn(e){return typeof e==`number`?Xn:typeof e==`string`?Yt(e)?Vn:yn.test(e)?qn:tr:Array.isArray(e)?Qn:typeof e==`object`?yn.test(e)?qn:$n:Vn}function Qn(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>Zn(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function $n(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Zn(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function er(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]],s=e.values[o]??0;n[i]=s,r[a]++}return n}var tr=(e,t)=>{let n=Rn.createTransformer(t),r=jn(e),i=jn(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?Jn.has(e)&&!i.values.length||Jn.has(t)&&!r.values.length?Yn(e,t):pt(Qn(er(r,i),i.values),n):(`${e}${t}`,Vn(e,t))},nr=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]*)$/iu;function rr(e,t){let n=nr.exec(e);if(!n)return;let r=nr.exec(t);if(!r||n[2]!==r[2])return;let i=n[2],a=parseFloat(n[1]),o=parseFloat(r[1]);return e=>Gt(Hn(a,o,e))+i}function ir(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return Hn(e,t,n);if(typeof e==`string`&&typeof t==`string`){let n=rr(e,t);if(n)return n}return Zn(e)(e,t)}var ar=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function or(e){let t=new Set,n=new Set,r=!1,i=!1,a=new Set,o={delta:0,timestamp:0,isProcessing:!1};function s(t){a.has(t)&&(n.add(t),e()),t(o)}let c={schedule:(e,i=!1,o=!1)=>{let s=o&&r?t:n;return i&&a.add(e),s.add(e),e},cancel:e=>{n.delete(e),a.delete(e)},process:e=>{if(o=e,r){i=!0;return}r=!0;let a=t;t=n,n=a,t.forEach(s),t.clear(),r=!1,i&&(i=!1,c.process(e))}};return c}var sr=40;function cr(e,t,n={delta:0,timestamp:0,isProcessing:!1}){let r=!1,i=!0,a=()=>r=!0,o=ar.reduce((e,t)=>(e[t]=or(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=st.useManualTiming,o=a?n.timestamp:performance.now();r=!1,a||(n.delta=i?1e3/60:Math.max(Math.min(o-n.timestamp,sr),1)),n.timestamp=o,n.isProcessing=!0,s.process(n),c.process(n),l.process(n),u.process(n),d.process(n),f.process(n),p.process(n),m.process(n),n.isProcessing=!1,r&&t&&(i=!1,e(h))},g=()=>{r=!0,i=!0,n.isProcessing||e(h)};return{schedule:ar.reduce((e,t)=>{let n=o[t];return e[t]=(e,t=!1,i=!1)=>(r||g(),n.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<ar.length;t++)o[ar[t]].cancel(e)},state:n,steps:o}}var{schedule:lr,cancel:ur,steps:dr}=cr(typeof requestAnimationFrame<`u`?requestAnimationFrame:ft,!0,Vt),fr=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>lr.update(t,e),stop:()=>ur(t),now:()=>Vt.isProcessing?Vt.timestamp:Wt.now()}},pr=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},mr=2e4;function hr(e,t=50,n=mr,r){let i=0,a=e.next(i);for(r?.push(a.value);!a.done&&i<n;)i+=t,a=e.next(i),r?.push(a.value);return i>=n?1/0:i}function gr(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(hr(r),mr);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:_t(i)}}var _r={stiffness:100,damping:10,mass:1,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05},vr=e=>e<0?1/Math.max(1+e,_r.minDamping):Math.max(1-e,_r.minDamping);function yr(e,t){if(!(e>1))return 1;let n=Math.sqrt(e*e-1),r=e-n,i=e+n,a=2*n*Math.exp(-t)*(1+t);return Sr(e=>i*Math.exp(-r*e)-r*Math.exp(-i*e)-a,e=>Math.exp(-i*e)-Math.exp(-r*e),t)/t}function br(e,t){return e*Math.sqrt(1-t*t)}var xr=12;function Sr(e,t,n){let r=n;for(let n=1;n<xr;n++)r-=e(r)/t(r);return r}var Cr=.001;function wr({duration:e=_r.duration,bounce:t=_r.bounce}){let n,r;_r.maxDuration;let i=vr(t);e=ot(_r.minDuration,_r.maxDuration,_t(e)),i<1?(n=t=>{let n=t*i,r=n*e,a=br(t,i),o=Math.exp(-r);return Cr-n/a*o},r=t=>{let r=t*i*e,a=i*i*t*t*e,o=Math.exp(-r),s=br(t*t,i);return(-n(t)+Cr>0?-1:1)*-a*o/s}):(n=t=>-.001+Math.exp(-t*e)*(t*e+1),r=t=>Math.exp(-t*e)*(-t*(e*e)));let a=5/e,o=Sr(n,r,a),s=o*yr(i,o*e),c=s*s;return{stiffness:c,damping:i*2*Math.sqrt(c),duration:gt(e)}}var Tr=(e,t)=>(t?e>=0:e>0)&&e<1/0;function Er(e,t){if(Tr(e,t))return e}function Dr(e){let t=Er(e.stiffness),n=Er(e.damping,!0),r=Er(e.mass),i={...e,stiffness:t??_r.stiffness,damping:n??_r.damping,mass:r??_r.mass,isResolvedFromDuration:!1,isTimeDefined:(t??n??r)===void 0&&(e.duration!==void 0||e.bounce!==void 0)};if(i.isTimeDefined){if(e.visualDuration){let t=vr(e.bounce||0),n=2*Math.PI/(e.visualDuration*1.2)*yr(t,2*Math.PI/1.2);i.stiffness=n*n,i.damping=2*t*Math.sqrt(i.stiffness)}else Object.assign(i,wr(i)),i.isResolvedFromDuration=!0;(!Tr(i.stiffness)||!Tr(i.damping,!0))&&(i.stiffness=_r.stiffness,i.damping=_r.damping)}return i}function Or(e=_r.visualDuration,t=_r.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},r=n.keyframes[0],i=n.keyframes[n.keyframes.length-1],a={done:!1,value:r},{stiffness:o,damping:s,mass:c,duration:l,isResolvedFromDuration:u,isTimeDefined:d}=Dr({...n}),f=e=>d?0:-_t(e),p=s/(2*Math.sqrt(o*c)),m=_t(Math.sqrt(o/c)),h=p*m,g={target:i,delta:i-r,velocity:f(n.velocity||0)||0,restSpeed:0,restDelta:0},_=()=>{let e=Math.abs(g.delta)<5;g.restSpeed=n.restSpeed||(e?_r.restSpeed.granular:_r.restSpeed.default),g.restDelta=n.restDelta||(e?_r.restDelta.granular:_r.restDelta.default)};_();let v,y,b;if(p<1){let e=br(m,p),t={A:0,sinC:0,cosC:0,t:-1,env:0,sin:0,cos:0};b=()=>{t.A=(g.velocity+h*g.delta)/e,t.sinC=h*t.A+g.delta*e,t.cosC=h*g.delta-t.A*e};let n=n=>{n!==t.t&&(t.t=n,t.env=Math.exp(-h*n),t.sin=Math.sin(e*n),t.cos=Math.cos(e*n))};v=e=>(n(e),g.target-t.env*(t.A*t.sin+g.delta*t.cos)),y=e=>(n(e),t.env*(t.sinC*t.sin+t.cosC*t.cos))}else if(p===1){v=e=>g.target-Math.exp(-m*e)*(g.delta+(g.velocity+m*g.delta)*e);let e={C:0};b=()=>{e.C=g.velocity+m*g.delta},y=t=>Math.exp(-m*t)*(m*e.C*t-g.velocity)}else{let e=m*Math.sqrt(p*p-1),t=h-e,n=h+e,r=d?1/0:300/e,i=(e,t)=>Math.exp(t>r?-e*r-h*(t-r):-e*t),a={S:0,F:0};b=()=>{let t=(g.velocity+h*g.delta)/e;a.S=(g.delta+t)/2,a.F=(g.delta-t)/2},v=e=>g.target-a.S*i(t,e)-a.F*i(n,e),y=e=>t*a.S*i(t,e)+n*a.F*i(n,e)}b();let x=u&&l||null,S={calculatedDuration:x,retarget:(e,t)=>{g.target=e[e.length-1],g.delta=g.target-e[0],g.velocity=f(t),n.restSpeed&&n.restDelta||_(),S.calculatedDuration=x,a.done=!1,b()},velocity:e=>gt(y(e)),next:e=>{let t=v(e);if(u)a.done=e>=l;else{let n=gt(y(e));a.done=Math.abs(n)<=g.restSpeed&&Math.abs(g.target-t)<=g.restDelta}return a.value=a.done?g.target:t,a},toString:()=>{let e=Math.min(hr(S),mr),t=pr(t=>S.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return S}Or.applyToOptions=e=>{let t=gr(e,100,Or);return e.ease=t.ease,e.duration=gt(t.duration),e.type=`keyframes`,e};function kr({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>e<s||e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>{let t=v(e);f.done=Math.abs(t)<=l,f.value=f.done?_:_+t},b,x,S=e=>{p(f.value)&&(b=e,x=Or({keyframes:[f.value,m(f.value)],velocity:-v(e)/r*1e3,damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return S(0),{calculatedDuration:null,next:e=>{let t=!1;return!x&&b===void 0&&(t=!0,y(e),S(e)),b!==void 0&&e>=b?x.next(e-b):(!t&&y(e),f)}}}function Ar(e,t,n){let r=[],i=n||st.mix||ir,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=pt(Array.isArray(t)?t[n]||ft:t,a)),r.push(a)}return r}function jr(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=Ar(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=mt(e[r],e[r+1],n);return s[r](i)};return n?t=>l(ot(e[0],e[a-1],t)):l}function Mr(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=mt(0,t,r);e.push(Hn(n,1,i))}}function Nr(e){let t=[0];return Mr(t,e.length-1),t}function Pr(e,t){return e.map(e=>e*t)}function Fr(e,t){return e.map(()=>t||Ft).splice(0,e.length-1)}function Ir({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=It(r)?r.map(Bt):Bt(r)||Ft,a={done:!1,value:t[0]};if(t.length===2&&!Array.isArray(i)&&(!n||n.length!==2||n[0]===0&&n[1]===1)){let[n,r]=t,o=n===r?void 0:(st.mix||ir)(n,r);return{calculatedDuration:e,next:t=>(a.value=o?o(i(e>0?ot(0,1,t/e):1)):r,a.done=t>=e,a)}}let o=jr(Pr(n&&n.length===t.length?n:Nr(t),e),t,{ease:Array.isArray(i)?i:Fr(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var Lr=5;function Rr(e,t,n){let r=Math.max(t-Lr,0);return vt(n-e(r),t-r)}function zr(e,t,n=0){return t<=0?n:e.velocity?e.velocity(t):Rr(t=>e.next(t).value,t,e.next(t).value)}var Br=e=>e!==null;function Vr(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(Br),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var Hr={decay:kr,inertia:kr,tween:Ir,keyframes:Ir,spring:Or};function Ur(e){typeof e.type==`string`&&(e.type=Hr[e.type])}function Wr(e,t){return{kind:e,animation:t,timestamp:Wt.now(),frameTimestamp:Vt.timestamp,frameIsProcessing:Vt.isProcessing}}function Gr(e,t,n){let r=globalThis.__MOTION_INSPECT__;if(r)try{r({...Wr(`animation-start`,e),options:n?{...t,...n}:t})}catch{}}function Kr(e,t){let n=globalThis.__MOTION_INSPECT__;if(n)try{n({...Wr(`layout-animation-start`,e),node:t})}catch{}}var qr=class{constructor(){this.isResolved=!1}get finished(){return this._finished||=this.isResolved?Promise.resolve():new Promise(e=>{this._resolve=e}),this._finished}updateFinished(){this._finished=this._resolve=void 0,this.isResolved=!1}notifyFinished(){this.isResolved=!0,this._resolve?.()}then(e,t){return this.finished.then(e,t)}},Jr=e=>e/100,Yr=class extends qr{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==Wt.now()&&this.tick(Wt.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause(),Gr(this,this.options)}initAnimation(){let{options:e}=this;Ur(e);let{type:t=Ir,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||Ir;s!==Ir&&typeof o[0]!=`number`&&(this.mixKeyframes=pt(Jr,ir(o[0],o[1])),o=[0,100]);let c=s(o===e.keyframes?e:{...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=hr(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.currentTime=this.holdTime===null?t:this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=ot(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==kr&&(b.value=Vr(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return _t(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+_t(e)}get time(){return _t(this.currentTime)}set time(e){e=gt(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){return zr(this.generator,this.currentTime,this.options.velocity)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(Wt.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=_t(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=fr,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??n:this.startTime=n-this.holdTime,this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(Wt.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}},Xr=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function Zr(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(tn)||[];if(!r)return e;let i=n.replace(r,``),a=+!!Xr.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var Qr=/\b([a-z-]*)\(.*?\)/gu,$r={...Rn,getAnimatableNone:e=>{let t=e.match(Qr);return t?t.map(Zr).join(` `):e}},ei={...Rn,getAnimatableNone:e=>{let t=Rn.parse(e);return Rn.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},ti={...Qt,transform:Math.round},ni={borderWidth:R,borderTopWidth:R,borderRightWidth:R,borderBottomWidth:R,borderLeftWidth:R,borderRadius:R,borderTopLeftRadius:R,borderTopRightRadius:R,borderBottomRightRadius:R,borderBottomLeftRadius:R,width:R,maxWidth:R,height:R,maxHeight:R,top:R,right:R,bottom:R,left:R,inset:R,insetBlock:R,insetBlockStart:R,insetBlockEnd:R,insetInline:R,insetInlineStart:R,insetInlineEnd:R,padding:R,paddingTop:R,paddingRight:R,paddingBottom:R,paddingLeft:R,paddingBlock:R,paddingBlockStart:R,paddingBlockEnd:R,paddingInline:R,paddingInlineStart:R,paddingInlineEnd:R,margin:R,marginTop:R,marginRight:R,marginBottom:R,marginLeft:R,marginBlock:R,marginBlockStart:R,marginBlockEnd:R,marginInline:R,marginInlineStart:R,marginInlineEnd:R,fontSize:R,backgroundPositionX:R,backgroundPositionY:R,rotate:pn,pathRotation:pn,rotateX:pn,rotateY:pn,rotateZ:pn,scale:en,scaleX:en,scaleY:en,scaleZ:en,skew:pn,skewX:pn,skewY:pn,distance:R,translateX:R,translateY:R,translateZ:R,x:R,y:R,z:R,perspective:R,transformPerspective:R,opacity:$t,originX:_n,originY:_n,originZ:R,zIndex:ti,fillOpacity:$t,strokeOpacity:$t,numOctaves:ti},ri={...ni,color:yn,backgroundColor:yn,outlineColor:yn,fill:yn,stroke:yn,borderColor:yn,borderTopColor:yn,borderRightColor:yn,borderBottomColor:yn,borderLeftColor:yn,filter:$r,WebkitFilter:$r,mask:ei,WebkitMask:ei},ii=e=>ri[e],ai=new Set([$r,ei]);function oi(e,t){let n=ii(e);return ai.has(n)||(n=Rn),n.getAnimatableNone?n.getAnimatableNone(t):void 0}function si(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var ci=e=>e*180/Math.PI,li=e=>di(ci(Math.atan2(e[1],e[0]))),ui={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:li,rotateZ:li,skewX:e=>ci(Math.atan(e[1])),skewY:e=>ci(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},di=e=>(e%=360,e<0&&(e+=360),e),fi=li,pi=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),mi=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),hi={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:pi,scaleY:mi,scale:e=>(pi(e)+mi(e))/2,rotateX:e=>di(ci(Math.atan2(e[6],e[5]))),rotateY:e=>di(ci(Math.atan2(-e[2],e[0]))),rotateZ:fi,rotate:fi,skewX:e=>ci(Math.atan(e[4])),skewY:e=>ci(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function gi(e){return+!!e.includes(`scale`)}function _i(e,t){if(!e||e===`none`)return gi(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=hi,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=ui,i=t}if(!i)return gi(t);let a=r[t],o=i[1].split(`,`).map(yi);return typeof a==`function`?a(o):o[a]}var vi=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return _i(n,t)};function yi(e){return parseFloat(e.trim())}var bi=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],xi=new Set([...bi,`pathRotation`]),Si=e=>e===Qt||e===R,Ci=new Set([`x`,`y`,`z`]),wi=bi.filter(e=>!Ci.has(e));function Ti(e){let t=[];return wi.forEach(n=>{let r=e.getValue(n);if(r!==void 0){let e=r.get(),i=+!!n.startsWith(`scale`);if(e===i)return;t.push([n,e]),r.set(i)}}),t}var Ei=new Set([`bottom`,`right`]);function Di(e,t,n,r,i,a){let o=parseFloat(e);if(!isNaN(o))return o;let{min:s,max:c}=t()[n],l=c-s;return a===`border-box`?l:l-parseFloat(r)-parseFloat(i)}var Oi={width:({width:e,paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r},i)=>Di(e,i,`x`,t,n,r),height:({height:e,paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r},i)=>Di(e,i,`y`,t,n,r),top:({top:e})=>parseFloat(e),left:({left:e})=>parseFloat(e),bottom:({top:e},t)=>{let{y:n}=t();return parseFloat(e)+(n.max-n.min)},right:({left:e},t)=>{let{x:n}=t();return parseFloat(e)+(n.max-n.min)},x:({transform:e})=>_i(e,`x`),y:({transform:e})=>_i(e,`y`)};Oi.translateX=Oi.x,Oi.translateY=Oi.y;var ki=new Set,Ai=!1,ji=!1,Mi=!1;function Ni(){if(ji){let e=[],t=new Set,n=new Set;ki.forEach(r=>{r.needsMeasurement&&(e.push(r),t.add(r.element),Ei.has(r.name)&&n.add(r.element))});let r=new Map;n.forEach(e=>{let t=Ti(e);t.length&&(r.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=r.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}ji=!1,Ai=!1,ki.forEach(e=>e.complete(Mi)),ki.clear()}function Pi(){ki.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(ji=!0)})}function Fi(){Mi=!0,Pi(),Ni(),Mi=!1}function Ii(e,t,n){if(typeof e==`string`){if(ct(e)||ut(e))return parseFloat(e);if(!Rn.test(e)&&Rn.test(n))return oi(t,n)}return e??void 0}var Li=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(ki.add(this),Ai||(Ai=!0,lr.read(Pi),lr.resolveKeyframes(Ni))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=Ii(n.readValue(t,a),t,a);r!==void 0&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}si(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),ki.delete(this)}cancel(){this.state===`scheduled`&&(ki.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},Ri=e=>e.startsWith(`--`);function zi(e,t,n){Ri(t)?e.style.setProperty(t,n):e.style[t]=n}var Bi={};function Vi(e,t){let n=dt(e);return()=>Bi[t]??n()}var Hi=Vi(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),Ui=Vi(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),Wi=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Gi={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:Wi([0,.65,.55,1]),circOut:Wi([.55,0,1,.45]),backIn:Wi([.31,.01,.66,-.59]),backOut:Wi([.33,1.53,.69,.99])};function Ki(e,t){if(e)return typeof e==`function`?Ui()?pr(e,t):`ease-out`:Lt(e)?Wi(e):Array.isArray(e)?e.map(e=>Ki(e,t)||Gi.easeOut):Gi[e]}function qi(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=Ki(s,i);Array.isArray(d)&&(u.easing=d);let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};return l&&(f.pseudoElement=l),e.animate(u,f)}function Ji(e){return typeof e==`function`&&`applyToOptions`in e}function Yi({type:e,...t}){return Ji(e)&&Ui()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var Xi=class extends qr{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=Yi(e);this.animation=qi(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=Vr(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),zi(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()},Gr(this,e,c)}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e!==`idle`&&e!==`finished`&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return _t(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+_t(e)}get time(){return _t(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=gt(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,onAttach:t,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&Hi()?(this.animation.timeline=e,t?.(this.animation),ft):n(this)}},Zi={anticipate:kt,backInOut:Ot,circInOut:Mt};function Qi(e){return e in Zi}function $i(e){typeof e.ease==`string`&&Qi(e.ease)&&(e.ease=Zi[e.ease])}var ea=10,ta=class extends Xi{constructor(e){$i(e),Ur(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new Yr({...a,autoplay:!1}),s=Math.max(ea,Wt.now()-this.startTime),c=ot(0,ea,s-ea),l=o.sample(s).value,{name:u}=this.options;i&&u&&zi(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},na=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(Rn.test(e)||e===`0`)&&!e.startsWith(`url(`));function ra(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function z(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=na(i,t),s=na(a,t);return!o||!s?(o!==s&&`${t}${i}${a}${o?a:i}`,!1):ra(e)||(n===`spring`||Ji(n))&&r}function ia(e){e.duration=0,e.type=`keyframes`}var aa=new Set([`opacity`,`clipPath`,`filter`,`transform`,`backgroundColor`]),oa=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function sa(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&oa.test(e[t]))return!0;return!1}var ca=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),la=dt(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function ua(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!n||!(aa.has(n)||ca.has(n)))return!1;let c=t?.owner?.current;if(!(c instanceof HTMLElement)&&!(c instanceof SVGElement))return!1;let{onUpdate:l,transformTemplate:u}=t.owner.getProps();return la()&&(aa.has(n)||ca.has(n)&&sa(s))&&(n!==`transform`||!u)&&!l&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var da=40,fa=class extends qr{constructor(e){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Wt.now();let{keyframes:t,name:n,motionValue:r,element:i}=e,a=e;a.autoplay??=!0,a.delay??=0,a.type??=`keyframes`,a.repeat??=0,a.repeatDelay??=0,a.repeatType??=`loop`;let o=i?.KeyframeResolver||Li;this.keyframeResolver=new o(t,(e,t,n)=>this.onKeyframesResolved(e,t,a,!n),n,r,i),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=Wt.now();let u=!0;z(e,i,a,o)||(u=!1,(st.instantAnimations||!s)&&l?.(Vr(e,n,t)),e[0]=e[e.length-1],ia(n),n.repeat=0);let d=r?this.resolvedAt&&this.resolvedAt-this.createdAt>da?this.resolvedAt:this.createdAt:void 0,{onComplete:f}=n;n.startTime??=d,n.finalKeyframe=t,n.keyframes=e,n.onComplete=()=>{f?.(),this.notifyFinished()};let p=u&&!c&&ua(n),m;if(p){n.element=n.motionValue?.owner?.current;try{m=new ta(n)}catch{m=new Yr(n)}}else m=new Yr(n);this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this._animation.finished:super.finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Fi()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function pa(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var ma=30,ha=e=>!isNaN(parseFloat(e)),ga={current:void 0},_a=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=Wt.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.notifyChange(),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=Wt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=ha(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){var n;return e===`change`?this.onChangeSubscribe(t):((n=this.events)[e]||(n[e]=new ht)).add(t)}onChangeSubscribe(e){let{events:t}=this;return!t.change&&!this.changeSubscriber?this.changeSubscriber=e:(t.change||(t.change=new ht,t.change.add(this.changeSubscriber),this.changeSubscriber=void 0),t.change.add(e)),()=>{this.changeSubscriber===e?this.changeSubscriber=void 0:t.change?.remove(e),this.stopIfUnobserved()}}stopIfUnobserved(){lr.read(()=>{!this.changeSubscriber&&!this.events.change?.getSize()&&this.stop()})}clearListeners(){this.changeSubscriber=void 0;for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.notifyChange()}notifyChange(){let{current:e,changeSubscriber:t}=this;t?t(e):this.events.change?.notify(e)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return ga.current&&ga.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=Wt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>ma)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,ma);return vt(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0;let n=!1,r;r=e(()=>{n=!0,this.events.animationComplete?.notify(),this.animation===r&&this.clearAnimation(),t()}),n||(this.animation=r),this.events.animationStart?.notify()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){this.animation=void 0}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function va(e,t){return new _a(e,t)}function ya(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function ba(e,t){let n=e?.[t]??e?.default??e;return n===e?n:ya(n,e)}var xa={type:`spring`,stiffness:500,damping:25,restSpeed:10},Sa=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Ca={type:`keyframes`,duration:.8},wa={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Ta=(e,{keyframes:t})=>t.length>2?Ca:xi.has(e)?e.startsWith(`scale`)?Sa(t[1]):xa:wa,Ea=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function Da(e){for(let t in e)if(!Ea.has(t))return!0;return!1}var Oa=(e,t,n,r={},i,a)=>o=>{let s=ba(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=gt(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};Da(s)||Object.assign(u,Ta(e,u)),u.duration&&=gt(u.duration),u.repeatDelay&&=gt(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(ia(u),u.delay===0&&(d=!0)),(st.instantAnimations||st.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,ia(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=Vr(u.keyframes,s);if(e!==void 0){lr.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new Yr(u):new fa(u)},ka=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Aa(e){let t=ka.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function ja(e,t,n=1){`${e}`;let[r,i]=Aa(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return ct(e)?parseFloat(e):e}return Yt(i)?ja(i,t,n+1):i}function Ma(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Na(e,t,n,r){let i=t=>typeof t==`function`?t(n===void 0?e.custom:n,...Ma(r)):t;return t=i(t),typeof t==`string`&&(t=e.variants&&e.variants[t]),i(t)}function Pa(e,t,n){return Na(e.getProps(),t,n,e)}var Fa=(e,t)=>t===`exit`?e.presenceContext?.custom:void 0,Ia=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...bi]),La=e=>Array.isArray(e);function Ra(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,va(n))}function za(e){return La(e)?e[e.length-1]||0:e}function Ba(e,t){let{transitionEnd:n={},transition:r={},...i}=Pa(e,t)||{};i={...i,...n};for(let t in i)Ra(e,t,za(i[t]))}var Va=e=>!!(e&&e.getVelocity);function Ha(e){return!!(Va(e)&&e.add)}function Ua(e,t){let n=e.getValue(`willChange`);if(Ha(n))return n.add(t);if(!n&&st.WillChange){let n=new st.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function Wa(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var Ga=`data-`+Wa(`framerAppearId`);function Ka(e){return e.props[Ga]}var qa=typeof window<`u`;function Ja({protectedKeys:e,needsAnimating:t},n){let r=n in e&&!t[n];return t[n]=!1,r}function Ya(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?ya(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f=i&&e.animationState?.getState()[i],p=a?.path;p&&p.animateVisualElement(e,s,a,n,d);for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||f&&Ja(f,t))continue;let o={delay:n,...ba(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){lr.update(()=>r.set(i));continue}let p=!1;if(qa&&window.MotionHandoffAnimation){let n=Ka(e);if(n){let e=window.MotionHandoffAnimation(n,t,lr);e!==null&&(o.startTime=e,p=!0)}}Ua(e,t);let m=l??e.shouldReduceMotion;r.start(Oa(t,r,i,m&&Ia.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>lr.update(()=>{o&&Ba(e,o)});d.length?Promise.all(d).then(t):t()}return d}function Xa(e,t,n={}){let r=Pa(e,t,Fa(e,n.type)),i=n.transitionOverride||(r?.transition??(e.getDefaultTransition()||{})),a=()=>Promise.all(r?Ya(e,r,n):[]),o=(r=0)=>{let{variantChildren:a}=e,{delayChildren:o=0,staggerChildren:s,staggerDirection:c}=i,l=[];return a?.forEach(e=>{e.notify(`AnimationStart`,t),l.push(Xa(e,t,{...n,delay:r+(typeof o==`function`?0:o)+pa(a,e,o,s,c)}).then(()=>e.notify(`AnimationComplete`,t)))}),Promise.all(l)},{when:s}=i;return s?s===`beforeChildren`?a().then(()=>o()):o().then(a):Promise.all([a(),o(n.delay)])}function Za(e,t,n={}){return e.notify(`AnimationStart`,t),(Array.isArray(t)?Promise.all(t.map(t=>Xa(e,t,n))):typeof t==`string`?Xa(e,t,n):Promise.all(Ya(e,Pa(e,t,n.custom),n))).then(()=>{e.notify(`AnimationComplete`,t)})}var Qa={test:e=>e===`auto`,parse:e=>e},$a=e=>t=>t.test(e),eo=[Qt,R,mn,pn,gn,hn,Qa],to=e=>eo.find($a(e));function no(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||ut(e)}var ro=new Set([`auto`,`none`,`0`]);function io(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!ro.has(t)&&An(t)&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]!==i&&(e[r]=oi(n,i))}var ao=class extends Li{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),Yt(r))){let i=ja(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Ia.has(n)||e.length!==2)return;let[r,i]=e;if(typeof r==`number`&&typeof i==`number`)return;let a=to(r),o=to(i);if(Zt(r)!==Zt(i)&&Oi[n]){this.needsMeasurement=!0;return}if(a!==o){if(Si(a)&&Si(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else Oi[n]&&(this.needsMeasurement=!0)}}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||no(e[t]))&&n.push(t);n.length&&io(e,n,t)}measure(){let{element:e,name:t}=this;return Oi[t](window.getComputedStyle(e.current),()=>e.measureViewportBox())}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=this.measure(),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&this.motionValue?.jump(r,!1)}measureEndState(){let{element:e,unresolvedKeyframes:t}=this;if(!e||!e.current)return;this.motionValue?.jump(this.measuredOrigin,!1);let n=t.length-1,r=t[n];t[n]=this.measure(),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}},oo=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function so(e){return lt(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}function co(e){return lt(e)&&`ownerSVGElement`in e}var lo=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function uo(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var fo={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},po=bi.length;function mo(e,t,n){let r=``,i=!0;for(let a=0;a<po;a++){let o=bi[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===+!!o.startsWith(`scale`);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=lo(s,ni[o]);if(!c){i=!1;let t=fo[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${lo(a,ni.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function ho(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(xi.has(e)){o=!0;continue}if(qt(e)){i[e]=n;continue}{let t=lo(n,ni[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=mo(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}var go={offset:`stroke-dashoffset`,array:`stroke-dasharray`},_o={offset:`strokeDashoffset`,array:`strokeDasharray`};function vo(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?go:_o;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var yo=[`transform`,`opacity`,`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function bo(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(ho(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;for(let e of yo)d[e]!==void 0&&(f[e]=d[e],delete d[e]);(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox),t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&vo(d,i,a,o,!1)}function xo({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function So({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Co(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function wo(e){return e===void 0||e===1}function To({scale:e,scaleX:t,scaleY:n}){return!wo(e)||!wo(t)||!wo(n)}function Eo(e){return To(e)||Do(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Do(e){return Oo(e.x)||Oo(e.y)}function Oo(e){return e&&e!==`0%`}function ko(e,t,n){return n+t*(e-n)}function Ao(e,t,n,r,i){return i!==void 0&&(e=ko(e,i,r)),ko(e,n,r)+t}function jo(e,t=0,n=1,r,i){e.min=Ao(e.min,t,n,r,i),e.max=Ao(e.max,t,n,r,i)}function Mo(e,{x:t,y:n}){jo(e.x,t.translate,t.scale,t.originPoint),jo(e.y,n.translate,n.scale,n.originPoint)}var No=.999999999999,Po=1.0000000000001;function Fo(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(Io(e.x,-a.scroll.offset.x),Io(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,Mo(e,o)),r&&Eo(a.latestValues)&&zo(e,a.latestValues,a.layout?.layoutBox))}t.x<Po&&t.x>No&&(t.x=1),t.y<Po&&t.y>No&&(t.y=1)}function Io(e,t){e.min+=t,e.max+=t}function Lo(e,t,n,r,i=.5){jo(e,t,n,Hn(e.min,e.max,i),r)}function Ro(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function zo(e,t,n){let r=n??e;Lo(e.x,Ro(t.x,r.x),t.scaleX,t.scale,t.originX),Lo(e.y,Ro(t.y,r.y),t.scaleY,t.scale,t.originY)}function Bo(e,t){return xo(Co(e.getBoundingClientRect(),t))}function Vo(e,t,n){let r=Bo(e,n),{scroll:i}=t;return i&&(Io(r.x,i.offset.x),Io(r.y,i.offset.y)),r}var{schedule:B,cancel:Ho}=cr(queueMicrotask,!1),Uo={x:!1,y:!1};function Wo(){return Uo.x||Uo.y}function Go(e){return e===`x`||e===`y`?Uo[e]?null:(Uo[e]=!0,()=>{Uo[e]=!1}):Uo.x||Uo.y?null:(Uo.x=Uo.y=!0,()=>{Uo.x=Uo.y=!1})}function Ko(e,t){let n=uo(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function qo(e){return!(e.pointerType===`touch`||Wo())}function Jo(e,t,n={}){let[r,i,a]=Ko(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{if(e.pointerType!==`touch`){if(n){r=!0;return}s(e)}};e.addEventListener(`pointerenter`,n=>{if(!qo(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var Yo=(e,t)=>t?e===t||Yo(e,t.parentElement):!1,Xo=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Zo=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Qo(e){return Zo.has(e.tagName)||e.isContentEditable===!0}var $o=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function es(e){return $o.has(e.tagName)||e.isContentEditable===!0}var ts=new WeakSet;function ns(e){return t=>{t.key===`Enter`&&e(t)}}function rs(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var is=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=ns(()=>{if(ts.has(n))return;rs(n,`down`);let e=ns(()=>{rs(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>rs(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function as(e){return Xo(e)&&!Wo()}var os=new WeakSet;function ss(e,t,n={}){let[r,i,a]=Ko(e,n),o=e=>{let r=e.currentTarget;if(!as(e)||os.has(e))return;ts.add(r),n.stopPropagation&&os.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),ts.has(r)&&ts.delete(r),as(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||Yo(r,e.target))},l=e=>{s(e,!1)};window.addEventListener(`pointerup`,c,o),window.addEventListener(`pointercancel`,l,o)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),so(e)&&(e.addEventListener(`focus`,e=>is(e,i)),!Qo(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}var cs=new WeakMap,ls,us=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:co(r)&&`getBBox`in r?r.getBBox()[t]:r[n],ds=us(`inline`,`width`,`offsetWidth`),fs=us(`block`,`height`,`offsetHeight`);function ps({target:e,borderBoxSize:t}){cs.get(e)?.forEach(n=>{n(e,{get width(){return ds(e,t)},get height(){return fs(e,t)}})})}function ms(e){e.forEach(ps)}function hs(){typeof ResizeObserver<`u`&&(ls=new ResizeObserver(ms))}function gs(e,t){ls||hs();let n=uo(e);return n.forEach(e=>{let n=cs.get(e);n||(n=new Set,cs.set(e,n)),n.add(t),ls?.observe(e)}),()=>{n.forEach(e=>{let n=cs.get(e);n?.delete(t),n?.size||ls?.unobserve(e)})}}var _s=new Set,vs;function ys(){vs=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};_s.forEach(t=>t(e))},window.addEventListener(`resize`,vs)}function bs(e){return _s.add(e),vs||ys(),()=>{_s.delete(e),!_s.size&&typeof vs==`function`&&(window.removeEventListener(`resize`,vs),vs=void 0)}}function xs(e,t){return typeof e==`function`?bs(e):gs(e,t)}var Ss={value:null,addProjectionMetrics:null};function Cs(e){return co(e)&&e.tagName===`svg`}var ws=e=>typeof e==`number`?e:parseFloat(e),Ts=()=>({translate:0,scale:1,origin:0,originPoint:0}),Es=()=>({x:Ts(),y:Ts()}),Ds=()=>({min:0,max:0}),Os=()=>({x:Ds(),y:Ds()}),ks=new WeakMap;function As(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function js(e){return typeof e==`string`||Array.isArray(e)}var Ms=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],Ns=[`initial`,...Ms];function Ps(e){if(As(e.animate))return!0;for(let t=0;t<Ns.length;t++)if(js(e[Ns[t]]))return!0;return!1}function Fs(e){return!!(Ps(e)||e.variants)}function Is(e,t,n){for(let r in t){let i=t[r],a=n[r];if(Va(i))e.addValue(r,i);else if(Va(a))e.addValue(r,va(i,{owner:e}));else if(a!==i){if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,va(t===void 0?i:t,{owner:e}))}}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var Ls={current:null},Rs={current:!1},zs=typeof window<`u`;function Bs(){if(Rs.current=!0,zs){if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>Ls.current=e.matches;e.addEventListener(`change`,t),t()}else Ls.current=!1}}var Vs=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],Hs={};function Us(e){Hs=e}function Ws(){return Hs}var Gs=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=Li,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=Wt.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,lr.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=Ps(t),this.isVariantNode=Fs(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&Va(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];if(this.current=e,ks.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.isVariantNode&&!this.isControllingVariants){let e=this;do e=e.props.inherit!==!1&&e.parent;while(e&&!e.isVariantNode);if(e){let{variantChildren:t}=e;t.add(this),this.removeFromVariantTree=()=>t.delete(this)}}this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(Rs.current||Bs(),this.shouldReduceMotion=Ls.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),ur(this.notifyUpdate),ur(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&aa.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new Xi({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:gt(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=xi.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&lr.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i()})}sortNodePosition(e){return!this.current||!e.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in Hs){let t=Hs[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Os()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<Vs.length;t++){let n=Vs[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=Is(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}addValue(e,t){let n=this.values.get(e);if(t!==n){n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t);let r=t.get();r!==void 0&&(this.latestValues[e]=r)}}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=va(t??this.getDefaultValue?.(e),{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(ct(n)||ut(n))?n=parseFloat(n):typeof n!=`number`&&!Rn.test(n)&&Rn.test(t)&&(n=oi(e,t)),this.setBaseTarget(e,Va(n)?n.get():n)),Va(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}on(e,t){return this.events[e]||(this.events[e]=new ht),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){B.render(this.render)}},Ks=class extends Gs{constructor(){super(...arguments),this.KeyframeResolver=ao}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;Va(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},qs=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function Js(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}var Ys={};function Xs(e,{layout:t,layoutId:n}){return xi.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!Ys[e]||e===`opacity`)}function Zs(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(Va(r[t])||i&&Va(i[t])||Xs(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function Qs(e){return window.getComputedStyle(e)}var $s=class extends Ks{constructor(){super(...arguments),this.type=`html`,this.renderInstance=Js}mount(e){e.style,super.mount(e)}readValueFromInstance(e,t){if(xi.has(t))return this.projection?.isProjecting?gi(t):vi(e,t);{let n=Qs(e),r=(qt(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return Bo(e,t)}build(e,t,n){ho(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return Zs(e,t,n)}},ec=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),tc=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function nc(e,t,n,r){Js(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(ec.has(n)?n:Wa(n),t.attrs[n])}function rc(e,t,n){let r=Zs(e,t,n);for(let n in e)if(Va(e[n])||Va(t[n])){let t=bi.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var ic=class extends Ks{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=Os}getBaseTargetFromProps(e,t){return xi.has(t)?super.getBaseTargetFromProps(e,t)??gi(t):e[t]}getDefaultValue(e){return xi.has(e)?this.latestValues[e]??gi(e):void 0}readValueFromInstance(e,t){if(xi.has(t)){let e=ii(t);return e&&e.default||0}if(yo.includes(t)){let n=getComputedStyle(e)[t];if(typeof n==`string`&&n)return n.trim()}return t=ec.has(t)?t:Wa(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return rc(e,t,n)}build(e,t,n){bo(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){nc(e,t,n,r)}mount(e){this.isSVGTag=tc(e.tagName),super.mount(e)}};function ac(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var oc=[...Ms].reverse();function sc(e){let t=t=>Promise.all(t.map(({animation:t,options:n})=>Za(e,t,n))),n=lc(),r=!0,i=!1;function a(a){let{props:o,parent:s,manuallyAnimateOnMount:c}=e,l=r||i,u=[],d=new Set,f={},p=1/0,m=e;do m=m.props.inherit!==!1&&m.parent;while(m&&!m.isControllingVariants);if(oc.forEach((t,r)=>{let i=n[t],h=o[t],g=m&&m.props[t],_=h===void 0?js(g)||g===!1?g:void 0:h,v=js(_),y=t===a?i.isActive:null;y===!1&&(p=r);let b=v&&h===void 0&&!(l&&c);if(i.protectedKeys={...f},!i.isActive&&y===null||!_&&!i.prevProp||As(_)||typeof _==`boolean`)return;if(t===`exit`&&i.isActive&&y!==!0){f={...f,...i.prevResolvedValues};return}let x=cc(i.prevProp,_),S=x||v&&(y&&!b||r>p),C=!1,w=Array.isArray(_)?_:[_],T={};if(y!==!1)for(let n of w){let{transition:r,transitionEnd:i,...a}=Pa(e,n,Fa(e,t))||{};T={...T,...a,...i}}let{prevResolvedValues:E}=i;for(let t in{...E,...T}){if(t in f)continue;let n=T[t],r=E[t],a=Array.isArray(n)&&Array.isArray(r)?!ac(n,r)||x:n!==r;if(a&&n==null)d.add(t);else if(a||n!==void 0&&d.has(t)){S=!0,d.delete(t)&&(C=!0),i.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)}else i.protectedKeys[t]=!0}if(i.prevProp=_,i.prevResolvedValues=T,i.isActive&&(f={...f,...T}),S&&(!(b&&x)||C))for(let n of w){let r={type:t};if(typeof n==`string`&&l&&c&&s?.enteringChildren){let t=Pa(s,n)?.transition?.delayChildren;r.delay=pa(s.enteringChildren,e,t)}u.push({animation:n,options:r})}}),d.size){let{initial:t}=o,n={},r=typeof t!=`boolean`&&Pa(e,Array.isArray(t)?t[0]:t,e.presenceContext?.custom);r&&r.transition&&(n.transition=r.transition),d.forEach(i=>{let a=e.getValue(i);a&&(a.liveStyle=!0);let s=r&&!Array.isArray(t)?r[i]:void 0,c=e.getBaseTargetFromProps(o,i);n[i]=(s===void 0?c!==void 0&&!Va(c)?c:e.initialValues[i]===void 0?e.baseTarget[i]:void 0:s)??null}),u.push({animation:n})}let h=l&&e.blockInitialAnimation||r&&!c&&(o.initial===!1||o.initial===o.animate);return r=i=!1,!h&&u.length?t(u):Promise.resolve()}function o(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=a(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:a,setActive:o,setAnimateFunction:n=>{t=n(e)},getState:()=>n,reset:()=>{n=lc(),i=!0}}}function cc(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!ac(t,e):!1}function lc(){let e={};for(let t of Ms)e[t]={isActive:t===`animate`,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}};return e}function uc(e,t){e.min=t.min,e.max=t.max}function dc(e,t){uc(e.x,t.x),uc(e.y,t.y)}function fc(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var pc=.9999,mc=1.0001,hc=-.01,gc=.01;function _c(e){return e.max-e.min}function vc(e,t,n){return Math.abs(e-t)<=n}function yc(e,t,n,r=.5){e.origin=r,e.originPoint=Hn(t.min,t.max,e.origin),e.scale=_c(n)/_c(t),e.translate=Hn(n.min,n.max,e.origin)-e.originPoint,(e.scale>=pc&&e.scale<=mc||isNaN(e.scale))&&(e.scale=1),(e.translate>=hc&&e.translate<=gc||isNaN(e.translate))&&(e.translate=0)}function bc(e,t,n,r){yc(e.x,t.x,n.x,r?r.originX:void 0),yc(e.y,t.y,n.y,r?r.originY:void 0)}function xc(e,t,n,r=0){e.min=(r?Hn(n.min,n.max,r):n.min)+t.min,e.max=e.min+_c(t)}function Sc(e,t,n,r){xc(e.x,t.x,n.x,r?.x),xc(e.y,t.y,n.y,r?.y)}function Cc(e,t,n,r=0){let i=r?Hn(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+_c(t)}function wc(e,t,n,r){Cc(e.x,t.x,n.x,r?.x),Cc(e.y,t.y,n.y,r?.y)}function Tc(e,t,n,r,i){return e-=t,e=ko(e,1/n,r),i!==void 0&&(e=ko(e,1/i,r)),e}function Ec(e,t=0,n=1,r=.5,i,a=e,o=e){if(mn.test(t)&&(t=parseFloat(t),t=Hn(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=Hn(a.min,a.max,r);e===a&&(s-=t),e.min=Tc(e.min,t,n,s,i),e.max=Tc(e.max,t,n,s,i)}function Dc(e,t,[n,r,i],a,o){Ec(e,t[n],t[r],t[i],t.scale,a,o)}var Oc=[`x`,`scaleX`,`originX`],kc=[`y`,`scaleY`,`originY`];function Ac(e,t,n,r){Dc(e.x,t,Oc,n?n.x:void 0,r?r.x:void 0),Dc(e.y,t,kc,n?n.y:void 0,r?r.y:void 0)}function jc(e){return e.translate===0&&e.scale===1}function Mc(e){return jc(e.x)&&jc(e.y)}function Nc(e,t){return e.min===t.min&&e.max===t.max}function Pc(e,t){return Nc(e.x,t.x)&&Nc(e.y,t.y)}function Fc(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Ic(e,t){return Fc(e.x,t.x)&&Fc(e.y,t.y)}function Lc(e){return _c(e.x)/_c(e.y)}function Rc(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function zc(e){return[e(`x`),e(`y`)]}function Bc(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var Vc={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`){if(R.test(e))e=parseFloat(e);else return e}return`${Bc(e,t.target.x)}% ${Bc(e,t.target.y)}%`}},Hc={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Rn.parse(e);if(i.length>5)return r;let a=Rn.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=Hn(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}};function Uc(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,pathRotation:i,rotateX:a,rotateY:o,skewX:s,skewY:c}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotate(${i}deg) `),a&&(r+=`rotateX(${a}deg) `),o&&(r+=`rotateY(${o}deg) `),s&&(r+=`skewX(${s}deg) `),c&&(r+=`skewY(${c}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var Wc=oo.length,Gc=e=>typeof e==`number`||R.test(e);function Kc(e,t,n,r,i,a){i?(e.opacity=Hn(0,n.opacity??1,Jc(r)),e.opacityExit=Hn(t.opacity??1,0,Yc(r))):a&&(e.opacity=Hn(t.opacity??1,n.opacity??1,r));for(let i=0;i<Wc;i++){let a=oo[i],o=qc(t,a),s=qc(n,a);(o!==void 0||s!==void 0)&&(o||=0,s||=0,o===0||s===0||Gc(o)===Gc(s)?(e[a]=Math.max(Hn(ws(o),ws(s),r),0),(mn.test(s)||mn.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=Hn(t.rotate||0,n.rotate||0,r))}function qc(e,t){return e[t]===void 0?e.borderRadius:e[t]}var Jc=Xc(0,.5,jt),Yc=Xc(.5,.95,ft);function Xc(e,t,n){return r=>r<e?0:r>t?1:n(mt(e,t,r))}function Zc(e,t,n){let r=Va(e)?e:va(e);return r.start(Oa(``,r,t,n)),r.animation}function Qc(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var $c=(e,t)=>e.depth-t.depth,el=class{constructor(){this.children=[],this.isDirty=!1}add(e){it(this.children,e),this.isDirty=!0}remove(e){at(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort($c),this.isDirty=!1,this.children.forEach(e)}};function tl(e,t){let n=Wt.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(ur(r),e(a-t))};return lr.setup(r,!0),()=>ur(r)}function nl(e){return Va(e)?e.get():e}var rl=class{constructor(){this.members=[]}add(e){it(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(at(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(at(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},il={borderRadius:{...Vc,applyTo:[...oo]},borderTopLeftRadius:Vc,borderTopRightRadius:Vc,borderBottomLeftRadius:Vc,borderBottomRightRadius:Vc,boxShadow:Hc},al={hasAnimatedSinceResize:!0,hasEverUpdated:!1};Object.assign(Ys,{...il,...Ys});var ol={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},sl=[``,`X`,`Y`,`Z`],cl=1e3,ll=0;function ul(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function dl(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=Ka(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,lr,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&dl(r)}function fl({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=ll++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,Ss.value&&(ol.nodes=ol.calculatedTargetDeltas=ol.calculatedProjections=0),this.nodes.forEach(hl),this.nodes.forEach(Tl),this.nodes.forEach(El),this.nodes.forEach(gl),Ss.addProjectionMetrics&&Ss.addProjectionMetrics(ol)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new el)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new ht),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=co(t)&&!Cs(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;lr.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=tl(i,250),al.hasAnimatedSinceResize&&(al.hasAnimatedSinceResize=!1,this.nodes.forEach(wl)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||Nl,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!Ic(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...ba(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||wl(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),ur(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Dl),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&dl(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(yl),this.nodes.forEach(vl);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(bl);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(xl),this.nodes.forEach(Sl),this.nodes.forEach(Cl),this.nodes.forEach(pl),this.nodes.forEach(ml)):this.nodes.forEach(bl),this.clearAllSnapshots();let e=Wt.now();Vt.delta=ot(0,1e3/60,e-Vt.timestamp),Vt.timestamp=e,Vt.isProcessing=!0,dr.update.process(Vt),dr.preRender.process(Vt),dr.render.process(Vt),Vt.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,B.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(_l),this.sharedNodes.forEach(Ol)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,lr.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){lr.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),this.snapshot&&!_c(this.snapshot.measuredBox.x)&&!_c(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutCorrected||=Os(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!Mc(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||Eo(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),Ll(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return Os();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(zl))){let{scroll:e}=this.root;e&&(Io(t.x,e.offset.x),Io(t.y,e.offset.y))}return t}removeElementScroll(e){let t=Os();if(dc(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&dc(t,e),Io(t.x,i.offset.x),Io(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||Os();dc(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(Io(r.x,-n.scroll.offset.x),Io(r.y,-n.scroll.offset.y)),Eo(n.latestValues)&&zo(r,n.latestValues,n.layout?.layoutBox)}return Eo(this.latestValues)&&zo(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=Os();dc(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!Eo(n.latestValues))continue;let r;n.instance&&(To(n.latestValues)&&n.updateSnapshot(),r=Os(),dc(r,n.measurePageBox())),Ac(t,n.latestValues,n.snapshot?.layoutBox,r)}return Eo(this.latestValues)&&Ac(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0||e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Vt.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=Vt.timestamp;let a=this.getClosestProjectingParent();!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),(this.relativeTarget||this.targetDelta)&&(this.target||(this.target=Os(),this.targetWithTransforms=Os()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Sc(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):dc(this.target,this.layout.layoutBox),Mo(this.target,this.targetDelta)):dc(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),Ss.value&&ol.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||To(this.parent.latestValues)||Do(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Os(),this.relativeTargetOrigin=Os(),wc(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),dc(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===Vt.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;dc(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;Fo(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=Os());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(fc(this.prevProjectionDelta.x,this.projectionDelta.x),fc(this.prevProjectionDelta.y,this.projectionDelta.y)),bc(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!Rc(this.projectionDelta.x,this.prevProjectionDelta.x)||!Rc(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),Ss.value&&ol.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Es(),this.projectionDelta=Es(),this.projectionDeltaWithTransform=Es()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=Es();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=Os(),c=(r?r.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),u=!l||l.members.length<=1,d=!(!c||u||this.options.crossfade!==!0||this.path.some(Ml));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);r?(o.x.translate=r.x,o.x.scale=Hn(e.x.scale,1,n),o.x.origin=e.x.origin,o.x.originPoint=e.x.originPoint,o.y.translate=r.y,o.y.scale=Hn(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(kl(o.x,e.x,n),kl(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(wc(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),jl(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&Pc(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=Os(),dc(f,this.relativeTarget)),c&&(this.animationValues=a,Kc(a,i,this.latestValues,n,d,u)),r&&r.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(ur(this.pendingAnimation),void 0),this.pendingAnimation=lr.update(()=>{al.hasAnimatedSinceResize=!0,this.motionValue||=va(0),this.motionValue.jump(0,!1),this.currentAnimation=Zc(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),Kr(this.currentAnimation,this),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(cl),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,layout:n,latestValues:r}=e,{target:i}=e;if(t&&i&&n){if(this!==e&&this.layout&&n&&Rl(this.options.animationType,this.layout.layoutBox,n.layoutBox)){i=this.target||Os();let t=_c(this.layout.layoutBox.x);i.x.min=e.target.x.min,i.x.max=i.x.min+t;let n=_c(this.layout.layoutBox.y);i.y.min=e.target.y.min,i.y.max=i.y.min+n}dc(t,i),zo(t,r),bc(this.projectionDeltaWithTransform,this.layoutCorrected,t,r)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new rl),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&ul(`z`,e,r,this.animationValues);for(let t=0;t<sl.length;t++)ul(`rotate${sl[t]}`,e,r,this.animationValues),ul(`skew${sl[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=nl(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=nl(t?.pointerEvents)||``),this.hasProjected&&!Eo(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=Uc(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,e.opacity=r.animationValues?r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in Ys){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=Ys[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?nl(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(vl),this.root.sharedNodes.clear()}}}function pl(e){e.updateLayout()}function ml(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)zc(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=_c(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;uc(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else Rl(i,t.layoutBox,n)&&zc(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=_c(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=Es();bc(o,n,t.layoutBox);let s=Es();a?bc(s,e.applyTransform(r,!0),t.measuredBox):bc(s,n,t.layoutBox);let c=!Mc(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=Os();wc(s,t.layoutBox,i.layoutBox,o);let c=Os();wc(c,n,a.layoutBox,o),Ic(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function hl(e){Ss.value&&ol.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function gl(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function _l(e){e.clearSnapshot()}function vl(e){e.clearMeasurements()}function yl(e){e.isLayoutDirty=!0,e.updateLayout()}function bl(e){e.isLayoutDirty=!1}function xl(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function Sl(e){e.relativeTarget&&e.relativeParent?.isLayoutDirty&&(e.currentAnimation?e.isLayoutDirty=!0:(e.targetDelta=void 0,e.removeRelativeTarget()))}function Cl(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function wl(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Tl(e){e.resolveTargetDelta()}function El(e){e.calcProjection()}function Dl(e){e.resetSkewAndRotation()}function Ol(e){e.removeLeadSnapshot()}function kl(e,t,n){e.translate=Hn(t.translate,0,n),e.scale=Hn(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function Al(e,t,n,r){e.min=Hn(t.min,n.min,r),e.max=Hn(t.max,n.max,r)}function jl(e,t,n,r){Al(e.x,t.x,n.x,r),Al(e.y,t.y,n.y,r)}function Ml(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var Nl={duration:.45,ease:[.4,0,.1,1]},Pl=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Fl=Pl(`applewebkit/`)&&!Pl(`chrome/`)?Math.round:ft;function Il(e){e.min=Fl(e.min),e.max=Fl(e.max)}function Ll(e){Il(e.x),Il(e.y)}function Rl(e,t,n){return e===`position`||e===`preserve-aspect`&&!vc(Lc(t),Lc(n),.2)}function zl(e){return e!==e.root&&e.scroll?.wasRoot}var Bl=fl({attachResizeListener:(e,t)=>Qc(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),Vl={current:void 0},Hl=fl({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Vl.current){let e=new Bl({});e.mount(window),e.setOptions({layoutScroll:!0}),Vl.current=e}return Vl.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),Ul=(0,m.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function Wl(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Gl(...e){return t=>{let n=!1,r=e.map(e=>{let r=Wl(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():Wl(e[t],null)}}}}function Kl(...e){return m.useCallback(Gl(...e),e)}var V=i(),ql=class extends m.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(so(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=so(e)&&e.offsetWidth||0,r=so(e)&&e.offsetHeight||0,i=getComputedStyle(t),a=this.props.sizeRef.current;a.height=parseFloat(i.height),a.width=parseFloat(i.width),a.top=t.offsetTop,a.left=t.offsetLeft,a.right=n-a.width-a.left,a.bottom=r-a.height-a.top,a.direction=i.direction}return null}componentDidUpdate(){}render(){return this.props.children}};function Jl({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:a}){let o=(0,m.useId)(),s=(0,m.useRef)(null),c=(0,m.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:l}=(0,m.useContext)(Ul),u=Kl(s,a===!1?void 0:e.props?.ref??e?.ref);return(0,m.useInsertionEffect)(()=>{let{width:e,height:u,top:d,left:f,right:p,bottom:m,direction:h}=c.current;if(t||a===!1||!s.current||!e||!u)return;let g=h===`rtl`,_=n===`left`?g?`right: ${p}`:`left: ${f}`:g?`left: ${f}`:`right: ${p}`,v=r===`bottom`?`bottom: ${m}`:`top: ${d}`;s.current.dataset.motionPopId=o;let y=document.createElement(`style`);l&&(y.nonce=l);let b=i??document.head;return b.appendChild(y),y.sheet&&y.sheet.insertRule(`
|
|
4
4
|
[data-motion-pop-id="${o}"] {
|
|
@@ -94,16 +94,16 @@ Error generating stack: `+e.message+`
|
|
|
94
94
|
--primary: oklch(0.55 0.2 260);
|
|
95
95
|
…
|
|
96
96
|
}
|
|
97
|
-
.dark { … }`,className:`max-h-56 font-mono text-xs`}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(`input`,{ref:l,type:`file`,accept:`.css,.json,text/css,application/json`,hidden:!0,tabIndex:-1,"aria-label":`Upload a theme file`,onChange:e=>{d(e.target.files?.[0]),e.target.value=``}}),(0,V.jsx)(UI,{label:`Save and apply the pasted theme`,text:`Save theme`,icon:Yf,tone:`primary`,disabled:!t.trim()||s,onClick:()=>void u(t,`Custom theme`)}),(0,V.jsx)(UI,{label:`Upload a .css or .json theme file`,text:`Upload file`,icon:Th,disabled:s,onClick:()=>l.current?.click()}),a?(0,V.jsx)(`p`,{role:`alert`,className:`ml-2 min-w-0 text-xs text-destructive`,children:a}):null]})]})}function HV(){let{theme:e,setTheme:t}=eV(),n=Qz();return(0,V.jsx)(GB,{prominent:!0,title:fV.appearance,children:(0,V.jsxs)(RB,{children:[(0,V.jsx)(LB,{label:`Prompt sounds`,help:`A droplet for each new actionable prompt or delivery review. Kept in this browser; sound starts after interaction. Desktop notifications remain separate.`,children:(0,V.jsx)(SB,{checked:!n,onCheckedChange:e=>Xz(!e),"aria-label":`Prompt sounds`})}),(0,V.jsx)(LB,{label:NV.themeLabel,help:NV.appearanceHelp,children:(0,V.jsx)(zB,{value:e,items:NV.themeItems.map(e=>({value:e.id,label:e.label})),label:NV.themeLabel,onChange:e=>t(e)})}),(0,V.jsx)(LB,{label:`Colour theme`,help:`The page's colours, the same in every pi session.`,stacked:!0,children:(0,V.jsx)(RV,{})}),(0,V.jsx)(LB,{label:`Typeface`,help:`The face for the page's text, kept in this browser.`,stacked:!0,children:(0,V.jsx)(tV,{kind:`font`})}),(0,V.jsx)(LB,{label:`Code typeface`,help:`The face for code, paths and commands.`,stacked:!0,children:(0,V.jsx)(tV,{kind:`mono`})}),(0,V.jsx)(LB,{label:`Saved themes`,help:`Themes you imported, kept with pi for every session and project.`,stacked:!0,children:(0,V.jsx)(BV,{})}),(0,V.jsx)(LB,{label:`Import a theme`,stacked:!0,children:(0,V.jsx)(VV,{})})]})})}function UV({className:e,...t}){return(0,V.jsx)(Ox,{"aria-keyshortcuts":`Space`,"aria-description":`When focused, press Space to toggle.`,"data-slot":`checkbox`,className:Y(`cs-cb`,e),...t,children:(0,V.jsx)(Ax,{forceMount:!0,"data-slot":`checkbox-indicator`,className:`contents`,children:(0,V.jsx)(Yf,{"aria-hidden":`true`,strokeWidth:3.4})})})}var WV=`flex min-h-10 w-full flex-col gap-1 rounded-lg border border-transparent px-3 py-2.5 text-left outline-none transition-colors duration-150 hover:bg-accent/60 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-accent`,GV={master:[`master`],designer:[`agents`,`designer`],backend:[`agents`,`backend`],qa:[`agents`,`qa`],scout:[`scout`],researcher:[`researcher`],planner:[`planner`]};function KV(e,t){let n=GV[t].reduce((e,t)=>e[t],e);return{...n.mcpTools?{mcpTools:n.mcpTools}:{},...n.skills?{skills:n.skills}:{}}}function qV(e,t){return GV[e].reduceRight((e,t)=>({[t]:e}),t)}function JV(e,t){let n=e.mcpTools?e.mcpTools.length===0?Q.noTools:`${e.mcpTools.length} MCP tool${e.mcpTools.length===1?``:`s`}`:Q.allTools;return t===`master`?n:`${n} · ${e.skills?e.skills.length===0?Q.noSkills:`${e.skills.length} skill${e.skills.length===1?``:`s`}`:Q.allSkills}`}var YV=/^mcp__[A-Za-z0-9_]+__[A-Za-z0-9_]+$/;function XV(e,t){let n=`mcp__${t}__`;return e.startsWith(n)?e.slice(n.length):e}function ZV(e){return/^mcp__([A-Za-z0-9_]+?)__/.exec(e)?.[1]??``}function QV({config:e,save:t,agent:n,onAgent:r}){let i=_R(`settings.grants`,{},[]),a=i.data;return(0,V.jsxs)(GB,{prominent:!0,title:fV.grants,children:[(0,V.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:Q.intro}),(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,13rem)_minmax(0,1fr)] items-start gap-4`,children:[(0,V.jsx)(`nav`,{"aria-label":Q.agents,className:`flex flex-col gap-0.5`,children:nV.map(t=>(0,V.jsxs)(`button`,{type:`button`,"aria-current":t===n,onClick:()=>r(t),className:Y(WV,`min-h-0 gap-0.5 py-2`),children:[(0,V.jsxs)(`span`,{className:`flex items-center gap-2 text-[0.8125rem] font-medium`,children:[(0,V.jsx)(IR,{source:t,className:`size-4 shrink-0 text-muted-foreground`}),rV[t]]}),(0,V.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:JV(KV(e,t),t)})]},t))}),(0,V.jsxs)(PB,{dense:!0,"aria-label":`${rV[n]} ${Q.cardLabel}`,children:[(0,V.jsx)(tH,{kind:n,grants:KV(e,n),offered:a?.mcpTools,error:i.error,save:t},`tools-${n}`),(0,V.jsx)(nH,{kind:n,grants:KV(e,n),offered:a?.skills,error:i.error,save:t},`skills-${n}`)]})]})]})}function $V({title:e,note:t}){return(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline justify-between gap-x-3 gap-y-1`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-semibold`,children:e}),(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t})]})}function eH({id:e,name:t,help:n,tag:r,tagTone:i,checked:a,disabled:o,title:s,onChange:c}){return(0,V.jsxs)(`label`,{htmlFor:e,title:s,className:Y(`flex min-w-0 cursor-pointer items-start gap-3 rounded-lg px-2 py-1.5 transition-colors hover:bg-accent/60`,o&&`cursor-not-allowed opacity-60 hover:bg-transparent`),children:[(0,V.jsx)(UV,{id:e,checked:a,disabled:o,onCheckedChange:e=>c(e===!0),className:`mt-0.5`}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,V.jsx)(`span`,{className:`break-all font-mono text-[0.8125rem]`,children:t}),n?(0,V.jsx)(`span`,{className:`break-words text-xs text-muted-foreground`,children:n}):null]}),r?(0,V.jsx)(`span`,{className:Y(`shrink-0 rounded-md px-1.5 py-0.5 text-[0.6875rem] font-medium`,i===`warning`?`bg-warning/12 text-warning`:`bg-accent text-muted-foreground`),children:r}):null]})}function tH({kind:e,grants:t,offered:n,error:r,save:i}){let[a,o]=(0,m.useState)(``),[s,c]=(0,m.useState)(``),l=!t.mcpTools,u=t.mcpTools??[],d=new Set(u),f=pV.has(e),p=t=>i(qV(e,{mcpTools:t?[...new Set(t)]:null})),h=(e,t)=>void p(t?[...u,...e]:u.filter(t=>!e.includes(t))),g=new Set((n??[]).map(e=>e.name)),_=u.filter(e=>!g.has(e)).map(e=>({name:e,server:ZV(e),description:``,readOnly:!1})),v=a.trim().toLowerCase(),y=[...n??[],..._].filter(e=>!v||e.name.toLowerCase().includes(v)||e.description.toLowerCase().includes(v)),b=[...new Set(y.map(e=>e.server))],x=e=>!f||e.readOnly||!g.has(e.name),S=e=>void p(e?null:(n??[]).filter(x).map(e=>e.name)),C=()=>{let e=s.trim();if(!YV.test(e)){H.error(Q.badName);return}c(``),d.has(e)||p([...u,e])};return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(IB,{className:`gap-1 border-b border-(--frame-panel-border-color) py-2.5`,children:[(0,V.jsx)($V,{title:Q.tools,note:l?Q.allTools:`${u.length} granted`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f?Q.readOnlyHelp:e===`qa`?Q.qaHelp:Q.toolsHelp})]}),(0,V.jsxs)(FB,{fit:!0,className:`flex flex-col gap-3 py-3`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-4 px-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:Q.everyTool}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f?Q.everyToolReadOnlyHelp:Q.everyToolHelp})]}),(0,V.jsx)(SB,{checked:l,onCheckedChange:S,"aria-label":`${rV[e]} ${Q.everyTool.toLowerCase()}`})]}),(n?.length??0)>8?(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)($m,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,V.jsx)(xB,{value:a,placeholder:Q.filter,"aria-label":Q.filter,className:`pl-8`,onChange:e=>o(e.target.value)})]}):null,!n&&!r?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Q.looking}):null,r&&!n?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r}):null,n&&n.length===0&&_.length===0?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[Q.noServers,` `,(0,V.jsx)(`code`,{className:`rounded bg-accent px-1 py-0.5 font-mono text-xs`,children:`pi mcp add <name> -- <command>`})]}):null,b.map(t=>{let n=y.filter(e=>e.server===t),r=n.filter(x).map(e=>e.name),i=l?r.length:r.filter(e=>d.has(e)).length;return(0,V.jsxs)(`div`,{role:`group`,"aria-label":`${t} tools`,className:Y(`flex flex-col gap-0.5`,l&&`opacity-60`),children:[(0,V.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1 text-xs font-medium text-muted-foreground`,children:[(0,V.jsx)(UV,{checked:i===0?!1:i===r.length||`indeterminate`,disabled:l||r.length===0,"aria-label":`Every ${t} tool`,onCheckedChange:e=>h(r,e===!0)}),(0,V.jsx)(`span`,{className:`font-mono`,children:t||Q.unknownServer}),(0,V.jsxs)(`span`,{children:[i,` of `,n.length]})]}),n.map(t=>{let n=g.has(t.name),r=!x(t);return(0,V.jsx)(eH,{id:`grant-${e}-${t.name}`,name:XV(t.name,t.server),help:n?t.description||void 0:Q.notConnectedHelp,tag:n?t.readOnly?Q.readOnly:Q.writes:Q.notConnected,tagTone:n?`muted`:`warning`,checked:l?!r:d.has(t.name),disabled:l||r&&!d.has(t.name),...r?{title:Q.blockedHelp}:{},onChange:e=>h([t.name],e)},t.name)})]},t)}),!l&&u.length===0?(0,V.jsxs)(`p`,{className:`flex items-center gap-1.5 px-2 text-xs text-warning`,children:[(0,V.jsx)(ap,{"aria-hidden":`true`,className:`size-3.5`}),Q.noToolsWarning]}):null,(0,V.jsxs)(`div`,{hidden:l,className:`flex min-w-0 items-center gap-2 border-t border-(--frame-panel-border-color) pt-3`,children:[(0,V.jsx)(xB,{value:s,placeholder:`mcp__server__tool`,"aria-label":Q.addLabel,className:`min-w-0 flex-1 font-mono`,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),C())}}),(0,V.jsx)(UI,{label:Q.add,icon:Lm,onClick:C})]})]})]})}function nH({kind:e,grants:t,offered:n,error:r,save:i}){if(e===`master`)return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(IB,{className:`gap-1 border-y border-(--frame-panel-border-color) py-2.5`,children:(0,V.jsx)($V,{title:Q.skills,note:Q.sessionSkills})}),(0,V.jsx)(FB,{fit:!0,className:`py-3`,children:(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Q.masterSkills})})]});let a=!t.skills,o=new Set(t.skills??[]),s=t=>i(qV(e,{skills:t?[...new Set(t)]:null})),c=new Set((n??[]).map(e=>e.name)),l=(t.skills??[]).filter(e=>!c.has(e));return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(IB,{className:`gap-1 border-y border-(--frame-panel-border-color) py-2.5`,children:[(0,V.jsx)($V,{title:Q.skills,note:a?Q.allSkills:`${o.size} granted`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Q.skillsHelp})]}),(0,V.jsxs)(FB,{fit:!0,className:`flex flex-col gap-3 py-3`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-4 px-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:Q.everySkill}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Q.everySkillHelp})]}),(0,V.jsx)(SB,{checked:a,onCheckedChange:e=>void s(e?null:(n??[]).map(e=>e.name)),"aria-label":`${rV[e]} ${Q.everySkill.toLowerCase()}`})]}),!n&&!r?(0,V.jsx)(`p`,{className:`px-2 text-sm text-muted-foreground`,children:Q.looking}):null,r&&!n?(0,V.jsx)(`p`,{className:`px-2 text-sm text-muted-foreground`,children:r}):null,n&&n.length===0&&l.length===0?(0,V.jsx)(`p`,{className:`px-2 text-sm text-muted-foreground`,children:Q.noSkillsFound}):null,(0,V.jsxs)(`div`,{role:`group`,"aria-label":`${rV[e]} skills`,className:Y(`flex flex-col gap-0.5`,a&&`opacity-60`),children:[(n??[]).map(t=>(0,V.jsx)(eH,{id:`skill-${e}-${t.name}`,name:t.name,help:t.description,checked:a||o.has(t.name),disabled:a,title:t.path,onChange:e=>void s(e?[...o,t.name]:[...o].filter(e=>e!==t.name))},t.name)),l.map(t=>(0,V.jsx)(eH,{id:`skill-${e}-${t}`,name:t,help:Q.skillMissingHelp,tag:Q.notFound,tagTone:`warning`,checked:!0,onChange:()=>void s([...o].filter(e=>e!==t))},t))]}),!a&&o.size===0?(0,V.jsxs)(`p`,{className:`flex items-center gap-1.5 px-2 text-xs text-warning`,children:[(0,V.jsx)(ap,{"aria-hidden":`true`,className:`size-3.5`}),Q.noneWarning]}):null]})]})}function rH(e){let t=[[`designer`,e.agents.designer],[`backend`,e.agents.backend],[`qa`,e.agents.qa],[`scout`,e.scout],[`researcher`,e.researcher]],n={};for(let[e,r]of t)r.harness&&PV.has(e)&&(n[r.harness]??=[]).push(e);return n}function iH({value:e,label:t,placeholder:n,onSave:r}){let[i,a]=(0,m.useState)(e);(0,m.useEffect)(()=>a(e),[e]);let o=()=>{let t=i.trim();t!==e&&r(t)};return(0,V.jsx)(xB,{value:i,placeholder:n,"aria-label":t,spellCheck:!1,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())}})}function aH({value:e,label:t,onSave:n}){let r=e>0?String(e):``,[i,a]=(0,m.useState)(r);(0,m.useEffect)(()=>a(r),[r]);let o=()=>{let e=i.trim().replace(/[,_\s]/g,``);if(e===r)return;if(e===``)return n(0);let t=Number(e);if(!Number.isFinite(t)||t<1e4||t>2e6){H.error(`"${i}" is not between 10,000 and 2,000,000 tokens.`),a(r);return}n(Math.round(t))};return(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(xB,{type:`number`,inputMode:`numeric`,min:1e4,max:2e6,step:1e4,value:i,placeholder:`harness default`,"aria-label":t,className:`pr-14`,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())}}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 right-2.5 flex items-center text-xs text-muted-foreground`,children:`tokens`})]})}function oH({status:e}){let t=!!e.path;return(0,V.jsxs)(`span`,{title:e.path??`${e.command||`No command`} is not on PATH`,className:Y(`inline-flex shrink-0 items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium`,t?`bg-success/8 text-success dark:bg-success/16`:`bg-warning/8 text-warning dark:bg-warning/16`),children:[t?(0,V.jsx)(sp,{"aria-hidden":`true`,className:`size-3.5`}):(0,V.jsx)(ap,{"aria-hidden":`true`,className:`size-3.5`}),t?`${$.installed}${e.version?` · ${e.version}`:``}`:$.notFound]})}function sH({status:e,config:t,users:n,save:r}){let i=e.id,a=t.harnesses[i],o=e=>void r({harnesses:{[i]:e}}),s=e.protocol===`acp`,c=i===`codex`?`CODEX_HOME`:i===`claude`?`CLAUDE_CONFIG_DIR`:void 0,l=e.providers.some(e=>e.value===a.modelProvider)||!a.modelProvider?e.providers:[...e.providers,{value:a.modelProvider,label:a.modelProvider}];return(0,V.jsxs)(`section`,{"data-slot":`harness-card`,"aria-label":e.label,className:`glass flex min-w-0 flex-col gap-3 rounded-xl border px-3.5 pt-3 pb-3.5`,children:[(0,V.jsxs)(`header`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,V.jsx)(`h3`,{className:`min-w-0 break-words text-sm font-semibold`,children:e.label}),(0,V.jsx)(oH,{status:e})]}),(0,V.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:e.blurb}),(0,V.jsxs)(`p`,{className:`break-words text-xs`,children:[(0,V.jsxs)(`span`,{className:`text-muted-foreground`,children:[$.usedBy,`: `]}),n.length>0?n.map(e=>rV[e]).join(`, `):(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:$.unused.toLowerCase()})]})]}),(0,V.jsxs)(`div`,{className:`flex flex-col divide-y divide-border border-t border-border [&>*]:py-2.5 [&>*:last-child]:pb-0`,children:[(0,V.jsx)(LB,{stacked:!0,label:$.binary,help:$.binaryHelp,children:(0,V.jsx)(iH,{value:a.binaryPath,label:`${e.label} ${$.binary.toLowerCase()}`,placeholder:e.command||`/path/to/agent`,onSave:e=>o({binaryPath:e})})}),(0,V.jsx)(LB,{stacked:!0,label:$.args,help:i===`acp`?$.argsAcpHelp:$.argsHelp,children:(0,V.jsx)(iH,{value:a.launchArgs,label:`${e.label} ${$.args.toLowerCase()}`,placeholder:i===`acp`?`--acp`:`none`,onSave:e=>o({launchArgs:e})})}),c?(0,V.jsx)(LB,{stacked:!0,label:$.home,help:$.homeHelp(c),children:(0,V.jsx)(iH,{value:a.homePath,label:`${e.label} ${$.home.toLowerCase()}`,placeholder:i===`codex`?`~/.codex`:`~/.claude`,onSave:e=>o({homePath:e})})}):null,l.length>0?(0,V.jsx)(LB,{stacked:!0,label:$.provider,help:$.providerHelp,children:(0,V.jsx)(zB,{value:a.modelProvider,items:l.map(e=>({value:e.value,label:e.label})),label:`${e.label} ${$.provider.toLowerCase()}`,onChange:e=>o({modelProvider:e})})}):null,s?null:(0,V.jsx)(LB,{stacked:!0,label:$.compact,help:$.compactHelp,children:(0,V.jsx)(aH,{value:a.compactAt,label:`${e.label} ${$.compact.toLowerCase()}`,onSave:e=>o({compactAt:e})})}),i===`antigravity`?(0,V.jsx)(LB,{stacked:!0,label:$.harnessPath,help:$.harnessPathHelp,children:(0,V.jsx)(iH,{value:a.harnessPath,label:`${e.label} ${$.harnessPath.toLowerCase()}`,placeholder:`localharness_external`,onSave:e=>o({harnessPath:e})})}):null,(0,V.jsx)(LB,{stacked:!0,label:$.custom,help:$.customHelp,children:(0,V.jsx)(iH,{value:a.customModels.join(` `),label:`${e.label} ${$.custom.toLowerCase()}`,placeholder:i===`opencode`?`anthropic/claude-sonnet-5-5`:`model-id`,onSave:e=>o({customModels:e.split(/[\s,]+/).filter(Boolean)})})}),(0,V.jsxs)(`div`,{className:`flex min-h-0 items-center justify-between gap-4`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:$.inject}),(0,V.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:$.injectHelp})]}),(0,V.jsx)(SB,{checked:a.injectPrompts,onCheckedChange:e=>o({injectPrompts:e}),"aria-label":`${e.label}: ${$.inject}`})]})]})]})}function cH({config:e,statuses:t,error:n,save:r}){let i=rH(e);return(0,V.jsxs)(GB,{prominent:!0,title:fV.harnesses,children:[(0,V.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:$.intro}),t?(0,V.jsx)(`div`,{className:`grid grid-cols-2 items-start gap-3 xl:grid-cols-3`,children:t.map(t=>(0,V.jsx)(sH,{status:t,config:e,users:i[t.id]??[],save:r},t.id))}):(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n??`Looking for installed harnesses…`})]})}var lH={master:[`master`],designer:[`agents`,`designer`],backend:[`agents`,`backend`],qa:[`agents`,`qa`],scout:[`scout`],researcher:[`researcher`],planner:[`planner`]},uH=[...hV,..._V.map(e=>({id:`panel:${e.id}`,label:e.label,help:vV}))];function dH(e,t){switch(t){case`master`:return e.master;case`scout`:return{model:e.scout.model,thinking:`low`,mcpTools:e.scout.mcpTools,...e.scout.skills?{skills:e.scout.skills}:{},...e.scout.autoCompact===!1?{autoCompact:!1}:{},...e.scout.compactAt?{compactAt:e.scout.compactAt}:{},...e.scout.harness?{harness:e.scout.harness}:{},...e.scout.harnessModel?{harnessModel:e.scout.harnessModel}:{}};case`researcher`:return e.researcher;case`planner`:return e.planner;default:return e.agents[t]}}function fH(e,t){return lH[e].reduceRight((e,t)=>({[t]:e}),t)}function pH(e,t){return e.find(e=>e.id===t)?.thinkingLevels??dV}function mH(e,t){return dV[BB(dV,e,Math.max(0,dV.indexOf(t)))]??t}var hH=e=>e>0?`${e} round${e===1?``:`s`}`:`unlimited`;function gH(e){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)(``),a=e.models.some(t=>t.id===e.value),o=[...e.inherit?[{value:iV,label:aV,help:oV}]:[],...e.none?[{value:iV,label:`none`,help:`Use the primary model`}]:[],...!e.inherit&&!e.none&&e.value===`inherit`?[{value:iV,label:aV,help:oV}]:[],...e.models.map(e=>({value:e.id,label:e.id,...e.label&&e.label!==e.id?{help:e.label}:{}})),...!a&&e.value!==`inherit`?[{value:e.value,label:e.value,help:lV}]:[],{value:sV,label:cV,help:lV}],s=t=>{if(t!==`__custom__`)return e.onChange(t);i(a?``:e.value),n(!0)},c=()=>{let t=r.trim();n(!1),t&&t!==e.value&&e.onChange(t)};return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsx)(zB,{value:e.value,items:o,label:e.label,onChange:s}),t?(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,V.jsx)(xB,{autoFocus:!0,value:r,placeholder:`provider/model`,"aria-label":`Model id`,className:`min-w-0 flex-1`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())}}),(0,V.jsx)(UI,{label:`Use this model`,icon:Yf,tone:`primary`,onClick:c})]}):null]})}function _H({label:e,help:t,checked:n,onChange:r,name:i}){return(0,V.jsxs)(`div`,{className:`flex min-h-0 items-center justify-between gap-4`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:e}),t?(0,V.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:t}):null]}),(0,V.jsx)(SB,{checked:n,onCheckedChange:r,"aria-label":i??e})]})}function vH({value:e,onSave:t,placeholder:n,label:r}){let[i,a]=(0,m.useState)(e);(0,m.useEffect)(()=>a(e),[e]);let o=()=>{let n=i.trim();n!==e&&t(n)};return(0,V.jsx)(xB,{value:i,placeholder:n,"aria-label":r,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())}})}function yH({value:e,label:t,onSave:n}){let r=Math.round(e/6e4);return(0,V.jsx)(SH,{label:t,value:String(r),min:1,suffix:`min`,onSave:e=>{let t=Number(e);return!Number.isFinite(t)||t<=0?(H.error(`"${e}" is not a positive number of minutes.`),!1):(n(Math.round(t*6e4)),!0)}})}function bH({value:e,label:t,onSave:n}){return(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-4 gap-y-1.5`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:mV.label}),(0,V.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:mV.help})]}),(0,V.jsx)(`div`,{className:`w-36 shrink-0`,children:(0,V.jsx)(SH,{label:t,value:e?String(e):``,min:mV.min,max:mV.max,step:1e3,placeholder:mV.placeholder,suffix:`tokens`,onSave:e=>{if(e===``)return n(null),!0;let t=Number(e);return!Number.isInteger(t)||t<mV.min||t>mV.max?(H.error(mV.bad(e)),!1):(n(t),!0)}})})]})}function xH({value:e,onSave:t}){return(0,V.jsx)(SH,{label:SV,value:String(e),min:0,max:65535,onSave:e=>!/^\d+$/.test(e)||Number(e)>65535?(H.error(`"${e}" is not a port (0, or 1-65535).`),!1):(t(Number(e)),!0)})}function SH({label:e,value:t,min:n,max:r,step:i,placeholder:a,suffix:o,onSave:s}){let[c,l]=(0,m.useState)(t);(0,m.useEffect)(()=>l(t),[t]);let u=()=>{c!==t&&(s(c.trim())||l(t))};return(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(xB,{type:`number`,inputMode:`numeric`,min:n,max:r,step:i,placeholder:a,value:c,"aria-label":e,className:o?o.length>3?`pr-14`:`pr-10`:void 0,onChange:e=>l(e.target.value),onBlur:u,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),u())}}),o?(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 right-2.5 flex items-center text-xs text-muted-foreground`,children:o}):null]})}function CH({value:e,label:t,onSave:n}){let[r,i]=(0,m.useState)(e);return(0,m.useEffect)(()=>i(e),[e]),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(CB,{rows:2,value:r,"aria-label":t,onChange:e=>i(e.target.value),onBlur:()=>{r.trim()!==e&&n(r.trim())}}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Saved when you leave the field.`})]})}function wH({value:e,statuses:t,label:n,onChange:r}){let i=[{value:`pi`,label:$.piLabel,help:$.piHelp},...t.map(e=>({value:e.id,label:e.label,help:e.path?e.version?`v${e.version}`:$.installed:$.missing}))];return i.some(t=>t.value===e)||i.push({value:e,label:e}),(0,V.jsx)(zB,{value:e,items:i,label:n,onChange:r})}function TH({value:e,models:t,label:n,onChange:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),c=e===``||t.some(t=>t.id===e),l=[{value:``,label:$.defaultModel,help:$.defaultModelHelp},...t.map(e=>({value:e.id,label:e.label,help:e.custom?lV:e.current?e.id:`${e.id} · ${$.older}`})),...c?[]:[{value:e,label:e,help:lV}],{value:sV,label:cV,help:lV}],u=t=>{if(t!==`__custom__`)return r(t);s(c?``:e),a(!0)},d=()=>{let t=o.trim();a(!1),t&&t!==e&&r(t)};return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsx)(zB,{value:e,items:l,label:n,onChange:u}),i?(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,V.jsx)(xB,{autoFocus:!0,value:o,placeholder:`model id`,"aria-label":`Harness model id`,className:`min-w-0 flex-1`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d())}}),(0,V.jsx)(UI,{label:`Use this model`,icon:Yf,tone:`primary`,onClick:d})]}):null]})}function EH(e,t){let n=e?.models.find(e=>e.id===t);if(n&&n.efforts.length>0)return n.efforts;if(e?.effort===`session`)return dV;let r=e?.models.find(e=>e.efforts.length>0)?.efforts;return r&&r.length>0?r:dV}function DH({kind:e,config:t,models:n,harnesses:r,save:i,onGrants:a}){let o=dH(t,e),s=t=>i(fH(e,t)),c=rV[e],l=o.harness?r.find(e=>e.id===o.harness):void 0,u=!!o.harness,d=o.harnessModel??``,f=u?EH(l,d):pH(n,o.model),p=t=>{if(t===(o.harness??`pi`))return;if(t===`pi`)return void s({harness:`pi`});let n=EH(r.find(e=>e.id===t),``),i={harness:t,harnessModel:``};e!==`scout`&&!n.includes(o.thinking)&&(i.thinking=mH(n,o.thinking)),s(i)},h=t=>{let n=EH(l,t),r={harnessModel:t};e!==`scout`&&!n.includes(o.thinking)&&(r.thinking=mH(n,o.thinking)),s(r)},g=t=>{let r={model:t};e!==`scout`&&!pH(n,t).includes(o.thinking)&&(r.thinking=mH(pH(n,t),o.thinking)),s(r)},_=e!==`scout`&&e!==`researcher`,[v,y]=(0,m.useState)(!1),b=OH(o,e);return(0,V.jsxs)(`section`,{"data-slot":`agent-row`,className:`glass flex min-w-0 flex-col gap-2.5 rounded-xl border px-3.5 pt-2.5 pb-3`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,V.jsxs)(`h3`,{className:`flex min-w-0 items-center gap-2 break-words text-sm font-semibold`,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-tile`,style:{"--ac":NR(e)},children:c[0]}),c]}),(0,V.jsx)(AH,{open:v,custom:b,onToggle:()=>y(e=>!e)})]}),PV.has(e)?(0,V.jsx)(wH,{value:o.harness??`pi`,statuses:r,label:`${c} ${$.label.toLowerCase()}`,onChange:p}):null,u?(0,V.jsx)(TH,{value:d,models:l?.models??[],label:`${c} model`,onChange:h}):(0,V.jsx)(gH,{value:o.model,models:n,label:`${c} model`,inherit:e===`master`,onChange:g}),e===`scout`?(0,V.jsx)(kH,{}):(0,V.jsx)(WB,{value:o.thinking,levels:dV,supported:f,recommended:uV[e],model:u?d||`${l?.label??o.harness}'s default model`:o.model===`inherit`?`the session model`:o.model,label:`${c} effort`,onChange:e=>s({thinking:e})}),u&&l?.effort===`session`&&e!==`scout`?(0,V.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:$.effortNote}):null,(0,V.jsx)(_H,{label:`Auto-compact`,help:e===`master`?`Compacts the oracle's context as it fills, and files what it learned into the knowledge base, shared with the agents it concerns.`:u?l?.protocol===`acp`?`${l.label} compacts on its own; this switch applies to pi, Codex and Claude Code.`:`Lets ${l?.label??`the harness`} compact this agent's context, at the threshold under Harnesses.`:`Compacts this agent's context as it fills.`,checked:o.autoCompact!==!1,onChange:e=>s({autoCompact:e}),name:`${c} auto-compact`}),o.autoCompact!==!1&&!u?(0,V.jsx)(bH,{value:o.compactAt,label:`${c} compact at`,onSave:e=>s({compactAt:e})}):null,(0,V.jsxs)(`div`,{hidden:!v,className:`grid gap-2 border-t border-border pt-2`,children:[u?(0,V.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:$.agentNote}):null,_?(0,V.jsx)(CH,{value:o.instructions??``,label:`${c} instructions`,onSave:e=>s({instructions:e})}):null,(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,V.jsx)(`p`,{className:`min-w-[7rem] flex-1 break-words text-xs text-muted-foreground`,children:JV(KV(t,e),e)}),(0,V.jsx)(UI,{label:Q.edit,icon:Nh,onClick:a})]})]})]})}function OH(e,t){return[t!==`scout`&&t!==`researcher`&&!!e.instructions,e.mcpTools!==void 0,t!==`master`&&e.skills!==void 0].filter(Boolean).length}function kH(){return(0,V.jsxs)(`p`,{className:`flex min-h-[4.5rem] items-center gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(Jf,{"aria-hidden":`true`,className:`size-4`}),`Effort `,(0,V.jsx)(`span`,{className:`capitalize`,children:`low`}),` (fixed for scouts)`]})}function AH({open:e,custom:t,onToggle:n}){return(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":e,onClick:n,className:`-mr-1.5 flex min-h-8 shrink-0 items-center gap-1 rounded-md px-1.5 text-xs text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[(0,V.jsx)(tp,{"aria-hidden":`true`,className:Y(`size-3.5 transition-transform duration-200 ease-snap`,e&&`rotate-90`)}),`More`,t>0?(0,V.jsxs)(`span`,{className:`text-primary`,children:[`· `,t,` customised`]}):null]})}function jH(e,t){return t.startsWith(`panel:`)?e.lobby.panels[t.slice(6)]:e.lobby[t]}function MH({config:e,item:t,save:n}){let r=t.id.startsWith(`panel:`);return(0,V.jsx)(_H,{label:t.label,help:t.help,checked:jH(e,t.id),onChange:e=>{n(r?{lobby:{panels:{[t.id.slice(6)]:e}}}:{lobby:{[t.id]:e}})}})}function NH({config:e,save:t}){let n=e.workflow.gitIsolation;return(0,V.jsx)(GB,{prominent:!0,title:fV.workflow,children:(0,V.jsx)(RB,{children:(0,V.jsx)(LB,{label:DV,help:EV.find(e=>e.id===n)?.help??`enter cycles off, branch, worktree`,children:(0,V.jsx)(zB,{value:n,items:EV.map(e=>({value:e.id,label:e.label})),label:DV,onChange:e=>void t({workflow:{gitIsolation:e}})})})})})}var PH=e=>e?`${e}/`:kV.top;function FH(e){return e.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function IH({replaced:e}){let t=_R(`settings.linters`,{},[]),n=t.data?.linters;return(0,V.jsx)(LB,{label:kV.found,help:e?kV.foundReplaced:kV.foundHelp,children:n?n.length===0?(0,V.jsx)(`p`,{className:`break-words text-sm text-muted-foreground text-right`,children:kV.foundNone}):(0,V.jsx)(`ul`,{"aria-label":kV.found,className:Y(`flex flex-col items-end gap-1.5`,e&&`opacity-60`),children:n.map(e=>(0,V.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm`,children:[(0,V.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.tool}),(0,V.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:PH(e.folder)}),(0,V.jsxs)(`span`,{title:e.installed?void 0:kV.missingHelp,className:Y(`inline-flex shrink-0 items-center gap-1 text-xs`,e.installed?`text-success`:`text-warning`),children:[e.installed?(0,V.jsx)(sp,{"aria-hidden":`true`,className:`size-3.5`}):(0,V.jsx)(ap,{"aria-hidden":`true`,className:`size-3.5`}),e.installed?kV.installed:kV.missing]})]},`${e.tool}:${e.folder}`))}):(0,V.jsx)(`p`,{className:`break-words text-sm text-muted-foreground text-right`,children:t.error?t.error:`Looking…`})})}function LH({config:e,save:t}){let n=e.lint,r=n.mode===`off`,i=n.command.trim().length>0;return(0,V.jsxs)(GB,{prominent:!0,title:fV.lint,children:[(0,V.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:kV.intro}),(0,V.jsxs)(RB,{children:[(0,V.jsx)(LB,{label:kV.mode,help:OV.find(e=>e.id===n.mode)?.help,children:(0,V.jsx)(zB,{value:n.mode,items:OV.map(e=>({value:e.id,label:e.label})),label:kV.mode,onChange:e=>void t({lint:{mode:e}})})}),(0,V.jsxs)(`div`,{className:Y(`flex flex-col divide-y divide-border [&>*]:py-3 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0`,r&&`opacity-60`),"aria-disabled":r||void 0,children:[(0,V.jsx)(LB,{label:kV.command,help:kV.commandHelp,children:(0,V.jsx)(vH,{value:n.command,label:kV.command,placeholder:kV.commandPlaceholder,onSave:e=>void t({lint:{command:e}})})}),i?(0,V.jsx)(LB,{label:kV.extensions,help:kV.extensionsHelp,children:(0,V.jsx)(vH,{value:n.extensions.join(` `),label:kV.extensions,placeholder:kV.extensionsPlaceholder,onSave:e=>void t({lint:{extensions:FH(e)}})})}):null,(0,V.jsx)(LB,{label:kV.timeout,help:kV.timeoutHelp,children:(0,V.jsx)(yH,{value:n.timeoutMs,label:`Lint ${kV.timeout.toLowerCase()}`,onSave:e=>void t({lint:{timeoutMs:e}})})}),(0,V.jsx)(IH,{replaced:i})]})]})]})}function RH({config:e,save:t}){let n=e.lobby.web;return(0,V.jsx)(GB,{prominent:!0,title:fV.lobby,children:(0,V.jsxs)(RB,{children:[uH.map(n=>(0,V.jsx)(MH,{config:e,item:n,save:t},n.id)),(0,V.jsx)(LB,{label:yV,help:bV,children:(0,V.jsx)(zB,{value:String(e.lobby.maxPlanningRounds),items:xV.map(e=>({value:String(e),label:hH(e)})),label:yV,onChange:e=>void t({lobby:{maxPlanningRounds:Number(e)}})})}),(0,V.jsx)(LB,{label:SV,help:CV,children:(0,V.jsx)(xH,{value:n.port,onSave:e=>void t({lobby:{web:{port:e}}})})}),(0,V.jsx)(_H,{label:wV,help:TV,checked:n.openBrowser,onChange:e=>void t({lobby:{web:{openBrowser:e}}})}),(0,V.jsx)(zH,{})]})})}function zH(){let e=_R(`lobby.retention`,{},[]),t=async t=>{try{await L(`lobby.setRetention`,{enabled:t}),e.reload()}catch(e){H.error(e instanceof Error?e.message:`That did not work. Try again.`)}};return(0,V.jsx)(_H,{label:gV.label,help:e.error?gV.error:gV.help,checked:e.data?.enabled??!1,onChange:e=>void t(e)})}function BH(e){let t=e.indexOf(`/`);return t>0?e.slice(0,t):``}function VH(e,t){let n=new Set,r=[];for(let e of t)n.has(e.id)||(n.add(e.id),r.push({id:e.id,label:e.label,kind:`classifier`}));for(let t of e)n.has(t.id)||(n.add(t.id),r.push({id:t.id,label:t.label,kind:`chat`}));return r}function HH({value:e,models:t,classifiers:n,onChange:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),c=VH(t,n),l=BH(e),[u,d]=(0,m.useState)(l),f=e?l:u,p=[...new Set([...c.map(e=>BH(e.id)),...l?[l]:[]])].filter(Boolean).sort(),h=[{value:UH,label:MV.engineJev,help:MV.engineJevHelp},...p.map(e=>{let t=c.filter(t=>BH(t.id)===e),n=t.filter(e=>e.kind===`classifier`).length,r=t.length-n,i=[n?`${n} ${MV.engineClassifier}${n===1?``:`s`}`:``,r?`${r} chat model${r===1?``:`s`}`:``].filter(Boolean).join(`, `);return{value:e,label:e,...i?{help:i}:{}}})],g=c.filter(e=>BH(e.id)===f),_=[...g.map(e=>({value:e.id,label:e.id.slice(f.length+1),help:`${e.kind===`classifier`?MV.engineClassifier:MV.engineChat}${e.label&&e.label!==e.id?` · ${e.label}`:``}`})),...e&&!g.some(t=>t.id===e)?[{value:e,label:e.slice(f.length+1)||e,help:lV}]:[],{value:sV,label:cV,help:lV}],v=e=>{if(a(!1),e===UH)return d(``),r(``);d(e);let t=c.find(t=>BH(t.id)===e&&t.kind===`classifier`)??c.find(t=>BH(t.id)===e);t&&r(t.id)},y=t=>{if(t!==`__custom__`)return r(t);s(e&&!g.some(t=>t.id===e)?e:`${f}/`),a(!0)},b=()=>{let t=o.trim();a(!1),t&&t!==e&&r(t)};return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsx)(zB,{value:f||UH,items:h,label:MV.provider,onChange:v}),f?(0,V.jsx)(zB,{value:e||`__custom__`,items:_,label:MV.engineModel,onChange:y}):null,i?(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,V.jsx)(xB,{autoFocus:!0,value:o,placeholder:`provider/model`,"aria-label":`Classifier model id`,className:`min-w-0 flex-1`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b())}}),(0,V.jsx)(UI,{label:`Use this model`,icon:Yf,tone:`primary`,onClick:b})]}):null]})}var UH=`__jev__`;function WH({config:e,models:t,classifiers:n,save:r}){let i=e.classifier,a=AV.find(e=>e.id===i.provider)?.label,o=!i.engine;return(0,V.jsx)(GB,{prominent:!0,title:fV.classifier,children:(0,V.jsxs)(RB,{children:[(0,V.jsx)(_H,{label:MV.enabled,help:MV.enabledHelp,checked:i.enabled,onChange:e=>void r({classifier:{enabled:e}})}),(0,V.jsx)(LB,{label:MV.engine,help:MV.engineHelp,children:(0,V.jsx)(HH,{value:i.engine,models:t,classifiers:n,onChange:e=>void r({classifier:{engine:e}})})}),o?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(LB,{label:MV.host,children:(0,V.jsx)(zB,{value:i.provider,items:AV.map(e=>({value:e.id,label:e.label})),label:MV.host,onChange:e=>void r({classifier:{provider:e}})})}),(0,V.jsx)(LB,{label:MV.model,help:MV.modelHelp,children:(0,V.jsx)(vH,{value:i.model,label:MV.model,placeholder:`the host's default`,onSave:e=>void r({classifier:{model:e}})})}),(0,V.jsx)(LB,{label:MV.key,help:MV.keyNote,children:(0,V.jsx)(`p`,{className:`break-words text-sm text-muted-foreground text-right`,children:a??i.provider})})]}):null,jV.map(e=>(0,V.jsx)(_H,{label:e.label,help:e.help,checked:i.features[e.id],onChange:t=>void r({classifier:{features:{[e.id]:t}}})},e.id)),(0,V.jsx)(LB,{label:MV.cheap,help:MV.cheapHelp,children:(0,V.jsx)(gH,{value:i.effort.cheapModel,models:t,label:MV.cheap,none:!0,onChange:e=>void r({classifier:{effort:{cheapModel:e}}})})})]})})}function GH(){let e=cB(),t=async e=>{if(!e)return uB();let t=await lB();t===`granted`?H.success(NV.notificationsOn):H.error(t===`unsupported`?NV.notificationsUnsupported:NV.notificationsBlocked)};return(0,V.jsx)(GB,{prominent:!0,title:fV.notifications,children:(0,V.jsx)(RB,{children:(0,V.jsx)(_H,{label:NV.notificationsLabel,help:NV.notificationsHelp,checked:e,onChange:e=>void t(e)})})})}function KH(){let{available:e,install:t}=y(),n=b(),r=x();return(0,V.jsx)(GB,{prominent:!0,title:fV.install,children:(0,V.jsxs)(RB,{children:[(0,V.jsx)(LB,{label:NV.installLabel,help:n?NV.installedNow:NV.installHelp,children:n?null:(0,V.jsx)(`div`,{className:`flex justify-end`,children:(0,V.jsx)(UI,{label:NV.installButton,icon:Dp,tone:`primary`,onClick:()=>e?void t().then(()=>H.success(NV.installDone)):H.warning(NV.installUnavailable)})})}),r.supported?(0,V.jsx)(LB,{label:NV.fullscreenLabel,help:NV.fullscreenHelp,children:(0,V.jsx)(`div`,{className:`flex justify-end`,children:(0,V.jsx)(UI,{label:r.on?NV.fullscreenOn:NV.fullscreenOff,icon:r.on?ym:lm,pressed:r.on,onClick:()=>void r.toggle()})})}):null]})})}var qH=[`Agents`,`Harnesses`,`Tools & skills`,`Workflow`,`Lobby`,`Classifier`,`Appearance & notifications`],JH=e=>`settings-${e.split(` `)[0]}`;function YH({config:e,models:t,classifierModels:n=[],onConfig:r}){let[i,a]=(0,m.useState)(`Agents`),[o,s]=(0,m.useState)(`master`),c=e=>{s(e),a(`Tools & skills`)},l=_R(`settings.harnesses`,{},[]),u=JSON.stringify(e.harnesses),d=l.reload,f=(0,m.useRef)(u);(0,m.useEffect)(()=>{f.current!==u&&(f.current=u,d())},[u,d]);let p=l.data?.harnesses??[],h=(0,m.useRef)(Promise.resolve()),g=e=>{let t=async()=>{try{return r((await L(`settings.set`,{patch:e})).config),H.success(NV.saved),!0}catch(e){return H.error(e instanceof Error?e.message:`That did not work. Try again.`),!1}},n=h.current.then(t,t);return h.current=n,n};return(0,V.jsxs)(`div`,{className:`cs-pg cs-set flex flex-col pb-dock`,children:[(0,V.jsx)(`header`,{className:`cs-pgh`,children:(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h1`,{className:`cs-hd1`,children:NV.title}),(0,V.jsx)(`p`,{className:`cs-hd2`,children:NV.intro})]})}),(0,V.jsx)(`nav`,{"aria-label":`Settings sections`,className:`cs-secn`,children:(0,V.jsx)(ME,{as:`nav`,size:`md`,label:`Settings sections`,items:qH.map(e=>({id:e,label:e,controls:JH(e)})),value:i,onChange:a})}),(0,V.jsxs)(`div`,{id:JH(`Agents`),hidden:i!==`Agents`,"aria-hidden":i!==`Agents`,children:[(0,V.jsx)(`h2`,{className:`sr-only`,children:fV.agents}),(0,V.jsx)(`div`,{className:`grid grid-cols-2 items-start gap-3.5 lg:grid-cols-3`,children:nV.map(n=>(0,V.jsx)(DH,{kind:n,config:e,models:t,harnesses:p,save:g,onGrants:()=>c(n)},n))})]}),(0,V.jsx)(`div`,{id:JH(`Harnesses`),hidden:i!==`Harnesses`,"aria-hidden":i!==`Harnesses`,children:(0,V.jsx)(cH,{config:e,statuses:l.data?.harnesses,...l.error?{error:l.error}:{},save:g})}),(0,V.jsx)(`div`,{id:JH(`Tools & skills`),hidden:i!==`Tools & skills`,"aria-hidden":i!==`Tools & skills`,children:(0,V.jsx)(QV,{config:e,save:g,agent:o,onAgent:s})}),(0,V.jsx)(`div`,{id:JH(`Workflow`),hidden:i!==`Workflow`,"aria-hidden":i!==`Workflow`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,V.jsx)(NH,{config:e,save:g}),(0,V.jsx)(LH,{config:e,save:g})]})}),(0,V.jsx)(`div`,{id:JH(`Lobby`),hidden:i!==`Lobby`,"aria-hidden":i!==`Lobby`,children:(0,V.jsx)(RH,{config:e,save:g})}),(0,V.jsx)(`div`,{id:JH(`Classifier`),hidden:i!==`Classifier`,"aria-hidden":i!==`Classifier`,children:(0,V.jsx)(WH,{config:e,models:t,classifiers:n,save:g})}),(0,V.jsx)(`div`,{id:JH(`Appearance & notifications`),hidden:i!==`Appearance & notifications`,"aria-hidden":i!==`Appearance & notifications`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,V.jsx)(HV,{}),(0,V.jsx)(GH,{}),(0,V.jsx)(KH,{})]})})]})}function XH(){return(0,V.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-4 px-8 pt-8 pb-dock`,role:`status`,"aria-label":NV.loading,children:[0,1,2,3].map(e=>(0,V.jsx)(qE,{shape:`card`,className:`h-48`},e))})}function ZH(){let e=_R(`settings.get`,{},[`status`]),[t,n]=(0,m.useState)(),r=(0,m.useRef)(0),i=(0,m.useCallback)(e=>{r.current=performance.now(),n(e)},[]);return(0,m.useEffect)(()=>{e.data&&e.requestedAt>r.current&&n(e.data.config)},[e.data,e.requestedAt]),!t&&e.error?(0,V.jsx)(wE,{message:`${NV.loadFailed} ${e.error}`,onRetry:e.reload}):t?(0,V.jsx)(YH,{config:t,models:e.data?.models??[],classifierModels:e.data?.classifierModels??[],onConfig:i}):(0,V.jsx)(XH,{})}function QH(){let e=globalThis.DOMParser;if(!e)throw Error(`DOMParser is unavailable`);return new e}var $H=`default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; img-src 'none'; font-src 'none'; connect-src 'none'; media-src 'none'; frame-src 'none'; object-src 'none'; form-action 'none'; base-uri 'none'`,eU=new Set(`div span p br hr h1 h2 h3 h4 h5 h6 section article header footer main aside nav ul ol li dl dt dd strong em b i u s small sub sup blockquote pre code table thead tbody tfoot tr th td caption colgroup col figure figcaption style button input label select option optgroup textarea details summary fieldset legend progress meter output kbd mark`.split(` `)),tU=new Set(`class id title role aria-label aria-hidden aria-expanded aria-selected aria-checked aria-pressed aria-current colspan rowspan scope type name value placeholder for checked selected disabled readonly open min max step rows cols tabindex`.split(` `)),nU=new Set(`text search email tel url number password checkbox radio range color date time month week button reset submit`.split(` `)),rU=`button,input,select,textarea,summary,label,[role=button],[role=tab]{transition:background-color .18s ease,color .18s ease,border-color .18s ease,box-shadow .18s ease,transform .18s ease,opacity .18s ease}button,summary,label,select,[role=button],[role=tab],input[type=checkbox],input[type=radio],input[type=range]{cursor:pointer}button:active,[role=button]:active{transform:scale(.97)}details[open]>:not(summary){animation:mockup-in .22s ease-out}@keyframes mockup-in{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}}`;function iU(e){if(!e||typeof e!=`object`)return;let t=e;if(!(typeof t.html!=`string`||t.html.length>1e5)&&!(t.css!==void 0&&(typeof t.css!=`string`||t.css.length>12e4)))return{html:t.html,...typeof t.css==`string`?{css:t.css}:{}}}function aU(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,``);return/\\|@import|url\s*\(|image-set\s*\(|expression\s*\(|behavior\s*:|-moz-binding/i.test(t)?``:t.replace(/<\/?style/gi,``)}function oU(e){if(!eU.has(e.localName)||e.namespaceURI!==`http://www.w3.org/1999/xhtml`){e.remove();return}for(let t of[...e.attributes])t.name===`style`?e.setAttribute(`style`,aU(t.value)):tU.has(t.name)||e.removeAttribute(t.name);if(e.localName===`input`){let t=[...e.attributes].find(e=>e.name===`type`)?.value.toLowerCase();t!==void 0&&!nU.has(t)&&e.setAttribute(`type`,`text`)}e.localName===`style`&&(e.textContent=aU(e.textContent??``));for(let t of[...e.children])oU(t)}function sU(e,t){try{return cU(e,t??QH())}catch{return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${$H}"><meta name="referrer" content="no-referrer"></head><body><p role="status">Static mockup unavailable. The preview could not be safely rendered.</p></body></html>`}}function cU(e,t){let n=t.parseFromString(e.html,`text/html`);for(let e of[...n.head.children,...n.body.children])oU(e);let r=[...n.head.querySelectorAll(`style`)].map(e=>e.outerHTML).join(``);return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${$H}"><meta name="referrer" content="no-referrer"><style>body{margin:16px;overflow-wrap:anywhere}*{box-sizing:border-box}${rU}${aU(e.css??``).replace(/</g,`\\3c `)}</style>${r}</head><body>${n.body.innerHTML}</body></html>`}function lU({preview:e,label:t,className:n,frameWidth:r,minWidth:i,onOpen:a}){let o=(0,m.useMemo)(()=>sU(e),[e]),s=(0,m.useRef)(null),[c,l]=(0,m.useState)();if((0,m.useLayoutEffect)(()=>{let e=s.current;if(!r&&!i||!e)return;let t=()=>l({width:e.clientWidth,height:e.clientHeight});if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[r,i]),!r&&!i)return(0,V.jsx)(`iframe`,{title:`Static mockup: ${t}`,sandbox:``,referrerPolicy:`no-referrer`,srcDoc:o,className:Y(`h-80 w-full rounded-lg border bg-background`,n)});let u=r??Math.max(c?.width??0,i??0),d=c&&c.width>0&&u>0?Math.min(1,c.width/u):1;return(0,V.jsxs)(`div`,{ref:s,className:Y(`group/mock relative h-80 w-full max-w-full overflow-hidden rounded-lg border bg-background`,n),children:[(0,V.jsx)(`iframe`,{title:`Static mockup: ${t}`,sandbox:``,referrerPolicy:`no-referrer`,srcDoc:o,className:`absolute top-0 left-0 origin-top-left border-0`,style:{width:u||`100%`,height:c?c.height/d:`100%`,transform:`scale(${d})`}}),a?(0,V.jsx)(`button`,{type:`button`,"data-compact":``,onClick:a,"aria-label":`Expand the mockup: ${t}`,title:`Expand`,className:`cs-mxb outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,V.jsx)(sm,{"aria-hidden":`true`,className:`size-3`})}):null]})}var uU=/\s*\(recommended\)\s*$/i,dU=1024,fU=e=>e.replace(uU,``);function pU(e){return!!(e&&(e.htmlPreview||e.image||e.preview))}function mU({option:e}){let t=fU(e.label);return pU(e)?(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3`,children:[e.htmlPreview?(0,V.jsx)(lU,{preview:e.htmlPreview,label:t,minWidth:dU,className:`h-auto min-h-[18rem] flex-1`}):null,e.image?(0,V.jsx)(`img`,{src:F(e.image),alt:`Mockup: ${t}`,className:`min-h-0 w-full flex-1 rounded-lg border bg-background object-contain`}):null,e.preview?(0,V.jsx)(QL,{text:e.preview,className:Y(`overflow-auto rounded-lg border bg-background p-4 text-sm`,!e.htmlPreview&&!e.image&&`flex-1`)}):null]}):(0,V.jsx)(`p`,{className:`grid h-full place-items-center p-6 text-sm text-muted-foreground`,children:`No mockup for this option.`})}function hU({options:e,start:t,title:n,picked:r=[],multi:i=!1,onChoose:a,onClose:o,onIndex:s}){let c=Jd(),l=(0,m.useRef)(null),u=(0,m.useRef)(null),[d,f]=(0,m.useState)(()=>Math.min(Math.max(0,t),e.length-1)),p=e[d],h=e.length-1;(0,m.useEffect)(()=>s?.(d),[d,s]),(0,m.useLayoutEffect)(()=>{let e=l.current;e&&(e.scrollLeft=d*e.clientWidth),u.current?.focus()},[]);let g=(0,m.useCallback)(e=>{let t=Math.min(Math.max(0,e),h),n=l.current;f(t),n?.scrollTo({left:t*n.clientWidth,behavior:c?`auto`:`smooth`})},[h,c]);(0,m.useEffect)(()=>{let e=l.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{e.scrollLeft=d*e.clientWidth});return t.observe(e),()=>t.disconnect()},[d]);function _(){let e=l.current;if(!e||e.clientWidth===0)return;let t=Math.round(e.scrollLeft/e.clientWidth);t!==d&&t>=0&&t<=h&&f(t)}function v(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=t.target;if(n.closest(`input, textarea, [contenteditable='true']`))return;let r={ArrowLeft:-1,ArrowRight:1,PageUp:-1,PageDown:1}[t.key];if(r){t.preventDefault(),g(d+r);return}if(t.key===`Home`||t.key===`End`){t.preventDefault(),g(t.key===`Home`?0:h);return}let i=Number(t.key);if(Number.isInteger(i)&&i>=1&&i<=e.length){t.preventDefault(),g(i-1);return}t.key===`Enter`&&a&&!(n instanceof HTMLButtonElement)&&(t.preventDefault(),a(d))}let y=r.includes(d);return(0,V.jsxs)(`div`,{ref:u,tabIndex:-1,"data-autofocus":``,onKeyDown:v,className:`mockup-viewer flex h-full min-h-0 flex-col outline-none`,role:`region`,"aria-label":`Mockups: ${n}`,"aria-roledescription":`carousel`,children:[(0,V.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border px-4 py-3`,children:[(0,V.jsx)(WT,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Back to the question`,title:`Back · Esc`,onClick:()=>o(d),children:(0,V.jsx)(_m,{"aria-hidden":`true`})}),(0,V.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:n}),(0,V.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,"aria-live":`polite`,children:[d+1,` of `,e.length]}),(0,V.jsx)(`div`,{role:`tablist`,"aria-label":`Options`,className:`flex w-full flex-wrap gap-1.5 sm:w-auto`,children:e.map((e,t)=>(0,V.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===d,"aria-controls":`mockup-slide-${t}`,"data-compact":``,onClick:()=>g(t),className:Y(`inline-flex h-7 max-w-48 items-center gap-1 rounded-lg border px-2.5 text-xs font-medium transition-colors outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t===d?`border-primary/50 bg-accent text-foreground`:`border-border text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,V.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:t+1}),(0,V.jsx)(`span`,{className:`truncate`,children:fU(e.label)}),r.includes(t)?(0,V.jsx)(Yf,{"aria-label":`picked`,className:`size-3 text-primary`}):null]},t))})]}),(0,V.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,V.jsx)(`div`,{ref:l,onScroll:_,className:`mockup-track flex h-full snap-x snap-mandatory overflow-x-auto overflow-y-hidden overscroll-x-contain`,children:e.map((t,n)=>(0,V.jsxs)(`section`,{id:`mockup-slide-${n}`,role:`tabpanel`,"aria-roledescription":`slide`,"aria-label":`${n+1} of ${e.length}: ${fU(t.label)}`,"aria-hidden":n!==d,className:`flex h-full w-full shrink-0 snap-center snap-always flex-col gap-2 overflow-y-hidden px-4 py-4 sm:px-14`,children:[(0,V.jsxs)(`div`,{className:`flex items-baseline gap-2 text-sm`,children:[(0,V.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[n+1,`.`]}),(0,V.jsx)(`span`,{className:`font-medium`,children:fU(t.label)}),uU.test(t.label)?(0,V.jsx)(`span`,{className:`text-xs font-medium text-primary`,children:`Recommended`}):null,r.includes(n)?(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-primary`,children:[(0,V.jsx)(Yf,{"aria-hidden":`true`,className:`size-3`}),`picked`]}):null]}),t.description?(0,V.jsx)(QL,{text:t.description,className:`text-sm text-muted-foreground`}):null,(0,V.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,V.jsx)(mU,{option:t})})]},n))}),d>0?(0,V.jsx)(WT,{type:`button`,variant:`outline`,size:`icon`,"aria-label":`Previous option`,title:`Previous · ←`,onClick:()=>g(d-1),className:`absolute top-1/2 left-2 -translate-y-1/2 rounded-full`,children:(0,V.jsx)($f,{"aria-hidden":`true`})}):null,d<h?(0,V.jsx)(WT,{type:`button`,variant:`outline`,size:`icon`,"aria-label":`Next option`,title:`Next · →`,onClick:()=>g(d+1),className:`absolute top-1/2 right-2 -translate-y-1/2 rounded-full`,children:(0,V.jsx)(tp,{"aria-hidden":`true`})}):null]}),(0,V.jsxs)(`footer`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2 border-t border-border px-4 py-3`,children:[(0,V.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,V.jsx)($T,{chord:`←→`,children:`option`}),a?(0,V.jsx)($T,{chord:`Enter`,children:i?y?`unpick`:`pick`:`choose`}):null,(0,V.jsx)($T,{chord:`Esc`,children:`back`})]}),a&&p?(0,V.jsxs)(WT,{type:`button`,onClick:()=>a(d),className:`max-w-full`,children:[i&&y?`Unpick`:i?`Pick`:`Choose`,(0,V.jsx)(`span`,{className:`truncate`,children:fU(p.label)})]}):null]})]})}function gU(e,t,n){e.nativeEvent.isComposing||(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),e.key===`Enter`&&e.ctrlKey&&(e.preventDefault(),e.stopPropagation(),t()))}function _U({text:e,disabled:t=!1,onSave:n,onCancel:r}){let[i,a]=(0,m.useState)(e),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(``),u=(0,m.useRef)(null);(0,m.useEffect)(()=>{u.current?.focus({preventScroll:!0}),u.current?.select()},[]);let d=async()=>{if(!(t||o||!i.trim())){s(!0),l(``);try{await n(i.trim()),r()}catch(e){l(e instanceof Error?e.message:String(e)),s(!1)}}};return(0,V.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,onKeyDown:e=>gU(e,()=>void d(),()=>{o||r()}),children:[(0,V.jsxs)(`label`,{className:`text-sm`,children:[`Edit message`,(0,V.jsx)(CB,{ref:u,value:i,onChange:e=>a(e.target.value),disabled:o,className:`mt-2 max-h-[40vh] min-h-24`})]}),c?(0,V.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not save. `,c]}):null,(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)(WT,{size:`sm`,onClick:()=>void d(),disabled:t||o||!i.trim(),children:o?`Saving…`:`Save`}),(0,V.jsx)(WT,{size:`sm`,variant:`ghost`,disabled:o,onClick:r,children:`Cancel`})]})]})}var vU=1200;function yU({question:e}){let[t,n]=(0,m.useState)(),r=lE(t!==void 0,cE.sheet),i=e.options.flatMap((e,t)=>e.mockup?[{option:e,index:t,mockup:e.mockup}]:[]);if(i.length===0)return null;let a=e.options.map(e=>({label:e.label,description:e.description,...e.mockup?{htmlPreview:e.mockup}:{}}));return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`ul`,{"aria-label":`Mockups`,className:`cs-mocks`,children:i.map(({option:e,index:t,mockup:r})=>(0,V.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,V.jsx)(lU,{preview:r,label:fU(e.label),frameWidth:vU,onOpen:()=>n(t),className:`cs-mk3f aspect-[3/2] h-auto`}),(0,V.jsxs)(`span`,{className:`truncate`,children:[(0,V.jsxs)(`span`,{className:`tabular-nums`,children:[t+1,`.`]}),` `,fU(e.label)]})]},t))}),(0,V.jsx)(tE,{open:t!==void 0&&r,onOpenChange:e=>{e||n(void 0)},label:`Mockups: ${e.text}`,className:`h-[min(92svh,60rem)] max-h-[min(92svh,60rem)] max-w-6xl`,children:t===void 0?null:(0,V.jsx)(hU,{options:a,start:t,title:e.text,onClose:()=>n(void 0)})})]})}function bU({questions:e}){return(0,V.jsx)(`ol`,{className:`cs-qs`,children:e.map((e,t)=>(0,V.jsxs)(`li`,{className:`cs-qc`,style:{"--ac":NR(e.from)},children:[(0,V.jsxs)(`p`,{className:`cs-qh`,children:[(0,V.jsxs)(`span`,{className:`cs-qwho`,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-tile`,children:zR(e.from)[0]}),zR(e.from)]}),(0,V.jsxs)(`span`,{className:`min-w-0`,children:[(0,V.jsxs)(`span`,{className:`sr-only`,children:[`Question `,t+1,`: `]}),e.text]})]}),e.options.length?(0,V.jsx)(`ul`,{"aria-label":`Options`,className:`cs-opts`,children:e.options.map(e=>(0,V.jsxs)(`li`,{className:`cs-op`,children:[(0,V.jsx)(`b`,{children:e.label}),e.description?` — ${e.description}`:``]},e.label))}):null,(0,V.jsx)(yU,{question:e})]},t))})}function xU({message:e}){let t=e.decided??[];return t.length?(0,V.jsx)(`ul`,{"aria-label":`Settled for you`,className:`cs-decided`,children:t.map((e,t)=>(0,V.jsxs)(`li`,{title:`Settled by the classifier, ${Math.round(e.probability*100)}% sure. Comment on the plan to overrule it.`,children:[(0,V.jsx)(Yf,{"aria-hidden":`true`,className:`size-3.5`}),(0,V.jsxs)(`span`,{className:`min-w-0`,children:[(0,V.jsx)(`b`,{className:`font-semibold`,style:{color:NR(e.from)},children:zR(e.from)}),` `,(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:e.question}),` `,(0,V.jsx)(`b`,{className:`font-semibold`,children:e.answer}),(0,V.jsxs)(`span`,{className:`cs-dh2`,children:[`auto · `,Math.round(e.probability*100),`% · comment to overrule`]})]})]},t))}):null}function SU({message:e,index:t,busy:n,readOnly:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(),c=o&&(o.editedAt??0)>(e.editedAt??0)?o:e,l=n||c!==e,u=async n=>{let r=await L(`planner.editMessage`,{messageIndex:t,at:e.at,text:n});s(r.message)},d=!r&&!e.settled?.length&&!i?(0,V.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>a(!0),className:`chat-action`,children:[(0,V.jsx)(km,{"aria-hidden":`true`,className:`size-3`}),`Edit`]}):null;return(0,V.jsx)(qR,{time:e.at>0?iz(e.at):void 0,head:!0,note:c.editedAt?`(edited)`:void 0,actions:d,children:i?(0,V.jsx)(_U,{text:c.text,disabled:n,onSave:u,onCancel:()=>a(!1)}):(0,V.jsx)(QL,{text:c.text})})}function CU({message:e,index:t,busy:n,readOnly:r}){if(e.role===`you`)return(0,V.jsx)(SU,{message:e,index:t,busy:n,readOnly:r});let i=e.questions??[];return(0,V.jsxs)(KR,{tile:!0,source:`PLANNER`,name:`Panel`,time:e.at>0?iz(e.at):void 0,head:!0,bubble:i.length===0,aside:i.length?`${i.length} question${i.length===1?``:`s`}`:void 0,children:[i.length>0?(0,V.jsx)(bU,{questions:i}):(0,V.jsx)(QL,{text:e.text}),(0,V.jsx)(xU,{message:e})]})}function wU({messages:e,seed:t,busy:n=!1,readOnly:r=!1}){return(0,V.jsxs)(`div`,{className:`chat-column`,role:`log`,"aria-label":`Panel conversation`,children:[t?(0,V.jsx)(JR,{children:t}):null,e.map((e,t)=>(0,V.jsx)(CU,{message:e,index:t,busy:n,readOnly:r},`${e.at}-${t}`)),n?(0,V.jsx)(KR,{tile:!0,source:`PLANNER`,name:`Panel`,head:!0,live:!0,waiting:!0,aside:`the panel is thinking`}):null]})}var TU=`ORACLE`,EU=`No draft yet.`,DU=`The draft appears after the panel's first round.`,OU=`What each seat needs`,kU=[`backend`,`designer`,`qa`,`researcher`],AU={backend:`DEV`,designer:`DESIGN`,qa:`QA`,researcher:`RESEARCH`},jU=`Describe a task in the box below. The panel asks what it needs to know, round by round, until the plan is clear.`,MU={ORACLE:`Chairs the panel, and settles the last round alone.`,DEV:`Code, data and the APIs it touches.`,DESIGN:`Screens, flows and the words on them.`,QA:`Tests, edge cases and what could break.`,RESEARCH:`Prior art, docs and sources.`},NU=[{title:`Describe it`,text:`Say what you want in the box below.`},{title:`The panel asks`,text:`Each seat asks what it needs to know.`},{title:`A draft forms`,text:`Answer, comment on lines, go another round.`},{title:`Save the plan`,text:`Keep it, or start it as a task.`}];function PU(e){let t=e.filter(e=>e.member);return`${t.filter(e=>e.seated).length} of ${t.length} seated`}function FU(e,t=0){return t<=0?`round ${e}`:e>t?`round ${e} · past the limit, revising`:e===t?`final round ${e}/${t}`:`round ${e}/${t}`}function IU(e,t){return`${e} ${t}${e===1?``:`s`}`}function LU(e){return e.round===0&&e.messages.length===0&&!e.busy}function RU(e){let t=e.members.find(e=>e.status===`failed`);if(t)return(t.error??`${AU[t.member]} failed`).split(`
|
|
98
|
-
`)[0]}function
|
|
99
|
-
`).map(e=>{let n=e.trimStart().startsWith("```");return n&&(t=!t),{text:e,fenced:t||n}})}function JU({notes:e}){return(0,V.jsx)(V.Fragment,{children:e.map((e,t)=>(0,V.jsx)(`p`,{className:`cs-dnote`,children:e},t))})}var YU=[],XU=(0,m.memo)(function({row:e,index:t,notes:n,form:r,onComment:i}){let a=e.text.trim(),o=()=>i(t);return(0,V.jsxs)(`li`,{"data-line":t,className:Y(`cs-dr`,!r&&`[contain-intrinsic-size:auto_2.75rem] [content-visibility:auto]`),children:[(0,V.jsxs)(`div`,{className:`cs-dln`,children:[(0,V.jsx)(`span`,{className:`cs-dd`,"aria-hidden":`true`,children:n.length>0?(0,V.jsx)(`i`,{}):null}),(0,V.jsx)(`div`,{className:Y(`cs-dtx`,e.fenced&&`font-mono text-[12.5px] whitespace-pre-wrap break-words`),"data-on":r?`true`:void 0,"data-k":/^#{1,6}\s/.test(a)?`h`:void 0,onClick:e=>!e.target.closest(`a`)&&o(),children:e.fenced?e.text:(0,V.jsx)(QL,{text:e.text})}),(0,V.jsx)(`button`,{type:`button`,className:`cs-dcb`,"aria-label":`Comment on this line: ${a}`,onClick:o,children:(0,V.jsx)(dm,{"aria-hidden":`true`,className:`size-[15px]`})})]}),(0,V.jsx)(JU,{notes:n}),r]})});function ZU({draft:e,comments:t,commenting:n,form:r,onComment:i}){let a=(0,m.useMemo)(()=>qU(e),[e]),o=vL(a.length);return(0,V.jsx)(`ul`,{className:`cs-drl`,"aria-label":`Draft plan lines`,children:a.slice(0,o).map((e,a)=>e.text.trim()?(0,V.jsx)(XU,{row:e,index:a,notes:t.get(e.text.trim())??YU,form:a===n?r:void 0,onComment:i},a):(0,V.jsx)(`li`,{"aria-hidden":`true`,className:`h-2`},a))})}function QU({notes:e}){return e.length===0?null:(0,V.jsx)(GB,{title:OU,children:(0,V.jsx)(`dl`,{className:`flex flex-col gap-2 text-sm`,children:e.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex min-w-0 gap-3`,children:[(0,V.jsx)(`dt`,{className:`w-20 shrink-0 font-semibold`,style:{color:NR(e.from)},children:zR(e.from)}),(0,V.jsx)(`dd`,{className:`min-w-0 flex-1`,children:(0,V.jsx)(QL,{text:e.text})})]},t))})})}function $U(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function eW({label:e,hint:t,buttonLabel:n=`Send`,onSend:r}){let i=(0,m.useId)(),[a,o]=(0,m.useState)(``),[s,c]=(0,m.useState)(!1),l=async()=>{a.trim()&&!s&&(c(!0),await r(a)&&o(``),c(!1))};return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium text-foreground`,children:e}),(0,V.jsx)(CB,{id:i,value:a,rows:2,"aria-describedby":t?`${i}-hint`:void 0,onChange:e=>o(e.target.value),onKeyDown:e=>{$U(e)&&(e.preventDefault(),l())}}),t?(0,V.jsx)(`p`,{id:`${i}-hint`,className:`text-xs text-muted-foreground`,children:t}):null,(0,V.jsx)(`div`,{className:`flex self-end`,children:(0,V.jsx)(UI,{label:n,icon:s?am:Rf,tone:`primary`,shortcut:`Enter`,className:s?`[&_svg]:animate-spin`:void 0,onClick:()=>void l(),disabled:!a.trim()||s})})]})}function tW({line:e,onCancel:t,onSent:n}){let r=(0,m.useRef)(null);return(0,m.useEffect)(()=>{let e=r.current?.querySelector(`textarea`);e?.focus(),e?.scrollIntoView({block:`nearest`})},[]),(0,V.jsxs)(`div`,{ref:r,role:`group`,"aria-label":`Comment on this line`,className:`line-comment cs-dform`,children:[(0,V.jsx)(WT,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Cancel the comment`,title:`Cancel · Esc`,onClick:t,className:`absolute top-1.5 right-1.5 size-7`,children:(0,V.jsx)(Fh,{"aria-hidden":`true`})}),(0,V.jsx)(eW,{label:`Your comment`,hint:`Enter adds the comment · Esc cancels`,buttonLabel:`Add comment`,onSend:async t=>await U(`planner.commentLine`,{line:e,text:t.trim()})?(n(t.trim()),!0):!1})]})}function nW({open:e,onClose:t,snap:n,comments:r,onSent:i}){let a=(0,m.useRef)(null),[o,s]=(0,m.useState)(),c=(0,m.useMemo)(()=>n.draft?qU(n.draft):[],[n.draft]),l=o===void 0?void 0:c[o]?.text.trim(),u=()=>{let e=o;s(void 0),requestAnimationFrame(()=>a.current?.querySelector(`[data-line="${e}"] button[aria-label^="Comment on this line"]`)?.focus())};return(0,V.jsx)(rD,{open:e,onClose:()=>{s(void 0),t()},label:`Draft plan`,closeText:!0,onEscape:e=>{l!==void 0&&(e.preventDefault(),u())},head:(0,V.jsxs)(`div`,{className:`cs-shtitle`,children:[(0,V.jsx)(`h3`,{children:`Draft plan`}),(0,V.jsxs)(`p`,{children:[n.round>0?`${FU(n.round,n.limit)} · `:``,`choose a line to comment on it`]})]}),children:(0,V.jsxs)(`div`,{ref:a,className:`flex flex-col gap-5`,children:[n.draft?(0,V.jsx)(ZU,{draft:n.draft,comments:r,commenting:l===void 0?void 0:o,form:l===void 0?void 0:(0,V.jsx)(tW,{line:l,onCancel:u,onSent:e=>(i(l,e),u())},o),onComment:s}):(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.busy?DU:EU}),(0,V.jsx)(QU,{notes:n.notes})]})})}function rW({title:e,sub:t,aside:n,className:r,children:i}){let a=(0,m.useRef)(null);function o(e){let t=a.current;if(!t||e.defaultPrevented||e.nativeEvent.isComposing||uE()||e.altKey||e.ctrlKey||e.metaKey||IE(e.target)||e.target instanceof HTMLInputElement)return;let n=LE(e.key);n?(e.preventDefault(),BE(t,e.target,n)):(e.key===`Home`||e.key===`End`)&&(e.preventDefault(),BE(t,e.target,e.key===`Home`?`first`:`last`))}return(0,V.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,V.jsx)(`div`,{ref:a,"data-pane":`list`,className:`cs-scroll pb-dock`,onKeyDown:o,children:(0,V.jsxs)(`div`,{className:Y(`cs-pg`,r),children:[(0,V.jsxs)(`div`,{className:`cs-pgh`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h1`,{className:`cs-hd1`,children:e}),t?(0,V.jsx)(`p`,{className:`cs-hd2`,children:t}):null]}),n?(0,V.jsx)(`div`,{className:`flex flex-none items-center gap-2`,children:n}):null]}),i]})}),(0,V.jsx)(m_,{target:a})]})}function iW({on:e,label:t,count:n,onToggle:r,describe:i}){return(0,V.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,"aria-label":i,className:`cs-chk`,onClick:r,children:[(0,V.jsx)(`span`,{className:`cs-cb`,"data-on":e?`true`:void 0,children:(0,V.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M5 12.5l4.5 4.5L19 7.5`})})}),t,n===void 0?null:(0,V.jsx)(`span`,{className:`cs-cn`,children:n})]})}var aW=()=>bE(yE(`plan`,`previous`)),oW=e=>bE(yE(`plan`,`previous`,e));function sW(e){let t=Date.now()-Date.parse(e);return Number.isFinite(t)?oz(Math.max(0,t)):``}function cW(e,t){return[`${t} message${t===1?``:`s`}`,`round ${e.rounds}`,sW(e.updatedAt)].filter(Boolean).join(` · `)}function lW({plan:e,selected:t}){return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>oW(e.id),className:`cs-trw cs-prw`,children:[(0,V.jsxs)(`span`,{className:`cs-tt1`,children:[(0,V.jsx)(`span`,{className:`cs-t`,children:e.title}),(0,V.jsx)(`span`,{className:`cs-mt`,children:cW(e,e.messages)})]}),e.hasDraft?(0,V.jsx)(`span`,{className:`cs-bdg`,"data-t":`acc`,children:`draft`}):(0,V.jsx)(`span`,{})]})})}function uW({id:e,onGone:t}){let n=_R(`planner.previousGet`,{id:e},[`planner`]),r=n.data;if(!r)return n.error?(0,V.jsx)(wE,{message:`Could not load that plan. ${n.error}`,onRetry:n.reload}):null;let i=!!r.archivedAt,a=async()=>{await U(`planner.previousOpen`,{id:e})&&bE(yE(`plan`))},o=async()=>{await U(`planner.previousArchive`,{id:e,archived:!i})&&t()},s=async()=>{await U(`planner.previousDelete`,{id:e})&&t()};return(0,V.jsxs)(`article`,{className:`cs-dt flex flex-col`,"aria-label":r.title,children:[(0,V.jsxs)(WI,{className:`cs-abm`,children:[(0,V.jsx)(UI,{label:`Carry on planning`,text:`Carry on`,icon:Fm,tone:`primary`,shortcut:`C`,onClick:()=>void a()}),(0,V.jsx)(UI,{label:i?`Bring it back from the archive`:`Archive`,text:i?`Unarchive`:`Archive`,icon:i?Of:Af,shortcut:`E`,onClick:()=>void o()}),(0,V.jsx)(uR,{icon:yh,label:`Delete`,shortcut:`Delete`,title:`Delete "${r.title}"?`,description:`The conversation and the draft are removed for good.`,confirmLabel:`Delete plan`,variant:`destructive`,onConfirm:()=>void s()})]}),(0,V.jsxs)(`header`,{children:[(0,V.jsx)(`h2`,{children:r.title}),(0,V.jsx)(`p`,{className:`cs-sub`,children:[i?`archived`:``,cW(r,r.messages.length),r.seed??``].filter(Boolean).join(` · `)})]}),(0,V.jsxs)(GB,{title:`Draft plan`,children:[r.draft?(0,V.jsx)(QL,{text:r.draft}):(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The panel had not written a draft yet.`}),(0,V.jsx)(QU,{notes:r.notes})]}),(0,V.jsx)(GB,{title:`Conversation`,children:(0,V.jsx)(`div`,{className:`cs-pvc`,children:(0,V.jsx)(wU,{messages:r.messages,readOnly:!0})})})]})}function dW({id:e}){let[t,n]=(0,m.useState)(!1),r=_R(`planner.previous`,t?{archived:!0}:{},[`planner`]),i=r.data?.plans??[];if(!r.data&&r.error)return(0,V.jsx)(wE,{message:`Could not load the previous plans. ${r.error}`,onRetry:r.reload});let a=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(UI,{label:`Back to the current plan`,text:`Back`,icon:Pf,onClick:()=>bE(yE(`plan`))}),(0,V.jsx)(iW,{on:t,label:`Archived`,describe:t?`Show the previous plans`:`Show the archived plans`,onToggle:()=>{n(e=>!e),aW()}})]}),o=r.data?i.length===0?(0,V.jsx)(`p`,{className:`px-2.5 py-6 text-sm text-muted-foreground`,children:t?`No archived plans.`:`No previous plans. A plan you leave without saving it as a task waits here; one saved as a task is in the Tasks tab.`}):(0,V.jsx)(`ul`,{className:`cs-lst`,"aria-label":t?`Archived plans`:`Previous plans`,children:i.map(t=>(0,V.jsx)(lW,{plan:t,selected:t.id===e},t.id))}):(0,V.jsx)(JE,{});return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(rW,{title:t?`Archived plans`:`Previous plans`,sub:r.data?`${i.length} ${i.length===1?`plan`:`plans`}`:void 0,className:`cs-ts`,aside:a,children:o}),(0,V.jsx)(rD,{open:e!==void 0,onClose:aW,label:`A previous plan`,className:`cs-tdw`,children:e?(0,V.jsx)(uW,{id:e,onGone:()=>{r.reload(),aW()}},e):null})]})}function fW({cell:e,onToggled:t}){let{member:n}=e,r=zR(e.label),i={"--c":NR(e.label)},a=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`span`,{className:`cs-sht`,children:[(0,V.jsxs)(`span`,{children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-tile`,style:{"--ac":NR(e.label)},children:r[0]}),r]}),n?(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-cb`,"data-on":e.seated?`true`:void 0,children:(0,V.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,V.jsx)(`path`,{d:`M5 12.5l4.5 4.5L19 7.5`})})}):null]}),(0,V.jsx)(`p`,{children:MU[e.label]}),(0,V.jsx)(`small`,{children:n?e.seated?`seated`:`sits this one out`:`always chairs`})]});return n?(0,V.jsx)(`li`,{children:(0,V.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e.seated,"aria-label":`${r} sits on the panel`,className:`cs-seatc`,"data-on":e.seated?`true`:`false`,style:i,onClick:()=>void pW(n,t),children:a})}):(0,V.jsx)(`li`,{children:(0,V.jsx)(`div`,{className:`cs-seatc`,"data-on":`true`,"data-fixed":`true`,style:i,children:a})})}async function pW(e,t){await U(`planner.toggleSeat`,{member:e})&&t()}function mW({cells:e,onToggled:t}){return(0,V.jsx)(`ul`,{"aria-label":`Panel`,className:`cs-seatg`,children:e.map(e=>(0,V.jsx)(fW,{cell:e,onToggled:t},e.label))})}function hW({limit:e}){return e<=0?null:(0,V.jsxs)(`span`,{className:`cs-rounds`,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-bars`,children:Array.from({length:e},(t,n)=>(0,V.jsx)(`i`,{"data-last":n===e-1||void 0},n))}),(0,V.jsxs)(`span`,{children:[`up to `,e,` rounds, the last the oracle's`]})]})}function gW({snap:e,onDone:t}){let n=VU(e),r=(0,m.useRef)(null);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{ref:r,className:`cs-scroll pb-dock`,children:(0,V.jsxs)(`div`,{className:`cs-pg cs-intro`,children:[(0,V.jsxs)(`header`,{className:`cs-ih`,children:[(0,V.jsxs)(`div`,{className:`cs-ic`,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-ico`,children:(0,V.jsx)(qm,{className:`size-5`})}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{children:`Plan with the panel`}),(0,V.jsx)(`p`,{children:jU})]})]}),(0,V.jsxs)(`div`,{className:`cs-ir`,children:[(0,V.jsx)(HU,{}),(0,V.jsx)(hW,{limit:e.limit})]})]}),(0,V.jsxs)(`section`,{"aria-labelledby":`plan-panel`,children:[(0,V.jsxs)(`h3`,{id:`plan-panel`,className:`cs-rl`,children:[`The panel`,(0,V.jsx)(`span`,{className:`cs-rr`,children:PU(n)})]}),(0,V.jsx)(mW,{cells:n,onToggled:t})]}),(0,V.jsxs)(`section`,{"aria-labelledby":`plan-steps`,children:[(0,V.jsx)(`h3`,{id:`plan-steps`,className:`cs-rl`,children:`How a plan comes together`}),(0,V.jsx)(`ol`,{className:`cs-stepg`,children:NU.map((e,t)=>(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-no`,children:t+1}),(0,V.jsxs)(`span`,{className:`min-w-0`,children:[(0,V.jsx)(`b`,{children:e.title}),(0,V.jsx)(`span`,{children:e.text})]})]},e.title))})]}),(0,V.jsxs)(`p`,{className:`cs-starth`,children:[(0,V.jsx)(Mf,{"aria-hidden":`true`,className:`size-4`}),`Start in the box below.`,(0,V.jsx)($T,{chord:`/`,children:`write`}),(0,V.jsx)($T,{chord:`Enter`,children:`send to the panel`})]})]})}),(0,V.jsx)(m_,{target:r})]})}function _W(e,t){let n=(0,m.useRef)(t);n.current=t;let r=(0,m.useCallback)(()=>n.current(),[]);tD(`v`,r,{enabled:!!e.draft}),jD(e.draft?r:void 0)}function vW({snap:e,reload:t}){let[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(new Map);_W(e,()=>r(!0));let o=(e,t)=>a(n=>new Map(n).set(e,[...n.get(e)??[],t])),{ref:s,onScroll:c}=DR(`${JSON.stringify(e.messages)}${e.busy}`);return(0,V.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,V.jsxs)(`div`,{ref:s,onScroll:c,className:`cs-thread min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-5 pb-dock`,children:[(0,V.jsx)(UU,{snap:e}),(0,V.jsx)(wU,{messages:e.messages,busy:e.busy})]}),(0,V.jsx)(m_,{target:s}),(0,V.jsx)(KU,{snap:e,onDone:t}),(0,V.jsx)(nW,{open:n,onClose:()=>r(!1),snap:e,comments:i,onSent:o})]})}function yW({rest:e=[]}){return e[0]===`previous`?(0,V.jsx)(dW,{id:e[1]}):(0,V.jsx)(bW,{})}function bW(){let e=_R(`planner.get`,{},[`planner`]),t=e.data;if(!t&&e.error)return(0,V.jsx)(wE,{message:`Could not load the plan. ${e.error}`,onRetry:e.reload});if(!t)return(0,V.jsx)(`p`,{role:`status`,className:`p-5 text-sm text-muted-foreground`,children:`Loading the plan…`});let n=LU(t);return(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:n?(0,V.jsx)(gW,{snap:t,onDone:e.reload}):(0,V.jsx)(vW,{snap:t,reload:e.reload})})}var xW={},SW=new Set;function CW(e){xW=e;for(let e of[...SW])e()}function wW(e){xW.taskId!==e&&CW({...xW,taskId:e})}function TW(e){return SW.add(e),()=>{SW.delete(e)}}function EW(){return(0,m.useSyncExternalStore)(TW,()=>xW,()=>xW)}function DW(e,t=0,n=!1){let r=!n&&!e.waiting&&!!e.runningSince,i=r?Date.parse(e.serverNow)-Date.parse(e.runningSince):0;return Math.max(0,e.elapsedMs)+(Number.isFinite(i)?Math.max(0,i):0)+(r?Math.max(0,t):0)}function OW(e){let t=Math.floor(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${t%60}s`:`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m`}function kW(e,t){let[n,r]=(0,m.useState)(0);return(0,m.useEffect)(()=>{if(r(0),!e)return;let t=performance.now(),n=window.setInterval(()=>r(performance.now()-t),1e3);return()=>window.clearInterval(n)},[e,t]),e?n:0}function AW({timing:e,stopped:t}){let[n,r]=(0,m.useState)(0);return(0,m.useEffect)(()=>{if(r(0),t||e.waiting||!e.runningSince)return;let n=performance.now(),i=window.setInterval(()=>r(performance.now()-n),1e3);return()=>window.clearInterval(i)},[e,t]),(0,V.jsxs)(`span`,{className:`tabular-nums break-words`,children:[e.waiting?`Waiting for you · `:``,OW(DW(e,n,t)),` execution`]})}function jW({work:e,timing:t,stopped:n}){let r=e.running&&!n&&!t?.waiting,i=kW(r,e);return(0,V.jsxs)(`span`,{className:`tabular-nums break-words`,"data-work-clock":r?`running`:`stopped`,children:[t?.waiting?`Waiting for you · `:``,`worked `,OW(e.workedMs+i)]})}function MW({timing:e,work:t,stopped:n=!1}){return t?(0,V.jsx)(jW,{work:t,...e?{timing:e}:{},stopped:n}):e?(0,V.jsx)(AW,{timing:e,stopped:n},JSON.stringify(e)):(0,V.jsx)(`span`,{children:`Timing unavailable`})}var NW=`This merges the reviewed commit into main and pushes main, then removes the task worktree after verifying the merge. The task branch is kept.`,PW={pending_approval:`Ready for your review`,deferred:`Saved for later`,in_progress:`Delivery in progress`,successful:`Delivered`,recoverable_failure:`Delivery needs attention`};function FW({delivery:e,title:t}){return(0,V.jsxs)(`div`,{className:`cs-dlv grid gap-2 text-[12.5px]`,children:[(0,V.jsx)(`p`,{className:`text-[13.5px] font-semibold break-words`,children:t}),(0,V.jsxs)(`dl`,{children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{children:`Project`}),(0,V.jsx)(`dd`,{children:e.project})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{children:`Repository`}),(0,V.jsx)(`dd`,{children:e.repository??`Unavailable — refresh review`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{children:`Source`}),(0,V.jsxs)(`dd`,{children:[e.sourceBranch,` · `,e.sourceCommit??`Commit unavailable`]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{children:`Target`}),(0,V.jsxs)(`dd`,{children:[`main`,e.targetCommit?` · ${e.targetCommit}`:``]})]})]}),(0,V.jsxs)(`p`,{children:[`Checks: `,e.verification?.checks??`unavailable`]}),(0,V.jsx)(`p`,{children:e.verification?.summary??`Verification unavailable. Refresh the review before delivery.`}),e.verification?(0,V.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Local completion/QA: `,e.verification.localVerified?`passed`:`not verified`,` · Repository rules: `,e.verification.rulesKnown?`known`:`unavailable`,e.verification.requiredChecks.length?` · Required: ${e.verification.requiredChecks.join(`, `)}`:``]}):null]})}function IW({action:e,delivery:t,busy:n,onAction:r}){let i=t.blocked[e],a=e===`merge_main`&&t.status===`successful`&&!!t.cleanupError,o=n||t.status===`in_progress`||t.status===`successful`&&!a||!!i;return(0,V.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,V.jsx)(WT,{variant:`outline`,size:`sm`,className:`w-fit`,disabled:o,onClick:()=>r(e),children:e===`create_pr`?`Create PR`:a?`Retry worktree cleanup`:`Merge to main`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e===`create_pr`?`Pushes the task branch and opens a PR targeting main. Does not merge.`:a?`Main was delivered. Removes the retained worktree after confirmation.`:`Updates and pushes main, then removes the task worktree. Requires confirmation.`}),i?(0,V.jsxs)(`p`,{className:`text-sm text-destructive`,children:[i,` Refresh review after resolving this restriction, then choose the action again.`]}):null]})}async function LW(e,t,n){let r={taskId:t,reviewId:n};return e===`refresh`?L(`tasks.deliveryReview`,{taskId:t}):e===`defer`?L(`tasks.deliveryDefer`,r):L(`tasks.deliver`,{...r,action:e,...e===`merge_main`?{confirmMain:!0}:{}})}function RW({taskId:e,delivery:t}){let[n,r]=(0,m.useState)(t),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(!1),u=(0,m.useRef)(null),d=pe(),f=`${d}:${e}`,p=(0,m.useRef)(f);return p.current=f,(0,m.useEffect)(()=>(p.current=f,()=>{p.current=``}),[f]),(0,m.useEffect)(()=>{r(t),l(!1)},[t,e]),{current:n,setCurrent:r,busy:i,setBusy:a,error:o,setError:s,confirm:c,setConfirm:l,trigger:u,project:d,identity:f,scope:p}}function zW(e){return e.scope.current===e.identity&&e.project===pe()}function BW(e,t){let n=(0,m.useRef)(!1);async function r(r){if(!(n.current||r===`merge_main`&&!e.confirm)){n.current=!0,e.setBusy(!0),e.setError(void 0),e.setConfirm(!1);try{let n=await LW(r,t.taskId,e.current.reviewId);zW(e)&&(e.setCurrent(n.delivery),t.onChanged())}catch(t){zW(e)&&e.setError(t instanceof Error?t.message:String(t))}finally{n.current=!1,e.scope.current&&e.setBusy(!1)}}}return r}function VW(e){let t=RW(e),n=BW(t,e),r=lE(t.confirm,cE.confirm),i=t.current.status===`successful`||t.current.status===`in_progress`;function a(){t.trigger.current=document.activeElement,t.setConfirm(!0)}return{...t,request:n,slot:r,terminal:i,reviewMerge:a}}function HW({review:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Task completion is recorded separately. Nothing is published without your approval.`}),(0,V.jsx)(`p`,{role:`status`,className:`text-sm`,children:e.busy?`Updating delivery…`:e.current.operation?`Operation: ${e.current.operation.stage}`:PW[e.current.status]}),e.current.error||e.error?(0,V.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.error??e.current.error,` Completed work is retained. Refresh review to reconcile the result before retrying.`]}):null,e.current.cleanupError?(0,V.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.current.cleanupError,` Retry cleanup after resolving it.`]}):null,e.current.operation?.worktreeRemoved?(0,V.jsx)(`p`,{className:`text-sm`,children:`Task worktree removed.`}):null,e.current.result?(0,V.jsxs)(`p`,{className:`text-sm break-all`,children:[e.current.result.action===`create_pr`?`PR #${e.current.result.pullNumber??``} created`:`main pushed · ${e.current.result.commit??``}`,e.current.result.pullUrl?(0,V.jsxs)(`span`,{children:[` · `,e.current.result.pullUrl]}):null]}):null]})}function UW({review:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,V.jsx)(IW,{action:`create_pr`,delivery:e.current,busy:e.busy,onAction:()=>void e.request(`create_pr`)}),(0,V.jsx)(IW,{action:`merge_main`,delivery:e.current,busy:e.busy,onAction:e.reviewMerge})]}),(0,V.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,V.jsx)(WT,{variant:`outline`,size:`sm`,disabled:e.busy,onClick:()=>void e.request(`refresh`),children:`Refresh review`}),(0,V.jsx)(WT,{variant:`ghost`,size:`sm`,disabled:e.busy||e.terminal,onClick:()=>void e.request(`defer`),children:`Not now`})]})]})}function WW({review:e}){let t=e.current.status===`successful`&&!!e.current.cleanupError,n=t?`Main was already delivered. Remove the task worktree if it still contains only the reviewed commit. The task branch is kept.`:NW;return(0,V.jsx)(tE,{open:e.slot,onOpenChange:e.setConfirm,label:t?`Confirm worktree removal`:`Confirm merge to main`,description:n,onCloseAutoFocus:t=>{t.preventDefault(),requestAnimationFrame(()=>e.trigger.current?.focus())},children:(0,V.jsxs)(`div`,{className:`grid gap-3 p-4`,children:[(0,V.jsx)(`h3`,{className:`font-medium`,children:t?`Remove task worktree?`:`Merge to main?`}),(0,V.jsx)(`p`,{className:`text-sm`,children:n}),(0,V.jsxs)(`p`,{className:`break-all text-sm text-muted-foreground`,children:[e.current.repository,` · `,e.current.sourceCommit,` → main`]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,V.jsx)(WT,{variant:`outline`,onClick:()=>e.setConfirm(!1),children:`Cancel`}),(0,V.jsx)(WT,{disabled:e.busy||!!e.current.blocked.merge_main||e.terminal&&!t,onClick:()=>void e.request(`merge_main`),children:t?`Confirm worktree removal`:`Confirm merge and push main`})]})]})})}function GW({title:e,review:t}){return(0,V.jsxs)(GB,{title:`Completed work · delivery review`,right:PW[t.current.status],children:[(0,V.jsxs)(`div`,{className:`cs-sunkbox`,children:[(0,V.jsx)(FW,{delivery:t.current,title:e}),(0,V.jsx)(HW,{review:t}),(0,V.jsx)(UW,{review:t})]}),(0,V.jsx)(WW,{review:t})]})}function KW(e){let t=VW(e);return(0,V.jsx)(GW,{title:e.title,review:t})}var qW={open:_p,delivered:dp,addressed:sp},JW={open:`waiting for the owning session`,delivered:`sent to the oracle`,addressed:`plan amended`};function YW({comment:e}){let t=oz(Date.now()-Date.parse(e.createdAt)),n=qW[e.status];return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(n,{"aria-hidden":`true`,className:`size-3.5`}),JW[e.status],`, `,t,e.editedAt?` (edited)`:``]})}function XW({comment:e,taskId:t,own:n}){let[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(),s=a&&(a.editedAt??``)>(e.editedAt??``)?a:e;return(0,V.jsxs)(`li`,{className:`cs-cmc`,children:[r?(0,V.jsx)(_U,{text:s.text,onSave:async n=>{let r=await L(`tasks.editComment`,{taskId:t,commentId:e.id,text:n});o(r.comment)},onCancel:()=>i(!1)}):(0,V.jsx)(QL,{text:s.text}),(0,V.jsxs)(`div`,{className:`cs-cmeta`,"data-s":s.status,children:[(0,V.jsx)(YW,{comment:s}),n&&!r?(0,V.jsx)(`button`,{type:`button`,className:`cs-eb`,onClick:()=>i(!0),children:`Edit`}):null]})]})}function ZW({taskId:e,onAdded:t}){let[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),c=(0,m.useId)();if(!n)return(0,V.jsxs)(WT,{size:`sm`,variant:`outline`,className:`w-fit`,onClick:()=>r(!0),children:[(0,V.jsx)(dm,{"aria-hidden":`true`}),`Add comment`]});let l=async()=>{if(o||!i.trim())return;s(!0);let n=await U(`tasks.comment`,{taskId:e,text:i.trim()})!==void 0;s(!1),n&&(a(``),r(!1),t())};return(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{htmlFor:c,className:`sr-only`,children:`Your comment`}),(0,V.jsx)(`textarea`,{id:c,autoFocus:!0,className:`cs-ta2`,placeholder:`Your comment`,value:i,disabled:o,onChange:e=>a(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),r(!1)):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),l()))}}),(0,V.jsxs)(`div`,{className:`cs-fa`,children:[(0,V.jsx)(`span`,{className:`cs-hint2`,children:`Enter adds the comment · Esc cancels`}),(0,V.jsx)(WT,{size:`sm`,variant:`ghost`,disabled:o,onClick:()=>r(!1),children:`Cancel`}),(0,V.jsx)(WT,{size:`sm`,disabled:o||!i.trim(),onClick:()=>void l(),children:`Add comment`})]})]})}function QW({taskId:e,finished:t,canComment:n}){let r=_R(`tasks.comments`,{taskId:e},[`tasks`]),i=FE(`status`),a=r.data?.comments??[],o=a.filter(e=>e.status!==`addressed`).length;return(0,V.jsxs)(`section`,{"aria-labelledby":`comments-${e}`,className:`cs-sec flex flex-col gap-3`,children:[(0,V.jsxs)(`h3`,{id:`comments-${e}`,className:`cs-rl`,children:[`Comments`,o>0?(0,V.jsxs)(`span`,{className:`cs-rr`,children:[o,` open`]}):null]}),a.length===0?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?`No comments.`:n?`No comments yet. Comment on the plan here or in the box below (Markdown and images work there); the oracle amends it.`:`No comments yet.`}):(0,V.jsx)(`ul`,{className:`cs-cm`,children:a.map(t=>(0,V.jsx)(XW,{taskId:e,comment:t,own:!!(t.by&&t.by===i.data?.sessionId)},`${e}-${t.id}`))}),n?(0,V.jsx)(ZW,{taskId:e,onAdded:r.reload}):null]})}var $W={mine:`This session`,others:`Other sessions`,pending:`Pending`,recent:`Finished`,archived:`Archived`},eG={open:`open`,done:`done`,dropped:`abandoned`},tG={none:{label:`None`,depth:`nothing that runs changed: the engine's checks decide, no QA agent`,tone:``},low:{label:`Low`,depth:`a light check: the diff, the nearest tests, done once confident`,tone:`ok`},medium:{label:`Medium`,depth:`a standard check: the acceptance criteria and realistic regressions`,tone:`warn`},high:{label:`High`,depth:`a deep, adversarial review: invariants, recovery and everything the change reaches`,tone:`bad`}};function nG(e){let t=e.source===`classifier`?`Jev`:`rules`;if(!e.qaRequired)return`${t} · no QA agent`;let{min:n,max:r}=e.testBudget;return`${t} · ${n===r?r:`${n}-${r}`} new tests at most`}var rG=`No tasks yet. Start one from the Lobby tab, or plan one in the Plan tab.`;function iG(e,t){return`${e.replace(/_/g,` `)}${t?` · paused`:``}`}function aG(e){return e===`now`?`just now`:`${e} ago`}function oG(e){if(e.kind===`plan`)return[`planned`,e.age?e.age===`now`?`saved just now`:`saved ${e.age} ago`:``,e.issue?`#${e.issue}`:``].filter(Boolean).join(` · `);let t=e.owner??(e.section===`mine`?`this session`:``);return[iG(e.status,e.paused),t].filter(Boolean).join(` · `)}function sG(e){let t=[];for(let n of e){let e=t.at(-1);e&&e.section===n.section?e.rows.push(n):t.push({section:n.section,rows:[n]})}return t}function cG(e){let t=e.filter(e=>e.kind!==`archived`),n=t.filter(e=>e.check===`open`).length,r=t.length-n,i=e.length-t.length;return[n?`${n} open`:``,r?`${r} finished`:``,i?`${i} archived`:``].filter(Boolean).join(` · `)||`0`}var lG=1e3;function uG({taskId:e,index:t,text:n,onSkipped:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(``),f=lE(i,cE.confirm),p=(0,m.useId)(),h=(0,m.useId)(),g=o.trim(),_=e=>{c||(a(e),s(``),d(``))},v=async()=>{if(g&&!c){l(!0),d(``);try{H((await L(`tasks.skipStep`,{taskId:e,step:t,text:n,reason:g})).notice),a(!1),s(``),r()}catch(e){d(e instanceof Error?e.message:`That did not work. Try again.`)}finally{l(!1)}}};return(0,V.jsxs)(nR,{open:i&&f,onOpenChange:_,children:[(0,V.jsxs)(`button`,{type:`button`,"aria-label":`Skip step ${t+1}`,onClick:()=>_(!0),className:`cs-skp step-skip`,children:[(0,V.jsx)(rh,{"aria-hidden":`true`,className:`size-3.5`}),`Skip`]}),(0,V.jsxs)(rR,{children:[(0,V.jsxs)(iR,{children:[(0,V.jsxs)(oR,{children:[`Skip step `,t+1,`?`]}),(0,V.jsx)(sR,{children:`The oracle is told to carry on without it, and your reason stays with the step in the task's history.`})]}),(0,V.jsx)(`p`,{className:`rounded-md bg-muted px-2.5 py-1.5 text-sm break-words`,children:n}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`label`,{htmlFor:p,className:`text-sm font-medium`,children:`Why skip it?`}),(0,V.jsx)(CB,{id:p,value:o,autoFocus:!0,required:!0,maxLength:lG,disabled:c,"aria-describedby":h,"aria-invalid":u?!0:void 0,placeholder:`Already done by hand, not needed any more, out of scope…`,className:`max-h-48 min-h-20`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),v())}}),(0,V.jsx)(`p`,{id:h,className:`text-xs text-muted-foreground`,children:`A reason is required.`})]}),u?(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:u}):null,(0,V.jsxs)(aR,{children:[(0,V.jsx)(lR,{disabled:c,children:`Cancel`}),(0,V.jsx)(WT,{disabled:!g||c,"aria-busy":c,onClick:()=>void v(),children:c?`Skipping…`:`Skip step`})]})]})]})}function dG({step:e,stopped:t}){let n=kW(!t,e);return(0,V.jsx)(`span`,{className:`tabular-nums`,children:OW((e.workedMs??0)+n)})}function fG(e){return(e.split(`
|
|
100
|
-
`).find(e=>e.trim())?.trim()??``).replace(/^steps?\s+\d+(?:\s*[-–]\s*\d+)?\s*[:.\-–]\s*/i,``).replace(/^\*\*?goal\*\*?\s*[:\-–]\s*/i,``)}var pG=e=>UR({domain:e.domain});function mG({id:e,agents:t,stepText:n}){let[r,i]=(0,m.useState)(Date.now);(0,m.useEffect)(()=>{let e=window.setInterval(()=>i(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let a=t.filter(e=>!e.parentRunId||!t.some(t=>t.runId===e.parentRunId)).flatMap(e=>[e,...t.filter(t=>t.parentRunId===e.runId)]);return(0,V.jsx)(`ul`,{id:e,"aria-label":`Agents on this step`,className:`cs-arows`,children:a.map(e=>{let i=pG(e),a=!!e.parentRunId&&t.some(t=>t.runId===e.parentRunId),o=Date.parse(e.startedAt),s=fG(e.instruction),c=s&&s.toLowerCase()!==n.trim().toLowerCase()?s:``;return(0,V.jsxs)(`li`,{className:`cs-arow`,"data-child":a?`true`:void 0,style:{"--ac":NR(i)},children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-bt`}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-be`}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-tile`,children:zR(i)[0]}),(0,V.jsxs)(`span`,{className:`cs-ab2`,children:[(0,V.jsxs)(`span`,{className:`cs-ab2h`,children:[(0,V.jsx)(`b`,{children:zR(i)}),a?(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`child`}):null,(0,V.jsx)(`span`,{className:`cs-live`,children:`working`})]}),c?(0,V.jsx)(`span`,{className:`cs-br`,title:e.instruction,children:c}):null]}),Number.isFinite(o)?(0,V.jsx)(`span`,{className:`cs-tm`,children:OW(Math.max(0,r-o))}):null]},e.runId)})})}function hG({agents:e,count:t,step:n,stopped:r}){let i=[...new Set(e.map(pG))].slice(0,3);return(0,V.jsxs)(V.Fragment,{children:[i.length>0?(0,V.jsx)(`span`,{className:`cs-avs`,"aria-hidden":`true`,children:i.map(e=>(0,V.jsx)(`i`,{style:{"--ac":NR(e)},children:zR(e)[0]},e))}):null,(0,V.jsxs)(`span`,{className:`cs-cn1`,children:[t,` `,r?t===1?`agent`:`agents`:`working`]}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-dm`,children:`·`}),(0,V.jsx)(dG,{step:n,stopped:r})]})}function gG(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString(void 0,{day:`numeric`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function _G({step:e,index:t}){let n=e.skip?gG(e.skip.at):``;return(0,V.jsxs)(`li`,{className:`cs-stp`,"data-k":`skip`,"data-step":`skipped`,children:[(0,V.jsxs)(`div`,{className:`cs-stpa`,children:[(0,V.jsx)(ez,{mark:`skip`}),(0,V.jsxs)(`span`,{className:`cs-n`,children:[t+1,`.`]}),(0,V.jsx)(`span`,{className:`cs-tx`,children:e.text}),(0,V.jsx)(`span`,{className:`cs-skd`,children:`skipped`})]}),e.skip?(0,V.jsxs)(`p`,{className:`cs-why step-skip-reason`,children:[(0,V.jsx)(`b`,{children:`Why: `}),e.skip.reason,n?(0,V.jsxs)(`span`,{className:`text-[var(--faint)]`,children:[` · `,n]}):null]}):null]})}function vG({step:e,index:t,stopped:n,skip:r}){let i=!!e.active&&!n,a=i?e.agents??[]:[],o=a.length||(e.activeAgentCount??1),[s,c]=(0,m.useState)(!0),l=(0,m.useId)(),u=e.status===`done`;if(e.status===`skipped`)return(0,V.jsx)(_G,{step:e,index:t});let d=e.status===`current`&&!n;return(0,V.jsxs)(`li`,{className:`cs-stp`,"data-k":i?`now`:u?`done`:d?`next`:`todo`,"data-step":i?`active`:e.status,children:[(0,V.jsxs)(`div`,{className:`cs-stpa`,children:[(0,V.jsx)(ez,{mark:i?`now`:u?`done`:`open`}),(0,V.jsxs)(`span`,{className:`cs-n`,children:[t+1,`.`]}),(0,V.jsx)(`span`,{className:`cs-tx`,children:e.text}),i?(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":a.length>0?s:void 0,"aria-controls":a.length>0?l:void 0,disabled:a.length===0,onClick:()=>c(e=>!e),className:`cs-abdg`,children:[(0,V.jsx)(hG,{agents:a,count:o,step:e,stopped:n}),a.length>0?(0,V.jsx)(Zf,{"aria-hidden":`true`,className:`size-3`}):null,(0,V.jsx)(`span`,{className:`sr-only`,children:` (being worked on now)`})]}):d?(0,V.jsxs)(`span`,{className:`cs-nx`,children:[`next`,(0,V.jsx)(`span`,{className:`sr-only`,children:` (the step up next)`})]}):null,r&&!u&&!n?(0,V.jsx)(uG,{taskId:r.taskId,index:t,text:e.text,onSkipped:r.onSkipped}):null]}),s&&a.length>0?(0,V.jsx)(mG,{id:l,agents:a,stepText:e.text}):null]})}function yG({steps:e,stopped:t,skip:n}){let r=e.filter(e=>e.status===`skipped`).length;return(0,V.jsx)(GB,{title:`Steps`,...r?{right:`${r} skipped`}:{},children:(0,V.jsx)(`ol`,{className:`cs-stl`,"aria-label":`Steps`,children:e.map((e,r)=>(0,V.jsx)(vG,{step:e,index:r,stopped:t,skip:n},`${r}-${e.text}`))})})}function bG({text:e}){let[t,n]=(0,m.useState)(!1),r=(0,m.useId)();return(0,V.jsxs)(GB,{title:`Full plan`,children:[(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":r,onClick:()=>n(e=>!e),className:`cs-fold w-fit`,children:[(0,V.jsx)(tp,{"aria-hidden":`true`,className:`size-4`}),t?`Hide the details`:`Read the details of each step`]}),t?(0,V.jsx)(`div`,{id:r,className:`cs-fpb`,children:(0,V.jsx)(QL,{text:e})}):null]})}function xG({detail:e,finished:t}){return e.plan&&e.planDetails?(0,V.jsx)(bG,{text:e.planDetails}):e.plan?(0,V.jsx)(GB,{title:`Approved plan`,children:(0,V.jsx)(QL,{text:e.plan})}):e.proposal?(0,V.jsx)(GB,{title:t?`Proposal`:`Proposal (no plan yet)`,children:(0,V.jsx)(QL,{text:e.proposal})}):(0,V.jsx)(GB,{title:`Plan`,children:(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?`It ended before a plan was made.`:`No proposal or plan yet — the oracle is still clarifying or scouting.`})})}function SG({amendments:e}){return e.length===0?null:(0,V.jsx)(GB,{title:`Amendments`,children:(0,V.jsx)(`ul`,{className:`cs-bl`,children:e.map(e=>(0,V.jsx)(`li`,{className:`break-words`,children:e},e))})})}function CG({risk:e}){let t=tG[e.risk];return(0,V.jsxs)(GB,{title:`QA risk`,right:nG(e),children:[(0,V.jsxs)(`p`,{className:`cs-qa1`,"data-qa-risk":e.risk,children:[(0,V.jsx)(`span`,{className:`cs-bdg`,"data-t":t.tone,children:t.label}),(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:t.depth})]}),e.focusAreas.length>0?(0,V.jsx)(`ul`,{className:`cs-bl`,"aria-label":`What QA looks at first`,children:e.focusAreas.map(e=>(0,V.jsx)(`li`,{className:`break-words`,children:e},e))}):null,(0,V.jsxs)(`p`,{className:`cs-qaf`,children:[e.riskFactors.join(` · `),e.qaRequired?` · existing tests ${e.existingTestsLikelySufficient?`likely enough`:`likely not enough`}`:``]})]})}function wG({runs:e}){return e.length===0?null:(0,V.jsx)(GB,{title:`Recent runs`,children:(0,V.jsx)(`ul`,{className:`cs-bl cs-plain`,children:e.map((e,t)=>(0,V.jsx)(`li`,{className:`break-words`,children:e},`${t}-${e}`))})})}function TG({detail:e,finished:t,skip:n}){return(0,V.jsxs)(V.Fragment,{children:[e.steps.length>0?(0,V.jsx)(yG,{steps:e.steps,stopped:t,skip:n}):null,e.request?(0,V.jsx)(GB,{title:`Request`,children:(0,V.jsx)(QL,{text:e.request})}):null,(0,V.jsx)(xG,{detail:e,finished:t})]})}function EG({detail:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(SG,{amendments:e.amendments}),e.qaRisk?(0,V.jsx)(CG,{risk:e.qaRisk}):null,(0,V.jsx)(wG,{runs:e.runs})]})}function DG({row:e,quiet:t=!1}){let n=(0,m.useRef)(!0);(0,m.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]);async function r(){if(e.section===`mine`)return bE(`#/lobby`);let t=pe(),r=()=>n.current&&pe()===t;try{let t=await L(`tasks.open`,{taskId:e.id});if(!r())return;let n=await L(`status.get`,{});if(!r())return;if(t.sessionId&&t.sessionId===n.sessionId)return bE(`#/lobby`);if(t.sessionId&&!t.key)return H.info(`This task runs in another terminal. Switch to that terminal to work on it.`);if(n.busy)return H.info(`The oracle is working in this window. Stop it first, then open the task in its session.`);await U(`sessions.switch`,t.key?{key:t.key}:{claimTaskId:e.id})&&r()&&bE(`#/lobby`)}catch(e){r()&&H.error(e instanceof Error?e.message:String(e))}}let i=e.section===`mine`;return(0,V.jsx)(UI,{label:i?`Open in its session: this window`:`Open in its session`,text:`Open in session`,icon:If,tone:t?`neutral`:`primary`,shortcut:`S`,onClick:()=>void r()})}function OG({split:e}){let t=e.after.length>0?`, after ${e.after.map(e=>`part ${e}`).join(` and `)}`:``;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[(0,V.jsxs)(`span`,{className:`font-medium text-primary`,children:[`part `,e.part,` of `,e.of]}),` of one plan that was split into tasks`,t?(0,V.jsx)(`span`,{className:`text-foreground`,children:t}):null]}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.titles.map((t,n)=>(0,V.jsxs)(`span`,{children:[n>0?(0,V.jsx)(`span`,{className:`text-muted-foreground/60`,children:` · `}):null,(0,V.jsxs)(`span`,{className:n+1===e.part?`font-medium text-foreground`:void 0,children:[n+1,`. `,t]})]},`${n}-${t}`))})]})}function kG({planId:e}){let t=_R(`plans.get`,{planId:e},[`plans`]),n=t.data;return n?(0,V.jsxs)(V.Fragment,{children:[n.issue?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`from issue #`,n.issue.number,` — `,n.issue.title,n.issue.url?(0,V.jsxs)(`span`,{className:`break-all`,children:[` `,n.issue.url]}):null]}):null,n.split?(0,V.jsx)(OG,{split:n.split}):null,(0,V.jsx)(GB,{title:`Agreed plan`,children:(0,V.jsx)(QL,{text:n.brief})})]}):t.error?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the agreed plan. `,t.error]}):null}function AG({row:e,onGone:t}){let n=async n=>{await U(`plans.start`,{planId:e.id,where:n})&&t()},r=async()=>{await U(`plans.discard`,{planId:e.id})&&t()};return(0,V.jsxs)(WI,{children:[(0,V.jsx)(UI,{label:`Start here`,icon:Fm,tone:`primary`,shortcut:`S`,onClick:()=>void n(`here`)}),(0,V.jsx)(UI,{label:`Start in a new session`,text:`New session`,icon:sh,shortcut:`N`,onClick:()=>void n(`session`)}),(0,V.jsx)(uR,{icon:yh,label:`Discard`,shortcut:`Delete`,title:`Discard "${e.title}"?`,description:`The saved plan is removed from the list. This cannot be undone.`,confirmLabel:`Discard`,variant:`destructive`,onConfirm:()=>void r()})]})}function jG({row:e}){return(0,V.jsxs)(`article`,{className:`cs-dt flex min-w-0 flex-col`,"aria-label":e.title,children:[(0,V.jsxs)(`header`,{children:[(0,V.jsxs)(`h2`,{children:[(0,V.jsx)(tz,{check:`open`}),(0,V.jsx)(`span`,{className:`min-w-0 break-words`,children:e.title})]}),(0,V.jsxs)(`p`,{className:`cs-sub`,children:[(0,V.jsx)(`span`,{className:`cs-bdg`,children:`planned`}),e.age?(0,V.jsxs)(`span`,{children:[`saved `,aG(e.age)]}):null]}),(0,V.jsx)(`p`,{className:`cs-ids`,children:e.id})]}),(0,V.jsx)(kG,{planId:e.id})]})}function MG({row:e,onResumed:t}){let[n,r]=(0,m.useState)(!1),i=(0,m.useRef)(!0);(0,m.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]);async function a(){let n=pe();r(!0);try{let r=await L(`tasks.resume`,{taskId:e.id});if(pe()!==n)return;H(r.notice,{action:{label:`View task`,onClick:()=>bE(yE(`tasks`,e.id))}}),t()}catch(e){pe()===n&&H.error(e instanceof Error?e.message:String(e))}finally{i.current&&r(!1)}}let o=e.owner===`not running`;return(0,V.jsx)(UI,{label:o?`Resume: carry it on in a background session`:`Resume: unpause it where it runs`,text:`Resume`,icon:Fm,tone:`primary`,shortcut:`R`,disabled:n,onClick:()=>void a()})}function NG(e){return e instanceof Error?e.message:`That did not work. Try again.`}function PG({run:e,onDone:t}){let[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(``);return{open:n,change:e=>{o||(r(e),a(``),l(``))},typed:i,setTyped:a,busy:o,error:c,submit:async()=>{s(!0),l(``);try{H((await e(i)).notice),r(!1),t()}catch(e){l(NG(e))}finally{s(!1)}}}}function FG({expected:e,value:t,onChange:n,disabled:r}){let i=(0,m.useId)();return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium`,children:`Type the task's title to confirm`}),(0,V.jsx)(`p`,{className:`break-words rounded-md bg-muted px-2 py-1 font-mono text-xs select-all`,children:e}),(0,V.jsx)(xB,{id:i,value:t,disabled:r,autoComplete:`off`,spellCheck:!1,onChange:e=>n(e.target.value)})]})}function IG(e){let t=PG(e),n=lE(t.open,cE.confirm),r=e.typeToConfirm!==void 0&&t.typed!==e.typeToConfirm,i=e.tone??`neutral`;return(0,V.jsxs)(nR,{open:t.open&&n,onOpenChange:t.change,children:[(0,V.jsx)(UI,{label:e.label,icon:e.icon,tone:i,onClick:()=>t.change(!0)}),(0,V.jsxs)(rR,{children:[(0,V.jsxs)(iR,{children:[(0,V.jsx)(oR,{children:e.title}),(0,V.jsx)(sR,{children:e.description})]}),e.typeToConfirm===void 0?null:(0,V.jsx)(FG,{expected:e.typeToConfirm,value:t.typed,onChange:t.setTyped,disabled:t.busy}),t.error?(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:t.error}):null,(0,V.jsxs)(aR,{children:[(0,V.jsx)(lR,{disabled:t.busy,children:`Cancel`}),(0,V.jsx)(WT,{variant:i===`danger`?`destructive`:`default`,disabled:r||t.busy,"aria-busy":t.busy,onClick:()=>void t.submit(),children:t.busy?`Working…`:e.confirmLabel})]})]})]})}function LG({taskId:e,item:t,onDone:n}){let r=n=>()=>L(`tasks.resolveApproval`,{taskId:e,approvalId:t.id,decision:n}),i=`${t.kind}${t.domain?` for ${t.domain}`:``}`;return(0,V.jsxs)(`span`,{className:`flex flex-wrap gap-1.5`,children:[(0,V.jsx)(IG,{label:`Approve`,icon:Yf,title:`Approve the ${i}?`,description:`${t.detail} The task's oracle is told and carries on with it.`,confirmLabel:`Approve`,run:r(`approved`),onDone:n}),(0,V.jsx)(IG,{label:`Reject`,icon:Fh,tone:`danger`,title:`Reject the ${i}?`,description:`${t.detail} The task's oracle is told and works without it.`,confirmLabel:`Reject`,run:r(`rejected`),onDone:n})]})}function RG({taskId:e,item:t,live:n,onDone:r}){return(0,V.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-1 basis-60 gap-2`,children:[(0,V.jsx)(ap,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-[var(--warn)]`}),(0,V.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[t.kind,` `,t.detail]})]}),n&&t.id?(0,V.jsx)(LG,{taskId:e,item:t,onDone:r}):null]})}function zG({blockers:e}){return e.map((e,t)=>(0,V.jsxs)(`li`,{className:`flex gap-2`,children:[(0,V.jsx)(hp,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-[var(--bad)]`}),(0,V.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[e.reason,` (needs: `,e.need,`)`]})]},`${t}-${e.reason}`))}function BG({row:e,detail:t,onChanged:n}){let r=e.id;return(0,V.jsxs)(`div`,{className:`cs-wacts`,children:[e.resumable?(0,V.jsx)(MG,{row:e,onResumed:n}):null,t.canAccept?(0,V.jsx)(IG,{label:`Accept as is`,icon:th,title:`Accept "${e.title}" as is?`,description:`You accept the work unverified: missing QA and lint checks are waived on your word. The task's oracle is asked to complete it; nothing is merged.`,confirmLabel:`Accept as is`,run:()=>L(`tasks.accept`,{taskId:r}),onDone:n}):null,t.canForceClose?(0,V.jsx)(IG,{label:`Force close`,icon:pp,tone:`danger`,title:`Force close "${e.title}"?`,description:`The task is abandoned and its running work cancelled. Its code, worktree and history are kept; it is not marked complete.`,confirmLabel:`Force close`,typeToConfirm:e.title,run:e=>L(`tasks.forceClose`,{taskId:r,title:e}),onDone:n}):null]})}function VG({row:e,detail:t,onChanged:n}){let r=e.kind===`task`&&e.check===`open`,i=r&&!!(e.resumable||t.canAccept||t.canForceClose),a=t.waiting;return a.length===0&&t.blockers.length===0&&!i?null:(0,V.jsx)(GB,{title:`Waiting on`,children:(0,V.jsxs)(`div`,{className:`cs-sunkbox cs-cal`,children:[(0,V.jsxs)(`ul`,{className:`flex flex-col gap-2.5 text-[13px]`,children:[a.map((t,i)=>(0,V.jsx)(RG,{taskId:e.id,item:t,live:r,onDone:n},`${i}-${t.id||t.kind}`)),(0,V.jsx)(zG,{blockers:t.blockers})]}),i?(0,V.jsx)(BG,{row:e,detail:t,onChanged:n}):null]})})}function HG(e){if(e.kind===`archived`)return{state:`archived`,rest:aG(e.age??`now`)};let t=e.check!==`open`,n=e.owner??(e.section===`mine`?`this session`:``),r=t&&e.age?`${e.check===`dropped`?`dropped`:`done`} ${aG(e.age)}`:``;return{state:iG(e.status,e.paused),rest:[t?``:n,r].filter(Boolean).join(` · `)}}function UG(e){return e?[QR(e.track),e.domains.join(`, `)].filter(Boolean).join(` · `):``}function WG({row:e}){return e.progress?(0,V.jsxs)(`p`,{className:`cs-prog`,children:[(0,V.jsx)($R,{done:e.progress.done,total:e.progress.total}),(0,V.jsxs)(`span`,{children:[e.progress.done,` of `,e.progress.total,` steps`]})]}):null}function GG({row:e,task:t}){let n=t?.git?`branch ${t.git.branch}${t.git.from?` · from ${t.git.from}`:``}`:``,{state:r,rest:i}=HG(e),[a,o]=(0,m.useState)(!1),s=(0,m.useId)();return(0,V.jsxs)(`header`,{children:[(0,V.jsxs)(`h2`,{children:[(0,V.jsx)(tz,{check:e.check}),(0,V.jsxs)(`span`,{className:`sr-only`,children:[eG[e.check],`:`]}),(0,V.jsx)(`span`,{className:e.check===`dropped`?`min-w-0 break-words line-through`:`min-w-0 break-words`,children:e.title})]}),(0,V.jsxs)(`p`,{className:`cs-sub`,children:[(0,V.jsx)(`span`,{className:`cs-bdg`,"data-t":e.check===`done`?`ok`:e.timing?.waiting?`warn`:e.check===`open`?`acc`:void 0,children:r}),i?(0,V.jsx)(`span`,{children:i}):null,(0,V.jsx)(`button`,{type:`button`,className:`cs-dtl`,"aria-expanded":a,"aria-controls":s,onClick:()=>o(e=>!e),children:a?`Hide details`:`Details`})]}),a?(0,V.jsx)(`p`,{id:s,className:`cs-ids`,children:[e.id,UG(t),n].filter(Boolean).join(` · `)}):null,(0,V.jsx)(WG,{row:e})]})}function KG({row:e,onGone:t,onChanged:n}){let r=e.id;return{restore:async()=>{await U(`tasks.restore`,{taskId:r},{undo:()=>void U(`tasks.archive`,{taskId:r})})&&t()},archive:async()=>{await U(`tasks.archive`,{taskId:r},{undo:()=>void U(`tasks.restore`,{taskId:r})})&&t()},remove:async()=>{await U(`tasks.delete`,{taskId:r,where:e.kind===`archived`?`archive`:`list`})&&t()},toggleAuto:()=>void U(`tasks.auto`,{taskId:r,on:!e.auto}).then(n)}}function qG({row:e,archive:t}){return e.check===`open`?(0,V.jsx)(uR,{label:`Archive`,icon:Af,shortcut:`E`,title:`Archive "${e.title}"?`,description:`A task still under way is abandoned first, then moved to the archive. Restore brings it back.`,confirmLabel:`Archive`,onConfirm:()=>void t()}):(0,V.jsx)(UI,{label:`Archive`,icon:Af,shortcut:`E`,onClick:()=>void t()})}function JG({on:e,toggle:t}){return tD(`a`,t),(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:(0,V.jsxs)(`label`,{className:`cs-autol`,children:[(0,V.jsx)(zm,{"aria-hidden":`true`,className:`size-3.5`}),(0,V.jsx)(`span`,{children:`Auto`}),(0,V.jsx)(SB,{small:!0,checked:e,onCheckedChange:t,"aria-label":`Auto mode`,"aria-keyshortcuts":`A`}),(0,V.jsx)(QT,{chord:`A`,className:`kbd-hint`})]})}),(0,V.jsx)(VI,{children:`Auto mode: the oracle decides without asking`})]})}function YG(e){return e.row.kind===`plan`?(0,V.jsx)(AG,{row:e.row,onGone:e.onGone}):(0,V.jsx)(XG,{...e})}function XG(e){let{row:t}=e,{restore:n,archive:r,remove:i,toggleAuto:a}=KG(e),o=t.kind===`archived`,s=t.kind===`task`&&t.check===`open`&&!!t.resumable;return(0,V.jsxs)(WI,{children:[t.kind===`task`&&t.check===`open`?(0,V.jsx)(DG,{row:t,quiet:s}):null,o?(0,V.jsx)(UI,{label:`Restore`,icon:Um,shortcut:`R`,onClick:()=>void n()}):null,t.check===`open`&&!o?(0,V.jsx)(JG,{on:!!t.auto,toggle:a}):null,o?null:(0,V.jsx)(qG,{row:t,archive:r}),(0,V.jsx)(uR,{icon:yh,label:o?`Delete for good`:`Delete`,text:`Delete`,shortcut:`Delete`,title:`Delete "${t.title}" for good?`,description:`This cannot be undone.`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:()=>void i()})]})}function ZG(e){let{row:t}=e,n=t.kind===`plan`,r=_R(`tasks.get`,{taskId:t.id},[`tasks`],!n),i=FE(`lobby`).data?.task,a=i?.id===t.id?i:void 0;if(n)return(0,V.jsx)(jG,{row:t});let o=t.check===`open`&&t.kind===`task`,s=r.data?r.data.work:t.work;return(0,V.jsxs)(`article`,{className:`cs-dt flex min-w-0 flex-col`,"aria-label":t.title,children:[(0,V.jsx)(GG,{row:t,task:a}),r.data?(0,V.jsx)(VG,{row:t,detail:r.data,onChanged:()=>{r.reload(),e.onChanged()}}):null,(0,V.jsx)(`p`,{className:`mt-2 text-[12.5px] text-muted-foreground`,children:(0,V.jsx)(MW,{timing:r.data?.timing??t.timing,...s?{work:s}:{},stopped:t.check!==`open`})}),r.data?.delivery?(0,V.jsx)(KW,{taskId:t.id,title:t.title,delivery:r.data.delivery,onChanged:r.reload},t.id):null,r.data?(0,V.jsx)(TG,{detail:r.data,finished:!o,...o&&r.data.canSkip?{skip:{taskId:t.id,onSkipped:()=>{r.reload(),e.onChanged()}}}:{}}):null,(0,V.jsx)(QW,{taskId:t.id,finished:!o,canComment:o}),r.data?(0,V.jsx)(EG,{detail:r.data}):null,r.error&&!r.data?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the plan detail. `,r.error]}):null]})}function QG({row:e}){let t=e.work,n=!!t?.running&&e.check===`open`&&!e.timing?.waiting,r=kW(n,t??{workedMs:0,running:!1});if(!t||e.kind===`plan`)return(0,V.jsx)(`span`,{className:`cs-ttm`});let i=OW(t.workedMs+r);return(0,V.jsx)(`span`,{className:`cs-ttm`,"data-work-clock":n?`running`:`stopped`,children:i.replace(/ \d+s$/,``)})}function $G(e){return e.kind===`archived`?``:e.delivery?`delivery ${e.delivery.status.replaceAll(`_`,` `)}`:e.kind===`plan`||e.check===`open`?`${e.timing?.waiting?`waiting for you · `:``}${oG(e)}${e.auto?` · auto`:``}`:``}function eK(e){return e.check===`dropped`?`drop`:e.kind===`archived`?`arch`:e.check===`done`?`done`:`open`}function tK({row:e,selected:t,onSelect:n,head:r,count:i}){let a=e.kind!==`plan`&&e.progress&&e.progress.total>0?e.progress:void 0;return(0,V.jsxs)(`li`,{children:[r?(0,V.jsxs)(`h3`,{className:`cs-tsec`,children:[$W[e.section],(0,V.jsx)(`b`,{children:i})]}):null,(0,V.jsxs)(`button`,{type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,onClick:()=>n(e.id),className:`cs-trw`,children:[(0,V.jsx)(tz,{check:e.check}),(0,V.jsxs)(`span`,{className:`cs-tt1`,children:[(0,V.jsxs)(`span`,{className:`sr-only`,children:[eG[e.check],`:`]}),(0,V.jsx)(`span`,{className:`cs-t`,"data-k":eK(e),children:e.title}),(0,V.jsx)(`span`,{className:`cs-mt`,"data-w":e.timing?.waiting?`warn`:void 0,children:$G(e)})]}),(0,V.jsx)(`span`,{className:`cs-tpg`,children:a?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($R,{done:a.done,total:a.total}),(0,V.jsxs)(`span`,{children:[a.done,`/`,a.total]})]}):null}),(0,V.jsx)(QG,{row:e}),(0,V.jsx)(`span`,{className:`cs-tag`,children:e.age??``})]})]})}function nK({rows:e,selectedId:t,onSelect:n}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`cs-tbh`,"aria-hidden":`true`,children:[(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{children:`Task`}),(0,V.jsx)(`span`,{children:`Progress`}),(0,V.jsx)(`span`,{children:`Worked`}),(0,V.jsx)(`span`,{children:`Age`})]}),(0,V.jsx)(`ul`,{className:`cs-lst`,children:sG(e).flatMap(({rows:e})=>e.map((r,i)=>(0,V.jsx)(tK,{row:r,head:i===0,count:e.length,selected:r.id===t,onSelect:n},`${r.kind}-${r.id}`)))})]})}var rK=()=>bE(yE(`tasks`)),iK=e=>bE(yE(`tasks`,e));function aK(){return(0,V.jsxs)(EE,{className:`m-4 flex-1`,children:[(0,V.jsxs)(DE,{children:[(0,V.jsx)(kE,{variant:`icon`,children:(0,V.jsx)(rm,{"aria-hidden":`true`})}),(0,V.jsx)(jE,{children:rG})]}),(0,V.jsx)(WT,{onClick:()=>bE(yE(`plan`)),children:`Plan a task`})]})}function oK({id:e}){let[t,n]=(0,m.useState)(!1),r=_R(`tasks.list`,{},[`tasks`,`plans`]),i=_R(`tasks.archived`,{},[`tasks`]),a=r.data?.rows??[],o=i.data?.rows??[],s=t?[...a,...o]:a,c=[...s,...o].find(t=>t.id===e&&t.kind===`task`)?.id;if((0,m.useEffect)(()=>(wW(c),()=>wW(void 0)),[c]),!r.data&&r.error)return(0,V.jsx)(wE,{message:`Could not load tasks. ${r.error}`,onRetry:r.reload});if(r.data&&a.length===0&&o.length===0)return(0,V.jsx)(aK,{});let l=[...s,...o].find(t=>t.id===e),u=l?{row:l,onGone:rK,onChanged:r.reload}:void 0;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(rW,{title:`Tasks`,sub:cG(s),className:`cs-ts`,aside:(0,V.jsx)(iW,{on:t,label:`Archived`,count:o.length,describe:`Show archived tasks`,onToggle:()=>n(e=>!e)}),children:r.data?s.length===0?(0,V.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:rG}):(0,V.jsx)(nK,{rows:s,selectedId:e,onSelect:iK}):(0,V.jsx)(JE,{})}),(0,V.jsx)(rD,{open:!!e,onClose:rK,label:l?.title??`Task`,className:`cs-tdw`,head:u?(0,V.jsx)(YG,{...u},u.row.id):null,children:u?(0,V.jsx)(ZG,{...u},u.row.id):e?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That task is not on the list any more.`}):null})]})}var sK={l:`lobby`,p:`plan`,t:`tasks`,n:`knowledge`,e:`settings`};function cK(e){if(e.kind===`settings`)return(0,V.jsx)(ZH,{});switch(e.tab){case`lobby`:return(0,V.jsx)(Bz,{});case`tasks`:return(0,V.jsx)(oK,{...TR(e.rest)});case`plan`:return(0,V.jsx)(yW,{rest:e.rest});case`knowledge`:return(0,V.jsx)(wR,{rest:e.rest})}}function lK(e,t){return t.overlay?!0:e===`savePlan`&&!t.saveAvailable}var uK={tab:`Tab`,esc:`Escape`,escape:`Escape`,enter:`Enter`,space:`Space`,pageup:`PageUp`,pagedown:`PageDown`,home:`Home`,end:`End`,"`":`Backquote`,"]":`BracketRight`,"[":`BracketLeft`,"/":`Slash`,"?":`Slash`,",":`Comma`,".":`Period`};function dK(e){return e.length===1&&/[a-z]/i.test(e)?`Key${e.toUpperCase()}`:e.length===1&&/[0-9]/.test(e)?`Digit${e}`:uK[e]}function fK(e){let t={alt:!1,ctrl:!1,shift:!1,meta:!1,code:``};for(let n of e.toLowerCase().split(`+`))if(n===`alt`)t.alt=!0;else if(n===`ctrl`||n===`control`)t.ctrl=!0;else if(n===`shift`)t.shift=!0;else if(n===`meta`||n===`cmd`)t.meta=!0;else{let e=dK(n);if(!e)return;t.code=e}return t.code?t:void 0}function pK(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.shiftKey===t.shift&&e.metaKey===t.meta}function mK(e,t){let n=fK(t);return n?pK(e,n):!1}function hK(e,t){for(let n of t)if(mK(e,n.key))return n.action}function gK(e,t){for(let n of t)if(mK(e,n.key))return n.id}function _K(e){return IE(e.target)||e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||uE()||!!document.querySelector(`[role='dialog'], [role='menu'], [role='listbox']`)}function vK(e,t,n,r){let i=!e.shiftKey&&/^[1-9]$/.test(e.key)?t[Number(e.key)-1]:void 0;if(i)r(i.id);else if(e.key===`/`)n(`search`);else if(e.key===`?`)n(`help`);else if(e.key===`j`||e.key===`k`)VE(e.key===`j`?1:-1);else return!1;return!0}function yK(e,t){let n=gK(e,t.tabs),r=hK(e,t.keys);return!n&&!r?!1:lK(r,{overlay:!!document.querySelector(`[role='dialog']:not([data-state='closed']), [role='menu']:not([data-state='closed']), [role='listbox']`)||uE(),typing:IE(e.target)||e.target instanceof HTMLInputElement,saveAvailable:!!document.querySelector(`[data-plan-save]:not([disabled])`)})||(r===`search`||r===`savePlan`)&&!t.insideApp()?!0:(e.preventDefault(),n?t.onTab(n):r&&t.onAction(r),!0)}function bK(e,t,n){if(e.key===`Escape`)return Date.now()<n&&e.preventDefault(),0;if(Date.now()<n){let n=sK[e.key];return n&&(e.preventDefault(),t.onTab(n)),0}return e.key===`g`?Date.now()+1500:(vK(e,t.tabs,t.onAction,t.onTab)&&e.preventDefault(),0)}function xK(e){(0,m.useEffect)(()=>{if(!e.enabled)return;let t=0,n=n=>{if(n.defaultPrevented||n.isComposing)return;if(n.target instanceof Element&&n.target.closest(`.xterm`)){hK(n,e.keys)===`terminal`&&(n.preventDefault(),e.onAction(`terminal`));return}if(!e.insideApp()){hK(n,e.keys)===`help`&&(n.preventDefault(),e.onAction(`help`));return}let r=!n.altKey&&!n.ctrlKey&&!n.metaKey;if(r&&_K(n)){t=0;return}if(yK(n,e)){t=0;return}t=r?bK(n,e,t):0};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e.enabled,e.keys,e.tabs,e.insideApp,e.onAction,e.onTab])}var SK=[{id:`focus`,caps:[`/`],help:`focus search, or the message box`},{id:`send`,label:`Enter`,help:`send the message`},{id:`newline`,label:`Shift+Enter`,help:`a new line (lists carry on)`},{id:`format`,label:`Ctrl+B`,help:`bold; Ctrl+I italic, Ctrl+E code, Ctrl+K link`},{id:`leave`,label:`Esc`,help:`leave the box for the tab bar`}],CK=[{id:`digits`,caps:[`1`,`…`,`9`],help:`jump to a tab in current order`},{id:`help`,caps:[`?`],help:`keyboard shortcuts`},...Object.entries(sK).map(([e,t])=>({id:`go.${t}`,caps:[`g`,e],help:`jump to ${t}`})),{id:`project`,caps:[`P`],help:`open the project switcher`},{id:`theme`,caps:[`D`],help:`switch between light and dark`},{id:`edit`,label:`Ctrl+Enter`,help:`save an edited message; Esc cancels`}],wK=[{id:`tasks`,page:`Tasks`,keys:[[`E`,`archive`],[`R`,`restore`],[`A`,`auto mode`],[`Delete`,`delete`]]},{id:`saved`,page:`Saved plan`,keys:[[`S`,`start here`],[`N`,`new session`],[`Delete`,`discard`]]},{id:`plan`,page:`Plan`,keys:[[`A`,`answer`],[`R`,`retry`],[`Ctrl+S`,`save`],[`N`,`new plan`]]},{id:`knowledge`,page:`Knowledge`,keys:[[`E`,`edit`],[`A`,`add`],[`C`,`comment`],[`F`,`edit file`],[`Delete`,`delete`]]},{id:`confirm`,page:`Asked to confirm`,keys:[[`Y`,`yes, do it`],[`Esc`,`keep it`]]}],TK=[{id:`enter`,caps:[`↓`],help:`from the tab bar, into the page`},{id:`rows`,caps:[`↑`,`↓`],help:`move through a list (j and k work too)`},{id:`pane`,caps:[`←`,`→`],help:`between a list and its detail (h and l)`},{id:`ends`,caps:[`Home`,`End`],help:`first and last row`},{id:`open`,caps:[`Enter`,`Space`],help:`activate the focused button or row (links: Enter; checkboxes: Space)`},{id:`back`,label:`Esc`,help:`back up to the tab bar`}],EK=[{id:`qmove`,caps:[`↑`,`↓`],help:`move between the options`},{id:`qpick`,label:`Space`,help:`pick an option (several when allowed)`},{id:`qchoose`,label:`Enter`,help:`choose and go on; in your own answer, send it`},{id:`qacross`,caps:[`←`,`→`],help:`previous and next question`},{id:`qdigit`,caps:[`1`,`2`,`…`],help:`pick that option`},{id:`qesc`,label:`Esc`,help:`put the question away for later`}];function DK({line:e}){return(0,V.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,V.jsx)(`span`,{className:`flex w-28 shrink-0 items-center`,children:e.caps?(0,V.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:e.caps.map(e=>(0,V.jsx)(KT,{children:e},e))}):(0,V.jsx)(QT,{chord:e.label??``})}),(0,V.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.help})]})}function OK(){return(0,V.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,V.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:`Buttons on a page`}),wK.map(e=>(0,V.jsxs)(`div`,{className:`flex items-start gap-3 py-1`,children:[(0,V.jsx)(`span`,{className:`w-28 shrink-0 pt-0.5 text-sm font-medium`,children:e.page}),(0,V.jsx)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5 text-sm text-muted-foreground`,children:e.keys.map(([e,t])=>(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,V.jsx)(QT,{chord:e}),t]},e))})]},e.id))]})}function kK({title:e,lines:t}){return(0,V.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,V.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:e}),t.map(e=>(0,V.jsx)(DK,{line:e},e.id))]})}function AK(e){return e.map(e=>({id:e.action,label:e.label,help:e.help}))}function jK(e){return e.map(e=>({id:`tab.${e.id}`,label:e.key,help:`jump to the ${e.label} tab`}))}function MK({open:e,onOpenChange:t,keys:n,tabs:r}){let i=e,a=lE(i,cE.help),o=(0,m.useRef)(null);return(0,m.useEffect)(()=>{if(!i||!a)return;let e=e=>{let r=n.find(e=>e.action===`help`)?.key;(e.key===`Escape`||r&&mK(e,r))&&(e.preventDefault(),t(!1))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n,t,a,i]),(0,V.jsxs)(tE,{open:i&&a,onOpenChange:t,label:`Keys`,className:`max-w-4xl`,children:[(0,V.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-border px-4 py-3`,children:[(0,V.jsx)(`h2`,{"aria-hidden":`true`,className:`text-base font-semibold tracking-tight`,children:`Keyboard shortcuts`}),(0,V.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(QT,{chord:`Esc`}),(0,V.jsx)(WT,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,onClick:()=>t(!1),children:(0,V.jsx)(Fh,{"aria-hidden":`true`})})]})]}),(0,V.jsxs)(`div`,{ref:o,className:`grid min-h-0 flex-1 grid-cols-2 gap-x-10 gap-y-6 overflow-y-auto p-4`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,V.jsx)(kK,{title:`Everywhere`,lines:AK(n)}),(0,V.jsx)(kK,{title:`Jump to a tab`,lines:jK(r)}),(0,V.jsx)(kK,{title:`Navigation and editing`,lines:CK}),(0,V.jsx)(kK,{title:`Message box`,lines:SK})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,V.jsx)(kK,{title:`Lists and panes`,lines:TK}),(0,V.jsx)(OK,{}),(0,V.jsx)(kK,{title:`Questions`,lines:EK})]})]}),(0,V.jsx)(m_,{target:o})]})}var NK=`size-[1.05rem]`;function PK({hint:e,onHelp:t,className:n,side:r=`top`}){return(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Keyboard shortcuts`,"aria-haspopup":`dialog`,"aria-keyshortcuts":e,"aria-describedby":`focused-action-help`,onClick:t,className:n,children:(0,V.jsx)($p,{"aria-hidden":`true`,className:NK})})}),(0,V.jsxs)(VI,{side:r,children:[`Keyboard shortcuts `,(0,V.jsx)(QT,{chord:e})]})]})}function FK({className:e,side:t=`top`}){let n=Qz(),r=n?`Unmute prompt sounds`:`Mute prompt sounds`;return(0,V.jsx)(V.Fragment,{children:(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":r,"aria-pressed":n,"aria-describedby":`focused-action-help`,className:e,onClick:()=>Xz(!n),children:n?(0,V.jsx)(kh,{"aria-hidden":`true`,className:NK}):(0,V.jsx)(Dh,{"aria-hidden":`true`,className:NK})})}),(0,V.jsx)(VI,{side:t,children:r})]})})}function IK({className:e,side:t=`top`}){let{theme:n,setTheme:r}=eV(),i=n===`dark`||n===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;return(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":i?`Switch to light mode`:`Switch to dark mode`,"aria-keyshortcuts":`D`,"aria-describedby":`focused-action-help`,onClick:()=>r(i?`light`:`dark`),className:e,children:i?(0,V.jsx)(dh,{"aria-hidden":`true`,className:NK}):(0,V.jsx)(xm,{"aria-hidden":`true`,className:NK})})}),(0,V.jsxs)(VI,{side:t,children:[i?`Light mode`:`Dark mode`,` `,(0,V.jsx)(QT,{chord:`D`})]})]})}var LK=[{id:`light`,label:`Light`},{id:`dark`,label:`Dark`},{id:`system`,label:`System`}];function RK({className:e,side:t=`top`}){let{theme:n,setTheme:r}=eV();return(0,V.jsxs)(wB,{children:[(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:(0,V.jsx)(TB,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Appearance`,className:e,children:(0,V.jsx)(Cm,{"aria-hidden":`true`,className:NK})})})}),(0,V.jsx)(VI,{side:t,children:`Appearance`})]}),(0,V.jsxs)(EB,{side:t===`right`?`right`:`top`,align:t===`right`?`start`:`center`,sideOffset:10,collisionPadding:12,"aria-label":`Appearance`,onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.focus({preventScroll:!0})},tabIndex:-1,className:`glass-pop flex max-h-[85svh] w-[26rem] max-w-[calc(100vw-1.5rem)] flex-col gap-3 overflow-y-auto rounded-2xl p-3`,children:[(0,V.jsx)(ME,{label:`Mode`,items:LK,value:n,onChange:e=>r(e),className:`w-full [&>button]:flex-1`}),(0,V.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,V.jsx)(`p`,{className:`px-0.5 text-xs font-medium text-muted-foreground`,children:`Colour theme`}),(0,V.jsx)(`div`,{className:`[&_[role=radiogroup]]:!grid-cols-3 [&_[role=radiogroup]]:gap-1.5`,children:(0,V.jsx)(RV,{})})]}),(0,V.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,V.jsx)(`p`,{className:`px-0.5 text-xs font-medium text-muted-foreground`,children:`Typeface`}),(0,V.jsx)(tV,{kind:`font`,dense:!0})]}),(0,V.jsx)(`a`,{href:`#/settings`,className:`px-0.5 text-xs text-link underline-offset-2 hover:underline`,children:`More in Settings`})]})]})}function zK({className:e,side:t=`top`}){let n=cB(),r=n?`Turn off desktop notifications`:`Turn on desktop notifications`,i=async()=>{if(n)return uB();let e=await lB();e===`granted`?H.success(`Desktop notifications are on.`):H.error(e===`unsupported`?`This browser cannot show notifications.`:`Notifications are blocked for this page in the browser's settings.`)};return(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":r,"aria-pressed":n,className:e,onClick:()=>void i(),children:n?(0,V.jsx)(Hf,{"aria-hidden":`true`,className:NK}):(0,V.jsx)(Bf,{"aria-hidden":`true`,className:NK})})}),(0,V.jsx)(VI,{side:t,children:r})]})}function BK({className:e,side:t=`top`}){let n=x();if(!n.supported)return null;let r=n.on?`Leave full screen`:`Full screen`;return(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":r,"aria-pressed":n.on,className:e,onClick:()=>void n.toggle(),children:n.on?(0,V.jsx)(ym,{"aria-hidden":`true`,className:NK}):(0,V.jsx)(lm,{"aria-hidden":`true`,className:NK})})}),(0,V.jsx)(VI,{side:t,children:r})]})}function VK(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}async function HK(e){if(e.size===0)throw Error(`${e.name||`That file`} is empty.`);if(e.size>20971520)throw Error(`${e.name||`That file`} is larger than 20 MB.`);let t=new URLSearchParams({name:e.name||`pasted-file`,type:e.type}),n=await fetch(F(`/api/files.upload?${t}`),{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:e,credentials:`same-origin`}),r=await n.json().catch(()=>void 0);if(!r)throw new xe(`the lobby answered ${n.status}`,`failed`,n.status);if(!r.ok)throw new xe(r.error,r.code,n.status);return r.result}function UK(e,t,n,r){let i=e.slice(0,t),a=e.slice(t,n),o=e.slice(n);if(a.length>=r.length*2&&a.startsWith(r)&&a.endsWith(r)){let e=a.slice(r.length,a.length-r.length);return{value:i+e+o,start:t,end:t+e.length}}return i.endsWith(r)&&o.startsWith(r)?{value:i.slice(0,i.length-r.length)+a+o.slice(r.length),start:t-r.length,end:n-r.length}:{value:i+r+a+r+o,start:t+r.length,end:n+r.length}}function WK(e,t,n){let r=e.slice(t,n)||`text`,i=`[${r}](url)`,a=t+r.length+3;return{value:e.slice(0,t)+i+e.slice(n),start:a,end:a+3}}var GK=/^(\s*)(?:([-*+])|(\d+)([.)]))\s+(\[[ xX]\]\s+)?/;function KK(e,t){let n=e.lastIndexOf(`
|
|
97
|
+
.dark { … }`,className:`max-h-56 font-mono text-xs`}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(`input`,{ref:l,type:`file`,accept:`.css,.json,text/css,application/json`,hidden:!0,tabIndex:-1,"aria-label":`Upload a theme file`,onChange:e=>{d(e.target.files?.[0]),e.target.value=``}}),(0,V.jsx)(UI,{label:`Save and apply the pasted theme`,text:`Save theme`,icon:Yf,tone:`primary`,disabled:!t.trim()||s,onClick:()=>void u(t,`Custom theme`)}),(0,V.jsx)(UI,{label:`Upload a .css or .json theme file`,text:`Upload file`,icon:Th,disabled:s,onClick:()=>l.current?.click()}),a?(0,V.jsx)(`p`,{role:`alert`,className:`ml-2 min-w-0 text-xs text-destructive`,children:a}):null]})]})}function HV(){let{theme:e,setTheme:t}=eV(),n=Qz();return(0,V.jsx)(GB,{prominent:!0,title:fV.appearance,children:(0,V.jsxs)(RB,{children:[(0,V.jsx)(LB,{label:`Prompt sounds`,help:`A droplet for each new actionable prompt or delivery review. Kept in this browser; sound starts after interaction. Desktop notifications remain separate.`,children:(0,V.jsx)(SB,{checked:!n,onCheckedChange:e=>Xz(!e),"aria-label":`Prompt sounds`})}),(0,V.jsx)(LB,{label:NV.themeLabel,help:NV.appearanceHelp,children:(0,V.jsx)(zB,{value:e,items:NV.themeItems.map(e=>({value:e.id,label:e.label})),label:NV.themeLabel,onChange:e=>t(e)})}),(0,V.jsx)(LB,{label:`Colour theme`,help:`The page's colours, the same in every pi session.`,stacked:!0,children:(0,V.jsx)(RV,{})}),(0,V.jsx)(LB,{label:`Typeface`,help:`The face for the page's text, kept in this browser.`,stacked:!0,children:(0,V.jsx)(tV,{kind:`font`})}),(0,V.jsx)(LB,{label:`Code typeface`,help:`The face for code, paths and commands.`,stacked:!0,children:(0,V.jsx)(tV,{kind:`mono`})}),(0,V.jsx)(LB,{label:`Saved themes`,help:`Themes you imported, kept with pi for every session and project.`,stacked:!0,children:(0,V.jsx)(BV,{})}),(0,V.jsx)(LB,{label:`Import a theme`,stacked:!0,children:(0,V.jsx)(VV,{})})]})})}function UV({className:e,...t}){return(0,V.jsx)(Ox,{"aria-keyshortcuts":`Space`,"aria-description":`When focused, press Space to toggle.`,"data-slot":`checkbox`,className:Y(`cs-cb`,e),...t,children:(0,V.jsx)(Ax,{forceMount:!0,"data-slot":`checkbox-indicator`,className:`contents`,children:(0,V.jsx)(Yf,{"aria-hidden":`true`,strokeWidth:3.4})})})}var WV=`flex min-h-10 w-full flex-col gap-1 rounded-lg border border-transparent px-3 py-2.5 text-left outline-none transition-colors duration-150 hover:bg-accent/60 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-accent`,GV={master:[`master`],designer:[`agents`,`designer`],backend:[`agents`,`backend`],qa:[`agents`,`qa`],scout:[`scout`],researcher:[`researcher`],planner:[`planner`]};function KV(e,t){let n=GV[t].reduce((e,t)=>e[t],e);return{...n.mcpTools?{mcpTools:n.mcpTools}:{},...n.skills?{skills:n.skills}:{}}}function qV(e,t){return GV[e].reduceRight((e,t)=>({[t]:e}),t)}function JV(e,t){let n=e.mcpTools?e.mcpTools.length===0?Q.noTools:`${e.mcpTools.length} MCP tool${e.mcpTools.length===1?``:`s`}`:Q.allTools;return t===`master`?n:`${n} · ${e.skills?e.skills.length===0?Q.noSkills:`${e.skills.length} skill${e.skills.length===1?``:`s`}`:Q.allSkills}`}var YV=/^mcp__[A-Za-z0-9_]+__[A-Za-z0-9_]+$/;function XV(e,t){let n=`mcp__${t}__`;return e.startsWith(n)?e.slice(n.length):e}function ZV(e){return/^mcp__([A-Za-z0-9_]+?)__/.exec(e)?.[1]??``}function QV({config:e,save:t,agent:n,onAgent:r}){let i=_R(`settings.grants`,{},[]),a=i.data;return(0,V.jsxs)(GB,{prominent:!0,title:fV.grants,children:[(0,V.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:Q.intro}),(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,13rem)_minmax(0,1fr)] items-start gap-4`,children:[(0,V.jsx)(`nav`,{"aria-label":Q.agents,className:`flex flex-col gap-0.5`,children:nV.map(t=>(0,V.jsxs)(`button`,{type:`button`,"aria-current":t===n,onClick:()=>r(t),className:Y(WV,`min-h-0 gap-0.5 py-2`),children:[(0,V.jsxs)(`span`,{className:`flex items-center gap-2 text-[0.8125rem] font-medium`,children:[(0,V.jsx)(IR,{source:t,className:`size-4 shrink-0 text-muted-foreground`}),rV[t]]}),(0,V.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:JV(KV(e,t),t)})]},t))}),(0,V.jsxs)(PB,{dense:!0,"aria-label":`${rV[n]} ${Q.cardLabel}`,children:[(0,V.jsx)(tH,{kind:n,grants:KV(e,n),offered:a?.mcpTools,error:i.error,save:t},`tools-${n}`),(0,V.jsx)(nH,{kind:n,grants:KV(e,n),offered:a?.skills,error:i.error,save:t},`skills-${n}`)]})]})]})}function $V({title:e,note:t}){return(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline justify-between gap-x-3 gap-y-1`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-semibold`,children:e}),(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t})]})}function eH({id:e,name:t,help:n,tag:r,tagTone:i,checked:a,disabled:o,title:s,onChange:c}){return(0,V.jsxs)(`label`,{htmlFor:e,title:s,className:Y(`flex min-w-0 cursor-pointer items-start gap-3 rounded-lg px-2 py-1.5 transition-colors hover:bg-accent/60`,o&&`cursor-not-allowed opacity-60 hover:bg-transparent`),children:[(0,V.jsx)(UV,{id:e,checked:a,disabled:o,onCheckedChange:e=>c(e===!0),className:`mt-0.5`}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,V.jsx)(`span`,{className:`break-all font-mono text-[0.8125rem]`,children:t}),n?(0,V.jsx)(`span`,{className:`break-words text-xs text-muted-foreground`,children:n}):null]}),r?(0,V.jsx)(`span`,{className:Y(`shrink-0 rounded-md px-1.5 py-0.5 text-[0.6875rem] font-medium`,i===`warning`?`bg-warning/12 text-warning`:`bg-accent text-muted-foreground`),children:r}):null]})}function tH({kind:e,grants:t,offered:n,error:r,save:i}){let[a,o]=(0,m.useState)(``),[s,c]=(0,m.useState)(``),l=!t.mcpTools,u=t.mcpTools??[],d=new Set(u),f=pV.has(e),p=t=>i(qV(e,{mcpTools:t?[...new Set(t)]:null})),h=(e,t)=>void p(t?[...u,...e]:u.filter(t=>!e.includes(t))),g=new Set((n??[]).map(e=>e.name)),_=u.filter(e=>!g.has(e)).map(e=>({name:e,server:ZV(e),description:``,readOnly:!1})),v=a.trim().toLowerCase(),y=[...n??[],..._].filter(e=>!v||e.name.toLowerCase().includes(v)||e.description.toLowerCase().includes(v)),b=[...new Set(y.map(e=>e.server))],x=e=>!f||e.readOnly||!g.has(e.name),S=e=>void p(e?null:(n??[]).filter(x).map(e=>e.name)),C=()=>{let e=s.trim();if(!YV.test(e)){H.error(Q.badName);return}c(``),d.has(e)||p([...u,e])};return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(IB,{className:`gap-1 border-b border-(--frame-panel-border-color) py-2.5`,children:[(0,V.jsx)($V,{title:Q.tools,note:l?Q.allTools:`${u.length} granted`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f?Q.readOnlyHelp:e===`qa`?Q.qaHelp:Q.toolsHelp})]}),(0,V.jsxs)(FB,{fit:!0,className:`flex flex-col gap-3 py-3`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-4 px-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:Q.everyTool}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f?Q.everyToolReadOnlyHelp:Q.everyToolHelp})]}),(0,V.jsx)(SB,{checked:l,onCheckedChange:S,"aria-label":`${rV[e]} ${Q.everyTool.toLowerCase()}`})]}),(n?.length??0)>8?(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)($m,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,V.jsx)(xB,{value:a,placeholder:Q.filter,"aria-label":Q.filter,className:`pl-8`,onChange:e=>o(e.target.value)})]}):null,!n&&!r?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Q.looking}):null,r&&!n?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r}):null,n&&n.length===0&&_.length===0?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[Q.noServers,` `,(0,V.jsx)(`code`,{className:`rounded bg-accent px-1 py-0.5 font-mono text-xs`,children:`pi mcp add <name> -- <command>`})]}):null,b.map(t=>{let n=y.filter(e=>e.server===t),r=n.filter(x).map(e=>e.name),i=l?r.length:r.filter(e=>d.has(e)).length;return(0,V.jsxs)(`div`,{role:`group`,"aria-label":`${t} tools`,className:Y(`flex flex-col gap-0.5`,l&&`opacity-60`),children:[(0,V.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1 text-xs font-medium text-muted-foreground`,children:[(0,V.jsx)(UV,{checked:i===0?!1:i===r.length||`indeterminate`,disabled:l||r.length===0,"aria-label":`Every ${t} tool`,onCheckedChange:e=>h(r,e===!0)}),(0,V.jsx)(`span`,{className:`font-mono`,children:t||Q.unknownServer}),(0,V.jsxs)(`span`,{children:[i,` of `,n.length]})]}),n.map(t=>{let n=g.has(t.name),r=!x(t);return(0,V.jsx)(eH,{id:`grant-${e}-${t.name}`,name:XV(t.name,t.server),help:n?t.description||void 0:Q.notConnectedHelp,tag:n?t.readOnly?Q.readOnly:Q.writes:Q.notConnected,tagTone:n?`muted`:`warning`,checked:l?!r:d.has(t.name),disabled:l||r&&!d.has(t.name),...r?{title:Q.blockedHelp}:{},onChange:e=>h([t.name],e)},t.name)})]},t)}),!l&&u.length===0?(0,V.jsxs)(`p`,{className:`flex items-center gap-1.5 px-2 text-xs text-warning`,children:[(0,V.jsx)(ap,{"aria-hidden":`true`,className:`size-3.5`}),Q.noToolsWarning]}):null,(0,V.jsxs)(`div`,{hidden:l,className:`flex min-w-0 items-center gap-2 border-t border-(--frame-panel-border-color) pt-3`,children:[(0,V.jsx)(xB,{value:s,placeholder:`mcp__server__tool`,"aria-label":Q.addLabel,className:`min-w-0 flex-1 font-mono`,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),C())}}),(0,V.jsx)(UI,{label:Q.add,icon:Lm,onClick:C})]})]})]})}function nH({kind:e,grants:t,offered:n,error:r,save:i}){if(e===`master`)return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(IB,{className:`gap-1 border-y border-(--frame-panel-border-color) py-2.5`,children:(0,V.jsx)($V,{title:Q.skills,note:Q.sessionSkills})}),(0,V.jsx)(FB,{fit:!0,className:`py-3`,children:(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Q.masterSkills})})]});let a=!t.skills,o=new Set(t.skills??[]),s=t=>i(qV(e,{skills:t?[...new Set(t)]:null})),c=new Set((n??[]).map(e=>e.name)),l=(t.skills??[]).filter(e=>!c.has(e));return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(IB,{className:`gap-1 border-y border-(--frame-panel-border-color) py-2.5`,children:[(0,V.jsx)($V,{title:Q.skills,note:a?Q.allSkills:`${o.size} granted`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Q.skillsHelp})]}),(0,V.jsxs)(FB,{fit:!0,className:`flex flex-col gap-3 py-3`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-4 px-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:Q.everySkill}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Q.everySkillHelp})]}),(0,V.jsx)(SB,{checked:a,onCheckedChange:e=>void s(e?null:(n??[]).map(e=>e.name)),"aria-label":`${rV[e]} ${Q.everySkill.toLowerCase()}`})]}),!n&&!r?(0,V.jsx)(`p`,{className:`px-2 text-sm text-muted-foreground`,children:Q.looking}):null,r&&!n?(0,V.jsx)(`p`,{className:`px-2 text-sm text-muted-foreground`,children:r}):null,n&&n.length===0&&l.length===0?(0,V.jsx)(`p`,{className:`px-2 text-sm text-muted-foreground`,children:Q.noSkillsFound}):null,(0,V.jsxs)(`div`,{role:`group`,"aria-label":`${rV[e]} skills`,className:Y(`flex flex-col gap-0.5`,a&&`opacity-60`),children:[(n??[]).map(t=>(0,V.jsx)(eH,{id:`skill-${e}-${t.name}`,name:t.name,help:t.description,checked:a||o.has(t.name),disabled:a,title:t.path,onChange:e=>void s(e?[...o,t.name]:[...o].filter(e=>e!==t.name))},t.name)),l.map(t=>(0,V.jsx)(eH,{id:`skill-${e}-${t}`,name:t,help:Q.skillMissingHelp,tag:Q.notFound,tagTone:`warning`,checked:!0,onChange:()=>void s([...o].filter(e=>e!==t))},t))]}),!a&&o.size===0?(0,V.jsxs)(`p`,{className:`flex items-center gap-1.5 px-2 text-xs text-warning`,children:[(0,V.jsx)(ap,{"aria-hidden":`true`,className:`size-3.5`}),Q.noneWarning]}):null]})]})}function rH(e){let t=[[`designer`,e.agents.designer],[`backend`,e.agents.backend],[`qa`,e.agents.qa],[`scout`,e.scout],[`researcher`,e.researcher]],n={};for(let[e,r]of t)r.harness&&PV.has(e)&&(n[r.harness]??=[]).push(e);return n}function iH({value:e,label:t,placeholder:n,onSave:r}){let[i,a]=(0,m.useState)(e);(0,m.useEffect)(()=>a(e),[e]);let o=()=>{let t=i.trim();t!==e&&r(t)};return(0,V.jsx)(xB,{value:i,placeholder:n,"aria-label":t,spellCheck:!1,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())}})}function aH({value:e,label:t,onSave:n}){let r=e>0?String(e):``,[i,a]=(0,m.useState)(r);(0,m.useEffect)(()=>a(r),[r]);let o=()=>{let e=i.trim().replace(/[,_\s]/g,``);if(e===r)return;if(e===``)return n(0);let t=Number(e);if(!Number.isFinite(t)||t<1e4||t>2e6){H.error(`"${i}" is not between 10,000 and 2,000,000 tokens.`),a(r);return}n(Math.round(t))};return(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(xB,{type:`number`,inputMode:`numeric`,min:1e4,max:2e6,step:1e4,value:i,placeholder:`harness default`,"aria-label":t,className:`pr-14`,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())}}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 right-2.5 flex items-center text-xs text-muted-foreground`,children:`tokens`})]})}function oH({status:e}){let t=!!e.path;return(0,V.jsxs)(`span`,{title:e.path??`${e.command||`No command`} is not on PATH`,className:Y(`inline-flex shrink-0 items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium`,t?`bg-success/8 text-success dark:bg-success/16`:`bg-warning/8 text-warning dark:bg-warning/16`),children:[t?(0,V.jsx)(sp,{"aria-hidden":`true`,className:`size-3.5`}):(0,V.jsx)(ap,{"aria-hidden":`true`,className:`size-3.5`}),t?`${$.installed}${e.version?` · ${e.version}`:``}`:$.notFound]})}function sH({status:e,config:t,users:n,save:r}){let i=e.id,a=t.harnesses[i],o=e=>void r({harnesses:{[i]:e}}),s=e.protocol===`acp`,c=i===`codex`?`CODEX_HOME`:i===`claude`?`CLAUDE_CONFIG_DIR`:void 0,l=e.providers.some(e=>e.value===a.modelProvider)||!a.modelProvider?e.providers:[...e.providers,{value:a.modelProvider,label:a.modelProvider}];return(0,V.jsxs)(`section`,{"data-slot":`harness-card`,"aria-label":e.label,className:`glass flex min-w-0 flex-col gap-3 rounded-xl border px-3.5 pt-3 pb-3.5`,children:[(0,V.jsxs)(`header`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,V.jsx)(`h3`,{className:`min-w-0 break-words text-sm font-semibold`,children:e.label}),(0,V.jsx)(oH,{status:e})]}),(0,V.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:e.blurb}),(0,V.jsxs)(`p`,{className:`break-words text-xs`,children:[(0,V.jsxs)(`span`,{className:`text-muted-foreground`,children:[$.usedBy,`: `]}),n.length>0?n.map(e=>rV[e]).join(`, `):(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:$.unused.toLowerCase()})]})]}),(0,V.jsxs)(`div`,{className:`flex flex-col divide-y divide-border border-t border-border [&>*]:py-2.5 [&>*:last-child]:pb-0`,children:[(0,V.jsx)(LB,{stacked:!0,label:$.binary,help:$.binaryHelp,children:(0,V.jsx)(iH,{value:a.binaryPath,label:`${e.label} ${$.binary.toLowerCase()}`,placeholder:e.command||`/path/to/agent`,onSave:e=>o({binaryPath:e})})}),(0,V.jsx)(LB,{stacked:!0,label:$.args,help:i===`acp`?$.argsAcpHelp:$.argsHelp,children:(0,V.jsx)(iH,{value:a.launchArgs,label:`${e.label} ${$.args.toLowerCase()}`,placeholder:i===`acp`?`--acp`:`none`,onSave:e=>o({launchArgs:e})})}),c?(0,V.jsx)(LB,{stacked:!0,label:$.home,help:$.homeHelp(c),children:(0,V.jsx)(iH,{value:a.homePath,label:`${e.label} ${$.home.toLowerCase()}`,placeholder:i===`codex`?`~/.codex`:`~/.claude`,onSave:e=>o({homePath:e})})}):null,l.length>0?(0,V.jsx)(LB,{stacked:!0,label:$.provider,help:$.providerHelp,children:(0,V.jsx)(zB,{value:a.modelProvider,items:l.map(e=>({value:e.value,label:e.label})),label:`${e.label} ${$.provider.toLowerCase()}`,onChange:e=>o({modelProvider:e})})}):null,s?null:(0,V.jsx)(LB,{stacked:!0,label:$.compact,help:$.compactHelp,children:(0,V.jsx)(aH,{value:a.compactAt,label:`${e.label} ${$.compact.toLowerCase()}`,onSave:e=>o({compactAt:e})})}),i===`antigravity`?(0,V.jsx)(LB,{stacked:!0,label:$.harnessPath,help:$.harnessPathHelp,children:(0,V.jsx)(iH,{value:a.harnessPath,label:`${e.label} ${$.harnessPath.toLowerCase()}`,placeholder:`localharness_external`,onSave:e=>o({harnessPath:e})})}):null,(0,V.jsx)(LB,{stacked:!0,label:$.custom,help:$.customHelp,children:(0,V.jsx)(iH,{value:a.customModels.join(` `),label:`${e.label} ${$.custom.toLowerCase()}`,placeholder:i===`opencode`?`anthropic/claude-sonnet-5-5`:`model-id`,onSave:e=>o({customModels:e.split(/[\s,]+/).filter(Boolean)})})}),(0,V.jsxs)(`div`,{className:`flex min-h-0 items-center justify-between gap-4`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:$.inject}),(0,V.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:$.injectHelp})]}),(0,V.jsx)(SB,{checked:a.injectPrompts,onCheckedChange:e=>o({injectPrompts:e}),"aria-label":`${e.label}: ${$.inject}`})]})]})]})}function cH({config:e,statuses:t,error:n,save:r}){let i=rH(e);return(0,V.jsxs)(GB,{prominent:!0,title:fV.harnesses,children:[(0,V.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:$.intro}),t?(0,V.jsx)(`div`,{className:`grid grid-cols-2 items-start gap-3 xl:grid-cols-3`,children:t.map(t=>(0,V.jsx)(sH,{status:t,config:e,users:i[t.id]??[],save:r},t.id))}):(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n??`Looking for installed harnesses…`})]})}var lH={master:[`master`],designer:[`agents`,`designer`],backend:[`agents`,`backend`],qa:[`agents`,`qa`],scout:[`scout`],researcher:[`researcher`],planner:[`planner`]},uH=[...hV,..._V.map(e=>({id:`panel:${e.id}`,label:e.label,help:vV}))];function dH(e,t){switch(t){case`master`:return e.master;case`scout`:return{model:e.scout.model,thinking:`low`,mcpTools:e.scout.mcpTools,...e.scout.skills?{skills:e.scout.skills}:{},...e.scout.autoCompact===!1?{autoCompact:!1}:{},...e.scout.compactAt?{compactAt:e.scout.compactAt}:{},...e.scout.harness?{harness:e.scout.harness}:{},...e.scout.harnessModel?{harnessModel:e.scout.harnessModel}:{}};case`researcher`:return e.researcher;case`planner`:return e.planner;default:return e.agents[t]}}function fH(e,t){return lH[e].reduceRight((e,t)=>({[t]:e}),t)}function pH(e,t){return e.find(e=>e.id===t)?.thinkingLevels??dV}function mH(e,t){return dV[BB(dV,e,Math.max(0,dV.indexOf(t)))]??t}var hH=e=>e>0?`${e} round${e===1?``:`s`}`:`unlimited`;function gH(e){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)(``),a=e.models.some(t=>t.id===e.value),o=[...e.inherit?[{value:iV,label:aV,help:oV}]:[],...e.none?[{value:iV,label:`none`,help:`Use the primary model`}]:[],...!e.inherit&&!e.none&&e.value===`inherit`?[{value:iV,label:aV,help:oV}]:[],...e.models.map(e=>({value:e.id,label:e.id,...e.label&&e.label!==e.id?{help:e.label}:{}})),...!a&&e.value!==`inherit`?[{value:e.value,label:e.value,help:lV}]:[],{value:sV,label:cV,help:lV}],s=t=>{if(t!==`__custom__`)return e.onChange(t);i(a?``:e.value),n(!0)},c=()=>{let t=r.trim();n(!1),t&&t!==e.value&&e.onChange(t)};return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsx)(zB,{value:e.value,items:o,label:e.label,onChange:s}),t?(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,V.jsx)(xB,{autoFocus:!0,value:r,placeholder:`provider/model`,"aria-label":`Model id`,className:`min-w-0 flex-1`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())}}),(0,V.jsx)(UI,{label:`Use this model`,icon:Yf,tone:`primary`,onClick:c})]}):null]})}function _H({label:e,help:t,checked:n,onChange:r,name:i}){return(0,V.jsxs)(`div`,{className:`flex min-h-0 items-center justify-between gap-4`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:e}),t?(0,V.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:t}):null]}),(0,V.jsx)(SB,{checked:n,onCheckedChange:r,"aria-label":i??e})]})}function vH({value:e,onSave:t,placeholder:n,label:r}){let[i,a]=(0,m.useState)(e);(0,m.useEffect)(()=>a(e),[e]);let o=()=>{let n=i.trim();n!==e&&t(n)};return(0,V.jsx)(xB,{value:i,placeholder:n,"aria-label":r,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())}})}function yH({value:e,label:t,onSave:n}){let r=Math.round(e/6e4);return(0,V.jsx)(SH,{label:t,value:String(r),min:1,suffix:`min`,onSave:e=>{let t=Number(e);return!Number.isFinite(t)||t<=0?(H.error(`"${e}" is not a positive number of minutes.`),!1):(n(Math.round(t*6e4)),!0)}})}function bH({value:e,label:t,onSave:n}){return(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-4 gap-y-1.5`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:mV.label}),(0,V.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:mV.help})]}),(0,V.jsx)(`div`,{className:`w-36 shrink-0`,children:(0,V.jsx)(SH,{label:t,value:e?String(e):``,min:mV.min,max:mV.max,step:1e3,placeholder:mV.placeholder,suffix:`tokens`,onSave:e=>{if(e===``)return n(null),!0;let t=Number(e);return!Number.isInteger(t)||t<mV.min||t>mV.max?(H.error(mV.bad(e)),!1):(n(t),!0)}})})]})}function xH({value:e,onSave:t}){return(0,V.jsx)(SH,{label:SV,value:String(e),min:0,max:65535,onSave:e=>!/^\d+$/.test(e)||Number(e)>65535?(H.error(`"${e}" is not a port (0, or 1-65535).`),!1):(t(Number(e)),!0)})}function SH({label:e,value:t,min:n,max:r,step:i,placeholder:a,suffix:o,onSave:s}){let[c,l]=(0,m.useState)(t);(0,m.useEffect)(()=>l(t),[t]);let u=()=>{c!==t&&(s(c.trim())||l(t))};return(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(xB,{type:`number`,inputMode:`numeric`,min:n,max:r,step:i,placeholder:a,value:c,"aria-label":e,className:o?o.length>3?`pr-14`:`pr-10`:void 0,onChange:e=>l(e.target.value),onBlur:u,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),u())}}),o?(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 right-2.5 flex items-center text-xs text-muted-foreground`,children:o}):null]})}function CH({value:e,label:t,onSave:n}){let[r,i]=(0,m.useState)(e);return(0,m.useEffect)(()=>i(e),[e]),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(CB,{rows:2,value:r,"aria-label":t,onChange:e=>i(e.target.value),onBlur:()=>{r.trim()!==e&&n(r.trim())}}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Saved when you leave the field.`})]})}function wH({value:e,statuses:t,label:n,onChange:r}){let i=[{value:`pi`,label:$.piLabel,help:$.piHelp},...t.map(e=>({value:e.id,label:e.label,help:e.path?e.version?`v${e.version}`:$.installed:$.missing}))];return i.some(t=>t.value===e)||i.push({value:e,label:e}),(0,V.jsx)(zB,{value:e,items:i,label:n,onChange:r})}function TH({value:e,models:t,label:n,onChange:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),c=e===``||t.some(t=>t.id===e),l=[{value:``,label:$.defaultModel,help:$.defaultModelHelp},...t.map(e=>({value:e.id,label:e.label,help:e.custom?lV:e.current?e.id:`${e.id} · ${$.older}`})),...c?[]:[{value:e,label:e,help:lV}],{value:sV,label:cV,help:lV}],u=t=>{if(t!==`__custom__`)return r(t);s(c?``:e),a(!0)},d=()=>{let t=o.trim();a(!1),t&&t!==e&&r(t)};return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsx)(zB,{value:e,items:l,label:n,onChange:u}),i?(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,V.jsx)(xB,{autoFocus:!0,value:o,placeholder:`model id`,"aria-label":`Harness model id`,className:`min-w-0 flex-1`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d())}}),(0,V.jsx)(UI,{label:`Use this model`,icon:Yf,tone:`primary`,onClick:d})]}):null]})}function EH(e,t){let n=e?.models.find(e=>e.id===t);if(n&&n.efforts.length>0)return n.efforts;if(e?.effort===`session`)return dV;let r=e?.models.find(e=>e.efforts.length>0)?.efforts;return r&&r.length>0?r:dV}function DH({kind:e,config:t,models:n,harnesses:r,save:i,onGrants:a}){let o=dH(t,e),s=t=>i(fH(e,t)),c=rV[e],l=o.harness?r.find(e=>e.id===o.harness):void 0,u=!!o.harness,d=o.harnessModel??``,f=u?EH(l,d):pH(n,o.model),p=t=>{if(t===(o.harness??`pi`))return;if(t===`pi`)return void s({harness:`pi`});let n=EH(r.find(e=>e.id===t),``),i={harness:t,harnessModel:``};e!==`scout`&&!n.includes(o.thinking)&&(i.thinking=mH(n,o.thinking)),s(i)},h=t=>{let n=EH(l,t),r={harnessModel:t};e!==`scout`&&!n.includes(o.thinking)&&(r.thinking=mH(n,o.thinking)),s(r)},g=t=>{let r={model:t};e!==`scout`&&!pH(n,t).includes(o.thinking)&&(r.thinking=mH(pH(n,t),o.thinking)),s(r)},_=e!==`scout`&&e!==`researcher`,[v,y]=(0,m.useState)(!1),b=OH(o,e);return(0,V.jsxs)(`section`,{"data-slot":`agent-row`,className:`glass flex min-w-0 flex-col gap-2.5 rounded-xl border px-3.5 pt-2.5 pb-3`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,V.jsxs)(`h3`,{className:`flex min-w-0 items-center gap-2 break-words text-sm font-semibold`,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-tile`,style:{"--ac":NR(e)},children:c[0]}),c]}),(0,V.jsx)(AH,{open:v,custom:b,onToggle:()=>y(e=>!e)})]}),PV.has(e)?(0,V.jsx)(wH,{value:o.harness??`pi`,statuses:r,label:`${c} ${$.label.toLowerCase()}`,onChange:p}):null,u?(0,V.jsx)(TH,{value:d,models:l?.models??[],label:`${c} model`,onChange:h}):(0,V.jsx)(gH,{value:o.model,models:n,label:`${c} model`,inherit:e===`master`,onChange:g}),e===`scout`?(0,V.jsx)(kH,{}):(0,V.jsx)(WB,{value:o.thinking,levels:dV,supported:f,recommended:uV[e],model:u?d||`${l?.label??o.harness}'s default model`:o.model===`inherit`?`the session model`:o.model,label:`${c} effort`,onChange:e=>s({thinking:e})}),u&&l?.effort===`session`&&e!==`scout`?(0,V.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:$.effortNote}):null,(0,V.jsx)(_H,{label:`Auto-compact`,help:e===`master`?`Compacts the oracle's context as it fills, and files what it learned into the knowledge base, shared with the agents it concerns.`:u?l?.protocol===`acp`?`${l.label} compacts on its own; this switch applies to pi, Codex and Claude Code.`:`Lets ${l?.label??`the harness`} compact this agent's context, at the threshold under Harnesses.`:`Compacts this agent's context as it fills.`,checked:o.autoCompact!==!1,onChange:e=>s({autoCompact:e}),name:`${c} auto-compact`}),o.autoCompact!==!1&&!u?(0,V.jsx)(bH,{value:o.compactAt,label:`${c} compact at`,onSave:e=>s({compactAt:e})}):null,(0,V.jsxs)(`div`,{hidden:!v,className:`grid gap-2 border-t border-border pt-2`,children:[u?(0,V.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:$.agentNote}):null,_?(0,V.jsx)(CH,{value:o.instructions??``,label:`${c} instructions`,onSave:e=>s({instructions:e})}):null,(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,V.jsx)(`p`,{className:`min-w-[7rem] flex-1 break-words text-xs text-muted-foreground`,children:JV(KV(t,e),e)}),(0,V.jsx)(UI,{label:Q.edit,icon:Nh,onClick:a})]})]})]})}function OH(e,t){return[t!==`scout`&&t!==`researcher`&&!!e.instructions,e.mcpTools!==void 0,t!==`master`&&e.skills!==void 0].filter(Boolean).length}function kH(){return(0,V.jsxs)(`p`,{className:`flex min-h-[4.5rem] items-center gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(Jf,{"aria-hidden":`true`,className:`size-4`}),`Effort `,(0,V.jsx)(`span`,{className:`capitalize`,children:`low`}),` (fixed for scouts)`]})}function AH({open:e,custom:t,onToggle:n}){return(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":e,onClick:n,className:`-mr-1.5 flex min-h-8 shrink-0 items-center gap-1 rounded-md px-1.5 text-xs text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[(0,V.jsx)(tp,{"aria-hidden":`true`,className:Y(`size-3.5 transition-transform duration-200 ease-snap`,e&&`rotate-90`)}),`More`,t>0?(0,V.jsxs)(`span`,{className:`text-primary`,children:[`· `,t,` customised`]}):null]})}function jH(e,t){return t.startsWith(`panel:`)?e.lobby.panels[t.slice(6)]:e.lobby[t]}function MH({config:e,item:t,save:n}){let r=t.id.startsWith(`panel:`);return(0,V.jsx)(_H,{label:t.label,help:t.help,checked:jH(e,t.id),onChange:e=>{n(r?{lobby:{panels:{[t.id.slice(6)]:e}}}:{lobby:{[t.id]:e}})}})}function NH({config:e,save:t}){let n=e.workflow.gitIsolation;return(0,V.jsx)(GB,{prominent:!0,title:fV.workflow,children:(0,V.jsx)(RB,{children:(0,V.jsx)(LB,{label:DV,help:EV.find(e=>e.id===n)?.help??`enter cycles off, branch, worktree`,children:(0,V.jsx)(zB,{value:n,items:EV.map(e=>({value:e.id,label:e.label})),label:DV,onChange:e=>void t({workflow:{gitIsolation:e}})})})})})}var PH=e=>e?`${e}/`:kV.top;function FH(e){return e.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function IH({replaced:e}){let t=_R(`settings.linters`,{},[]),n=t.data?.linters;return(0,V.jsx)(LB,{label:kV.found,help:e?kV.foundReplaced:kV.foundHelp,children:n?n.length===0?(0,V.jsx)(`p`,{className:`break-words text-sm text-muted-foreground text-right`,children:kV.foundNone}):(0,V.jsx)(`ul`,{"aria-label":kV.found,className:Y(`flex flex-col items-end gap-1.5`,e&&`opacity-60`),children:n.map(e=>(0,V.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm`,children:[(0,V.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.tool}),(0,V.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:PH(e.folder)}),(0,V.jsxs)(`span`,{title:e.installed?void 0:kV.missingHelp,className:Y(`inline-flex shrink-0 items-center gap-1 text-xs`,e.installed?`text-success`:`text-warning`),children:[e.installed?(0,V.jsx)(sp,{"aria-hidden":`true`,className:`size-3.5`}):(0,V.jsx)(ap,{"aria-hidden":`true`,className:`size-3.5`}),e.installed?kV.installed:kV.missing]})]},`${e.tool}:${e.folder}`))}):(0,V.jsx)(`p`,{className:`break-words text-sm text-muted-foreground text-right`,children:t.error?t.error:`Looking…`})})}function LH({config:e,save:t}){let n=e.lint,r=n.mode===`off`,i=n.command.trim().length>0;return(0,V.jsxs)(GB,{prominent:!0,title:fV.lint,children:[(0,V.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:kV.intro}),(0,V.jsxs)(RB,{children:[(0,V.jsx)(LB,{label:kV.mode,help:OV.find(e=>e.id===n.mode)?.help,children:(0,V.jsx)(zB,{value:n.mode,items:OV.map(e=>({value:e.id,label:e.label})),label:kV.mode,onChange:e=>void t({lint:{mode:e}})})}),(0,V.jsxs)(`div`,{className:Y(`flex flex-col divide-y divide-border [&>*]:py-3 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0`,r&&`opacity-60`),"aria-disabled":r||void 0,children:[(0,V.jsx)(LB,{label:kV.command,help:kV.commandHelp,children:(0,V.jsx)(vH,{value:n.command,label:kV.command,placeholder:kV.commandPlaceholder,onSave:e=>void t({lint:{command:e}})})}),i?(0,V.jsx)(LB,{label:kV.extensions,help:kV.extensionsHelp,children:(0,V.jsx)(vH,{value:n.extensions.join(` `),label:kV.extensions,placeholder:kV.extensionsPlaceholder,onSave:e=>void t({lint:{extensions:FH(e)}})})}):null,(0,V.jsx)(LB,{label:kV.timeout,help:kV.timeoutHelp,children:(0,V.jsx)(yH,{value:n.timeoutMs,label:`Lint ${kV.timeout.toLowerCase()}`,onSave:e=>void t({lint:{timeoutMs:e}})})}),(0,V.jsx)(IH,{replaced:i})]})]})]})}function RH({config:e,save:t}){let n=e.lobby.web;return(0,V.jsx)(GB,{prominent:!0,title:fV.lobby,children:(0,V.jsxs)(RB,{children:[uH.map(n=>(0,V.jsx)(MH,{config:e,item:n,save:t},n.id)),(0,V.jsx)(LB,{label:yV,help:bV,children:(0,V.jsx)(zB,{value:String(e.lobby.maxPlanningRounds),items:xV.map(e=>({value:String(e),label:hH(e)})),label:yV,onChange:e=>void t({lobby:{maxPlanningRounds:Number(e)}})})}),(0,V.jsx)(LB,{label:SV,help:CV,children:(0,V.jsx)(xH,{value:n.port,onSave:e=>void t({lobby:{web:{port:e}}})})}),(0,V.jsx)(_H,{label:wV,help:TV,checked:n.openBrowser,onChange:e=>void t({lobby:{web:{openBrowser:e}}})}),(0,V.jsx)(zH,{})]})})}function zH(){let e=_R(`lobby.retention`,{},[]),t=async t=>{try{await L(`lobby.setRetention`,{enabled:t}),e.reload()}catch(e){H.error(e instanceof Error?e.message:`That did not work. Try again.`)}};return(0,V.jsx)(_H,{label:gV.label,help:e.error?gV.error:gV.help,checked:e.data?.enabled??!1,onChange:e=>void t(e)})}function BH(e){let t=e.indexOf(`/`);return t>0?e.slice(0,t):``}function VH(e,t){let n=new Set,r=[];for(let e of t)n.has(e.id)||(n.add(e.id),r.push({id:e.id,label:e.label,kind:`classifier`}));for(let t of e)n.has(t.id)||(n.add(t.id),r.push({id:t.id,label:t.label,kind:`chat`}));return r}function HH({value:e,models:t,classifiers:n,onChange:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),c=VH(t,n),l=BH(e),[u,d]=(0,m.useState)(l),f=e?l:u,p=[...new Set([...c.map(e=>BH(e.id)),...l?[l]:[]])].filter(Boolean).sort(),h=[{value:UH,label:MV.engineJev,help:MV.engineJevHelp},...p.map(e=>{let t=c.filter(t=>BH(t.id)===e),n=t.filter(e=>e.kind===`classifier`).length,r=t.length-n,i=[n?`${n} ${MV.engineClassifier}${n===1?``:`s`}`:``,r?`${r} chat model${r===1?``:`s`}`:``].filter(Boolean).join(`, `);return{value:e,label:e,...i?{help:i}:{}}})],g=c.filter(e=>BH(e.id)===f),_=[...g.map(e=>({value:e.id,label:e.id.slice(f.length+1),help:`${e.kind===`classifier`?MV.engineClassifier:MV.engineChat}${e.label&&e.label!==e.id?` · ${e.label}`:``}`})),...e&&!g.some(t=>t.id===e)?[{value:e,label:e.slice(f.length+1)||e,help:lV}]:[],{value:sV,label:cV,help:lV}],v=e=>{if(a(!1),e===UH)return d(``),r(``);d(e);let t=c.find(t=>BH(t.id)===e&&t.kind===`classifier`)??c.find(t=>BH(t.id)===e);t&&r(t.id)},y=t=>{if(t!==`__custom__`)return r(t);s(e&&!g.some(t=>t.id===e)?e:`${f}/`),a(!0)},b=()=>{let t=o.trim();a(!1),t&&t!==e&&r(t)};return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsx)(zB,{value:f||UH,items:h,label:MV.provider,onChange:v}),f?(0,V.jsx)(zB,{value:e||`__custom__`,items:_,label:MV.engineModel,onChange:y}):null,i?(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,V.jsx)(xB,{autoFocus:!0,value:o,placeholder:`provider/model`,"aria-label":`Classifier model id`,className:`min-w-0 flex-1`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b())}}),(0,V.jsx)(UI,{label:`Use this model`,icon:Yf,tone:`primary`,onClick:b})]}):null]})}var UH=`__jev__`;function WH({config:e,models:t,classifiers:n,save:r}){let i=e.classifier,a=AV.find(e=>e.id===i.provider)?.label,o=!i.engine;return(0,V.jsx)(GB,{prominent:!0,title:fV.classifier,children:(0,V.jsxs)(RB,{children:[(0,V.jsx)(_H,{label:MV.enabled,help:MV.enabledHelp,checked:i.enabled,onChange:e=>void r({classifier:{enabled:e}})}),(0,V.jsx)(LB,{label:MV.engine,help:MV.engineHelp,children:(0,V.jsx)(HH,{value:i.engine,models:t,classifiers:n,onChange:e=>void r({classifier:{engine:e}})})}),o?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(LB,{label:MV.host,children:(0,V.jsx)(zB,{value:i.provider,items:AV.map(e=>({value:e.id,label:e.label})),label:MV.host,onChange:e=>void r({classifier:{provider:e}})})}),(0,V.jsx)(LB,{label:MV.model,help:MV.modelHelp,children:(0,V.jsx)(vH,{value:i.model,label:MV.model,placeholder:`the host's default`,onSave:e=>void r({classifier:{model:e}})})}),(0,V.jsx)(LB,{label:MV.key,help:MV.keyNote,children:(0,V.jsx)(`p`,{className:`break-words text-sm text-muted-foreground text-right`,children:a??i.provider})})]}):null,jV.map(e=>(0,V.jsx)(_H,{label:e.label,help:e.help,checked:i.features[e.id],onChange:t=>void r({classifier:{features:{[e.id]:t}}})},e.id)),(0,V.jsx)(LB,{label:MV.cheap,help:MV.cheapHelp,children:(0,V.jsx)(gH,{value:i.effort.cheapModel,models:t,label:MV.cheap,none:!0,onChange:e=>void r({classifier:{effort:{cheapModel:e}}})})})]})})}function GH(){let e=cB(),t=async e=>{if(!e)return uB();let t=await lB();t===`granted`?H.success(NV.notificationsOn):H.error(t===`unsupported`?NV.notificationsUnsupported:NV.notificationsBlocked)};return(0,V.jsx)(GB,{prominent:!0,title:fV.notifications,children:(0,V.jsx)(RB,{children:(0,V.jsx)(_H,{label:NV.notificationsLabel,help:NV.notificationsHelp,checked:e,onChange:e=>void t(e)})})})}function KH(){let{available:e,install:t}=y(),n=b(),r=x();return(0,V.jsx)(GB,{prominent:!0,title:fV.install,children:(0,V.jsxs)(RB,{children:[(0,V.jsx)(LB,{label:NV.installLabel,help:n?NV.installedNow:NV.installHelp,children:n?null:(0,V.jsx)(`div`,{className:`flex justify-end`,children:(0,V.jsx)(UI,{label:NV.installButton,icon:Dp,tone:`primary`,onClick:()=>e?void t().then(()=>H.success(NV.installDone)):H.warning(NV.installUnavailable)})})}),r.supported?(0,V.jsx)(LB,{label:NV.fullscreenLabel,help:NV.fullscreenHelp,children:(0,V.jsx)(`div`,{className:`flex justify-end`,children:(0,V.jsx)(UI,{label:r.on?NV.fullscreenOn:NV.fullscreenOff,icon:r.on?ym:lm,pressed:r.on,onClick:()=>void r.toggle()})})}):null]})})}var qH=[`Agents`,`Harnesses`,`Tools & skills`,`Workflow`,`Lobby`,`Classifier`,`Appearance & notifications`],JH=e=>`settings-${e.split(` `)[0]}`;function YH({config:e,models:t,classifierModels:n=[],onConfig:r}){let[i,a]=(0,m.useState)(`Agents`),[o,s]=(0,m.useState)(`master`),c=e=>{s(e),a(`Tools & skills`)},l=_R(`settings.harnesses`,{},[]),u=JSON.stringify(e.harnesses),d=l.reload,f=(0,m.useRef)(u);(0,m.useEffect)(()=>{f.current!==u&&(f.current=u,d())},[u,d]);let p=l.data?.harnesses??[],h=(0,m.useRef)(Promise.resolve()),g=e=>{let t=async()=>{try{return r((await L(`settings.set`,{patch:e})).config),H.success(NV.saved),!0}catch(e){return H.error(e instanceof Error?e.message:`That did not work. Try again.`),!1}},n=h.current.then(t,t);return h.current=n,n};return(0,V.jsxs)(`div`,{className:`cs-pg cs-set flex flex-col pb-dock`,children:[(0,V.jsx)(`header`,{className:`cs-pgh`,children:(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h1`,{className:`cs-hd1`,children:NV.title}),(0,V.jsx)(`p`,{className:`cs-hd2`,children:NV.intro})]})}),(0,V.jsx)(`nav`,{"aria-label":`Settings sections`,className:`cs-secn`,children:(0,V.jsx)(ME,{as:`nav`,size:`md`,label:`Settings sections`,items:qH.map(e=>({id:e,label:e,controls:JH(e)})),value:i,onChange:a})}),(0,V.jsxs)(`div`,{id:JH(`Agents`),hidden:i!==`Agents`,"aria-hidden":i!==`Agents`,children:[(0,V.jsx)(`h2`,{className:`sr-only`,children:fV.agents}),(0,V.jsx)(`div`,{className:`grid grid-cols-2 items-start gap-3.5 lg:grid-cols-3`,children:nV.map(n=>(0,V.jsx)(DH,{kind:n,config:e,models:t,harnesses:p,save:g,onGrants:()=>c(n)},n))})]}),(0,V.jsx)(`div`,{id:JH(`Harnesses`),hidden:i!==`Harnesses`,"aria-hidden":i!==`Harnesses`,children:(0,V.jsx)(cH,{config:e,statuses:l.data?.harnesses,...l.error?{error:l.error}:{},save:g})}),(0,V.jsx)(`div`,{id:JH(`Tools & skills`),hidden:i!==`Tools & skills`,"aria-hidden":i!==`Tools & skills`,children:(0,V.jsx)(QV,{config:e,save:g,agent:o,onAgent:s})}),(0,V.jsx)(`div`,{id:JH(`Workflow`),hidden:i!==`Workflow`,"aria-hidden":i!==`Workflow`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,V.jsx)(NH,{config:e,save:g}),(0,V.jsx)(LH,{config:e,save:g})]})}),(0,V.jsx)(`div`,{id:JH(`Lobby`),hidden:i!==`Lobby`,"aria-hidden":i!==`Lobby`,children:(0,V.jsx)(RH,{config:e,save:g})}),(0,V.jsx)(`div`,{id:JH(`Classifier`),hidden:i!==`Classifier`,"aria-hidden":i!==`Classifier`,children:(0,V.jsx)(WH,{config:e,models:t,classifiers:n,save:g})}),(0,V.jsx)(`div`,{id:JH(`Appearance & notifications`),hidden:i!==`Appearance & notifications`,"aria-hidden":i!==`Appearance & notifications`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,V.jsx)(HV,{}),(0,V.jsx)(GH,{}),(0,V.jsx)(KH,{})]})})]})}function XH(){return(0,V.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-4 px-8 pt-8 pb-dock`,role:`status`,"aria-label":NV.loading,children:[0,1,2,3].map(e=>(0,V.jsx)(qE,{shape:`card`,className:`h-48`},e))})}function ZH(){let e=_R(`settings.get`,{},[`status`]),[t,n]=(0,m.useState)(),r=(0,m.useRef)(0),i=(0,m.useCallback)(e=>{r.current=performance.now(),n(e)},[]);return(0,m.useEffect)(()=>{e.data&&e.requestedAt>r.current&&n(e.data.config)},[e.data,e.requestedAt]),!t&&e.error?(0,V.jsx)(wE,{message:`${NV.loadFailed} ${e.error}`,onRetry:e.reload}):t?(0,V.jsx)(YH,{config:t,models:e.data?.models??[],classifierModels:e.data?.classifierModels??[],onConfig:i}):(0,V.jsx)(XH,{})}function QH(){let e=globalThis.DOMParser;if(!e)throw Error(`DOMParser is unavailable`);return new e}var $H=`default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; img-src 'none'; font-src 'none'; connect-src 'none'; media-src 'none'; frame-src 'none'; object-src 'none'; form-action 'none'; base-uri 'none'`,eU=new Set(`div span p br hr h1 h2 h3 h4 h5 h6 section article header footer main aside nav ul ol li dl dt dd strong em b i u s small sub sup blockquote pre code table thead tbody tfoot tr th td caption colgroup col figure figcaption style button input label select option optgroup textarea details summary fieldset legend progress meter output kbd mark`.split(` `)),tU=new Set(`class id title role aria-label aria-hidden aria-expanded aria-selected aria-checked aria-pressed aria-current colspan rowspan scope type name value placeholder for checked selected disabled readonly open min max step rows cols tabindex`.split(` `)),nU=new Set(`text search email tel url number password checkbox radio range color date time month week button reset submit`.split(` `)),rU=`button,input,select,textarea,summary,label,[role=button],[role=tab]{transition:background-color .18s ease,color .18s ease,border-color .18s ease,box-shadow .18s ease,transform .18s ease,opacity .18s ease}button,summary,label,select,[role=button],[role=tab],input[type=checkbox],input[type=radio],input[type=range]{cursor:pointer}button:active,[role=button]:active{transform:scale(.97)}details[open]>:not(summary){animation:mockup-in .22s ease-out}@keyframes mockup-in{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}}`;function iU(e){if(!e||typeof e!=`object`)return;let t=e;if(!(typeof t.html!=`string`||t.html.length>1e5)&&!(t.css!==void 0&&(typeof t.css!=`string`||t.css.length>12e4)))return{html:t.html,...typeof t.css==`string`?{css:t.css}:{}}}function aU(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,``);return/\\|@import|url\s*\(|image-set\s*\(|expression\s*\(|behavior\s*:|-moz-binding/i.test(t)?``:t.replace(/<\/?style/gi,``)}function oU(e){if(!eU.has(e.localName)||e.namespaceURI!==`http://www.w3.org/1999/xhtml`){e.remove();return}for(let t of[...e.attributes])t.name===`style`?e.setAttribute(`style`,aU(t.value)):tU.has(t.name)||e.removeAttribute(t.name);if(e.localName===`input`){let t=[...e.attributes].find(e=>e.name===`type`)?.value.toLowerCase();t!==void 0&&!nU.has(t)&&e.setAttribute(`type`,`text`)}e.localName===`style`&&(e.textContent=aU(e.textContent??``));for(let t of[...e.children])oU(t)}function sU(e,t){try{return cU(e,t??QH())}catch{return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${$H}"><meta name="referrer" content="no-referrer"></head><body><p role="status">Static mockup unavailable. The preview could not be safely rendered.</p></body></html>`}}function cU(e,t){let n=t.parseFromString(e.html,`text/html`);for(let e of[...n.head.children,...n.body.children])oU(e);let r=[...n.head.querySelectorAll(`style`)].map(e=>e.outerHTML).join(``);return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${$H}"><meta name="referrer" content="no-referrer"><style>body{margin:16px;overflow-wrap:anywhere}*{box-sizing:border-box}${rU}${aU(e.css??``).replace(/</g,`\\3c `)}</style>${r}</head><body>${n.body.innerHTML}</body></html>`}function lU({preview:e,label:t,className:n,frameWidth:r,minWidth:i,onOpen:a}){let o=(0,m.useMemo)(()=>sU(e),[e]),s=(0,m.useRef)(null),[c,l]=(0,m.useState)();if((0,m.useLayoutEffect)(()=>{let e=s.current;if(!r&&!i||!e)return;let t=()=>l({width:e.clientWidth,height:e.clientHeight});if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[r,i]),!r&&!i)return(0,V.jsx)(`iframe`,{title:`Static mockup: ${t}`,sandbox:``,referrerPolicy:`no-referrer`,srcDoc:o,className:Y(`h-80 w-full rounded-lg border bg-background`,n)});let u=r??Math.max(c?.width??0,i??0),d=c&&c.width>0&&u>0?Math.min(1,c.width/u):1;return(0,V.jsxs)(`div`,{ref:s,className:Y(`group/mock relative h-80 w-full max-w-full overflow-hidden rounded-lg border bg-background`,n),children:[(0,V.jsx)(`iframe`,{title:`Static mockup: ${t}`,sandbox:``,referrerPolicy:`no-referrer`,srcDoc:o,className:`absolute top-0 left-0 origin-top-left border-0`,style:{width:u||`100%`,height:c?c.height/d:`100%`,transform:`scale(${d})`}}),a?(0,V.jsx)(`button`,{type:`button`,"data-compact":``,onClick:a,"aria-label":`Expand the mockup: ${t}`,title:`Expand`,className:`cs-mxb outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,V.jsx)(sm,{"aria-hidden":`true`,className:`size-3`})}):null]})}var uU=/\s*\(recommended\)\s*$/i,dU=1024,fU=e=>e.replace(uU,``);function pU(e){return!!(e&&(e.htmlPreview||e.image||e.preview))}function mU({option:e}){let t=fU(e.label);return pU(e)?(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3`,children:[e.htmlPreview?(0,V.jsx)(lU,{preview:e.htmlPreview,label:t,minWidth:dU,className:`h-auto min-h-[18rem] flex-1`}):null,e.image?(0,V.jsx)(`img`,{src:F(e.image),alt:`Mockup: ${t}`,className:`min-h-0 w-full flex-1 rounded-lg border bg-background object-contain`}):null,e.preview?(0,V.jsx)(QL,{text:e.preview,className:Y(`overflow-auto rounded-lg border bg-background p-4 text-sm`,!e.htmlPreview&&!e.image&&`flex-1`)}):null]}):(0,V.jsx)(`p`,{className:`grid h-full place-items-center p-6 text-sm text-muted-foreground`,children:`No mockup for this option.`})}function hU({options:e,start:t,title:n,picked:r=[],multi:i=!1,onChoose:a,onClose:o,onIndex:s}){let c=Jd(),l=(0,m.useRef)(null),u=(0,m.useRef)(null),[d,f]=(0,m.useState)(()=>Math.min(Math.max(0,t),e.length-1)),p=e[d],h=e.length-1;(0,m.useEffect)(()=>s?.(d),[d,s]),(0,m.useLayoutEffect)(()=>{let e=l.current;e&&(e.scrollLeft=d*e.clientWidth),u.current?.focus()},[]);let g=(0,m.useCallback)(e=>{let t=Math.min(Math.max(0,e),h),n=l.current;f(t),n?.scrollTo({left:t*n.clientWidth,behavior:c?`auto`:`smooth`})},[h,c]);(0,m.useEffect)(()=>{let e=l.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{e.scrollLeft=d*e.clientWidth});return t.observe(e),()=>t.disconnect()},[d]);function _(){let e=l.current;if(!e||e.clientWidth===0)return;let t=Math.round(e.scrollLeft/e.clientWidth);t!==d&&t>=0&&t<=h&&f(t)}function v(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=t.target;if(n.closest(`input, textarea, [contenteditable='true']`))return;let r={ArrowLeft:-1,ArrowRight:1,PageUp:-1,PageDown:1}[t.key];if(r){t.preventDefault(),g(d+r);return}if(t.key===`Home`||t.key===`End`){t.preventDefault(),g(t.key===`Home`?0:h);return}let i=Number(t.key);if(Number.isInteger(i)&&i>=1&&i<=e.length){t.preventDefault(),g(i-1);return}t.key===`Enter`&&a&&!(n instanceof HTMLButtonElement)&&(t.preventDefault(),a(d))}let y=r.includes(d);return(0,V.jsxs)(`div`,{ref:u,tabIndex:-1,"data-autofocus":``,onKeyDown:v,className:`mockup-viewer flex h-full min-h-0 flex-col outline-none`,role:`region`,"aria-label":`Mockups: ${n}`,"aria-roledescription":`carousel`,children:[(0,V.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border px-4 py-3`,children:[(0,V.jsx)(WT,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Back to the question`,title:`Back · Esc`,onClick:()=>o(d),children:(0,V.jsx)(_m,{"aria-hidden":`true`})}),(0,V.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:n}),(0,V.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,"aria-live":`polite`,children:[d+1,` of `,e.length]}),(0,V.jsx)(`div`,{role:`tablist`,"aria-label":`Options`,className:`flex w-full flex-wrap gap-1.5 sm:w-auto`,children:e.map((e,t)=>(0,V.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===d,"aria-controls":`mockup-slide-${t}`,"data-compact":``,onClick:()=>g(t),className:Y(`inline-flex h-7 max-w-48 items-center gap-1 rounded-lg border px-2.5 text-xs font-medium transition-colors outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t===d?`border-primary/50 bg-accent text-foreground`:`border-border text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,V.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:t+1}),(0,V.jsx)(`span`,{className:`truncate`,children:fU(e.label)}),r.includes(t)?(0,V.jsx)(Yf,{"aria-label":`picked`,className:`size-3 text-primary`}):null]},t))})]}),(0,V.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,V.jsx)(`div`,{ref:l,onScroll:_,className:`mockup-track flex h-full snap-x snap-mandatory overflow-x-auto overflow-y-hidden overscroll-x-contain`,children:e.map((t,n)=>(0,V.jsxs)(`section`,{id:`mockup-slide-${n}`,role:`tabpanel`,"aria-roledescription":`slide`,"aria-label":`${n+1} of ${e.length}: ${fU(t.label)}`,"aria-hidden":n!==d,className:`flex h-full w-full shrink-0 snap-center snap-always flex-col gap-2 overflow-y-hidden px-4 py-4 sm:px-14`,children:[(0,V.jsxs)(`div`,{className:`flex items-baseline gap-2 text-sm`,children:[(0,V.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[n+1,`.`]}),(0,V.jsx)(`span`,{className:`font-medium`,children:fU(t.label)}),uU.test(t.label)?(0,V.jsx)(`span`,{className:`text-xs font-medium text-primary`,children:`Recommended`}):null,r.includes(n)?(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-primary`,children:[(0,V.jsx)(Yf,{"aria-hidden":`true`,className:`size-3`}),`picked`]}):null]}),t.description?(0,V.jsx)(QL,{text:t.description,className:`text-sm text-muted-foreground`}):null,(0,V.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,V.jsx)(mU,{option:t})})]},n))}),d>0?(0,V.jsx)(WT,{type:`button`,variant:`outline`,size:`icon`,"aria-label":`Previous option`,title:`Previous · ←`,onClick:()=>g(d-1),className:`absolute top-1/2 left-2 -translate-y-1/2 rounded-full`,children:(0,V.jsx)($f,{"aria-hidden":`true`})}):null,d<h?(0,V.jsx)(WT,{type:`button`,variant:`outline`,size:`icon`,"aria-label":`Next option`,title:`Next · →`,onClick:()=>g(d+1),className:`absolute top-1/2 right-2 -translate-y-1/2 rounded-full`,children:(0,V.jsx)(tp,{"aria-hidden":`true`})}):null]}),(0,V.jsxs)(`footer`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2 border-t border-border px-4 py-3`,children:[(0,V.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,V.jsx)($T,{chord:`←→`,children:`option`}),a?(0,V.jsx)($T,{chord:`Enter`,children:i?y?`unpick`:`pick`:`choose`}):null,(0,V.jsx)($T,{chord:`Esc`,children:`back`})]}),a&&p?(0,V.jsxs)(WT,{type:`button`,onClick:()=>a(d),className:`max-w-full`,children:[i&&y?`Unpick`:i?`Pick`:`Choose`,(0,V.jsx)(`span`,{className:`truncate`,children:fU(p.label)})]}):null]})]})}function gU(e,t,n){e.nativeEvent.isComposing||(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),e.key===`Enter`&&e.ctrlKey&&(e.preventDefault(),e.stopPropagation(),t()))}function _U({text:e,disabled:t=!1,onSave:n,onCancel:r}){let[i,a]=(0,m.useState)(e),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(``),u=(0,m.useRef)(null);(0,m.useEffect)(()=>{u.current?.focus({preventScroll:!0}),u.current?.select()},[]);let d=async()=>{if(!(t||o||!i.trim())){s(!0),l(``);try{await n(i.trim()),r()}catch(e){l(e instanceof Error?e.message:String(e)),s(!1)}}};return(0,V.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,onKeyDown:e=>gU(e,()=>void d(),()=>{o||r()}),children:[(0,V.jsxs)(`label`,{className:`text-sm`,children:[`Edit message`,(0,V.jsx)(CB,{ref:u,value:i,onChange:e=>a(e.target.value),disabled:o,className:`mt-2 max-h-[40vh] min-h-24`})]}),c?(0,V.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not save. `,c]}):null,(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)(WT,{size:`sm`,onClick:()=>void d(),disabled:t||o||!i.trim(),children:o?`Saving…`:`Save`}),(0,V.jsx)(WT,{size:`sm`,variant:`ghost`,disabled:o,onClick:r,children:`Cancel`})]})]})}var vU=1200;function yU({question:e}){let[t,n]=(0,m.useState)(),r=lE(t!==void 0,cE.sheet),i=e.options.flatMap((e,t)=>e.mockup?[{option:e,index:t,mockup:e.mockup}]:[]);if(i.length===0)return null;let a=e.options.map(e=>({label:e.label,description:e.description,...e.mockup?{htmlPreview:e.mockup}:{}}));return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`ul`,{"aria-label":`Mockups`,className:`cs-mocks`,children:i.map(({option:e,index:t,mockup:r})=>(0,V.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,V.jsx)(lU,{preview:r,label:fU(e.label),frameWidth:vU,onOpen:()=>n(t),className:`cs-mk3f aspect-[3/2] h-auto`}),(0,V.jsxs)(`span`,{className:`truncate`,children:[(0,V.jsxs)(`span`,{className:`tabular-nums`,children:[t+1,`.`]}),` `,fU(e.label)]})]},t))}),(0,V.jsx)(tE,{open:t!==void 0&&r,onOpenChange:e=>{e||n(void 0)},label:`Mockups: ${e.text}`,className:`h-[min(92svh,60rem)] max-h-[min(92svh,60rem)] max-w-6xl`,children:t===void 0?null:(0,V.jsx)(hU,{options:a,start:t,title:e.text,onClose:()=>n(void 0)})})]})}function bU({questions:e}){return(0,V.jsx)(`ol`,{className:`cs-qs`,children:e.map((e,t)=>(0,V.jsxs)(`li`,{className:`cs-qc`,style:{"--ac":NR(e.from)},children:[(0,V.jsxs)(`p`,{className:`cs-qh`,children:[(0,V.jsxs)(`span`,{className:`cs-qwho`,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-tile`,children:zR(e.from)[0]}),zR(e.from)]}),(0,V.jsxs)(`span`,{className:`min-w-0`,children:[(0,V.jsxs)(`span`,{className:`sr-only`,children:[`Question `,t+1,`: `]}),e.text]})]}),e.options.length?(0,V.jsx)(`ul`,{"aria-label":`Options`,className:`cs-opts`,children:e.options.map(e=>(0,V.jsxs)(`li`,{className:`cs-op`,children:[(0,V.jsx)(`b`,{children:e.label}),e.description?` — ${e.description}`:``]},e.label))}):null,(0,V.jsx)(yU,{question:e})]},t))})}function xU({message:e}){let t=e.decided??[];return t.length?(0,V.jsx)(`ul`,{"aria-label":`Settled for you`,className:`cs-decided`,children:t.map((e,t)=>(0,V.jsxs)(`li`,{title:`Settled by the classifier, ${Math.round(e.probability*100)}% sure. Comment on the plan to overrule it.`,children:[(0,V.jsx)(Yf,{"aria-hidden":`true`,className:`size-3.5`}),(0,V.jsxs)(`span`,{className:`min-w-0`,children:[(0,V.jsx)(`b`,{className:`font-semibold`,style:{color:NR(e.from)},children:zR(e.from)}),` `,(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:e.question}),` `,(0,V.jsx)(`b`,{className:`font-semibold`,children:e.answer}),(0,V.jsxs)(`span`,{className:`cs-dh2`,children:[`auto · `,Math.round(e.probability*100),`% · comment to overrule`]})]})]},t))}):null}function SU({message:e,index:t,busy:n,readOnly:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(),c=o&&(o.editedAt??0)>(e.editedAt??0)?o:e,l=n||c!==e,u=async n=>{let r=await L(`planner.editMessage`,{messageIndex:t,at:e.at,text:n});s(r.message)},d=!r&&!e.settled?.length&&!i?(0,V.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>a(!0),className:`chat-action`,children:[(0,V.jsx)(km,{"aria-hidden":`true`,className:`size-3`}),`Edit`]}):null;return(0,V.jsx)(qR,{time:e.at>0?iz(e.at):void 0,head:!0,note:c.editedAt?`(edited)`:void 0,actions:d,children:i?(0,V.jsx)(_U,{text:c.text,disabled:n,onSave:u,onCancel:()=>a(!1)}):(0,V.jsx)(QL,{text:c.text})})}function CU({message:e,index:t,busy:n,readOnly:r}){if(e.role===`you`)return(0,V.jsx)(SU,{message:e,index:t,busy:n,readOnly:r});let i=e.questions??[];return(0,V.jsxs)(KR,{tile:!0,source:`PLANNER`,name:`Panel`,time:e.at>0?iz(e.at):void 0,head:!0,bubble:i.length===0,aside:i.length?`${i.length} question${i.length===1?``:`s`}`:void 0,children:[i.length>0?(0,V.jsx)(bU,{questions:i}):(0,V.jsx)(QL,{text:e.text}),(0,V.jsx)(xU,{message:e})]})}function wU({messages:e,seed:t,busy:n=!1,readOnly:r=!1}){return(0,V.jsxs)(`div`,{className:`chat-column`,role:`log`,"aria-label":`Panel conversation`,children:[t?(0,V.jsx)(JR,{children:t}):null,e.map((e,t)=>(0,V.jsx)(CU,{message:e,index:t,busy:n,readOnly:r},`${e.at}-${t}`)),n?(0,V.jsx)(KR,{tile:!0,source:`PLANNER`,name:`Panel`,head:!0,live:!0,waiting:!0,aside:`the panel is thinking`}):null]})}var TU=`ORACLE`,EU=`No draft yet.`,DU=`The draft appears after the panel's first round.`,OU=`What each seat needs`,kU=[`backend`,`designer`,`qa`,`researcher`],AU={backend:`DEV`,designer:`DESIGN`,qa:`QA`,researcher:`RESEARCH`},jU=`Describe a task in the box below. The panel asks what it needs to know, round by round, until the plan is clear.`,MU=[{title:`Describe it`,text:`Say what you want in the box below.`},{title:`The panel asks`,text:`Each seat asks what it needs to know.`},{title:`A draft forms`,text:`Answer, comment on lines, go another round.`},{title:`Save the plan`,text:`Keep it, or start it as a task.`}];function NU(e){let t=e.filter(e=>e.member);return`${t.filter(e=>e.seated).length} of ${t.length} seated`}function PU(e,t=0){return t<=0?`round ${e}`:e>t?`round ${e} · past the limit, revising`:e===t?`final round ${e}/${t}`:`round ${e}/${t}`}function FU(e,t){return`${e} ${t}${e===1?``:`s`}`}function IU(e){return e.round===0&&e.messages.length===0&&!e.busy}function LU(e){let t=e.members.find(e=>e.status===`failed`);if(t)return(t.error??`${AU[t.member]} failed`).split(`
|
|
98
|
+
`)[0]}function RU(e){let t=[],n=LU(e);return e.busy?t.push(PU(e.round,e.limit)):n?t.push(`${n} — Retry runs the round again`):e.questions.length>0&&t.push(`${FU(e.questions.length,`question`)} waiting`),!e.busy&&e.round>0&&t.push(PU(e.round,e.limit)),!e.busy&&e.limit>0&&e.round+1===e.limit&&t.push(`the next round is the last: the oracle settles the rest`),t}function zU(e,t){let n=AU[e],r=t.seats.includes(e),i=t.members.find(t=>t.member===e),a={member:e,label:n,seated:r,working:!1};if(!r)return{...a,text:`off`};if(i?.status===`thinking`)return{...a,working:!0,text:i.step??`thinking`};if(i?.status===`failed`)return{...a,text:`failed — Retry`};if(!i)return{...a,text:`·`};if(i.reply?.status===`ready`)return{...a,text:`ready`};let o=t.questions.filter(e=>e.from===n).length;return{...a,text:o===0?`done`:FU(o,`question`)}}function BU(e){let t=e.questions.filter(e=>e.from===TU).length;return[{label:TU,seated:!0,working:e.busy,text:e.busy?`chairing`:t?FU(t,`question`):`·`},...kU.map(t=>zU(t,e))]}function VU({iconOnly:e,className:t,side:n}){return(0,V.jsx)(UI,{label:`Previous plans`,text:`Previous`,icon:Vm,shortcut:`H`,iconOnly:e,...t?{className:t}:{},...n?{side:n}:{},onClick:()=>bE(yE(`plan`,`previous`))})}function HU({snap:e}){return e.busy||LU(e)===void 0?null:(0,V.jsx)(`p`,{role:`status`,className:`cs-note mx-auto mb-4 max-w-[48.75rem] text-[var(--bad)]`,children:RU(e).join(` · `)})}function UU({cell:e,asked:t,onToggled:n}){let r=zR(e.label),i=`${e.member?e.seated?`${r} sits on the panel`:`${r} sits this one out`:`${r} chairs the panel`}${e.text&&e.text!==`·`&&e.text!==`off`?` · ${e.text}`:``}${e.member?` · click to toggle`:``}`,a=async()=>{e.member&&await U(`planner.toggleSeat`,{member:e.member})&&n()};return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,className:`cs-sq cs-tipl`,"data-tip":i,"aria-label":i,"aria-pressed":e.member?e.seated:void 0,"data-on":e.seated?`true`:`false`,"data-fixed":e.member?void 0:`true`,"data-working":e.working?`true`:void 0,style:{"--c":NR(e.label)},onClick:e.member?()=>void a():void 0,children:[(0,V.jsx)(IR,{source:e.label,className:`size-[17px]`}),t>0?(0,V.jsx)(`span`,{className:`cs-sqn`,children:t}):null]})})}function WU(e){let t=e.messages.at(-1);return t?.role===`planner`?t.questions??[]:[]}function GU({snap:e,onDone:t}){let n=FE(`status`).data?.keys.find(e=>e.action===`savePlan`)?.label,r=e=>async()=>{await U(e,{})&&t()},i=RU(e).join(` · `)||`No rounds yet`,a=e.busy?e.round+1:Math.max(e.round,1);return(0,V.jsxs)(`aside`,{className:`cs-pside`,"aria-label":`Planning`,children:[e.limit>0?(0,V.jsxs)(`span`,{className:`cs-rcnt cs-tipl`,"data-tip":i,role:`status`,"aria-label":i,children:[(0,V.jsx)(`b`,{children:Math.min(a,e.limit)}),(0,V.jsxs)(`i`,{children:[`/`,e.limit]})]}):(0,V.jsx)(`span`,{className:`sr-only`,role:`status`,children:i}),(0,V.jsx)(`ul`,{className:`cs-chips`,"aria-label":`Panel`,children:BU(e).map(n=>(0,V.jsx)(UU,{cell:n,asked:WU(e).filter(e=>PR(e.from,n.label)).length,onToggled:t},n.label))}),(0,V.jsx)(`div`,{className:`cs-sqsep`}),(0,V.jsxs)(`ul`,{className:`cs-chips`,"aria-label":`Plan actions`,children:[e.retryable?(0,V.jsx)(`li`,{children:(0,V.jsx)(UI,{iconOnly:!0,side:`left`,className:`cs-sq cs-act`,label:`Retry the round`,icon:Gm,shortcut:`R`,onClick:()=>void r(`planner.retry`)()})}):null,(0,V.jsx)(`li`,{children:(0,V.jsx)(VU,{iconOnly:!0,side:`left`,className:`cs-sq cs-act`})}),(0,V.jsx)(`li`,{children:(0,V.jsx)(UI,{iconOnly:!0,side:`left`,className:`cs-sq cs-act`,"data-plan-save":!0,label:`Save the plan`,icon:Zm,shortcut:n??`Ctrl+S`,disabled:!e.draft||e.busy,onClick:()=>void r(`planner.save`)()})}),(0,V.jsx)(`li`,{children:(0,V.jsx)(uR,{iconOnly:!0,side:`left`,className:`cs-sq cs-act`,icon:Fp,label:`New plan`,shortcut:`N`,title:`Start a new plan?`,description:`The conversation and the draft are left behind. Saved plans are not touched.`,confirmLabel:`New plan`,onConfirm:()=>void U(`planner.new`,{}).then(t)})})]})]})}function KU(e){let t=!1;return e.split(`
|
|
99
|
+
`).map(e=>{let n=e.trimStart().startsWith("```");return n&&(t=!t),{text:e,fenced:t||n}})}function qU({notes:e}){return(0,V.jsx)(V.Fragment,{children:e.map((e,t)=>(0,V.jsx)(`p`,{className:`cs-dnote`,children:e},t))})}var JU=[],YU=(0,m.memo)(function({row:e,index:t,notes:n,form:r,onComment:i}){let a=e.text.trim(),o=()=>i(t);return(0,V.jsxs)(`li`,{"data-line":t,className:Y(`cs-dr`,!r&&`[contain-intrinsic-size:auto_2.75rem] [content-visibility:auto]`),children:[(0,V.jsxs)(`div`,{className:`cs-dln`,children:[(0,V.jsx)(`span`,{className:`cs-dd`,"aria-hidden":`true`,children:n.length>0?(0,V.jsx)(`i`,{}):null}),(0,V.jsx)(`div`,{className:Y(`cs-dtx`,e.fenced&&`font-mono text-[12.5px] whitespace-pre-wrap break-words`),"data-on":r?`true`:void 0,"data-k":/^#{1,6}\s/.test(a)?`h`:void 0,onClick:e=>!e.target.closest(`a`)&&o(),children:e.fenced?e.text:(0,V.jsx)(QL,{text:e.text})}),(0,V.jsx)(`button`,{type:`button`,className:`cs-dcb`,"aria-label":`Comment on this line: ${a}`,onClick:o,children:(0,V.jsx)(dm,{"aria-hidden":`true`,className:`size-[15px]`})})]}),(0,V.jsx)(qU,{notes:n}),r]})});function XU({draft:e,comments:t,commenting:n,form:r,onComment:i}){let a=(0,m.useMemo)(()=>KU(e),[e]),o=vL(a.length);return(0,V.jsx)(`ul`,{className:`cs-drl`,"aria-label":`Draft plan lines`,children:a.slice(0,o).map((e,a)=>e.text.trim()?(0,V.jsx)(YU,{row:e,index:a,notes:t.get(e.text.trim())??JU,form:a===n?r:void 0,onComment:i},a):(0,V.jsx)(`li`,{"aria-hidden":`true`,className:`h-2`},a))})}function ZU({notes:e}){return e.length===0?null:(0,V.jsx)(GB,{title:OU,children:(0,V.jsx)(`dl`,{className:`flex flex-col gap-2 text-sm`,children:e.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex min-w-0 gap-3`,children:[(0,V.jsx)(`dt`,{className:`w-20 shrink-0 font-semibold`,style:{color:NR(e.from)},children:zR(e.from)}),(0,V.jsx)(`dd`,{className:`min-w-0 flex-1`,children:(0,V.jsx)(QL,{text:e.text})})]},t))})})}function QU(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function $U({label:e,hint:t,buttonLabel:n=`Send`,onSend:r}){let i=(0,m.useId)(),[a,o]=(0,m.useState)(``),[s,c]=(0,m.useState)(!1),l=async()=>{a.trim()&&!s&&(c(!0),await r(a)&&o(``),c(!1))};return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium text-foreground`,children:e}),(0,V.jsx)(CB,{id:i,value:a,rows:2,"aria-describedby":t?`${i}-hint`:void 0,onChange:e=>o(e.target.value),onKeyDown:e=>{QU(e)&&(e.preventDefault(),l())}}),t?(0,V.jsx)(`p`,{id:`${i}-hint`,className:`text-xs text-muted-foreground`,children:t}):null,(0,V.jsx)(`div`,{className:`flex self-end`,children:(0,V.jsx)(UI,{label:n,icon:s?am:Rf,tone:`primary`,shortcut:`Enter`,className:s?`[&_svg]:animate-spin`:void 0,onClick:()=>void l(),disabled:!a.trim()||s})})]})}function eW({line:e,onCancel:t,onSent:n}){let r=(0,m.useRef)(null);return(0,m.useEffect)(()=>{let e=r.current?.querySelector(`textarea`);e?.focus(),e?.scrollIntoView({block:`nearest`})},[]),(0,V.jsxs)(`div`,{ref:r,role:`group`,"aria-label":`Comment on this line`,className:`line-comment cs-dform`,children:[(0,V.jsx)(WT,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Cancel the comment`,title:`Cancel · Esc`,onClick:t,className:`absolute top-1.5 right-1.5 size-7`,children:(0,V.jsx)(Fh,{"aria-hidden":`true`})}),(0,V.jsx)($U,{label:`Your comment`,hint:`Enter adds the comment · Esc cancels`,buttonLabel:`Add comment`,onSend:async t=>await U(`planner.commentLine`,{line:e,text:t.trim()})?(n(t.trim()),!0):!1})]})}function tW({open:e,onClose:t,snap:n,comments:r,onSent:i}){let a=(0,m.useRef)(null),[o,s]=(0,m.useState)(),c=(0,m.useMemo)(()=>n.draft?KU(n.draft):[],[n.draft]),l=o===void 0?void 0:c[o]?.text.trim(),u=()=>{let e=o;s(void 0),requestAnimationFrame(()=>a.current?.querySelector(`[data-line="${e}"] button[aria-label^="Comment on this line"]`)?.focus())};return(0,V.jsx)(rD,{open:e,onClose:()=>{s(void 0),t()},label:`Draft plan`,closeText:!0,onEscape:e=>{l!==void 0&&(e.preventDefault(),u())},head:(0,V.jsxs)(`div`,{className:`cs-shtitle`,children:[(0,V.jsx)(`h3`,{children:`Draft plan`}),(0,V.jsxs)(`p`,{children:[n.round>0?`${PU(n.round,n.limit)} · `:``,`choose a line to comment on it`]})]}),children:(0,V.jsxs)(`div`,{ref:a,className:`flex flex-col gap-5`,children:[n.draft?(0,V.jsx)(XU,{draft:n.draft,comments:r,commenting:l===void 0?void 0:o,form:l===void 0?void 0:(0,V.jsx)(eW,{line:l,onCancel:u,onSent:e=>(i(l,e),u())},o),onComment:s}):(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.busy?DU:EU}),(0,V.jsx)(ZU,{notes:n.notes})]})})}function nW({title:e,sub:t,aside:n,className:r,children:i}){let a=(0,m.useRef)(null);function o(e){let t=a.current;if(!t||e.defaultPrevented||e.nativeEvent.isComposing||uE()||e.altKey||e.ctrlKey||e.metaKey||IE(e.target)||e.target instanceof HTMLInputElement)return;let n=LE(e.key);n?(e.preventDefault(),BE(t,e.target,n)):(e.key===`Home`||e.key===`End`)&&(e.preventDefault(),BE(t,e.target,e.key===`Home`?`first`:`last`))}return(0,V.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,V.jsx)(`div`,{ref:a,"data-pane":`list`,className:`cs-scroll pb-dock`,onKeyDown:o,children:(0,V.jsxs)(`div`,{className:Y(`cs-pg`,r),children:[(0,V.jsxs)(`div`,{className:`cs-pgh`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h1`,{className:`cs-hd1`,children:e}),t?(0,V.jsx)(`p`,{className:`cs-hd2`,children:t}):null]}),n?(0,V.jsx)(`div`,{className:`flex flex-none items-center gap-2`,children:n}):null]}),i]})}),(0,V.jsx)(m_,{target:a})]})}function rW({on:e,label:t,count:n,onToggle:r,describe:i}){return(0,V.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,"aria-label":i,className:`cs-chk`,onClick:r,children:[(0,V.jsx)(`span`,{className:`cs-cb`,"data-on":e?`true`:void 0,children:(0,V.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M5 12.5l4.5 4.5L19 7.5`})})}),t,n===void 0?null:(0,V.jsx)(`span`,{className:`cs-cn`,children:n})]})}var iW=()=>bE(yE(`plan`,`previous`)),aW=e=>bE(yE(`plan`,`previous`,e));function oW(e){let t=Date.now()-Date.parse(e);return Number.isFinite(t)?oz(Math.max(0,t)):``}function sW(e,t){return[`${t} message${t===1?``:`s`}`,`round ${e.rounds}`,oW(e.updatedAt)].filter(Boolean).join(` · `)}function cW({plan:e,selected:t}){return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>aW(e.id),className:`cs-trw cs-prw`,children:[(0,V.jsxs)(`span`,{className:`cs-tt1`,children:[(0,V.jsx)(`span`,{className:`cs-t`,children:e.title}),(0,V.jsx)(`span`,{className:`cs-mt`,children:sW(e,e.messages)})]}),e.hasDraft?(0,V.jsx)(`span`,{className:`cs-bdg`,"data-t":`acc`,children:`draft`}):(0,V.jsx)(`span`,{})]})})}function lW({id:e,onGone:t}){let n=_R(`planner.previousGet`,{id:e},[`planner`]),r=n.data;if(!r)return n.error?(0,V.jsx)(wE,{message:`Could not load that plan. ${n.error}`,onRetry:n.reload}):null;let i=!!r.archivedAt,a=async()=>{await U(`planner.previousOpen`,{id:e})&&bE(yE(`plan`))},o=async()=>{await U(`planner.previousArchive`,{id:e,archived:!i})&&t()},s=async()=>{await U(`planner.previousDelete`,{id:e})&&t()};return(0,V.jsxs)(`article`,{className:`cs-dt flex flex-col`,"aria-label":r.title,children:[(0,V.jsxs)(WI,{className:`cs-abm`,children:[(0,V.jsx)(UI,{label:`Carry on planning`,text:`Carry on`,icon:Fm,tone:`primary`,shortcut:`C`,onClick:()=>void a()}),(0,V.jsx)(UI,{label:i?`Bring it back from the archive`:`Archive`,text:i?`Unarchive`:`Archive`,icon:i?Of:Af,shortcut:`E`,onClick:()=>void o()}),(0,V.jsx)(uR,{icon:yh,label:`Delete`,shortcut:`Delete`,title:`Delete "${r.title}"?`,description:`The conversation and the draft are removed for good.`,confirmLabel:`Delete plan`,variant:`destructive`,onConfirm:()=>void s()})]}),(0,V.jsxs)(`header`,{children:[(0,V.jsx)(`h2`,{children:r.title}),(0,V.jsx)(`p`,{className:`cs-sub`,children:[i?`archived`:``,sW(r,r.messages.length),r.seed??``].filter(Boolean).join(` · `)})]}),(0,V.jsxs)(GB,{title:`Draft plan`,children:[r.draft?(0,V.jsx)(QL,{text:r.draft}):(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The panel had not written a draft yet.`}),(0,V.jsx)(ZU,{notes:r.notes})]}),(0,V.jsx)(GB,{title:`Conversation`,children:(0,V.jsx)(`div`,{className:`cs-pvc`,children:(0,V.jsx)(wU,{messages:r.messages,readOnly:!0})})})]})}function uW({id:e}){let[t,n]=(0,m.useState)(!1),r=_R(`planner.previous`,t?{archived:!0}:{},[`planner`]),i=r.data?.plans??[];if(!r.data&&r.error)return(0,V.jsx)(wE,{message:`Could not load the previous plans. ${r.error}`,onRetry:r.reload});let a=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(UI,{label:`Back to the current plan`,text:`Back`,icon:Pf,onClick:()=>bE(yE(`plan`))}),(0,V.jsx)(rW,{on:t,label:`Archived`,describe:t?`Show the previous plans`:`Show the archived plans`,onToggle:()=>{n(e=>!e),iW()}})]}),o=r.data?i.length===0?(0,V.jsx)(`p`,{className:`px-2.5 py-6 text-sm text-muted-foreground`,children:t?`No archived plans.`:`No previous plans. A plan you leave without saving it as a task waits here; one saved as a task is in the Tasks tab.`}):(0,V.jsx)(`ul`,{className:`cs-lst`,"aria-label":t?`Archived plans`:`Previous plans`,children:i.map(t=>(0,V.jsx)(cW,{plan:t,selected:t.id===e},t.id))}):(0,V.jsx)(JE,{});return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(nW,{title:t?`Archived plans`:`Previous plans`,sub:r.data?`${i.length} ${i.length===1?`plan`:`plans`}`:void 0,className:`cs-ts`,aside:a,children:o}),(0,V.jsx)(rD,{open:e!==void 0,onClose:iW,label:`A previous plan`,className:`cs-tdw`,children:e?(0,V.jsx)(lW,{id:e,onGone:()=>{r.reload(),iW()}},e):null})]})}function dW({snap:e,onDone:t}){let n=BU(e),r=(0,m.useRef)(null);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{ref:r,className:`cs-scroll pb-dock`,children:(0,V.jsxs)(`div`,{className:`cs-pg cs-intro`,children:[(0,V.jsx)(`header`,{className:`cs-ih`,children:(0,V.jsxs)(`div`,{className:`cs-ic`,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-ico`,children:(0,V.jsx)(qm,{className:`size-5`})}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{children:`Plan with the panel`}),(0,V.jsx)(`p`,{children:jU})]})]})}),(0,V.jsxs)(`p`,{className:`cs-ipanel`,children:[NU(n),e.limit>0?` · up to ${e.limit} rounds, the last the oracle's`:``,`. Click a seat in the rail at the right to leave it out of this plan.`]}),(0,V.jsxs)(`section`,{"aria-labelledby":`plan-steps`,children:[(0,V.jsx)(`h3`,{id:`plan-steps`,className:`cs-rl`,children:`How a plan comes together`}),(0,V.jsx)(`ol`,{className:`cs-stepg`,children:MU.map((e,t)=>(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-no`,children:t+1}),(0,V.jsxs)(`span`,{className:`min-w-0`,children:[(0,V.jsx)(`b`,{children:e.title}),(0,V.jsx)(`span`,{children:e.text})]})]},e.title))})]}),(0,V.jsxs)(`p`,{className:`cs-starth`,children:[(0,V.jsx)(Mf,{"aria-hidden":`true`,className:`size-4`}),`Start in the box below.`,(0,V.jsx)($T,{chord:`/`,children:`write`}),(0,V.jsx)($T,{chord:`Enter`,children:`send to the panel`})]})]})}),(0,V.jsx)(m_,{target:r}),(0,V.jsx)(GU,{snap:e,onDone:t})]})}function fW(e,t){let n=(0,m.useRef)(t);n.current=t;let r=(0,m.useCallback)(()=>n.current(),[]);tD(`v`,r,{enabled:!!e.draft}),jD(e.draft?r:void 0)}function pW({snap:e,reload:t}){let[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(new Map);fW(e,()=>r(!0));let o=(e,t)=>a(n=>new Map(n).set(e,[...n.get(e)??[],t])),{ref:s,onScroll:c}=DR(`${JSON.stringify(e.messages)}${e.busy}`);return(0,V.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,V.jsxs)(`div`,{ref:s,onScroll:c,className:`cs-thread min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-5 pb-dock`,children:[(0,V.jsx)(HU,{snap:e}),(0,V.jsx)(wU,{messages:e.messages,busy:e.busy})]}),(0,V.jsx)(m_,{target:s}),(0,V.jsx)(GU,{snap:e,onDone:t}),(0,V.jsx)(tW,{open:n,onClose:()=>r(!1),snap:e,comments:i,onSent:o})]})}function mW({rest:e=[]}){return e[0]===`previous`?(0,V.jsx)(uW,{id:e[1]}):(0,V.jsx)(hW,{})}function hW(){let e=_R(`planner.get`,{},[`planner`]),t=e.data;if(!t&&e.error)return(0,V.jsx)(wE,{message:`Could not load the plan. ${e.error}`,onRetry:e.reload});if(!t)return(0,V.jsx)(`p`,{role:`status`,className:`p-5 text-sm text-muted-foreground`,children:`Loading the plan…`});let n=IU(t);return(0,V.jsx)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:n?(0,V.jsx)(dW,{snap:t,onDone:e.reload}):(0,V.jsx)(pW,{snap:t,reload:e.reload})})}var gW={},_W=new Set;function vW(e){gW=e;for(let e of[..._W])e()}function yW(e){gW.taskId!==e&&vW({...gW,taskId:e})}function bW(e){return _W.add(e),()=>{_W.delete(e)}}function xW(){return(0,m.useSyncExternalStore)(bW,()=>gW,()=>gW)}function SW(e,t=0,n=!1){let r=!n&&!e.waiting&&!!e.runningSince,i=r?Date.parse(e.serverNow)-Date.parse(e.runningSince):0;return Math.max(0,e.elapsedMs)+(Number.isFinite(i)?Math.max(0,i):0)+(r?Math.max(0,t):0)}function CW(e){let t=Math.floor(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${t%60}s`:`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m`}function wW(e,t){let[n,r]=(0,m.useState)(0);return(0,m.useEffect)(()=>{if(r(0),!e)return;let t=performance.now(),n=window.setInterval(()=>r(performance.now()-t),1e3);return()=>window.clearInterval(n)},[e,t]),e?n:0}function TW({timing:e,stopped:t}){let[n,r]=(0,m.useState)(0);return(0,m.useEffect)(()=>{if(r(0),t||e.waiting||!e.runningSince)return;let n=performance.now(),i=window.setInterval(()=>r(performance.now()-n),1e3);return()=>window.clearInterval(i)},[e,t]),(0,V.jsxs)(`span`,{className:`tabular-nums break-words`,children:[e.waiting?`Waiting for you · `:``,CW(SW(e,n,t)),` execution`]})}function EW({work:e,timing:t,stopped:n}){let r=e.running&&!n&&!t?.waiting,i=wW(r,e);return(0,V.jsxs)(`span`,{className:`tabular-nums break-words`,"data-work-clock":r?`running`:`stopped`,children:[t?.waiting?`Waiting for you · `:``,`worked `,CW(e.workedMs+i)]})}function DW({timing:e,work:t,stopped:n=!1}){return t?(0,V.jsx)(EW,{work:t,...e?{timing:e}:{},stopped:n}):e?(0,V.jsx)(TW,{timing:e,stopped:n},JSON.stringify(e)):(0,V.jsx)(`span`,{children:`Timing unavailable`})}var OW=`This merges the reviewed commit into main and pushes main, then removes the task worktree after verifying the merge. The task branch is kept.`,kW={pending_approval:`Ready for your review`,deferred:`Saved for later`,in_progress:`Delivery in progress`,successful:`Delivered`,recoverable_failure:`Delivery needs attention`};function AW({delivery:e,title:t}){return(0,V.jsxs)(`div`,{className:`cs-dlv grid gap-2 text-[12.5px]`,children:[(0,V.jsx)(`p`,{className:`text-[13.5px] font-semibold break-words`,children:t}),(0,V.jsxs)(`dl`,{children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{children:`Project`}),(0,V.jsx)(`dd`,{children:e.project})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{children:`Repository`}),(0,V.jsx)(`dd`,{children:e.repository??`Unavailable — refresh review`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{children:`Source`}),(0,V.jsxs)(`dd`,{children:[e.sourceBranch,` · `,e.sourceCommit??`Commit unavailable`]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{children:`Target`}),(0,V.jsxs)(`dd`,{children:[`main`,e.targetCommit?` · ${e.targetCommit}`:``]})]})]}),(0,V.jsxs)(`p`,{children:[`Checks: `,e.verification?.checks??`unavailable`]}),(0,V.jsx)(`p`,{children:e.verification?.summary??`Verification unavailable. Refresh the review before delivery.`}),e.verification?(0,V.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Local completion/QA: `,e.verification.localVerified?`passed`:`not verified`,` · Repository rules: `,e.verification.rulesKnown?`known`:`unavailable`,e.verification.requiredChecks.length?` · Required: ${e.verification.requiredChecks.join(`, `)}`:``]}):null]})}function jW({action:e,delivery:t,busy:n,onAction:r}){let i=t.blocked[e],a=e===`merge_main`&&t.status===`successful`&&!!t.cleanupError,o=n||t.status===`in_progress`||t.status===`successful`&&!a||!!i;return(0,V.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,V.jsx)(WT,{variant:`outline`,size:`sm`,className:`w-fit`,disabled:o,onClick:()=>r(e),children:e===`create_pr`?`Create PR`:a?`Retry worktree cleanup`:`Merge to main`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e===`create_pr`?`Pushes the task branch and opens a PR targeting main. Does not merge.`:a?`Main was delivered. Removes the retained worktree after confirmation.`:`Updates and pushes main, then removes the task worktree. Requires confirmation.`}),i?(0,V.jsxs)(`p`,{className:`text-sm text-destructive`,children:[i,` Refresh review after resolving this restriction, then choose the action again.`]}):null]})}async function MW(e,t,n){let r={taskId:t,reviewId:n};return e===`refresh`?L(`tasks.deliveryReview`,{taskId:t}):e===`defer`?L(`tasks.deliveryDefer`,r):L(`tasks.deliver`,{...r,action:e,...e===`merge_main`?{confirmMain:!0}:{}})}function NW({taskId:e,delivery:t}){let[n,r]=(0,m.useState)(t),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(!1),u=(0,m.useRef)(null),d=pe(),f=`${d}:${e}`,p=(0,m.useRef)(f);return p.current=f,(0,m.useEffect)(()=>(p.current=f,()=>{p.current=``}),[f]),(0,m.useEffect)(()=>{r(t),l(!1)},[t,e]),{current:n,setCurrent:r,busy:i,setBusy:a,error:o,setError:s,confirm:c,setConfirm:l,trigger:u,project:d,identity:f,scope:p}}function PW(e){return e.scope.current===e.identity&&e.project===pe()}function FW(e,t){let n=(0,m.useRef)(!1);async function r(r){if(!(n.current||r===`merge_main`&&!e.confirm)){n.current=!0,e.setBusy(!0),e.setError(void 0),e.setConfirm(!1);try{let n=await MW(r,t.taskId,e.current.reviewId);PW(e)&&(e.setCurrent(n.delivery),t.onChanged())}catch(t){PW(e)&&e.setError(t instanceof Error?t.message:String(t))}finally{n.current=!1,e.scope.current&&e.setBusy(!1)}}}return r}function IW(e){let t=NW(e),n=FW(t,e),r=lE(t.confirm,cE.confirm),i=t.current.status===`successful`||t.current.status===`in_progress`;function a(){t.trigger.current=document.activeElement,t.setConfirm(!0)}return{...t,request:n,slot:r,terminal:i,reviewMerge:a}}function LW({review:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Task completion is recorded separately. Nothing is published without your approval.`}),(0,V.jsx)(`p`,{role:`status`,className:`text-sm`,children:e.busy?`Updating delivery…`:e.current.operation?`Operation: ${e.current.operation.stage}`:kW[e.current.status]}),e.current.error||e.error?(0,V.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.error??e.current.error,` Completed work is retained. Refresh review to reconcile the result before retrying.`]}):null,e.current.cleanupError?(0,V.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.current.cleanupError,` Retry cleanup after resolving it.`]}):null,e.current.operation?.worktreeRemoved?(0,V.jsx)(`p`,{className:`text-sm`,children:`Task worktree removed.`}):null,e.current.result?(0,V.jsxs)(`p`,{className:`text-sm break-all`,children:[e.current.result.action===`create_pr`?`PR #${e.current.result.pullNumber??``} created`:`main pushed · ${e.current.result.commit??``}`,e.current.result.pullUrl?(0,V.jsxs)(`span`,{children:[` · `,e.current.result.pullUrl]}):null]}):null]})}function RW({review:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,V.jsx)(jW,{action:`create_pr`,delivery:e.current,busy:e.busy,onAction:()=>void e.request(`create_pr`)}),(0,V.jsx)(jW,{action:`merge_main`,delivery:e.current,busy:e.busy,onAction:e.reviewMerge})]}),(0,V.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,V.jsx)(WT,{variant:`outline`,size:`sm`,disabled:e.busy,onClick:()=>void e.request(`refresh`),children:`Refresh review`}),(0,V.jsx)(WT,{variant:`ghost`,size:`sm`,disabled:e.busy||e.terminal,onClick:()=>void e.request(`defer`),children:`Not now`})]})]})}function zW({review:e}){let t=e.current.status===`successful`&&!!e.current.cleanupError,n=t?`Main was already delivered. Remove the task worktree if it still contains only the reviewed commit. The task branch is kept.`:OW;return(0,V.jsx)(tE,{open:e.slot,onOpenChange:e.setConfirm,label:t?`Confirm worktree removal`:`Confirm merge to main`,description:n,onCloseAutoFocus:t=>{t.preventDefault(),requestAnimationFrame(()=>e.trigger.current?.focus())},children:(0,V.jsxs)(`div`,{className:`grid gap-3 p-4`,children:[(0,V.jsx)(`h3`,{className:`font-medium`,children:t?`Remove task worktree?`:`Merge to main?`}),(0,V.jsx)(`p`,{className:`text-sm`,children:n}),(0,V.jsxs)(`p`,{className:`break-all text-sm text-muted-foreground`,children:[e.current.repository,` · `,e.current.sourceCommit,` → main`]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,V.jsx)(WT,{variant:`outline`,onClick:()=>e.setConfirm(!1),children:`Cancel`}),(0,V.jsx)(WT,{disabled:e.busy||!!e.current.blocked.merge_main||e.terminal&&!t,onClick:()=>void e.request(`merge_main`),children:t?`Confirm worktree removal`:`Confirm merge and push main`})]})]})})}function BW({title:e,review:t}){return(0,V.jsxs)(GB,{title:`Completed work · delivery review`,right:kW[t.current.status],children:[(0,V.jsxs)(`div`,{className:`cs-sunkbox`,children:[(0,V.jsx)(AW,{delivery:t.current,title:e}),(0,V.jsx)(LW,{review:t}),(0,V.jsx)(RW,{review:t})]}),(0,V.jsx)(zW,{review:t})]})}function VW(e){let t=IW(e);return(0,V.jsx)(BW,{title:e.title,review:t})}var HW={open:_p,delivered:dp,addressed:sp},UW={open:`waiting for the owning session`,delivered:`sent to the oracle`,addressed:`plan amended`};function WW({comment:e}){let t=oz(Date.now()-Date.parse(e.createdAt)),n=HW[e.status];return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(n,{"aria-hidden":`true`,className:`size-3.5`}),UW[e.status],`, `,t,e.editedAt?` (edited)`:``]})}function GW({comment:e,taskId:t,own:n}){let[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(),s=a&&(a.editedAt??``)>(e.editedAt??``)?a:e;return(0,V.jsxs)(`li`,{className:`cs-cmc`,children:[r?(0,V.jsx)(_U,{text:s.text,onSave:async n=>{let r=await L(`tasks.editComment`,{taskId:t,commentId:e.id,text:n});o(r.comment)},onCancel:()=>i(!1)}):(0,V.jsx)(QL,{text:s.text}),(0,V.jsxs)(`div`,{className:`cs-cmeta`,"data-s":s.status,children:[(0,V.jsx)(WW,{comment:s}),n&&!r?(0,V.jsx)(`button`,{type:`button`,className:`cs-eb`,onClick:()=>i(!0),children:`Edit`}):null]})]})}function KW({taskId:e,onAdded:t}){let[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),c=(0,m.useId)();if(!n)return(0,V.jsxs)(WT,{size:`sm`,variant:`outline`,className:`w-fit`,onClick:()=>r(!0),children:[(0,V.jsx)(dm,{"aria-hidden":`true`}),`Add comment`]});let l=async()=>{if(o||!i.trim())return;s(!0);let n=await U(`tasks.comment`,{taskId:e,text:i.trim()})!==void 0;s(!1),n&&(a(``),r(!1),t())};return(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{htmlFor:c,className:`sr-only`,children:`Your comment`}),(0,V.jsx)(`textarea`,{id:c,autoFocus:!0,className:`cs-ta2`,placeholder:`Your comment`,value:i,disabled:o,onChange:e=>a(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),r(!1)):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),l()))}}),(0,V.jsxs)(`div`,{className:`cs-fa`,children:[(0,V.jsx)(`span`,{className:`cs-hint2`,children:`Enter adds the comment · Esc cancels`}),(0,V.jsx)(WT,{size:`sm`,variant:`ghost`,disabled:o,onClick:()=>r(!1),children:`Cancel`}),(0,V.jsx)(WT,{size:`sm`,disabled:o||!i.trim(),onClick:()=>void l(),children:`Add comment`})]})]})}function qW({taskId:e,finished:t,canComment:n}){let r=_R(`tasks.comments`,{taskId:e},[`tasks`]),i=FE(`status`),a=r.data?.comments??[],o=a.filter(e=>e.status!==`addressed`).length;return(0,V.jsxs)(`section`,{"aria-labelledby":`comments-${e}`,className:`cs-sec flex flex-col gap-3`,children:[(0,V.jsxs)(`h3`,{id:`comments-${e}`,className:`cs-rl`,children:[`Comments`,o>0?(0,V.jsxs)(`span`,{className:`cs-rr`,children:[o,` open`]}):null]}),a.length===0?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?`No comments.`:n?`No comments yet. Comment on the plan here or in the box below (Markdown and images work there); the oracle amends it.`:`No comments yet.`}):(0,V.jsx)(`ul`,{className:`cs-cm`,children:a.map(t=>(0,V.jsx)(GW,{taskId:e,comment:t,own:!!(t.by&&t.by===i.data?.sessionId)},`${e}-${t.id}`))}),n?(0,V.jsx)(KW,{taskId:e,onAdded:r.reload}):null]})}var JW={mine:`This session`,others:`Other sessions`,pending:`Pending`,recent:`Finished`,archived:`Archived`},YW={open:`open`,done:`done`,dropped:`abandoned`},XW={none:{label:`None`,depth:`nothing that runs changed: the engine's checks decide, no QA agent`,tone:``},low:{label:`Low`,depth:`a light check: the diff, the nearest tests, done once confident`,tone:`ok`},medium:{label:`Medium`,depth:`a standard check: the acceptance criteria and realistic regressions`,tone:`warn`},high:{label:`High`,depth:`a deep, adversarial review: invariants, recovery and everything the change reaches`,tone:`bad`}};function ZW(e){let t=e.source===`classifier`?`Jev`:`rules`;if(!e.qaRequired)return`${t} · no QA agent`;let{min:n,max:r}=e.testBudget;return`${t} · ${n===r?r:`${n}-${r}`} new tests at most`}var QW=`No tasks yet. Start one from the Lobby tab, or plan one in the Plan tab.`;function $W(e,t){return`${e.replace(/_/g,` `)}${t?` · paused`:``}`}function eG(e){return e===`now`?`just now`:`${e} ago`}function tG(e){if(e.kind===`plan`)return[`planned`,e.age?e.age===`now`?`saved just now`:`saved ${e.age} ago`:``,e.issue?`#${e.issue}`:``].filter(Boolean).join(` · `);let t=e.owner??(e.section===`mine`?`this session`:``);return[$W(e.status,e.paused),t].filter(Boolean).join(` · `)}function nG(e){let t=[];for(let n of e){let e=t.at(-1);e&&e.section===n.section?e.rows.push(n):t.push({section:n.section,rows:[n]})}return t}function rG(e){let t=e.filter(e=>e.kind!==`archived`),n=t.filter(e=>e.check===`open`).length,r=t.length-n,i=e.length-t.length;return[n?`${n} open`:``,r?`${r} finished`:``,i?`${i} archived`:``].filter(Boolean).join(` · `)||`0`}var iG=1e3;function aG({taskId:e,index:t,text:n,onSkipped:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(``),f=lE(i,cE.confirm),p=(0,m.useId)(),h=(0,m.useId)(),g=o.trim(),_=e=>{c||(a(e),s(``),d(``))},v=async()=>{if(g&&!c){l(!0),d(``);try{H((await L(`tasks.skipStep`,{taskId:e,step:t,text:n,reason:g})).notice),a(!1),s(``),r()}catch(e){d(e instanceof Error?e.message:`That did not work. Try again.`)}finally{l(!1)}}};return(0,V.jsxs)(nR,{open:i&&f,onOpenChange:_,children:[(0,V.jsxs)(`button`,{type:`button`,"aria-label":`Skip step ${t+1}`,onClick:()=>_(!0),className:`cs-skp step-skip`,children:[(0,V.jsx)(rh,{"aria-hidden":`true`,className:`size-3.5`}),`Skip`]}),(0,V.jsxs)(rR,{children:[(0,V.jsxs)(iR,{children:[(0,V.jsxs)(oR,{children:[`Skip step `,t+1,`?`]}),(0,V.jsx)(sR,{children:`The oracle is told to carry on without it, and your reason stays with the step in the task's history.`})]}),(0,V.jsx)(`p`,{className:`rounded-md bg-muted px-2.5 py-1.5 text-sm break-words`,children:n}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`label`,{htmlFor:p,className:`text-sm font-medium`,children:`Why skip it?`}),(0,V.jsx)(CB,{id:p,value:o,autoFocus:!0,required:!0,maxLength:iG,disabled:c,"aria-describedby":h,"aria-invalid":u?!0:void 0,placeholder:`Already done by hand, not needed any more, out of scope…`,className:`max-h-48 min-h-20`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),v())}}),(0,V.jsx)(`p`,{id:h,className:`text-xs text-muted-foreground`,children:`A reason is required.`})]}),u?(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:u}):null,(0,V.jsxs)(aR,{children:[(0,V.jsx)(lR,{disabled:c,children:`Cancel`}),(0,V.jsx)(WT,{disabled:!g||c,"aria-busy":c,onClick:()=>void v(),children:c?`Skipping…`:`Skip step`})]})]})]})}function oG({step:e,stopped:t}){let n=wW(!t,e);return(0,V.jsx)(`span`,{className:`tabular-nums`,children:CW((e.workedMs??0)+n)})}function sG(e){return(e.split(`
|
|
100
|
+
`).find(e=>e.trim())?.trim()??``).replace(/^steps?\s+\d+(?:\s*[-–]\s*\d+)?\s*[:.\-–]\s*/i,``).replace(/^\*\*?goal\*\*?\s*[:\-–]\s*/i,``)}var cG=e=>UR({domain:e.domain});function lG({id:e,agents:t,stepText:n}){let[r,i]=(0,m.useState)(Date.now);(0,m.useEffect)(()=>{let e=window.setInterval(()=>i(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let a=t.filter(e=>!e.parentRunId||!t.some(t=>t.runId===e.parentRunId)).flatMap(e=>[e,...t.filter(t=>t.parentRunId===e.runId)]);return(0,V.jsx)(`ul`,{id:e,"aria-label":`Agents on this step`,className:`cs-arows`,children:a.map(e=>{let i=cG(e),a=!!e.parentRunId&&t.some(t=>t.runId===e.parentRunId),o=Date.parse(e.startedAt),s=sG(e.instruction),c=s&&s.toLowerCase()!==n.trim().toLowerCase()?s:``;return(0,V.jsxs)(`li`,{className:`cs-arow`,"data-child":a?`true`:void 0,style:{"--ac":NR(i)},children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-bt`}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-be`}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-tile`,children:zR(i)[0]}),(0,V.jsxs)(`span`,{className:`cs-ab2`,children:[(0,V.jsxs)(`span`,{className:`cs-ab2h`,children:[(0,V.jsx)(`b`,{children:zR(i)}),a?(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`child`}):null,(0,V.jsx)(`span`,{className:`cs-live`,children:`working`})]}),c?(0,V.jsx)(`span`,{className:`cs-br`,title:e.instruction,children:c}):null]}),Number.isFinite(o)?(0,V.jsx)(`span`,{className:`cs-tm`,children:CW(Math.max(0,r-o))}):null]},e.runId)})})}function uG({agents:e,count:t,step:n,stopped:r}){let i=[...new Set(e.map(cG))].slice(0,3);return(0,V.jsxs)(V.Fragment,{children:[i.length>0?(0,V.jsx)(`span`,{className:`cs-avs`,"aria-hidden":`true`,children:i.map(e=>(0,V.jsx)(`i`,{style:{"--ac":NR(e)},children:zR(e)[0]},e))}):null,(0,V.jsxs)(`span`,{className:`cs-cn1`,children:[t,` `,r?t===1?`agent`:`agents`:`working`]}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`cs-dm`,children:`·`}),(0,V.jsx)(oG,{step:n,stopped:r})]})}function dG(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString(void 0,{day:`numeric`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function fG({step:e,index:t}){let n=e.skip?dG(e.skip.at):``;return(0,V.jsxs)(`li`,{className:`cs-stp`,"data-k":`skip`,"data-step":`skipped`,children:[(0,V.jsxs)(`div`,{className:`cs-stpa`,children:[(0,V.jsx)(ez,{mark:`skip`}),(0,V.jsxs)(`span`,{className:`cs-n`,children:[t+1,`.`]}),(0,V.jsx)(`span`,{className:`cs-tx`,children:e.text}),(0,V.jsx)(`span`,{className:`cs-skd`,children:`skipped`})]}),e.skip?(0,V.jsxs)(`p`,{className:`cs-why step-skip-reason`,children:[(0,V.jsx)(`b`,{children:`Why: `}),e.skip.reason,n?(0,V.jsxs)(`span`,{className:`text-[var(--faint)]`,children:[` · `,n]}):null]}):null]})}function pG({step:e,index:t,stopped:n,skip:r}){let i=!!e.active&&!n,a=i?e.agents??[]:[],o=a.length||(e.activeAgentCount??1),[s,c]=(0,m.useState)(!0),l=(0,m.useId)(),u=e.status===`done`;if(e.status===`skipped`)return(0,V.jsx)(fG,{step:e,index:t});let d=e.status===`current`&&!n;return(0,V.jsxs)(`li`,{className:`cs-stp`,"data-k":i?`now`:u?`done`:d?`next`:`todo`,"data-step":i?`active`:e.status,children:[(0,V.jsxs)(`div`,{className:`cs-stpa`,children:[(0,V.jsx)(ez,{mark:i?`now`:u?`done`:`open`}),(0,V.jsxs)(`span`,{className:`cs-n`,children:[t+1,`.`]}),(0,V.jsx)(`span`,{className:`cs-tx`,children:e.text}),i?(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":a.length>0?s:void 0,"aria-controls":a.length>0?l:void 0,disabled:a.length===0,onClick:()=>c(e=>!e),className:`cs-abdg`,children:[(0,V.jsx)(uG,{agents:a,count:o,step:e,stopped:n}),a.length>0?(0,V.jsx)(Zf,{"aria-hidden":`true`,className:`size-3`}):null,(0,V.jsx)(`span`,{className:`sr-only`,children:` (being worked on now)`})]}):d?(0,V.jsxs)(`span`,{className:`cs-nx`,children:[`next`,(0,V.jsx)(`span`,{className:`sr-only`,children:` (the step up next)`})]}):null,r&&!u&&!n?(0,V.jsx)(aG,{taskId:r.taskId,index:t,text:e.text,onSkipped:r.onSkipped}):null]}),s&&a.length>0?(0,V.jsx)(lG,{id:l,agents:a,stepText:e.text}):null]})}function mG({steps:e,stopped:t,skip:n}){let r=e.filter(e=>e.status===`skipped`).length;return(0,V.jsx)(GB,{title:`Steps`,...r?{right:`${r} skipped`}:{},children:(0,V.jsx)(`ol`,{className:`cs-stl`,"aria-label":`Steps`,children:e.map((e,r)=>(0,V.jsx)(pG,{step:e,index:r,stopped:t,skip:n},`${r}-${e.text}`))})})}function hG({text:e}){let[t,n]=(0,m.useState)(!1),r=(0,m.useId)();return(0,V.jsxs)(GB,{title:`Full plan`,children:[(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":r,onClick:()=>n(e=>!e),className:`cs-fold w-fit`,children:[(0,V.jsx)(tp,{"aria-hidden":`true`,className:`size-4`}),t?`Hide the details`:`Read the details of each step`]}),t?(0,V.jsx)(`div`,{id:r,className:`cs-fpb`,children:(0,V.jsx)(QL,{text:e})}):null]})}function gG({detail:e,finished:t}){return e.plan&&e.planDetails?(0,V.jsx)(hG,{text:e.planDetails}):e.plan?(0,V.jsx)(GB,{title:`Approved plan`,children:(0,V.jsx)(QL,{text:e.plan})}):e.proposal?(0,V.jsx)(GB,{title:t?`Proposal`:`Proposal (no plan yet)`,children:(0,V.jsx)(QL,{text:e.proposal})}):(0,V.jsx)(GB,{title:`Plan`,children:(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?`It ended before a plan was made.`:`No proposal or plan yet — the oracle is still clarifying or scouting.`})})}function _G({amendments:e}){return e.length===0?null:(0,V.jsx)(GB,{title:`Amendments`,children:(0,V.jsx)(`ul`,{className:`cs-bl`,children:e.map(e=>(0,V.jsx)(`li`,{className:`break-words`,children:e},e))})})}function vG({risk:e}){let t=XW[e.risk];return(0,V.jsxs)(GB,{title:`QA risk`,right:ZW(e),children:[(0,V.jsxs)(`p`,{className:`cs-qa1`,"data-qa-risk":e.risk,children:[(0,V.jsx)(`span`,{className:`cs-bdg`,"data-t":t.tone,children:t.label}),(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:t.depth})]}),e.focusAreas.length>0?(0,V.jsx)(`ul`,{className:`cs-bl`,"aria-label":`What QA looks at first`,children:e.focusAreas.map(e=>(0,V.jsx)(`li`,{className:`break-words`,children:e},e))}):null,(0,V.jsxs)(`p`,{className:`cs-qaf`,children:[e.riskFactors.join(` · `),e.qaRequired?` · existing tests ${e.existingTestsLikelySufficient?`likely enough`:`likely not enough`}`:``]})]})}function yG({runs:e}){return e.length===0?null:(0,V.jsx)(GB,{title:`Recent runs`,children:(0,V.jsx)(`ul`,{className:`cs-bl cs-plain`,children:e.map((e,t)=>(0,V.jsx)(`li`,{className:`break-words`,children:e},`${t}-${e}`))})})}function bG({detail:e,finished:t,skip:n}){return(0,V.jsxs)(V.Fragment,{children:[e.steps.length>0?(0,V.jsx)(mG,{steps:e.steps,stopped:t,skip:n}):null,e.request?(0,V.jsx)(GB,{title:`Request`,children:(0,V.jsx)(QL,{text:e.request})}):null,(0,V.jsx)(gG,{detail:e,finished:t})]})}function xG({detail:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(_G,{amendments:e.amendments}),e.qaRisk?(0,V.jsx)(vG,{risk:e.qaRisk}):null,(0,V.jsx)(yG,{runs:e.runs})]})}function SG({row:e,quiet:t=!1}){let n=(0,m.useRef)(!0);(0,m.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]);async function r(){if(e.section===`mine`)return bE(`#/lobby`);let t=pe(),r=()=>n.current&&pe()===t;try{let t=await L(`tasks.open`,{taskId:e.id});if(!r())return;let n=await L(`status.get`,{});if(!r())return;if(t.sessionId&&t.sessionId===n.sessionId)return bE(`#/lobby`);if(t.sessionId&&!t.key)return H.info(`This task runs in another terminal. Switch to that terminal to work on it.`);if(n.busy)return H.info(`The oracle is working in this window. Stop it first, then open the task in its session.`);await U(`sessions.switch`,t.key?{key:t.key}:{claimTaskId:e.id})&&r()&&bE(`#/lobby`)}catch(e){r()&&H.error(e instanceof Error?e.message:String(e))}}let i=e.section===`mine`;return(0,V.jsx)(UI,{label:i?`Open in its session: this window`:`Open in its session`,text:`Open in session`,icon:If,tone:t?`neutral`:`primary`,shortcut:`S`,onClick:()=>void r()})}function CG({split:e}){let t=e.after.length>0?`, after ${e.after.map(e=>`part ${e}`).join(` and `)}`:``;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[(0,V.jsxs)(`span`,{className:`font-medium text-primary`,children:[`part `,e.part,` of `,e.of]}),` of one plan that was split into tasks`,t?(0,V.jsx)(`span`,{className:`text-foreground`,children:t}):null]}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.titles.map((t,n)=>(0,V.jsxs)(`span`,{children:[n>0?(0,V.jsx)(`span`,{className:`text-muted-foreground/60`,children:` · `}):null,(0,V.jsxs)(`span`,{className:n+1===e.part?`font-medium text-foreground`:void 0,children:[n+1,`. `,t]})]},`${n}-${t}`))})]})}function wG({planId:e}){let t=_R(`plans.get`,{planId:e},[`plans`]),n=t.data;return n?(0,V.jsxs)(V.Fragment,{children:[n.issue?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`from issue #`,n.issue.number,` — `,n.issue.title,n.issue.url?(0,V.jsxs)(`span`,{className:`break-all`,children:[` `,n.issue.url]}):null]}):null,n.split?(0,V.jsx)(CG,{split:n.split}):null,(0,V.jsx)(GB,{title:`Agreed plan`,children:(0,V.jsx)(QL,{text:n.brief})})]}):t.error?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the agreed plan. `,t.error]}):null}function TG({row:e,onGone:t}){let n=async n=>{await U(`plans.start`,{planId:e.id,where:n})&&t()},r=async()=>{await U(`plans.discard`,{planId:e.id})&&t()};return(0,V.jsxs)(WI,{children:[(0,V.jsx)(UI,{label:`Start here`,icon:Fm,tone:`primary`,shortcut:`S`,onClick:()=>void n(`here`)}),(0,V.jsx)(UI,{label:`Start in a new session`,text:`New session`,icon:sh,shortcut:`N`,onClick:()=>void n(`session`)}),(0,V.jsx)(uR,{icon:yh,label:`Discard`,shortcut:`Delete`,title:`Discard "${e.title}"?`,description:`The saved plan is removed from the list. This cannot be undone.`,confirmLabel:`Discard`,variant:`destructive`,onConfirm:()=>void r()})]})}function EG({row:e}){return(0,V.jsxs)(`article`,{className:`cs-dt flex min-w-0 flex-col`,"aria-label":e.title,children:[(0,V.jsxs)(`header`,{children:[(0,V.jsxs)(`h2`,{children:[(0,V.jsx)(tz,{check:`open`}),(0,V.jsx)(`span`,{className:`min-w-0 break-words`,children:e.title})]}),(0,V.jsxs)(`p`,{className:`cs-sub`,children:[(0,V.jsx)(`span`,{className:`cs-bdg`,children:`planned`}),e.age?(0,V.jsxs)(`span`,{children:[`saved `,eG(e.age)]}):null]}),(0,V.jsx)(`p`,{className:`cs-ids`,children:e.id})]}),(0,V.jsx)(wG,{planId:e.id})]})}function DG({row:e,onResumed:t}){let[n,r]=(0,m.useState)(!1),i=(0,m.useRef)(!0);(0,m.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]);async function a(){let n=pe();r(!0);try{let r=await L(`tasks.resume`,{taskId:e.id});if(pe()!==n)return;H(r.notice,{action:{label:`View task`,onClick:()=>bE(yE(`tasks`,e.id))}}),t()}catch(e){pe()===n&&H.error(e instanceof Error?e.message:String(e))}finally{i.current&&r(!1)}}let o=e.owner===`not running`;return(0,V.jsx)(UI,{label:o?`Resume: carry it on in a background session`:`Resume: unpause it where it runs`,text:`Resume`,icon:Fm,tone:`primary`,shortcut:`R`,disabled:n,onClick:()=>void a()})}function OG(e){return e instanceof Error?e.message:`That did not work. Try again.`}function kG({run:e,onDone:t}){let[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(``);return{open:n,change:e=>{o||(r(e),a(``),l(``))},typed:i,setTyped:a,busy:o,error:c,submit:async()=>{s(!0),l(``);try{H((await e(i)).notice),r(!1),t()}catch(e){l(OG(e))}finally{s(!1)}}}}function AG({expected:e,value:t,onChange:n,disabled:r}){let i=(0,m.useId)();return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium`,children:`Type the task's title to confirm`}),(0,V.jsx)(`p`,{className:`break-words rounded-md bg-muted px-2 py-1 font-mono text-xs select-all`,children:e}),(0,V.jsx)(xB,{id:i,value:t,disabled:r,autoComplete:`off`,spellCheck:!1,onChange:e=>n(e.target.value)})]})}function jG(e){let t=kG(e),n=lE(t.open,cE.confirm),r=e.typeToConfirm!==void 0&&t.typed!==e.typeToConfirm,i=e.tone??`neutral`;return(0,V.jsxs)(nR,{open:t.open&&n,onOpenChange:t.change,children:[(0,V.jsx)(UI,{label:e.label,icon:e.icon,tone:i,onClick:()=>t.change(!0)}),(0,V.jsxs)(rR,{children:[(0,V.jsxs)(iR,{children:[(0,V.jsx)(oR,{children:e.title}),(0,V.jsx)(sR,{children:e.description})]}),e.typeToConfirm===void 0?null:(0,V.jsx)(AG,{expected:e.typeToConfirm,value:t.typed,onChange:t.setTyped,disabled:t.busy}),t.error?(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:t.error}):null,(0,V.jsxs)(aR,{children:[(0,V.jsx)(lR,{disabled:t.busy,children:`Cancel`}),(0,V.jsx)(WT,{variant:i===`danger`?`destructive`:`default`,disabled:r||t.busy,"aria-busy":t.busy,onClick:()=>void t.submit(),children:t.busy?`Working…`:e.confirmLabel})]})]})]})}function MG({taskId:e,item:t,onDone:n}){let r=n=>()=>L(`tasks.resolveApproval`,{taskId:e,approvalId:t.id,decision:n}),i=`${t.kind}${t.domain?` for ${t.domain}`:``}`;return(0,V.jsxs)(`span`,{className:`flex flex-wrap gap-1.5`,children:[(0,V.jsx)(jG,{label:`Approve`,icon:Yf,title:`Approve the ${i}?`,description:`${t.detail} The task's oracle is told and carries on with it.`,confirmLabel:`Approve`,run:r(`approved`),onDone:n}),(0,V.jsx)(jG,{label:`Reject`,icon:Fh,tone:`danger`,title:`Reject the ${i}?`,description:`${t.detail} The task's oracle is told and works without it.`,confirmLabel:`Reject`,run:r(`rejected`),onDone:n})]})}function NG({taskId:e,item:t,live:n,onDone:r}){return(0,V.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-1 basis-60 gap-2`,children:[(0,V.jsx)(ap,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-[var(--warn)]`}),(0,V.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[t.kind,` `,t.detail]})]}),n&&t.id?(0,V.jsx)(MG,{taskId:e,item:t,onDone:r}):null]})}function PG({blockers:e}){return e.map((e,t)=>(0,V.jsxs)(`li`,{className:`flex gap-2`,children:[(0,V.jsx)(hp,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-[var(--bad)]`}),(0,V.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[e.reason,` (needs: `,e.need,`)`]})]},`${t}-${e.reason}`))}function FG({row:e,detail:t,onChanged:n}){let r=e.id;return(0,V.jsxs)(`div`,{className:`cs-wacts`,children:[e.resumable?(0,V.jsx)(DG,{row:e,onResumed:n}):null,t.canAccept?(0,V.jsx)(jG,{label:`Accept as is`,icon:th,title:`Accept "${e.title}" as is?`,description:`You accept the work unverified: missing QA and lint checks are waived on your word. The task's oracle is asked to complete it; nothing is merged.`,confirmLabel:`Accept as is`,run:()=>L(`tasks.accept`,{taskId:r}),onDone:n}):null,t.canForceClose?(0,V.jsx)(jG,{label:`Force close`,icon:pp,tone:`danger`,title:`Force close "${e.title}"?`,description:`The task is abandoned and its running work cancelled. Its code, worktree and history are kept; it is not marked complete.`,confirmLabel:`Force close`,typeToConfirm:e.title,run:e=>L(`tasks.forceClose`,{taskId:r,title:e}),onDone:n}):null]})}function IG({row:e,detail:t,onChanged:n}){let r=e.kind===`task`&&e.check===`open`,i=r&&!!(e.resumable||t.canAccept||t.canForceClose),a=t.waiting;return a.length===0&&t.blockers.length===0&&!i?null:(0,V.jsx)(GB,{title:`Waiting on`,children:(0,V.jsxs)(`div`,{className:`cs-sunkbox cs-cal`,children:[(0,V.jsxs)(`ul`,{className:`flex flex-col gap-2.5 text-[13px]`,children:[a.map((t,i)=>(0,V.jsx)(NG,{taskId:e.id,item:t,live:r,onDone:n},`${i}-${t.id||t.kind}`)),(0,V.jsx)(PG,{blockers:t.blockers})]}),i?(0,V.jsx)(FG,{row:e,detail:t,onChanged:n}):null]})})}function LG(e){if(e.kind===`archived`)return{state:`archived`,rest:eG(e.age??`now`)};let t=e.check!==`open`,n=e.owner??(e.section===`mine`?`this session`:``),r=t&&e.age?`${e.check===`dropped`?`dropped`:`done`} ${eG(e.age)}`:``;return{state:$W(e.status,e.paused),rest:[t?``:n,r].filter(Boolean).join(` · `)}}function RG(e){return e?[QR(e.track),e.domains.join(`, `)].filter(Boolean).join(` · `):``}function zG({row:e}){return e.progress?(0,V.jsxs)(`p`,{className:`cs-prog`,children:[(0,V.jsx)($R,{done:e.progress.done,total:e.progress.total}),(0,V.jsxs)(`span`,{children:[e.progress.done,` of `,e.progress.total,` steps`]})]}):null}function BG({row:e,task:t}){let n=t?.git?`branch ${t.git.branch}${t.git.from?` · from ${t.git.from}`:``}`:``,{state:r,rest:i}=LG(e),[a,o]=(0,m.useState)(!1),s=(0,m.useId)();return(0,V.jsxs)(`header`,{children:[(0,V.jsxs)(`h2`,{children:[(0,V.jsx)(tz,{check:e.check}),(0,V.jsxs)(`span`,{className:`sr-only`,children:[YW[e.check],`:`]}),(0,V.jsx)(`span`,{className:e.check===`dropped`?`min-w-0 break-words line-through`:`min-w-0 break-words`,children:e.title})]}),(0,V.jsxs)(`p`,{className:`cs-sub`,children:[(0,V.jsx)(`span`,{className:`cs-bdg`,"data-t":e.check===`done`?`ok`:e.timing?.waiting?`warn`:e.check===`open`?`acc`:void 0,children:r}),i?(0,V.jsx)(`span`,{children:i}):null,(0,V.jsx)(`button`,{type:`button`,className:`cs-dtl`,"aria-expanded":a,"aria-controls":s,onClick:()=>o(e=>!e),children:a?`Hide details`:`Details`})]}),a?(0,V.jsx)(`p`,{id:s,className:`cs-ids`,children:[e.id,RG(t),n].filter(Boolean).join(` · `)}):null,(0,V.jsx)(zG,{row:e})]})}function VG({row:e,onGone:t,onChanged:n}){let r=e.id;return{restore:async()=>{await U(`tasks.restore`,{taskId:r},{undo:()=>void U(`tasks.archive`,{taskId:r})})&&t()},archive:async()=>{await U(`tasks.archive`,{taskId:r},{undo:()=>void U(`tasks.restore`,{taskId:r})})&&t()},remove:async()=>{await U(`tasks.delete`,{taskId:r,where:e.kind===`archived`?`archive`:`list`})&&t()},toggleAuto:()=>void U(`tasks.auto`,{taskId:r,on:!e.auto}).then(n)}}function HG({row:e,archive:t}){return e.check===`open`?(0,V.jsx)(uR,{label:`Archive`,icon:Af,shortcut:`E`,title:`Archive "${e.title}"?`,description:`A task still under way is abandoned first, then moved to the archive. Restore brings it back.`,confirmLabel:`Archive`,onConfirm:()=>void t()}):(0,V.jsx)(UI,{label:`Archive`,icon:Af,shortcut:`E`,onClick:()=>void t()})}function UG({on:e,toggle:t}){return tD(`a`,t),(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:(0,V.jsxs)(`label`,{className:`cs-autol`,children:[(0,V.jsx)(zm,{"aria-hidden":`true`,className:`size-3.5`}),(0,V.jsx)(`span`,{children:`Auto`}),(0,V.jsx)(SB,{small:!0,checked:e,onCheckedChange:t,"aria-label":`Auto mode`,"aria-keyshortcuts":`A`}),(0,V.jsx)(QT,{chord:`A`,className:`kbd-hint`})]})}),(0,V.jsx)(VI,{children:`Auto mode: the oracle decides without asking`})]})}function WG(e){return e.row.kind===`plan`?(0,V.jsx)(TG,{row:e.row,onGone:e.onGone}):(0,V.jsx)(GG,{...e})}function GG(e){let{row:t}=e,{restore:n,archive:r,remove:i,toggleAuto:a}=VG(e),o=t.kind===`archived`,s=t.kind===`task`&&t.check===`open`&&!!t.resumable;return(0,V.jsxs)(WI,{children:[t.kind===`task`&&t.check===`open`?(0,V.jsx)(SG,{row:t,quiet:s}):null,o?(0,V.jsx)(UI,{label:`Restore`,icon:Um,shortcut:`R`,onClick:()=>void n()}):null,t.check===`open`&&!o?(0,V.jsx)(UG,{on:!!t.auto,toggle:a}):null,o?null:(0,V.jsx)(HG,{row:t,archive:r}),(0,V.jsx)(uR,{icon:yh,label:o?`Delete for good`:`Delete`,text:`Delete`,shortcut:`Delete`,title:`Delete "${t.title}" for good?`,description:`This cannot be undone.`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:()=>void i()})]})}function KG(e){let{row:t}=e,n=t.kind===`plan`,r=_R(`tasks.get`,{taskId:t.id},[`tasks`],!n),i=FE(`lobby`).data?.task,a=i?.id===t.id?i:void 0;if(n)return(0,V.jsx)(EG,{row:t});let o=t.check===`open`&&t.kind===`task`,s=r.data?r.data.work:t.work;return(0,V.jsxs)(`article`,{className:`cs-dt flex min-w-0 flex-col`,"aria-label":t.title,children:[(0,V.jsx)(BG,{row:t,task:a}),r.data?(0,V.jsx)(IG,{row:t,detail:r.data,onChanged:()=>{r.reload(),e.onChanged()}}):null,(0,V.jsx)(`p`,{className:`mt-2 text-[12.5px] text-muted-foreground`,children:(0,V.jsx)(DW,{timing:r.data?.timing??t.timing,...s?{work:s}:{},stopped:t.check!==`open`})}),r.data?.delivery?(0,V.jsx)(VW,{taskId:t.id,title:t.title,delivery:r.data.delivery,onChanged:r.reload},t.id):null,r.data?(0,V.jsx)(bG,{detail:r.data,finished:!o,...o&&r.data.canSkip?{skip:{taskId:t.id,onSkipped:()=>{r.reload(),e.onChanged()}}}:{}}):null,(0,V.jsx)(qW,{taskId:t.id,finished:!o,canComment:o}),r.data?(0,V.jsx)(xG,{detail:r.data}):null,r.error&&!r.data?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the plan detail. `,r.error]}):null]})}function qG({row:e}){let t=e.work,n=!!t?.running&&e.check===`open`&&!e.timing?.waiting,r=wW(n,t??{workedMs:0,running:!1});if(!t||e.kind===`plan`)return(0,V.jsx)(`span`,{className:`cs-ttm`});let i=CW(t.workedMs+r);return(0,V.jsx)(`span`,{className:`cs-ttm`,"data-work-clock":n?`running`:`stopped`,children:i.replace(/ \d+s$/,``)})}function JG(e){return e.kind===`archived`?``:e.delivery?`delivery ${e.delivery.status.replaceAll(`_`,` `)}`:e.kind===`plan`||e.check===`open`?`${e.timing?.waiting?`waiting for you · `:``}${tG(e)}${e.auto?` · auto`:``}`:``}function YG(e){return e.check===`dropped`?`drop`:e.kind===`archived`?`arch`:e.check===`done`?`done`:`open`}function XG({row:e,selected:t,onSelect:n,head:r,count:i}){let a=e.kind!==`plan`&&e.progress&&e.progress.total>0?e.progress:void 0;return(0,V.jsxs)(`li`,{children:[r?(0,V.jsxs)(`h3`,{className:`cs-tsec`,children:[JW[e.section],(0,V.jsx)(`b`,{children:i})]}):null,(0,V.jsxs)(`button`,{type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,onClick:()=>n(e.id),className:`cs-trw`,children:[(0,V.jsx)(tz,{check:e.check}),(0,V.jsxs)(`span`,{className:`cs-tt1`,children:[(0,V.jsxs)(`span`,{className:`sr-only`,children:[YW[e.check],`:`]}),(0,V.jsx)(`span`,{className:`cs-t`,"data-k":YG(e),children:e.title}),(0,V.jsx)(`span`,{className:`cs-mt`,"data-w":e.timing?.waiting?`warn`:void 0,children:JG(e)})]}),(0,V.jsx)(`span`,{className:`cs-tpg`,children:a?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($R,{done:a.done,total:a.total}),(0,V.jsxs)(`span`,{children:[a.done,`/`,a.total]})]}):null}),(0,V.jsx)(qG,{row:e}),(0,V.jsx)(`span`,{className:`cs-tag`,children:e.age??``})]})]})}function ZG({rows:e,selectedId:t,onSelect:n}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`cs-tbh`,"aria-hidden":`true`,children:[(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{children:`Task`}),(0,V.jsx)(`span`,{children:`Progress`}),(0,V.jsx)(`span`,{children:`Worked`}),(0,V.jsx)(`span`,{children:`Age`})]}),(0,V.jsx)(`ul`,{className:`cs-lst`,children:nG(e).flatMap(({rows:e})=>e.map((r,i)=>(0,V.jsx)(XG,{row:r,head:i===0,count:e.length,selected:r.id===t,onSelect:n},`${r.kind}-${r.id}`)))})]})}var QG=()=>bE(yE(`tasks`)),$G=e=>bE(yE(`tasks`,e));function eK(){return(0,V.jsxs)(EE,{className:`m-4 flex-1`,children:[(0,V.jsxs)(DE,{children:[(0,V.jsx)(kE,{variant:`icon`,children:(0,V.jsx)(rm,{"aria-hidden":`true`})}),(0,V.jsx)(jE,{children:QW})]}),(0,V.jsx)(WT,{onClick:()=>bE(yE(`plan`)),children:`Plan a task`})]})}function tK({id:e}){let[t,n]=(0,m.useState)(!1),r=_R(`tasks.list`,{},[`tasks`,`plans`]),i=_R(`tasks.archived`,{},[`tasks`]),a=r.data?.rows??[],o=i.data?.rows??[],s=t?[...a,...o]:a,c=[...s,...o].find(t=>t.id===e&&t.kind===`task`)?.id;if((0,m.useEffect)(()=>(yW(c),()=>yW(void 0)),[c]),!r.data&&r.error)return(0,V.jsx)(wE,{message:`Could not load tasks. ${r.error}`,onRetry:r.reload});if(r.data&&a.length===0&&o.length===0)return(0,V.jsx)(eK,{});let l=[...s,...o].find(t=>t.id===e),u=l?{row:l,onGone:QG,onChanged:r.reload}:void 0;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(nW,{title:`Tasks`,sub:rG(s),className:`cs-ts`,aside:(0,V.jsx)(rW,{on:t,label:`Archived`,count:o.length,describe:`Show archived tasks`,onToggle:()=>n(e=>!e)}),children:r.data?s.length===0?(0,V.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:QW}):(0,V.jsx)(ZG,{rows:s,selectedId:e,onSelect:$G}):(0,V.jsx)(JE,{})}),(0,V.jsx)(rD,{open:!!e,onClose:QG,label:l?.title??`Task`,className:`cs-tdw`,head:u?(0,V.jsx)(WG,{...u},u.row.id):null,children:u?(0,V.jsx)(KG,{...u},u.row.id):e?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That task is not on the list any more.`}):null})]})}var nK={l:`lobby`,p:`plan`,t:`tasks`,n:`knowledge`,e:`settings`};function rK(e){if(e.kind===`settings`)return(0,V.jsx)(ZH,{});switch(e.tab){case`lobby`:return(0,V.jsx)(Bz,{});case`tasks`:return(0,V.jsx)(tK,{...TR(e.rest)});case`plan`:return(0,V.jsx)(mW,{rest:e.rest});case`knowledge`:return(0,V.jsx)(wR,{rest:e.rest})}}function iK(e,t){return t.overlay?!0:e===`savePlan`&&!t.saveAvailable}var aK={tab:`Tab`,esc:`Escape`,escape:`Escape`,enter:`Enter`,space:`Space`,pageup:`PageUp`,pagedown:`PageDown`,home:`Home`,end:`End`,"`":`Backquote`,"]":`BracketRight`,"[":`BracketLeft`,"/":`Slash`,"?":`Slash`,",":`Comma`,".":`Period`};function oK(e){return e.length===1&&/[a-z]/i.test(e)?`Key${e.toUpperCase()}`:e.length===1&&/[0-9]/.test(e)?`Digit${e}`:aK[e]}function sK(e){let t={alt:!1,ctrl:!1,shift:!1,meta:!1,code:``};for(let n of e.toLowerCase().split(`+`))if(n===`alt`)t.alt=!0;else if(n===`ctrl`||n===`control`)t.ctrl=!0;else if(n===`shift`)t.shift=!0;else if(n===`meta`||n===`cmd`)t.meta=!0;else{let e=oK(n);if(!e)return;t.code=e}return t.code?t:void 0}function cK(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.shiftKey===t.shift&&e.metaKey===t.meta}function lK(e,t){let n=sK(t);return n?cK(e,n):!1}function uK(e,t){for(let n of t)if(lK(e,n.key))return n.action}function dK(e,t){for(let n of t)if(lK(e,n.key))return n.id}function fK(e){return IE(e.target)||e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||uE()||!!document.querySelector(`[role='dialog'], [role='menu'], [role='listbox']`)}function pK(e,t,n,r){let i=!e.shiftKey&&/^[1-9]$/.test(e.key)?t[Number(e.key)-1]:void 0;if(i)r(i.id);else if(e.key===`/`)n(`search`);else if(e.key===`?`)n(`help`);else if(e.key===`j`||e.key===`k`)VE(e.key===`j`?1:-1);else return!1;return!0}function mK(e,t){let n=dK(e,t.tabs),r=uK(e,t.keys);return!n&&!r?!1:iK(r,{overlay:!!document.querySelector(`[role='dialog']:not([data-state='closed']), [role='menu']:not([data-state='closed']), [role='listbox']`)||uE(),typing:IE(e.target)||e.target instanceof HTMLInputElement,saveAvailable:!!document.querySelector(`[data-plan-save]:not([disabled])`)})||(r===`search`||r===`savePlan`)&&!t.insideApp()?!0:(e.preventDefault(),n?t.onTab(n):r&&t.onAction(r),!0)}function hK(e,t,n){if(e.key===`Escape`)return Date.now()<n&&e.preventDefault(),0;if(Date.now()<n){let n=nK[e.key];return n&&(e.preventDefault(),t.onTab(n)),0}return e.key===`g`?Date.now()+1500:(pK(e,t.tabs,t.onAction,t.onTab)&&e.preventDefault(),0)}function gK(e){(0,m.useEffect)(()=>{if(!e.enabled)return;let t=0,n=n=>{if(n.defaultPrevented||n.isComposing)return;if(n.target instanceof Element&&n.target.closest(`.xterm`)){uK(n,e.keys)===`terminal`&&(n.preventDefault(),e.onAction(`terminal`));return}if(!e.insideApp()){uK(n,e.keys)===`help`&&(n.preventDefault(),e.onAction(`help`));return}let r=!n.altKey&&!n.ctrlKey&&!n.metaKey;if(r&&fK(n)){t=0;return}if(mK(n,e)){t=0;return}t=r?hK(n,e,t):0};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e.enabled,e.keys,e.tabs,e.insideApp,e.onAction,e.onTab])}var _K=[{id:`focus`,caps:[`/`],help:`focus search, or the message box`},{id:`send`,label:`Enter`,help:`send the message`},{id:`newline`,label:`Shift+Enter`,help:`a new line (lists carry on)`},{id:`format`,label:`Ctrl+B`,help:`bold; Ctrl+I italic, Ctrl+E code, Ctrl+K link`},{id:`leave`,label:`Esc`,help:`leave the box for the tab bar`}],vK=[{id:`digits`,caps:[`1`,`…`,`9`],help:`jump to a tab in current order`},{id:`help`,caps:[`?`],help:`keyboard shortcuts`},...Object.entries(nK).map(([e,t])=>({id:`go.${t}`,caps:[`g`,e],help:`jump to ${t}`})),{id:`project`,caps:[`P`],help:`open the project switcher`},{id:`theme`,caps:[`D`],help:`switch between light and dark`},{id:`edit`,label:`Ctrl+Enter`,help:`save an edited message; Esc cancels`}],yK=[{id:`tasks`,page:`Tasks`,keys:[[`E`,`archive`],[`R`,`restore`],[`A`,`auto mode`],[`Delete`,`delete`]]},{id:`saved`,page:`Saved plan`,keys:[[`S`,`start here`],[`N`,`new session`],[`Delete`,`discard`]]},{id:`plan`,page:`Plan`,keys:[[`A`,`answer`],[`R`,`retry`],[`Ctrl+S`,`save`],[`N`,`new plan`]]},{id:`knowledge`,page:`Knowledge`,keys:[[`E`,`edit`],[`A`,`add`],[`C`,`comment`],[`F`,`edit file`],[`Delete`,`delete`]]},{id:`confirm`,page:`Asked to confirm`,keys:[[`Y`,`yes, do it`],[`Esc`,`keep it`]]}],bK=[{id:`enter`,caps:[`↓`],help:`from the tab bar, into the page`},{id:`rows`,caps:[`↑`,`↓`],help:`move through a list (j and k work too)`},{id:`pane`,caps:[`←`,`→`],help:`between a list and its detail (h and l)`},{id:`ends`,caps:[`Home`,`End`],help:`first and last row`},{id:`open`,caps:[`Enter`,`Space`],help:`activate the focused button or row (links: Enter; checkboxes: Space)`},{id:`back`,label:`Esc`,help:`back up to the tab bar`}],xK=[{id:`qmove`,caps:[`↑`,`↓`],help:`move between the options`},{id:`qpick`,label:`Space`,help:`pick an option (several when allowed)`},{id:`qchoose`,label:`Enter`,help:`choose and go on; in your own answer, send it`},{id:`qacross`,caps:[`←`,`→`],help:`previous and next question`},{id:`qdigit`,caps:[`1`,`2`,`…`],help:`pick that option`},{id:`qesc`,label:`Esc`,help:`put the question away for later`}];function SK({line:e}){return(0,V.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,V.jsx)(`span`,{className:`flex w-28 shrink-0 items-center`,children:e.caps?(0,V.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:e.caps.map(e=>(0,V.jsx)(KT,{children:e},e))}):(0,V.jsx)(QT,{chord:e.label??``})}),(0,V.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.help})]})}function CK(){return(0,V.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,V.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:`Buttons on a page`}),yK.map(e=>(0,V.jsxs)(`div`,{className:`flex items-start gap-3 py-1`,children:[(0,V.jsx)(`span`,{className:`w-28 shrink-0 pt-0.5 text-sm font-medium`,children:e.page}),(0,V.jsx)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5 text-sm text-muted-foreground`,children:e.keys.map(([e,t])=>(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,V.jsx)(QT,{chord:e}),t]},e))})]},e.id))]})}function wK({title:e,lines:t}){return(0,V.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,V.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:e}),t.map(e=>(0,V.jsx)(SK,{line:e},e.id))]})}function TK(e){return e.map(e=>({id:e.action,label:e.label,help:e.help}))}function EK(e){return e.map(e=>({id:`tab.${e.id}`,label:e.key,help:`jump to the ${e.label} tab`}))}function DK({open:e,onOpenChange:t,keys:n,tabs:r}){let i=e,a=lE(i,cE.help),o=(0,m.useRef)(null);return(0,m.useEffect)(()=>{if(!i||!a)return;let e=e=>{let r=n.find(e=>e.action===`help`)?.key;(e.key===`Escape`||r&&lK(e,r))&&(e.preventDefault(),t(!1))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n,t,a,i]),(0,V.jsxs)(tE,{open:i&&a,onOpenChange:t,label:`Keys`,className:`max-w-4xl`,children:[(0,V.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-border px-4 py-3`,children:[(0,V.jsx)(`h2`,{"aria-hidden":`true`,className:`text-base font-semibold tracking-tight`,children:`Keyboard shortcuts`}),(0,V.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(QT,{chord:`Esc`}),(0,V.jsx)(WT,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,onClick:()=>t(!1),children:(0,V.jsx)(Fh,{"aria-hidden":`true`})})]})]}),(0,V.jsxs)(`div`,{ref:o,className:`grid min-h-0 flex-1 grid-cols-2 gap-x-10 gap-y-6 overflow-y-auto p-4`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,V.jsx)(wK,{title:`Everywhere`,lines:TK(n)}),(0,V.jsx)(wK,{title:`Jump to a tab`,lines:EK(r)}),(0,V.jsx)(wK,{title:`Navigation and editing`,lines:vK}),(0,V.jsx)(wK,{title:`Message box`,lines:_K})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,V.jsx)(wK,{title:`Lists and panes`,lines:bK}),(0,V.jsx)(CK,{}),(0,V.jsx)(wK,{title:`Questions`,lines:xK})]})]}),(0,V.jsx)(m_,{target:o})]})}var OK=`size-[1.05rem]`;function kK({hint:e,onHelp:t,className:n,side:r=`top`}){return(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Keyboard shortcuts`,"aria-haspopup":`dialog`,"aria-keyshortcuts":e,"aria-describedby":`focused-action-help`,onClick:t,className:n,children:(0,V.jsx)($p,{"aria-hidden":`true`,className:OK})})}),(0,V.jsxs)(VI,{side:r,children:[`Keyboard shortcuts `,(0,V.jsx)(QT,{chord:e})]})]})}function AK({className:e,side:t=`top`}){let n=Qz(),r=n?`Unmute prompt sounds`:`Mute prompt sounds`;return(0,V.jsx)(V.Fragment,{children:(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":r,"aria-pressed":n,"aria-describedby":`focused-action-help`,className:e,onClick:()=>Xz(!n),children:n?(0,V.jsx)(kh,{"aria-hidden":`true`,className:OK}):(0,V.jsx)(Dh,{"aria-hidden":`true`,className:OK})})}),(0,V.jsx)(VI,{side:t,children:r})]})})}function jK({className:e,side:t=`top`}){let{theme:n,setTheme:r}=eV(),i=n===`dark`||n===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;return(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":i?`Switch to light mode`:`Switch to dark mode`,"aria-keyshortcuts":`D`,"aria-describedby":`focused-action-help`,onClick:()=>r(i?`light`:`dark`),className:e,children:i?(0,V.jsx)(dh,{"aria-hidden":`true`,className:OK}):(0,V.jsx)(xm,{"aria-hidden":`true`,className:OK})})}),(0,V.jsxs)(VI,{side:t,children:[i?`Light mode`:`Dark mode`,` `,(0,V.jsx)(QT,{chord:`D`})]})]})}var MK=[{id:`light`,label:`Light`},{id:`dark`,label:`Dark`},{id:`system`,label:`System`}];function NK({className:e,side:t=`top`}){let{theme:n,setTheme:r}=eV();return(0,V.jsxs)(wB,{children:[(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:(0,V.jsx)(TB,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Appearance`,className:e,children:(0,V.jsx)(Cm,{"aria-hidden":`true`,className:OK})})})}),(0,V.jsx)(VI,{side:t,children:`Appearance`})]}),(0,V.jsxs)(EB,{side:t===`right`?`right`:`top`,align:t===`right`?`start`:`center`,sideOffset:10,collisionPadding:12,"aria-label":`Appearance`,onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.focus({preventScroll:!0})},tabIndex:-1,className:`glass-pop flex max-h-[85svh] w-[26rem] max-w-[calc(100vw-1.5rem)] flex-col gap-3 overflow-y-auto rounded-2xl p-3`,children:[(0,V.jsx)(ME,{label:`Mode`,items:MK,value:n,onChange:e=>r(e),className:`w-full [&>button]:flex-1`}),(0,V.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,V.jsx)(`p`,{className:`px-0.5 text-xs font-medium text-muted-foreground`,children:`Colour theme`}),(0,V.jsx)(`div`,{className:`[&_[role=radiogroup]]:!grid-cols-3 [&_[role=radiogroup]]:gap-1.5`,children:(0,V.jsx)(RV,{})})]}),(0,V.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,V.jsx)(`p`,{className:`px-0.5 text-xs font-medium text-muted-foreground`,children:`Typeface`}),(0,V.jsx)(tV,{kind:`font`,dense:!0})]}),(0,V.jsx)(`a`,{href:`#/settings`,className:`px-0.5 text-xs text-link underline-offset-2 hover:underline`,children:`More in Settings`})]})]})}function PK({className:e,side:t=`top`}){let n=cB(),r=n?`Turn off desktop notifications`:`Turn on desktop notifications`,i=async()=>{if(n)return uB();let e=await lB();e===`granted`?H.success(`Desktop notifications are on.`):H.error(e===`unsupported`?`This browser cannot show notifications.`:`Notifications are blocked for this page in the browser's settings.`)};return(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":r,"aria-pressed":n,className:e,onClick:()=>void i(),children:n?(0,V.jsx)(Hf,{"aria-hidden":`true`,className:OK}):(0,V.jsx)(Bf,{"aria-hidden":`true`,className:OK})})}),(0,V.jsx)(VI,{side:t,children:r})]})}function FK({className:e,side:t=`top`}){let n=x();if(!n.supported)return null;let r=n.on?`Leave full screen`:`Full screen`;return(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":r,"aria-pressed":n.on,className:e,onClick:()=>void n.toggle(),children:n.on?(0,V.jsx)(ym,{"aria-hidden":`true`,className:OK}):(0,V.jsx)(lm,{"aria-hidden":`true`,className:OK})})}),(0,V.jsx)(VI,{side:t,children:r})]})}function IK(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}async function LK(e){if(e.size===0)throw Error(`${e.name||`That file`} is empty.`);if(e.size>20971520)throw Error(`${e.name||`That file`} is larger than 20 MB.`);let t=new URLSearchParams({name:e.name||`pasted-file`,type:e.type}),n=await fetch(F(`/api/files.upload?${t}`),{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:e,credentials:`same-origin`}),r=await n.json().catch(()=>void 0);if(!r)throw new xe(`the lobby answered ${n.status}`,`failed`,n.status);if(!r.ok)throw new xe(r.error,r.code,n.status);return r.result}function RK(e,t,n,r){let i=e.slice(0,t),a=e.slice(t,n),o=e.slice(n);if(a.length>=r.length*2&&a.startsWith(r)&&a.endsWith(r)){let e=a.slice(r.length,a.length-r.length);return{value:i+e+o,start:t,end:t+e.length}}return i.endsWith(r)&&o.startsWith(r)?{value:i.slice(0,i.length-r.length)+a+o.slice(r.length),start:t-r.length,end:n-r.length}:{value:i+r+a+r+o,start:t+r.length,end:n+r.length}}function zK(e,t,n){let r=e.slice(t,n)||`text`,i=`[${r}](url)`,a=t+r.length+3;return{value:e.slice(0,t)+i+e.slice(n),start:a,end:a+3}}var BK=/^(\s*)(?:([-*+])|(\d+)([.)]))\s+(\[[ xX]\]\s+)?/;function VK(e,t){let n=e.lastIndexOf(`
|
|
101
101
|
`,t-1)+1,r=e.indexOf(`
|
|
102
|
-
`,t),i=e.slice(n,r<0?e.length:r),a=GK.exec(i);if(!a||t-n<a[0].length)return;let[o,s=``,c,l,u=`.`,d]=a;if(i.slice(o.length).trim()===``)return{value:e.slice(0,n)+e.slice(r<0?e.length:r),start:n,end:n};let f=`\n${s}${c??`${Number(l)+1}${u}`} ${d?`[ ] `:``}`;return{value:e.slice(0,t)+f+e.slice(t),start:t+f.length,end:t+f.length}}function qK(){try{return{id:pe()}}catch(e){return{error:e.message}}}function JK(e,t){if(e){if(t&&!e.projects.some(e=>e.id===t))return`Selected project is unknown or offline. Refresh or choose a running project.`;if(!e.projects.length)return`No authorized running projects found. Open a folder from the Project menu, or refresh.`}}function YK(){let[e,t]=(0,m.useState)(),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(0);async function s(){let e=++o.current;a(!0),r(void 0);try{let n=await L(`projects.list`,{});ve(n.projects),e===o.current&&t(n)}catch(t){e===o.current&&r(t.message)}finally{e===o.current&&a(!1)}}(0,m.useEffect)(()=>(s(),()=>{o.current++}),[]);let[c,l]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{if(!i)return l(!1);let e=setTimeout(()=>l(!0),300);return()=>clearTimeout(e)},[i]),{data:e,error:n,busy:i,slow:c,refresh:s}}function XK({data:e,error:t}){let n=qK();return n.error??t??JK(e,n.id)}function ZK({projects:e}){let t=XK(e);return t?(0,V.jsxs)(`p`,{role:`alert`,className:`notice flex min-w-0 items-start gap-2 pt-1 pb-0.5 text-xs break-words text-destructive`,children:[(0,V.jsx)(xh,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,V.jsx)(`span`,{children:t})]}):null}function QK(e){let t=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0,n=e.key===`Home`?`first`:e.key===`End`?`last`:void 0;if(!t&&!n)return;let r=[...e.currentTarget.querySelectorAll(`[role='option'], [data-walk]`)];if(r.length===0)return;e.preventDefault();let i=r.indexOf(document.activeElement);r[n===`first`?0:n===`last`?r.length-1:Math.max(0,Math.min(r.length-1,(i<0?t>0?-1:r.length:i)+t))]?.focus()}var $K=`bot-lobby:open-projects`,eq=4;function tq(e){return{w:400,h:49+Math.max(1,Math.min(e.data?.projects.length??1,eq))*52+1+40+(XK(e)?36:0)}}function nq({projects:e,name:t,branch:n,open:r,onToggle:i}){let a=XK(e);return(0,V.jsxs)(`button`,{type:`button`,role:`combobox`,"aria-label":`Project`,"aria-description":`${t}${n?`, branch ${n}`:``}`,"aria-haspopup":`listbox`,"aria-expanded":r,"aria-keyshortcuts":`P ArrowDown`,"aria-busy":e.busy,"data-tip":`Switch project`,"data-on":r||void 0,onClick:i,onKeyDown:e=>{e.key!==`ArrowDown`||e.altKey||e.metaKey||e.ctrlKey||r||(e.preventDefault(),i())},title:n?`${t} · ${n}`:t,className:`bubble-chip bubble-tip bubble-tool min-w-0`,children:[e.slow?(0,V.jsx)(ER,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,V.jsx)(Up,{"aria-hidden":`true`,className:Y(`size-3.5 shrink-0`,a&&`text-destructive`)}),(0,V.jsx)(`span`,{className:`truncate`,children:t}),(0,V.jsx)(Zf,{"aria-hidden":`true`,className:`size-3 shrink-0`,strokeWidth:2})]})}function rq({projects:e,tab:t,onBrowse:n,onClose:r}){let{data:i,busy:a,refresh:o}=e,s=qK(),c=XK(e),l=s.error?`invalid`:s.id??i?.currentId??``,u=(0,m.useRef)(null);tD(`r`,()=>void o(),{inDialog:!0}),(0,m.useEffect)(()=>{(u.current?.querySelector(`[role='option'][aria-selected='true']`)??u.current?.querySelector(`[role='option']`))?.focus({preventScroll:!0})},[!!i]);function d(e){r(),e!==l&&I(e,t)}let f=Math.max(1,Math.min(i?.projects.length??1,eq));return(0,V.jsxs)(`div`,{ref:u,"aria-label":`Projects`,onKeyDown:QK,className:`bubble-pane flex flex-col p-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center justify-between ps-2.5`,children:[(0,V.jsx)(`span`,{className:`text-[13px] font-medium text-(--bubble-muted)`,children:`Running projects`}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>void o(),disabled:a,"aria-label":`Refresh list`,"aria-keyshortcuts":`R`,className:`bubble-chip h-7 text-xs`,children:[a?(0,V.jsx)(ER,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):(0,V.jsx)(zm,{"aria-hidden":`true`,className:`size-3.5`}),`Refresh`,(0,V.jsx)(`kbd`,{className:`bubble-kbd`,children:`R`})]})]}),(0,V.jsx)(`div`,{className:`h-px shrink-0`}),(0,V.jsx)(`div`,{role:`listbox`,"aria-label":`Projects`,className:`bubble-scroll flex shrink-0 flex-col overflow-y-auto`,style:{height:f*52},children:i?i.projects.map((e,t)=>{let n=e.id===l;return(0,V.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,onClick:()=>d(e.id),className:Y(`bubble-row h-[52px] shrink-0`,n&&`bubble-prow`),style:{"--delay":`${40+t*12}ms`},children:[(0,V.jsx)(`span`,{className:`flex w-4 shrink-0 justify-center`,children:n?(0,V.jsx)(Yf,{"aria-hidden":`true`,className:`size-4 text-(--bubble-accent)`,strokeWidth:2}):null}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,V.jsx)(`span`,{className:`truncate text-sm font-medium text-(--bubble-ink)`,children:e.name}),(0,V.jsxs)(`span`,{className:`truncate text-xs text-(--bubble-muted)`,children:[e.cwd,` · :`,e.port]})]})]},e.id)}):(0,V.jsxs)(`div`,{className:`flex h-[52px] items-center gap-2.5 px-2.5 text-[13px] text-(--bubble-muted)`,children:[(0,V.jsx)(ER,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}),`Loading projects…`]})}),c?(0,V.jsxs)(`p`,{role:`alert`,className:`flex h-9 shrink-0 items-center gap-2 px-2.5 text-xs text-destructive`,children:[(0,V.jsx)(xh,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,V.jsx)(`span`,{className:`truncate`,title:c,children:c})]}):null,(0,V.jsx)(`div`,{className:`h-px shrink-0`}),(0,V.jsxs)(`button`,{type:`button`,"data-walk":!0,onClick:n,className:`bubble-row h-10 shrink-0`,style:{"--delay":`0ms`},children:[(0,V.jsx)(Vp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Open folder…`})]})]})}var iq={w:540,h:324};function aq(e){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)();async function a(r){if(!t){n(!0),i(void 0);try{let{project:t}=await L(`projects.open`,{path:r});ve([t]),I(t.id,e)}catch(e){i(e.message)}finally{n(!1)}}}return{opening:t,error:r,open:a}}function oq(e){let t=e.includes(`\\`)&&!e.includes(`/`)?`\\`:`/`,n=e.split(t),r=[];return n.forEach((e,i)=>{if(!e)return;let a=n.slice(0,i+1).join(t);r.push({name:e,path:a||t})}),r.length?r:[{name:t,path:t}]}function sq(e,t,n){let r=[...e.currentTarget.querySelectorAll(`button[data-folder]:not(:disabled)`)],i=r.indexOf(document.activeElement),a={ArrowDown:Math.min(r.length-1,i+1),ArrowUp:Math.max(0,i-1),Home:0,End:r.length-1}[e.key];a!==void 0&&r.length>0?(e.preventDefault(),r[a]?.focus()):e.key===`Backspace`&&t&&(e.preventDefault(),n(t))}function cq({tab:e,onClose:t}){let[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)({step:0,dir:`fwd`}),o=_R(`projects.browse`,n===void 0?{}:{path:n},[]),s=aq(e),c=(0,m.useRef)(null),l=o.loading||s.opening,u=o.data?.path??n??``,d=(e,t)=>{e!==u&&(a(e=>({step:e.step+1,dir:t})),r(e))};(0,m.useEffect)(()=>{if(!o.data)return;let e=c.current?.querySelector(`button[data-folder]`);e&&!c.current?.contains(document.activeElement)&&e.focus({preventScroll:!0})},[o.data]);let f=oq(u),p=f.slice(-4),h=o.data?.folders.length??0,g=o.error||s.error?o.error??s.error:o.loading&&!o.data?`Loading…`:h===0?`No subfolders`:`${h.toLocaleString()} ${h===1?`folder`:`folders`}${o.data?.truncated?` (first 2,000)`:``}`;return(0,V.jsxs)(`div`,{role:`group`,"aria-label":`Open project folder`,className:`bubble-pane flex flex-col gap-1.5 p-2`,style:{height:iq.h},children:[(0,V.jsxs)(`div`,{className:`bubble-wellbar flex h-10 shrink-0 items-center gap-0.5 rounded-2xl px-1`,children:[(0,V.jsx)(`button`,{type:`button`,"aria-label":`Parent folder`,title:`Parent folder (Backspace)`,disabled:l||!o.data?.parent,onClick:()=>o.data?.parent&&d(o.data.parent,`back`),className:`bubble-iconbtn size-8 rounded-xl`,children:(0,V.jsx)(Rf,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.8})}),(0,V.jsxs)(`nav`,{"aria-label":`Folder path`,className:`flex min-w-0 flex-1 items-center overflow-hidden whitespace-nowrap`,title:u,children:[f.length>p.length?(0,V.jsx)(`span`,{className:`shrink-0 px-1.5 text-[13px] text-(--bubble-muted)`,children:`…`}):null,p.map((e,t)=>(0,V.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[t>0?(0,V.jsx)(tp,{"aria-hidden":`true`,className:`size-3 shrink-0 text-(--bubble-faint)`,strokeWidth:2}):null,(0,V.jsx)(`button`,{type:`button`,className:`bubble-crumb`,"data-last":t===p.length-1||void 0,"aria-current":t===p.length-1?`location`:void 0,disabled:l,onClick:()=>d(e.path,`back`),children:e.name})]},e.path))]})]}),(0,V.jsxs)(`div`,{ref:c,role:`group`,"aria-label":`Folders`,"aria-busy":o.loading,"data-dir":i.step?i.dir:void 0,onKeyDown:e=>sq(e,o.data?.parent,e=>d(e,`back`)),className:`bubble-flist bubble-scroll`,children:[o.data?.folders.map(e=>{let t=e.name.startsWith(`.`);return(0,V.jsxs)(`button`,{type:`button`,"data-folder":!0,disabled:s.opening,onClick:()=>d(e.path,`fwd`),title:e.path,className:Y(`bubble-frow`,t&&`text-(--bubble-muted)`),children:[(0,V.jsx)(`span`,{className:`bubble-ftile`,children:(0,V.jsx)(Up,{"aria-hidden":`true`,className:`size-3.5 text-(--bubble-muted)`,strokeWidth:1.8})}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,V.jsx)(tp,{"aria-hidden":`true`,className:`bubble-go size-3.5 shrink-0`,strokeWidth:2})]},e.path)}),o.data&&h===0?(0,V.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-xs text-(--bubble-muted)`,children:[(0,V.jsx)(Up,{"aria-hidden":`true`,className:`size-6`,strokeWidth:1.5}),(0,V.jsx)(`span`,{children:`No subfolders here. You can open this folder.`})]}):null]},i.step),(0,V.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between gap-2 ps-2.5`,children:[(0,V.jsx)(`span`,{role:o.error||s.error?`alert`:`status`,className:Y(`min-w-0 truncate text-xs`,o.error||s.error?`text-destructive`:`text-(--bubble-muted)`),children:g}),(0,V.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[o.error?(0,V.jsx)(`button`,{type:`button`,className:`bubble-btn bubble-ghostbtn`,onClick:o.reload,disabled:o.loading,children:`Retry`}):null,(0,V.jsx)(`button`,{type:`button`,className:`bubble-btn bubble-ghostbtn`,onClick:t,disabled:s.opening,children:`Cancel`}),(0,V.jsx)(`button`,{type:`button`,className:`bubble-btn bubble-key`,disabled:!o.data||o.loading||!!o.error||s.opening,onClick:()=>void s.open(o.data.path),children:s.opening?`Opening project…`:`Open this folder`})]})]})]})}function lq(){return(0,V.jsx)(`svg`,{width:`0`,height:`0`,className:`absolute`,"aria-hidden":`true`,focusable:`false`,children:(0,V.jsxs)(`defs`,{children:[(0,V.jsxs)(`filter`,{id:`bubble-goolit`,x:`-10%`,y:`-10%`,width:`120%`,height:`120%`,colorInterpolationFilters:`sRGB`,children:[(0,V.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`9`,result:`b`}),(0,V.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`0.9`,dy:`1.3`,result:`dn`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`rimA`}),(0,V.jsx)(`feGaussianBlur`,{in:`rimA`,stdDeviation:`0.4`,result:`rimB`}),(0,V.jsx)(`feComposite`,{in:`rimB`,in2:`shape`,operator:`in`,result:`rimC`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-hl)`},result:`hlc`}),(0,V.jsx)(`feComposite`,{in:`hlc`,in2:`rimC`,operator:`in`,result:`hl`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`-0.9`,dy:`-1.3`,result:`up`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`shA`}),(0,V.jsx)(`feGaussianBlur`,{in:`shA`,stdDeviation:`0.4`,result:`shB`}),(0,V.jsx)(`feComposite`,{in:`shB`,in2:`shape`,operator:`in`,result:`shC`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-sh)`},result:`shc`}),(0,V.jsx)(`feComposite`,{in:`shc`,in2:`shC`,operator:`in`,result:`sh`}),(0,V.jsxs)(`feMerge`,{children:[(0,V.jsx)(`feMergeNode`,{in:`shape`}),(0,V.jsx)(`feMergeNode`,{in:`sh`}),(0,V.jsx)(`feMergeNode`,{in:`hl`})]})]}),(0,V.jsxs)(`filter`,{id:`bubble-gooedge`,x:`-10%`,y:`-10%`,width:`120%`,height:`120%`,colorInterpolationFilters:`sRGB`,children:[(0,V.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`9`,result:`b`}),(0,V.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`2`,dy:`3`,result:`dn`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`tS0`}),(0,V.jsx)(`feGaussianBlur`,{in:`tS0`,stdDeviation:`0.8`,result:`tS1`}),(0,V.jsx)(`feComposite`,{in:`tS1`,in2:`shape`,operator:`in`,result:`tS`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-ehl)`},result:`tc`}),(0,V.jsx)(`feComposite`,{in:`tc`,in2:`tS`,operator:`in`,result:`eh`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`-2`,dy:`-3`,result:`up`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`bS0`}),(0,V.jsx)(`feGaussianBlur`,{in:`bS0`,stdDeviation:`0.8`,result:`bS1`}),(0,V.jsx)(`feComposite`,{in:`bS1`,in2:`shape`,operator:`in`,result:`bS`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-esh)`},result:`bc`}),(0,V.jsx)(`feComposite`,{in:`bc`,in2:`bS`,operator:`in`,result:`es`}),(0,V.jsxs)(`feMerge`,{children:[(0,V.jsx)(`feMergeNode`,{in:`shape`}),(0,V.jsx)(`feMergeNode`,{in:`eh`}),(0,V.jsx)(`feMergeNode`,{in:`es`})]})]})]})})}function uq({kind:e}){return(0,V.jsxs)(`div`,{className:Y(`bubble-layer`,e===`edge`?`bubble-edge`:`bubble-fill`),"aria-hidden":`true`,children:[(0,V.jsx)(`div`,{className:`bubble-menu`,children:(0,V.jsx)(`div`,{className:`bubble-menu-clip`})}),(0,V.jsx)(`div`,{className:`bubble-ghost`})]})}function dq({open:e,size:t,shrunk:n,morphing:r,menu:i,children:a,className:o,style:s,...c}){let[l,u]=(0,m.useState)(e);return(0,m.useEffect)(()=>{if(e)return u(!0);let t=setTimeout(()=>u(!1),140);return()=>clearTimeout(t)},[e]),(0,V.jsxs)(`div`,{"data-slot":`composer-shell`,"data-open":e||void 0,"data-shrunk":n||void 0,"data-morphing":r||void 0,className:Y(`bubble`,o),style:{...s,"--w":`${t.w}px`,"--h":`${e?t.h:0}px`},...c,children:[(0,V.jsx)(lq,{}),(0,V.jsx)(uq,{kind:`edge`}),(0,V.jsx)(uq,{kind:`fill`}),(0,V.jsxs)(`div`,{className:`bubble-real`,children:[(0,V.jsx)(`div`,{className:`bubble-menu`,inert:!e,children:(0,V.jsx)(`div`,{className:`bubble-menu-clip`,children:(0,V.jsx)(`div`,{className:`bubble-menu-body`,children:e||l?i:null})})}),a]})]})}var fq=e=>e.preventDefault();function pq({onStop:e}){let[t,n]=(0,m.useState)(!1),r=lE(t,cE.confirm),i=()=>{n(!1),e()};return tD(`y`,i,{enabled:t&&r,inDialog:!0}),(0,V.jsxs)(nR,{open:t&&r,onOpenChange:n,children:[(0,V.jsx)(`button`,{type:`button`,className:`bubble-send bubble-key bubble-stop bubble-tip`,"data-tip":`Interrupt`,onPointerDown:fq,onClick:()=>n(!0),"aria-label":`Stop`,"aria-haspopup":`dialog`,children:(0,V.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,V.jsx)(`rect`,{x:`2`,y:`2`,width:`8`,height:`8`,rx:`1.5`})})}),(0,V.jsxs)(rR,{children:[(0,V.jsxs)(iR,{children:[(0,V.jsx)(oR,{children:`Stop the oracle?`}),(0,V.jsx)(sR,{children:`The current response stops. Work already recorded is kept.`})]}),(0,V.jsxs)(aR,{children:[(0,V.jsxs)(lR,{children:[`Keep it`,(0,V.jsx)(QT,{chord:`Esc`,className:`kbd-hint ml-1`})]}),(0,V.jsxs)(cR,{variant:`destructive`,onClick:i,children:[`Stop`,(0,V.jsx)(QT,{chord:`Y`,className:`kbd-hint ml-1`})]})]})]})]})}function mq({sending:e,disabled:t,steering:n,onSend:r}){return(0,V.jsx)(`button`,{type:`button`,className:Y(`bubble-send bubble-tip`,!t&&`bubble-key`),"data-tip":n?`Steer`:`Send`,onPointerDown:fq,onClick:r,disabled:t,"aria-label":`Send`,"aria-keyshortcuts":`Enter`,children:e?(0,V.jsx)(ER,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,V.jsxs)(`svg`,{className:`bubble-plane`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M22 2L11 13`}),(0,V.jsx)(`path`,{d:`M22 2l-7 20-4-9-9-4z`})]})})}function hq(e){return e.agent?NR(e.agent):e.tag===`lobby`?`var(--c-orc)`:e.tag===`skill`?`var(--c-pl)`:`var(--c-qa)`}function gq(e,t){let n=/^\s*([/@])([a-z0-9:_.-]*)$/i.exec(e.slice(0,t));if(n&&!/\S/.test(e.slice(t,t+1)))return{kind:n[1]===`/`?`slash-command`:`mention`,query:n[2].toLowerCase()}}function _q(e){return[...hE.map(e=>({id:`/${e.name}`,insert:`/${e.name}`,label:`/${e.name}`,description:e.hint,tag:`lobby`})),...e.map(e=>({id:`/${e.name}`,insert:`/${e.name}`,label:`/${e.name}`,description:e.description+(e.terminal?` · continue in Pi terminal`:``),tag:e.name.startsWith(`skill:`)?`skill`:`pi`}))]}function vq(e,t=[]){let n=e.kind===`slash-command`?_q(t):mE.map(e=>({id:`@${e.name}`,insert:`@${e.name}`,label:`@${e.name}`,description:e.hint,agent:e.agent,tag:`agent`})),r=n.filter((e,t)=>n.findIndex(t=>t.id===e.id)===t),i=r.filter(t=>t.label.slice(1).startsWith(e.query)),a=r.filter(t=>!i.includes(t)&&t.label.slice(1).includes(e.query));return[...i,...a]}function yq(e,t){return`${e}-${encodeURIComponent(t)}`}var bq={"slash-command":`Commands`,mention:`Agents`};function xq(e){return 12+Math.min(e,8)*36}var Sq;function Cq(e,t){let n=0;try{if(Sq??=document.createElement(`canvas`).getContext(`2d`),!Sq)throw Error(`no canvas`);for(let r of e){Sq.font=`500 14px ${t}`;let e=Sq.measureText(r.label.slice(1)).width;Sq.font=`400 13px ${t}`,n=Math.max(n,e+Sq.measureText(r.description).width)}}catch{for(let t of e)n=Math.max(n,t.label.length*8+t.description.length*6.6)}return Math.min(Math.max(Math.ceil(n)+150,200),640)}var wq=(0,m.memo)(function(e){let t=(0,m.useRef)(null);(0,m.useLayoutEffect)(()=>{e.activeItemId&&t.current&&t.current.querySelector(`[data-composer-item-id="${CSS.escape(e.activeItemId)}"]`)?.scrollIntoView({block:`nearest`})},[e.activeItemId]);let n=Math.min(e.items.length,8);return(0,V.jsx)(`div`,{ref:t,id:e.listId,role:`listbox`,"aria-label":bq[e.triggerKind],"data-composer-command-drawer":`true`,className:`bubble-pane bubble-scroll overflow-y-auto p-1.5`,style:{height:xq(e.items.length)},children:e.items.map((t,r)=>{let i=e.activeItemId===t.id;return(0,V.jsxs)(`div`,{id:yq(e.listId,t.id),role:`option`,"aria-selected":i,"data-composer-item-id":t.id,"data-active":i||void 0,onMouseMove:()=>{i||e.onHighlightedItemChange(t.id)},onMouseDown:e=>e.preventDefault(),onClick:()=>e.onSelect(t),className:`bubble-row`,style:{"--delay":`${Math.max(0,n-1-r)*22}ms`},children:[(0,V.jsx)(`span`,{className:`bubble-glyph cs-kg`,"aria-hidden":`true`,style:{"--k":hq(t)},children:t.agent?(0,V.jsx)(IR,{source:t.agent,strokeWidth:2}):t.label.charAt(1).toUpperCase()}),(0,V.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-(--bubble-ink)`,children:t.label.slice(1)}),(0,V.jsx)(`span`,{className:`min-w-0 truncate text-[13px] text-(--bubble-muted)`,children:t.description}),(0,V.jsx)(`span`,{className:`cs-ktag`,style:{"--k":hq(t)},children:t.tag})]},t.id)})})});function Tq(e){return typeof e==`object`&&e?e:{}}function Eq(e){return typeof e==`string`?e.trim():``}function Dq(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Oq(e){let t=Tq(e),n=Eq(t.label);if(!n)return;let r=Eq(t.description),i=Eq(t.preview),a=Eq(t.image),o=iU(t.htmlPreview);return{label:n,...r?{description:r}:{},...i?{preview:i}:{},...a?{image:a}:{},...o?{htmlPreview:o}:{}}}function kq(e){let t=Tq(e),n=Eq(t.question);if(!n)return;let r=(Array.isArray(t.options)?t.options:[]).map(Oq).filter(e=>!!e);return{question:n,header:Eq(t.header)||`Question`,options:r,...t.multiSelect===!0?{multiSelect:!0}:{}}}function Aq(e){let t=Tq(e),n=Eq(t.method);if(n!==`select`&&n!==`confirm`&&n!==`input`&&n!==`editor`)return;let r=Eq(t.message),i=Dq(t.options),a=Eq(t.placeholder),o=Eq(t.prefill);return{id:Eq(t.id),method:n,title:Eq(t.title)||`Answer`,...r?{message:r}:{},...i.length>0?{options:i}:{},...a?{placeholder:a}:{},...o?{prefill:o}:{}}}function jq(e){let t=(Array.isArray(e.questions)?e.questions:[]).map(kq).filter(e=>!!e);return t.length>0?{kind:`questionnaire`,questions:t}:void 0}function Mq(e){return{kind:`choose`,title:Eq(e.title)||`Choose an option`,options:Dq(e.options)}}function Nq(e){let t=Eq(e.question)||Eq(e.title)||`Continue?`,n=Eq(e.detail)||Eq(e.message);return{kind:`confirm`,question:t,...n?{detail:n}:{}}}function Pq(e){let t=Eq(e.question)||Eq(e.title)||`Type an answer`,n=Eq(e.placeholder);return{kind:`text`,question:t,...n?{placeholder:n}:{}}}function Fq(e){let t=Tq(e.payload);if(e.kind===`questionnaire`)return jq(t);if(e.kind===`choose`)return Mq(t);if(e.kind===`confirm`)return Nq(t);if(e.kind===`text`)return Pq(t);let n=Aq(t.dialog);return n?{kind:`sessionDialog`,dialog:n}:void 0}var Iq=`That question was already answered in the terminal.`;function Lq(e){let t=e.from.trim();return/panel|plann/i.test(t)?`PLANNER`:/oracle|master|lobby/i.test(t)||!t?`MASTER`:t.split(/\s+/)[0].toUpperCase()}function Rq(e,t){let n=Lq(e);return n===`PLANNER`&&t&&NR(t)!==`var(--muted-foreground)`?t.toUpperCase():n}function zq(e,t){let n=Rq(e,t);if(n!==Lq(e))return n===`DEV`||n===`BACKEND`?`Dev`:n===`QA`?`QA`:n.charAt(0)+n.slice(1).toLowerCase();let r=Lq(e);if(r===`PLANNER`)return`Panel`;if(r===`MASTER`)return`Oracle`;let i=e.from.trim().split(/\s+/)[0]??`Agent`;return i.charAt(0).toUpperCase()+i.slice(1)}function Bq(e,t){let{round:n,limit:r}=e.payload??{},i=n?`From planning · round ${r?`${Math.min(n,r)}/${r}`:n}`:`From planning`,a=Lq(e)===`PLANNER`?i:e.taskId?`From task ${e.taskId}`:`From the Lobby`;return t&&t!==`Question`&&Rq(e,t)===Lq(e)?`${a} · ${t}`:a}function Vq(e,t,n){let r={prompt:e,view:t,index:0,multi:!1,placeholder:`Or type your own reply…`};if(t.kind===`questionnaire`){let e=t.questions[n];return e?{...r,index:n,question:e.question,header:e.header,multi:!!e.multiSelect,options:e.options.map(e=>({...e,value:e.label})),typed:e=>e}:void 0}if(t.kind===`choose`)return{...r,question:t.title,options:t.options.map(e=>({label:e,value:e}))};if(t.kind===`confirm`)return{...r,question:t.detail?`${t.question}\n\n${t.detail}`:t.question,options:[{label:`Yes`,value:!0},{label:`No`,value:!1}]};if(t.kind===`text`)return{...r,question:t.question,options:[],typed:e=>e,placeholder:t.placeholder||`Type your reply…`};let i=t.dialog,a=i.message?`${i.title}\n\n${i.message}`:i.title;return i.method===`select`?{...r,question:a,options:(i.options??[]).map(e=>({label:e,value:{value:e}}))}:i.method===`confirm`?{...r,question:a,options:[{label:`Yes`,value:{confirmed:!0}},{label:`No`,value:{confirmed:!1}}]}:{...r,question:a,options:[],typed:e=>({value:e}),placeholder:i.placeholder||`Type your reply…`}}function Hq(e,t){return e&&e.kind===`questionnaire`?Math.max(0,e.questions.length-t):1}function Uq(e,t,n){let[r,i]=(0,m.useState)({}),[a,o]=(0,m.useState)([]),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(0),d=(0,m.useMemo)(()=>e.map(e=>({prompt:e,view:Fq(e)})),[e]),f=d[0],p=f?.view?Vq(f.prompt,f.view,r[f.prompt.id]?.length??0):void 0,h=d.reduce((e,{prompt:t,view:n})=>e+Hq(n,r[t.id]?.length??0),0);(0,m.useEffect)(()=>{e.length===0&&(u(0),i({}))},[e.length]);let g=p?`${p.prompt.id}:${p.index}`:``;(0,m.useEffect)(()=>o([]),[g]);let _=(0,m.useCallback)(async(e,n)=>{c(!0);try{await t(e,n)}catch(e){e instanceof xe&&e.code===`question_withdrawn`?H(Iq):H.error(e instanceof Error?e.message:`Could not send the answer`)}finally{c(!1)}},[t]),v=(0,m.useCallback)((e,t=`option`,n)=>{if(!p||s)return;if(u(e=>e+1),p.view.kind!==`questionnaire`)return void _(p.prompt.id,e);let a=[...r[p.prompt.id]??[],{questionIndex:p.index,question:p.question,kind:t,answer:String(e),...n?{selected:n}:{}}];if(a.length<p.view.questions.length)return i(e=>({...e,[p.prompt.id]:a}));_(p.prompt.id,{answers:a,cancelled:!1}).then(()=>i(e=>{let t={...e};return delete t[p.prompt.id],t}))},[s,r,_,p]),y=(0,m.useCallback)(e=>{let t=p?.options[e];if(t){if(p.multi)return o(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);v(t.value)}},[p,v]),b=y,x=(0,m.useCallback)(()=>{if(!p||a.length===0)return;let e=[...a].sort((e,t)=>e-t).map(e=>p.options[e].label);v(e.join(`, `),`multi`,e)},[a,p,v]),S=(0,m.useCallback)(e=>!p?.typed||!e.trim()?!1:(v(p.typed(e.trim()),`custom`),!0),[p,v]),C=(0,m.useCallback)(()=>{p&&n(p.prompt.id).catch(e=>H.error(e instanceof Error?e.message:`Could not dismiss the question`))},[n,p]);return{...p?{step:p}:{},position:l+1,total:l+h,left:h,picks:a,busy:s,choose:y,toggle:b,submitPicks:x,reply:S,dismiss:C}}function Wq({option:e,large:t}){let n=fU(e.label);return e.htmlPreview?(0,V.jsx)(lU,{preview:e.htmlPreview,label:n,frameWidth:t?void 0:1200,minWidth:t?1024:void 0,className:`static-thumb h-full`}):e.image?(0,V.jsx)(`img`,{src:F(e.image),alt:t?`Mockup: ${n}`:``,loading:`lazy`}):e.preview?t?(0,V.jsx)(`div`,{className:`cs-mktext`,children:(0,V.jsx)(QL,{text:e.preview})}):(0,V.jsx)(`pre`,{className:`cs-mktext`,children:e.preview}):null}function Gq({color:e,children:t}){return(0,V.jsx)(`span`,{className:`bubble-glyph cs-kg`,"aria-hidden":`true`,style:{"--k":e},children:t})}function Kq({drawer:e,onExpand:t}){let{step:n}=e,[r,i]=(0,m.useState)(!1);if((0,m.useEffect)(()=>i(!1),[n?.prompt.id]),!n)return(0,V.jsx)(`div`,{className:`bubble-pane p-3 text-sm text-(--bubble-muted)`,children:`No questions are waiting.`});let a=Rq(n.prompt,n.header),o=NR(a),s=n.options.some(pU),c=n.options.length;return(0,V.jsxs)(`div`,{className:`bubble-pane p-1.5`,role:`group`,"aria-label":`Question`,children:[(0,V.jsxs)(`div`,{className:`cs-askh`,children:[(0,V.jsxs)(`div`,{className:`cs-asks`,children:[(0,V.jsx)(Gq,{color:o,children:(0,V.jsx)(IR,{source:a,strokeWidth:2.2,className:`size-3`})}),(0,V.jsx)(`b`,{style:{color:o},children:zq(n.prompt,n.header)}),(0,V.jsx)(`span`,{className:`cs-askf`,children:Bq(n.prompt,n.header)}),(0,V.jsxs)(`span`,{className:`cs-askn`,children:[e.position,` of `,e.total]}),(0,V.jsx)(`button`,{type:`button`,className:`cs-askx`,"data-confirm":r||void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>r?e.dismiss():i(!0),onBlur:()=>i(!1),children:r?`Dismiss it?`:`Dismiss`})]}),(0,V.jsx)(`p`,{className:`cs-askq`,title:n.question,children:n.question})]}),s?(0,V.jsx)(`div`,{className:`cs-askm`,children:n.options.map((n,r)=>(0,V.jsxs)(`button`,{type:`button`,className:`cs-mko`,"data-on":e.picks.includes(r)||void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>e.choose(r),style:{animationDelay:`${r*30}ms`},children:[(0,V.jsxs)(`div`,{className:`cs-mk3`,children:[(0,V.jsx)(Wq,{option:n}),(0,V.jsx)(`span`,{className:`cs-mxb`,role:`button`,"aria-label":`Expand ${fU(n.label)}`,onClick:e=>{e.stopPropagation(),t(r)},children:(0,V.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7`})})})]}),(0,V.jsxs)(`span`,{className:`cs-mkl`,children:[(0,V.jsx)(Gq,{color:o,children:r+1}),(0,V.jsx)(`span`,{children:fU(n.label)})]})]},n.label))}):(0,V.jsxs)(`div`,{className:`cs-askopts`,children:[n.options.map((t,r)=>(0,V.jsxs)(`button`,{type:`button`,className:`bubble-row`,"data-active":e.picks.includes(r)||void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>e.choose(r),style:{"--delay":`${(c-1-r)*22}ms`},children:[(0,V.jsx)(Gq,{color:o,children:r+1}),(0,V.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-(--bubble-ink)`,children:fU(t.label)}),t.description?(0,V.jsx)(`span`,{className:`min-w-0 truncate text-[13px] text-(--bubble-muted)`,title:t.description,children:t.description}):null,n.multi?(0,V.jsx)(`span`,{className:`cs-cb cs-sm`,"data-on":e.picks.includes(r),children:(0,V.jsx)(Yf,{"aria-hidden":`true`,strokeWidth:3})}):null]},t.label)),c===0?(0,V.jsx)(`div`,{className:`flex h-9 items-center px-2.5 text-[13px] text-(--bubble-muted)`,children:`Type your reply in the box below, then press Enter.`}):null]}),n.multi?(0,V.jsx)(`button`,{type:`button`,className:`bubble-row`,disabled:e.picks.length===0,onMouseDown:e=>e.preventDefault(),onClick:e.submitPicks,children:(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-accent)`,children:e.picks.length===0?`Pick one or more`:`Answer with ${e.picks.length} picked`})}):null]})}function qq({drawer:e,at:t,onAt:n}){let r=e.step,i=r?.options??[],a=t>=0&&t<i.length,o=(0,m.useRef)(t);a&&(o.current=t);let s=i[o.current],c=(0,m.useRef)(null);(0,m.useEffect)(()=>{a&&c.current?.focus({preventScroll:!0})},[a]);let l=e=>n((o.current+e+i.length)%i.length),u=r?NR(Rq(r.prompt,r.header)):`var(--primary)`;return(0,V.jsxs)(`div`,{className:`cs-mxw`,"data-open":a,"aria-hidden":!a,inert:!a,children:[(0,V.jsx)(`div`,{className:`cs-shbd`,onClick:()=>n(-1)}),(0,V.jsxs)(`div`,{ref:c,role:`dialog`,"aria-modal":`true`,"aria-label":s?`Mockup: ${fU(s.label)}`:`Mockup`,tabIndex:-1,className:`cs-mxc`,onKeyDown:t=>{t.key===`Escape`?(t.preventDefault(),t.stopPropagation(),n(-1)):t.key===`ArrowRight`||t.key===`ArrowLeft`?(t.preventDefault(),l(t.key===`ArrowRight`?1:-1)):t.key===`Enter`&&s&&(t.preventDefault(),n(-1),e.choose(o.current))},children:[(0,V.jsx)(`div`,{className:`cs-mxbig`,children:s?(0,V.jsx)(Wq,{option:s,large:!0}):null}),s&&r?(0,V.jsxs)(`div`,{className:`cs-mxf`,children:[(0,V.jsx)(Gq,{color:u,children:o.current+1}),(0,V.jsx)(`b`,{children:fU(s.label)}),(0,V.jsxs)(`span`,{className:`cs-mxwho`,children:[zq(r.prompt,r.header),` · `,r.question]}),i.length>1?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib`,"aria-label":`Previous mockup`,onClick:()=>l(-1),children:(0,V.jsx)($f,{"aria-hidden":`true`,className:`size-3.5`})}),(0,V.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib`,"aria-label":`Next mockup`,onClick:()=>l(1),children:(0,V.jsx)(tp,{"aria-hidden":`true`,className:`size-3.5`})})]}):null,(0,V.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-pri`,onClick:()=>{n(-1),e.choose(o.current)},children:r.multi?e.picks.includes(o.current)?`Unpick this`:`Pick this`:`Choose this`}),(0,V.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib`,"aria-label":`Close`,onClick:()=>n(-1),children:(0,V.jsx)(Fh,{"aria-hidden":`true`,className:`size-3.5`})})]}):null]})]})}var Jq=`bot-lobby.questionsPutAway`,Yq=new Set,Xq;function Zq(){if(Xq!==void 0)return Xq;try{Xq=sessionStorage.getItem(Jq)===`1`}catch{Xq=!1}return Xq}function Qq(e){if(Zq()!==e){Xq=e;try{e?sessionStorage.setItem(Jq,`1`):sessionStorage.removeItem(Jq)}catch{}for(let e of[...Yq])e()}}function $q(e){return Yq.add(e),()=>{Yq.delete(e)}}function eJ(){return(0,m.useSyncExternalStore)($q,Zq,()=>!1)}var tJ={id:`oracle`,label:`Message the team`,placeholder:`Write a message, run a command, or ask an agent`},nJ=new Set([`lobby`,`tasks`,`plan`,`knowledge`]);function rJ(e){return e.kind===`settings`||e.kind===`tab`&&nJ.has(e.tab)}var iJ={id:`knowledge`,label:`Ask what the agents know`,placeholder:`Ask what the agents know…`};function aJ(e,t,n){if(e.kind!==`tab`)return tJ;if(e.tab===`knowledge`)return n?iJ:tJ;if(e.tab===`plan`)return{id:`panel`,label:`Message the panel`,placeholder:`Describe a task, or answer the panel…`};let r=e.tab===`tasks`?TR(e.rest).id??t:void 0;return r?{id:`comment`,label:`Comment on ${r}`,placeholder:`Comment on ${r}'s plan…`,taskId:r}:tJ}var oJ={w:300,h:125},sJ=0;function cJ(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}var lJ={duration:.16,ease:`easeOut`};function uJ({file:e,onRemove:t}){let n=(0,V.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,onClick:t,className:Y(`flex shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,e.image?`absolute top-1 right-1 size-[1.625rem] rounded-full bg-background/85 text-foreground shadow-xs hover:bg-background`:`size-7`),children:(0,V.jsx)(Fh,{"aria-hidden":`true`,className:`size-3.5`})});return e.image?(0,V.jsxs)(Yd.li,{layout:!0,initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:lJ,title:`${e.name} · ${VK(e.size)}`,className:`relative size-16 shrink-0 overflow-hidden rounded-xl border border-(--bubble-edge) bg-background`,children:[(0,V.jsx)(`img`,{src:F(e.image),alt:e.name,className:`size-full object-cover`}),e.state===`uploading`?(0,V.jsxs)(`span`,{className:`pointer-events-none absolute inset-x-0 bottom-0 flex items-center justify-center gap-1 bg-background/85 px-1 text-[0.625rem] text-foreground`,children:[(0,V.jsx)(ER,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}),`uploading`]}):null,n]}):(0,V.jsxs)(Yd.li,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:lJ,className:`flex min-w-0 basis-full items-center gap-2 text-sm text-foreground`,children:[(0,V.jsx)(Lp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,V.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-muted-foreground`,children:[e.state===`uploading`?(0,V.jsx)(ER,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}):null,e.state===`uploading`?`uploading…`:VK(e.size)]}),n]})}function dJ(e,t,n,r){let[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(r);o.current=r;let s=n.kind===`tab`?n.tab:n.kind;return(0,m.useEffect)(()=>a(!1),[s]),(0,m.useEffect)(()=>{if(!t)return;let n=0,r=t=>{e.current?.contains(t.target)||(n=performance.now())},i=t=>{[`PageDown`,`PageUp`,`ArrowDown`,`ArrowUp`,`Home`,`End`,` `].includes(t.key)&&!e.current?.contains(t.target)&&(n=performance.now())},s=t=>{let r=e.current;!r||o.current||performance.now()-n>400||r.contains(document.activeElement)||r.contains(t.target)||a(!0)};return document.addEventListener(`wheel`,r,{capture:!0,passive:!0}),document.addEventListener(`touchmove`,r,{capture:!0,passive:!0}),document.addEventListener(`keydown`,i,{capture:!0}),document.addEventListener(`scroll`,s,{capture:!0,passive:!0}),()=>{document.removeEventListener(`wheel`,r,{capture:!0}),document.removeEventListener(`touchmove`,r,{capture:!0}),document.removeEventListener(`keydown`,i,{capture:!0}),document.removeEventListener(`scroll`,s,{capture:!0})}},[t,e]),{shrunk:i,expand:(0,m.useCallback)(()=>a(!1),[])}}function fJ({children:e}){return(0,V.jsx)(`kbd`,{className:`bubble-kbd`,children:e})}function pJ(e,t){let[n,r]=(0,m.useState)({w:250,h:48});return(0,m.useLayoutEffect)(()=>{let n=t.current;if(!n)return;let i=e===`bar`?{w:Math.ceil(n.scrollWidth)+12,h:48}:{w:580,h:Math.ceil(n.scrollHeight)};r(e=>e.w===i.w&&e.h===i.h?e:i)}),n}function mJ({route:e,projects:t,drawer:n,drawerOpen:r}){let[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)([]),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(null),h=FE(`status`),g=FE(`lobby`),_=dE(),v=(h.data?.busy??!1)||!!g.data?.reply?.trim(),y=rJ(e),b=(0,m.useRef)(y);b.current=y;let{taskId:x}=EW(),S=e.kind===`tab`?e.tab:e.kind,[C,w]=(0,m.useState)(!1);(0,m.useEffect)(()=>w(!1),[S]);let T=(0,m.useMemo)(()=>aJ(e,x,C),[e,x,C]),E=AD(),[D,O]=(0,m.useState)(-1),k=(0,m.useRef)(null),A=(0,m.useRef)(null),ee=(0,m.useRef)(null),j=(0,m.useRef)(null),M=(0,m.useRef)(null),te=(0,m.useRef)(null),ne=(0,m.useRef)(null),N=(0,m.useRef)(o);N.current=o;let re=(0,m.useRef)(void 0),[ie,ae]=(0,m.useState)(0),[oe,se]=(0,m.useState)(null),[ce,le]=(0,m.useState)(void 0),ue=r&&!!n.step&&y&&!_&&f===null,P=T.id===`oracle`&&!f&&!ue?gq(i,ie):void 0,de=(0,m.useMemo)(()=>P?vq(P,h.data?.commands):[],[P?.kind,P?.query,h.data?.commands]),fe=!!P&&de.length>0&&ce!==i&&y&&!_,pe=fe?de.find(e=>e.id===oe)??de[0]:void 0,F=`composer-suggestions`,I={answer:n.left>0&&!r,plan:S===`plan`&&!!E,knowledge:S===`knowledge`&&!C},me=!fe&&f===null&&!ue&&y&&!_&&(I.answer||I.plan||I.knowledge),he=fe||ue||f!==null&&y&&!_,ge=he||me,{shrunk:_e,expand:ve}=dJ(k,y&&!_,e,ge&&!me),[ye,be]=(0,m.useState)(!1),xe=(0,m.useRef)(_e);(0,m.useEffect)(()=>{if(xe.current===_e)return;xe.current=_e,be(!0);let e=setTimeout(()=>be(!1),420);return()=>clearTimeout(e)},[_e]),(0,m.useEffect)(()=>p(null),[S]),(0,m.useEffect)(()=>{(!y||_)&&p(null)},[y,_]),(0,m.useEffect)(()=>{if(!f)return;let e=e=>{A.current?.contains(e.target)||p(null)};return document.addEventListener(`pointerdown`,e,{capture:!0}),()=>document.removeEventListener(`pointerdown`,e,{capture:!0})},[f]);let Se=(0,m.useCallback)(e=>{ve(),p(t=>t===e||e===`projects`&&t===`browse`?null:e)},[ve]),Ce=(0,m.useCallback)(()=>{p(e=>{let t=e===`attach`?`[data-composer-attach]`:e?`[role="combobox"][aria-label="Project"]`:void 0;return t&&requestAnimationFrame(()=>A.current?.querySelector(t)?.focus({preventScroll:!0})),null})},[]);tD(`p`,()=>Se(`projects`),{enabled:y&&!_&&f===null}),(0,m.useEffect)(()=>{let e=()=>{ve(),p(`projects`)};return window.addEventListener($K,e),()=>window.removeEventListener($K,e)},[ve]);let we=(0,m.useRef)(`suggest`),Te=(0,m.useRef)({w:320,h:0}),Ee=f??(ue?`ask`:fe?`suggest`:me?`bar`:we.current),De=(0,m.useRef)(null),Oe=pJ(Ee,De);if(ge){we.current=Ee;let e=M.current?getComputedStyle(M.current).fontFamily:`system-ui, sans-serif`;Te.current=Ee===`suggest`?{w:Cq(de,e),h:xq(de.length)}:Ee===`attach`?oJ:Ee===`projects`?tq(t):Ee===`bar`||Ee===`ask`?Oe:iq}let ke=(0,m.useRef)({items:[],kind:`slash-command`});fe&&P&&pe&&(ke.current={items:de,kind:P.kind,lit:pe.id});let Ae=(0,m.useCallback)(e=>{let t=i.replace(/^\s*[/@][a-z0-9:_.-]*\s*/i,``),n=`${e.insert} ${t}`,r=e.insert.length+1;re.current={start:r,end:r},ae(r),a(n),se(null),M.current?.focus()},[i]);(0,m.useLayoutEffect)(()=>{let e=re.current,t=M.current;e&&t&&(re.current=void 0,t.setSelectionRange(e.start,e.end))},[i]);let je=(0,m.useCallback)(e=>{re.current={start:e.start,end:e.end},ae(e.end),a(e.value)},[]);(0,m.useLayoutEffect)(()=>{let e=j.current,t=A.current;if(!e||!t)return;let n=()=>{t.hasAttribute(`data-shrunk`)||t.style.setProperty(`--ch-open`,`${Math.ceil(e.getBoundingClientRect().height)}px`)};n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[_e]),(0,m.useEffect)(()=>{let e=ee.current,t=k.current;if(!e||!t)return;let n=document.documentElement,r=()=>{let r=e.getBoundingClientRect(),i=t.getBoundingClientRect().bottom;if(n.style.setProperty(`--composer-h`,_||!y?`0px`:`${Math.ceil(i-r.top)}px`),!y||r.width===0){n.style.removeProperty(`--composer-x`),n.style.removeProperty(`--composer-w`);return}n.style.setProperty(`--composer-x`,`${Math.round(r.left)}px`),n.style.setProperty(`--composer-w`,`${Math.round(r.width)}px`)};r();let i=new ResizeObserver(r);return i.observe(e),e.addEventListener(`transitionend`,r),window.addEventListener(`resize`,r),()=>{i.disconnect(),e.removeEventListener(`transitionend`,r),window.removeEventListener(`resize`,r),n.style.setProperty(`--composer-h`,`0px`),n.style.removeProperty(`--composer-x`),n.style.removeProperty(`--composer-w`)}},[_,y]);let Me=(0,m.useCallback)(e=>{if(!b.current)return;let t=[...e],n=8-N.current.length;t.length>n&&H.warning(`At most 8 files go with one message.`);for(let e of t.slice(0,Math.max(0,n))){let t=`f${++sJ}`,n=e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0;s(r=>[...r,{key:t,name:e.name||(n?`image.png`:`file`),size:e.size,...n?{image:n}:{},state:`uploading`}]),HK(e).then(e=>s(n=>n.map(n=>n.key===t?{...n,state:`ready`,info:e}:n))).catch(e=>{H.error(e instanceof Error?e.message:`That file did not upload.`),s(e=>e.filter(e=>e.key!==t))})}},[]),Ne=(0,m.useCallback)(e=>{s(t=>{let n=t.find(t=>t.key===e);return n?.image&&URL.revokeObjectURL(n.image),t.filter(t=>t.key!==e)})},[]),Pe=o.some(e=>e.state===`uploading`),Fe=o.flatMap(e=>e.info?[e.info.id]:[]),Ie=(i.trim().length>0||Fe.length>0)&&!Pe&&!c,Le=(0,m.useCallback)(async()=>{if(!Ie||!b.current)return;l(!0);let e=Fe.length>0?Fe:void 0,t={text:i,...e?{attachments:e}:{}};try{let e=!0;if(T.id===`oracle`){let e=await L(`lobby.send`,t);e.notice&&H(e.notice),e.open===`plan`?bE(yE(`plan`)):S===`knowledge`&&bE(yE(`lobby`))}else T.id===`knowledge`?(e=await U(`knowledge.ask`,t)!==void 0,e&&(window.dispatchEvent(new CustomEvent(MD,{detail:i.trim()})),w(!1))):e=T.id===`panel`?await U(`planner.send`,t)!==void 0:await U(`tasks.comment`,{taskId:T.taskId,...t})!==void 0;if(e){a(``);for(let e of N.current)e.image&&URL.revokeObjectURL(e.image);s([])}}catch(e){H.error(e instanceof Error?e.message:`Could not send`)}finally{l(!1)}},[Ie,Fe,T,i,e,S]),Re=(0,m.useCallback)(async()=>{try{await L(`lobby.abort`,{})}catch(e){H.error(e instanceof Error?e.message:`Could not stop`)}},[]),ze=e=>{if(fe&&pe&&!e.nativeEvent.isComposing){let t=de.indexOf(pe);if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=(t+(e.key===`ArrowDown`?1:-1)+de.length)%de.length;se(de[n].id);return}if(e.key===`Enter`&&!e.shiftKey||e.key===`Tab`){e.preventDefault(),Ae(pe);return}if(e.key===`Escape`){e.preventDefault(),le(i);return}}if(e.key===`Escape`&&!e.nativeEvent.isComposing){e.preventDefault(),f?p(null):ue?Qq(!0):C?w(!1):WE();return}if(ue&&cJ(e)){e.preventDefault(),n.reply(i)?a(``):!i.trim()&&n.step?.multi&&n.submitPicks();return}let t=e.currentTarget,r=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&!e.altKey&&!e.shiftKey&&[`b`,`i`,`e`,`k`].includes(r)){e.preventDefault();let{selectionStart:n,selectionEnd:i,value:a}=t;je(r===`k`?WK(a,n,i):UK(a,n,i,r===`b`?`**`:r===`i`?`_`:"`"));return}if(e.key===`Enter`&&e.shiftKey&&!e.nativeEvent.isComposing&&t.selectionStart===t.selectionEnd){let n=KK(t.value,t.selectionStart);n&&(e.preventDefault(),je(n));return}if(e.key===`Backspace`&&t.value===``&&N.current.length>0){e.preventDefault(),Ne(N.current.at(-1).key);return}(cJ(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey))&&(e.preventDefault(),Le())},Be=e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),Me(t))},Ve=e=>{e.preventDefault(),d(!1),e.dataTransfer.files.length>0&&Me(e.dataTransfer.files)},He=h.data?.workspace.name??`bot-lobby`,Ue=h.data?.branch??h.data?.workspace.branch,We=v&&T.id===`oracle`,Ge=_e?`Write a message…`:ue?n.step?.typed?n.step.placeholder:`Pick an answer above`:We?`The oracle is working. Enter steers it…`:T.placeholder,Ke=e=>{p(null),e.current?.click()},qe=Ee===`ask`?(0,V.jsx)(`div`,{ref:De,children:(0,V.jsx)(Kq,{drawer:n,onExpand:O})},`ask`):Ee===`bar`?(0,V.jsx)(`div`,{ref:De,className:`bubble-pane p-1.5`,style:{width:`max-content`},children:(0,V.jsxs)(`div`,{className:`cs-pbar`,children:[I.answer?(0,V.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq cs-acc`,onMouseDown:e=>e.preventDefault(),onClick:()=>{Qq(!1),requestAnimationFrame(()=>M.current?.focus({preventScroll:!0}))},children:[(0,V.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M21 12a8 8 0 01-11.6 7.1L4 20l1-4.6A8 8 0 1121 12z`}),(0,V.jsx)(`path`,{d:`M9.6 9.5a2.5 2.5 0 014.8.9c0 1.6-2.4 2-2.4 3.4M12 16.5h.01`})]}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-accent)`,children:`Answer questions`}),(0,V.jsxs)(`span`,{className:`cs-ktag`,style:{"--k":`var(--primary)`},children:[n.left,` left`]})]}):null,I.plan?(0,V.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq`,"aria-keyshortcuts":`V`,onMouseDown:e=>e.preventDefault(),onClick:()=>E?.(),children:[(0,V.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M14 3H7a2 2 0 00-2 2v14a2 2 0 002 2h10a2 2 0 002-2V8z`}),(0,V.jsx)(`path`,{d:`M14 3v5h5M9 13h6M9 17h4`})]}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`View plan`}),(0,V.jsx)(`span`,{className:`cs-kb`,children:`V`})]}):null,I.knowledge?(0,V.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq`,onMouseDown:e=>e.preventDefault(),onClick:()=>{w(!0),requestAnimationFrame(()=>M.current?.focus({preventScroll:!0}))},children:[(0,V.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z`})}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Ask the knowledge`})]}):null]})},`bar`):Ee===`suggest`?(0,V.jsx)(wq,{listId:F,items:fe?de:ke.current.items,triggerKind:fe&&P?P.kind:ke.current.kind,activeItemId:pe?.id??null,onHighlightedItemChange:se,onSelect:Ae},`suggest`):Ee===`attach`?(0,V.jsxs)(`div`,{role:`menu`,"aria-label":`Attach`,className:`bubble-pane flex flex-col p-1.5`,onKeyDown:e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=[...e.currentTarget.querySelectorAll(`[role='menuitem']`)];t[(t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:t.length-1))%t.length]?.focus()},children:[(0,V.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`bubble-row h-10`,style:{"--delay":`24ms`},onClick:()=>Ke(te),children:[(0,V.jsx)(Lp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Upload a file…`})]}),(0,V.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`bubble-row h-10`,style:{"--delay":`12ms`},onClick:()=>Ke(ne),children:[(0,V.jsx)(qp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Upload an image…`})]}),(0,V.jsx)(`div`,{className:`h-px`}),(0,V.jsx)(`div`,{className:`flex h-8 items-center px-2.5 text-xs text-(--bubble-muted)`,children:`Or drop files on the composer`})]},`attach`):Ee===`projects`?(0,V.jsx)(rq,{projects:t,tab:S,onBrowse:()=>p(`browse`),onClose:()=>p(null)},`projects`):(0,V.jsx)(cq,{tab:S,onClose:Ce},`browse`);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`cs-scrim`,"data-open":he||void 0,"aria-hidden":`true`}),(0,V.jsx)(`div`,{id:`app-dock`,ref:k,"data-shrunk":_e||void 0,onFocus:ve,className:Y(`dock pointer-events-none absolute inset-x-0 bottom-0 z-30 px-6 pb-[max(24px,env(safe-area-inset-bottom))] transition-opacity duration-200 ease-snap`,_&&`opacity-0`),hidden:!y,"aria-hidden":!y||void 0,inert:_||!y,children:(0,V.jsx)(dq,{ref:A,open:ge,size:Te.current,shrunk:_e,morphing:ye,menu:qe,className:`composer-shell pointer-events-auto`,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||(f?(e.preventDefault(),Ce()):ue&&(e.preventDefault(),Qq(!0)))},children:(0,V.jsxs)(`div`,{ref:ee,className:`bubble-composer group/composer composer-box`,"data-dragging":u||void 0,"data-chat-composer-main-surface":`true`,onPointerDown:ve,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),d(!0))},onDragLeave:()=>d(!1),onDrop:Ve,children:[(0,V.jsxs)(`div`,{ref:j,"data-chat-composer-surface":`true`,children:[(0,V.jsx)(eu,{initial:!1,children:o.length>0?(0,V.jsx)(Yd.ul,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.18,ease:`easeOut`},"aria-label":`Attachments`,className:`composer-files flex max-w-full flex-wrap gap-2 overflow-hidden px-3.5 pt-3`,children:o.map(e=>(0,V.jsx)(uJ,{file:e,onRemove:()=>Ne(e.key)},e.key))},`files`):null}),(0,V.jsx)(`textarea`,{ref:M,id:`composer-text`,"aria-label":T.label,...T.id===`oracle`?{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":fe,"aria-controls":fe?F:void 0}:{},...pe?{"aria-activedescendant":yq(F,pe.id)}:{},value:i,onChange:e=>{a(e.target.value),ae(e.target.selectionStart),p(null)},onSelect:e=>ae(e.currentTarget.selectionStart),onKeyDown:ze,onPaste:Be,placeholder:Ge,rows:1,className:`bubble-text`}),(0,V.jsxs)(`div`,{"data-chat-composer-footer":`true`,className:`bubble-tools composer-tools`,children:[(0,V.jsx)(`button`,{type:`button`,"data-composer-attach":!0,"aria-label":`Attach images, PDFs or files`,"aria-haspopup":`menu`,"aria-expanded":f===`attach`,"data-on":f===`attach`||void 0,"data-tip":`Attach a file`,onPointerDown:e=>e.preventDefault(),onClick:()=>Se(`attach`),className:`bubble-iconbtn bubble-tip bubble-tool size-8 rounded-full`,style:{"--i":0},children:(0,V.jsx)(Tm,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.7})}),(0,V.jsx)(`span`,{className:`bubble-tool flex min-w-0`,style:{"--i":1},children:(0,V.jsx)(nq,{projects:t,name:He,branch:Ue,open:f===`projects`||f===`browse`,onToggle:()=>Se(`projects`)})}),(0,V.jsx)(`span`,{className:`flex-1`}),(0,V.jsx)(`span`,{className:`bubble-hints bubble-tool`,style:{"--i":2},"aria-hidden":`true`,children:fe?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fJ,{children:`↑`}),(0,V.jsx)(fJ,{children:`↓`}),`choose`,(0,V.jsx)(fJ,{children:`↵`}),`insert`]}):f?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fJ,{children:`Esc`}),`close`]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fJ,{children:`Shift`}),(0,V.jsx)(fJ,{children:`↵`}),`new line`]})}),(0,V.jsxs)(`span`,{"data-chat-composer-actions":`right`,className:`bubble-tool flex shrink-0 items-center gap-2`,style:{"--i":3},children:[We?(0,V.jsx)(pq,{onStop:()=>void Re()}):null,(0,V.jsx)(mq,{sending:c,disabled:!Ie,steering:We,onSend:()=>void Le()})]})]})]}),(0,V.jsx)(`input`,{ref:te,type:`file`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach files`,onChange:e=>{Me(e.target.files??[]),e.target.value=``}}),(0,V.jsx)(`input`,{ref:ne,type:`file`,accept:`image/*`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach images`,onChange:e=>{Me(e.target.files??[]),e.target.value=``}}),u?(0,V.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-30 flex items-center justify-center rounded-[inherit] text-sm font-medium text-(--bubble-accent)`,children:`Drop to attach`}):null]})})}),(0,V.jsx)(qq,{drawer:n,at:ue?D:-1,onAt:O})]})}function hJ({open:e,onOpenChange:t}){let n=lE(e,cE.help),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(``),l=(0,m.useId)(),u=()=>{a||(t(!1),i(``),c(``))},d=async()=>{let e=r.trim();if(e&&!a){o(!0),c(``);try{H((await L(`sessions.start`,{request:e})).notice),t(!1),i(``)}catch(e){c(e instanceof Error?e.message:`That did not work. Try again.`)}finally{o(!1)}}};return(0,V.jsx)(tE,{open:n,label:`New session`,description:`Starts a task in a session of its own, in the background.`,onOpenChange:e=>{e||u()},dismissOnBackdrop:!a,className:`max-w-[460px]`,children:(0,V.jsxs)(`div`,{className:`flex w-full flex-col`,children:[(0,V.jsxs)(`div`,{className:`cs-dh`,children:[(0,V.jsx)(`h2`,{children:`New session`}),(0,V.jsx)(`p`,{className:`mt-[5px] text-[12.5px] leading-normal text-muted-foreground`,children:`It runs in the background and shows up in the sidebar; this window carries on with what it is doing.`})]}),(0,V.jsxs)(`div`,{className:`cs-db flex flex-col`,children:[(0,V.jsx)(`label`,{htmlFor:l,className:`mb-[7px] text-[12.5px] font-semibold`,children:`What should it do?`}),(0,V.jsx)(CB,{id:l,value:r,autoFocus:!0,disabled:a,"aria-invalid":s?!0:void 0,placeholder:`Fix the flaky login test, add dark mode to Settings…`,className:`cs-nsta max-h-60 min-h-[108px]`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d())}}),s?(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:s}):null]}),(0,V.jsxs)(`div`,{className:`cs-df`,children:[(0,V.jsxs)(`span`,{className:`mr-auto flex items-center gap-1.5 text-xs text-[var(--faint)]`,children:[(0,V.jsx)(QT,{chord:`Ctrl+Enter`}),` to start`]}),(0,V.jsx)(WT,{variant:`outline`,onClick:u,disabled:a,children:`Cancel`}),(0,V.jsx)(WT,{onClick:()=>void d(),disabled:!r.trim()||a,"aria-busy":a,children:a?`Starting…`:`Start session`})]})]})})}function gJ(){let e=(e,t)=>(0,V.jsxs)(`filter`,{id:e,x:`-20%`,y:`-35%`,width:`140%`,height:`170%`,colorInterpolationFilters:`sRGB`,children:[(0,V.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:t,result:`b`}),(0,V.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`0.9`,dy:`1.3`,result:`dn`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`rimA`}),(0,V.jsx)(`feGaussianBlur`,{in:`rimA`,stdDeviation:`0.4`,result:`rimB`}),(0,V.jsx)(`feComposite`,{in:`rimB`,in2:`shape`,operator:`in`,result:`rimC`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--hl)`},result:`hlc`}),(0,V.jsx)(`feComposite`,{in:`hlc`,in2:`rimC`,operator:`in`,result:`hl`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`-0.9`,dy:`-1.3`,result:`up`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`shA`}),(0,V.jsx)(`feGaussianBlur`,{in:`shA`,stdDeviation:`0.4`,result:`shB`}),(0,V.jsx)(`feComposite`,{in:`shB`,in2:`shape`,operator:`in`,result:`shC`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--sh)`},result:`shc`}),(0,V.jsx)(`feComposite`,{in:`shc`,in2:`shC`,operator:`in`,result:`sh`}),(0,V.jsxs)(`feMerge`,{children:[(0,V.jsx)(`feMergeNode`,{in:`shape`}),(0,V.jsx)(`feMergeNode`,{in:`sh`}),(0,V.jsx)(`feMergeNode`,{in:`hl`})]})]});return(0,V.jsx)(`svg`,{width:`0`,height:`0`,className:`absolute`,"aria-hidden":`true`,focusable:`false`,children:(0,V.jsxs)(`defs`,{children:[e(`cs-baylit`,5),e(`cs-worklit`,3.2),(0,V.jsxs)(`filter`,{id:`cs-bayedge`,x:`-20%`,y:`-35%`,width:`140%`,height:`170%`,colorInterpolationFilters:`sRGB`,children:[(0,V.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`5`,result:`b`}),(0,V.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`2`,dy:`3`,result:`dn`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`tS0`}),(0,V.jsx)(`feGaussianBlur`,{in:`tS0`,stdDeviation:`0.8`,result:`tS1`}),(0,V.jsx)(`feComposite`,{in:`tS1`,in2:`shape`,operator:`in`,result:`tS`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--ehl)`},result:`tc`}),(0,V.jsx)(`feComposite`,{in:`tc`,in2:`tS`,operator:`in`,result:`eh`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`-2`,dy:`-3`,result:`up`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`bS0`}),(0,V.jsx)(`feGaussianBlur`,{in:`bS0`,stdDeviation:`0.8`,result:`bS1`}),(0,V.jsx)(`feComposite`,{in:`bS1`,in2:`shape`,operator:`in`,result:`bS`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--esh)`},result:`bc`}),(0,V.jsx)(`feComposite`,{in:`bc`,in2:`bS`,operator:`in`,result:`es`}),(0,V.jsxs)(`feMerge`,{children:[(0,V.jsx)(`feMergeNode`,{in:`shape`}),(0,V.jsx)(`feMergeNode`,{in:`eh`}),(0,V.jsx)(`feMergeNode`,{in:`es`})]})]}),(0,V.jsxs)(`filter`,{id:`cs-tabdent`,x:`-10%`,y:`-45%`,width:`120%`,height:`190%`,colorInterpolationFilters:`sRGB`,children:[(0,V.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`2.6`,result:`b`}),(0,V.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`2.2`,dy:`3`,result:`dn`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`sA`}),(0,V.jsx)(`feGaussianBlur`,{in:`sA`,stdDeviation:`1.5`,result:`sB`}),(0,V.jsx)(`feComposite`,{in:`sB`,in2:`shape`,operator:`in`,result:`sC`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--tdsh)`},result:`shc`}),(0,V.jsx)(`feComposite`,{in:`shc`,in2:`sC`,operator:`in`,result:`sh`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`-1.4`,dy:`-2`,result:`up`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`hA`}),(0,V.jsx)(`feGaussianBlur`,{in:`hA`,stdDeviation:`1`,result:`hB`}),(0,V.jsx)(`feComposite`,{in:`hB`,in2:`shape`,operator:`in`,result:`hC`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--tdhl)`},result:`hlc`}),(0,V.jsx)(`feComposite`,{in:`hlc`,in2:`hC`,operator:`in`,result:`hl`}),(0,V.jsxs)(`feMerge`,{children:[(0,V.jsx)(`feMergeNode`,{in:`shape`}),(0,V.jsx)(`feMergeNode`,{in:`sh`}),(0,V.jsx)(`feMergeNode`,{in:`hl`})]})]}),(0,V.jsxs)(`filter`,{id:`cs-indgoo`,x:`-20%`,y:`-80%`,width:`140%`,height:`260%`,colorInterpolationFilters:`sRGB`,children:[(0,V.jsx)(`feGaussianBlur`,{stdDeviation:`2.6`}),(0,V.jsx)(`feColorMatrix`,{type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 22 -10`})]})]})})}function _J({className:e,style:t}){return(0,V.jsxs)(`div`,{className:e,"aria-hidden":`true`,style:t,children:[(0,V.jsx)(`div`,{className:`cs-layer cs-edge`,children:(0,V.jsx)(`div`,{className:`cs-bb`})}),(0,V.jsx)(`div`,{className:`cs-layer cs-fill`,children:(0,V.jsx)(`div`,{className:`cs-bb`})})]})}function vJ(e){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)(!1),a=(0,m.useRef)(void 0);(0,m.useEffect)(()=>()=>window.clearTimeout(a.current),[]);let o=(0,m.useCallback)(()=>{window.clearTimeout(a.current),n(!0)},[]),s=(0,m.useCallback)(()=>{window.clearTimeout(a.current),a.current=window.setTimeout(()=>n(!1),e)},[e]),c=(0,m.useCallback)(()=>{window.clearTimeout(a.current),n(!0),a.current=window.setTimeout(()=>n(!1),e)},[e]);return{open:t||r,flash:c,close:()=>{window.clearTimeout(a.current),n(!1)},handlers:{onPointerEnter:e=>{e.pointerType!==`touch`&&o()},onPointerLeave:e=>{e.pointerType!==`touch`&&s()},onFocus:()=>i(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||i(!1)}}}}function yJ({id:e}){let t={width:15,height:15,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0};return e===`lobby`?(0,V.jsx)(`svg`,{...t,children:(0,V.jsx)(`path`,{d:`M21 12a8 8 0 01-11.6 7.1L4 20l1-4.6A8 8 0 1121 12z`})}):e===`tasks`?(0,V.jsxs)(`svg`,{...t,children:[(0,V.jsx)(`path`,{d:`M9 11l3 3L22 4`}),(0,V.jsx)(`path`,{d:`M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11`})]}):e===`plan`?(0,V.jsxs)(`svg`,{...t,children:[(0,V.jsx)(`path`,{d:`M3 6l6-3 6 3 6-3v15l-6 3-6-3-6 3z`}),(0,V.jsx)(`path`,{d:`M9 3v15M15 6v15`})]}):e===`knowledge`?(0,V.jsxs)(`svg`,{...t,children:[(0,V.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 016.5 17H20`}),(0,V.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 014 19.5v-15A2.5 2.5 0 016.5 2z`})]}):(0,V.jsxs)(`svg`,{...t,children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,V.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 00.3 1.8l.1.1a2 2 0 11-2.8 2.8l-.1-.1a1.7 1.7 0 00-1.8-.3 1.7 1.7 0 00-1 1.5V21a2 2 0 11-4 0v-.1a1.7 1.7 0 00-1.1-1.5 1.7 1.7 0 00-1.8.3l-.1.1a2 2 0 11-2.8-2.8l.1-.1a1.7 1.7 0 00.3-1.8 1.7 1.7 0 00-1.5-1H3a2 2 0 110-4h.1a1.7 1.7 0 001.5-1.1 1.7 1.7 0 00-.3-1.8l-.1-.1a2 2 0 112.8-2.8l.1.1a1.7 1.7 0 001.8.3H9a1.7 1.7 0 001-1.5V3a2 2 0 114 0v.1a1.7 1.7 0 001 1.5 1.7 1.7 0 001.8-.3l.1-.1a2 2 0 112.8 2.8l-.1.1a1.7 1.7 0 00-.3 1.8V9a1.7 1.7 0 001.5 1H21a2 2 0 110 4h-.1a1.7 1.7 0 00-1.5 1z`})]})}var bJ=`cubic-bezier(0.3,1.2,0.5,1)`,xJ=`cubic-bezier(0.22,1,0.36,1)`;function SJ({tabs:e,activeId:t,label:n,onSelect:r,flashRef:i}){let a=vJ(600);i.current=a.flash;let o=(0,m.useRef)(null),s=(0,m.useRef)(null),c=(0,m.useRef)({}),[l,u]=(0,m.useState)({closed:99,open:346}),[d,f]=(0,m.useState)(0),p=(0,m.useRef)({placed:!1}),h=e.find(e=>e.id===t),g=h?.id??n.id,_=h?.label??n.text;(0,m.useLayoutEffect)(()=>{let e=()=>{let e=s.current?Math.ceil(s.current.getBoundingClientRect().width)+40:99,t=o.current?[...o.current.querySelectorAll(`[role='tab']`)]:[],n=t.length?Math.ceil(t.reduce((e,t)=>e+t.offsetWidth,0)+(t.length-1)*2)+20:346;u(t=>t.closed===e&&t.open===n?t:{closed:e,open:n})};e(),document.fonts?.ready.then(e)},[_,e.length]),(0,m.useEffect)(()=>f(e=>e+1),[g]);let v=(0,m.useCallback)(()=>{let e=o.current;if(!e)return;let n=t?c.current[t]:void 0;if(!n)return;let r=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,i=!p.current.placed,a=n.offsetLeft,s=e.offsetWidth-a-n.offsetWidth,l=p.current.left===void 0||a>p.current.left;for(let t of e.querySelectorAll(`.cs-tabind`)){let n=t.firstElementChild;if(n){if(i||r||e.offsetWidth===0){n.style.transition=`none`,n.style.left=`${a}px`,n.style.right=`${s}px`;continue}a!==p.current.left&&(n.style.transition=l?`left 520ms ${xJ} 24ms, right 320ms ${bJ}`:`left 320ms ${bJ}, right 520ms ${xJ} 24ms`,n.style.left=`${a}px`,n.style.right=`${s}px`,t.animate?.([{transform:`scaleY(1)`},{transform:`scaleY(0.84)`,offset:.35},{transform:`scaleY(1.05)`,offset:.75},{transform:`scaleY(1)`}],{duration:540,easing:`ease-in-out`}))}}e.offsetWidth>0&&(p.current={left:a,placed:!0})},[t]);(0,m.useLayoutEffect)(()=>{let e=requestAnimationFrame(()=>requestAnimationFrame(v));return()=>cancelAnimationFrame(e)},[v,l.open]);function y(n){if(n.key===`ArrowDown`&&!n.altKey){UE()&&n.preventDefault();return}let i=n.key===`ArrowRight`?1:n.key===`ArrowLeft`?-1:0;if(!i||e.length===0)return;n.preventDefault();let a=n.target.closest(`[role='tab']`)?.id.replace(/^tab-/,``)??t,o=e[(Math.max(0,e.findIndex(e=>e.id===a))+i+e.length)%e.length];GE.active=!0,GE.to=o.id,window.setTimeout(()=>{GE.active=!1,GE.to=void 0},3e3),r(o.id),c.current[o.id]?.focus({preventScroll:!0})}let b=a.open,x={"--wT":`${b?l.open:l.closed}px`,"--hT":b?`38px`:`30px`};return{open:b,vars:x,ghost:(0,V.jsx)(_J,{className:`cs-gt`,style:x}),bay:(0,V.jsx)(`div`,{className:`cs-tbwrap`,style:x,...a.handlers,children:(0,V.jsxs)(`div`,{className:`cs-tbx`,children:[(0,V.jsx)(`div`,{className:`cs-tbc`,"aria-hidden":`true`,children:(0,V.jsxs)(`span`,{ref:s,className:`cs-lb`,"data-p":String(d%2),children:[(0,V.jsx)(`span`,{className:`cs-ti`,children:(0,V.jsx)(yJ,{id:g})}),_]},g)}),(0,V.jsx)(`div`,{className:`cs-tbo`,"data-none":t?void 0:``,children:(0,V.jsxs)(`div`,{ref:o,role:`tablist`,"aria-label":`Lobby tabs`,onKeyDown:y,className:`cs-track`,children:[(0,V.jsx)(`span`,{className:`cs-tabind cs-dent`,"aria-hidden":`true`,children:(0,V.jsx)(`i`,{})}),(0,V.jsx)(`span`,{className:`cs-tabind cs-tint`,"aria-hidden":`true`,children:(0,V.jsx)(`i`,{})}),e.map((e,n)=>(0,V.jsxs)(`a`,{ref:t=>{c.current[e.id]=t},role:`tab`,id:`tab-${e.id}`,href:`#/${e.id}`,"aria-selected":e.id===t,"aria-keyshortcuts":e.key,title:`${e.label} · ${e.key.replace(`+`,` `)}`,tabIndex:e.id===t||!t&&n===0?0:-1,className:`cs-tab`,style:{"--i":n},children:[(0,V.jsx)(`span`,{className:`cs-ti`,children:(0,V.jsx)(yJ,{id:e.id})}),e.label]},e.id))]})})]})})}}function CJ({children:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(_J,{className:`cs-gr`}),(0,V.jsx)(`div`,{className:Y(`cs-rbx`),children:e})]})}function wJ(e){return e.waiting>0&&e.alive?`asking`:e.status===`exited`||!e.alive?`exited`:e.busy||e.status===`working`?`working`:e.status===`starting`?`starting`:`idle`}function TJ(e,t){let n=e?.sessionId,r={id:`here`,name:e?.sessionName?.trim()||`This window`,where:`here`,state:e?.busy?`working`:`idle`,waiting:0,...n?{sessionId:n}:{}},i=(t?.background??[]).filter(e=>!n||e.sessionId!==n).map(e=>({id:`bg:${e.key}`,name:e.name,where:`background`,state:wJ(e),waiting:e.alive?e.waiting:0,key:e.key,...e.sessionId?{sessionId:e.sessionId}:{}})),a=new Set([n,...i.map(e=>e.sessionId)].filter(Boolean)),o=(t?.live??[]).filter(e=>!a.has(e.sessionId)).map(e=>({id:`live:${e.sessionId}`,name:e.name?.trim()||`Unnamed session`,where:`elsewhere`,state:`idle`,waiting:0,sessionId:e.sessionId}));return i.sort((e,t)=>Number(e.state===`exited`)-Number(t.state===`exited`)),[r,...i,...o]}var EJ=`app.sidebar.pinned`,DJ=()=>hz(EJ),OJ={w:244,h:`min(520px, calc(100vh - 112px))`},kJ=`cs-iconbtn cs-sm`;function AJ({label:e,hint:t,side:n=`bottom`,children:r}){return(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:r}),(0,V.jsxs)(VI,{side:n,children:[e,` `,t?(0,V.jsx)(QT,{chord:t}):null]})]})}function jJ(){let e=FE(`status`).data;return TJ(e,_R(`sessions.list`,{},[`sessions`]).data)}function MJ(){return(0,m.useCallback)(async e=>{if(e.where===`here`)return bE(`#/lobby`);if(e.where===`elsewhere`)return void H.info(`${e.name} runs in another terminal. Switch to that terminal to work in it.`);await U(`sessions.switch`,e.key?{key:e.key}:{sessionId:e.sessionId})&&bE(`#/lobby`)},[])}function NJ({entry:e}){return e.where!==`elsewhere`&&e.state===`asking`?(0,V.jsxs)(`span`,{className:`cs-badge`,children:[(0,V.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,V.jsx)(`path`,{d:`M9.1 9a3 3 0 015.8 1c0 2-3 2.5-3 4M12 17h.01`})]}),e.waiting,(0,V.jsxs)(`span`,{className:`sr-only`,children:[e.waiting===1?` question`:` questions`,`, Waiting`]})]}):e.where!==`elsewhere`&&(e.state===`working`||e.state===`starting`)?(0,V.jsxs)(`span`,{className:Y(`inline-flex shrink-0`,e.state===`working`?`text-primary`:`text-muted-foreground`),children:[(0,V.jsx)(lp,{"aria-hidden":`true`,className:`session-spin size-3.5`}),(0,V.jsx)(`span`,{className:`sr-only`,children:e.state===`working`?`Working`:`Starting`})]}):(0,V.jsx)(`span`,{className:`sr-only`,children:e.where===`elsewhere`?`Other terminal`:e.state===`exited`?`Ended`:`Idle`})}var PJ={here:`This window`,background:`Background`,elsewhere:`Other terminal`};function FJ(e){let t=e.key;return U(`sessions.archive`,{key:t},{undo:()=>void U(`sessions.archive`,{key:t,archived:!1})})}function IJ({entry:e,onDone:t}){let[n,r]=(0,m.useState)(e.name),i=(0,m.useRef)(!1),a=async()=>{if(i.current)return;i.current=!0;let r=n.replace(/\s+/g,` `).trim();r&&r!==e.name&&await U(`sessions.rename`,{...e.where===`here`?{}:{key:e.key},name:r}),t()};return(0,V.jsx)(`input`,{value:n,autoFocus:!0,maxLength:120,"aria-label":`New name for ${e.name}`,onFocus:e=>e.currentTarget.select(),onChange:e=>r(e.target.value),onBlur:()=>void a(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),a()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i.current=!0,t())},className:`h-6 w-full min-w-0 rounded-md bg-[var(--fill)] px-1.5 text-[13px] text-foreground outline-none ring-2 ring-ring`})}function LJ({entry:e,index:t}){let n=MJ(),[r,i]=(0,m.useState)(!1),a=e.state===`exited`||e.where===`elsewhere`,o=e.where!==`elsewhere`,s=e.where===`background`&&e.state===`exited`&&!!e.key,c=o||s,l={"--i":t};return(0,V.jsxs)(`li`,{className:`cs-srow session-item`,children:[r?(0,V.jsx)(`div`,{className:`cs-sr`,"data-active":e.where===`here`||void 0,style:l,children:(0,V.jsx)(IJ,{entry:e,onDone:()=>i(!1)})}):(0,V.jsxs)(`button`,{type:`button`,"aria-current":e.where===`here`?`true`:void 0,"aria-label":e.where===`here`?`${e.name}, this window`:e.where===`elsewhere`?`${e.name}, in another terminal`:`Switch to ${e.name}`,title:e.name,"data-where":e.where,"data-state":e.state,"data-dim":a||void 0,onClick:()=>void n(e),onDoubleClick:e=>{o&&(e.preventDefault(),i(!0))},className:`cs-sr session-row`,style:l,children:[(0,V.jsx)(`span`,{className:`cs-grow`,children:e.name}),(0,V.jsx)(`span`,{className:Y(`flex shrink-0 items-center`,c&&`cs-sstate`),children:(0,V.jsx)(NJ,{entry:e})})]}),!r&&c?(0,V.jsxs)(`span`,{className:`cs-sacts`,children:[o?(0,V.jsx)(AJ,{label:`Rename`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Rename ${e.name}`,onClick:()=>i(!0),className:`cs-sact`,children:(0,V.jsx)(km,{"aria-hidden":`true`,className:`size-3.5`})})}):null,s?(0,V.jsx)(AJ,{label:`Archive`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Archive ${e.name}`,onClick:()=>void FJ(e),className:`cs-sact`,children:(0,V.jsx)(Af,{"aria-hidden":`true`,className:`size-3.5`})})}):null]}):null]})}function RJ({id:e,label:t,entries:n,start:r,archivable:i=!1}){let[a,o]=gz(`app.sidebar.${e}`),s=(0,m.useId)();return n.length===0?null:(0,V.jsxs)(`section`,{"aria-label":t,className:`group/shelf flex flex-col`,children:[(0,V.jsxs)(`div`,{className:`cs-sh`,style:{"--i":r},children:[(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":!a,"aria-controls":s,onClick:o,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left outline-none hover:text-foreground focus-visible:underline`,children:[(0,V.jsx)(`span`,{children:t}),a?(0,V.jsx)(`span`,{className:`tabular-nums`,children:n.length}):null,(0,V.jsx)(Zf,{"aria-hidden":`true`,className:Y(`size-3 opacity-0 transition-[opacity,rotate] duration-150 group-hover/shelf:opacity-100 group-focus-within/shelf:opacity-100`,a&&`-rotate-90 opacity-100`)})]}),i?(0,V.jsx)(`button`,{type:`button`,onClick:()=>void(async()=>{for(let e of n)e.key&&await U(`sessions.archive`,{key:e.key})})(),className:`shrink-0 outline-none hover:text-foreground focus-visible:underline`,children:`Archive all`}):null]}),a?null:(0,V.jsx)(`ul`,{id:s,className:`flex flex-col`,children:n.map((e,t)=>(0,V.jsx)(LJ,{entry:e,index:r+1+t},e.id))})]})}function zJ(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean),r=`${e.name} ${PJ[e.where]}`.toLowerCase();return n.every(e=>r.includes(e))}function BJ({query:e,onQuery:t,onNew:n}){return(0,V.jsxs)(`label`,{className:`cs-sr cs-search`,style:{"--i":0},children:[(0,V.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,V.jsx)(`path`,{d:`M21 21l-4.3-4.3`})]}),(0,V.jsx)(`input`,{type:`search`,value:e,"aria-label":`Search sessions`,placeholder:`Search`,onChange:e=>t(e.target.value),onKeyDown:n=>{n.key===`Escape`&&e&&(n.preventDefault(),n.stopPropagation(),t(``))}}),(0,V.jsx)(AJ,{label:`New session`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`New session`,"aria-haspopup":`dialog`,onClick:n,className:`flex text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground`,children:(0,V.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M12 20h9`}),(0,V.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`})]})})})]})}function VJ({query:e}){let t=jJ(),n=t.filter(t=>zJ(t,e)),r=n.filter(e=>e.where===`here`&&e.state!==`exited`),i=n.filter(e=>e.where===`background`&&e.state!==`exited`),a=n.filter(e=>e.where===`elsewhere`),o=n.filter(e=>e.where!==`elsewhere`&&e.state===`exited`),s=1,c=e=>{let t=s;return s+=e+1,t},l=c(r.length),u=c(i.length);return(0,V.jsxs)(`nav`,{"aria-label":`Sessions list`,className:`cs-sblist`,children:[n.length===0?(0,V.jsxs)(`p`,{className:`px-2.5 py-1.5 text-xs text-muted-foreground`,children:[`No sessions match “`,e.trim(),`”.`]}):null,r.length>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`cs-sh`,style:{"--i":l},children:`This window`}),(0,V.jsx)(`ul`,{className:`flex flex-col`,children:r.map((e,t)=>(0,V.jsx)(LJ,{entry:e,index:l+1+t},e.id))})]}):null,i.length>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`cs-sh`,style:{"--i":u},children:`Background`}),(0,V.jsx)(`ul`,{className:`flex flex-col`,children:i.map((e,t)=>(0,V.jsx)(LJ,{entry:e,index:u+1+t},e.id))})]}):!e.trim()&&t.length===1?(0,V.jsx)(`p`,{className:`cs-sh`,style:{"--i":u},children:`No other sessions are running.`}):null,(0,V.jsx)(RJ,{id:`elsewhere`,label:`Other terminals`,entries:a,start:c(a.length)}),(0,V.jsx)(RJ,{id:`ended`,label:`Ended`,entries:o,start:c(o.length),archivable:!0})]})}function HJ({route:e,keys:t,onHelp:n}){let r=t.settings??`Alt+S`;return(0,V.jsxs)(`div`,{className:`cs-sbfoot`,children:[(0,V.jsxs)(`a`,{href:`#/settings`,"aria-label":`Settings`,"aria-current":e.kind===`settings`?`page`:void 0,"aria-keyshortcuts":r,className:`cs-sr`,style:{"--i":20},children:[(0,V.jsx)(yJ,{id:`settings`}),(0,V.jsx)(`span`,{className:`cs-grow`,children:`Settings`}),(0,V.jsx)(QT,{chord:r})]}),(0,V.jsxs)(`div`,{className:`cs-sr cs-tools`,style:{"--i":21},children:[(0,V.jsx)(PK,{hint:t.help??`Alt+H`,onHelp:n,className:kJ}),(0,V.jsx)(FK,{className:kJ}),(0,V.jsx)(RK,{className:kJ}),(0,V.jsx)(zK,{className:kJ}),(0,V.jsx)(BK,{className:kJ})]})]})}function UJ(e){let[t,n]=gz(EJ),r=vJ(160),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),c=t||r.open||o,l={"--wL":`${c?OJ.w:46}px`,"--hL":c?OJ.h:`148px`,"--sb-open-h":OJ.h},u=(0,m.useCallback)(()=>s(!0),[]);return{open:c,ghost:(0,V.jsx)(_J,{className:`cs-gl`,style:l}),bay:(0,V.jsxs)(`div`,{className:`cs-sbwrap`,style:l,...r.handlers,children:[(0,V.jsxs)(`aside`,{id:`app-sidebar`,"aria-label":`Sidebar`,className:`cs-sbx`,children:[(0,V.jsxs)(`div`,{className:`cs-sbmini`,inert:c,children:[(0,V.jsx)(AJ,{label:t?`Unpin sidebar`:`Pin sidebar`,hint:e.keys.sidebar,side:`right`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Sessions`,"aria-pressed":t,"aria-keyshortcuts":e.keys.sidebar,onClick:n,className:`cs-iconbtn`,children:(0,V.jsx)(yJ,{id:`lobby`})})}),(0,V.jsx)(AJ,{label:`New session`,side:`right`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`New session`,"aria-haspopup":`dialog`,onClick:u,className:`cs-iconbtn`,children:(0,V.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M12 20h9`}),(0,V.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`})]})})}),(0,V.jsx)(AJ,{label:`Settings`,hint:e.keys.settings??`Alt+S`,side:`right`,children:(0,V.jsx)(`a`,{href:`#/settings`,"aria-label":`Settings`,"aria-current":e.route.kind===`settings`?`page`:void 0,className:`cs-iconbtn`,children:(0,V.jsx)(yJ,{id:`settings`})})})]}),(0,V.jsxs)(`div`,{className:`cs-sbfull`,inert:!c,children:[(0,V.jsx)(BJ,{query:i,onQuery:a,onNew:u}),(0,V.jsx)(VJ,{query:i}),(0,V.jsx)(HJ,{...e})]})]}),(0,V.jsx)(hJ,{open:o,onOpenChange:s})]})}}var WJ=`bot-lobby.terminal.open`,GJ=`bot-lobby.terminal.height`,KJ=`bot-lobby.terminal.popup`,qJ={start:280,min:140},JJ=new Set,YJ,XJ,ZJ;function QJ(e){try{return localStorage.getItem(e)}catch{return null}}function $J(e,t){try{localStorage.setItem(e,t)}catch{}}function eY(){for(let e of[...JJ])e()}function tY(e){return JJ.add(e),()=>{JJ.delete(e)}}function nY(){return YJ??=QJ(WJ)===`1`,YJ}function rY(){if(XJ===void 0){let e=Number(QJ(GJ));XJ=e>=qJ.min?e:qJ.start}return XJ}function iY(e){YJ=e,$J(WJ,e?`1`:`0`),eY()}function aY(){iY(!nY())}function oY(e){XJ=Math.max(qJ.min,Math.round(e)),$J(GJ,String(XJ)),eY()}function sY(){return(0,m.useSyncExternalStore)(tY,nY,()=>!1)}function cY(){return(0,m.useSyncExternalStore)(tY,rY,()=>qJ.start)}function lY(){return ZJ??=QJ(KJ)===`1`,ZJ}function uY(e){ZJ=e,$J(KJ,e?`1`:`0`),eY()}function dY(){return(0,m.useSyncExternalStore)(tY,lY,()=>!1)}var fY=`modulepreload`,pY=function(e){return`/`+e},mY={},hY=function(e){return e.pathname.endsWith(`.css`)},gY=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=pY(t,n);let r=s(t);if(r.href in mY)return;mY[r.href]=!0;let i=hY(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:fY,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},_Y=(0,m.lazy)(()=>gY(()=>import(`./TerminalView-e5ZKQJXF.js`),__vite__mapDeps([0,1,2,3]))),vY=`inline-flex size-6 items-center justify-center text-foreground/80 outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40 aria-pressed:bg-accent aria-pressed:text-foreground`;function yY({label:e,hint:t,children:n}){return(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:n}),(0,V.jsxs)(VI,{side:`top`,children:[e,` `,t?(0,V.jsx)(QT,{chord:t}):null]})]})}function bY({hint:e,className:t}){let n=sY();return(0,V.jsx)(yY,{label:n?`Hide terminal`:`Terminal`,hint:e,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Terminal`,"aria-pressed":n,"aria-controls":n?`terminal-drawer`:void 0,"aria-keyshortcuts":e,onClick:aY,className:t,children:(0,V.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M4 17l6-6-6-6M12 19h8`})})})})}function xY(e){let[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(``),a=(0,m.useCallback)(async()=>{try{n(await L(`terminal.list`,{})),i(``)}catch(e){i(e instanceof Error?e.message:`The terminals could not be read.`)}},[]);return(0,m.useEffect)(()=>{e&&a()},[e,a]),{list:t,error:r,reload:a}}function SY({height:e,max:t}){let n=(0,m.useRef)(null);return(0,V.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-label":`Resize terminal`,"aria-orientation":`horizontal`,"aria-valuenow":e,"aria-valuemin":qJ.min,"aria-valuemax":t,className:`terminal-edge`,onPointerDown:t=>{t.button===0&&(t.currentTarget.setPointerCapture?.(t.pointerId),n.current={y:t.clientY,height:e},document.documentElement.dataset.resizing=`row`)},onPointerMove:e=>{n.current&&oY(Math.min(t,n.current.height+n.current.y-e.clientY))},onPointerUp:()=>{n.current=null,delete document.documentElement.dataset.resizing},onPointerCancel:()=>{n.current=null,delete document.documentElement.dataset.resizing},onDoubleClick:()=>oY(qJ.start),onKeyDown:n=>{(n.key===`ArrowUp`||n.key===`ArrowDown`)&&(n.preventDefault(),oY(Math.min(t,e+(n.key===`ArrowUp`?24:-24))))}})}function CY({toggleKey:e}){let t=sY(),n=dY(),r=cY(),i=lE(t&&n,cE.sheet),{list:a,error:o,reload:s}=xY(t),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(()=>Math.round(window.innerHeight*.7)),h=a?.terminals??[],g=h.find(e=>e.id===c)??h.at(-1);(0,m.useEffect)(()=>{let e=()=>p(Math.round(window.innerHeight*.7));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let _=(0,m.useCallback)(async()=>{d(!0);try{let e=await L(`terminal.open`,{cols:100,rows:24});l(e.id),await s()}catch(e){H.error(e instanceof Error?e.message:`The terminal did not start.`)}finally{d(!1)}},[s]),v=(0,m.useCallback)(async e=>{try{await L(`terminal.close`,{id:e})}catch{}await s()},[s]),y=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!t){y.current=!1;return}!a||!a.available||a.terminals.length>0||y.current||u||(y.current=!0,_())},[t,a,u,_]);let b=t&&!n?Math.min(r,f):0;if((0,m.useEffect)(()=>{let e=document.documentElement;return b?e.style.setProperty(`--terminal-h`,`${b}px`):e.style.removeProperty(`--terminal-h`),()=>{e.style.removeProperty(`--terminal-h`)}},[b]),!t)return null;let x=(0,V.jsx)(wY,{list:a,error:o,terminals:h,shown:g,busy:u,popup:n,toggleKey:e,onPick:l,onStart:()=>void _(),onEnd:e=>void v(e),onReload:()=>void s()});return n?(0,V.jsx)(tE,{open:i,onOpenChange:e=>{e||iY(!1)},label:`Terminal`,className:`terminal-pop h-[min(72svh,40rem)] max-h-none max-w-5xl`,onEscapeKeyDown:e=>{e.target?.closest?.(`.xterm`)&&e.preventDefault()},children:(0,V.jsx)(`div`,{id:`terminal-drawer`,className:`flex min-h-0 flex-1`,children:x})}):(0,V.jsxs)(`section`,{id:`terminal-drawer`,"aria-label":`Terminal`,className:`terminal-drawer relative flex shrink-0 border-t border-border`,style:{height:Math.min(r,f)},children:[(0,V.jsx)(SY,{height:Math.min(r,f),max:f}),x]})}function wY({list:e,error:t,terminals:n,shown:r,busy:i,popup:a,toggleKey:o,onPick:s,onStart:c,onEnd:l,onReload:u}){let d=(0,V.jsxs)(`div`,{className:`terminal-tools pointer-events-auto inline-flex items-center overflow-hidden rounded-md border border-border/80 bg-background shadow-xs`,children:[(0,V.jsx)(yY,{label:`New terminal`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`New terminal`,disabled:i||e?.available===!1,onClick:c,className:vY,children:(0,V.jsx)(Lm,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,V.jsx)(yY,{label:`End this terminal`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`End this terminal`,disabled:!r,onClick:()=>r&&l(r.id),className:vY,children:(0,V.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,V.jsx)(yY,{label:a?`Back to the drawer`:`Open in a pop-up`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Pop out terminal`,"aria-pressed":a,onClick:()=>uY(!a),className:vY,children:(0,V.jsx)(jm,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,V.jsx)(yY,{label:`Hide terminal`,hint:o,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Hide terminal`,onClick:()=>iY(!1),className:vY,children:a?(0,V.jsx)(Fh,{"aria-hidden":`true`,className:`size-3.5`}):(0,V.jsx)(Zf,{"aria-hidden":`true`,className:`size-3.5`})})})]}),f=(0,V.jsx)(V.Fragment,{children:e&&!e.available?(0,V.jsx)(`p`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:e.reason}):t?(0,V.jsx)(`p`,{role:`alert`,className:`flex h-full items-center justify-center px-6 text-center text-sm text-destructive`,children:t}):(0,V.jsxs)(m.Suspense,{fallback:(0,V.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`Loading the terminal…`}),children:[e&&n.length===0&&!i?(0,V.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`No terminal is running. Start one with New terminal.`}):null,n.map(e=>(0,V.jsx)(_Y,{id:e.id,active:e.id===r?.id,toggleKey:o,onExit:u},e.id))]})}),p=n.length>1?(0,V.jsx)(`nav`,{"aria-label":`Terminals`,className:Y(`flex w-36 shrink-0 flex-col gap-0.5 overflow-y-auto border-l border-border px-1 pb-1`,a?`pt-2`:`pt-10`),children:n.map(e=>(0,V.jsxs)(`button`,{type:`button`,"aria-current":e.id===r?.id?`true`:void 0,onClick:()=>s(e.id),className:Y(`flex h-6 min-w-0 items-center gap-1.5 rounded px-1.5 text-left text-xs text-muted-foreground outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-accent aria-[current=true]:text-foreground`,!e.alive&&`opacity-60`),children:[(0,V.jsx)(lh,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.title}),e.alive?null:(0,V.jsx)(`span`,{className:`sr-only`,children:`, ended`})]},e.id))}):null;return a?(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,V.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border/70 pr-2 pl-4`,children:[(0,V.jsx)(lh,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`flex-1 text-sm font-medium`,children:`Terminal`}),d]}),(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,V.jsx)(`div`,{className:`min-w-0 flex-1 py-2 pl-2`,children:(0,V.jsx)(`div`,{className:`relative h-full`,children:f})}),p]})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[f,(0,V.jsx)(`div`,{className:`pointer-events-none absolute top-2 right-2 z-20`,children:d})]}),p]})}var TY=(0,m.lazy)(()=>gY(()=>import(`./CodeSurface-DBSaDzAn.js`),__vite__mapDeps([4,1,2]))),EY=`inline-flex size-7 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40 aria-pressed:bg-accent aria-pressed:text-foreground`;function DY({label:e,hint:t,children:n}){return(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:n}),(0,V.jsxs)(VI,{side:`bottom`,children:[e,` `,t?(0,V.jsx)(QT,{chord:t}):null]})]})}function OY({hint:e,className:t}){let{open:n}=OL();return(0,V.jsx)(DY,{label:`Code and changes`,hint:e,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Code`,"aria-pressed":n,"aria-keyshortcuts":e,onClick:()=>n?EL():TL(),className:t,children:(0,V.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M16 18l6-6-6-6M8 6l-6 6 6 6`})})})})}var kY={modified:{letter:`M`,word:`Modified`,tone:`text-warning`},added:{letter:`A`,word:`Added`,tone:`text-success`},untracked:{letter:`U`,word:`New, not committed`,tone:`text-success`},deleted:{letter:`D`,word:`Deleted`,tone:`text-destructive`},renamed:{letter:`R`,word:`Renamed`,tone:`text-primary`}};function AY(e){let t=e.lastIndexOf(`/`);return t<0?{dir:``,name:e}:{dir:e.slice(0,t),name:e.slice(t+1)}}function jY({change:e,className:t}){return e.additions===void 0&&e.deletions===void 0?null:(0,V.jsxs)(`span`,{className:Y(`shrink-0 font-mono text-[0.6875rem] tabular-nums`,t),children:[(0,V.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions??0]}),` `,(0,V.jsxs)(`span`,{className:`text-destructive`,children:[`−`,e.deletions??0]})]})}function MY(){let[e,t]=(0,m.useState)(()=>document.documentElement.classList.contains(`dark`));return(0,m.useEffect)(()=>{let e=document.documentElement,n=new MutationObserver(()=>t(e.classList.contains(`dark`)));return n.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>n.disconnect()},[]),e}function NY({changes:e,loading:t,error:n,current:r,onPick:i,onRefresh:a}){let[o,s]=(0,m.useState)(``),c=e?.files??[],l=c.reduce((e,t)=>({additions:e.additions+(t.additions??0),deletions:e.deletions+(t.deletions??0)}),{additions:0,deletions:0});function u(e){e.preventDefault();let t=o.trim();t&&(i(t),s(``))}return(0,V.jsxs)(`nav`,{"aria-label":`Changed files`,className:`code-rail flex w-64 shrink-0 flex-col border-r border-border max-md:w-52`,children:[(0,V.jsx)(`form`,{onSubmit:u,className:`border-b border-border p-2`,children:(0,V.jsxs)(`label`,{className:`flex h-8 items-center gap-2 rounded-md border border-input bg-background px-2 transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/20`,children:[(0,V.jsx)($m,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),"aria-label":`Open a file by path`,placeholder:`Open a file by path…`,spellCheck:!1,autoComplete:`off`,className:`h-full min-w-0 flex-1 bg-transparent font-mono text-xs outline-none placeholder:font-sans placeholder:text-muted-foreground`})]})}),(0,V.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 px-3 text-xs`,children:[(0,V.jsx)(`span`,{className:`font-medium text-foreground`,children:`Changes`}),(0,V.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[c.length,e?.truncated?`+`:``]}),(0,V.jsx)(jY,{change:l,className:`ml-auto`}),(0,V.jsx)(DY,{label:`Read the changes again`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Refresh changes`,onClick:a,disabled:t,className:Y(EY,`-mr-1.5 size-6`,c.length?``:`ml-auto`),children:(0,V.jsx)(zm,{"aria-hidden":`true`,className:Y(`size-3.5`,t&&`animate-spin motion-reduce:animate-none`)})})})]}),(0,V.jsxs)(`ul`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-1.5 pb-2`,children:[c.map(e=>{let{dir:t,name:n}=AY(e.path),a=kY[e.status];return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,onClick:()=>i(e.path),"aria-current":e.path===r?`true`:void 0,title:e.from?`${e.from} → ${e.path}`:e.path,className:`group/row flex h-7 w-full min-w-0 items-center gap-2 rounded-md px-1.5 text-left text-[0.8125rem] outline-none transition-colors duration-150 hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-accent`,children:[(0,V.jsx)(`span`,{"aria-label":a.word,className:Y(`w-3 shrink-0 text-center font-mono text-[0.6875rem] font-semibold`,a.tone),children:a.letter}),(0,V.jsxs)(`span`,{className:Y(`min-w-0 flex-1 truncate`,e.status===`deleted`&&`text-muted-foreground line-through decoration-muted-foreground/50`),children:[n,t?(0,V.jsx)(`span`,{className:`ml-1.5 text-xs text-muted-foreground`,children:t}):null]}),(0,V.jsx)(jY,{change:e})]})},e.path)}),e&&!e.git?(0,V.jsx)(`li`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:`This folder is not a git repository, so there are no changes to show. Open a file by its path above.`}):null,e?.git&&c.length===0?(0,V.jsx)(`li`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:`No changes since the last commit.`}):null,n?(0,V.jsx)(`li`,{role:`alert`,className:`px-2 py-3 text-xs text-destructive`,children:n}):null]})]})}function PY(e){let[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(!1),s=(0,m.useRef)(0),c=(0,m.useCallback)(async e=>{let t=++s.current;o(!0),i(void 0);try{let r=await L(`code.read`,{path:e});t===s.current&&n(e=>({file:r,version:(e?.version??0)+1}))}catch(e){t===s.current&&(n(void 0),i(e instanceof Error?e.message:String(e)))}finally{t===s.current&&o(!1)}},[]);return(0,m.useEffect)(()=>{e?c(e):(s.current++,n(void 0),i(void 0))},[e,c]),{loaded:t,setLoaded:n,error:r,loading:a,reload:()=>e&&c(e)}}function FY({requested:e,requestedMode:t,request:n,codeKey:r,onClose:i,onDirtyChange:a,closeAsked:o}){let s=_R(`code.changes`,{},[`lobby`,`tasks`]),[c,l]=(0,m.useState)(e),[u,d]=(0,m.useState)(t??`code`),{loaded:f,setLoaded:p,error:h,loading:g,reload:_}=PY(c),[v,y]=(0,m.useState)(),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(),E=FL(),D=IL(),O=MY(),k=f?.file,A=v!==void 0&&v!==k?.contents;(0,m.useEffect)(()=>a(A),[A,a]),(0,m.useEffect)(()=>{if(!e||e===c){t&&d(t);return}j({kind:`open`,path:e})},[n]),(0,m.useEffect)(()=>{if(!c&&s.data?.files[0]){let e=s.data.files.find(e=>e.status!==`deleted`)??s.data.files[0];l(e.path),t||d(`diff`)}},[s.data]),(0,m.useEffect)(()=>{k&&k.path!==c&&l(k.path)},[k?.path]),(0,m.useEffect)(()=>{o&&j({kind:`close`})},[o]);function ee(e){if(T(void 0),C(!1),e.kind===`close`){i();return}y(void 0),l(e.path)}function j(e){(e.kind!==`open`||e.path!==c)&&(A?T(e):ee(e))}async function M(e=!1){if(k&&v!==void 0&&!b){x(!0);try{let t=await L(`code.save`,{path:k.path,contents:v,mtimeMs:k.mtimeMs,...e?{force:!0}:{}});return p(e=>e&&{...e,file:{...e.file,contents:v,mtimeMs:t.mtimeMs,size:v.length}}),y(void 0),C(!1),s.reload(),w&&ee(w),!0}catch(e){return e instanceof xe&&e.code===`conflict`?C(!0):H.error(e instanceof Error?e.message:`The file could not be saved.`),!1}finally{x(!1)}}}function te(e){(e.ctrlKey||e.metaKey)&&!e.altKey&&e.key.toLowerCase()===`s`?(e.preventDefault(),e.stopPropagation(),M()):r&&mK(e.nativeEvent,r)&&(e.preventDefault(),j({kind:`close`}))}let ne=k?.change,N=!!ne||k?.original!==void 0,re=N?u:`code`,{dir:ie,name:ae}=AY(k?.path??c??``),oe=!!(k?.exists&&k.contents!==void 0),se=ne?kY[ne.status]:void 0;return(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1`,onKeyDown:te,children:[(0,V.jsx)(NY,{changes:s.data,loading:s.loading,error:s.error,current:k?.path??c,onPick:e=>j({kind:`open`,path:e}),onRefresh:()=>{s.reload(),A||_()}}),(0,V.jsxs)(`section`,{"aria-label":`File`,className:`flex min-w-0 flex-1 flex-col`,children:[(0,V.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border pr-2 pl-3`,children:[c?(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[se?(0,V.jsx)(`span`,{title:se.word,className:Y(`font-mono text-xs font-semibold`,se.tone),children:se.letter}):(0,V.jsx)(jp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,V.jsxs)(`h2`,{className:`min-w-0 truncate text-[0.8125rem]`,title:k?.path??c,children:[ie?(0,V.jsxs)(`span`,{className:`text-muted-foreground`,children:[ie,`/`]}):null,(0,V.jsx)(`span`,{className:`font-medium text-foreground`,children:ae}),A?(0,V.jsx)(`span`,{"aria-label":`unsaved`,title:`Unsaved edits`,className:`ml-1.5 inline-block size-1.5 -translate-y-0.5 rounded-full bg-foreground/70`}):null]}),ne?(0,V.jsx)(jY,{change:ne}):null]}):(0,V.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-muted-foreground`,children:`Code`}),N?(0,V.jsx)(ME,{label:`View`,value:re,onChange:d,items:[{id:`code`,label:`Code`},{id:`diff`,label:`Diff`}]}):null,re===`diff`?(0,V.jsx)(DY,{label:D===`split`?`Unified diff`:`Side by side`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Side by side`,"aria-pressed":D===`split`,onClick:()=>PL(D===`split`?`unified`:`split`),className:EY,children:D===`split`?(0,V.jsx)(Ym,{"aria-hidden":`true`,className:`size-4`}):(0,V.jsx)(xp,{"aria-hidden":`true`,className:`size-4`})})}):null,(0,V.jsx)(DY,{label:E?`Do not wrap lines`:`Wrap long lines`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Wrap lines`,"aria-pressed":E,onClick:()=>NL(!E),className:EY,children:(0,V.jsx)(_h,{"aria-hidden":`true`,className:`size-4`})})}),(0,V.jsx)(DY,{label:`Save`,hint:`Ctrl+S`,children:(0,V.jsxs)(WT,{size:`sm`,variant:A?`default`:`outline`,disabled:!A||b,onClick:()=>void M(),"aria-keyshortcuts":`Control+S Meta+S`,children:[(0,V.jsx)(Zm,{"aria-hidden":`true`}),b?`Saving…`:`Save`]})}),(0,V.jsx)(DY,{label:`Close`,hint:r,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Close code viewer`,onClick:()=>j({kind:`close`}),className:EY,children:(0,V.jsx)(Fh,{"aria-hidden":`true`,className:`size-4`})})})]}),w?(0,V.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-muted/40 px-3 py-2 text-xs`,children:[(0,V.jsx)(Dm,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[ae,` has unsaved edits.`]}),(0,V.jsx)(WT,{size:`xs`,variant:`ghost`,onClick:()=>T(void 0),children:`Keep editing`}),(0,V.jsx)(WT,{size:`xs`,variant:`outline`,onClick:()=>ee(w),children:`Discard`}),(0,V.jsx)(WT,{size:`xs`,onClick:()=>void M(),disabled:b,children:`Save`})]}):null,S?(0,V.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-muted/40 px-3 py-2 text-xs`,children:[(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[ae,` changed on disk since you opened it, maybe by an agent.`]}),(0,V.jsx)(WT,{size:`xs`,variant:`outline`,onClick:()=>{y(void 0),C(!1),_()},children:`Load theirs`}),(0,V.jsx)(WT,{size:`xs`,onClick:()=>void M(!0),disabled:b,children:`Overwrite with mine`})]}):null,(0,V.jsx)(`div`,{className:`code-pane relative flex min-h-0 flex-1 flex-col`,children:h?(0,V.jsx)(`p`,{role:`alert`,className:`m-auto max-w-sm px-6 text-center text-sm text-muted-foreground`,children:h}):c?k?k.binary||k.tooLarge?(0,V.jsx)(`p`,{className:`m-auto max-w-sm px-6 text-center text-sm text-muted-foreground`,children:k.binary?`This is a binary file, so it is not shown.`:`This file is too large to show here.`}):!k.exists&&re===`code`?(0,V.jsxs)(`p`,{className:`m-auto flex max-w-sm flex-col items-center gap-2 px-6 text-center text-sm text-muted-foreground`,children:[(0,V.jsx)(zp,{"aria-hidden":`true`,className:`size-5`}),`This file was deleted. Switch to Diff to see what it held.`]}):(0,V.jsx)(m.Suspense,{fallback:(0,V.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:`Loading code…`}),children:(0,V.jsx)(TY,{path:k.path,version:`${f.version}`,contents:k.contents??``,draft:v,original:k.original,mode:re,layout:D,wrap:E,dark:O,readOnly:!oe,onDraft:y})}):(0,V.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:g?`Opening…`:``}):(0,V.jsx)(IY,{loading:s.loading})})]})]})}function IY({loading:e}){return(0,V.jsxs)(`div`,{className:`m-auto flex max-w-xs flex-col items-center gap-2 px-6 text-center`,children:[(0,V.jsx)(Np,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e?`Reading the changes…`:`Pick a changed file, open one by its path, or click a file name in the Lobby chat.`})]})}function LY({codeKey:e}){let{open:t,path:n,mode:r,request:i}=OL(),a=lE(t,cE.help),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(0),u=()=>l(e=>e+1);return(0,V.jsx)(tE,{open:a,onOpenChange:e=>{e||(o?u():EL())},label:`Code viewer`,className:`code-pop h-[min(86svh,52rem)] max-h-none max-w-6xl`,onEscapeKeyDown:e=>{o&&(e.preventDefault(),u())},children:t?(0,V.jsx)(FY,{requested:n,requestedMode:r,request:i,codeKey:e,onClose:EL,onDirtyChange:s,closeAsked:c}):null})}function RY(e){let t=e.match(/[#&?]?token=([^&\s#]+)/i);if(t?.[1])return decodeURIComponent(t[1]);let n=e.trim();return n&&!n.includes(`/`)&&!n.includes(` `)?n:void 0}function zY(){let[e,t]=(0,m.useState)(``),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1);async function o(e){a(!0),r(void 0),e&&(window.location.hash=`token=${encodeURIComponent(e)}`),await we()?window.location.reload():(r(e?`That link did not sign in. Copy the link from Pi and try again.`:`Paste the link from Pi below.`),a(!1))}function s(t){t.preventDefault(),o(RY(e))}return(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-y-auto p-6`,children:(0,V.jsxs)(`form`,{onSubmit:s,className:`cs-dlg w-full max-w-[420px]`,children:[(0,V.jsxs)(`div`,{className:`cs-dh flex items-center gap-3.5 pt-[22px]`,children:[(0,V.jsx)(`span`,{className:`cs-drop`,"aria-hidden":`true`,children:(0,V.jsx)(Zp,{className:`size-[18px]`})}),(0,V.jsx)(`h1`,{children:`Sign in to bot-lobby`})]}),(0,V.jsxs)(`div`,{className:`cs-db`,children:[(0,V.jsxs)(`p`,{className:`mb-3.5 text-[12.5px] leading-relaxed text-muted-foreground`,children:[`Pi printed a link when it started (or run `,(0,V.jsx)(`code`,{className:`cs-cd`,children:`/bot-lobby web`}),` to see it again). Paste it here.`]}),(0,V.jsxs)(`label`,{children:[(0,V.jsx)(`span`,{children:`Lobby link or token`}),(0,V.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),autoComplete:`off`,spellCheck:!1,autoFocus:!0,placeholder:`http://127.0.0.1:7347/#token=…`,className:`cs-inp`})]}),n?(0,V.jsx)(`p`,{role:`alert`,className:`mt-2.5 text-[12.5px] text-[var(--bad)]`,children:n}):null]}),(0,V.jsxs)(`div`,{className:`cs-df`,children:[(0,V.jsx)(WT,{type:`button`,variant:`outline`,disabled:i,onClick:()=>void o(void 0),children:`Retry`}),(0,V.jsx)(WT,{type:`submit`,disabled:i||!e.trim(),children:`Sign in`})]})]})})}function BY({oracleBusy:e,runs:t,activity:n,background:r}){let i=new Set;e&&i.add(`Oracle`);for(let e of t)e.status===`running`&&i.add(zR(UR(e)));for(let e of n)e.pending&&e.source!==`LOBBY`&&i.add(e.source===`MASTER`?`Oracle`:zR(e.source));let a=r.filter(e=>e.alive&&e.busy).length;return a&&i.add(a===1?`1 in the background`:`${a} in the background`),[...i]}function VY(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}var HY=6,UY=`bot-lobby.orb`,WY=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=1;function GY(e,t,n,r){let i=e=>e+HY,a=(e,t)=>Math.max(e+HY,e+t-r-HY);return{x:Math.min(a(n.left,n.width),Math.max(i(n.left),e)),y:Math.min(a(n.top,n.height),Math.max(i(n.top),t))}}function KY(e,t,n,r){let i=e=>Math.max(1,e-r),a=GY(e,t,n,r);return{fx:Math.min(1,Math.max(0,(a.x-n.left)/i(n.width))),fy:Math.min(1,Math.max(0,(a.y-n.top)/i(n.height)))}}function qY(e,t,n){return GY(t.left+e.fx*Math.max(0,t.width-n),t.top+e.fy*Math.max(0,t.height-n),t,n)}function JY(e){if(e)try{let t=JSON.parse(e);return WY(t.fx)&&WY(t.fy)?{fx:t.fx,fy:t.fy}:void 0}catch{return}}function YY(){try{return JY(localStorage.getItem(UY))}catch{return}}function XY(e){try{localStorage.setItem(UY,JSON.stringify(e))}catch{}}var ZY=5,QY=16;function $Y(e){return{left:e.left,top:e.top,width:e.width,height:e.height}}function eX(){let e=document.getElementById(`main`)?.getBoundingClientRect();return e?$Y(e):void 0}function tX(e,t){return!e||!t?e===t:e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function nX(){let[e,t]=(0,m.useState)(()=>eX());return(0,m.useEffect)(()=>{let e=()=>{let e=eX();t(t=>tX(t,e)?t:e)},n=document.getElementById(`main`),r=document.getElementById(`app-dock`),i=typeof ResizeObserver>`u`?void 0:new ResizeObserver(e);n&&i?.observe(n),r&&i?.observe(r);let a=window.visualViewport;return window.addEventListener(`resize`,e),window.addEventListener(`orientationchange`,e),a?.addEventListener(`resize`,e),a?.addEventListener(`scroll`,e),e(),()=>{i?.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`orientationchange`,e),a?.removeEventListener(`resize`,e),a?.removeEventListener(`scroll`,e)}},[]),e}var rX=(0,m.forwardRef)(function({spotlight:e,thinking:t,busy:n=[],tone:r,expanded:i,hidden:a,shortcut:o,onOpen:s},c){let l=nX(),[u,d]=(0,m.useState)(YY),[f,p]=(0,m.useState)(),[h,g]=(0,m.useState)(!1),_=(0,m.useRef)(void 0),v=(0,m.useRef)(!1),y=(0,m.useRef)(44),b=f??(u&&l?qY(u,l,y.current):void 0),x=(0,m.useCallback)((e,t)=>{let n=eX();if(!n)return;let r=KY(e,t,n,y.current);d(r),XY(r)},[]);(0,m.useEffect)(()=>{l&&p(e=>e&&GY(e.x,e.y,l,y.current))},[l]);function S(e){if(e.button!==0)return;let t=e.currentTarget.getBoundingClientRect();y.current=t.width,_.current={id:e.pointerId,sx:e.clientX,sy:e.clientY,ox:t.left,oy:t.top,moved:!1},e.currentTarget.setPointerCapture?.(e.pointerId)}function C(e){let t=_.current;if(!t||t.id!==e.pointerId)return;let n=e.clientX-t.sx,r=e.clientY-t.sy;if(!t.moved&&Math.hypot(n,r)<ZY)return;t.moved=!0;let i=eX();i&&p(GY(t.ox+n,t.oy+r,i,y.current))}function w(e){let t=_.current;_.current=void 0,t?.moved&&(v.current=!0,x(t.ox+e.clientX-t.sx,t.oy+e.clientY-t.sy),p(void 0))}function T(e){let t=e.shiftKey?64:QY,n={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];if(!n||e.altKey||e.ctrlKey||e.metaKey)return;e.preventDefault();let r=e.currentTarget.getBoundingClientRect();y.current=r.width,x(r.left+n[0],r.top+n[1])}let E=!e&&n.length>0,D=e?zR(e):E?VY(n):void 0,O=n.length===1&&!n[0].includes(`background`)?n[0]:void 0,k=e??(E?O:void 0),A=e?`${t.map(zR).join(`, `)} thinking. `:E?`${n.join(`, `)} at work. `:``,ee=b&&l?b.x-l.left<140:!1,j={"--orb":r,...b?{left:b.x,top:b.y,right:`auto`,bottom:`auto`}:{}};return(0,V.jsxs)(zI,{open:h&&!f,onOpenChange:g,children:[(0,V.jsx)(BI,{asChild:!0,children:(0,V.jsxs)(`button`,{ref:c,type:`button`,"aria-label":`Open Thinking`,"aria-description":`${A}Drag, or use the arrow keys, to move it.`,"aria-haspopup":`dialog`,"aria-expanded":i,"aria-keyshortcuts":o?`${o} Enter Space`:`Enter Space`,onClick:e=>{if(v.current){v.current=!1,e.preventDefault();return}s()},onPointerDown:S,onPointerMove:C,onPointerUp:w,onPointerCancel:()=>{_.current=void 0,p(void 0)},onKeyDown:T,style:j,"data-thinking":e?``:void 0,"data-busy":E?``:void 0,"data-dragging":f?``:void 0,"data-placed":b?``:void 0,"data-flip":ee||void 0,className:Y(`thinking-bubble fixed z-20 touch-none rounded-full outline-none select-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,a&&`invisible`),children:[(0,V.jsx)(eu,{initial:!1,children:D?(0,V.jsx)(Yd.span,{className:`orb-label`,initial:{opacity:0,x:ee?-8:8,scale:.9},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:ee?-8:8,scale:.9},transition:{type:`spring`,visualDuration:.3,bounce:.35},children:(0,V.jsx)(eu,{mode:`popLayout`,initial:!1,children:(0,V.jsx)(Yd.span,{className:`inline-flex items-center gap-1`,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{type:`spring`,visualDuration:.28,bounce:.3},children:D},D)})},`label`):null}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`orb orb-float`,children:(0,V.jsx)(`span`,{className:`orb-icon`,children:(0,V.jsx)(IR,{source:k,strokeWidth:2.25,className:`size-3.5`})})})]})}),(0,V.jsxs)(VI,{side:`top`,children:[`Thinking `,o?(0,V.jsx)(QT,{chord:o}):null,(0,V.jsx)(`span`,{className:`text-background/70`,children:` · drag to move`})]})]})}),iX=/^\s*(?:#{1,6}\s+(.+?)\s*#*|\*\*([^*\n]{2,90}?):?\*\*:?|__([^_\n]{2,90}?):?__:?)\s*$/,aX=260,oX=200,sX=/^\s*(?:[-*+]\s|\d+[.)]\s|>|```|~~~|\|)/m;function cX(e){let t=[],n=[],r=!1;for(let i of e){if(/^\s*(```|~~~)/.test(i)&&(r=!r),!r&&!i.trim()){n.length&&t.push(n.join(`
|
|
102
|
+
`,t),i=e.slice(n,r<0?e.length:r),a=BK.exec(i);if(!a||t-n<a[0].length)return;let[o,s=``,c,l,u=`.`,d]=a;if(i.slice(o.length).trim()===``)return{value:e.slice(0,n)+e.slice(r<0?e.length:r),start:n,end:n};let f=`\n${s}${c??`${Number(l)+1}${u}`} ${d?`[ ] `:``}`;return{value:e.slice(0,t)+f+e.slice(t),start:t+f.length,end:t+f.length}}function HK(){try{return{id:pe()}}catch(e){return{error:e.message}}}function UK(e,t){if(e){if(t&&!e.projects.some(e=>e.id===t))return`Selected project is unknown or offline. Refresh or choose a running project.`;if(!e.projects.length)return`No authorized running projects found. Open a folder from the Project menu, or refresh.`}}function WK(){let[e,t]=(0,m.useState)(),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(0);async function s(){let e=++o.current;a(!0),r(void 0);try{let n=await L(`projects.list`,{});ve(n.projects),e===o.current&&t(n)}catch(t){e===o.current&&r(t.message)}finally{e===o.current&&a(!1)}}(0,m.useEffect)(()=>(s(),()=>{o.current++}),[]);let[c,l]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{if(!i)return l(!1);let e=setTimeout(()=>l(!0),300);return()=>clearTimeout(e)},[i]),{data:e,error:n,busy:i,slow:c,refresh:s}}function GK({data:e,error:t}){let n=HK();return n.error??t??UK(e,n.id)}function KK({projects:e}){let t=GK(e);return t?(0,V.jsxs)(`p`,{role:`alert`,className:`notice flex min-w-0 items-start gap-2 pt-1 pb-0.5 text-xs break-words text-destructive`,children:[(0,V.jsx)(xh,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,V.jsx)(`span`,{children:t})]}):null}function qK(e){let t=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0,n=e.key===`Home`?`first`:e.key===`End`?`last`:void 0;if(!t&&!n)return;let r=[...e.currentTarget.querySelectorAll(`[role='option'], [data-walk]`)];if(r.length===0)return;e.preventDefault();let i=r.indexOf(document.activeElement);r[n===`first`?0:n===`last`?r.length-1:Math.max(0,Math.min(r.length-1,(i<0?t>0?-1:r.length:i)+t))]?.focus()}var JK=`bot-lobby:open-projects`,YK=4;function XK(e){return{w:400,h:49+Math.max(1,Math.min(e.data?.projects.length??1,YK))*52+1+40+(GK(e)?36:0)}}function ZK({projects:e,name:t,branch:n,open:r,onToggle:i}){let a=GK(e);return(0,V.jsxs)(`button`,{type:`button`,role:`combobox`,"aria-label":`Project`,"aria-description":`${t}${n?`, branch ${n}`:``}`,"aria-haspopup":`listbox`,"aria-expanded":r,"aria-keyshortcuts":`P ArrowDown`,"aria-busy":e.busy,"data-tip":`Switch project`,"data-on":r||void 0,onClick:i,onKeyDown:e=>{e.key!==`ArrowDown`||e.altKey||e.metaKey||e.ctrlKey||r||(e.preventDefault(),i())},title:n?`${t} · ${n}`:t,className:`bubble-chip bubble-tip bubble-tool min-w-0`,children:[e.slow?(0,V.jsx)(ER,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,V.jsx)(Up,{"aria-hidden":`true`,className:Y(`size-3.5 shrink-0`,a&&`text-destructive`)}),(0,V.jsx)(`span`,{className:`truncate`,children:t}),(0,V.jsx)(Zf,{"aria-hidden":`true`,className:`size-3 shrink-0`,strokeWidth:2})]})}function QK({projects:e,tab:t,onBrowse:n,onClose:r}){let{data:i,busy:a,refresh:o}=e,s=HK(),c=GK(e),l=s.error?`invalid`:s.id??i?.currentId??``,u=(0,m.useRef)(null);tD(`r`,()=>void o(),{inDialog:!0}),(0,m.useEffect)(()=>{(u.current?.querySelector(`[role='option'][aria-selected='true']`)??u.current?.querySelector(`[role='option']`))?.focus({preventScroll:!0})},[!!i]);function d(e){r(),e!==l&&I(e,t)}let f=Math.max(1,Math.min(i?.projects.length??1,YK));return(0,V.jsxs)(`div`,{ref:u,"aria-label":`Projects`,onKeyDown:qK,className:`bubble-pane flex flex-col p-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center justify-between ps-2.5`,children:[(0,V.jsx)(`span`,{className:`text-[13px] font-medium text-(--bubble-muted)`,children:`Running projects`}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>void o(),disabled:a,"aria-label":`Refresh list`,"aria-keyshortcuts":`R`,className:`bubble-chip h-7 text-xs`,children:[a?(0,V.jsx)(ER,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):(0,V.jsx)(zm,{"aria-hidden":`true`,className:`size-3.5`}),`Refresh`,(0,V.jsx)(`kbd`,{className:`bubble-kbd`,children:`R`})]})]}),(0,V.jsx)(`div`,{className:`h-px shrink-0`}),(0,V.jsx)(`div`,{role:`listbox`,"aria-label":`Projects`,className:`bubble-scroll flex shrink-0 flex-col overflow-y-auto`,style:{height:f*52},children:i?i.projects.map((e,t)=>{let n=e.id===l;return(0,V.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,onClick:()=>d(e.id),className:Y(`bubble-row h-[52px] shrink-0`,n&&`bubble-prow`),style:{"--delay":`${40+t*12}ms`},children:[(0,V.jsx)(`span`,{className:`flex w-4 shrink-0 justify-center`,children:n?(0,V.jsx)(Yf,{"aria-hidden":`true`,className:`size-4 text-(--bubble-accent)`,strokeWidth:2}):null}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,V.jsx)(`span`,{className:`truncate text-sm font-medium text-(--bubble-ink)`,children:e.name}),(0,V.jsxs)(`span`,{className:`truncate text-xs text-(--bubble-muted)`,children:[e.cwd,` · :`,e.port]})]})]},e.id)}):(0,V.jsxs)(`div`,{className:`flex h-[52px] items-center gap-2.5 px-2.5 text-[13px] text-(--bubble-muted)`,children:[(0,V.jsx)(ER,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}),`Loading projects…`]})}),c?(0,V.jsxs)(`p`,{role:`alert`,className:`flex h-9 shrink-0 items-center gap-2 px-2.5 text-xs text-destructive`,children:[(0,V.jsx)(xh,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,V.jsx)(`span`,{className:`truncate`,title:c,children:c})]}):null,(0,V.jsx)(`div`,{className:`h-px shrink-0`}),(0,V.jsxs)(`button`,{type:`button`,"data-walk":!0,onClick:n,className:`bubble-row h-10 shrink-0`,style:{"--delay":`0ms`},children:[(0,V.jsx)(Vp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Open folder…`})]})]})}var $K={w:540,h:324};function eq(e){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)();async function a(r){if(!t){n(!0),i(void 0);try{let{project:t}=await L(`projects.open`,{path:r});ve([t]),I(t.id,e)}catch(e){i(e.message)}finally{n(!1)}}}return{opening:t,error:r,open:a}}function tq(e){let t=e.includes(`\\`)&&!e.includes(`/`)?`\\`:`/`,n=e.split(t),r=[];return n.forEach((e,i)=>{if(!e)return;let a=n.slice(0,i+1).join(t);r.push({name:e,path:a||t})}),r.length?r:[{name:t,path:t}]}function nq(e,t,n){let r=[...e.currentTarget.querySelectorAll(`button[data-folder]:not(:disabled)`)],i=r.indexOf(document.activeElement),a={ArrowDown:Math.min(r.length-1,i+1),ArrowUp:Math.max(0,i-1),Home:0,End:r.length-1}[e.key];a!==void 0&&r.length>0?(e.preventDefault(),r[a]?.focus()):e.key===`Backspace`&&t&&(e.preventDefault(),n(t))}function rq({tab:e,onClose:t}){let[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)({step:0,dir:`fwd`}),o=_R(`projects.browse`,n===void 0?{}:{path:n},[]),s=eq(e),c=(0,m.useRef)(null),l=o.loading||s.opening,u=o.data?.path??n??``,d=(e,t)=>{e!==u&&(a(e=>({step:e.step+1,dir:t})),r(e))};(0,m.useEffect)(()=>{if(!o.data)return;let e=c.current?.querySelector(`button[data-folder]`);e&&!c.current?.contains(document.activeElement)&&e.focus({preventScroll:!0})},[o.data]);let f=tq(u),p=f.slice(-4),h=o.data?.folders.length??0,g=o.error||s.error?o.error??s.error:o.loading&&!o.data?`Loading…`:h===0?`No subfolders`:`${h.toLocaleString()} ${h===1?`folder`:`folders`}${o.data?.truncated?` (first 2,000)`:``}`;return(0,V.jsxs)(`div`,{role:`group`,"aria-label":`Open project folder`,className:`bubble-pane flex flex-col gap-1.5 p-2`,style:{height:$K.h},children:[(0,V.jsxs)(`div`,{className:`bubble-wellbar flex h-10 shrink-0 items-center gap-0.5 rounded-2xl px-1`,children:[(0,V.jsx)(`button`,{type:`button`,"aria-label":`Parent folder`,title:`Parent folder (Backspace)`,disabled:l||!o.data?.parent,onClick:()=>o.data?.parent&&d(o.data.parent,`back`),className:`bubble-iconbtn size-8 rounded-xl`,children:(0,V.jsx)(Rf,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.8})}),(0,V.jsxs)(`nav`,{"aria-label":`Folder path`,className:`flex min-w-0 flex-1 items-center overflow-hidden whitespace-nowrap`,title:u,children:[f.length>p.length?(0,V.jsx)(`span`,{className:`shrink-0 px-1.5 text-[13px] text-(--bubble-muted)`,children:`…`}):null,p.map((e,t)=>(0,V.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[t>0?(0,V.jsx)(tp,{"aria-hidden":`true`,className:`size-3 shrink-0 text-(--bubble-faint)`,strokeWidth:2}):null,(0,V.jsx)(`button`,{type:`button`,className:`bubble-crumb`,"data-last":t===p.length-1||void 0,"aria-current":t===p.length-1?`location`:void 0,disabled:l,onClick:()=>d(e.path,`back`),children:e.name})]},e.path))]})]}),(0,V.jsxs)(`div`,{ref:c,role:`group`,"aria-label":`Folders`,"aria-busy":o.loading,"data-dir":i.step?i.dir:void 0,onKeyDown:e=>nq(e,o.data?.parent,e=>d(e,`back`)),className:`bubble-flist bubble-scroll`,children:[o.data?.folders.map(e=>{let t=e.name.startsWith(`.`);return(0,V.jsxs)(`button`,{type:`button`,"data-folder":!0,disabled:s.opening,onClick:()=>d(e.path,`fwd`),title:e.path,className:Y(`bubble-frow`,t&&`text-(--bubble-muted)`),children:[(0,V.jsx)(`span`,{className:`bubble-ftile`,children:(0,V.jsx)(Up,{"aria-hidden":`true`,className:`size-3.5 text-(--bubble-muted)`,strokeWidth:1.8})}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,V.jsx)(tp,{"aria-hidden":`true`,className:`bubble-go size-3.5 shrink-0`,strokeWidth:2})]},e.path)}),o.data&&h===0?(0,V.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-xs text-(--bubble-muted)`,children:[(0,V.jsx)(Up,{"aria-hidden":`true`,className:`size-6`,strokeWidth:1.5}),(0,V.jsx)(`span`,{children:`No subfolders here. You can open this folder.`})]}):null]},i.step),(0,V.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between gap-2 ps-2.5`,children:[(0,V.jsx)(`span`,{role:o.error||s.error?`alert`:`status`,className:Y(`min-w-0 truncate text-xs`,o.error||s.error?`text-destructive`:`text-(--bubble-muted)`),children:g}),(0,V.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[o.error?(0,V.jsx)(`button`,{type:`button`,className:`bubble-btn bubble-ghostbtn`,onClick:o.reload,disabled:o.loading,children:`Retry`}):null,(0,V.jsx)(`button`,{type:`button`,className:`bubble-btn bubble-ghostbtn`,onClick:t,disabled:s.opening,children:`Cancel`}),(0,V.jsx)(`button`,{type:`button`,className:`bubble-btn bubble-key`,disabled:!o.data||o.loading||!!o.error||s.opening,onClick:()=>void s.open(o.data.path),children:s.opening?`Opening project…`:`Open this folder`})]})]})]})}function iq(){return(0,V.jsx)(`svg`,{width:`0`,height:`0`,className:`absolute`,"aria-hidden":`true`,focusable:`false`,children:(0,V.jsxs)(`defs`,{children:[(0,V.jsxs)(`filter`,{id:`bubble-goolit`,x:`-10%`,y:`-10%`,width:`120%`,height:`120%`,colorInterpolationFilters:`sRGB`,children:[(0,V.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`9`,result:`b`}),(0,V.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`0.9`,dy:`1.3`,result:`dn`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`rimA`}),(0,V.jsx)(`feGaussianBlur`,{in:`rimA`,stdDeviation:`0.4`,result:`rimB`}),(0,V.jsx)(`feComposite`,{in:`rimB`,in2:`shape`,operator:`in`,result:`rimC`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-hl)`},result:`hlc`}),(0,V.jsx)(`feComposite`,{in:`hlc`,in2:`rimC`,operator:`in`,result:`hl`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`-0.9`,dy:`-1.3`,result:`up`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`shA`}),(0,V.jsx)(`feGaussianBlur`,{in:`shA`,stdDeviation:`0.4`,result:`shB`}),(0,V.jsx)(`feComposite`,{in:`shB`,in2:`shape`,operator:`in`,result:`shC`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-sh)`},result:`shc`}),(0,V.jsx)(`feComposite`,{in:`shc`,in2:`shC`,operator:`in`,result:`sh`}),(0,V.jsxs)(`feMerge`,{children:[(0,V.jsx)(`feMergeNode`,{in:`shape`}),(0,V.jsx)(`feMergeNode`,{in:`sh`}),(0,V.jsx)(`feMergeNode`,{in:`hl`})]})]}),(0,V.jsxs)(`filter`,{id:`bubble-gooedge`,x:`-10%`,y:`-10%`,width:`120%`,height:`120%`,colorInterpolationFilters:`sRGB`,children:[(0,V.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`9`,result:`b`}),(0,V.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`2`,dy:`3`,result:`dn`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`tS0`}),(0,V.jsx)(`feGaussianBlur`,{in:`tS0`,stdDeviation:`0.8`,result:`tS1`}),(0,V.jsx)(`feComposite`,{in:`tS1`,in2:`shape`,operator:`in`,result:`tS`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-ehl)`},result:`tc`}),(0,V.jsx)(`feComposite`,{in:`tc`,in2:`tS`,operator:`in`,result:`eh`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`-2`,dy:`-3`,result:`up`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`bS0`}),(0,V.jsx)(`feGaussianBlur`,{in:`bS0`,stdDeviation:`0.8`,result:`bS1`}),(0,V.jsx)(`feComposite`,{in:`bS1`,in2:`shape`,operator:`in`,result:`bS`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-esh)`},result:`bc`}),(0,V.jsx)(`feComposite`,{in:`bc`,in2:`bS`,operator:`in`,result:`es`}),(0,V.jsxs)(`feMerge`,{children:[(0,V.jsx)(`feMergeNode`,{in:`shape`}),(0,V.jsx)(`feMergeNode`,{in:`eh`}),(0,V.jsx)(`feMergeNode`,{in:`es`})]})]})]})})}function aq({kind:e}){return(0,V.jsxs)(`div`,{className:Y(`bubble-layer`,e===`edge`?`bubble-edge`:`bubble-fill`),"aria-hidden":`true`,children:[(0,V.jsx)(`div`,{className:`bubble-menu`,children:(0,V.jsx)(`div`,{className:`bubble-menu-clip`})}),(0,V.jsx)(`div`,{className:`bubble-ghost`})]})}function oq({open:e,size:t,shrunk:n,morphing:r,menu:i,children:a,className:o,style:s,...c}){let[l,u]=(0,m.useState)(e);return(0,m.useEffect)(()=>{if(e)return u(!0);let t=setTimeout(()=>u(!1),140);return()=>clearTimeout(t)},[e]),(0,V.jsxs)(`div`,{"data-slot":`composer-shell`,"data-open":e||void 0,"data-shrunk":n||void 0,"data-morphing":r||void 0,className:Y(`bubble`,o),style:{...s,"--w":`${t.w}px`,"--h":`${e?t.h:0}px`},...c,children:[(0,V.jsx)(iq,{}),(0,V.jsx)(aq,{kind:`edge`}),(0,V.jsx)(aq,{kind:`fill`}),(0,V.jsxs)(`div`,{className:`bubble-real`,children:[(0,V.jsx)(`div`,{className:`bubble-menu`,inert:!e,children:(0,V.jsx)(`div`,{className:`bubble-menu-clip`,children:(0,V.jsx)(`div`,{className:`bubble-menu-body`,children:e||l?i:null})})}),a]})]})}var sq=e=>e.preventDefault();function cq({onStop:e}){let[t,n]=(0,m.useState)(!1),r=lE(t,cE.confirm),i=()=>{n(!1),e()};return tD(`y`,i,{enabled:t&&r,inDialog:!0}),(0,V.jsxs)(nR,{open:t&&r,onOpenChange:n,children:[(0,V.jsx)(`button`,{type:`button`,className:`bubble-send bubble-key bubble-stop bubble-tip`,"data-tip":`Interrupt`,onPointerDown:sq,onClick:()=>n(!0),"aria-label":`Stop`,"aria-haspopup":`dialog`,children:(0,V.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,V.jsx)(`rect`,{x:`2`,y:`2`,width:`8`,height:`8`,rx:`1.5`})})}),(0,V.jsxs)(rR,{children:[(0,V.jsxs)(iR,{children:[(0,V.jsx)(oR,{children:`Stop the oracle?`}),(0,V.jsx)(sR,{children:`The current response stops. Work already recorded is kept.`})]}),(0,V.jsxs)(aR,{children:[(0,V.jsxs)(lR,{children:[`Keep it`,(0,V.jsx)(QT,{chord:`Esc`,className:`kbd-hint ml-1`})]}),(0,V.jsxs)(cR,{variant:`destructive`,onClick:i,children:[`Stop`,(0,V.jsx)(QT,{chord:`Y`,className:`kbd-hint ml-1`})]})]})]})]})}function lq({sending:e,disabled:t,steering:n,onSend:r}){return(0,V.jsx)(`button`,{type:`button`,className:Y(`bubble-send bubble-tip`,!t&&`bubble-key`),"data-tip":n?`Steer`:`Send`,onPointerDown:sq,onClick:r,disabled:t,"aria-label":`Send`,"aria-keyshortcuts":`Enter`,children:e?(0,V.jsx)(ER,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,V.jsxs)(`svg`,{className:`bubble-plane`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M22 2L11 13`}),(0,V.jsx)(`path`,{d:`M22 2l-7 20-4-9-9-4z`})]})})}function uq(e){return e.agent?NR(e.agent):e.tag===`lobby`?`var(--c-orc)`:e.tag===`skill`?`var(--c-pl)`:`var(--c-qa)`}function dq(e,t){let n=/^\s*([/@])([a-z0-9:_.-]*)$/i.exec(e.slice(0,t));if(n&&!/\S/.test(e.slice(t,t+1)))return{kind:n[1]===`/`?`slash-command`:`mention`,query:n[2].toLowerCase()}}function fq(e){return[...hE.map(e=>({id:`/${e.name}`,insert:`/${e.name}`,label:`/${e.name}`,description:e.hint,tag:`lobby`})),...e.map(e=>({id:`/${e.name}`,insert:`/${e.name}`,label:`/${e.name}`,description:e.description+(e.terminal?` · continue in Pi terminal`:``),tag:e.name.startsWith(`skill:`)?`skill`:`pi`}))]}function pq(e,t=[]){let n=e.kind===`slash-command`?fq(t):mE.map(e=>({id:`@${e.name}`,insert:`@${e.name}`,label:`@${e.name}`,description:e.hint,agent:e.agent,tag:`agent`})),r=n.filter((e,t)=>n.findIndex(t=>t.id===e.id)===t),i=r.filter(t=>t.label.slice(1).startsWith(e.query)),a=r.filter(t=>!i.includes(t)&&t.label.slice(1).includes(e.query));return[...i,...a]}function mq(e,t){return`${e}-${encodeURIComponent(t)}`}var hq={"slash-command":`Commands`,mention:`Agents`};function gq(e){return 12+Math.min(e,8)*36}var _q;function vq(e,t){let n=0;try{if(_q??=document.createElement(`canvas`).getContext(`2d`),!_q)throw Error(`no canvas`);for(let r of e){_q.font=`500 14px ${t}`;let e=_q.measureText(r.label.slice(1)).width;_q.font=`400 13px ${t}`,n=Math.max(n,e+_q.measureText(r.description).width)}}catch{for(let t of e)n=Math.max(n,t.label.length*8+t.description.length*6.6)}return Math.min(Math.max(Math.ceil(n)+150,200),640)}var yq=(0,m.memo)(function(e){let t=(0,m.useRef)(null);(0,m.useLayoutEffect)(()=>{e.activeItemId&&t.current&&t.current.querySelector(`[data-composer-item-id="${CSS.escape(e.activeItemId)}"]`)?.scrollIntoView({block:`nearest`})},[e.activeItemId]);let n=Math.min(e.items.length,8);return(0,V.jsx)(`div`,{ref:t,id:e.listId,role:`listbox`,"aria-label":hq[e.triggerKind],"data-composer-command-drawer":`true`,className:`bubble-pane bubble-scroll overflow-y-auto p-1.5`,style:{height:gq(e.items.length)},children:e.items.map((t,r)=>{let i=e.activeItemId===t.id;return(0,V.jsxs)(`div`,{id:mq(e.listId,t.id),role:`option`,"aria-selected":i,"data-composer-item-id":t.id,"data-active":i||void 0,onMouseMove:()=>{i||e.onHighlightedItemChange(t.id)},onMouseDown:e=>e.preventDefault(),onClick:()=>e.onSelect(t),className:`bubble-row`,style:{"--delay":`${Math.max(0,n-1-r)*22}ms`},children:[(0,V.jsx)(`span`,{className:`bubble-glyph cs-kg`,"aria-hidden":`true`,style:{"--k":uq(t)},children:t.agent?(0,V.jsx)(IR,{source:t.agent,strokeWidth:2}):t.label.charAt(1).toUpperCase()}),(0,V.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-(--bubble-ink)`,children:t.label.slice(1)}),(0,V.jsx)(`span`,{className:`min-w-0 truncate text-[13px] text-(--bubble-muted)`,children:t.description}),(0,V.jsx)(`span`,{className:`cs-ktag`,style:{"--k":uq(t)},children:t.tag})]},t.id)})})});function bq(e){return typeof e==`object`&&e?e:{}}function xq(e){return typeof e==`string`?e.trim():``}function Sq(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Cq(e){let t=bq(e),n=xq(t.label);if(!n)return;let r=xq(t.description),i=xq(t.preview),a=xq(t.image),o=iU(t.htmlPreview);return{label:n,...r?{description:r}:{},...i?{preview:i}:{},...a?{image:a}:{},...o?{htmlPreview:o}:{}}}function wq(e){let t=bq(e),n=xq(t.question);if(!n)return;let r=(Array.isArray(t.options)?t.options:[]).map(Cq).filter(e=>!!e);return{question:n,header:xq(t.header)||`Question`,options:r,...t.multiSelect===!0?{multiSelect:!0}:{}}}function Tq(e){let t=bq(e),n=xq(t.method);if(n!==`select`&&n!==`confirm`&&n!==`input`&&n!==`editor`)return;let r=xq(t.message),i=Sq(t.options),a=xq(t.placeholder),o=xq(t.prefill);return{id:xq(t.id),method:n,title:xq(t.title)||`Answer`,...r?{message:r}:{},...i.length>0?{options:i}:{},...a?{placeholder:a}:{},...o?{prefill:o}:{}}}function Eq(e){let t=(Array.isArray(e.questions)?e.questions:[]).map(wq).filter(e=>!!e);return t.length>0?{kind:`questionnaire`,questions:t}:void 0}function Dq(e){return{kind:`choose`,title:xq(e.title)||`Choose an option`,options:Sq(e.options)}}function Oq(e){let t=xq(e.question)||xq(e.title)||`Continue?`,n=xq(e.detail)||xq(e.message);return{kind:`confirm`,question:t,...n?{detail:n}:{}}}function kq(e){let t=xq(e.question)||xq(e.title)||`Type an answer`,n=xq(e.placeholder);return{kind:`text`,question:t,...n?{placeholder:n}:{}}}function Aq(e){let t=bq(e.payload);if(e.kind===`questionnaire`)return Eq(t);if(e.kind===`choose`)return Dq(t);if(e.kind===`confirm`)return Oq(t);if(e.kind===`text`)return kq(t);let n=Tq(t.dialog);return n?{kind:`sessionDialog`,dialog:n}:void 0}var jq=`That question was already answered in the terminal.`;function Mq(e){let t=e.from.trim();return/panel|plann/i.test(t)?`PLANNER`:/oracle|master|lobby/i.test(t)||!t?`MASTER`:t.split(/\s+/)[0].toUpperCase()}function Nq(e,t){let n=Mq(e);return n===`PLANNER`&&t&&NR(t)!==`var(--muted-foreground)`?t.toUpperCase():n}function Pq(e,t){let n=Nq(e,t);if(n!==Mq(e))return n===`DEV`||n===`BACKEND`?`Dev`:n===`QA`?`QA`:n.charAt(0)+n.slice(1).toLowerCase();let r=Mq(e);if(r===`PLANNER`)return`Panel`;if(r===`MASTER`)return`Oracle`;let i=e.from.trim().split(/\s+/)[0]??`Agent`;return i.charAt(0).toUpperCase()+i.slice(1)}function Fq(e,t){let{round:n,limit:r}=e.payload??{},i=n?`From planning · round ${r?`${Math.min(n,r)}/${r}`:n}`:`From planning`,a=Mq(e)===`PLANNER`?i:e.taskId?`From task ${e.taskId}`:`From the Lobby`;return t&&t!==`Question`&&Nq(e,t)===Mq(e)?`${a} · ${t}`:a}function Iq(e,t,n){let r={prompt:e,view:t,index:0,multi:!1,placeholder:`Or type your own reply…`};if(t.kind===`questionnaire`){let e=t.questions[n];return e?{...r,index:n,question:e.question,header:e.header,multi:!!e.multiSelect,options:e.options.map(e=>({...e,value:e.label})),typed:e=>e}:void 0}if(t.kind===`choose`)return{...r,question:t.title,options:t.options.map(e=>({label:e,value:e}))};if(t.kind===`confirm`)return{...r,question:t.detail?`${t.question}\n\n${t.detail}`:t.question,options:[{label:`Yes`,value:!0},{label:`No`,value:!1}]};if(t.kind===`text`)return{...r,question:t.question,options:[],typed:e=>e,placeholder:t.placeholder||`Type your reply…`};let i=t.dialog,a=i.message?`${i.title}\n\n${i.message}`:i.title;return i.method===`select`?{...r,question:a,options:(i.options??[]).map(e=>({label:e,value:{value:e}}))}:i.method===`confirm`?{...r,question:a,options:[{label:`Yes`,value:{confirmed:!0}},{label:`No`,value:{confirmed:!1}}]}:{...r,question:a,options:[],typed:e=>({value:e}),placeholder:i.placeholder||`Type your reply…`}}function Lq(e,t){return e&&e.kind===`questionnaire`?Math.max(0,e.questions.length-t):1}function Rq(e,t,n){let[r,i]=(0,m.useState)({}),[a,o]=(0,m.useState)([]),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(0),d=(0,m.useMemo)(()=>e.map(e=>({prompt:e,view:Aq(e)})),[e]),f=d[0],p=f?.view?Iq(f.prompt,f.view,r[f.prompt.id]?.length??0):void 0,h=d.reduce((e,{prompt:t,view:n})=>e+Lq(n,r[t.id]?.length??0),0);(0,m.useEffect)(()=>{e.length===0&&(u(0),i({}))},[e.length]);let g=p?`${p.prompt.id}:${p.index}`:``;(0,m.useEffect)(()=>o([]),[g]);let _=(0,m.useCallback)(async(e,n)=>{c(!0);try{await t(e,n)}catch(e){e instanceof xe&&e.code===`question_withdrawn`?H(jq):H.error(e instanceof Error?e.message:`Could not send the answer`)}finally{c(!1)}},[t]),v=(0,m.useCallback)((e,t=`option`,n)=>{if(!p||s)return;if(u(e=>e+1),p.view.kind!==`questionnaire`)return void _(p.prompt.id,e);let a=[...r[p.prompt.id]??[],{questionIndex:p.index,question:p.question,kind:t,answer:String(e),...n?{selected:n}:{}}];if(a.length<p.view.questions.length)return i(e=>({...e,[p.prompt.id]:a}));_(p.prompt.id,{answers:a,cancelled:!1}).then(()=>i(e=>{let t={...e};return delete t[p.prompt.id],t}))},[s,r,_,p]),y=(0,m.useCallback)(e=>{let t=p?.options[e];if(t){if(p.multi)return o(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);v(t.value)}},[p,v]),b=y,x=(0,m.useCallback)(()=>{if(!p||a.length===0)return;let e=[...a].sort((e,t)=>e-t).map(e=>p.options[e].label);v(e.join(`, `),`multi`,e)},[a,p,v]),S=(0,m.useCallback)(e=>!p?.typed||!e.trim()?!1:(v(p.typed(e.trim()),`custom`),!0),[p,v]),C=(0,m.useCallback)(()=>{p&&n(p.prompt.id).catch(e=>H.error(e instanceof Error?e.message:`Could not dismiss the question`))},[n,p]);return{...p?{step:p}:{},position:l+1,total:l+h,left:h,picks:a,busy:s,choose:y,toggle:b,submitPicks:x,reply:S,dismiss:C}}function zq({option:e,large:t}){let n=fU(e.label);return e.htmlPreview?(0,V.jsx)(lU,{preview:e.htmlPreview,label:n,frameWidth:t?void 0:1200,minWidth:t?1024:void 0,className:`static-thumb h-full`}):e.image?(0,V.jsx)(`img`,{src:F(e.image),alt:t?`Mockup: ${n}`:``,loading:`lazy`}):e.preview?t?(0,V.jsx)(`div`,{className:`cs-mktext`,children:(0,V.jsx)(QL,{text:e.preview})}):(0,V.jsx)(`pre`,{className:`cs-mktext`,children:e.preview}):null}function Bq({color:e,children:t}){return(0,V.jsx)(`span`,{className:`bubble-glyph cs-kg`,"aria-hidden":`true`,style:{"--k":e},children:t})}function Vq({drawer:e,onExpand:t}){let{step:n}=e,[r,i]=(0,m.useState)(!1);if((0,m.useEffect)(()=>i(!1),[n?.prompt.id]),!n)return(0,V.jsx)(`div`,{className:`bubble-pane p-3 text-sm text-(--bubble-muted)`,children:`No questions are waiting.`});let a=Nq(n.prompt,n.header),o=NR(a),s=n.options.some(pU),c=n.options.length;return(0,V.jsxs)(`div`,{className:`bubble-pane p-1.5`,role:`group`,"aria-label":`Question`,children:[(0,V.jsxs)(`div`,{className:`cs-askh`,children:[(0,V.jsxs)(`div`,{className:`cs-asks`,children:[(0,V.jsx)(Bq,{color:o,children:(0,V.jsx)(IR,{source:a,strokeWidth:2.2,className:`size-3`})}),(0,V.jsx)(`b`,{style:{color:o},children:Pq(n.prompt,n.header)}),(0,V.jsx)(`span`,{className:`cs-askf`,children:Fq(n.prompt,n.header)}),(0,V.jsxs)(`span`,{className:`cs-askn`,children:[e.position,` of `,e.total]}),(0,V.jsx)(`button`,{type:`button`,className:`cs-askx`,"data-confirm":r||void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>r?e.dismiss():i(!0),onBlur:()=>i(!1),children:r?`Dismiss it?`:`Dismiss`})]}),(0,V.jsx)(`p`,{className:`cs-askq`,title:n.question,children:n.question})]}),s?(0,V.jsx)(`div`,{className:`cs-askm`,children:n.options.map((n,r)=>(0,V.jsxs)(`button`,{type:`button`,className:`cs-mko`,"data-on":e.picks.includes(r)||void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>e.choose(r),style:{animationDelay:`${r*30}ms`},children:[(0,V.jsxs)(`div`,{className:`cs-mk3`,children:[(0,V.jsx)(zq,{option:n}),(0,V.jsx)(`span`,{className:`cs-mxb`,role:`button`,"aria-label":`Expand ${fU(n.label)}`,onClick:e=>{e.stopPropagation(),t(r)},children:(0,V.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7`})})})]}),(0,V.jsxs)(`span`,{className:`cs-mkl`,children:[(0,V.jsx)(Bq,{color:o,children:r+1}),(0,V.jsx)(`span`,{children:fU(n.label)})]})]},n.label))}):(0,V.jsxs)(`div`,{className:`cs-askopts`,children:[n.options.map((t,r)=>(0,V.jsxs)(`button`,{type:`button`,className:`bubble-row`,"data-active":e.picks.includes(r)||void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>e.choose(r),style:{"--delay":`${(c-1-r)*22}ms`},children:[(0,V.jsx)(Bq,{color:o,children:r+1}),(0,V.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-(--bubble-ink)`,children:fU(t.label)}),t.description?(0,V.jsx)(`span`,{className:`min-w-0 truncate text-[13px] text-(--bubble-muted)`,title:t.description,children:t.description}):null,n.multi?(0,V.jsx)(`span`,{className:`cs-cb cs-sm`,"data-on":e.picks.includes(r),children:(0,V.jsx)(Yf,{"aria-hidden":`true`,strokeWidth:3})}):null]},t.label)),c===0?(0,V.jsx)(`div`,{className:`flex h-9 items-center px-2.5 text-[13px] text-(--bubble-muted)`,children:`Type your reply in the box below, then press Enter.`}):null]}),n.multi?(0,V.jsx)(`button`,{type:`button`,className:`bubble-row`,disabled:e.picks.length===0,onMouseDown:e=>e.preventDefault(),onClick:e.submitPicks,children:(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-accent)`,children:e.picks.length===0?`Pick one or more`:`Answer with ${e.picks.length} picked`})}):null]})}function Hq({drawer:e,at:t,onAt:n}){let r=e.step,i=r?.options??[],a=t>=0&&t<i.length,o=(0,m.useRef)(t);a&&(o.current=t);let s=i[o.current],c=(0,m.useRef)(null);(0,m.useEffect)(()=>{a&&c.current?.focus({preventScroll:!0})},[a]);let l=e=>n((o.current+e+i.length)%i.length),u=r?NR(Nq(r.prompt,r.header)):`var(--primary)`;return(0,V.jsxs)(`div`,{className:`cs-mxw`,"data-open":a,"aria-hidden":!a,inert:!a,children:[(0,V.jsx)(`div`,{className:`cs-shbd`,onClick:()=>n(-1)}),(0,V.jsxs)(`div`,{ref:c,role:`dialog`,"aria-modal":`true`,"aria-label":s?`Mockup: ${fU(s.label)}`:`Mockup`,tabIndex:-1,className:`cs-mxc`,onKeyDown:t=>{t.key===`Escape`?(t.preventDefault(),t.stopPropagation(),n(-1)):t.key===`ArrowRight`||t.key===`ArrowLeft`?(t.preventDefault(),l(t.key===`ArrowRight`?1:-1)):t.key===`Enter`&&s&&(t.preventDefault(),n(-1),e.choose(o.current))},children:[(0,V.jsx)(`div`,{className:`cs-mxbig`,children:s?(0,V.jsx)(zq,{option:s,large:!0}):null}),s&&r?(0,V.jsxs)(`div`,{className:`cs-mxf`,children:[(0,V.jsx)(Bq,{color:u,children:o.current+1}),(0,V.jsx)(`b`,{children:fU(s.label)}),(0,V.jsxs)(`span`,{className:`cs-mxwho`,children:[Pq(r.prompt,r.header),` · `,r.question]}),i.length>1?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib`,"aria-label":`Previous mockup`,onClick:()=>l(-1),children:(0,V.jsx)($f,{"aria-hidden":`true`,className:`size-3.5`})}),(0,V.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib`,"aria-label":`Next mockup`,onClick:()=>l(1),children:(0,V.jsx)(tp,{"aria-hidden":`true`,className:`size-3.5`})})]}):null,(0,V.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-pri`,onClick:()=>{n(-1),e.choose(o.current)},children:r.multi?e.picks.includes(o.current)?`Unpick this`:`Pick this`:`Choose this`}),(0,V.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib`,"aria-label":`Close`,onClick:()=>n(-1),children:(0,V.jsx)(Fh,{"aria-hidden":`true`,className:`size-3.5`})})]}):null]})]})}var Uq=`bot-lobby.questionsPutAway`,Wq=new Set,Gq;function Kq(){if(Gq!==void 0)return Gq;try{Gq=sessionStorage.getItem(Uq)===`1`}catch{Gq=!1}return Gq}function qq(e){if(Kq()!==e){Gq=e;try{e?sessionStorage.setItem(Uq,`1`):sessionStorage.removeItem(Uq)}catch{}for(let e of[...Wq])e()}}function Jq(e){return Wq.add(e),()=>{Wq.delete(e)}}function Yq(){return(0,m.useSyncExternalStore)(Jq,Kq,()=>!1)}var Xq={id:`oracle`,label:`Message the team`,placeholder:`Write a message, run a command, or ask an agent`},Zq=new Set([`lobby`,`tasks`,`plan`,`knowledge`]);function Qq(e){return e.kind===`settings`||e.kind===`tab`&&Zq.has(e.tab)}var $q={id:`knowledge`,label:`Ask what the agents know`,placeholder:`Ask what the agents know…`};function eJ(e,t,n){if(e.kind!==`tab`)return Xq;if(e.tab===`knowledge`)return n?$q:Xq;if(e.tab===`plan`)return{id:`panel`,label:`Message the panel`,placeholder:`Describe a task, or answer the panel…`};let r=e.tab===`tasks`?TR(e.rest).id??t:void 0;return r?{id:`comment`,label:`Comment on ${r}`,placeholder:`Comment on ${r}'s plan…`,taskId:r}:Xq}var tJ={w:300,h:125},nJ=0;function rJ(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}var iJ={duration:.16,ease:`easeOut`};function aJ({file:e,onRemove:t}){let n=(0,V.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,onClick:t,className:Y(`flex shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,e.image?`absolute top-1 right-1 size-[1.625rem] rounded-full bg-background/85 text-foreground shadow-xs hover:bg-background`:`size-7`),children:(0,V.jsx)(Fh,{"aria-hidden":`true`,className:`size-3.5`})});return e.image?(0,V.jsxs)(Yd.li,{layout:!0,initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:iJ,title:`${e.name} · ${IK(e.size)}`,className:`relative size-16 shrink-0 overflow-hidden rounded-xl border border-(--bubble-edge) bg-background`,children:[(0,V.jsx)(`img`,{src:F(e.image),alt:e.name,className:`size-full object-cover`}),e.state===`uploading`?(0,V.jsxs)(`span`,{className:`pointer-events-none absolute inset-x-0 bottom-0 flex items-center justify-center gap-1 bg-background/85 px-1 text-[0.625rem] text-foreground`,children:[(0,V.jsx)(ER,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}),`uploading`]}):null,n]}):(0,V.jsxs)(Yd.li,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:iJ,className:`flex min-w-0 basis-full items-center gap-2 text-sm text-foreground`,children:[(0,V.jsx)(Lp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,V.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-muted-foreground`,children:[e.state===`uploading`?(0,V.jsx)(ER,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}):null,e.state===`uploading`?`uploading…`:IK(e.size)]}),n]})}function oJ(e,t,n,r){let[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(r);o.current=r;let s=n.kind===`tab`?n.tab:n.kind;return(0,m.useEffect)(()=>a(!1),[s]),(0,m.useEffect)(()=>{if(!t)return;let n=0,r=t=>{e.current?.contains(t.target)||(n=performance.now())},i=t=>{[`PageDown`,`PageUp`,`ArrowDown`,`ArrowUp`,`Home`,`End`,` `].includes(t.key)&&!e.current?.contains(t.target)&&(n=performance.now())},s=t=>{let r=e.current;!r||o.current||performance.now()-n>400||r.contains(document.activeElement)||r.contains(t.target)||a(!0)};return document.addEventListener(`wheel`,r,{capture:!0,passive:!0}),document.addEventListener(`touchmove`,r,{capture:!0,passive:!0}),document.addEventListener(`keydown`,i,{capture:!0}),document.addEventListener(`scroll`,s,{capture:!0,passive:!0}),()=>{document.removeEventListener(`wheel`,r,{capture:!0}),document.removeEventListener(`touchmove`,r,{capture:!0}),document.removeEventListener(`keydown`,i,{capture:!0}),document.removeEventListener(`scroll`,s,{capture:!0})}},[t,e]),{shrunk:i,expand:(0,m.useCallback)(()=>a(!1),[])}}function sJ({children:e}){return(0,V.jsx)(`kbd`,{className:`bubble-kbd`,children:e})}function cJ(e,t){let[n,r]=(0,m.useState)({w:250,h:48});return(0,m.useLayoutEffect)(()=>{let n=t.current;if(!n)return;let i=e===`bar`?{w:Math.ceil(n.scrollWidth)+12,h:48}:{w:580,h:Math.ceil(n.scrollHeight)};r(e=>e.w===i.w&&e.h===i.h?e:i)}),n}function lJ({route:e,projects:t,drawer:n,drawerOpen:r}){let[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)([]),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(null),h=FE(`status`),g=FE(`lobby`),_=dE(),v=(h.data?.busy??!1)||!!g.data?.reply?.trim(),y=Qq(e),b=(0,m.useRef)(y);b.current=y;let{taskId:x}=xW(),S=e.kind===`tab`?e.tab:e.kind,[C,w]=(0,m.useState)(!1);(0,m.useEffect)(()=>w(!1),[S]);let T=(0,m.useMemo)(()=>eJ(e,x,C),[e,x,C]),E=AD(),[D,O]=(0,m.useState)(-1),k=(0,m.useRef)(null),A=(0,m.useRef)(null),ee=(0,m.useRef)(null),j=(0,m.useRef)(null),M=(0,m.useRef)(null),te=(0,m.useRef)(null),ne=(0,m.useRef)(null),N=(0,m.useRef)(o);N.current=o;let re=(0,m.useRef)(void 0),[ie,ae]=(0,m.useState)(0),[oe,se]=(0,m.useState)(null),[ce,le]=(0,m.useState)(void 0),ue=r&&!!n.step&&y&&!_&&f===null,P=T.id===`oracle`&&!f&&!ue?dq(i,ie):void 0,de=(0,m.useMemo)(()=>P?pq(P,h.data?.commands):[],[P?.kind,P?.query,h.data?.commands]),fe=!!P&&de.length>0&&ce!==i&&y&&!_,pe=fe?de.find(e=>e.id===oe)??de[0]:void 0,F=`composer-suggestions`,I={answer:n.left>0&&!r,plan:S===`plan`&&!!E,knowledge:S===`knowledge`&&!C},me=!fe&&f===null&&!ue&&y&&!_&&(I.answer||I.plan||I.knowledge),he=fe||ue||f!==null&&y&&!_,ge=he||me,{shrunk:_e,expand:ve}=oJ(k,y&&!_,e,ge&&!me),[ye,be]=(0,m.useState)(!1),xe=(0,m.useRef)(_e);(0,m.useEffect)(()=>{if(xe.current===_e)return;xe.current=_e,be(!0);let e=setTimeout(()=>be(!1),420);return()=>clearTimeout(e)},[_e]),(0,m.useEffect)(()=>p(null),[S]),(0,m.useEffect)(()=>{(!y||_)&&p(null)},[y,_]),(0,m.useEffect)(()=>{if(!f)return;let e=e=>{A.current?.contains(e.target)||p(null)};return document.addEventListener(`pointerdown`,e,{capture:!0}),()=>document.removeEventListener(`pointerdown`,e,{capture:!0})},[f]);let Se=(0,m.useCallback)(e=>{ve(),p(t=>t===e||e===`projects`&&t===`browse`?null:e)},[ve]),Ce=(0,m.useCallback)(()=>{p(e=>{let t=e===`attach`?`[data-composer-attach]`:e?`[role="combobox"][aria-label="Project"]`:void 0;return t&&requestAnimationFrame(()=>A.current?.querySelector(t)?.focus({preventScroll:!0})),null})},[]);tD(`p`,()=>Se(`projects`),{enabled:y&&!_&&f===null}),(0,m.useEffect)(()=>{let e=()=>{ve(),p(`projects`)};return window.addEventListener(JK,e),()=>window.removeEventListener(JK,e)},[ve]);let we=(0,m.useRef)(`suggest`),Te=(0,m.useRef)({w:320,h:0}),Ee=f??(ue?`ask`:fe?`suggest`:me?`bar`:we.current),De=(0,m.useRef)(null),Oe=cJ(Ee,De);if(ge){we.current=Ee;let e=M.current?getComputedStyle(M.current).fontFamily:`system-ui, sans-serif`;Te.current=Ee===`suggest`?{w:vq(de,e),h:gq(de.length)}:Ee===`attach`?tJ:Ee===`projects`?XK(t):Ee===`bar`||Ee===`ask`?Oe:$K}let ke=(0,m.useRef)({items:[],kind:`slash-command`});fe&&P&&pe&&(ke.current={items:de,kind:P.kind,lit:pe.id});let Ae=(0,m.useCallback)(e=>{let t=i.replace(/^\s*[/@][a-z0-9:_.-]*\s*/i,``),n=`${e.insert} ${t}`,r=e.insert.length+1;re.current={start:r,end:r},ae(r),a(n),se(null),M.current?.focus()},[i]);(0,m.useLayoutEffect)(()=>{let e=re.current,t=M.current;e&&t&&(re.current=void 0,t.setSelectionRange(e.start,e.end))},[i]);let je=(0,m.useCallback)(e=>{re.current={start:e.start,end:e.end},ae(e.end),a(e.value)},[]);(0,m.useLayoutEffect)(()=>{let e=j.current,t=A.current;if(!e||!t)return;let n=()=>{t.hasAttribute(`data-shrunk`)||t.style.setProperty(`--ch-open`,`${Math.ceil(e.getBoundingClientRect().height)}px`)};n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[_e]),(0,m.useEffect)(()=>{let e=ee.current,t=k.current;if(!e||!t)return;let n=document.documentElement,r=()=>{let r=e.getBoundingClientRect(),i=t.getBoundingClientRect().bottom;if(n.style.setProperty(`--composer-h`,_||!y?`0px`:`${Math.ceil(i-r.top)}px`),!y||r.width===0){n.style.removeProperty(`--composer-x`),n.style.removeProperty(`--composer-w`);return}n.style.setProperty(`--composer-x`,`${Math.round(r.left)}px`),n.style.setProperty(`--composer-w`,`${Math.round(r.width)}px`)};r();let i=new ResizeObserver(r);return i.observe(e),e.addEventListener(`transitionend`,r),window.addEventListener(`resize`,r),()=>{i.disconnect(),e.removeEventListener(`transitionend`,r),window.removeEventListener(`resize`,r),n.style.setProperty(`--composer-h`,`0px`),n.style.removeProperty(`--composer-x`),n.style.removeProperty(`--composer-w`)}},[_,y]);let Me=(0,m.useCallback)(e=>{if(!b.current)return;let t=[...e],n=8-N.current.length;t.length>n&&H.warning(`At most 8 files go with one message.`);for(let e of t.slice(0,Math.max(0,n))){let t=`f${++nJ}`,n=e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0;s(r=>[...r,{key:t,name:e.name||(n?`image.png`:`file`),size:e.size,...n?{image:n}:{},state:`uploading`}]),LK(e).then(e=>s(n=>n.map(n=>n.key===t?{...n,state:`ready`,info:e}:n))).catch(e=>{H.error(e instanceof Error?e.message:`That file did not upload.`),s(e=>e.filter(e=>e.key!==t))})}},[]),Ne=(0,m.useCallback)(e=>{s(t=>{let n=t.find(t=>t.key===e);return n?.image&&URL.revokeObjectURL(n.image),t.filter(t=>t.key!==e)})},[]),Pe=o.some(e=>e.state===`uploading`),Fe=o.flatMap(e=>e.info?[e.info.id]:[]),Ie=(i.trim().length>0||Fe.length>0)&&!Pe&&!c,Le=(0,m.useCallback)(async()=>{if(!Ie||!b.current)return;l(!0);let e=Fe.length>0?Fe:void 0,t={text:i,...e?{attachments:e}:{}};try{let e=!0;if(T.id===`oracle`){let e=await L(`lobby.send`,t);e.notice&&H(e.notice),e.open===`plan`?bE(yE(`plan`)):S===`knowledge`&&bE(yE(`lobby`))}else T.id===`knowledge`?(e=await U(`knowledge.ask`,t)!==void 0,e&&(window.dispatchEvent(new CustomEvent(MD,{detail:i.trim()})),w(!1))):e=T.id===`panel`?await U(`planner.send`,t)!==void 0:await U(`tasks.comment`,{taskId:T.taskId,...t})!==void 0;if(e){a(``);for(let e of N.current)e.image&&URL.revokeObjectURL(e.image);s([])}}catch(e){H.error(e instanceof Error?e.message:`Could not send`)}finally{l(!1)}},[Ie,Fe,T,i,e,S]),Re=(0,m.useCallback)(async()=>{try{await L(`lobby.abort`,{})}catch(e){H.error(e instanceof Error?e.message:`Could not stop`)}},[]),ze=e=>{if(fe&&pe&&!e.nativeEvent.isComposing){let t=de.indexOf(pe);if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=(t+(e.key===`ArrowDown`?1:-1)+de.length)%de.length;se(de[n].id);return}if(e.key===`Enter`&&!e.shiftKey||e.key===`Tab`){e.preventDefault(),Ae(pe);return}if(e.key===`Escape`){e.preventDefault(),le(i);return}}if(e.key===`Escape`&&!e.nativeEvent.isComposing){e.preventDefault(),f?p(null):ue?qq(!0):C?w(!1):WE();return}if(ue&&rJ(e)){e.preventDefault(),n.reply(i)?a(``):!i.trim()&&n.step?.multi&&n.submitPicks();return}let t=e.currentTarget,r=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&!e.altKey&&!e.shiftKey&&[`b`,`i`,`e`,`k`].includes(r)){e.preventDefault();let{selectionStart:n,selectionEnd:i,value:a}=t;je(r===`k`?zK(a,n,i):RK(a,n,i,r===`b`?`**`:r===`i`?`_`:"`"));return}if(e.key===`Enter`&&e.shiftKey&&!e.nativeEvent.isComposing&&t.selectionStart===t.selectionEnd){let n=VK(t.value,t.selectionStart);n&&(e.preventDefault(),je(n));return}if(e.key===`Backspace`&&t.value===``&&N.current.length>0){e.preventDefault(),Ne(N.current.at(-1).key);return}(rJ(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey))&&(e.preventDefault(),Le())},Be=e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),Me(t))},Ve=e=>{e.preventDefault(),d(!1),e.dataTransfer.files.length>0&&Me(e.dataTransfer.files)},He=h.data?.workspace.name??`bot-lobby`,Ue=h.data?.branch??h.data?.workspace.branch,We=v&&T.id===`oracle`,Ge=_e?`Write a message…`:ue?n.step?.typed?n.step.placeholder:`Pick an answer above`:We?`The oracle is working. Enter steers it…`:T.placeholder,Ke=e=>{p(null),e.current?.click()},qe=Ee===`ask`?(0,V.jsx)(`div`,{ref:De,children:(0,V.jsx)(Vq,{drawer:n,onExpand:O})},`ask`):Ee===`bar`?(0,V.jsx)(`div`,{ref:De,className:`bubble-pane p-1.5`,style:{width:`max-content`},children:(0,V.jsxs)(`div`,{className:`cs-pbar`,children:[I.answer?(0,V.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq cs-acc`,onMouseDown:e=>e.preventDefault(),onClick:()=>{qq(!1),requestAnimationFrame(()=>M.current?.focus({preventScroll:!0}))},children:[(0,V.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M21 12a8 8 0 01-11.6 7.1L4 20l1-4.6A8 8 0 1121 12z`}),(0,V.jsx)(`path`,{d:`M9.6 9.5a2.5 2.5 0 014.8.9c0 1.6-2.4 2-2.4 3.4M12 16.5h.01`})]}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-accent)`,children:`Answer questions`}),(0,V.jsxs)(`span`,{className:`cs-ktag`,style:{"--k":`var(--primary)`},children:[n.left,` left`]})]}):null,I.plan?(0,V.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq`,"aria-keyshortcuts":`V`,onMouseDown:e=>e.preventDefault(),onClick:()=>E?.(),children:[(0,V.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M14 3H7a2 2 0 00-2 2v14a2 2 0 002 2h10a2 2 0 002-2V8z`}),(0,V.jsx)(`path`,{d:`M14 3v5h5M9 13h6M9 17h4`})]}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`View plan`}),(0,V.jsx)(`span`,{className:`cs-kb`,children:`V`})]}):null,I.knowledge?(0,V.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq`,onMouseDown:e=>e.preventDefault(),onClick:()=>{w(!0),requestAnimationFrame(()=>M.current?.focus({preventScroll:!0}))},children:[(0,V.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z`})}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Ask the knowledge`})]}):null]})},`bar`):Ee===`suggest`?(0,V.jsx)(yq,{listId:F,items:fe?de:ke.current.items,triggerKind:fe&&P?P.kind:ke.current.kind,activeItemId:pe?.id??null,onHighlightedItemChange:se,onSelect:Ae},`suggest`):Ee===`attach`?(0,V.jsxs)(`div`,{role:`menu`,"aria-label":`Attach`,className:`bubble-pane flex flex-col p-1.5`,onKeyDown:e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=[...e.currentTarget.querySelectorAll(`[role='menuitem']`)];t[(t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:t.length-1))%t.length]?.focus()},children:[(0,V.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`bubble-row h-10`,style:{"--delay":`24ms`},onClick:()=>Ke(te),children:[(0,V.jsx)(Lp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Upload a file…`})]}),(0,V.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`bubble-row h-10`,style:{"--delay":`12ms`},onClick:()=>Ke(ne),children:[(0,V.jsx)(qp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Upload an image…`})]}),(0,V.jsx)(`div`,{className:`h-px`}),(0,V.jsx)(`div`,{className:`flex h-8 items-center px-2.5 text-xs text-(--bubble-muted)`,children:`Or drop files on the composer`})]},`attach`):Ee===`projects`?(0,V.jsx)(QK,{projects:t,tab:S,onBrowse:()=>p(`browse`),onClose:()=>p(null)},`projects`):(0,V.jsx)(rq,{tab:S,onClose:Ce},`browse`);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`cs-scrim`,"data-open":he||void 0,"aria-hidden":`true`}),(0,V.jsx)(`div`,{id:`app-dock`,ref:k,"data-shrunk":_e||void 0,onFocus:ve,className:Y(`dock pointer-events-none absolute inset-x-0 bottom-0 z-30 px-6 pb-[max(24px,env(safe-area-inset-bottom))] transition-opacity duration-200 ease-snap`,_&&`opacity-0`),hidden:!y,"aria-hidden":!y||void 0,inert:_||!y,children:(0,V.jsx)(oq,{ref:A,open:ge,size:Te.current,shrunk:_e,morphing:ye,menu:qe,className:`composer-shell pointer-events-auto`,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||(f?(e.preventDefault(),Ce()):ue&&(e.preventDefault(),qq(!0)))},children:(0,V.jsxs)(`div`,{ref:ee,className:`bubble-composer group/composer composer-box`,"data-dragging":u||void 0,"data-chat-composer-main-surface":`true`,onPointerDown:ve,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),d(!0))},onDragLeave:()=>d(!1),onDrop:Ve,children:[(0,V.jsxs)(`div`,{ref:j,"data-chat-composer-surface":`true`,children:[(0,V.jsx)(eu,{initial:!1,children:o.length>0?(0,V.jsx)(Yd.ul,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.18,ease:`easeOut`},"aria-label":`Attachments`,className:`composer-files flex max-w-full flex-wrap gap-2 overflow-hidden px-3.5 pt-3`,children:o.map(e=>(0,V.jsx)(aJ,{file:e,onRemove:()=>Ne(e.key)},e.key))},`files`):null}),(0,V.jsx)(`textarea`,{ref:M,id:`composer-text`,"aria-label":T.label,...T.id===`oracle`?{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":fe,"aria-controls":fe?F:void 0}:{},...pe?{"aria-activedescendant":mq(F,pe.id)}:{},value:i,onChange:e=>{a(e.target.value),ae(e.target.selectionStart),p(null)},onSelect:e=>ae(e.currentTarget.selectionStart),onKeyDown:ze,onPaste:Be,placeholder:Ge,rows:1,className:`bubble-text`}),(0,V.jsxs)(`div`,{"data-chat-composer-footer":`true`,className:`bubble-tools composer-tools`,children:[(0,V.jsx)(`button`,{type:`button`,"data-composer-attach":!0,"aria-label":`Attach images, PDFs or files`,"aria-haspopup":`menu`,"aria-expanded":f===`attach`,"data-on":f===`attach`||void 0,"data-tip":`Attach a file`,onPointerDown:e=>e.preventDefault(),onClick:()=>Se(`attach`),className:`bubble-iconbtn bubble-tip bubble-tool size-8 rounded-full`,style:{"--i":0},children:(0,V.jsx)(Tm,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.7})}),(0,V.jsx)(`span`,{className:`bubble-tool flex min-w-0`,style:{"--i":1},children:(0,V.jsx)(ZK,{projects:t,name:He,branch:Ue,open:f===`projects`||f===`browse`,onToggle:()=>Se(`projects`)})}),(0,V.jsx)(`span`,{className:`flex-1`}),(0,V.jsx)(`span`,{className:`bubble-hints bubble-tool`,style:{"--i":2},"aria-hidden":`true`,children:fe?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(sJ,{children:`↑`}),(0,V.jsx)(sJ,{children:`↓`}),`choose`,(0,V.jsx)(sJ,{children:`↵`}),`insert`]}):f?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(sJ,{children:`Esc`}),`close`]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(sJ,{children:`Shift`}),(0,V.jsx)(sJ,{children:`↵`}),`new line`]})}),(0,V.jsxs)(`span`,{"data-chat-composer-actions":`right`,className:`bubble-tool flex shrink-0 items-center gap-2`,style:{"--i":3},children:[We?(0,V.jsx)(cq,{onStop:()=>void Re()}):null,(0,V.jsx)(lq,{sending:c,disabled:!Ie,steering:We,onSend:()=>void Le()})]})]})]}),(0,V.jsx)(`input`,{ref:te,type:`file`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach files`,onChange:e=>{Me(e.target.files??[]),e.target.value=``}}),(0,V.jsx)(`input`,{ref:ne,type:`file`,accept:`image/*`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach images`,onChange:e=>{Me(e.target.files??[]),e.target.value=``}}),u?(0,V.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-30 flex items-center justify-center rounded-[inherit] text-sm font-medium text-(--bubble-accent)`,children:`Drop to attach`}):null]})})}),(0,V.jsx)(Hq,{drawer:n,at:ue?D:-1,onAt:O})]})}function uJ({open:e,onOpenChange:t}){let n=lE(e,cE.help),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(``),l=(0,m.useId)(),u=()=>{a||(t(!1),i(``),c(``))},d=async()=>{let e=r.trim();if(e&&!a){o(!0),c(``);try{H((await L(`sessions.start`,{request:e})).notice),t(!1),i(``)}catch(e){c(e instanceof Error?e.message:`That did not work. Try again.`)}finally{o(!1)}}};return(0,V.jsx)(tE,{open:n,label:`New session`,description:`Starts a task in a session of its own, in the background.`,onOpenChange:e=>{e||u()},dismissOnBackdrop:!a,className:`max-w-[460px]`,children:(0,V.jsxs)(`div`,{className:`flex w-full flex-col`,children:[(0,V.jsxs)(`div`,{className:`cs-dh`,children:[(0,V.jsx)(`h2`,{children:`New session`}),(0,V.jsx)(`p`,{className:`mt-[5px] text-[12.5px] leading-normal text-muted-foreground`,children:`It runs in the background and shows up in the sidebar; this window carries on with what it is doing.`})]}),(0,V.jsxs)(`div`,{className:`cs-db flex flex-col`,children:[(0,V.jsx)(`label`,{htmlFor:l,className:`mb-[7px] text-[12.5px] font-semibold`,children:`What should it do?`}),(0,V.jsx)(CB,{id:l,value:r,autoFocus:!0,disabled:a,"aria-invalid":s?!0:void 0,placeholder:`Fix the flaky login test, add dark mode to Settings…`,className:`cs-nsta max-h-60 min-h-[108px]`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d())}}),s?(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:s}):null]}),(0,V.jsxs)(`div`,{className:`cs-df`,children:[(0,V.jsxs)(`span`,{className:`mr-auto flex items-center gap-1.5 text-xs text-[var(--faint)]`,children:[(0,V.jsx)(QT,{chord:`Ctrl+Enter`}),` to start`]}),(0,V.jsx)(WT,{variant:`outline`,onClick:u,disabled:a,children:`Cancel`}),(0,V.jsx)(WT,{onClick:()=>void d(),disabled:!r.trim()||a,"aria-busy":a,children:a?`Starting…`:`Start session`})]})]})})}function dJ(){let e=(e,t)=>(0,V.jsxs)(`filter`,{id:e,x:`-20%`,y:`-35%`,width:`140%`,height:`170%`,colorInterpolationFilters:`sRGB`,children:[(0,V.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:t,result:`b`}),(0,V.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`0.9`,dy:`1.3`,result:`dn`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`rimA`}),(0,V.jsx)(`feGaussianBlur`,{in:`rimA`,stdDeviation:`0.4`,result:`rimB`}),(0,V.jsx)(`feComposite`,{in:`rimB`,in2:`shape`,operator:`in`,result:`rimC`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--hl)`},result:`hlc`}),(0,V.jsx)(`feComposite`,{in:`hlc`,in2:`rimC`,operator:`in`,result:`hl`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`-0.9`,dy:`-1.3`,result:`up`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`shA`}),(0,V.jsx)(`feGaussianBlur`,{in:`shA`,stdDeviation:`0.4`,result:`shB`}),(0,V.jsx)(`feComposite`,{in:`shB`,in2:`shape`,operator:`in`,result:`shC`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--sh)`},result:`shc`}),(0,V.jsx)(`feComposite`,{in:`shc`,in2:`shC`,operator:`in`,result:`sh`}),(0,V.jsxs)(`feMerge`,{children:[(0,V.jsx)(`feMergeNode`,{in:`shape`}),(0,V.jsx)(`feMergeNode`,{in:`sh`}),(0,V.jsx)(`feMergeNode`,{in:`hl`})]})]});return(0,V.jsx)(`svg`,{width:`0`,height:`0`,className:`absolute`,"aria-hidden":`true`,focusable:`false`,children:(0,V.jsxs)(`defs`,{children:[e(`cs-baylit`,5),e(`cs-worklit`,3.2),(0,V.jsxs)(`filter`,{id:`cs-bayedge`,x:`-20%`,y:`-35%`,width:`140%`,height:`170%`,colorInterpolationFilters:`sRGB`,children:[(0,V.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`5`,result:`b`}),(0,V.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`2`,dy:`3`,result:`dn`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`tS0`}),(0,V.jsx)(`feGaussianBlur`,{in:`tS0`,stdDeviation:`0.8`,result:`tS1`}),(0,V.jsx)(`feComposite`,{in:`tS1`,in2:`shape`,operator:`in`,result:`tS`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--ehl)`},result:`tc`}),(0,V.jsx)(`feComposite`,{in:`tc`,in2:`tS`,operator:`in`,result:`eh`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`-2`,dy:`-3`,result:`up`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`bS0`}),(0,V.jsx)(`feGaussianBlur`,{in:`bS0`,stdDeviation:`0.8`,result:`bS1`}),(0,V.jsx)(`feComposite`,{in:`bS1`,in2:`shape`,operator:`in`,result:`bS`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--esh)`},result:`bc`}),(0,V.jsx)(`feComposite`,{in:`bc`,in2:`bS`,operator:`in`,result:`es`}),(0,V.jsxs)(`feMerge`,{children:[(0,V.jsx)(`feMergeNode`,{in:`shape`}),(0,V.jsx)(`feMergeNode`,{in:`eh`}),(0,V.jsx)(`feMergeNode`,{in:`es`})]})]}),(0,V.jsxs)(`filter`,{id:`cs-tabdent`,x:`-10%`,y:`-45%`,width:`120%`,height:`190%`,colorInterpolationFilters:`sRGB`,children:[(0,V.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`2.6`,result:`b`}),(0,V.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`2.2`,dy:`3`,result:`dn`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`sA`}),(0,V.jsx)(`feGaussianBlur`,{in:`sA`,stdDeviation:`1.5`,result:`sB`}),(0,V.jsx)(`feComposite`,{in:`sB`,in2:`shape`,operator:`in`,result:`sC`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--tdsh)`},result:`shc`}),(0,V.jsx)(`feComposite`,{in:`shc`,in2:`sC`,operator:`in`,result:`sh`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`-1.4`,dy:`-2`,result:`up`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`hA`}),(0,V.jsx)(`feGaussianBlur`,{in:`hA`,stdDeviation:`1`,result:`hB`}),(0,V.jsx)(`feComposite`,{in:`hB`,in2:`shape`,operator:`in`,result:`hC`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--tdhl)`},result:`hlc`}),(0,V.jsx)(`feComposite`,{in:`hlc`,in2:`hC`,operator:`in`,result:`hl`}),(0,V.jsxs)(`feMerge`,{children:[(0,V.jsx)(`feMergeNode`,{in:`shape`}),(0,V.jsx)(`feMergeNode`,{in:`sh`}),(0,V.jsx)(`feMergeNode`,{in:`hl`})]})]}),(0,V.jsxs)(`filter`,{id:`cs-indgoo`,x:`-20%`,y:`-80%`,width:`140%`,height:`260%`,colorInterpolationFilters:`sRGB`,children:[(0,V.jsx)(`feGaussianBlur`,{stdDeviation:`2.6`}),(0,V.jsx)(`feColorMatrix`,{type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 22 -10`})]})]})})}function fJ({className:e,style:t}){return(0,V.jsxs)(`div`,{className:e,"aria-hidden":`true`,style:t,children:[(0,V.jsx)(`div`,{className:`cs-layer cs-edge`,children:(0,V.jsx)(`div`,{className:`cs-bb`})}),(0,V.jsx)(`div`,{className:`cs-layer cs-fill`,children:(0,V.jsx)(`div`,{className:`cs-bb`})})]})}function pJ(e){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)(!1),a=(0,m.useRef)(void 0);(0,m.useEffect)(()=>()=>window.clearTimeout(a.current),[]);let o=(0,m.useCallback)(()=>{window.clearTimeout(a.current),n(!0)},[]),s=(0,m.useCallback)(()=>{window.clearTimeout(a.current),a.current=window.setTimeout(()=>n(!1),e)},[e]),c=(0,m.useCallback)(()=>{window.clearTimeout(a.current),n(!0),a.current=window.setTimeout(()=>n(!1),e)},[e]);return{open:t||r,flash:c,close:()=>{window.clearTimeout(a.current),n(!1)},handlers:{onPointerEnter:e=>{e.pointerType!==`touch`&&o()},onPointerLeave:e=>{e.pointerType!==`touch`&&s()},onFocus:()=>i(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||i(!1)}}}}function mJ({id:e}){let t={width:15,height:15,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0};return e===`lobby`?(0,V.jsx)(`svg`,{...t,children:(0,V.jsx)(`path`,{d:`M21 12a8 8 0 01-11.6 7.1L4 20l1-4.6A8 8 0 1121 12z`})}):e===`tasks`?(0,V.jsxs)(`svg`,{...t,children:[(0,V.jsx)(`path`,{d:`M9 11l3 3L22 4`}),(0,V.jsx)(`path`,{d:`M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11`})]}):e===`plan`?(0,V.jsxs)(`svg`,{...t,children:[(0,V.jsx)(`path`,{d:`M3 6l6-3 6 3 6-3v15l-6 3-6-3-6 3z`}),(0,V.jsx)(`path`,{d:`M9 3v15M15 6v15`})]}):e===`knowledge`?(0,V.jsxs)(`svg`,{...t,children:[(0,V.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 016.5 17H20`}),(0,V.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 014 19.5v-15A2.5 2.5 0 016.5 2z`})]}):(0,V.jsxs)(`svg`,{...t,children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,V.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 00.3 1.8l.1.1a2 2 0 11-2.8 2.8l-.1-.1a1.7 1.7 0 00-1.8-.3 1.7 1.7 0 00-1 1.5V21a2 2 0 11-4 0v-.1a1.7 1.7 0 00-1.1-1.5 1.7 1.7 0 00-1.8.3l-.1.1a2 2 0 11-2.8-2.8l.1-.1a1.7 1.7 0 00.3-1.8 1.7 1.7 0 00-1.5-1H3a2 2 0 110-4h.1a1.7 1.7 0 001.5-1.1 1.7 1.7 0 00-.3-1.8l-.1-.1a2 2 0 112.8-2.8l.1.1a1.7 1.7 0 001.8.3H9a1.7 1.7 0 001-1.5V3a2 2 0 114 0v.1a1.7 1.7 0 001 1.5 1.7 1.7 0 001.8-.3l.1-.1a2 2 0 112.8 2.8l-.1.1a1.7 1.7 0 00-.3 1.8V9a1.7 1.7 0 001.5 1H21a2 2 0 110 4h-.1a1.7 1.7 0 00-1.5 1z`})]})}var hJ=`cubic-bezier(0.3,1.2,0.5,1)`,gJ=`cubic-bezier(0.22,1,0.36,1)`;function _J({tabs:e,activeId:t,label:n,onSelect:r,flashRef:i}){let a=pJ(600);i.current=a.flash;let o=(0,m.useRef)(null),s=(0,m.useRef)(null),c=(0,m.useRef)({}),[l,u]=(0,m.useState)({closed:99,open:346}),[d,f]=(0,m.useState)(0),p=(0,m.useRef)({placed:!1}),h=e.find(e=>e.id===t),g=h?.id??n.id,_=h?.label??n.text;(0,m.useLayoutEffect)(()=>{let e=()=>{let e=s.current?Math.ceil(s.current.getBoundingClientRect().width)+40:99,t=o.current?[...o.current.querySelectorAll(`[role='tab']`)]:[],n=t.length?Math.ceil(t.reduce((e,t)=>e+t.offsetWidth,0)+(t.length-1)*2)+20:346;u(t=>t.closed===e&&t.open===n?t:{closed:e,open:n})};e(),document.fonts?.ready.then(e)},[_,e.length]),(0,m.useEffect)(()=>f(e=>e+1),[g]);let v=(0,m.useCallback)(()=>{let e=o.current;if(!e)return;let n=t?c.current[t]:void 0;if(!n)return;let r=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,i=!p.current.placed,a=n.offsetLeft,s=e.offsetWidth-a-n.offsetWidth,l=p.current.left===void 0||a>p.current.left;for(let t of e.querySelectorAll(`.cs-tabind`)){let n=t.firstElementChild;if(n){if(i||r||e.offsetWidth===0){n.style.transition=`none`,n.style.left=`${a}px`,n.style.right=`${s}px`;continue}a!==p.current.left&&(n.style.transition=l?`left 520ms ${gJ} 24ms, right 320ms ${hJ}`:`left 320ms ${hJ}, right 520ms ${gJ} 24ms`,n.style.left=`${a}px`,n.style.right=`${s}px`,t.animate?.([{transform:`scaleY(1)`},{transform:`scaleY(0.84)`,offset:.35},{transform:`scaleY(1.05)`,offset:.75},{transform:`scaleY(1)`}],{duration:540,easing:`ease-in-out`}))}}e.offsetWidth>0&&(p.current={left:a,placed:!0})},[t]);(0,m.useLayoutEffect)(()=>{let e=requestAnimationFrame(()=>requestAnimationFrame(v));return()=>cancelAnimationFrame(e)},[v,l.open]);function y(n){if(n.key===`ArrowDown`&&!n.altKey){UE()&&n.preventDefault();return}let i=n.key===`ArrowRight`?1:n.key===`ArrowLeft`?-1:0;if(!i||e.length===0)return;n.preventDefault();let a=n.target.closest(`[role='tab']`)?.id.replace(/^tab-/,``)??t,o=e[(Math.max(0,e.findIndex(e=>e.id===a))+i+e.length)%e.length];GE.active=!0,GE.to=o.id,window.setTimeout(()=>{GE.active=!1,GE.to=void 0},3e3),r(o.id),c.current[o.id]?.focus({preventScroll:!0})}let b=a.open,x={"--wT":`${b?l.open:l.closed}px`,"--hT":b?`38px`:`30px`};return{open:b,vars:x,ghost:(0,V.jsx)(fJ,{className:`cs-gt`,style:x}),bay:(0,V.jsx)(`div`,{className:`cs-tbwrap`,style:x,...a.handlers,children:(0,V.jsxs)(`div`,{className:`cs-tbx`,children:[(0,V.jsx)(`div`,{className:`cs-tbc`,"aria-hidden":`true`,children:(0,V.jsxs)(`span`,{ref:s,className:`cs-lb`,"data-p":String(d%2),children:[(0,V.jsx)(`span`,{className:`cs-ti`,children:(0,V.jsx)(mJ,{id:g})}),_]},g)}),(0,V.jsx)(`div`,{className:`cs-tbo`,"data-none":t?void 0:``,children:(0,V.jsxs)(`div`,{ref:o,role:`tablist`,"aria-label":`Lobby tabs`,onKeyDown:y,className:`cs-track`,children:[(0,V.jsx)(`span`,{className:`cs-tabind cs-dent`,"aria-hidden":`true`,children:(0,V.jsx)(`i`,{})}),(0,V.jsx)(`span`,{className:`cs-tabind cs-tint`,"aria-hidden":`true`,children:(0,V.jsx)(`i`,{})}),e.map((e,n)=>(0,V.jsxs)(`a`,{ref:t=>{c.current[e.id]=t},role:`tab`,id:`tab-${e.id}`,href:`#/${e.id}`,"aria-selected":e.id===t,"aria-keyshortcuts":e.key,title:`${e.label} · ${e.key.replace(`+`,` `)}`,tabIndex:e.id===t||!t&&n===0?0:-1,className:`cs-tab`,style:{"--i":n},children:[(0,V.jsx)(`span`,{className:`cs-ti`,children:(0,V.jsx)(mJ,{id:e.id})}),e.label]},e.id))]})})]})})}}function vJ({children:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fJ,{className:`cs-gr`}),(0,V.jsx)(`div`,{className:Y(`cs-rbx`),children:e})]})}function yJ(e){return e.waiting>0&&e.alive?`asking`:e.status===`exited`||!e.alive?`exited`:e.busy||e.status===`working`?`working`:e.status===`starting`?`starting`:`idle`}function bJ(e,t){let n=e?.sessionId,r={id:`here`,name:e?.sessionName?.trim()||`This window`,where:`here`,state:e?.busy?`working`:`idle`,waiting:0,...n?{sessionId:n}:{}},i=(t?.background??[]).filter(e=>!n||e.sessionId!==n).map(e=>({id:`bg:${e.key}`,name:e.name,where:`background`,state:yJ(e),waiting:e.alive?e.waiting:0,key:e.key,...e.sessionId?{sessionId:e.sessionId}:{}})),a=new Set([n,...i.map(e=>e.sessionId)].filter(Boolean)),o=(t?.live??[]).filter(e=>!a.has(e.sessionId)).map(e=>({id:`live:${e.sessionId}`,name:e.name?.trim()||`Unnamed session`,where:`elsewhere`,state:`idle`,waiting:0,sessionId:e.sessionId}));return i.sort((e,t)=>Number(e.state===`exited`)-Number(t.state===`exited`)),[r,...i,...o]}var xJ=`app.sidebar.pinned`,SJ=()=>hz(xJ),CJ={w:244,h:`min(520px, calc(100vh - 112px))`},wJ=`cs-iconbtn cs-sm`;function TJ({label:e,hint:t,side:n=`bottom`,children:r}){return(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:r}),(0,V.jsxs)(VI,{side:n,children:[e,` `,t?(0,V.jsx)(QT,{chord:t}):null]})]})}function EJ(){let e=FE(`status`).data;return bJ(e,_R(`sessions.list`,{},[`sessions`]).data)}function DJ(){return(0,m.useCallback)(async e=>{if(e.where===`here`)return bE(`#/lobby`);if(e.where===`elsewhere`)return void H.info(`${e.name} runs in another terminal. Switch to that terminal to work in it.`);await U(`sessions.switch`,e.key?{key:e.key}:{sessionId:e.sessionId})&&bE(`#/lobby`)},[])}function OJ({entry:e}){return e.where!==`elsewhere`&&e.state===`asking`?(0,V.jsxs)(`span`,{className:`cs-badge`,children:[(0,V.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,V.jsx)(`path`,{d:`M9.1 9a3 3 0 015.8 1c0 2-3 2.5-3 4M12 17h.01`})]}),e.waiting,(0,V.jsxs)(`span`,{className:`sr-only`,children:[e.waiting===1?` question`:` questions`,`, Waiting`]})]}):e.where!==`elsewhere`&&(e.state===`working`||e.state===`starting`)?(0,V.jsxs)(`span`,{className:Y(`inline-flex shrink-0`,e.state===`working`?`text-primary`:`text-muted-foreground`),children:[(0,V.jsx)(lp,{"aria-hidden":`true`,className:`session-spin size-3.5`}),(0,V.jsx)(`span`,{className:`sr-only`,children:e.state===`working`?`Working`:`Starting`})]}):(0,V.jsx)(`span`,{className:`sr-only`,children:e.where===`elsewhere`?`Other terminal`:e.state===`exited`?`Ended`:`Idle`})}var kJ={here:`This window`,background:`Background`,elsewhere:`Other terminal`};function AJ(e){let t=e.key;return U(`sessions.archive`,{key:t},{undo:()=>void U(`sessions.archive`,{key:t,archived:!1})})}function jJ({entry:e,onDone:t}){let[n,r]=(0,m.useState)(e.name),i=(0,m.useRef)(!1),a=async()=>{if(i.current)return;i.current=!0;let r=n.replace(/\s+/g,` `).trim();r&&r!==e.name&&await U(`sessions.rename`,{...e.where===`here`?{}:{key:e.key},name:r}),t()};return(0,V.jsx)(`input`,{value:n,autoFocus:!0,maxLength:120,"aria-label":`New name for ${e.name}`,onFocus:e=>e.currentTarget.select(),onChange:e=>r(e.target.value),onBlur:()=>void a(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),a()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i.current=!0,t())},className:`h-6 w-full min-w-0 rounded-md bg-[var(--fill)] px-1.5 text-[13px] text-foreground outline-none ring-2 ring-ring`})}function MJ({entry:e,index:t}){let n=DJ(),[r,i]=(0,m.useState)(!1),a=e.state===`exited`||e.where===`elsewhere`,o=e.where!==`elsewhere`,s=e.where===`background`&&e.state===`exited`&&!!e.key,c=o||s,l={"--i":t};return(0,V.jsxs)(`li`,{className:`cs-srow session-item`,children:[r?(0,V.jsx)(`div`,{className:`cs-sr`,"data-active":e.where===`here`||void 0,style:l,children:(0,V.jsx)(jJ,{entry:e,onDone:()=>i(!1)})}):(0,V.jsxs)(`button`,{type:`button`,"aria-current":e.where===`here`?`true`:void 0,"aria-label":e.where===`here`?`${e.name}, this window`:e.where===`elsewhere`?`${e.name}, in another terminal`:`Switch to ${e.name}`,title:e.name,"data-where":e.where,"data-state":e.state,"data-dim":a||void 0,onClick:()=>void n(e),onDoubleClick:e=>{o&&(e.preventDefault(),i(!0))},className:`cs-sr session-row`,style:l,children:[(0,V.jsx)(`span`,{className:`cs-grow`,children:e.name}),(0,V.jsx)(`span`,{className:Y(`flex shrink-0 items-center`,c&&`cs-sstate`),children:(0,V.jsx)(OJ,{entry:e})})]}),!r&&c?(0,V.jsxs)(`span`,{className:`cs-sacts`,children:[o?(0,V.jsx)(TJ,{label:`Rename`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Rename ${e.name}`,onClick:()=>i(!0),className:`cs-sact`,children:(0,V.jsx)(km,{"aria-hidden":`true`,className:`size-3.5`})})}):null,s?(0,V.jsx)(TJ,{label:`Archive`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Archive ${e.name}`,onClick:()=>void AJ(e),className:`cs-sact`,children:(0,V.jsx)(Af,{"aria-hidden":`true`,className:`size-3.5`})})}):null]}):null]})}function NJ({id:e,label:t,entries:n,start:r,archivable:i=!1}){let[a,o]=gz(`app.sidebar.${e}`),s=(0,m.useId)();return n.length===0?null:(0,V.jsxs)(`section`,{"aria-label":t,className:`group/shelf flex flex-col`,children:[(0,V.jsxs)(`div`,{className:`cs-sh`,style:{"--i":r},children:[(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":!a,"aria-controls":s,onClick:o,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left outline-none hover:text-foreground focus-visible:underline`,children:[(0,V.jsx)(`span`,{children:t}),a?(0,V.jsx)(`span`,{className:`tabular-nums`,children:n.length}):null,(0,V.jsx)(Zf,{"aria-hidden":`true`,className:Y(`size-3 opacity-0 transition-[opacity,rotate] duration-150 group-hover/shelf:opacity-100 group-focus-within/shelf:opacity-100`,a&&`-rotate-90 opacity-100`)})]}),i?(0,V.jsx)(`button`,{type:`button`,onClick:()=>void(async()=>{for(let e of n)e.key&&await U(`sessions.archive`,{key:e.key})})(),className:`shrink-0 outline-none hover:text-foreground focus-visible:underline`,children:`Archive all`}):null]}),a?null:(0,V.jsx)(`ul`,{id:s,className:`flex flex-col`,children:n.map((e,t)=>(0,V.jsx)(MJ,{entry:e,index:r+1+t},e.id))})]})}function PJ(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean),r=`${e.name} ${kJ[e.where]}`.toLowerCase();return n.every(e=>r.includes(e))}function FJ({query:e,onQuery:t,onNew:n}){return(0,V.jsxs)(`label`,{className:`cs-sr cs-search`,style:{"--i":0},children:[(0,V.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,V.jsx)(`path`,{d:`M21 21l-4.3-4.3`})]}),(0,V.jsx)(`input`,{type:`search`,value:e,"aria-label":`Search sessions`,placeholder:`Search`,onChange:e=>t(e.target.value),onKeyDown:n=>{n.key===`Escape`&&e&&(n.preventDefault(),n.stopPropagation(),t(``))}}),(0,V.jsx)(TJ,{label:`New session`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`New session`,"aria-haspopup":`dialog`,onClick:n,className:`flex text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground`,children:(0,V.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M12 20h9`}),(0,V.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`})]})})})]})}function IJ({query:e}){let t=EJ(),n=t.filter(t=>PJ(t,e)),r=n.filter(e=>e.where===`here`&&e.state!==`exited`),i=n.filter(e=>e.where===`background`&&e.state!==`exited`),a=n.filter(e=>e.where===`elsewhere`),o=n.filter(e=>e.where!==`elsewhere`&&e.state===`exited`),s=1,c=e=>{let t=s;return s+=e+1,t},l=c(r.length),u=c(i.length);return(0,V.jsxs)(`nav`,{"aria-label":`Sessions list`,className:`cs-sblist`,children:[n.length===0?(0,V.jsxs)(`p`,{className:`px-2.5 py-1.5 text-xs text-muted-foreground`,children:[`No sessions match “`,e.trim(),`”.`]}):null,r.length>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`cs-sh`,style:{"--i":l},children:`This window`}),(0,V.jsx)(`ul`,{className:`flex flex-col`,children:r.map((e,t)=>(0,V.jsx)(MJ,{entry:e,index:l+1+t},e.id))})]}):null,i.length>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`cs-sh`,style:{"--i":u},children:`Background`}),(0,V.jsx)(`ul`,{className:`flex flex-col`,children:i.map((e,t)=>(0,V.jsx)(MJ,{entry:e,index:u+1+t},e.id))})]}):!e.trim()&&t.length===1?(0,V.jsx)(`p`,{className:`cs-sh`,style:{"--i":u},children:`No other sessions are running.`}):null,(0,V.jsx)(NJ,{id:`elsewhere`,label:`Other terminals`,entries:a,start:c(a.length)}),(0,V.jsx)(NJ,{id:`ended`,label:`Ended`,entries:o,start:c(o.length),archivable:!0})]})}function LJ({route:e,keys:t,onHelp:n}){let r=t.settings??`Alt+S`;return(0,V.jsxs)(`div`,{className:`cs-sbfoot`,children:[(0,V.jsxs)(`a`,{href:`#/settings`,"aria-label":`Settings`,"aria-current":e.kind===`settings`?`page`:void 0,"aria-keyshortcuts":r,className:`cs-sr`,style:{"--i":20},children:[(0,V.jsx)(mJ,{id:`settings`}),(0,V.jsx)(`span`,{className:`cs-grow`,children:`Settings`}),(0,V.jsx)(QT,{chord:r})]}),(0,V.jsxs)(`div`,{className:`cs-sr cs-tools`,style:{"--i":21},children:[(0,V.jsx)(kK,{hint:t.help??`Alt+H`,onHelp:n,className:wJ}),(0,V.jsx)(AK,{className:wJ}),(0,V.jsx)(NK,{className:wJ}),(0,V.jsx)(PK,{className:wJ}),(0,V.jsx)(FK,{className:wJ})]})]})}function RJ(e){let[t,n]=gz(xJ),r=pJ(160),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),c=t||r.open||o,l={"--wL":`${c?CJ.w:46}px`,"--hL":c?CJ.h:`148px`,"--sb-open-h":CJ.h},u=(0,m.useCallback)(()=>s(!0),[]);return{open:c,ghost:(0,V.jsx)(fJ,{className:`cs-gl`,style:l}),bay:(0,V.jsxs)(`div`,{className:`cs-sbwrap`,style:l,...r.handlers,children:[(0,V.jsxs)(`aside`,{id:`app-sidebar`,"aria-label":`Sidebar`,className:`cs-sbx`,children:[(0,V.jsxs)(`div`,{className:`cs-sbmini`,inert:c,children:[(0,V.jsx)(TJ,{label:t?`Unpin sidebar`:`Pin sidebar`,hint:e.keys.sidebar,side:`right`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Sessions`,"aria-pressed":t,"aria-keyshortcuts":e.keys.sidebar,onClick:n,className:`cs-iconbtn`,children:(0,V.jsx)(mJ,{id:`lobby`})})}),(0,V.jsx)(TJ,{label:`New session`,side:`right`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`New session`,"aria-haspopup":`dialog`,onClick:u,className:`cs-iconbtn`,children:(0,V.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M12 20h9`}),(0,V.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`})]})})}),(0,V.jsx)(TJ,{label:`Settings`,hint:e.keys.settings??`Alt+S`,side:`right`,children:(0,V.jsx)(`a`,{href:`#/settings`,"aria-label":`Settings`,"aria-current":e.route.kind===`settings`?`page`:void 0,className:`cs-iconbtn`,children:(0,V.jsx)(mJ,{id:`settings`})})})]}),(0,V.jsxs)(`div`,{className:`cs-sbfull`,inert:!c,children:[(0,V.jsx)(FJ,{query:i,onQuery:a,onNew:u}),(0,V.jsx)(IJ,{query:i}),(0,V.jsx)(LJ,{...e})]})]}),(0,V.jsx)(uJ,{open:o,onOpenChange:s})]})}}var zJ=`bot-lobby.terminal.open`,BJ=`bot-lobby.terminal.height`,VJ=`bot-lobby.terminal.popup`,HJ={start:280,min:140},UJ=new Set,WJ,GJ,KJ;function qJ(e){try{return localStorage.getItem(e)}catch{return null}}function JJ(e,t){try{localStorage.setItem(e,t)}catch{}}function YJ(){for(let e of[...UJ])e()}function XJ(e){return UJ.add(e),()=>{UJ.delete(e)}}function ZJ(){return WJ??=qJ(zJ)===`1`,WJ}function QJ(){if(GJ===void 0){let e=Number(qJ(BJ));GJ=e>=HJ.min?e:HJ.start}return GJ}function $J(e){WJ=e,JJ(zJ,e?`1`:`0`),YJ()}function eY(){$J(!ZJ())}function tY(e){GJ=Math.max(HJ.min,Math.round(e)),JJ(BJ,String(GJ)),YJ()}function nY(){return(0,m.useSyncExternalStore)(XJ,ZJ,()=>!1)}function rY(){return(0,m.useSyncExternalStore)(XJ,QJ,()=>HJ.start)}function iY(){return KJ??=qJ(VJ)===`1`,KJ}function aY(e){KJ=e,JJ(VJ,e?`1`:`0`),YJ()}function oY(){return(0,m.useSyncExternalStore)(XJ,iY,()=>!1)}var sY=`modulepreload`,cY=function(e){return`/`+e},lY={},uY=function(e){return e.pathname.endsWith(`.css`)},dY=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=cY(t,n);let r=s(t);if(r.href in lY)return;lY[r.href]=!0;let i=uY(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:sY,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},fY=(0,m.lazy)(()=>dY(()=>import(`./TerminalView-qi3aVzXz.js`),__vite__mapDeps([0,1,2,3]))),pY=`inline-flex size-6 items-center justify-center text-foreground/80 outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40 aria-pressed:bg-accent aria-pressed:text-foreground`;function mY({label:e,hint:t,children:n}){return(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:n}),(0,V.jsxs)(VI,{side:`top`,children:[e,` `,t?(0,V.jsx)(QT,{chord:t}):null]})]})}function hY({hint:e,className:t}){let n=nY();return(0,V.jsx)(mY,{label:n?`Hide terminal`:`Terminal`,hint:e,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Terminal`,"aria-pressed":n,"aria-controls":n?`terminal-drawer`:void 0,"aria-keyshortcuts":e,onClick:eY,className:t,children:(0,V.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M4 17l6-6-6-6M12 19h8`})})})})}function gY(e){let[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(``),a=(0,m.useCallback)(async()=>{try{n(await L(`terminal.list`,{})),i(``)}catch(e){i(e instanceof Error?e.message:`The terminals could not be read.`)}},[]);return(0,m.useEffect)(()=>{e&&a()},[e,a]),{list:t,error:r,reload:a}}function _Y({height:e,max:t}){let n=(0,m.useRef)(null);return(0,V.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-label":`Resize terminal`,"aria-orientation":`horizontal`,"aria-valuenow":e,"aria-valuemin":HJ.min,"aria-valuemax":t,className:`terminal-edge`,onPointerDown:t=>{t.button===0&&(t.currentTarget.setPointerCapture?.(t.pointerId),n.current={y:t.clientY,height:e},document.documentElement.dataset.resizing=`row`)},onPointerMove:e=>{n.current&&tY(Math.min(t,n.current.height+n.current.y-e.clientY))},onPointerUp:()=>{n.current=null,delete document.documentElement.dataset.resizing},onPointerCancel:()=>{n.current=null,delete document.documentElement.dataset.resizing},onDoubleClick:()=>tY(HJ.start),onKeyDown:n=>{(n.key===`ArrowUp`||n.key===`ArrowDown`)&&(n.preventDefault(),tY(Math.min(t,e+(n.key===`ArrowUp`?24:-24))))}})}function vY({toggleKey:e}){let t=nY(),n=oY(),r=rY(),i=lE(t&&n,cE.sheet),{list:a,error:o,reload:s}=gY(t),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(()=>Math.round(window.innerHeight*.7)),h=a?.terminals??[],g=h.find(e=>e.id===c)??h.at(-1);(0,m.useEffect)(()=>{let e=()=>p(Math.round(window.innerHeight*.7));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let _=(0,m.useCallback)(async()=>{d(!0);try{let e=await L(`terminal.open`,{cols:100,rows:24});l(e.id),await s()}catch(e){H.error(e instanceof Error?e.message:`The terminal did not start.`)}finally{d(!1)}},[s]),v=(0,m.useCallback)(async e=>{try{await L(`terminal.close`,{id:e})}catch{}await s()},[s]),y=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!t){y.current=!1;return}!a||!a.available||a.terminals.length>0||y.current||u||(y.current=!0,_())},[t,a,u,_]);let b=t&&!n?Math.min(r,f):0;if((0,m.useEffect)(()=>{let e=document.documentElement;return b?e.style.setProperty(`--terminal-h`,`${b}px`):e.style.removeProperty(`--terminal-h`),()=>{e.style.removeProperty(`--terminal-h`)}},[b]),!t)return null;let x=(0,V.jsx)(yY,{list:a,error:o,terminals:h,shown:g,busy:u,popup:n,toggleKey:e,onPick:l,onStart:()=>void _(),onEnd:e=>void v(e),onReload:()=>void s()});return n?(0,V.jsx)(tE,{open:i,onOpenChange:e=>{e||$J(!1)},label:`Terminal`,className:`terminal-pop h-[min(72svh,40rem)] max-h-none max-w-5xl`,onEscapeKeyDown:e=>{e.target?.closest?.(`.xterm`)&&e.preventDefault()},children:(0,V.jsx)(`div`,{id:`terminal-drawer`,className:`flex min-h-0 flex-1`,children:x})}):(0,V.jsxs)(`section`,{id:`terminal-drawer`,"aria-label":`Terminal`,className:`terminal-drawer relative flex shrink-0 border-t border-border`,style:{height:Math.min(r,f)},children:[(0,V.jsx)(_Y,{height:Math.min(r,f),max:f}),x]})}function yY({list:e,error:t,terminals:n,shown:r,busy:i,popup:a,toggleKey:o,onPick:s,onStart:c,onEnd:l,onReload:u}){let d=(0,V.jsxs)(`div`,{className:`terminal-tools pointer-events-auto inline-flex items-center overflow-hidden rounded-md border border-border/80 bg-background shadow-xs`,children:[(0,V.jsx)(mY,{label:`New terminal`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`New terminal`,disabled:i||e?.available===!1,onClick:c,className:pY,children:(0,V.jsx)(Lm,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,V.jsx)(mY,{label:`End this terminal`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`End this terminal`,disabled:!r,onClick:()=>r&&l(r.id),className:pY,children:(0,V.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,V.jsx)(mY,{label:a?`Back to the drawer`:`Open in a pop-up`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Pop out terminal`,"aria-pressed":a,onClick:()=>aY(!a),className:pY,children:(0,V.jsx)(jm,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,V.jsx)(mY,{label:`Hide terminal`,hint:o,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Hide terminal`,onClick:()=>$J(!1),className:pY,children:a?(0,V.jsx)(Fh,{"aria-hidden":`true`,className:`size-3.5`}):(0,V.jsx)(Zf,{"aria-hidden":`true`,className:`size-3.5`})})})]}),f=(0,V.jsx)(V.Fragment,{children:e&&!e.available?(0,V.jsx)(`p`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:e.reason}):t?(0,V.jsx)(`p`,{role:`alert`,className:`flex h-full items-center justify-center px-6 text-center text-sm text-destructive`,children:t}):(0,V.jsxs)(m.Suspense,{fallback:(0,V.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`Loading the terminal…`}),children:[e&&n.length===0&&!i?(0,V.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`No terminal is running. Start one with New terminal.`}):null,n.map(e=>(0,V.jsx)(fY,{id:e.id,active:e.id===r?.id,toggleKey:o,onExit:u},e.id))]})}),p=n.length>1?(0,V.jsx)(`nav`,{"aria-label":`Terminals`,className:Y(`flex w-36 shrink-0 flex-col gap-0.5 overflow-y-auto border-l border-border px-1 pb-1`,a?`pt-2`:`pt-10`),children:n.map(e=>(0,V.jsxs)(`button`,{type:`button`,"aria-current":e.id===r?.id?`true`:void 0,onClick:()=>s(e.id),className:Y(`flex h-6 min-w-0 items-center gap-1.5 rounded px-1.5 text-left text-xs text-muted-foreground outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-accent aria-[current=true]:text-foreground`,!e.alive&&`opacity-60`),children:[(0,V.jsx)(lh,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.title}),e.alive?null:(0,V.jsx)(`span`,{className:`sr-only`,children:`, ended`})]},e.id))}):null;return a?(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,V.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border/70 pr-2 pl-4`,children:[(0,V.jsx)(lh,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`flex-1 text-sm font-medium`,children:`Terminal`}),d]}),(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,V.jsx)(`div`,{className:`min-w-0 flex-1 py-2 pl-2`,children:(0,V.jsx)(`div`,{className:`relative h-full`,children:f})}),p]})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[f,(0,V.jsx)(`div`,{className:`pointer-events-none absolute top-2 right-2 z-20`,children:d})]}),p]})}var bY=(0,m.lazy)(()=>dY(()=>import(`./CodeSurface-CUNGWpkc.js`),__vite__mapDeps([4,1,2]))),xY=`inline-flex size-7 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40 aria-pressed:bg-accent aria-pressed:text-foreground`;function SY({label:e,hint:t,children:n}){return(0,V.jsxs)(zI,{children:[(0,V.jsx)(BI,{asChild:!0,children:n}),(0,V.jsxs)(VI,{side:`bottom`,children:[e,` `,t?(0,V.jsx)(QT,{chord:t}):null]})]})}function CY({hint:e,className:t}){let{open:n}=OL();return(0,V.jsx)(SY,{label:`Code and changes`,hint:e,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Code`,"aria-pressed":n,"aria-keyshortcuts":e,onClick:()=>n?EL():TL(),className:t,children:(0,V.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M16 18l6-6-6-6M8 6l-6 6 6 6`})})})})}var wY={modified:{letter:`M`,word:`Modified`,tone:`text-warning`},added:{letter:`A`,word:`Added`,tone:`text-success`},untracked:{letter:`U`,word:`New, not committed`,tone:`text-success`},deleted:{letter:`D`,word:`Deleted`,tone:`text-destructive`},renamed:{letter:`R`,word:`Renamed`,tone:`text-primary`}};function TY(e){let t=e.lastIndexOf(`/`);return t<0?{dir:``,name:e}:{dir:e.slice(0,t),name:e.slice(t+1)}}function EY({change:e,className:t}){return e.additions===void 0&&e.deletions===void 0?null:(0,V.jsxs)(`span`,{className:Y(`shrink-0 font-mono text-[0.6875rem] tabular-nums`,t),children:[(0,V.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions??0]}),` `,(0,V.jsxs)(`span`,{className:`text-destructive`,children:[`−`,e.deletions??0]})]})}function DY(){let[e,t]=(0,m.useState)(()=>document.documentElement.classList.contains(`dark`));return(0,m.useEffect)(()=>{let e=document.documentElement,n=new MutationObserver(()=>t(e.classList.contains(`dark`)));return n.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>n.disconnect()},[]),e}function OY({changes:e,loading:t,error:n,current:r,onPick:i,onRefresh:a}){let[o,s]=(0,m.useState)(``),c=e?.files??[],l=c.reduce((e,t)=>({additions:e.additions+(t.additions??0),deletions:e.deletions+(t.deletions??0)}),{additions:0,deletions:0});function u(e){e.preventDefault();let t=o.trim();t&&(i(t),s(``))}return(0,V.jsxs)(`nav`,{"aria-label":`Changed files`,className:`code-rail flex w-64 shrink-0 flex-col border-r border-border max-md:w-52`,children:[(0,V.jsx)(`form`,{onSubmit:u,className:`border-b border-border p-2`,children:(0,V.jsxs)(`label`,{className:`flex h-8 items-center gap-2 rounded-md border border-input bg-background px-2 transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/20`,children:[(0,V.jsx)($m,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),"aria-label":`Open a file by path`,placeholder:`Open a file by path…`,spellCheck:!1,autoComplete:`off`,className:`h-full min-w-0 flex-1 bg-transparent font-mono text-xs outline-none placeholder:font-sans placeholder:text-muted-foreground`})]})}),(0,V.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 px-3 text-xs`,children:[(0,V.jsx)(`span`,{className:`font-medium text-foreground`,children:`Changes`}),(0,V.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[c.length,e?.truncated?`+`:``]}),(0,V.jsx)(EY,{change:l,className:`ml-auto`}),(0,V.jsx)(SY,{label:`Read the changes again`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Refresh changes`,onClick:a,disabled:t,className:Y(xY,`-mr-1.5 size-6`,c.length?``:`ml-auto`),children:(0,V.jsx)(zm,{"aria-hidden":`true`,className:Y(`size-3.5`,t&&`animate-spin motion-reduce:animate-none`)})})})]}),(0,V.jsxs)(`ul`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-1.5 pb-2`,children:[c.map(e=>{let{dir:t,name:n}=TY(e.path),a=wY[e.status];return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,onClick:()=>i(e.path),"aria-current":e.path===r?`true`:void 0,title:e.from?`${e.from} → ${e.path}`:e.path,className:`group/row flex h-7 w-full min-w-0 items-center gap-2 rounded-md px-1.5 text-left text-[0.8125rem] outline-none transition-colors duration-150 hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-accent`,children:[(0,V.jsx)(`span`,{"aria-label":a.word,className:Y(`w-3 shrink-0 text-center font-mono text-[0.6875rem] font-semibold`,a.tone),children:a.letter}),(0,V.jsxs)(`span`,{className:Y(`min-w-0 flex-1 truncate`,e.status===`deleted`&&`text-muted-foreground line-through decoration-muted-foreground/50`),children:[n,t?(0,V.jsx)(`span`,{className:`ml-1.5 text-xs text-muted-foreground`,children:t}):null]}),(0,V.jsx)(EY,{change:e})]})},e.path)}),e&&!e.git?(0,V.jsx)(`li`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:`This folder is not a git repository, so there are no changes to show. Open a file by its path above.`}):null,e?.git&&c.length===0?(0,V.jsx)(`li`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:`No changes since the last commit.`}):null,n?(0,V.jsx)(`li`,{role:`alert`,className:`px-2 py-3 text-xs text-destructive`,children:n}):null]})]})}function kY(e){let[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(!1),s=(0,m.useRef)(0),c=(0,m.useCallback)(async e=>{let t=++s.current;o(!0),i(void 0);try{let r=await L(`code.read`,{path:e});t===s.current&&n(e=>({file:r,version:(e?.version??0)+1}))}catch(e){t===s.current&&(n(void 0),i(e instanceof Error?e.message:String(e)))}finally{t===s.current&&o(!1)}},[]);return(0,m.useEffect)(()=>{e?c(e):(s.current++,n(void 0),i(void 0))},[e,c]),{loaded:t,setLoaded:n,error:r,loading:a,reload:()=>e&&c(e)}}function AY({requested:e,requestedMode:t,request:n,codeKey:r,onClose:i,onDirtyChange:a,closeAsked:o}){let s=_R(`code.changes`,{},[`lobby`,`tasks`]),[c,l]=(0,m.useState)(e),[u,d]=(0,m.useState)(t??`code`),{loaded:f,setLoaded:p,error:h,loading:g,reload:_}=kY(c),[v,y]=(0,m.useState)(),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(),E=FL(),D=IL(),O=DY(),k=f?.file,A=v!==void 0&&v!==k?.contents;(0,m.useEffect)(()=>a(A),[A,a]),(0,m.useEffect)(()=>{if(!e||e===c){t&&d(t);return}j({kind:`open`,path:e})},[n]),(0,m.useEffect)(()=>{if(!c&&s.data?.files[0]){let e=s.data.files.find(e=>e.status!==`deleted`)??s.data.files[0];l(e.path),t||d(`diff`)}},[s.data]),(0,m.useEffect)(()=>{k&&k.path!==c&&l(k.path)},[k?.path]),(0,m.useEffect)(()=>{o&&j({kind:`close`})},[o]);function ee(e){if(T(void 0),C(!1),e.kind===`close`){i();return}y(void 0),l(e.path)}function j(e){(e.kind!==`open`||e.path!==c)&&(A?T(e):ee(e))}async function M(e=!1){if(k&&v!==void 0&&!b){x(!0);try{let t=await L(`code.save`,{path:k.path,contents:v,mtimeMs:k.mtimeMs,...e?{force:!0}:{}});return p(e=>e&&{...e,file:{...e.file,contents:v,mtimeMs:t.mtimeMs,size:v.length}}),y(void 0),C(!1),s.reload(),w&&ee(w),!0}catch(e){return e instanceof xe&&e.code===`conflict`?C(!0):H.error(e instanceof Error?e.message:`The file could not be saved.`),!1}finally{x(!1)}}}function te(e){(e.ctrlKey||e.metaKey)&&!e.altKey&&e.key.toLowerCase()===`s`?(e.preventDefault(),e.stopPropagation(),M()):r&&lK(e.nativeEvent,r)&&(e.preventDefault(),j({kind:`close`}))}let ne=k?.change,N=!!ne||k?.original!==void 0,re=N?u:`code`,{dir:ie,name:ae}=TY(k?.path??c??``),oe=!!(k?.exists&&k.contents!==void 0),se=ne?wY[ne.status]:void 0;return(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1`,onKeyDown:te,children:[(0,V.jsx)(OY,{changes:s.data,loading:s.loading,error:s.error,current:k?.path??c,onPick:e=>j({kind:`open`,path:e}),onRefresh:()=>{s.reload(),A||_()}}),(0,V.jsxs)(`section`,{"aria-label":`File`,className:`flex min-w-0 flex-1 flex-col`,children:[(0,V.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border pr-2 pl-3`,children:[c?(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[se?(0,V.jsx)(`span`,{title:se.word,className:Y(`font-mono text-xs font-semibold`,se.tone),children:se.letter}):(0,V.jsx)(jp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,V.jsxs)(`h2`,{className:`min-w-0 truncate text-[0.8125rem]`,title:k?.path??c,children:[ie?(0,V.jsxs)(`span`,{className:`text-muted-foreground`,children:[ie,`/`]}):null,(0,V.jsx)(`span`,{className:`font-medium text-foreground`,children:ae}),A?(0,V.jsx)(`span`,{"aria-label":`unsaved`,title:`Unsaved edits`,className:`ml-1.5 inline-block size-1.5 -translate-y-0.5 rounded-full bg-foreground/70`}):null]}),ne?(0,V.jsx)(EY,{change:ne}):null]}):(0,V.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-muted-foreground`,children:`Code`}),N?(0,V.jsx)(ME,{label:`View`,value:re,onChange:d,items:[{id:`code`,label:`Code`},{id:`diff`,label:`Diff`}]}):null,re===`diff`?(0,V.jsx)(SY,{label:D===`split`?`Unified diff`:`Side by side`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Side by side`,"aria-pressed":D===`split`,onClick:()=>PL(D===`split`?`unified`:`split`),className:xY,children:D===`split`?(0,V.jsx)(Ym,{"aria-hidden":`true`,className:`size-4`}):(0,V.jsx)(xp,{"aria-hidden":`true`,className:`size-4`})})}):null,(0,V.jsx)(SY,{label:E?`Do not wrap lines`:`Wrap long lines`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Wrap lines`,"aria-pressed":E,onClick:()=>NL(!E),className:xY,children:(0,V.jsx)(_h,{"aria-hidden":`true`,className:`size-4`})})}),(0,V.jsx)(SY,{label:`Save`,hint:`Ctrl+S`,children:(0,V.jsxs)(WT,{size:`sm`,variant:A?`default`:`outline`,disabled:!A||b,onClick:()=>void M(),"aria-keyshortcuts":`Control+S Meta+S`,children:[(0,V.jsx)(Zm,{"aria-hidden":`true`}),b?`Saving…`:`Save`]})}),(0,V.jsx)(SY,{label:`Close`,hint:r,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Close code viewer`,onClick:()=>j({kind:`close`}),className:xY,children:(0,V.jsx)(Fh,{"aria-hidden":`true`,className:`size-4`})})})]}),w?(0,V.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-muted/40 px-3 py-2 text-xs`,children:[(0,V.jsx)(Dm,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[ae,` has unsaved edits.`]}),(0,V.jsx)(WT,{size:`xs`,variant:`ghost`,onClick:()=>T(void 0),children:`Keep editing`}),(0,V.jsx)(WT,{size:`xs`,variant:`outline`,onClick:()=>ee(w),children:`Discard`}),(0,V.jsx)(WT,{size:`xs`,onClick:()=>void M(),disabled:b,children:`Save`})]}):null,S?(0,V.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-muted/40 px-3 py-2 text-xs`,children:[(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[ae,` changed on disk since you opened it, maybe by an agent.`]}),(0,V.jsx)(WT,{size:`xs`,variant:`outline`,onClick:()=>{y(void 0),C(!1),_()},children:`Load theirs`}),(0,V.jsx)(WT,{size:`xs`,onClick:()=>void M(!0),disabled:b,children:`Overwrite with mine`})]}):null,(0,V.jsx)(`div`,{className:`code-pane relative flex min-h-0 flex-1 flex-col`,children:h?(0,V.jsx)(`p`,{role:`alert`,className:`m-auto max-w-sm px-6 text-center text-sm text-muted-foreground`,children:h}):c?k?k.binary||k.tooLarge?(0,V.jsx)(`p`,{className:`m-auto max-w-sm px-6 text-center text-sm text-muted-foreground`,children:k.binary?`This is a binary file, so it is not shown.`:`This file is too large to show here.`}):!k.exists&&re===`code`?(0,V.jsxs)(`p`,{className:`m-auto flex max-w-sm flex-col items-center gap-2 px-6 text-center text-sm text-muted-foreground`,children:[(0,V.jsx)(zp,{"aria-hidden":`true`,className:`size-5`}),`This file was deleted. Switch to Diff to see what it held.`]}):(0,V.jsx)(m.Suspense,{fallback:(0,V.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:`Loading code…`}),children:(0,V.jsx)(bY,{path:k.path,version:`${f.version}`,contents:k.contents??``,draft:v,original:k.original,mode:re,layout:D,wrap:E,dark:O,readOnly:!oe,onDraft:y})}):(0,V.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:g?`Opening…`:``}):(0,V.jsx)(jY,{loading:s.loading})})]})]})}function jY({loading:e}){return(0,V.jsxs)(`div`,{className:`m-auto flex max-w-xs flex-col items-center gap-2 px-6 text-center`,children:[(0,V.jsx)(Np,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e?`Reading the changes…`:`Pick a changed file, open one by its path, or click a file name in the Lobby chat.`})]})}function MY({codeKey:e}){let{open:t,path:n,mode:r,request:i}=OL(),a=lE(t,cE.help),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(0),u=()=>l(e=>e+1);return(0,V.jsx)(tE,{open:a,onOpenChange:e=>{e||(o?u():EL())},label:`Code viewer`,className:`code-pop h-[min(86svh,52rem)] max-h-none max-w-6xl`,onEscapeKeyDown:e=>{o&&(e.preventDefault(),u())},children:t?(0,V.jsx)(AY,{requested:n,requestedMode:r,request:i,codeKey:e,onClose:EL,onDirtyChange:s,closeAsked:c}):null})}function NY(e){let t=e.match(/[#&?]?token=([^&\s#]+)/i);if(t?.[1])return decodeURIComponent(t[1]);let n=e.trim();return n&&!n.includes(`/`)&&!n.includes(` `)?n:void 0}function PY(){let[e,t]=(0,m.useState)(``),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1);async function o(e){a(!0),r(void 0),e&&(window.location.hash=`token=${encodeURIComponent(e)}`),await we()?window.location.reload():(r(e?`That link did not sign in. Copy the link from Pi and try again.`:`Paste the link from Pi below.`),a(!1))}function s(t){t.preventDefault(),o(NY(e))}return(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-y-auto p-6`,children:(0,V.jsxs)(`form`,{onSubmit:s,className:`cs-dlg w-full max-w-[420px]`,children:[(0,V.jsxs)(`div`,{className:`cs-dh flex items-center gap-3.5 pt-[22px]`,children:[(0,V.jsx)(`span`,{className:`cs-drop`,"aria-hidden":`true`,children:(0,V.jsx)(Zp,{className:`size-[18px]`})}),(0,V.jsx)(`h1`,{children:`Sign in to bot-lobby`})]}),(0,V.jsxs)(`div`,{className:`cs-db`,children:[(0,V.jsxs)(`p`,{className:`mb-3.5 text-[12.5px] leading-relaxed text-muted-foreground`,children:[`Pi printed a link when it started (or run `,(0,V.jsx)(`code`,{className:`cs-cd`,children:`/bot-lobby web`}),` to see it again). Paste it here.`]}),(0,V.jsxs)(`label`,{children:[(0,V.jsx)(`span`,{children:`Lobby link or token`}),(0,V.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),autoComplete:`off`,spellCheck:!1,autoFocus:!0,placeholder:`http://127.0.0.1:7347/#token=…`,className:`cs-inp`})]}),n?(0,V.jsx)(`p`,{role:`alert`,className:`mt-2.5 text-[12.5px] text-[var(--bad)]`,children:n}):null]}),(0,V.jsxs)(`div`,{className:`cs-df`,children:[(0,V.jsx)(WT,{type:`button`,variant:`outline`,disabled:i,onClick:()=>void o(void 0),children:`Retry`}),(0,V.jsx)(WT,{type:`submit`,disabled:i||!e.trim(),children:`Sign in`})]})]})})}function FY({oracleBusy:e,runs:t,activity:n,background:r}){let i=new Set;e&&i.add(`Oracle`);for(let e of t)e.status===`running`&&i.add(zR(UR(e)));for(let e of n)e.pending&&e.source!==`LOBBY`&&i.add(e.source===`MASTER`?`Oracle`:zR(e.source));let a=r.filter(e=>e.alive&&e.busy).length;return a&&i.add(a===1?`1 in the background`:`${a} in the background`),[...i]}function IY(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}var LY=6,RY=`bot-lobby.orb`,zY=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=1;function BY(e,t,n,r){let i=e=>e+LY,a=(e,t)=>Math.max(e+LY,e+t-r-LY);return{x:Math.min(a(n.left,n.width),Math.max(i(n.left),e)),y:Math.min(a(n.top,n.height),Math.max(i(n.top),t))}}function VY(e,t,n,r){let i=e=>Math.max(1,e-r),a=BY(e,t,n,r);return{fx:Math.min(1,Math.max(0,(a.x-n.left)/i(n.width))),fy:Math.min(1,Math.max(0,(a.y-n.top)/i(n.height)))}}function HY(e,t,n){return BY(t.left+e.fx*Math.max(0,t.width-n),t.top+e.fy*Math.max(0,t.height-n),t,n)}function UY(e){if(e)try{let t=JSON.parse(e);return zY(t.fx)&&zY(t.fy)?{fx:t.fx,fy:t.fy}:void 0}catch{return}}function WY(){try{return UY(localStorage.getItem(RY))}catch{return}}function GY(e){try{localStorage.setItem(RY,JSON.stringify(e))}catch{}}var KY=5,qY=16;function JY(e){return{left:e.left,top:e.top,width:e.width,height:e.height}}function YY(){let e=document.getElementById(`main`)?.getBoundingClientRect();return e?JY(e):void 0}function XY(e,t){return!e||!t?e===t:e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function ZY(){let[e,t]=(0,m.useState)(()=>YY());return(0,m.useEffect)(()=>{let e=()=>{let e=YY();t(t=>XY(t,e)?t:e)},n=document.getElementById(`main`),r=document.getElementById(`app-dock`),i=typeof ResizeObserver>`u`?void 0:new ResizeObserver(e);n&&i?.observe(n),r&&i?.observe(r);let a=window.visualViewport;return window.addEventListener(`resize`,e),window.addEventListener(`orientationchange`,e),a?.addEventListener(`resize`,e),a?.addEventListener(`scroll`,e),e(),()=>{i?.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`orientationchange`,e),a?.removeEventListener(`resize`,e),a?.removeEventListener(`scroll`,e)}},[]),e}var QY=(0,m.forwardRef)(function({spotlight:e,thinking:t,busy:n=[],tone:r,expanded:i,hidden:a,shortcut:o,onOpen:s},c){let l=ZY(),[u,d]=(0,m.useState)(WY),[f,p]=(0,m.useState)(),[h,g]=(0,m.useState)(!1),_=(0,m.useRef)(void 0),v=(0,m.useRef)(!1),y=(0,m.useRef)(44),b=f??(u&&l?HY(u,l,y.current):void 0),x=(0,m.useCallback)((e,t)=>{let n=YY();if(!n)return;let r=VY(e,t,n,y.current);d(r),GY(r)},[]);(0,m.useEffect)(()=>{l&&p(e=>e&&BY(e.x,e.y,l,y.current))},[l]);function S(e){if(e.button!==0)return;let t=e.currentTarget.getBoundingClientRect();y.current=t.width,_.current={id:e.pointerId,sx:e.clientX,sy:e.clientY,ox:t.left,oy:t.top,moved:!1},e.currentTarget.setPointerCapture?.(e.pointerId)}function C(e){let t=_.current;if(!t||t.id!==e.pointerId)return;let n=e.clientX-t.sx,r=e.clientY-t.sy;if(!t.moved&&Math.hypot(n,r)<KY)return;t.moved=!0;let i=YY();i&&p(BY(t.ox+n,t.oy+r,i,y.current))}function w(e){let t=_.current;_.current=void 0,t?.moved&&(v.current=!0,x(t.ox+e.clientX-t.sx,t.oy+e.clientY-t.sy),p(void 0))}function T(e){let t=e.shiftKey?64:qY,n={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];if(!n||e.altKey||e.ctrlKey||e.metaKey)return;e.preventDefault();let r=e.currentTarget.getBoundingClientRect();y.current=r.width,x(r.left+n[0],r.top+n[1])}let E=!e&&n.length>0,D=e?zR(e):E?IY(n):void 0,O=n.length===1&&!n[0].includes(`background`)?n[0]:void 0,k=e??(E?O:void 0),A=e?`${t.map(zR).join(`, `)} thinking. `:E?`${n.join(`, `)} at work. `:``,ee=b&&l?b.x-l.left<140:!1,j={"--orb":r,...b?{left:b.x,top:b.y,right:`auto`,bottom:`auto`}:{}};return(0,V.jsxs)(zI,{open:h&&!f,onOpenChange:g,children:[(0,V.jsx)(BI,{asChild:!0,children:(0,V.jsxs)(`button`,{ref:c,type:`button`,"aria-label":`Open Thinking`,"aria-description":`${A}Drag, or use the arrow keys, to move it.`,"aria-haspopup":`dialog`,"aria-expanded":i,"aria-keyshortcuts":o?`${o} Enter Space`:`Enter Space`,onClick:e=>{if(v.current){v.current=!1,e.preventDefault();return}s()},onPointerDown:S,onPointerMove:C,onPointerUp:w,onPointerCancel:()=>{_.current=void 0,p(void 0)},onKeyDown:T,style:j,"data-thinking":e?``:void 0,"data-busy":E?``:void 0,"data-dragging":f?``:void 0,"data-placed":b?``:void 0,"data-flip":ee||void 0,className:Y(`thinking-bubble fixed z-20 touch-none rounded-full outline-none select-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,a&&`invisible`),children:[(0,V.jsx)(eu,{initial:!1,children:D?(0,V.jsx)(Yd.span,{className:`orb-label`,initial:{opacity:0,x:ee?-8:8,scale:.9},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:ee?-8:8,scale:.9},transition:{type:`spring`,visualDuration:.3,bounce:.35},children:(0,V.jsx)(eu,{mode:`popLayout`,initial:!1,children:(0,V.jsx)(Yd.span,{className:`inline-flex items-center gap-1`,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{type:`spring`,visualDuration:.28,bounce:.3},children:D},D)})},`label`):null}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`orb orb-float`,children:(0,V.jsx)(`span`,{className:`orb-icon`,children:(0,V.jsx)(IR,{source:k,strokeWidth:2.25,className:`size-3.5`})})})]})}),(0,V.jsxs)(VI,{side:`top`,children:[`Thinking `,o?(0,V.jsx)(QT,{chord:o}):null,(0,V.jsx)(`span`,{className:`text-background/70`,children:` · drag to move`})]})]})}),$Y=/^\s*(?:#{1,6}\s+(.+?)\s*#*|\*\*([^*\n]{2,90}?):?\*\*:?|__([^_\n]{2,90}?):?__:?)\s*$/,eX=260,tX=200,nX=/^\s*(?:[-*+]\s|\d+[.)]\s|>|```|~~~|\|)/m;function rX(e){let t=[],n=[],r=!1;for(let i of e){if(/^\s*(```|~~~)/.test(i)&&(r=!r),!r&&!i.trim()){n.length&&t.push(n.join(`
|
|
103
103
|
`).trim()),n=[];continue}n.push(i)}return n.length&&t.push(n.join(`
|
|
104
|
-
`).trim()),t.filter(Boolean)}function
|
|
104
|
+
`).trim()),t.filter(Boolean)}function iX(e){let t=e.split(/(?<=[.!?…])\s+(?=[A-Z"'“‘`(\[])/),n=[];for(let e of t){let t=n.at(-1);t!==void 0&&(t.split("`").length-1)%2==1?n[n.length-1]=`${t} ${e}`:n.push(e)}return n}function aX(e){if(e.length<=eX||nX.test(e))return[e];let t=[],n=``;for(let r of iX(e.replace(/\s*\n\s*/g,` `)))n&&n.length+r.length+1>tX?(t.push(n),n=r):n=n?`${n} ${r}`:r;return n&&t.push(n),t}function oX(e){let t=e.replace(/\r\n?/g,`
|
|
105
105
|
`).trim().split(`
|
|
106
|
-
`),n=[{lines:[]}],r=!1;for(let e of t){/^\s*(```|~~~)/.test(e)&&(r=!r);let t=r?null
|
|
106
|
+
`),n=[{lines:[]}],r=!1;for(let e of t){/^\s*(```|~~~)/.test(e)&&(r=!r);let t=r?null:$Y.exec(e),i=t?(t[1]??t[2]??t[3])?.trim():void 0;i?n.push({title:i,lines:[]}):n.at(-1).lines.push(e)}let i=[];for(let e of n){let t=rX(e.lines);if(e.title)i.push({title:e.title,text:t.join(`
|
|
107
107
|
|
|
108
|
-
`)});else for(let e of t)for(let t of
|
|
109
|
-
`)}function DX(){let e=_R(`planner.get`,{},[`planner`]),[t,n]=(0,m.useState)(wX),r=TX(e.data),i=(0,m.useMemo)(()=>r&&!t.includes(r.createdAt)?[r]:[],[r?.id,t.join(`,`)]);return{prompts:i,answer:(0,m.useCallback)(async(t,n)=>{let r=i.find(e=>e.id===t);r&&(await L(`planner.send`,{text:EX(r,n)}),e.reload())},[i,e]),dismiss:(0,m.useCallback)(async e=>{let t=Number(e.slice(5));n(e=>{let n=[...e,t].slice(-20);try{sessionStorage.setItem(SX,JSON.stringify(n))}catch{}return n})},[])}}var OX=2;function kX(e){let t=globalThis.EventSource;if(!t)throw Error(`EventSource is not available in this environment`);return new t(e)}function AX(e){try{return JSON.parse(e)}catch{return}}function jX(e,t){switch(e.type){case`hello`:t.onHello?.(e.versions);return;case`changed`:t.onChanged?.(e.topic,e.version);return;case`feed`:t.onFeed?.({activity:e.activity,thoughts:e.thoughts,chat:e.chat});return;case`reply`:t.onReply?.(e.text);return;case`notice`:t.onNotice?.(e.text,e.level)}}function MX(e,t=kX){let n=t(F(`/api/events`));return e.onConnection?.(`connecting`),n.onopen=()=>e.onConnection?.(`live`),n.onerror=()=>e.onConnection?.(n.readyState===OX?`offline`:`connecting`),n.onmessage=t=>{let n=AX(t.data);n&&jX(n,e)},()=>n.close()}var NX=2e3,PX=()=>L(`projects.list`,{});async function FX(){let e;try{e=pe()}catch{return}if(e&&!ye(e))try{ve((await PX()).projects)}catch{}}function IX(){let e=(0,m.useRef)(void 0),t=(0,m.useRef)(void 0),n=(0,m.useCallback)(()=>{clearTimeout(t.current),e.current?.();try{pe()}catch{P.onStatus({connection:`offline`});return}e.current=MX({onHello:e=>{P.onHello(e),FX()},onChanged:(e,t)=>P.onChanged(e,t),onFeed:e=>P.onFeedDelta(e),onReply:e=>P.onReplyDelta(e),onNotice:(e,t)=>H[t](e),onConnection:e=>{P.onStatus({connection:e}),e===`offline`&&(clearTimeout(t.current),t.current=setTimeout(()=>{be(PX).catch(()=>!1).finally(n)},NX))}})},[]);return(0,m.useEffect)(()=>(n(),()=>{clearTimeout(t.current),e.current?.()}),[n]),n}var LX=`bot-lobby.recoveredAt`,RX;function zX(e,t=BX()){try{RX===void 0&&(RX=Number(t?.getItem(LX)??0))}catch{RX??=0}if(RX!==void 0&&e<=RX)return!1;RX=e;try{t?.setItem(LX,String(e))}catch{}return!0}function BX(){try{return globalThis.sessionStorage}catch{return}}function VX(e){let t=e?.recovered?.at,n=e?.recovered?.text;(0,m.useEffect)(()=>{t!==void 0&&n&&zX(t)&&H.success(n)},[t,n])}function HX(){let e=FE(`prompts`),t=(0,m.useCallback)(async(e,t)=>{await L(`prompts.answer`,{id:e,answer:t})},[]),n=(0,m.useCallback)(async e=>{await L(`prompts.dismiss`,{id:e})},[]);return{prompts:e.data?.prompts??[],loading:e.loading,error:e.error,answer:t,dismiss:n}}function UX(e,t,n,r,i){e===`search`?(document.querySelector(`#main input[type='search']`)??document.getElementById(`composer-text`))?.focus():e===`help`?n():e===`settings`?bE(`#/settings`):e===`thinking`?hz(`lobby.thinking`):e===`sidebar`?i():e===`terminal`?aY():e===`code`?DL():e===`activity`?t.kind===`tab`&&t.tab===`lobby`?hz(_z):bE(yE(`lobby`)):e===`nextTab`?r(1):e===`prevTab`?r(-1):e===`savePlan`&&t.kind===`tab`&&t.tab===`plan`&&U(`planner.save`,{})}var WX=`cs-iconbtn cs-sq10`,GX=2500;function KX(e){let[t,n]=(0,m.useState)(!1),r=(0,m.useRef)(!1);return e===`live`&&(r.current=!0),(0,m.useEffect)(()=>{if(e!==`connecting`||!r.current)return n(!1);let t=setTimeout(()=>n(!0),GX);return()=>clearTimeout(t)},[e]),e===`offline`||e===`connecting`&&t}function qX({connection:e,onRetry:t}){return KX(e)?(0,V.jsx)(TE,{onRetry:t}):null}var JX={tick:0,route:0,focus:0};window.addEventListener(`hashchange`,()=>{JX.route=++JX.tick}),document.addEventListener(`focusin`,()=>{JX.focus=++JX.tick});var YX=()=>JX.focus>JX.route;function XX(e){return e.kind===`tab`?e.tab:e.kind}function ZX(){let e=xE(),t=FE(`status`),n=FE(`lobby`),{prompts:r,loading:i,answer:a,dismiss:o}=HX(),s=DX(),c=(0,m.useMemo)(()=>[...r,...s.prompts],[r,s.prompts]),l=Uq(c,(0,m.useCallback)((e,t)=>CX(e)?s.answer(e,t):a(e,t),[a,s.answer]),(0,m.useCallback)(e=>CX(e)?s.dismiss(e):o(e),[o,s.dismiss])),{connection:u,signedOut:d}=PE(),[f,p]=(0,m.useState)(!1),h=eJ();(0,m.useEffect)(()=>{c.length===0&&!i&&Qq(!1)},[c.length,i]);let g=(0,m.useRef)(null),_=IX();bB();let v=t.data;VX(v);let y=!!v&&!d;(0,m.useEffect)(()=>{y&&ze()},[y]);let b=v?.tabs??[],x=v?.keys??[],S=e.kind===`tab`?e.tab:void 0,C=(0,m.useCallback)(e=>bE(yE(e)),[]),w=(0,m.useCallback)(e=>{if(b.length===0)return;let t=Math.max(0,b.findIndex(e=>e.id===S)),n=b[(t+e+b.length)%b.length];n&&bE(yE(n.id))},[b,S]),T=(0,m.useCallback)(()=>p(e=>!e),[]),E=YK(),D=(0,m.useCallback)(()=>DJ(),[]),O=(0,m.useRef)(null),k=(0,m.useCallback)(t=>{(t!==`thinking`&&t!==`activity`||v?.panels?.[t]!==!1)&&((t===`nextTab`||t===`prevTab`)&&O.current?.(),UX(t,vE(window.location.hash)??e,T,w,D))},[e,T,w,D,v?.panels]),A=(0,m.useCallback)(e=>{O.current?.(),C(e)},[C]),ee=(0,m.useCallback)(()=>{let e=document.activeElement;return!e||e===document.body||g.current?.contains(e)===!0||e.closest(`.thinking-bubble, .terminal-pop`)?!0:e.closest(`[data-state='closed']`)!==null},[]);xK({enabled:!!v,keys:x,tabs:b,insideApp:ee,onAction:k,onTab:A});let j=(0,m.useCallback)(()=>P.onHello({}),[]),M=e.kind===`tab`?e.tab:e.kind,te=!!v;(0,m.useEffect)(()=>{if(!te)return;let e=GE.active&&GE.to===M;if(GE.active=!1,GE.to=void 0,e)return;let t=requestAnimationFrame(()=>{if(YX()||document.querySelector(`[role='dialog']:not([data-state='closed'])`))return;let e=document.getElementById(`composer-text`);!window.matchMedia(`(pointer: coarse)`).matches&&e&&!e.disabled&&!e.closest(`[inert]`)?e.focus({preventScroll:!0}):document.activeElement?.id!==`composer-text`&&document.getElementById(`main`)?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(t)},[M,te]);let ne=Object.fromEntries(x.map(e=>[e.action,e.label])),N=SJ({tabs:b,activeId:S,label:{id:`settings`,text:`Settings`},onSelect:C,flashRef:O}),re=UJ({route:e,keys:ne,onHelp:T});return d||!v?(0,V.jsxs)(`div`,{ref:g,className:`cs-frame`,children:[(0,V.jsx)(gJ,{}),(0,V.jsx)(`main`,{id:`main`,tabIndex:-1,className:`cs-main`,children:d?(0,V.jsx)(zY,{}):t.error?(0,V.jsx)(wE,{message:t.error,onRetry:j}):(0,V.jsx)(CE,{})}),(0,V.jsxs)(CJ,{children:[(0,V.jsx)(IK,{className:WX,side:`bottom`}),(0,V.jsx)(FK,{className:WX,side:`bottom`})]})]}):(0,V.jsxs)(`div`,{ref:g,className:`cs-frame`,"data-sb":re.open?`open`:`closed`,"data-tb":N.open?`open`:`closed`,children:[(0,V.jsx)(gJ,{}),(0,V.jsxs)(`div`,{className:`cs-body`,children:[(0,V.jsx)(qX,{connection:u,onRetry:_}),(0,V.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,V.jsx)(`main`,{id:`main`,tabIndex:-1,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||IE(e.target)||e.target.closest(`[role='dialog'], [role='menu'], [role='listbox']`)||WE()&&e.preventDefault()},role:S?`tabpanel`:void 0,"aria-labelledby":S?`tab-${S}`:void 0,className:`cs-main surface`,children:(0,V.jsx)(Yd.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.17,ease:[.22,1,.36,1]},className:`flex min-h-0 flex-1 flex-col`,children:cK(e)},XX(e))}),(0,V.jsx)(mJ,{route:e,projects:E,drawer:l,drawerOpen:c.length>0&&!h})]}),(0,V.jsx)(CY,{toggleKey:ne.terminal??"Ctrl+`"})]}),re.ghost,N.ghost,(0,V.jsxs)(CJ,{children:[(0,V.jsx)(OY,{hint:ne.code,className:WX}),(0,V.jsx)(bY,{hint:ne.terminal,className:WX})]}),re.bay,N.bay,(0,V.jsx)(ZK,{projects:E}),(0,V.jsx)(`span`,{id:`focused-action-help`,className:`sr-only`,children:`Focused buttons: Enter or Space. Links: Enter. Checkboxes: Space.`}),(0,V.jsx)(bX,{status:v,lobby:n.data}),(0,V.jsx)(LY,{codeKey:x.find(e=>e.action===`code`)?.key}),(0,V.jsx)(dL,{}),(0,V.jsx)(MK,{open:f,onOpenChange:p,keys:x,tabs:b})]})}async function QX(e){switch(e){case`status`:return L(`status.get`,{});case`lobby`:return L(`lobby.snapshot`,{});case`prompts`:return L(`prompts.list`,{});default:return}}var $X=[`status`,`lobby`,`prompts`];function eZ(){let[e,t]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{let e=!0;return(async()=>{await we(),e&&(P.markUsed($X,QX),t(!0))})(),()=>{e=!1}},[]),e}function tZ(){return eZ()?(0,V.jsx)(ZX,{}):(0,V.jsx)(`div`,{className:`fixed inset-0 flex`,children:(0,V.jsx)(CE,{})})}var nZ={info:Yp,success:sp,warning:xh,error:hp},rZ={info:`Note:`,success:`Done:`,warning:`Warning:`,error:`Error:`},iZ={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-destructive`};function aZ(){let{item:e,waiting:t}=ff(),n=dE(),r=e&&!n;return(0,m.useEffect)(()=>{if(!e||n)return;let r=window.setTimeout(()=>uf(e.id),t>0?Math.min(e.duration,1600):e.duration);return()=>window.clearTimeout(r)},[e,n,t]),(0,V.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`pointer-events-none fixed z-[1050] flex justify-center px-4`,style:{bottom:`calc(var(--composer-h, 0px) + var(--terminal-h, 0px) + 0.25rem)`,left:`var(--composer-x, 0px)`,width:`var(--composer-w, 100%)`},children:(0,V.jsx)(eu,{mode:`wait`,children:r?(0,V.jsxs)(Yd.div,{initial:{opacity:0,scale:.55,y:18},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.92,y:6,transition:{duration:.14,ease:`easeIn`}},transition:{type:`spring`,stiffness:560,damping:15,mass:.8},className:`pointer-events-auto flex max-w-[min(32rem,100%)] items-center gap-2.5 glass-toast rounded-lg px-3.5 py-2.5 text-sm`,children:[(0,V.jsx)(oZ,{kind:e.kind}),(0,V.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,V.jsxs)(`span`,{className:`sr-only`,children:[rZ[e.kind],` `]}),e.message]}),e.action?(0,V.jsx)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,className:`btn-outline -my-1.5 -mr-1 h-7 shrink-0 rounded-lg border px-2.5 text-xs font-medium text-foreground transition-[box-shadow,scale] active:scale-[0.97] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,onClick:()=>{e.action?.onClick(),uf(e.id)},children:e.action.label}):null]},e.id):null})})}function oZ({kind:e}){let t=nZ[e];return(0,V.jsx)(t,{"aria-hidden":`true`,className:Y(`size-4 shrink-0`,iZ[e])})}(0,tf.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(m.StrictMode,{children:(0,V.jsx)($B,{children:(0,V.jsx)(su,{reducedMotion:`user`,children:(0,V.jsxs)(RI,{children:[(0,V.jsx)(tZ,{}),(0,V.jsx)(aZ,{})]})})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{updateViaCache:`none`}).catch(()=>void 0)});export{F as i,mK as n,L as r,gY as t};
|
|
108
|
+
`)});else for(let e of t)for(let t of aX(e))i.push({text:t})}return i}var sX=4,cX=1800,lX=e=>({"--orb":e});function uX(e){let[t,n]=(0,m.useState)(0),r=e.join(`|`);return(0,m.useEffect)(()=>{if(n(0),e.length<2)return;let t=window.setInterval(()=>n(e=>e+1),cX);return()=>window.clearInterval(t)},[r,e.length]),e.length?e[t%e.length]:void 0}function dX({thought:e}){let t=(0,m.useMemo)(()=>oX(e.text),[e.text]),[n,r]=(0,m.useState)(!1),i=n?0:Math.max(0,t.length-sX),a=t.slice(i),o=zR(e.source);return(0,V.jsxs)(`li`,{className:`thought`,style:lX(HR(e.source)),"data-live":e.live||void 0,"aria-label":`${o}${e.live?`, thinking`:``}`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsxs)(`span`,{className:`thought-label`,children:[(0,V.jsx)(IR,{source:e.source,strokeWidth:2.25,className:`size-3.5`}),o]}),(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.live?(0,V.jsxs)(`span`,{className:`thought-live`,children:[`thinking`,(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`thought-ellipsis`})]}):oz(Date.now()-e.at)}),t.length>1?(0,V.jsxs)(`span`,{className:`ml-auto text-xs text-muted-foreground tabular-nums`,children:[t.length,` steps`]}):null]}),i?(0,V.jsxs)(`button`,{type:`button`,"data-compact":!0,className:`thought-more`,onClick:()=>r(!0),children:[i,` earlier `,i===1?`step`:`steps`]}):null,(0,V.jsx)(`ol`,{className:`thought-steps`,"data-single":a.length===1||void 0,children:a.map((t,n)=>(0,V.jsxs)(`li`,{"data-current":e.live&&n===a.length-1||void 0,children:[t.title?(0,V.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t.title}):null,t.text?(0,V.jsx)(QL,{text:t.text,className:`thought-text`}):null]},i+n))})]})}function fX(e,t,n){(0,m.useEffect)(()=>{if(!e||!t)return;let r=e=>{e.defaultPrevented||e.isComposing||!lK(e,t)||e.target?.closest(`input, textarea, [contenteditable='true']`)||(e.preventDefault(),n())};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,t,n])}function pX(e){return[...e].sort((e,t)=>Number(t.live)-Number(e.live)||t.at-e.at||t.id-e.id)}function mX({thoughts:e,collapsed:t,onToggle:n,shortcut:r,busy:i=[]}){let a=pX(GR(e)),o=a.filter(e=>e.live).map(e=>e.source),s=uX(o),c=s?HR(s):i.length?`var(--primary)`:`var(--orb-idle)`,l=s?`thinking`:i.length?`busy`:void 0,u=(0,m.useRef)(null),d=(0,m.useRef)(null),f=(0,m.useRef)(t);f.current=t,(0,m.useEffect)(()=>()=>{f.current||n()},[n]);let p=lE(!t,cE.sheet),h=dE();fX(p,r,n);let g=a.length>0||i.length>0;return(0,V.jsxs)(V.Fragment,{children:[g&&(0,z_.createPortal)((0,V.jsx)(QY,{ref:u,spotlight:s,thinking:o,busy:i,tone:c,expanded:!t,hidden:h,shortcut:r,onOpen:n}),document.body),(0,V.jsxs)(tE,{open:p,onOpenChange:e=>{!e&&!t&&n()},label:`Thinking`,className:Y(`thought-pane max-w-xl`,l&&`thought-pane-live`),style:lX(c),onCloseAutoFocus:e=>{e.preventDefault(),requestAnimationFrame(()=>{document.querySelector(`[role='dialog']`)||u.current?.focus()})},children:[(0,V.jsx)(`div`,{"aria-hidden":`true`,className:`thought-aura`,"data-working":l}),(0,V.jsx)(`div`,{ref:d,className:`relative min-h-0 overflow-y-auto p-4 outline-none`,role:`log`,"aria-label":`Latest thoughts`,tabIndex:0,children:a.length?(0,V.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:a.map(e=>(0,V.jsx)(dX,{thought:e},e.id))}):(0,V.jsx)(`p`,{className:`px-2 py-6 text-center text-sm text-muted-foreground`,children:`Thoughts from the oracle and every agent appear here, and only here.`})}),(0,V.jsx)(m_,{target:d})]})]})}function hX({status:e,lobby:t}){let[n,r]=gz(`lobby.thinking`),i=_R(`sessions.list`,{},[`sessions`]);if(!e||e.panels?.thinking===!1)return null;let a=FY({oracleBusy:e.busy,runs:WR(t),activity:t?.activity??[],background:i.data?.background??[]}),o=e.keys.find(e=>e.action===`thinking`)?.label;return(0,V.jsx)(mX,{thoughts:t?.thoughts??[],collapsed:n,onToggle:r,shortcut:o,busy:a})}var gX=`plan:`,_X=`bot-lobby:plan-put-away`,vX=e=>e.startsWith(gX);function yX(){try{let e=JSON.parse(sessionStorage.getItem(_X)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`number`):[]}catch{return[]}}function bX(e){let t=e?.messages.at(-1);if(e&&!e.busy&&t?.role===`planner`&&t.questions?.length)return{id:`${gX}${t.at}`,kind:`questionnaire`,createdAt:t.at,from:`planner`,payload:{round:Math.max(e.round,1),limit:e.limit,questions:t.questions.map(e=>({question:e.text,header:e.from,options:e.options.map(e=>({label:e.label,description:e.description,...e.mockup?{htmlPreview:e.mockup}:{}}))}))}}}function xX(e,t){let n=e.payload.questions??[];return(t.answers??[]).map(e=>`${zR(n[e.questionIndex]?.header??``)}: ${e.question} ${e.answer}`.trim()).join(`
|
|
109
|
+
`)}function SX(){let e=_R(`planner.get`,{},[`planner`]),[t,n]=(0,m.useState)(yX),r=bX(e.data),i=(0,m.useMemo)(()=>r&&!t.includes(r.createdAt)?[r]:[],[r?.id,t.join(`,`)]);return{prompts:i,answer:(0,m.useCallback)(async(t,n)=>{let r=i.find(e=>e.id===t);r&&(await L(`planner.send`,{text:xX(r,n)}),e.reload())},[i,e]),dismiss:(0,m.useCallback)(async e=>{let t=Number(e.slice(5));n(e=>{let n=[...e,t].slice(-20);try{sessionStorage.setItem(_X,JSON.stringify(n))}catch{}return n})},[])}}var CX=2;function wX(e){let t=globalThis.EventSource;if(!t)throw Error(`EventSource is not available in this environment`);return new t(e)}function TX(e){try{return JSON.parse(e)}catch{return}}function EX(e,t){switch(e.type){case`hello`:t.onHello?.(e.versions);return;case`changed`:t.onChanged?.(e.topic,e.version);return;case`feed`:t.onFeed?.({activity:e.activity,thoughts:e.thoughts,chat:e.chat});return;case`reply`:t.onReply?.(e.text);return;case`notice`:t.onNotice?.(e.text,e.level)}}function DX(e,t=wX){let n=t(F(`/api/events`));return e.onConnection?.(`connecting`),n.onopen=()=>e.onConnection?.(`live`),n.onerror=()=>e.onConnection?.(n.readyState===CX?`offline`:`connecting`),n.onmessage=t=>{let n=TX(t.data);n&&EX(n,e)},()=>n.close()}var OX=2e3,kX=()=>L(`projects.list`,{});async function AX(){let e;try{e=pe()}catch{return}if(e&&!ye(e))try{ve((await kX()).projects)}catch{}}function jX(){let e=(0,m.useRef)(void 0),t=(0,m.useRef)(void 0),n=(0,m.useCallback)(()=>{clearTimeout(t.current),e.current?.();try{pe()}catch{P.onStatus({connection:`offline`});return}e.current=DX({onHello:e=>{P.onHello(e),AX()},onChanged:(e,t)=>P.onChanged(e,t),onFeed:e=>P.onFeedDelta(e),onReply:e=>P.onReplyDelta(e),onNotice:(e,t)=>H[t](e),onConnection:e=>{P.onStatus({connection:e}),e===`offline`&&(clearTimeout(t.current),t.current=setTimeout(()=>{be(kX).catch(()=>!1).finally(n)},OX))}})},[]);return(0,m.useEffect)(()=>(n(),()=>{clearTimeout(t.current),e.current?.()}),[n]),n}var MX=`bot-lobby.recoveredAt`,NX;function PX(e,t=FX()){try{NX===void 0&&(NX=Number(t?.getItem(MX)??0))}catch{NX??=0}if(NX!==void 0&&e<=NX)return!1;NX=e;try{t?.setItem(MX,String(e))}catch{}return!0}function FX(){try{return globalThis.sessionStorage}catch{return}}function IX(e){let t=e?.recovered?.at,n=e?.recovered?.text;(0,m.useEffect)(()=>{t!==void 0&&n&&PX(t)&&H.success(n)},[t,n])}function LX(){let e=FE(`prompts`),t=(0,m.useCallback)(async(e,t)=>{await L(`prompts.answer`,{id:e,answer:t})},[]),n=(0,m.useCallback)(async e=>{await L(`prompts.dismiss`,{id:e})},[]);return{prompts:e.data?.prompts??[],loading:e.loading,error:e.error,answer:t,dismiss:n}}function RX(e,t,n,r,i){e===`search`?(document.querySelector(`#main input[type='search']`)??document.getElementById(`composer-text`))?.focus():e===`help`?n():e===`settings`?bE(`#/settings`):e===`thinking`?hz(`lobby.thinking`):e===`sidebar`?i():e===`terminal`?eY():e===`code`?DL():e===`activity`?t.kind===`tab`&&t.tab===`lobby`?hz(_z):bE(yE(`lobby`)):e===`nextTab`?r(1):e===`prevTab`?r(-1):e===`savePlan`&&t.kind===`tab`&&t.tab===`plan`&&U(`planner.save`,{})}var zX=`cs-iconbtn cs-sq10`,BX=2500;function VX(e){let[t,n]=(0,m.useState)(!1),r=(0,m.useRef)(!1);return e===`live`&&(r.current=!0),(0,m.useEffect)(()=>{if(e!==`connecting`||!r.current)return n(!1);let t=setTimeout(()=>n(!0),BX);return()=>clearTimeout(t)},[e]),e===`offline`||e===`connecting`&&t}function HX({connection:e,onRetry:t}){return VX(e)?(0,V.jsx)(TE,{onRetry:t}):null}var UX={tick:0,route:0,focus:0};window.addEventListener(`hashchange`,()=>{UX.route=++UX.tick}),document.addEventListener(`focusin`,()=>{UX.focus=++UX.tick});var WX=()=>UX.focus>UX.route;function GX(e){return e.kind===`tab`?e.tab:e.kind}function KX(){let e=xE(),t=FE(`status`),n=FE(`lobby`),{prompts:r,loading:i,answer:a,dismiss:o}=LX(),s=SX(),c=(0,m.useMemo)(()=>[...r,...s.prompts],[r,s.prompts]),l=Rq(c,(0,m.useCallback)((e,t)=>vX(e)?s.answer(e,t):a(e,t),[a,s.answer]),(0,m.useCallback)(e=>vX(e)?s.dismiss(e):o(e),[o,s.dismiss])),{connection:u,signedOut:d}=PE(),[f,p]=(0,m.useState)(!1),h=Yq();(0,m.useEffect)(()=>{c.length===0&&!i&&qq(!1)},[c.length,i]);let g=(0,m.useRef)(null),_=jX();bB();let v=t.data;IX(v);let y=!!v&&!d;(0,m.useEffect)(()=>{y&&ze()},[y]);let b=v?.tabs??[],x=v?.keys??[],S=e.kind===`tab`?e.tab:void 0,C=(0,m.useCallback)(e=>bE(yE(e)),[]),w=(0,m.useCallback)(e=>{if(b.length===0)return;let t=Math.max(0,b.findIndex(e=>e.id===S)),n=b[(t+e+b.length)%b.length];n&&bE(yE(n.id))},[b,S]),T=(0,m.useCallback)(()=>p(e=>!e),[]),E=WK(),D=(0,m.useCallback)(()=>SJ(),[]),O=(0,m.useRef)(null),k=(0,m.useCallback)(t=>{(t!==`thinking`&&t!==`activity`||v?.panels?.[t]!==!1)&&((t===`nextTab`||t===`prevTab`)&&O.current?.(),RX(t,vE(window.location.hash)??e,T,w,D))},[e,T,w,D,v?.panels]),A=(0,m.useCallback)(e=>{O.current?.(),C(e)},[C]),ee=(0,m.useCallback)(()=>{let e=document.activeElement;return!e||e===document.body||g.current?.contains(e)===!0||e.closest(`.thinking-bubble, .terminal-pop`)?!0:e.closest(`[data-state='closed']`)!==null},[]);gK({enabled:!!v,keys:x,tabs:b,insideApp:ee,onAction:k,onTab:A});let j=(0,m.useCallback)(()=>P.onHello({}),[]),M=e.kind===`tab`?e.tab:e.kind,te=!!v;(0,m.useEffect)(()=>{if(!te)return;let e=GE.active&&GE.to===M;if(GE.active=!1,GE.to=void 0,e)return;let t=requestAnimationFrame(()=>{if(WX()||document.querySelector(`[role='dialog']:not([data-state='closed'])`))return;let e=document.getElementById(`composer-text`);!window.matchMedia(`(pointer: coarse)`).matches&&e&&!e.disabled&&!e.closest(`[inert]`)?e.focus({preventScroll:!0}):document.activeElement?.id!==`composer-text`&&document.getElementById(`main`)?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(t)},[M,te]);let ne=Object.fromEntries(x.map(e=>[e.action,e.label])),N=_J({tabs:b,activeId:S,label:{id:`settings`,text:`Settings`},onSelect:C,flashRef:O}),re=RJ({route:e,keys:ne,onHelp:T});return d||!v?(0,V.jsxs)(`div`,{ref:g,className:`cs-frame`,children:[(0,V.jsx)(dJ,{}),(0,V.jsx)(`main`,{id:`main`,tabIndex:-1,className:`cs-main`,children:d?(0,V.jsx)(PY,{}):t.error?(0,V.jsx)(wE,{message:t.error,onRetry:j}):(0,V.jsx)(CE,{})}),(0,V.jsxs)(vJ,{children:[(0,V.jsx)(jK,{className:zX,side:`bottom`}),(0,V.jsx)(AK,{className:zX,side:`bottom`})]})]}):(0,V.jsxs)(`div`,{ref:g,className:`cs-frame`,"data-sb":re.open?`open`:`closed`,"data-tb":N.open?`open`:`closed`,children:[(0,V.jsx)(dJ,{}),(0,V.jsxs)(`div`,{className:`cs-body`,children:[(0,V.jsx)(HX,{connection:u,onRetry:_}),(0,V.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,V.jsx)(`main`,{id:`main`,tabIndex:-1,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||IE(e.target)||e.target.closest(`[role='dialog'], [role='menu'], [role='listbox']`)||WE()&&e.preventDefault()},role:S?`tabpanel`:void 0,"aria-labelledby":S?`tab-${S}`:void 0,className:`cs-main surface`,children:(0,V.jsx)(Yd.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.17,ease:[.22,1,.36,1]},className:`flex min-h-0 flex-1 flex-col`,children:rK(e)},GX(e))}),(0,V.jsx)(lJ,{route:e,projects:E,drawer:l,drawerOpen:c.length>0&&!h})]}),(0,V.jsx)(vY,{toggleKey:ne.terminal??"Ctrl+`"})]}),re.ghost,N.ghost,(0,V.jsxs)(vJ,{children:[(0,V.jsx)(CY,{hint:ne.code,className:zX}),(0,V.jsx)(hY,{hint:ne.terminal,className:zX})]}),re.bay,N.bay,(0,V.jsx)(KK,{projects:E}),(0,V.jsx)(`span`,{id:`focused-action-help`,className:`sr-only`,children:`Focused buttons: Enter or Space. Links: Enter. Checkboxes: Space.`}),(0,V.jsx)(hX,{status:v,lobby:n.data}),(0,V.jsx)(MY,{codeKey:x.find(e=>e.action===`code`)?.key}),(0,V.jsx)(dL,{}),(0,V.jsx)(DK,{open:f,onOpenChange:p,keys:x,tabs:b})]})}async function qX(e){switch(e){case`status`:return L(`status.get`,{});case`lobby`:return L(`lobby.snapshot`,{});case`prompts`:return L(`prompts.list`,{});default:return}}var JX=[`status`,`lobby`,`prompts`];function YX(){let[e,t]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{let e=!0;return(async()=>{await we(),e&&(P.markUsed(JX,qX),t(!0))})(),()=>{e=!1}},[]),e}function XX(){return YX()?(0,V.jsx)(KX,{}):(0,V.jsx)(`div`,{className:`fixed inset-0 flex`,children:(0,V.jsx)(CE,{})})}var ZX={info:Yp,success:sp,warning:xh,error:hp},QX={info:`Note:`,success:`Done:`,warning:`Warning:`,error:`Error:`},$X={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-destructive`};function eZ(){let{item:e,waiting:t}=ff(),n=dE(),r=e&&!n;return(0,m.useEffect)(()=>{if(!e||n)return;let r=window.setTimeout(()=>uf(e.id),t>0?Math.min(e.duration,1600):e.duration);return()=>window.clearTimeout(r)},[e,n,t]),(0,V.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`pointer-events-none fixed z-[1050] flex justify-center px-4`,style:{bottom:`calc(var(--composer-h, 0px) + var(--terminal-h, 0px) + 0.25rem)`,left:`var(--composer-x, 0px)`,width:`var(--composer-w, 100%)`},children:(0,V.jsx)(eu,{mode:`wait`,children:r?(0,V.jsxs)(Yd.div,{initial:{opacity:0,scale:.55,y:18},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.92,y:6,transition:{duration:.14,ease:`easeIn`}},transition:{type:`spring`,stiffness:560,damping:15,mass:.8},className:`pointer-events-auto flex max-w-[min(32rem,100%)] items-center gap-2.5 glass-toast rounded-lg px-3.5 py-2.5 text-sm`,children:[(0,V.jsx)(tZ,{kind:e.kind}),(0,V.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,V.jsxs)(`span`,{className:`sr-only`,children:[QX[e.kind],` `]}),e.message]}),e.action?(0,V.jsx)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,className:`btn-outline -my-1.5 -mr-1 h-7 shrink-0 rounded-lg border px-2.5 text-xs font-medium text-foreground transition-[box-shadow,scale] active:scale-[0.97] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,onClick:()=>{e.action?.onClick(),uf(e.id)},children:e.action.label}):null]},e.id):null})})}function tZ({kind:e}){let t=ZX[e];return(0,V.jsx)(t,{"aria-hidden":`true`,className:Y(`size-4 shrink-0`,$X[e])})}(0,tf.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(m.StrictMode,{children:(0,V.jsx)($B,{children:(0,V.jsx)(su,{reducedMotion:`user`,children:(0,V.jsxs)(RI,{children:[(0,V.jsx)(XX,{}),(0,V.jsx)(eZ,{})]})})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{updateViaCache:`none`}).catch(()=>void 0)});export{F as i,lK as n,L as r,dY as t};
|