@a-t-h-i/bot-lobby 0.6.79 → 0.6.80

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-CRwPTCho.js","assets/rolldown-runtime-hePW80VL.js","assets/ccount-DQxSH8e6.js","assets/TerminalView-BrP-ENHg.css","assets/CodeSurface-DZdLN-w3.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalView-BW7Ik8CM.js","assets/rolldown-runtime-hePW80VL.js","assets/ccount-DQxSH8e6.js","assets/TerminalView-BrP-ENHg.css","assets/CodeSurface-v19_sKLO.js"])))=>i.map(i=>d[i]);
2
2
  import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{a as r,c as i,i as a,l as o,n as s,o as c,r as l,s as u,t as d}from"./ccount-DQxSH8e6.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var f=document.querySelector(`meta[property="csp-nonce"]`),p=f?.nonce||f?.content;p&&(window.__webpack_nonce__=p);var m=t(o(),1),h,g=new Set;function _(){for(let e of[...g])e()}typeof window<`u`&&(window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),h=e,_()}),window.addEventListener(`appinstalled`,()=>{h=void 0,_()}));function v(e){return g.add(e),()=>{g.delete(e)}}function y(){return{available:(0,m.useSyncExternalStore)(v,()=>h!==void 0,()=>!1),install:async()=>{let e=h;e&&(await e.prompt().catch(()=>void 0),await e.userChoice?.catch(()=>void 0),h=void 0,_())}}}function b(){let e=`(display-mode: fullscreen), (display-mode: standalone), (display-mode: minimal-ui)`,[t,n]=(0,m.useState)(()=>typeof window<`u`&&window.matchMedia(e).matches);return(0,m.useEffect)(()=>{let t=window.matchMedia(e),r=()=>n(t.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[]),t}function x(){let e=typeof document<`u`&&typeof document.documentElement.requestFullscreen==`function`,[t,n]=(0,m.useState)(()=>typeof document<`u`&&document.fullscreenElement!==null);return(0,m.useEffect)(()=>{let e=()=>n(document.fullscreenElement!==null);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]),{supported:e,on:t,toggle:async()=>{document.fullscreenElement?await document.exitFullscreen().catch(()=>void 0):await document.documentElement.requestFullscreen().catch(()=>void 0)}}}var S=[`background`,`foreground`,`card`,`card-foreground`,`popover`,`popover-foreground`,`primary`,`primary-foreground`,`secondary`,`secondary-foreground`,`muted`,`muted-foreground`,`accent`,`accent-foreground`,`destructive`,`border`,`input`,`ring`,`chart-1`,`chart-2`,`chart-3`,`chart-4`,`chart-5`],C=[`font-sans`,`font-mono`],w=new Set([...S,...C]),T=/^[\w\s#%.,()/+*'"-]{1,300}$/,E=/url\s*\(|expression|import|javascript|\\|<|>/i;function D(e){let t=e.replace(/!important/gi,``).trim();if(t&&T.test(t)&&!E.test(t))return t}function O(e,t,n){let r=e.replace(/^--/,``).toLowerCase();if(!w.has(r))return;let i=D(t);i&&(n[r]=i)}function k(e){let t={};for(let n of e.matchAll(/--([a-z0-9-]+)\s*:\s*([^;}]+)/gi))O(n[1],n[2],t);return t}function 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 A(e){let t=e.trim();if(!t)return{error:`Paste a theme first.`};if(t.length>2e5)return{error:`That file is too large to be a theme.`};let n={},r={},i;if(t.startsWith(`{`)){let e;try{e=JSON.parse(t)}catch{return{error:`That is not valid JSON or CSS.`}}let a=e,o=a.cssVars;if(!o||typeof o!=`object`)return{error:`That JSON has no cssVars. Copy the theme's CSS from tweakcn instead.`};let s=e=>{let t={};for(let[n,r]of Object.entries(e??{}))typeof r==`string`&&O(n,r,t);return t};n={...s(o.theme),...s(o.light)},r={...s(o.theme),...s(o.dark)},i=typeof a.title==`string`?a.title:typeof a.name==`string`?a.name:void 0}else for(let e of t.matchAll(/(?<=^|[}\s])((?::root|html|\.dark|:root\.dark|html\.dark)(?:\s*,\s*[^{]+)?)\s*\{([^}]*)\}/g)){let t=e[1].trim(),i=k(e[2]);/\.dark/.test(t)?r={...r,...i}:n={...n,...i}}let a=e=>Object.keys(e).filter(e=>S.includes(e)).length;return a(n)<5&&a(r)<5?{error:`No theme colours found. Copy the code from tweakcn's Code panel (the :root and .dark blocks).`}:{...a(n)>=5?{light:n}:{},...a(r)>=5?{dark:r}:{},...i?{name:i}:{}}}var j={"glass-border":`var(--border)`,typing:`var(--ring)`,"tab-active":`color-mix(in oklab, var(--primary) 14%, var(--background))`,you:`color-mix(in oklab, var(--primary) 9%, var(--card))`,heading:`var(--foreground)`,link:`var(--primary)`,bullet:`var(--primary)`},M=`"Inter Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`,te=`ui-monospace, "JetBrains Mono", "Cascadia Mono", "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace`;function ne(e,t){let n=[];for(let[e,r]of Object.entries(t))e===`font-sans`?n.push(`--app-font-sans:${r},${M};`):e===`font-mono`?n.push(`--app-font-mono:${r},${te};`):n.push(`--${e}:${r};`);for(let[e,r]of Object.entries(j))e in t||n.push(`--${e}:${r};`);return`${e}{${n.join(``)}}`}function N(e){let t=[];return e.light&&t.push(ne(`:root`,e.light)),e.dark&&t.push(ne(`.dark`,e.dark)),t.join(`
3
3
  `)}var re=`mist`,ie=[{id:re,name:`Default`}],ae={light:{background:`#faf9f5`,card:`#ffffff`,primary:`#c96442`,accent:`#f0eee6`},dark:{background:`#262624`,card:`#30302e`,primary:`#d97757`,accent:`#1f1e1d`}};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,Re=Promise.resolve();function ze(e=!1){return Le&&!e||(Le=(async()=>{let e=await L(`themes.get`,{}),t=ke.legacy;if(t){let n=e.active??(ke.id===De?void 0:ke.id);e=await L(`themes.save`,{name:t.name,...t.light?{light:t.light}:{},...t.dark?{dark:t.dark}:{}}),n&&(e=await L(`themes.choose`,{id:n}));let{legacy:r,...i}=ke;ke=i}Ie(e)})().catch(()=>{Le=void 0})),Le}typeof window<`u`&&(Pe(),window.addEventListener(`storage`,e=>{if(e.key===Te){ke=je(),Pe();for(let e of[...Oe])e()}}),window.addEventListener(`focus`,()=>void ze(!0)));function Be(e){return Oe.add(e),()=>{Oe.delete(e)}}function Ve(){let e=(0,m.useSyncExternalStore)(Be,()=>ke,()=>ke),t=(0,m.useCallback)(e=>{Fe({...ke,id:e}),e!==De&&(Re=Re.then(()=>L(`themes.choose`,{id:e})).then(Ie,()=>{}))},[]),n=(0,m.useCallback)(async(e,t)=>(Ie(await L(`themes.save`,{name:t,...e.light?{light:e.light}:{},...e.dark?{dark:e.dark}:{}})),Ne(ke)),[]),r=(0,m.useCallback)(async(e,t)=>Ie(await L(`themes.rename`,{id:e,name:t})),[]),i=(0,m.useCallback)(async e=>Ie(await L(`themes.remove`,{id:e})),[]),a=e.legacy?[...e.saved,e.legacy]:e.saved;return{active:Ne(e),saved:a,all:Me(e),isSaved:e=>a.some(t=>t.id===e),choose:t,adopt:n,rename:r,remove:i}}var He=[{id:`theme`,label:`System`,help:`The system's own (or the colour theme's)`},{id:`inter`,label:`Inter`,help:`Neutral and very legible`},{id:`geist`,label:`Geist`,help:`Crisp and modern`},{id:`plex`,label:`IBM Plex Sans`,help:`Technical, with character`},{id:`manrope`,label:`Manrope`,help:`Round and friendly`},{id:`dm-sans`,label:`DM Sans`,help:`Geometric, low contrast`},{id:`jakarta`,label:`Plus Jakarta Sans`,help:`Polished product sans`},{id:`figtree`,label:`Figtree`,help:`Clean and approachable`},{id:`outfit`,label:`Outfit`,help:`Geometric display feel`},{id:`nunito`,label:`Nunito`,help:`Soft rounded terminals`},{id:`space-grotesk`,label:`Space Grotesk`,help:`Quirky, technical`},{id:`source-sans`,label:`Source Sans 3`,help:`Classic UI workhorse`}],Ue=[{id:`theme`,label:`System mono`,help:`The system's own (or the colour theme's)`},{id:`jetbrains`,label:`JetBrains Mono`,help:`Tall, made for code`},{id:`geist-mono`,label:`Geist Mono`,help:`Pairs with Geist`},{id:`fira-code`,label:`Fira Code`,help:`Ligatures for operators`},{id:`roboto-mono`,label:`Roboto Mono`,help:`Even and compact`},{id:`source-code`,label:`Source Code Pro`,help:`Open and readable`}],We={font:`bot-lobby.typeface`,mono:`bot-lobby.typeface-code`},Ge={font:He,mono:Ue},Ke={font:`theme`,mono:`theme`},qe=new Set;function Je(e){let t=null;try{t=localStorage.getItem(We[e])}catch{t=Ke[e]}return Ge[e].some(e=>e.id===t)?t:`theme`}function Ye(e,t){let n=document.documentElement;t===`theme`?delete n.dataset[e]:n.dataset[e]=t}function Xe(e,t){Ke[e]=t;try{localStorage.setItem(We[e],t)}catch{}Ye(e,t);for(let e of qe)e()}function Ze(e){return qe.add(e),()=>qe.delete(e)}function Qe(e){return(0,m.useSyncExternalStore)(Ze,()=>Je(e),()=>`theme`)}typeof document<`u`&&(Ye(`font`,Je(`font`)),Ye(`mono`,Je(`mono`)));var $e={inter:`"Inter Variable", system-ui, sans-serif`,geist:`"Geist Variable", system-ui, sans-serif`,plex:`"IBM Plex Sans Variable", system-ui, sans-serif`,manrope:`"Manrope Variable", system-ui, sans-serif`,jetbrains:`"JetBrains Mono Variable", ui-monospace, monospace`,"geist-mono":`"Geist Mono Variable", ui-monospace, monospace`,"dm-sans":`"DM Sans Variable", system-ui, sans-serif`,jakarta:`"Plus Jakarta Sans Variable", system-ui, sans-serif`,figtree:`"Figtree Variable", system-ui, sans-serif`,outfit:`"Outfit Variable", system-ui, sans-serif`,nunito:`"Nunito Variable", system-ui, sans-serif`,"space-grotesk":`"Space Grotesk Variable", system-ui, sans-serif`,"source-sans":`"Source Sans 3 Variable", system-ui, sans-serif`,"fira-code":`"Fira Code Variable", ui-monospace, monospace`,"roboto-mono":`"Roboto Mono Variable", ui-monospace, monospace`,"source-code":`"Source Code Pro Variable", ui-monospace, monospace`},et=(0,m.createContext)({});function tt(e){let t=(0,m.useRef)(null);return t.current===null&&(t.current=e()),t.current}var nt=typeof window<`u`?m.useLayoutEffect:m.useEffect,rt=(0,m.createContext)(null);function it(e,t){e.indexOf(t)===-1&&e.push(t)}function at(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var ot=(e,t,n)=>n>t?t:n<e?e:n,st={},ct=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),lt=e=>typeof e==`object`&&!!e,ut=e=>/^0[^.\s]+$/u.test(e);function dt(e){let t;return()=>(t===void 0&&(t=e()),t)}var ft=e=>e,pt=(...e)=>e.reduce((e,t)=>n=>t(e(n))),mt=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},ht=class{constructor(){this.subscriptions=[]}add(e){return it(this.subscriptions,e),()=>this.remove(e)}remove(e){at(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r){if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},gt=e=>e*1e3,_t=e=>e/1e3,vt=(e,t)=>t?1e3/t*e:0,yt=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,bt=1e-7,xt=12;function St(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=yt(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>bt&&++s<xt);return o}function Ct(e,t,n,r){if(e===t&&n===r)return ft;let i=t=>St(t,0,1,e,n);return e=>e===0||e===1?e:yt(i(e),t,r)}var wt=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Tt=e=>t=>1-e(1-t),Et=Ct(.33,1.53,.69,.99),Dt=Tt(Et),Ot=wt(Dt),kt=e=>e>=1?1:(e*=2)<1?.5*Dt(e):.5*(2-2**(-10*(e-1))),At=e=>1-Math.sin(Math.acos(e)),jt=Tt(At),Mt=wt(At),Nt=Ct(.42,0,1,1),Pt=Ct(0,0,.58,1),Ft=Ct(.42,0,.58,1),It=e=>Array.isArray(e)&&typeof e[0]!=`number`,Lt=e=>Array.isArray(e)&&typeof e[0]==`number`,Rt={linear:ft,easeIn:Nt,easeInOut:Ft,easeOut:Pt,circIn:At,circInOut:Mt,circOut:jt,backIn:Dt,backInOut:Ot,backOut:Et,anticipate:kt},zt=e=>typeof e==`string`,Bt=e=>{if(Lt(e)){e.length;let[t,n,r,i]=e;return Ct(t,n,r,i)}return zt(e)?(Rt[e],`${e}`,Rt[e]):e},Vt={delta:0,timestamp:0,isProcessing:!1},Ht;function Ut(){Ht=void 0}var Wt={now:()=>(Ht===void 0&&Wt.set(Vt.isProcessing||st.useManualTiming?Vt.timestamp:performance.now()),Ht),set:e=>{Ht=e,queueMicrotask(Ut)}},Gt=e=>Math.round(e*1e5)/1e5,Kt=e=>t=>typeof t==`string`&&t.startsWith(e),qt=Kt(`--`),Jt=Kt(`var(--`),Yt=e=>Jt(e)?Xt.test(e.split(`/*`)[0].trim()):!1,Xt=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Zt(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var Qt={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},$t={...Qt,transform:e=>ot(0,1,e)},en={...Qt,default:1},tn=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function nn(e){return e==null}var rn=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,an=(e,t)=>n=>!!(typeof n==`string`&&rn.test(n)&&n.startsWith(e)||t&&!nn(n)&&Object.prototype.hasOwnProperty.call(n,t)),on=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(tn);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},sn=e=>ot(0,255,e),cn={...Qt,transform:e=>Math.round(sn(e))},ln={test:an(`rgb`,`red`),parse:on(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+cn.transform(e)+`, `+cn.transform(t)+`, `+cn.transform(n)+`, `+Gt($t.transform(r))+`)`};function un(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var dn={test:an(`#`),parse:un,transform:ln.transform},fn=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),pn=fn(`deg`),mn=fn(`%`),R=fn(`px`),hn=fn(`vh`),gn=fn(`vw`),_n={...mn,parse:e=>mn.parse(e)/100,transform:e=>mn.transform(e*100)},vn={test:an(`hsl`,`hue`),parse:on(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+mn.transform(Gt(t))+`, `+mn.transform(Gt(n))+`, `+Gt($t.transform(r))+`)`},yn={test:e=>ln.test(e)||dn.test(e)||vn.test(e),parse:e=>ln.test(e)?ln.parse(e):vn.test(e)?vn.parse(e):dn.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?ln.transform(e):vn.transform(e),getAnimatableNone:e=>{let t=yn.parse(e);return t.alpha=0,yn.transform(t)}},bn=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,xn=new RegExp(tn.source),Sn=new RegExp(bn.source,`i`);function Cn(e){return isNaN(e)&&typeof e==`string`&&(xn.test(e)||Sn.test(e))}var wn=`number`,Tn=`color`,En=`var`,Dn=`var(`,On="${}",kn=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function An(e){let t=e.toString();return xn.test(t)||Sn.test(t)}function jn(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(kn,e=>(yn.test(e)?(r.color.push(a),i.push(Tn),n.push(yn.parse(e))):e.startsWith(Dn)?(r.var.push(a),i.push(En),n.push(e)):(r.number.push(a),i.push(wn),n.push(parseFloat(e))),++a,On)).split(On),indexes:r,types:i}}function Mn(e){return jn(e).values}function Nn({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];i+=e===wn?Gt(r[a]):e===Tn?yn.transform(r[a]):r[a]}return i}}function Pn(e){return Nn(jn(e))}var Fn=e=>typeof e==`number`?0:yn.test(e)?yn.getAnimatableNone(e):e,In=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:Fn(e);function Ln(e){let t=jn(e);return Nn(t)(t.values.map((e,n)=>In(e,t.split[n])))}var Rn={test:Cn,parse:Mn,createTransformer:Pn,getAnimatableNone:Ln};function zn(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Bn({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=zn(s,r,e+1/3),a=zn(s,r,e),o=zn(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function Vn(e,t){return n=>n>0?t:e}var Hn=(e,t,n)=>e+(t-e)*n,Un=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},Wn=[dn,ln,vn],Gn=e=>Wn.find(t=>t.test(e));function Kn(e){let t=Gn(e);if(!t)return`${e}`,!1;let n=t.parse(e);return t===vn&&(n=Bn(n)),n}var qn=(e,t)=>{let n=Kn(e),r=Kn(t);if(!n||!r)return Vn(e,t);let i={...n};return e=>(i.red=Un(n.red,r.red,e),i.green=Un(n.green,r.green,e),i.blue=Un(n.blue,r.blue,e),i.alpha=Hn(n.alpha,r.alpha,e),ln.transform(i))},Jn=new Set([`none`,`hidden`]);function Yn(e,t){return Jn.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Xn(e,t){return n=>Hn(e,t,n)}function Zn(e){return typeof e==`number`?Xn:typeof e==`string`?Yt(e)?Vn:yn.test(e)?qn:tr:Array.isArray(e)?Qn:typeof e==`object`?yn.test(e)?qn:$n:Vn}function Qn(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>Zn(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function $n(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Zn(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function er(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]],s=e.values[o]??0;n[i]=s,r[a]++}return n}var tr=(e,t)=>{let n=Rn.createTransformer(t),r=jn(e),i=jn(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?Jn.has(e)&&!i.values.length||Jn.has(t)&&!r.values.length?Yn(e,t):pt(Qn(er(r,i),i.values),n):(`${e}${t}`,Vn(e,t))},nr=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]*)$/iu;function rr(e,t){let n=nr.exec(e);if(!n)return;let r=nr.exec(t);if(!r||n[2]!==r[2])return;let i=n[2],a=parseFloat(n[1]),o=parseFloat(r[1]);return e=>Gt(Hn(a,o,e))+i}function ir(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return Hn(e,t,n);if(typeof e==`string`&&typeof t==`string`){let n=rr(e,t);if(n)return n}return Zn(e)(e,t)}var ar=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function or(e){let t=new Set,n=new Set,r=!1,i=!1,a=new Set,o={delta:0,timestamp:0,isProcessing:!1};function s(t){a.has(t)&&(n.add(t),e()),t(o)}let c={schedule:(e,i=!1,o=!1)=>{let s=o&&r?t:n;return i&&a.add(e),s.add(e),e},cancel:e=>{n.delete(e),a.delete(e)},process:e=>{if(o=e,r){i=!0;return}r=!0;let a=t;t=n,n=a,t.forEach(s),t.clear(),r=!1,i&&(i=!1,c.process(e))}};return c}var sr=40;function cr(e,t,n={delta:0,timestamp:0,isProcessing:!1}){let r=!1,i=!0,a=()=>r=!0,o=ar.reduce((e,t)=>(e[t]=or(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=st.useManualTiming,o=a?n.timestamp:performance.now();r=!1,a||(n.delta=i?1e3/60:Math.max(Math.min(o-n.timestamp,sr),1)),n.timestamp=o,n.isProcessing=!0,s.process(n),c.process(n),l.process(n),u.process(n),d.process(n),f.process(n),p.process(n),m.process(n),n.isProcessing=!1,r&&t&&(i=!1,e(h))},g=()=>{r=!0,i=!0,n.isProcessing||e(h)};return{schedule:ar.reduce((e,t)=>{let n=o[t];return e[t]=(e,t=!1,i=!1)=>(r||g(),n.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<ar.length;t++)o[ar[t]].cancel(e)},state:n,steps:o}}var{schedule:lr,cancel:ur,steps:dr}=cr(typeof requestAnimationFrame<`u`?requestAnimationFrame:ft,!0,Vt),fr=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>lr.update(t,e),stop:()=>ur(t),now:()=>Vt.isProcessing?Vt.timestamp:Wt.now()}},pr=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},mr=2e4;function hr(e,t=50,n=mr,r){let i=0,a=e.next(i);for(r?.push(a.value);!a.done&&i<n;)i+=t,a=e.next(i),r?.push(a.value);return i>=n?1/0:i}function gr(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(hr(r),mr);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:_t(i)}}var _r={stiffness:100,damping:10,mass:1,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05},vr=e=>e<0?1/Math.max(1+e,_r.minDamping):Math.max(1-e,_r.minDamping);function yr(e,t){if(!(e>1))return 1;let n=Math.sqrt(e*e-1),r=e-n,i=e+n,a=2*n*Math.exp(-t)*(1+t);return Sr(e=>i*Math.exp(-r*e)-r*Math.exp(-i*e)-a,e=>Math.exp(-i*e)-Math.exp(-r*e),t)/t}function br(e,t){return e*Math.sqrt(1-t*t)}var xr=12;function Sr(e,t,n){let r=n;for(let n=1;n<xr;n++)r-=e(r)/t(r);return r}var Cr=.001;function wr({duration:e=_r.duration,bounce:t=_r.bounce}){let n,r;_r.maxDuration;let i=vr(t);e=ot(_r.minDuration,_r.maxDuration,_t(e)),i<1?(n=t=>{let n=t*i,r=n*e,a=br(t,i),o=Math.exp(-r);return Cr-n/a*o},r=t=>{let r=t*i*e,a=i*i*t*t*e,o=Math.exp(-r),s=br(t*t,i);return(-n(t)+Cr>0?-1:1)*-a*o/s}):(n=t=>-.001+Math.exp(-t*e)*(t*e+1),r=t=>Math.exp(-t*e)*(-t*(e*e)));let a=5/e,o=Sr(n,r,a),s=o*yr(i,o*e),c=s*s;return{stiffness:c,damping:i*2*Math.sqrt(c),duration:gt(e)}}var Tr=(e,t)=>(t?e>=0:e>0)&&e<1/0;function Er(e,t){if(Tr(e,t))return e}function Dr(e){let t=Er(e.stiffness),n=Er(e.damping,!0),r=Er(e.mass),i={...e,stiffness:t??_r.stiffness,damping:n??_r.damping,mass:r??_r.mass,isResolvedFromDuration:!1,isTimeDefined:(t??n??r)===void 0&&(e.duration!==void 0||e.bounce!==void 0)};if(i.isTimeDefined){if(e.visualDuration){let t=vr(e.bounce||0),n=2*Math.PI/(e.visualDuration*1.2)*yr(t,2*Math.PI/1.2);i.stiffness=n*n,i.damping=2*t*Math.sqrt(i.stiffness)}else Object.assign(i,wr(i)),i.isResolvedFromDuration=!0;(!Tr(i.stiffness)||!Tr(i.damping,!0))&&(i.stiffness=_r.stiffness,i.damping=_r.damping)}return i}function Or(e=_r.visualDuration,t=_r.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},r=n.keyframes[0],i=n.keyframes[n.keyframes.length-1],a={done:!1,value:r},{stiffness:o,damping:s,mass:c,duration:l,isResolvedFromDuration:u,isTimeDefined:d}=Dr({...n}),f=e=>d?0:-_t(e),p=s/(2*Math.sqrt(o*c)),m=_t(Math.sqrt(o/c)),h=p*m,g={target:i,delta:i-r,velocity:f(n.velocity||0)||0,restSpeed:0,restDelta:0},_=()=>{let e=Math.abs(g.delta)<5;g.restSpeed=n.restSpeed||(e?_r.restSpeed.granular:_r.restSpeed.default),g.restDelta=n.restDelta||(e?_r.restDelta.granular:_r.restDelta.default)};_();let v,y,b;if(p<1){let e=br(m,p),t={A:0,sinC:0,cosC:0,t:-1,env:0,sin:0,cos:0};b=()=>{t.A=(g.velocity+h*g.delta)/e,t.sinC=h*t.A+g.delta*e,t.cosC=h*g.delta-t.A*e};let n=n=>{n!==t.t&&(t.t=n,t.env=Math.exp(-h*n),t.sin=Math.sin(e*n),t.cos=Math.cos(e*n))};v=e=>(n(e),g.target-t.env*(t.A*t.sin+g.delta*t.cos)),y=e=>(n(e),t.env*(t.sinC*t.sin+t.cosC*t.cos))}else if(p===1){v=e=>g.target-Math.exp(-m*e)*(g.delta+(g.velocity+m*g.delta)*e);let e={C:0};b=()=>{e.C=g.velocity+m*g.delta},y=t=>Math.exp(-m*t)*(m*e.C*t-g.velocity)}else{let e=m*Math.sqrt(p*p-1),t=h-e,n=h+e,r=d?1/0:300/e,i=(e,t)=>Math.exp(t>r?-e*r-h*(t-r):-e*t),a={S:0,F:0};b=()=>{let t=(g.velocity+h*g.delta)/e;a.S=(g.delta+t)/2,a.F=(g.delta-t)/2},v=e=>g.target-a.S*i(t,e)-a.F*i(n,e),y=e=>t*a.S*i(t,e)+n*a.F*i(n,e)}b();let x=u&&l||null,S={calculatedDuration:x,retarget:(e,t)=>{g.target=e[e.length-1],g.delta=g.target-e[0],g.velocity=f(t),n.restSpeed&&n.restDelta||_(),S.calculatedDuration=x,a.done=!1,b()},velocity:e=>gt(y(e)),next:e=>{let t=v(e);if(u)a.done=e>=l;else{let n=gt(y(e));a.done=Math.abs(n)<=g.restSpeed&&Math.abs(g.target-t)<=g.restDelta}return a.value=a.done?g.target:t,a},toString:()=>{let e=Math.min(hr(S),mr),t=pr(t=>S.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return S}Or.applyToOptions=e=>{let t=gr(e,100,Or);return e.ease=t.ease,e.duration=gt(t.duration),e.type=`keyframes`,e};function kr({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>e<s||e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>{let t=v(e);f.done=Math.abs(t)<=l,f.value=f.done?_:_+t},b,x,S=e=>{p(f.value)&&(b=e,x=Or({keyframes:[f.value,m(f.value)],velocity:-v(e)/r*1e3,damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return S(0),{calculatedDuration:null,next:e=>{let t=!1;return!x&&b===void 0&&(t=!0,y(e),S(e)),b!==void 0&&e>=b?x.next(e-b):(!t&&y(e),f)}}}function Ar(e,t,n){let r=[],i=n||st.mix||ir,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=pt(Array.isArray(t)?t[n]||ft:t,a)),r.push(a)}return r}function jr(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=Ar(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=mt(e[r],e[r+1],n);return s[r](i)};return n?t=>l(ot(e[0],e[a-1],t)):l}function Mr(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=mt(0,t,r);e.push(Hn(n,1,i))}}function Nr(e){let t=[0];return Mr(t,e.length-1),t}function Pr(e,t){return e.map(e=>e*t)}function Fr(e,t){return e.map(()=>t||Ft).splice(0,e.length-1)}function Ir({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=It(r)?r.map(Bt):Bt(r)||Ft,a={done:!1,value:t[0]};if(t.length===2&&!Array.isArray(i)&&(!n||n.length!==2||n[0]===0&&n[1]===1)){let[n,r]=t,o=n===r?void 0:(st.mix||ir)(n,r);return{calculatedDuration:e,next:t=>(a.value=o?o(i(e>0?ot(0,1,t/e):1)):r,a.done=t>=e,a)}}let o=jr(Pr(n&&n.length===t.length?n:Nr(t),e),t,{ease:Array.isArray(i)?i:Fr(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var Lr=5;function Rr(e,t,n){let r=Math.max(t-Lr,0);return vt(n-e(r),t-r)}function zr(e,t,n=0){return t<=0?n:e.velocity?e.velocity(t):Rr(t=>e.next(t).value,t,e.next(t).value)}var Br=e=>e!==null;function Vr(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(Br),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var Hr={decay:kr,inertia:kr,tween:Ir,keyframes:Ir,spring:Or};function Ur(e){typeof e.type==`string`&&(e.type=Hr[e.type])}function Wr(e,t){return{kind:e,animation:t,timestamp:Wt.now(),frameTimestamp:Vt.timestamp,frameIsProcessing:Vt.isProcessing}}function Gr(e,t,n){let r=globalThis.__MOTION_INSPECT__;if(r)try{r({...Wr(`animation-start`,e),options:n?{...t,...n}:t})}catch{}}function Kr(e,t){let n=globalThis.__MOTION_INSPECT__;if(n)try{n({...Wr(`layout-animation-start`,e),node:t})}catch{}}var qr=class{constructor(){this.isResolved=!1}get finished(){return this._finished||=this.isResolved?Promise.resolve():new Promise(e=>{this._resolve=e}),this._finished}updateFinished(){this._finished=this._resolve=void 0,this.isResolved=!1}notifyFinished(){this.isResolved=!0,this._resolve?.()}then(e,t){return this.finished.then(e,t)}},Jr=e=>e/100,Yr=class extends qr{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==Wt.now()&&this.tick(Wt.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause(),Gr(this,this.options)}initAnimation(){let{options:e}=this;Ur(e);let{type:t=Ir,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||Ir;s!==Ir&&typeof o[0]!=`number`&&(this.mixKeyframes=pt(Jr,ir(o[0],o[1])),o=[0,100]);let c=s(o===e.keyframes?e:{...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=hr(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.currentTime=this.holdTime===null?t:this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=ot(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==kr&&(b.value=Vr(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return _t(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+_t(e)}get time(){return _t(this.currentTime)}set time(e){e=gt(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){return zr(this.generator,this.currentTime,this.options.velocity)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(Wt.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=_t(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=fr,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??n:this.startTime=n-this.holdTime,this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(Wt.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}},Xr=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function Zr(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(tn)||[];if(!r)return e;let i=n.replace(r,``),a=+!!Xr.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var Qr=/\b([a-z-]*)\(.*?\)/gu,$r={...Rn,getAnimatableNone:e=>{let t=e.match(Qr);return t?t.map(Zr).join(` `):e}},ei={...Rn,getAnimatableNone:e=>{let t=Rn.parse(e);return Rn.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},ti={...Qt,transform:Math.round},ni={borderWidth:R,borderTopWidth:R,borderRightWidth:R,borderBottomWidth:R,borderLeftWidth:R,borderRadius:R,borderTopLeftRadius:R,borderTopRightRadius:R,borderBottomRightRadius:R,borderBottomLeftRadius:R,width:R,maxWidth:R,height:R,maxHeight:R,top:R,right:R,bottom:R,left:R,inset:R,insetBlock:R,insetBlockStart:R,insetBlockEnd:R,insetInline:R,insetInlineStart:R,insetInlineEnd:R,padding:R,paddingTop:R,paddingRight:R,paddingBottom:R,paddingLeft:R,paddingBlock:R,paddingBlockStart:R,paddingBlockEnd:R,paddingInline:R,paddingInlineStart:R,paddingInlineEnd:R,margin:R,marginTop:R,marginRight:R,marginBottom:R,marginLeft:R,marginBlock:R,marginBlockStart:R,marginBlockEnd:R,marginInline:R,marginInlineStart:R,marginInlineEnd:R,fontSize:R,backgroundPositionX:R,backgroundPositionY:R,rotate:pn,pathRotation:pn,rotateX:pn,rotateY:pn,rotateZ:pn,scale:en,scaleX:en,scaleY:en,scaleZ:en,skew:pn,skewX:pn,skewY:pn,distance:R,translateX:R,translateY:R,translateZ:R,x:R,y:R,z:R,perspective:R,transformPerspective:R,opacity:$t,originX:_n,originY:_n,originZ:R,zIndex:ti,fillOpacity:$t,strokeOpacity:$t,numOctaves:ti},ri={...ni,color:yn,backgroundColor:yn,outlineColor:yn,fill:yn,stroke:yn,borderColor:yn,borderTopColor:yn,borderRightColor:yn,borderBottomColor:yn,borderLeftColor:yn,filter:$r,WebkitFilter:$r,mask:ei,WebkitMask:ei},ii=e=>ri[e],ai=new Set([$r,ei]);function oi(e,t){let n=ii(e);return ai.has(n)||(n=Rn),n.getAnimatableNone?n.getAnimatableNone(t):void 0}function si(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var ci=e=>e*180/Math.PI,li=e=>di(ci(Math.atan2(e[1],e[0]))),ui={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:li,rotateZ:li,skewX:e=>ci(Math.atan(e[1])),skewY:e=>ci(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},di=e=>(e%=360,e<0&&(e+=360),e),fi=li,pi=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),mi=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),hi={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:pi,scaleY:mi,scale:e=>(pi(e)+mi(e))/2,rotateX:e=>di(ci(Math.atan2(e[6],e[5]))),rotateY:e=>di(ci(Math.atan2(-e[2],e[0]))),rotateZ:fi,rotate:fi,skewX:e=>ci(Math.atan(e[4])),skewY:e=>ci(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function gi(e){return+!!e.includes(`scale`)}function _i(e,t){if(!e||e===`none`)return gi(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=hi,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=ui,i=t}if(!i)return gi(t);let a=r[t],o=i[1].split(`,`).map(yi);return typeof a==`function`?a(o):o[a]}var vi=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return _i(n,t)};function yi(e){return parseFloat(e.trim())}var bi=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],xi=new Set([...bi,`pathRotation`]),Si=e=>e===Qt||e===R,Ci=new Set([`x`,`y`,`z`]),wi=bi.filter(e=>!Ci.has(e));function Ti(e){let t=[];return wi.forEach(n=>{let r=e.getValue(n);if(r!==void 0){let e=r.get(),i=+!!n.startsWith(`scale`);if(e===i)return;t.push([n,e]),r.set(i)}}),t}var Ei=new Set([`bottom`,`right`]);function Di(e,t,n,r,i,a){let o=parseFloat(e);if(!isNaN(o))return o;let{min:s,max:c}=t()[n],l=c-s;return a===`border-box`?l:l-parseFloat(r)-parseFloat(i)}var Oi={width:({width:e,paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r},i)=>Di(e,i,`x`,t,n,r),height:({height:e,paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r},i)=>Di(e,i,`y`,t,n,r),top:({top:e})=>parseFloat(e),left:({left:e})=>parseFloat(e),bottom:({top:e},t)=>{let{y:n}=t();return parseFloat(e)+(n.max-n.min)},right:({left:e},t)=>{let{x:n}=t();return parseFloat(e)+(n.max-n.min)},x:({transform:e})=>_i(e,`x`),y:({transform:e})=>_i(e,`y`)};Oi.translateX=Oi.x,Oi.translateY=Oi.y;var ki=new Set,Ai=!1,ji=!1,Mi=!1;function Ni(){if(ji){let e=[],t=new Set,n=new Set;ki.forEach(r=>{r.needsMeasurement&&(e.push(r),t.add(r.element),Ei.has(r.name)&&n.add(r.element))});let r=new Map;n.forEach(e=>{let t=Ti(e);t.length&&(r.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=r.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}ji=!1,Ai=!1,ki.forEach(e=>e.complete(Mi)),ki.clear()}function Pi(){ki.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(ji=!0)})}function Fi(){Mi=!0,Pi(),Ni(),Mi=!1}function Ii(e,t,n){if(typeof e==`string`){if(ct(e)||ut(e))return parseFloat(e);if(!Rn.test(e)&&Rn.test(n))return oi(t,n)}return e??void 0}var Li=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(ki.add(this),Ai||(Ai=!0,lr.read(Pi),lr.resolveKeyframes(Ni))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=Ii(n.readValue(t,a),t,a);r!==void 0&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}si(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),ki.delete(this)}cancel(){this.state===`scheduled`&&(ki.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},Ri=e=>e.startsWith(`--`);function zi(e,t,n){Ri(t)?e.style.setProperty(t,n):e.style[t]=n}var Bi={};function Vi(e,t){let n=dt(e);return()=>Bi[t]??n()}var Hi=Vi(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),Ui=Vi(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),Wi=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Gi={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:Wi([0,.65,.55,1]),circOut:Wi([.55,0,1,.45]),backIn:Wi([.31,.01,.66,-.59]),backOut:Wi([.33,1.53,.69,.99])};function Ki(e,t){if(e)return typeof e==`function`?Ui()?pr(e,t):`ease-out`:Lt(e)?Wi(e):Array.isArray(e)?e.map(e=>Ki(e,t)||Gi.easeOut):Gi[e]}function qi(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=Ki(s,i);Array.isArray(d)&&(u.easing=d);let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};return l&&(f.pseudoElement=l),e.animate(u,f)}function Ji(e){return typeof e==`function`&&`applyToOptions`in e}function Yi({type:e,...t}){return Ji(e)&&Ui()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var Xi=class extends qr{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=Yi(e);this.animation=qi(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=Vr(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),zi(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()},Gr(this,e,c)}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e!==`idle`&&e!==`finished`&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return _t(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+_t(e)}get time(){return _t(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=gt(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,onAttach:t,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&Hi()?(this.animation.timeline=e,t?.(this.animation),ft):n(this)}},Zi={anticipate:kt,backInOut:Ot,circInOut:Mt};function Qi(e){return e in Zi}function $i(e){typeof e.ease==`string`&&Qi(e.ease)&&(e.ease=Zi[e.ease])}var ea=10,ta=class extends Xi{constructor(e){$i(e),Ur(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new Yr({...a,autoplay:!1}),s=Math.max(ea,Wt.now()-this.startTime),c=ot(0,ea,s-ea),l=o.sample(s).value,{name:u}=this.options;i&&u&&zi(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},na=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(Rn.test(e)||e===`0`)&&!e.startsWith(`url(`));function ra(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function z(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=na(i,t),s=na(a,t);return!o||!s?(o!==s&&`${t}${i}${a}${o?a:i}`,!1):ra(e)||(n===`spring`||Ji(n))&&r}function ia(e){e.duration=0,e.type=`keyframes`}var aa=new Set([`opacity`,`clipPath`,`filter`,`transform`,`backgroundColor`]),oa=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function sa(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&oa.test(e[t]))return!0;return!1}var ca=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),la=dt(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function ua(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!n||!(aa.has(n)||ca.has(n)))return!1;let c=t?.owner?.current;if(!(c instanceof HTMLElement)&&!(c instanceof SVGElement))return!1;let{onUpdate:l,transformTemplate:u}=t.owner.getProps();return la()&&(aa.has(n)||ca.has(n)&&sa(s))&&(n!==`transform`||!u)&&!l&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var da=40,fa=class extends qr{constructor(e){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Wt.now();let{keyframes:t,name:n,motionValue:r,element:i}=e,a=e;a.autoplay??=!0,a.delay??=0,a.type??=`keyframes`,a.repeat??=0,a.repeatDelay??=0,a.repeatType??=`loop`;let o=i?.KeyframeResolver||Li;this.keyframeResolver=new o(t,(e,t,n)=>this.onKeyframesResolved(e,t,a,!n),n,r,i),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=Wt.now();let u=!0;z(e,i,a,o)||(u=!1,(st.instantAnimations||!s)&&l?.(Vr(e,n,t)),e[0]=e[e.length-1],ia(n),n.repeat=0);let d=r?this.resolvedAt&&this.resolvedAt-this.createdAt>da?this.resolvedAt:this.createdAt:void 0,{onComplete:f}=n;n.startTime??=d,n.finalKeyframe=t,n.keyframes=e,n.onComplete=()=>{f?.(),this.notifyFinished()};let p=u&&!c&&ua(n),m;if(p){n.element=n.motionValue?.owner?.current;try{m=new ta(n)}catch{m=new Yr(n)}}else m=new Yr(n);this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this._animation.finished:super.finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Fi()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function pa(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var ma=30,ha=e=>!isNaN(parseFloat(e)),ga={current:void 0},_a=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=Wt.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.notifyChange(),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=Wt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=ha(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){var n;return e===`change`?this.onChangeSubscribe(t):((n=this.events)[e]||(n[e]=new ht)).add(t)}onChangeSubscribe(e){let{events:t}=this;return!t.change&&!this.changeSubscriber?this.changeSubscriber=e:(t.change||(t.change=new ht,t.change.add(this.changeSubscriber),this.changeSubscriber=void 0),t.change.add(e)),()=>{this.changeSubscriber===e?this.changeSubscriber=void 0:t.change?.remove(e),this.stopIfUnobserved()}}stopIfUnobserved(){lr.read(()=>{!this.changeSubscriber&&!this.events.change?.getSize()&&this.stop()})}clearListeners(){this.changeSubscriber=void 0;for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.notifyChange()}notifyChange(){let{current:e,changeSubscriber:t}=this;t?t(e):this.events.change?.notify(e)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return ga.current&&ga.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=Wt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>ma)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,ma);return vt(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0;let n=!1,r;r=e(()=>{n=!0,this.events.animationComplete?.notify(),this.animation===r&&this.clearAnimation(),t()}),n||(this.animation=r),this.events.animationStart?.notify()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){this.animation=void 0}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function va(e,t){return new _a(e,t)}function ya(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function ba(e,t){let n=e?.[t]??e?.default??e;return n===e?n:ya(n,e)}var xa={type:`spring`,stiffness:500,damping:25,restSpeed:10},Sa=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Ca={type:`keyframes`,duration:.8},wa={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Ta=(e,{keyframes:t})=>t.length>2?Ca:xi.has(e)?e.startsWith(`scale`)?Sa(t[1]):xa:wa,Ea=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function Da(e){for(let t in e)if(!Ea.has(t))return!0;return!1}var Oa=(e,t,n,r={},i,a)=>o=>{let s=ba(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=gt(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};Da(s)||Object.assign(u,Ta(e,u)),u.duration&&=gt(u.duration),u.repeatDelay&&=gt(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(ia(u),u.delay===0&&(d=!0)),(st.instantAnimations||st.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,ia(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=Vr(u.keyframes,s);if(e!==void 0){lr.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new Yr(u):new fa(u)},ka=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Aa(e){let t=ka.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function ja(e,t,n=1){`${e}`;let[r,i]=Aa(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return ct(e)?parseFloat(e):e}return Yt(i)?ja(i,t,n+1):i}function Ma(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Na(e,t,n,r){let i=t=>typeof t==`function`?t(n===void 0?e.custom:n,...Ma(r)):t;return t=i(t),typeof t==`string`&&(t=e.variants&&e.variants[t]),i(t)}function Pa(e,t,n){return Na(e.getProps(),t,n,e)}var Fa=(e,t)=>t===`exit`?e.presenceContext?.custom:void 0,Ia=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...bi]),La=e=>Array.isArray(e);function Ra(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,va(n))}function za(e){return La(e)?e[e.length-1]||0:e}function Ba(e,t){let{transitionEnd:n={},transition:r={},...i}=Pa(e,t)||{};i={...i,...n};for(let t in i)Ra(e,t,za(i[t]))}var Va=e=>!!(e&&e.getVelocity);function Ha(e){return!!(Va(e)&&e.add)}function Ua(e,t){let n=e.getValue(`willChange`);if(Ha(n))return n.add(t);if(!n&&st.WillChange){let n=new st.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function Wa(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var Ga=`data-`+Wa(`framerAppearId`);function Ka(e){return e.props[Ga]}var qa=typeof window<`u`;function Ja({protectedKeys:e,needsAnimating:t},n){let r=n in e&&!t[n];return t[n]=!1,r}function Ya(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?ya(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f=i&&e.animationState?.getState()[i],p=a?.path;p&&p.animateVisualElement(e,s,a,n,d);for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||f&&Ja(f,t))continue;let o={delay:n,...ba(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){lr.update(()=>r.set(i));continue}let p=!1;if(qa&&window.MotionHandoffAnimation){let n=Ka(e);if(n){let e=window.MotionHandoffAnimation(n,t,lr);e!==null&&(o.startTime=e,p=!0)}}Ua(e,t);let m=l??e.shouldReduceMotion;r.start(Oa(t,r,i,m&&Ia.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>lr.update(()=>{o&&Ba(e,o)});d.length?Promise.all(d).then(t):t()}return d}function Xa(e,t,n={}){let r=Pa(e,t,Fa(e,n.type)),i=n.transitionOverride||(r?.transition??(e.getDefaultTransition()||{})),a=()=>Promise.all(r?Ya(e,r,n):[]),o=(r=0)=>{let{variantChildren:a}=e,{delayChildren:o=0,staggerChildren:s,staggerDirection:c}=i,l=[];return a?.forEach(e=>{e.notify(`AnimationStart`,t),l.push(Xa(e,t,{...n,delay:r+(typeof o==`function`?0:o)+pa(a,e,o,s,c)}).then(()=>e.notify(`AnimationComplete`,t)))}),Promise.all(l)},{when:s}=i;return s?s===`beforeChildren`?a().then(()=>o()):o().then(a):Promise.all([a(),o(n.delay)])}function Za(e,t,n={}){return e.notify(`AnimationStart`,t),(Array.isArray(t)?Promise.all(t.map(t=>Xa(e,t,n))):typeof t==`string`?Xa(e,t,n):Promise.all(Ya(e,Pa(e,t,n.custom),n))).then(()=>{e.notify(`AnimationComplete`,t)})}var Qa={test:e=>e===`auto`,parse:e=>e},$a=e=>t=>t.test(e),eo=[Qt,R,mn,pn,gn,hn,Qa],to=e=>eo.find($a(e));function no(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||ut(e)}var ro=new Set([`auto`,`none`,`0`]);function io(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!ro.has(t)&&An(t)&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]!==i&&(e[r]=oi(n,i))}var ao=class extends Li{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),Yt(r))){let i=ja(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Ia.has(n)||e.length!==2)return;let[r,i]=e;if(typeof r==`number`&&typeof i==`number`)return;let a=to(r),o=to(i);if(Zt(r)!==Zt(i)&&Oi[n]){this.needsMeasurement=!0;return}if(a!==o){if(Si(a)&&Si(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else Oi[n]&&(this.needsMeasurement=!0)}}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||no(e[t]))&&n.push(t);n.length&&io(e,n,t)}measure(){let{element:e,name:t}=this;return Oi[t](window.getComputedStyle(e.current),()=>e.measureViewportBox())}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=this.measure(),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&this.motionValue?.jump(r,!1)}measureEndState(){let{element:e,unresolvedKeyframes:t}=this;if(!e||!e.current)return;this.motionValue?.jump(this.measuredOrigin,!1);let n=t.length-1,r=t[n];t[n]=this.measure(),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}},oo=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function so(e){return lt(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}function co(e){return lt(e)&&`ownerSVGElement`in e}var lo=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function uo(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var fo={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},po=bi.length;function mo(e,t,n){let r=``,i=!0;for(let a=0;a<po;a++){let o=bi[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===+!!o.startsWith(`scale`);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=lo(s,ni[o]);if(!c){i=!1;let t=fo[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${lo(a,ni.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function ho(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(xi.has(e)){o=!0;continue}if(qt(e)){i[e]=n;continue}{let t=lo(n,ni[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=mo(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}var go={offset:`stroke-dashoffset`,array:`stroke-dasharray`},_o={offset:`strokeDashoffset`,array:`strokeDasharray`};function vo(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?go:_o;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var yo=[`transform`,`opacity`,`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function bo(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(ho(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;for(let e of yo)d[e]!==void 0&&(f[e]=d[e],delete d[e]);(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox),t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&vo(d,i,a,o,!1)}function xo({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function So({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Co(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function wo(e){return e===void 0||e===1}function To({scale:e,scaleX:t,scaleY:n}){return!wo(e)||!wo(t)||!wo(n)}function Eo(e){return To(e)||Do(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Do(e){return Oo(e.x)||Oo(e.y)}function Oo(e){return e&&e!==`0%`}function ko(e,t,n){return n+t*(e-n)}function Ao(e,t,n,r,i){return i!==void 0&&(e=ko(e,i,r)),ko(e,n,r)+t}function jo(e,t=0,n=1,r,i){e.min=Ao(e.min,t,n,r,i),e.max=Ao(e.max,t,n,r,i)}function Mo(e,{x:t,y:n}){jo(e.x,t.translate,t.scale,t.originPoint),jo(e.y,n.translate,n.scale,n.originPoint)}var No=.999999999999,Po=1.0000000000001;function Fo(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(Io(e.x,-a.scroll.offset.x),Io(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,Mo(e,o)),r&&Eo(a.latestValues)&&zo(e,a.latestValues,a.layout?.layoutBox))}t.x<Po&&t.x>No&&(t.x=1),t.y<Po&&t.y>No&&(t.y=1)}function Io(e,t){e.min+=t,e.max+=t}function Lo(e,t,n,r,i=.5){jo(e,t,n,Hn(e.min,e.max,i),r)}function Ro(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function zo(e,t,n){let r=n??e;Lo(e.x,Ro(t.x,r.x),t.scaleX,t.scale,t.originX),Lo(e.y,Ro(t.y,r.y),t.scaleY,t.scale,t.originY)}function Bo(e,t){return xo(Co(e.getBoundingClientRect(),t))}function Vo(e,t,n){let r=Bo(e,n),{scroll:i}=t;return i&&(Io(r.x,i.offset.x),Io(r.y,i.offset.y)),r}var{schedule:B,cancel:Ho}=cr(queueMicrotask,!1),Uo={x:!1,y:!1};function Wo(){return Uo.x||Uo.y}function Go(e){return e===`x`||e===`y`?Uo[e]?null:(Uo[e]=!0,()=>{Uo[e]=!1}):Uo.x||Uo.y?null:(Uo.x=Uo.y=!0,()=>{Uo.x=Uo.y=!1})}function Ko(e,t){let n=uo(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function qo(e){return!(e.pointerType===`touch`||Wo())}function Jo(e,t,n={}){let[r,i,a]=Ko(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{if(e.pointerType!==`touch`){if(n){r=!0;return}s(e)}};e.addEventListener(`pointerenter`,n=>{if(!qo(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var Yo=(e,t)=>t?e===t||Yo(e,t.parentElement):!1,Xo=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Zo=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Qo(e){return Zo.has(e.tagName)||e.isContentEditable===!0}var $o=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function es(e){return $o.has(e.tagName)||e.isContentEditable===!0}var ts=new WeakSet;function ns(e){return t=>{t.key===`Enter`&&e(t)}}function rs(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var is=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=ns(()=>{if(ts.has(n))return;rs(n,`down`);let e=ns(()=>{rs(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>rs(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function as(e){return Xo(e)&&!Wo()}var os=new WeakSet;function ss(e,t,n={}){let[r,i,a]=Ko(e,n),o=e=>{let r=e.currentTarget;if(!as(e)||os.has(e))return;ts.add(r),n.stopPropagation&&os.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),ts.has(r)&&ts.delete(r),as(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||Yo(r,e.target))},l=e=>{s(e,!1)};window.addEventListener(`pointerup`,c,o),window.addEventListener(`pointercancel`,l,o)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),so(e)&&(e.addEventListener(`focus`,e=>is(e,i)),!Qo(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}var cs=new WeakMap,ls,us=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:co(r)&&`getBBox`in r?r.getBBox()[t]:r[n],ds=us(`inline`,`width`,`offsetWidth`),fs=us(`block`,`height`,`offsetHeight`);function ps({target:e,borderBoxSize:t}){cs.get(e)?.forEach(n=>{n(e,{get width(){return ds(e,t)},get height(){return fs(e,t)}})})}function ms(e){e.forEach(ps)}function hs(){typeof ResizeObserver<`u`&&(ls=new ResizeObserver(ms))}function gs(e,t){ls||hs();let n=uo(e);return n.forEach(e=>{let n=cs.get(e);n||(n=new Set,cs.set(e,n)),n.add(t),ls?.observe(e)}),()=>{n.forEach(e=>{let n=cs.get(e);n?.delete(t),n?.size||ls?.unobserve(e)})}}var _s=new Set,vs;function ys(){vs=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};_s.forEach(t=>t(e))},window.addEventListener(`resize`,vs)}function bs(e){return _s.add(e),vs||ys(),()=>{_s.delete(e),!_s.size&&typeof vs==`function`&&(window.removeEventListener(`resize`,vs),vs=void 0)}}function xs(e,t){return typeof e==`function`?bs(e):gs(e,t)}var Ss={value:null,addProjectionMetrics:null};function Cs(e){return co(e)&&e.tagName===`svg`}var ws=e=>typeof e==`number`?e:parseFloat(e),Ts=()=>({translate:0,scale:1,origin:0,originPoint:0}),Es=()=>({x:Ts(),y:Ts()}),Ds=()=>({min:0,max:0}),Os=()=>({x:Ds(),y:Ds()}),ks=new WeakMap;function As(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function js(e){return typeof e==`string`||Array.isArray(e)}var Ms=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],Ns=[`initial`,...Ms];function Ps(e){if(As(e.animate))return!0;for(let t=0;t<Ns.length;t++)if(js(e[Ns[t]]))return!0;return!1}function Fs(e){return!!(Ps(e)||e.variants)}function Is(e,t,n){for(let r in t){let i=t[r],a=n[r];if(Va(i))e.addValue(r,i);else if(Va(a))e.addValue(r,va(i,{owner:e}));else if(a!==i){if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,va(t===void 0?i:t,{owner:e}))}}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var Ls={current:null},Rs={current:!1},zs=typeof window<`u`;function Bs(){if(Rs.current=!0,zs){if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>Ls.current=e.matches;e.addEventListener(`change`,t),t()}else Ls.current=!1}}var Vs=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],Hs={};function Us(e){Hs=e}function Ws(){return Hs}var Gs=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=Li,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=Wt.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,lr.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=Ps(t),this.isVariantNode=Fs(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&Va(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];if(this.current=e,ks.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.isVariantNode&&!this.isControllingVariants){let e=this;do e=e.props.inherit!==!1&&e.parent;while(e&&!e.isVariantNode);if(e){let{variantChildren:t}=e;t.add(this),this.removeFromVariantTree=()=>t.delete(this)}}this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(Rs.current||Bs(),this.shouldReduceMotion=Ls.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),ur(this.notifyUpdate),ur(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&aa.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new Xi({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:gt(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=xi.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&lr.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i()})}sortNodePosition(e){return!this.current||!e.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in Hs){let t=Hs[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Os()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<Vs.length;t++){let n=Vs[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=Is(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}addValue(e,t){let n=this.values.get(e);if(t!==n){n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t);let r=t.get();r!==void 0&&(this.latestValues[e]=r)}}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=va(t??this.getDefaultValue?.(e),{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(ct(n)||ut(n))?n=parseFloat(n):typeof n!=`number`&&!Rn.test(n)&&Rn.test(t)&&(n=oi(e,t)),this.setBaseTarget(e,Va(n)?n.get():n)),Va(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}on(e,t){return this.events[e]||(this.events[e]=new ht),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){B.render(this.render)}},Ks=class extends Gs{constructor(){super(...arguments),this.KeyframeResolver=ao}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;Va(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},qs=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function Js(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}var Ys={};function Xs(e,{layout:t,layoutId:n}){return xi.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!Ys[e]||e===`opacity`)}function Zs(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(Va(r[t])||i&&Va(i[t])||Xs(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function Qs(e){return window.getComputedStyle(e)}var $s=class extends Ks{constructor(){super(...arguments),this.type=`html`,this.renderInstance=Js}mount(e){e.style,super.mount(e)}readValueFromInstance(e,t){if(xi.has(t))return this.projection?.isProjecting?gi(t):vi(e,t);{let n=Qs(e),r=(qt(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return Bo(e,t)}build(e,t,n){ho(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return Zs(e,t,n)}},ec=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),tc=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function nc(e,t,n,r){Js(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(ec.has(n)?n:Wa(n),t.attrs[n])}function rc(e,t,n){let r=Zs(e,t,n);for(let n in e)if(Va(e[n])||Va(t[n])){let t=bi.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var ic=class extends Ks{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=Os}getBaseTargetFromProps(e,t){return xi.has(t)?super.getBaseTargetFromProps(e,t)??gi(t):e[t]}getDefaultValue(e){return xi.has(e)?this.latestValues[e]??gi(e):void 0}readValueFromInstance(e,t){if(xi.has(t)){let e=ii(t);return e&&e.default||0}if(yo.includes(t)){let n=getComputedStyle(e)[t];if(typeof n==`string`&&n)return n.trim()}return t=ec.has(t)?t:Wa(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return rc(e,t,n)}build(e,t,n){bo(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){nc(e,t,n,r)}mount(e){this.isSVGTag=tc(e.tagName),super.mount(e)}};function ac(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var oc=[...Ms].reverse();function sc(e){let t=t=>Promise.all(t.map(({animation:t,options:n})=>Za(e,t,n))),n=lc(),r=!0,i=!1;function a(a){let{props:o,parent:s,manuallyAnimateOnMount:c}=e,l=r||i,u=[],d=new Set,f={},p=1/0,m=e;do m=m.props.inherit!==!1&&m.parent;while(m&&!m.isControllingVariants);if(oc.forEach((t,r)=>{let i=n[t],h=o[t],g=m&&m.props[t],_=h===void 0?js(g)||g===!1?g:void 0:h,v=js(_),y=t===a?i.isActive:null;y===!1&&(p=r);let b=v&&h===void 0&&!(l&&c);if(i.protectedKeys={...f},!i.isActive&&y===null||!_&&!i.prevProp||As(_)||typeof _==`boolean`)return;if(t===`exit`&&i.isActive&&y!==!0){f={...f,...i.prevResolvedValues};return}let x=cc(i.prevProp,_),S=x||v&&(y&&!b||r>p),C=!1,w=Array.isArray(_)?_:[_],T={};if(y!==!1)for(let n of w){let{transition:r,transitionEnd:i,...a}=Pa(e,n,Fa(e,t))||{};T={...T,...a,...i}}let{prevResolvedValues:E}=i;for(let t in{...E,...T}){if(t in f)continue;let n=T[t],r=E[t],a=Array.isArray(n)&&Array.isArray(r)?!ac(n,r)||x:n!==r;if(a&&n==null)d.add(t);else if(a||n!==void 0&&d.has(t)){S=!0,d.delete(t)&&(C=!0),i.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)}else i.protectedKeys[t]=!0}if(i.prevProp=_,i.prevResolvedValues=T,i.isActive&&(f={...f,...T}),S&&(!(b&&x)||C))for(let n of w){let r={type:t};if(typeof n==`string`&&l&&c&&s?.enteringChildren){let t=Pa(s,n)?.transition?.delayChildren;r.delay=pa(s.enteringChildren,e,t)}u.push({animation:n,options:r})}}),d.size){let{initial:t}=o,n={},r=typeof t!=`boolean`&&Pa(e,Array.isArray(t)?t[0]:t,e.presenceContext?.custom);r&&r.transition&&(n.transition=r.transition),d.forEach(i=>{let a=e.getValue(i);a&&(a.liveStyle=!0);let s=r&&!Array.isArray(t)?r[i]:void 0,c=e.getBaseTargetFromProps(o,i);n[i]=(s===void 0?c!==void 0&&!Va(c)?c:e.initialValues[i]===void 0?e.baseTarget[i]:void 0:s)??null}),u.push({animation:n})}let h=l&&e.blockInitialAnimation||r&&!c&&(o.initial===!1||o.initial===o.animate);return r=i=!1,!h&&u.length?t(u):Promise.resolve()}function o(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=a(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:a,setActive:o,setAnimateFunction:n=>{t=n(e)},getState:()=>n,reset:()=>{n=lc(),i=!0}}}function cc(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!ac(t,e):!1}function lc(){let e={};for(let t of Ms)e[t]={isActive:t===`animate`,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}};return e}function uc(e,t){e.min=t.min,e.max=t.max}function dc(e,t){uc(e.x,t.x),uc(e.y,t.y)}function fc(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var pc=.9999,mc=1.0001,hc=-.01,gc=.01;function _c(e){return e.max-e.min}function vc(e,t,n){return Math.abs(e-t)<=n}function yc(e,t,n,r=.5){e.origin=r,e.originPoint=Hn(t.min,t.max,e.origin),e.scale=_c(n)/_c(t),e.translate=Hn(n.min,n.max,e.origin)-e.originPoint,(e.scale>=pc&&e.scale<=mc||isNaN(e.scale))&&(e.scale=1),(e.translate>=hc&&e.translate<=gc||isNaN(e.translate))&&(e.translate=0)}function bc(e,t,n,r){yc(e.x,t.x,n.x,r?r.originX:void 0),yc(e.y,t.y,n.y,r?r.originY:void 0)}function xc(e,t,n,r=0){e.min=(r?Hn(n.min,n.max,r):n.min)+t.min,e.max=e.min+_c(t)}function Sc(e,t,n,r){xc(e.x,t.x,n.x,r?.x),xc(e.y,t.y,n.y,r?.y)}function Cc(e,t,n,r=0){let i=r?Hn(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+_c(t)}function wc(e,t,n,r){Cc(e.x,t.x,n.x,r?.x),Cc(e.y,t.y,n.y,r?.y)}function Tc(e,t,n,r,i){return e-=t,e=ko(e,1/n,r),i!==void 0&&(e=ko(e,1/i,r)),e}function Ec(e,t=0,n=1,r=.5,i,a=e,o=e){if(mn.test(t)&&(t=parseFloat(t),t=Hn(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=Hn(a.min,a.max,r);e===a&&(s-=t),e.min=Tc(e.min,t,n,s,i),e.max=Tc(e.max,t,n,s,i)}function Dc(e,t,[n,r,i],a,o){Ec(e,t[n],t[r],t[i],t.scale,a,o)}var Oc=[`x`,`scaleX`,`originX`],kc=[`y`,`scaleY`,`originY`];function Ac(e,t,n,r){Dc(e.x,t,Oc,n?n.x:void 0,r?r.x:void 0),Dc(e.y,t,kc,n?n.y:void 0,r?r.y:void 0)}function jc(e){return e.translate===0&&e.scale===1}function Mc(e){return jc(e.x)&&jc(e.y)}function Nc(e,t){return e.min===t.min&&e.max===t.max}function Pc(e,t){return Nc(e.x,t.x)&&Nc(e.y,t.y)}function Fc(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Ic(e,t){return Fc(e.x,t.x)&&Fc(e.y,t.y)}function Lc(e){return _c(e.x)/_c(e.y)}function Rc(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function zc(e){return[e(`x`),e(`y`)]}function Bc(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var Vc={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`){if(R.test(e))e=parseFloat(e);else return e}return`${Bc(e,t.target.x)}% ${Bc(e,t.target.y)}%`}},Hc={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Rn.parse(e);if(i.length>5)return r;let a=Rn.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=Hn(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}};function Uc(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,pathRotation:i,rotateX:a,rotateY:o,skewX:s,skewY:c}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotate(${i}deg) `),a&&(r+=`rotateX(${a}deg) `),o&&(r+=`rotateY(${o}deg) `),s&&(r+=`skewX(${s}deg) `),c&&(r+=`skewY(${c}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var Wc=oo.length,Gc=e=>typeof e==`number`||R.test(e);function Kc(e,t,n,r,i,a){i?(e.opacity=Hn(0,n.opacity??1,Jc(r)),e.opacityExit=Hn(t.opacity??1,0,Yc(r))):a&&(e.opacity=Hn(t.opacity??1,n.opacity??1,r));for(let i=0;i<Wc;i++){let a=oo[i],o=qc(t,a),s=qc(n,a);(o!==void 0||s!==void 0)&&(o||=0,s||=0,o===0||s===0||Gc(o)===Gc(s)?(e[a]=Math.max(Hn(ws(o),ws(s),r),0),(mn.test(s)||mn.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=Hn(t.rotate||0,n.rotate||0,r))}function qc(e,t){return e[t]===void 0?e.borderRadius:e[t]}var Jc=Xc(0,.5,jt),Yc=Xc(.5,.95,ft);function Xc(e,t,n){return r=>r<e?0:r>t?1:n(mt(e,t,r))}function Zc(e,t,n){let r=Va(e)?e:va(e);return r.start(Oa(``,r,t,n)),r.animation}function Qc(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var $c=(e,t)=>e.depth-t.depth,el=class{constructor(){this.children=[],this.isDirty=!1}add(e){it(this.children,e),this.isDirty=!0}remove(e){at(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort($c),this.isDirty=!1,this.children.forEach(e)}};function tl(e,t){let n=Wt.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(ur(r),e(a-t))};return lr.setup(r,!0),()=>ur(r)}function nl(e){return Va(e)?e.get():e}var rl=class{constructor(){this.members=[]}add(e){it(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(at(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(at(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},il={borderRadius:{...Vc,applyTo:[...oo]},borderTopLeftRadius:Vc,borderTopRightRadius:Vc,borderBottomLeftRadius:Vc,borderBottomRightRadius:Vc,boxShadow:Hc},al={hasAnimatedSinceResize:!0,hasEverUpdated:!1};Object.assign(Ys,{...il,...Ys});var ol={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},sl=[``,`X`,`Y`,`Z`],cl=1e3,ll=0;function ul(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function dl(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=Ka(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,lr,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&dl(r)}function fl({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=ll++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,Ss.value&&(ol.nodes=ol.calculatedTargetDeltas=ol.calculatedProjections=0),this.nodes.forEach(hl),this.nodes.forEach(Tl),this.nodes.forEach(El),this.nodes.forEach(gl),Ss.addProjectionMetrics&&Ss.addProjectionMetrics(ol)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new el)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new ht),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=co(t)&&!Cs(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;lr.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=tl(i,250),al.hasAnimatedSinceResize&&(al.hasAnimatedSinceResize=!1,this.nodes.forEach(wl)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||Nl,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!Ic(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...ba(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||wl(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),ur(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Dl),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&dl(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(yl),this.nodes.forEach(vl);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(bl);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(xl),this.nodes.forEach(Sl),this.nodes.forEach(Cl),this.nodes.forEach(pl),this.nodes.forEach(ml)):this.nodes.forEach(bl),this.clearAllSnapshots();let e=Wt.now();Vt.delta=ot(0,1e3/60,e-Vt.timestamp),Vt.timestamp=e,Vt.isProcessing=!0,dr.update.process(Vt),dr.preRender.process(Vt),dr.render.process(Vt),Vt.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,B.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(_l),this.sharedNodes.forEach(Ol)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,lr.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){lr.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),this.snapshot&&!_c(this.snapshot.measuredBox.x)&&!_c(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutCorrected||=Os(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!Mc(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||Eo(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),Ll(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return Os();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(zl))){let{scroll:e}=this.root;e&&(Io(t.x,e.offset.x),Io(t.y,e.offset.y))}return t}removeElementScroll(e){let t=Os();if(dc(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&dc(t,e),Io(t.x,i.offset.x),Io(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||Os();dc(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(Io(r.x,-n.scroll.offset.x),Io(r.y,-n.scroll.offset.y)),Eo(n.latestValues)&&zo(r,n.latestValues,n.layout?.layoutBox)}return Eo(this.latestValues)&&zo(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=Os();dc(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!Eo(n.latestValues))continue;let r;n.instance&&(To(n.latestValues)&&n.updateSnapshot(),r=Os(),dc(r,n.measurePageBox())),Ac(t,n.latestValues,n.snapshot?.layoutBox,r)}return Eo(this.latestValues)&&Ac(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0||e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Vt.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=Vt.timestamp;let a=this.getClosestProjectingParent();!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),(this.relativeTarget||this.targetDelta)&&(this.target||(this.target=Os(),this.targetWithTransforms=Os()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Sc(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):dc(this.target,this.layout.layoutBox),Mo(this.target,this.targetDelta)):dc(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),Ss.value&&ol.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||To(this.parent.latestValues)||Do(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Os(),this.relativeTargetOrigin=Os(),wc(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),dc(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===Vt.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;dc(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;Fo(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=Os());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(fc(this.prevProjectionDelta.x,this.projectionDelta.x),fc(this.prevProjectionDelta.y,this.projectionDelta.y)),bc(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!Rc(this.projectionDelta.x,this.prevProjectionDelta.x)||!Rc(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),Ss.value&&ol.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Es(),this.projectionDelta=Es(),this.projectionDeltaWithTransform=Es()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=Es();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=Os(),c=(r?r.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),u=!l||l.members.length<=1,d=!(!c||u||this.options.crossfade!==!0||this.path.some(Ml));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);r?(o.x.translate=r.x,o.x.scale=Hn(e.x.scale,1,n),o.x.origin=e.x.origin,o.x.originPoint=e.x.originPoint,o.y.translate=r.y,o.y.scale=Hn(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(kl(o.x,e.x,n),kl(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(wc(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),jl(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&Pc(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=Os(),dc(f,this.relativeTarget)),c&&(this.animationValues=a,Kc(a,i,this.latestValues,n,d,u)),r&&r.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(ur(this.pendingAnimation),void 0),this.pendingAnimation=lr.update(()=>{al.hasAnimatedSinceResize=!0,this.motionValue||=va(0),this.motionValue.jump(0,!1),this.currentAnimation=Zc(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),Kr(this.currentAnimation,this),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(cl),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,layout:n,latestValues:r}=e,{target:i}=e;if(t&&i&&n){if(this!==e&&this.layout&&n&&Rl(this.options.animationType,this.layout.layoutBox,n.layoutBox)){i=this.target||Os();let t=_c(this.layout.layoutBox.x);i.x.min=e.target.x.min,i.x.max=i.x.min+t;let n=_c(this.layout.layoutBox.y);i.y.min=e.target.y.min,i.y.max=i.y.min+n}dc(t,i),zo(t,r),bc(this.projectionDeltaWithTransform,this.layoutCorrected,t,r)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new rl),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&ul(`z`,e,r,this.animationValues);for(let t=0;t<sl.length;t++)ul(`rotate${sl[t]}`,e,r,this.animationValues),ul(`skew${sl[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=nl(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=nl(t?.pointerEvents)||``),this.hasProjected&&!Eo(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=Uc(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,e.opacity=r.animationValues?r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in Ys){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=Ys[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?nl(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(vl),this.root.sharedNodes.clear()}}}function pl(e){e.updateLayout()}function ml(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)zc(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=_c(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;uc(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else Rl(i,t.layoutBox,n)&&zc(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=_c(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=Es();bc(o,n,t.layoutBox);let s=Es();a?bc(s,e.applyTransform(r,!0),t.measuredBox):bc(s,n,t.layoutBox);let c=!Mc(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=Os();wc(s,t.layoutBox,i.layoutBox,o);let c=Os();wc(c,n,a.layoutBox,o),Ic(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function hl(e){Ss.value&&ol.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function gl(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function _l(e){e.clearSnapshot()}function vl(e){e.clearMeasurements()}function yl(e){e.isLayoutDirty=!0,e.updateLayout()}function bl(e){e.isLayoutDirty=!1}function xl(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function Sl(e){e.relativeTarget&&e.relativeParent?.isLayoutDirty&&(e.currentAnimation?e.isLayoutDirty=!0:(e.targetDelta=void 0,e.removeRelativeTarget()))}function Cl(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function wl(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Tl(e){e.resolveTargetDelta()}function El(e){e.calcProjection()}function Dl(e){e.resetSkewAndRotation()}function Ol(e){e.removeLeadSnapshot()}function kl(e,t,n){e.translate=Hn(t.translate,0,n),e.scale=Hn(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function Al(e,t,n,r){e.min=Hn(t.min,n.min,r),e.max=Hn(t.max,n.max,r)}function jl(e,t,n,r){Al(e.x,t.x,n.x,r),Al(e.y,t.y,n.y,r)}function Ml(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var Nl={duration:.45,ease:[.4,0,.1,1]},Pl=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Fl=Pl(`applewebkit/`)&&!Pl(`chrome/`)?Math.round:ft;function Il(e){e.min=Fl(e.min),e.max=Fl(e.max)}function Ll(e){Il(e.x),Il(e.y)}function Rl(e,t,n){return e===`position`||e===`preserve-aspect`&&!vc(Lc(t),Lc(n),.2)}function zl(e){return e!==e.root&&e.scroll?.wasRoot}var Bl=fl({attachResizeListener:(e,t)=>Qc(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),Vl={current:void 0},Hl=fl({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Vl.current){let e=new Bl({});e.mount(window),e.setOptions({layoutScroll:!0}),Vl.current=e}return Vl.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),Ul=(0,m.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function Wl(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Gl(...e){return t=>{let n=!1,r=e.map(e=>{let r=Wl(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():Wl(e[t],null)}}}}function Kl(...e){return m.useCallback(Gl(...e),e)}var V=i(),ql=class extends m.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(so(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=so(e)&&e.offsetWidth||0,r=so(e)&&e.offsetHeight||0,i=getComputedStyle(t),a=this.props.sizeRef.current;a.height=parseFloat(i.height),a.width=parseFloat(i.width),a.top=t.offsetTop,a.left=t.offsetLeft,a.right=n-a.width-a.left,a.bottom=r-a.height-a.top,a.direction=i.direction}return null}componentDidUpdate(){}render(){return this.props.children}};function Jl({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:a}){let o=(0,m.useId)(),s=(0,m.useRef)(null),c=(0,m.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:l}=(0,m.useContext)(Ul),u=Kl(s,a===!1?void 0:e.props?.ref??e?.ref);return(0,m.useInsertionEffect)(()=>{let{width:e,height:u,top:d,left:f,right:p,bottom:m,direction:h}=c.current;if(t||a===!1||!s.current||!e||!u)return;let g=h===`rtl`,_=n===`left`?g?`right: ${p}`:`left: ${f}`:g?`left: ${f}`:`right: ${p}`,v=r===`bottom`?`bottom: ${m}`:`top: ${d}`;s.current.dataset.motionPopId=o;let y=document.createElement(`style`);l&&(y.nonce=l);let b=i??document.head;return b.appendChild(y),y.sheet&&y.sheet.insertRule(`
4
4
  [data-motion-pop-id="${o}"] {
@@ -110,6 +110,6 @@ Agreed plan (from the planning session):
110
110
  `,t-1)+1,r=e.indexOf(`
111
111
  `,t),i=e.slice(n,r<0?e.length:r),a=HK.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 WK(){try{return{id:pe()}}catch(e){return{error:e.message}}}function GK(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 KK(){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 qK({data:e,error:t}){let n=WK();return n.error??t??GK(e,n.id)}function JK({projects:e}){let t=qK(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)(ah,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,V.jsx)(`span`,{children:t})]}):null}function YK(e){let t=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0,n=e.key===`Home`?`first`:e.key===`End`?`last`:void 0;if(!t&&!n)return;let r=[...e.currentTarget.querySelectorAll(`[role='option'], [data-walk]`)];if(r.length===0)return;e.preventDefault();let i=r.indexOf(document.activeElement);r[n===`first`?0:n===`last`?r.length-1:Math.max(0,Math.min(r.length-1,(i<0?t>0?-1:r.length:i)+t))]?.focus()}var XK=`bot-lobby:open-projects`,ZK=4;function QK(e){return{w:360,h:45+Math.max(1,Math.min(e.data?.projects.length??1,ZK))*46+1+32+(qK(e)?32:0)}}function $K({projects:e,name:t,branch:n,open:r,onToggle:i}){let a=qK(e);return(0,V.jsxs)(`button`,{type:`button`,role:`combobox`,"aria-label":`Project`,"aria-description":`${t}${n?`, branch ${n}`:``}`,"aria-haspopup":`listbox`,"aria-expanded":r,"aria-keyshortcuts":`P ArrowDown`,"aria-busy":e.busy,"data-tip":`Switch project`,"data-on":r||void 0,onClick:i,onKeyDown:e=>{e.key!==`ArrowDown`||e.altKey||e.metaKey||e.ctrlKey||r||(e.preventDefault(),i())},title:n?`${t} · ${n}`:t,className:`bubble-chip bubble-tip bubble-tool min-w-0`,children:[e.slow?(0,V.jsx)(lR,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,V.jsx)(Lp,{"aria-hidden":`true`,className:Y(`size-3.5 shrink-0`,a&&`text-destructive`)}),(0,V.jsx)(`span`,{className:`truncate`,children:t}),(0,V.jsx)(Yf,{"aria-hidden":`true`,className:`size-3 shrink-0`,strokeWidth:2})]})}function eq({projects:e,tab:t,onBrowse:n,onClose:r}){let{data:i,busy:a,refresh:o}=e,s=WK(),c=qK(e),l=s.error?`invalid`:s.id??i?.currentId??``,u=(0,m.useRef)(null);RE(`r`,()=>void o(),{inDialog:!0}),(0,m.useEffect)(()=>{(u.current?.querySelector(`[role='option'][aria-selected='true']`)??u.current?.querySelector(`[role='option']`))?.focus({preventScroll:!0})},[!!i]);function d(e){r(),e!==l&&I(e,t)}let f=Math.max(1,Math.min(i?.projects.length??1,ZK));return(0,V.jsxs)(`div`,{ref:u,"aria-label":`Projects`,onKeyDown:YK,className:`bubble-pane flex flex-col p-1`,children:[(0,V.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center justify-between ps-2.5 pe-1`,children:[(0,V.jsx)(`span`,{className:`text-[13px] font-medium text-(--bubble-muted)`,children:`Running projects`}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>void o(),disabled:a,"aria-label":`Refresh list`,"aria-keyshortcuts":`R`,className:`bubble-chip h-6 text-xs`,children:[a?(0,V.jsx)(lR,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):(0,V.jsx)(km,{"aria-hidden":`true`,className:`size-3.5`}),`Refresh`,(0,V.jsx)(`kbd`,{className:`bubble-kbd`,children:`R`})]})]}),(0,V.jsx)(`div`,{className:`h-px shrink-0`}),(0,V.jsx)(`div`,{role:`listbox`,"aria-label":`Projects`,className:`bubble-scroll flex shrink-0 flex-col overflow-y-auto`,style:{height:f*46},children:i?i.projects.map((e,t)=>{let n=e.id===l;return(0,V.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,onClick:()=>d(e.id),className:Y(`bubble-row cs-prow shrink-0`,n&&`bubble-prow`),style:{"--delay":`${40+t*12}ms`},children:[(0,V.jsx)(`span`,{className:`flex w-4 shrink-0 justify-center`,children:n?(0,V.jsx)(Jf,{"aria-hidden":`true`,className:`size-4 text-(--bubble-accent)`,strokeWidth:2}):null}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,V.jsx)(`span`,{className:`truncate text-sm font-medium text-(--bubble-ink)`,children:e.name}),(0,V.jsxs)(`span`,{className:`truncate text-xs text-(--bubble-muted)`,children:[e.cwd,` · :`,e.port]})]})]},e.id)}):(0,V.jsxs)(`div`,{className:`flex h-[46px] items-center gap-2 px-2.5 text-[13px] text-(--bubble-muted)`,children:[(0,V.jsx)(lR,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}),`Loading projects…`]})}),c?(0,V.jsxs)(`p`,{role:`alert`,className:`flex h-8 shrink-0 items-center gap-2 px-2 text-xs text-destructive`,children:[(0,V.jsx)(ah,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,V.jsx)(`span`,{className:`truncate`,title:c,children:c})]}):null,(0,V.jsx)(`div`,{className:`h-px shrink-0`}),(0,V.jsxs)(`button`,{type:`button`,"data-walk":!0,onClick:n,className:`bubble-row cs-orow shrink-0`,style:{"--delay":`0ms`},children:[(0,V.jsx)(Fp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Open folder…`})]})]})}var tq={w:500,h:308};function nq(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 rq(e){let t=e.includes(`\\`)&&!e.includes(`/`)?`\\`:`/`,n=e.split(t),r=[];return n.forEach((e,i)=>{if(!e)return;let a=n.slice(0,i+1).join(t);r.push({name:e,path:a||t})}),r.length?r:[{name:t,path:t}]}function iq(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 aq({tab:e,onClose:t}){let[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)({step:0,dir:`fwd`}),o=eR(`projects.browse`,n===void 0?{}:{path:n},[]),s=nq(e),c=(0,m.useRef)(null),l=o.loading||s.opening,u=o.data?.path??n??``,d=(e,t)=>{e!==u&&(a(e=>({step:e.step+1,dir:t})),r(e))};(0,m.useEffect)(()=>{if(!o.data)return;let e=c.current?.querySelector(`button[data-folder]`);e&&!c.current?.contains(document.activeElement)&&e.focus({preventScroll:!0})},[o.data]);let f=rq(u),p=f.slice(-4),h=o.data?.folders.length??0,g=o.error||s.error?o.error??s.error:o.loading&&!o.data?`Loading…`:h===0?`No subfolders`:`${h.toLocaleString()} ${h===1?`folder`:`folders`}${o.data?.truncated?` (first 2,000)`:``}`;return(0,V.jsxs)(`div`,{role:`group`,"aria-label":`Open project folder`,className:`bubble-pane flex flex-col gap-1 p-1`,style:{height:tq.h},children:[(0,V.jsxs)(`div`,{className:`bubble-wellbar flex h-9 shrink-0 items-center gap-0.5 px-1`,children:[(0,V.jsx)(`button`,{type:`button`,"aria-label":`Parent folder`,title:`Parent folder (Backspace)`,disabled:l||!o.data?.parent,onClick:()=>o.data?.parent&&d(o.data.parent,`back`),className:`bubble-iconbtn size-7`,children:(0,V.jsx)(Rf,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.8})}),(0,V.jsxs)(`nav`,{"aria-label":`Folder path`,className:`flex min-w-0 flex-1 items-center overflow-hidden whitespace-nowrap`,title:u,children:[f.length>p.length?(0,V.jsx)(`span`,{className:`shrink-0 px-1.5 text-[13px] text-(--bubble-muted)`,children:`…`}):null,p.map((e,t)=>(0,V.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[t>0?(0,V.jsx)($f,{"aria-hidden":`true`,className:`size-3 shrink-0 text-(--bubble-faint)`,strokeWidth:2}):null,(0,V.jsx)(`button`,{type:`button`,className:`bubble-crumb`,"data-last":t===p.length-1||void 0,"aria-current":t===p.length-1?`location`:void 0,disabled:l,onClick:()=>d(e.path,`back`),children:e.name})]},e.path))]})]}),(0,V.jsxs)(`div`,{ref:c,role:`group`,"aria-label":`Folders`,"aria-busy":o.loading,"data-dir":i.step?i.dir:void 0,onKeyDown:e=>iq(e,o.data?.parent,e=>d(e,`back`)),className:`bubble-flist bubble-scroll`,children:[o.data?.folders.map(e=>{let t=e.name.startsWith(`.`);return(0,V.jsxs)(`button`,{type:`button`,"data-folder":!0,disabled:s.opening,onClick:()=>d(e.path,`fwd`),title:e.path,className:Y(`bubble-frow`,t&&`text-(--bubble-muted)`),children:[(0,V.jsx)(`span`,{className:`bubble-ftile`,children:(0,V.jsx)(Lp,{"aria-hidden":`true`,className:`size-3.5 text-(--bubble-muted)`,strokeWidth:1.8})}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,V.jsx)($f,{"aria-hidden":`true`,className:`bubble-go size-3.5 shrink-0`,strokeWidth:2})]},e.path)}),o.data&&h===0?(0,V.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-xs text-(--bubble-muted)`,children:[(0,V.jsx)(Lp,{"aria-hidden":`true`,className:`size-6`,strokeWidth:1.5}),(0,V.jsx)(`span`,{children:`No subfolders here. You can open this folder.`})]}):null]},i.step),(0,V.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between gap-2 ps-2.5 pe-1`,children:[(0,V.jsx)(`span`,{role:o.error||s.error?`alert`:`status`,className:Y(`min-w-0 truncate text-xs`,o.error||s.error?`text-destructive`:`text-(--bubble-muted)`),children:g}),(0,V.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[o.error?(0,V.jsx)(`button`,{type:`button`,className:`bubble-btn bubble-ghostbtn`,onClick:o.reload,disabled:o.loading,children:`Retry`}):null,(0,V.jsx)(`button`,{type:`button`,className:`bubble-btn bubble-ghostbtn`,onClick:t,disabled:s.opening,children:`Cancel`}),(0,V.jsx)(`button`,{type:`button`,className:`bubble-btn bubble-key`,disabled:!o.data||o.loading||!!o.error||s.opening,onClick:()=>void s.open(o.data.path),children:s.opening?`Opening project…`:`Open this folder`})]})]})]})}function oq(){return(0,V.jsx)(`svg`,{width:`0`,height:`0`,className:`absolute`,"aria-hidden":`true`,focusable:`false`,children:(0,V.jsxs)(`defs`,{children:[(0,V.jsxs)(`filter`,{id:`bubble-goolit`,x:`-10%`,y:`-10%`,width:`120%`,height:`120%`,colorInterpolationFilters:`sRGB`,children:[(0,V.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`4.5`,result:`b`}),(0,V.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`rimA`}),(0,V.jsx)(`feGaussianBlur`,{in:`rimA`,stdDeviation:`0.6`,result:`rimB`}),(0,V.jsx)(`feComposite`,{in:`rimB`,in2:`shape`,operator:`in`,result:`rimC`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-hl)`},result:`hlc`}),(0,V.jsx)(`feComposite`,{in:`hlc`,in2:`rimC`,operator:`in`,result:`hl`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`shA`}),(0,V.jsx)(`feGaussianBlur`,{in:`shA`,stdDeviation:`0.6`,result:`shB`}),(0,V.jsx)(`feComposite`,{in:`shB`,in2:`shape`,operator:`in`,result:`shC`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-sh)`},result:`shc`}),(0,V.jsx)(`feComposite`,{in:`shc`,in2:`shC`,operator:`in`,result:`sh`}),(0,V.jsxs)(`feMerge`,{children:[(0,V.jsx)(`feMergeNode`,{in:`shape`}),(0,V.jsx)(`feMergeNode`,{in:`sh`}),(0,V.jsx)(`feMergeNode`,{in:`hl`})]})]}),(0,V.jsxs)(`filter`,{id:`bubble-gooedge`,x:`-10%`,y:`-10%`,width:`120%`,height:`120%`,colorInterpolationFilters:`sRGB`,children:[(0,V.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`4.5`,result:`b`}),(0,V.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`tS0`}),(0,V.jsx)(`feGaussianBlur`,{in:`tS0`,stdDeviation:`0.3`,result:`tS1`}),(0,V.jsx)(`feComposite`,{in:`tS1`,in2:`shape`,operator:`in`,result:`tS`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-ehl)`},result:`tc`}),(0,V.jsx)(`feComposite`,{in:`tc`,in2:`tS`,operator:`in`,result:`eh`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`bS0`}),(0,V.jsx)(`feGaussianBlur`,{in:`bS0`,stdDeviation:`0.3`,result:`bS1`}),(0,V.jsx)(`feComposite`,{in:`bS1`,in2:`shape`,operator:`in`,result:`bS`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-esh)`},result:`bc`}),(0,V.jsx)(`feComposite`,{in:`bc`,in2:`bS`,operator:`in`,result:`es`}),(0,V.jsxs)(`feMerge`,{children:[(0,V.jsx)(`feMergeNode`,{in:`shape`}),(0,V.jsx)(`feMergeNode`,{in:`eh`}),(0,V.jsx)(`feMergeNode`,{in:`es`})]})]})]})})}function sq({kind:e}){return(0,V.jsxs)(`div`,{className:Y(`bubble-layer`,e===`edge`?`bubble-edge`:`bubble-fill`),"aria-hidden":`true`,children:[(0,V.jsx)(`div`,{className:`bubble-menu`,children:(0,V.jsx)(`div`,{className:`bubble-menu-clip`})}),(0,V.jsx)(`div`,{className:`bubble-ghost`})]})}function cq({open:e,size:t,shrunk:n,morphing:r,menu:i,children:a,className:o,style:s,...c}){let[l,u]=(0,m.useState)(e);return(0,m.useEffect)(()=>{if(e)return u(!0);let t=setTimeout(()=>u(!1),140);return()=>clearTimeout(t)},[e]),(0,V.jsxs)(`div`,{"data-slot":`composer-shell`,"data-open":e||void 0,"data-shrunk":n||void 0,"data-morphing":r||void 0,className:Y(`bubble`,o),style:{...s,"--w":`${t.w}px`,"--h":`${e?t.h:0}px`},...c,children:[(0,V.jsx)(oq,{}),(0,V.jsx)(sq,{kind:`edge`}),(0,V.jsx)(sq,{kind:`fill`}),(0,V.jsxs)(`div`,{className:`bubble-real`,children:[(0,V.jsx)(`div`,{className:`bubble-menu`,inert:!e,children:(0,V.jsx)(`div`,{className:`bubble-menu-clip`,children:(0,V.jsx)(`div`,{className:`bubble-menu-body`,children:e||l?i:null})})}),a]})]})}var lq=/^\s{0,3}(`{3,}|~{3,})/,uq=/^(\s{0,3}#{1,6})(\s+)(.*)$/,dq=/^(\s{0,3}>[>\s]*)(.*)$/,fq=/^(\s*)([-*+]|\d{1,9}[.)])(\s+)(\[[ xX]\]\s)?(.*)$/,pq=/^\s{0,3}([-*_])(\s*\1){2,}\s*$/,mq=/(`+)([^`\n]+?)\1|\[([^\]\n]+)\]\(([^)\s]+)\)|(\*\*|__)(?=\S)([^\n]*?\S)\5|(~~)(?=\S)([^\n]*?\S)~~|(?<![\w*])(\*)(?=[^\s*])([^*\n]*?[^\s*])\*(?!\*)|(?<![\w_])(_)(?=[^\s_])([^_\n]*?[^\s_])_(?![\w_])|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?'"])|(?<![\w@])(@[a-z][\w-]*)/gi;function hq(e,t,n){if(!t)return;let r=e.at(-1);r&&r.kind===n?r.text+=t:e.push({text:t,kind:n})}var gq=(...e)=>e.filter(Boolean).join(` `);function _q(e,t,n){let r=0;for(let i of t.matchAll(mq)){let a=i.index;hq(e,t.slice(r,a),n);let[o,s,c,l,u,d,f,p,m,h,g,_,v,y,b]=i;if(s)hq(e,s,gq(n,`code`,`mark`)),hq(e,c,gq(n,`code`)),hq(e,s,gq(n,`code`,`mark`));else if(l)hq(e,`[`,gq(n,`mark`)),hq(e,l,gq(n,`link`)),hq(e,`](${u})`,gq(n,`mark`));else if(d)hq(e,d,gq(n,`mark`)),_q(e,f,gq(n,`strong`)),hq(e,d,gq(n,`mark`));else if(p)hq(e,p,gq(n,`mark`)),_q(e,m,gq(n,`strike`)),hq(e,p,gq(n,`mark`));else if(h||_){let t=h??_;hq(e,t,gq(n,`mark`)),_q(e,g??v,gq(n,`em`)),hq(e,t,gq(n,`mark`))}else y?hq(e,y,gq(n,`link`)):b?hq(e,b,gq(n,`mention`)):hq(e,o,n);r=a+o.length}hq(e,t.slice(r),n)}function vq(e){let t=[],n;return e.split(`
112
112
  `).forEach((e,r)=>{r>0&&hq(t,`
113
- `,``);let i=lq.exec(e);if(n!==void 0){i&&i[1].startsWith(n)?(n=void 0,hq(t,e,`codeblock mark`)):hq(t,e,`codeblock`);return}if(i){n=i[1][0].repeat(3),hq(t,e,`codeblock mark`);return}if(r===0&&/^\/[a-z][\w-]*/i.test(e)){let n=/^\/[a-z][\w-]*/i.exec(e)[0];hq(t,n,`mention`),_q(t,e.slice(n.length),``);return}if(pq.test(e))return hq(t,e,`mark`);let a=uq.exec(e);if(a)return hq(t,a[1]+a[2],`heading mark`),_q(t,a[3],`heading`);let o=dq.exec(e);if(o)return hq(t,o[1],`quote mark`),_q(t,o[2],`quote`);let s=fq.exec(e);if(s)return hq(t,s[1],``),hq(t,s[2],`list`),hq(t,s[3],``),s[4]&&hq(t,s[4],`list`),_q(t,s[5],``);_q(t,e,``)}),t}function yq(e){if(e.startsWith(`/`))return`var(--primary)`;let t=pR(e.slice(1));return t===`var(--muted-foreground)`?`var(--primary)`:t}function bq(e,t){if(t.length<=e.length)return;let n=0;for(;n<e.length&&e[n]===t[n];)n++;let r=0;for(;r<e.length-n&&e[e.length-1-r]===t[t.length-1-r];)r++;let i=t.length-r;return i-n>0&&i-n<=24?{start:n,end:i}:void 0}var xq=(0,m.memo)(function({text:e,fresh:t}){let n=0;return(0,V.jsxs)(V.Fragment,{children:[vq(e).flatMap((e,r)=>{let i=n;n+=e.text.length;let a=e.kind?e.kind.split(` `).map(e=>`md-${e}`).join(` `):``,o=e.kind===`mention`?{color:yq(e.text)}:void 0,s=t&&t.start<n&&t.end>i?[[i,Math.max(i,t.start)],[Math.max(i,t.start),Math.min(n,t.end)],[Math.min(n,t.end),n]]:[[i,n]];return s.filter(([e,t])=>t>e).map(([n,c])=>{let l=t!==void 0&&s.length>1&&n===Math.max(i,t.start),u=e.text.slice(n-i,c-i);return a||l?(0,V.jsx)(`span`,{className:[a,l?`md-new`:``].filter(Boolean).join(` `),style:o,children:u},l?`n${t.seq}-${r}`:`${r}-${n}`):u})}),`​`]})}),Sq=(0,m.forwardRef)(function({text:e},t){let n=(0,m.useRef)({text:e,fresh:void 0,seq:0});if(n.current.text!==e){let t=bq(n.current.text,e),r=n.current.seq+1;n.current={text:e,seq:r,fresh:t?{...t,seq:r}:void 0}}return(0,V.jsx)(`div`,{ref:t,className:`bubble-text bubble-mirror`,"aria-hidden":`true`,children:(0,V.jsx)(xq,{text:e,...n.current.fresh?{fresh:n.current.fresh}:{}})})}),Cq=e=>e.preventDefault();function wq({onStop:e}){let[t,n]=(0,m.useState)(!1),r=qT(t,KT.confirm),i=()=>{n(!1),e()};return RE(`y`,i,{enabled:t&&r,inDialog:!0}),(0,V.jsxs)(zL,{open:t&&r,onOpenChange:n,children:[(0,V.jsx)(`button`,{type:`button`,className:`bubble-send bubble-key bubble-stop`,"data-tip":`Interrupt`,onPointerDown:Cq,onClick:()=>n(!0),"aria-label":`Stop`,"aria-haspopup":`dialog`,children:(0,V.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,V.jsx)(`rect`,{x:`2`,y:`2`,width:`8`,height:`8`,rx:`1.5`})})}),(0,V.jsxs)(BL,{children:[(0,V.jsxs)(VL,{children:[(0,V.jsx)(UL,{children:`Stop the oracle?`}),(0,V.jsx)(WL,{children:`The current response stops. Work already recorded is kept.`})]}),(0,V.jsxs)(HL,{children:[(0,V.jsxs)(KL,{children:[`Keep it`,(0,V.jsx)(IT,{chord:`Esc`,className:`kbd-hint ml-1`})]}),(0,V.jsxs)(GL,{variant:`destructive`,onClick:i,children:[`Stop`,(0,V.jsx)(IT,{chord:`Y`,className:`kbd-hint ml-1`})]})]})]})]})}function Tq({sending:e,disabled:t,steering:n,onSend:r}){let[i,a]=(0,m.useState)(0),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(!1),u=(0,m.useRef)(e);return(0,m.useEffect)(()=>{if(!i)return;l(!0);let e=setTimeout(()=>l(!1),640);return()=>clearTimeout(e)},[i]),(0,m.useEffect)(()=>{if(e&&!u.current&&a(e=>e+1),u.current=e,!e)return s(!1);let t=setTimeout(()=>s(!0),600);return()=>clearTimeout(t)},[e]),(0,V.jsx)(`button`,{type:`button`,className:Y(`bubble-send`,(!t||c)&&`bubble-key`),"data-tip":n?`Steer`:`Send`,"data-flying":c||void 0,onPointerDown:Cq,onClick:r,disabled:t,"aria-label":`Send`,"aria-keyshortcuts":`Enter`,children:o?(0,V.jsx)(lR,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,V.jsxs)(`span`,{className:`bubble-plane-wrap`,"data-fly":i>0?``:void 0,"aria-hidden":`true`,children:[(0,V.jsxs)(`svg`,{className:`bubble-plane`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`path`,{d:`M22 2L11 13`}),(0,V.jsx)(`path`,{d:`M22 2l-7 20-4-9-9-4z`})]}),(0,V.jsx)(`span`,{className:`bubble-trail`})]},i)})}function Eq(e){return e.agent?pR(e.agent):e.tag===`lobby`?`var(--c-orc)`:e.tag===`skill`?`var(--c-pl)`:`var(--c-qa)`}function Dq(e,t){let n=/^\s*([/@])([a-z0-9:_.-]*)$/i.exec(e.slice(0,t));if(n&&!/\S/.test(e.slice(t,t+1)))return{kind:n[1]===`/`?`slash-command`:`mention`,query:n[2].toLowerCase()}}function Oq(e){return[...$T.map(e=>({id:`/${e.name}`,insert:`/${e.name}`,label:`/${e.name}`,description:e.hint,tag:`lobby`})),...e.map(e=>({id:`/${e.name}`,insert:`/${e.name}`,label:`/${e.name}`,description:e.description+(e.terminal?` · continue in Pi terminal`:``),tag:e.name.startsWith(`skill:`)?`skill`:`pi`}))]}function kq(e,t=[]){let n=e.kind===`slash-command`?Oq(t):QT.map(e=>({id:`@${e.name}`,insert:`@${e.name}`,label:`@${e.name}`,description:e.hint,agent:e.agent,tag:`agent`})),r=n.filter((e,t)=>n.findIndex(t=>t.id===e.id)===t),i=r.filter(t=>t.label.slice(1).startsWith(e.query)),a=r.filter(t=>!i.includes(t)&&t.label.slice(1).includes(e.query));return[...i,...a]}function Aq(e,t){return`${e}-${encodeURIComponent(t)}`}var jq={"slash-command":`Commands`,mention:`Agents`};function Mq(e){return 8+Math.min(e,8)*30}var Nq;function Pq(e,t){let n=0;try{if(Nq??=document.createElement(`canvas`).getContext(`2d`),!Nq)throw Error(`no canvas`);for(let r of e){Nq.font=`500 13px ${t}`;let e=Nq.measureText(r.label.slice(1)).width;Nq.font=`400 12px ${t}`,n=Math.max(n,e+Nq.measureText(r.description).width)}}catch{for(let t of e)n=Math.max(n,t.label.length*7.4+t.description.length*6.1)}return Math.min(Math.max(Math.ceil(n)+128,180),600)}var Fq=(0,m.memo)(function(e){let t=(0,m.useRef)(null);(0,m.useLayoutEffect)(()=>{e.activeItemId&&t.current&&t.current.querySelector(`[data-composer-item-id="${CSS.escape(e.activeItemId)}"]`)?.scrollIntoView({block:`nearest`})},[e.activeItemId]);let n=Math.min(e.items.length,8);return(0,V.jsx)(`div`,{ref:t,id:e.listId,role:`listbox`,"aria-label":jq[e.triggerKind],"data-composer-command-drawer":`true`,className:`bubble-pane bubble-scroll overflow-y-auto p-1`,style:{height:Mq(e.items.length)},children:e.items.map((t,r)=>{let i=e.activeItemId===t.id;return(0,V.jsxs)(`div`,{id:Aq(e.listId,t.id),role:`option`,"aria-selected":i,"data-composer-item-id":t.id,"data-active":i||void 0,onMouseMove:()=>{i||e.onHighlightedItemChange(t.id)},onMouseDown:e=>e.preventDefault(),onClick:()=>e.onSelect(t),className:`bubble-row`,style:{"--delay":`${Math.max(0,n-1-r)*22}ms`},children:[t.agent?(0,V.jsx)(`span`,{className:`cs-kdot`,"aria-hidden":`true`,style:{"--k":Eq(t)}}):(0,V.jsx)(`span`,{className:`bubble-glyph cs-kg`,"aria-hidden":`true`,style:{"--k":Eq(t)},children:t.label.charAt(1).toUpperCase()}),(0,V.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-(--bubble-ink)`,children:t.label.slice(1)}),(0,V.jsx)(`span`,{className:`min-w-0 truncate text-[13px] text-(--bubble-muted)`,children:t.description}),(0,V.jsx)(`span`,{className:`cs-ktag`,style:{"--k":Eq(t)},children:t.tag})]},t.id)})})});function Iq(e){return typeof e==`object`&&e?e:{}}function Lq(e){return typeof e==`string`?e.trim():``}function Rq(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function zq(e){let t=Iq(e),n=Lq(t.label);if(!n)return;let r=Lq(t.description),i=Lq(t.preview),a=Lq(t.image),o=sU(t.htmlPreview);return{label:n,...r?{description:r}:{},...i?{preview:i}:{},...a?{image:a}:{},...o?{htmlPreview:o}:{}}}function Bq(e){let t=Iq(e),n=Lq(t.question);if(!n)return;let r=(Array.isArray(t.options)?t.options:[]).map(zq).filter(e=>!!e);return{question:n,header:Lq(t.header)||`Question`,options:r,...t.multiSelect===!0?{multiSelect:!0}:{}}}function Vq(e){let t=Iq(e),n=Lq(t.method);if(n!==`select`&&n!==`confirm`&&n!==`input`&&n!==`editor`)return;let r=Lq(t.message),i=Rq(t.options),a=Lq(t.placeholder),o=Lq(t.prefill);return{id:Lq(t.id),method:n,title:Lq(t.title)||`Answer`,...r?{message:r}:{},...i.length>0?{options:i}:{},...a?{placeholder:a}:{},...o?{prefill:o}:{}}}function Hq(e){let t=(Array.isArray(e.questions)?e.questions:[]).map(Bq).filter(e=>!!e);return t.length>0?{kind:`questionnaire`,questions:t}:void 0}function Uq(e){return{kind:`choose`,title:Lq(e.title)||`Choose an option`,options:Rq(e.options)}}function Wq(e){let t=Lq(e.question)||Lq(e.title)||`Continue?`,n=Lq(e.detail)||Lq(e.message);return{kind:`confirm`,question:t,...n?{detail:n}:{}}}function Gq(e){let t=Lq(e.question)||Lq(e.title)||`Type an answer`,n=Lq(e.placeholder);return{kind:`text`,question:t,...n?{placeholder:n}:{}}}function Kq(e){let t=Iq(e.payload);if(e.kind===`questionnaire`)return Hq(t);if(e.kind===`choose`)return Uq(t);if(e.kind===`confirm`)return Wq(t);if(e.kind===`text`)return Gq(t);let n=Vq(t.dialog);return n?{kind:`sessionDialog`,dialog:n}:void 0}var qq=`That question was already answered in the terminal.`;function Jq(e){let t=e.from.trim();return/panel|plann/i.test(t)?`PLANNER`:/oracle|master|lobby/i.test(t)||!t?`MASTER`:t.split(/\s+/)[0].toUpperCase()}function Yq(e,t){let n=Jq(e);return n===`PLANNER`&&t&&pR(t)!==`var(--muted-foreground)`?t.toUpperCase():n}function Xq(e,t){let n=Yq(e,t);if(n!==Jq(e))return n===`DEV`||n===`BACKEND`?`Dev`:n===`QA`?`QA`:n.charAt(0)+n.slice(1).toLowerCase();let r=Jq(e);if(r===`PLANNER`)return`Panel`;if(r===`MASTER`)return`Oracle`;let i=e.from.trim().split(/\s+/)[0]??`Agent`;return i.charAt(0).toUpperCase()+i.slice(1)}function Zq(e,t){let{round:n,limit:r}=e.payload??{},i=n?`From planning · round ${r?`${Math.min(n,r)}/${r}`:n}`:`From planning`,a=Jq(e)===`PLANNER`?i:e.taskId?`From task ${e.taskId}`:`From the Lobby`;return t&&t!==`Question`&&Yq(e,t)===Jq(e)?`${a} · ${t}`:a}function Qq(e,t,n){let r={prompt:e,view:t,index:0,multi:!1,placeholder:`Or type your own reply…`};if(t.kind===`questionnaire`){let e=t.questions[n];return e?{...r,index:n,question:e.question,header:e.header,multi:!!e.multiSelect,options:e.options.map(e=>({...e,value:e.label})),typed:e=>e}:void 0}if(t.kind===`choose`)return{...r,question:t.title,options:t.options.map(e=>({label:e,value:e}))};if(t.kind===`confirm`)return{...r,question:t.detail?`${t.question}\n\n${t.detail}`:t.question,options:[{label:`Yes`,value:!0},{label:`No`,value:!1}]};if(t.kind===`text`)return{...r,question:t.question,options:[],typed:e=>e,placeholder:t.placeholder||`Type your reply…`};let i=t.dialog,a=i.message?`${i.title}\n\n${i.message}`:i.title;return i.method===`select`?{...r,question:a,options:(i.options??[]).map(e=>({label:e,value:{value:e}}))}:i.method===`confirm`?{...r,question:a,options:[{label:`Yes`,value:{confirmed:!0}},{label:`No`,value:{confirmed:!1}}]}:{...r,question:a,options:[],typed:e=>({value:e}),placeholder:i.placeholder||`Type your reply…`}}function $q(e,t){return e&&e.kind===`questionnaire`?Math.max(0,e.questions.length-t):1}function eJ(e,t,n){let[r,i]=(0,m.useState)({}),[a,o]=(0,m.useState)([]),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(0),[d,f]=(0,m.useState)(),p=(0,m.useMemo)(()=>e.map(e=>({prompt:e,view:Kq(e)})),[e]),h=p[0],g=h?.view?Qq(h.prompt,h.view,r[h.prompt.id]?.length??0):void 0,_=p.reduce((e,{prompt:t,view:n})=>e+$q(n,r[t.id]?.length??0),0);(0,m.useEffect)(()=>{e.length===0&&(u(0),i({}))},[e.length]);let v=g?`${g.prompt.id}:${g.index}`:``;(0,m.useEffect)(()=>o([]),[v]);let y=(0,m.useCallback)(async(e,n)=>{c(!0);try{await t(e,n)}catch(e){e instanceof xe&&e.code===`question_withdrawn`?H(qq):H.error(e instanceof Error?e.message:`Could not send the answer`)}finally{c(!1)}},[t]),b=(0,m.useCallback)((e,t=`option`,n)=>{if(!g||s)return;if(u(e=>e+1),g.view.kind!==`questionnaire`)return void y(g.prompt.id,e);let a=[...r[g.prompt.id]??[],{questionIndex:g.index,question:g.question,kind:t,answer:String(e),...n?{selected:n}:{}}];if(a.length<g.view.questions.length)return i(e=>({...e,[g.prompt.id]:a}));y(g.prompt.id,{answers:a,cancelled:!1}).then(()=>i(e=>{let t={...e};return delete t[g.prompt.id],t}))},[s,r,y,g]),x=(0,m.useCallback)(e=>{let t=g?.options[e];if(t){if(g.multi)return o(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);b(t.value)}},[g,b]),S=x,C=(0,m.useCallback)(()=>{if(!g||a.length===0)return;let e=[...a].sort((e,t)=>e-t).map(e=>g.options[e].label);b(e.join(`, `),`multi`,e)},[a,g,b]),w=(0,m.useCallback)(e=>!g?.typed||!e.trim()?!1:(b(g.typed(e.trim()),`custom`),!0),[g,b]),T=(0,m.useCallback)(()=>{g&&n(g.prompt.id).catch(e=>H.error(e instanceof Error?e.message:`Could not dismiss the question`))},[n,g]),E=g?r[g.prompt.id]:void 0,D=(0,m.useCallback)(()=>{if(!g||s||!E?.length)return;let e=E.at(-1);i(e=>({...e,[g.prompt.id]:E.slice(0,-1)})),u(e=>Math.max(0,e-1)),f({id:g.prompt.id,index:e.questionIndex,answer:e.answer??``})},[s,E,g]),O=d&&g&&d.id===g.prompt.id&&d.index===g.index?d.answer:void 0;return{...g?{step:g}:{},position:l+1,total:l+_,left:_,picks:a,busy:s,choose:x,toggle:S,submitPicks:C,reply:w,dismiss:T,...E?.length?{back:D}:{},...O?{was:O}:{}}}function tJ({option:e,large:t}){let n=hU(e.label);return e.htmlPreview?(0,V.jsx)(fU,{preview:e.htmlPreview,label:n,frameWidth:t?void 0:880,minWidth:t?1024:void 0,className:`static-thumb h-full`}):e.image?(0,V.jsx)(`img`,{src:F(e.image),alt:t?`Mockup: ${n}`:``,loading:`lazy`}):e.preview?t?(0,V.jsx)(`div`,{className:`cs-mktext`,children:(0,V.jsx)(FL,{text:e.preview})}):(0,V.jsx)(`pre`,{className:`cs-mktext`,children:e.preview}):null}function nJ(e,t){return e!==void 0&&(e===t||e.split(`, `).includes(t))}function rJ({color:e,children:t}){return(0,V.jsx)(`span`,{className:`bubble-glyph cs-kg`,"aria-hidden":`true`,style:{"--k":e},children:t})}function iJ({drawer:e,onExpand:t}){let{step:n}=e,[r,i]=(0,m.useState)(!1);if((0,m.useEffect)(()=>i(!1),[n?.prompt.id]),!n)return(0,V.jsx)(`div`,{className:`bubble-pane p-3 text-sm text-(--bubble-muted)`,children:`No questions are waiting.`});let a=pR(Yq(n.prompt,n.header)),o=n.options.some(gU),s=n.options.length;return(0,V.jsxs)(`div`,{className:`bubble-pane p-1.5`,role:`group`,"aria-label":`Question`,children:[(0,V.jsxs)(`div`,{className:`cs-askh`,children:[(0,V.jsxs)(`div`,{className:`cs-asks`,children:[(0,V.jsx)(`b`,{style:{color:a},children:Xq(n.prompt,n.header)}),(0,V.jsx)(`span`,{className:`cs-askf`,children:Zq(n.prompt,n.header)}),e.back?(0,V.jsx)(`button`,{type:`button`,className:`cs-askx`,"aria-label":`Back to the previous question`,onMouseDown:e=>e.preventDefault(),onClick:e.back,children:`‹ Back`}):null,(0,V.jsxs)(`span`,{className:`cs-askn`,children:[e.position,` of `,e.total]}),(0,V.jsx)(`button`,{type:`button`,className:`cs-askx`,"data-confirm":r||void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>r?e.dismiss():i(!0),onBlur:()=>i(!1),children:r?`Dismiss it?`:`Dismiss`})]}),(0,V.jsx)(`p`,{className:`cs-askq`,title:n.question,children:n.question})]}),o?(0,V.jsx)(`div`,{className:`cs-askm`,children:n.options.map((n,r)=>(0,V.jsxs)(`button`,{type:`button`,className:`cs-mko`,"data-on":e.picks.includes(r)||nJ(e.was,n.label)||void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>e.choose(r),style:{animationDelay:`${r*30}ms`},children:[(0,V.jsxs)(`div`,{className:`cs-mk3`,children:[(0,V.jsx)(tJ,{option:n}),(0,V.jsx)(`span`,{className:`cs-mxb`,role:`button`,"aria-label":`Expand ${hU(n.label)}`,onClick:e=>{e.stopPropagation(),t(r)},children:(0,V.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7`})})})]}),(0,V.jsxs)(`span`,{className:`cs-mkl`,children:[(0,V.jsx)(rJ,{color:a,children:r+1}),(0,V.jsx)(`span`,{children:hU(n.label)})]})]},n.label))}):(0,V.jsxs)(`div`,{className:`cs-askopts`,children:[n.options.map((t,r)=>(0,V.jsxs)(`button`,{type:`button`,className:`bubble-row`,"data-active":e.picks.includes(r)||nJ(e.was,t.label)||void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>e.choose(r),style:{"--delay":`${(s-1-r)*22}ms`},children:[(0,V.jsx)(rJ,{color:a,children:r+1}),(0,V.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-(--bubble-ink)`,children:hU(t.label)}),t.description?(0,V.jsx)(`span`,{className:`min-w-0 truncate text-[13px] text-(--bubble-muted)`,title:t.description,children:t.description}):null,n.multi?(0,V.jsx)(`span`,{className:`cs-cb cs-sm`,"data-on":e.picks.includes(r),children:(0,V.jsx)(Jf,{"aria-hidden":`true`,strokeWidth:3})}):null]},t.label)),s===0?(0,V.jsx)(`div`,{className:`flex h-9 items-center px-2.5 text-[13px] text-(--bubble-muted)`,children:`Type your reply in the box below, then press Enter.`}):null]}),n.multi?(0,V.jsx)(`button`,{type:`button`,className:`bubble-row`,disabled:e.picks.length===0,onMouseDown:e=>e.preventDefault(),onClick:e.submitPicks,children:(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-accent)`,children:e.picks.length===0?`Pick one or more`:`Answer with ${e.picks.length} picked`})}):null]})}function aJ({drawer:e,at:t,onAt:n}){let r=e.step,i=r?.options??[],a=t>=0&&t<i.length,o=(0,m.useRef)(t);a&&(o.current=t);let s=i[o.current],c=(0,m.useRef)(null);(0,m.useEffect)(()=>{a&&c.current?.focus({preventScroll:!0})},[a]);let l=e=>n((o.current+e+i.length)%i.length),u=r?pR(Yq(r.prompt,r.header)):`var(--primary)`;return(0,V.jsxs)(`div`,{className:`cs-mxw`,"data-open":a,"aria-hidden":!a,inert:!a,children:[(0,V.jsx)(`div`,{className:`cs-shbd`,onClick:()=>n(-1)}),(0,V.jsxs)(`div`,{ref:c,role:a?`dialog`:void 0,"aria-modal":a?`true`:void 0,"aria-label":s?`Mockup: ${hU(s.label)}`:`Mockup`,tabIndex:-1,className:`cs-mxc`,onKeyDown:t=>{t.key===`Escape`?(t.preventDefault(),t.stopPropagation(),n(-1)):t.key===`ArrowRight`||t.key===`ArrowLeft`?(t.preventDefault(),l(t.key===`ArrowRight`?1:-1)):t.key===`Enter`&&s&&(t.preventDefault(),n(-1),e.choose(o.current))},children:[(0,V.jsx)(`div`,{className:`cs-mxbig`,children:s?(0,V.jsx)(tJ,{option:s,large:!0}):null}),s&&r?(0,V.jsxs)(`div`,{className:`cs-mxf`,children:[(0,V.jsx)(rJ,{color:u,children:o.current+1}),(0,V.jsx)(`b`,{children:hU(s.label)}),(0,V.jsxs)(`span`,{className:`cs-mxwho`,children:[Xq(r.prompt,r.header),` · `,r.question]}),i.length>1?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib`,"aria-label":`Previous mockup`,onClick:()=>l(-1),children:(0,V.jsx)(Zf,{"aria-hidden":`true`,className:`size-3.5`})}),(0,V.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib`,"aria-label":`Next mockup`,onClick:()=>l(1),children:(0,V.jsx)($f,{"aria-hidden":`true`,className:`size-3.5`})})]}):null,(0,V.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-pri`,onClick:()=>{n(-1),e.choose(o.current)},children:r.multi?e.picks.includes(o.current)?`Unpick this`:`Pick this`:`Choose this`}),(0,V.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib`,"aria-label":`Close`,onClick:()=>n(-1),children:(0,V.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5`})})]}):null]})]})}var oJ=`bot-lobby.questionsPutAway`,sJ=new Set,cJ;function lJ(){if(cJ!==void 0)return cJ;try{cJ=sessionStorage.getItem(oJ)===`1`}catch{cJ=!1}return cJ}function uJ(e){if(lJ()!==e){cJ=e;try{e?sessionStorage.setItem(oJ,`1`):sessionStorage.removeItem(oJ)}catch{}for(let e of[...sJ])e()}}function dJ(e){return sJ.add(e),()=>{sJ.delete(e)}}function fJ(){return(0,m.useSyncExternalStore)(dJ,lJ,()=>!1)}var pJ={id:`oracle`,label:`Message the team`,placeholder:`Write a message, run a command, or ask an agent`},mJ=new Set([`lobby`,`tasks`,`plan`,`knowledge`]);function hJ(e){return e.kind===`settings`||e.kind===`tab`&&mJ.has(e.tab)}var gJ={id:`knowledge`,label:`Ask what the agents know`,placeholder:`Ask what the agents know…`};function _J(e,t){if(e.kind!==`tab`)return pJ;if(e.tab===`knowledge`)return gJ;if(e.tab===`plan`)return{id:`panel`,label:`Message the panel`,placeholder:`Describe a task, or answer the panel…`};let n=e.tab===`tasks`?cR(e.rest).id??t:void 0;return n?{id:`comment`,label:`Comment on ${n}`,placeholder:`Comment on ${n}'s plan…`,taskId:n}:pJ}var vJ={w:260,h:97},yJ=0,bJ=document.createElement(`canvas`).getContext(`2d`);function xJ(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}var SJ={duration:.16,ease:`easeOut`};function CJ({file:e,onRemove:t}){let n=(0,V.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,onClick:t,className:Y(`flex shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,e.image?`absolute top-1 right-1 size-[1.625rem] rounded-full bg-background/85 text-foreground shadow-xs hover:bg-background`:`size-7`),children:(0,V.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5`})});return e.image?(0,V.jsxs)(Yd.li,{layout:!0,initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:SJ,title:`${e.name} · ${RK(e.size)}`,className:`relative size-16 shrink-0 overflow-hidden rounded-xl border border-(--bubble-edge) bg-background`,children:[(0,V.jsx)(`img`,{src:F(e.image),alt:e.name,className:`size-full object-cover`}),e.state===`uploading`?(0,V.jsxs)(`span`,{className:`pointer-events-none absolute inset-x-0 bottom-0 flex items-center justify-center gap-1 bg-background/85 px-1 text-[0.625rem] text-foreground`,children:[(0,V.jsx)(lR,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}),`uploading`]}):null,n]}):(0,V.jsxs)(Yd.li,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:SJ,className:`flex min-w-0 basis-full items-center gap-2 text-sm text-foreground`,children:[(0,V.jsx)(jp,{"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)(lR,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}):null,e.state===`uploading`?`uploading…`:RK(e.size)]}),n]})}function wJ(e,t,n,r){let[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(r);o.current=r;let s=n.kind===`tab`?n.tab:n.kind;return(0,m.useEffect)(()=>a(!1),[s]),(0,m.useEffect)(()=>{if(!t)return;let n=0,r=t=>{e.current?.contains(t.target)||(n=performance.now())},i=t=>{[`PageDown`,`PageUp`,`ArrowDown`,`ArrowUp`,`Home`,`End`,` `].includes(t.key)&&!e.current?.contains(t.target)&&(n=performance.now())},s=t=>{let r=e.current;!r||o.current||performance.now()-n>400||r.contains(document.activeElement)||r.contains(t.target)||a(!0)};return document.addEventListener(`wheel`,r,{capture:!0,passive:!0}),document.addEventListener(`touchmove`,r,{capture:!0,passive:!0}),document.addEventListener(`keydown`,i,{capture:!0}),document.addEventListener(`scroll`,s,{capture:!0,passive:!0}),()=>{document.removeEventListener(`wheel`,r,{capture:!0}),document.removeEventListener(`touchmove`,r,{capture:!0}),document.removeEventListener(`keydown`,i,{capture:!0}),document.removeEventListener(`scroll`,s,{capture:!0})}},[t,e]),{shrunk:i,expand:(0,m.useCallback)(()=>a(!1),[])}}function TJ({children:e}){return(0,V.jsx)(`kbd`,{className:`bubble-kbd`,"data-glyph":/^[^A-Za-z0-9]$/.test(e)||void 0,children:e})}function EJ(e,t,n){let[r,i]=(0,m.useState)({w:250,h:38});return(0,m.useLayoutEffect)(()=>{let r=t.current;if(!r)return;let a=()=>{let t=e===`bar`?{w:Math.ceil(r.scrollWidth),h:38}:{w:n??580,h:Math.ceil(r.scrollHeight)};i(e=>e.w===t.w&&e.h===t.h?e:t)};a();let o=new ResizeObserver(a);for(let e of r.children)o.observe(e);return()=>o.disconnect()}),r}function DJ({route:e,projects:t,drawer:n,drawerOpen:r}){let[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)([]),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(null),h=vE(`status`),g=vE(`lobby`),_=YT(),v=(h.data?.busy??!1)||!!g.data?.reply?.trim(),y=hJ(e),b=(0,m.useRef)(y);b.current=y;let{taskId:x}=SW(),S=e.kind===`tab`?e.tab:e.kind,C=(0,m.useMemo)(()=>_J(e,x),[e,x]),w=pD(),[T,E]=(0,m.useState)(-1),D=(0,m.useRef)(null),O=(0,m.useRef)(null),k=(0,m.useRef)(null),ee=(0,m.useRef)(null),A=(0,m.useRef)(null),j=(0,m.useRef)(null),M=(0,m.useRef)(null),te=(0,m.useRef)(null),ne=(0,m.useRef)(o);ne.current=o;let N=(0,m.useRef)(void 0),[re,ie]=(0,m.useState)(0),[ae,oe]=(0,m.useState)(null),[se,ce]=(0,m.useState)(void 0),le=r&&!!n.step&&y&&!_&&f===null,ue=C.id===`oracle`&&!f&&!le?Dq(i,re):void 0,P=(0,m.useMemo)(()=>ue?kq(ue,h.data?.commands):[],[ue?.kind,ue?.query,h.data?.commands]),de=!!ue&&P.length>0&&se!==i&&y&&!_,fe=de?P.find(e=>e.id===ae)??P[0]:void 0,pe=`composer-suggestions`,F={answer:n.left>0&&!r,plan:S===`plan`&&!!w},I=!de&&f===null&&!le&&y&&!_&&(F.answer||F.plan),me=de||le||f!==null&&y&&!_,{shrunk:he,expand:ge}=wJ(D,y&&!_,e,me),[_e,ve]=(0,m.useState)(!1),ye=(0,m.useRef)(he);(0,m.useEffect)(()=>{if(ye.current===he)return;ye.current=he,ve(!0);let e=setTimeout(()=>ve(!1),400);return()=>clearTimeout(e)},[he]);let be=I&&!he&&!_e,xe=me||be;(0,m.useEffect)(()=>{let e=document.documentElement;return e.style.setProperty(`--dock-bar`,I?`44px`:`0px`),()=>e.style.setProperty(`--dock-bar`,`0px`)},[I]),(0,m.useEffect)(()=>p(null),[S]),(0,m.useEffect)(()=>{(!y||_)&&p(null)},[y,_]),(0,m.useEffect)(()=>{if(!f)return;let e=e=>{O.current?.contains(e.target)||p(null)};return document.addEventListener(`pointerdown`,e,{capture:!0}),()=>document.removeEventListener(`pointerdown`,e,{capture:!0})},[f]);let Se=(0,m.useCallback)(e=>{ge(),p(t=>t===e||e===`projects`&&t===`browse`?null:e)},[ge]),Ce=(0,m.useCallback)(()=>{p(e=>{let t=e===`attach`?`[data-composer-attach]`:e?`[role="combobox"][aria-label="Project"]`:void 0;return t&&requestAnimationFrame(()=>O.current?.querySelector(t)?.focus({preventScroll:!0})),null})},[]);RE(`p`,()=>Se(`projects`),{enabled:y&&!_&&f===null}),(0,m.useEffect)(()=>{let e=()=>{ge(),p(`projects`)};return window.addEventListener(XK,e),()=>window.removeEventListener(XK,e)},[ge]);let we=(0,m.useRef)(`suggest`),Te=(0,m.useRef)({w:320,h:0}),Ee=f??(le?`ask`:de?`suggest`:be?`bar`:we.current),De=(0,m.useRef)(null),Oe=EJ(Ee,De,Ee===`ask`&&n.step?.options.some(gU)?Math.max(580,Math.min(960,(k.current?.clientWidth??740)-12)):void 0);if(xe){we.current=Ee;let e=A.current?getComputedStyle(A.current).fontFamily:`system-ui, sans-serif`;Te.current=Ee===`suggest`?{w:Pq(P,e),h:Mq(P.length)}:Ee===`attach`?vJ:Ee===`projects`?QK(t):Ee===`bar`||Ee===`ask`?Oe:tq}let ke=(0,m.useRef)({items:[],kind:`slash-command`});de&&ue&&fe&&(ke.current={items:P,kind:ue.kind,lit:fe.id});let Ae=(0,m.useCallback)(e=>{let t=i.replace(/^\s*[/@][a-z0-9:_.-]*\s*/i,``),n=`${e.insert} ${t}`,r=e.insert.length+1;N.current={start:r,end:r},ie(r),a(n),oe(null),A.current?.focus()},[i]);(0,m.useLayoutEffect)(()=>{let e=N.current,t=A.current;e&&t&&(N.current=void 0,t.setSelectionRange(e.start,e.end))},[i]);let je=(0,m.useCallback)(e=>{N.current={start:e.start,end:e.end},ie(e.end),a(e.value)},[]);(0,m.useLayoutEffect)(()=>{let e=ee.current,t=O.current;if(!e||!t)return;let n=()=>{t.hasAttribute(`data-shrunk`)||t.style.setProperty(`--ch-open`,`${Math.ceil(e.getBoundingClientRect().height)}px`)};n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[he]),(0,m.useLayoutEffect)(()=>{let e=A.current,t=O.current;if(!e||!t)return;if(he||!i)return void t.style.removeProperty(`--cg`);let n=getComputedStyle(e);bJ.font=`${n.fontStyle} ${n.fontWeight} ${n.fontSize} ${n.fontFamily}`;let r=Math.max(...i.split(`
114
- `).map(e=>bJ.measureText(e).width));t.style.setProperty(`--cg`,`${Math.ceil((r+44)/48)*48}px`)},[i,he]),(0,m.useLayoutEffect)(()=>{j.current&&A.current&&(j.current.scrollTop=A.current.scrollTop)}),(0,m.useEffect)(()=>{let e=k.current,t=D.current;if(!e||!t)return;let n=document.documentElement,r=()=>{let r=e.getBoundingClientRect(),i=t.getBoundingClientRect().bottom;if(!t.hasAttribute(`data-shrunk`)&&!e.closest(`.bubble`)?.hasAttribute(`data-morphing`)||!y||_){if(n.style.setProperty(`--composer-h`,_||!y?`0px`:`${Math.ceil(i-r.top)}px`),!y||r.width===0){n.style.removeProperty(`--composer-x`),n.style.removeProperty(`--composer-w`);return}n.style.setProperty(`--composer-x`,`${Math.round(r.left)}px`),n.style.setProperty(`--composer-w`,`${Math.round(r.width)}px`)}};r();let i=new ResizeObserver(r);return i.observe(e),e.addEventListener(`transitionend`,r),window.addEventListener(`resize`,r),()=>{i.disconnect(),e.removeEventListener(`transitionend`,r),window.removeEventListener(`resize`,r),n.style.setProperty(`--composer-h`,`0px`),n.style.removeProperty(`--composer-x`),n.style.removeProperty(`--composer-w`)}},[_,y]);let Me=(0,m.useCallback)(e=>{if(!b.current)return;let t=[...e],n=8-ne.current.length;t.length>n&&H.warning(`At most 8 files go with one message.`);for(let e of t.slice(0,Math.max(0,n))){let t=`f${++yJ}`,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`}]),zK(e).then(e=>s(n=>n.map(n=>n.key===t?{...n,state:`ready`,info:e}:n))).catch(e=>{H.error(e instanceof Error?e.message:`That file did not upload.`),s(e=>e.filter(e=>e.key!==t))})}},[]),Ne=(0,m.useCallback)(e=>{s(t=>{let n=t.find(t=>t.key===e);return n?.image&&URL.revokeObjectURL(n.image),t.filter(t=>t.key!==e)})},[]),Pe=o.some(e=>e.state===`uploading`),Fe=o.flatMap(e=>e.info?[e.info.id]:[]),Ie=(i.trim().length>0||Fe.length>0)&&!Pe&&!c,Le=(0,m.useCallback)(async()=>{if(!Ie||!b.current)return;l(!0);let e=Fe.length>0?Fe:void 0,t={text:i,...e?{attachments:e}:{}};try{let e=!0,n=C.id===`knowledge`&&/^\s*[/@]/.test(i);if(C.id===`oracle`||n){let e=await L(`lobby.send`,t);e.notice&&H(e.notice),e.open===`plan`?iE(rE(`plan`)):S===`knowledge`&&iE(rE(`lobby`))}else C.id===`knowledge`?(e=await U(`knowledge.ask`,t)!==void 0,e&&window.dispatchEvent(new CustomEvent(hD,{detail:i.trim()}))):e=C.id===`panel`?await U(`planner.send`,t)!==void 0:await U(`tasks.comment`,{taskId:C.taskId,...t})!==void 0;if(e){a(``);for(let e of ne.current)e.image&&URL.revokeObjectURL(e.image);s([])}}catch(e){H.error(e instanceof Error?e.message:`Could not send`)}finally{l(!1)}},[Ie,Fe,C,i,e,S]),Re=(0,m.useCallback)(async()=>{try{await L(`lobby.abort`,{})}catch(e){H.error(e instanceof Error?e.message:`Could not stop`)}},[]),ze=e=>{if(de&&fe&&!e.nativeEvent.isComposing){let t=P.indexOf(fe);if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=(t+(e.key===`ArrowDown`?1:-1)+P.length)%P.length;oe(P[n].id);return}if(e.key===`Enter`&&!e.shiftKey||e.key===`Tab`){e.preventDefault(),Ae(fe);return}if(e.key===`Escape`){e.preventDefault(),ce(i);return}}if(e.key===`Escape`&&!e.nativeEvent.isComposing){e.preventDefault(),f?p(null):le?uJ(!0):DE();return}if(le&&xJ(e)){e.preventDefault(),n.reply(i)?a(``):!i.trim()&&n.step?.multi&&n.submitPicks();return}let t=e.currentTarget,r=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&!e.altKey&&!e.shiftKey&&[`b`,`i`,`e`,`k`].includes(r)){e.preventDefault();let{selectionStart:n,selectionEnd:i,value:a}=t;je(r===`k`?VK(a,n,i):BK(a,n,i,r===`b`?`**`:r===`i`?`_`:"`"));return}if(e.key===`Enter`&&e.shiftKey&&!e.nativeEvent.isComposing&&t.selectionStart===t.selectionEnd){let n=UK(t.value,t.selectionStart);n&&(e.preventDefault(),je(n));return}if(e.key===`Backspace`&&t.value===``&&ne.current.length>0){e.preventDefault(),Ne(ne.current.at(-1).key);return}(xJ(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey))&&(e.preventDefault(),Le())},Be=e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),Me(t))},Ve=e=>{e.preventDefault(),d(!1),e.dataTransfer.files.length>0&&Me(e.dataTransfer.files)},He=h.data?.workspace.name??`bot-lobby`,Ue=h.data?.branch??h.data?.workspace.branch,We=v&&C.id===`oracle`,Ge=he?S===`knowledge`?`Ask what the agents know…`:`Write a message…`:le?n.step?.typed?n.step.placeholder:`Pick an answer above`:We?`The oracle is working. Enter steers it…`:C.placeholder,Ke=e=>{p(null),e.current?.click()},qe=Ee===`ask`?(0,V.jsx)(`div`,{ref:De,children:(0,V.jsx)(iJ,{drawer:n,onExpand:E})},`ask`):Ee===`bar`?(0,V.jsx)(`div`,{ref:De,className:`bubble-pane p-1`,style:{width:`max-content`},children:(0,V.jsxs)(`div`,{className:`cs-pbar`,children:[F.answer?(0,V.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq cs-acc`,onMouseDown:e=>e.preventDefault(),onClick:()=>{uJ(!1),requestAnimationFrame(()=>A.current?.focus({preventScroll:!0}))},children:[(0,V.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M21 12a8 8 0 01-11.6 7.1L4 20l1-4.6A8 8 0 1121 12z`}),(0,V.jsx)(`path`,{d:`M9.6 9.5a2.5 2.5 0 014.8.9c0 1.6-2.4 2-2.4 3.4M12 16.5h.01`})]}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-accent)`,children:`Answer questions`}),(0,V.jsxs)(`span`,{className:`cs-ktag`,style:{"--k":`var(--primary)`},children:[n.left,` left`]})]}):null,F.plan?(0,V.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq`,"aria-keyshortcuts":`V`,onMouseDown:e=>e.preventDefault(),onClick:()=>w?.(),children:[(0,V.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M14 3H7a2 2 0 00-2 2v14a2 2 0 002 2h10a2 2 0 002-2V8z`}),(0,V.jsx)(`path`,{d:`M14 3v5h5M9 13h6M9 17h4`})]}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`View plan`}),(0,V.jsx)(`span`,{className:`cs-kb`,children:`V`})]}):null]})},`bar`):Ee===`suggest`?(0,V.jsx)(Fq,{listId:pe,items:de?P:ke.current.items,triggerKind:de&&ue?ue.kind:ke.current.kind,activeItemId:fe?.id??null,onHighlightedItemChange:oe,onSelect:Ae},`suggest`):Ee===`attach`?(0,V.jsxs)(`div`,{role:`menu`,"aria-label":`Attach`,className:`bubble-pane flex flex-col p-1`,onKeyDown:e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=[...e.currentTarget.querySelectorAll(`[role='menuitem']`)];t[(t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:t.length-1))%t.length]?.focus()},children:[(0,V.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`bubble-row`,style:{"--delay":`24ms`},onClick:()=>Ke(M),children:[(0,V.jsx)(jp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Upload a file…`})]}),(0,V.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`bubble-row`,style:{"--delay":`12ms`},onClick:()=>Ke(te),children:[(0,V.jsx)(Vp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Upload an image…`})]}),(0,V.jsx)(`div`,{className:`h-px`}),(0,V.jsx)(`div`,{className:`flex h-7 items-center px-2 text-[11.5px] text-(--bubble-muted)`,children:`Or drop files on the composer`})]},`attach`):Ee===`projects`?(0,V.jsx)(eq,{projects:t,tab:S,onBrowse:()=>p(`browse`),onClose:()=>p(null)},`projects`):(0,V.jsx)(aq,{tab:S,onClose:Ce},`browse`);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`cs-scrim`,"data-open":me||void 0,"aria-hidden":`true`}),(0,V.jsx)(`div`,{id:`app-dock`,ref:D,"data-shrunk":he||void 0,onFocus:ge,className:Y(`dock pointer-events-none absolute inset-x-0 bottom-0 z-30 px-6 pb-[max(24px,env(safe-area-inset-bottom))] transition-opacity duration-200 ease-snap`,_&&`opacity-0`),hidden:!y,"aria-hidden":!y||void 0,inert:_||!y,children:(0,V.jsx)(cq,{ref:O,open:xe,size:Te.current,shrunk:he,morphing:_e,menu:qe,className:`composer-shell pointer-events-auto`,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||(f?(e.preventDefault(),Ce()):le&&(e.preventDefault(),uJ(!0)))},children:(0,V.jsxs)(`div`,{ref:k,className:`bubble-composer group/composer composer-box`,"data-dragging":u||void 0,"data-chat-composer-main-surface":`true`,onPointerDown:ge,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),d(!0))},onDragLeave:()=>d(!1),onDrop:Ve,children:[(0,V.jsxs)(`div`,{ref:ee,"data-chat-composer-surface":`true`,children:[(0,V.jsx)(eu,{initial:!1,children:o.length>0?(0,V.jsx)(Yd.ul,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.18,ease:`easeOut`},"aria-label":`Attachments`,className:`composer-files flex max-w-full flex-wrap gap-2 overflow-hidden px-3.5 pt-3`,children:o.map(e=>(0,V.jsx)(CJ,{file:e,onRemove:()=>Ne(e.key)},e.key))},`files`):null}),(0,V.jsxs)(`div`,{className:`bubble-field`,children:[(0,V.jsx)(Sq,{ref:j,text:i}),(0,V.jsx)(`textarea`,{ref:A,id:`composer-text`,"aria-label":C.label,...C.id===`oracle`?{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":de,"aria-controls":de?pe:void 0}:{},...fe?{"aria-activedescendant":Aq(pe,fe.id)}:{},value:i,onChange:e=>{a(e.target.value),ie(e.target.selectionStart),p(null)},onSelect:e=>ie(e.currentTarget.selectionStart),onKeyDown:ze,onPaste:Be,onScroll:e=>{j.current&&(j.current.scrollTop=e.currentTarget.scrollTop)},placeholder:Ge,rows:1,className:`bubble-text bubble-input`})]}),(0,V.jsxs)(`div`,{"data-chat-composer-footer":`true`,className:`bubble-tools composer-tools`,children:[(0,V.jsx)(`button`,{type:`button`,"data-composer-attach":!0,"aria-label":`Attach images, PDFs or files`,"aria-haspopup":`menu`,"aria-expanded":f===`attach`,"data-on":f===`attach`||void 0,"data-tip":`Attach a file`,onPointerDown:e=>e.preventDefault(),onClick:()=>Se(`attach`),className:`bubble-iconbtn bubble-tip bubble-tool size-8 rounded-full`,style:{"--i":0},children:(0,V.jsx)(hm,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.7})}),(0,V.jsx)(`span`,{className:`bubble-tool flex min-w-0`,style:{"--i":1},children:(0,V.jsx)($K,{projects:t,name:He,branch:Ue,open:f===`projects`||f===`browse`,onToggle:()=>Se(`projects`)})}),(0,V.jsx)(`span`,{className:`flex-1`}),(0,V.jsx)(`span`,{className:`bubble-hints bubble-tool`,style:{"--i":2},"aria-hidden":`true`,children:de?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(TJ,{children:`↑`}),(0,V.jsx)(TJ,{children:`↓`}),`choose`,(0,V.jsx)(TJ,{children:`↵`}),`insert`]}):f?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(TJ,{children:`Esc`}),`close`]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(TJ,{children:`Shift`}),(0,V.jsx)(TJ,{children:`↵`}),`new line`]})}),(0,V.jsxs)(`span`,{"data-chat-composer-actions":`right`,className:`bubble-tool flex shrink-0 items-center gap-2`,style:{"--i":3},children:[We?(0,V.jsx)(wq,{onStop:()=>void Re()}):null,(0,V.jsx)(Tq,{sending:c,disabled:!Ie,steering:We,onSend:()=>void Le()})]})]})]}),(0,V.jsx)(`input`,{ref:M,type:`file`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach files`,onChange:e=>{Me(e.target.files??[]),e.target.value=``}}),(0,V.jsx)(`input`,{ref:te,type:`file`,accept:`image/*`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach images`,onChange:e=>{Me(e.target.files??[]),e.target.value=``}}),u?(0,V.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-30 flex items-center justify-center rounded-[inherit] text-sm font-medium text-(--bubble-accent)`,children:`Drop to attach`}):null]})})}),(0,V.jsx)(aJ,{drawer:n,at:le?T:-1,onAt:E})]})}function OJ({open:e,onOpenChange:t}){let n=qT(e,KT.help),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(``),l=(0,m.useId)(),u=()=>{a||(t(!1),i(``),c(``))},d=async()=>{let e=r.trim();if(e&&!a){o(!0),c(``);try{H((await L(`sessions.start`,{request:e})).notice),t(!1),i(``)}catch(e){c(e instanceof Error?e.message:`That did not work. Try again.`)}finally{o(!1)}}};return(0,V.jsx)(zT,{open:n,label:`New session`,description:`Starts a task in a session of its own, in the background.`,onOpenChange:e=>{e||u()},dismissOnBackdrop:!a,className:`max-w-[460px]`,children:(0,V.jsxs)(`div`,{className:`flex w-full flex-col`,children:[(0,V.jsxs)(`div`,{className:`cs-dh`,children:[(0,V.jsx)(`h2`,{children:`New session`}),(0,V.jsx)(`p`,{className:`mt-[5px] text-[12.5px] leading-normal text-muted-foreground`,children:`It runs in the background and shows up in the sidebar; this window carries on with what it is doing.`})]}),(0,V.jsxs)(`div`,{className:`cs-db flex flex-col`,children:[(0,V.jsx)(`label`,{htmlFor:l,className:`mb-[7px] text-[12.5px] font-semibold`,children:`What should it do?`}),(0,V.jsx)(TB,{id:l,value:r,autoFocus:!0,disabled:a,"aria-invalid":s?!0:void 0,placeholder:`Fix the flaky login test, add dark mode to Settings…`,className:`cs-nsta max-h-60 min-h-[108px]`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d())}}),s?(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:s}):null]}),(0,V.jsxs)(`div`,{className:`cs-df`,children:[(0,V.jsxs)(`span`,{className:`mr-auto flex items-center gap-1.5 text-xs text-[var(--faint)]`,children:[(0,V.jsx)(IT,{chord:`Ctrl+Enter`}),` to start`]}),(0,V.jsx)(OT,{variant:`outline`,onClick:u,disabled:a,children:`Cancel`}),(0,V.jsx)(OT,{onClick:()=>void d(),disabled:!r.trim()||a,"aria-busy":a,children:a?`Starting…`:`Start session`})]})]})})}var kJ=.6;function AJ(e,t,n={}){return{initial:e?void 0:!1,animate:t,transition:{duration:kJ,...n}}}var jJ=(e,t)=>[0,Math.max(e,.001),Math.min(Math.max(t,e+.01),.999),1];function MJ(e,t=0,n=1){return AJ(e,{pathLength:[0,0,1,1],strokeOpacity:[0,0,1,1]},{pathLength:{duration:kJ,times:jJ(t,n),ease:`easeInOut`},strokeOpacity:{duration:kJ,times:jJ(t,t+.02)}})}function NJ(e,t){return AJ(e,{scale:[0,0,1.3,1]},{times:jJ(t,t+.18),ease:`easeOut`})}function PJ(e,t,n=1.3){return AJ(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 FJ=(e=.5,t=.5)=>({transformBox:`fill-box`,originX:e,originY:t});function IJ({play:e}){return(0,V.jsxs)(Yd.g,{style:FJ(.1,.9),...AJ(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)(Yd.circle,{cx:t,cy:11,r:1.15,fill:`currentColor`,stroke:`none`,...AJ(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 LJ({play:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Yd.path,{d:`M13 5h8`,...MJ(e,.15,.45)}),(0,V.jsx)(Yd.path,{d:`M13 12h8`,...MJ(e,.3,.6)}),(0,V.jsx)(Yd.path,{d:`M13 19h8`,...MJ(e,.45,.75)}),(0,V.jsx)(Yd.path,{d:`m3 17 2 2 4-4`,...MJ(e,.35,.7)}),(0,V.jsx)(Yd.path,{d:`m3 7 2 2 4-4`,...MJ(e,0,.35)})]})}function RJ({play:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Yd.circle,{cx:6,cy:19,r:3,style:FJ(),...PJ(e,0)}),(0,V.jsx)(Yd.path,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,...MJ(e,.1,.7)}),(0,V.jsx)(Yd.circle,{cx:18,cy:5,r:3,style:FJ(),...NJ(e,.62)})]})}function zJ({play:e}){return(0,V.jsxs)(Yd.g,{style:FJ(),...AJ(e,{scaleX:[1,.55,1.08,1],y:[0,-1,0,0]},{times:[0,.35,.65,1],ease:`easeInOut`}),children:[(0,V.jsx)(Yd.path,{d:`M12 5v16`,style:FJ(),...AJ(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 BJ={lobby:IJ,tasks:LJ,plan:RJ,knowledge:zJ};function VJ({id:e,play:t,className:n}){let r=BJ[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:1.8,strokeLinecap:`round`,strokeLinejoin:`round`,className:Y(`overflow-visible`,n),children:(0,V.jsx)(r,{play:t})},t):null}function HJ(){let e=(e,t)=>(0,V.jsxs)(`filter`,{id:e,x:`-20%`,y:`-35%`,width:`140%`,height:`170%`,colorInterpolationFilters:`sRGB`,children:[(0,V.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:t,result:`b`}),(0,V.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`rimA`}),(0,V.jsx)(`feGaussianBlur`,{in:`rimA`,stdDeviation:`0.6`,result:`rimB`}),(0,V.jsx)(`feComposite`,{in:`rimB`,in2:`shape`,operator:`in`,result:`rimC`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--hl)`},result:`hlc`}),(0,V.jsx)(`feComposite`,{in:`hlc`,in2:`rimC`,operator:`in`,result:`hl`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`shA`}),(0,V.jsx)(`feGaussianBlur`,{in:`shA`,stdDeviation:`0.6`,result:`shB`}),(0,V.jsx)(`feComposite`,{in:`shB`,in2:`shape`,operator:`in`,result:`shC`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--sh)`},result:`shc`}),(0,V.jsx)(`feComposite`,{in:`shc`,in2:`shC`,operator:`in`,result:`sh`}),(0,V.jsxs)(`feMerge`,{children:[(0,V.jsx)(`feMergeNode`,{in:`shape`}),(0,V.jsx)(`feMergeNode`,{in:`sh`}),(0,V.jsx)(`feMergeNode`,{in:`hl`})]})]});return(0,V.jsx)(`svg`,{width:`0`,height:`0`,className:`absolute`,"aria-hidden":`true`,focusable:`false`,children:(0,V.jsxs)(`defs`,{children:[e(`cs-baylit`,3.5),e(`cs-worklit`,3.2),(0,V.jsxs)(`filter`,{id:`cs-bayedge`,x:`-20%`,y:`-35%`,width:`140%`,height:`170%`,colorInterpolationFilters:`sRGB`,children:[(0,V.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`3.5`,result:`b`}),(0,V.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`tS0`}),(0,V.jsx)(`feGaussianBlur`,{in:`tS0`,stdDeviation:`0.3`,result:`tS1`}),(0,V.jsx)(`feComposite`,{in:`tS1`,in2:`shape`,operator:`in`,result:`tS`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--ehl)`},result:`tc`}),(0,V.jsx)(`feComposite`,{in:`tc`,in2:`tS`,operator:`in`,result:`eh`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`bS0`}),(0,V.jsx)(`feGaussianBlur`,{in:`bS0`,stdDeviation:`0.3`,result:`bS1`}),(0,V.jsx)(`feComposite`,{in:`bS1`,in2:`shape`,operator:`in`,result:`bS`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--esh)`},result:`bc`}),(0,V.jsx)(`feComposite`,{in:`bc`,in2:`bS`,operator:`in`,result:`es`}),(0,V.jsxs)(`feMerge`,{children:[(0,V.jsx)(`feMergeNode`,{in:`shape`}),(0,V.jsx)(`feMergeNode`,{in:`eh`}),(0,V.jsx)(`feMergeNode`,{in:`es`})]})]})]})})}function UJ({className:e,style:t}){return(0,V.jsxs)(`div`,{className:e,"aria-hidden":`true`,style:t,children:[(0,V.jsx)(`div`,{className:`cs-layer cs-edge`,children:(0,V.jsx)(`div`,{className:`cs-bb`})}),(0,V.jsx)(`div`,{className:`cs-layer cs-fill`,children:(0,V.jsx)(`div`,{className:`cs-bb`})})]})}function WJ(e,t=e){let[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(void 0);(0,m.useEffect)(()=>()=>window.clearTimeout(o.current),[]);let s=(0,m.useCallback)(()=>{window.clearTimeout(o.current),r(!0)},[]),c=(0,m.useCallback)(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(()=>r(!1),e)},[e]),l=(0,m.useCallback)(()=>{window.clearTimeout(o.current),r(!0),o.current=window.setTimeout(()=>r(!1),t)},[t]),u=(0,m.useRef)(void 0);return(0,m.useEffect)(()=>()=>u.current?.(),[]),{open:n||i,flash:l,close:()=>{window.clearTimeout(o.current),r(!1)},handlers:{onPointerDown:e=>{if(e.pointerType!==`touch`)return;let t=e.currentTarget;if(n)e.target.closest(`[role='tab']`)&&c();else{window.clearTimeout(o.current),r(!0),u.current?.();let e=e=>{t.contains(e.target)||(window.clearTimeout(o.current),r(!1),u.current?.())};document.addEventListener(`pointerdown`,e,!0);let n=e=>{e.preventDefault(),e.stopPropagation()};t.addEventListener(`click`,n,{capture:!0,once:!0}),window.setTimeout(()=>t.removeEventListener(`click`,n,!0),500),u.current=()=>{document.removeEventListener(`pointerdown`,e,!0),u.current=void 0}}},onPointerEnter:e=>{e.pointerType!==`touch`&&s()},onPointerLeave:e=>{e.pointerType!==`touch`&&c()},onFocus:()=>a(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||a(!1)}}}}function GJ({id:e}){let t={width:15,height:15,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0};return e===`lobby`?(0,V.jsx)(`svg`,{...t,children:(0,V.jsx)(`path`,{d:`M21 12a8 8 0 01-11.6 7.1L4 20l1-4.6A8 8 0 1121 12z`})}):e===`tasks`?(0,V.jsxs)(`svg`,{...t,children:[(0,V.jsx)(`path`,{d:`M9 11l3 3L22 4`}),(0,V.jsx)(`path`,{d:`M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11`})]}):e===`plan`?(0,V.jsxs)(`svg`,{...t,children:[(0,V.jsx)(`path`,{d:`M3 6l6-3 6 3 6-3v15l-6 3-6-3-6 3z`}),(0,V.jsx)(`path`,{d:`M9 3v15M15 6v15`})]}):e===`knowledge`?(0,V.jsxs)(`svg`,{...t,children:[(0,V.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 016.5 17H20`}),(0,V.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 014 19.5v-15A2.5 2.5 0 016.5 2z`})]}):(0,V.jsxs)(`svg`,{...t,children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,V.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 00.3 1.8l.1.1a2 2 0 11-2.8 2.8l-.1-.1a1.7 1.7 0 00-1.8-.3 1.7 1.7 0 00-1 1.5V21a2 2 0 11-4 0v-.1a1.7 1.7 0 00-1.1-1.5 1.7 1.7 0 00-1.8.3l-.1.1a2 2 0 11-2.8-2.8l.1-.1a1.7 1.7 0 00.3-1.8 1.7 1.7 0 00-1.5-1H3a2 2 0 110-4h.1a1.7 1.7 0 001.5-1.1 1.7 1.7 0 00-.3-1.8l-.1-.1a2 2 0 112.8-2.8l.1.1a1.7 1.7 0 001.8.3H9a1.7 1.7 0 001-1.5V3a2 2 0 114 0v.1a1.7 1.7 0 001 1.5 1.7 1.7 0 001.8-.3l.1-.1a2 2 0 112.8 2.8l-.1.1a1.7 1.7 0 00-.3 1.8V9a1.7 1.7 0 001.5 1H21a2 2 0 110 4h-.1a1.7 1.7 0 00-1.5 1z`})]})}function KJ({tabs:e,activeId:t,onSelect:n}){let r=(0,m.useRef)(null),i=(0,m.useRef)({}),[a,o]=(0,m.useState)(346),s=e.map(e=>e.label).join(`|`),[c,l]=(0,m.useState)({}),u=(0,m.useRef)(t);(0,m.useEffect)(()=>{u.current!==t&&(u.current=t,t&&!window.matchMedia(`(prefers-reduced-motion: reduce)`).matches&&l(e=>({...e,[t]:(e[t]??0)+1})))},[t]),(0,m.useLayoutEffect)(()=>{let e=()=>{let e=r.current?[...r.current.querySelectorAll(`[role='tab']`)]:[],t=e.length?Math.ceil(e.reduce((e,t)=>e+t.offsetWidth,0)+(e.length-1)*2)+6:346;o(t)};e(),document.fonts?.ready.then(e)},[s]);function d(r){if(r.key===`ArrowDown`&&!r.altKey){EE()&&r.preventDefault();return}let a=r.key===`ArrowRight`?1:r.key===`ArrowLeft`?-1:0;if(!a||e.length===0)return;r.preventDefault();let o=r.target.closest(`[role='tab']`)?.id.replace(/^tab-/,``)??t,s=e[(Math.max(0,e.findIndex(e=>e.id===o))+a+e.length)%e.length];OE.active=!0,OE.to=s.id,window.setTimeout(()=>{OE.active=!1,OE.to=void 0},3e3),n(s.id),i.current[s.id]?.focus({preventScroll:!0})}let f={"--wT":`${a}px`,"--hT":`40px`};return{vars:f,ghost:(0,V.jsx)(UJ,{className:`cs-gt`,style:f}),bay:(0,V.jsx)(`div`,{className:`cs-tbwrap`,style:f,children:(0,V.jsx)(`div`,{className:`cs-tbx`,children:(0,V.jsx)(`div`,{className:`cs-tbo`,"data-none":t?void 0:``,children:(0,V.jsx)(`div`,{ref:r,role:`tablist`,"aria-label":`Lobby tabs`,onKeyDown:d,className:`cs-track`,children:e.map((e,n)=>(0,V.jsxs)(`a`,{ref:t=>{i.current[e.id]=t},role:`tab`,id:`tab-${e.id}`,href:`#/${e.id}`,"aria-selected":e.id===t,"aria-keyshortcuts":e.key,title:`${e.label} · ${e.key.replace(`+`,` `)}`,tabIndex:e.id===t||!t&&n===0?0:-1,className:`cs-tab`,style:{"--i":n},children:[(0,V.jsx)(`span`,{className:`cs-ti`,children:(0,V.jsx)(VJ,{id:e.id,play:c[e.id]??0,className:`size-[15px]`})}),(0,V.jsx)(`span`,{className:`cs-tl`,"data-t":e.label,children:e.label})]},e.id))})})})})}}function qJ({children:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(UJ,{className:`cs-gr`}),(0,V.jsx)(`div`,{className:Y(`cs-rbx`),children:e})]})}function JJ(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 YJ(e,t){let n=e?.sessionId,r={id:`here`,name:e?.sessionName?.trim()||e?.workspace?.name||`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:JJ(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}));i.sort((e,t)=>Number(e.state===`exited`)-Number(t.state===`exited`));let s=new Set([...a,...o.map(e=>e.sessionId)]),c=(t?.saved??[]).filter(e=>!e.archived&&!s.has(e.sessionId)).map(e=>({id:`saved:${e.sessionId}`,name:e.name,where:`saved`,state:`exited`,waiting:0,sessionId:e.sessionId,at:e.at}));return[r,...i,...o,...c]}var XJ=`app.sidebar.pinned`,ZJ=()=>ZR(XJ),QJ={w:244,h:`min(600px, calc(100vh - 40px))`},$J=`cs-iconbtn cs-sm`;function eY({label:e,hint:t,side:n=`bottom`,children:r}){return(0,V.jsxs)(SI,{children:[(0,V.jsx)(CI,{asChild:!0,children:r}),(0,V.jsxs)(wI,{side:n,children:[e,` `,t?(0,V.jsx)(IT,{chord:t}):null]})]})}function tY(){let e=vE(`status`).data;return YJ(e,eR(`sessions.list`,{},[`sessions`]).data)}async function nY(e){if(e.where===`here`)return iE(`#/lobby`);if(e.where===`elsewhere`)return void H.info(`${e.name} runs in another terminal. Switch to that terminal to work in it.`);await U(`sessions.switch`,e.key?{key:e.key}:{sessionId:e.sessionId})&&iE(`#/lobby`)}function rY(){return(0,m.useCallback)(nY,[])}var iY={entries:[]};async function aY(e){let t=iY.entries.filter(e=>e.where!==`elsewhere`),n=t.findIndex(e=>e.where===`here`);if(t.length<2||n<0)return void H.info(`No other session to switch to.`);iY.flash?.(),await nY(t[(n+e+t.length)%t.length])}function oY({entry:e}){return e.where!==`elsewhere`&&e.state===`asking`?(0,V.jsxs)(`span`,{className:`cs-badge`,children:[(0,V.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,V.jsx)(`path`,{d:`M9.1 9a3 3 0 015.8 1c0 2-3 2.5-3 4M12 17h.01`})]}),e.waiting,(0,V.jsxs)(`span`,{className:`sr-only`,children:[e.waiting===1?` question`:` questions`,`, Waiting`]})]}):e.where!==`elsewhere`&&(e.state===`working`||e.state===`starting`)?(0,V.jsxs)(`span`,{className:Y(`inline-flex shrink-0`,e.state===`working`?`text-primary`:`text-muted-foreground`),children:[(0,V.jsx)(sp,{"aria-hidden":`true`,className:`session-spin size-3.5`}),(0,V.jsx)(`span`,{className:`sr-only`,children:e.state===`working`?`Working`:`Starting`})]}):(0,V.jsx)(`span`,{className:`sr-only`,children:e.where===`elsewhere`?`Other terminal`:e.state===`exited`?`Ended`:`Idle`})}var sY={here:`Current`,background:`Background`,elsewhere:`Other terminal`,saved:`Recent`};function cY(e){let t=e.key?{key:e.key}:{sessionId:e.sessionId};return U(`sessions.archive`,t,{undo:()=>void U(`sessions.archive`,{...t,archived:!1})})}function lY({entry:e,onDone:t}){let[n,r]=(0,m.useState)(e.name),i=(0,m.useRef)(!1),a=async()=>{if(i.current)return;i.current=!0;let r=n.replace(/\s+/g,` `).trim();r&&r!==e.name&&await U(`sessions.rename`,{...e.where===`here`?{}:{key:e.key},name:r}),t()};return(0,V.jsx)(`input`,{value:n,autoFocus:!0,maxLength:120,"aria-label":`New name for ${e.name}`,onFocus:e=>e.currentTarget.select(),onChange:e=>r(e.target.value),onBlur:()=>void a(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),a()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i.current=!0,t())},className:`h-6 w-full min-w-0 rounded-md bg-[var(--fill)] px-1.5 text-[13px] text-foreground outline-none ring-2 ring-ring`})}function uY({entry:e,index:t}){let n=rY(),[r,i]=(0,m.useState)(!1),a=e.state===`exited`||e.where===`elsewhere`,o=e.where===`here`||e.where===`background`,s=e.where===`background`&&e.state===`exited`&&!!e.key||e.where===`saved`,c=e.where===`saved`,l=o||s||c,u={"--i":t};return(0,V.jsxs)(`li`,{className:`cs-srow session-item`,children:[r?(0,V.jsx)(`div`,{className:`cs-sr`,"data-active":e.where===`here`||void 0,style:u,children:(0,V.jsx)(lY,{entry:e,onDone:()=>i(!1)})}):(0,V.jsxs)(`button`,{type:`button`,"aria-current":e.where===`here`?`true`:void 0,"aria-label":e.where===`here`?`${e.name}, this window`:e.where===`elsewhere`?`${e.name}, in another terminal`:`Switch to ${e.name}`,title:e.name,"data-where":e.where,"data-state":e.state,"data-dim":a||void 0,onClick:()=>void n(e),onDoubleClick:e=>{o&&(e.preventDefault(),i(!0))},className:`cs-sr session-row`,style:u,children:[(0,V.jsx)(`span`,{className:`cs-grow`,children:e.name}),(0,V.jsx)(`span`,{className:Y(`flex shrink-0 items-center`,l&&`cs-sstate`),children:(0,V.jsx)(oY,{entry:e})})]}),!r&&l?(0,V.jsxs)(`span`,{className:`cs-sacts`,children:[o?(0,V.jsx)(eY,{label:`Rename`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Rename ${e.name}`,onClick:()=>i(!0),className:`cs-sact`,children:(0,V.jsx)(ym,{"aria-hidden":`true`,className:`size-3.5`})})}):null,s?(0,V.jsx)(eY,{label:`Archive`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Archive ${e.name}`,onClick:()=>void cY(e),className:`cs-sact`,children:(0,V.jsx)(Af,{"aria-hidden":`true`,className:`size-3.5`})})}):null,c?(0,V.jsx)(qL,{iconOnly:!0,className:`cs-sact`,side:`bottom`,label:`Delete ${e.name}`,icon:rh,variant:`destructive`,title:`Delete ${e.name}?`,description:`Its conversation file is removed for good. Archive it instead to keep it.`,confirmLabel:`Delete`,onConfirm:()=>void U(`sessions.delete`,{sessionId:e.sessionId})}):null]}):null]})}function dY({id:e,label:t,entries:n,start:r,archivable:i=!1}){let[a,o]=QR(`app.sidebar.${e}`),s=(0,m.useId)();return n.length===0?null:(0,V.jsxs)(`section`,{"aria-label":t,className:`group/shelf flex flex-col`,children:[(0,V.jsxs)(`div`,{className:`cs-sh`,style:{"--i":r},children:[(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":!a,"aria-controls":s,onClick:o,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left outline-none hover:text-foreground focus-visible:underline`,children:[(0,V.jsx)(`span`,{children:t}),a?(0,V.jsx)(`span`,{className:`tabular-nums`,children:n.length}):null,(0,V.jsx)(Yf,{"aria-hidden":`true`,className:Y(`size-3 opacity-0 transition-[opacity,rotate] duration-150 group-hover/shelf:opacity-100 group-focus-within/shelf:opacity-100`,a&&`-rotate-90 opacity-100`)})]}),i?(0,V.jsx)(`button`,{type:`button`,onClick:()=>void(async()=>{for(let e of n)await U(`sessions.archive`,e.key?{key:e.key}:{sessionId:e.sessionId})})(),className:`shrink-0 outline-none hover:text-foreground focus-visible:underline`,children:`Archive all`}):null]}),a?null:(0,V.jsx)(`ul`,{id:s,className:`flex flex-col`,children:n.map((e,t)=>(0,V.jsx)(uY,{entry:e,index:r+1+t},e.id))})]})}function fY(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean),r=`${e.name} ${sY[e.where]}`.toLowerCase();return n.every(e=>r.includes(e))}function pY({query:e,onQuery:t,onNew:n}){return(0,V.jsxs)(`label`,{className:`cs-sr cs-search`,style:{"--i":0},children:[(0,V.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,V.jsx)(`path`,{d:`M21 21l-4.3-4.3`})]}),(0,V.jsx)(`input`,{type:`search`,value:e,"aria-label":`Search sessions`,placeholder:`Search`,onChange:e=>t(e.target.value),onKeyDown:n=>{n.key===`Escape`&&e&&(n.preventDefault(),n.stopPropagation(),t(``))}}),(0,V.jsx)(eY,{label:`New session`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`New session`,"aria-haspopup":`dialog`,onClick:n,className:`flex text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground`,children:(0,V.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M12 20h9`}),(0,V.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`})]})})})]})}function mY({query:e}){let t=tY(),n=t.filter(t=>fY(t,e)),r=n.filter(e=>e.where===`here`&&e.state!==`exited`),i=n.filter(e=>e.where===`background`&&e.state!==`exited`),a=n.filter(e=>e.where===`elsewhere`),o=n.filter(e=>e.where!==`elsewhere`&&e.state===`exited`),s=1,c=e=>{let t=s;return s+=e+1,t},l=c(r.length),u=c(i.length);return(0,V.jsxs)(`nav`,{"aria-label":`Sessions list`,className:`cs-sblist`,children:[n.length===0?(0,V.jsxs)(`p`,{className:`px-2.5 py-1.5 text-xs text-muted-foreground`,children:[`No sessions match “`,e.trim(),`”.`]}):null,r.length>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`cs-sh`,style:{"--i":l},children:`Current`}),(0,V.jsx)(`ul`,{className:`flex flex-col`,children:r.map((e,t)=>(0,V.jsx)(uY,{entry:e,index:l+1+t},e.id))})]}):null,i.length>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`cs-sh`,style:{"--i":u},children:`Background`}),(0,V.jsx)(`ul`,{className:`flex flex-col`,children:i.map((e,t)=>(0,V.jsx)(uY,{entry:e,index:u+1+t},e.id))})]}):!e.trim()&&t.length===1?(0,V.jsx)(`p`,{className:`cs-sh`,style:{"--i":u},children:`No other sessions are running.`}):null,(0,V.jsx)(dY,{id:`elsewhere`,label:`Other terminals`,entries:a,start:c(a.length)}),(0,V.jsx)(dY,{id:`ended`,label:`Recent`,entries:o,start:c(o.length),archivable:!0})]})}function hY({route:e,keys:t,onHelp:n}){let r=t.settings??`Alt+S`;return(0,V.jsxs)(`div`,{className:`cs-sbfoot`,children:[(0,V.jsxs)(`a`,{href:`#/settings`,"aria-label":`Settings`,"aria-current":e.kind===`settings`?`page`:void 0,"aria-keyshortcuts":r,className:`cs-sr`,style:{"--i":20},children:[(0,V.jsx)(GJ,{id:`settings`}),(0,V.jsx)(`span`,{className:`cs-grow`,children:`Settings`}),(0,V.jsx)(IT,{chord:r})]}),(0,V.jsxs)(`div`,{className:`cs-sr cs-tools`,style:{"--i":21},children:[(0,V.jsx)(NK,{hint:t.help??`Alt+H`,onHelp:n,className:$J}),(0,V.jsx)(PK,{className:$J}),(0,V.jsx)(IK,{className:$J}),(0,V.jsx)(LK,{className:$J})]})]})}function gY(e){let[t,n]=QR(XJ),r=WJ(160,1600);iY.entries=tY(),iY.flash=r.flash;let[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),c=t||r.open||o,l={"--wL":`${c?QJ.w:122}px`,"--hL":c?QJ.h:`40px`,"--sb-open-h":QJ.h},u=(0,m.useCallback)(()=>s(!0),[]);return{open:c,pinned:t,ghost:(0,V.jsx)(UJ,{className:`cs-gl`,style:l}),bay:(0,V.jsxs)(`div`,{className:`cs-sbwrap`,style:l,...r.handlers,children:[(0,V.jsxs)(`aside`,{id:`app-sidebar`,"aria-label":`Sidebar`,className:`cs-sbx`,children:[(0,V.jsxs)(`div`,{className:`cs-sbmini`,inert:c,children:[(0,V.jsx)(eY,{label:t?`Unpin sidebar`:`Pin sidebar`,hint:e.keys.sidebar,side:`bottom`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Sessions`,"aria-pressed":t,"aria-keyshortcuts":e.keys.sidebar,onClick:n,className:`cs-iconbtn`,children:(0,V.jsx)(GJ,{id:`lobby`})})}),(0,V.jsx)(eY,{label:`New session`,side:`bottom`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`New session`,"aria-haspopup":`dialog`,onClick:u,className:`cs-iconbtn`,children:(0,V.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M12 20h9`}),(0,V.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`})]})})}),(0,V.jsx)(eY,{label:`Settings`,hint:e.keys.settings??`Alt+S`,side:`bottom`,children:(0,V.jsx)(`a`,{href:`#/settings`,"aria-label":`Settings`,"aria-current":e.route.kind===`settings`?`page`:void 0,className:`cs-iconbtn`,children:(0,V.jsx)(GJ,{id:`settings`})})})]}),(0,V.jsxs)(`div`,{className:`cs-sbfull`,inert:!c,children:[(0,V.jsx)(pY,{query:i,onQuery:a,onNew:u}),(0,V.jsx)(mY,{query:i}),(0,V.jsx)(hY,{...e})]})]}),(0,V.jsx)(OJ,{open:o,onOpenChange:s})]})}}var _Y=`bot-lobby.terminal.open`,vY=`bot-lobby.terminal.height`,yY=`bot-lobby.terminal.popup`,bY={start:280,min:140},xY=new Set,SY,CY,wY;function TY(e){try{return localStorage.getItem(e)}catch{return null}}function EY(e,t){try{localStorage.setItem(e,t)}catch{}}function DY(){for(let e of[...xY])e()}function OY(e){return xY.add(e),()=>{xY.delete(e)}}function kY(){return SY??=TY(_Y)===`1`,SY}function AY(){if(CY===void 0){let e=Number(TY(vY));CY=e>=bY.min?e:bY.start}return CY}function jY(e){SY=e,EY(_Y,e?`1`:`0`),DY()}function MY(){jY(!kY())}function NY(e){CY=Math.max(bY.min,Math.round(e)),EY(vY,String(CY)),DY()}function PY(){return(0,m.useSyncExternalStore)(OY,kY,()=>!1)}function FY(){return(0,m.useSyncExternalStore)(OY,AY,()=>bY.start)}function IY(){return wY??=TY(yY)===`1`,wY}function LY(e){wY=e,EY(yY,e?`1`:`0`),DY()}function RY(){return(0,m.useSyncExternalStore)(OY,IY,()=>!1)}var zY=`modulepreload`,BY=function(e){return`/`+e},VY={},HY=function(e){return e.pathname.endsWith(`.css`)},UY=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=BY(t,n);let r=s(t);if(r.href in VY)return;VY[r.href]=!0;let i=HY(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:zY,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)})},WY=(0,m.lazy)(()=>UY(()=>import(`./TerminalView-CRwPTCho.js`),__vite__mapDeps([0,1,2,3]))),GY=`inline-flex size-6 items-center justify-center text-foreground/80 outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40 aria-pressed:bg-accent aria-pressed:text-foreground`;function KY({label:e,hint:t,children:n}){return(0,V.jsxs)(SI,{children:[(0,V.jsx)(CI,{asChild:!0,children:n}),(0,V.jsxs)(wI,{side:`top`,children:[e,` `,t?(0,V.jsx)(IT,{chord:t}):null]})]})}function qY({hint:e,className:t}){let n=PY();return(0,V.jsx)(KY,{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:MY,className:t,children:(0,V.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M4 17l6-6-6-6M12 19h8`})})})})}function JY(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 YY({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":bY.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&&NY(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:()=>NY(bY.start),onKeyDown:n=>{(n.key===`ArrowUp`||n.key===`ArrowDown`)&&(n.preventDefault(),NY(Math.min(t,e+(n.key===`ArrowUp`?24:-24))))}})}function XY({toggleKey:e}){let t=PY(),n=RY(),r=FY(),i=qT(t&&n,KT.sheet),{list:a,error:o,reload:s}=JY(t),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(()=>Math.round(window.innerHeight*.7)),h=a?.terminals??[],g=h.find(e=>e.id===c)??h.at(-1);(0,m.useEffect)(()=>{let e=()=>p(Math.round(window.innerHeight*.7));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let _=(0,m.useCallback)(async()=>{d(!0);try{let e=await L(`terminal.open`,{cols:100,rows:24});l(e.id),await s()}catch(e){H.error(e instanceof Error?e.message:`The terminal did not start.`)}finally{d(!1)}},[s]),v=(0,m.useCallback)(async e=>{try{await L(`terminal.close`,{id:e})}catch{}await s()},[s]);(0,m.useEffect)(()=>{if(!t||h.length<2)return;let e=e=>{if(!e.ctrlKey||e.altKey||e.metaKey||e.key!==`PageDown`&&e.key!==`PageUp`)return;e.preventDefault();let t=Math.max(0,h.findIndex(e=>e.id===g?.id)),n=h[(t+(e.key===`PageDown`?1:-1)+h.length)%h.length];l(n.id)};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[t,h,g?.id]);let y=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!t){y.current=!1;return}!a||!a.available||a.terminals.length>0||y.current||u||(y.current=!0,_())},[t,a,u,_]);let b=t&&!n?Math.min(r,f):0;if((0,m.useEffect)(()=>{let e=document.documentElement;return b?e.style.setProperty(`--terminal-h`,`${b}px`):e.style.removeProperty(`--terminal-h`),()=>{e.style.removeProperty(`--terminal-h`)}},[b]),!t)return null;let x=(0,V.jsx)(ZY,{list:a,error:o,terminals:h,shown:g,busy:u,popup:n,toggleKey:e,onPick:l,onStart:()=>void _(),onEnd:e=>void v(e),onReload:()=>void s()});return n?(0,V.jsx)(zT,{open:i,onOpenChange:e=>{e||jY(!1)},label:`Terminal`,className:`terminal-pop h-[min(72svh,40rem)] max-h-none max-w-5xl`,onEscapeKeyDown:e=>{e.target?.closest?.(`.xterm`)&&e.preventDefault()},children:(0,V.jsx)(`div`,{id:`terminal-drawer`,className:`flex min-h-0 flex-1`,children:x})}):(0,V.jsxs)(`section`,{id:`terminal-drawer`,"aria-label":`Terminal`,className:`terminal-drawer relative flex shrink-0 border-t border-border`,style:{height:Math.min(r,f)},children:[(0,V.jsx)(YY,{height:Math.min(r,f),max:f}),x]})}function ZY({list:e,error:t,terminals:n,shown:r,busy:i,popup:a,toggleKey:o,onPick:s,onStart:c,onEnd:l,onReload:u}){let d=(0,V.jsxs)(`div`,{className:`terminal-tools pointer-events-auto inline-flex items-center overflow-hidden rounded-md border border-border/80 bg-background shadow-xs`,children:[(0,V.jsx)(KY,{label:`New terminal`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`New terminal`,disabled:i||e?.available===!1,onClick:c,className:GY,children:(0,V.jsx)(Dm,{"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)(KY,{label:`End this terminal`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`End this terminal`,disabled:!r,onClick:()=>r&&l(r.id),className:GY,children:(0,V.jsx)(rh,{"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)(KY,{label:a?`Back to the drawer`:`Open in a pop-up`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Pop out terminal`,"aria-pressed":a,onClick:()=>LY(!a),className:GY,children:(0,V.jsx)(xm,{"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)(KY,{label:`Hide terminal`,hint:o,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Hide terminal`,onClick:()=>jY(!1),className:GY,children:a?(0,V.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5`}):(0,V.jsx)(Yf,{"aria-hidden":`true`,className:`size-3.5`})})})]}),f=(0,V.jsx)(V.Fragment,{children:e&&!e.available?(0,V.jsx)(`p`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:e.reason}):t?(0,V.jsx)(`p`,{role:`alert`,className:`flex h-full items-center justify-center px-6 text-center text-sm text-destructive`,children:t}):(0,V.jsxs)(m.Suspense,{fallback:(0,V.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`Loading the terminal…`}),children:[e&&n.length===0&&!i?(0,V.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`No terminal is running. Start one with New terminal.`}):null,n.map(e=>(0,V.jsx)(WY,{id:e.id,active:e.id===r?.id,toggleKey:o,onExit:u},e.id))]})}),p=n.length>1?(0,V.jsx)(`nav`,{"aria-label":`Terminals`,className:Y(`flex w-36 shrink-0 flex-col gap-0.5 overflow-y-auto border-l border-border px-1 pb-1`,a?`pt-2`:`pt-10`),children:n.map(e=>(0,V.jsxs)(`button`,{type:`button`,"aria-current":e.id===r?.id?`true`:void 0,onClick:()=>s(e.id),className:Y(`flex h-6 min-w-0 items-center gap-1.5 rounded px-1.5 text-left text-xs text-muted-foreground outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-accent aria-[current=true]:text-foreground`,!e.alive&&`opacity-60`),children:[(0,V.jsx)(Zm,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.title}),e.alive?null:(0,V.jsx)(`span`,{className:`sr-only`,children:`, ended`})]},e.id))}):null;return a?(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,V.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border/70 pr-2 pl-4`,children:[(0,V.jsx)(Zm,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`flex-1 text-sm font-medium`,children:`Terminal`}),d]}),(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,V.jsx)(`div`,{className:`min-w-0 flex-1 py-2 pl-2`,children:(0,V.jsx)(`div`,{className:`relative h-full`,children:f})}),p]})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[f,(0,V.jsx)(`div`,{className:`pointer-events-none absolute top-2 right-2 z-20`,children:d})]}),p]})}var QY=(0,m.lazy)(()=>UY(()=>import(`./CodeSurface-DZdLN-w3.js`),__vite__mapDeps([4,1,2]))),$Y=`inline-flex size-7 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40 aria-pressed:bg-accent aria-pressed:text-foreground`;function eX({label:e,hint:t,children:n}){return(0,V.jsxs)(SI,{children:[(0,V.jsx)(CI,{asChild:!0,children:n}),(0,V.jsxs)(wI,{side:`bottom`,children:[e,` `,t?(0,V.jsx)(IT,{chord:t}):null]})]})}function tX({hint:e,className:t}){let{open:n}=dL();return(0,V.jsx)(eX,{label:`Code and changes`,hint:e,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Code`,"aria-pressed":n,"aria-keyshortcuts":e,onClick:()=>n?lL():cL(),className:t,children:(0,V.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M16 18l6-6-6-6M8 6l-6 6 6 6`})})})})}var nX={modified:{letter:`M`,word:`Modified`,tone:`text-warning`},added:{letter:`A`,word:`Added`,tone:`text-success`},untracked:{letter:`U`,word:`New, not committed`,tone:`text-success`},deleted:{letter:`D`,word:`Deleted`,tone:`text-destructive`},renamed:{letter:`R`,word:`Renamed`,tone:`text-primary`}};function rX(e){let t=e.lastIndexOf(`/`);return t<0?{dir:``,name:e}:{dir:e.slice(0,t),name:e.slice(t+1)}}function iX({change:e,className:t}){return e.additions===void 0&&e.deletions===void 0?null:(0,V.jsxs)(`span`,{className:Y(`shrink-0 font-mono text-[0.6875rem] tabular-nums`,t),children:[(0,V.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions??0]}),` `,(0,V.jsxs)(`span`,{className:`text-destructive`,children:[`−`,e.deletions??0]})]})}function aX(){let[e,t]=(0,m.useState)(()=>document.documentElement.classList.contains(`dark`));return(0,m.useEffect)(()=>{let e=document.documentElement,n=new MutationObserver(()=>t(e.classList.contains(`dark`)));return n.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>n.disconnect()},[]),e}function oX({changes:e,loading:t,error:n,current:r,onPick:i,onRefresh:a}){let[o,s]=(0,m.useState)(``),c=e?.files??[],l=c.reduce((e,t)=>({additions:e.additions+(t.additions??0),deletions:e.deletions+(t.deletions??0)}),{additions:0,deletions:0});function u(e){e.preventDefault();let t=o.trim();t&&(i(t),s(``))}return(0,V.jsxs)(`nav`,{"aria-label":`Changed files`,className:`code-rail flex w-64 shrink-0 flex-col border-r border-border max-md:w-52`,children:[(0,V.jsx)(`form`,{onSubmit:u,className:`border-b border-border p-2`,children:(0,V.jsxs)(`label`,{className:`flex h-8 items-center gap-2 rounded-md border border-input bg-background px-2 transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/20`,children:[(0,V.jsx)(Vm,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),"aria-label":`Open a file by path`,placeholder:`Open a file by path…`,spellCheck:!1,autoComplete:`off`,className:`h-full min-w-0 flex-1 bg-transparent font-mono text-xs outline-none placeholder:font-sans placeholder:text-muted-foreground`})]})}),(0,V.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 px-3 text-xs`,children:[(0,V.jsx)(`span`,{className:`font-medium text-foreground`,children:`Changes`}),(0,V.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[c.length,e?.truncated?`+`:``]}),(0,V.jsx)(iX,{change:l,className:`ml-auto`}),(0,V.jsx)(eX,{label:`Read the changes again`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Refresh changes`,onClick:a,disabled:t,className:Y($Y,`-mr-1.5 size-6`,c.length?``:`ml-auto`),children:(0,V.jsx)(km,{"aria-hidden":`true`,className:Y(`size-3.5`,t&&`animate-spin motion-reduce:animate-none`)})})})]}),(0,V.jsxs)(`ul`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-1.5 pb-2`,children:[c.map(e=>{let{dir:t,name:n}=rX(e.path),a=nX[e.status];return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,onClick:()=>i(e.path),"aria-current":e.path===r?`true`:void 0,title:e.from?`${e.from} → ${e.path}`:e.path,className:`group/row flex h-7 w-full min-w-0 items-center gap-2 rounded-md px-1.5 text-left text-[0.8125rem] outline-none transition-colors duration-150 hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-accent`,children:[(0,V.jsx)(`span`,{"aria-label":a.word,className:Y(`w-3 shrink-0 text-center font-mono text-[0.6875rem] font-semibold`,a.tone),children:a.letter}),(0,V.jsxs)(`span`,{className:Y(`min-w-0 flex-1 truncate`,e.status===`deleted`&&`text-muted-foreground line-through decoration-muted-foreground/50`),children:[n,t?(0,V.jsx)(`span`,{className:`ml-1.5 text-xs text-muted-foreground`,children:t}):null]}),(0,V.jsx)(iX,{change:e})]})},e.path)}),e&&!e.git?(0,V.jsx)(`li`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:`This folder is not a git repository, so there are no changes to show. Open a file by its path above.`}):null,e?.git&&c.length===0?(0,V.jsx)(`li`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:`No changes since the last commit.`}):null,n?(0,V.jsx)(`li`,{role:`alert`,className:`px-2 py-3 text-xs text-destructive`,children:n}):null]})]})}function sX(e){let[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(!1),s=(0,m.useRef)(0),c=(0,m.useCallback)(async e=>{let t=++s.current;o(!0),i(void 0);try{let r=await L(`code.read`,{path:e});t===s.current&&n(e=>({file:r,version:(e?.version??0)+1}))}catch(e){t===s.current&&(n(void 0),i(e instanceof Error?e.message:String(e)))}finally{t===s.current&&o(!1)}},[]);return(0,m.useEffect)(()=>{e?c(e):(s.current++,n(void 0),i(void 0))},[e,c]),{loaded:t,setLoaded:n,error:r,loading:a,reload:()=>e&&c(e)}}function cX({requested:e,requestedMode:t,request:n,codeKey:r,onClose:i,onDirtyChange:a,closeAsked:o}){let s=eR(`code.changes`,{},[`lobby`,`tasks`]),[c,l]=(0,m.useState)(e),[u,d]=(0,m.useState)(t??`code`),{loaded:f,setLoaded:p,error:h,loading:g,reload:_}=sX(c),[v,y]=(0,m.useState)(),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(),E=vL(),D=yL(),O=aX(),k=f?.file,ee=v!==void 0&&v!==k?.contents;(0,m.useEffect)(()=>a(ee),[ee,a]),(0,m.useEffect)(()=>{if(!e||e===c){t&&d(t);return}j({kind:`open`,path:e})},[n]),(0,m.useEffect)(()=>{if(!c&&s.data?.files[0]){let e=s.data.files.find(e=>e.status!==`deleted`)??s.data.files[0];l(e.path),t||d(`diff`)}},[s.data]),(0,m.useEffect)(()=>{k&&k.path!==c&&l(k.path)},[k?.path]),(0,m.useEffect)(()=>{o&&j({kind:`close`})},[o]);function A(e){if(T(void 0),C(!1),e.kind===`close`){i();return}y(void 0),l(e.path)}function j(e){(e.kind!==`open`||e.path!==c)&&(ee?T(e):A(e))}async function M(e=!1){if(k&&v!==void 0&&!b){x(!0);try{let t=await L(`code.save`,{path:k.path,contents:v,mtimeMs:k.mtimeMs,...e?{force:!0}:{}});return p(e=>e&&{...e,file:{...e.file,contents:v,mtimeMs:t.mtimeMs,size:v.length}}),y(void 0),C(!1),s.reload(),w&&A(w),!0}catch(e){return e instanceof xe&&e.code===`conflict`?C(!0):H.error(e instanceof Error?e.message:`The file could not be saved.`),!1}finally{x(!1)}}}function te(e){(e.ctrlKey||e.metaKey)&&!e.altKey&&e.key.toLowerCase()===`s`?(e.preventDefault(),e.stopPropagation(),M()):r&&pK(e.nativeEvent,r)&&(e.preventDefault(),j({kind:`close`}))}let ne=k?.change,N=!!ne||k?.original!==void 0,re=N?u:`code`,{dir:ie,name:ae}=rX(k?.path??c??``),oe=!!(k?.exists&&k.contents!==void 0),se=ne?nX[ne.status]:void 0;return(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1`,onKeyDown:te,children:[(0,V.jsx)(oX,{changes:s.data,loading:s.loading,error:s.error,current:k?.path??c,onPick:e=>j({kind:`open`,path:e}),onRefresh:()=>{s.reload(),ee||_()}}),(0,V.jsxs)(`section`,{"aria-label":`File`,className:`flex min-w-0 flex-1 flex-col`,children:[(0,V.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border pr-2 pl-3`,children:[c?(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[se?(0,V.jsx)(`span`,{title:se.word,className:Y(`font-mono text-xs font-semibold`,se.tone),children:se.letter}):(0,V.jsx)(Tp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,V.jsxs)(`h2`,{className:`min-w-0 truncate text-[0.8125rem]`,title:k?.path??c,children:[ie?(0,V.jsxs)(`span`,{className:`text-muted-foreground`,children:[ie,`/`]}):null,(0,V.jsx)(`span`,{className:`font-medium text-foreground`,children:ae}),ee?(0,V.jsx)(`span`,{"aria-label":`unsaved`,title:`Unsaved edits`,className:`ml-1.5 inline-block size-1.5 -translate-y-0.5 rounded-full bg-foreground/70`}):null]}),ne?(0,V.jsx)(iX,{change:ne}):null]}):(0,V.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-muted-foreground`,children:`Code`}),N?(0,V.jsx)(hE,{label:`View`,value:re,onChange:d,items:[{id:`code`,label:`Code`},{id:`diff`,label:`Diff`}]}):null,re===`diff`?(0,V.jsx)(eX,{label:D===`split`?`Unified diff`:`Side by side`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Side by side`,"aria-pressed":D===`split`,onClick:()=>_L(D===`split`?`unified`:`split`),className:$Y,children:D===`split`?(0,V.jsx)(Lm,{"aria-hidden":`true`,className:`size-4`}):(0,V.jsx)(_p,{"aria-hidden":`true`,className:`size-4`})})}):null,(0,V.jsx)(eX,{label:E?`Do not wrap lines`:`Wrap long lines`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Wrap lines`,"aria-pressed":E,onClick:()=>gL(!E),className:$Y,children:(0,V.jsx)(th,{"aria-hidden":`true`,className:`size-4`})})}),(0,V.jsx)(eX,{label:`Save`,hint:`Ctrl+S`,children:(0,V.jsxs)(OT,{size:`sm`,variant:ee?`default`:`outline`,disabled:!ee||b,onClick:()=>void M(),"aria-keyshortcuts":`Control+S Meta+S`,children:[(0,V.jsx)(zm,{"aria-hidden":`true`}),b?`Saving…`:`Save`]})}),(0,V.jsx)(eX,{label:`Close`,hint:r,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Close code viewer`,onClick:()=>j({kind:`close`}),className:$Y,children:(0,V.jsx)(yh,{"aria-hidden":`true`,className:`size-4`})})})]}),w?(0,V.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-muted/40 px-3 py-2 text-xs`,children:[(0,V.jsx)(_m,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[ae,` has unsaved edits.`]}),(0,V.jsx)(OT,{size:`xs`,variant:`ghost`,onClick:()=>T(void 0),children:`Keep editing`}),(0,V.jsx)(OT,{size:`xs`,variant:`outline`,onClick:()=>A(w),children:`Discard`}),(0,V.jsx)(OT,{size:`xs`,onClick:()=>void M(),disabled:b,children:`Save`})]}):null,S?(0,V.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-muted/40 px-3 py-2 text-xs`,children:[(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[ae,` changed on disk since you opened it, maybe by an agent.`]}),(0,V.jsx)(OT,{size:`xs`,variant:`outline`,onClick:()=>{y(void 0),C(!1),_()},children:`Load theirs`}),(0,V.jsx)(OT,{size:`xs`,onClick:()=>void M(!0),disabled:b,children:`Overwrite with mine`})]}):null,(0,V.jsx)(`div`,{className:`code-pane relative flex min-h-0 flex-1 flex-col`,children:h?(0,V.jsx)(`p`,{role:`alert`,className:`m-auto max-w-sm px-6 text-center text-sm text-muted-foreground`,children:h}):c?k?k.binary||k.tooLarge?(0,V.jsx)(`p`,{className:`m-auto max-w-sm px-6 text-center text-sm text-muted-foreground`,children:k.binary?`This is a binary file, so it is not shown.`:`This file is too large to show here.`}):!k.exists&&re===`code`?(0,V.jsxs)(`p`,{className:`m-auto flex max-w-sm flex-col items-center gap-2 px-6 text-center text-sm text-muted-foreground`,children:[(0,V.jsx)(Np,{"aria-hidden":`true`,className:`size-5`}),`This file was deleted. Switch to Diff to see what it held.`]}):(0,V.jsx)(m.Suspense,{fallback:(0,V.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:`Loading code…`}),children:(0,V.jsx)(QY,{path:k.path,version:`${f.version}`,contents:k.contents??``,draft:v,original:k.original,mode:re,layout:D,wrap:E,dark:O,readOnly:!oe,onDraft:y})}):(0,V.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:g?`Opening…`:``}):(0,V.jsx)(lX,{loading:s.loading})})]})]})}function lX({loading:e}){return(0,V.jsxs)(`div`,{className:`m-auto flex max-w-xs flex-col items-center gap-2 px-6 text-center`,children:[(0,V.jsx)(Dp,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e?`Reading the changes…`:`Pick a changed file, open one by its path, or click a file name in the Lobby chat.`})]})}function uX({codeKey:e}){let{open:t,path:n,mode:r,request:i}=dL(),a=qT(t,KT.help),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(0),u=()=>l(e=>e+1);return(0,V.jsx)(zT,{open:a,onOpenChange:e=>{e||(o?u():lL())},label:`Code viewer`,className:`code-pop h-[min(86svh,52rem)] max-h-none max-w-6xl`,onEscapeKeyDown:e=>{o&&(e.preventDefault(),u())},children:t?(0,V.jsx)(cX,{requested:n,requestedMode:r,request:i,codeKey:e,onClose:lL,onDirtyChange:s,closeAsked:c}):null})}function dX(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 fX(){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(dX(e))}return(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-y-auto p-6`,children:(0,V.jsxs)(`form`,{onSubmit:s,className:`cs-dlg w-full max-w-[420px]`,children:[(0,V.jsxs)(`div`,{className:`cs-dh flex items-center gap-3.5 pt-[22px]`,children:[(0,V.jsx)(`span`,{className:`cs-drop`,"aria-hidden":`true`,children:(0,V.jsx)(Gp,{className:`size-[18px]`})}),(0,V.jsx)(`h1`,{children:`Sign in to bot-lobby`})]}),(0,V.jsxs)(`div`,{className:`cs-db`,children:[(0,V.jsxs)(`p`,{className:`mb-3.5 text-[12.5px] leading-relaxed text-muted-foreground`,children:[`Pi printed a link when it started (or run `,(0,V.jsx)(`code`,{className:`cs-cd`,children:`/bot-lobby web`}),` to see it again). Paste it here.`]}),(0,V.jsxs)(`label`,{children:[(0,V.jsx)(`span`,{children:`Lobby link or token`}),(0,V.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),autoComplete:`off`,spellCheck:!1,autoFocus:!0,placeholder:`http://127.0.0.1:7347/#token=…`,className:`cs-inp`})]}),n?(0,V.jsx)(`p`,{role:`alert`,className:`mt-2.5 text-[12.5px] text-[var(--bad)]`,children:n}):null]}),(0,V.jsxs)(`div`,{className:`cs-df`,children:[(0,V.jsx)(OT,{type:`button`,variant:`outline`,disabled:i,onClick:()=>void o(void 0),children:`Retry`}),(0,V.jsx)(OT,{type:`submit`,disabled:i||!e.trim(),children:`Sign in`})]})]})})}var pX=`plan:`,mX=`bot-lobby:plan-put-away`,hX=e=>e.startsWith(pX);function gX(){try{let e=JSON.parse(sessionStorage.getItem(mX)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`number`):[]}catch{return[]}}function _X(e){let t=e?.messages.at(-1);if(e&&!e.busy&&t?.role===`planner`&&t.questions?.length)return{id:`${pX}${t.at}`,kind:`questionnaire`,createdAt:t.at,from:`planner`,payload:{round:Math.max(e.round,1),limit:e.limit,questions:t.questions.map(e=>({question:e.text,header:e.from,options:e.options.map(e=>({label:e.label,description:e.description,...e.mockup?{htmlPreview:e.mockup}:{}}))}))}}}function vX(e,t){let n=e.payload.questions??[];return(t.answers??[]).map(e=>`${vR(n[e.questionIndex]?.header??``)}: ${e.question} ${e.answer}`.trim()).join(`
115
- `)}function yX(){let e=eR(`planner.get`,{},[`planner`]),[t,n]=(0,m.useState)(gX),r=_X(e.data),i=(0,m.useMemo)(()=>r&&!t.includes(r.createdAt)?[r]:[],[r?.id,t.join(`,`)]);return{prompts:i,answer:(0,m.useCallback)(async(t,n)=>{let r=i.find(e=>e.id===t);r&&(await L(`planner.send`,{text:vX(r,n)}),e.reload())},[i,e]),dismiss:(0,m.useCallback)(async e=>{let t=Number(e.slice(5));n(e=>{let n=[...e,t].slice(-20);try{sessionStorage.setItem(mX,JSON.stringify(n))}catch{}return n})},[])}}var bX=2;function xX(e){let t=globalThis.EventSource;if(!t)throw Error(`EventSource is not available in this environment`);return new t(e)}function SX(e){try{return JSON.parse(e)}catch{return}}function CX(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 wX(e,t=xX){let n=t(F(`/api/events`));return e.onConnection?.(`connecting`),n.onopen=()=>e.onConnection?.(`live`),n.onerror=()=>e.onConnection?.(n.readyState===bX?`offline`:`connecting`),n.onmessage=t=>{let n=SX(t.data);n&&CX(n,e)},()=>n.close()}var TX=2e3,EX=()=>L(`projects.list`,{});async function DX(){let e;try{e=pe()}catch{return}if(e&&!ye(e))try{ve((await EX()).projects)}catch{}}function OX(){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=wX({onHello:e=>{P.onHello(e),DX()},onChanged:(e,t)=>P.onChanged(e,t),onFeed:e=>P.onFeedDelta(e),onReply:e=>P.onReplyDelta(e),onNotice:(e,t)=>H[t](e),onConnection:e=>{P.onStatus({connection:e}),e===`offline`&&(clearTimeout(t.current),t.current=setTimeout(()=>{be(EX).catch(()=>!1).finally(n)},TX))}})},[]);return(0,m.useEffect)(()=>(n(),()=>{clearTimeout(t.current),e.current?.()}),[n]),n}var kX=`bot-lobby.recoveredAt`,AX;function jX(e,t=MX()){try{AX===void 0&&(AX=Number(t?.getItem(kX)??0))}catch{AX??=0}if(AX!==void 0&&e<=AX)return!1;AX=e;try{t?.setItem(kX,String(e))}catch{}return!0}function MX(){try{return globalThis.sessionStorage}catch{return}}function NX(e){let t=e?.recovered?.at,n=e?.recovered?.text;(0,m.useEffect)(()=>{t!==void 0&&n&&jX(t)&&H.success(n)},[t,n])}function PX(){let e=vE(`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}}var FX=class extends m.Component{state={};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`bot-lobby: a tab failed to draw`,e,t.componentStack)}render(){let{error:e}=this.state;return e?this.props.fallback?this.props.fallback(e,()=>this.setState({error:void 0})):(0,V.jsxs)(`div`,{role:`alert`,className:`cs-pg cs-blank`,children:[(0,V.jsx)(`h2`,{children:`This page hit a snag`}),(0,V.jsx)(`p`,{children:e.message||String(e)}),(0,V.jsx)(`p`,{children:(0,V.jsx)(`button`,{type:`button`,className:`cs-kc`,onClick:()=>this.setState({error:void 0}),children:`Try again`})})]}):this.props.children}};function IX(e,t,n,r,i){e===`search`?(document.querySelector(`#main input[type='search']`)??document.getElementById(`composer-text`))?.focus():e===`help`?n():e===`settings`?iE(`#/settings`):e===`thinking`?t.kind===`tab`&&t.tab===`lobby`?ZR(`lobby.thinking`):iE(rE(`lobby`)):e===`nextSession`||e===`prevSession`?aY(e===`nextSession`?1:-1):e===`sidebar`?i():e===`terminal`?MY():e===`code`?uL():e===`activity`?t.kind===`tab`&&t.tab===`lobby`?ZR($R):iE(rE(`lobby`)):e===`nextTab`?r(1):e===`prevTab`?r(-1):e===`savePlan`&&t.kind===`tab`&&t.tab===`plan`&&U(`planner.save`,{})}var LX=`cs-iconbtn cs-sq10`,RX=2500;function zX(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),RX);return()=>clearTimeout(t)},[e]),e===`offline`||e===`connecting`&&t}function BX({connection:e,onRetry:t}){return zX(e)?(0,V.jsx)(`div`,{className:`cs-outage`,children:(0,V.jsx)(lE,{onRetry:t})}):null}var VX={tick:0,route:0,focus:0};window.addEventListener(`hashchange`,()=>{VX.route=++VX.tick}),document.addEventListener(`focusin`,()=>{VX.focus=++VX.tick});var HX=()=>VX.focus>VX.route;function UX(e){return e.kind===`tab`?e.tab:e.kind}function WX(){let e=aE(),t=vE(`status`);vE(`lobby`);let{prompts:n,loading:r,answer:i,dismiss:a}=PX(),o=yX(),s=(0,m.useMemo)(()=>[...n,...o.prompts],[n,o.prompts]),c=eJ(s,(0,m.useCallback)((e,t)=>hX(e)?o.answer(e,t):i(e,t),[i,o.answer]),(0,m.useCallback)(e=>hX(e)?o.dismiss(e):a(e),[a,o.dismiss])),{connection:l,signedOut:u}=_E(),[d,f]=(0,m.useState)(!1),p=fJ();(0,m.useEffect)(()=>{s.length===0&&!r&&uJ(!1)},[s.length,r]);let h=(0,m.useRef)(null),g=OX();SB();let _=t.data;NX(_);let v=!!_&&!u;(0,m.useEffect)(()=>{v&&ze()},[v]);let y=_?.tabs??[],b=_?.keys??[],x=e.kind===`tab`?e.tab:void 0,S=(0,m.useCallback)(e=>iE(rE(e)),[]),C=(0,m.useCallback)(e=>{if(y.length===0)return;let t=Math.max(0,y.findIndex(e=>e.id===x)),n=y[(t+e+y.length)%y.length];n&&iE(rE(n.id))},[y,x]),w=(0,m.useCallback)(()=>f(e=>!e),[]),T=KK(),E=(0,m.useCallback)(()=>ZJ(),[]),D=(0,m.useCallback)(t=>{(t!==`thinking`&&t!==`activity`||_?.panels?.[t]!==!1)&&IX(t,nE(window.location.hash)??e,w,C,E)},[e,w,C,E,_?.panels]),O=S,k=(0,m.useCallback)(()=>{let e=document.activeElement;return!e||e===document.body||h.current?.contains(e)===!0||e.closest(`.terminal-pop`)?!0:e.closest(`[data-state='closed']`)!==null},[]);bK({enabled:!!_,keys:b,tabs:y,insideApp:k,onAction:D,onTab:O});let ee=(0,m.useCallback)(()=>P.onHello({}),[]),A=e.kind===`tab`?e.tab:e.kind,j=!!_;(0,m.useEffect)(()=>{if(!j)return;let e=OE.active&&OE.to===A;if(OE.active=!1,OE.to=void 0,e)return;let t=requestAnimationFrame(()=>{if(HX()||document.querySelector(`[role='dialog']:not([data-state='closed'])`))return;let e=document.getElementById(`composer-text`);!window.matchMedia(`(pointer: coarse)`).matches&&e&&!e.disabled&&!e.closest(`[inert]`)?e.focus({preventScroll:!0}):document.activeElement?.id!==`composer-text`&&document.getElementById(`main`)?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(t)},[A,j]);let M=Object.fromEntries(b.map(e=>[e.action,e.label])),te=KJ({tabs:y,activeId:x,onSelect:S}),ne=gY({route:e,keys:M,onHelp:w});return u||!_?(0,V.jsxs)(`div`,{ref:h,className:`cs-frame`,children:[(0,V.jsx)(HJ,{}),(0,V.jsx)(`main`,{id:`main`,tabIndex:-1,className:`cs-main`,children:u?(0,V.jsx)(fX,{}):t.error?(0,V.jsx)(cE,{message:t.error,onRetry:ee}):(0,V.jsx)(sE,{})}),(0,V.jsxs)(qJ,{children:[(0,V.jsx)(FK,{className:LX,side:`bottom`}),(0,V.jsx)(PK,{className:LX,side:`bottom`})]})]}):(0,V.jsxs)(`div`,{ref:h,className:`cs-frame`,"data-sb":ne.open?`open`:`closed`,"data-sbpin":ne.pinned||void 0,"data-tb":`open`,children:[(0,V.jsx)(HJ,{}),(0,V.jsxs)(`div`,{className:`cs-body`,children:[(0,V.jsx)(BX,{connection:l,onRetry:g}),(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||yE(e.target)||e.target.closest(`[role='dialog'], [role='menu'], [role='listbox']`)||DE()&&e.preventDefault()},role:x?`tabpanel`:void 0,"aria-labelledby":x?`tab-${x}`:void 0,className:`cs-main surface`,children:(0,V.jsx)(Yd.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.17,ease:[.22,1,.36,1]},className:`flex min-h-0 flex-1 flex-col`,children:(0,V.jsx)(FX,{children:sK(e)})},UX(e))}),(0,V.jsx)(FX,{fallback:(e,t)=>(0,V.jsxs)(`div`,{role:`alert`,className:`pointer-events-auto absolute inset-x-0 bottom-6 z-30 mx-auto w-fit rounded-xl bg-card px-4 py-2 text-sm shadow`,children:[`The message box hit a snag: `,e.message,` `,(0,V.jsx)(`button`,{type:`button`,className:`font-medium text-primary underline`,onClick:t,children:`Try again`})]}),children:(0,V.jsx)(DJ,{route:e,projects:T,drawer:c,drawerOpen:s.length>0&&!p})})]}),(0,V.jsx)(XY,{toggleKey:M.terminal??"Ctrl+`"})]}),ne.ghost,te.ghost,(0,V.jsxs)(qJ,{children:[(0,V.jsx)(tX,{hint:M.code,className:LX}),(0,V.jsx)(qY,{hint:M.terminal,className:LX})]}),ne.bay,te.bay,(0,V.jsx)(JK,{projects:T}),(0,V.jsx)(`span`,{id:`focused-action-help`,className:`sr-only`,children:`Focused buttons: Enter or Space. Links: Enter. Checkboxes: Space.`}),(0,V.jsx)(uX,{codeKey:b.find(e=>e.action===`code`)?.key}),(0,V.jsx)(JI,{}),(0,V.jsx)(jK,{open:d,onOpenChange:f,keys:b,tabs:y})]})}async function GX(e){switch(e){case`status`:return L(`status.get`,{});case`lobby`:return L(`lobby.snapshot`,{});case`prompts`:return L(`prompts.list`,{});default:return}}var KX=[`status`,`lobby`,`prompts`];function qX(){let[e,t]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{let e=!0;return(async()=>{await we(),e&&(P.markUsed(KX,GX),t(!0))})(),()=>{e=!1}},[]),e}function JX(){return qX()?(0,V.jsx)(WX,{}):(0,V.jsx)(`div`,{className:`fixed inset-0 flex`,children:(0,V.jsx)(sE,{})})}var YX={info:Up,success:ap,warning:ah,error:pp},XX={info:`Note:`,success:`Done:`,warning:`Warning:`,error:`Error:`},ZX={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-destructive`};function QX(){let{item:e,waiting:t}=ff(),n=YT(),r=e&&!n;return(0,m.useEffect)(()=>{if(!e||n)return;let r=window.setTimeout(()=>uf(e.id),t>0?Math.min(e.duration,1600):e.duration);return()=>window.clearTimeout(r)},[e,n,t]),(0,V.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`pointer-events-none fixed z-[1050] flex justify-center px-4`,style:{bottom:`calc(var(--composer-h, 0px) + var(--terminal-h, 0px) + 0.25rem)`,left:`var(--composer-x, 0px)`,width:`var(--composer-w, 100%)`},children:(0,V.jsx)(eu,{mode:`wait`,children:r?(0,V.jsxs)(Yd.div,{initial:{opacity:0,scale:.55,y:18},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.92,y:6,transition:{duration:.14,ease:`easeIn`}},transition:{type:`spring`,stiffness:560,damping:15,mass:.8},className:`pointer-events-auto flex max-w-[min(32rem,100%)] items-center gap-2.5 glass-toast rounded-lg px-3.5 py-2.5 text-sm`,children:[(0,V.jsx)($X,{kind:e.kind}),(0,V.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,V.jsxs)(`span`,{className:`sr-only`,children:[XX[e.kind],` `]}),e.message]}),e.action?(0,V.jsx)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,className:`btn-outline -my-1.5 -mr-1 h-7 shrink-0 rounded-lg border px-2.5 text-xs font-medium text-foreground transition-[box-shadow,scale] active:scale-[0.97] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,onClick:()=>{e.action?.onClick(),uf(e.id)},children:e.action.label}):null]},e.id):null})})}function $X({kind:e}){let t=YX[e];return(0,V.jsx)(t,{"aria-hidden":`true`,className:Y(`size-4 shrink-0`,ZX[e])})}var eZ=6,tZ=8,nZ=400;function rZ(e){return e.matches(`:disabled, [aria-disabled='true'], [aria-pressed='true'], [data-on='true'], [data-on=''], [aria-expanded='true']`)||!e.isConnected}function iZ(e){return e.classList.contains(`cs-tipl`)?`left`:e.classList.contains(`cs-b`)?`bottom`:`top`}function aZ(e,t,n,r){let i=window.innerWidth,a=window.innerHeight,o=r=>r===`top`?e.top-eZ-n>=tZ:r===`bottom`?e.bottom+eZ+n<=a-tZ:r===`left`?e.left-eZ-t>=tZ:e.right+eZ+t<=i-tZ,s={top:`bottom`,bottom:`top`,left:`right`,right:`left`},c=o(r)||!o(s[r])?r:s[r],l=(e,t,n)=>Math.min(Math.max(e,tZ),n-t-tZ);if(c===`top`||c===`bottom`)return{x:l(e.left+e.width/2-t/2,t,i),y:c===`top`?e.top-eZ-n:e.bottom+eZ,side:c};let u=l(e.top+e.height/2-n/2,n,a);return{x:c===`left`?e.left-eZ-t:e.right+eZ,y:u,side:c}}function oZ(){let[e,t]=(0,m.useState)(null),[n,r]=(0,m.useState)(null),i=(0,m.useRef)(null),a=(0,m.useRef)(null);return(0,m.useEffect)(()=>{let e=0,n=()=>{window.clearTimeout(e),a.current=null,t(null),r(null)},i=r=>{if(r.pointerType===`touch`)return;let i=r.target?.closest?.(`[data-tip]`);i!==a.current&&(n(),i&&i.dataset.tip&&(a.current=i,e=window.setTimeout(()=>{a.current===i&&!rZ(i)&&i.dataset.tip&&t({text:i.dataset.tip,el:i,side:iZ(i)})},nZ)))},o=e=>{let t=e.relatedTarget;a.current&&(!t||!a.current.contains(t))&&n()};return document.addEventListener(`pointerover`,i,!0),document.addEventListener(`pointerout`,o,!0),document.addEventListener(`pointerdown`,n,!0),document.addEventListener(`keydown`,n,!0),document.addEventListener(`scroll`,n,!0),window.addEventListener(`blur`,n),()=>{n(),document.removeEventListener(`pointerover`,i,!0),document.removeEventListener(`pointerout`,o,!0),document.removeEventListener(`pointerdown`,n,!0),document.removeEventListener(`keydown`,n,!0),document.removeEventListener(`scroll`,n,!0),window.removeEventListener(`blur`,n)}},[]),(0,m.useLayoutEffect)(()=>{let t=i.current;if(!e||!t)return;let n=t.getBoundingClientRect();r(aZ(e.el.getBoundingClientRect(),n.width,n.height,e.side))},[e]),e?(0,C_.createPortal)((0,V.jsx)(`div`,{ref:i,role:`tooltip`,className:`tipbox`,"data-side":n?.side??e.side,"data-ready":n?``:void 0,style:{position:`fixed`,left:n?.x??0,top:n?.y??0},children:e.text}),document.body):null}(0,tf.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(m.StrictMode,{children:(0,V.jsx)(tV,{children:(0,V.jsx)(su,{reducedMotion:`user`,children:(0,V.jsxs)(xI,{children:[(0,V.jsx)(JX,{}),(0,V.jsx)(QX,{}),(0,V.jsx)(oZ,{})]})})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{updateViaCache:`none`}).catch(()=>void 0)});export{F as i,pK as n,L as r,UY as t};
113
+ `,``);let i=lq.exec(e);if(n!==void 0){i&&i[1].startsWith(n)?(n=void 0,hq(t,e,`codeblock mark`)):hq(t,e,`codeblock`);return}if(i){n=i[1][0].repeat(3),hq(t,e,`codeblock mark`);return}if(r===0&&/^\/[a-z][\w-]*/i.test(e)){let n=/^\/[a-z][\w-]*/i.exec(e)[0];hq(t,n,`mention`),_q(t,e.slice(n.length),``);return}if(pq.test(e))return hq(t,e,`mark`);let a=uq.exec(e);if(a)return hq(t,a[1]+a[2],`heading mark`),_q(t,a[3],`heading`);let o=dq.exec(e);if(o)return hq(t,o[1],`quote mark`),_q(t,o[2],`quote`);let s=fq.exec(e);if(s)return hq(t,s[1],``),hq(t,s[2],`list`),hq(t,s[3],``),s[4]&&hq(t,s[4],`list`),_q(t,s[5],``);_q(t,e,``)}),t}function yq(e){if(e.startsWith(`/`))return`var(--primary)`;let t=pR(e.slice(1));return t===`var(--muted-foreground)`?`var(--primary)`:t}var bq=520;function xq(e,t){if(t.length<=e.length)return;let n=0;for(;n<e.length&&e[n]===t[n];)n++;let r=0;for(;r<e.length-n&&e[e.length-1-r]===t[t.length-1-r];)r++;let i=t.length-r;return i-n>0&&i-n<=24?{start:n,end:i}:void 0}function Sq(e,t,n,r,i){let a=xq(e,t);if(!a)return[];let o=a.end-a.start;return[...n.filter(e=>i-e.at<bq&&!(e.start<a.start&&e.end>a.start)).map(e=>e.start>=a.start?{...e,start:e.start+o,end:e.end+o}:e),{...a,seq:r,at:i}].sort((e,t)=>e.start-t.start)}var Cq=(0,m.memo)(function({text:e,fresh:t}){let n=0;return(0,V.jsxs)(V.Fragment,{children:[vq(e).flatMap((e,r)=>{let i=n;n+=e.text.length;let a=e.kind?e.kind.split(` `).map(e=>`md-${e}`).join(` `):``,o=e.kind===`mention`?{color:yq(e.text)}:void 0,s=[],c=i;for(let e of t){let t=Math.max(i,e.start),r=Math.min(n,e.end);r<=t||(t>c&&s.push({a:c,b:t}),s.push({a:t,b:r,seq:e.seq}),c=r)}return c<n&&s.push({a:c,b:n}),s.map(({a:t,b:n,seq:s})=>{let c=e.text.slice(t-i,n-i),l=s!==void 0;return a||l?(0,V.jsx)(`span`,{className:[a,l?`md-new`:``].filter(Boolean).join(` `),style:o,children:c},l?`n${s}-${r}`:`${r}-${t}`):c})}),`​`]})}),wq=(0,m.forwardRef)(function({text:e},t){let n=(0,m.useRef)({text:e,fresh:[],seq:0});if(n.current.text!==e){let t=n.current.seq+1;n.current={text:e,seq:t,fresh:Sq(n.current.text,e,n.current.fresh,t,performance.now())}}return(0,V.jsx)(`div`,{ref:t,className:`bubble-text bubble-mirror`,"aria-hidden":`true`,children:(0,V.jsx)(Cq,{text:e,fresh:n.current.fresh})})}),Tq=e=>e.preventDefault();function Eq({onStop:e}){let[t,n]=(0,m.useState)(!1),r=qT(t,KT.confirm),i=()=>{n(!1),e()};return RE(`y`,i,{enabled:t&&r,inDialog:!0}),(0,V.jsxs)(zL,{open:t&&r,onOpenChange:n,children:[(0,V.jsx)(`button`,{type:`button`,className:`bubble-send bubble-key bubble-stop`,"data-tip":`Interrupt`,onPointerDown:Tq,onClick:()=>n(!0),"aria-label":`Stop`,"aria-haspopup":`dialog`,children:(0,V.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,V.jsx)(`rect`,{x:`2`,y:`2`,width:`8`,height:`8`,rx:`1.5`})})}),(0,V.jsxs)(BL,{children:[(0,V.jsxs)(VL,{children:[(0,V.jsx)(UL,{children:`Stop the oracle?`}),(0,V.jsx)(WL,{children:`The current response stops. Work already recorded is kept.`})]}),(0,V.jsxs)(HL,{children:[(0,V.jsxs)(KL,{children:[`Keep it`,(0,V.jsx)(IT,{chord:`Esc`,className:`kbd-hint ml-1`})]}),(0,V.jsxs)(GL,{variant:`destructive`,onClick:i,children:[`Stop`,(0,V.jsx)(IT,{chord:`Y`,className:`kbd-hint ml-1`})]})]})]})]})}function Dq({sending:e,disabled:t,steering:n,onSend:r}){let[i,a]=(0,m.useState)(0),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(!1),u=(0,m.useRef)(e);return(0,m.useEffect)(()=>{if(!i)return;l(!0);let e=setTimeout(()=>l(!1),640);return()=>clearTimeout(e)},[i]),(0,m.useEffect)(()=>{if(e&&!u.current&&a(e=>e+1),u.current=e,!e)return s(!1);let t=setTimeout(()=>s(!0),600);return()=>clearTimeout(t)},[e]),(0,V.jsx)(`button`,{type:`button`,className:Y(`bubble-send`,(!t||c)&&`bubble-key`),"data-tip":n?`Steer`:`Send`,"data-flying":c||void 0,onPointerDown:Tq,onClick:r,disabled:t,"aria-label":`Send`,"aria-keyshortcuts":`Enter`,children:o?(0,V.jsx)(lR,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,V.jsxs)(`span`,{className:`bubble-plane-wrap`,"data-fly":i>0?``:void 0,"aria-hidden":`true`,children:[(0,V.jsxs)(`svg`,{className:`bubble-plane`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`path`,{d:`M22 2L11 13`}),(0,V.jsx)(`path`,{d:`M22 2l-7 20-4-9-9-4z`})]}),(0,V.jsx)(`span`,{className:`bubble-trail`})]},i)})}function Oq(e){return e.agent?pR(e.agent):e.tag===`lobby`?`var(--c-orc)`:e.tag===`skill`?`var(--c-pl)`:`var(--c-qa)`}function kq(e,t){let n=/^\s*([/@])([a-z0-9:_.-]*)$/i.exec(e.slice(0,t));if(n&&!/\S/.test(e.slice(t,t+1)))return{kind:n[1]===`/`?`slash-command`:`mention`,query:n[2].toLowerCase()}}function Aq(e){return[...$T.map(e=>({id:`/${e.name}`,insert:`/${e.name}`,label:`/${e.name}`,description:e.hint,tag:`lobby`})),...e.map(e=>({id:`/${e.name}`,insert:`/${e.name}`,label:`/${e.name}`,description:e.description+(e.terminal?` · continue in Pi terminal`:``),tag:e.name.startsWith(`skill:`)?`skill`:`pi`}))]}function jq(e,t=[]){let n=e.kind===`slash-command`?Aq(t):QT.map(e=>({id:`@${e.name}`,insert:`@${e.name}`,label:`@${e.name}`,description:e.hint,agent:e.agent,tag:`agent`})),r=n.filter((e,t)=>n.findIndex(t=>t.id===e.id)===t),i=r.filter(t=>t.label.slice(1).startsWith(e.query)),a=r.filter(t=>!i.includes(t)&&t.label.slice(1).includes(e.query));return[...i,...a]}function Mq(e,t){return`${e}-${encodeURIComponent(t)}`}var Nq={"slash-command":`Commands`,mention:`Agents`};function Pq(e){return 8+Math.min(e,8)*30}var Fq;function Iq(e,t){let n=0;try{if(Fq??=document.createElement(`canvas`).getContext(`2d`),!Fq)throw Error(`no canvas`);for(let r of e){Fq.font=`500 13px ${t}`;let e=Fq.measureText(r.label.slice(1)).width;Fq.font=`400 12px ${t}`,n=Math.max(n,e+Fq.measureText(r.description).width)}}catch{for(let t of e)n=Math.max(n,t.label.length*7.4+t.description.length*6.1)}return Math.min(Math.max(Math.ceil(n)+128,180),600)}var Lq=(0,m.memo)(function(e){let t=(0,m.useRef)(null);(0,m.useLayoutEffect)(()=>{e.activeItemId&&t.current&&t.current.querySelector(`[data-composer-item-id="${CSS.escape(e.activeItemId)}"]`)?.scrollIntoView({block:`nearest`})},[e.activeItemId]);let n=Math.min(e.items.length,8);return(0,V.jsx)(`div`,{ref:t,id:e.listId,role:`listbox`,"aria-label":Nq[e.triggerKind],"data-composer-command-drawer":`true`,className:`bubble-pane bubble-scroll overflow-y-auto p-1`,style:{height:Pq(e.items.length)},children:e.items.map((t,r)=>{let i=e.activeItemId===t.id;return(0,V.jsxs)(`div`,{id:Mq(e.listId,t.id),role:`option`,"aria-selected":i,"data-composer-item-id":t.id,"data-active":i||void 0,onMouseMove:()=>{i||e.onHighlightedItemChange(t.id)},onMouseDown:e=>e.preventDefault(),onClick:()=>e.onSelect(t),className:`bubble-row`,style:{"--delay":`${Math.max(0,n-1-r)*22}ms`},children:[t.agent?(0,V.jsx)(`span`,{className:`cs-kdot`,"aria-hidden":`true`,style:{"--k":Oq(t)}}):(0,V.jsx)(`span`,{className:`bubble-glyph cs-kg`,"aria-hidden":`true`,style:{"--k":Oq(t)},children:t.label.charAt(1).toUpperCase()}),(0,V.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-(--bubble-ink)`,children:t.label.slice(1)}),(0,V.jsx)(`span`,{className:`min-w-0 truncate text-[13px] text-(--bubble-muted)`,children:t.description}),(0,V.jsx)(`span`,{className:`cs-ktag`,style:{"--k":Oq(t)},children:t.tag})]},t.id)})})});function Rq(e){return typeof e==`object`&&e?e:{}}function zq(e){return typeof e==`string`?e.trim():``}function Bq(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Vq(e){let t=Rq(e),n=zq(t.label);if(!n)return;let r=zq(t.description),i=zq(t.preview),a=zq(t.image),o=sU(t.htmlPreview);return{label:n,...r?{description:r}:{},...i?{preview:i}:{},...a?{image:a}:{},...o?{htmlPreview:o}:{}}}function Hq(e){let t=Rq(e),n=zq(t.question);if(!n)return;let r=(Array.isArray(t.options)?t.options:[]).map(Vq).filter(e=>!!e);return{question:n,header:zq(t.header)||`Question`,options:r,...t.multiSelect===!0?{multiSelect:!0}:{}}}function Uq(e){let t=Rq(e),n=zq(t.method);if(n!==`select`&&n!==`confirm`&&n!==`input`&&n!==`editor`)return;let r=zq(t.message),i=Bq(t.options),a=zq(t.placeholder),o=zq(t.prefill);return{id:zq(t.id),method:n,title:zq(t.title)||`Answer`,...r?{message:r}:{},...i.length>0?{options:i}:{},...a?{placeholder:a}:{},...o?{prefill:o}:{}}}function Wq(e){let t=(Array.isArray(e.questions)?e.questions:[]).map(Hq).filter(e=>!!e);return t.length>0?{kind:`questionnaire`,questions:t}:void 0}function Gq(e){return{kind:`choose`,title:zq(e.title)||`Choose an option`,options:Bq(e.options)}}function Kq(e){let t=zq(e.question)||zq(e.title)||`Continue?`,n=zq(e.detail)||zq(e.message);return{kind:`confirm`,question:t,...n?{detail:n}:{}}}function qq(e){let t=zq(e.question)||zq(e.title)||`Type an answer`,n=zq(e.placeholder);return{kind:`text`,question:t,...n?{placeholder:n}:{}}}function Jq(e){let t=Rq(e.payload);if(e.kind===`questionnaire`)return Wq(t);if(e.kind===`choose`)return Gq(t);if(e.kind===`confirm`)return Kq(t);if(e.kind===`text`)return qq(t);let n=Uq(t.dialog);return n?{kind:`sessionDialog`,dialog:n}:void 0}var Yq=`That question was already answered in the terminal.`;function Xq(e){let t=e.from.trim();return/panel|plann/i.test(t)?`PLANNER`:/oracle|master|lobby/i.test(t)||!t?`MASTER`:t.split(/\s+/)[0].toUpperCase()}function Zq(e,t){let n=Xq(e);return n===`PLANNER`&&t&&pR(t)!==`var(--muted-foreground)`?t.toUpperCase():n}function Qq(e,t){let n=Zq(e,t);if(n!==Xq(e))return n===`DEV`||n===`BACKEND`?`Dev`:n===`QA`?`QA`:n.charAt(0)+n.slice(1).toLowerCase();let r=Xq(e);if(r===`PLANNER`)return`Panel`;if(r===`MASTER`)return`Oracle`;let i=e.from.trim().split(/\s+/)[0]??`Agent`;return i.charAt(0).toUpperCase()+i.slice(1)}function $q(e,t){let{round:n,limit:r}=e.payload??{},i=n?`From planning · round ${r?`${Math.min(n,r)}/${r}`:n}`:`From planning`,a=Xq(e)===`PLANNER`?i:e.taskId?`From task ${e.taskId}`:`From the Lobby`;return t&&t!==`Question`&&Zq(e,t)===Xq(e)?`${a} · ${t}`:a}function eJ(e,t,n){let r={prompt:e,view:t,index:0,multi:!1,placeholder:`Or type your own reply…`};if(t.kind===`questionnaire`){let e=t.questions[n];return e?{...r,index:n,question:e.question,header:e.header,multi:!!e.multiSelect,options:e.options.map(e=>({...e,value:e.label})),typed:e=>e}:void 0}if(t.kind===`choose`)return{...r,question:t.title,options:t.options.map(e=>({label:e,value:e}))};if(t.kind===`confirm`)return{...r,question:t.detail?`${t.question}\n\n${t.detail}`:t.question,options:[{label:`Yes`,value:!0},{label:`No`,value:!1}]};if(t.kind===`text`)return{...r,question:t.question,options:[],typed:e=>e,placeholder:t.placeholder||`Type your reply…`};let i=t.dialog,a=i.message?`${i.title}\n\n${i.message}`:i.title;return i.method===`select`?{...r,question:a,options:(i.options??[]).map(e=>({label:e,value:{value:e}}))}:i.method===`confirm`?{...r,question:a,options:[{label:`Yes`,value:{confirmed:!0}},{label:`No`,value:{confirmed:!1}}]}:{...r,question:a,options:[],typed:e=>({value:e}),placeholder:i.placeholder||`Type your reply…`}}function tJ(e,t){return e&&e.kind===`questionnaire`?Math.max(0,e.questions.length-t):1}function nJ(e,t,n){let[r,i]=(0,m.useState)({}),[a,o]=(0,m.useState)([]),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(0),[d,f]=(0,m.useState)(),p=(0,m.useMemo)(()=>e.map(e=>({prompt:e,view:Jq(e)})),[e]),h=p[0],g=h?.view?eJ(h.prompt,h.view,r[h.prompt.id]?.length??0):void 0,_=p.reduce((e,{prompt:t,view:n})=>e+tJ(n,r[t.id]?.length??0),0);(0,m.useEffect)(()=>{e.length===0&&(u(0),i({}))},[e.length]);let v=g?`${g.prompt.id}:${g.index}`:``;(0,m.useEffect)(()=>o([]),[v]);let y=(0,m.useCallback)(async(e,n)=>{c(!0);try{await t(e,n)}catch(e){e instanceof xe&&e.code===`question_withdrawn`?H(Yq):H.error(e instanceof Error?e.message:`Could not send the answer`)}finally{c(!1)}},[t]),b=(0,m.useCallback)((e,t=`option`,n)=>{if(!g||s)return;if(u(e=>e+1),g.view.kind!==`questionnaire`)return void y(g.prompt.id,e);let a=[...r[g.prompt.id]??[],{questionIndex:g.index,question:g.question,kind:t,answer:String(e),...n?{selected:n}:{}}];if(a.length<g.view.questions.length)return i(e=>({...e,[g.prompt.id]:a}));y(g.prompt.id,{answers:a,cancelled:!1}).then(()=>i(e=>{let t={...e};return delete t[g.prompt.id],t}))},[s,r,y,g]),x=(0,m.useCallback)(e=>{let t=g?.options[e];if(t){if(g.multi)return o(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);b(t.value)}},[g,b]),S=x,C=(0,m.useCallback)(()=>{if(!g||a.length===0)return;let e=[...a].sort((e,t)=>e-t).map(e=>g.options[e].label);b(e.join(`, `),`multi`,e)},[a,g,b]),w=(0,m.useCallback)(e=>!g?.typed||!e.trim()?!1:(b(g.typed(e.trim()),`custom`),!0),[g,b]),T=(0,m.useCallback)(()=>{g&&n(g.prompt.id).catch(e=>H.error(e instanceof Error?e.message:`Could not dismiss the question`))},[n,g]),E=g?r[g.prompt.id]:void 0,D=(0,m.useCallback)(()=>{if(!g||s||!E?.length)return;let e=E.at(-1);i(e=>({...e,[g.prompt.id]:E.slice(0,-1)})),u(e=>Math.max(0,e-1)),f({id:g.prompt.id,index:e.questionIndex,answer:e.answer??``})},[s,E,g]),O=d&&g&&d.id===g.prompt.id&&d.index===g.index?d.answer:void 0;return{...g?{step:g}:{},position:l+1,total:l+_,left:_,picks:a,busy:s,choose:x,toggle:S,submitPicks:C,reply:w,dismiss:T,...E?.length?{back:D}:{},...O?{was:O}:{}}}function rJ({option:e,large:t}){let n=hU(e.label);return e.htmlPreview?(0,V.jsx)(fU,{preview:e.htmlPreview,label:n,frameWidth:t?void 0:880,minWidth:t?1024:void 0,className:`static-thumb h-full`}):e.image?(0,V.jsx)(`img`,{src:F(e.image),alt:t?`Mockup: ${n}`:``,loading:`lazy`}):e.preview?t?(0,V.jsx)(`div`,{className:`cs-mktext`,children:(0,V.jsx)(FL,{text:e.preview})}):(0,V.jsx)(`pre`,{className:`cs-mktext`,children:e.preview}):null}function iJ(e,t){return e!==void 0&&(e===t||e.split(`, `).includes(t))}function aJ({color:e,children:t}){return(0,V.jsx)(`span`,{className:`bubble-glyph cs-kg`,"aria-hidden":`true`,style:{"--k":e},children:t})}function oJ({drawer:e,onExpand:t}){let{step:n}=e,[r,i]=(0,m.useState)(!1);if((0,m.useEffect)(()=>i(!1),[n?.prompt.id]),!n)return(0,V.jsx)(`div`,{className:`bubble-pane p-3 text-sm text-(--bubble-muted)`,children:`No questions are waiting.`});let a=pR(Zq(n.prompt,n.header)),o=n.options.some(gU),s=n.options.length;return(0,V.jsxs)(`div`,{className:`bubble-pane p-1.5`,role:`group`,"aria-label":`Question`,children:[(0,V.jsxs)(`div`,{className:`cs-askh`,children:[(0,V.jsxs)(`div`,{className:`cs-asks`,children:[(0,V.jsx)(`b`,{style:{color:a},children:Qq(n.prompt,n.header)}),(0,V.jsx)(`span`,{className:`cs-askf`,children:$q(n.prompt,n.header)}),e.back?(0,V.jsx)(`button`,{type:`button`,className:`cs-askx`,"aria-label":`Back to the previous question`,onMouseDown:e=>e.preventDefault(),onClick:e.back,children:`‹ Back`}):null,(0,V.jsxs)(`span`,{className:`cs-askn`,children:[e.position,` of `,e.total]}),(0,V.jsx)(`button`,{type:`button`,className:`cs-askx`,"data-confirm":r||void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>r?e.dismiss():i(!0),onBlur:()=>i(!1),children:r?`Dismiss it?`:`Dismiss`})]}),(0,V.jsx)(`p`,{className:`cs-askq`,title:n.question,children:n.question})]}),o?(0,V.jsx)(`div`,{className:`cs-askm`,children:n.options.map((n,r)=>(0,V.jsxs)(`button`,{type:`button`,className:`cs-mko`,"data-on":e.picks.includes(r)||iJ(e.was,n.label)||void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>e.choose(r),style:{animationDelay:`${r*30}ms`},children:[(0,V.jsxs)(`div`,{className:`cs-mk3`,children:[(0,V.jsx)(rJ,{option:n}),(0,V.jsx)(`span`,{className:`cs-mxb`,role:`button`,"aria-label":`Expand ${hU(n.label)}`,onClick:e=>{e.stopPropagation(),t(r)},children:(0,V.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7`})})})]}),(0,V.jsxs)(`span`,{className:`cs-mkl`,children:[(0,V.jsx)(aJ,{color:a,children:r+1}),(0,V.jsx)(`span`,{children:hU(n.label)})]})]},n.label))}):(0,V.jsxs)(`div`,{className:`cs-askopts`,children:[n.options.map((t,r)=>(0,V.jsxs)(`button`,{type:`button`,className:`bubble-row`,"data-active":e.picks.includes(r)||iJ(e.was,t.label)||void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>e.choose(r),style:{"--delay":`${(s-1-r)*22}ms`},children:[(0,V.jsx)(aJ,{color:a,children:r+1}),(0,V.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-(--bubble-ink)`,children:hU(t.label)}),t.description?(0,V.jsx)(`span`,{className:`min-w-0 truncate text-[13px] text-(--bubble-muted)`,title:t.description,children:t.description}):null,n.multi?(0,V.jsx)(`span`,{className:`cs-cb cs-sm`,"data-on":e.picks.includes(r),children:(0,V.jsx)(Jf,{"aria-hidden":`true`,strokeWidth:3})}):null]},t.label)),s===0?(0,V.jsx)(`div`,{className:`flex h-9 items-center px-2.5 text-[13px] text-(--bubble-muted)`,children:`Type your reply in the box below, then press Enter.`}):null]}),n.multi?(0,V.jsx)(`button`,{type:`button`,className:`bubble-row`,disabled:e.picks.length===0,onMouseDown:e=>e.preventDefault(),onClick:e.submitPicks,children:(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-accent)`,children:e.picks.length===0?`Pick one or more`:`Answer with ${e.picks.length} picked`})}):null]})}function sJ({drawer:e,at:t,onAt:n}){let r=e.step,i=r?.options??[],a=t>=0&&t<i.length,o=(0,m.useRef)(t);a&&(o.current=t);let s=i[o.current],c=(0,m.useRef)(null);(0,m.useEffect)(()=>{a&&c.current?.focus({preventScroll:!0})},[a]);let l=e=>n((o.current+e+i.length)%i.length),u=r?pR(Zq(r.prompt,r.header)):`var(--primary)`;return(0,V.jsxs)(`div`,{className:`cs-mxw`,"data-open":a,"aria-hidden":!a,inert:!a,children:[(0,V.jsx)(`div`,{className:`cs-shbd`,onClick:()=>n(-1)}),(0,V.jsxs)(`div`,{ref:c,role:a?`dialog`:void 0,"aria-modal":a?`true`:void 0,"aria-label":s?`Mockup: ${hU(s.label)}`:`Mockup`,tabIndex:-1,className:`cs-mxc`,onKeyDown:t=>{t.key===`Escape`?(t.preventDefault(),t.stopPropagation(),n(-1)):t.key===`ArrowRight`||t.key===`ArrowLeft`?(t.preventDefault(),l(t.key===`ArrowRight`?1:-1)):t.key===`Enter`&&s&&(t.preventDefault(),n(-1),e.choose(o.current))},children:[(0,V.jsx)(`div`,{className:`cs-mxbig`,children:s?(0,V.jsx)(rJ,{option:s,large:!0}):null}),s&&r?(0,V.jsxs)(`div`,{className:`cs-mxf`,children:[(0,V.jsx)(aJ,{color:u,children:o.current+1}),(0,V.jsx)(`b`,{children:hU(s.label)}),(0,V.jsxs)(`span`,{className:`cs-mxwho`,children:[Qq(r.prompt,r.header),` · `,r.question]}),i.length>1?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib`,"aria-label":`Previous mockup`,onClick:()=>l(-1),children:(0,V.jsx)(Zf,{"aria-hidden":`true`,className:`size-3.5`})}),(0,V.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib`,"aria-label":`Next mockup`,onClick:()=>l(1),children:(0,V.jsx)($f,{"aria-hidden":`true`,className:`size-3.5`})})]}):null,(0,V.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-pri`,onClick:()=>{n(-1),e.choose(o.current)},children:r.multi?e.picks.includes(o.current)?`Unpick this`:`Pick this`:`Choose this`}),(0,V.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib`,"aria-label":`Close`,onClick:()=>n(-1),children:(0,V.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5`})})]}):null]})]})}var cJ=`bot-lobby.questionsPutAway`,lJ=new Set,uJ;function dJ(){if(uJ!==void 0)return uJ;try{uJ=sessionStorage.getItem(cJ)===`1`}catch{uJ=!1}return uJ}function fJ(e){if(dJ()!==e){uJ=e;try{e?sessionStorage.setItem(cJ,`1`):sessionStorage.removeItem(cJ)}catch{}for(let e of[...lJ])e()}}function pJ(e){return lJ.add(e),()=>{lJ.delete(e)}}function mJ(){return(0,m.useSyncExternalStore)(pJ,dJ,()=>!1)}var hJ={id:`oracle`,label:`Message the team`,placeholder:`Write a message, run a command, or ask an agent`},gJ=new Set([`lobby`,`tasks`,`plan`,`knowledge`]);function _J(e){return e.kind===`settings`||e.kind===`tab`&&gJ.has(e.tab)}var vJ={id:`knowledge`,label:`Ask what the agents know`,placeholder:`Ask what the agents know…`};function yJ(e,t){if(e.kind!==`tab`)return hJ;if(e.tab===`knowledge`)return vJ;if(e.tab===`plan`)return{id:`panel`,label:`Message the panel`,placeholder:`Describe a task, or answer the panel…`};let n=e.tab===`tasks`?cR(e.rest).id??t:void 0;return n?{id:`comment`,label:`Comment on ${n}`,placeholder:`Comment on ${n}'s plan…`,taskId:n}:hJ}var bJ={w:260,h:97},xJ=0,SJ=document.createElement(`canvas`).getContext(`2d`);function CJ(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}var wJ={duration:.16,ease:`easeOut`};function TJ({file:e,onRemove:t}){let n=(0,V.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,onClick:t,className:Y(`flex shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,e.image?`absolute top-1 right-1 size-[1.625rem] rounded-full bg-background/85 text-foreground shadow-xs hover:bg-background`:`size-7`),children:(0,V.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5`})});return e.image?(0,V.jsxs)(Yd.li,{layout:!0,initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:wJ,title:`${e.name} · ${RK(e.size)}`,className:`relative size-16 shrink-0 overflow-hidden rounded-xl border border-(--bubble-edge) bg-background`,children:[(0,V.jsx)(`img`,{src:F(e.image),alt:e.name,className:`size-full object-cover`}),e.state===`uploading`?(0,V.jsxs)(`span`,{className:`pointer-events-none absolute inset-x-0 bottom-0 flex items-center justify-center gap-1 bg-background/85 px-1 text-[0.625rem] text-foreground`,children:[(0,V.jsx)(lR,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}),`uploading`]}):null,n]}):(0,V.jsxs)(Yd.li,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:wJ,className:`flex min-w-0 basis-full items-center gap-2 text-sm text-foreground`,children:[(0,V.jsx)(jp,{"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)(lR,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}):null,e.state===`uploading`?`uploading…`:RK(e.size)]}),n]})}function EJ(e,t,n,r){let[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(r);o.current=r;let s=n.kind===`tab`?n.tab:n.kind;return(0,m.useEffect)(()=>a(!1),[s]),(0,m.useEffect)(()=>{if(!t)return;let n=0,r=t=>{e.current?.contains(t.target)||(n=performance.now())},i=t=>{[`PageDown`,`PageUp`,`ArrowDown`,`ArrowUp`,`Home`,`End`,` `].includes(t.key)&&!e.current?.contains(t.target)&&(n=performance.now())},s=t=>{let r=e.current;!r||o.current||performance.now()-n>400||r.contains(document.activeElement)||r.contains(t.target)||a(!0)};return document.addEventListener(`wheel`,r,{capture:!0,passive:!0}),document.addEventListener(`touchmove`,r,{capture:!0,passive:!0}),document.addEventListener(`keydown`,i,{capture:!0}),document.addEventListener(`scroll`,s,{capture:!0,passive:!0}),()=>{document.removeEventListener(`wheel`,r,{capture:!0}),document.removeEventListener(`touchmove`,r,{capture:!0}),document.removeEventListener(`keydown`,i,{capture:!0}),document.removeEventListener(`scroll`,s,{capture:!0})}},[t,e]),{shrunk:i,expand:(0,m.useCallback)(()=>a(!1),[])}}function DJ({children:e}){return(0,V.jsx)(`kbd`,{className:`bubble-kbd`,"data-glyph":/^[^A-Za-z0-9]$/.test(e)||void 0,children:e})}function OJ(e,t,n){let[r,i]=(0,m.useState)({w:250,h:38});return(0,m.useLayoutEffect)(()=>{let r=t.current;if(!r)return;let a=()=>{let t=e===`bar`?{w:Math.ceil(r.scrollWidth),h:38}:{w:n??580,h:Math.ceil(r.scrollHeight)};i(e=>e.w===t.w&&e.h===t.h?e:t)};a();let o=new ResizeObserver(a);for(let e of r.children)o.observe(e);return()=>o.disconnect()}),r}function kJ({route:e,projects:t,drawer:n,drawerOpen:r}){let[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)([]),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(null),h=vE(`status`),g=vE(`lobby`),_=YT(),v=(h.data?.busy??!1)||!!g.data?.reply?.trim(),y=_J(e),b=(0,m.useRef)(y);b.current=y;let{taskId:x}=SW(),S=e.kind===`tab`?e.tab:e.kind,C=(0,m.useMemo)(()=>yJ(e,x),[e,x]),w=pD(),[T,E]=(0,m.useState)(-1),D=(0,m.useRef)(null),O=(0,m.useRef)(null),k=(0,m.useRef)(null),ee=(0,m.useRef)(null),A=(0,m.useRef)(null),j=(0,m.useRef)(null),M=(0,m.useRef)(null),te=(0,m.useRef)(null),ne=(0,m.useRef)(o);ne.current=o;let N=(0,m.useRef)(void 0),[re,ie]=(0,m.useState)(0),[ae,oe]=(0,m.useState)(null),[se,ce]=(0,m.useState)(void 0),le=r&&!!n.step&&y&&!_&&f===null,ue=C.id===`oracle`&&!f&&!le?kq(i,re):void 0,P=(0,m.useMemo)(()=>ue?jq(ue,h.data?.commands):[],[ue?.kind,ue?.query,h.data?.commands]),de=!!ue&&P.length>0&&se!==i&&y&&!_,fe=de?P.find(e=>e.id===ae)??P[0]:void 0,pe=`composer-suggestions`,F={answer:n.left>0&&!r,plan:S===`plan`&&!!w},I=!de&&f===null&&!le&&y&&!_&&(F.answer||F.plan),me=de||le||f!==null&&y&&!_,{shrunk:he,expand:ge}=EJ(D,y&&!_,e,me),[_e,ve]=(0,m.useState)(!1),ye=(0,m.useRef)(he);(0,m.useEffect)(()=>{if(ye.current===he)return;ye.current=he,ve(!0);let e=setTimeout(()=>ve(!1),400);return()=>clearTimeout(e)},[he]);let be=I&&!he&&!_e,xe=me||be;(0,m.useEffect)(()=>{let e=document.documentElement;return e.style.setProperty(`--dock-bar`,I?`44px`:`0px`),()=>e.style.setProperty(`--dock-bar`,`0px`)},[I]),(0,m.useEffect)(()=>p(null),[S]),(0,m.useEffect)(()=>{(!y||_)&&p(null)},[y,_]),(0,m.useEffect)(()=>{if(!f)return;let e=e=>{O.current?.contains(e.target)||p(null)};return document.addEventListener(`pointerdown`,e,{capture:!0}),()=>document.removeEventListener(`pointerdown`,e,{capture:!0})},[f]);let Se=(0,m.useCallback)(e=>{ge(),p(t=>t===e||e===`projects`&&t===`browse`?null:e)},[ge]),Ce=(0,m.useCallback)(()=>{p(e=>{let t=e===`attach`?`[data-composer-attach]`:e?`[role="combobox"][aria-label="Project"]`:void 0;return t&&requestAnimationFrame(()=>O.current?.querySelector(t)?.focus({preventScroll:!0})),null})},[]);RE(`p`,()=>Se(`projects`),{enabled:y&&!_&&f===null}),(0,m.useEffect)(()=>{let e=()=>{ge(),p(`projects`)};return window.addEventListener(XK,e),()=>window.removeEventListener(XK,e)},[ge]);let we=(0,m.useRef)(`suggest`),Te=(0,m.useRef)({w:320,h:0}),Ee=f??(le?`ask`:de?`suggest`:be?`bar`:we.current),De=(0,m.useRef)(null),Oe=OJ(Ee,De,Ee===`ask`&&n.step?.options.some(gU)?Math.max(580,Math.min(960,(k.current?.clientWidth??740)-12)):void 0);if(xe){we.current=Ee;let e=A.current?getComputedStyle(A.current).fontFamily:`system-ui, sans-serif`;Te.current=Ee===`suggest`?{w:Iq(P,e),h:Pq(P.length)}:Ee===`attach`?bJ:Ee===`projects`?QK(t):Ee===`bar`||Ee===`ask`?Oe:tq}let ke=(0,m.useRef)({items:[],kind:`slash-command`});de&&ue&&fe&&(ke.current={items:P,kind:ue.kind,lit:fe.id});let Ae=(0,m.useCallback)(e=>{let t=i.replace(/^\s*[/@][a-z0-9:_.-]*\s*/i,``),n=`${e.insert} ${t}`,r=e.insert.length+1;N.current={start:r,end:r},ie(r),a(n),oe(null),A.current?.focus()},[i]);(0,m.useLayoutEffect)(()=>{let e=N.current,t=A.current;e&&t&&(N.current=void 0,t.setSelectionRange(e.start,e.end))},[i]);let je=(0,m.useCallback)(e=>{N.current={start:e.start,end:e.end},ie(e.end),a(e.value)},[]);(0,m.useLayoutEffect)(()=>{let e=ee.current,t=O.current;if(!e||!t)return;let n=()=>{t.hasAttribute(`data-shrunk`)||t.style.setProperty(`--ch-open`,`${Math.ceil(e.getBoundingClientRect().height)}px`)};n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[he]),(0,m.useLayoutEffect)(()=>{let e=A.current,t=O.current;if(!e||!t)return;if(he||!i)return void t.style.removeProperty(`--cg`);let n=getComputedStyle(e);SJ.font=`${n.fontStyle} ${n.fontWeight} ${n.fontSize} ${n.fontFamily}`;let r=Math.max(...i.split(`
114
+ `).map(e=>SJ.measureText(e).width));t.style.setProperty(`--cg`,`${Math.ceil((r+44)/48)*48}px`)},[i,he]),(0,m.useLayoutEffect)(()=>{j.current&&A.current&&(j.current.scrollTop=A.current.scrollTop)}),(0,m.useEffect)(()=>{let e=k.current,t=D.current;if(!e||!t)return;let n=document.documentElement,r=()=>{let r=e.getBoundingClientRect(),i=t.getBoundingClientRect().bottom;if(!t.hasAttribute(`data-shrunk`)&&!e.closest(`.bubble`)?.hasAttribute(`data-morphing`)||!y||_){if(n.style.setProperty(`--composer-h`,_||!y?`0px`:`${Math.ceil(i-r.top)}px`),!y||r.width===0){n.style.removeProperty(`--composer-x`),n.style.removeProperty(`--composer-w`);return}n.style.setProperty(`--composer-x`,`${Math.round(r.left)}px`),n.style.setProperty(`--composer-w`,`${Math.round(r.width)}px`)}};r();let i=new ResizeObserver(r);return i.observe(e),e.addEventListener(`transitionend`,r),window.addEventListener(`resize`,r),()=>{i.disconnect(),e.removeEventListener(`transitionend`,r),window.removeEventListener(`resize`,r),n.style.setProperty(`--composer-h`,`0px`),n.style.removeProperty(`--composer-x`),n.style.removeProperty(`--composer-w`)}},[_,y]);let Me=(0,m.useCallback)(e=>{if(!b.current)return;let t=[...e],n=8-ne.current.length;t.length>n&&H.warning(`At most 8 files go with one message.`);for(let e of t.slice(0,Math.max(0,n))){let t=`f${++xJ}`,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`}]),zK(e).then(e=>s(n=>n.map(n=>n.key===t?{...n,state:`ready`,info:e}:n))).catch(e=>{H.error(e instanceof Error?e.message:`That file did not upload.`),s(e=>e.filter(e=>e.key!==t))})}},[]),Ne=(0,m.useCallback)(e=>{s(t=>{let n=t.find(t=>t.key===e);return n?.image&&URL.revokeObjectURL(n.image),t.filter(t=>t.key!==e)})},[]),Pe=o.some(e=>e.state===`uploading`),Fe=o.flatMap(e=>e.info?[e.info.id]:[]),Ie=(i.trim().length>0||Fe.length>0)&&!Pe&&!c,Le=(0,m.useCallback)(async()=>{if(!Ie||!b.current)return;l(!0);let e=Fe.length>0?Fe:void 0,t={text:i,...e?{attachments:e}:{}};try{let e=!0,n=C.id===`knowledge`&&/^\s*[/@]/.test(i);if(C.id===`oracle`||n){let e=await L(`lobby.send`,t);e.notice&&H(e.notice),e.open===`plan`?iE(rE(`plan`)):S===`knowledge`&&iE(rE(`lobby`))}else C.id===`knowledge`?(e=await U(`knowledge.ask`,t)!==void 0,e&&window.dispatchEvent(new CustomEvent(hD,{detail:i.trim()}))):e=C.id===`panel`?await U(`planner.send`,t)!==void 0:await U(`tasks.comment`,{taskId:C.taskId,...t})!==void 0;if(e){a(``);for(let e of ne.current)e.image&&URL.revokeObjectURL(e.image);s([])}}catch(e){H.error(e instanceof Error?e.message:`Could not send`)}finally{l(!1)}},[Ie,Fe,C,i,e,S]),Re=(0,m.useCallback)(async()=>{try{await L(`lobby.abort`,{})}catch(e){H.error(e instanceof Error?e.message:`Could not stop`)}},[]),ze=e=>{if(de&&fe&&!e.nativeEvent.isComposing){let t=P.indexOf(fe);if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=(t+(e.key===`ArrowDown`?1:-1)+P.length)%P.length;oe(P[n].id);return}if(e.key===`Enter`&&!e.shiftKey||e.key===`Tab`){e.preventDefault(),Ae(fe);return}if(e.key===`Escape`){e.preventDefault(),ce(i);return}}if(e.key===`Escape`&&!e.nativeEvent.isComposing){e.preventDefault(),f?p(null):le?fJ(!0):DE();return}if(le&&CJ(e)){e.preventDefault(),n.reply(i)?a(``):!i.trim()&&n.step?.multi&&n.submitPicks();return}let t=e.currentTarget,r=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&!e.altKey&&!e.shiftKey&&[`b`,`i`,`e`,`k`].includes(r)){e.preventDefault();let{selectionStart:n,selectionEnd:i,value:a}=t;je(r===`k`?VK(a,n,i):BK(a,n,i,r===`b`?`**`:r===`i`?`_`:"`"));return}if(e.key===`Enter`&&e.shiftKey&&!e.nativeEvent.isComposing&&t.selectionStart===t.selectionEnd){let n=UK(t.value,t.selectionStart);n&&(e.preventDefault(),je(n));return}if(e.key===`Backspace`&&t.value===``&&ne.current.length>0){e.preventDefault(),Ne(ne.current.at(-1).key);return}(CJ(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey))&&(e.preventDefault(),Le())},Be=e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),Me(t))},Ve=e=>{e.preventDefault(),d(!1),e.dataTransfer.files.length>0&&Me(e.dataTransfer.files)},He=h.data?.workspace.name??`bot-lobby`,Ue=h.data?.branch??h.data?.workspace.branch,We=v&&C.id===`oracle`,Ge=he?S===`knowledge`?`Ask what the agents know…`:`Write a message…`:le?n.step?.typed?n.step.placeholder:`Pick an answer above`:We?`The oracle is working. Enter steers it…`:C.placeholder,Ke=e=>{p(null),e.current?.click()},qe=Ee===`ask`?(0,V.jsx)(`div`,{ref:De,children:(0,V.jsx)(oJ,{drawer:n,onExpand:E})},`ask`):Ee===`bar`?(0,V.jsx)(`div`,{ref:De,className:`bubble-pane p-1`,style:{width:`max-content`},children:(0,V.jsxs)(`div`,{className:`cs-pbar`,children:[F.answer?(0,V.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq cs-acc`,onMouseDown:e=>e.preventDefault(),onClick:()=>{fJ(!1),requestAnimationFrame(()=>A.current?.focus({preventScroll:!0}))},children:[(0,V.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M21 12a8 8 0 01-11.6 7.1L4 20l1-4.6A8 8 0 1121 12z`}),(0,V.jsx)(`path`,{d:`M9.6 9.5a2.5 2.5 0 014.8.9c0 1.6-2.4 2-2.4 3.4M12 16.5h.01`})]}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-accent)`,children:`Answer questions`}),(0,V.jsxs)(`span`,{className:`cs-ktag`,style:{"--k":`var(--primary)`},children:[n.left,` left`]})]}):null,F.plan?(0,V.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq`,"aria-keyshortcuts":`V`,onMouseDown:e=>e.preventDefault(),onClick:()=>w?.(),children:[(0,V.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M14 3H7a2 2 0 00-2 2v14a2 2 0 002 2h10a2 2 0 002-2V8z`}),(0,V.jsx)(`path`,{d:`M14 3v5h5M9 13h6M9 17h4`})]}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`View plan`}),(0,V.jsx)(`span`,{className:`cs-kb`,children:`V`})]}):null]})},`bar`):Ee===`suggest`?(0,V.jsx)(Lq,{listId:pe,items:de?P:ke.current.items,triggerKind:de&&ue?ue.kind:ke.current.kind,activeItemId:fe?.id??null,onHighlightedItemChange:oe,onSelect:Ae},`suggest`):Ee===`attach`?(0,V.jsxs)(`div`,{role:`menu`,"aria-label":`Attach`,className:`bubble-pane flex flex-col p-1`,onKeyDown:e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=[...e.currentTarget.querySelectorAll(`[role='menuitem']`)];t[(t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:t.length-1))%t.length]?.focus()},children:[(0,V.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`bubble-row`,style:{"--delay":`24ms`},onClick:()=>Ke(M),children:[(0,V.jsx)(jp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Upload a file…`})]}),(0,V.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`bubble-row`,style:{"--delay":`12ms`},onClick:()=>Ke(te),children:[(0,V.jsx)(Vp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Upload an image…`})]}),(0,V.jsx)(`div`,{className:`h-px`}),(0,V.jsx)(`div`,{className:`flex h-7 items-center px-2 text-[11.5px] text-(--bubble-muted)`,children:`Or drop files on the composer`})]},`attach`):Ee===`projects`?(0,V.jsx)(eq,{projects:t,tab:S,onBrowse:()=>p(`browse`),onClose:()=>p(null)},`projects`):(0,V.jsx)(aq,{tab:S,onClose:Ce},`browse`);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`cs-scrim`,"data-open":me||void 0,"aria-hidden":`true`}),(0,V.jsx)(`div`,{id:`app-dock`,ref:D,"data-shrunk":he||void 0,onFocus:ge,className:Y(`dock pointer-events-none absolute inset-x-0 bottom-0 z-30 px-6 pb-[max(24px,env(safe-area-inset-bottom))] transition-opacity duration-200 ease-snap`,_&&`opacity-0`),hidden:!y,"aria-hidden":!y||void 0,inert:_||!y,children:(0,V.jsx)(cq,{ref:O,open:xe,size:Te.current,shrunk:he,morphing:_e,menu:qe,className:`composer-shell pointer-events-auto`,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||(f?(e.preventDefault(),Ce()):le&&(e.preventDefault(),fJ(!0)))},children:(0,V.jsxs)(`div`,{ref:k,className:`bubble-composer group/composer composer-box`,"data-dragging":u||void 0,"data-chat-composer-main-surface":`true`,onPointerDown:ge,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),d(!0))},onDragLeave:()=>d(!1),onDrop:Ve,children:[(0,V.jsxs)(`div`,{ref:ee,"data-chat-composer-surface":`true`,children:[(0,V.jsx)(eu,{initial:!1,children:o.length>0?(0,V.jsx)(Yd.ul,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.18,ease:`easeOut`},"aria-label":`Attachments`,className:`composer-files flex max-w-full flex-wrap gap-2 overflow-hidden px-3.5 pt-3`,children:o.map(e=>(0,V.jsx)(TJ,{file:e,onRemove:()=>Ne(e.key)},e.key))},`files`):null}),(0,V.jsxs)(`div`,{className:`bubble-field`,children:[(0,V.jsx)(wq,{ref:j,text:i}),(0,V.jsx)(`textarea`,{ref:A,id:`composer-text`,"aria-label":C.label,...C.id===`oracle`?{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":de,"aria-controls":de?pe:void 0}:{},...fe?{"aria-activedescendant":Mq(pe,fe.id)}:{},value:i,onChange:e=>{a(e.target.value),ie(e.target.selectionStart),p(null)},onSelect:e=>ie(e.currentTarget.selectionStart),onKeyDown:ze,onPaste:Be,onScroll:e=>{j.current&&(j.current.scrollTop=e.currentTarget.scrollTop)},placeholder:Ge,rows:1,className:`bubble-text bubble-input`})]}),(0,V.jsxs)(`div`,{"data-chat-composer-footer":`true`,className:`bubble-tools composer-tools`,children:[(0,V.jsx)(`button`,{type:`button`,"data-composer-attach":!0,"aria-label":`Attach images, PDFs or files`,"aria-haspopup":`menu`,"aria-expanded":f===`attach`,"data-on":f===`attach`||void 0,"data-tip":`Attach a file`,onPointerDown:e=>e.preventDefault(),onClick:()=>Se(`attach`),className:`bubble-iconbtn bubble-tip bubble-tool size-8 rounded-full`,style:{"--i":0},children:(0,V.jsx)(hm,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.7})}),(0,V.jsx)(`span`,{className:`bubble-tool flex min-w-0`,style:{"--i":1},children:(0,V.jsx)($K,{projects:t,name:He,branch:Ue,open:f===`projects`||f===`browse`,onToggle:()=>Se(`projects`)})}),(0,V.jsx)(`span`,{className:`flex-1`}),(0,V.jsx)(`span`,{className:`bubble-hints bubble-tool`,style:{"--i":2},"aria-hidden":`true`,children:de?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(DJ,{children:`↑`}),(0,V.jsx)(DJ,{children:`↓`}),`choose`,(0,V.jsx)(DJ,{children:`↵`}),`insert`]}):f?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(DJ,{children:`Esc`}),`close`]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(DJ,{children:`Shift`}),(0,V.jsx)(DJ,{children:`↵`}),`new line`]})}),(0,V.jsxs)(`span`,{"data-chat-composer-actions":`right`,className:`bubble-tool flex shrink-0 items-center gap-2`,style:{"--i":3},children:[We?(0,V.jsx)(Eq,{onStop:()=>void Re()}):null,(0,V.jsx)(Dq,{sending:c,disabled:!Ie,steering:We,onSend:()=>void Le()})]})]})]}),(0,V.jsx)(`input`,{ref:M,type:`file`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach files`,onChange:e=>{Me(e.target.files??[]),e.target.value=``}}),(0,V.jsx)(`input`,{ref:te,type:`file`,accept:`image/*`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach images`,onChange:e=>{Me(e.target.files??[]),e.target.value=``}}),u?(0,V.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-30 flex items-center justify-center rounded-[inherit] text-sm font-medium text-(--bubble-accent)`,children:`Drop to attach`}):null]})})}),(0,V.jsx)(sJ,{drawer:n,at:le?T:-1,onAt:E})]})}function AJ({open:e,onOpenChange:t}){let n=qT(e,KT.help),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(``),l=(0,m.useId)(),u=()=>{a||(t(!1),i(``),c(``))},d=async()=>{let e=r.trim();if(e&&!a){o(!0),c(``);try{H((await L(`sessions.start`,{request:e})).notice),t(!1),i(``)}catch(e){c(e instanceof Error?e.message:`That did not work. Try again.`)}finally{o(!1)}}};return(0,V.jsx)(zT,{open:n,label:`New session`,description:`Starts a task in a session of its own, in the background.`,onOpenChange:e=>{e||u()},dismissOnBackdrop:!a,className:`max-w-[460px]`,children:(0,V.jsxs)(`div`,{className:`flex w-full flex-col`,children:[(0,V.jsxs)(`div`,{className:`cs-dh`,children:[(0,V.jsx)(`h2`,{children:`New session`}),(0,V.jsx)(`p`,{className:`mt-[5px] text-[12.5px] leading-normal text-muted-foreground`,children:`It runs in the background and shows up in the sidebar; this window carries on with what it is doing.`})]}),(0,V.jsxs)(`div`,{className:`cs-db flex flex-col`,children:[(0,V.jsx)(`label`,{htmlFor:l,className:`mb-[7px] text-[12.5px] font-semibold`,children:`What should it do?`}),(0,V.jsx)(TB,{id:l,value:r,autoFocus:!0,disabled:a,"aria-invalid":s?!0:void 0,placeholder:`Fix the flaky login test, add dark mode to Settings…`,className:`cs-nsta max-h-60 min-h-[108px]`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d())}}),s?(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:s}):null]}),(0,V.jsxs)(`div`,{className:`cs-df`,children:[(0,V.jsxs)(`span`,{className:`mr-auto flex items-center gap-1.5 text-xs text-[var(--faint)]`,children:[(0,V.jsx)(IT,{chord:`Ctrl+Enter`}),` to start`]}),(0,V.jsx)(OT,{variant:`outline`,onClick:u,disabled:a,children:`Cancel`}),(0,V.jsx)(OT,{onClick:()=>void d(),disabled:!r.trim()||a,"aria-busy":a,children:a?`Starting…`:`Start session`})]})]})})}var jJ=.6;function MJ(e,t,n={}){return{initial:e?void 0:!1,animate:t,transition:{duration:jJ,...n}}}var NJ=(e,t)=>[0,Math.max(e,.001),Math.min(Math.max(t,e+.01),.999),1];function PJ(e,t=0,n=1){return MJ(e,{pathLength:[0,0,1,1],strokeOpacity:[0,0,1,1]},{pathLength:{duration:jJ,times:NJ(t,n),ease:`easeInOut`},strokeOpacity:{duration:jJ,times:NJ(t,t+.02)}})}function FJ(e,t){return MJ(e,{scale:[0,0,1.3,1]},{times:NJ(t,t+.18),ease:`easeOut`})}function IJ(e,t,n=1.3){return MJ(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 LJ=(e=.5,t=.5)=>({transformBox:`fill-box`,originX:e,originY:t});function RJ({play:e}){return(0,V.jsxs)(Yd.g,{style:LJ(.1,.9),...MJ(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)(Yd.circle,{cx:t,cy:11,r:1.15,fill:`currentColor`,stroke:`none`,...MJ(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 zJ({play:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Yd.path,{d:`M13 5h8`,...PJ(e,.15,.45)}),(0,V.jsx)(Yd.path,{d:`M13 12h8`,...PJ(e,.3,.6)}),(0,V.jsx)(Yd.path,{d:`M13 19h8`,...PJ(e,.45,.75)}),(0,V.jsx)(Yd.path,{d:`m3 17 2 2 4-4`,...PJ(e,.35,.7)}),(0,V.jsx)(Yd.path,{d:`m3 7 2 2 4-4`,...PJ(e,0,.35)})]})}function BJ({play:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Yd.circle,{cx:6,cy:19,r:3,style:LJ(),...IJ(e,0)}),(0,V.jsx)(Yd.path,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,...PJ(e,.1,.7)}),(0,V.jsx)(Yd.circle,{cx:18,cy:5,r:3,style:LJ(),...FJ(e,.62)})]})}function VJ({play:e}){return(0,V.jsxs)(Yd.g,{style:LJ(),...MJ(e,{scaleX:[1,.55,1.08,1],y:[0,-1,0,0]},{times:[0,.35,.65,1],ease:`easeInOut`}),children:[(0,V.jsx)(Yd.path,{d:`M12 5v16`,style:LJ(),...MJ(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 HJ={lobby:RJ,tasks:zJ,plan:BJ,knowledge:VJ};function UJ({id:e,play:t,className:n}){let r=HJ[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:1.8,strokeLinecap:`round`,strokeLinejoin:`round`,className:Y(`overflow-visible`,n),children:(0,V.jsx)(r,{play:t})},t):null}function WJ(){let e=(e,t)=>(0,V.jsxs)(`filter`,{id:e,x:`-20%`,y:`-35%`,width:`140%`,height:`170%`,colorInterpolationFilters:`sRGB`,children:[(0,V.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:t,result:`b`}),(0,V.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`rimA`}),(0,V.jsx)(`feGaussianBlur`,{in:`rimA`,stdDeviation:`0.6`,result:`rimB`}),(0,V.jsx)(`feComposite`,{in:`rimB`,in2:`shape`,operator:`in`,result:`rimC`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--hl)`},result:`hlc`}),(0,V.jsx)(`feComposite`,{in:`hlc`,in2:`rimC`,operator:`in`,result:`hl`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`shA`}),(0,V.jsx)(`feGaussianBlur`,{in:`shA`,stdDeviation:`0.6`,result:`shB`}),(0,V.jsx)(`feComposite`,{in:`shB`,in2:`shape`,operator:`in`,result:`shC`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--sh)`},result:`shc`}),(0,V.jsx)(`feComposite`,{in:`shc`,in2:`shC`,operator:`in`,result:`sh`}),(0,V.jsxs)(`feMerge`,{children:[(0,V.jsx)(`feMergeNode`,{in:`shape`}),(0,V.jsx)(`feMergeNode`,{in:`sh`}),(0,V.jsx)(`feMergeNode`,{in:`hl`})]})]});return(0,V.jsx)(`svg`,{width:`0`,height:`0`,className:`absolute`,"aria-hidden":`true`,focusable:`false`,children:(0,V.jsxs)(`defs`,{children:[e(`cs-baylit`,3.5),e(`cs-worklit`,3.2),(0,V.jsxs)(`filter`,{id:`cs-bayedge`,x:`-20%`,y:`-35%`,width:`140%`,height:`170%`,colorInterpolationFilters:`sRGB`,children:[(0,V.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`3.5`,result:`b`}),(0,V.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`tS0`}),(0,V.jsx)(`feGaussianBlur`,{in:`tS0`,stdDeviation:`0.3`,result:`tS1`}),(0,V.jsx)(`feComposite`,{in:`tS1`,in2:`shape`,operator:`in`,result:`tS`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--ehl)`},result:`tc`}),(0,V.jsx)(`feComposite`,{in:`tc`,in2:`tS`,operator:`in`,result:`eh`}),(0,V.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,V.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`bS0`}),(0,V.jsx)(`feGaussianBlur`,{in:`bS0`,stdDeviation:`0.3`,result:`bS1`}),(0,V.jsx)(`feComposite`,{in:`bS1`,in2:`shape`,operator:`in`,result:`bS`}),(0,V.jsx)(`feFlood`,{style:{floodColor:`var(--esh)`},result:`bc`}),(0,V.jsx)(`feComposite`,{in:`bc`,in2:`bS`,operator:`in`,result:`es`}),(0,V.jsxs)(`feMerge`,{children:[(0,V.jsx)(`feMergeNode`,{in:`shape`}),(0,V.jsx)(`feMergeNode`,{in:`eh`}),(0,V.jsx)(`feMergeNode`,{in:`es`})]})]})]})})}function GJ({className:e,style:t}){return(0,V.jsxs)(`div`,{className:e,"aria-hidden":`true`,style:t,children:[(0,V.jsx)(`div`,{className:`cs-layer cs-edge`,children:(0,V.jsx)(`div`,{className:`cs-bb`})}),(0,V.jsx)(`div`,{className:`cs-layer cs-fill`,children:(0,V.jsx)(`div`,{className:`cs-bb`})})]})}function KJ(e,t=e){let[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(void 0);(0,m.useEffect)(()=>()=>window.clearTimeout(o.current),[]);let s=(0,m.useCallback)(()=>{window.clearTimeout(o.current),r(!0)},[]),c=(0,m.useCallback)(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(()=>r(!1),e)},[e]),l=(0,m.useCallback)(()=>{window.clearTimeout(o.current),r(!0),o.current=window.setTimeout(()=>r(!1),t)},[t]),u=(0,m.useRef)(void 0);return(0,m.useEffect)(()=>()=>u.current?.(),[]),{open:n||i,flash:l,close:()=>{window.clearTimeout(o.current),r(!1)},handlers:{onPointerDown:e=>{if(e.pointerType!==`touch`)return;let t=e.currentTarget;if(n)e.target.closest(`[role='tab']`)&&c();else{window.clearTimeout(o.current),r(!0),u.current?.();let e=e=>{t.contains(e.target)||(window.clearTimeout(o.current),r(!1),u.current?.())};document.addEventListener(`pointerdown`,e,!0);let n=e=>{e.preventDefault(),e.stopPropagation()};t.addEventListener(`click`,n,{capture:!0,once:!0}),window.setTimeout(()=>t.removeEventListener(`click`,n,!0),500),u.current=()=>{document.removeEventListener(`pointerdown`,e,!0),u.current=void 0}}},onPointerEnter:e=>{e.pointerType!==`touch`&&s()},onPointerLeave:e=>{e.pointerType!==`touch`&&c()},onFocus:()=>a(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||a(!1)}}}}function qJ({id:e}){let t={width:15,height:15,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0};return e===`lobby`?(0,V.jsx)(`svg`,{...t,children:(0,V.jsx)(`path`,{d:`M21 12a8 8 0 01-11.6 7.1L4 20l1-4.6A8 8 0 1121 12z`})}):e===`tasks`?(0,V.jsxs)(`svg`,{...t,children:[(0,V.jsx)(`path`,{d:`M9 11l3 3L22 4`}),(0,V.jsx)(`path`,{d:`M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11`})]}):e===`plan`?(0,V.jsxs)(`svg`,{...t,children:[(0,V.jsx)(`path`,{d:`M3 6l6-3 6 3 6-3v15l-6 3-6-3-6 3z`}),(0,V.jsx)(`path`,{d:`M9 3v15M15 6v15`})]}):e===`knowledge`?(0,V.jsxs)(`svg`,{...t,children:[(0,V.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 016.5 17H20`}),(0,V.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 014 19.5v-15A2.5 2.5 0 016.5 2z`})]}):(0,V.jsxs)(`svg`,{...t,children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,V.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 00.3 1.8l.1.1a2 2 0 11-2.8 2.8l-.1-.1a1.7 1.7 0 00-1.8-.3 1.7 1.7 0 00-1 1.5V21a2 2 0 11-4 0v-.1a1.7 1.7 0 00-1.1-1.5 1.7 1.7 0 00-1.8.3l-.1.1a2 2 0 11-2.8-2.8l.1-.1a1.7 1.7 0 00.3-1.8 1.7 1.7 0 00-1.5-1H3a2 2 0 110-4h.1a1.7 1.7 0 001.5-1.1 1.7 1.7 0 00-.3-1.8l-.1-.1a2 2 0 112.8-2.8l.1.1a1.7 1.7 0 001.8.3H9a1.7 1.7 0 001-1.5V3a2 2 0 114 0v.1a1.7 1.7 0 001 1.5 1.7 1.7 0 001.8-.3l.1-.1a2 2 0 112.8 2.8l-.1.1a1.7 1.7 0 00-.3 1.8V9a1.7 1.7 0 001.5 1H21a2 2 0 110 4h-.1a1.7 1.7 0 00-1.5 1z`})]})}function JJ({tabs:e,activeId:t,onSelect:n}){let r=(0,m.useRef)(null),i=(0,m.useRef)({}),[a,o]=(0,m.useState)(346),s=e.map(e=>e.label).join(`|`),[c,l]=(0,m.useState)({}),u=(0,m.useRef)(t);(0,m.useEffect)(()=>{u.current!==t&&(u.current=t,t&&!window.matchMedia(`(prefers-reduced-motion: reduce)`).matches&&l(e=>({...e,[t]:(e[t]??0)+1})))},[t]),(0,m.useLayoutEffect)(()=>{let e=()=>{let e=r.current?[...r.current.querySelectorAll(`[role='tab']`)]:[],t=e.length?Math.ceil(e.reduce((e,t)=>e+t.offsetWidth,0)+(e.length-1)*2)+6:346;o(t)};e(),document.fonts?.ready.then(e)},[s]);function d(r){if(r.key===`ArrowDown`&&!r.altKey){EE()&&r.preventDefault();return}let a=r.key===`ArrowRight`?1:r.key===`ArrowLeft`?-1:0;if(!a||e.length===0)return;r.preventDefault();let o=r.target.closest(`[role='tab']`)?.id.replace(/^tab-/,``)??t,s=e[(Math.max(0,e.findIndex(e=>e.id===o))+a+e.length)%e.length];OE.active=!0,OE.to=s.id,window.setTimeout(()=>{OE.active=!1,OE.to=void 0},3e3),n(s.id),i.current[s.id]?.focus({preventScroll:!0})}let f={"--wT":`${a}px`,"--hT":`40px`};return{vars:f,ghost:(0,V.jsx)(GJ,{className:`cs-gt`,style:f}),bay:(0,V.jsx)(`div`,{className:`cs-tbwrap`,style:f,children:(0,V.jsx)(`div`,{className:`cs-tbx`,children:(0,V.jsx)(`div`,{className:`cs-tbo`,"data-none":t?void 0:``,children:(0,V.jsx)(`div`,{ref:r,role:`tablist`,"aria-label":`Lobby tabs`,onKeyDown:d,className:`cs-track`,children:e.map((e,n)=>(0,V.jsxs)(`a`,{ref:t=>{i.current[e.id]=t},role:`tab`,id:`tab-${e.id}`,href:`#/${e.id}`,"aria-selected":e.id===t,"aria-keyshortcuts":e.key,title:`${e.label} · ${e.key.replace(`+`,` `)}`,tabIndex:e.id===t||!t&&n===0?0:-1,className:`cs-tab`,style:{"--i":n},children:[(0,V.jsx)(`span`,{className:`cs-ti`,children:(0,V.jsx)(UJ,{id:e.id,play:c[e.id]??0,className:`size-[15px]`})}),(0,V.jsx)(`span`,{className:`cs-tl`,"data-t":e.label,children:e.label})]},e.id))})})})})}}function YJ({children:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(GJ,{className:`cs-gr`}),(0,V.jsx)(`div`,{className:Y(`cs-rbx`),children:e})]})}function XJ(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 ZJ(e,t){let n=e?.sessionId,r={id:`here`,name:e?.sessionName?.trim()||e?.workspace?.name||`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:XJ(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}));i.sort((e,t)=>Number(e.state===`exited`)-Number(t.state===`exited`));let s=new Set([...a,...o.map(e=>e.sessionId)]),c=(t?.saved??[]).filter(e=>!e.archived&&!s.has(e.sessionId)).map(e=>({id:`saved:${e.sessionId}`,name:e.name,where:`saved`,state:`exited`,waiting:0,sessionId:e.sessionId,at:e.at}));return[r,...i,...o,...c]}var QJ=`app.sidebar.pinned`,$J=()=>ZR(QJ),eY={w:244,h:`min(600px, calc(100vh - 40px))`},tY=`cs-iconbtn cs-sm`;function nY({label:e,hint:t,side:n=`bottom`,children:r}){return(0,V.jsxs)(SI,{children:[(0,V.jsx)(CI,{asChild:!0,children:r}),(0,V.jsxs)(wI,{side:n,children:[e,` `,t?(0,V.jsx)(IT,{chord:t}):null]})]})}function rY(){let e=vE(`status`).data;return ZJ(e,eR(`sessions.list`,{},[`sessions`]).data)}async function iY(e){if(e.where===`here`)return iE(`#/lobby`);if(e.where===`elsewhere`)return void H.info(`${e.name} runs in another terminal. Switch to that terminal to work in it.`);await U(`sessions.switch`,e.key?{key:e.key}:{sessionId:e.sessionId})&&iE(`#/lobby`)}function aY(){return(0,m.useCallback)(iY,[])}var oY={entries:[]};async function sY(e){let t=oY.entries.filter(e=>e.where!==`elsewhere`),n=t.findIndex(e=>e.where===`here`);if(t.length<2||n<0)return void H.info(`No other session to switch to.`);oY.flash?.(),await iY(t[(n+e+t.length)%t.length])}function cY({entry:e}){return e.where!==`elsewhere`&&e.state===`asking`?(0,V.jsxs)(`span`,{className:`cs-badge`,children:[(0,V.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,V.jsx)(`path`,{d:`M9.1 9a3 3 0 015.8 1c0 2-3 2.5-3 4M12 17h.01`})]}),e.waiting,(0,V.jsxs)(`span`,{className:`sr-only`,children:[e.waiting===1?` question`:` questions`,`, Waiting`]})]}):e.where!==`elsewhere`&&(e.state===`working`||e.state===`starting`)?(0,V.jsxs)(`span`,{className:Y(`inline-flex shrink-0`,e.state===`working`?`text-primary`:`text-muted-foreground`),children:[(0,V.jsx)(sp,{"aria-hidden":`true`,className:`session-spin size-3.5`}),(0,V.jsx)(`span`,{className:`sr-only`,children:e.state===`working`?`Working`:`Starting`})]}):(0,V.jsx)(`span`,{className:`sr-only`,children:e.where===`elsewhere`?`Other terminal`:e.state===`exited`?`Ended`:`Idle`})}var lY={here:`Current`,background:`Background`,elsewhere:`Other terminal`,saved:`Recent`};function uY(e){let t=e.key?{key:e.key}:{sessionId:e.sessionId};return U(`sessions.archive`,t,{undo:()=>void U(`sessions.archive`,{...t,archived:!1})})}function dY({entry:e,onDone:t}){let[n,r]=(0,m.useState)(e.name),i=(0,m.useRef)(!1),a=async()=>{if(i.current)return;i.current=!0;let r=n.replace(/\s+/g,` `).trim();r&&r!==e.name&&await U(`sessions.rename`,{...e.where===`here`?{}:{key:e.key},name:r}),t()};return(0,V.jsx)(`input`,{value:n,autoFocus:!0,maxLength:120,"aria-label":`New name for ${e.name}`,onFocus:e=>e.currentTarget.select(),onChange:e=>r(e.target.value),onBlur:()=>void a(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),a()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i.current=!0,t())},className:`h-6 w-full min-w-0 rounded-md bg-[var(--fill)] px-1.5 text-[13px] text-foreground outline-none ring-2 ring-ring`})}function fY({entry:e,index:t}){let n=aY(),[r,i]=(0,m.useState)(!1),a=e.state===`exited`||e.where===`elsewhere`,o=e.where===`here`||e.where===`background`,s=e.where===`background`&&e.state===`exited`&&!!e.key||e.where===`saved`,c=e.where===`saved`,l=o||s||c,u={"--i":t};return(0,V.jsxs)(`li`,{className:`cs-srow session-item`,children:[r?(0,V.jsx)(`div`,{className:`cs-sr`,"data-active":e.where===`here`||void 0,style:u,children:(0,V.jsx)(dY,{entry:e,onDone:()=>i(!1)})}):(0,V.jsxs)(`button`,{type:`button`,"aria-current":e.where===`here`?`true`:void 0,"aria-label":e.where===`here`?`${e.name}, this window`:e.where===`elsewhere`?`${e.name}, in another terminal`:`Switch to ${e.name}`,title:e.name,"data-where":e.where,"data-state":e.state,"data-dim":a||void 0,onClick:()=>void n(e),onDoubleClick:e=>{o&&(e.preventDefault(),i(!0))},className:`cs-sr session-row`,style:u,children:[(0,V.jsx)(`span`,{className:`cs-grow`,children:e.name}),(0,V.jsx)(`span`,{className:Y(`flex shrink-0 items-center`,l&&`cs-sstate`),children:(0,V.jsx)(cY,{entry:e})})]}),!r&&l?(0,V.jsxs)(`span`,{className:`cs-sacts`,children:[o?(0,V.jsx)(nY,{label:`Rename`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Rename ${e.name}`,onClick:()=>i(!0),className:`cs-sact`,children:(0,V.jsx)(ym,{"aria-hidden":`true`,className:`size-3.5`})})}):null,s?(0,V.jsx)(nY,{label:`Archive`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Archive ${e.name}`,onClick:()=>void uY(e),className:`cs-sact`,children:(0,V.jsx)(Af,{"aria-hidden":`true`,className:`size-3.5`})})}):null,c?(0,V.jsx)(qL,{iconOnly:!0,className:`cs-sact`,side:`bottom`,label:`Delete ${e.name}`,icon:rh,variant:`destructive`,title:`Delete ${e.name}?`,description:`Its conversation file is removed for good. Archive it instead to keep it.`,confirmLabel:`Delete`,onConfirm:()=>void U(`sessions.delete`,{sessionId:e.sessionId})}):null]}):null]})}function pY({id:e,label:t,entries:n,start:r,archivable:i=!1}){let[a,o]=QR(`app.sidebar.${e}`),s=(0,m.useId)();return n.length===0?null:(0,V.jsxs)(`section`,{"aria-label":t,className:`group/shelf flex flex-col`,children:[(0,V.jsxs)(`div`,{className:`cs-sh`,style:{"--i":r},children:[(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":!a,"aria-controls":s,onClick:o,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left outline-none hover:text-foreground focus-visible:underline`,children:[(0,V.jsx)(`span`,{children:t}),a?(0,V.jsx)(`span`,{className:`tabular-nums`,children:n.length}):null,(0,V.jsx)(Yf,{"aria-hidden":`true`,className:Y(`size-3 opacity-0 transition-[opacity,rotate] duration-150 group-hover/shelf:opacity-100 group-focus-within/shelf:opacity-100`,a&&`-rotate-90 opacity-100`)})]}),i?(0,V.jsx)(`button`,{type:`button`,onClick:()=>void(async()=>{for(let e of n)await U(`sessions.archive`,e.key?{key:e.key}:{sessionId:e.sessionId})})(),className:`shrink-0 outline-none hover:text-foreground focus-visible:underline`,children:`Archive all`}):null]}),a?null:(0,V.jsx)(`ul`,{id:s,className:`flex flex-col`,children:n.map((e,t)=>(0,V.jsx)(fY,{entry:e,index:r+1+t},e.id))})]})}function mY(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean),r=`${e.name} ${lY[e.where]}`.toLowerCase();return n.every(e=>r.includes(e))}function hY({query:e,onQuery:t,onNew:n}){return(0,V.jsxs)(`label`,{className:`cs-sr cs-search`,style:{"--i":0},children:[(0,V.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,V.jsx)(`path`,{d:`M21 21l-4.3-4.3`})]}),(0,V.jsx)(`input`,{type:`search`,value:e,"aria-label":`Search sessions`,placeholder:`Search`,onChange:e=>t(e.target.value),onKeyDown:n=>{n.key===`Escape`&&e&&(n.preventDefault(),n.stopPropagation(),t(``))}}),(0,V.jsx)(nY,{label:`New session`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`New session`,"aria-haspopup":`dialog`,onClick:n,className:`flex text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground`,children:(0,V.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M12 20h9`}),(0,V.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`})]})})})]})}function gY({query:e}){let t=rY(),n=t.filter(t=>mY(t,e)),r=n.filter(e=>e.where===`here`&&e.state!==`exited`),i=n.filter(e=>e.where===`background`&&e.state!==`exited`),a=n.filter(e=>e.where===`elsewhere`),o=n.filter(e=>e.where!==`elsewhere`&&e.state===`exited`),s=1,c=e=>{let t=s;return s+=e+1,t},l=c(r.length),u=c(i.length);return(0,V.jsxs)(`nav`,{"aria-label":`Sessions list`,className:`cs-sblist`,children:[n.length===0?(0,V.jsxs)(`p`,{className:`px-2.5 py-1.5 text-xs text-muted-foreground`,children:[`No sessions match “`,e.trim(),`”.`]}):null,r.length>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`cs-sh`,style:{"--i":l},children:`Current`}),(0,V.jsx)(`ul`,{className:`flex flex-col`,children:r.map((e,t)=>(0,V.jsx)(fY,{entry:e,index:l+1+t},e.id))})]}):null,i.length>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`cs-sh`,style:{"--i":u},children:`Background`}),(0,V.jsx)(`ul`,{className:`flex flex-col`,children:i.map((e,t)=>(0,V.jsx)(fY,{entry:e,index:u+1+t},e.id))})]}):!e.trim()&&t.length===1?(0,V.jsx)(`p`,{className:`cs-sh`,style:{"--i":u},children:`No other sessions are running.`}):null,(0,V.jsx)(pY,{id:`elsewhere`,label:`Other terminals`,entries:a,start:c(a.length)}),(0,V.jsx)(pY,{id:`ended`,label:`Recent`,entries:o,start:c(o.length),archivable:!0})]})}function _Y({route:e,keys:t,onHelp:n}){let r=t.settings??`Alt+S`;return(0,V.jsxs)(`div`,{className:`cs-sbfoot`,children:[(0,V.jsxs)(`a`,{href:`#/settings`,"aria-label":`Settings`,"aria-current":e.kind===`settings`?`page`:void 0,"aria-keyshortcuts":r,className:`cs-sr`,style:{"--i":20},children:[(0,V.jsx)(qJ,{id:`settings`}),(0,V.jsx)(`span`,{className:`cs-grow`,children:`Settings`}),(0,V.jsx)(IT,{chord:r})]}),(0,V.jsxs)(`div`,{className:`cs-sr cs-tools`,style:{"--i":21},children:[(0,V.jsx)(NK,{hint:t.help??`Alt+H`,onHelp:n,className:tY}),(0,V.jsx)(PK,{className:tY}),(0,V.jsx)(IK,{className:tY}),(0,V.jsx)(LK,{className:tY})]})]})}function vY(e){let[t,n]=QR(QJ),r=KJ(160,1600);oY.entries=rY(),oY.flash=r.flash;let[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),c=t||r.open||o,l={"--wL":`${c?eY.w:122}px`,"--hL":c?eY.h:`40px`,"--sb-open-h":eY.h},u=(0,m.useCallback)(()=>s(!0),[]);return{open:c,pinned:t,ghost:(0,V.jsx)(GJ,{className:`cs-gl`,style:l}),bay:(0,V.jsxs)(`div`,{className:`cs-sbwrap`,style:l,...r.handlers,children:[(0,V.jsxs)(`aside`,{id:`app-sidebar`,"aria-label":`Sidebar`,className:`cs-sbx`,children:[(0,V.jsxs)(`div`,{className:`cs-sbmini`,inert:c,children:[(0,V.jsx)(nY,{label:t?`Unpin sidebar`:`Pin sidebar`,hint:e.keys.sidebar,side:`bottom`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Sessions`,"aria-pressed":t,"aria-keyshortcuts":e.keys.sidebar,onClick:n,className:`cs-iconbtn`,children:(0,V.jsx)(qJ,{id:`lobby`})})}),(0,V.jsx)(nY,{label:`New session`,side:`bottom`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`New session`,"aria-haspopup":`dialog`,onClick:u,className:`cs-iconbtn`,children:(0,V.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M12 20h9`}),(0,V.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`})]})})}),(0,V.jsx)(nY,{label:`Settings`,hint:e.keys.settings??`Alt+S`,side:`bottom`,children:(0,V.jsx)(`a`,{href:`#/settings`,"aria-label":`Settings`,"aria-current":e.route.kind===`settings`?`page`:void 0,className:`cs-iconbtn`,children:(0,V.jsx)(qJ,{id:`settings`})})})]}),(0,V.jsxs)(`div`,{className:`cs-sbfull`,inert:!c,children:[(0,V.jsx)(hY,{query:i,onQuery:a,onNew:u}),(0,V.jsx)(gY,{query:i}),(0,V.jsx)(_Y,{...e})]})]}),(0,V.jsx)(AJ,{open:o,onOpenChange:s})]})}}var yY=`bot-lobby.terminal.open`,bY=`bot-lobby.terminal.height`,xY=`bot-lobby.terminal.popup`,SY={start:280,min:140},CY=new Set,wY,TY,EY;function DY(e){try{return localStorage.getItem(e)}catch{return null}}function OY(e,t){try{localStorage.setItem(e,t)}catch{}}function kY(){for(let e of[...CY])e()}function AY(e){return CY.add(e),()=>{CY.delete(e)}}function jY(){return wY??=DY(yY)===`1`,wY}function MY(){if(TY===void 0){let e=Number(DY(bY));TY=e>=SY.min?e:SY.start}return TY}function NY(e){wY=e,OY(yY,e?`1`:`0`),kY()}function PY(){NY(!jY())}function FY(e){TY=Math.max(SY.min,Math.round(e)),OY(bY,String(TY)),kY()}function IY(){return(0,m.useSyncExternalStore)(AY,jY,()=>!1)}function LY(){return(0,m.useSyncExternalStore)(AY,MY,()=>SY.start)}function RY(){return EY??=DY(xY)===`1`,EY}function zY(e){EY=e,OY(xY,e?`1`:`0`),kY()}function BY(){return(0,m.useSyncExternalStore)(AY,RY,()=>!1)}var VY=`modulepreload`,HY=function(e){return`/`+e},UY={},WY=function(e){return e.pathname.endsWith(`.css`)},GY=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=HY(t,n);let r=s(t);if(r.href in UY)return;UY[r.href]=!0;let i=WY(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`:VY,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)})},KY=(0,m.lazy)(()=>GY(()=>import(`./TerminalView-BW7Ik8CM.js`),__vite__mapDeps([0,1,2,3]))),qY=`inline-flex size-6 items-center justify-center text-foreground/80 outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40 aria-pressed:bg-accent aria-pressed:text-foreground`;function JY({label:e,hint:t,children:n}){return(0,V.jsxs)(SI,{children:[(0,V.jsx)(CI,{asChild:!0,children:n}),(0,V.jsxs)(wI,{side:`top`,children:[e,` `,t?(0,V.jsx)(IT,{chord:t}):null]})]})}function YY({hint:e,className:t}){let n=IY();return(0,V.jsx)(JY,{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:PY,className:t,children:(0,V.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M4 17l6-6-6-6M12 19h8`})})})})}function XY(e){let[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(``),a=(0,m.useCallback)(async()=>{try{n(await L(`terminal.list`,{})),i(``)}catch(e){i(e instanceof Error?e.message:`The terminals could not be read.`)}},[]);return(0,m.useEffect)(()=>{e&&a()},[e,a]),{list:t,error:r,reload:a}}function ZY({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":SY.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&&FY(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:()=>FY(SY.start),onKeyDown:n=>{(n.key===`ArrowUp`||n.key===`ArrowDown`)&&(n.preventDefault(),FY(Math.min(t,e+(n.key===`ArrowUp`?24:-24))))}})}function QY({toggleKey:e}){let t=IY(),n=BY(),r=LY(),i=qT(t&&n,KT.sheet),{list:a,error:o,reload:s}=XY(t),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(()=>Math.round(window.innerHeight*.7)),h=a?.terminals??[],g=h.find(e=>e.id===c)??h.at(-1);(0,m.useEffect)(()=>{let e=()=>p(Math.round(window.innerHeight*.7));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let _=(0,m.useCallback)(async()=>{d(!0);try{let e=await L(`terminal.open`,{cols:100,rows:24});l(e.id),await s()}catch(e){H.error(e instanceof Error?e.message:`The terminal did not start.`)}finally{d(!1)}},[s]),v=(0,m.useCallback)(async e=>{try{await L(`terminal.close`,{id:e})}catch{}await s()},[s]);(0,m.useEffect)(()=>{if(!t||h.length<2)return;let e=e=>{if(!e.ctrlKey||e.altKey||e.metaKey||e.key!==`PageDown`&&e.key!==`PageUp`)return;e.preventDefault();let t=Math.max(0,h.findIndex(e=>e.id===g?.id)),n=h[(t+(e.key===`PageDown`?1:-1)+h.length)%h.length];l(n.id)};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[t,h,g?.id]);let y=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!t){y.current=!1;return}!a||!a.available||a.terminals.length>0||y.current||u||(y.current=!0,_())},[t,a,u,_]);let b=t&&!n?Math.min(r,f):0;if((0,m.useEffect)(()=>{let e=document.documentElement;return b?e.style.setProperty(`--terminal-h`,`${b}px`):e.style.removeProperty(`--terminal-h`),()=>{e.style.removeProperty(`--terminal-h`)}},[b]),!t)return null;let x=(0,V.jsx)($Y,{list:a,error:o,terminals:h,shown:g,busy:u,popup:n,toggleKey:e,onPick:l,onStart:()=>void _(),onEnd:e=>void v(e),onReload:()=>void s()});return n?(0,V.jsx)(zT,{open:i,onOpenChange:e=>{e||NY(!1)},label:`Terminal`,className:`terminal-pop h-[min(72svh,40rem)] max-h-none max-w-5xl`,onEscapeKeyDown:e=>{e.target?.closest?.(`.xterm`)&&e.preventDefault()},children:(0,V.jsx)(`div`,{id:`terminal-drawer`,className:`flex min-h-0 flex-1`,children:x})}):(0,V.jsxs)(`section`,{id:`terminal-drawer`,"aria-label":`Terminal`,className:`terminal-drawer relative flex shrink-0 border-t border-border`,style:{height:Math.min(r,f)},children:[(0,V.jsx)(ZY,{height:Math.min(r,f),max:f}),x]})}function $Y({list:e,error:t,terminals:n,shown:r,busy:i,popup:a,toggleKey:o,onPick:s,onStart:c,onEnd:l,onReload:u}){let d=(0,V.jsxs)(`div`,{className:`terminal-tools pointer-events-auto inline-flex items-center overflow-hidden rounded-md border border-border/80 bg-background shadow-xs`,children:[(0,V.jsx)(JY,{label:`New terminal`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`New terminal`,disabled:i||e?.available===!1,onClick:c,className:qY,children:(0,V.jsx)(Dm,{"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)(JY,{label:`End this terminal`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`End this terminal`,disabled:!r,onClick:()=>r&&l(r.id),className:qY,children:(0,V.jsx)(rh,{"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)(JY,{label:a?`Back to the drawer`:`Open in a pop-up`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Pop out terminal`,"aria-pressed":a,onClick:()=>zY(!a),className:qY,children:(0,V.jsx)(xm,{"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)(JY,{label:`Hide terminal`,hint:o,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Hide terminal`,onClick:()=>NY(!1),className:qY,children:a?(0,V.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5`}):(0,V.jsx)(Yf,{"aria-hidden":`true`,className:`size-3.5`})})})]}),f=(0,V.jsx)(V.Fragment,{children:e&&!e.available?(0,V.jsx)(`p`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:e.reason}):t?(0,V.jsx)(`p`,{role:`alert`,className:`flex h-full items-center justify-center px-6 text-center text-sm text-destructive`,children:t}):(0,V.jsxs)(m.Suspense,{fallback:(0,V.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`Loading the terminal…`}),children:[e&&n.length===0&&!i?(0,V.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`No terminal is running. Start one with New terminal.`}):null,n.map(e=>(0,V.jsx)(KY,{id:e.id,active:e.id===r?.id,toggleKey:o,onExit:u},e.id))]})}),p=n.length>1?(0,V.jsx)(`nav`,{"aria-label":`Terminals`,className:Y(`flex w-36 shrink-0 flex-col gap-0.5 overflow-y-auto border-l border-border px-1 pb-1`,a?`pt-2`:`pt-10`),children:n.map(e=>(0,V.jsxs)(`button`,{type:`button`,"aria-current":e.id===r?.id?`true`:void 0,onClick:()=>s(e.id),className:Y(`flex h-6 min-w-0 items-center gap-1.5 rounded px-1.5 text-left text-xs text-muted-foreground outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-accent aria-[current=true]:text-foreground`,!e.alive&&`opacity-60`),children:[(0,V.jsx)(Zm,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.title}),e.alive?null:(0,V.jsx)(`span`,{className:`sr-only`,children:`, ended`})]},e.id))}):null;return a?(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,V.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border/70 pr-2 pl-4`,children:[(0,V.jsx)(Zm,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`flex-1 text-sm font-medium`,children:`Terminal`}),d]}),(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,V.jsx)(`div`,{className:`min-w-0 flex-1 py-2 pl-2`,children:(0,V.jsx)(`div`,{className:`relative h-full`,children:f})}),p]})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[f,(0,V.jsx)(`div`,{className:`pointer-events-none absolute top-2 right-2 z-20`,children:d})]}),p]})}var eX=(0,m.lazy)(()=>GY(()=>import(`./CodeSurface-v19_sKLO.js`),__vite__mapDeps([4,1,2]))),tX=`inline-flex size-7 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40 aria-pressed:bg-accent aria-pressed:text-foreground`;function nX({label:e,hint:t,children:n}){return(0,V.jsxs)(SI,{children:[(0,V.jsx)(CI,{asChild:!0,children:n}),(0,V.jsxs)(wI,{side:`bottom`,children:[e,` `,t?(0,V.jsx)(IT,{chord:t}):null]})]})}function rX({hint:e,className:t}){let{open:n}=dL();return(0,V.jsx)(nX,{label:`Code and changes`,hint:e,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Code`,"aria-pressed":n,"aria-keyshortcuts":e,onClick:()=>n?lL():cL(),className:t,children:(0,V.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M16 18l6-6-6-6M8 6l-6 6 6 6`})})})})}var iX={modified:{letter:`M`,word:`Modified`,tone:`text-warning`},added:{letter:`A`,word:`Added`,tone:`text-success`},untracked:{letter:`U`,word:`New, not committed`,tone:`text-success`},deleted:{letter:`D`,word:`Deleted`,tone:`text-destructive`},renamed:{letter:`R`,word:`Renamed`,tone:`text-primary`}};function aX(e){let t=e.lastIndexOf(`/`);return t<0?{dir:``,name:e}:{dir:e.slice(0,t),name:e.slice(t+1)}}function oX({change:e,className:t}){return e.additions===void 0&&e.deletions===void 0?null:(0,V.jsxs)(`span`,{className:Y(`shrink-0 font-mono text-[0.6875rem] tabular-nums`,t),children:[(0,V.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions??0]}),` `,(0,V.jsxs)(`span`,{className:`text-destructive`,children:[`−`,e.deletions??0]})]})}function sX(){let[e,t]=(0,m.useState)(()=>document.documentElement.classList.contains(`dark`));return(0,m.useEffect)(()=>{let e=document.documentElement,n=new MutationObserver(()=>t(e.classList.contains(`dark`)));return n.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>n.disconnect()},[]),e}function cX({changes:e,loading:t,error:n,current:r,onPick:i,onRefresh:a}){let[o,s]=(0,m.useState)(``),c=e?.files??[],l=c.reduce((e,t)=>({additions:e.additions+(t.additions??0),deletions:e.deletions+(t.deletions??0)}),{additions:0,deletions:0});function u(e){e.preventDefault();let t=o.trim();t&&(i(t),s(``))}return(0,V.jsxs)(`nav`,{"aria-label":`Changed files`,className:`code-rail flex w-64 shrink-0 flex-col border-r border-border max-md:w-52`,children:[(0,V.jsx)(`form`,{onSubmit:u,className:`border-b border-border p-2`,children:(0,V.jsxs)(`label`,{className:`flex h-8 items-center gap-2 rounded-md border border-input bg-background px-2 transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/20`,children:[(0,V.jsx)(Vm,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),"aria-label":`Open a file by path`,placeholder:`Open a file by path…`,spellCheck:!1,autoComplete:`off`,className:`h-full min-w-0 flex-1 bg-transparent font-mono text-xs outline-none placeholder:font-sans placeholder:text-muted-foreground`})]})}),(0,V.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 px-3 text-xs`,children:[(0,V.jsx)(`span`,{className:`font-medium text-foreground`,children:`Changes`}),(0,V.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[c.length,e?.truncated?`+`:``]}),(0,V.jsx)(oX,{change:l,className:`ml-auto`}),(0,V.jsx)(nX,{label:`Read the changes again`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Refresh changes`,onClick:a,disabled:t,className:Y(tX,`-mr-1.5 size-6`,c.length?``:`ml-auto`),children:(0,V.jsx)(km,{"aria-hidden":`true`,className:Y(`size-3.5`,t&&`animate-spin motion-reduce:animate-none`)})})})]}),(0,V.jsxs)(`ul`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-1.5 pb-2`,children:[c.map(e=>{let{dir:t,name:n}=aX(e.path),a=iX[e.status];return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,onClick:()=>i(e.path),"aria-current":e.path===r?`true`:void 0,title:e.from?`${e.from} → ${e.path}`:e.path,className:`group/row flex h-7 w-full min-w-0 items-center gap-2 rounded-md px-1.5 text-left text-[0.8125rem] outline-none transition-colors duration-150 hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-accent`,children:[(0,V.jsx)(`span`,{"aria-label":a.word,className:Y(`w-3 shrink-0 text-center font-mono text-[0.6875rem] font-semibold`,a.tone),children:a.letter}),(0,V.jsxs)(`span`,{className:Y(`min-w-0 flex-1 truncate`,e.status===`deleted`&&`text-muted-foreground line-through decoration-muted-foreground/50`),children:[n,t?(0,V.jsx)(`span`,{className:`ml-1.5 text-xs text-muted-foreground`,children:t}):null]}),(0,V.jsx)(oX,{change:e})]})},e.path)}),e&&!e.git?(0,V.jsx)(`li`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:`This folder is not a git repository, so there are no changes to show. Open a file by its path above.`}):null,e?.git&&c.length===0?(0,V.jsx)(`li`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:`No changes since the last commit.`}):null,n?(0,V.jsx)(`li`,{role:`alert`,className:`px-2 py-3 text-xs text-destructive`,children:n}):null]})]})}function lX(e){let[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(!1),s=(0,m.useRef)(0),c=(0,m.useCallback)(async e=>{let t=++s.current;o(!0),i(void 0);try{let r=await L(`code.read`,{path:e});t===s.current&&n(e=>({file:r,version:(e?.version??0)+1}))}catch(e){t===s.current&&(n(void 0),i(e instanceof Error?e.message:String(e)))}finally{t===s.current&&o(!1)}},[]);return(0,m.useEffect)(()=>{e?c(e):(s.current++,n(void 0),i(void 0))},[e,c]),{loaded:t,setLoaded:n,error:r,loading:a,reload:()=>e&&c(e)}}function uX({requested:e,requestedMode:t,request:n,codeKey:r,onClose:i,onDirtyChange:a,closeAsked:o}){let s=eR(`code.changes`,{},[`lobby`,`tasks`]),[c,l]=(0,m.useState)(e),[u,d]=(0,m.useState)(t??`code`),{loaded:f,setLoaded:p,error:h,loading:g,reload:_}=lX(c),[v,y]=(0,m.useState)(),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(),E=vL(),D=yL(),O=sX(),k=f?.file,ee=v!==void 0&&v!==k?.contents;(0,m.useEffect)(()=>a(ee),[ee,a]),(0,m.useEffect)(()=>{if(!e||e===c){t&&d(t);return}j({kind:`open`,path:e})},[n]),(0,m.useEffect)(()=>{if(!c&&s.data?.files[0]){let e=s.data.files.find(e=>e.status!==`deleted`)??s.data.files[0];l(e.path),t||d(`diff`)}},[s.data]),(0,m.useEffect)(()=>{k&&k.path!==c&&l(k.path)},[k?.path]),(0,m.useEffect)(()=>{o&&j({kind:`close`})},[o]);function A(e){if(T(void 0),C(!1),e.kind===`close`){i();return}y(void 0),l(e.path)}function j(e){(e.kind!==`open`||e.path!==c)&&(ee?T(e):A(e))}async function M(e=!1){if(k&&v!==void 0&&!b){x(!0);try{let t=await L(`code.save`,{path:k.path,contents:v,mtimeMs:k.mtimeMs,...e?{force:!0}:{}});return p(e=>e&&{...e,file:{...e.file,contents:v,mtimeMs:t.mtimeMs,size:v.length}}),y(void 0),C(!1),s.reload(),w&&A(w),!0}catch(e){return e instanceof xe&&e.code===`conflict`?C(!0):H.error(e instanceof Error?e.message:`The file could not be saved.`),!1}finally{x(!1)}}}function te(e){(e.ctrlKey||e.metaKey)&&!e.altKey&&e.key.toLowerCase()===`s`?(e.preventDefault(),e.stopPropagation(),M()):r&&pK(e.nativeEvent,r)&&(e.preventDefault(),j({kind:`close`}))}let ne=k?.change,N=!!ne||k?.original!==void 0,re=N?u:`code`,{dir:ie,name:ae}=aX(k?.path??c??``),oe=!!(k?.exists&&k.contents!==void 0),se=ne?iX[ne.status]:void 0;return(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1`,onKeyDown:te,children:[(0,V.jsx)(cX,{changes:s.data,loading:s.loading,error:s.error,current:k?.path??c,onPick:e=>j({kind:`open`,path:e}),onRefresh:()=>{s.reload(),ee||_()}}),(0,V.jsxs)(`section`,{"aria-label":`File`,className:`flex min-w-0 flex-1 flex-col`,children:[(0,V.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border pr-2 pl-3`,children:[c?(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[se?(0,V.jsx)(`span`,{title:se.word,className:Y(`font-mono text-xs font-semibold`,se.tone),children:se.letter}):(0,V.jsx)(Tp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,V.jsxs)(`h2`,{className:`min-w-0 truncate text-[0.8125rem]`,title:k?.path??c,children:[ie?(0,V.jsxs)(`span`,{className:`text-muted-foreground`,children:[ie,`/`]}):null,(0,V.jsx)(`span`,{className:`font-medium text-foreground`,children:ae}),ee?(0,V.jsx)(`span`,{"aria-label":`unsaved`,title:`Unsaved edits`,className:`ml-1.5 inline-block size-1.5 -translate-y-0.5 rounded-full bg-foreground/70`}):null]}),ne?(0,V.jsx)(oX,{change:ne}):null]}):(0,V.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-muted-foreground`,children:`Code`}),N?(0,V.jsx)(hE,{label:`View`,value:re,onChange:d,items:[{id:`code`,label:`Code`},{id:`diff`,label:`Diff`}]}):null,re===`diff`?(0,V.jsx)(nX,{label:D===`split`?`Unified diff`:`Side by side`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Side by side`,"aria-pressed":D===`split`,onClick:()=>_L(D===`split`?`unified`:`split`),className:tX,children:D===`split`?(0,V.jsx)(Lm,{"aria-hidden":`true`,className:`size-4`}):(0,V.jsx)(_p,{"aria-hidden":`true`,className:`size-4`})})}):null,(0,V.jsx)(nX,{label:E?`Do not wrap lines`:`Wrap long lines`,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Wrap lines`,"aria-pressed":E,onClick:()=>gL(!E),className:tX,children:(0,V.jsx)(th,{"aria-hidden":`true`,className:`size-4`})})}),(0,V.jsx)(nX,{label:`Save`,hint:`Ctrl+S`,children:(0,V.jsxs)(OT,{size:`sm`,variant:ee?`default`:`outline`,disabled:!ee||b,onClick:()=>void M(),"aria-keyshortcuts":`Control+S Meta+S`,children:[(0,V.jsx)(zm,{"aria-hidden":`true`}),b?`Saving…`:`Save`]})}),(0,V.jsx)(nX,{label:`Close`,hint:r,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Close code viewer`,onClick:()=>j({kind:`close`}),className:tX,children:(0,V.jsx)(yh,{"aria-hidden":`true`,className:`size-4`})})})]}),w?(0,V.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-muted/40 px-3 py-2 text-xs`,children:[(0,V.jsx)(_m,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[ae,` has unsaved edits.`]}),(0,V.jsx)(OT,{size:`xs`,variant:`ghost`,onClick:()=>T(void 0),children:`Keep editing`}),(0,V.jsx)(OT,{size:`xs`,variant:`outline`,onClick:()=>A(w),children:`Discard`}),(0,V.jsx)(OT,{size:`xs`,onClick:()=>void M(),disabled:b,children:`Save`})]}):null,S?(0,V.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-muted/40 px-3 py-2 text-xs`,children:[(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[ae,` changed on disk since you opened it, maybe by an agent.`]}),(0,V.jsx)(OT,{size:`xs`,variant:`outline`,onClick:()=>{y(void 0),C(!1),_()},children:`Load theirs`}),(0,V.jsx)(OT,{size:`xs`,onClick:()=>void M(!0),disabled:b,children:`Overwrite with mine`})]}):null,(0,V.jsx)(`div`,{className:`code-pane relative flex min-h-0 flex-1 flex-col`,children:h?(0,V.jsx)(`p`,{role:`alert`,className:`m-auto max-w-sm px-6 text-center text-sm text-muted-foreground`,children:h}):c?k?k.binary||k.tooLarge?(0,V.jsx)(`p`,{className:`m-auto max-w-sm px-6 text-center text-sm text-muted-foreground`,children:k.binary?`This is a binary file, so it is not shown.`:`This file is too large to show here.`}):!k.exists&&re===`code`?(0,V.jsxs)(`p`,{className:`m-auto flex max-w-sm flex-col items-center gap-2 px-6 text-center text-sm text-muted-foreground`,children:[(0,V.jsx)(Np,{"aria-hidden":`true`,className:`size-5`}),`This file was deleted. Switch to Diff to see what it held.`]}):(0,V.jsx)(m.Suspense,{fallback:(0,V.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:`Loading code…`}),children:(0,V.jsx)(eX,{path:k.path,version:`${f.version}`,contents:k.contents??``,draft:v,original:k.original,mode:re,layout:D,wrap:E,dark:O,readOnly:!oe,onDraft:y})}):(0,V.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:g?`Opening…`:``}):(0,V.jsx)(dX,{loading:s.loading})})]})]})}function dX({loading:e}){return(0,V.jsxs)(`div`,{className:`m-auto flex max-w-xs flex-col items-center gap-2 px-6 text-center`,children:[(0,V.jsx)(Dp,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e?`Reading the changes…`:`Pick a changed file, open one by its path, or click a file name in the Lobby chat.`})]})}function fX({codeKey:e}){let{open:t,path:n,mode:r,request:i}=dL(),a=qT(t,KT.help),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(0),u=()=>l(e=>e+1);return(0,V.jsx)(zT,{open:a,onOpenChange:e=>{e||(o?u():lL())},label:`Code viewer`,className:`code-pop h-[min(86svh,52rem)] max-h-none max-w-6xl`,onEscapeKeyDown:e=>{o&&(e.preventDefault(),u())},children:t?(0,V.jsx)(uX,{requested:n,requestedMode:r,request:i,codeKey:e,onClose:lL,onDirtyChange:s,closeAsked:c}):null})}function pX(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 mX(){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(pX(e))}return(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-y-auto p-6`,children:(0,V.jsxs)(`form`,{onSubmit:s,className:`cs-dlg w-full max-w-[420px]`,children:[(0,V.jsxs)(`div`,{className:`cs-dh flex items-center gap-3.5 pt-[22px]`,children:[(0,V.jsx)(`span`,{className:`cs-drop`,"aria-hidden":`true`,children:(0,V.jsx)(Gp,{className:`size-[18px]`})}),(0,V.jsx)(`h1`,{children:`Sign in to bot-lobby`})]}),(0,V.jsxs)(`div`,{className:`cs-db`,children:[(0,V.jsxs)(`p`,{className:`mb-3.5 text-[12.5px] leading-relaxed text-muted-foreground`,children:[`Pi printed a link when it started (or run `,(0,V.jsx)(`code`,{className:`cs-cd`,children:`/bot-lobby web`}),` to see it again). Paste it here.`]}),(0,V.jsxs)(`label`,{children:[(0,V.jsx)(`span`,{children:`Lobby link or token`}),(0,V.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),autoComplete:`off`,spellCheck:!1,autoFocus:!0,placeholder:`http://127.0.0.1:7347/#token=…`,className:`cs-inp`})]}),n?(0,V.jsx)(`p`,{role:`alert`,className:`mt-2.5 text-[12.5px] text-[var(--bad)]`,children:n}):null]}),(0,V.jsxs)(`div`,{className:`cs-df`,children:[(0,V.jsx)(OT,{type:`button`,variant:`outline`,disabled:i,onClick:()=>void o(void 0),children:`Retry`}),(0,V.jsx)(OT,{type:`submit`,disabled:i||!e.trim(),children:`Sign in`})]})]})})}var hX=`plan:`,gX=`bot-lobby:plan-put-away`,_X=e=>e.startsWith(hX);function vX(){try{let e=JSON.parse(sessionStorage.getItem(gX)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`number`):[]}catch{return[]}}function yX(e){let t=e?.messages.at(-1);if(e&&!e.busy&&t?.role===`planner`&&t.questions?.length)return{id:`${hX}${t.at}`,kind:`questionnaire`,createdAt:t.at,from:`planner`,payload:{round:Math.max(e.round,1),limit:e.limit,questions:t.questions.map(e=>({question:e.text,header:e.from,options:e.options.map(e=>({label:e.label,description:e.description,...e.mockup?{htmlPreview:e.mockup}:{}}))}))}}}function bX(e,t){let n=e.payload.questions??[];return(t.answers??[]).map(e=>`${vR(n[e.questionIndex]?.header??``)}: ${e.question} ${e.answer}`.trim()).join(`
115
+ `)}function xX(){let e=eR(`planner.get`,{},[`planner`]),[t,n]=(0,m.useState)(vX),r=yX(e.data),i=(0,m.useMemo)(()=>r&&!t.includes(r.createdAt)?[r]:[],[r?.id,t.join(`,`)]);return{prompts:i,answer:(0,m.useCallback)(async(t,n)=>{let r=i.find(e=>e.id===t);r&&(await L(`planner.send`,{text:bX(r,n)}),e.reload())},[i,e]),dismiss:(0,m.useCallback)(async e=>{let t=Number(e.slice(5));n(e=>{let n=[...e,t].slice(-20);try{sessionStorage.setItem(gX,JSON.stringify(n))}catch{}return n})},[])}}var SX=2;function CX(e){let t=globalThis.EventSource;if(!t)throw Error(`EventSource is not available in this environment`);return new t(e)}function wX(e){try{return JSON.parse(e)}catch{return}}function TX(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 EX(e,t=CX){let n=t(F(`/api/events`));return e.onConnection?.(`connecting`),n.onopen=()=>e.onConnection?.(`live`),n.onerror=()=>e.onConnection?.(n.readyState===SX?`offline`:`connecting`),n.onmessage=t=>{let n=wX(t.data);n&&TX(n,e)},()=>n.close()}var DX=2e3,OX=()=>L(`projects.list`,{});async function kX(){let e;try{e=pe()}catch{return}if(e&&!ye(e))try{ve((await OX()).projects)}catch{}}function AX(){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=EX({onHello:e=>{P.onHello(e),kX()},onChanged:(e,t)=>P.onChanged(e,t),onFeed:e=>P.onFeedDelta(e),onReply:e=>P.onReplyDelta(e),onNotice:(e,t)=>H[t](e),onConnection:e=>{P.onStatus({connection:e}),e===`offline`&&(clearTimeout(t.current),t.current=setTimeout(()=>{be(OX).catch(()=>!1).finally(n)},DX))}})},[]);return(0,m.useEffect)(()=>(n(),()=>{clearTimeout(t.current),e.current?.()}),[n]),n}var jX=`bot-lobby.recoveredAt`,MX;function NX(e,t=PX()){try{MX===void 0&&(MX=Number(t?.getItem(jX)??0))}catch{MX??=0}if(MX!==void 0&&e<=MX)return!1;MX=e;try{t?.setItem(jX,String(e))}catch{}return!0}function PX(){try{return globalThis.sessionStorage}catch{return}}function FX(e){let t=e?.recovered?.at,n=e?.recovered?.text;(0,m.useEffect)(()=>{t!==void 0&&n&&NX(t)&&H.success(n)},[t,n])}function IX(){let e=vE(`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}}var LX=class extends m.Component{state={};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`bot-lobby: a tab failed to draw`,e,t.componentStack)}render(){let{error:e}=this.state;return e?this.props.fallback?this.props.fallback(e,()=>this.setState({error:void 0})):(0,V.jsxs)(`div`,{role:`alert`,className:`cs-pg cs-blank`,children:[(0,V.jsx)(`h2`,{children:`This page hit a snag`}),(0,V.jsx)(`p`,{children:e.message||String(e)}),(0,V.jsx)(`p`,{children:(0,V.jsx)(`button`,{type:`button`,className:`cs-kc`,onClick:()=>this.setState({error:void 0}),children:`Try again`})})]}):this.props.children}};function RX(e,t,n,r,i){e===`search`?(document.querySelector(`#main input[type='search']`)??document.getElementById(`composer-text`))?.focus():e===`help`?n():e===`settings`?iE(`#/settings`):e===`thinking`?t.kind===`tab`&&t.tab===`lobby`?ZR(`lobby.thinking`):iE(rE(`lobby`)):e===`nextSession`||e===`prevSession`?sY(e===`nextSession`?1:-1):e===`sidebar`?i():e===`terminal`?PY():e===`code`?uL():e===`activity`?t.kind===`tab`&&t.tab===`lobby`?ZR($R):iE(rE(`lobby`)):e===`nextTab`?r(1):e===`prevTab`?r(-1):e===`savePlan`&&t.kind===`tab`&&t.tab===`plan`&&U(`planner.save`,{})}var zX=`cs-iconbtn cs-sq10`,BX=2500;function VX(e){let[t,n]=(0,m.useState)(!1),r=(0,m.useRef)(!1);return e===`live`&&(r.current=!0),(0,m.useEffect)(()=>{if(e!==`connecting`||!r.current)return n(!1);let t=setTimeout(()=>n(!0),BX);return()=>clearTimeout(t)},[e]),e===`offline`||e===`connecting`&&t}function HX({connection:e,onRetry:t}){return VX(e)?(0,V.jsx)(`div`,{className:`cs-outage`,children:(0,V.jsx)(lE,{onRetry:t})}):null}var UX={tick:0,route:0,focus:0};window.addEventListener(`hashchange`,()=>{UX.route=++UX.tick}),document.addEventListener(`focusin`,()=>{UX.focus=++UX.tick});var WX=()=>UX.focus>UX.route;function GX(e){return e.kind===`tab`?e.tab:e.kind}function KX(){let e=aE(),t=vE(`status`);vE(`lobby`);let{prompts:n,loading:r,answer:i,dismiss:a}=IX(),o=xX(),s=(0,m.useMemo)(()=>[...n,...o.prompts],[n,o.prompts]),c=nJ(s,(0,m.useCallback)((e,t)=>_X(e)?o.answer(e,t):i(e,t),[i,o.answer]),(0,m.useCallback)(e=>_X(e)?o.dismiss(e):a(e),[a,o.dismiss])),{connection:l,signedOut:u}=_E(),[d,f]=(0,m.useState)(!1),p=mJ();(0,m.useEffect)(()=>{s.length===0&&!r&&fJ(!1)},[s.length,r]);let h=(0,m.useRef)(null),g=AX();SB();let _=t.data;FX(_);let v=!!_&&!u;(0,m.useEffect)(()=>{v&&ze()},[v]);let y=_?.tabs??[],b=_?.keys??[],x=e.kind===`tab`?e.tab:void 0,S=(0,m.useCallback)(e=>iE(rE(e)),[]),C=(0,m.useCallback)(e=>{if(y.length===0)return;let t=Math.max(0,y.findIndex(e=>e.id===x)),n=y[(t+e+y.length)%y.length];n&&iE(rE(n.id))},[y,x]),w=(0,m.useCallback)(()=>f(e=>!e),[]),T=KK(),E=(0,m.useCallback)(()=>$J(),[]),D=(0,m.useCallback)(t=>{(t!==`thinking`&&t!==`activity`||_?.panels?.[t]!==!1)&&RX(t,nE(window.location.hash)??e,w,C,E)},[e,w,C,E,_?.panels]),O=S,k=(0,m.useCallback)(()=>{let e=document.activeElement;return!e||e===document.body||h.current?.contains(e)===!0||e.closest(`.terminal-pop`)?!0:e.closest(`[data-state='closed']`)!==null},[]);bK({enabled:!!_,keys:b,tabs:y,insideApp:k,onAction:D,onTab:O});let ee=(0,m.useCallback)(()=>P.onHello({}),[]),A=e.kind===`tab`?e.tab:e.kind,j=!!_;(0,m.useEffect)(()=>{if(!j)return;let e=OE.active&&OE.to===A;if(OE.active=!1,OE.to=void 0,e)return;let t=requestAnimationFrame(()=>{if(WX()||document.querySelector(`[role='dialog']:not([data-state='closed'])`))return;let e=document.getElementById(`composer-text`);!window.matchMedia(`(pointer: coarse)`).matches&&e&&!e.disabled&&!e.closest(`[inert]`)?e.focus({preventScroll:!0}):document.activeElement?.id!==`composer-text`&&document.getElementById(`main`)?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(t)},[A,j]);let M=Object.fromEntries(b.map(e=>[e.action,e.label])),te=JJ({tabs:y,activeId:x,onSelect:S}),ne=vY({route:e,keys:M,onHelp:w});return u||!_?(0,V.jsxs)(`div`,{ref:h,className:`cs-frame`,children:[(0,V.jsx)(WJ,{}),(0,V.jsx)(`main`,{id:`main`,tabIndex:-1,className:`cs-main`,children:u?(0,V.jsx)(mX,{}):t.error?(0,V.jsx)(cE,{message:t.error,onRetry:ee}):(0,V.jsx)(sE,{})}),(0,V.jsxs)(YJ,{children:[(0,V.jsx)(FK,{className:zX,side:`bottom`}),(0,V.jsx)(PK,{className:zX,side:`bottom`})]})]}):(0,V.jsxs)(`div`,{ref:h,className:`cs-frame`,"data-sb":ne.open?`open`:`closed`,"data-sbpin":ne.pinned||void 0,"data-tb":`open`,children:[(0,V.jsx)(WJ,{}),(0,V.jsxs)(`div`,{className:`cs-body`,children:[(0,V.jsx)(HX,{connection:l,onRetry:g}),(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||yE(e.target)||e.target.closest(`[role='dialog'], [role='menu'], [role='listbox']`)||DE()&&e.preventDefault()},role:x?`tabpanel`:void 0,"aria-labelledby":x?`tab-${x}`:void 0,className:`cs-main surface`,children:(0,V.jsx)(Yd.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.17,ease:[.22,1,.36,1]},className:`flex min-h-0 flex-1 flex-col`,children:(0,V.jsx)(LX,{children:sK(e)})},GX(e))}),(0,V.jsx)(LX,{fallback:(e,t)=>(0,V.jsxs)(`div`,{role:`alert`,className:`pointer-events-auto absolute inset-x-0 bottom-6 z-30 mx-auto w-fit rounded-xl bg-card px-4 py-2 text-sm shadow`,children:[`The message box hit a snag: `,e.message,` `,(0,V.jsx)(`button`,{type:`button`,className:`font-medium text-primary underline`,onClick:t,children:`Try again`})]}),children:(0,V.jsx)(kJ,{route:e,projects:T,drawer:c,drawerOpen:s.length>0&&!p})})]}),(0,V.jsx)(QY,{toggleKey:M.terminal??"Ctrl+`"})]}),ne.ghost,te.ghost,(0,V.jsxs)(YJ,{children:[(0,V.jsx)(rX,{hint:M.code,className:zX}),(0,V.jsx)(YY,{hint:M.terminal,className:zX})]}),ne.bay,te.bay,(0,V.jsx)(JK,{projects:T}),(0,V.jsx)(`span`,{id:`focused-action-help`,className:`sr-only`,children:`Focused buttons: Enter or Space. Links: Enter. Checkboxes: Space.`}),(0,V.jsx)(fX,{codeKey:b.find(e=>e.action===`code`)?.key}),(0,V.jsx)(JI,{}),(0,V.jsx)(jK,{open:d,onOpenChange:f,keys:b,tabs:y})]})}async function qX(e){switch(e){case`status`:return L(`status.get`,{});case`lobby`:return L(`lobby.snapshot`,{});case`prompts`:return L(`prompts.list`,{});default:return}}var JX=[`status`,`lobby`,`prompts`];function YX(){let[e,t]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{let e=!0;return(async()=>{await we(),e&&(P.markUsed(JX,qX),t(!0))})(),()=>{e=!1}},[]),e}function XX(){return YX()?(0,V.jsx)(KX,{}):(0,V.jsx)(`div`,{className:`fixed inset-0 flex`,children:(0,V.jsx)(sE,{})})}var ZX={info:Up,success:ap,warning:ah,error:pp},QX={info:`Note:`,success:`Done:`,warning:`Warning:`,error:`Error:`},$X={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-destructive`};function eZ(){let{item:e,waiting:t}=ff(),n=YT(),r=e&&!n;return(0,m.useEffect)(()=>{if(!e||n)return;let r=window.setTimeout(()=>uf(e.id),t>0?Math.min(e.duration,1600):e.duration);return()=>window.clearTimeout(r)},[e,n,t]),(0,V.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`pointer-events-none fixed z-[1050] flex justify-center px-4`,style:{bottom:`calc(var(--composer-h, 0px) + var(--terminal-h, 0px) + 0.25rem)`,left:`var(--composer-x, 0px)`,width:`var(--composer-w, 100%)`},children:(0,V.jsx)(eu,{mode:`wait`,children:r?(0,V.jsxs)(Yd.div,{initial:{opacity:0,scale:.55,y:18},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.92,y:6,transition:{duration:.14,ease:`easeIn`}},transition:{type:`spring`,stiffness:560,damping:15,mass:.8},className:`pointer-events-auto flex max-w-[min(32rem,100%)] items-center gap-2.5 glass-toast rounded-lg px-3.5 py-2.5 text-sm`,children:[(0,V.jsx)(tZ,{kind:e.kind}),(0,V.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,V.jsxs)(`span`,{className:`sr-only`,children:[QX[e.kind],` `]}),e.message]}),e.action?(0,V.jsx)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,className:`btn-outline -my-1.5 -mr-1 h-7 shrink-0 rounded-lg border px-2.5 text-xs font-medium text-foreground transition-[box-shadow,scale] active:scale-[0.97] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,onClick:()=>{e.action?.onClick(),uf(e.id)},children:e.action.label}):null]},e.id):null})})}function tZ({kind:e}){let t=ZX[e];return(0,V.jsx)(t,{"aria-hidden":`true`,className:Y(`size-4 shrink-0`,$X[e])})}var nZ=6,rZ=8,iZ=400;function aZ(e){return e.matches(`:disabled, [aria-disabled='true'], [aria-pressed='true'], [data-on='true'], [data-on=''], [aria-expanded='true']`)||!e.isConnected}function oZ(e){return e.classList.contains(`cs-tipl`)?`left`:e.classList.contains(`cs-b`)?`bottom`:`top`}function sZ(e,t,n,r){let i=window.innerWidth,a=window.innerHeight,o=r=>r===`top`?e.top-nZ-n>=rZ:r===`bottom`?e.bottom+nZ+n<=a-rZ:r===`left`?e.left-nZ-t>=rZ:e.right+nZ+t<=i-rZ,s={top:`bottom`,bottom:`top`,left:`right`,right:`left`},c=o(r)||!o(s[r])?r:s[r],l=(e,t,n)=>Math.min(Math.max(e,rZ),n-t-rZ);if(c===`top`||c===`bottom`)return{x:l(e.left+e.width/2-t/2,t,i),y:c===`top`?e.top-nZ-n:e.bottom+nZ,side:c};let u=l(e.top+e.height/2-n/2,n,a);return{x:c===`left`?e.left-nZ-t:e.right+nZ,y:u,side:c}}function cZ(){let[e,t]=(0,m.useState)(null),[n,r]=(0,m.useState)(null),i=(0,m.useRef)(null),a=(0,m.useRef)(null);return(0,m.useEffect)(()=>{let e=0,n=()=>{window.clearTimeout(e),a.current=null,t(null),r(null)},i=r=>{if(r.pointerType===`touch`)return;let i=r.target?.closest?.(`[data-tip]`);i!==a.current&&(n(),i&&i.dataset.tip&&(a.current=i,e=window.setTimeout(()=>{a.current===i&&!aZ(i)&&i.dataset.tip&&t({text:i.dataset.tip,el:i,side:oZ(i)})},iZ)))},o=e=>{let t=e.relatedTarget;a.current&&(!t||!a.current.contains(t))&&n()};return document.addEventListener(`pointerover`,i,!0),document.addEventListener(`pointerout`,o,!0),document.addEventListener(`pointerdown`,n,!0),document.addEventListener(`keydown`,n,!0),document.addEventListener(`scroll`,n,!0),window.addEventListener(`blur`,n),()=>{n(),document.removeEventListener(`pointerover`,i,!0),document.removeEventListener(`pointerout`,o,!0),document.removeEventListener(`pointerdown`,n,!0),document.removeEventListener(`keydown`,n,!0),document.removeEventListener(`scroll`,n,!0),window.removeEventListener(`blur`,n)}},[]),(0,m.useLayoutEffect)(()=>{let t=i.current;if(!e||!t)return;let n=t.getBoundingClientRect();r(sZ(e.el.getBoundingClientRect(),n.width,n.height,e.side))},[e]),e?(0,C_.createPortal)((0,V.jsx)(`div`,{ref:i,role:`tooltip`,className:`tipbox`,"data-side":n?.side??e.side,"data-ready":n?``:void 0,style:{position:`fixed`,left:n?.x??0,top:n?.y??0},children:e.text}),document.body):null}(0,tf.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(m.StrictMode,{children:(0,V.jsx)(tV,{children:(0,V.jsx)(su,{reducedMotion:`user`,children:(0,V.jsxs)(xI,{children:[(0,V.jsx)(XX,{}),(0,V.jsx)(eZ,{}),(0,V.jsx)(cZ,{})]})})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{updateViaCache:`none`}).catch(()=>void 0)});export{F as i,pK as n,L as r,GY as t};