@a-t-h-i/bot-lobby 0.6.52 → 0.6.53

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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalView-DhNPNk-y.js","assets/TerminalView-BrP-ENHg.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalView-CbRc77C8.js","assets/TerminalView-BrP-ENHg.css"])))=>i.map(i=>d[i]);
2
2
  var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(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 u=document.querySelector(`meta[property="csp-nonce"]`),d=u?.nonce||u?.content;d&&(window.__webpack_nonce__=d);var f=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ee(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var te=/\/+/g;function A(e,t){return typeof e==`object`&&e&&e.key!=null?ee(``+e.key):t.toString(36)}function j(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function M(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,M(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+A(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(te,`$&/`)+`/`),M(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(te,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+A(a,u),c+=M(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+A(a,u++),c+=M(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return M(j(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function ne(e,t,n){if(e==null)return e;var r=[],i=0;return M(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function N(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var re=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function ie(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,re)}catch(e){re(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function ae(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else ie(ae.bind(null,e))}var oe={map:ne,forEach:function(e,t,n){ne(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ne(e,function(){t++}),t},toArray:function(e){return ne(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=oe,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=ae,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:N}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=ie,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.0`})),p=o(((e,t)=>{t.exports=f()})),m=l(p(),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 ee(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 te(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 A={"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)`},j=`"Inter Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`,M=`ui-monospace, "JetBrains Mono", "Cascadia Mono", "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace`;function ne(e,t){let n=[];for(let[e,r]of Object.entries(t))e===`font-sans`?n.push(`--app-font-sans:${r},${j};`):e===`font-mono`?n.push(`--app-font-mono:${r},${M};`):n.push(`--${e}:${r};`);for(let[e,r]of Object.entries(A))e in t||n.push(`--${e}:${r};`);return`${e}{${n.join(``)}}`}function N(e){let t=[];return e.light&&t.push(ne(`:root`,e.light)),e.dark&&t.push(ne(`.dark`,e.dark)),t.join(`
3
3
  `)}var re=`mist`,ie=[{id:re,name:`Default`},{id:`blossom`,name:`Blossom`,light:{background:`oklch(0.982446 0.010114 325.653)`,foreground:`oklch(0.325698 0.116116 325.037)`,card:`oklch(0.971835 0.012884 321.894)`,"card-foreground":`oklch(0.325698 0.116116 325.037)`,popover:`oklch(1 0 0)`,"popover-foreground":`oklch(0.325698 0.116116 325.037)`,primary:`oklch(0.591646 0.217985 0.584)`,"primary-foreground":`oklch(1 0 0)`,secondary:`oklch(0.869588 0.06751 334.899)`,"secondary-foreground":`oklch(0.444777 0.134061 324.799)`,muted:`oklch(0.802407 0.090963 345.892)`,"muted-foreground":`oklch(0.428932 0.163929 354.332)`,accent:`oklch(0.939552 0.024286 321.664)`,"accent-foreground":`oklch(0.396296 0.025134 285.196)`,destructive:`oklch(0.627117 0.248974 7.734)`,border:`oklch(0.923531 0.021247 328.096)`,input:`oklch(0.851713 0.055822 336.6)`,ring:`oklch(0.591646 0.217985 0.584)`,"chart-1":`oklch(0.591646 0.217985 0.584)`},dark:{background:`oklch(0.22813 0.020366 307.469)`,foreground:`oklch(0.980735 0.004092 301.426)`,card:`oklch(0.267101 0.02016 311.799)`,"card-foreground":`oklch(0.980735 0.004092 301.426)`,popover:`oklch(0.154761 0.01316 338.901)`,"popover-foreground":`oklch(0.980735 0.004092 301.426)`,primary:`oklch(0.460685 0.185347 4.099)`,"primary-foreground":`oklch(0.901233 0.057189 343.694)`,secondary:`oklch(0.313674 0.030572 310.061)`,"secondary-foreground":`oklch(0.848252 0.038248 307.961)`,muted:`oklch(0.360924 0.021469 316.83)`,"muted-foreground":`oklch(0.880303 0.03077 342.696)`,accent:`oklch(0.364912 0.050794 308.491)`,"accent-foreground":`oklch(0.964695 0.009139 341.803)`,destructive:`oklch(0.458704 0.169677 3.815)`,border:`oklch(0.266943 0.015262 302.425)`,input:`oklch(0.266817 0.02897 344.461)`,ring:`oklch(0.591646 0.217985 0.584)`,"chart-1":`oklch(0.460685 0.185347 4.099)`}},{id:`grove`,name:`Grove`,light:{background:`oklch(0.972369 0.005497 157.15)`,foreground:`oklch(0.222003 0.03479 328.979)`,card:`oklch(0.972369 0.005497 157.15)`,"card-foreground":`oklch(0.222003 0.03479 328.979)`,popover:`oklch(0.932695 0.003778 160.944)`,"popover-foreground":`oklch(0.222003 0.03479 328.979)`,primary:`oklch(0.523295 0.112292 158.089)`,"primary-foreground":`oklch(0.990339 0.008411 325.64)`,secondary:`oklch(0.936464 0.014601 163.554)`,"secondary-foreground":`oklch(0.222003 0.03479 328.979)`,muted:`oklch(0.945455 0.012308 162.879)`,"muted-foreground":`oklch(0.527266 0.012309 320.683)`,accent:`oklch(0.909438 0.021521 164.612)`,"accent-foreground":`oklch(0.222003 0.03479 328.979)`,destructive:`oklch(0.637823 0.237287 25.436)`,border:`oklch(0.864831 0.01312 167.255)`,input:`oklch(0.829746 0.016084 168.234)`,ring:`oklch(0.523295 0.112292 158.089)`,"chart-1":`oklch(0.523295 0.112292 158.089)`},dark:{background:`oklch(0.260865 0.02152 162.75)`,foreground:`oklch(0.990339 0.008411 325.64)`,card:`oklch(0.260865 0.02152 162.75)`,"card-foreground":`oklch(0.990339 0.008411 325.64)`,popover:`oklch(0.411828 0.014378 166.627)`,"popover-foreground":`oklch(0.990339 0.008411 325.64)`,primary:`oklch(0.796228 0.133058 157.319)`,"primary-foreground":`oklch(0.222003 0.03479 328.979)`,secondary:`oklch(0.380487 0.048313 159.608)`,"secondary-foreground":`oklch(0.990339 0.008411 325.64)`,muted:`oklch(0.339728 0.039456 160.274)`,"muted-foreground":`oklch(0.715427 0.010896 171.428)`,accent:`oklch(0.437021 0.060312 158.962)`,"accent-foreground":`oklch(0.990339 0.008411 325.64)`,destructive:`oklch(0.655108 0.221148 23.473)`,border:`oklch(0.457475 0.044046 160.971)`,input:`oklch(0.519849 0.049896 160.863)`,ring:`oklch(0.796228 0.133058 157.319)`,"chart-1":`oklch(0.796228 0.133058 157.319)`}},{id:`ocean`,name:`Ocean`,light:{background:`oklch(0.974199 0.002856 241.597)`,foreground:`oklch(0.222003 0.03479 328.979)`,card:`oklch(0.974199 0.002856 241.597)`,"card-foreground":`oklch(0.222003 0.03479 328.979)`,popover:`oklch(0.934442 0.003181 269.1)`,"popover-foreground":`oklch(0.222003 0.03479 328.979)`,primary:`oklch(0.536684 0.120219 247.01)`,"primary-foreground":`oklch(0.990339 0.008411 325.64)`,secondary:`oklch(0.939254 0.01193 241.729)`,"secondary-foreground":`oklch(0.222003 0.03479 328.979)`,muted:`oklch(0.948004 0.009649 241.695)`,"muted-foreground":`oklch(0.528741 0.01828 313.823)`,accent:`oklch(0.91295 0.018827 241.836)`,"accent-foreground":`oklch(0.222003 0.03479 328.979)`,destructive:`oklch(0.637823 0.237287 25.436)`,border:`oklch(0.867646 0.013482 252.362)`,input:`oklch(0.832939 0.017389 252.598)`,ring:`oklch(0.536684 0.120219 247.01)`,"chart-1":`oklch(0.536684 0.120219 247.01)`},dark:{background:`oklch(0.242641 0.024125 250.573)`,foreground:`oklch(0.990339 0.008411 325.64)`,card:`oklch(0.242641 0.024125 250.573)`,"card-foreground":`oklch(0.990339 0.008411 325.64)`,popover:`oklch(0.398517 0.018232 255.72)`,"popover-foreground":`oklch(0.990339 0.008411 325.64)`,primary:`oklch(0.758933 0.105833 241.548)`,"primary-foreground":`oklch(0.222003 0.03479 328.979)`,secondary:`oklch(0.358725 0.043145 244.911)`,"secondary-foreground":`oklch(0.990339 0.008411 325.64)`,muted:`oklch(0.319287 0.036766 246.065)`,"muted-foreground":`oklch(0.691936 0.016294 261.588)`,accent:`oklch(0.413315 0.051874 243.855)`,"accent-foreground":`oklch(0.990339 0.008411 325.64)`,destructive:`oklch(0.655108 0.221148 23.473)`,border:`oklch(0.438653 0.039496 245.44)`,input:`oklch(0.500905 0.043574 244.781)`,ring:`oklch(0.758933 0.105833 241.548)`,"chart-1":`oklch(0.758933 0.105833 241.548)`}},{id:`ember`,name:`Ember`,light:{background:`oklch(0.976527 0.002685 60.725)`,foreground:`oklch(0.222003 0.03479 328.979)`,card:`oklch(0.976527 0.002685 60.725)`,"card-foreground":`oklch(0.222003 0.03479 328.979)`,popover:`oklch(0.936659 0.002879 29.96)`,"popover-foreground":`oklch(0.222003 0.03479 328.979)`,primary:`oklch(0.552831 0.129438 44.656)`,"primary-foreground":`oklch(0.990339 0.008411 325.64)`,secondary:`oklch(0.942267 0.01151 50.785)`,"secondary-foreground":`oklch(0.222003 0.03479 328.979)`,muted:`oklch(0.950842 0.009273 51.528)`,"muted-foreground":`oklch(0.530413 0.018453 341.181)`,accent:`oklch(0.916502 0.01832 49.597)`,"accent-foreground":`oklch(0.222003 0.03479 328.979)`,destructive:`oklch(0.637823 0.237287 25.436)`,border:`oklch(0.870631 0.013204 39.431)`,input:`oklch(0.836213 0.017153 38.661)`,ring:`oklch(0.552831 0.129438 44.656)`,"chart-1":`oklch(0.552831 0.129438 44.656)`},dark:{background:`oklch(0.245899 0.019144 42.044)`,foreground:`oklch(0.990339 0.008411 325.64)`,card:`oklch(0.245899 0.019144 42.044)`,"card-foreground":`oklch(0.990339 0.008411 325.64)`,popover:`oklch(0.401111 0.014308 34.896)`,"popover-foreground":`oklch(0.990339 0.008411 325.64)`,primary:`oklch(0.762174 0.124117 52.082)`,"primary-foreground":`oklch(0.222003 0.03479 328.979)`,secondary:`oklch(0.361499 0.044052 49.515)`,"secondary-foreground":`oklch(0.990339 0.008411 325.64)`,muted:`oklch(0.322144 0.03574 48.309)`,"muted-foreground":`oklch(0.692479 0.015227 30.963)`,accent:`oklch(0.416048 0.055354 50.484)`,"accent-foreground":`oklch(0.990339 0.008411 325.64)`,destructive:`oklch(0.655108 0.221148 23.473)`,border:`oklch(0.44099 0.040202 48.807)`,input:`oklch(0.503003 0.045721 49.44)`,ring:`oklch(0.762174 0.124117 52.082)`,"chart-1":`oklch(0.762174 0.124117 52.082)`}},{id:`iris`,name:`Iris`,light:{background:`oklch(0.976531 0.003855 303.226)`,foreground:`oklch(0.222003 0.03479 328.979)`,card:`oklch(0.976531 0.003855 303.226)`,"card-foreground":`oklch(0.222003 0.03479 328.979)`,popover:`oklch(0.936665 0.005041 310.132)`,"popover-foreground":`oklch(0.222003 0.03479 328.979)`,primary:`oklch(0.525348 0.15373 294.176)`,"primary-foreground":`oklch(0.990339 0.008411 325.64)`,secondary:`oklch(0.941387 0.014687 300.474)`,"secondary-foreground":`oklch(0.222003 0.03479 328.979)`,muted:`oklch(0.950194 0.011956 300.733)`,"muted-foreground":`oklch(0.529955 0.022319 321.556)`,accent:`oklch(0.914882 0.022965 299.986)`,"accent-foreground":`oklch(0.222003 0.03479 328.979)`,destructive:`oklch(0.637823 0.237287 25.436)`,border:`oklch(0.869608 0.018226 303.859)`,input:`oklch(0.834773 0.023405 303.676)`,ring:`oklch(0.525348 0.15373 294.176)`,"chart-1":`oklch(0.525348 0.15373 294.176)`},dark:{background:`oklch(0.225975 0.031062 293.741)`,foreground:`oklch(0.990339 0.008411 325.64)`,card:`oklch(0.225975 0.031062 293.741)`,"card-foreground":`oklch(0.990339 0.008411 325.64)`,popover:`oklch(0.386739 0.024023 297.509)`,"popover-foreground":`oklch(0.990339 0.008411 325.64)`,primary:`oklch(0.671712 0.169136 293.929)`,"primary-foreground":`oklch(0.222003 0.03479 328.979)`,secondary:`oklch(0.325405 0.063614 294.23)`,"secondary-foreground":`oklch(0.990339 0.008411 325.64)`,muted:`oklch(0.291515 0.05276 294.209)`,"muted-foreground":`oklch(0.663321 0.025932 301.862)`,accent:`oklch(0.372436 0.07841 294.204)`,"accent-foreground":`oklch(0.990339 0.008411 325.64)`,destructive:`oklch(0.655108 0.221148 23.473)`,border:`oklch(0.40874 0.058536 295.893)`,input:`oklch(0.46756 0.065775 296.265)`,ring:`oklch(0.671712 0.169136 293.929)`,"chart-1":`oklch(0.671712 0.169136 293.929)`}},{id:`slate`,name:`Slate`,light:{background:`#f5f7fa`,foreground:`#202b3b`,card:`#ffffff`,"card-foreground":`#202b3b`,popover:`#ffffff`,"popover-foreground":`#202b3b`,primary:`#465b78`,"primary-foreground":`#ffffff`,secondary:`#e7ecf2`,"secondary-foreground":`#202b3b`,muted:`#edf1f6`,"muted-foreground":`#526177`,accent:`#e0e7ef`,"accent-foreground":`#202b3b`,destructive:`#a52a34`,border:`#cad3df`,input:`#b9c5d4`,ring:`#465b78`,"chart-1":`#465b78`},dark:{background:`#141b26`,foreground:`#e8edf5`,card:`#1c2533`,"card-foreground":`#e8edf5`,popover:`#202b3b`,"popover-foreground":`#e8edf5`,primary:`#adc0dc`,"primary-foreground":`#141b26`,secondary:`#2a3648`,"secondary-foreground":`#e8edf5`,muted:`#243043`,"muted-foreground":`#afbdd0`,accent:`#33445d`,"accent-foreground":`#e8edf5`,destructive:`#fb8990`,border:`#43536a`,input:`#53647d`,ring:`#adc0dc`,"chart-1":`#adc0dc`}},{id:`sand`,name:`Sand`,light:{background:`#faf7f1`,foreground:`#352b22`,card:`#fffdf8`,"card-foreground":`#352b22`,popover:`#fffdf8`,"popover-foreground":`#352b22`,primary:`#765536`,"primary-foreground":`#ffffff`,secondary:`#eee6da`,"secondary-foreground":`#352b22`,muted:`#f2ece2`,"muted-foreground":`#6c5b49`,accent:`#e9ddcb`,"accent-foreground":`#352b22`,destructive:`#a52a34`,border:`#d9cbb8`,input:`#c9b79e`,ring:`#765536`,"chart-1":`#765536`},dark:{background:`#211c17`,foreground:`#f4ece0`,card:`#2c251e`,"card-foreground":`#f4ece0`,popover:`#352c23`,"popover-foreground":`#f4ece0`,primary:`#dcbc92`,"primary-foreground":`#211c17`,secondary:`#3c3227`,"secondary-foreground":`#f4ece0`,muted:`#352d24`,"muted-foreground":`#c9b9a5`,accent:`#4a3b2b`,"accent-foreground":`#f4ece0`,destructive:`#fb8990`,border:`#64503e`,input:`#79614b`,ring:`#dcbc92`,"chart-1":`#dcbc92`}},{id:`rosewood`,name:`Rosewood`,light:{background:`#fbf6f5`,foreground:`#3b262c`,card:`#fffafa`,"card-foreground":`#3b262c`,popover:`#fffafa`,"popover-foreground":`#3b262c`,primary:`#854252`,"primary-foreground":`#ffffff`,secondary:`#f0e2e5`,"secondary-foreground":`#3b262c`,muted:`#f5eaec`,"muted-foreground":`#76525d`,accent:`#edd6dd`,"accent-foreground":`#3b262c`,destructive:`#a52a34`,border:`#dfc5cc`,input:`#d0afb9`,ring:`#854252`,"chart-1":`#854252`},dark:{background:`#241a20`,foreground:`#f6e8ed`,card:`#30222a`,"card-foreground":`#f6e8ed`,popover:`#3a2932`,"popover-foreground":`#f6e8ed`,primary:`#e3a5b7`,"primary-foreground":`#241a20`,secondary:`#442e38`,"secondary-foreground":`#f6e8ed`,muted:`#3a2932`,"muted-foreground":`#d2b4c0`,accent:`#553441`,"accent-foreground":`#f6e8ed`,destructive:`#fb8990`,border:`#70505d`,input:`#856170`,ring:`#e3a5b7`,"chart-1":`#e3a5b7`}},{id:`aurora`,name:`Aurora`,light:{background:`#f2faf8`,foreground:`#193a37`,card:`#fafffe`,"card-foreground":`#193a37`,popover:`#fafffe`,"popover-foreground":`#193a37`,primary:`#216c63`,"primary-foreground":`#ffffff`,secondary:`#def0eb`,"secondary-foreground":`#193a37`,muted:`#e6f2ef`,"muted-foreground":`#456c66`,accent:`#eee5f6`,"accent-foreground":`#193a37`,destructive:`#a52a34`,border:`#bbd7d1`,input:`#a7c8c0`,ring:`#216c63`,"chart-1":`#216c63`},dark:{background:`#142321`,foreground:`#e1f5ef`,card:`#1d302d`,"card-foreground":`#e1f5ef`,popover:`#253d38`,"popover-foreground":`#e1f5ef`,primary:`#87d5c1`,"primary-foreground":`#142321`,secondary:`#29443e`,"secondary-foreground":`#e1f5ef`,muted:`#243c36`,"muted-foreground":`#a9cfc3`,accent:`#3d3352`,"accent-foreground":`#e1f5ef`,destructive:`#fb8990`,border:`#466b60`,input:`#568172`,ring:`#87d5c1`,"chart-1":`#87d5c1`}},{id:`midnight`,name:`Midnight`,light:{background:`#f5f6fb`,foreground:`#282e48`,card:`#fcfcff`,"card-foreground":`#282e48`,popover:`#fcfcff`,"popover-foreground":`#282e48`,primary:`#4f5f96`,"primary-foreground":`#ffffff`,secondary:`#e5e8f4`,"secondary-foreground":`#282e48`,muted:`#eceef7`,"muted-foreground":`#565f7d`,accent:`#dfe4f6`,"accent-foreground":`#282e48`,destructive:`#a52a34`,border:`#c7cee5`,input:`#b4bfdc`,ring:`#4f5f96`,"chart-1":`#4f5f96`},dark:{background:`#151a2b`,foreground:`#e8ecfa`,card:`#1f263b`,"card-foreground":`#e8ecfa`,popover:`#29314a`,"popover-foreground":`#e8ecfa`,primary:`#acbbed`,"primary-foreground":`#151a2b`,secondary:`#303954`,"secondary-foreground":`#e8ecfa`,muted:`#28314b`,"muted-foreground":`#b1bedf`,accent:`#3a466a`,"accent-foreground":`#e8ecfa`,destructive:`#fb8990`,border:`#48577d`,input:`#596990`,ring:`#acbbed`,"chart-1":`#acbbed`}},{id:`graphite`,name:`Graphite`,light:{background:`#fafafa`,foreground:`#222222`,card:`#fefefe`,"card-foreground":`#222222`,popover:`#fefefe`,"popover-foreground":`#222222`,primary:`#333333`,"primary-foreground":`#fcfcfc`,secondary:`#ebebeb`,"secondary-foreground":`#222222`,muted:`#f0f0f0`,"muted-foreground":`#5d5d5d`,accent:`#e8e8e8`,"accent-foreground":`#222222`,destructive:`#d02b31`,border:`#dedede`,input:`#cecece`,ring:`#333333`,"chart-1":`#333333`},dark:{background:`#121212`,foreground:`#eeeeee`,card:`#191919`,"card-foreground":`#eeeeee`,popover:`#202020`,"popover-foreground":`#eeeeee`,primary:`#e4e4e4`,"primary-foreground":`#121212`,secondary:`#292929`,"secondary-foreground":`#eeeeee`,muted:`#242424`,"muted-foreground":`#ababab`,accent:`#333333`,"accent-foreground":`#eeeeee`,destructive:`#f66c6d`,border:`#333333`,input:`#424242`,ring:`#e4e4e4`,"chart-1":`#e4e4e4`}},{id:`lagoon`,name:`Lagoon`,light:{background:`#f3fcfd`,foreground:`#0e2627`,card:`#fbffff`,"card-foreground":`#0e2627`,popover:`#fbffff`,"popover-foreground":`#0e2627`,primary:`#007780`,"primary-foreground":`#fcfcfc`,secondary:`#d5f2f3`,"secondary-foreground":`#0e2627`,muted:`#e3f4f5`,"muted-foreground":`#456466`,accent:`#c3f2f4`,"accent-foreground":`#0e2627`,destructive:`#d02b31`,border:`#cde3e4`,input:`#b8d4d5`,ring:`#007780`,"chart-1":`#007780`},dark:{background:`#041516`,foreground:`#e8f1f1`,card:`#091d1e`,"card-foreground":`#e8f1f1`,popover:`#102425`,"popover-foreground":`#e8f1f1`,primary:`#53c5cb`,"primary-foreground":`#041516`,secondary:`#162d2f`,"secondary-foreground":`#e8f1f1`,muted:`#152829`,"muted-foreground":`#9cafb0`,accent:`#0c3a3c`,"accent-foreground":`#e8f1f1`,destructive:`#f66c6d`,border:`#203839`,input:`#2f4749`,ring:`#53c5cb`,"chart-1":`#53c5cb`}},{id:`dune`,name:`Dune`,light:{background:`#fef9f3`,foreground:`#2b1f11`,card:`#fffefb`,"card-foreground":`#2b1f11`,popover:`#fffefb`,"popover-foreground":`#2b1f11`,primary:`#9d6300`,"primary-foreground":`#fcfcfc`,secondary:`#f9e8d6`,"secondary-foreground":`#2b1f11`,muted:`#f8eee4`,"muted-foreground":`#6b5a48`,accent:`#fde3c6`,"accent-foreground":`#2b1f11`,destructive:`#d02b31`,border:`#e9dccd`,input:`#dbcbb9`,ring:`#9d6300`,"chart-1":`#9d6300`},dark:{background:`#181006`,foreground:`#f3ede8`,card:`#21170c`,"card-foreground":`#f3ede8`,popover:`#291e12`,"popover-foreground":`#f3ede8`,primary:`#dba666`,"primary-foreground":`#181006`,secondary:`#322618`,"secondary-foreground":`#f3ede8`,muted:`#2c2217`,"muted-foreground":`#b4a99d`,accent:`#422e16`,"accent-foreground":`#f3ede8`,destructive:`#f66c6d`,border:`#3d3022`,input:`#4d4031`,ring:`#dba666`,"chart-1":`#dba666`}},{id:`plum`,name:`Plum`,light:{background:`#fef8ff`,foreground:`#291c2c`,card:`#fffdff`,"card-foreground":`#291c2c`,popover:`#fffdff`,"popover-foreground":`#291c2c`,primary:`#9553a4`,"primary-foreground":`#fcfcfc`,secondary:`#f6e4fa`,"secondary-foreground":`#291c2c`,muted:`#f7ecf9`,"muted-foreground":`#68566d`,accent:`#f9dcff`,"accent-foreground":`#291c2c`,destructive:`#d02b31`,border:`#e7d8ea`,input:`#d8c7dc`,ring:`#9553a4`,"chart-1":`#9553a4`},dark:{background:`#170d19`,foreground:`#f2ecf3`,card:`#201522`,"card-foreground":`#f2ecf3`,popover:`#271c2a`,"popover-foreground":`#f2ecf3`,primary:`#d398e0`,"primary-foreground":`#170d19`,secondary:`#312334`,"secondary-foreground":`#f2ecf3`,muted:`#2a202d`,"muted-foreground":`#b2a6b5`,accent:`#3f2945`,"accent-foreground":`#f2ecf3`,destructive:`#f66c6d`,border:`#3b2d3e`,input:`#4b3c4e`,ring:`#d398e0`,"chart-1":`#d398e0`}},{id:`moss`,name:`Moss`,light:{background:`#f8fcf6`,foreground:`#1c2517`,card:`#fdfffc`,"card-foreground":`#1c2517`,popover:`#fdfffc`,"popover-foreground":`#1c2517`,primary:`#4a7333`,"primary-foreground":`#fcfcfc`,secondary:`#e3f0dd`,"secondary-foreground":`#1c2517`,muted:`#ebf3e8`,"muted-foreground":`#56624f`,accent:`#dcefd2`,"accent-foreground":`#1c2517`,destructive:`#d02b31`,border:`#d8e2d3`,input:`#c6d2c0`,ring:`#4a7333`,"chart-1":`#4a7333`},dark:{background:`#0d140a`,foreground:`#ecf0ea`,card:`#151c11`,"card-foreground":`#ecf0ea`,popover:`#1b2317`,"popover-foreground":`#ecf0ea`,primary:`#97bf82`,"primary-foreground":`#0d140a`,secondary:`#232c1e`,"secondary-foreground":`#ecf0ea`,muted:`#1f271c`,"muted-foreground":`#a6aea1`,accent:`#293821`,"accent-foreground":`#ecf0ea`,destructive:`#f66c6d`,border:`#2d3628`,input:`#3c4637`,ring:`#97bf82`,"chart-1":`#97bf82`}},{id:`crimson`,name:`Crimson`,light:{background:`#fff7f6`,foreground:`#331919`,card:`#fffcfc`,"card-foreground":`#331919`,popover:`#fffcfc`,"popover-foreground":`#331919`,primary:`#c13a46`,"primary-foreground":`#fcfcfc`,secondary:`#ffe1df`,"secondary-foreground":`#331919`,muted:`#ffeae9`,"muted-foreground":`#785252`,accent:`#ffd7d5`,"accent-foreground":`#331919`,destructive:`#d02b31`,border:`#f4d6d5`,input:`#e9c3c2`,ring:`#c13a46`,"chart-1":`#c13a46`},dark:{background:`#1e0b0b`,foreground:`#f8ebeb`,card:`#281212`,"card-foreground":`#f8ebeb`,popover:`#301919`,"popover-foreground":`#f8ebeb`,primary:`#ff898b`,"primary-foreground":`#1e0b0b`,secondary:`#3b2020`,"secondary-foreground":`#f8ebeb`,muted:`#331d1d`,"muted-foreground":`#bea4a3`,accent:`#502324`,"accent-foreground":`#f8ebeb`,destructive:`#f66c6d`,border:`#462a2a`,input:`#573939`,ring:`#ff898b`,"chart-1":`#ff898b`}}],ae={light:{background:`#fcfcfc`,card:`#ffffff`,primary:`#1b4ed8`,accent:`#f4f4f5`},dark:{background:`#0a0a0a`,card:`#111111`,primary:`#346bf1`,accent:`#141414`}};function oe(e,t){let n=t?e.dark:e.light,r=ae[t?`dark`:`light`];return n?{background:n.background??r.background,card:n.card??r.card,primary:n.primary??r.primary,accent:n.primary?`color-mix(in oklab, ${n.primary} 18%, ${n.background??r.background})`:r.accent}:{...r}}var se={activity:400,thoughts:40,chat:100};function ce(e,t,n){let r=e??[],i=new Set(r.map(e=>e.id)),a=t.filter(e=>typeof e?.id==`number`&&!i.has(e.id));return[...r,...a].slice(-n)}var le=class{records=new Map;listeners=new Set;reads=new Map;used=new Set;reader;currentStatus={connection:`connecting`,signedOut:!1};get(e){let t=this.records.get(e);if(t)return t;let n={version:0,data:void 0,loading:!1,error:void 0,stale:!1};return this.records.set(e,n),n}status(){return{...this.currentStatus}}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}markUsed(e,t){this.reader=t;let n=e.filter(e=>!this.used.has(e));this.used=new Set(e);for(let e of n)this.read(e)}onHello(e){for(let t of this.used){let n=e[t];n!==void 0&&(this.get(t).version=n),this.read(t)}}onChanged(e,t){let n=this.get(e);n.version=t,this.used.has(e)?this.read(e):n.stale=!0,this.notify()}onFeedDelta(e){let t=this.get(`lobby`).data;t&&(this.get(`lobby`).data={...t,activity:ce(t.activity,e.activity??[],se.activity),thoughts:ce(t.thoughts,e.thoughts??[],se.thoughts),chat:ce(t.chat,e.chat??[],se.chat)},this.notify())}onReplyDelta(e){let t=this.get(`lobby`),n=t.data;n&&(t.data={...n,reply:e},this.notify())}onStatus(e){this.currentStatus={...this.currentStatus,...e},this.notify()}async read(e){let t=this.reader;if(!t)return;let n=(this.reads.get(e)??0)+1;this.reads.set(e,n);let r=this.get(e);r.loading=!0,r.error=void 0,this.notify();try{let i=await t(e);if(this.reads.get(e)!==n)return;this.apply(r,i)}catch(t){if(this.reads.get(e)!==n)return;r.loading=!1,r.error=t instanceof Error?t.message:String(t)}this.notify()}apply(e,t){e.data=t,e.loading=!1,e.stale=!1,e.error=void 0}notify(){for(let e of[...this.listeners])e()}};function ue(){return new le}var P=ue(),de=/^[a-f0-9]{32}$/;function fe(){return globalThis.location}function pe(){let e=fe()?.search??``,t=new URLSearchParams(e).getAll(`project`);if(t.length){if(t.length!==1||!de.test(t[0]))throw Error(`Invalid project ID. Choose a running project below.`);return t[0]}}function F(e){if(!e.startsWith(`/api/`)&&!e.startsWith(`/files/preview/`))return e;let t=pe();return t?`/projects/${t}${e}`:e}function I(e,t){if(!de.test(e))throw Error(`Invalid project ID.`);let n=fe();if(!n)throw Error(`Project switching requires a browser.`);let r=new URL(n.origin);r.pathname=n.pathname,r.searchParams.set(`project`,e),r.hash=`/${t}`,n.assign(r.href)}var me=`bot-lobby.projectFolders`,he=new Map;function ge(){try{return globalThis.sessionStorage}catch{return}}function _e(){try{let e=JSON.parse(ge()?.getItem(me)??`{}`);for(let[t,n]of Object.entries(e))de.test(t)&&typeof n==`string`&&he.set(t,n)}catch{}}function ve(e){_e();for(let t of e)de.test(t.id)&&he.set(t.id,t.cwd);try{ge()?.setItem(me,JSON.stringify(Object.fromEntries([...he].slice(-64))))}catch{}}function ye(e){return he.has(e)||_e(),he.get(e)}async function be(e){let t;try{t=pe()}catch{return!1}if(!t)return!1;let n=ye(t);if(!n)return!1;let{projects:r}=await e();if(ve(r),r.some(e=>e.id===t))return!1;let i=r.find(e=>e.cwd===n),a=fe(),o=globalThis.history;if(!i||!a||!o)return!1;let s=new URL(a.origin);return s.pathname=a.pathname,s.search=a.search,s.searchParams.set(`project`,i.id),s.hash=globalThis.location?.hash??``,o.replaceState(null,``,s.href),!0}var xe=class extends Error{code;status;constructor(e,t,n){super(e),this.name=`ApiError`,this.code=t,this.status=n}},Se={"Content-Type":`application/json`};async function L(e,t={}){let n=await fetch(e===`auth.login`||e.startsWith(`projects.`)?`/api/${e}`:F(`/api/${e}`),{method:`POST`,headers:Se,body:JSON.stringify(t),credentials:`same-origin`}),r=await n.json().catch(()=>void 0);if(!r)throw new xe(`the lobby answered ${n.status}`,`failed`,n.status);if(!r.ok)throw r.code===`unauthorized`&&P.onStatus({signedOut:!0}),new xe(r.error,r.code,n.status);return r.result}function Ce(){return globalThis.location}async function we(){let e=Ce(),t=e?new URLSearchParams(e.hash.replace(/^#/,``)).get(`token`):null;if(!t||!(await fetch(`/api/auth.login`,{method:`POST`,headers:Se,body:JSON.stringify({token:t}),credentials:`same-origin`}).catch(()=>void 0))?.ok)return!1;let n=globalThis.history;return n&&n.replaceState(null,``,e.pathname+e.search),P.onStatus({signedOut:!1}),!0}var Te=`bot-lobby.palette`,Ee=`bot-lobby-palette`,De=`custom`,Oe=new Set,ke=je();function Ae(e){let t=e;if(!t||typeof t.id!=`string`||typeof t.name!=`string`)return;let n=ee(t.light),r=ee(t.dark);if(n||r)return{id:t.id,name:t.name.slice(0,40),...n?{light:n}:{},...r?{dark:r}:{}}}function je(){try{let e=localStorage.getItem(Te);if(!e)return{id:re,saved:[]};let t=JSON.parse(e),n=(t.saved??[]).map(Ae).filter(e=>!!e),r=Ae(t.legacy??(t.custom?{...t.custom,id:De}:void 0)),i=new Set([...ie.map(e=>e.id),...n.map(e=>e.id),...r?[De]:[]]);return{id:t.id&&i.has(t.id)?t.id:re,saved:n,...r?{legacy:r}:{}}}catch{return{id:re,saved:[]}}}function Me(e){return[...ie,...e.saved,...e.legacy?[e.legacy]:[]]}function Ne(e){return Me(e).find(t=>t.id===e.id)??ie[0]}function Pe(){if(typeof document>`u`)return;let e=N(Ne(ke)),t=document.getElementById(Ee);if(!e){t?.remove();return}t||(t=document.createElement(`style`),t.id=Ee,document.head.appendChild(t)),t.textContent=e}function Fe(e){ke=e;try{localStorage.setItem(Te,JSON.stringify(e))}catch{}Pe();for(let e of[...Oe])e()}function Ie(e){let t=e.themes.map(e=>Ae(e)).filter(e=>!!e),{legacy:n}=ke;Fe({id:e.active??(ke.id===De&&n?De:`mist`),saved:t,...n?{legacy:n}:{}})}var Le;function Re(e=!1){return Le&&!e||(Le=(async()=>{let e=await L(`themes.get`,{}),t=ke.legacy;if(t){let n=e.active??(ke.id===De?void 0:ke.id);e=await L(`themes.save`,{name:t.name,...t.light?{light:t.light}:{},...t.dark?{dark:t.dark}:{}}),n&&(e=await L(`themes.choose`,{id:n}));let{legacy:r,...i}=ke;ke=i}Ie(e)})().catch(()=>{Le=void 0})),Le}typeof window<`u`&&(Pe(),window.addEventListener(`storage`,e=>{if(e.key===Te){ke=je(),Pe();for(let e of[...Oe])e()}}),window.addEventListener(`focus`,()=>void Re(!0)));function ze(e){return Oe.add(e),()=>{Oe.delete(e)}}function Be(){let e=(0,m.useSyncExternalStore)(ze,()=>ke,()=>ke),t=(0,m.useCallback)(e=>{Fe({...ke,id:e}),e!==De&&L(`themes.choose`,{id:e}).then(Ie,()=>{})},[]),n=(0,m.useCallback)(async(e,t)=>(Ie(await L(`themes.save`,{name:t,...e.light?{light:e.light}:{},...e.dark?{dark:e.dark}:{}})),Ne(ke)),[]),r=(0,m.useCallback)(async(e,t)=>Ie(await L(`themes.rename`,{id:e,name:t})),[]),i=(0,m.useCallback)(async e=>Ie(await L(`themes.remove`,{id:e})),[]),a=e.legacy?[...e.saved,e.legacy]:e.saved;return{active:Ne(e),saved:a,all:Me(e),isSaved:e=>a.some(t=>t.id===e),choose:t,adopt:n,rename:r,remove:i}}var Ve=[{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`}],He=[{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`}],Ue={font:`bot-lobby.typeface`,mono:`bot-lobby.typeface-code`},We={font:Ve,mono:He},Ge={font:`theme`,mono:`theme`},Ke=new Set;function qe(e){let t=null;try{t=localStorage.getItem(Ue[e])}catch{t=Ge[e]}return We[e].some(e=>e.id===t)?t:`theme`}function Je(e,t){let n=document.documentElement;t===`theme`?delete n.dataset[e]:n.dataset[e]=t}function Ye(e,t){Ge[e]=t;try{localStorage.setItem(Ue[e],t)}catch{}Je(e,t);for(let e of Ke)e()}function Xe(e){return Ke.add(e),()=>Ke.delete(e)}function Ze(e){return(0,m.useSyncExternalStore)(Xe,()=>qe(e),()=>`theme`)}typeof document<`u`&&(Je(`font`,qe(`font`)),Je(`mono`,qe(`mono`)));var Qe={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`},$e=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),et=o(((e,t)=>{t.exports=$e()})),tt=(0,m.createContext)({});function nt(e){let t=(0,m.useRef)(null);return t.current===null&&(t.current=e()),t.current}var rt=typeof window<`u`?m.useLayoutEffect:m.useEffect,it=(0,m.createContext)(null);function at(e,t){e.indexOf(t)===-1&&e.push(t)}function ot(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var st=(e,t,n)=>n>t?t:n<e?e:n,ct={},lt=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),ut=e=>typeof e==`object`&&!!e,dt=e=>/^0[^.\s]+$/u.test(e);function ft(e){let t;return()=>(t===void 0&&(t=e()),t)}var pt=e=>e,mt=(...e)=>e.reduce((e,t)=>n=>t(e(n))),ht=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},gt=class{constructor(){this.subscriptions=[]}add(e){return at(this.subscriptions,e),()=>this.remove(e)}remove(e){ot(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}},_t=e=>e*1e3,vt=e=>e/1e3,yt=(e,t)=>t?1e3/t*e:0,bt=(e,t,n)=>{let r=t-e;return((n-e)%r+r)%r+e},xt=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,St=1e-7,Ct=12;function wt(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=xt(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>St&&++s<Ct);return o}function Tt(e,t,n,r){if(e===t&&n===r)return pt;let i=t=>wt(t,0,1,e,n);return e=>e===0||e===1?e:xt(i(e),t,r)}var Et=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Dt=e=>t=>1-e(1-t),Ot=Tt(.33,1.53,.69,.99),kt=Dt(Ot),At=Et(kt),jt=e=>e>=1?1:(e*=2)<1?.5*kt(e):.5*(2-2**(-10*(e-1))),Mt=e=>1-Math.sin(Math.acos(e)),Nt=Dt(Mt),Pt=Et(Mt),Ft=Tt(.42,0,1,1),It=Tt(0,0,.58,1),Lt=Tt(.42,0,.58,1),Rt=e=>Array.isArray(e)&&typeof e[0]!=`number`;function zt(e,t){return Rt(e)?e[bt(0,e.length,t)]:e}var Bt=e=>Array.isArray(e)&&typeof e[0]==`number`,Vt={linear:pt,easeIn:Ft,easeInOut:Lt,easeOut:It,circIn:Mt,circInOut:Pt,circOut:Nt,backIn:kt,backInOut:At,backOut:Ot,anticipate:jt},Ht=e=>typeof e==`string`,Ut=e=>{if(Bt(e)){e.length;let[t,n,r,i]=e;return Tt(t,n,r,i)}return Ht(e)?(Vt[e],`${e}`,Vt[e]):e},Wt={delta:0,timestamp:0,isProcessing:!1},Gt;function Kt(){Gt=void 0}var qt={now:()=>(Gt===void 0&&qt.set(Wt.isProcessing||ct.useManualTiming?Wt.timestamp:performance.now()),Gt),set:e=>{Gt=e,queueMicrotask(Kt)}},Jt=e=>Math.round(e*1e5)/1e5,Yt=e=>t=>typeof t==`string`&&t.startsWith(e),Xt=Yt(`--`),Zt=Yt(`var(--`),Qt=e=>Zt(e)?$t.test(e.split(`/*`)[0].trim()):!1,$t=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function en(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var tn={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},nn={...tn,transform:e=>st(0,1,e)},rn={...tn,default:1},an=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function on(e){return e==null}var sn=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,cn=(e,t)=>n=>!!(typeof n==`string`&&sn.test(n)&&n.startsWith(e)||t&&!on(n)&&Object.prototype.hasOwnProperty.call(n,t)),ln=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(an);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},un=e=>st(0,255,e),dn={...tn,transform:e=>Math.round(un(e))},fn={test:cn(`rgb`,`red`),parse:ln(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+dn.transform(e)+`, `+dn.transform(t)+`, `+dn.transform(n)+`, `+Jt(nn.transform(r))+`)`};function pn(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 mn={test:cn(`#`),parse:pn,transform:fn.transform},hn=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),gn=hn(`deg`),_n=hn(`%`),R=hn(`px`),vn=hn(`vh`),yn=hn(`vw`),bn={..._n,parse:e=>_n.parse(e)/100,transform:e=>_n.transform(e*100)},xn={test:cn(`hsl`,`hue`),parse:ln(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+_n.transform(Jt(t))+`, `+_n.transform(Jt(n))+`, `+Jt(nn.transform(r))+`)`},Sn={test:e=>fn.test(e)||mn.test(e)||xn.test(e),parse:e=>fn.test(e)?fn.parse(e):xn.test(e)?xn.parse(e):mn.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?fn.transform(e):xn.transform(e),getAnimatableNone:e=>{let t=Sn.parse(e);return t.alpha=0,Sn.transform(t)}},Cn=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,wn=new RegExp(an.source),Tn=new RegExp(Cn.source,`i`);function En(e){return isNaN(e)&&typeof e==`string`&&(wn.test(e)||Tn.test(e))}var Dn=`number`,On=`color`,kn=`var`,An=`var(`,jn="${}",Mn=/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 Nn(e){let t=e.toString();return wn.test(t)||Tn.test(t)}function Pn(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(Mn,e=>(Sn.test(e)?(r.color.push(a),i.push(On),n.push(Sn.parse(e))):e.startsWith(An)?(r.var.push(a),i.push(kn),n.push(e)):(r.number.push(a),i.push(Dn),n.push(parseFloat(e))),++a,jn)).split(jn),indexes:r,types:i}}function Fn(e){return Pn(e).values}function In({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===Dn?Jt(r[a]):e===On?Sn.transform(r[a]):r[a]}return i}}function Ln(e){return In(Pn(e))}var Rn=e=>typeof e==`number`?0:Sn.test(e)?Sn.getAnimatableNone(e):e,zn=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:Rn(e);function Bn(e){let t=Pn(e);return In(t)(t.values.map((e,n)=>zn(e,t.split[n])))}var Vn={test:En,parse:Fn,createTransformer:Ln,getAnimatableNone:Bn};function Hn(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 Un({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=Hn(s,r,e+1/3),a=Hn(s,r,e),o=Hn(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function Wn(e,t){return n=>n>0?t:e}var Gn=(e,t,n)=>e+(t-e)*n,Kn=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},qn=[mn,fn,xn],Jn=e=>qn.find(t=>t.test(e));function Yn(e){let t=Jn(e);if(!t)return`${e}`,!1;let n=t.parse(e);return t===xn&&(n=Un(n)),n}var Xn=(e,t)=>{let n=Yn(e),r=Yn(t);if(!n||!r)return Wn(e,t);let i={...n};return e=>(i.red=Kn(n.red,r.red,e),i.green=Kn(n.green,r.green,e),i.blue=Kn(n.blue,r.blue,e),i.alpha=Gn(n.alpha,r.alpha,e),fn.transform(i))},Zn=new Set([`none`,`hidden`]);function Qn(e,t){return Zn.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function $n(e,t){return n=>Gn(e,t,n)}function er(e){return typeof e==`number`?$n:typeof e==`string`?Qt(e)?Wn:Sn.test(e)?Xn:ir:Array.isArray(e)?tr:typeof e==`object`?Sn.test(e)?Xn:nr:Wn}function tr(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>er(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function nr(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=er(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function rr(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 ir=(e,t)=>{let n=Vn.createTransformer(t),r=Pn(e),i=Pn(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?Zn.has(e)&&!i.values.length||Zn.has(t)&&!r.values.length?Qn(e,t):mt(tr(rr(r,i),i.values),n):(`${e}${t}`,Wn(e,t))},ar=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]*)$/iu;function or(e,t){let n=ar.exec(e);if(!n)return;let r=ar.exec(t);if(!r||n[2]!==r[2])return;let i=n[2],a=parseFloat(n[1]),o=parseFloat(r[1]);return e=>Jt(Gn(a,o,e))+i}function sr(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return Gn(e,t,n);if(typeof e==`string`&&typeof t==`string`){let n=or(e,t);if(n)return n}return er(e)(e,t)}var cr=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function lr(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 ur=40;function dr(e,t,n={delta:0,timestamp:0,isProcessing:!1}){let r=!1,i=!0,a=()=>r=!0,o=cr.reduce((e,t)=>(e[t]=lr(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=ct.useManualTiming,o=a?n.timestamp:performance.now();r=!1,a||(n.delta=i?1e3/60:Math.max(Math.min(o-n.timestamp,ur),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:cr.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<cr.length;t++)o[cr[t]].cancel(e)},state:n,steps:o}}var{schedule:fr,cancel:pr,steps:mr}=dr(typeof requestAnimationFrame<`u`?requestAnimationFrame:pt,!0,Wt),hr=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>fr.update(t,e),stop:()=>pr(t),now:()=>Wt.isProcessing?Wt.timestamp:qt.now()}},gr=(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)})`},_r=2e4;function vr(e,t=50,n=_r,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 yr(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(vr(r),_r);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:vt(i)}}var br={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},xr=e=>e<0?1/Math.max(1+e,br.minDamping):Math.max(1-e,br.minDamping);function Sr(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 Tr(e=>i*Math.exp(-r*e)-r*Math.exp(-i*e)-a,e=>Math.exp(-i*e)-Math.exp(-r*e),t)/t}function Cr(e,t){return e*Math.sqrt(1-t*t)}var wr=12;function Tr(e,t,n){let r=n;for(let n=1;n<wr;n++)r-=e(r)/t(r);return r}var Er=.001;function Dr({duration:e=br.duration,bounce:t=br.bounce}){let n,r;br.maxDuration;let i=xr(t);e=st(br.minDuration,br.maxDuration,vt(e)),i<1?(n=t=>{let n=t*i,r=n*e,a=Cr(t,i),o=Math.exp(-r);return Er-n/a*o},r=t=>{let r=t*i*e,a=i*i*t*t*e,o=Math.exp(-r),s=Cr(t*t,i);return(-n(t)+Er>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=Tr(n,r,a),s=o*Sr(i,o*e),c=s*s;return{stiffness:c,damping:i*2*Math.sqrt(c),duration:_t(e)}}var Or=(e,t)=>(t?e>=0:e>0)&&e<1/0;function kr(e,t){if(Or(e,t))return e}function Ar(e){let t=kr(e.stiffness),n=kr(e.damping,!0),r=kr(e.mass),i={...e,stiffness:t??br.stiffness,damping:n??br.damping,mass:r??br.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=xr(e.bounce||0),n=2*Math.PI/(e.visualDuration*1.2)*Sr(t,2*Math.PI/1.2);i.stiffness=n*n,i.damping=2*t*Math.sqrt(i.stiffness)}else Object.assign(i,Dr(i)),i.isResolvedFromDuration=!0;(!Or(i.stiffness)||!Or(i.damping,!0))&&(i.stiffness=br.stiffness,i.damping=br.damping)}return i}function jr(e=br.visualDuration,t=br.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}=Ar({...n}),f=e=>d?0:-vt(e),p=s/(2*Math.sqrt(o*c)),m=vt(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?br.restSpeed.granular:br.restSpeed.default),g.restDelta=n.restDelta||(e?br.restDelta.granular:br.restDelta.default)};_();let v,y,b;if(p<1){let e=Cr(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=>_t(y(e)),next:e=>{let t=v(e);if(u)a.done=e>=l;else{let n=_t(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(vr(S),_r),t=gr(t=>S.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return S}jr.applyToOptions=e=>{let t=yr(e,100,jr);return e.ease=t.ease,e.duration=_t(t.duration),e.type=`keyframes`,e};function Mr({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=jr({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 Nr(e,t,n){let r=[],i=n||ct.mix||sr,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=mt(Array.isArray(t)?t[n]||pt:t,a)),r.push(a)}return r}function Pr(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=Nr(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=ht(e[r],e[r+1],n);return s[r](i)};return n?t=>l(st(e[0],e[a-1],t)):l}function Fr(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=ht(0,t,r);e.push(Gn(n,1,i))}}function Ir(e){let t=[0];return Fr(t,e.length-1),t}function Lr(e,t){return e.map(e=>e*t)}function Rr(e,t){return e.map(()=>t||Lt).splice(0,e.length-1)}function zr({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=Rt(r)?r.map(Ut):Ut(r)||Lt,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:(ct.mix||sr)(n,r);return{calculatedDuration:e,next:t=>(a.value=o?o(i(e>0?st(0,1,t/e):1)):r,a.done=t>=e,a)}}let o=Pr(Lr(n&&n.length===t.length?n:Ir(t),e),t,{ease:Array.isArray(i)?i:Rr(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var Br=5;function Vr(e,t,n){let r=Math.max(t-Br,0);return yt(n-e(r),t-r)}function Hr(e,t,n=0){return t<=0?n:e.velocity?e.velocity(t):Vr(t=>e.next(t).value,t,e.next(t).value)}var Ur=e=>e!==null;function Wr(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(Ur),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var Gr={decay:Mr,inertia:Mr,tween:zr,keyframes:zr,spring:jr};function Kr(e){typeof e.type==`string`&&(e.type=Gr[e.type])}function qr(e,t){return{kind:e,animation:t,timestamp:qt.now(),frameTimestamp:Wt.timestamp,frameIsProcessing:Wt.isProcessing}}function Jr(e,t,n){let r=globalThis.__MOTION_INSPECT__;if(r)try{r({...qr(`animation-start`,e),options:n?{...t,...n}:t})}catch{}}function Yr(e,t){let n=globalThis.__MOTION_INSPECT__;if(n)try{n({...qr(`layout-animation-start`,e),node:t})}catch{}}var Xr=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)}},Zr=e=>e/100,Qr=class extends Xr{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!==qt.now()&&this.tick(qt.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause(),Jr(this,this.options)}initAnimation(){let{options:e}=this;Kr(e);let{type:t=zr,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||zr;s!==zr&&typeof o[0]!=`number`&&(this.mixKeyframes=mt(Zr,sr(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=vr(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=st(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!==Mr&&(b.value=Wr(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 vt(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+vt(e)}get time(){return vt(this.currentTime)}set time(e){e=_t(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 Hr(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(qt.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=vt(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=hr,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(qt.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)}},$r=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function ei(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(an)||[];if(!r)return e;let i=n.replace(r,``),a=+!!$r.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var ti=/\b([a-z-]*)\(.*?\)/gu,ni={...Vn,getAnimatableNone:e=>{let t=e.match(ti);return t?t.map(ei).join(` `):e}},ri={...Vn,getAnimatableNone:e=>{let t=Vn.parse(e);return Vn.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},ii={...tn,transform:Math.round},ai={rotate:gn,pathRotation:gn,rotateX:gn,rotateY:gn,rotateZ:gn,scale:rn,scaleX:rn,scaleY:rn,scaleZ:rn,skew:gn,skewX:gn,skewY:gn,distance:R,translateX:R,translateY:R,translateZ:R,x:R,y:R,z:R,perspective:R,transformPerspective:R,opacity:nn,originX:bn,originY:bn,originZ:R},oi={borderWidth:R,borderTopWidth:R,borderRightWidth:R,borderBottomWidth:R,borderLeftWidth:R,borderRadius:R,borderTopLeftRadius:R,borderTopRightRadius:R,borderBottomRightRadius:R,borderBottomLeftRadius:R,width:R,maxWidth:R,height:R,maxHeight:R,top:R,right:R,bottom:R,left:R,inset:R,insetBlock:R,insetBlockStart:R,insetBlockEnd:R,insetInline:R,insetInlineStart:R,insetInlineEnd:R,padding:R,paddingTop:R,paddingRight:R,paddingBottom:R,paddingLeft:R,paddingBlock:R,paddingBlockStart:R,paddingBlockEnd:R,paddingInline:R,paddingInlineStart:R,paddingInlineEnd:R,margin:R,marginTop:R,marginRight:R,marginBottom:R,marginLeft:R,marginBlock:R,marginBlockStart:R,marginBlockEnd:R,marginInline:R,marginInlineStart:R,marginInlineEnd:R,fontSize:R,backgroundPositionX:R,backgroundPositionY:R,...ai,zIndex:ii,fillOpacity:nn,strokeOpacity:nn,numOctaves:ii},si={...oi,color:Sn,backgroundColor:Sn,outlineColor:Sn,fill:Sn,stroke:Sn,borderColor:Sn,borderTopColor:Sn,borderRightColor:Sn,borderBottomColor:Sn,borderLeftColor:Sn,filter:ni,WebkitFilter:ni,mask:ri,WebkitMask:ri},ci=e=>si[e],li=new Set([ni,ri]);function ui(e,t){let n=ci(e);return li.has(n)||(n=Vn),n.getAnimatableNone?n.getAnimatableNone(t):void 0}function di(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var fi=e=>e*180/Math.PI,pi=e=>hi(fi(Math.atan2(e[1],e[0]))),mi={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:pi,rotateZ:pi,skewX:e=>fi(Math.atan(e[1])),skewY:e=>fi(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},hi=e=>(e%=360,e<0&&(e+=360),e),gi=pi,_i=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),vi=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),yi={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:_i,scaleY:vi,scale:e=>(_i(e)+vi(e))/2,rotateX:e=>hi(fi(Math.atan2(e[6],e[5]))),rotateY:e=>hi(fi(Math.atan2(-e[2],e[0]))),rotateZ:gi,rotate:gi,skewX:e=>fi(Math.atan(e[4])),skewY:e=>fi(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function bi(e){return+!!e.includes(`scale`)}function xi(e,t){if(!e||e===`none`)return bi(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=yi,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=mi,i=t}if(!i)return bi(t);let a=r[t],o=i[1].split(`,`).map(Ci);return typeof a==`function`?a(o):o[a]}var Si=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return xi(n,t)};function Ci(e){return parseFloat(e.trim())}var wi=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],Ti=new Set([...wi,`pathRotation`]),Ei=e=>e===tn||e===R,Di=new Set([`x`,`y`,`z`]),Oi=wi.filter(e=>!Di.has(e));function ki(e){let t=[];return Oi.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 Ai=new Set([`bottom`,`right`]);function ji(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 Mi={width:({width:e,paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r},i)=>ji(e,i,`x`,t,n,r),height:({height:e,paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r},i)=>ji(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})=>xi(e,`x`),y:({transform:e})=>xi(e,`y`)};Mi.translateX=Mi.x,Mi.translateY=Mi.y;var Ni=new Set,Pi=!1,Fi=!1,Ii=!1;function Li(){if(Fi){let e=[],t=new Set,n=new Set;Ni.forEach(r=>{r.needsMeasurement&&(e.push(r),t.add(r.element),Ai.has(r.name)&&n.add(r.element))});let r=new Map;n.forEach(e=>{let t=ki(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)})}Fi=!1,Pi=!1,Ni.forEach(e=>e.complete(Ii)),Ni.clear()}function Ri(){Ni.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Fi=!0)})}function zi(){Ii=!0,Ri(),Li(),Ii=!1}function Bi(e,t,n){if(typeof e==`string`){if(lt(e)||dt(e))return parseFloat(e);if(!Vn.test(e)&&Vn.test(n))return ui(t,n)}return e??void 0}var Vi=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?(Ni.add(this),Pi||(Pi=!0,fr.read(Ri),fr.resolveKeyframes(Li))):(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=Bi(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])}di(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Ni.delete(this)}cancel(){this.state===`scheduled`&&(Ni.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},Hi=e=>e.startsWith(`--`);function Ui(e,t,n){Hi(t)?e.style.setProperty(t,n):e.style[t]=n}var Wi={};function Gi(e,t){let n=ft(e);return()=>Wi[t]??n()}var Ki=Gi(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),qi=Gi(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),Ji=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Yi={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:Ji([0,.65,.55,1]),circOut:Ji([.55,0,1,.45]),backIn:Ji([.31,.01,.66,-.59]),backOut:Ji([.33,1.53,.69,.99])};function Xi(e,t){if(e)return typeof e==`function`?qi()?gr(e,t):`ease-out`:Bt(e)?Ji(e):Array.isArray(e)?e.map(e=>Xi(e,t)||Yi.easeOut):Yi[e]}function Zi(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=Xi(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 Qi(e){return typeof e==`function`&&`applyToOptions`in e}function $i({type:e,...t}){return Qi(e)&&qi()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var ea=class extends Xr{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=$i(e);this.animation=Zi(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=Wr(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),Ui(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()},Jr(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 vt(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+vt(e)}get time(){return vt(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=_t(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&&Ki()?(this.animation.timeline=e,t?.(this.animation),pt):n(this)}},ta={anticipate:jt,backInOut:At,circInOut:Pt};function na(e){return e in ta}function ra(e){typeof e.ease==`string`&&na(e.ease)&&(e.ease=ta[e.ease])}var z=10,ia=class extends ea{constructor(e){ra(e),Kr(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 Qr({...a,autoplay:!1}),s=Math.max(z,qt.now()-this.startTime),c=st(0,z,s-z),l=o.sample(s).value,{name:u}=this.options;i&&u&&Ui(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},aa=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(Vn.test(e)||e===`0`)&&!e.startsWith(`url(`));function oa(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 sa(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=aa(i,t),s=aa(a,t);return!o||!s?(o!==s&&`${t}${i}${a}${o?a:i}`,!1):oa(e)||(n===`spring`||Qi(n))&&r}function ca(e){e.duration=0,e.type=`keyframes`}var la=new Set([`opacity`,`clipPath`,`filter`,`transform`,`backgroundColor`]),ua=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function da(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&ua.test(e[t]))return!0;return!1}var fa=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),pa=ft(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function ma(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!n||!(la.has(n)||fa.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 pa()&&(la.has(n)||fa.has(n)&&da(s))&&(n!==`transform`||!u)&&!l&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var ha=40,ga=class extends Xr{constructor(e){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=qt.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||Vi;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=qt.now();let u=!0;sa(e,i,a,o)||(u=!1,(ct.instantAnimations||!s)&&l?.(Wr(e,n,t)),e[0]=e[e.length-1],ca(n),n.repeat=0);let d=r?this.resolvedAt&&this.resolvedAt-this.createdAt>ha?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&&ma(n),m;if(p){n.element=n.motionValue?.owner?.current;try{m=new ia(n)}catch{m=new Qr(n)}}else m=new Qr(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(),zi()),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()}},_a=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 va(this.animations,`duration`)}get iterationDuration(){return va(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 va(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 ya=class extends _a{then(e,t){return this.finished.finally(e).then(()=>{})}};function ba(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 xa=30,Sa=e=>!isNaN(parseFloat(e)),Ca={current:void 0},wa=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=qt.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=qt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Sa(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 gt)).add(t)}onChangeSubscribe(e){let{events:t}=this;return!t.change&&!this.changeSubscriber?this.changeSubscriber=e:(t.change||(t.change=new gt,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(){fr.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 Ca.current&&Ca.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=qt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>xa)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,xa);return yt(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 Ta(e,t){return new wa(e,t)}function Ea(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function Da(e,t){let n=e?.[t]??e?.default??e;return n===e?n:Ea(n,e)}var Oa={type:`spring`,stiffness:500,damping:25,restSpeed:10},ka=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Aa={type:`keyframes`,duration:.8},ja={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Ma=(e,{keyframes:t})=>t.length>2?Aa:Ti.has(e)?e.startsWith(`scale`)?ka(t[1]):Oa:ja,Na=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function Pa(e){for(let t in e)if(!Na.has(t))return!0;return!1}var Fa=(e,t,n,r={},i,a)=>o=>{let s=Da(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=_t(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};Pa(s)||Object.assign(u,Ma(e,u)),u.duration&&=_t(u.duration),u.repeatDelay&&=_t(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(ca(u),u.delay===0&&(d=!0)),(ct.instantAnimations||ct.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,ca(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=Wr(u.keyframes,s);if(e!==void 0){fr.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new Qr(u):new ga(u)},Ia=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function La(e){let t=Ia.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function Ra(e,t,n=1){`${e}`;let[r,i]=La(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return lt(e)?parseFloat(e):e}return Qt(i)?Ra(i,t,n+1):i}function za(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Ba(e,t,n,r){let i=t=>typeof t==`function`?t(n===void 0?e.custom:n,...za(r)):t;return t=i(t),typeof t==`string`&&(t=e.variants&&e.variants[t]),i(t)}function Va(e,t,n){return Ba(e.getProps(),t,n,e)}var Ha=(e,t)=>t===`exit`?e.presenceContext?.custom:void 0,Ua=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...wi]),Wa=e=>Array.isArray(e);function Ga(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Ta(n))}function Ka(e){return Wa(e)?e[e.length-1]||0:e}function qa(e,t){let{transitionEnd:n={},transition:r={},...i}=Va(e,t)||{};i={...i,...n};for(let t in i)Ga(e,t,Ka(i[t]))}var Ja=e=>!!(e&&e.getVelocity);function Ya(e){return!!(Ja(e)&&e.add)}function Xa(e,t){let n=e.getValue(`willChange`);if(Ya(n))return n.add(t);if(!n&&ct.WillChange){let n=new ct.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function Za(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var Qa=`data-`+Za(`framerAppearId`);function $a(e){return e.props[Qa]}var eo=typeof window<`u`;function to({protectedKeys:e,needsAnimating:t},n){let r=n in e&&!t[n];return t[n]=!1,r}function no(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?Ea(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&&to(f,t))continue;let o={delay:n,...Da(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){fr.update(()=>r.set(i));continue}let p=!1;if(eo&&window.MotionHandoffAnimation){let n=$a(e);if(n){let e=window.MotionHandoffAnimation(n,t,fr);e!==null&&(o.startTime=e,p=!0)}}Xa(e,t);let m=l??e.shouldReduceMotion;r.start(Fa(t,r,i,m&&Ua.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>fr.update(()=>{o&&qa(e,o)});d.length?Promise.all(d).then(t):t()}return d}function ro(e,t,n={}){let r=Va(e,t,Ha(e,n.type)),i=n.transitionOverride||(r?.transition??(e.getDefaultTransition()||{})),a=()=>Promise.all(r?no(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(ro(e,t,{...n,delay:r+(typeof o==`function`?0:o)+ba(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 io(e,t,n={}){return e.notify(`AnimationStart`,t),(Array.isArray(t)?Promise.all(t.map(t=>ro(e,t,n))):typeof t==`string`?ro(e,t,n):Promise.all(no(e,Va(e,t,n.custom),n))).then(()=>{e.notify(`AnimationComplete`,t)})}var ao={test:e=>e===`auto`,parse:e=>e},oo=e=>t=>t.test(e),so=[tn,R,_n,gn,yn,vn,ao],co=e=>so.find(oo(e));function lo(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||dt(e)}var uo=new Set([`auto`,`none`,`0`]);function fo(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!uo.has(t)&&Nn(t)&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]!==i&&(e[r]=ui(n,i))}var po=class extends Vi{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(),Qt(r))){let i=Ra(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Ua.has(n)||e.length!==2)return;let[r,i]=e;if(typeof r==`number`&&typeof i==`number`)return;let a=co(r),o=co(i);if(en(r)!==en(i)&&Mi[n]){this.needsMeasurement=!0;return}if(a!==o){if(Ei(a)&&Ei(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else Mi[n]&&(this.needsMeasurement=!0)}}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||lo(e[t]))&&n.push(t);n.length&&fo(e,n,t)}measure(){let{element:e,name:t}=this;return Mi[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()}},mo=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`],ho=[];function go(e){typeof e.test==`function`&&e.read,_o(e),ho.unshift(e)}function _o(e){ot(ho,e)}function vo(e){return ho.find(t=>t.test(e))}function yo(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){fr.update(()=>l.set(c));continue}l.start(Fa(s,l,c,o&&Ua.has(s)?{type:!1}:n,r)),l.animation&&i.push(l.animation)}let{transitionEnd:s}=t;if(s){let t=()=>fr.update(()=>{for(let t in s)e(t).set(s[t])});i.length?Promise.all(i).then(t):t()}return i}function bo(e,t,n,r,i){return yo(r=>{let a=e.get(t,r);if(!a){let o;if(!i){let i=n[r];o=xo(i)??e.read(t,r,i),`${r}`}a=Ta(o,{owner:i}),e(t,{[r]:a})}return a},n,r,i)}function xo(e){let t=Array.isArray(e)?e[0]:void 0;return t===null?void 0:t}function So(e){return ut(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}function Co(e){return ut(e)&&`ownerSVGElement`in e}var wo=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function To(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 Eo=class{constructor(e=fr.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 Do(e,{step:t,...n}={}){let r=new WeakMap;return Object.assign((n,i)=>{let a=r.get(n)??new Eo(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 Oo={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},ko={};function Ao(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&&` `)+(ko[i]||(ko[i]=(Oo[i]||i)+`(`))+wo(a,ai[i])+`)`)}let i=e.get(`pathRotation`)?.get();return i&&(t+=(t&&` `)+`rotate(`+wo(i,ai.pathRotation)+`)`),t||`none`}var jo=new Set([`originX`,`originY`,`originZ`]),Mo=(e,t)=>wo(e.get(t)?.get(),oi[t]),No=(e,t,n,r)=>{let i,a;if(Ti.has(n)){if(n!==`pathRotation`){let e=t.transformKeys??=[];(t.transformValues??={})[n]=r,e.includes(n)||(e.push(n),e.sort((e,t)=>wi.indexOf(e)-wi.indexOf(t)))}t.get(`transform`)||(!So(e)&&!t.get(`transformBox`)&&No(e,t,`transformBox`,new wa(`fill-box`)),t.set(`transform`,new wa(`none`),()=>{e.style.transform=Ao(t)})),a=t.get(`transform`)}else jo.has(n)?(t.get(`transformOrigin`)||t.set(`transformOrigin`,new wa(``),()=>{let n=Mo(t,`originX`)??`50%`,r=Mo(t,`originY`)??`50%`,i=Mo(t,`originZ`)??0;e.style.transformOrigin=`${n} ${r} ${i}`}),a=t.get(`transformOrigin`)):i=Hi(n)?()=>{e.style.setProperty(n,r.get())}:()=>{e.style[n]=wo(r.get(),oi[n])};return t.set(n,r,i,a)},Po=e=>So(e)||Co(e),Fo=(e,t)=>{if(Ti.has(t))return Si(e,t);let n=getComputedStyle(e),r=Hi(t)?n.getPropertyValue(t):n[t];return typeof r==`string`&&r.trim()||0},Io=Do(No,{test:Po,read:Fo}),Lo={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},Ro=wi.length;function zo(e,t,n){let r=``,i=!0;for(let a=0;a<Ro;a++){let o=wi[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=wo(s,oi[o]);if(!c){i=!1;let t=Lo[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${wo(a,oi.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function Bo(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(Ti.has(e)){o=!0;continue}if(Xt(e)){i[e]=n;continue}{let t=wo(n,oi[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=zo(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 Vo={offset:`stroke-dashoffset`,array:`stroke-dasharray`},B={offset:`strokeDashoffset`,array:`strokeDasharray`};function Ho(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?Vo:B;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var Uo=[`transform`,`opacity`,`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function Wo(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(Bo(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 Uo)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&&Ho(d,i,a,o,!1)}function Go(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 Ko=(e,t,n,r,i=n)=>{let a=Go(e,i);!a&&(i.startsWith(`data`)||i.startsWith(`aria`))&&(i=Za(i));let o=oi[n]||oi[i],s=a?()=>{e[i]=wo(r.get(),oi[n])}:()=>{let t=wo(r.get(),o);t==null?e.removeAttribute(i):e.setAttribute(i,String(t))};return t.set(n,r,s)};function qo(e,t,n,r){return fr.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 wa(`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 Jo=Do((e,t,n,r)=>n.startsWith(`path`)?qo(e,t,n,r):n.startsWith(`attr`)?Ko(e,t,n,r,Yo(n)):(Ti.has(n)||jo.has(n)||Hi(n)||n in e.style?No:Ko)(e,t,n,r),{test:Co,read:(e,t)=>Ti.has(t)?oi[t]?.default||0:Hi(t)||Uo.includes(t)?Fo(e,t)||e.getAttribute(Za(t))||0:(t=Yo(t),e.getAttribute(Za(t))??e.getAttribute(t)??void 0)});function Yo(e){return e.replace(/^attr([A-Z])/,(e,t)=>t.toLowerCase())}function Xo({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function Zo({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Qo(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 $o(e){return e===void 0||e===1}function es({scale:e,scaleX:t,scaleY:n}){return!$o(e)||!$o(t)||!$o(n)}function ts(e){return es(e)||ns(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function ns(e){return rs(e.x)||rs(e.y)}function rs(e){return e&&e!==`0%`}function is(e,t,n){return n+t*(e-n)}function as(e,t,n,r,i){return i!==void 0&&(e=is(e,i,r)),is(e,n,r)+t}function os(e,t=0,n=1,r,i){e.min=as(e.min,t,n,r,i),e.max=as(e.max,t,n,r,i)}function ss(e,{x:t,y:n}){os(e.x,t.translate,t.scale,t.originPoint),os(e.y,n.translate,n.scale,n.originPoint)}var cs=.999999999999,ls=1.0000000000001;function us(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&&(ds(e.x,-a.scroll.offset.x),ds(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,ss(e,o)),r&&ts(a.latestValues)&&ms(e,a.latestValues,a.layout?.layoutBox))}t.x<ls&&t.x>cs&&(t.x=1),t.y<ls&&t.y>cs&&(t.y=1)}function ds(e,t){e.min+=t,e.max+=t}function fs(e,t,n,r,i=.5){os(e,t,n,Gn(e.min,e.max,i),r)}function ps(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function ms(e,t,n){let r=n??e;fs(e.x,ps(t.x,r.x),t.scaleX,t.scale,t.originX),fs(e.y,ps(t.y,r.y),t.scaleY,t.scale,t.originY)}function hs(e,t){return Xo(Qo(e.getBoundingClientRect(),t))}function gs(e,t,n){let r=hs(e,n),{scroll:i}=t;return i&&(ds(r.x,i.offset.x),ds(r.y,i.offset.y)),r}var _s={},vs=e=>Co(e)?Jo:Io,ys=class{constructor(e,t){this.effect=e,this.current=t,this.KeyframeResolver=po}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 hs(this.current)}getProps(){return _s}};function bs(e,t,n,r){if(r)return yo(e=>r.getValue(e,null),t,n,r);let i=vs(e);return bo(i,e,t,n,new ys(i,e))}var xs=Do((e,t,n,r)=>t.set(n,r,()=>{e[n]=r.get()}),{test:e=>ut(e),read:(e,t)=>{let n=e[t];return typeof n==`string`||typeof n==`number`?n:void 0}}),{schedule:Ss,cancel:Cs}=dr(queueMicrotask,!1),ws={x:!1,y:!1};function Ts(){return ws.x||ws.y}function Es(e){return e===`x`||e===`y`?ws[e]?null:(ws[e]=!0,()=>{ws[e]=!1}):ws.x||ws.y?null:(ws.x=ws.y=!0,()=>{ws.x=ws.y=!1})}function Ds(e,t){let n=To(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function Os(e){return!(e.pointerType===`touch`||Ts())}function ks(e,t,n={}){let[r,i,a]=Ds(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(!Os(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 As=(e,t)=>t?e===t||As(e,t.parentElement):!1,js=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Ms=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Ns(e){return Ms.has(e.tagName)||e.isContentEditable===!0}var Ps=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function Fs(e){return Ps.has(e.tagName)||e.isContentEditable===!0}var Is=new WeakSet;function Ls(e){return t=>{t.key===`Enter`&&e(t)}}function Rs(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var zs=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=Ls(()=>{if(Is.has(n))return;Rs(n,`down`);let e=Ls(()=>{Rs(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>Rs(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function Bs(e){return js(e)&&!Ts()}var Vs=new WeakSet;function Hs(e,t,n={}){let[r,i,a]=Ds(e,n),o=e=>{let r=e.currentTarget;if(!Bs(e)||Vs.has(e))return;Is.add(r),n.stopPropagation&&Vs.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),Is.has(r)&&Is.delete(r),Bs(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||As(r,e.target))},l=e=>{s(e,!1)};window.addEventListener(`pointerup`,c,o),window.addEventListener(`pointercancel`,l,o)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),So(e)&&(e.addEventListener(`focus`,e=>zs(e,i)),!Ns(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}var Us=new WeakMap,Ws,Gs=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:Co(r)&&`getBBox`in r?r.getBBox()[t]:r[n],Ks=Gs(`inline`,`width`,`offsetWidth`),qs=Gs(`block`,`height`,`offsetHeight`);function Js({target:e,borderBoxSize:t}){Us.get(e)?.forEach(n=>{n(e,{get width(){return Ks(e,t)},get height(){return qs(e,t)}})})}function Ys(e){e.forEach(Js)}function Xs(){typeof ResizeObserver<`u`&&(Ws=new ResizeObserver(Ys))}function Zs(e,t){Ws||Xs();let n=To(e);return n.forEach(e=>{let n=Us.get(e);n||(n=new Set,Us.set(e,n)),n.add(t),Ws?.observe(e)}),()=>{n.forEach(e=>{let n=Us.get(e);n?.delete(t),n?.size||Ws?.unobserve(e)})}}var Qs=new Set,$s;function ec(){$s=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Qs.forEach(t=>t(e))},window.addEventListener(`resize`,$s)}function tc(e){return Qs.add(e),$s||ec(),()=>{Qs.delete(e),!Qs.size&&typeof $s==`function`&&(window.removeEventListener(`resize`,$s),$s=void 0)}}function nc(e,t){return typeof e==`function`?tc(e):Zs(e,t)}var rc={value:null,addProjectionMetrics:null};function ic(e){return Co(e)&&e.tagName===`svg`}var ac=e=>typeof e==`number`?e:parseFloat(e),oc=()=>({translate:0,scale:1,origin:0,originPoint:0}),sc=()=>({x:oc(),y:oc()}),cc=()=>({min:0,max:0}),lc=()=>({x:cc(),y:cc()}),uc=new WeakMap;function dc(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function fc(e){return typeof e==`string`||Array.isArray(e)}var pc=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],mc=[`initial`,...pc];function hc(e){if(dc(e.animate))return!0;for(let t=0;t<mc.length;t++)if(fc(e[mc[t]]))return!0;return!1}function gc(e){return!!(hc(e)||e.variants)}function _c(e,t,n){for(let r in t){let i=t[r],a=n[r];if(Ja(i))e.addValue(r,i);else if(Ja(a))e.addValue(r,Ta(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,Ta(t===void 0?i:t,{owner:e}))}}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var vc={current:null},yc={current:!1},bc=typeof window<`u`;function xc(){if(yc.current=!0,bc){if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>vc.current=e.matches;e.addEventListener(`change`,t),t()}else vc.current=!1}}var Sc=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],Cc={};function wc(e){Cc=e}function Tc(){return Cc}var Ec=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=Vi,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=qt.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,fr.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=hc(t),this.isVariantNode=gc(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&&Ja(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,uc.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:(yc.current||xc(),this.shouldReduceMotion=vc.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(),pr(this.notifyUpdate),pr(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&&la.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new ea({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:_t(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=Ti.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&fr.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 Cc){let t=Cc[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):lc()}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<Sc.length;t++){let n=Sc[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=_c(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=Ta(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`&&(lt(n)||dt(n))?n=parseFloat(n):typeof n!=`number`&&!Vn.test(n)&&Vn.test(t)&&(n=ui(e,t)),this.setBaseTarget(e,Ja(n)?n.get():n)),Ja(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}on(e,t){return this.events[e]||(this.events[e]=new gt),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){Ss.render(this.render)}},Dc=class extends Ec{constructor(){super(...arguments),this.KeyframeResolver=po}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;Ja(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},Oc=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function kc(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 Ac={};function jc(e,{layout:t,layoutId:n}){return Ti.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!Ac[e]||e===`opacity`)}function Mc(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(Ja(r[t])||i&&Ja(i[t])||jc(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function Nc(e){return window.getComputedStyle(e)}var Pc=class extends Dc{constructor(){super(...arguments),this.type=`html`,this.renderInstance=kc}mount(e){e.style,super.mount(e)}readValueFromInstance(e,t){if(Ti.has(t))return this.projection?.isProjecting?bi(t):Si(e,t);{let n=Nc(e),r=(Xt(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return hs(e,t)}build(e,t,n){Bo(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return Mc(e,t,n)}},Fc=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`]),Ic=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function Lc(e,t,n,r){kc(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(Fc.has(n)?n:Za(n),t.attrs[n])}function Rc(e,t,n){let r=Mc(e,t,n);for(let n in e)if(Ja(e[n])||Ja(t[n])){let t=wi.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var zc=class extends Dc{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=lc}getBaseTargetFromProps(e,t){return Ti.has(t)?super.getBaseTargetFromProps(e,t)??bi(t):e[t]}getDefaultValue(e){return Ti.has(e)?this.latestValues[e]??bi(e):void 0}readValueFromInstance(e,t){if(Ti.has(t)){let e=ci(t);return e&&e.default||0}if(Uo.includes(t)){let n=getComputedStyle(e)[t];if(typeof n==`string`&&n)return n.trim()}return t=Fc.has(t)?t:Za(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return Rc(e,t,n)}build(e,t,n){Wo(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){Lc(e,t,n,r)}mount(e){this.isSVGTag=Ic(e.tagName),super.mount(e)}};function Bc(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 Vc=[...pc].reverse();function Hc(e){let t=t=>Promise.all(t.map(({animation:t,options:n})=>io(e,t,n))),n=Wc(),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(Vc.forEach((t,r)=>{let i=n[t],h=o[t],g=m&&m.props[t],_=h===void 0?fc(g)||g===!1?g:void 0:h,v=fc(_),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||dc(_)||typeof _==`boolean`)return;if(t===`exit`&&i.isActive&&y!==!0){f={...f,...i.prevResolvedValues};return}let x=Uc(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}=Va(e,n,Ha(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)?!Bc(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=Va(s,n)?.transition?.delayChildren;r.delay=ba(s.enteringChildren,e,t)}u.push({animation:n,options:r})}}),d.size){let{initial:t}=o,n={},r=typeof t!=`boolean`&&Va(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&&!Ja(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=Wc(),i=!0}}}function Uc(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!Bc(t,e):!1}function Wc(){let e={};for(let t of pc)e[t]={isActive:t===`animate`,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}};return e}function Gc(e,t){e.min=t.min,e.max=t.max}function Kc(e,t){Gc(e.x,t.x),Gc(e.y,t.y)}function qc(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var Jc=.9999,Yc=1.0001,Xc=-.01,Zc=.01;function Qc(e){return e.max-e.min}function $c(e,t,n){return Math.abs(e-t)<=n}function el(e,t,n,r=.5){e.origin=r,e.originPoint=Gn(t.min,t.max,e.origin),e.scale=Qc(n)/Qc(t),e.translate=Gn(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Jc&&e.scale<=Yc||isNaN(e.scale))&&(e.scale=1),(e.translate>=Xc&&e.translate<=Zc||isNaN(e.translate))&&(e.translate=0)}function tl(e,t,n,r){el(e.x,t.x,n.x,r?r.originX:void 0),el(e.y,t.y,n.y,r?r.originY:void 0)}function nl(e,t,n,r=0){e.min=(r?Gn(n.min,n.max,r):n.min)+t.min,e.max=e.min+Qc(t)}function rl(e,t,n,r){nl(e.x,t.x,n.x,r?.x),nl(e.y,t.y,n.y,r?.y)}function il(e,t,n,r=0){let i=r?Gn(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+Qc(t)}function al(e,t,n,r){il(e.x,t.x,n.x,r?.x),il(e.y,t.y,n.y,r?.y)}function ol(e,t,n,r,i){return e-=t,e=is(e,1/n,r),i!==void 0&&(e=is(e,1/i,r)),e}function sl(e,t=0,n=1,r=.5,i,a=e,o=e){if(_n.test(t)&&(t=parseFloat(t),t=Gn(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=Gn(a.min,a.max,r);e===a&&(s-=t),e.min=ol(e.min,t,n,s,i),e.max=ol(e.max,t,n,s,i)}function cl(e,t,[n,r,i],a,o){sl(e,t[n],t[r],t[i],t.scale,a,o)}var ll=[`x`,`scaleX`,`originX`],ul=[`y`,`scaleY`,`originY`];function dl(e,t,n,r){cl(e.x,t,ll,n?n.x:void 0,r?r.x:void 0),cl(e.y,t,ul,n?n.y:void 0,r?r.y:void 0)}function fl(e){return e.translate===0&&e.scale===1}function pl(e){return fl(e.x)&&fl(e.y)}function ml(e,t){return e.min===t.min&&e.max===t.max}function hl(e,t){return ml(e.x,t.x)&&ml(e.y,t.y)}function gl(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function _l(e,t){return gl(e.x,t.x)&&gl(e.y,t.y)}function vl(e){return Qc(e.x)/Qc(e.y)}function yl(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function bl(e){return[e(`x`),e(`y`)]}function xl(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var Sl={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`){if(R.test(e))e=parseFloat(e);else return e}return`${xl(e,t.target.x)}% ${xl(e,t.target.y)}%`}},Cl={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Vn.parse(e);if(i.length>5)return r;let a=Vn.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=Gn(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 wl(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 Tl=mo.length,El=e=>typeof e==`number`||R.test(e);function Dl(e,t,n,r,i,a){i?(e.opacity=Gn(0,n.opacity??1,kl(r)),e.opacityExit=Gn(t.opacity??1,0,Al(r))):a&&(e.opacity=Gn(t.opacity??1,n.opacity??1,r));for(let i=0;i<Tl;i++){let a=mo[i],o=Ol(t,a),s=Ol(n,a);(o!==void 0||s!==void 0)&&(o||=0,s||=0,o===0||s===0||El(o)===El(s)?(e[a]=Math.max(Gn(ac(o),ac(s),r),0),(_n.test(s)||_n.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=Gn(t.rotate||0,n.rotate||0,r))}function Ol(e,t){return e[t]===void 0?e.borderRadius:e[t]}var kl=jl(0,.5,Nt),Al=jl(.5,.95,pt);function jl(e,t,n){return r=>r<e?0:r>t?1:n(ht(e,t,r))}function Ml(e,t,n){let r=Ja(e)?e:Ta(e);return r.start(Fa(``,r,t,n)),r.animation}function Nl(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var Pl=(e,t)=>e.depth-t.depth,Fl=class{constructor(){this.children=[],this.isDirty=!1}add(e){at(this.children,e),this.isDirty=!0}remove(e){ot(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Pl),this.isDirty=!1,this.children.forEach(e)}};function Il(e,t){let n=qt.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(pr(r),e(a-t))};return fr.setup(r,!0),()=>pr(r)}function Ll(e){return Ja(e)?e.get():e}var Rl=class{constructor(){this.members=[]}add(e){at(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&&(ot(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(ot(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)}},zl={borderRadius:{...Sl,applyTo:[...mo]},borderTopLeftRadius:Sl,borderTopRightRadius:Sl,borderBottomLeftRadius:Sl,borderBottomRightRadius:Sl,boxShadow:Cl},Bl={hasAnimatedSinceResize:!0,hasEverUpdated:!1};Object.assign(Ac,{...zl,...Ac});var Vl={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},Hl=[``,`X`,`Y`,`Z`],Ul=1e3,Wl=0;function Gl(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function Kl(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=$a(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,fr,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&Kl(r)}function ql({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=Wl++,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,rc.value&&(Vl.nodes=Vl.calculatedTargetDeltas=Vl.calculatedProjections=0),this.nodes.forEach(Xl),this.nodes.forEach(ou),this.nodes.forEach(su),this.nodes.forEach(Zl),rc.addProjectionMetrics&&rc.addProjectionMetrics(Vl)},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 Fl)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new gt),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=Co(t)&&!ic(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;fr.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=Il(i,250),Bl.hasAnimatedSinceResize&&(Bl.hasAnimatedSinceResize=!1,this.nodes.forEach(au)))})}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()||mu,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!_l(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={...Da(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||au(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(),pr(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(cu),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&&Kl(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(eu),this.nodes.forEach($l);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(tu);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(nu),this.nodes.forEach(ru),this.nodes.forEach(iu),this.nodes.forEach(Jl),this.nodes.forEach(Yl)):this.nodes.forEach(tu),this.clearAllSnapshots();let e=qt.now();Wt.delta=st(0,1e3/60,e-Wt.timestamp),Wt.timestamp=e,Wt.isProcessing=!0,mr.update.process(Wt),mr.preRender.process(Wt),mr.render.process(Wt),Wt.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Ss.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Ql),this.sharedNodes.forEach(lu)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,fr.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){fr.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),this.snapshot&&!Qc(this.snapshot.measuredBox.x)&&!Qc(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||=lc(),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&&!pl(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||ts(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)),vu(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return lc();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(bu))){let{scroll:e}=this.root;e&&(ds(t.x,e.offset.x),ds(t.y,e.offset.y))}return t}removeElementScroll(e){let t=lc();if(Kc(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&&Kc(t,e),ds(t.x,i.offset.x),ds(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||lc();Kc(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&&(ds(r.x,-n.scroll.offset.x),ds(r.y,-n.scroll.offset.y)),ts(n.latestValues)&&ms(r,n.latestValues,n.layout?.layoutBox)}return ts(this.latestValues)&&ms(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=lc();Kc(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!ts(n.latestValues))continue;let r;n.instance&&(es(n.latestValues)&&n.updateSnapshot(),r=lc(),Kc(r,n.measurePageBox())),dl(t,n.latestValues,n.snapshot?.layoutBox,r)}return ts(this.latestValues)&&dl(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!==Wt.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=Wt.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=lc(),this.targetWithTransforms=lc()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),rl(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Kc(this.target,this.layout.layoutBox),ss(this.target,this.targetDelta)):Kc(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),rc.value&&Vl.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||es(this.parent.latestValues)||ns(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=lc(),this.relativeTargetOrigin=lc(),al(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),Kc(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===Wt.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;Kc(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;us(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=lc());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(qc(this.prevProjectionDelta.x,this.projectionDelta.x),qc(this.prevProjectionDelta.y,this.projectionDelta.y)),tl(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!yl(this.projectionDelta.x,this.prevProjectionDelta.x)||!yl(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),rc.value&&Vl.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=sc(),this.projectionDelta=sc(),this.projectionDeltaWithTransform=sc()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=sc();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=lc(),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(pu));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=Gn(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=Gn(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(uu(o.x,e.x,n),uu(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(al(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),fu(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&hl(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=lc(),Kc(f,this.relativeTarget)),c&&(this.animationValues=a,Dl(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&&=(pr(this.pendingAnimation),void 0),this.pendingAnimation=fr.update(()=>{Bl.hasAnimatedSinceResize=!0,this.motionValue||=Ta(0),this.motionValue.jump(0,!1),this.currentAnimation=Ml(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()}}),Yr(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(Ul),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&&yu(this.options.animationType,this.layout.layoutBox,n.layoutBox)){i=this.target||lc();let t=Qc(this.layout.layoutBox.x);i.x.min=e.target.x.min,i.x.max=i.x.min+t;let n=Qc(this.layout.layoutBox.y);i.y.min=e.target.y.min,i.y.max=i.y.min+n}Kc(t,i),ms(t,r),tl(this.projectionDeltaWithTransform,this.layoutCorrected,t,r)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new Rl),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&Gl(`z`,e,r,this.animationValues);for(let t=0;t<Hl.length;t++)Gl(`rotate${Hl[t]}`,e,r,this.animationValues),Gl(`skew${Hl[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=Ll(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=Ll(t?.pointerEvents)||``),this.hasProjected&&!ts(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=wl(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 Ac){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=Ac[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?Ll(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach($l),this.root.sharedNodes.clear()}}}function Jl(e){e.updateLayout()}function Yl(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`)bl(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=Qc(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;Gc(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else yu(i,t.layoutBox,n)&&bl(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=Qc(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=sc();tl(o,n,t.layoutBox);let s=sc();a?tl(s,e.applyTransform(r,!0),t.measuredBox):tl(s,n,t.layoutBox);let c=!pl(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=lc();al(s,t.layoutBox,i.layoutBox,o);let c=lc();al(c,n,a.layoutBox,o),_l(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 Xl(e){rc.value&&Vl.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 Zl(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Ql(e){e.clearSnapshot()}function $l(e){e.clearMeasurements()}function eu(e){e.isLayoutDirty=!0,e.updateLayout()}function tu(e){e.isLayoutDirty=!1}function nu(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function ru(e){e.relativeTarget&&e.relativeParent?.isLayoutDirty&&(e.currentAnimation?e.isLayoutDirty=!0:(e.targetDelta=void 0,e.removeRelativeTarget()))}function iu(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function au(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function ou(e){e.resolveTargetDelta()}function su(e){e.calcProjection()}function cu(e){e.resetSkewAndRotation()}function lu(e){e.removeLeadSnapshot()}function uu(e,t,n){e.translate=Gn(t.translate,0,n),e.scale=Gn(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function du(e,t,n,r){e.min=Gn(t.min,n.min,r),e.max=Gn(t.max,n.max,r)}function fu(e,t,n,r){du(e.x,t.x,n.x,r),du(e.y,t.y,n.y,r)}function pu(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var mu={duration:.45,ease:[.4,0,.1,1]},hu=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),gu=hu(`applewebkit/`)&&!hu(`chrome/`)?Math.round:pt;function _u(e){e.min=gu(e.min),e.max=gu(e.max)}function vu(e){_u(e.x),_u(e.y)}function yu(e,t,n){return e===`position`||e===`preserve-aspect`&&!$c(vl(t),vl(n),.2)}function bu(e){return e!==e.root&&e.scroll?.wasRoot}var xu=ql({attachResizeListener:(e,t)=>Nl(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),Su={current:void 0},Cu=ql({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Su.current){let e=new xu({});e.mount(window),e.setOptions({layoutScroll:!0}),Su.current=e}return Su.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),wu=(0,m.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function Tu(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Eu(...e){return t=>{let n=!1,r=e.map(e=>{let r=Tu(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():Tu(e[t],null)}}}}function Du(...e){return m.useCallback(Eu(...e),e)}var V=et(),Ou=class extends m.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(So(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=So(e)&&e.offsetWidth||0,r=So(e)&&e.offsetHeight||0,i=getComputedStyle(t),a=this.props.sizeRef.current;a.height=parseFloat(i.height),a.width=parseFloat(i.width),a.top=t.offsetTop,a.left=t.offsetLeft,a.right=n-a.width-a.left,a.bottom=r-a.height-a.top,a.direction=i.direction}return null}componentDidUpdate(){}render(){return this.props.children}};function ku({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)(wu),u=Du(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}"] {
@@ -89,7 +89,7 @@ Error generating stack: `+e.message+`
89
89
  `)),n=[]),n.push(i);return t.push(n.join(`
90
90
  `)),t}function Fz(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 Iz(e,t){return!e&&!t}async function Lz(e,t){if(!t)throw Error(`Clipboard is unavailable. Select the code and copy it manually.`);await t.writeText(e)}var Rz=/^-\s+(.+?)\s+\(([^()\s]+\/[^()\s]+)\)\s*$/;function zz(e){let t=e.lastIndexOf(`${sO}\n`);if(t<0||t>0&&e[t-1]!==`
91
91
  `)return{body:e,files:[]};let n=e.slice(t+sO.length+1).split(`
92
- `).filter(Boolean),r=[];for(let t of n){let n=Rz.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 Bz=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function Vz({files:e}){return e.length===0?null:(0,V.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,V.jsx)(`li`,{children:Bz.has(e.mime)?(0,V.jsx)(`a`,{href:F(`/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,V.jsx)(`img`,{src:F(`/files/preview/attachments/${e.id}`),alt:e.name,loading:`lazy`,className:`max-h-40 max-w-[min(14rem,100%)] object-cover`})}):(0,V.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,V.jsx)(Xm,{"aria-hidden":`true`,className:`size-4 shrink-0`}):(0,V.jsx)(eg,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.name})]})},e.id))})}var Hz=!1,Uz=[],Wz=0,Gz=900;function Kz(){Hz=!0,window.clearTimeout(Wz),Wz=window.setTimeout(qz,Gz)}function qz(){Hz=!1,window.clearTimeout(Wz);let e=Uz;Uz=[];for(let t of e)t()}function Jz(e){if(!Hz)return e(),()=>{};let t=()=>e();return Uz.push(t),()=>{Uz=Uz.filter(e=>e!==t)}}var Yz=8;function Xz(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=Jz(()=>{e=requestAnimationFrame(()=>{let e=performance.now();(0,fy.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*Yz/t)))})});return()=>{t(),cancelAnimationFrame(e)}},[a,n]),Math.min(n,e)}function Zz(e){return e?.type===`text`?e.value??``:(e?.children??[]).map(Zz).join(``)}function Qz(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}),Qz(t,n)}function $z(){return e=>Qz(e)}function eB(e){let[t,n]=(0,m.useState)(!1);async function r(){try{await Lz(e,navigator.clipboard),n(!0),mp.success(`Code copied.`)}catch{mp.error(`Could not copy code. Select it and copy manually, or allow clipboard access.`)}}return{copied:t,copy:r}}function tB({text:e,children:t,block:n=!1}){let{copy:r}=eB(e),i=(0,m.useRef)(void 0);return(0,V.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(),Iz(window.getSelection()?.toString()??``,i.current?.moved??!1)&&r(),i.current=void 0},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),Iz(window.getSelection()?.toString()??``,!1)&&r())},children:[t,n?null:(0,V.jsx)(`span`,{className:`sr-only`,children:` (activate to copy)`})]})}function nB({node:e,children:t,source:n}){let r=e,{copied:i,copy:a}=eB(Fz(n,r?.position,!0)??Zz(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,V.jsxs)(`div`,{className:`relative my-3 rounded-lg bg-muted`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between pl-3`,children:[(0,V.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s&&/^[\w+#.-]{1,20}$/.test(s)?s:`code`,` · tap to copy`]}),(0,V.jsx)(nk,{label:i?`Copied`:`Copy the code`,icon:i?nm:Rm,iconOnly:!0,onClick:()=>void a()})]}),(0,V.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 rB(e){return{pre:t=>(0,V.jsx)(nB,{...t,source:e}),code:({node:t,children:n})=>{let r=t;if(r?.properties?.copyBlocked)return(0,V.jsx)(`code`,{children:n});let i=!!r?.properties?.blockCode;return(0,V.jsx)(tB,{text:Fz(e,r?.position,i)??Zz(r),block:i,children:n})},a:({href:e,children:t})=>(0,V.jsx)(`a`,{href:e?F(e):void 0,target:`_blank`,rel:`noopener noreferrer nofollow`,children:t}),img:({src:e,alt:t})=>(0,V.jsx)(`img`,{src:e?F(e):void 0,alt:t??``,loading:`lazy`}),table:({children:e})=>(0,V.jsx)(`div`,{className:`my-3 w-full overflow-x-auto`,children:(0,V.jsx)(`table`,{className:`w-full border-collapse text-sm`,children:e})})}}var iB=(0,m.memo)(function({text:e}){return(0,V.jsx)(xI,{remarkPlugins:[Dz],rehypePlugins:[$z],urlTransform:kz,components:rB(e),children:e})}),aB=(0,m.memo)(function({text:e,className:t}){let{body:n,files:r}=zz(e),i=n?Pz(n):[],a=Xz(i.length,3);return(0,V.jsxs)(`div`,{className:J(`md-body`,t),children:[i.slice(0,a).map((e,t)=>(0,V.jsx)(iB,{text:e},t)),(0,V.jsx)(Vz,{files:r})]})});function oB({title:e,note:t,className:n,children:r,collapsed:i,onToggle:a,shortcut:o,...s}){let c=typeof e==`string`?e:`pane`;return(0,V.jsxs)(`section`,{className:J(`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,V.jsxs)(`div`,{className:J(`flex min-h-12 shrink-0 items-center justify-between gap-3 px-4`,!i&&`border-b border-border`),children:[e?(0,V.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-medium`,children:e}):(0,V.jsx)(`span`,{}),(0,V.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,V.jsx)(`span`,{className:`flex items-center gap-2 truncate text-xs text-muted-foreground`,children:t}):null,a?(0,V.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,V.jsx)(KD,{chord:o,className:`kbd-hint`}):null,(0,V.jsx)(im,{"aria-hidden":`true`,className:J(`size-4 transition-transform duration-200 ease-snap`,i&&`-rotate-90`)})]}):null]})]}):null,i?null:r]})}function sB({title:e,right:t,className:n}){return(0,V.jsxs)(`span`,{className:J(`flex min-w-0 items-center gap-3`,n),children:[(0,V.jsx)(`span`,{className:`truncate font-medium`,children:e}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`}),t?(0,V.jsx)(`span`,{className:`shrink-0 text-xs font-normal text-muted-foreground`,children:t}):null]})}function cB({title:e,right:t,prominent:n,children:r}){return(0,V.jsxs)(`section`,{className:J(`flex min-w-0 flex-col`,n?`gap-4`:`workspace-section gap-3 rounded-xl border p-4 shadow-xs`),children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:(0,V.jsx)(sB,{title:e,right:t,className:n?`[&>span:first-child]:font-semibold`:void 0})}),r]})}var lB=`Pull requests`,uB=`An agent reviews it, optionally with a focus you type; Jev's quick read sizes it up first.`,dB=`nothing is posted to GitHub`,fB=`Refresh to load open pull requests with the GitHub CLI (gh).`,pB=`No open pull requests.`,mB=`loading pull requests from GitHub…`,hB=`reading the diff…`,gB=`the pull request has new commits since this review — review it again`,_B=`(no description)`,vB=`Review with a focus (optional)`,yB=`Leave it empty for a full review.`;function bB(e){return e===`passing`?`✓`:e===`failing`?`✗`:e===`pending`?`…`:``}function xB(e){return e===`passing`?`text-success`:e===`failing`?`text-destructive`:`text-muted-foreground`}function SB(e,t){return`+${e} −${t}`}function CB(e){return e===`APPROVED`?`approved`:e===`CHANGES_REQUESTED`?`changes requested`:e===`REVIEW_REQUIRED`?`review required`:``}function wB(e){return e?e.status===`running`?`reviewing`:e.status!==`done`||!e.verdict?``:e.verdict===`approve`?`approved`:e.verdict===`changes`?`changes found`:`commented`:``}function TB(e){return e===`approve`?`approve`:e===`changes`?`request changes`:e===`comment`?`comment`:``}function EB(e,t){if(e.status===`running`)return DB(e,t);if(e.status===`cancelled`)return`stopped`;let n=e.status===`done`?DB(e,t):e.status;return[TB(e.verdict),n].filter(Boolean).join(` · `)}function DB(e,t){let n=Math.max(0,Math.round(((e.finishedAt??t)-e.startedAt)/1e3));return n<60?`${n}s`:`${Math.floor(n/60)}m ${String(n%60).padStart(2,`0`)}s`}function OB(e,t){return[e.state?e.draft?`draft`:e.state.toLowerCase():e.draft?`draft`:``,e.author?`by ${e.author}`:``,e.updatedAt?`updated ${Dk(t-Date.parse(e.updatedAt))}`:``].filter(Boolean).join(` · `)}function kB(e){let t=`${e.changedFiles} file${e.changedFiles===1?``:`s`}`;return`${e.headRef||`?`} → ${e.baseRef||`?`} · ${SB(e.additions,e.deletions)} · ${t}`}function AB(e){let t=e.mergeable===`CONFLICTING`?`conflicts`:e.mergeable===`MERGEABLE`?`mergeable`:``;return[e.checks?`checks ${e.checks} (${e.checkCount})`:``,CB(e.decision),t,e.labels.join(`, `)].filter(Boolean).join(` · `)}function jB(e){return[`${e.changedFiles} file${e.changedFiles===1?``:`s`}`,e.labels.join(`, `),e.review?.stale?`stale`:``].filter(Boolean).join(` · `)}function MB(e){return e.read?`${e.read.model} · ${e.read.ms} ms`:``}function NB(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),e?t:Date.now()}function PB({pull:e,now:t}){return(0,V.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,V.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:[(0,V.jsxs)(`span`,{className:`font-normal text-muted-foreground tabular-nums`,children:[`#`,e.number]}),` `,e.title]}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:OB(e,t)}),(0,V.jsx)(`p`,{className:`text-sm tabular-nums`,children:kB(e)}),AB(e)?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:AB(e)}):null,e.url?(0,V.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer nofollow`,className:`inline-flex max-w-full break-all text-xs text-primary underline underline-offset-4`,children:e.url}):null]})}function FB({read:e}){return(0,V.jsxs)(cB,{title:`Jev's read`,right:MB(e),children:[e.status===`running`?(0,V.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(bO,{className:`size-3.5`}),hB]}):null,e.status===`failed`?(0,V.jsx)(`p`,{className:`text-sm text-foreground`,children:e.error??`Jev could not read it`}):null,e.status===`done`&&e.line?(0,V.jsx)(aB,{text:e.line}):null]})}function IB({review:e,now:t}){return(0,V.jsxs)(V.Fragment,{children:[e.model?(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:[e.model,e.thinking].filter(Boolean).join(` · `)}):null,e.focus?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`focus: `,e.focus]}):null,e.saved?(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`kept from `,Dk(t-e.startedAt)]}):null,e.stale?(0,V.jsx)(`p`,{className:`text-sm text-foreground`,children:gB}):null,e.status===`running`?(0,V.jsx)(LB,{steps:e.steps}):null,e.status===`cancelled`?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`stopped`}):null,e.status===`failed`||e.status===`timeout`?(0,V.jsxs)(`p`,{className:`text-sm text-destructive`,children:[`✗ `,e.error??e.status]}):null,e.text?(0,V.jsx)(aB,{text:e.text}):null]})}function LB({steps:e}){return(0,V.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.slice(-6).map((e,t)=>(0,V.jsxs)(`li`,{className:`break-words`,children:[`· `,e]},t))})}function RB({number:e,focus:t,onChange:n}){return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`label`,{htmlFor:`focus-${e}`,className:`text-[0.8125rem] font-medium text-foreground`,children:vB}),(0,V.jsx)(Ck,{id:`focus-${e}`,value:t,rows:2,maxLength:2e3,onChange:e=>n(e.target.value)}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:yB})]})}function zB({number:e,review:t,now:n,focus:r,onFocus:i}){return(0,V.jsxs)(cB,{title:`Review`,right:t?EB(t,n):void 0,children:[t?(0,V.jsx)(IB,{review:t,now:n}):null,(0,V.jsx)(RB,{number:e,focus:r,onChange:i}),(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`A read-only agent reviews it — `,dB,`.`]})]})}function BB({files:e}){return(0,V.jsx)(cB,{title:`Files`,right:String(e.length),children:(0,V.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:(0,V.jsx)(`table`,{className:`w-full border-collapse text-sm tabular-nums`,children:(0,V.jsx)(`tbody`,{children:e.map(e=>(0,V.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,V.jsx)(`td`,{className:`max-w-0 px-3 py-1.5 break-all`,children:e.path}),(0,V.jsx)(`td`,{className:`px-3 py-1.5 text-right text-xs whitespace-nowrap text-muted-foreground`,children:SB(e.additions,e.deletions)})]},e.path))})})})})}function VB({note:e,now:t}){let n=[e.state&&e.state!==`COMMENTED`?e.state.toLowerCase().replace(/_/g,` `):``,e.at?Dk(t-Date.parse(e.at)):``].filter(Boolean).join(` · `);return(0,V.jsxs)(`article`,{className:`card-flat flex flex-col gap-1.5 rounded-lg border px-3.5 py-2.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,V.jsx)(`span`,{className:`font-medium text-foreground`,children:e.author??`comment`}),n?(0,V.jsx)(`span`,{children:n}):null]}),e.body.trim()?(0,V.jsx)(aB,{text:e.body.trim()}):null]})}function HB({notes:e,now:t}){return e.length===0?null:(0,V.jsx)(cB,{title:`Discussion`,right:String(e.length),children:(0,V.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,V.jsx)(VB,{note:e,now:t},n))})})}function UB({number:e,error:t}){return t?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load #`,e,`. `,t]}):(0,V.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(bO,{className:`size-3.5`}),`loading #`,e,`…`]})}function WB({number:e,onChanged:t}){let n=MO(`git.pull`,{number:e},[`git`]),[r,i]=(0,m.useState)(``),a=n.data?.review?.status===`running`,o=NB(a);if(!n.data)return(0,V.jsx)(UB,{number:e,error:n.error});let{pull:s,review:c,read:l}=n.data,u=()=>{n.reload(),t?.()},d=async()=>{let t=r.trim();i(``),await U(`git.review`,{number:e,...t?{focus:t}:{}}),u()},f=async()=>{await U(`git.jev`,{number:e}),u()},p=async()=>{await U(`git.cancelReview`,{number:e}),u()};return(0,V.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`Pull request #${e}`,children:[(0,V.jsxs)(rk,{children:[(0,V.jsx)(nk,{label:`Review`,icon:cg,tone:`primary`,shortcut:`V`,disabled:a,onClick:()=>void d()}),(0,V.jsx)(nk,{label:`Jev's read`,icon:Xp,shortcut:`Q`,disabled:a,onClick:()=>void f()}),a?(0,V.jsx)(Rk,{icon:wm,label:`Stop the review`,text:`Stop`,shortcut:`X`,title:`Stop this review?`,description:`The agent stops reading the pull request. Nothing is posted to GitHub.`,confirmLabel:`Stop review`,variant:`destructive`,onConfirm:()=>void p()}):null]}),(0,V.jsx)(PB,{pull:s,now:o}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:uB}),l?(0,V.jsx)(FB,{read:l}):null,(0,V.jsx)(zB,{number:e,review:c,now:o,focus:r,onFocus:i}),s.files.length>0?(0,V.jsx)(BB,{files:s.files}):null,(0,V.jsx)(cB,{title:`Description`,children:s.body.trim()?(0,V.jsx)(aB,{text:s.body.trim()}):(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:_B})}),(0,V.jsx)(HB,{notes:s.notes,now:o})]})}var GB=Wv([`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 KB({className:e,variant:t,size:n,radius:r,asChild:i=!1,...a}){let o=i?$v:`span`;return(0,V.jsx)(o,{"data-slot":`badge`,className:J(GB({variant:t,size:n,radius:r,className:e})),...a})}var qB=`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`,JB=`flex flex-col gap-1 px-2 pb-3`,YB=`px-4 pt-4 pb-1 text-xs font-medium text-muted-foreground`;function XB({checks:e}){let t=bB(e);return t?(0,V.jsx)(`span`,{className:J(`w-4 shrink-0 text-center`,xB(e)),"aria-hidden":`true`,children:t}):(0,V.jsx)(`span`,{className:`w-4 shrink-0`,"aria-hidden":`true`})}function ZB({pull:e,selected:t,onSelect:n}){let r=wB(e.review);return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(e.number),className:qB,children:[(0,V.jsxs)(`span`,{className:`flex items-start gap-2 text-sm`,children:[(0,V.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[`#`,e.number]}),(0,V.jsx)(XB,{checks:e.checks}),e.draft?(0,V.jsx)(KB,{variant:`secondary`,children:`draft`}):null,(0,V.jsx)(`span`,{className:J(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title})]}),(0,V.jsxs)(`span`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-xs text-muted-foreground`,children:[(0,V.jsx)(`span`,{children:jB(e)}),(0,V.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[r?(0,V.jsx)(`span`,{children:r}):null,(0,V.jsx)(`span`,{className:`tabular-nums`,children:SB(e.additions,e.deletions)})]})]})]})})}function QB({pulls:e,selectedId:t,onSelect:n}){return(0,V.jsx)(`ul`,{className:JB,children:e.map(e=>(0,V.jsx)(ZB,{pull:e,selected:e.number===t,onSelect:n},e.number))})}function $B(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function eV({label:e,hint:t,buttonLabel:n=`Send`,onSend:r}){let i=(0,m.useId)(),[a,o]=(0,m.useState)(``),[s,c]=(0,m.useState)(!1),l=async()=>{a.trim()&&!s&&(c(!0),await r(a)&&o(``),c(!1))};return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium text-foreground`,children:e}),(0,V.jsx)(Ck,{id:i,value:a,rows:2,"aria-describedby":t?`${i}-hint`:void 0,onChange:e=>o(e.target.value),onKeyDown:e=>{$B(e)&&(e.preventDefault(),l())}}),t?(0,V.jsx)(`p`,{id:`${i}-hint`,className:`text-xs text-muted-foreground`,children:t}):null,(0,V.jsx)(`div`,{className:`flex self-end`,children:(0,V.jsx)(nk,{label:n,icon:s?wh:Hp,tone:`primary`,shortcut:`Enter`,className:s?`[&_svg]:animate-spin`:void 0,onClick:()=>void l(),disabled:!a.trim()||s})})]})}var tV=`Issues`,nV=`Issue`,rV=`Plan it opens a planning session on this issue; save the plan as a task once the panel agrees it.`,iV=`Refresh to load open issues with the GitHub CLI (gh).`,aV=`No open issues. File one with New issue.`,oV=`loading issues from GitHub…`,sV=`issues are off (lobby.issues)`,cV=`(no description)`;function lV(e,t){return[e.state?e.state.toLowerCase():``,e.author?`by ${e.author}`:``,e.updatedAt?`updated ${Dk(t-Date.parse(e.updatedAt))}`:``,e.labels.join(`, `)].filter(Boolean).join(` · `)}function uV(e,t){return[e.author?`by ${e.author}`:``,e.updatedAt?Dk(t-Date.parse(e.updatedAt)):``].filter(Boolean).join(` · `)}function dV(e){return e.length>0?`[${e.slice(0,2).join(`, `)}]`:``}function fV({issue:e,now:t}){return(0,V.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,V.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:[(0,V.jsxs)(`span`,{className:`font-normal text-muted-foreground tabular-nums`,children:[`#`,e.number]}),` `,e.title]}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:lV(e,t)}),e.url?(0,V.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer nofollow`,className:`inline-flex max-w-full break-all text-xs text-primary underline underline-offset-4`,children:e.url}):null]})}function pV({comment:e,now:t}){return(0,V.jsxs)(`article`,{className:`card-flat flex flex-col gap-1.5 rounded-lg border px-3.5 py-2.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,V.jsx)(`span`,{className:`font-medium text-foreground`,children:e.author??`comment`}),e.createdAt?(0,V.jsx)(`span`,{children:Dk(t-Date.parse(e.createdAt))}):null]}),(0,V.jsx)(aB,{text:e.body.trim()})]})}function mV({comments:e,now:t}){return e.length===0?null:(0,V.jsx)(cB,{title:`Comments`,right:String(e.length),children:(0,V.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,V.jsx)(pV,{comment:e,now:t},n))})})}function hV({issue:e}){let t=async()=>{await U(`planner.new`,{seed:{issue:{number:e.number,title:e.title,...e.url?{url:e.url}:{}},body:e.body}})&&fO(dO(`plan`))};return(0,V.jsx)(Rk,{icon:i_,label:`Plan #${e.number} with the panel`,text:`Plan it`,shortcut:`N`,title:`Plan #${e.number} with the panel?`,description:`A new planning session starts from this issue. A plan already under way waits under Plan → Previous.`,confirmLabel:`Plan it`,onConfirm:()=>void t()})}function gV({number:e}){let t=MO(`issues.get`,{number:e},[`issues`]),n=Date.now();if(!t.data)return t.error?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load #`,e,`. `,t.error]}):(0,V.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(bO,{className:`size-3.5`}),`loading #`,e,`…`]});let r=t.data.issue;return(0,V.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${nV} #${e}`,children:[(0,V.jsx)(rk,{children:(0,V.jsx)(hV,{issue:r})}),(0,V.jsx)(fV,{issue:r,now:n}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:rV}),(0,V.jsx)(cB,{title:`Description`,children:r.body.trim()?(0,V.jsx)(aB,{text:r.body.trim()}):(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:cV})}),(0,V.jsx)(mV,{comments:r.comments,now:n})]})}function _V({issue:e,selected:t,now:n,onSelect:r}){let i=dV(e.labels);return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>r(e.number),className:qB,children:[(0,V.jsxs)(`span`,{className:`flex flex-wrap items-start gap-2 text-sm`,children:[(0,V.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[`#`,e.number]}),(0,V.jsx)(`span`,{className:J(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title}),i?(0,V.jsx)(`span`,{className:`max-w-full break-words text-xs text-muted-foreground`,children:i}):null]}),(0,V.jsx)(`span`,{className:`pl-9 text-xs text-muted-foreground`,children:uV(e,n)})]})})}function vV({issues:e,selectedId:t,now:n,onSelect:r}){return(0,V.jsx)(`ul`,{className:JB,children:e.map(e=>(0,V.jsx)(_V,{issue:e,selected:e.number===t,now:n,onSelect:r},e.number))})}var yV=()=>fO(dO(`git`,`issues`)),bV=e=>fO(dO(`git`,`issues`,String(e)));function xV(e){let t=Number(e[0]);return Number.isInteger(t)&&t>0?t:void 0}function SV(){return(0,V.jsx)(mO,{className:`m-4 flex-1`,children:(0,V.jsxs)(hO,{children:[(0,V.jsx)(_O,{variant:`icon`,children:(0,V.jsx)(vm,{"aria-hidden":`true`})}),(0,V.jsx)(vO,{children:`Issues are off`}),(0,V.jsx)(yO,{className:`font-mono`,children:sV})]})})}function CV({loading:e,loaded:t,error:n,onRetry:r}){let i=n?`✗ ${n}`:t?aV:e?oV:iV;return(0,V.jsxs)(mO,{className:`m-4 flex-1`,children:[(0,V.jsxs)(hO,{children:[(0,V.jsx)(_O,{variant:`icon`,children:(0,V.jsx)(vm,{"aria-hidden":`true`})}),(0,V.jsx)(yO,{className:n?`text-destructive`:void 0,children:i})]}),n?(0,V.jsx)(Y,{variant:`outline`,onClick:r,children:`Retry`}):null]})}function wV({onCreate:e}){return(0,V.jsx)(_k,{className:`shrink-0 border-t border-border p-4`,children:(0,V.jsx)(eV,{label:`New issue`,hint:`The first line becomes the title; the rest is the body. Enter files it.`,buttonLabel:`File issue`,onSend:e})})}function TV(){let e=AO(`status`).data?.issuesEnabled??!0;return{enabled:e,read:MO(`issues.list`,{},[`issues`],e)}}function EV({enabled:e,read:t}){return!e||t.error?.includes(`issues are off`)?(0,V.jsx)(SV,{}):!t.data&&t.error?(0,V.jsx)(EO,{message:`Could not load issues. ${t.error}`,onRetry:t.reload}):null}function DV({issues:e,rest:t,top:n}){let r=gk(),{read:i}=e,a=xV(t),o=i.data?.issues??[],s=async e=>await U(`issues.create`,{text:e})?(i.reload(),!0):!1,c=EV(e);if(c)return(0,V.jsxs)(V.Fragment,{children:[n,c]});if(i.data&&o.length===0)return(0,V.jsxs)(V.Fragment,{children:[n,(0,V.jsx)(CV,{loading:i.data.loading,loaded:i.data.loaded,error:i.data.error,onRetry:i.reload}),(0,V.jsx)(`div`,{className:`shrink-0 pb-dock`,children:(0,V.jsx)(wV,{onCreate:s})})]});let l=(0,V.jsxs)(V.Fragment,{children:[n,i.data?.error?(0,V.jsxs)(`p`,{className:`px-3 pt-2 text-sm text-destructive`,children:[`✗ `,i.data.error]}):null,i.data?(0,V.jsx)(vV,{issues:o,selectedId:a,now:Date.now(),onSelect:bV}):(0,V.jsx)(Sk,{}),(0,V.jsx)(wV,{onCreate:s})]});return(0,V.jsx)(bk,{wide:r,list:l,detail:a===void 0?null:(0,V.jsx)(gV,{number:a},a),open:a!==void 0,onClose:yV,hint:`Select an issue to read it.`,describe:`Issue detail`})}var OV=()=>fO(dO(`git`)),kV=e=>fO(dO(`git`,String(e)));function AV(e){let t=Number(e[0]);return Number.isInteger(t)&&t>0?t:void 0}function jV({loading:e,loaded:t,error:n,onRetry:r}){let i=n?`✗ ${n}`:t?pB:e?mB:fB;return(0,V.jsxs)(mO,{className:`m-4 flex-1`,children:[(0,V.jsxs)(hO,{children:[(0,V.jsx)(_O,{variant:`icon`,children:(0,V.jsx)(ih,{"aria-hidden":`true`})}),(0,V.jsx)(yO,{className:n?`text-destructive`:void 0,children:i})]}),n?(0,V.jsx)(Y,{variant:`outline`,onClick:r,children:`Retry`}):null]})}var MV=[{id:`pulls`,label:lB,hash:dO(`git`)},{id:`issues`,label:tV,hash:dO(`git`,`issues`)}];function NV({view:e}){return(0,V.jsx)(ak,{label:`Show`,items:MV,value:e,idPrefix:`git-view`,onChange:e=>fO(MV.find(t=>t.id===e).hash)})}function PV(e,t){return(0,m.useCallback)(()=>{U(`git.pulls`,{refresh:!0}).then(()=>e.reload()),t.enabled&&U(`issues.list`,{refresh:!0}).then(()=>t.read.reload())},[e,t])}function FV({view:e,count:t,busy:n,refresh:r}){return(0,V.jsx)(xk,{title:e===`issues`?tV:lB,count:t,lead:(0,V.jsx)(NV,{view:e}),children:(0,V.jsx)(nk,{label:`Refresh`,icon:fg,iconOnly:!0,shortcut:`R`,disabled:n,className:J(`size-7`,n&&`[&_svg]:animate-spin`),onClick:r})})}function IV({read:e,rest:t,top:n}){let r=gk(),i=AV(t),a=e.data?.pulls??[];if(!e.data&&e.error)return(0,V.jsxs)(V.Fragment,{children:[n,(0,V.jsx)(EO,{message:`Could not load pull requests. ${e.error}`,onRetry:e.reload})]});if(e.data&&a.length===0)return(0,V.jsxs)(V.Fragment,{children:[n,(0,V.jsx)(jV,{loading:e.data.loading,loaded:e.data.loaded,error:e.data.error,onRetry:e.reload})]});let o=(0,V.jsxs)(V.Fragment,{children:[n,e.data?.error?(0,V.jsxs)(`p`,{className:`px-3 pt-2 text-sm text-destructive`,children:[`✗ `,e.data.error]}):null,e.data?(0,V.jsx)(QB,{pulls:a,selectedId:i,onSelect:kV}):(0,V.jsx)(Sk,{})]}),s=i===void 0?null:(0,V.jsx)(WB,{number:i,onChanged:e.reload},i);return(0,V.jsx)(bk,{wide:r,list:o,detail:s,open:i!==void 0,onClose:OV,hint:`Select a pull request to see its detail.`,describe:`Pull request detail`})}var LV=()=>MO(`git.pulls`,{},[`git`]);function RV(e,t,n){let r=e===`issues`?n.read:t,i=e===`issues`?n.read.data?.issues:t.data?.pulls,a=t.loading||!!t.data?.loading||n.enabled&&(n.read.loading||!!n.read.data?.loading),o=i&&(e===`pulls`||n.enabled)?`${i.length} open`:void 0;return{busy:a||r.loading,count:o}}function zV({rest:e}){let t=LV(),n=TV(),r=PV(t,n),i=e[0]===`issues`?`issues`:`pulls`,{busy:a,count:o}=RV(i,t,n),s=(0,V.jsx)(FV,{view:i,count:o,busy:a,refresh:r}),c=i===`issues`?(0,V.jsx)(DV,{issues:n,rest:e.slice(1),top:s}):(0,V.jsx)(IV,{read:t,rest:e,top:s});return(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:c})}function BV(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 VV={DEV:Mm,DESIGN:Kh,QA:Og,RESEARCH:Hg,"QUICK FIX":c_,SCOUT:Im,PLANNER:bg,CLASSIFIER:Bg,LOBBY:Ih,LINT:gh};function HV(e){return e?VV[e.toUpperCase()]??Qp:em}function UV({className:e,strokeWidth:t=2,source:n}){return(0,V.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:J(`agent-oracle shrink-0`,e),children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`10`,r:`7`}),(0,V.jsx)(`path`,{d:`M8.5 7.5a4 4 0 0 1 3-2`}),(0,V.jsx)(`path`,{d:`M8 16.2 6.5 20h11L16 16.2`}),(0,V.jsx)(`path`,{d:`M5 20h14`})]})}function WV(e){let t=e?.toUpperCase();return t===`ORACLE`||t===`MASTER`}function GV({source:e,className:t,strokeWidth:n}){if(WV(e))return(0,V.jsx)(UV,{source:e,className:t,strokeWidth:n});let r=HV(e);return(0,V.jsx)(r,{"aria-hidden":`true`,"data-agent-icon":e??`thinking`,strokeWidth:n,className:J(`shrink-0`,t)})}var KV={MASTER:`text-primary`,DEV:`text-source-dev`,DESIGN:`text-source-design`,QA:`text-source-qa`,RESEARCH:`text-source-research`,"QUICK FIX":`text-source-quickfix`,ORACLE:`text-primary`,LOBBY:`text-muted-foreground`};function qV(e){return e.length<=2?e:e.charAt(0)+e.slice(1).toLowerCase()}function JV(e){return KV[e]??`text-muted-foreground`}var YV={MASTER:`var(--primary)`,DEV:`var(--source-dev)`,DESIGN:`var(--source-design)`,QA:`var(--source-qa)`,RESEARCH:`var(--source-research)`,"QUICK FIX":`var(--source-quickfix)`,ORACLE:`var(--primary)`,LOBBY:`var(--muted-foreground)`};function XV(e){return YV[e]??`var(--muted-foreground)`}function ZV(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 QV(e){return e?.runs??[]}function $V(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 eH({source:e,name:t,time:n,head:r,live:i,children:a,aside:o}){let s=r&&!WV(e);return(0,V.jsxs)(`div`,{className:`chat-agent group/msg`,"data-live":i||void 0,style:i?{"--orb":XV(e)}:void 0,children:[s||o?(0,V.jsxs)(`p`,{className:`chat-speaker`,children:[s?(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-medium text-foreground`,style:{"--orb":XV(e)},children:[(0,V.jsx)(GV,{source:e,strokeWidth:2.25,className:`size-3.5 text-[color-mix(in_oklab,var(--orb)_85%,var(--foreground))]`}),t]}):null,s&&n?(0,V.jsx)(`time`,{className:`text-xs text-muted-foreground tabular-nums`,children:n}):null,o?(0,V.jsx)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:o}):null]}):null,(0,V.jsx)(`div`,{className:`chat-prose`,children:a}),n&&!s?(0,V.jsx)(`time`,{className:`chat-meta`,children:n}):null]})}function tH({time:e,head:t,note:n,children:r,below:i,actions:a}){return(0,V.jsxs)(`div`,{className:`group/msg flex flex-col items-end gap-1`,children:[(0,V.jsx)(`div`,{className:`chat-bubble`,children:r}),e||n||a?(0,V.jsxs)(`div`,{className:`chat-meta flex items-center gap-2`,children:[a,n?(0,V.jsx)(`span`,{children:n}):null,e?(0,V.jsx)(`time`,{className:`tabular-nums`,children:e}):null]}):null,i]})}function nH({failed:e,children:t}){return(0,V.jsx)(`div`,{role:`note`,className:J(`chat-note`,e&&`text-destructive`),children:(0,V.jsx)(`span`,{children:t})})}function rH({className:e}){return(0,V.jsxs)(`span`,{"aria-hidden":`true`,className:J(`typing-dots`,e),children:[(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{})]})}function iH({onClick:e,className:t}){return(0,V.jsx)(`button`,{type:`button`,"aria-label":`Jump to latest`,title:`Jump to latest`,onClick:e,className:J(`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,V.jsx)(Ip,{"aria-hidden":`true`,className:`size-4`})})}var aH=`(max-width: 1023.98px)`;function oH(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 sH=`bot-lobby.collapsed.`,cH=new Set,lH=new Map;function uH(e){if(lH.has(e))return lH.get(e);if(e===`lobby.thinking`)return oH(e);try{return oH(e,localStorage.getItem(sH+e))}catch{return!1}}function dH(e,t){lH.set(e,t);try{e!==`lobby.thinking`&&localStorage.setItem(sH+e,t?`1`:`0`)}catch{}for(let e of[...cH])e()}function fH(e){return cH.add(e),()=>{cH.delete(e)}}function pH(e){dH(e,!uH(e))}function mH(e){return[(0,m.useSyncExternalStore)(fH,()=>uH(e),()=>oH(e)),(0,m.useCallback)(()=>dH(e,!uH(e)),[e])]}function hH({className:e}){return(0,V.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`working-mark`,className:J(`working-mark`,e),children:(0,V.jsx)(`span`,{className:`working-mark-core`})})}var gH=`lobby.activity.open`;function _H({entry:e}){return e.pending?(0,V.jsx)(hH,{className:`size-3`}):e.kind===`error`?(0,V.jsx)(o_,{"aria-hidden":`true`,className:`size-3.5 text-destructive`}):e.kind===`warning`?(0,V.jsx)(Kg,{"aria-hidden":`true`,className:`size-3.5 text-warning`}):e.kind===`success`?(0,V.jsx)(nm,{"aria-hidden":`true`,className:`size-3.5 text-success`}):(0,V.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`})}function vH({entry:e}){return(0,V.jsxs)(`li`,{className:`activity-step`,title:Tk(e.at),style:e.pending?{"--orb":XV(e.source)}:void 0,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`flex h-5 w-6 items-center justify-center`,children:(0,V.jsx)(_H,{entry:e})}),(0,V.jsx)(`span`,{className:`sr-only`,children:e.pending?`pending`:e.kind}),(0,V.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,V.jsx)(`span`,{className:J(`font-medium`,JV(e.source)),children:qV(e.source)}),` `,(0,V.jsx)(`span`,{className:e.kind===`error`?`text-destructive`:e.pending?`text-foreground`:void 0,children:e.pending?`${e.text}…`:e.text})]})]})}function yH(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 bH(e){let t=[...e].reverse().find(e=>e.pending),n=[...new Set(e.map(e=>qV(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 xH(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 SH({entries:e}){let[t]=mH(gH),[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}=bH(e),f=xH(!!o),p=o?{"--orb":XV(o.source)}:void 0;return(0,V.jsxs)(`div`,{className:`activity-run`,"data-live":o?!0:void 0,"data-open":i||void 0,style:p,children:[(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":a,onClick:()=>r(!i),className:`activity-toggle`,children:[o?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(hH,{}),(0,V.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,V.jsx)(CH,{text:`Working`}),(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:` · `}),(0,V.jsxs)(`span`,{className:`activity-live-step`,children:[(0,V.jsx)(`span`,{className:J(`font-medium`,JV(o.source)),children:qV(o.source)}),` `,(0,V.jsxs)(`span`,{className:`text-foreground`,children:[o.text,`…`]})]},o.id)]}),(0,V.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[c,e[0]&&f-e[0].at>=1e3?` · ${yH(f-e[0].at)}`:``]})]}):(0,V.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,V.jsx)(`span`,{className:`font-medium`,children:s>=1e3?`Worked for ${yH(s)}`:`Worked`}),(0,V.jsxs)(`span`,{children:[` · `,c,l?` · ${l}`:``]})]}),u?(0,V.jsxs)(`span`,{className:`shrink-0 text-destructive`,children:[u,` `,u===1?`error`:`errors`]}):null,d?(0,V.jsxs)(`span`,{className:`shrink-0 text-warning`,children:[d,` `,d===1?`warning`:`warnings`]}):null,(0,V.jsx)(im,{"aria-hidden":`true`,className:`activity-chevron size-3.5 shrink-0`})]}),i?(0,V.jsx)(`ol`,{id:a,"aria-label":`Activity`,className:`activity-steps`,children:e.map(e=>(0,V.jsx)(vH,{entry:e},e.id))}):null]})}function CH({text:e}){return(0,V.jsxs)(`span`,{className:`activity-shimmer`,children:[(0,V.jsx)(`span`,{className:`sr-only`,children:e}),[...e].map((e,t)=>(0,V.jsx)(`span`,{"aria-hidden":`true`,style:{"--i":t},children:e},t))]})}function wH(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 TH=3e5,EH=`No task is running in this session.`,DH=`Type a request below and press enter to start one: the oracle scouts, proposes, plans and delegates.`,OH=`Nothing said yet. Type below to talk to the oracle about this task.`;function kH({entry:e}){return(0,V.jsxs)(nH,{failed:e.text.startsWith(`✗`),children:[e.text,e.at?` · ${Tk(e.at)}`:``]})}function AH({entry:e,head:t}){if(e.role===`you`)return(0,V.jsx)(tH,{time:Tk(e.at),head:t,children:(0,V.jsx)(aB,{text:e.text})});let n=e.role===`panel`;return(0,V.jsx)(eH,{source:n?`PLANNER`:`ORACLE`,name:n?`Panel`:`Oracle`,time:Tk(e.at),head:t,children:(0,V.jsx)(aB,{text:e.text})})}var jH=(0,m.memo)(function({entry:e,head:t,fresh:n}){return(0,V.jsx)($f.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,V.jsx)(kH,{entry:e}):(0,V.jsx)(AH,{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);function MH({text:e,busy:t,working:n}){let r=!!e?.trim();return!r&&(!t||n)?null:(0,V.jsx)(eH,{source:`ORACLE`,name:`Oracle`,head:!0,live:t,aside:t&&r?`writing…`:void 0,children:r?(0,V.jsx)(aB,{text:e??``}):(0,V.jsx)(rH,{className:`mt-1`})})}function NH({hasTask:e}){return(0,V.jsxs)(mO,{className:`h-full border-0`,children:[(0,V.jsxs)(hO,{children:[(0,V.jsx)(_O,{variant:`icon`,children:(0,V.jsx)(Ph,{"aria-hidden":`true`})}),e?null:(0,V.jsx)(vO,{children:EH}),(0,V.jsx)(yO,{children:e?OH:DH})]}),e?null:(0,V.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm text-muted-foreground`,children:[(0,V.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[`Or plan it first with the whole panel in `,(0,V.jsx)(KD,{chord:`3`}),` Plan`]}),(0,V.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[`or make a direct change in `,(0,V.jsx)(KD,{chord:`4`}),` Quick fix`]})]})]})}async function PH(e){let t=await L(`lobby.history`,{before:e});return{entries:t.entries,hasOlder:t.hasOlder}}function FH(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 PH(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 IH=[];function LH({chat:e,activity:t=IH,reply:n,busy:r,hasOlder:i,hasTask:a}){let o=(0,m.useMemo)(()=>t.slice(-400),[t]),{ref:s,atBottom:c,stick:l,onScroll:u}=BV(`${e.length}:${n?.length??0}:${o.length}:${o.at(-1)?.pending??``}`),{merged:d,more:f,loading:p,load:h}=FH(e,i,s),g=(0,m.useCallback)(()=>{u();let e=s.current;e&&e.scrollTop<80&&f&&!p&&h()},[u,s,f,p,h]),_=(0,m.useMemo)(()=>wH(d,o),[d,o]),v=d.length===0&&o.length===0&&!n?.trim()&&!r,y=_.at(-1),b=y?.kind===`activity`&&!!bH(y.entries).live,[x,S]=(0,m.useState)(!1);return(0,m.useEffect)(()=>S(!0),[]),(0,V.jsxs)(oB,{"aria-label":`Conversation`,"data-bare":!0,className:`flex-1 rounded-none border-0 shadow-none`,children:[(0,V.jsx)(`div`,{ref:s,onScroll:g,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:v?(0,V.jsx)(NH,{hasTask:a}):(0,V.jsxs)(`div`,{className:`chat-column`,children:[f?(0,V.jsx)(`p`,{className:`mb-4 text-center text-xs text-muted-foreground`,children:`Earlier messages load as you scroll up.`}):null,_.map((e,t)=>{if(e.kind===`activity`)return(0,V.jsx)(SH,{entries:e.entries},e.key);let n=_[t-1],r=n?.kind===`message`?n.entry:void 0,i=!r||r.role!==e.entry.role||e.entry.at-r.at>TH;return(0,V.jsx)(jH,{entry:e.entry,head:i,fresh:x},e.entry.id)}),(0,V.jsx)(MH,{text:n,busy:r,working:b})]})}),(0,V.jsx)(Vv,{target:s,down:!1}),c?null:(0,V.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-dock z-10 flex justify-center [&>*]:pointer-events-auto`,children:(0,V.jsx)(iH,{onClick:l})})]})}function RH(e){let t=e[0]===`ask`,[n,r]=t?e.slice(1):e;return{chat:t,agent:n,file:r}}function zH(e,t){let{agent:n,file:r}=RH(e);return dO(`knowledge`,...t?[`ask`]:[],n??``,r??``)}var BH=[`master`,`designer`,`backend`,`qa`],VH={master:`Master (oracle)`,designer:`Designer`,backend:`Backend`,qa:`QA`},HH={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`},UH=`Every write archives the version before it.`;function WH(e){if(e<1e3)return String(e);let t=e/1e3;return`${t>=10?Math.round(t):t.toFixed(1)}k`}function GH(e){return`over the compaction threshold — ask the oracle to compact ${e}`}function KH(e){return{text:e.text,occurrence:e.occurrence}}function qH(e){return BH.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 JH(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function YH({initial:e,busy:t,onSave:n,onCancel:r}){let[i,a]=(0,m.useState)(e),o=()=>{!t&&i.trim()&&n(i)};return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-input p-3`,children:[(0,V.jsx)(`label`,{htmlFor:`knowledge-entry`,className:`text-sm font-medium text-foreground`,children:`Edit entry`}),(0,V.jsx)(Ck,{id:`knowledge-entry`,value:i,rows:4,autoFocus:!0,onChange:e=>a(e.target.value),onKeyDown:e=>{JH(e)&&(e.preventDefault(),o())}}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:UH}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(Y,{variant:`outline`,onClick:r,disabled:t,children:`Cancel`}),(0,V.jsxs)(Y,{onClick:o,disabled:t||!i.trim(),children:[t?(0,V.jsx)(bO,{}):null,`Save`]})]})]})]})}function XH({open:e,file:t,initial:n,busy:r,onClose:i,onSave:a}){let[o,s]=(0,m.useState)(n),c=nO(e,tO.confirm);return(0,V.jsx)(JD,{open:e&&c,onOpenChange:e=>!e&&i(),label:`Edit ${t}`,description:UH,dismissOnBackdrop:!1,className:`max-w-3xl`,children:(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`h2`,{className:`text-base font-medium`,children:[`Edit `,t]}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:UH})]}),(0,V.jsx)(Ck,{value:o,rows:14,className:`min-h-0 flex-1 font-mono text-sm`,onChange:e=>s(e.target.value)}),(0,V.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,V.jsx)(Y,{variant:`outline`,onClick:i,disabled:r,children:`Cancel`}),(0,V.jsxs)(Y,{onClick:()=>a(o),disabled:r,children:[r?(0,V.jsx)(bO,{}):null,`Save file`]})]})]})})}function ZH({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,V.jsxs)(`li`,{className:`flex items-start gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(ig,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-primary`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:i}),(0,V.jsx)(nk,{label:`Take the note back`,icon:Jg,iconOnly:!0,className:`-my-1 size-7`,disabled:r,onClick:()=>n(e.id)})]})}function QH({entry:e,index:t,selected:n,notes:r,onPick:i,onTakeBack:a,busy:o}){let s=()=>i(t);return(0,V.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,V.jsx)(`div`,{className:`flex gap-2`,children:(0,V.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,V.jsx)(aB,{text:e.text})})}),r.length>0?(0,V.jsx)(`ul`,{className:`flex flex-col gap-1 pl-1`,children:r.map(e=>(0,V.jsx)(ZH,{note:e,onTakeBack:a,busy:o},e.id))}):null]})}function $H({notes:e,onTakeBack:t,busy:n}){return e.length===0?null:(0,V.jsx)(cB,{title:`Notes on entries that changed`,right:String(e.length),children:(0,V.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,V.jsx)(ZH,{note:e,about:e.entry,onTakeBack:t,busy:n},e.id))})})}function eU({view:e}){let t=e.entries.length;return(0,V.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsxs)(`h2`,{className:`min-w-0 break-words text-lg font-semibold tracking-tight`,children:[HH[e.agent],` `,(0,V.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,e.file]})]}),(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` `,t===1?`entry`:`entries`,` · `,WH(e.chars),` chars`]}),e.over?(0,V.jsx)(`p`,{className:`text-sm text-foreground`,children:GH(e.file)}):null]})}function tU({draft:e,picked:t,setDraft:n,onEditFile:r,onDelete:i}){let a=!!e;return(0,V.jsxs)(rk,{children:[(0,V.jsx)(nk,{label:`Edit the entry`,text:`Edit`,icon:og,shortcut:`E`,disabled:a||!t,onClick:()=>n({kind:`edit`,entry:t})}),(0,V.jsx)(nk,{label:t?`Add an entry after it`:`Add an entry`,text:`Add`,icon:ug,shortcut:`A`,disabled:a,onClick:()=>n({kind:`add`,entry:t})}),(0,V.jsx)(nk,{label:`Comment on the entry`,text:`Comment`,icon:Mh,shortcut:`C`,disabled:a||!t,onClick:()=>n({kind:`comment`,entry:t})}),(0,V.jsx)(nk,{label:`Edit the whole file`,text:`Edit file`,icon:Km,shortcut:`F`,disabled:a,onClick:r}),(0,V.jsx)(Rk,{icon:Wg,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 nU({agent:e,file:t,onChanged:n}){let r=MO(`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(()=>U(`knowledge.unnote`,{id:e})),v=()=>{h&&g(()=>U(`knowledge.remove`,{agent:e,file:t,ref:KH(h)}))},y=n=>{let r=o?.entry;if(o?.kind===`edit`&&r)return void g(()=>U(`knowledge.edit`,{agent:e,file:t,ref:KH(r),text:n}));if(o?.kind===`comment`&&r)return void g(()=>U(`knowledge.comment`,{agent:e,file:t,ref:KH(r),text:n}));g(()=>U(`knowledge.add`,{agent:e,file:t,...h?{ref:KH(h)}:{},text:n}))};return f?(0,V.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${HH[e]} ${t}`,children:[(0,V.jsx)(tU,{draft:o,picked:h,setDraft:s,onEditFile:()=>l(!0),onDelete:v}),(0,V.jsx)(eU,{view:f}),p.length===0?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing here yet. Add the first entry below.`}):null,(0,V.jsx)(`ul`,{className:`workspace-section flex flex-col gap-2 rounded-xl border p-3 shadow-xs`,children:p.map((e,t)=>(0,V.jsx)(QH,{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,V.jsx)(YH,{initial:o.entry.text,busy:u,onSave:y,onCancel:()=>s(void 0)}):null,o?.kind===`comment`?(0,V.jsx)(eV,{label:`Comment on this entry`,hint:UH,buttonLabel:`Add note`,onSend:async e=>(y(e),!0)}):null,o?.kind===`add`?(0,V.jsx)(eV,{label:`Add an entry`,hint:UH,buttonLabel:`Add entry`,onSend:async e=>(y(e),!0)}):null,u&&!o?(0,V.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(bO,{}),` saving…`]}):null,(0,V.jsx)($H,{notes:f.detached,onTakeBack:_,busy:u}),(0,V.jsx)(XH,{open:c,file:t,initial:f.content,busy:u,onClose:()=>l(!1),onSave:n=>{l(!1),g(()=>U(`knowledge.replaceFile`,{agent:e,file:t,text:n}))}})]}):r.error?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not read the file. `,r.error]}):(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`reading…`})}function rU(e){return`${e.agent}/${e.file}`}var iU=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function aU({info:e}){return(0,V.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs text-muted-foreground tabular-nums`,children:[(0,V.jsx)(`span`,{children:WH(e.chars)}),e.over?(0,V.jsx)(`span`,{className:`text-foreground`,children:`· over`}):null,e.notes>0?(0,V.jsx)(`span`,{className:`text-primary`,children:iU(e.notes,`note`)}):null]})}function oU({name:e}){let t=e.split(`.`).pop()?.toLowerCase();return t===`md`||t===`mdx`||t===`txt`?(0,V.jsx)(Xm,{"aria-hidden":`true`,className:`ktree-icon`,"data-ext":`md`}):t===`json`||t===`yaml`||t===`yml`||t===`toml`?(0,V.jsx)(Wm,{"aria-hidden":`true`,className:`ktree-icon`,"data-ext":`data`}):(0,V.jsx)(Qm,{"aria-hidden":`true`,className:`ktree-icon`})}function sU({info:e,selected:t,onSelect:n}){return(0,V.jsx)(`li`,{className:`ktree-leaf`,children:(0,V.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(rU(e)),title:e.label,className:`ktree-row ktree-file`,children:[(0,V.jsx)(oU,{name:e.file}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,V.jsxs)(`span`,{className:`sr-only`,children:[e.label,`, `]}),(0,V.jsx)(`span`,{"aria-hidden":`true`,children:e.file})]}),(0,V.jsx)(aU,{info:e})]})})}var cU=`bot-lobby.knowledge.folded`;function lU(){try{let e=JSON.parse(window.localStorage.getItem(cU)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function uU({files:e,models:t={},selectedKey:n,onSelect:r}){let[i,a]=(0,m.useState)(lU),o=qH(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(cU,JSON.stringify(r))}catch{}return r})}return(0,V.jsxs)(`div`,{className:`ktree px-2 pt-2 pb-3`,children:[(0,V.jsxs)(`p`,{className:`ktree-row ktree-root`,children:[(0,V.jsx)(mh,{"aria-hidden":`true`,className:`ktree-icon`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:`Project knowledge`}),(0,V.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[iU(e.length,`file`),` · `,iU(o.length,`agent`),s>0?` · ${iU(s,`note`)}`:``]})]}),(0,V.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,V.jsxs)(`li`,{className:`ktree-branch`,children:[(0,V.jsx)(`h3`,{className:`font-normal`,children:(0,V.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,V.jsx)(cm,{"aria-hidden":`true`,className:J(`ktree-chevron`,a&&`rotate-90`)}),a?(0,V.jsx)(eh,{"aria-hidden":`true`,className:`ktree-icon ktree-folder`}):(0,V.jsx)(nh,{"aria-hidden":`true`,className:`ktree-icon ktree-folder`}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,V.jsx)(`span`,{className:`text-foreground`,children:VH[e.agent]}),s?(0,V.jsxs)(`span`,{className:`ms-2 text-xs text-muted-foreground`,children:[(0,V.jsx)(`span`,{className:`sr-only`,children:`runs on `}),s]}):null]}),(0,V.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[e.notes>0?(0,V.jsxs)(`span`,{className:`text-primary`,children:[iU(e.notes,`note`),` · `]}):null,iU(e.files.length,`file`)]})]})}),(0,V.jsx)(Fu,{initial:!1,children:a?(0,V.jsx)($f.ul,{id:o,"aria-label":`${VH[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,V.jsx)(sU,{info:e,selected:rU(e)===n,onSelect:r},rU(e)))},`files`):null})]},e.agent)})})]})}var dU=()=>fO(dO(`knowledge`)),fU=e=>{let[t,n]=e.split(`/`);fO(dO(`knowledge`,t??``,n??``))};function pU(){return(0,V.jsx)(mO,{className:`m-4 flex-1`,children:(0,V.jsxs)(hO,{children:[(0,V.jsx)(_O,{variant:`icon`,children:(0,V.jsx)(Xp,{"aria-hidden":`true`})}),(0,V.jsx)(yO,{children:`No knowledge files yet.`})]})})}function mU(e,t,n,r){let i=e.find(e=>e.agent===t&&e.file===n);return i?(0,V.jsx)(nU,{agent:i.agent,file:i.file,onChanged:r},rU(i)):t&&n?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That file is not on the list any more.`}):null}function hU(){let e=AO(`lobby`),t=AO(`status`),n=e.data,r=t.data?.busy??!1;return!n?.chat.length&&!n?.reply&&!r?(0,V.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,V.jsx)(LH,{chat:n?.chat??[],reply:n?.reply,busy:r,hasOlder:n?.hasOlderChat??!1,hasTask:!!n?.task})}function gU({read:e,selected:t}){let n=e.data?.files.reduce((e,t)=>e+t.notes,0)??0;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(xk,{title:`Knowledge`,count:n>0?`${n} note${n===1?``:`s`}`:void 0}),(0,V.jsx)(_U,{read:e,selected:t})]})}function _U({read:e,selected:t}){return!e.data&&e.error?(0,V.jsx)(EO,{message:`Could not load the knowledge files. ${e.error}`,onRetry:e.reload}):e.data?e.data.files.length?(0,V.jsx)(uU,{files:e.data.files,models:e.data.models??{},selectedKey:t,onSelect:fU}):(0,V.jsx)(pU,{}):(0,V.jsx)(Sk,{})}function vU({rest:e}){let{chat:t,agent:n,file:r}=RH(e),i=gk(),a=MO(`knowledge.files`,{},[`knowledge`]),o=a.data?.files??[],s=o.find(e=>e.agent===n&&e.file===r);return(0,V.jsx)(bk,{wide:i,inlineDetail:!0,list:(0,V.jsx)(gU,{read:a,selected:s?rU(s):void 0}),detail:t?(0,V.jsx)(hU,{}):mU(o,n,r,a.reload),detailClassName:t?`flex flex-col overflow-hidden p-0`:void 0,open:t||!!(n&&r),onClose:dU,hint:`Select a file to read its entries, or ask about the project below.`,describe:t?`Knowledge chat`:`Knowledge file`})}function yU(e){let t=e[0];try{return{id:t?decodeURIComponent(t):void 0}}catch{return{id:t}}}var bU=e=>e?.panels??{conversation:!0,activity:!0,thinking:!0};function xU({data:e,status:t}){let n=bU(t);if(!n.conversation)return null;let r=n.activity?e?.activity:void 0;return(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,V.jsx)(LH,{chat:e?.chat??[],...r?{activity:r}:{},reply:e?.reply,busy:t?.busy??!1,hasOlder:e?.hasOlderChat??!1,hasTask:!!e?.task})})}function SU(){let e=AO(`lobby`),t=AO(`status`);return!e.data&&e.loading?(0,V.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(bO,{}),(0,V.jsx)(`span`,{children:`Connecting…`})]}):!e.data&&e.error?(0,V.jsx)(EO,{message:e.error,onRetry:()=>P.onHello({})}):(0,V.jsx)(xU,{data:e.data,status:t.data})}var CU=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 wU(e,t){return JSON.stringify([e,`prompt`,t])}function TU(e,t,n){return JSON.stringify([e,`dialog`,t,n])}function EU(e,t,n){return JSON.stringify([e,`delivery`,t,n])}var DU=`bot-lobby.prompt-sound-muted`,OU=new Set,kU,AU=!1;function jU(){try{return localStorage.getItem(DU)===`on`}catch{return AU}}function MU(e){AU=e;try{localStorage.setItem(DU,e?`on`:`off`)}catch{}for(let e of OU)e()}function NU(e){return OU.add(e),()=>{OU.delete(e)}}function PU(){return(0,m.useSyncExternalStore)(NU,jU,()=>!1)}function FU(){(0,m.useEffect)(()=>{let e=()=>{try{kU??=new AudioContext,kU.resume().catch(()=>void 0)}catch{}};return window.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,e)}},[])}function IU(){if(!jU()&&kU&&kU.state===`running`)try{let e=kU.currentTime,t=kU.createOscillator(),n=kU.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(kU.destination),t.start(e),t.stop(e+.24),t.onended=()=>{t.disconnect(),n.disconnect()}}catch{}}var LU=`bot-lobby.notifications`,RU=`/icon-192.png`,zU=new Set;function BU(){for(let e of[...zU])e()}function VU(){try{return localStorage.getItem(LU)===`on`}catch{return!1}}function HU(e){return zU.add(e),()=>{zU.delete(e)}}function UU(e){try{localStorage.setItem(LU,e?`on`:`off`)}catch{}BU()}function WU(){return(0,m.useSyncExternalStore)(HU,VU,()=>!1)}async function GU(){return typeof Notification>`u`?`unsupported`:(Notification.permission==="default"&&await Notification.requestPermission().catch(()=>void 0),Notification.permission===`granted`?(UU(!0),`granted`):`denied`)}function KU(){UU(!1)}function qU(e){if(e===`completed`)return`finished`;if(e===`abandoned`)return`dropped`}function JU(){return typeof Notification<`u`&&Notification.permission===`granted`&&document.hidden}function YU(e){try{new Notification(`bot-lobby`,{body:e,icon:RU,tag:`bot-lobby`})}catch{}}function XU(){try{return new CU(sessionStorage)}catch{return new CU}}function ZU(e,t){let n=t.payload;return t.kind===`sessionDialog`&&n?.dialog?.id?TU(e,t.sessionId??n.key??t.from,n.dialog.id):wU(e,t.id)}function QU(){let e=WU();FU(),OO();let t=MO(`tasks.list`,{},[`tasks`]),n=MO(`sessions.list`,{},[`sessions`]),r=P.get(`prompts`),i=P.get(`lobby`).data,a=(0,m.useRef)(XU()),o=(0,m.useRef)(new Set([`prompts`,`sessions`,`delivery`])),s=(0,m.useRef)(void 0),c=pe()??`current`,l=P.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 $U(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(()=>IU()),c&&JU()&&YU(r),t===`delivery`&&mp.info(r,{action:{label:`Review tasks`,onClick:()=>fO(`#/tasks`)}}))}function eW(e){let{prompts:t,sessions:n,tasks:r,project:i}=e,a=t.data?.prompts;$U(e,`prompts`,(a??[]).map(e=>ZU(i,e)),`A question is waiting for you.`,!!a&&!t.loading),$U(e,`sessions`,n.data?.background.flatMap(e=>e.dialogs.map(t=>TU(i,e.sessionId??e.key,t.id)))??[],`A background session is asking something.`,!!n.data&&!n.loading),$U(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=>EU(i,e.id,e.delivery.reviewId))??[],`Completed work is ready for delivery review in Tasks.`,!!r.data&&!r.loading)}function tW(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}eW(e);let s=a?.task?.state??``,c=qU(s);i.current&&c&&s!==i.current&&o&&JU()&&YU(`${a?.task?.title??`The task`} ${c}.`),i.current=s}function nW(){let e=QU(),{connection:t,enabled:n,project:r,prompts:i,sessions:a,tasks:o,lobby:s}=e;(0,m.useEffect)(()=>tW(e),[t,n,r,i.data,i.loading,a.data,a.loading,o.data,o.loading,s])}function rW({className:e,type:t,...n}){return(0,V.jsx)(`input`,{type:t,"data-slot":`input`,className:J(`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 iW({className:e,thumbClassName:t,...n}){return(0,V.jsx)(JE,{"aria-keyshortcuts":`Enter Space`,"aria-description":`When focused, press Enter or Space to toggle.`,"data-slot":`switch`,className:J(`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,V.jsx)(XE,{"data-slot":`switch-thumb`,className:J(`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 aW(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}function oW(e,t,n,r){for(let i=n+r;i>=0&&i<e.length;i+=r)if(t.includes(e[i]))return i;return n}var sW={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 cW(e,t,n,r){let i=Math.max(t.length-1,1);if(e===`ArrowRight`||e===`ArrowUp`)return oW(t,n,r,1);if(e===`ArrowLeft`||e===`ArrowDown`)return oW(t,n,r,-1);if(e===`Home`)return aW(t,n,0);if(e===`End`)return aW(t,n,i)}function lW(e,t,n,r,i){let a=e.current?.getBoundingClientRect();if(!a||a.width===0)return i;let o=Math.min(1,Math.max(0,(t-a.left)/a.width));return aW(n,r,Math.round(o*Math.max(n.length-1,1)))}function uW(e){let[t,n]=(0,m.useState)(),r=(0,m.useRef)(void 0),i=(0,m.useRef)(0),a=(0,m.useCallback)(()=>{r.current=void 0,i.current=0,n(void 0)},[]);return(0,m.useEffect)(()=>{if(t===void 0)return;let e=window.setTimeout(a,1e4);return()=>window.clearTimeout(e)},[t,a]),{chosenByKey:t,intended:r,choose:(t,o)=>{r.current=t,n(t),i.current+=1,Promise.resolve(e(o)).catch(()=>void 0).then(()=>{--i.current,i.current<=0&&a()})}}}function dW({levels:e,supported:t,value:n,disabled:r,onChange:i}){let a=(0,m.useRef)(null),[o,s]=(0,m.useState)(),c=uW(i),l=aW(e,t,Math.max(0,e.indexOf(n))),u=o??c.chosenByKey??l,d=n=>lW(a,n,e,t,l);function f(e){r||t.length===0||(e.currentTarget.setPointerCapture(e.pointerId),s(d(e.clientX)))}function p(e){if(o===void 0)return;let t=d(e.clientX);t!==o&&s(t)}function h(){if(o===void 0)return;let t=e[o];s(void 0),t&&t!==n&&i(t)}function g(n){if(r||u<0)return;let i=c.intended.current??u,a=cW(n.key,e,t,i);if(a===void 0)return;n.preventDefault();let o=e[a];o&&a!==i&&c.choose(a,o)}function _(n){let i=e[n];!r&&i&&t.includes(i)&&n!==(c.intended.current??u)&&c.choose(n,i)}return{track:a,shown:u,dragging:o!==void 0,jump:_,handlers:{onPointerDown:f,onPointerMove:p,onPointerUp:h,onPointerCancel:()=>s(void 0),onKeyDown:g}}}var fW={xhigh:`Extra high`},pW=e=>fW[e]??`${e.charAt(0).toUpperCase()}${e.slice(1)}`,mW={type:`spring`,stiffness:520,damping:36},hW={xhigh:{type:`spring`,stiffness:120,damping:20,mass:1.4},max:{type:`spring`,stiffness:46,damping:13,mass:2.2}},gW={xhigh:1100,max:2e3},_W=3;function vW(e,t){let[n,r]=(0,m.useState)(),i=(0,m.useRef)(e);return(0,m.useEffect)(()=>{let n=i.current;if(i.current=e,t||n===e||e!==`xhigh`&&e!==`max`||e===`xhigh`&&n===`max`)return;r(e);let a=window.setTimeout(()=>r(void 0),gW[e]);return()=>window.clearTimeout(a)},[e,t]),n}var yW=`1.625rem`,bW=`1.25rem`;function xW({value:e,levels:t,supported:n,recommended:r,model:i,label:a,disabled:o,onChange:s}){let c=kf()??!1,l=dW({levels:t,supported:n,value:e,disabled:o,onChange:s}),{shown:u,dragging:d}=l,f=Math.max(t.length-1,1),p=Math.max(u,0),m=t[u]??e,h=p===t.length-1&&t.length>1,g=u>=0&&!d&&m!==e,_=r?aW(t,n,Math.max(0,t.indexOf(r))):-1,v=i??`this model`,y=vW(m,c),b=d||c?{duration:0}:y?hW[y]:mW,x=[`high`,`xhigh`,`max`].includes(m),S=e=>`calc(${yW} + (100% - 2 * ${yW}) * ${e/f})`,C=`${a.replace(/\W+/g,`-`)}-hint`;return(0,V.jsxs)(`div`,{className:J(`effort grid min-w-0 gap-1`,o&&`opacity-64`),"data-off":m===`off`||void 0,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,"aria-hidden":`true`,children:[`Effort`,` `,(0,V.jsx)(`span`,{"data-slot":`effort-value`,className:`font-semibold text-foreground`,children:pW(m)})]}),(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`About effort`,"aria-describedby":C,"data-compact":!0,className:`effort-help inline-flex size-6 shrink-0 items-center justify-center rounded-md text-xs font-semibold text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:`?`})}),(0,V.jsxs)(IO,{className:`max-w-64`,children:[sW[m]??``,` More effort means more reasoning before each answer: slower and costlier, better on hard problems.`]})]})]}),(0,V.jsxs)(`div`,{role:`slider`,tabIndex:o?-1:0,"aria-label":a,"aria-valuemin":0,"aria-valuemax":t.length-1,"aria-valuenow":p,"aria-valuetext":m,"aria-describedby":C,"aria-disabled":o||void 0,...l.handlers,"data-slot":`effort-track`,"data-level":m,"data-top":h||void 0,"data-dragging":d||void 0,"data-charge":y,className:`effort-track relative h-10 cursor-pointer touch-none rounded-md outline-none select-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,children:[m===`max`?(0,V.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`effort-aura`,className:`effort-aura pointer-events-none absolute -inset-1 rounded-lg`}):null,(0,V.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`effort-rail`,className:`effort-rail absolute inset-0 overflow-hidden rounded-md`,children:(0,V.jsxs)($f.span,{"data-slot":`effort-fill`,className:`effort-fill absolute inset-y-0 left-0 rounded-md`,initial:!1,animate:{width:`calc(${S(p)} + ${bW})`},transition:b,children:[(0,V.jsx)(`span`,{className:`effort-flow absolute inset-y-0 left-0`}),x&&m!==`max`?(0,V.jsx)(`span`,{"data-slot":`effort-embers`,className:`effort-embers absolute inset-0`}):null,m===`max`?(0,V.jsxs)(`span`,{"data-slot":`effort-warp`,className:`effort-warp absolute inset-0`,children:[Array.from({length:_W},(e,t)=>(0,V.jsx)(`span`,{className:`effort-stars absolute inset-y-0 left-0`,"data-layer":t},t)),(0,V.jsx)(`span`,{className:`effort-streaks absolute inset-y-0 left-0`}),(0,V.jsx)(`span`,{className:`effort-tunnel absolute inset-0`})]}):null,h?(0,V.jsx)(`span`,{"data-slot":`effort-sheen`,className:`effort-sheen absolute inset-0`}):null]})}),(0,V.jsx)(`div`,{ref:l.track,"aria-hidden":`true`,className:`absolute inset-y-0`,style:{left:yW,right:yW}}),t.map((e,t)=>{let r=n.includes(e);return(0,V.jsx)(`span`,{"aria-hidden":`true`,"data-stop":e,"data-supported":r,title:r?pW(e):`Not supported by ${v}`,className:J(`absolute top-1/2 size-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full transition-colors duration-200`,r?t<=p?`effort-dot-lit`:`effort-dot`:`ring-1 ring-muted-foreground/50`),style:{left:S(t)}},e)}),_>=0&&_!==p?(0,V.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`effort-recommended-mark`,className:`effort-mark absolute top-1/2 size-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full`,style:{left:S(_)}}):null,(0,V.jsx)($f.span,{"aria-hidden":`true`,"data-slot":`effort-thumb`,className:`absolute top-1/2 z-10`,initial:!1,animate:{left:S(p)},transition:b,children:(0,V.jsx)($f.span,{className:`effort-thumb block h-8 w-10 -translate-x-1/2 -translate-y-1/2 rounded-md`,initial:!1,animate:{scale:d===void 0?1:1.08,scaleX:d===void 0?1:1.12},transition:c?{duration:0}:{type:`spring`,stiffness:600,damping:20}})})]}),(0,V.jsxs)(`div`,{"aria-hidden":`true`,className:`relative flex h-4 justify-between px-1 text-xs text-muted-foreground`,children:[(0,V.jsx)(`span`,{className:J(_>=0&&_/f<.3&&`invisible`),children:`Faster`}),(0,V.jsx)(`span`,{className:J(_>=0&&_/f>.7&&`invisible`),children:`Smarter`}),_>=0?(0,V.jsx)(`span`,{"data-slot":`effort-recommended`,className:J(`absolute top-0 -translate-x-1/2 whitespace-nowrap transition-colors`,p===_?`font-medium text-foreground`:`text-muted-foreground`),style:{left:`clamp(2.75rem, ${S(_)}, calc(100% - 2.75rem))`},children:`Recommended`}):null]}),(0,V.jsx)(`p`,{id:C,"data-slot":`effort-hint`,className:`sr-only`,"aria-live":`polite`,children:sW[m]??``}),g?(0,V.jsxs)(`p`,{className:`text-xs text-warning`,children:[e,` is not supported by `,v,`, so it runs at `,m,`.`]}):null]})}function SW(e){return(0,V.jsx)(PE,{...e})}function CW(e){return(0,V.jsx)(FE,{"data-slot":`popover-trigger`,...e})}function wW({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,V.jsx)(IE,{children:(0,V.jsx)(LE,{"data-slot":`popover-content`,align:t,sideOffset:n,className:J(`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 TW=`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`,EW=`-me-1 size-3 shrink-0 opacity-50`;function DW(e,t){let n=`${e.label} ${e.hint??``} ${e.value}`.toLowerCase();return t.toLowerCase().split(/\s+/).filter(Boolean).every(e=>n.includes(e))}function OW({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=>DW(e,c)),[t,c]),g=t.find(t=>t.value===e);(0,m.useEffect)(()=>{o&&(l(``),d(Math.max(0,t.findIndex(t=>t.value===e))))},[o]),(0,m.useEffect)(()=>{c&&d(0)},[c]),(0,m.useEffect)(()=>{f.current?.querySelector(`[data-index="${u}"]`)?.scrollIntoView({block:`nearest`})},[u,o,h.length]);function _(t){t&&(s(!1),t.value!==e&&n(t.value))}function v(e){e.key===`ArrowDown`?(e.preventDefault(),d(e=>Math.min(h.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),d(e=>Math.max(0,e-1))):e.key===`Home`&&!c?(e.preventDefault(),d(0)):e.key===`End`&&!c?(e.preventDefault(),d(Math.max(0,h.length-1))):e.key===`Tab`?s(!1):e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),_(h[u]))}return(0,V.jsxs)(SW,{open:o,onOpenChange:s,children:[(0,V.jsxs)(CW,{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:J(TW,`w-full min-w-0 overflow-hidden whitespace-nowrap`,i),children:[(0,V.jsx)(`span`,{className:`min-w-0 truncate`,children:g?.label??e}),(0,V.jsx)(im,{"aria-hidden":`true`,strokeWidth:2.25,className:EW})]}),(0,V.jsxs)(wW,{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,V.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-2.5`,children:[(0,V.jsx)(wg,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),onKeyDown:v,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,V.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,V.jsxs)(`p`,{className:`px-2.5 py-2 text-xs text-muted-foreground`,children:[`Nothing matches “`,c,`”.`]}):null,h.map((t,n)=>(0,V.jsx)(`div`,{id:`${p}-${n}`,role:`option`,"aria-selected":t.value===e,"data-index":n,onPointerMove:()=>d(n),onClick:()=>_(t),className:J(`flex min-h-8 cursor-pointer items-center gap-2 rounded-sm px-2 py-1 text-sm select-none sm:min-h-7`,t.value===e&&`bg-foreground/[0.08]`,n===u&&`bg-accent text-accent-foreground`),children:(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,V.jsx)(`span`,{className:`truncate`,children:t.label}),t.hint?(0,V.jsx)(`span`,{className:`line-clamp-2 text-pretty text-xs text-muted-foreground/80`,children:t.hint}):null]})},t.value))]})]})]})}var kW=Wv([`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 AW({className:e,variant:t,spacing:n,stacked:r,dense:i,...a}){return(0,V.jsx)(`div`,{className:J(kW({variant:t,spacing:n,stacked:r,dense:i}),e),"data-slot":`frame`,"data-spacing":n,...a})}function jW({className:e,fit:t,...n}){return(0,V.jsx)(`div`,{className:J(`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 MW({label:e,help:t,children:n,stacked:r}){return(0,V.jsxs)(`div`,{className:r?`grid gap-1`:`grid grid-cols-[minmax(0,1fr)_minmax(0,18rem)] items-center gap-4`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 break-words`,children:[(0,V.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:e}),t?(0,V.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:t}):null]}),(0,V.jsx)(`div`,{className:`min-w-0`,children:n})]})}function NW({children:e}){return(0,V.jsx)(AW,{dense:!0,children:(0,V.jsx)(jW,{className:`flex flex-col divide-y divide-border py-0 [&>*]:py-2`,children:e})})}function PW({value:e,items:t,label:n,onChange:r}){return(0,V.jsx)(OW,{value:e,options:t.map(e=>({value:e.value,label:e.label,...e.help?{hint:e.help}:{}})),label:n,onChange:r})}var FW=`(prefers-color-scheme: dark)`,IW=[`dark`,`light`,`system`],LW=m.createContext(void 0);function RW(e){return e!==null&&IW.includes(e)}function zW(){return window.matchMedia(FW).matches?`dark`:`light`}function BW(){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 VW(e){return e instanceof HTMLElement&&!!(e.isContentEditable||e.closest(`input, textarea, select, [contenteditable='true']`))}function HW({children:e,defaultTheme:t=`system`,storageKey:n=`theme`,disableTransitionOnChange:r=!0,...i}){let[a,o]=m.useState(()=>{let e=localStorage.getItem(n);return RW(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`?zW():e,i=r?BW():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(FW),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||VW(e.target)||e.key.toLowerCase()===`d`&&o(e=>{let t=e===`dark`?`light`:e===`light`?`dark`:zW()===`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(RW(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,V.jsx)(LW.Provider,{...i,value:l,children:e})}var UW=()=>{let e=m.useContext(LW);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e};function WW({kind:e,dense:t=!1}){let n=e===`font`?Ve:He,r=Ze(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];Ye(e,s.id),requestAnimationFrame(()=>i.current?.querySelector(`[data-face="${s.id}"]`)?.focus())}return(0,V.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=Qe[n.id];return(0,V.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":i,"data-face":n.id,tabIndex:i?0:-1,onClick:()=>Ye(e,n.id),className:J(`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`:J(`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,V.jsx)(`span`,{"aria-hidden":`true`,className:J(`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,V.jsxs)(`span`,{className:J(`flex min-w-0 items-center justify-between gap-2`,t&&`flex-1`),children:[(0,V.jsxs)(`span`,{className:`min-w-0`,children:[(0,V.jsx)(`span`,{className:`block truncate text-[0.8125rem] font-medium`,children:n.label}),t?null:(0,V.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:n.help})]}),i?(0,V.jsx)(nm,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]})]},n.id)})})}var GW=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`quickfix`,`planner`],KW={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scout`,researcher:`Researcher`,quickfix:`Quick fix`,planner:`Planner`},qW=`inherit`,JW=`inherit`,YW=`Use the session's current model`,XW=`__custom__`,ZW=`custom…`,QW=`Type a provider/model id`,$W={master:`high`,designer:`medium`,backend:`medium`,qa:`medium`,scout:`low`,researcher:`low`,quickfix:`low`,planner:`high`},eG=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],tG={agents:`Agents`,workflow:`Workflow`,lint:`Linting`,lobby:`Lobby`,classifier:`Classifier`,appearance:`Appearance`,notifications:`Notifications`,install:`Install as app`},nG=[{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)`},{id:`issues`,label:`Issues`,help:`GitHub issues under Git`}],rG=[{id:`conversation`,label:`Conversation pane`},{id:`activity`,label:`Activity steps in the conversation`},{id:`thinking`,label:`Thinking bubble`}],iG=`shown on the Lobby tab`,aG=`Planning rounds`,oG=`how many rounds the panel gets before the oracle settles the rest alone`,sG=[2,3,5,8,0],cG=`Split long plans`,lG=`saving a plan with more steps offers to split it into up to 5 tasks`,uG=[6,8,10,12,0],dG=`Port`,fG=`the base port (then the next free up to +20); 0 means any free port; applies the next time pi starts`,pG=`Open browser`,mG=`open this page in the browser when pi starts`,hG=[{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`}],gG=`Git isolation`,_G=[{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`}],vG={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`},yG=[{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`}],bG=[{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:`triage`,label:`Task triage`,help:`a new task's size, domains and research need reach the Master as hints; a quick fix that is really a task is held for you`},{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, quick fixes and the planning panel start with the files most likely needed, and can look more up with find_relevant_files`}],xG={enabled:`Classifier`,enabledHelp:`a fast model makes the obvious decisions so large models spend fewer tokens on them`,engine:`Answered by`,engineHelp:`Jev, another classifier model, or any chat model your pi logins offer (OpenAI, Anthropic, Google, …); a small, fast one works best`,engineJev:`Jev on a host`,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`},SG={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`},CG=`https://tweakcn.com/editor/theme`;function wG(){let{theme:e}=UW();return e===`dark`||e===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}function TG({palette:e,dark:t}){let n=oe(e,t);return(0,V.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,V.jsx)(`span`,{className:`size-4 rounded-full border border-black/10`,style:{background:n.card}}),(0,V.jsx)(`span`,{className:`size-4 rounded-full`,style:{background:n.primary}}),(0,V.jsx)(`span`,{className:`h-2 flex-1 rounded-full`,style:{background:n.accent}})]})}function EG(){let e=Be(),t=wG(),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,V.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,V.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:J(`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,V.jsx)(TG,{palette:n,dark:t}),(0,V.jsxs)(`span`,{className:`flex min-w-0 items-center justify-between gap-2 px-0.5 text-[0.8125rem] font-medium`,children:[(0,V.jsxs)(`span`,{className:`truncate`,children:[n.name,e.isSaved(n.id)?(0,V.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:`saved`}):null]}),r?(0,V.jsx)(nm,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]})]},n.id)})})}function DG({entry:e}){let t=Be(),[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),mp.success(`Renamed to ${n}.`)}catch(e){s(e.message)}}return(0,V.jsxs)(`li`,{className:`flex min-h-10 flex-wrap items-center gap-2 py-1.5`,children:[n?(0,V.jsxs)(`form`,{className:`flex min-w-0 flex-1 items-center gap-1`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,V.jsx)(rW,{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,V.jsx)(nk,{label:`Save the name`,text:`Save`,icon:nm,tone:`primary`,type:`submit`,disabled:!i.trim()}),(0,V.jsx)(nk,{label:`Keep the old name`,icon:o_,iconOnly:!0,onClick:()=>{a(e.name),r(!1)}})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),(0,V.jsx)(nk,{label:`Rename ${e.name}`,text:`Rename`,icon:og,onClick:()=>{a(e.name),r(!0)}}),(0,V.jsx)(Rk,{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:Wg,variant:`destructive`,onConfirm:()=>void t.remove(e.id).catch(e=>mp.error(e.message))})]}),o?(0,V.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,children:o}):null]})}function OG(){let e=Be();return e.saved.length===0?(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No saved themes yet. Import one below and give it a name.`}):(0,V.jsx)(`ul`,{"aria-label":`Saved themes`,className:`divide-y divide-border`,children:e.saved.map(e=>(0,V.jsx)(DG,{entry:e},e.id))})}function kG(){let e=Be(),[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=te(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`;mp.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,V.jsxs)(`div`,{className:`grid gap-2`,children:[(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Pick or build a theme in the`,` `,(0,V.jsxs)(`a`,{href:CG,target:`_blank`,rel:`noreferrer noopener`,className:`inline-flex items-center gap-0.5 text-link underline-offset-2 hover:underline`,children:[`tweakcn editor `,(0,V.jsx)(Hm,{"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,V.jsxs)(`label`,{className:`grid gap-1 text-xs text-muted-foreground`,children:[`Name`,(0,V.jsx)(rW,{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,V.jsx)(Ck,{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=Rz.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 Bz=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function Vz({files:e}){return e.length===0?null:(0,V.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,V.jsx)(`li`,{children:Bz.has(e.mime)?(0,V.jsx)(`a`,{href:F(`/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,V.jsx)(`img`,{src:F(`/files/preview/attachments/${e.id}`),alt:e.name,loading:`lazy`,className:`max-h-40 max-w-[min(14rem,100%)] object-cover`})}):(0,V.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,V.jsx)(Xm,{"aria-hidden":`true`,className:`size-4 shrink-0`}):(0,V.jsx)(eg,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.name})]})},e.id))})}var Hz=!1,Uz=[],Wz=0,Gz=900;function Kz(){Hz=!0,window.clearTimeout(Wz),Wz=window.setTimeout(qz,Gz)}function qz(){Hz=!1,window.clearTimeout(Wz);let e=Uz;Uz=[];for(let t of e)t()}function Jz(e){if(!Hz)return e(),()=>{};let t=()=>e();return Uz.push(t),()=>{Uz=Uz.filter(e=>e!==t)}}var Yz=8;function Xz(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=Jz(()=>{e=requestAnimationFrame(()=>{let e=performance.now();(0,fy.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*Yz/t)))})});return()=>{t(),cancelAnimationFrame(e)}},[a,n]),Math.min(n,e)}function Zz(e){return e?.type===`text`?e.value??``:(e?.children??[]).map(Zz).join(``)}function Qz(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}),Qz(t,n)}function $z(){return e=>Qz(e)}function eB(e){let[t,n]=(0,m.useState)(!1);async function r(){try{await Lz(e,navigator.clipboard),n(!0),mp.success(`Code copied.`)}catch{mp.error(`Could not copy code. Select it and copy manually, or allow clipboard access.`)}}return{copied:t,copy:r}}function tB({text:e,children:t,block:n=!1}){let{copy:r}=eB(e),i=(0,m.useRef)(void 0);return(0,V.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(),Iz(window.getSelection()?.toString()??``,i.current?.moved??!1)&&r(),i.current=void 0},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),Iz(window.getSelection()?.toString()??``,!1)&&r())},children:[t,n?null:(0,V.jsx)(`span`,{className:`sr-only`,children:` (activate to copy)`})]})}function nB({node:e,children:t,source:n}){let r=e,{copied:i,copy:a}=eB(Fz(n,r?.position,!0)??Zz(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,V.jsxs)(`div`,{className:`relative my-3 rounded-lg bg-muted`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between pl-3`,children:[(0,V.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s&&/^[\w+#.-]{1,20}$/.test(s)?s:`code`,` · tap to copy`]}),(0,V.jsx)(nk,{label:i?`Copied`:`Copy the code`,icon:i?nm:Rm,iconOnly:!0,onClick:()=>void a()})]}),(0,V.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 rB(e){return{pre:t=>(0,V.jsx)(nB,{...t,source:e}),code:({node:t,children:n})=>{let r=t;if(r?.properties?.copyBlocked)return(0,V.jsx)(`code`,{children:n});let i=!!r?.properties?.blockCode;return(0,V.jsx)(tB,{text:Fz(e,r?.position,i)??Zz(r),block:i,children:n})},a:({href:e,children:t})=>(0,V.jsx)(`a`,{href:e?F(e):void 0,target:`_blank`,rel:`noopener noreferrer nofollow`,children:t}),img:({src:e,alt:t})=>(0,V.jsx)(`img`,{src:e?F(e):void 0,alt:t??``,loading:`lazy`}),table:({children:e})=>(0,V.jsx)(`div`,{className:`my-3 w-full overflow-x-auto`,children:(0,V.jsx)(`table`,{className:`w-full border-collapse text-sm`,children:e})})}}var iB=(0,m.memo)(function({text:e}){return(0,V.jsx)(xI,{remarkPlugins:[Dz],rehypePlugins:[$z],urlTransform:kz,components:rB(e),children:e})}),aB=(0,m.memo)(function({text:e,className:t}){let{body:n,files:r}=zz(e),i=n?Pz(n):[],a=Xz(i.length,3);return(0,V.jsxs)(`div`,{className:J(`md-body`,t),children:[i.slice(0,a).map((e,t)=>(0,V.jsx)(iB,{text:e},t)),(0,V.jsx)(Vz,{files:r})]})});function oB({title:e,note:t,className:n,children:r,collapsed:i,onToggle:a,shortcut:o,...s}){let c=typeof e==`string`?e:`pane`;return(0,V.jsxs)(`section`,{className:J(`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,V.jsxs)(`div`,{className:J(`flex min-h-12 shrink-0 items-center justify-between gap-3 px-4`,!i&&`border-b border-border`),children:[e?(0,V.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-medium`,children:e}):(0,V.jsx)(`span`,{}),(0,V.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,V.jsx)(`span`,{className:`flex items-center gap-2 truncate text-xs text-muted-foreground`,children:t}):null,a?(0,V.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,V.jsx)(KD,{chord:o,className:`kbd-hint`}):null,(0,V.jsx)(im,{"aria-hidden":`true`,className:J(`size-4 transition-transform duration-200 ease-snap`,i&&`-rotate-90`)})]}):null]})]}):null,i?null:r]})}function sB({title:e,right:t,className:n}){return(0,V.jsxs)(`span`,{className:J(`flex min-w-0 items-center gap-3`,n),children:[(0,V.jsx)(`span`,{className:`truncate font-medium`,children:e}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`}),t?(0,V.jsx)(`span`,{className:`shrink-0 text-xs font-normal text-muted-foreground`,children:t}):null]})}function cB({title:e,right:t,prominent:n,children:r}){return(0,V.jsxs)(`section`,{className:J(`flex min-w-0 flex-col`,n?`gap-4`:`workspace-section gap-3 rounded-xl border p-4 shadow-xs`),children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:(0,V.jsx)(sB,{title:e,right:t,className:n?`[&>span:first-child]:font-semibold`:void 0})}),r]})}var lB=`Pull requests`,uB=`An agent reviews it, optionally with a focus you type; Jev's quick read sizes it up first.`,dB=`nothing is posted to GitHub`,fB=`Refresh to load open pull requests with the GitHub CLI (gh).`,pB=`No open pull requests.`,mB=`loading pull requests from GitHub…`,hB=`reading the diff…`,gB=`the pull request has new commits since this review — review it again`,_B=`(no description)`,vB=`Review with a focus (optional)`,yB=`Leave it empty for a full review.`;function bB(e){return e===`passing`?`✓`:e===`failing`?`✗`:e===`pending`?`…`:``}function xB(e){return e===`passing`?`text-success`:e===`failing`?`text-destructive`:`text-muted-foreground`}function SB(e,t){return`+${e} −${t}`}function CB(e){return e===`APPROVED`?`approved`:e===`CHANGES_REQUESTED`?`changes requested`:e===`REVIEW_REQUIRED`?`review required`:``}function wB(e){return e?e.status===`running`?`reviewing`:e.status!==`done`||!e.verdict?``:e.verdict===`approve`?`approved`:e.verdict===`changes`?`changes found`:`commented`:``}function TB(e){return e===`approve`?`approve`:e===`changes`?`request changes`:e===`comment`?`comment`:``}function EB(e,t){if(e.status===`running`)return DB(e,t);if(e.status===`cancelled`)return`stopped`;let n=e.status===`done`?DB(e,t):e.status;return[TB(e.verdict),n].filter(Boolean).join(` · `)}function DB(e,t){let n=Math.max(0,Math.round(((e.finishedAt??t)-e.startedAt)/1e3));return n<60?`${n}s`:`${Math.floor(n/60)}m ${String(n%60).padStart(2,`0`)}s`}function OB(e,t){return[e.state?e.draft?`draft`:e.state.toLowerCase():e.draft?`draft`:``,e.author?`by ${e.author}`:``,e.updatedAt?`updated ${Dk(t-Date.parse(e.updatedAt))}`:``].filter(Boolean).join(` · `)}function kB(e){let t=`${e.changedFiles} file${e.changedFiles===1?``:`s`}`;return`${e.headRef||`?`} → ${e.baseRef||`?`} · ${SB(e.additions,e.deletions)} · ${t}`}function AB(e){let t=e.mergeable===`CONFLICTING`?`conflicts`:e.mergeable===`MERGEABLE`?`mergeable`:``;return[e.checks?`checks ${e.checks} (${e.checkCount})`:``,CB(e.decision),t,e.labels.join(`, `)].filter(Boolean).join(` · `)}function jB(e){return[`${e.changedFiles} file${e.changedFiles===1?``:`s`}`,e.labels.join(`, `),e.review?.stale?`stale`:``].filter(Boolean).join(` · `)}function MB(e){return e.read?`${e.read.model} · ${e.read.ms} ms`:``}function NB(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),e?t:Date.now()}function PB({pull:e,now:t}){return(0,V.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,V.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:[(0,V.jsxs)(`span`,{className:`font-normal text-muted-foreground tabular-nums`,children:[`#`,e.number]}),` `,e.title]}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:OB(e,t)}),(0,V.jsx)(`p`,{className:`text-sm tabular-nums`,children:kB(e)}),AB(e)?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:AB(e)}):null,e.url?(0,V.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer nofollow`,className:`inline-flex max-w-full break-all text-xs text-primary underline underline-offset-4`,children:e.url}):null]})}function FB({read:e}){return(0,V.jsxs)(cB,{title:`Jev's read`,right:MB(e),children:[e.status===`running`?(0,V.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(bO,{className:`size-3.5`}),hB]}):null,e.status===`failed`?(0,V.jsx)(`p`,{className:`text-sm text-foreground`,children:e.error??`Jev could not read it`}):null,e.status===`done`&&e.line?(0,V.jsx)(aB,{text:e.line}):null]})}function IB({review:e,now:t}){return(0,V.jsxs)(V.Fragment,{children:[e.model?(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:[e.model,e.thinking].filter(Boolean).join(` · `)}):null,e.focus?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`focus: `,e.focus]}):null,e.saved?(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`kept from `,Dk(t-e.startedAt)]}):null,e.stale?(0,V.jsx)(`p`,{className:`text-sm text-foreground`,children:gB}):null,e.status===`running`?(0,V.jsx)(LB,{steps:e.steps}):null,e.status===`cancelled`?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`stopped`}):null,e.status===`failed`||e.status===`timeout`?(0,V.jsxs)(`p`,{className:`text-sm text-destructive`,children:[`✗ `,e.error??e.status]}):null,e.text?(0,V.jsx)(aB,{text:e.text}):null]})}function LB({steps:e}){return(0,V.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.slice(-6).map((e,t)=>(0,V.jsxs)(`li`,{className:`break-words`,children:[`· `,e]},t))})}function RB({number:e,focus:t,onChange:n}){return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`label`,{htmlFor:`focus-${e}`,className:`text-[0.8125rem] font-medium text-foreground`,children:vB}),(0,V.jsx)(Ck,{id:`focus-${e}`,value:t,rows:2,maxLength:2e3,onChange:e=>n(e.target.value)}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:yB})]})}function zB({number:e,review:t,now:n,focus:r,onFocus:i}){return(0,V.jsxs)(cB,{title:`Review`,right:t?EB(t,n):void 0,children:[t?(0,V.jsx)(IB,{review:t,now:n}):null,(0,V.jsx)(RB,{number:e,focus:r,onChange:i}),(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`A read-only agent reviews it — `,dB,`.`]})]})}function BB({files:e}){return(0,V.jsx)(cB,{title:`Files`,right:String(e.length),children:(0,V.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:(0,V.jsx)(`table`,{className:`w-full border-collapse text-sm tabular-nums`,children:(0,V.jsx)(`tbody`,{children:e.map(e=>(0,V.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,V.jsx)(`td`,{className:`max-w-0 px-3 py-1.5 break-all`,children:e.path}),(0,V.jsx)(`td`,{className:`px-3 py-1.5 text-right text-xs whitespace-nowrap text-muted-foreground`,children:SB(e.additions,e.deletions)})]},e.path))})})})})}function VB({note:e,now:t}){let n=[e.state&&e.state!==`COMMENTED`?e.state.toLowerCase().replace(/_/g,` `):``,e.at?Dk(t-Date.parse(e.at)):``].filter(Boolean).join(` · `);return(0,V.jsxs)(`article`,{className:`card-flat flex flex-col gap-1.5 rounded-lg border px-3.5 py-2.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,V.jsx)(`span`,{className:`font-medium text-foreground`,children:e.author??`comment`}),n?(0,V.jsx)(`span`,{children:n}):null]}),e.body.trim()?(0,V.jsx)(aB,{text:e.body.trim()}):null]})}function HB({notes:e,now:t}){return e.length===0?null:(0,V.jsx)(cB,{title:`Discussion`,right:String(e.length),children:(0,V.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,V.jsx)(VB,{note:e,now:t},n))})})}function UB({number:e,error:t}){return t?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load #`,e,`. `,t]}):(0,V.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(bO,{className:`size-3.5`}),`loading #`,e,`…`]})}function WB({number:e,onChanged:t}){let n=MO(`git.pull`,{number:e},[`git`]),[r,i]=(0,m.useState)(``),a=n.data?.review?.status===`running`,o=NB(a);if(!n.data)return(0,V.jsx)(UB,{number:e,error:n.error});let{pull:s,review:c,read:l}=n.data,u=()=>{n.reload(),t?.()},d=async()=>{let t=r.trim();i(``),await U(`git.review`,{number:e,...t?{focus:t}:{}}),u()},f=async()=>{await U(`git.jev`,{number:e}),u()},p=async()=>{await U(`git.cancelReview`,{number:e}),u()};return(0,V.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`Pull request #${e}`,children:[(0,V.jsxs)(rk,{children:[(0,V.jsx)(nk,{label:`Review`,icon:cg,tone:`primary`,shortcut:`V`,disabled:a,onClick:()=>void d()}),(0,V.jsx)(nk,{label:`Jev's read`,icon:Xp,shortcut:`Q`,disabled:a,onClick:()=>void f()}),a?(0,V.jsx)(Rk,{icon:wm,label:`Stop the review`,text:`Stop`,shortcut:`X`,title:`Stop this review?`,description:`The agent stops reading the pull request. Nothing is posted to GitHub.`,confirmLabel:`Stop review`,variant:`destructive`,onConfirm:()=>void p()}):null]}),(0,V.jsx)(PB,{pull:s,now:o}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:uB}),l?(0,V.jsx)(FB,{read:l}):null,(0,V.jsx)(zB,{number:e,review:c,now:o,focus:r,onFocus:i}),s.files.length>0?(0,V.jsx)(BB,{files:s.files}):null,(0,V.jsx)(cB,{title:`Description`,children:s.body.trim()?(0,V.jsx)(aB,{text:s.body.trim()}):(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:_B})}),(0,V.jsx)(HB,{notes:s.notes,now:o})]})}var GB=Wv([`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 KB({className:e,variant:t,size:n,radius:r,asChild:i=!1,...a}){let o=i?$v:`span`;return(0,V.jsx)(o,{"data-slot":`badge`,className:J(GB({variant:t,size:n,radius:r,className:e})),...a})}var qB=`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`,JB=`flex flex-col gap-1 px-2 pb-3`,YB=`px-4 pt-4 pb-1 text-xs font-medium text-muted-foreground`;function XB({checks:e}){let t=bB(e);return t?(0,V.jsx)(`span`,{className:J(`w-4 shrink-0 text-center`,xB(e)),"aria-hidden":`true`,children:t}):(0,V.jsx)(`span`,{className:`w-4 shrink-0`,"aria-hidden":`true`})}function ZB({pull:e,selected:t,onSelect:n}){let r=wB(e.review);return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(e.number),className:qB,children:[(0,V.jsxs)(`span`,{className:`flex items-start gap-2 text-sm`,children:[(0,V.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[`#`,e.number]}),(0,V.jsx)(XB,{checks:e.checks}),e.draft?(0,V.jsx)(KB,{variant:`secondary`,children:`draft`}):null,(0,V.jsx)(`span`,{className:J(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title})]}),(0,V.jsxs)(`span`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-xs text-muted-foreground`,children:[(0,V.jsx)(`span`,{children:jB(e)}),(0,V.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[r?(0,V.jsx)(`span`,{children:r}):null,(0,V.jsx)(`span`,{className:`tabular-nums`,children:SB(e.additions,e.deletions)})]})]})]})})}function QB({pulls:e,selectedId:t,onSelect:n}){return(0,V.jsx)(`ul`,{className:JB,children:e.map(e=>(0,V.jsx)(ZB,{pull:e,selected:e.number===t,onSelect:n},e.number))})}function $B(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function eV({label:e,hint:t,buttonLabel:n=`Send`,onSend:r}){let i=(0,m.useId)(),[a,o]=(0,m.useState)(``),[s,c]=(0,m.useState)(!1),l=async()=>{a.trim()&&!s&&(c(!0),await r(a)&&o(``),c(!1))};return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium text-foreground`,children:e}),(0,V.jsx)(Ck,{id:i,value:a,rows:2,"aria-describedby":t?`${i}-hint`:void 0,onChange:e=>o(e.target.value),onKeyDown:e=>{$B(e)&&(e.preventDefault(),l())}}),t?(0,V.jsx)(`p`,{id:`${i}-hint`,className:`text-xs text-muted-foreground`,children:t}):null,(0,V.jsx)(`div`,{className:`flex self-end`,children:(0,V.jsx)(nk,{label:n,icon:s?wh:Hp,tone:`primary`,shortcut:`Enter`,className:s?`[&_svg]:animate-spin`:void 0,onClick:()=>void l(),disabled:!a.trim()||s})})]})}var tV=`Issues`,nV=`Issue`,rV=`Plan it opens a planning session on this issue; save the plan as a task once the panel agrees it.`,iV=`Refresh to load open issues with the GitHub CLI (gh).`,aV=`No open issues. File one with New issue.`,oV=`loading issues from GitHub…`,sV=`issues are off (lobby.issues)`,cV=`(no description)`;function lV(e,t){return[e.state?e.state.toLowerCase():``,e.author?`by ${e.author}`:``,e.updatedAt?`updated ${Dk(t-Date.parse(e.updatedAt))}`:``,e.labels.join(`, `)].filter(Boolean).join(` · `)}function uV(e,t){return[e.author?`by ${e.author}`:``,e.updatedAt?Dk(t-Date.parse(e.updatedAt)):``].filter(Boolean).join(` · `)}function dV(e){return e.length>0?`[${e.slice(0,2).join(`, `)}]`:``}function fV({issue:e,now:t}){return(0,V.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,V.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:[(0,V.jsxs)(`span`,{className:`font-normal text-muted-foreground tabular-nums`,children:[`#`,e.number]}),` `,e.title]}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:lV(e,t)}),e.url?(0,V.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer nofollow`,className:`inline-flex max-w-full break-all text-xs text-primary underline underline-offset-4`,children:e.url}):null]})}function pV({comment:e,now:t}){return(0,V.jsxs)(`article`,{className:`card-flat flex flex-col gap-1.5 rounded-lg border px-3.5 py-2.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,V.jsx)(`span`,{className:`font-medium text-foreground`,children:e.author??`comment`}),e.createdAt?(0,V.jsx)(`span`,{children:Dk(t-Date.parse(e.createdAt))}):null]}),(0,V.jsx)(aB,{text:e.body.trim()})]})}function mV({comments:e,now:t}){return e.length===0?null:(0,V.jsx)(cB,{title:`Comments`,right:String(e.length),children:(0,V.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,V.jsx)(pV,{comment:e,now:t},n))})})}function hV({issue:e}){let t=async()=>{await U(`planner.new`,{seed:{issue:{number:e.number,title:e.title,...e.url?{url:e.url}:{}},body:e.body}})&&fO(dO(`plan`))};return(0,V.jsx)(Rk,{icon:i_,label:`Plan #${e.number} with the panel`,text:`Plan it`,shortcut:`N`,title:`Plan #${e.number} with the panel?`,description:`A new planning session starts from this issue. A plan already under way waits under Plan → Previous.`,confirmLabel:`Plan it`,onConfirm:()=>void t()})}function gV({number:e}){let t=MO(`issues.get`,{number:e},[`issues`]),n=Date.now();if(!t.data)return t.error?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load #`,e,`. `,t.error]}):(0,V.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(bO,{className:`size-3.5`}),`loading #`,e,`…`]});let r=t.data.issue;return(0,V.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${nV} #${e}`,children:[(0,V.jsx)(rk,{children:(0,V.jsx)(hV,{issue:r})}),(0,V.jsx)(fV,{issue:r,now:n}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:rV}),(0,V.jsx)(cB,{title:`Description`,children:r.body.trim()?(0,V.jsx)(aB,{text:r.body.trim()}):(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:cV})}),(0,V.jsx)(mV,{comments:r.comments,now:n})]})}function _V({issue:e,selected:t,now:n,onSelect:r}){let i=dV(e.labels);return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>r(e.number),className:qB,children:[(0,V.jsxs)(`span`,{className:`flex flex-wrap items-start gap-2 text-sm`,children:[(0,V.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[`#`,e.number]}),(0,V.jsx)(`span`,{className:J(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title}),i?(0,V.jsx)(`span`,{className:`max-w-full break-words text-xs text-muted-foreground`,children:i}):null]}),(0,V.jsx)(`span`,{className:`pl-9 text-xs text-muted-foreground`,children:uV(e,n)})]})})}function vV({issues:e,selectedId:t,now:n,onSelect:r}){return(0,V.jsx)(`ul`,{className:JB,children:e.map(e=>(0,V.jsx)(_V,{issue:e,selected:e.number===t,now:n,onSelect:r},e.number))})}var yV=()=>fO(dO(`git`,`issues`)),bV=e=>fO(dO(`git`,`issues`,String(e)));function xV(e){let t=Number(e[0]);return Number.isInteger(t)&&t>0?t:void 0}function SV(){return(0,V.jsx)(mO,{className:`m-4 flex-1`,children:(0,V.jsxs)(hO,{children:[(0,V.jsx)(_O,{variant:`icon`,children:(0,V.jsx)(vm,{"aria-hidden":`true`})}),(0,V.jsx)(vO,{children:`Issues are off`}),(0,V.jsx)(yO,{className:`font-mono`,children:sV})]})})}function CV({loading:e,loaded:t,error:n,onRetry:r}){let i=n?`✗ ${n}`:t?aV:e?oV:iV;return(0,V.jsxs)(mO,{className:`m-4 flex-1`,children:[(0,V.jsxs)(hO,{children:[(0,V.jsx)(_O,{variant:`icon`,children:(0,V.jsx)(vm,{"aria-hidden":`true`})}),(0,V.jsx)(yO,{className:n?`text-destructive`:void 0,children:i})]}),n?(0,V.jsx)(Y,{variant:`outline`,onClick:r,children:`Retry`}):null]})}function wV({onCreate:e}){return(0,V.jsx)(_k,{className:`shrink-0 border-t border-border p-4`,children:(0,V.jsx)(eV,{label:`New issue`,hint:`The first line becomes the title; the rest is the body. Enter files it.`,buttonLabel:`File issue`,onSend:e})})}function TV(){let e=AO(`status`).data?.issuesEnabled??!0;return{enabled:e,read:MO(`issues.list`,{},[`issues`],e)}}function EV({enabled:e,read:t}){return!e||t.error?.includes(`issues are off`)?(0,V.jsx)(SV,{}):!t.data&&t.error?(0,V.jsx)(EO,{message:`Could not load issues. ${t.error}`,onRetry:t.reload}):null}function DV({issues:e,rest:t,top:n}){let r=gk(),{read:i}=e,a=xV(t),o=i.data?.issues??[],s=async e=>await U(`issues.create`,{text:e})?(i.reload(),!0):!1,c=EV(e);if(c)return(0,V.jsxs)(V.Fragment,{children:[n,c]});if(i.data&&o.length===0)return(0,V.jsxs)(V.Fragment,{children:[n,(0,V.jsx)(CV,{loading:i.data.loading,loaded:i.data.loaded,error:i.data.error,onRetry:i.reload}),(0,V.jsx)(`div`,{className:`shrink-0 pb-dock`,children:(0,V.jsx)(wV,{onCreate:s})})]});let l=(0,V.jsxs)(V.Fragment,{children:[n,i.data?.error?(0,V.jsxs)(`p`,{className:`px-3 pt-2 text-sm text-destructive`,children:[`✗ `,i.data.error]}):null,i.data?(0,V.jsx)(vV,{issues:o,selectedId:a,now:Date.now(),onSelect:bV}):(0,V.jsx)(Sk,{}),(0,V.jsx)(wV,{onCreate:s})]});return(0,V.jsx)(bk,{wide:r,list:l,detail:a===void 0?null:(0,V.jsx)(gV,{number:a},a),open:a!==void 0,onClose:yV,hint:`Select an issue to read it.`,describe:`Issue detail`})}var OV=()=>fO(dO(`git`)),kV=e=>fO(dO(`git`,String(e)));function AV(e){let t=Number(e[0]);return Number.isInteger(t)&&t>0?t:void 0}function jV({loading:e,loaded:t,error:n,onRetry:r}){let i=n?`✗ ${n}`:t?pB:e?mB:fB;return(0,V.jsxs)(mO,{className:`m-4 flex-1`,children:[(0,V.jsxs)(hO,{children:[(0,V.jsx)(_O,{variant:`icon`,children:(0,V.jsx)(ih,{"aria-hidden":`true`})}),(0,V.jsx)(yO,{className:n?`text-destructive`:void 0,children:i})]}),n?(0,V.jsx)(Y,{variant:`outline`,onClick:r,children:`Retry`}):null]})}var MV=[{id:`pulls`,label:lB,hash:dO(`git`)},{id:`issues`,label:tV,hash:dO(`git`,`issues`)}];function NV({view:e}){return(0,V.jsx)(ak,{label:`Show`,items:MV,value:e,idPrefix:`git-view`,onChange:e=>fO(MV.find(t=>t.id===e).hash)})}function PV(e,t){return(0,m.useCallback)(()=>{U(`git.pulls`,{refresh:!0}).then(()=>e.reload()),t.enabled&&U(`issues.list`,{refresh:!0}).then(()=>t.read.reload())},[e,t])}function FV({view:e,count:t,busy:n,refresh:r}){return(0,V.jsx)(xk,{title:e===`issues`?tV:lB,count:t,lead:(0,V.jsx)(NV,{view:e}),children:(0,V.jsx)(nk,{label:`Refresh`,icon:fg,iconOnly:!0,shortcut:`R`,disabled:n,className:J(`size-7`,n&&`[&_svg]:animate-spin`),onClick:r})})}function IV({read:e,rest:t,top:n}){let r=gk(),i=AV(t),a=e.data?.pulls??[];if(!e.data&&e.error)return(0,V.jsxs)(V.Fragment,{children:[n,(0,V.jsx)(EO,{message:`Could not load pull requests. ${e.error}`,onRetry:e.reload})]});if(e.data&&a.length===0)return(0,V.jsxs)(V.Fragment,{children:[n,(0,V.jsx)(jV,{loading:e.data.loading,loaded:e.data.loaded,error:e.data.error,onRetry:e.reload})]});let o=(0,V.jsxs)(V.Fragment,{children:[n,e.data?.error?(0,V.jsxs)(`p`,{className:`px-3 pt-2 text-sm text-destructive`,children:[`✗ `,e.data.error]}):null,e.data?(0,V.jsx)(QB,{pulls:a,selectedId:i,onSelect:kV}):(0,V.jsx)(Sk,{})]}),s=i===void 0?null:(0,V.jsx)(WB,{number:i,onChanged:e.reload},i);return(0,V.jsx)(bk,{wide:r,list:o,detail:s,open:i!==void 0,onClose:OV,hint:`Select a pull request to see its detail.`,describe:`Pull request detail`})}var LV=()=>MO(`git.pulls`,{},[`git`]);function RV(e,t,n){let r=e===`issues`?n.read:t,i=e===`issues`?n.read.data?.issues:t.data?.pulls,a=t.loading||!!t.data?.loading||n.enabled&&(n.read.loading||!!n.read.data?.loading),o=i&&(e===`pulls`||n.enabled)?`${i.length} open`:void 0;return{busy:a||r.loading,count:o}}function zV({rest:e}){let t=LV(),n=TV(),r=PV(t,n),i=e[0]===`issues`?`issues`:`pulls`,{busy:a,count:o}=RV(i,t,n),s=(0,V.jsx)(FV,{view:i,count:o,busy:a,refresh:r}),c=i===`issues`?(0,V.jsx)(DV,{issues:n,rest:e.slice(1),top:s}):(0,V.jsx)(IV,{read:t,rest:e,top:s});return(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:c})}function BV(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 VV={DEV:Mm,DESIGN:Kh,QA:Og,RESEARCH:Hg,"QUICK FIX":c_,SCOUT:Im,PLANNER:bg,CLASSIFIER:Bg,LOBBY:Ih,LINT:gh};function HV(e){return e?VV[e.toUpperCase()]??Qp:em}function UV({className:e,strokeWidth:t=2,source:n}){return(0,V.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:J(`agent-oracle shrink-0`,e),children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`10`,r:`7`}),(0,V.jsx)(`path`,{d:`M8.5 7.5a4 4 0 0 1 3-2`}),(0,V.jsx)(`path`,{d:`M8 16.2 6.5 20h11L16 16.2`}),(0,V.jsx)(`path`,{d:`M5 20h14`})]})}function WV(e){let t=e?.toUpperCase();return t===`ORACLE`||t===`MASTER`}function GV({source:e,className:t,strokeWidth:n}){if(WV(e))return(0,V.jsx)(UV,{source:e,className:t,strokeWidth:n});let r=HV(e);return(0,V.jsx)(r,{"aria-hidden":`true`,"data-agent-icon":e??`thinking`,strokeWidth:n,className:J(`shrink-0`,t)})}var KV={MASTER:`text-primary`,DEV:`text-source-dev`,DESIGN:`text-source-design`,QA:`text-source-qa`,RESEARCH:`text-source-research`,"QUICK FIX":`text-source-quickfix`,ORACLE:`text-primary`,LOBBY:`text-muted-foreground`};function qV(e){return e.length<=2?e:e.charAt(0)+e.slice(1).toLowerCase()}function JV(e){return KV[e]??`text-muted-foreground`}var YV={MASTER:`var(--primary)`,DEV:`var(--source-dev)`,DESIGN:`var(--source-design)`,QA:`var(--source-qa)`,RESEARCH:`var(--source-research)`,"QUICK FIX":`var(--source-quickfix)`,ORACLE:`var(--primary)`,LOBBY:`var(--muted-foreground)`};function XV(e){return YV[e]??`var(--muted-foreground)`}function ZV(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 QV(e){return e?.runs??[]}function $V(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 eH({source:e,name:t,time:n,head:r,live:i,children:a,aside:o}){let s=r&&!WV(e);return(0,V.jsxs)(`div`,{className:`chat-agent group/msg`,"data-live":i||void 0,style:i?{"--orb":XV(e)}:void 0,children:[s||o?(0,V.jsxs)(`p`,{className:`chat-speaker`,children:[s?(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-medium text-foreground`,style:{"--orb":XV(e)},children:[(0,V.jsx)(GV,{source:e,strokeWidth:2.25,className:`size-3.5 text-[color-mix(in_oklab,var(--orb)_85%,var(--foreground))]`}),t]}):null,s&&n?(0,V.jsx)(`time`,{className:`text-xs text-muted-foreground tabular-nums`,children:n}):null,o?(0,V.jsx)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:o}):null]}):null,(0,V.jsx)(`div`,{className:`chat-prose`,children:a}),n&&!s?(0,V.jsx)(`time`,{className:`chat-meta`,children:n}):null]})}function tH({time:e,head:t,note:n,children:r,below:i,actions:a}){return(0,V.jsxs)(`div`,{className:`group/msg flex flex-col items-end gap-1`,children:[(0,V.jsx)(`div`,{className:`chat-bubble`,children:r}),e||n||a?(0,V.jsxs)(`div`,{className:`chat-meta flex items-center gap-2`,children:[a,n?(0,V.jsx)(`span`,{children:n}):null,e?(0,V.jsx)(`time`,{className:`tabular-nums`,children:e}):null]}):null,i]})}function nH({failed:e,children:t}){return(0,V.jsx)(`div`,{role:`note`,className:J(`chat-note`,e&&`text-destructive`),children:(0,V.jsx)(`span`,{children:t})})}function rH({className:e}){return(0,V.jsxs)(`span`,{"aria-hidden":`true`,className:J(`typing-dots`,e),children:[(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{})]})}function iH({onClick:e,className:t}){return(0,V.jsx)(`button`,{type:`button`,"aria-label":`Jump to latest`,title:`Jump to latest`,onClick:e,className:J(`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,V.jsx)(Ip,{"aria-hidden":`true`,className:`size-4`})})}var aH=`(max-width: 1023.98px)`;function oH(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 sH=`bot-lobby.collapsed.`,cH=new Set,lH=new Map;function uH(e){if(lH.has(e))return lH.get(e);if(e===`lobby.thinking`)return oH(e);try{return oH(e,localStorage.getItem(sH+e))}catch{return!1}}function dH(e,t){lH.set(e,t);try{e!==`lobby.thinking`&&localStorage.setItem(sH+e,t?`1`:`0`)}catch{}for(let e of[...cH])e()}function fH(e){return cH.add(e),()=>{cH.delete(e)}}function pH(e){dH(e,!uH(e))}function mH(e){return[(0,m.useSyncExternalStore)(fH,()=>uH(e),()=>oH(e)),(0,m.useCallback)(()=>dH(e,!uH(e)),[e])]}function hH({className:e}){return(0,V.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`working-mark`,className:J(`working-mark`,e)})}var gH=`lobby.activity.open`;function _H({entry:e}){return e.pending?(0,V.jsx)(hH,{className:`size-3`}):e.kind===`error`?(0,V.jsx)(o_,{"aria-hidden":`true`,className:`size-3.5 text-destructive`}):e.kind===`warning`?(0,V.jsx)(Kg,{"aria-hidden":`true`,className:`size-3.5 text-warning`}):e.kind===`success`?(0,V.jsx)(nm,{"aria-hidden":`true`,className:`size-3.5 text-success`}):(0,V.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`})}function vH({entry:e}){return(0,V.jsxs)(`li`,{className:`activity-step`,title:Tk(e.at),style:e.pending?{"--orb":XV(e.source)}:void 0,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`flex h-5 w-6 items-center justify-center`,children:(0,V.jsx)(_H,{entry:e})}),(0,V.jsx)(`span`,{className:`sr-only`,children:e.pending?`pending`:e.kind}),(0,V.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,V.jsx)(`span`,{className:J(`font-medium`,JV(e.source)),children:qV(e.source)}),` `,(0,V.jsx)(`span`,{className:e.kind===`error`?`text-destructive`:e.pending?`text-foreground`:void 0,children:e.pending?`${e.text}…`:e.text})]})]})}function yH(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 bH(e){let t=[...e].reverse().find(e=>e.pending),n=[...new Set(e.map(e=>qV(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 xH(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 SH({entries:e}){let[t]=mH(gH),[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}=bH(e),f=xH(!!o),p=o?{"--orb":XV(o.source)}:void 0;return(0,V.jsxs)(`div`,{className:`activity-run`,"data-live":o?!0:void 0,"data-open":i||void 0,style:p,children:[(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":a,onClick:()=>r(!i),className:`activity-toggle`,children:[o?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(hH,{}),(0,V.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,V.jsx)(CH,{text:`Working`}),(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:` · `}),(0,V.jsxs)(`span`,{className:`activity-live-step`,children:[(0,V.jsx)(`span`,{className:J(`font-medium`,JV(o.source)),children:qV(o.source)}),` `,(0,V.jsxs)(`span`,{className:`text-foreground`,children:[o.text,`…`]})]},o.id)]}),(0,V.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[c,e[0]&&f-e[0].at>=1e3?` · ${yH(f-e[0].at)}`:``]})]}):(0,V.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,V.jsx)(`span`,{className:`font-medium`,children:s>=1e3?`Worked for ${yH(s)}`:`Worked`}),(0,V.jsxs)(`span`,{children:[` · `,c,l?` · ${l}`:``]})]}),u?(0,V.jsxs)(`span`,{className:`shrink-0 text-destructive`,children:[u,` `,u===1?`error`:`errors`]}):null,d?(0,V.jsxs)(`span`,{className:`shrink-0 text-warning`,children:[d,` `,d===1?`warning`:`warnings`]}):null,(0,V.jsx)(im,{"aria-hidden":`true`,className:`activity-chevron size-3.5 shrink-0`})]}),i?(0,V.jsx)(`ol`,{id:a,"aria-label":`Activity`,className:`activity-steps`,children:e.map(e=>(0,V.jsx)(vH,{entry:e},e.id))}):null]})}function CH({text:e}){return(0,V.jsxs)(`span`,{className:`activity-shimmer`,children:[(0,V.jsx)(`span`,{className:`sr-only`,children:e}),[...e].map((e,t)=>(0,V.jsx)(`span`,{"aria-hidden":`true`,style:{"--i":t},children:e},t))]})}function wH(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 TH=3e5,EH=`No task is running in this session.`,DH=`Type a request below and press enter to start one: the oracle scouts, proposes, plans and delegates.`,OH=`Nothing said yet. Type below to talk to the oracle about this task.`;function kH({entry:e}){return(0,V.jsxs)(nH,{failed:e.text.startsWith(`✗`),children:[e.text,e.at?` · ${Tk(e.at)}`:``]})}function AH({entry:e,head:t}){if(e.role===`you`)return(0,V.jsx)(tH,{time:Tk(e.at),head:t,children:(0,V.jsx)(aB,{text:e.text})});let n=e.role===`panel`;return(0,V.jsx)(eH,{source:n?`PLANNER`:`ORACLE`,name:n?`Panel`:`Oracle`,time:Tk(e.at),head:t,children:(0,V.jsx)(aB,{text:e.text})})}var jH=(0,m.memo)(function({entry:e,head:t,fresh:n}){return(0,V.jsx)($f.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,V.jsx)(kH,{entry:e}):(0,V.jsx)(AH,{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);function MH({text:e,busy:t,working:n}){let r=!!e?.trim();return!r&&(!t||n)?null:(0,V.jsx)(eH,{source:`ORACLE`,name:`Oracle`,head:!0,live:t,aside:t&&r?`writing…`:void 0,children:r?(0,V.jsx)(aB,{text:e??``}):(0,V.jsx)(rH,{className:`mt-1`})})}function NH({hasTask:e}){return(0,V.jsxs)(mO,{className:`h-full border-0`,children:[(0,V.jsxs)(hO,{children:[(0,V.jsx)(_O,{variant:`icon`,children:(0,V.jsx)(Ph,{"aria-hidden":`true`})}),e?null:(0,V.jsx)(vO,{children:EH}),(0,V.jsx)(yO,{children:e?OH:DH})]}),e?null:(0,V.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm text-muted-foreground`,children:[(0,V.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[`Or plan it first with the whole panel in `,(0,V.jsx)(KD,{chord:`3`}),` Plan`]}),(0,V.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[`or make a direct change in `,(0,V.jsx)(KD,{chord:`4`}),` Quick fix`]})]})]})}async function PH(e){let t=await L(`lobby.history`,{before:e});return{entries:t.entries,hasOlder:t.hasOlder}}function FH(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 PH(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 IH=[];function LH({chat:e,activity:t=IH,reply:n,busy:r,hasOlder:i,hasTask:a}){let o=(0,m.useMemo)(()=>t.slice(-400),[t]),{ref:s,atBottom:c,stick:l,onScroll:u}=BV(`${e.length}:${n?.length??0}:${o.length}:${o.at(-1)?.pending??``}`),{merged:d,more:f,loading:p,load:h}=FH(e,i,s),g=(0,m.useCallback)(()=>{u();let e=s.current;e&&e.scrollTop<80&&f&&!p&&h()},[u,s,f,p,h]),_=(0,m.useMemo)(()=>wH(d,o),[d,o]),v=d.length===0&&o.length===0&&!n?.trim()&&!r,y=_.at(-1),b=y?.kind===`activity`&&!!bH(y.entries).live,[x,S]=(0,m.useState)(!1);return(0,m.useEffect)(()=>S(!0),[]),(0,V.jsxs)(oB,{"aria-label":`Conversation`,"data-bare":!0,className:`flex-1 rounded-none border-0 shadow-none`,children:[(0,V.jsx)(`div`,{ref:s,onScroll:g,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:v?(0,V.jsx)(NH,{hasTask:a}):(0,V.jsxs)(`div`,{className:`chat-column`,children:[f?(0,V.jsx)(`p`,{className:`mb-4 text-center text-xs text-muted-foreground`,children:`Earlier messages load as you scroll up.`}):null,_.map((e,t)=>{if(e.kind===`activity`)return(0,V.jsx)(SH,{entries:e.entries},e.key);let n=_[t-1],r=n?.kind===`message`?n.entry:void 0,i=!r||r.role!==e.entry.role||e.entry.at-r.at>TH;return(0,V.jsx)(jH,{entry:e.entry,head:i,fresh:x},e.entry.id)}),(0,V.jsx)(MH,{text:n,busy:r,working:b})]})}),(0,V.jsx)(Vv,{target:s,down:!1}),c?null:(0,V.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-dock z-10 flex justify-center [&>*]:pointer-events-auto`,children:(0,V.jsx)(iH,{onClick:l})})]})}function RH(e){let t=e[0]===`ask`,[n,r]=t?e.slice(1):e;return{chat:t,agent:n,file:r}}function zH(e,t){let{agent:n,file:r}=RH(e);return dO(`knowledge`,...t?[`ask`]:[],n??``,r??``)}var BH=[`master`,`designer`,`backend`,`qa`],VH={master:`Master (oracle)`,designer:`Designer`,backend:`Backend`,qa:`QA`},HH={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`},UH=`Every write archives the version before it.`;function WH(e){if(e<1e3)return String(e);let t=e/1e3;return`${t>=10?Math.round(t):t.toFixed(1)}k`}function GH(e){return`over the compaction threshold — ask the oracle to compact ${e}`}function KH(e){return{text:e.text,occurrence:e.occurrence}}function qH(e){return BH.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 JH(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function YH({initial:e,busy:t,onSave:n,onCancel:r}){let[i,a]=(0,m.useState)(e),o=()=>{!t&&i.trim()&&n(i)};return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-input p-3`,children:[(0,V.jsx)(`label`,{htmlFor:`knowledge-entry`,className:`text-sm font-medium text-foreground`,children:`Edit entry`}),(0,V.jsx)(Ck,{id:`knowledge-entry`,value:i,rows:4,autoFocus:!0,onChange:e=>a(e.target.value),onKeyDown:e=>{JH(e)&&(e.preventDefault(),o())}}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:UH}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(Y,{variant:`outline`,onClick:r,disabled:t,children:`Cancel`}),(0,V.jsxs)(Y,{onClick:o,disabled:t||!i.trim(),children:[t?(0,V.jsx)(bO,{}):null,`Save`]})]})]})]})}function XH({open:e,file:t,initial:n,busy:r,onClose:i,onSave:a}){let[o,s]=(0,m.useState)(n),c=nO(e,tO.confirm);return(0,V.jsx)(JD,{open:e&&c,onOpenChange:e=>!e&&i(),label:`Edit ${t}`,description:UH,dismissOnBackdrop:!1,className:`max-w-3xl`,children:(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`h2`,{className:`text-base font-medium`,children:[`Edit `,t]}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:UH})]}),(0,V.jsx)(Ck,{value:o,rows:14,className:`min-h-0 flex-1 font-mono text-sm`,onChange:e=>s(e.target.value)}),(0,V.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,V.jsx)(Y,{variant:`outline`,onClick:i,disabled:r,children:`Cancel`}),(0,V.jsxs)(Y,{onClick:()=>a(o),disabled:r,children:[r?(0,V.jsx)(bO,{}):null,`Save file`]})]})]})})}function ZH({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,V.jsxs)(`li`,{className:`flex items-start gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(ig,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-primary`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:i}),(0,V.jsx)(nk,{label:`Take the note back`,icon:Jg,iconOnly:!0,className:`-my-1 size-7`,disabled:r,onClick:()=>n(e.id)})]})}function QH({entry:e,index:t,selected:n,notes:r,onPick:i,onTakeBack:a,busy:o}){let s=()=>i(t);return(0,V.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,V.jsx)(`div`,{className:`flex gap-2`,children:(0,V.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,V.jsx)(aB,{text:e.text})})}),r.length>0?(0,V.jsx)(`ul`,{className:`flex flex-col gap-1 pl-1`,children:r.map(e=>(0,V.jsx)(ZH,{note:e,onTakeBack:a,busy:o},e.id))}):null]})}function $H({notes:e,onTakeBack:t,busy:n}){return e.length===0?null:(0,V.jsx)(cB,{title:`Notes on entries that changed`,right:String(e.length),children:(0,V.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,V.jsx)(ZH,{note:e,about:e.entry,onTakeBack:t,busy:n},e.id))})})}function eU({view:e}){let t=e.entries.length;return(0,V.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsxs)(`h2`,{className:`min-w-0 break-words text-lg font-semibold tracking-tight`,children:[HH[e.agent],` `,(0,V.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,e.file]})]}),(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` `,t===1?`entry`:`entries`,` · `,WH(e.chars),` chars`]}),e.over?(0,V.jsx)(`p`,{className:`text-sm text-foreground`,children:GH(e.file)}):null]})}function tU({draft:e,picked:t,setDraft:n,onEditFile:r,onDelete:i}){let a=!!e;return(0,V.jsxs)(rk,{children:[(0,V.jsx)(nk,{label:`Edit the entry`,text:`Edit`,icon:og,shortcut:`E`,disabled:a||!t,onClick:()=>n({kind:`edit`,entry:t})}),(0,V.jsx)(nk,{label:t?`Add an entry after it`:`Add an entry`,text:`Add`,icon:ug,shortcut:`A`,disabled:a,onClick:()=>n({kind:`add`,entry:t})}),(0,V.jsx)(nk,{label:`Comment on the entry`,text:`Comment`,icon:Mh,shortcut:`C`,disabled:a||!t,onClick:()=>n({kind:`comment`,entry:t})}),(0,V.jsx)(nk,{label:`Edit the whole file`,text:`Edit file`,icon:Km,shortcut:`F`,disabled:a,onClick:r}),(0,V.jsx)(Rk,{icon:Wg,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 nU({agent:e,file:t,onChanged:n}){let r=MO(`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(()=>U(`knowledge.unnote`,{id:e})),v=()=>{h&&g(()=>U(`knowledge.remove`,{agent:e,file:t,ref:KH(h)}))},y=n=>{let r=o?.entry;if(o?.kind===`edit`&&r)return void g(()=>U(`knowledge.edit`,{agent:e,file:t,ref:KH(r),text:n}));if(o?.kind===`comment`&&r)return void g(()=>U(`knowledge.comment`,{agent:e,file:t,ref:KH(r),text:n}));g(()=>U(`knowledge.add`,{agent:e,file:t,...h?{ref:KH(h)}:{},text:n}))};return f?(0,V.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${HH[e]} ${t}`,children:[(0,V.jsx)(tU,{draft:o,picked:h,setDraft:s,onEditFile:()=>l(!0),onDelete:v}),(0,V.jsx)(eU,{view:f}),p.length===0?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing here yet. Add the first entry below.`}):null,(0,V.jsx)(`ul`,{className:`workspace-section flex flex-col gap-2 rounded-xl border p-3 shadow-xs`,children:p.map((e,t)=>(0,V.jsx)(QH,{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,V.jsx)(YH,{initial:o.entry.text,busy:u,onSave:y,onCancel:()=>s(void 0)}):null,o?.kind===`comment`?(0,V.jsx)(eV,{label:`Comment on this entry`,hint:UH,buttonLabel:`Add note`,onSend:async e=>(y(e),!0)}):null,o?.kind===`add`?(0,V.jsx)(eV,{label:`Add an entry`,hint:UH,buttonLabel:`Add entry`,onSend:async e=>(y(e),!0)}):null,u&&!o?(0,V.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(bO,{}),` saving…`]}):null,(0,V.jsx)($H,{notes:f.detached,onTakeBack:_,busy:u}),(0,V.jsx)(XH,{open:c,file:t,initial:f.content,busy:u,onClose:()=>l(!1),onSave:n=>{l(!1),g(()=>U(`knowledge.replaceFile`,{agent:e,file:t,text:n}))}})]}):r.error?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not read the file. `,r.error]}):(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`reading…`})}function rU(e){return`${e.agent}/${e.file}`}var iU=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function aU({info:e}){return(0,V.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs text-muted-foreground tabular-nums`,children:[(0,V.jsx)(`span`,{children:WH(e.chars)}),e.over?(0,V.jsx)(`span`,{className:`text-foreground`,children:`· over`}):null,e.notes>0?(0,V.jsx)(`span`,{className:`text-primary`,children:iU(e.notes,`note`)}):null]})}function oU({name:e}){let t=e.split(`.`).pop()?.toLowerCase();return t===`md`||t===`mdx`||t===`txt`?(0,V.jsx)(Xm,{"aria-hidden":`true`,className:`ktree-icon`,"data-ext":`md`}):t===`json`||t===`yaml`||t===`yml`||t===`toml`?(0,V.jsx)(Wm,{"aria-hidden":`true`,className:`ktree-icon`,"data-ext":`data`}):(0,V.jsx)(Qm,{"aria-hidden":`true`,className:`ktree-icon`})}function sU({info:e,selected:t,onSelect:n}){return(0,V.jsx)(`li`,{className:`ktree-leaf`,children:(0,V.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(rU(e)),title:e.label,className:`ktree-row ktree-file`,children:[(0,V.jsx)(oU,{name:e.file}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,V.jsxs)(`span`,{className:`sr-only`,children:[e.label,`, `]}),(0,V.jsx)(`span`,{"aria-hidden":`true`,children:e.file})]}),(0,V.jsx)(aU,{info:e})]})})}var cU=`bot-lobby.knowledge.folded`;function lU(){try{let e=JSON.parse(window.localStorage.getItem(cU)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function uU({files:e,models:t={},selectedKey:n,onSelect:r}){let[i,a]=(0,m.useState)(lU),o=qH(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(cU,JSON.stringify(r))}catch{}return r})}return(0,V.jsxs)(`div`,{className:`ktree px-2 pt-2 pb-3`,children:[(0,V.jsxs)(`p`,{className:`ktree-row ktree-root`,children:[(0,V.jsx)(mh,{"aria-hidden":`true`,className:`ktree-icon`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:`Project knowledge`}),(0,V.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[iU(e.length,`file`),` · `,iU(o.length,`agent`),s>0?` · ${iU(s,`note`)}`:``]})]}),(0,V.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,V.jsxs)(`li`,{className:`ktree-branch`,children:[(0,V.jsx)(`h3`,{className:`font-normal`,children:(0,V.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,V.jsx)(cm,{"aria-hidden":`true`,className:J(`ktree-chevron`,a&&`rotate-90`)}),a?(0,V.jsx)(eh,{"aria-hidden":`true`,className:`ktree-icon ktree-folder`}):(0,V.jsx)(nh,{"aria-hidden":`true`,className:`ktree-icon ktree-folder`}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,V.jsx)(`span`,{className:`text-foreground`,children:VH[e.agent]}),s?(0,V.jsxs)(`span`,{className:`ms-2 text-xs text-muted-foreground`,children:[(0,V.jsx)(`span`,{className:`sr-only`,children:`runs on `}),s]}):null]}),(0,V.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[e.notes>0?(0,V.jsxs)(`span`,{className:`text-primary`,children:[iU(e.notes,`note`),` · `]}):null,iU(e.files.length,`file`)]})]})}),(0,V.jsx)(Fu,{initial:!1,children:a?(0,V.jsx)($f.ul,{id:o,"aria-label":`${VH[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,V.jsx)(sU,{info:e,selected:rU(e)===n,onSelect:r},rU(e)))},`files`):null})]},e.agent)})})]})}var dU=()=>fO(dO(`knowledge`)),fU=e=>{let[t,n]=e.split(`/`);fO(dO(`knowledge`,t??``,n??``))};function pU(){return(0,V.jsx)(mO,{className:`m-4 flex-1`,children:(0,V.jsxs)(hO,{children:[(0,V.jsx)(_O,{variant:`icon`,children:(0,V.jsx)(Xp,{"aria-hidden":`true`})}),(0,V.jsx)(yO,{children:`No knowledge files yet.`})]})})}function mU(e,t,n,r){let i=e.find(e=>e.agent===t&&e.file===n);return i?(0,V.jsx)(nU,{agent:i.agent,file:i.file,onChanged:r},rU(i)):t&&n?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That file is not on the list any more.`}):null}function hU(){let e=AO(`lobby`),t=AO(`status`),n=e.data,r=t.data?.busy??!1;return!n?.chat.length&&!n?.reply&&!r?(0,V.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,V.jsx)(LH,{chat:n?.chat??[],reply:n?.reply,busy:r,hasOlder:n?.hasOlderChat??!1,hasTask:!!n?.task})}function gU({read:e,selected:t}){let n=e.data?.files.reduce((e,t)=>e+t.notes,0)??0;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(xk,{title:`Knowledge`,count:n>0?`${n} note${n===1?``:`s`}`:void 0}),(0,V.jsx)(_U,{read:e,selected:t})]})}function _U({read:e,selected:t}){return!e.data&&e.error?(0,V.jsx)(EO,{message:`Could not load the knowledge files. ${e.error}`,onRetry:e.reload}):e.data?e.data.files.length?(0,V.jsx)(uU,{files:e.data.files,models:e.data.models??{},selectedKey:t,onSelect:fU}):(0,V.jsx)(pU,{}):(0,V.jsx)(Sk,{})}function vU({rest:e}){let{chat:t,agent:n,file:r}=RH(e),i=gk(),a=MO(`knowledge.files`,{},[`knowledge`]),o=a.data?.files??[],s=o.find(e=>e.agent===n&&e.file===r);return(0,V.jsx)(bk,{wide:i,inlineDetail:!0,list:(0,V.jsx)(gU,{read:a,selected:s?rU(s):void 0}),detail:t?(0,V.jsx)(hU,{}):mU(o,n,r,a.reload),detailClassName:t?`flex flex-col overflow-hidden p-0`:void 0,open:t||!!(n&&r),onClose:dU,hint:`Select a file to read its entries, or ask about the project below.`,describe:t?`Knowledge chat`:`Knowledge file`})}function yU(e){let t=e[0];try{return{id:t?decodeURIComponent(t):void 0}}catch{return{id:t}}}var bU=e=>e?.panels??{conversation:!0,activity:!0,thinking:!0};function xU({data:e,status:t}){let n=bU(t);if(!n.conversation)return null;let r=n.activity?e?.activity:void 0;return(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,V.jsx)(LH,{chat:e?.chat??[],...r?{activity:r}:{},reply:e?.reply,busy:t?.busy??!1,hasOlder:e?.hasOlderChat??!1,hasTask:!!e?.task})})}function SU(){let e=AO(`lobby`),t=AO(`status`);return!e.data&&e.loading?(0,V.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(bO,{}),(0,V.jsx)(`span`,{children:`Connecting…`})]}):!e.data&&e.error?(0,V.jsx)(EO,{message:e.error,onRetry:()=>P.onHello({})}):(0,V.jsx)(xU,{data:e.data,status:t.data})}var CU=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 wU(e,t){return JSON.stringify([e,`prompt`,t])}function TU(e,t,n){return JSON.stringify([e,`dialog`,t,n])}function EU(e,t,n){return JSON.stringify([e,`delivery`,t,n])}var DU=`bot-lobby.prompt-sound-muted`,OU=new Set,kU,AU=!1;function jU(){try{return localStorage.getItem(DU)===`on`}catch{return AU}}function MU(e){AU=e;try{localStorage.setItem(DU,e?`on`:`off`)}catch{}for(let e of OU)e()}function NU(e){return OU.add(e),()=>{OU.delete(e)}}function PU(){return(0,m.useSyncExternalStore)(NU,jU,()=>!1)}function FU(){(0,m.useEffect)(()=>{let e=()=>{try{kU??=new AudioContext,kU.resume().catch(()=>void 0)}catch{}};return window.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,e)}},[])}function IU(){if(!jU()&&kU&&kU.state===`running`)try{let e=kU.currentTime,t=kU.createOscillator(),n=kU.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(kU.destination),t.start(e),t.stop(e+.24),t.onended=()=>{t.disconnect(),n.disconnect()}}catch{}}var LU=`bot-lobby.notifications`,RU=`/icon-192.png`,zU=new Set;function BU(){for(let e of[...zU])e()}function VU(){try{return localStorage.getItem(LU)===`on`}catch{return!1}}function HU(e){return zU.add(e),()=>{zU.delete(e)}}function UU(e){try{localStorage.setItem(LU,e?`on`:`off`)}catch{}BU()}function WU(){return(0,m.useSyncExternalStore)(HU,VU,()=>!1)}async function GU(){return typeof Notification>`u`?`unsupported`:(Notification.permission==="default"&&await Notification.requestPermission().catch(()=>void 0),Notification.permission===`granted`?(UU(!0),`granted`):`denied`)}function KU(){UU(!1)}function qU(e){if(e===`completed`)return`finished`;if(e===`abandoned`)return`dropped`}function JU(){return typeof Notification<`u`&&Notification.permission===`granted`&&document.hidden}function YU(e){try{new Notification(`bot-lobby`,{body:e,icon:RU,tag:`bot-lobby`})}catch{}}function XU(){try{return new CU(sessionStorage)}catch{return new CU}}function ZU(e,t){let n=t.payload;return t.kind===`sessionDialog`&&n?.dialog?.id?TU(e,t.sessionId??n.key??t.from,n.dialog.id):wU(e,t.id)}function QU(){let e=WU();FU(),OO();let t=MO(`tasks.list`,{},[`tasks`]),n=MO(`sessions.list`,{},[`sessions`]),r=P.get(`prompts`),i=P.get(`lobby`).data,a=(0,m.useRef)(XU()),o=(0,m.useRef)(new Set([`prompts`,`sessions`,`delivery`])),s=(0,m.useRef)(void 0),c=pe()??`current`,l=P.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 $U(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(()=>IU()),c&&JU()&&YU(r),t===`delivery`&&mp.info(r,{action:{label:`Review tasks`,onClick:()=>fO(`#/tasks`)}}))}function eW(e){let{prompts:t,sessions:n,tasks:r,project:i}=e,a=t.data?.prompts;$U(e,`prompts`,(a??[]).map(e=>ZU(i,e)),`A question is waiting for you.`,!!a&&!t.loading),$U(e,`sessions`,n.data?.background.flatMap(e=>e.dialogs.map(t=>TU(i,e.sessionId??e.key,t.id)))??[],`A background session is asking something.`,!!n.data&&!n.loading),$U(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=>EU(i,e.id,e.delivery.reviewId))??[],`Completed work is ready for delivery review in Tasks.`,!!r.data&&!r.loading)}function tW(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}eW(e);let s=a?.task?.state??``,c=qU(s);i.current&&c&&s!==i.current&&o&&JU()&&YU(`${a?.task?.title??`The task`} ${c}.`),i.current=s}function nW(){let e=QU(),{connection:t,enabled:n,project:r,prompts:i,sessions:a,tasks:o,lobby:s}=e;(0,m.useEffect)(()=>tW(e),[t,n,r,i.data,i.loading,a.data,a.loading,o.data,o.loading,s])}function rW({className:e,type:t,...n}){return(0,V.jsx)(`input`,{type:t,"data-slot":`input`,className:J(`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 iW({className:e,thumbClassName:t,...n}){return(0,V.jsx)(JE,{"aria-keyshortcuts":`Enter Space`,"aria-description":`When focused, press Enter or Space to toggle.`,"data-slot":`switch`,className:J(`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,V.jsx)(XE,{"data-slot":`switch-thumb`,className:J(`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 aW(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}function oW(e,t,n,r){for(let i=n+r;i>=0&&i<e.length;i+=r)if(t.includes(e[i]))return i;return n}var sW={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 cW(e,t,n,r){let i=Math.max(t.length-1,1);if(e===`ArrowRight`||e===`ArrowUp`)return oW(t,n,r,1);if(e===`ArrowLeft`||e===`ArrowDown`)return oW(t,n,r,-1);if(e===`Home`)return aW(t,n,0);if(e===`End`)return aW(t,n,i)}function lW(e,t,n,r,i){let a=e.current?.getBoundingClientRect();if(!a||a.width===0)return i;let o=Math.min(1,Math.max(0,(t-a.left)/a.width));return aW(n,r,Math.round(o*Math.max(n.length-1,1)))}function uW(e){let[t,n]=(0,m.useState)(),r=(0,m.useRef)(void 0),i=(0,m.useRef)(0),a=(0,m.useCallback)(()=>{r.current=void 0,i.current=0,n(void 0)},[]);return(0,m.useEffect)(()=>{if(t===void 0)return;let e=window.setTimeout(a,1e4);return()=>window.clearTimeout(e)},[t,a]),{chosenByKey:t,intended:r,choose:(t,o)=>{r.current=t,n(t),i.current+=1,Promise.resolve(e(o)).catch(()=>void 0).then(()=>{--i.current,i.current<=0&&a()})}}}function dW({levels:e,supported:t,value:n,disabled:r,onChange:i}){let a=(0,m.useRef)(null),[o,s]=(0,m.useState)(),c=uW(i),l=aW(e,t,Math.max(0,e.indexOf(n))),u=o??c.chosenByKey??l,d=n=>lW(a,n,e,t,l);function f(e){r||t.length===0||(e.currentTarget.setPointerCapture(e.pointerId),s(d(e.clientX)))}function p(e){if(o===void 0)return;let t=d(e.clientX);t!==o&&s(t)}function h(){if(o===void 0)return;let t=e[o];s(void 0),t&&t!==n&&i(t)}function g(n){if(r||u<0)return;let i=c.intended.current??u,a=cW(n.key,e,t,i);if(a===void 0)return;n.preventDefault();let o=e[a];o&&a!==i&&c.choose(a,o)}function _(n){let i=e[n];!r&&i&&t.includes(i)&&n!==(c.intended.current??u)&&c.choose(n,i)}return{track:a,shown:u,dragging:o!==void 0,jump:_,handlers:{onPointerDown:f,onPointerMove:p,onPointerUp:h,onPointerCancel:()=>s(void 0),onKeyDown:g}}}var fW={xhigh:`Extra high`},pW=e=>fW[e]??`${e.charAt(0).toUpperCase()}${e.slice(1)}`,mW={type:`spring`,stiffness:520,damping:36},hW={xhigh:{type:`spring`,stiffness:120,damping:20,mass:1.4},max:{type:`spring`,stiffness:46,damping:13,mass:2.2}},gW={xhigh:1100,max:2e3},_W=3;function vW(e,t){let[n,r]=(0,m.useState)(),i=(0,m.useRef)(e);return(0,m.useEffect)(()=>{let n=i.current;if(i.current=e,t||n===e||e!==`xhigh`&&e!==`max`||e===`xhigh`&&n===`max`)return;r(e);let a=window.setTimeout(()=>r(void 0),gW[e]);return()=>window.clearTimeout(a)},[e,t]),n}var yW=`1.625rem`,bW=`1.25rem`;function xW({value:e,levels:t,supported:n,recommended:r,model:i,label:a,disabled:o,onChange:s}){let c=kf()??!1,l=dW({levels:t,supported:n,value:e,disabled:o,onChange:s}),{shown:u,dragging:d}=l,f=Math.max(t.length-1,1),p=Math.max(u,0),m=t[u]??e,h=p===t.length-1&&t.length>1,g=u>=0&&!d&&m!==e,_=r?aW(t,n,Math.max(0,t.indexOf(r))):-1,v=i??`this model`,y=vW(m,c),b=d||c?{duration:0}:y?hW[y]:mW,x=[`high`,`xhigh`,`max`].includes(m),S=e=>`calc(${yW} + (100% - 2 * ${yW}) * ${e/f})`,C=`${a.replace(/\W+/g,`-`)}-hint`;return(0,V.jsxs)(`div`,{className:J(`effort grid min-w-0 gap-1`,o&&`opacity-64`),"data-off":m===`off`||void 0,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,"aria-hidden":`true`,children:[`Effort`,` `,(0,V.jsx)(`span`,{"data-slot":`effort-value`,className:`font-semibold text-foreground`,children:pW(m)})]}),(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`About effort`,"aria-describedby":C,"data-compact":!0,className:`effort-help inline-flex size-6 shrink-0 items-center justify-center rounded-md text-xs font-semibold text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:`?`})}),(0,V.jsxs)(IO,{className:`max-w-64`,children:[sW[m]??``,` More effort means more reasoning before each answer: slower and costlier, better on hard problems.`]})]})]}),(0,V.jsxs)(`div`,{role:`slider`,tabIndex:o?-1:0,"aria-label":a,"aria-valuemin":0,"aria-valuemax":t.length-1,"aria-valuenow":p,"aria-valuetext":m,"aria-describedby":C,"aria-disabled":o||void 0,...l.handlers,"data-slot":`effort-track`,"data-level":m,"data-top":h||void 0,"data-dragging":d||void 0,"data-charge":y,className:`effort-track relative h-10 cursor-pointer touch-none rounded-md outline-none select-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,children:[m===`max`?(0,V.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`effort-aura`,className:`effort-aura pointer-events-none absolute -inset-1 rounded-lg`}):null,(0,V.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`effort-rail`,className:`effort-rail absolute inset-0 overflow-hidden rounded-md`,children:(0,V.jsxs)($f.span,{"data-slot":`effort-fill`,className:`effort-fill absolute inset-y-0 left-0 rounded-md`,initial:!1,animate:{width:`calc(${S(p)} + ${bW})`},transition:b,children:[(0,V.jsx)(`span`,{className:`effort-flow absolute inset-y-0 left-0`}),x&&m!==`max`?(0,V.jsx)(`span`,{"data-slot":`effort-embers`,className:`effort-embers absolute inset-0`}):null,m===`max`?(0,V.jsxs)(`span`,{"data-slot":`effort-warp`,className:`effort-warp absolute inset-0`,children:[Array.from({length:_W},(e,t)=>(0,V.jsx)(`span`,{className:`effort-stars absolute inset-y-0 left-0`,"data-layer":t},t)),(0,V.jsx)(`span`,{className:`effort-streaks absolute inset-y-0 left-0`}),(0,V.jsx)(`span`,{className:`effort-tunnel absolute inset-0`})]}):null,h?(0,V.jsx)(`span`,{"data-slot":`effort-sheen`,className:`effort-sheen absolute inset-0`}):null]})}),(0,V.jsx)(`div`,{ref:l.track,"aria-hidden":`true`,className:`absolute inset-y-0`,style:{left:yW,right:yW}}),t.map((e,t)=>{let r=n.includes(e);return(0,V.jsx)(`span`,{"aria-hidden":`true`,"data-stop":e,"data-supported":r,title:r?pW(e):`Not supported by ${v}`,className:J(`absolute top-1/2 size-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full transition-colors duration-200`,r?t<=p?`effort-dot-lit`:`effort-dot`:`ring-1 ring-muted-foreground/50`),style:{left:S(t)}},e)}),_>=0&&_!==p?(0,V.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`effort-recommended-mark`,className:`effort-mark absolute top-1/2 size-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full`,style:{left:S(_)}}):null,(0,V.jsx)($f.span,{"aria-hidden":`true`,"data-slot":`effort-thumb`,className:`absolute top-1/2 z-10`,initial:!1,animate:{left:S(p)},transition:b,children:(0,V.jsx)($f.span,{className:`effort-thumb block h-8 w-10 -translate-x-1/2 -translate-y-1/2 rounded-md`,initial:!1,animate:{scale:d===void 0?1:1.08,scaleX:d===void 0?1:1.12},transition:c?{duration:0}:{type:`spring`,stiffness:600,damping:20}})})]}),(0,V.jsxs)(`div`,{"aria-hidden":`true`,className:`relative flex h-4 justify-between px-1 text-xs text-muted-foreground`,children:[(0,V.jsx)(`span`,{className:J(_>=0&&_/f<.3&&`invisible`),children:`Faster`}),(0,V.jsx)(`span`,{className:J(_>=0&&_/f>.7&&`invisible`),children:`Smarter`}),_>=0?(0,V.jsx)(`span`,{"data-slot":`effort-recommended`,className:J(`absolute top-0 -translate-x-1/2 whitespace-nowrap transition-colors`,p===_?`font-medium text-foreground`:`text-muted-foreground`),style:{left:`clamp(2.75rem, ${S(_)}, calc(100% - 2.75rem))`},children:`Recommended`}):null]}),(0,V.jsx)(`p`,{id:C,"data-slot":`effort-hint`,className:`sr-only`,"aria-live":`polite`,children:sW[m]??``}),g?(0,V.jsxs)(`p`,{className:`text-xs text-warning`,children:[e,` is not supported by `,v,`, so it runs at `,m,`.`]}):null]})}function SW(e){return(0,V.jsx)(PE,{...e})}function CW(e){return(0,V.jsx)(FE,{"data-slot":`popover-trigger`,...e})}function wW({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,V.jsx)(IE,{children:(0,V.jsx)(LE,{"data-slot":`popover-content`,align:t,sideOffset:n,className:J(`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 TW=`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`,EW=`-me-1 size-3 shrink-0 opacity-50`;function DW(e,t){let n=`${e.label} ${e.hint??``} ${e.value}`.toLowerCase();return t.toLowerCase().split(/\s+/).filter(Boolean).every(e=>n.includes(e))}function OW({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=>DW(e,c)),[t,c]),g=t.find(t=>t.value===e);(0,m.useEffect)(()=>{o&&(l(``),d(Math.max(0,t.findIndex(t=>t.value===e))))},[o]),(0,m.useEffect)(()=>{c&&d(0)},[c]),(0,m.useEffect)(()=>{f.current?.querySelector(`[data-index="${u}"]`)?.scrollIntoView({block:`nearest`})},[u,o,h.length]);function _(t){t&&(s(!1),t.value!==e&&n(t.value))}function v(e){e.key===`ArrowDown`?(e.preventDefault(),d(e=>Math.min(h.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),d(e=>Math.max(0,e-1))):e.key===`Home`&&!c?(e.preventDefault(),d(0)):e.key===`End`&&!c?(e.preventDefault(),d(Math.max(0,h.length-1))):e.key===`Tab`?s(!1):e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),_(h[u]))}return(0,V.jsxs)(SW,{open:o,onOpenChange:s,children:[(0,V.jsxs)(CW,{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:J(TW,`w-full min-w-0 overflow-hidden whitespace-nowrap`,i),children:[(0,V.jsx)(`span`,{className:`min-w-0 truncate`,children:g?.label??e}),(0,V.jsx)(im,{"aria-hidden":`true`,strokeWidth:2.25,className:EW})]}),(0,V.jsxs)(wW,{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,V.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-2.5`,children:[(0,V.jsx)(wg,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),onKeyDown:v,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,V.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,V.jsxs)(`p`,{className:`px-2.5 py-2 text-xs text-muted-foreground`,children:[`Nothing matches “`,c,`”.`]}):null,h.map((t,n)=>(0,V.jsx)(`div`,{id:`${p}-${n}`,role:`option`,"aria-selected":t.value===e,"data-index":n,onPointerMove:()=>d(n),onClick:()=>_(t),className:J(`flex min-h-8 cursor-pointer items-center gap-2 rounded-sm px-2 py-1 text-sm select-none sm:min-h-7`,t.value===e&&`bg-foreground/[0.08]`,n===u&&`bg-accent text-accent-foreground`),children:(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,V.jsx)(`span`,{className:`truncate`,children:t.label}),t.hint?(0,V.jsx)(`span`,{className:`line-clamp-2 text-pretty text-xs text-muted-foreground/80`,children:t.hint}):null]})},t.value))]})]})]})}var kW=Wv([`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 AW({className:e,variant:t,spacing:n,stacked:r,dense:i,...a}){return(0,V.jsx)(`div`,{className:J(kW({variant:t,spacing:n,stacked:r,dense:i}),e),"data-slot":`frame`,"data-spacing":n,...a})}function jW({className:e,fit:t,...n}){return(0,V.jsx)(`div`,{className:J(`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 MW({label:e,help:t,children:n,stacked:r}){return(0,V.jsxs)(`div`,{className:r?`grid gap-1`:`grid grid-cols-[minmax(0,1fr)_minmax(0,18rem)] items-center gap-4`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 break-words`,children:[(0,V.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:e}),t?(0,V.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:t}):null]}),(0,V.jsx)(`div`,{className:`min-w-0`,children:n})]})}function NW({children:e}){return(0,V.jsx)(AW,{dense:!0,children:(0,V.jsx)(jW,{className:`flex flex-col divide-y divide-border py-0 [&>*]:py-2`,children:e})})}function PW({value:e,items:t,label:n,onChange:r}){return(0,V.jsx)(OW,{value:e,options:t.map(e=>({value:e.value,label:e.label,...e.help?{hint:e.help}:{}})),label:n,onChange:r})}var FW=`(prefers-color-scheme: dark)`,IW=[`dark`,`light`,`system`],LW=m.createContext(void 0);function RW(e){return e!==null&&IW.includes(e)}function zW(){return window.matchMedia(FW).matches?`dark`:`light`}function BW(){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 VW(e){return e instanceof HTMLElement&&!!(e.isContentEditable||e.closest(`input, textarea, select, [contenteditable='true']`))}function HW({children:e,defaultTheme:t=`system`,storageKey:n=`theme`,disableTransitionOnChange:r=!0,...i}){let[a,o]=m.useState(()=>{let e=localStorage.getItem(n);return RW(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`?zW():e,i=r?BW():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(FW),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||VW(e.target)||e.key.toLowerCase()===`d`&&o(e=>{let t=e===`dark`?`light`:e===`light`?`dark`:zW()===`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(RW(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,V.jsx)(LW.Provider,{...i,value:l,children:e})}var UW=()=>{let e=m.useContext(LW);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e};function WW({kind:e,dense:t=!1}){let n=e===`font`?Ve:He,r=Ze(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];Ye(e,s.id),requestAnimationFrame(()=>i.current?.querySelector(`[data-face="${s.id}"]`)?.focus())}return(0,V.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=Qe[n.id];return(0,V.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":i,"data-face":n.id,tabIndex:i?0:-1,onClick:()=>Ye(e,n.id),className:J(`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`:J(`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,V.jsx)(`span`,{"aria-hidden":`true`,className:J(`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,V.jsxs)(`span`,{className:J(`flex min-w-0 items-center justify-between gap-2`,t&&`flex-1`),children:[(0,V.jsxs)(`span`,{className:`min-w-0`,children:[(0,V.jsx)(`span`,{className:`block truncate text-[0.8125rem] font-medium`,children:n.label}),t?null:(0,V.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:n.help})]}),i?(0,V.jsx)(nm,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]})]},n.id)})})}var GW=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`quickfix`,`planner`],KW={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scout`,researcher:`Researcher`,quickfix:`Quick fix`,planner:`Planner`},qW=`inherit`,JW=`inherit`,YW=`Use the session's current model`,XW=`__custom__`,ZW=`custom…`,QW=`Type a provider/model id`,$W={master:`high`,designer:`medium`,backend:`medium`,qa:`medium`,scout:`low`,researcher:`low`,quickfix:`low`,planner:`high`},eG=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],tG={agents:`Agents`,workflow:`Workflow`,lint:`Linting`,lobby:`Lobby`,classifier:`Classifier`,appearance:`Appearance`,notifications:`Notifications`,install:`Install as app`},nG=[{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)`},{id:`issues`,label:`Issues`,help:`GitHub issues under Git`}],rG=[{id:`conversation`,label:`Conversation pane`},{id:`activity`,label:`Activity steps in the conversation`},{id:`thinking`,label:`Thinking bubble`}],iG=`shown on the Lobby tab`,aG=`Planning rounds`,oG=`how many rounds the panel gets before the oracle settles the rest alone`,sG=[2,3,5,8,0],cG=`Split long plans`,lG=`saving a plan with more steps offers to split it into up to 5 tasks`,uG=[6,8,10,12,0],dG=`Port`,fG=`the base port (then the next free up to +20); 0 means any free port; applies the next time pi starts`,pG=`Open browser`,mG=`open this page in the browser when pi starts`,hG=[{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`}],gG=`Git isolation`,_G=[{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`}],vG={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`},yG=[{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`}],bG=[{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:`triage`,label:`Task triage`,help:`a new task's size, domains and research need reach the Master as hints; a quick fix that is really a task is held for you`},{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, quick fixes and the planning panel start with the files most likely needed, and can look more up with find_relevant_files`}],xG={enabled:`Classifier`,enabledHelp:`a fast model makes the obvious decisions so large models spend fewer tokens on them`,engine:`Answered by`,engineHelp:`Jev, another classifier model, or any chat model your pi logins offer (OpenAI, Anthropic, Google, …); a small, fast one works best`,engineJev:`Jev on a host`,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`},SG={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`},CG=`https://tweakcn.com/editor/theme`;function wG(){let{theme:e}=UW();return e===`dark`||e===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}function TG({palette:e,dark:t}){let n=oe(e,t);return(0,V.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,V.jsx)(`span`,{className:`size-4 rounded-full border border-black/10`,style:{background:n.card}}),(0,V.jsx)(`span`,{className:`size-4 rounded-full`,style:{background:n.primary}}),(0,V.jsx)(`span`,{className:`h-2 flex-1 rounded-full`,style:{background:n.accent}})]})}function EG(){let e=Be(),t=wG(),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,V.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,V.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:J(`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,V.jsx)(TG,{palette:n,dark:t}),(0,V.jsxs)(`span`,{className:`flex min-w-0 items-center justify-between gap-2 px-0.5 text-[0.8125rem] font-medium`,children:[(0,V.jsxs)(`span`,{className:`truncate`,children:[n.name,e.isSaved(n.id)?(0,V.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:`saved`}):null]}),r?(0,V.jsx)(nm,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]})]},n.id)})})}function DG({entry:e}){let t=Be(),[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),mp.success(`Renamed to ${n}.`)}catch(e){s(e.message)}}return(0,V.jsxs)(`li`,{className:`flex min-h-10 flex-wrap items-center gap-2 py-1.5`,children:[n?(0,V.jsxs)(`form`,{className:`flex min-w-0 flex-1 items-center gap-1`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,V.jsx)(rW,{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,V.jsx)(nk,{label:`Save the name`,text:`Save`,icon:nm,tone:`primary`,type:`submit`,disabled:!i.trim()}),(0,V.jsx)(nk,{label:`Keep the old name`,icon:o_,iconOnly:!0,onClick:()=>{a(e.name),r(!1)}})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),(0,V.jsx)(nk,{label:`Rename ${e.name}`,text:`Rename`,icon:og,onClick:()=>{a(e.name),r(!0)}}),(0,V.jsx)(Rk,{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:Wg,variant:`destructive`,onConfirm:()=>void t.remove(e.id).catch(e=>mp.error(e.message))})]}),o?(0,V.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,children:o}):null]})}function OG(){let e=Be();return e.saved.length===0?(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No saved themes yet. Import one below and give it a name.`}):(0,V.jsx)(`ul`,{"aria-label":`Saved themes`,className:`divide-y divide-border`,children:e.saved.map(e=>(0,V.jsx)(DG,{entry:e},e.id))})}function kG(){let e=Be(),[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=te(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`;mp.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,V.jsxs)(`div`,{className:`grid gap-2`,children:[(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Pick or build a theme in the`,` `,(0,V.jsxs)(`a`,{href:CG,target:`_blank`,rel:`noreferrer noopener`,className:`inline-flex items-center gap-0.5 text-link underline-offset-2 hover:underline`,children:[`tweakcn editor `,(0,V.jsx)(Hm,{"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,V.jsxs)(`label`,{className:`grid gap-1 text-xs text-muted-foreground`,children:[`Name`,(0,V.jsx)(rW,{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,V.jsx)(Ck,{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
  …
@@ -102,14 +102,14 @@ Error generating stack: `+e.message+`
102
102
  `)?(0,V.jsx)(aB,{text:e.prompt}):null,(0,V.jsx)(Uq,{job:e}),(0,V.jsx)(cB,{title:`Steps`,children:(0,V.jsx)(Wq,{job:e})}),e.files?.length?(0,V.jsx)(cB,{title:`Edited`,children:(0,V.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.files.map(e=>(0,V.jsxs)(`li`,{className:`break-all`,children:[`· `,e]},e))})}):null,e.error?(0,V.jsx)(`p`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:e.error}):null,e.report?(0,V.jsx)(cB,{title:`Report`,children:(0,V.jsx)(aB,{text:e.report})}):null]})}function qq({status:e}){if(e===`running`)return(0,V.jsx)(bO,{className:`size-3.5`,"aria-label":`running`});let t={queued:Am,success:nm,failed:o_,timeout:o_,cancelled:Hh,held:ng,running:Am}[e];return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(t,{"aria-hidden":`true`,className:`size-4 ${e===`success`?`text-success`:e===`failed`||e===`timeout`?`text-destructive`:e===`held`?`text-warning`:`text-muted-foreground`}`}),(0,V.jsx)(`span`,{className:`sr-only`,children:e})]})}function Jq({job:e,selected:t,now:n,onSelect:r}){let i=Bq(e,n);return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>r(e.id),className:J(qB,`flex-row items-start gap-2.5 text-sm`),children:[(0,V.jsx)(`span`,{className:`flex h-5 w-4 shrink-0 items-center justify-center`,children:(0,V.jsx)(qq,{status:e.status})}),(0,V.jsx)(`span`,{className:J(`min-w-0 flex-1 break-words`,t?`font-medium text-foreground`:`text-foreground`),children:Lq(e)}),i?(0,V.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:i}):null]})})}function Yq({jobs:e,selectedId:t,now:n,onSelect:r}){return(0,V.jsx)(`ul`,{className:JB,children:e.map(e=>(0,V.jsx)(Jq,{job:e,selected:e.id===t,now:n,onSelect:r},e.id))})}var Xq=()=>fO(dO(`quickfix`)),Zq=e=>fO(dO(`quickfix`,e));function Qq(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),e?t:Date.now()}function $q(){return(0,V.jsx)(mO,{className:`m-4 flex-1`,children:(0,V.jsxs)(hO,{children:[(0,V.jsx)(_O,{variant:`icon`,children:(0,V.jsx)(c_,{"aria-hidden":`true`})}),(0,V.jsx)(yO,{className:`font-medium text-foreground`,children:Iq})]})})}function eJ({id:e}){let t=gk(),n=MO(`quickfix.list`,{},[`quickfix`]),r=Rq(n.data?.jobs??[]),i=Qq(r.some(e=>e.status===`running`));if(!n.data&&n.error)return(0,V.jsx)(EO,{message:`Could not load quick fixes. ${n.error}`,onRetry:n.reload});let a=n.data&&r.length===0?(0,V.jsx)($q,{}):(0,V.jsx)(tJ,{id:e,wide:t,loaded:!!n.data,jobs:r,now:i});return(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:a})}function tJ({id:e,wide:t,loaded:n,jobs:r,now:i}){let a=e??(t?r[0]?.id:void 0),o=r.find(e=>e.id===a),s=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(xk,{title:`Quick fixes`,count:String(r.length)}),n?(0,V.jsx)(Yq,{jobs:r,selectedId:a,now:i,onSelect:Zq}):(0,V.jsx)(Sk,{})]});return(0,V.jsx)(bk,{wide:t,list:s,detail:o?(0,V.jsx)(Kq,{job:o,now:i}):e?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That quick fix is not on the list any more.`}):null,open:!!e,onClose:Xq,hint:`Select a quick fix to see its steps.`,describe:`Quick fix detail`})}var nJ={},rJ=new Set;function iJ(e){nJ=e;for(let e of[...rJ])e()}function aJ(e){nJ.taskId!==e&&iJ({...nJ,taskId:e})}function oJ(e){return rJ.add(e),()=>{rJ.delete(e)}}function sJ(){return(0,m.useSyncExternalStore)(oJ,()=>nJ,()=>nJ)}function cJ(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 lJ(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 uJ(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 dJ({timing:e,stopped:t}){let[n,r]=(0,m.useState)(0);return(0,m.useEffect)(()=>{if(r(0),t||e.waiting||!e.runningSince)return;let n=performance.now(),i=window.setInterval(()=>r(performance.now()-n),1e3);return()=>window.clearInterval(i)},[e,t]),(0,V.jsxs)(`span`,{className:`tabular-nums break-words`,children:[e.waiting?`Waiting for you · `:``,e.phase.replaceAll(`_`,` `),` · `,lJ(cJ(e,n,t)),` execution`]})}function fJ({work:e,timing:t,stopped:n}){let r=e.running&&!n&&!t?.waiting,i=uJ(r,e);return(0,V.jsxs)(`span`,{className:`tabular-nums break-words`,"data-work-clock":r?`running`:`stopped`,children:[t?.waiting?`Waiting for you · `:``,t?`${t.phase.replaceAll(`_`,` `)} · `:``,`worked `,lJ(e.workedMs+i)]})}function pJ({timing:e,work:t,stopped:n=!1}){return t?(0,V.jsx)(fJ,{work:t,...e?{timing:e}:{},stopped:n}):e?(0,V.jsx)(dJ,{timing:e,stopped:n},JSON.stringify(e)):(0,V.jsx)(`span`,{children:`Timing unavailable`})}var mJ=`This merges the reviewed commit into main and pushes main, then removes the task worktree after verifying the merge. The task branch is kept.`,hJ={pending_approval:`Ready for your review`,deferred:`Saved for later`,in_progress:`Delivery in progress`,successful:`Delivered`,recoverable_failure:`Delivery needs attention`};function gJ({delivery:e,title:t}){return(0,V.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,V.jsx)(`p`,{className:`font-medium break-words`,children:t}),(0,V.jsxs)(`dl`,{className:`grid gap-1 break-all text-muted-foreground`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline`,children:`Project: `}),(0,V.jsx)(`dd`,{className:`inline`,children:e.project})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline`,children:`Repository: `}),(0,V.jsx)(`dd`,{className:`inline`,children:e.repository??`Unavailable — refresh review`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline`,children:`Source: `}),(0,V.jsxs)(`dd`,{className:`inline`,children:[e.sourceBranch,` · `,e.sourceCommit??`Commit unavailable`]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline`,children:`Target: `}),(0,V.jsxs)(`dd`,{className:`inline`,children:[`main`,e.targetCommit?` · ${e.targetCommit}`:``]})]})]}),(0,V.jsxs)(`p`,{children:[`Checks: `,e.verification?.checks??`unavailable`]}),(0,V.jsx)(`p`,{children:e.verification?.summary??`Verification unavailable. Refresh the review before delivery.`}),e.verification?(0,V.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Local completion/QA: `,e.verification.localVerified?`passed`:`not verified`,` · Repository rules: `,e.verification.rulesKnown?`known`:`unavailable`,e.verification.requiredChecks.length?` · Required: ${e.verification.requiredChecks.join(`, `)}`:``]}):null]})}function _J({action:e,delivery:t,busy:n,onAction:r}){let i=t.blocked[e],a=e===`merge_main`&&t.status===`successful`&&!!t.cleanupError,o=n||t.status===`in_progress`||t.status===`successful`&&!a||!!i;return(0,V.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,V.jsx)(Y,{variant:`outline`,disabled:o,onClick:()=>r(e),children:e===`create_pr`?`Create PR`:a?`Retry worktree cleanup`:`Merge to main`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e===`create_pr`?`Pushes the task branch and opens a PR targeting main. Does not merge.`:a?`Main was delivered. Removes the retained worktree after confirmation.`:`Updates and pushes main, then removes the task worktree. Requires confirmation.`}),i?(0,V.jsxs)(`p`,{className:`text-sm text-destructive`,children:[i,` Refresh review after resolving this restriction, then choose the action again.`]}):null]})}async function vJ(e,t,n){let r={taskId:t,reviewId:n};return e===`refresh`?L(`tasks.deliveryReview`,{taskId:t}):e===`defer`?L(`tasks.deliveryDefer`,r):L(`tasks.deliver`,{...r,action:e,...e===`merge_main`?{confirmMain:!0}:{}})}function yJ({taskId:e,delivery:t}){let[n,r]=(0,m.useState)(t),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(!1),u=(0,m.useRef)(null),d=pe(),f=`${d}:${e}`,p=(0,m.useRef)(f);return p.current=f,(0,m.useEffect)(()=>(p.current=f,()=>{p.current=``}),[f]),(0,m.useEffect)(()=>{r(t),l(!1)},[t,e]),{current:n,setCurrent:r,busy:i,setBusy:a,error:o,setError:s,confirm:c,setConfirm:l,trigger:u,project:d,identity:f,scope:p}}function bJ(e){return e.scope.current===e.identity&&e.project===pe()}function xJ(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 vJ(r,t.taskId,e.current.reviewId);bJ(e)&&(e.setCurrent(n.delivery),t.onChanged())}catch(t){bJ(e)&&e.setError(t instanceof Error?t.message:String(t))}finally{n.current=!1,e.scope.current&&e.setBusy(!1)}}}return r}function SJ(e){let t=yJ(e),n=xJ(t,e),r=nO(t.confirm,tO.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 CJ({review:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Task completion is recorded separately. Nothing is published without your approval.`}),(0,V.jsx)(`p`,{role:`status`,className:`text-sm`,children:e.busy?`Updating delivery…`:e.current.operation?`Operation: ${e.current.operation.stage}`:hJ[e.current.status]}),e.current.error||e.error?(0,V.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.error??e.current.error,` Completed work is retained. Refresh review to reconcile the result before retrying.`]}):null,e.current.cleanupError?(0,V.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.current.cleanupError,` Retry cleanup after resolving it.`]}):null,e.current.operation?.worktreeRemoved?(0,V.jsx)(`p`,{className:`text-sm`,children:`Task worktree removed.`}):null,e.current.result?(0,V.jsxs)(`p`,{className:`text-sm break-all`,children:[e.current.result.action===`create_pr`?`PR #${e.current.result.pullNumber??``} created`:`main pushed · ${e.current.result.commit??``}`,e.current.result.pullUrl?(0,V.jsxs)(`span`,{children:[` · `,e.current.result.pullUrl]}):null]}):null]})}function wJ({review:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,V.jsx)(_J,{action:`create_pr`,delivery:e.current,busy:e.busy,onAction:()=>void e.request(`create_pr`)}),(0,V.jsx)(_J,{action:`merge_main`,delivery:e.current,busy:e.busy,onAction:e.reviewMerge})]}),(0,V.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,V.jsx)(Y,{variant:`ghost`,disabled:e.busy,onClick:()=>void e.request(`refresh`),children:`Refresh review`}),(0,V.jsx)(Y,{variant:`ghost`,disabled:e.busy||e.terminal,onClick:()=>void e.request(`defer`),children:`Not now`})]})]})}function TJ({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.`:mJ;return(0,V.jsx)(JD,{open:e.slot,onOpenChange:e.setConfirm,label:t?`Confirm worktree removal`:`Confirm merge to main`,description:n,onCloseAutoFocus:t=>{t.preventDefault(),requestAnimationFrame(()=>e.trigger.current?.focus())},children:(0,V.jsxs)(`div`,{className:`grid gap-3 p-4`,children:[(0,V.jsx)(`h3`,{className:`font-medium`,children:t?`Remove task worktree?`:`Merge to main?`}),(0,V.jsx)(`p`,{className:`text-sm`,children:n}),(0,V.jsxs)(`p`,{className:`break-all text-sm text-muted-foreground`,children:[e.current.repository,` · `,e.current.sourceCommit,` → main`]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,V.jsx)(Y,{variant:`outline`,onClick:()=>e.setConfirm(!1),children:`Cancel`}),(0,V.jsx)(Y,{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 EJ({title:e,review:t}){return(0,V.jsxs)(cB,{title:`Completed work · delivery review`,right:hJ[t.current.status],children:[(0,V.jsx)(gJ,{delivery:t.current,title:e}),(0,V.jsx)(CJ,{review:t}),(0,V.jsx)(wJ,{review:t}),(0,V.jsx)(TJ,{review:t})]})}function DJ(e){let t=SJ(e);return(0,V.jsx)(EJ,{title:e.title,review:t})}var OJ=8;function kJ(e){return e?e.path===`fast`?`fast track (${e.size})`:`full workflow (${e.size})`:``}function AJ(e,t){let n=Math.min(t,OJ);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 jJ({done:e,total:t}){return(0,V.jsx)(`span`,{className:`inline-flex items-center gap-0.5`,"aria-hidden":`true`,children:AJ(e,t).map((e,t)=>(0,V.jsx)(`span`,{className:J(`h-1.5 w-3 rounded-full`,e?`bg-primary`:`bg-muted-foreground/25`)},t))})}function MJ({check:e,className:t}){return(0,V.jsx)(e===`done`?mm:e===`dropped`?Em:Om,{"aria-hidden":`true`,className:J(`size-4 shrink-0`,e===`done`?`text-success`:`text-muted-foreground`,t)})}var NJ={open:Om,delivered:vm,addressed:mm},PJ={open:`waiting for the owning session`,delivered:`sent to the oracle`,addressed:`plan amended`};function FJ({comment:e}){let t=Dk(Date.now()-Date.parse(e.createdAt)),n=NJ[e.status];return(0,V.jsxs)(`p`,{className:`mt-1 flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,V.jsx)(n,{"aria-hidden":`true`,className:e.status===`addressed`?`size-3.5 text-success`:`size-3.5`}),PJ[e.status],`, `,t,e.editedAt?` (edited)`:``]})}function IJ({comment:e,taskId:t,own:n}){let[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(),s=a&&(a.editedAt??``)>(e.editedAt??``)?a:e;return(0,V.jsxs)(`li`,{className:`card-flat min-w-0 rounded-lg border px-3.5 py-2.5`,children:[r?(0,V.jsx)(MK,{text:s.text,onSave:async n=>{let r=await L(`tasks.editComment`,{taskId:t,commentId:e.id,text:n});o(r.comment)},onCancel:()=>i(!1)}):(0,V.jsx)(aB,{text:s.text}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsx)(FJ,{comment:s}),n&&!r?(0,V.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>i(!0),children:`Edit`}):null]})]})}function LJ({taskId:e,finished:t,canComment:n}){let r=MO(`tasks.comments`,{taskId:e},[`tasks`]),i=AO(`status`),a=r.data?.comments??[],o=a.filter(e=>e.status!==`addressed`).length;return(0,V.jsxs)(`section`,{"aria-labelledby":`comments-${e}`,className:`flex flex-col gap-3`,children:[(0,V.jsx)(`h3`,{id:`comments-${e}`,className:`text-sm`,children:(0,V.jsx)(sB,{title:`Comments`,right:o>0?`${o} open`:void 0})}),a.length===0?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?`No comments.`:n?`No comments yet. Comment on the plan in the box below (Markdown and images work); the oracle amends it.`:`No comments yet.`}):(0,V.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:a.map(t=>(0,V.jsx)(IJ,{taskId:e,comment:t,own:!!(t.by&&t.by===i.data?.sessionId)},`${e}-${t.id}`))})]})}var RJ={mine:`This session`,others:`Other sessions`,pending:`Pending`,recent:`Finished`,archived:`Archived`},zJ={open:`open`,done:`done`,dropped:`abandoned`},BJ={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 VJ(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 HJ=`No tasks yet. Start one from the Lobby tab, or plan one in the Plan tab.`;function UJ(e,t){return`${e.replace(/_/g,` `)}${t?` · paused`:``}`}function WJ(e){return e===`now`?`just now`:`${e} ago`}function GJ(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[UJ(e.status,e.paused),e.auto?`auto`:``,t].filter(Boolean).join(` · `)}function KJ(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 qJ(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 JJ=1e3;function YJ({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=nO(i,tO.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{mp((await L(`tasks.skipStep`,{taskId:e,step:t,text:n,reason:g})).notice),a(!1),s(``),r()}catch(e){d(e instanceof Error?e.message:`That did not work. Try again.`)}finally{l(!1)}}};return(0,V.jsxs)(Ok,{open:i&&f,onOpenChange:_,children:[(0,V.jsxs)(`button`,{type:`button`,"aria-label":`Skip step ${t+1}`,onClick:()=>_(!0),className:J(`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,V.jsx)(Ag,{"aria-hidden":`true`,className:`size-3.5`}),`Skip`]}),(0,V.jsxs)(jk,{children:[(0,V.jsxs)(Mk,{children:[(0,V.jsxs)(Pk,{children:[`Skip step `,t+1,`?`]}),(0,V.jsx)(Fk,{children:`The oracle is told to carry on without it, and your reason stays with the step in the task's history.`})]}),(0,V.jsx)(`p`,{className:`rounded-md bg-muted px-2.5 py-1.5 text-sm break-words`,children:n}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`label`,{htmlFor:p,className:`text-sm font-medium`,children:`Why skip it?`}),(0,V.jsx)(Ck,{id:p,value:o,autoFocus:!0,required:!0,maxLength:JJ,disabled:c,"aria-describedby":h,"aria-invalid":u?!0:void 0,placeholder:`Already done by hand, not needed any more, out of scope…`,className:`max-h-48 min-h-20`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),v())}}),(0,V.jsx)(`p`,{id:h,className:`text-xs text-muted-foreground`,children:`A reason is required.`})]}),u?(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:u}):null,(0,V.jsxs)(Nk,{children:[(0,V.jsx)(Lk,{disabled:c,children:`Cancel`}),(0,V.jsx)(Y,{disabled:!g||c,"aria-busy":c,onClick:()=>void v(),children:c?`Skipping…`:`Skip step`})]})]})]})}function XJ({step:e,stopped:t}){let n=uJ(!t,e);return(0,V.jsx)(`span`,{className:`tabular-nums`,children:lJ((e.workedMs??0)+n)})}function ZJ(){return(0,V.jsxs)(`span`,{"aria-hidden":`true`,className:`relative mt-[0.3125rem] grid size-4 shrink-0 place-items-center`,children:[(0,V.jsx)(`span`,{className:`absolute size-2.5 rounded-full bg-primary/30 motion-safe:animate-status-ping`}),(0,V.jsx)(`span`,{className:`size-2 rounded-full bg-primary`})]})}function QJ(e){return(e.split(`
103
103
  `).find(e=>e.trim())?.trim()??``).replace(/^steps?\s+\d+(?:\s*[-–]\s*\d+)?\s*[:.\-–]\s*/i,``).replace(/^\*\*?goal\*\*?\s*[:\-–]\s*/i,``)}function $J({name:e,className:t}){return(0,V.jsx)(`span`,{"aria-hidden":`true`,className:J(`grid size-5 shrink-0 place-items-center rounded-md border border-border bg-card`,JV(e),t),children:(0,V.jsx)(GV,{source:e,className:`size-3`})})}function eY({id:e,agents:t,stepText:n}){let[r,i]=(0,m.useState)(Date.now);(0,m.useEffect)(()=>{let e=window.setInterval(()=>i(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let a=t.filter(e=>!e.parentRunId||!t.some(t=>t.runId===e.parentRunId)).flatMap(e=>[e,...t.filter(t=>t.parentRunId===e.runId)]);return(0,V.jsx)(`ul`,{id:e,"aria-label":`Agents on this step`,className:`mt-2 flex flex-col overflow-hidden rounded-lg border border-border bg-card`,children:a.map(e=>{let i=ZV({domain:e.domain}),a=!!e.parentRunId&&t.some(t=>t.runId===e.parentRunId),o=Date.parse(e.startedAt),s=QJ(e.instruction),c=s&&s.toLowerCase()!==n.trim().toLowerCase()?s:``;return(0,V.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,V.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,V.jsx)($J,{name:i}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,V.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,V.jsx)(`span`,{className:J(`font-medium`,JV(i)),children:qV(i)}),a?(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`child`}):null,(0,V.jsx)(hH,{className:`size-3 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`working`})]}),c?(0,V.jsx)(`span`,{className:`truncate text-muted-foreground`,title:e.instruction,children:c}):null]}),Number.isFinite(o)?(0,V.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:lJ(Math.max(0,r-o))}):null]},e.runId)})})}function tY({agents:e,count:t,step:n,stopped:r}){let i=[...new Set(e.map(e=>ZV({domain:e.domain})))].slice(0,3);return(0,V.jsxs)(V.Fragment,{children:[i.length>0?(0,V.jsx)(`span`,{className:`flex -space-x-1.5`,children:i.map(e=>(0,V.jsx)($J,{name:e,className:`size-[1.125rem] ring-2 ring-card`},e))}):null,(0,V.jsxs)(`span`,{children:[t,` `,t===1?`agent`:`agents`,(0,V.jsx)(`span`,{className:`sr-only`,children:` working`})]}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground/60`,children:`·`}),(0,V.jsx)(XJ,{step:n,stopped:r})]})}var nY=`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 rY(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 iY({step:e,index:t}){let n=e.skip?rY(e.skip.at):``;return(0,V.jsxs)(`li`,{className:`flex min-w-0 flex-col`,"data-step":`skipped`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5 text-sm`,children:[(0,V.jsx)(Sm,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),(0,V.jsxs)(`span`,{className:`shrink-0 text-xs leading-5 text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,V.jsx)(`span`,{className:`min-w-0 break-words text-muted-foreground line-through decoration-muted-foreground/50`,children:e.text}),(0,V.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,V.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,V.jsx)(`span`,{className:`font-medium text-foreground/80`,children:`Why: `}),e.skip.reason,n?(0,V.jsxs)(`span`,{className:`text-muted-foreground/70`,children:[` · `,n]}):null]}):null]})}function aY({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?mm:Om;return e.status===`skipped`?(0,V.jsx)(iY,{step:e,index:t}):(0,V.jsxs)(`li`,{className:`group/step flex min-w-0 flex-col`,"data-step":i?`active`:e.status,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5 text-sm`,children:[i?(0,V.jsx)(ZJ,{}):(0,V.jsx)(f,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 ${d}`}),(0,V.jsxs)(`span`,{className:`shrink-0 text-xs leading-5 text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,V.jsx)(`span`,{className:J(`min-w-0 break-words`,i||e.status===`current`?`text-foreground`:`text-muted-foreground`),children:e.text}),i&&a.length>0?(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":s,"aria-controls":l,onClick:()=>c(e=>!e),className:J(nY,`-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,V.jsx)(tY,{agents:a,count:o,step:e,stopped:n}),(0,V.jsx)(im,{"aria-hidden":`true`,className:J(`size-3 transition-transform duration-200`,s&&`rotate-180`)}),(0,V.jsx)(`span`,{className:`sr-only`,children:` (being worked on now)`})]}):i?(0,V.jsxs)(`span`,{className:J(nY,`-my-0.5`),children:[(0,V.jsx)(tY,{agents:a,count:o,step:e,stopped:n}),(0,V.jsx)(`span`,{className:`sr-only`,children:` (being worked on now)`})]}):e.status===`current`&&!n?(0,V.jsxs)(`span`,{className:`shrink-0 rounded-md bg-accent px-2 py-0.5 text-xs font-medium`,children:[`next`,(0,V.jsx)(`span`,{className:`sr-only`,children:` (the step up next)`})]}):null,r&&!u&&!n?(0,V.jsx)(YJ,{taskId:r.taskId,index:t,text:e.text,onSkipped:r.onSkipped}):null]}),s&&a.length>0?(0,V.jsx)(`div`,{className:`pl-[3.25rem]`,children:(0,V.jsx)(eY,{id:l,agents:a,stepText:e.text})}):null]})}function oY({steps:e,stopped:t,skip:n}){let r=e.filter(e=>e.status===`done`).length,i=e.filter(e=>e.status===`skipped`).length;return(0,V.jsx)(cB,{title:`Steps`,right:`${r}/${e.length} done${i?` · ${i} skipped`:``}`,children:(0,V.jsx)(`ol`,{className:`flex flex-col gap-2`,"aria-label":`Steps`,children:e.map((e,r)=>(0,V.jsx)(aY,{step:e,index:r,stopped:t,skip:n},`${r}-${e.text}`))})})}function sY({text:e}){let[t,n]=(0,m.useState)(!1),r=(0,m.useId)();return(0,V.jsxs)(cB,{title:`Full plan`,children:[(0,V.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,V.jsx)(cm,{"aria-hidden":`true`,className:J(`size-4 transition-transform duration-200 ease-snap`,t&&`rotate-90`)}),t?`Hide the details`:`Read the details of each step`]}),t?(0,V.jsx)(`div`,{id:r,children:(0,V.jsx)(aB,{text:e})}):null]})}function cY({detail:e,finished:t}){return e.plan&&e.planDetails?(0,V.jsx)(sY,{text:e.planDetails}):e.plan?(0,V.jsx)(cB,{title:`Approved plan`,children:(0,V.jsx)(aB,{text:e.plan})}):e.proposal?(0,V.jsx)(cB,{title:t?`Proposal`:`Proposal (no plan yet)`,children:(0,V.jsx)(aB,{text:e.proposal})}):(0,V.jsx)(cB,{title:`Plan`,children:(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?`It ended before a plan was made.`:`No proposal or plan yet — the oracle is still clarifying or scouting.`})})}function lY({amendments:e}){return e.length===0?null:(0,V.jsx)(cB,{title:`Amendments`,children:(0,V.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-sm text-muted-foreground`,children:e.map(e=>(0,V.jsx)(`li`,{className:`break-words`,children:e},e))})})}function uY({risk:e}){let t=BJ[e.risk];return(0,V.jsxs)(cB,{title:`QA risk`,right:VJ(e),children:[(0,V.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1 text-sm`,"data-qa-risk":e.risk,children:[(0,V.jsx)(`span`,{className:J(`rounded-md px-2 py-0.5 text-xs font-medium`,t.tone),children:t.label}),(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:t.depth})]}),e.focusAreas.length>0?(0,V.jsx)(`ul`,{className:`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,V.jsx)(`li`,{className:`break-words`,children:e},e))}):null,(0,V.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 dY({runs:e}){return e.length===0?null:(0,V.jsx)(cB,{title:`Recent runs`,children:(0,V.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.map((e,t)=>(0,V.jsx)(`li`,{className:`break-words`,children:e},`${t}-${e}`))})})}function fY({detail:e,finished:t,skip:n}){return(0,V.jsxs)(V.Fragment,{children:[e.steps.length>0?(0,V.jsx)(oY,{steps:e.steps,stopped:t,skip:n}):null,e.request?(0,V.jsx)(cB,{title:`Request`,children:(0,V.jsx)(aB,{text:e.request})}):null,(0,V.jsx)(cY,{detail:e,finished:t})]})}function pY({detail:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(lY,{amendments:e.amendments}),e.qaRisk?(0,V.jsx)(uY,{risk:e.qaRisk}):null,(0,V.jsx)(dY,{runs:e.runs})]})}function mY({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 fO(`#/lobby`);let t=pe(),r=()=>n.current&&pe()===t;try{let t=await L(`tasks.open`,{taskId:e.id});if(!r())return;let n=await L(`status.get`,{});if(!r())return;if(t.sessionId&&t.sessionId===n.sessionId)return fO(`#/lobby`);if(t.sessionId&&!t.key)return mp.info(`This task runs in another terminal. Switch to that terminal to work on it.`);if(n.busy)return mp.info(`The oracle is working in this window. Stop it first, then open the task in its session.`);await U(`sessions.switch`,t.key?{key:t.key}:{claimTaskId:e.id})&&r()&&fO(`#/lobby`)}catch(e){r()&&mp.error(e instanceof Error?e.message:String(e))}}let i=e.section===`mine`;return(0,V.jsx)(nk,{label:i?`Open in its session: this window`:`Open in its session`,text:`Open in session`,icon:Bp,tone:t?`neutral`:`primary`,shortcut:`S`,onClick:()=>void r()})}function hY({split:e}){let t=e.after.length>0?`, after ${e.after.map(e=>`part ${e}`).join(` and `)}`:``;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[(0,V.jsxs)(`span`,{className:`font-medium text-primary`,children:[`part `,e.part,` of `,e.of]}),` of one plan that was split into tasks`,t?(0,V.jsx)(`span`,{className:`text-foreground`,children:t}):null]}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.titles.map((t,n)=>(0,V.jsxs)(`span`,{children:[n>0?(0,V.jsx)(`span`,{className:`text-muted-foreground/60`,children:` · `}):null,(0,V.jsxs)(`span`,{className:n+1===e.part?`font-medium text-foreground`:void 0,children:[n+1,`. `,t]})]},`${n}-${t}`))})]})}function gY({planId:e}){let t=MO(`plans.get`,{planId:e},[`plans`]),n=t.data;return n?(0,V.jsxs)(V.Fragment,{children:[n.issue?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`from issue #`,n.issue.number,` — `,n.issue.title,n.issue.url?(0,V.jsxs)(`span`,{className:`break-all`,children:[` `,n.issue.url]}):null]}):null,n.split?(0,V.jsx)(hY,{split:n.split}):null,(0,V.jsx)(cB,{title:`Agreed plan`,children:(0,V.jsx)(aB,{text:n.brief})})]}):t.error?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the agreed plan. `,t.error]}):null}function _Y({row:e,onGone:t}){let n=async n=>{await U(`plans.start`,{planId:e.id,where:n})&&t()},r=async()=>{await U(`plans.discard`,{planId:e.id})&&t()};return(0,V.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-4`,"aria-label":e.title,children:[(0,V.jsxs)(rk,{children:[(0,V.jsx)(nk,{label:`Start here`,icon:cg,tone:`primary`,shortcut:`S`,onClick:()=>void n(`here`)}),(0,V.jsx)(nk,{label:`Start in a new session`,text:`New session`,icon:Mg,shortcut:`N`,onClick:()=>void n(`session`)}),(0,V.jsx)(Rk,{icon:Wg,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,V.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,V.jsxs)(`h2`,{className:`flex items-start gap-2.5 text-lg font-medium`,children:[(0,V.jsx)(MJ,{check:`open`,className:`mt-1.5`}),(0,V.jsx)(`span`,{className:`min-w-0 break-words`,children:e.title})]}),(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`pending`,e.age?` · saved ${WJ(e.age)}`:``]}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:e.id})]}),(0,V.jsx)(gY,{planId:e.id})]})}function vY({row:e,onResumed:t}){let[n,r]=(0,m.useState)(!1),i=(0,m.useRef)(!0);(0,m.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]);async function a(){let n=pe();r(!0);try{let r=await L(`tasks.resume`,{taskId:e.id});if(pe()!==n)return;mp(r.notice,{action:{label:`View task`,onClick:()=>fO(dO(`tasks`,e.id))}}),t()}catch(e){pe()===n&&mp.error(e instanceof Error?e.message:String(e))}finally{i.current&&r(!1)}}let o=e.owner===`not running`;return(0,V.jsx)(nk,{label:o?`Resume: carry it on in a background session`:`Resume: unpause it where it runs`,text:`Resume`,icon:cg,tone:`primary`,shortcut:`R`,disabled:n,onClick:()=>void a()})}function yY(e){return e instanceof Error?e.message:`That did not work. Try again.`}function bY({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{mp((await e(i)).notice),r(!1),t()}catch(e){l(yY(e))}finally{s(!1)}}}}function xY({expected:e,value:t,onChange:n,disabled:r}){let i=(0,m.useId)();return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium`,children:`Type the task's title to confirm`}),(0,V.jsx)(`p`,{className:`break-words rounded-md bg-muted px-2 py-1 font-mono text-xs select-all`,children:e}),(0,V.jsx)(rW,{id:i,value:t,disabled:r,autoComplete:`off`,spellCheck:!1,onChange:e=>n(e.target.value)})]})}function SY(e){let t=bY(e),n=nO(t.open,tO.confirm),r=e.typeToConfirm!==void 0&&t.typed!==e.typeToConfirm,i=e.tone??`neutral`;return(0,V.jsxs)(Ok,{open:t.open&&n,onOpenChange:t.change,children:[(0,V.jsx)(nk,{label:e.label,icon:e.icon,tone:i,onClick:()=>t.change(!0)}),(0,V.jsxs)(jk,{children:[(0,V.jsxs)(Mk,{children:[(0,V.jsx)(Pk,{children:e.title}),(0,V.jsx)(Fk,{children:e.description})]}),e.typeToConfirm===void 0?null:(0,V.jsx)(xY,{expected:e.typeToConfirm,value:t.typed,onChange:t.setTyped,disabled:t.busy}),t.error?(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:t.error}):null,(0,V.jsxs)(Nk,{children:[(0,V.jsx)(Lk,{disabled:t.busy,children:`Cancel`}),(0,V.jsx)(Y,{variant:i===`danger`?`destructive`:`default`,disabled:r||t.busy,"aria-busy":t.busy,onClick:()=>void t.submit(),children:t.busy?`Working…`:e.confirmLabel})]})]})]})}function CY({taskId:e,item:t,onDone:n}){let r=n=>()=>L(`tasks.resolveApproval`,{taskId:e,approvalId:t.id,decision:n}),i=`${t.kind}${t.domain?` for ${t.domain}`:``}`;return(0,V.jsxs)(`span`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)(SY,{label:`Approve`,icon:nm,title:`Approve the ${i}?`,description:`${t.detail} The task's oracle is told and carries on with it.`,confirmLabel:`Approve`,run:r(`approved`),onDone:n}),(0,V.jsx)(SY,{label:`Reject`,icon:o_,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 wY({taskId:e,item:t,live:n,onDone:r}){return(0,V.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-1 basis-60 gap-2`,children:[(0,V.jsx)(fm,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-warning`}),(0,V.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[t.kind,` `,t.detail]})]}),n&&t.id?(0,V.jsx)(CY,{taskId:e,item:t,onDone:r}):null]})}function TY({blockers:e}){return e.map((e,t)=>(0,V.jsxs)(`li`,{className:`flex gap-2`,children:[(0,V.jsx)(Em,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-destructive`}),(0,V.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[e.reason,` (needs: `,e.need,`)`]})]},`${t}-${e.reason}`))}function EY({row:e,detail:t,onChanged:n}){let r=e.id;return(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.resumable?(0,V.jsx)(vY,{row:e,onResumed:n}):null,t.canAccept?(0,V.jsx)(SY,{label:`Accept as is`,icon:Og,title:`Accept "${e.title}" as is?`,description:`You accept the work unverified: missing QA and lint checks are waived on your word. The task's oracle is asked to complete it; nothing is merged.`,confirmLabel:`Accept as is`,run:()=>L(`tasks.accept`,{taskId:r}),onDone:n}):null,t.canForceClose?(0,V.jsx)(SY,{label:`Force close`,icon:Sm,tone:`danger`,title:`Force close "${e.title}"?`,description:`The task is abandoned and its running work cancelled. Its code, worktree and history are kept; it is not marked complete.`,confirmLabel:`Force close`,typeToConfirm:e.title,run:e=>L(`tasks.forceClose`,{taskId:r,title:e}),onDone:n}):null]})}function DY({row:e,detail:t,onChanged:n}){let r=e.kind===`task`&&e.check===`open`,i=r&&!!(e.resumable||t.canAccept||t.canForceClose),a=t.waiting;return a.length===0&&t.blockers.length===0&&!i?null:(0,V.jsxs)(cB,{title:`Waiting on`,children:[(0,V.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:[a.map((t,i)=>(0,V.jsx)(wY,{taskId:e.id,item:t,live:r,onDone:n},`${i}-${t.id||t.kind}`)),(0,V.jsx)(TY,{blockers:t.blockers})]}),i?(0,V.jsx)(EY,{row:e,detail:t,onChanged:n}):null]})}function OY(e){if(e.kind===`archived`)return{state:`archived`,rest:WJ(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`} ${WJ(e.age)}`:``;return{state:UJ(e.status,e.paused),rest:[t?``:n,r].filter(Boolean).join(` · `)}}function kY(e){return e?[kJ(e.track),e.domains.join(`, `)].filter(Boolean).join(` · `):``}function AY({row:e}){return e.progress?(0,V.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,V.jsx)(jJ,{done:e.progress.done,total:e.progress.total}),(0,V.jsxs)(`span`,{children:[e.progress.done,` of `,e.progress.total,` steps`]})]}):null}function jY({row:e,task:t}){let n=t?.git?`branch ${t.git.branch}${t.git.from?` · from ${t.git.from}`:``}`:``,{state:r,rest:i}=OY(e);return(0,V.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,V.jsxs)(`h2`,{className:`flex items-start gap-2.5 text-lg font-semibold tracking-tight`,children:[(0,V.jsx)(MJ,{check:e.check,className:`mt-1.5`}),(0,V.jsxs)(`span`,{className:`sr-only`,children:[zJ[e.check],`:`]}),(0,V.jsx)(`span`,{className:e.check===`dropped`?`min-w-0 break-words line-through`:`min-w-0 break-words`,children:e.title})]}),(0,V.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,V.jsx)(`span`,{className:`rounded-md bg-accent px-2 py-0.5 text-xs font-medium text-foreground`,children:r}),i?(0,V.jsx)(`span`,{children:i}):null]}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:[e.id,kY(t),n].filter(Boolean).join(` · `)}),(0,V.jsx)(AY,{row:e})]})}function MY({row:e,onGone:t,onChanged:n}){let r=e.id;return{restore:async()=>{await U(`tasks.restore`,{taskId:r},{undo:()=>void U(`tasks.archive`,{taskId:r})})&&t()},archive:async()=>{await U(`tasks.archive`,{taskId:r},{undo:()=>void U(`tasks.restore`,{taskId:r})})&&t()},remove:async()=>{await U(`tasks.delete`,{taskId:r,where:e.kind===`archived`?`archive`:`list`})&&t()},toggleAuto:()=>void U(`tasks.auto`,{taskId:r,on:!e.auto}).then(n)}}function NY({row:e,archive:t}){return e.check===`open`?(0,V.jsx)(Rk,{label:`Archive`,icon:Pp,shortcut:`E`,title:`Archive "${e.title}"?`,description:`A task still under way is abandoned first, then moved to the archive. Restore brings it back.`,confirmLabel:`Archive`,onConfirm:()=>void t()}):(0,V.jsx)(nk,{label:`Archive`,icon:Pp,shortcut:`E`,onClick:()=>void t()})}function PY({on:e,toggle:t}){return ek(`a`,t),(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.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,V.jsx)(fg,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,V.jsx)(`span`,{children:`Auto`}),(0,V.jsx)(iW,{checked:e,onCheckedChange:t,"aria-label":`Auto mode`,"aria-keyshortcuts":`A`}),(0,V.jsx)(KD,{chord:`A`,className:`kbd-hint`})]})}),(0,V.jsx)(IO,{children:`Auto mode: the oracle decides without asking`})]})}function FY(e){let{row:t}=e,{restore:n,archive:r,remove:i,toggleAuto:a}=MY(e),o=t.kind===`archived`,s=t.kind===`task`&&t.check===`open`&&!!t.resumable;return(0,V.jsxs)(rk,{children:[t.kind===`task`&&t.check===`open`?(0,V.jsx)(mY,{row:t,quiet:s}):null,o?(0,V.jsx)(nk,{label:`Restore`,icon:gg,shortcut:`R`,onClick:()=>void n()}):null,t.check===`open`&&!o?(0,V.jsx)(PY,{on:!!t.auto,toggle:a}):null,o?null:(0,V.jsx)(NY,{row:t,archive:r}),(0,V.jsx)(Rk,{icon:Wg,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 IY(e){let{row:t}=e,n=t.kind===`plan`,r=MO(`tasks.get`,{taskId:t.id},[`tasks`],!n),i=AO(`lobby`).data?.task,a=i?.id===t.id?i:void 0;if(n)return(0,V.jsx)(_Y,{row:t,onGone:e.onGone});let o=t.check===`open`&&t.kind===`task`,s=r.data?r.data.work:t.work;return(0,V.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-5`,"aria-label":t.title,children:[(0,V.jsx)(FY,{...e}),(0,V.jsx)(jY,{row:t,task:a}),r.data?(0,V.jsx)(DY,{row:t,detail:r.data,onChanged:()=>{r.reload(),e.onChanged()}}):null,(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,V.jsx)(pJ,{timing:r.data?.timing??t.timing,...s?{work:s}:{},stopped:t.check!==`open`})}),r.data?.delivery?(0,V.jsx)(DJ,{taskId:t.id,title:t.title,delivery:r.data.delivery,onChanged:r.reload},t.id):null,r.data?(0,V.jsx)(fY,{detail:r.data,finished:!o,...o&&r.data.canSkip?{skip:{taskId:t.id,onSkipped:()=>{r.reload(),e.onChanged()}}}:{}}):null,(0,V.jsx)(LJ,{taskId:t.id,finished:!o,canComment:o}),r.data?(0,V.jsx)(pY,{detail:r.data}):null,r.error&&!r.data?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the plan detail. `,r.error]}):null]})}function LY({row:e}){return e.check===`open`&&e.progress?(0,V.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground tabular-nums`,children:[(0,V.jsx)(jJ,{done:e.progress.done,total:e.progress.total}),(0,V.jsxs)(`span`,{children:[e.progress.done,`/`,e.progress.total]})]}):e.age&&e.check!==`open`?(0,V.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.age}):null}function RY(e){return e.check===`dropped`?`text-muted-foreground line-through`:e.kind===`archived`||e.check===`done`?`text-muted-foreground`:`text-foreground`}function zY({row:e}){return(0,V.jsxs)(V.Fragment,{children:[e.check===`open`?(0,V.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:GJ(e)}):null,e.kind===`plan`?null:(0,V.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:(0,V.jsx)(pJ,{timing:e.timing,...e.work?{work:e.work}:{},stopped:e.check!==`open`})}),e.delivery?(0,V.jsxs)(`span`,{className:`pl-6 text-xs text-foreground`,children:[`Delivery: `,e.delivery.status.replaceAll(`_`,` `),` · open task to review`]}):null]})}function BY({row:e,selected:t,onSelect:n}){return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(e.id),className:qB,children:[(0,V.jsxs)(`span`,{className:`flex items-start gap-2 text-sm`,children:[(0,V.jsx)(MJ,{check:e.check,className:`mt-0.5`}),(0,V.jsxs)(`span`,{className:`sr-only`,children:[zJ[e.check],`:`]}),(0,V.jsx)(`span`,{className:J(`min-w-0 flex-1 break-words`,RY(e),t&&`font-medium text-foreground`),children:e.title}),(0,V.jsx)(LY,{row:e})]}),(0,V.jsx)(zY,{row:e})]})})}function VY({rows:e,selectedId:t,onSelect:n}){return(0,V.jsx)(`div`,{className:`flex flex-col pb-2`,children:KJ(e).map(({section:e,rows:r})=>(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:YB,children:(0,V.jsx)(sB,{title:RJ[e],right:String(r.length),className:`[&>span:first-child]:font-medium [&>span:first-child]:text-muted-foreground`})}),(0,V.jsx)(`ul`,{className:JB,children:r.map(e=>(0,V.jsx)(BY,{row:e,selected:e.id===t,onSelect:n},`${e.kind}-${e.id}`))})]},e))})}var HY=()=>fO(dO(`tasks`)),UY=e=>fO(dO(`tasks`,e));function WY(){return(0,V.jsxs)(mO,{className:`m-4 flex-1`,children:[(0,V.jsxs)(hO,{children:[(0,V.jsx)(_O,{variant:`icon`,children:(0,V.jsx)(gh,{"aria-hidden":`true`})}),(0,V.jsx)(yO,{children:HJ})]}),(0,V.jsx)(Y,{onClick:()=>fO(dO(`plan`)),children:`Plan a task`})]})}function GY({shown:e,count:t,onToggle:n}){return(0,V.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,V.jsx)(BK,{checked:e,onCheckedChange:n,"aria-label":`Show archived tasks`,className:`size-4`}),`Archived`,(0,V.jsx)(KB,{variant:`secondary`,className:`h-5 px-1.5`,children:t})]})}function KY({id:e}){let t=gk(),[n,r]=(0,m.useState)(!1),i=MO(`tasks.list`,{},[`tasks`,`plans`]),a=MO(`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)(()=>(aJ(u),()=>aJ(void 0)),[u]),!i.data&&i.error)return(0,V.jsx)(EO,{message:`Could not load tasks. ${i.error}`,onRetry:i.reload});if(i.data&&o.length===0&&s.length===0)return(0,V.jsx)(WY,{});let d=[...c,...s].find(e=>e.id===l),f=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(xk,{title:`Tasks`,count:qJ(c),children:(0,V.jsx)(GY,{shown:n,count:s.length,onToggle:()=>r(e=>!e)})}),i.data?c.length===0?(0,V.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:HJ}):(0,V.jsx)(VY,{rows:c,selectedId:l,onSelect:UY}):(0,V.jsx)(Sk,{})]}),p=d?(0,V.jsx)(IY,{row:d,onGone:HY,onChanged:i.reload},d.id):e?(0,V.jsx)(qY,{}):null;return(0,V.jsx)(bk,{wide:t,list:f,detail:p,open:!!e,onClose:HY,hint:`Select a task to see its detail.`,describe:`Task detail`})}function qY(){return(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That task is not on the list any more.`})}var JY={l:`lobby`,p:`plan`,t:`tasks`,u:`git`,n:`knowledge`,q:`quickfix`,e:`settings`};function YY(e){let t=e[0];if(t)try{return decodeURIComponent(t)}catch{return t}}function XY(e){if(e.kind===`settings`)return(0,V.jsx)(fK,{});switch(e.tab){case`lobby`:return(0,V.jsx)(SU,{});case`tasks`:return(0,V.jsx)(KY,{...yU(e.rest)});case`plan`:return(0,V.jsx)(Pq,{rest:e.rest});case`quickfix`:return(0,V.jsx)(eJ,{id:YY(e.rest)});case`git`:return(0,V.jsx)(zV,{rest:e.rest});case`knowledge`:return(0,V.jsx)(vU,{rest:e.rest})}}function ZY(e,t){return t.overlay?!0:e===`savePlan`&&!t.saveAvailable}var QY={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 $Y(e){return e.length===1&&/[a-z]/i.test(e)?`Key${e.toUpperCase()}`:e.length===1&&/[0-9]/.test(e)?`Digit${e}`:QY[e]}function eX(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=$Y(n);if(!e)return;t.code=e}return t.code?t:void 0}function tX(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.shiftKey===t.shift&&e.metaKey===t.meta}function nX(e,t){let n=eX(t);return n?tX(e,n):!1}function rX(e,t){for(let n of t)if(nX(e,n.key))return n.action}function iX(e,t){for(let n of t)if(nX(e,n.key))return n.id}function aX(e){return zO(e.target)||e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||rO()||!!document.querySelector(`[role='dialog'], [role='menu'], [role='listbox']`)}function oX(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`)GO(e.key===`j`?1:-1);else return!1;return!0}function sX(e,t){let n=iX(e,t.tabs),r=rX(e,t.keys);return!n&&!r?!1:ZY(r,{overlay:!!document.querySelector(`[role='dialog']:not([data-state='closed']), [role='menu']:not([data-state='closed']), [role='listbox']`)||rO(),typing:zO(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 cX(e,t,n){if(e.key===`Escape`)return Date.now()<n&&e.preventDefault(),0;if(Date.now()<n){let n=JY[e.key];return n&&(e.preventDefault(),t.onTab(n)),0}return e.key===`g`?Date.now()+1500:(oX(e,t.tabs,t.onAction,t.onTab)&&e.preventDefault(),0)}function lX(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`)){rX(n,e.keys)===`terminal`&&(n.preventDefault(),e.onAction(`terminal`));return}if(!e.insideApp()){rX(n,e.keys)===`help`&&(n.preventDefault(),e.onAction(`help`));return}let r=!n.altKey&&!n.ctrlKey&&!n.metaKey;if(r&&aX(n)){t=0;return}if(sX(n,e)){t=0;return}t=r?cX(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 uX=[{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`}],dX=[{id:`digits`,caps:[`1`,`…`,`9`],help:`jump to a tab in current order`},{id:`help`,caps:[`?`],help:`keyboard shortcuts`},...Object.entries(JY).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`}],fX=[{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:`quickfix`,page:`Quick fix`,keys:[[`R`,`run anyway`],[`T`,`make a task`],[`C`,`cancel`]]},{id:`git`,page:`Git`,keys:[[`R`,`refresh both lists`],[`V`,`review`],[`Q`,`Jev's read`],[`X`,`stop`],[`N`,`plan an issue`]]},{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`]]}],pX=[{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`}],mX=[{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 hX({line:e}){return(0,V.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,V.jsx)(`span`,{className:`flex w-28 shrink-0 items-center`,children:e.caps?(0,V.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:e.caps.map(e=>(0,V.jsx)(BD,{children:e},e))}):(0,V.jsx)(KD,{chord:e.label??``})}),(0,V.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.help})]})}function gX(){return(0,V.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,V.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:`Buttons on a page`}),fX.map(e=>(0,V.jsxs)(`div`,{className:`flex items-start gap-3 py-1`,children:[(0,V.jsx)(`span`,{className:`w-28 shrink-0 pt-0.5 text-sm font-medium`,children:e.page}),(0,V.jsx)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5 text-sm text-muted-foreground`,children:e.keys.map(([e,t])=>(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,V.jsx)(KD,{chord:e}),t]},e))})]},e.id))]})}function _X({title:e,lines:t}){return(0,V.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,V.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:e}),t.map(e=>(0,V.jsx)(hX,{line:e},e.id))]})}function vX(e){return e.map(e=>({id:e.action,label:e.label,help:e.help}))}function yX(e){return e.map(e=>({id:`tab.${e.id}`,label:e.key,help:`jump to the ${e.label} tab`}))}function bX({open:e,onOpenChange:t,keys:n,tabs:r}){let i=e,a=nO(i,tO.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&&nX(e,r))&&(e.preventDefault(),t(!1))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n,t,a,i]),(0,V.jsxs)(JD,{open:i&&a,onOpenChange:t,label:`Keys`,className:`max-w-4xl`,children:[(0,V.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-border px-4 py-3`,children:[(0,V.jsx)(`h2`,{"aria-hidden":`true`,className:`text-base font-semibold tracking-tight`,children:`Keyboard shortcuts`}),(0,V.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(KD,{chord:`Esc`}),(0,V.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,onClick:()=>t(!1),children:(0,V.jsx)(o_,{"aria-hidden":`true`})})]})]}),(0,V.jsxs)(`div`,{ref:o,className:`grid min-h-0 flex-1 grid-cols-2 gap-x-10 gap-y-6 overflow-y-auto p-4`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,V.jsx)(_X,{title:`Everywhere`,lines:vX(n)}),(0,V.jsx)(_X,{title:`Jump to a tab`,lines:yX(r)}),(0,V.jsx)(_X,{title:`Navigation and editing`,lines:dX}),(0,V.jsx)(_X,{title:`Message box`,lines:uX})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,V.jsx)(_X,{title:`Lists and panes`,lines:pX}),(0,V.jsx)(gX,{}),(0,V.jsx)(_X,{title:`Questions`,lines:mX})]})]}),(0,V.jsx)(Vv,{target:o})]})}var xX=`size-[1.05rem]`;function SX({hint:e,onHelp:t,className:n,side:r=`top`}){return(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Keyboard shortcuts`,"aria-haspopup":`dialog`,"aria-keyshortcuts":e,"aria-describedby":`focused-action-help`,onClick:t,className:n,children:(0,V.jsx)(fh,{"aria-hidden":`true`,className:xX})})}),(0,V.jsxs)(IO,{side:r,children:[`Keyboard shortcuts `,(0,V.jsx)(KD,{chord:e})]})]})}function CX({className:e,side:t=`top`}){let n=PU(),r=n?`Unmute prompt sounds`:`Mute prompt sounds`;return(0,V.jsx)(V.Fragment,{children:(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":r,"aria-pressed":n,"aria-describedby":`focused-action-help`,className:e,onClick:()=>MU(!n),children:n?(0,V.jsx)(e_,{"aria-hidden":`true`,className:xX}):(0,V.jsx)(Qg,{"aria-hidden":`true`,className:xX})})}),(0,V.jsx)(IO,{side:t,children:r})]})})}function wX({className:e,side:t=`top`}){let{theme:n,setTheme:r}=UW(),i=n===`dark`||n===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;return(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":i?`Switch to light mode`:`Switch to dark mode`,"aria-keyshortcuts":`D`,"aria-describedby":`focused-action-help`,onClick:()=>r(i?`light`:`dark`),className:e,children:i?(0,V.jsx)(Rg,{"aria-hidden":`true`,className:xX}):(0,V.jsx)(Wh,{"aria-hidden":`true`,className:xX})})}),(0,V.jsxs)(IO,{side:t,children:[i?`Light mode`:`Dark mode`,` `,(0,V.jsx)(KD,{chord:`D`})]})]})}var TX=[{id:`light`,label:`Light`},{id:`dark`,label:`Dark`},{id:`system`,label:`System`}];function EX({className:e,side:t=`top`}){let{theme:n,setTheme:r}=UW();return(0,V.jsxs)(SW,{children:[(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.jsx)(CW,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Appearance`,className:e,children:(0,V.jsx)(Kh,{"aria-hidden":`true`,className:xX})})})}),(0,V.jsx)(IO,{side:t,children:`Appearance`})]}),(0,V.jsxs)(wW,{side:t===`right`?`right`:`top`,align:t===`right`?`start`:`center`,sideOffset:10,collisionPadding:12,"aria-label":`Appearance`,onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.focus({preventScroll:!0})},tabIndex:-1,className:`glass-pop flex max-h-[85svh] w-[26rem] max-w-[calc(100vw-1.5rem)] flex-col gap-3 overflow-y-auto rounded-2xl p-3`,children:[(0,V.jsx)(ak,{label:`Mode`,items:TX,value:n,onChange:e=>r(e),className:`w-full [&>button]:flex-1`}),(0,V.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,V.jsx)(`p`,{className:`px-0.5 text-xs font-medium text-muted-foreground`,children:`Colour theme`}),(0,V.jsx)(`div`,{className:`[&_[role=radiogroup]]:!grid-cols-3 [&_[role=radiogroup]]:gap-1.5`,children:(0,V.jsx)(EG,{})})]}),(0,V.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,V.jsx)(`p`,{className:`px-0.5 text-xs font-medium text-muted-foreground`,children:`Typeface`}),(0,V.jsx)(WW,{kind:`font`,dense:!0})]}),(0,V.jsx)(`a`,{href:`#/settings`,className:`px-0.5 text-xs text-link underline-offset-2 hover:underline`,children:`More in Settings`})]})]})}function DX({className:e,side:t=`top`}){let n=WU(),r=n?`Turn off desktop notifications`:`Turn on desktop notifications`,i=async()=>{if(n)return KU();let e=await GU();e===`granted`?mp.success(`Desktop notifications are on.`):mp.error(e===`unsupported`?`This browser cannot show notifications.`:`Notifications are blocked for this page in the browser's settings.`)};return(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":r,"aria-pressed":n,className:e,onClick:()=>void i(),children:n?(0,V.jsx)(Kp,{"aria-hidden":`true`,className:xX}):(0,V.jsx)(Wp,{"aria-hidden":`true`,className:xX})})}),(0,V.jsx)(IO,{side:t,children:r})]})}function OX({className:e,side:t=`top`}){let n=x();if(!n.supported)return null;let r=n.on?`Leave full screen`:`Full screen`;return(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":r,"aria-pressed":n.on,className:e,onClick:()=>void n.toggle(),children:n.on?(0,V.jsx)(Bh,{"aria-hidden":`true`,className:xX}):(0,V.jsx)(Oh,{"aria-hidden":`true`,className:xX})})}),(0,V.jsx)(IO,{side:t,children:r})]})}function kX(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}async function AX(e){if(e.size===0)throw Error(`${e.name||`That file`} is empty.`);if(e.size>20971520)throw Error(`${e.name||`That file`} is larger than 20 MB.`);let t=new URLSearchParams({name:e.name||`pasted-file`,type:e.type}),n=await fetch(F(`/api/files.upload?${t}`),{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:e,credentials:`same-origin`}),r=await n.json().catch(()=>void 0);if(!r)throw new xe(`the lobby answered ${n.status}`,`failed`,n.status);if(!r.ok)throw new xe(r.error,r.code,n.status);return r.result}function jX(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 MX(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 NX=/^(\s*)(?:([-*+])|(\d+)([.)]))\s+(\[[ xX]\]\s+)?/;function PX(e,t){let n=e.lastIndexOf(`
104
104
  `,t-1)+1,r=e.indexOf(`
105
- `,t),i=e.slice(n,r<0?e.length:r),a=NX.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 FX({rest:e}){let{chat:t}=RH(e);return(0,V.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,V.jsx)(`button`,{type:`button`,"aria-pressed":t===(n===`Chat`),onClick:()=>fO(zH(e,n===`Chat`)),className:J(`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 IX(e,t){return J(`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 LX({className:e,size:t=`sm`,asChild:n=!1,...r}){let i=n?$v:`button`;return(0,V.jsx)(i,{type:n?void 0:`button`,className:IX(t,e),...r})}function RX(e){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)();async function a(r){if(!t){n(!0),i(void 0);try{let{project:t}=await L(`projects.open`,{path:r});ve([t]),I(t.id,e)}catch(e){i(e.message)}finally{n(!1)}}}return{opening:t,error:r,open:a}}function zX({path:e,parent:t,busy:n,browse:r}){let[i,a]=(0,m.useState)(e);return(0,m.useEffect)(()=>a(e),[e]),(0,V.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,V.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,V.jsx)(Hp,{"aria-hidden":`true`,className:`size-4`})}),(0,V.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,V.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 BX(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 VX({data:e,loading:t,busy:n,browse:r}){let i=e?.folders.length??0;return(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-md border border-border`,children:[(0,V.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,V.jsx)(`span`,{children:`Name`}),(0,V.jsx)(`span`,{className:`normal-case tracking-normal`,children:t?`Loading…`:`${i.toLocaleString()} ${i===1?`folder`:`folders`}${e?.truncated?` (first 2,000)`:``}`})]}),(0,V.jsxs)(`div`,{"aria-label":`Folders`,role:`group`,onKeyDown:t=>BX(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,V.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,V.jsx)(nh,{"aria-hidden":`true`,className:J(`size-4 shrink-0`,t?`text-muted-foreground/60`:`text-muted-foreground`)}),(0,V.jsx)(`span`,{className:J(`min-w-0 flex-1 truncate`,t&&`text-muted-foreground`),children:e.name}),(0,V.jsx)(cm,{"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,V.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,V.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 HX({tab:e,close:t,busyChanged:n}){let[r,i]=(0,m.useState)(),a=MO(`projects.browse`,r===void 0?{}:{path:r},[]),o=RX(e);return(0,m.useEffect)(()=>n(o.opening),[o.opening,n]),(0,V.jsxs)(`div`,{className:`flex min-h-0 max-h-full w-full flex-col overflow-y-auto`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border px-4 py-3`,children:[(0,V.jsx)(`h2`,{className:`text-[0.9375rem] font-semibold`,children:`Open project folder`}),(0,V.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,V.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3 p-4`,children:[(0,V.jsx)(zX,{path:a.data?.path??r??``,parent:a.data?.parent,busy:o.opening,browse:i}),(0,V.jsx)(VX,{data:a.data,loading:a.loading,busy:a.loading||o.opening,browse:i}),a.loading?(0,V.jsx)(`p`,{role:`status`,className:`sr-only`,children:`Loading folders…`}):null,a.error||o.error?(0,V.jsx)(`p`,{role:`alert`,className:`break-words text-xs text-destructive`,children:a.error??o.error}):null]}),(0,V.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,V.jsx)(Y,{variant:`outline`,onClick:a.reload,disabled:a.loading,children:`Retry`}):null,(0,V.jsx)(Y,{variant:`outline`,onClick:t,disabled:o.opening,children:`Cancel`}),(0,V.jsx)(Y,{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 UX({open:e,onClose:t,tab:n}){let r=nO(e,tO.help),[i,a]=(0,m.useState)(!1);return(0,V.jsx)(JD,{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,V.jsx)(HX,{tab:n,close:t,busyChanged:a}):null})}function WX(){try{return{id:pe()}}catch(e){return{error:e.message}}}function GX(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 KX(){let[e,t]=(0,m.useState)(),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(0);async function s(){let e=++o.current;a(!0),r(void 0);try{let n=await L(`projects.list`,{});ve(n.projects),e===o.current&&t(n)}catch(t){e===o.current&&r(t.message)}finally{e===o.current&&a(!1)}}(0,m.useEffect)(()=>(s(),()=>{o.current++}),[]);let[c,l]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{if(!i)return l(!1);let e=setTimeout(()=>l(!0),300);return()=>clearTimeout(e)},[i]),{data:e,error:n,busy:i,slow:c,refresh:s}}function qX({data:e,error:t}){let n=WX();return n.error??t??GX(e,n.id)}function JX({projects:e}){let t=qX(e);return t?(0,V.jsxs)(`p`,{role:`alert`,className:`notice flex min-w-0 items-start gap-2 pt-1 pb-0.5 text-xs break-words text-destructive`,children:[(0,V.jsx)(Kg,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,V.jsx)(`span`,{children:t})]}):null}function YX(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 XX=`bot-lobby:open-projects`;function ZX({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=WX(),p=qX(e),h=f.error?`invalid`:f.id??i?.currentId??``;ek(`p`,()=>l(!0)),(0,m.useEffect)(()=>{let e=()=>l(!0);return window.addEventListener(XX,e),()=>window.removeEventListener(XX,e)},[]),ek(`r`,()=>void s(),{enabled:c,inDialog:!0});function g(e){l(!1),e!==h&&I(e,t)}return(0,V.jsxs)(`div`,{"aria-busy":a,className:`flex min-w-0 items-center gap-1`,children:[(0,V.jsxs)(SW,{open:c,onOpenChange:l,children:[(0,V.jsxs)(CW,{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:J(`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`,IX(`xs`,`min-w-0 justify-start`)),children:[(0,V.jsx)(nh,{"aria-hidden":`true`,className:J(`size-3 shrink-0`,p&&`text-destructive`)}),(0,V.jsx)(`span`,{className:`truncate`,children:n}),(0,V.jsx)(im,{"aria-hidden":`true`,className:`size-3 shrink-0 opacity-50`})]}),(0,V.jsxs)(wW,{align:`start`,side:`top`,sideOffset:8,"aria-label":`Projects`,onKeyDown:YX,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,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,V.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Running projects`}),(0,V.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,V.jsx)(bO,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):(0,V.jsx)(fg,{"aria-hidden":`true`,className:`size-3`}),`Refresh`,(0,V.jsx)(KD,{chord:`R`,className:`kbd-hint`})]})]}),(0,V.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,V.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>g(e.id),className:J(`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,V.jsx)(`span`,{className:`flex h-5 w-4 shrink-0 items-center justify-center`,children:t?(0,V.jsx)(nm,{"aria-hidden":`true`,className:`size-3.5 text-primary`}):null}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`span`,{className:`block whitespace-normal break-words text-sm font-medium`,children:e.name}),(0,V.jsxs)(`span`,{className:`block whitespace-normal break-all text-xs text-muted-foreground`,children:[e.cwd,` · :`,e.port]})]})]},e.id)})}),(0,V.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,V.jsx)(eh,{"aria-hidden":`true`,className:`size-4`}),`Open folder…`]})]})]}),(0,V.jsx)(UX,{open:u,onClose:()=>d(!1),tab:t}),o||p?(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Refresh projects`,disabled:a,onClick:()=>void s(),className:J(`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`,IX(`xs`,`w-7 px-0 sm:w-[1.625rem]`)),children:a?(0,V.jsx)(bO,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,V.jsx)(fg,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,V.jsx)(IO,{side:`top`,children:`Refresh projects`})]}):null]})}function QX({contextStrip:e=!1,className:t,...n}){return(0,V.jsx)(`div`,{"data-slot":`composer-shell`,"data-with-context":e||void 0,className:J(`@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 $X=`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)`,eZ=`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 tZ({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`composer-host`,className:J(`relative z-10 w-full rounded-3xl shadow-composer after:z-1 dark:shadow-none`,$X,eZ,`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 nZ({className:e,...t}){return(0,V.jsx)(`div`,{"data-chat-composer-main-surface":`true`,className:J(`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)`,$X,eZ,`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 rZ({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`composer-context-strip`,className:J(`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 iZ={Shell:QX,Host:tZ,Main:nZ,ContextStrip:rZ},aZ=e=>e.preventDefault();function oZ({onStop:e}){let[t,n]=(0,m.useState)(!1),r=nO(t,tO.confirm),i=()=>{n(!1),e()};return ek(`y`,i,{enabled:t&&r,inDialog:!0}),(0,V.jsxs)(Ok,{open:t&&r,onOpenChange:n,children:[(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.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:aZ,onClick:()=>n(!0),"aria-label":`Stop`,"aria-haspopup":`dialog`,children:(0,V.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,V.jsx)(`rect`,{x:`2`,y:`2`,width:`8`,height:`8`,rx:`1.5`})})})}),(0,V.jsx)(IO,{side:`top`,children:`Interrupt`})]}),(0,V.jsxs)(jk,{children:[(0,V.jsxs)(Mk,{children:[(0,V.jsx)(Pk,{children:`Stop the oracle?`}),(0,V.jsx)(Fk,{children:`The current response stops. Work already recorded is kept.`})]}),(0,V.jsxs)(Nk,{children:[(0,V.jsxs)(Lk,{children:[`Keep it`,(0,V.jsx)(KD,{chord:`Esc`,className:`kbd-hint ml-1`})]}),(0,V.jsxs)(Ik,{variant:`destructive`,onClick:i,children:[`Stop`,(0,V.jsx)(KD,{chord:`Y`,className:`kbd-hint ml-1`})]})]})]})]})}function sZ({sending:e,disabled:t,steering:n,onSend:r}){let i=n?`Steer message`:`Send`;return(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.jsx)(`span`,{className:`inline-flex`,children:(0,V.jsx)(`button`,{type:`button`,className:J(`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:aZ,onClick:r,disabled:t,"aria-label":`Send`,"aria-keyshortcuts":`Enter`,children:e?(0,V.jsx)(bO,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,V.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":`true`,children:(0,V.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,V.jsxs)(IO,{side:`top`,children:[i,` `,(0,V.jsx)(KD,{chord:`Enter`})]})]})}var cZ={id:`oracle`,label:`Message the oracle`,placeholder:`Message the oracle…`},lZ=new Set([`lobby`,`tasks`,`plan`,`quickfix`,`knowledge`]);function uZ(e){return e.kind===`tab`&&lZ.has(e.tab)}function dZ(e,t){if(e.kind!==`tab`)return cZ;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…`};if(e.tab===`quickfix`)return{id:`quickfix`,label:`Describe a quick fix`,placeholder:`Describe a small change…`};let n=e.tab===`tasks`?yU(e.rest).id??t:void 0;return n?{id:`comment`,label:`Comment on ${n}`,placeholder:`Comment on ${n}'s plan…`,taskId:n}:cZ}var fZ=0;function pZ(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}var mZ={type:`spring`,stiffness:520,damping:32};function hZ({file:e,onRemove:t}){let n=(0,V.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,onClick:t,className:J(`flex shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,e.image?`absolute top-1 right-1 size-[1.625rem] rounded-full bg-background/85 text-foreground shadow-xs hover:bg-background`:`size-7`),children:(0,V.jsx)(o_,{"aria-hidden":`true`,className:`size-3.5`})});return e.image?(0,V.jsxs)($f.li,{layout:!0,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:mZ,title:`${e.name} · ${kX(e.size)}`,className:`relative size-16 shrink-0 overflow-hidden rounded-lg border border-border/80 bg-background`,children:[(0,V.jsx)(`img`,{src:F(e.image),alt:e.name,className:`size-full object-cover`}),e.state===`uploading`?(0,V.jsxs)(`span`,{className:`pointer-events-none absolute inset-x-0 bottom-0 flex items-center justify-center gap-1 bg-background/85 px-1 text-[0.625rem] text-foreground`,children:[(0,V.jsx)(bO,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}),`uploading`]}):null,n]}):(0,V.jsxs)($f.li,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:mZ,className:`flex min-w-0 basis-full items-center gap-2 text-sm text-foreground`,children:[(0,V.jsx)(Xm,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,V.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-muted-foreground`,children:[e.state===`uploading`?(0,V.jsx)(bO,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}):null,e.state===`uploading`?`uploading…`:kX(e.size)]}),n]})}function gZ(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 _Z({route:e,keys:t,projects:n,onHelp:r}){let[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)([]),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=AO(`status`),p=AO(`lobby`),h=iO(),g=(f.data?.busy??!1)||!!p.data?.reply?.trim(),_=uZ(e),v=(0,m.useRef)(_);v.current=_;let{taskId:y}=sJ(),b=(0,m.useMemo)(()=>dZ(e,y),[e,y]),x=(0,m.useRef)(null),{shrunk:S,expand:C}=gZ(x,_&&!h,e),w=(0,m.useRef)(null),T=(0,m.useRef)(null),E=(0,m.useRef)(o);E.current=o;let D=(0,m.useRef)(void 0);(0,m.useLayoutEffect)(()=>{let e=D.current,t=w.current;e&&t&&(D.current=void 0,t.setSelectionRange(e.start,e.end))},[i]);let O=(0,m.useCallback)(e=>{D.current={start:e.start,end:e.end},a(e.value)},[]);(0,m.useEffect)(()=>{let e=x.current;if(!e)return;let t=document.documentElement,n=()=>{let n=e.getBoundingClientRect();if(t.style.setProperty(`--composer-h`,h||!_?`0px`:`${Math.ceil(n.height)}px`),!_||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`)}},[h,_]);let k=(0,m.useCallback)(e=>{if(!v.current)return;let t=[...e],n=8-E.current.length;t.length>n&&mp.warning(`At most 8 files go with one message.`);for(let e of t.slice(0,Math.max(0,n))){let t=`f${++fZ}`,n=e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0;s(r=>[...r,{key:t,name:e.name||(n?`image.png`:`file`),size:e.size,...n?{image:n}:{},state:`uploading`}]),AX(e).then(e=>s(n=>n.map(n=>n.key===t?{...n,state:`ready`,info:e}:n))).catch(e=>{mp.error(e instanceof Error?e.message:`That file did not upload.`),s(e=>e.filter(e=>e.key!==t))})}},[]),ee=(0,m.useCallback)(e=>{s(t=>{let n=t.find(t=>t.key===e);return n?.image&&URL.revokeObjectURL(n.image),t.filter(t=>t.key!==e)})},[]),te=o.some(e=>e.state===`uploading`),A=o.flatMap(e=>e.info?[e.info.id]:[]),j=(i.trim().length>0||A.length>0)&&!te&&!c,M=(0,m.useCallback)(async()=>{if(!j||!v.current)return;l(!0);let e=A.length>0?A:void 0,t={text:i,...e?{attachments:e}:{}};try{let e=!0;if(b.id===`oracle`){let e=await L(`lobby.send`,t);e.notice&&mp(e.notice)}else if(b.id===`knowledge`){e=await U(`knowledge.ask`,t)!==void 0;let n=uO(window.location.hash);e&&n?.kind===`tab`&&n.tab===`knowledge`&&fO(zH(n.rest,!0))}else e=b.id===`panel`?await U(`planner.send`,t)!==void 0:b.id===`quickfix`?await U(`quickfix.submit`,t)!==void 0:await U(`tasks.comment`,{taskId:b.taskId,...t})!==void 0;if(e){a(``);for(let e of E.current)e.image&&URL.revokeObjectURL(e.image);s([])}}catch(e){mp.error(e instanceof Error?e.message:`Could not send`)}finally{l(!1)}},[j,A,b,i,e]),ne=(0,m.useCallback)(async()=>{try{await L(`lobby.abort`,{})}catch(e){mp.error(e instanceof Error?e.message:`Could not stop`)}},[]),N=e=>{if(e.key===`Escape`&&!e.nativeEvent.isComposing){e.preventDefault(),JO();return}let t=e.currentTarget,n=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&!e.altKey&&!e.shiftKey&&[`b`,`i`,`e`,`k`].includes(n)){e.preventDefault();let{selectionStart:r,selectionEnd:i,value:a}=t;O(n===`k`?MX(a,r,i):jX(a,r,i,n===`b`?`**`:n===`i`?`_`:"`"));return}if(e.key===`Enter`&&e.shiftKey&&!e.nativeEvent.isComposing&&t.selectionStart===t.selectionEnd){let n=PX(t.value,t.selectionStart);n&&(e.preventDefault(),O(n));return}if(e.key===`Backspace`&&t.value===``&&E.current.length>0){e.preventDefault(),ee(E.current.at(-1).key);return}(pZ(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey))&&(e.preventDefault(),M())},re=e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),k(t))},ie=e=>{e.preventDefault(),d(!1),e.dataTransfer.files.length>0&&k(e.dataTransfer.files)},ae=e.kind===`tab`&&e.tab===`knowledge`,oe=f.data?.workspace.name??`bot-lobby`,se=f.data?.branch??f.data?.workspace.branch,ce=(0,V.jsx)(`div`,{className:`min-h-0`,children:(0,V.jsx)(`div`,{className:`relative z-0`,children:(0,V.jsxs)(iZ.ContextStrip,{role:`group`,"aria-label":`Message context`,className:`composer-strip gap-1 text-xs font-normal text-muted-foreground/70`,children:[(0,V.jsx)(ZX,{projects:n,tab:e.kind===`tab`?e.tab:e.kind,name:oe,branch:se}),(0,V.jsxs)(`div`,{className:`@container ml-auto flex min-w-0 flex-1 items-center justify-end gap-3 overflow-hidden pe-1`,children:[e.kind===`tab`&&e.tab===`plan`?(0,V.jsx)(qD,{chord:t.savePlan??`Ctrl+S`,className:`hidden @[24rem]:inline-flex`,children:`save plan`}):null,(0,V.jsx)(qD,{chord:`Shift+Enter`,className:`hidden @[14rem]:inline-flex`,children:`new line`}),(0,V.jsxs)(LX,{size:`xs`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,"aria-label":`Keyboard shortcuts`,"aria-haspopup":`dialog`,"data-compact":!0,onClick:r,className:`kbd-hint`,children:[(0,V.jsx)(KD,{chord:t.help??`Alt+H`,className:`kbd-hint`}),(0,V.jsx)(`span`,{className:`hidden @[8rem]:inline`,children:`shortcuts`})]})]})]})})});return(0,V.jsx)(`div`,{id:`app-dock`,ref:x,"data-shrunk":S||void 0,onFocus:C,className:J(`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`,h&&`opacity-0`),hidden:!_,"aria-hidden":!_||void 0,inert:h||!_,children:(0,V.jsxs)(iZ.Shell,{contextStrip:!0,className:`composer-shell pointer-events-auto`,children:[(0,V.jsx)(iZ.Host,{onPointerDown:C,children:(0,V.jsx)(`div`,{className:`relative z-10`,children:(0,V.jsxs)(iZ.Main,{className:`group/composer composer-box`,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),d(!0))},onDragLeave:()=>d(!1),onDrop:ie,children:[(0,V.jsxs)(`div`,{"data-chat-composer-surface":`true`,className:J(`rounded-3xl transition-[background-color] duration-200`,u&&`bg-accent/45 ring-1 ring-inset ring-primary/70`),children:[(0,V.jsxs)(`div`,{"data-chat-composer-body":`true`,className:J(`composer-text relative px-3 pb-2 sm:px-4`,`pt-3.5 sm:pt-4`),children:[(0,V.jsx)(Fu,{initial:!1,children:o.length>0?(0,V.jsx)($f.ul,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{type:`spring`,stiffness:420,damping:36},"aria-label":`Attachments`,className:`composer-files mb-3 flex max-w-full flex-wrap gap-2 overflow-hidden`,children:o.map(e=>(0,V.jsx)(hZ,{file:e,onRemove:()=>ee(e.key)},e.key))},`files`):null}),(0,V.jsx)(`div`,{className:`relative flow-root font-sans text-sm max-sm:pointer-coarse:text-base`,children:(0,V.jsx)(`textarea`,{ref:w,id:`composer-text`,"aria-label":b.label,value:i,onChange:e=>a(e.target.value),onKeyDown:N,onPaste:re,placeholder:g&&b.id===`oracle`?`The oracle is working. Enter steers it…`:b.placeholder,rows:1,className:J(`-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,V.jsxs)(`div`,{"data-chat-composer-footer":`true`,className:J(`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,V.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:ae?(0,V.jsx)(FX,{rest:e.kind===`tab`?e.rest:[]}):null}),(0,V.jsxs)(`div`,{"data-chat-composer-actions":`right`,className:`flex shrink-0 flex-nowrap items-center justify-end gap-2`,children:[(0,V.jsx)(`input`,{ref:T,type:`file`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach files`,onChange:e=>{k(e.target.files??[]),e.target.value=``}}),(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Attach images, PDFs or files`,"data-compact":!0,onPointerDown:e=>e.preventDefault(),onClick:()=>T.current?.click(),className:`pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11`,children:(0,V.jsx)(eg,{"aria-hidden":`true`})})}),(0,V.jsx)(IO,{side:`top`,children:`Attach files`})]}),g&&b.id===`oracle`?(0,V.jsx)(oZ,{onStop:()=>void ne()}):null,(0,V.jsx)(sZ,{sending:c,disabled:!j,steering:g&&b.id===`oracle`,onSend:()=>void M()})]})]})]}),u?(0,V.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-30 flex items-center justify-center rounded-[inherit] text-sm font-medium text-primary`,children:`Drop to attach`}):null]})})}),ce]})})}function vZ({state:e}){return e===`live`?(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.jsx)(`span`,{role:`img`,"aria-label":`Connected`,className:`grid size-6 place-items-center`,children:(0,V.jsx)(`span`,{className:`size-2 rounded-full bg-success`})})}),(0,V.jsx)(IO,{children:`Connected`})]}):e===`connecting`?(0,V.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 rounded-full bg-warning motion-safe:animate-status-pulse`}),`reconnecting…`]}):(0,V.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:`Connection lost`})}function yZ(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 bZ=24;function xZ(){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=yZ(t.querySelector(`.where`))+(r?.offsetWidth??0)+yZ(t.querySelector(`.tools`))+a*2;n(s+bZ<=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 SZ({connection:e,projects:t,lead:n,tabs:r,extra:i,tools:a}){let{header:o,one:s}=xZ();return(0,V.jsxs)(`header`,{ref:o,className:`app-header shrink-0`,"data-one-row":s||void 0,children:[(0,V.jsx)(`div`,{className:`where flex min-w-0 items-center gap-2`,children:n}),(0,V.jsx)(`div`,{className:`tabs min-w-0`,children:r}),(0,V.jsxs)(`div`,{className:`tools flex min-w-0 items-center justify-end gap-2`,children:[i,(0,V.jsx)(vZ,{state:e}),a,(0,V.jsx)(`span`,{id:`focused-action-help`,className:`sr-only`,children:`Focused buttons: Enter or Space. Links: Enter. Checkboxes: Space.`})]}),(0,V.jsx)(JX,{projects:t})]})}function CZ({open:e,onOpenChange:t}){let n=nO(e,tO.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{mp((await L(`sessions.start`,{request:e})).notice),t(!1),i(``)}catch(e){c(e instanceof Error?e.message:`That did not work. Try again.`)}finally{o(!1)}}};return(0,V.jsx)(JD,{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,V.jsxs)(`div`,{className:`flex w-[min(32rem,calc(100vw-2rem))] flex-col`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border px-4 py-3`,children:[(0,V.jsx)(`h2`,{className:`text-[0.9375rem] font-semibold`,children:`New session`}),(0,V.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,V.jsxs)(`div`,{className:`flex flex-col gap-1.5 p-4`,children:[(0,V.jsx)(`label`,{htmlFor:l,className:`text-sm font-medium`,children:`What should it do?`}),(0,V.jsx)(Ck,{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,V.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:s}):null]}),(0,V.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,V.jsx)(Y,{variant:`outline`,onClick:u,disabled:a,children:`Cancel`}),(0,V.jsx)(Y,{onClick:()=>void d(),disabled:!r.trim()||a,"aria-busy":a,children:a?`Starting…`:`Start session`})]})]})})}function wZ(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 TZ(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:wZ(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 EZ=`app.sidebar`,DZ={start:16,min:13,max:24},OZ=`bot-lobby.sidebar.width`,kZ=`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`,AZ=`session-card flex w-full min-w-0 flex-col rounded-md px-2.5 py-2 text-left outline-none transition-[background-color,scale] duration-150 hover:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:scale-[0.98] aria-[current=true]:bg-[var(--sidebar-selected)] aria-[current=true]:shadow-control motion-reduce:active:scale-100`;function jZ({label:e,hint:t,side:n=`bottom`,children:r}){return(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:r}),(0,V.jsxs)(IO,{side:n,children:[e,` `,t?(0,V.jsx)(KD,{chord:t}):null]})]})}function MZ(){let e=AO(`status`).data;return{entries:TZ(e,MO(`sessions.list`,{},[`sessions`]).data),branch:e?.branch??e?.workspace.branch}}function NZ(){return(0,m.useCallback)(async e=>{if(e.where===`here`)return fO(`#/lobby`);if(e.where===`elsewhere`)return void mp.info(`${e.name} runs in another terminal. Switch to that terminal to work in it.`);await U(`sessions.switch`,e.key?{key:e.key}:{sessionId:e.sessionId})&&fO(`#/lobby`)},[])}function PZ({entry:e}){return(0,V.jsx)(`span`,{"aria-hidden":`true`,"data-state":e.where===`elsewhere`?`elsewhere`:e.state,className:`session-dot relative`})}function FZ({entry:e}){return e.where===`elsewhere`?null:e.state===`asking`?(0,V.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-warning`,children:[(0,V.jsx)(Ah,{"aria-hidden":`true`,className:`size-3.5`}),e.waiting===1?`1 question`:`${e.waiting} questions`]}):e.state===`working`||e.state===`starting`?(0,V.jsxs)(`span`,{className:J(`inline-flex shrink-0 items-center gap-1`,e.state===`working`?`text-primary`:`text-muted-foreground`),children:[(0,V.jsx)(gm,{"aria-hidden":`true`,className:`session-spin size-3.5`}),e.state===`working`?`Working`:`Starting`]}):e.state===`exited`?(0,V.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-muted-foreground`,children:[(0,V.jsx)(mm,{"aria-hidden":`true`,className:`size-3.5`}),`Ended`]}):(0,V.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Idle`})}var IZ={here:`This window`,background:`Background`,elsewhere:`Other terminal`};function LZ(e){let t=e.key;return U(`sessions.archive`,{key:t},{undo:()=>void U(`sessions.archive`,{key:t,archived:!1})})}function RZ({entry:e,onDone:t}){let[n,r]=(0,m.useState)(e.name),i=(0,m.useRef)(!1),a=async()=>{if(i.current)return;i.current=!0;let r=n.replace(/\s+/g,` `).trim();r&&r!==e.name&&await U(`sessions.rename`,{...e.where===`here`?{}:{key:e.key},name:r}),t()};return(0,V.jsx)(`input`,{value:n,autoFocus:!0,maxLength:120,"aria-label":`New name for ${e.name}`,onFocus:e=>e.currentTarget.select(),onChange:e=>r(e.target.value),onBlur:()=>void a(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),a()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i.current=!0,t())},className:`-mx-1 mt-1 h-5 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 zZ=`inline-flex size-7 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 BZ({entry:e,branch:t}){let n=NZ(),[r,i]=(0,m.useState)(!1),a=e.where===`here`?t?`on ${t}`:`Where you are now`:e.where===`elsewhere`?`Switch in that terminal`:e.state===`exited`?`Its task keeps its state`:`Click to bring it here`,o=J(`mt-1 truncate text-sm`,e.where===`here`?`font-medium text-sidebar-foreground`:e.state===`exited`||e.where===`elsewhere`?`text-muted-foreground`:`text-sidebar-foreground`),s=(0,V.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,V.jsx)(PZ,{entry:e}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.where===`here`?null:IZ[e.where]}),(0,V.jsx)(FZ,{entry:e})]}),c=e.where!==`elsewhere`,l=e.where===`background`&&e.state===`exited`&&!!e.key;return(0,V.jsxs)(`li`,{className:`session-enter session-item relative py-0.5`,children:[r?(0,V.jsxs)(`div`,{"aria-current":e.where===`here`?`true`:void 0,className:J(AZ,`hover:bg-transparent active:scale-100`),children:[s,(0,V.jsx)(RZ,{entry:e,onDone:()=>i(!1)}),(0,V.jsx)(`span`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:a})]}):(0,V.jsxs)(`button`,{type:`button`,"aria-current":e.where===`here`?`true`:void 0,"aria-label":e.where===`here`?`${e.name}, this window`:e.where===`elsewhere`?`${e.name}, in another terminal`:`Switch to ${e.name}`,"data-where":e.where,"data-state":e.state,onClick:()=>void n(e),onDoubleClick:e=>{c&&(e.preventDefault(),i(!0))},className:AZ,children:[s,(0,V.jsx)(`span`,{className:o,children:e.name}),(0,V.jsx)(`span`,{className:J(`mt-0.5 truncate text-xs text-muted-foreground`,(c||l)&&`pr-14`),children:a})]}),!r&&(c||l)?(0,V.jsxs)(`span`,{className:`session-actions absolute right-1 bottom-1 flex items-center gap-0.5`,children:[c?(0,V.jsx)(jZ,{label:`Rename`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Rename ${e.name}`,onClick:()=>i(!0),className:zZ,children:(0,V.jsx)(og,{"aria-hidden":`true`,className:`size-3.5`})})}):null,l?(0,V.jsx)(jZ,{label:`Archive`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Archive ${e.name}`,onClick:()=>void LZ(e),className:zZ,children:(0,V.jsx)(Pp,{"aria-hidden":`true`,className:`size-3.5`})})}):null]}):null]})}function VZ({id:e,label:t,entries:n,branch:r,archivable:i=!1}){let[a,o]=mH(`app.sidebar.${e}`),s=(0,m.useId)();return n.length===0?null:(0,V.jsxs)(`section`,{"aria-label":t,className:`flex flex-col`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":!a,"aria-controls":s,onClick:o,className:`flex h-8 min-w-0 flex-1 items-center gap-2 rounded-md px-2 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,V.jsx)(`span`,{children:t}),a?(0,V.jsx)(`span`,{className:`tabular-nums`,children:n.length}):null,(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`h-px flex-1 bg-[var(--sidebar-border)]`}),(0,V.jsx)(im,{"aria-hidden":`true`,className:J(`size-3.5 transition-transform duration-200 motion-reduce:transition-none`,a&&`-rotate-90`)})]}),i?(0,V.jsx)(`button`,{type:`button`,onClick:()=>void(async()=>{for(let e of n)e.key&&await U(`sessions.archive`,{key:e.key})})(),className:`h-7 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]}),a?null:(0,V.jsx)(`ul`,{id:s,className:`flex flex-col`,children:n.map(e=>(0,V.jsx)(BZ,{entry:e,branch:r},e.id))})]})}function HZ(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean),r=`${e.name} ${IZ[e.where]}`.toLowerCase();return n.every(e=>r.includes(e))}function UZ({query:e,onQuery:t,onNew:n}){return(0,V.jsxs)(`div`,{className:`flex items-center gap-1 px-1 pb-2`,children:[(0,V.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,V.jsx)(wg,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,V.jsx)(`input`,{type:`search`,value:e,"aria-label":`Search sessions`,placeholder:`Search`,onChange:e=>t(e.target.value),onKeyDown:n=>{n.key===`Escape`&&e&&(n.preventDefault(),n.stopPropagation(),t(``))},className:`min-w-0 flex-1 bg-transparent text-sidebar-foreground outline-none placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden`})]}),(0,V.jsx)(jZ,{label:`New session`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`New session`,"aria-haspopup":`dialog`,onClick:n,className:kZ,children:(0,V.jsx)(Pg,{"aria-hidden":`true`,className:`size-4`})})})]})}function WZ({query:e}){let{entries:t,branch:n}=MZ(),r=t.filter(t=>HZ(t,e)),i=r.filter(e=>e.where!==`elsewhere`&&e.state!==`exited`),a=r.filter(e=>e.where===`elsewhere`),o=r.filter(e=>e.where!==`elsewhere`&&e.state===`exited`),s=(0,m.useRef)(null);return(0,V.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,V.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:[r.length===0?(0,V.jsxs)(`p`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:[`No sessions match “`,e.trim(),`”.`]}):(0,V.jsx)(`ul`,{className:`flex flex-col`,children:i.map(e=>(0,V.jsx)(BZ,{entry:e,branch:n},e.id))}),!e.trim()&&t.length===1?(0,V.jsx)(`p`,{className:`px-2.5 pt-1 text-xs text-muted-foreground`,children:`No other sessions are running.`}):null,(0,V.jsxs)(`div`,{className:`mt-auto flex flex-col pt-2`,children:[(0,V.jsx)(VZ,{id:`elsewhere`,label:`Other terminals`,entries:a,branch:n}),(0,V.jsx)(VZ,{id:`ended`,label:`Ended`,entries:o,branch:n,archivable:!0})]})]}),(0,V.jsx)(Vv,{target:s})]})}function GZ({route:e,keys:t,onHelp:n}){let r=t.settings??`Alt+S`;return(0,V.jsxs)(`div`,{className:`sidebar-foot flex flex-col gap-1 border-t border-[var(--sidebar-border)] px-1 py-2`,children:[(0,V.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,V.jsx)(Eg,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,V.jsx)(`span`,{className:`flex-1`,children:`Settings`}),(0,V.jsx)(KD,{chord:r})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(SX,{hint:t.help??`Alt+H`,onHelp:n,className:kZ}),(0,V.jsx)(wX,{className:kZ}),(0,V.jsx)(CX,{className:kZ}),(0,V.jsx)(EX,{className:kZ}),(0,V.jsx)(DX,{className:kZ}),(0,V.jsx)(OX,{className:kZ})]})]})}function KZ(){try{let e=Number(localStorage.getItem(OZ));if(e>=DZ.min&&e<=DZ.max)return e}catch{}return DZ.start}function qZ(e){try{e===DZ.start?localStorage.removeItem(OZ):localStorage.setItem(OZ,String(e))}catch{}}var JZ=e=>Math.min(DZ.max,Math.max(DZ.min,Math.round(e*4)/4));function YZ({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,V.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-label":`Resize sidebar`,"aria-orientation":`vertical`,"aria-controls":`app-sidebar`,"aria-valuemin":DZ.min,"aria-valuemax":DZ.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(JZ(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(DZ.start)},onKeyDown:n=>{n.key===`ArrowLeft`||n.key===`ArrowRight`?(n.preventDefault(),t(JZ(e+(n.key===`ArrowRight`?1:-1)))):n.key===`Home`||n.key===`End`?(n.preventDefault(),t(n.key===`Home`?DZ.min:DZ.max)):n.key===`Enter`&&(n.preventDefault(),r())}})}function XZ(e){jO(aH);let[t,n]=mH(EZ),[r,i]=(0,m.useState)(KZ),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(``),[l,u]=(0,m.useState)(!1),d=(0,m.useCallback)(e=>{i(e),qZ(e)},[]);return(0,V.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,V.jsxs)(`div`,{className:`sidebar-panel flex min-h-0 flex-1 flex-col`,style:{width:`${r}rem`},children:[(0,V.jsxs)(`div`,{className:`flex min-h-12 items-center gap-2 pr-1 pl-3`,children:[(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-semibold tracking-tight text-sidebar-foreground`,children:`Bot Lobby`}),(0,V.jsx)(jZ,{label:`Collapse sidebar`,hint:e.keys.sidebar,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Collapse sidebar`,"aria-expanded":!0,"aria-controls":`app-sidebar`,"aria-keyshortcuts":e.keys.sidebar,onClick:n,className:kZ,children:(0,V.jsx)(Jh,{"aria-hidden":`true`,className:`size-4`})})})]}),(0,V.jsx)(UZ,{query:s,onQuery:c,onNew:()=>u(!0)}),(0,V.jsx)(WZ,{query:s}),(0,V.jsx)(GZ,{...e})]}),(0,V.jsx)(YZ,{width:r,onWidth:d,onResizing:o,onFold:n}),(0,V.jsx)(CZ,{open:l,onOpenChange:u})]})}function ZZ({hint:e}){jO(aH);let[t,n]=mH(EZ);return t?(0,V.jsx)(jZ,{label:`Expand sidebar`,hint:e,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Expand sidebar`,"aria-expanded":!1,"aria-controls":`app-sidebar`,"aria-keyshortcuts":e,onClick:n,className:J(kZ,`sidebar-open size-8 text-foreground`),children:(0,V.jsx)(Xh,{"aria-hidden":`true`,className:`size-4`})})}):null}var QZ=`bot-lobby.terminal.open`,$Z=`bot-lobby.terminal.height`,eQ={start:280,min:140},tQ=new Set,nQ,rQ;function iQ(e){try{return localStorage.getItem(e)}catch{return null}}function aQ(e,t){try{localStorage.setItem(e,t)}catch{}}function oQ(){for(let e of[...tQ])e()}function sQ(e){return tQ.add(e),()=>{tQ.delete(e)}}function cQ(){return nQ??=iQ(QZ)===`1`,nQ}function lQ(){if(rQ===void 0){let e=Number(iQ($Z));rQ=e>=eQ.min?e:eQ.start}return rQ}function uQ(e){nQ=e,aQ(QZ,e?`1`:`0`),oQ()}function dQ(){uQ(!cQ())}function fQ(e){rQ=Math.max(eQ.min,Math.round(e)),aQ($Z,String(rQ)),oQ()}function pQ(){return(0,m.useSyncExternalStore)(sQ,cQ,()=>!1)}function mQ(){return(0,m.useSyncExternalStore)(sQ,lQ,()=>eQ.start)}var hQ=`modulepreload`,gQ=function(e){return`/`+e},_Q={},vQ=function(e){return e.pathname.endsWith(`.css`)},yQ=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=gQ(t,n);let r=s(t);if(r.href in _Q)return;_Q[r.href]=!0;let i=vQ(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`:hQ,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)})},bQ=(0,m.lazy)(()=>yQ(()=>import(`./TerminalView-DhNPNk-y.js`),__vite__mapDeps([0,1]))),xQ=`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`;function SQ({label:e,hint:t,children:n}){return(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:n}),(0,V.jsxs)(IO,{side:`top`,children:[e,` `,t?(0,V.jsx)(KD,{chord:t}):null]})]})}function CQ({hint:e,className:t}){let n=pQ();return(0,V.jsx)(SQ,{label:n?`Hide terminal`:`Terminal`,hint:e,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Terminal`,"aria-pressed":n,"aria-controls":n?`terminal-drawer`:void 0,"aria-keyshortcuts":e,onClick:dQ,className:t,children:(0,V.jsx)(Ig,{"aria-hidden":`true`,className:`size-4`})})})}function wQ(e){let[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(``),a=(0,m.useCallback)(async()=>{try{n(await L(`terminal.list`,{})),i(``)}catch(e){i(e instanceof Error?e.message:`The terminals could not be read.`)}},[]);return(0,m.useEffect)(()=>{e&&a()},[e,a]),{list:t,error:r,reload:a}}function TQ({height:e,max:t}){let n=(0,m.useRef)(null);return(0,V.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-label":`Resize terminal`,"aria-orientation":`horizontal`,"aria-valuenow":e,"aria-valuemin":eQ.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&&fQ(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:()=>fQ(eQ.start),onKeyDown:n=>{(n.key===`ArrowUp`||n.key===`ArrowDown`)&&(n.preventDefault(),fQ(Math.min(t,e+(n.key===`ArrowUp`?24:-24))))}})}function EQ({toggleKey:e}){let t=pQ(),n=mQ(),{list:r,error:i,reload:a}=wQ(t),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(()=>Math.round(window.innerHeight*.7)),f=r?.terminals??[],p=f.find(e=>e.id===o)??f.at(-1);(0,m.useEffect)(()=>{let e=()=>d(Math.round(window.innerHeight*.7));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let h=(0,m.useCallback)(async()=>{l(!0);try{let e=await L(`terminal.open`,{cols:100,rows:24});s(e.id),await a()}catch(e){mp.error(e instanceof Error?e.message:`The terminal did not start.`)}finally{l(!1)}},[a]),g=(0,m.useCallback)(async e=>{try{await L(`terminal.close`,{id:e})}catch{}await a()},[a]),_=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!t){_.current=!1;return}!r||!r.available||r.terminals.length>0||_.current||c||(_.current=!0,h())},[t,r,c,h]);let v=t?Math.min(n,u):0;return(0,m.useEffect)(()=>{let e=document.documentElement;return v?e.style.setProperty(`--terminal-h`,`${v}px`):e.style.removeProperty(`--terminal-h`),()=>{e.style.removeProperty(`--terminal-h`)}},[v]),t?(0,V.jsxs)(`section`,{id:`terminal-drawer`,"aria-label":`Terminal`,className:`terminal-drawer relative flex shrink-0 border-t border-border`,style:{height:Math.min(n,u)},children:[(0,V.jsx)(TQ,{height:Math.min(n,u),max:u}),(0,V.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[r&&!r.available?(0,V.jsx)(`p`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:r.reason}):i?(0,V.jsx)(`p`,{role:`alert`,className:`flex h-full items-center justify-center px-6 text-center text-sm text-destructive`,children:i}):(0,V.jsxs)(m.Suspense,{fallback:(0,V.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`Loading the terminal…`}),children:[r&&f.length===0&&!c?(0,V.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`No terminal is running. Start one with New terminal.`}):null,f.map(t=>(0,V.jsx)(bQ,{id:t.id,active:t.id===p?.id,toggleKey:e,onExit:()=>void a()},t.id))]}),(0,V.jsx)(`div`,{className:`pointer-events-none absolute top-2 right-2 z-20`,children:(0,V.jsxs)(`div`,{className:`terminal-tools pointer-events-auto inline-flex items-center overflow-hidden rounded-md border border-border/80 bg-background shadow-xs`,children:[(0,V.jsx)(SQ,{label:`New terminal`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`New terminal`,disabled:c||r?.available===!1,onClick:()=>void h(),className:xQ,children:(0,V.jsx)(ug,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,V.jsx)(SQ,{label:`End this terminal`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`End this terminal`,disabled:!p,onClick:()=>p&&void g(p.id),className:xQ,children:(0,V.jsx)(Wg,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,V.jsx)(SQ,{label:`Hide terminal`,hint:e,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Hide terminal`,onClick:()=>uQ(!1),className:xQ,children:(0,V.jsx)(im,{"aria-hidden":`true`,className:`size-3.5`})})})]})})]}),f.length>1?(0,V.jsx)(`nav`,{"aria-label":`Terminals`,className:`flex w-36 shrink-0 flex-col gap-0.5 overflow-y-auto border-l border-border px-1 pt-10 pb-1`,children:f.map(e=>(0,V.jsxs)(`button`,{type:`button`,"aria-current":e.id===p?.id?`true`:void 0,onClick:()=>s(e.id),className:J(`flex h-6 min-w-0 items-center gap-1.5 rounded px-1.5 text-left text-xs text-muted-foreground outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-accent aria-[current=true]:text-foreground`,!e.alive&&`opacity-60`),children:[(0,V.jsx)(Ig,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.title}),e.alive?null:(0,V.jsx)(`span`,{className:`sr-only`,children:`, ended`})]},e.id))}):null]}):null}function DQ(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 OQ(){let[e,t]=(0,m.useState)(``),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1);async function o(e){a(!0),r(void 0),e&&(window.location.hash=`token=${encodeURIComponent(e)}`),await we()?window.location.reload():(r(e?`That link did not sign in. Copy the link from Pi and try again.`:`Paste the link from Pi below.`),a(!1))}function s(t){t.preventDefault(),o(DQ(e))}return(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-y-auto p-6`,children:(0,V.jsxs)(`form`,{onSubmit:s,className:`glass flex min-h-0 w-full max-w-md flex-col gap-4 rounded-xl p-6`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(uh,{className:`size-5`,"aria-hidden":`true`}),(0,V.jsx)(`h1`,{className:`text-base font-medium`,children:`Sign in to bot-lobby`})]}),(0,V.jsxs)(`p`,{className:`break-words text-sm text-muted-foreground`,children:[`Pi printed a link when it started (or run `,(0,V.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,V.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,V.jsx)(`span`,{className:`font-medium`,children:`Lobby link or token`}),(0,V.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,V.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:n}):null,(0,V.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,V.jsx)(Y,{type:`button`,variant:`ghost`,disabled:i,onClick:()=>void o(void 0),children:`Retry`}),(0,V.jsx)(Y,{type:`submit`,disabled:i||!e.trim(),children:`Sign in`})]})]})})}var kQ=.6;function AQ(e,t,n={}){return{initial:e?void 0:!1,animate:t,transition:{duration:kQ,...n}}}var jQ=(e,t)=>[0,Math.max(e,.001),Math.min(Math.max(t,e+.01),.999),1];function MQ(e,t=0,n=1){return AQ(e,{pathLength:[0,0,1,1],strokeOpacity:[0,0,1,1]},{pathLength:{duration:kQ,times:jQ(t,n),ease:`easeInOut`},strokeOpacity:{duration:kQ,times:jQ(t,t+.02)}})}function NQ(e,t){return AQ(e,{scale:[0,0,1.3,1]},{times:jQ(t,t+.18),ease:`easeOut`})}function PQ(e,t,n=1.3){return AQ(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 FQ=(e=.5,t=.5)=>({transformBox:`fill-box`,originX:e,originY:t});function IQ({play:e}){return(0,V.jsxs)($f.g,{style:FQ(.1,.9),...AQ(e,{rotate:[0,-12,8,-4,0],scale:[1,1.12,.96,1.02,1]},{ease:`easeInOut`}),children:[(0,V.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,V.jsx)($f.circle,{cx:t,cy:11,r:1.15,fill:`currentColor`,stroke:`none`,...AQ(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 LQ({play:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($f.path,{d:`M13 5h8`,...MQ(e,.15,.45)}),(0,V.jsx)($f.path,{d:`M13 12h8`,...MQ(e,.3,.6)}),(0,V.jsx)($f.path,{d:`M13 19h8`,...MQ(e,.45,.75)}),(0,V.jsx)($f.path,{d:`m3 17 2 2 4-4`,...MQ(e,.35,.7)}),(0,V.jsx)($f.path,{d:`m3 7 2 2 4-4`,...MQ(e,0,.35)})]})}function RQ({play:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($f.circle,{cx:6,cy:19,r:3,style:FQ(),...PQ(e,0)}),(0,V.jsx)($f.path,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,...MQ(e,.1,.7)}),(0,V.jsx)($f.circle,{cx:18,cy:5,r:3,style:FQ(),...NQ(e,.62)})]})}function zQ({play:e}){return(0,V.jsx)($f.g,{style:FQ(),...AQ(e,{rotate:[0,-14,10,-6,0],scale:[1,1.18,.94,1.04,1]},{duration:.5,ease:`easeInOut`}),children:(0,V.jsx)($f.path,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,fill:`currentColor`,...AQ(e,{fillOpacity:[0,.85,0]},{duration:.5,times:[0,.2,1]})})})}function BQ({play:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($f.circle,{cx:12,cy:12,r:10,style:FQ(),...AQ(e,{scale:[1,1,1.4],strokeOpacity:[0,.5,0]},{times:[0,.25,1],ease:`easeOut`})}),(0,V.jsx)($f.circle,{cx:12,cy:12,r:10,style:FQ(),...AQ(e,{scale:[1,.86,1.06,1]},{times:[0,.25,.55,1],ease:`easeInOut`})}),(0,V.jsx)($f.circle,{cx:12,cy:12,r:1,fill:`currentColor`,style:FQ(),...AQ(e,{scale:[1,2.4,.8,1]},{times:[0,.3,.6,1],ease:`easeInOut`})})]})}function VQ({play:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($f.circle,{cx:6,cy:6,r:3,style:FQ(),...PQ(e,0)}),(0,V.jsx)($f.line,{x1:6,x2:6,y1:9,y2:21,...MQ(e,.05,.45)}),(0,V.jsx)($f.path,{d:`M13 6h3a2 2 0 0 1 2 2v7`,...MQ(e,.2,.62)}),(0,V.jsx)($f.circle,{cx:18,cy:18,r:3,style:FQ(),...NQ(e,.58)})]})}function HQ({play:e}){return(0,V.jsxs)($f.g,{style:FQ(),...AQ(e,{scaleX:[1,.55,1.08,1],y:[0,-1,0,0]},{times:[0,.35,.65,1],ease:`easeInOut`}),children:[(0,V.jsx)($f.path,{d:`M12 5v16`,style:FQ(),...AQ(e,{scaleY:[1,1.12,1,1]},{times:[0,.35,.65,1]})}),(0,V.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 UQ={lobby:IQ,tasks:LQ,plan:RQ,quickfix:zQ,issues:BQ,git:VQ,knowledge:HQ};function WQ({id:e,play:t,className:n}){let r=UQ[e];return r?(0,V.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:J(`overflow-visible`,n),children:(0,V.jsx)(r,{play:t})},t):null}function GQ(e){return/(\d)$/.exec(e)?.[1]}var KQ=160;function qQ(e){let t=kf(),[n,r]=(0,m.useState)(0),i=(0,m.useRef)(0),a=(0,m.useCallback)(()=>{t||performance.now()<i.current||(i.current=performance.now()+kQ*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,KQ);return()=>window.clearTimeout(n)},[e,a]),{play:n,onPointerEnter:(0,m.useCallback)(e=>{e.pointerType!==`touch`&&a()},[a])}}var JQ=(0,m.forwardRef)(function({tab:e,active:t},n){let r=GQ(e.key),{play:i,onPointerEnter:a}=qQ(t);return(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.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:J(`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,V.jsx)(WQ,{id:e.id,play:i,className:J(`size-3.5 shrink-0 transition-colors duration-200`,t&&`text-primary`)}),r?(0,V.jsx)(`span`,{"aria-hidden":`true`,className:J(`text-[0.72rem] font-semibold tabular-nums transition-colors duration-200`,t?`text-primary`:`text-muted-foreground/75`),children:r}):null,(0,V.jsx)(`span`,{children:e.label})]})}),(0,V.jsxs)(IO,{children:[e.label,` `,(0,V.jsx)(KD,{chord:e.key})]})]})}),YQ=1.5;function XQ(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 ZQ(e,t){let n=e.right-e.left,{height:r}=e,i=YQ/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 QQ(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}`),ZQ(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 $Q={type:`spring`,visualDuration:.12,bounce:0},e$={type:`spring`,visualDuration:.17,bounce:.15,delay:.015},t$={type:`spring`,visualDuration:.17,bounce:.05,delay:.07},n$={type:`spring`,visualDuration:.22,bounce:.25},r$={type:`spring`,visualDuration:.2,bounce:0},i$={type:`spring`,stiffness:900,damping:18,velocity:45,restDelta:.02,restSpeed:1},a$=(()=>{let e=jr({keyframes:[0,1],visualDuration:n$.visualDuration,bounce:n$.bounce}),t=0;for(;t<1e3&&e.next(t).value<.97;)t+=4;return t/1e3})(),o$={type:`spring`,visualDuration:.28,bounce:.6};function s$(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);XQ(r.current,t),XQ(i.current,void 0),QQ(a.current,t,`left`,1),QQ(o.current,void 0,`left`,0);for(let e of c.current)e&&(e.style.width=`0px`);qz()},[p,h]),_=(0,m.useCallback)((e,t)=>{let n=p(e),m=p(t);if(!n||!m)return g(t);h(),Kz(),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);XQ(i.current,n,_>0?n.left+e:n.left,_>0?n.right:n.right-e),QQ(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));XQ(r.current,d,_>0?d.left:d.right-f,_>0?d.left+f:d.right,Math.min(1,T.squash)),QQ(a.current,d,S,T.rung)},O=(e,t,n,r,i=1)=>{let a=Qf(t,i,{...n,onUpdate:t=>{T[e]=t,r?.(t),D()}});return u.current.push(a),a},k=!1,ee=()=>{if(k)return;k=!0;let e=O(`filled`,0,n$,e=>{d.current=e});e.then(()=>{l.current===t&&qz()}),O(`squash`,.8,o$),O(`rung`,0,r$,e=>{f.current=e}),O(`budge`,0,{...i$,delay:a$},void 0,0),Promise.all([e,...u.current]).then(()=>{l.current===t&&u.current.includes(e)&&g(t)})};O(`drained`,T.drained,$Q),O(`unrung`,T.unrung,$Q),O(`head`,0,e$,e=>{e>=w&&ee()}),O(`tail`,0,t$),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 c$=(0,m.forwardRef)(function({which:e},t){return(0,V.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,V.jsx)(`path`,{pathLength:1,strokeWidth:YQ,strokeLinecap:`round`,className:`stroke-tab-rim`}),(0,V.jsx)(`path`,{pathLength:1,strokeWidth:YQ,strokeLinecap:`round`,className:`stroke-tab-rim`})]})});function l$(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 u$({tabs:e,activeId:t,onSelect:n}){let{track:r,fill:i,drain:a,ring:o,unring:s,cells:c,liquids:l}=s$(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){qO()&&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];YO.active=!0,YO.to=o.id,window.setTimeout(()=>{YO.active=!1,YO.to=void 0},3e3),n(o.id),c.current[o.id]?.focus({preventScroll:!0})}return(0,V.jsx)(`div`,{ref:u,onScroll:p,style:{maskImage:l$(d),WebkitMaskImage:l$(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,V.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,V.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,V.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,V.jsx)(c$,{ref:s,which:`unring`}),(0,V.jsx)(c$,{ref:o,which:`ring`}),e.map((e,n)=>(0,V.jsxs)(m.Fragment,{children:[n>0?(0,V.jsxs)(`span`,{"aria-hidden":`true`,"data-tab-link":!0,className:`relative h-[2px] w-3.5 shrink-0 sm:w-4`,children:[(0,V.jsx)(`span`,{className:`absolute inset-0 border-t-2 border-dotted border-input`}),(0,V.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,V.jsx)(JQ,{ref:t=>{c.current[e.id]=t},tab:e,active:e.id===t})]},e.id))]})})}function d$({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(qV(ZV(e)));for(let e of n)e.pending&&e.source!==`LOBBY`&&i.add(e.source===`MASTER`?`Oracle`:qV(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 f$(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}var p$=6,m$=`bot-lobby.orb`,h$=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=1;function g$(e,t,n,r){let i=e=>e+p$,a=(e,t)=>Math.max(e+p$,e+t-r-p$);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 _$(e,t,n,r){let i=e=>Math.max(1,e-r),a=g$(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 v$(e,t,n){return g$(t.left+e.fx*Math.max(0,t.width-n),t.top+e.fy*Math.max(0,t.height-n),t,n)}function y$(e){if(e)try{let t=JSON.parse(e);return h$(t.fx)&&h$(t.fy)?{fx:t.fx,fy:t.fy}:void 0}catch{return}}function b$(){try{return y$(localStorage.getItem(m$))}catch{return}}function x$(e){try{localStorage.setItem(m$,JSON.stringify(e))}catch{}}var S$=5,C$=16;function w$(e){return{left:e.left,top:e.top,width:e.width,height:e.height}}function T$(){let e=document.getElementById(`main`)?.getBoundingClientRect();return e?w$(e):void 0}function E$(e,t){return!e||!t?e===t:e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function D$(){let[e,t]=(0,m.useState)(()=>T$());return(0,m.useEffect)(()=>{let e=()=>{let e=T$();t(t=>E$(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 O$=(0,m.forwardRef)(function({spotlight:e,thinking:t,busy:n=[],tone:r,expanded:i,hidden:a,shortcut:o,onOpen:s},c){let l=D$(),[u,d]=(0,m.useState)(b$),[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?v$(u,l,y.current):void 0),x=(0,m.useCallback)((e,t)=>{let n=T$();if(!n)return;let r=_$(e,t,n,y.current);d(r),x$(r)},[]);(0,m.useEffect)(()=>{l&&p(e=>e&&g$(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)<S$)return;t.moved=!0;let i=T$();i&&p(g$(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:C$,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?qV(e):E?f$(n):void 0,O=n.length===1&&!n[0].includes(`background`)?n[0]:void 0,k=e??(E?O:void 0),ee=e?`${t.map(qV).join(`, `)} thinking. `:E?`${n.join(`, `)} at work. `:``,te=b&&l?b.x-l.left<140:!1,A={"--orb":r,...b?{left:b.x,top:b.y,right:`auto`,bottom:`auto`}:{}};return(0,V.jsxs)(PO,{open:h&&!f,onOpenChange:g,children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.jsxs)(`button`,{ref:c,type:`button`,"aria-label":`Open Thinking`,"aria-description":`${ee}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:A,"data-thinking":e?``:void 0,"data-busy":E?``:void 0,"data-dragging":f?``:void 0,"data-placed":b?``:void 0,"data-flip":te||void 0,className:J(`thinking-bubble fixed z-20 touch-none rounded-full outline-none select-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,a&&`invisible`),children:[(0,V.jsx)(Fu,{initial:!1,children:D?(0,V.jsx)($f.span,{className:`orb-label`,initial:{opacity:0,x:te?-8:8,scale:.9},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:te?-8:8,scale:.9},transition:{type:`spring`,visualDuration:.3,bounce:.35},children:(0,V.jsx)(Fu,{mode:`popLayout`,initial:!1,children:(0,V.jsx)($f.span,{className:`inline-flex items-center gap-1`,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{type:`spring`,visualDuration:.28,bounce:.3},children:D},D)})},`label`):null}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`orb orb-float`,children:(0,V.jsx)(`span`,{className:`orb-icon`,children:(0,V.jsx)(GV,{source:k,strokeWidth:2.25,className:`size-3.5`})})})]})}),(0,V.jsxs)(IO,{side:`top`,children:[`Thinking `,o?(0,V.jsx)(KD,{chord:o}):null,(0,V.jsx)(`span`,{className:`text-background/70`,children:` · drag to move`})]})]})}),k$=/^\s*(?:#{1,6}\s+(.+?)\s*#*|\*\*([^*\n]{2,90}?):?\*\*:?|__([^_\n]{2,90}?):?__:?)\s*$/,A$=260,j$=200,M$=/^\s*(?:[-*+]\s|\d+[.)]\s|>|```|~~~|\|)/m;function N$(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(`
105
+ `,t),i=e.slice(n,r<0?e.length:r),a=NX.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 FX({rest:e}){let{chat:t}=RH(e);return(0,V.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,V.jsx)(`button`,{type:`button`,"aria-pressed":t===(n===`Chat`),onClick:()=>fO(zH(e,n===`Chat`)),className:J(`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 IX(e,t){return J(`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 LX({className:e,size:t=`sm`,asChild:n=!1,...r}){let i=n?$v:`button`;return(0,V.jsx)(i,{type:n?void 0:`button`,className:IX(t,e),...r})}function RX(e){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)();async function a(r){if(!t){n(!0),i(void 0);try{let{project:t}=await L(`projects.open`,{path:r});ve([t]),I(t.id,e)}catch(e){i(e.message)}finally{n(!1)}}}return{opening:t,error:r,open:a}}function zX({path:e,parent:t,busy:n,browse:r}){let[i,a]=(0,m.useState)(e);return(0,m.useEffect)(()=>a(e),[e]),(0,V.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,V.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,V.jsx)(Hp,{"aria-hidden":`true`,className:`size-4`})}),(0,V.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,V.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 BX(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 VX({data:e,loading:t,busy:n,browse:r}){let i=e?.folders.length??0;return(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-md border border-border`,children:[(0,V.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,V.jsx)(`span`,{children:`Name`}),(0,V.jsx)(`span`,{className:`normal-case tracking-normal`,children:t?`Loading…`:`${i.toLocaleString()} ${i===1?`folder`:`folders`}${e?.truncated?` (first 2,000)`:``}`})]}),(0,V.jsxs)(`div`,{"aria-label":`Folders`,role:`group`,onKeyDown:t=>BX(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,V.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,V.jsx)(nh,{"aria-hidden":`true`,className:J(`size-4 shrink-0`,t?`text-muted-foreground/60`:`text-muted-foreground`)}),(0,V.jsx)(`span`,{className:J(`min-w-0 flex-1 truncate`,t&&`text-muted-foreground`),children:e.name}),(0,V.jsx)(cm,{"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,V.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,V.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 HX({tab:e,close:t,busyChanged:n}){let[r,i]=(0,m.useState)(),a=MO(`projects.browse`,r===void 0?{}:{path:r},[]),o=RX(e);return(0,m.useEffect)(()=>n(o.opening),[o.opening,n]),(0,V.jsxs)(`div`,{className:`flex min-h-0 max-h-full w-full flex-col overflow-y-auto`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border px-4 py-3`,children:[(0,V.jsx)(`h2`,{className:`text-[0.9375rem] font-semibold`,children:`Open project folder`}),(0,V.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,V.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3 p-4`,children:[(0,V.jsx)(zX,{path:a.data?.path??r??``,parent:a.data?.parent,busy:o.opening,browse:i}),(0,V.jsx)(VX,{data:a.data,loading:a.loading,busy:a.loading||o.opening,browse:i}),a.loading?(0,V.jsx)(`p`,{role:`status`,className:`sr-only`,children:`Loading folders…`}):null,a.error||o.error?(0,V.jsx)(`p`,{role:`alert`,className:`break-words text-xs text-destructive`,children:a.error??o.error}):null]}),(0,V.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,V.jsx)(Y,{variant:`outline`,onClick:a.reload,disabled:a.loading,children:`Retry`}):null,(0,V.jsx)(Y,{variant:`outline`,onClick:t,disabled:o.opening,children:`Cancel`}),(0,V.jsx)(Y,{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 UX({open:e,onClose:t,tab:n}){let r=nO(e,tO.help),[i,a]=(0,m.useState)(!1);return(0,V.jsx)(JD,{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,V.jsx)(HX,{tab:n,close:t,busyChanged:a}):null})}function WX(){try{return{id:pe()}}catch(e){return{error:e.message}}}function GX(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 KX(){let[e,t]=(0,m.useState)(),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(0);async function s(){let e=++o.current;a(!0),r(void 0);try{let n=await L(`projects.list`,{});ve(n.projects),e===o.current&&t(n)}catch(t){e===o.current&&r(t.message)}finally{e===o.current&&a(!1)}}(0,m.useEffect)(()=>(s(),()=>{o.current++}),[]);let[c,l]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{if(!i)return l(!1);let e=setTimeout(()=>l(!0),300);return()=>clearTimeout(e)},[i]),{data:e,error:n,busy:i,slow:c,refresh:s}}function qX({data:e,error:t}){let n=WX();return n.error??t??GX(e,n.id)}function JX({projects:e}){let t=qX(e);return t?(0,V.jsxs)(`p`,{role:`alert`,className:`notice flex min-w-0 items-start gap-2 pt-1 pb-0.5 text-xs break-words text-destructive`,children:[(0,V.jsx)(Kg,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,V.jsx)(`span`,{children:t})]}):null}function YX(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 XX=`bot-lobby:open-projects`;function ZX({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=WX(),p=qX(e),h=f.error?`invalid`:f.id??i?.currentId??``;ek(`p`,()=>l(!0)),(0,m.useEffect)(()=>{let e=()=>l(!0);return window.addEventListener(XX,e),()=>window.removeEventListener(XX,e)},[]),ek(`r`,()=>void s(),{enabled:c,inDialog:!0});function g(e){l(!1),e!==h&&I(e,t)}return(0,V.jsxs)(`div`,{"aria-busy":a,className:`flex min-w-0 items-center gap-1`,children:[(0,V.jsxs)(SW,{open:c,onOpenChange:l,children:[(0,V.jsxs)(CW,{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:J(`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`,IX(`xs`,`min-w-0 justify-start`)),children:[(0,V.jsx)(nh,{"aria-hidden":`true`,className:J(`size-3 shrink-0`,p&&`text-destructive`)}),(0,V.jsx)(`span`,{className:`truncate`,children:n}),(0,V.jsx)(im,{"aria-hidden":`true`,className:`size-3 shrink-0 opacity-50`})]}),(0,V.jsxs)(wW,{align:`start`,side:`top`,sideOffset:8,"aria-label":`Projects`,onKeyDown:YX,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,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,V.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Running projects`}),(0,V.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,V.jsx)(bO,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):(0,V.jsx)(fg,{"aria-hidden":`true`,className:`size-3`}),`Refresh`,(0,V.jsx)(KD,{chord:`R`,className:`kbd-hint`})]})]}),(0,V.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,V.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>g(e.id),className:J(`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,V.jsx)(`span`,{className:`flex h-5 w-4 shrink-0 items-center justify-center`,children:t?(0,V.jsx)(nm,{"aria-hidden":`true`,className:`size-3.5 text-primary`}):null}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`span`,{className:`block whitespace-normal break-words text-sm font-medium`,children:e.name}),(0,V.jsxs)(`span`,{className:`block whitespace-normal break-all text-xs text-muted-foreground`,children:[e.cwd,` · :`,e.port]})]})]},e.id)})}),(0,V.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,V.jsx)(eh,{"aria-hidden":`true`,className:`size-4`}),`Open folder…`]})]})]}),(0,V.jsx)(UX,{open:u,onClose:()=>d(!1),tab:t}),o||p?(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Refresh projects`,disabled:a,onClick:()=>void s(),className:J(`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`,IX(`xs`,`w-7 px-0 sm:w-[1.625rem]`)),children:a?(0,V.jsx)(bO,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,V.jsx)(fg,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,V.jsx)(IO,{side:`top`,children:`Refresh projects`})]}):null]})}function QX({contextStrip:e=!1,className:t,...n}){return(0,V.jsx)(`div`,{"data-slot":`composer-shell`,"data-with-context":e||void 0,className:J(`@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 $X=`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)`,eZ=`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 tZ({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`composer-host`,className:J(`relative z-10 w-full rounded-3xl shadow-composer after:z-1 dark:shadow-none`,$X,eZ,`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 nZ({className:e,...t}){return(0,V.jsx)(`div`,{"data-chat-composer-main-surface":`true`,className:J(`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)`,$X,eZ,`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 rZ({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`composer-context-strip`,className:J(`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 iZ={Shell:QX,Host:tZ,Main:nZ,ContextStrip:rZ},aZ=e=>e.preventDefault();function oZ({onStop:e}){let[t,n]=(0,m.useState)(!1),r=nO(t,tO.confirm),i=()=>{n(!1),e()};return ek(`y`,i,{enabled:t&&r,inDialog:!0}),(0,V.jsxs)(Ok,{open:t&&r,onOpenChange:n,children:[(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.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:aZ,onClick:()=>n(!0),"aria-label":`Stop`,"aria-haspopup":`dialog`,children:(0,V.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,V.jsx)(`rect`,{x:`2`,y:`2`,width:`8`,height:`8`,rx:`1.5`})})})}),(0,V.jsx)(IO,{side:`top`,children:`Interrupt`})]}),(0,V.jsxs)(jk,{children:[(0,V.jsxs)(Mk,{children:[(0,V.jsx)(Pk,{children:`Stop the oracle?`}),(0,V.jsx)(Fk,{children:`The current response stops. Work already recorded is kept.`})]}),(0,V.jsxs)(Nk,{children:[(0,V.jsxs)(Lk,{children:[`Keep it`,(0,V.jsx)(KD,{chord:`Esc`,className:`kbd-hint ml-1`})]}),(0,V.jsxs)(Ik,{variant:`destructive`,onClick:i,children:[`Stop`,(0,V.jsx)(KD,{chord:`Y`,className:`kbd-hint ml-1`})]})]})]})]})}function sZ({sending:e,disabled:t,steering:n,onSend:r}){let i=n?`Steer message`:`Send`;return(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.jsx)(`span`,{className:`inline-flex`,children:(0,V.jsx)(`button`,{type:`button`,className:J(`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:aZ,onClick:r,disabled:t,"aria-label":`Send`,"aria-keyshortcuts":`Enter`,children:e?(0,V.jsx)(bO,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,V.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":`true`,children:(0,V.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,V.jsxs)(IO,{side:`top`,children:[i,` `,(0,V.jsx)(KD,{chord:`Enter`})]})]})}var cZ={id:`oracle`,label:`Message the oracle`,placeholder:`Message the oracle…`},lZ=new Set([`lobby`,`tasks`,`plan`,`quickfix`,`knowledge`]);function uZ(e){return e.kind===`tab`&&lZ.has(e.tab)}function dZ(e,t){if(e.kind!==`tab`)return cZ;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…`};if(e.tab===`quickfix`)return{id:`quickfix`,label:`Describe a quick fix`,placeholder:`Describe a small change…`};let n=e.tab===`tasks`?yU(e.rest).id??t:void 0;return n?{id:`comment`,label:`Comment on ${n}`,placeholder:`Comment on ${n}'s plan…`,taskId:n}:cZ}var fZ=0;function pZ(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}var mZ={duration:.16,ease:`easeOut`};function hZ({file:e,onRemove:t}){let n=(0,V.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,onClick:t,className:J(`flex shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,e.image?`absolute top-1 right-1 size-[1.625rem] rounded-full bg-background/85 text-foreground shadow-xs hover:bg-background`:`size-7`),children:(0,V.jsx)(o_,{"aria-hidden":`true`,className:`size-3.5`})});return e.image?(0,V.jsxs)($f.li,{layout:!0,initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:mZ,title:`${e.name} · ${kX(e.size)}`,className:`relative size-16 shrink-0 overflow-hidden rounded-lg border border-border/80 bg-background`,children:[(0,V.jsx)(`img`,{src:F(e.image),alt:e.name,className:`size-full object-cover`}),e.state===`uploading`?(0,V.jsxs)(`span`,{className:`pointer-events-none absolute inset-x-0 bottom-0 flex items-center justify-center gap-1 bg-background/85 px-1 text-[0.625rem] text-foreground`,children:[(0,V.jsx)(bO,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}),`uploading`]}):null,n]}):(0,V.jsxs)($f.li,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:mZ,className:`flex min-w-0 basis-full items-center gap-2 text-sm text-foreground`,children:[(0,V.jsx)(Xm,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,V.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-muted-foreground`,children:[e.state===`uploading`?(0,V.jsx)(bO,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}):null,e.state===`uploading`?`uploading…`:kX(e.size)]}),n]})}function gZ(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 _Z({route:e,keys:t,projects:n,onHelp:r}){let[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)([]),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=AO(`status`),p=AO(`lobby`),h=iO(),g=(f.data?.busy??!1)||!!p.data?.reply?.trim(),_=uZ(e),v=(0,m.useRef)(_);v.current=_;let{taskId:y}=sJ(),b=(0,m.useMemo)(()=>dZ(e,y),[e,y]),x=(0,m.useRef)(null),{shrunk:S,expand:C}=gZ(x,_&&!h,e),w=(0,m.useRef)(null),T=(0,m.useRef)(null),E=(0,m.useRef)(o);E.current=o;let D=(0,m.useRef)(void 0);(0,m.useLayoutEffect)(()=>{let e=D.current,t=w.current;e&&t&&(D.current=void 0,t.setSelectionRange(e.start,e.end))},[i]);let O=(0,m.useCallback)(e=>{D.current={start:e.start,end:e.end},a(e.value)},[]);(0,m.useEffect)(()=>{let e=x.current;if(!e)return;let t=document.documentElement,n=()=>{let n=e.getBoundingClientRect();if(t.style.setProperty(`--composer-h`,h||!_?`0px`:`${Math.ceil(n.height)}px`),!_||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`)}},[h,_]);let k=(0,m.useCallback)(e=>{if(!v.current)return;let t=[...e],n=8-E.current.length;t.length>n&&mp.warning(`At most 8 files go with one message.`);for(let e of t.slice(0,Math.max(0,n))){let t=`f${++fZ}`,n=e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0;s(r=>[...r,{key:t,name:e.name||(n?`image.png`:`file`),size:e.size,...n?{image:n}:{},state:`uploading`}]),AX(e).then(e=>s(n=>n.map(n=>n.key===t?{...n,state:`ready`,info:e}:n))).catch(e=>{mp.error(e instanceof Error?e.message:`That file did not upload.`),s(e=>e.filter(e=>e.key!==t))})}},[]),ee=(0,m.useCallback)(e=>{s(t=>{let n=t.find(t=>t.key===e);return n?.image&&URL.revokeObjectURL(n.image),t.filter(t=>t.key!==e)})},[]),te=o.some(e=>e.state===`uploading`),A=o.flatMap(e=>e.info?[e.info.id]:[]),j=(i.trim().length>0||A.length>0)&&!te&&!c,M=(0,m.useCallback)(async()=>{if(!j||!v.current)return;l(!0);let e=A.length>0?A:void 0,t={text:i,...e?{attachments:e}:{}};try{let e=!0;if(b.id===`oracle`){let e=await L(`lobby.send`,t);e.notice&&mp(e.notice)}else if(b.id===`knowledge`){e=await U(`knowledge.ask`,t)!==void 0;let n=uO(window.location.hash);e&&n?.kind===`tab`&&n.tab===`knowledge`&&fO(zH(n.rest,!0))}else e=b.id===`panel`?await U(`planner.send`,t)!==void 0:b.id===`quickfix`?await U(`quickfix.submit`,t)!==void 0:await U(`tasks.comment`,{taskId:b.taskId,...t})!==void 0;if(e){a(``);for(let e of E.current)e.image&&URL.revokeObjectURL(e.image);s([])}}catch(e){mp.error(e instanceof Error?e.message:`Could not send`)}finally{l(!1)}},[j,A,b,i,e]),ne=(0,m.useCallback)(async()=>{try{await L(`lobby.abort`,{})}catch(e){mp.error(e instanceof Error?e.message:`Could not stop`)}},[]),N=e=>{if(e.key===`Escape`&&!e.nativeEvent.isComposing){e.preventDefault(),JO();return}let t=e.currentTarget,n=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&!e.altKey&&!e.shiftKey&&[`b`,`i`,`e`,`k`].includes(n)){e.preventDefault();let{selectionStart:r,selectionEnd:i,value:a}=t;O(n===`k`?MX(a,r,i):jX(a,r,i,n===`b`?`**`:n===`i`?`_`:"`"));return}if(e.key===`Enter`&&e.shiftKey&&!e.nativeEvent.isComposing&&t.selectionStart===t.selectionEnd){let n=PX(t.value,t.selectionStart);n&&(e.preventDefault(),O(n));return}if(e.key===`Backspace`&&t.value===``&&E.current.length>0){e.preventDefault(),ee(E.current.at(-1).key);return}(pZ(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey))&&(e.preventDefault(),M())},re=e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),k(t))},ie=e=>{e.preventDefault(),d(!1),e.dataTransfer.files.length>0&&k(e.dataTransfer.files)},ae=e.kind===`tab`&&e.tab===`knowledge`,oe=f.data?.workspace.name??`bot-lobby`,se=f.data?.branch??f.data?.workspace.branch,ce=(0,V.jsx)(`div`,{className:`min-h-0`,children:(0,V.jsx)(`div`,{className:`relative z-0`,children:(0,V.jsxs)(iZ.ContextStrip,{role:`group`,"aria-label":`Message context`,className:`composer-strip gap-1 text-xs font-normal text-muted-foreground/70`,children:[(0,V.jsx)(ZX,{projects:n,tab:e.kind===`tab`?e.tab:e.kind,name:oe,branch:se}),(0,V.jsxs)(`div`,{className:`@container ml-auto flex min-w-0 flex-1 items-center justify-end gap-3 overflow-hidden pe-1`,children:[e.kind===`tab`&&e.tab===`plan`?(0,V.jsx)(qD,{chord:t.savePlan??`Ctrl+S`,className:`hidden @[24rem]:inline-flex`,children:`save plan`}):null,(0,V.jsx)(qD,{chord:`Shift+Enter`,className:`hidden @[14rem]:inline-flex`,children:`new line`}),(0,V.jsxs)(LX,{size:`xs`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,"aria-label":`Keyboard shortcuts`,"aria-haspopup":`dialog`,"data-compact":!0,onClick:r,className:`kbd-hint`,children:[(0,V.jsx)(KD,{chord:t.help??`Alt+H`,className:`kbd-hint`}),(0,V.jsx)(`span`,{className:`hidden @[8rem]:inline`,children:`shortcuts`})]})]})]})})});return(0,V.jsx)(`div`,{id:`app-dock`,ref:x,"data-shrunk":S||void 0,onFocus:C,className:J(`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`,h&&`opacity-0`),hidden:!_,"aria-hidden":!_||void 0,inert:h||!_,children:(0,V.jsxs)(iZ.Shell,{contextStrip:!0,className:`composer-shell pointer-events-auto`,children:[(0,V.jsx)(iZ.Host,{onPointerDown:C,children:(0,V.jsx)(`div`,{className:`relative z-10`,children:(0,V.jsxs)(iZ.Main,{className:`group/composer composer-box`,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),d(!0))},onDragLeave:()=>d(!1),onDrop:ie,children:[(0,V.jsxs)(`div`,{"data-chat-composer-surface":`true`,className:J(`rounded-3xl transition-[background-color] duration-200`,u&&`bg-accent/45 ring-1 ring-inset ring-primary/70`),children:[(0,V.jsxs)(`div`,{"data-chat-composer-body":`true`,className:J(`composer-text relative px-3 pb-2 sm:px-4`,`pt-3.5 sm:pt-4`),children:[(0,V.jsx)(Fu,{initial:!1,children:o.length>0?(0,V.jsx)($f.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:o.map(e=>(0,V.jsx)(hZ,{file:e,onRemove:()=>ee(e.key)},e.key))},`files`):null}),(0,V.jsx)(`div`,{className:`relative flow-root font-sans text-sm max-sm:pointer-coarse:text-base`,children:(0,V.jsx)(`textarea`,{ref:w,id:`composer-text`,"aria-label":b.label,value:i,onChange:e=>a(e.target.value),onKeyDown:N,onPaste:re,placeholder:g&&b.id===`oracle`?`The oracle is working. Enter steers it…`:b.placeholder,rows:1,className:J(`-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,V.jsxs)(`div`,{"data-chat-composer-footer":`true`,className:J(`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,V.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:ae?(0,V.jsx)(FX,{rest:e.kind===`tab`?e.rest:[]}):null}),(0,V.jsxs)(`div`,{"data-chat-composer-actions":`right`,className:`flex shrink-0 flex-nowrap items-center justify-end gap-2`,children:[(0,V.jsx)(`input`,{ref:T,type:`file`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach files`,onChange:e=>{k(e.target.files??[]),e.target.value=``}}),(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Attach images, PDFs or files`,"data-compact":!0,onPointerDown:e=>e.preventDefault(),onClick:()=>T.current?.click(),className:`pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11`,children:(0,V.jsx)(eg,{"aria-hidden":`true`})})}),(0,V.jsx)(IO,{side:`top`,children:`Attach files`})]}),g&&b.id===`oracle`?(0,V.jsx)(oZ,{onStop:()=>void ne()}):null,(0,V.jsx)(sZ,{sending:c,disabled:!j,steering:g&&b.id===`oracle`,onSend:()=>void M()})]})]})]}),u?(0,V.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-30 flex items-center justify-center rounded-[inherit] text-sm font-medium text-primary`,children:`Drop to attach`}):null]})})}),ce]})})}function vZ({state:e}){return e===`live`?(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.jsx)(`span`,{role:`img`,"aria-label":`Connected`,className:`grid size-6 place-items-center`,children:(0,V.jsx)(`span`,{className:`size-2 rounded-full bg-success`})})}),(0,V.jsx)(IO,{children:`Connected`})]}):e===`connecting`?(0,V.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 rounded-full bg-warning motion-safe:animate-status-pulse`}),`reconnecting…`]}):(0,V.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:`Connection lost`})}function yZ(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 bZ=24;function xZ(){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=yZ(t.querySelector(`.where`))+(r?.offsetWidth??0)+yZ(t.querySelector(`.tools`))+a*2;n(s+bZ<=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 SZ({connection:e,projects:t,lead:n,tabs:r,extra:i,tools:a}){let{header:o,one:s}=xZ();return(0,V.jsxs)(`header`,{ref:o,className:`app-header shrink-0`,"data-one-row":s||void 0,children:[(0,V.jsx)(`div`,{className:`where flex min-w-0 items-center gap-2`,children:n}),(0,V.jsx)(`div`,{className:`tabs min-w-0`,children:r}),(0,V.jsxs)(`div`,{className:`tools flex min-w-0 items-center justify-end gap-2`,children:[i,(0,V.jsx)(vZ,{state:e}),a,(0,V.jsx)(`span`,{id:`focused-action-help`,className:`sr-only`,children:`Focused buttons: Enter or Space. Links: Enter. Checkboxes: Space.`})]}),(0,V.jsx)(JX,{projects:t})]})}function CZ({open:e,onOpenChange:t}){let n=nO(e,tO.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{mp((await L(`sessions.start`,{request:e})).notice),t(!1),i(``)}catch(e){c(e instanceof Error?e.message:`That did not work. Try again.`)}finally{o(!1)}}};return(0,V.jsx)(JD,{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,V.jsxs)(`div`,{className:`flex w-[min(32rem,calc(100vw-2rem))] flex-col`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border px-4 py-3`,children:[(0,V.jsx)(`h2`,{className:`text-[0.9375rem] font-semibold`,children:`New session`}),(0,V.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,V.jsxs)(`div`,{className:`flex flex-col gap-1.5 p-4`,children:[(0,V.jsx)(`label`,{htmlFor:l,className:`text-sm font-medium`,children:`What should it do?`}),(0,V.jsx)(Ck,{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,V.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:s}):null]}),(0,V.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,V.jsx)(Y,{variant:`outline`,onClick:u,disabled:a,children:`Cancel`}),(0,V.jsx)(Y,{onClick:()=>void d(),disabled:!r.trim()||a,"aria-busy":a,children:a?`Starting…`:`Start session`})]})]})})}function wZ(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 TZ(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:wZ(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 EZ=`app.sidebar`,DZ={start:16,min:13,max:24},OZ=`bot-lobby.sidebar.width`,kZ=`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`,AZ=`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 jZ({label:e,hint:t,side:n=`bottom`,children:r}){return(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:r}),(0,V.jsxs)(IO,{side:n,children:[e,` `,t?(0,V.jsx)(KD,{chord:t}):null]})]})}function MZ(){let e=AO(`status`).data;return{entries:TZ(e,MO(`sessions.list`,{},[`sessions`]).data),branch:e?.branch??e?.workspace.branch}}function NZ(){return(0,m.useCallback)(async e=>{if(e.where===`here`)return fO(`#/lobby`);if(e.where===`elsewhere`)return void mp.info(`${e.name} runs in another terminal. Switch to that terminal to work in it.`);await U(`sessions.switch`,e.key?{key:e.key}:{sessionId:e.sessionId})&&fO(`#/lobby`)},[])}function PZ({entry:e}){return(0,V.jsx)(`span`,{"aria-hidden":`true`,"data-state":e.where===`elsewhere`?`elsewhere`:e.state,className:`session-dot relative`})}function FZ({entry:e}){return e.where===`elsewhere`?(0,V.jsx)(PZ,{entry:e}):e.state===`asking`?(0,V.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-warning tabular-nums`,children:[(0,V.jsx)(Ah,{"aria-hidden":`true`,className:`size-3.5`}),e.waiting,(0,V.jsxs)(`span`,{className:`sr-only`,children:[e.waiting===1?` question`:` questions`,`, Waiting`]})]}):e.state===`working`||e.state===`starting`?(0,V.jsxs)(`span`,{className:J(`inline-flex shrink-0`,e.state===`working`?`text-primary`:`text-muted-foreground`),children:[(0,V.jsx)(gm,{"aria-hidden":`true`,className:`session-spin size-3.5`}),(0,V.jsx)(`span`,{className:`sr-only`,children:e.state===`working`?`Working`:`Starting`})]}):(0,V.jsxs)(`span`,{className:`inline-flex shrink-0`,children:[(0,V.jsx)(PZ,{entry:e}),(0,V.jsx)(`span`,{className:`sr-only`,children:e.state===`exited`?`Ended`:`Idle`})]})}var IZ={here:`This window`,background:`Background`,elsewhere:`Other terminal`};function LZ(e){let t=e.key;return U(`sessions.archive`,{key:t},{undo:()=>void U(`sessions.archive`,{key:t,archived:!1})})}function RZ({entry:e,onDone:t}){let[n,r]=(0,m.useState)(e.name),i=(0,m.useRef)(!1),a=async()=>{if(i.current)return;i.current=!0;let r=n.replace(/\s+/g,` `).trim();r&&r!==e.name&&await U(`sessions.rename`,{...e.where===`here`?{}:{key:e.key},name:r}),t()};return(0,V.jsx)(`input`,{value:n,autoFocus:!0,maxLength:120,"aria-label":`New name for ${e.name}`,onFocus:e=>e.currentTarget.select(),onChange:e=>r(e.target.value),onBlur:()=>void a(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),a()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i.current=!0,t())},className:`-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 zZ=`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 BZ({entry:e}){let t=NZ(),[n,r]=(0,m.useState)(!1),i=e.state===`exited`||e.where===`elsewhere`,a=J(`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,V.jsxs)(`li`,{className:`session-enter session-item relative`,children:[n?(0,V.jsx)(`div`,{"aria-current":e.where===`here`?`true`:void 0,className:J(AZ,`hover:bg-transparent`),children:(0,V.jsx)(RZ,{entry:e,onDone:()=>r(!1)})}):(0,V.jsxs)(`button`,{type:`button`,"aria-current":e.where===`here`?`true`:void 0,"aria-label":e.where===`here`?`${e.name}, this window`:e.where===`elsewhere`?`${e.name}, in another terminal`:`Switch to ${e.name}`,title:e.name,"data-where":e.where,"data-state":e.state,onClick:()=>void t(e),onDoubleClick:e=>{o&&(e.preventDefault(),r(!0))},className:AZ,children:[(0,V.jsx)(`span`,{className:a,children:e.name}),(0,V.jsx)(`span`,{className:J(`flex shrink-0 items-center`,c&&`session-state`),children:(0,V.jsx)(FZ,{entry:e})})]}),!n&&c?(0,V.jsxs)(`span`,{className:`session-actions absolute top-1/2 right-1 flex -translate-y-1/2 items-center gap-0.5`,children:[o?(0,V.jsx)(jZ,{label:`Rename`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Rename ${e.name}`,onClick:()=>r(!0),className:zZ,children:(0,V.jsx)(og,{"aria-hidden":`true`,className:`size-3.5`})})}):null,s?(0,V.jsx)(jZ,{label:`Archive`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Archive ${e.name}`,onClick:()=>void LZ(e),className:zZ,children:(0,V.jsx)(Pp,{"aria-hidden":`true`,className:`size-3.5`})})}):null]}):null]})}var VZ=`flex h-7 items-center px-2.5 pt-2 text-xs font-medium text-muted-foreground`;function HZ({id:e,label:t,entries:n,archivable:r=!1}){let[i,a]=mH(`app.sidebar.${e}`),o=(0,m.useId)();return n.length===0?null:(0,V.jsxs)(`section`,{"aria-label":t,className:`group/shelf flex flex-col`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1 pt-2`,children:[(0,V.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,V.jsx)(`span`,{children:t}),i?(0,V.jsx)(`span`,{className:`tabular-nums`,children:n.length}):null,(0,V.jsx)(im,{"aria-hidden":`true`,className:J(`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,V.jsx)(`button`,{type:`button`,onClick:()=>void(async()=>{for(let e of n)e.key&&await U(`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,V.jsx)(`ul`,{id:o,className:`flex flex-col gap-px`,children:n.map(e=>(0,V.jsx)(BZ,{entry:e},e.id))})]})}function UZ(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean),r=`${e.name} ${IZ[e.where]}`.toLowerCase();return n.every(e=>r.includes(e))}function WZ({query:e,onQuery:t,onNew:n}){return(0,V.jsxs)(`div`,{className:`flex items-center gap-1 px-1 pb-2`,children:[(0,V.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,V.jsx)(wg,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,V.jsx)(`input`,{type:`search`,value:e,"aria-label":`Search sessions`,placeholder:`Search`,onChange:e=>t(e.target.value),onKeyDown:n=>{n.key===`Escape`&&e&&(n.preventDefault(),n.stopPropagation(),t(``))},className:`min-w-0 flex-1 bg-transparent text-sidebar-foreground outline-none placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden`})]}),(0,V.jsx)(jZ,{label:`New session`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`New session`,"aria-haspopup":`dialog`,onClick:n,className:kZ,children:(0,V.jsx)(Pg,{"aria-hidden":`true`,className:`size-4`})})})]})}function GZ({query:e}){let{entries:t}=MZ(),n=t.filter(t=>UZ(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,V.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,V.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,V.jsxs)(`p`,{className:`px-2.5 py-1.5 text-xs text-muted-foreground`,children:[`No sessions match “`,e.trim(),`”.`]}):null,r.length>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:VZ,children:`This window`}),(0,V.jsx)(`ul`,{className:`flex flex-col gap-px`,children:r.map(e=>(0,V.jsx)(BZ,{entry:e},e.id))})]}):null,i.length>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:J(VZ,`mt-2`),children:`Background`}),(0,V.jsx)(`ul`,{className:`flex flex-col gap-px`,children:i.map(e=>(0,V.jsx)(BZ,{entry:e},e.id))})]}):!e.trim()&&t.length===1?(0,V.jsx)(`p`,{className:`px-2.5 pt-2 text-xs text-muted-foreground`,children:`No other sessions are running.`}):null,(0,V.jsxs)(`div`,{className:`mt-auto flex flex-col pt-2`,children:[(0,V.jsx)(HZ,{id:`elsewhere`,label:`Other terminals`,entries:a}),(0,V.jsx)(HZ,{id:`ended`,label:`Ended`,entries:o,archivable:!0})]})]}),(0,V.jsx)(Vv,{target:s})]})}function KZ({route:e,keys:t,onHelp:n}){let r=t.settings??`Alt+S`;return(0,V.jsxs)(`div`,{className:`sidebar-foot flex flex-col gap-1 border-t border-[var(--sidebar-border)] px-1 py-2`,children:[(0,V.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,V.jsx)(Eg,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,V.jsx)(`span`,{className:`flex-1`,children:`Settings`}),(0,V.jsx)(KD,{chord:r})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(SX,{hint:t.help??`Alt+H`,onHelp:n,className:kZ}),(0,V.jsx)(wX,{className:kZ}),(0,V.jsx)(CX,{className:kZ}),(0,V.jsx)(EX,{className:kZ}),(0,V.jsx)(DX,{className:kZ}),(0,V.jsx)(OX,{className:kZ})]})]})}function qZ(){try{let e=Number(localStorage.getItem(OZ));if(e>=DZ.min&&e<=DZ.max)return e}catch{}return DZ.start}function JZ(e){try{e===DZ.start?localStorage.removeItem(OZ):localStorage.setItem(OZ,String(e))}catch{}}var YZ=e=>Math.min(DZ.max,Math.max(DZ.min,Math.round(e*4)/4));function XZ({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,V.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-label":`Resize sidebar`,"aria-orientation":`vertical`,"aria-controls":`app-sidebar`,"aria-valuemin":DZ.min,"aria-valuemax":DZ.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(YZ(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(DZ.start)},onKeyDown:n=>{n.key===`ArrowLeft`||n.key===`ArrowRight`?(n.preventDefault(),t(YZ(e+(n.key===`ArrowRight`?1:-1)))):n.key===`Home`||n.key===`End`?(n.preventDefault(),t(n.key===`Home`?DZ.min:DZ.max)):n.key===`Enter`&&(n.preventDefault(),r())}})}function ZZ(e){jO(aH);let[t,n]=mH(EZ),[r,i]=(0,m.useState)(qZ),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(``),[l,u]=(0,m.useState)(!1),d=(0,m.useCallback)(e=>{i(e),JZ(e)},[]);return(0,V.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,V.jsxs)(`div`,{className:`sidebar-panel flex min-h-0 flex-1 flex-col`,style:{width:`${r}rem`},children:[(0,V.jsxs)(`div`,{className:`flex min-h-12 items-center gap-2 pr-1 pl-3`,children:[(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-semibold tracking-tight text-sidebar-foreground`,children:`Bot Lobby`}),(0,V.jsx)(jZ,{label:`Collapse sidebar`,hint:e.keys.sidebar,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Collapse sidebar`,"aria-expanded":!0,"aria-controls":`app-sidebar`,"aria-keyshortcuts":e.keys.sidebar,onClick:n,className:kZ,children:(0,V.jsx)(Jh,{"aria-hidden":`true`,className:`size-4`})})})]}),(0,V.jsx)(WZ,{query:s,onQuery:c,onNew:()=>u(!0)}),(0,V.jsx)(GZ,{query:s}),(0,V.jsx)(KZ,{...e})]}),(0,V.jsx)(XZ,{width:r,onWidth:d,onResizing:o,onFold:n}),(0,V.jsx)(CZ,{open:l,onOpenChange:u})]})}function QZ({hint:e}){jO(aH);let[t,n]=mH(EZ);return t?(0,V.jsx)(jZ,{label:`Expand sidebar`,hint:e,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Expand sidebar`,"aria-expanded":!1,"aria-controls":`app-sidebar`,"aria-keyshortcuts":e,onClick:n,className:J(kZ,`sidebar-open size-8 text-foreground`),children:(0,V.jsx)(Xh,{"aria-hidden":`true`,className:`size-4`})})}):null}var $Z=`bot-lobby.terminal.open`,eQ=`bot-lobby.terminal.height`,tQ={start:280,min:140},nQ=new Set,rQ,iQ;function aQ(e){try{return localStorage.getItem(e)}catch{return null}}function oQ(e,t){try{localStorage.setItem(e,t)}catch{}}function sQ(){for(let e of[...nQ])e()}function cQ(e){return nQ.add(e),()=>{nQ.delete(e)}}function lQ(){return rQ??=aQ($Z)===`1`,rQ}function uQ(){if(iQ===void 0){let e=Number(aQ(eQ));iQ=e>=tQ.min?e:tQ.start}return iQ}function dQ(e){rQ=e,oQ($Z,e?`1`:`0`),sQ()}function fQ(){dQ(!lQ())}function pQ(e){iQ=Math.max(tQ.min,Math.round(e)),oQ(eQ,String(iQ)),sQ()}function mQ(){return(0,m.useSyncExternalStore)(cQ,lQ,()=>!1)}function hQ(){return(0,m.useSyncExternalStore)(cQ,uQ,()=>tQ.start)}var gQ=`modulepreload`,_Q=function(e){return`/`+e},vQ={},yQ=function(e){return e.pathname.endsWith(`.css`)},bQ=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=_Q(t,n);let r=s(t);if(r.href in vQ)return;vQ[r.href]=!0;let i=yQ(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`:gQ,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)})},xQ=(0,m.lazy)(()=>bQ(()=>import(`./TerminalView-CbRc77C8.js`),__vite__mapDeps([0,1]))),SQ=`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`;function CQ({label:e,hint:t,children:n}){return(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:n}),(0,V.jsxs)(IO,{side:`top`,children:[e,` `,t?(0,V.jsx)(KD,{chord:t}):null]})]})}function wQ({hint:e,className:t}){let n=mQ();return(0,V.jsx)(CQ,{label:n?`Hide terminal`:`Terminal`,hint:e,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Terminal`,"aria-pressed":n,"aria-controls":n?`terminal-drawer`:void 0,"aria-keyshortcuts":e,onClick:fQ,className:t,children:(0,V.jsx)(Ig,{"aria-hidden":`true`,className:`size-4`})})})}function TQ(e){let[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(``),a=(0,m.useCallback)(async()=>{try{n(await L(`terminal.list`,{})),i(``)}catch(e){i(e instanceof Error?e.message:`The terminals could not be read.`)}},[]);return(0,m.useEffect)(()=>{e&&a()},[e,a]),{list:t,error:r,reload:a}}function EQ({height:e,max:t}){let n=(0,m.useRef)(null);return(0,V.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-label":`Resize terminal`,"aria-orientation":`horizontal`,"aria-valuenow":e,"aria-valuemin":tQ.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&&pQ(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:()=>pQ(tQ.start),onKeyDown:n=>{(n.key===`ArrowUp`||n.key===`ArrowDown`)&&(n.preventDefault(),pQ(Math.min(t,e+(n.key===`ArrowUp`?24:-24))))}})}function DQ({toggleKey:e}){let t=mQ(),n=hQ(),{list:r,error:i,reload:a}=TQ(t),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(()=>Math.round(window.innerHeight*.7)),f=r?.terminals??[],p=f.find(e=>e.id===o)??f.at(-1);(0,m.useEffect)(()=>{let e=()=>d(Math.round(window.innerHeight*.7));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let h=(0,m.useCallback)(async()=>{l(!0);try{let e=await L(`terminal.open`,{cols:100,rows:24});s(e.id),await a()}catch(e){mp.error(e instanceof Error?e.message:`The terminal did not start.`)}finally{l(!1)}},[a]),g=(0,m.useCallback)(async e=>{try{await L(`terminal.close`,{id:e})}catch{}await a()},[a]),_=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!t){_.current=!1;return}!r||!r.available||r.terminals.length>0||_.current||c||(_.current=!0,h())},[t,r,c,h]);let v=t?Math.min(n,u):0;return(0,m.useEffect)(()=>{let e=document.documentElement;return v?e.style.setProperty(`--terminal-h`,`${v}px`):e.style.removeProperty(`--terminal-h`),()=>{e.style.removeProperty(`--terminal-h`)}},[v]),t?(0,V.jsxs)(`section`,{id:`terminal-drawer`,"aria-label":`Terminal`,className:`terminal-drawer relative flex shrink-0 border-t border-border`,style:{height:Math.min(n,u)},children:[(0,V.jsx)(EQ,{height:Math.min(n,u),max:u}),(0,V.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[r&&!r.available?(0,V.jsx)(`p`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:r.reason}):i?(0,V.jsx)(`p`,{role:`alert`,className:`flex h-full items-center justify-center px-6 text-center text-sm text-destructive`,children:i}):(0,V.jsxs)(m.Suspense,{fallback:(0,V.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`Loading the terminal…`}),children:[r&&f.length===0&&!c?(0,V.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`No terminal is running. Start one with New terminal.`}):null,f.map(t=>(0,V.jsx)(xQ,{id:t.id,active:t.id===p?.id,toggleKey:e,onExit:()=>void a()},t.id))]}),(0,V.jsx)(`div`,{className:`pointer-events-none absolute top-2 right-2 z-20`,children:(0,V.jsxs)(`div`,{className:`terminal-tools pointer-events-auto inline-flex items-center overflow-hidden rounded-md border border-border/80 bg-background shadow-xs`,children:[(0,V.jsx)(CQ,{label:`New terminal`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`New terminal`,disabled:c||r?.available===!1,onClick:()=>void h(),className:SQ,children:(0,V.jsx)(ug,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,V.jsx)(CQ,{label:`End this terminal`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`End this terminal`,disabled:!p,onClick:()=>p&&void g(p.id),className:SQ,children:(0,V.jsx)(Wg,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,V.jsx)(CQ,{label:`Hide terminal`,hint:e,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Hide terminal`,onClick:()=>dQ(!1),className:SQ,children:(0,V.jsx)(im,{"aria-hidden":`true`,className:`size-3.5`})})})]})})]}),f.length>1?(0,V.jsx)(`nav`,{"aria-label":`Terminals`,className:`flex w-36 shrink-0 flex-col gap-0.5 overflow-y-auto border-l border-border px-1 pt-10 pb-1`,children:f.map(e=>(0,V.jsxs)(`button`,{type:`button`,"aria-current":e.id===p?.id?`true`:void 0,onClick:()=>s(e.id),className:J(`flex h-6 min-w-0 items-center gap-1.5 rounded px-1.5 text-left text-xs text-muted-foreground outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-accent aria-[current=true]:text-foreground`,!e.alive&&`opacity-60`),children:[(0,V.jsx)(Ig,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.title}),e.alive?null:(0,V.jsx)(`span`,{className:`sr-only`,children:`, ended`})]},e.id))}):null]}):null}function OQ(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 kQ(){let[e,t]=(0,m.useState)(``),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1);async function o(e){a(!0),r(void 0),e&&(window.location.hash=`token=${encodeURIComponent(e)}`),await we()?window.location.reload():(r(e?`That link did not sign in. Copy the link from Pi and try again.`:`Paste the link from Pi below.`),a(!1))}function s(t){t.preventDefault(),o(OQ(e))}return(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-y-auto p-6`,children:(0,V.jsxs)(`form`,{onSubmit:s,className:`glass flex min-h-0 w-full max-w-md flex-col gap-4 rounded-xl p-6`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(uh,{className:`size-5`,"aria-hidden":`true`}),(0,V.jsx)(`h1`,{className:`text-base font-medium`,children:`Sign in to bot-lobby`})]}),(0,V.jsxs)(`p`,{className:`break-words text-sm text-muted-foreground`,children:[`Pi printed a link when it started (or run `,(0,V.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,V.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,V.jsx)(`span`,{className:`font-medium`,children:`Lobby link or token`}),(0,V.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,V.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:n}):null,(0,V.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,V.jsx)(Y,{type:`button`,variant:`ghost`,disabled:i,onClick:()=>void o(void 0),children:`Retry`}),(0,V.jsx)(Y,{type:`submit`,disabled:i||!e.trim(),children:`Sign in`})]})]})})}var AQ=.6;function jQ(e,t,n={}){return{initial:e?void 0:!1,animate:t,transition:{duration:AQ,...n}}}var MQ=(e,t)=>[0,Math.max(e,.001),Math.min(Math.max(t,e+.01),.999),1];function NQ(e,t=0,n=1){return jQ(e,{pathLength:[0,0,1,1],strokeOpacity:[0,0,1,1]},{pathLength:{duration:AQ,times:MQ(t,n),ease:`easeInOut`},strokeOpacity:{duration:AQ,times:MQ(t,t+.02)}})}function PQ(e,t){return jQ(e,{scale:[0,0,1.3,1]},{times:MQ(t,t+.18),ease:`easeOut`})}function FQ(e,t,n=1.3){return jQ(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 IQ=(e=.5,t=.5)=>({transformBox:`fill-box`,originX:e,originY:t});function LQ({play:e}){return(0,V.jsxs)($f.g,{style:IQ(.1,.9),...jQ(e,{rotate:[0,-12,8,-4,0],scale:[1,1.12,.96,1.02,1]},{ease:`easeInOut`}),children:[(0,V.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,V.jsx)($f.circle,{cx:t,cy:11,r:1.15,fill:`currentColor`,stroke:`none`,...jQ(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 RQ({play:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($f.path,{d:`M13 5h8`,...NQ(e,.15,.45)}),(0,V.jsx)($f.path,{d:`M13 12h8`,...NQ(e,.3,.6)}),(0,V.jsx)($f.path,{d:`M13 19h8`,...NQ(e,.45,.75)}),(0,V.jsx)($f.path,{d:`m3 17 2 2 4-4`,...NQ(e,.35,.7)}),(0,V.jsx)($f.path,{d:`m3 7 2 2 4-4`,...NQ(e,0,.35)})]})}function zQ({play:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($f.circle,{cx:6,cy:19,r:3,style:IQ(),...FQ(e,0)}),(0,V.jsx)($f.path,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,...NQ(e,.1,.7)}),(0,V.jsx)($f.circle,{cx:18,cy:5,r:3,style:IQ(),...PQ(e,.62)})]})}function BQ({play:e}){return(0,V.jsx)($f.g,{style:IQ(),...jQ(e,{rotate:[0,-14,10,-6,0],scale:[1,1.18,.94,1.04,1]},{duration:.5,ease:`easeInOut`}),children:(0,V.jsx)($f.path,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,fill:`currentColor`,...jQ(e,{fillOpacity:[0,.85,0]},{duration:.5,times:[0,.2,1]})})})}function VQ({play:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($f.circle,{cx:12,cy:12,r:10,style:IQ(),...jQ(e,{scale:[1,1,1.4],strokeOpacity:[0,.5,0]},{times:[0,.25,1],ease:`easeOut`})}),(0,V.jsx)($f.circle,{cx:12,cy:12,r:10,style:IQ(),...jQ(e,{scale:[1,.86,1.06,1]},{times:[0,.25,.55,1],ease:`easeInOut`})}),(0,V.jsx)($f.circle,{cx:12,cy:12,r:1,fill:`currentColor`,style:IQ(),...jQ(e,{scale:[1,2.4,.8,1]},{times:[0,.3,.6,1],ease:`easeInOut`})})]})}function HQ({play:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($f.circle,{cx:6,cy:6,r:3,style:IQ(),...FQ(e,0)}),(0,V.jsx)($f.line,{x1:6,x2:6,y1:9,y2:21,...NQ(e,.05,.45)}),(0,V.jsx)($f.path,{d:`M13 6h3a2 2 0 0 1 2 2v7`,...NQ(e,.2,.62)}),(0,V.jsx)($f.circle,{cx:18,cy:18,r:3,style:IQ(),...PQ(e,.58)})]})}function UQ({play:e}){return(0,V.jsxs)($f.g,{style:IQ(),...jQ(e,{scaleX:[1,.55,1.08,1],y:[0,-1,0,0]},{times:[0,.35,.65,1],ease:`easeInOut`}),children:[(0,V.jsx)($f.path,{d:`M12 5v16`,style:IQ(),...jQ(e,{scaleY:[1,1.12,1,1]},{times:[0,.35,.65,1]})}),(0,V.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 WQ={lobby:LQ,tasks:RQ,plan:zQ,quickfix:BQ,issues:VQ,git:HQ,knowledge:UQ};function GQ({id:e,play:t,className:n}){let r=WQ[e];return r?(0,V.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:J(`overflow-visible`,n),children:(0,V.jsx)(r,{play:t})},t):null}function KQ(e){return/(\d)$/.exec(e)?.[1]}var qQ=160;function JQ(e){let t=kf(),[n,r]=(0,m.useState)(0),i=(0,m.useRef)(0),a=(0,m.useCallback)(()=>{t||performance.now()<i.current||(i.current=performance.now()+AQ*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,qQ);return()=>window.clearTimeout(n)},[e,a]),{play:n,onPointerEnter:(0,m.useCallback)(e=>{e.pointerType!==`touch`&&a()},[a])}}var YQ=(0,m.forwardRef)(function({tab:e,active:t},n){let r=KQ(e.key),{play:i,onPointerEnter:a}=JQ(t);return(0,V.jsxs)(PO,{children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.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:J(`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,V.jsx)(GQ,{id:e.id,play:i,className:J(`size-3.5 shrink-0 transition-colors duration-200`,t&&`text-primary`)}),r?(0,V.jsx)(`span`,{"aria-hidden":`true`,className:J(`text-[0.72rem] font-semibold tabular-nums transition-colors duration-200`,t?`text-primary`:`text-muted-foreground/75`),children:r}):null,(0,V.jsx)(`span`,{children:e.label})]})}),(0,V.jsxs)(IO,{children:[e.label,` `,(0,V.jsx)(KD,{chord:e.key})]})]})}),XQ=1.5;function ZQ(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 QQ(e,t){let n=e.right-e.left,{height:r}=e,i=XQ/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 $Q(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}`),QQ(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 e$={type:`spring`,visualDuration:.12,bounce:0},t$={type:`spring`,visualDuration:.17,bounce:.15,delay:.015},n$={type:`spring`,visualDuration:.17,bounce:.05,delay:.07},r$={type:`spring`,visualDuration:.22,bounce:.25},i$={type:`spring`,visualDuration:.2,bounce:0},a$={type:`spring`,stiffness:900,damping:18,velocity:45,restDelta:.02,restSpeed:1},o$=(()=>{let e=jr({keyframes:[0,1],visualDuration:r$.visualDuration,bounce:r$.bounce}),t=0;for(;t<1e3&&e.next(t).value<.97;)t+=4;return t/1e3})(),s$={type:`spring`,visualDuration:.28,bounce:.6};function c$(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);ZQ(r.current,t),ZQ(i.current,void 0),$Q(a.current,t,`left`,1),$Q(o.current,void 0,`left`,0);for(let e of c.current)e&&(e.style.width=`0px`);qz()},[p,h]),_=(0,m.useCallback)((e,t)=>{let n=p(e),m=p(t);if(!n||!m)return g(t);h(),Kz(),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);ZQ(i.current,n,_>0?n.left+e:n.left,_>0?n.right:n.right-e),$Q(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));ZQ(r.current,d,_>0?d.left:d.right-f,_>0?d.left+f:d.right,Math.min(1,T.squash)),$Q(a.current,d,S,T.rung)},O=(e,t,n,r,i=1)=>{let a=Qf(t,i,{...n,onUpdate:t=>{T[e]=t,r?.(t),D()}});return u.current.push(a),a},k=!1,ee=()=>{if(k)return;k=!0;let e=O(`filled`,0,r$,e=>{d.current=e});e.then(()=>{l.current===t&&qz()}),O(`squash`,.8,s$),O(`rung`,0,i$,e=>{f.current=e}),O(`budge`,0,{...a$,delay:o$},void 0,0),Promise.all([e,...u.current]).then(()=>{l.current===t&&u.current.includes(e)&&g(t)})};O(`drained`,T.drained,e$),O(`unrung`,T.unrung,e$),O(`head`,0,t$,e=>{e>=w&&ee()}),O(`tail`,0,n$),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 l$=(0,m.forwardRef)(function({which:e},t){return(0,V.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,V.jsx)(`path`,{pathLength:1,strokeWidth:XQ,strokeLinecap:`round`,className:`stroke-tab-rim`}),(0,V.jsx)(`path`,{pathLength:1,strokeWidth:XQ,strokeLinecap:`round`,className:`stroke-tab-rim`})]})});function u$(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 d$({tabs:e,activeId:t,onSelect:n}){let{track:r,fill:i,drain:a,ring:o,unring:s,cells:c,liquids:l}=c$(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){qO()&&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];YO.active=!0,YO.to=o.id,window.setTimeout(()=>{YO.active=!1,YO.to=void 0},3e3),n(o.id),c.current[o.id]?.focus({preventScroll:!0})}return(0,V.jsx)(`div`,{ref:u,onScroll:p,style:{maskImage:u$(d),WebkitMaskImage:u$(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,V.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,V.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,V.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,V.jsx)(l$,{ref:s,which:`unring`}),(0,V.jsx)(l$,{ref:o,which:`ring`}),e.map((e,n)=>(0,V.jsxs)(m.Fragment,{children:[n>0?(0,V.jsxs)(`span`,{"aria-hidden":`true`,"data-tab-link":!0,className:`relative h-[2px] w-3.5 shrink-0 sm:w-4`,children:[(0,V.jsx)(`span`,{className:`absolute inset-0 border-t-2 border-dotted border-input`}),(0,V.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,V.jsx)(YQ,{ref:t=>{c.current[e.id]=t},tab:e,active:e.id===t})]},e.id))]})})}function f$({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(qV(ZV(e)));for(let e of n)e.pending&&e.source!==`LOBBY`&&i.add(e.source===`MASTER`?`Oracle`:qV(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 p$(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}var m$=6,h$=`bot-lobby.orb`,g$=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=1;function _$(e,t,n,r){let i=e=>e+m$,a=(e,t)=>Math.max(e+m$,e+t-r-m$);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 v$(e,t,n,r){let i=e=>Math.max(1,e-r),a=_$(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 y$(e,t,n){return _$(t.left+e.fx*Math.max(0,t.width-n),t.top+e.fy*Math.max(0,t.height-n),t,n)}function b$(e){if(e)try{let t=JSON.parse(e);return g$(t.fx)&&g$(t.fy)?{fx:t.fx,fy:t.fy}:void 0}catch{return}}function x$(){try{return b$(localStorage.getItem(h$))}catch{return}}function S$(e){try{localStorage.setItem(h$,JSON.stringify(e))}catch{}}var C$=5,w$=16;function T$(e){return{left:e.left,top:e.top,width:e.width,height:e.height}}function E$(){let e=document.getElementById(`main`)?.getBoundingClientRect();return e?T$(e):void 0}function D$(e,t){return!e||!t?e===t:e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function O$(){let[e,t]=(0,m.useState)(()=>E$());return(0,m.useEffect)(()=>{let e=()=>{let e=E$();t(t=>D$(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 k$=(0,m.forwardRef)(function({spotlight:e,thinking:t,busy:n=[],tone:r,expanded:i,hidden:a,shortcut:o,onOpen:s},c){let l=O$(),[u,d]=(0,m.useState)(x$),[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?y$(u,l,y.current):void 0),x=(0,m.useCallback)((e,t)=>{let n=E$();if(!n)return;let r=v$(e,t,n,y.current);d(r),S$(r)},[]);(0,m.useEffect)(()=>{l&&p(e=>e&&_$(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)<C$)return;t.moved=!0;let i=E$();i&&p(_$(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:w$,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?qV(e):E?p$(n):void 0,O=n.length===1&&!n[0].includes(`background`)?n[0]:void 0,k=e??(E?O:void 0),ee=e?`${t.map(qV).join(`, `)} thinking. `:E?`${n.join(`, `)} at work. `:``,te=b&&l?b.x-l.left<140:!1,A={"--orb":r,...b?{left:b.x,top:b.y,right:`auto`,bottom:`auto`}:{}};return(0,V.jsxs)(PO,{open:h&&!f,onOpenChange:g,children:[(0,V.jsx)(FO,{asChild:!0,children:(0,V.jsxs)(`button`,{ref:c,type:`button`,"aria-label":`Open Thinking`,"aria-description":`${ee}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:A,"data-thinking":e?``:void 0,"data-busy":E?``:void 0,"data-dragging":f?``:void 0,"data-placed":b?``:void 0,"data-flip":te||void 0,className:J(`thinking-bubble fixed z-20 touch-none rounded-full outline-none select-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,a&&`invisible`),children:[(0,V.jsx)(Fu,{initial:!1,children:D?(0,V.jsx)($f.span,{className:`orb-label`,initial:{opacity:0,x:te?-8:8,scale:.9},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:te?-8:8,scale:.9},transition:{type:`spring`,visualDuration:.3,bounce:.35},children:(0,V.jsx)(Fu,{mode:`popLayout`,initial:!1,children:(0,V.jsx)($f.span,{className:`inline-flex items-center gap-1`,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{type:`spring`,visualDuration:.28,bounce:.3},children:D},D)})},`label`):null}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`orb orb-float`,children:(0,V.jsx)(`span`,{className:`orb-icon`,children:(0,V.jsx)(GV,{source:k,strokeWidth:2.25,className:`size-3.5`})})})]})}),(0,V.jsxs)(IO,{side:`top`,children:[`Thinking `,o?(0,V.jsx)(KD,{chord:o}):null,(0,V.jsx)(`span`,{className:`text-background/70`,children:` · drag to move`})]})]})}),A$=/^\s*(?:#{1,6}\s+(.+?)\s*#*|\*\*([^*\n]{2,90}?):?\*\*:?|__([^_\n]{2,90}?):?__:?)\s*$/,j$=260,M$=200,N$=/^\s*(?:[-*+]\s|\d+[.)]\s|>|```|~~~|\|)/m;function P$(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(`
106
106
  `).trim()),n=[];continue}n.push(i)}return n.length&&t.push(n.join(`
107
- `).trim()),t.filter(Boolean)}function P$(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 F$(e){if(e.length<=A$||M$.test(e))return[e];let t=[],n=``;for(let r of P$(e.replace(/\s*\n\s*/g,` `)))n&&n.length+r.length+1>j$?(t.push(n),n=r):n=n?`${n} ${r}`:r;return n&&t.push(n),t}function I$(e){let t=e.replace(/\r\n?/g,`
107
+ `).trim()),t.filter(Boolean)}function F$(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 I$(e){if(e.length<=j$||N$.test(e))return[e];let t=[],n=``;for(let r of F$(e.replace(/\s*\n\s*/g,` `)))n&&n.length+r.length+1>M$?(t.push(n),n=r):n=n?`${n} ${r}`:r;return n&&t.push(n),t}function L$(e){let t=e.replace(/\r\n?/g,`
108
108
  `).trim().split(`
109
- `),n=[{lines:[]}],r=!1;for(let e of t){/^\s*(```|~~~)/.test(e)&&(r=!r);let t=r?null:k$.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=N$(e.lines);if(e.title)i.push({title:e.title,text:t.join(`
109
+ `),n=[{lines:[]}],r=!1;for(let e of t){/^\s*(```|~~~)/.test(e)&&(r=!r);let t=r?null:A$.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=P$(e.lines);if(e.title)i.push({title:e.title,text:t.join(`
110
110
 
111
- `)});else for(let e of t)for(let t of F$(e))i.push({text:t})}return i}var L$=4,R$=1800,z$=e=>({"--orb":e});function B$(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),R$);return()=>window.clearInterval(t)},[r,e.length]),e.length?e[t%e.length]:void 0}function V$({thought:e}){let t=(0,m.useMemo)(()=>I$(e.text),[e.text]),[n,r]=(0,m.useState)(!1),i=n?0:Math.max(0,t.length-L$),a=t.slice(i),o=qV(e.source);return(0,V.jsxs)(`li`,{className:`thought`,style:z$(XV(e.source)),"data-live":e.live||void 0,"aria-label":`${o}${e.live?`, thinking`:``}`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsxs)(`span`,{className:`thought-label`,children:[(0,V.jsx)(GV,{source:e.source,strokeWidth:2.25,className:`size-3.5`}),o]}),(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.live?(0,V.jsxs)(`span`,{className:`thought-live`,children:[`thinking`,(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`thought-ellipsis`})]}):Dk(Date.now()-e.at)}),t.length>1?(0,V.jsxs)(`span`,{className:`ml-auto text-xs text-muted-foreground tabular-nums`,children:[t.length,` steps`]}):null]}),i?(0,V.jsxs)(`button`,{type:`button`,"data-compact":!0,className:`thought-more`,onClick:()=>r(!0),children:[i,` earlier `,i===1?`step`:`steps`]}):null,(0,V.jsx)(`ol`,{className:`thought-steps`,"data-single":a.length===1||void 0,children:a.map((t,n)=>(0,V.jsxs)(`li`,{"data-current":e.live&&n===a.length-1||void 0,children:[t.title?(0,V.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t.title}):null,t.text?(0,V.jsx)(aB,{text:t.text,className:`thought-text`}):null]},i+n))})]})}function H$(e,t,n){(0,m.useEffect)(()=>{if(!e||!t)return;let r=e=>{e.defaultPrevented||e.isComposing||!nX(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 U$(e){return[...e].sort((e,t)=>Number(t.live)-Number(e.live)||t.at-e.at||t.id-e.id)}function W$({thoughts:e,collapsed:t,onToggle:n,shortcut:r,busy:i=[]}){let a=U$($V(e)),o=a.filter(e=>e.live).map(e=>e.source),s=B$(o),c=s?XV(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=nO(!t,tO.sheet),h=iO();H$(p,r,n);let g=a.length>0||i.length>0;return(0,V.jsxs)(V.Fragment,{children:[g&&(0,fy.createPortal)((0,V.jsx)(O$,{ref:u,spotlight:s,thinking:o,busy:i,tone:c,expanded:!t,hidden:h,shortcut:r,onOpen:n}),document.body),(0,V.jsxs)(JD,{open:p,onOpenChange:e=>{!e&&!t&&n()},label:`Thinking`,className:J(`thought-pane max-w-xl`,l&&`thought-pane-live`),style:z$(c),onCloseAutoFocus:e=>{e.preventDefault(),requestAnimationFrame(()=>{document.querySelector(`[role='dialog']`)||u.current?.focus()})},children:[(0,V.jsx)(`div`,{"aria-hidden":`true`,className:`thought-aura`,"data-working":l}),(0,V.jsx)(`div`,{ref:d,className:`relative min-h-0 overflow-y-auto p-4 outline-none`,role:`log`,"aria-label":`Latest thoughts`,tabIndex:0,children:a.length?(0,V.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:a.map(e=>(0,V.jsx)(V$,{thought:e},e.id))}):(0,V.jsx)(`p`,{className:`px-2 py-6 text-center text-sm text-muted-foreground`,children:`Thoughts from the oracle and every agent appear here, and only here.`})}),(0,V.jsx)(Vv,{target:d})]})]})}function G$({status:e,lobby:t}){let[n,r]=mH(`lobby.thinking`),i=MO(`sessions.list`,{},[`sessions`]);if(!e||e.panels?.thinking===!1)return null;let a=d$({oracleBusy:e.busy,runs:QV(t),activity:t?.activity??[],background:i.data?.background??[]}),o=e.keys.find(e=>e.action===`thinking`)?.label;return(0,V.jsx)(W$,{thoughts:t?.thoughts??[],collapsed:n,onToggle:r,shortcut:o,busy:a})}var K$=/​/g;function q$(e){let t=[],n=e=>{if(e.nodeType===Node.TEXT_NODE)return(e.textContent??``).replace(K$,``);if(!(e instanceof HTMLElement))return``;let t=[...e.childNodes].map(n).join(``),i=e.tagName;return i===`BR`?`
111
+ `)});else for(let e of t)for(let t of I$(e))i.push({text:t})}return i}var R$=4,z$=1800,B$=e=>({"--orb":e});function V$(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),z$);return()=>window.clearInterval(t)},[r,e.length]),e.length?e[t%e.length]:void 0}function H$({thought:e}){let t=(0,m.useMemo)(()=>L$(e.text),[e.text]),[n,r]=(0,m.useState)(!1),i=n?0:Math.max(0,t.length-R$),a=t.slice(i),o=qV(e.source);return(0,V.jsxs)(`li`,{className:`thought`,style:B$(XV(e.source)),"data-live":e.live||void 0,"aria-label":`${o}${e.live?`, thinking`:``}`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsxs)(`span`,{className:`thought-label`,children:[(0,V.jsx)(GV,{source:e.source,strokeWidth:2.25,className:`size-3.5`}),o]}),(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.live?(0,V.jsxs)(`span`,{className:`thought-live`,children:[`thinking`,(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`thought-ellipsis`})]}):Dk(Date.now()-e.at)}),t.length>1?(0,V.jsxs)(`span`,{className:`ml-auto text-xs text-muted-foreground tabular-nums`,children:[t.length,` steps`]}):null]}),i?(0,V.jsxs)(`button`,{type:`button`,"data-compact":!0,className:`thought-more`,onClick:()=>r(!0),children:[i,` earlier `,i===1?`step`:`steps`]}):null,(0,V.jsx)(`ol`,{className:`thought-steps`,"data-single":a.length===1||void 0,children:a.map((t,n)=>(0,V.jsxs)(`li`,{"data-current":e.live&&n===a.length-1||void 0,children:[t.title?(0,V.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t.title}):null,t.text?(0,V.jsx)(aB,{text:t.text,className:`thought-text`}):null]},i+n))})]})}function U$(e,t,n){(0,m.useEffect)(()=>{if(!e||!t)return;let r=e=>{e.defaultPrevented||e.isComposing||!nX(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 W$(e){return[...e].sort((e,t)=>Number(t.live)-Number(e.live)||t.at-e.at||t.id-e.id)}function G$({thoughts:e,collapsed:t,onToggle:n,shortcut:r,busy:i=[]}){let a=W$($V(e)),o=a.filter(e=>e.live).map(e=>e.source),s=V$(o),c=s?XV(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=nO(!t,tO.sheet),h=iO();U$(p,r,n);let g=a.length>0||i.length>0;return(0,V.jsxs)(V.Fragment,{children:[g&&(0,fy.createPortal)((0,V.jsx)(k$,{ref:u,spotlight:s,thinking:o,busy:i,tone:c,expanded:!t,hidden:h,shortcut:r,onOpen:n}),document.body),(0,V.jsxs)(JD,{open:p,onOpenChange:e=>{!e&&!t&&n()},label:`Thinking`,className:J(`thought-pane max-w-xl`,l&&`thought-pane-live`),style:B$(c),onCloseAutoFocus:e=>{e.preventDefault(),requestAnimationFrame(()=>{document.querySelector(`[role='dialog']`)||u.current?.focus()})},children:[(0,V.jsx)(`div`,{"aria-hidden":`true`,className:`thought-aura`,"data-working":l}),(0,V.jsx)(`div`,{ref:d,className:`relative min-h-0 overflow-y-auto p-4 outline-none`,role:`log`,"aria-label":`Latest thoughts`,tabIndex:0,children:a.length?(0,V.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:a.map(e=>(0,V.jsx)(H$,{thought:e},e.id))}):(0,V.jsx)(`p`,{className:`px-2 py-6 text-center text-sm text-muted-foreground`,children:`Thoughts from the oracle and every agent appear here, and only here.`})}),(0,V.jsx)(Vv,{target:d})]})]})}function K$({status:e,lobby:t}){let[n,r]=mH(`lobby.thinking`),i=MO(`sessions.list`,{},[`sessions`]);if(!e||e.panels?.thinking===!1)return null;let a=f$({oracleBusy:e.busy,runs:QV(t),activity:t?.activity??[],background:i.data?.background??[]}),o=e.keys.find(e=>e.action===`thinking`)?.label;return(0,V.jsx)(G$,{thoughts:t?.thoughts??[],collapsed:n,onToggle:r,shortcut:o,busy:a})}var q$=/​/g;function J$(e){let t=[],n=e=>{if(e.nodeType===Node.TEXT_NODE)return(e.textContent??``).replace(q$,``);if(!(e instanceof HTMLElement))return``;let t=[...e.childNodes].map(n).join(``),i=e.tagName;return i===`BR`?`
112
112
  `: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(`
113
113
  `);return t.push([...e.childNodes].map(n).join(``)),t.join(``).replace(/\n{3,}/g,`
114
114
 
115
- `).trim()}function J$(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(K$,``)===``}function Y$(e){let t=window.getSelection()?.anchorNode,n=t instanceof HTMLElement?t:t?.parentElement;return!!(n?.closest(`li`)&&e.contains(n))}function X$(e){return e.replace(/[&<>"]/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`})[e]??e)}function Z$(e){if(e!==`code`){document.execCommand(e);return}let t=window.getSelection()?.toString()??``;document.execCommand(`insertHTML`,!1,t?`<code>${X$(t)}</code>`:`<code>​</code>`)}var Q$=[{format:`bold`,label:`Bold`,keys:`Ctrl+B`,icon:Jp},{format:`italic`,label:`Italic`,keys:`Ctrl+I`,icon:ch},{format:`code`,label:`Code`,keys:`Ctrl+E`,icon:Pm},{format:`insertUnorderedList`,label:`Bulleted list`,icon:Sh},{format:`insertOrderedList`,label:`Numbered list`,icon:bh}],$$=(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=q$(e);p(t===``&&!e.querySelector(`li`)),i(t,t?e.innerHTML:``)},[i]);(0,m.useEffect)(()=>{if(!u)return;let e=()=>g(Object.fromEntries(Q$.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(),Z$(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(Y$(t))return;e.preventDefault(),o();return}e.key===`ArrowUp`&&J$(t)&&(e.preventDefault(),s())}return(0,V.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,V.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:()=>{d(!1),a(!1)},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,V.jsxs)(`div`,{role:`toolbar`,"aria-label":`Formatting`,"aria-hidden":!u,className:J(`q-own-bar flex items-center gap-0.5 px-2 pb-1.5`,!u&&`pointer-events-none`),children:[Q$.map(({format:e,label:t,keys:n,icon:r})=>(0,V.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,V.jsx)(r,{"aria-hidden":`true`,className:`size-3.5`})},e)),(0,V.jsx)(`span`,{className:`ms-auto pe-1 text-2xs text-muted-foreground`,children:`Enter answers · Shift+Enter new line`})]})]})});function e1(e){return e?e.options.some(OK)?`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 t1=/\s*\(recommended\)\s*$/i,n1=1200,r1=`Type something.`;function i1(e){return{text:e.replace(t1,``),recommended:t1.test(e)}}function a1({label:e}){let{text:t,recommended:n}=i1(e);return(0,V.jsxs)(`span`,{className:`leading-snug break-words`,children:[t,n?(0,V.jsx)(`span`,{className:`ms-1 font-medium text-primary`,children:`(Recommended)`}):null]})}function o1({multi:e,on:t}){return(0,V.jsxs)(`span`,{"aria-hidden":`true`,className:J(`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,V.jsx)(nm,{className:J(e?`size-3`:`hidden`)}):null,t&&!e?(0,V.jsx)(`span`,{className:`size-2 rounded-full bg-primary-foreground`}):null]})}function s1({option:e,index:t,multi:n,name:r,selected:i,onToggle:a,onFocusOption:o}){return(0,V.jsxs)(`div`,{className:`grid gap-1`,children:[(0,V.jsxs)(`label`,{className:J(`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,V.jsx)(`input`,{type:n?`checkbox`:`radio`,name:r,"data-nav":``,"data-option":t,className:`sr-only`,checked:i,onChange:a,onFocus:o}),(0,V.jsx)(o1,{multi:n,on:i}),(0,V.jsx)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:(0,V.jsxs)(`span`,{className:`flex gap-1.5`,children:[(0,V.jsxs)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,V.jsx)(a1,{label:e.label})]})})]}),e.description?(0,V.jsx)(aB,{text:e.description,className:`px-3 text-muted-foreground`}):null]})}function c1({option:e,onExpand:t}){return!e||!OK(e)?null:(0,V.jsxs)(`div`,{className:`card-flat flex min-w-0 max-w-full flex-col gap-2 rounded-lg border p-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsxs)(`p`,{className:`min-w-0 truncate text-xs font-medium text-muted-foreground`,children:[`Preview · `,i1(e.label).text]}),(0,V.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,onClick:t,"aria-keyshortcuts":`E`,title:`Expand · E`,className:`-my-1 shrink-0`,children:[(0,V.jsx)(Eh,{"aria-hidden":`true`}),`Expand`]})]}),e.image?(0,V.jsx)(`img`,{src:F(e.image),alt:``,loading:`lazy`,className:`max-h-64 w-full rounded-lg border object-contain`}):null,e.htmlPreview?(0,V.jsx)(wK,{preview:e.htmlPreview,label:i1(e.label).text,frameWidth:n1,onOpen:t,className:`h-auto aspect-[3/2]`}):null,e.preview?(0,V.jsx)(aB,{text:e.preview,className:`text-xs`}):null]})}function l1({option:e,index:t,multi:n,name:r,selected:i,active:a,onToggle:o,onFocusOption:s}){let{text:c,recommended:l}=i1(e.label),u=l?`${c} (Recommended)`:c;return(0,V.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,V.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,V.jsx)(`span`,{"aria-hidden":`true`,className:J(`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,V.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 u1={type:`spring`,visualDuration:.2,bounce:.12},d1={type:`spring`,visualDuration:.2,bounce:.04,delay:.06},f1={type:`spring`,visualDuration:.28,bounce:.55},p1={type:`spring`,visualDuration:.2,bounce:0},m1={type:`spring`,stiffness:900,damping:18,velocity:50,restDelta:.02,restSpeed:1},h1=-1;function g1(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===h1){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||o||!s){g(r===h1?void 0:n),r===h1&&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=Qf(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===h1){g(void 0),f.current();return}let e={open:0,reach:0},i=()=>p(r)??n;y(0,1,f1,t=>{e.open=t,g(i(),e.open,e.reach)}),y(0,1,{...p1,delay:.05},t=>{e.reach=t,g(i(),e.open,e.reach)});let a=t.current;a&&y(0,0,{...m1,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===h1?void 0:a,t,t)}),y(0,1,u1,e=>{m.head=e,b(),e>.85&&x()}),y(0,1,d1,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===h1?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 _1({option:e,position:t,count:n,chosen:r,onExpand:i,panel:a,dim:o}){if(!e)return null;let{text:s,recommended:c}=i1(e.label),l=OK(e);return(0,V.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,V.jsxs)(`div`,{"aria-live":`polite`,className:J(`q-panel-body grid min-w-0 gap-4`,l?`grid-cols-[minmax(0,1fr)_minmax(0,1.25fr)]`:``),children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2.5 py-0.5`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5`,children:[(0,V.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,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,V.jsxs)(`p`,{className:`text-2xs font-medium tracking-wide text-muted-foreground uppercase`,children:[`Option `,t+1,` of `,n]}),(0,V.jsxs)(`p`,{className:`text-base font-semibold break-words`,children:[s,c?(0,V.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,V.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,V.jsx)(nm,{"aria-hidden":`true`,className:`size-3.5`}),`Chosen`]}):null]}),e.description?(0,V.jsx)(aB,{text:e.description,className:`q-panel-text min-w-0 text-sm leading-relaxed`}):(0,V.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`No further detail.`})]}),l?(0,V.jsx)(c1,{option:e,onExpand:i}):null]},t)})}function v1({primary:e,primaryLabel:t,disabled:n,submitting:r,onCancel:i,intent:a}){return(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsx)(Y,{type:`button`,variant:`ghost`,onClick:i,children:`Cancel`}),a?(0,V.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,V.jsxs)(`span`,{className:`q-intent-text flex min-w-0 items-center gap-1.5`,children:[(0,V.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:a.lead}),a.empty?null:(0,V.jsx)(`span`,{className:`truncate font-medium`,children:a.text})]},`${a.lead}${a.text}`)}):null,(0,V.jsx)(Y,{type:e,disabled:n||r,children:r?`Sending…`:t})]})}function y1(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=>i1(e).text).join(`, `)}}function b1(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 x1({questions:e,picks:t,own:n,index:r,onGo:i}){return e.length===1?(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e[0]?.header}):(0,V.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,V.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:J(`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,V.jsxs)(`span`,{className:`min-w-0 break-words text-start`,children:[a+1,` `,e.header]}),o?(0,V.jsx)(nm,{className:`size-3 shrink-0`,"aria-hidden":`true`}):null]},a)})})}function S1({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,ee]=(0,m.useState)({}),te=(0,m.useRef)(null),A=(0,m.useRef)(null),j=(0,m.useRef)(null),M=e[s],ne=v[s]??[],N=b[s]??``,re=M?.options[k[s]??ne[0]??0],ie=b1(e,v,b,s),ae=M?.multiSelect===!0,oe=Math.max(0,M?.options.indexOf(re)??0),se=w||N.trim()!==``,ce=se?h1:oe,le=g1(A,j,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?.(e1(M)),[M,o]),(0,m.useEffect)(()=>{let e=te.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&&(ee(e=>({...e,[s]:g.current})),te.current?.querySelector(`[data-option="${g.current}"]`)?.focus())},[d]),!M)return null;let ue=M.options.some(OK);function P(e){h(Math.max(0,e)),g.current=Math.max(0,e),f(!0)}function de(e){g.current=e,f(!1)}if(d&&ue)return(0,V.jsx)(AK,{options:M.options,start:p,title:M.header||M.question,picked:ne,multi:ae,onChoose:e=>{fe(e),ae||de(e)},onClose:de,onIndex:e=>{g.current=e}},s);function fe(e){let t=ae?ne.includes(e)?ne.filter(t=>t!==e):[...ne,e]:[e];y({...v,[s]:t}),ae||(x({...b,[s]:``}),C({...S,[s]:``})),ee({...k,[s]:e})}function pe(e){let t=e instanceof HTMLInputElement&&e.dataset.option!==void 0?Number(e.dataset.option):-1;t>=0&&!ae&&fe(t)}function F(t,r){if(b1(e,t,r,s)){if(s<e.length-1){c(s+1);return}n({answers:e.map((n,i)=>b1(e,t,r,i)).filter(e=>!!e),cancelled:!1})}}function I(e){e.preventDefault(),t||F(v,b)}function me(t){t>=0&&t<e.length&&c(t)}function he(e){let n=e.target,r=te.current;if(!r||e.altKey)return;if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)){e.preventDefault(),t||F(v,b);return}if(zO(n))return;let i=BO(e.key);if(i||e.key===`Home`||e.key===`End`){e.preventDefault(),RO(r,n,i||(e.key===`Home`?`first`:`last`)),pe(document.activeElement);return}let a=VO(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)ne.length>0&&ne.includes(o)?F(v,b):fe(o);else{let e={...v,[s]:[o]},t={...b,[s]:``};y(e),x(t),C({...S,[s]:``}),F(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<=M.options.length){e.preventDefault(),fe(c-1),r.querySelector(`[data-option="${c-1}"]`)?.focus();return}e.key.toLowerCase()===`e`&&ue&&!e.ctrlKey&&!e.metaKey&&(e.preventDefault(),P(o>=0?o:k[s]??ne[0]??0))}return(0,V.jsxs)(`form`,{ref:te,className:`flex min-w-0 flex-col gap-3`,onSubmit:I,onKeyDown:he,children:[(0,V.jsx)(x1,{questions:e,picks:v,own:b,index:s,onGo:c}),(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.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,V.jsx)(aB,{text:M.question,className:`mt-1 text-base font-medium`})]}),(0,V.jsxs)(`div`,{className:`relative grid min-w-0 grid-cols-[2.25rem_minmax(0,1fr)] gap-x-3`,children:[(0,V.jsxs)(`div`,{ref:A,role:ae?`group`:`radiogroup`,"aria-label":`Options`,className:`q-rail relative flex min-w-0 flex-col justify-evenly py-2`,children:[(0,V.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,V.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,V.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,V.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`}),M.options.map((e,t)=>(0,V.jsx)(l1,{option:e,index:t,multi:ae,name:`question-${s}`,selected:ne.includes(t),active:ce===t,onToggle:()=>fe(t),onFocusOption:()=>ee({...k,[s]:t})},t))]}),(0,V.jsx)(_1,{panel:j,option:re,position:oe,count:M.options.length,chosen:!se&&ne.includes(oe),dim:se,onExpand:()=>P(oe)})]}),(0,V.jsx)(`div`,{className:`q-own-wrap mx-auto w-full`,children:(0,V.jsx)($$,{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:T,onSubmit:()=>{t||F(v,b)},onUp:()=>{let e=te.current;e&&RO(e,O.current?.element??null,-1)}},s)}),(0,V.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,V.jsx)(`span`,{children:ae?`Pick several`:`Pick one`}),(0,V.jsx)(qD,{chord:`↑↓`,children:`move`}),(0,V.jsx)(qD,{chord:ae?`Space`:`Enter`,children:ae?`pick`:`choose`}),ae?(0,V.jsx)(qD,{chord:`Enter`,children:`next`}):null,e.length>1?(0,V.jsx)(qD,{chord:`←→`,children:`question`}):null,ue?(0,V.jsx)(qD,{chord:`E`,children:`expand mockups`}):null,(0,V.jsx)(qD,{chord:`Esc`,children:`later`})]}),(0,V.jsx)(v1,{primary:`submit`,primaryLabel:s<e.length-1?`Next`:`Answer`,disabled:!ie,submitting:t,onCancel:r,intent:y1(ie)})]})}function C1(e,t,n){let r=e.currentTarget,i=e.target;if(e.altKey||zO(i))return;let a=BO(e.key);if(a){e.preventDefault(),RO(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 w1({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,V.jsxs)(`form`,{ref:o,className:`flex min-w-0 flex-col gap-3`,onSubmit:e=>{e.preventDefault(),i&&n(i)},onKeyDown:r=>C1(r,e.options.length,(r,i)=>{let o=e.options[r];o!==void 0&&(a(o),i&&!t&&n(o))}),children:[(0,V.jsx)(aB,{text:e.title,className:`text-base`}),(0,V.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.options.map((e,t)=>(0,V.jsx)(s1,{option:{label:e},index:t,multi:!1,name:`choice`,selected:i===e,onToggle:()=>a(e)},e))}),(0,V.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,V.jsx)(qD,{chord:`↑↓`,children:`move`}),(0,V.jsx)(qD,{chord:`Enter`,children:`choose`}),(0,V.jsx)(qD,{chord:`Esc`,children:`later`})]}),(0,V.jsx)(v1,{primary:`submit`,primaryLabel:`Choose`,disabled:!i,submitting:t,onCancel:r})]})}function T1({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,V.jsxs)(`div`,{ref:r,tabIndex:-1,"data-autofocus":``,onKeyDown:i,className:`flex min-w-0 flex-col gap-3 outline-none`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(aB,{text:e.question,className:`text-base`}),e.detail?(0,V.jsx)(aB,{text:e.detail,className:`mt-1 text-muted-foreground`}):null]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsxs)(`p`,{className:`flex items-center gap-x-4 text-xs text-muted-foreground`,children:[(0,V.jsx)(qD,{chord:`Y`,children:`yes`}),(0,V.jsx)(qD,{chord:`N`,children:`no`}),(0,V.jsx)(qD,{chord:`Esc`,children:`later`})]}),(0,V.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(Y,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n(!1),children:`No`}),(0,V.jsx)(Y,{type:`button`,disabled:t,onClick:()=>n(!0),children:t?`Sending…`:`Yes`})]})]})]})}function E1({view:e,submitting:t,onAnswer:n,onCancel:r}){let[i,a]=(0,m.useState)(``);return(0,V.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-3`,onSubmit:e=>{e.preventDefault(),i.trim()&&n(i.trim())},children:[(0,V.jsx)(aB,{text:e.question,className:`text-base`}),(0,V.jsx)(Ck,{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??r1,"aria-label":e.question,rows:3,className:`min-h-9 resize-none text-sm`}),(0,V.jsxs)(`p`,{className:`flex items-center gap-x-4 text-xs text-muted-foreground`,children:[(0,V.jsx)(qD,{chord:`Enter`,children:`answer`}),(0,V.jsx)(qD,{chord:`Shift+Enter`,children:`new line`}),(0,V.jsx)(qD,{chord:`Esc`,children:`later`})]}),(0,V.jsx)(v1,{primary:`submit`,primaryLabel:`Answer`,disabled:!i.trim(),submitting:t,onCancel:r})]})}function D1({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,V.jsxs)(`form`,{ref:l,className:`flex min-w-0 flex-col gap-3`,onSubmit:u,onKeyDown:r=>{e.method===`select`&&C1(r,s.length,(e,r)=>{let i=s[e];i!==void 0&&(o(i),r&&!t&&n({value:i}))})},children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.title}),e.message?(0,V.jsx)(aB,{text:e.message,className:`mt-1 text-base`}):null]}),e.method===`select`?(0,V.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.map((e,t)=>(0,V.jsx)(s1,{option:{label:e},index:t,multi:!1,name:`dialog`,selected:a===e,onToggle:()=>o(e)},e))}):null,e.method===`input`||e.method===`editor`?(0,V.jsx)(Ck,{value:r,onChange:e=>i(e.target.value),placeholder:e.placeholder??r1,"aria-label":e.title,rows:e.method===`editor`?4:2,className:`min-h-9 resize-none text-sm`}):null,(0,V.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,V.jsx)(Y,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n({cancelled:!0}),children:`Cancel`}),e.method===`confirm`?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Y,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n({confirmed:!1}),children:`No`}),(0,V.jsx)(Y,{type:`button`,disabled:t,onClick:()=>n({confirmed:!0}),children:t?`Sending…`:`Yes`})]}):(0,V.jsx)(Y,{type:`submit`,disabled:!c||t,children:t?`Sending…`:`Answer`})]})]})}function O1(e){let{view:t}=e;return t.kind===`questionnaire`?(0,V.jsx)(S1,{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,V.jsx)(w1,{...e,view:t}):t.kind===`confirm`?(0,V.jsx)(T1,{...e,view:t}):t.kind===`text`?(0,V.jsx)(E1,{...e,view:t}):(0,V.jsx)(D1,{...e,dialog:t.dialog})}function k1(e){return typeof e==`object`&&e?e:{}}function A1(e){return typeof e==`string`?e.trim():``}function j1(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function M1(e){let t=k1(e),n=A1(t.label);if(!n)return;let r=A1(t.description),i=A1(t.preview),a=A1(t.image),o=yK(t.htmlPreview);return{label:n,...r?{description:r}:{},...i?{preview:i}:{},...a?{image:a}:{},...o?{htmlPreview:o}:{}}}function N1(e){let t=k1(e),n=A1(t.question);if(!n)return;let r=(Array.isArray(t.options)?t.options:[]).map(M1).filter(e=>!!e);return{question:n,header:A1(t.header)||`Question`,options:r,...t.multiSelect===!0?{multiSelect:!0}:{}}}function P1(e){let t=k1(e),n=A1(t.method);if(n!==`select`&&n!==`confirm`&&n!==`input`&&n!==`editor`)return;let r=A1(t.message),i=j1(t.options),a=A1(t.placeholder),o=A1(t.prefill);return{id:A1(t.id),method:n,title:A1(t.title)||`Answer`,...r?{message:r}:{},...i.length>0?{options:i}:{},...a?{placeholder:a}:{},...o?{prefill:o}:{}}}function F1(e){let t=(Array.isArray(e.questions)?e.questions:[]).map(N1).filter(e=>!!e);return t.length>0?{kind:`questionnaire`,questions:t}:void 0}function I1(e){return{kind:`choose`,title:A1(e.title)||`Choose an option`,options:j1(e.options)}}function L1(e){let t=A1(e.question)||A1(e.title)||`Continue?`,n=A1(e.detail)||A1(e.message);return{kind:`confirm`,question:t,...n?{detail:n}:{}}}function R1(e){let t=A1(e.question)||A1(e.title)||`Type an answer`,n=A1(e.placeholder);return{kind:`text`,question:t,...n?{placeholder:n}:{}}}function z1(e){let t=k1(e.payload);if(e.kind===`questionnaire`)return F1(t);if(e.kind===`choose`)return I1(t);if(e.kind===`confirm`)return L1(t);if(e.kind===`text`)return R1(t);let n=P1(t.dialog);return n?{kind:`sessionDialog`,dialog:n}:void 0}var B1={md:`max-w-3xl`,lg:`max-w-4xl max-h-[min(88svh,52rem)]`,xl:`max-w-5xl max-h-[min(90svh,58rem)]`};function V1({submitting:e,onKeep:t,onLeave:n}){return(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,role:`alert`,children:[(0,V.jsx)(`p`,{className:`text-sm`,children:`Leave without answering? The oracle will not guess for you.`}),(0,V.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,V.jsx)(Y,{type:`button`,variant:`outline`,onClick:t,children:`Keep answering`}),(0,V.jsx)(Y,{type:`button`,disabled:e,onClick:n,children:e?`Leaving…`:`Leave`})]})]})}function H1({count:e,onOpen:t}){return(0,V.jsxs)(Y,{type:`button`,variant:`soft`,onClick:t,"aria-label":`${e} question${e===1?``:`s`} waiting — open`,className:`gap-1.5 text-warning`,children:[(0,V.jsx)(bm,{"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tabular-nums`,children:e}),(0,V.jsx)(`span`,{children:`waiting`})]})}function U1({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?z1(g):void 0,v=h>0&&!r,y=nO(v,tO.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 xe&&e.code===`question_withdrawn`?mp(oO):mp.error(e instanceof Error?e.message:t)}finally{c(!1)}}let S=g?.from?`${g.from} asks`:`A question`;return(0,V.jsx)(JD,{open:v&&y&&!!g,label:`Question from the lobby`,dismissOnBackdrop:!1,onOpenChange:e=>{e||(l?u(!1):a?o(!1):i(!0))},className:J(`transition-[max-width] duration-300 ease-snap`,l?`h-[min(92svh,60rem)] max-h-[min(92svh,60rem)] max-w-7xl`:B1[_?.kind===`questionnaire`?f:`md`]),children:g?(0,V.jsxs)(`section`,{"aria-label":`Question from the lobby`,className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,V.jsxs)(`header`,{className:J(`flex items-center gap-3 px-4 pt-4 pb-2`,l&&`hidden`),children:[(0,V.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,V.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Later: put the question away`,title:`Later · Esc`,onClick:()=>i(!0),children:(0,V.jsx)(o_,{"aria-hidden":`true`})})]}),(0,V.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,V.jsx)(V1,{submitting:s,onKeep:()=>o(!1),onLeave:()=>void x(n(g.id),`Could not leave the question`)}):(0,V.jsx)(O1,{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,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsx)(`p`,{className:` text-sm text-muted-foreground`,children:`This question cannot be shown here.`}),(0,V.jsx)(Y,{type:`button`,disabled:s,onClick:()=>void x(n(g.id),`Could not dismiss the question`),children:`Dismiss`})]})}),l?null:(0,V.jsx)(Vv,{target:d})]}):null})}var W1=2;function G1(e){let t=globalThis.EventSource;if(!t)throw Error(`EventSource is not available in this environment`);return new t(e)}function K1(e){try{return JSON.parse(e)}catch{return}}function q1(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 J1(e,t=G1){let n=t(F(`/api/events`));return e.onConnection?.(`connecting`),n.onopen=()=>e.onConnection?.(`live`),n.onerror=()=>e.onConnection?.(n.readyState===W1?`offline`:`connecting`),n.onmessage=t=>{let n=K1(t.data);n&&q1(n,e)},()=>n.close()}var Y1=2e3,X1=()=>L(`projects.list`,{});async function Z1(){let e;try{e=pe()}catch{return}if(e&&!ye(e))try{ve((await X1()).projects)}catch{}}function Q1(){let e=(0,m.useRef)(void 0),t=(0,m.useRef)(void 0),n=(0,m.useCallback)(()=>{clearTimeout(t.current),e.current?.();try{pe()}catch{P.onStatus({connection:`offline`});return}e.current=J1({onHello:e=>{P.onHello(e),Z1()},onChanged:(e,t)=>P.onChanged(e,t),onFeed:e=>P.onFeedDelta(e),onReply:e=>P.onReplyDelta(e),onNotice:(e,t)=>mp[t](e),onConnection:e=>{P.onStatus({connection:e}),e===`offline`&&(clearTimeout(t.current),t.current=setTimeout(()=>{be(X1).catch(()=>!1).finally(n)},Y1))}})},[]);return(0,m.useEffect)(()=>(n(),()=>{clearTimeout(t.current),e.current?.()}),[n]),n}var $1=`bot-lobby.recoveredAt`,e0;function t0(e,t=n0()){try{e0===void 0&&(e0=Number(t?.getItem($1)??0))}catch{e0??=0}if(e0!==void 0&&e<=e0)return!1;e0=e;try{t?.setItem($1,String(e))}catch{}return!0}function n0(){try{return globalThis.sessionStorage}catch{return}}function r0(e){let t=e?.recovered?.at,n=e?.recovered?.text;(0,m.useEffect)(()=>{t!==void 0&&n&&t0(t)&&mp.success(n)},[t,n])}function i0(){let e=AO(`prompts`),t=(0,m.useCallback)(async(e,t)=>{await L(`prompts.answer`,{id:e,answer:t})},[]),n=(0,m.useCallback)(async e=>{await L(`prompts.dismiss`,{id:e})},[]);return{prompts:e.data?.prompts??[],loading:e.loading,error:e.error,answer:t,dismiss:n}}function a0(e,t,n,r,i){e===`search`?(document.querySelector(`#main input[type='search']`)??document.getElementById(`composer-text`))?.focus():e===`help`?n():e===`settings`?fO(`#/settings`):e===`thinking`?pH(`lobby.thinking`):e===`sidebar`?i():e===`terminal`?dQ():e===`activity`?t.kind===`tab`&&t.tab===`lobby`?pH(gH):fO(dO(`lobby`)):e===`nextTab`?r(1):e===`prevTab`?r(-1):e===`savePlan`&&t.kind===`tab`&&t.tab===`plan`&&U(`planner.save`,{})}var o0=`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`,s0=`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`,c0=2500;function l0(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),c0);return()=>clearTimeout(t)},[e]),e===`offline`||e===`connecting`&&t}function u0({connection:e,onRetry:t}){return l0(e)?(0,V.jsx)(DO,{onRetry:t}):null}var d0={tick:0,route:0,focus:0};window.addEventListener(`hashchange`,()=>{d0.route=++d0.tick}),document.addEventListener(`focusin`,()=>{d0.focus=++d0.tick});var f0=()=>d0.focus>d0.route;function p0(e){return e.kind===`tab`?e.tab:e.kind}function m0(){let e=pO(),t=AO(`status`),n=AO(`lobby`),{prompts:r,answer:i,dismiss:a}=i0(),{connection:o,signedOut:s}=kO(),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=(0,m.useRef)(null),p=Q1();nW();let h=t.data;r0(h);let g=!!h&&!s;(0,m.useEffect)(()=>{g&&Re()},[g]);let _=h?.tabs??[],v=h?.keys??[],y=e.kind===`tab`?e.tab:void 0,b=(0,m.useCallback)(e=>fO(dO(e)),[]),x=(0,V.jsx)(u$,{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&&fO(dO(n.id))},[_,y]),C=(0,m.useCallback)(()=>l(e=>!e),[]),w=KX();jO(aH);let[T]=mH(EZ),E=(0,m.useCallback)(()=>pH(EZ),[]),D=(0,m.useCallback)(t=>{(t!==`thinking`&&t!==`activity`||h?.panels?.[t]!==!1)&&a0(t,uO(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`)?!0:e.closest(`[data-state='closed']`)!==null},[]);lX({enabled:!!h,keys:v,tabs:_,insideApp:O,onAction:D,onTab:b});let k=(0,m.useCallback)(()=>P.onHello({}),[]),ee=e.kind===`tab`?e.tab:e.kind,te=!!h;(0,m.useEffect)(()=>{if(!te)return;let e=YO.active&&YO.to===ee;if(YO.active=!1,YO.to=void 0,e)return;let t=requestAnimationFrame(()=>{if(f0()||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)},[ee,te]);let A=Object.fromEntries(v.map(e=>[e.action,e.label])),j=!!h&&!s,M=j?(0,V.jsx)(ZZ,{hint:A.sidebar}):null,ne=(0,V.jsx)(SZ,{connection:o,projects:w,lead:M,tabs:x,extra:u&&r.length>0?(0,V.jsx)(H1,{count:r.length,onOpen:()=>d(!1)}):null,tools:j?(0,V.jsx)(CQ,{hint:A.terminal,className:s0}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(wX,{className:o0,side:`bottom`}),(0,V.jsx)(CX,{className:o0,side:`bottom`})]})});return s||!h?(0,V.jsxs)(`div`,{ref:f,className:`fixed inset-0 flex flex-col`,children:[ne,(0,V.jsx)(`main`,{className:`surface flex min-h-0 flex-1 flex-col overflow-y-auto`,children:s?(0,V.jsx)(OQ,{}):t.error?(0,V.jsx)(EO,{message:t.error,onRetry:k}):(0,V.jsx)(TO,{})})]}):(0,V.jsxs)(`div`,{ref:f,className:`app-chrome fixed inset-0 flex`,"data-sidebar":T?`folded`:`open`,children:[(0,V.jsx)(XZ,{route:e,keys:A,onHelp:C}),(0,V.jsxs)(`div`,{className:`relative flex min-w-0 flex-1 flex-col`,children:[ne,(0,V.jsxs)(`div`,{className:`app-page relative flex min-h-0 flex-1 flex-col`,children:[(0,V.jsx)(u0,{connection:o,onRetry:p}),(0,V.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,V.jsx)(`main`,{id:`main`,tabIndex:-1,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||zO(e.target)||e.target.closest(`[role='dialog'], [role='menu'], [role='listbox']`)||JO()&&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,V.jsx)($f.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:XY(e)},p0(e))}),(0,V.jsx)(_Z,{route:e,keys:A,projects:w,onHelp:C})]}),(0,V.jsx)(EQ,{toggleKey:A.terminal??"Ctrl+`"})]})]}),(0,V.jsx)(G$,{status:h,lobby:n.data}),(0,V.jsx)(U1,{prompts:r,answer:i,dismiss:a,minimized:u,onMinimize:d}),(0,V.jsx)(bX,{open:c,onOpenChange:l,keys:v,tabs:_})]})}async function h0(e){switch(e){case`status`:return L(`status.get`,{});case`lobby`:return L(`lobby.snapshot`,{});case`prompts`:return L(`prompts.list`,{});default:return}}var g0=[`status`,`lobby`,`prompts`];function _0(){let[e,t]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{let e=!0;return(async()=>{await we(),e&&(P.markUsed(g0,h0),t(!0))})(),()=>{e=!1}},[]),e}function v0(){return _0()?(0,V.jsx)(m0,{}):(0,V.jsx)(`div`,{className:`fixed inset-0 flex`,children:(0,V.jsx)(TO,{})})}var y0={info:oh,success:mm,warning:Kg,error:Em},b0={info:`Note:`,success:`Done:`,warning:`Warning:`,error:`Error:`},x0={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-destructive`};function S0(){let{item:e,waiting:t}=gp(),n=iO(),r=e&&!n;return(0,m.useEffect)(()=>{if(!e||n)return;let r=window.setTimeout(()=>pp(e.id),t>0?Math.min(e.duration,1600):e.duration);return()=>window.clearTimeout(r)},[e,n,t]),(0,V.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`pointer-events-none fixed z-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,V.jsx)(Fu,{mode:`wait`,children:r?(0,V.jsxs)($f.div,{initial:{opacity:0,scale:.55,y:18},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.92,y:6,transition:{duration:.14,ease:`easeIn`}},transition:{type:`spring`,stiffness:560,damping:15,mass:.8},className:`pointer-events-auto flex max-w-[min(32rem,100%)] items-center gap-2.5 glass-toast rounded-lg px-3.5 py-2.5 text-sm`,children:[(0,V.jsx)(C0,{kind:e.kind}),(0,V.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,V.jsxs)(`span`,{className:`sr-only`,children:[b0[e.kind],` `]}),e.message]}),e.action?(0,V.jsx)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,className:`btn-outline -my-1.5 -mr-1 h-7 shrink-0 rounded-lg border px-2.5 text-xs font-medium text-foreground transition-[box-shadow,scale] active:scale-[0.97] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,onClick:()=>{e.action?.onClick(),pp(e.id)},children:e.action.label}):null]},e.id):null})})}function C0({kind:e}){let t=y0[e];return(0,V.jsx)(t,{"aria-hidden":`true`,className:J(`size-4 shrink-0`,x0[e])})}(0,ap.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(m.StrictMode,{children:(0,V.jsx)(HW,{children:(0,V.jsx)(Hu,{reducedMotion:`user`,children:(0,V.jsxs)(NO,{children:[(0,V.jsx)(v0,{}),(0,V.jsx)(S0,{})]})})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{updateViaCache:`none`}).catch(()=>void 0)});export{p as a,F as i,et as n,l as o,L as r,nX as t};
115
+ `).trim()}function Y$(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(q$,``)===``}function X$(e){let t=window.getSelection()?.anchorNode,n=t instanceof HTMLElement?t:t?.parentElement;return!!(n?.closest(`li`)&&e.contains(n))}function Z$(e){return e.replace(/[&<>"]/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`})[e]??e)}function Q$(e){if(e!==`code`){document.execCommand(e);return}let t=window.getSelection()?.toString()??``;document.execCommand(`insertHTML`,!1,t?`<code>${Z$(t)}</code>`:`<code>​</code>`)}var $$=[{format:`bold`,label:`Bold`,keys:`Ctrl+B`,icon:Jp},{format:`italic`,label:`Italic`,keys:`Ctrl+I`,icon:ch},{format:`code`,label:`Code`,keys:`Ctrl+E`,icon:Pm},{format:`insertUnorderedList`,label:`Bulleted list`,icon:Sh},{format:`insertOrderedList`,label:`Numbered list`,icon:bh}],e1=(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=J$(e);p(t===``&&!e.querySelector(`li`)),i(t,t?e.innerHTML:``)},[i]);(0,m.useEffect)(()=>{if(!u)return;let e=()=>g(Object.fromEntries($$.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(),Q$(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(X$(t))return;e.preventDefault(),o();return}e.key===`ArrowUp`&&Y$(t)&&(e.preventDefault(),s())}return(0,V.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,V.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:()=>{d(!1),a(!1)},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,V.jsxs)(`div`,{role:`toolbar`,"aria-label":`Formatting`,"aria-hidden":!u,className:J(`q-own-bar flex items-center gap-0.5 px-2 pb-1.5`,!u&&`pointer-events-none`),children:[$$.map(({format:e,label:t,keys:n,icon:r})=>(0,V.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,V.jsx)(r,{"aria-hidden":`true`,className:`size-3.5`})},e)),(0,V.jsx)(`span`,{className:`ms-auto pe-1 text-2xs text-muted-foreground`,children:`Enter answers · Shift+Enter new line`})]})]})});function t1(e){return e?e.options.some(OK)?`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 n1=/\s*\(recommended\)\s*$/i,r1=1200,i1=`Type something.`;function a1(e){return{text:e.replace(n1,``),recommended:n1.test(e)}}function o1({label:e}){let{text:t,recommended:n}=a1(e);return(0,V.jsxs)(`span`,{className:`leading-snug break-words`,children:[t,n?(0,V.jsx)(`span`,{className:`ms-1 font-medium text-primary`,children:`(Recommended)`}):null]})}function s1({multi:e,on:t}){return(0,V.jsxs)(`span`,{"aria-hidden":`true`,className:J(`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,V.jsx)(nm,{className:J(e?`size-3`:`hidden`)}):null,t&&!e?(0,V.jsx)(`span`,{className:`size-2 rounded-full bg-primary-foreground`}):null]})}function c1({option:e,index:t,multi:n,name:r,selected:i,onToggle:a,onFocusOption:o}){return(0,V.jsxs)(`div`,{className:`grid gap-1`,children:[(0,V.jsxs)(`label`,{className:J(`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,V.jsx)(`input`,{type:n?`checkbox`:`radio`,name:r,"data-nav":``,"data-option":t,className:`sr-only`,checked:i,onChange:a,onFocus:o}),(0,V.jsx)(s1,{multi:n,on:i}),(0,V.jsx)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:(0,V.jsxs)(`span`,{className:`flex gap-1.5`,children:[(0,V.jsxs)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,V.jsx)(o1,{label:e.label})]})})]}),e.description?(0,V.jsx)(aB,{text:e.description,className:`px-3 text-muted-foreground`}):null]})}function l1({option:e,onExpand:t}){return!e||!OK(e)?null:(0,V.jsxs)(`div`,{className:`card-flat flex min-w-0 max-w-full flex-col gap-2 rounded-lg border p-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsxs)(`p`,{className:`min-w-0 truncate text-xs font-medium text-muted-foreground`,children:[`Preview · `,a1(e.label).text]}),(0,V.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,onClick:t,"aria-keyshortcuts":`E`,title:`Expand · E`,className:`-my-1 shrink-0`,children:[(0,V.jsx)(Eh,{"aria-hidden":`true`}),`Expand`]})]}),e.image?(0,V.jsx)(`img`,{src:F(e.image),alt:``,loading:`lazy`,className:`max-h-64 w-full rounded-lg border object-contain`}):null,e.htmlPreview?(0,V.jsx)(wK,{preview:e.htmlPreview,label:a1(e.label).text,frameWidth:r1,onOpen:t,className:`h-auto aspect-[3/2]`}):null,e.preview?(0,V.jsx)(aB,{text:e.preview,className:`text-xs`}):null]})}function u1({option:e,index:t,multi:n,name:r,selected:i,active:a,onToggle:o,onFocusOption:s}){let{text:c,recommended:l}=a1(e.label),u=l?`${c} (Recommended)`:c;return(0,V.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,V.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,V.jsx)(`span`,{"aria-hidden":`true`,className:J(`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,V.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 d1={type:`spring`,visualDuration:.2,bounce:.12},f1={type:`spring`,visualDuration:.2,bounce:.04,delay:.06},p1={type:`spring`,visualDuration:.28,bounce:.55},m1={type:`spring`,visualDuration:.2,bounce:0},h1={type:`spring`,stiffness:900,damping:18,velocity:50,restDelta:.02,restSpeed:1},g1=-1;function _1(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===g1){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||o||!s){g(r===g1?void 0:n),r===g1&&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=Qf(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===g1){g(void 0),f.current();return}let e={open:0,reach:0},i=()=>p(r)??n;y(0,1,p1,t=>{e.open=t,g(i(),e.open,e.reach)}),y(0,1,{...m1,delay:.05},t=>{e.reach=t,g(i(),e.open,e.reach)});let a=t.current;a&&y(0,0,{...h1,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===g1?void 0:a,t,t)}),y(0,1,d1,e=>{m.head=e,b(),e>.85&&x()}),y(0,1,f1,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===g1?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 v1({option:e,position:t,count:n,chosen:r,onExpand:i,panel:a,dim:o}){if(!e)return null;let{text:s,recommended:c}=a1(e.label),l=OK(e);return(0,V.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,V.jsxs)(`div`,{"aria-live":`polite`,className:J(`q-panel-body grid min-w-0 gap-4`,l?`grid-cols-[minmax(0,1fr)_minmax(0,1.25fr)]`:``),children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2.5 py-0.5`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5`,children:[(0,V.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,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,V.jsxs)(`p`,{className:`text-2xs font-medium tracking-wide text-muted-foreground uppercase`,children:[`Option `,t+1,` of `,n]}),(0,V.jsxs)(`p`,{className:`text-base font-semibold break-words`,children:[s,c?(0,V.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,V.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,V.jsx)(nm,{"aria-hidden":`true`,className:`size-3.5`}),`Chosen`]}):null]}),e.description?(0,V.jsx)(aB,{text:e.description,className:`q-panel-text min-w-0 text-sm leading-relaxed`}):(0,V.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`No further detail.`})]}),l?(0,V.jsx)(l1,{option:e,onExpand:i}):null]},t)})}function y1({primary:e,primaryLabel:t,disabled:n,submitting:r,onCancel:i,intent:a}){return(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsx)(Y,{type:`button`,variant:`ghost`,onClick:i,children:`Cancel`}),a?(0,V.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,V.jsxs)(`span`,{className:`q-intent-text flex min-w-0 items-center gap-1.5`,children:[(0,V.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:a.lead}),a.empty?null:(0,V.jsx)(`span`,{className:`truncate font-medium`,children:a.text})]},`${a.lead}${a.text}`)}):null,(0,V.jsx)(Y,{type:e,disabled:n||r,children:r?`Sending…`:t})]})}function b1(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=>a1(e).text).join(`, `)}}function x1(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 S1({questions:e,picks:t,own:n,index:r,onGo:i}){return e.length===1?(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e[0]?.header}):(0,V.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,V.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:J(`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,V.jsxs)(`span`,{className:`min-w-0 break-words text-start`,children:[a+1,` `,e.header]}),o?(0,V.jsx)(nm,{className:`size-3 shrink-0`,"aria-hidden":`true`}):null]},a)})})}function C1({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,ee]=(0,m.useState)({}),te=(0,m.useRef)(null),A=(0,m.useRef)(null),j=(0,m.useRef)(null),M=e[s],ne=v[s]??[],N=b[s]??``,re=M?.options[k[s]??ne[0]??0],ie=x1(e,v,b,s),ae=M?.multiSelect===!0,oe=Math.max(0,M?.options.indexOf(re)??0),se=w||N.trim()!==``,ce=se?g1:oe,le=_1(A,j,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?.(t1(M)),[M,o]),(0,m.useEffect)(()=>{let e=te.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&&(ee(e=>({...e,[s]:g.current})),te.current?.querySelector(`[data-option="${g.current}"]`)?.focus())},[d]),!M)return null;let ue=M.options.some(OK);function P(e){h(Math.max(0,e)),g.current=Math.max(0,e),f(!0)}function de(e){g.current=e,f(!1)}if(d&&ue)return(0,V.jsx)(AK,{options:M.options,start:p,title:M.header||M.question,picked:ne,multi:ae,onChoose:e=>{fe(e),ae||de(e)},onClose:de,onIndex:e=>{g.current=e}},s);function fe(e){let t=ae?ne.includes(e)?ne.filter(t=>t!==e):[...ne,e]:[e];y({...v,[s]:t}),ae||(x({...b,[s]:``}),C({...S,[s]:``})),ee({...k,[s]:e})}function pe(e){let t=e instanceof HTMLInputElement&&e.dataset.option!==void 0?Number(e.dataset.option):-1;t>=0&&!ae&&fe(t)}function F(t,r){if(x1(e,t,r,s)){if(s<e.length-1){c(s+1);return}n({answers:e.map((n,i)=>x1(e,t,r,i)).filter(e=>!!e),cancelled:!1})}}function I(e){e.preventDefault(),t||F(v,b)}function me(t){t>=0&&t<e.length&&c(t)}function he(e){let n=e.target,r=te.current;if(!r||e.altKey)return;if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)){e.preventDefault(),t||F(v,b);return}if(zO(n))return;let i=BO(e.key);if(i||e.key===`Home`||e.key===`End`){e.preventDefault(),RO(r,n,i||(e.key===`Home`?`first`:`last`)),pe(document.activeElement);return}let a=VO(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)ne.length>0&&ne.includes(o)?F(v,b):fe(o);else{let e={...v,[s]:[o]},t={...b,[s]:``};y(e),x(t),C({...S,[s]:``}),F(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<=M.options.length){e.preventDefault(),fe(c-1),r.querySelector(`[data-option="${c-1}"]`)?.focus();return}e.key.toLowerCase()===`e`&&ue&&!e.ctrlKey&&!e.metaKey&&(e.preventDefault(),P(o>=0?o:k[s]??ne[0]??0))}return(0,V.jsxs)(`form`,{ref:te,className:`flex min-w-0 flex-col gap-3`,onSubmit:I,onKeyDown:he,children:[(0,V.jsx)(S1,{questions:e,picks:v,own:b,index:s,onGo:c}),(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.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,V.jsx)(aB,{text:M.question,className:`mt-1 text-base font-medium`})]}),(0,V.jsxs)(`div`,{className:`relative grid min-w-0 grid-cols-[2.25rem_minmax(0,1fr)] gap-x-3`,children:[(0,V.jsxs)(`div`,{ref:A,role:ae?`group`:`radiogroup`,"aria-label":`Options`,className:`q-rail relative flex min-w-0 flex-col justify-evenly py-2`,children:[(0,V.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,V.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,V.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,V.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`}),M.options.map((e,t)=>(0,V.jsx)(u1,{option:e,index:t,multi:ae,name:`question-${s}`,selected:ne.includes(t),active:ce===t,onToggle:()=>fe(t),onFocusOption:()=>ee({...k,[s]:t})},t))]}),(0,V.jsx)(v1,{panel:j,option:re,position:oe,count:M.options.length,chosen:!se&&ne.includes(oe),dim:se,onExpand:()=>P(oe)})]}),(0,V.jsx)(`div`,{className:`q-own-wrap mx-auto w-full`,children:(0,V.jsx)(e1,{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:T,onSubmit:()=>{t||F(v,b)},onUp:()=>{let e=te.current;e&&RO(e,O.current?.element??null,-1)}},s)}),(0,V.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,V.jsx)(`span`,{children:ae?`Pick several`:`Pick one`}),(0,V.jsx)(qD,{chord:`↑↓`,children:`move`}),(0,V.jsx)(qD,{chord:ae?`Space`:`Enter`,children:ae?`pick`:`choose`}),ae?(0,V.jsx)(qD,{chord:`Enter`,children:`next`}):null,e.length>1?(0,V.jsx)(qD,{chord:`←→`,children:`question`}):null,ue?(0,V.jsx)(qD,{chord:`E`,children:`expand mockups`}):null,(0,V.jsx)(qD,{chord:`Esc`,children:`later`})]}),(0,V.jsx)(y1,{primary:`submit`,primaryLabel:s<e.length-1?`Next`:`Answer`,disabled:!ie,submitting:t,onCancel:r,intent:b1(ie)})]})}function w1(e,t,n){let r=e.currentTarget,i=e.target;if(e.altKey||zO(i))return;let a=BO(e.key);if(a){e.preventDefault(),RO(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 T1({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,V.jsxs)(`form`,{ref:o,className:`flex min-w-0 flex-col gap-3`,onSubmit:e=>{e.preventDefault(),i&&n(i)},onKeyDown:r=>w1(r,e.options.length,(r,i)=>{let o=e.options[r];o!==void 0&&(a(o),i&&!t&&n(o))}),children:[(0,V.jsx)(aB,{text:e.title,className:`text-base`}),(0,V.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.options.map((e,t)=>(0,V.jsx)(c1,{option:{label:e},index:t,multi:!1,name:`choice`,selected:i===e,onToggle:()=>a(e)},e))}),(0,V.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,V.jsx)(qD,{chord:`↑↓`,children:`move`}),(0,V.jsx)(qD,{chord:`Enter`,children:`choose`}),(0,V.jsx)(qD,{chord:`Esc`,children:`later`})]}),(0,V.jsx)(y1,{primary:`submit`,primaryLabel:`Choose`,disabled:!i,submitting:t,onCancel:r})]})}function E1({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,V.jsxs)(`div`,{ref:r,tabIndex:-1,"data-autofocus":``,onKeyDown:i,className:`flex min-w-0 flex-col gap-3 outline-none`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(aB,{text:e.question,className:`text-base`}),e.detail?(0,V.jsx)(aB,{text:e.detail,className:`mt-1 text-muted-foreground`}):null]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsxs)(`p`,{className:`flex items-center gap-x-4 text-xs text-muted-foreground`,children:[(0,V.jsx)(qD,{chord:`Y`,children:`yes`}),(0,V.jsx)(qD,{chord:`N`,children:`no`}),(0,V.jsx)(qD,{chord:`Esc`,children:`later`})]}),(0,V.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(Y,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n(!1),children:`No`}),(0,V.jsx)(Y,{type:`button`,disabled:t,onClick:()=>n(!0),children:t?`Sending…`:`Yes`})]})]})]})}function D1({view:e,submitting:t,onAnswer:n,onCancel:r}){let[i,a]=(0,m.useState)(``);return(0,V.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-3`,onSubmit:e=>{e.preventDefault(),i.trim()&&n(i.trim())},children:[(0,V.jsx)(aB,{text:e.question,className:`text-base`}),(0,V.jsx)(Ck,{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??i1,"aria-label":e.question,rows:3,className:`min-h-9 resize-none text-sm`}),(0,V.jsxs)(`p`,{className:`flex items-center gap-x-4 text-xs text-muted-foreground`,children:[(0,V.jsx)(qD,{chord:`Enter`,children:`answer`}),(0,V.jsx)(qD,{chord:`Shift+Enter`,children:`new line`}),(0,V.jsx)(qD,{chord:`Esc`,children:`later`})]}),(0,V.jsx)(y1,{primary:`submit`,primaryLabel:`Answer`,disabled:!i.trim(),submitting:t,onCancel:r})]})}function O1({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,V.jsxs)(`form`,{ref:l,className:`flex min-w-0 flex-col gap-3`,onSubmit:u,onKeyDown:r=>{e.method===`select`&&w1(r,s.length,(e,r)=>{let i=s[e];i!==void 0&&(o(i),r&&!t&&n({value:i}))})},children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.title}),e.message?(0,V.jsx)(aB,{text:e.message,className:`mt-1 text-base`}):null]}),e.method===`select`?(0,V.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.map((e,t)=>(0,V.jsx)(c1,{option:{label:e},index:t,multi:!1,name:`dialog`,selected:a===e,onToggle:()=>o(e)},e))}):null,e.method===`input`||e.method===`editor`?(0,V.jsx)(Ck,{value:r,onChange:e=>i(e.target.value),placeholder:e.placeholder??i1,"aria-label":e.title,rows:e.method===`editor`?4:2,className:`min-h-9 resize-none text-sm`}):null,(0,V.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,V.jsx)(Y,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n({cancelled:!0}),children:`Cancel`}),e.method===`confirm`?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Y,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n({confirmed:!1}),children:`No`}),(0,V.jsx)(Y,{type:`button`,disabled:t,onClick:()=>n({confirmed:!0}),children:t?`Sending…`:`Yes`})]}):(0,V.jsx)(Y,{type:`submit`,disabled:!c||t,children:t?`Sending…`:`Answer`})]})]})}function k1(e){let{view:t}=e;return t.kind===`questionnaire`?(0,V.jsx)(C1,{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,V.jsx)(T1,{...e,view:t}):t.kind===`confirm`?(0,V.jsx)(E1,{...e,view:t}):t.kind===`text`?(0,V.jsx)(D1,{...e,view:t}):(0,V.jsx)(O1,{...e,dialog:t.dialog})}function A1(e){return typeof e==`object`&&e?e:{}}function j1(e){return typeof e==`string`?e.trim():``}function M1(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function N1(e){let t=A1(e),n=j1(t.label);if(!n)return;let r=j1(t.description),i=j1(t.preview),a=j1(t.image),o=yK(t.htmlPreview);return{label:n,...r?{description:r}:{},...i?{preview:i}:{},...a?{image:a}:{},...o?{htmlPreview:o}:{}}}function P1(e){let t=A1(e),n=j1(t.question);if(!n)return;let r=(Array.isArray(t.options)?t.options:[]).map(N1).filter(e=>!!e);return{question:n,header:j1(t.header)||`Question`,options:r,...t.multiSelect===!0?{multiSelect:!0}:{}}}function F1(e){let t=A1(e),n=j1(t.method);if(n!==`select`&&n!==`confirm`&&n!==`input`&&n!==`editor`)return;let r=j1(t.message),i=M1(t.options),a=j1(t.placeholder),o=j1(t.prefill);return{id:j1(t.id),method:n,title:j1(t.title)||`Answer`,...r?{message:r}:{},...i.length>0?{options:i}:{},...a?{placeholder:a}:{},...o?{prefill:o}:{}}}function I1(e){let t=(Array.isArray(e.questions)?e.questions:[]).map(P1).filter(e=>!!e);return t.length>0?{kind:`questionnaire`,questions:t}:void 0}function L1(e){return{kind:`choose`,title:j1(e.title)||`Choose an option`,options:M1(e.options)}}function R1(e){let t=j1(e.question)||j1(e.title)||`Continue?`,n=j1(e.detail)||j1(e.message);return{kind:`confirm`,question:t,...n?{detail:n}:{}}}function z1(e){let t=j1(e.question)||j1(e.title)||`Type an answer`,n=j1(e.placeholder);return{kind:`text`,question:t,...n?{placeholder:n}:{}}}function B1(e){let t=A1(e.payload);if(e.kind===`questionnaire`)return I1(t);if(e.kind===`choose`)return L1(t);if(e.kind===`confirm`)return R1(t);if(e.kind===`text`)return z1(t);let n=F1(t.dialog);return n?{kind:`sessionDialog`,dialog:n}:void 0}var V1={md:`max-w-3xl`,lg:`max-w-4xl max-h-[min(88svh,52rem)]`,xl:`max-w-5xl max-h-[min(90svh,58rem)]`};function H1({submitting:e,onKeep:t,onLeave:n}){return(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,role:`alert`,children:[(0,V.jsx)(`p`,{className:`text-sm`,children:`Leave without answering? The oracle will not guess for you.`}),(0,V.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,V.jsx)(Y,{type:`button`,variant:`outline`,onClick:t,children:`Keep answering`}),(0,V.jsx)(Y,{type:`button`,disabled:e,onClick:n,children:e?`Leaving…`:`Leave`})]})]})}function U1({count:e,onOpen:t}){return(0,V.jsxs)(Y,{type:`button`,variant:`soft`,onClick:t,"aria-label":`${e} question${e===1?``:`s`} waiting — open`,className:`gap-1.5 text-warning`,children:[(0,V.jsx)(bm,{"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tabular-nums`,children:e}),(0,V.jsx)(`span`,{children:`waiting`})]})}function W1({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?B1(g):void 0,v=h>0&&!r,y=nO(v,tO.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 xe&&e.code===`question_withdrawn`?mp(oO):mp.error(e instanceof Error?e.message:t)}finally{c(!1)}}let S=g?.from?`${g.from} asks`:`A question`;return(0,V.jsx)(JD,{open:v&&y&&!!g,label:`Question from the lobby`,dismissOnBackdrop:!1,onOpenChange:e=>{e||(l?u(!1):a?o(!1):i(!0))},className:J(`transition-[max-width] duration-300 ease-snap`,l?`h-[min(92svh,60rem)] max-h-[min(92svh,60rem)] max-w-7xl`:V1[_?.kind===`questionnaire`?f:`md`]),children:g?(0,V.jsxs)(`section`,{"aria-label":`Question from the lobby`,className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,V.jsxs)(`header`,{className:J(`flex items-center gap-3 px-4 pt-4 pb-2`,l&&`hidden`),children:[(0,V.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,V.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Later: put the question away`,title:`Later · Esc`,onClick:()=>i(!0),children:(0,V.jsx)(o_,{"aria-hidden":`true`})})]}),(0,V.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,V.jsx)(H1,{submitting:s,onKeep:()=>o(!1),onLeave:()=>void x(n(g.id),`Could not leave the question`)}):(0,V.jsx)(k1,{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,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsx)(`p`,{className:` text-sm text-muted-foreground`,children:`This question cannot be shown here.`}),(0,V.jsx)(Y,{type:`button`,disabled:s,onClick:()=>void x(n(g.id),`Could not dismiss the question`),children:`Dismiss`})]})}),l?null:(0,V.jsx)(Vv,{target:d})]}):null})}var G1=2;function K1(e){let t=globalThis.EventSource;if(!t)throw Error(`EventSource is not available in this environment`);return new t(e)}function q1(e){try{return JSON.parse(e)}catch{return}}function J1(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 Y1(e,t=K1){let n=t(F(`/api/events`));return e.onConnection?.(`connecting`),n.onopen=()=>e.onConnection?.(`live`),n.onerror=()=>e.onConnection?.(n.readyState===G1?`offline`:`connecting`),n.onmessage=t=>{let n=q1(t.data);n&&J1(n,e)},()=>n.close()}var X1=2e3,Z1=()=>L(`projects.list`,{});async function Q1(){let e;try{e=pe()}catch{return}if(e&&!ye(e))try{ve((await Z1()).projects)}catch{}}function $1(){let e=(0,m.useRef)(void 0),t=(0,m.useRef)(void 0),n=(0,m.useCallback)(()=>{clearTimeout(t.current),e.current?.();try{pe()}catch{P.onStatus({connection:`offline`});return}e.current=Y1({onHello:e=>{P.onHello(e),Q1()},onChanged:(e,t)=>P.onChanged(e,t),onFeed:e=>P.onFeedDelta(e),onReply:e=>P.onReplyDelta(e),onNotice:(e,t)=>mp[t](e),onConnection:e=>{P.onStatus({connection:e}),e===`offline`&&(clearTimeout(t.current),t.current=setTimeout(()=>{be(Z1).catch(()=>!1).finally(n)},X1))}})},[]);return(0,m.useEffect)(()=>(n(),()=>{clearTimeout(t.current),e.current?.()}),[n]),n}var e0=`bot-lobby.recoveredAt`,t0;function n0(e,t=r0()){try{t0===void 0&&(t0=Number(t?.getItem(e0)??0))}catch{t0??=0}if(t0!==void 0&&e<=t0)return!1;t0=e;try{t?.setItem(e0,String(e))}catch{}return!0}function r0(){try{return globalThis.sessionStorage}catch{return}}function i0(e){let t=e?.recovered?.at,n=e?.recovered?.text;(0,m.useEffect)(()=>{t!==void 0&&n&&n0(t)&&mp.success(n)},[t,n])}function a0(){let e=AO(`prompts`),t=(0,m.useCallback)(async(e,t)=>{await L(`prompts.answer`,{id:e,answer:t})},[]),n=(0,m.useCallback)(async e=>{await L(`prompts.dismiss`,{id:e})},[]);return{prompts:e.data?.prompts??[],loading:e.loading,error:e.error,answer:t,dismiss:n}}function o0(e,t,n,r,i){e===`search`?(document.querySelector(`#main input[type='search']`)??document.getElementById(`composer-text`))?.focus():e===`help`?n():e===`settings`?fO(`#/settings`):e===`thinking`?pH(`lobby.thinking`):e===`sidebar`?i():e===`terminal`?fQ():e===`activity`?t.kind===`tab`&&t.tab===`lobby`?pH(gH):fO(dO(`lobby`)):e===`nextTab`?r(1):e===`prevTab`?r(-1):e===`savePlan`&&t.kind===`tab`&&t.tab===`plan`&&U(`planner.save`,{})}var s0=`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`,c0=`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`,l0=2500;function u0(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),l0);return()=>clearTimeout(t)},[e]),e===`offline`||e===`connecting`&&t}function d0({connection:e,onRetry:t}){return u0(e)?(0,V.jsx)(DO,{onRetry:t}):null}var f0={tick:0,route:0,focus:0};window.addEventListener(`hashchange`,()=>{f0.route=++f0.tick}),document.addEventListener(`focusin`,()=>{f0.focus=++f0.tick});var p0=()=>f0.focus>f0.route;function m0(e){return e.kind===`tab`?e.tab:e.kind}function h0(){let e=pO(),t=AO(`status`),n=AO(`lobby`),{prompts:r,answer:i,dismiss:a}=a0(),{connection:o,signedOut:s}=kO(),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=(0,m.useRef)(null),p=$1();nW();let h=t.data;i0(h);let g=!!h&&!s;(0,m.useEffect)(()=>{g&&Re()},[g]);let _=h?.tabs??[],v=h?.keys??[],y=e.kind===`tab`?e.tab:void 0,b=(0,m.useCallback)(e=>fO(dO(e)),[]),x=(0,V.jsx)(d$,{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&&fO(dO(n.id))},[_,y]),C=(0,m.useCallback)(()=>l(e=>!e),[]),w=KX();jO(aH);let[T]=mH(EZ),E=(0,m.useCallback)(()=>pH(EZ),[]),D=(0,m.useCallback)(t=>{(t!==`thinking`&&t!==`activity`||h?.panels?.[t]!==!1)&&o0(t,uO(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`)?!0:e.closest(`[data-state='closed']`)!==null},[]);lX({enabled:!!h,keys:v,tabs:_,insideApp:O,onAction:D,onTab:b});let k=(0,m.useCallback)(()=>P.onHello({}),[]),ee=e.kind===`tab`?e.tab:e.kind,te=!!h;(0,m.useEffect)(()=>{if(!te)return;let e=YO.active&&YO.to===ee;if(YO.active=!1,YO.to=void 0,e)return;let t=requestAnimationFrame(()=>{if(p0()||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)},[ee,te]);let A=Object.fromEntries(v.map(e=>[e.action,e.label])),j=!!h&&!s,M=j?(0,V.jsx)(QZ,{hint:A.sidebar}):null,ne=(0,V.jsx)(SZ,{connection:o,projects:w,lead:M,tabs:x,extra:u&&r.length>0?(0,V.jsx)(U1,{count:r.length,onOpen:()=>d(!1)}):null,tools:j?(0,V.jsx)(wQ,{hint:A.terminal,className:c0}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(wX,{className:s0,side:`bottom`}),(0,V.jsx)(CX,{className:s0,side:`bottom`})]})});return s||!h?(0,V.jsxs)(`div`,{ref:f,className:`fixed inset-0 flex flex-col`,children:[ne,(0,V.jsx)(`main`,{className:`surface flex min-h-0 flex-1 flex-col overflow-y-auto`,children:s?(0,V.jsx)(kQ,{}):t.error?(0,V.jsx)(EO,{message:t.error,onRetry:k}):(0,V.jsx)(TO,{})})]}):(0,V.jsxs)(`div`,{ref:f,className:`app-chrome fixed inset-0 flex`,"data-sidebar":T?`folded`:`open`,children:[(0,V.jsx)(ZZ,{route:e,keys:A,onHelp:C}),(0,V.jsxs)(`div`,{className:`relative flex min-w-0 flex-1 flex-col`,children:[ne,(0,V.jsxs)(`div`,{className:`app-page relative flex min-h-0 flex-1 flex-col`,children:[(0,V.jsx)(d0,{connection:o,onRetry:p}),(0,V.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,V.jsx)(`main`,{id:`main`,tabIndex:-1,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||zO(e.target)||e.target.closest(`[role='dialog'], [role='menu'], [role='listbox']`)||JO()&&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,V.jsx)($f.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:XY(e)},m0(e))}),(0,V.jsx)(_Z,{route:e,keys:A,projects:w,onHelp:C})]}),(0,V.jsx)(DQ,{toggleKey:A.terminal??"Ctrl+`"})]})]}),(0,V.jsx)(K$,{status:h,lobby:n.data}),(0,V.jsx)(W1,{prompts:r,answer:i,dismiss:a,minimized:u,onMinimize:d}),(0,V.jsx)(bX,{open:c,onOpenChange:l,keys:v,tabs:_})]})}async function g0(e){switch(e){case`status`:return L(`status.get`,{});case`lobby`:return L(`lobby.snapshot`,{});case`prompts`:return L(`prompts.list`,{});default:return}}var _0=[`status`,`lobby`,`prompts`];function v0(){let[e,t]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{let e=!0;return(async()=>{await we(),e&&(P.markUsed(_0,g0),t(!0))})(),()=>{e=!1}},[]),e}function y0(){return v0()?(0,V.jsx)(h0,{}):(0,V.jsx)(`div`,{className:`fixed inset-0 flex`,children:(0,V.jsx)(TO,{})})}var b0={info:oh,success:mm,warning:Kg,error:Em},x0={info:`Note:`,success:`Done:`,warning:`Warning:`,error:`Error:`},S0={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-destructive`};function C0(){let{item:e,waiting:t}=gp(),n=iO(),r=e&&!n;return(0,m.useEffect)(()=>{if(!e||n)return;let r=window.setTimeout(()=>pp(e.id),t>0?Math.min(e.duration,1600):e.duration);return()=>window.clearTimeout(r)},[e,n,t]),(0,V.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`pointer-events-none fixed z-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,V.jsx)(Fu,{mode:`wait`,children:r?(0,V.jsxs)($f.div,{initial:{opacity:0,scale:.55,y:18},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.92,y:6,transition:{duration:.14,ease:`easeIn`}},transition:{type:`spring`,stiffness:560,damping:15,mass:.8},className:`pointer-events-auto flex max-w-[min(32rem,100%)] items-center gap-2.5 glass-toast rounded-lg px-3.5 py-2.5 text-sm`,children:[(0,V.jsx)(w0,{kind:e.kind}),(0,V.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,V.jsxs)(`span`,{className:`sr-only`,children:[x0[e.kind],` `]}),e.message]}),e.action?(0,V.jsx)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,className:`btn-outline -my-1.5 -mr-1 h-7 shrink-0 rounded-lg border px-2.5 text-xs font-medium text-foreground transition-[box-shadow,scale] active:scale-[0.97] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,onClick:()=>{e.action?.onClick(),pp(e.id)},children:e.action.label}):null]},e.id):null})})}function w0({kind:e}){let t=b0[e];return(0,V.jsx)(t,{"aria-hidden":`true`,className:J(`size-4 shrink-0`,S0[e])})}(0,ap.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(m.StrictMode,{children:(0,V.jsx)(HW,{children:(0,V.jsx)(Hu,{reducedMotion:`user`,children:(0,V.jsxs)(NO,{children:[(0,V.jsx)(y0,{}),(0,V.jsx)(C0,{})]})})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{updateViaCache:`none`}).catch(()=>void 0)});export{p as a,F as i,et as n,l as o,L as r,nX as t};