@a-t-h-i/bot-lobby 0.6.62 → 0.6.64
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/README.md +5 -1
- package/package.json +1 -1
- package/src/lobby/host.ts +1 -0
- package/src/lobby/pi-commands.ts +83 -0
- package/src/lobby/service.ts +3 -4
- package/src/webui/api/status.ts +1 -0
- package/src/webui/dev/fake-service.ts +8 -0
- package/src/webui/protocol.ts +1 -0
- package/webui/dist/assets/{CodeSurface-D3c12DBE.js → CodeSurface-CdyiJTYa.js} +1 -1
- package/webui/dist/assets/{TerminalView-DG4X3Yyr.js → TerminalView-D2nbR2J1.js} +1 -1
- package/webui/dist/assets/{index-BDmgr1OS.js → index-BUGK22Z6.js} +12 -12
- package/webui/dist/build.json +9 -9
- package/webui/dist/index.html +1 -1
|
@@ -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-D2nbR2J1.js","assets/rolldown-runtime-hePW80VL.js","assets/ccount-DQxSH8e6.js","assets/TerminalView-BrP-ENHg.css","assets/CodeSurface-CdyiJTYa.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 N(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 P(e){let t=[];return e.light&&t.push(N(`:root`,e.light)),e.dark&&t.push(N(`.dark`,e.dark)),t.join(`
|
|
3
3
|
`)}var ne=`mist`,re=[{id:ne,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`}}],ie={light:{background:`#fcfcfc`,card:`#ffffff`,primary:`#1b4ed8`,accent:`#f4f4f5`},dark:{background:`#0a0a0a`,card:`#111111`,primary:`#346bf1`,accent:`#141414`}};function ae(e,t){let n=t?e.dark:e.light,r=ie[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 oe={activity:400,thoughts:40,chat:100};function se(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 ce=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:se(t.activity,e.activity??[],oe.activity),thoughts:se(t.thoughts,e.thoughts??[],oe.thoughts),chat:se(t.chat,e.chat??[],oe.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 le(){return new ce}var F=le(),ue=/^[a-f0-9]{32}$/;function de(){return globalThis.location}function fe(){let e=de()?.search??``,t=new URLSearchParams(e).getAll(`project`);if(t.length){if(t.length!==1||!ue.test(t[0]))throw Error(`Invalid project ID. Choose a running project below.`);return t[0]}}function I(e){if(!e.startsWith(`/api/`)&&!e.startsWith(`/files/preview/`))return e;let t=fe();return t?`/projects/${t}${e}`:e}function L(e,t){if(!ue.test(e))throw Error(`Invalid project ID.`);let n=de();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 pe=`bot-lobby.projectFolders`,me=new Map;function he(){try{return globalThis.sessionStorage}catch{return}}function ge(){try{let e=JSON.parse(he()?.getItem(pe)??`{}`);for(let[t,n]of Object.entries(e))ue.test(t)&&typeof n==`string`&&me.set(t,n)}catch{}}function _e(e){ge();for(let t of e)ue.test(t.id)&&me.set(t.id,t.cwd);try{he()?.setItem(pe,JSON.stringify(Object.fromEntries([...me].slice(-64))))}catch{}}function ve(e){return me.has(e)||ge(),me.get(e)}async function ye(e){let t;try{t=fe()}catch{return!1}if(!t)return!1;let n=ve(t);if(!n)return!1;let{projects:r}=await e();if(_e(r),r.some(e=>e.id===t))return!1;let i=r.find(e=>e.cwd===n),a=de(),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 be=class extends Error{code;status;constructor(e,t,n){super(e),this.name=`ApiError`,this.code=t,this.status=n}},xe={"Content-Type":`application/json`};async function R(e,t={}){let n=await fetch(e===`auth.login`||e.startsWith(`projects.`)?`/api/${e}`:I(`/api/${e}`),{method:`POST`,headers:xe,body:JSON.stringify(t),credentials:`same-origin`}),r=await n.json().catch(()=>void 0);if(!r)throw new be(`the lobby answered ${n.status}`,`failed`,n.status);if(!r.ok)throw r.code===`unauthorized`&&F.onStatus({signedOut:!0}),new be(r.error,r.code,n.status);return r.result}function Se(){return globalThis.location}async function Ce(){let e=Se(),t=e?new URLSearchParams(e.hash.replace(/^#/,``)).get(`token`):null;if(!t||!(await fetch(`/api/auth.login`,{method:`POST`,headers:xe,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),F.onStatus({signedOut:!1}),!0}var we=`bot-lobby.palette`,Te=`bot-lobby-palette`,Ee=`custom`,De=new Set,Oe=Ae();function ke(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 Ae(){try{let e=localStorage.getItem(we);if(!e)return{id:ne,saved:[]};let t=JSON.parse(e),n=(t.saved??[]).map(ke).filter(e=>!!e),r=ke(t.legacy??(t.custom?{...t.custom,id:Ee}:void 0)),i=new Set([...re.map(e=>e.id),...n.map(e=>e.id),...r?[Ee]:[]]);return{id:t.id&&i.has(t.id)?t.id:ne,saved:n,...r?{legacy:r}:{}}}catch{return{id:ne,saved:[]}}}function je(e){return[...re,...e.saved,...e.legacy?[e.legacy]:[]]}function Me(e){return je(e).find(t=>t.id===e.id)??re[0]}function Ne(){if(typeof document>`u`)return;let e=P(Me(Oe)),t=document.getElementById(Te);if(!e){t?.remove();return}t||(t=document.createElement(`style`),t.id=Te,document.head.appendChild(t)),t.textContent=e}function Pe(e){Oe=e;try{localStorage.setItem(we,JSON.stringify(e))}catch{}Ne();for(let e of[...De])e()}function Fe(e){let t=e.themes.map(e=>ke(e)).filter(e=>!!e),{legacy:n}=Oe;Pe({id:e.active??(Oe.id===Ee&&n?Ee:`mist`),saved:t,...n?{legacy:n}:{}})}var Ie;function Le(e=!1){return Ie&&!e||(Ie=(async()=>{let e=await R(`themes.get`,{}),t=Oe.legacy;if(t){let n=e.active??(Oe.id===Ee?void 0:Oe.id);e=await R(`themes.save`,{name:t.name,...t.light?{light:t.light}:{},...t.dark?{dark:t.dark}:{}}),n&&(e=await R(`themes.choose`,{id:n}));let{legacy:r,...i}=Oe;Oe=i}Fe(e)})().catch(()=>{Ie=void 0})),Ie}typeof window<`u`&&(Ne(),window.addEventListener(`storage`,e=>{if(e.key===we){Oe=Ae(),Ne();for(let e of[...De])e()}}),window.addEventListener(`focus`,()=>void Le(!0)));function Re(e){return De.add(e),()=>{De.delete(e)}}function ze(){let e=(0,m.useSyncExternalStore)(Re,()=>Oe,()=>Oe),t=(0,m.useCallback)(e=>{Pe({...Oe,id:e}),e!==Ee&&R(`themes.choose`,{id:e}).then(Fe,()=>{})},[]),n=(0,m.useCallback)(async(e,t)=>(Fe(await R(`themes.save`,{name:t,...e.light?{light:e.light}:{},...e.dark?{dark:e.dark}:{}})),Me(Oe)),[]),r=(0,m.useCallback)(async(e,t)=>Fe(await R(`themes.rename`,{id:e,name:t})),[]),i=(0,m.useCallback)(async e=>Fe(await R(`themes.remove`,{id:e})),[]),a=e.legacy?[...e.saved,e.legacy]:e.saved;return{active:Me(e),saved:a,all:je(e),isSaved:e=>a.some(t=>t.id===e),choose:t,adopt:n,rename:r,remove:i}}var Be=[{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`}],Ve=[{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`}],He={font:`bot-lobby.typeface`,mono:`bot-lobby.typeface-code`},Ue={font:Be,mono:Ve},We={font:`theme`,mono:`theme`},Ge=new Set;function Ke(e){let t=null;try{t=localStorage.getItem(He[e])}catch{t=We[e]}return Ue[e].some(e=>e.id===t)?t:`theme`}function qe(e,t){let n=document.documentElement;t===`theme`?delete n.dataset[e]:n.dataset[e]=t}function Je(e,t){We[e]=t;try{localStorage.setItem(He[e],t)}catch{}qe(e,t);for(let e of Ge)e()}function Ye(e){return Ge.add(e),()=>Ge.delete(e)}function Xe(e){return(0,m.useSyncExternalStore)(Ye,()=>Ke(e),()=>`theme`)}typeof document<`u`&&(qe(`font`,Ke(`font`)),qe(`mono`,Ke(`mono`)));var Ze={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`},Qe=(0,m.createContext)({});function $e(e){let t=(0,m.useRef)(null);return t.current===null&&(t.current=e()),t.current}var et=typeof window<`u`?m.useLayoutEffect:m.useEffect,tt=(0,m.createContext)(null);function nt(e,t){e.indexOf(t)===-1&&e.push(t)}function rt(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var it=(e,t,n)=>n>t?t:n<e?e:n,at={},ot=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),st=e=>typeof e==`object`&&!!e,ct=e=>/^0[^.\s]+$/u.test(e);function lt(e){let t;return()=>(t===void 0&&(t=e()),t)}var ut=e=>e,dt=(...e)=>e.reduce((e,t)=>n=>t(e(n))),ft=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},pt=class{constructor(){this.subscriptions=[]}add(e){return nt(this.subscriptions,e),()=>this.remove(e)}remove(e){rt(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}},mt=e=>e*1e3,ht=e=>e/1e3,gt=(e,t)=>t?1e3/t*e:0,_t=(e,t,n)=>{let r=t-e;return((n-e)%r+r)%r+e},vt=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,yt=1e-7,bt=12;function xt(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=vt(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>yt&&++s<bt);return o}function St(e,t,n,r){if(e===t&&n===r)return ut;let i=t=>xt(t,0,1,e,n);return e=>e===0||e===1?e:vt(i(e),t,r)}var Ct=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,wt=e=>t=>1-e(1-t),Tt=St(.33,1.53,.69,.99),Et=wt(Tt),Dt=Ct(Et),Ot=e=>e>=1?1:(e*=2)<1?.5*Et(e):.5*(2-2**(-10*(e-1))),kt=e=>1-Math.sin(Math.acos(e)),At=wt(kt),jt=Ct(kt),Mt=St(.42,0,1,1),Nt=St(0,0,.58,1),Pt=St(.42,0,.58,1),Ft=e=>Array.isArray(e)&&typeof e[0]!=`number`;function It(e,t){return Ft(e)?e[_t(0,e.length,t)]:e}var Lt=e=>Array.isArray(e)&&typeof e[0]==`number`,Rt={linear:ut,easeIn:Mt,easeInOut:Pt,easeOut:Nt,circIn:kt,circInOut:jt,circOut:At,backIn:Et,backInOut:Dt,backOut:Tt,anticipate:Ot},zt=e=>typeof e==`string`,Bt=e=>{if(Lt(e)){e.length;let[t,n,r,i]=e;return St(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 z={now:()=>(Ht===void 0&&z.set(Vt.isProcessing||at.useManualTiming?Vt.timestamp:performance.now()),Ht),set:e=>{Ht=e,queueMicrotask(Ut)}},Wt=e=>Math.round(e*1e5)/1e5,Gt=e=>t=>typeof t==`string`&&t.startsWith(e),Kt=Gt(`--`),qt=Gt(`var(--`),Jt=e=>qt(e)?Yt.test(e.split(`/*`)[0].trim()):!1,Yt=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Xt(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var Zt={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Qt={...Zt,transform:e=>it(0,1,e)},$t={...Zt,default:1},en=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function tn(e){return e==null}var nn=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,rn=(e,t)=>n=>!!(typeof n==`string`&&nn.test(n)&&n.startsWith(e)||t&&!tn(n)&&Object.prototype.hasOwnProperty.call(n,t)),an=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(en);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},on=e=>it(0,255,e),sn={...Zt,transform:e=>Math.round(on(e))},cn={test:rn(`rgb`,`red`),parse:an(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+sn.transform(e)+`, `+sn.transform(t)+`, `+sn.transform(n)+`, `+Wt(Qt.transform(r))+`)`};function ln(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 un={test:rn(`#`),parse:ln,transform:cn.transform},dn=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),fn=dn(`deg`),pn=dn(`%`),B=dn(`px`),mn=dn(`vh`),hn=dn(`vw`),gn={...pn,parse:e=>pn.parse(e)/100,transform:e=>pn.transform(e*100)},_n={test:rn(`hsl`,`hue`),parse:an(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+pn.transform(Wt(t))+`, `+pn.transform(Wt(n))+`, `+Wt(Qt.transform(r))+`)`},vn={test:e=>cn.test(e)||un.test(e)||_n.test(e),parse:e=>cn.test(e)?cn.parse(e):_n.test(e)?_n.parse(e):un.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?cn.transform(e):_n.transform(e),getAnimatableNone:e=>{let t=vn.parse(e);return t.alpha=0,vn.transform(t)}},yn=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,bn=new RegExp(en.source),xn=new RegExp(yn.source,`i`);function Sn(e){return isNaN(e)&&typeof e==`string`&&(bn.test(e)||xn.test(e))}var Cn=`number`,wn=`color`,Tn=`var`,En=`var(`,Dn="${}",On=/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 kn(e){let t=e.toString();return bn.test(t)||xn.test(t)}function An(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(On,e=>(vn.test(e)?(r.color.push(a),i.push(wn),n.push(vn.parse(e))):e.startsWith(En)?(r.var.push(a),i.push(Tn),n.push(e)):(r.number.push(a),i.push(Cn),n.push(parseFloat(e))),++a,Dn)).split(Dn),indexes:r,types:i}}function jn(e){return An(e).values}function Mn({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===Cn?Wt(r[a]):e===wn?vn.transform(r[a]):r[a]}return i}}function Nn(e){return Mn(An(e))}var Pn=e=>typeof e==`number`?0:vn.test(e)?vn.getAnimatableNone(e):e,Fn=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:Pn(e);function In(e){let t=An(e);return Mn(t)(t.values.map((e,n)=>Fn(e,t.split[n])))}var Ln={test:Sn,parse:jn,createTransformer:Nn,getAnimatableNone:In};function Rn(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 zn({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=Rn(s,r,e+1/3),a=Rn(s,r,e),o=Rn(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function Bn(e,t){return n=>n>0?t:e}var Vn=(e,t,n)=>e+(t-e)*n,Hn=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},Un=[un,cn,_n],Wn=e=>Un.find(t=>t.test(e));function Gn(e){let t=Wn(e);if(!t)return`${e}`,!1;let n=t.parse(e);return t===_n&&(n=zn(n)),n}var Kn=(e,t)=>{let n=Gn(e),r=Gn(t);if(!n||!r)return Bn(e,t);let i={...n};return e=>(i.red=Hn(n.red,r.red,e),i.green=Hn(n.green,r.green,e),i.blue=Hn(n.blue,r.blue,e),i.alpha=Vn(n.alpha,r.alpha,e),cn.transform(i))},qn=new Set([`none`,`hidden`]);function Jn(e,t){return qn.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Yn(e,t){return n=>Vn(e,t,n)}function Xn(e){return typeof e==`number`?Yn:typeof e==`string`?Jt(e)?Bn:vn.test(e)?Kn:er:Array.isArray(e)?Zn:typeof e==`object`?vn.test(e)?Kn:Qn:Bn}function Zn(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>Xn(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function Qn(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Xn(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function $n(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 er=(e,t)=>{let n=Ln.createTransformer(t),r=An(e),i=An(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?qn.has(e)&&!i.values.length||qn.has(t)&&!r.values.length?Jn(e,t):dt(Zn($n(r,i),i.values),n):(`${e}${t}`,Bn(e,t))},tr=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]*)$/iu;function nr(e,t){let n=tr.exec(e);if(!n)return;let r=tr.exec(t);if(!r||n[2]!==r[2])return;let i=n[2],a=parseFloat(n[1]),o=parseFloat(r[1]);return e=>Wt(Vn(a,o,e))+i}function rr(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return Vn(e,t,n);if(typeof e==`string`&&typeof t==`string`){let n=nr(e,t);if(n)return n}return Xn(e)(e,t)}var ir=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function ar(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 or=40;function sr(e,t,n={delta:0,timestamp:0,isProcessing:!1}){let r=!1,i=!0,a=()=>r=!0,o=ir.reduce((e,t)=>(e[t]=ar(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=at.useManualTiming,o=a?n.timestamp:performance.now();r=!1,a||(n.delta=i?1e3/60:Math.max(Math.min(o-n.timestamp,or),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:ir.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<ir.length;t++)o[ir[t]].cancel(e)},state:n,steps:o}}var{schedule:cr,cancel:lr,steps:ur}=sr(typeof requestAnimationFrame<`u`?requestAnimationFrame:ut,!0,Vt),dr=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>cr.update(t,e),stop:()=>lr(t),now:()=>Vt.isProcessing?Vt.timestamp:z.now()}},fr=(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)})`},pr=2e4;function mr(e,t=50,n=pr,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 hr(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(mr(r),pr);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:ht(i)}}var gr={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},_r=e=>e<0?1/Math.max(1+e,gr.minDamping):Math.max(1-e,gr.minDamping);function vr(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 xr(e=>i*Math.exp(-r*e)-r*Math.exp(-i*e)-a,e=>Math.exp(-i*e)-Math.exp(-r*e),t)/t}function yr(e,t){return e*Math.sqrt(1-t*t)}var br=12;function xr(e,t,n){let r=n;for(let n=1;n<br;n++)r-=e(r)/t(r);return r}var Sr=.001;function Cr({duration:e=gr.duration,bounce:t=gr.bounce}){let n,r;gr.maxDuration;let i=_r(t);e=it(gr.minDuration,gr.maxDuration,ht(e)),i<1?(n=t=>{let n=t*i,r=n*e,a=yr(t,i),o=Math.exp(-r);return Sr-n/a*o},r=t=>{let r=t*i*e,a=i*i*t*t*e,o=Math.exp(-r),s=yr(t*t,i);return(-n(t)+Sr>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=xr(n,r,a),s=o*vr(i,o*e),c=s*s;return{stiffness:c,damping:i*2*Math.sqrt(c),duration:mt(e)}}var wr=(e,t)=>(t?e>=0:e>0)&&e<1/0;function Tr(e,t){if(wr(e,t))return e}function Er(e){let t=Tr(e.stiffness),n=Tr(e.damping,!0),r=Tr(e.mass),i={...e,stiffness:t??gr.stiffness,damping:n??gr.damping,mass:r??gr.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=_r(e.bounce||0),n=2*Math.PI/(e.visualDuration*1.2)*vr(t,2*Math.PI/1.2);i.stiffness=n*n,i.damping=2*t*Math.sqrt(i.stiffness)}else Object.assign(i,Cr(i)),i.isResolvedFromDuration=!0;(!wr(i.stiffness)||!wr(i.damping,!0))&&(i.stiffness=gr.stiffness,i.damping=gr.damping)}return i}function Dr(e=gr.visualDuration,t=gr.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}=Er({...n}),f=e=>d?0:-ht(e),p=s/(2*Math.sqrt(o*c)),m=ht(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?gr.restSpeed.granular:gr.restSpeed.default),g.restDelta=n.restDelta||(e?gr.restDelta.granular:gr.restDelta.default)};_();let v,y,b;if(p<1){let e=yr(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=>mt(y(e)),next:e=>{let t=v(e);if(u)a.done=e>=l;else{let n=mt(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(mr(S),pr),t=fr(t=>S.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return S}Dr.applyToOptions=e=>{let t=hr(e,100,Dr);return e.ease=t.ease,e.duration=mt(t.duration),e.type=`keyframes`,e};function Or({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=Dr({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 kr(e,t,n){let r=[],i=n||at.mix||rr,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=dt(Array.isArray(t)?t[n]||ut:t,a)),r.push(a)}return r}function Ar(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=kr(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=ft(e[r],e[r+1],n);return s[r](i)};return n?t=>l(it(e[0],e[a-1],t)):l}function jr(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=ft(0,t,r);e.push(Vn(n,1,i))}}function Mr(e){let t=[0];return jr(t,e.length-1),t}function Nr(e,t){return e.map(e=>e*t)}function Pr(e,t){return e.map(()=>t||Pt).splice(0,e.length-1)}function Fr({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=Ft(r)?r.map(Bt):Bt(r)||Pt,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:(at.mix||rr)(n,r);return{calculatedDuration:e,next:t=>(a.value=o?o(i(e>0?it(0,1,t/e):1)):r,a.done=t>=e,a)}}let o=Ar(Nr(n&&n.length===t.length?n:Mr(t),e),t,{ease:Array.isArray(i)?i:Pr(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var Ir=5;function Lr(e,t,n){let r=Math.max(t-Ir,0);return gt(n-e(r),t-r)}function Rr(e,t,n=0){return t<=0?n:e.velocity?e.velocity(t):Lr(t=>e.next(t).value,t,e.next(t).value)}var zr=e=>e!==null;function Br(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(zr),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var Vr={decay:Or,inertia:Or,tween:Fr,keyframes:Fr,spring:Dr};function Hr(e){typeof e.type==`string`&&(e.type=Vr[e.type])}function Ur(e,t){return{kind:e,animation:t,timestamp:z.now(),frameTimestamp:Vt.timestamp,frameIsProcessing:Vt.isProcessing}}function Wr(e,t,n){let r=globalThis.__MOTION_INSPECT__;if(r)try{r({...Ur(`animation-start`,e),options:n?{...t,...n}:t})}catch{}}function Gr(e,t){let n=globalThis.__MOTION_INSPECT__;if(n)try{n({...Ur(`layout-animation-start`,e),node:t})}catch{}}var Kr=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)}},qr=e=>e/100,Jr=class extends Kr{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!==z.now()&&this.tick(z.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause(),Wr(this,this.options)}initAnimation(){let{options:e}=this;Hr(e);let{type:t=Fr,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||Fr;s!==Fr&&typeof o[0]!=`number`&&(this.mixKeyframes=dt(qr,rr(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=mr(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=it(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!==Or&&(b.value=Br(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 ht(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ht(e)}get time(){return ht(this.currentTime)}set time(e){e=mt(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 Rr(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(z.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=ht(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=dr,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(z.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)}},Yr=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function Xr(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(en)||[];if(!r)return e;let i=n.replace(r,``),a=+!!Yr.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var Zr=/\b([a-z-]*)\(.*?\)/gu,Qr={...Ln,getAnimatableNone:e=>{let t=e.match(Zr);return t?t.map(Xr).join(` `):e}},$r={...Ln,getAnimatableNone:e=>{let t=Ln.parse(e);return Ln.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},ei={...Zt,transform:Math.round},ti={rotate:fn,pathRotation:fn,rotateX:fn,rotateY:fn,rotateZ:fn,scale:$t,scaleX:$t,scaleY:$t,scaleZ:$t,skew:fn,skewX:fn,skewY:fn,distance:B,translateX:B,translateY:B,translateZ:B,x:B,y:B,z:B,perspective:B,transformPerspective:B,opacity:Qt,originX:gn,originY:gn,originZ:B},ni={borderWidth:B,borderTopWidth:B,borderRightWidth:B,borderBottomWidth:B,borderLeftWidth:B,borderRadius:B,borderTopLeftRadius:B,borderTopRightRadius:B,borderBottomRightRadius:B,borderBottomLeftRadius:B,width:B,maxWidth:B,height:B,maxHeight:B,top:B,right:B,bottom:B,left:B,inset:B,insetBlock:B,insetBlockStart:B,insetBlockEnd:B,insetInline:B,insetInlineStart:B,insetInlineEnd:B,padding:B,paddingTop:B,paddingRight:B,paddingBottom:B,paddingLeft:B,paddingBlock:B,paddingBlockStart:B,paddingBlockEnd:B,paddingInline:B,paddingInlineStart:B,paddingInlineEnd:B,margin:B,marginTop:B,marginRight:B,marginBottom:B,marginLeft:B,marginBlock:B,marginBlockStart:B,marginBlockEnd:B,marginInline:B,marginInlineStart:B,marginInlineEnd:B,fontSize:B,backgroundPositionX:B,backgroundPositionY:B,...ti,zIndex:ei,fillOpacity:Qt,strokeOpacity:Qt,numOctaves:ei},ri={...ni,color:vn,backgroundColor:vn,outlineColor:vn,fill:vn,stroke:vn,borderColor:vn,borderTopColor:vn,borderRightColor:vn,borderBottomColor:vn,borderLeftColor:vn,filter:Qr,WebkitFilter:Qr,mask:$r,WebkitMask:$r},ii=e=>ri[e],ai=new Set([Qr,$r]);function oi(e,t){let n=ii(e);return ai.has(n)||(n=Ln),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===Zt||e===B,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(ot(e)||ct(e))return parseFloat(e);if(!Ln.test(e)&&Ln.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,cr.read(Pi),cr.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=lt(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()?fr(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 Kr{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=Br(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),zi(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()},Wr(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 ht(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ht(e)}get time(){return ht(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=mt(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),ut):n(this)}},Zi={anticipate:Ot,backInOut:Dt,circInOut:jt};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),Hr(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 Jr({...a,autoplay:!1}),s=Math.max(ea,z.now()-this.startTime),c=it(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()}},V=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(Ln.test(e)||e===`0`)&&!e.startsWith(`url(`));function na(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 ra(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=V(i,t),s=V(a,t);return!o||!s?(o!==s&&`${t}${i}${a}${o?a:i}`,!1):na(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=lt(()=>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 Kr{constructor(e){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=z.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=z.now();let u=!0;ra(e,i,a,o)||(u=!1,(at.instantAnimations||!s)&&l?.(Br(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 Jr(n)}}else m=new Jr(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()}},pa=class{constructor(e){this.stop=()=>this.runAll(`stop`),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>e.finished))}getAll(e){return this.animations[0][e]}setAll(e,t){for(let n=0;n<this.animations.length;n++)this.animations[n][e]=t}attachTimeline(e){let t=this.animations.map(t=>t.attachTimeline(e));return()=>{t.forEach((e,t)=>{e&&e(),this.animations[t].stop()})}}get time(){return this.getAll(`time`)}set time(e){this.setAll(`time`,e)}get speed(){return this.getAll(`speed`)}set speed(e){this.setAll(`speed`,e)}get state(){return this.getAll(`state`)}get startTime(){return this.getAll(`startTime`)}get duration(){return ma(this.animations,`duration`)}get iterationDuration(){return ma(this.animations,`iterationDuration`)}runAll(e){this.animations.forEach(t=>t[e]())}play(){this.runAll(`play`)}pause(){this.runAll(`pause`)}cancel(){this.runAll(`cancel`)}complete(){this.runAll(`complete`)}};function ma(e,t){let n=0;for(let r=0;r<e.length;r++){let i=e[r][t];i!==null&&i>n&&(n=i)}return n}var ha=class extends pa{then(e,t){return this.finished.finally(e).then(()=>{})}};function ga(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 _a=30,va=e=>!isNaN(parseFloat(e)),ya={current:void 0},ba=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=z.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=z.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=va(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 pt)).add(t)}onChangeSubscribe(e){let{events:t}=this;return!t.change&&!this.changeSubscriber?this.changeSubscriber=e:(t.change||(t.change=new pt,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(){cr.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 ya.current&&ya.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=z.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>_a)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,_a);return gt(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 xa(e,t){return new ba(e,t)}function Sa(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function Ca(e,t){let n=e?.[t]??e?.default??e;return n===e?n:Sa(n,e)}var wa={type:`spring`,stiffness:500,damping:25,restSpeed:10},Ta=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Ea={type:`keyframes`,duration:.8},Da={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Oa=(e,{keyframes:t})=>t.length>2?Ea:xi.has(e)?e.startsWith(`scale`)?Ta(t[1]):wa:Da,ka=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function Aa(e){for(let t in e)if(!ka.has(t))return!0;return!1}var ja=(e,t,n,r={},i,a)=>o=>{let s=Ca(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=mt(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};Aa(s)||Object.assign(u,Oa(e,u)),u.duration&&=mt(u.duration),u.repeatDelay&&=mt(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)),(at.instantAnimations||at.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=Br(u.keyframes,s);if(e!==void 0){cr.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new Jr(u):new fa(u)},Ma=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Na(e){let t=Ma.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function Pa(e,t,n=1){`${e}`;let[r,i]=Na(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return ot(e)?parseFloat(e):e}return Jt(i)?Pa(i,t,n+1):i}function Fa(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Ia(e,t,n,r){let i=t=>typeof t==`function`?t(n===void 0?e.custom:n,...Fa(r)):t;return t=i(t),typeof t==`string`&&(t=e.variants&&e.variants[t]),i(t)}function La(e,t,n){return Ia(e.getProps(),t,n,e)}var Ra=(e,t)=>t===`exit`?e.presenceContext?.custom:void 0,za=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...bi]),Ba=e=>Array.isArray(e);function Va(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,xa(n))}function Ha(e){return Ba(e)?e[e.length-1]||0:e}function Ua(e,t){let{transitionEnd:n={},transition:r={},...i}=La(e,t)||{};i={...i,...n};for(let t in i)Va(e,t,Ha(i[t]))}var Wa=e=>!!(e&&e.getVelocity);function Ga(e){return!!(Wa(e)&&e.add)}function Ka(e,t){let n=e.getValue(`willChange`);if(Ga(n))return n.add(t);if(!n&&at.WillChange){let n=new at.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function qa(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var Ja=`data-`+qa(`framerAppearId`);function Ya(e){return e.props[Ja]}var Xa=typeof window<`u`;function Za({protectedKeys:e,needsAnimating:t},n){let r=n in e&&!t[n];return t[n]=!1,r}function Qa(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?Sa(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&&Za(f,t))continue;let o={delay:n,...Ca(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){cr.update(()=>r.set(i));continue}let p=!1;if(Xa&&window.MotionHandoffAnimation){let n=Ya(e);if(n){let e=window.MotionHandoffAnimation(n,t,cr);e!==null&&(o.startTime=e,p=!0)}}Ka(e,t);let m=l??e.shouldReduceMotion;r.start(ja(t,r,i,m&&za.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>cr.update(()=>{o&&Ua(e,o)});d.length?Promise.all(d).then(t):t()}return d}function $a(e,t,n={}){let r=La(e,t,Ra(e,n.type)),i=n.transitionOverride||(r?.transition??(e.getDefaultTransition()||{})),a=()=>Promise.all(r?Qa(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($a(e,t,{...n,delay:r+(typeof o==`function`?0:o)+ga(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 eo(e,t,n={}){return e.notify(`AnimationStart`,t),(Array.isArray(t)?Promise.all(t.map(t=>$a(e,t,n))):typeof t==`string`?$a(e,t,n):Promise.all(Qa(e,La(e,t,n.custom),n))).then(()=>{e.notify(`AnimationComplete`,t)})}var to={test:e=>e===`auto`,parse:e=>e},no=e=>t=>t.test(e),ro=[Zt,B,pn,fn,hn,mn,to],io=e=>ro.find(no(e));function ao(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||ct(e)}var oo=new Set([`auto`,`none`,`0`]);function so(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!oo.has(t)&&kn(t)&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]!==i&&(e[r]=oi(n,i))}var co=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(),Jt(r))){let i=Pa(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!za.has(n)||e.length!==2)return;let[r,i]=e;if(typeof r==`number`&&typeof i==`number`)return;let a=io(r),o=io(i);if(Xt(r)!==Xt(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||ao(e[t]))&&n.push(t);n.length&&so(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()}},lo=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`],uo=[];function fo(e){typeof e.test==`function`&&e.read,po(e),uo.unshift(e)}function po(e){rt(uo,e)}function mo(e){return uo.find(t=>t.test(e))}function ho(e,t,n={},r){let i=[],{velocity:a}=n,o=n.reduceMotion??r?.shouldReduceMotion;for(let s in t){if(s===`transition`||s===`transitionEnd`)continue;let c=t[s];if(c===void 0)continue;let l=e(s),u=l.get();if(u!==void 0&&!l.isAnimating()&&!Array.isArray(c)&&c===u&&!a){cr.update(()=>l.set(c));continue}l.start(ja(s,l,c,o&&za.has(s)?{type:!1}:n,r)),l.animation&&i.push(l.animation)}let{transitionEnd:s}=t;if(s){let t=()=>cr.update(()=>{for(let t in s)e(t).set(s[t])});i.length?Promise.all(i).then(t):t()}return i}function go(e,t,n,r,i){return ho(r=>{let a=e.get(t,r);if(!a){let o;if(!i){let i=n[r];o=_o(i)??e.read(t,r,i),`${r}`}a=xa(o,{owner:i}),e(t,{[r]:a})}return a},n,r,i)}function _o(e){let t=Array.isArray(e)?e[0]:void 0;return t===null?void 0:t}function vo(e){return st(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}function yo(e){return st(e)&&`ownerSVGElement`in e}var bo=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function xo(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 So=class{constructor(e=cr.render){this.step=e,this.values=new Map,this.pending=[],this.numPending=0,this.flush=()=>{let{pending:e,numPending:t}=this;this.numPending=0;for(let n=0;n<t;n++)e[n]()}}set(e,t,n,r){if(this.values.get(e)?.onRemove(),r)for(let e of this.values.values())e.value===r&&(n=e.render);let i=()=>n&&this.schedule(n);t.get()!==void 0&&i();let a=t.on(`change`,i),o=()=>{a(),n&&!r&&this.cancel(n),this.values.get(e)?.onRemove===o&&this.values.delete(e)};return this.values.set(e,{value:t,render:r?void 0:n,onRemove:o}),o}get(e){return this.values.get(e)?.value}release(){let e=new Map;return this.values.forEach((t,n)=>{e.set(n,t.value),t.onRemove()}),this.transformKeys=this.transformValues=void 0,e}schedule(e){let{pending:t,numPending:n}=this;for(let r=0;r<n;r++)if(t[r]===e)return;n||this.step(this.flush),t[this.numPending++]=e}cancel(e){let{pending:t}=this;for(let n=0;n<this.numPending;n++)if(t[n]===e){t[n]=t[--this.numPending];return}}};function Co(e,{step:t,...n}={}){let r=new WeakMap;return Object.assign((n,i)=>{let a=r.get(n)??new So(t);r.set(n,a);let o=[];for(let t in i){let r=i[t],s=e(n,a,t,r);o.push(s)}return()=>{for(let e of o)e()}},n,{get:(e,t)=>r.get(e)?.get(t),flush:e=>r.get(e)?.flush(),state:e=>r.get(e)})}var wo={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},To={};function Eo(e){let t=``,{transformKeys:n=[],transformValues:r={}}=e;for(let e=0;e<n.length;e++){let i=n[e],a=r[i].get();a!==void 0&&(typeof a==`number`?a:parseFloat(a))!==+!!i.startsWith(`scale`)&&(t+=(t&&` `)+(To[i]||(To[i]=(wo[i]||i)+`(`))+bo(a,ti[i])+`)`)}let i=e.get(`pathRotation`)?.get();return i&&(t+=(t&&` `)+`rotate(`+bo(i,ti.pathRotation)+`)`),t||`none`}var Do=new Set([`originX`,`originY`,`originZ`]),Oo=(e,t)=>bo(e.get(t)?.get(),ni[t]),ko=(e,t,n,r)=>{let i,a;if(xi.has(n)){if(n!==`pathRotation`){let e=t.transformKeys??=[];(t.transformValues??={})[n]=r,e.includes(n)||(e.push(n),e.sort((e,t)=>bi.indexOf(e)-bi.indexOf(t)))}t.get(`transform`)||(!vo(e)&&!t.get(`transformBox`)&&ko(e,t,`transformBox`,new ba(`fill-box`)),t.set(`transform`,new ba(`none`),()=>{e.style.transform=Eo(t)})),a=t.get(`transform`)}else Do.has(n)?(t.get(`transformOrigin`)||t.set(`transformOrigin`,new ba(``),()=>{let n=Oo(t,`originX`)??`50%`,r=Oo(t,`originY`)??`50%`,i=Oo(t,`originZ`)??0;e.style.transformOrigin=`${n} ${r} ${i}`}),a=t.get(`transformOrigin`)):i=Ri(n)?()=>{e.style.setProperty(n,r.get())}:()=>{e.style[n]=bo(r.get(),ni[n])};return t.set(n,r,i,a)},Ao=e=>vo(e)||yo(e),jo=(e,t)=>{if(xi.has(t))return vi(e,t);let n=getComputedStyle(e),r=Ri(t)?n.getPropertyValue(t):n[t];return typeof r==`string`&&r.trim()||0},Mo=Co(ko,{test:Ao,read:jo}),No={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},Po=bi.length;function Fo(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=bo(s,ni[o]);if(!c){i=!1;let t=No[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${bo(a,ni.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function Io(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(Kt(e)){i[e]=n;continue}{let t=bo(n,ni[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=Fo(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 Lo={offset:`stroke-dashoffset`,array:`stroke-dasharray`},Ro={offset:`strokeDashoffset`,array:`strokeDasharray`};function zo(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?Lo:Ro;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var H=[`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(Io(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 H)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&&zo(d,i,a,o,!1)}function Vo(e,t){if(!(t in e))return!1;let n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),t)||Object.getOwnPropertyDescriptor(e,t);return n&&typeof n.set==`function`}var Ho=(e,t,n,r,i=n)=>{let a=Vo(e,i);!a&&(i.startsWith(`data`)||i.startsWith(`aria`))&&(i=qa(i));let o=ni[n]||ni[i],s=a?()=>{e[i]=bo(r.get(),ni[n])}:()=>{let t=bo(r.get(),o);t==null?e.removeAttribute(i):e.setAttribute(i,String(t))};return t.set(n,r,s)};function Uo(e,t,n,r){return cr.render(()=>e.setAttribute(`pathLength`,`1`)),n===`pathOffset`?t.set(n,r,()=>{let t=r.get();e.setAttribute(`stroke-dashoffset`,`${-t}`)}):(t.get(`stroke-dasharray`)||t.set(`stroke-dasharray`,new ba(`1 1`),()=>{let n=t.get(`pathLength`)?.get()??1,r=t.get(`pathSpacing`)?.get();e.setAttribute(`stroke-dasharray`,`${n} ${r??1-Number(n)}`)}),t.set(n,r,void 0,t.get(`stroke-dasharray`)))}var Wo=Co((e,t,n,r)=>n.startsWith(`path`)?Uo(e,t,n,r):n.startsWith(`attr`)?Ho(e,t,n,r,Go(n)):(xi.has(n)||Do.has(n)||Ri(n)||n in e.style?ko:Ho)(e,t,n,r),{test:yo,read:(e,t)=>xi.has(t)?ni[t]?.default||0:Ri(t)||H.includes(t)?jo(e,t)||e.getAttribute(qa(t))||0:(t=Go(t),e.getAttribute(qa(t))??e.getAttribute(t)??void 0)});function Go(e){return e.replace(/^attr([A-Z])/,(e,t)=>t.toLowerCase())}function Ko({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function qo({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Jo(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 Yo(e){return e===void 0||e===1}function Xo({scale:e,scaleX:t,scaleY:n}){return!Yo(e)||!Yo(t)||!Yo(n)}function Zo(e){return Xo(e)||Qo(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Qo(e){return $o(e.x)||$o(e.y)}function $o(e){return e&&e!==`0%`}function es(e,t,n){return n+t*(e-n)}function ts(e,t,n,r,i){return i!==void 0&&(e=es(e,i,r)),es(e,n,r)+t}function ns(e,t=0,n=1,r,i){e.min=ts(e.min,t,n,r,i),e.max=ts(e.max,t,n,r,i)}function rs(e,{x:t,y:n}){ns(e.x,t.translate,t.scale,t.originPoint),ns(e.y,n.translate,n.scale,n.originPoint)}var is=.999999999999,as=1.0000000000001;function os(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&&(ss(e.x,-a.scroll.offset.x),ss(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,rs(e,o)),r&&Zo(a.latestValues)&&us(e,a.latestValues,a.layout?.layoutBox))}t.x<as&&t.x>is&&(t.x=1),t.y<as&&t.y>is&&(t.y=1)}function ss(e,t){e.min+=t,e.max+=t}function cs(e,t,n,r,i=.5){ns(e,t,n,Vn(e.min,e.max,i),r)}function ls(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function us(e,t,n){let r=n??e;cs(e.x,ls(t.x,r.x),t.scaleX,t.scale,t.originX),cs(e.y,ls(t.y,r.y),t.scaleY,t.scale,t.originY)}function ds(e,t){return Ko(Jo(e.getBoundingClientRect(),t))}function fs(e,t,n){let r=ds(e,n),{scroll:i}=t;return i&&(ss(r.x,i.offset.x),ss(r.y,i.offset.y)),r}var ps={},ms=e=>yo(e)?Wo:Mo,hs=class{constructor(e,t){this.effect=e,this.current=t,this.KeyframeResolver=co}getValue(e){return this.effect.get(this.current,e)}readValue(e,t){return this.effect.read(this.current,e,t)}render(){this.effect.flush(this.current)}measureViewportBox(){return ds(this.current)}getProps(){return ps}};function gs(e,t,n,r){if(r)return ho(e=>r.getValue(e,null),t,n,r);let i=ms(e);return go(i,e,t,n,new hs(i,e))}var _s=Co((e,t,n,r)=>t.set(n,r,()=>{e[n]=r.get()}),{test:e=>st(e),read:(e,t)=>{let n=e[t];return typeof n==`string`||typeof n==`number`?n:void 0}}),{schedule:vs,cancel:ys}=sr(queueMicrotask,!1),bs={x:!1,y:!1};function xs(){return bs.x||bs.y}function Ss(e){return e===`x`||e===`y`?bs[e]?null:(bs[e]=!0,()=>{bs[e]=!1}):bs.x||bs.y?null:(bs.x=bs.y=!0,()=>{bs.x=bs.y=!1})}function Cs(e,t){let n=xo(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function ws(e){return!(e.pointerType===`touch`||xs())}function Ts(e,t,n={}){let[r,i,a]=Cs(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(!ws(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 Es=(e,t)=>t?e===t||Es(e,t.parentElement):!1,Ds=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Os=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function ks(e){return Os.has(e.tagName)||e.isContentEditable===!0}var As=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function js(e){return As.has(e.tagName)||e.isContentEditable===!0}var Ms=new WeakSet;function Ns(e){return t=>{t.key===`Enter`&&e(t)}}function Ps(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var Fs=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=Ns(()=>{if(Ms.has(n))return;Ps(n,`down`);let e=Ns(()=>{Ps(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>Ps(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function Is(e){return Ds(e)&&!xs()}var Ls=new WeakSet;function Rs(e,t,n={}){let[r,i,a]=Cs(e,n),o=e=>{let r=e.currentTarget;if(!Is(e)||Ls.has(e))return;Ms.add(r),n.stopPropagation&&Ls.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),Ms.has(r)&&Ms.delete(r),Is(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||Es(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),vo(e)&&(e.addEventListener(`focus`,e=>Fs(e,i)),!ks(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}var zs=new WeakMap,Bs,Vs=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:yo(r)&&`getBBox`in r?r.getBBox()[t]:r[n],Hs=Vs(`inline`,`width`,`offsetWidth`),Us=Vs(`block`,`height`,`offsetHeight`);function Ws({target:e,borderBoxSize:t}){zs.get(e)?.forEach(n=>{n(e,{get width(){return Hs(e,t)},get height(){return Us(e,t)}})})}function Gs(e){e.forEach(Ws)}function Ks(){typeof ResizeObserver<`u`&&(Bs=new ResizeObserver(Gs))}function qs(e,t){Bs||Ks();let n=xo(e);return n.forEach(e=>{let n=zs.get(e);n||(n=new Set,zs.set(e,n)),n.add(t),Bs?.observe(e)}),()=>{n.forEach(e=>{let n=zs.get(e);n?.delete(t),n?.size||Bs?.unobserve(e)})}}var Js=new Set,Ys;function Xs(){Ys=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Js.forEach(t=>t(e))},window.addEventListener(`resize`,Ys)}function Zs(e){return Js.add(e),Ys||Xs(),()=>{Js.delete(e),!Js.size&&typeof Ys==`function`&&(window.removeEventListener(`resize`,Ys),Ys=void 0)}}function Qs(e,t){return typeof e==`function`?Zs(e):qs(e,t)}var $s={value:null,addProjectionMetrics:null};function ec(e){return yo(e)&&e.tagName===`svg`}var tc=e=>typeof e==`number`?e:parseFloat(e),nc=()=>({translate:0,scale:1,origin:0,originPoint:0}),rc=()=>({x:nc(),y:nc()}),ic=()=>({min:0,max:0}),ac=()=>({x:ic(),y:ic()}),oc=new WeakMap;function sc(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function cc(e){return typeof e==`string`||Array.isArray(e)}var lc=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],uc=[`initial`,...lc];function dc(e){if(sc(e.animate))return!0;for(let t=0;t<uc.length;t++)if(cc(e[uc[t]]))return!0;return!1}function fc(e){return!!(dc(e)||e.variants)}function pc(e,t,n){for(let r in t){let i=t[r],a=n[r];if(Wa(i))e.addValue(r,i);else if(Wa(a))e.addValue(r,xa(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,xa(t===void 0?i:t,{owner:e}))}}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var mc={current:null},hc={current:!1},gc=typeof window<`u`;function _c(){if(hc.current=!0,gc){if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>mc.current=e.matches;e.addEventListener(`change`,t),t()}else mc.current=!1}}var vc=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],yc={};function bc(e){yc=e}function xc(){return yc}var Sc=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=z.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,cr.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=dc(t),this.isVariantNode=fc(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&&Wa(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,oc.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:(hc.current||_c(),this.shouldReduceMotion=mc.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(),lr(this.notifyUpdate),lr(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:mt(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&&cr.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 yc){let t=yc[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):ac()}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<vc.length;t++){let n=vc[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=pc(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=xa(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`&&(ot(n)||ct(n))?n=parseFloat(n):typeof n!=`number`&&!Ln.test(n)&&Ln.test(t)&&(n=oi(e,t)),this.setBaseTarget(e,Wa(n)?n.get():n)),Wa(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}on(e,t){return this.events[e]||(this.events[e]=new pt),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){vs.render(this.render)}},Cc=class extends Sc{constructor(){super(...arguments),this.KeyframeResolver=co}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;Wa(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},wc=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function Tc(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 Ec={};function Dc(e,{layout:t,layoutId:n}){return xi.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!Ec[e]||e===`opacity`)}function Oc(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(Wa(r[t])||i&&Wa(i[t])||Dc(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function kc(e){return window.getComputedStyle(e)}var Ac=class extends Cc{constructor(){super(...arguments),this.type=`html`,this.renderInstance=Tc}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=kc(e),r=(Kt(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return ds(e,t)}build(e,t,n){Io(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return Oc(e,t,n)}},jc=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`]),Mc=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function Nc(e,t,n,r){Tc(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(jc.has(n)?n:qa(n),t.attrs[n])}function Pc(e,t,n){let r=Oc(e,t,n);for(let n in e)if(Wa(e[n])||Wa(t[n])){let t=bi.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var Fc=class extends Cc{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=ac}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(H.includes(t)){let n=getComputedStyle(e)[t];if(typeof n==`string`&&n)return n.trim()}return t=jc.has(t)?t:qa(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return Pc(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=Mc(e.tagName),super.mount(e)}};function Ic(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 Lc=[...lc].reverse();function Rc(e){let t=t=>Promise.all(t.map(({animation:t,options:n})=>eo(e,t,n))),n=Bc(),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(Lc.forEach((t,r)=>{let i=n[t],h=o[t],g=m&&m.props[t],_=h===void 0?cc(g)||g===!1?g:void 0:h,v=cc(_),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||sc(_)||typeof _==`boolean`)return;if(t===`exit`&&i.isActive&&y!==!0){f={...f,...i.prevResolvedValues};return}let x=zc(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}=La(e,n,Ra(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)?!Ic(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=La(s,n)?.transition?.delayChildren;r.delay=ga(s.enteringChildren,e,t)}u.push({animation:n,options:r})}}),d.size){let{initial:t}=o,n={},r=typeof t!=`boolean`&&La(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&&!Wa(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=Bc(),i=!0}}}function zc(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!Ic(t,e):!1}function Bc(){let e={};for(let t of lc)e[t]={isActive:t===`animate`,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}};return e}function Vc(e,t){e.min=t.min,e.max=t.max}function Hc(e,t){Vc(e.x,t.x),Vc(e.y,t.y)}function Uc(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var Wc=.9999,Gc=1.0001,Kc=-.01,qc=.01;function Jc(e){return e.max-e.min}function Yc(e,t,n){return Math.abs(e-t)<=n}function Xc(e,t,n,r=.5){e.origin=r,e.originPoint=Vn(t.min,t.max,e.origin),e.scale=Jc(n)/Jc(t),e.translate=Vn(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Wc&&e.scale<=Gc||isNaN(e.scale))&&(e.scale=1),(e.translate>=Kc&&e.translate<=qc||isNaN(e.translate))&&(e.translate=0)}function Zc(e,t,n,r){Xc(e.x,t.x,n.x,r?r.originX:void 0),Xc(e.y,t.y,n.y,r?r.originY:void 0)}function Qc(e,t,n,r=0){e.min=(r?Vn(n.min,n.max,r):n.min)+t.min,e.max=e.min+Jc(t)}function $c(e,t,n,r){Qc(e.x,t.x,n.x,r?.x),Qc(e.y,t.y,n.y,r?.y)}function el(e,t,n,r=0){let i=r?Vn(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+Jc(t)}function tl(e,t,n,r){el(e.x,t.x,n.x,r?.x),el(e.y,t.y,n.y,r?.y)}function nl(e,t,n,r,i){return e-=t,e=es(e,1/n,r),i!==void 0&&(e=es(e,1/i,r)),e}function rl(e,t=0,n=1,r=.5,i,a=e,o=e){if(pn.test(t)&&(t=parseFloat(t),t=Vn(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=Vn(a.min,a.max,r);e===a&&(s-=t),e.min=nl(e.min,t,n,s,i),e.max=nl(e.max,t,n,s,i)}function il(e,t,[n,r,i],a,o){rl(e,t[n],t[r],t[i],t.scale,a,o)}var al=[`x`,`scaleX`,`originX`],ol=[`y`,`scaleY`,`originY`];function sl(e,t,n,r){il(e.x,t,al,n?n.x:void 0,r?r.x:void 0),il(e.y,t,ol,n?n.y:void 0,r?r.y:void 0)}function cl(e){return e.translate===0&&e.scale===1}function ll(e){return cl(e.x)&&cl(e.y)}function ul(e,t){return e.min===t.min&&e.max===t.max}function dl(e,t){return ul(e.x,t.x)&&ul(e.y,t.y)}function fl(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function pl(e,t){return fl(e.x,t.x)&&fl(e.y,t.y)}function ml(e){return Jc(e.x)/Jc(e.y)}function hl(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function gl(e){return[e(`x`),e(`y`)]}function _l(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var vl={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`){if(B.test(e))e=parseFloat(e);else return e}return`${_l(e,t.target.x)}% ${_l(e,t.target.y)}%`}},yl={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Ln.parse(e);if(i.length>5)return r;let a=Ln.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=Vn(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 bl(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 xl=lo.length,Sl=e=>typeof e==`number`||B.test(e);function Cl(e,t,n,r,i,a){i?(e.opacity=Vn(0,n.opacity??1,Tl(r)),e.opacityExit=Vn(t.opacity??1,0,El(r))):a&&(e.opacity=Vn(t.opacity??1,n.opacity??1,r));for(let i=0;i<xl;i++){let a=lo[i],o=wl(t,a),s=wl(n,a);(o!==void 0||s!==void 0)&&(o||=0,s||=0,o===0||s===0||Sl(o)===Sl(s)?(e[a]=Math.max(Vn(tc(o),tc(s),r),0),(pn.test(s)||pn.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=Vn(t.rotate||0,n.rotate||0,r))}function wl(e,t){return e[t]===void 0?e.borderRadius:e[t]}var Tl=Dl(0,.5,At),El=Dl(.5,.95,ut);function Dl(e,t,n){return r=>r<e?0:r>t?1:n(ft(e,t,r))}function Ol(e,t,n){let r=Wa(e)?e:xa(e);return r.start(ja(``,r,t,n)),r.animation}function kl(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var Al=(e,t)=>e.depth-t.depth,jl=class{constructor(){this.children=[],this.isDirty=!1}add(e){nt(this.children,e),this.isDirty=!0}remove(e){rt(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Al),this.isDirty=!1,this.children.forEach(e)}};function Ml(e,t){let n=z.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(lr(r),e(a-t))};return cr.setup(r,!0),()=>lr(r)}function Nl(e){return Wa(e)?e.get():e}var Pl=class{constructor(){this.members=[]}add(e){nt(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&&(rt(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(rt(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)}},Fl={borderRadius:{...vl,applyTo:[...lo]},borderTopLeftRadius:vl,borderTopRightRadius:vl,borderBottomLeftRadius:vl,borderBottomRightRadius:vl,boxShadow:yl},Il={hasAnimatedSinceResize:!0,hasEverUpdated:!1};Object.assign(Ec,{...Fl,...Ec});var Ll={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},Rl=[``,`X`,`Y`,`Z`],zl=1e3,Bl=0;function Vl(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function Hl(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=Ya(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,cr,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&Hl(r)}function Ul({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=Bl++,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,$s.value&&(Ll.nodes=Ll.calculatedTargetDeltas=Ll.calculatedProjections=0),this.nodes.forEach(Kl),this.nodes.forEach(nu),this.nodes.forEach(ru),this.nodes.forEach(ql),$s.addProjectionMetrics&&$s.addProjectionMetrics(Ll)},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 jl)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new pt),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=yo(t)&&!ec(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;cr.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=Ml(i,250),Il.hasAnimatedSinceResize&&(Il.hasAnimatedSinceResize=!1,this.nodes.forEach(tu)))})}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()||uu,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!pl(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={...Ca(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||tu(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(),lr(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(iu),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&&Hl(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(Xl),this.nodes.forEach(Yl);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Zl);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Ql),this.nodes.forEach($l),this.nodes.forEach(eu),this.nodes.forEach(Wl),this.nodes.forEach(Gl)):this.nodes.forEach(Zl),this.clearAllSnapshots();let e=z.now();Vt.delta=it(0,1e3/60,e-Vt.timestamp),Vt.timestamp=e,Vt.isProcessing=!0,ur.update.process(Vt),ur.preRender.process(Vt),ur.render.process(Vt),Vt.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,vs.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Jl),this.sharedNodes.forEach(au)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,cr.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){cr.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),this.snapshot&&!Jc(this.snapshot.measuredBox.x)&&!Jc(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||=ac(),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&&!ll(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||Zo(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)),mu(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return ac();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(gu))){let{scroll:e}=this.root;e&&(ss(t.x,e.offset.x),ss(t.y,e.offset.y))}return t}removeElementScroll(e){let t=ac();if(Hc(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&&Hc(t,e),ss(t.x,i.offset.x),ss(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||ac();Hc(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&&(ss(r.x,-n.scroll.offset.x),ss(r.y,-n.scroll.offset.y)),Zo(n.latestValues)&&us(r,n.latestValues,n.layout?.layoutBox)}return Zo(this.latestValues)&&us(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=ac();Hc(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!Zo(n.latestValues))continue;let r;n.instance&&(Xo(n.latestValues)&&n.updateSnapshot(),r=ac(),Hc(r,n.measurePageBox())),sl(t,n.latestValues,n.snapshot?.layoutBox,r)}return Zo(this.latestValues)&&sl(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=ac(),this.targetWithTransforms=ac()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),$c(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Hc(this.target,this.layout.layoutBox),rs(this.target,this.targetDelta)):Hc(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),$s.value&&Ll.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||Xo(this.parent.latestValues)||Qo(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=ac(),this.relativeTargetOrigin=ac(),tl(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),Hc(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;Hc(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;os(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=ac());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Uc(this.prevProjectionDelta.x,this.projectionDelta.x),Uc(this.prevProjectionDelta.y,this.projectionDelta.y)),Zc(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!hl(this.projectionDelta.x,this.prevProjectionDelta.x)||!hl(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),$s.value&&Ll.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=rc(),this.projectionDelta=rc(),this.projectionDeltaWithTransform=rc()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=rc();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=ac(),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(lu));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=Vn(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=Vn(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(ou(o.x,e.x,n),ou(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(tl(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),cu(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&dl(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=ac(),Hc(f,this.relativeTarget)),c&&(this.animationValues=a,Cl(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&&=(lr(this.pendingAnimation),void 0),this.pendingAnimation=cr.update(()=>{Il.hasAnimatedSinceResize=!0,this.motionValue||=xa(0),this.motionValue.jump(0,!1),this.currentAnimation=Ol(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()}}),Gr(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(zl),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&&hu(this.options.animationType,this.layout.layoutBox,n.layoutBox)){i=this.target||ac();let t=Jc(this.layout.layoutBox.x);i.x.min=e.target.x.min,i.x.max=i.x.min+t;let n=Jc(this.layout.layoutBox.y);i.y.min=e.target.y.min,i.y.max=i.y.min+n}Hc(t,i),us(t,r),Zc(this.projectionDeltaWithTransform,this.layoutCorrected,t,r)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new Pl),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&&Vl(`z`,e,r,this.animationValues);for(let t=0;t<Rl.length;t++)Vl(`rotate${Rl[t]}`,e,r,this.animationValues),Vl(`skew${Rl[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&&!Zo(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=bl(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 Ec){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=Ec[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(Yl),this.root.sharedNodes.clear()}}}function Wl(e){e.updateLayout()}function Gl(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`)gl(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=Jc(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;Vc(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else hu(i,t.layoutBox,n)&&gl(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=Jc(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=rc();Zc(o,n,t.layoutBox);let s=rc();a?Zc(s,e.applyTransform(r,!0),t.measuredBox):Zc(s,n,t.layoutBox);let c=!ll(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=ac();tl(s,t.layoutBox,i.layoutBox,o);let c=ac();tl(c,n,a.layoutBox,o),pl(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 Kl(e){$s.value&&Ll.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 ql(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Jl(e){e.clearSnapshot()}function Yl(e){e.clearMeasurements()}function Xl(e){e.isLayoutDirty=!0,e.updateLayout()}function Zl(e){e.isLayoutDirty=!1}function Ql(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function $l(e){e.relativeTarget&&e.relativeParent?.isLayoutDirty&&(e.currentAnimation?e.isLayoutDirty=!0:(e.targetDelta=void 0,e.removeRelativeTarget()))}function eu(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function tu(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function nu(e){e.resolveTargetDelta()}function ru(e){e.calcProjection()}function iu(e){e.resetSkewAndRotation()}function au(e){e.removeLeadSnapshot()}function ou(e,t,n){e.translate=Vn(t.translate,0,n),e.scale=Vn(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function su(e,t,n,r){e.min=Vn(t.min,n.min,r),e.max=Vn(t.max,n.max,r)}function cu(e,t,n,r){su(e.x,t.x,n.x,r),su(e.y,t.y,n.y,r)}function lu(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var uu={duration:.45,ease:[.4,0,.1,1]},du=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),fu=du(`applewebkit/`)&&!du(`chrome/`)?Math.round:ut;function pu(e){e.min=fu(e.min),e.max=fu(e.max)}function mu(e){pu(e.x),pu(e.y)}function hu(e,t,n){return e===`position`||e===`preserve-aspect`&&!Yc(ml(t),ml(n),.2)}function gu(e){return e!==e.root&&e.scroll?.wasRoot}var _u=Ul({attachResizeListener:(e,t)=>kl(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),vu={current:void 0},yu=Ul({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!vu.current){let e=new _u({});e.mount(window),e.setOptions({layoutScroll:!0}),vu.current=e}return vu.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),bu=(0,m.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function xu(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Su(...e){return t=>{let n=!1,r=e.map(e=>{let r=xu(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():xu(e[t],null)}}}}function Cu(...e){return m.useCallback(Su(...e),e)}var U=i(),wu=class extends m.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(vo(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=vo(e)&&e.offsetWidth||0,r=vo(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 Tu({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)(bu),u=Cu(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}"] {
|
|
@@ -56,7 +56,7 @@ Error generating stack: `+e.message+`
|
|
|
56
56
|
`},Ax=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},jx=function(){m.useEffect(function(){return document.body.setAttribute(Ox,(Ax()+1).toString()),function(){var e=Ax()-1;e<=0?document.body.removeAttribute(Ox):document.body.setAttribute(Ox,e.toString())}},[])},Mx=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;jx();var a=m.useMemo(function(){return Ex(i)},[i]);return m.createElement(Dx,{styles:kx(a,!t,i,n?``:`!important`)})},Nx=!1;if(typeof window<`u`)try{var Px=Object.defineProperty({},"passive",{get:function(){return Nx=!0,!0}});window.addEventListener(`test`,Px,Px),window.removeEventListener(`test`,Px,Px)}catch{Nx=!1}var Fx=Nx?{passive:!1}:!1,Ix=function(e){return e.tagName===`TEXTAREA`},Lx=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Ix(e)&&n[t]===`visible`)},Rx=function(e){return Lx(e,`overflowY`)},zx=function(e){return Lx(e,`overflowX`)},Bx=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Ux(e,r)){var i=Wx(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Vx=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Hx=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Ux=function(e,t){return e===`v`?Rx(t):zx(t)},Wx=function(e,t){return e===`v`?Vx(t):Hx(t)},Gx=function(e,t){return e===`h`&&t===`rtl`?-1:1},Kx=function(e,t,n,r,i){var a=Gx(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=Wx(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Ux(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},qx=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Jx=function(e){return[e.deltaX,e.deltaY]},Yx=function(e){return e&&`current`in e?e.current:e},Xx=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Zx=function(e){return`
|
|
57
57
|
.block-interactivity-${e} {pointer-events: none;}
|
|
58
58
|
.allow-interactivity-${e} {pointer-events: all;}
|
|
59
|
-
`},Qx=0,$x=[];function eS(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),i=m.useState(Qx++)[0],a=m.useState(Sx)[0],o=m.useRef(e);m.useEffect(function(){o.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Qb([e.lockRef.current],(e.shards||[]).map(Yx),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=m.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=qx(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Bx(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Bx(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Kx(h,t,e,h===`h`?s:c,!0)},[]),c=m.useCallback(function(e){var n=e;if($x.length&&$x[$x.length-1]===a){var r=`deltaY`in n?Jx(n):qx(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Xx(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Yx).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=m.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:tS(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=m.useCallback(function(e){n.current=qx(e),r.current=void 0},[]),d=m.useCallback(function(t){l(t.type,Jx(t),t.target,s(t,e.lockRef.current))},[]),f=m.useCallback(function(t){l(t.type,qx(t),t.target,s(t,e.lockRef.current))},[]);m.useEffect(function(){return $x.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Fx),document.addEventListener(`touchmove`,c,Fx),document.addEventListener(`touchstart`,u,Fx),function(){$x=$x.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Fx),document.removeEventListener(`touchmove`,c,Fx),document.removeEventListener(`touchstart`,u,Fx)}},[]);var p=e.removeScrollBar,h=e.inert;return m.createElement(m.Fragment,null,h?m.createElement(a,{styles:Zx(i)}):null,p?m.createElement(Mx,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function tS(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var nS=fx(px,eS),rS=m.forwardRef(function(e,t){return m.createElement(hx,Xb({},e,{ref:t,sideCar:nS}))});rS.classNames=hx.classNames;var iS=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},aS=new WeakMap,oS=new WeakMap,sS={},cS=0,lS=function(e){return e&&(e.host||lS(e.parentNode))},uS=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=lS(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},dS=function(e,t,n,r){var i=uS(t,Array.isArray(e)?e:[e]);sS[n]||(sS[n]=new WeakMap);var a=sS[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(aS.get(e)||0)+1,l=(a.get(e)||0)+1;aS.set(e,c),a.set(e,l),o.push(e),c===1&&i&&oS.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),cS++,function(){o.forEach(function(e){var t=aS.get(e)-1,i=a.get(e)-1;aS.set(e,t),a.set(e,i),t||(oS.has(e)||e.removeAttribute(r),oS.delete(e)),i||e.removeAttribute(n)}),cS--,cS||(aS=new WeakMap,aS=new WeakMap,oS=new WeakMap,sS={})}},fS=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||iS(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),dS(r,i,n,`aria-hidden`)):function(){return null}},pS=Object.defineProperty,mS=(e,t)=>pS(e,`name`,{value:t,configurable:!0}),hS=`Dialog`,[gS,_S]=Cy(hS),[vS,yS]=gS(hS),bS=mS(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=m.useRef(null),c=m.useRef(null),[l,u]=Hy({prop:r,defaultProp:i??!1,onChange:a,caller:hS}),[d,f]=m.useState(0),[p,h]=m.useState(0);return(0,U.jsx)(vS,{scope:t,triggerRef:s,contentRef:c,contentId:ob(),titleId:ob(),descriptionId:ob(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:h,open:l,onOpenChange:u,onOpenToggle:m.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),xS=`DialogTrigger`,SS=m.forwardRef(mS(function(e,t){let{__scopeDialog:n,...r}=e,i=yS(xS,n),a=Jv(t,i.triggerRef);return(0,U.jsx)(my.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":HS(i.open),...r,ref:a,onClick:Oy(e.onClick,i.onOpenToggle)})},`DialogTrigger`)),CS=`DialogPortal`,[wS,TS]=gS(CS,{forceMount:void 0}),ES=mS(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=yS(CS,t);return(0,U.jsx)(wS,{scope:t,forceMount:n,children:m.Children.map(r,e=>(0,U.jsx)(Xy,{present:n||a.open,children:(0,U.jsx)(Hb,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),DS=`DialogOverlay`,OS=m.forwardRef(mS(function(e,t){let n=TS(DS,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=yS(DS,e.__scopeDialog);return a.modal?(0,U.jsx)(Xy,{present:r||a.open,children:(0,U.jsx)(AS,{...i,ref:t})}):null},`DialogOverlay`)),kS=Zv(`DialogOverlay.RemoveScroll`),AS=m.forwardRef(mS(function(e,t){let{__scopeDialog:n,...r}=e,i=yS(DS,n),a=Jv(t,vb());return(0,U.jsx)(rS,{as:kS,allowPinchZoom:!0,shards:[i.contentRef],children:(0,U.jsx)(my.div,{"data-state":HS(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),jS=`DialogContent`,MS=m.forwardRef(mS(function(e,t){let n=TS(jS,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=yS(jS,e.__scopeDialog);return(0,U.jsx)(Xy,{present:r||a.open,children:a.modal?(0,U.jsx)(NS,{...i,ref:t}):(0,U.jsx)(PS,{...i,ref:t})})},`DialogContent`)),NS=m.forwardRef(mS(function(e,t){let n=yS(jS,e.__scopeDialog),r=m.useRef(null),i=Jv(t,n.contentRef,r);return m.useEffect(()=>{let e=r.current;if(e)return fS(e)},[]),(0,U.jsx)(FS,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Oy(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Oy(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Oy(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),PS=m.forwardRef(mS(function(e,t){let n=yS(jS,e.__scopeDialog),r=m.useRef(!1),i=m.useRef(!1);return(0,U.jsx)(FS,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),FS=m.forwardRef(mS(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=yS(jS,n);return Jb(),(0,U.jsx)(U.Fragment,{children:(0,U.jsx)(kb,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,U.jsx)(_b,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":HS(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),IS=`DialogTitle`,LS=m.forwardRef(mS(function(e,t){let{__scopeDialog:n,...r}=e,i=yS(IS,n),{setTitleCount:a}=i;return Ny(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,U.jsx)(my.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),RS=`DialogDescription`,zS=m.forwardRef(mS(function(e,t){let{__scopeDialog:n,...r}=e,i=yS(RS,n),{setDescriptionCount:a}=i;return Ny(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,U.jsx)(my.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),BS=`DialogClose`,VS=m.forwardRef(mS(function(e,t){let{__scopeDialog:n,...r}=e,i=yS(BS,n);return(0,U.jsx)(my.button,{type:`button`,...r,ref:t,onClick:Oy(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function HS(e){return e?`open`:`closed`}mS(HS,`getState`);var US=Object.defineProperty,WS=(e,t)=>US(e,`name`,{value:t,configurable:!0}),[GS,KS]=Cy(`AlertDialog`,[_S]),qS=_S(),JS=WS(e=>{let{__scopeAlertDialog:t,...n}=e,r=qS(t);return(0,U.jsx)(bS,{...r,...n,modal:!0})},`AlertDialog`);m.forwardRef(WS(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=qS(n);return(0,U.jsx)(SS,{...i,...r,ref:t})},`AlertDialogTrigger`));var YS=WS(e=>{let{__scopeAlertDialog:t,...n}=e,r=qS(t);return(0,U.jsx)(ES,{...r,...n})},`AlertDialogPortal`),XS=m.forwardRef(WS(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=qS(n);return(0,U.jsx)(OS,{...i,...r,ref:t})},`AlertDialogOverlay`)),[ZS,QS]=GS(`AlertDialogContent`),$S=m.forwardRef(WS(function(e,t){let{__scopeAlertDialog:n,children:r,...i}=e,a=qS(n),o=Jv(t,m.useRef(null)),s=m.useRef(null);return(0,U.jsx)(ZS,{scope:n,cancelRef:s,children:(0,U.jsx)(MS,{role:`alertdialog`,...a,...i,ref:o,onOpenAutoFocus:Oy(i.onOpenAutoFocus,e=>{e.preventDefault(),s.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:r})})},`AlertDialogContent`)),eC=m.forwardRef(WS(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=qS(n);return(0,U.jsx)(LS,{...i,...r,ref:t})},`AlertDialogTitle`)),tC=m.forwardRef(WS(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=qS(n);return(0,U.jsx)(zS,{...i,...r,ref:t})},`AlertDialogDescription`)),nC=m.forwardRef(WS(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=qS(n);return(0,U.jsx)(VS,{...i,...r,ref:t})},`AlertDialogAction`)),rC=`AlertDialogCancel`,iC=m.forwardRef(WS(function(e,t){let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=QS(rC,n),a=qS(n),o=Jv(t,i);return(0,U.jsx)(VS,{...a,...r,ref:o})},`AlertDialogCancel`)),aC=JS,oC=YS,sC=XS,cC=$S,lC=nC,uC=iC,dC=eC,fC=tC,pC=Object.defineProperty,mC=(e,t)=>pC(e,`name`,{value:t,configurable:!0});function hC(e){let[t,n]=m.useState(void 0);return Ny(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}mC(hC,`useSize`);var gC=Object.defineProperty,_C=(e,t)=>gC(e,`name`,{value:t,configurable:!0}),vC=`Checkbox`,[yC,bC]=Cy(vC),[xC,SC]=yC(vC);function CC(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=Hy({prop:n,defaultProp:i??!1,onChange:c,caller:vC}),[h,g]=m.useState(null),[_,v]=m.useState(null),y=m.useRef(!1),[b,x]=m.useReducer(e=>e+1,0),S=!h||!!o||!!h.closest(`form`),C={checked:f,disabled:a,setChecked:p,control:h,setControl:g,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:y,userInteractionCount:b,onUserInteraction:x,required:l,defaultChecked:!MC(i)&&i,isFormControl:S,bubbleInput:_,setBubbleInput:v};return(0,U.jsx)(xC,{scope:t,...C,children:jC(d)?d(C):r})}_C(CC,`CheckboxProvider`);var wC=`CheckboxTrigger`,TC=m.forwardRef(_C(function({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i){let{control:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,onUserInteraction:p,isFormControl:h,bubbleInput:g}=SC(wC,e),_=Jv(i,u),v=m.useRef(c);return m.useEffect(()=>{let e=a?.form;if(e){let t=_C(()=>d(v.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,d]),(0,U.jsx)(my.button,{type:`button`,role:`checkbox`,"aria-checked":MC(c)?`mixed`:c,"aria-required":l,"data-state":NC(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:_,onKeyDown:Oy(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:Oy(n,e=>{p(),d(e=>MC(e)?!0:!e),g&&h&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`CheckboxTrigger`)),EC=m.forwardRef(_C(function(e,t){let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,U.jsx)(CC,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(TC,{...d,ref:t,__scopeCheckbox:n}),e&&(0,U.jsx)(AC,{__scopeCheckbox:n})]})})},`Checkbox`)),DC=`CheckboxIndicator`,OC=m.forwardRef(_C(function(e,t){let{__scopeCheckbox:n,forceMount:r,...i}=e,a=SC(DC,n);return(0,U.jsx)(Xy,{present:r||MC(a.checked)||a.checked===!0,children:(0,U.jsx)(my.span,{"data-state":NC(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})},`CheckboxIndicator`)),kC=`CheckboxBubbleInput`,AC=m.forwardRef(_C(function({__scopeCheckbox:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:u,name:d,value:f,form:p,bubbleInput:h,setBubbleInput:g}=SC(kC,e),_=Jv(r,g),v=hC(i),y=m.useRef(!1),b=m.useRef(s),x=m.useRef(o);m.useEffect(()=>{let e=h;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==x.current;x.current=o;let i=b.current!==s;b.current=s;let c=!(r&&a.current);if(i&&n){y.current=!r;let t=new Event(`click`,{bubbles:c});e.indeterminate=MC(s),n.call(e,!MC(s)&&s),e.dispatchEvent(t),y.current=!1}},[h,s,a,o]);let S=m.useRef(!MC(s)&&s);return(0,U.jsx)(my.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??S.current,required:l,disabled:u,name:d,value:f,form:p,...n,tabIndex:-1,ref:_,onClick:Oy(t,e=>{y.current&&e.stopPropagation()}),style:{...n.style,...v,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`CheckboxBubbleInput`));function jC(e){return typeof e==`function`}_C(jC,`isFunction`);function MC(e){return e===`indeterminate`}_C(MC,`isIndeterminate`);function NC(e){return MC(e)?`indeterminate`:e?`checked`:`unchecked`}_C(NC,`getState`);var PC=[`top`,`right`,`bottom`,`left`],FC=Math.min,IC=Math.max,LC=Math.round,RC=Math.floor,zC=e=>({x:e,y:e}),BC={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function VC(e,t,n){return IC(e,FC(t,n))}function HC(e,t){return typeof e==`function`?e(t):e}function UC(e){return e.split(`-`)[0]}function WC(e){return e.split(`-`)[1]}function GC(e){return e===`x`?`y`:`x`}function KC(e){return e===`y`?`height`:`width`}function qC(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function JC(e){return GC(qC(e))}function YC(e,t,n){n===void 0&&(n=!1);let r=WC(e),i=JC(e),a=KC(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=iw(o)),[o,iw(o)]}function XC(e){let t=iw(e);return[ZC(e),t,ZC(t)]}function ZC(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var QC=[`left`,`right`],$C=[`right`,`left`],ew=[`top`,`bottom`],tw=[`bottom`,`top`];function nw(e,t,n){switch(e){case`top`:case`bottom`:return n?t?$C:QC:t?QC:$C;case`left`:case`right`:return t?ew:tw;default:return[]}}function rw(e,t,n,r){let i=WC(e),a=nw(UC(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(ZC)))),a}function iw(e){let t=UC(e);return BC[t]+e.slice(t.length)}function aw(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function ow(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:aw(e)}function sw(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function cw(e,t,n){let{reference:r,floating:i}=e,a=qC(t),o=JC(t),s=KC(o),c=UC(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=WC(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function lw(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=HC(t,e),p=ow(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=sw(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=sw(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var uw=50,dw=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:lw},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=cw(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<uw&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=cw(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},fw=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=HC(e,t)||{};if(l==null)return{};let d=ow(u),f={x:n,y:r},p=JC(i),m=KC(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=FC(d[_],T),D=FC(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=VC(E,k,O),ee=!c.arrow&&WC(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,j=ee?k<E?k-E:k-O:0;return{[p]:f[p]+j,data:{[p]:A,centerOffset:k-A-j,...ee&&{alignmentOffset:j}},reset:ee}}}),pw=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=HC(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=UC(r),_=qC(o),v=UC(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[iw(o)]:XC(o)),x=p!==`none`;!d&&x&&b.push(...rw(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=YC(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===qC(t)||T.every(e=>qC(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=qC(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function mw(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function hw(e){return PC.some(t=>e[t]>=0)}var gw=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=HC(e,t);switch(i){case`referenceHidden`:{let e=mw(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:hw(e)}}}case`escaped`:{let e=mw(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:hw(e)}}}default:return{}}}}},_w=new Set([`left`,`top`]);async function vw(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=UC(n),s=WC(n),c=qC(n)===`y`,l=_w.has(o)?-1:1,u=a&&c?-1:1,d=HC(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var yw=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await vw(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},bw=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=HC(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=qC(i),p=GC(f),m=u[p],h=u[f],g=(e,t)=>VC(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},xw=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=HC(e,t),u={x:n,y:r},d=qC(i),f=GC(d),p=u[f],m=u[d],h=HC(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=_w.has(UC(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Sw=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=HC(e,t),c=await i.detectOverflow(t,s),l=UC(n),u=WC(n),d=qC(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=FC(p-c[m],g),y=FC(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*IC(c.left,c.right):S=p-2*IC(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function Cw(){return typeof window<`u`}function ww(e){return Dw(e)?(e.nodeName||``).toLowerCase():`#document`}function Tw(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ew(e){return((Dw(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Dw(e){return Cw()?e instanceof Node||e instanceof Tw(e).Node:!1}function Ow(e){return Cw()?e instanceof Element||e instanceof Tw(e).Element:!1}function kw(e){return Cw()?e instanceof HTMLElement||e instanceof Tw(e).HTMLElement:!1}function Aw(e){return!Cw()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Tw(e).ShadowRoot}function jw(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Hw(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Mw(e){return/^(table|td|th)$/.test(ww(e))}function Nw(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Pw=/transform|translate|scale|rotate|perspective|filter/,Fw=/paint|layout|strict|content/,Iw=e=>!!e&&e!==`none`,Lw;function Rw(e){let t=Ow(e)?Hw(e):e;return Iw(t.transform)||Iw(t.translate)||Iw(t.scale)||Iw(t.rotate)||Iw(t.perspective)||!Bw()&&(Iw(t.backdropFilter)||Iw(t.filter))||Pw.test(t.willChange||``)||Fw.test(t.contain||``)}function zw(e){let t=Ww(e);for(;kw(t)&&!Vw(t);){if(Rw(t))return t;if(Nw(t))return null;t=Ww(t)}return null}function Bw(){return Lw??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Lw}function Vw(e){return/^(html|body|#document)$/.test(ww(e))}function Hw(e){return Tw(e).getComputedStyle(e)}function Uw(e){return Ow(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ww(e){if(ww(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Aw(e)&&e.host||Ew(e);return Aw(t)?t.host:t}function Gw(e){let t=Ww(e);return Vw(t)?(e.ownerDocument||e).body:kw(t)&&jw(t)?t:Gw(t)}function Kw(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Gw(e),i=r===e.ownerDocument?.body,a=Tw(r);if(i){let e=qw(a);return t.concat(a,a.visualViewport||[],jw(r)?r:[],e&&n?Kw(e):[])}return t.concat(r,Kw(r,[],n))}function qw(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Jw(e){let t=Hw(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=kw(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=LC(n)!==a||LC(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Yw(e){return Ow(e)?e:e.contextElement}function Xw(e){let t=Yw(e);if(!kw(t))return zC(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Jw(t),o=(a?LC(n.width):n.width)/r,s=(a?LC(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Zw=zC(0);function Qw(e){let t=Tw(e);return!Bw()||!t.visualViewport?Zw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function $w(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Tw(e)}function eT(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Yw(e),o=zC(1);t&&(r?Ow(r)&&(o=Xw(r)):o=Xw(e));let s=$w(a,n,r)?Qw(a):zC(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=Tw(a),t=Ow(r)?Tw(r):r,n=e,i=qw(n);for(;i&&t!==n;){let e=Xw(i),t=i.getBoundingClientRect(),r=Hw(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Tw(i),i=qw(n)}}return sw({width:u,height:d,x:c,y:l})}function tT(e,t){let n=Uw(e).scrollLeft;return t?t.left+n:eT(Ew(e)).left+n}function nT(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-tT(e,n),y:n.top+t.scrollTop}}function rT(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Ew(r),s=t?Nw(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=zC(1),u=zC(0),d=kw(r);if((d||!a)&&((ww(r)!==`body`||jw(o))&&(c=Uw(r)),d)){let e=eT(r);l=Xw(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?nT(o,c):zC(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function iT(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function aT(e){let t=Uw(e),n=e.ownerDocument.body,r=IC(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=IC(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+tT(e),o=-t.scrollTop;return Hw(n).direction===`rtl`&&(a+=IC(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var oT=25;function sT(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Tw(e),a=Ew(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Bw()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(tT(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=oT&&(s-=o)}return{width:s,height:c,x:l,y:u}}function cT(e,t){let n=eT(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Xw(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function lT(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=sT(e,n,t);else if(t===`document`)r=aT(Ew(e));else if(Ow(t))r=cT(t,n);else{let n=Qw(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return sw(r)}function uT(e,t){let n=t.get(e);if(n)return n;let r=Kw(e,[],!1).filter(e=>Ow(e)&&ww(e)!==`body`),i=null,a=Hw(e).position===`fixed`,o=a?Ww(e):e;for(;Ow(o)&&!Vw(o);){let e=Hw(o),t=Rw(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Ww(o)}return t.set(e,r),r}function dT(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Nw(t)?[]:uT(t,this._c):[].concat(n),r],o=lT(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=lT(t,a[e],i);s=IC(n.top,s),c=FC(n.right,c),l=FC(n.bottom,l),u=IC(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function fT(e){let{width:t,height:n}=Jw(e);return{width:t,height:n}}function pT(e,t,n){let r=kw(t),i=Ew(t),a=n===`fixed`,o=eT(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=zC(0);if((r||!a)&&((ww(t)!==`body`||jw(i))&&(s=Uw(t)),r)){let e=eT(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=tT(i));let l=i&&!r&&!a?nT(i,s):zC(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function mT(e){return Hw(e).position===`static`}function hT(e,t){if(!kw(e)||Hw(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Ew(e)===n&&(n=n.ownerDocument.body),n}function gT(e,t){let n=Tw(e);if(Nw(e))return n;if(!kw(e)){let t=Ww(e);for(;t&&!Vw(t);){if(Ow(t)&&!mT(t))return t;t=Ww(t)}return n}let r=hT(e,t);for(;r&&Mw(r)&&mT(r);)r=hT(r,t);return r&&Vw(r)&&mT(r)&&!Rw(r)?n:r||zw(e)||n}var _T=async function(e){let t=this.getOffsetParent||gT,n=this.getDimensions,r=await n(e.floating);return{reference:pT(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function vT(e){return Hw(e).direction===`rtl`}var yT={convertOffsetParentRelativeRectToViewportRelativeRect:rT,getDocumentElement:Ew,getClippingRect:dT,getOffsetParent:gT,getElementRects:_T,getClientRects:iT,getDimensions:fT,getScale:Xw,isElement:Ow,isRTL:vT};function bT(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function xT(e,t,n){let r=null,i,a=Ew(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=RC(d),h=RC(a.clientWidth-(u+f)),g=RC(a.clientHeight-(d+p)),_=RC(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:IC(0,FC(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!bT(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=Tw(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function ST(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Yw(e),u=i||a?[...l?Kw(l):[],...t?Kw(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?xT(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?eT(e):null;c&&g();function g(){let t=eT(e);h&&!bT(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var CT=yw,wT=bw,TT=pw,ET=Sw,DT=gw,OT=fw,kT=xw,AT=(e,t,n)=>{let r=new Map,i=n??{},a={...yT,...i.platform,_c:r};return dw(e,t,{...i,platform:a})},jT=typeof document<`u`?m.useLayoutEffect:function(){};function MT(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!MT(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!MT(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function NT(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function PT(e,t){let n=NT(e);return Math.round(t*n)/n}function FT(e){let t=m.useRef(e);return jT(()=>{t.current=e}),t}function IT(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=m.useState(r);MT(f,r)||p(r);let[h,g]=m.useState(null),[_,v]=m.useState(null),y=m.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=m.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=m.useRef(null),w=m.useRef(null),T=m.useRef(u),E=c!=null,D=FT(c),O=FT(i),k=FT(l),A=m.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),AT(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};ee.current&&!MT(T.current,t)&&(T.current=t,dy.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);jT(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let ee=m.useRef(!1);jT(()=>(ee.current=!0,()=>{ee.current=!1}),[]),jT(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let j=m.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),M=m.useMemo(()=>({reference:x,floating:S}),[x,S]),te=m.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=PT(M.floating,u.x),r=PT(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...NT(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:A,refs:j,elements:M,floatingStyles:te}),[u,A,j,M,te])}var LT=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:OT({element:r.current,padding:i}).fn(n):r?OT({element:r,padding:i}).fn(n):{}}}},RT=(e,t)=>{let n=CT(e);return{name:n.name,fn:n.fn,options:[e,t]}},zT=(e,t)=>{let n=wT(e);return{name:n.name,fn:n.fn,options:[e,t]}},BT=(e,t)=>({fn:kT(e).fn,options:[e,t]}),VT=(e,t)=>{let n=TT(e);return{name:n.name,fn:n.fn,options:[e,t]}},HT=(e,t)=>{let n=ET(e);return{name:n.name,fn:n.fn,options:[e,t]}},UT=(e,t)=>{let n=DT(e);return{name:n.name,fn:n.fn,options:[e,t]}},WT=(e,t)=>{let n=LT(e);return{name:n.name,fn:n.fn,options:[e,t]}},GT=Object.defineProperty,KT=(e,t)=>GT(e,`name`,{value:t,configurable:!0}),qT=`Popper`,[JT,YT]=Cy(qT),[XT,ZT]=JT(qT),QT=KT(e=>{let{__scopePopper:t,children:n}=e,[r,i]=m.useState(null),[a,o]=m.useState(void 0);return(0,U.jsx)(XT,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),$T=`PopperAnchor`,eE=m.forwardRef(KT(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=ZT($T,n),o=m.useRef(null),s=a.onAnchorChange,c=Jv(t,m.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=m.useRef(null);m.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&sE(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,U.jsx)(my.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),tE=`PopperContent`,[nE,rE]=JT(tE),iE=m.forwardRef(KT(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:h,...g}=e,_=ZT(tE,n),[v,y]=m.useState(null),b=Jv(t,y),[x,S]=m.useState(null),C=hC(x),w=C?.width??0,T=C?.height??0,E=r+(a===`center`?``:`-`+a),D=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},O=Array.isArray(l)?l:[l],k=O.length>0,A={padding:D,boundary:O.filter(aE),altBoundary:k},{refs:ee,floatingStyles:j,placement:M,isPositioned:te,middlewareData:N}=IT({strategy:`fixed`,placement:E,whileElementsMounted:KT((...e)=>ST(...e,{animationFrame:p===`always`}),`whileElementsMounted`),elements:{reference:_.anchor},middleware:[RT({mainAxis:i+T,alignmentAxis:o}),c&&zT({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?BT():void 0,...A}),c&&VT({...A}),HT({...A,apply:KT(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),x&&WT({element:x,padding:s}),oE({arrowWidth:w,arrowHeight:T}),f&&UT({strategy:`referenceHidden`,...A,boundary:k?A.boundary:void 0})]}),P=_.setPlacementState;Ny(()=>(P(M),()=>{P(void 0)}),[M,P]);let[ne,re]=sE(M),ie=lb(h);Ny(()=>{te&&ie?.()},[te,ie]);let ae=N.arrow?.x,oe=N.arrow?.y,se=N.arrow?.centerOffset!==0,[ce,le]=m.useState();return Ny(()=>{v&&le(window.getComputedStyle(v).zIndex)},[v]),(0,U.jsx)(`div`,{ref:ee.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:te?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ce,"--radix-popper-transform-origin":[N.transformOrigin?.x,N.transformOrigin?.y].join(` `),...N.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,U.jsx)(nE,{scope:n,placedSide:ne,placedAlign:re,onArrowChange:S,arrowX:ae,arrowY:oe,shouldHideArrow:se,children:(0,U.jsx)(my.div,{"data-side":ne,"data-align":re,...g,ref:b,style:{...g.style,animation:te?g.style?.animation:`none`}})})})},`PopperContent`));function aE(e){return e!==null}KT(aE,`isNotNull`);var oE=KT(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=sE(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function sE(e){let[t,n=`center`]=e.split(`-`);return[t,n]}KT(sE,`getSideAndAlignFromPlacement`);var cE=QT,lE=eE,uE=iE,dE=Object.defineProperty,fE=(e,t)=>dE(e,`name`,{value:t,configurable:!0}),pE=`Popover`,[mE,hE]=Cy(pE,[YT]),gE=YT(),[_E,vE]=mE(pE),yE=fE(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=gE(t),c=m.useRef(null),[l,u]=m.useState(!1),[d,f]=Hy({prop:r,defaultProp:i??!1,onChange:a,caller:pE});return(0,U.jsx)(cE,{...s,children:(0,U.jsx)(_E,{scope:t,contentId:ob(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:m.useCallback(()=>u(!0),[]),onCustomAnchorRemove:m.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),bE=`PopoverTrigger`,xE=m.forwardRef(fE(function(e,t){let{__scopePopover:n,...r}=e,i=vE(bE,n),a=gE(n),o=Jv(t,i.triggerRef),s=(0,U.jsx)(my.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":ME(i.open),...r,ref:o,onClick:Oy(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,U.jsx)(lE,{asChild:!0,...a,children:s})},`PopoverTrigger`)),SE=`PopoverPortal`,[CE,wE]=mE(SE,{forceMount:void 0}),TE=fE(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=vE(SE,t);return(0,U.jsx)(CE,{scope:t,forceMount:n,children:(0,U.jsx)(Xy,{present:n||a.open,children:(0,U.jsx)(Hb,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),EE=`PopoverContent`,DE=m.forwardRef(fE(function(e,t){let n=wE(EE,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=vE(EE,e.__scopePopover);return(0,U.jsx)(Xy,{present:r||a.open,children:a.modal?(0,U.jsx)(kE,{...i,ref:t}):(0,U.jsx)(AE,{...i,ref:t})})},`PopoverContent`)),OE=Zv(`PopoverContent.RemoveScroll`),kE=m.forwardRef(fE(function(e,t){let n=vE(EE,e.__scopePopover),r=m.useRef(null),i=Jv(t,r),a=m.useRef(!1);return m.useEffect(()=>{let e=r.current;if(e)return fS(e)},[]),(0,U.jsx)(rS,{as:OE,allowPinchZoom:!0,children:(0,U.jsx)(jE,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Oy(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Oy(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:Oy(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),AE=m.forwardRef(fE(function(e,t){let n=vE(EE,e.__scopePopover),r=m.useRef(!1),i=m.useRef(!1);return(0,U.jsx)(jE,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),jE=m.forwardRef(fE(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=vE(EE,n),p=gE(n);return Jb(),(0,U.jsx)(kb,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,U.jsx)(_b,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,U.jsx)(uE,{"data-state":ME(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})},`PopoverContentImpl`));function ME(e){return e?`open`:`closed`}fE(ME,`getState`);var NE=yE,PE=xE,FE=TE,IE=DE,LE=Object.defineProperty,RE=(e,t)=>LE(e,`name`,{value:t,configurable:!0}),zE=`Switch`,[BE,VE]=Cy(zE),[HE,UE]=BE(zE);function WE(e){let{__scopeSwitch:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=Hy({prop:n,defaultProp:i??!1,onChange:c,caller:zE}),[h,g]=m.useState(null),[_,v]=m.useState(null),y=m.useRef(!1),[b,x]=m.useReducer(e=>e+1,0),S={checked:f,setChecked:p,disabled:a,control:h,setControl:g,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:y,userInteractionCount:b,onUserInteraction:x,required:l,defaultChecked:i,isFormControl:!h||!!o||!!h.closest(`form`),bubbleInput:_,setBubbleInput:v};return(0,U.jsx)(HE,{scope:t,...S,children:QE(d)?d(S):r})}RE(WE,`SwitchProvider`);var GE=`SwitchTrigger`,KE=m.forwardRef(RE(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,form:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,onUserInteraction:p,isFormControl:h,bubbleInput:g}=UE(GE,e),_=Jv(r,u),v=m.useRef(c);return m.useEffect(()=>{let e=a?i?.ownerDocument.getElementById(a):i?.form;if(e instanceof HTMLFormElement){let t=RE(()=>d(v.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[i,a,d]),(0,U.jsx)(my.button,{type:`button`,role:`switch`,"aria-checked":c,"aria-required":l,"data-state":$E(c),"data-disabled":s?``:void 0,disabled:s,value:o,...n,ref:_,onClick:Oy(t,e=>{p(),d(e=>!e),g&&h&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`SwitchTrigger`)),qE=m.forwardRef(RE(function(e,t){let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,U.jsx)(WE,{__scopeSwitch:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(KE,{...d,ref:t,__scopeSwitch:n}),e&&(0,U.jsx)(ZE,{__scopeSwitch:n})]})})},`Switch`)),JE=`SwitchThumb`,YE=m.forwardRef(RE(function(e,t){let{__scopeSwitch:n,...r}=e,i=UE(JE,n);return(0,U.jsx)(my.span,{"data-state":$E(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})},`SwitchThumb`)),XE=`SwitchBubbleInput`,ZE=m.forwardRef(RE(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:u,name:d,value:f,form:p,bubbleInput:h,setBubbleInput:g}=UE(XE,e),_=Jv(r,g),v=hC(i),y=m.useRef(!1),b=m.useRef(s),x=m.useRef(o);m.useEffect(()=>{let e=h;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==x.current;x.current=o;let i=b.current!==s;b.current=s;let c=!(r&&a.current);if(i&&n){y.current=!r;let t=new Event(`click`,{bubbles:c});n.call(e,s),e.dispatchEvent(t),y.current=!1}},[h,s,a,o]);let S=m.useRef(s);return(0,U.jsx)(my.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??S.current,required:l,disabled:u,name:d,value:f,form:p,...n,tabIndex:-1,ref:_,onClick:Oy(t,e=>{y.current&&e.stopPropagation()}),style:{...n.style,...v,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`SwitchBubbleInput`));function QE(e){return typeof e==`function`}RE(QE,`isFunction`);function $E(e){return e?`checked`:`unchecked`}RE($E,`getState`);var eD=Object.defineProperty,tD=(e,t)=>eD(e,`name`,{value:t,configurable:!0}),[nD,rD]=Cy(`Tooltip`,[YT]),iD=YT(),aD=`TooltipProvider`,oD=700,sD=`tooltip.open`,[cD,lD]=nD(aD),uD=tD(e=>{let{__scopeTooltip:t,delayDuration:n=oD,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=m.useRef(!0),s=m.useRef(!1),c=m.useRef(0);return m.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,U.jsx)(cD,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:m.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:m.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:m.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),dD=`Tooltip`,[fD,pD]=nD(dD),mD=tD(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=lD(dD,e.__scopeTooltip),l=iD(t),[u,d]=m.useState(null),[f,p]=m.useState(void 0),h=ob(),g=m.useRef(0),_=o??c.disableHoverableContent,v=s??c.delayDuration,y=m.useRef(!1),[b,x]=Hy({prop:r,defaultProp:i??!1,onChange:tD(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(sD))):c.onClose(),a?.(e)},`onChange`),caller:dD}),S=m.useMemo(()=>b?y.current?`delayed-open`:`instant-open`:`closed`,[b]),C=m.useCallback(()=>{window.clearTimeout(g.current),g.current=0,y.current=!1,x(!0)},[x]),w=m.useCallback(()=>{window.clearTimeout(g.current),g.current=0,x(!1)},[x]),T=m.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{y.current=!0,x(!0),g.current=0},v)},[v,x]);m.useEffect(()=>()=>{g.current&&=(window.clearTimeout(g.current),0)},[]);let E=f??h;return(0,U.jsx)(cE,{...l,children:(0,U.jsx)(fD,{scope:t,contentId:E,setContentId:p,open:b,stateAttribute:S,trigger:u,onTriggerChange:d,onTriggerEnter:m.useCallback(()=>{c.isOpenDelayedRef.current?T():C()},[c.isOpenDelayedRef,T,C]),onTriggerLeave:m.useCallback(()=>{_?w():(window.clearTimeout(g.current),g.current=0)},[w,_]),onOpen:C,onClose:w,disableHoverableContent:_,children:n})})},`Tooltip`),hD=`TooltipTrigger`,gD=m.forwardRef(tD(function(e,t){let{__scopeTooltip:n,...r}=e,i=pD(hD,n),a=lD(hD,n),o=iD(n),s=Jv(t,m.useRef(null),i.onTriggerChange),c=m.useRef(!1),l=m.useRef(!1),u=m.useCallback(()=>c.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,U.jsx)(lE,{asChild:!0,...o,children:(0,U.jsx)(my.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:Oy(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:Oy(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:Oy(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:Oy(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Oy(e.onBlur,i.onClose),onClick:Oy(e.onClick,i.onClose)})})},`TooltipTrigger`)),_D=`TooltipPortal`,[vD,yD]=nD(_D,{forceMount:void 0}),bD=tD(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=pD(_D,t);return(0,U.jsx)(vD,{scope:t,forceMount:n,children:(0,U.jsx)(Xy,{present:n||a.open,children:(0,U.jsx)(Hb,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),xD=`TooltipContent`,SD=m.forwardRef(tD(function(e,t){let n=yD(xD,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=pD(xD,e.__scopeTooltip);return(0,U.jsx)(Xy,{present:r||o.open,children:o.disableHoverableContent?(0,U.jsx)(TD,{side:i,...a,ref:t}):(0,U.jsx)(CD,{side:i,...a,ref:t})})},`TooltipContent`)),CD=m.forwardRef(tD(function(e,t){let n=pD(xD,e.__scopeTooltip),r=lD(xD,e.__scopeTooltip),i=m.useRef(null),a=Jv(t,i),[o,s]=m.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=m.useCallback(()=>{s(null),d(!1)},[d]),p=m.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=DD(r,ED(r,n.getBoundingClientRect())),a=OD(t.getBoundingClientRect()),o=AD([...i,...a]);s(o),d(!0)},[d]);return m.useEffect(()=>()=>f(),[f]),m.useEffect(()=>{if(c&&u){let e=tD(e=>p(e,u),`handleTriggerLeave`),t=tD(e=>p(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),m.useEffect(()=>{if(o){let e=tD(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!kD(n,o);r?f():i&&(f(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,U.jsx)(TD,{...e,ref:a})},`TooltipContentHoverable`)),wD=ey(`TooltipContent`),TD=m.forwardRef(tD(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=pD(xD,n),u=iD(n),{onClose:d}=l;m.useEffect(()=>(document.addEventListener(sD,d),()=>document.removeEventListener(sD,d)),[d]),m.useEffect(()=>{if(l.trigger){let e=tD(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:f}=l;return Ny(()=>(f(a),()=>{f(void 0)}),[a,f]),(0,U.jsx)(_b,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,U.jsxs)(uE,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,U.jsx)(wD,{children:r}),i?(0,U.jsx)(yy,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`));function ED(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}tD(ED,`getExitSideFromRect`);function DD(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}tD(DD,`getPaddedExitPoints`);function OD(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}tD(OD,`getPointsFromRect`);function kD(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}tD(kD,`isPointInPolygon`);function AD(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),jD(t)}tD(AD,`getHull`);function jD(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}tD(jD,`getHullPresorted`);var MD=uD,ND=mD,PD=gD,FD=bD,ID=SD,LD=Uv(`group/button motion-reduce:transition-none motion-reduce:active:scale-100 inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-[scale,background-color,box-shadow,color,border-color] duration-150 active:not-aria-[haspopup]:scale-[0.97] ease-snap outline-none select-none focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`btn-tint text-primary-foreground [--tint:var(--primary)] disabled:text-muted-foreground`,soft:`btn-soft text-foreground`,outline:`btn-outline text-foreground [&_svg]:text-muted-foreground`,secondary:`btn-soft text-secondary-foreground`,ghost:`btn-ghost text-foreground [&_svg]:text-muted-foreground hover:[&_svg]:text-foreground`,destructive:`btn-tint text-white [--tint:var(--destructive)] focus-visible:outline-destructive disabled:text-muted-foreground dark:text-background`,link:`text-link underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-3`,xs:`h-7 gap-1 px-2.5 text-xs [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1.5 px-2.5 text-xs [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-2 px-4`,icon:`size-8`,"icon-xs":`size-7 [&_svg:not([class*='size-'])]:size-3.5`,"icon-sm":`size-7`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function X({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){let a=r?Qv:`button`;return(0,U.jsx)(a,{"aria-keyshortcuts":r?void 0:`Enter Space`,"aria-description":r?`When focused, press Enter to activate.`:`When focused, press Enter or Space to activate.`,"aria-describedby":`focused-action-help`,"data-slot":`button`,"data-variant":t,"data-size":n,className:Y(LD({variant:t,size:n,className:e})),...i})}var RD=Y(`pointer-events-none inline-flex h-[1.125rem] min-w-[1.125rem] w-fit items-center justify-center gap-1 rounded-[4px] bg-accent px-1 font-sans text-2xs leading-none font-medium text-muted-foreground select-none`,`in-data-[slot=tooltip-content]:bg-accent in-data-[slot=tooltip-content]:text-muted-foreground`,`in-data-[variant=default]:bg-primary-foreground/16 in-data-[variant=default]:text-primary-foreground`,`in-data-[variant=destructive]:bg-white/16 in-data-[variant=destructive]:text-current`,`[&_svg:not([class*='size-'])]:size-3`);function zD({className:e,...t}){return(0,U.jsx)(`kbd`,{"data-slot":`kbd`,className:Y(RD,e),...t})}function BD({className:e,...t}){return(0,U.jsx)(`kbd`,{"data-slot":`kbd-group`,className:Y(`inline-flex items-center gap-0.5`,e),...t})}var VD=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),HD={alt:`⌥`,ctrl:`⌃`,shift:`⇧`,meta:`⌘`,cmd:`⌘`},UD={enter:`↵`,esc:`Esc`,escape:`Esc`,arrowleft:`←`,arrowright:`→`,arrowup:`↑`,arrowdown:`↓`,space:`Space`,delete:`Del`,backspace:`⌫`};function WD(e){return e.split(`+`).map(e=>{let t=e.toLowerCase();return VD&&HD[t]?HD[t]:UD[t]??(e.length===1?e.toUpperCase():e[0].toUpperCase()+e.slice(1))})}function GD({chord:e,className:t}){let n=WD(e);return(0,U.jsx)(BD,{className:t,children:n.map((e,t)=>(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[t>0?(0,U.jsx)(`span`,{className:`sr-only`,children:`plus`}):null,(0,U.jsx)(zD,{children:e})]},t))})}function KD({chord:e,children:t,className:n}){return(0,U.jsxs)(`span`,{className:Y(`kbd-hint inline-flex shrink-0 items-center gap-1.5 text-xs whitespace-nowrap text-muted-foreground`,n),children:[(0,U.jsx)(GD,{chord:e}),t]})}function qD({open:e,onOpenChange:t,label:n,description:r,dismissOnBackdrop:i=!0,className:a,style:o,onCloseAutoFocus:s,onEscapeKeyDown:c,children:l}){let u=Ef();return(0,U.jsx)(bS,{open:e,onOpenChange:t,children:(0,U.jsx)(ju,{children:e?(0,U.jsxs)(ES,{forceMount:!0,children:[(0,U.jsx)(OS,{asChild:!0,forceMount:!0,children:(0,U.jsx)(Xf.div,{className:`fixed inset-0 z-50 bg-scrim backdrop-blur-sm`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16,ease:`easeOut`}})}),(0,U.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-50 grid place-items-center p-4`,children:(0,U.jsx)(MS,{asChild:!0,forceMount:!0,onCloseAutoFocus:s,...c?{onEscapeKeyDown:c}:{},onInteractOutside:e=>{i||e.preventDefault()},onOpenAutoFocus:e=>{let t=e.currentTarget?.querySelector(`[data-nav], [data-autofocus], textarea`);t&&(e.preventDefault(),t.focus())},...r?{}:{"aria-describedby":void 0},children:(0,U.jsxs)(Xf.div,{className:Y(`glass-pop pointer-events-auto flex max-h-[min(86svh,48rem)] w-full max-w-2xl flex-col overflow-hidden rounded-2xl outline-none`,a),style:o,initial:{opacity:0,scale:u?1:.98,y:u?0:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:u?1:.98,transition:{duration:.15,ease:`easeIn`}},transition:{duration:.2,ease:[.32,.72,0,1]},children:[(0,U.jsx)(LS,{className:`sr-only`,children:n}),r?(0,U.jsx)(zS,{className:`sr-only`,children:r}):null,l]})})})]}):null})})}var JD=[],YD=0,XD=new Set;function ZD(){for(let e of[...XD])e()}function QD(e){return XD.add(e),()=>{XD.delete(e)}}function $D(){let e;for(let t of JD)(!e||t.priority>e.priority||t.priority===e.priority&&t.order<e.order)&&(e=t);return e?.id}var eO={question:30,confirm:20,help:10,sheet:5};function tO(e,t){let n=(0,m.useId)();(0,m.useEffect)(()=>{if(e)return JD=[...JD,{id:n,priority:t,order:++YD}],ZD(),()=>{JD=JD.filter(e=>e.id!==n),ZD()}},[e,t,n]);let r=(0,m.useSyncExternalStore)(QD,$D,()=>void 0);return e&&r===n}function nO(){return JD.length>0}function rO(){return(0,m.useSyncExternalStore)(QD,()=>JD.length>0,()=>!1)}function iO(){let[e,t]=(0,m.useReducer)(e=>e+1,0);return(0,m.useEffect)(()=>F.subscribe(t),[]),e}function aO(){return iO(),F.status()}function oO(e){return iO(),F.get(e)}function sO(e){let t=(0,m.useCallback)(t=>{let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},[e]),n=(0,m.useCallback)(()=>window.matchMedia(e).matches,[e]);return(0,m.useSyncExternalStore)(t,n)}function cO(e){let t=(0,m.useRef)(null),n=(0,m.useRef)(!0),[r,i]=(0,m.useState)(!0),a=(0,m.useRef)(void 0),o=(0,m.useRef)(null),s=(0,m.useCallback)(()=>{n.current=!0,i(!0);let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[]);return(0,m.useLayoutEffect)(()=>{n.current&&s()},[e,s]),(0,m.useLayoutEffect)(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{n.current&&(e.scrollTop=e.scrollHeight)});return r.observe(e),a.current=r,()=>{r.disconnect(),a.current=void 0,o.current=null}},[]),(0,m.useLayoutEffect)(()=>{let e=a.current,n=t.current?.firstElementChild??null;e&&n!==o.current&&(o.current&&e.unobserve(o.current),n&&e.observe(n),o.current=n)},[e]),{ref:t,atBottom:r,stick:s,onScroll:(0,m.useCallback)(()=>{let e=t.current;e&&(n.current=e.scrollHeight-e.scrollTop-e.clientHeight<48,i(n.current))},[])}}var lO={DEV:Tm,DESIGN:Vh,QA:Dg,RESEARCH:Vg,SCOUT:jm,PLANNER:_g,CLASSIFIER:zg,LOBBY:Nh,LINT:hh};function uO(e){return e?lO[e.toUpperCase()]??Yp:Zp}function dO({className:e,strokeWidth:t=2,source:n}){return(0,U.jsxs)(`svg`,{"aria-hidden":`true`,"data-agent-icon":n,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:t,strokeLinecap:`round`,strokeLinejoin:`round`,className:Y(`agent-oracle shrink-0`,e),children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`10`,r:`7`}),(0,U.jsx)(`path`,{d:`M8.5 7.5a4 4 0 0 1 3-2`}),(0,U.jsx)(`path`,{d:`M8 16.2 6.5 20h11L16 16.2`}),(0,U.jsx)(`path`,{d:`M5 20h14`})]})}function fO(e){let t=e?.toUpperCase();return t===`ORACLE`||t===`MASTER`}function pO({source:e,className:t,strokeWidth:n}){if(fO(e))return(0,U.jsx)(dO,{source:e,className:t,strokeWidth:n});let r=uO(e);return(0,U.jsx)(r,{"aria-hidden":`true`,"data-agent-icon":e??`thinking`,strokeWidth:n,className:Y(`shrink-0`,t)})}function mO(e){return e.role===`you`||e.role===`note`?e.role:e.role===`panel`?`PLANNER`:e.agent??`MASTER`}var hO={MASTER:`text-primary`,DEV:`text-source-dev`,DESIGN:`text-source-design`,QA:`text-source-qa`,RESEARCH:`text-source-research`,SCOUT:`text-source-scout`,ORACLE:`text-primary`,LOBBY:`text-muted-foreground`};function gO(e){return e.length<=2?e:e.charAt(0)+e.slice(1).toLowerCase()}function _O(e){return hO[e]??`text-muted-foreground`}var vO={MASTER:`var(--primary)`,DEV:`var(--source-dev)`,DESIGN:`var(--source-design)`,QA:`var(--source-qa)`,RESEARCH:`var(--source-research)`,SCOUT:`var(--source-scout)`,ORACLE:`var(--primary)`,LOBBY:`var(--muted-foreground)`};function yO(e){return vO[e]??`var(--muted-foreground)`}function bO(e){if(e.role===`researcher`)return`RESEARCH`;let t=e.domain??e.role;return t===`backend`||t===`dev`?`DEV`:t===`designer`||t===`design`?`DESIGN`:t===`researcher`||t===`research`?`RESEARCH`:t===`qa`?`QA`:t?String(t).toUpperCase():`AGENT`}function xO(e){return e?.runs??[]}function SO(e,t=40){let n=new Map;for(let t of e)n.set(t.source,t);return[...n.values()].sort((e,t)=>e.at-t.at).slice(-t)}function CO({source:e,name:t,time:n,head:r,live:i,children:a,aside:o,named:s,waiting:c}){let l=c||r&&(s||!fO(e));return(0,U.jsxs)(`div`,{className:`chat-agent group/msg`,"data-live":i||void 0,style:i?{"--orb":yO(e)}:void 0,children:[l||o?(0,U.jsxs)(`p`,{className:`chat-speaker`,children:[l?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-medium text-foreground`,style:{"--orb":yO(e)},children:[(0,U.jsx)(pO,{source:e,strokeWidth:2.25,className:`size-3.5 text-[color-mix(in_oklab,var(--orb)_85%,var(--foreground))]`}),c?(0,U.jsx)(EO,{text:t}):t]}):null,l&&n?(0,U.jsx)(`time`,{className:`text-xs text-muted-foreground tabular-nums`,children:n}):null,o?(0,U.jsx)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:o}):null]}):null,c?null:(0,U.jsx)(`div`,{className:`chat-prose`,children:a}),n&&!l?(0,U.jsx)(`time`,{className:`chat-meta`,children:n}):null]})}function wO({time:e,head:t,note:n,children:r,below:i,actions:a}){return(0,U.jsxs)(`div`,{className:`group/msg flex flex-col items-end gap-1`,children:[(0,U.jsx)(`div`,{className:`chat-bubble`,children:r}),e||n||a?(0,U.jsxs)(`div`,{className:`chat-meta flex items-center gap-2`,"data-note":n?``:void 0,children:[a,n?(0,U.jsx)(`span`,{children:n}):null,e?(0,U.jsx)(`time`,{className:`tabular-nums`,children:e}):null]}):null,i]})}function TO({failed:e,auto:t,children:n}){return(0,U.jsx)(`div`,{role:`note`,className:Y(`chat-note`,e&&`text-destructive`,t&&`chat-note-auto`),children:(0,U.jsx)(`span`,{children:n})})}function EO({text:e}){return(0,U.jsxs)(`span`,{className:`activity-shimmer`,children:[(0,U.jsx)(`span`,{className:`sr-only`,children:e}),[...e].map((e,t)=>(0,U.jsx)(`span`,{"aria-hidden":`true`,style:{"--i":t},children:e},t))]})}function DO({onClick:e,className:t}){return(0,U.jsx)(`button`,{type:`button`,"aria-label":`Jump to latest`,title:`Jump to latest`,onClick:e,className:Y(`jump-latest btn-outline grid size-9 place-items-center rounded-full border bg-card text-foreground shadow-card outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t),children:(0,U.jsx)(Np,{"aria-hidden":`true`,className:`size-4`})})}var OO=8;function kO(e){return e?e.path===`fast`?`fast track (${e.size})`:`full workflow (${e.size})`:``}function AO(e,t){let n=Math.min(t,OO);if(n<=0)return[];let r=Math.min(n,Math.round(Math.max(0,e)/t*n));return Array.from({length:n},(e,t)=>t<r)}function jO({done:e,total:t}){return(0,U.jsx)(`span`,{className:`inline-flex items-center gap-0.5`,"aria-hidden":`true`,children:AO(e,t).map((e,t)=>(0,U.jsx)(`span`,{className:Y(`h-1.5 w-3 rounded-full`,e?`bg-primary`:`bg-muted-foreground/25`)},t))})}function MO({check:e,className:t}){return(0,U.jsx)(e===`done`?dm:e===`dropped`?xm:Cm,{"aria-hidden":`true`,className:Y(`size-4 shrink-0`,e===`done`?`text-success`:`text-muted-foreground`,t)})}var NO=`auto mode`;function PO(){return(0,U.jsx)(`span`,{className:`auto-mode-text`,children:NO})}function FO({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`empty`,className:Y(`flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 p-6 text-center text-balance`,e),...t})}function IO({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`empty-header`,className:Y(`flex max-w-sm flex-col items-center gap-2`,e),...t})}var LO=Uv(`mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{default:`bg-transparent`,icon:`relative flex size-9 shrink-0 items-center justify-center rounded-md border bg-card text-foreground shadow-sm/5 [&_svg:not([class*='size-'])]:size-4.5`}},defaultVariants:{variant:`default`}});function RO({className:e,variant:t=`default`,...n}){return(0,U.jsx)(`div`,{"data-slot":`empty-icon`,"data-variant":t,className:Y(LO({variant:t,className:e})),...n})}function zO({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`empty-title`,className:Y(`text-[1.0625rem] leading-6 font-medium`,e),...t})}function BO({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`empty-description`,className:Y(`text-[0.8125rem] leading-[1.125rem] text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function VO(e){return e<10?`0${e}`:String(e)}function HO(e){if(!Number.isFinite(e))return`0`;let t=new Date(e);return`${VO(t.getHours())}:${VO(t.getMinutes())}`}function UO(e){if(!Number.isFinite(e)||e<5e3)return`now`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<48?`${r}h`:`${Math.floor(r/24)}d`}function WO(e){let t=UO(e);return t===`now`?`just now`:`${t} ago`}function GO({title:e,note:t,className:n,children:r,collapsed:i,onToggle:a,shortcut:o,...s}){let c=typeof e==`string`?e:`pane`;return(0,U.jsxs)(`section`,{className:Y(`workspace-frame group/frame relative flex min-h-0 min-w-0 flex-col rounded-xl border shadow-xs`,i&&`flex-none`,n),...s,children:[e||t||a?(0,U.jsxs)(`div`,{className:Y(`flex min-h-12 shrink-0 items-center justify-between gap-3 px-4`,!i&&`border-b border-border`),children:[e?(0,U.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-medium`,children:e}):(0,U.jsx)(`span`,{}),(0,U.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,U.jsx)(`span`,{className:`flex items-center gap-2 truncate text-xs text-muted-foreground`,children:t}):null,a?(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":!i,"aria-label":i?`Expand ${c}`:`Minimize ${c}`,title:`${i?`Expand`:`Minimize`}${o?` · ${o}`:``}`,"aria-keyshortcuts":o?`${o} Enter Space`:`Enter Space`,"aria-describedby":`focused-action-help`,onClick:a,className:`btn-ghost -mr-1.5 inline-flex h-8 items-center gap-1.5 rounded-lg border border-transparent px-2 text-muted-foreground transition-[box-shadow,color,scale] duration-150 ease-snap outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:scale-[0.97] motion-reduce:active:scale-100`,children:[o?(0,U.jsx)(GD,{chord:o,className:`kbd-hint`}):null,(0,U.jsx)(tm,{"aria-hidden":`true`,className:Y(`size-4 transition-transform duration-200 ease-snap`,i&&`-rotate-90`)})]}):null]})]}):null,i?null:r]})}function KO({title:e,right:t,className:n}){return(0,U.jsxs)(`span`,{className:Y(`flex min-w-0 items-center gap-3`,n),children:[(0,U.jsx)(`span`,{className:`truncate font-medium`,children:e}),(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`}),t?(0,U.jsx)(`span`,{className:`shrink-0 text-xs font-normal text-muted-foreground`,children:t}):null]})}var qO=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,JO=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,YO={};function XO(e,t){return((t||YO).jsx?JO:qO).test(e)}var ZO={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},QO=n(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
59
|
+
`},Qx=0,$x=[];function eS(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),i=m.useState(Qx++)[0],a=m.useState(Sx)[0],o=m.useRef(e);m.useEffect(function(){o.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Qb([e.lockRef.current],(e.shards||[]).map(Yx),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=m.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=qx(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Bx(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Bx(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Kx(h,t,e,h===`h`?s:c,!0)},[]),c=m.useCallback(function(e){var n=e;if($x.length&&$x[$x.length-1]===a){var r=`deltaY`in n?Jx(n):qx(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Xx(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Yx).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=m.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:tS(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=m.useCallback(function(e){n.current=qx(e),r.current=void 0},[]),d=m.useCallback(function(t){l(t.type,Jx(t),t.target,s(t,e.lockRef.current))},[]),f=m.useCallback(function(t){l(t.type,qx(t),t.target,s(t,e.lockRef.current))},[]);m.useEffect(function(){return $x.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Fx),document.addEventListener(`touchmove`,c,Fx),document.addEventListener(`touchstart`,u,Fx),function(){$x=$x.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Fx),document.removeEventListener(`touchmove`,c,Fx),document.removeEventListener(`touchstart`,u,Fx)}},[]);var p=e.removeScrollBar,h=e.inert;return m.createElement(m.Fragment,null,h?m.createElement(a,{styles:Zx(i)}):null,p?m.createElement(Mx,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function tS(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var nS=fx(px,eS),rS=m.forwardRef(function(e,t){return m.createElement(hx,Xb({},e,{ref:t,sideCar:nS}))});rS.classNames=hx.classNames;var iS=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},aS=new WeakMap,oS=new WeakMap,sS={},cS=0,lS=function(e){return e&&(e.host||lS(e.parentNode))},uS=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=lS(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},dS=function(e,t,n,r){var i=uS(t,Array.isArray(e)?e:[e]);sS[n]||(sS[n]=new WeakMap);var a=sS[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(aS.get(e)||0)+1,l=(a.get(e)||0)+1;aS.set(e,c),a.set(e,l),o.push(e),c===1&&i&&oS.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),cS++,function(){o.forEach(function(e){var t=aS.get(e)-1,i=a.get(e)-1;aS.set(e,t),a.set(e,i),t||(oS.has(e)||e.removeAttribute(r),oS.delete(e)),i||e.removeAttribute(n)}),cS--,cS||(aS=new WeakMap,aS=new WeakMap,oS=new WeakMap,sS={})}},fS=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||iS(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),dS(r,i,n,`aria-hidden`)):function(){return null}},pS=Object.defineProperty,mS=(e,t)=>pS(e,`name`,{value:t,configurable:!0}),hS=`Dialog`,[gS,_S]=Cy(hS),[vS,yS]=gS(hS),bS=mS(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=m.useRef(null),c=m.useRef(null),[l,u]=Hy({prop:r,defaultProp:i??!1,onChange:a,caller:hS}),[d,f]=m.useState(0),[p,h]=m.useState(0);return(0,U.jsx)(vS,{scope:t,triggerRef:s,contentRef:c,contentId:ob(),titleId:ob(),descriptionId:ob(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:h,open:l,onOpenChange:u,onOpenToggle:m.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),xS=`DialogTrigger`,SS=m.forwardRef(mS(function(e,t){let{__scopeDialog:n,...r}=e,i=yS(xS,n),a=Jv(t,i.triggerRef);return(0,U.jsx)(my.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":HS(i.open),...r,ref:a,onClick:Oy(e.onClick,i.onOpenToggle)})},`DialogTrigger`)),CS=`DialogPortal`,[wS,TS]=gS(CS,{forceMount:void 0}),ES=mS(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=yS(CS,t);return(0,U.jsx)(wS,{scope:t,forceMount:n,children:m.Children.map(r,e=>(0,U.jsx)(Xy,{present:n||a.open,children:(0,U.jsx)(Hb,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),DS=`DialogOverlay`,OS=m.forwardRef(mS(function(e,t){let n=TS(DS,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=yS(DS,e.__scopeDialog);return a.modal?(0,U.jsx)(Xy,{present:r||a.open,children:(0,U.jsx)(AS,{...i,ref:t})}):null},`DialogOverlay`)),kS=Zv(`DialogOverlay.RemoveScroll`),AS=m.forwardRef(mS(function(e,t){let{__scopeDialog:n,...r}=e,i=yS(DS,n),a=Jv(t,vb());return(0,U.jsx)(rS,{as:kS,allowPinchZoom:!0,shards:[i.contentRef],children:(0,U.jsx)(my.div,{"data-state":HS(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),jS=`DialogContent`,MS=m.forwardRef(mS(function(e,t){let n=TS(jS,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=yS(jS,e.__scopeDialog);return(0,U.jsx)(Xy,{present:r||a.open,children:a.modal?(0,U.jsx)(NS,{...i,ref:t}):(0,U.jsx)(PS,{...i,ref:t})})},`DialogContent`)),NS=m.forwardRef(mS(function(e,t){let n=yS(jS,e.__scopeDialog),r=m.useRef(null),i=Jv(t,n.contentRef,r);return m.useEffect(()=>{let e=r.current;if(e)return fS(e)},[]),(0,U.jsx)(FS,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Oy(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Oy(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Oy(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),PS=m.forwardRef(mS(function(e,t){let n=yS(jS,e.__scopeDialog),r=m.useRef(!1),i=m.useRef(!1);return(0,U.jsx)(FS,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),FS=m.forwardRef(mS(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=yS(jS,n);return Jb(),(0,U.jsx)(U.Fragment,{children:(0,U.jsx)(kb,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,U.jsx)(_b,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":HS(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),IS=`DialogTitle`,LS=m.forwardRef(mS(function(e,t){let{__scopeDialog:n,...r}=e,i=yS(IS,n),{setTitleCount:a}=i;return Ny(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,U.jsx)(my.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),RS=`DialogDescription`,zS=m.forwardRef(mS(function(e,t){let{__scopeDialog:n,...r}=e,i=yS(RS,n),{setDescriptionCount:a}=i;return Ny(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,U.jsx)(my.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),BS=`DialogClose`,VS=m.forwardRef(mS(function(e,t){let{__scopeDialog:n,...r}=e,i=yS(BS,n);return(0,U.jsx)(my.button,{type:`button`,...r,ref:t,onClick:Oy(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function HS(e){return e?`open`:`closed`}mS(HS,`getState`);var US=Object.defineProperty,WS=(e,t)=>US(e,`name`,{value:t,configurable:!0}),[GS,KS]=Cy(`AlertDialog`,[_S]),qS=_S(),JS=WS(e=>{let{__scopeAlertDialog:t,...n}=e,r=qS(t);return(0,U.jsx)(bS,{...r,...n,modal:!0})},`AlertDialog`);m.forwardRef(WS(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=qS(n);return(0,U.jsx)(SS,{...i,...r,ref:t})},`AlertDialogTrigger`));var YS=WS(e=>{let{__scopeAlertDialog:t,...n}=e,r=qS(t);return(0,U.jsx)(ES,{...r,...n})},`AlertDialogPortal`),XS=m.forwardRef(WS(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=qS(n);return(0,U.jsx)(OS,{...i,...r,ref:t})},`AlertDialogOverlay`)),[ZS,QS]=GS(`AlertDialogContent`),$S=m.forwardRef(WS(function(e,t){let{__scopeAlertDialog:n,children:r,...i}=e,a=qS(n),o=Jv(t,m.useRef(null)),s=m.useRef(null);return(0,U.jsx)(ZS,{scope:n,cancelRef:s,children:(0,U.jsx)(MS,{role:`alertdialog`,...a,...i,ref:o,onOpenAutoFocus:Oy(i.onOpenAutoFocus,e=>{e.preventDefault(),s.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:r})})},`AlertDialogContent`)),eC=m.forwardRef(WS(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=qS(n);return(0,U.jsx)(LS,{...i,...r,ref:t})},`AlertDialogTitle`)),tC=m.forwardRef(WS(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=qS(n);return(0,U.jsx)(zS,{...i,...r,ref:t})},`AlertDialogDescription`)),nC=m.forwardRef(WS(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=qS(n);return(0,U.jsx)(VS,{...i,...r,ref:t})},`AlertDialogAction`)),rC=`AlertDialogCancel`,iC=m.forwardRef(WS(function(e,t){let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=QS(rC,n),a=qS(n),o=Jv(t,i);return(0,U.jsx)(VS,{...a,...r,ref:o})},`AlertDialogCancel`)),aC=JS,oC=YS,sC=XS,cC=$S,lC=nC,uC=iC,dC=eC,fC=tC,pC=Object.defineProperty,mC=(e,t)=>pC(e,`name`,{value:t,configurable:!0});function hC(e){let[t,n]=m.useState(void 0);return Ny(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}mC(hC,`useSize`);var gC=Object.defineProperty,_C=(e,t)=>gC(e,`name`,{value:t,configurable:!0}),vC=`Checkbox`,[yC,bC]=Cy(vC),[xC,SC]=yC(vC);function CC(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=Hy({prop:n,defaultProp:i??!1,onChange:c,caller:vC}),[h,g]=m.useState(null),[_,v]=m.useState(null),y=m.useRef(!1),[b,x]=m.useReducer(e=>e+1,0),S=!h||!!o||!!h.closest(`form`),C={checked:f,disabled:a,setChecked:p,control:h,setControl:g,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:y,userInteractionCount:b,onUserInteraction:x,required:l,defaultChecked:!MC(i)&&i,isFormControl:S,bubbleInput:_,setBubbleInput:v};return(0,U.jsx)(xC,{scope:t,...C,children:jC(d)?d(C):r})}_C(CC,`CheckboxProvider`);var wC=`CheckboxTrigger`,TC=m.forwardRef(_C(function({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i){let{control:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,onUserInteraction:p,isFormControl:h,bubbleInput:g}=SC(wC,e),_=Jv(i,u),v=m.useRef(c);return m.useEffect(()=>{let e=a?.form;if(e){let t=_C(()=>d(v.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,d]),(0,U.jsx)(my.button,{type:`button`,role:`checkbox`,"aria-checked":MC(c)?`mixed`:c,"aria-required":l,"data-state":NC(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:_,onKeyDown:Oy(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:Oy(n,e=>{p(),d(e=>MC(e)?!0:!e),g&&h&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`CheckboxTrigger`)),EC=m.forwardRef(_C(function(e,t){let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,U.jsx)(CC,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(TC,{...d,ref:t,__scopeCheckbox:n}),e&&(0,U.jsx)(AC,{__scopeCheckbox:n})]})})},`Checkbox`)),DC=`CheckboxIndicator`,OC=m.forwardRef(_C(function(e,t){let{__scopeCheckbox:n,forceMount:r,...i}=e,a=SC(DC,n);return(0,U.jsx)(Xy,{present:r||MC(a.checked)||a.checked===!0,children:(0,U.jsx)(my.span,{"data-state":NC(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})},`CheckboxIndicator`)),kC=`CheckboxBubbleInput`,AC=m.forwardRef(_C(function({__scopeCheckbox:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:u,name:d,value:f,form:p,bubbleInput:h,setBubbleInput:g}=SC(kC,e),_=Jv(r,g),v=hC(i),y=m.useRef(!1),b=m.useRef(s),x=m.useRef(o);m.useEffect(()=>{let e=h;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==x.current;x.current=o;let i=b.current!==s;b.current=s;let c=!(r&&a.current);if(i&&n){y.current=!r;let t=new Event(`click`,{bubbles:c});e.indeterminate=MC(s),n.call(e,!MC(s)&&s),e.dispatchEvent(t),y.current=!1}},[h,s,a,o]);let S=m.useRef(!MC(s)&&s);return(0,U.jsx)(my.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??S.current,required:l,disabled:u,name:d,value:f,form:p,...n,tabIndex:-1,ref:_,onClick:Oy(t,e=>{y.current&&e.stopPropagation()}),style:{...n.style,...v,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`CheckboxBubbleInput`));function jC(e){return typeof e==`function`}_C(jC,`isFunction`);function MC(e){return e===`indeterminate`}_C(MC,`isIndeterminate`);function NC(e){return MC(e)?`indeterminate`:e?`checked`:`unchecked`}_C(NC,`getState`);var PC=[`top`,`right`,`bottom`,`left`],FC=Math.min,IC=Math.max,LC=Math.round,RC=Math.floor,zC=e=>({x:e,y:e}),BC={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function VC(e,t,n){return IC(e,FC(t,n))}function HC(e,t){return typeof e==`function`?e(t):e}function UC(e){return e.split(`-`)[0]}function WC(e){return e.split(`-`)[1]}function GC(e){return e===`x`?`y`:`x`}function KC(e){return e===`y`?`height`:`width`}function qC(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function JC(e){return GC(qC(e))}function YC(e,t,n){n===void 0&&(n=!1);let r=WC(e),i=JC(e),a=KC(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=iw(o)),[o,iw(o)]}function XC(e){let t=iw(e);return[ZC(e),t,ZC(t)]}function ZC(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var QC=[`left`,`right`],$C=[`right`,`left`],ew=[`top`,`bottom`],tw=[`bottom`,`top`];function nw(e,t,n){switch(e){case`top`:case`bottom`:return n?t?$C:QC:t?QC:$C;case`left`:case`right`:return t?ew:tw;default:return[]}}function rw(e,t,n,r){let i=WC(e),a=nw(UC(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(ZC)))),a}function iw(e){let t=UC(e);return BC[t]+e.slice(t.length)}function aw(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function ow(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:aw(e)}function sw(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function cw(e,t,n){let{reference:r,floating:i}=e,a=qC(t),o=JC(t),s=KC(o),c=UC(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=WC(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function lw(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=HC(t,e),p=ow(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=sw(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=sw(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var uw=50,dw=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:lw},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=cw(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<uw&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=cw(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},fw=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=HC(e,t)||{};if(l==null)return{};let d=ow(u),f={x:n,y:r},p=JC(i),m=KC(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=FC(d[_],T),D=FC(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=VC(E,k,O),ee=!c.arrow&&WC(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,j=ee?k<E?k-E:k-O:0;return{[p]:f[p]+j,data:{[p]:A,centerOffset:k-A-j,...ee&&{alignmentOffset:j}},reset:ee}}}),pw=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=HC(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=UC(r),_=qC(o),v=UC(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[iw(o)]:XC(o)),x=p!==`none`;!d&&x&&b.push(...rw(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=YC(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===qC(t)||T.every(e=>qC(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=qC(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function mw(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function hw(e){return PC.some(t=>e[t]>=0)}var gw=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=HC(e,t);switch(i){case`referenceHidden`:{let e=mw(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:hw(e)}}}case`escaped`:{let e=mw(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:hw(e)}}}default:return{}}}}},_w=new Set([`left`,`top`]);async function vw(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=UC(n),s=WC(n),c=qC(n)===`y`,l=_w.has(o)?-1:1,u=a&&c?-1:1,d=HC(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var yw=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await vw(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},bw=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=HC(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=qC(i),p=GC(f),m=u[p],h=u[f],g=(e,t)=>VC(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},xw=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=HC(e,t),u={x:n,y:r},d=qC(i),f=GC(d),p=u[f],m=u[d],h=HC(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=_w.has(UC(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Sw=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=HC(e,t),c=await i.detectOverflow(t,s),l=UC(n),u=WC(n),d=qC(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=FC(p-c[m],g),y=FC(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*IC(c.left,c.right):S=p-2*IC(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function Cw(){return typeof window<`u`}function ww(e){return Dw(e)?(e.nodeName||``).toLowerCase():`#document`}function Tw(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ew(e){return((Dw(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Dw(e){return Cw()?e instanceof Node||e instanceof Tw(e).Node:!1}function Ow(e){return Cw()?e instanceof Element||e instanceof Tw(e).Element:!1}function kw(e){return Cw()?e instanceof HTMLElement||e instanceof Tw(e).HTMLElement:!1}function Aw(e){return!Cw()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Tw(e).ShadowRoot}function jw(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Hw(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Mw(e){return/^(table|td|th)$/.test(ww(e))}function Nw(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Pw=/transform|translate|scale|rotate|perspective|filter/,Fw=/paint|layout|strict|content/,Iw=e=>!!e&&e!==`none`,Lw;function Rw(e){let t=Ow(e)?Hw(e):e;return Iw(t.transform)||Iw(t.translate)||Iw(t.scale)||Iw(t.rotate)||Iw(t.perspective)||!Bw()&&(Iw(t.backdropFilter)||Iw(t.filter))||Pw.test(t.willChange||``)||Fw.test(t.contain||``)}function zw(e){let t=Ww(e);for(;kw(t)&&!Vw(t);){if(Rw(t))return t;if(Nw(t))return null;t=Ww(t)}return null}function Bw(){return Lw??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Lw}function Vw(e){return/^(html|body|#document)$/.test(ww(e))}function Hw(e){return Tw(e).getComputedStyle(e)}function Uw(e){return Ow(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ww(e){if(ww(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Aw(e)&&e.host||Ew(e);return Aw(t)?t.host:t}function Gw(e){let t=Ww(e);return Vw(t)?(e.ownerDocument||e).body:kw(t)&&jw(t)?t:Gw(t)}function Kw(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Gw(e),i=r===e.ownerDocument?.body,a=Tw(r);if(i){let e=qw(a);return t.concat(a,a.visualViewport||[],jw(r)?r:[],e&&n?Kw(e):[])}return t.concat(r,Kw(r,[],n))}function qw(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Jw(e){let t=Hw(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=kw(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=LC(n)!==a||LC(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Yw(e){return Ow(e)?e:e.contextElement}function Xw(e){let t=Yw(e);if(!kw(t))return zC(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Jw(t),o=(a?LC(n.width):n.width)/r,s=(a?LC(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Zw=zC(0);function Qw(e){let t=Tw(e);return!Bw()||!t.visualViewport?Zw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function $w(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Tw(e)}function eT(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Yw(e),o=zC(1);t&&(r?Ow(r)&&(o=Xw(r)):o=Xw(e));let s=$w(a,n,r)?Qw(a):zC(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=Tw(a),t=Ow(r)?Tw(r):r,n=e,i=qw(n);for(;i&&t!==n;){let e=Xw(i),t=i.getBoundingClientRect(),r=Hw(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Tw(i),i=qw(n)}}return sw({width:u,height:d,x:c,y:l})}function tT(e,t){let n=Uw(e).scrollLeft;return t?t.left+n:eT(Ew(e)).left+n}function nT(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-tT(e,n),y:n.top+t.scrollTop}}function rT(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Ew(r),s=t?Nw(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=zC(1),u=zC(0),d=kw(r);if((d||!a)&&((ww(r)!==`body`||jw(o))&&(c=Uw(r)),d)){let e=eT(r);l=Xw(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?nT(o,c):zC(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function iT(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function aT(e){let t=Uw(e),n=e.ownerDocument.body,r=IC(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=IC(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+tT(e),o=-t.scrollTop;return Hw(n).direction===`rtl`&&(a+=IC(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var oT=25;function sT(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Tw(e),a=Ew(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Bw()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(tT(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=oT&&(s-=o)}return{width:s,height:c,x:l,y:u}}function cT(e,t){let n=eT(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Xw(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function lT(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=sT(e,n,t);else if(t===`document`)r=aT(Ew(e));else if(Ow(t))r=cT(t,n);else{let n=Qw(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return sw(r)}function uT(e,t){let n=t.get(e);if(n)return n;let r=Kw(e,[],!1).filter(e=>Ow(e)&&ww(e)!==`body`),i=null,a=Hw(e).position===`fixed`,o=a?Ww(e):e;for(;Ow(o)&&!Vw(o);){let e=Hw(o),t=Rw(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Ww(o)}return t.set(e,r),r}function dT(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Nw(t)?[]:uT(t,this._c):[].concat(n),r],o=lT(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=lT(t,a[e],i);s=IC(n.top,s),c=FC(n.right,c),l=FC(n.bottom,l),u=IC(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function fT(e){let{width:t,height:n}=Jw(e);return{width:t,height:n}}function pT(e,t,n){let r=kw(t),i=Ew(t),a=n===`fixed`,o=eT(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=zC(0);if((r||!a)&&((ww(t)!==`body`||jw(i))&&(s=Uw(t)),r)){let e=eT(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=tT(i));let l=i&&!r&&!a?nT(i,s):zC(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function mT(e){return Hw(e).position===`static`}function hT(e,t){if(!kw(e)||Hw(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Ew(e)===n&&(n=n.ownerDocument.body),n}function gT(e,t){let n=Tw(e);if(Nw(e))return n;if(!kw(e)){let t=Ww(e);for(;t&&!Vw(t);){if(Ow(t)&&!mT(t))return t;t=Ww(t)}return n}let r=hT(e,t);for(;r&&Mw(r)&&mT(r);)r=hT(r,t);return r&&Vw(r)&&mT(r)&&!Rw(r)?n:r||zw(e)||n}var _T=async function(e){let t=this.getOffsetParent||gT,n=this.getDimensions,r=await n(e.floating);return{reference:pT(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function vT(e){return Hw(e).direction===`rtl`}var yT={convertOffsetParentRelativeRectToViewportRelativeRect:rT,getDocumentElement:Ew,getClippingRect:dT,getOffsetParent:gT,getElementRects:_T,getClientRects:iT,getDimensions:fT,getScale:Xw,isElement:Ow,isRTL:vT};function bT(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function xT(e,t,n){let r=null,i,a=Ew(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=RC(d),h=RC(a.clientWidth-(u+f)),g=RC(a.clientHeight-(d+p)),_=RC(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:IC(0,FC(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!bT(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=Tw(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function ST(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Yw(e),u=i||a?[...l?Kw(l):[],...t?Kw(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?xT(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?eT(e):null;c&&g();function g(){let t=eT(e);h&&!bT(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var CT=yw,wT=bw,TT=pw,ET=Sw,DT=gw,OT=fw,kT=xw,AT=(e,t,n)=>{let r=new Map,i=n??{},a={...yT,...i.platform,_c:r};return dw(e,t,{...i,platform:a})},jT=typeof document<`u`?m.useLayoutEffect:function(){};function MT(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!MT(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!MT(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function NT(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function PT(e,t){let n=NT(e);return Math.round(t*n)/n}function FT(e){let t=m.useRef(e);return jT(()=>{t.current=e}),t}function IT(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=m.useState(r);MT(f,r)||p(r);let[h,g]=m.useState(null),[_,v]=m.useState(null),y=m.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=m.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=m.useRef(null),w=m.useRef(null),T=m.useRef(u),E=c!=null,D=FT(c),O=FT(i),k=FT(l),A=m.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),AT(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};ee.current&&!MT(T.current,t)&&(T.current=t,dy.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);jT(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let ee=m.useRef(!1);jT(()=>(ee.current=!0,()=>{ee.current=!1}),[]),jT(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let j=m.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),M=m.useMemo(()=>({reference:x,floating:S}),[x,S]),te=m.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=PT(M.floating,u.x),r=PT(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...NT(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:A,refs:j,elements:M,floatingStyles:te}),[u,A,j,M,te])}var LT=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:OT({element:r.current,padding:i}).fn(n):r?OT({element:r,padding:i}).fn(n):{}}}},RT=(e,t)=>{let n=CT(e);return{name:n.name,fn:n.fn,options:[e,t]}},zT=(e,t)=>{let n=wT(e);return{name:n.name,fn:n.fn,options:[e,t]}},BT=(e,t)=>({fn:kT(e).fn,options:[e,t]}),VT=(e,t)=>{let n=TT(e);return{name:n.name,fn:n.fn,options:[e,t]}},HT=(e,t)=>{let n=ET(e);return{name:n.name,fn:n.fn,options:[e,t]}},UT=(e,t)=>{let n=DT(e);return{name:n.name,fn:n.fn,options:[e,t]}},WT=(e,t)=>{let n=LT(e);return{name:n.name,fn:n.fn,options:[e,t]}},GT=Object.defineProperty,KT=(e,t)=>GT(e,`name`,{value:t,configurable:!0}),qT=`Popper`,[JT,YT]=Cy(qT),[XT,ZT]=JT(qT),QT=KT(e=>{let{__scopePopper:t,children:n}=e,[r,i]=m.useState(null),[a,o]=m.useState(void 0);return(0,U.jsx)(XT,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),$T=`PopperAnchor`,eE=m.forwardRef(KT(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=ZT($T,n),o=m.useRef(null),s=a.onAnchorChange,c=Jv(t,m.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=m.useRef(null);m.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&sE(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,U.jsx)(my.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),tE=`PopperContent`,[nE,rE]=JT(tE),iE=m.forwardRef(KT(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:h,...g}=e,_=ZT(tE,n),[v,y]=m.useState(null),b=Jv(t,y),[x,S]=m.useState(null),C=hC(x),w=C?.width??0,T=C?.height??0,E=r+(a===`center`?``:`-`+a),D=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},O=Array.isArray(l)?l:[l],k=O.length>0,A={padding:D,boundary:O.filter(aE),altBoundary:k},{refs:ee,floatingStyles:j,placement:M,isPositioned:te,middlewareData:N}=IT({strategy:`fixed`,placement:E,whileElementsMounted:KT((...e)=>ST(...e,{animationFrame:p===`always`}),`whileElementsMounted`),elements:{reference:_.anchor},middleware:[RT({mainAxis:i+T,alignmentAxis:o}),c&&zT({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?BT():void 0,...A}),c&&VT({...A}),HT({...A,apply:KT(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),x&&WT({element:x,padding:s}),oE({arrowWidth:w,arrowHeight:T}),f&&UT({strategy:`referenceHidden`,...A,boundary:k?A.boundary:void 0})]}),P=_.setPlacementState;Ny(()=>(P(M),()=>{P(void 0)}),[M,P]);let[ne,re]=sE(M),ie=lb(h);Ny(()=>{te&&ie?.()},[te,ie]);let ae=N.arrow?.x,oe=N.arrow?.y,se=N.arrow?.centerOffset!==0,[ce,le]=m.useState();return Ny(()=>{v&&le(window.getComputedStyle(v).zIndex)},[v]),(0,U.jsx)(`div`,{ref:ee.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:te?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ce,"--radix-popper-transform-origin":[N.transformOrigin?.x,N.transformOrigin?.y].join(` `),...N.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,U.jsx)(nE,{scope:n,placedSide:ne,placedAlign:re,onArrowChange:S,arrowX:ae,arrowY:oe,shouldHideArrow:se,children:(0,U.jsx)(my.div,{"data-side":ne,"data-align":re,...g,ref:b,style:{...g.style,animation:te?g.style?.animation:`none`}})})})},`PopperContent`));function aE(e){return e!==null}KT(aE,`isNotNull`);var oE=KT(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=sE(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function sE(e){let[t,n=`center`]=e.split(`-`);return[t,n]}KT(sE,`getSideAndAlignFromPlacement`);var cE=QT,lE=eE,uE=iE,dE=Object.defineProperty,fE=(e,t)=>dE(e,`name`,{value:t,configurable:!0}),pE=`Popover`,[mE,hE]=Cy(pE,[YT]),gE=YT(),[_E,vE]=mE(pE),yE=fE(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=gE(t),c=m.useRef(null),[l,u]=m.useState(!1),[d,f]=Hy({prop:r,defaultProp:i??!1,onChange:a,caller:pE});return(0,U.jsx)(cE,{...s,children:(0,U.jsx)(_E,{scope:t,contentId:ob(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:m.useCallback(()=>u(!0),[]),onCustomAnchorRemove:m.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),bE=`PopoverTrigger`,xE=m.forwardRef(fE(function(e,t){let{__scopePopover:n,...r}=e,i=vE(bE,n),a=gE(n),o=Jv(t,i.triggerRef),s=(0,U.jsx)(my.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":ME(i.open),...r,ref:o,onClick:Oy(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,U.jsx)(lE,{asChild:!0,...a,children:s})},`PopoverTrigger`)),SE=`PopoverPortal`,[CE,wE]=mE(SE,{forceMount:void 0}),TE=fE(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=vE(SE,t);return(0,U.jsx)(CE,{scope:t,forceMount:n,children:(0,U.jsx)(Xy,{present:n||a.open,children:(0,U.jsx)(Hb,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),EE=`PopoverContent`,DE=m.forwardRef(fE(function(e,t){let n=wE(EE,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=vE(EE,e.__scopePopover);return(0,U.jsx)(Xy,{present:r||a.open,children:a.modal?(0,U.jsx)(kE,{...i,ref:t}):(0,U.jsx)(AE,{...i,ref:t})})},`PopoverContent`)),OE=Zv(`PopoverContent.RemoveScroll`),kE=m.forwardRef(fE(function(e,t){let n=vE(EE,e.__scopePopover),r=m.useRef(null),i=Jv(t,r),a=m.useRef(!1);return m.useEffect(()=>{let e=r.current;if(e)return fS(e)},[]),(0,U.jsx)(rS,{as:OE,allowPinchZoom:!0,children:(0,U.jsx)(jE,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Oy(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Oy(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:Oy(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),AE=m.forwardRef(fE(function(e,t){let n=vE(EE,e.__scopePopover),r=m.useRef(!1),i=m.useRef(!1);return(0,U.jsx)(jE,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),jE=m.forwardRef(fE(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=vE(EE,n),p=gE(n);return Jb(),(0,U.jsx)(kb,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,U.jsx)(_b,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,U.jsx)(uE,{"data-state":ME(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})},`PopoverContentImpl`));function ME(e){return e?`open`:`closed`}fE(ME,`getState`);var NE=yE,PE=xE,FE=TE,IE=DE,LE=Object.defineProperty,RE=(e,t)=>LE(e,`name`,{value:t,configurable:!0}),zE=`Switch`,[BE,VE]=Cy(zE),[HE,UE]=BE(zE);function WE(e){let{__scopeSwitch:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=Hy({prop:n,defaultProp:i??!1,onChange:c,caller:zE}),[h,g]=m.useState(null),[_,v]=m.useState(null),y=m.useRef(!1),[b,x]=m.useReducer(e=>e+1,0),S={checked:f,setChecked:p,disabled:a,control:h,setControl:g,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:y,userInteractionCount:b,onUserInteraction:x,required:l,defaultChecked:i,isFormControl:!h||!!o||!!h.closest(`form`),bubbleInput:_,setBubbleInput:v};return(0,U.jsx)(HE,{scope:t,...S,children:QE(d)?d(S):r})}RE(WE,`SwitchProvider`);var GE=`SwitchTrigger`,KE=m.forwardRef(RE(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,form:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,onUserInteraction:p,isFormControl:h,bubbleInput:g}=UE(GE,e),_=Jv(r,u),v=m.useRef(c);return m.useEffect(()=>{let e=a?i?.ownerDocument.getElementById(a):i?.form;if(e instanceof HTMLFormElement){let t=RE(()=>d(v.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[i,a,d]),(0,U.jsx)(my.button,{type:`button`,role:`switch`,"aria-checked":c,"aria-required":l,"data-state":$E(c),"data-disabled":s?``:void 0,disabled:s,value:o,...n,ref:_,onClick:Oy(t,e=>{p(),d(e=>!e),g&&h&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`SwitchTrigger`)),qE=m.forwardRef(RE(function(e,t){let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,U.jsx)(WE,{__scopeSwitch:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(KE,{...d,ref:t,__scopeSwitch:n}),e&&(0,U.jsx)(ZE,{__scopeSwitch:n})]})})},`Switch`)),JE=`SwitchThumb`,YE=m.forwardRef(RE(function(e,t){let{__scopeSwitch:n,...r}=e,i=UE(JE,n);return(0,U.jsx)(my.span,{"data-state":$E(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})},`SwitchThumb`)),XE=`SwitchBubbleInput`,ZE=m.forwardRef(RE(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:u,name:d,value:f,form:p,bubbleInput:h,setBubbleInput:g}=UE(XE,e),_=Jv(r,g),v=hC(i),y=m.useRef(!1),b=m.useRef(s),x=m.useRef(o);m.useEffect(()=>{let e=h;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==x.current;x.current=o;let i=b.current!==s;b.current=s;let c=!(r&&a.current);if(i&&n){y.current=!r;let t=new Event(`click`,{bubbles:c});n.call(e,s),e.dispatchEvent(t),y.current=!1}},[h,s,a,o]);let S=m.useRef(s);return(0,U.jsx)(my.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??S.current,required:l,disabled:u,name:d,value:f,form:p,...n,tabIndex:-1,ref:_,onClick:Oy(t,e=>{y.current&&e.stopPropagation()}),style:{...n.style,...v,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`SwitchBubbleInput`));function QE(e){return typeof e==`function`}RE(QE,`isFunction`);function $E(e){return e?`checked`:`unchecked`}RE($E,`getState`);var eD=Object.defineProperty,tD=(e,t)=>eD(e,`name`,{value:t,configurable:!0}),[nD,rD]=Cy(`Tooltip`,[YT]),iD=YT(),aD=`TooltipProvider`,oD=700,sD=`tooltip.open`,[cD,lD]=nD(aD),uD=tD(e=>{let{__scopeTooltip:t,delayDuration:n=oD,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=m.useRef(!0),s=m.useRef(!1),c=m.useRef(0);return m.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,U.jsx)(cD,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:m.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:m.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:m.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),dD=`Tooltip`,[fD,pD]=nD(dD),mD=tD(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=lD(dD,e.__scopeTooltip),l=iD(t),[u,d]=m.useState(null),[f,p]=m.useState(void 0),h=ob(),g=m.useRef(0),_=o??c.disableHoverableContent,v=s??c.delayDuration,y=m.useRef(!1),[b,x]=Hy({prop:r,defaultProp:i??!1,onChange:tD(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(sD))):c.onClose(),a?.(e)},`onChange`),caller:dD}),S=m.useMemo(()=>b?y.current?`delayed-open`:`instant-open`:`closed`,[b]),C=m.useCallback(()=>{window.clearTimeout(g.current),g.current=0,y.current=!1,x(!0)},[x]),w=m.useCallback(()=>{window.clearTimeout(g.current),g.current=0,x(!1)},[x]),T=m.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{y.current=!0,x(!0),g.current=0},v)},[v,x]);m.useEffect(()=>()=>{g.current&&=(window.clearTimeout(g.current),0)},[]);let E=f??h;return(0,U.jsx)(cE,{...l,children:(0,U.jsx)(fD,{scope:t,contentId:E,setContentId:p,open:b,stateAttribute:S,trigger:u,onTriggerChange:d,onTriggerEnter:m.useCallback(()=>{c.isOpenDelayedRef.current?T():C()},[c.isOpenDelayedRef,T,C]),onTriggerLeave:m.useCallback(()=>{_?w():(window.clearTimeout(g.current),g.current=0)},[w,_]),onOpen:C,onClose:w,disableHoverableContent:_,children:n})})},`Tooltip`),hD=`TooltipTrigger`,gD=m.forwardRef(tD(function(e,t){let{__scopeTooltip:n,...r}=e,i=pD(hD,n),a=lD(hD,n),o=iD(n),s=Jv(t,m.useRef(null),i.onTriggerChange),c=m.useRef(!1),l=m.useRef(!1),u=m.useCallback(()=>c.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,U.jsx)(lE,{asChild:!0,...o,children:(0,U.jsx)(my.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:Oy(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:Oy(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:Oy(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:Oy(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Oy(e.onBlur,i.onClose),onClick:Oy(e.onClick,i.onClose)})})},`TooltipTrigger`)),_D=`TooltipPortal`,[vD,yD]=nD(_D,{forceMount:void 0}),bD=tD(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=pD(_D,t);return(0,U.jsx)(vD,{scope:t,forceMount:n,children:(0,U.jsx)(Xy,{present:n||a.open,children:(0,U.jsx)(Hb,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),xD=`TooltipContent`,SD=m.forwardRef(tD(function(e,t){let n=yD(xD,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=pD(xD,e.__scopeTooltip);return(0,U.jsx)(Xy,{present:r||o.open,children:o.disableHoverableContent?(0,U.jsx)(TD,{side:i,...a,ref:t}):(0,U.jsx)(CD,{side:i,...a,ref:t})})},`TooltipContent`)),CD=m.forwardRef(tD(function(e,t){let n=pD(xD,e.__scopeTooltip),r=lD(xD,e.__scopeTooltip),i=m.useRef(null),a=Jv(t,i),[o,s]=m.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=m.useCallback(()=>{s(null),d(!1)},[d]),p=m.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=DD(r,ED(r,n.getBoundingClientRect())),a=OD(t.getBoundingClientRect()),o=AD([...i,...a]);s(o),d(!0)},[d]);return m.useEffect(()=>()=>f(),[f]),m.useEffect(()=>{if(c&&u){let e=tD(e=>p(e,u),`handleTriggerLeave`),t=tD(e=>p(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),m.useEffect(()=>{if(o){let e=tD(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!kD(n,o);r?f():i&&(f(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,U.jsx)(TD,{...e,ref:a})},`TooltipContentHoverable`)),wD=ey(`TooltipContent`),TD=m.forwardRef(tD(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=pD(xD,n),u=iD(n),{onClose:d}=l;m.useEffect(()=>(document.addEventListener(sD,d),()=>document.removeEventListener(sD,d)),[d]),m.useEffect(()=>{if(l.trigger){let e=tD(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:f}=l;return Ny(()=>(f(a),()=>{f(void 0)}),[a,f]),(0,U.jsx)(_b,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,U.jsxs)(uE,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,U.jsx)(wD,{children:r}),i?(0,U.jsx)(yy,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`));function ED(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}tD(ED,`getExitSideFromRect`);function DD(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}tD(DD,`getPaddedExitPoints`);function OD(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}tD(OD,`getPointsFromRect`);function kD(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}tD(kD,`isPointInPolygon`);function AD(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),jD(t)}tD(AD,`getHull`);function jD(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}tD(jD,`getHullPresorted`);var MD=uD,ND=mD,PD=gD,FD=bD,ID=SD,LD=Uv(`group/button motion-reduce:transition-none motion-reduce:active:scale-100 inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-[scale,background-color,box-shadow,color,border-color] duration-150 active:not-aria-[haspopup]:scale-[0.97] ease-snap outline-none select-none focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`btn-tint text-primary-foreground [--tint:var(--primary)] disabled:text-muted-foreground`,soft:`btn-soft text-foreground`,outline:`btn-outline text-foreground [&_svg]:text-muted-foreground`,secondary:`btn-soft text-secondary-foreground`,ghost:`btn-ghost text-foreground [&_svg]:text-muted-foreground hover:[&_svg]:text-foreground`,destructive:`btn-tint text-white [--tint:var(--destructive)] focus-visible:outline-destructive disabled:text-muted-foreground dark:text-background`,link:`text-link underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-3`,xs:`h-7 gap-1 px-2.5 text-xs [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1.5 px-2.5 text-xs [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-2 px-4`,icon:`size-8`,"icon-xs":`size-7 [&_svg:not([class*='size-'])]:size-3.5`,"icon-sm":`size-7`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function X({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){let a=r?Qv:`button`;return(0,U.jsx)(a,{"aria-keyshortcuts":r?void 0:`Enter Space`,"aria-description":r?`When focused, press Enter to activate.`:`When focused, press Enter or Space to activate.`,"aria-describedby":`focused-action-help`,"data-slot":`button`,"data-variant":t,"data-size":n,className:Y(LD({variant:t,size:n,className:e})),...i})}var RD=Y(`pointer-events-none inline-flex h-[1.125rem] min-w-[1.125rem] w-fit items-center justify-center gap-1 rounded-[4px] bg-accent px-1 font-sans text-2xs leading-none font-medium text-muted-foreground select-none`,`in-data-[slot=tooltip-content]:bg-accent in-data-[slot=tooltip-content]:text-muted-foreground`,`in-data-[variant=default]:bg-primary-foreground/16 in-data-[variant=default]:text-primary-foreground`,`in-data-[variant=destructive]:bg-white/16 in-data-[variant=destructive]:text-current`,`[&_svg:not([class*='size-'])]:size-3`);function zD({className:e,...t}){return(0,U.jsx)(`kbd`,{"data-slot":`kbd`,className:Y(RD,e),...t})}function BD({className:e,...t}){return(0,U.jsx)(`kbd`,{"data-slot":`kbd-group`,className:Y(`inline-flex items-center gap-0.5`,e),...t})}var VD=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),HD={alt:`⌥`,ctrl:`⌃`,shift:`⇧`,meta:`⌘`,cmd:`⌘`},UD={enter:`↵`,esc:`Esc`,escape:`Esc`,arrowleft:`←`,arrowright:`→`,arrowup:`↑`,arrowdown:`↓`,space:`Space`,delete:`Del`,backspace:`⌫`};function WD(e){return e.split(`+`).map(e=>{let t=e.toLowerCase();return VD&&HD[t]?HD[t]:UD[t]??(e.length===1?e.toUpperCase():e[0].toUpperCase()+e.slice(1))})}function GD({chord:e,className:t}){let n=WD(e);return(0,U.jsx)(BD,{className:t,children:n.map((e,t)=>(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[t>0?(0,U.jsx)(`span`,{className:`sr-only`,children:`plus`}):null,(0,U.jsx)(zD,{children:e})]},t))})}function KD({chord:e,children:t,className:n}){return(0,U.jsxs)(`span`,{className:Y(`kbd-hint inline-flex shrink-0 items-center gap-1.5 text-xs whitespace-nowrap text-muted-foreground`,n),children:[(0,U.jsx)(GD,{chord:e}),t]})}function qD({open:e,onOpenChange:t,label:n,description:r,dismissOnBackdrop:i=!0,className:a,style:o,onCloseAutoFocus:s,onEscapeKeyDown:c,children:l}){let u=Ef();return(0,U.jsx)(bS,{open:e,onOpenChange:t,children:(0,U.jsx)(ju,{children:e?(0,U.jsxs)(ES,{forceMount:!0,children:[(0,U.jsx)(OS,{asChild:!0,forceMount:!0,children:(0,U.jsx)(Xf.div,{className:`fixed inset-0 z-50 bg-scrim backdrop-blur-sm`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16,ease:`easeOut`}})}),(0,U.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-50 grid place-items-center p-4`,children:(0,U.jsx)(MS,{asChild:!0,forceMount:!0,onCloseAutoFocus:s,...c?{onEscapeKeyDown:c}:{},onInteractOutside:e=>{i||e.preventDefault()},onOpenAutoFocus:e=>{let t=e.currentTarget?.querySelector(`[data-nav], [data-autofocus], textarea`);t&&(e.preventDefault(),t.focus())},...r?{}:{"aria-describedby":void 0},children:(0,U.jsxs)(Xf.div,{className:Y(`glass-pop pointer-events-auto flex max-h-[min(86svh,48rem)] w-full max-w-2xl flex-col overflow-hidden rounded-2xl outline-none`,a),style:o,initial:{opacity:0,scale:u?1:.98,y:u?0:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:u?1:.98,transition:{duration:.15,ease:`easeIn`}},transition:{duration:.2,ease:[.32,.72,0,1]},children:[(0,U.jsx)(LS,{className:`sr-only`,children:n}),r?(0,U.jsx)(zS,{className:`sr-only`,children:r}):null,l]})})})]}):null})})}var JD=[],YD=0,XD=new Set;function ZD(){for(let e of[...XD])e()}function QD(e){return XD.add(e),()=>{XD.delete(e)}}function $D(){let e;for(let t of JD)(!e||t.priority>e.priority||t.priority===e.priority&&t.order<e.order)&&(e=t);return e?.id}var eO={question:30,confirm:20,help:10,sheet:5};function tO(e,t){let n=(0,m.useId)();(0,m.useEffect)(()=>{if(e)return JD=[...JD,{id:n,priority:t,order:++YD}],ZD(),()=>{JD=JD.filter(e=>e.id!==n),ZD()}},[e,t,n]);let r=(0,m.useSyncExternalStore)(QD,$D,()=>void 0);return e&&r===n}function nO(){return JD.length>0}function rO(){return(0,m.useSyncExternalStore)(QD,()=>JD.length>0,()=>!1)}function iO(){let[e,t]=(0,m.useReducer)(e=>e+1,0);return(0,m.useEffect)(()=>F.subscribe(t),[]),e}function aO(){return iO(),F.status()}function oO(e){return iO(),F.get(e)}function sO(e){let t=(0,m.useCallback)(t=>{let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},[e]),n=(0,m.useCallback)(()=>window.matchMedia(e).matches,[e]);return(0,m.useSyncExternalStore)(t,n)}function cO(e){let t=(0,m.useRef)(null),n=(0,m.useRef)(!0),[r,i]=(0,m.useState)(!0),a=(0,m.useRef)(void 0),o=(0,m.useRef)(null),s=(0,m.useCallback)(()=>{n.current=!0,i(!0);let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[]);return(0,m.useLayoutEffect)(()=>{n.current&&s()},[e,s]),(0,m.useLayoutEffect)(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{n.current&&(e.scrollTop=e.scrollHeight)});return r.observe(e),a.current=r,()=>{r.disconnect(),a.current=void 0,o.current=null}},[]),(0,m.useLayoutEffect)(()=>{let e=a.current,n=t.current?.firstElementChild??null;e&&n!==o.current&&(o.current&&e.unobserve(o.current),n&&e.observe(n),o.current=n)},[e]),{ref:t,atBottom:r,stick:s,onScroll:(0,m.useCallback)(()=>{let e=t.current;e&&(n.current=e.scrollHeight-e.scrollTop-e.clientHeight<48,i(n.current))},[])}}var lO={DEV:Tm,DESIGN:Vh,QA:Dg,RESEARCH:Vg,SCOUT:jm,PLANNER:_g,CLASSIFIER:zg,LOBBY:Nh,LINT:hh};function uO(e){return e?lO[e.toUpperCase()]??Yp:Zp}function dO({className:e,strokeWidth:t=2,source:n}){return(0,U.jsxs)(`svg`,{"aria-hidden":`true`,"data-agent-icon":n,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:t,strokeLinecap:`round`,strokeLinejoin:`round`,className:Y(`agent-oracle shrink-0`,e),children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`10`,r:`7`}),(0,U.jsx)(`path`,{d:`M8.5 7.5a4 4 0 0 1 3-2`}),(0,U.jsx)(`path`,{d:`M8 16.2 6.5 20h11L16 16.2`}),(0,U.jsx)(`path`,{d:`M5 20h14`})]})}function fO(e){let t=e?.toUpperCase();return t===`ORACLE`||t===`MASTER`}function pO({source:e,className:t,strokeWidth:n}){if(fO(e))return(0,U.jsx)(dO,{source:e,className:t,strokeWidth:n});let r=uO(e);return(0,U.jsx)(r,{"aria-hidden":`true`,"data-agent-icon":e??`thinking`,strokeWidth:n,className:Y(`shrink-0`,t)})}function mO(e){return e.role===`you`||e.role===`note`?e.role:e.role===`panel`?`PLANNER`:e.agent??`MASTER`}var hO={MASTER:`text-primary`,DEV:`text-source-dev`,DESIGN:`text-source-design`,QA:`text-source-qa`,RESEARCH:`text-source-research`,SCOUT:`text-source-scout`,ORACLE:`text-primary`,LOBBY:`text-muted-foreground`};function gO(e){return e===`MASTER`?`Oracle`:e.length<=2?e:e.charAt(0)+e.slice(1).toLowerCase()}function _O(e){return hO[e]??`text-muted-foreground`}var vO={MASTER:`var(--primary)`,DEV:`var(--source-dev)`,DESIGN:`var(--source-design)`,QA:`var(--source-qa)`,RESEARCH:`var(--source-research)`,SCOUT:`var(--source-scout)`,ORACLE:`var(--primary)`,LOBBY:`var(--muted-foreground)`};function yO(e){return vO[e]??`var(--muted-foreground)`}function bO(e){if(e.role===`researcher`)return`RESEARCH`;let t=e.domain??e.role;return t===`backend`||t===`dev`?`DEV`:t===`designer`||t===`design`?`DESIGN`:t===`researcher`||t===`research`?`RESEARCH`:t===`qa`?`QA`:t?String(t).toUpperCase():`AGENT`}function xO(e){return e?.runs??[]}function SO(e,t=40){let n=new Map;for(let t of e)n.set(t.source,t);return[...n.values()].sort((e,t)=>e.at-t.at).slice(-t)}function CO({source:e,name:t,time:n,head:r,live:i,children:a,aside:o,named:s,waiting:c}){let l=c||r&&(s||!fO(e));return(0,U.jsxs)(`div`,{className:`chat-agent group/msg`,"data-live":i||void 0,style:i?{"--orb":yO(e)}:void 0,children:[l||o?(0,U.jsxs)(`p`,{className:`chat-speaker`,children:[l?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-medium text-foreground`,style:{"--orb":yO(e)},children:[(0,U.jsx)(pO,{source:e,strokeWidth:2.25,className:`size-3.5 text-[color-mix(in_oklab,var(--orb)_85%,var(--foreground))]`}),c?(0,U.jsx)(EO,{text:t}):t]}):null,l&&n?(0,U.jsx)(`time`,{className:`text-xs text-muted-foreground tabular-nums`,children:n}):null,o?(0,U.jsx)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:o}):null]}):null,c?null:(0,U.jsx)(`div`,{className:`chat-prose`,children:a}),n&&!l?(0,U.jsx)(`time`,{className:`chat-meta`,children:n}):null]})}function wO({time:e,head:t,note:n,children:r,below:i,actions:a}){return(0,U.jsxs)(`div`,{className:`group/msg flex flex-col items-end gap-1`,children:[(0,U.jsx)(`div`,{className:`chat-bubble`,children:r}),e||n||a?(0,U.jsxs)(`div`,{className:`chat-meta flex items-center gap-2`,"data-note":n?``:void 0,children:[a,n?(0,U.jsx)(`span`,{children:n}):null,e?(0,U.jsx)(`time`,{className:`tabular-nums`,children:e}):null]}):null,i]})}function TO({failed:e,auto:t,children:n}){return(0,U.jsx)(`div`,{role:`note`,className:Y(`chat-note`,e&&`text-destructive`,t&&`chat-note-auto`),children:(0,U.jsx)(`span`,{children:n})})}function EO({text:e}){return(0,U.jsxs)(`span`,{className:`activity-shimmer`,children:[(0,U.jsx)(`span`,{className:`sr-only`,children:e}),[...e].map((e,t)=>(0,U.jsx)(`span`,{"aria-hidden":`true`,style:{"--i":t},children:e},t))]})}function DO({onClick:e,className:t}){return(0,U.jsx)(`button`,{type:`button`,"aria-label":`Jump to latest`,title:`Jump to latest`,onClick:e,className:Y(`jump-latest btn-outline grid size-9 place-items-center rounded-full border bg-card text-foreground shadow-card outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t),children:(0,U.jsx)(Np,{"aria-hidden":`true`,className:`size-4`})})}var OO=8;function kO(e){return e?e.path===`fast`?`fast track (${e.size})`:`full workflow (${e.size})`:``}function AO(e,t){let n=Math.min(t,OO);if(n<=0)return[];let r=Math.min(n,Math.round(Math.max(0,e)/t*n));return Array.from({length:n},(e,t)=>t<r)}function jO({done:e,total:t}){return(0,U.jsx)(`span`,{className:`inline-flex items-center gap-0.5`,"aria-hidden":`true`,children:AO(e,t).map((e,t)=>(0,U.jsx)(`span`,{className:Y(`h-1.5 w-3 rounded-full`,e?`bg-primary`:`bg-muted-foreground/25`)},t))})}function MO({check:e,className:t}){return(0,U.jsx)(e===`done`?dm:e===`dropped`?xm:Cm,{"aria-hidden":`true`,className:Y(`size-4 shrink-0`,e===`done`?`text-success`:`text-muted-foreground`,t)})}var NO=`auto mode`;function PO(){return(0,U.jsx)(`span`,{className:`auto-mode-text`,children:NO})}function FO({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`empty`,className:Y(`flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 p-6 text-center text-balance`,e),...t})}function IO({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`empty-header`,className:Y(`flex max-w-sm flex-col items-center gap-2`,e),...t})}var LO=Uv(`mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{default:`bg-transparent`,icon:`relative flex size-9 shrink-0 items-center justify-center rounded-md border bg-card text-foreground shadow-sm/5 [&_svg:not([class*='size-'])]:size-4.5`}},defaultVariants:{variant:`default`}});function RO({className:e,variant:t=`default`,...n}){return(0,U.jsx)(`div`,{"data-slot":`empty-icon`,"data-variant":t,className:Y(LO({variant:t,className:e})),...n})}function zO({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`empty-title`,className:Y(`text-[1.0625rem] leading-6 font-medium`,e),...t})}function BO({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`empty-description`,className:Y(`text-[0.8125rem] leading-[1.125rem] text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function VO(e){return e<10?`0${e}`:String(e)}function HO(e){if(!Number.isFinite(e))return`0`;let t=new Date(e);return`${VO(t.getHours())}:${VO(t.getMinutes())}`}function UO(e){if(!Number.isFinite(e)||e<5e3)return`now`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<48?`${r}h`:`${Math.floor(r/24)}d`}function WO(e){let t=UO(e);return t===`now`?`just now`:`${t} ago`}function GO({title:e,note:t,className:n,children:r,collapsed:i,onToggle:a,shortcut:o,...s}){let c=typeof e==`string`?e:`pane`;return(0,U.jsxs)(`section`,{className:Y(`workspace-frame group/frame relative flex min-h-0 min-w-0 flex-col rounded-xl border shadow-xs`,i&&`flex-none`,n),...s,children:[e||t||a?(0,U.jsxs)(`div`,{className:Y(`flex min-h-12 shrink-0 items-center justify-between gap-3 px-4`,!i&&`border-b border-border`),children:[e?(0,U.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-medium`,children:e}):(0,U.jsx)(`span`,{}),(0,U.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,U.jsx)(`span`,{className:`flex items-center gap-2 truncate text-xs text-muted-foreground`,children:t}):null,a?(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":!i,"aria-label":i?`Expand ${c}`:`Minimize ${c}`,title:`${i?`Expand`:`Minimize`}${o?` · ${o}`:``}`,"aria-keyshortcuts":o?`${o} Enter Space`:`Enter Space`,"aria-describedby":`focused-action-help`,onClick:a,className:`btn-ghost -mr-1.5 inline-flex h-8 items-center gap-1.5 rounded-lg border border-transparent px-2 text-muted-foreground transition-[box-shadow,color,scale] duration-150 ease-snap outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:scale-[0.97] motion-reduce:active:scale-100`,children:[o?(0,U.jsx)(GD,{chord:o,className:`kbd-hint`}):null,(0,U.jsx)(tm,{"aria-hidden":`true`,className:Y(`size-4 transition-transform duration-200 ease-snap`,i&&`-rotate-90`)})]}):null]})]}):null,i?null:r]})}function KO({title:e,right:t,className:n}){return(0,U.jsxs)(`span`,{className:Y(`flex min-w-0 items-center gap-3`,n),children:[(0,U.jsx)(`span`,{className:`truncate font-medium`,children:e}),(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`}),t?(0,U.jsx)(`span`,{className:`shrink-0 text-xs font-normal text-muted-foreground`,children:t}):null]})}var qO=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,JO=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,YO={};function XO(e,t){return((t||YO).jsx?JO:qO).test(e)}var ZO={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},QO=n(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
60
60
|
`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),$O=n((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(QO());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),ek=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),tk=n(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})($O()),r=ek();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),nk=ik(`end`),rk=ik(`start`);function ik(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function ak(e){let t=rk(e),n=nk(e);if(t&&n)return{start:t,end:n}}function ok(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?ck(e.position):`start`in e||`end`in e?ck(e):`line`in e||`column`in e?sk(e):``}function sk(e){return lk(e&&e.line)+`:`+lk(e&&e.column)}function ck(e){return sk(e&&e.start)+`-`+sk(e&&e.end)}function lk(e){return e&&typeof e==`number`?e:1}var uk=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=ok(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};uk.prototype.file=``,uk.prototype.name=``,uk.prototype.reason=``,uk.prototype.message=``,uk.prototype.stack=``,uk.prototype.column=void 0,uk.prototype.line=void 0,uk.prototype.ancestors=void 0,uk.prototype.cause=void 0,uk.prototype.fatal=void 0,uk.prototype.place=void 0,uk.prototype.ruleId=void 0,uk.prototype.source=void 0;var dk=t(tk(),1),fk={}.hasOwnProperty,pk=new Map,mk=/[A-Z]/g,hk=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),gk=new Set([`td`,`th`]),_k=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function vk(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=kk(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=Ok(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?a:l,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=yk(i,e,void 0);return o&&typeof o!=`string`?o:i.create(e,i.Fragment,{children:o||void 0},void 0)}function yk(e,t,n){if(t.type===`element`)return bk(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return xk(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return Ck(e,t,n);if(t.type===`mdxjsEsm`)return Sk(e,t);if(t.type===`root`)return wk(e,t,n);if(t.type===`text`)return Tk(e,t)}function bk(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=a,e.schema=i),e.ancestors.push(t);let o=Fk(e,t.tagName,!1),s=Ak(e,t),l=Mk(e,t);return hk.has(t.tagName)&&(l=l.filter(function(e){return typeof e!=`string`||!c(e)})),Ek(e,s,o,t),Dk(s,l),e.ancestors.pop(),e.schema=r,e.create(t,o,s,n)}function xk(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}Ik(e,t.position)}function Sk(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Ik(e,t.position)}function Ck(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=a,e.schema=i),e.ancestors.push(t);let o=t.name===null?e.Fragment:Fk(e,t.name,!0),s=jk(e,t),c=Mk(e,t);return Ek(e,s,o,t),Dk(s,c),e.ancestors.pop(),e.schema=r,e.create(t,o,s,n)}function wk(e,t,n){let r={};return Dk(r,Mk(e,t)),e.create(t,e.Fragment,r,n)}function Tk(e,t){return t.value}function Ek(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Dk(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function Ok(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function kk(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=rk(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function Ak(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&fk.call(t.properties,i)){let a=Nk(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&gk.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function jk(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else Ik(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else Ik(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function Mk(e,t){let n=[],r=-1,i=e.passKeys?new Map:pk;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=yk(e,a,o);s!==void 0&&n.push(s)}return n}function Nk(e,t,n){let i=r(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=i.commaSeparated?u(n):s(n)),i.property===`style`){let t=typeof n==`object`?n:Pk(e,String(n));return e.stylePropertyNameCase===`css`&&(t=Lk(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&i.space?ZO[i.property]||i.property:i.attribute,n]}}function Pk(e,t){try{return(0,dk.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new uk("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=_k+`#cannot-parse-style-attribute`,r}}function Fk(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=XO(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=XO(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return fk.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);Ik(e)}function Ik(e,t){let n=new uk("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=_k+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function Lk(e){let t={},n;for(n in e)fk.call(e,n)&&(t[Rk(n)]=e[n]);return t}function Rk(e){let t=e.replace(mk,zk);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function zk(e){return`-`+e.toLowerCase()}var Bk={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},Vk={};function Hk(e,t){let n=t||Vk;return Uk(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function Uk(e,t,n){if(Gk(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return Wk(e.children,t,n)}return Array.isArray(e)?Wk(e,t,n):``}function Wk(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=Uk(e[i],t,n);return r.join(``)}function Gk(e){return!!(e&&typeof e==`object`)}var Kk=document.createElement(`i`);function qk(e){let t=`&`+e+`;`;Kk.innerHTML=t;let n=Kk.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function Jk(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function Yk(e,t){return e.length>0?(Jk(e,e.length,0,t),e):t}var Xk={}.hasOwnProperty;function Zk(e){let t={},n=-1;for(;++n<e.length;)Qk(t,e[n]);return t}function Qk(e,t){let n;for(n in t){let r=(Xk.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){Xk.call(r,a)||(r[a]=[]);let e=i[a];$k(r[a],Array.isArray(e)?e:e?[e]:[])}}}function $k(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);Jk(e,0,0,r)}function eA(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function tA(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var nA=pA(/[A-Za-z]/),rA=pA(/[\dA-Za-z]/),iA=pA(/[#-'*+\--9=?A-Z^-~]/);function aA(e){return e!==null&&(e<32||e===127)}var oA=pA(/\d/),sA=pA(/[\dA-Fa-f]/),cA=pA(/[!-/:-@[-`{-~]/);function Z(e){return e!==null&&e<-2}function lA(e){return e!==null&&(e<0||e===32)}function uA(e){return e===-2||e===-1||e===32}var dA=pA(/\p{P}|\p{S}/u),fA=pA(/\s/);function pA(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function mA(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&rA(e.charCodeAt(n+1))&&rA(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function hA(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return uA(r)?(e.enter(n),s(r)):t(r)}function s(r){return uA(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}function gA(e,t,n,r,i,a){let o=0;return s;function s(t){return a>0&&uA(t)?(e.enter(r),c(t)):l(t)}function c(t){return uA(t)&&o<a?(e.consume(t),o++,c):(e.exit(r),l(t))}function l(e){return o>=i?t(e):n(e)}}var _A={tokenize:vA};function vA(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),hA(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return Z(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var yA=class{constructor(){this.index=new Map,this.map=[]}add(e,t,n){bA(this,e,t,n,!1)}addBefore(e,t,n){bA(this,e,t,n,!0)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function bA(e,t,n,r,i){if(n===0&&r.length===0)return;let a=e.index.get(t);if(a){a[1]+=n,i?(r.push(...a[2]),a[2]=r):a[2].push(...r);return}let o=[t,n,r];e.map.push(o),e.index.set(t,o)}var xA={tokenize:CA},SA={tokenize:wA};function CA(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;let c=new yA;return c.add(a+1,0,t.events.slice(n)),c.add(n,s-n,[]),c.consume(t.events),l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(SA,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(SA,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return Z(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;let l=new yA;l.add(a+1,0,t.events.slice(n)),l.add(n,e-n,[]),l.consume(t.events)}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function wA(e,t,n){return hA(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function TA(e){if(e===null||lA(e)||fA(e))return 1;if(dA(e))return 2}function EA(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var DA={name:`attention`,resolveAll:OA,tokenize:kA};function OA(e,t){let n=-1,r;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){let i=n;for(;i--;)if(e[i][0]===`exit`&&e[i][1].type===`attentionSequence`&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;let a=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1,o={...e[i][1].end},s={...e[n][1].start};AA(o,-a),AA(s,a);let c={type:a>1?`strongSequence`:`emphasisSequence`,start:o,end:{...e[i][1].end}},l={type:a>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:s},u={type:a>1?`strongText`:`emphasisText`,start:{...e[i][1].end},end:{...e[n][1].start}},d={type:a>1?`strong`:`emphasis`,start:{...c.start},end:{...l.end}};e[i][1].end={...c.start},e[n][1].start={...l.end},r=[],e[i][1].end.offset-e[i][1].start.offset&&(r=Yk(r,[[`enter`,e[i][1],t],[`exit`,e[i][1],t]])),r=Yk(r,[[`enter`,d,t],[`enter`,c,t],[`exit`,c,t],[`enter`,u,t]]),r=Yk(r,EA(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),r=Yk(r,[[`exit`,u,t],[`enter`,l,t],[`exit`,l,t],[`exit`,d,t]]);let f=0;e[n][1].end.offset-e[n][1].start.offset&&(f=2,r=Yk(r,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])),Jk(e,i-1,n-i+3,r),n=i+r.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function kA(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=TA(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=TA(o),u=!l||l===2&&i||n.includes(o)&&o!==42&&o!==95,d=!i||i===2&&l||n.includes(r)&&r!==42&&r!==95;return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function AA(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var jA={name:`autolink`,tokenize:MA};function MA(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return nA(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||rA(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||rA(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||aA(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):iA(t)?(e.consume(t),l):n(t)}function u(e){return rA(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||rA(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var NA={partial:!0,tokenize:PA};function PA(e,t,n){return r;function r(t){return uA(t)?hA(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||Z(e)?t(e):n(e)}}var FA={continuation:{tokenize:LA},exit:RA,name:`blockQuote`,tokenize:IA};function IA(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return uA(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function LA(e,t,n){let r=this;return i;function i(t){return uA(t)?hA(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(FA,t,n)(r)}}function RA(e){e.exit(`blockQuote`)}var zA={name:`characterEscape`,tokenize:BA};function BA(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return cA(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var VA={name:`characterReference`,tokenize:HA};function HA(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=rA,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=sA,u):(e.enter(`characterReferenceValue`),a=7,o=oA,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===rA&&!qk(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var UA={partial:!0,tokenize:WA};function WA(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var GA={concrete:!0,name:`codeFenced`,tokenize:KA};function KA(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),uA(t)?hA(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||Z(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(UA,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||Z(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):uA(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),hA(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||Z(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||Z(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&uA(t)?hA(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||Z(t)?e.check(UA,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||Z(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),uA(t)?hA(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),uA(t)?hA(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||Z(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}var qA={name:`codeIndented`,tokenize:YA},JA={partial:!0,tokenize:XA};function YA(e,t,n){return r;function r(t){return e.enter(`codeIndented`),gA(e,i,n,`linePrefix`,4,4)(t)}function i(t){return t===null?o(t):Z(t)?e.attempt(JA,i,o)(t):(e.enter(`codeFlowValue`),a(t))}function a(t){return t===null||Z(t)?(e.exit(`codeFlowValue`),i(t)):(e.consume(t),a)}function o(n){return e.exit(`codeIndented`),t(n)}}function XA(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):Z(o)?(e.enter(`lineEnding`),e.consume(o),e.exit(`lineEnding`),i):gA(e,t,a,`linePrefix`,4,4)(o)}function a(e){return Z(e)?i(e):n(e)}}var ZA={name:`codeText`,previous:$A,resolve:QA,tokenize:ej};function QA(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function $A(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function ej(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):Z(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||Z(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var tj=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&nj(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),nj(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),nj(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);nj(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);nj(this.left,t.reverse())}}}};function nj(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function rj(e){let t={},n=-1,r,i,a,o,s,c,l,u=new tj(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,ij(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return Jk(e,0,1/0,u.slice(0)),!l}function ij(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var aj={resolve:sj,tokenize:cj},oj={partial:!0,tokenize:lj};function sj(e){return rj(e),e}function cj(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):Z(t)?e.check(oj,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function lj(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),hA(e,a,`linePrefix`)}function a(i){if(i===null||Z(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function uj(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||aA(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||Z(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||lA(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||aA(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function dj(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):Z(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||Z(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!uA(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function fj(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):Z(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),hA(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||Z(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function pj(e,t){let n;return r;function r(i){return Z(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):uA(i)?hA(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var mj={name:`definition`,tokenize:gj},hj={partial:!0,tokenize:_j};function gj(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return dj.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=tA(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return lA(t)?pj(e,l)(t):l(t)}function l(t){return uj(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(hj,d,d)(t)}function d(t){return uA(t)?hA(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||Z(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function _j(e,t,n){return r;function r(t){return lA(t)?pj(e,i)(t):n(t)}function i(t){return fj(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return uA(t)?hA(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||Z(e)?t(e):n(e)}}var vj={name:`hardBreakEscape`,tokenize:yj};function yj(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return Z(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var bj={name:`headingAtx`,resolve:xj,tokenize:Sj};function xj(e,t){let n=e.length-2,r=3;if(e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r){let i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`};Jk(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])}return e}function Sj(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||lA(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||Z(n)?(e.exit(`atxHeading`),t(n)):uA(n)?hA(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||lA(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Cj=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),wj=[`pre`,`script`,`style`,`textarea`],Tj={concrete:!0,name:`htmlFlow`,resolveTo:Dj,tokenize:Oj},Ej={partial:!0,tokenize:kj};function Dj(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Oj(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:P):nA(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):nA(a)?(e.consume(a),i=4,r.interrupt?t:P):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:P):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return nA(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||lA(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&wj.includes(l)?(i=1,r.interrupt?t(s):O(s)):Cj.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||rA(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return uA(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||nA(t)?(e.consume(t),b):uA(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||rA(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):uA(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):uA(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||Z(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||lA(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||uA(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||Z(t)?O(t):uA(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),j):t===60&&i===1?(e.consume(t),M):t===62&&i===4?(e.consume(t),ne):t===63&&i===3?(e.consume(t),P):t===93&&i===5?(e.consume(t),N):Z(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Ej,re,k)(t)):t===null||Z(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(UA,A,re)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ee}function ee(t){return t===null||Z(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function j(t){return t===45?(e.consume(t),P):O(t)}function M(t){return t===47?(e.consume(t),o=``,te):O(t)}function te(t){if(t===62){let n=o.toLowerCase();return wj.includes(n)?(e.consume(t),ne):O(t)}return nA(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),te):O(t)}function N(t){return t===93?(e.consume(t),P):O(t)}function P(t){return t===62?(e.consume(t),ne):t===45&&i===2?(e.consume(t),P):O(t)}function ne(t){return t===null||Z(t)?(e.exit(`htmlFlowData`),re(t)):(e.consume(t),ne)}function re(n){return e.exit(`htmlFlow`),t(n)}}function kj(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(NA,t,n)}}var Aj={name:`htmlText`,tokenize:jj};function jj(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):nA(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):nA(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):Z(t)?(o=d,M(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?j(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):Z(t)?(o=h,M(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?j(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?j(t):Z(t)?(o=v,M(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):Z(t)?(o=y,M(t)):(e.consume(t),y)}function b(e){return e===62?j(e):y(e)}function x(t){return nA(t)?(e.consume(t),S):n(t)}function S(t){return t===45||rA(t)?(e.consume(t),S):C(t)}function C(t){return Z(t)?(o=C,M(t)):uA(t)?(e.consume(t),C):j(t)}function w(t){return t===45||rA(t)?(e.consume(t),w):t===47||t===62||lA(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),j):t===58||t===95||nA(t)?(e.consume(t),E):Z(t)?(o=T,M(t)):uA(t)?(e.consume(t),T):j(t)}function E(t){return t===45||t===46||t===58||t===95||rA(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):Z(t)?(o=D,M(t)):uA(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):Z(t)?(o=O,M(t)):uA(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,ee):t===null?n(t):Z(t)?(o=k,M(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||lA(t)?T(t):(e.consume(t),A)}function ee(e){return e===47||e===62||lA(e)?T(e):n(e)}function j(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function M(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),te}function te(t){return uA(t)?hA(e,N,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):N(t)}function N(t){return e.enter(`htmlTextData`),o(t)}}var Mj={name:`labelEnd`,resolveAll:Ij,resolveTo:Lj,tokenize:Rj},Nj={tokenize:zj},Pj={tokenize:Bj},Fj={tokenize:Vj};function Ij(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&Jk(e,0,e.length,n),e}function Lj(e,t){let n=e.length,r=0,i,a,o;for(;n--;){let t=e[n][1];if(i){if(t.type===`link`||t.type===`labelLink`&&t._inactive)break;e[n][0]===`enter`&&t.type===`labelLink`&&(t._inactive=!0)}else if(a){if(e[n][0]===`enter`&&(t.type===`labelImage`||t.type===`labelLink`)&&!t._balanced&&(i=n,t.type!==`labelLink`)){r=2;break}}else t.type===`labelEnd`&&(a=n)}let s={type:e[i][1].type===`labelLink`?`link`:`image`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:`label`,start:{...e[i][1].start},end:{...e[a][1].end}},l={type:`labelText`,start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return o=[[`enter`,s,t],[`enter`,c,t]],o=Yk(o,e.slice(i+1,i+r+3)),o=Yk(o,[[`enter`,l,t]]),o=Yk(o,EA(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=Yk(o,[[`exit`,l,t],e[a-2],e[a-1],[`exit`,c,t]]),o=Yk(o,e.slice(a+1)),o=Yk(o,[[`exit`,s,t]]),Jk(e,i,e.length,o),e}function Rj(e,t,n){let r=this,i=r._labelStarts,a,o;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();a=i[i.length-1]}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(tA(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Nj,u,o?u:d)(t):t===91?e.attempt(Pj,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Fj,u,d)(t)}function u(e){return i.pop(),t(e)}function d(e){return a._balanced=!0,n(e)}}function zj(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return lA(t)?pj(e,a)(t):a(t)}function a(t){return t===41?u(t):uj(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return lA(t)?pj(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?fj(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return lA(t)?pj(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function Bj(e,t,n){let r=this;return i;function i(t){return dj.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(tA(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function Vj(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var Hj={name:`labelStartImage`,resolveAll:Mj.resolveAll,tokenize:Uj};function Uj(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),o}function o(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelImage`),s):n(t)}function s(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var Wj={name:`labelStartLink`,resolveAll:Mj.resolveAll,tokenize:Gj};function Gj(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelLink`),o}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var Kj={name:`lineEnding`,tokenize:qj};function qj(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),hA(e,t,`linePrefix`)}}var Jj={name:`thematicBreak`,tokenize:Yj};function Yj(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||Z(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),uA(t)?hA(e,s,`whitespace`)(t):s(t))}}var Xj={continuation:{tokenize:eM},exit:nM,name:`list`,tokenize:$j},Zj={partial:!0,tokenize:rM},Qj={partial:!0,tokenize:tM};function $j(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:oA(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(Jj,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return oA(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(NA,r.interrupt?n:u,e.attempt(Zj,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return uA(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function eM(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(NA,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,hA(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!uA(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Qj,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,hA(e,e.attempt(Xj,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function tM(e,t,n){let r=this;return hA(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function nM(e){e.exit(this.containerState.type)}function rM(e,t,n){let r=this;return hA(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!uA(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var iM={name:`setextUnderline`,resolveTo:aM,tokenize:oM};function aM(e,t){let n=new yA,r=e.length,i,a,o;for(;r--;)if(e[r][0]===`enter`){if(e[r][1].type===`content`){i=r;break}e[r][1].type===`paragraph`&&(a=r)}else e[r][1].type===`content`&&n.add(r,1,[]),!o&&e[r][1].type===`definition`&&(o=r);let s={type:`setextHeading`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type=`setextHeadingText`,o?(n.add(a,0,[[`enter`,s,t]]),n.add(o+1,0,[[`exit`,e[i][1],t]]),e[i][1].end={...e[o][1].end}):e[i][1]=s,n.add(e.length,0,[[`exit`,s,t]]),n.consume(e),e}function oM(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),uA(t)?hA(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||Z(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var sM={tokenize:cM};function cM(e){let t=this,n=e.attempt(NA,r,e.attempt(this.parser.constructs.flowInitial,i,hA(e,e.attempt(this.parser.constructs.flow,i,e.attempt(aj,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var lM={resolveAll:pM()},uM=fM(`string`),dM=fM(`text`);function fM(e){return{resolveAll:pM(e===`text`?mM:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function pM(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function mM(e,t){let n=new yA,r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type===`lineEnding`)&&e[r-1][1].type===`data`){let i=e[r-1][1],a=t.sliceStream(i),o=a.length,s=-1,c=0,l;for(;o--;){let e=a[o];if(typeof e==`string`){for(s=e.length;e.charCodeAt(s-1)===32;)c++,s--;if(s)break;s=-1}else if(e===-2)l=!0,c++;else if(e!==-1){o++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let a={type:r===e.length||l||c<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):n.add(r,0,[[`enter`,a,t],[`exit`,a,t]])}r++}return n.consume(e),e}var hM=e({attentionMarkers:()=>CM,contentInitial:()=>_M,disable:()=>wM,document:()=>gM,flow:()=>yM,flowInitial:()=>vM,insideSpan:()=>SM,string:()=>bM,text:()=>xM}),gM={42:Xj,43:Xj,45:Xj,48:Xj,49:Xj,50:Xj,51:Xj,52:Xj,53:Xj,54:Xj,55:Xj,56:Xj,57:Xj,62:FA},_M={91:mj},vM={[-2]:qA,[-1]:qA,32:qA},yM={35:bj,42:Jj,45:[iM,Jj],60:Tj,61:iM,95:Jj,96:GA,126:GA},bM={38:VA,92:zA},xM={[-5]:Kj,[-4]:Kj,[-3]:Kj,33:Hj,38:VA,42:DA,60:[jA,Aj],91:Wj,92:[vj,zA],93:Mj,95:DA,96:ZA},SM={null:[DA,lM]},CM={null:[42,95]},wM={null:[]};function TM(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=Yk(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=EA(a,l.events,l),l.events):[]}function f(e,t){return DM(p(e),t)}function p(e){return EM(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){for(;r._index<o.length;){let e=o[r._index];if(typeof e==`string`){let t=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===t&&r._bufferIndex<e.length;)_(e.charCodeAt(r._bufferIndex))}else _(e)}}function _(e){u=u(e)}function v(e){Z(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&Jk(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function EM(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function DM(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
61
61
|
`;break;case-3:o=`\r
|
|
62
62
|
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function OM(e){let t={constructs:Zk([hM,...(e||{}).extensions||[]]),content:n(_A),defined:[],document:n(xA),flow:n(sM),lazy:{},string:n(uM),text:n(dM)};return t;function n(e){return n;function n(n){return TM(t,e,n)}}}function kM(e){for(;!rj(e););return e}var AM=/[\0\t\n\r]/g;function jM(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i));let s=[],c=0;for(t=``,n&&=(i.charCodeAt(0)===65279&&c++,void 0);c<i.length;){AM.lastIndex=c;let n=AM.exec(i),a=n&&n.index!==void 0?n.index:i.length,o=i.charCodeAt(a);if(!n){t=i.slice(c);break}if(o===10&&c===a&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),c<a&&(s.push(i.slice(c,a)),e+=a-c),o){case 0:s.push(65533),e++;break;case 9:{let t=Math.ceil(e/4)*4;for(s.push(-2);e++<t;)s.push(-1);break}case 10:s.push(-4),e=1;break;default:r=!0,e=1}c=a+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var MM=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function NM(e){return e.replace(MM,PM)}function PM(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return eA(n.slice(t?2:1),t?16:10)}return qk(n)||e}var FM={}.hasOwnProperty;function IM(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),LM(n)(kM(OM(n).document().write(jM()(e,t,!0))))}function LM(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(_e),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(pe),blockQuote:a(ue),characterEscape:T,characterReference:T,codeFenced:a(de),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(de,o),codeText:a(fe,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(I),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(L),hardBreakEscape:a(me),hardBreakTrailing:a(me),htmlFlow:a(he,o),htmlFlowData:T,htmlText:a(he,o),htmlTextData:T,image:a(ge),label:o,link:a(_e),listItem:a(ye),listItemValue:f,listOrdered:a(ve,d),listUnordered:a(ve),paragraph:a(be),reference:ie,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(pe),strong:a(xe),thematicBreak:a(Se)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:F,autolinkProtocol:le,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:oe,characterReferenceMarkerNumeric:oe,characterReferenceValue:se,characterReference:ce,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(ee),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(M),label:N,labelText:te,lineEnding:D,link:c(j),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ae,resourceDestinationString:P,resourceTitleString:ne,resource:re,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};zM(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];FM.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||VM).call(a,void 0,e[0])}for(r.position={start:RM(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:RM(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:RM(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||VM).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+ok({start:e.start,end:e.end})+`): it’s not open`);n.position.end=RM(e.end)}function u(){return Hk(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=tA(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=R(),n.position={start:RM(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=RM(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=RM(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function ee(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function te(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=NM(t),n.identifier=tA(t).toLowerCase()}function N(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function P(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function ne(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function re(){this.data.inReference=void 0}function ie(){this.data.referenceType=`collapsed`}function ae(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=tA(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function oe(e){this.data.characterReferenceType=e.type}function se(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=eA(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=qk(t);let i=this.stack[this.stack.length-1];i.value+=r}function ce(e){let t=this.stack.pop();t.position.end=RM(e.end)}function le(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function F(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ue(){return{type:`blockquote`,children:[]}}function de(){return{type:`code`,lang:null,meta:null,value:``}}function fe(){return{type:`inlineCode`,value:``}}function I(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function L(){return{type:`emphasis`,children:[]}}function pe(){return{type:`heading`,depth:0,children:[]}}function me(){return{type:`break`}}function he(){return{type:`html`,value:``}}function ge(){return{type:`image`,title:null,url:``,alt:null}}function _e(){return{type:`link`,title:null,url:``,children:[]}}function ve(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function ye(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function be(){return{type:`paragraph`,children:[]}}function xe(){return{type:`strong`,children:[]}}function R(){return{type:`text`,value:``}}function Se(){return{type:`thematicBreak`}}}function RM(e){return{line:e.line,column:e.column,offset:e.offset}}function zM(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?zM(e,r):BM(e,r)}}function BM(e,t){let n;for(n in t)if(FM.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function VM(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+ok({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ok({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+ok({start:t.start,end:t.end})+`) is still open`)}function HM(e){let t=this;t.parser=n;function n(n){return IM(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function UM(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function WM(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
@@ -89,24 +89,24 @@ Error generating stack: `+e.message+`
|
|
|
89
89
|
`)),n=[]),n.push(i);return t.push(n.join(`
|
|
90
90
|
`)),t}function jR(e,t,n=!1){let r=t?.start?.offset,i=t?.end?.offset;if(r===void 0||i===void 0)return;let a=e.slice(r,i);if(!n){let e=a.match(/^`+/)?.[0];return e&&a.endsWith(e)?a.slice(e.length,-e.length):a}let o=a.match(/^ {0,3}(`{3,}|~{3,})[^\r\n]*(?:\r\n|\n|\r)/);if(!o)return a;let s=a.slice(o[0].length),c=RegExp(`^ {0,3}${o[1][0]}{${o[1].length},}[ \\t]*$`,`m`).exec(s);return c?s.slice(0,c.index):s}function MR(e,t){return!e&&!t}async function NR(e,t){if(!t)throw Error(`Clipboard is unavailable. Select the code and copy it manually.`);await t.writeText(e)}var PR=[`lobby`,`tasks`,`plan`,`knowledge`],FR=`already answered in another window`,IR=`Attached files:`,LR={master:`MASTER`,designer:`DESIGN`,backend:`DEV`,qa:`QA`,researcher:`RESEARCH`,scout:`SCOUT`},RR=[{name:`master`,agent:`master`,hint:`The oracle: anything, and changes across the project`},{name:`design`,agent:`designer`,hint:`Frontend: pages, components, styling and UX`},{name:`dev`,agent:`backend`,hint:`Backend: APIs, data and server code`},{name:`qa`,agent:`qa`,hint:`Tests, and how to check a change`},{name:`research`,agent:`researcher`,hint:`Facts from the web: libraries, versions, docs`},{name:`scout`,agent:`scout`,hint:`Reads the code and explains how something works`}],zR=[{name:`plan`,args:`what to plan`,hint:`Plan it with the panel on the Plan tab`},{name:`task`,args:`what to do`,hint:`Start it as a task for the team`}],BR=/^-\s+(.+?)\s+\(([^()\s]+\/[^()\s]+)\)\s*$/;function VR(e){let t=e.lastIndexOf(`${IR}\n`);if(t<0||t>0&&e[t-1]!==`
|
|
91
91
|
`)return{body:e,files:[]};let n=e.slice(t+IR.length+1).split(`
|
|
92
|
-
`).filter(Boolean),r=[];for(let t of n){let n=BR.exec(t);if(!n)return{body:e,files:[]};let i=n[1].split(/[\\/]/).pop()??``;if(!/^[\w.-]+$/.test(i))return{body:e,files:[]};r.push({id:i,name:i.replace(/^[a-z0-9]+-/,``),mime:n[2]})}return r.length>0?{body:e.slice(0,t).trimEnd(),files:r}:{body:e,files:[]}}var HR=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function UR({files:e}){return e.length===0?null:(0,U.jsx)(`ul`,{className:`mt-2 flex min-w-0 max-w-full flex-wrap gap-2`,"aria-label":`Attached files`,children:e.map(e=>(0,U.jsx)(`li`,{children:HR.has(e.mime)?(0,U.jsx)(`a`,{href:I(`/files/preview/attachments/${e.id}`),target:`_blank`,rel:`noopener noreferrer`,className:`block max-w-full overflow-hidden rounded-lg border border-border bg-muted/40 transition-transform duration-150 ease-snap hover:scale-[1.02] focus-visible:outline-2 focus-visible:outline-ring`,children:(0,U.jsx)(`img`,{src:I(`/files/preview/attachments/${e.id}`),alt:e.name,loading:`lazy`,className:`max-h-40 max-w-[min(14rem,100%)] object-cover`})}):(0,U.jsxs)(`span`,{className:`inline-flex max-w-[min(16rem,100%)] min-w-0 items-center gap-2 rounded-lg border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground`,children:[e.mime===`application/pdf`?(0,U.jsx)(Ym,{"aria-hidden":`true`,className:`size-4 shrink-0`}):(0,U.jsx)(Yh,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate`,children:e.name})]})},e.id))})}var WR=!1,GR=[],KR=0,qR=900;function JR(){WR=!0,window.clearTimeout(KR),KR=window.setTimeout(YR,qR)}function YR(){WR=!1,window.clearTimeout(KR);let e=GR;GR=[];for(let t of e)t()}function XR(e){if(!WR)return e(),()=>{};let t=()=>e();return GR.push(t),()=>{GR=GR.filter(e=>e!==t)}}var ZR=8;function QR(e,t=24){let[n,r]=(0,m.useState)(t),i=(0,m.useRef)(8),a=n<e;return(0,m.useEffect)(()=>{if(!a)return;let e=0,t=XR(()=>{e=requestAnimationFrame(()=>{let e=performance.now();(0,dy.flushSync)(()=>r(e=>e+i.current));let t=Math.max(1,performance.now()-e);i.current=Math.max(2,Math.min(400,Math.round(i.current*ZR/t)))})});return()=>{t(),cancelAnimationFrame(e)}},[a,n]),Math.min(n,e)}var $R=`bot-lobby.code.wrap`,ez=`bot-lobby.code.layout`,tz=new Set,nz={open:!1,request:0};function rz(){for(let e of[...tz])e()}function iz(e){return tz.add(e),()=>{tz.delete(e)}}function az(e,t){nz={open:!0,...e?{path:e}:nz.path?{path:nz.path}:{},...t?{mode:t}:{},request:nz.request+1},rz()}function oz(){nz.open&&(nz={...nz,open:!1},rz())}function sz(){nz.open?oz():az()}function cz(){return(0,m.useSyncExternalStore)(iz,()=>nz)}function lz(e){try{return localStorage.getItem(e)}catch{return null}}function uz(e,t){try{localStorage.setItem(e,t)}catch{}}var dz=lz($R)===`1`,fz=lz(ez)===`split`?`split`:`unified`;function pz(e){dz=e,uz($R,e?`1`:`0`),rz()}function mz(e){fz=e,uz(ez,e),rz()}function hz(){return(0,m.useSyncExternalStore)(iz,()=>dz)}function gz(){return(0,m.useSyncExternalStore)(iz,()=>fz)}var _z=new Set(`ts tsx mts cts js jsx mjs cjs json jsonc json5 jsonl md mdx css scss sass less html htm vue svelte astro py rb go rs java kt kts swift c h cc cpp hpp cs php lua sh bash zsh fish ps1 sql graphql gql yml yaml toml ini cfg conf env xml svg txt lock prisma proto dockerfile mk gradle`.split(` `));function vz(e){let t=e.trim();if(!t||t.length>300||/\s/.test(t)||/^[a-z][\w+.-]*:\/\//i.test(t))return;let n=t.replace(/:\d+(?::\d+)?$/,``).replace(/^\.\//,``);if(!/^[\w@~./-]+$/.test(n)||n.endsWith(`/`)||n.includes(`..`))return;let r=n.split(`/`).at(-1)??``,i=/^[\w@.-]*[A-Za-z_][\w@-]*\.[A-Za-z][\w]{0,9}$/.test(r)||/^\.[A-Za-z][\w.-]*$/.test(r),a=/^(Dockerfile|Makefile|LICENSE|Procfile|Gemfile|Rakefile)$/.test(r)&&n.includes(`/`);if((i||a)&&!/^v?\d+(\.\d+)+$/.test(r)&&(n.includes(`/`)||r.startsWith(`.`)||_z.has(r.slice(r.lastIndexOf(`.`)+1).toLowerCase())))return n}function yz({path:e,children:t,className:n}){return(0,U.jsx)(`button`,{type:`button`,"data-file-link":e,title:`Open ${e} in the code viewer`,onClick:t=>{t.stopPropagation(),az(e)},className:Y(`file-link`,n),children:t})}function bz(e){return e.split(/(\s+)/).map((e,t)=>{let n=e.replace(/^[("'`[]+|[)"'`\],.;:!?]+$/g,``),r=n?vz(n):void 0;if(!r)return e;let i=e.indexOf(n);return(0,U.jsxs)(`span`,{children:[e.slice(0,i),(0,U.jsx)(yz,{path:r,children:n}),e.slice(i+n.length)]},t)})}function xz(e){return e?.type===`text`?e.value??``:(e?.children??[]).map(xz).join(``)}function Sz(e,t=!1){let n=t||e.tagName===`a`;e.tagName===`code`&&(e.properties={...e.properties,copyBlocked:n,blockCode:t===!1&&e.properties?.blockCode});for(let t of e.children??[])e.tagName===`pre`&&(t.properties={...t.properties,blockCode:!0}),Sz(t,n)}function Cz(){return e=>Sz(e)}var wz=/(?<![\w/@.:-])((?:\.{1,2}\/)?(?:[\w@.-]+\/)+[\w@.-]*[A-Za-z_][\w@-]*\.[A-Za-z]\w{0,9})(:\d+)?(?![\w/])/g;function Tz(e){if(e.tagName===`code`||e.tagName===`pre`||e.tagName===`a`)return;let t=e.children;if(!t)return;let n=[];for(let e of t){if(e.type!==`text`||!e.value||!e.value.includes(`/`)){Tz(e),n.push(e);continue}let t=0;for(let r of e.value.matchAll(wz)){let i=vz(r[1]);i&&(r.index>t&&n.push({type:`text`,value:e.value.slice(t,r.index)}),n.push({type:`element`,tagName:`span`,properties:{dataFilePath:i},children:[{type:`text`,value:r[0]}]}),t=r.index+r[0].length)}t===0?n.push(e):t<e.value.length&&n.push({type:`text`,value:e.value.slice(t)})}e.children=n}function Ez(){return e=>Tz(e)}function Dz(e){let[t,n]=(0,m.useState)(!1);async function r(){try{await NR(e,navigator.clipboard),n(!0),W.success(`Code copied.`)}catch{W.error(`Could not copy code. Select it and copy manually, or allow clipboard access.`)}}return{copied:t,copy:r}}function Oz({text:e,children:t,block:n=!1}){let{copy:r}=Dz(e),i=(0,m.useRef)(void 0);return(0,U.jsxs)(`code`,{role:`button`,tabIndex:0,"aria-label":`Copy code`,"aria-keyshortcuts":`Enter Space`,title:`Copy code · Enter / Space`,className:`cursor-copy focus-visible:outline-2 focus-visible:outline-ring`,onPointerDown:e=>{i.current={x:e.clientX,y:e.clientY,moved:!1}},onPointerMove:e=>{let t=i.current;t&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>4&&(t.moved=!0)},onClick:e=>{e.stopPropagation(),MR(window.getSelection()?.toString()??``,i.current?.moved??!1)&&r(),i.current=void 0},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),MR(window.getSelection()?.toString()??``,!1)&&r())},children:[t,n?null:(0,U.jsx)(`span`,{className:`sr-only`,children:` (activate to copy)`})]})}function kz({node:e,children:t,source:n}){let r=e,{copied:i,copy:a}=Dz(jR(n,r?.position,!0)??xz(r)),o=r?.children?.find(e=>e.tagName===`code`)?.properties?.className,s=(Array.isArray(o)?o:[]).map(String).find(e=>e.startsWith(`language-`))?.slice(9);return(0,U.jsxs)(`div`,{className:`relative my-3 rounded-lg bg-muted`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between pl-3`,children:[(0,U.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s&&/^[\w+#.-]{1,20}$/.test(s)?s:`code`,` · tap to copy`]}),(0,U.jsx)(SR,{label:i?`Copied`:`Copy the code`,icon:i?$p:Nm,iconOnly:!0,onClick:()=>void a()})]}),(0,U.jsx)(`pre`,{className:`!my-0 overflow-x-auto !rounded-t-none !bg-transparent px-3 pb-3 text-sm leading-relaxed [&>code]:block`,children:t})]})}function Az(e){return{pre:t=>(0,U.jsx)(kz,{...t,source:e}),code:({node:t,children:n})=>{let r=t;if(r?.properties?.copyBlocked)return(0,U.jsx)(`code`,{children:n});let i=!!r?.properties?.blockCode,a=i?void 0:vz(xz(r));return a?(0,U.jsx)(yz,{path:a,children:(0,U.jsx)(`code`,{children:n})}):(0,U.jsx)(Oz,{text:jR(e,r?.position,i)??xz(r),block:i,children:n})},span:({node:e,children:t,...n})=>{let r=e?.properties?.dataFilePath;return typeof r==`string`?(0,U.jsx)(yz,{path:r,children:t}):(0,U.jsx)(`span`,{...n,children:t})},a:({href:e,children:t})=>(0,U.jsx)(`a`,{href:e?I(e):void 0,target:`_blank`,rel:`noopener noreferrer nofollow`,children:t}),img:({src:e,alt:t})=>(0,U.jsx)(`img`,{src:e?I(e):void 0,alt:t??``,loading:`lazy`}),table:({children:e})=>(0,U.jsx)(`div`,{className:`my-3 w-full overflow-x-auto`,children:(0,U.jsx)(`table`,{className:`w-full border-collapse text-sm`,children:e})})}}var jz=(0,m.memo)(function({text:e}){return(0,U.jsx)(qP,{remarkPlugins:[QL],rehypePlugins:[Cz,Ez],urlTransform:TR,components:Az(e),children:e})}),Mz=(0,m.memo)(function({text:e,className:t}){let{body:n,files:r}=VR(e),i=n?AR(n):[],a=QR(i.length,3);return(0,U.jsxs)(`div`,{className:Y(`md-body`,t),children:[i.slice(0,a).map((e,t)=>(0,U.jsx)(jz,{text:e},t)),(0,U.jsx)(UR,{files:r})]})}),Nz=`(max-width: 1023.98px)`;function Pz(e,t){if(e===`app.sidebar`&&t==null){let e=globalThis.matchMedia;return typeof e==`function`&&e(`(max-width: 1023.98px)`).matches}return e===`lobby.thinking`||t===`1`}var Fz=`bot-lobby.collapsed.`,Iz=new Set,Lz=new Map;function Rz(e){if(Lz.has(e))return Lz.get(e);if(e===`lobby.thinking`)return Pz(e);try{return Pz(e,localStorage.getItem(Fz+e))}catch{return!1}}function zz(e,t){Lz.set(e,t);try{e!==`lobby.thinking`&&localStorage.setItem(Fz+e,t?`1`:`0`)}catch{}for(let e of[...Iz])e()}function Bz(e){return Iz.add(e),()=>{Iz.delete(e)}}function Vz(e){zz(e,!Rz(e))}function Hz(e){return[(0,m.useSyncExternalStore)(Bz,()=>Rz(e),()=>Pz(e)),(0,m.useCallback)(()=>zz(e,!Rz(e)),[e])]}function Uz({className:e}){return(0,U.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`working-mark`,className:Y(`working-mark`,e)})}var Wz=`lobby.activity.open`;function Gz({entry:e}){return e.pending?(0,U.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--orb)]`}):e.kind===`error`?(0,U.jsx)(s_,{"aria-hidden":`true`,className:`size-3.5 text-destructive`}):e.kind===`warning`?(0,U.jsx)(qg,{"aria-hidden":`true`,className:`size-3.5 text-warning`}):e.kind===`success`?(0,U.jsx)($p,{"aria-hidden":`true`,className:`size-3.5 text-success`}):(0,U.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`})}function Kz({entry:e}){return(0,U.jsxs)(`li`,{className:`activity-step`,title:HO(e.at),style:e.pending?{"--orb":yO(e.source)}:void 0,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`flex h-5 w-6 items-center justify-center`,children:(0,U.jsx)(Gz,{entry:e})}),(0,U.jsx)(`span`,{className:`sr-only`,children:e.pending?`pending`:e.kind}),(0,U.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,U.jsx)(`span`,{className:Y(`font-medium`,_O(e.source)),children:gO(e.source)}),` `,(0,U.jsxs)(`span`,{className:e.kind===`error`?`text-destructive`:e.pending?`text-foreground`:void 0,children:[bz(e.text),e.pending?`…`:``]})]})]})}function qz(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,`0`)}m`}function Jz(e){let t=[...e].reverse().find(e=>e.pending),n=[...new Set(e.map(e=>gO(e.source)))];return{...t?{live:t}:{},took:(e.at(-1)?.at??0)-(e[0]?.at??0),count:`${e.length} ${e.length===1?`step`:`steps`}`,sources:n.length>3?`${n.slice(0,3).join(`, `)} +${n.length-3}`:n.join(`, `),errors:e.filter(e=>e.kind===`error`).length,warnings:e.filter(e=>e.kind===`warning`).length}}function Yz(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{if(!e)return;n(Date.now());let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),t}function Xz({entries:e}){let[t]=Hz(Wz),[n,r]=(0,m.useState)();(0,m.useEffect)(()=>r(void 0),[t]);let i=n??t,a=(0,m.useId)(),{live:o,took:s,count:c,sources:l,errors:u,warnings:d}=Jz(e),f=Yz(!!o),p=o?{"--orb":yO(o.source)}:void 0;return(0,U.jsxs)(`div`,{className:`activity-run`,"data-live":o?!0:void 0,"data-open":i||void 0,style:p,children:[(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":a,onClick:()=>r(!i),className:`activity-toggle`,children:[o?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Uz,{}),(0,U.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,U.jsx)(EO,{text:`Working`}),(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:` · `}),(0,U.jsxs)(`span`,{className:`activity-live-step`,children:[(0,U.jsx)(`span`,{className:Y(`font-medium`,_O(o.source)),children:gO(o.source)}),` `,(0,U.jsxs)(`span`,{className:`text-foreground`,children:[o.text,`…`]})]},o.id)]}),(0,U.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[c,e[0]&&f-e[0].at>=1e3?` · ${qz(f-e[0].at)}`:``]})]}):(0,U.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:s>=1e3?`Worked for ${qz(s)}`:`Worked`}),(0,U.jsxs)(`span`,{children:[` · `,c,l?` · ${l}`:``]})]}),u?(0,U.jsxs)(`span`,{className:`shrink-0 text-destructive`,children:[u,` `,u===1?`error`:`errors`]}):null,d?(0,U.jsxs)(`span`,{className:`shrink-0 text-warning`,children:[d,` `,d===1?`warning`:`warnings`]}):null,(0,U.jsx)(tm,{"aria-hidden":`true`,className:`activity-chevron size-3.5 shrink-0`})]}),i?(0,U.jsx)(`ol`,{id:a,"aria-label":`Activity`,className:`activity-steps`,children:e.map(e=>(0,U.jsx)(Kz,{entry:e},e.id))}):null]})}function Zz(e,t){let n=[...t].sort((e,t)=>e.at-t.at||e.id-t.id),r=[],i=0,a=e=>{let t=[];for(;i<n.length&&n[i].at<e;)t.push(n[i++]);t.length&&r.push({kind:`activity`,key:`steps-${t[0].id}`,entries:t})};for(let t of e)a(t.at),r.push({kind:`message`,entry:t});return a(1/0),r}var Qz=3e5,$z=`Talk to the team.`,eB=`Ask a question or ask for a change below: the right agent answers and does it here.`,tB=`Nothing said yet. Type below to talk to the oracle about this task.`;function nB({entry:e}){return e.text===`auto mode`?(0,U.jsx)(TO,{auto:!0,children:NO}):(0,U.jsxs)(TO,{failed:e.text.startsWith(`✗`),children:[e.text,e.at?` · ${HO(e.at)}`:``]})}function rB({entry:e,head:t}){if(e.role===`you`)return(0,U.jsx)(wO,{time:HO(e.at),head:t,...e.to?{note:`to ${gO(e.to)}`}:{},children:(0,U.jsx)(Mz,{text:e.text})});let n=mO(e);return(0,U.jsx)(CO,{source:n,name:n===`PLANNER`?`Panel`:gO(n),time:HO(e.at),head:t,named:!0,children:(0,U.jsx)(Mz,{text:e.text})})}var iB=(0,m.memo)(function({entry:e,head:t,fresh:n}){return(0,U.jsx)(Xf.div,{initial:n?{opacity:0,y:10}:!1,animate:{opacity:1,y:0},transition:{type:`spring`,stiffness:420,damping:32},children:e.role===`note`?(0,U.jsx)(nB,{entry:e}):(0,U.jsx)(rB,{entry:e,head:t})})},(e,t)=>e.head===t.head&&e.entry.id===t.entry.id&&e.entry.text===t.entry.text&&e.entry.at===t.entry.at&&e.entry.to===t.entry.to);function aB({text:e,busy:t,working:n,answering:r}){let i=!!e?.trim();if(!i&&(!t||n))return null;let a=i?`MASTER`:r??`MASTER`;return(0,U.jsx)(CO,{source:a,name:gO(a),head:!0,named:!0,live:t,waiting:!i,aside:t&&i?`writing…`:void 0,children:i?(0,U.jsx)(Mz,{text:e??``}):null})}function oB({hasTask:e}){return(0,U.jsxs)(FO,{className:`h-full border-0`,children:[(0,U.jsxs)(IO,{children:[(0,U.jsx)(RO,{variant:`icon`,children:(0,U.jsx)(jh,{"aria-hidden":`true`})}),e?null:(0,U.jsx)(zO,{children:$z}),(0,U.jsx)(BO,{children:e?tB:eB})]}),e?null:(0,U.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm text-muted-foreground`,children:[(0,U.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[(0,U.jsx)(GD,{chord:`@`}),` names who answers: @design, @dev, @qa, @research, @scout`]}),(0,U.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[(0,U.jsx)(GD,{chord:`/`}),` /plan plans it with the panel, /task starts it as a task`]})]})]})}async function sB(e){let t=await R(`lobby.history`,{before:e});return{entries:t.entries,hasOlder:t.hasOlder}}function cB(e,t,n){let[r,i]=(0,m.useState)([]),[a,o]=(0,m.useState)(t),[s,c]=(0,m.useState)(!1),l=(0,m.useMemo)(()=>{let t=new Set(e.map(e=>e.id));return[...r.filter(e=>!t.has(e.id)),...e]},[r,e]);return{merged:l,more:a,loading:s,load:(0,m.useCallback)(async()=>{let e=l[0]?.id;if(e===void 0||s||!a)return;c(!0);let t=n.current,r=t?.scrollHeight??0,u=t?.scrollTop??0;try{let t=await sB(e);i(e=>[...t.entries,...e]),o(t.hasOlder),window.requestAnimationFrame(()=>{let e=n.current;e&&(e.scrollTop=e.scrollHeight-r+u)})}catch{o(!1)}finally{c(!1)}},[l,s,a,n])}}var lB=[];function uB({chat:e,activity:t=lB,reply:n,busy:r,answering:i,hasOlder:a,hasTask:o}){let s=(0,m.useMemo)(()=>t.slice(-400),[t]),{ref:c,atBottom:l,stick:u,onScroll:d}=cO(`${e.length}:${n?.length??0}:${s.length}:${s.at(-1)?.pending??``}:${i??``}`),{merged:f,more:p,loading:h,load:g}=cB(e,a,c),_=(0,m.useCallback)(()=>{d();let e=c.current;e&&e.scrollTop<80&&p&&!h&&g()},[d,c,p,h,g]),v=(0,m.useMemo)(()=>Zz(f,s),[f,s]),y=f.length===0&&s.length===0&&!n?.trim()&&!r,b=v.at(-1),x=b?.kind===`activity`&&!!Jz(b.entries).live,[S,C]=(0,m.useState)(!1);return(0,m.useEffect)(()=>C(!0),[]),(0,U.jsxs)(GO,{"aria-label":`Conversation`,"data-bare":!0,className:`flex-1 rounded-none border-0 shadow-none`,children:[(0,U.jsx)(`div`,{ref:c,onScroll:_,className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-5 pt-4 pb-dock outline-none focus-visible:bg-muted/30`,role:`log`,"aria-label":`Conversation`,tabIndex:0,children:y?(0,U.jsx)(oB,{hasTask:o}):(0,U.jsxs)(`div`,{className:`chat-column`,children:[p?(0,U.jsx)(`p`,{className:`mb-4 text-center text-xs text-muted-foreground`,children:`Earlier messages load as you scroll up.`}):null,v.map((e,t)=>{if(e.kind===`activity`)return(0,U.jsx)(Xz,{entries:e.entries},e.key);let n=v[t-1],r=n?.kind===`message`?n.entry:void 0,i=!r||mO(r)!==mO(e.entry)||e.entry.at-r.at>Qz;return(0,U.jsx)(iB,{entry:e.entry,head:i,fresh:S},e.entry.id)}),(0,U.jsx)(aB,{text:n,busy:r,working:x,...i?{answering:i}:{}})]})}),(0,U.jsx)(Bv,{target:c,down:!1}),l?null:(0,U.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-dock z-10 flex justify-center [&>*]:pointer-events-auto`,children:(0,U.jsx)(DO,{onClick:u})})]})}var dB=new Set(PR);function fB(e){let t=e.replace(/^#\/?/,``).split(`/`).filter(Boolean);if(t[0]===`sessions`||t[0]===`issues`||t[0]===`git`||t[0]===`excalidraw`||t[0]===`metrics`)return`#/lobby`;if(t[0]===`tasks`&&t[1]===`board`)return[`#/tasks`,...t.slice(2,3)].join(`/`)}function pB(e){let t=e.replace(/^#\/?/,``).split(`/`).filter(Boolean),n=t[0];if(!n||n===`lobby`)return{kind:`tab`,tab:`lobby`,rest:t.slice(1)};if(n===`settings`)return{kind:`settings`};if(dB.has(n))return{kind:`tab`,tab:n,rest:t.slice(1)}}function mB(e,...t){return`#/${e}${t.filter(Boolean).map(e=>`/${encodeURIComponent(e)}`).join(``)}`}function hB(e){window.location.hash!==e&&(window.location.hash=e)}function gB(){let[e,t]=(0,m.useState)(()=>pB(fB(window.location.hash)??window.location.hash)??{kind:`tab`,tab:`lobby`,rest:[]});return(0,m.useEffect)(()=>{let e=()=>{let e=fB(window.location.hash),n=pB(e||window.location.hash);(e||!n)&&window.history.replaceState(null,``,e??`#/lobby`),t(n??{kind:`tab`,tab:`lobby`,rest:[]})};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),e}function _B(e){let t=e[0]===`ask`,[n,r]=t?e.slice(1):e;return{chat:t,agent:n,file:r}}function vB(e,t){let{agent:n,file:r}=_B(e);return mB(`knowledge`,...t?[`ask`]:[],n??``,r??``)}function yB({className:e,...t}){return(0,U.jsx)(`span`,{"data-slot":`spinner`,role:`status`,"aria-label":`Loading`,className:Y(`inline-flex size-4 shrink-0 items-end justify-between text-primary`,e),...t,children:[0,1,2].map(e=>(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`block aspect-square h-[28%] shrink-0 rounded-full bg-current motion-safe:animate-[hop_0.9s_ease-in-out_infinite]`,style:{animationDelay:`${e*.14}s`}},e))})}var bB=Uv([`relative w-full text-sm border has-[>svg]:grid-cols-[calc(var(--spacing)*3)_1fr] grid-cols-[0_1fr] grid gap-y-0.5 items-center [&>svg:not([class*=size-])]:size-4`,`has-[>[data-slot=alert-title]+[data-slot=alert-description]]:[&_[data-slot=alert-action]]:sm:row-end-3`,`has-[>[data-slot=alert-title]+[data-slot=alert-description]]:items-start`,`has-[>[data-slot=alert-title]+[data-slot=alert-description]]:[&_svg]:translate-y-0.5`,`rounded-lg`,`px-3`,`py-2.5`,`has-[>svg]:gap-x-2.5`],{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`border-destructive/30 bg-destructive/4 [&>svg]:text-destructive`,info:`border-info/30 bg-info/4 [&>svg]:text-info`,success:`border-success/30 bg-success/4 [&>svg]:text-success`,warning:`border-warning/30 bg-warning/4 [&>svg]:text-warning`,invert:`border-invert bg-invert text-invert-foreground [&_[data-slot=alert-description]]:text-invert-foreground/70`}},defaultVariants:{variant:`default`}});function xB({className:e,variant:t,...n}){return(0,U.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:Y(bB({variant:t}),e),...n})}function SB({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`alert-description`,className:Y(`text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed`,e),...t})}function CB({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`alert-action`,className:Y(`flex gap-1.5 max-sm:col-start-2 max-sm:mt-2 max-sm:justify-start sm:col-start-3 sm:row-start-1 sm:justify-end sm:self-center`,e),...t})}function wB({label:e=`Connecting…`}){return(0,U.jsxs)(`div`,{className:`flex min-h-48 min-w-0 w-full max-w-full flex-1 items-center justify-center gap-2 overflow-y-auto px-4 py-8 text-sm text-muted-foreground`,children:[(0,U.jsx)(yB,{}),(0,U.jsx)(`span`,{children:e})]})}function TB({message:e,onRetry:t}){return(0,U.jsxs)(FO,{className:`m-4 min-h-0 min-w-0 flex-1 overflow-y-auto`,children:[(0,U.jsxs)(IO,{children:[(0,U.jsxs)(zO,{className:`flex items-center gap-2`,children:[(0,U.jsx)(qg,{className:`size-4 text-destructive`,"aria-hidden":`true`}),`Could not load this view`]}),(0,U.jsx)(BO,{children:e??`The request failed. Try again.`})]}),t?(0,U.jsxs)(X,{variant:`outline`,onClick:t,children:[(0,U.jsx)(hg,{"aria-hidden":`true`}),`Try again`]}):null]})}function EB({onRetry:e}){return(0,U.jsxs)(xB,{variant:`destructive`,role:`status`,className:`mx-3 mb-1 max-h-32 w-auto min-w-0 overflow-y-auto max-sm:mx-2`,children:[(0,U.jsx)(r_,{className:`size-4`,"aria-hidden":`true`}),(0,U.jsx)(SB,{children:`Lost pi — reconnecting every 2 s. Your planning session and tasks carry on when it is back.`}),e?(0,U.jsx)(CB,{children:(0,U.jsx)(X,{variant:`link`,className:`h-8 px-1 text-destructive`,onClick:e,children:`Retry now`})}):null]})}function DB(e,t,n,r=!0){iO();let[i,a]=(0,m.useState)({loading:!0,at:0}),[o,s]=(0,m.useState)(0),c=[F.status().connection,...n.map(e=>F.get(e).version)].join(`,`),l=JSON.stringify(t);(0,m.useEffect)(()=>{if(!r)return;let t=!0,n=performance.now();return a(e=>({...e,loading:!0})),R(e,JSON.parse(l)).then(e=>t&&a({data:e,loading:!1,at:n}),e=>t&&a(t=>({...t,error:e instanceof Error?e.message:String(e),loading:!1}))),()=>{t=!1}},[e,l,c,o,r]);let u=(0,m.useCallback)(()=>s(e=>e+1),[]);return{data:i.data,error:i.error,loading:i.loading,requestedAt:i.at,reload:u}}function OB({...e}){return(0,U.jsx)(bS,{"data-slot":`sheet`,...e})}function kB({...e}){return(0,U.jsx)(VS,{"data-slot":`sheet-close`,...e})}function AB({...e}){return(0,U.jsx)(ES,{"data-slot":`sheet-portal`,...e})}function jB({className:e,...t}){return(0,U.jsx)(OS,{"data-slot":`sheet-overlay`,className:Y(`fixed inset-0 z-50 bg-scrim backdrop-blur-sm duration-150 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function MB({className:e,children:t,side:n=`right`,showCloseButton:r=!0,forceMount:i,hidden:a,...o}){return(0,U.jsxs)(AB,{forceMount:i,children:[a?null:(0,U.jsx)(jB,{}),(0,U.jsxs)(MS,{forceMount:i,hidden:a,"data-slot":`sheet-content`,"data-side":n,className:Y(`glass-pop fixed z-50 flex flex-col gap-4 bg-clip-padding text-sm shadow-lg/5 transition duration-200 ease-calm data-[side=bottom]:rounded-t-2xl data-[side=top]:rounded-b-2xl data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-8 data-[side=left]:data-open:slide-in-from-left-8 data-[side=right]:data-open:slide-in-from-right-8 data-[side=top]:data-open:slide-in-from-top-8 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-8 data-[side=left]:data-closed:slide-out-to-left-8 data-[side=right]:data-closed:slide-out-to-right-8 data-[side=top]:data-closed:slide-out-to-top-8`,e),...o,children:[t,r&&(0,U.jsx)(VS,{"data-slot":`sheet-close`,asChild:!0,children:(0,U.jsxs)(X,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,U.jsx)(s_,{}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function NB({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`sheet-header`,className:Y(`flex flex-col gap-0.5 p-4`,e),...t})}function PB({className:e,...t}){return(0,U.jsx)(LS,{"data-slot":`sheet-title`,className:Y(`text-base font-medium text-foreground`,e),...t})}function FB({className:e,...t}){return(0,U.jsx)(zS,{"data-slot":`sheet-description`,className:Y(`text-sm text-muted-foreground`,e),...t})}var IB=Uv(`bg-muted-foreground/15 motion-safe:animate-skeleton`,{variants:{shape:{block:`rounded-sm`,card:`rounded-lg`,pill:`rounded-full`}},defaultVariants:{shape:`block`}});function LB({className:e,shape:t,...n}){return(0,U.jsx)(`div`,{"aria-hidden":`true`,className:Y(IB({shape:t}),e),"data-slot":`skeleton`,...n})}function RB(){return sO(`(min-width: 1024px)`)}function zB({className:e,...t}){return(0,U.jsx)(`section`,{className:Y(`min-h-0 min-w-0`,e),...t})}function BB({open:e,onClose:t,describe:n,children:r}){let i=tO(e,eO.sheet),a=(0,m.useRef)(!1),o=(0,m.useRef)(null);return i&&(a.current=!0),e||(a.current=!1),(0,U.jsx)(OB,{open:e&&i,onOpenChange:e=>!e&&t(),children:(0,U.jsxs)(MB,{forceMount:e&&a.current?!0:void 0,hidden:!i,showCloseButton:!1,side:`right`,className:Y(`gap-0 data-[side=right]:w-[92%] data-[side=right]:sm:max-w-3xl`,!i&&`!hidden`),children:[(0,U.jsxs)(NB,{className:`flex-row items-center justify-between border-b px-4 py-2`,children:[(0,U.jsx)(PB,{className:`text-sm`,children:`Detail`}),(0,U.jsx)(FB,{className:`sr-only`,children:n}),(0,U.jsx)(kB,{asChild:!0,children:(0,U.jsxs)(X,{variant:`ghost`,size:`sm`,"aria-label":`Close detail`,title:`Close · Esc`,className:`gap-2`,children:[(0,U.jsx)(s_,{"aria-hidden":`true`}),`Close`,(0,U.jsx)(GD,{chord:`Esc`,className:`kbd-hint`})]})})]}),(0,U.jsx)(`div`,{ref:o,className:`min-h-0 flex-1 overflow-y-auto p-5`,children:r}),(0,U.jsx)(Bv,{target:o})]})})}function VB({list:e,detail:t,open:n,detailClassName:r,listPane:i,detailPane:a,onListKey:o,onDetailKey:s}){let c=n&&t!==null;return(0,U.jsxs)(`div`,{className:Y(`relative grid min-h-0 min-w-0 flex-1`,c?`grid-rows-[minmax(0,1fr)_minmax(0,2fr)]`:`grid-rows-1`),children:[(0,U.jsx)(zB,{"data-pane":`list`,ref:i,onKeyDown:o,className:Y(`min-w-0 overflow-x-hidden overflow-y-auto`,c?`border-b border-border`:`pb-dock`),children:e}),c?(0,U.jsx)(zB,{"data-pane":`detail`,ref:a,"aria-label":`Detail`,tabIndex:0,onKeyDown:s,className:Y(`min-w-0 overflow-x-hidden overflow-y-auto px-5 pt-5 pb-dock`,r),children:t}):null,(0,U.jsx)(Bv,{target:i}),c?(0,U.jsx)(Bv,{target:a}):null]})}function HB({wide:e,list:t,detail:n,open:r,onClose:i,hint:a,describe:o,inlineDetail:s,detailClassName:c}){let l=(0,m.useRef)(null),u=(0,m.useRef)(null),d=(0,m.useRef)(null);function f(t){let n=l.current;if(!n||t.defaultPrevented||t.nativeEvent.isComposing||nO()||t.altKey||t.ctrlKey||t.metaKey||aR(t.target)||t.target instanceof HTMLInputElement)return;let r=oR(t.key,!1);r?(t.preventDefault(),uR(n,t.target,r)):t.key===`Home`||t.key===`End`?(t.preventDefault(),uR(n,t.target,t.key===`Home`?`first`:`last`)):(e||s)&&sR(t.key)===1&&u.current&&(t.preventDefault(),u.current.focus())}function p(e){e.defaultPrevented||e.nativeEvent.isComposing||nO()||e.altKey||e.ctrlKey||e.metaKey||aR(e.target)||sR(e.key)===-1&&l.current&&(e.preventDefault(),fR(l.current)?.focus())}return!e&&s?(0,U.jsx)(VB,{list:t,detail:n,open:r,detailClassName:c,listPane:l,detailPane:u,onListKey:f,onDetailKey:p}):e?(0,U.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[clamp(17rem,28%,23rem)_minmax(0,1fr)] gap-3 p-3`,children:[(0,U.jsxs)(`div`,{className:`workspace-pane min-h-0 min-w-0 overflow-hidden rounded-xl border shadow-xs`,children:[(0,U.jsx)(zB,{"data-pane":`list`,ref:l,onKeyDown:f,className:`h-full overflow-y-auto pb-dock`,children:t}),(0,U.jsx)(Bv,{target:l})]}),(0,U.jsxs)(`div`,{className:`workspace-pane min-h-0 min-w-0 overflow-hidden rounded-xl border shadow-xs`,children:[(0,U.jsx)(zB,{"data-pane":`detail`,ref:u,tabIndex:0,"aria-label":`Detail`,onKeyDown:p,className:Y(`h-full overflow-y-auto px-5 pt-5 pb-dock outline-none focus-visible:bg-muted/30`,c),children:n??(0,U.jsx)(`div`,{className:`grid h-full min-h-48 place-items-center`,children:(0,U.jsxs)(`div`,{className:`flex max-w-xs flex-col items-center gap-3 text-center`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`flex size-10 items-center justify-center rounded-xl bg-muted text-muted-foreground`,children:(0,U.jsx)(qh,{className:`size-5`})}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a}),(0,U.jsxs)(`p`,{className:`kbd-hint flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(GD,{chord:`ArrowUp`}),(0,U.jsx)(GD,{chord:`ArrowDown`}),`move`]}),(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(GD,{chord:`ArrowRight`}),`open`]})]})]})})}),(0,U.jsx)(Bv,{target:u})]})]}):(0,U.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,U.jsxs)(`div`,{ref:d,className:`flex min-h-0 flex-1 flex-col overflow-y-auto pb-dock`,children:[(0,U.jsx)(zB,{"data-pane":`list`,ref:l,onKeyDown:f,children:t}),(0,U.jsx)(BB,{open:r&&n!==null,onClose:i,describe:o,children:n})]}),(0,U.jsx)(Bv,{target:d})]})}function UB({title:e,count:t,lead:n,children:r}){return(0,U.jsxs)(`div`,{className:`sticky top-0 z-10 flex min-h-12 flex-wrap items-center gap-x-3 gap-y-1 border-b border-[var(--glass-edge)] sticky-glass px-4 py-2`,children:[(0,U.jsx)(`h2`,{className:n?`sr-only`:`text-sm font-medium`,children:e}),n,(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-2 flex-1`}),t?(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:t}):null,r?(0,U.jsx)(`div`,{className:`flex items-center gap-1.5`,children:r}):null]})}function WB(){return(0,U.jsx)(`div`,{className:`flex flex-col gap-1.5 p-3`,role:`status`,"aria-label":`Loading`,children:[0,1,2,3].map(e=>(0,U.jsx)(LB,{shape:`card`,className:`h-11`},e))})}function GB({...e}){return(0,U.jsx)(aC,{"data-slot":`alert-dialog`,...e})}function KB({...e}){return(0,U.jsx)(oC,{"data-slot":`alert-dialog-portal`,...e})}function qB({className:e,...t}){return(0,U.jsx)(sC,{"data-slot":`alert-dialog-overlay`,className:Y(`fixed inset-0 z-50 bg-scrim backdrop-blur-sm duration-150 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function JB({className:e,...t}){return(0,U.jsxs)(KB,{children:[(0,U.jsx)(qB,{}),(0,U.jsx)(cC,{"data-slot":`alert-dialog-content`,className:Y(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 glass-pop rounded-2xl p-4 text-sm duration-200 data-open:zoom-in-[0.98] data-closed:zoom-out-[0.98] outline-none sm:max-w-md data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})]})}function YB({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:Y(`flex flex-col gap-1.5`,e),...t})}function XB({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:Y(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function ZB({className:e,...t}){return(0,U.jsx)(dC,{"data-slot":`alert-dialog-title`,className:Y(`text-base font-medium text-foreground`,e),...t})}function QB({className:e,...t}){return(0,U.jsx)(fC,{"data-slot":`alert-dialog-description`,className:Y(`text-sm text-muted-foreground`,e),...t})}function $B({className:e,variant:t=`default`,...n}){return(0,U.jsx)(X,{variant:t,size:`sm`,className:Y(`h-7 gap-1 px-2.5`,e),asChild:!0,children:(0,U.jsx)(lC,{"data-slot":`alert-dialog-action`,...n})})}function eV({className:e,...t}){return(0,U.jsx)(X,{variant:`outline`,size:`sm`,className:Y(`h-7 gap-1 px-2.5`,e),asChild:!0,children:(0,U.jsx)(uC,{"data-slot":`alert-dialog-cancel`,...t})})}function tV({label:e,text:t,shortcut:n,title:r,description:i,confirmLabel:a,onConfirm:o,icon:s,disabled:c,variant:l=`outline`,iconOnly:u,compact:d}){let[f,p]=(0,m.useState)(!1),h=tO(f,eO.confirm),g=l===`destructive`;return bR(`y`,()=>{p(!1),o()},{enabled:f&&h,inDialog:!0}),(0,U.jsxs)(GB,{open:f&&h,onOpenChange:p,children:[(0,U.jsx)(SR,{label:e,icon:s,tone:g?`danger`:`neutral`,disabled:c,shortcut:n,iconOnly:u,...d?{"data-compact":!0,className:`size-8`}:{},...t?{text:t}:{},onClick:()=>p(!0)}),(0,U.jsxs)(JB,{children:[(0,U.jsxs)(YB,{children:[(0,U.jsx)(ZB,{children:r}),(0,U.jsx)(QB,{children:i})]}),(0,U.jsxs)(XB,{children:[(0,U.jsxs)(eV,{children:[`Keep it`,(0,U.jsx)(GD,{chord:`Esc`,className:`kbd-hint ml-1`})]}),(0,U.jsxs)($B,{variant:g?`destructive`:`default`,onClick:o,children:[a,(0,U.jsx)(GD,{chord:`Y`,className:`kbd-hint ml-1`})]})]})]})]})}function nV({className:e,...t}){return(0,U.jsx)(`textarea`,{"data-slot":`textarea`,className:Y(`flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-background bg-clip-padding px-3 py-2 text-sm shadow-control transition-[border-color,box-shadow] duration-150 outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/24 focus-visible:shadow-none disabled:cursor-not-allowed disabled:opacity-64 aria-invalid:border-destructive/36 aria-invalid:focus-visible:border-destructive/64 aria-invalid:focus-visible:ring-destructive/16 dark:bg-input/32`,e),...t})}function rV(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function iV({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,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium text-foreground`,children:e}),(0,U.jsx)(nV,{id:i,value:a,rows:2,"aria-describedby":t?`${i}-hint`:void 0,onChange:e=>o(e.target.value),onKeyDown:e=>{rV(e)&&(e.preventDefault(),l())}}),t?(0,U.jsx)(`p`,{id:`${i}-hint`,className:`text-xs text-muted-foreground`,children:t}):null,(0,U.jsx)(`div`,{className:`flex self-end`,children:(0,U.jsx)(SR,{label:n,icon:s?xh:zp,tone:`primary`,shortcut:`Enter`,className:s?`[&_svg]:animate-spin`:void 0,onClick:()=>void l(),disabled:!a.trim()||s})})]})}function aV({title:e,right:t,prominent:n,children:r}){return(0,U.jsxs)(`section`,{className:Y(`flex min-w-0 flex-col`,n?`gap-4`:`workspace-section gap-3 rounded-xl border p-4 shadow-xs`),children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:(0,U.jsx)(KO,{title:e,right:t,className:n?`[&>span:first-child]:font-semibold`:void 0})}),r]})}var oV=[`master`,`designer`,`backend`,`qa`],sV={master:`Master (oracle)`,designer:`Designer`,backend:`Backend`,qa:`QA`},cV={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`},lV=`Every write archives the version before it.`;function uV(e){if(e<1e3)return String(e);let t=e/1e3;return`${t>=10?Math.round(t):t.toFixed(1)}k`}function dV(e){return`over the compaction threshold — ask the oracle to compact ${e}`}function fV(e){return{text:e.text,occurrence:e.occurrence}}function pV(e){return oV.map(t=>{let n=e.filter(e=>e.agent===t);return{agent:t,files:n,notes:n.reduce((e,t)=>e+t.notes,0)}}).filter(e=>e.files.length>0)}function mV(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function hV({initial:e,busy:t,onSave:n,onCancel:r}){let[i,a]=(0,m.useState)(e),o=()=>{!t&&i.trim()&&n(i)};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-input p-3`,children:[(0,U.jsx)(`label`,{htmlFor:`knowledge-entry`,className:`text-sm font-medium text-foreground`,children:`Edit entry`}),(0,U.jsx)(nV,{id:`knowledge-entry`,value:i,rows:4,autoFocus:!0,onChange:e=>a(e.target.value),onKeyDown:e=>{mV(e)&&(e.preventDefault(),o())}}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:lV}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(X,{variant:`outline`,onClick:r,disabled:t,children:`Cancel`}),(0,U.jsxs)(X,{onClick:o,disabled:t||!i.trim(),children:[t?(0,U.jsx)(yB,{}):null,`Save`]})]})]})]})}function gV({open:e,file:t,initial:n,busy:r,onClose:i,onSave:a}){let[o,s]=(0,m.useState)(n),c=tO(e,eO.confirm);return(0,U.jsx)(qD,{open:e&&c,onOpenChange:e=>!e&&i(),label:`Edit ${t}`,description:lV,dismissOnBackdrop:!1,className:`max-w-3xl`,children:(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`h2`,{className:`text-base font-medium`,children:[`Edit `,t]}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:lV})]}),(0,U.jsx)(nV,{value:o,rows:14,className:`min-h-0 flex-1 font-mono text-sm`,onChange:e=>s(e.target.value)}),(0,U.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(X,{variant:`outline`,onClick:i,disabled:r,children:`Cancel`}),(0,U.jsxs)(X,{onClick:()=>a(o),disabled:r,children:[r?(0,U.jsx)(yB,{}):null,`Save file`]})]})]})})}function _V({note:e,about:t,onTakeBack:n,busy:r}){let i=t?`about "${t.replace(/\s+/g,` `).trim().slice(0,50)}": ${e.text}`:e.text;return(0,U.jsxs)(`li`,{className:`flex items-start gap-2 text-sm text-muted-foreground`,children:[(0,U.jsx)($h,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-primary`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:i}),(0,U.jsx)(SR,{label:`Take the note back`,icon:Yg,iconOnly:!0,className:`-my-1 size-7`,disabled:r,onClick:()=>n(e.id)})]})}function vV({entry:e,index:t,selected:n,notes:r,onPick:i,onTakeBack:a,busy:o}){let s=()=>i(t);return(0,U.jsxs)(`li`,{role:`button`,tabIndex:0,"aria-pressed":n,onClick:s,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},className:n?`flex min-h-9 cursor-pointer flex-col gap-1 rounded-lg border border-primary/30 bg-accent px-3 py-2.5 outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`:`flex min-h-9 cursor-pointer flex-col gap-1 rounded-lg border border-border px-3 py-2.5 outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[(0,U.jsx)(`div`,{className:`flex gap-2`,children:(0,U.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,U.jsx)(Mz,{text:e.text})})}),r.length>0?(0,U.jsx)(`ul`,{className:`flex flex-col gap-1 pl-1`,children:r.map(e=>(0,U.jsx)(_V,{note:e,onTakeBack:a,busy:o},e.id))}):null]})}function yV({notes:e,onTakeBack:t,busy:n}){return e.length===0?null:(0,U.jsx)(aV,{title:`Notes on entries that changed`,right:String(e.length),children:(0,U.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,U.jsx)(_V,{note:e,about:e.entry,onTakeBack:t,busy:n},e.id))})})}function bV({view:e}){let t=e.entries.length;return(0,U.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(`h2`,{className:`min-w-0 break-words text-lg font-semibold tracking-tight`,children:[cV[e.agent],` `,(0,U.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,e.file]})]}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` `,t===1?`entry`:`entries`,` · `,uV(e.chars),` chars`]}),e.over?(0,U.jsx)(`p`,{className:`text-sm text-foreground`,children:dV(e.file)}):null]})}function xV({draft:e,picked:t,setDraft:n,onEditFile:r,onDelete:i}){let a=!!e;return(0,U.jsxs)(CR,{children:[(0,U.jsx)(SR,{label:`Edit the entry`,text:`Edit`,icon:tg,shortcut:`E`,disabled:a||!t,onClick:()=>n({kind:`edit`,entry:t})}),(0,U.jsx)(SR,{label:t?`Add an entry after it`:`Add an entry`,text:`Add`,icon:sg,shortcut:`A`,disabled:a,onClick:()=>n({kind:`add`,entry:t})}),(0,U.jsx)(SR,{label:`Comment on the entry`,text:`Comment`,icon:kh,shortcut:`C`,disabled:a||!t,onClick:()=>n({kind:`comment`,entry:t})}),(0,U.jsx)(SR,{label:`Edit the whole file`,text:`Edit file`,icon:Um,shortcut:`F`,disabled:a,onClick:r}),(0,U.jsx)(tV,{icon:Gg,label:`Delete the entry`,text:`Delete`,shortcut:`Delete`,title:`Delete this entry?`,description:`The entry and its notes are removed. The version before is archived.`,confirmLabel:`Delete entry`,variant:`destructive`,disabled:a||!t,onConfirm:i})]})}function SV({agent:e,file:t,onChanged:n}){let r=DB(`knowledge.open`,{agent:e,file:t},[`knowledge`]),[i,a]=(0,m.useState)(0),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=r.data?.view,p=f?.entries??[],h=p[Math.min(i,Math.max(0,p.length-1))],g=async e=>{d(!0),await e(),s(void 0),r.reload(),n(),d(!1)},_=e=>void g(()=>mp(`knowledge.unnote`,{id:e})),v=()=>{h&&g(()=>mp(`knowledge.remove`,{agent:e,file:t,ref:fV(h)}))},y=n=>{let r=o?.entry;if(o?.kind===`edit`&&r)return void g(()=>mp(`knowledge.edit`,{agent:e,file:t,ref:fV(r),text:n}));if(o?.kind===`comment`&&r)return void g(()=>mp(`knowledge.comment`,{agent:e,file:t,ref:fV(r),text:n}));g(()=>mp(`knowledge.add`,{agent:e,file:t,...h?{ref:fV(h)}:{},text:n}))};return f?(0,U.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${cV[e]} ${t}`,children:[(0,U.jsx)(xV,{draft:o,picked:h,setDraft:s,onEditFile:()=>l(!0),onDelete:v}),(0,U.jsx)(bV,{view:f}),p.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing here yet. Add the first entry below.`}):null,(0,U.jsx)(`ul`,{className:`workspace-section flex flex-col gap-2 rounded-xl border p-3 shadow-xs`,children:p.map((e,t)=>(0,U.jsx)(vV,{entry:e,index:t,selected:t===i,notes:f.attached.filter(t=>t.entry===e.text),onPick:a,onTakeBack:_,busy:u},`${t}-${e.text}`))}),o?.kind===`edit`?(0,U.jsx)(hV,{initial:o.entry.text,busy:u,onSave:y,onCancel:()=>s(void 0)}):null,o?.kind===`comment`?(0,U.jsx)(iV,{label:`Comment on this entry`,hint:lV,buttonLabel:`Add note`,onSend:async e=>(y(e),!0)}):null,o?.kind===`add`?(0,U.jsx)(iV,{label:`Add an entry`,hint:lV,buttonLabel:`Add entry`,onSend:async e=>(y(e),!0)}):null,u&&!o?(0,U.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,U.jsx)(yB,{}),` saving…`]}):null,(0,U.jsx)(yV,{notes:f.detached,onTakeBack:_,busy:u}),(0,U.jsx)(gV,{open:c,file:t,initial:f.content,busy:u,onClose:()=>l(!1),onSave:n=>{l(!1),g(()=>mp(`knowledge.replaceFile`,{agent:e,file:t,text:n}))}})]}):r.error?(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not read the file. `,r.error]}):(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`reading…`})}function CV(e){return`${e.agent}/${e.file}`}var wV=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function TV({info:e}){return(0,U.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs text-muted-foreground tabular-nums`,children:[(0,U.jsx)(`span`,{children:uV(e.chars)}),e.over?(0,U.jsx)(`span`,{className:`text-foreground`,children:`· over`}):null,e.notes>0?(0,U.jsx)(`span`,{className:`text-primary`,children:wV(e.notes,`note`)}):null]})}function EV({name:e}){let t=e.split(`.`).pop()?.toLowerCase();return t===`md`||t===`mdx`||t===`txt`?(0,U.jsx)(Ym,{"aria-hidden":`true`,className:`ktree-icon`,"data-ext":`md`}):t===`json`||t===`yaml`||t===`yml`||t===`toml`?(0,U.jsx)(zm,{"aria-hidden":`true`,className:`ktree-icon`,"data-ext":`data`}):(0,U.jsx)($m,{"aria-hidden":`true`,className:`ktree-icon`})}function DV({info:e,selected:t,onSelect:n}){return(0,U.jsx)(`li`,{className:`ktree-leaf`,children:(0,U.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(CV(e)),title:e.label,className:`ktree-row ktree-file`,children:[(0,U.jsx)(EV,{name:e.file}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,U.jsxs)(`span`,{className:`sr-only`,children:[e.label,`, `]}),(0,U.jsx)(`span`,{"aria-hidden":`true`,children:e.file})]}),(0,U.jsx)(TV,{info:e})]})})}var OV=`bot-lobby.knowledge.folded`;function kV(){try{let e=JSON.parse(window.localStorage.getItem(OV)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function AV({files:e,models:t={},selectedKey:n,onSelect:r}){let[i,a]=(0,m.useState)(kV),o=pV(e),s=e.reduce((e,t)=>e+t.notes,0);function c(e,t){a(n=>{let r=t?n.filter(t=>t!==e):[...new Set([...n,e])];try{window.localStorage.setItem(OV,JSON.stringify(r))}catch{}return r})}return(0,U.jsxs)(`div`,{className:`ktree px-2 pt-2 pb-3`,children:[(0,U.jsxs)(`p`,{className:`ktree-row ktree-root`,children:[(0,U.jsx)(ph,{"aria-hidden":`true`,className:`ktree-icon`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:`Project knowledge`}),(0,U.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[wV(e.length,`file`),` · `,wV(o.length,`agent`),s>0?` · ${wV(s,`note`)}`:``]})]}),(0,U.jsx)(`ul`,{className:`ktree-branches`,"aria-label":`Agents and their knowledge`,children:o.map(e=>{let a=!i.includes(e.agent),o=`knowledge-${e.agent}`,s=t[e.agent];return(0,U.jsxs)(`li`,{className:`ktree-branch`,children:[(0,U.jsx)(`h3`,{className:`font-normal`,children:(0,U.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space ArrowLeft ArrowRight`,"aria-describedby":`focused-action-help`,type:`button`,"aria-expanded":a,"aria-controls":o,onClick:()=>c(e.agent,!a),onKeyDown:t=>{t.key===`ArrowLeft`||t.key===`h`?(t.preventDefault(),t.stopPropagation(),c(e.agent,!1)):(t.key===`ArrowRight`||t.key===`l`)&&(t.preventDefault(),t.stopPropagation(),a||c(e.agent,!0))},className:`ktree-row ktree-node`,children:[(0,U.jsx)(am,{"aria-hidden":`true`,className:Y(`ktree-chevron`,a&&`rotate-90`)}),a?(0,U.jsx)(th,{"aria-hidden":`true`,className:`ktree-icon ktree-folder`}):(0,U.jsx)(rh,{"aria-hidden":`true`,className:`ktree-icon ktree-folder`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,U.jsx)(`span`,{className:`text-foreground`,children:sV[e.agent]}),s?(0,U.jsxs)(`span`,{className:`ms-2 text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`sr-only`,children:`runs on `}),s]}):null]}),(0,U.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[e.notes>0?(0,U.jsxs)(`span`,{className:`text-primary`,children:[wV(e.notes,`note`),` · `]}):null,wV(e.files.length,`file`)]})]})}),(0,U.jsx)(ju,{initial:!1,children:a?(0,U.jsx)(Xf.ul,{id:o,"aria-label":`${sV[e.agent]}'s knowledge`,initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{type:`spring`,stiffness:520,damping:42},className:`ktree-leaves`,children:e.files.map(e=>(0,U.jsx)(DV,{info:e,selected:CV(e)===n,onSelect:r},CV(e)))},`files`):null})]},e.agent)})})]})}var jV=()=>hB(mB(`knowledge`)),MV=e=>{let[t,n]=e.split(`/`);hB(mB(`knowledge`,t??``,n??``))};function NV(){return(0,U.jsx)(FO,{className:`m-4 flex-1`,children:(0,U.jsxs)(IO,{children:[(0,U.jsx)(RO,{variant:`icon`,children:(0,U.jsx)(qp,{"aria-hidden":`true`})}),(0,U.jsx)(BO,{children:`No knowledge files yet.`})]})})}function PV(e,t,n,r){let i=e.find(e=>e.agent===t&&e.file===n);return i?(0,U.jsx)(SV,{agent:i.agent,file:i.file,onChanged:r},CV(i)):t&&n?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That file is not on the list any more.`}):null}function FV(){let e=oO(`lobby`),t=oO(`status`),n=e.data,r=t.data?.busy??!1;return!n?.chat.length&&!n?.reply&&!r?(0,U.jsx)(`p`,{className:`m-auto max-w-md px-5 pb-dock text-center text-sm text-muted-foreground`,children:`Ask about this project below. The oracle checks saved knowledge, searches the codebase for missing information, and saves verified findings.`}):(0,U.jsx)(uB,{chat:n?.chat??[],reply:n?.reply,busy:r,hasOlder:n?.hasOlderChat??!1,hasTask:!!n?.task})}function IV({read:e,selected:t}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(UB,{title:`Knowledge`}),(0,U.jsx)(LV,{read:e,selected:t})]})}function LV({read:e,selected:t}){return!e.data&&e.error?(0,U.jsx)(TB,{message:`Could not load the knowledge files. ${e.error}`,onRetry:e.reload}):e.data?e.data.files.length?(0,U.jsx)(AV,{files:e.data.files,models:e.data.models??{},selectedKey:t,onSelect:MV}):(0,U.jsx)(NV,{}):(0,U.jsx)(WB,{})}function RV({rest:e}){let{chat:t,agent:n,file:r}=_B(e),i=RB(),a=DB(`knowledge.files`,{},[`knowledge`]),o=a.data?.files??[],s=o.find(e=>e.agent===n&&e.file===r);return(0,U.jsx)(HB,{wide:i,inlineDetail:!0,list:(0,U.jsx)(IV,{read:a,selected:s?CV(s):void 0}),detail:t?(0,U.jsx)(FV,{}):PV(o,n,r,a.reload),detailClassName:t?`flex flex-col overflow-hidden p-0`:void 0,open:t||!!(n&&r),onClose:jV,hint:`Select a file to read its entries, or ask about the project below.`,describe:t?`Knowledge chat`:`Knowledge file`})}function zV(e){let t=e[0];try{return{id:t?decodeURIComponent(t):void 0}}catch{return{id:t}}}var BV=e=>e?.panels??{conversation:!0,activity:!0,thinking:!0};function VV({data:e,status:t}){let n=BV(t);if(!n.conversation)return null;let r=n.activity?e?.activity:void 0;return(0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,U.jsx)(uB,{chat:e?.chat??[],...r?{activity:r}:{},reply:e?.reply,busy:t?.busy??!1,...e?.answering?{answering:e.answering}:{},hasOlder:e?.hasOlderChat??!1,hasTask:!!e?.task})})}function HV(){let e=oO(`lobby`),t=oO(`status`);return!e.data&&e.loading?(0,U.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,U.jsx)(yB,{}),(0,U.jsx)(`span`,{children:`Connecting…`})]}):!e.data&&e.error?(0,U.jsx)(TB,{message:e.error,onRetry:()=>F.onHello({})}):(0,U.jsx)(VV,{data:e.data,status:t.data})}var UV=class{seen=new Set;initialized=new Set;storage;constructor(e){this.storage=e;try{let t=JSON.parse(e?.getItem(`bot-lobby.prompt-seen`)??`[]`);Array.isArray(t)&&(this.seen=new Set(t.filter(e=>typeof e==`string`)))}catch{}}observe(e,t,n=!1){let r=this.initialized.has(e)&&!n?t.filter(e=>!this.seen.has(e)):[];this.initialized.add(e);for(let e of t)this.seen.add(e);try{this.storage?.setItem(`bot-lobby.prompt-seen`,JSON.stringify([...this.seen]))}catch{}return r}};function WV(e,t){return JSON.stringify([e,`prompt`,t])}function GV(e,t,n){return JSON.stringify([e,`dialog`,t,n])}function KV(e,t,n){return JSON.stringify([e,`delivery`,t,n])}var qV=`bot-lobby.prompt-sound-muted`,JV=new Set,YV,XV=!1;function ZV(){try{return localStorage.getItem(qV)===`on`}catch{return XV}}function QV(e){XV=e;try{localStorage.setItem(qV,e?`on`:`off`)}catch{}for(let e of JV)e()}function $V(e){return JV.add(e),()=>{JV.delete(e)}}function eH(){return(0,m.useSyncExternalStore)($V,ZV,()=>!1)}function tH(){(0,m.useEffect)(()=>{let e=()=>{try{YV??=new AudioContext,YV.resume().catch(()=>void 0)}catch{}};return window.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,e)}},[])}function nH(){if(!ZV()&&YV&&YV.state===`running`)try{let e=YV.currentTime,t=YV.createOscillator(),n=YV.createGain();t.frequency.setValueAtTime(960,e),t.frequency.exponentialRampToValueAtTime(360,e+.16),n.gain.setValueAtTime(1e-4,e),n.gain.exponentialRampToValueAtTime(.12,e+.012),n.gain.exponentialRampToValueAtTime(1e-4,e+.22),t.connect(n),n.connect(YV.destination),t.start(e),t.stop(e+.24),t.onended=()=>{t.disconnect(),n.disconnect()}}catch{}}var rH=`bot-lobby.notifications`,iH=`/icon-192.png`,aH=new Set;function oH(){for(let e of[...aH])e()}function sH(){try{return localStorage.getItem(rH)===`on`}catch{return!1}}function cH(e){return aH.add(e),()=>{aH.delete(e)}}function lH(e){try{localStorage.setItem(rH,e?`on`:`off`)}catch{}oH()}function uH(){return(0,m.useSyncExternalStore)(cH,sH,()=>!1)}async function dH(){return typeof Notification>`u`?`unsupported`:(Notification.permission==="default"&&await Notification.requestPermission().catch(()=>void 0),Notification.permission===`granted`?(lH(!0),`granted`):`denied`)}function fH(){lH(!1)}function pH(e){if(e===`completed`)return`finished`;if(e===`abandoned`)return`dropped`}function mH(){return typeof Notification<`u`&&Notification.permission===`granted`&&document.hidden}function hH(e){try{new Notification(`bot-lobby`,{body:e,icon:iH,tag:`bot-lobby`})}catch{}}function gH(){try{return new UV(sessionStorage)}catch{return new UV}}function _H(e,t){let n=t.payload;return t.kind===`sessionDialog`&&n?.dialog?.id?GV(e,t.sessionId??n.key??t.from,n.dialog.id):WV(e,t.id)}function vH(){let e=uH();tH(),iO();let t=DB(`tasks.list`,{},[`tasks`]),n=DB(`sessions.list`,{},[`sessions`]),r=F.get(`prompts`),i=F.get(`lobby`).data,a=(0,m.useRef)(gH()),o=(0,m.useRef)(new Set([`prompts`,`sessions`,`delivery`])),s=(0,m.useRef)(void 0),c=fe()??`current`,l=F.status().connection;return{enabled:e,tasks:t,sessions:n,prompts:r,lobby:i,seen:a,quiet:o,previousState:s,project:c,connection:l,lastConnection:(0,m.useRef)(l)}}function yH(e,t,n,r,i){if(!i)return;let{seen:a,project:o,quiet:s,enabled:c}=e,l=a.current.observe(`${o}:${t}`,n,s.current.has(t));s.current.delete(t),l.length&&(l.forEach(()=>nH()),c&&mH()&&hH(r),t===`delivery`&&W.info(r,{action:{label:`Review tasks`,onClick:()=>hB(`#/tasks`)}}))}function bH(e){let{prompts:t,sessions:n,tasks:r,project:i}=e,a=t.data?.prompts;yH(e,`prompts`,(a??[]).map(e=>_H(i,e)),`A question is waiting for you.`,!!a&&!t.loading),yH(e,`sessions`,n.data?.background.flatMap(e=>e.dialogs.map(t=>GV(i,e.sessionId??e.key,t.id)))??[],`A background session is asking something.`,!!n.data&&!n.loading),yH(e,`delivery`,r.data?.rows.filter(e=>e.delivery&&(e.delivery.status===`pending_approval`||e.delivery.status===`deferred`||e.delivery.status===`recoverable_failure`)).map(e=>KV(i,e.id,e.delivery.reviewId))??[],`Completed work is ready for delivery review in Tasks.`,!!r.data&&!r.loading)}function xH(e){let{lastConnection:t,connection:n,quiet:r,previousState:i,lobby:a,enabled:o}=e;if(t.current!==n||n!==`live`){t.current=n,r.current=new Set([`prompts`,`sessions`,`delivery`]),i.current=void 0;return}bH(e);let s=a?.task?.state??``,c=pH(s);i.current&&c&&s!==i.current&&o&&mH()&&hH(`${a?.task?.title??`The task`} ${c}.`),i.current=s}function SH(){let e=vH(),{connection:t,enabled:n,project:r,prompts:i,sessions:a,tasks:o,lobby:s}=e;(0,m.useEffect)(()=>xH(e),[t,n,r,i.data,i.loading,a.data,a.loading,o.data,o.loading,s])}function CH({className:e,type:t,...n}){return(0,U.jsx)(`input`,{type:t,"data-slot":`input`,className:Y(`flex h-8 w-full rounded-lg border border-input bg-background bg-clip-padding px-3 py-1 text-sm shadow-control transition-[border-color,box-shadow] duration-150 outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/24 focus-visible:shadow-none disabled:cursor-not-allowed disabled:opacity-64 aria-invalid:border-destructive/36 aria-invalid:focus-visible:border-destructive/64 aria-invalid:focus-visible:ring-destructive/16 dark:bg-input/32`,e),...n})}function wH({className:e,thumbClassName:t,...n}){return(0,U.jsx)(qE,{"aria-keyshortcuts":`Enter Space`,"aria-description":`When focused, press Enter or Space to toggle.`,"data-slot":`switch`,className:Y(`peer relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border border-transparent outline-none before:absolute before:-inset-x-2 before:-inset-y-3 before:content-[''] transition-[background-color,box-shadow] duration-200 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-64 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,e),...n,children:(0,U.jsx)(YE,{"data-slot":`switch-thumb`,className:Y(`pointer-events-none block size-4 rounded-full bg-background shadow-sm/5 ring-0 [transition:translate_.15s,scale_.1s_.1s] origin-left in-[[role=switch]:active]:scale-x-110 data-[state=checked]:origin-right data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0 dark:bg-white`,t)})})}function TH(e){return(0,U.jsx)(NE,{...e})}function EH(e){return(0,U.jsx)(PE,{"data-slot":`popover-trigger`,...e})}function DH({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,U.jsx)(FE,{children:(0,U.jsx)(IE,{"data-slot":`popover-content`,align:t,sideOffset:n,className:Y(`reui-menu z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-lg border p-1 outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-[0.98] data-closed:animate-out data-closed:fade-out-0 motion-reduce:animate-none`,e),...r})})}var OH=`reui-select inline-flex h-8 min-w-36 cursor-pointer items-center justify-between gap-2 rounded-lg border px-[calc(--spacing(3)-1px)] text-left text-sm text-foreground outline-none select-none transition-[color,box-shadow,background-color,border-color] duration-150 focus-visible:ring-[3px] focus-visible:ring-inset focus-visible:ring-ring/24 disabled:pointer-events-none disabled:opacity-64 [&_svg]:pointer-events-none [&_svg]:shrink-0`,kH=`-me-1 size-3 shrink-0 opacity-50`;function AH(e,t){let n=`${e.label} ${e.hint??``} ${e.value}`.toLowerCase();return t.toLowerCase().split(/\s+/).filter(Boolean).every(e=>n.includes(e))}function jH(e,t,n,r){for(let r=t;r>=0&&r<e.length;r+=n)if(!e[r].disabled)return r;return r}function MH(e){return jH(e,0,1,0)}function NH({value:e,options:t,onChange:n,label:r,className:i,disabled:a}){let[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(0),f=(0,m.useRef)(null),p=(0,m.useId)(),h=(0,m.useMemo)(()=>t.filter(e=>AH(e,c)),[t,c]),g=t.find(t=>t.value===e);(0,m.useEffect)(()=>{o&&(l(``),d(jH(t,Math.max(0,t.findIndex(t=>t.value===e)),1,MH(t))))},[o]);function _(e){l(e),d(MH(t.filter(t=>AH(t,e))))}(0,m.useEffect)(()=>{f.current?.querySelector(`[data-index="${u}"]`)?.scrollIntoView({block:`nearest`})},[u,o,h.length]);function v(t){t&&!t.disabled&&(s(!1),t.value!==e&&n(t.value))}function y(e){e.key===`ArrowDown`?(e.preventDefault(),d(e=>jH(h,Math.min(h.length-1,e+1),-1,e))):e.key===`ArrowUp`?(e.preventDefault(),d(e=>jH(h,Math.max(0,e-1),1,e))):e.key===`Home`&&!c?(e.preventDefault(),d(MH(h))):e.key===`End`&&!c?(e.preventDefault(),d(jH(h,h.length-1,-1,0))):e.key===`Tab`?s(!1):e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),v(h[u]))}return(0,U.jsxs)(TH,{open:o,onOpenChange:s,children:[(0,U.jsxs)(EH,{type:`button`,role:`combobox`,"aria-label":r,"aria-keyshortcuts":`Enter Space ArrowDown ArrowUp`,"aria-description":`When focused, press Enter, Space or an arrow key to choose. Type to search.`,"aria-expanded":o,"aria-haspopup":`listbox`,"aria-controls":o?p:void 0,disabled:a,onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),s(!0))},"data-slot":`select-trigger`,className:Y(OH,`w-full min-w-0 overflow-hidden whitespace-nowrap`,i),children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:g?.label??e}),(0,U.jsx)(tm,{"aria-hidden":`true`,strokeWidth:2.25,className:kH})]}),(0,U.jsxs)(DH,{align:`start`,sideOffset:4,collisionPadding:8,onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.querySelector(`input`)?.focus()},className:`p-0 flex max-h-[min(20rem,var(--radix-popover-content-available-height))] w-[max(var(--radix-popover-trigger-width),17rem)] max-w-(--radix-popover-content-available-width) flex-col overflow-hidden rounded-lg outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-[0.98] data-closed:animate-out data-closed:fade-out-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-2.5`,children:[(0,U.jsx)(Cg,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,U.jsx)(`input`,{value:c,onChange:e=>_(e.target.value),onKeyDown:y,role:`searchbox`,"aria-label":`Search ${r}`,"aria-controls":p,"aria-activedescendant":h[u]?`${p}-${u}`:void 0,placeholder:`Search…`,autoComplete:`off`,spellCheck:!1,className:`h-8 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground`})]}),(0,U.jsxs)(`div`,{ref:f,id:p,role:`listbox`,"aria-label":r,className:`min-h-0 flex-1 overflow-y-auto p-1`,children:[h.length===0?(0,U.jsxs)(`p`,{className:`px-2.5 py-2 text-xs text-muted-foreground`,children:[`Nothing matches “`,c,`”.`]}):null,h.map((t,n)=>(0,U.jsx)(`div`,{id:`${p}-${n}`,role:`option`,"aria-selected":t.value===e,"aria-disabled":t.disabled||void 0,"data-index":n,"data-disabled":t.disabled||void 0,onPointerMove:()=>{t.disabled||d(n)},onClick:()=>v(t),className:Y(`flex min-h-8 items-center gap-2 rounded-sm px-2 py-1 text-sm select-none sm:min-h-7`,t.disabled?`cursor-not-allowed opacity-60`:`cursor-pointer`,!t.disabled&&t.value===e&&`bg-foreground/[0.08]`,!t.disabled&&n===u&&`bg-accent text-accent-foreground`),children:(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate`,children:t.label}),t.hint?(0,U.jsx)(`span`,{className:`line-clamp-2 text-pretty text-xs text-muted-foreground/80`,children:t.hint}):null]})},t.value))]})]})]})}var PH=Uv([`relative flex flex-col overflow-hidden bg-card text-card-foreground rounded-(--frame-radius)`,`[--frame-radius:var(--radius-xl)]`,`[--frame-gap:0px] [--frame-px:0px] [--frame-py:0px] [--frame-panel-header-gap:0rem] [--frame-panel-footer-gap:--spacing(1)]`,`[--frame-panel-px-adjust:0px] [--frame-panel-py-adjust:0px] [--frame-panel-header-px-adjust:0px] [--frame-panel-header-py-adjust:0px] [--frame-panel-footer-px-adjust:0px] [--frame-panel-footer-py-adjust:0px]`,`[--frame-panel-px:calc(var(--frame-panel-px-base)+var(--frame-panel-px-adjust))] [--frame-panel-py:calc(var(--frame-panel-py-base)+var(--frame-panel-py-adjust))] [--frame-panel-header-px:calc(var(--frame-panel-header-px-base)+var(--frame-panel-header-px-adjust))] [--frame-panel-header-py:calc(var(--frame-panel-header-py-base)+var(--frame-panel-header-py-adjust))] [--frame-panel-footer-px:calc(var(--frame-panel-footer-px-base)+var(--frame-panel-footer-px-adjust))] [--frame-panel-footer-py:calc(var(--frame-panel-footer-py-base)+var(--frame-panel-footer-py-adjust))]`,``,`[--frame-panel-bg:var(--workspace-card)] [--frame-panel-border-color:var(--workspace-border)] [--frame-border-color:var(--workspace-border)]`,`[--frame-panel-radius:calc(var(--frame-radius)-var(--frame-px)-1px)]`],{variants:{variant:{default:`border border-[var(--frame-border-color)] bg-clip-padding`,inverse:`[--frame-panel-bg:color-mix(in_oklch,var(--color-muted)_40%,transparent)] border border-[var(--frame-border-color)] bg-background bg-clip-padding`,ghost:`[--frame-panel-radius:calc(var(--frame-radius)-var(--frame-px))]`},spacing:{xs:`[--frame-panel-px-base:--spacing(2)] [--frame-panel-py-base:--spacing(2)] [--frame-panel-header-px-base:--spacing(2)] [--frame-panel-header-py-base:--spacing(0.5)] [--frame-panel-footer-px-base:--spacing(2)] [--frame-panel-footer-py-base:--spacing(0.5)]`,sm:`[--frame-panel-px-base:--spacing(3)] [--frame-panel-py-base:--spacing(3.5)] [--frame-panel-header-px-base:--spacing(3)] [--frame-panel-header-py-base:--spacing(1.5)] [--frame-panel-footer-px-base:--spacing(3)] [--frame-panel-footer-py-base:--spacing(1.5)]`,default:`[--frame-panel-px-base:--spacing(4)] [--frame-panel-py-base:--spacing(4)] [--frame-panel-header-px-base:--spacing(4)] [--frame-panel-header-py-base:--spacing(2)] [--frame-panel-footer-px-base:--spacing(4)] [--frame-panel-footer-py-base:--spacing(2)]`,lg:`[--frame-panel-px-base:--spacing(5)] [--frame-panel-py-base:--spacing(5)] [--frame-panel-header-px-base:--spacing(5)] [--frame-panel-header-py-base:--spacing(2.5)] [--frame-panel-footer-px-base:--spacing(5)] [--frame-panel-footer-py-base:--spacing(2.5)]`},stacked:{true:``,false:``},dense:{true:`p-0 gap-0 border-[var(--frame-border-color)] [--frame-panel-radius:var(--frame-radius)] [&_[data-slot=frame-panel]]:-mx-px [&_[data-slot=frame-panel]]:before:hidden [&_[data-slot=frame-panel]:last-child]:-mb-px [&:not(:has([data-slot=frame-panel-header]))_[data-slot=frame-panel]:is(:first-child)]:-mt-px`,false:``}},defaultVariants:{variant:`default`,spacing:`default`,stacked:!1,dense:!1}});function FH({className:e,variant:t,spacing:n,stacked:r,dense:i,...a}){return(0,U.jsx)(`div`,{className:Y(PH({variant:t,spacing:n,stacked:r,dense:i}),e),"data-slot":`frame`,"data-spacing":n,...a})}function IH({className:e,fit:t,...n}){return(0,U.jsx)(`div`,{className:Y(`relative min-w-0 [[data-slot=frame-panel-header]+&]:border-t [[data-slot=frame-panel]+&]:border-t border-(--frame-panel-border-color)`,!t&&`grow`,`px-(--frame-panel-px) py-(--frame-panel-py)`,e),"data-slot":`frame-panel`,...n})}function LH({className:e,...t}){return(0,U.jsx)(`header`,{className:Y(`flex flex-col gap-(--frame-panel-header-gap) px-(--frame-panel-header-px) py-(--frame-panel-header-py)`,e),"data-slot":`frame-panel-header`,...t})}function RH({label:e,help:t,children:n,stacked:r}){return(0,U.jsxs)(`div`,{className:r?`grid gap-1`:`grid grid-cols-[minmax(0,1fr)_minmax(0,18rem)] items-center gap-4`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 break-words`,children:[(0,U.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:e}),t?(0,U.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:t}):null]}),(0,U.jsx)(`div`,{className:`min-w-0`,children:n})]})}function zH({children:e}){return(0,U.jsx)(FH,{dense:!0,children:(0,U.jsx)(IH,{className:`flex flex-col divide-y divide-border py-0 [&>*]:py-2`,children:e})})}function BH({value:e,items:t,label:n,disabled:r,onChange:i}){let a=t.map(e=>({value:e.value,label:e.label,...e.help?{hint:e.help}:{},...e.disabled?{disabled:e.disabled}:{}}));return(0,U.jsx)(NH,{value:e,options:a,label:n,disabled:r,onChange:i})}function VH(e,t,n){let r=-1;for(let i=0;i<e.length;i+=1)t.includes(e[i])&&(r<0||Math.abs(i-n)<Math.abs(r-n))&&(r=i);return r}var HH={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},UH={off:`No extra reasoning: the quickest, cheapest answer.`,minimal:`A moment of reasoning, barely.`,low:`Light reasoning for simple work.`,medium:`Balanced reasoning for most work.`,high:`Careful reasoning: slower, better on hard problems.`,xhigh:`Very deep reasoning: slow and costly.`,max:`As deep as the model goes.`};function WH(e,t,n){let r=VH(e,t,Math.max(0,e.indexOf(n)));return e[Math.max(r,0)]??n}function GH({value:e,levels:t,supported:n,recommended:r,model:i,label:a,disabled:o,onChange:s}){let c=i??`this model`,l=WH(t,n,e),u=t.map(e=>{let t=n.includes(e),i=t?UH[e]:`Not supported by ${c}.`;return{value:e,label:HH[e]??e,help:t&&e===r?`${i} Recommended.`:i,disabled:!t}});return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(BH,{value:l,items:u,label:a,disabled:o,onChange:e=>void s(e)}),e===l?null:(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e,` is not supported by `,c,`, so it runs at `,l,`.`]})]})}var KH={type:`spring`,stiffness:520,damping:34,mass:.8};function qH({items:e,value:t,onChange:n,label:r,as:i=`radio`,size:a=`sm`,className:o,idPrefix:s}){let c=(0,m.useId)(),l=Ef()??!1,u=s??c;function d(r){let i=Math.max(0,e.findIndex(e=>e.id===t)),a=r.key===`ArrowRight`||r.key===`ArrowDown`?1:r.key===`ArrowLeft`||r.key===`ArrowUp`?-1:0,o=a?(i+a+e.length)%e.length:r.key===`Home`?0:r.key===`End`?e.length-1:-1;if(o<0)return;r.preventDefault(),r.stopPropagation();let s=e[o];n(s.id);let c=0,l=()=>{let e=document.getElementById(`${u}-${s.id}`);e&&e.tabIndex===0?e.focus():c++<20&&requestAnimationFrame(l)};requestAnimationFrame(l)}return(0,U.jsx)(`div`,{role:i===`tab`?`tablist`:i===`radio`?`radiogroup`:void 0,"aria-label":i===`nav`?void 0:r,onKeyDown:d,"data-slot":`segmented`,className:Y(`segmented relative inline-flex max-w-full min-w-0 items-center gap-0.5 overflow-x-auto rounded-[10px] p-0.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,o),children:e.map(e=>{let r=e.id===t;return(0,U.jsxs)(`button`,{id:`${u}-${e.id}`,type:`button`,"data-segment":e.id,role:i===`nav`?void 0:i,...i===`tab`?{"aria-selected":r,"aria-controls":e.controls}:i===`radio`?{"aria-checked":r}:{"aria-current":r?`page`:void 0,"aria-controls":e.controls},"aria-label":e.name,tabIndex:r||i===`nav`?0:-1,onClick:()=>n(e.id),className:Y(`relative isolate inline-flex shrink-0 items-center justify-center gap-1.5 rounded-lg px-3 font-medium whitespace-nowrap outline-none transition-colors duration-200 ease-snap focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,a===`sm`?`h-7 text-[0.8125rem]`:`h-8 text-sm`,r?`text-foreground`:`text-muted-foreground hover:text-foreground`),children:[r?(0,U.jsx)(Xf.span,{"aria-hidden":`true`,layoutId:`segment-thumb-${c}`,className:`segmented-thumb absolute inset-0 -z-10 rounded-lg`,transition:l?{duration:0}:KH}):null,e.label]},e.id)})})}var JH=`(prefers-color-scheme: dark)`,YH=[`dark`,`light`,`system`],XH=m.createContext(void 0);function ZH(e){return e!==null&&YH.includes(e)}function QH(){return window.matchMedia(JH).matches?`dark`:`light`}function $H(){let e=document.createElement(`style`);return e.appendChild(document.createTextNode(`*,*::before,*::after{-webkit-transition:none!important;transition:none!important}`)),document.head.appendChild(e),()=>{window.getComputedStyle(document.body),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.remove()})})}}function eU(e){let t=e;for(;t instanceof HTMLElement&&t.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement&&!!(t.isContentEditable||t.closest(`input, textarea, select, [contenteditable='true']`))}function tU({children:e,defaultTheme:t=`system`,storageKey:n=`theme`,disableTransitionOnChange:r=!0,...i}){let[a,o]=m.useState(()=>{let e=localStorage.getItem(n);return ZH(e)?e:t}),s=m.useCallback(e=>{localStorage.setItem(n,e),o(e)},[n]),c=m.useCallback(e=>{let t=document.documentElement,n=e===`system`?QH():e,i=r?$H():null;t.classList.remove(`light`,`dark`),t.classList.add(n),i&&i()},[r]);m.useEffect(()=>{if(c(a),a!==`system`)return;let e=window.matchMedia(JH),t=()=>{c(`system`)};return e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t)}},[a,c]),m.useEffect(()=>{let e=e=>{e.repeat||e.metaKey||e.ctrlKey||e.altKey||eU(e.target)||e.key.toLowerCase()===`d`&&o(e=>{let t=e===`dark`?`light`:e===`light`?`dark`:QH()===`dark`?`light`:`dark`;return localStorage.setItem(n,t),t})};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[n]),m.useEffect(()=>{let e=e=>{if(e.storageArea===localStorage&&e.key===n){if(ZH(e.newValue)){o(e.newValue);return}o(t)}};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}},[t,n]);let l=m.useMemo(()=>({theme:a,setTheme:s}),[a,s]);return(0,U.jsx)(XH.Provider,{...i,value:l,children:e})}var nU=()=>{let e=m.useContext(XH);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e};function rU({kind:e,dense:t=!1}){let n=e===`font`?Be:Ve,r=Xe(e),i=(0,m.useRef)(null);function a(t){let a=t.key===`ArrowRight`||t.key===`ArrowDown`?1:t.key===`ArrowLeft`||t.key===`ArrowUp`?-1:0;if(!a)return;t.preventDefault(),t.stopPropagation();let o=Math.max(0,n.findIndex(e=>e.id===r)),s=n[(o+a+n.length)%n.length];Je(e,s.id),requestAnimationFrame(()=>i.current?.querySelector(`[data-face="${s.id}"]`)?.focus())}return(0,U.jsx)(`div`,{ref:i,role:`radiogroup`,"aria-label":e===`font`?`Typeface`:`Code typeface`,onKeyDown:a,className:t?`grid grid-cols-2 gap-0.5`:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4`,children:n.map(n=>{let i=n.id===r,a=Ze[n.id];return(0,U.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":i,"data-face":n.id,tabIndex:i?0:-1,onClick:()=>Je(e,n.id),className:Y(`outline-none transition-[background-color,border-color,box-shadow] duration-150 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t?`flex min-h-8 items-center gap-2 rounded-lg px-2 text-left text-sm hover:bg-accent`:Y(`grid gap-1 rounded-xl border p-2.5 text-left`,i?`border-primary bg-accent shadow-[0_0_0_1px_var(--primary)]`:`border-[var(--glass-edge)] hover:bg-accent/50`)),children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:Y(`leading-none`,t?`w-7 text-base`:`text-2xl`),style:a?{fontFamily:a}:e===`mono`?{fontFamily:`var(--app-font-mono, ui-monospace, monospace)`}:void 0,children:e===`font`?`Aa`:`{ }`}),(0,U.jsxs)(`span`,{className:Y(`flex min-w-0 items-center justify-between gap-2`,t&&`flex-1`),children:[(0,U.jsxs)(`span`,{className:`min-w-0`,children:[(0,U.jsx)(`span`,{className:`block truncate text-[0.8125rem] font-medium`,children:n.label}),t?null:(0,U.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:n.help})]}),i?(0,U.jsx)($p,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]})]},n.id)})})}var iU=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`planner`],aU={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scout`,researcher:`Researcher`,planner:`Planner`},oU=`inherit`,sU=`inherit`,cU=`Use the session's current model`,lU=`__custom__`,uU=`custom…`,dU=`Type a provider/model id`,fU={master:`high`,designer:`medium`,backend:`medium`,qa:`medium`,scout:`low`,researcher:`low`,planner:`high`},pU=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],mU={agents:`Agents`,grants:`Tools & skills`,workflow:`Workflow`,lint:`Linting`,lobby:`Lobby`,classifier:`Classifier`,harnesses:`Harnesses`,appearance:`Appearance`,notifications:`Notifications`,install:`Install as app`},hU=new Set([`scout`,`researcher`,`planner`]),gU={label:`Compact at`,help:`Empty: built-in 64K.`,placeholder:`64000`,min:4e3,max:2e6,bad:e=>`"${e}" is not a whole number of tokens from 4000 to 2000000.`},Q={intro:`Every agent picks up the MCP tools of the servers pi has connected and the skills pi finds, including ones you add later. Narrow an agent here when it should use fewer. Children an agent delegates to get the same grants. Every change saves at once.`,agents:`Agents`,cardLabel:`tools and skills`,tools:`MCP tools`,toolsHelp:`Granted tools are the only MCP tools this agent can call, directly or from codemode.`,everyTool:`Every MCP tool pi connects`,everyToolHelp:`New servers and tools are picked up on the next run. Off: only the tools ticked below.`,everyToolReadOnlyHelp:`Every read-only tool, picked up on the next run as servers connect. Off: only the tools ticked below.`,allTools:`all MCP tools`,noToolsWarning:`This agent gets no MCP tools at all.`,readOnlyHelp:`This agent only reads, so it can call only tools their server marks read-only.`,qaHelp:`QA's tests may use any granted tool; the QA gate, which only reads, calls only the read-only ones.`,blockedHelp:`This agent only reads; the server does not mark this tool read-only.`,filter:`Filter tools`,looking:`Asking pi…`,noServers:`pi has no MCP servers connected. Add one, then reopen Settings:`,unknownServer:`other`,readOnly:`read-only`,writes:`writes`,notConnected:`not connected`,notConnectedHelp:`Granted, but its server is not connected now. It works again once the server is back.`,addLabel:`Grant a tool by its exact name`,add:`Grant`,badName:`A tool name reads mcp__server__tool, such as mcp__github__get_issue.`,noTools:`no MCP tools`,skills:`Skills`,skillsHelp:`An agent sees each granted skill's name and description, and reads its instructions when the work calls for them.`,sessionSkills:`this session's`,masterSkills:`The oracle is this pi session, so it uses the skills pi loads for it (pi's own skill settings).`,everySkill:`Every skill pi finds`,everySkillHelp:`Off: only the skills ticked below.`,allSkills:`all skills`,noSkills:`no skills`,noSkillsFound:`pi finds no skills. Put one in ~/.pi/agent/skills/ or the project's .pi/skills/ or .agents/skills/.`,notFound:`not found`,skillMissingHelp:`Granted, but pi no longer finds this skill.`,noneWarning:`This agent gets no skills at all.`,edit:`Tools & skills`},_U=[{id:`startOn`,label:`On when pi starts`,help:`off: pi starts as plain pi, and ctrl+shift+m or /bot-lobby on turns bot-lobby on (a session that owns a task under way always starts on)`}],vU={label:`Retain lobby data in git`,help:`Track this lobby's data (.pi/bot-lobby: tasks, knowledge, scripts, reports) in git. Off keeps it local and gitignored.`,error:`Couldn't read this repository's .gitignore.`},yU=[{id:`conversation`,label:`Conversation pane`},{id:`activity`,label:`Activity steps in the conversation`},{id:`thinking`,label:`Thinking bubble`}],bU=`shown on the Lobby tab`,xU=`Planning rounds`,SU=`how many rounds the panel gets before the oracle settles the rest alone`,CU=[2,3,5,8,0],wU=`Port`,TU=`the base port (then the next free up to +20); 0 means any free port; applies the next time pi starts`,EU=`Open browser`,DU=`open this page in the browser when pi starts`,OU=[{id:`off`,label:`off`,help:`tasks work in the folder you started them in`},{id:`branch`,label:`branch`,help:`each new task gets a git branch named after it, checked out in the working folder`},{id:`worktree`,label:`worktree`,help:`each new task gets its own worktree and branch, named after it: every agent runs there, apart from your checkout`}],kU=`Git isolation`,AU=[{id:`off`,label:`off`,help:`agents' work is never linted`},{id:`advise`,label:`advise`,help:`the oracle and QA are told what the project's linter finds on the lines a task changed; nothing is held`},{id:`block`,label:`block`,help:`new lint errors also hold a task's completion until they are fixed, or you accept the work as it is`}],jU={intro:`After every worker step, before QA and at completion, bot-lobby lints only the files the task's agents touched. Problems on the lines the task changed are the task's; anything already there is shown but never holds it. Suppressions and lint-config changes the task adds go to QA to judge.`,mode:`Lint gate`,command:`Command`,commandHelp:`empty runs the linters the project configures (ESLint, Biome, Oxlint, Ruff), each from its own folder; a command runs without a shell from the repository's top, with {files} standing for the touched files`,commandPlaceholder:`found from the project`,extensions:`File types`,extensionsHelp:`which touched files the command is given, such as .ts .tsx .py`,extensionsPlaceholder:`every touched file`,timeout:`Time limit`,timeoutHelp:`for one linter run; one that runs over reads as could not run, and holds nothing`,found:`Found in this project`,foundHelp:`config files in the project and the folders a few levels below it`,foundNone:`No linter config found. Add one to the project, or set a command above.`,foundReplaced:`The command replaces these.`,installed:`installed`,missing:`not installed`,missingHelp:`install the project's dependencies there, or lint cannot run`,top:`project root`},MU=[{id:`auto`,label:`Auto (OpenCode's free Jev, else TypeSafe)`},{id:`opencode`,label:`OpenCode Zen`},{id:`typesafe`,label:`TypeSafe`},{id:`openrouter`,label:`OpenRouter`},{id:`vercel`,label:`Vercel AI Gateway`}],NU=[{id:`seats`,label:`Planning seats`,help:`each round, only the seats your idea or latest answers touch sit; 1-4 in the Plan tab pins one`},{id:`answers`,label:`Obvious answers`,help:`a panel question whose recommended option the conversation already makes clearly right is answered for you (listed under Assumptions)`},{id:`lobby`,label:`Lobby replies`,help:`each lobby message goes to the agent whose area it is: a frontend question to Design, a library question to Research, "how does this work" to a scout; when it is unsure, or off, the Master answers. Naming an agent with @ always decides`},{id:`triage`,label:`Task triage`,help:`a new task's size, domains and research need reach the Master as hints`},{id:`effort`,label:`Effort routing`,help:`a simple step runs one thinking level lower, a trivial one on the cheaper model below; a routed run that falls short runs again on your settings`},{id:`qa`,label:`QA risk`,help:`once a task's work is in, the classifier reads the diff and sizes QA to it: no QA agent for a change with nothing that runs, a light check for a small one, deep review where a defect would spread; with it off the engine's rules decide`},{id:`review`,label:`Pull request read`,help:`the Git tab's quick read of a pull request: its size, and how likely it is risky, security-relevant, breaking or untested, before an agent reviews it`},{id:`knowledge`,label:`Relevant knowledge`,help:`when an agent's knowledge, standards or decisions file is too long for its prompt, the classifier picks the sections that bear on the step, and the agent is told where the rest is`},{id:`scripts`,label:`Shared scripts`,help:`the classifier matches each step to the shared scripts that do part of it, and the agent is told to run them instead of redoing the work`},{id:`files`,label:`File hints`,help:`scouts, workers, chat agents and the planning panel start with the files most likely needed, and can look more up with find_relevant_files`}],PU={enabled:`Classifier`,enabledHelp:`a fast model makes the obvious decisions so large models spend fewer tokens on them`,engine:`Answered by`,engineHelp:`pick a provider, then its model: Jev, another classifier model, or any chat model your pi logins offer (OpenAI, Anthropic, Google, …); a small, fast one works best`,provider:`Classifier provider`,engineModel:`Classifier model`,engineJev:`Jev (built in)`,engineJevHelp:`TypeSafe's classifier, on the host below`,engineClassifier:`classifier model`,engineChat:`chat model, answers as JSON`,host:`Host`,model:`Model`,modelHelp:`empty uses the host's default`,key:`API key`,keyNote:`the key pi already holds for this host; it is never read by this page`,cheap:`Cheaper model`,cheapNone:`none: trivial steps keep their model and drop a thinking level`,cheapHelp:`what effort routing runs trivial steps on`},FU={title:`Settings`,intro:`Each agent's model and effort, the workflow and its lint gate, the lobby and the classifier. Changes save as you make them.`,loading:`Loading settings…`,loadFailed:`Could not load settings.`,saved:`Settings saved`,saving:`Saving…`,appearanceHelp:`Light, dark, or follow your system. Kept in this browser only.`,themeLabel:`Mode`,themeItems:[{id:`light`,label:`Light`},{id:`dark`,label:`Dark`},{id:`system`,label:`System`}],notificationsLabel:`Browser notifications`,notificationsHelp:`While this page is hidden, tell me when a question waits, a task finishes or a background session asks something.`,notificationsBlocked:`Notifications are blocked in your browser. Allow them for this site and try again.`,notificationsUnsupported:`This browser does not offer notifications.`,notificationsOn:`Browser notifications are on.`,notificationsOff:`Browser notifications are off.`,installLabel:`Install bot-lobby`,installHelp:`Opens in its own fullscreen window, with the shell cached so it starts when Pi is not running.`,installButton:`Install as fullscreen app`,installUnavailable:`Your browser has not offered to install it. Use its menu: “Install app” (Chrome, Edge) or Share, then “Add to Home Screen” (Safari).`,installDone:`bot-lobby is installed.`,installedNow:`Running as an installed app.`,fullscreenLabel:`Fullscreen`,fullscreenHelp:`Hide the browser's own bars for this tab (F11 does the same).`,fullscreenOn:`Exit fullscreen`,fullscreenOff:`Go fullscreen`},IU=new Set([`designer`,`backend`,`qa`,`scout`,`researcher`]),$={label:`Harness`,piLabel:`pi`,piHelp:`Bot Lobby's own agent, with your pi logins`,missing:`not found`,model:`Model`,defaultModel:`Harness default`,defaultModelHelp:`Whatever the harness is set to use`,older:`older`,effortNote:`Applied when the agent offers effort levels in its session.`,agentNote:`Runs in this harness with Bot Lobby's prompts. It cannot ask you questions or use Bot Lobby's own tools (desk, board).`,intro:`Run any agent but the oracle and the planner on another coding agent. The oracle stays on pi and hands each step over: the harness gets the agent's role prompt, and its own login and models. Pick the harness per agent under Agents.`,installed:`Installed`,notFound:`Not found`,usedBy:`Used by`,unused:`No agent uses it yet`,binary:`Command`,binaryHelp:`The executable to start; empty uses the usual command on PATH.`,args:`Launch arguments`,argsHelp:`Added to every run, quoted as in a shell.`,argsAcpHelp:`The arguments that start the agent in ACP mode.`,home:`Home folder`,homeHelp:e=>`Sets ${e} for its config and login; empty keeps its own.`,provider:`Model provider`,providerHelp:`Who serves the models.`,compact:`Compact after`,compactHelp:`Tokens before it compacts an agent's context (10,000 to 2,000,000); empty keeps the harness's own. An agent with Auto-compact off never compacts.`,inject:`Inject Bot Lobby's prompts`,injectHelp:`Give it the agent's role prompt, knowledge and standards. Off sends the task and the report format only.`,custom:`Extra models`,customHelp:`Model ids it should also offer, separated by spaces.`,harnessPath:`Harness path`,harnessPathHelp:`Antigravity's localharness_external, when its ACP server does not find it itself.`},LU=`https://tweakcn.com/editor/theme`;function RU(){let{theme:e}=nU();return e===`dark`||e===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}function zU({palette:e,dark:t}){let n=ae(e,t);return(0,U.jsxs)(`span`,{"aria-hidden":`true`,className:`flex h-9 items-center gap-1.5 rounded-lg border border-border px-2`,style:{background:n.background},children:[(0,U.jsx)(`span`,{className:`size-4 rounded-full border border-black/10`,style:{background:n.card}}),(0,U.jsx)(`span`,{className:`size-4 rounded-full`,style:{background:n.primary}}),(0,U.jsx)(`span`,{className:`h-2 flex-1 rounded-full`,style:{background:n.accent}})]})}function BU(){let e=ze(),t=RU(),n=(0,m.useRef)(null);function r(t){let r=t.key===`ArrowRight`||t.key===`ArrowDown`?1:t.key===`ArrowLeft`||t.key===`ArrowUp`?-1:0;if(!r)return;t.preventDefault(),t.stopPropagation();let i=Math.max(0,e.all.findIndex(t=>t.id===e.active.id)),a=e.all[(i+r+e.all.length)%e.all.length];e.choose(a.id),window.requestAnimationFrame(()=>n.current?.querySelector(`[data-theme-id="${a.id}"]`)?.focus())}return(0,U.jsx)(`div`,{ref:n,role:`radiogroup`,"aria-label":`Colour theme`,onKeyDown:r,className:`grid grid-cols-3 gap-2 lg:grid-cols-4`,children:e.all.map(n=>{let r=n.id===e.active.id;return(0,U.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space ArrowLeft ArrowRight`,"aria-describedby":`focused-action-help`,type:`button`,role:`radio`,"aria-checked":r,"data-theme-id":n.id,tabIndex:r?0:-1,onClick:()=>e.choose(n.id),className:Y(`grid gap-1.5 rounded-lg border p-2 text-left outline-none transition-[border-color,box-shadow,background-color] duration-150 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,r?`border-primary bg-accent shadow-[0_0_0_1px_var(--primary)]`:`border-border hover:bg-accent/50`),children:[(0,U.jsx)(zU,{palette:n,dark:t}),(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center justify-between gap-2 px-0.5 text-[0.8125rem] font-medium`,children:[(0,U.jsxs)(`span`,{className:`truncate`,children:[n.name,e.isSaved(n.id)?(0,U.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:`saved`}):null]}),r?(0,U.jsx)($p,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]})]},n.id)})})}function VU({entry:e}){let t=ze(),[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(e.name),[o,s]=(0,m.useState)();async function c(){let n=i.trim();if(!n||n===e.name)return r(!1);try{await t.rename(e.id,n),r(!1),s(void 0),W.success(`Renamed to ${n}.`)}catch(e){s(e.message)}}return(0,U.jsxs)(`li`,{className:`flex min-h-10 flex-wrap items-center gap-2 py-1.5`,children:[n?(0,U.jsxs)(`form`,{className:`flex min-w-0 flex-1 items-center gap-1`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,U.jsx)(CH,{autoFocus:!0,value:i,maxLength:40,"aria-label":`New name for ${e.name}`,"aria-invalid":o?!0:void 0,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(t.preventDefault(),t.stopPropagation(),a(e.name),r(!1))},className:`h-8 max-w-64`}),(0,U.jsx)(SR,{label:`Save the name`,text:`Save`,icon:$p,tone:`primary`,type:`submit`,disabled:!i.trim()}),(0,U.jsx)(SR,{label:`Keep the old name`,icon:s_,iconOnly:!0,onClick:()=>{a(e.name),r(!1)}})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),(0,U.jsx)(SR,{label:`Rename ${e.name}`,text:`Rename`,icon:tg,onClick:()=>{a(e.name),r(!0)}}),(0,U.jsx)(tV,{label:`Remove ${e.name}`,text:`Remove`,title:`Remove ${e.name}?`,description:`It is removed for every pi session. Keep a copy of its CSS if you want to use it again.`,confirmLabel:`Remove theme`,icon:Gg,variant:`destructive`,onConfirm:()=>void t.remove(e.id).catch(e=>W.error(e.message))})]}),o?(0,U.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,children:o}):null]})}function HU(){let e=ze();return e.saved.length===0?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No saved themes yet. Import one below and give it a name.`}):(0,U.jsx)(`ul`,{"aria-label":`Saved themes`,className:`divide-y divide-border`,children:e.saved.map(e=>(0,U.jsx)(VU,{entry:e},e.id))})}function UU(){let e=ze(),[t,n]=(0,m.useState)(``),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(),[s,c]=(0,m.useState)(!1),l=(0,m.useRef)(null);async function u(t,a){let s=ee(t);if(`error`in s){o(s.error);return}o(void 0),c(!0);try{let t=await e.adopt(s,r.trim()||s.name||a);n(``),i(``);let o=s.light?s.dark?void 0:`dark`:`light`;W.success(o?`${t.name} saved and applied. It has no ${o} colours, so ${o} mode keeps the default ones.`:`${t.name} saved and applied.`)}catch(e){o(e.message)}finally{c(!1)}}async function d(e){if(e){if(e.size>2e5){o(`That file is too large to be a theme.`);return}await u(await e.text(),e.name.replace(/\.[^.]+$/,``)||`Custom theme`)}}return(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Pick or build a theme in the`,` `,(0,U.jsxs)(`a`,{href:LU,target:`_blank`,rel:`noreferrer noopener`,className:`inline-flex items-center gap-0.5 text-link underline-offset-2 hover:underline`,children:[`tweakcn editor `,(0,U.jsx)(Lm,{"aria-hidden":`true`,className:`size-3`})]}),`, press Code, copy it, and paste it here, or save it as a file and upload that. Colours and fonts are used; corners stay the page's own.`]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs text-muted-foreground`,children:[`Name`,(0,U.jsx)(CH,{value:r,maxLength:40,placeholder:`the theme's own name, or the file's`,onChange:e=>i(e.target.value),className:`h-8 max-w-80 text-foreground`})]}),(0,U.jsx)(nV,{value:t,onChange:e=>{n(e.target.value),o(void 0)},rows:4,spellCheck:!1,"aria-label":`Theme CSS from tweakcn`,"aria-invalid":a?!0:void 0,placeholder:`:root {
|
|
92
|
+
`).filter(Boolean),r=[];for(let t of n){let n=BR.exec(t);if(!n)return{body:e,files:[]};let i=n[1].split(/[\\/]/).pop()??``;if(!/^[\w.-]+$/.test(i))return{body:e,files:[]};r.push({id:i,name:i.replace(/^[a-z0-9]+-/,``),mime:n[2]})}return r.length>0?{body:e.slice(0,t).trimEnd(),files:r}:{body:e,files:[]}}var HR=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function UR({files:e}){return e.length===0?null:(0,U.jsx)(`ul`,{className:`mt-2 flex min-w-0 max-w-full flex-wrap gap-2`,"aria-label":`Attached files`,children:e.map(e=>(0,U.jsx)(`li`,{children:HR.has(e.mime)?(0,U.jsx)(`a`,{href:I(`/files/preview/attachments/${e.id}`),target:`_blank`,rel:`noopener noreferrer`,className:`block max-w-full overflow-hidden rounded-lg border border-border bg-muted/40 transition-transform duration-150 ease-snap hover:scale-[1.02] focus-visible:outline-2 focus-visible:outline-ring`,children:(0,U.jsx)(`img`,{src:I(`/files/preview/attachments/${e.id}`),alt:e.name,loading:`lazy`,className:`max-h-40 max-w-[min(14rem,100%)] object-cover`})}):(0,U.jsxs)(`span`,{className:`inline-flex max-w-[min(16rem,100%)] min-w-0 items-center gap-2 rounded-lg border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground`,children:[e.mime===`application/pdf`?(0,U.jsx)(Ym,{"aria-hidden":`true`,className:`size-4 shrink-0`}):(0,U.jsx)(Yh,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate`,children:e.name})]})},e.id))})}var WR=!1,GR=[],KR=0,qR=900;function JR(){WR=!0,window.clearTimeout(KR),KR=window.setTimeout(YR,qR)}function YR(){WR=!1,window.clearTimeout(KR);let e=GR;GR=[];for(let t of e)t()}function XR(e){if(!WR)return e(),()=>{};let t=()=>e();return GR.push(t),()=>{GR=GR.filter(e=>e!==t)}}var ZR=8;function QR(e,t=24){let[n,r]=(0,m.useState)(t),i=(0,m.useRef)(8),a=n<e;return(0,m.useEffect)(()=>{if(!a)return;let e=0,t=XR(()=>{e=requestAnimationFrame(()=>{let e=performance.now();(0,dy.flushSync)(()=>r(e=>e+i.current));let t=Math.max(1,performance.now()-e);i.current=Math.max(2,Math.min(400,Math.round(i.current*ZR/t)))})});return()=>{t(),cancelAnimationFrame(e)}},[a,n]),Math.min(n,e)}var $R=`bot-lobby.code.wrap`,ez=`bot-lobby.code.layout`,tz=new Set,nz={open:!1,request:0};function rz(){for(let e of[...tz])e()}function iz(e){return tz.add(e),()=>{tz.delete(e)}}function az(e,t){nz={open:!0,...e?{path:e}:nz.path?{path:nz.path}:{},...t?{mode:t}:{},request:nz.request+1},rz()}function oz(){nz.open&&(nz={...nz,open:!1},rz())}function sz(){nz.open?oz():az()}function cz(){return(0,m.useSyncExternalStore)(iz,()=>nz)}function lz(e){try{return localStorage.getItem(e)}catch{return null}}function uz(e,t){try{localStorage.setItem(e,t)}catch{}}var dz=lz($R)===`1`,fz=lz(ez)===`split`?`split`:`unified`;function pz(e){dz=e,uz($R,e?`1`:`0`),rz()}function mz(e){fz=e,uz(ez,e),rz()}function hz(){return(0,m.useSyncExternalStore)(iz,()=>dz)}function gz(){return(0,m.useSyncExternalStore)(iz,()=>fz)}var _z=new Set(`ts tsx mts cts js jsx mjs cjs json jsonc json5 jsonl md mdx css scss sass less html htm vue svelte astro py rb go rs java kt kts swift c h cc cpp hpp cs php lua sh bash zsh fish ps1 sql graphql gql yml yaml toml ini cfg conf env xml svg txt lock prisma proto dockerfile mk gradle`.split(` `));function vz(e){let t=e.trim();if(!t||t.length>300||/\s/.test(t)||/^[a-z][\w+.-]*:\/\//i.test(t))return;let n=t.replace(/:\d+(?::\d+)?$/,``).replace(/^\.\//,``);if(!/^[\w@~./-]+$/.test(n)||n.endsWith(`/`)||n.includes(`..`))return;let r=n.split(`/`).at(-1)??``,i=/^[\w@.-]*[A-Za-z_][\w@-]*\.[A-Za-z][\w]{0,9}$/.test(r)||/^\.[A-Za-z][\w.-]*$/.test(r),a=/^(Dockerfile|Makefile|LICENSE|Procfile|Gemfile|Rakefile)$/.test(r)&&n.includes(`/`);if((i||a)&&!/^v?\d+(\.\d+)+$/.test(r)&&(n.includes(`/`)||r.startsWith(`.`)||_z.has(r.slice(r.lastIndexOf(`.`)+1).toLowerCase())))return n}function yz({path:e,children:t,className:n}){return(0,U.jsx)(`button`,{type:`button`,"data-file-link":e,title:`Open ${e} in the code viewer`,onClick:t=>{t.stopPropagation(),az(e)},className:Y(`file-link`,n),children:t})}function bz(e){return e.split(/(\s+)/).map((e,t)=>{let n=e.replace(/^[("'`[]+|[)"'`\],.;:!?]+$/g,``),r=n?vz(n):void 0;if(!r)return e;let i=e.indexOf(n);return(0,U.jsxs)(`span`,{children:[e.slice(0,i),(0,U.jsx)(yz,{path:r,children:n}),e.slice(i+n.length)]},t)})}function xz(e){return e?.type===`text`?e.value??``:(e?.children??[]).map(xz).join(``)}function Sz(e,t=!1){let n=t||e.tagName===`a`;e.tagName===`code`&&(e.properties={...e.properties,copyBlocked:n,blockCode:t===!1&&e.properties?.blockCode});for(let t of e.children??[])e.tagName===`pre`&&(t.properties={...t.properties,blockCode:!0}),Sz(t,n)}function Cz(){return e=>Sz(e)}var wz=/(?<![\w/@.:-])((?:\.{1,2}\/)?(?:[\w@.-]+\/)+[\w@.-]*[A-Za-z_][\w@-]*\.[A-Za-z]\w{0,9})(:\d+)?(?![\w/])/g;function Tz(e){if(e.tagName===`code`||e.tagName===`pre`||e.tagName===`a`)return;let t=e.children;if(!t)return;let n=[];for(let e of t){if(e.type!==`text`||!e.value||!e.value.includes(`/`)){Tz(e),n.push(e);continue}let t=0;for(let r of e.value.matchAll(wz)){let i=vz(r[1]);i&&(r.index>t&&n.push({type:`text`,value:e.value.slice(t,r.index)}),n.push({type:`element`,tagName:`span`,properties:{dataFilePath:i},children:[{type:`text`,value:r[0]}]}),t=r.index+r[0].length)}t===0?n.push(e):t<e.value.length&&n.push({type:`text`,value:e.value.slice(t)})}e.children=n}function Ez(){return e=>Tz(e)}function Dz(e){let[t,n]=(0,m.useState)(!1);async function r(){try{await NR(e,navigator.clipboard),n(!0),W.success(`Code copied.`)}catch{W.error(`Could not copy code. Select it and copy manually, or allow clipboard access.`)}}return{copied:t,copy:r}}function Oz({text:e,children:t,block:n=!1}){let{copy:r}=Dz(e),i=(0,m.useRef)(void 0);return(0,U.jsxs)(`code`,{role:`button`,tabIndex:0,"aria-label":`Copy code`,"aria-keyshortcuts":`Enter Space`,title:`Copy code · Enter / Space`,className:`cursor-copy focus-visible:outline-2 focus-visible:outline-ring`,onPointerDown:e=>{i.current={x:e.clientX,y:e.clientY,moved:!1}},onPointerMove:e=>{let t=i.current;t&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>4&&(t.moved=!0)},onClick:e=>{e.stopPropagation(),MR(window.getSelection()?.toString()??``,i.current?.moved??!1)&&r(),i.current=void 0},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),MR(window.getSelection()?.toString()??``,!1)&&r())},children:[t,n?null:(0,U.jsx)(`span`,{className:`sr-only`,children:` (activate to copy)`})]})}function kz({node:e,children:t,source:n}){let r=e,{copied:i,copy:a}=Dz(jR(n,r?.position,!0)??xz(r)),o=r?.children?.find(e=>e.tagName===`code`)?.properties?.className,s=(Array.isArray(o)?o:[]).map(String).find(e=>e.startsWith(`language-`))?.slice(9);return(0,U.jsxs)(`div`,{className:`relative my-3 rounded-lg bg-muted`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between pl-3`,children:[(0,U.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s&&/^[\w+#.-]{1,20}$/.test(s)?s:`code`,` · tap to copy`]}),(0,U.jsx)(SR,{label:i?`Copied`:`Copy the code`,icon:i?$p:Nm,iconOnly:!0,onClick:()=>void a()})]}),(0,U.jsx)(`pre`,{className:`!my-0 overflow-x-auto !rounded-t-none !bg-transparent px-3 pb-3 text-sm leading-relaxed [&>code]:block`,children:t})]})}function Az(e){return{pre:t=>(0,U.jsx)(kz,{...t,source:e}),code:({node:t,children:n})=>{let r=t;if(r?.properties?.copyBlocked)return(0,U.jsx)(`code`,{children:n});let i=!!r?.properties?.blockCode,a=i?void 0:vz(xz(r));return a?(0,U.jsx)(yz,{path:a,children:(0,U.jsx)(`code`,{children:n})}):(0,U.jsx)(Oz,{text:jR(e,r?.position,i)??xz(r),block:i,children:n})},span:({node:e,children:t,...n})=>{let r=e?.properties?.dataFilePath;return typeof r==`string`?(0,U.jsx)(yz,{path:r,children:t}):(0,U.jsx)(`span`,{...n,children:t})},a:({href:e,children:t})=>(0,U.jsx)(`a`,{href:e?I(e):void 0,target:`_blank`,rel:`noopener noreferrer nofollow`,children:t}),img:({src:e,alt:t})=>(0,U.jsx)(`img`,{src:e?I(e):void 0,alt:t??``,loading:`lazy`}),table:({children:e})=>(0,U.jsx)(`div`,{className:`my-3 w-full overflow-x-auto`,children:(0,U.jsx)(`table`,{className:`w-full border-collapse text-sm`,children:e})})}}var jz=(0,m.memo)(function({text:e}){return(0,U.jsx)(qP,{remarkPlugins:[QL],rehypePlugins:[Cz,Ez],urlTransform:TR,components:Az(e),children:e})}),Mz=(0,m.memo)(function({text:e,className:t}){let{body:n,files:r}=VR(e),i=n?AR(n):[],a=QR(i.length,3);return(0,U.jsxs)(`div`,{className:Y(`md-body`,t),children:[i.slice(0,a).map((e,t)=>(0,U.jsx)(jz,{text:e},t)),(0,U.jsx)(UR,{files:r})]})}),Nz=`(max-width: 1023.98px)`;function Pz(e,t){if(e===`app.sidebar`&&t==null){let e=globalThis.matchMedia;return typeof e==`function`&&e(`(max-width: 1023.98px)`).matches}return e===`lobby.thinking`||t===`1`}var Fz=`bot-lobby.collapsed.`,Iz=new Set,Lz=new Map;function Rz(e){if(Lz.has(e))return Lz.get(e);if(e===`lobby.thinking`)return Pz(e);try{return Pz(e,localStorage.getItem(Fz+e))}catch{return!1}}function zz(e,t){Lz.set(e,t);try{e!==`lobby.thinking`&&localStorage.setItem(Fz+e,t?`1`:`0`)}catch{}for(let e of[...Iz])e()}function Bz(e){return Iz.add(e),()=>{Iz.delete(e)}}function Vz(e){zz(e,!Rz(e))}function Hz(e){return[(0,m.useSyncExternalStore)(Bz,()=>Rz(e),()=>Pz(e)),(0,m.useCallback)(()=>zz(e,!Rz(e)),[e])]}var Uz=`lobby.activity.open`;function Wz({entry:e}){return e.pending?(0,U.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--orb)]`}):e.kind===`error`?(0,U.jsx)(s_,{"aria-hidden":`true`,className:`size-3.5 text-destructive`}):e.kind===`warning`?(0,U.jsx)(qg,{"aria-hidden":`true`,className:`size-3.5 text-warning`}):e.kind===`success`?(0,U.jsx)($p,{"aria-hidden":`true`,className:`size-3.5 text-success`}):(0,U.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`})}function Gz({entry:e}){return(0,U.jsxs)(`li`,{className:`activity-step`,title:HO(e.at),style:e.pending?{"--orb":yO(e.source)}:void 0,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`flex h-5 w-6 items-center justify-center`,children:(0,U.jsx)(Wz,{entry:e})}),(0,U.jsx)(`span`,{className:`sr-only`,children:e.pending?`pending`:e.kind}),(0,U.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,U.jsx)(`span`,{className:Y(`font-medium`,_O(e.source)),children:gO(e.source)}),` `,(0,U.jsxs)(`span`,{className:e.kind===`error`?`text-destructive`:e.pending?`text-foreground`:void 0,children:[bz(e.text),e.pending?`…`:``]})]})]})}function Kz(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,`0`)}m`}function qz(e){let t=[...e].reverse().find(e=>e.pending),n=[...new Set(e.map(e=>gO(e.source)))];return{...t?{live:t}:{},took:(e.at(-1)?.at??0)-(e[0]?.at??0),count:`${e.length} ${e.length===1?`step`:`steps`}`,sources:n.length>3?`${n.slice(0,3).join(`, `)} +${n.length-3}`:n.join(`, `),errors:e.filter(e=>e.kind===`error`).length,warnings:e.filter(e=>e.kind===`warning`).length}}function Jz(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{if(!e)return;n(Date.now());let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),t}function Yz({entries:e}){let[t]=Hz(Uz),[n,r]=(0,m.useState)();(0,m.useEffect)(()=>r(void 0),[t]);let i=n??t,a=(0,m.useId)(),{live:o,took:s,count:c,sources:l,errors:u,warnings:d}=qz(e),f=Jz(!!o),p=o?{"--orb":yO(o.source)}:void 0;return(0,U.jsxs)(`div`,{className:`activity-run`,"data-live":o?!0:void 0,"data-open":i||void 0,style:p,children:[(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":a,onClick:()=>r(!i),className:`activity-toggle`,children:[o?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,U.jsx)(EO,{text:`Working`}),(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:` · `}),(0,U.jsxs)(`span`,{className:`activity-live-step`,children:[(0,U.jsx)(`span`,{className:Y(`font-medium`,_O(o.source)),children:gO(o.source)}),` `,(0,U.jsxs)(`span`,{className:`text-foreground`,children:[o.text,`…`]})]},o.id)]}),(0,U.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[c,e[0]&&f-e[0].at>=1e3?` · ${Kz(f-e[0].at)}`:``]})]}):(0,U.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:s>=1e3?`Worked for ${Kz(s)}`:`Worked`}),(0,U.jsxs)(`span`,{children:[` · `,c,l?` · ${l}`:``]})]}),u?(0,U.jsxs)(`span`,{className:`shrink-0 text-destructive`,children:[u,` `,u===1?`error`:`errors`]}):null,d?(0,U.jsxs)(`span`,{className:`shrink-0 text-warning`,children:[d,` `,d===1?`warning`:`warnings`]}):null,(0,U.jsx)(tm,{"aria-hidden":`true`,className:`activity-chevron size-3.5 shrink-0`})]}),i?(0,U.jsx)(`ol`,{id:a,"aria-label":`Activity`,className:`activity-steps`,children:e.map(e=>(0,U.jsx)(Gz,{entry:e},e.id))}):null]})}function Xz(e,t){let n=[...t].sort((e,t)=>e.at-t.at||e.id-t.id),r=[],i=0,a=e=>{let t=[];for(;i<n.length&&n[i].at<e;)t.push(n[i++]);t.length&&r.push({kind:`activity`,key:`steps-${t[0].id}`,entries:t})};for(let t of e)a(t.at),r.push({kind:`message`,entry:t});return a(1/0),r}var Zz=3e5,Qz=`Talk to the team.`,$z=`Ask a question or ask for a change below: the right agent answers and does it here.`,eB=`Nothing said yet. Type below to talk to the oracle about this task.`;function tB({entry:e}){return e.text===`auto mode`?(0,U.jsx)(TO,{auto:!0,children:NO}):(0,U.jsxs)(TO,{failed:e.text.startsWith(`✗`),children:[e.text,e.at?` · ${HO(e.at)}`:``]})}function nB({entry:e,head:t}){if(e.role===`you`)return(0,U.jsx)(wO,{time:HO(e.at),head:t,...e.to?{note:`to ${gO(e.to)}`}:{},children:(0,U.jsx)(Mz,{text:e.text})});let n=mO(e);return(0,U.jsx)(CO,{source:n,name:n===`PLANNER`?`Panel`:gO(n),time:HO(e.at),head:t,named:!0,children:(0,U.jsx)(Mz,{text:e.text})})}var rB=(0,m.memo)(function({entry:e,head:t,fresh:n}){return(0,U.jsx)(Xf.div,{initial:n?{opacity:0,y:10}:!1,animate:{opacity:1,y:0},transition:{type:`spring`,stiffness:420,damping:32},children:e.role===`note`?(0,U.jsx)(tB,{entry:e}):(0,U.jsx)(nB,{entry:e,head:t})})},(e,t)=>e.head===t.head&&e.entry.id===t.entry.id&&e.entry.text===t.entry.text&&e.entry.at===t.entry.at&&e.entry.to===t.entry.to);function iB({text:e,busy:t,working:n,answering:r}){let i=!!e?.trim();if(!i&&(!t||n))return null;let a=i?`MASTER`:r??`MASTER`;return(0,U.jsx)(CO,{source:a,name:gO(a),head:!0,named:!0,live:t,waiting:!i,aside:t&&i?`writing…`:void 0,children:i?(0,U.jsx)(Mz,{text:e??``}):null})}function aB({hasTask:e}){return(0,U.jsxs)(FO,{className:`h-full border-0`,children:[(0,U.jsxs)(IO,{children:[(0,U.jsx)(RO,{variant:`icon`,children:(0,U.jsx)(jh,{"aria-hidden":`true`})}),e?null:(0,U.jsx)(zO,{children:Qz}),(0,U.jsx)(BO,{children:e?eB:$z})]}),e?null:(0,U.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm text-muted-foreground`,children:[(0,U.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[(0,U.jsx)(GD,{chord:`@`}),` names who answers: @design, @dev, @qa, @research, @scout`]}),(0,U.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[(0,U.jsx)(GD,{chord:`/`}),` /plan plans it with the panel, /task starts it as a task`]})]})]})}async function oB(e){let t=await R(`lobby.history`,{before:e});return{entries:t.entries,hasOlder:t.hasOlder}}function sB(e,t,n){let[r,i]=(0,m.useState)([]),[a,o]=(0,m.useState)(t),[s,c]=(0,m.useState)(!1),l=(0,m.useMemo)(()=>{let t=new Set(e.map(e=>e.id));return[...r.filter(e=>!t.has(e.id)),...e]},[r,e]);return{merged:l,more:a,loading:s,load:(0,m.useCallback)(async()=>{let e=l[0]?.id;if(e===void 0||s||!a)return;c(!0);let t=n.current,r=t?.scrollHeight??0,u=t?.scrollTop??0;try{let t=await oB(e);i(e=>[...t.entries,...e]),o(t.hasOlder),window.requestAnimationFrame(()=>{let e=n.current;e&&(e.scrollTop=e.scrollHeight-r+u)})}catch{o(!1)}finally{c(!1)}},[l,s,a,n])}}var cB=[];function lB({chat:e,activity:t=cB,reply:n,busy:r,answering:i,hasOlder:a,hasTask:o}){let s=(0,m.useMemo)(()=>t.slice(-400),[t]),{ref:c,atBottom:l,stick:u,onScroll:d}=cO(`${e.length}:${n?.length??0}:${s.length}:${s.at(-1)?.pending??``}:${i??``}`),{merged:f,more:p,loading:h,load:g}=sB(e,a,c),_=(0,m.useCallback)(()=>{d();let e=c.current;e&&e.scrollTop<80&&p&&!h&&g()},[d,c,p,h,g]),v=(0,m.useMemo)(()=>Xz(f,s),[f,s]),y=f.length===0&&s.length===0&&!n?.trim()&&!r,b=v.at(-1),x=b?.kind===`activity`&&!!qz(b.entries).live,[S,C]=(0,m.useState)(!1);return(0,m.useEffect)(()=>C(!0),[]),(0,U.jsxs)(GO,{"aria-label":`Conversation`,"data-bare":!0,className:`flex-1 rounded-none border-0 shadow-none`,children:[(0,U.jsx)(`div`,{ref:c,onScroll:_,className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-5 pt-4 pb-dock outline-none focus-visible:bg-muted/30`,role:`log`,"aria-label":`Conversation`,tabIndex:0,children:y?(0,U.jsx)(aB,{hasTask:o}):(0,U.jsxs)(`div`,{className:`chat-column`,children:[p?(0,U.jsx)(`p`,{className:`mb-4 text-center text-xs text-muted-foreground`,children:`Earlier messages load as you scroll up.`}):null,v.map((e,t)=>{if(e.kind===`activity`)return(0,U.jsx)(Yz,{entries:e.entries},e.key);let n=v[t-1],r=n?.kind===`message`?n.entry:void 0,i=!r||mO(r)!==mO(e.entry)||e.entry.at-r.at>Zz;return(0,U.jsx)(rB,{entry:e.entry,head:i,fresh:S},e.entry.id)}),(0,U.jsx)(iB,{text:n,busy:r,working:x,...i?{answering:i}:{}})]})}),(0,U.jsx)(Bv,{target:c,down:!1}),l?null:(0,U.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-dock z-10 flex justify-center [&>*]:pointer-events-auto`,children:(0,U.jsx)(DO,{onClick:u})})]})}var uB=new Set(PR);function dB(e){let t=e.replace(/^#\/?/,``).split(`/`).filter(Boolean);if(t[0]===`sessions`||t[0]===`issues`||t[0]===`git`||t[0]===`excalidraw`||t[0]===`metrics`)return`#/lobby`;if(t[0]===`tasks`&&t[1]===`board`)return[`#/tasks`,...t.slice(2,3)].join(`/`)}function fB(e){let t=e.replace(/^#\/?/,``).split(`/`).filter(Boolean),n=t[0];if(!n||n===`lobby`)return{kind:`tab`,tab:`lobby`,rest:t.slice(1)};if(n===`settings`)return{kind:`settings`};if(uB.has(n))return{kind:`tab`,tab:n,rest:t.slice(1)}}function pB(e,...t){return`#/${e}${t.filter(Boolean).map(e=>`/${encodeURIComponent(e)}`).join(``)}`}function mB(e){window.location.hash!==e&&(window.location.hash=e)}function hB(){let[e,t]=(0,m.useState)(()=>fB(dB(window.location.hash)??window.location.hash)??{kind:`tab`,tab:`lobby`,rest:[]});return(0,m.useEffect)(()=>{let e=()=>{let e=dB(window.location.hash),n=fB(e||window.location.hash);(e||!n)&&window.history.replaceState(null,``,e??`#/lobby`),t(n??{kind:`tab`,tab:`lobby`,rest:[]})};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),e}function gB(e){let t=e[0]===`ask`,[n,r]=t?e.slice(1):e;return{chat:t,agent:n,file:r}}function _B(e,t){let{agent:n,file:r}=gB(e);return pB(`knowledge`,...t?[`ask`]:[],n??``,r??``)}function vB({className:e,...t}){return(0,U.jsx)(`span`,{"data-slot":`spinner`,role:`status`,"aria-label":`Loading`,className:Y(`inline-flex size-4 shrink-0 items-end justify-between text-primary`,e),...t,children:[0,1,2].map(e=>(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`block aspect-square h-[28%] shrink-0 rounded-full bg-current motion-safe:animate-[hop_0.9s_ease-in-out_infinite]`,style:{animationDelay:`${e*.14}s`}},e))})}var yB=Uv([`relative w-full text-sm border has-[>svg]:grid-cols-[calc(var(--spacing)*3)_1fr] grid-cols-[0_1fr] grid gap-y-0.5 items-center [&>svg:not([class*=size-])]:size-4`,`has-[>[data-slot=alert-title]+[data-slot=alert-description]]:[&_[data-slot=alert-action]]:sm:row-end-3`,`has-[>[data-slot=alert-title]+[data-slot=alert-description]]:items-start`,`has-[>[data-slot=alert-title]+[data-slot=alert-description]]:[&_svg]:translate-y-0.5`,`rounded-lg`,`px-3`,`py-2.5`,`has-[>svg]:gap-x-2.5`],{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`border-destructive/30 bg-destructive/4 [&>svg]:text-destructive`,info:`border-info/30 bg-info/4 [&>svg]:text-info`,success:`border-success/30 bg-success/4 [&>svg]:text-success`,warning:`border-warning/30 bg-warning/4 [&>svg]:text-warning`,invert:`border-invert bg-invert text-invert-foreground [&_[data-slot=alert-description]]:text-invert-foreground/70`}},defaultVariants:{variant:`default`}});function bB({className:e,variant:t,...n}){return(0,U.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:Y(yB({variant:t}),e),...n})}function xB({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`alert-description`,className:Y(`text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed`,e),...t})}function SB({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`alert-action`,className:Y(`flex gap-1.5 max-sm:col-start-2 max-sm:mt-2 max-sm:justify-start sm:col-start-3 sm:row-start-1 sm:justify-end sm:self-center`,e),...t})}function CB({label:e=`Connecting…`}){return(0,U.jsxs)(`div`,{className:`flex min-h-48 min-w-0 w-full max-w-full flex-1 items-center justify-center gap-2 overflow-y-auto px-4 py-8 text-sm text-muted-foreground`,children:[(0,U.jsx)(vB,{}),(0,U.jsx)(`span`,{children:e})]})}function wB({message:e,onRetry:t}){return(0,U.jsxs)(FO,{className:`m-4 min-h-0 min-w-0 flex-1 overflow-y-auto`,children:[(0,U.jsxs)(IO,{children:[(0,U.jsxs)(zO,{className:`flex items-center gap-2`,children:[(0,U.jsx)(qg,{className:`size-4 text-destructive`,"aria-hidden":`true`}),`Could not load this view`]}),(0,U.jsx)(BO,{children:e??`The request failed. Try again.`})]}),t?(0,U.jsxs)(X,{variant:`outline`,onClick:t,children:[(0,U.jsx)(hg,{"aria-hidden":`true`}),`Try again`]}):null]})}function TB({onRetry:e}){return(0,U.jsxs)(bB,{variant:`destructive`,role:`status`,className:`mx-3 mb-1 max-h-32 w-auto min-w-0 overflow-y-auto max-sm:mx-2`,children:[(0,U.jsx)(r_,{className:`size-4`,"aria-hidden":`true`}),(0,U.jsx)(xB,{children:`Lost pi — reconnecting every 2 s. Your planning session and tasks carry on when it is back.`}),e?(0,U.jsx)(SB,{children:(0,U.jsx)(X,{variant:`link`,className:`h-8 px-1 text-destructive`,onClick:e,children:`Retry now`})}):null]})}function EB(e,t,n,r=!0){iO();let[i,a]=(0,m.useState)({loading:!0,at:0}),[o,s]=(0,m.useState)(0),c=[F.status().connection,...n.map(e=>F.get(e).version)].join(`,`),l=JSON.stringify(t);(0,m.useEffect)(()=>{if(!r)return;let t=!0,n=performance.now();return a(e=>({...e,loading:!0})),R(e,JSON.parse(l)).then(e=>t&&a({data:e,loading:!1,at:n}),e=>t&&a(t=>({...t,error:e instanceof Error?e.message:String(e),loading:!1}))),()=>{t=!1}},[e,l,c,o,r]);let u=(0,m.useCallback)(()=>s(e=>e+1),[]);return{data:i.data,error:i.error,loading:i.loading,requestedAt:i.at,reload:u}}function DB({...e}){return(0,U.jsx)(bS,{"data-slot":`sheet`,...e})}function OB({...e}){return(0,U.jsx)(VS,{"data-slot":`sheet-close`,...e})}function kB({...e}){return(0,U.jsx)(ES,{"data-slot":`sheet-portal`,...e})}function AB({className:e,...t}){return(0,U.jsx)(OS,{"data-slot":`sheet-overlay`,className:Y(`fixed inset-0 z-50 bg-scrim backdrop-blur-sm duration-150 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function jB({className:e,children:t,side:n=`right`,showCloseButton:r=!0,forceMount:i,hidden:a,...o}){return(0,U.jsxs)(kB,{forceMount:i,children:[a?null:(0,U.jsx)(AB,{}),(0,U.jsxs)(MS,{forceMount:i,hidden:a,"data-slot":`sheet-content`,"data-side":n,className:Y(`glass-pop fixed z-50 flex flex-col gap-4 bg-clip-padding text-sm shadow-lg/5 transition duration-200 ease-calm data-[side=bottom]:rounded-t-2xl data-[side=top]:rounded-b-2xl data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-8 data-[side=left]:data-open:slide-in-from-left-8 data-[side=right]:data-open:slide-in-from-right-8 data-[side=top]:data-open:slide-in-from-top-8 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-8 data-[side=left]:data-closed:slide-out-to-left-8 data-[side=right]:data-closed:slide-out-to-right-8 data-[side=top]:data-closed:slide-out-to-top-8`,e),...o,children:[t,r&&(0,U.jsx)(VS,{"data-slot":`sheet-close`,asChild:!0,children:(0,U.jsxs)(X,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,U.jsx)(s_,{}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function MB({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`sheet-header`,className:Y(`flex flex-col gap-0.5 p-4`,e),...t})}function NB({className:e,...t}){return(0,U.jsx)(LS,{"data-slot":`sheet-title`,className:Y(`text-base font-medium text-foreground`,e),...t})}function PB({className:e,...t}){return(0,U.jsx)(zS,{"data-slot":`sheet-description`,className:Y(`text-sm text-muted-foreground`,e),...t})}var FB=Uv(`bg-muted-foreground/15 motion-safe:animate-skeleton`,{variants:{shape:{block:`rounded-sm`,card:`rounded-lg`,pill:`rounded-full`}},defaultVariants:{shape:`block`}});function IB({className:e,shape:t,...n}){return(0,U.jsx)(`div`,{"aria-hidden":`true`,className:Y(FB({shape:t}),e),"data-slot":`skeleton`,...n})}function LB(){return sO(`(min-width: 1024px)`)}function RB({className:e,...t}){return(0,U.jsx)(`section`,{className:Y(`min-h-0 min-w-0`,e),...t})}function zB({open:e,onClose:t,describe:n,children:r}){let i=tO(e,eO.sheet),a=(0,m.useRef)(!1),o=(0,m.useRef)(null);return i&&(a.current=!0),e||(a.current=!1),(0,U.jsx)(DB,{open:e&&i,onOpenChange:e=>!e&&t(),children:(0,U.jsxs)(jB,{forceMount:e&&a.current?!0:void 0,hidden:!i,showCloseButton:!1,side:`right`,className:Y(`gap-0 data-[side=right]:w-[92%] data-[side=right]:sm:max-w-3xl`,!i&&`!hidden`),children:[(0,U.jsxs)(MB,{className:`flex-row items-center justify-between border-b px-4 py-2`,children:[(0,U.jsx)(NB,{className:`text-sm`,children:`Detail`}),(0,U.jsx)(PB,{className:`sr-only`,children:n}),(0,U.jsx)(OB,{asChild:!0,children:(0,U.jsxs)(X,{variant:`ghost`,size:`sm`,"aria-label":`Close detail`,title:`Close · Esc`,className:`gap-2`,children:[(0,U.jsx)(s_,{"aria-hidden":`true`}),`Close`,(0,U.jsx)(GD,{chord:`Esc`,className:`kbd-hint`})]})})]}),(0,U.jsx)(`div`,{ref:o,className:`min-h-0 flex-1 overflow-y-auto p-5`,children:r}),(0,U.jsx)(Bv,{target:o})]})})}function BB({list:e,detail:t,open:n,detailClassName:r,listPane:i,detailPane:a,onListKey:o,onDetailKey:s}){let c=n&&t!==null;return(0,U.jsxs)(`div`,{className:Y(`relative grid min-h-0 min-w-0 flex-1`,c?`grid-rows-[minmax(0,1fr)_minmax(0,2fr)]`:`grid-rows-1`),children:[(0,U.jsx)(RB,{"data-pane":`list`,ref:i,onKeyDown:o,className:Y(`min-w-0 overflow-x-hidden overflow-y-auto`,c?`border-b border-border`:`pb-dock`),children:e}),c?(0,U.jsx)(RB,{"data-pane":`detail`,ref:a,"aria-label":`Detail`,tabIndex:0,onKeyDown:s,className:Y(`min-w-0 overflow-x-hidden overflow-y-auto px-5 pt-5 pb-dock`,r),children:t}):null,(0,U.jsx)(Bv,{target:i}),c?(0,U.jsx)(Bv,{target:a}):null]})}function VB({wide:e,list:t,detail:n,open:r,onClose:i,hint:a,describe:o,inlineDetail:s,detailClassName:c}){let l=(0,m.useRef)(null),u=(0,m.useRef)(null),d=(0,m.useRef)(null);function f(t){let n=l.current;if(!n||t.defaultPrevented||t.nativeEvent.isComposing||nO()||t.altKey||t.ctrlKey||t.metaKey||aR(t.target)||t.target instanceof HTMLInputElement)return;let r=oR(t.key,!1);r?(t.preventDefault(),uR(n,t.target,r)):t.key===`Home`||t.key===`End`?(t.preventDefault(),uR(n,t.target,t.key===`Home`?`first`:`last`)):(e||s)&&sR(t.key)===1&&u.current&&(t.preventDefault(),u.current.focus())}function p(e){e.defaultPrevented||e.nativeEvent.isComposing||nO()||e.altKey||e.ctrlKey||e.metaKey||aR(e.target)||sR(e.key)===-1&&l.current&&(e.preventDefault(),fR(l.current)?.focus())}return!e&&s?(0,U.jsx)(BB,{list:t,detail:n,open:r,detailClassName:c,listPane:l,detailPane:u,onListKey:f,onDetailKey:p}):e?(0,U.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[clamp(17rem,28%,23rem)_minmax(0,1fr)] gap-3 p-3`,children:[(0,U.jsxs)(`div`,{className:`workspace-pane min-h-0 min-w-0 overflow-hidden rounded-xl border shadow-xs`,children:[(0,U.jsx)(RB,{"data-pane":`list`,ref:l,onKeyDown:f,className:`h-full overflow-y-auto pb-dock`,children:t}),(0,U.jsx)(Bv,{target:l})]}),(0,U.jsxs)(`div`,{className:`workspace-pane min-h-0 min-w-0 overflow-hidden rounded-xl border shadow-xs`,children:[(0,U.jsx)(RB,{"data-pane":`detail`,ref:u,tabIndex:0,"aria-label":`Detail`,onKeyDown:p,className:Y(`h-full overflow-y-auto px-5 pt-5 pb-dock outline-none focus-visible:bg-muted/30`,c),children:n??(0,U.jsx)(`div`,{className:`grid h-full min-h-48 place-items-center`,children:(0,U.jsxs)(`div`,{className:`flex max-w-xs flex-col items-center gap-3 text-center`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`flex size-10 items-center justify-center rounded-xl bg-muted text-muted-foreground`,children:(0,U.jsx)(qh,{className:`size-5`})}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a}),(0,U.jsxs)(`p`,{className:`kbd-hint flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(GD,{chord:`ArrowUp`}),(0,U.jsx)(GD,{chord:`ArrowDown`}),`move`]}),(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(GD,{chord:`ArrowRight`}),`open`]})]})]})})}),(0,U.jsx)(Bv,{target:u})]})]}):(0,U.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,U.jsxs)(`div`,{ref:d,className:`flex min-h-0 flex-1 flex-col overflow-y-auto pb-dock`,children:[(0,U.jsx)(RB,{"data-pane":`list`,ref:l,onKeyDown:f,children:t}),(0,U.jsx)(zB,{open:r&&n!==null,onClose:i,describe:o,children:n})]}),(0,U.jsx)(Bv,{target:d})]})}function HB({title:e,count:t,lead:n,children:r}){return(0,U.jsxs)(`div`,{className:`sticky top-0 z-10 flex min-h-12 flex-wrap items-center gap-x-3 gap-y-1 border-b border-[var(--glass-edge)] sticky-glass px-4 py-2`,children:[(0,U.jsx)(`h2`,{className:n?`sr-only`:`text-sm font-medium`,children:e}),n,(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-2 flex-1`}),t?(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:t}):null,r?(0,U.jsx)(`div`,{className:`flex items-center gap-1.5`,children:r}):null]})}function UB(){return(0,U.jsx)(`div`,{className:`flex flex-col gap-1.5 p-3`,role:`status`,"aria-label":`Loading`,children:[0,1,2,3].map(e=>(0,U.jsx)(IB,{shape:`card`,className:`h-11`},e))})}function WB({...e}){return(0,U.jsx)(aC,{"data-slot":`alert-dialog`,...e})}function GB({...e}){return(0,U.jsx)(oC,{"data-slot":`alert-dialog-portal`,...e})}function KB({className:e,...t}){return(0,U.jsx)(sC,{"data-slot":`alert-dialog-overlay`,className:Y(`fixed inset-0 z-50 bg-scrim backdrop-blur-sm duration-150 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function qB({className:e,...t}){return(0,U.jsxs)(GB,{children:[(0,U.jsx)(KB,{}),(0,U.jsx)(cC,{"data-slot":`alert-dialog-content`,className:Y(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 glass-pop rounded-2xl p-4 text-sm duration-200 data-open:zoom-in-[0.98] data-closed:zoom-out-[0.98] outline-none sm:max-w-md data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})]})}function JB({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:Y(`flex flex-col gap-1.5`,e),...t})}function YB({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:Y(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function XB({className:e,...t}){return(0,U.jsx)(dC,{"data-slot":`alert-dialog-title`,className:Y(`text-base font-medium text-foreground`,e),...t})}function ZB({className:e,...t}){return(0,U.jsx)(fC,{"data-slot":`alert-dialog-description`,className:Y(`text-sm text-muted-foreground`,e),...t})}function QB({className:e,variant:t=`default`,...n}){return(0,U.jsx)(X,{variant:t,size:`sm`,className:Y(`h-7 gap-1 px-2.5`,e),asChild:!0,children:(0,U.jsx)(lC,{"data-slot":`alert-dialog-action`,...n})})}function $B({className:e,...t}){return(0,U.jsx)(X,{variant:`outline`,size:`sm`,className:Y(`h-7 gap-1 px-2.5`,e),asChild:!0,children:(0,U.jsx)(uC,{"data-slot":`alert-dialog-cancel`,...t})})}function eV({label:e,text:t,shortcut:n,title:r,description:i,confirmLabel:a,onConfirm:o,icon:s,disabled:c,variant:l=`outline`,iconOnly:u,compact:d}){let[f,p]=(0,m.useState)(!1),h=tO(f,eO.confirm),g=l===`destructive`;return bR(`y`,()=>{p(!1),o()},{enabled:f&&h,inDialog:!0}),(0,U.jsxs)(WB,{open:f&&h,onOpenChange:p,children:[(0,U.jsx)(SR,{label:e,icon:s,tone:g?`danger`:`neutral`,disabled:c,shortcut:n,iconOnly:u,...d?{"data-compact":!0,className:`size-8`}:{},...t?{text:t}:{},onClick:()=>p(!0)}),(0,U.jsxs)(qB,{children:[(0,U.jsxs)(JB,{children:[(0,U.jsx)(XB,{children:r}),(0,U.jsx)(ZB,{children:i})]}),(0,U.jsxs)(YB,{children:[(0,U.jsxs)($B,{children:[`Keep it`,(0,U.jsx)(GD,{chord:`Esc`,className:`kbd-hint ml-1`})]}),(0,U.jsxs)(QB,{variant:g?`destructive`:`default`,onClick:o,children:[a,(0,U.jsx)(GD,{chord:`Y`,className:`kbd-hint ml-1`})]})]})]})]})}function tV({className:e,...t}){return(0,U.jsx)(`textarea`,{"data-slot":`textarea`,className:Y(`flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-background bg-clip-padding px-3 py-2 text-sm shadow-control transition-[border-color,box-shadow] duration-150 outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/24 focus-visible:shadow-none disabled:cursor-not-allowed disabled:opacity-64 aria-invalid:border-destructive/36 aria-invalid:focus-visible:border-destructive/64 aria-invalid:focus-visible:ring-destructive/16 dark:bg-input/32`,e),...t})}function nV(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function rV({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,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium text-foreground`,children:e}),(0,U.jsx)(tV,{id:i,value:a,rows:2,"aria-describedby":t?`${i}-hint`:void 0,onChange:e=>o(e.target.value),onKeyDown:e=>{nV(e)&&(e.preventDefault(),l())}}),t?(0,U.jsx)(`p`,{id:`${i}-hint`,className:`text-xs text-muted-foreground`,children:t}):null,(0,U.jsx)(`div`,{className:`flex self-end`,children:(0,U.jsx)(SR,{label:n,icon:s?xh:zp,tone:`primary`,shortcut:`Enter`,className:s?`[&_svg]:animate-spin`:void 0,onClick:()=>void l(),disabled:!a.trim()||s})})]})}function iV({title:e,right:t,prominent:n,children:r}){return(0,U.jsxs)(`section`,{className:Y(`flex min-w-0 flex-col`,n?`gap-4`:`workspace-section gap-3 rounded-xl border p-4 shadow-xs`),children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:(0,U.jsx)(KO,{title:e,right:t,className:n?`[&>span:first-child]:font-semibold`:void 0})}),r]})}var aV=[`master`,`designer`,`backend`,`qa`],oV={master:`Oracle`,designer:`Designer`,backend:`Backend`,qa:`QA`},sV={master:`Oracle`,designer:`Designer`,backend:`Backend`,qa:`QA`},cV=`Every write archives the version before it.`;function lV(e){if(e<1e3)return String(e);let t=e/1e3;return`${t>=10?Math.round(t):t.toFixed(1)}k`}function uV(e){return`over the compaction threshold — ask the oracle to compact ${e}`}function dV(e){return{text:e.text,occurrence:e.occurrence}}function fV(e){return aV.map(t=>{let n=e.filter(e=>e.agent===t);return{agent:t,files:n,notes:n.reduce((e,t)=>e+t.notes,0)}}).filter(e=>e.files.length>0)}function pV(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function mV({initial:e,busy:t,onSave:n,onCancel:r}){let[i,a]=(0,m.useState)(e),o=()=>{!t&&i.trim()&&n(i)};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-input p-3`,children:[(0,U.jsx)(`label`,{htmlFor:`knowledge-entry`,className:`text-sm font-medium text-foreground`,children:`Edit entry`}),(0,U.jsx)(tV,{id:`knowledge-entry`,value:i,rows:4,autoFocus:!0,onChange:e=>a(e.target.value),onKeyDown:e=>{pV(e)&&(e.preventDefault(),o())}}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:cV}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(X,{variant:`outline`,onClick:r,disabled:t,children:`Cancel`}),(0,U.jsxs)(X,{onClick:o,disabled:t||!i.trim(),children:[t?(0,U.jsx)(vB,{}):null,`Save`]})]})]})]})}function hV({open:e,file:t,initial:n,busy:r,onClose:i,onSave:a}){let[o,s]=(0,m.useState)(n),c=tO(e,eO.confirm);return(0,U.jsx)(qD,{open:e&&c,onOpenChange:e=>!e&&i(),label:`Edit ${t}`,description:cV,dismissOnBackdrop:!1,className:`max-w-3xl`,children:(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`h2`,{className:`text-base font-medium`,children:[`Edit `,t]}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:cV})]}),(0,U.jsx)(tV,{value:o,rows:14,className:`min-h-0 flex-1 font-mono text-sm`,onChange:e=>s(e.target.value)}),(0,U.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(X,{variant:`outline`,onClick:i,disabled:r,children:`Cancel`}),(0,U.jsxs)(X,{onClick:()=>a(o),disabled:r,children:[r?(0,U.jsx)(vB,{}):null,`Save file`]})]})]})})}function gV({note:e,about:t,onTakeBack:n,busy:r}){let i=t?`about "${t.replace(/\s+/g,` `).trim().slice(0,50)}": ${e.text}`:e.text;return(0,U.jsxs)(`li`,{className:`flex items-start gap-2 text-sm text-muted-foreground`,children:[(0,U.jsx)($h,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-primary`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:i}),(0,U.jsx)(SR,{label:`Take the note back`,icon:Yg,iconOnly:!0,className:`-my-1 size-7`,disabled:r,onClick:()=>n(e.id)})]})}function _V({entry:e,index:t,selected:n,notes:r,onPick:i,onTakeBack:a,busy:o}){let s=()=>i(t);return(0,U.jsxs)(`li`,{role:`button`,tabIndex:0,"aria-pressed":n,onClick:s,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},className:n?`flex min-h-9 cursor-pointer flex-col gap-1 rounded-lg border border-primary/30 bg-accent px-3 py-2.5 outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`:`flex min-h-9 cursor-pointer flex-col gap-1 rounded-lg border border-border px-3 py-2.5 outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[(0,U.jsx)(`div`,{className:`flex gap-2`,children:(0,U.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,U.jsx)(Mz,{text:e.text})})}),r.length>0?(0,U.jsx)(`ul`,{className:`flex flex-col gap-1 pl-1`,children:r.map(e=>(0,U.jsx)(gV,{note:e,onTakeBack:a,busy:o},e.id))}):null]})}function vV({notes:e,onTakeBack:t,busy:n}){return e.length===0?null:(0,U.jsx)(iV,{title:`Notes on entries that changed`,right:String(e.length),children:(0,U.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,U.jsx)(gV,{note:e,about:e.entry,onTakeBack:t,busy:n},e.id))})})}function yV({view:e}){let t=e.entries.length;return(0,U.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(`h2`,{className:`min-w-0 break-words text-lg font-semibold tracking-tight`,children:[sV[e.agent],` `,(0,U.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,e.file]})]}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` `,t===1?`entry`:`entries`,` · `,lV(e.chars),` chars`]}),e.over?(0,U.jsx)(`p`,{className:`text-sm text-foreground`,children:uV(e.file)}):null]})}function bV({draft:e,picked:t,setDraft:n,onEditFile:r,onDelete:i}){let a=!!e;return(0,U.jsxs)(CR,{children:[(0,U.jsx)(SR,{label:`Edit the entry`,text:`Edit`,icon:tg,shortcut:`E`,disabled:a||!t,onClick:()=>n({kind:`edit`,entry:t})}),(0,U.jsx)(SR,{label:t?`Add an entry after it`:`Add an entry`,text:`Add`,icon:sg,shortcut:`A`,disabled:a,onClick:()=>n({kind:`add`,entry:t})}),(0,U.jsx)(SR,{label:`Comment on the entry`,text:`Comment`,icon:kh,shortcut:`C`,disabled:a||!t,onClick:()=>n({kind:`comment`,entry:t})}),(0,U.jsx)(SR,{label:`Edit the whole file`,text:`Edit file`,icon:Um,shortcut:`F`,disabled:a,onClick:r}),(0,U.jsx)(eV,{icon:Gg,label:`Delete the entry`,text:`Delete`,shortcut:`Delete`,title:`Delete this entry?`,description:`The entry and its notes are removed. The version before is archived.`,confirmLabel:`Delete entry`,variant:`destructive`,disabled:a||!t,onConfirm:i})]})}function xV({agent:e,file:t,onChanged:n}){let r=EB(`knowledge.open`,{agent:e,file:t},[`knowledge`]),[i,a]=(0,m.useState)(0),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=r.data?.view,p=f?.entries??[],h=p[Math.min(i,Math.max(0,p.length-1))],g=async e=>{d(!0),await e(),s(void 0),r.reload(),n(),d(!1)},_=e=>void g(()=>mp(`knowledge.unnote`,{id:e})),v=()=>{h&&g(()=>mp(`knowledge.remove`,{agent:e,file:t,ref:dV(h)}))},y=n=>{let r=o?.entry;if(o?.kind===`edit`&&r)return void g(()=>mp(`knowledge.edit`,{agent:e,file:t,ref:dV(r),text:n}));if(o?.kind===`comment`&&r)return void g(()=>mp(`knowledge.comment`,{agent:e,file:t,ref:dV(r),text:n}));g(()=>mp(`knowledge.add`,{agent:e,file:t,...h?{ref:dV(h)}:{},text:n}))};return f?(0,U.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${sV[e]} ${t}`,children:[(0,U.jsx)(bV,{draft:o,picked:h,setDraft:s,onEditFile:()=>l(!0),onDelete:v}),(0,U.jsx)(yV,{view:f}),p.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing here yet. Add the first entry below.`}):null,(0,U.jsx)(`ul`,{className:`workspace-section flex flex-col gap-2 rounded-xl border p-3 shadow-xs`,children:p.map((e,t)=>(0,U.jsx)(_V,{entry:e,index:t,selected:t===i,notes:f.attached.filter(t=>t.entry===e.text),onPick:a,onTakeBack:_,busy:u},`${t}-${e.text}`))}),o?.kind===`edit`?(0,U.jsx)(mV,{initial:o.entry.text,busy:u,onSave:y,onCancel:()=>s(void 0)}):null,o?.kind===`comment`?(0,U.jsx)(rV,{label:`Comment on this entry`,hint:cV,buttonLabel:`Add note`,onSend:async e=>(y(e),!0)}):null,o?.kind===`add`?(0,U.jsx)(rV,{label:`Add an entry`,hint:cV,buttonLabel:`Add entry`,onSend:async e=>(y(e),!0)}):null,u&&!o?(0,U.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,U.jsx)(vB,{}),` saving…`]}):null,(0,U.jsx)(vV,{notes:f.detached,onTakeBack:_,busy:u}),(0,U.jsx)(hV,{open:c,file:t,initial:f.content,busy:u,onClose:()=>l(!1),onSave:n=>{l(!1),g(()=>mp(`knowledge.replaceFile`,{agent:e,file:t,text:n}))}})]}):r.error?(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not read the file. `,r.error]}):(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`reading…`})}function SV(e){return`${e.agent}/${e.file}`}var CV=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function wV({info:e}){return(0,U.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs text-muted-foreground tabular-nums`,children:[(0,U.jsx)(`span`,{children:lV(e.chars)}),e.over?(0,U.jsx)(`span`,{className:`text-foreground`,children:`· over`}):null,e.notes>0?(0,U.jsx)(`span`,{className:`text-primary`,children:CV(e.notes,`note`)}):null]})}function TV({name:e}){let t=e.split(`.`).pop()?.toLowerCase();return t===`md`||t===`mdx`||t===`txt`?(0,U.jsx)(Ym,{"aria-hidden":`true`,className:`ktree-icon`,"data-ext":`md`}):t===`json`||t===`yaml`||t===`yml`||t===`toml`?(0,U.jsx)(zm,{"aria-hidden":`true`,className:`ktree-icon`,"data-ext":`data`}):(0,U.jsx)($m,{"aria-hidden":`true`,className:`ktree-icon`})}function EV({info:e,selected:t,onSelect:n}){return(0,U.jsx)(`li`,{className:`ktree-leaf`,children:(0,U.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(SV(e)),title:e.label,className:`ktree-row ktree-file`,children:[(0,U.jsx)(TV,{name:e.file}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,U.jsxs)(`span`,{className:`sr-only`,children:[e.label,`, `]}),(0,U.jsx)(`span`,{"aria-hidden":`true`,children:e.file})]}),(0,U.jsx)(wV,{info:e})]})})}var DV=`bot-lobby.knowledge.folded`;function OV(){try{let e=JSON.parse(window.localStorage.getItem(DV)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function kV({files:e,models:t={},selectedKey:n,onSelect:r}){let[i,a]=(0,m.useState)(OV),o=fV(e),s=e.reduce((e,t)=>e+t.notes,0);function c(e,t){a(n=>{let r=t?n.filter(t=>t!==e):[...new Set([...n,e])];try{window.localStorage.setItem(DV,JSON.stringify(r))}catch{}return r})}return(0,U.jsxs)(`div`,{className:`ktree px-2 pt-2 pb-3`,children:[(0,U.jsxs)(`p`,{className:`ktree-row ktree-root`,children:[(0,U.jsx)(ph,{"aria-hidden":`true`,className:`ktree-icon`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:`Project knowledge`}),(0,U.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[CV(e.length,`file`),` · `,CV(o.length,`agent`),s>0?` · ${CV(s,`note`)}`:``]})]}),(0,U.jsx)(`ul`,{className:`ktree-branches`,"aria-label":`Agents and their knowledge`,children:o.map(e=>{let a=!i.includes(e.agent),o=`knowledge-${e.agent}`,s=t[e.agent];return(0,U.jsxs)(`li`,{className:`ktree-branch`,children:[(0,U.jsx)(`h3`,{className:`font-normal`,children:(0,U.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space ArrowLeft ArrowRight`,"aria-describedby":`focused-action-help`,type:`button`,"aria-expanded":a,"aria-controls":o,onClick:()=>c(e.agent,!a),onKeyDown:t=>{t.key===`ArrowLeft`||t.key===`h`?(t.preventDefault(),t.stopPropagation(),c(e.agent,!1)):(t.key===`ArrowRight`||t.key===`l`)&&(t.preventDefault(),t.stopPropagation(),a||c(e.agent,!0))},className:`ktree-row ktree-node`,children:[(0,U.jsx)(am,{"aria-hidden":`true`,className:Y(`ktree-chevron`,a&&`rotate-90`)}),a?(0,U.jsx)(th,{"aria-hidden":`true`,className:`ktree-icon ktree-folder`}):(0,U.jsx)(rh,{"aria-hidden":`true`,className:`ktree-icon ktree-folder`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,U.jsx)(`span`,{className:`text-foreground`,children:oV[e.agent]}),s?(0,U.jsxs)(`span`,{className:`ms-2 text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`sr-only`,children:`runs on `}),s]}):null]}),(0,U.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[e.notes>0?(0,U.jsxs)(`span`,{className:`text-primary`,children:[CV(e.notes,`note`),` · `]}):null,CV(e.files.length,`file`)]})]})}),(0,U.jsx)(ju,{initial:!1,children:a?(0,U.jsx)(Xf.ul,{id:o,"aria-label":`${oV[e.agent]}'s knowledge`,initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{type:`spring`,stiffness:520,damping:42},className:`ktree-leaves`,children:e.files.map(e=>(0,U.jsx)(EV,{info:e,selected:SV(e)===n,onSelect:r},SV(e)))},`files`):null})]},e.agent)})})]})}var AV=()=>mB(pB(`knowledge`)),jV=e=>{let[t,n]=e.split(`/`);mB(pB(`knowledge`,t??``,n??``))};function MV(){return(0,U.jsx)(FO,{className:`m-4 flex-1`,children:(0,U.jsxs)(IO,{children:[(0,U.jsx)(RO,{variant:`icon`,children:(0,U.jsx)(qp,{"aria-hidden":`true`})}),(0,U.jsx)(BO,{children:`No knowledge files yet.`})]})})}function NV(e,t,n,r){let i=e.find(e=>e.agent===t&&e.file===n);return i?(0,U.jsx)(xV,{agent:i.agent,file:i.file,onChanged:r},SV(i)):t&&n?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That file is not on the list any more.`}):null}function PV(){let e=oO(`lobby`),t=oO(`status`),n=e.data,r=t.data?.busy??!1;return!n?.chat.length&&!n?.reply&&!r?(0,U.jsx)(`p`,{className:`m-auto max-w-md px-5 pb-dock text-center text-sm text-muted-foreground`,children:`Ask about this project below. The oracle checks saved knowledge, searches the codebase for missing information, and saves verified findings.`}):(0,U.jsx)(lB,{chat:n?.chat??[],reply:n?.reply,busy:r,hasOlder:n?.hasOlderChat??!1,hasTask:!!n?.task})}function FV({read:e,selected:t}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(HB,{title:`Knowledge`}),(0,U.jsx)(IV,{read:e,selected:t})]})}function IV({read:e,selected:t}){return!e.data&&e.error?(0,U.jsx)(wB,{message:`Could not load the knowledge files. ${e.error}`,onRetry:e.reload}):e.data?e.data.files.length?(0,U.jsx)(kV,{files:e.data.files,models:e.data.models??{},selectedKey:t,onSelect:jV}):(0,U.jsx)(MV,{}):(0,U.jsx)(UB,{})}function LV({rest:e}){let{chat:t,agent:n,file:r}=gB(e),i=LB(),a=EB(`knowledge.files`,{},[`knowledge`]),o=a.data?.files??[],s=o.find(e=>e.agent===n&&e.file===r);return(0,U.jsx)(VB,{wide:i,inlineDetail:!0,list:(0,U.jsx)(FV,{read:a,selected:s?SV(s):void 0}),detail:t?(0,U.jsx)(PV,{}):NV(o,n,r,a.reload),detailClassName:t?`flex flex-col overflow-hidden p-0`:void 0,open:t||!!(n&&r),onClose:AV,hint:`Select a file to read its entries, or ask about the project below.`,describe:t?`Knowledge chat`:`Knowledge file`})}function RV(e){let t=e[0];try{return{id:t?decodeURIComponent(t):void 0}}catch{return{id:t}}}var zV=e=>e?.panels??{conversation:!0,activity:!0,thinking:!0};function BV({data:e,status:t}){let n=zV(t);if(!n.conversation)return null;let r=n.activity?e?.activity:void 0;return(0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,U.jsx)(lB,{chat:e?.chat??[],...r?{activity:r}:{},reply:e?.reply,busy:t?.busy??!1,...e?.answering?{answering:e.answering}:{},hasOlder:e?.hasOlderChat??!1,hasTask:!!e?.task})})}function VV(){let e=oO(`lobby`),t=oO(`status`);return!e.data&&e.loading?(0,U.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,U.jsx)(vB,{}),(0,U.jsx)(`span`,{children:`Connecting…`})]}):!e.data&&e.error?(0,U.jsx)(wB,{message:e.error,onRetry:()=>F.onHello({})}):(0,U.jsx)(BV,{data:e.data,status:t.data})}var HV=class{seen=new Set;initialized=new Set;storage;constructor(e){this.storage=e;try{let t=JSON.parse(e?.getItem(`bot-lobby.prompt-seen`)??`[]`);Array.isArray(t)&&(this.seen=new Set(t.filter(e=>typeof e==`string`)))}catch{}}observe(e,t,n=!1){let r=this.initialized.has(e)&&!n?t.filter(e=>!this.seen.has(e)):[];this.initialized.add(e);for(let e of t)this.seen.add(e);try{this.storage?.setItem(`bot-lobby.prompt-seen`,JSON.stringify([...this.seen]))}catch{}return r}};function UV(e,t){return JSON.stringify([e,`prompt`,t])}function WV(e,t,n){return JSON.stringify([e,`dialog`,t,n])}function GV(e,t,n){return JSON.stringify([e,`delivery`,t,n])}var KV=`bot-lobby.prompt-sound-muted`,qV=new Set,JV,YV=!1;function XV(){try{return localStorage.getItem(KV)===`on`}catch{return YV}}function ZV(e){YV=e;try{localStorage.setItem(KV,e?`on`:`off`)}catch{}for(let e of qV)e()}function QV(e){return qV.add(e),()=>{qV.delete(e)}}function $V(){return(0,m.useSyncExternalStore)(QV,XV,()=>!1)}function eH(){(0,m.useEffect)(()=>{let e=()=>{try{JV??=new AudioContext,JV.resume().catch(()=>void 0)}catch{}};return window.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,e)}},[])}function tH(){if(!XV()&&JV&&JV.state===`running`)try{let e=JV.currentTime,t=JV.createOscillator(),n=JV.createGain();t.frequency.setValueAtTime(960,e),t.frequency.exponentialRampToValueAtTime(360,e+.16),n.gain.setValueAtTime(1e-4,e),n.gain.exponentialRampToValueAtTime(.12,e+.012),n.gain.exponentialRampToValueAtTime(1e-4,e+.22),t.connect(n),n.connect(JV.destination),t.start(e),t.stop(e+.24),t.onended=()=>{t.disconnect(),n.disconnect()}}catch{}}var nH=`bot-lobby.notifications`,rH=`/icon-192.png`,iH=new Set;function aH(){for(let e of[...iH])e()}function oH(){try{return localStorage.getItem(nH)===`on`}catch{return!1}}function sH(e){return iH.add(e),()=>{iH.delete(e)}}function cH(e){try{localStorage.setItem(nH,e?`on`:`off`)}catch{}aH()}function lH(){return(0,m.useSyncExternalStore)(sH,oH,()=>!1)}async function uH(){return typeof Notification>`u`?`unsupported`:(Notification.permission==="default"&&await Notification.requestPermission().catch(()=>void 0),Notification.permission===`granted`?(cH(!0),`granted`):`denied`)}function dH(){cH(!1)}function fH(e){if(e===`completed`)return`finished`;if(e===`abandoned`)return`dropped`}function pH(){return typeof Notification<`u`&&Notification.permission===`granted`&&document.hidden}function mH(e){try{new Notification(`bot-lobby`,{body:e,icon:rH,tag:`bot-lobby`})}catch{}}function hH(){try{return new HV(sessionStorage)}catch{return new HV}}function gH(e,t){let n=t.payload;return t.kind===`sessionDialog`&&n?.dialog?.id?WV(e,t.sessionId??n.key??t.from,n.dialog.id):UV(e,t.id)}function _H(){let e=lH();eH(),iO();let t=EB(`tasks.list`,{},[`tasks`]),n=EB(`sessions.list`,{},[`sessions`]),r=F.get(`prompts`),i=F.get(`lobby`).data,a=(0,m.useRef)(hH()),o=(0,m.useRef)(new Set([`prompts`,`sessions`,`delivery`])),s=(0,m.useRef)(void 0),c=fe()??`current`,l=F.status().connection;return{enabled:e,tasks:t,sessions:n,prompts:r,lobby:i,seen:a,quiet:o,previousState:s,project:c,connection:l,lastConnection:(0,m.useRef)(l)}}function vH(e,t,n,r,i){if(!i)return;let{seen:a,project:o,quiet:s,enabled:c}=e,l=a.current.observe(`${o}:${t}`,n,s.current.has(t));s.current.delete(t),l.length&&(l.forEach(()=>tH()),c&&pH()&&mH(r),t===`delivery`&&W.info(r,{action:{label:`Review tasks`,onClick:()=>mB(`#/tasks`)}}))}function yH(e){let{prompts:t,sessions:n,tasks:r,project:i}=e,a=t.data?.prompts;vH(e,`prompts`,(a??[]).map(e=>gH(i,e)),`A question is waiting for you.`,!!a&&!t.loading),vH(e,`sessions`,n.data?.background.flatMap(e=>e.dialogs.map(t=>WV(i,e.sessionId??e.key,t.id)))??[],`A background session is asking something.`,!!n.data&&!n.loading),vH(e,`delivery`,r.data?.rows.filter(e=>e.delivery&&(e.delivery.status===`pending_approval`||e.delivery.status===`deferred`||e.delivery.status===`recoverable_failure`)).map(e=>GV(i,e.id,e.delivery.reviewId))??[],`Completed work is ready for delivery review in Tasks.`,!!r.data&&!r.loading)}function bH(e){let{lastConnection:t,connection:n,quiet:r,previousState:i,lobby:a,enabled:o}=e;if(t.current!==n||n!==`live`){t.current=n,r.current=new Set([`prompts`,`sessions`,`delivery`]),i.current=void 0;return}yH(e);let s=a?.task?.state??``,c=fH(s);i.current&&c&&s!==i.current&&o&&pH()&&mH(`${a?.task?.title??`The task`} ${c}.`),i.current=s}function xH(){let e=_H(),{connection:t,enabled:n,project:r,prompts:i,sessions:a,tasks:o,lobby:s}=e;(0,m.useEffect)(()=>bH(e),[t,n,r,i.data,i.loading,a.data,a.loading,o.data,o.loading,s])}function SH({className:e,type:t,...n}){return(0,U.jsx)(`input`,{type:t,"data-slot":`input`,className:Y(`flex h-8 w-full rounded-lg border border-input bg-background bg-clip-padding px-3 py-1 text-sm shadow-control transition-[border-color,box-shadow] duration-150 outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/24 focus-visible:shadow-none disabled:cursor-not-allowed disabled:opacity-64 aria-invalid:border-destructive/36 aria-invalid:focus-visible:border-destructive/64 aria-invalid:focus-visible:ring-destructive/16 dark:bg-input/32`,e),...n})}function CH({className:e,thumbClassName:t,...n}){return(0,U.jsx)(qE,{"aria-keyshortcuts":`Enter Space`,"aria-description":`When focused, press Enter or Space to toggle.`,"data-slot":`switch`,className:Y(`peer relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border border-transparent outline-none before:absolute before:-inset-x-2 before:-inset-y-3 before:content-[''] transition-[background-color,box-shadow] duration-200 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-64 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,e),...n,children:(0,U.jsx)(YE,{"data-slot":`switch-thumb`,className:Y(`pointer-events-none block size-4 rounded-full bg-background shadow-sm/5 ring-0 [transition:translate_.15s,scale_.1s_.1s] origin-left in-[[role=switch]:active]:scale-x-110 data-[state=checked]:origin-right data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0 dark:bg-white`,t)})})}function wH(e){return(0,U.jsx)(NE,{...e})}function TH(e){return(0,U.jsx)(PE,{"data-slot":`popover-trigger`,...e})}function EH({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,U.jsx)(FE,{children:(0,U.jsx)(IE,{"data-slot":`popover-content`,align:t,sideOffset:n,className:Y(`reui-menu z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-lg border p-1 outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-[0.98] data-closed:animate-out data-closed:fade-out-0 motion-reduce:animate-none`,e),...r})})}var DH=`reui-select inline-flex h-8 min-w-36 cursor-pointer items-center justify-between gap-2 rounded-lg border px-[calc(--spacing(3)-1px)] text-left text-sm text-foreground outline-none select-none transition-[color,box-shadow,background-color,border-color] duration-150 focus-visible:ring-[3px] focus-visible:ring-inset focus-visible:ring-ring/24 disabled:pointer-events-none disabled:opacity-64 [&_svg]:pointer-events-none [&_svg]:shrink-0`,OH=`-me-1 size-3 shrink-0 opacity-50`;function kH(e,t){let n=`${e.label} ${e.hint??``} ${e.value}`.toLowerCase();return t.toLowerCase().split(/\s+/).filter(Boolean).every(e=>n.includes(e))}function AH(e,t,n,r){for(let r=t;r>=0&&r<e.length;r+=n)if(!e[r].disabled)return r;return r}function jH(e){return AH(e,0,1,0)}function MH({value:e,options:t,onChange:n,label:r,className:i,disabled:a}){let[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(0),f=(0,m.useRef)(null),p=(0,m.useId)(),h=(0,m.useMemo)(()=>t.filter(e=>kH(e,c)),[t,c]),g=t.find(t=>t.value===e);(0,m.useEffect)(()=>{o&&(l(``),d(AH(t,Math.max(0,t.findIndex(t=>t.value===e)),1,jH(t))))},[o]);function _(e){l(e),d(jH(t.filter(t=>kH(t,e))))}(0,m.useEffect)(()=>{f.current?.querySelector(`[data-index="${u}"]`)?.scrollIntoView({block:`nearest`})},[u,o,h.length]);function v(t){t&&!t.disabled&&(s(!1),t.value!==e&&n(t.value))}function y(e){e.key===`ArrowDown`?(e.preventDefault(),d(e=>AH(h,Math.min(h.length-1,e+1),-1,e))):e.key===`ArrowUp`?(e.preventDefault(),d(e=>AH(h,Math.max(0,e-1),1,e))):e.key===`Home`&&!c?(e.preventDefault(),d(jH(h))):e.key===`End`&&!c?(e.preventDefault(),d(AH(h,h.length-1,-1,0))):e.key===`Tab`?s(!1):e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),v(h[u]))}return(0,U.jsxs)(wH,{open:o,onOpenChange:s,children:[(0,U.jsxs)(TH,{type:`button`,role:`combobox`,"aria-label":r,"aria-keyshortcuts":`Enter Space ArrowDown ArrowUp`,"aria-description":`When focused, press Enter, Space or an arrow key to choose. Type to search.`,"aria-expanded":o,"aria-haspopup":`listbox`,"aria-controls":o?p:void 0,disabled:a,onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),s(!0))},"data-slot":`select-trigger`,className:Y(DH,`w-full min-w-0 overflow-hidden whitespace-nowrap`,i),children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:g?.label??e}),(0,U.jsx)(tm,{"aria-hidden":`true`,strokeWidth:2.25,className:OH})]}),(0,U.jsxs)(EH,{align:`start`,sideOffset:4,collisionPadding:8,onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.querySelector(`input`)?.focus()},className:`p-0 flex max-h-[min(20rem,var(--radix-popover-content-available-height))] w-[max(var(--radix-popover-trigger-width),17rem)] max-w-(--radix-popover-content-available-width) flex-col overflow-hidden rounded-lg outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-[0.98] data-closed:animate-out data-closed:fade-out-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-2.5`,children:[(0,U.jsx)(Cg,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,U.jsx)(`input`,{value:c,onChange:e=>_(e.target.value),onKeyDown:y,role:`searchbox`,"aria-label":`Search ${r}`,"aria-controls":p,"aria-activedescendant":h[u]?`${p}-${u}`:void 0,placeholder:`Search…`,autoComplete:`off`,spellCheck:!1,className:`h-8 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground`})]}),(0,U.jsxs)(`div`,{ref:f,id:p,role:`listbox`,"aria-label":r,className:`min-h-0 flex-1 overflow-y-auto p-1`,children:[h.length===0?(0,U.jsxs)(`p`,{className:`px-2.5 py-2 text-xs text-muted-foreground`,children:[`Nothing matches “`,c,`”.`]}):null,h.map((t,n)=>(0,U.jsx)(`div`,{id:`${p}-${n}`,role:`option`,"aria-selected":t.value===e,"aria-disabled":t.disabled||void 0,"data-index":n,"data-disabled":t.disabled||void 0,onPointerMove:()=>{t.disabled||d(n)},onClick:()=>v(t),className:Y(`flex min-h-8 items-center gap-2 rounded-sm px-2 py-1 text-sm select-none sm:min-h-7`,t.disabled?`cursor-not-allowed opacity-60`:`cursor-pointer`,!t.disabled&&t.value===e&&`bg-foreground/[0.08]`,!t.disabled&&n===u&&`bg-accent text-accent-foreground`),children:(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate`,children:t.label}),t.hint?(0,U.jsx)(`span`,{className:`line-clamp-2 text-pretty text-xs text-muted-foreground/80`,children:t.hint}):null]})},t.value))]})]})]})}var NH=Uv([`relative flex flex-col overflow-hidden bg-card text-card-foreground rounded-(--frame-radius)`,`[--frame-radius:var(--radius-xl)]`,`[--frame-gap:0px] [--frame-px:0px] [--frame-py:0px] [--frame-panel-header-gap:0rem] [--frame-panel-footer-gap:--spacing(1)]`,`[--frame-panel-px-adjust:0px] [--frame-panel-py-adjust:0px] [--frame-panel-header-px-adjust:0px] [--frame-panel-header-py-adjust:0px] [--frame-panel-footer-px-adjust:0px] [--frame-panel-footer-py-adjust:0px]`,`[--frame-panel-px:calc(var(--frame-panel-px-base)+var(--frame-panel-px-adjust))] [--frame-panel-py:calc(var(--frame-panel-py-base)+var(--frame-panel-py-adjust))] [--frame-panel-header-px:calc(var(--frame-panel-header-px-base)+var(--frame-panel-header-px-adjust))] [--frame-panel-header-py:calc(var(--frame-panel-header-py-base)+var(--frame-panel-header-py-adjust))] [--frame-panel-footer-px:calc(var(--frame-panel-footer-px-base)+var(--frame-panel-footer-px-adjust))] [--frame-panel-footer-py:calc(var(--frame-panel-footer-py-base)+var(--frame-panel-footer-py-adjust))]`,``,`[--frame-panel-bg:var(--workspace-card)] [--frame-panel-border-color:var(--workspace-border)] [--frame-border-color:var(--workspace-border)]`,`[--frame-panel-radius:calc(var(--frame-radius)-var(--frame-px)-1px)]`],{variants:{variant:{default:`border border-[var(--frame-border-color)] bg-clip-padding`,inverse:`[--frame-panel-bg:color-mix(in_oklch,var(--color-muted)_40%,transparent)] border border-[var(--frame-border-color)] bg-background bg-clip-padding`,ghost:`[--frame-panel-radius:calc(var(--frame-radius)-var(--frame-px))]`},spacing:{xs:`[--frame-panel-px-base:--spacing(2)] [--frame-panel-py-base:--spacing(2)] [--frame-panel-header-px-base:--spacing(2)] [--frame-panel-header-py-base:--spacing(0.5)] [--frame-panel-footer-px-base:--spacing(2)] [--frame-panel-footer-py-base:--spacing(0.5)]`,sm:`[--frame-panel-px-base:--spacing(3)] [--frame-panel-py-base:--spacing(3.5)] [--frame-panel-header-px-base:--spacing(3)] [--frame-panel-header-py-base:--spacing(1.5)] [--frame-panel-footer-px-base:--spacing(3)] [--frame-panel-footer-py-base:--spacing(1.5)]`,default:`[--frame-panel-px-base:--spacing(4)] [--frame-panel-py-base:--spacing(4)] [--frame-panel-header-px-base:--spacing(4)] [--frame-panel-header-py-base:--spacing(2)] [--frame-panel-footer-px-base:--spacing(4)] [--frame-panel-footer-py-base:--spacing(2)]`,lg:`[--frame-panel-px-base:--spacing(5)] [--frame-panel-py-base:--spacing(5)] [--frame-panel-header-px-base:--spacing(5)] [--frame-panel-header-py-base:--spacing(2.5)] [--frame-panel-footer-px-base:--spacing(5)] [--frame-panel-footer-py-base:--spacing(2.5)]`},stacked:{true:``,false:``},dense:{true:`p-0 gap-0 border-[var(--frame-border-color)] [--frame-panel-radius:var(--frame-radius)] [&_[data-slot=frame-panel]]:-mx-px [&_[data-slot=frame-panel]]:before:hidden [&_[data-slot=frame-panel]:last-child]:-mb-px [&:not(:has([data-slot=frame-panel-header]))_[data-slot=frame-panel]:is(:first-child)]:-mt-px`,false:``}},defaultVariants:{variant:`default`,spacing:`default`,stacked:!1,dense:!1}});function PH({className:e,variant:t,spacing:n,stacked:r,dense:i,...a}){return(0,U.jsx)(`div`,{className:Y(NH({variant:t,spacing:n,stacked:r,dense:i}),e),"data-slot":`frame`,"data-spacing":n,...a})}function FH({className:e,fit:t,...n}){return(0,U.jsx)(`div`,{className:Y(`relative min-w-0 [[data-slot=frame-panel-header]+&]:border-t [[data-slot=frame-panel]+&]:border-t border-(--frame-panel-border-color)`,!t&&`grow`,`px-(--frame-panel-px) py-(--frame-panel-py)`,e),"data-slot":`frame-panel`,...n})}function IH({className:e,...t}){return(0,U.jsx)(`header`,{className:Y(`flex flex-col gap-(--frame-panel-header-gap) px-(--frame-panel-header-px) py-(--frame-panel-header-py)`,e),"data-slot":`frame-panel-header`,...t})}function LH({label:e,help:t,children:n,stacked:r}){return(0,U.jsxs)(`div`,{className:r?`grid gap-1`:`grid grid-cols-[minmax(0,1fr)_minmax(0,18rem)] items-center gap-4`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 break-words`,children:[(0,U.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:e}),t?(0,U.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:t}):null]}),(0,U.jsx)(`div`,{className:`min-w-0`,children:n})]})}function RH({children:e}){return(0,U.jsx)(PH,{dense:!0,children:(0,U.jsx)(FH,{className:`flex flex-col divide-y divide-border py-0 [&>*]:py-2`,children:e})})}function zH({value:e,items:t,label:n,disabled:r,onChange:i}){let a=t.map(e=>({value:e.value,label:e.label,...e.help?{hint:e.help}:{},...e.disabled?{disabled:e.disabled}:{}}));return(0,U.jsx)(MH,{value:e,options:a,label:n,disabled:r,onChange:i})}function BH(e,t,n){let r=-1;for(let i=0;i<e.length;i+=1)t.includes(e[i])&&(r<0||Math.abs(i-n)<Math.abs(r-n))&&(r=i);return r}var VH={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},HH={off:`No extra reasoning: the quickest, cheapest answer.`,minimal:`A moment of reasoning, barely.`,low:`Light reasoning for simple work.`,medium:`Balanced reasoning for most work.`,high:`Careful reasoning: slower, better on hard problems.`,xhigh:`Very deep reasoning: slow and costly.`,max:`As deep as the model goes.`};function UH(e,t,n){let r=BH(e,t,Math.max(0,e.indexOf(n)));return e[Math.max(r,0)]??n}function WH({value:e,levels:t,supported:n,recommended:r,model:i,label:a,disabled:o,onChange:s}){let c=i??`this model`,l=UH(t,n,e),u=t.map(e=>{let t=n.includes(e),i=t?HH[e]:`Not supported by ${c}.`;return{value:e,label:VH[e]??e,help:t&&e===r?`${i} Recommended.`:i,disabled:!t}});return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(zH,{value:l,items:u,label:a,disabled:o,onChange:e=>void s(e)}),e===l?null:(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e,` is not supported by `,c,`, so it runs at `,l,`.`]})]})}var GH={type:`spring`,stiffness:520,damping:34,mass:.8};function KH({items:e,value:t,onChange:n,label:r,as:i=`radio`,size:a=`sm`,className:o,idPrefix:s}){let c=(0,m.useId)(),l=Ef()??!1,u=s??c;function d(r){let i=Math.max(0,e.findIndex(e=>e.id===t)),a=r.key===`ArrowRight`||r.key===`ArrowDown`?1:r.key===`ArrowLeft`||r.key===`ArrowUp`?-1:0,o=a?(i+a+e.length)%e.length:r.key===`Home`?0:r.key===`End`?e.length-1:-1;if(o<0)return;r.preventDefault(),r.stopPropagation();let s=e[o];n(s.id);let c=0,l=()=>{let e=document.getElementById(`${u}-${s.id}`);e&&e.tabIndex===0?e.focus():c++<20&&requestAnimationFrame(l)};requestAnimationFrame(l)}return(0,U.jsx)(`div`,{role:i===`tab`?`tablist`:i===`radio`?`radiogroup`:void 0,"aria-label":i===`nav`?void 0:r,onKeyDown:d,"data-slot":`segmented`,className:Y(`segmented relative inline-flex max-w-full min-w-0 items-center gap-0.5 overflow-x-auto rounded-[10px] p-0.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,o),children:e.map(e=>{let r=e.id===t;return(0,U.jsxs)(`button`,{id:`${u}-${e.id}`,type:`button`,"data-segment":e.id,role:i===`nav`?void 0:i,...i===`tab`?{"aria-selected":r,"aria-controls":e.controls}:i===`radio`?{"aria-checked":r}:{"aria-current":r?`page`:void 0,"aria-controls":e.controls},"aria-label":e.name,tabIndex:r||i===`nav`?0:-1,onClick:()=>n(e.id),className:Y(`relative isolate inline-flex shrink-0 items-center justify-center gap-1.5 rounded-lg px-3 font-medium whitespace-nowrap outline-none transition-colors duration-200 ease-snap focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,a===`sm`?`h-7 text-[0.8125rem]`:`h-8 text-sm`,r?`text-foreground`:`text-muted-foreground hover:text-foreground`),children:[r?(0,U.jsx)(Xf.span,{"aria-hidden":`true`,layoutId:`segment-thumb-${c}`,className:`segmented-thumb absolute inset-0 -z-10 rounded-lg`,transition:l?{duration:0}:GH}):null,e.label]},e.id)})})}var qH=`(prefers-color-scheme: dark)`,JH=[`dark`,`light`,`system`],YH=m.createContext(void 0);function XH(e){return e!==null&&JH.includes(e)}function ZH(){return window.matchMedia(qH).matches?`dark`:`light`}function QH(){let e=document.createElement(`style`);return e.appendChild(document.createTextNode(`*,*::before,*::after{-webkit-transition:none!important;transition:none!important}`)),document.head.appendChild(e),()=>{window.getComputedStyle(document.body),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.remove()})})}}function $H(e){let t=e;for(;t instanceof HTMLElement&&t.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement&&!!(t.isContentEditable||t.closest(`input, textarea, select, [contenteditable='true']`))}function eU({children:e,defaultTheme:t=`system`,storageKey:n=`theme`,disableTransitionOnChange:r=!0,...i}){let[a,o]=m.useState(()=>{let e=localStorage.getItem(n);return XH(e)?e:t}),s=m.useCallback(e=>{localStorage.setItem(n,e),o(e)},[n]),c=m.useCallback(e=>{let t=document.documentElement,n=e===`system`?ZH():e,i=r?QH():null;t.classList.remove(`light`,`dark`),t.classList.add(n),i&&i()},[r]);m.useEffect(()=>{if(c(a),a!==`system`)return;let e=window.matchMedia(qH),t=()=>{c(`system`)};return e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t)}},[a,c]),m.useEffect(()=>{let e=e=>{e.repeat||e.metaKey||e.ctrlKey||e.altKey||$H(e.target)||e.key.toLowerCase()===`d`&&o(e=>{let t=e===`dark`?`light`:e===`light`?`dark`:ZH()===`dark`?`light`:`dark`;return localStorage.setItem(n,t),t})};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[n]),m.useEffect(()=>{let e=e=>{if(e.storageArea===localStorage&&e.key===n){if(XH(e.newValue)){o(e.newValue);return}o(t)}};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}},[t,n]);let l=m.useMemo(()=>({theme:a,setTheme:s}),[a,s]);return(0,U.jsx)(YH.Provider,{...i,value:l,children:e})}var tU=()=>{let e=m.useContext(YH);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e};function nU({kind:e,dense:t=!1}){let n=e===`font`?Be:Ve,r=Xe(e),i=(0,m.useRef)(null);function a(t){let a=t.key===`ArrowRight`||t.key===`ArrowDown`?1:t.key===`ArrowLeft`||t.key===`ArrowUp`?-1:0;if(!a)return;t.preventDefault(),t.stopPropagation();let o=Math.max(0,n.findIndex(e=>e.id===r)),s=n[(o+a+n.length)%n.length];Je(e,s.id),requestAnimationFrame(()=>i.current?.querySelector(`[data-face="${s.id}"]`)?.focus())}return(0,U.jsx)(`div`,{ref:i,role:`radiogroup`,"aria-label":e===`font`?`Typeface`:`Code typeface`,onKeyDown:a,className:t?`grid grid-cols-2 gap-0.5`:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4`,children:n.map(n=>{let i=n.id===r,a=Ze[n.id];return(0,U.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":i,"data-face":n.id,tabIndex:i?0:-1,onClick:()=>Je(e,n.id),className:Y(`outline-none transition-[background-color,border-color,box-shadow] duration-150 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t?`flex min-h-8 items-center gap-2 rounded-lg px-2 text-left text-sm hover:bg-accent`:Y(`grid gap-1 rounded-xl border p-2.5 text-left`,i?`border-primary bg-accent shadow-[0_0_0_1px_var(--primary)]`:`border-[var(--glass-edge)] hover:bg-accent/50`)),children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:Y(`leading-none`,t?`w-7 text-base`:`text-2xl`),style:a?{fontFamily:a}:e===`mono`?{fontFamily:`var(--app-font-mono, ui-monospace, monospace)`}:void 0,children:e===`font`?`Aa`:`{ }`}),(0,U.jsxs)(`span`,{className:Y(`flex min-w-0 items-center justify-between gap-2`,t&&`flex-1`),children:[(0,U.jsxs)(`span`,{className:`min-w-0`,children:[(0,U.jsx)(`span`,{className:`block truncate text-[0.8125rem] font-medium`,children:n.label}),t?null:(0,U.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:n.help})]}),i?(0,U.jsx)($p,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]})]},n.id)})})}var rU=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`planner`],iU={master:`Oracle`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scout`,researcher:`Researcher`,planner:`Planner`},aU=`inherit`,oU=`inherit`,sU=`Use the session's current model`,cU=`__custom__`,lU=`custom…`,uU=`Type a provider/model id`,dU={master:`high`,designer:`medium`,backend:`medium`,qa:`medium`,scout:`low`,researcher:`low`,planner:`high`},fU=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],pU={agents:`Agents`,grants:`Tools & skills`,workflow:`Workflow`,lint:`Linting`,lobby:`Lobby`,classifier:`Classifier`,harnesses:`Harnesses`,appearance:`Appearance`,notifications:`Notifications`,install:`Install as app`},mU=new Set([`scout`,`researcher`,`planner`]),hU={label:`Compact at`,help:`Empty: built-in 64K.`,placeholder:`64000`,min:4e3,max:2e6,bad:e=>`"${e}" is not a whole number of tokens from 4000 to 2000000.`},Q={intro:`Every agent picks up the MCP tools of the servers pi has connected and the skills pi finds, including ones you add later. Narrow an agent here when it should use fewer. Children an agent delegates to get the same grants. Every change saves at once.`,agents:`Agents`,cardLabel:`tools and skills`,tools:`MCP tools`,toolsHelp:`Granted tools are the only MCP tools this agent can call, directly or from codemode.`,everyTool:`Every MCP tool pi connects`,everyToolHelp:`New servers and tools are picked up on the next run. Off: only the tools ticked below.`,everyToolReadOnlyHelp:`Every read-only tool, picked up on the next run as servers connect. Off: only the tools ticked below.`,allTools:`all MCP tools`,noToolsWarning:`This agent gets no MCP tools at all.`,readOnlyHelp:`This agent only reads, so it can call only tools their server marks read-only.`,qaHelp:`QA's tests may use any granted tool; the QA gate, which only reads, calls only the read-only ones.`,blockedHelp:`This agent only reads; the server does not mark this tool read-only.`,filter:`Filter tools`,looking:`Asking pi…`,noServers:`pi has no MCP servers connected. Add one, then reopen Settings:`,unknownServer:`other`,readOnly:`read-only`,writes:`writes`,notConnected:`not connected`,notConnectedHelp:`Granted, but its server is not connected now. It works again once the server is back.`,addLabel:`Grant a tool by its exact name`,add:`Grant`,badName:`A tool name reads mcp__server__tool, such as mcp__github__get_issue.`,noTools:`no MCP tools`,skills:`Skills`,skillsHelp:`An agent sees each granted skill's name and description, and reads its instructions when the work calls for them.`,sessionSkills:`this session's`,masterSkills:`The oracle is this pi session, so it uses the skills pi loads for it (pi's own skill settings).`,everySkill:`Every skill pi finds`,everySkillHelp:`Off: only the skills ticked below.`,allSkills:`all skills`,noSkills:`no skills`,noSkillsFound:`pi finds no skills. Put one in ~/.pi/agent/skills/ or the project's .pi/skills/ or .agents/skills/.`,notFound:`not found`,skillMissingHelp:`Granted, but pi no longer finds this skill.`,noneWarning:`This agent gets no skills at all.`,edit:`Tools & skills`},gU=[{id:`startOn`,label:`On when pi starts`,help:`off: pi starts as plain pi, and ctrl+shift+m or /bot-lobby on turns bot-lobby on (a session that owns a task under way always starts on)`}],_U={label:`Retain lobby data in git`,help:`Track this lobby's data (.pi/bot-lobby: tasks, knowledge, scripts, reports) in git. Off keeps it local and gitignored.`,error:`Couldn't read this repository's .gitignore.`},vU=[{id:`conversation`,label:`Conversation pane`},{id:`activity`,label:`Activity steps in the conversation`},{id:`thinking`,label:`Thinking bubble`}],yU=`shown on the Lobby tab`,bU=`Planning rounds`,xU=`how many rounds the panel gets before the oracle settles the rest alone`,SU=[2,3,5,8,0],CU=`Port`,wU=`the base port (then the next free up to +20); 0 means any free port; applies the next time pi starts`,TU=`Open browser`,EU=`open this page in the browser when pi starts`,DU=[{id:`off`,label:`off`,help:`tasks work in the folder you started them in`},{id:`branch`,label:`branch`,help:`each new task gets a git branch named after it, checked out in the working folder`},{id:`worktree`,label:`worktree`,help:`each new task gets its own worktree and branch, named after it: every agent runs there, apart from your checkout`}],OU=`Git isolation`,kU=[{id:`off`,label:`off`,help:`agents' work is never linted`},{id:`advise`,label:`advise`,help:`the oracle and QA are told what the project's linter finds on the lines a task changed; nothing is held`},{id:`block`,label:`block`,help:`new lint errors also hold a task's completion until they are fixed, or you accept the work as it is`}],AU={intro:`After every worker step, before QA and at completion, bot-lobby lints only the files the task's agents touched. Problems on the lines the task changed are the task's; anything already there is shown but never holds it. Suppressions and lint-config changes the task adds go to QA to judge.`,mode:`Lint gate`,command:`Command`,commandHelp:`empty runs the linters the project configures (ESLint, Biome, Oxlint, Ruff), each from its own folder; a command runs without a shell from the repository's top, with {files} standing for the touched files`,commandPlaceholder:`found from the project`,extensions:`File types`,extensionsHelp:`which touched files the command is given, such as .ts .tsx .py`,extensionsPlaceholder:`every touched file`,timeout:`Time limit`,timeoutHelp:`for one linter run; one that runs over reads as could not run, and holds nothing`,found:`Found in this project`,foundHelp:`config files in the project and the folders a few levels below it`,foundNone:`No linter config found. Add one to the project, or set a command above.`,foundReplaced:`The command replaces these.`,installed:`installed`,missing:`not installed`,missingHelp:`install the project's dependencies there, or lint cannot run`,top:`project root`},jU=[{id:`auto`,label:`Auto (OpenCode's free Jev, else TypeSafe)`},{id:`opencode`,label:`OpenCode Zen`},{id:`typesafe`,label:`TypeSafe`},{id:`openrouter`,label:`OpenRouter`},{id:`vercel`,label:`Vercel AI Gateway`}],MU=[{id:`seats`,label:`Planning seats`,help:`each round, only the seats your idea or latest answers touch sit; 1-4 in the Plan tab pins one`},{id:`answers`,label:`Obvious answers`,help:`a panel question whose recommended option the conversation already makes clearly right is answered for you (listed under Assumptions)`},{id:`lobby`,label:`Lobby replies`,help:`each lobby message goes to the agent whose area it is: a frontend question to Design, a library question to Research, "how does this work" to a scout; when it is unsure, or off, the Oracle answers. Naming an agent with @ always decides`},{id:`triage`,label:`Task triage`,help:`a new task's size, domains and research need reach the Oracle as hints`},{id:`effort`,label:`Effort routing`,help:`a simple step runs one thinking level lower, a trivial one on the cheaper model below; a routed run that falls short runs again on your settings`},{id:`qa`,label:`QA risk`,help:`once a task's work is in, the classifier reads the diff and sizes QA to it: no QA agent for a change with nothing that runs, a light check for a small one, deep review where a defect would spread; with it off the engine's rules decide`},{id:`review`,label:`Pull request read`,help:`the Git tab's quick read of a pull request: its size, and how likely it is risky, security-relevant, breaking or untested, before an agent reviews it`},{id:`knowledge`,label:`Relevant knowledge`,help:`when an agent's knowledge, standards or decisions file is too long for its prompt, the classifier picks the sections that bear on the step, and the agent is told where the rest is`},{id:`scripts`,label:`Shared scripts`,help:`the classifier matches each step to the shared scripts that do part of it, and the agent is told to run them instead of redoing the work`},{id:`files`,label:`File hints`,help:`scouts, workers, chat agents and the planning panel start with the files most likely needed, and can look more up with find_relevant_files`}],NU={enabled:`Classifier`,enabledHelp:`a fast model makes the obvious decisions so large models spend fewer tokens on them`,engine:`Answered by`,engineHelp:`pick a provider, then its model: Jev, another classifier model, or any chat model your pi logins offer (OpenAI, Anthropic, Google, …); a small, fast one works best`,provider:`Classifier provider`,engineModel:`Classifier model`,engineJev:`Jev (built in)`,engineJevHelp:`TypeSafe's classifier, on the host below`,engineClassifier:`classifier model`,engineChat:`chat model, answers as JSON`,host:`Host`,model:`Model`,modelHelp:`empty uses the host's default`,key:`API key`,keyNote:`the key pi already holds for this host; it is never read by this page`,cheap:`Cheaper model`,cheapNone:`none: trivial steps keep their model and drop a thinking level`,cheapHelp:`what effort routing runs trivial steps on`},PU={title:`Settings`,intro:`Each agent's model and effort, the workflow and its lint gate, the lobby and the classifier. Changes save as you make them.`,loading:`Loading settings…`,loadFailed:`Could not load settings.`,saved:`Settings saved`,saving:`Saving…`,appearanceHelp:`Light, dark, or follow your system. Kept in this browser only.`,themeLabel:`Mode`,themeItems:[{id:`light`,label:`Light`},{id:`dark`,label:`Dark`},{id:`system`,label:`System`}],notificationsLabel:`Browser notifications`,notificationsHelp:`While this page is hidden, tell me when a question waits, a task finishes or a background session asks something.`,notificationsBlocked:`Notifications are blocked in your browser. Allow them for this site and try again.`,notificationsUnsupported:`This browser does not offer notifications.`,notificationsOn:`Browser notifications are on.`,notificationsOff:`Browser notifications are off.`,installLabel:`Install bot-lobby`,installHelp:`Opens in its own fullscreen window, with the shell cached so it starts when Pi is not running.`,installButton:`Install as fullscreen app`,installUnavailable:`Your browser has not offered to install it. Use its menu: “Install app” (Chrome, Edge) or Share, then “Add to Home Screen” (Safari).`,installDone:`bot-lobby is installed.`,installedNow:`Running as an installed app.`,fullscreenLabel:`Fullscreen`,fullscreenHelp:`Hide the browser's own bars for this tab (F11 does the same).`,fullscreenOn:`Exit fullscreen`,fullscreenOff:`Go fullscreen`},FU=new Set([`designer`,`backend`,`qa`,`scout`,`researcher`]),$={label:`Harness`,piLabel:`pi`,piHelp:`Bot Lobby's own agent, with your pi logins`,missing:`not found`,model:`Model`,defaultModel:`Harness default`,defaultModelHelp:`Whatever the harness is set to use`,older:`older`,effortNote:`Applied when the agent offers effort levels in its session.`,agentNote:`Runs in this harness with Bot Lobby's prompts. It cannot ask you questions or use Bot Lobby's own tools (desk, board).`,intro:`Run any agent but the oracle and the planner on another coding agent. The oracle stays on pi and hands each step over: the harness gets the agent's role prompt, and its own login and models. Pick the harness per agent under Agents.`,installed:`Installed`,notFound:`Not found`,usedBy:`Used by`,unused:`No agent uses it yet`,binary:`Command`,binaryHelp:`The executable to start; empty uses the usual command on PATH.`,args:`Launch arguments`,argsHelp:`Added to every run, quoted as in a shell.`,argsAcpHelp:`The arguments that start the agent in ACP mode.`,home:`Home folder`,homeHelp:e=>`Sets ${e} for its config and login; empty keeps its own.`,provider:`Model provider`,providerHelp:`Who serves the models.`,compact:`Compact after`,compactHelp:`Tokens before it compacts an agent's context (10,000 to 2,000,000); empty keeps the harness's own. An agent with Auto-compact off never compacts.`,inject:`Inject Bot Lobby's prompts`,injectHelp:`Give it the agent's role prompt, knowledge and standards. Off sends the task and the report format only.`,custom:`Extra models`,customHelp:`Model ids it should also offer, separated by spaces.`,harnessPath:`Harness path`,harnessPathHelp:`Antigravity's localharness_external, when its ACP server does not find it itself.`},IU=`https://tweakcn.com/editor/theme`;function LU(){let{theme:e}=tU();return e===`dark`||e===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}function RU({palette:e,dark:t}){let n=ae(e,t);return(0,U.jsxs)(`span`,{"aria-hidden":`true`,className:`flex h-9 items-center gap-1.5 rounded-lg border border-border px-2`,style:{background:n.background},children:[(0,U.jsx)(`span`,{className:`size-4 rounded-full border border-black/10`,style:{background:n.card}}),(0,U.jsx)(`span`,{className:`size-4 rounded-full`,style:{background:n.primary}}),(0,U.jsx)(`span`,{className:`h-2 flex-1 rounded-full`,style:{background:n.accent}})]})}function zU(){let e=ze(),t=LU(),n=(0,m.useRef)(null);function r(t){let r=t.key===`ArrowRight`||t.key===`ArrowDown`?1:t.key===`ArrowLeft`||t.key===`ArrowUp`?-1:0;if(!r)return;t.preventDefault(),t.stopPropagation();let i=Math.max(0,e.all.findIndex(t=>t.id===e.active.id)),a=e.all[(i+r+e.all.length)%e.all.length];e.choose(a.id),window.requestAnimationFrame(()=>n.current?.querySelector(`[data-theme-id="${a.id}"]`)?.focus())}return(0,U.jsx)(`div`,{ref:n,role:`radiogroup`,"aria-label":`Colour theme`,onKeyDown:r,className:`grid grid-cols-3 gap-2 lg:grid-cols-4`,children:e.all.map(n=>{let r=n.id===e.active.id;return(0,U.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space ArrowLeft ArrowRight`,"aria-describedby":`focused-action-help`,type:`button`,role:`radio`,"aria-checked":r,"data-theme-id":n.id,tabIndex:r?0:-1,onClick:()=>e.choose(n.id),className:Y(`grid gap-1.5 rounded-lg border p-2 text-left outline-none transition-[border-color,box-shadow,background-color] duration-150 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,r?`border-primary bg-accent shadow-[0_0_0_1px_var(--primary)]`:`border-border hover:bg-accent/50`),children:[(0,U.jsx)(RU,{palette:n,dark:t}),(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center justify-between gap-2 px-0.5 text-[0.8125rem] font-medium`,children:[(0,U.jsxs)(`span`,{className:`truncate`,children:[n.name,e.isSaved(n.id)?(0,U.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:`saved`}):null]}),r?(0,U.jsx)($p,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]})]},n.id)})})}function BU({entry:e}){let t=ze(),[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(e.name),[o,s]=(0,m.useState)();async function c(){let n=i.trim();if(!n||n===e.name)return r(!1);try{await t.rename(e.id,n),r(!1),s(void 0),W.success(`Renamed to ${n}.`)}catch(e){s(e.message)}}return(0,U.jsxs)(`li`,{className:`flex min-h-10 flex-wrap items-center gap-2 py-1.5`,children:[n?(0,U.jsxs)(`form`,{className:`flex min-w-0 flex-1 items-center gap-1`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,U.jsx)(SH,{autoFocus:!0,value:i,maxLength:40,"aria-label":`New name for ${e.name}`,"aria-invalid":o?!0:void 0,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(t.preventDefault(),t.stopPropagation(),a(e.name),r(!1))},className:`h-8 max-w-64`}),(0,U.jsx)(SR,{label:`Save the name`,text:`Save`,icon:$p,tone:`primary`,type:`submit`,disabled:!i.trim()}),(0,U.jsx)(SR,{label:`Keep the old name`,icon:s_,iconOnly:!0,onClick:()=>{a(e.name),r(!1)}})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),(0,U.jsx)(SR,{label:`Rename ${e.name}`,text:`Rename`,icon:tg,onClick:()=>{a(e.name),r(!0)}}),(0,U.jsx)(eV,{label:`Remove ${e.name}`,text:`Remove`,title:`Remove ${e.name}?`,description:`It is removed for every pi session. Keep a copy of its CSS if you want to use it again.`,confirmLabel:`Remove theme`,icon:Gg,variant:`destructive`,onConfirm:()=>void t.remove(e.id).catch(e=>W.error(e.message))})]}),o?(0,U.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,children:o}):null]})}function VU(){let e=ze();return e.saved.length===0?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No saved themes yet. Import one below and give it a name.`}):(0,U.jsx)(`ul`,{"aria-label":`Saved themes`,className:`divide-y divide-border`,children:e.saved.map(e=>(0,U.jsx)(BU,{entry:e},e.id))})}function HU(){let e=ze(),[t,n]=(0,m.useState)(``),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(),[s,c]=(0,m.useState)(!1),l=(0,m.useRef)(null);async function u(t,a){let s=ee(t);if(`error`in s){o(s.error);return}o(void 0),c(!0);try{let t=await e.adopt(s,r.trim()||s.name||a);n(``),i(``);let o=s.light?s.dark?void 0:`dark`:`light`;W.success(o?`${t.name} saved and applied. It has no ${o} colours, so ${o} mode keeps the default ones.`:`${t.name} saved and applied.`)}catch(e){o(e.message)}finally{c(!1)}}async function d(e){if(e){if(e.size>2e5){o(`That file is too large to be a theme.`);return}await u(await e.text(),e.name.replace(/\.[^.]+$/,``)||`Custom theme`)}}return(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Pick or build a theme in the`,` `,(0,U.jsxs)(`a`,{href:IU,target:`_blank`,rel:`noreferrer noopener`,className:`inline-flex items-center gap-0.5 text-link underline-offset-2 hover:underline`,children:[`tweakcn editor `,(0,U.jsx)(Lm,{"aria-hidden":`true`,className:`size-3`})]}),`, press Code, copy it, and paste it here, or save it as a file and upload that. Colours and fonts are used; corners stay the page's own.`]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs text-muted-foreground`,children:[`Name`,(0,U.jsx)(SH,{value:r,maxLength:40,placeholder:`the theme's own name, or the file's`,onChange:e=>i(e.target.value),className:`h-8 max-w-80 text-foreground`})]}),(0,U.jsx)(tV,{value:t,onChange:e=>{n(e.target.value),o(void 0)},rows:4,spellCheck:!1,"aria-label":`Theme CSS from tweakcn`,"aria-invalid":a?!0:void 0,placeholder:`:root {
|
|
93
93
|
--background: oklch(0.98 0 0);
|
|
94
94
|
--primary: oklch(0.55 0.2 260);
|
|
95
95
|
…
|
|
96
96
|
}
|
|
97
|
-
.dark { … }`,className:`max-h-56 font-mono text-xs`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.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,U.jsx)(SR,{label:`Save and apply the pasted theme`,text:`Save theme`,icon:$p,tone:`primary`,disabled:!t.trim()||s,onClick:()=>void u(t,`Custom theme`)}),(0,U.jsx)(SR,{label:`Upload a .css or .json theme file`,text:`Upload file`,icon:Zg,disabled:s,onClick:()=>l.current?.click()}),a?(0,U.jsx)(`p`,{role:`alert`,className:`ml-2 min-w-0 text-xs text-destructive`,children:a}):null]})]})}function WU(){let{theme:e,setTheme:t}=nU(),n=eH();return(0,U.jsx)(aV,{prominent:!0,title:mU.appearance,children:(0,U.jsxs)(zH,{children:[(0,U.jsx)(RH,{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,U.jsx)(wH,{checked:!n,onCheckedChange:e=>QV(!e),"aria-label":`Prompt sounds`})}),(0,U.jsx)(RH,{label:FU.themeLabel,help:FU.appearanceHelp,children:(0,U.jsx)(BH,{value:e,items:FU.themeItems.map(e=>({value:e.id,label:e.label})),label:FU.themeLabel,onChange:e=>t(e)})}),(0,U.jsx)(RH,{label:`Colour theme`,help:`The page's colours, the same in every pi session.`,stacked:!0,children:(0,U.jsx)(BU,{})}),(0,U.jsx)(RH,{label:`Typeface`,help:`The face for the page's text, kept in this browser.`,stacked:!0,children:(0,U.jsx)(rU,{kind:`font`})}),(0,U.jsx)(RH,{label:`Code typeface`,help:`The face for code, paths and commands.`,stacked:!0,children:(0,U.jsx)(rU,{kind:`mono`})}),(0,U.jsx)(RH,{label:`Saved themes`,help:`Themes you imported, kept with pi for every session and project.`,stacked:!0,children:(0,U.jsx)(HU,{})}),(0,U.jsx)(RH,{label:`Import a theme`,stacked:!0,children:(0,U.jsx)(UU,{})})]})})}function GU({className:e,...t}){return(0,U.jsx)(EC,{"aria-keyshortcuts":`Space`,"aria-description":`When focused, press Space to toggle.`,"data-slot":`checkbox`,className:Y(`peer relative flex size-[1.125rem] shrink-0 items-center justify-center rounded-[.25rem] border border-input bg-background bg-clip-padding text-primary-foreground shadow-control transition-[background-color,border-color,box-shadow] duration-150 outline-none before:absolute before:-inset-3 before:content-[''] focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring disabled:cursor-not-allowed disabled:opacity-64 data-[state=checked]:shadow-none dark:bg-input/32 data-[state=checked]:border-primary data-[state=checked]:bg-primary`,e),...t,children:(0,U.jsx)(OC,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center`,children:(0,U.jsx)($p,{"aria-hidden":`true`,className:`size-3`,strokeWidth:3})})})}var KU=`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`,qU=`flex flex-col gap-1 px-2 pb-3`,JU=`px-4 pt-4 pb-1 text-xs font-medium text-muted-foreground`,YU={master:[`master`],designer:[`agents`,`designer`],backend:[`agents`,`backend`],qa:[`agents`,`qa`],scout:[`scout`],researcher:[`researcher`],planner:[`planner`]};function XU(e,t){let n=YU[t].reduce((e,t)=>e[t],e);return{...n.mcpTools?{mcpTools:n.mcpTools}:{},...n.skills?{skills:n.skills}:{}}}function ZU(e,t){return YU[e].reduceRight((e,t)=>({[t]:e}),t)}function QU(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 $U=/^mcp__[A-Za-z0-9_]+__[A-Za-z0-9_]+$/;function eW(e,t){let n=`mcp__${t}__`;return e.startsWith(n)?e.slice(n.length):e}function tW(e){return/^mcp__([A-Za-z0-9_]+?)__/.exec(e)?.[1]??``}function nW({config:e,save:t,agent:n,onAgent:r}){let i=DB(`settings.grants`,{},[]),a=i.data;return(0,U.jsxs)(aV,{prominent:!0,title:mU.grants,children:[(0,U.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:Q.intro}),(0,U.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,13rem)_minmax(0,1fr)] items-start gap-4`,children:[(0,U.jsx)(`nav`,{"aria-label":Q.agents,className:`flex flex-col gap-0.5`,children:iU.map(t=>(0,U.jsxs)(`button`,{type:`button`,"aria-current":t===n,onClick:()=>r(t),className:Y(KU,`min-h-0 gap-0.5 py-2`),children:[(0,U.jsxs)(`span`,{className:`flex items-center gap-2 text-[0.8125rem] font-medium`,children:[(0,U.jsx)(pO,{source:t,className:`size-4 shrink-0 text-muted-foreground`}),aU[t]]}),(0,U.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:QU(XU(e,t),t)})]},t))}),(0,U.jsxs)(FH,{dense:!0,"aria-label":`${aU[n]} ${Q.cardLabel}`,children:[(0,U.jsx)(aW,{kind:n,grants:XU(e,n),offered:a?.mcpTools,error:i.error,save:t},`tools-${n}`),(0,U.jsx)(oW,{kind:n,grants:XU(e,n),offered:a?.skills,error:i.error,save:t},`skills-${n}`)]})]})]})}function rW({title:e,note:t}){return(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline justify-between gap-x-3 gap-y-1`,children:[(0,U.jsx)(`h4`,{className:`text-sm font-semibold`,children:e}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t})]})}function iW({id:e,name:t,help:n,tag:r,tagTone:i,checked:a,disabled:o,title:s,onChange:c}){return(0,U.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,U.jsx)(GU,{id:e,checked:a,disabled:o,onCheckedChange:e=>c(e===!0),className:`mt-0.5`}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,U.jsx)(`span`,{className:`break-all font-mono text-[0.8125rem]`,children:t}),n?(0,U.jsx)(`span`,{className:`break-words text-xs text-muted-foreground`,children:n}):null]}),r?(0,U.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 aW({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=hU.has(e),p=t=>i(ZU(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:tW(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(!$U.test(e)){W.error(Q.badName);return}c(``),d.has(e)||p([...u,e])};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(LH,{className:`gap-1 border-b border-(--frame-panel-border-color) py-2.5`,children:[(0,U.jsx)(rW,{title:Q.tools,note:l?Q.allTools:`${u.length} granted`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f?Q.readOnlyHelp:e===`qa`?Q.qaHelp:Q.toolsHelp})]}),(0,U.jsxs)(IH,{fit:!0,className:`flex flex-col gap-3 py-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-4 px-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:Q.everyTool}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f?Q.everyToolReadOnlyHelp:Q.everyToolHelp})]}),(0,U.jsx)(wH,{checked:l,onCheckedChange:S,"aria-label":`${aU[e]} ${Q.everyTool.toLowerCase()}`})]}),(n?.length??0)>8?(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(Cg,{"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,U.jsx)(CH,{value:a,placeholder:Q.filter,"aria-label":Q.filter,className:`pl-8`,onChange:e=>o(e.target.value)})]}):null,!n&&!r?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Q.looking}):null,r&&!n?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r}):null,n&&n.length===0&&_.length===0?(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[Q.noServers,` `,(0,U.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,U.jsxs)(`div`,{role:`group`,"aria-label":`${t} tools`,className:Y(`flex flex-col gap-0.5`,l&&`opacity-60`),children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1 text-xs font-medium text-muted-foreground`,children:[(0,U.jsx)(GU,{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,U.jsx)(`span`,{className:`font-mono`,children:t||Q.unknownServer}),(0,U.jsxs)(`span`,{children:[i,` of `,n.length]})]}),n.map(t=>{let n=g.has(t.name),r=!x(t);return(0,U.jsx)(iW,{id:`grant-${e}-${t.name}`,name:eW(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,U.jsxs)(`p`,{className:`flex items-center gap-1.5 px-2 text-xs text-warning`,children:[(0,U.jsx)(lm,{"aria-hidden":`true`,className:`size-3.5`}),Q.noToolsWarning]}):null,(0,U.jsxs)(`div`,{hidden:l,className:`flex min-w-0 items-center gap-2 border-t border-(--frame-panel-border-color) pt-3`,children:[(0,U.jsx)(CH,{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,U.jsx)(SR,{label:Q.add,icon:sg,onClick:C})]})]})]})}function oW({kind:e,grants:t,offered:n,error:r,save:i}){if(e===`master`)return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(LH,{className:`gap-1 border-y border-(--frame-panel-border-color) py-2.5`,children:(0,U.jsx)(rW,{title:Q.skills,note:Q.sessionSkills})}),(0,U.jsx)(IH,{fit:!0,className:`py-3`,children:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Q.masterSkills})})]});let a=!t.skills,o=new Set(t.skills??[]),s=t=>i(ZU(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,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(LH,{className:`gap-1 border-y border-(--frame-panel-border-color) py-2.5`,children:[(0,U.jsx)(rW,{title:Q.skills,note:a?Q.allSkills:`${o.size} granted`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Q.skillsHelp})]}),(0,U.jsxs)(IH,{fit:!0,className:`flex flex-col gap-3 py-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-4 px-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:Q.everySkill}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Q.everySkillHelp})]}),(0,U.jsx)(wH,{checked:a,onCheckedChange:e=>void s(e?null:(n??[]).map(e=>e.name)),"aria-label":`${aU[e]} ${Q.everySkill.toLowerCase()}`})]}),!n&&!r?(0,U.jsx)(`p`,{className:`px-2 text-sm text-muted-foreground`,children:Q.looking}):null,r&&!n?(0,U.jsx)(`p`,{className:`px-2 text-sm text-muted-foreground`,children:r}):null,n&&n.length===0&&l.length===0?(0,U.jsx)(`p`,{className:`px-2 text-sm text-muted-foreground`,children:Q.noSkillsFound}):null,(0,U.jsxs)(`div`,{role:`group`,"aria-label":`${aU[e]} skills`,className:Y(`flex flex-col gap-0.5`,a&&`opacity-60`),children:[(n??[]).map(t=>(0,U.jsx)(iW,{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,U.jsx)(iW,{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,U.jsxs)(`p`,{className:`flex items-center gap-1.5 px-2 text-xs text-warning`,children:[(0,U.jsx)(lm,{"aria-hidden":`true`,className:`size-3.5`}),Q.noneWarning]}):null]})]})}function sW(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&&IU.has(e)&&(n[r.harness]??=[]).push(e);return n}function cW({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,U.jsx)(CH,{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 lW({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){W.error(`"${i}" is not between 10,000 and 2,000,000 tokens.`),a(r);return}n(Math.round(t))};return(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(CH,{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,U.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 uW({status:e}){let t=!!e.path;return(0,U.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,U.jsx)(dm,{"aria-hidden":`true`,className:`size-3.5`}):(0,U.jsx)(lm,{"aria-hidden":`true`,className:`size-3.5`}),t?`${$.installed}${e.version?` · ${e.version}`:``}`:$.notFound]})}function dW({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,U.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,U.jsxs)(`header`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,U.jsx)(`h3`,{className:`min-w-0 break-words text-sm font-semibold`,children:e.label}),(0,U.jsx)(uW,{status:e})]}),(0,U.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:e.blurb}),(0,U.jsxs)(`p`,{className:`break-words text-xs`,children:[(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[$.usedBy,`: `]}),n.length>0?n.map(e=>aU[e]).join(`, `):(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:$.unused.toLowerCase()})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col divide-y divide-border border-t border-border [&>*]:py-2.5 [&>*:last-child]:pb-0`,children:[(0,U.jsx)(RH,{stacked:!0,label:$.binary,help:$.binaryHelp,children:(0,U.jsx)(cW,{value:a.binaryPath,label:`${e.label} ${$.binary.toLowerCase()}`,placeholder:e.command||`/path/to/agent`,onSave:e=>o({binaryPath:e})})}),(0,U.jsx)(RH,{stacked:!0,label:$.args,help:i===`acp`?$.argsAcpHelp:$.argsHelp,children:(0,U.jsx)(cW,{value:a.launchArgs,label:`${e.label} ${$.args.toLowerCase()}`,placeholder:i===`acp`?`--acp`:`none`,onSave:e=>o({launchArgs:e})})}),c?(0,U.jsx)(RH,{stacked:!0,label:$.home,help:$.homeHelp(c),children:(0,U.jsx)(cW,{value:a.homePath,label:`${e.label} ${$.home.toLowerCase()}`,placeholder:i===`codex`?`~/.codex`:`~/.claude`,onSave:e=>o({homePath:e})})}):null,l.length>0?(0,U.jsx)(RH,{stacked:!0,label:$.provider,help:$.providerHelp,children:(0,U.jsx)(BH,{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,U.jsx)(RH,{stacked:!0,label:$.compact,help:$.compactHelp,children:(0,U.jsx)(lW,{value:a.compactAt,label:`${e.label} ${$.compact.toLowerCase()}`,onSave:e=>o({compactAt:e})})}),i===`antigravity`?(0,U.jsx)(RH,{stacked:!0,label:$.harnessPath,help:$.harnessPathHelp,children:(0,U.jsx)(cW,{value:a.harnessPath,label:`${e.label} ${$.harnessPath.toLowerCase()}`,placeholder:`localharness_external`,onSave:e=>o({harnessPath:e})})}):null,(0,U.jsx)(RH,{stacked:!0,label:$.custom,help:$.customHelp,children:(0,U.jsx)(cW,{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,U.jsxs)(`div`,{className:`flex min-h-0 items-center justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:$.inject}),(0,U.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:$.injectHelp})]}),(0,U.jsx)(wH,{checked:a.injectPrompts,onCheckedChange:e=>o({injectPrompts:e}),"aria-label":`${e.label}: ${$.inject}`})]})]})]})}function fW({config:e,statuses:t,error:n,save:r}){let i=sW(e);return(0,U.jsxs)(aV,{prominent:!0,title:mU.harnesses,children:[(0,U.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:$.intro}),t?(0,U.jsx)(`div`,{className:`grid grid-cols-2 items-start gap-3 xl:grid-cols-3`,children:t.map(t=>(0,U.jsx)(dW,{status:t,config:e,users:i[t.id]??[],save:r},t.id))}):(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n??`Looking for installed harnesses…`})]})}var pW={master:[`master`],designer:[`agents`,`designer`],backend:[`agents`,`backend`],qa:[`agents`,`qa`],scout:[`scout`],researcher:[`researcher`],planner:[`planner`]},mW=[..._U,...yU.map(e=>({id:`panel:${e.id}`,label:e.label,help:bU}))];function hW(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 gW(e,t){return pW[e].reduceRight((e,t)=>({[t]:e}),t)}function _W(e,t){return e.find(e=>e.id===t)?.thinkingLevels??pU}function vW(e,t){return pU[VH(pU,e,Math.max(0,pU.indexOf(t)))]??t}var yW=e=>e>0?`${e} round${e===1?``:`s`}`:`unlimited`;function bW(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:oU,label:sU,help:cU}]:[],...e.none?[{value:oU,label:`none`,help:`Use the primary model`}]:[],...!e.inherit&&!e.none&&e.value===`inherit`?[{value:oU,label:sU,help:cU}]:[],...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:dU}]:[],{value:lU,label:uU,help:dU}],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,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(BH,{value:e.value,items:o,label:e.label,onChange:s}),t?(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,U.jsx)(CH,{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,U.jsx)(SR,{label:`Use this model`,icon:$p,tone:`primary`,onClick:c})]}):null]})}function xW({label:e,help:t,checked:n,onChange:r,name:i}){return(0,U.jsxs)(`div`,{className:`flex min-h-0 items-center justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:e}),t?(0,U.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:t}):null]}),(0,U.jsx)(wH,{checked:n,onCheckedChange:r,"aria-label":i??e})]})}function SW({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,U.jsx)(CH,{value:i,placeholder:n,"aria-label":r,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())}})}function CW({value:e,label:t,onSave:n}){let r=Math.round(e/6e4);return(0,U.jsx)(EW,{label:t,value:String(r),min:1,suffix:`min`,onSave:e=>{let t=Number(e);return!Number.isFinite(t)||t<=0?(W.error(`"${e}" is not a positive number of minutes.`),!1):(n(Math.round(t*6e4)),!0)}})}function wW({value:e,label:t,onSave:n}){return(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-4 gap-y-1.5`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:gU.label}),(0,U.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:gU.help})]}),(0,U.jsx)(`div`,{className:`w-36 shrink-0`,children:(0,U.jsx)(EW,{label:t,value:e?String(e):``,min:gU.min,max:gU.max,step:1e3,placeholder:gU.placeholder,suffix:`tokens`,onSave:e=>{if(e===``)return n(null),!0;let t=Number(e);return!Number.isInteger(t)||t<gU.min||t>gU.max?(W.error(gU.bad(e)),!1):(n(t),!0)}})})]})}function TW({value:e,onSave:t}){return(0,U.jsx)(EW,{label:wU,value:String(e),min:0,max:65535,onSave:e=>!/^\d+$/.test(e)||Number(e)>65535?(W.error(`"${e}" is not a port (0, or 1-65535).`),!1):(t(Number(e)),!0)})}function EW({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,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(CH,{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,U.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 DW({value:e,label:t,onSave:n}){let[r,i]=(0,m.useState)(e);return(0,m.useEffect)(()=>i(e),[e]),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(nV,{rows:2,value:r,"aria-label":t,onChange:e=>i(e.target.value),onBlur:()=>{r.trim()!==e&&n(r.trim())}}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Saved when you leave the field.`})]})}function OW({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,U.jsx)(BH,{value:e,items:i,label:n,onChange:r})}function kW({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?dU:e.current?e.id:`${e.id} · ${$.older}`})),...c?[]:[{value:e,label:e,help:dU}],{value:lU,label:uU,help:dU}],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,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(BH,{value:e,items:l,label:n,onChange:u}),i?(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,U.jsx)(CH,{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,U.jsx)(SR,{label:`Use this model`,icon:$p,tone:`primary`,onClick:d})]}):null]})}function AW(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 pU;let r=e?.models.find(e=>e.efforts.length>0)?.efforts;return r&&r.length>0?r:pU}function jW({kind:e,config:t,models:n,harnesses:r,save:i,onGrants:a}){let o=hW(t,e),s=t=>i(gW(e,t)),c=aU[e],l=o.harness?r.find(e=>e.id===o.harness):void 0,u=!!o.harness,d=o.harnessModel??``,f=u?AW(l,d):_W(n,o.model),p=t=>{if(t===(o.harness??`pi`))return;if(t===`pi`)return void s({harness:`pi`});let n=AW(r.find(e=>e.id===t),``),i={harness:t,harnessModel:``};e!==`scout`&&!n.includes(o.thinking)&&(i.thinking=vW(n,o.thinking)),s(i)},h=t=>{let n=AW(l,t),r={harnessModel:t};e!==`scout`&&!n.includes(o.thinking)&&(r.thinking=vW(n,o.thinking)),s(r)},g=t=>{let r={model:t};e!==`scout`&&!_W(n,t).includes(o.thinking)&&(r.thinking=vW(_W(n,t),o.thinking)),s(r)},_=e!==`scout`&&e!==`researcher`,[v,y]=(0,m.useState)(!1),b=MW(o,e);return(0,U.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,U.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,U.jsxs)(`h3`,{className:`flex min-w-0 items-center gap-2 break-words text-sm font-semibold`,children:[(0,U.jsx)(pO,{source:e,className:`size-4 shrink-0 text-muted-foreground`}),c]}),(0,U.jsx)(PW,{open:v,custom:b,onToggle:()=>y(e=>!e)})]}),IU.has(e)?(0,U.jsx)(OW,{value:o.harness??`pi`,statuses:r,label:`${c} ${$.label.toLowerCase()}`,onChange:p}):null,u?(0,U.jsx)(kW,{value:d,models:l?.models??[],label:`${c} model`,onChange:h}):(0,U.jsx)(bW,{value:o.model,models:n,label:`${c} model`,inherit:e===`master`,onChange:g}),e===`scout`?(0,U.jsx)(NW,{}):(0,U.jsx)(GH,{value:o.thinking,levels:pU,supported:f,recommended:fU[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,U.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:$.effortNote}):null,(0,U.jsx)(xW,{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,U.jsx)(wW,{value:o.compactAt,label:`${c} compact at`,onSave:e=>s({compactAt:e})}):null,(0,U.jsxs)(`div`,{hidden:!v,className:`grid gap-2 border-t border-border pt-2`,children:[u?(0,U.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:$.agentNote}):null,_?(0,U.jsx)(DW,{value:o.instructions??``,label:`${c} instructions`,onSave:e=>s({instructions:e})}):null,(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,U.jsx)(`p`,{className:`min-w-[7rem] flex-1 break-words text-xs text-muted-foreground`,children:QU(XU(t,e),e)}),(0,U.jsx)(SR,{label:Q.edit,icon:a_,onClick:a})]})]})]})}function MW(e,t){return[t!==`scout`&&t!==`researcher`&&!!e.instructions,e.mcpTools!==void 0,t!==`master`&&e.skills!==void 0].filter(Boolean).length}function NW(){return(0,U.jsxs)(`p`,{className:`flex min-h-[4.5rem] items-center gap-2 text-sm text-muted-foreground`,children:[(0,U.jsx)(Zp,{"aria-hidden":`true`,className:`size-4`}),`Effort `,(0,U.jsx)(`span`,{className:`capitalize`,children:`low`}),` (fixed for scouts)`]})}function PW({open:e,custom:t,onToggle:n}){return(0,U.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,U.jsx)(am,{"aria-hidden":`true`,className:Y(`size-3.5 transition-transform duration-200 ease-snap`,e&&`rotate-90`)}),`More`,t>0?(0,U.jsxs)(`span`,{className:`text-primary`,children:[`· `,t,` customised`]}):null]})}function FW(e,t){return t.startsWith(`panel:`)?e.lobby.panels[t.slice(6)]:e.lobby[t]}function IW({config:e,item:t,save:n}){let r=t.id.startsWith(`panel:`);return(0,U.jsx)(xW,{label:t.label,help:t.help,checked:FW(e,t.id),onChange:e=>{n(r?{lobby:{panels:{[t.id.slice(6)]:e}}}:{lobby:{[t.id]:e}})}})}function LW({config:e,save:t}){let n=e.workflow.gitIsolation;return(0,U.jsx)(aV,{prominent:!0,title:mU.workflow,children:(0,U.jsx)(zH,{children:(0,U.jsx)(RH,{label:kU,help:OU.find(e=>e.id===n)?.help??`enter cycles off, branch, worktree`,children:(0,U.jsx)(BH,{value:n,items:OU.map(e=>({value:e.id,label:e.label})),label:kU,onChange:e=>void t({workflow:{gitIsolation:e}})})})})})}var RW=e=>e?`${e}/`:jU.top;function zW(e){return e.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function BW({replaced:e}){let t=DB(`settings.linters`,{},[]),n=t.data?.linters;return(0,U.jsx)(RH,{label:jU.found,help:e?jU.foundReplaced:jU.foundHelp,children:n?n.length===0?(0,U.jsx)(`p`,{className:`break-words text-sm text-muted-foreground text-right`,children:jU.foundNone}):(0,U.jsx)(`ul`,{"aria-label":jU.found,className:Y(`flex flex-col items-end gap-1.5`,e&&`opacity-60`),children:n.map(e=>(0,U.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm`,children:[(0,U.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.tool}),(0,U.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:RW(e.folder)}),(0,U.jsxs)(`span`,{title:e.installed?void 0:jU.missingHelp,className:Y(`inline-flex shrink-0 items-center gap-1 text-xs`,e.installed?`text-success`:`text-warning`),children:[e.installed?(0,U.jsx)(dm,{"aria-hidden":`true`,className:`size-3.5`}):(0,U.jsx)(lm,{"aria-hidden":`true`,className:`size-3.5`}),e.installed?jU.installed:jU.missing]})]},`${e.tool}:${e.folder}`))}):(0,U.jsx)(`p`,{className:`break-words text-sm text-muted-foreground text-right`,children:t.error?t.error:`Looking…`})})}function VW({config:e,save:t}){let n=e.lint,r=n.mode===`off`,i=n.command.trim().length>0;return(0,U.jsxs)(aV,{prominent:!0,title:mU.lint,children:[(0,U.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:jU.intro}),(0,U.jsxs)(zH,{children:[(0,U.jsx)(RH,{label:jU.mode,help:AU.find(e=>e.id===n.mode)?.help,children:(0,U.jsx)(BH,{value:n.mode,items:AU.map(e=>({value:e.id,label:e.label})),label:jU.mode,onChange:e=>void t({lint:{mode:e}})})}),(0,U.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,U.jsx)(RH,{label:jU.command,help:jU.commandHelp,children:(0,U.jsx)(SW,{value:n.command,label:jU.command,placeholder:jU.commandPlaceholder,onSave:e=>void t({lint:{command:e}})})}),i?(0,U.jsx)(RH,{label:jU.extensions,help:jU.extensionsHelp,children:(0,U.jsx)(SW,{value:n.extensions.join(` `),label:jU.extensions,placeholder:jU.extensionsPlaceholder,onSave:e=>void t({lint:{extensions:zW(e)}})})}):null,(0,U.jsx)(RH,{label:jU.timeout,help:jU.timeoutHelp,children:(0,U.jsx)(CW,{value:n.timeoutMs,label:`Lint ${jU.timeout.toLowerCase()}`,onSave:e=>void t({lint:{timeoutMs:e}})})}),(0,U.jsx)(BW,{replaced:i})]})]})]})}function HW({config:e,save:t}){let n=e.lobby.web;return(0,U.jsx)(aV,{prominent:!0,title:mU.lobby,children:(0,U.jsxs)(zH,{children:[mW.map(n=>(0,U.jsx)(IW,{config:e,item:n,save:t},n.id)),(0,U.jsx)(RH,{label:xU,help:SU,children:(0,U.jsx)(BH,{value:String(e.lobby.maxPlanningRounds),items:CU.map(e=>({value:String(e),label:yW(e)})),label:xU,onChange:e=>void t({lobby:{maxPlanningRounds:Number(e)}})})}),(0,U.jsx)(RH,{label:wU,help:TU,children:(0,U.jsx)(TW,{value:n.port,onSave:e=>void t({lobby:{web:{port:e}}})})}),(0,U.jsx)(xW,{label:EU,help:DU,checked:n.openBrowser,onChange:e=>void t({lobby:{web:{openBrowser:e}}})}),(0,U.jsx)(UW,{})]})})}function UW(){let e=DB(`lobby.retention`,{},[]),t=async t=>{try{await R(`lobby.setRetention`,{enabled:t}),e.reload()}catch(e){W.error(e instanceof Error?e.message:`That did not work. Try again.`)}};return(0,U.jsx)(xW,{label:vU.label,help:e.error?vU.error:vU.help,checked:e.data?.enabled??!1,onChange:e=>void t(e)})}function WW(e){let t=e.indexOf(`/`);return t>0?e.slice(0,t):``}function GW(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 KW({value:e,models:t,classifiers:n,onChange:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),c=GW(t,n),l=WW(e),[u,d]=(0,m.useState)(l),f=e?l:u,p=[...new Set([...c.map(e=>WW(e.id)),...l?[l]:[]])].filter(Boolean).sort(),h=[{value:qW,label:PU.engineJev,help:PU.engineJevHelp},...p.map(e=>{let t=c.filter(t=>WW(t.id)===e),n=t.filter(e=>e.kind===`classifier`).length,r=t.length-n,i=[n?`${n} ${PU.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=>WW(e.id)===f),_=[...g.map(e=>({value:e.id,label:e.id.slice(f.length+1),help:`${e.kind===`classifier`?PU.engineClassifier:PU.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:dU}]:[],{value:lU,label:uU,help:dU}],v=e=>{if(a(!1),e===qW)return d(``),r(``);d(e);let t=c.find(t=>WW(t.id)===e&&t.kind===`classifier`)??c.find(t=>WW(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,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(BH,{value:f||qW,items:h,label:PU.provider,onChange:v}),f?(0,U.jsx)(BH,{value:e||`__custom__`,items:_,label:PU.engineModel,onChange:y}):null,i?(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,U.jsx)(CH,{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,U.jsx)(SR,{label:`Use this model`,icon:$p,tone:`primary`,onClick:b})]}):null]})}var qW=`__jev__`;function JW({config:e,models:t,classifiers:n,save:r}){let i=e.classifier,a=MU.find(e=>e.id===i.provider)?.label,o=!i.engine;return(0,U.jsx)(aV,{prominent:!0,title:mU.classifier,children:(0,U.jsxs)(zH,{children:[(0,U.jsx)(xW,{label:PU.enabled,help:PU.enabledHelp,checked:i.enabled,onChange:e=>void r({classifier:{enabled:e}})}),(0,U.jsx)(RH,{label:PU.engine,help:PU.engineHelp,children:(0,U.jsx)(KW,{value:i.engine,models:t,classifiers:n,onChange:e=>void r({classifier:{engine:e}})})}),o?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(RH,{label:PU.host,children:(0,U.jsx)(BH,{value:i.provider,items:MU.map(e=>({value:e.id,label:e.label})),label:PU.host,onChange:e=>void r({classifier:{provider:e}})})}),(0,U.jsx)(RH,{label:PU.model,help:PU.modelHelp,children:(0,U.jsx)(SW,{value:i.model,label:PU.model,placeholder:`the host's default`,onSave:e=>void r({classifier:{model:e}})})}),(0,U.jsx)(RH,{label:PU.key,help:PU.keyNote,children:(0,U.jsx)(`p`,{className:`break-words text-sm text-muted-foreground text-right`,children:a??i.provider})})]}):null,NU.map(e=>(0,U.jsx)(xW,{label:e.label,help:e.help,checked:i.features[e.id],onChange:t=>void r({classifier:{features:{[e.id]:t}}})},e.id)),(0,U.jsx)(RH,{label:PU.cheap,help:PU.cheapHelp,children:(0,U.jsx)(bW,{value:i.effort.cheapModel,models:t,label:PU.cheap,none:!0,onChange:e=>void r({classifier:{effort:{cheapModel:e}}})})})]})})}function YW(){let e=uH(),t=async e=>{if(!e)return fH();let t=await dH();t===`granted`?W.success(FU.notificationsOn):W.error(t===`unsupported`?FU.notificationsUnsupported:FU.notificationsBlocked)};return(0,U.jsx)(aV,{prominent:!0,title:mU.notifications,children:(0,U.jsx)(zH,{children:(0,U.jsx)(xW,{label:FU.notificationsLabel,help:FU.notificationsHelp,checked:e,onChange:e=>void t(e)})})})}function XW(){let{available:e,install:t}=y(),n=b(),r=x();return(0,U.jsx)(aV,{prominent:!0,title:mU.install,children:(0,U.jsxs)(zH,{children:[(0,U.jsx)(RH,{label:FU.installLabel,help:n?FU.installedNow:FU.installHelp,children:n?null:(0,U.jsx)(`div`,{className:`flex justify-end`,children:(0,U.jsx)(SR,{label:FU.installButton,icon:Fm,tone:`primary`,onClick:()=>e?void t().then(()=>W.success(FU.installDone)):W.warning(FU.installUnavailable)})})}),r.supported?(0,U.jsx)(RH,{label:FU.fullscreenLabel,help:FU.fullscreenHelp,children:(0,U.jsx)(`div`,{className:`flex justify-end`,children:(0,U.jsx)(SR,{label:r.on?FU.fullscreenOn:FU.fullscreenOff,icon:r.on?Lh:Th,pressed:r.on,onClick:()=>void r.toggle()})})}):null]})})}var ZW=[`Agents`,`Harnesses`,`Tools & skills`,`Workflow`,`Lobby`,`Classifier`,`Appearance & notifications`],QW=e=>`settings-${e.split(` `)[0]}`;function $W({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=DB(`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 R(`settings.set`,{patch:e})).config),W.success(FU.saved),!0}catch(e){return W.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,U.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-4 px-6 pt-6 pb-dock`,children:[(0,U.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-x-6 gap-y-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:FU.title}),(0,U.jsx)(`p`,{className:`max-w-xl text-xs text-muted-foreground`,children:FU.intro})]}),(0,U.jsx)(`nav`,{"aria-label":`Settings sections`,className:`min-w-0 max-w-full`,children:(0,U.jsx)(qH,{as:`nav`,label:`Settings sections`,items:ZW.map(e=>({id:e,label:e,controls:QW(e)})),value:i,onChange:a})})]}),(0,U.jsxs)(`div`,{id:QW(`Agents`),hidden:i!==`Agents`,"aria-hidden":i!==`Agents`,children:[(0,U.jsx)(`h2`,{className:`sr-only`,children:mU.agents}),(0,U.jsx)(`div`,{className:`grid grid-cols-2 items-start gap-3 lg:grid-cols-3`,children:iU.map(n=>(0,U.jsx)(jW,{kind:n,config:e,models:t,harnesses:p,save:g,onGrants:()=>c(n)},n))})]}),(0,U.jsx)(`div`,{id:QW(`Harnesses`),hidden:i!==`Harnesses`,"aria-hidden":i!==`Harnesses`,children:(0,U.jsx)(fW,{config:e,statuses:l.data?.harnesses,...l.error?{error:l.error}:{},save:g})}),(0,U.jsx)(`div`,{id:QW(`Tools & skills`),hidden:i!==`Tools & skills`,"aria-hidden":i!==`Tools & skills`,children:(0,U.jsx)(nW,{config:e,save:g,agent:o,onAgent:s})}),(0,U.jsx)(`div`,{id:QW(`Workflow`),hidden:i!==`Workflow`,"aria-hidden":i!==`Workflow`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,U.jsx)(LW,{config:e,save:g}),(0,U.jsx)(VW,{config:e,save:g})]})}),(0,U.jsx)(`div`,{id:QW(`Lobby`),hidden:i!==`Lobby`,"aria-hidden":i!==`Lobby`,children:(0,U.jsx)(HW,{config:e,save:g})}),(0,U.jsx)(`div`,{id:QW(`Classifier`),hidden:i!==`Classifier`,"aria-hidden":i!==`Classifier`,children:(0,U.jsx)(JW,{config:e,models:t,classifiers:n,save:g})}),(0,U.jsx)(`div`,{id:QW(`Appearance & notifications`),hidden:i!==`Appearance & notifications`,"aria-hidden":i!==`Appearance & notifications`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,U.jsx)(WU,{}),(0,U.jsx)(YW,{}),(0,U.jsx)(XW,{})]})})]})}function eG(){return(0,U.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":FU.loading,children:[0,1,2,3].map(e=>(0,U.jsx)(LB,{shape:`card`,className:`h-48`},e))})}function tG(){let e=DB(`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,U.jsx)(TB,{message:`${FU.loadFailed} ${e.error}`,onRetry:e.reload}):t?(0,U.jsx)($W,{config:t,models:e.data?.models??[],classifierModels:e.data?.classifierModels??[],onConfig:i}):(0,U.jsx)(eG,{})}function nG(){let e=globalThis.DOMParser;if(!e)throw Error(`DOMParser is unavailable`);return new e}var rG=`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'`,iG=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(` `)),aG=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(` `)),oG=new Set(`text search email tel url number password checkbox radio range color date time month week button reset submit`.split(` `)),sG=`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 cG(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 lG(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 uG(e){if(!iG.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`,lG(t.value)):aG.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&&!oG.has(t)&&e.setAttribute(`type`,`text`)}e.localName===`style`&&(e.textContent=lG(e.textContent??``));for(let t of[...e.children])uG(t)}function dG(e,t){try{return fG(e,t??nG())}catch{return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${rG}"><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 fG(e,t){let n=t.parseFromString(e.html,`text/html`);for(let e of[...n.head.children,...n.body.children])uG(e);let r=[...n.head.querySelectorAll(`style`)].map(e=>e.outerHTML).join(``);return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${rG}"><meta name="referrer" content="no-referrer"><style>body{margin:16px;overflow-wrap:anywhere}*{box-sizing:border-box}${sG}${lG(e.css??``).replace(/</g,`\\3c `)}</style>${r}</head><body>${n.body.innerHTML}</body></html>`}function pG({preview:e,label:t,className:n,frameWidth:r,minWidth:i,onOpen:a}){let o=(0,m.useMemo)(()=>dG(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,U.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,U.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,U.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,U.jsx)(`button`,{type:`button`,"data-compact":``,onClick:a,"aria-label":`Expand the mockup: ${t}`,className:`group/open absolute right-2 bottom-2 rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border bg-card/90 px-1.5 py-0.5 text-[0.6875rem] font-medium text-muted-foreground opacity-60 shadow-sm backdrop-blur-sm transition-opacity group-hover/mock:opacity-100 group-focus-visible/open:opacity-100`,children:[(0,U.jsx)(Ch,{"aria-hidden":`true`,className:`size-3`}),`Expand`]})}):null]})}var mG=/\s*\(recommended\)\s*$/i,hG=1024,gG=e=>e.replace(mG,``);function _G(e){return!!(e&&(e.htmlPreview||e.image||e.preview))}function vG({option:e}){let t=gG(e.label);return _G(e)?(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3`,children:[e.htmlPreview?(0,U.jsx)(pG,{preview:e.htmlPreview,label:t,minWidth:hG,className:`h-auto min-h-[18rem] flex-1`}):null,e.image?(0,U.jsx)(`img`,{src:I(e.image),alt:`Mockup: ${t}`,className:`min-h-0 w-full flex-1 rounded-lg border bg-background object-contain`}):null,e.preview?(0,U.jsx)(Mz,{text:e.preview,className:Y(`overflow-auto rounded-lg border bg-background p-4 text-sm`,!e.htmlPreview&&!e.image&&`flex-1`)}):null]}):(0,U.jsx)(`p`,{className:`grid h-full place-items-center p-6 text-sm text-muted-foreground`,children:`No mockup for this option.`})}function yG({options:e,start:t,title:n,picked:r=[],multi:i=!1,onChoose:a,onClose:o,onIndex:s}){let c=Ef(),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,U.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,U.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border px-4 py-3`,children:[(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Back to the question`,title:`Back · Esc`,onClick:()=>o(d),children:(0,U.jsx)(Fh,{"aria-hidden":`true`})}),(0,U.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:n}),(0,U.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,"aria-live":`polite`,children:[d+1,` of `,e.length]}),(0,U.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,U.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,U.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:t+1}),(0,U.jsx)(`span`,{className:`truncate`,children:gG(e.label)}),r.includes(t)?(0,U.jsx)($p,{"aria-label":`picked`,className:`size-3 text-primary`}):null]},t))})]}),(0,U.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,U.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,U.jsxs)(`section`,{id:`mockup-slide-${n}`,role:`tabpanel`,"aria-roledescription":`slide`,"aria-label":`${n+1} of ${e.length}: ${gG(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,U.jsxs)(`div`,{className:`flex items-baseline gap-2 text-sm`,children:[(0,U.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[n+1,`.`]}),(0,U.jsx)(`span`,{className:`font-medium`,children:gG(t.label)}),mG.test(t.label)?(0,U.jsx)(`span`,{className:`text-xs font-medium text-primary`,children:`Recommended`}):null,r.includes(n)?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-primary`,children:[(0,U.jsx)($p,{"aria-hidden":`true`,className:`size-3`}),`picked`]}):null]}),t.description?(0,U.jsx)(Mz,{text:t.description,className:`text-sm text-muted-foreground`}):null,(0,U.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,U.jsx)(vG,{option:t})})]},n))}),d>0?(0,U.jsx)(X,{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,U.jsx)(rm,{"aria-hidden":`true`})}):null,d<h?(0,U.jsx)(X,{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,U.jsx)(am,{"aria-hidden":`true`})}):null]}),(0,U.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,U.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,U.jsx)(KD,{chord:`←→`,children:`option`}),a?(0,U.jsx)(KD,{chord:`Enter`,children:i?y?`unpick`:`pick`:`choose`}):null,(0,U.jsx)(KD,{chord:`Esc`,children:`back`})]}),a&&p?(0,U.jsxs)(X,{type:`button`,onClick:()=>a(d),className:`max-w-full`,children:[i&&y?`Unpick`:i?`Pick`:`Choose`,(0,U.jsx)(`span`,{className:`truncate`,children:gG(p.label)})]}):null]})]})}function bG(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 xG({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,U.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,onKeyDown:e=>bG(e,()=>void d(),()=>{o||r()}),children:[(0,U.jsxs)(`label`,{className:`text-sm`,children:[`Edit message`,(0,U.jsx)(nV,{ref:u,value:i,onChange:e=>a(e.target.value),disabled:o,className:`mt-2 max-h-[40vh] min-h-24`})]}),c?(0,U.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not save. `,c]}):null,(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsx)(X,{size:`sm`,onClick:()=>void d(),disabled:t||o||!i.trim(),children:o?`Saving…`:`Save`}),(0,U.jsx)(X,{size:`sm`,variant:`ghost`,disabled:o,onClick:r,children:`Cancel`})]})]})}var SG=1200;function CG({question:e}){let[t,n]=(0,m.useState)(),r=tO(t!==void 0,eO.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,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`ul`,{"aria-label":`Mockups`,className:`grid grid-cols-3 gap-2`,children:i.map(({option:e,index:t,mockup:r})=>(0,U.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsx)(pG,{preview:r,label:gG(e.label),frameWidth:SG,onOpen:()=>n(t),className:`aspect-[3/2] h-auto`}),(0,U.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[(0,U.jsxs)(`span`,{className:`tabular-nums`,children:[t+1,`.`]}),` `,gG(e.label)]})]},t))}),(0,U.jsx)(qD,{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,U.jsx)(yG,{options:a,start:t,title:e.text,onClose:()=>n(void 0)})})]})}function wG({questions:e}){return(0,U.jsx)(`ol`,{className:`mt-1 flex flex-col gap-2`,children:e.map((e,t)=>(0,U.jsxs)(`li`,{className:`card-flat flex min-w-0 flex-col gap-2 rounded-xl border p-3 text-sm`,style:{"--orb":yO(e.from)},children:[(0,U.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,U.jsxs)(`span`,{className:`mt-px inline-flex shrink-0 items-center gap-1 rounded-full bg-[color-mix(in_oklab,var(--orb)_12%,transparent)] px-2 py-0.5 text-xs font-medium text-[color-mix(in_oklab,var(--orb)_85%,var(--foreground))]`,children:[(0,U.jsx)(pO,{source:e.from,className:`size-3`}),gO(e.from)]}),(0,U.jsxs)(`span`,{className:`min-w-0`,children:[(0,U.jsxs)(`span`,{className:`sr-only`,children:[`Question `,t+1,`: `]}),e.text]})]}),e.options.length?(0,U.jsx)(`ul`,{"aria-label":`Options`,className:`flex flex-wrap gap-1.5`,children:e.options.map(e=>(0,U.jsxs)(`li`,{className:`rounded-lg border border-border bg-muted/60 px-2 py-1 text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label}),e.description?` — ${e.description}`:``]},e.label))}):null,(0,U.jsx)(CG,{question:e})]},t))})}function TG({message:e}){let t=e.decided??[];return t.length?(0,U.jsx)(`ul`,{"aria-label":`Settled for you`,className:`mt-1 flex flex-col gap-1`,children:t.map((e,t)=>(0,U.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,title:`Settled by the classifier, ${Math.round(e.probability*100)}% sure. Comment on the plan to overrule it.`,children:[(0,U.jsx)($p,{"aria-hidden":`true`,className:`mt-[0.1875rem] size-3.5 shrink-0 text-success`}),(0,U.jsxs)(`span`,{className:`min-w-0`,children:[(0,U.jsx)(`span`,{className:Y(`font-medium`,_O(e.from)),children:gO(e.from)}),` `,(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:e.question}),` `,(0,U.jsx)(`span`,{className:`font-medium`,children:e.answer}),(0,U.jsxs)(`span`,{className:`decided-hint`,children:[`auto · `,Math.round(e.probability*100),`% · comment to overrule`]})]})]},t))}):null}function EG({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 R(`planner.editMessage`,{messageIndex:t,at:e.at,text:n});s(r.message)},d=!r&&!e.settled?.length&&!i?(0,U.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>a(!0),className:`chat-action`,children:[(0,U.jsx)(tg,{"aria-hidden":`true`,className:`size-3`}),`Edit`]}):null;return(0,U.jsx)(wO,{time:e.at>0?HO(e.at):void 0,head:!0,note:c.editedAt?`(edited)`:void 0,actions:d,children:i?(0,U.jsx)(xG,{text:c.text,disabled:n,onSave:u,onCancel:()=>a(!1)}):(0,U.jsx)(Mz,{text:c.text})})}function DG({message:e,index:t,busy:n,readOnly:r}){if(e.role===`you`)return(0,U.jsx)(EG,{message:e,index:t,busy:n,readOnly:r});let i=e.questions??[];return(0,U.jsxs)(CO,{source:`PLANNER`,name:`Panel`,time:e.at>0?HO(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,U.jsx)(wG,{questions:i}):(0,U.jsx)(Mz,{text:e.text}),(0,U.jsx)(TG,{message:e})]})}function OG({messages:e,seed:t,busy:n=!1,readOnly:r=!1}){return(0,U.jsxs)(`div`,{className:`chat-column`,role:`log`,"aria-label":`Panel conversation`,children:[t?(0,U.jsx)(TO,{children:t}):null,e.map((e,t)=>(0,U.jsx)(DG,{message:e,index:t,busy:n,readOnly:r},`${e.at}-${t}`)),n?(0,U.jsx)(CO,{source:`PLANNER`,name:`Panel`,head:!0,live:!0,waiting:!0,aside:`the panel is thinking`}):null]})}var kG=`ORACLE`,AG=`No draft yet.`,jG=`The draft appears after the panel's first round.`,MG=`What each seat needs`,NG=[`backend`,`designer`,`qa`,`researcher`],PG={backend:`DEV`,designer:`DESIGN`,qa:`QA`,researcher:`RESEARCH`},FG=`Describe a task in the box below. The panel asks what it needs to know, round by round, until the plan is clear.`,IG={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.`},LG=[{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 RG(e){let t=e.filter(e=>e.member);return`${t.filter(e=>e.seated).length} of ${t.length} seated`}function zG(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 BG(e,t){return`${e} ${t}${e===1?``:`s`}`}function VG(e){return e.round===0&&e.messages.length===0&&!e.busy}function HG(e){let t=e.members.find(e=>e.status===`failed`);if(t)return(t.error??`${PG[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 rK({notes:e}){return(0,U.jsx)(U.Fragment,{children:e.map((e,t)=>(0,U.jsx)(`p`,{className:`ml-6 rounded-lg border border-primary/15 bg-accent px-3 py-1.5 text-sm text-foreground italic`,children:e},t))})}var iK=[],aK=(0,m.memo)(function({row:e,index:t,notes:n,form:r,onComment:i}){let a=e.text.trim(),o=()=>i(t);return(0,U.jsxs)(`li`,{"data-line":t,className:Y(`group/line`,!r&&`[contain-intrinsic-size:auto_2.75rem] [content-visibility:auto]`),children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1`,children:[(0,U.jsx)(`span`,{className:`flex w-4 shrink-0 justify-center pt-3.5`,"aria-hidden":`true`,children:n.length>0?(0,U.jsx)(`span`,{className:`size-2 rounded-full bg-primary`}):null}),(0,U.jsx)(`div`,{className:Y(`min-w-0 flex-1 cursor-pointer rounded-lg px-2 py-1.5 transition-colors hover:bg-muted`,r&&`bg-muted`,e.fenced&&`font-mono text-sm whitespace-pre-wrap break-words`),onClick:e=>!e.target.closest(`a`)&&o(),children:e.fenced?e.text:(0,U.jsx)(Mz,{text:e.text})}),(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/line:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100`,"aria-label":`Comment on this line: ${a}`,onClick:o,children:(0,U.jsx)(kh,{"aria-hidden":`true`})})]}),(0,U.jsx)(rK,{notes:n}),r]})});function oK({draft:e,comments:t,commenting:n,form:r,onComment:i}){let a=(0,m.useMemo)(()=>nK(e),[e]),o=QR(a.length);return(0,U.jsx)(`ul`,{className:`flex flex-col`,"aria-label":`Draft plan lines`,children:a.slice(0,o).map((e,a)=>e.text.trim()?(0,U.jsx)(aK,{row:e,index:a,notes:t.get(e.text.trim())??iK,form:a===n?r:void 0,onComment:i},a):(0,U.jsx)(`li`,{"aria-hidden":`true`,className:`h-2`},a))})}function sK({notes:e}){return e.length===0?null:(0,U.jsx)(aV,{title:MG,children:(0,U.jsx)(`dl`,{className:`flex flex-col gap-2 text-sm`,children:e.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex min-w-0 gap-3`,children:[(0,U.jsx)(`dt`,{className:Y(`w-20 shrink-0 font-medium`,_O(e.from)),children:gO(e.from)}),(0,U.jsx)(`dd`,{className:`min-w-0 flex-1`,children:(0,U.jsx)(Mz,{text:e.text})})]},t))})})}function cK({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,U.jsxs)(`div`,{ref:r,role:`group`,"aria-label":`Comment on this line`,className:`line-comment relative mt-1 mb-2 ml-6 rounded-xl border p-3`,children:[(0,U.jsx)(X,{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 text-muted-foreground`,children:(0,U.jsx)(s_,{"aria-hidden":`true`})}),(0,U.jsx)(iV,{label:`Your comment`,hint:`Enter adds the comment · Esc cancels`,buttonLabel:`Add comment`,onSend:async t=>await mp(`planner.commentLine`,{line:e,text:t.trim()})?(n(t.trim()),!0):!1})]})}function lK({open:e,onClose:t,snap:n,comments:r,onSent:i}){let a=tO(e,eO.sheet),o=(0,m.useRef)(null),[s,c]=(0,m.useState)(),l=(0,m.useMemo)(()=>n.draft?nK(n.draft):[],[n.draft]),u=s===void 0?void 0:l[s]?.text.trim(),d=()=>{let e=s;c(void 0),requestAnimationFrame(()=>o.current?.querySelector(`[data-line="${e}"] button[aria-label^="Comment on this line"]`)?.focus())};return(0,U.jsx)(OB,{open:e&&a,onOpenChange:e=>!e&&t(),children:(0,U.jsxs)(MB,{showCloseButton:!1,side:`right`,"aria-label":`Draft plan`,onEscapeKeyDown:e=>{u!==void 0&&(e.preventDefault(),d())},onCloseAutoFocus:()=>c(void 0),className:`plan-sheet gap-0 data-[side=right]:w-[min(44rem,92vw)] data-[side=right]:sm:max-w-none`,children:[(0,U.jsxs)(NB,{className:`flex-row items-center justify-between gap-3 border-b px-5 py-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,U.jsx)(PB,{className:`text-base font-semibold tracking-tight`,children:`Draft plan`}),(0,U.jsxs)(FB,{className:`text-xs text-muted-foreground`,children:[n.round>0?`${zG(n.round,n.limit)} · `:``,`choose a line to comment on it`]})]}),(0,U.jsx)(kB,{asChild:!0,children:(0,U.jsxs)(X,{variant:`ghost`,size:`sm`,"aria-label":`Close the plan`,title:`Close · Esc`,className:`gap-2 text-muted-foreground`,children:[(0,U.jsx)(s_,{"aria-hidden":`true`}),`Close`,(0,U.jsx)(GD,{chord:`Esc`,className:`kbd-hint`})]})})]}),(0,U.jsxs)(`div`,{ref:o,className:`flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto overscroll-contain px-5 pt-4 pb-8`,children:[n.draft?(0,U.jsx)(oK,{draft:n.draft,comments:r,commenting:u===void 0?void 0:s,form:u===void 0?void 0:(0,U.jsx)(cK,{line:u,onCancel:d,onSent:e=>(i(u,e),d())},s),onComment:c}):(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.busy?jG:AG}),(0,U.jsx)(sK,{notes:n.notes})]}),(0,U.jsx)(Bv,{target:o})]})})}var uK=Uv([`relative inline-flex w-fit shrink-0 items-center justify-center border border-transparent font-medium whitespace-nowrap outline-none transition-shadow`,`focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-64`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-3 [&_svg:not([class*=opacity-])]:opacity-80`],{variants:{variant:{default:`bg-primary text-primary-foreground`,secondary:`bg-accent text-secondary-foreground`,outline:`border-input bg-background text-foreground dark:bg-input/32`,info:`bg-info/8 text-info dark:bg-info/16`,success:`bg-success/8 text-success dark:bg-success/16`,warning:`bg-warning/8 text-warning dark:bg-warning/16`,destructive:`bg-destructive/8 text-destructive dark:bg-destructive/16`},size:{sm:`h-4 min-w-4 gap-1 px-1 text-3xs leading-none`,default:`h-[1.125rem] min-w-[1.125rem] gap-1 px-1 text-xs`,lg:`h-5 min-w-5 gap-1 px-1.5 text-xs`},radius:{default:`rounded-sm`,full:`rounded-full`}},defaultVariants:{variant:`default`,size:`default`,radius:`default`}});function dK({className:e,variant:t,size:n,radius:r,asChild:i=!1,...a}){let o=i?Qv:`span`;return(0,U.jsx)(o,{"data-slot":`badge`,className:Y(uK({variant:t,size:n,radius:r,className:e})),...a})}var fK=()=>hB(mB(`plan`,`previous`)),pK=e=>hB(mB(`plan`,`previous`,e));function mK(e){let t=Date.now()-Date.parse(e);return Number.isFinite(t)?WO(Math.max(0,t)):``}function hK(e,t){return[`${t} message${t===1?``:`s`}`,`round ${e.rounds}`,mK(e.updatedAt)].filter(Boolean).join(` · `)}function gK({plan:e,selected:t}){return(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>pK(e.id),className:KU,children:[(0,U.jsxs)(`span`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(`span`,{className:Y(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title}),e.hasDraft?(0,U.jsx)(dK,{variant:`secondary`,children:`draft`}):null]}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:hK(e,e.messages)})]})})}function _K({id:e,onGone:t}){let n=DB(`planner.previousGet`,{id:e},[`planner`]),r=n.data;if(!r)return n.error?(0,U.jsx)(TB,{message:`Could not load that plan. ${n.error}`,onRetry:n.reload}):null;let i=!!r.archivedAt,a=async()=>{await mp(`planner.previousOpen`,{id:e})&&hB(mB(`plan`))},o=async()=>{await mp(`planner.previousArchive`,{id:e,archived:!i})&&t()},s=async()=>{await mp(`planner.previousDelete`,{id:e})&&t()};return(0,U.jsxs)(`article`,{className:`flex flex-col gap-5`,"aria-label":r.title,children:[(0,U.jsxs)(CR,{children:[(0,U.jsx)(SR,{label:`Carry on planning`,text:`Carry on`,icon:ag,tone:`primary`,shortcut:`C`,onClick:()=>void a()}),(0,U.jsx)(SR,{label:i?`Bring it back from the archive`:`Archive`,text:i?`Unarchive`:`Archive`,icon:i?kp:jp,shortcut:`E`,onClick:()=>void o()}),(0,U.jsx)(tV,{icon:Gg,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,U.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:r.title}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:[i?`archived`:``,hK(r,r.messages.length),r.seed??``].filter(Boolean).join(` · `)})]}),(0,U.jsxs)(aV,{title:`Draft plan`,children:[r.draft?(0,U.jsx)(Mz,{text:r.draft}):(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The panel had not written a draft yet.`}),(0,U.jsx)(sK,{notes:r.notes})]}),(0,U.jsx)(aV,{title:`Conversation`,children:(0,U.jsx)(OG,{messages:r.messages,readOnly:!0})})]})}function vK({id:e}){let t=RB(),[n,r]=(0,m.useState)(!1),i=DB(`planner.previous`,n?{archived:!0}:{},[`planner`]),a=i.data?.plans??[];if(!i.data&&i.error)return(0,U.jsx)(TB,{message:`Could not load the previous plans. ${i.error}`,onRetry:i.reload});let o=(0,U.jsxs)(UB,{title:n?`Archived plans`:`Previous plans`,count:i.data?String(a.length):void 0,children:[(0,U.jsx)(SR,{label:`Back to the current plan`,icon:Fp,iconOnly:!0,onClick:()=>hB(mB(`plan`))}),(0,U.jsx)(SR,{label:n?`Show the previous plans`:`Show the archived plans`,text:n?`Previous`:`Archived`,icon:n?dg:jp,pressed:n,onClick:()=>{r(e=>!e),fK()}})]}),s=i.data?a.length===0?(0,U.jsx)(`p`,{className:`px-4 py-6 text-sm text-muted-foreground`,children:n?`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,U.jsx)(`ul`,{className:Y(qU,`pt-2`),"aria-label":n?`Archived plans`:`Previous plans`,children:a.map(t=>(0,U.jsx)(gK,{plan:t,selected:t.id===e},t.id))}):(0,U.jsx)(WB,{});return(0,U.jsx)(HB,{wide:t,list:(0,U.jsxs)(U.Fragment,{children:[o,s]}),detail:e?(0,U.jsx)(_K,{id:e,onGone:()=>{i.reload(),fK()}},e):null,open:e!==void 0,onClose:fK,hint:`Pick a plan to read it, carry it on, archive it or delete it.`,describe:`A previous plan`})}function yK({limit:e}){return e<=0?null:(0,U.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`flex gap-1`,children:Array.from({length:e},(t,n)=>(0,U.jsx)(`span`,{className:Y(`h-1.5 w-4 rounded-full`,n===e-1?`bg-primary`:`bg-border`)},n))}),(0,U.jsxs)(`span`,{children:[`up to `,e,` rounds, the last the oracle's`]})]})}function bK({snap:e,onDone:t}){let n=GG(e),r=(0,m.useRef)(null);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{ref:r,className:`@container flex-1 overflow-y-auto px-8 pt-10 pb-dock`,children:(0,U.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-8`,children:[(0,U.jsxs)(`header`,{className:`flex flex-col gap-4 @3xl:flex-row @3xl:items-end @3xl:justify-between`,children:[(0,U.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`card-flat grid size-11 shrink-0 place-items-center rounded-xl border text-primary`,children:(0,U.jsx)(_g,{className:`size-5`})}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`Plan with the panel`}),(0,U.jsx)(`p`,{className:`max-w-xl text-sm leading-relaxed text-muted-foreground`,children:FG})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col items-start gap-2 @3xl:items-end`,children:[(0,U.jsx)($G,{}),(0,U.jsx)(yK,{limit:e.limit})]})]}),(0,U.jsxs)(`section`,{"aria-labelledby":`plan-panel`,className:`flex flex-col gap-3`,children:[(0,U.jsx)(`h3`,{id:`plan-panel`,className:`text-xs text-muted-foreground`,children:(0,U.jsx)(KO,{title:`The panel`,right:RG(n)})}),(0,U.jsx)(ZG,{cells:n,onToggled:t})]}),(0,U.jsxs)(`section`,{"aria-labelledby":`plan-steps`,className:`flex flex-col gap-3`,children:[(0,U.jsx)(`h3`,{id:`plan-steps`,className:`text-xs text-muted-foreground`,children:(0,U.jsx)(KO,{title:`How a plan comes together`})}),(0,U.jsx)(`ol`,{className:`grid gap-3 @2xl:grid-cols-2 @4xl:grid-cols-4`,children:LG.map((e,t)=>(0,U.jsxs)(`li`,{className:`card-flat relative flex gap-3 rounded-xl border p-3.5`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-6 shrink-0 place-items-center rounded-full bg-accent text-xs font-semibold text-primary tabular-nums`,children:t+1}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,U.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:e.text})]})]},e.title))})]}),(0,U.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 text-sm text-muted-foreground`,children:[(0,U.jsx)(Np,{"aria-hidden":`true`,className:`size-4 text-primary motion-safe:animate-bounce`}),`Start in the box below.`,(0,U.jsx)(KD,{chord:`/`,children:`write`}),(0,U.jsx)(KD,{chord:`Enter`,children:`send to the panel`})]})]})}),(0,U.jsx)(Bv,{target:r})]})}function xK({snap:e,onOpen:t}){let n=(0,m.useRef)(null);return bR(`v`,()=>n.current?.click()),e.draft?(0,U.jsx)(`div`,{className:`pointer-events-none sticky top-0 z-10 -mt-2 mb-3 flex justify-center`,children:(0,U.jsxs)(`button`,{ref:n,type:`button`,"aria-haspopup":`dialog`,"aria-keyshortcuts":`V`,onClick:t,className:`plan-pill pointer-events-auto inline-flex items-center gap-2 rounded-full border py-1.5 ps-2.5 pe-3 text-sm font-medium shadow-card backdrop-blur-sm`,children:[(0,U.jsx)(Ym,{"aria-hidden":`true`,className:`size-4 text-primary`}),`View plan`,(0,U.jsx)(GD,{chord:`V`,className:`kbd-hint`})]})}):null}function SK({snap:e,reload:t}){let[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(new Map),o=(e,t)=>a(n=>new Map(n).set(e,[...n.get(e)??[],t])),{ref:s,onScroll:c}=cO(`${JSON.stringify(e.messages)}${e.busy}`);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(tK,{snap:e,onDone:t}),(0,U.jsxs)(`div`,{ref:s,onScroll:c,className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-5 pt-5 pb-dock`,children:[(0,U.jsx)(xK,{snap:e,onOpen:()=>r(!0)}),(0,U.jsx)(OG,{messages:e.messages,busy:e.busy})]}),(0,U.jsx)(Bv,{target:s}),(0,U.jsx)(lK,{open:n,onClose:()=>r(!1),snap:e,comments:i,onSent:o})]})}function CK({rest:e=[]}){return e[0]===`previous`?(0,U.jsx)(vK,{id:e[1]}):(0,U.jsx)(wK,{})}function wK(){let e=DB(`planner.get`,{},[`planner`]),t=e.data;if(!t&&e.error)return(0,U.jsx)(TB,{message:`Could not load the plan. ${e.error}`,onRetry:e.reload});if(!t)return(0,U.jsx)(`p`,{role:`status`,className:`p-5 text-sm text-muted-foreground`,children:`Loading the plan…`});let n=VG(t);return(0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:n?(0,U.jsx)(bK,{snap:t,onDone:e.reload}):(0,U.jsx)(SK,{snap:t,reload:e.reload})})}var TK={},EK=new Set;function DK(e){TK=e;for(let e of[...EK])e()}function OK(e){TK.taskId!==e&&DK({...TK,taskId:e})}function kK(e){return EK.add(e),()=>{EK.delete(e)}}function AK(){return(0,m.useSyncExternalStore)(kK,()=>TK,()=>TK)}function jK(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 MK(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 NK(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 PK({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,U.jsxs)(`span`,{className:`tabular-nums break-words`,children:[e.waiting?`Waiting for you · `:``,MK(jK(e,n,t)),` execution`]})}function FK({work:e,timing:t,stopped:n}){let r=e.running&&!n&&!t?.waiting,i=NK(r,e);return(0,U.jsxs)(`span`,{className:`tabular-nums break-words`,"data-work-clock":r?`running`:`stopped`,children:[t?.waiting?`Waiting for you · `:``,`worked `,MK(e.workedMs+i)]})}function IK({timing:e,work:t,stopped:n=!1}){return t?(0,U.jsx)(FK,{work:t,...e?{timing:e}:{},stopped:n}):e?(0,U.jsx)(PK,{timing:e,stopped:n},JSON.stringify(e)):(0,U.jsx)(`span`,{children:`Timing unavailable`})}var LK=`This merges the reviewed commit into main and pushes main, then removes the task worktree after verifying the merge. The task branch is kept.`,RK={pending_approval:`Ready for your review`,deferred:`Saved for later`,in_progress:`Delivery in progress`,successful:`Delivered`,recoverable_failure:`Delivery needs attention`};function zK({delivery:e,title:t}){return(0,U.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,U.jsx)(`p`,{className:`font-medium break-words`,children:t}),(0,U.jsxs)(`dl`,{className:`grid gap-1 break-all text-muted-foreground`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{className:`inline`,children:`Project: `}),(0,U.jsx)(`dd`,{className:`inline`,children:e.project})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{className:`inline`,children:`Repository: `}),(0,U.jsx)(`dd`,{className:`inline`,children:e.repository??`Unavailable — refresh review`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{className:`inline`,children:`Source: `}),(0,U.jsxs)(`dd`,{className:`inline`,children:[e.sourceBranch,` · `,e.sourceCommit??`Commit unavailable`]})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{className:`inline`,children:`Target: `}),(0,U.jsxs)(`dd`,{className:`inline`,children:[`main`,e.targetCommit?` · ${e.targetCommit}`:``]})]})]}),(0,U.jsxs)(`p`,{children:[`Checks: `,e.verification?.checks??`unavailable`]}),(0,U.jsx)(`p`,{children:e.verification?.summary??`Verification unavailable. Refresh the review before delivery.`}),e.verification?(0,U.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 BK({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,U.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,U.jsx)(X,{variant:`outline`,disabled:o,onClick:()=>r(e),children:e===`create_pr`?`Create PR`:a?`Retry worktree cleanup`:`Merge to main`}),(0,U.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,U.jsxs)(`p`,{className:`text-sm text-destructive`,children:[i,` Refresh review after resolving this restriction, then choose the action again.`]}):null]})}async function VK(e,t,n){let r={taskId:t,reviewId:n};return e===`refresh`?R(`tasks.deliveryReview`,{taskId:t}):e===`defer`?R(`tasks.deliveryDefer`,r):R(`tasks.deliver`,{...r,action:e,...e===`merge_main`?{confirmMain:!0}:{}})}function HK({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=fe(),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 UK(e){return e.scope.current===e.identity&&e.project===fe()}function WK(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 VK(r,t.taskId,e.current.reviewId);UK(e)&&(e.setCurrent(n.delivery),t.onChanged())}catch(t){UK(e)&&e.setError(t instanceof Error?t.message:String(t))}finally{n.current=!1,e.scope.current&&e.setBusy(!1)}}}return r}function GK(e){let t=HK(e),n=WK(t,e),r=tO(t.confirm,eO.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 KK({review:e}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Task completion is recorded separately. Nothing is published without your approval.`}),(0,U.jsx)(`p`,{role:`status`,className:`text-sm`,children:e.busy?`Updating delivery…`:e.current.operation?`Operation: ${e.current.operation.stage}`:RK[e.current.status]}),e.current.error||e.error?(0,U.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,U.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.current.cleanupError,` Retry cleanup after resolving it.`]}):null,e.current.operation?.worktreeRemoved?(0,U.jsx)(`p`,{className:`text-sm`,children:`Task worktree removed.`}):null,e.current.result?(0,U.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,U.jsxs)(`span`,{children:[` · `,e.current.result.pullUrl]}):null]}):null]})}function qK({review:e}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,U.jsx)(BK,{action:`create_pr`,delivery:e.current,busy:e.busy,onAction:()=>void e.request(`create_pr`)}),(0,U.jsx)(BK,{action:`merge_main`,delivery:e.current,busy:e.busy,onAction:e.reviewMerge})]}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,U.jsx)(X,{variant:`ghost`,disabled:e.busy,onClick:()=>void e.request(`refresh`),children:`Refresh review`}),(0,U.jsx)(X,{variant:`ghost`,disabled:e.busy||e.terminal,onClick:()=>void e.request(`defer`),children:`Not now`})]})]})}function JK({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.`:LK;return(0,U.jsx)(qD,{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,U.jsxs)(`div`,{className:`grid gap-3 p-4`,children:[(0,U.jsx)(`h3`,{className:`font-medium`,children:t?`Remove task worktree?`:`Merge to main?`}),(0,U.jsx)(`p`,{className:`text-sm`,children:n}),(0,U.jsxs)(`p`,{className:`break-all text-sm text-muted-foreground`,children:[e.current.repository,` · `,e.current.sourceCommit,` → main`]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,U.jsx)(X,{variant:`outline`,onClick:()=>e.setConfirm(!1),children:`Cancel`}),(0,U.jsx)(X,{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 YK({title:e,review:t}){return(0,U.jsxs)(aV,{title:`Completed work · delivery review`,right:RK[t.current.status],children:[(0,U.jsx)(zK,{delivery:t.current,title:e}),(0,U.jsx)(KK,{review:t}),(0,U.jsx)(qK,{review:t}),(0,U.jsx)(JK,{review:t})]})}function XK(e){let t=GK(e);return(0,U.jsx)(YK,{title:e.title,review:t})}var ZK={open:Cm,delivered:hm,addressed:dm},QK={open:`waiting for the owning session`,delivered:`sent to the oracle`,addressed:`plan amended`};function $K({comment:e}){let t=WO(Date.now()-Date.parse(e.createdAt)),n=ZK[e.status];return(0,U.jsxs)(`p`,{className:`mt-1 flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,U.jsx)(n,{"aria-hidden":`true`,className:e.status===`addressed`?`size-3.5 text-success`:`size-3.5`}),QK[e.status],`, `,t,e.editedAt?` (edited)`:``]})}function eq({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,U.jsxs)(`li`,{className:`card-flat min-w-0 rounded-lg border px-3.5 py-2.5`,children:[r?(0,U.jsx)(xG,{text:s.text,onSave:async n=>{let r=await R(`tasks.editComment`,{taskId:t,commentId:e.id,text:n});o(r.comment)},onCancel:()=>i(!1)}):(0,U.jsx)(Mz,{text:s.text}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)($K,{comment:s}),n&&!r?(0,U.jsx)(X,{size:`sm`,variant:`ghost`,onClick:()=>i(!0),children:`Edit`}):null]})]})}function tq({taskId:e,finished:t,canComment:n}){let r=DB(`tasks.comments`,{taskId:e},[`tasks`]),i=oO(`status`),a=r.data?.comments??[],o=a.filter(e=>e.status!==`addressed`).length;return(0,U.jsxs)(`section`,{"aria-labelledby":`comments-${e}`,className:`flex flex-col gap-3`,children:[(0,U.jsx)(`h3`,{id:`comments-${e}`,className:`text-sm`,children:(0,U.jsx)(KO,{title:`Comments`,right:o>0?`${o} open`:void 0})}),a.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?`No comments.`:n?`No comments yet. Comment on the plan in the box below (Markdown and images work); the oracle amends it.`:`No comments yet.`}):(0,U.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:a.map(t=>(0,U.jsx)(eq,{taskId:e,comment:t,own:!!(t.by&&t.by===i.data?.sessionId)},`${e}-${t.id}`))})]})}var nq={mine:`This session`,others:`Other sessions`,pending:`Pending`,recent:`Finished`,archived:`Archived`},rq={open:`open`,done:`done`,dropped:`abandoned`},iq={none:{label:`None`,depth:`nothing that runs changed: the engine's checks decide, no QA agent`,tone:`bg-accent text-muted-foreground`},low:{label:`Low`,depth:`a light check: the diff, the nearest tests, done once confident`,tone:`bg-success/10 text-success`},medium:{label:`Medium`,depth:`a standard check: the acceptance criteria and realistic regressions`,tone:`bg-warning/10 text-warning`},high:{label:`High`,depth:`a deep, adversarial review: invariants, recovery and everything the change reaches`,tone:`bg-destructive/10 text-destructive`}};function aq(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 oq=`No tasks yet. Start one from the Lobby tab, or plan one in the Plan tab.`;function sq(e,t){return`${e.replace(/_/g,` `)}${t?` · paused`:``}`}function cq(e){return e===`now`?`just now`:`${e} ago`}function lq(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[sq(e.status,e.paused),t].filter(Boolean).join(` · `)}function uq(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 dq(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 fq=1e3;function pq({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=tO(i,eO.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{W((await R(`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,U.jsxs)(GB,{open:i&&f,onOpenChange:_,children:[(0,U.jsxs)(`button`,{type:`button`,"aria-label":`Skip step ${t+1}`,onClick:()=>_(!0),className:Y(`step-skip -my-0.5 ml-auto inline-flex h-6 shrink-0 items-center gap-1 rounded-md px-1.5 text-xs text-muted-foreground outline-none`,`transition-[opacity,background-color,color,scale] duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:scale-[0.96] motion-reduce:active:scale-100`),children:[(0,U.jsx)(kg,{"aria-hidden":`true`,className:`size-3.5`}),`Skip`]}),(0,U.jsxs)(JB,{children:[(0,U.jsxs)(YB,{children:[(0,U.jsxs)(ZB,{children:[`Skip step `,t+1,`?`]}),(0,U.jsx)(QB,{children:`The oracle is told to carry on without it, and your reason stays with the step in the task's history.`})]}),(0,U.jsx)(`p`,{className:`rounded-md bg-muted px-2.5 py-1.5 text-sm break-words`,children:n}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(`label`,{htmlFor:p,className:`text-sm font-medium`,children:`Why skip it?`}),(0,U.jsx)(nV,{id:p,value:o,autoFocus:!0,required:!0,maxLength:fq,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,U.jsx)(`p`,{id:h,className:`text-xs text-muted-foreground`,children:`A reason is required.`})]}),u?(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:u}):null,(0,U.jsxs)(XB,{children:[(0,U.jsx)(eV,{disabled:c,children:`Cancel`}),(0,U.jsx)(X,{disabled:!g||c,"aria-busy":c,onClick:()=>void v(),children:c?`Skipping…`:`Skip step`})]})]})]})}function mq({step:e,stopped:t}){let n=NK(!t,e);return(0,U.jsx)(`span`,{className:`tabular-nums`,children:MK((e.workedMs??0)+n)})}function hq(){return(0,U.jsxs)(`span`,{"aria-hidden":`true`,className:`relative mt-[0.3125rem] grid size-4 shrink-0 place-items-center`,children:[(0,U.jsx)(`span`,{className:`absolute size-2.5 rounded-full bg-primary/30 motion-safe:animate-status-ping`}),(0,U.jsx)(`span`,{className:`size-2 rounded-full bg-primary`})]})}function gq(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,``)}function _q({name:e,className:t}){return(0,U.jsx)(`span`,{"aria-hidden":`true`,className:Y(`grid size-5 shrink-0 place-items-center rounded-md border border-border bg-card`,_O(e),t),children:(0,U.jsx)(pO,{source:e,className:`size-3`})})}function vq({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,U.jsx)(`ul`,{id:e,"aria-label":`Agents on this step`,className:`mt-2 flex flex-col overflow-hidden rounded-lg border border-border bg-card`,children:a.map(e=>{let i=bO({domain:e.domain}),a=!!e.parentRunId&&t.some(t=>t.runId===e.parentRunId),o=Date.parse(e.startedAt),s=gq(e.instruction),c=s&&s.toLowerCase()!==n.trim().toLowerCase()?s:``;return(0,U.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2.5 border-b border-border px-3 py-2 text-xs last:border-b-0`,children:[a?(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`ml-1.5 h-4 w-3 shrink-0 rounded-bl-md border-b border-l border-border`}):null,(0,U.jsx)(_q,{name:i}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:Y(`font-medium`,_O(i)),children:gO(i)}),a?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`child`}):null,(0,U.jsx)(Uz,{className:`size-3 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`working`})]}),c?(0,U.jsx)(`span`,{className:`truncate text-muted-foreground`,title:e.instruction,children:c}):null]}),Number.isFinite(o)?(0,U.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:MK(Math.max(0,r-o))}):null]},e.runId)})})}function yq({agents:e,count:t,step:n,stopped:r}){let i=[...new Set(e.map(e=>bO({domain:e.domain})))].slice(0,3);return(0,U.jsxs)(U.Fragment,{children:[i.length>0?(0,U.jsx)(`span`,{className:`flex -space-x-1.5`,children:i.map(e=>(0,U.jsx)(_q,{name:e,className:`size-[1.125rem] ring-2 ring-card`},e))}):null,(0,U.jsxs)(`span`,{children:[t,` `,t===1?`agent`:`agents`,(0,U.jsx)(`span`,{className:`sr-only`,children:` working`})]}),(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground/60`,children:`·`}),(0,U.jsx)(mq,{step:n,stopped:r})]})}var bq=`inline-flex h-6 shrink-0 items-center gap-1.5 rounded-full border border-primary/20 bg-primary/5 pr-2 pl-1 text-xs font-medium text-primary`;function xq(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 Sq({step:e,index:t}){let n=e.skip?xq(e.skip.at):``;return(0,U.jsxs)(`li`,{className:`flex min-w-0 flex-col`,"data-step":`skipped`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5 text-sm`,children:[(0,U.jsx)(ym,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),(0,U.jsxs)(`span`,{className:`shrink-0 text-xs leading-5 text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,U.jsx)(`span`,{className:`min-w-0 break-words text-muted-foreground line-through decoration-muted-foreground/50`,children:e.text}),(0,U.jsx)(`span`,{className:`shrink-0 rounded-md bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground`,children:`skipped`})]}),e.skip?(0,U.jsxs)(`p`,{className:`step-skip-reason mt-1 ml-[3.25rem] border-l-2 border-border pl-2.5 text-xs break-words text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground/80`,children:`Why: `}),e.skip.reason,n?(0,U.jsxs)(`span`,{className:`text-muted-foreground/70`,children:[` · `,n]}):null]}):null]})}function Cq({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)(!1),l=(0,m.useId)(),u=e.status===`done`,d=u?`text-success`:e.status===`current`?`text-primary`:`text-muted-foreground`,f=u?dm:Cm;return e.status===`skipped`?(0,U.jsx)(Sq,{step:e,index:t}):(0,U.jsxs)(`li`,{className:`group/step flex min-w-0 flex-col`,"data-step":i?`active`:e.status,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5 text-sm`,children:[i?(0,U.jsx)(hq,{}):(0,U.jsx)(f,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 ${d}`}),(0,U.jsxs)(`span`,{className:`shrink-0 text-xs leading-5 text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,U.jsx)(`span`,{className:Y(`min-w-0 break-words`,i||e.status===`current`?`text-foreground`:`text-muted-foreground`),children:e.text}),i&&a.length>0?(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":s,"aria-controls":l,onClick:()=>c(e=>!e),className:Y(bq,`-my-0.5 transition-colors outline-none hover:bg-primary/10 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`),children:[(0,U.jsx)(yq,{agents:a,count:o,step:e,stopped:n}),(0,U.jsx)(tm,{"aria-hidden":`true`,className:Y(`size-3 transition-transform duration-200`,s&&`rotate-180`)}),(0,U.jsx)(`span`,{className:`sr-only`,children:` (being worked on now)`})]}):i?(0,U.jsxs)(`span`,{className:Y(bq,`-my-0.5`),children:[(0,U.jsx)(yq,{agents:a,count:o,step:e,stopped:n}),(0,U.jsx)(`span`,{className:`sr-only`,children:` (being worked on now)`})]}):e.status===`current`&&!n?(0,U.jsxs)(`span`,{className:`shrink-0 rounded-md bg-accent px-2 py-0.5 text-xs font-medium`,children:[`next`,(0,U.jsx)(`span`,{className:`sr-only`,children:` (the step up next)`})]}):null,r&&!u&&!n?(0,U.jsx)(pq,{taskId:r.taskId,index:t,text:e.text,onSkipped:r.onSkipped}):null]}),s&&a.length>0?(0,U.jsx)(`div`,{className:`pl-[3.25rem]`,children:(0,U.jsx)(vq,{id:l,agents:a,stepText:e.text})}):null]})}function wq({steps:e,stopped:t,skip:n}){let r=e.filter(e=>e.status===`skipped`).length;return(0,U.jsx)(aV,{title:`Steps`,...r?{right:`${r} skipped`}:{},children:(0,U.jsx)(`ol`,{className:`flex flex-col gap-2`,"aria-label":`Steps`,children:e.map((e,r)=>(0,U.jsx)(Cq,{step:e,index:r,stopped:t,skip:n},`${r}-${e.text}`))})})}function Tq({text:e}){let[t,n]=(0,m.useState)(!1),r=(0,m.useId)();return(0,U.jsxs)(aV,{title:`Full plan`,children:[(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":r,onClick:()=>n(e=>!e),className:`inline-flex min-h-11 w-fit items-center gap-1.5 rounded-md text-sm text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[(0,U.jsx)(am,{"aria-hidden":`true`,className:Y(`size-4 transition-transform duration-200 ease-snap`,t&&`rotate-90`)}),t?`Hide the details`:`Read the details of each step`]}),t?(0,U.jsx)(`div`,{id:r,children:(0,U.jsx)(Mz,{text:e})}):null]})}function Eq({detail:e,finished:t}){return e.plan&&e.planDetails?(0,U.jsx)(Tq,{text:e.planDetails}):e.plan?(0,U.jsx)(aV,{title:`Approved plan`,children:(0,U.jsx)(Mz,{text:e.plan})}):e.proposal?(0,U.jsx)(aV,{title:t?`Proposal`:`Proposal (no plan yet)`,children:(0,U.jsx)(Mz,{text:e.proposal})}):(0,U.jsx)(aV,{title:`Plan`,children:(0,U.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 Dq({amendments:e}){return e.length===0?null:(0,U.jsx)(aV,{title:`Amendments`,children:(0,U.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-sm text-muted-foreground`,children:e.map(e=>(0,U.jsx)(`li`,{className:`break-words`,children:e},e))})})}function Oq({risk:e}){let t=iq[e.risk];return(0,U.jsxs)(aV,{title:`QA risk`,right:aq(e),children:[(0,U.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1 text-sm`,"data-qa-risk":e.risk,children:[(0,U.jsx)(`span`,{className:Y(`rounded-md px-2 py-0.5 text-xs font-medium`,t.tone),children:t.label}),(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:t.depth})]}),e.focusAreas.length>0?(0,U.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-sm text-muted-foreground`,"aria-label":`What QA looks at first`,children:e.focusAreas.map(e=>(0,U.jsx)(`li`,{className:`break-words`,children:e},e))}):null,(0,U.jsxs)(`p`,{className:`text-xs break-words text-muted-foreground`,children:[e.riskFactors.join(` · `),e.qaRequired?` · existing tests ${e.existingTestsLikelySufficient?`likely enough`:`likely not enough`}`:``]})]})}function kq({runs:e}){return e.length===0?null:(0,U.jsx)(aV,{title:`Recent runs`,children:(0,U.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.map((e,t)=>(0,U.jsx)(`li`,{className:`break-words`,children:e},`${t}-${e}`))})})}function Aq({detail:e,finished:t,skip:n}){return(0,U.jsxs)(U.Fragment,{children:[e.steps.length>0?(0,U.jsx)(wq,{steps:e.steps,stopped:t,skip:n}):null,e.request?(0,U.jsx)(aV,{title:`Request`,children:(0,U.jsx)(Mz,{text:e.request})}):null,(0,U.jsx)(Eq,{detail:e,finished:t})]})}function jq({detail:e}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Dq,{amendments:e.amendments}),e.qaRisk?(0,U.jsx)(Oq,{risk:e.qaRisk}):null,(0,U.jsx)(kq,{runs:e.runs})]})}function Mq({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 hB(`#/lobby`);let t=fe(),r=()=>n.current&&fe()===t;try{let t=await R(`tasks.open`,{taskId:e.id});if(!r())return;let n=await R(`status.get`,{});if(!r())return;if(t.sessionId&&t.sessionId===n.sessionId)return hB(`#/lobby`);if(t.sessionId&&!t.key)return W.info(`This task runs in another terminal. Switch to that terminal to work on it.`);if(n.busy)return W.info(`The oracle is working in this window. Stop it first, then open the task in its session.`);await mp(`sessions.switch`,t.key?{key:t.key}:{claimTaskId:e.id})&&r()&&hB(`#/lobby`)}catch(e){r()&&W.error(e instanceof Error?e.message:String(e))}}let i=e.section===`mine`;return(0,U.jsx)(SR,{label:i?`Open in its session: this window`:`Open in its session`,text:`Open in session`,icon:Lp,tone:t?`neutral`:`primary`,shortcut:`S`,onClick:()=>void r()})}function Nq({split:e}){let t=e.after.length>0?`, after ${e.after.map(e=>`part ${e}`).join(` and `)}`:``;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[(0,U.jsxs)(`span`,{className:`font-medium text-primary`,children:[`part `,e.part,` of `,e.of]}),` of one plan that was split into tasks`,t?(0,U.jsx)(`span`,{className:`text-foreground`,children:t}):null]}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.titles.map((t,n)=>(0,U.jsxs)(`span`,{children:[n>0?(0,U.jsx)(`span`,{className:`text-muted-foreground/60`,children:` · `}):null,(0,U.jsxs)(`span`,{className:n+1===e.part?`font-medium text-foreground`:void 0,children:[n+1,`. `,t]})]},`${n}-${t}`))})]})}function Pq({planId:e}){let t=DB(`plans.get`,{planId:e},[`plans`]),n=t.data;return n?(0,U.jsxs)(U.Fragment,{children:[n.issue?(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`from issue #`,n.issue.number,` — `,n.issue.title,n.issue.url?(0,U.jsxs)(`span`,{className:`break-all`,children:[` `,n.issue.url]}):null]}):null,n.split?(0,U.jsx)(Nq,{split:n.split}):null,(0,U.jsx)(aV,{title:`Agreed plan`,children:(0,U.jsx)(Mz,{text:n.brief})})]}):t.error?(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the agreed plan. `,t.error]}):null}function Fq({row:e,onGone:t}){let n=async n=>{await mp(`plans.start`,{planId:e.id,where:n})&&t()},r=async()=>{await mp(`plans.discard`,{planId:e.id})&&t()};return(0,U.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-4`,"aria-label":e.title,children:[(0,U.jsxs)(CR,{children:[(0,U.jsx)(SR,{label:`Start here`,icon:ag,tone:`primary`,shortcut:`S`,onClick:()=>void n(`here`)}),(0,U.jsx)(SR,{label:`Start in a new session`,text:`New session`,icon:jg,shortcut:`N`,onClick:()=>void n(`session`)}),(0,U.jsx)(tV,{icon:Gg,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()})]}),(0,U.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,U.jsxs)(`h2`,{className:`flex items-start gap-2.5 text-lg font-medium`,children:[(0,U.jsx)(MO,{check:`open`,className:`mt-1.5`}),(0,U.jsx)(`span`,{className:`min-w-0 break-words`,children:e.title})]}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`pending`,e.age?` · saved ${cq(e.age)}`:``]}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:e.id})]}),(0,U.jsx)(Pq,{planId:e.id})]})}function Iq({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=fe();r(!0);try{let r=await R(`tasks.resume`,{taskId:e.id});if(fe()!==n)return;W(r.notice,{action:{label:`View task`,onClick:()=>hB(mB(`tasks`,e.id))}}),t()}catch(e){fe()===n&&W.error(e instanceof Error?e.message:String(e))}finally{i.current&&r(!1)}}let o=e.owner===`not running`;return(0,U.jsx)(SR,{label:o?`Resume: carry it on in a background session`:`Resume: unpause it where it runs`,text:`Resume`,icon:ag,tone:`primary`,shortcut:`R`,disabled:n,onClick:()=>void a()})}function Lq(e){return e instanceof Error?e.message:`That did not work. Try again.`}function Rq({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{W((await e(i)).notice),r(!1),t()}catch(e){l(Lq(e))}finally{s(!1)}}}}function zq({expected:e,value:t,onChange:n,disabled:r}){let i=(0,m.useId)();return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium`,children:`Type the task's title to confirm`}),(0,U.jsx)(`p`,{className:`break-words rounded-md bg-muted px-2 py-1 font-mono text-xs select-all`,children:e}),(0,U.jsx)(CH,{id:i,value:t,disabled:r,autoComplete:`off`,spellCheck:!1,onChange:e=>n(e.target.value)})]})}function Bq(e){let t=Rq(e),n=tO(t.open,eO.confirm),r=e.typeToConfirm!==void 0&&t.typed!==e.typeToConfirm,i=e.tone??`neutral`;return(0,U.jsxs)(GB,{open:t.open&&n,onOpenChange:t.change,children:[(0,U.jsx)(SR,{label:e.label,icon:e.icon,tone:i,onClick:()=>t.change(!0)}),(0,U.jsxs)(JB,{children:[(0,U.jsxs)(YB,{children:[(0,U.jsx)(ZB,{children:e.title}),(0,U.jsx)(QB,{children:e.description})]}),e.typeToConfirm===void 0?null:(0,U.jsx)(zq,{expected:e.typeToConfirm,value:t.typed,onChange:t.setTyped,disabled:t.busy}),t.error?(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:t.error}):null,(0,U.jsxs)(XB,{children:[(0,U.jsx)(eV,{disabled:t.busy,children:`Cancel`}),(0,U.jsx)(X,{variant:i===`danger`?`destructive`:`default`,disabled:r||t.busy,"aria-busy":t.busy,onClick:()=>void t.submit(),children:t.busy?`Working…`:e.confirmLabel})]})]})]})}function Vq({taskId:e,item:t,onDone:n}){let r=n=>()=>R(`tasks.resolveApproval`,{taskId:e,approvalId:t.id,decision:n}),i=`${t.kind}${t.domain?` for ${t.domain}`:``}`;return(0,U.jsxs)(`span`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsx)(Bq,{label:`Approve`,icon:$p,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,U.jsx)(Bq,{label:`Reject`,icon:s_,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 Hq({taskId:e,item:t,live:n,onDone:r}){return(0,U.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 basis-60 gap-2`,children:[(0,U.jsx)(lm,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-warning`}),(0,U.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[t.kind,` `,t.detail]})]}),n&&t.id?(0,U.jsx)(Vq,{taskId:e,item:t,onDone:r}):null]})}function Uq({blockers:e}){return e.map((e,t)=>(0,U.jsxs)(`li`,{className:`flex gap-2`,children:[(0,U.jsx)(xm,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-destructive`}),(0,U.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[e.reason,` (needs: `,e.need,`)`]})]},`${t}-${e.reason}`))}function Wq({row:e,detail:t,onChanged:n}){let r=e.id;return(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.resumable?(0,U.jsx)(Iq,{row:e,onResumed:n}):null,t.canAccept?(0,U.jsx)(Bq,{label:`Accept as is`,icon:Dg,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:()=>R(`tasks.accept`,{taskId:r}),onDone:n}):null,t.canForceClose?(0,U.jsx)(Bq,{label:`Force close`,icon:ym,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=>R(`tasks.forceClose`,{taskId:r,title:e}),onDone:n}):null]})}function Gq({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,U.jsxs)(aV,{title:`Waiting on`,children:[(0,U.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:[a.map((t,i)=>(0,U.jsx)(Hq,{taskId:e.id,item:t,live:r,onDone:n},`${i}-${t.id||t.kind}`)),(0,U.jsx)(Uq,{blockers:t.blockers})]}),i?(0,U.jsx)(Wq,{row:e,detail:t,onChanged:n}):null]})}function Kq(e){if(e.kind===`archived`)return{state:`archived`,rest:cq(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`} ${cq(e.age)}`:``;return{state:sq(e.status,e.paused),rest:[t?``:n,r].filter(Boolean).join(` · `)}}function qq(e){return e?[kO(e.track),e.domains.join(`, `)].filter(Boolean).join(` · `):``}function Jq({row:e}){return e.progress?(0,U.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,U.jsx)(jO,{done:e.progress.done,total:e.progress.total}),(0,U.jsxs)(`span`,{children:[e.progress.done,` of `,e.progress.total,` steps`]})]}):null}function Yq({row:e,task:t}){let n=t?.git?`branch ${t.git.branch}${t.git.from?` · from ${t.git.from}`:``}`:``,{state:r,rest:i}=Kq(e);return(0,U.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(`h2`,{className:`flex items-start gap-2.5 text-lg font-semibold tracking-tight`,children:[(0,U.jsx)(MO,{check:e.check,className:`mt-1.5`}),(0,U.jsxs)(`span`,{className:`sr-only`,children:[rq[e.check],`:`]}),(0,U.jsx)(`span`,{className:e.check===`dropped`?`min-w-0 break-words line-through`:`min-w-0 break-words`,children:e.title})]}),(0,U.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`rounded-md bg-accent px-2 py-0.5 text-xs font-medium text-foreground`,children:r}),i?(0,U.jsx)(`span`,{children:i}):null]}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:[e.id,qq(t),n].filter(Boolean).join(` · `)}),(0,U.jsx)(Jq,{row:e})]})}function Xq({row:e,onGone:t,onChanged:n}){let r=e.id;return{restore:async()=>{await mp(`tasks.restore`,{taskId:r},{undo:()=>void mp(`tasks.archive`,{taskId:r})})&&t()},archive:async()=>{await mp(`tasks.archive`,{taskId:r},{undo:()=>void mp(`tasks.restore`,{taskId:r})})&&t()},remove:async()=>{await mp(`tasks.delete`,{taskId:r,where:e.kind===`archived`?`archive`:`list`})&&t()},toggleAuto:()=>void mp(`tasks.auto`,{taskId:r,on:!e.auto}).then(n)}}function Zq({row:e,archive:t}){return e.check===`open`?(0,U.jsx)(tV,{label:`Archive`,icon:jp,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,U.jsx)(SR,{label:`Archive`,icon:jp,shortcut:`E`,onClick:()=>void t()})}function Qq({on:e,toggle:t}){return bR(`a`,t),(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsxs)(`label`,{className:`flex h-8 cursor-pointer items-center gap-2 rounded-lg px-2.5 text-[0.8125rem] font-medium transition-colors hover:bg-accent`,children:[(0,U.jsx)(lg,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,U.jsx)(`span`,{children:`Auto`}),(0,U.jsx)(wH,{checked:e,onCheckedChange:t,"aria-label":`Auto mode`,"aria-keyshortcuts":`A`}),(0,U.jsx)(GD,{chord:`A`,className:`kbd-hint`})]})}),(0,U.jsx)(nR,{children:`Auto mode: the oracle decides without asking`})]})}function $q(e){let{row:t}=e,{restore:n,archive:r,remove:i,toggleAuto:a}=Xq(e),o=t.kind===`archived`,s=t.kind===`task`&&t.check===`open`&&!!t.resumable;return(0,U.jsxs)(CR,{children:[t.kind===`task`&&t.check===`open`?(0,U.jsx)(Mq,{row:t,quiet:s}):null,o?(0,U.jsx)(SR,{label:`Restore`,icon:pg,shortcut:`R`,onClick:()=>void n()}):null,t.check===`open`&&!o?(0,U.jsx)(Qq,{on:!!t.auto,toggle:a}):null,o?null:(0,U.jsx)(Zq,{row:t,archive:r}),(0,U.jsx)(tV,{icon:Gg,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 eJ(e){let{row:t}=e,n=t.kind===`plan`,r=DB(`tasks.get`,{taskId:t.id},[`tasks`],!n),i=oO(`lobby`).data?.task,a=i?.id===t.id?i:void 0;if(n)return(0,U.jsx)(Fq,{row:t,onGone:e.onGone});let o=t.check===`open`&&t.kind===`task`,s=r.data?r.data.work:t.work;return(0,U.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-5`,"aria-label":t.title,children:[(0,U.jsx)($q,{...e}),(0,U.jsx)(Yq,{row:t,task:a}),r.data?(0,U.jsx)(Gq,{row:t,detail:r.data,onChanged:()=>{r.reload(),e.onChanged()}}):null,(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,U.jsx)(IK,{timing:r.data?.timing??t.timing,...s?{work:s}:{},stopped:t.check!==`open`})}),r.data?.delivery?(0,U.jsx)(XK,{taskId:t.id,title:t.title,delivery:r.data.delivery,onChanged:r.reload},t.id):null,r.data?(0,U.jsx)(Aq,{detail:r.data,finished:!o,...o&&r.data.canSkip?{skip:{taskId:t.id,onSkipped:()=>{r.reload(),e.onChanged()}}}:{}}):null,(0,U.jsx)(tq,{taskId:t.id,finished:!o,canComment:o}),r.data?(0,U.jsx)(jq,{detail:r.data}):null,r.error&&!r.data?(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the plan detail. `,r.error]}):null]})}function tJ({row:e}){return e.check===`open`&&e.progress?(0,U.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground tabular-nums`,children:[(0,U.jsx)(jO,{done:e.progress.done,total:e.progress.total}),(0,U.jsxs)(`span`,{children:[e.progress.done,`/`,e.progress.total]})]}):e.age&&e.check!==`open`?(0,U.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.age}):null}function nJ(e){return e.check===`dropped`?`text-muted-foreground line-through`:e.kind===`archived`||e.check===`done`?`text-muted-foreground`:`text-foreground`}function rJ({row:e}){return(0,U.jsxs)(U.Fragment,{children:[e.check===`open`?(0,U.jsxs)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:[lq(e),e.auto?(0,U.jsxs)(U.Fragment,{children:[` · `,(0,U.jsx)(PO,{})]}):null]}):null,e.kind===`plan`?null:(0,U.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:(0,U.jsx)(IK,{timing:e.timing,...e.work?{work:e.work}:{},stopped:e.check!==`open`})}),e.delivery?(0,U.jsxs)(`span`,{className:`pl-6 text-xs text-foreground`,children:[`Delivery: `,e.delivery.status.replaceAll(`_`,` `),` · open task to review`]}):null]})}function iJ({row:e,selected:t,onSelect:n}){return(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(e.id),className:KU,children:[(0,U.jsxs)(`span`,{className:`flex items-start gap-2 text-sm`,children:[(0,U.jsx)(MO,{check:e.check,className:`mt-0.5`}),(0,U.jsxs)(`span`,{className:`sr-only`,children:[rq[e.check],`:`]}),(0,U.jsx)(`span`,{className:Y(`min-w-0 flex-1 break-words`,nJ(e),t&&`font-medium text-foreground`),children:e.title}),(0,U.jsx)(tJ,{row:e})]}),(0,U.jsx)(rJ,{row:e})]})})}function aJ({rows:e,selectedId:t,onSelect:n}){return(0,U.jsx)(`div`,{className:`flex flex-col pb-2`,children:uq(e).map(({section:e,rows:r})=>(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:JU,children:(0,U.jsx)(KO,{title:nq[e],right:String(r.length),className:`[&>span:first-child]:font-medium [&>span:first-child]:text-muted-foreground`})}),(0,U.jsx)(`ul`,{className:qU,children:r.map(e=>(0,U.jsx)(iJ,{row:e,selected:e.id===t,onSelect:n},`${e.kind}-${e.id}`))})]},e))})}var oJ=()=>hB(mB(`tasks`)),sJ=e=>hB(mB(`tasks`,e));function cJ(){return(0,U.jsxs)(FO,{className:`m-4 flex-1`,children:[(0,U.jsxs)(IO,{children:[(0,U.jsx)(RO,{variant:`icon`,children:(0,U.jsx)(hh,{"aria-hidden":`true`})}),(0,U.jsx)(BO,{children:oq})]}),(0,U.jsx)(X,{onClick:()=>hB(mB(`plan`)),children:`Plan a task`})]})}function lJ({shown:e,count:t,onToggle:n}){return(0,U.jsxs)(`label`,{className:`btn-outline flex h-7 min-w-0 cursor-pointer items-center gap-2 rounded-lg border bg-card px-2 text-xs font-medium transition-[box-shadow]`,children:[(0,U.jsx)(GU,{checked:e,onCheckedChange:n,"aria-label":`Show archived tasks`,className:`size-4`}),`Archived`,(0,U.jsx)(dK,{variant:`secondary`,className:`h-5 px-1.5`,children:t})]})}function uJ({id:e}){let t=RB(),[n,r]=(0,m.useState)(!1),i=DB(`tasks.list`,{},[`tasks`,`plans`]),a=DB(`tasks.archived`,{},[`tasks`]),o=i.data?.rows??[],s=a.data?.rows??[],c=n?[...o,...s]:o,l=e??(t?c[0]?.id:void 0),u=[...c,...s].find(e=>e.id===l&&e.kind===`task`)?.id;if((0,m.useEffect)(()=>(OK(u),()=>OK(void 0)),[u]),!i.data&&i.error)return(0,U.jsx)(TB,{message:`Could not load tasks. ${i.error}`,onRetry:i.reload});if(i.data&&o.length===0&&s.length===0)return(0,U.jsx)(cJ,{});let d=[...c,...s].find(e=>e.id===l),f=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(UB,{title:`Tasks`,count:dq(c),children:(0,U.jsx)(lJ,{shown:n,count:s.length,onToggle:()=>r(e=>!e)})}),i.data?c.length===0?(0,U.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:oq}):(0,U.jsx)(aJ,{rows:c,selectedId:l,onSelect:sJ}):(0,U.jsx)(WB,{})]}),p=d?(0,U.jsx)(eJ,{row:d,onGone:oJ,onChanged:i.reload},d.id):e?(0,U.jsx)(dJ,{}):null;return(0,U.jsx)(HB,{wide:t,list:f,detail:p,open:!!e,onClose:oJ,hint:`Select a task to see its detail.`,describe:`Task detail`})}function dJ(){return(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That task is not on the list any more.`})}var fJ={l:`lobby`,p:`plan`,t:`tasks`,n:`knowledge`,e:`settings`};function pJ(e){if(e.kind===`settings`)return(0,U.jsx)(tG,{});switch(e.tab){case`lobby`:return(0,U.jsx)(HV,{});case`tasks`:return(0,U.jsx)(uJ,{...zV(e.rest)});case`plan`:return(0,U.jsx)(CK,{rest:e.rest});case`knowledge`:return(0,U.jsx)(RV,{rest:e.rest})}}function mJ(e,t){return t.overlay?!0:e===`savePlan`&&!t.saveAvailable}var hJ={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 gJ(e){return e.length===1&&/[a-z]/i.test(e)?`Key${e.toUpperCase()}`:e.length===1&&/[0-9]/.test(e)?`Digit${e}`:hJ[e]}function _J(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=gJ(n);if(!e)return;t.code=e}return t.code?t:void 0}function vJ(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.shiftKey===t.shift&&e.metaKey===t.meta}function yJ(e,t){let n=_J(t);return n?vJ(e,n):!1}function bJ(e,t){for(let n of t)if(yJ(e,n.key))return n.action}function xJ(e,t){for(let n of t)if(yJ(e,n.key))return n.id}function SJ(e){return aR(e.target)||e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||nO()||!!document.querySelector(`[role='dialog'], [role='menu'], [role='listbox']`)}function CJ(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`)dR(e.key===`j`?1:-1);else return!1;return!0}function wJ(e,t){let n=xJ(e,t.tabs),r=bJ(e,t.keys);return!n&&!r?!1:mJ(r,{overlay:!!document.querySelector(`[role='dialog']:not([data-state='closed']), [role='menu']:not([data-state='closed']), [role='listbox']`)||nO(),typing:aR(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 TJ(e,t,n){if(e.key===`Escape`)return Date.now()<n&&e.preventDefault(),0;if(Date.now()<n){let n=fJ[e.key];return n&&(e.preventDefault(),t.onTab(n)),0}return e.key===`g`?Date.now()+1500:(CJ(e,t.tabs,t.onAction,t.onTab)&&e.preventDefault(),0)}function EJ(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`)){bJ(n,e.keys)===`terminal`&&(n.preventDefault(),e.onAction(`terminal`));return}if(!e.insideApp()){bJ(n,e.keys)===`help`&&(n.preventDefault(),e.onAction(`help`));return}let r=!n.altKey&&!n.ctrlKey&&!n.metaKey;if(r&&SJ(n)){t=0;return}if(wJ(n,e)){t=0;return}t=r?TJ(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 DJ=[{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`}],OJ=[{id:`digits`,caps:[`1`,`…`,`9`],help:`jump to a tab in current order`},{id:`help`,caps:[`?`],help:`keyboard shortcuts`},...Object.entries(fJ).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`}],kJ=[{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`]]}],AJ=[{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`}],jJ=[{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 MJ({line:e}){return(0,U.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,U.jsx)(`span`,{className:`flex w-28 shrink-0 items-center`,children:e.caps?(0,U.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:e.caps.map(e=>(0,U.jsx)(zD,{children:e},e))}):(0,U.jsx)(GD,{chord:e.label??``})}),(0,U.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.help})]})}function NJ(){return(0,U.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:`Buttons on a page`}),kJ.map(e=>(0,U.jsxs)(`div`,{className:`flex items-start gap-3 py-1`,children:[(0,U.jsx)(`span`,{className:`w-28 shrink-0 pt-0.5 text-sm font-medium`,children:e.page}),(0,U.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,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsx)(GD,{chord:e}),t]},e))})]},e.id))]})}function PJ({title:e,lines:t}){return(0,U.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:e}),t.map(e=>(0,U.jsx)(MJ,{line:e},e.id))]})}function FJ(e){return e.map(e=>({id:e.action,label:e.label,help:e.help}))}function IJ(e){return e.map(e=>({id:`tab.${e.id}`,label:e.key,help:`jump to the ${e.label} tab`}))}function LJ({open:e,onOpenChange:t,keys:n,tabs:r}){let i=e,a=tO(i,eO.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&&yJ(e,r))&&(e.preventDefault(),t(!1))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n,t,a,i]),(0,U.jsxs)(qD,{open:i&&a,onOpenChange:t,label:`Keys`,className:`max-w-4xl`,children:[(0,U.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-border px-4 py-3`,children:[(0,U.jsx)(`h2`,{"aria-hidden":`true`,className:`text-base font-semibold tracking-tight`,children:`Keyboard shortcuts`}),(0,U.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(GD,{chord:`Esc`}),(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,onClick:()=>t(!1),children:(0,U.jsx)(s_,{"aria-hidden":`true`})})]})]}),(0,U.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,U.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,U.jsx)(PJ,{title:`Everywhere`,lines:FJ(n)}),(0,U.jsx)(PJ,{title:`Jump to a tab`,lines:IJ(r)}),(0,U.jsx)(PJ,{title:`Navigation and editing`,lines:OJ}),(0,U.jsx)(PJ,{title:`Message box`,lines:DJ})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,U.jsx)(PJ,{title:`Lists and panes`,lines:AJ}),(0,U.jsx)(NJ,{}),(0,U.jsx)(PJ,{title:`Questions`,lines:jJ})]})]}),(0,U.jsx)(Bv,{target:o})]})}var RJ=`size-[1.05rem]`;function zJ({hint:e,onHelp:t,className:n,side:r=`top`}){return(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.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,U.jsx)(dh,{"aria-hidden":`true`,className:RJ})})}),(0,U.jsxs)(nR,{side:r,children:[`Keyboard shortcuts `,(0,U.jsx)(GD,{chord:e})]})]})}function BJ({className:e,side:t=`top`}){let n=eH(),r=n?`Unmute prompt sounds`:`Mute prompt sounds`;return(0,U.jsx)(U.Fragment,{children:(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":r,"aria-pressed":n,"aria-describedby":`focused-action-help`,className:e,onClick:()=>QV(!n),children:n?(0,U.jsx)(t_,{"aria-hidden":`true`,className:RJ}):(0,U.jsx)($g,{"aria-hidden":`true`,className:RJ})})}),(0,U.jsx)(nR,{side:t,children:r})]})})}function VJ({className:e,side:t=`top`}){let{theme:n,setTheme:r}=nU(),i=n===`dark`||n===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;return(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.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,U.jsx)(Lg,{"aria-hidden":`true`,className:RJ}):(0,U.jsx)(zh,{"aria-hidden":`true`,className:RJ})})}),(0,U.jsxs)(nR,{side:t,children:[i?`Light mode`:`Dark mode`,` `,(0,U.jsx)(GD,{chord:`D`})]})]})}var HJ=[{id:`light`,label:`Light`},{id:`dark`,label:`Dark`},{id:`system`,label:`System`}];function UJ({className:e,side:t=`top`}){let{theme:n,setTheme:r}=nU();return(0,U.jsxs)(TH,{children:[(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsx)(EH,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Appearance`,className:e,children:(0,U.jsx)(Vh,{"aria-hidden":`true`,className:RJ})})})}),(0,U.jsx)(nR,{side:t,children:`Appearance`})]}),(0,U.jsxs)(DH,{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,U.jsx)(qH,{label:`Mode`,items:HJ,value:n,onChange:e=>r(e),className:`w-full [&>button]:flex-1`}),(0,U.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,U.jsx)(`p`,{className:`px-0.5 text-xs font-medium text-muted-foreground`,children:`Colour theme`}),(0,U.jsx)(`div`,{className:`[&_[role=radiogroup]]:!grid-cols-3 [&_[role=radiogroup]]:gap-1.5`,children:(0,U.jsx)(BU,{})})]}),(0,U.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,U.jsx)(`p`,{className:`px-0.5 text-xs font-medium text-muted-foreground`,children:`Typeface`}),(0,U.jsx)(rU,{kind:`font`,dense:!0})]}),(0,U.jsx)(`a`,{href:`#/settings`,className:`px-0.5 text-xs text-link underline-offset-2 hover:underline`,children:`More in Settings`})]})]})}function WJ({className:e,side:t=`top`}){let n=uH(),r=n?`Turn off desktop notifications`:`Turn on desktop notifications`,i=async()=>{if(n)return fH();let e=await dH();e===`granted`?W.success(`Desktop notifications are on.`):W.error(e===`unsupported`?`This browser cannot show notifications.`:`Notifications are blocked for this page in the browser's settings.`)};return(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":r,"aria-pressed":n,className:e,onClick:()=>void i(),children:n?(0,U.jsx)(Up,{"aria-hidden":`true`,className:RJ}):(0,U.jsx)(Vp,{"aria-hidden":`true`,className:RJ})})}),(0,U.jsx)(nR,{side:t,children:r})]})}function GJ({className:e,side:t=`top`}){let n=x();if(!n.supported)return null;let r=n.on?`Leave full screen`:`Full screen`;return(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":r,"aria-pressed":n.on,className:e,onClick:()=>void n.toggle(),children:n.on?(0,U.jsx)(Lh,{"aria-hidden":`true`,className:RJ}):(0,U.jsx)(Th,{"aria-hidden":`true`,className:RJ})})}),(0,U.jsx)(nR,{side:t,children:r})]})}function KJ(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}async function qJ(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(I(`/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 be(`the lobby answered ${n.status}`,`failed`,n.status);if(!r.ok)throw new be(r.error,r.code,n.status);return r.result}function JJ(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 YJ(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 XJ=/^(\s*)(?:([-*+])|(\d+)([.)]))\s+(\[[ xX]\]\s+)?/;function ZJ(e,t){let n=e.lastIndexOf(`
|
|
97
|
+
.dark { … }`,className:`max-h-56 font-mono text-xs`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.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,U.jsx)(SR,{label:`Save and apply the pasted theme`,text:`Save theme`,icon:$p,tone:`primary`,disabled:!t.trim()||s,onClick:()=>void u(t,`Custom theme`)}),(0,U.jsx)(SR,{label:`Upload a .css or .json theme file`,text:`Upload file`,icon:Zg,disabled:s,onClick:()=>l.current?.click()}),a?(0,U.jsx)(`p`,{role:`alert`,className:`ml-2 min-w-0 text-xs text-destructive`,children:a}):null]})]})}function UU(){let{theme:e,setTheme:t}=tU(),n=$V();return(0,U.jsx)(iV,{prominent:!0,title:pU.appearance,children:(0,U.jsxs)(RH,{children:[(0,U.jsx)(LH,{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,U.jsx)(CH,{checked:!n,onCheckedChange:e=>ZV(!e),"aria-label":`Prompt sounds`})}),(0,U.jsx)(LH,{label:PU.themeLabel,help:PU.appearanceHelp,children:(0,U.jsx)(zH,{value:e,items:PU.themeItems.map(e=>({value:e.id,label:e.label})),label:PU.themeLabel,onChange:e=>t(e)})}),(0,U.jsx)(LH,{label:`Colour theme`,help:`The page's colours, the same in every pi session.`,stacked:!0,children:(0,U.jsx)(zU,{})}),(0,U.jsx)(LH,{label:`Typeface`,help:`The face for the page's text, kept in this browser.`,stacked:!0,children:(0,U.jsx)(nU,{kind:`font`})}),(0,U.jsx)(LH,{label:`Code typeface`,help:`The face for code, paths and commands.`,stacked:!0,children:(0,U.jsx)(nU,{kind:`mono`})}),(0,U.jsx)(LH,{label:`Saved themes`,help:`Themes you imported, kept with pi for every session and project.`,stacked:!0,children:(0,U.jsx)(VU,{})}),(0,U.jsx)(LH,{label:`Import a theme`,stacked:!0,children:(0,U.jsx)(HU,{})})]})})}function WU({className:e,...t}){return(0,U.jsx)(EC,{"aria-keyshortcuts":`Space`,"aria-description":`When focused, press Space to toggle.`,"data-slot":`checkbox`,className:Y(`peer relative flex size-[1.125rem] shrink-0 items-center justify-center rounded-[.25rem] border border-input bg-background bg-clip-padding text-primary-foreground shadow-control transition-[background-color,border-color,box-shadow] duration-150 outline-none before:absolute before:-inset-3 before:content-[''] focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring disabled:cursor-not-allowed disabled:opacity-64 data-[state=checked]:shadow-none dark:bg-input/32 data-[state=checked]:border-primary data-[state=checked]:bg-primary`,e),...t,children:(0,U.jsx)(OC,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center`,children:(0,U.jsx)($p,{"aria-hidden":`true`,className:`size-3`,strokeWidth:3})})})}var GU=`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`,KU=`flex flex-col gap-1 px-2 pb-3`,qU=`px-4 pt-4 pb-1 text-xs font-medium text-muted-foreground`,JU={master:[`master`],designer:[`agents`,`designer`],backend:[`agents`,`backend`],qa:[`agents`,`qa`],scout:[`scout`],researcher:[`researcher`],planner:[`planner`]};function YU(e,t){let n=JU[t].reduce((e,t)=>e[t],e);return{...n.mcpTools?{mcpTools:n.mcpTools}:{},...n.skills?{skills:n.skills}:{}}}function XU(e,t){return JU[e].reduceRight((e,t)=>({[t]:e}),t)}function ZU(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 QU=/^mcp__[A-Za-z0-9_]+__[A-Za-z0-9_]+$/;function $U(e,t){let n=`mcp__${t}__`;return e.startsWith(n)?e.slice(n.length):e}function eW(e){return/^mcp__([A-Za-z0-9_]+?)__/.exec(e)?.[1]??``}function tW({config:e,save:t,agent:n,onAgent:r}){let i=EB(`settings.grants`,{},[]),a=i.data;return(0,U.jsxs)(iV,{prominent:!0,title:pU.grants,children:[(0,U.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:Q.intro}),(0,U.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,13rem)_minmax(0,1fr)] items-start gap-4`,children:[(0,U.jsx)(`nav`,{"aria-label":Q.agents,className:`flex flex-col gap-0.5`,children:rU.map(t=>(0,U.jsxs)(`button`,{type:`button`,"aria-current":t===n,onClick:()=>r(t),className:Y(GU,`min-h-0 gap-0.5 py-2`),children:[(0,U.jsxs)(`span`,{className:`flex items-center gap-2 text-[0.8125rem] font-medium`,children:[(0,U.jsx)(pO,{source:t,className:`size-4 shrink-0 text-muted-foreground`}),iU[t]]}),(0,U.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:ZU(YU(e,t),t)})]},t))}),(0,U.jsxs)(PH,{dense:!0,"aria-label":`${iU[n]} ${Q.cardLabel}`,children:[(0,U.jsx)(iW,{kind:n,grants:YU(e,n),offered:a?.mcpTools,error:i.error,save:t},`tools-${n}`),(0,U.jsx)(aW,{kind:n,grants:YU(e,n),offered:a?.skills,error:i.error,save:t},`skills-${n}`)]})]})]})}function nW({title:e,note:t}){return(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline justify-between gap-x-3 gap-y-1`,children:[(0,U.jsx)(`h4`,{className:`text-sm font-semibold`,children:e}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t})]})}function rW({id:e,name:t,help:n,tag:r,tagTone:i,checked:a,disabled:o,title:s,onChange:c}){return(0,U.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,U.jsx)(WU,{id:e,checked:a,disabled:o,onCheckedChange:e=>c(e===!0),className:`mt-0.5`}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,U.jsx)(`span`,{className:`break-all font-mono text-[0.8125rem]`,children:t}),n?(0,U.jsx)(`span`,{className:`break-words text-xs text-muted-foreground`,children:n}):null]}),r?(0,U.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 iW({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=mU.has(e),p=t=>i(XU(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:eW(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(!QU.test(e)){W.error(Q.badName);return}c(``),d.has(e)||p([...u,e])};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(IH,{className:`gap-1 border-b border-(--frame-panel-border-color) py-2.5`,children:[(0,U.jsx)(nW,{title:Q.tools,note:l?Q.allTools:`${u.length} granted`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f?Q.readOnlyHelp:e===`qa`?Q.qaHelp:Q.toolsHelp})]}),(0,U.jsxs)(FH,{fit:!0,className:`flex flex-col gap-3 py-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-4 px-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:Q.everyTool}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f?Q.everyToolReadOnlyHelp:Q.everyToolHelp})]}),(0,U.jsx)(CH,{checked:l,onCheckedChange:S,"aria-label":`${iU[e]} ${Q.everyTool.toLowerCase()}`})]}),(n?.length??0)>8?(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(Cg,{"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,U.jsx)(SH,{value:a,placeholder:Q.filter,"aria-label":Q.filter,className:`pl-8`,onChange:e=>o(e.target.value)})]}):null,!n&&!r?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Q.looking}):null,r&&!n?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r}):null,n&&n.length===0&&_.length===0?(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[Q.noServers,` `,(0,U.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,U.jsxs)(`div`,{role:`group`,"aria-label":`${t} tools`,className:Y(`flex flex-col gap-0.5`,l&&`opacity-60`),children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1 text-xs font-medium text-muted-foreground`,children:[(0,U.jsx)(WU,{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,U.jsx)(`span`,{className:`font-mono`,children:t||Q.unknownServer}),(0,U.jsxs)(`span`,{children:[i,` of `,n.length]})]}),n.map(t=>{let n=g.has(t.name),r=!x(t);return(0,U.jsx)(rW,{id:`grant-${e}-${t.name}`,name:$U(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,U.jsxs)(`p`,{className:`flex items-center gap-1.5 px-2 text-xs text-warning`,children:[(0,U.jsx)(lm,{"aria-hidden":`true`,className:`size-3.5`}),Q.noToolsWarning]}):null,(0,U.jsxs)(`div`,{hidden:l,className:`flex min-w-0 items-center gap-2 border-t border-(--frame-panel-border-color) pt-3`,children:[(0,U.jsx)(SH,{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,U.jsx)(SR,{label:Q.add,icon:sg,onClick:C})]})]})]})}function aW({kind:e,grants:t,offered:n,error:r,save:i}){if(e===`master`)return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(IH,{className:`gap-1 border-y border-(--frame-panel-border-color) py-2.5`,children:(0,U.jsx)(nW,{title:Q.skills,note:Q.sessionSkills})}),(0,U.jsx)(FH,{fit:!0,className:`py-3`,children:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Q.masterSkills})})]});let a=!t.skills,o=new Set(t.skills??[]),s=t=>i(XU(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,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(IH,{className:`gap-1 border-y border-(--frame-panel-border-color) py-2.5`,children:[(0,U.jsx)(nW,{title:Q.skills,note:a?Q.allSkills:`${o.size} granted`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Q.skillsHelp})]}),(0,U.jsxs)(FH,{fit:!0,className:`flex flex-col gap-3 py-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-4 px-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:Q.everySkill}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Q.everySkillHelp})]}),(0,U.jsx)(CH,{checked:a,onCheckedChange:e=>void s(e?null:(n??[]).map(e=>e.name)),"aria-label":`${iU[e]} ${Q.everySkill.toLowerCase()}`})]}),!n&&!r?(0,U.jsx)(`p`,{className:`px-2 text-sm text-muted-foreground`,children:Q.looking}):null,r&&!n?(0,U.jsx)(`p`,{className:`px-2 text-sm text-muted-foreground`,children:r}):null,n&&n.length===0&&l.length===0?(0,U.jsx)(`p`,{className:`px-2 text-sm text-muted-foreground`,children:Q.noSkillsFound}):null,(0,U.jsxs)(`div`,{role:`group`,"aria-label":`${iU[e]} skills`,className:Y(`flex flex-col gap-0.5`,a&&`opacity-60`),children:[(n??[]).map(t=>(0,U.jsx)(rW,{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,U.jsx)(rW,{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,U.jsxs)(`p`,{className:`flex items-center gap-1.5 px-2 text-xs text-warning`,children:[(0,U.jsx)(lm,{"aria-hidden":`true`,className:`size-3.5`}),Q.noneWarning]}):null]})]})}function oW(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&&FU.has(e)&&(n[r.harness]??=[]).push(e);return n}function sW({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,U.jsx)(SH,{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 cW({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){W.error(`"${i}" is not between 10,000 and 2,000,000 tokens.`),a(r);return}n(Math.round(t))};return(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(SH,{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,U.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 lW({status:e}){let t=!!e.path;return(0,U.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,U.jsx)(dm,{"aria-hidden":`true`,className:`size-3.5`}):(0,U.jsx)(lm,{"aria-hidden":`true`,className:`size-3.5`}),t?`${$.installed}${e.version?` · ${e.version}`:``}`:$.notFound]})}function uW({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,U.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,U.jsxs)(`header`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,U.jsx)(`h3`,{className:`min-w-0 break-words text-sm font-semibold`,children:e.label}),(0,U.jsx)(lW,{status:e})]}),(0,U.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:e.blurb}),(0,U.jsxs)(`p`,{className:`break-words text-xs`,children:[(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[$.usedBy,`: `]}),n.length>0?n.map(e=>iU[e]).join(`, `):(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:$.unused.toLowerCase()})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col divide-y divide-border border-t border-border [&>*]:py-2.5 [&>*:last-child]:pb-0`,children:[(0,U.jsx)(LH,{stacked:!0,label:$.binary,help:$.binaryHelp,children:(0,U.jsx)(sW,{value:a.binaryPath,label:`${e.label} ${$.binary.toLowerCase()}`,placeholder:e.command||`/path/to/agent`,onSave:e=>o({binaryPath:e})})}),(0,U.jsx)(LH,{stacked:!0,label:$.args,help:i===`acp`?$.argsAcpHelp:$.argsHelp,children:(0,U.jsx)(sW,{value:a.launchArgs,label:`${e.label} ${$.args.toLowerCase()}`,placeholder:i===`acp`?`--acp`:`none`,onSave:e=>o({launchArgs:e})})}),c?(0,U.jsx)(LH,{stacked:!0,label:$.home,help:$.homeHelp(c),children:(0,U.jsx)(sW,{value:a.homePath,label:`${e.label} ${$.home.toLowerCase()}`,placeholder:i===`codex`?`~/.codex`:`~/.claude`,onSave:e=>o({homePath:e})})}):null,l.length>0?(0,U.jsx)(LH,{stacked:!0,label:$.provider,help:$.providerHelp,children:(0,U.jsx)(zH,{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,U.jsx)(LH,{stacked:!0,label:$.compact,help:$.compactHelp,children:(0,U.jsx)(cW,{value:a.compactAt,label:`${e.label} ${$.compact.toLowerCase()}`,onSave:e=>o({compactAt:e})})}),i===`antigravity`?(0,U.jsx)(LH,{stacked:!0,label:$.harnessPath,help:$.harnessPathHelp,children:(0,U.jsx)(sW,{value:a.harnessPath,label:`${e.label} ${$.harnessPath.toLowerCase()}`,placeholder:`localharness_external`,onSave:e=>o({harnessPath:e})})}):null,(0,U.jsx)(LH,{stacked:!0,label:$.custom,help:$.customHelp,children:(0,U.jsx)(sW,{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,U.jsxs)(`div`,{className:`flex min-h-0 items-center justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:$.inject}),(0,U.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:$.injectHelp})]}),(0,U.jsx)(CH,{checked:a.injectPrompts,onCheckedChange:e=>o({injectPrompts:e}),"aria-label":`${e.label}: ${$.inject}`})]})]})]})}function dW({config:e,statuses:t,error:n,save:r}){let i=oW(e);return(0,U.jsxs)(iV,{prominent:!0,title:pU.harnesses,children:[(0,U.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:$.intro}),t?(0,U.jsx)(`div`,{className:`grid grid-cols-2 items-start gap-3 xl:grid-cols-3`,children:t.map(t=>(0,U.jsx)(uW,{status:t,config:e,users:i[t.id]??[],save:r},t.id))}):(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n??`Looking for installed harnesses…`})]})}var fW={master:[`master`],designer:[`agents`,`designer`],backend:[`agents`,`backend`],qa:[`agents`,`qa`],scout:[`scout`],researcher:[`researcher`],planner:[`planner`]},pW=[...gU,...vU.map(e=>({id:`panel:${e.id}`,label:e.label,help:yU}))];function mW(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 hW(e,t){return fW[e].reduceRight((e,t)=>({[t]:e}),t)}function gW(e,t){return e.find(e=>e.id===t)?.thinkingLevels??fU}function _W(e,t){return fU[BH(fU,e,Math.max(0,fU.indexOf(t)))]??t}var vW=e=>e>0?`${e} round${e===1?``:`s`}`:`unlimited`;function yW(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:aU,label:oU,help:sU}]:[],...e.none?[{value:aU,label:`none`,help:`Use the primary model`}]:[],...!e.inherit&&!e.none&&e.value===`inherit`?[{value:aU,label:oU,help:sU}]:[],...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:uU}]:[],{value:cU,label:lU,help:uU}],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,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(zH,{value:e.value,items:o,label:e.label,onChange:s}),t?(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,U.jsx)(SH,{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,U.jsx)(SR,{label:`Use this model`,icon:$p,tone:`primary`,onClick:c})]}):null]})}function bW({label:e,help:t,checked:n,onChange:r,name:i}){return(0,U.jsxs)(`div`,{className:`flex min-h-0 items-center justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:e}),t?(0,U.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:t}):null]}),(0,U.jsx)(CH,{checked:n,onCheckedChange:r,"aria-label":i??e})]})}function xW({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,U.jsx)(SH,{value:i,placeholder:n,"aria-label":r,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())}})}function SW({value:e,label:t,onSave:n}){let r=Math.round(e/6e4);return(0,U.jsx)(TW,{label:t,value:String(r),min:1,suffix:`min`,onSave:e=>{let t=Number(e);return!Number.isFinite(t)||t<=0?(W.error(`"${e}" is not a positive number of minutes.`),!1):(n(Math.round(t*6e4)),!0)}})}function CW({value:e,label:t,onSave:n}){return(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-4 gap-y-1.5`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:hU.label}),(0,U.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:hU.help})]}),(0,U.jsx)(`div`,{className:`w-36 shrink-0`,children:(0,U.jsx)(TW,{label:t,value:e?String(e):``,min:hU.min,max:hU.max,step:1e3,placeholder:hU.placeholder,suffix:`tokens`,onSave:e=>{if(e===``)return n(null),!0;let t=Number(e);return!Number.isInteger(t)||t<hU.min||t>hU.max?(W.error(hU.bad(e)),!1):(n(t),!0)}})})]})}function wW({value:e,onSave:t}){return(0,U.jsx)(TW,{label:CU,value:String(e),min:0,max:65535,onSave:e=>!/^\d+$/.test(e)||Number(e)>65535?(W.error(`"${e}" is not a port (0, or 1-65535).`),!1):(t(Number(e)),!0)})}function TW({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,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(SH,{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,U.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 EW({value:e,label:t,onSave:n}){let[r,i]=(0,m.useState)(e);return(0,m.useEffect)(()=>i(e),[e]),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(tV,{rows:2,value:r,"aria-label":t,onChange:e=>i(e.target.value),onBlur:()=>{r.trim()!==e&&n(r.trim())}}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Saved when you leave the field.`})]})}function DW({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,U.jsx)(zH,{value:e,items:i,label:n,onChange:r})}function OW({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?uU:e.current?e.id:`${e.id} · ${$.older}`})),...c?[]:[{value:e,label:e,help:uU}],{value:cU,label:lU,help:uU}],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,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(zH,{value:e,items:l,label:n,onChange:u}),i?(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,U.jsx)(SH,{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,U.jsx)(SR,{label:`Use this model`,icon:$p,tone:`primary`,onClick:d})]}):null]})}function kW(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 fU;let r=e?.models.find(e=>e.efforts.length>0)?.efforts;return r&&r.length>0?r:fU}function AW({kind:e,config:t,models:n,harnesses:r,save:i,onGrants:a}){let o=mW(t,e),s=t=>i(hW(e,t)),c=iU[e],l=o.harness?r.find(e=>e.id===o.harness):void 0,u=!!o.harness,d=o.harnessModel??``,f=u?kW(l,d):gW(n,o.model),p=t=>{if(t===(o.harness??`pi`))return;if(t===`pi`)return void s({harness:`pi`});let n=kW(r.find(e=>e.id===t),``),i={harness:t,harnessModel:``};e!==`scout`&&!n.includes(o.thinking)&&(i.thinking=_W(n,o.thinking)),s(i)},h=t=>{let n=kW(l,t),r={harnessModel:t};e!==`scout`&&!n.includes(o.thinking)&&(r.thinking=_W(n,o.thinking)),s(r)},g=t=>{let r={model:t};e!==`scout`&&!gW(n,t).includes(o.thinking)&&(r.thinking=_W(gW(n,t),o.thinking)),s(r)},_=e!==`scout`&&e!==`researcher`,[v,y]=(0,m.useState)(!1),b=jW(o,e);return(0,U.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,U.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,U.jsxs)(`h3`,{className:`flex min-w-0 items-center gap-2 break-words text-sm font-semibold`,children:[(0,U.jsx)(pO,{source:e,className:`size-4 shrink-0 text-muted-foreground`}),c]}),(0,U.jsx)(NW,{open:v,custom:b,onToggle:()=>y(e=>!e)})]}),FU.has(e)?(0,U.jsx)(DW,{value:o.harness??`pi`,statuses:r,label:`${c} ${$.label.toLowerCase()}`,onChange:p}):null,u?(0,U.jsx)(OW,{value:d,models:l?.models??[],label:`${c} model`,onChange:h}):(0,U.jsx)(yW,{value:o.model,models:n,label:`${c} model`,inherit:e===`master`,onChange:g}),e===`scout`?(0,U.jsx)(MW,{}):(0,U.jsx)(WH,{value:o.thinking,levels:fU,supported:f,recommended:dU[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,U.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:$.effortNote}):null,(0,U.jsx)(bW,{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,U.jsx)(CW,{value:o.compactAt,label:`${c} compact at`,onSave:e=>s({compactAt:e})}):null,(0,U.jsxs)(`div`,{hidden:!v,className:`grid gap-2 border-t border-border pt-2`,children:[u?(0,U.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:$.agentNote}):null,_?(0,U.jsx)(EW,{value:o.instructions??``,label:`${c} instructions`,onSave:e=>s({instructions:e})}):null,(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,U.jsx)(`p`,{className:`min-w-[7rem] flex-1 break-words text-xs text-muted-foreground`,children:ZU(YU(t,e),e)}),(0,U.jsx)(SR,{label:Q.edit,icon:a_,onClick:a})]})]})]})}function jW(e,t){return[t!==`scout`&&t!==`researcher`&&!!e.instructions,e.mcpTools!==void 0,t!==`master`&&e.skills!==void 0].filter(Boolean).length}function MW(){return(0,U.jsxs)(`p`,{className:`flex min-h-[4.5rem] items-center gap-2 text-sm text-muted-foreground`,children:[(0,U.jsx)(Zp,{"aria-hidden":`true`,className:`size-4`}),`Effort `,(0,U.jsx)(`span`,{className:`capitalize`,children:`low`}),` (fixed for scouts)`]})}function NW({open:e,custom:t,onToggle:n}){return(0,U.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,U.jsx)(am,{"aria-hidden":`true`,className:Y(`size-3.5 transition-transform duration-200 ease-snap`,e&&`rotate-90`)}),`More`,t>0?(0,U.jsxs)(`span`,{className:`text-primary`,children:[`· `,t,` customised`]}):null]})}function PW(e,t){return t.startsWith(`panel:`)?e.lobby.panels[t.slice(6)]:e.lobby[t]}function FW({config:e,item:t,save:n}){let r=t.id.startsWith(`panel:`);return(0,U.jsx)(bW,{label:t.label,help:t.help,checked:PW(e,t.id),onChange:e=>{n(r?{lobby:{panels:{[t.id.slice(6)]:e}}}:{lobby:{[t.id]:e}})}})}function IW({config:e,save:t}){let n=e.workflow.gitIsolation;return(0,U.jsx)(iV,{prominent:!0,title:pU.workflow,children:(0,U.jsx)(RH,{children:(0,U.jsx)(LH,{label:OU,help:DU.find(e=>e.id===n)?.help??`enter cycles off, branch, worktree`,children:(0,U.jsx)(zH,{value:n,items:DU.map(e=>({value:e.id,label:e.label})),label:OU,onChange:e=>void t({workflow:{gitIsolation:e}})})})})})}var LW=e=>e?`${e}/`:AU.top;function RW(e){return e.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function zW({replaced:e}){let t=EB(`settings.linters`,{},[]),n=t.data?.linters;return(0,U.jsx)(LH,{label:AU.found,help:e?AU.foundReplaced:AU.foundHelp,children:n?n.length===0?(0,U.jsx)(`p`,{className:`break-words text-sm text-muted-foreground text-right`,children:AU.foundNone}):(0,U.jsx)(`ul`,{"aria-label":AU.found,className:Y(`flex flex-col items-end gap-1.5`,e&&`opacity-60`),children:n.map(e=>(0,U.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm`,children:[(0,U.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.tool}),(0,U.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:LW(e.folder)}),(0,U.jsxs)(`span`,{title:e.installed?void 0:AU.missingHelp,className:Y(`inline-flex shrink-0 items-center gap-1 text-xs`,e.installed?`text-success`:`text-warning`),children:[e.installed?(0,U.jsx)(dm,{"aria-hidden":`true`,className:`size-3.5`}):(0,U.jsx)(lm,{"aria-hidden":`true`,className:`size-3.5`}),e.installed?AU.installed:AU.missing]})]},`${e.tool}:${e.folder}`))}):(0,U.jsx)(`p`,{className:`break-words text-sm text-muted-foreground text-right`,children:t.error?t.error:`Looking…`})})}function BW({config:e,save:t}){let n=e.lint,r=n.mode===`off`,i=n.command.trim().length>0;return(0,U.jsxs)(iV,{prominent:!0,title:pU.lint,children:[(0,U.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:AU.intro}),(0,U.jsxs)(RH,{children:[(0,U.jsx)(LH,{label:AU.mode,help:kU.find(e=>e.id===n.mode)?.help,children:(0,U.jsx)(zH,{value:n.mode,items:kU.map(e=>({value:e.id,label:e.label})),label:AU.mode,onChange:e=>void t({lint:{mode:e}})})}),(0,U.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,U.jsx)(LH,{label:AU.command,help:AU.commandHelp,children:(0,U.jsx)(xW,{value:n.command,label:AU.command,placeholder:AU.commandPlaceholder,onSave:e=>void t({lint:{command:e}})})}),i?(0,U.jsx)(LH,{label:AU.extensions,help:AU.extensionsHelp,children:(0,U.jsx)(xW,{value:n.extensions.join(` `),label:AU.extensions,placeholder:AU.extensionsPlaceholder,onSave:e=>void t({lint:{extensions:RW(e)}})})}):null,(0,U.jsx)(LH,{label:AU.timeout,help:AU.timeoutHelp,children:(0,U.jsx)(SW,{value:n.timeoutMs,label:`Lint ${AU.timeout.toLowerCase()}`,onSave:e=>void t({lint:{timeoutMs:e}})})}),(0,U.jsx)(zW,{replaced:i})]})]})]})}function VW({config:e,save:t}){let n=e.lobby.web;return(0,U.jsx)(iV,{prominent:!0,title:pU.lobby,children:(0,U.jsxs)(RH,{children:[pW.map(n=>(0,U.jsx)(FW,{config:e,item:n,save:t},n.id)),(0,U.jsx)(LH,{label:bU,help:xU,children:(0,U.jsx)(zH,{value:String(e.lobby.maxPlanningRounds),items:SU.map(e=>({value:String(e),label:vW(e)})),label:bU,onChange:e=>void t({lobby:{maxPlanningRounds:Number(e)}})})}),(0,U.jsx)(LH,{label:CU,help:wU,children:(0,U.jsx)(wW,{value:n.port,onSave:e=>void t({lobby:{web:{port:e}}})})}),(0,U.jsx)(bW,{label:TU,help:EU,checked:n.openBrowser,onChange:e=>void t({lobby:{web:{openBrowser:e}}})}),(0,U.jsx)(HW,{})]})})}function HW(){let e=EB(`lobby.retention`,{},[]),t=async t=>{try{await R(`lobby.setRetention`,{enabled:t}),e.reload()}catch(e){W.error(e instanceof Error?e.message:`That did not work. Try again.`)}};return(0,U.jsx)(bW,{label:_U.label,help:e.error?_U.error:_U.help,checked:e.data?.enabled??!1,onChange:e=>void t(e)})}function UW(e){let t=e.indexOf(`/`);return t>0?e.slice(0,t):``}function WW(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 GW({value:e,models:t,classifiers:n,onChange:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),c=WW(t,n),l=UW(e),[u,d]=(0,m.useState)(l),f=e?l:u,p=[...new Set([...c.map(e=>UW(e.id)),...l?[l]:[]])].filter(Boolean).sort(),h=[{value:KW,label:NU.engineJev,help:NU.engineJevHelp},...p.map(e=>{let t=c.filter(t=>UW(t.id)===e),n=t.filter(e=>e.kind===`classifier`).length,r=t.length-n,i=[n?`${n} ${NU.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=>UW(e.id)===f),_=[...g.map(e=>({value:e.id,label:e.id.slice(f.length+1),help:`${e.kind===`classifier`?NU.engineClassifier:NU.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:uU}]:[],{value:cU,label:lU,help:uU}],v=e=>{if(a(!1),e===KW)return d(``),r(``);d(e);let t=c.find(t=>UW(t.id)===e&&t.kind===`classifier`)??c.find(t=>UW(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,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(zH,{value:f||KW,items:h,label:NU.provider,onChange:v}),f?(0,U.jsx)(zH,{value:e||`__custom__`,items:_,label:NU.engineModel,onChange:y}):null,i?(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,U.jsx)(SH,{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,U.jsx)(SR,{label:`Use this model`,icon:$p,tone:`primary`,onClick:b})]}):null]})}var KW=`__jev__`;function qW({config:e,models:t,classifiers:n,save:r}){let i=e.classifier,a=jU.find(e=>e.id===i.provider)?.label,o=!i.engine;return(0,U.jsx)(iV,{prominent:!0,title:pU.classifier,children:(0,U.jsxs)(RH,{children:[(0,U.jsx)(bW,{label:NU.enabled,help:NU.enabledHelp,checked:i.enabled,onChange:e=>void r({classifier:{enabled:e}})}),(0,U.jsx)(LH,{label:NU.engine,help:NU.engineHelp,children:(0,U.jsx)(GW,{value:i.engine,models:t,classifiers:n,onChange:e=>void r({classifier:{engine:e}})})}),o?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(LH,{label:NU.host,children:(0,U.jsx)(zH,{value:i.provider,items:jU.map(e=>({value:e.id,label:e.label})),label:NU.host,onChange:e=>void r({classifier:{provider:e}})})}),(0,U.jsx)(LH,{label:NU.model,help:NU.modelHelp,children:(0,U.jsx)(xW,{value:i.model,label:NU.model,placeholder:`the host's default`,onSave:e=>void r({classifier:{model:e}})})}),(0,U.jsx)(LH,{label:NU.key,help:NU.keyNote,children:(0,U.jsx)(`p`,{className:`break-words text-sm text-muted-foreground text-right`,children:a??i.provider})})]}):null,MU.map(e=>(0,U.jsx)(bW,{label:e.label,help:e.help,checked:i.features[e.id],onChange:t=>void r({classifier:{features:{[e.id]:t}}})},e.id)),(0,U.jsx)(LH,{label:NU.cheap,help:NU.cheapHelp,children:(0,U.jsx)(yW,{value:i.effort.cheapModel,models:t,label:NU.cheap,none:!0,onChange:e=>void r({classifier:{effort:{cheapModel:e}}})})})]})})}function JW(){let e=lH(),t=async e=>{if(!e)return dH();let t=await uH();t===`granted`?W.success(PU.notificationsOn):W.error(t===`unsupported`?PU.notificationsUnsupported:PU.notificationsBlocked)};return(0,U.jsx)(iV,{prominent:!0,title:pU.notifications,children:(0,U.jsx)(RH,{children:(0,U.jsx)(bW,{label:PU.notificationsLabel,help:PU.notificationsHelp,checked:e,onChange:e=>void t(e)})})})}function YW(){let{available:e,install:t}=y(),n=b(),r=x();return(0,U.jsx)(iV,{prominent:!0,title:pU.install,children:(0,U.jsxs)(RH,{children:[(0,U.jsx)(LH,{label:PU.installLabel,help:n?PU.installedNow:PU.installHelp,children:n?null:(0,U.jsx)(`div`,{className:`flex justify-end`,children:(0,U.jsx)(SR,{label:PU.installButton,icon:Fm,tone:`primary`,onClick:()=>e?void t().then(()=>W.success(PU.installDone)):W.warning(PU.installUnavailable)})})}),r.supported?(0,U.jsx)(LH,{label:PU.fullscreenLabel,help:PU.fullscreenHelp,children:(0,U.jsx)(`div`,{className:`flex justify-end`,children:(0,U.jsx)(SR,{label:r.on?PU.fullscreenOn:PU.fullscreenOff,icon:r.on?Lh:Th,pressed:r.on,onClick:()=>void r.toggle()})})}):null]})})}var XW=[`Agents`,`Harnesses`,`Tools & skills`,`Workflow`,`Lobby`,`Classifier`,`Appearance & notifications`],ZW=e=>`settings-${e.split(` `)[0]}`;function QW({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=EB(`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 R(`settings.set`,{patch:e})).config),W.success(PU.saved),!0}catch(e){return W.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,U.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-4 px-6 pt-6 pb-dock`,children:[(0,U.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-x-6 gap-y-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:PU.title}),(0,U.jsx)(`p`,{className:`max-w-xl text-xs text-muted-foreground`,children:PU.intro})]}),(0,U.jsx)(`nav`,{"aria-label":`Settings sections`,className:`min-w-0 max-w-full`,children:(0,U.jsx)(KH,{as:`nav`,label:`Settings sections`,items:XW.map(e=>({id:e,label:e,controls:ZW(e)})),value:i,onChange:a})})]}),(0,U.jsxs)(`div`,{id:ZW(`Agents`),hidden:i!==`Agents`,"aria-hidden":i!==`Agents`,children:[(0,U.jsx)(`h2`,{className:`sr-only`,children:pU.agents}),(0,U.jsx)(`div`,{className:`grid grid-cols-2 items-start gap-3 lg:grid-cols-3`,children:rU.map(n=>(0,U.jsx)(AW,{kind:n,config:e,models:t,harnesses:p,save:g,onGrants:()=>c(n)},n))})]}),(0,U.jsx)(`div`,{id:ZW(`Harnesses`),hidden:i!==`Harnesses`,"aria-hidden":i!==`Harnesses`,children:(0,U.jsx)(dW,{config:e,statuses:l.data?.harnesses,...l.error?{error:l.error}:{},save:g})}),(0,U.jsx)(`div`,{id:ZW(`Tools & skills`),hidden:i!==`Tools & skills`,"aria-hidden":i!==`Tools & skills`,children:(0,U.jsx)(tW,{config:e,save:g,agent:o,onAgent:s})}),(0,U.jsx)(`div`,{id:ZW(`Workflow`),hidden:i!==`Workflow`,"aria-hidden":i!==`Workflow`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,U.jsx)(IW,{config:e,save:g}),(0,U.jsx)(BW,{config:e,save:g})]})}),(0,U.jsx)(`div`,{id:ZW(`Lobby`),hidden:i!==`Lobby`,"aria-hidden":i!==`Lobby`,children:(0,U.jsx)(VW,{config:e,save:g})}),(0,U.jsx)(`div`,{id:ZW(`Classifier`),hidden:i!==`Classifier`,"aria-hidden":i!==`Classifier`,children:(0,U.jsx)(qW,{config:e,models:t,classifiers:n,save:g})}),(0,U.jsx)(`div`,{id:ZW(`Appearance & notifications`),hidden:i!==`Appearance & notifications`,"aria-hidden":i!==`Appearance & notifications`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,U.jsx)(UU,{}),(0,U.jsx)(JW,{}),(0,U.jsx)(YW,{})]})})]})}function $W(){return(0,U.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":PU.loading,children:[0,1,2,3].map(e=>(0,U.jsx)(IB,{shape:`card`,className:`h-48`},e))})}function eG(){let e=EB(`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,U.jsx)(wB,{message:`${PU.loadFailed} ${e.error}`,onRetry:e.reload}):t?(0,U.jsx)(QW,{config:t,models:e.data?.models??[],classifierModels:e.data?.classifierModels??[],onConfig:i}):(0,U.jsx)($W,{})}function tG(){let e=globalThis.DOMParser;if(!e)throw Error(`DOMParser is unavailable`);return new e}var nG=`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'`,rG=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(` `)),iG=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(` `)),aG=new Set(`text search email tel url number password checkbox radio range color date time month week button reset submit`.split(` `)),oG=`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 sG(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 cG(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 lG(e){if(!rG.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`,cG(t.value)):iG.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&&!aG.has(t)&&e.setAttribute(`type`,`text`)}e.localName===`style`&&(e.textContent=cG(e.textContent??``));for(let t of[...e.children])lG(t)}function uG(e,t){try{return dG(e,t??tG())}catch{return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${nG}"><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 dG(e,t){let n=t.parseFromString(e.html,`text/html`);for(let e of[...n.head.children,...n.body.children])lG(e);let r=[...n.head.querySelectorAll(`style`)].map(e=>e.outerHTML).join(``);return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${nG}"><meta name="referrer" content="no-referrer"><style>body{margin:16px;overflow-wrap:anywhere}*{box-sizing:border-box}${oG}${cG(e.css??``).replace(/</g,`\\3c `)}</style>${r}</head><body>${n.body.innerHTML}</body></html>`}function fG({preview:e,label:t,className:n,frameWidth:r,minWidth:i,onOpen:a}){let o=(0,m.useMemo)(()=>uG(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,U.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,U.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,U.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,U.jsx)(`button`,{type:`button`,"data-compact":``,onClick:a,"aria-label":`Expand the mockup: ${t}`,className:`group/open absolute right-2 bottom-2 rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border bg-card/90 px-1.5 py-0.5 text-[0.6875rem] font-medium text-muted-foreground opacity-60 shadow-sm backdrop-blur-sm transition-opacity group-hover/mock:opacity-100 group-focus-visible/open:opacity-100`,children:[(0,U.jsx)(Ch,{"aria-hidden":`true`,className:`size-3`}),`Expand`]})}):null]})}var pG=/\s*\(recommended\)\s*$/i,mG=1024,hG=e=>e.replace(pG,``);function gG(e){return!!(e&&(e.htmlPreview||e.image||e.preview))}function _G({option:e}){let t=hG(e.label);return gG(e)?(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3`,children:[e.htmlPreview?(0,U.jsx)(fG,{preview:e.htmlPreview,label:t,minWidth:mG,className:`h-auto min-h-[18rem] flex-1`}):null,e.image?(0,U.jsx)(`img`,{src:I(e.image),alt:`Mockup: ${t}`,className:`min-h-0 w-full flex-1 rounded-lg border bg-background object-contain`}):null,e.preview?(0,U.jsx)(Mz,{text:e.preview,className:Y(`overflow-auto rounded-lg border bg-background p-4 text-sm`,!e.htmlPreview&&!e.image&&`flex-1`)}):null]}):(0,U.jsx)(`p`,{className:`grid h-full place-items-center p-6 text-sm text-muted-foreground`,children:`No mockup for this option.`})}function vG({options:e,start:t,title:n,picked:r=[],multi:i=!1,onChoose:a,onClose:o,onIndex:s}){let c=Ef(),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,U.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,U.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border px-4 py-3`,children:[(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Back to the question`,title:`Back · Esc`,onClick:()=>o(d),children:(0,U.jsx)(Fh,{"aria-hidden":`true`})}),(0,U.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:n}),(0,U.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,"aria-live":`polite`,children:[d+1,` of `,e.length]}),(0,U.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,U.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,U.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:t+1}),(0,U.jsx)(`span`,{className:`truncate`,children:hG(e.label)}),r.includes(t)?(0,U.jsx)($p,{"aria-label":`picked`,className:`size-3 text-primary`}):null]},t))})]}),(0,U.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,U.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,U.jsxs)(`section`,{id:`mockup-slide-${n}`,role:`tabpanel`,"aria-roledescription":`slide`,"aria-label":`${n+1} of ${e.length}: ${hG(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,U.jsxs)(`div`,{className:`flex items-baseline gap-2 text-sm`,children:[(0,U.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[n+1,`.`]}),(0,U.jsx)(`span`,{className:`font-medium`,children:hG(t.label)}),pG.test(t.label)?(0,U.jsx)(`span`,{className:`text-xs font-medium text-primary`,children:`Recommended`}):null,r.includes(n)?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-primary`,children:[(0,U.jsx)($p,{"aria-hidden":`true`,className:`size-3`}),`picked`]}):null]}),t.description?(0,U.jsx)(Mz,{text:t.description,className:`text-sm text-muted-foreground`}):null,(0,U.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,U.jsx)(_G,{option:t})})]},n))}),d>0?(0,U.jsx)(X,{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,U.jsx)(rm,{"aria-hidden":`true`})}):null,d<h?(0,U.jsx)(X,{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,U.jsx)(am,{"aria-hidden":`true`})}):null]}),(0,U.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,U.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,U.jsx)(KD,{chord:`←→`,children:`option`}),a?(0,U.jsx)(KD,{chord:`Enter`,children:i?y?`unpick`:`pick`:`choose`}):null,(0,U.jsx)(KD,{chord:`Esc`,children:`back`})]}),a&&p?(0,U.jsxs)(X,{type:`button`,onClick:()=>a(d),className:`max-w-full`,children:[i&&y?`Unpick`:i?`Pick`:`Choose`,(0,U.jsx)(`span`,{className:`truncate`,children:hG(p.label)})]}):null]})]})}function yG(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 bG({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,U.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,onKeyDown:e=>yG(e,()=>void d(),()=>{o||r()}),children:[(0,U.jsxs)(`label`,{className:`text-sm`,children:[`Edit message`,(0,U.jsx)(tV,{ref:u,value:i,onChange:e=>a(e.target.value),disabled:o,className:`mt-2 max-h-[40vh] min-h-24`})]}),c?(0,U.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not save. `,c]}):null,(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsx)(X,{size:`sm`,onClick:()=>void d(),disabled:t||o||!i.trim(),children:o?`Saving…`:`Save`}),(0,U.jsx)(X,{size:`sm`,variant:`ghost`,disabled:o,onClick:r,children:`Cancel`})]})]})}var xG=1200;function SG({question:e}){let[t,n]=(0,m.useState)(),r=tO(t!==void 0,eO.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,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`ul`,{"aria-label":`Mockups`,className:`grid grid-cols-3 gap-2`,children:i.map(({option:e,index:t,mockup:r})=>(0,U.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsx)(fG,{preview:r,label:hG(e.label),frameWidth:xG,onOpen:()=>n(t),className:`aspect-[3/2] h-auto`}),(0,U.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[(0,U.jsxs)(`span`,{className:`tabular-nums`,children:[t+1,`.`]}),` `,hG(e.label)]})]},t))}),(0,U.jsx)(qD,{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,U.jsx)(vG,{options:a,start:t,title:e.text,onClose:()=>n(void 0)})})]})}function CG({questions:e}){return(0,U.jsx)(`ol`,{className:`mt-1 flex flex-col gap-2`,children:e.map((e,t)=>(0,U.jsxs)(`li`,{className:`card-flat flex min-w-0 flex-col gap-2 rounded-xl border p-3 text-sm`,style:{"--orb":yO(e.from)},children:[(0,U.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,U.jsxs)(`span`,{className:`mt-px inline-flex shrink-0 items-center gap-1 rounded-full bg-[color-mix(in_oklab,var(--orb)_12%,transparent)] px-2 py-0.5 text-xs font-medium text-[color-mix(in_oklab,var(--orb)_85%,var(--foreground))]`,children:[(0,U.jsx)(pO,{source:e.from,className:`size-3`}),gO(e.from)]}),(0,U.jsxs)(`span`,{className:`min-w-0`,children:[(0,U.jsxs)(`span`,{className:`sr-only`,children:[`Question `,t+1,`: `]}),e.text]})]}),e.options.length?(0,U.jsx)(`ul`,{"aria-label":`Options`,className:`flex flex-wrap gap-1.5`,children:e.options.map(e=>(0,U.jsxs)(`li`,{className:`rounded-lg border border-border bg-muted/60 px-2 py-1 text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label}),e.description?` — ${e.description}`:``]},e.label))}):null,(0,U.jsx)(SG,{question:e})]},t))})}function wG({message:e}){let t=e.decided??[];return t.length?(0,U.jsx)(`ul`,{"aria-label":`Settled for you`,className:`mt-1 flex flex-col gap-1`,children:t.map((e,t)=>(0,U.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,title:`Settled by the classifier, ${Math.round(e.probability*100)}% sure. Comment on the plan to overrule it.`,children:[(0,U.jsx)($p,{"aria-hidden":`true`,className:`mt-[0.1875rem] size-3.5 shrink-0 text-success`}),(0,U.jsxs)(`span`,{className:`min-w-0`,children:[(0,U.jsx)(`span`,{className:Y(`font-medium`,_O(e.from)),children:gO(e.from)}),` `,(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:e.question}),` `,(0,U.jsx)(`span`,{className:`font-medium`,children:e.answer}),(0,U.jsxs)(`span`,{className:`decided-hint`,children:[`auto · `,Math.round(e.probability*100),`% · comment to overrule`]})]})]},t))}):null}function TG({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 R(`planner.editMessage`,{messageIndex:t,at:e.at,text:n});s(r.message)},d=!r&&!e.settled?.length&&!i?(0,U.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>a(!0),className:`chat-action`,children:[(0,U.jsx)(tg,{"aria-hidden":`true`,className:`size-3`}),`Edit`]}):null;return(0,U.jsx)(wO,{time:e.at>0?HO(e.at):void 0,head:!0,note:c.editedAt?`(edited)`:void 0,actions:d,children:i?(0,U.jsx)(bG,{text:c.text,disabled:n,onSave:u,onCancel:()=>a(!1)}):(0,U.jsx)(Mz,{text:c.text})})}function EG({message:e,index:t,busy:n,readOnly:r}){if(e.role===`you`)return(0,U.jsx)(TG,{message:e,index:t,busy:n,readOnly:r});let i=e.questions??[];return(0,U.jsxs)(CO,{source:`PLANNER`,name:`Panel`,time:e.at>0?HO(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,U.jsx)(CG,{questions:i}):(0,U.jsx)(Mz,{text:e.text}),(0,U.jsx)(wG,{message:e})]})}function DG({messages:e,seed:t,busy:n=!1,readOnly:r=!1}){return(0,U.jsxs)(`div`,{className:`chat-column`,role:`log`,"aria-label":`Panel conversation`,children:[t?(0,U.jsx)(TO,{children:t}):null,e.map((e,t)=>(0,U.jsx)(EG,{message:e,index:t,busy:n,readOnly:r},`${e.at}-${t}`)),n?(0,U.jsx)(CO,{source:`PLANNER`,name:`Panel`,head:!0,live:!0,waiting:!0,aside:`the panel is thinking`}):null]})}var OG=`ORACLE`,kG=`No draft yet.`,AG=`The draft appears after the panel's first round.`,jG=`What each seat needs`,MG=[`backend`,`designer`,`qa`,`researcher`],NG={backend:`DEV`,designer:`DESIGN`,qa:`QA`,researcher:`RESEARCH`},PG=`Describe a task in the box below. The panel asks what it needs to know, round by round, until the plan is clear.`,FG={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.`},IG=[{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 LG(e){let t=e.filter(e=>e.member);return`${t.filter(e=>e.seated).length} of ${t.length} seated`}function RG(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 zG(e,t){return`${e} ${t}${e===1?``:`s`}`}function BG(e){return e.round===0&&e.messages.length===0&&!e.busy}function VG(e){let t=e.members.find(e=>e.status===`failed`);if(t)return(t.error??`${NG[t.member]} failed`).split(`
|
|
98
|
+
`)[0]}function HG(e){let t=[],n=VG(e);return e.busy?t.push(RG(e.round,e.limit)):n?t.push(`${n} — Retry runs the round again`):e.questions.length>0&&t.push(`${zG(e.questions.length,`question`)} waiting`),!e.busy&&e.round>0&&t.push(RG(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 UG(e,t){let n=NG[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`:zG(o,`question`)}}function WG(e){let t=e.questions.filter(e=>e.from===OG).length;return[{label:OG,seated:!0,working:e.busy,text:e.busy?`chairing`:t?zG(t,`question`):`·`},...MG.map(t=>UG(t,e))]}function GG({cell:e,intro:t}){let n=t?e.member?e.seated?`seated`:`not seated`:`chairs`:e.text;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`span`,{className:Y(`inline-flex items-center gap-1 font-medium`,e.seated?_O(e.label):`text-muted-foreground`),children:[(0,U.jsx)(pO,{source:e.label,className:`size-3`}),gO(e.label)]}),e.working&&!t?(0,U.jsx)(vB,{className:`size-3`,"aria-hidden":`true`}):null,n===`·`?null:(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:n})]})}function KG({cell:e,intro:t,onToggled:n}){let{member:r}=e,i=`roster-chip inline-flex h-7 items-center gap-1.5 rounded-full border px-2.5 text-xs whitespace-nowrap`;if(!r)return(0,U.jsx)(`li`,{className:Y(i,`border-transparent bg-muted`),children:(0,U.jsx)(GG,{cell:e,intro:t})});let a=async()=>{await mp(`planner.toggleSeat`,{member:r})&&n()};return(0,U.jsx)(`li`,{children:(0,U.jsxs)(`label`,{className:Y(i,`cursor-pointer pl-1.5 transition-colors`,e.seated?`border-border bg-card hover:bg-muted`:`border-dashed border-border text-muted-foreground hover:bg-muted`),children:[(0,U.jsx)(WU,{checked:e.seated,onCheckedChange:()=>void a(),"aria-label":`${gO(e.label)} sits on the panel`,className:`size-3.5 rounded-[4px] [&_svg]:size-2.5`}),(0,U.jsx)(GG,{cell:e,intro:t})]})})}function qG({cells:e,intro:t,onToggled:n,className:r}){return(0,U.jsx)(`ul`,{"aria-label":`Panel`,className:Y(`flex flex-wrap items-center gap-1.5`,r),children:e.map(e=>(0,U.jsx)(KG,{cell:e,intro:t,onToggled:n},e.label))})}function JG({cell:e,onToggled:t}){let{member:n}=e,r=gO(e.label),i=Y(`flex h-full flex-col gap-2 rounded-xl border p-3.5 transition-[background-color,border-color,box-shadow]`,e.seated?`border-[color-mix(in_oklab,var(--orb)_26%,var(--border))] bg-[color-mix(in_oklab,var(--orb)_5%,var(--card))] shadow-card`:`border-dashed border-input bg-transparent`),a=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:Y(`grid size-6 place-items-center rounded-lg bg-[color-mix(in_oklab,var(--orb)_14%,transparent)] text-[color-mix(in_oklab,var(--orb)_85%,var(--foreground))]`,!e.seated&&`opacity-50 grayscale`),children:(0,U.jsx)(pO,{source:e.label,className:`size-3.5`})}),(0,U.jsx)(`span`,{className:Y(`truncate text-sm font-semibold`,e.seated?_O(e.label):`text-muted-foreground`),children:r})]}),n?(0,U.jsx)(WU,{checked:e.seated,onCheckedChange:()=>void YG(n,t),"aria-label":`${r} sits on the panel`}):null]}),(0,U.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:FG[e.label]}),(0,U.jsx)(`span`,{className:Y(`mt-auto text-xs font-medium`,e.seated?`text-foreground`:`text-muted-foreground`),children:n?e.seated?`seated`:`sits this one out`:`always chairs`})]}),o={"--orb":yO(e.label)};return n?(0,U.jsx)(`li`,{style:o,children:(0,U.jsx)(`label`,{className:Y(i,`cursor-pointer`,e.seated?`hover:shadow-[0_0_0_3px_color-mix(in_oklab,var(--orb)_10%,transparent)]`:`hover:bg-muted`),children:a})}):(0,U.jsx)(`li`,{style:o,children:(0,U.jsx)(`div`,{className:i,children:a})})}async function YG(e,t){await mp(`planner.toggleSeat`,{member:e})&&t()}function XG({cells:e,onToggled:t}){return(0,U.jsx)(`ul`,{"aria-label":`Panel`,className:`grid grid-cols-1 gap-3 @lg:grid-cols-2 @4xl:grid-cols-5`,children:e.map(e=>(0,U.jsx)(JG,{cell:e,onToggled:t},e.label))})}function ZG({snap:e}){let t=HG(e),n=!e.busy&&VG(e)!==void 0;return(0,U.jsx)(`p`,{role:`status`,className:n?`inline-flex items-center gap-2 text-sm text-destructive`:`inline-flex items-center gap-2 text-sm text-muted-foreground`,children:t.join(` · `)})}function QG({iconOnly:e}){return(0,U.jsx)(SR,{label:`Previous plans`,text:`Previous`,icon:dg,shortcut:`H`,iconOnly:e,onClick:()=>mB(pB(`plan`,`previous`))})}function $G({snap:e,onDone:t}){let n=oO(`status`).data?.keys.find(e=>e.action===`savePlan`)?.label,r=e=>async()=>{await mp(e,{})&&t()};return(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1 @min-[68rem]:shrink-0`,children:[e.questions.length>0&&!e.busy?(0,U.jsx)(SR,{label:`Answer questions`,icon:Dh,tone:`primary`,shortcut:`A`,onClick:()=>void r(`planner.answer`)()}):null,e.retryable?(0,U.jsx)(SR,{label:`Retry`,icon:hg,shortcut:`R`,onClick:()=>void r(`planner.retry`)()}):null,(0,U.jsx)(QG,{}),(0,U.jsx)(SR,{"data-plan-save":!0,label:`Save the plan`,text:`Save`,icon:xg,shortcut:n??`Ctrl+S`,disabled:!e.draft||e.busy,onClick:()=>void r(`planner.save`)()}),(0,U.jsx)(eV,{icon:qm,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 mp(`planner.new`,{}).then(t)})]})}function eK({snap:e,onDone:t}){return(0,U.jsxs)(`header`,{className:`@container flex shrink-0 flex-col gap-2.5 border-b border-border px-5 pt-3 pb-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,U.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:`Planning`}),(0,U.jsx)(ZG,{snap:e})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2.5 @min-[68rem]:flex-nowrap`,children:[(0,U.jsx)(qG,{cells:WG(e),intro:!1,onToggled:t,className:`order-last basis-full @min-[68rem]:order-none @min-[68rem]:min-w-0 @min-[68rem]:basis-auto`}),(0,U.jsx)($G,{snap:e,onDone:t})]})]})}function tK(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 nK({notes:e}){return(0,U.jsx)(U.Fragment,{children:e.map((e,t)=>(0,U.jsx)(`p`,{className:`ml-6 rounded-lg border border-primary/15 bg-accent px-3 py-1.5 text-sm text-foreground italic`,children:e},t))})}var rK=[],iK=(0,m.memo)(function({row:e,index:t,notes:n,form:r,onComment:i}){let a=e.text.trim(),o=()=>i(t);return(0,U.jsxs)(`li`,{"data-line":t,className:Y(`group/line`,!r&&`[contain-intrinsic-size:auto_2.75rem] [content-visibility:auto]`),children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1`,children:[(0,U.jsx)(`span`,{className:`flex w-4 shrink-0 justify-center pt-3.5`,"aria-hidden":`true`,children:n.length>0?(0,U.jsx)(`span`,{className:`size-2 rounded-full bg-primary`}):null}),(0,U.jsx)(`div`,{className:Y(`min-w-0 flex-1 cursor-pointer rounded-lg px-2 py-1.5 transition-colors hover:bg-muted`,r&&`bg-muted`,e.fenced&&`font-mono text-sm whitespace-pre-wrap break-words`),onClick:e=>!e.target.closest(`a`)&&o(),children:e.fenced?e.text:(0,U.jsx)(Mz,{text:e.text})}),(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/line:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100`,"aria-label":`Comment on this line: ${a}`,onClick:o,children:(0,U.jsx)(kh,{"aria-hidden":`true`})})]}),(0,U.jsx)(nK,{notes:n}),r]})});function aK({draft:e,comments:t,commenting:n,form:r,onComment:i}){let a=(0,m.useMemo)(()=>tK(e),[e]),o=QR(a.length);return(0,U.jsx)(`ul`,{className:`flex flex-col`,"aria-label":`Draft plan lines`,children:a.slice(0,o).map((e,a)=>e.text.trim()?(0,U.jsx)(iK,{row:e,index:a,notes:t.get(e.text.trim())??rK,form:a===n?r:void 0,onComment:i},a):(0,U.jsx)(`li`,{"aria-hidden":`true`,className:`h-2`},a))})}function oK({notes:e}){return e.length===0?null:(0,U.jsx)(iV,{title:jG,children:(0,U.jsx)(`dl`,{className:`flex flex-col gap-2 text-sm`,children:e.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex min-w-0 gap-3`,children:[(0,U.jsx)(`dt`,{className:Y(`w-20 shrink-0 font-medium`,_O(e.from)),children:gO(e.from)}),(0,U.jsx)(`dd`,{className:`min-w-0 flex-1`,children:(0,U.jsx)(Mz,{text:e.text})})]},t))})})}function sK({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,U.jsxs)(`div`,{ref:r,role:`group`,"aria-label":`Comment on this line`,className:`line-comment relative mt-1 mb-2 ml-6 rounded-xl border p-3`,children:[(0,U.jsx)(X,{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 text-muted-foreground`,children:(0,U.jsx)(s_,{"aria-hidden":`true`})}),(0,U.jsx)(rV,{label:`Your comment`,hint:`Enter adds the comment · Esc cancels`,buttonLabel:`Add comment`,onSend:async t=>await mp(`planner.commentLine`,{line:e,text:t.trim()})?(n(t.trim()),!0):!1})]})}function cK({open:e,onClose:t,snap:n,comments:r,onSent:i}){let a=tO(e,eO.sheet),o=(0,m.useRef)(null),[s,c]=(0,m.useState)(),l=(0,m.useMemo)(()=>n.draft?tK(n.draft):[],[n.draft]),u=s===void 0?void 0:l[s]?.text.trim(),d=()=>{let e=s;c(void 0),requestAnimationFrame(()=>o.current?.querySelector(`[data-line="${e}"] button[aria-label^="Comment on this line"]`)?.focus())};return(0,U.jsx)(DB,{open:e&&a,onOpenChange:e=>!e&&t(),children:(0,U.jsxs)(jB,{showCloseButton:!1,side:`right`,"aria-label":`Draft plan`,onEscapeKeyDown:e=>{u!==void 0&&(e.preventDefault(),d())},onCloseAutoFocus:()=>c(void 0),className:`plan-sheet gap-0 data-[side=right]:w-[min(44rem,92vw)] data-[side=right]:sm:max-w-none`,children:[(0,U.jsxs)(MB,{className:`flex-row items-center justify-between gap-3 border-b px-5 py-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,U.jsx)(NB,{className:`text-base font-semibold tracking-tight`,children:`Draft plan`}),(0,U.jsxs)(PB,{className:`text-xs text-muted-foreground`,children:[n.round>0?`${RG(n.round,n.limit)} · `:``,`choose a line to comment on it`]})]}),(0,U.jsx)(OB,{asChild:!0,children:(0,U.jsxs)(X,{variant:`ghost`,size:`sm`,"aria-label":`Close the plan`,title:`Close · Esc`,className:`gap-2 text-muted-foreground`,children:[(0,U.jsx)(s_,{"aria-hidden":`true`}),`Close`,(0,U.jsx)(GD,{chord:`Esc`,className:`kbd-hint`})]})})]}),(0,U.jsxs)(`div`,{ref:o,className:`flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto overscroll-contain px-5 pt-4 pb-8`,children:[n.draft?(0,U.jsx)(aK,{draft:n.draft,comments:r,commenting:u===void 0?void 0:s,form:u===void 0?void 0:(0,U.jsx)(sK,{line:u,onCancel:d,onSent:e=>(i(u,e),d())},s),onComment:c}):(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.busy?AG:kG}),(0,U.jsx)(oK,{notes:n.notes})]}),(0,U.jsx)(Bv,{target:o})]})})}var lK=Uv([`relative inline-flex w-fit shrink-0 items-center justify-center border border-transparent font-medium whitespace-nowrap outline-none transition-shadow`,`focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-64`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-3 [&_svg:not([class*=opacity-])]:opacity-80`],{variants:{variant:{default:`bg-primary text-primary-foreground`,secondary:`bg-accent text-secondary-foreground`,outline:`border-input bg-background text-foreground dark:bg-input/32`,info:`bg-info/8 text-info dark:bg-info/16`,success:`bg-success/8 text-success dark:bg-success/16`,warning:`bg-warning/8 text-warning dark:bg-warning/16`,destructive:`bg-destructive/8 text-destructive dark:bg-destructive/16`},size:{sm:`h-4 min-w-4 gap-1 px-1 text-3xs leading-none`,default:`h-[1.125rem] min-w-[1.125rem] gap-1 px-1 text-xs`,lg:`h-5 min-w-5 gap-1 px-1.5 text-xs`},radius:{default:`rounded-sm`,full:`rounded-full`}},defaultVariants:{variant:`default`,size:`default`,radius:`default`}});function uK({className:e,variant:t,size:n,radius:r,asChild:i=!1,...a}){let o=i?Qv:`span`;return(0,U.jsx)(o,{"data-slot":`badge`,className:Y(lK({variant:t,size:n,radius:r,className:e})),...a})}var dK=()=>mB(pB(`plan`,`previous`)),fK=e=>mB(pB(`plan`,`previous`,e));function pK(e){let t=Date.now()-Date.parse(e);return Number.isFinite(t)?WO(Math.max(0,t)):``}function mK(e,t){return[`${t} message${t===1?``:`s`}`,`round ${e.rounds}`,pK(e.updatedAt)].filter(Boolean).join(` · `)}function hK({plan:e,selected:t}){return(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>fK(e.id),className:GU,children:[(0,U.jsxs)(`span`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(`span`,{className:Y(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title}),e.hasDraft?(0,U.jsx)(uK,{variant:`secondary`,children:`draft`}):null]}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:mK(e,e.messages)})]})})}function gK({id:e,onGone:t}){let n=EB(`planner.previousGet`,{id:e},[`planner`]),r=n.data;if(!r)return n.error?(0,U.jsx)(wB,{message:`Could not load that plan. ${n.error}`,onRetry:n.reload}):null;let i=!!r.archivedAt,a=async()=>{await mp(`planner.previousOpen`,{id:e})&&mB(pB(`plan`))},o=async()=>{await mp(`planner.previousArchive`,{id:e,archived:!i})&&t()},s=async()=>{await mp(`planner.previousDelete`,{id:e})&&t()};return(0,U.jsxs)(`article`,{className:`flex flex-col gap-5`,"aria-label":r.title,children:[(0,U.jsxs)(CR,{children:[(0,U.jsx)(SR,{label:`Carry on planning`,text:`Carry on`,icon:ag,tone:`primary`,shortcut:`C`,onClick:()=>void a()}),(0,U.jsx)(SR,{label:i?`Bring it back from the archive`:`Archive`,text:i?`Unarchive`:`Archive`,icon:i?kp:jp,shortcut:`E`,onClick:()=>void o()}),(0,U.jsx)(eV,{icon:Gg,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,U.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:r.title}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:[i?`archived`:``,mK(r,r.messages.length),r.seed??``].filter(Boolean).join(` · `)})]}),(0,U.jsxs)(iV,{title:`Draft plan`,children:[r.draft?(0,U.jsx)(Mz,{text:r.draft}):(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The panel had not written a draft yet.`}),(0,U.jsx)(oK,{notes:r.notes})]}),(0,U.jsx)(iV,{title:`Conversation`,children:(0,U.jsx)(DG,{messages:r.messages,readOnly:!0})})]})}function _K({id:e}){let t=LB(),[n,r]=(0,m.useState)(!1),i=EB(`planner.previous`,n?{archived:!0}:{},[`planner`]),a=i.data?.plans??[];if(!i.data&&i.error)return(0,U.jsx)(wB,{message:`Could not load the previous plans. ${i.error}`,onRetry:i.reload});let o=(0,U.jsxs)(HB,{title:n?`Archived plans`:`Previous plans`,count:i.data?String(a.length):void 0,children:[(0,U.jsx)(SR,{label:`Back to the current plan`,icon:Fp,iconOnly:!0,onClick:()=>mB(pB(`plan`))}),(0,U.jsx)(SR,{label:n?`Show the previous plans`:`Show the archived plans`,text:n?`Previous`:`Archived`,icon:n?dg:jp,pressed:n,onClick:()=>{r(e=>!e),dK()}})]}),s=i.data?a.length===0?(0,U.jsx)(`p`,{className:`px-4 py-6 text-sm text-muted-foreground`,children:n?`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,U.jsx)(`ul`,{className:Y(KU,`pt-2`),"aria-label":n?`Archived plans`:`Previous plans`,children:a.map(t=>(0,U.jsx)(hK,{plan:t,selected:t.id===e},t.id))}):(0,U.jsx)(UB,{});return(0,U.jsx)(VB,{wide:t,list:(0,U.jsxs)(U.Fragment,{children:[o,s]}),detail:e?(0,U.jsx)(gK,{id:e,onGone:()=>{i.reload(),dK()}},e):null,open:e!==void 0,onClose:dK,hint:`Pick a plan to read it, carry it on, archive it or delete it.`,describe:`A previous plan`})}function vK({limit:e}){return e<=0?null:(0,U.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`flex gap-1`,children:Array.from({length:e},(t,n)=>(0,U.jsx)(`span`,{className:Y(`h-1.5 w-4 rounded-full`,n===e-1?`bg-primary`:`bg-border`)},n))}),(0,U.jsxs)(`span`,{children:[`up to `,e,` rounds, the last the oracle's`]})]})}function yK({snap:e,onDone:t}){let n=WG(e),r=(0,m.useRef)(null);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{ref:r,className:`@container flex-1 overflow-y-auto px-8 pt-10 pb-dock`,children:(0,U.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-8`,children:[(0,U.jsxs)(`header`,{className:`flex flex-col gap-4 @3xl:flex-row @3xl:items-end @3xl:justify-between`,children:[(0,U.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`card-flat grid size-11 shrink-0 place-items-center rounded-xl border text-primary`,children:(0,U.jsx)(_g,{className:`size-5`})}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`Plan with the panel`}),(0,U.jsx)(`p`,{className:`max-w-xl text-sm leading-relaxed text-muted-foreground`,children:PG})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col items-start gap-2 @3xl:items-end`,children:[(0,U.jsx)(QG,{}),(0,U.jsx)(vK,{limit:e.limit})]})]}),(0,U.jsxs)(`section`,{"aria-labelledby":`plan-panel`,className:`flex flex-col gap-3`,children:[(0,U.jsx)(`h3`,{id:`plan-panel`,className:`text-xs text-muted-foreground`,children:(0,U.jsx)(KO,{title:`The panel`,right:LG(n)})}),(0,U.jsx)(XG,{cells:n,onToggled:t})]}),(0,U.jsxs)(`section`,{"aria-labelledby":`plan-steps`,className:`flex flex-col gap-3`,children:[(0,U.jsx)(`h3`,{id:`plan-steps`,className:`text-xs text-muted-foreground`,children:(0,U.jsx)(KO,{title:`How a plan comes together`})}),(0,U.jsx)(`ol`,{className:`grid gap-3 @2xl:grid-cols-2 @4xl:grid-cols-4`,children:IG.map((e,t)=>(0,U.jsxs)(`li`,{className:`card-flat relative flex gap-3 rounded-xl border p-3.5`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-6 shrink-0 place-items-center rounded-full bg-accent text-xs font-semibold text-primary tabular-nums`,children:t+1}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,U.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:e.text})]})]},e.title))})]}),(0,U.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 text-sm text-muted-foreground`,children:[(0,U.jsx)(Np,{"aria-hidden":`true`,className:`size-4 text-primary motion-safe:animate-bounce`}),`Start in the box below.`,(0,U.jsx)(KD,{chord:`/`,children:`write`}),(0,U.jsx)(KD,{chord:`Enter`,children:`send to the panel`})]})]})}),(0,U.jsx)(Bv,{target:r})]})}function bK({snap:e,onOpen:t}){let n=(0,m.useRef)(null);return bR(`v`,()=>n.current?.click()),e.draft?(0,U.jsx)(`div`,{className:`pointer-events-none sticky top-0 z-10 -mt-2 mb-3 flex justify-center`,children:(0,U.jsxs)(`button`,{ref:n,type:`button`,"aria-haspopup":`dialog`,"aria-keyshortcuts":`V`,onClick:t,className:`plan-pill pointer-events-auto inline-flex items-center gap-2 rounded-full border py-1.5 ps-2.5 pe-3 text-sm font-medium shadow-card backdrop-blur-sm`,children:[(0,U.jsx)(Ym,{"aria-hidden":`true`,className:`size-4 text-primary`}),`View plan`,(0,U.jsx)(GD,{chord:`V`,className:`kbd-hint`})]})}):null}function xK({snap:e,reload:t}){let[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(new Map),o=(e,t)=>a(n=>new Map(n).set(e,[...n.get(e)??[],t])),{ref:s,onScroll:c}=cO(`${JSON.stringify(e.messages)}${e.busy}`);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(eK,{snap:e,onDone:t}),(0,U.jsxs)(`div`,{ref:s,onScroll:c,className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-5 pt-5 pb-dock`,children:[(0,U.jsx)(bK,{snap:e,onOpen:()=>r(!0)}),(0,U.jsx)(DG,{messages:e.messages,busy:e.busy})]}),(0,U.jsx)(Bv,{target:s}),(0,U.jsx)(cK,{open:n,onClose:()=>r(!1),snap:e,comments:i,onSent:o})]})}function SK({rest:e=[]}){return e[0]===`previous`?(0,U.jsx)(_K,{id:e[1]}):(0,U.jsx)(CK,{})}function CK(){let e=EB(`planner.get`,{},[`planner`]),t=e.data;if(!t&&e.error)return(0,U.jsx)(wB,{message:`Could not load the plan. ${e.error}`,onRetry:e.reload});if(!t)return(0,U.jsx)(`p`,{role:`status`,className:`p-5 text-sm text-muted-foreground`,children:`Loading the plan…`});let n=BG(t);return(0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:n?(0,U.jsx)(yK,{snap:t,onDone:e.reload}):(0,U.jsx)(xK,{snap:t,reload:e.reload})})}var wK={},TK=new Set;function EK(e){wK=e;for(let e of[...TK])e()}function DK(e){wK.taskId!==e&&EK({...wK,taskId:e})}function OK(e){return TK.add(e),()=>{TK.delete(e)}}function kK(){return(0,m.useSyncExternalStore)(OK,()=>wK,()=>wK)}function AK(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 jK(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 MK(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 NK({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,U.jsxs)(`span`,{className:`tabular-nums break-words`,children:[e.waiting?`Waiting for you · `:``,jK(AK(e,n,t)),` execution`]})}function PK({work:e,timing:t,stopped:n}){let r=e.running&&!n&&!t?.waiting,i=MK(r,e);return(0,U.jsxs)(`span`,{className:`tabular-nums break-words`,"data-work-clock":r?`running`:`stopped`,children:[t?.waiting?`Waiting for you · `:``,`worked `,jK(e.workedMs+i)]})}function FK({timing:e,work:t,stopped:n=!1}){return t?(0,U.jsx)(PK,{work:t,...e?{timing:e}:{},stopped:n}):e?(0,U.jsx)(NK,{timing:e,stopped:n},JSON.stringify(e)):(0,U.jsx)(`span`,{children:`Timing unavailable`})}var IK=`This merges the reviewed commit into main and pushes main, then removes the task worktree after verifying the merge. The task branch is kept.`,LK={pending_approval:`Ready for your review`,deferred:`Saved for later`,in_progress:`Delivery in progress`,successful:`Delivered`,recoverable_failure:`Delivery needs attention`};function RK({delivery:e,title:t}){return(0,U.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,U.jsx)(`p`,{className:`font-medium break-words`,children:t}),(0,U.jsxs)(`dl`,{className:`grid gap-1 break-all text-muted-foreground`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{className:`inline`,children:`Project: `}),(0,U.jsx)(`dd`,{className:`inline`,children:e.project})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{className:`inline`,children:`Repository: `}),(0,U.jsx)(`dd`,{className:`inline`,children:e.repository??`Unavailable — refresh review`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{className:`inline`,children:`Source: `}),(0,U.jsxs)(`dd`,{className:`inline`,children:[e.sourceBranch,` · `,e.sourceCommit??`Commit unavailable`]})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{className:`inline`,children:`Target: `}),(0,U.jsxs)(`dd`,{className:`inline`,children:[`main`,e.targetCommit?` · ${e.targetCommit}`:``]})]})]}),(0,U.jsxs)(`p`,{children:[`Checks: `,e.verification?.checks??`unavailable`]}),(0,U.jsx)(`p`,{children:e.verification?.summary??`Verification unavailable. Refresh the review before delivery.`}),e.verification?(0,U.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 zK({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,U.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,U.jsx)(X,{variant:`outline`,disabled:o,onClick:()=>r(e),children:e===`create_pr`?`Create PR`:a?`Retry worktree cleanup`:`Merge to main`}),(0,U.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,U.jsxs)(`p`,{className:`text-sm text-destructive`,children:[i,` Refresh review after resolving this restriction, then choose the action again.`]}):null]})}async function BK(e,t,n){let r={taskId:t,reviewId:n};return e===`refresh`?R(`tasks.deliveryReview`,{taskId:t}):e===`defer`?R(`tasks.deliveryDefer`,r):R(`tasks.deliver`,{...r,action:e,...e===`merge_main`?{confirmMain:!0}:{}})}function VK({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=fe(),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 HK(e){return e.scope.current===e.identity&&e.project===fe()}function UK(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 BK(r,t.taskId,e.current.reviewId);HK(e)&&(e.setCurrent(n.delivery),t.onChanged())}catch(t){HK(e)&&e.setError(t instanceof Error?t.message:String(t))}finally{n.current=!1,e.scope.current&&e.setBusy(!1)}}}return r}function WK(e){let t=VK(e),n=UK(t,e),r=tO(t.confirm,eO.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 GK({review:e}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Task completion is recorded separately. Nothing is published without your approval.`}),(0,U.jsx)(`p`,{role:`status`,className:`text-sm`,children:e.busy?`Updating delivery…`:e.current.operation?`Operation: ${e.current.operation.stage}`:LK[e.current.status]}),e.current.error||e.error?(0,U.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,U.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.current.cleanupError,` Retry cleanup after resolving it.`]}):null,e.current.operation?.worktreeRemoved?(0,U.jsx)(`p`,{className:`text-sm`,children:`Task worktree removed.`}):null,e.current.result?(0,U.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,U.jsxs)(`span`,{children:[` · `,e.current.result.pullUrl]}):null]}):null]})}function KK({review:e}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,U.jsx)(zK,{action:`create_pr`,delivery:e.current,busy:e.busy,onAction:()=>void e.request(`create_pr`)}),(0,U.jsx)(zK,{action:`merge_main`,delivery:e.current,busy:e.busy,onAction:e.reviewMerge})]}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,U.jsx)(X,{variant:`ghost`,disabled:e.busy,onClick:()=>void e.request(`refresh`),children:`Refresh review`}),(0,U.jsx)(X,{variant:`ghost`,disabled:e.busy||e.terminal,onClick:()=>void e.request(`defer`),children:`Not now`})]})]})}function qK({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.`:IK;return(0,U.jsx)(qD,{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,U.jsxs)(`div`,{className:`grid gap-3 p-4`,children:[(0,U.jsx)(`h3`,{className:`font-medium`,children:t?`Remove task worktree?`:`Merge to main?`}),(0,U.jsx)(`p`,{className:`text-sm`,children:n}),(0,U.jsxs)(`p`,{className:`break-all text-sm text-muted-foreground`,children:[e.current.repository,` · `,e.current.sourceCommit,` → main`]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,U.jsx)(X,{variant:`outline`,onClick:()=>e.setConfirm(!1),children:`Cancel`}),(0,U.jsx)(X,{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 JK({title:e,review:t}){return(0,U.jsxs)(iV,{title:`Completed work · delivery review`,right:LK[t.current.status],children:[(0,U.jsx)(RK,{delivery:t.current,title:e}),(0,U.jsx)(GK,{review:t}),(0,U.jsx)(KK,{review:t}),(0,U.jsx)(qK,{review:t})]})}function YK(e){let t=WK(e);return(0,U.jsx)(JK,{title:e.title,review:t})}var XK={open:Cm,delivered:hm,addressed:dm},ZK={open:`waiting for the owning session`,delivered:`sent to the oracle`,addressed:`plan amended`};function QK({comment:e}){let t=WO(Date.now()-Date.parse(e.createdAt)),n=XK[e.status];return(0,U.jsxs)(`p`,{className:`mt-1 flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,U.jsx)(n,{"aria-hidden":`true`,className:e.status===`addressed`?`size-3.5 text-success`:`size-3.5`}),ZK[e.status],`, `,t,e.editedAt?` (edited)`:``]})}function $K({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,U.jsxs)(`li`,{className:`card-flat min-w-0 rounded-lg border px-3.5 py-2.5`,children:[r?(0,U.jsx)(bG,{text:s.text,onSave:async n=>{let r=await R(`tasks.editComment`,{taskId:t,commentId:e.id,text:n});o(r.comment)},onCancel:()=>i(!1)}):(0,U.jsx)(Mz,{text:s.text}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(QK,{comment:s}),n&&!r?(0,U.jsx)(X,{size:`sm`,variant:`ghost`,onClick:()=>i(!0),children:`Edit`}):null]})]})}function eq({taskId:e,finished:t,canComment:n}){let r=EB(`tasks.comments`,{taskId:e},[`tasks`]),i=oO(`status`),a=r.data?.comments??[],o=a.filter(e=>e.status!==`addressed`).length;return(0,U.jsxs)(`section`,{"aria-labelledby":`comments-${e}`,className:`flex flex-col gap-3`,children:[(0,U.jsx)(`h3`,{id:`comments-${e}`,className:`text-sm`,children:(0,U.jsx)(KO,{title:`Comments`,right:o>0?`${o} open`:void 0})}),a.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?`No comments.`:n?`No comments yet. Comment on the plan in the box below (Markdown and images work); the oracle amends it.`:`No comments yet.`}):(0,U.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:a.map(t=>(0,U.jsx)($K,{taskId:e,comment:t,own:!!(t.by&&t.by===i.data?.sessionId)},`${e}-${t.id}`))})]})}function tq({className:e}){return(0,U.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`working-mark`,className:Y(`working-mark`,e)})}var nq={mine:`This session`,others:`Other sessions`,pending:`Pending`,recent:`Finished`,archived:`Archived`},rq={open:`open`,done:`done`,dropped:`abandoned`},iq={none:{label:`None`,depth:`nothing that runs changed: the engine's checks decide, no QA agent`,tone:`bg-accent text-muted-foreground`},low:{label:`Low`,depth:`a light check: the diff, the nearest tests, done once confident`,tone:`bg-success/10 text-success`},medium:{label:`Medium`,depth:`a standard check: the acceptance criteria and realistic regressions`,tone:`bg-warning/10 text-warning`},high:{label:`High`,depth:`a deep, adversarial review: invariants, recovery and everything the change reaches`,tone:`bg-destructive/10 text-destructive`}};function aq(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 oq=`No tasks yet. Start one from the Lobby tab, or plan one in the Plan tab.`;function sq(e,t){return`${e.replace(/_/g,` `)}${t?` · paused`:``}`}function cq(e){return e===`now`?`just now`:`${e} ago`}function lq(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[sq(e.status,e.paused),t].filter(Boolean).join(` · `)}function uq(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 dq(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 fq=1e3;function pq({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=tO(i,eO.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{W((await R(`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,U.jsxs)(WB,{open:i&&f,onOpenChange:_,children:[(0,U.jsxs)(`button`,{type:`button`,"aria-label":`Skip step ${t+1}`,onClick:()=>_(!0),className:Y(`step-skip -my-0.5 ml-auto inline-flex h-6 shrink-0 items-center gap-1 rounded-md px-1.5 text-xs text-muted-foreground outline-none`,`transition-[opacity,background-color,color,scale] duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:scale-[0.96] motion-reduce:active:scale-100`),children:[(0,U.jsx)(kg,{"aria-hidden":`true`,className:`size-3.5`}),`Skip`]}),(0,U.jsxs)(qB,{children:[(0,U.jsxs)(JB,{children:[(0,U.jsxs)(XB,{children:[`Skip step `,t+1,`?`]}),(0,U.jsx)(ZB,{children:`The oracle is told to carry on without it, and your reason stays with the step in the task's history.`})]}),(0,U.jsx)(`p`,{className:`rounded-md bg-muted px-2.5 py-1.5 text-sm break-words`,children:n}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(`label`,{htmlFor:p,className:`text-sm font-medium`,children:`Why skip it?`}),(0,U.jsx)(tV,{id:p,value:o,autoFocus:!0,required:!0,maxLength:fq,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,U.jsx)(`p`,{id:h,className:`text-xs text-muted-foreground`,children:`A reason is required.`})]}),u?(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:u}):null,(0,U.jsxs)(YB,{children:[(0,U.jsx)($B,{disabled:c,children:`Cancel`}),(0,U.jsx)(X,{disabled:!g||c,"aria-busy":c,onClick:()=>void v(),children:c?`Skipping…`:`Skip step`})]})]})]})}function mq({step:e,stopped:t}){let n=MK(!t,e);return(0,U.jsx)(`span`,{className:`tabular-nums`,children:jK((e.workedMs??0)+n)})}function hq(){return(0,U.jsxs)(`span`,{"aria-hidden":`true`,className:`relative mt-[0.3125rem] grid size-4 shrink-0 place-items-center`,children:[(0,U.jsx)(`span`,{className:`absolute size-2.5 rounded-full bg-primary/30 motion-safe:animate-status-ping`}),(0,U.jsx)(`span`,{className:`size-2 rounded-full bg-primary`})]})}function gq(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,``)}function _q({name:e,className:t}){return(0,U.jsx)(`span`,{"aria-hidden":`true`,className:Y(`grid size-5 shrink-0 place-items-center rounded-md border border-border bg-card`,_O(e),t),children:(0,U.jsx)(pO,{source:e,className:`size-3`})})}function vq({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,U.jsx)(`ul`,{id:e,"aria-label":`Agents on this step`,className:`mt-2 flex flex-col overflow-hidden rounded-lg border border-border bg-card`,children:a.map(e=>{let i=bO({domain:e.domain}),a=!!e.parentRunId&&t.some(t=>t.runId===e.parentRunId),o=Date.parse(e.startedAt),s=gq(e.instruction),c=s&&s.toLowerCase()!==n.trim().toLowerCase()?s:``;return(0,U.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2.5 border-b border-border px-3 py-2 text-xs last:border-b-0`,children:[a?(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`ml-1.5 h-4 w-3 shrink-0 rounded-bl-md border-b border-l border-border`}):null,(0,U.jsx)(_q,{name:i}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:Y(`font-medium`,_O(i)),children:gO(i)}),a?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`child`}):null,(0,U.jsx)(tq,{className:`size-3 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`working`})]}),c?(0,U.jsx)(`span`,{className:`truncate text-muted-foreground`,title:e.instruction,children:c}):null]}),Number.isFinite(o)?(0,U.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:jK(Math.max(0,r-o))}):null]},e.runId)})})}function yq({agents:e,count:t,step:n,stopped:r}){let i=[...new Set(e.map(e=>bO({domain:e.domain})))].slice(0,3);return(0,U.jsxs)(U.Fragment,{children:[i.length>0?(0,U.jsx)(`span`,{className:`flex -space-x-1.5`,children:i.map(e=>(0,U.jsx)(_q,{name:e,className:`size-[1.125rem] ring-2 ring-card`},e))}):null,(0,U.jsxs)(`span`,{children:[t,` `,t===1?`agent`:`agents`,(0,U.jsx)(`span`,{className:`sr-only`,children:` working`})]}),(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground/60`,children:`·`}),(0,U.jsx)(mq,{step:n,stopped:r})]})}var bq=`inline-flex h-6 shrink-0 items-center gap-1.5 rounded-full border border-primary/20 bg-primary/5 pr-2 pl-1 text-xs font-medium text-primary`;function xq(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 Sq({step:e,index:t}){let n=e.skip?xq(e.skip.at):``;return(0,U.jsxs)(`li`,{className:`flex min-w-0 flex-col`,"data-step":`skipped`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5 text-sm`,children:[(0,U.jsx)(ym,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),(0,U.jsxs)(`span`,{className:`shrink-0 text-xs leading-5 text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,U.jsx)(`span`,{className:`min-w-0 break-words text-muted-foreground line-through decoration-muted-foreground/50`,children:e.text}),(0,U.jsx)(`span`,{className:`shrink-0 rounded-md bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground`,children:`skipped`})]}),e.skip?(0,U.jsxs)(`p`,{className:`step-skip-reason mt-1 ml-[3.25rem] border-l-2 border-border pl-2.5 text-xs break-words text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground/80`,children:`Why: `}),e.skip.reason,n?(0,U.jsxs)(`span`,{className:`text-muted-foreground/70`,children:[` · `,n]}):null]}):null]})}function Cq({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)(!1),l=(0,m.useId)(),u=e.status===`done`,d=u?`text-success`:e.status===`current`?`text-primary`:`text-muted-foreground`,f=u?dm:Cm;return e.status===`skipped`?(0,U.jsx)(Sq,{step:e,index:t}):(0,U.jsxs)(`li`,{className:`group/step flex min-w-0 flex-col`,"data-step":i?`active`:e.status,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5 text-sm`,children:[i?(0,U.jsx)(hq,{}):(0,U.jsx)(f,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 ${d}`}),(0,U.jsxs)(`span`,{className:`shrink-0 text-xs leading-5 text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,U.jsx)(`span`,{className:Y(`min-w-0 break-words`,i||e.status===`current`?`text-foreground`:`text-muted-foreground`),children:e.text}),i&&a.length>0?(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":s,"aria-controls":l,onClick:()=>c(e=>!e),className:Y(bq,`-my-0.5 transition-colors outline-none hover:bg-primary/10 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`),children:[(0,U.jsx)(yq,{agents:a,count:o,step:e,stopped:n}),(0,U.jsx)(tm,{"aria-hidden":`true`,className:Y(`size-3 transition-transform duration-200`,s&&`rotate-180`)}),(0,U.jsx)(`span`,{className:`sr-only`,children:` (being worked on now)`})]}):i?(0,U.jsxs)(`span`,{className:Y(bq,`-my-0.5`),children:[(0,U.jsx)(yq,{agents:a,count:o,step:e,stopped:n}),(0,U.jsx)(`span`,{className:`sr-only`,children:` (being worked on now)`})]}):e.status===`current`&&!n?(0,U.jsxs)(`span`,{className:`shrink-0 rounded-md bg-accent px-2 py-0.5 text-xs font-medium`,children:[`next`,(0,U.jsx)(`span`,{className:`sr-only`,children:` (the step up next)`})]}):null,r&&!u&&!n?(0,U.jsx)(pq,{taskId:r.taskId,index:t,text:e.text,onSkipped:r.onSkipped}):null]}),s&&a.length>0?(0,U.jsx)(`div`,{className:`pl-[3.25rem]`,children:(0,U.jsx)(vq,{id:l,agents:a,stepText:e.text})}):null]})}function wq({steps:e,stopped:t,skip:n}){let r=e.filter(e=>e.status===`skipped`).length;return(0,U.jsx)(iV,{title:`Steps`,...r?{right:`${r} skipped`}:{},children:(0,U.jsx)(`ol`,{className:`flex flex-col gap-2`,"aria-label":`Steps`,children:e.map((e,r)=>(0,U.jsx)(Cq,{step:e,index:r,stopped:t,skip:n},`${r}-${e.text}`))})})}function Tq({text:e}){let[t,n]=(0,m.useState)(!1),r=(0,m.useId)();return(0,U.jsxs)(iV,{title:`Full plan`,children:[(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":r,onClick:()=>n(e=>!e),className:`inline-flex min-h-11 w-fit items-center gap-1.5 rounded-md text-sm text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[(0,U.jsx)(am,{"aria-hidden":`true`,className:Y(`size-4 transition-transform duration-200 ease-snap`,t&&`rotate-90`)}),t?`Hide the details`:`Read the details of each step`]}),t?(0,U.jsx)(`div`,{id:r,children:(0,U.jsx)(Mz,{text:e})}):null]})}function Eq({detail:e,finished:t}){return e.plan&&e.planDetails?(0,U.jsx)(Tq,{text:e.planDetails}):e.plan?(0,U.jsx)(iV,{title:`Approved plan`,children:(0,U.jsx)(Mz,{text:e.plan})}):e.proposal?(0,U.jsx)(iV,{title:t?`Proposal`:`Proposal (no plan yet)`,children:(0,U.jsx)(Mz,{text:e.proposal})}):(0,U.jsx)(iV,{title:`Plan`,children:(0,U.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 Dq({amendments:e}){return e.length===0?null:(0,U.jsx)(iV,{title:`Amendments`,children:(0,U.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-sm text-muted-foreground`,children:e.map(e=>(0,U.jsx)(`li`,{className:`break-words`,children:e},e))})})}function Oq({risk:e}){let t=iq[e.risk];return(0,U.jsxs)(iV,{title:`QA risk`,right:aq(e),children:[(0,U.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1 text-sm`,"data-qa-risk":e.risk,children:[(0,U.jsx)(`span`,{className:Y(`rounded-md px-2 py-0.5 text-xs font-medium`,t.tone),children:t.label}),(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:t.depth})]}),e.focusAreas.length>0?(0,U.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-sm text-muted-foreground`,"aria-label":`What QA looks at first`,children:e.focusAreas.map(e=>(0,U.jsx)(`li`,{className:`break-words`,children:e},e))}):null,(0,U.jsxs)(`p`,{className:`text-xs break-words text-muted-foreground`,children:[e.riskFactors.join(` · `),e.qaRequired?` · existing tests ${e.existingTestsLikelySufficient?`likely enough`:`likely not enough`}`:``]})]})}function kq({runs:e}){return e.length===0?null:(0,U.jsx)(iV,{title:`Recent runs`,children:(0,U.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.map((e,t)=>(0,U.jsx)(`li`,{className:`break-words`,children:e},`${t}-${e}`))})})}function Aq({detail:e,finished:t,skip:n}){return(0,U.jsxs)(U.Fragment,{children:[e.steps.length>0?(0,U.jsx)(wq,{steps:e.steps,stopped:t,skip:n}):null,e.request?(0,U.jsx)(iV,{title:`Request`,children:(0,U.jsx)(Mz,{text:e.request})}):null,(0,U.jsx)(Eq,{detail:e,finished:t})]})}function jq({detail:e}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Dq,{amendments:e.amendments}),e.qaRisk?(0,U.jsx)(Oq,{risk:e.qaRisk}):null,(0,U.jsx)(kq,{runs:e.runs})]})}function Mq({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 mB(`#/lobby`);let t=fe(),r=()=>n.current&&fe()===t;try{let t=await R(`tasks.open`,{taskId:e.id});if(!r())return;let n=await R(`status.get`,{});if(!r())return;if(t.sessionId&&t.sessionId===n.sessionId)return mB(`#/lobby`);if(t.sessionId&&!t.key)return W.info(`This task runs in another terminal. Switch to that terminal to work on it.`);if(n.busy)return W.info(`The oracle is working in this window. Stop it first, then open the task in its session.`);await mp(`sessions.switch`,t.key?{key:t.key}:{claimTaskId:e.id})&&r()&&mB(`#/lobby`)}catch(e){r()&&W.error(e instanceof Error?e.message:String(e))}}let i=e.section===`mine`;return(0,U.jsx)(SR,{label:i?`Open in its session: this window`:`Open in its session`,text:`Open in session`,icon:Lp,tone:t?`neutral`:`primary`,shortcut:`S`,onClick:()=>void r()})}function Nq({split:e}){let t=e.after.length>0?`, after ${e.after.map(e=>`part ${e}`).join(` and `)}`:``;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[(0,U.jsxs)(`span`,{className:`font-medium text-primary`,children:[`part `,e.part,` of `,e.of]}),` of one plan that was split into tasks`,t?(0,U.jsx)(`span`,{className:`text-foreground`,children:t}):null]}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.titles.map((t,n)=>(0,U.jsxs)(`span`,{children:[n>0?(0,U.jsx)(`span`,{className:`text-muted-foreground/60`,children:` · `}):null,(0,U.jsxs)(`span`,{className:n+1===e.part?`font-medium text-foreground`:void 0,children:[n+1,`. `,t]})]},`${n}-${t}`))})]})}function Pq({planId:e}){let t=EB(`plans.get`,{planId:e},[`plans`]),n=t.data;return n?(0,U.jsxs)(U.Fragment,{children:[n.issue?(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`from issue #`,n.issue.number,` — `,n.issue.title,n.issue.url?(0,U.jsxs)(`span`,{className:`break-all`,children:[` `,n.issue.url]}):null]}):null,n.split?(0,U.jsx)(Nq,{split:n.split}):null,(0,U.jsx)(iV,{title:`Agreed plan`,children:(0,U.jsx)(Mz,{text:n.brief})})]}):t.error?(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the agreed plan. `,t.error]}):null}function Fq({row:e,onGone:t}){let n=async n=>{await mp(`plans.start`,{planId:e.id,where:n})&&t()},r=async()=>{await mp(`plans.discard`,{planId:e.id})&&t()};return(0,U.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-4`,"aria-label":e.title,children:[(0,U.jsxs)(CR,{children:[(0,U.jsx)(SR,{label:`Start here`,icon:ag,tone:`primary`,shortcut:`S`,onClick:()=>void n(`here`)}),(0,U.jsx)(SR,{label:`Start in a new session`,text:`New session`,icon:jg,shortcut:`N`,onClick:()=>void n(`session`)}),(0,U.jsx)(eV,{icon:Gg,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()})]}),(0,U.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,U.jsxs)(`h2`,{className:`flex items-start gap-2.5 text-lg font-medium`,children:[(0,U.jsx)(MO,{check:`open`,className:`mt-1.5`}),(0,U.jsx)(`span`,{className:`min-w-0 break-words`,children:e.title})]}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`pending`,e.age?` · saved ${cq(e.age)}`:``]}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:e.id})]}),(0,U.jsx)(Pq,{planId:e.id})]})}function Iq({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=fe();r(!0);try{let r=await R(`tasks.resume`,{taskId:e.id});if(fe()!==n)return;W(r.notice,{action:{label:`View task`,onClick:()=>mB(pB(`tasks`,e.id))}}),t()}catch(e){fe()===n&&W.error(e instanceof Error?e.message:String(e))}finally{i.current&&r(!1)}}let o=e.owner===`not running`;return(0,U.jsx)(SR,{label:o?`Resume: carry it on in a background session`:`Resume: unpause it where it runs`,text:`Resume`,icon:ag,tone:`primary`,shortcut:`R`,disabled:n,onClick:()=>void a()})}function Lq(e){return e instanceof Error?e.message:`That did not work. Try again.`}function Rq({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{W((await e(i)).notice),r(!1),t()}catch(e){l(Lq(e))}finally{s(!1)}}}}function zq({expected:e,value:t,onChange:n,disabled:r}){let i=(0,m.useId)();return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium`,children:`Type the task's title to confirm`}),(0,U.jsx)(`p`,{className:`break-words rounded-md bg-muted px-2 py-1 font-mono text-xs select-all`,children:e}),(0,U.jsx)(SH,{id:i,value:t,disabled:r,autoComplete:`off`,spellCheck:!1,onChange:e=>n(e.target.value)})]})}function Bq(e){let t=Rq(e),n=tO(t.open,eO.confirm),r=e.typeToConfirm!==void 0&&t.typed!==e.typeToConfirm,i=e.tone??`neutral`;return(0,U.jsxs)(WB,{open:t.open&&n,onOpenChange:t.change,children:[(0,U.jsx)(SR,{label:e.label,icon:e.icon,tone:i,onClick:()=>t.change(!0)}),(0,U.jsxs)(qB,{children:[(0,U.jsxs)(JB,{children:[(0,U.jsx)(XB,{children:e.title}),(0,U.jsx)(ZB,{children:e.description})]}),e.typeToConfirm===void 0?null:(0,U.jsx)(zq,{expected:e.typeToConfirm,value:t.typed,onChange:t.setTyped,disabled:t.busy}),t.error?(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:t.error}):null,(0,U.jsxs)(YB,{children:[(0,U.jsx)($B,{disabled:t.busy,children:`Cancel`}),(0,U.jsx)(X,{variant:i===`danger`?`destructive`:`default`,disabled:r||t.busy,"aria-busy":t.busy,onClick:()=>void t.submit(),children:t.busy?`Working…`:e.confirmLabel})]})]})]})}function Vq({taskId:e,item:t,onDone:n}){let r=n=>()=>R(`tasks.resolveApproval`,{taskId:e,approvalId:t.id,decision:n}),i=`${t.kind}${t.domain?` for ${t.domain}`:``}`;return(0,U.jsxs)(`span`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsx)(Bq,{label:`Approve`,icon:$p,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,U.jsx)(Bq,{label:`Reject`,icon:s_,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 Hq({taskId:e,item:t,live:n,onDone:r}){return(0,U.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 basis-60 gap-2`,children:[(0,U.jsx)(lm,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-warning`}),(0,U.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[t.kind,` `,t.detail]})]}),n&&t.id?(0,U.jsx)(Vq,{taskId:e,item:t,onDone:r}):null]})}function Uq({blockers:e}){return e.map((e,t)=>(0,U.jsxs)(`li`,{className:`flex gap-2`,children:[(0,U.jsx)(xm,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-destructive`}),(0,U.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[e.reason,` (needs: `,e.need,`)`]})]},`${t}-${e.reason}`))}function Wq({row:e,detail:t,onChanged:n}){let r=e.id;return(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.resumable?(0,U.jsx)(Iq,{row:e,onResumed:n}):null,t.canAccept?(0,U.jsx)(Bq,{label:`Accept as is`,icon:Dg,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:()=>R(`tasks.accept`,{taskId:r}),onDone:n}):null,t.canForceClose?(0,U.jsx)(Bq,{label:`Force close`,icon:ym,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=>R(`tasks.forceClose`,{taskId:r,title:e}),onDone:n}):null]})}function Gq({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,U.jsxs)(iV,{title:`Waiting on`,children:[(0,U.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:[a.map((t,i)=>(0,U.jsx)(Hq,{taskId:e.id,item:t,live:r,onDone:n},`${i}-${t.id||t.kind}`)),(0,U.jsx)(Uq,{blockers:t.blockers})]}),i?(0,U.jsx)(Wq,{row:e,detail:t,onChanged:n}):null]})}function Kq(e){if(e.kind===`archived`)return{state:`archived`,rest:cq(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`} ${cq(e.age)}`:``;return{state:sq(e.status,e.paused),rest:[t?``:n,r].filter(Boolean).join(` · `)}}function qq(e){return e?[kO(e.track),e.domains.join(`, `)].filter(Boolean).join(` · `):``}function Jq({row:e}){return e.progress?(0,U.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,U.jsx)(jO,{done:e.progress.done,total:e.progress.total}),(0,U.jsxs)(`span`,{children:[e.progress.done,` of `,e.progress.total,` steps`]})]}):null}function Yq({row:e,task:t}){let n=t?.git?`branch ${t.git.branch}${t.git.from?` · from ${t.git.from}`:``}`:``,{state:r,rest:i}=Kq(e);return(0,U.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(`h2`,{className:`flex items-start gap-2.5 text-lg font-semibold tracking-tight`,children:[(0,U.jsx)(MO,{check:e.check,className:`mt-1.5`}),(0,U.jsxs)(`span`,{className:`sr-only`,children:[rq[e.check],`:`]}),(0,U.jsx)(`span`,{className:e.check===`dropped`?`min-w-0 break-words line-through`:`min-w-0 break-words`,children:e.title})]}),(0,U.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`rounded-md bg-accent px-2 py-0.5 text-xs font-medium text-foreground`,children:r}),i?(0,U.jsx)(`span`,{children:i}):null]}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:[e.id,qq(t),n].filter(Boolean).join(` · `)}),(0,U.jsx)(Jq,{row:e})]})}function Xq({row:e,onGone:t,onChanged:n}){let r=e.id;return{restore:async()=>{await mp(`tasks.restore`,{taskId:r},{undo:()=>void mp(`tasks.archive`,{taskId:r})})&&t()},archive:async()=>{await mp(`tasks.archive`,{taskId:r},{undo:()=>void mp(`tasks.restore`,{taskId:r})})&&t()},remove:async()=>{await mp(`tasks.delete`,{taskId:r,where:e.kind===`archived`?`archive`:`list`})&&t()},toggleAuto:()=>void mp(`tasks.auto`,{taskId:r,on:!e.auto}).then(n)}}function Zq({row:e,archive:t}){return e.check===`open`?(0,U.jsx)(eV,{label:`Archive`,icon:jp,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,U.jsx)(SR,{label:`Archive`,icon:jp,shortcut:`E`,onClick:()=>void t()})}function Qq({on:e,toggle:t}){return bR(`a`,t),(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsxs)(`label`,{className:`flex h-8 cursor-pointer items-center gap-2 rounded-lg px-2.5 text-[0.8125rem] font-medium transition-colors hover:bg-accent`,children:[(0,U.jsx)(lg,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,U.jsx)(`span`,{children:`Auto`}),(0,U.jsx)(CH,{checked:e,onCheckedChange:t,"aria-label":`Auto mode`,"aria-keyshortcuts":`A`}),(0,U.jsx)(GD,{chord:`A`,className:`kbd-hint`})]})}),(0,U.jsx)(nR,{children:`Auto mode: the oracle decides without asking`})]})}function $q(e){let{row:t}=e,{restore:n,archive:r,remove:i,toggleAuto:a}=Xq(e),o=t.kind===`archived`,s=t.kind===`task`&&t.check===`open`&&!!t.resumable;return(0,U.jsxs)(CR,{children:[t.kind===`task`&&t.check===`open`?(0,U.jsx)(Mq,{row:t,quiet:s}):null,o?(0,U.jsx)(SR,{label:`Restore`,icon:pg,shortcut:`R`,onClick:()=>void n()}):null,t.check===`open`&&!o?(0,U.jsx)(Qq,{on:!!t.auto,toggle:a}):null,o?null:(0,U.jsx)(Zq,{row:t,archive:r}),(0,U.jsx)(eV,{icon:Gg,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 eJ(e){let{row:t}=e,n=t.kind===`plan`,r=EB(`tasks.get`,{taskId:t.id},[`tasks`],!n),i=oO(`lobby`).data?.task,a=i?.id===t.id?i:void 0;if(n)return(0,U.jsx)(Fq,{row:t,onGone:e.onGone});let o=t.check===`open`&&t.kind===`task`,s=r.data?r.data.work:t.work;return(0,U.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-5`,"aria-label":t.title,children:[(0,U.jsx)($q,{...e}),(0,U.jsx)(Yq,{row:t,task:a}),r.data?(0,U.jsx)(Gq,{row:t,detail:r.data,onChanged:()=>{r.reload(),e.onChanged()}}):null,(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,U.jsx)(FK,{timing:r.data?.timing??t.timing,...s?{work:s}:{},stopped:t.check!==`open`})}),r.data?.delivery?(0,U.jsx)(YK,{taskId:t.id,title:t.title,delivery:r.data.delivery,onChanged:r.reload},t.id):null,r.data?(0,U.jsx)(Aq,{detail:r.data,finished:!o,...o&&r.data.canSkip?{skip:{taskId:t.id,onSkipped:()=>{r.reload(),e.onChanged()}}}:{}}):null,(0,U.jsx)(eq,{taskId:t.id,finished:!o,canComment:o}),r.data?(0,U.jsx)(jq,{detail:r.data}):null,r.error&&!r.data?(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the plan detail. `,r.error]}):null]})}function tJ({row:e}){return e.check===`open`&&e.progress?(0,U.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground tabular-nums`,children:[(0,U.jsx)(jO,{done:e.progress.done,total:e.progress.total}),(0,U.jsxs)(`span`,{children:[e.progress.done,`/`,e.progress.total]})]}):e.age&&e.check!==`open`?(0,U.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.age}):null}function nJ(e){return e.check===`dropped`?`text-muted-foreground line-through`:e.kind===`archived`||e.check===`done`?`text-muted-foreground`:`text-foreground`}function rJ({row:e}){return(0,U.jsxs)(U.Fragment,{children:[e.check===`open`?(0,U.jsxs)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:[lq(e),e.auto?(0,U.jsxs)(U.Fragment,{children:[` · `,(0,U.jsx)(PO,{})]}):null]}):null,e.kind===`plan`?null:(0,U.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:(0,U.jsx)(FK,{timing:e.timing,...e.work?{work:e.work}:{},stopped:e.check!==`open`})}),e.delivery?(0,U.jsxs)(`span`,{className:`pl-6 text-xs text-foreground`,children:[`Delivery: `,e.delivery.status.replaceAll(`_`,` `),` · open task to review`]}):null]})}function iJ({row:e,selected:t,onSelect:n}){return(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(e.id),className:GU,children:[(0,U.jsxs)(`span`,{className:`flex items-start gap-2 text-sm`,children:[(0,U.jsx)(MO,{check:e.check,className:`mt-0.5`}),(0,U.jsxs)(`span`,{className:`sr-only`,children:[rq[e.check],`:`]}),(0,U.jsx)(`span`,{className:Y(`min-w-0 flex-1 break-words`,nJ(e),t&&`font-medium text-foreground`),children:e.title}),(0,U.jsx)(tJ,{row:e})]}),(0,U.jsx)(rJ,{row:e})]})})}function aJ({rows:e,selectedId:t,onSelect:n}){return(0,U.jsx)(`div`,{className:`flex flex-col pb-2`,children:uq(e).map(({section:e,rows:r})=>(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:qU,children:(0,U.jsx)(KO,{title:nq[e],right:String(r.length),className:`[&>span:first-child]:font-medium [&>span:first-child]:text-muted-foreground`})}),(0,U.jsx)(`ul`,{className:KU,children:r.map(e=>(0,U.jsx)(iJ,{row:e,selected:e.id===t,onSelect:n},`${e.kind}-${e.id}`))})]},e))})}var oJ=()=>mB(pB(`tasks`)),sJ=e=>mB(pB(`tasks`,e));function cJ(){return(0,U.jsxs)(FO,{className:`m-4 flex-1`,children:[(0,U.jsxs)(IO,{children:[(0,U.jsx)(RO,{variant:`icon`,children:(0,U.jsx)(hh,{"aria-hidden":`true`})}),(0,U.jsx)(BO,{children:oq})]}),(0,U.jsx)(X,{onClick:()=>mB(pB(`plan`)),children:`Plan a task`})]})}function lJ({shown:e,count:t,onToggle:n}){return(0,U.jsxs)(`label`,{className:`btn-outline flex h-7 min-w-0 cursor-pointer items-center gap-2 rounded-lg border bg-card px-2 text-xs font-medium transition-[box-shadow]`,children:[(0,U.jsx)(WU,{checked:e,onCheckedChange:n,"aria-label":`Show archived tasks`,className:`size-4`}),`Archived`,(0,U.jsx)(uK,{variant:`secondary`,className:`h-5 px-1.5`,children:t})]})}function uJ({id:e}){let t=LB(),[n,r]=(0,m.useState)(!1),i=EB(`tasks.list`,{},[`tasks`,`plans`]),a=EB(`tasks.archived`,{},[`tasks`]),o=i.data?.rows??[],s=a.data?.rows??[],c=n?[...o,...s]:o,l=e??(t?c[0]?.id:void 0),u=[...c,...s].find(e=>e.id===l&&e.kind===`task`)?.id;if((0,m.useEffect)(()=>(DK(u),()=>DK(void 0)),[u]),!i.data&&i.error)return(0,U.jsx)(wB,{message:`Could not load tasks. ${i.error}`,onRetry:i.reload});if(i.data&&o.length===0&&s.length===0)return(0,U.jsx)(cJ,{});let d=[...c,...s].find(e=>e.id===l),f=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(HB,{title:`Tasks`,count:dq(c),children:(0,U.jsx)(lJ,{shown:n,count:s.length,onToggle:()=>r(e=>!e)})}),i.data?c.length===0?(0,U.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:oq}):(0,U.jsx)(aJ,{rows:c,selectedId:l,onSelect:sJ}):(0,U.jsx)(UB,{})]}),p=d?(0,U.jsx)(eJ,{row:d,onGone:oJ,onChanged:i.reload},d.id):e?(0,U.jsx)(dJ,{}):null;return(0,U.jsx)(VB,{wide:t,list:f,detail:p,open:!!e,onClose:oJ,hint:`Select a task to see its detail.`,describe:`Task detail`})}function dJ(){return(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That task is not on the list any more.`})}var fJ={l:`lobby`,p:`plan`,t:`tasks`,n:`knowledge`,e:`settings`};function pJ(e){if(e.kind===`settings`)return(0,U.jsx)(eG,{});switch(e.tab){case`lobby`:return(0,U.jsx)(VV,{});case`tasks`:return(0,U.jsx)(uJ,{...RV(e.rest)});case`plan`:return(0,U.jsx)(SK,{rest:e.rest});case`knowledge`:return(0,U.jsx)(LV,{rest:e.rest})}}function mJ(e,t){return t.overlay?!0:e===`savePlan`&&!t.saveAvailable}var hJ={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 gJ(e){return e.length===1&&/[a-z]/i.test(e)?`Key${e.toUpperCase()}`:e.length===1&&/[0-9]/.test(e)?`Digit${e}`:hJ[e]}function _J(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=gJ(n);if(!e)return;t.code=e}return t.code?t:void 0}function vJ(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.shiftKey===t.shift&&e.metaKey===t.meta}function yJ(e,t){let n=_J(t);return n?vJ(e,n):!1}function bJ(e,t){for(let n of t)if(yJ(e,n.key))return n.action}function xJ(e,t){for(let n of t)if(yJ(e,n.key))return n.id}function SJ(e){return aR(e.target)||e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||nO()||!!document.querySelector(`[role='dialog'], [role='menu'], [role='listbox']`)}function CJ(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`)dR(e.key===`j`?1:-1);else return!1;return!0}function wJ(e,t){let n=xJ(e,t.tabs),r=bJ(e,t.keys);return!n&&!r?!1:mJ(r,{overlay:!!document.querySelector(`[role='dialog']:not([data-state='closed']), [role='menu']:not([data-state='closed']), [role='listbox']`)||nO(),typing:aR(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 TJ(e,t,n){if(e.key===`Escape`)return Date.now()<n&&e.preventDefault(),0;if(Date.now()<n){let n=fJ[e.key];return n&&(e.preventDefault(),t.onTab(n)),0}return e.key===`g`?Date.now()+1500:(CJ(e,t.tabs,t.onAction,t.onTab)&&e.preventDefault(),0)}function EJ(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`)){bJ(n,e.keys)===`terminal`&&(n.preventDefault(),e.onAction(`terminal`));return}if(!e.insideApp()){bJ(n,e.keys)===`help`&&(n.preventDefault(),e.onAction(`help`));return}let r=!n.altKey&&!n.ctrlKey&&!n.metaKey;if(r&&SJ(n)){t=0;return}if(wJ(n,e)){t=0;return}t=r?TJ(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 DJ=[{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`}],OJ=[{id:`digits`,caps:[`1`,`…`,`9`],help:`jump to a tab in current order`},{id:`help`,caps:[`?`],help:`keyboard shortcuts`},...Object.entries(fJ).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`}],kJ=[{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`]]}],AJ=[{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`}],jJ=[{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 MJ({line:e}){return(0,U.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,U.jsx)(`span`,{className:`flex w-28 shrink-0 items-center`,children:e.caps?(0,U.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:e.caps.map(e=>(0,U.jsx)(zD,{children:e},e))}):(0,U.jsx)(GD,{chord:e.label??``})}),(0,U.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.help})]})}function NJ(){return(0,U.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:`Buttons on a page`}),kJ.map(e=>(0,U.jsxs)(`div`,{className:`flex items-start gap-3 py-1`,children:[(0,U.jsx)(`span`,{className:`w-28 shrink-0 pt-0.5 text-sm font-medium`,children:e.page}),(0,U.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,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsx)(GD,{chord:e}),t]},e))})]},e.id))]})}function PJ({title:e,lines:t}){return(0,U.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:e}),t.map(e=>(0,U.jsx)(MJ,{line:e},e.id))]})}function FJ(e){return e.map(e=>({id:e.action,label:e.label,help:e.help}))}function IJ(e){return e.map(e=>({id:`tab.${e.id}`,label:e.key,help:`jump to the ${e.label} tab`}))}function LJ({open:e,onOpenChange:t,keys:n,tabs:r}){let i=e,a=tO(i,eO.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&&yJ(e,r))&&(e.preventDefault(),t(!1))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n,t,a,i]),(0,U.jsxs)(qD,{open:i&&a,onOpenChange:t,label:`Keys`,className:`max-w-4xl`,children:[(0,U.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-border px-4 py-3`,children:[(0,U.jsx)(`h2`,{"aria-hidden":`true`,className:`text-base font-semibold tracking-tight`,children:`Keyboard shortcuts`}),(0,U.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(GD,{chord:`Esc`}),(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,onClick:()=>t(!1),children:(0,U.jsx)(s_,{"aria-hidden":`true`})})]})]}),(0,U.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,U.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,U.jsx)(PJ,{title:`Everywhere`,lines:FJ(n)}),(0,U.jsx)(PJ,{title:`Jump to a tab`,lines:IJ(r)}),(0,U.jsx)(PJ,{title:`Navigation and editing`,lines:OJ}),(0,U.jsx)(PJ,{title:`Message box`,lines:DJ})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,U.jsx)(PJ,{title:`Lists and panes`,lines:AJ}),(0,U.jsx)(NJ,{}),(0,U.jsx)(PJ,{title:`Questions`,lines:jJ})]})]}),(0,U.jsx)(Bv,{target:o})]})}var RJ=`size-[1.05rem]`;function zJ({hint:e,onHelp:t,className:n,side:r=`top`}){return(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.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,U.jsx)(dh,{"aria-hidden":`true`,className:RJ})})}),(0,U.jsxs)(nR,{side:r,children:[`Keyboard shortcuts `,(0,U.jsx)(GD,{chord:e})]})]})}function BJ({className:e,side:t=`top`}){let n=$V(),r=n?`Unmute prompt sounds`:`Mute prompt sounds`;return(0,U.jsx)(U.Fragment,{children:(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":r,"aria-pressed":n,"aria-describedby":`focused-action-help`,className:e,onClick:()=>ZV(!n),children:n?(0,U.jsx)(t_,{"aria-hidden":`true`,className:RJ}):(0,U.jsx)($g,{"aria-hidden":`true`,className:RJ})})}),(0,U.jsx)(nR,{side:t,children:r})]})})}function VJ({className:e,side:t=`top`}){let{theme:n,setTheme:r}=tU(),i=n===`dark`||n===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;return(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.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,U.jsx)(Lg,{"aria-hidden":`true`,className:RJ}):(0,U.jsx)(zh,{"aria-hidden":`true`,className:RJ})})}),(0,U.jsxs)(nR,{side:t,children:[i?`Light mode`:`Dark mode`,` `,(0,U.jsx)(GD,{chord:`D`})]})]})}var HJ=[{id:`light`,label:`Light`},{id:`dark`,label:`Dark`},{id:`system`,label:`System`}];function UJ({className:e,side:t=`top`}){let{theme:n,setTheme:r}=tU();return(0,U.jsxs)(wH,{children:[(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsx)(TH,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Appearance`,className:e,children:(0,U.jsx)(Vh,{"aria-hidden":`true`,className:RJ})})})}),(0,U.jsx)(nR,{side:t,children:`Appearance`})]}),(0,U.jsxs)(EH,{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,U.jsx)(KH,{label:`Mode`,items:HJ,value:n,onChange:e=>r(e),className:`w-full [&>button]:flex-1`}),(0,U.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,U.jsx)(`p`,{className:`px-0.5 text-xs font-medium text-muted-foreground`,children:`Colour theme`}),(0,U.jsx)(`div`,{className:`[&_[role=radiogroup]]:!grid-cols-3 [&_[role=radiogroup]]:gap-1.5`,children:(0,U.jsx)(zU,{})})]}),(0,U.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,U.jsx)(`p`,{className:`px-0.5 text-xs font-medium text-muted-foreground`,children:`Typeface`}),(0,U.jsx)(nU,{kind:`font`,dense:!0})]}),(0,U.jsx)(`a`,{href:`#/settings`,className:`px-0.5 text-xs text-link underline-offset-2 hover:underline`,children:`More in Settings`})]})]})}function WJ({className:e,side:t=`top`}){let n=lH(),r=n?`Turn off desktop notifications`:`Turn on desktop notifications`,i=async()=>{if(n)return dH();let e=await uH();e===`granted`?W.success(`Desktop notifications are on.`):W.error(e===`unsupported`?`This browser cannot show notifications.`:`Notifications are blocked for this page in the browser's settings.`)};return(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":r,"aria-pressed":n,className:e,onClick:()=>void i(),children:n?(0,U.jsx)(Up,{"aria-hidden":`true`,className:RJ}):(0,U.jsx)(Vp,{"aria-hidden":`true`,className:RJ})})}),(0,U.jsx)(nR,{side:t,children:r})]})}function GJ({className:e,side:t=`top`}){let n=x();if(!n.supported)return null;let r=n.on?`Leave full screen`:`Full screen`;return(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":r,"aria-pressed":n.on,className:e,onClick:()=>void n.toggle(),children:n.on?(0,U.jsx)(Lh,{"aria-hidden":`true`,className:RJ}):(0,U.jsx)(Th,{"aria-hidden":`true`,className:RJ})})}),(0,U.jsx)(nR,{side:t,children:r})]})}function KJ(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}async function qJ(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(I(`/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 be(`the lobby answered ${n.status}`,`failed`,n.status);if(!r.ok)throw new be(r.error,r.code,n.status);return r.result}function JJ(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 YJ(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 XJ=/^(\s*)(?:([-*+])|(\d+)([.)]))\s+(\[[ xX]\]\s+)?/;function ZJ(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=XJ.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 QJ({rest:e}){let{chat:t}=_B(e);return(0,U.jsx)(`div`,{role:`group`,"aria-label":`Knowledge pane`,className:`flex items-center gap-0.5 rounded-lg bg-muted p-0.5`,children:[`Chat`,`Docs`].map(n=>(0,U.jsx)(`button`,{type:`button`,"aria-pressed":t===(n===`Chat`),onClick:()=>hB(vB(e,n===`Chat`)),className:Y(`h-6 rounded-md border px-2.5 text-xs font-medium outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t===(n===`Chat`)?`btn-outline btn-soft bg-card text-foreground`:`btn-ghost text-muted-foreground hover:text-foreground`),children:n},n))})}function $J(e,t){return Y(`relative inline-flex shrink-0 cursor-pointer items-center justify-center whitespace-nowrap rounded-(--control-radius) border border-transparent text-base outline-none hover:bg-accent data-pressed:bg-accent data-[state=open]:bg-accent aria-expanded:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-64 data-disabled:pointer-events-none data-disabled:opacity-64 pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 [&:active:not([aria-haspopup])]:scale-[0.97] motion-reduce:[&:active:not([aria-haspopup])]:scale-100 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:-mx-0.5 [&_svg[data-composer-control-icon]]:mx-0`,e===`xs`?`h-7 gap-1 px-1.75 font-normal text-muted-foreground/70 text-sm hover:text-foreground/80 sm:h-[1.625rem] sm:text-xs [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5 [&_svg[data-composer-control-chevron]]:ms-0 [&_svg[data-composer-control-chevron]]:-me-1`:`h-7 gap-1.5 px-2.5 font-medium text-secondary-label [&_svg:not([class*='text-'])]:text-muted-foreground hover:text-foreground sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4`,`aria-pressed:bg-accent aria-pressed:text-accent-foreground aria-pressed:hover:bg-accent/80`,t)}function eY(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 R(`projects.open`,{path:r});_e([t]),L(t.id,e)}catch(e){i(e.message)}finally{n(!1)}}}return{opening:t,error:r,open:a}}function tY({path:e,parent:t,busy:n,browse:r}){let[i,a]=(0,m.useState)(e);return(0,m.useEffect)(()=>a(e),[e]),(0,U.jsxs)(`form`,{className:`flex h-9 min-w-0 items-center rounded-md border border-input bg-background shadow-xs transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/20`,onSubmit:e=>{e.preventDefault(),r(i)},children:[(0,U.jsx)(`button`,{type:`button`,"aria-label":`Parent folder`,title:`Parent folder (Backspace)`,disabled:n||!t,onClick:()=>t&&r(t),className:`grid h-full w-9 shrink-0 place-items-center border-r border-input text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:bg-muted disabled:pointer-events-none disabled:opacity-40`,children:(0,U.jsx)(zp,{"aria-hidden":`true`,className:`size-4`})}),(0,U.jsx)(`input`,{"aria-label":`Folder path`,value:i,disabled:n,spellCheck:!1,autoComplete:`off`,onChange:e=>a(e.target.value),className:`h-full min-w-0 flex-1 bg-transparent px-3 font-mono text-[0.8125rem] text-foreground outline-none placeholder:text-muted-foreground disabled:opacity-60`}),(0,U.jsx)(`button`,{type:`submit`,disabled:n||!i.trim(),className:`h-full shrink-0 border-l border-input px-3 text-xs font-medium text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:bg-muted disabled:pointer-events-none disabled:opacity-40`,children:`Go`})]})}function nY(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 rY({data:e,loading:t,busy:n,browse:r}){let i=e?.folders.length??0;return(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-md border border-border`,children:[(0,U.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center justify-between border-b border-border bg-muted/50 px-3 text-[0.7rem] font-medium tracking-wide text-muted-foreground uppercase`,children:[(0,U.jsx)(`span`,{children:`Name`}),(0,U.jsx)(`span`,{className:`normal-case tracking-normal`,children:t?`Loading…`:`${i.toLocaleString()} ${i===1?`folder`:`folders`}${e?.truncated?` (first 2,000)`:``}`})]}),(0,U.jsxs)(`div`,{"aria-label":`Folders`,role:`group`,onKeyDown:t=>nY(t,e?.parent,r),className:`h-64 overflow-y-auto overscroll-contain py-1`,children:[e?.folders.map(e=>{let t=e.name.startsWith(`.`);return(0,U.jsxs)(`button`,{type:`button`,"data-folder":!0,disabled:n,onClick:()=>r(e.path),title:e.path,className:`group/row flex h-8 w-full min-w-0 items-center gap-2.5 px-3 text-left text-[0.8125rem] transition-colors outline-none hover:bg-muted focus-visible:bg-accent focus-visible:text-accent-foreground disabled:opacity-60`,children:[(0,U.jsx)(rh,{"aria-hidden":`true`,className:Y(`size-4 shrink-0`,t?`text-muted-foreground/60`:`text-muted-foreground`)}),(0,U.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate`,t&&`text-muted-foreground`),children:e.name}),(0,U.jsx)(am,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground/0 transition-colors group-hover/row:text-muted-foreground group-focus-visible/row:text-muted-foreground`})]},e.path)}),e&&!i?(0,U.jsx)(`p`,{className:`px-3 py-6 text-center text-xs text-muted-foreground`,children:`No subfolders. You can open this folder.`}):null,e?.truncated?(0,U.jsx)(`p`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:`Only the first 2,000 entries are listed. Enter a path to go further.`}):null]})]})}function iY({tab:e,close:t,busyChanged:n}){let[r,i]=(0,m.useState)(),a=DB(`projects.browse`,r===void 0?{}:{path:r},[]),o=eY(e);return(0,m.useEffect)(()=>n(o.opening),[o.opening,n]),(0,U.jsxs)(`div`,{className:`flex min-h-0 max-h-full w-full flex-col overflow-y-auto`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border px-4 py-3`,children:[(0,U.jsx)(`h2`,{className:`text-[0.9375rem] font-semibold`,children:`Open project folder`}),(0,U.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:`Folders on the machine running bot-lobby. The project opens in a session of its own; this one keeps running, and its project-local extensions stay off until you enable them.`})]}),(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3 p-4`,children:[(0,U.jsx)(tY,{path:a.data?.path??r??``,parent:a.data?.parent,busy:o.opening,browse:i}),(0,U.jsx)(rY,{data:a.data,loading:a.loading,busy:a.loading||o.opening,browse:i}),a.loading?(0,U.jsx)(`p`,{role:`status`,className:`sr-only`,children:`Loading folders…`}):null,a.error||o.error?(0,U.jsx)(`p`,{role:`alert`,className:`break-words text-xs text-destructive`,children:a.error??o.error}):null]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 border-t border-border bg-muted/30 px-4 py-3`,children:[a.error?(0,U.jsx)(X,{variant:`outline`,onClick:a.reload,disabled:a.loading,children:`Retry`}):null,(0,U.jsx)(X,{variant:`outline`,onClick:t,disabled:o.opening,children:`Cancel`}),(0,U.jsx)(X,{disabled:!a.data||a.loading||!!a.error||o.opening,onClick:()=>void o.open(a.data.path),children:o.opening?`Opening project…`:`Open this folder`})]})]})}function aY({open:e,onClose:t,tab:n}){let r=tO(e,eO.help),[i,a]=(0,m.useState)(!1);return(0,U.jsx)(qD,{open:r,label:`Open project folder`,className:`max-w-[40rem]`,onOpenChange:e=>{!e&&!i&&t()},dismissOnBackdrop:!i,onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[role="combobox"][aria-label="Project"]`)?.focus()},children:e?(0,U.jsx)(iY,{tab:n,close:t,busyChanged:a}):null})}function oY(){try{return{id:fe()}}catch(e){return{error:e.message}}}function sY(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 cY(){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 R(`projects.list`,{});_e(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 lY({data:e,error:t}){let n=oY();return n.error??t??sY(e,n.id)}function uY({projects:e}){let t=lY(e);return t?(0,U.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,U.jsx)(qg,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,U.jsx)(`span`,{children:t})]}):null}function dY(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']`)];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 fY=`bot-lobby:open-projects`;function pY({projects:e,tab:t,name:n,branch:r}){let{data:i,busy:a,slow:o,refresh:s}=e,[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=oY(),p=lY(e),h=f.error?`invalid`:f.id??i?.currentId??``;bR(`p`,()=>l(!0)),(0,m.useEffect)(()=>{let e=()=>l(!0);return window.addEventListener(fY,e),()=>window.removeEventListener(fY,e)},[]),bR(`r`,()=>void s(),{enabled:c,inDialog:!0});function g(e){l(!1),e!==h&&L(e,t)}return(0,U.jsxs)(`div`,{"aria-busy":a,className:`flex min-w-0 items-center gap-1`,children:[(0,U.jsxs)(TH,{open:c,onOpenChange:l,children:[(0,U.jsxs)(EH,{type:`button`,role:`combobox`,"aria-label":`Project`,"aria-description":`${n}${r?`, branch ${r}`:``}`,"aria-haspopup":`listbox`,"aria-expanded":c,"aria-keyshortcuts":`P ArrowDown`,onKeyDown:e=>{e.key!==`ArrowDown`||e.altKey||e.metaKey||e.ctrlKey||(e.preventDefault(),l(!0))},title:r?`${n} · ${r}`:n,className:Y(`group flex min-w-0 items-center outline-none transition-colors duration-150 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none`,$J(`xs`,`min-w-0 justify-start`)),children:[(0,U.jsx)(rh,{"aria-hidden":`true`,className:Y(`size-3 shrink-0`,p&&`text-destructive`)}),(0,U.jsx)(`span`,{className:`truncate`,children:n}),(0,U.jsx)(tm,{"aria-hidden":`true`,className:`size-3 shrink-0 opacity-50`})]}),(0,U.jsxs)(DH,{align:`start`,side:`top`,sideOffset:8,"aria-label":`Projects`,onKeyDown:dY,onOpenAutoFocus:e=>{let t=e.currentTarget?.querySelector(`[role='option'][aria-selected='true']`)??e.currentTarget?.querySelector(`[role='option']`);t&&(e.preventDefault(),t.focus())},className:`p-0 flex max-h-[calc(100svh-2rem)] w-[min(26rem,calc(100vw-1.5rem))] origin-(--radix-popover-content-transform-origin) flex-col overflow-hidden rounded-xl outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,U.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Running projects`}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>void s(),disabled:a,"aria-label":`Refresh list`,"aria-keyshortcuts":`R`,className:`inline-flex h-7 items-center gap-1.5 rounded-lg px-2 text-xs 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 disabled:opacity-60`,children:[a?(0,U.jsx)(yB,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):(0,U.jsx)(lg,{"aria-hidden":`true`,className:`size-3`}),`Refresh`,(0,U.jsx)(GD,{chord:`R`,className:`kbd-hint`})]})]}),(0,U.jsx)(`div`,{role:`listbox`,"aria-label":`Projects`,className:`flex max-h-72 flex-col overflow-y-auto overscroll-contain p-1`,children:i?.projects.map(e=>{let t=e.id===h;return(0,U.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>g(e.id),className:Y(`flex min-h-10 w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left outline-none transition-colors hover:bg-muted focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t&&`bg-accent`),children:[(0,U.jsx)(`span`,{className:`flex h-5 w-4 shrink-0 items-center justify-center`,children:t?(0,U.jsx)($p,{"aria-hidden":`true`,className:`size-3.5 text-primary`}):null}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block whitespace-normal break-words text-sm font-medium`,children:e.name}),(0,U.jsxs)(`span`,{className:`block whitespace-normal break-all text-xs text-muted-foreground`,children:[e.cwd,` · :`,e.port]})]})]},e.id)})}),(0,U.jsxs)(`button`,{type:`button`,className:`flex min-h-11 items-center gap-2 border-t border-border px-3 py-3 text-sm font-medium outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,onClick:()=>{l(!1),d(!0)},children:[(0,U.jsx)(th,{"aria-hidden":`true`,className:`size-4`}),`Open folder…`]})]})]}),(0,U.jsx)(aY,{open:u,onClose:()=>d(!1),tab:t}),o||p?(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Refresh projects`,disabled:a,onClick:()=>void s(),className:Y(`inline-flex shrink-0 items-center justify-center text-muted-foreground outline-none transition-[background-color,color,scale] hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:scale-[0.97] disabled:opacity-60 motion-reduce:active:scale-100`,$J(`xs`,`w-7 px-0 sm:w-[1.625rem]`)),children:a?(0,U.jsx)(yB,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,U.jsx)(lg,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,U.jsx)(nR,{side:`top`,children:`Refresh projects`})]}):null]})}function mY({contextStrip:e=!1,className:t,...n}){return(0,U.jsx)(`div`,{"data-slot":`composer-shell`,"data-with-context":e||void 0,className:Y(`@container/composer-surface group/composer-surface relative isolate mx-auto w-full max-w-(--chat-content-max-width)`,`[--chat-composer-drawer-inset:1.375rem] [--chat-composer-glass-surface:var(--card)] [--chat-composer-outline:rgb(0_0_0/8%)]`,`dark:[--chat-composer-glass-surface:var(--surface-raised)] dark:[--chat-composer-highlight:rgb(255_255_255/3%)] dark:[--chat-composer-outline:color-mix(in_srgb,var(--color-white)_5%,transparent)]`,`before:pointer-events-none before:absolute before:inset-0 before:z-0 before:rounded-3xl before:bg-(--chat-composer-glass-surface)/(--glass-opacity) before:backdrop-blur-(--glass-blur) before:backdrop-saturate-(--glass-saturation)`,`not-supports-[((backdrop-filter:blur(1px))_or_(-webkit-backdrop-filter:blur(1px)))]:before:bg-(--chat-composer-glass-surface)`,`has-data-[composer-banner-surface=attached]:before:hidden data-model-strip-transition:before:hidden`,e&&[`[--chat-composer-context-extension:2.25rem] sm:[--chat-composer-context-extension:2rem]`,`before:[clip-path:shape(from_0_22px,curve_to_22px_0_with_0_9.85px/9.85px_0,line_to_calc(100%-22px)_0,curve_to_100%_22px_with_calc(100%-9.85px)_0/100%_9.85px,line_to_100%_calc(100%-var(--chat-composer-context-extension)-var(--chat-composer-drawer-inset)),curve_to_calc(100%-var(--chat-composer-drawer-inset))_calc(100%-var(--chat-composer-context-extension))_with_100%_calc(100%-var(--chat-composer-context-extension)-var(--chat-composer-drawer-inset)*0.4477)/calc(100%-var(--chat-composer-drawer-inset)*0.4477)_calc(100%-var(--chat-composer-context-extension)),line_to_calc(100%-var(--chat-composer-drawer-inset))_calc(100%-16px),curve_to_calc(100%-var(--chat-composer-drawer-inset)-16px)_100%_with_calc(100%-var(--chat-composer-drawer-inset))_calc(100%-7.16px)/calc(100%-var(--chat-composer-drawer-inset)-7.16px)_100%,line_to_calc(var(--chat-composer-drawer-inset)+16px)_100%,curve_to_var(--chat-composer-drawer-inset)_calc(100%-16px)_with_calc(var(--chat-composer-drawer-inset)+7.16px)_100%/var(--chat-composer-drawer-inset)_calc(100%-7.16px),line_to_var(--chat-composer-drawer-inset)_calc(100%-var(--chat-composer-context-extension)),curve_to_0_calc(100%-var(--chat-composer-context-extension)-var(--chat-composer-drawer-inset))_with_calc(var(--chat-composer-drawer-inset)*0.4477)_calc(100%-var(--chat-composer-context-extension))/0_calc(100%-var(--chat-composer-context-extension)-var(--chat-composer-drawer-inset)*0.4477),line_to_0_22px,close)]`,`not-supports-[clip-path:shape(from_0_0,line_to_1px_1px)]:before:bottom-(--chat-composer-context-extension)`],t),...n})}var hY=`after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:border after:border-(--chat-composer-outline) dark:after:inset-shadow-2xs dark:after:inset-shadow-(color:--chat-composer-highlight)`,gY=`group-data-with-context/composer-surface:after:[clip-path:polygon(0_0,100%_0,100%_100%,calc(100%-22px)_100%,calc(100%-22px)_calc(100%-2px),22px_calc(100%-2px),22px_100%,0_100%)]`;function _Y({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`composer-host`,className:Y(`relative z-10 w-full rounded-3xl shadow-composer after:z-1 dark:shadow-none`,hY,gY,`group-has-data-[composer-banner-surface=attached]/composer-surface:shadow-none group-has-data-[composer-banner-surface=attached]/composer-surface:after:hidden`,e),...t})}function vY({className:e,...t}){return(0,U.jsx)(`div`,{"data-chat-composer-main-surface":`true`,className:Y(`group relative z-10 rounded-3xl p-px`,`group-data-model-strip-transition/composer-surface:bg-(--chat-composer-glass-surface)/(--glass-opacity) group-data-model-strip-transition/composer-surface:backdrop-blur-(--glass-blur) group-data-model-strip-transition/composer-surface:backdrop-saturate-(--glass-saturation)`,hY,gY,`after:z-20 after:hidden group-has-data-[composer-banner-surface=attached]/composer-surface:after:block group-data-model-strip-transition/composer-surface:after:block`,`group-has-data-[composer-banner-surface=attached]/composer-surface:bg-(--chat-composer-glass-surface)/(--glass-opacity) group-has-data-[composer-banner-surface=attached]/composer-surface:backdrop-blur-(--glass-blur) group-has-data-[composer-banner-surface=attached]/composer-surface:backdrop-saturate-(--glass-saturation)`,`group-has-data-[composer-banner-surface=attached]/composer-surface:shadow-composer dark:group-has-data-[composer-banner-surface=attached]/composer-surface:shadow-none`,`not-supports-[((backdrop-filter:blur(1px))_or_(-webkit-backdrop-filter:blur(1px)))]:group-has-data-[composer-banner-surface=attached]/composer-surface:bg-(--chat-composer-glass-surface)`,`group-has-data-[composer-banner-surface=attached]/composer-surface:**:data-[chat-composer-mobile-collapsed=true]:min-h-[calc(1rem+1px)]`,e),...t})}function yY({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`composer-context-strip`,className:Y(`group/composer-context relative isolate mx-auto -mt-4 flex w-[calc(100%-2*var(--chat-composer-drawer-inset))] items-center gap-2 overflow-x-clip overflow-y-visible px-2 pt-5 pb-1`,`before:absolute before:inset-0 before:-z-1 before:rounded-b-2xl before:border before:border-(--chat-composer-outline) before:mask-b-from-transparent before:mask-b-from-4 before:mask-b-to-black before:mask-b-to-4 before:shadow-composer`,`dark:before:border-white/7 dark:before:bg-composer-seam-below dark:before:shadow-composer-dark`,`group-has-data-[composer-banner-surface=attached]/composer-surface:before:bg-(--chat-composer-glass-surface)/(--glass-opacity) group-has-data-[composer-banner-surface=attached]/composer-surface:before:backdrop-blur-(--glass-blur) group-has-data-[composer-banner-surface=attached]/composer-surface:before:backdrop-saturate-(--glass-saturation)`,`not-supports-[clip-path:shape(from_0_0,line_to_1px_1px)]:before:bg-(--chat-composer-glass-surface)/(--glass-opacity) not-supports-[clip-path:shape(from_0_0,line_to_1px_1px)]:before:backdrop-blur-(--glass-blur) not-supports-[clip-path:shape(from_0_0,line_to_1px_1px)]:before:backdrop-saturate-(--glass-saturation)`,e),...t})}var bY={Shell:mY,Host:_Y,Main:vY,ContextStrip:yY},xY=e=>e.preventDefault();function SY({onStop:e}){let[t,n]=(0,m.useState)(!1),r=tO(t,eO.confirm),i=()=>{n(!1),e()};return bR(`y`,i,{enabled:t&&r,inDialog:!0}),(0,U.jsxs)(GB,{open:t&&r,onOpenChange:n,children:[(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:`flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-full bg-stop-action text-white shadow-xs shadow-stop-action/24 inset-shadow-control-highlight transition-colors duration-150 outline-none hover:bg-stop-action-hover focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background active:inset-shadow-control-pressed active:shadow-none pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 [&_svg]:pointer-events-none`,onPointerDown:xY,onClick:()=>n(!0),"aria-label":`Stop`,"aria-haspopup":`dialog`,children:(0,U.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,U.jsx)(`rect`,{x:`2`,y:`2`,width:`8`,height:`8`,rx:`1.5`})})})}),(0,U.jsx)(nR,{side:`top`,children:`Interrupt`})]}),(0,U.jsxs)(JB,{children:[(0,U.jsxs)(YB,{children:[(0,U.jsx)(ZB,{children:`Stop the oracle?`}),(0,U.jsx)(QB,{children:`The current response stops. Work already recorded is kept.`})]}),(0,U.jsxs)(XB,{children:[(0,U.jsxs)(eV,{children:[`Keep it`,(0,U.jsx)(GD,{chord:`Esc`,className:`kbd-hint ml-1`})]}),(0,U.jsxs)($B,{variant:`destructive`,onClick:i,children:[`Stop`,(0,U.jsx)(GD,{chord:`Y`,className:`kbd-hint ml-1`})]})]})]})]})}function CY({sending:e,disabled:t,steering:n,onSend:r}){let i=n?`Steer message`:`Send`;return(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsx)(`span`,{className:`inline-flex`,children:(0,U.jsx)(`button`,{type:`button`,className:Y(`relative isolate flex h-9 w-9 items-center justify-center overflow-hidden rounded-full shadow-xs outline-none transition-all duration-150 enabled:cursor-pointer enabled:inset-shadow-control-highlight hover:scale-105 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background active:inset-shadow-control-pressed active:shadow-none disabled:pointer-events-none disabled:opacity-64 disabled:shadow-none disabled:hover:scale-100 motion-reduce:hover:scale-100 sm:h-8 sm:w-8 [&_svg]:pointer-events-none`,`bg-message-action text-message-action-foreground enabled:shadow-message-action/24 hover:bg-message-action-hover`),onPointerDown:xY,onClick:r,disabled:t,"aria-label":`Send`,"aria-keyshortcuts":`Enter`,children:e?(0,U.jsx)(yB,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,U.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":`true`,children:(0,U.jsx)(`path`,{d:`M7 11.5V2.5M7 2.5L3 6.5M7 2.5L11 6.5`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})})})})}),(0,U.jsxs)(nR,{side:`top`,children:[i,` `,(0,U.jsx)(GD,{chord:`Enter`})]})]})}function wY(e,t){let n=/^\s*([/@])([a-z]*)$/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 TY(e){let t=e.kind===`slash-command`?zR.map(e=>({id:`/${e.name}`,insert:`/${e.name}`,label:`/${e.name}`,description:`${e.hint} · /${e.name} ${e.args}`})):RR.map(e=>({id:`@${e.name}`,insert:`@${e.name}`,label:`@${e.name}`,description:e.hint,agent:e.agent})),n=t.filter(t=>t.label.slice(1).startsWith(e.query)),r=t.filter(t=>!n.includes(t)&&t.label.slice(1).includes(e.query));return[...n,...r]}function EY(e,t){return`${e}-${encodeURIComponent(t)}`}var DY={"slash-command":`Commands`,mention:`Agents`};function OY({item:e}){if(e.agent)return(0,U.jsx)(pO,{source:LR[e.agent],strokeWidth:2,className:`size-4 shrink-0 text-muted-foreground`});let t=e.id===`/plan`?_g:hh;return(0,U.jsx)(t,{"aria-hidden":`true`,strokeWidth:2,className:`size-4 shrink-0 text-muted-foreground`})}var kY=(0,m.memo)(function(e){let t=(0,m.useRef)(null);return(0,m.useLayoutEffect)(()=>{e.activeItemId&&t.current&&t.current.querySelector(`[data-composer-item-id="${CSS.escape(e.activeItemId)}"]`)?.scrollIntoView({block:`nearest`})},[e.activeItemId]),(0,U.jsx)(`div`,{ref:t,"data-composer-command-drawer":`true`,className:Y(`composer-command-drawer relative isolate flex min-h-0 w-full flex-col overflow-hidden pb-[calc(1rem+1px)]`,`before:pointer-events-none before:absolute before:inset-0 before:-z-1 before:rounded-t-2xl before:border before:border-(--chat-composer-outline)`,`before:bg-(--chat-composer-glass-surface)/(--glass-opacity) before:backdrop-blur-(--glass-blur) before:backdrop-saturate-(--glass-saturation)`,`before:mask-t-from-transparent before:mask-t-from-4 before:mask-t-to-black before:mask-t-to-4 before:shadow-composer dark:before:shadow-none`,`not-supports-[((backdrop-filter:blur(1px))_or_(-webkit-backdrop-filter:blur(1px)))]:before:bg-(--chat-composer-glass-surface)`),children:(0,U.jsx)(`div`,{id:e.listId,role:`listbox`,"aria-label":DY[e.triggerKind],className:`max-h-72 min-h-0 overflow-y-auto p-2`,children:e.items.map(t=>{let n=e.activeItemId===t.id;return(0,U.jsxs)(`div`,{id:EY(e.listId,t.id),role:`option`,"aria-selected":n,"data-composer-item-id":t.id,"data-active":n||void 0,onMouseMove:()=>{n||e.onHighlightedItemChange(t.id)},onMouseDown:e=>e.preventDefault(),onClick:()=>e.onSelect(t),className:Y(`flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 text-sm outline-none select-none`,n&&`bg-accent text-accent-foreground`),children:[(0,U.jsx)(OY,{item:t}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`min-w-0 max-w-[45%] shrink-0 truncate font-sans text-xs font-medium`,children:t.label}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left text-xs text-muted-foreground`,children:t.description})]})]},t.id)})})})}),AY={id:`oracle`,label:`Message the team`,placeholder:`Message the team… @ picks who answers, / for /plan and /task`},jY=new Set([`lobby`,`tasks`,`plan`,`knowledge`]);function MY(e){return e.kind===`tab`&&jY.has(e.tab)}function NY(e,t){if(e.kind!==`tab`)return AY;if(e.tab===`knowledge`)return{id:`knowledge`,label:`Ask the oracle about this project`,placeholder:`Ask about this project — the oracle searches the code and learns what is missing…`};if(e.tab===`plan`)return{id:`panel`,label:`Message the panel`,placeholder:`Describe a task, or answer the panel…`};let n=e.tab===`tasks`?zV(e.rest).id??t:void 0;return n?{id:`comment`,label:`Comment on ${n}`,placeholder:`Comment on ${n}'s plan…`,taskId:n}:AY}var PY=0;function FY(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}var IY={duration:.16,ease:`easeOut`};function LY({file:e,onRemove:t}){let n=(0,U.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,U.jsx)(s_,{"aria-hidden":`true`,className:`size-3.5`})});return e.image?(0,U.jsxs)(Xf.li,{layout:!0,initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:IY,title:`${e.name} · ${KJ(e.size)}`,className:`relative size-16 shrink-0 overflow-hidden rounded-lg border border-border/80 bg-background`,children:[(0,U.jsx)(`img`,{src:I(e.image),alt:e.name,className:`size-full object-cover`}),e.state===`uploading`?(0,U.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,U.jsx)(yB,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}),`uploading`]}):null,n]}):(0,U.jsxs)(Xf.li,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:IY,className:`flex min-w-0 basis-full items-center gap-2 text-sm text-foreground`,children:[(0,U.jsx)(Ym,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,U.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-muted-foreground`,children:[e.state===`uploading`?(0,U.jsx)(yB,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}):null,e.state===`uploading`?`uploading…`:KJ(e.size)]}),n]})}function RY(e,t,n){let[r,i]=(0,m.useState)(!1),a=n.kind===`tab`?n.tab:n.kind;return(0,m.useEffect)(()=>i(!1),[a]),(0,m.useEffect)(()=>{if(!t)return;let n=0,r=t=>{e.current?.contains(t.target)||(n=performance.now())},a=t=>{[`PageDown`,`PageUp`,`ArrowDown`,`ArrowUp`,`Home`,`End`,` `].includes(t.key)&&!e.current?.contains(t.target)&&(n=performance.now())},o=t=>{let r=e.current;!r||performance.now()-n>400||r.contains(document.activeElement)||r.contains(t.target)||i(!0)};return document.addEventListener(`wheel`,r,{capture:!0,passive:!0}),document.addEventListener(`touchmove`,r,{capture:!0,passive:!0}),document.addEventListener(`keydown`,a,{capture:!0}),document.addEventListener(`scroll`,o,{capture:!0,passive:!0}),()=>{document.removeEventListener(`wheel`,r,{capture:!0}),document.removeEventListener(`touchmove`,r,{capture:!0}),document.removeEventListener(`keydown`,a,{capture:!0}),document.removeEventListener(`scroll`,o,{capture:!0})}},[t,e]),{shrunk:r,expand:(0,m.useCallback)(()=>i(!1),[])}}function zY({route:e,projects:t}){let[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)([]),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(!1),u=oO(`status`),d=oO(`lobby`),f=rO(),p=(u.data?.busy??!1)||!!d.data?.reply?.trim(),h=MY(e),g=(0,m.useRef)(h);g.current=h;let{taskId:_}=AK(),v=(0,m.useMemo)(()=>NY(e,_),[e,_]),y=(0,m.useRef)(null),{shrunk:b,expand:x}=RY(y,h&&!f,e),S=(0,m.useRef)(null),C=(0,m.useRef)(null),w=(0,m.useRef)(i);w.current=i;let T=(0,m.useRef)(void 0),[E,D]=(0,m.useState)(0),[O,k]=(0,m.useState)(null),[A,ee]=(0,m.useState)(void 0),j=v.id===`oracle`?wY(n,E):void 0,M=(0,m.useMemo)(()=>j?TY(j):[],[j?.kind,j?.query]),te=!!j&&M.length>0&&A!==n&&h&&!f,N=te?M.find(e=>e.id===O)??M[0]:void 0,P=`composer-suggestions`,ne=(0,m.useCallback)(e=>{let t=n.replace(/^\s*[/@][a-z]*\s*/i,``),i=`${e.insert} ${t}`,a=e.insert.length+1;T.current={start:a,end:a},D(a),r(i),k(null),S.current?.focus()},[n]);(0,m.useLayoutEffect)(()=>{let e=T.current,t=S.current;e&&t&&(T.current=void 0,t.setSelectionRange(e.start,e.end))},[n]);let re=(0,m.useCallback)(e=>{T.current={start:e.start,end:e.end},D(e.end),r(e.value)},[]);(0,m.useEffect)(()=>{let e=y.current;if(!e)return;let t=document.documentElement,n=()=>{let n=e.getBoundingClientRect();if(t.style.setProperty(`--composer-h`,f||!h?`0px`:`${Math.ceil(n.height)}px`),!h||n.width===0){t.style.removeProperty(`--composer-x`),t.style.removeProperty(`--composer-w`);return}t.style.setProperty(`--composer-x`,`${Math.round(n.left)}px`),t.style.setProperty(`--composer-w`,`${Math.round(n.width)}px`)};n();let r=new ResizeObserver(n);return r.observe(e),window.addEventListener(`resize`,n),()=>{r.disconnect(),window.removeEventListener(`resize`,n),t.style.setProperty(`--composer-h`,`0px`),t.style.removeProperty(`--composer-x`),t.style.removeProperty(`--composer-w`)}},[f,h]);let ie=(0,m.useCallback)(e=>{if(!g.current)return;let t=[...e],n=8-w.current.length;t.length>n&&W.warning(`At most 8 files go with one message.`);for(let e of t.slice(0,Math.max(0,n))){let t=`f${++PY}`,n=e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0;a(r=>[...r,{key:t,name:e.name||(n?`image.png`:`file`),size:e.size,...n?{image:n}:{},state:`uploading`}]),qJ(e).then(e=>a(n=>n.map(n=>n.key===t?{...n,state:`ready`,info:e}:n))).catch(e=>{W.error(e instanceof Error?e.message:`That file did not upload.`),a(e=>e.filter(e=>e.key!==t))})}},[]),ae=(0,m.useCallback)(e=>{a(t=>{let n=t.find(t=>t.key===e);return n?.image&&URL.revokeObjectURL(n.image),t.filter(t=>t.key!==e)})},[]),oe=i.some(e=>e.state===`uploading`),se=i.flatMap(e=>e.info?[e.info.id]:[]),ce=(n.trim().length>0||se.length>0)&&!oe&&!o,le=(0,m.useCallback)(async()=>{if(!ce||!g.current)return;s(!0);let e=se.length>0?se:void 0,t={text:n,...e?{attachments:e}:{}};try{let e=!0;if(v.id===`oracle`){let e=await R(`lobby.send`,t);e.notice&&W(e.notice),e.open===`plan`&&hB(mB(`plan`))}else if(v.id===`knowledge`){e=await mp(`knowledge.ask`,t)!==void 0;let n=pB(window.location.hash);e&&n?.kind===`tab`&&n.tab===`knowledge`&&hB(vB(n.rest,!0))}else e=v.id===`panel`?await mp(`planner.send`,t)!==void 0:await mp(`tasks.comment`,{taskId:v.taskId,...t})!==void 0;if(e){r(``);for(let e of w.current)e.image&&URL.revokeObjectURL(e.image);a([])}}catch(e){W.error(e instanceof Error?e.message:`Could not send`)}finally{s(!1)}},[ce,se,v,n,e]),F=(0,m.useCallback)(async()=>{try{await R(`lobby.abort`,{})}catch(e){W.error(e instanceof Error?e.message:`Could not stop`)}},[]),ue=e=>{if(te&&N&&!e.nativeEvent.isComposing){let t=M.indexOf(N);if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=(t+(e.key===`ArrowDown`?1:-1)+M.length)%M.length;k(M[n].id);return}if(e.key===`Enter`&&!e.shiftKey||e.key===`Tab`){e.preventDefault(),ne(N);return}if(e.key===`Escape`){e.preventDefault(),ee(n);return}}if(e.key===`Escape`&&!e.nativeEvent.isComposing){e.preventDefault(),mR();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;re(r===`k`?YJ(a,n,i):JJ(a,n,i,r===`b`?`**`:r===`i`?`_`:"`"));return}if(e.key===`Enter`&&e.shiftKey&&!e.nativeEvent.isComposing&&t.selectionStart===t.selectionEnd){let n=ZJ(t.value,t.selectionStart);n&&(e.preventDefault(),re(n));return}if(e.key===`Backspace`&&t.value===``&&w.current.length>0){e.preventDefault(),ae(w.current.at(-1).key);return}(FY(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey))&&(e.preventDefault(),le())},de=e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),ie(t))},fe=e=>{e.preventDefault(),l(!1),e.dataTransfer.files.length>0&&ie(e.dataTransfer.files)},I=e.kind===`tab`&&e.tab===`knowledge`,L=u.data?.workspace.name??`bot-lobby`,pe=u.data?.branch??u.data?.workspace.branch,me=(0,U.jsx)(`div`,{className:`min-h-0`,children:(0,U.jsx)(`div`,{className:`relative z-0`,children:(0,U.jsxs)(bY.ContextStrip,{role:`group`,"aria-label":`Message context`,className:`composer-strip gap-1 text-xs font-normal text-muted-foreground/70`,children:[(0,U.jsx)(pY,{projects:t,tab:e.kind===`tab`?e.tab:e.kind,name:L,branch:pe}),(0,U.jsx)(`div`,{className:`@container ml-auto flex min-w-0 flex-1 items-center justify-end gap-3 overflow-hidden pe-1`,children:(0,U.jsx)(KD,{chord:`Shift+Enter`,className:`hidden @[14rem]:inline-flex`,children:`new line`})})]})})});return(0,U.jsx)(`div`,{id:`app-dock`,ref:y,"data-shrunk":b||void 0,onFocus:x,className:Y(`dock pointer-events-none absolute inset-x-0 bottom-0 z-30 px-6 pb-[max(1rem,env(safe-area-inset-bottom))] transition-opacity duration-200 ease-snap`,f&&`opacity-0`),hidden:!h,"aria-hidden":!h||void 0,inert:f||!h,children:(0,U.jsxs)(bY.Shell,{contextStrip:!0,className:`composer-shell pointer-events-auto`,children:[(0,U.jsx)(ju,{initial:!1,children:te&&j&&N?(0,U.jsx)(Xf.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:IY,"data-composer-drawer-layer":`true`,className:`absolute inset-x-(--chat-composer-drawer-inset) bottom-full z-0 -mb-[calc(1rem+1px)] flex flex-col`,children:(0,U.jsx)(kY,{listId:P,items:M,triggerKind:j.kind,activeItemId:N.id,onHighlightedItemChange:k,onSelect:ne})},`commands`):null}),(0,U.jsx)(bY.Host,{onPointerDown:x,children:(0,U.jsx)(`div`,{className:`relative z-10`,children:(0,U.jsxs)(bY.Main,{className:`group/composer composer-box`,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),l(!0))},onDragLeave:()=>l(!1),onDrop:fe,children:[(0,U.jsxs)(`div`,{"data-chat-composer-surface":`true`,className:Y(`rounded-3xl transition-[background-color] duration-200`,c&&`bg-accent/45 ring-1 ring-inset ring-primary/70`),children:[(0,U.jsxs)(`div`,{"data-chat-composer-body":`true`,className:Y(`composer-text relative px-3 pb-2 sm:px-4`,`pt-3.5 sm:pt-4`),children:[(0,U.jsx)(ju,{initial:!1,children:i.length>0?(0,U.jsx)(Xf.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 mb-3 flex max-w-full flex-wrap gap-2 overflow-hidden`,children:i.map(e=>(0,U.jsx)(LY,{file:e,onRemove:()=>ae(e.key)},e.key))},`files`):null}),(0,U.jsx)(`div`,{className:`relative flow-root font-sans text-sm max-sm:pointer-coarse:text-base`,children:(0,U.jsx)(`textarea`,{ref:S,id:`composer-text`,"aria-label":v.label,...v.id===`oracle`?{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":te,"aria-controls":te?P:void 0}:{},...N?{"aria-activedescendant":EY(P,N.id)}:{},value:n,onChange:e=>{r(e.target.value),D(e.target.selectionStart)},onSelect:e=>D(e.currentTarget.selectionStart),onKeyDown:ue,onPaste:de,placeholder:p&&v.id===`oracle`?`The oracle is working. Enter steers it…`:v.placeholder,rows:1,className:Y(`-m-1 block field-sizing-content max-h-52 min-h-19.5 w-[calc(100%+0.5rem)] resize-none overflow-y-auto bg-transparent p-1 leading-relaxed whitespace-pre-wrap text-foreground caret-primary outline-none placeholder:text-placeholder/75`)})})]}),(0,U.jsxs)(`div`,{"data-chat-composer-footer":`true`,className:Y(`composer-tools flex min-w-0 flex-nowrap items-center justify-between gap-2 overflow-visible px-3 pb-3 sm:gap-0 sm:px-4 sm:pb-4`),children:[(0,U.jsx)(`div`,{"data-chat-composer-controls":`left`,className:`composer-controls relative -m-1 -ms-3.5 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto p-1 ps-3.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:I?(0,U.jsx)(QJ,{rest:e.kind===`tab`?e.rest:[]}):null}),(0,U.jsxs)(`div`,{"data-chat-composer-actions":`right`,className:`flex shrink-0 flex-nowrap items-center justify-end gap-2`,children:[(0,U.jsx)(`input`,{ref:C,type:`file`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach files`,onChange:e=>{ie(e.target.files??[]),e.target.value=``}}),(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Attach images, PDFs or files`,"data-compact":!0,onPointerDown:e=>e.preventDefault(),onClick:()=>C.current?.click(),className:`pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11`,children:(0,U.jsx)(Yh,{"aria-hidden":`true`})})}),(0,U.jsx)(nR,{side:`top`,children:`Attach files`})]}),p&&v.id===`oracle`?(0,U.jsx)(SY,{onStop:()=>void F()}):null,(0,U.jsx)(CY,{sending:o,disabled:!ce,steering:p&&v.id===`oracle`,onSend:()=>void le()})]})]})]}),c?(0,U.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-primary`,children:`Drop to attach`}):null]})})}),me]})})}function BY({state:e}){return e===`live`?null:e===`connecting`?(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 rounded-full bg-warning motion-safe:animate-status-pulse`}),`reconnecting…`]}):(0,U.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:`Connection lost`})}function VY(e){if(!e)return 0;let t=[...e.children].filter(e=>e instanceof HTMLElement&&e.offsetParent!==null&&getComputedStyle(e).position!==`absolute`);if(!t.length)return 0;let n=Math.min(...t.map(e=>e.getBoundingClientRect().left)),r=Math.max(...t.map(e=>e.getBoundingClientRect().right)),i=0;for(let t of e.querySelectorAll(`*`))t.clientWidth<=1||t.offsetParent===null||t.scrollWidth<=t.clientWidth+1||getComputedStyle(t).textOverflow===`ellipsis`&&(i+=t.scrollWidth-t.clientWidth);return r-n+i}var HY=24;function UY(){let e=(0,m.useRef)(null),[t,n]=(0,m.useState)(!1),r=(0,m.useRef)(()=>{});return r.current=()=>{let t=e.current;if(!t)return;let r=t.querySelector(`[role="tablist"]`),i=getComputedStyle(t),a=parseFloat(i.columnGap)||0,o=t.clientWidth-(parseFloat(i.paddingLeft)||0)-(parseFloat(i.paddingRight)||0),s=VY(t.querySelector(`.where`))+(r?.offsetWidth??0)+VY(t.querySelector(`.tools`))+a*2;n(s+HY<=o)},(0,m.useLayoutEffect)(()=>r.current()),(0,m.useLayoutEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>r.current());n.observe(t);for(let e of t.querySelectorAll(`[role="tablist"], .where, .tools`))n.observe(e);return()=>n.disconnect()},[]),{header:e,one:t}}function WY({connection:e,projects:t,lead:n,tabs:r,extra:i,tools:a}){let{header:o,one:s}=UY();return(0,U.jsxs)(`header`,{ref:o,className:`app-header shrink-0`,"data-one-row":s||void 0,children:[(0,U.jsx)(`div`,{className:`where flex min-w-0 items-center gap-2`,children:n}),(0,U.jsx)(`div`,{className:`tabs min-w-0`,children:r}),(0,U.jsxs)(`div`,{className:`tools flex min-w-0 items-center justify-end gap-2`,children:[i,(0,U.jsx)(BY,{state:e}),a,(0,U.jsx)(`span`,{id:`focused-action-help`,className:`sr-only`,children:`Focused buttons: Enter or Space. Links: Enter. Checkboxes: Space.`})]}),(0,U.jsx)(uY,{projects:t})]})}function GY({open:e,onOpenChange:t}){let n=tO(e,eO.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{W((await R(`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,U.jsx)(qD,{open:n,label:`New session`,description:`Starts a task in a session of its own, in the background.`,onOpenChange:e=>{e||u()},dismissOnBackdrop:!a,children:(0,U.jsxs)(`div`,{className:`flex w-[min(32rem,calc(100vw-2rem))] flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border px-4 py-3`,children:[(0,U.jsx)(`h2`,{className:`text-[0.9375rem] font-semibold`,children:`New session`}),(0,U.jsx)(`p`,{className:`text-xs 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,U.jsxs)(`div`,{className:`flex flex-col gap-1.5 p-4`,children:[(0,U.jsx)(`label`,{htmlFor:l,className:`text-sm font-medium`,children:`What should it do?`}),(0,U.jsx)(nV,{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:`max-h-60 min-h-24`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d())}}),s?(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:s}):null]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 border-t border-border bg-muted/30 px-4 py-3`,children:[(0,U.jsx)(X,{variant:`outline`,onClick:u,disabled:a,children:`Cancel`}),(0,U.jsx)(X,{onClick:()=>void d(),disabled:!r.trim()||a,"aria-busy":a,children:a?`Starting…`:`Start session`})]})]})})}function KY(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 qY(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:KY(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 JY=`app.sidebar`,YY={start:16,min:13,max:24},XY=`bot-lobby.sidebar.width`,ZY=`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-[var(--sidebar-icon)] outline-none transition-[background-color,color,scale] duration-150 hover:bg-sidebar-accent hover:text-sidebar-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:scale-[0.96] aria-pressed:text-sidebar-foreground aria-[current=page]:bg-[var(--sidebar-selected)] aria-[current=page]:text-sidebar-foreground motion-reduce:active:scale-100`,QY=`session-row flex h-8 w-full min-w-0 items-center gap-2 rounded-lg px-2.5 text-left text-sm outline-none transition-colors duration-150 hover:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-[var(--sidebar-selected)]`;function $Y({label:e,hint:t,side:n=`bottom`,children:r}){return(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:r}),(0,U.jsxs)(nR,{side:n,children:[e,` `,t?(0,U.jsx)(GD,{chord:t}):null]})]})}function eX(){let e=oO(`status`).data;return{entries:qY(e,DB(`sessions.list`,{},[`sessions`]).data),branch:e?.branch??e?.workspace.branch}}function tX(){return(0,m.useCallback)(async e=>{if(e.where===`here`)return hB(`#/lobby`);if(e.where===`elsewhere`)return void W.info(`${e.name} runs in another terminal. Switch to that terminal to work in it.`);await mp(`sessions.switch`,e.key?{key:e.key}:{sessionId:e.sessionId})&&hB(`#/lobby`)},[])}function nX({entry:e}){return e.where!==`elsewhere`&&e.state===`asking`?(0,U.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-warning tabular-nums`,children:[(0,U.jsx)(Dh,{"aria-hidden":`true`,className:`size-3.5`}),e.waiting,(0,U.jsxs)(`span`,{className:`sr-only`,children:[e.waiting===1?` question`:` questions`,`, Waiting`]})]}):e.where!==`elsewhere`&&(e.state===`working`||e.state===`starting`)?(0,U.jsxs)(`span`,{className:Y(`inline-flex shrink-0`,e.state===`working`?`text-primary`:`text-muted-foreground`),children:[(0,U.jsx)(pm,{"aria-hidden":`true`,className:`session-spin size-3.5`}),(0,U.jsx)(`span`,{className:`sr-only`,children:e.state===`working`?`Working`:`Starting`})]}):(0,U.jsx)(`span`,{className:`sr-only`,children:e.where===`elsewhere`?`Other terminal`:e.state===`exited`?`Ended`:`Idle`})}var rX={here:`This window`,background:`Background`,elsewhere:`Other terminal`};function iX(e){let t=e.key;return mp(`sessions.archive`,{key:t},{undo:()=>void mp(`sessions.archive`,{key:t,archived:!1})})}function aX({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 mp(`sessions.rename`,{...e.where===`here`?{}:{key:e.key},name:r}),t()};return(0,U.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:`-mx-1 h-6 w-[calc(100%+0.5rem)] min-w-0 rounded-sm bg-background px-1 text-sm leading-5 text-sidebar-foreground outline-none ring-2 ring-ring`})}var oX=`inline-flex size-[1.625rem] items-center justify-center rounded-md text-muted-foreground outline-none transition-[background-color,color] duration-150 hover:bg-[var(--sidebar-selected)] hover:text-sidebar-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`;function sX({entry:e}){let t=tX(),[n,r]=(0,m.useState)(!1),i=e.state===`exited`||e.where===`elsewhere`,a=Y(`min-w-0 flex-1 truncate`,e.where===`here`?`font-medium text-sidebar-foreground`:i?`text-muted-foreground`:`text-sidebar-foreground`),o=e.where!==`elsewhere`,s=e.where===`background`&&e.state===`exited`&&!!e.key,c=o||s;return(0,U.jsxs)(`li`,{className:`session-enter session-item relative`,children:[n?(0,U.jsx)(`div`,{"aria-current":e.where===`here`?`true`:void 0,className:Y(QY,`hover:bg-transparent`),children:(0,U.jsx)(aX,{entry:e,onDone:()=>r(!1)})}):(0,U.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,onClick:()=>void t(e),onDoubleClick:e=>{o&&(e.preventDefault(),r(!0))},className:QY,children:[(0,U.jsx)(`span`,{className:a,children:e.name}),(0,U.jsx)(`span`,{className:Y(`flex shrink-0 items-center`,c&&`session-state`),children:(0,U.jsx)(nX,{entry:e})})]}),!n&&c?(0,U.jsxs)(`span`,{className:`session-actions absolute top-1/2 right-1 flex -translate-y-1/2 items-center gap-0.5`,children:[o?(0,U.jsx)($Y,{label:`Rename`,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Rename ${e.name}`,onClick:()=>r(!0),className:oX,children:(0,U.jsx)(tg,{"aria-hidden":`true`,className:`size-3.5`})})}):null,s?(0,U.jsx)($Y,{label:`Archive`,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Archive ${e.name}`,onClick:()=>void iX(e),className:oX,children:(0,U.jsx)(jp,{"aria-hidden":`true`,className:`size-3.5`})})}):null]}):null]})}var cX=`flex h-7 items-center px-2.5 pt-2 text-xs font-medium text-muted-foreground`;function lX({id:e,label:t,entries:n,archivable:r=!1}){let[i,a]=Hz(`app.sidebar.${e}`),o=(0,m.useId)();return n.length===0?null:(0,U.jsxs)(`section`,{"aria-label":t,className:`group/shelf flex flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1 pt-2`,children:[(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":!i,"aria-controls":o,onClick:a,className:`flex h-7 min-w-0 flex-1 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium text-muted-foreground outline-none transition-colors duration-150 hover:text-sidebar-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[(0,U.jsx)(`span`,{children:t}),i?(0,U.jsx)(`span`,{className:`tabular-nums`,children:n.length}):null,(0,U.jsx)(tm,{"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 motion-reduce:transition-none`,i&&`-rotate-90 opacity-100`)})]}),r?(0,U.jsx)(`button`,{type:`button`,onClick:()=>void(async()=>{for(let e of n)e.key&&await mp(`sessions.archive`,{key:e.key})})(),className:`h-[1.625rem] shrink-0 rounded-md px-1.5 text-xs text-muted-foreground outline-none transition-colors duration-150 hover:bg-sidebar-accent hover:text-sidebar-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:`Archive all`}):null]}),i?null:(0,U.jsx)(`ul`,{id:o,className:`flex flex-col gap-px`,children:n.map(e=>(0,U.jsx)(sX,{entry:e},e.id))})]})}function uX(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean),r=`${e.name} ${rX[e.where]}`.toLowerCase();return n.every(e=>r.includes(e))}function dX({query:e,onQuery:t,onNew:n}){return(0,U.jsxs)(`div`,{className:`flex items-center gap-1 px-1 pb-2`,children:[(0,U.jsxs)(`label`,{className:`flex h-8 min-w-0 flex-1 items-center gap-2 rounded-md px-2 text-sm text-muted-foreground transition-colors duration-150 hover:bg-sidebar-accent focus-within:bg-sidebar-accent focus-within:ring-2 focus-within:ring-inset focus-within:ring-ring`,children:[(0,U.jsx)(Cg,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,U.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(``))},className:`min-w-0 flex-1 bg-transparent text-sidebar-foreground outline-none placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden`})]}),(0,U.jsx)($Y,{label:`New session`,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`New session`,"aria-haspopup":`dialog`,onClick:n,className:ZY,children:(0,U.jsx)(Ng,{"aria-hidden":`true`,className:`size-4`})})})]})}function fX({query:e}){let{entries:t}=eX(),n=t.filter(t=>uX(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=(0,m.useRef)(null);return(0,U.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,U.jsxs)(`nav`,{ref:s,"aria-label":`Sessions list`,className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-1 pb-2`,children:[n.length===0?(0,U.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,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:cX,children:`This window`}),(0,U.jsx)(`ul`,{className:`flex flex-col gap-px`,children:r.map(e=>(0,U.jsx)(sX,{entry:e},e.id))})]}):null,i.length>0?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:Y(cX,`mt-2`),children:`Background`}),(0,U.jsx)(`ul`,{className:`flex flex-col gap-px`,children:i.map(e=>(0,U.jsx)(sX,{entry:e},e.id))})]}):!e.trim()&&t.length===1?(0,U.jsx)(`p`,{className:`px-2.5 pt-2 text-xs text-muted-foreground`,children:`No other sessions are running.`}):null,(0,U.jsxs)(`div`,{className:`mt-auto flex flex-col pt-2`,children:[(0,U.jsx)(lX,{id:`elsewhere`,label:`Other terminals`,entries:a}),(0,U.jsx)(lX,{id:`ended`,label:`Ended`,entries:o,archivable:!0})]})]}),(0,U.jsx)(Bv,{target:s})]})}function pX(){let e=oO(`status`).data?.workspace.name;return(0,U.jsx)(`span`,{"data-slot":`sidebar-title`,title:e,className:`min-w-0 flex-1 truncate text-sm font-semibold tracking-tight text-sidebar-foreground`,children:e??`Bot Lobby`})}function mX({route:e,keys:t,onHelp:n}){let r=t.settings??`Alt+S`;return(0,U.jsxs)(`div`,{className:`sidebar-foot flex flex-col gap-1 border-t border-[var(--sidebar-border)] px-1 py-2`,children:[(0,U.jsxs)(`a`,{href:`#/settings`,"aria-label":`Settings`,"aria-current":e.kind===`settings`?`page`:void 0,"aria-keyshortcuts":r,className:`flex h-8 items-center gap-2 rounded-md px-2 text-sm text-sidebar-foreground outline-none transition-colors duration-150 hover:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=page]:bg-[var(--sidebar-selected)] aria-[current=page]:font-medium [&>svg]:text-[var(--sidebar-icon)]`,children:[(0,U.jsx)(Tg,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,U.jsx)(`span`,{className:`flex-1`,children:`Settings`}),(0,U.jsx)(GD,{chord:r})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(zJ,{hint:t.help??`Alt+H`,onHelp:n,className:ZY}),(0,U.jsx)(BJ,{className:ZY}),(0,U.jsx)(UJ,{className:ZY}),(0,U.jsx)(WJ,{className:ZY}),(0,U.jsx)(GJ,{className:ZY})]})]})}function hX(){try{let e=Number(localStorage.getItem(XY));if(e>=YY.min&&e<=YY.max)return e}catch{}return YY.start}function gX(e){try{e===YY.start?localStorage.removeItem(XY):localStorage.setItem(XY,String(e))}catch{}}var _X=e=>Math.min(YY.max,Math.max(YY.min,Math.round(e*4)/4));function vX({width:e,onWidth:t,onResizing:n,onFold:r}){let i=(0,m.useRef)(null),a=(0,m.useRef)(!1),o=(0,m.useRef)(void 0);(0,m.useEffect)(()=>()=>window.clearTimeout(o.current),[]);let s=()=>parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return(0,U.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-label":`Resize sidebar`,"aria-orientation":`vertical`,"aria-controls":`app-sidebar`,"aria-valuemin":YY.min,"aria-valuemax":YY.max,"aria-valuenow":e,title:`Drag to resize, click to fold, double-click to reset`,className:`sidebar-edge`,onPointerDown:t=>{t.button===0&&(t.currentTarget.setPointerCapture?.(t.pointerId),i.current={x:t.clientX,width:e,moved:!1})},onPointerMove:e=>{let r=i.current;if(!r)return;let a=e.clientX-r.x;!r.moved&&Math.abs(a)<3||(r.moved||n(!0),r.moved=!0,t(_X(r.width+a/s())))},onPointerUp:()=>{let e=i.current;i.current=null,e&&(a.current=e.moved,n(!1))},onClick:e=>{a.current||e.detail!==1||(o.current=window.setTimeout(r,240))},onPointerCancel:()=>{i.current=null,n(!1)},onDoubleClick:()=>{window.clearTimeout(o.current),t(YY.start)},onKeyDown:n=>{n.key===`ArrowLeft`||n.key===`ArrowRight`?(n.preventDefault(),t(_X(e+(n.key===`ArrowRight`?1:-1)))):n.key===`Home`||n.key===`End`?(n.preventDefault(),t(n.key===`Home`?YY.min:YY.max)):n.key===`Enter`&&(n.preventDefault(),r())}})}function yX(e){sO(Nz);let[t,n]=Hz(JY),[r,i]=(0,m.useState)(hX),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(``),[l,u]=(0,m.useState)(!1),d=(0,m.useCallback)(e=>{i(e),gX(e)},[]);return(0,U.jsxs)(`aside`,{id:`app-sidebar`,"aria-label":`Sidebar`,"data-folded":t?``:void 0,"data-resizing":a?``:void 0,inert:t,style:{width:t?0:`${r}rem`},className:`app-sidebar`,children:[(0,U.jsxs)(`div`,{className:`sidebar-panel flex min-h-0 flex-1 flex-col`,style:{width:`${r}rem`},children:[(0,U.jsxs)(`div`,{className:`flex min-h-12 items-center gap-2 pr-1 pl-3`,children:[(0,U.jsx)(pX,{}),(0,U.jsx)($Y,{label:`Collapse sidebar`,hint:e.keys.sidebar,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Collapse sidebar`,"aria-expanded":!0,"aria-controls":`app-sidebar`,"aria-keyshortcuts":e.keys.sidebar,onClick:n,className:ZY,children:(0,U.jsx)(Uh,{"aria-hidden":`true`,className:`size-4`})})})]}),(0,U.jsx)(dX,{query:s,onQuery:c,onNew:()=>u(!0)}),(0,U.jsx)(fX,{query:s}),(0,U.jsx)(mX,{...e})]}),(0,U.jsx)(vX,{width:r,onWidth:d,onResizing:o,onFold:n}),(0,U.jsx)(GY,{open:l,onOpenChange:u})]})}function bX({hint:e}){sO(Nz);let[t,n]=Hz(JY);return t?(0,U.jsx)($Y,{label:`Expand sidebar`,hint:e,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Expand sidebar`,"aria-expanded":!1,"aria-controls":`app-sidebar`,"aria-keyshortcuts":e,onClick:n,className:Y(ZY,`sidebar-open size-8 text-foreground`),children:(0,U.jsx)(Gh,{"aria-hidden":`true`,className:`size-4`})})}):null}var xX=`bot-lobby.terminal.open`,SX=`bot-lobby.terminal.height`,CX=`bot-lobby.terminal.popup`,wX={start:280,min:140},TX=new Set,EX,DX,OX;function kX(e){try{return localStorage.getItem(e)}catch{return null}}function AX(e,t){try{localStorage.setItem(e,t)}catch{}}function jX(){for(let e of[...TX])e()}function MX(e){return TX.add(e),()=>{TX.delete(e)}}function NX(){return EX??=kX(xX)===`1`,EX}function PX(){if(DX===void 0){let e=Number(kX(SX));DX=e>=wX.min?e:wX.start}return DX}function FX(e){EX=e,AX(xX,e?`1`:`0`),jX()}function IX(){FX(!NX())}function LX(e){DX=Math.max(wX.min,Math.round(e)),AX(SX,String(DX)),jX()}function RX(){return(0,m.useSyncExternalStore)(MX,NX,()=>!1)}function zX(){return(0,m.useSyncExternalStore)(MX,PX,()=>wX.start)}function BX(){return OX??=kX(CX)===`1`,OX}function VX(e){OX=e,AX(CX,e?`1`:`0`),jX()}function HX(){return(0,m.useSyncExternalStore)(MX,BX,()=>!1)}var UX=`modulepreload`,WX=function(e){return`/`+e},GX={},KX=function(e){return e.pathname.endsWith(`.css`)},qX=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=WX(t,n);let r=s(t);if(r.href in GX)return;GX[r.href]=!0;let i=KX(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`:UX,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)})},JX=(0,m.lazy)(()=>qX(()=>import(`./TerminalView-DG4X3Yyr.js`),__vite__mapDeps([0,1,2,3]))),YX=`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 XX({label:e,hint:t,children:n}){return(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:n}),(0,U.jsxs)(nR,{side:`top`,children:[e,` `,t?(0,U.jsx)(GD,{chord:t}):null]})]})}function ZX({hint:e,className:t}){let n=RX();return(0,U.jsx)(XX,{label:n?`Hide terminal`:`Terminal`,hint:e,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Terminal`,"aria-pressed":n,"aria-controls":n?`terminal-drawer`:void 0,"aria-keyshortcuts":e,onClick:IX,className:t,children:(0,U.jsx)(Fg,{"aria-hidden":`true`,className:`size-4`})})})}function QX(e){let[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(``),a=(0,m.useCallback)(async()=>{try{n(await R(`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 $X({height:e,max:t}){let n=(0,m.useRef)(null);return(0,U.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-label":`Resize terminal`,"aria-orientation":`horizontal`,"aria-valuenow":e,"aria-valuemin":wX.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&&LX(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:()=>LX(wX.start),onKeyDown:n=>{(n.key===`ArrowUp`||n.key===`ArrowDown`)&&(n.preventDefault(),LX(Math.min(t,e+(n.key===`ArrowUp`?24:-24))))}})}function eZ({toggleKey:e}){let t=RX(),n=HX(),r=zX(),i=tO(t&&n,eO.sheet),{list:a,error:o,reload:s}=QX(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 R(`terminal.open`,{cols:100,rows:24});l(e.id),await s()}catch(e){W.error(e instanceof Error?e.message:`The terminal did not start.`)}finally{d(!1)}},[s]),v=(0,m.useCallback)(async e=>{try{await R(`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,U.jsx)(tZ,{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,U.jsx)(qD,{open:i,onOpenChange:e=>{e||FX(!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,U.jsx)(`div`,{id:`terminal-drawer`,className:`flex min-h-0 flex-1`,children:x})}):(0,U.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,U.jsx)($X,{height:Math.min(r,f),max:f}),x]})}function tZ({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,U.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,U.jsx)(XX,{label:`New terminal`,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`New terminal`,disabled:i||e?.available===!1,onClick:c,className:YX,children:(0,U.jsx)(sg,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,U.jsx)(XX,{label:`End this terminal`,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`End this terminal`,disabled:!r,onClick:()=>r&&l(r.id),className:YX,children:(0,U.jsx)(Gg,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,U.jsx)(XX,{label:a?`Back to the drawer`:`Open in a pop-up`,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Pop out terminal`,"aria-pressed":a,onClick:()=>VX(!a),className:YX,children:(0,U.jsx)(rg,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,U.jsx)(XX,{label:`Hide terminal`,hint:o,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Hide terminal`,onClick:()=>FX(!1),className:YX,children:a?(0,U.jsx)(s_,{"aria-hidden":`true`,className:`size-3.5`}):(0,U.jsx)(tm,{"aria-hidden":`true`,className:`size-3.5`})})})]}),f=(0,U.jsx)(U.Fragment,{children:e&&!e.available?(0,U.jsx)(`p`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:e.reason}):t?(0,U.jsx)(`p`,{role:`alert`,className:`flex h-full items-center justify-center px-6 text-center text-sm text-destructive`,children:t}):(0,U.jsxs)(m.Suspense,{fallback:(0,U.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`Loading the terminal…`}),children:[e&&n.length===0&&!i?(0,U.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,U.jsx)(JX,{id:e.id,active:e.id===r?.id,toggleKey:o,onExit:u},e.id))]})}),p=n.length>1?(0,U.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,U.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,U.jsx)(Fg,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate`,children:e.title}),e.alive?null:(0,U.jsx)(`span`,{className:`sr-only`,children:`, ended`})]},e.id))}):null;return a?(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border/70 pr-2 pl-4`,children:[(0,U.jsx)(Fg,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`flex-1 text-sm font-medium`,children:`Terminal`}),d]}),(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`min-w-0 flex-1 py-2 pl-2`,children:(0,U.jsx)(`div`,{className:`relative h-full`,children:f})}),p]})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[f,(0,U.jsx)(`div`,{className:`pointer-events-none absolute top-2 right-2 z-20`,children:d})]}),p]})}var nZ=(0,m.lazy)(()=>qX(()=>import(`./CodeSurface-D3c12DBE.js`),__vite__mapDeps([4,1,2]))),rZ=`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 iZ({label:e,hint:t,children:n}){return(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:n}),(0,U.jsxs)(nR,{side:`bottom`,children:[e,` `,t?(0,U.jsx)(GD,{chord:t}):null]})]})}function aZ({hint:e,className:t}){let{open:n}=cz();return(0,U.jsx)(iZ,{label:`Code and changes`,hint:e,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Code`,"aria-pressed":n,"aria-keyshortcuts":e,onClick:()=>n?oz():az(),className:t,children:(0,U.jsx)(Vm,{"aria-hidden":`true`,className:`size-4`})})})}var oZ={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 sZ(e){let t=e.lastIndexOf(`/`);return t<0?{dir:``,name:e}:{dir:e.slice(0,t),name:e.slice(t+1)}}function cZ({change:e,className:t}){return e.additions===void 0&&e.deletions===void 0?null:(0,U.jsxs)(`span`,{className:Y(`shrink-0 font-mono text-[0.6875rem] tabular-nums`,t),children:[(0,U.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions??0]}),` `,(0,U.jsxs)(`span`,{className:`text-destructive`,children:[`−`,e.deletions??0]})]})}function lZ(){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 uZ({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,U.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,U.jsx)(`form`,{onSubmit:u,className:`border-b border-border p-2`,children:(0,U.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,U.jsx)(Cg,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,U.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,U.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 px-3 text-xs`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:`Changes`}),(0,U.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[c.length,e?.truncated?`+`:``]}),(0,U.jsx)(cZ,{change:l,className:`ml-auto`}),(0,U.jsx)(iZ,{label:`Read the changes again`,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Refresh changes`,onClick:a,disabled:t,className:Y(rZ,`-mr-1.5 size-6`,c.length?``:`ml-auto`),children:(0,U.jsx)(lg,{"aria-hidden":`true`,className:Y(`size-3.5`,t&&`animate-spin motion-reduce:animate-none`)})})})]}),(0,U.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}=sZ(e.path),a=oZ[e.status];return(0,U.jsx)(`li`,{children:(0,U.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,U.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,U.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,U.jsx)(`span`,{className:`ml-1.5 text-xs text-muted-foreground`,children:t}):null]}),(0,U.jsx)(cZ,{change:e})]})},e.path)}),e&&!e.git?(0,U.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,U.jsx)(`li`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:`No changes since the last commit.`}):null,n?(0,U.jsx)(`li`,{role:`alert`,className:`px-2 py-3 text-xs text-destructive`,children:n}):null]})]})}function dZ(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 R(`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 fZ({requested:e,requestedMode:t,request:n,codeKey:r,onClose:i,onDirtyChange:a,closeAsked:o}){let s=DB(`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:_}=dZ(c),[v,y]=(0,m.useState)(),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(),E=hz(),D=gz(),O=lZ(),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 R(`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 be&&e.code===`conflict`?C(!0):W.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&&yJ(e.nativeEvent,r)&&(e.preventDefault(),j({kind:`close`}))}let N=k?.change,P=!!N||k?.original!==void 0,ne=P?u:`code`,{dir:re,name:ie}=sZ(k?.path??c??``),ae=!!(k?.exists&&k.contents!==void 0),oe=N?oZ[N.status]:void 0;return(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1`,onKeyDown:te,children:[(0,U.jsx)(uZ,{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,U.jsxs)(`section`,{"aria-label":`File`,className:`flex min-w-0 flex-1 flex-col`,children:[(0,U.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border pr-2 pl-3`,children:[c?(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[oe?(0,U.jsx)(`span`,{title:oe.word,className:Y(`font-mono text-xs font-semibold`,oe.tone),children:oe.letter}):(0,U.jsx)(Vm,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,U.jsxs)(`h2`,{className:`min-w-0 truncate text-[0.8125rem]`,title:k?.path??c,children:[re?(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[re,`/`]}):null,(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:ie}),A?(0,U.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]}),N?(0,U.jsx)(cZ,{change:N}):null]}):(0,U.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-muted-foreground`,children:`Code`}),P?(0,U.jsx)(qH,{label:`View`,value:ne,onChange:d,items:[{id:`code`,label:`Code`},{id:`diff`,label:`Diff`}]}):null,ne===`diff`?(0,U.jsx)(iZ,{label:D===`split`?`Unified diff`:`Side by side`,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Side by side`,"aria-pressed":D===`split`,onClick:()=>mz(D===`split`?`unified`:`split`),className:rZ,children:D===`split`?(0,U.jsx)(yg,{"aria-hidden":`true`,className:`size-4`}):(0,U.jsx)(km,{"aria-hidden":`true`,className:`size-4`})})}):null,(0,U.jsx)(iZ,{label:E?`Do not wrap lines`:`Wrap long lines`,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Wrap lines`,"aria-pressed":E,onClick:()=>pz(!E),className:rZ,children:(0,U.jsx)(Ug,{"aria-hidden":`true`,className:`size-4`})})}),(0,U.jsx)(iZ,{label:`Save`,hint:`Ctrl+S`,children:(0,U.jsxs)(X,{size:`sm`,variant:A?`default`:`outline`,disabled:!A||b,onClick:()=>void M(),"aria-keyshortcuts":`Control+S Meta+S`,children:[(0,U.jsx)(xg,{"aria-hidden":`true`}),b?`Saving…`:`Save`]})}),(0,U.jsx)(iZ,{label:`Close`,hint:r,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Close code viewer`,onClick:()=>j({kind:`close`}),className:rZ,children:(0,U.jsx)(s_,{"aria-hidden":`true`,className:`size-4`})})})]}),w?(0,U.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,U.jsx)(Zh,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[ie,` has unsaved edits.`]}),(0,U.jsx)(X,{size:`xs`,variant:`ghost`,onClick:()=>T(void 0),children:`Keep editing`}),(0,U.jsx)(X,{size:`xs`,variant:`outline`,onClick:()=>ee(w),children:`Discard`}),(0,U.jsx)(X,{size:`xs`,onClick:()=>void M(),disabled:b,children:`Save`})]}):null,S?(0,U.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,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[ie,` changed on disk since you opened it, maybe by an agent.`]}),(0,U.jsx)(X,{size:`xs`,variant:`outline`,onClick:()=>{y(void 0),C(!1),_()},children:`Load theirs`}),(0,U.jsx)(X,{size:`xs`,onClick:()=>void M(!0),disabled:b,children:`Overwrite with mine`})]}):null,(0,U.jsx)(`div`,{className:`code-pane relative flex min-h-0 flex-1 flex-col`,children:h?(0,U.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,U.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&&ne===`code`?(0,U.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,U.jsx)(Zm,{"aria-hidden":`true`,className:`size-5`}),`This file was deleted. Switch to Diff to see what it held.`]}):(0,U.jsx)(m.Suspense,{fallback:(0,U.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:`Loading code…`}),children:(0,U.jsx)(nZ,{path:k.path,version:`${f.version}`,contents:k.contents??``,draft:v,original:k.original,mode:ne,layout:D,wrap:E,dark:O,readOnly:!ae,onDraft:y})}):(0,U.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:g?`Opening…`:``}):(0,U.jsx)(pZ,{loading:s.loading})})]})]})}function pZ({loading:e}){return(0,U.jsxs)(`div`,{className:`m-auto flex max-w-xs flex-col items-center gap-2 px-6 text-center`,children:[(0,U.jsx)(Gm,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`}),(0,U.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 mZ({codeKey:e}){let{open:t,path:n,mode:r,request:i}=cz(),a=tO(t,eO.help),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(0),u=()=>l(e=>e+1);return(0,U.jsx)(qD,{open:a,onOpenChange:e=>{e||(o?u():oz())},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,U.jsx)(fZ,{requested:n,requestedMode:r,request:i,codeKey:e,onClose:oz,onDirtyChange:s,closeAsked:c}):null})}function hZ(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 gZ(){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 Ce()?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(hZ(e))}return(0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-y-auto p-6`,children:(0,U.jsxs)(`form`,{onSubmit:s,className:`glass flex min-h-0 w-full max-w-md flex-col gap-4 rounded-xl p-6`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(lh,{className:`size-5`,"aria-hidden":`true`}),(0,U.jsx)(`h1`,{className:`text-base font-medium`,children:`Sign in to bot-lobby`})]}),(0,U.jsxs)(`p`,{className:`break-words text-sm text-muted-foreground`,children:[`Pi printed a link when it started (or run `,(0,U.jsx)(`code`,{className:`rounded-lg bg-muted px-1.5 py-0.5 font-mono text-xs`,children:`/bot-lobby web`}),`to see it again). Paste it here.`]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:`Lobby link or token`}),(0,U.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),autoComplete:`off`,spellCheck:!1,placeholder:`http://127.0.0.1:7347/#token=…`,className:`h-8 min-w-0 rounded-lg border border-input bg-background px-3.5 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30`})]}),n?(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:n}):null,(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,U.jsx)(X,{type:`button`,variant:`ghost`,disabled:i,onClick:()=>void o(void 0),children:`Retry`}),(0,U.jsx)(X,{type:`submit`,disabled:i||!e.trim(),children:`Sign in`})]})]})})}var _Z=.6;function vZ(e,t,n={}){return{initial:e?void 0:!1,animate:t,transition:{duration:_Z,...n}}}var yZ=(e,t)=>[0,Math.max(e,.001),Math.min(Math.max(t,e+.01),.999),1];function bZ(e,t=0,n=1){return vZ(e,{pathLength:[0,0,1,1],strokeOpacity:[0,0,1,1]},{pathLength:{duration:_Z,times:yZ(t,n),ease:`easeInOut`},strokeOpacity:{duration:_Z,times:yZ(t,t+.02)}})}function xZ(e,t){return vZ(e,{scale:[0,0,1.3,1]},{times:yZ(t,t+.18),ease:`easeOut`})}function SZ(e,t,n=1.3){return vZ(e,{scale:[1,1,n,1,1]},{times:[0,Math.max(t,.001),Math.min(t+.15,.9),Math.min(t+.35,.99),1],ease:`easeInOut`})}var CZ=(e=.5,t=.5)=>({transformBox:`fill-box`,originX:e,originY:t});function wZ({play:e}){return(0,U.jsxs)(Xf.g,{style:CZ(.1,.9),...vZ(e,{rotate:[0,-12,8,-4,0],scale:[1,1.12,.96,1.02,1]},{ease:`easeInOut`}),children:[(0,U.jsx)(`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`}),[8,12,16].map((t,n)=>(0,U.jsx)(Xf.circle,{cx:t,cy:11,r:1.15,fill:`currentColor`,stroke:`none`,...vZ(e,{fillOpacity:[0,0,1,1,0],y:[0,0,-1.5,0,0]},{times:[0,.12+n*.12,.24+n*.12,.72,1]})},t))]})}function TZ({play:e}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Xf.path,{d:`M13 5h8`,...bZ(e,.15,.45)}),(0,U.jsx)(Xf.path,{d:`M13 12h8`,...bZ(e,.3,.6)}),(0,U.jsx)(Xf.path,{d:`M13 19h8`,...bZ(e,.45,.75)}),(0,U.jsx)(Xf.path,{d:`m3 17 2 2 4-4`,...bZ(e,.35,.7)}),(0,U.jsx)(Xf.path,{d:`m3 7 2 2 4-4`,...bZ(e,0,.35)})]})}function EZ({play:e}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Xf.circle,{cx:6,cy:19,r:3,style:CZ(),...SZ(e,0)}),(0,U.jsx)(Xf.path,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,...bZ(e,.1,.7)}),(0,U.jsx)(Xf.circle,{cx:18,cy:5,r:3,style:CZ(),...xZ(e,.62)})]})}function DZ({play:e}){return(0,U.jsxs)(Xf.g,{style:CZ(),...vZ(e,{scaleX:[1,.55,1.08,1],y:[0,-1,0,0]},{times:[0,.35,.65,1],ease:`easeInOut`}),children:[(0,U.jsx)(Xf.path,{d:`M12 5v16`,style:CZ(),...vZ(e,{scaleY:[1,1.12,1,1]},{times:[0,.35,.65,1]})}),(0,U.jsx)(`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`})]})}var OZ={lobby:wZ,tasks:TZ,plan:EZ,knowledge:DZ};function kZ({id:e,play:t,className:n}){let r=OZ[e];return r?(0,U.jsx)(`svg`,{"aria-hidden":`true`,"data-tab-icon":e,"data-play":t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:Y(`overflow-visible`,n),children:(0,U.jsx)(r,{play:t})},t):null}function AZ(e){return/(\d)$/.exec(e)?.[1]}var jZ=160;function MZ(e){let t=Ef(),[n,r]=(0,m.useState)(0),i=(0,m.useRef)(0),a=(0,m.useCallback)(()=>{t||performance.now()<i.current||(i.current=performance.now()+_Z*1e3,r(e=>e+1))},[t]),o=(0,m.useRef)(e);return(0,m.useEffect)(()=>{let t=e&&!o.current;if(o.current=e,!t)return;let n=window.setTimeout(a,jZ);return()=>window.clearTimeout(n)},[e,a]),{play:n,onPointerEnter:(0,m.useCallback)(e=>{e.pointerType!==`touch`&&a()},[a])}}var NZ=(0,m.forwardRef)(function({tab:e,active:t},n){let r=AZ(e.key),{play:i,onPointerEnter:a}=MZ(t);return(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsxs)(`a`,{ref:n,role:`tab`,id:`tab-${e.id}`,href:`#/${e.id}`,"aria-selected":t,"aria-keyshortcuts":e.key,tabIndex:t?0:-1,onPointerEnter:a,className:Y(`relative z-10 inline-flex h-7 shrink-0 items-center gap-1.5 rounded-lg border border-[var(--tab-outline)] px-2.5 text-[0.8125rem] leading-none font-medium whitespace-nowrap outline-none`,`transition-colors duration-200 ease-snap focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t?`text-foreground`:`bg-[var(--tab-idle)] text-muted-foreground hover:bg-accent hover:text-foreground`),children:[(0,U.jsx)(kZ,{id:e.id,play:i,className:Y(`size-3.5 shrink-0 transition-colors duration-200`,t&&`text-primary`)}),r?(0,U.jsx)(`span`,{"aria-hidden":`true`,className:Y(`text-[0.72rem] font-semibold tabular-nums transition-colors duration-200`,t?`text-primary`:`text-muted-foreground/75`),children:r}):null,(0,U.jsx)(`span`,{children:e.label})]})}),(0,U.jsxs)(nR,{children:[e.label,` `,(0,U.jsx)(GD,{chord:e.key})]})]})}),PZ=1.5;function FZ(e,t,n=t?.left??0,r=t?.right??0,i=1){if(e){if(!t||r-n<.5){e.style.opacity=`0`;return}e.style.opacity=String(Math.min(1,(r-n)/14)),e.style.top=`${t.top}px`,e.style.height=`${t.height}px`,e.style.width=`${r-n}px`,e.style.transform=`translateX(${n}px)`,e.style.scale=i===1?``:`1 ${i}`}}function IZ(e,t){let n=e.right-e.left,{height:r}=e,i=PZ/2,a=Math.max(0,Math.min(e.radius-i,r/2-i,n/2-i)),o=r/2,s=e=>+(t===`left`?e:n-e).toFixed(2),c=+(t===`left`),l=1-c,u=i,d=n-i,f=r-i;return[`M${s(u)} ${o}L${s(u)} ${i+a}A${a} ${a} 0 0 ${c} ${s(u+a)} ${i}L${s(d-a)} ${i}A${a} ${a} 0 0 ${c} ${s(d)} ${i+a}L${s(d)} ${o}`,`M${s(u)} ${o}L${s(u)} ${f-a}A${a} ${a} 0 0 ${l} ${s(u+a)} ${f}L${s(d-a)} ${f}A${a} ${a} 0 0 ${l} ${s(d)} ${f-a}L${s(d)} ${o}`]}function LZ(e,t,n,r){if(!e)return;if(!t||r<=.002){e.style.opacity=`0`;return}let i=t.right-t.left,a=`${i}x${t.height}r${t.radius}${n}`;e.dataset.shape!==a&&(e.dataset.shape=a,e.dataset.port=n,e.setAttribute(`viewBox`,`0 0 ${i} ${t.height}`),IZ(t,n).forEach((t,n)=>e.children[n]?.setAttribute(`d`,t))),e.style.opacity=String(Math.min(1,r*12)),e.style.top=`${t.top}px`,e.style.height=`${t.height}px`,e.style.width=`${i}px`,e.style.transform=`translateX(${t.left}px)`;let o=`${Math.min(1,r)} 2`;for(let t of e.children)t.style.strokeDasharray=o}var RZ={type:`spring`,visualDuration:.12,bounce:0},zZ={type:`spring`,visualDuration:.17,bounce:.15,delay:.015},BZ={type:`spring`,visualDuration:.17,bounce:.05,delay:.07},VZ={type:`spring`,visualDuration:.22,bounce:.25},HZ={type:`spring`,visualDuration:.2,bounce:0},UZ={type:`spring`,stiffness:900,damping:18,velocity:45,restDelta:.02,restSpeed:1},WZ=(()=>{let e=Dr({keyframes:[0,1],visualDuration:VZ.visualDuration,bounce:VZ.bounce}),t=0;for(;t<1e3&&e.next(t).value<.97;)t+=4;return t/1e3})(),GZ={type:`spring`,visualDuration:.28,bounce:.6};function KZ(e,t){let n=(0,m.useRef)(null),r=(0,m.useRef)(null),i=(0,m.useRef)(null),a=(0,m.useRef)(null),o=(0,m.useRef)(null),s=(0,m.useRef)({}),c=(0,m.useRef)([]),l=(0,m.useRef)(void 0),u=(0,m.useRef)([]),d=(0,m.useRef)(1),f=(0,m.useRef)(1),p=(0,m.useCallback)(e=>{let t=e?s.current[e]:void 0;if(!t)return;let n=parseFloat(getComputedStyle(t).borderTopLeftRadius)||0;return{left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,top:t.offsetTop,height:t.offsetHeight,radius:n}},[]),h=(0,m.useCallback)(()=>{for(let e of u.current)e.stop();u.current=[];for(let e of Object.values(s.current))e?.style.translate&&(e.style.translate=``)},[]),g=(0,m.useCallback)(e=>{h(),l.current=e,d.current=1,f.current=1;let t=p(e);FZ(r.current,t),FZ(i.current,void 0),LZ(a.current,t,`left`,1),LZ(o.current,void 0,`left`,0);for(let e of c.current)e&&(e.style.width=`0px`);YR()},[p,h]),_=(0,m.useCallback)((e,t)=>{let n=p(e),m=p(t);if(!n||!m)return g(t);h(),JR(),l.current=t;let _=m.left>n.left?1:-1,v=_>0?n.right:n.left,y=_>0?m.left:m.right,b=Math.abs(y-v),x=_>0?`right`:`left`,S=_>0?`left`:`right`,C=c.current.map(e=>{let t=e?.parentElement;return t?{liquid:e,from:t.offsetLeft,to:t.offsetLeft+t.offsetWidth}:void 0}),w=b>4?1-4/b:0,T={drained:1-Math.min(1,d.current),unrung:1-Math.min(1,f.current),head:0,tail:0,filled:0,rung:0,squash:1,budge:0},E=s.current[t];d.current=0,f.current=0;let D=()=>{let e=(n.right-n.left)*Math.min(1,T.drained);FZ(i.current,n,_>0?n.left+e:n.left,_>0?n.right:n.right-e),LZ(o.current,n,x,1-T.unrung);let t=v+_*b*T.head,s=v+_*b*T.tail,c=Math.min(t,s),l=Math.max(t,s);for(let e of C){if(!e?.liquid)continue;let t=Math.max(c,e.from),n=Math.min(l,e.to);e.liquid.style.width=`${Math.max(0,n-t)}px`,e.liquid.style.transform=`translateX(${Math.max(0,t-e.from)}px)`}let u=_*T.budge,d=u?{...m,left:m.left+u,right:m.right+u}:m;E&&(E.style.translate=Math.abs(u)>.01?`${u.toFixed(2)}px`:``);let f=(d.right-d.left)*Math.min(1,Math.max(0,T.filled));FZ(r.current,d,_>0?d.left:d.right-f,_>0?d.left+f:d.right,Math.min(1,T.squash)),LZ(a.current,d,S,T.rung)},O=(e,t,n,r,i=1)=>{let a=Yf(t,i,{...n,onUpdate:t=>{T[e]=t,r?.(t),D()}});return u.current.push(a),a},k=!1,A=()=>{if(k)return;k=!0;let e=O(`filled`,0,VZ,e=>{d.current=e});e.then(()=>{l.current===t&&YR()}),O(`squash`,.8,GZ),O(`rung`,0,HZ,e=>{f.current=e}),O(`budge`,0,{...UZ,delay:WZ},void 0,0),Promise.all([e,...u.current]).then(()=>{l.current===t&&u.current.includes(e)&&g(t)})};O(`drained`,T.drained,RZ),O(`unrung`,T.unrung,RZ),O(`head`,0,zZ,e=>{e>=w&&A()}),O(`tail`,0,BZ),D()},[p,g,h]);(0,m.useLayoutEffect)(()=>{let t=l.current,n=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;!t||!e||t===e||n?g(e):_(t,e)},[e,t,_,g]);let v=(0,m.useRef)(e);return v.current=e,(0,m.useEffect)(()=>{let e=n.current;if(!e||typeof ResizeObserver>`u`)return;let t=!0,r=new ResizeObserver(()=>{if(t){t=!1;return}g(v.current)});return r.observe(e),()=>{r.disconnect(),h()}},[g,h]),{track:n,fill:r,drain:i,ring:a,unring:o,cells:s,liquids:c}}var qZ=(0,m.forwardRef)(function({which:e},t){return(0,U.jsxs)(`svg`,{ref:t,"aria-hidden":`true`,[`data-tab-${e}`]:``,className:`pointer-events-none absolute left-0 z-20 overflow-visible opacity-0 will-change-transform`,fill:`none`,children:[(0,U.jsx)(`path`,{pathLength:1,strokeWidth:PZ,strokeLinecap:`round`,className:`stroke-tab-rim`}),(0,U.jsx)(`path`,{pathLength:1,strokeWidth:PZ,strokeLinecap:`round`,className:`stroke-tab-rim`})]})});function JZ(e){if(e.left||e.right)return`linear-gradient(to right, ${e.left?`transparent 0, black 28px`:`black 0`}, ${e.right?`black calc(100% - 28px), transparent 100%`:`black 100%`})`}function YZ({tabs:e,activeId:t,onSelect:n}){let{track:r,fill:i,drain:a,ring:o,unring:s,cells:c,liquids:l}=KZ(t,e.length),u=(0,m.useRef)(null),[d,f]=(0,m.useState)({left:!1,right:!1}),p=(0,m.useCallback)(()=>{let e=u.current;if(!e)return;let t=e.scrollLeft>2,n=e.scrollLeft+e.clientWidth<e.scrollWidth-2;f(e=>e.left===t&&e.right===n?e:{left:t,right:n})},[]);(0,m.useEffect)(()=>{let e=u.current;if(!e||typeof ResizeObserver>`u`)return;p();let t=new ResizeObserver(p);return t.observe(e),e.firstElementChild&&t.observe(e.firstElementChild),()=>t.disconnect()},[p,e.length]),(0,m.useEffect)(()=>{let e=u.current,n=t?c.current[t]:void 0;e&&n&&(n.offsetLeft<e.scrollLeft?e.scrollLeft=n.offsetLeft-8:n.offsetLeft+n.offsetWidth>e.scrollLeft+e.clientWidth&&(e.scrollLeft=n.offsetLeft+n.offsetWidth-e.clientWidth+8))},[t,c]);function h(r){if(r.key===`ArrowDown`&&!r.altKey){pR()&&r.preventDefault();return}let i=r.key===`ArrowRight`?1:r.key===`ArrowLeft`?-1:0;if(!i||e.length===0)return;r.preventDefault();let a=r.target.closest(`[role='tab']`)?.id.replace(/^tab-/,``)??t,o=e[(Math.max(0,e.findIndex(e=>e.id===a))+i+e.length)%e.length];hR.active=!0,hR.to=o.id,window.setTimeout(()=>{hR.active=!1,hR.to=void 0},3e3),n(o.id),c.current[o.id]?.focus({preventScroll:!0})}return(0,U.jsx)(`div`,{ref:u,onScroll:p,style:{maskImage:JZ(d),WebkitMaskImage:JZ(d)},className:`min-w-0 max-w-full overflow-x-auto [scrollbar-width:none] pointer-coarse:-my-1.5 pointer-coarse:py-1.5 [&::-webkit-scrollbar]:hidden`,children:(0,U.jsxs)(`div`,{ref:r,role:`tablist`,"aria-label":`Lobby tabs`,onKeyDown:h,className:`relative mx-auto flex w-max items-center py-0.5`,children:[(0,U.jsx)(`span`,{ref:a,"aria-hidden":`true`,"data-tab-drain":!0,className:`pointer-events-none absolute left-0 z-0 rounded-lg bg-tab-fill opacity-0 will-change-transform`}),(0,U.jsx)(`span`,{ref:i,"aria-hidden":`true`,"data-tab-fill":!0,className:`pointer-events-none absolute left-0 z-0 rounded-lg bg-tab-fill opacity-0 will-change-transform`}),(0,U.jsx)(qZ,{ref:s,which:`unring`}),(0,U.jsx)(qZ,{ref:o,which:`ring`}),e.map((e,n)=>(0,U.jsxs)(m.Fragment,{children:[n>0?(0,U.jsxs)(`span`,{"aria-hidden":`true`,"data-tab-link":!0,className:`relative h-[2px] w-3.5 shrink-0 sm:w-4`,children:[(0,U.jsx)(`span`,{className:`absolute inset-0 border-t-2 border-dotted border-input`}),(0,U.jsx)(`span`,{ref:e=>{l.current[n-1]=e},"data-tab-liquid":!0,className:`absolute top-0 left-0 h-[2px] w-0 rounded-full bg-tab-liquid shadow-[0_0_6px_var(--tab-liquid)] will-change-transform`})]}):null,(0,U.jsx)(NZ,{ref:t=>{c.current[e.id]=t},tab:e,active:e.id===t})]},e.id))]})})}function XZ({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(gO(bO(e)));for(let e of n)e.pending&&e.source!==`LOBBY`&&i.add(e.source===`MASTER`?`Oracle`:gO(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 ZZ(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}var QZ=6,$Z=`bot-lobby.orb`,eQ=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=1;function tQ(e,t,n,r){let i=e=>e+QZ,a=(e,t)=>Math.max(e+QZ,e+t-r-QZ);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 nQ(e,t,n,r){let i=e=>Math.max(1,e-r),a=tQ(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 rQ(e,t,n){return tQ(t.left+e.fx*Math.max(0,t.width-n),t.top+e.fy*Math.max(0,t.height-n),t,n)}function iQ(e){if(e)try{let t=JSON.parse(e);return eQ(t.fx)&&eQ(t.fy)?{fx:t.fx,fy:t.fy}:void 0}catch{return}}function aQ(){try{return iQ(localStorage.getItem($Z))}catch{return}}function oQ(e){try{localStorage.setItem($Z,JSON.stringify(e))}catch{}}var sQ=5,cQ=16;function lQ(e){return{left:e.left,top:e.top,width:e.width,height:e.height}}function uQ(){let e=document.getElementById(`main`)?.getBoundingClientRect();return e?lQ(e):void 0}function dQ(e,t){return!e||!t?e===t:e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function fQ(){let[e,t]=(0,m.useState)(()=>uQ());return(0,m.useEffect)(()=>{let e=()=>{let e=uQ();t(t=>dQ(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 pQ=(0,m.forwardRef)(function({spotlight:e,thinking:t,busy:n=[],tone:r,expanded:i,hidden:a,shortcut:o,onOpen:s},c){let l=fQ(),[u,d]=(0,m.useState)(aQ),[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?rQ(u,l,y.current):void 0),x=(0,m.useCallback)((e,t)=>{let n=uQ();if(!n)return;let r=nQ(e,t,n,y.current);d(r),oQ(r)},[]);(0,m.useEffect)(()=>{l&&p(e=>e&&tQ(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)<sQ)return;t.moved=!0;let i=uQ();i&&p(tQ(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:cQ,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?gO(e):E?ZZ(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(gO).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,U.jsxs)(eR,{open:h&&!f,onOpenChange:g,children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.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,U.jsx)(ju,{initial:!1,children:D?(0,U.jsx)(Xf.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,U.jsx)(ju,{mode:`popLayout`,initial:!1,children:(0,U.jsx)(Xf.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,U.jsx)(`span`,{"aria-hidden":`true`,className:`orb orb-float`,children:(0,U.jsx)(`span`,{className:`orb-icon`,children:(0,U.jsx)(pO,{source:k,strokeWidth:2.25,className:`size-3.5`})})})]})}),(0,U.jsxs)(nR,{side:`top`,children:[`Thinking `,o?(0,U.jsx)(GD,{chord:o}):null,(0,U.jsx)(`span`,{className:`text-background/70`,children:` · drag to move`})]})]})}),mQ=/^\s*(?:#{1,6}\s+(.+?)\s*#*|\*\*([^*\n]{2,90}?):?\*\*:?|__([^_\n]{2,90}?):?__:?)\s*$/,hQ=260,gQ=200,_Q=/^\s*(?:[-*+]\s|\d+[.)]\s|>|```|~~~|\|)/m;function vQ(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=XJ.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 QJ({rest:e}){let{chat:t}=gB(e);return(0,U.jsx)(`div`,{role:`group`,"aria-label":`Knowledge pane`,className:`flex items-center gap-0.5 rounded-lg bg-muted p-0.5`,children:[`Chat`,`Docs`].map(n=>(0,U.jsx)(`button`,{type:`button`,"aria-pressed":t===(n===`Chat`),onClick:()=>mB(_B(e,n===`Chat`)),className:Y(`h-6 rounded-md border px-2.5 text-xs font-medium outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t===(n===`Chat`)?`btn-outline btn-soft bg-card text-foreground`:`btn-ghost text-muted-foreground hover:text-foreground`),children:n},n))})}function $J(e,t){return Y(`relative inline-flex shrink-0 cursor-pointer items-center justify-center whitespace-nowrap rounded-(--control-radius) border border-transparent text-base outline-none hover:bg-accent data-pressed:bg-accent data-[state=open]:bg-accent aria-expanded:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-64 data-disabled:pointer-events-none data-disabled:opacity-64 pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 [&:active:not([aria-haspopup])]:scale-[0.97] motion-reduce:[&:active:not([aria-haspopup])]:scale-100 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:-mx-0.5 [&_svg[data-composer-control-icon]]:mx-0`,e===`xs`?`h-7 gap-1 px-1.75 font-normal text-muted-foreground/70 text-sm hover:text-foreground/80 sm:h-[1.625rem] sm:text-xs [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5 [&_svg[data-composer-control-chevron]]:ms-0 [&_svg[data-composer-control-chevron]]:-me-1`:`h-7 gap-1.5 px-2.5 font-medium text-secondary-label [&_svg:not([class*='text-'])]:text-muted-foreground hover:text-foreground sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4`,`aria-pressed:bg-accent aria-pressed:text-accent-foreground aria-pressed:hover:bg-accent/80`,t)}function eY(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 R(`projects.open`,{path:r});_e([t]),L(t.id,e)}catch(e){i(e.message)}finally{n(!1)}}}return{opening:t,error:r,open:a}}function tY({path:e,parent:t,busy:n,browse:r}){let[i,a]=(0,m.useState)(e);return(0,m.useEffect)(()=>a(e),[e]),(0,U.jsxs)(`form`,{className:`flex h-9 min-w-0 items-center rounded-md border border-input bg-background shadow-xs transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/20`,onSubmit:e=>{e.preventDefault(),r(i)},children:[(0,U.jsx)(`button`,{type:`button`,"aria-label":`Parent folder`,title:`Parent folder (Backspace)`,disabled:n||!t,onClick:()=>t&&r(t),className:`grid h-full w-9 shrink-0 place-items-center border-r border-input text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:bg-muted disabled:pointer-events-none disabled:opacity-40`,children:(0,U.jsx)(zp,{"aria-hidden":`true`,className:`size-4`})}),(0,U.jsx)(`input`,{"aria-label":`Folder path`,value:i,disabled:n,spellCheck:!1,autoComplete:`off`,onChange:e=>a(e.target.value),className:`h-full min-w-0 flex-1 bg-transparent px-3 font-mono text-[0.8125rem] text-foreground outline-none placeholder:text-muted-foreground disabled:opacity-60`}),(0,U.jsx)(`button`,{type:`submit`,disabled:n||!i.trim(),className:`h-full shrink-0 border-l border-input px-3 text-xs font-medium text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:bg-muted disabled:pointer-events-none disabled:opacity-40`,children:`Go`})]})}function nY(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 rY({data:e,loading:t,busy:n,browse:r}){let i=e?.folders.length??0;return(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-md border border-border`,children:[(0,U.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center justify-between border-b border-border bg-muted/50 px-3 text-[0.7rem] font-medium tracking-wide text-muted-foreground uppercase`,children:[(0,U.jsx)(`span`,{children:`Name`}),(0,U.jsx)(`span`,{className:`normal-case tracking-normal`,children:t?`Loading…`:`${i.toLocaleString()} ${i===1?`folder`:`folders`}${e?.truncated?` (first 2,000)`:``}`})]}),(0,U.jsxs)(`div`,{"aria-label":`Folders`,role:`group`,onKeyDown:t=>nY(t,e?.parent,r),className:`h-64 overflow-y-auto overscroll-contain py-1`,children:[e?.folders.map(e=>{let t=e.name.startsWith(`.`);return(0,U.jsxs)(`button`,{type:`button`,"data-folder":!0,disabled:n,onClick:()=>r(e.path),title:e.path,className:`group/row flex h-8 w-full min-w-0 items-center gap-2.5 px-3 text-left text-[0.8125rem] transition-colors outline-none hover:bg-muted focus-visible:bg-accent focus-visible:text-accent-foreground disabled:opacity-60`,children:[(0,U.jsx)(rh,{"aria-hidden":`true`,className:Y(`size-4 shrink-0`,t?`text-muted-foreground/60`:`text-muted-foreground`)}),(0,U.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate`,t&&`text-muted-foreground`),children:e.name}),(0,U.jsx)(am,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground/0 transition-colors group-hover/row:text-muted-foreground group-focus-visible/row:text-muted-foreground`})]},e.path)}),e&&!i?(0,U.jsx)(`p`,{className:`px-3 py-6 text-center text-xs text-muted-foreground`,children:`No subfolders. You can open this folder.`}):null,e?.truncated?(0,U.jsx)(`p`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:`Only the first 2,000 entries are listed. Enter a path to go further.`}):null]})]})}function iY({tab:e,close:t,busyChanged:n}){let[r,i]=(0,m.useState)(),a=EB(`projects.browse`,r===void 0?{}:{path:r},[]),o=eY(e);return(0,m.useEffect)(()=>n(o.opening),[o.opening,n]),(0,U.jsxs)(`div`,{className:`flex min-h-0 max-h-full w-full flex-col overflow-y-auto`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border px-4 py-3`,children:[(0,U.jsx)(`h2`,{className:`text-[0.9375rem] font-semibold`,children:`Open project folder`}),(0,U.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:`Folders on the machine running bot-lobby. The project opens in a session of its own; this one keeps running, and its project-local extensions stay off until you enable them.`})]}),(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3 p-4`,children:[(0,U.jsx)(tY,{path:a.data?.path??r??``,parent:a.data?.parent,busy:o.opening,browse:i}),(0,U.jsx)(rY,{data:a.data,loading:a.loading,busy:a.loading||o.opening,browse:i}),a.loading?(0,U.jsx)(`p`,{role:`status`,className:`sr-only`,children:`Loading folders…`}):null,a.error||o.error?(0,U.jsx)(`p`,{role:`alert`,className:`break-words text-xs text-destructive`,children:a.error??o.error}):null]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 border-t border-border bg-muted/30 px-4 py-3`,children:[a.error?(0,U.jsx)(X,{variant:`outline`,onClick:a.reload,disabled:a.loading,children:`Retry`}):null,(0,U.jsx)(X,{variant:`outline`,onClick:t,disabled:o.opening,children:`Cancel`}),(0,U.jsx)(X,{disabled:!a.data||a.loading||!!a.error||o.opening,onClick:()=>void o.open(a.data.path),children:o.opening?`Opening project…`:`Open this folder`})]})]})}function aY({open:e,onClose:t,tab:n}){let r=tO(e,eO.help),[i,a]=(0,m.useState)(!1);return(0,U.jsx)(qD,{open:r,label:`Open project folder`,className:`max-w-[40rem]`,onOpenChange:e=>{!e&&!i&&t()},dismissOnBackdrop:!i,onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[role="combobox"][aria-label="Project"]`)?.focus()},children:e?(0,U.jsx)(iY,{tab:n,close:t,busyChanged:a}):null})}function oY(){try{return{id:fe()}}catch(e){return{error:e.message}}}function sY(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 cY(){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 R(`projects.list`,{});_e(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 lY({data:e,error:t}){let n=oY();return n.error??t??sY(e,n.id)}function uY({projects:e}){let t=lY(e);return t?(0,U.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,U.jsx)(qg,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,U.jsx)(`span`,{children:t})]}):null}function dY(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']`)];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 fY=`bot-lobby:open-projects`;function pY({projects:e,tab:t,name:n,branch:r}){let{data:i,busy:a,slow:o,refresh:s}=e,[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=oY(),p=lY(e),h=f.error?`invalid`:f.id??i?.currentId??``;bR(`p`,()=>l(!0)),(0,m.useEffect)(()=>{let e=()=>l(!0);return window.addEventListener(fY,e),()=>window.removeEventListener(fY,e)},[]),bR(`r`,()=>void s(),{enabled:c,inDialog:!0});function g(e){l(!1),e!==h&&L(e,t)}return(0,U.jsxs)(`div`,{"aria-busy":a,className:`flex min-w-0 items-center gap-1`,children:[(0,U.jsxs)(wH,{open:c,onOpenChange:l,children:[(0,U.jsxs)(TH,{type:`button`,role:`combobox`,"aria-label":`Project`,"aria-description":`${n}${r?`, branch ${r}`:``}`,"aria-haspopup":`listbox`,"aria-expanded":c,"aria-keyshortcuts":`P ArrowDown`,onKeyDown:e=>{e.key!==`ArrowDown`||e.altKey||e.metaKey||e.ctrlKey||(e.preventDefault(),l(!0))},title:r?`${n} · ${r}`:n,className:Y(`group flex min-w-0 items-center outline-none transition-colors duration-150 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none`,$J(`xs`,`min-w-0 justify-start`)),children:[(0,U.jsx)(rh,{"aria-hidden":`true`,className:Y(`size-3 shrink-0`,p&&`text-destructive`)}),(0,U.jsx)(`span`,{className:`truncate`,children:n}),(0,U.jsx)(tm,{"aria-hidden":`true`,className:`size-3 shrink-0 opacity-50`})]}),(0,U.jsxs)(EH,{align:`start`,side:`top`,sideOffset:8,"aria-label":`Projects`,onKeyDown:dY,onOpenAutoFocus:e=>{let t=e.currentTarget?.querySelector(`[role='option'][aria-selected='true']`)??e.currentTarget?.querySelector(`[role='option']`);t&&(e.preventDefault(),t.focus())},className:`p-0 flex max-h-[calc(100svh-2rem)] w-[min(26rem,calc(100vw-1.5rem))] origin-(--radix-popover-content-transform-origin) flex-col overflow-hidden rounded-xl outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,U.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Running projects`}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>void s(),disabled:a,"aria-label":`Refresh list`,"aria-keyshortcuts":`R`,className:`inline-flex h-7 items-center gap-1.5 rounded-lg px-2 text-xs 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 disabled:opacity-60`,children:[a?(0,U.jsx)(vB,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):(0,U.jsx)(lg,{"aria-hidden":`true`,className:`size-3`}),`Refresh`,(0,U.jsx)(GD,{chord:`R`,className:`kbd-hint`})]})]}),(0,U.jsx)(`div`,{role:`listbox`,"aria-label":`Projects`,className:`flex max-h-72 flex-col overflow-y-auto overscroll-contain p-1`,children:i?.projects.map(e=>{let t=e.id===h;return(0,U.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>g(e.id),className:Y(`flex min-h-10 w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left outline-none transition-colors hover:bg-muted focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t&&`bg-accent`),children:[(0,U.jsx)(`span`,{className:`flex h-5 w-4 shrink-0 items-center justify-center`,children:t?(0,U.jsx)($p,{"aria-hidden":`true`,className:`size-3.5 text-primary`}):null}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block whitespace-normal break-words text-sm font-medium`,children:e.name}),(0,U.jsxs)(`span`,{className:`block whitespace-normal break-all text-xs text-muted-foreground`,children:[e.cwd,` · :`,e.port]})]})]},e.id)})}),(0,U.jsxs)(`button`,{type:`button`,className:`flex min-h-11 items-center gap-2 border-t border-border px-3 py-3 text-sm font-medium outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,onClick:()=>{l(!1),d(!0)},children:[(0,U.jsx)(th,{"aria-hidden":`true`,className:`size-4`}),`Open folder…`]})]})]}),(0,U.jsx)(aY,{open:u,onClose:()=>d(!1),tab:t}),o||p?(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Refresh projects`,disabled:a,onClick:()=>void s(),className:Y(`inline-flex shrink-0 items-center justify-center text-muted-foreground outline-none transition-[background-color,color,scale] hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:scale-[0.97] disabled:opacity-60 motion-reduce:active:scale-100`,$J(`xs`,`w-7 px-0 sm:w-[1.625rem]`)),children:a?(0,U.jsx)(vB,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,U.jsx)(lg,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,U.jsx)(nR,{side:`top`,children:`Refresh projects`})]}):null]})}function mY({contextStrip:e=!1,className:t,...n}){return(0,U.jsx)(`div`,{"data-slot":`composer-shell`,"data-with-context":e||void 0,className:Y(`@container/composer-surface group/composer-surface relative isolate mx-auto w-full max-w-(--chat-content-max-width)`,`[--chat-composer-drawer-inset:1.375rem] [--chat-composer-glass-surface:var(--card)] [--chat-composer-outline:rgb(0_0_0/8%)]`,`dark:[--chat-composer-glass-surface:var(--surface-raised)] dark:[--chat-composer-highlight:rgb(255_255_255/3%)] dark:[--chat-composer-outline:color-mix(in_srgb,var(--color-white)_5%,transparent)]`,`before:pointer-events-none before:absolute before:inset-0 before:z-0 before:rounded-3xl before:bg-(--chat-composer-glass-surface)/(--glass-opacity) before:backdrop-blur-(--glass-blur) before:backdrop-saturate-(--glass-saturation)`,`not-supports-[((backdrop-filter:blur(1px))_or_(-webkit-backdrop-filter:blur(1px)))]:before:bg-(--chat-composer-glass-surface)`,`has-data-[composer-banner-surface=attached]:before:hidden data-model-strip-transition:before:hidden`,e&&[`[--chat-composer-context-extension:2.25rem] sm:[--chat-composer-context-extension:2rem]`,`before:[clip-path:shape(from_0_22px,curve_to_22px_0_with_0_9.85px/9.85px_0,line_to_calc(100%-22px)_0,curve_to_100%_22px_with_calc(100%-9.85px)_0/100%_9.85px,line_to_100%_calc(100%-var(--chat-composer-context-extension)-var(--chat-composer-drawer-inset)),curve_to_calc(100%-var(--chat-composer-drawer-inset))_calc(100%-var(--chat-composer-context-extension))_with_100%_calc(100%-var(--chat-composer-context-extension)-var(--chat-composer-drawer-inset)*0.4477)/calc(100%-var(--chat-composer-drawer-inset)*0.4477)_calc(100%-var(--chat-composer-context-extension)),line_to_calc(100%-var(--chat-composer-drawer-inset))_calc(100%-16px),curve_to_calc(100%-var(--chat-composer-drawer-inset)-16px)_100%_with_calc(100%-var(--chat-composer-drawer-inset))_calc(100%-7.16px)/calc(100%-var(--chat-composer-drawer-inset)-7.16px)_100%,line_to_calc(var(--chat-composer-drawer-inset)+16px)_100%,curve_to_var(--chat-composer-drawer-inset)_calc(100%-16px)_with_calc(var(--chat-composer-drawer-inset)+7.16px)_100%/var(--chat-composer-drawer-inset)_calc(100%-7.16px),line_to_var(--chat-composer-drawer-inset)_calc(100%-var(--chat-composer-context-extension)),curve_to_0_calc(100%-var(--chat-composer-context-extension)-var(--chat-composer-drawer-inset))_with_calc(var(--chat-composer-drawer-inset)*0.4477)_calc(100%-var(--chat-composer-context-extension))/0_calc(100%-var(--chat-composer-context-extension)-var(--chat-composer-drawer-inset)*0.4477),line_to_0_22px,close)]`,`not-supports-[clip-path:shape(from_0_0,line_to_1px_1px)]:before:bottom-(--chat-composer-context-extension)`],t),...n})}var hY=`after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:border after:border-(--chat-composer-outline) dark:after:inset-shadow-2xs dark:after:inset-shadow-(color:--chat-composer-highlight)`,gY=`group-data-with-context/composer-surface:after:[clip-path:polygon(0_0,100%_0,100%_100%,calc(100%-22px)_100%,calc(100%-22px)_calc(100%-2px),22px_calc(100%-2px),22px_100%,0_100%)]`;function _Y({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`composer-host`,className:Y(`relative z-10 w-full rounded-3xl shadow-composer after:z-1 dark:shadow-none`,hY,gY,`group-has-data-[composer-banner-surface=attached]/composer-surface:shadow-none group-has-data-[composer-banner-surface=attached]/composer-surface:after:hidden`,e),...t})}function vY({className:e,...t}){return(0,U.jsx)(`div`,{"data-chat-composer-main-surface":`true`,className:Y(`group relative z-10 rounded-3xl p-px`,`group-data-model-strip-transition/composer-surface:bg-(--chat-composer-glass-surface)/(--glass-opacity) group-data-model-strip-transition/composer-surface:backdrop-blur-(--glass-blur) group-data-model-strip-transition/composer-surface:backdrop-saturate-(--glass-saturation)`,hY,gY,`after:z-20 after:hidden group-has-data-[composer-banner-surface=attached]/composer-surface:after:block group-data-model-strip-transition/composer-surface:after:block`,`group-has-data-[composer-banner-surface=attached]/composer-surface:bg-(--chat-composer-glass-surface)/(--glass-opacity) group-has-data-[composer-banner-surface=attached]/composer-surface:backdrop-blur-(--glass-blur) group-has-data-[composer-banner-surface=attached]/composer-surface:backdrop-saturate-(--glass-saturation)`,`group-has-data-[composer-banner-surface=attached]/composer-surface:shadow-composer dark:group-has-data-[composer-banner-surface=attached]/composer-surface:shadow-none`,`not-supports-[((backdrop-filter:blur(1px))_or_(-webkit-backdrop-filter:blur(1px)))]:group-has-data-[composer-banner-surface=attached]/composer-surface:bg-(--chat-composer-glass-surface)`,`group-has-data-[composer-banner-surface=attached]/composer-surface:**:data-[chat-composer-mobile-collapsed=true]:min-h-[calc(1rem+1px)]`,e),...t})}function yY({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`composer-context-strip`,className:Y(`group/composer-context relative isolate mx-auto -mt-4 flex w-[calc(100%-2*var(--chat-composer-drawer-inset))] items-center gap-2 overflow-x-clip overflow-y-visible px-2 pt-5 pb-1`,`before:absolute before:inset-0 before:-z-1 before:rounded-b-2xl before:border before:border-(--chat-composer-outline) before:mask-b-from-transparent before:mask-b-from-4 before:mask-b-to-black before:mask-b-to-4 before:shadow-composer`,`dark:before:border-white/7 dark:before:bg-composer-seam-below dark:before:shadow-composer-dark`,`group-has-data-[composer-banner-surface=attached]/composer-surface:before:bg-(--chat-composer-glass-surface)/(--glass-opacity) group-has-data-[composer-banner-surface=attached]/composer-surface:before:backdrop-blur-(--glass-blur) group-has-data-[composer-banner-surface=attached]/composer-surface:before:backdrop-saturate-(--glass-saturation)`,`not-supports-[clip-path:shape(from_0_0,line_to_1px_1px)]:before:bg-(--chat-composer-glass-surface)/(--glass-opacity) not-supports-[clip-path:shape(from_0_0,line_to_1px_1px)]:before:backdrop-blur-(--glass-blur) not-supports-[clip-path:shape(from_0_0,line_to_1px_1px)]:before:backdrop-saturate-(--glass-saturation)`,e),...t})}var bY={Shell:mY,Host:_Y,Main:vY,ContextStrip:yY},xY=e=>e.preventDefault();function SY({onStop:e}){let[t,n]=(0,m.useState)(!1),r=tO(t,eO.confirm),i=()=>{n(!1),e()};return bR(`y`,i,{enabled:t&&r,inDialog:!0}),(0,U.jsxs)(WB,{open:t&&r,onOpenChange:n,children:[(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:`flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-full bg-stop-action text-white shadow-xs shadow-stop-action/24 inset-shadow-control-highlight transition-colors duration-150 outline-none hover:bg-stop-action-hover focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background active:inset-shadow-control-pressed active:shadow-none pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 [&_svg]:pointer-events-none`,onPointerDown:xY,onClick:()=>n(!0),"aria-label":`Stop`,"aria-haspopup":`dialog`,children:(0,U.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,U.jsx)(`rect`,{x:`2`,y:`2`,width:`8`,height:`8`,rx:`1.5`})})})}),(0,U.jsx)(nR,{side:`top`,children:`Interrupt`})]}),(0,U.jsxs)(qB,{children:[(0,U.jsxs)(JB,{children:[(0,U.jsx)(XB,{children:`Stop the oracle?`}),(0,U.jsx)(ZB,{children:`The current response stops. Work already recorded is kept.`})]}),(0,U.jsxs)(YB,{children:[(0,U.jsxs)($B,{children:[`Keep it`,(0,U.jsx)(GD,{chord:`Esc`,className:`kbd-hint ml-1`})]}),(0,U.jsxs)(QB,{variant:`destructive`,onClick:i,children:[`Stop`,(0,U.jsx)(GD,{chord:`Y`,className:`kbd-hint ml-1`})]})]})]})]})}function CY({sending:e,disabled:t,steering:n,onSend:r}){let i=n?`Steer message`:`Send`;return(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsx)(`span`,{className:`inline-flex`,children:(0,U.jsx)(`button`,{type:`button`,className:Y(`relative isolate flex h-9 w-9 items-center justify-center overflow-hidden rounded-full shadow-xs outline-none transition-all duration-150 enabled:cursor-pointer enabled:inset-shadow-control-highlight hover:scale-105 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background active:inset-shadow-control-pressed active:shadow-none disabled:pointer-events-none disabled:opacity-64 disabled:shadow-none disabled:hover:scale-100 motion-reduce:hover:scale-100 sm:h-8 sm:w-8 [&_svg]:pointer-events-none`,`bg-message-action text-message-action-foreground enabled:shadow-message-action/24 hover:bg-message-action-hover`),onPointerDown:xY,onClick:r,disabled:t,"aria-label":`Send`,"aria-keyshortcuts":`Enter`,children:e?(0,U.jsx)(vB,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,U.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":`true`,children:(0,U.jsx)(`path`,{d:`M7 11.5V2.5M7 2.5L3 6.5M7 2.5L11 6.5`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})})})})}),(0,U.jsxs)(nR,{side:`top`,children:[i,` `,(0,U.jsx)(GD,{chord:`Enter`})]})]})}function wY(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 TY(e){return[...zR.map(e=>({name:e.name,description:`${e.hint} · /${e.name} ${e.args}`})),...e].map(e=>({id:`/${e.name}`,insert:`/${e.name}`,label:`/${e.name}`,description:e.description+(`terminal`in e&&e.terminal?` · continue in Pi terminal`:``)}))}function EY(e,t=[]){let n=e.kind===`slash-command`?TY(t):RR.map(e=>({id:`@${e.name}`,insert:`@${e.name}`,label:`@${e.name}`,description:e.hint,agent:e.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 DY(e,t){return`${e}-${encodeURIComponent(t)}`}var OY={"slash-command":`Commands`,mention:`Agents`};function kY({item:e}){if(e.agent)return(0,U.jsx)(pO,{source:LR[e.agent],strokeWidth:2,className:`size-4 shrink-0 text-muted-foreground`});let t=e.id===`/plan`?_g:hh;return(0,U.jsx)(t,{"aria-hidden":`true`,strokeWidth:2,className:`size-4 shrink-0 text-muted-foreground`})}var AY=(0,m.memo)(function(e){let t=(0,m.useRef)(null);return(0,m.useLayoutEffect)(()=>{e.activeItemId&&t.current&&t.current.querySelector(`[data-composer-item-id="${CSS.escape(e.activeItemId)}"]`)?.scrollIntoView({block:`nearest`})},[e.activeItemId]),(0,U.jsx)(`div`,{ref:t,"data-composer-command-drawer":`true`,className:Y(`composer-command-drawer relative isolate flex min-h-0 w-full flex-col overflow-hidden pb-[calc(1rem+1px)]`,`before:pointer-events-none before:absolute before:inset-0 before:-z-1 before:rounded-t-2xl before:border before:border-(--chat-composer-outline)`,`before:bg-(--chat-composer-glass-surface)/(--glass-opacity) before:backdrop-blur-(--glass-blur) before:backdrop-saturate-(--glass-saturation)`,`before:mask-t-from-transparent before:mask-t-from-4 before:mask-t-to-black before:mask-t-to-4 before:shadow-composer dark:before:shadow-none`,`not-supports-[((backdrop-filter:blur(1px))_or_(-webkit-backdrop-filter:blur(1px)))]:before:bg-(--chat-composer-glass-surface)`),children:(0,U.jsx)(`div`,{id:e.listId,role:`listbox`,"aria-label":OY[e.triggerKind],className:`max-h-72 min-h-0 overflow-y-auto p-2`,children:e.items.map(t=>{let n=e.activeItemId===t.id;return(0,U.jsxs)(`div`,{id:DY(e.listId,t.id),role:`option`,"aria-selected":n,"data-composer-item-id":t.id,"data-active":n||void 0,onMouseMove:()=>{n||e.onHighlightedItemChange(t.id)},onMouseDown:e=>e.preventDefault(),onClick:()=>e.onSelect(t),className:Y(`flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 text-sm outline-none select-none`,n&&`bg-accent text-accent-foreground`),children:[(0,U.jsx)(kY,{item:t}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`min-w-0 max-w-[45%] shrink-0 truncate font-sans text-xs font-medium`,children:t.label}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left text-xs text-muted-foreground`,children:t.description})]})]},t.id)})})})}),jY={id:`oracle`,label:`Message the team`,placeholder:`Message the team… @ picks who answers, / for commands and skills`},MY=new Set([`lobby`,`tasks`,`plan`,`knowledge`]);function NY(e){return e.kind===`tab`&&MY.has(e.tab)}function PY(e,t){if(e.kind!==`tab`)return jY;if(e.tab===`knowledge`)return{id:`knowledge`,label:`Ask the oracle about this project`,placeholder:`Ask about this project — the oracle searches the code and learns what is missing…`};if(e.tab===`plan`)return{id:`panel`,label:`Message the panel`,placeholder:`Describe a task, or answer the panel…`};let n=e.tab===`tasks`?RV(e.rest).id??t:void 0;return n?{id:`comment`,label:`Comment on ${n}`,placeholder:`Comment on ${n}'s plan…`,taskId:n}:jY}var FY=0;function IY(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}var LY={duration:.16,ease:`easeOut`};function RY({file:e,onRemove:t}){let n=(0,U.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,U.jsx)(s_,{"aria-hidden":`true`,className:`size-3.5`})});return e.image?(0,U.jsxs)(Xf.li,{layout:!0,initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:LY,title:`${e.name} · ${KJ(e.size)}`,className:`relative size-16 shrink-0 overflow-hidden rounded-lg border border-border/80 bg-background`,children:[(0,U.jsx)(`img`,{src:I(e.image),alt:e.name,className:`size-full object-cover`}),e.state===`uploading`?(0,U.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,U.jsx)(vB,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}),`uploading`]}):null,n]}):(0,U.jsxs)(Xf.li,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:LY,className:`flex min-w-0 basis-full items-center gap-2 text-sm text-foreground`,children:[(0,U.jsx)(Ym,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,U.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-muted-foreground`,children:[e.state===`uploading`?(0,U.jsx)(vB,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}):null,e.state===`uploading`?`uploading…`:KJ(e.size)]}),n]})}function zY(e,t,n){let[r,i]=(0,m.useState)(!1),a=n.kind===`tab`?n.tab:n.kind;return(0,m.useEffect)(()=>i(!1),[a]),(0,m.useEffect)(()=>{if(!t)return;let n=0,r=t=>{e.current?.contains(t.target)||(n=performance.now())},a=t=>{[`PageDown`,`PageUp`,`ArrowDown`,`ArrowUp`,`Home`,`End`,` `].includes(t.key)&&!e.current?.contains(t.target)&&(n=performance.now())},o=t=>{let r=e.current;!r||performance.now()-n>400||r.contains(document.activeElement)||r.contains(t.target)||i(!0)};return document.addEventListener(`wheel`,r,{capture:!0,passive:!0}),document.addEventListener(`touchmove`,r,{capture:!0,passive:!0}),document.addEventListener(`keydown`,a,{capture:!0}),document.addEventListener(`scroll`,o,{capture:!0,passive:!0}),()=>{document.removeEventListener(`wheel`,r,{capture:!0}),document.removeEventListener(`touchmove`,r,{capture:!0}),document.removeEventListener(`keydown`,a,{capture:!0}),document.removeEventListener(`scroll`,o,{capture:!0})}},[t,e]),{shrunk:r,expand:(0,m.useCallback)(()=>i(!1),[])}}function BY({route:e,projects:t}){let[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)([]),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(!1),u=oO(`status`),d=oO(`lobby`),f=rO(),p=(u.data?.busy??!1)||!!d.data?.reply?.trim(),h=NY(e),g=(0,m.useRef)(h);g.current=h;let{taskId:_}=kK(),v=(0,m.useMemo)(()=>PY(e,_),[e,_]),y=(0,m.useRef)(null),{shrunk:b,expand:x}=zY(y,h&&!f,e),S=(0,m.useRef)(null),C=(0,m.useRef)(null),w=(0,m.useRef)(i);w.current=i;let T=(0,m.useRef)(void 0),[E,D]=(0,m.useState)(0),[O,k]=(0,m.useState)(null),[A,ee]=(0,m.useState)(void 0),j=v.id===`oracle`?wY(n,E):void 0,M=(0,m.useMemo)(()=>j?EY(j,u.data?.commands):[],[j?.kind,j?.query,u.data?.commands]),te=!!j&&M.length>0&&A!==n&&h&&!f,N=te?M.find(e=>e.id===O)??M[0]:void 0,P=`composer-suggestions`,ne=(0,m.useCallback)(e=>{let t=n.replace(/^\s*[/@][a-z0-9:_.-]*\s*/i,``),i=`${e.insert} ${t}`,a=e.insert.length+1;T.current={start:a,end:a},D(a),r(i),k(null),S.current?.focus()},[n]);(0,m.useLayoutEffect)(()=>{let e=T.current,t=S.current;e&&t&&(T.current=void 0,t.setSelectionRange(e.start,e.end))},[n]);let re=(0,m.useCallback)(e=>{T.current={start:e.start,end:e.end},D(e.end),r(e.value)},[]);(0,m.useEffect)(()=>{let e=y.current;if(!e)return;let t=document.documentElement,n=()=>{let n=e.getBoundingClientRect();if(t.style.setProperty(`--composer-h`,f||!h?`0px`:`${Math.ceil(n.height)}px`),!h||n.width===0){t.style.removeProperty(`--composer-x`),t.style.removeProperty(`--composer-w`);return}t.style.setProperty(`--composer-x`,`${Math.round(n.left)}px`),t.style.setProperty(`--composer-w`,`${Math.round(n.width)}px`)};n();let r=new ResizeObserver(n);return r.observe(e),window.addEventListener(`resize`,n),()=>{r.disconnect(),window.removeEventListener(`resize`,n),t.style.setProperty(`--composer-h`,`0px`),t.style.removeProperty(`--composer-x`),t.style.removeProperty(`--composer-w`)}},[f,h]);let ie=(0,m.useCallback)(e=>{if(!g.current)return;let t=[...e],n=8-w.current.length;t.length>n&&W.warning(`At most 8 files go with one message.`);for(let e of t.slice(0,Math.max(0,n))){let t=`f${++FY}`,n=e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0;a(r=>[...r,{key:t,name:e.name||(n?`image.png`:`file`),size:e.size,...n?{image:n}:{},state:`uploading`}]),qJ(e).then(e=>a(n=>n.map(n=>n.key===t?{...n,state:`ready`,info:e}:n))).catch(e=>{W.error(e instanceof Error?e.message:`That file did not upload.`),a(e=>e.filter(e=>e.key!==t))})}},[]),ae=(0,m.useCallback)(e=>{a(t=>{let n=t.find(t=>t.key===e);return n?.image&&URL.revokeObjectURL(n.image),t.filter(t=>t.key!==e)})},[]),oe=i.some(e=>e.state===`uploading`),se=i.flatMap(e=>e.info?[e.info.id]:[]),ce=(n.trim().length>0||se.length>0)&&!oe&&!o,le=(0,m.useCallback)(async()=>{if(!ce||!g.current)return;s(!0);let e=se.length>0?se:void 0,t={text:n,...e?{attachments:e}:{}};try{let e=!0;if(v.id===`oracle`){let e=await R(`lobby.send`,t);e.notice&&W(e.notice),e.open===`plan`&&mB(pB(`plan`))}else if(v.id===`knowledge`){e=await mp(`knowledge.ask`,t)!==void 0;let n=fB(window.location.hash);e&&n?.kind===`tab`&&n.tab===`knowledge`&&mB(_B(n.rest,!0))}else e=v.id===`panel`?await mp(`planner.send`,t)!==void 0:await mp(`tasks.comment`,{taskId:v.taskId,...t})!==void 0;if(e){r(``);for(let e of w.current)e.image&&URL.revokeObjectURL(e.image);a([])}}catch(e){W.error(e instanceof Error?e.message:`Could not send`)}finally{s(!1)}},[ce,se,v,n,e]),F=(0,m.useCallback)(async()=>{try{await R(`lobby.abort`,{})}catch(e){W.error(e instanceof Error?e.message:`Could not stop`)}},[]),ue=e=>{if(te&&N&&!e.nativeEvent.isComposing){let t=M.indexOf(N);if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=(t+(e.key===`ArrowDown`?1:-1)+M.length)%M.length;k(M[n].id);return}if(e.key===`Enter`&&!e.shiftKey||e.key===`Tab`){e.preventDefault(),ne(N);return}if(e.key===`Escape`){e.preventDefault(),ee(n);return}}if(e.key===`Escape`&&!e.nativeEvent.isComposing){e.preventDefault(),mR();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;re(r===`k`?YJ(a,n,i):JJ(a,n,i,r===`b`?`**`:r===`i`?`_`:"`"));return}if(e.key===`Enter`&&e.shiftKey&&!e.nativeEvent.isComposing&&t.selectionStart===t.selectionEnd){let n=ZJ(t.value,t.selectionStart);n&&(e.preventDefault(),re(n));return}if(e.key===`Backspace`&&t.value===``&&w.current.length>0){e.preventDefault(),ae(w.current.at(-1).key);return}(IY(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey))&&(e.preventDefault(),le())},de=e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),ie(t))},fe=e=>{e.preventDefault(),l(!1),e.dataTransfer.files.length>0&&ie(e.dataTransfer.files)},I=e.kind===`tab`&&e.tab===`knowledge`,L=u.data?.workspace.name??`bot-lobby`,pe=u.data?.branch??u.data?.workspace.branch,me=(0,U.jsx)(`div`,{className:`min-h-0`,children:(0,U.jsx)(`div`,{className:`relative z-0`,children:(0,U.jsxs)(bY.ContextStrip,{role:`group`,"aria-label":`Message context`,className:`composer-strip gap-1 text-xs font-normal text-muted-foreground/70`,children:[(0,U.jsx)(pY,{projects:t,tab:e.kind===`tab`?e.tab:e.kind,name:L,branch:pe}),(0,U.jsx)(`div`,{className:`@container ml-auto flex min-w-0 flex-1 items-center justify-end gap-3 overflow-hidden pe-1`,children:(0,U.jsx)(KD,{chord:`Shift+Enter`,className:`hidden @[14rem]:inline-flex`,children:`new line`})})]})})});return(0,U.jsx)(`div`,{id:`app-dock`,ref:y,"data-shrunk":b||void 0,onFocus:x,className:Y(`dock pointer-events-none absolute inset-x-0 bottom-0 z-30 px-6 pb-[max(1rem,env(safe-area-inset-bottom))] transition-opacity duration-200 ease-snap`,f&&`opacity-0`),hidden:!h,"aria-hidden":!h||void 0,inert:f||!h,children:(0,U.jsxs)(bY.Shell,{contextStrip:!0,className:`composer-shell pointer-events-auto`,children:[(0,U.jsx)(ju,{initial:!1,children:te&&j&&N?(0,U.jsx)(Xf.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:LY,"data-composer-drawer-layer":`true`,className:`absolute inset-x-(--chat-composer-drawer-inset) bottom-full z-0 -mb-[calc(1rem+1px)] flex flex-col`,children:(0,U.jsx)(AY,{listId:P,items:M,triggerKind:j.kind,activeItemId:N.id,onHighlightedItemChange:k,onSelect:ne})},`commands`):null}),(0,U.jsx)(bY.Host,{onPointerDown:x,children:(0,U.jsx)(`div`,{className:`relative z-10`,children:(0,U.jsxs)(bY.Main,{className:`group/composer composer-box`,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),l(!0))},onDragLeave:()=>l(!1),onDrop:fe,children:[(0,U.jsxs)(`div`,{"data-chat-composer-surface":`true`,className:Y(`rounded-3xl transition-[background-color] duration-200`,c&&`bg-accent/45 ring-1 ring-inset ring-primary/70`),children:[(0,U.jsxs)(`div`,{"data-chat-composer-body":`true`,className:Y(`composer-text relative px-3 pb-2 sm:px-4`,`pt-3.5 sm:pt-4`),children:[(0,U.jsx)(ju,{initial:!1,children:i.length>0?(0,U.jsx)(Xf.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 mb-3 flex max-w-full flex-wrap gap-2 overflow-hidden`,children:i.map(e=>(0,U.jsx)(RY,{file:e,onRemove:()=>ae(e.key)},e.key))},`files`):null}),(0,U.jsx)(`div`,{className:`relative flow-root font-sans text-sm max-sm:pointer-coarse:text-base`,children:(0,U.jsx)(`textarea`,{ref:S,id:`composer-text`,"aria-label":v.label,...v.id===`oracle`?{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":te,"aria-controls":te?P:void 0}:{},...N?{"aria-activedescendant":DY(P,N.id)}:{},value:n,onChange:e=>{r(e.target.value),D(e.target.selectionStart)},onSelect:e=>D(e.currentTarget.selectionStart),onKeyDown:ue,onPaste:de,placeholder:p&&v.id===`oracle`?`The oracle is working. Enter steers it…`:v.placeholder,rows:1,className:Y(`-m-1 block field-sizing-content max-h-52 min-h-19.5 w-[calc(100%+0.5rem)] resize-none overflow-y-auto bg-transparent p-1 leading-relaxed whitespace-pre-wrap text-foreground caret-primary outline-none placeholder:text-placeholder/75`)})})]}),(0,U.jsxs)(`div`,{"data-chat-composer-footer":`true`,className:Y(`composer-tools flex min-w-0 flex-nowrap items-center justify-between gap-2 overflow-visible px-3 pb-3 sm:gap-0 sm:px-4 sm:pb-4`),children:[(0,U.jsx)(`div`,{"data-chat-composer-controls":`left`,className:`composer-controls relative -m-1 -ms-3.5 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto p-1 ps-3.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:I?(0,U.jsx)(QJ,{rest:e.kind===`tab`?e.rest:[]}):null}),(0,U.jsxs)(`div`,{"data-chat-composer-actions":`right`,className:`flex shrink-0 flex-nowrap items-center justify-end gap-2`,children:[(0,U.jsx)(`input`,{ref:C,type:`file`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach files`,onChange:e=>{ie(e.target.files??[]),e.target.value=``}}),(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Attach images, PDFs or files`,"data-compact":!0,onPointerDown:e=>e.preventDefault(),onClick:()=>C.current?.click(),className:`pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11`,children:(0,U.jsx)(Yh,{"aria-hidden":`true`})})}),(0,U.jsx)(nR,{side:`top`,children:`Attach files`})]}),p&&v.id===`oracle`?(0,U.jsx)(SY,{onStop:()=>void F()}):null,(0,U.jsx)(CY,{sending:o,disabled:!ce,steering:p&&v.id===`oracle`,onSend:()=>void le()})]})]})]}),c?(0,U.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-primary`,children:`Drop to attach`}):null]})})}),me]})})}function VY({state:e}){return e===`live`?null:e===`connecting`?(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 rounded-full bg-warning motion-safe:animate-status-pulse`}),`reconnecting…`]}):(0,U.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:`Connection lost`})}function HY(e){if(!e)return 0;let t=[...e.children].filter(e=>e instanceof HTMLElement&&e.offsetParent!==null&&getComputedStyle(e).position!==`absolute`);if(!t.length)return 0;let n=Math.min(...t.map(e=>e.getBoundingClientRect().left)),r=Math.max(...t.map(e=>e.getBoundingClientRect().right)),i=0;for(let t of e.querySelectorAll(`*`))t.clientWidth<=1||t.offsetParent===null||t.scrollWidth<=t.clientWidth+1||getComputedStyle(t).textOverflow===`ellipsis`&&(i+=t.scrollWidth-t.clientWidth);return r-n+i}var UY=24;function WY(){let e=(0,m.useRef)(null),[t,n]=(0,m.useState)(!1),r=(0,m.useRef)(()=>{});return r.current=()=>{let t=e.current;if(!t)return;let r=t.querySelector(`[role="tablist"]`),i=getComputedStyle(t),a=parseFloat(i.columnGap)||0,o=t.clientWidth-(parseFloat(i.paddingLeft)||0)-(parseFloat(i.paddingRight)||0),s=HY(t.querySelector(`.where`))+(r?.offsetWidth??0)+HY(t.querySelector(`.tools`))+a*2;n(s+UY<=o)},(0,m.useLayoutEffect)(()=>r.current()),(0,m.useLayoutEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>r.current());n.observe(t);for(let e of t.querySelectorAll(`[role="tablist"], .where, .tools`))n.observe(e);return()=>n.disconnect()},[]),{header:e,one:t}}function GY({connection:e,projects:t,lead:n,tabs:r,extra:i,tools:a}){let{header:o,one:s}=WY();return(0,U.jsxs)(`header`,{ref:o,className:`app-header shrink-0`,"data-one-row":s||void 0,children:[(0,U.jsx)(`div`,{className:`where flex min-w-0 items-center gap-2`,children:n}),(0,U.jsx)(`div`,{className:`tabs min-w-0`,children:r}),(0,U.jsxs)(`div`,{className:`tools flex min-w-0 items-center justify-end gap-2`,children:[i,(0,U.jsx)(VY,{state:e}),a,(0,U.jsx)(`span`,{id:`focused-action-help`,className:`sr-only`,children:`Focused buttons: Enter or Space. Links: Enter. Checkboxes: Space.`})]}),(0,U.jsx)(uY,{projects:t})]})}function KY({open:e,onOpenChange:t}){let n=tO(e,eO.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{W((await R(`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,U.jsx)(qD,{open:n,label:`New session`,description:`Starts a task in a session of its own, in the background.`,onOpenChange:e=>{e||u()},dismissOnBackdrop:!a,children:(0,U.jsxs)(`div`,{className:`flex w-[min(32rem,calc(100vw-2rem))] flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border px-4 py-3`,children:[(0,U.jsx)(`h2`,{className:`text-[0.9375rem] font-semibold`,children:`New session`}),(0,U.jsx)(`p`,{className:`text-xs 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,U.jsxs)(`div`,{className:`flex flex-col gap-1.5 p-4`,children:[(0,U.jsx)(`label`,{htmlFor:l,className:`text-sm font-medium`,children:`What should it do?`}),(0,U.jsx)(tV,{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:`max-h-60 min-h-24`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d())}}),s?(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:s}):null]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 border-t border-border bg-muted/30 px-4 py-3`,children:[(0,U.jsx)(X,{variant:`outline`,onClick:u,disabled:a,children:`Cancel`}),(0,U.jsx)(X,{onClick:()=>void d(),disabled:!r.trim()||a,"aria-busy":a,children:a?`Starting…`:`Start session`})]})]})})}function qY(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 JY(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:qY(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 YY=`app.sidebar`,XY={start:16,min:13,max:24},ZY=`bot-lobby.sidebar.width`,QY=`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-[var(--sidebar-icon)] outline-none transition-[background-color,color,scale] duration-150 hover:bg-sidebar-accent hover:text-sidebar-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:scale-[0.96] aria-pressed:text-sidebar-foreground aria-[current=page]:bg-[var(--sidebar-selected)] aria-[current=page]:text-sidebar-foreground motion-reduce:active:scale-100`,$Y=`session-row flex h-8 w-full min-w-0 items-center gap-2 rounded-lg px-2.5 text-left text-sm outline-none transition-colors duration-150 hover:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-[var(--sidebar-selected)]`;function eX({label:e,hint:t,side:n=`bottom`,children:r}){return(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:r}),(0,U.jsxs)(nR,{side:n,children:[e,` `,t?(0,U.jsx)(GD,{chord:t}):null]})]})}function tX(){let e=oO(`status`).data;return{entries:JY(e,EB(`sessions.list`,{},[`sessions`]).data),branch:e?.branch??e?.workspace.branch}}function nX(){return(0,m.useCallback)(async e=>{if(e.where===`here`)return mB(`#/lobby`);if(e.where===`elsewhere`)return void W.info(`${e.name} runs in another terminal. Switch to that terminal to work in it.`);await mp(`sessions.switch`,e.key?{key:e.key}:{sessionId:e.sessionId})&&mB(`#/lobby`)},[])}function rX({entry:e}){return e.where!==`elsewhere`&&e.state===`asking`?(0,U.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-warning tabular-nums`,children:[(0,U.jsx)(Dh,{"aria-hidden":`true`,className:`size-3.5`}),e.waiting,(0,U.jsxs)(`span`,{className:`sr-only`,children:[e.waiting===1?` question`:` questions`,`, Waiting`]})]}):e.where!==`elsewhere`&&(e.state===`working`||e.state===`starting`)?(0,U.jsxs)(`span`,{className:Y(`inline-flex shrink-0`,e.state===`working`?`text-primary`:`text-muted-foreground`),children:[(0,U.jsx)(pm,{"aria-hidden":`true`,className:`session-spin size-3.5`}),(0,U.jsx)(`span`,{className:`sr-only`,children:e.state===`working`?`Working`:`Starting`})]}):(0,U.jsx)(`span`,{className:`sr-only`,children:e.where===`elsewhere`?`Other terminal`:e.state===`exited`?`Ended`:`Idle`})}var iX={here:`This window`,background:`Background`,elsewhere:`Other terminal`};function aX(e){let t=e.key;return mp(`sessions.archive`,{key:t},{undo:()=>void mp(`sessions.archive`,{key:t,archived:!1})})}function oX({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 mp(`sessions.rename`,{...e.where===`here`?{}:{key:e.key},name:r}),t()};return(0,U.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:`-mx-1 h-6 w-[calc(100%+0.5rem)] min-w-0 rounded-sm bg-background px-1 text-sm leading-5 text-sidebar-foreground outline-none ring-2 ring-ring`})}var sX=`inline-flex size-[1.625rem] items-center justify-center rounded-md text-muted-foreground outline-none transition-[background-color,color] duration-150 hover:bg-[var(--sidebar-selected)] hover:text-sidebar-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`;function cX({entry:e}){let t=nX(),[n,r]=(0,m.useState)(!1),i=e.state===`exited`||e.where===`elsewhere`,a=Y(`min-w-0 flex-1 truncate`,e.where===`here`?`font-medium text-sidebar-foreground`:i?`text-muted-foreground`:`text-sidebar-foreground`),o=e.where!==`elsewhere`,s=e.where===`background`&&e.state===`exited`&&!!e.key,c=o||s;return(0,U.jsxs)(`li`,{className:`session-enter session-item relative`,children:[n?(0,U.jsx)(`div`,{"aria-current":e.where===`here`?`true`:void 0,className:Y($Y,`hover:bg-transparent`),children:(0,U.jsx)(oX,{entry:e,onDone:()=>r(!1)})}):(0,U.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,onClick:()=>void t(e),onDoubleClick:e=>{o&&(e.preventDefault(),r(!0))},className:$Y,children:[(0,U.jsx)(`span`,{className:a,children:e.name}),(0,U.jsx)(`span`,{className:Y(`flex shrink-0 items-center`,c&&`session-state`),children:(0,U.jsx)(rX,{entry:e})})]}),!n&&c?(0,U.jsxs)(`span`,{className:`session-actions absolute top-1/2 right-1 flex -translate-y-1/2 items-center gap-0.5`,children:[o?(0,U.jsx)(eX,{label:`Rename`,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Rename ${e.name}`,onClick:()=>r(!0),className:sX,children:(0,U.jsx)(tg,{"aria-hidden":`true`,className:`size-3.5`})})}):null,s?(0,U.jsx)(eX,{label:`Archive`,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Archive ${e.name}`,onClick:()=>void aX(e),className:sX,children:(0,U.jsx)(jp,{"aria-hidden":`true`,className:`size-3.5`})})}):null]}):null]})}var lX=`flex h-7 items-center px-2.5 pt-2 text-xs font-medium text-muted-foreground`;function uX({id:e,label:t,entries:n,archivable:r=!1}){let[i,a]=Hz(`app.sidebar.${e}`),o=(0,m.useId)();return n.length===0?null:(0,U.jsxs)(`section`,{"aria-label":t,className:`group/shelf flex flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1 pt-2`,children:[(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":!i,"aria-controls":o,onClick:a,className:`flex h-7 min-w-0 flex-1 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium text-muted-foreground outline-none transition-colors duration-150 hover:text-sidebar-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[(0,U.jsx)(`span`,{children:t}),i?(0,U.jsx)(`span`,{className:`tabular-nums`,children:n.length}):null,(0,U.jsx)(tm,{"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 motion-reduce:transition-none`,i&&`-rotate-90 opacity-100`)})]}),r?(0,U.jsx)(`button`,{type:`button`,onClick:()=>void(async()=>{for(let e of n)e.key&&await mp(`sessions.archive`,{key:e.key})})(),className:`h-[1.625rem] shrink-0 rounded-md px-1.5 text-xs text-muted-foreground outline-none transition-colors duration-150 hover:bg-sidebar-accent hover:text-sidebar-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:`Archive all`}):null]}),i?null:(0,U.jsx)(`ul`,{id:o,className:`flex flex-col gap-px`,children:n.map(e=>(0,U.jsx)(cX,{entry:e},e.id))})]})}function dX(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean),r=`${e.name} ${iX[e.where]}`.toLowerCase();return n.every(e=>r.includes(e))}function fX({query:e,onQuery:t,onNew:n}){return(0,U.jsxs)(`div`,{className:`flex items-center gap-1 px-1 pb-2`,children:[(0,U.jsxs)(`label`,{className:`flex h-8 min-w-0 flex-1 items-center gap-2 rounded-md px-2 text-sm text-muted-foreground transition-colors duration-150 hover:bg-sidebar-accent focus-within:bg-sidebar-accent focus-within:ring-2 focus-within:ring-inset focus-within:ring-ring`,children:[(0,U.jsx)(Cg,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,U.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(``))},className:`min-w-0 flex-1 bg-transparent text-sidebar-foreground outline-none placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden`})]}),(0,U.jsx)(eX,{label:`New session`,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`New session`,"aria-haspopup":`dialog`,onClick:n,className:QY,children:(0,U.jsx)(Ng,{"aria-hidden":`true`,className:`size-4`})})})]})}function pX({query:e}){let{entries:t}=tX(),n=t.filter(t=>dX(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=(0,m.useRef)(null);return(0,U.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,U.jsxs)(`nav`,{ref:s,"aria-label":`Sessions list`,className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-1 pb-2`,children:[n.length===0?(0,U.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,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:lX,children:`This window`}),(0,U.jsx)(`ul`,{className:`flex flex-col gap-px`,children:r.map(e=>(0,U.jsx)(cX,{entry:e},e.id))})]}):null,i.length>0?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:Y(lX,`mt-2`),children:`Background`}),(0,U.jsx)(`ul`,{className:`flex flex-col gap-px`,children:i.map(e=>(0,U.jsx)(cX,{entry:e},e.id))})]}):!e.trim()&&t.length===1?(0,U.jsx)(`p`,{className:`px-2.5 pt-2 text-xs text-muted-foreground`,children:`No other sessions are running.`}):null,(0,U.jsxs)(`div`,{className:`mt-auto flex flex-col pt-2`,children:[(0,U.jsx)(uX,{id:`elsewhere`,label:`Other terminals`,entries:a}),(0,U.jsx)(uX,{id:`ended`,label:`Ended`,entries:o,archivable:!0})]})]}),(0,U.jsx)(Bv,{target:s})]})}function mX(){let e=oO(`status`).data?.workspace.name;return(0,U.jsx)(`span`,{"data-slot":`sidebar-title`,title:e,className:`min-w-0 flex-1 truncate text-sm font-semibold tracking-tight text-sidebar-foreground`,children:e??`Bot Lobby`})}function hX({route:e,keys:t,onHelp:n}){let r=t.settings??`Alt+S`;return(0,U.jsxs)(`div`,{className:`sidebar-foot flex flex-col gap-1 border-t border-[var(--sidebar-border)] px-1 py-2`,children:[(0,U.jsxs)(`a`,{href:`#/settings`,"aria-label":`Settings`,"aria-current":e.kind===`settings`?`page`:void 0,"aria-keyshortcuts":r,className:`flex h-8 items-center gap-2 rounded-md px-2 text-sm text-sidebar-foreground outline-none transition-colors duration-150 hover:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=page]:bg-[var(--sidebar-selected)] aria-[current=page]:font-medium [&>svg]:text-[var(--sidebar-icon)]`,children:[(0,U.jsx)(Tg,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,U.jsx)(`span`,{className:`flex-1`,children:`Settings`}),(0,U.jsx)(GD,{chord:r})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(zJ,{hint:t.help??`Alt+H`,onHelp:n,className:QY}),(0,U.jsx)(BJ,{className:QY}),(0,U.jsx)(UJ,{className:QY}),(0,U.jsx)(WJ,{className:QY}),(0,U.jsx)(GJ,{className:QY})]})]})}function gX(){try{let e=Number(localStorage.getItem(ZY));if(e>=XY.min&&e<=XY.max)return e}catch{}return XY.start}function _X(e){try{e===XY.start?localStorage.removeItem(ZY):localStorage.setItem(ZY,String(e))}catch{}}var vX=e=>Math.min(XY.max,Math.max(XY.min,Math.round(e*4)/4));function yX({width:e,onWidth:t,onResizing:n,onFold:r}){let i=(0,m.useRef)(null),a=(0,m.useRef)(!1),o=(0,m.useRef)(void 0);(0,m.useEffect)(()=>()=>window.clearTimeout(o.current),[]);let s=()=>parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return(0,U.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-label":`Resize sidebar`,"aria-orientation":`vertical`,"aria-controls":`app-sidebar`,"aria-valuemin":XY.min,"aria-valuemax":XY.max,"aria-valuenow":e,title:`Drag to resize, click to fold, double-click to reset`,className:`sidebar-edge`,onPointerDown:t=>{t.button===0&&(t.currentTarget.setPointerCapture?.(t.pointerId),i.current={x:t.clientX,width:e,moved:!1})},onPointerMove:e=>{let r=i.current;if(!r)return;let a=e.clientX-r.x;!r.moved&&Math.abs(a)<3||(r.moved||n(!0),r.moved=!0,t(vX(r.width+a/s())))},onPointerUp:()=>{let e=i.current;i.current=null,e&&(a.current=e.moved,n(!1))},onClick:e=>{a.current||e.detail!==1||(o.current=window.setTimeout(r,240))},onPointerCancel:()=>{i.current=null,n(!1)},onDoubleClick:()=>{window.clearTimeout(o.current),t(XY.start)},onKeyDown:n=>{n.key===`ArrowLeft`||n.key===`ArrowRight`?(n.preventDefault(),t(vX(e+(n.key===`ArrowRight`?1:-1)))):n.key===`Home`||n.key===`End`?(n.preventDefault(),t(n.key===`Home`?XY.min:XY.max)):n.key===`Enter`&&(n.preventDefault(),r())}})}function bX(e){sO(Nz);let[t,n]=Hz(YY),[r,i]=(0,m.useState)(gX),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(``),[l,u]=(0,m.useState)(!1),d=(0,m.useCallback)(e=>{i(e),_X(e)},[]);return(0,U.jsxs)(`aside`,{id:`app-sidebar`,"aria-label":`Sidebar`,"data-folded":t?``:void 0,"data-resizing":a?``:void 0,inert:t,style:{width:t?0:`${r}rem`},className:`app-sidebar`,children:[(0,U.jsxs)(`div`,{className:`sidebar-panel flex min-h-0 flex-1 flex-col`,style:{width:`${r}rem`},children:[(0,U.jsxs)(`div`,{className:`flex min-h-12 items-center gap-2 pr-1 pl-3`,children:[(0,U.jsx)(mX,{}),(0,U.jsx)(eX,{label:`Collapse sidebar`,hint:e.keys.sidebar,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Collapse sidebar`,"aria-expanded":!0,"aria-controls":`app-sidebar`,"aria-keyshortcuts":e.keys.sidebar,onClick:n,className:QY,children:(0,U.jsx)(Uh,{"aria-hidden":`true`,className:`size-4`})})})]}),(0,U.jsx)(fX,{query:s,onQuery:c,onNew:()=>u(!0)}),(0,U.jsx)(pX,{query:s}),(0,U.jsx)(hX,{...e})]}),(0,U.jsx)(yX,{width:r,onWidth:d,onResizing:o,onFold:n}),(0,U.jsx)(KY,{open:l,onOpenChange:u})]})}function xX({hint:e}){sO(Nz);let[t,n]=Hz(YY);return t?(0,U.jsx)(eX,{label:`Expand sidebar`,hint:e,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Expand sidebar`,"aria-expanded":!1,"aria-controls":`app-sidebar`,"aria-keyshortcuts":e,onClick:n,className:Y(QY,`sidebar-open size-8 text-foreground`),children:(0,U.jsx)(Gh,{"aria-hidden":`true`,className:`size-4`})})}):null}var SX=`bot-lobby.terminal.open`,CX=`bot-lobby.terminal.height`,wX=`bot-lobby.terminal.popup`,TX={start:280,min:140},EX=new Set,DX,OX,kX;function AX(e){try{return localStorage.getItem(e)}catch{return null}}function jX(e,t){try{localStorage.setItem(e,t)}catch{}}function MX(){for(let e of[...EX])e()}function NX(e){return EX.add(e),()=>{EX.delete(e)}}function PX(){return DX??=AX(SX)===`1`,DX}function FX(){if(OX===void 0){let e=Number(AX(CX));OX=e>=TX.min?e:TX.start}return OX}function IX(e){DX=e,jX(SX,e?`1`:`0`),MX()}function LX(){IX(!PX())}function RX(e){OX=Math.max(TX.min,Math.round(e)),jX(CX,String(OX)),MX()}function zX(){return(0,m.useSyncExternalStore)(NX,PX,()=>!1)}function BX(){return(0,m.useSyncExternalStore)(NX,FX,()=>TX.start)}function VX(){return kX??=AX(wX)===`1`,kX}function HX(e){kX=e,jX(wX,e?`1`:`0`),MX()}function UX(){return(0,m.useSyncExternalStore)(NX,VX,()=>!1)}var WX=`modulepreload`,GX=function(e){return`/`+e},KX={},qX=function(e){return e.pathname.endsWith(`.css`)},JX=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=GX(t,n);let r=s(t);if(r.href in KX)return;KX[r.href]=!0;let i=qX(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`:WX,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)})},YX=(0,m.lazy)(()=>JX(()=>import(`./TerminalView-D2nbR2J1.js`),__vite__mapDeps([0,1,2,3]))),XX=`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 ZX({label:e,hint:t,children:n}){return(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:n}),(0,U.jsxs)(nR,{side:`top`,children:[e,` `,t?(0,U.jsx)(GD,{chord:t}):null]})]})}function QX({hint:e,className:t}){let n=zX();return(0,U.jsx)(ZX,{label:n?`Hide terminal`:`Terminal`,hint:e,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Terminal`,"aria-pressed":n,"aria-controls":n?`terminal-drawer`:void 0,"aria-keyshortcuts":e,onClick:LX,className:t,children:(0,U.jsx)(Fg,{"aria-hidden":`true`,className:`size-4`})})})}function $X(e){let[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(``),a=(0,m.useCallback)(async()=>{try{n(await R(`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 eZ({height:e,max:t}){let n=(0,m.useRef)(null);return(0,U.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-label":`Resize terminal`,"aria-orientation":`horizontal`,"aria-valuenow":e,"aria-valuemin":TX.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&&RX(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:()=>RX(TX.start),onKeyDown:n=>{(n.key===`ArrowUp`||n.key===`ArrowDown`)&&(n.preventDefault(),RX(Math.min(t,e+(n.key===`ArrowUp`?24:-24))))}})}function tZ({toggleKey:e}){let t=zX(),n=UX(),r=BX(),i=tO(t&&n,eO.sheet),{list:a,error:o,reload:s}=$X(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 R(`terminal.open`,{cols:100,rows:24});l(e.id),await s()}catch(e){W.error(e instanceof Error?e.message:`The terminal did not start.`)}finally{d(!1)}},[s]),v=(0,m.useCallback)(async e=>{try{await R(`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,U.jsx)(nZ,{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,U.jsx)(qD,{open:i,onOpenChange:e=>{e||IX(!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,U.jsx)(`div`,{id:`terminal-drawer`,className:`flex min-h-0 flex-1`,children:x})}):(0,U.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,U.jsx)(eZ,{height:Math.min(r,f),max:f}),x]})}function nZ({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,U.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,U.jsx)(ZX,{label:`New terminal`,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`New terminal`,disabled:i||e?.available===!1,onClick:c,className:XX,children:(0,U.jsx)(sg,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,U.jsx)(ZX,{label:`End this terminal`,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`End this terminal`,disabled:!r,onClick:()=>r&&l(r.id),className:XX,children:(0,U.jsx)(Gg,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,U.jsx)(ZX,{label:a?`Back to the drawer`:`Open in a pop-up`,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Pop out terminal`,"aria-pressed":a,onClick:()=>HX(!a),className:XX,children:(0,U.jsx)(rg,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,U.jsx)(ZX,{label:`Hide terminal`,hint:o,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Hide terminal`,onClick:()=>IX(!1),className:XX,children:a?(0,U.jsx)(s_,{"aria-hidden":`true`,className:`size-3.5`}):(0,U.jsx)(tm,{"aria-hidden":`true`,className:`size-3.5`})})})]}),f=(0,U.jsx)(U.Fragment,{children:e&&!e.available?(0,U.jsx)(`p`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:e.reason}):t?(0,U.jsx)(`p`,{role:`alert`,className:`flex h-full items-center justify-center px-6 text-center text-sm text-destructive`,children:t}):(0,U.jsxs)(m.Suspense,{fallback:(0,U.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`Loading the terminal…`}),children:[e&&n.length===0&&!i?(0,U.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,U.jsx)(YX,{id:e.id,active:e.id===r?.id,toggleKey:o,onExit:u},e.id))]})}),p=n.length>1?(0,U.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,U.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,U.jsx)(Fg,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate`,children:e.title}),e.alive?null:(0,U.jsx)(`span`,{className:`sr-only`,children:`, ended`})]},e.id))}):null;return a?(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border/70 pr-2 pl-4`,children:[(0,U.jsx)(Fg,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`flex-1 text-sm font-medium`,children:`Terminal`}),d]}),(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`min-w-0 flex-1 py-2 pl-2`,children:(0,U.jsx)(`div`,{className:`relative h-full`,children:f})}),p]})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[f,(0,U.jsx)(`div`,{className:`pointer-events-none absolute top-2 right-2 z-20`,children:d})]}),p]})}var rZ=(0,m.lazy)(()=>JX(()=>import(`./CodeSurface-CdyiJTYa.js`),__vite__mapDeps([4,1,2]))),iZ=`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 aZ({label:e,hint:t,children:n}){return(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:n}),(0,U.jsxs)(nR,{side:`bottom`,children:[e,` `,t?(0,U.jsx)(GD,{chord:t}):null]})]})}function oZ({hint:e,className:t}){let{open:n}=cz();return(0,U.jsx)(aZ,{label:`Code and changes`,hint:e,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Code`,"aria-pressed":n,"aria-keyshortcuts":e,onClick:()=>n?oz():az(),className:t,children:(0,U.jsx)(Vm,{"aria-hidden":`true`,className:`size-4`})})})}var sZ={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 cZ(e){let t=e.lastIndexOf(`/`);return t<0?{dir:``,name:e}:{dir:e.slice(0,t),name:e.slice(t+1)}}function lZ({change:e,className:t}){return e.additions===void 0&&e.deletions===void 0?null:(0,U.jsxs)(`span`,{className:Y(`shrink-0 font-mono text-[0.6875rem] tabular-nums`,t),children:[(0,U.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions??0]}),` `,(0,U.jsxs)(`span`,{className:`text-destructive`,children:[`−`,e.deletions??0]})]})}function uZ(){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 dZ({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,U.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,U.jsx)(`form`,{onSubmit:u,className:`border-b border-border p-2`,children:(0,U.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,U.jsx)(Cg,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,U.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,U.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 px-3 text-xs`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:`Changes`}),(0,U.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[c.length,e?.truncated?`+`:``]}),(0,U.jsx)(lZ,{change:l,className:`ml-auto`}),(0,U.jsx)(aZ,{label:`Read the changes again`,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Refresh changes`,onClick:a,disabled:t,className:Y(iZ,`-mr-1.5 size-6`,c.length?``:`ml-auto`),children:(0,U.jsx)(lg,{"aria-hidden":`true`,className:Y(`size-3.5`,t&&`animate-spin motion-reduce:animate-none`)})})})]}),(0,U.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}=cZ(e.path),a=sZ[e.status];return(0,U.jsx)(`li`,{children:(0,U.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,U.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,U.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,U.jsx)(`span`,{className:`ml-1.5 text-xs text-muted-foreground`,children:t}):null]}),(0,U.jsx)(lZ,{change:e})]})},e.path)}),e&&!e.git?(0,U.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,U.jsx)(`li`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:`No changes since the last commit.`}):null,n?(0,U.jsx)(`li`,{role:`alert`,className:`px-2 py-3 text-xs text-destructive`,children:n}):null]})]})}function fZ(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 R(`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 pZ({requested:e,requestedMode:t,request:n,codeKey:r,onClose:i,onDirtyChange:a,closeAsked:o}){let s=EB(`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:_}=fZ(c),[v,y]=(0,m.useState)(),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(),E=hz(),D=gz(),O=uZ(),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 R(`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 be&&e.code===`conflict`?C(!0):W.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&&yJ(e.nativeEvent,r)&&(e.preventDefault(),j({kind:`close`}))}let N=k?.change,P=!!N||k?.original!==void 0,ne=P?u:`code`,{dir:re,name:ie}=cZ(k?.path??c??``),ae=!!(k?.exists&&k.contents!==void 0),oe=N?sZ[N.status]:void 0;return(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1`,onKeyDown:te,children:[(0,U.jsx)(dZ,{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,U.jsxs)(`section`,{"aria-label":`File`,className:`flex min-w-0 flex-1 flex-col`,children:[(0,U.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border pr-2 pl-3`,children:[c?(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[oe?(0,U.jsx)(`span`,{title:oe.word,className:Y(`font-mono text-xs font-semibold`,oe.tone),children:oe.letter}):(0,U.jsx)(Vm,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,U.jsxs)(`h2`,{className:`min-w-0 truncate text-[0.8125rem]`,title:k?.path??c,children:[re?(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[re,`/`]}):null,(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:ie}),A?(0,U.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]}),N?(0,U.jsx)(lZ,{change:N}):null]}):(0,U.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-muted-foreground`,children:`Code`}),P?(0,U.jsx)(KH,{label:`View`,value:ne,onChange:d,items:[{id:`code`,label:`Code`},{id:`diff`,label:`Diff`}]}):null,ne===`diff`?(0,U.jsx)(aZ,{label:D===`split`?`Unified diff`:`Side by side`,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Side by side`,"aria-pressed":D===`split`,onClick:()=>mz(D===`split`?`unified`:`split`),className:iZ,children:D===`split`?(0,U.jsx)(yg,{"aria-hidden":`true`,className:`size-4`}):(0,U.jsx)(km,{"aria-hidden":`true`,className:`size-4`})})}):null,(0,U.jsx)(aZ,{label:E?`Do not wrap lines`:`Wrap long lines`,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Wrap lines`,"aria-pressed":E,onClick:()=>pz(!E),className:iZ,children:(0,U.jsx)(Ug,{"aria-hidden":`true`,className:`size-4`})})}),(0,U.jsx)(aZ,{label:`Save`,hint:`Ctrl+S`,children:(0,U.jsxs)(X,{size:`sm`,variant:A?`default`:`outline`,disabled:!A||b,onClick:()=>void M(),"aria-keyshortcuts":`Control+S Meta+S`,children:[(0,U.jsx)(xg,{"aria-hidden":`true`}),b?`Saving…`:`Save`]})}),(0,U.jsx)(aZ,{label:`Close`,hint:r,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Close code viewer`,onClick:()=>j({kind:`close`}),className:iZ,children:(0,U.jsx)(s_,{"aria-hidden":`true`,className:`size-4`})})})]}),w?(0,U.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,U.jsx)(Zh,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[ie,` has unsaved edits.`]}),(0,U.jsx)(X,{size:`xs`,variant:`ghost`,onClick:()=>T(void 0),children:`Keep editing`}),(0,U.jsx)(X,{size:`xs`,variant:`outline`,onClick:()=>ee(w),children:`Discard`}),(0,U.jsx)(X,{size:`xs`,onClick:()=>void M(),disabled:b,children:`Save`})]}):null,S?(0,U.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,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[ie,` changed on disk since you opened it, maybe by an agent.`]}),(0,U.jsx)(X,{size:`xs`,variant:`outline`,onClick:()=>{y(void 0),C(!1),_()},children:`Load theirs`}),(0,U.jsx)(X,{size:`xs`,onClick:()=>void M(!0),disabled:b,children:`Overwrite with mine`})]}):null,(0,U.jsx)(`div`,{className:`code-pane relative flex min-h-0 flex-1 flex-col`,children:h?(0,U.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,U.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&&ne===`code`?(0,U.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,U.jsx)(Zm,{"aria-hidden":`true`,className:`size-5`}),`This file was deleted. Switch to Diff to see what it held.`]}):(0,U.jsx)(m.Suspense,{fallback:(0,U.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:`Loading code…`}),children:(0,U.jsx)(rZ,{path:k.path,version:`${f.version}`,contents:k.contents??``,draft:v,original:k.original,mode:ne,layout:D,wrap:E,dark:O,readOnly:!ae,onDraft:y})}):(0,U.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:g?`Opening…`:``}):(0,U.jsx)(mZ,{loading:s.loading})})]})]})}function mZ({loading:e}){return(0,U.jsxs)(`div`,{className:`m-auto flex max-w-xs flex-col items-center gap-2 px-6 text-center`,children:[(0,U.jsx)(Gm,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`}),(0,U.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 hZ({codeKey:e}){let{open:t,path:n,mode:r,request:i}=cz(),a=tO(t,eO.help),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(0),u=()=>l(e=>e+1);return(0,U.jsx)(qD,{open:a,onOpenChange:e=>{e||(o?u():oz())},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,U.jsx)(pZ,{requested:n,requestedMode:r,request:i,codeKey:e,onClose:oz,onDirtyChange:s,closeAsked:c}):null})}function gZ(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 _Z(){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 Ce()?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(gZ(e))}return(0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-y-auto p-6`,children:(0,U.jsxs)(`form`,{onSubmit:s,className:`glass flex min-h-0 w-full max-w-md flex-col gap-4 rounded-xl p-6`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(lh,{className:`size-5`,"aria-hidden":`true`}),(0,U.jsx)(`h1`,{className:`text-base font-medium`,children:`Sign in to bot-lobby`})]}),(0,U.jsxs)(`p`,{className:`break-words text-sm text-muted-foreground`,children:[`Pi printed a link when it started (or run `,(0,U.jsx)(`code`,{className:`rounded-lg bg-muted px-1.5 py-0.5 font-mono text-xs`,children:`/bot-lobby web`}),`to see it again). Paste it here.`]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:`Lobby link or token`}),(0,U.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),autoComplete:`off`,spellCheck:!1,placeholder:`http://127.0.0.1:7347/#token=…`,className:`h-8 min-w-0 rounded-lg border border-input bg-background px-3.5 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30`})]}),n?(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:n}):null,(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,U.jsx)(X,{type:`button`,variant:`ghost`,disabled:i,onClick:()=>void o(void 0),children:`Retry`}),(0,U.jsx)(X,{type:`submit`,disabled:i||!e.trim(),children:`Sign in`})]})]})})}var vZ=.6;function yZ(e,t,n={}){return{initial:e?void 0:!1,animate:t,transition:{duration:vZ,...n}}}var bZ=(e,t)=>[0,Math.max(e,.001),Math.min(Math.max(t,e+.01),.999),1];function xZ(e,t=0,n=1){return yZ(e,{pathLength:[0,0,1,1],strokeOpacity:[0,0,1,1]},{pathLength:{duration:vZ,times:bZ(t,n),ease:`easeInOut`},strokeOpacity:{duration:vZ,times:bZ(t,t+.02)}})}function SZ(e,t){return yZ(e,{scale:[0,0,1.3,1]},{times:bZ(t,t+.18),ease:`easeOut`})}function CZ(e,t,n=1.3){return yZ(e,{scale:[1,1,n,1,1]},{times:[0,Math.max(t,.001),Math.min(t+.15,.9),Math.min(t+.35,.99),1],ease:`easeInOut`})}var wZ=(e=.5,t=.5)=>({transformBox:`fill-box`,originX:e,originY:t});function TZ({play:e}){return(0,U.jsxs)(Xf.g,{style:wZ(.1,.9),...yZ(e,{rotate:[0,-12,8,-4,0],scale:[1,1.12,.96,1.02,1]},{ease:`easeInOut`}),children:[(0,U.jsx)(`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`}),[8,12,16].map((t,n)=>(0,U.jsx)(Xf.circle,{cx:t,cy:11,r:1.15,fill:`currentColor`,stroke:`none`,...yZ(e,{fillOpacity:[0,0,1,1,0],y:[0,0,-1.5,0,0]},{times:[0,.12+n*.12,.24+n*.12,.72,1]})},t))]})}function EZ({play:e}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Xf.path,{d:`M13 5h8`,...xZ(e,.15,.45)}),(0,U.jsx)(Xf.path,{d:`M13 12h8`,...xZ(e,.3,.6)}),(0,U.jsx)(Xf.path,{d:`M13 19h8`,...xZ(e,.45,.75)}),(0,U.jsx)(Xf.path,{d:`m3 17 2 2 4-4`,...xZ(e,.35,.7)}),(0,U.jsx)(Xf.path,{d:`m3 7 2 2 4-4`,...xZ(e,0,.35)})]})}function DZ({play:e}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Xf.circle,{cx:6,cy:19,r:3,style:wZ(),...CZ(e,0)}),(0,U.jsx)(Xf.path,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,...xZ(e,.1,.7)}),(0,U.jsx)(Xf.circle,{cx:18,cy:5,r:3,style:wZ(),...SZ(e,.62)})]})}function OZ({play:e}){return(0,U.jsxs)(Xf.g,{style:wZ(),...yZ(e,{scaleX:[1,.55,1.08,1],y:[0,-1,0,0]},{times:[0,.35,.65,1],ease:`easeInOut`}),children:[(0,U.jsx)(Xf.path,{d:`M12 5v16`,style:wZ(),...yZ(e,{scaleY:[1,1.12,1,1]},{times:[0,.35,.65,1]})}),(0,U.jsx)(`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`})]})}var kZ={lobby:TZ,tasks:EZ,plan:DZ,knowledge:OZ};function AZ({id:e,play:t,className:n}){let r=kZ[e];return r?(0,U.jsx)(`svg`,{"aria-hidden":`true`,"data-tab-icon":e,"data-play":t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:Y(`overflow-visible`,n),children:(0,U.jsx)(r,{play:t})},t):null}function jZ(e){return/(\d)$/.exec(e)?.[1]}var MZ=160;function NZ(e){let t=Ef(),[n,r]=(0,m.useState)(0),i=(0,m.useRef)(0),a=(0,m.useCallback)(()=>{t||performance.now()<i.current||(i.current=performance.now()+vZ*1e3,r(e=>e+1))},[t]),o=(0,m.useRef)(e);return(0,m.useEffect)(()=>{let t=e&&!o.current;if(o.current=e,!t)return;let n=window.setTimeout(a,MZ);return()=>window.clearTimeout(n)},[e,a]),{play:n,onPointerEnter:(0,m.useCallback)(e=>{e.pointerType!==`touch`&&a()},[a])}}var PZ=(0,m.forwardRef)(function({tab:e,active:t},n){let r=jZ(e.key),{play:i,onPointerEnter:a}=NZ(t);return(0,U.jsxs)(eR,{children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.jsxs)(`a`,{ref:n,role:`tab`,id:`tab-${e.id}`,href:`#/${e.id}`,"aria-selected":t,"aria-keyshortcuts":e.key,tabIndex:t?0:-1,onPointerEnter:a,className:Y(`relative z-10 inline-flex h-7 shrink-0 items-center gap-1.5 rounded-lg border border-[var(--tab-outline)] px-2.5 text-[0.8125rem] leading-none font-medium whitespace-nowrap outline-none`,`transition-colors duration-200 ease-snap focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t?`text-foreground`:`bg-[var(--tab-idle)] text-muted-foreground hover:bg-accent hover:text-foreground`),children:[(0,U.jsx)(AZ,{id:e.id,play:i,className:Y(`size-3.5 shrink-0 transition-colors duration-200`,t&&`text-primary`)}),r?(0,U.jsx)(`span`,{"aria-hidden":`true`,className:Y(`text-[0.72rem] font-semibold tabular-nums transition-colors duration-200`,t?`text-primary`:`text-muted-foreground/75`),children:r}):null,(0,U.jsx)(`span`,{children:e.label})]})}),(0,U.jsxs)(nR,{children:[e.label,` `,(0,U.jsx)(GD,{chord:e.key})]})]})}),FZ=1.5;function IZ(e,t,n=t?.left??0,r=t?.right??0,i=1){if(e){if(!t||r-n<.5){e.style.opacity=`0`;return}e.style.opacity=String(Math.min(1,(r-n)/14)),e.style.top=`${t.top}px`,e.style.height=`${t.height}px`,e.style.width=`${r-n}px`,e.style.transform=`translateX(${n}px)`,e.style.scale=i===1?``:`1 ${i}`}}function LZ(e,t){let n=e.right-e.left,{height:r}=e,i=FZ/2,a=Math.max(0,Math.min(e.radius-i,r/2-i,n/2-i)),o=r/2,s=e=>+(t===`left`?e:n-e).toFixed(2),c=+(t===`left`),l=1-c,u=i,d=n-i,f=r-i;return[`M${s(u)} ${o}L${s(u)} ${i+a}A${a} ${a} 0 0 ${c} ${s(u+a)} ${i}L${s(d-a)} ${i}A${a} ${a} 0 0 ${c} ${s(d)} ${i+a}L${s(d)} ${o}`,`M${s(u)} ${o}L${s(u)} ${f-a}A${a} ${a} 0 0 ${l} ${s(u+a)} ${f}L${s(d-a)} ${f}A${a} ${a} 0 0 ${l} ${s(d)} ${f-a}L${s(d)} ${o}`]}function RZ(e,t,n,r){if(!e)return;if(!t||r<=.002){e.style.opacity=`0`;return}let i=t.right-t.left,a=`${i}x${t.height}r${t.radius}${n}`;e.dataset.shape!==a&&(e.dataset.shape=a,e.dataset.port=n,e.setAttribute(`viewBox`,`0 0 ${i} ${t.height}`),LZ(t,n).forEach((t,n)=>e.children[n]?.setAttribute(`d`,t))),e.style.opacity=String(Math.min(1,r*12)),e.style.top=`${t.top}px`,e.style.height=`${t.height}px`,e.style.width=`${i}px`,e.style.transform=`translateX(${t.left}px)`;let o=`${Math.min(1,r)} 2`;for(let t of e.children)t.style.strokeDasharray=o}var zZ={type:`spring`,visualDuration:.12,bounce:0},BZ={type:`spring`,visualDuration:.17,bounce:.15,delay:.015},VZ={type:`spring`,visualDuration:.17,bounce:.05,delay:.07},HZ={type:`spring`,visualDuration:.22,bounce:.25},UZ={type:`spring`,visualDuration:.2,bounce:0},WZ={type:`spring`,stiffness:900,damping:18,velocity:45,restDelta:.02,restSpeed:1},GZ=(()=>{let e=Dr({keyframes:[0,1],visualDuration:HZ.visualDuration,bounce:HZ.bounce}),t=0;for(;t<1e3&&e.next(t).value<.97;)t+=4;return t/1e3})(),KZ={type:`spring`,visualDuration:.28,bounce:.6};function qZ(e,t){let n=(0,m.useRef)(null),r=(0,m.useRef)(null),i=(0,m.useRef)(null),a=(0,m.useRef)(null),o=(0,m.useRef)(null),s=(0,m.useRef)({}),c=(0,m.useRef)([]),l=(0,m.useRef)(void 0),u=(0,m.useRef)([]),d=(0,m.useRef)(1),f=(0,m.useRef)(1),p=(0,m.useCallback)(e=>{let t=e?s.current[e]:void 0;if(!t)return;let n=parseFloat(getComputedStyle(t).borderTopLeftRadius)||0;return{left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,top:t.offsetTop,height:t.offsetHeight,radius:n}},[]),h=(0,m.useCallback)(()=>{for(let e of u.current)e.stop();u.current=[];for(let e of Object.values(s.current))e?.style.translate&&(e.style.translate=``)},[]),g=(0,m.useCallback)(e=>{h(),l.current=e,d.current=1,f.current=1;let t=p(e);IZ(r.current,t),IZ(i.current,void 0),RZ(a.current,t,`left`,1),RZ(o.current,void 0,`left`,0);for(let e of c.current)e&&(e.style.width=`0px`);YR()},[p,h]),_=(0,m.useCallback)((e,t)=>{let n=p(e),m=p(t);if(!n||!m)return g(t);h(),JR(),l.current=t;let _=m.left>n.left?1:-1,v=_>0?n.right:n.left,y=_>0?m.left:m.right,b=Math.abs(y-v),x=_>0?`right`:`left`,S=_>0?`left`:`right`,C=c.current.map(e=>{let t=e?.parentElement;return t?{liquid:e,from:t.offsetLeft,to:t.offsetLeft+t.offsetWidth}:void 0}),w=b>4?1-4/b:0,T={drained:1-Math.min(1,d.current),unrung:1-Math.min(1,f.current),head:0,tail:0,filled:0,rung:0,squash:1,budge:0},E=s.current[t];d.current=0,f.current=0;let D=()=>{let e=(n.right-n.left)*Math.min(1,T.drained);IZ(i.current,n,_>0?n.left+e:n.left,_>0?n.right:n.right-e),RZ(o.current,n,x,1-T.unrung);let t=v+_*b*T.head,s=v+_*b*T.tail,c=Math.min(t,s),l=Math.max(t,s);for(let e of C){if(!e?.liquid)continue;let t=Math.max(c,e.from),n=Math.min(l,e.to);e.liquid.style.width=`${Math.max(0,n-t)}px`,e.liquid.style.transform=`translateX(${Math.max(0,t-e.from)}px)`}let u=_*T.budge,d=u?{...m,left:m.left+u,right:m.right+u}:m;E&&(E.style.translate=Math.abs(u)>.01?`${u.toFixed(2)}px`:``);let f=(d.right-d.left)*Math.min(1,Math.max(0,T.filled));IZ(r.current,d,_>0?d.left:d.right-f,_>0?d.left+f:d.right,Math.min(1,T.squash)),RZ(a.current,d,S,T.rung)},O=(e,t,n,r,i=1)=>{let a=Yf(t,i,{...n,onUpdate:t=>{T[e]=t,r?.(t),D()}});return u.current.push(a),a},k=!1,A=()=>{if(k)return;k=!0;let e=O(`filled`,0,HZ,e=>{d.current=e});e.then(()=>{l.current===t&&YR()}),O(`squash`,.8,KZ),O(`rung`,0,UZ,e=>{f.current=e}),O(`budge`,0,{...WZ,delay:GZ},void 0,0),Promise.all([e,...u.current]).then(()=>{l.current===t&&u.current.includes(e)&&g(t)})};O(`drained`,T.drained,zZ),O(`unrung`,T.unrung,zZ),O(`head`,0,BZ,e=>{e>=w&&A()}),O(`tail`,0,VZ),D()},[p,g,h]);(0,m.useLayoutEffect)(()=>{let t=l.current,n=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;!t||!e||t===e||n?g(e):_(t,e)},[e,t,_,g]);let v=(0,m.useRef)(e);return v.current=e,(0,m.useEffect)(()=>{let e=n.current;if(!e||typeof ResizeObserver>`u`)return;let t=!0,r=new ResizeObserver(()=>{if(t){t=!1;return}g(v.current)});return r.observe(e),()=>{r.disconnect(),h()}},[g,h]),{track:n,fill:r,drain:i,ring:a,unring:o,cells:s,liquids:c}}var JZ=(0,m.forwardRef)(function({which:e},t){return(0,U.jsxs)(`svg`,{ref:t,"aria-hidden":`true`,[`data-tab-${e}`]:``,className:`pointer-events-none absolute left-0 z-20 overflow-visible opacity-0 will-change-transform`,fill:`none`,children:[(0,U.jsx)(`path`,{pathLength:1,strokeWidth:FZ,strokeLinecap:`round`,className:`stroke-tab-rim`}),(0,U.jsx)(`path`,{pathLength:1,strokeWidth:FZ,strokeLinecap:`round`,className:`stroke-tab-rim`})]})});function YZ(e){if(e.left||e.right)return`linear-gradient(to right, ${e.left?`transparent 0, black 28px`:`black 0`}, ${e.right?`black calc(100% - 28px), transparent 100%`:`black 100%`})`}function XZ({tabs:e,activeId:t,onSelect:n}){let{track:r,fill:i,drain:a,ring:o,unring:s,cells:c,liquids:l}=qZ(t,e.length),u=(0,m.useRef)(null),[d,f]=(0,m.useState)({left:!1,right:!1}),p=(0,m.useCallback)(()=>{let e=u.current;if(!e)return;let t=e.scrollLeft>2,n=e.scrollLeft+e.clientWidth<e.scrollWidth-2;f(e=>e.left===t&&e.right===n?e:{left:t,right:n})},[]);(0,m.useEffect)(()=>{let e=u.current;if(!e||typeof ResizeObserver>`u`)return;p();let t=new ResizeObserver(p);return t.observe(e),e.firstElementChild&&t.observe(e.firstElementChild),()=>t.disconnect()},[p,e.length]),(0,m.useEffect)(()=>{let e=u.current,n=t?c.current[t]:void 0;e&&n&&(n.offsetLeft<e.scrollLeft?e.scrollLeft=n.offsetLeft-8:n.offsetLeft+n.offsetWidth>e.scrollLeft+e.clientWidth&&(e.scrollLeft=n.offsetLeft+n.offsetWidth-e.clientWidth+8))},[t,c]);function h(r){if(r.key===`ArrowDown`&&!r.altKey){pR()&&r.preventDefault();return}let i=r.key===`ArrowRight`?1:r.key===`ArrowLeft`?-1:0;if(!i||e.length===0)return;r.preventDefault();let a=r.target.closest(`[role='tab']`)?.id.replace(/^tab-/,``)??t,o=e[(Math.max(0,e.findIndex(e=>e.id===a))+i+e.length)%e.length];hR.active=!0,hR.to=o.id,window.setTimeout(()=>{hR.active=!1,hR.to=void 0},3e3),n(o.id),c.current[o.id]?.focus({preventScroll:!0})}return(0,U.jsx)(`div`,{ref:u,onScroll:p,style:{maskImage:YZ(d),WebkitMaskImage:YZ(d)},className:`min-w-0 max-w-full overflow-x-auto [scrollbar-width:none] pointer-coarse:-my-1.5 pointer-coarse:py-1.5 [&::-webkit-scrollbar]:hidden`,children:(0,U.jsxs)(`div`,{ref:r,role:`tablist`,"aria-label":`Lobby tabs`,onKeyDown:h,className:`relative mx-auto flex w-max items-center py-0.5`,children:[(0,U.jsx)(`span`,{ref:a,"aria-hidden":`true`,"data-tab-drain":!0,className:`pointer-events-none absolute left-0 z-0 rounded-lg bg-tab-fill opacity-0 will-change-transform`}),(0,U.jsx)(`span`,{ref:i,"aria-hidden":`true`,"data-tab-fill":!0,className:`pointer-events-none absolute left-0 z-0 rounded-lg bg-tab-fill opacity-0 will-change-transform`}),(0,U.jsx)(JZ,{ref:s,which:`unring`}),(0,U.jsx)(JZ,{ref:o,which:`ring`}),e.map((e,n)=>(0,U.jsxs)(m.Fragment,{children:[n>0?(0,U.jsxs)(`span`,{"aria-hidden":`true`,"data-tab-link":!0,className:`relative h-[2px] w-3.5 shrink-0 sm:w-4`,children:[(0,U.jsx)(`span`,{className:`absolute inset-0 border-t-2 border-dotted border-input`}),(0,U.jsx)(`span`,{ref:e=>{l.current[n-1]=e},"data-tab-liquid":!0,className:`absolute top-0 left-0 h-[2px] w-0 rounded-full bg-tab-liquid shadow-[0_0_6px_var(--tab-liquid)] will-change-transform`})]}):null,(0,U.jsx)(PZ,{ref:t=>{c.current[e.id]=t},tab:e,active:e.id===t})]},e.id))]})})}function ZZ({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(gO(bO(e)));for(let e of n)e.pending&&e.source!==`LOBBY`&&i.add(e.source===`MASTER`?`Oracle`:gO(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 QZ(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}var $Z=6,eQ=`bot-lobby.orb`,tQ=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=1;function nQ(e,t,n,r){let i=e=>e+$Z,a=(e,t)=>Math.max(e+$Z,e+t-r-$Z);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 rQ(e,t,n,r){let i=e=>Math.max(1,e-r),a=nQ(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 iQ(e,t,n){return nQ(t.left+e.fx*Math.max(0,t.width-n),t.top+e.fy*Math.max(0,t.height-n),t,n)}function aQ(e){if(e)try{let t=JSON.parse(e);return tQ(t.fx)&&tQ(t.fy)?{fx:t.fx,fy:t.fy}:void 0}catch{return}}function oQ(){try{return aQ(localStorage.getItem(eQ))}catch{return}}function sQ(e){try{localStorage.setItem(eQ,JSON.stringify(e))}catch{}}var cQ=5,lQ=16;function uQ(e){return{left:e.left,top:e.top,width:e.width,height:e.height}}function dQ(){let e=document.getElementById(`main`)?.getBoundingClientRect();return e?uQ(e):void 0}function fQ(e,t){return!e||!t?e===t:e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function pQ(){let[e,t]=(0,m.useState)(()=>dQ());return(0,m.useEffect)(()=>{let e=()=>{let e=dQ();t(t=>fQ(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 mQ=(0,m.forwardRef)(function({spotlight:e,thinking:t,busy:n=[],tone:r,expanded:i,hidden:a,shortcut:o,onOpen:s},c){let l=pQ(),[u,d]=(0,m.useState)(oQ),[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?iQ(u,l,y.current):void 0),x=(0,m.useCallback)((e,t)=>{let n=dQ();if(!n)return;let r=rQ(e,t,n,y.current);d(r),sQ(r)},[]);(0,m.useEffect)(()=>{l&&p(e=>e&&nQ(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)<cQ)return;t.moved=!0;let i=dQ();i&&p(nQ(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:lQ,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?gO(e):E?QZ(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(gO).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,U.jsxs)(eR,{open:h&&!f,onOpenChange:g,children:[(0,U.jsx)(tR,{asChild:!0,children:(0,U.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,U.jsx)(ju,{initial:!1,children:D?(0,U.jsx)(Xf.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,U.jsx)(ju,{mode:`popLayout`,initial:!1,children:(0,U.jsx)(Xf.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,U.jsx)(`span`,{"aria-hidden":`true`,className:`orb orb-float`,children:(0,U.jsx)(`span`,{className:`orb-icon`,children:(0,U.jsx)(pO,{source:k,strokeWidth:2.25,className:`size-3.5`})})})]})}),(0,U.jsxs)(nR,{side:`top`,children:[`Thinking `,o?(0,U.jsx)(GD,{chord:o}):null,(0,U.jsx)(`span`,{className:`text-background/70`,children:` · drag to move`})]})]})}),hQ=/^\s*(?:#{1,6}\s+(.+?)\s*#*|\*\*([^*\n]{2,90}?):?\*\*:?|__([^_\n]{2,90}?):?__:?)\s*$/,gQ=260,_Q=200,vQ=/^\s*(?:[-*+]\s|\d+[.)]\s|>|```|~~~|\|)/m;function yQ(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 bQ(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 xQ(e){if(e.length<=gQ||vQ.test(e))return[e];let t=[],n=``;for(let r of bQ(e.replace(/\s*\n\s*/g,` `)))n&&n.length+r.length+1>_Q?(t.push(n),n=r):n=n?`${n} ${r}`:r;return n&&t.push(n),t}function SQ(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:hQ.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=yQ(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
|
|
108
|
+
`)});else for(let e of t)for(let t of xQ(e))i.push({text:t})}return i}var CQ=4,wQ=1800,TQ=e=>({"--orb":e});function EQ(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),wQ);return()=>window.clearInterval(t)},[r,e.length]),e.length?e[t%e.length]:void 0}function DQ({thought:e}){let t=(0,m.useMemo)(()=>SQ(e.text),[e.text]),[n,r]=(0,m.useState)(!1),i=n?0:Math.max(0,t.length-CQ),a=t.slice(i),o=gO(e.source);return(0,U.jsxs)(`li`,{className:`thought`,style:TQ(yO(e.source)),"data-live":e.live||void 0,"aria-label":`${o}${e.live?`, thinking`:``}`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`span`,{className:`thought-label`,children:[(0,U.jsx)(pO,{source:e.source,strokeWidth:2.25,className:`size-3.5`}),o]}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.live?(0,U.jsxs)(`span`,{className:`thought-live`,children:[`thinking`,(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`thought-ellipsis`})]}):WO(Date.now()-e.at)}),t.length>1?(0,U.jsxs)(`span`,{className:`ml-auto text-xs text-muted-foreground tabular-nums`,children:[t.length,` steps`]}):null]}),i?(0,U.jsxs)(`button`,{type:`button`,"data-compact":!0,className:`thought-more`,onClick:()=>r(!0),children:[i,` earlier `,i===1?`step`:`steps`]}):null,(0,U.jsx)(`ol`,{className:`thought-steps`,"data-single":a.length===1||void 0,children:a.map((t,n)=>(0,U.jsxs)(`li`,{"data-current":e.live&&n===a.length-1||void 0,children:[t.title?(0,U.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t.title}):null,t.text?(0,U.jsx)(Mz,{text:t.text,className:`thought-text`}):null]},i+n))})]})}function OQ(e,t,n){(0,m.useEffect)(()=>{if(!e||!t)return;let r=e=>{e.defaultPrevented||e.isComposing||!yJ(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 kQ(e){return[...e].sort((e,t)=>Number(t.live)-Number(e.live)||t.at-e.at||t.id-e.id)}function AQ({thoughts:e,collapsed:t,onToggle:n,shortcut:r,busy:i=[]}){let a=kQ(SO(e)),o=a.filter(e=>e.live).map(e=>e.source),s=EQ(o),c=s?yO(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=tO(!t,eO.sheet),h=rO();OQ(p,r,n);let g=a.length>0||i.length>0;return(0,U.jsxs)(U.Fragment,{children:[g&&(0,dy.createPortal)((0,U.jsx)(mQ,{ref:u,spotlight:s,thinking:o,busy:i,tone:c,expanded:!t,hidden:h,shortcut:r,onOpen:n}),document.body),(0,U.jsxs)(qD,{open:p,onOpenChange:e=>{!e&&!t&&n()},label:`Thinking`,className:Y(`thought-pane max-w-xl`,l&&`thought-pane-live`),style:TQ(c),onCloseAutoFocus:e=>{e.preventDefault(),requestAnimationFrame(()=>{document.querySelector(`[role='dialog']`)||u.current?.focus()})},children:[(0,U.jsx)(`div`,{"aria-hidden":`true`,className:`thought-aura`,"data-working":l}),(0,U.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,U.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:a.map(e=>(0,U.jsx)(DQ,{thought:e},e.id))}):(0,U.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,U.jsx)(Bv,{target:d})]})]})}function jQ({status:e,lobby:t}){let[n,r]=Hz(`lobby.thinking`),i=EB(`sessions.list`,{},[`sessions`]);if(!e||e.panels?.thinking===!1)return null;let a=ZZ({oracleBusy:e.busy,runs:xO(t),activity:t?.activity??[],background:i.data?.background??[]}),o=e.keys.find(e=>e.action===`thinking`)?.label;return(0,U.jsx)(AQ,{thoughts:t?.thoughts??[],collapsed:n,onToggle:r,shortcut:o,busy:a})}var MQ=//g;function NQ(e){let t=[],n=e=>{if(e.nodeType===Node.TEXT_NODE)return(e.textContent??``).replace(MQ,``);if(!(e instanceof HTMLElement))return``;let t=[...e.childNodes].map(n).join(``),i=e.tagName;return i===`BR`?`
|
|
109
109
|
`:t.trim()?i===`B`||i===`STRONG`?`**${t}**`:i===`I`||i===`EM`?`_${t}_`:i===`CODE`?`\`${t}\``:i===`UL`||i===`OL`?`\n${r(e)}\n`:i===`DIV`||i===`P`||i===`LI`?`\n${t}\n`:t:t},r=e=>[...e.children].filter(e=>e.tagName===`LI`).map((t,r)=>`${e.tagName===`OL`?`${r+1}.`:`-`} ${[...t.childNodes].map(n).join(``).trim()}`).join(`
|
|
110
110
|
`);return t.push([...e.childNodes].map(n).join(``)),t.join(``).replace(/\n{3,}/g,`
|
|
111
111
|
|
|
112
|
-
`).trim()}function NQ(e){let t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return!1;let n=document.createRange();return n.selectNodeContents(e),n.setEnd(t.getRangeAt(0).startContainer,t.getRangeAt(0).startOffset),n.toString().replace(jQ,``)===``}function PQ(e){let t=window.getSelection()?.anchorNode,n=t instanceof HTMLElement?t:t?.parentElement;return!!(n?.closest(`li`)&&e.contains(n))}function FQ(e){return e.replace(/[&<>"]/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`})[e]??e)}function IQ(e){if(e!==`code`){document.execCommand(e);return}let t=window.getSelection()?.toString()??``;document.execCommand(`insertHTML`,!1,t?`<code>${FQ(t)}</code>`:`<code></code>`)}var LQ=[{format:`bold`,label:`Bold`,keys:`Ctrl+B`,icon:Gp},{format:`italic`,label:`Italic`,keys:`Ctrl+I`,icon:sh},{format:`code`,label:`Code`,keys:`Ctrl+E`,icon:Dm},{format:`insertUnorderedList`,label:`Bulleted list`,icon:yh},{format:`insertOrderedList`,label:`Numbered list`,icon:_h}],RQ=(0,m.forwardRef)(function({html:e,placeholder:t,label:n,landed:r,onChange:i,onFocusChange:a,onSubmit:o,onUp:s},c){let l=(0,m.useRef)(null),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(!e),[h,g]=(0,m.useState)({});(0,m.useImperativeHandle)(c,()=>({element:l.current}),[]),(0,m.useEffect)(()=>{let t=l.current;t&&(e===``&&t.innerHTML!==``?(t.innerHTML=``,p(!0)):e&&t.innerHTML===``&&(t.innerHTML=e,p(!1)))},[e]);let _=(0,m.useCallback)(()=>{let e=l.current;if(!e)return;let t=MQ(e);p(t===``&&!e.querySelector(`li`)),i(t,t?e.innerHTML:``)},[i]);(0,m.useEffect)(()=>{if(!u)return;let e=()=>g(Object.fromEntries(LQ.filter(e=>e.format!==`code`).map(e=>[e.format,document.queryCommandState(e.format)])));return document.addEventListener(`selectionchange`,e),e(),()=>document.removeEventListener(`selectionchange`,e)},[u]);function v(e){l.current?.focus(),IQ(e),_()}function y(e){let t=l.current;if(!t)return;let n=e.ctrlKey||e.metaKey;if(n&&!e.altKey&&[`b`,`i`,`e`].includes(e.key.toLowerCase())){e.preventDefault(),e.stopPropagation(),v(e.key.toLowerCase()===`b`?`bold`:e.key.toLowerCase()===`i`?`italic`:`code`);return}if(e.key===`Enter`&&!e.shiftKey&&!n&&!e.nativeEvent.isComposing){if(PQ(t))return;e.preventDefault(),o();return}e.key===`ArrowUp`&&NQ(t)&&(e.preventDefault(),s())}return(0,U.jsxs)(`div`,{"data-own":``,"data-open":u||!f||void 0,"data-landed":r||void 0,className:`q-own group/own relative flex w-full min-w-0 flex-col overflow-hidden border`,children:[(0,U.jsx)(`div`,{ref:l,role:`textbox`,"aria-multiline":`true`,"aria-label":n,"aria-placeholder":t,contentEditable:!0,suppressContentEditableWarning:!0,"data-nav":``,"data-empty":f||void 0,"data-placeholder":t,tabIndex:0,onInput:_,onKeyDown:y,onPaste:e=>{e.preventDefault(),document.execCommand(`insertText`,!1,e.clipboardData.getData(`text/plain`))},onFocus:()=>{d(!0),a(!0)},onBlur:e=>{d(!1),a(!1,e.relatedTarget)},className:`q-own-text min-h-9 w-full min-w-0 px-4 py-2 text-sm break-words outline-none [&_code]:rounded [&_code]:bg-muted [&_code]:px-1 [&_code]:font-mono [&_code]:text-[0.8125rem] [&_ol]:list-decimal [&_ol]:ps-5 [&_ul]:list-disc [&_ul]:ps-5`}),(0,U.jsxs)(`div`,{role:`toolbar`,"aria-label":`Formatting`,"aria-hidden":!u,className:Y(`q-own-bar flex items-center gap-0.5 px-2 pb-1.5`,!u&&`pointer-events-none`),children:[LQ.map(({format:e,label:t,keys:n,icon:r})=>(0,U.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":t,"aria-pressed":h[e]??!1,title:n?`${t} · ${n}`:t,onMouseDown:e=>e.preventDefault(),onClick:()=>v(e),className:`inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground aria-pressed:bg-primary/12 aria-pressed:text-primary`,children:(0,U.jsx)(r,{"aria-hidden":`true`,className:`size-3.5`})},e)),(0,U.jsx)(`span`,{className:`ms-auto pe-1 text-2xs text-muted-foreground`,children:`Enter answers · Shift+Enter new line`})]})]})});function zQ(e){return e?e.options.some(_G)?`xl`:e.question.length+e.options.reduce((e,t)=>e+t.label.length+(t.description?.length??0),0)>700||e.options.length>6?`lg`:`md`:`md`}var BQ=/\s*\(recommended\)\s*$/i,VQ=1200,HQ=`Type something.`;function UQ(e){return{text:e.replace(BQ,``),recommended:BQ.test(e)}}function WQ({label:e}){let{text:t,recommended:n}=UQ(e);return(0,U.jsxs)(`span`,{className:`leading-snug break-words`,children:[t,n?(0,U.jsx)(`span`,{className:`ms-1 font-medium text-primary`,children:`(Recommended)`}):null]})}function GQ({multi:e,on:t}){return(0,U.jsxs)(`span`,{"aria-hidden":`true`,className:Y(`relative mt-0.5 flex size-4 shrink-0 items-center justify-center border`,e?`rounded-lg`:`rounded-full`,t?`border-primary bg-primary text-primary-foreground`:`border-input`),children:[t?(0,U.jsx)($p,{className:Y(e?`size-3`:`hidden`)}):null,t&&!e?(0,U.jsx)(`span`,{className:`size-2 rounded-full bg-primary-foreground`}):null]})}function KQ({option:e,index:t,multi:n,name:r,selected:i,onToggle:a,onFocusOption:o}){return(0,U.jsxs)(`div`,{className:`grid gap-1`,children:[(0,U.jsxs)(`label`,{className:Y(`flex min-h-9 cursor-pointer items-start gap-2.5 rounded-lg border px-3 py-2 text-start text-sm transition-[background-color,border-color,transform] duration-150 ease-snap active:scale-[0.99]`,i?`border-primary/50 bg-accent`:`border-input bg-background hover:bg-accent/60`,`has-[:focus-visible]:border-ring has-[:focus-visible]:ring-3 has-[:focus-visible]:ring-ring/30`),children:[(0,U.jsx)(`input`,{type:n?`checkbox`:`radio`,name:r,"data-nav":``,"data-option":t,className:`sr-only`,checked:i,onChange:a,onFocus:o}),(0,U.jsx)(GQ,{multi:n,on:i}),(0,U.jsx)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:(0,U.jsxs)(`span`,{className:`flex gap-1.5`,children:[(0,U.jsxs)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,U.jsx)(WQ,{label:e.label})]})})]}),e.description?(0,U.jsx)(Mz,{text:e.description,className:`px-3 text-muted-foreground`}):null]})}function qQ({option:e,onExpand:t}){return!e||!_G(e)?null:(0,U.jsxs)(`div`,{className:`card-flat flex min-w-0 max-w-full flex-col gap-2 rounded-lg border p-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`p`,{className:`min-w-0 truncate text-xs font-medium text-muted-foreground`,children:[`Preview · `,UQ(e.label).text]}),(0,U.jsxs)(X,{type:`button`,variant:`ghost`,size:`xs`,onClick:t,"aria-keyshortcuts":`E`,title:`Expand · E`,className:`-my-1 shrink-0`,children:[(0,U.jsx)(Ch,{"aria-hidden":`true`}),`Expand`]})]}),e.image?(0,U.jsx)(`img`,{src:I(e.image),alt:``,loading:`lazy`,className:`max-h-64 w-full rounded-lg border object-contain`}):null,e.htmlPreview?(0,U.jsx)(pG,{preview:e.htmlPreview,label:UQ(e.label).text,frameWidth:VQ,onOpen:t,className:`h-auto aspect-[3/2]`}):null,e.preview?(0,U.jsx)(Mz,{text:e.preview,className:`text-xs`}):null]})}function JQ({option:e,index:t,multi:n,name:r,selected:i,active:a,onToggle:o,onFocusOption:s}){let{text:c,recommended:l}=UQ(e.label),u=l?`${c} (Recommended)`:c;return(0,U.jsxs)(`label`,{"data-active":a||void 0,"data-picked":i||void 0,className:`q-dot group relative flex h-11 w-full shrink-0 cursor-pointer items-center justify-center outline-none`,children:[(0,U.jsx)(`input`,{type:n?`checkbox`:`radio`,name:r,"data-nav":``,"data-option":t,"aria-label":u,className:`sr-only`,checked:i,onChange:o,onFocus:s}),(0,U.jsx)(`span`,{"aria-hidden":`true`,className:Y(`q-dot-mark relative z-10 flex size-5 items-center justify-center rounded-full text-[0.625rem] font-semibold tabular-nums transition-[background-color,color,scale] duration-200 ease-snap group-hover:scale-110`,l&&`q-dot-star`),children:t+1}),(0,U.jsxs)(`span`,{"aria-hidden":`true`,className:`q-dot-tag pointer-events-none absolute top-1/2 left-[calc(100%+0.5rem)] z-30 -translate-y-1/2 rounded-full px-2.5 py-1 text-xs font-medium whitespace-nowrap opacity-0 transition-[opacity,translate] duration-150 ease-snap group-hover:opacity-100 group-has-[:focus-visible]:opacity-100 group-data-[active]:!opacity-0`,children:[t+1,`. `,u]})]})}var YQ={type:`spring`,visualDuration:.2,bounce:.12},XQ={type:`spring`,visualDuration:.2,bounce:.04,delay:.06},ZQ={type:`spring`,visualDuration:.28,bounce:.55},QQ={type:`spring`,visualDuration:.2,bounce:0},$Q={type:`spring`,stiffness:900,damping:18,velocity:50,restDelta:.02,restSpeed:1},e$=-1;function t$(e,t,n,r,i,a){let o=(0,m.useRef)(null),s=(0,m.useRef)(null),c=(0,m.useRef)(null),l=(0,m.useRef)(null),u=(0,m.useRef)(void 0),d=(0,m.useRef)([]),f=(0,m.useRef)(a);f.current=a;let p=(0,m.useCallback)(t=>{if(t===e$){let t=n.current?.element,r=e.current;return t&&r?t.getBoundingClientRect().top-r.getBoundingClientRect().top+6:void 0}let r=e.current?.querySelectorAll(`.q-dot`)[t];return r?r.offsetTop+r.offsetHeight/2:void 0},[e,n]),h=(0,m.useCallback)(()=>{let t=o.current,n=e.current?.querySelectorAll(`.q-dot`);if(!t||!n||n.length===0)return;let r=n[0],i=n[n.length-1],a=r.offsetTop+r.offsetHeight/2;t.style.top=`${a}px`,t.style.height=`${Math.max(0,i.offsetTop+i.offsetHeight/2-a)}px`},[e]),g=(0,m.useCallback)((e,t=1,n=1)=>{let r=s.current,i=c.current;if(r&&i){if(e===void 0){r.style.opacity=`0`,i.style.opacity=`0`;return}r.style.opacity=String(Math.min(1,t*3)),r.style.transform=`translate(-50%, ${e}px) translateY(-50%) scale(${Math.max(0,t)})`,i.style.opacity=n>.02?`1`:`0`,i.style.transform=`translateY(${e}px) scaleX(${Math.max(0,Math.min(1,n))})`}},[]),_=(0,m.useRef)(i);return(0,m.useLayoutEffect)(()=>{_.current!==i&&(_.current=i,u.current=void 0),h();for(let e of d.current)e.stop();d.current=[],t.current&&(t.current.style.translate=``);let e=u.current;u.current=r;let n=p(r),a=e===void 0?void 0:p(e),o=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,s=l.current;if(s&&(s.style.opacity=`0`),n===void 0||a===void 0||e===r||e===e$||o||!s){g(r===e$?void 0:n),r===e$&&e!==r&&e!==void 0&&f.current();return}let c=n>a?1:-1,m={head:0,tail:0},v=!1,y=(e,t,n,r)=>{let i=Yf(e,t,{...n,onUpdate:r});return d.current.push(i),i},b=()=>{let e=a+(n-a)*m.head,t=a+(n-a)*m.tail;s.style.opacity=Math.abs(e-t)>1?`1`:`0`,s.style.transform=`translateY(${Math.min(e,t)}px)`,s.style.height=`${Math.abs(e-t)}px`},x=()=>{if(v)return;if(v=!0,r===e$){g(void 0),f.current();return}let e={open:0,reach:0},i=()=>p(r)??n;y(0,1,ZQ,t=>{e.open=t,g(i(),e.open,e.reach)}),y(0,1,{...QQ,delay:.05},t=>{e.reach=t,g(i(),e.open,e.reach)});let a=t.current;a&&y(0,0,{...$Q,delay:.1},e=>{a.style.translate=Math.abs(e)>.01?`0 ${(c*e).toFixed(2)}px`:``})};return y(1,0,{type:`spring`,visualDuration:.12,bounce:0},t=>{v||g(e===e$?void 0:a,t,t)}),y(0,1,YQ,e=>{m.head=e,b(),e>.85&&x()}),y(0,1,XQ,e=>{m.tail=e,b()}),()=>{for(let e of d.current)e.stop()}},[r,i,p,t,g,h]),(0,m.useEffect)(()=>{let r=e.current;if(!r||typeof ResizeObserver>`u`)return;let i=0,a=()=>{i=0,h(),d.current.some(e=>e.state===`running`)||g(u.current===e$?void 0:p(u.current??0))},o=new ResizeObserver(()=>{i||=requestAnimationFrame(a)});o.observe(r),t.current&&o.observe(t.current);let s=n.current?.element;return s&&o.observe(s),()=>{cancelAnimationFrame(i),o.disconnect()}},[e,t,n,p,g,h]),{track:o,ring:s,line:c,drop:l}}function n$({option:e,position:t,count:n,chosen:r,onExpand:i,panel:a,dim:o}){if(!e)return null;let{text:s,recommended:c}=UQ(e.label),l=_G(e);return(0,U.jsx)(`div`,{ref:a,"data-dim":o||void 0,"data-chosen":r||void 0,className:`q-panel min-w-0 rounded-2xl p-4 transition-opacity duration-300 data-[dim]:opacity-55`,children:(0,U.jsxs)(`div`,{"aria-live":`polite`,className:Y(`q-panel-body grid min-w-0 gap-4`,l?`grid-cols-[minmax(0,1fr)_minmax(0,1.25fr)]`:``),children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2.5 py-0.5`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`q-panel-number mt-px flex size-6 shrink-0 items-center justify-center rounded-md text-xs font-semibold tabular-nums`,children:t+1}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,U.jsxs)(`p`,{className:`text-2xs font-medium tracking-wide text-muted-foreground uppercase`,children:[`Option `,t+1,` of `,n]}),(0,U.jsxs)(`p`,{className:`text-base font-semibold break-words`,children:[s,c?(0,U.jsx)(`span`,{className:`q-recommended ms-2 inline-flex translate-y-[-1px] items-center rounded-md px-1.5 py-0.5 align-middle text-2xs font-medium`,children:`Recommended`}):null]})]}),r?(0,U.jsxs)(`span`,{className:`q-chosen inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs font-medium`,children:[(0,U.jsx)($p,{"aria-hidden":`true`,className:`size-3.5`}),`Chosen`]}):null]}),e.description?(0,U.jsx)(Mz,{text:e.description,className:`q-panel-text min-w-0 text-sm leading-relaxed`}):(0,U.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`No further detail.`})]}),l?(0,U.jsx)(qQ,{option:e,onExpand:i}):null]},t)})}function r$({primary:e,primaryLabel:t,disabled:n,submitting:r,onCancel:i,intent:a}){return(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(X,{type:`button`,variant:`ghost`,onClick:i,children:`Cancel`}),a?(0,U.jsx)(`p`,{role:`status`,"aria-live":`polite`,"data-empty":a.empty||void 0,className:`q-intent flex min-w-0 flex-1 items-center justify-end gap-1.5 text-sm`,children:(0,U.jsxs)(`span`,{className:`q-intent-text flex min-w-0 items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:a.lead}),a.empty?null:(0,U.jsx)(`span`,{className:`truncate font-medium`,children:a.text})]},`${a.lead}${a.text}`)}):null,(0,U.jsx)(X,{type:e,disabled:n||r,children:r?`Sending…`:t})]})}function i$(e){if(!e?.answer)return{lead:`Nothing chosen yet`,text:``,empty:!0};if(e.kind===`custom`){let t=e.answer.replace(/[*_`#>]/g,``).replace(/\s+/g,` `).trim();return{lead:`You answer:`,text:`“${t.length>80?`${t.slice(0,79)}…`:t}”`}}return{lead:`You choose:`,text:(e.selected??[e.answer]).map(e=>UQ(e).text).join(`, `)}}function a$(e,t,n,r){let i=e[r];if(!i)return;let a=n[r]?.trim();if(a)return{questionIndex:r,question:i.question,kind:`custom`,answer:a};let o=(t[r]??[]).map(e=>i.options[e]?.label).filter(e=>!!e);if(o.length!==0)return i.multiSelect?{questionIndex:r,question:i.question,kind:`multi`,answer:o.join(`, `),selected:o}:{questionIndex:r,question:i.question,kind:`option`,answer:o[0]??null}}function o$({questions:e,picks:t,own:n,index:r,onGo:i}){return e.length===1?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e[0]?.header}):(0,U.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:e.map((e,a)=>{let o=!!n[a]?.trim()||(t[a]?.length??0)>0;return(0,U.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-description":`When focused, press Enter or Space to open this question.`,type:`button`,onClick:()=>i(a),"aria-current":a===r,className:Y(`inline-flex min-h-8 min-w-0 items-center gap-1 rounded-lg border px-3 text-xs font-medium transition-colors`,a===r?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,U.jsxs)(`span`,{className:`min-w-0 break-words text-start`,children:[a+1,` `,e.header]}),o?(0,U.jsx)($p,{className:`size-3 shrink-0`,"aria-hidden":`true`}):null]},a)})})}function s$({questions:e,submitting:t,onAnswer:n,onCancel:r,expanded:i,onExpand:a,onSize:o}){let[s,c]=(0,m.useState)(0),[l,u]=(0,m.useState)(!1),d=i??l,f=e=>a?a(e):u(e),[p,h]=(0,m.useState)(0),g=(0,m.useRef)(0),_=(0,m.useRef)(!1),[v,y]=(0,m.useState)({}),[b,x]=(0,m.useState)({}),[S,C]=(0,m.useState)({}),[w,T]=(0,m.useState)(!1),[E,D]=(0,m.useState)(!1),O=(0,m.useRef)(null),[k,A]=(0,m.useState)({}),ee=(0,m.useRef)(void 0),j=(0,m.useRef)(null),M=(0,m.useRef)(null),te=(0,m.useRef)(null),N=e[s],P=v[s]??[],ne=b[s]??``,re=N?.options[k[s]??P[0]??0],ie=a$(e,v,b,s),ae=N?.multiSelect===!0,oe=Math.max(0,N?.options.indexOf(re)??0),se=w||ne.trim()!==``,ce=se?e$:oe,le=t$(M,te,O,ce,`${s}:${d}`,()=>D(!0));if((0,m.useEffect)(()=>{if(!E)return;let e=window.setTimeout(()=>D(!1),700);return()=>window.clearTimeout(e)},[E]),(0,m.useEffect)(()=>o?.(zQ(N)),[N,o]),(0,m.useEffect)(()=>{let e=j.current;e&&(e.querySelector(`[data-option="${v[s]?.[0]??0}"]`)??e.querySelector(`[data-nav]`))?.focus()},[s]),(0,m.useEffect)(()=>{let e=_.current&&!d;_.current=d,e&&(A(e=>({...e,[s]:g.current})),j.current?.querySelector(`[data-option="${g.current}"]`)?.focus())},[d]),!N)return null;let F=N.options.some(_G);function ue(e){h(Math.max(0,e)),g.current=Math.max(0,e),f(!0)}function de(e){g.current=e,f(!1)}if(d&&F)return(0,U.jsx)(yG,{options:N.options,start:p,title:N.header||N.question,picked:P,multi:ae,onChoose:e=>{fe(e),ae||de(e)},onClose:de,onIndex:e=>{g.current=e}},s);function fe(e){let t=ae?P.includes(e)?P.filter(t=>t!==e):[...P,e]:[e];y({...v,[s]:t}),ae||(x({...b,[s]:``}),C({...S,[s]:``})),A({...k,[s]:e})}function I(e){let t=e instanceof HTMLInputElement&&e.dataset.option!==void 0?Number(e.dataset.option):-1;t>=0&&!ae&&fe(t)}function L(t,r){if(a$(e,t,r,s)){if(s<e.length-1){c(s+1);return}n({answers:e.map((n,i)=>a$(e,t,r,i)).filter(e=>!!e),cancelled:!1})}}function pe(e){e.preventDefault(),t||L(v,b)}function me(t){t>=0&&t<e.length&&c(t)}function he(e){let n=e.target,r=j.current;if(!r||e.altKey)return;if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)){e.preventDefault(),t||L(v,b);return}if(aR(n))return;let i=oR(e.key);if(i||e.key===`Home`||e.key===`End`){e.preventDefault(),iR(r,n,i||(e.key===`Home`?`first`:`last`)),I(document.activeElement);return}let a=sR(e.key);if(a&&!(n instanceof HTMLButtonElement)){e.preventDefault(),me(s+a);return}let o=n instanceof HTMLInputElement&&n.dataset.option!==void 0?Number(n.dataset.option):-1;if(e.key===`Enter`&&o>=0){if(e.preventDefault(),ae)P.length>0&&P.includes(o)?L(v,b):fe(o);else{let e={...v,[s]:[o]},t={...b,[s]:``};y(e),x(t),C({...S,[s]:``}),L(e,t)}return}if(e.key===` `&&o>=0){e.preventDefault(),fe(o);return}let c=Number(e.key);if(Number.isInteger(c)&&c>=1&&c<=N.options.length){e.preventDefault(),fe(c-1),r.querySelector(`[data-option="${c-1}"]`)?.focus();return}e.key.toLowerCase()===`e`&&F&&!e.ctrlKey&&!e.metaKey&&(e.preventDefault(),ue(o>=0?o:k[s]??P[0]??0))}return(0,U.jsxs)(`form`,{ref:j,className:`flex min-w-0 flex-col gap-3`,onSubmit:pe,onKeyDown:he,children:[(0,U.jsx)(o$,{questions:e,picks:v,own:b,index:s,onGo:c}),(0,U.jsxs)(`div`,{className:`text-center`,children:[(0,U.jsx)(`p`,{className:`text-2xs font-medium tracking-wide text-muted-foreground uppercase`,children:e.length>1?`Question ${s+1} of ${e.length}`:`Question`}),(0,U.jsx)(Mz,{text:N.question,className:`mt-1 text-base font-medium`})]}),(0,U.jsxs)(`div`,{className:`relative grid min-w-0 grid-cols-[2.25rem_minmax(0,1fr)] gap-x-3`,children:[(0,U.jsxs)(`div`,{ref:M,role:ae?`group`:`radiogroup`,"aria-label":`Options`,className:`q-rail relative flex min-w-0 flex-col justify-evenly py-2`,onPointerDown:e=>{if(!w)return;let t=e.target.closest(`.q-dot`)?.querySelector(`[data-option]`)?.getAttribute(`data-option`);ee.current=t==null?void 0:Number(t)},children:[(0,U.jsx)(`span`,{ref:le.track,"aria-hidden":`true`,className:`q-rail-line pointer-events-none absolute top-0 left-1/2 h-0 -translate-x-1/2`}),(0,U.jsx)(`span`,{ref:le.drop,"aria-hidden":`true`,className:`q-drop pointer-events-none absolute top-0 left-1/2 w-[3px] -translate-x-1/2 rounded-full opacity-0`}),(0,U.jsx)(`span`,{ref:le.ring,"aria-hidden":`true`,className:`q-ring pointer-events-none absolute top-0 left-1/2 z-20 size-7 rounded-full opacity-0`}),(0,U.jsx)(`span`,{ref:le.line,"aria-hidden":`true`,className:`q-line pointer-events-none absolute top-0 left-[calc(50%+0.875rem)] z-10 h-px w-[calc(50%-0.875rem+0.75rem)] origin-left opacity-0`}),N.options.map((e,t)=>(0,U.jsx)(JQ,{option:e,index:t,multi:ae,name:`question-${s}`,selected:P.includes(t),active:ce===t,onToggle:()=>fe(t),onFocusOption:()=>A({...k,[s]:t})},t))]}),(0,U.jsx)(n$,{panel:te,option:re,position:oe,count:N.options.length,chosen:!se&&P.includes(oe),dim:se,onExpand:()=>ue(oe)})]}),(0,U.jsx)(`div`,{className:`q-own-wrap mx-auto w-full`,children:(0,U.jsx)(RQ,{ref:O,html:S[s]??``,placeholder:`Type something else…`,label:`Your own answer`,landed:E,onChange:(e,t)=>{x(t=>({...t,[s]:e})),C(e=>({...e,[s]:t})),e&&y(e=>({...e,[s]:[]}))},onFocusChange:(e,t)=>{if(!e){let e=t?.closest?.(`[data-option]`)?.getAttribute(`data-option`),n=e==null?ee.current??N.options.length-1:Number(e);A(e=>({...e,[s]:n}))}ee.current=void 0,T(e)},onSubmit:()=>{t||L(v,b)},onUp:()=>{let e=j.current;e&&iR(e,O.current?.element??null,-1)}},s)}),(0,U.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{children:ae?`Pick several`:`Pick one`}),(0,U.jsx)(KD,{chord:`↑↓`,children:`move`}),(0,U.jsx)(KD,{chord:ae?`Space`:`Enter`,children:ae?`pick`:`choose`}),ae?(0,U.jsx)(KD,{chord:`Enter`,children:`next`}):null,e.length>1?(0,U.jsx)(KD,{chord:`←→`,children:`question`}):null,F?(0,U.jsx)(KD,{chord:`E`,children:`expand mockups`}):null,(0,U.jsx)(KD,{chord:`Esc`,children:`later`})]}),(0,U.jsx)(r$,{primary:`submit`,primaryLabel:s<e.length-1?`Next`:`Answer`,disabled:!ie,submitting:t,onCancel:r,intent:i$(ie)})]})}function c$(e,t,n){let r=e.currentTarget,i=e.target;if(e.altKey||aR(i))return;let a=oR(e.key);if(a){e.preventDefault(),iR(r,i,a);return}let o=i instanceof HTMLInputElement&&i.dataset.option!==void 0?Number(i.dataset.option):-1;if((e.key===`Enter`||e.key===` `)&&o>=0){e.preventDefault(),n(o,e.key===`Enter`);return}let s=Number(e.key);Number.isInteger(s)&&s>=1&&s<=t&&(e.preventDefault(),n(s-1,!1),r.querySelector(`[data-option="${s-1}"]`)?.focus())}function l$({view:e,submitting:t,onAnswer:n,onCancel:r}){let[i,a]=(0,m.useState)(``),o=(0,m.useRef)(null);return(0,m.useEffect)(()=>{o.current?.querySelector(`[data-nav]`)?.focus()},[]),(0,U.jsxs)(`form`,{ref:o,className:`flex min-w-0 flex-col gap-3`,onSubmit:e=>{e.preventDefault(),i&&n(i)},onKeyDown:r=>c$(r,e.options.length,(r,i)=>{let o=e.options[r];o!==void 0&&(a(o),i&&!t&&n(o))}),children:[(0,U.jsx)(Mz,{text:e.title,className:`text-base`}),(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.options.map((e,t)=>(0,U.jsx)(KQ,{option:{label:e},index:t,multi:!1,name:`choice`,selected:i===e,onToggle:()=>a(e)},e))}),(0,U.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,U.jsx)(KD,{chord:`↑↓`,children:`move`}),(0,U.jsx)(KD,{chord:`Enter`,children:`choose`}),(0,U.jsx)(KD,{chord:`Esc`,children:`later`})]}),(0,U.jsx)(r$,{primary:`submit`,primaryLabel:`Choose`,disabled:!i,submitting:t,onCancel:r})]})}function u$({view:e,submitting:t,onAnswer:n}){let r=(0,m.useRef)(null);(0,m.useEffect)(()=>r.current?.focus(),[]);function i(e){if(e.altKey||e.ctrlKey||e.metaKey||t)return;let r=e.key.toLowerCase();r===`y`?n(!0):r===`n`&&n(!1)}return(0,U.jsxs)(`div`,{ref:r,tabIndex:-1,"data-autofocus":``,onKeyDown:i,className:`flex min-w-0 flex-col gap-3 outline-none`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(Mz,{text:e.question,className:`text-base`}),e.detail?(0,U.jsx)(Mz,{text:e.detail,className:`mt-1 text-muted-foreground`}):null]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`p`,{className:`flex items-center gap-x-4 text-xs text-muted-foreground`,children:[(0,U.jsx)(KD,{chord:`Y`,children:`yes`}),(0,U.jsx)(KD,{chord:`N`,children:`no`}),(0,U.jsx)(KD,{chord:`Esc`,children:`later`})]}),(0,U.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(X,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n(!1),children:`No`}),(0,U.jsx)(X,{type:`button`,disabled:t,onClick:()=>n(!0),children:t?`Sending…`:`Yes`})]})]})]})}function d$({view:e,submitting:t,onAnswer:n,onCancel:r}){let[i,a]=(0,m.useState)(``);return(0,U.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-3`,onSubmit:e=>{e.preventDefault(),i.trim()&&n(i.trim())},children:[(0,U.jsx)(Mz,{text:e.question,className:`text-base`}),(0,U.jsx)(nV,{autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},value:i,onChange:e=>a(e.target.value),placeholder:e.placeholder??HQ,"aria-label":e.question,rows:3,className:`min-h-9 resize-none text-sm`}),(0,U.jsxs)(`p`,{className:`flex items-center gap-x-4 text-xs text-muted-foreground`,children:[(0,U.jsx)(KD,{chord:`Enter`,children:`answer`}),(0,U.jsx)(KD,{chord:`Shift+Enter`,children:`new line`}),(0,U.jsx)(KD,{chord:`Esc`,children:`later`})]}),(0,U.jsx)(r$,{primary:`submit`,primaryLabel:`Answer`,disabled:!i.trim(),submitting:t,onCancel:r})]})}function f$({dialog:e,submitting:t,onAnswer:n}){let[r,i]=(0,m.useState)(e.method===`editor`?e.prefill??``:``),[a,o]=(0,m.useState)(``),s=e.options??[],c=e.method===`select`?a!==``:r.trim()!==``,l=(0,m.useRef)(null);(0,m.useEffect)(()=>{l.current?.querySelector(`[data-nav], textarea`)?.focus()},[]);function u(t){t.preventDefault(),e.method===`select`?n({value:a}):e.method===`confirm`?n({confirmed:!0}):(e.method===`input`||e.method===`editor`)&&n({value:r.trim()})}return(0,U.jsxs)(`form`,{ref:l,className:`flex min-w-0 flex-col gap-3`,onSubmit:u,onKeyDown:r=>{e.method===`select`&&c$(r,s.length,(e,r)=>{let i=s[e];i!==void 0&&(o(i),r&&!t&&n({value:i}))})},children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.title}),e.message?(0,U.jsx)(Mz,{text:e.message,className:`mt-1 text-base`}):null]}),e.method===`select`?(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.map((e,t)=>(0,U.jsx)(KQ,{option:{label:e},index:t,multi:!1,name:`dialog`,selected:a===e,onToggle:()=>o(e)},e))}):null,e.method===`input`||e.method===`editor`?(0,U.jsx)(nV,{value:r,onChange:e=>i(e.target.value),placeholder:e.placeholder??HQ,"aria-label":e.title,rows:e.method===`editor`?4:2,className:`min-h-9 resize-none text-sm`}):null,(0,U.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,U.jsx)(X,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n({cancelled:!0}),children:`Cancel`}),e.method===`confirm`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(X,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n({confirmed:!1}),children:`No`}),(0,U.jsx)(X,{type:`button`,disabled:t,onClick:()=>n({confirmed:!0}),children:t?`Sending…`:`Yes`})]}):(0,U.jsx)(X,{type:`submit`,disabled:!c||t,children:t?`Sending…`:`Answer`})]})]})}function p$(e){let{view:t}=e;return t.kind===`questionnaire`?(0,U.jsx)(s$,{questions:t.questions,submitting:e.submitting,onAnswer:e.onAnswer,onCancel:e.onCancel,onSize:e.onSize,...e.onExpand?{expanded:e.expanded??!1,onExpand:e.onExpand}:{}}):t.kind===`choose`?(0,U.jsx)(l$,{...e,view:t}):t.kind===`confirm`?(0,U.jsx)(u$,{...e,view:t}):t.kind===`text`?(0,U.jsx)(d$,{...e,view:t}):(0,U.jsx)(f$,{...e,dialog:t.dialog})}function m$(e){return typeof e==`object`&&e?e:{}}function h$(e){return typeof e==`string`?e.trim():``}function g$(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function _$(e){let t=m$(e),n=h$(t.label);if(!n)return;let r=h$(t.description),i=h$(t.preview),a=h$(t.image),o=cG(t.htmlPreview);return{label:n,...r?{description:r}:{},...i?{preview:i}:{},...a?{image:a}:{},...o?{htmlPreview:o}:{}}}function v$(e){let t=m$(e),n=h$(t.question);if(!n)return;let r=(Array.isArray(t.options)?t.options:[]).map(_$).filter(e=>!!e);return{question:n,header:h$(t.header)||`Question`,options:r,...t.multiSelect===!0?{multiSelect:!0}:{}}}function y$(e){let t=m$(e),n=h$(t.method);if(n!==`select`&&n!==`confirm`&&n!==`input`&&n!==`editor`)return;let r=h$(t.message),i=g$(t.options),a=h$(t.placeholder),o=h$(t.prefill);return{id:h$(t.id),method:n,title:h$(t.title)||`Answer`,...r?{message:r}:{},...i.length>0?{options:i}:{},...a?{placeholder:a}:{},...o?{prefill:o}:{}}}function b$(e){let t=(Array.isArray(e.questions)?e.questions:[]).map(v$).filter(e=>!!e);return t.length>0?{kind:`questionnaire`,questions:t}:void 0}function x$(e){return{kind:`choose`,title:h$(e.title)||`Choose an option`,options:g$(e.options)}}function S$(e){let t=h$(e.question)||h$(e.title)||`Continue?`,n=h$(e.detail)||h$(e.message);return{kind:`confirm`,question:t,...n?{detail:n}:{}}}function C$(e){let t=h$(e.question)||h$(e.title)||`Type an answer`,n=h$(e.placeholder);return{kind:`text`,question:t,...n?{placeholder:n}:{}}}function w$(e){let t=m$(e.payload);if(e.kind===`questionnaire`)return b$(t);if(e.kind===`choose`)return x$(t);if(e.kind===`confirm`)return S$(t);if(e.kind===`text`)return C$(t);let n=y$(t.dialog);return n?{kind:`sessionDialog`,dialog:n}:void 0}var T$={md:`max-w-3xl`,lg:`max-w-4xl max-h-[min(88svh,52rem)]`,xl:`max-w-5xl max-h-[min(90svh,58rem)]`};function E$({submitting:e,onKeep:t,onLeave:n}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,role:`alert`,children:[(0,U.jsx)(`p`,{className:`text-sm`,children:`Leave without answering? The oracle will not guess for you.`}),(0,U.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,U.jsx)(X,{type:`button`,variant:`outline`,onClick:t,children:`Keep answering`}),(0,U.jsx)(X,{type:`button`,disabled:e,onClick:n,children:e?`Leaving…`:`Leave`})]})]})}function D$({count:e,onOpen:t}){return(0,U.jsxs)(X,{type:`button`,variant:`soft`,onClick:t,"aria-label":`${e} question${e===1?``:`s`} waiting — open`,className:`gap-1.5 text-warning`,children:[(0,U.jsx)(_m,{"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`tabular-nums`,children:e}),(0,U.jsx)(`span`,{children:`waiting`})]})}function O$({prompts:e,answer:t,dismiss:n,minimized:r,onMinimize:i}){let[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(!1),d=(0,m.useRef)(null),[f,p]=(0,m.useState)(`md`),h=e.length,g=e[0],_=g?w$(g):void 0,v=h>0&&!r,y=tO(v,eO.question);(0,m.useEffect)(()=>{h===0&&(o(!1),i(!1))},[h,i]);let b=g?.id;(0,m.useEffect)(()=>u(!1),[b]);async function x(e,t){c(!0);try{await e,o(!1)}catch(e){e instanceof be&&e.code===`question_withdrawn`?W(FR):W.error(e instanceof Error?e.message:t)}finally{c(!1)}}let S=g?.from?`${g.from} asks`:`A question`;return(0,U.jsx)(qD,{open:v&&y&&!!g,label:`Question from the lobby`,dismissOnBackdrop:!1,onOpenChange:e=>{e||(l?u(!1):a?o(!1):i(!0))},className:Y(`transition-[max-width] duration-300 ease-snap`,l?`h-[min(92svh,60rem)] max-h-[min(92svh,60rem)] max-w-7xl`:T$[_?.kind===`questionnaire`?f:`md`]),children:g?(0,U.jsxs)(`section`,{"aria-label":`Question from the lobby`,className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,U.jsxs)(`header`,{className:Y(`flex items-center gap-3 px-4 pt-4 pb-2`,l&&`hidden`),children:[(0,U.jsxs)(`p`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-muted-foreground first-letter:uppercase`,children:[S,h>1?` · 1 of ${h}`:``]}),(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Later: put the question away`,title:`Later · Esc`,onClick:()=>i(!0),children:(0,U.jsx)(s_,{"aria-hidden":`true`})})]}),(0,U.jsx)(`div`,{ref:d,className:l?`flex min-h-0 min-w-0 flex-1 flex-col`:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain px-4 pb-4`,children:_?a?(0,U.jsx)(E$,{submitting:s,onKeep:()=>o(!1),onLeave:()=>void x(n(g.id),`Could not leave the question`)}):(0,U.jsx)(p$,{view:_,submitting:s,onAnswer:e=>void x(t(g.id,e),`Could not send the answer`),onCancel:()=>o(!0),expanded:l,onExpand:u,onSize:p},g.id):(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:` text-sm text-muted-foreground`,children:`This question cannot be shown here.`}),(0,U.jsx)(X,{type:`button`,disabled:s,onClick:()=>void x(n(g.id),`Could not dismiss the question`),children:`Dismiss`})]})}),l?null:(0,U.jsx)(Bv,{target:d})]}):null})}var k$=2;function A$(e){let t=globalThis.EventSource;if(!t)throw Error(`EventSource is not available in this environment`);return new t(e)}function j$(e){try{return JSON.parse(e)}catch{return}}function M$(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 N$(e,t=A$){let n=t(I(`/api/events`));return e.onConnection?.(`connecting`),n.onopen=()=>e.onConnection?.(`live`),n.onerror=()=>e.onConnection?.(n.readyState===k$?`offline`:`connecting`),n.onmessage=t=>{let n=j$(t.data);n&&M$(n,e)},()=>n.close()}var P$=2e3,F$=()=>R(`projects.list`,{});async function I$(){let e;try{e=fe()}catch{return}if(e&&!ve(e))try{_e((await F$()).projects)}catch{}}function L$(){let e=(0,m.useRef)(void 0),t=(0,m.useRef)(void 0),n=(0,m.useCallback)(()=>{clearTimeout(t.current),e.current?.();try{fe()}catch{F.onStatus({connection:`offline`});return}e.current=N$({onHello:e=>{F.onHello(e),I$()},onChanged:(e,t)=>F.onChanged(e,t),onFeed:e=>F.onFeedDelta(e),onReply:e=>F.onReplyDelta(e),onNotice:(e,t)=>W[t](e),onConnection:e=>{F.onStatus({connection:e}),e===`offline`&&(clearTimeout(t.current),t.current=setTimeout(()=>{ye(F$).catch(()=>!1).finally(n)},P$))}})},[]);return(0,m.useEffect)(()=>(n(),()=>{clearTimeout(t.current),e.current?.()}),[n]),n}var R$=`bot-lobby.recoveredAt`,z$;function B$(e,t=V$()){try{z$===void 0&&(z$=Number(t?.getItem(R$)??0))}catch{z$??=0}if(z$!==void 0&&e<=z$)return!1;z$=e;try{t?.setItem(R$,String(e))}catch{}return!0}function V$(){try{return globalThis.sessionStorage}catch{return}}function H$(e){let t=e?.recovered?.at,n=e?.recovered?.text;(0,m.useEffect)(()=>{t!==void 0&&n&&B$(t)&&W.success(n)},[t,n])}function U$(){let e=oO(`prompts`),t=(0,m.useCallback)(async(e,t)=>{await R(`prompts.answer`,{id:e,answer:t})},[]),n=(0,m.useCallback)(async e=>{await R(`prompts.dismiss`,{id:e})},[]);return{prompts:e.data?.prompts??[],loading:e.loading,error:e.error,answer:t,dismiss:n}}function W$(e,t,n,r,i){e===`search`?(document.querySelector(`#main input[type='search']`)??document.getElementById(`composer-text`))?.focus():e===`help`?n():e===`settings`?hB(`#/settings`):e===`thinking`?Vz(`lobby.thinking`):e===`sidebar`?i():e===`terminal`?IX():e===`code`?sz():e===`activity`?t.kind===`tab`&&t.tab===`lobby`?Vz(Wz):hB(mB(`lobby`)):e===`nextTab`?r(1):e===`prevTab`?r(-1):e===`savePlan`&&t.kind===`tab`&&t.tab===`plan`&&mp(`planner.save`,{})}var G$=`toolbar-button inline-flex size-8 shrink-0 items-center justify-center rounded-lg border text-foreground transition-[background-color,border-color,scale] duration-150 ease-snap outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:scale-[0.97] motion-reduce:active:scale-100`,K$=`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-[background-color,color,scale] duration-150 ease-snap outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:scale-[0.97] aria-pressed:bg-accent aria-pressed:text-foreground motion-reduce:active:scale-100`,q$=2500;function J$(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),q$);return()=>clearTimeout(t)},[e]),e===`offline`||e===`connecting`&&t}function Y$({connection:e,onRetry:t}){return J$(e)?(0,U.jsx)(EB,{onRetry:t}):null}var X$={tick:0,route:0,focus:0};window.addEventListener(`hashchange`,()=>{X$.route=++X$.tick}),document.addEventListener(`focusin`,()=>{X$.focus=++X$.tick});var Z$=()=>X$.focus>X$.route;function Q$(e){return e.kind===`tab`?e.tab:e.kind}function $$(){let e=gB(),t=oO(`status`),n=oO(`lobby`),{prompts:r,answer:i,dismiss:a}=U$(),{connection:o,signedOut:s}=aO(),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=(0,m.useRef)(null),p=L$();SH();let h=t.data;H$(h);let g=!!h&&!s;(0,m.useEffect)(()=>{g&&Le()},[g]);let _=h?.tabs??[],v=h?.keys??[],y=e.kind===`tab`?e.tab:void 0,b=(0,m.useCallback)(e=>hB(mB(e)),[]),x=(0,U.jsx)(YZ,{tabs:_,activeId:y,onSelect:b}),S=(0,m.useCallback)(e=>{if(_.length===0)return;let t=Math.max(0,_.findIndex(e=>e.id===y)),n=_[(t+e+_.length)%_.length];n&&hB(mB(n.id))},[_,y]),C=(0,m.useCallback)(()=>l(e=>!e),[]),w=cY();sO(Nz);let[T]=Hz(JY),E=(0,m.useCallback)(()=>Vz(JY),[]),D=(0,m.useCallback)(t=>{(t!==`thinking`&&t!==`activity`||h?.panels?.[t]!==!1)&&W$(t,pB(window.location.hash)??e,C,S,E)},[e,C,S,E,h?.panels]),O=(0,m.useCallback)(()=>{let e=document.activeElement;return!e||e===document.body||f.current?.contains(e)===!0||e.closest(`.thinking-bubble, .terminal-pop`)?!0:e.closest(`[data-state='closed']`)!==null},[]);EJ({enabled:!!h,keys:v,tabs:_,insideApp:O,onAction:D,onTab:b});let k=(0,m.useCallback)(()=>F.onHello({}),[]),A=e.kind===`tab`?e.tab:e.kind,ee=!!h;(0,m.useEffect)(()=>{if(!ee)return;let e=hR.active&&hR.to===A;if(hR.active=!1,hR.to=void 0,e)return;let t=requestAnimationFrame(()=>{if(Z$()||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)},[A,ee]);let j=Object.fromEntries(v.map(e=>[e.action,e.label])),M=!!h&&!s,te=M?(0,U.jsx)(bX,{hint:j.sidebar}):null,N=(0,U.jsx)(WY,{connection:o,projects:w,lead:te,tabs:x,extra:u&&r.length>0?(0,U.jsx)(D$,{count:r.length,onOpen:()=>d(!1)}):null,tools:M?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(aZ,{hint:j.code,className:K$}),(0,U.jsx)(ZX,{hint:j.terminal,className:K$})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(VJ,{className:G$,side:`bottom`}),(0,U.jsx)(BJ,{className:G$,side:`bottom`})]})});return s||!h?(0,U.jsxs)(`div`,{ref:f,className:`fixed inset-0 flex flex-col`,children:[N,(0,U.jsx)(`main`,{className:`surface flex min-h-0 flex-1 flex-col overflow-y-auto`,children:s?(0,U.jsx)(gZ,{}):t.error?(0,U.jsx)(TB,{message:t.error,onRetry:k}):(0,U.jsx)(wB,{})})]}):(0,U.jsxs)(`div`,{ref:f,className:`app-chrome fixed inset-0 flex`,"data-sidebar":T?`folded`:`open`,children:[(0,U.jsx)(yX,{route:e,keys:j,onHelp:C}),(0,U.jsxs)(`div`,{className:`relative flex min-w-0 flex-1 flex-col`,children:[N,(0,U.jsxs)(`div`,{className:`app-page relative flex min-h-0 flex-1 flex-col`,children:[(0,U.jsx)(Y$,{connection:o,onRetry:p}),(0,U.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,U.jsx)(`main`,{id:`main`,tabIndex:-1,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||aR(e.target)||e.target.closest(`[role='dialog'], [role='menu'], [role='listbox']`)||mR()&&e.preventDefault()},role:y?`tabpanel`:void 0,"aria-labelledby":y?`tab-${y}`:void 0,className:`surface flex min-h-0 flex-1 flex-col overflow-y-auto outline-none`,children:(0,U.jsx)(Xf.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.18,ease:[.2,.8,.2,1]},className:`flex min-h-0 flex-1 flex-col`,children:pJ(e)},Q$(e))}),(0,U.jsx)(zY,{route:e,projects:w})]}),(0,U.jsx)(eZ,{toggleKey:j.terminal??"Ctrl+`"})]})]}),(0,U.jsx)(AQ,{status:h,lobby:n.data}),(0,U.jsx)(mZ,{codeKey:v.find(e=>e.action===`code`)?.key}),(0,U.jsx)(O$,{prompts:r,answer:i,dismiss:a,minimized:u,onMinimize:d}),(0,U.jsx)(LJ,{open:c,onOpenChange:l,keys:v,tabs:_})]})}async function e1(e){switch(e){case`status`:return R(`status.get`,{});case`lobby`:return R(`lobby.snapshot`,{});case`prompts`:return R(`prompts.list`,{});default:return}}var t1=[`status`,`lobby`,`prompts`];function n1(){let[e,t]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{let e=!0;return(async()=>{await Ce(),e&&(F.markUsed(t1,e1),t(!0))})(),()=>{e=!1}},[]),e}function r1(){return n1()?(0,U.jsx)($$,{}):(0,U.jsx)(`div`,{className:`fixed inset-0 flex`,children:(0,U.jsx)(wB,{})})}var i1={info:ah,success:dm,warning:qg,error:xm},a1={info:`Note:`,success:`Done:`,warning:`Warning:`,error:`Error:`},o1={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-destructive`};function s1(){let{item:e,waiting:t}=fp(),n=rO(),r=e&&!n;return(0,m.useEffect)(()=>{if(!e||n)return;let r=window.setTimeout(()=>up(e.id),t>0?Math.min(e.duration,1600):e.duration);return()=>window.clearTimeout(r)},[e,n,t]),(0,U.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`pointer-events-none fixed z-40 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,U.jsx)(ju,{mode:`wait`,children:r?(0,U.jsxs)(Xf.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,U.jsx)(c1,{kind:e.kind}),(0,U.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,U.jsxs)(`span`,{className:`sr-only`,children:[a1[e.kind],` `]}),e.message]}),e.action?(0,U.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(),up(e.id)},children:e.action.label}):null]},e.id):null})})}function c1({kind:e}){let t=i1[e];return(0,U.jsx)(t,{"aria-hidden":`true`,className:Y(`size-4 shrink-0`,o1[e])})}(0,np.createRoot)(document.getElementById(`root`)).render((0,U.jsx)(m.StrictMode,{children:(0,U.jsx)(tU,{children:(0,U.jsx)(Ru,{reducedMotion:`user`,children:(0,U.jsxs)($L,{children:[(0,U.jsx)(r1,{}),(0,U.jsx)(s1,{})]})})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{updateViaCache:`none`}).catch(()=>void 0)});export{I as i,yJ as n,R as r,qX as t};
|
|
112
|
+
`).trim()}function PQ(e){let t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return!1;let n=document.createRange();return n.selectNodeContents(e),n.setEnd(t.getRangeAt(0).startContainer,t.getRangeAt(0).startOffset),n.toString().replace(MQ,``)===``}function FQ(e){let t=window.getSelection()?.anchorNode,n=t instanceof HTMLElement?t:t?.parentElement;return!!(n?.closest(`li`)&&e.contains(n))}function IQ(e){return e.replace(/[&<>"]/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`})[e]??e)}function LQ(e){if(e!==`code`){document.execCommand(e);return}let t=window.getSelection()?.toString()??``;document.execCommand(`insertHTML`,!1,t?`<code>${IQ(t)}</code>`:`<code></code>`)}var RQ=[{format:`bold`,label:`Bold`,keys:`Ctrl+B`,icon:Gp},{format:`italic`,label:`Italic`,keys:`Ctrl+I`,icon:sh},{format:`code`,label:`Code`,keys:`Ctrl+E`,icon:Dm},{format:`insertUnorderedList`,label:`Bulleted list`,icon:yh},{format:`insertOrderedList`,label:`Numbered list`,icon:_h}],zQ=(0,m.forwardRef)(function({html:e,placeholder:t,label:n,landed:r,onChange:i,onFocusChange:a,onSubmit:o,onUp:s},c){let l=(0,m.useRef)(null),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(!e),[h,g]=(0,m.useState)({});(0,m.useImperativeHandle)(c,()=>({element:l.current}),[]),(0,m.useEffect)(()=>{let t=l.current;t&&(e===``&&t.innerHTML!==``?(t.innerHTML=``,p(!0)):e&&t.innerHTML===``&&(t.innerHTML=e,p(!1)))},[e]);let _=(0,m.useCallback)(()=>{let e=l.current;if(!e)return;let t=NQ(e);p(t===``&&!e.querySelector(`li`)),i(t,t?e.innerHTML:``)},[i]);(0,m.useEffect)(()=>{if(!u)return;let e=()=>g(Object.fromEntries(RQ.filter(e=>e.format!==`code`).map(e=>[e.format,document.queryCommandState(e.format)])));return document.addEventListener(`selectionchange`,e),e(),()=>document.removeEventListener(`selectionchange`,e)},[u]);function v(e){l.current?.focus(),LQ(e),_()}function y(e){let t=l.current;if(!t)return;let n=e.ctrlKey||e.metaKey;if(n&&!e.altKey&&[`b`,`i`,`e`].includes(e.key.toLowerCase())){e.preventDefault(),e.stopPropagation(),v(e.key.toLowerCase()===`b`?`bold`:e.key.toLowerCase()===`i`?`italic`:`code`);return}if(e.key===`Enter`&&!e.shiftKey&&!n&&!e.nativeEvent.isComposing){if(FQ(t))return;e.preventDefault(),o();return}e.key===`ArrowUp`&&PQ(t)&&(e.preventDefault(),s())}return(0,U.jsxs)(`div`,{"data-own":``,"data-open":u||!f||void 0,"data-landed":r||void 0,className:`q-own group/own relative flex w-full min-w-0 flex-col overflow-hidden border`,children:[(0,U.jsx)(`div`,{ref:l,role:`textbox`,"aria-multiline":`true`,"aria-label":n,"aria-placeholder":t,contentEditable:!0,suppressContentEditableWarning:!0,"data-nav":``,"data-empty":f||void 0,"data-placeholder":t,tabIndex:0,onInput:_,onKeyDown:y,onPaste:e=>{e.preventDefault(),document.execCommand(`insertText`,!1,e.clipboardData.getData(`text/plain`))},onFocus:()=>{d(!0),a(!0)},onBlur:e=>{d(!1),a(!1,e.relatedTarget)},className:`q-own-text min-h-9 w-full min-w-0 px-4 py-2 text-sm break-words outline-none [&_code]:rounded [&_code]:bg-muted [&_code]:px-1 [&_code]:font-mono [&_code]:text-[0.8125rem] [&_ol]:list-decimal [&_ol]:ps-5 [&_ul]:list-disc [&_ul]:ps-5`}),(0,U.jsxs)(`div`,{role:`toolbar`,"aria-label":`Formatting`,"aria-hidden":!u,className:Y(`q-own-bar flex items-center gap-0.5 px-2 pb-1.5`,!u&&`pointer-events-none`),children:[RQ.map(({format:e,label:t,keys:n,icon:r})=>(0,U.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":t,"aria-pressed":h[e]??!1,title:n?`${t} · ${n}`:t,onMouseDown:e=>e.preventDefault(),onClick:()=>v(e),className:`inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground aria-pressed:bg-primary/12 aria-pressed:text-primary`,children:(0,U.jsx)(r,{"aria-hidden":`true`,className:`size-3.5`})},e)),(0,U.jsx)(`span`,{className:`ms-auto pe-1 text-2xs text-muted-foreground`,children:`Enter answers · Shift+Enter new line`})]})]})});function BQ(e){return e?e.options.some(gG)?`xl`:e.question.length+e.options.reduce((e,t)=>e+t.label.length+(t.description?.length??0),0)>700||e.options.length>6?`lg`:`md`:`md`}var VQ=/\s*\(recommended\)\s*$/i,HQ=1200,UQ=`Type something.`;function WQ(e){return{text:e.replace(VQ,``),recommended:VQ.test(e)}}function GQ({label:e}){let{text:t,recommended:n}=WQ(e);return(0,U.jsxs)(`span`,{className:`leading-snug break-words`,children:[t,n?(0,U.jsx)(`span`,{className:`ms-1 font-medium text-primary`,children:`(Recommended)`}):null]})}function KQ({multi:e,on:t}){return(0,U.jsxs)(`span`,{"aria-hidden":`true`,className:Y(`relative mt-0.5 flex size-4 shrink-0 items-center justify-center border`,e?`rounded-lg`:`rounded-full`,t?`border-primary bg-primary text-primary-foreground`:`border-input`),children:[t?(0,U.jsx)($p,{className:Y(e?`size-3`:`hidden`)}):null,t&&!e?(0,U.jsx)(`span`,{className:`size-2 rounded-full bg-primary-foreground`}):null]})}function qQ({option:e,index:t,multi:n,name:r,selected:i,onToggle:a,onFocusOption:o}){return(0,U.jsxs)(`div`,{className:`grid gap-1`,children:[(0,U.jsxs)(`label`,{className:Y(`flex min-h-9 cursor-pointer items-start gap-2.5 rounded-lg border px-3 py-2 text-start text-sm transition-[background-color,border-color,transform] duration-150 ease-snap active:scale-[0.99]`,i?`border-primary/50 bg-accent`:`border-input bg-background hover:bg-accent/60`,`has-[:focus-visible]:border-ring has-[:focus-visible]:ring-3 has-[:focus-visible]:ring-ring/30`),children:[(0,U.jsx)(`input`,{type:n?`checkbox`:`radio`,name:r,"data-nav":``,"data-option":t,className:`sr-only`,checked:i,onChange:a,onFocus:o}),(0,U.jsx)(KQ,{multi:n,on:i}),(0,U.jsx)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:(0,U.jsxs)(`span`,{className:`flex gap-1.5`,children:[(0,U.jsxs)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,U.jsx)(GQ,{label:e.label})]})})]}),e.description?(0,U.jsx)(Mz,{text:e.description,className:`px-3 text-muted-foreground`}):null]})}function JQ({option:e,onExpand:t}){return!e||!gG(e)?null:(0,U.jsxs)(`div`,{className:`card-flat flex min-w-0 max-w-full flex-col gap-2 rounded-lg border p-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`p`,{className:`min-w-0 truncate text-xs font-medium text-muted-foreground`,children:[`Preview · `,WQ(e.label).text]}),(0,U.jsxs)(X,{type:`button`,variant:`ghost`,size:`xs`,onClick:t,"aria-keyshortcuts":`E`,title:`Expand · E`,className:`-my-1 shrink-0`,children:[(0,U.jsx)(Ch,{"aria-hidden":`true`}),`Expand`]})]}),e.image?(0,U.jsx)(`img`,{src:I(e.image),alt:``,loading:`lazy`,className:`max-h-64 w-full rounded-lg border object-contain`}):null,e.htmlPreview?(0,U.jsx)(fG,{preview:e.htmlPreview,label:WQ(e.label).text,frameWidth:HQ,onOpen:t,className:`h-auto aspect-[3/2]`}):null,e.preview?(0,U.jsx)(Mz,{text:e.preview,className:`text-xs`}):null]})}function YQ({option:e,index:t,multi:n,name:r,selected:i,active:a,onToggle:o,onFocusOption:s}){let{text:c,recommended:l}=WQ(e.label),u=l?`${c} (Recommended)`:c;return(0,U.jsxs)(`label`,{"data-active":a||void 0,"data-picked":i||void 0,className:`q-dot group relative flex h-11 w-full shrink-0 cursor-pointer items-center justify-center outline-none`,children:[(0,U.jsx)(`input`,{type:n?`checkbox`:`radio`,name:r,"data-nav":``,"data-option":t,"aria-label":u,className:`sr-only`,checked:i,onChange:o,onFocus:s}),(0,U.jsx)(`span`,{"aria-hidden":`true`,className:Y(`q-dot-mark relative z-10 flex size-5 items-center justify-center rounded-full text-[0.625rem] font-semibold tabular-nums transition-[background-color,color,scale] duration-200 ease-snap group-hover:scale-110`,l&&`q-dot-star`),children:t+1}),(0,U.jsxs)(`span`,{"aria-hidden":`true`,className:`q-dot-tag pointer-events-none absolute top-1/2 left-[calc(100%+0.5rem)] z-30 -translate-y-1/2 rounded-full px-2.5 py-1 text-xs font-medium whitespace-nowrap opacity-0 transition-[opacity,translate] duration-150 ease-snap group-hover:opacity-100 group-has-[:focus-visible]:opacity-100 group-data-[active]:!opacity-0`,children:[t+1,`. `,u]})]})}var XQ={type:`spring`,visualDuration:.2,bounce:.12},ZQ={type:`spring`,visualDuration:.2,bounce:.04,delay:.06},QQ={type:`spring`,visualDuration:.28,bounce:.55},$Q={type:`spring`,visualDuration:.2,bounce:0},e$={type:`spring`,stiffness:900,damping:18,velocity:50,restDelta:.02,restSpeed:1},t$=-1;function n$(e,t,n,r,i,a){let o=(0,m.useRef)(null),s=(0,m.useRef)(null),c=(0,m.useRef)(null),l=(0,m.useRef)(null),u=(0,m.useRef)(void 0),d=(0,m.useRef)([]),f=(0,m.useRef)(a);f.current=a;let p=(0,m.useCallback)(t=>{if(t===t$){let t=n.current?.element,r=e.current;return t&&r?t.getBoundingClientRect().top-r.getBoundingClientRect().top+6:void 0}let r=e.current?.querySelectorAll(`.q-dot`)[t];return r?r.offsetTop+r.offsetHeight/2:void 0},[e,n]),h=(0,m.useCallback)(()=>{let t=o.current,n=e.current?.querySelectorAll(`.q-dot`);if(!t||!n||n.length===0)return;let r=n[0],i=n[n.length-1],a=r.offsetTop+r.offsetHeight/2;t.style.top=`${a}px`,t.style.height=`${Math.max(0,i.offsetTop+i.offsetHeight/2-a)}px`},[e]),g=(0,m.useCallback)((e,t=1,n=1)=>{let r=s.current,i=c.current;if(r&&i){if(e===void 0){r.style.opacity=`0`,i.style.opacity=`0`;return}r.style.opacity=String(Math.min(1,t*3)),r.style.transform=`translate(-50%, ${e}px) translateY(-50%) scale(${Math.max(0,t)})`,i.style.opacity=n>.02?`1`:`0`,i.style.transform=`translateY(${e}px) scaleX(${Math.max(0,Math.min(1,n))})`}},[]),_=(0,m.useRef)(i);return(0,m.useLayoutEffect)(()=>{_.current!==i&&(_.current=i,u.current=void 0),h();for(let e of d.current)e.stop();d.current=[],t.current&&(t.current.style.translate=``);let e=u.current;u.current=r;let n=p(r),a=e===void 0?void 0:p(e),o=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,s=l.current;if(s&&(s.style.opacity=`0`),n===void 0||a===void 0||e===r||e===t$||o||!s){g(r===t$?void 0:n),r===t$&&e!==r&&e!==void 0&&f.current();return}let c=n>a?1:-1,m={head:0,tail:0},v=!1,y=(e,t,n,r)=>{let i=Yf(e,t,{...n,onUpdate:r});return d.current.push(i),i},b=()=>{let e=a+(n-a)*m.head,t=a+(n-a)*m.tail;s.style.opacity=Math.abs(e-t)>1?`1`:`0`,s.style.transform=`translateY(${Math.min(e,t)}px)`,s.style.height=`${Math.abs(e-t)}px`},x=()=>{if(v)return;if(v=!0,r===t$){g(void 0),f.current();return}let e={open:0,reach:0},i=()=>p(r)??n;y(0,1,QQ,t=>{e.open=t,g(i(),e.open,e.reach)}),y(0,1,{...$Q,delay:.05},t=>{e.reach=t,g(i(),e.open,e.reach)});let a=t.current;a&&y(0,0,{...e$,delay:.1},e=>{a.style.translate=Math.abs(e)>.01?`0 ${(c*e).toFixed(2)}px`:``})};return y(1,0,{type:`spring`,visualDuration:.12,bounce:0},t=>{v||g(e===t$?void 0:a,t,t)}),y(0,1,XQ,e=>{m.head=e,b(),e>.85&&x()}),y(0,1,ZQ,e=>{m.tail=e,b()}),()=>{for(let e of d.current)e.stop()}},[r,i,p,t,g,h]),(0,m.useEffect)(()=>{let r=e.current;if(!r||typeof ResizeObserver>`u`)return;let i=0,a=()=>{i=0,h(),d.current.some(e=>e.state===`running`)||g(u.current===t$?void 0:p(u.current??0))},o=new ResizeObserver(()=>{i||=requestAnimationFrame(a)});o.observe(r),t.current&&o.observe(t.current);let s=n.current?.element;return s&&o.observe(s),()=>{cancelAnimationFrame(i),o.disconnect()}},[e,t,n,p,g,h]),{track:o,ring:s,line:c,drop:l}}function r$({option:e,position:t,count:n,chosen:r,onExpand:i,panel:a,dim:o}){if(!e)return null;let{text:s,recommended:c}=WQ(e.label),l=gG(e);return(0,U.jsx)(`div`,{ref:a,"data-dim":o||void 0,"data-chosen":r||void 0,className:`q-panel min-w-0 rounded-2xl p-4 transition-opacity duration-300 data-[dim]:opacity-55`,children:(0,U.jsxs)(`div`,{"aria-live":`polite`,className:Y(`q-panel-body grid min-w-0 gap-4`,l?`grid-cols-[minmax(0,1fr)_minmax(0,1.25fr)]`:``),children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2.5 py-0.5`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`q-panel-number mt-px flex size-6 shrink-0 items-center justify-center rounded-md text-xs font-semibold tabular-nums`,children:t+1}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,U.jsxs)(`p`,{className:`text-2xs font-medium tracking-wide text-muted-foreground uppercase`,children:[`Option `,t+1,` of `,n]}),(0,U.jsxs)(`p`,{className:`text-base font-semibold break-words`,children:[s,c?(0,U.jsx)(`span`,{className:`q-recommended ms-2 inline-flex translate-y-[-1px] items-center rounded-md px-1.5 py-0.5 align-middle text-2xs font-medium`,children:`Recommended`}):null]})]}),r?(0,U.jsxs)(`span`,{className:`q-chosen inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs font-medium`,children:[(0,U.jsx)($p,{"aria-hidden":`true`,className:`size-3.5`}),`Chosen`]}):null]}),e.description?(0,U.jsx)(Mz,{text:e.description,className:`q-panel-text min-w-0 text-sm leading-relaxed`}):(0,U.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`No further detail.`})]}),l?(0,U.jsx)(JQ,{option:e,onExpand:i}):null]},t)})}function i$({primary:e,primaryLabel:t,disabled:n,submitting:r,onCancel:i,intent:a}){return(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(X,{type:`button`,variant:`ghost`,onClick:i,children:`Cancel`}),a?(0,U.jsx)(`p`,{role:`status`,"aria-live":`polite`,"data-empty":a.empty||void 0,className:`q-intent flex min-w-0 flex-1 items-center justify-end gap-1.5 text-sm`,children:(0,U.jsxs)(`span`,{className:`q-intent-text flex min-w-0 items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:a.lead}),a.empty?null:(0,U.jsx)(`span`,{className:`truncate font-medium`,children:a.text})]},`${a.lead}${a.text}`)}):null,(0,U.jsx)(X,{type:e,disabled:n||r,children:r?`Sending…`:t})]})}function a$(e){if(!e?.answer)return{lead:`Nothing chosen yet`,text:``,empty:!0};if(e.kind===`custom`){let t=e.answer.replace(/[*_`#>]/g,``).replace(/\s+/g,` `).trim();return{lead:`You answer:`,text:`“${t.length>80?`${t.slice(0,79)}…`:t}”`}}return{lead:`You choose:`,text:(e.selected??[e.answer]).map(e=>WQ(e).text).join(`, `)}}function o$(e,t,n,r){let i=e[r];if(!i)return;let a=n[r]?.trim();if(a)return{questionIndex:r,question:i.question,kind:`custom`,answer:a};let o=(t[r]??[]).map(e=>i.options[e]?.label).filter(e=>!!e);if(o.length!==0)return i.multiSelect?{questionIndex:r,question:i.question,kind:`multi`,answer:o.join(`, `),selected:o}:{questionIndex:r,question:i.question,kind:`option`,answer:o[0]??null}}function s$({questions:e,picks:t,own:n,index:r,onGo:i}){return e.length===1?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e[0]?.header}):(0,U.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:e.map((e,a)=>{let o=!!n[a]?.trim()||(t[a]?.length??0)>0;return(0,U.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-description":`When focused, press Enter or Space to open this question.`,type:`button`,onClick:()=>i(a),"aria-current":a===r,className:Y(`inline-flex min-h-8 min-w-0 items-center gap-1 rounded-lg border px-3 text-xs font-medium transition-colors`,a===r?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,U.jsxs)(`span`,{className:`min-w-0 break-words text-start`,children:[a+1,` `,e.header]}),o?(0,U.jsx)($p,{className:`size-3 shrink-0`,"aria-hidden":`true`}):null]},a)})})}function c$({questions:e,submitting:t,onAnswer:n,onCancel:r,expanded:i,onExpand:a,onSize:o}){let[s,c]=(0,m.useState)(0),[l,u]=(0,m.useState)(!1),d=i??l,f=e=>a?a(e):u(e),[p,h]=(0,m.useState)(0),g=(0,m.useRef)(0),_=(0,m.useRef)(!1),[v,y]=(0,m.useState)({}),[b,x]=(0,m.useState)({}),[S,C]=(0,m.useState)({}),[w,T]=(0,m.useState)(!1),[E,D]=(0,m.useState)(!1),O=(0,m.useRef)(null),[k,A]=(0,m.useState)({}),ee=(0,m.useRef)(void 0),j=(0,m.useRef)(null),M=(0,m.useRef)(null),te=(0,m.useRef)(null),N=e[s],P=v[s]??[],ne=b[s]??``,re=N?.options[k[s]??P[0]??0],ie=o$(e,v,b,s),ae=N?.multiSelect===!0,oe=Math.max(0,N?.options.indexOf(re)??0),se=w||ne.trim()!==``,ce=se?t$:oe,le=n$(M,te,O,ce,`${s}:${d}`,()=>D(!0));if((0,m.useEffect)(()=>{if(!E)return;let e=window.setTimeout(()=>D(!1),700);return()=>window.clearTimeout(e)},[E]),(0,m.useEffect)(()=>o?.(BQ(N)),[N,o]),(0,m.useEffect)(()=>{let e=j.current;e&&(e.querySelector(`[data-option="${v[s]?.[0]??0}"]`)??e.querySelector(`[data-nav]`))?.focus()},[s]),(0,m.useEffect)(()=>{let e=_.current&&!d;_.current=d,e&&(A(e=>({...e,[s]:g.current})),j.current?.querySelector(`[data-option="${g.current}"]`)?.focus())},[d]),!N)return null;let F=N.options.some(gG);function ue(e){h(Math.max(0,e)),g.current=Math.max(0,e),f(!0)}function de(e){g.current=e,f(!1)}if(d&&F)return(0,U.jsx)(vG,{options:N.options,start:p,title:N.header||N.question,picked:P,multi:ae,onChoose:e=>{fe(e),ae||de(e)},onClose:de,onIndex:e=>{g.current=e}},s);function fe(e){let t=ae?P.includes(e)?P.filter(t=>t!==e):[...P,e]:[e];y({...v,[s]:t}),ae||(x({...b,[s]:``}),C({...S,[s]:``})),A({...k,[s]:e})}function I(e){let t=e instanceof HTMLInputElement&&e.dataset.option!==void 0?Number(e.dataset.option):-1;t>=0&&!ae&&fe(t)}function L(t,r){if(o$(e,t,r,s)){if(s<e.length-1){c(s+1);return}n({answers:e.map((n,i)=>o$(e,t,r,i)).filter(e=>!!e),cancelled:!1})}}function pe(e){e.preventDefault(),t||L(v,b)}function me(t){t>=0&&t<e.length&&c(t)}function he(e){let n=e.target,r=j.current;if(!r||e.altKey)return;if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)){e.preventDefault(),t||L(v,b);return}if(aR(n))return;let i=oR(e.key);if(i||e.key===`Home`||e.key===`End`){e.preventDefault(),iR(r,n,i||(e.key===`Home`?`first`:`last`)),I(document.activeElement);return}let a=sR(e.key);if(a&&!(n instanceof HTMLButtonElement)){e.preventDefault(),me(s+a);return}let o=n instanceof HTMLInputElement&&n.dataset.option!==void 0?Number(n.dataset.option):-1;if(e.key===`Enter`&&o>=0){if(e.preventDefault(),ae)P.length>0&&P.includes(o)?L(v,b):fe(o);else{let e={...v,[s]:[o]},t={...b,[s]:``};y(e),x(t),C({...S,[s]:``}),L(e,t)}return}if(e.key===` `&&o>=0){e.preventDefault(),fe(o);return}let c=Number(e.key);if(Number.isInteger(c)&&c>=1&&c<=N.options.length){e.preventDefault(),fe(c-1),r.querySelector(`[data-option="${c-1}"]`)?.focus();return}e.key.toLowerCase()===`e`&&F&&!e.ctrlKey&&!e.metaKey&&(e.preventDefault(),ue(o>=0?o:k[s]??P[0]??0))}return(0,U.jsxs)(`form`,{ref:j,className:`flex min-w-0 flex-col gap-3`,onSubmit:pe,onKeyDown:he,children:[(0,U.jsx)(s$,{questions:e,picks:v,own:b,index:s,onGo:c}),(0,U.jsxs)(`div`,{className:`text-center`,children:[(0,U.jsx)(`p`,{className:`text-2xs font-medium tracking-wide text-muted-foreground uppercase`,children:e.length>1?`Question ${s+1} of ${e.length}`:`Question`}),(0,U.jsx)(Mz,{text:N.question,className:`mt-1 text-base font-medium`})]}),(0,U.jsxs)(`div`,{className:`relative grid min-w-0 grid-cols-[2.25rem_minmax(0,1fr)] gap-x-3`,children:[(0,U.jsxs)(`div`,{ref:M,role:ae?`group`:`radiogroup`,"aria-label":`Options`,className:`q-rail relative flex min-w-0 flex-col justify-evenly py-2`,onPointerDown:e=>{if(!w)return;let t=e.target.closest(`.q-dot`)?.querySelector(`[data-option]`)?.getAttribute(`data-option`);ee.current=t==null?void 0:Number(t)},children:[(0,U.jsx)(`span`,{ref:le.track,"aria-hidden":`true`,className:`q-rail-line pointer-events-none absolute top-0 left-1/2 h-0 -translate-x-1/2`}),(0,U.jsx)(`span`,{ref:le.drop,"aria-hidden":`true`,className:`q-drop pointer-events-none absolute top-0 left-1/2 w-[3px] -translate-x-1/2 rounded-full opacity-0`}),(0,U.jsx)(`span`,{ref:le.ring,"aria-hidden":`true`,className:`q-ring pointer-events-none absolute top-0 left-1/2 z-20 size-7 rounded-full opacity-0`}),(0,U.jsx)(`span`,{ref:le.line,"aria-hidden":`true`,className:`q-line pointer-events-none absolute top-0 left-[calc(50%+0.875rem)] z-10 h-px w-[calc(50%-0.875rem+0.75rem)] origin-left opacity-0`}),N.options.map((e,t)=>(0,U.jsx)(YQ,{option:e,index:t,multi:ae,name:`question-${s}`,selected:P.includes(t),active:ce===t,onToggle:()=>fe(t),onFocusOption:()=>A({...k,[s]:t})},t))]}),(0,U.jsx)(r$,{panel:te,option:re,position:oe,count:N.options.length,chosen:!se&&P.includes(oe),dim:se,onExpand:()=>ue(oe)})]}),(0,U.jsx)(`div`,{className:`q-own-wrap mx-auto w-full`,children:(0,U.jsx)(zQ,{ref:O,html:S[s]??``,placeholder:`Type something else…`,label:`Your own answer`,landed:E,onChange:(e,t)=>{x(t=>({...t,[s]:e})),C(e=>({...e,[s]:t})),e&&y(e=>({...e,[s]:[]}))},onFocusChange:(e,t)=>{if(!e){let e=t?.closest?.(`[data-option]`)?.getAttribute(`data-option`),n=e==null?ee.current??N.options.length-1:Number(e);A(e=>({...e,[s]:n}))}ee.current=void 0,T(e)},onSubmit:()=>{t||L(v,b)},onUp:()=>{let e=j.current;e&&iR(e,O.current?.element??null,-1)}},s)}),(0,U.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{children:ae?`Pick several`:`Pick one`}),(0,U.jsx)(KD,{chord:`↑↓`,children:`move`}),(0,U.jsx)(KD,{chord:ae?`Space`:`Enter`,children:ae?`pick`:`choose`}),ae?(0,U.jsx)(KD,{chord:`Enter`,children:`next`}):null,e.length>1?(0,U.jsx)(KD,{chord:`←→`,children:`question`}):null,F?(0,U.jsx)(KD,{chord:`E`,children:`expand mockups`}):null,(0,U.jsx)(KD,{chord:`Esc`,children:`later`})]}),(0,U.jsx)(i$,{primary:`submit`,primaryLabel:s<e.length-1?`Next`:`Answer`,disabled:!ie,submitting:t,onCancel:r,intent:a$(ie)})]})}function l$(e,t,n){let r=e.currentTarget,i=e.target;if(e.altKey||aR(i))return;let a=oR(e.key);if(a){e.preventDefault(),iR(r,i,a);return}let o=i instanceof HTMLInputElement&&i.dataset.option!==void 0?Number(i.dataset.option):-1;if((e.key===`Enter`||e.key===` `)&&o>=0){e.preventDefault(),n(o,e.key===`Enter`);return}let s=Number(e.key);Number.isInteger(s)&&s>=1&&s<=t&&(e.preventDefault(),n(s-1,!1),r.querySelector(`[data-option="${s-1}"]`)?.focus())}function u$({view:e,submitting:t,onAnswer:n,onCancel:r}){let[i,a]=(0,m.useState)(``),o=(0,m.useRef)(null);return(0,m.useEffect)(()=>{o.current?.querySelector(`[data-nav]`)?.focus()},[]),(0,U.jsxs)(`form`,{ref:o,className:`flex min-w-0 flex-col gap-3`,onSubmit:e=>{e.preventDefault(),i&&n(i)},onKeyDown:r=>l$(r,e.options.length,(r,i)=>{let o=e.options[r];o!==void 0&&(a(o),i&&!t&&n(o))}),children:[(0,U.jsx)(Mz,{text:e.title,className:`text-base`}),(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.options.map((e,t)=>(0,U.jsx)(qQ,{option:{label:e},index:t,multi:!1,name:`choice`,selected:i===e,onToggle:()=>a(e)},e))}),(0,U.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,U.jsx)(KD,{chord:`↑↓`,children:`move`}),(0,U.jsx)(KD,{chord:`Enter`,children:`choose`}),(0,U.jsx)(KD,{chord:`Esc`,children:`later`})]}),(0,U.jsx)(i$,{primary:`submit`,primaryLabel:`Choose`,disabled:!i,submitting:t,onCancel:r})]})}function d$({view:e,submitting:t,onAnswer:n}){let r=(0,m.useRef)(null);(0,m.useEffect)(()=>r.current?.focus(),[]);function i(e){if(e.altKey||e.ctrlKey||e.metaKey||t)return;let r=e.key.toLowerCase();r===`y`?n(!0):r===`n`&&n(!1)}return(0,U.jsxs)(`div`,{ref:r,tabIndex:-1,"data-autofocus":``,onKeyDown:i,className:`flex min-w-0 flex-col gap-3 outline-none`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(Mz,{text:e.question,className:`text-base`}),e.detail?(0,U.jsx)(Mz,{text:e.detail,className:`mt-1 text-muted-foreground`}):null]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`p`,{className:`flex items-center gap-x-4 text-xs text-muted-foreground`,children:[(0,U.jsx)(KD,{chord:`Y`,children:`yes`}),(0,U.jsx)(KD,{chord:`N`,children:`no`}),(0,U.jsx)(KD,{chord:`Esc`,children:`later`})]}),(0,U.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(X,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n(!1),children:`No`}),(0,U.jsx)(X,{type:`button`,disabled:t,onClick:()=>n(!0),children:t?`Sending…`:`Yes`})]})]})]})}function f$({view:e,submitting:t,onAnswer:n,onCancel:r}){let[i,a]=(0,m.useState)(``);return(0,U.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-3`,onSubmit:e=>{e.preventDefault(),i.trim()&&n(i.trim())},children:[(0,U.jsx)(Mz,{text:e.question,className:`text-base`}),(0,U.jsx)(tV,{autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},value:i,onChange:e=>a(e.target.value),placeholder:e.placeholder??UQ,"aria-label":e.question,rows:3,className:`min-h-9 resize-none text-sm`}),(0,U.jsxs)(`p`,{className:`flex items-center gap-x-4 text-xs text-muted-foreground`,children:[(0,U.jsx)(KD,{chord:`Enter`,children:`answer`}),(0,U.jsx)(KD,{chord:`Shift+Enter`,children:`new line`}),(0,U.jsx)(KD,{chord:`Esc`,children:`later`})]}),(0,U.jsx)(i$,{primary:`submit`,primaryLabel:`Answer`,disabled:!i.trim(),submitting:t,onCancel:r})]})}function p$({dialog:e,submitting:t,onAnswer:n}){let[r,i]=(0,m.useState)(e.method===`editor`?e.prefill??``:``),[a,o]=(0,m.useState)(``),s=e.options??[],c=e.method===`select`?a!==``:r.trim()!==``,l=(0,m.useRef)(null);(0,m.useEffect)(()=>{l.current?.querySelector(`[data-nav], textarea`)?.focus()},[]);function u(t){t.preventDefault(),e.method===`select`?n({value:a}):e.method===`confirm`?n({confirmed:!0}):(e.method===`input`||e.method===`editor`)&&n({value:r.trim()})}return(0,U.jsxs)(`form`,{ref:l,className:`flex min-w-0 flex-col gap-3`,onSubmit:u,onKeyDown:r=>{e.method===`select`&&l$(r,s.length,(e,r)=>{let i=s[e];i!==void 0&&(o(i),r&&!t&&n({value:i}))})},children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.title}),e.message?(0,U.jsx)(Mz,{text:e.message,className:`mt-1 text-base`}):null]}),e.method===`select`?(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.map((e,t)=>(0,U.jsx)(qQ,{option:{label:e},index:t,multi:!1,name:`dialog`,selected:a===e,onToggle:()=>o(e)},e))}):null,e.method===`input`||e.method===`editor`?(0,U.jsx)(tV,{value:r,onChange:e=>i(e.target.value),placeholder:e.placeholder??UQ,"aria-label":e.title,rows:e.method===`editor`?4:2,className:`min-h-9 resize-none text-sm`}):null,(0,U.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,U.jsx)(X,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n({cancelled:!0}),children:`Cancel`}),e.method===`confirm`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(X,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n({confirmed:!1}),children:`No`}),(0,U.jsx)(X,{type:`button`,disabled:t,onClick:()=>n({confirmed:!0}),children:t?`Sending…`:`Yes`})]}):(0,U.jsx)(X,{type:`submit`,disabled:!c||t,children:t?`Sending…`:`Answer`})]})]})}function m$(e){let{view:t}=e;return t.kind===`questionnaire`?(0,U.jsx)(c$,{questions:t.questions,submitting:e.submitting,onAnswer:e.onAnswer,onCancel:e.onCancel,onSize:e.onSize,...e.onExpand?{expanded:e.expanded??!1,onExpand:e.onExpand}:{}}):t.kind===`choose`?(0,U.jsx)(u$,{...e,view:t}):t.kind===`confirm`?(0,U.jsx)(d$,{...e,view:t}):t.kind===`text`?(0,U.jsx)(f$,{...e,view:t}):(0,U.jsx)(p$,{...e,dialog:t.dialog})}function h$(e){return typeof e==`object`&&e?e:{}}function g$(e){return typeof e==`string`?e.trim():``}function _$(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function v$(e){let t=h$(e),n=g$(t.label);if(!n)return;let r=g$(t.description),i=g$(t.preview),a=g$(t.image),o=sG(t.htmlPreview);return{label:n,...r?{description:r}:{},...i?{preview:i}:{},...a?{image:a}:{},...o?{htmlPreview:o}:{}}}function y$(e){let t=h$(e),n=g$(t.question);if(!n)return;let r=(Array.isArray(t.options)?t.options:[]).map(v$).filter(e=>!!e);return{question:n,header:g$(t.header)||`Question`,options:r,...t.multiSelect===!0?{multiSelect:!0}:{}}}function b$(e){let t=h$(e),n=g$(t.method);if(n!==`select`&&n!==`confirm`&&n!==`input`&&n!==`editor`)return;let r=g$(t.message),i=_$(t.options),a=g$(t.placeholder),o=g$(t.prefill);return{id:g$(t.id),method:n,title:g$(t.title)||`Answer`,...r?{message:r}:{},...i.length>0?{options:i}:{},...a?{placeholder:a}:{},...o?{prefill:o}:{}}}function x$(e){let t=(Array.isArray(e.questions)?e.questions:[]).map(y$).filter(e=>!!e);return t.length>0?{kind:`questionnaire`,questions:t}:void 0}function S$(e){return{kind:`choose`,title:g$(e.title)||`Choose an option`,options:_$(e.options)}}function C$(e){let t=g$(e.question)||g$(e.title)||`Continue?`,n=g$(e.detail)||g$(e.message);return{kind:`confirm`,question:t,...n?{detail:n}:{}}}function w$(e){let t=g$(e.question)||g$(e.title)||`Type an answer`,n=g$(e.placeholder);return{kind:`text`,question:t,...n?{placeholder:n}:{}}}function T$(e){let t=h$(e.payload);if(e.kind===`questionnaire`)return x$(t);if(e.kind===`choose`)return S$(t);if(e.kind===`confirm`)return C$(t);if(e.kind===`text`)return w$(t);let n=b$(t.dialog);return n?{kind:`sessionDialog`,dialog:n}:void 0}var E$={md:`max-w-3xl`,lg:`max-w-4xl max-h-[min(88svh,52rem)]`,xl:`max-w-5xl max-h-[min(90svh,58rem)]`};function D$({submitting:e,onKeep:t,onLeave:n}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,role:`alert`,children:[(0,U.jsx)(`p`,{className:`text-sm`,children:`Leave without answering? The oracle will not guess for you.`}),(0,U.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,U.jsx)(X,{type:`button`,variant:`outline`,onClick:t,children:`Keep answering`}),(0,U.jsx)(X,{type:`button`,disabled:e,onClick:n,children:e?`Leaving…`:`Leave`})]})]})}function O$({count:e,onOpen:t}){return(0,U.jsxs)(X,{type:`button`,variant:`soft`,onClick:t,"aria-label":`${e} question${e===1?``:`s`} waiting — open`,className:`gap-1.5 text-warning`,children:[(0,U.jsx)(_m,{"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`tabular-nums`,children:e}),(0,U.jsx)(`span`,{children:`waiting`})]})}function k$({prompts:e,answer:t,dismiss:n,minimized:r,onMinimize:i}){let[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(!1),d=(0,m.useRef)(null),[f,p]=(0,m.useState)(`md`),h=e.length,g=e[0],_=g?T$(g):void 0,v=h>0&&!r,y=tO(v,eO.question);(0,m.useEffect)(()=>{h===0&&(o(!1),i(!1))},[h,i]);let b=g?.id;(0,m.useEffect)(()=>u(!1),[b]);async function x(e,t){c(!0);try{await e,o(!1)}catch(e){e instanceof be&&e.code===`question_withdrawn`?W(FR):W.error(e instanceof Error?e.message:t)}finally{c(!1)}}let S=g?.from?`${g.from} asks`:`A question`;return(0,U.jsx)(qD,{open:v&&y&&!!g,label:`Question from the lobby`,dismissOnBackdrop:!1,onOpenChange:e=>{e||(l?u(!1):a?o(!1):i(!0))},className:Y(`transition-[max-width] duration-300 ease-snap`,l?`h-[min(92svh,60rem)] max-h-[min(92svh,60rem)] max-w-7xl`:E$[_?.kind===`questionnaire`?f:`md`]),children:g?(0,U.jsxs)(`section`,{"aria-label":`Question from the lobby`,className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,U.jsxs)(`header`,{className:Y(`flex items-center gap-3 px-4 pt-4 pb-2`,l&&`hidden`),children:[(0,U.jsxs)(`p`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-muted-foreground first-letter:uppercase`,children:[S,h>1?` · 1 of ${h}`:``]}),(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Later: put the question away`,title:`Later · Esc`,onClick:()=>i(!0),children:(0,U.jsx)(s_,{"aria-hidden":`true`})})]}),(0,U.jsx)(`div`,{ref:d,className:l?`flex min-h-0 min-w-0 flex-1 flex-col`:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain px-4 pb-4`,children:_?a?(0,U.jsx)(D$,{submitting:s,onKeep:()=>o(!1),onLeave:()=>void x(n(g.id),`Could not leave the question`)}):(0,U.jsx)(m$,{view:_,submitting:s,onAnswer:e=>void x(t(g.id,e),`Could not send the answer`),onCancel:()=>o(!0),expanded:l,onExpand:u,onSize:p},g.id):(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:` text-sm text-muted-foreground`,children:`This question cannot be shown here.`}),(0,U.jsx)(X,{type:`button`,disabled:s,onClick:()=>void x(n(g.id),`Could not dismiss the question`),children:`Dismiss`})]})}),l?null:(0,U.jsx)(Bv,{target:d})]}):null})}var A$=2;function j$(e){let t=globalThis.EventSource;if(!t)throw Error(`EventSource is not available in this environment`);return new t(e)}function M$(e){try{return JSON.parse(e)}catch{return}}function N$(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 P$(e,t=j$){let n=t(I(`/api/events`));return e.onConnection?.(`connecting`),n.onopen=()=>e.onConnection?.(`live`),n.onerror=()=>e.onConnection?.(n.readyState===A$?`offline`:`connecting`),n.onmessage=t=>{let n=M$(t.data);n&&N$(n,e)},()=>n.close()}var F$=2e3,I$=()=>R(`projects.list`,{});async function L$(){let e;try{e=fe()}catch{return}if(e&&!ve(e))try{_e((await I$()).projects)}catch{}}function R$(){let e=(0,m.useRef)(void 0),t=(0,m.useRef)(void 0),n=(0,m.useCallback)(()=>{clearTimeout(t.current),e.current?.();try{fe()}catch{F.onStatus({connection:`offline`});return}e.current=P$({onHello:e=>{F.onHello(e),L$()},onChanged:(e,t)=>F.onChanged(e,t),onFeed:e=>F.onFeedDelta(e),onReply:e=>F.onReplyDelta(e),onNotice:(e,t)=>W[t](e),onConnection:e=>{F.onStatus({connection:e}),e===`offline`&&(clearTimeout(t.current),t.current=setTimeout(()=>{ye(I$).catch(()=>!1).finally(n)},F$))}})},[]);return(0,m.useEffect)(()=>(n(),()=>{clearTimeout(t.current),e.current?.()}),[n]),n}var z$=`bot-lobby.recoveredAt`,B$;function V$(e,t=H$()){try{B$===void 0&&(B$=Number(t?.getItem(z$)??0))}catch{B$??=0}if(B$!==void 0&&e<=B$)return!1;B$=e;try{t?.setItem(z$,String(e))}catch{}return!0}function H$(){try{return globalThis.sessionStorage}catch{return}}function U$(e){let t=e?.recovered?.at,n=e?.recovered?.text;(0,m.useEffect)(()=>{t!==void 0&&n&&V$(t)&&W.success(n)},[t,n])}function W$(){let e=oO(`prompts`),t=(0,m.useCallback)(async(e,t)=>{await R(`prompts.answer`,{id:e,answer:t})},[]),n=(0,m.useCallback)(async e=>{await R(`prompts.dismiss`,{id:e})},[]);return{prompts:e.data?.prompts??[],loading:e.loading,error:e.error,answer:t,dismiss:n}}function G$(e,t,n,r,i){e===`search`?(document.querySelector(`#main input[type='search']`)??document.getElementById(`composer-text`))?.focus():e===`help`?n():e===`settings`?mB(`#/settings`):e===`thinking`?Vz(`lobby.thinking`):e===`sidebar`?i():e===`terminal`?LX():e===`code`?sz():e===`activity`?t.kind===`tab`&&t.tab===`lobby`?Vz(Uz):mB(pB(`lobby`)):e===`nextTab`?r(1):e===`prevTab`?r(-1):e===`savePlan`&&t.kind===`tab`&&t.tab===`plan`&&mp(`planner.save`,{})}var K$=`toolbar-button inline-flex size-8 shrink-0 items-center justify-center rounded-lg border text-foreground transition-[background-color,border-color,scale] duration-150 ease-snap outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:scale-[0.97] motion-reduce:active:scale-100`,q$=`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-[background-color,color,scale] duration-150 ease-snap outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:scale-[0.97] aria-pressed:bg-accent aria-pressed:text-foreground motion-reduce:active:scale-100`,J$=2500;function Y$(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),J$);return()=>clearTimeout(t)},[e]),e===`offline`||e===`connecting`&&t}function X$({connection:e,onRetry:t}){return Y$(e)?(0,U.jsx)(TB,{onRetry:t}):null}var Z$={tick:0,route:0,focus:0};window.addEventListener(`hashchange`,()=>{Z$.route=++Z$.tick}),document.addEventListener(`focusin`,()=>{Z$.focus=++Z$.tick});var Q$=()=>Z$.focus>Z$.route;function $$(e){return e.kind===`tab`?e.tab:e.kind}function e1(){let e=hB(),t=oO(`status`),n=oO(`lobby`),{prompts:r,answer:i,dismiss:a}=W$(),{connection:o,signedOut:s}=aO(),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=(0,m.useRef)(null),p=R$();xH();let h=t.data;U$(h);let g=!!h&&!s;(0,m.useEffect)(()=>{g&&Le()},[g]);let _=h?.tabs??[],v=h?.keys??[],y=e.kind===`tab`?e.tab:void 0,b=(0,m.useCallback)(e=>mB(pB(e)),[]),x=(0,U.jsx)(XZ,{tabs:_,activeId:y,onSelect:b}),S=(0,m.useCallback)(e=>{if(_.length===0)return;let t=Math.max(0,_.findIndex(e=>e.id===y)),n=_[(t+e+_.length)%_.length];n&&mB(pB(n.id))},[_,y]),C=(0,m.useCallback)(()=>l(e=>!e),[]),w=cY();sO(Nz);let[T]=Hz(YY),E=(0,m.useCallback)(()=>Vz(YY),[]),D=(0,m.useCallback)(t=>{(t!==`thinking`&&t!==`activity`||h?.panels?.[t]!==!1)&&G$(t,fB(window.location.hash)??e,C,S,E)},[e,C,S,E,h?.panels]),O=(0,m.useCallback)(()=>{let e=document.activeElement;return!e||e===document.body||f.current?.contains(e)===!0||e.closest(`.thinking-bubble, .terminal-pop`)?!0:e.closest(`[data-state='closed']`)!==null},[]);EJ({enabled:!!h,keys:v,tabs:_,insideApp:O,onAction:D,onTab:b});let k=(0,m.useCallback)(()=>F.onHello({}),[]),A=e.kind===`tab`?e.tab:e.kind,ee=!!h;(0,m.useEffect)(()=>{if(!ee)return;let e=hR.active&&hR.to===A;if(hR.active=!1,hR.to=void 0,e)return;let t=requestAnimationFrame(()=>{if(Q$()||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)},[A,ee]);let j=Object.fromEntries(v.map(e=>[e.action,e.label])),M=!!h&&!s,te=M?(0,U.jsx)(xX,{hint:j.sidebar}):null,N=(0,U.jsx)(GY,{connection:o,projects:w,lead:te,tabs:x,extra:u&&r.length>0?(0,U.jsx)(O$,{count:r.length,onOpen:()=>d(!1)}):null,tools:M?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(oZ,{hint:j.code,className:q$}),(0,U.jsx)(QX,{hint:j.terminal,className:q$})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(VJ,{className:K$,side:`bottom`}),(0,U.jsx)(BJ,{className:K$,side:`bottom`})]})});return s||!h?(0,U.jsxs)(`div`,{ref:f,className:`fixed inset-0 flex flex-col`,children:[N,(0,U.jsx)(`main`,{className:`surface flex min-h-0 flex-1 flex-col overflow-y-auto`,children:s?(0,U.jsx)(_Z,{}):t.error?(0,U.jsx)(wB,{message:t.error,onRetry:k}):(0,U.jsx)(CB,{})})]}):(0,U.jsxs)(`div`,{ref:f,className:`app-chrome fixed inset-0 flex`,"data-sidebar":T?`folded`:`open`,children:[(0,U.jsx)(bX,{route:e,keys:j,onHelp:C}),(0,U.jsxs)(`div`,{className:`relative flex min-w-0 flex-1 flex-col`,children:[N,(0,U.jsxs)(`div`,{className:`app-page relative flex min-h-0 flex-1 flex-col`,children:[(0,U.jsx)(X$,{connection:o,onRetry:p}),(0,U.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,U.jsx)(`main`,{id:`main`,tabIndex:-1,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||aR(e.target)||e.target.closest(`[role='dialog'], [role='menu'], [role='listbox']`)||mR()&&e.preventDefault()},role:y?`tabpanel`:void 0,"aria-labelledby":y?`tab-${y}`:void 0,className:`surface flex min-h-0 flex-1 flex-col overflow-y-auto outline-none`,children:(0,U.jsx)(Xf.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.18,ease:[.2,.8,.2,1]},className:`flex min-h-0 flex-1 flex-col`,children:pJ(e)},$$(e))}),(0,U.jsx)(BY,{route:e,projects:w})]}),(0,U.jsx)(tZ,{toggleKey:j.terminal??"Ctrl+`"})]})]}),(0,U.jsx)(jQ,{status:h,lobby:n.data}),(0,U.jsx)(hZ,{codeKey:v.find(e=>e.action===`code`)?.key}),(0,U.jsx)(k$,{prompts:r,answer:i,dismiss:a,minimized:u,onMinimize:d}),(0,U.jsx)(LJ,{open:c,onOpenChange:l,keys:v,tabs:_})]})}async function t1(e){switch(e){case`status`:return R(`status.get`,{});case`lobby`:return R(`lobby.snapshot`,{});case`prompts`:return R(`prompts.list`,{});default:return}}var n1=[`status`,`lobby`,`prompts`];function r1(){let[e,t]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{let e=!0;return(async()=>{await Ce(),e&&(F.markUsed(n1,t1),t(!0))})(),()=>{e=!1}},[]),e}function i1(){return r1()?(0,U.jsx)(e1,{}):(0,U.jsx)(`div`,{className:`fixed inset-0 flex`,children:(0,U.jsx)(CB,{})})}var a1={info:ah,success:dm,warning:qg,error:xm},o1={info:`Note:`,success:`Done:`,warning:`Warning:`,error:`Error:`},s1={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-destructive`};function c1(){let{item:e,waiting:t}=fp(),n=rO(),r=e&&!n;return(0,m.useEffect)(()=>{if(!e||n)return;let r=window.setTimeout(()=>up(e.id),t>0?Math.min(e.duration,1600):e.duration);return()=>window.clearTimeout(r)},[e,n,t]),(0,U.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`pointer-events-none fixed z-40 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,U.jsx)(ju,{mode:`wait`,children:r?(0,U.jsxs)(Xf.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,U.jsx)(l1,{kind:e.kind}),(0,U.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,U.jsxs)(`span`,{className:`sr-only`,children:[o1[e.kind],` `]}),e.message]}),e.action?(0,U.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(),up(e.id)},children:e.action.label}):null]},e.id):null})})}function l1({kind:e}){let t=a1[e];return(0,U.jsx)(t,{"aria-hidden":`true`,className:Y(`size-4 shrink-0`,s1[e])})}(0,np.createRoot)(document.getElementById(`root`)).render((0,U.jsx)(m.StrictMode,{children:(0,U.jsx)(eU,{children:(0,U.jsx)(Ru,{reducedMotion:`user`,children:(0,U.jsxs)($L,{children:[(0,U.jsx)(i1,{}),(0,U.jsx)(c1,{})]})})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{updateViaCache:`none`}).catch(()=>void 0)});export{I as i,yJ as n,R as r,JX as t};
|