openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
4 lines • 301 kB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./_1____________________________.css","./en-devices-CUABNinu.js","./en-route-subtitles-CjswZHfJ.js","./_0____________________________________.css","./deferred-ui-support-DZEPWjAk.js","./control-ui-boot-chat-CqvkfPXD.js","./control-ui-boot-chat-styles-DMRbEm40.js","./markdown-runtime-CtlJb8xA.js","./chat-message-media-runtime-tT5AgKo0.js","./virtual-core-runtime-LhyriIY5.js","./control-ui-boot-chat-styles-ixIYYh0U.css","./connect-command-BZS_TVWX.js","./cloud-target-view-C31rMrsY.js","./place-browser-jpiBsXZ0.js","./lobster-pet-identity-DgA0FbCN.js","./lobster-dex-BAaz3U8C.js","./lobster-pet-audio-waE6qgq0.js","./lobster-pet-identity-BPFofFUK.css","./artifact-download-url-BHTP5fwQ.js","./mcp-app-view-lazy-Cj7YIwk1.js","./panel-hosted-tabs-C4cjAhdY.js","./panel-empty-state-B1lP2be5.js","./mcp-app-icon-DkQsvoJC.js","./en-chat-session-optional-Dhpd_jPf.js","./chat-attachment-text-reader-nCp-5odC.js","./canvas-limits-DuPWavzb.js","./markdown-code-D3nSKiQb.js","./canvas-embed-policy-C_npQEMa.js","./canvas-frame-presentation-zrG8hVcD.js","./file-disclosure-D1MEPYPz.js","./chat-video-player-CXZFWONb.js","./chat-attachment-admission-ref-BGiVn4jD.js","./chat-html-preview-view-GuQwfnsq.js","./chat-file-scroll-CqTm7TBq.js","./chat-diff-render.solid-DV4R4R0K.js","./file-disclosure-DBL-8RI5.css","./chat-detail-panel-KTvzgxHD.css"])))=>i.map(i=>d[i]);
import{n as e,r as t}from"./rolldown-runtime-CNOWq4Kh.js";import{$ as n,$u as r,Al as i,B as a,Bo as o,Cl as s,El as c,Fu as l,G as u,It as d,J as f,K as p,Ko as m,Ol as h,Qa as g,Qo as _,Qu as v,Rl as y,Rt as b,Sl as x,Tl as S,Ts as ee,Tt as te,Va as ne,Vl as C,Vo as re,Wo as w,Xc as ie,Y as ae,Ya as oe,Z as se,ac as ce,al as T,at as le,bt as ue,gl as de,hl as fe,jl as pe,li as E,ll as D,mi as me,oi as O,ol as he,pi as ge,qs as _e,rc as ve,rt as ye,sr as be,v as xe,y as Se,ys as Ce,za as we}from"./_4____________________________.js";import{$A as Te,$N as Ee,$a as De,$s as Oe,AN as k,AS as ke,Ac as Ae,Ai as je,Am as Me,Ax as Ne,BN as Pe,Bi as Fe,Bj as Ie,Bn as Le,Br as Re,Bt as ze,CC as Be,CP as Ve,CT as A,Co as He,Ct as Ue,DM as We,DN as Ge,Da as Ke,Dc as qe,Df as Je,Di as Ye,Dn as Xe,Dw as Ze,EN as j,Ec as Qe,Ef as $e,Ek as et,Eo as tt,Er as nt,FS as rt,Fn as it,Fo as at,GA as ot,GN as M,Ga as st,Gj as ct,Gk as lt,Go as ut,Gt as dt,Gx as ft,Ha as pt,Hj as mt,Hn as ht,Hr as gt,Hs as _t,Ht as vt,IM as yt,IN as bt,IS as xt,Ia as St,In as Ct,Io as wt,JN as N,JO as Tt,Ja as Et,Jo as Dt,Ka as Ot,Ki as kt,Kj as At,Ks as jt,Kt as Mt,La as Nt,Lk as Pt,MN as Ft,Ma as It,Mi as Lt,Mm as Rt,Mn as zt,Mo as Bt,Na as Vt,Nc as Ht,Nn as Ut,OS as Wt,Oa as Gt,Oc as Kt,Oi as qt,Ok as Jt,On as Yt,Oy as Xt,PA as Zt,PM as Qt,PN as $t,Pa as en,Pk as tn,Pn as nn,Pv as rn,QN as an,Qi as on,Qn as sn,Qs as cn,Qy as ln,Rn as un,SP as dn,Sc as fn,Si as pn,Ss as mn,St as hn,Sw as gn,TT as _n,Tn as vn,To as yn,Tr as bn,Tt as xn,Tw as Sn,Un as Cn,Vr as wn,Vt as Tn,Vx as En,WN as Dn,Wa as On,Wj as kn,Wk as An,Wn as jn,Wr as Mn,XA as Nn,XM as Pn,Xa as Fn,Xw as In,YA as Ln,YN as Rn,YO as zn,Ya as Bn,Yg as Vn,ZN as Hn,Za as Un,Zn as Wn,Zw as Gn,_P as Kn,_a as qn,_i as Jn,_k as Yn,_o as Xn,_r as Zn,_x as Qn,aA as $n,aO as er,aa as tr,aj as nr,ak as rr,an as ir,ar,av as or,bP as sr,bn as cr,bo as lr,br as ur,bs as dr,bt as fr,by as pr,cD as mr,ca as hr,ck as gr,cl as _r,cn as vr,cr as yr,dP as br,dT as xr,da as Sr,di as Cr,dj as wr,dl as Tr,dn as Er,ds as Dr,dx as Or,eD as kr,eS as Ar,ea as jr,eb as Mr,ej as Nr,fN as P,fO as Pr,fT as Fr,fa as Ir,fk as Lr,fn as Rr,fo as zr,fs as Br,gP as Vr,ga as Hr,gj as Ur,gr as Wr,gy as Gr,hO as Kr,h_ as qr,ha as Jr,hi as Yr,hp as Xr,hs as Zr,hy as Qr,iA as $r,iO as ei,iS as ti,ia as ni,ib as ri,in as ii,ir as ai,ix as oi,jA as si,jN as ci,jS as li,jj as ui,jk as di,jn as fi,jx as pi,jy as mi,kM as hi,kc as gi,kj as _i,kx as vi,lD as yi,lS as bi,la as xi,lk as Si,ll as Ci,ln as wi,lr as Ti,mS as Ei,m_ as Di,ma as Oi,mj as ki,mk as Ai,mo as ji,mp as Mi,ms as Ni,mx as Pi,my as Fi,nD as Ii,nP as Li,nS as Ri,n_ as zi,nl as Bi,nn as Vi,no as Hi,nr as Ui,oA as Wi,oN as Gi,oO as Ki,oS as qi,oa as Ji,oj as Yi,ok as Xi,ol as Zi,on as Qi,oo as $i,ov as ea,pN as F,pS as ta,pa as na,pj as ra,po as ia,ps as aa,py as oa,qN as sa,qa as ca,qs as la,rA as ua,rP as da,rS as fa,rb as pa,rl as ma,rn as ha,ro as ga,rr as _a,sA as va,sS as ya,sa as ba,sk as xa,sl as Sa,so as Ca,ss as wa,tA as Ta,tP as Ea,tS as Da,tl as Oa,tr as ka,uP as Aa,uS as ja,ua as Ma,uk as Na,ul as Pa,un as Fa,us as Ia,va as La,vc as Ra,vk as za,vo as Ba,wc as Va,wi as Ha,wn as Ua,wo as Wa,wt as Ga,xC as Ka,xP as qa,x_ as Ja,xn as Ya,xo as Xa,xr as Za,xt as Qa,xw as $a,yP as eo,yc as to,yi as no,yj as ro,yy as io,zA as ao,zN as oo,zj as so,zn as co,zr as lo,zt as uo,zx as fo}from"./_2_____________________________.js";import{$ as po,A as mo,B as ho,C as go,Ct as _o,F as I,H as vo,I as yo,J as bo,K as xo,M as So,O as L,P as Co,Rt as wo,S as To,St as Eo,U as R,V as Do,W as Oo,_t as ko,d as z,f as B,g as V,gt as H,i as Ao,j as U,l as W,m as G,o as jo,p as Mo,r as No,s as Po,u as K,v as Fo,w as Io,x as q,y as Lo,yt as Ro}from"./_6____________________.js";import"./_1____________________________________.js";import{A as zo,C as Bo,E as Vo,I as Ho,L as Uo,M as Wo,N as Go,O as Ko,P as qo,R as Jo,S as Yo,T as Xo,V as Zo,_ as Qo,a as $o,b as es,c as ts,d as ns,f as rs,g as is,h as as,i as os,l as ss,n as cs,p as ls,r as us,s as ds,t as fs,x as ps}from"./route-controls-runtime-LXiVRSj4.js";import"./control-ui-boot-new-styles-C3bRIOZh.js";import{n as ms,t as hs}from"./command-discovery-english-zfhZUSVO.js";import{d as gs,g as _s,i as vs,l as ys,m as bs,o as xs,r as Ss,t as Cs}from"./composer-invocation-menus-Dvscf6c8.js";async function ws(e){let t=await e.request(`agents.list`,{includeSessionPlacement:!0});if(!t.sessionPlacement)throw Error(`Session placement policy is unavailable`);return t.sessionPlacement}function Ts(e){return{key:e.key,agentId:e.agentId,...e.target.kind===`profile`?{profileId:e.target.profileId,...e.target.os?{os:e.target.os}:{},...e.target.machineClass?{machineClass:e.target.machineClass}:{}}:e.target.kind===`device`?{deviceId:e.target.deviceId}:{autoDevice:!0}}}function Es(e){return e instanceof xe?e.retryable||e.gatewayCode===`UNAVAILABLE`:!0}async function Ds(e,t){try{let n=await e.describe({key:t},{refresh:!0,client:e.client});if(n?.session===null)return{status:`missing`};let r=n?.session?.sessionId;return{status:`read`,placement:n?.session?.placement,...r?.trim()?{sessionId:r}:{}}}catch(e){return Jt(e,null)?{status:`awaiting-gateway`}:Es(e)?{status:`unavailable`}:{status:`rejected`,error:j(e)}}}async function Os(e,t){try{await e.request(`sessions.reclaim`,{key:t.key,agentId:t.agentId});return}catch(e){return j(e)}}async function ks(e,t,n,r){if(!n())return{status:`interrupted`};let i=await Os(e,t);return i?{status:`cleanup-rejected`,error:i,...r===void 0?{}:{messageId:r}}:{status:`cancelled`}}async function As(e,t,n,r=!1){let{client:i}=e;if(!i)return`gateway unavailable during draft cleanup`;let a=await Ds({...e,client:i},t);if(a.status===`missing`)return;if(a.status===`rejected`)return a.error;if(a.status===`unavailable`||a.status===`awaiting-gateway`)return r?`session placement could not be verified`:`placement draft session could not be verified`;if(r&&a.placement){let e=await Os(i,{key:t,agentId:n});if(e)return e}if(!a.sessionId)return`placement draft session identity is unavailable`;let o={key:t,agentId:n,expectedSessionId:a.sessionId};try{await i.request(`sessions.patch`,{...o,archived:!0})}catch(e){return j(e)}try{if((await i.request(`sessions.delete`,{...o,deleteTranscript:!0,archivedOnly:!0})).deleted!==!0)throw Error(`placement draft session was not deleted`);return}catch(e){let t=j(e);try{await i.request(`sessions.patch`,{...o,archived:!1})}catch(e){return`${t}; restoring the placement draft failed: ${j(e)}`}return t}}async function js(e,t,n,r=()=>!0){let{client:a}=e,o=t.message,s=t.mentions,c=t.cleanupOnCancellation??(()=>!0),l=async(r,i)=>{let a={key:t.key,agentId:t.agentId},o=t.sessionId,{client:s}=e,l=i,u=0,d=0,f=!1;for(let t=0;t<Ns;t+=1){let t=l??await Ds(e,a.key);if(f=t.status===`read`&&t.placement!==void 0&&Is.has(t.placement.state),l=void 0,t.status===`missing`)return{status:`missing`};if(t.status===`rejected`)return{status:`cleanup-rejected`,error:t.error};if(t.status===`unavailable`||t.status===`awaiting-gateway`){if(u=t.status===`awaiting-gateway`?0:u+1,!n())return ks(s,a,c);if(u>=Ps){let e=await Os(s,a),t=`session placement could not be verified`;return{status:`cleanup-rejected`,error:e?`${t}; cleanup failed: ${e}`:t}}await C(Ms)}else{if(u=0,t.status===`read`){if(o&&t.sessionId&&o!==t.sessionId)return{status:`cleanup-rejected`,error:`The selected session changed. Review this message before trying again.`};let e=t.placement;if(e)d=0;else if(d+=1,d>=Fs)return{status:`cleanup-rejected`,error:`session placement could not be verified`};if(!n())return ks(s,a,c);if(e?.state===`active`)return{status:`active`,placement:e,sessionId:t.sessionId};if(r===`retry`&&(!e||e.state===`local`||e.state===`reclaimed`||e.state===`failed`))return{status:`dispatch`,sessionId:t.sessionId};if(e&&!Is.has(e.state)){if(e.state===`failed`){let e=await Os(s,a);if(e)return{status:`cleanup-rejected`,error:e}}return{status:`rejected`,placement:e}}}await C(Ms)}}return n()?{status:`cleanup-rejected`,error:E(f?`newSession.placementStillStarting`:`newSession.placementCompletionUnconfirmed`)}:ks(s,a,c)},u={status:`dispatch`},d=``,f,p=t.target.kind===`profile`&&t.target.required?t.target:void 0;if(t.mode!==`resend`&&p)try{let r=ws(a);f=Ds(e,t.key);let i=await r;if(!n())return ks(a,t,c);if(i.requiredProfile?.id!==p.profileId)return{status:`dispatch-rejected`,error:E(`newSession.requiredWorkerChanged`)};if(!i.requiredProfile.providerId)return{status:`dispatch-rejected`,error:E(`newSession.requiredWorkerUnavailable`)}}catch(e){return n()?{status:`dispatch-rejected`,error:j(e)}:ks(a,t,c)}if(t.mode!==`resend`&&(t.mode!==`dispatch`||p)&&(u=await l(t.mode,f&&await f),u.status===`dispatch`&&!n()))return ks(a,t,c);if(t.mode!==`resend`&&!p&&u.status===`dispatch`)try{let e=await a.request(`sessions.dispatch`,Ts(t));u=await l(`recover`,e.placement?{status:`read`,placement:e.placement,sessionId:e.sessionId}:void 0)}catch(e){if(d=j(e),!c()&&!n())return{status:`interrupted`};if(!Es(e))return{status:`dispatch-rejected`,error:d};u=await l(`recover`)}if(!c()&&!n())return{status:`interrupted`};if(u.status===`cancelled`||u.status===`interrupted`||u.status===`cleanup-rejected`)return u;if(u.status===`missing`)return{status:`session-missing`,error:`placement draft session no longer exists`};if(u.status===`rejected`){let e=typeof u.placement?.state==`string`?u.placement.state:``;return{status:`dispatch-rejected`,error:(u.placement?.state===`failed`?u.placement.recoveryError:void 0)||d||(e?`session placement became ${e}`:``)}}if(!n())return ks(a,t,c);let m=t.messageId??T(),h=t.sessionId??u.sessionId;if(!h)return{status:`send-not-started`,messageId:m,error:`Session identity is unavailable. Retry.`};let g=async(e,n)=>{let r=t.mode===`resend`?void 0:await Os(a,t);return{status:n,messageId:m,error:r?`${e}; cleanup failed: ${r}`:e}};if(!r(h))return g(`placement recovery storage is unavailable`,`send-not-started`);try{let e=await a.request(`chat.send`,{sessionKey:t.key,sessionId:h,expectedLeafEntryId:null,agentId:t.agentId,message:o,...s?.length?{mentions:s}:{},attachments:t.attachments,idempotencyKey:m},{timeoutMs:i,signal:t.signal,retainSentResultOnAbort:!0});if(!n())return await ks(a,t,c,m);let r=ti(e,m);return fa(r)?g(Ar(r,`chat`),`send-definitive-rejected`):{status:`started`,messageId:m}}catch(e){return Ri(e)?{status:`send-definitive-rejected`,messageId:m,error:j(e)}:n()?e instanceof S||e instanceof Error&&!(e instanceof xe)&&e.message===`gateway not connected`?g(j(e),`send-not-started`):Es(e)?{status:`send-rejected`,retryAfterMs:ja(e)??500,error:j(e),messageId:m}:g(j(e),`send-definitive-rejected`):ks(a,t,c,m)}}var Ms,Ns,Ps,Fs,Is;function Ls(){return(Ls=e((()=>{h(),y(),pe(),Se(),O(),rt(),k(),et(),he(),bi(),Da(),xt(),Ms=250,Ns=1200,Ps=4,Fs=20,Is=new Set([`requested`,`provisioning`,`syncing`,`starting`,`draining`,`reconciling`])})))()}function Rs(e){var t=Bs(),n=t.firstChild,r=n.nextSibling,i=r.nextSibling;return z(n,()=>e.title),z(t,U(L,{get when(){return e.onClose},get children(){return U(Pi,{size:28,class:`oc-dialog__close`,icon:`x`,get label(){return N(`common.close`)},tooltip:!1,get disabled(){return e.closeDisabled},onClick:()=>e.onClose?.()})}}),r),z(t,U(L,{get when(){return e.description},get children(){var t=zs();return z(t,()=>e.description),t}}),i),t}var zs,Bs;function Vs(){return(Vs=e((()=>{K(),R(),M(),Qn(),zs=q(`<div class=oc-dialog__description>`),Bs=q(`<div class=oc-dialog__header><h2 class=oc-dialog__title></h2><!><!>`)})))()}function Hs(e,t,n){e.onNavigate&&e.sessionDataContext&&(e.sessionDataContext.agentSelection.set(n),e.onNavigate(`terminal`,{pathname:ve(`terminal`,e.basePath),search:Ln(t),hash:``}))}async function Us(e,t,n){let{prepareCatalogTerminal:r}=await v(async()=>{let{prepareCatalogTerminal:e}=await import(`./catalog-terminal-start-B3f2soaI.js`).then(e=>(e.n(),e.t));return{prepareCatalogTerminal:e}},__vite__mapDeps([0]),import.meta.url);return r(e,t,n)}function Ws(){return(Ws=e((()=>{_e(),Nn(),r()})))()}function Gs(e){let t=new Set,n=new Set,r=new MutationObserver(e=>{let n=new Set(e.map(e=>e.attributeName)),r=[...t].filter(e=>e.attributes.some(e=>n.has(e)));for(let e of r)if(t.has(e))try{e.notify()}catch(e){reportError(e)}});return{subscribe(i,a){let o={attributes:i,notify:a};t.add(o);let s=!1;for(let e of i)n.has(e)||(n.add(e),s=!0);return s&&r.observe(e,{attributes:!0,attributeFilter:[...n]}),()=>{t.delete(o)&&t.size===0&&(r.disconnect(),qs.delete(e))}}}}function Ks(e,t,n){let r=e.documentElement,i=qs.get(r);return i||(i=Gs(r),qs.set(r,i)),i.subscribe(t,n)}var qs;function Js(){return(Js=e((()=>{qs=new WeakMap})))()}function Ys(){return{floatOffset:0,antennaDegrees:0,antennaDroop:0,leftClawDegrees:0,rightClawDegrees:0,eyeGlowOpacity:1,glowScale:1,leftEyeOpenness:1,rightEyeOpenness:1,happyEyes:0,gaze:{x:0,y:0},mouthCurve:0,mouthOpen:0,mouthRound:0,hardHat:0,bodyTilt:0,bodyStretch:1,effect:`none`,effectPhase:0}}function J(e,t=0,n=1){return Math.min(Math.max(e,t),n)}function Xs(e){let t=J(e);return t*t*(3-2*t)}function Zs(e){let t=J(e);return Xs(t<.5?t*2:(1-t)*2)}function Qs(e){return e.floatOffset=J(e.floatOffset,-12,2),e.antennaDegrees=J(e.antennaDegrees,-14,14),e.antennaDroop=J(e.antennaDroop,0,1),e.leftClawDegrees=J(e.leftClawDegrees,-45,45),e.rightClawDegrees=J(e.rightClawDegrees,-45,45),e.eyeGlowOpacity=J(e.eyeGlowOpacity,0,1),e.glowScale=J(e.glowScale,.5,1.6),e.leftEyeOpenness=J(e.leftEyeOpenness,0,1),e.rightEyeOpenness=J(e.rightEyeOpenness,0,1),e.happyEyes=J(e.happyEyes,0,1),e.gaze.x=J(e.gaze.x,-1.2,1.2),e.gaze.y=J(e.gaze.y,-1.2,1.2),e.mouthCurve=J(e.mouthCurve,-1,1),e.mouthOpen=J(e.mouthOpen,0,1),e.mouthRound=J(e.mouthRound,0,1),e.hardHat=J(e.hardHat,0,1),e.bodyTilt=J(e.bodyTilt,-8,8),e.bodyStretch=J(e.bodyStretch,.86,1.05),e}function $s(e){let t=Ys();switch(e){case`idle`:case`curious`:case`attentive`:break;case`thinking`:t.gaze={x:.3,y:-.5};break;case`working`:t.hardHat=1,t.rightClawDegrees=-28,t.gaze={x:.4,y:.35},t.mouthCurve=.15,t.bodyTilt=2;break;case`happy`:t.mouthCurve=.6,t.happyEyes=.4;break;case`celebrating`:t.mouthCurve=.9,t.mouthOpen=.4,t.happyEyes=.8,t.leftClawDegrees=30,t.rightClawDegrees=-30;break;case`sad`:t.antennaDroop=.75,t.mouthCurve=-.55,t.eyeGlowOpacity=.6,t.gaze={x:0,y:.5};break;case`sleepy`:t.leftEyeOpenness=.25,t.rightEyeOpenness=.25,t.eyeGlowOpacity=.5,t.antennaDroop=.35}return t}function ec(e){return e?rc:nc}var tc,nc,rc;function ic(){return(ic=e((()=>{tc=[`idle`,`curious`,`thinking`,`working`,`happy`,`celebrating`,`sad`,`sleepy`,`attentive`],nc={gradientTop:`#ff4d4d`,gradientBottom:`#991b1b`,antenna:`#ff4d4d`},rc={gradientTop:`#ff7079`,gradientBottom:`#ea4c59`,antenna:`#ef4b58`}})))()}function ac(){return Cc||(Cc={body:{path:new Path2D(`M60 10 C30 10 15 35 15 55 C15 75 30 95 45 100 L45 110 L55 110 L55 100 C55 100 60 102 65 100 L65 110 L75 110 L75 100 C90 95 105 75 105 55 C105 35 90 10 60 10 Z`),bounds:{minX:15,minY:10,maxX:105,maxY:110}},leftClaw:{path:new Path2D(`M20 45 C5 40 0 50 5 60 C10 70 20 65 25 55 C28 48 25 45 20 45 Z`),bounds:{minX:3.125,minY:43.67006838144548,maxX:26.196938456699073,maxY:65.45084971874738}},rightClaw:{path:new Path2D(`M100 45 C115 40 120 50 115 60 C110 70 100 65 95 55 C92 48 95 45 100 45 Z`),bounds:{minX:93.80306154330093,minY:43.67006838144548,maxX:116.875,maxY:65.45084971874738}},leftAntenna:new Path2D(`M45 15 Q35 5 30 8`),rightAntenna:new Path2D(`M75 15 Q85 5 90 8`)},Cc)}function oc(e,t,n){let{bounds:r}=t,i=e.createLinearGradient(r.minX,r.minY,r.maxX,r.maxY);return i.addColorStop(0,n.gradientTop),i.addColorStop(1,n.gradientBottom),i}function sc(e){return e*Math.PI/180}function cc(e,t,n,r){e.save(),e.translate(n.x,n.y),e.rotate(sc(t)),e.translate(-n.x,-n.y),r(),e.restore()}function lc(e,t,n){let r=new Path2D;return r.ellipse(e.x,e.y,t,n,0,0,_c),r}function uc(e,t,n,r){let i={x:t.x+r.gaze.x*2,y:t.y+r.gaze.y*1.5};if(r.happyEyes<1){let t=Math.max(1.2,12*n*(1-.6*r.happyEyes));e.save(),e.globalAlpha*=1-r.happyEyes,e.fillStyle=vc,e.fill(lc({x:i.x,y:i.y-6+(12-t)*.65+t/2},6,t/2)),e.restore()}if(r.happyEyes>0){let t=new Path2D;t.moveTo(i.x-6,i.y+2),t.quadraticCurveTo(i.x,i.y-5.5,i.x+6,i.y+2),e.save(),e.globalAlpha*=r.happyEyes,e.strokeStyle=vc,e.lineWidth=2.6,e.lineCap=`round`,e.stroke(t),e.restore()}let a=r.eyeGlowOpacity*n*(1-r.happyEyes);if(a<=.01)return;let o=2*r.glowScale,s={x:i.x+1+r.gaze.x*1.2,y:i.y-1+r.gaze.y*.9};e.save(),e.globalAlpha*=a,e.fillStyle=yc,e.fill(lc(s,o,o)),e.restore()}function dc(e,t){if(e.fillStyle=vc,e.strokeStyle=vc,e.lineCap=`round`,t.mouthRound>.05){let n=1+3.2*t.mouthRound,r=1+4.2*t.mouthRound;e.fill(lc({x:60,y:51},n,r));return}if(t.mouthOpen>.05){let n=new Path2D;n.moveTo(52.5,48.5),n.quadraticCurveTo(60,48.5+14*t.mouthOpen,67.5,48.5),n.closePath(),e.fill(n);return}if(Math.abs(t.mouthCurve)<=.05)return;let n=new Path2D;n.moveTo(52.5,49),n.quadraticCurveTo(60,49+8*t.mouthCurve,67.5,49),e.lineWidth=2.2,e.stroke(n)}function fc(e,t){if(t<=.01)return;let n=new Path2D(`M45 15 C47 7 54 3 60 3 C66 3 73 7 75 15 L45 15 Z`),r=new Path2D(`M43 14 L77 14 Q79 14 79 16 L79 17 Q79 19 77 19 L43 19 Q41 19 41 17 L41 16 Q41 14 43 14 Z`);e.save(),e.globalAlpha*=t,e.translate(60,15-14*(1-t)),e.rotate(sc(-5)),e.translate(-60,-15);let i=e.createLinearGradient(60,3,60,16);i.addColorStop(0,xc),i.addColorStop(1,bc),e.fillStyle=i,e.fill(n),e.strokeStyle=Sc,e.lineWidth=.8,e.stroke(n),e.fillStyle=bc,e.fill(r),e.stroke(r),e.restore()}function pc(e,t){let n=new Path2D;n.moveTo(e.x,e.y-t);for(let[r,i]of[[1,0],[0,1],[-1,0],[0,-1]])n.quadraticCurveTo(e.x,e.y,e.x+t*r,e.y+t*i);return n.closePath(),n}function mc(e,t,n){switch(t.effect){case`none`:return;case`sparkles`:for(let r=0;r<6;r+=1){let i=Zs((t.effectPhase+r*.37)%1);if(i<=.05)continue;let a=Math.PI+Math.PI*(r+.5)/6,o={x:60+Math.cos(a)*(50+r%3*4),y:55+Math.sin(a)*(40+r*5%3*4)};e.save(),e.globalAlpha*=i,e.fillStyle=r%2==0?yc:n.antenna,e.fill(pc(o,2.5+2*i)),e.restore()}return;case`zzz`:for(let n=0;n<3;n+=1){let r=(t.effectPhase+n*.33)%1,i=r<.2?r/.2:1-(r-.2)/.8;if(i<=.05)continue;let a={x:86+14*r+2*Math.sin(r*4*Math.PI),y:24-20*r},o=6+4*r,s=new Path2D,c=o*.62,l=o*.78;s.moveTo(a.x-c/2,a.y-l/2),s.lineTo(a.x+c/2,a.y-l/2),s.lineTo(a.x-c/2,a.y+l/2),s.lineTo(a.x+c/2,a.y+l/2),e.save(),e.globalAlpha*=i*.9,e.strokeStyle=yc,e.lineWidth=Math.max(1.2,o*.16),e.lineCap=`round`,e.lineJoin=`round`,e.stroke(s),e.restore()}return;case`sparks`:for(let n=0;n<5;n+=1){let r=t.effectPhase-n*.025;if(r<0||r>=.45)continue;let i=r<.08?r/.08:1-(r-.08)/.37,a=sc(-160+n*35),o=5+12*r/.45,s=2.2+n%3*.8,c={x:J(106+Math.cos(a)*o,s,gc-s),y:J(66+Math.sin(a)*o,s,gc-s)};e.save(),e.globalAlpha*=i,e.fillStyle=n%2==0?yc:bc,e.fill(pc(c,s)),e.restore()}return;case`sweat`:{let n=Zs(t.effectPhase);if(n<=.02)return;let r={x:42,y:24+7*t.effectPhase},i=new Path2D;i.moveTo(r.x,r.y-3),i.bezierCurveTo(r.x-4,r.y+1,r.x-2,r.y+3,r.x,r.y+3),i.bezierCurveTo(r.x+2,r.y+3,r.x+4,r.y+1,r.x,r.y-3),e.save(),e.globalAlpha*=n,e.fillStyle=`#80d4ff`,e.fill(i),e.restore()}}}function hc(e,t,n,r){let i=ac();if(n.save(),n.scale(r/gc,r/gc),e.bodyStretch!==1){let t=J(1+(1-e.bodyStretch)*.5,.97,1.03);n.translate(60,110),n.scale(t,e.bodyStretch),n.translate(-60,-110)}e.bodyTilt!==0&&(n.translate(60,60),n.rotate(sc(e.bodyTilt)),n.translate(-60,-60)),n.fillStyle=oc(n,i.body,t),n.fill(i.body.path),cc(n,e.leftClawDegrees,{x:26,y:53},()=>{n.fillStyle=oc(n,i.leftClaw,t),n.fill(i.leftClaw.path)}),cc(n,e.rightClawDegrees,{x:94,y:53},()=>{n.fillStyle=oc(n,i.rightClaw,t),n.fill(i.rightClaw.path)});let a=e.antennaDegrees*(1-e.antennaDroop);n.strokeStyle=t.antenna,n.lineWidth=2,n.lineCap=`round`,cc(n,-e.antennaDroop*40,{x:45,y:15},()=>{cc(n,a,{x:37.5,y:11},()=>n.stroke(i.leftAntenna))}),cc(n,e.antennaDroop*40,{x:75,y:15},()=>{cc(n,a,{x:82.5,y:11},()=>n.stroke(i.rightAntenna))}),fc(n,e.hardHat),uc(n,{x:45,y:35},e.leftEyeOpenness,e),uc(n,{x:75,y:35},e.rightEyeOpenness,e),dc(n,e),mc(n,e,t),n.restore()}var gc,_c,vc,yc,bc,xc,Sc,Cc;function wc(){return(wc=e((()=>{ic(),gc=120,_c=Math.PI*2,vc=`#050810`,yc=`#00e5cc`,bc=`#f2a833`,xc=`#ffd659`,Sc=`rgba(184, 115, 31, 0.7)`,Cc=null})))()}var Tc,Ec,Dc;function Oc(){return(Oc=e((()=>{K(),R(),Js(),Ze(),Gr(),pa(),Ft(),wc(),ic(),Mr(),r(),Tc=q(`<canvas>`),Ec=q(`<span class=openclaw-mascot--neutral>`),Dc=new Set(tc),ci(`openclaw-mascot`,(e,t)=>{t.setAttribute(`aria-hidden`,`true`);let n=ri,[r,i]=ho(!1),a=I(async()=>{if(r())try{let{MascotAnimator:e}=await v(async()=>{let{MascotAnimator:e}=await import(`./mascot-motion-runtime-CtKqPHti.js`).then(e=>(e.t(),e.n));return{MascotAnimator:e}},[],import.meta.url);return new e}catch{return}}),o,[s,c]=ho(0),l=()=>Dc.has(e.mood)?e.mood:`idle`,u=()=>Number.isFinite(e.size)&&e.size>0?e.size:120,d=Fi(`(prefers-reduced-motion: reduce)`),f=oa(),p=0,m=typeof IntersectionObserver>`u`,h,g=120,_,y=!1,b=()=>h?.isConnected&&m&&y&&o,x=()=>{p&&=(window.cancelAnimationFrame(p),0)},S=e=>{let t=h,n=typeof Path2D>`u`?null:t?.getContext(`2d`);if(!t?.isConnected||!n)return;let r=Math.max(1,window.devicePixelRatio||1),i=Math.round(g*r);(t.width!==i||t.height!==i)&&(t.width=i,t.height=i),n.setTransform(r,0,0,r,0,0),n.clearRect(0,0,g,g),hc(e,ec(document.documentElement.dataset.themeMode===`light`),n,g),t.style.transform=`translate3d(0, ${e.floatOffset*g/120}px, 0)`},ee=e=>{let t=_??o?.poseAt(e);t&&S(t)},te=e=>{p=0,b()&&(ee(e/1e3),p=window.requestAnimationFrame(te))},ne=()=>{m&&y&&i(!0),b()?p||=window.requestAnimationFrame(te):(x(),_&&S(_))},C=I(()=>[l(),e.tease,u(),n.read(),s()]);return Co(()=>[C(),d(),f(),Eo(a)?void 0:a()],([e,n,r,i],a)=>{let[s,c,l,u]=e;if(g=l,o=i,_=n||!o?$s(s):void 0,y=u.brandIcon===`claw`&&!n&&r,e!==a?.[0]||o!==a?.[3]){let e=performance.now()/1e3;o?.setMood(s,e),o?.setTease(c,e),t.style.setProperty(`--openclaw-mascot-size`,`${l}px`),ee(e)}ne()}),Sn(()=>[t],e=>{m=e.some(e=>e.isIntersecting),ne()}),H(()=>{let e=Ks(document,[`data-theme-mode`,`data-theme-mascot`],()=>c(e=>e+1));return ee(performance.now()/1e3),ne(),()=>{e(),x()}}),B(()=>B(()=>n.read().brandIcon===`claw`)()?(()=>{var e=Tc();return G(()=>e=>h=e,e),e})():(()=>{var e=Ec();return z(e,U(ln,{get branding(){return n.read()}})),e})())},{properties:{mood:{default:`idle`,reflect:!0},size:{default:120,type:Number},tease:{default:!1,type:Boolean}}})})))()}function kc(e,t,n){let r=t===`standard`?void 0:t,i=e.includes(`standard`);if(r===void 0&&i)return;let a=r&&e.includes(r)?r:e.find(e=>e!==`standard`)??(i?`standard`:void 0);return a===n?void 0:a}function Ac(){return(Ac=e((()=>{})))()}function jc(e){let{gateway:t}=e,n=t.snapshot.client,r=t.connectionRevision,i=t.connection.gatewayUrl,a=t.snapshot.hello?.auth?.recoveryScope;return()=>e.gateway===t&&t.snapshot.phase===`connected`&&t.connection.gatewayUrl===i&&t.connectionRevision===r&&t.snapshot.hello?.auth?.recoveryScope===a&&(!!a||t.snapshot.client===n)}function Mc(e,t,n){Nr({selection:e.agentSelection,gateway:e.gateway,sessionKey:t,agentId:n}),e.navigate(`chat`,ot({context:e,face:`chat`,sessionKey:t,agentId:n}).options)}function Nc(){return(Nc=e((()=>{Te(),ao()})))()}function Pc(e,t,n){let r=e();if(!r)return;ms();let i=jc(r),a=t.initialRun.status===`rejected`?E(`palette.sessionCreatedWithError`,{error:j(t.initialRun.error)}):E(t.initialRun.status===`started`?`palette.sessionStarted`:`palette.sessionCreated`);Ai({message:a,dedupeKey:`session-create:${t.agentId}:${t.key}`,severity:t.initialRun.status===`rejected`?`error`:`success`,actionLabel:E(`sessionsView.openSession`),onAction:()=>{e()===r&&i()&&(Mc(r,t.key,t.agentId),n?.())}})}function Fc(e){let t=jc(e.context);return(n,r)=>{let i=r?.trim();if(!e.enabled)return!1;if(!i)return!0;let{agentId:a,client:o,context:s}=e;return(async()=>{let e;for(;!e;)try{let t=await o.request(`agent.wait`,{runId:i,timeoutMs:3e4},{timeoutMs:null});if(s.gateway.snapshot.client!==o)return;let r=t.status===`timeout`&&t.endedAt===void 0&&!t.error&&!t.stopReason&&t.providerStarted!==!0;if(t.status===`pending`||t.pendingError===!0)await C(Lc);else if(r){let t=s.placementStartup.get(n)?.initialTurn;t?.sendState===`failed`&&t.sendRunId===i?e={status:`error`,error:t.sendError}:await C(Lc)}else e=t}catch{let e=s.gateway.snapshot,t=e.phase===`connecting`||e.phase===`starting`||e.phase===`reconnecting`;if(e.client!==o||!t)return;await C(Lc)}if(!t())return;let r=s.gateway.snapshot;if(ee(r,n,a))return;let c=s.sessions.state.result?.sessions.find(e=>m(e.key,n)),l=e.status===`ok`?void 0:e.status===`timeout`?E(`sessionsView.statusTimeout`):e.stopReason===`rpc`?E(`chat.handoffSessionStatus.stopped`):E(`sessionsView.statusFailed`),u=ot({face:`chat`,sessionKey:n,fallbackAgentId:a,exactKey:!0});s.nativeNotifications?.backgroundSessionCompleted({runId:i,path:u.options.pathname,...u.options.search?{search:u.options.search}:{}});let d=s.agents.state.agentsList?.agents.find(e=>e.id===a)??{id:a},f=s.agentIdentity.get(a);Ai({severity:e.status===`ok`?`success`:e.status===`timeout`?`error`:e.stopReason===`rpc`?void 0:`error`,placement:`top-right`,avatar:{id:a,name:Ur(d,f),avatar:b(d,f),textAvatar:ro(d,f)},message:tn(n,c),description:l,actionLabel:E(`sessionsView.openSession`),actionHref:ot({context:s,face:`chat`,sessionKey:n,agentId:a}).href,onAction:e=>{if(!t()){e?.preventDefault();return}let r=()=>Mc(s,n,a);e?e.type===`click`&&Gi(e,r):r()}})})(),!0}}function Ic(e,t,n,r){Hr({connected:e.gateway.snapshot.phase===`connected`,directComposerSend:r&&Oi(),message:t,hasAttachments:n,isCommand:Dt(t)!==null})&&na(e)}var Lc;function Rc(){return(Rc=e((()=>{y(),Jr(),O(),hs(),ra(),d(),ut(),k(),di(),ao(),_(),Lr(),Nc(),Lc=1e3})))()}var Y,zc,X;function Z(){return(Z=e((()=>{rt(),me(),Y=xt.catalog.newSession,zc={newSession:{openClawWorker:`Cloud device`,deviceFolder:`Existing folder`,deviceFolderOn:`Existing folder on {device}`,deviceFolderModelUnsupported:`Not available with this model`,deviceFolderDescription:`Work in place on the selected device. Files aren’t copied to this computer.`,deviceFolderPath:`Absolute path on device`,deviceFolderPathPlaceholder:`/path/to/existing/folder`,deviceFolderUnavailable:`This device can’t use an existing folder right now. Check its connection and session hosting, or choose another workspace.`,deviceFolderRuntimeUnsupported:`This model can’t work in an existing device folder. Choose an OpenClaw model or another workspace; your folder path is kept.`,deviceFolderPathRequired:`Enter an absolute path to an existing folder on the selected device.`,deviceFolderAttachmentsUnsupported:`Existing device folders can’t receive attachments. Remove them, or choose another workspace.`,requiredWorkerHint:`Say what you’d like to work on.`,requiredWorker:`Device`,requiredWorkerUnavailable:Y.requiredWorkerUnavailable,requiredWorkerChanged:Y.requiredWorkerChanged,title:ge.newSession.title,hint:ge.newSession.hint,environments:`Devices`,gateway:`This computer`,cloudWorkerMachine:`{profile} · {machine}`,cloudWorkerOsMachine:`{profile} · {os} · {machine}`,cloudWorkerOs:`{profile} · {os}`,cloudRuntimeUnsupported:`The {runtime} runtime doesn’t support cloud devices.`,cloudProfileRuntimeUnsupported:`The {runtime} runtime can’t use this cloud device. Choose a compatible cloud device or run on this computer.`,deviceRuntimeUnsupported:`This runtime doesn’t support paired devices`,placementStartFailed:Y.placementStartFailed,placementCreateFailed:`Couldn’t prepare session recovery. Your draft has been kept.`,placementStillStarting:Y.placementStillStarting,placementCompletionUnconfirmed:Y.placementCompletionUnconfirmed,placementReloadBlocked:ge.newSession.placementReloadBlocked,placementCancelled:Y.placementCancelled,discardUnsavedAndReload:ge.newSession.discardUnsavedAndReload,yourDevices:`Your devices`,autoDeviceSub:`Least-busy device`,autoDeviceSubEligible:`First eligible device`,cloud:Y.cloud,hosted:`Hosted workspaces`,hostedWorkspace:`Hosted workspace`,hostedHint:`Runs in the provider’s workspace. Files aren’t copied to this computer.`,hostedUnavailable:`This hosted workspace isn’t available. Check its setup or choose another workspace.`,hostModelRequired:`Choose a model with an available local runtime before selecting a device or cloud worker.`,hostedSetup:`Agents API setup`,hostedSetupHint:`Requires the enabled Agents API plugin, a compatible API-key model, and a hosted environment. ChatGPT subscriptions are not supported.`,machine:`Device size`,operatingSystem:`Operating system`,runsOn:Y.runsOn,browse:`Browse folders`,worktree:`Worktree`,checkingGit:`Checking Git availability…`,folderRequiresScope:`You need admin access to check Git for this folder. Ask an admin for access.`,folderRequiresWrite:`You need write access to check Git for this folder. Ask an admin for access.`,folderRequiresRead:`You need read access to check Git for this folder. Ask an admin for access.`,gitCheckAccessDenied:`You don’t have permission to check Git for this folder. Ask an admin for access.`,gitCheckUnavailable:`Couldn’t verify Git for this folder. Try again.`,starting:Y.starting,tryAgain:`Try again`,followUps:`Follow-up messages`,followUpCommandsUnavailable:Y.followUpCommandsUnavailable,followUpReloadBlocked:Y.followUpReloadBlocked,followUpsPaused:Y.followUpsPaused,followUpsAdmissionFailed:Y.followUpsAdmissionFailed,retrySetup:Y.retrySetup,createFailed:Y.createFailed,checkoutCurrentNote:`Works in the selected folder on its current branch.`,preferenceSaveUnconfirmed:Y.preferenceSaveUnconfirmed,worktreeNameClearUnconfirmed:Y.worktreeNameClearUnconfirmed,agent:`Agent`,agents:`Agents`,where:`Where`,gatewayNamed:`This computer · {name}`,cloudWorker:`Cloud device · {profile}`,cloudWorkerProvider:`Cloud provider: {provider}`,cloudRecoveryUnavailable:`Cloud devices are unavailable because this connection doesn’t support session recovery. Reconnect or update the Gateway.`,placementSyncsFolder:`Syncs {folder} to the selected device`,placementClonesRepository:`Clones {folder} on the selected device. No checkout is created on this computer.`,folder:`Folder`,autoDevice:`Auto`,neverConnected:`Never connected`,offlineFor:`Offline for {duration}`,lastSeen:`Last seen {time}`,nodeUpdateRequired:`Update this device: run {updateCommand}, then reconnect. For a headless device, run {restartCommand}.`,nodeCommandPendingApproval:`Ask an admin to approve the pending command request, or pick another device.`,nodeCommandUndeclared:`Make the required command available on this device, then reconnect, or pick another device.`,nodeCommandUnauthorized:`Ask an admin to allow the required command on this device, or pick another device.`,capabilityCamera:`Camera`,capabilityLocation:`Location`,capabilityTalk:`Talk`,capabilityScreenCapture:`Screen capture`,capabilityCanvas:`Canvas`,capabilityVoice:`Voice`,environmentDisposable:`Disposable`,environmentPersistent:`Persistent`,registerProject:`Register as project`,machineShape:`{cpu} vCPU · {memory} GB`,machineCpu:`{cpu} vCPU`,machineMemory:`{memory} GB`,machineDefault:`Default`,browseRequiresRead:`You need read access to browse folders. Ask an admin for access.`,browseRequiresWrite:`You need write access to browse folders on this device. Ask an admin for access.`,browseAccessDenied:`You don’t have permission to browse this folder. Ask an admin for access.`,browseRequiresAdmin:`You need admin access to browse outside agent workspaces. Ask an admin for access.`,browseRequiresAdminTooltip:`Only admins can browse outside agent workspaces.`,connectMachine:`Connect a device`,browserUp:`Parent folder`,browserUse:`Use this folder`,browserEmpty:`No subfolders yet.`,browserNoMatches:`No folders match your search.`,browserLoadFailed:`Couldn’t list that folder. Try again.`,hiddenFolder:`Hidden folder`,worktreeUnavailable:`The selected folder isn’t a Git checkout`,worktreeBaseRef:`From`,worktreeBranchesUnavailable:`Branch suggestions are unavailable. Enter a branch or commit.`,worktreeName:`Name`,worktreeNamePlaceholder:`From session title`,worktreeBranchNote:`Creates branch {branch} in a separate checkout.`,worktreeNameInvalid:`Use lowercase letters, digits, and dashes.`,draft:`Draft`,draftDescription:`Keep this session to yourself until you publish it`,draftUnavailable:`Draft creation is disabled. Your message and attachments have been kept. Turn off Draft to create a Shared session, or ask an administrator to enable Draft creation.`,messagePlaceholder:`Ask me anything, or hand me something to do`,dictate:`Dictate`,readingAttachment:`Reading attachment`,start:`Start session`,backgroundSend:`Background`,created:`Session created`,startInTerminal:`Start in terminal`,nativeTerminalHint:`Starts the native CLI on the selected device using its own account and configuration. This doesn’t create an OpenClaw session.`,nativeTerminalHintTooltip:`Opens the native CLI on the selected device with its own account and settings—not an OpenClaw session.`,chooseNativeHost:`Choose a device for the native CLI`,nativeHostsUnavailable:`No native CLI is available. Install it on this computer or connect a device with CLI access, then reconnect to the Gateway.`,nativeTerminalPrompt:`What should the CLI agent do first? (optional)`,terminalNodeFolder:`Existing absolute folder on this device`,terminalAttachmentsUnsupported:`Remove attachments before starting a native CLI. Add files from the terminal after it opens.`,createOutcomeUnknown:`The Gateway changed while this session was starting. Check recent sessions before starting this task again.`,cliAgentsGroup:`CLI agents`,cliAgentsUnavailable:`CLI agents unavailable`,placementSetupInterrupted:`This session’s device setup was interrupted. Check recent sessions before starting this task again.`,catalogUnavailable:`Couldn’t use this device or workspace. Refresh and try again.`,placementNotReady:`The selected runner isn't ready yet. Try again in a moment.`,nodeUnavailable:`The selected device is unavailable. Pick another place.`,terminalCapabilityOverridesUnsupported:`Clear session capability overrides before starting in a terminal.`,checkout:`Checkout`,checkoutCurrent:`Current checkout`,checkoutWorktree:`New worktree`,checkoutWorktreeNamed:`Worktree · {name}`,checkoutWorktreeFrom:`New worktree from {branch}`,checkoutCloud:`Starting branch`,checkoutCloudFrom:`From {branch}`,checkoutRepository:`Remote checkout`,checkoutRepositoryFrom:`Remote checkout from {branch}`,checkoutRequiresWorktree:`Use an isolated worktree for this project and agent`,checkoutCheckUnavailable:`Couldn’t check the checkout. Select the project again to retry.`,checkoutRemoteLocked:`Paired and cloud devices use a worktree`,local:`This computer`,folderPlaceholder:`Agent workspace`,localProjects:`Local projects`,noLocalProjects:`No local projects registered`,noLocalProjectMatches:`No local projects match`,noAdditionalGithubProjects:`No additional GitHub repositories`,projectsAdminHint:`Admins can register projects from Browse folders`,projectSearchPlaceholder:`Search projects or paste a Git URL`,searchProjects:`Search projects`,githubProjects:`GitHub`,githubTokenHint:`No GitHub account is configured for the web app or Gateway. Only public GitHub results are shown.`,cloneProject:`Clone`,recentFolders:`Recent`,what:`What`,newWorkspace:`New workspace`,newWorkspaceDescription:`Start without existing files. The agent uses its default workspace.`,remoteSourceUnavailable:`This folder cannot provide a Git checkout. Select New workspace to start empty, or choose a repository.`,environmentSearchPlaceholder:`Search devices`,environmentSearchEmpty:`No devices match your search.`,gatewayHost:`This computer`,device:`Device`,environmentDetails:`Show details for {name}`,concurrentSessionsValue:`{used} of {total} session slots in use`,autoDeviceChoose:`Any available device`,manageCloudWorkers:`Manage cloud workers`,persistentEnvironmentHint:`Reusable device`,disposableEnvironmentHint:`Disposable device`,sessionHostingAction:`Session hosting is disabled. Run these commands on the paired device:`,updateAction:`This device needs an update. Run the following command:`,reconnectAction:`Then reconnect the device. For a headless device, run:`,runsOnGateway:`Runs on this computer`,autoDeviceHint:`Chooses the least-busy connected device`,autoDeviceHintEligible:`Chooses the first eligible connected device`,autoDeviceInfo:`About automatic device selection`,autoDeviceScope:`Connected devices only`,restoringPreferences:`Restoring your last session setup…`,checkingPlace:`Checking the selected device…`,agentsUnavailable:`No agents are available on this Gateway. Ask an admin to add one before starting a session.`,loadingAgentDefaults:`Refreshing agent defaults…`,agentDefaultsUnavailable:`Couldn’t refresh agent defaults. Reload to try again.`,terminalHostUnavailable:`Native CLI unavailable on this device. Check that the CLI is installed and the device is connected with its fresh-start command approved, then try again.`,terminalDisabled:`Enable CLI agents and terminals in Gateway settings to start a native CLI.`,terminalPlacementUnsupported:`Native CLI sessions use a specific device. Reset this draft and choose a device for the native CLI.`,terminalNeedsFolder:`Pick a folder before starting in a terminal.`,noSessionHosts:`No devices have session hosting enabled. Connect a device with session hosting enabled, or enable it on a paired device.`,deviceUnavailable:`Device unavailable. Reconnect it and try again.`,environmentUnavailable:`Unavailable`,sessionHostingDisabled:`Session hosting is disabled. On the paired device, run openclaw config set nodeHost.workerRuns.enabled true, then openclaw node install --force.`,deviceCapacityUnavailable:`Device capacity is unavailable. Restart its session hosting and try again.`,deviceNoSlots:`No session slots are available. Wait for a slot or pick another device.`,connectMachineTitle:`Connect a device`,connectMachineDescription:`Run this command on the device you want to connect.`,connectMachineGenerating:`Creating a secure connection link…`,connectMachineFailed:`Couldn’t create the device connection link. Try again.`,connectMachineMissingUrl:`The Gateway didn’t return a connection link. Update it and try again.`,connectMachineUnavailable:`Reconnect to create a connection link.`,connectMachineTeamHint:`Installs a background service that connects this device to your team and can run agent sessions.`,connectMachineCommandOnly:`Command access only (no agent sessions)`,connectMachineInstalled:`Already have OpenClaw installed? Run this command:`,connectMachineSingleUse:`This link is single-use and expires soon.`,connectMachineSingleUseExpires:`This link is single-use and expires at {time}.`,connectMachineFreshCode:`Create new code`,connectMachineRefreshing:`Creating code…`,connectMachineManageDevices:`Manage devices`}},X=Object.assign(()=>{Object.assign(ge.newSession,zc.newSession)},{catalog:zc})})))()}var Bc;function Vc(){return(Vc=e((()=>{O(),Z(),k(),r(),X(),Bc=class{constructor(e,t){this.gateway=e,this.changed=t,this.openValue=!1,this.loadingValue=!1,this.errorValue=null,this.setupValue=null,this.requestId=0,this.request=null,this.requestListeners=new Set,this.subscribeRequests=e=>{let t=g(this.requestListeners,e);return this.request&&e(this.request),t}}get open(){return this.openValue}start(){this.openValue=!0,this.errorValue=null,this.setupValue=null,this.changed(),this.refresh()}close(){this.retireRequest?.(),this.retireRequest=void 0,this.request=null,this.requestId+=1,this.openValue=!1,this.loadingValue=!1,this.errorValue=null,this.setupValue=null}view(e,t){return{open:this.open&&e,loading:this.loadingValue,error:this.errorValue,setup:this.setupValue,subscribeRequests:this.subscribeRequests,onClose:()=>{this.close(),this.changed()},onRefresh:()=>void this.refresh(),onManageDevices:t}}refresh(){if(!this.openValue||this.loadingValue)return Promise.resolve();let{client:e,connected:t}=this.gateway();if(!t||!e)return this.errorValue=E(`newSession.connectMachineUnavailable`),this.changed(),Promise.resolve();let n=++this.requestId;this.loadingValue=!0,this.errorValue=null;let r=Promise.withResolvers();this.retireRequest=r.resolve;let i=this.load(n,e),a={completion:i,retired:r.promise,isCurrent:()=>this.loadingValue&&this.stillCurrent(n,e),reportError:t=>{this.stillCurrent(n,e)&&(this.errorValue=j(t),this.changed())}};this.request=a,this.changed();for(let e of this.requestListeners)e(a);return i}async load(e,t){try{let{requestDevicePairJoinSetup:n}=await v(async()=>{let{requestDevicePairJoinSetup:e}=await import(`./device-pair-setup-runtime-D-7HDL06.js`).then(e=>(e.a(),e.i));return{requestDevicePairJoinSetup:e}},__vite__mapDeps([1,2,0,3]),import.meta.url);if(!this.stillCurrent(e,t))return;let r=await n(t);if(!this.stillCurrent(e,t))return;if(!r.joinUrl?.trim()){this.setupValue=null,this.errorValue=E(`newSession.connectMachineMissingUrl`);return}this.setupValue=r}catch(n){this.stillCurrent(e,t)&&(this.errorValue=j(n))}finally{e===this.requestId&&(this.request=null,this.loadingValue=!1,this.changed())}}stillCurrent(e,t){let n=this.gateway();return e===this.requestId&&t===n.client&&n.connected&&this.openValue}}})))()}function Hc(e,t,n,r){return JSON.stringify([e,t,n,...r?[r]:[]])}function Uc(e){return Hc(e?.requestedAgentId??``,e?.catalogId??``,e?.group??``,e?.requestedModel)}function Wc(e){let t=Bo(e);return Hc(t.agentId,t.catalogId,t.group??``,t.requestedModel)}function Gc(e,t){return!e?.requestedAgentId||D(e.requestedAgentId)===D(t)?e?.requestedModel:void 0}function Kc(e){return!!(e?.catalogId&&e.startTerminal&&e.catalogLabel)}function qc(e){return A(e)&&!Kc(e)||!!(e?.group&&e.groupStatus!==`resolved`)}function Jc(e){return JSON.stringify([e?.groupStatus??``,e?.groupCwd??``,e?.groupWorktree===!0])}function Yc(e,t){return!(!e?.group||t&&e.groupStatus===`resolved`)}function Xc(e,t){return qc(e)||Yc(e,t)}function Zc(e,t){return e?.groupStatus===`resolved`&&!Yc(e,t)?e.group:void 0}function Qc(e,t,n){let r=e?.agentId?.trim(),i=r?D(r):void 0;return i&&t.some(e=>D(e.id)===i)?i:n&&D(n)}function $c(e,t){return!A(e)||Kc(e)&&!!t}async function el(e,t,n){if(e.client&&ae(e,`sessions.catalog.list`,`operator.read`))try{let r=(await e.client.request(`sessions.catalog.list`,{...n?{agentId:n}:{},catalogId:t,limitPerHost:1})).catalogs.find(e=>e.id===t),i=r?.capabilities.startTerminal;return r&&i===!0?{catalogLabel:r.label,startTerminal:!0,terminalHosts:r.hosts.filter(e=>e.canStartTerminal===!0).map(({hostId:e,label:t})=>({hostId:e,label:t}))}:void 0}catch{return}}var tl;function Q(){return(Q=e((()=>{O(),Z(),se(),_(),Yo(),X(),tl=class{constructor(e){this.notify=e}clear(){let e=this.read;this.read=void 0,e&&this.notify()}startRequest(e){let t={owner:e,canRetry:!1,completion:{promise:e.client.request(`sessions.catalog.list`,{agentId:e.agentId,metadataOnly:!0}).then(e=>{let n=e.catalogs.filter(e=>e.capabilities.startTerminal===!0).map(({id:e,label:t})=>({value:e,label:t}));return this.read===t&&(t.options=n,this.notify()),n},e=>{throw this.read===t&&(t.canRetry=!0,this.notify()),e})}};t.completion.promise.catch(()=>{}),this.read=t,this.notify()}load(e,t,n){let r=e?.gateway.snapshot,i=r?.client,a=t.trim()?D(t):``;if(!n||!i||!a||!ae(r,`sessions.catalog.list`,`operator.read`)){this.clear();return}let o={agentId:a,client:i},s=this.read;s&&s.owner.client===o.client&&s.owner.agentId===o.agentId||(this.clear(),this.startRequest(o))}retry(e,t){let n=this.read;n?.canRetry&&ae(e,`sessions.catalog.list`,`operator.read`)&&n.owner.client===e?.client&&n.owner.agentId===t&&this.startRequest(n.owner)}groups(){let e=this.read;if(e&&e.options?.length!==0)return[{errorLabel:E(`newSession.cliAgentsUnavailable`),id:`cliAgents`,label:E(`newSession.cliAgentsGroup`),options:e.options??[],completion:e.completion}]}}})))()}var nl;function rl(){return(rl=e((()=>{nl=[1e3,3e3,1e4,3e4,6e4]})))()}var il=t({requestPlaceCatalog:()=>al});async function al(e,t){let n=await e.request(`environments.list`,t?{runtimeId:t}:{});return{profiles:(n.profiles??[]).filter(e=>n.dispatchableProfileIds?.includes(e.id)??!0).toSorted((e,t)=>e.id.localeCompare(t.id)),suggestedProfile:n.suggestedProfile,environments:n.environments.filter(e=>[`local`,`node`,`worker`].includes(e.type)).toSorted((e,t)=>e.id.localeCompare(t.id))}}function ol(e){let t=e.cpu===void 0?void 0:String(e.cpu),n=e.memoryGb===void 0?void 0:String(e.memoryGb);return t&&n?E(`newSession.machineShape`,{cpu:t,memory:n}):t?E(`newSession.machineCpu`,{cpu:t}):n?E(`newSession.machineMemory`,{memory:n}):void 0}function sl(){return(sl=e((()=>{O(),Z(),Xn(),X(),Ba()})))()}function cl(e){let t=ll.get(e.client);t||(t=new WeakMap,ll.set(e.client,t));let n=t.get(e.hello);n||(n=new Map,t.set(e.hello,n));let r=JSON.stringify([e.gatewayUrl,e.profileId]),i=n.get(r);if(!i){let t=n,a=new ul(e,()=>{t.get(r)===a&&t.delete(r)});i=a,n.set(r,i)}return i}var ll,ul;function dl(){return(dl=e((()=>{kr(),Ma(),r(),ll=new WeakMap,ul=class{constructor(e,t){this.owner=e,this.release=t,this.mode=`loading`,this.palettePreference=null,this.listeners=new Map,this.writing=Promise.resolve(),this.pendingWrites=0,this.loading=this.load()}subscribe(e,t){return this.listeners.set(e,t),()=>{this.listeners.delete(e),this.releaseIfIdle()}}releaseIfIdle(){!this.listeners.size&&!this.pendingWrites&&this.release()}hasCurrentBinding(){return[...this.listeners.values()].some(e=>e())}setPalettePreference(e,t){if(!t())return Promise.resolve(!1);let n=async()=>{if(await this.loading,!this.hasCurrentBinding()||this.mode!==`remote`)return!1;try{return(await Ii(this.owner.client,{entries:{"new-session.palette.v1":e}})).status===`ok`&&(this.palettePreference=e,this.publish(`changed`),!0)}catch{return!1}};this.pendingWrites+=1;let r=this.writing.then(n,n);return this.writing=r.then(()=>{},()=>{}),r.finally(()=>{--this.pendingWrites,this.releaseIfIdle()})}publish(e){for(let[t,n]of this.listeners)n()&&t(e)}async load(){try{let{loadUserPreferences:e}=await v(async()=>{let{loadUserPreferences:e}=await import(`./user-prefs-request-DMVPtOdQ.js`).then(e=>(e.t(),e.r));return{loadUserPreferences:e}},__vite__mapDeps([0,3]),import.meta.url);if(!this.hasCurrentBinding())return;let t=await e(this.owner.client,this.owner.profileId);if(!this.hasCurrentBinding())return;if(t.status!==`ok`){this.mode=`local`;return}this.palettePreference=hr(t.entries[ba]),this.mode=`remote`}catch{this.mode=`local`}finally{this.publish(`loaded`)}}}})))()}function fl(e){return e.gatewayIdentityChanged||!e.placementDraftOwned?`gateway-changed`:`placement-interrupted`}var pl,ml;function hl(){return(hl=e((()=>{Go(),he(),pl=new WeakMap,ml=class{constructor(e){this.readOwner=e,this.sessionKey=``,this.messageId=``,this.message=``,this.target=null,this.agentId=``,this.gatewayUrl=``,this.recoveryScope=``,this.phase=`dispatching`,this.retryAllowed=!1,this.restored=!1,this.persistent=!0}releaseClaim(){this.claim?.owners.get(this.claim.key)===this&&this.claim.owners.delete(this.claim.key),this.claim=void 0}claimOwners(){let e=this.readOwner?.();if(!e)return;let t=pl.get(e);return t||(t=new Map,pl.set(e,t)),t}claimKey(e,t,n){return JSON.stringify([e,t,n])}clear(){this.persistent&&Wo(this.gatewayUrl,this.recoveryScope,this.sessionKey,this.messageId),this.reset()}hasOtherLiveOwner(e,t,n){let r=this.claimOwners()?.get(this.claimKey(e,t,n));return r!==void 0&&r!==this}owns(e,t,n){return!this.hasOtherLiveOwner(e,t,n)&&this.gatewayUrl===e&&this.recoveryScope===t&&this.sessionKey===n}reset(){this.releaseClaim(),this.sessionKey=``,this.messageId=``,this.message=``,this.mentions=void 0,this.attachments=void 0,this.target=null,this.agentId=``,this.gatewayUrl=``,this.recoveryScope=``,this.phase=`dispatching`,this.createParams=void 0,this.retryAllowed=!1,this.restored=!1,this.persistent=!0}restore(e,t){let n=this.claimOwners(),r=qo(e,t).find(r=>{let i=n?.get(this.claimKey(e,t,r.sessionKey));return r.phase===`creating`&&(!i||i===this)});return!r||r.phase!==`creating`?null:(this.apply(r,!0,!0),r)}capture(){return this.snapshot(this.sessionKey,this.phase)}stageCreate(e){let t=`agent:${e.agentId}:dashboard:${T()}`,n=Ho({...e.createParams,key:t},t,e.agentId);if(!n)return null;let r=e.persistent!==!1;r||delete n.key;let i={sessionKey:t,messageId:T(),message:e.message,...e.mentions?.length?{mentions:e.mentions}:{},attachments:e.attachments,target:e.target,agentId:e.agentId,gatewayUrl:e.gatewayUrl,recoveryScope:e.recoveryScope,phase:`creating`,createParams:n};return r&&!Zo(i)?null:(this.apply(i,!1,r),n)}promoteToDispatching(e){let t=this.sessionKey,n=this.snapshot(e,`dispatching`);return!n||this.persistent&&!Jo(t,n)?!1:(this.releaseClaim(),this.sessionKey=e,this.phase=`dispatching`,this.createParams=void 0,!0)}snapshot(e,t){return!this.sessionKey||!this.messageId||!this.target||!this.agentId||t===`creating`&&!this.createParams?null:{sessionKey:e,messageId:this.messageId,message:this.message,...this.mentions?.length?{mentions:this.mentions}:{},attachments:this.attachments,target:this.target,agentId:this.agentId,gatewayUrl:this.gatewayUrl,recoveryScope:this.recoveryScope,phase:t,...t===`creating`&&this.createParams?{createParams:this.createParams}:{}}}apply(e,t,n){this.releaseClaim();let r=this.claimOwners();if(r&&e.phase===`creating`){let t=this.claimKey(e.gatewayUrl,e.recoveryScope,e.sessionKey);r.set(t,this),this.claim={owners:r,key:t}}this.sessionKey=e.sessionKey,this.messageId=e.messageId,this.message=e.message,this.mentions=e.mentions,this.attachments=e.attachments,this.target=e.target,this.agentId=e.agentId,this.gatewayUrl=e.gatewayUrl,this.recoveryScope=e.recoveryScope,this.phase=e.phase,this.createParams=e.createParams,this.retryAllowed=!0,this.restored=t,this.persistent=n}}})))()}var gl,_l;function vl(){return(vl=e((()=>{we(),p(),O(),Z(),se(),ia(),Q(),rl(),sl(),Ji(),dl(),hl(),X(),gl=[0,1e3,3e3],_l=class{static requiredPlacement(e,t){return!!e.requiredProfile&&!A(t)}constructor(e,t){this.read=e,this.callbacks=t,this.cloudProfilesValue=[],this.gatewayAuthorityValue=``,this.environmentsValue=null,this.cloudProfilesReadyValue=!1,this.catalogRetryingValue=!1,this.catalogRevalidationPending=!1,this.gatewaySource=null,this.gatewayClientValue=null,this.gatewayUrlValue=``,this.gatewayBootIdValue=``,this.gatewayRecoveryScopeValue=``,this.gatewayRecoveryScopeReady=!1,this.gatewayConnectedValue=!1,this.gatewayConnectionEpochValue=0,this.catalogRetryScope=``,this.catalogRetryAttempt=0,this.cloudProfileRetryAttempt=0,this.cloudProfileRefresh=null,this.gatewayNameValue=``,this.gatewayNameArgs=[],this.cloudProfileArgs=[],this.cloudProfileStatus=`initial`,this.cloudProfileComplete=Promise.resolve(),this.handleCatalogRetry=()=>{let{context:e,data:t}=this.read();if(!this.gatewayConnectedValue||t?.group&&e?.sessions.groupsStatus()===`loading`||!t?.startTerminal&&!Xc(t,e?.sessions))return;if(this.catalogRetryingValue){this.catalogRevalidationPending=!0;return}t?.group&&e?.sessions.groupsInvalidate();let n=e?.revalidate(`new-session`);n&&(globalThis.clearTimeout(this.catalogRetryTimer),this.catalogRetryTimer=void 0,this.catalogRetryingValue=!0,this.catalogRevalidation=n,this.callbacks.changed(),n.catch(()=>void 0).then(()=>this.callbacks.updateComplete()).finally(()=>{this.catalogRetryingValue=!1,this.catalogRevalidationPending?(this.catalogRevalidationPending=!1,this.handleCatalogRetry()):this.retryPendingCatalogTarget(),this.callbacks.changed()}))},this.preferences=new tr(()=>({source:this.gatewaySource,client:this.gatewayClientValue,gatewayUrl:this.gatewayUrlValue,recoveryScope:this.gatewayRecoveryScopeValue,bootId:this.gatewayBootIdValue,connected:this.gatewayConnectedValue,connectionEpoch:this.gatewayConnectionEpochValue,data:this.read().data,pendingPlacementSessionKey:this.read().pendingPlacement.sessionKey,agentsHydrated:this.read().agentsHydrated}),t)}synchronizeMetadata(){this.synchronizeGatewayName(),this.synchronizeCloudProfiles()}synchronizeGatewayName(){let e=this.read().isConnected&&this.gatewayConnectedValue?this.gatewaySource:null,t=zr(this.read().context?.gateway.snapshot)&&document.visibilityState!==`hidden`,n=[e,t,this.gatewayConnectionEpochValue];if(n.every((e,t)=>Object.is(e,this.gatewayNameArgs[t]))||(this.gatewayNameArgs=n,this.gatewayNameRequest?.abort(),this.gatewayNameRequest=void 0,this.gatewayNameValue=``,!e||!t))return;let r=new AbortController;this.gatewayNameRequest=r,ji(e,r.signal).then(({value:e})=>{r.signal.aborted||(this.gatewayNameValue=l(e.machineName)??l(e.hostname)?.split(`.`,1)[0]??``)}).catch(()=>void 0).finally(()=>{this.gatewayNameRequest===r&&(this.gatewayNameRequest=void 0,this.callbacks.changed())})}cloudProfileInput(){return[this.read().isConnected&&this.gatewayConnectedValue?this.gatewayClientValue:null,this.gatewayConnectionEpochValue,u(this.read().context?.gateway.snapshot.hello?.auth??null),this.read().isAdmin,this.gatewayRecoveryScopeValue,this.read().runtimeId,this.placementPolicy()]}synchronizeCloudProfiles(){let e=this.cloudProfileInput();e.every((e,t)=>Object.is(e,this.cloudProfileArgs[t]))||this.readCloudProfiles(e)}readCloudProfiles(e=this.cloudProfileInput()){this.cloudProfileArgs=e;let[t,n,r,i,a,o,s]=e,c={};if(this.cloudProfileRequest=c,this.cloudProfileStatus=t&&s?`pending`:`initial`,!t||!s)return this.callbacks.changed(),Promise.resolve();let l=s.requiredProfile,u=l||!r?Promise.resolve({profiles:l?.providerId?[{...l,providerId:l.providerId}]:[],environments:[],suggestedProfile:void 0}):al(t,o).then(e=>({...e,profiles:e.profiles,suggestedProfile:i?e.suggestedProfile:void 0}));return this.cloudProfileComplete=u.then(e=>{this.cloudProfileRequest===c&&(this.cloudProfileStatus=`complete`,this.resetCloudProfileRetry(),this.environmentsValue=e.environments,this.applyCloudProfiles(e.profiles),this.suggestedProfileValue=e.profiles.length===0?e.suggestedProfile:void 0,this.cloudProfilesReadyValue=!0)}).catch(()=>{this.cloudProfileRequest===c&&(this.cloudProfileStatus=`error`,this.scheduleCloudProfileRetry())}).finally(()=>{this.cloudProfileRequest===c&&this.callbacks.changed()}),this.callbacks.changed(),this.cloudProfileComplete}retireCloudProfiles(){this.cloudProfileRequest=void 0,this.cloudProfileArgs=[],this.cloudProfileStatus=`initial`}get gatewayName(){return this.gatewayNameValue}get cloudProfiles(){return this.cloudProfilesValue}get suggestedProfile(){return this.suggestedProfileValue}async adoptSuggestedProfile(){let e=this.gatewayClientValue,t=this.gatewayConnectionEpochValue,n=this.sessionCreateScope;if(!e||!this.gatewayConnectedValue||!this.read().isAdmin||!this.suggestedProfileValue)return;let{profile:r}=await e.request(`environments.adoptSuggestedProfile`,{});if(e===this.gatewayClientValue&&t===this.gatewayConnectionEpochValue&&n===this.sessionCreateScope&&this.gatewayConnectedValue&&this.read().isAdmin)return this.readCloudProfiles(),this.applyCloudProfiles([r]),this.suggestedProfileValue=void 0,this.callbacks.changed(),r.id}placementPolicy(){return this.callbacks.readAgents()?.state.agentsList?.sessionPlacement}get requiredProfile(){return this.placementPolicy()?.requiredProfile?.id}get placementPolicyReady(){let e=this.placementPolicy();return e!==void 0&&(!e.requiredProfile||this.cloudProfilesReadyValue)}get environments(){return this.environmentsValue}get cloudProfilesReady(){return this.cloudProfilesReadyValue}get cloudProfilesRead(){return this.cloudProfileStatus===`initial`?void 0:this.cloudProfileComplete}get cloudProfilesPending(){return this.cloudProfileStatus===`pending`}get deviceCatalogDisabledReason(){return this.cloudProfilesReadyValue&&this.cloudProfileStatus===`complete`?void 0:E(`newSession.placementNotReady`)}get catalogRetrying(){return this.catalogRetryingValue}get catalogRetryRead(){return this.catalogRevalidation}get client(){return this.gatewayClientValue}get gatewayUrl(){return this.gatewayUrlValue}get recoveryScope(){return this.gatewayRecoveryScopeValue}get sessionCreateScope(){let e=[this.gatewayUrlValue,this.gatewayRecoveryScopeValue,this.gatewayBootIdValue];return e.every(Boolean)?JSON.stringify(e):``}get connected(){return this.gatewayConnectedValue}get connectionEpoch(){return this.gatewayConnectionEpochValue}get preferenceLoading(){return this.preferences.loading||this.identityPreferences?.mode===`loading`}refreshCloudProfiles(){if(this.cloudProfileStatus===`pending`){let e=this.cloudProfileRefresh??this.cloudProfileComplete.catch(()=>void 0).then(()=>{if(this.cloudProfileRefresh===e)return this.cloudProfileRefresh=null,this.refreshCloudProfiles()});return this.cloudProfileRefresh=e,e}return globalThis.clearTimeout(this.cloudProfileRetryTimer),this.cloudProfileRetryTimer=void 0,this.readCloudProfiles()}async retryRequiredPlacement(){await this.callbacks.readAgents()?.refreshList(),await this.refreshCloudProfiles()}synchronize(e){let t=e.snapshot,n=t.phase===`connected`,r=this.gatewaySource===null,i=n?t.hello?.server?.bootId?.trim()??``:this.gatewayBootIdValue,a=!r&&n&&!!this.gatewayBootIdValue&&i!==this.gatewayBootIdValue,o=!r&&this.gatewayUrlValue!==e.connection.gatewayUrl,s=!r&&this.gatewaySource!==e,c=n?JSON.stringify([t.selfUser?.id,t.hello?.auth?.role,t.hello?.auth?.scopes?.toSorted()]):this.gatewayAuthorityValue,l=!r&&this.gatewayAuthorityValue!==c,u=!r&&(s||this.gatewayClientValue!==t.client||l),d=!r&&this.gatewayConnectedValue!==n,f=n&&(u||!this.gatewayConnectedValue),p=n&&t.client?.recoveryScopeReady===!0&&!this.gatewayRecoveryScopeReady,m=n?t.hello?.auth?.recoveryScope??``:ne({client:t.client})??``,h=!r&&this.gatewayRecoveryScopeValue!==m;if(this.gatewayAuthorityValue=c,this.gatewaySource=e,this.gatewayClientValue=t.client,this.gatewayUrlValue=e.connection.gatewayUrl,this.gatewayBootIdValue=i,this.gatewayRecoveryScopeValue=m,this.gatewayRecoveryScopeReady=t.client?.recoveryScopeReady===!0,this.gatewayConnectedValue=n,o||a||u||d||h){let e=s||o||h||l,t=o||h;this.invalidateDiscovery(e,fl({gatewayIdentityChanged:t,placementDraftOwned:!!this.read().pendingPlacement.sessionKey}))}if(r||o||h||p||f){let e=this.read().pendingPlacement;e.gatewayUrl&&(e.gatewayUrl!==this.gatewayUrlValue||e.recoveryScope!==this.gatewayRecoveryScopeValue)&&this.callbacks.onPendingPlacementReset(),m&&(!n||t.client?.recoveryScopeReady)&&this.callbacks.onRecoveryReady(this.gatewayUrlValue,this.gatewayRecoveryScopeValue)}f&&(this.gatewayConnectionEpochValue+=1,!r&&this.read().data?.startTerminal?this.handleCatalogRetry():this.retryPendingCatalogTarget()),this.preferences.synchronize(),this.synchronizeIdentityPreferences(t.selfUser?.id),this.callbacks.changed()}invalidateDiscovery(e,t){this.cloudProfileRefresh=null,this.retireCloudProfiles(),this.cloudProfilesValue=[],this.suggestedProfileValue=void 0,this.cloudProfilesReadyValue=!1,e&&(this.environmentsValue=null),this.resetCloudProfileRetry(),this.callbacks.onInvalidate(e,t),this.callbacks.changed()}retryPendingCatalogTarget(){let{context:e,data:t}=this.read();if(this.catalogRetryingValue)return;if(t?.group&&e?.sessions.groupsStatus()===`loading`){globalThis.clearTimeout(this.catalogRetryTimer),this.catalogRetryTimer=void 0;return}if(!this.gatewayConnectedValue||!Xc(t,e?.sessions)){globalThis.clearTimeout(this.catalogRetryTimer),this.catalogRetryTimer=void 0,this.catalogRetryScope=``,this.catalogRetryAttempt=0;return}let n=`${this.gatewayConnectionEpochValue}:${Uc(t)}`;if(this.catalogRetryScope!==n&&(globalThis.clearTimeout(this.catalogRetryTimer),this.catalogRetryTimer=void 0,this.catalogRetryScope=n,this.catalogRetryAttempt=0),this.catalogRetryTimer||this.catalogRetryAttempt>=gl.length)return;let r=gl[this.catalogRetryAttempt];this.catalogRetryAttempt+=1,this.catalogRetryTimer=globalThis.setTimeout(()=>{this.catalogRetryTimer=void 0;let e=this.read();if(this.catalogRetryScope!==n||!this.gatewayConnectedValue||e.data?.group&&e.context?.sessions.groupsStatus()===`loading`||!Xc(e.data,e.context?.sessions))return;e.data?.group&&e.context?.sessions.groupsInvalidate();let t=e.context?.revalidate(`new-session`);t&&t.catch(()=>void 0).then(()=>this.callbacks.updateComplete()).then(()=>this.retryPendingCatalogTarget())},r)}get preferenceState(){return this.identityPreferences}savePalettePreference(e){let t=this.identityPreferences,n=this.read().context?.gateway.snapshot,r=n?.client,i=n?.hello,a=n?.selfUser?.id,o=this.gatewayUrlValue;return t?.setPalettePreference(e,()=>this.identityPreferences===t&&this.gatewayConnectedValue&&this.read().context?.gateway.snapshot.client===r&&this.read().context?.gateway.snapshot.hello===i&&this.read().context?.gateway.snapshot.selfUser?.id===a&&this.read().context?.gateway.connection.gatewayUrl===o)??Promise.resolve(!1)}readPreference(e){return this.preferences.readPreference(e)}capturePreferenceConsumption(e,t,n){if(this.callbacks.preferenceScope!==`palette`)return this.preferences.capturePreferenceConsumption(e,t,n)}persistModelPreference(e,t){return this.preferences.persistPreference(e,void 0,t)}persistPreference(e,t,n){if(this.callbacks.preferenceScope!==`palette`)return this.preferences.persistPreference(e,t,n)}disconnect(){this.preferences.disconnect(),this.stopPreferences?.(),this.stopPreferences=void 0,this.identityPreferences=void 0,this.cloudProfilesValue=[],this.suggestedProfileValue=void 0,this.cloudProfilesReadyValue=!1,this.environmentsValue=null,this.cloudProfileRefresh=null,this.gatewaySource=null,this.gatewayAuthorityValue=``,this.gatewayClientValue=null,this.gatewayConnectedValue=!1,this.gatewayConnectionEpochValue=0,this.catalogRetryScope=``,this.catalogRetryAttempt=0,globalThis.clearTimeout(this.catalogRetryTimer),this.catalogRetryTimer=void 0,this.gatewayNameRequest?.abort(),this.gatewayNameRequest=void 0,this.gatewayNameArgs=[],this.gatewayNameValue=``,this.retireCloudProfiles(),this.resetCloudProfileRetry()}applyCloudProfiles(e){let t=e.length>0&&!this.gatewayRecoveryScopeValue;this.cloudProfilesValue=t?[]:e;let n=this.read(),r=!!n.pendingPlacement.sessionKey,i=u(n.context?.gateway.snapshot.hello?.auth??null);(!this.gatewayConnectedValue||!i)&&!r&&this.callbacks.onCloudProfileCleared(),!r&&n.cloudProfileId&&!e.some(e=>e.id===n.cloudProfileId)?this.callbacks.onCloudState(E(`newSession.catalogUnavailable`)):t?this.callbacks.onCloudState(E(`newSession.cloudRecoveryUnavailable`)):this.callbacks.onCloudState(null)}resetCloudProfileRetry(){globalThis.clearTimeout(this.cloudProfileRetryTimer),this.cloudProfileRetryTimer=void 0,this.cloudProfileRetryAttempt=0}scheduleCloudProfileRetry(){if(this.cloudProfileRetryTimer||!this.gatewayConnectedValue||!this.gatewayClientValue||this.cloudProfileRetryAttempt>=nl.length)return;let e=nl[this.cloudProfileRetryAttempt];this.cloudProfileRetryAttempt+=1,this.cloudProfileRetryTimer=globalThis.setTimeout(()=>{this.cloudProfileRetryTimer=void 0,this.gatewayConnectedValue&&this.readCloudProfiles()},e)}synchronizeIdentityPreferences(e){let t=this.gatewayConnectedValue?this.gatewayClientValue:null,r=this.read().context,i=r?.gateway.snapshot.hello,a=r&&n(r.gateway.snapshot,`users.prefs.get`)===!0&&n(r.gateway.snapshot,`users.prefs.set`)===!0,o=this.callbacks.preferenceScope===`palette`&&t&&i&&e&&a?cl({client:t,hello:i,profileId:e,gatewayUrl:this.gatewayUrlValue}):void 0;if(o===this.identityPreferences||(this.stopPreferences?.(),this.stopPreferences=void 0,this.identityPreferences=o,!o))return;let s=()=>{this.identityPreferences===o&&this.callbacks.changed()};this.stopPreferences=o.subscribe(s,()=>this.identityPreferences===o&&this.gatewayConnectedValue&&this.read().context?.gateway.snapshot.client===t&&this.read().context?.gateway.snapshot.hello===i&&this.read().context?.gateway.connection.gatewayUrl===this.gatewayUrlValue),o.mode!==`loading`&&s()}}})))()}function yl(e){let t=e.replace(/[\\/]+$/u,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));if(n<0)return;let r=n===0?t.slice(0,1):t.slice(0,n);return Pt(r)||void 0}function bl(e){return e.startsWith(`/`)||e.startsWith(`\\`)||/^[A-Za-z]:[\\/]/.test(e)}function xl(e){if(!bl(e))return null;let t=e.trim().replaceAll(`\\`,`/`),n=/^[A-Za-z]:\//u.test(t)||t.startsWith(`//`),r=[],i=/^[A-Za-z]:\//u.test(t)?1:t.startsWith(`//`)?2:0;for(let e of t.split(`/`))e&&e!==`.`&&(e===`..`?r.length>i&&r.pop():r.push(e));let a=`${t.startsWith(`//`)?`//`:t.startsWith(`/`)?`/`:``}${r.join(`/`)}`.replace(/\/+$/u,``)||`/`;return n?a.toLowerCase():a}function Sl(e,t){let n=xl(e);return n!==null&&n===xl(t)}function Cl(e,t){let n=xl(t);return n!==null&&e.some(e=>{let t=xl(e);return t!==null&&(n===t||n.startsWith(t===`/`?t:`${t}/`))})}function wl(){return(wl=e((()=>{})))()}function Tl(e){return e instanceof xe&&e.gatewayCode===`INVALID_REQUEST`&&/^(?:Error:\s+)?(?:ENOENT|ENOTDIR):/u.test(e.message)}var El;function Dl(){return(Dl=e((()=>{Se(),El=class{constructor(e,t){this.read=e,this.callbacks=t,this.state=`none`,this.requestToken=0,this.approvedRoots=[]}knownWorkspaceRoots(e){return e?[e,...this.approvedRoots]:this.approvedRoots}recordApprovedListing(e){if(this.read().isAdmin)return;let t=new Set(this.approvedRoots);t.add(e.path),e.parent&&t.add(e.parent),t.size!==this.approvedRoots.length&&(this.approvedRoots=[...t],this.callbacks.onApprovedRootsChange())}reset(){this.cancel(),this.approvedRoots=[]}get blocked(){return this.state!==`none`}cancel(){this.requestToken+=1,this.state=`none`}restore(){this.state=`none`,this.callbacks.onMissing()}validate(e){let t=this.read().gateway,n=t?.client;if(t?.phase!==`connected`||!n){this.restore();return}let r=++this.requestToken;this.state=`checking`;let i=()=>{let t=this.read();return r===this.requestToken&&!t.selectedByUser&&t.folder===e};n.request(`fs.listDir`,{path:e}).then(e=>{i()&&(this.recordApprovedListing(e),this.state=`none`,this.callbacks.onVerified())}).catch(e=>{i()&&(!this.read().isAdmin||Tl(e)?this.restore():(this.state=`failed`,this.callbacks.onFailed()))})}}})))()}function Ol(e){if(!bl(e))return null;let t=/^[A-Za-z]:[\\/]/u.test(e)?3:1,n=e.search(/[\\/]+$/u),r=n>=0?n:Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return{directory:e.slice(0,Math.max(t,r)),prefix:n>=0?``:e.slice(r+1)}}function kl(e,t){if(!t)return[...e];let n=t.toLowerCase().normalize(`NFC`),r=[],i=[],a=[],o=[];for(let s of e){if(s.hidden&&!t.startsWith(`.`))continue;let e=s.name.toLowerCase().normalize(`NFC`);s.name===t?r.push(s):e===n?i.push(s):e.startsWith(n)?a.push(s):e.includes(n)&&o.push(s)}return[...r,...i,...a,...o]}function Al(e){let{listing:t,draft:n,loading:r}=e,i=Ol(n);if(t&&Sl(n,t.path)||!i){let e=t?.entries??[];return{entries:e,empty:t&&e.length===0&&!r?`no-subfolders`:`none`}}if(t&&Sl(i.directory,t.path)){let e=kl(t.entries,i.prefix);return{entries:e,empty:e.length===0&&!r?i.prefix?`no-matches`:`no-subfolders`:`none`}}return{entries:[],empty:r?`none`:`no-matches`}}function jl(){return(jl=e((()=>{wl()})))()}var Ml;function Nl(){return(Nl=e((()=>{fe(),O(),Z(),Dl(),wl(),jl(),X(),Ml=class{constructor(e,t,n){this.listDirectory=e,this.changed=t,this.onListing=n,this.listing=null,this.draft=``,this.loading=!1,this.readCompletion=null,this.error=null,this.activeIndex=-1,this.token=0}navigate(e,t=`navigation`){this.cancelPending(),this.draft=e??``,this.activeIndex=-1,this.error=null,this.loading=!0;let n=this.load(e,t,this.token);return this.readCompletion=n,this.changed(),n.then(()=>{})}setDraft(e){this.cancelPending(),this.draft=e,this.activeIndex=-1,this.error=null;let t=Ol(e.trim());if(this.loading=!(!t||this.draftInLoadedDirectory()),t&&this.loading){let e=this.token;this.readCompletion=new Promise(n=>{this.timer=globalThis.setTimeout(()=>{this.timer=void 0,this.load(t.directory,`typing`,e).then(n)},300)})}this.changed()}draftInLoadedDirectory(){if(!this.listing)return!1;let e=this.draft.trim(),t=Ol(e);return!t||Sl(e,this.listing.path)||Sl(t.directory,this.listing.path)}moveHighlight(e){let t=this.view().entries.length;t!==0&&(this.activeIndex=this.activeIndex<0?e===1?0:t-1:(this.activeIndex+e+t)%t,this.changed())}highlightedEntry(){return this.view().entries[this.activeIndex]}completeHighlighted(){let e=this.highlightedEntry()??this.view().entries[0];return!e||this.draft.trim()===e.path?!1:(this.setDraft(e.path),!0)}async activate(){let e=this.usablePath();e!==null&&await this.navigate(this.highlightedEntry()?.path??(e||void 0))}usablePath(){let e=this.draft.trim();return!e||bl(e)?e:null}reset(){this.cancelPending(),this.listing=null,this.draft=``,this.loading=!1,this.error=null,this.activeIndex=-1}view(){let e=this.draft.trim();return Al({listing:this.listing,draft:e,loading:this.loading})}cancelPending(){this.token+=1,globalThis.clearTimeout(this.timer),this.timer=void 0,this.readCompletion=null}async load(e,t,n){let r=this.draft;try{let i=await this.listDirectory(e);if(n!==this.token)return null;this.listing=i,t!==`typing`&&this.draft===r&&(this.draft=i.path),this.activeIndex=-1,this.onListing?.(i)}catch(r){if(n!==this.token)return null;if(t===`initial`&&e&&Tl(r))return this.draft=``,await this.load(void 0,`navigation`,n);if(t!==`typing`){let e=de(r)?.missingScope;return E(e===`operator.admin`?`newSession.browseRequiresAdmin`:e===`operator.write`?`newSession.browseRequiresWrite`:e===`operator.read`?`newSession.browseRequiresRead`:e?`newSession.browseAccessDenied`:`newSession.browserLoadFailed`)}}finally{n===this.token&&(this.loading=!1,this.changed())}return null}}})))()}function Pl(e){let t=e.trim();return!t||t.startsWith(`-`)||/\s/u.test(t)?null:/^(?:https:\/\/|ssh:\/\/git@|git@[^:]+:)/iu.test(t)?t:null}function Fl(e){let t=e.folder.trim(),n=e.projects.find(t=>t.id===e.projectId),r=e.projectQuery.trim().toLowerCase().normalize(`NFC`);return{label:e.freshWorkspace?E(`newSession.newWorkspace`):n?n.repositoryIdentity??n.displayName:e.selectedRemoteProject?.identity?e.selectedRemoteProject.identity:t?Pt(t):Pt(e.workspace)||E(`newSession.folderPlaceholder`),recents:r?[]:e.recents.filter(e=>e.kind!==`project`),showWorkspace:!r||Pt(e.workspace).toLowerCase().normalize(`NFC`).includes(r)}}function Il(){return(Il=e((()=>{O(),Z(),X()})))()}var Ll;function Rl(){return(Rl=e((()=>{p(),es(),k(),se(),Mi(),wl(),Nl(),Il(),Ll=class{constructor(e,t,n){this.gateway=e,this.read=t,this.callbacks=n,this.projectFocus={},this.lastProjectResult=null,this.projectSelection=null,this.projectQueryValue=``,this.environmentQueryValue=``,this.debouncedProjectQuery=``,this.browserOpenValue=!1,this.browserNodeIdValue=``,this.browserProjectPathValue=null,this.browserRegistration=null,this.openPopoverValue=null,this.focusRequestId=0,this.projectSearchArgs=[],this.projectSearchReadValue=null,this.projectSearchRequest=Qo(()=>this.callbacks.changed(),{task:([e,t],{signal:n})=>e.request(`projects.searchRemote`,{query:t},{signal:n}),onComplete:e=>{this.finishProjectSearch?.({result:e}),this.finishProjectSearch=void 0},onError:e=>{this.finishProjectSearch?.({error:e}),this.finishProjectSearch=void 0}}),this.browser=new Ml(e=>{let t=this.read().context?.gateway.snapshot;return t?.phase!==`connected`||!t.client||!this.browserOpenValue?Promise.reject(Error(`Folder browser is unavailable`)):t.client.request(`fs.listDir`,{...this.browserNodeIdValue?{nodeId:this.browserNodeIdValue}:{},...e?{path:e}:{}})},this.callbacks.changed,e=>{if(this.browserProjectPathValue=null,this.browserNodeIdValue)return;this.callbacks.onApprovedListing(e);let t=this.read(),n=t.context?.gateway;t.isAdmin&&n?.snapshot.client&&ps(n,`worktrees.branches`,{repoRoot:e.path,includeRepositoryStatus:!0}).then(t=>{this.browser.listing===e&&t.repositoryStatus===`git`&&(this.browserProjectPathValue=e.path,this.callbacks.changed())}).catch(()=>void 0)})}synchronize(){let e=this.browserRegistration;e&&(!this.gateway.connected||e.client!==this.gateway.client||e.epoch!==this.gateway.connectionEpoch)&&this.retireRegistration(),this.bindProjectCatalog();let t=this.projectSearchInput();t.every((e,t)=>Object.is(e,this.projectSearchArgs[t]))||this.searchProjects(t)}projectSearchInput(){return[this.read().context&&this.gateway.connected?this.gateway.client:null,ae(this.read().context?.gateway.snapshot,`projects.searchRemote`,`operator.read`),this.debouncedProjectQuery,this.gateway.connectionEpoch]}searchProjects(e=this.projectSearchInput()){this.projectSearchArgs=e,this.projectSearchRequest.cancel(),this.finishProjectSearch?.(null),this.finishProjectSearch=void 0,this.projectSearchReadValue=null;let[t,n,r]=e;if(!t||!n||r.length<2||Pl(r))return;let i=Promise.withResolvers();this.projectSearchReadValue={query:r,completed:i.promise},this.finishProjectSearch=i.resolve,this.projectSearchRequest.run([t,r])}get projects(){return this.projectCatalog?.snapshot.result?.projects??[]}get projectsReady(){return this.projectCatalog?.snapshot.ready??!1}get projectCatalogError(){return this.projectCatalog?.snapshot.error??null}get projectsLoading(){return this.projectCatalog?.loading??!1}get projectRead(){return this.projectCatalog?.pendingRead??null}get projectRecents(){return this.projectCatalog?.snapshot.result?.recents}get githubHost(){return this.projectCatalog?.snapshot.result?.githubHost}get defaultRemoteProject(){let e=this.projectCatalog?.snapshot.result?.defaultRepository;return e?{identity:e.identity,cloneUrl:e.url,...e.ref?{defaultBranch:e.ref}:{}}:null}get defaultRemoteProjectProfileId(){return this.projectCatalog?.snapshot.result?.defaultRepository?.profileId??``}get projectId(){return this.projectSelection?.kind===`local`?this.projectSelection.id:``}get canOpenRemoteProjects(){return u(this.read().context?.gateway.snapshot.hello?.auth??null)}get remoteProject(){return this.projectSelection?.kind===`remote`?this.projectSelection.project:null}get projectQuery(){return this.projectQueryValue}get environmentQuery(){return this.environmentQueryValue}changeEnvironmentQuery(e){this.environmentQueryValue=e,this.callbacks.changed()}get projectSearchRead(){return this.projectSearchReadValue?.query===this.projectQueryValue.trim()?this.projectSearchReadValue:null}get browserOpen(){return this.browserOpenValue}get browserNodeId(){return this.browserNodeIdValue}get browserProjectPath(){return this.browser.loading||!this.browser.draftInLoadedDirectory()?null:this.browserProjectPathValue}get browserRegistering(){return this.browserRegistration!==null}popoverOpen(e){return this.openPopoverValue===e}popoverCallbacks(e){return{popoverOpen:this.popoverOpen(e),onPopoverShow:()=>this.transitionPopover(e,!0),onPopoverHide:()=>this.transitionPopover(e,!1),onPopoverAfterHide:this.callbacks.changed}}bindProjectCatalog(){let e=this.gateway.connected?this.read().context?.gateway:void 0;if(e===this.projectCatalogGateway)return;this.projectCatalogCleanup?.(),this.projectCatalogGateway=e,this.projectCatalog=e?Xr(e):void 0,this.lastProjectResult=null;let t=()=>{let e=this.projectCatalog?.snapshot.result??null;e&&e!==this.lastProjectResult&&(this.lastProjectResult=e,this.projectId&&!e.projects.some(e=>e.id===this.projectId)&&this.callbacks.onProjectMissing()),this.callbacks.changed()};this.projectCatalogCleanup=this.projectCatalog?.subscribe(t),t()}async refreshProjects(e=!1){this.bindProjectCatalog(),await this.projectCatalog?.refresh(e)}selectedProject(){return this.projects.find(e=>e.id===this.projectId)??(this.gateway.connected?void 0:this.selectedProjectRecord)}selectProject(e){this.projectSelection=e,this.selectedProjectRecord=this.projects.find(e=>e.id===this.projectId)}recordRemoteProjectId(e,t){let n=this.remoteProject;n?.cloneUrl===e&&(this.projectSelection={kind:`remote`,project:{...n,projectId:t}})}clearProjectSelection(){this.projectSelection=null,this.selectedProjectRecord=void 0}resolveProjectRecents(e){let t=t=>e.isAdmin||Cl(e.workspaceRoots,t),n=this.projectRecents?.filter(e=>e.kind===`project`?this.projects.some(t=>t.id===e.projectId):e.kind===`repository`||!e.execNode&&t(e.folder));if(n!==void 0)return n;let r=new Set;for(let n of e.sessions){let i=l(n.execCwd)??l(n.worktree?.repoRoot)??n.spawnedCwd?.trim(),a=l(n.execNode);if(i&&!a&&!n.deviceFolder&&i!==e.workspace&&t(i)&&(r.add(i),r.size>=4))break}return Array.from(r,e=>({kind:`folder`,folder:e,displayName:Pt(e)}))}changeProjectQuery(e){this.projectQueryValue=e,this.clearProjectSearchTimer(),this.debouncedProjectQuery=``,this.searchProjects([null,!1,``,this.gateway.connectionEpoch]);let t=e.trim(),n=this.read().context;if(t.length<2||Pl(t)||!this.gateway.connected||!this.gateway.client||!n||!ae(n.gateway.snapshot,`projects.searchRemote`,`operator.read`)){this.callbacks.changed();return}let r=this.gateway.client,i=this.gateway.connectionEpoch;this.projectSearchTimer=globalThis.setTimeout(()=>{this.projectSearchTimer=void 0,r===this.gateway.client&&i===this.gateway.connectionEpoch&&(this.debouncedProjectQuery=t,this.searchProjects([r,!0,t,i]),this.callbacks.changed())},300),this.callbacks.changed()}resetProjectSearch(){this.clearProjectSearchTimer(),this.projectQueryValue=``,this.debouncedProjectQuery=``,this.callbacks.changed()}resetProjects(e=!0){this.projectCatalog&&this.refreshProjects(!0),e&&(this.clearProjectSelection(),this.resetProjectSearch())}close(){this.resetBrowser(!0)}showRoot(){let e=this.browserOpenValue;this.resetBrowser(!1),e&&this.focusProjectView(`browse`)}selectGatewayBrowser(e){this.openBrowser(``,e)}selectDeviceBrowser(e,t){this.openBrowser(e,t)}openBrowser(e,t){this.browserOpenValue=!0,this.browserNodeIdValue=e,this.browserProjectPathValue=null,this.browser.navigate(t&&bl(t)?t:void 0,`initial`),this.focusProjectView(`path`)}async registerBrowserProject(e,t){let n=this.read(),r=n.context?.gateway.snapshot,i=r?.client;if(r?.phase!==`connected`||!i||!n.isAdmin||this.browserProjectPath!==e||this.browserRegistering)return;let a=this.browser.listing,o=Promise.withResolvers(),s=this.gateway.connectionEpoch,c={retire:o.resolve,client:i,epoch:s};this.browserRegistration=c;let l=()=>this.gateway.connected&&this.browser.listing===a&&this.browserProjectPath===e&&i===this.gateway.client&&s===this.gateway.connectionEpoch,u=()=>this.browserRegistration===c&&l();this.browser.error=null,this.browser.readCompletion=null,this.callbacks.changed(),t?.({retired:o.promise,isCurrent:l});try{let t=await i.request(`projects.register`,{path:e});if(!u()||(await this.refreshProjects(!0),!u()))return;this.callbacks.onSelectProject(t.id),this.close()}catch(e){u()&&(this.browser.error=j(e))}finally{this.browserRegistration===c&&(this.browserRegistration=null,this.callbacks.changed())}}transitionPopover(e,t){t?(this.openPopoverValue=e,e===`where`&&(this.environmentQueryValue=``)):this.openPopoverValue===e&&(this.openPopoverValue=null),e===`project`?this.showRoot():this.callbacks.changed()}disconnect(){this.focusRequestId+=1,this.environmentQueryValue=``,this.browser.reset(),this.retireRegistration(),this.clearProjectSearchTimer(),this.projectCatalogCleanup?.(),this.projectCatalogCleanup=void 0,this.projectCatalogGateway=void 0,this.projectCatalog=void 0,this.searchProjects([null,!1,``,-1])}resetBrowser(e){this.focusRequestId+=1,this.browser.reset(),this.browserOpenValue=!1,this.browserNodeIdValue=``,this.browserProjectPathValue=null,this.retireRegistration(),e&&(this.openPopoverValue=null),this.callbacks.changed()}retireRegistration(){this.browserRegistration?.retire(),this.browserRegistration=null}clearProjectSearchTimer(){globalThis.clearTimeout(this.projectSearchTimer),this.projectSearchTimer=void 0}focusProjectView(e){let t=++this.focusRequestId,n=this.callbacks.activeElement();this.callbacks.updateComplete().then(()=>{if(t!==this.focusRequestId||this.openPopoverValue!==`project`)return;let r=this.callbacks.activeElement(),i=this.projectFocus[e];i?.isConnected&&(!r||r===n||r===r.ownerDocument.body||r===this.projectFocus.search)&&i.focus({preventScroll:!0})})}}})))()}function zl(e){return e.available+(e.reclaimableIdle??0)}function Bl(){return(Bl=e((()=>{})))()}function Vl(e){let t=e?.issues?.find(e=>e.code===`update-required`);return t?E(`newSession.nodeUpdateRequired`,{updateCommand:t.updateCommand,restartCommand:t.headlessReconnectCommand}):e?.issues?.find(e=>e.code===`worker-host-unavailable`)?.message}function Hl(e){if(e.connected)return;let t=e.environment;if(t?.lastConnectedAtMs===void 0)return E(`newSession.neverConnected`);if(t.lastDisconnectedAtMs!==void 0){let e=Me(Math.max(0,Date.now()-t.lastDisconnectedAtMs))??E(`common.justNow`);return E(`newSession.offlineFor`,{duration:e})}let n=t.lastSeenAtMs??t.lastConnectedAtMs;return E(`newSession.lastSeen`,{time:oi(n)})}function Ul(e,t={}){let n=Hl({environment:e,connected:t.connected??!0}),r=Vl(e)??n,i=r?[r]:[];e?.platform&&i.push(ze(e.platform));for(let t of Wl(e?.capabilities))if(i.includes(t)||i.push(t),i.length>=4)break;return i}function Wl(e=[]){return[...new Set(e.flatMap(e=>{let t=e.split(`.`,1)[0]?.toLowerCase(),n=Object.entries(Gl).find(([e])=>e===t)?.[1];return n?[E(n)]:[]}))]}var Gl;function Kl(){return(Kl=e((()=>{O(),Z(),Rt(),Or(),uo(),X(),Gl={camera:`newSession.capabilityCamera`,location:`newSession.capabilityLocation`,talk:`newSession.capabilityTalk`,screen:`newSession.capabilityScreenCapture`,canvas:`newSession.capabilityCanvas`,microphone:`newSession.capabilityVoice`,voice:`newSession.capabilityVoice`}})))()}function ql(e,t,n){let r=new Map;for(let[n,i]of e.entries()){let e=t(i);r.set(e,[...r.get(e)??[],n])}let i=e.map(()=>void 0);for(let t of r.values()){if(t.length<2)continue;let r=n.at(-1);if(!r)continue;let a=n.find(n=>{let i=t.map(t=>n(e[t])??r(e[t]));return i.every(e=>e!==void 0)&&new Set(i).size===t.length})??r;for(let n of t)i[n]=a(e[n])??r(e[n])}return i}function Jl(){return(Jl=e((()=>{})))()}function Yl(e,t){let n=Vl(e);if(n!==void 0)return n;if(e.status!==`available`)return E(`newSession.deviceUnavailable`);if(e.sessionHost!==!0)return E(`newSession.sessionHostingDisabled`);if(t.requiredNodeCommands.length>0){let t=e.requiredNodeCommand;if(!t)return E(`newSession.placementNotReady`);if(t.state!==`invocable`&&t.message)return t.message;if(t.state===`pending-approval`)return E(`newSession.nodeCommandPendingApproval`,{command:t.command});if(t.state===`undeclared`)return E(`newSession.nodeCommandUndeclared`,{command:t.command});if(t.state===`unauthorized`)return E(`newSession.nodeCommandUnauthorized`,{command:t.command})}if(t.consumesWorkerSlot)return e.workerSlots?zl(e.workerSlots)===0?E(`newSession.deviceNoSlots`):void 0:E(`newSession.deviceCapacityUnavailable`)}function Xl(e,t=tu,n){let r=(e??[]).flatMap(e=>{if(e.type!==`node`||!e.id.startsWith(`node:`))return[];let r=e.id.slice(5).trim();if(!r)return[];let i=n??Yl(e,t),a=Ul(e,{connected:e.status===`available`}),o=+((e.issues?.length??0)>0||e.status!==`available`),s=i&&!a.includes(i)?[...a.slice(0,o),i,...a.slice(o)].slice(0,4):a;return[{deviceId:r,label:e.label??r,platform:e.platform,hideDetails:!n&&e.status===`unavailable`&&!e.issues?.length,remediation:n?void 0:e.issues?.some(e=>e.code===`update-required`)?`update-device`:e.status===`available`&&e.sessionHost!==!0&&!e.issues?.length?`enable-session-hosting`:void 0,facts:n?[n]:s,workerSlots:e.workerSlots,workerHost:e.workerHost,capabilities:e.capabilities,invocableCommands:e.invocableCommands,selectable:i===void 0,...i?{disabledReason:i}:{}}]}).toSorted((e,t)=>e.label.localeCompare(t.label)||e.deviceId.localeCompare(t.deviceId)),i=ql(r,e=>e.label,[e=>e.deviceId.slice(0,8)]);return r.forEach((e,t)=>{let n=i[t];n&&(r[t]={...e,subtitle:n})}),r}function Zl(e,t,n){if(n)return n;let r=new Set((e??[]).filter(e=>e.type===`node`&&e.sessionHost===!0).map(e=>e.id));if(r.size===0){let t=(e??[]).find(e=>e.issues?.some(e=>e.code===`update-required`||e.code===`worker-host-unavailable`));return t?Yl(t,tu):E(`newSession.noSessionHosts`)}return t.some(e=>e.selectable)?void 0:t.find(e=>r.has(`node:${e.deviceId}`))?.disabledReason}function Ql(e,t,n){let r=e.find(e=>e.deviceId===n.deviceId);return{ready:n.autoDevice?e.some(e=>e.selectable):!n.deviceId||r?.selectable===!0,disabledReason:n.autoDevice?Zl(t,e):n.deviceId?r?.disabledReason??E(`newSession.nodeUnavailable`):void 0}}function $l(e,t){return!!(e&&t.some(t=>t.deviceId===e&&t.selectable&&t.workerHost?.deviceFolders===!0))}function eu(e,t){return t.find(t=>t.deviceId===e&&t.workerHost?.deviceFolders===!0&&t.invocableCommands?.includes(`fs.listDir`))}var tu;function nu(){return(nu=e((()=>{Bl(),O(),Z(),Kl(),X(),tu={requiredNodeCommands:[],consumesWorkerSlot:!0}})))()}function ru(e,t){return e.executionModes?.includes(t)===!0}function iu(e){return e.operatingSystems?.find(e=>e.default)?.id??e.operatingSystems?.[0]?.id??e.machines?.find(e=>e.os)?.os??``}function au(e,t){return(e.machines??[]).filter(e=>!e.os||e.os===t)}function ou(e,t=iu(e)){let n=au(e,t);return n.find(e=>e.default)??n.find(e=>n.every(t=>e.cpu!==void 0&&e.memoryGb!==void 0&&t.cpu!==void 0&&t.memoryGb!==void 0&&e.cpu<=t.cpu&&e.memoryGb<=t.memoryGb))??n[0]}function su(){return(su=e((()=>{})))()}var cu;function lu(){return(lu=e((()=>{cu=class{constructor(){this.overrides=new Map}clear(){this.overrides.clear()}applyPending(e,t,n){t||n?this.overrides.set(e,{machineClass:t,os:n}):this.overrides.delete(e)}resolve(e){return this.overrides.get(e)?.machineClass??``}resolveOs(e){return this.overrides.get(e)?.os??``}selection(e,t){let n=t.find(t=>t.id===e),r=this.resolveOs(e)||n&&iu(n)||``;return{machineClass:this.resolve(e)||n&&ou(n,r)?.id||``,os:r}}selectedOs(e){return this.resolveOs(e.id)||iu(e)}machines(e){return au(e,this.selectedOs(e))}selectOs(e,t,n,r=!1,i){let a=n.find(t=>t.id===e),o=a?.operatingSystems?.find(e=>e.id===t);if(r||!a||!o||o.disabledReason)return!1;let s=this.resolve(e);return this.applyPending(e,au(a,o.id).some(e=>e.id===s)?s:void 0,o.id),i?.(),!0}select(e,t,n,r=!1,i){let a=n.find(t=>t.id===e),o=a&&this.machines(a).find(e=>e.id===t);return r||!o?!1:(this.applyPending(e,o.id,this.selectedOs(a)),i?.(),!0)}}})))()}function uu(e){let t=e?.gateway?.github?.host?.trim().toLowerCase()||`github.com`;if(!/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/u.test(t)||t.includes(`..`))throw Error(`gateway.github.host must be a hostname`);return t}function du(){return(du=e((()=>{})))()}function fu(e){let t=e.split(`/`).filter(Boolean),n=t[0],r=t[1]?.replace(/\.git$/iu,``);return t.length!==2||!n||!r||!mu.test(n)||!mu.test(r)||n===`.`||n===`..`||r===`.`||r===`..`?null:{owner:n,repo:r}}function pu(e,t=uu()){let n=e.trim();if(!n||n.startsWith(`-`)||n.includes(`\0`)||/[\r\n\t ]/u.test(n))return null;let r=`git@${t}:`,i=n.toLowerCase().startsWith(r)?n.slice(r.length):void 0,a;if(i!==void 0)a=fu(i);else{let e=URL.parse(n);if(!e)return null;let r=e.protocol===`https:`,i=e.protocol===`ssh:`&&e.username===`git`&&(!e.port||e.port===`22`);if(!r&&!i||e.hostname.toLowerCase()!==t||e.password||r&&e.username||e.search||e.hash)return null;a=fu(e.pathname)}return a?{url:`https://${t}/${a.owner.toLowerCase()}/${a.repo.toLowerCase()}.git`,name:a.repo}:null}var mu;function hu(){return(hu=e((()=>{du(),mu=/^[A-Za-z0-9_.-]+$/u})))()}function gu(){return{deviceId:``,autoDevice:!1,cloudProfileId:``,freshWorkspace:!0,folderSelectedByUser:!1,preferredWhereRestore:null,preferredProjectRestore:``,preferredRemoteProjectRestore:null,configuredDefaultRepositoryPending:!1,configuredDefaultRepositoryOptOut:!1,whereSelectedByUser:!1,projectSelectedByUser:!1,requiredModelDefaults:!1}}function _u(e,t,n,r,i){let a=e.preferredWhereRestore??Ir(e);return{workspace:r,folder:i,projectId:e.preferredProjectRestore||t.projectId,remoteProject:e.preferredRemoteProjectRestore??t.remoteProject,defaultRepositoryOptOut:e.configuredDefaultRepositoryOptOut,where:a,worktree:(a.kind!==`local`||n.preferenceWorktree)&&!n.remoteRepository,freshWorkspace:e.freshWorkspace,baseRef:n.baseRef,worktreeName:n.worktreeName}}function vu(e,t){return!e.folderSelectedByUser&&!e.whereSelectedByUser&&!e.projectSelectedByUser&&!t.hasUserSelection}function yu(e,t){e.projectSelectedByUser=!0,e.preferredProjectRestore=``,e.preferredRemoteProjectRestore=null,e.configuredDefaultRepositoryPending=!1,e.configuredDefaultRepositoryOptOut=t}function bu(e,t,n,r){let i=n||r;if(!e.whereSelectedByUser){let n=i?void 0:t?.where;e.preferredWhereRestore=n?.kind===`local`?null:n??null}e.preferredProjectRestore=i?``:t?.projectId??``,e.preferredRemoteProjectRestore=i?null:t?.remoteProject??null,e.configuredDefaultRepositoryOptOut=t?.defaultRepositoryOptOut===!0,e.configuredDefaultRepositoryPending=!i&&!e.configuredDefaultRepositoryOptOut&&!t?.projectId&&!t?.remoteProject,e.preferredRemoteProjectRestore&&(e.preferredProjectRestore=``),e.projectSelectedByUser=!1}function xu(e,t,n,r=!1){return r||t&&!(e.configuredDefaultRepositoryPending&&n)&&e.preferredWhereRestore===null&&!e.preferredProjectRestore&&!e.preferredRemoteProjectRestore}function Su(e){let{state:t,browser:n,gateway:r,modelControl:i,repositoryState:a,isAdmin:o,persistPreference:s,changed:c}=e;if(t.requiredModelDefaults!==e.requiredPlacement&&(t.requiredModelDefaults=e.requiredPlacement,e.loadConfiguredDefaults(e.requiredPlacement)),e.requiredPlacement){(n.browserOpen||[`where`,`project`,`checkout`].some(e=>n.popoverOpen(e)))&&n.close();return}let l=!1,u=t.whereSelectedByUser?null:t.preferredWhereRestore,d=t.projectSelectedByUser?``:t.preferredProjectRestore,f=t.preferredRemoteProjectRestore,p=n.remoteProject;if((f||p)&&n.projectsReady&&n.githubHost){let e=e=>pu(e.cloneUrl,n.githubHost)!==null,r=f&&!e(f),i=p&&!e(p);(r||i)&&(r&&(t.preferredRemoteProjectRestore=null),i&&(n.clearProjectSelection(),t.projectSelectedByUser=!1),(i||r&&!p&&!n.projectId)&&a.clearDetails(!0),t.configuredDefaultRepositoryPending=!t.configuredDefaultRepositoryOptOut&&!d,s({remoteProject:t.preferredRemoteProjectRestore??n.remoteProject??null}),l=!0)}let m=n.defaultRemoteProject,h=n.defaultRemoteProjectProfileId,g=h?r.cloudProfiles.find(e=>e.id===h):void 0,_=!!(m&&t.preferredRemoteProjectRestore?.cloneUrl===m.cloneUrl),v=t.configuredDefaultRepositoryPending||_,y=v&&n.projectsReady&&(!h||r.cloudProfilesReady),b=!!(y&&(!h||o()&&g&&!i.cloudRuntimeUnsupportedReason(g))),x=t.projectSelectedByUser||!n.projectsReady?null:_?b?t.preferredRemoteProjectRestore:null:t.preferredRemoteProjectRestore??(b?m:null);if(y&&(t.configuredDefaultRepositoryPending=!1,_&&!b&&(t.preferredRemoteProjectRestore=null,l=!0),c()),x&&!n.canOpenRemoteProjects)t.preferredRemoteProjectRestore=null,l=!0;else if(x){let r=v&&x.cloneUrl===m?.cloneUrl;h&&r&&b&&!t.whereSelectedByUser&&!u&&e.where.kind===`local`&&(t.deviceId=``,t.autoDevice=!1,t.cloudProfileId=h),n.selectProject({kind:`remote`,project:x}),t.freshWorkspace=!1,t.folderSelectedByUser=!1,(r&&!_||!a.baseRef&&x.defaultBranch)&&a.setDetail(`baseRef`,x.defaultBranch??``,!1),t.preferredRemoteProjectRestore=null,l=!0}if(d&&!x){let e=n.projects.find(e=>e.id===d);e&&(n.selectProject({kind:`local`,id:e.id}),t.folderSelectedByUser=!1),(e||n.projectsReady)&&(t.preferredProjectRestore=``,l=!0)}if(u&&u.kind!==`local`&&r.cloudProfilesReady){if(u.kind===`cloud`){let e=r.cloudProfiles.find(e=>e.id===u.id);o()&&e&&!i.cloudRuntimeUnsupportedReason(e)?(t.deviceId=``,t.autoDevice=!1,t.cloudProfileId=u.id):(t.cloudProfileId=``,s({where:{kind:`local`}}))}else t.autoDevice=u.kind===`auto-device`,t.deviceId=u.kind===`device`?u.id:``,t.cloudProfileId=``;t.preferredWhereRestore=null,l=!0}l&&(a.synchronize(),c())}function Cu(){return(Cu=e((()=>{hu(),Ma()})))()}function wu(e){if(e.remoteProject)return{kind:`pending-clone`,cloneUrl:e.remoteProject.cloneUrl};if(e.selectedProject&&!e.selectedProject.repoRoot)return e.selectedProject.source===`workspace`?{kind:`idle`}:{kind:`pending-project`,projectId:e.selectedProject.id};let t=e.selectedProject?.repoRoot??(e.folder.trim()||e.workspace);return t?!e.selectedProject&&t===e.workspace&&!e.workspaceGit?{kind:`direct`,repoRoot:t}:{kind:`checking`,repoRoot:t}:{kind:`idle`}}var Tu;function Eu(){return(Eu=e((()=>{h(),fe(),p(),O(),Z(),ra(),es(),_(),X(),Tu=class{get checkoutRead(){return this.checkoutReadValue}get repositoryRead(){return this.repositoryReadValue}get refreshing(){return typeof this.checkoutOptions==`object`&&this.checkoutOptions.refreshing===!0||this.repositoryValue.kind===`checking`||this.repositoryValue.kind===`git`&&this.repositoryValue.refreshing===!0}checkoutVisible(e){return this.repositoryValue.kind===`direct`&&!e?!1:this.checkoutPending||e||this.repositoryValue.kind===`unavailable`||this.available()||(this.read().remotePlacement||this.worktree)&&!this.remoteRepository}get checkoutPending(){let e=this.checkoutOptions;return this.read().selectedProject&&!this.read().remotePlacement?this.currentCheckoutUnavailable===`checking`||typeof e==`object`&&e.refreshing===!0&&this.checkoutSubmissionBlocked:this.repositoryValue.kind===`checking`&&!this.worktree}constructor(e,t){this.read=e,this.callbacks=t,this.worktreeValue=!1,this.details={worktreeName:``},this.repositoryValue={kind:`idle`},this.readController=new AbortController,this.selectionRevision=0,this.preferredWorktreeRestore=!1,this.worktreeSelectedByUser=!1,this.selectedDetails=new Set}matchesProjectCheckout(){let{selectedProject:e,agentId:t,remotePlacement:n}=this.read();return n||!e?!this.checkoutScope:this.checkoutScope?.project===e&&this.checkoutScope.agentId===t}get currentCheckoutUnavailable(){let e=this.read();if(e.remotePlacement)return;if(!e.selectedProject)return this.requiresWorktree?`worktree`:void 0;let t=this.checkoutOptions;return!this.matchesProjectCheckout()||!t||t===`loading`?`checking`:t===`error`?`unavailable`:t.refreshing&&!t.current&&!t.worktree?`checking`:t.current?void 0:t.worktree?`worktree`:`unavailable`}get checkoutSubmissionBlocked(){if(!this.read().selectedProject||this.read().remotePlacement)return!1;let e=this.checkoutOptions;return!this.matchesProjectCheckout()||!e||typeof e==`string`||!(this.worktreeValue?e.worktree:e.current)}get currentCheckoutUnavailableReason(){let e=this.currentCheckoutUnavailable;return e===`checking`?E(`newSession.checkingPlace`):e===`worktree`?E(`newSession.checkoutRequiresWorktree`):e===`unavailable`?E(`newSession.checkoutCheckUnavailable`):void 0}synchronizeProjectCheckout(){this.matchesProjectCheckout()||this.load()}get requiresWorktree(){return this.repositoryValue.kind===`git`&&this.repositoryValue.requiresWorktree===!0&&this.matchesCurrentRepo()}get worktree(){return this.worktreeValue||this.requiresWorktree}get preferenceWorktree(){return this.worktreeValue||this.preferredWorktreeRestore}get worktreeName(){return this.details.worktreeName}get baseRef(){return this.details.baseRef??``}get remoteRepository(){let{remotePlacement:e,remoteProject:t}=this.read();if(!e||!t)return;let n=this.baseRef.trim();return{url:t.cloneUrl,...n?{ref:n}:{}}}get repository(){return this.repositoryValue}get preferenceReady(){return!this.preferredWorktreeRestore}get hasUserSelection(){return this.worktreeSelectedByUser||this.selectedDetails.size>0}adoptPreference(e){if(this.worktreeSelectedByUser||(this.worktreeValue=!1,this.preferredWorktreeRestore=e?.worktree===!0&&(!e.where||e.where.kind===`local`)),!this.selectedDetails.has(`baseRef`)){let t=e?.baseRef||void 0;this.details.baseRef!==t&&(this.selectionRevision+=1),this.details.baseRef=t}if(!this.selectedDetails.has(`worktreeName`)){let t=e?.worktreeName??``;this.details.worktreeName!==t&&(this.selectionRevision+=1),this.details.worktreeName=t}this.matchesCurrentRepo()?this.repositoryValue.kind!==`checking`&&this.adoptResolvedRepository(this.repositoryValue):this.invalidate()}reset(){this.invalidate(),this.worktreeValue=!1,this.clearDetails(),this.preferredWorktreeRestore=!1,this.worktreeSelectedByUser=!1}clearDetails(e=!1){this.selectionRevision+=1,this.details.baseRef=void 0,this.details.worktreeName=``,this.selectedDetails.clear(),e&&this.callbacks.persistPreference({baseRef:``,worktreeName:``})}invalidate(){this.readController.abort(),this.repositoryValue={kind:`idle`},this.checkoutScope=void 0,this.checkoutOptions=void 0,this.checkoutReadValue=void 0,this.repositoryReadValue=void 0}selectWorktree(e,t=!0){this.selectionRevision+=1,this.preferredWorktreeRestore=!1,this.worktreeSelectedByUser=!0,this.worktreeValue=e,t&&this.clearDetails(!0)}rejectPreferredWorktree(){this.preferredWorktreeRestore=!1,this.worktreeValue=!1,this.clearDetails(!0)}select(e){return this.worktree===e||this.read().remotePlacement||(e?!this.available():this.currentCheckoutUnavailable)?!1:(this.selectWorktree(e,!1),this.callbacks.persistPreference({folder:this.read().folder.trim()||this.read().workspace,worktree:this.worktreeValue}),this.callbacks.changed(),!0)}setDetail(e,t,n){n||(this.selectionRevision+=1,this.details[e]=t,this.selectedDetails.add(e),this.callbacks.persistPreference({[e]:t}),this.callbacks.changed())}captureSubmittedName(e,t){let n=e.worktreeName?.trim();if(!e.worktree||!n)return;let r=this.selectionRevision,i=this.read(),a=D(t.agentId),o=wr(i.agents,a),s={agentId:a,workspace:l(o?.workspace)??``},c=s.agentId===i.agentId,u=this.callbacks.capturePreferenceConsumption(s,{worktreeName:n,...t.recovered?{}:{selectedBaseRef:this.details.baseRef?.trim()??``},folder:e.cwd??(c&&i.folder.trim()||s.workspace),baseRef:e.worktreeBaseRef??(c?this.baseRef:void 0),projectId:e.projectId??(c?i.selectedProject?.id:void 0)});return u&&(()=>u(()=>{s.agentId===this.read().agentId&&r===this.selectionRevision&&n===this.details.worktreeName.trim()&&(this.selectionRevision+=1,this.details.worktreeName=``,this.selectedDetails.add(`worktreeName`),this.callbacks.changed())}))}available(){let e=this.read();if(e.selectedProject&&!e.remotePlacement){let e=this.checkoutOptions;return this.matchesProjectCheckout()&&e!==void 0&&typeof e!=`string`&&e.worktree}let t=this.repositoryValue;return t.kind===`git`||t.kind===`pending-clone`||t.kind===`pending-project`}matchesCurrentRepo(){let e=this.read(),t=this.repositoryValue;if(!this.matchesProjectCheckout())return!1;if(t.kind===`pending-project`)return!e.remoteProject&&!e.selectedProject?.repoRoot&&e.selectedProject?.id===t.projectId;if(t.kind===`pending-clone`)return e.remoteProject?.cloneUrl===t.cloneUrl;if(t.kind===`idle`||e.remoteProject)return!1;let n=e.selectedProject?.repoRoot??(e.folder.trim()||e.workspace);return t.repoRoot===n}load(){this.readController.abort(),this.readController=new AbortController;let e=this.readController.signal,t=this.read();if(this.checkoutScope=t.selectedProject&&!t.remotePlacement?{project:t.selectedProject,agentId:t.agentId}:void 0,this.checkoutOptions=this.checkoutScope?`loading`:void 0,this.checkoutReadValue=void 0,this.repositoryReadValue=void 0,this.checkoutScope&&t.gateway?.snapshot.phase===`connected`&&t.gateway.snapshot.client){let n=ps(t.gateway,`projects.checkoutOptions`,{projectId:this.checkoutScope.project.id,agentId:this.checkoutScope.agentId},{signal:e,onSnapshot:e=>{this.matchesProjectCheckout()&&(this.checkoutOptions=e,this.reconcileCheckoutChoice(),this.callbacks.changed())}});this.checkoutReadValue={completed:n},n.catch(()=>{e.aborted||(this.checkoutOptions=`error`,this.callbacks.changed())})}let n=wu(t);if(n.kind!==`checking`)return this.adoptResolvedRepository(n);let r=t.gateway?.snapshot.client;if(t.gateway?.snapshot.phase!==`connected`||!r)return this.adoptResolvedRepository({kind:`idle`});let{repoRoot:i}=n;if(!u(t.gateway.snapshot.hello?.auth??null))return this.adoptResolvedRepository({kind:`forbidden`,repoRoot:i,missingScope:`operator.write`});this.repositoryValue=n;let a=ps(t.gateway,`worktrees.branches`,{repoRoot:i,includeRepositoryStatus:!0},{signal:e,onSnapshot:e=>{if(e.refreshing&&!e.repositoryStatus){this.callbacks.changed();return}let{repositoryStatus:t,...n}=e;this.adoptResolvedRepository(t===`git`?{kind:`git`,repoRoot:i,...n}:{kind:t===`not_git`?`direct`:`unavailable`,repoRoot:i})}});this.repositoryReadValue={completed:a},a.catch(t=>{if(e.aborted)return;let n=de(t);this.adoptResolvedRepository(n||t instanceof c&&t.gatewayCode===`FORBIDDEN`?{kind:`forbidden`,repoRoot:i,...n?{missingScope:n.missingScope}:{}}:this.repositoryValue.kind===`git`?{...this.repositoryValue,refreshing:!1,branchesUnavailable:!0}:{kind:`unavailable`,repoRoot:i})})}synchronize(){this.matchesCurrentRepo()||this.load()}reconcileCheckoutChoice(){let e=this.checkoutOptions;this.matchesProjectCheckout()&&e&&typeof e!=`string`&&!e.refreshing&&!this.read().remotePlacement&&(this.preferredWorktreeRestore&&!this.worktreeSelectedByUser&&(this.worktreeValue=!0,this.preferredWorktreeRestore=!1),!(this.worktreeValue?e.worktree:e.current)&&(e.current||e.worktree)&&(this.worktreeValue=e.worktree,this.preferredWorktreeRestore=!1,this.callbacks.persistPreference({worktree:this.worktreeValue})))}adoptResolvedRepository(e){if(this.repositoryValue=e,e.kind===`direct`&&(!this.read().selectedProject||this.read().remotePlacement)){let e=this.worktreeValue||this.preferredWorktreeRestore;this.worktreeValue=!1,e&&!this.read().remotePlacement&&this.callbacks.persistPreference({worktree:!1})}else this.preferredWorktreeRestore&&!this.worktreeSelectedByUser&&(this.worktreeValue=!0);this.preferredWorktreeRestore=!1,this.reconcileCheckoutChoice(),this.callbacks.changed()}}})))()}function Du(){return{catalog:[],hasSnapshot:!1,status:`idle`}}function Ou(e){let{agent:t,defaults:n,catalog:r,modelSelectionPolicy:i}=e;return $(i?.restricted?i.defaultModel:t?.model?.primary??n?.model,i?.restricted||t?.model?.primary?void 0:n?.modelProvider,r)}function ku(e){let t=e.model?$(e.model,void 0,e.catalog,e.agentRuntime):Ou(e),n=e.requested??t?.entry?.cyberAccessProgramDefault,r=t?.entry?.availableAccessPrograms?.cyber;return(r&&kc(r,n,n))??n}function Au(e){let{model:t,selection:n,metadata:r,agent:i,defaults:a}=e,o=r.modelSelectionPolicy,s=o?.restricted?o.defaultModel??void 0:i?.model?.primary,c=Ou({agent:i,defaults:a,catalog:r.catalog,modelSelectionPolicy:o}),l=$(t,void 0,r.catalog,n.agentRuntime),u=l?.entry??c?.entry,d=n.contextWindow||u?.contextWindowDefault,f=ni(ju(c,o?.restricted?void 0:i),o?.restricted?void 0:a,r.catalog);return{defaultTarget:c,agentDefaultModel:s,modelCatalogState:{hasSnapshot:i!==void 0&&r.hasSnapshot,initialized:!r.retired&&(r.initialized??r.hasSnapshot),refreshFailed:r.refreshFailed,pendingProviders:r.pendingProviders,modelSelectionPolicy:o,retired:r.retired,status:!i&&r.status!==`error`?`loading`:r.status},contextWindowTarget:u?.contextWindows&&d?{contextWindow:d,contextWindows:u.contextWindows,...u.contextWindowDefault?{contextWindowDefault:u.contextWindowDefault}:{}}:void 0,fastModeTarget:{agentRuntime:u?.agentRuntime,model:l?.model??c?.model,modelProvider:l?.provider??c?.provider??void 0,fastMode:n.fastMode,effectiveFastMode:n.fastMode??u?.effectiveFastMode},thinkingDefaults:{modelProvider:c?.provider??null,model:c?.model??null,contextTokens:o?.restricted?null:a?.contextTokens??null,agentRuntime:f?.agentRuntime,thinkingLevels:f?.thinkingLevels,thinkingDefault:f?.thinkingDefault},thinkingSession:ju(l,void 0,n)}}function ju(e,t,n){let r=n?.agentRuntime?e?.entry:void 0;return{model:e?.model??t?.model?.primary,modelProvider:e?.provider??void 0,agentRuntime:t?.agentRuntime??e?.entry?.agentRuntime,thinkingLevels:t?.thinkingLevels??r?.thinkingLevels,thinkingOptions:t?.thinkingOptions,thinkingDefault:t?.thinkingDefault??r?.thinkingDefault,thinkingLevel:n?.thinkingLevel||void 0}}function $(e,t,n,r){let i=At(e,t,n);if(!i)return null;let a=i.toLowerCase(),o=n.find(e=>mt(e.id,e.provider).toLowerCase()===a);if(o)return{entry:at(o,r),model:o.id,provider:ct(o.provider)||null};let s=i.indexOf(`/`);return{model:s>0?i.slice(s+1):i,provider:ct(s>0?i.slice(0,s):t??``)||null}}function Mu(e){let{metadata:t,agent:n}=e;if(!t.hasSnapshot||t.status===`offline`)return;let r=t.modelSelectionPolicy,i=e.model||(r?.restricted?r.defaultModel??void 0:n?.model?.primary);return e.agentRuntime?$(i,void 0,t.catalog,e.agentRuntime)?.entry?.unavailableReason:Bt(i,void 0,t.catalog)}function Nu(e,t,n){let r=$(e.model,void 0,t,n);return r?.entry?.available===!0&&r.entry.manualSelectionAllowed!==!1&&r.provider===e.provider}function Pu(e){let{metadata:t,model:n,agentRuntime:r}=e;if(t.retired||e.initialModelPending||!t.hasSnapshot&&(n||r))return E(`chat.modelControls.modelsUnavailable`);if(t.modelSelectionPolicy?.restricted&&!n&&!t.modelSelectionPolicy.defaultModel)return E(t.catalog.length?`chat.modelControls.selectionRequired`:`chat.modelControls.noPermittedModels`);let i=n||r?$(n,void 0,t.catalog,r)?.entry:void 0;if(r&&t.hasSnapshot&&!i||n&&i?.manualSelectionAllowed===!1)return E(`chat.modelControls.modelsUnavailable`);if(r&&i?.available===!1)return He(Mu(e))??E(`chat.modelControls.modelsUnavailable`);let a=He(Mu(e),!n&&!r&&!e.accountSelected?e.inference:void 0);if(e.accountSelected){if(t.status===`error`||e.metadataPending||!t.hasSnapshot)return E(`chat.modelControls.modelsUnavailable`);if(!e.accountReady)return a??E(`chat.modelControls.modelsUnavailable`)}return a}function Fu(e){if(e.retired)return;let t=e.modelSelectionPolicy,n=e.model||(t?.restricted?t.defaultModel??``:``),r;n?r=$(n,void 0,e.catalog,e.agentRuntime)?.entry?.agentRuntime:t?.restricted||(r=Ou(e)?.entry?.agentRuntime??e.agent?.agentRuntime??e.defaults?.agentRuntime);let i=r?.id.trim();if(r&&i&&i!==`auto`&&i!=="default")return i===r.id?r:{...r,id:i}}function Iu(e){let t=e.model.trim(),n=t?$(t,void 0,e.catalog,e.agentRuntime):null;if(t&&(!n?.entry||n.entry.available===!1||n.entry.manualSelectionAllowed===!1))return e.agentRuntime&&e.agentRuntime!==`openclaw`?{model:t,agentRuntime:e.agentRuntime,thinkingLevel:e.thinkingLevel,fastMode:e.fastMode,repaired:!1}:{model:``,thinkingLevel:``,repaired:!0};let r=n?.entry?mt(n.entry.id,n.entry.provider):``,i=e.modelSelectionPolicy,a=i?.restricted?void 0:e.agent,o=i?.restricted?void 0:e.defaults,s=r?null:Ou(e),c=(n??s)?.provider,l=n?.entry??s?.entry,u=l?.supportsFastMode??(!c||yn(c))?e.fastMode:void 0,d={model:r,...r&&e.agentRuntime?{agentRuntime:e.agentRuntime}:{},fastMode:u},f=u!==e.fastMode;if(!e.thinkingLevel)return{...d,thinkingLevel:``,repaired:f};let p=ni(ju(n??s,r?void 0:a,{agentRuntime:e.agentRuntime}),r?void 0:o,e.catalog)?.thinkingLevels,m=jr(e.thinkingLevel),h=p?.some(e=>jr(e.id)===m);return l?.reasoning===!1||p!==void 0&&!h?{...d,thinkingLevel:``,repaired:!0}:{...d,thinkingLevel:e.thinkingLevel,repaired:f}}function Lu(e){return e&&!e.devicePlacement?E(`newSession.deviceRuntimeUnsupported`):void 0}function Ru(e,t){return e?.cloudPlacementSupported===!1?E(`newSession.cloudRuntimeUnsupported`,{runtime:e.id}):e&&t&&e.cloudPlacementExecutionMode&&!ru(t,e.cloudPlacementExecutionMode)?E(`newSession.cloudProfileRuntimeUnsupported`,{runtime:e.id}):void 0}function zu(){return(zu=e((()=>{O(),Ra(),Z(),kn(),Wa(),on(),X(),to()})))()}function Bu(e,t,n){let r=new Map;for(let i of e){let e=mt(i.id,i.provider);for(let a of[i.agentRuntime,...(i.runtimeChoices??[]).map(e=>e.agentRuntime)]){if(a?.workspaceEnvironment?.kind!==`provider-hosted`)continue;let o=at(i,a.id),s=n&&o?.available===!0&&o.manualSelectionAllowed!==!1;(!r.get(a.id)?.model||s&&e===t)&&r.set(a.id,{id:a.id,label:a.workspaceEnvironment.label,...s?{model:e}:{disabledReason:E(`newSession.hostedUnavailable`)}})}}return[...r.values()]}function Vu(e,t){let n=$(t,void 0,e),r=n&&e.find(e=>e.id===n.model&&e.provider===n.provider);if(!r)return;let i=[r,...r.runtimeChoices??[]].find(e=>e.agentRuntime&&!e.agentRuntime.workspaceEnvironment&&e.available===!0&&e.manualSelectionAllowed!==!1);return i?.agentRuntime?{model:mt(r.id,r.provider),runtime:i.agentRuntime}:void 0}function Hu(e){return e.hostEnvironmentRuntime()?.runtime??e.resolveAgentRuntime()}function Uu(e){return e.hostEnvironmentDisabledReason()??Lu(Hu(e))}function Wu(e,t){return e.hostEnvironmentDisabledReason()??Ru(Hu(e),t)}function Gu(){return(Gu=e((()=>{O(),Z(),kn(),zu(),X()})))()}var Ku;function qu(){return(qu=e((()=>{k(),Gu(),Ku=class{constructor(e,t,n,r){this.gateway=e,this.place=t,this.read=n,this.callbacks=r,this.adoption=null}get pending(){return this.adoption!==null}cancel(){this.adoption?.resolve(),this.adoption=null}canSelect(e){let t=this.read(),n=this.gateway.cloudProfiles.find(t=>t.id===e);return!t.submitting&&!t.pendingPlacementSessionKey&&!this.place.requiredPlacement&&n!==void 0&&!Wu(this.place.modelControl,n)}async adopt(e){let t=this.read();if(this.pending||t.submitting||t.pendingPlacementSessionKey||this.place.requiredPlacement||!this.place.isAdmin()||!this.gateway.suggestedProfile||Wu(this.place.modelControl))return;let n=Promise.withResolvers();this.adoption=n,this.callbacks.onError(null),this.callbacks.changed();let r=this.settle(n);return e?.({completion:r,retired:n.promise,isCurrent:()=>this.adoption===n,reportError:e=>{this.adoption===n&&(this.callbacks.onError(j(e)),this.callbacks.changed())}}),r}async settle(e){try{let t=await this.gateway.adoptSuggestedProfile();this.adoption===e&&t&&this.place.selectCloudProfile(t)}catch(t){this.adoption===e&&this.callbacks.onError(j(t))}finally{this.adoption===e&&(this.cancel(),this.callbacks.changed())}}}})))()}function Ju(e,t){let n=e.read();!e.place.deviceFolderAvailable||n.submitting||n.pendingPlacementSessionKey||(t(),e.selection.freshWorkspace=!1,e.selection.folderSelectedByUser=!0,yu(e.selection,!0),e.browser.resetProjectSearch(),e.folderValidation.cancel(),e.browser.clearProjectSelection(),e.repositoryState.reset(),e.browser.close(),e.callbacks.changed())}function Yu(e,t,n=!1){let r=e.read();e.place.requiredPlacement||r.submitting||r.pendingPlacementSessionKey||e.place.hostedEnvironment&&(t||n)&&Uu(e.modelControl)||e.modelControl.selectHostEnvironment()&&(t&&e.place.devices().find(e=>e.deviceId===t)?.selectable!==!0||n&&!e.place.devices().some(e=>e.selectable)||(e.place.suggestedCloudProfile.cancel(),e.selection.whereSelectedByUser=!0,e.selection.preferredWhereRestore=null,t===e.selection.deviceId&&n===e.selection.autoDevice&&!e.selection.cloudProfileId?(e.browser.close(),e.callbacks.changed()):(e.folderValidation.cancel(),e.clearDeviceFolder(),e.selection.deviceId=t,e.selection.autoDevice=n,e.selection.cloudProfileId=``,e.persistPreference({where:Ir({cloudProfileId:``,deviceId:t,autoDevice:n}),projectId:e.browser.projectId,folder:e.place.folder,worktree:!!(t||n)||e.place.worktree,freshWorkspace:e.selection.freshWorkspace}),e.browser.close(),e.repositoryState.synchronize(),e.callbacks.changed())))}function Xu(e,t){e.place.suggestedCloudProfile.canSelect(t)&&e.modelControl.selectHostEnvironment()&&(e.place.suggestedCloudProfile.cancel(),e.clearDeviceFolder(),e.selection.cloudProfileId=t,e.selection.deviceId=``,e.selection.autoDevice=!1,e.selection.whereSelectedByUser=!0,e.selection.preferredWhereRestore=null,e.callbacks.onError(null),e.persistPreference({where:{kind:`cloud`,id:t},projectId:e.browser.projectId,worktree:!0,freshWorkspace:e.selection.freshWorkspace}),e.repositoryState.synchronize(),e.callbacks.changed())}function Zu(e,t){!e.read().submitting&&e.repositoryState.select(t)&&t&&e.selection.freshWorkspace&&(e.selection.freshWorkspace=!1,e.persistPreference({freshWorkspace:!1}))}function Qu(){return(Qu=e((()=>{Cu(),Gu(),Ma()})))()}var $u;function ed(){return(ed=e((()=>{$u=class{constructor(){this.hostIdValue=`gateway:local`,this.initialized=!1}get hostId(){return this.hostIdValue}get onNode(){return this.hostIdValue.startsWith(`node:`)}select(e,t,n){t||(this.initialized=!0,e!==this.hostIdValue&&(this.hostIdValue=e,n()))}synchronize(e,t){!this.initialized&&e?.length&&t(e.find(e=>e.hostId===this.hostIdValue)?.hostId??e[0].hostId)}reset(){this.hostIdValue=`gateway:local`,this.initialized=!1}}})))()}var td;function nd(){return(nd=e((()=>{Wa(),on(),zu(),td=class{selectHostedEnvironment(e){let t=this.hostedEnvironments().find(t=>t.id===e);return t?.model?(this.selectModel(t.model,e),!0):!1}selectHostEnvironment(){if(!this.resolveAgentRuntime()?.workspaceEnvironment)return!0;let e=this.hostEnvironmentRuntime();return e?(this.selectModel(e.model,wt(e.runtime)),!0):!1}devicePlacementUnsupportedReason(){return Lu(this.resolveAgentRuntime())}autoPlacementSelectionMode(e=this.resolveAgentRuntime()){return e?.cloudPlacementExecutionMode===`remote-exec`?`eligible-order`:`least-busy`}cloudRuntimeUnsupportedReason(e){return Ru(this.resolveAgentRuntime(),e)}constructor(e,t){this.onSelectionChange=e,this.changed=t,this.selectionOrigin=`none`,this.fastModeSelected=!1,this.selectionGeneration=0,this.restoringPreference=!1,this.selected=``,this.contextWindow=``,this.thinkingLevel=``,this.listeners=oe(),this.notify=()=>{this.listeners.publish(),this.changed()},this.subscribe=this.listeners.subscribe,this.selectThinkingLevel=e=>{this.selectionGeneration+=1,this.restoringPreference=!1,this.thinkingLevel=e,this.markExplicitSelection(),this.persistSelection(),this.onDraftSelectionChange?.(),this.notify()},this.selectFastMode=e=>{this.selectionGeneration+=1,this.restoringPreference=!1,this.fastModeSelected=!0,this.fastMode=tt(e),this.persistSelection(),this.notify()},this.selectAccessProgram=(e,t,n)=>{this.selectionGeneration+=1,this.restoringPreference=!1,this.cyberAccessProgram=e,e===`standard`?n&&(this.daybreakAccessProgram=n):this.daybreakAccessProgram=e,this.markExplicitSelection(),this.onSelectionChange({cyberAccessProgram:e,...this.daybreakAccessProgram===void 0?{}:{daybreakAccessProgram:this.daybreakAccessProgram}}),this.onDraftSelectionChange?.(),this.notify()}}initializeAccessProgram(){let e=this.accessProgramForSubmission();this.cyberAccessProgram===void 0&&e!==void 0&&(this.cyberAccessProgram=e,this.onSelectionChange({cyberAccessProgram:e}))}resetSelection(e=``){this.selected=e,this.agentRuntime=void 0,this.contextWindow=``,this.thinkingLevel=``,this.fastMode=void 0,this.cyberAccessProgram=void 0,this.daybreakAccessProgram=void 0,this.selectionOrigin=`none`,this.fastModeSelected=!1}applyModelSelection(e){let t=this.selected!==e.model||this.agentRuntime!==e.agentRuntime||this.thinkingLevel!==e.thinkingLevel||this.fastMode!==e.fastMode;return this.selected=e.model,this.agentRuntime=e.agentRuntime,this.thinkingLevel=e.thinkingLevel,this.fastMode=e.fastMode,t}draftSelection(e){return this.selectionOrigin===`none`?void 0:{agentId:e,model:this.selected,agentRuntime:this.agentRuntime,thinkingLevel:this.thinkingLevel,cyberAccessProgram:this.cyberAccessProgram,daybreakAccessProgram:this.daybreakAccessProgram}}preferenceForDraft(e,t){let n=this.fastModeSelected||e===void 0?this.fastMode:e?.fastMode;if(this.selectionOrigin!==`none`)return{model:this.selected,agentRuntime:this.agentRuntime,thinkingLevel:this.thinkingLevel,cyberAccessProgram:this.cyberAccessProgram??e?.cyberAccessProgram,daybreakAccessProgram:this.daybreakAccessProgram??e?.daybreakAccessProgram,fastMode:n};let r={cyberAccessProgram:e?.cyberAccessProgram,daybreakAccessProgram:e?.daybreakAccessProgram};return t.initialModel?{...r,model:t.initialModelPending?t.initialModel:this.selected,agentRuntime:this.agentRuntime,thinkingLevel:this.thinkingLevel,fastMode:n}:t.policy===`configured`||t.policy===null?{fastMode:n,...r}:this.fastModeSelected?{...e,fastMode:n}:e}takeDraftSelection(e,t,n){let r=this.pendingDraftSelection;if(t&&r&&r.agentId===e&&(this.pendingDraftSelection=void 0,this.selectionOrigin!==`explicit`))return this.selectionOrigin=`restored`,this.selected=r.model,this.agentRuntime=r.agentRuntime,this.thinkingLevel=r.thinkingLevel,this.cyberAccessProgram=r.cyberAccessProgram,this.daybreakAccessProgram=r.daybreakAccessProgram,this.fastModeSelected||(this.fastMode=n??this.fastMode),{...r,fastMode:this.fastMode}}markExplicitSelection(){this.selectionOrigin=`explicit`}retireModelSelection(e){return e&&this.selectionOrigin!==`restored`?!1:(this.selectionOrigin=`none`,e||(this.fastModeSelected=!1),this.pendingDraftSelection=void 0,this.selected=``,this.agentRuntime=void 0,this.thinkingLevel=``,this.cyberAccessProgram=void 0,this.daybreakAccessProgram=void 0,this.contextWindow=``,!0)}restoreModelPreference(e,t,n){if(!e)return!1;let r=Iu({model:e.model??``,agentRuntime:e.agentRuntime,thinkingLevel:e.thinkingLevel??``,fastMode:e.fastMode,...t}),i=this.cyberAccessProgram!==e.cyberAccessProgram;this.cyberAccessProgram=e.cyberAccessProgram,this.daybreakAccessProgram=e.daybreakAccessProgram;let a=this.applyModelSelection(r)||i;return r.repaired&&n&&this.persistSelection(e.agentRuntime?this.agentRuntime??``:void 0),a}selectModelIntent(e,t,n,r){let i=Iu({model:e,agentRuntime:t,thinkingLevel:this.thinkingLevel,fastMode:this.fastMode,...n});if(i.model===r&&i.agentRuntime===this.agentRuntime&&i.fastMode===this.fastMode&&jr(i.thinkingLevel)===jr(this.thinkingLevel))return!1;let a=this.agentRuntime!==i.agentRuntime;this.applyModelSelection(i),this.markExplicitSelection();let o=$(i.model,void 0,n.catalog,this.agentRuntime)??Ou(n);return this.contextWindow=``,{target:o,runtimeChanged:a}}persistSelection(e=this.agentRuntime){this.onSelectionChange({model:this.selected,...e===void 0?{}:{agentRuntime:e},thinkingLevel:this.thinkingLevel,fastMode:this.fastMode,...this.cyberAccessProgram===void 0?{}:{cyberAccessProgram:this.cyberAccessProgram},...this.daybreakAccessProgram===void 0?{}:{daybreakAccessProgram:this.daybreakAccessProgram}})}}})))()}function rd(){let e;return t=>{let n=[t.model,t.agentRuntime,t.catalog,t.retired,t.agent?.model?.primary,t.agent?.agentRuntime,t.defaults?.model,t.defaults?.modelProvider,t.defaults?.agentRuntime,t.modelSelectionPolicy?.restricted,t.modelSelectionPolicy?.defaultModel];if(e?.inputs.every((e,t)=>e===n[t]))return e.value;let r=Fu(t);return e={inputs:n,value:r},r}}function id(){return(id=e((()=>{zu()})))()}var ad;function od(){return(od=e((()=>{s(),p(),O(),kn(),er(),Vo(),Fe(),_(),lr(),Wr(),Q(),Gu(),nd(),zu(),Ma(),id(),ad=class extends td{constructor(e,t=()=>void 0,n=()=>void 0){super(t,e),this.onCatalogTargetSelect=n,this.initialModelPending=!1,this.agentId=``,this.metadataState=Du(),this.pendingSelectionGeneration=0,this.resolveRuntime=rd(),this.configuredDefaults=!1,this.catalogTargets=new tl(this.notify),this.metadataReader=new Xo(()=>{if(this.metadataClient&&this.metadataScope&&!this.ownsMetadata(this.metadataClient,this.metadataScope))this.restoringPreference=!1,this.draftAccount=void 0,this.clearMetadataSubscription(),this.updateMetadataState({catalog:[],hasSnapshot:!1,status:`offline`});else if(this.metadataReader.pending){let e=this.metadataReader.snapshot;e.retired?this.metadataState={catalog:[],hasSnapshot:!1,retired:!0,status:`loading`}:e.hasSnapshot&&!this.metadataState.hasSnapshot&&this.assignMetadataCatalog(e,!0),this.updateMetadataState({...this.metadataState,status:this.metadataState.hasSnapshot&&this.metadataState.status===`ready`?`ready`:`loading`})}else this.notify()},{timeoutMs:x,onRead:e=>{this.metadataRead=e},onResult:e=>{if(this.ownsMetadata()){if(this.assignMetadataCatalog(e),this.metadataState.accountSelection=e.accountSelection,!this.draftAccount&&this.pendingSelectionGeneration===this.selectionGeneration&&(this.initialModelPending&&!e.modelSelectionPolicy?.restricted?this.resetSelection(this.initialModel):this.restorePreference()),this.initialModelPending=!1,!this.draftAccount&&e.modelSelectionPolicy?.restricted&&this.selected){let t=Iu({model:this.selected,agentRuntime:this.agentRuntime,thinkingLevel:this.thinkingLevel,fastMode:this.fastMode,modelSelectionPolicy:e.modelSelectionPolicy,catalog:e.models});this.applyModelSelection(t)}this.restoringPreference=!1,this.notify()}},onError:()=>{this.ownsMetadata()&&(!this.metadataState.retired&&!this.metadataState.modelSelectionPolicy?.restricted&&!this.draftAccount&&this.pendingSelectionGeneration===this.selectionGeneration&&(this.initialModelPending?(this.resetSelection(this.initialModel),this.initialModelPending=!1):this.pendingPreference&&(this.selected=this.pendingPreference.model??``,this.agentRuntime=this.pendingPreference.agentRuntime,this.thinkingLevel=this.pendingPreference.thinkingLevel??``,this.fastMode=this.pendingPreference.fastMode,this.cyberAccessProgram=this.pendingPreference.cyberAccessProgram)),this.restoringPreference=!1,this.updateMetadataState({...this.metadataState,status:`error`}))}})}get catalog(){return this.metadataState.catalog}get effectiveModel(){return this.draftAccount?.model??this.selected}clearMetadataSubscription(){this.metadataReader.clear(),this.metadataRead=void 0,this.metadataScope=void 0,this.metadataGateway=void 0}ownsMetadata(e=this.metadataClient,t=this.metadataScope){let n=this.pendingContext?.gateway.snapshot;return!!(e&&t&&this.metadataClient===e&&this.metadataGateway===this.pendingContext?.gateway&&this.metadataScope===t&&n?.phase===`connected`&&n.client===e&&n.hello===this.metadataHello&&n.selfUser?.id===this.metadataIdentityId)}bindMetadataSubscription(e,t){if(this.metadataScope&&this.metadataClient===e&&this.metadataGateway===this.pendingContext?.gateway&&this.metadataScope.agentId===t.agentId&&this.metadataScope.authProfileId===t.authProfileId)return this.metadataScope;this.clearMetadataSubscription(),this.metadataClient=e,this.metadataScope=t;let n=this.pendingContext?.gateway;return this.metadataGateway=n,n&&this.metadataReader.bind(n,t),t}loadCatalogTargets(e,t,n){this.catalogTargets.load(e,t,n)}updateMetadataState(e){this.metadataState={...e,initialized:!e.retired&&e.status!==`offline`&&(e.hasSnapshot||ei(this.metadataClient))},this.notify()}assignMetadataCatalog(e,t=!1){this.metadataState={...this.metadataState,catalog:e.models,displayOnly:t,...kt(e)}}selectDraftAccount(e,t){let n=this.metadataClient;if(!n||!t)return Promise.resolve(!1);this.selectionGeneration+=1,this.restoringPreference=!1,this.draftAccount={authProfileId:e.authProfileId,provider:e.provider,model:t};let r={agentId:this.agentId,authProfileId:e.authProfileId};this.metadataState={catalog:[],accountSelection:this.metadataState.accountSelection,hasSnapshot:!1,status:`loading`};let i=this.bindMetadataSubscription(n,r);return this.metadataReader.read().then(e=>!!e&&this.ownsMetadata(n,i))}clearDraftAccount(){return this.draftAccount?(this.draftAccount=void 0,this.clearMetadataSubscription(),this.metadataState=Du(),!0):!1}invalidate(e=!1){!e&&this.metadataClient&&Ki(this.metadataClient,this.metadataScope),this.clearDraftAccount(),this.clearMetadataSubscription(),this.catalogTargets.clear(),this.restoringPreference=!1,e?(this.pendingDraftSelection=void 0,this.agentId=``,this.metadataClient=void 0,this.resetSelection(),this.initialModel=void 0,this.initialModelPending=!1,this.updateMetadataState(Du())):this.updateMetadataState({...this.metadataState,status:this.metadataState.hasSnapshot?this.metadataState.status:`idle`})}reset(){this.resolveRuntime=rd(),this.invalidate(!0)}load(e,t,n,r={}){let i=e?.gateway.snapshot,a=i?.client,o=t.trim()?D(t):``;if(this.pendingContext=e,(this.agentId!==o||this.metadataClient&&this.metadataClient!==a||this.metadataGateway&&this.metadataGateway!==e?.gateway||this.metadataIdentityId!==i?.selfUser?.id||this.metadataHello&&this.metadataHello!==i?.hello)&&(this.draftAccount=void 0,this.clearMetadataSubscription(),this.agentId!==o&&(this.resetSelection(),this.initialModel=void 0,this.initialModelPending=!1),this.agentId=o,this.metadataClient=void 0,this.metadataState=Du()),this.metadataIdentityId=i?.selfUser?.id,this.metadataHello=i?.hello,!e||i?.phase!==`connected`||!a||!o||!n){this.clearDraftAccount(),this.clearMetadataSubscription(),this.metadataClient=void 0,this.restoringPreference=!1,e&&i?.phase!==`connected`&&(this.metadataState={catalog:[],hasSnapshot:!1,status:`offline`}),this.notify();return}this.configuredDefaults=r.configuredDefaults===!0;let s=r.initialModel;s&&s!==this.initialModel&&(this.resetSelection(),this.selectionGeneration+=1,this.initialModel=s,this.initialModelPending=!0);let c=this.selectionGeneration,l={agentId:o,...this.draftAccount?{authProfileId:this.draftAccount.authProfileId}:{}},u=this.metadataScope,d=this.bindMetadataSubscription(a,l)!==u;this.pendingPreference=this.preferenceForDraft(r.preference,{policy:this.modelDefaultsPolicy,initialModel:this.initialModel,initialModelPending:this.initialModelPending}),this.pendingAgent=r.agent,this.pendingSelectionGeneration=c,this.applyPendingDraftSelection(),this.restoringPreference=!this.draftAccount&&xi(this.pendingPreference),this.metadataReader.pending?this.notify():!d&&this.metadataState.status!==`idle`?(this.metadataState.status===`ready`&&this.metadataState.hasSnapshot&&!this.draftAccount&&this.pendingSelectionGeneration===this.selectionGeneration&&this.restorePreference(),this.restoringPreference=!1):this.metadataReader.read()}isRestoringPreference(){return this.restoringPreference}requiresModelSetup(e){return Xa({...e,modelCatalogState:{...this.metadataState,initialized:this.metadataState.hasSnapshot&&!this.metadataState.retired}})}modelSelectionBlockedReason(e,t){let n=this.resolveAgentRuntime({agent:e,context:this.pendingContext});return Pu({model:this.effectiveModel,agentRuntime:this.agentRuntime,metadata:this.metadataState,agent:e,initialModelPending:this.initialModelPending,accountSelected:!!this.draftAccount,accountReady:this.accountSelectionReady(),metadataPending:this.metadataReader.pending,inference:n?.id===`openclaw`&&n.cloudPlacementExecutionMode===`worker-turn`?t:void 0})}accessProgramForSubmission(){return!this.ownsMetadata()||this.metadataState.status!==`ready`?this.cyberAccessProgram:ku({model:this.effectiveModel,agentRuntime:this.agentRuntime,agent:this.pendingAgent,defaults:this.pendingContext?.sessions.state.result?.defaults,...this.metadataState,requested:this.cyberAccessProgram})}modelForSubmission(){return this.draftAccount?`${this.draftAccount.model}@${this.draftAccount.authProfileId}`:this.selected}accountSelectionReady(){if(!this.draftAccount)return!0;let e=this.metadataState.accountSelection;return!this.ownsMetadata()||this.metadataReader.pending||this.metadataState.status!==`ready`||e?.kind!==`personal`||e.authProfileId!==this.draftAccount.authProfileId?!1:Nu(this.draftAccount,this.catalog,this.agentRuntime)}restorePreference(){let e=this.metadataState.modelSelectionPolicy;this.restoreModelPreference(this.pendingPreference,{agent:this.pendingAgent,defaults:this.pendingContext?.sessions.state.result?.defaults,modelSelectionPolicy:e,catalog:this.catalog},!this.initialModelPending&&!e?.restricted&&this.modelDefaultsPolicy!==`configured`&&this.modelDefaultsPolicy!==null)&&this.notify()}restoreDraftSelection(e){this.pendingDraftSelection=e,e||this.retireDraftSelection(!0),this.applyPendingDraftSelection()}retireDraftSelection(e=!1){this.retireModelSelection(e)&&(this.pendingSelectionGeneration=++this.selectionGeneration,this.pendingPreference={fastMode:this.fastMode},!e&&this.clearDraftAccount()&&this.load(this.pendingContext,this.agentId,!0,{agent:this.pendingAgent}),this.notify())}get modelDefaultsPolicy(){return this.configuredDefaults?`configured`:this.pendingContext?.config?.current.newSessionModelDefaults}applyPendingDraftSelection(){let e=this.takeDraftSelection(this.agentId,this.modelDefaultsPolicy===`configured`,this.pendingPreference?.fastMode);e&&(this.selectionGeneration+=1,this.initialModelPending=!1,this.pendingPreference=e,this.pendingSelectionGeneration=this.selectionGeneration,this.metadataState.status===`ready`&&this.restorePreference(),this.notify())}resolveAgentRuntime(e={agent:this.pendingAgent,context:this.pendingContext}){return this.resolveRuntime({model:this.effectiveModel,agentRuntime:this.agentRuntime,agent:e.agent,defaults:e.context?.sessions.state.result?.defaults,catalog:this.metadataState.displayOnly?[]:this.catalog,modelSelectionPolicy:this.metadataState.modelSelectionPolicy,retired:this.metadataState.retired})}selectModel(e,t){this.selectionGeneration+=1,this.initialModelPending=!1,this.restoringPreference=!1;let n=this.selectModelIntent(e,t,{agent:this.pendingAgent,defaults:this.pendingContext?.sessions.state.result?.defaults,catalog:this.catalog,modelSelectionPolicy:this.metadataState.modelSelectionPolicy},this.effectiveModel);if(n===!1)return;let{target:r,runtimeChanged:i}=n;this.metadataState.displayOnly=!1,this.draftAccount&&this.draftAccount.provider!==r?.provider?(this.clearDraftAccount(),this.load(this.pendingContext,this.agentId,!0,{agent:this.pendingAgent})):this.draftAccount&&r&&(this.draftAccount={...this.draftAccount,model:mt(r.model,r.provider)}),this.persistSelection(i?this.agentRuntime??``:void 0),this.onDraftSelectionChange?.(),this.notify()}hostedEnvironmentsLoading(){return!this.metadataState.hasSnapshot&&this.metadataState.status!==`error`}hostedEnvironments(){return Bu(this.catalog,this.effectiveModel||this.pendingAgent?.model?.primary||``,this.metadataState.status===`ready`&&!this.metadataState.retired&&!this.metadataState.displayOnly)}hostEnvironmentDisabledReason(){return this.resolveAgentRuntime()?.workspaceEnvironment&&!this.hostEnvironmentRuntime()?E(`newSession.hostModelRequired`):void 0}hostEnvironmentRuntime(){return this.metadataState.retired||this.metadataState.displayOnly||!this.resolveAgentRuntime()?.workspaceEnvironment?void 0:Vu(this.catalog,this.effectiveModel||this.pendingAgent?.model?.primary)}get metadataReadScope(){return this.metadataScope}renderProps(e){let t=e.context?.gateway.snapshot,n=`new-session:${D(e.agentId)}`,r=e.context?.sessions.state.result??null,i=e.agent!==void 0,{defaultTarget:a,...o}=Au({model:this.effectiveModel,selection:this,metadata:this.metadataState,agent:e.agent,defaults:r?.defaults}),s=t?.client,c=this.metadataScope,l=this.metadataState.accountSelection,d=()=>!!(s&&c&&this.ownsMetadata(s,c)&&this.metadataState.accountSelection===l);return{...o,renderAccountSection:n=>Zn({owner:this,client:s,selection:d()&&t?.selfUser?l:void 0,model:n,disabled:e.sending||!n||!u(t?.hello?.auth??null),ownsSelection:d,onSelect:e=>d()?this.selectDraftAccount(e,n):Promise.resolve(!1),onAutomatic:this.draftAccount?()=>{d()&&(this.selectionGeneration+=1,this.clearDraftAccount(),this.load(e.context,e.agentId,!0,{agent:e.agent}))}:void 0,onManage:()=>e.context?.navigate(`profile`)}),activeRunId:null,connected:t?.phase===`connected`,gatewayAvailable:!!t?.client,loading:!1,modelCatalog:this.catalog,modelOverrides:{[n]:this.effectiveModel||null},modelPickerTargetGroups:this.catalogTargets.groups(),modelSwitching:!1,sending:e.sending,sessionKey:n,selectedSession:void 0,requestedAccessProgram:this.accessProgramForSubmission(),daybreakAccessProgram:this.daybreakAccessProgram,selectedAgentRuntime:this.agentRuntime,sessionsResult:i?r:null,stream:null,onModelSelect:(e,t,n)=>{this.selectModel(e,n??void 0)},onModelPickerTargetSelect:(e,t)=>{e===`cliAgents`&&this.onCatalogTargetSelect(t)},onModelPickerTargetRetry:t=>{t===`cliAgents`&&this.catalogTargets.retry(e.context?.gateway.snapshot,this.agentId)},onThinkingSelect:this.selectThinkingLevel,onAccessProgramSelect:this.selectAccessProgram,onFastModeSelect:this.selectFastMode,onContextWindowSelect:e=>{this.selectionGeneration+=1,this.restoringPreference=!1,this.contextWindow=e,this.notify()},onModelSetup:()=>e.context?.navigate(`model-setup`),onProviderSettings:t=>_t(e.context,e.agentId,t),onModelPickerOpen:()=>{let t=this.metadataClient,n=this.metadataScope;!this.metadataReader.pending&&t&&n&&this.metadataReader.read(),this.catalogTargets.retry(e.context?.gateway.snapshot,this.agentId)}}}}})))()}var sd;function cd(){return(cd=e((()=>{p(),O(),Z(),ra(),_(),Q(),nu(),lu(),vl(),Cu(),Eu(),qu(),Qu(),ed(),Dl(),od(),wl(),Ma(),X(),sd=class{get terminalHostId(){return this.terminalHost.hostId}get terminalOnNode(){return this.terminalHost.onNode}selectTerminalHost(e){this.terminalHost.select(e,this.read().submitting,()=>{this.folderValidation.cancel(),this.browser.clearProjectSelection(),this.repositoryState.reset(),this.folderValue=this.terminalOnNode?``:this.workspacePath(),this.selection.folderSelectedByUser=!0,this.terminalOnNode||this.repositoryState.load(),this.callbacks.changed()})}synchronizeTerminalHosts(){this.terminalHost.synchronize(this.read().data?.terminalHosts,e=>this.selectTerminalHost(e))}get deviceFolder(){return this.deviceFolderValue!==null&&this.deviceId?{deviceId:this.deviceId,path:this.deviceFolderValue}:void 0}get deviceFolderAvailable(){return this.deviceFolderOffered&&!this.deviceFolderRuntimeUnsupportedReason}get deviceFolderRuntimeUnsupportedReason(){return this.devicePlacementRuntime()?.cloudPlacementExecutionMode===`worker-turn`?void 0:E(`newSession.deviceFolderRuntimeUnsupported`)}get deviceFolderOffered(){return $l(this.deviceId,this.devices())}selectDeviceFolder(){Ju(this.targetActions(),()=>{this.deviceFolderValue=``})}setDeviceFolderPath(e){this.deviceFolderValue===null||this.read().submitting||this.read().pendingPlacementSessionKey||(this.deviceFolderValue=e,this.callbacks.changed())}constructor(e,t,n,r){this.gateway=e,this.browser=t,this.read=n,this.callbacks=r,this.terminalHost=new $u,this.agentIdValue=``,this.folderValue=``,this.deviceFolderValue=null,this.cloudMachines=new cu,this.agentsHydrated=!1,this.agentSelectedByUser=!1,this.routeModelIntentActive=!0,this.selection=gu(),this.suggestedCloudProfile=new Ku(e,this,n,r),this.folderValidation=new El(()=>({gateway:this.read().context?.gateway.snapshot,folder:this.folderValue,selectedByUser:this.selection.folderSelectedByUser,isAdmin:this.isAdmin()}),{onApprovedRootsChange:r.changed,onVerified:()=>{this.callbacks.onClearError(E(`newSession.browserLoadFailed`)),this.repositoryState.load()},onMissing:()=>{this.callbacks.onClearError(E(`newSession.browserLoadFailed`)),this.folderValue=this.workspacePath(),this.repositoryState.rejectPreferredWorktree(),this.persistPreference({folder:this.folderValue,worktree:!1}),this.repositoryState.load()},onFailed:()=>this.callbacks.onError(E(`newSession.browserLoadFailed`))}),this.repositoryState=new Tu(()=>({agentId:this.agentIdValue,agents:this.agents(),remotePlacement:this.remotePlacement,selectedProject:this.browser.selectedProject(),remoteProject:this.browser.remoteProject,folder:this.folderValue,workspace:this.workspacePath(),workspaceGit:this.selectedAgent()?.workspaceGit===!0,gateway:this.read().context?.gateway}),{changed:r.changed,persistPreference:e=>this.persistPreference(e),capturePreferenceConsumption:(e,t)=>this.gateway.capturePreferenceConsumption(e.agentId,e.workspace,t)}),this.modelControl=new ad(r.changed,e=>void this.gateway.persistModelPreference(this.agentIdValue,e),e=>this.read().context?.navigate(`new-session`,{search:_n(this.agentIdValue,{catalogId:e})}))}get agentId(){return this.agentIdValue}get folder(){return this.folderValue}get hostedEnvironment(){return this.requiredPlacement||A(this.read().data)?void 0:this.modelControl.resolveAgentRuntime()?.workspaceEnvironment}selectHostedEnvironment(e){let t=this.read();t.submitting||t.pendingPlacementSessionKey||!this.canWrite()||this.requiredPlacement||A(t.data)||this.modelControl.selectHostedEnvironment(e)&&(this.deviceFolderValue=null,this.suggestedCloudProfile.cancel(),this.browser.close(),this.callbacks.onError(null),this.callbacks.changed())}get worktree(){return!this.deviceFolder&&!this.hostedEnvironment&&(this.remotePlacement||this.repositoryState.worktree)&&!this.remoteRepository}get currentCheckoutUnavailableReason(){return this.repositoryState.currentCheckoutUnavailableReason}get checkoutVisible(){return!this.deviceFolder&&!this.hostedEnvironment&&!this.freshWorkspace&&this.repositoryState.checkoutVisible(!!this.browser.projectId)}get freshWorkspace(){return!this.deviceFolder&&(this.requiredPlacement||this.remotePlacement&&this.selection.freshWorkspace)}get remoteRepository(){return this.requiredPlacement||this.deviceFolder?void 0:this.repositoryState.remoteRepository}get worktreeName(){return this.freshWorkspace?``:this.repositoryState.worktreeName}get baseRef(){return this.freshWorkspace?``:this.repositoryState.baseRef}get repository(){return this.repositoryState.repository}get deviceId(){return this.requiredPlacement||this.hostedEnvironment?``:this.selection.deviceId}get autoDevice(){return!this.requiredPlacement&&!this.hostedEnvironment&&this.selection.autoDevice}get remotePlacement(){return!!(this.requiredPlacement||!this.hostedEnvironment&&(this.selection.deviceId||this.selection.autoDevice||this.selection.cloudProfileId))}get requiredPlacement(){return _l.requiredPlacement(this.gateway,this.read().data)}get cloudProfileId(){return this.requiredPlacement?this.gateway.requiredProfile:this.hostedEnvironment?``:this.selection.cloudProfileId}get cloudSelection(){return this.requiredPlacement?{os:``,machineClass:``}:this.cloudMachines.selection(this.selection.cloudProfileId,this.gateway.cloudProfiles)}preferenceSelection(){return _u(this.selection,this.browser,this.repositoryState,this.workspacePath(),this.folderValue)}get placementPreferenceReady(){return!!this.deviceFolder||!!this.hostedEnvironment||xu(this.selection,this.freshWorkspace||this.repositoryState.preferenceReady,this.browser.projectsLoading||this.browser.projectsReady,this.requiredPlacement)}adoptGroupDefaults(){this.read().data?.groupStatus===`resolved`&&vu(this.selection,this.repositoryState)&&this.adoptAgentDefaults({preserveSelectedAgent:!0})}agents(){return ki(this.read().context?.agents.state.agentsList?.agents??[])}selectedAgent(){let e=this.read().context?.agents.state.agentsList?.agents??[];return wr(e,this.agentIdValue)}devicePlacementRuntime(){return this.modelControl.resolveAgentRuntime({agent:this.selectedAgent(),context:this.read().context})}devices(){return Xl(this.gateway.environments,this.devicePlacementRuntime()?.devicePlacement,this.gateway.deviceCatalogDisabledReason)}devicePlacement(){return Ql(this.devices(),this.gateway.environments,this)}isAdmin(){return a(this.read().context?.gateway.snapshot.hello?.auth??null)}canWrite(){return u(this.read().context?.gateway.snapshot.hello?.auth??null)}workspacePath(){return l(this.selectedAgent()?.workspace)??``}knownWorkspaceRoots(){return this.folderValidation.knownWorkspaceRoots(this.workspacePath())}recordGatewayApprovedListing(e){this.folderValidation.recordApprovedListing(e)}folderSubmissionBlocked(){return this.deviceFolder?!this.deviceFolderAvailable||!bl(this.deviceFolder.path.trim()):this.hostedEnvironment||this.freshWorkspace?!1:this.browser.projectId||this.browser.remoteProject?!this.browser.remoteProject&&(!this.browser.selectedProject()||this.repositoryState.checkoutSubmissionBlocked):this.folderValidation.blocked}adoptAgentDefaults(e={}){let t=this.read(),n=this.agents(),r=t.context?.agents.state.agentsList?.defaultId,i=n.some(e=>e.id===r)?r??``:n[0]?.id??``;if(e.preserveSelectedAgent&&this.agentSelectedByUser&&this.selectedAgent()||(this.agentIdValue=Qc(t.data,n,i),this.agentSelectedByUser=!1),A(t.data)&&this.terminalOnNode){this.callbacks.changed();return}let a=this.agentIdValue?this.gateway.readPreference(this.agentIdValue):null,o=e.preserveSelectedFolder&&this.selection.folderSelectedByUser;if(!o&&!t.pendingPlacementSessionKey){let e=this.workspacePath(),n=Sr(a,e),r=!!t.data?.group,i=t.data?.groupCwd??``,o=t.data?.groupWorktree===!0;this.folderValue=r?i||e:n.folder,this.selection.projectSelectedByUser||(this.selection.freshWorkspace=!r&&n.freshWorkspace),this.selection.folderSelectedByUser=!1,this.repositoryState.adoptPreference(r?{worktree:o}:a),bu(this.selection,a,r,A(t.data)),n.workspaceMoved&&!r&&this.persistPreference({folder:e})}o&&!t.pendingPlacementSessionKey&&this.agentIdValue&&this.persistPreference({folder:this.folderValue,worktree:this.worktree}),this.modelControl.load(t.context,this.agentIdValue,!A(t.data),{agent:this.selectedAgent(),preference:a,configuredDefaults:this.requiredPlacement,initialModel:this.routeModelIntentActive?Gc(t.data,this.agentIdValue):void 0}),this.selection.preferredProjectRestore?this.folderValidation.cancel():!this.selection.folderSelectedByUser&&this.folderValue!==this.workspacePath()&&!t.pendingPlacementSessionKey?this.folderValidation.validate(this.folderValue):(this.folderValidation.cancel(),this.repositoryState.synchronize()),this.callbacks.changed()}resetPlaceSelection(){this.deviceFolderValue=null,this.suggestedCloudProfile.cancel(),this.folderValidation.reset(),Object.assign(this.selection,gu()),this.repositoryState.reset()}resetDraft(){this.routeModelIntentActive=!0,this.terminalHost.reset(),this.agentSelectedByUser=!1,this.folderValue=``,this.browser.clearProjectSelection(),this.resetPlaceSelection(),this.browser.resetProjectSearch(),this.modelControl.reset(),this.cloudMachines.clear(),this.callbacks.changed()}invalidateGatewayDiscovery(e){this.suggestedCloudProfile.cancel(),this.repositoryState.invalidate(),this.agentsHydrated=!1,this.modelControl.invalidate(e),this.browser.close(),this.folderValidation.reset(),this.browser.resetProjectSearch(),this.browser.resetProjects(e),e&&(this.agentIdValue=``,this.agentSelectedByUser=!1,this.folderValue=``,this.resetPlaceSelection(),this.cloudMachines.clear()),this.callbacks.changed()}applyPendingPlacement(e){this.agentIdValue=e.agentId,this.selection.deviceId=e.deviceId??``,this.selection.autoDevice=e.autoDevice===!0,this.selection.cloudProfileId=e.profileId,this.cloudMachines.applyPending(e.profileId,e.machineClass,e.os),this.folderValue=e.cwd??``,this.deviceFolderValue=e.deviceFolder?.path??null,this.selection.freshWorkspace=e.worktreeSource===`empty`,this.selection.freshWorkspace&&this.browser.clearProjectSelection(),e.repository&&(this.browser.selectProject({kind:`remote`,project:{identity:e.repository.url,cloneUrl:e.repository.url}}),this.repositoryState.setDetail(`baseRef`,e.repository.ref??``,!1),this.repositoryState.load()),this.callbacks.changed()}clearCloudProfile(){this.selection.cloudProfileId=``,this.browser.close(),this.callbacks.changed()}clearProjectSelection(){(this.browser.projectId||this.browser.remoteProject)&&this.repositoryState.clearDetails(!0),this.browser.clearProjectSelection(),yu(this.selection,!0),this.persistPreference({projectId:``,remoteProject:null,defaultRepositoryOptOut:!0}),this.repositoryState.load(),this.callbacks.changed()}selectAgentId(e){let t=this.read();t.submitting||t.pendingPlacementSessionKey||A(t.data)||D(e)!==D(this.agentIdValue)&&(this.agentIdValue=D(e),this.routeModelIntentActive=!1,this.modelControl.reset(),this.callbacks.onError(null),this.agentSelectedByUser=!0,this.browser.clearProjectSelection(),this.resetPlaceSelection(),this.browser.close(),this.adoptAgentDefaults({preserveSelectedAgent:!0}))}applyFolder(e){let t=this.read();t.submitting||t.pendingPlacementSessionKey||(this.deviceFolderValue=null,this.browser.clearProjectSelection(),this.folderValidation.cancel(),this.callbacks.onError(null),this.folderValue=e.trim(),this.selection.freshWorkspace=!1,this.selection.folderSelectedByUser=!0,yu(this.selection,!0),A(t.data)&&this.terminalOnNode?this.callbacks.changed():(this.repositoryState.selectWorktree(!1),this.agentsHydrated&&this.persistPreference({folder:this.folderValue,projectId:``,remoteProject:null,defaultRepositoryOptOut:!0,worktree:this.worktree,freshWorkspace:!1}),this.repositoryState.load()))}selectNewWorkspace(){let e=this.read();e.submitting||e.pendingPlacementSessionKey||!this.remotePlacement||(this.folderValidation.cancel(),this.browser.clearProjectSelection(),this.browser.resetProjectSearch(),this.callbacks.onError(null),this.deviceFolderValue=null,this.folderValue=this.workspacePath(),this.selection.folderSelectedByUser=!0,yu(this.selection,!0),this.selection.freshWorkspace=!0,this.repositoryState.selectWorktree(!1),this.persistPreference({folder:this.folderValue,projectId:``,remoteProject:null,defaultRepositoryOptOut:!0,worktree:!0,freshWorkspace:!0}),this.browser.close(),this.callbacks.changed())}selectProjectId(e){let t=this.browser.projects.find(t=>t.id===e);t&&this.selectProject({kind:`local`,id:t.id})}selectRemoteProject(e){this.selectProject({kind:`remote`,project:e})}selectProject(e){let t=this.read();t.submitting||t.pendingPlacementSessionKey||(this.deviceFolderValue=null,this.browser.selectProject(e),this.selection.freshWorkspace=!1,this.folderValidation.cancel(),this.browser.resetProjectSearch(),this.callbacks.onError(null),this.selection.folderSelectedByUser=!1,yu(this.selection,!1),this.repositoryState.clearDetails(!0),this.persistPreference({projectId:e.kind===`local`?e.id:``,remoteProject:e.kind===`remote`?e.project:null,defaultRepositoryOptOut:!1,...e.kind===`local`?{where:Ir(this)}:{},worktree:this.worktree,...e.kind===`local`?{worktreeName:``}:{},freshWorkspace:!1}),e.kind===`remote`&&e.project.defaultBranch&&this.repositoryState.setDetail(`baseRef`,e.project.defaultBranch,!1),this.repositoryState.load(),this.browser.close())}targetActions(){return{place:this,read:this.read,selection:this.selection,callbacks:this.callbacks,folderValidation:this.folderValidation,repositoryState:this.repositoryState,browser:this.browser,modelControl:this.modelControl,persistPreference:e=>this.persistPreference(e),clearDeviceFolder:()=>{this.deviceFolderValue=null}}}selectDevice(e,t=!1){Yu(this.targetActions(),e,t)}selectCloudProfile(e){Xu(this.targetActions(),e)}selectWorktree(e){Zu(this.targetActions(),e)}setBaseRef(e){this.repositoryState.setDetail(`baseRef`,e,this.read().submitting)}setWorktreeName(e){this.repositoryState.setDetail(`worktreeName`,e,this.read().submitting)}captureSubmittedWorktreeName(e,t,n=!1){return this.repositoryState.captureSubmittedName(e,{agentId:t,recovered:n})}restorePreferenceSelections(){this.hostedEnvironment||(Su({state:this.selection,browser:this.browser,gateway:this.gateway,where:Ir(this),modelControl:this.modelControl,repositoryState:this.repositoryState,isAdmin:()=>this.isAdmin(),persistPreference:e=>this.persistPreference(e),changed:this.callbacks.changed,requiredPlacement:this.requiredPlacement,loadConfiguredDefaults:e=>{this.modelControl.load(this.read().context,this.agentId,!A(this.read().data),{agent:this.selectedAgent(),preference:this.gateway.readPreference(this.agentId),configuredDefaults:e})}}),this.repositoryState.synchronizeProjectCheckout())}browseAvailable(){return this.gateway.connected&&(this.isAdmin()||!!this.workspacePath())}worktreeAvailable(){return!this.hostedEnvironment&&this.repositoryState.available()}persistPreference(e){this.gateway.persistPreference(this.agentIdValue,this.workspacePath(),e)}}})))()}var ld;function ud(){return(ud=e((()=>{fo(),Nt(),ld=class{constructor(e,t){this.notify=e,this.onUserChange=t,this.attachments=[],this.reads=new St(e)}replace(e){this.attachments=e,this.onUserChange(),this.notify()}restore(e){En(this.attachments,[e]),this.attachments=e,this.notify()}take(){this.reads.abortReads();let e=this.attachments;return this.attachments=[],this.notify(),e}reset(){this.reads.abortReads(),this.clearAfterSubmit(!0)}clearAfterSubmit(e){e&&ft(this.attachments),this.attachments=[],this.notify()}}})))()}var dd;function fd(){return(fd=e((()=>{Xi(),he(),dd=class{begin(e){let{context:t,params:n}=e,r=n.key??(e.resumed?void 0:this.preview?.creation.sessionKey??`agent:${e.agentId}:dashboard:${n.incognito?`incognito-`:``}${T()}`);if(!r){this.clear();return}e.resumed||(n.key=r);let i=rr(t.gateway),a=t.gateway.connection.gatewayUrl,o=this.preview?.creation.sessionKey===r?this.preview:void 0,s=o?.creation??{sessionKey:r,admitted:!1},c={creation:s,message:e.message,displayName:e.displayName,canDisplay:()=>rr(t.gateway)===i&&t.gateway.connection.gatewayUrl===a};if(o)o.handle.update(c),this.preview={...o,entry:c,retry:e.retry};else{this.clear();let n=t.chatSubmissions.beginBackgroundCreate(c);this.preview={creation:s,entry:c,handle:n,retry:e.retry}}}admitBefore(e){return(t,n)=>(this.clear(),e(t,n))}settle(e,t){let n=this.preview;n&&!t&&(e?(n.entry={...n.entry,failure:{error:e,retry:n.retry}},n.handle.update(n.entry)):this.clear())}clear(){let e=this.preview;this.preview=void 0,e&&(e.creation.admitted=!0,e.handle.clear())}}})))()}var pd;function md(){return(md=e((()=>{p(),O(),qi(),ui(),xn(),ya(),pd=class{constructor(e,t){this.notify=e,this.onMutation=t,this.toolOverridesValue=null,this.skillCatalog=new hn(e)}get toolOverrides(){return this.toolOverridesValue}setToolOverrides(e){let t=Rr(e)>0?e:null;t!==this.toolOverridesValue&&(this.onMutation(),this.toolOverridesValue=t,this.notify())}reset(){this.toolOverridesValue=null}canStartAsDraft(e){let t=e?.gateway.snapshot.hello?.policy;return t?.allowedSessionVisibilities?.includes(`draft`)===!0&&t?.hasMultipleSessionSharingIdentities===!0}composerProps(e,t,n){return e?(this.skillCatalog.synchronize(t.client,t.connectionEpoch),{toolOverrides:this.toolOverridesValue,capabilityMenu:{read:()=>{let r=e.runtimeConfig.state,i=_i(r),a=t.connected&&!!t.client,o=f(e.gateway.snapshot),s=a?i?o.canAdmin?null:E(`chat.composer.menu.adminBlocked`):r.lastError??E(`common.loading`):E(`chat.composer.menu.offlineBlocked`);return{basePath:e.basePath,skills:this.skillCatalog.rows(n,this.toolOverridesValue),skillsRead:this.skillCatalog.read(n),...Ue(i,{auth:e.gateway.snapshot.hello?.auth??null,loading:r.configLoading}),toolsEffectiveResult:null,toolsEffectiveLoading:!1,toolsEffectiveError:!1,toolAccessMutationBlockedReason:s,webSearchBaseEnabled:Ga(i),mutationBlockedReason:s,canAdmin:o.canAdmin&&a,adminBlockedReason:o.canAdmin?a?null:E(`chat.composer.menu.offlineBlocked`):E(`chat.composer.menu.adminBlocked`),onLoadSkills:()=>{let e=t.client,r=t.connectionEpoch;this.skillCatalog.load(e,r,n,()=>t.connected&&t.client===e&&t.connectionEpoch===r)},onPatchToolOverrides:e=>this.setToolOverrides(e),onNavigate:(t,n)=>e.navigate(t,n)}}}}):{toolOverrides:this.toolOverridesValue,capabilityMenu:void 0}}}})))()}function hd(e){let t=null;return{captureSelection(){let n=e();t=n?{start:n.selectionStart,end:n.selectionEnd,value:n.value}:null},previewTranscript(n,r){let i=e();return i?n(r,t,{start:i.selectionStart,end:i.selectionEnd,value:i.value,maxLength:i.maxLength})?.value:void 0},insertTranscript(n,r,i,a){let o=e(),s=o&&n(r,t,{start:i?o.selectionStart:o.value.length,end:i?o.selectionEnd:o.value.length,value:o.value,maxLength:o.maxLength},i,a);return!o||!s||(t=s.captured,!s.changed)?null:(o.value=s.value,fn(o),queueMicrotask(()=>{o.isConnected&&(Bi(o,{preventScroll:!0}),Zi(o,s.caret,s.caret))}),s.value)}}}var gd;function _d(){return(_d=e((()=>{ye(),ue(),ma(),Kt(),sn(),jn(),gd=class extends EventTarget{constructor(e){super(),this.options=e,this.devicePicker=new Cn,this.session=null,this.owner=null,this.changed=()=>this.dispatchEvent(new Event(`change`)),this.place=(...e)=>this.session?.placeTranscript(...e),this.devicePicker.subscribe(this.changed)}subscribe(e){return w(this,`change`,e)}dispose(){this.owner=null,this.session?.dispose(),this.session=null,this.devicePicker.dispose()}get active(){return this.session?.active===!0}previewDraft(){return this.session?.active?this.options.textarea.previewTranscript(this.place,this.session.transcript):void 0}get dictation(){return this.session??void 0}prepare(e,t){this.owner?.key!==e&&(this.owner={key:e},this.session?.dispose(),this.session=null);let n=this.owner,r=()=>this.owner===n,i=this.options.getClient(),a=this.options.isConnected()&&i!==null;this.devicePicker.syncCatalog(i,a,this.options.getSessionKey?.());let o=this.options.canCommit(),s={client:i,connected:a,enabled:o,prepareSession:i?.auth&&!le({role:i.auth.role??`operator`,requestedScopes:[`operator.talk`],allowedScopes:i.auth.scopes??[]})?this.options.prepareSession:void 0,dictationAvailable:this.devicePicker.dictationStatus===`ready`,realtimeTalkActive:!1,onCommit:(e,t,n)=>{if(!r()||!this.options.canCommit())return;let i=this.options.textarea.insertTranscript(this.place,e,t,n);i!==null&&this.options.onMessage(i)},onError:e=>{r()&&this.options.onError(e)},onDictationUnavailable:this.devicePicker.handleOpen};this.session||(this.session=new Wn(s),this.session.subscribe(this.changed)),this.session.update(s);let c=this.session;return{voice:{connected:a,disabled:!o,readDictation:()=>c,microphonePicker:{devices:this.devicePicker.devices,loading:this.devicePicker.loading,open:this.devicePicker.open,selectedDeviceId:t?.trim()??``,voiceActive:!1,issue:this.devicePicker.issue,showRealtimeCapability:!1,realtimeStatus:this.devicePicker.realtimeStatus,dictationStatus:this.devicePicker.dictationStatus,onOpen:this.devicePicker.handleOpen,onClose:this.devicePicker.handleClose,onSelect:e=>{te({realtimeTalkInputDeviceId:e.trim()||void 0}),this.devicePicker.handleClose()}},onDirectDictationStart:()=>this.options.textarea.captureSelection()},onSubmit:()=>{r()&&this.options.canCommit()&&this.options.onSubmit()}}}}})))()}function vd(){let e=null,t=null,n=``,r=``,i=``,a={...hd(()=>e),critterVisit:Math.random(),skillMenu:Jn(),slashMenu:Cr(),mentionMenu:pn(),emojiMenu:Ye(),composing:!1,mentionInput:void 0,capabilityMenuOpen:!1,capabilityMenuView:`root`,ref(t){let n=t instanceof HTMLTextAreaElement?t:null;e&&e!==n&&Va(e),e=n,n&&(gi(n),Ht(n))},syncDraft(t){e?.isConnected&&e.value!==t&&Ht(e)},getTextarea:()=>e,syncSkillCommandOwner(e,o){a.ownsSkillCommands(e,o)||(t=e,n=o.agentId.trim(),r=o.draftOwnerKey,i=o.commandProjectId?.trim()??``,a.emojiMenu.close(),a.skillMenu.reset(),a.slashMenu.dispose(),a.slashMenu.reset())},ownsSkillCommands(e,a){return t===e&&n===a.agentId.trim()&&r===a.draftOwnerKey&&i===(a.commandProjectId?.trim()??``)},refreshSkillCommands(e){let t={agentId:n,draftOwnerKey:r,commandProjectId:i};return Lt({client:e,agentId:t.agentId,projectId:t.commandProjectId,shouldApply:()=>a.ownsSkillCommands(e,t)})},disconnect(){a.skillMenu.dispose(),a.slashMenu.dispose(),a.emojiMenu.dispose(),a.composing=!1,a.mentionMenu.dispose(),t=null,n=``,r=``,i=``,a.capabilityMenuOpen=!1,a.capabilityMenuView=`root`,a.ref()}};return a}function yd(){return(yd=e((()=>{je(),Kt(),qt(),Ha(),no(),Yr(),_d()})))()}var bd;function xd(){return(xd=e((()=>{o(),Xi(),O(),rt(),Wt(),Ja(),Lr(),gr(),he(),fo(),ud(),xt(),bd=class{constructor(e,t,n,r,i){this.context=e,this.agentId=t,this.incognito=n,this.notifyDraft=r,this.retireCreation=i,this.id=T(),this.composerDraft={read:()=>({draft:this.message,mentions:this.mentions,attachments:this.attachmentDraft.attachments,pendingAttachmentReads:this.attachmentDraft.reads.pendingReads}),subscribe:e=>this.subscribe(e)},this.message=``,this.mentions=[],this.inputs=[],this.error=null,this.listeners=oe(),this.invalidations=new Set,this.transferred=!1,this.initializationPending=!1,this.disposed=!1,this.notify=()=>{this.notifyDraft(),this.listeners.publish()},this.subscribe=this.listeners.subscribe,this.gatewayUrl=e.gateway.connection.gatewayUrl,this.recoveryScope=e.gateway.snapshot.hello?.auth?.recoveryScope,this.presentationScope=rr(e.gateway),this.attachmentDraft=new ld(this.notify,()=>{this.error=null});let a=w(window,`beforeunload`,e=>{this.hasInput&&(e.preventDefault(),e.returnValue=``)}),o=re(()=>!this.hasInput,()=>Ai({severity:`error`,message:E(`newSession.followUpReloadBlocked`)}));this.unregisterReload=()=>{o(),a()}}get hasInput(){return!!(this.message||this.inputs.length||this.transfer?.inputs.length||this.attachmentDraft.attachments.length||this.attachmentDraft.reads.pendingReads)}ownsScope(){let{gateway:e}=this.context;return!!this.recoveryScope&&rr(e)===this.presentationScope&&e.connection.gatewayUrl===this.gatewayUrl&&(e.snapshot.phase!==`connected`||e.snapshot.hello?.auth?.recoveryScope===this.recoveryScope)}canDisplay(){return!this.disposed&&!this.transferred&&this.ownsScope()}canRecover(){return!this.disposed&&this.ownsScope()&&this.accepted!==void 0}get acceptedSessionKey(){return this.accepted?.key}canAdopt(){return this.canDisplay()&&this.accepted!==void 0&&!this.initializationPending}setMessage(e,t){this.canDisplay()&&(this.mentions=t??li(this.message,e,this.mentions),this.message=e,this.error=null,this.notify())}enqueue(){if(!this.canDisplay()||this.attachmentDraft.reads.pendingReads)return!1;let e=ke(this.message,this.mentions);if(!e.text&&!this.attachmentDraft.attachments.length)return!1;if(/^[!/]/u.test(e.text))this.error=E(`newSession.followUpCommandsUnavailable`);else if(this.inputs.length>=50)this.error=E(`chat.queue.full`);else if(this.attachmentDraft.attachments.length&&!Na(this.context.config))this.error=Si();else{let t={id:T(),text:e.text,...e.mentions?.length?{mentions:e.mentions}:{},attachments:this.attachmentDraft.take(),createdAt:Date.now()};return this.inputs=[...this.inputs,t],this.message=``,this.mentions=[],this.error=null,this.notify(),!0}return this.notify(),!1}remove(e){if(!this.canDisplay())return;let t=this.inputs.find(t=>t.id===e);this.inputs=this.inputs.filter(e=>e!==t),ft(t?.attachments??[]),this.notify()}accept(e,t){this.accepted=e,this.initializationPending=t?.initializationPending===!0}take(e=()=>{}){if(this.transfer)return this.canRecover()?this.transfer:void 0;if(!this.canAdopt())return;this.flushInput?.();let t=!1,n={sessionKey:this.accepted.key,draft:this.message,mentions:this.mentions,attachments:this.attachmentDraft.attachments,reads:this.attachmentDraft.reads,inputs:this.inputs,incognito:this.incognito,isCurrent:()=>!this.disposed&&this.ownsScope(),claimDraft:()=>!t&&(t=!0,!0),onInvalidate:e=>this.disposed?(e(),()=>{}):g(this.invalidations,e),complete:()=>{this.invalidations.clear(),this.unregisterReload(),this.transfer=void 0,e()},initialRejected:this.accepted.initialRun.status===`rejected`,...typeof this.accepted.entry?.sessionId==`string`?{sessionId:this.accepted.entry.sessionId}:{}};return this.transfer=n,this.transferred=!0,this.inputs=[],this.message=``,this.mentions=[],this.attachmentDraft.attachments=[],this.flushInput=void 0,this.releasePresentation?.(),this.releasePresentation=void 0,n}releaseDraft(){this.accepted||this.dispose()}dispose(){if(!this.disposed){this.disposed=!0,this.retireCreation?.(),this.recovery=void 0;for(let e of this.invalidations)e();if(this.invalidations.clear(),this.transfer=void 0,this.unregisterReload(),this.transferred)this.listeners.clear();else{this.flushInput=void 0,this.releasePresentation?.(),this.releasePresentation=void 0,this.attachmentDraft.reset();for(let e of this.inputs)ft(e.attachments);this.inputs=[],this.message=``,this.mentions=[],this.listeners.clear()}}}}})))()}function Sd(e){return e.hostedEnvironment?void 0:(e.browser.remoteProject?.projectId??e.browser.projectId)||void 0}function Cd(e,t){let n={...t,deferInitialTurn:e.remotePlacement,agentId:e.agentId,model:e.modelControl.modelForSubmission(),agentRuntime:e.modelControl.agentRuntime,contextWindow:e.modelControl.contextWindow,thinkingLevel:e.modelControl.thinkingLevel,fastMode:e.modelControl.fastMode,cyberAccessProgram:e.modelControl.accessProgramForSubmission(),projectId:Sd(e),projectGitUrl:e.hostedEnvironment?void 0:e.browser.remoteProject?.cloneUrl,repository:e.remoteRepository,deviceFolder:e.deviceFolder,worktree:e.worktree,worktreeSource:e.freshWorkspace?`empty`:void 0,baseRef:e.baseRef,worktreeName:e.worktreeName,cwd:e.hostedEnvironment?void 0:e.folder,workspace:e.workspacePath()},r=l(n.displayName),i=l(n.baseRef),a=l(n.worktreeName),o=l(n.cwd),s=l(n.workspace),c=l(n.catalogId),u=l(n.category),d=l(n.model),f=l(n.agentRuntime),p=l(n.contextWindow),m=l(n.thinkingLevel),h=n.deferInitialTurn?``:n.message,g=n.deferInitialTurn&&n.visibility!==`incognito`?be(n.message.trim(),1e3):void 0,_=n.deviceFolder,v=!_&&n.worktreeSource===`empty`,y=_||v?void 0:n.repository,b=_||v||y?void 0:l(n.projectId),x=!_&&!v&&!y&&!b&&(h.trim()||!n.deferInitialTurn&&n.attachments?.length)?l(n.projectGitUrl):void 0,S=!_&&!v&&!y&&!b&&!x&&o&&o!==s?o:void 0;return{agentId:D(n.agentId),message:h,...!n.deferInitialTurn&&n.mentions?.length?{mentions:n.mentions.map(e=>({...e}))}:{},...r?{displayName:r}:{},...g?{titleSource:g}:{},...n.visibility===`incognito`?{incognito:!0}:{},...n.visibility===`draft`?{visibility:`draft`}:{},...!n.deferInitialTurn&&n.attachments?.length?{attachments:n.attachments}:{},...c?{catalogId:c}:{},...u?{category:u}:{},...!c&&d?{model:d}:{},...!c&&d&&f?{agentRuntime:f}:{},...!c&&p?{contextWindow:p}:{},...!c&&m?{thinkingLevel:m}:{},...!c&&n.fastMode!==void 0?{fastMode:n.fastMode}:{},...!c&&n.cyberAccessProgram!==void 0?{cyberAccessProgram:n.cyberAccessProgram}:{},...n.toolOverrides?{toolOverrides:n.toolOverrides}:{},...n.permissionMode?{permissionMode:n.permissionMode}:{},...b?{projectId:b}:{},...x?{projectGitUrl:x}:{},...y?{repository:{...y}}:{},..._?{deviceFolder:{..._,path:_.path.trim()}}:{},...S?{cwd:S}:{},...v?{worktree:!0,worktreeSource:`empty`}:{},...n.worktree&&!_&&!y&&!v?{worktree:!0,...i?{worktreeBaseRef:i}:{},...a?{worktreeName:a}:{}}:{}}}function wd(){return(wd=e((()=>{_()})))()}var Td,Ed,Dd,Od,kd;function Ad(){return(Ad=e((()=>{Di(),Vn(),aa(),r(),Td=()=>({writeId:Math.random().toString(36).slice(2),retired:!1,committedRevision:0,writes:new Set}),Dd=()=>Ed??=v(()=>import(`./_2_____________________________.js`).then(e=>(e.q(),e.K)),__vite__mapDeps([0,3]),import.meta.url),Od=200,kd=class e{static{this.active=new Set}constructor(e,t,n){this.read=e,this.apply=t,this.onStorageError=n,this.contentReconciled=!1,this.pendingSelectionMutations=new Set,this.gatewayOwner=``,this.recoveryScope=``,this.routeKey=``,this.revision=0,this.mutationGeneration=0,this.mutation=Td(),this.inheritedWriteIds=[],this.disconnected=!1,this.pendingHandoffMutation=null,this.submittedMutation=null,this.pristineMutationBaseline=0,this.restoreGeneration=0,this.restoredIdentity=``,this.pending=null,this.timer=null,this.lineageByScope=new Map}setOwner(e,t,n=!1){let r=zi(e).gatewayOwner,i=JSON.stringify([r,t]),a=this.gatewayOwner?JSON.stringify([this.gatewayOwner,this.recoveryScope]):``;if(a===i)return;let o=this.routeKey;this.persistNow(),this.restoreGeneration+=1,this.restoredIdentity=``,this.contentReconciled=!1,this.routeKey=``,this.gatewayOwner=r,this.recoveryScope=t,a&&!n&&(this.pendingSelectionMutations.clear(),this.apply({message:``,attachments:[],permissionMode:void 0},!0)),n||this.activateRoute(o)}setIncognito(e){if(e)return this.retireActive();let t=this.scope();return(t?this.lineage(t).retirement:void 0)?.then(()=>{})??Promise.resolve()}transitionIncognito(e,t,n){let r=this.setIncognito(t);e&&!t?(this.noteUserMutation(),r.finally(n)):n()}selectRoute(e){e&&this.routeKey!==e&&(this.persistNow(),this.routeKey&&this.pendingSelectionMutations.clear(),this.routeKey=e,this.contentReconciled=!1,this.revision=0)}activateRoute(e){this.selectRoute(e);let t=this.scope();if(!t)return;let n=Dr(t);if(n===this.restoredIdentity)return;if(this.restoredIdentity=n,this.contentReconciled=!1,this.read().incognito){this.retireActive();return}let r=++this.restoreGeneration,i=this.mutationGeneration,a=this.read(),o=De(a.message,a.attachments,void 0,a.mentions),s=this.restoreScope(t,i,()=>{let e=this.read();return r===this.restoreGeneration&&i===this.mutationGeneration&&this.matchesScope(t)&&o===De(e.message,e.attachments,void 0,e.mentions)});this.restorePromise=s,s.then(e=>{this.restorePromise===s&&(this.restorePromise=void 0,this.contentReconciled=e,this.flushSelectionMutations())},()=>{this.restorePromise===s&&(this.restorePromise=void 0,this.contentReconciled=!1,Ni(t,this.onStorageError))})}noteDraftReplaced(){this.restoreGeneration+=1,this.mutationGeneration+=1,this.mutation=Td(),this.pendingHandoffMutation=null,this.submittedMutation=null,this.inheritedWriteIds=[],this.pristineMutationBaseline=this.mutationGeneration}noteSelectionMutation(e){let t=!this.contentReconciled&&this.mutationGeneration===this.pristineMutationBaseline&&(this.submittedMutation===this.mutation||!this.restorePromise);this.submittedMutation=null,this.pendingSelectionMutations.add(e),t?(this.restoredIdentity=``,this.activateRoute(this.routeKey)):this.flushSelectionMutations()}flushSelectionMutations(){this.pendingSelectionMutations.size>0&&!this.restorePromise&&this.restoredIdentity&&(this.contentReconciled||this.mutationGeneration>this.pristineMutationBaseline)&&!this.disconnected&&this.submittedMutation!==this.mutation&&(this.noteUserMutation(),this.persistNow())}noteUserMutation(){if(this.pendingSelectionMutations.clear(),this.mutationGeneration+=1,this.mutation=Td(),this.pendingHandoffMutation=null,this.submittedMutation=null,this.revision=qr(this.revision),this.read().incognito)return;this.discardPending();let e=this.snapshot();e&&(this.pending=e,this.timer=globalThis.setTimeout(()=>this.persistNow(),Od))}retireActive(){this.mutationGeneration+=1,this.mutation.retired=!0,this.discardPending();let e=qr(this.revision);this.revision=e;let t=this.scope();if(!t)return Promise.resolve();let n=this.lineage(t);return n.localWriteIds.clear(),n.retirement=(async()=>{let{retireDurableComposerDraft:r}=await Dd(),i=Math.max(e,n.revision),a=await r(t,i);if(a.status===`storage-failed`)Ni(t,this.onStorageError);else if(a.status===`persisted`){let e=a.revision??i;return this.adoptCommittedRevision(t,e,a.writeId),{revision:e,writeId:a.writeId}}})(),n.retirement.then(()=>{})}captureSubmission(){this.pendingSelectionMutations.clear(),this.reconcileHandoffCommit(),this.submittedMutation=this.mutation,this.mutationGeneration===this.pristineMutationBaseline&&(this.restorePromise&&(this.contentReconciled=!1),this.restoreGeneration+=1),this.persistNow();let e=this.scope(),t=e?this.lineage(e):null;return{scope:e,mutation:this.mutation,revision:this.revision,incognito:this.read().incognito,pendingEdit:this.mutationGeneration>this.pristineMutationBaseline&&this.mutation.committedRevision===0,writeIds:new Set([t?.writeId,this.mutation.writeId,...this.inheritedWriteIds,...t?.localWriteIds??[]])}}adoptHandoff(e){e.scope&&this.matchesScope(e.scope)&&(this.mutation=e.mutation,this.revision=Math.max(this.revision,e.revision),e.pendingEdit&&!e.mutation.committedRevision&&(this.pristineMutationBaseline=this.mutationGeneration-1,this.pendingHandoffMutation=e.mutation),this.inheritedWriteIds=[...e.writeIds])}async clearSubmittedDraft(t,n){t.mutation.retired=!0;let{scope:r}=t;if(this.mutation===t.mutation&&this.matchesScope(r)&&(this.modelSelection?.retire(),n?.()),await Promise.all(t.mutation.writes),!r)return;let{readDurableComposerDraft:i}=await Dd();for(let n=0;n<3;n+=1){let n=await i(r);if(n.status===`storage-failed`){Ni(r,this.onStorageError);return}if(n.status!==`found`||!t.writeIds.has(n.draft.writeId))return;let a=n.draft.revision,o=n.draft.writeId,s=qr(a),c=`clear:${s}`,{result:l}=await Zr({scope:r,expectedRevision:a,...o?{expectedWriteId:o}:{},revision:s,text:``,storedAttachments:[],writeId:c});if(l.status===`persisted`){this.adoptCommittedRevision(r,l.revision??s,l.writeId??c);for(let t of e.active){let e=t.scope();e&&Dr(e)===Dr(r)&&(t.restoredIdentity=``,t.activateRoute(e.scopeKey))}return}if(l.status===`storage-failed`){Ni(r,this.onStorageError);return}}}persistNow(){this.clearTimer();let e=this.pending;if(!e)return;if(this.read().incognito){this.discardPending();return}this.pending=null;let t=(async()=>{try{let t=e.retirement?await e.retirement:void 0;if(e.mutation.retired||!this.lineage(e.scope).localWriteIds.has(e.writeId))return;let n=t&&t.revision>e.expectedRevision?{...e,expectedRevision:t.revision,expectedWriteId:t.writeId,revision:qr(Math.max(e.revision,t.revision))}:e,{result:r,payloadUnavailable:i}=await Zr(n);if(i&&Ni(e.scope,this.onStorageError),r.status===`persisted`||r.status===`payload-too-large`){let t=r.revision??n.revision;e.mutation.committedRevision=t,this.adoptCommittedRevision(e.scope,t,r.writeId??e.writeId),r.status===`payload-too-large`&&Ni(e.scope,this.onStorageError);return}if(r.status===`storage-failed`){Ni(e.scope,this.onStorageError);return}if(this.disconnected||e.mutation.retired||this.routeKey!==e.scope.scopeKey||this.revision!==e.revision)return;this.restoredIdentity=``,this.activateRoute(this.routeKey)}finally{this.forgetLocalWrite(e)}})();e.mutation.writes.add(t),t.finally(()=>e.mutation.writes.delete(t))}connect(){this.disconnected=!1,e.active.add(this)}disconnect(){this.disconnected=!0,e.active.delete(this),this.persistNow(),this.restoreGeneration+=1}scope(){return!this.gatewayOwner||!this.recoveryScope||!this.routeKey?null:{gatewayOwner:this.gatewayOwner,recoveryScope:this.recoveryScope,scopeKey:this.routeKey}}matchesScope(e){let t=this.scope();return e===null?t===null:t!==null&&Dr(e)===Dr(t)}snapshot(){let e=this.scope();if(!e||this.revision<=0||this.mutation.retired)return null;let t=this.read(),n=this.lineage(e),r=[...n.localWriteIds],i=this.mutation.writeId;return n.localWriteIds.add(i),{scope:e,mutation:this.mutation,retirement:n.retirement,expectedRevision:n.revision,...n.writeId?{expectedWriteId:n.writeId}:{},expectedWriteIds:r,revision:this.revision,text:t.message,...t.mentions?.length?{mentions:t.mentions.map(e=>({...e}))}:{},modelSelection:this.modelSelection?.read(),permissionMode:t.permissionMode,storedAttachments:Ia(t.attachments),writeId:i}}async restoreScope(e,t,n){let{readDurableComposerDraft:r}=await Dd(),i=await r(e);if(i.status===`storage-failed`)return Ni(e,this.onStorageError),!1;let a=i.status===`found`?i.draft.revision:i.revision,o=i.status===`found`?i.draft.writeId:i.writeId,s=this.lineage(e);if(s.revision=a??0,s.writeId=o,!n()||(this.reconcileHandoffCommit(),this.submittedMutation===this.mutation&&this.mutation.committedRevision>0))return!1;if(a===void 0||a<this.revision||t>this.pristineMutationBaseline)return a!==void 0&&a>=this.revision?this.revision=qr(a):this.revision<=0&&t>this.pristineMutationBaseline&&(this.revision=qr(0)),this.pending=this.snapshot(),this.persistNow(),!0;let c=[];if(i.status===`found`)try{c=await Br(i.draft.attachments)}catch{return Ni(e,this.onStorageError),!1}if(!n())return!1;this.revision=a;let l=i.status===`found`?i.draft:void 0,u=this.pendingSelectionMutations.has(`permission`)?this.read().permissionMode:l?.permissionMode;return this.apply({message:l?.text??``,attachments:c,mentions:l?.mentions,permissionMode:u}),this.modelSelection?.restore(i.status===`found`?i.draft.modelSelection:void 0),this.mutation.committedRevision=a,!0}reconcileHandoffCommit(){this.pendingHandoffMutation===this.mutation&&this.mutation.committedRevision>0&&this.submittedMutation!==this.mutation&&(this.revision=Math.max(this.revision,this.mutation.committedRevision),this.pristineMutationBaseline=this.mutationGeneration,this.pendingHandoffMutation=null)}clearTimer(){this.timer!==null&&(globalThis.clearTimeout(this.timer),this.timer=null)}discardPending(){this.clearTimer();let e=this.pending;this.pending=null,e&&this.forgetLocalWrite(e)}forgetLocalWrite(e){let t=Dr(e.scope),n=this.lineageByScope.get(t);n&&(n.localWriteIds.delete(e.writeId),!n.revision&&!n.writeId&&!n.localWriteIds.size&&!n.retirement&&this.lineageByScope.delete(t))}lineage(e){let t=Dr(e),n=this.lineageByScope.get(t);return n||(n={revision:0,localWriteIds:new Set},this.lineageByScope.set(t,n)),n}adoptCommittedRevision(e,t,n){let r=this.lineage(e);r.revision=t,n&&(r.writeId=n),this.matchesScope(e)&&t>this.revision&&(this.revision=t)}}})))()}function jd(e,t){let{os:n,machineClass:r}=t.cloudSelection;return e.sessionKey?e.target:t.cloudProfileId?{kind:`profile`,profileId:t.cloudProfileId,...t.requiredPlacement?{required:!0}:{},...n?{os:n}:{},...r?{machineClass:r}:{}}:t.deviceId?{kind:`device`,deviceId:t.deviceId}:t.autoDevice?{kind:`auto-device`}:null}function Md(e){let t=e.createParams?.incognito?`incognito`:e.createParams?.visibility===`draft`?`draft`:`normal`;return{placement:{agentId:e.agentId,profileId:e.target.kind===`profile`?e.target.profileId:``,...e.target.kind===`profile`?{os:e.target.os,machineClass:e.target.machineClass}:e.target.kind===`device`?{deviceId:e.target.deviceId}:{autoDevice:!0},cwd:e.createParams?.cwd,...e.createParams?.deviceFolder?{deviceFolder:e.createParams.deviceFolder}:{},...e.createParams?.worktreeSource?{worktreeSource:e.createParams.worktreeSource}:{},...e.createParams?.repository?{repository:e.createParams.repository}:{}},draft:{message:e.message,...e.mentions?.length?{mentions:e.mentions}:{},attachments:yi(e.attachments),visibility:t,toolOverrides:e.createParams?.toolOverrides??null,permissionMode:e.createParams?.permissionMode}}}async function Nd(e){let{pending:t,submittedRecovery:n,sessionKey:r}=e,{gatewayUrl:i,recoveryScope:a}=n,o=e=>t.owns(i,a,e),s=()=>o(n.sessionKey);if(n.phase===`creating`&&(!e.isLifecycleCurrent()||!s())){if(t.hasOtherLiveOwner(i,a,n.sessionKey))return;let o=await As({client:e.client,describe:e.context.sessions.describe},r,e.agentId);o?(s()&&(t.promoteToDispatching(r),t.retryAllowed=!0),e.setError(E(`newSession.placementStartFailed`,{error:o}))):s()&&e.clearRecovery();return}if(n.phase===`creating`&&e.isLifecycleCurrent()&&s()&&!t.promoteToDispatching(r)){e.onRecoveryUnavailable();return}let c=t.capture();if(!c||c.phase===`creating`){e.onRecoveryUnavailable();return}if(!e.isRequestCurrent())return;let l=e.startupError?Uo(c,e.startupError,t.persistent).recovery:c;e.context.placementStartup.start({recovery:l,persistRecovery:t.persistent,mode:n.phase===`creating`?`dispatch`:`recover`,createdAt:e.createdAt}),await e.consumeWorktreeName?.();let u=()=>e.isLifecycleCurrent()&&o(l.sessionKey);u()&&(await e.clearDraft(),u()&&(t.reset(),e.completeInBackground(l.sessionKey,l.messageId)?e.onAccepted():await e.navigate()))}function Pd(){return(Pd=e((()=>{O(),Z(),Go(),Ls(),mr(),X()})))()}var Fd;function Id(){return(Id=e((()=>{Mn(),pe(),O(),Z(),he(),Da(),X(),Fd=class{constructor(e,t){this.gateway=e,this.readPreparation=t,this.request=new AbortController,this.preparedDictation=null,this.pending=null,this.dictationSessionKey=()=>this.currentDictationPreparation()?.key}currentDictationPreparation(e=this.pending?.preparedDictation??this.preparedDictation){let t=this.readPreparation?.();return t&&e?.client===t.client&&e.selection===JSON.stringify(t.params)?e:null}async prepareDictationSession(){let e=this.readPreparation?.();if(!e)throw Error(E(`newSession.createFailed`));let{context:t,client:n,params:r,access:i}=e;if(!t||!n||!i.allowed)throw Error(i.allowed?E(`newSession.createFailed`):i.reason);let a=this.currentDictationPreparation();a||(a={client:n,selection:JSON.stringify(r),request:t.sessions.createResult(r,{reconciliation:`background`,signal:t.lifecycleAbortSignal})},this.preparedDictation=a);let o=await a.request;if(!o||this.currentDictationPreparation()!==a)throw this.preparedDictation===a&&(this.preparedDictation=null),Error(t.sessions.state.error??E(`newSession.createFailed`));return a.key=o.key,e.changed(),o.key}async startPreparedSession(e,t,n){let r=await e.request;if(!r)return null;let a=t.idempotencyKey??T(),o=ti(await e.client.request(`chat.send`,{sessionKey:r.key,agentId:t.agentId,message:t.message??``,mentions:t.mentions,attachments:t.attachments,idempotencyKey:a},{timeoutMs:i,signal:n,retainSentResultOnAbort:!0}),a);return fa(o)?{key:r.key,initialRun:{status:`rejected`,error:Ar(o,`chat`)}}:{key:r.key,initialRun:{status:`started`,runId:o.runId}}}captureRequest(){return this.request.abort(),this.request=new AbortController,this.request.signal}abortRequest(){this.request.abort()}clearPreparation(){this.preparedDictation=null}create(e,t,n){if(n.pendingKey)return Promise.resolve({key:n.pendingKey,initialRun:{status:`idle`}});let r=n.resumedParams??this.start(t,n.background),i=n.allowPrepared?this.currentDictationPreparation():null;return n.allowPrepared&&this.pending?.preparedDictation&&!i?Promise.resolve(null):(i&&this.pending&&(this.pending.preparedDictation=i),i?this.startPreparedSession(i,r,n.signal):e.sessions.createResult(r,{reconciliation:`background`,signal:n.signal}))}get active(){return this.pending!==null}start(e,t=!1){let n=this.gateway.sessionCreateScope;if(!n)return e;if(!this.pending){let r=Date.now();this.pending={params:Object.freeze({...e,idempotencyKey:T()}),scope:n,startedAt:r,interrupted:!1,background:t}}return this.pending.params}clear(){this.pending=null}interrupt(){return!this.pending||!this.matchesOwner()?(this.clear(),!1):(this.pending.interrupted=!0,!0)}retireChangedOwner(){return!this.pending||this.matchesOwner()?!1:(this.clear(),!0)}resume(){return this.pending?.interrupted?Date.now()>=this.pending.startedAt+24e4?(this.clear(),{kind:`expired`}):this.matchesOwner()?this.gateway.connected?(this.pending.interrupted=!1,{kind:`resume`,params:this.pending.params,startedAt:this.pending.startedAt,background:this.pending.background}):{kind:`wait`}:(this.clear(),{kind:`owner-changed`}):{kind:`wait`}}matchesOwner(){return this.pending?.scope===this.gateway.sessionCreateScope&&(!this.pending?.preparedDictation||this.currentDictationPreparation(this.pending.preparedDictation)!==null)}}})))()}function Ld(e,t){let n=t.flatMap(e=>e.selectionAnnotation?[wa(e.selectionAnnotation)]:[]);if(!n.length)return e;let r=[...n,e.text].filter(Boolean).join(`
`),i=r.length-e.text.length;return{text:r,mentions:e.mentions?.map(e=>({...e,start:e.start+i,end:e.end+i}))}}function Rd(e,t,n,r,i=!1){let a=t.pendingPlacement,o=!r&&!!a.sessionKey,s=Ld(ke(t.message,t.mentions),t.attachmentDraft.attachments),c=r?.params.message??(o?a.message:s.text),l=(r?r.params.mentions:o?a.mentions:s.mentions)?.map(({profileId:e,start:t,end:n})=>({profileId:e,start:t,end:n})),u=t.attachmentDraft.attachments.filter(e=>!e.selectionAnnotation);if(!r&&!o){let t=pt(u,e.gateway.snapshot.hello?.policy);if(t!==void 0)return Ai({severity:`error`,message:t}),null}let d=r?r.params.attachments:o?void 0:Ot(u),f=o?a.attachments:d,p=r?.params.agentId??(o?a.agentId:D(n.agentId)),m=o?a.gatewayUrl:e.gateway.connection.gatewayUrl,h=e.gateway.snapshot.client;if(!h||!e.gateway.snapshot.hello)return null;!r&&!o&&n.modelControl.initializeAccessProgram();let g=Fc({enabled:i,agentId:p,client:h,context:e}),_=o?a.recoveryScope:h.recoveryScope,v=r?.params??(o?a.createParams:Cd(n,{message:c,visibility:t.visibility})),{hello:y,selfUser:b}=e.gateway.snapshot;return{turn:{text:c,mentions:l,attachments:u,createdAt:r?.startedAt??Date.now(),sender:Bn(y,h.instanceId,b)??void 0},consumeWorktreeName:v&&n.captureSubmittedWorktreeName(v,p,!!(r||o)),pendingPlacement:o,message:c,mentions:l,attachments:u,draftAttachments:d,apiAttachments:f,agentId:p,gatewayUrl:m,client:h,recoveryScope:_,completeInBackground:g,hasInitialTurn:!!(c||f?.length)}}function zd(){return(zd=e((()=>{Et(),Wt(),_(),Lr(),ca(),On(),Rc(),wd()})))()}function Bd(e,t){let{context:n,result:r,turn:i}=e,{text:a,attachments:o}=i;return r.initialRun.status===`rejected`&&is({agentId:e.agentId,attachments:o,context:n,error:r.initialRun.error,message:a,mentions:i.mentions,sessionKey:r.key,sessionId:typeof r.entry?.sessionId==`string`?r.entry.sessionId:void 0,retryAfter:t})}async function Vd(e){let{context:t,client:n,agentId:r,result:i,instant:a}=e,{key:o,initialRun:s}=i,c=s.status===`started`?vi(o,e.turn,n,s.runId):null;!a&&e.isCurrent()&&t.chatSubmissions.retain(c);let l=s.status===`rejected`?void 0:e.clearDraft(!0,e.isCurrent()&&(!a||a.isCurrent())?void 0:!1);if((a||l)&&await Promise.all([a?.waitForReady(),l]),!e.isCurrent()||a&&!a.isCurrent())return;let u=s.status===`rejected`&&Ei(s.errorDetails)?s.errorDetails:void 0,d=u?so():void 0;try{if(l)a&&t.chatSubmissions.retain(c);else{let t=Bd(e,d?.promise);await e.clearDraft(!t)}if(!e.isCurrent()||a&&!a.isCurrent())return;if(e.completeInBackground(o,s.status===`started`?s.runId:void 0)){e.onAccepted?.();return}if(e.composer&&(e.composer.accept(i),ga(t,o,e.composer)),a?.admitted(o,r),await e.navigation.navigate(t,{client:n,key:o,agentId:r,entry:i.entry},a?.commit.bind(a)),e.finishNavigation(),u){let e=t.gateway.snapshot,a=()=>t.gateway.snapshot.phase===`connected`&&t.gateway.snapshot.client===n&&t.gateway.snapshot.hello===e.hello&&m(t.gateway.snapshot.sessionKey,o);try{let{confirmNativeRuntimePermissionRecovery:n}=await v(async()=>{let{confirmNativeRuntimePermissionRecovery:e}=await import(`./chat-native-runtime-recovery-4try-xI_.js`);return{confirmNativeRuntimePermissionRecovery:e}},__vite__mapDeps([4,5,6,7,8,9,0,3,10]),import.meta.url),s=await n({sessions:t.sessions,hello:e.hello},o,u,{agentId:r,expectedSessionId:typeof i.entry?.sessionId==`string`?i.entry.sessionId:void 0,signal:t.lifecycleAbortSignal,retriesMessage:!0,canDispatch:a});d?.resolve(!!(s&&a()))}catch(e){a()&&Ai({severity:`error`,message:E(`chat.nativeRuntimeRecovery.failed`,{error:``}).trim(),detail:Ge(e)})}}}finally{d?.resolve(!1)}}function Hd(){return(Hd=e((()=>{Ie(),O(),Ra(),k(),ta(),_(),Lr(),pi(),Hi(),as(),r(),to()})))()}function Ud(e,t,n){let{router:r,lifecycleAbortSignal:i}=e,a=new AbortController,o=r.navigate(t,e,{history:`none`},n),s=r.getState().location,c=i?AbortSignal.any([a.signal,i]):a.signal,l=r.subscribe(e=>{e.location!==s&&a.abort()}),u=w(c,`abort`,l,{once:!0});return{ready:o.catch(()=>void 0),signal:c,isActive:()=>!c.aborted&&r.getState().location===s,dispose(){l(),u()}}}function Wd(){return(Wd=e((()=>{})))()}function Gd(e,t){let n=Yd.get(e);if(n&&n.search===t&&n.owns())return Yd.delete(e),Xd.set(n.draft.data,{page:n.draft.page,canDisplay:n.canDisplay}),n.draft.data}function Kd(e,t){e&&Xd.get(e)?.page===t&&Xd.delete(e)}function qd(e){let t=e&&typeof e==`object`?Xd.get(e):void 0;return t?.canDisplay()?t.page:void 0}function Jd(e,t){return Yd.set(e,t),()=>{Yd.get(e)===t&&Yd.delete(e)}}var Yd,Xd;function Zd(){return(Zd=e((()=>{Yd=new WeakMap,Xd=new WeakMap})))()}function Qd(e){let{context:t,params:n,agentId:r,retainDraft:i}=e;if(!e.enabled||!t.gateway.snapshot.hello?.auth?.recoveryScope||!i)return;let a=(e.resumed?n.key:void 0)??`agent:${r}:dashboard:${n.incognito?`incognito-`:``}${T()}`;return e.resumed||(n.key=a),()=>{let o=i();return o?new ef(t,a,r,o,e.message,e.composer,n.displayName,n.category):void 0}}var $d,ef;function tf(){return(tf=e((()=>{Xi(),fr(),ao(),he(),Wd(),Zd(),$d=new WeakMap,ef=class{constructor(e,t,n,r,i,a,o,s){this.context=e,this.key=t,this.draft=r,this.stopGateway=()=>{},this.clearPendingCreate=()=>{},this.disposed=!1,this.lifetime=new AbortController,this.creation={sessionKey:t,admitted:!1},this.client=e.gateway.snapshot.client,this.hello=e.gateway.snapshot.hello,this.gatewayUrl=e.gateway.connection.gatewayUrl,this.recoveryScope=this.hello?.auth?.recoveryScope,this.presentationScope=rr(e.gateway);let c=$d.get(e);this.previousSessionKey=e.gateway.snapshot.sessionKey,this.previousAgentId=e.agentSelection.state.selectedId,c?.dispose(),this.returnLocation={pathname:globalThis.location.pathname,search:globalThis.location.search,hash:globalThis.location.hash},$d.set(e,this);let l={pathname:ot({context:e,face:`chat`,sessionKey:t,agentId:n,exactKey:!0}).options.pathname,search:``,hash:``};this.clearPendingCreate=e.chatSubmissions.beginCreate({creation:this.creation,message:i,composer:a,displayName:o,category:s,canDisplay:()=>this.canDisplay()}),this.transition=Ud(e,`chat`,l),w(this.transition.signal,`abort`,()=>this.dispose(),{once:!0,signal:this.lifetime.signal}),this.stopGateway=e.gateway.subscribe(()=>{let t=e.gateway.snapshot;(t.phase!==`connected`||t.hello!==this.hello||t.client!==this.client||e.gateway.connection.gatewayUrl!==this.gatewayUrl||t.hello?.auth?.recoveryScope!==this.recoveryScope)&&(t.phase!==`connected`&&e.gateway.connection.gatewayUrl===this.gatewayUrl&&r.synchronizeGateway(),this.rollback())})}sameIdentity(){let{gateway:e}=this.context;return!!this.recoveryScope&&e.connection.gatewayUrl===this.gatewayUrl&&e.snapshot.phase===`connected`&&e.snapshot.hello?.auth?.recoveryScope===this.recoveryScope}canDisplay(){return rr(this.context.gateway)===this.presentationScope&&this.context.gateway.connection.gatewayUrl===this.gatewayUrl&&(this.context.gateway.snapshot.phase!==`connected`||this.sameIdentity())}liveConnection(){return this.sameIdentity()&&this.context.gateway.snapshot.client===this.client&&this.context.gateway.snapshot.hello===this.hello}ownsSelection(){let e=this.admittedSelection?.key??this.previousSessionKey,t=this.admittedSelection?.agentId??this.previousAgentId;return this.context.gateway.snapshot.sessionKey===e&&this.context.agentSelection.state.selectedId===t}async waitForReady(){await this.transition.ready}isCurrent(){return!this.disposed&&!this.rollingBack&&$d.get(this.context)===this&&this.transition.isActive()&&this.liveConnection()&&this.ownsSelection()}rollback(){return this.rollingBack??=this.restore(),this.rollingBack}async restore(){await this.transition.ready;try{await Qa(this.context.gateway,this.lifetime.signal)}catch{return}if(this.disposed||$d.get(this.context)!==this||!this.transition.isActive())return;let e=this.sameIdentity()&&this.ownsSelection();this.transition.dispose(),this.stopGateway();let t=this.context.agentSelection.state.selectedId,n={draft:this.draft,search:this.returnLocation.search??``,owns:()=>$d.get(this.context)===this&&!this.disposed&&this.sameIdentity(),canDisplay:()=>this.canDisplay()&&this.context.agentSelection.state.selectedId===t},r=()=>{};e&&(this.draft.synchronizeGateway(),r=Jd(this.context,n));try{let e=Ud(this.context,`new-session`,this.returnLocation);await e.ready,await new Promise(e=>{globalThis.setTimeout(e,0)}),e.dispose()}finally{r(),this.dispose()}}admitted(e,t){this.admittedSelection={key:e,agentId:t},!this.disposed&&e===this.key&&(this.creation.admitted=!0,this.clearPendingCreate())}commit(){return this.disposed||this.rollingBack||!this.transition.isActive()||!this.liveConnection()?!1:(this.transition.dispose(),this.stopGateway(),!0)}async finish(){await this.rollingBack,this.dispose()}dispose(){this.disposed||(this.disposed=!0,this.lifetime.abort(),this.clearPendingCreate(),this.transition.dispose(),this.stopGateway(),$d.get(this.context)===this&&$d.delete(this.context),this.draft.release())}}})))()}function nf(e,t){if(t?.renderedElements?.(`openclaw-chat-pane`).some(e=>e.active&&e.composerReady))return{cancel:()=>void 0,ready:Promise.resolve()};let{promise:n,resolve:r}=so();return{cancel:w(e,si,()=>r(),{once:!0}),ready:n}}async function rf(e){let{document:t,from:n,navigate:r,prefersReducedMotion:i,router:a,signal:o,to:s}=e;if(n!==`new-session`||s!==`chat`)return r();let c=e.getOutlet(),l=nf(t,c),u=!1,d,{promise:f,resolve:p}=so(),m=()=>{u||(u=!0,d?.cancel(),p())},h=()=>{},g=o&&w(o,`abort`,m,{once:!0});try{if(o?.aborted)return;let e=r(),t=a.getState().location.pathname,n=()=>{let e=a.getState();((e.pendingMatches[0]??e.matches[0])?.routeId!==s||e.location.pathname!==t)&&m()};if(h=a.subscribe(n),n(),await Promise.race([(async()=>{await e,await c?.settlePresentation(),await l.ready})(),f]),u||i)return;d=c?.animate?.(af,of),await Promise.race([d?.finished.catch(()=>void 0),f])}finally{h(),g?.(),l.cancel()}}var af,of;function sf(){return(sf=e((()=>{Ie(),Zt(),af=[{transform:`translateY(5px) scale(0.997)`},{transform:`none`}],of={duration:180,easing:`cubic-bezier(0.16, 1, 0.3, 1)`}})))()}function cf(e){let t=rr(e),n=e.connection.gatewayUrl,r=e.snapshot.hello?.auth?.recoveryScope??(e.snapshot.client?.recoveryScopeReady?e.snapshot.client.recoveryScope:void 0);return()=>{let i=e.snapshot,a=i.hello?.auth?.recoveryScope??(i.client?.recoveryScopeReady?i.client.recoveryScope:void 0);return r??=a,rr(e)===t&&e.connection.gatewayUrl===n&&(!a||a===r)}}var lf;function uf(){return(uf=e((()=>{Te(),Xi(),sf(),k(),di(),nr(),ao(),_(),pi(),lf=class{constructor(){this.current=null,this.submitted=null}captureSubmission(e,t,n,r=()=>!0){let i=cf(e.gateway);return(a,o)=>{n&&r()&&i()&&(this.submitted={context:e,message:n,key:a,agentId:t,error:o,canDisplay:i})}}submission(e){let t=this.submitted;return t&&t.context===e&&t.canDisplay()?t:null}messageForTurn(e,t,n){return Ne(n,`available`)??(this.isCurrent(e,t)?this.submission(e)?.message??null:null)}async openSubmission(e,t,n){let r=e?.gateway.snapshot.client;if(!t||!e||!r||e.gateway.snapshot.phase!==`connected`||this.submission(e)!==t)return;let i=n.capture();n.publish(t.message,null);let a;try{await this.navigate(e,{client:r,key:t.key,agentId:t.agentId})}catch(e){i()&&t.canDisplay()&&(a=j(e))}finally{i()&&n.publish(null,a)}}clearSubmission(){this.submitted=null}isCurrent(e,t){let n=this.current,r=e?.gateway.snapshot;return!!(n&&r?.phase===`connected`&&r.client===n.client&&r.hello===n.hello&&r.sessionKey===n.key&&D(t)===n.agentId)}async navigate(e,t,n){let r={...t,hello:e.gateway.snapshot.hello};this.current=r,Nr({selection:e.agentSelection,gateway:e.gateway,sessionKey:t.key,agentId:t.agentId});let i=ot({context:e,face:`chat`,sessionKey:t.key,agentId:t.agentId,focusComposer:!0,navigationKey:t.key}).options;await rf({document,getOutlet:()=>e.routeOutlet,from:e.router.getState().matches[0]?.routeId,to:`chat`,router:e.router,signal:e.lifecycleAbortSignal,prefersReducedMotion:globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,navigate:()=>{if(this.current!==r||!this.isCurrent(e,t.agentId))throw new DOMException(`Session navigation interrupted`,`AbortError`);if(n&&!n())throw new DOMException(`Session navigation superseded`,`AbortError`);return e.chatSubmissions.acceptCreate({creation:{sessionKey:t.key,admitted:!0},displayName:tn(t.key,{displayName:l(t.entry?.displayName),label:l(t.entry?.label)}),category:l(t.entry?.category),canDisplay:cf(e.gateway)}),Yi(e.gateway,i.pathname,t.key),e.navigateAndWait(`chat`,i)}}),this.current===r&&(this.current=null)}}})))()}function df(e){let t=e.trim();return!t||ff.test(t)}var ff;function pf(){return(pf=e((()=>{ff=/^[a-z0-9][a-z0-9-]{0,63}$/})))()}function mf(e,t){let n=zn(e,{method:`sessions.catalog.startTerminal`,requiredScope:`operator.admin`});return!n.allowed||!t?n:zn(e,{method:`worktrees.create`,requiredScope:`operator.admin`})}async function hf(e){let{context:t,data:n}=e.snapshot,{place:r,flow:i}=e,a=t?.gateway.snapshot.client,o=n?.catalogId.trim()??``,s=D(r.agentId);if(!t||!a||!o||!s||!i.canSubmit()){i.noteBlockedSubmitAttempt();return}let c=e.capture(a),l=i.message.trim(),u={hostId:r.terminalHostId,cwd:r.folder.trim()||(r.terminalOnNode?``:r.workspacePath()),worktree:r.worktree,worktreeName:r.worktreeName,baseRef:r.baseRef},d=r.captureSubmittedWorktreeName(u,s);c.publish(Ne({text:l,createdAt:Date.now()},`available`),!0),r.browser.close(),e.closeTransientUi();try{let e=u.cwd;if(u.worktree){let t=await ls(a,{repoRoot:e,name:u.worktreeName,baseRef:u.baseRef});if(!c.isCurrent())return;e=t.path}let n=await Us(a,{catalogId:o,agentId:s,hostId:u.hostId,cwd:e,...l?{initialMessage:l}:{}},c.isCurrent);if(!n||!c.isCurrent()||(await d?.(),!c.isCurrent()))return;await c.consume(),c.isCurrent()&&t.replace(`terminal`,{pathname:ce(n.sessionId,t.basePath),search:``,hash:``})}catch(e){c.isCurrent()&&i.setError(j(e))}finally{c.isRequestCurrent()&&c.publish(null,!1)}}function gf(){return(gf=e((()=>{_e(),Z(),k(),Tt(),Ws(),_(),pi(),X()})))()}function _f(e){switch(e.kind){case`forbidden`:return e.missingScope===`operator.admin`?E(`newSession.folderRequiresScope`):e.missingScope===`operator.write`?E(`newSession.folderRequiresWrite`):e.missingScope===`operator.read`?E(`newSession.folderRequiresRead`):E(`newSession.gitCheckAccessDenied`);case`unavailable`:return E(`newSession.gitCheckUnavailable`);default:return}}function vf(e){let{gateway:t,place:n,pendingPlacement:r,hasInitialTurn:i,createParams:a}=e,o=!!r.sessionKey,s=jd(r,n),c=!n.hostedEnvironment&&!s&&!i?n.browser.remoteProject:null;if(!o&&c&&!c.projectId){let e=zn(t,{method:`projects.add`,requiredScope:`operator.write`});if(!e.allowed)return e}if(!s||!o||r.phase===`creating`){let e=zn(t,{method:`sessions.create`,params:a,sessionScope:!0});if(!e.allowed||!s||s.kind===`profile`&&s.required)return e}return s.kind===`profile`&&s.required?zn(t,{method:`chat.send`,sessionScope:!0}):zn(t,{method:`sessions.dispatch`,requiredScope:`operator.write`,params:Ts({key:r.sessionKey,agentId:r.agentId||n.agentId,target:s})})}function yf(e){let{snapshot:t,gateway:n,place:r,pendingPlacement:i}=e;if(!n.placementPolicyReady)return!1;let a=r.selectedAgent(),o=t.context?.agents.state;return r.modelControl.requiresModelSetup({catalog:A(t.data)||r.remotePlacement||!!i.sessionKey,connected:n.connected,agentsLoaded:!!o?.agentsList,selectedAgentFound:a!==void 0,agentModel:a?.model?.primary})}function bf(e,t,n,r){let i=A(r.data)?`terminal`:`session`,a=!!n.pendingPlacement.sessionKey;if(n.mentions.length>0&&(i===`terminal`||n.visibility===`incognito`||n.message.trimStart().startsWith(`/`)))return{gate:`mentions-unsupported`,reason:E(`chat.mentions.unsupported`)};if(e.preferenceLoading||i===`session`&&t.modelControl.isRestoringPreference()||!t.placementPreferenceReady)return{gate:`preference-restore`,reason:E(`newSession.restoringPreferences`)};let o=r.context?.agents.state,s=()=>({gate:`agents`,reason:E(o?.agentsError?`newSession.agentDefaultsUnavailable`:`newSession.loadingAgentDefaults`)});if(i===`session`&&!e.placementPolicyReady)return o?.agentsList?{gate:`cloud`,reason:E(`newSession.placementNotReady`)}:s();if(i===`session`&&e.requiredProfile&&!e.cloudProfiles.some(t=>t.id===e.requiredProfile))return{gate:`cloud`,reason:E(`newSession.requiredWorkerUnavailable`)};if(i===`session`&&n.requiresModelSetup())return{gate:`model-setup`,reason:E(`modelSetup.required.title`)};if(Xc(r.data,r.context?.sessions))return{gate:`route-pending`,reason:E(`newSession.catalogUnavailable`)};if(n.attachmentDraft.reads.pendingReads>0)return{gate:`attachment-reads`,reason:E(`newSession.readingAttachment`)};if(!a&&n.submissionOutcomeUnknown)return{gate:`outcome-unknown`,reason:E(n.submissionOutcomeUnknown===`gateway-changed`?`newSession.createOutcomeUnknown`:`newSession.placementSetupInterrupted`)};let c=r.context?.gateway,l=c?.snapshot.phase===`connected`?c.snapshot.client??null:null;if(!c||!l)return{gate:`disconnected`,reason:E(`sessionsView.actionRequiresConnection`)};if(i===`session`&&!a&&n.visibility===`draft`&&c.snapshot.hello?.policy?.allowedSessionVisibilities?.includes(`draft`)===!1)return{gate:`draft-unavailable`,reason:E(`newSession.draftUnavailable`)};let u=i===`terminal`?mf(c.snapshot,t.worktree):n.submissionAccess();if(!u.allowed)return{gate:`access`,reason:u.reason};if(i===`terminal`){if(r.context?.config.current.cliAgentsEnabled!==!0||!r.context.config.current.terminalEnabled)return{gate:`terminal-capabilities`,reason:E(`newSession.terminalDisabled`)};if(!r.data?.terminalHosts?.some(e=>e.hostId===t.terminalHostId))return{gate:`device`,reason:E(`newSession.terminalHostUnavailable`)};if(n.attachmentDraft.attachments.length>0)return{gate:`terminal-capabilities`,reason:E(`newSession.terminalAttachmentsUnsupported`)};if(t.remotePlacement||n.pendingPlacement.sessionKey)return{gate:`device`,reason:E(`newSession.terminalPlacementUnsupported`)};if(n.capabilities.toolOverrides!==null)return{gate:`terminal-capabilities`,reason:E(`newSession.terminalCapabilityOverridesUnsupported`)}}if(t.suggestedCloudProfile.pending)return{gate:`cloud`,reason:E(`newSession.placementNotReady`)};if(a)return n.pendingPlacement.retryAllowed&&l.recoveryScopeReady&&jd(n.pendingPlacement,t)&&n.pendingPlacement.agentId&&n.pendingPlacement.gatewayUrl===c.connection.gatewayUrl&&n.pendingPlacement.recoveryScope===l.recoveryScope?xf(n,i,a):{gate:`placement-recovery`,reason:E(`newSession.placementNotReady`)};if(t.folderSubmissionBlocked())return{gate:`folder`,reason:t.deviceFolder&&t.deviceFolderRuntimeUnsupportedReason||t.currentCheckoutUnavailableReason||E(t.deviceFolder?t.deviceFolderAvailable?`newSession.deviceFolderPathRequired`:`newSession.deviceFolderUnavailable`:`newSession.checkingPlace`)};if(t.deviceFolder&&n.attachmentDraft.attachments.length>0)return{gate:`folder`,reason:E(`newSession.deviceFolderAttachmentsUnsupported`)};if(!o?.agentsList)return s();let d=jd(n.pendingPlacement,t),f=d?.kind===`profile`?d.profileId:``,p=e.cloudProfiles.find(e=>e.id===f),m=i===`session`&&t.modelControl.modelSelectionBlockedReason(t.selectedAgent(),p?.inference);if(m)return{gate:`model-unavailable`,reason:m};if(t.agents().length===0)return{gate:`agents`,reason:E(`newSession.agentsUnavailable`)};if(!$c(r.data,t.selectedAgent()))return{gate:`agent-not-allowed`,reason:E(`newSession.catalogUnavailable`)};let h=i===`session`?t.devicePlacement():void 0;if(h&&!h.ready)return{gate:`device`,reason:h.disabledReason??E(`newSession.nodeUnavailable`)};let g=t.modelControl.devicePlacementUnsupportedReason();if((t.deviceId||t.autoDevice)&&g)return{gate:`device-runtime`,reason:g};if(d&&(!l.recoveryScope||!l.recoveryScopeReady||e.cloudProfilesPending))return{gate:`placement-recovery`,reason:E(`newSession.placementNotReady`)};let _=()=>t.modelControl.cloudRuntimeUnsupportedReason(p);return f&&(!e.cloudProfilesReady||!p||_())?{gate:`cloud`,reason:_()??E(`newSession.placementNotReady`)}:t.worktree&&!t.freshWorkspace&&!t.worktreeAvailable()?{gate:`worktree-unavailable`,reason:t.repository.kind===`checking`?E(`newSession.checkingGit`):t.remotePlacement&&t.repository.kind!==`forbidden`?E(`newSession.remoteSourceUnavailable`):_f(t.repository)??E(`newSession.gitCheckUnavailable`)}:t.worktree&&!t.freshWorkspace&&!df(t.worktreeName)?{gate:`worktree-name`,reason:E(`newSession.worktreeNameInvalid`)}:i===`terminal`&&!(t.folder.trim()||!t.terminalOnNode&&t.workspacePath())?{gate:`terminal-folder`,reason:E(`newSession.terminalNeedsFolder`)}:xf(n,i,a)}function xf(e,t,n){if(t!==`session`)return;let r=n?e.pendingPlacement.message:e.message.trim(),i=n?!!e.pendingPlacement.attachments?.length:e.attachmentDraft.attachments.length>0;return r||i?void 0:{gate:`empty-draft`}}var Sf;function Cf(){return(Cf=e((()=>{O(),Z(),Tt(),Ls(),Q(),pf(),Pd(),gf(),X(),Sf=new Set([`attachment-reads`,`outcome-unknown`,`worktree-name`])})))()}var wf;function Tf(){return(Tf=e((()=>{O(),Z(),La(),Wt(),k(),Tt(),gr(),Un(),ud(),fd(),Rc(),md(),Q(),yd(),Hi(),xd(),wd(),Ad(),Pd(),Id(),zd(),Hd(),tf(),hl(),uf(),Cf(),gf(),X(),wf=class{updateMessage(e){e!==this.messageText&&(this.messageText=e,this.callbacks.onMessageChange?.(e))}get creationComposer(){return this.creationComposerValue?.canDisplay()?this.creationComposerValue:void 0}constructor(e,t,n,r){this.gateway=e,this.place=t,this.read=n,this.callbacks=r,this.visibilityValue=`normal`,this.messageText=``,this.mentionsValue=[],this.activeSubmission=null,this.blockedSubmitAttempt=!1,this.submissionOutcomeUnknown=null,this.startedSession=new lf,this.backgroundPreview=new dd,this.error=null,this.pendingPlacement=new ml(()=>this.read().context),this.composerDraft=qn(()=>({draft:this.messageText,mentions:this.mentionsValue,attachments:this.attachmentDraft.attachments,pendingAttachmentReads:this.attachmentDraft.reads.pendingReads,attachmentReadRevision:this.attachmentDraft.reads.revision})),this.draftChanged=()=>{this.composerDraft.publish(),this.callbacks.changed()},this.composerTextarea=vd(),this.buildDraftSessionCreateParams=(e={})=>Cd(this.place,{...e,message:e.message??``,toolOverrides:this.capabilities.toolOverrides,permissionMode:this.permissionMode,visibility:e.visibility??this.visibility,catalogId:this.read().data?.catalogId,category:Zc(this.read().data,this.read().context?.sessions)}),this.submissionAccess=(e=this.pendingPlacement.createParams??this.buildDraftSessionCreateParams())=>vf({gateway:this.read().context?.gateway.snapshot,place:this.place,pendingPlacement:this.pendingPlacement,hasInitialTurn:!!(this.messageText.trim()||this.attachmentDraft.attachments.length),createParams:e}),this.submitDisabledReason=()=>this.submitBlock()?.reason,this.canSubmit=()=>this.submitBlock()===void 0,this.requiresModelSetup=()=>yf({snapshot:this.read(),gateway:this.gateway,place:this.place,pendingPlacement:this.pendingPlacement}),this.capabilities=new pd(r.changed,()=>this.startedSession.current=null),this.sessionStartup=new Fd(e,()=>({context:this.read().context,client:this.gateway.client,params:this.buildDraftSessionCreateParams(),access:this.submissionAccess(),changed:this.callbacks.changed})),this.draftPersistence=new kd(()=>({message:this.messageText,mentions:this.mentionsValue,attachments:this.attachmentDraft.attachments,incognito:this.visibilityValue===`incognito`,permissionMode:this.permissionMode}),(e,t)=>this.restoreDraftState({...e,visibility:t?`normal`:this.visibilityValue}),()=>this.setError(Fn())),this.attachmentDraft=new ld(this.draftChanged,()=>{this.startedSession.current=null,this.draftPersistence.noteUserMutation()})}get visibility(){return this.visibilityValue}get message(){return this.messageText}get mentions(){return this.mentionsValue}get submitting(){return this.activeSubmission!==null||this.sessionStartup.active}get pendingMessage(){return this.activeSubmission?.message??this.completedSubmission?.message??null}get completedSubmission(){return this.activeSubmission?null:this.startedSession.submission(this.read().context)}openSubmittedSession(){return this.startedSession.openSubmission(this.read().context,this.completedSubmission,{capture:()=>{let e=this.sessionStartup.captureRequest();return()=>!e.aborted},publish:(e,t)=>{this.activeSubmission=e?{phase:`accepted`,message:e}:null,t!==void 0&&(this.error=t),this.callbacks.changed()}})}synchronizeSubmission(){this.blockedSubmitAttempt=this.blockedSubmitAttempt&&!!this.submitBlock()?.reason;let e=this.sessionStartup.resume();e.kind===`resume`?this.submit(e):e.kind!==`wait`&&(this.activeSubmission=null,this.submissionOutcomeUnknown=`gateway-changed`,this.callbacks.changed())}setMessage(e,t){this.startedSession.current=null,this.mentionsValue=t??li(this.messageText,e,this.mentionsValue),this.updateMessage(e),this.draftPersistence.noteUserMutation(),this.draftChanged()}restoreMessage(e,t=[]){this.draftPersistence.noteDraftReplaced(),this.updateMessage(e),this.mentionsValue=t,this.draftChanged()}restoreDraftState(e){this.draftPersistence.noteDraftReplaced(),this.updateMessage(e.message),this.mentionsValue=e.mentions??[],this.visibilityValue=e.visibility,e.toolOverrides!==void 0&&this.capabilities.setToolOverrides(e.toolOverrides),`permissionMode`in e&&(this.permissionMode=e.permissionMode),this.attachmentDraft.restore(e.attachments)}setPermissionMode(e){this.permissionMode=e,this.startedSession.current=null,this.draftPersistence.noteSelectionMutation(`permission`),this.callbacks.changed()}setVisibility(e){this.startedSession.current=null;let t=this.visibilityValue===`incognito`,n=this.callbacks.changed;this.visibilityValue=e,this.draftPersistence.transitionIncognito(t,e===`incognito`,n)}setError(e){(e!==null||this.error===E(`newSession.cloudRecoveryUnavailable`))&&(this.error=e),this.callbacks.changed()}clearError(e){(e===void 0||this.error===e)&&(this.error=null,this.callbacks.changed())}markPendingPlacementUnavailable(e){this.pendingPlacement.retryAllowed=!1,this.submissionOutcomeUnknown=e,this.callbacks.changed()}noteBlockedSubmitAttempt(){this.blockedSubmitAttempt=!!this.submitBlock()?.reason,this.callbacks.changed()}blockedSubmitNotice(e={}){let t=this.submitBlock();if(t?.gate===`draft-unavailable`)return t.reason;let n=e.includePageRendered||!Sf.has(t?.gate??``);return this.blockedSubmitAttempt&&n?t?.reason:void 0}incognitoDisabledReason(){let e=zn(this.read().context?.gateway.snapshot,{method:`sessions.create`,params:this.buildDraftSessionCreateParams({visibility:`incognito`})});return e.allowed?void 0:e.reason}submitBlock(){return!A(this.read().data)&&this.attachmentDraft.reads.pendingReads===0&&this.startedSession.isCurrent(this.read().context,this.place.agentId)?this.activeSubmission?{gate:`submitting`}:void 0:this.activeSubmission?{gate:`submitting`}:bf(this.gateway,this.place,this,this.read())}invalidate(e=null){this.sessionStartup.clearPreparation(),this.sessionStartup.abortRequest(),this.startedSession.current=null;let t=this.activeSubmission?.phase===`creating`,n=e!==null&&t&&this.sessionStartup.interrupt();(e&&t&&!n||this.sessionStartup.retireChangedOwner())&&(this.submissionOutcomeUnknown=e),n||(this.activeSubmission=null),this.callbacks.changed()}resetDraft(){this.creationComposerValue?.releaseDraft(),this.creationComposerValue=void 0,this.startedSession.clearSubmission(),this.backgroundPreview.clear(),this.sessionStartup.clear(),this.blockedSubmitAttempt=!1;let e=!!this.pendingPlacement.sessionKey;this.invalidate(),this.submissionOutcomeUnknown=e?this.submissionOutcomeUnknown??`placement-interrupted`:null,this.visibilityValue=`normal`,this.capabilities.reset(),this.permissionMode=void 0,this.attachmentDraft.reset(),e?(this.pendingPlacement.restored||(this.pendingPlacement.retryAllowed=!1),this.applyRecoveryDraft(this.pendingPlacement.capture()),this.pendingPlacement.restored=!1):(this.clearPendingPlacementRecovery(),this.draftPersistence.noteDraftReplaced(),this.updateMessage(``),this.mentionsValue=[]),this.clearError(),this.composerDraft.publish()}clearPendingPlacementRecovery(){this.pendingPlacement.clear(),this.submissionOutcomeUnknown=null,this.callbacks.changed()}releasePendingPlacementOwner(){this.pendingPlacement.reset(),this.submissionOutcomeUnknown=null,this.callbacks.changed()}restorePendingPlacementRecovery(e,t){this.applyRecoveryDraft(this.pendingPlacement.restore(e,t))}async submit(e,t=!1){if(!e&&A(this.read().data))return this.startInTerminal();let n=this.pendingPlacement,r=e?.background??(t&&this.visibilityValue!==`draft`),i=this.read().context;if(!i||!e&&!this.canSubmit()){this.noteBlockedSubmitAttempt();return}if(this.blockedSubmitAttempt=!1,!Na(i.config)&&(this.attachmentDraft.attachments.length||n.attachments?.length||e?.params.attachments?.length)){this.error=Si(),this.callbacks.changed();return}let a=Rd(i,this,this.place,e,r);if(!a)return;let o=this.callbacks.takePreparedTitle?.(),s=this.sessionStartup.captureRequest(),c=this.draftPersistence.captureSubmission(),l=this.startedSession.messageForTurn(i,a.agentId,a.turn),u=r?null:l;r&&this.startedSession.clearSubmission();let d=this.startedSession.captureSubmission(i,a.agentId,u,()=>!s.aborted);this.activeSubmission={phase:`creating`,message:u},this.error=null,this.place.browser.close(),this.callbacks.closeTransientUi(),this.callbacks.changed();let f,p;try{let t=this.startedSession.current;if(t&&this.startedSession.isCurrent(i,this.place.agentId)){await this.startedSession.navigate(i,t);return}this.startedSession.current=null,!r&&this.callbacks.retainForHandoff&&(!this.creationComposer||this.creationComposer.acceptedSessionKey)&&(this.creationComposerValue?.releaseDraft(),this.creationComposerValue=new bd(i,a.agentId,this.visibilityValue===`incognito`,this.callbacks.changed)),this.creationComposer&&this.visibilityValue===`incognito`&&(this.creationComposer.incognito=!0);let u=e?null:jd(n,this.place);Ic(i,a.message,!!a.apiAttachments?.length,!e&&!a.pendingPlacement);let m=!this.place.hostedEnvironment&&!e&&!a.pendingPlacement&&!u&&!a.hasInitialTurn?this.place.browser.remoteProject:null;if(m&&!m.projectId&&!this.place.browser.projectId){let e=await a.client.request(`projects.add`,{gitUrl:m.cloneUrl},{timeoutMs:null});if(s.aborted||this.gateway.client!==a.client)return;this.place.browser.recordRemoteProjectId(m.cloneUrl,e.id)}let h=e?.params??this.buildDraftSessionCreateParams({message:a.message,mentions:a.mentions,displayName:o,visibility:this.visibilityValue,attachments:a.draftAttachments}),g=Qd({context:i,params:h,resumed:!!e,enabled:!r&&!u,agentId:a.agentId,retainDraft:this.callbacks.retainForHandoff,message:this.pendingMessage,composer:this.creationComposer}),_=u?a.pendingPlacement?n.createParams:n.stageCreate({agentId:a.agentId,target:u,message:a.message,mentions:a.mentions,attachments:a.apiAttachments,gatewayUrl:a.gatewayUrl,recoveryScope:a.recoveryScope,createParams:h,persistent:this.visibilityValue!==`incognito`}):void 0,v=e?zn(i.gateway.snapshot,{method:`sessions.create`,params:h,sessionScope:!0}):this.submissionAccess(_??h);if(!v.allowed){this.sessionStartup.clear(),this.error=v.reason;return}let y=u?n.capture():null;if(u&&!y){this.error=E(`newSession.placementCreateFailed`);return}a.apiAttachments?.length&&xa(i.config),r&&!u&&this.backgroundPreview.begin({context:i,agentId:a.agentId,params:h,resumed:!!e,message:l,displayName:o,retry:()=>void this.submit(void 0,!0)});let b=this.sessionStartup.create(i,h,{pendingKey:a.pendingPlacement&&n.phase!==`creating`?n.sessionKey:void 0,resumedParams:_??e?.params,background:r,allowPrepared:!u,signal:s});f=g?.();let x=await b;if(x&&!u&&x.initialRun.status!==`rejected`&&(p=a.consumeWorktreeName?.()),s.aborted&&!u){x&&x.initialRun.status!==`rejected`&&await this.clearSubmittedDraft(!0,c,!1);return}if(!x){if(s.aborted)return;this.sessionStartup.clear(),this.error=i.sessions.state.error??E(`newSession.createFailed`),f&&await f.rollback();return}if(u&&y){await Nd({context:i,client:a.client,agentId:a.agentId,pending:n,submittedRecovery:y,sessionKey:x.key,createdAt:a.turn.createdAt,startupError:x.initialRun.status===`rejected`?x.initialRun.error:void 0,isRequestCurrent:()=>!s.aborted,isLifecycleCurrent:()=>this.read().isConnected&&a.client.recoveryScopeReady&&!s.aborted&&this.gateway.client===a.client&&this.gateway.gatewayUrl===a.gatewayUrl&&this.gateway.recoveryScope===a.recoveryScope,clearRecovery:()=>this.clearPendingPlacementRecovery(),setError:e=>this.setError(e),onRecoveryUnavailable:()=>{this.error=E(`newSession.placementStartFailed`,{error:`placement recovery storage is unavailable`})},clearDraft:()=>{let e=this.creationComposer;return e&&(e.accept(x),ga(i,x.key,e)),d(x.key),this.clearSubmittedDraft(!0,c)},consumeWorktreeName:a.consumeWorktreeName,completeInBackground:a.completeInBackground,onAccepted:()=>this.callbacks.onAccepted?.({...x,agentId:a.agentId}),navigate:()=>this.startedSession.navigate(i,{...x,client:a.client,agentId:a.agentId})});return}await Vd({context:i,client:a.client,agentId:a.agentId,result:x,turn:a.turn,instant:f,composer:this.creationComposer,navigation:this.startedSession,isCurrent:()=>!s.aborted,clearDraft:(e,t)=>(t!==!1&&d(x.key,x.initialRun.status===`rejected`?x.initialRun.error:void 0),this.clearSubmittedDraft(e,c,t)),completeInBackground:this.backgroundPreview.admitBefore(a.completeInBackground),onAccepted:()=>this.callbacks.onAccepted?.({...x,agentId:a.agentId}),finishNavigation:()=>this.sessionStartup.clear()})}catch(e){!s.aborted&&this.gateway.client===a.client&&(this.sessionStartup.clear(),this.error=j(e),f&&await f.rollback())}finally{(p||f)&&await Promise.all([p,f?.finish()]),s.aborted||(this.activeSubmission=null,this.callbacks.changed()),this.backgroundPreview.settle(this.error,this.submitting)}}startInTerminal(){return hf({snapshot:this.read(),place:this.place,flow:this,closeTransientUi:this.callbacks.closeTransientUi,capture:e=>{this.blockedSubmitAttempt=!1,this.error=null;let t=this.sessionStartup.captureRequest(),n=this.draftPersistence.captureSubmission(),r=()=>!t.aborted;return{isRequestCurrent:r,isCurrent:()=>r()&&this.gateway.client===e,publish:(e,t)=>{this.activeSubmission=t?{phase:`creating`,message:e}:null,this.callbacks.changed()},consume:()=>(this.startedSession.current=null,this.clearSubmittedDraft(!0,n))}}})}clearSubmittedDraft(e,t,n=!0){return this.draftPersistence.clearSubmittedDraft(t,()=>{n?this.activeSubmission&&(this.activeSubmission.phase=`accepted`):this.activeSubmission=null,this.updateMessage(``),this.mentionsValue=[],this.permissionMode=void 0,this.draftPersistence.noteDraftReplaced(),this.attachmentDraft.clearAfterSubmit(e),this.sessionStartup.clear()})}disconnect(){this.sessionStartup.abortRequest(),this.backgroundPreview.clear(),this.creationComposerValue?.releaseDraft(),this.pendingPlacement.releaseClaim(),this.startedSession.current=null,this.draftPersistence.disconnect(),this.attachmentDraft.reset(),this.composerTextarea.disconnect()}applyRecoveryDraft(e){if(e){let t=Md(e);this.place.applyPendingPlacement(t.placement),this.restoreDraftState(t.draft)}}}})))()}function Ef(e){return Of.has(e)}function Df(e){let t=new Map;for(let n of e){let e=(n.deviceId??n.instanceId)?.trim().toLowerCase();e&&n.roles?.includes(`node`)&&t.set(e,n.reason?.trim().toLowerCase()===`disconnect`?`offline`:`connected`)}return JSON.stringify([...t].toSorted(([e],[t])=>e.localeCompare(t)))}var Of;function kf(){return(kf=e((()=>{Of=new Set([`config.changed`,`node.pair.requested`,`node.pair.resolved`,`node.runnerInventory.changed`,`device.pair.requested`,`device.pair.resolved`])})))()}var Af;function jf(){return(jf=e((()=>{o(),Kn(),sr(),O(),Lr(),dr(),Q(),vl(),Rl(),cd(),Tf(),kf(),Af=class{protectPrivateDraftFromReload(){let e=()=>this.submission.visibility===`incognito`&&!!(this.submission.message||this.submission.mentions.length||this.submission.attachmentDraft.attachments.length||this.submission.attachmentDraft.reads.pendingReads),t=(e=!1)=>Ai({severity:`error`,actionPrimary:!0,message:E(e?`chat.privateDraftReload.changed`:`chat.privateDraftReload.blocked`),actionLabel:E(`chat.privateDraftReload.review`),onAction:()=>void n()}),n=async()=>{let n=this.read().context;if(!n||!this.read().isConnected||!e()||this.privateDraftReview)return;let r=new AbortController,i=n.gateway.snapshot.client,a=n.gateway.connection,o=this.submission.message,s=this.submission.mentions,c=[...this.submission.attachmentDraft.attachments],l=this.submission.attachmentDraft.reads.pendingReads,u=()=>!r.signal.aborted&&this.read().isConnected&&this.read().context===n&&n.gateway.snapshot.client===i&&n.gateway.connection===a,d=()=>u()&&this.submission.visibility===`incognito`&&this.submission.message===o&&this.submission.mentions===s&&this.submission.attachmentDraft.reads.pendingReads===l&&this.submission.attachmentDraft.attachments.length===c.length&&c.every((e,t)=>this.submission.attachmentDraft.attachments[t]===e);this.privateDraftReview={controller:r,isCurrent:d};let f=Vr(n.gateway);try{let n=await mn({text:o,attachments:c,hasGoal:!1,pendingReads:l,isCurrent:d,signal:r.signal});if(!d()){u()&&e()&&t(!0);return}if(!n)return;this.submission.attachmentDraft.reset(),this.submission.setMessage(``,[]),await Ve({timeoutMs:0,...f})}catch{u()&&Ai({severity:`error`,message:E(`chat.privateDraftReload.unavailable`)})}finally{this.privateDraftReview?.controller===r&&(this.privateDraftReview=void 0),r.signal.reason===`draft-changed`&&this.read().isConnected&&this.read().context===n&&n.gateway.connection===a&&n.gateway.snapshot.client===i&&e()&&t(!0)}},r=re(()=>!e(),()=>t());return()=>{r(),this.privateDraftReview?.controller.abort()}}constructor(e,t){this.read=e;let n=this.changed=()=>{this.privateDraftReview&&!this.privateDraftReview.isCurrent()&&this.privateDraftReview.controller.abort(`draft-changed`),t.changed()};this.gateway=new _l(()=>({...e(),isAdmin:this.place?.isAdmin()??!1,cloudProfileId:this.place?.cloudProfileId??``,pendingPlacement:this.submission?.pendingPlacement??{sessionKey:``,gatewayUrl:``,recoveryScope:``},agentsHydrated:this.place?.agentsHydrated??!1,runtimeId:this.place?.devicePlacementRuntime()?.id??``}),{preferenceScope:t.preferenceScope,readPalettePreference:t.readPalettePreference,readAgents:()=>e().context?.agents,changed:n,updateComplete:t.updateComplete,onInvalidate:(e,n)=>{this.invalidate(e,n),t.onInvalidate()},onCloudProfileCleared:()=>this.place.clearCloudProfile(),onCloudState:e=>this.submission.setError(e),onPendingPlacementReset:()=>this.submission.releasePendingPlacementOwner(),onRecoveryReady:t.onRecoveryReady,onAdoptAgentDefaults:()=>this.place.adoptAgentDefaults({preserveSelectedAgent:!0,preserveSelectedFolder:!0})}),this.browser=new Ll(this.gateway,()=>({context:e().context,isAdmin:this.place?.isAdmin()??!1}),{changed:n,updateComplete:t.updateComplete,onProjectMissing:()=>this.place.clearProjectSelection(),onSelectProject:e=>this.place.selectProjectId(e),onApprovedListing:e=>this.place.recordGatewayApprovedListing(e),activeElement:t.activeElement}),this.place=new sd(this.gateway,this.browser,()=>({context:e().context,data:e().data,submitting:this.submission?.submitting??!1,pendingPlacementSessionKey:this.submission?.pendingPlacement.sessionKey??``}),{changed:n,onError:e=>e===null?this.submission.clearError():this.submission.setError(e),onClearError:e=>this.submission.clearError(e)}),this.submission=new wf(this.gateway,this.place,e,{...t,changed:n}),this.submission.draftPersistence.modelSelection={read:()=>this.place.modelControl.modelDefaultsPolicy===`configured`?this.place.modelControl.draftSelection(this.place.agentId):void 0,restore:e=>this.place.modelControl.restoreDraftSelection(e),retire:()=>{this.place.modelControl.modelDefaultsPolicy===`configured`&&this.place.modelControl.retireDraftSelection()}},this.place.modelControl.onDraftSelectionChange=()=>{this.place.modelControl.modelDefaultsPolicy===`configured`&&this.submission.draftPersistence.noteSelectionMutation(`model`)}}connect(){if(!this.stopLifetime){let e=this.protectPrivateDraftFromReload(),t=w(document,`visibilitychange`,()=>{this.synchronize(),this.changed()});this.stopLifetime=()=>{t(),e()}}this.synchronize()}synchronize(){if(!this.stopLifetime)return;let e=this.read().context?.gateway;if(e!==this.boundGateway&&(this.stopGateway?.(),this.stopGateway=void 0,this.boundGateway=e,e)){let t=e.subscribe(()=>{this.read().context?.gateway===e&&this.gateway.synchronize(e)}),n=Df(rn(e.snapshot.hello?.snapshot)??[]),r=e.subscribeEvents(t=>{if(this.read().context?.gateway!==e)return;let r=t.event===`presence`?rn(t.payload):null,i=r?Df(r):n;(Ef(t.event)||i!==n)&&(n=i,this.gateway.refreshCloudProfiles(),this.gateway.handleCatalogRetry())});this.stopGateway=()=>{t(),r()},this.gateway.synchronize(e)}this.gateway.synchronizeMetadata(),this.browser.synchronize()}agentsReady(){let e=this.read().context?.agents.state;return!!(this.gateway.connected&&this.gateway.client&&e?.connected&&!e.agentsLoading&&!e.agentsError&&e.client===this.gateway.client&&this.place.agents().length>0)}synchronizeSelections(){let e=this.place.requiredPlacement?`configured`:this.read().context?.config?.current.newSessionModelDefaults;if(!this.place.agentsHydrated&&this.agentsReady())this.place.agentsHydrated=!0,this.place.adoptAgentDefaults({preserveSelectedAgent:!0,preserveSelectedFolder:!0});else if(this.place.agentsHydrated&&e!==this.modelDefaultsPolicy){let{context:e,data:t}=this.read();this.place.modelControl.load(e,this.place.agentId,!A(t),{agent:this.place.selectedAgent(),preference:this.gateway.readPreference(this.place.agentId),configuredDefaults:this.place.requiredPlacement})}this.place.modelControl.modelDefaultsPolicy===`configured`&&this.modelDefaultsPolicy!==`configured`&&!this.submission.submitting&&this.place.modelControl.draftSelection(this.place.agentId)&&this.submission.draftPersistence.noteSelectionMutation(`model`),this.modelDefaultsPolicy=this.place.modelControl.modelDefaultsPolicy,this.place.restorePreferenceSelections(),this.place.synchronizeTerminalHosts()}invalidate(e,t){this.place.invalidateGatewayDiscovery(e),this.submission.attachmentDraft.reads.abortReads(),this.submission.invalidate(t),e&&this.submission.pendingPlacement.sessionKey&&this.submission.markPendingPlacementUnavailable(t),e&&this.submission.clearError()}disconnect(){this.stopLifetime?.(),this.stopLifetime=void 0,this.stopGateway?.(),this.stopGateway=void 0,this.boundGateway=void 0,this.gateway.invalidateDiscovery(!0,this.submission.pendingPlacement.sessionKey?`placement-interrupted`:`gateway-changed`),this.gateway.disconnect(),this.browser.disconnect(),this.submission.disconnect()}}})))()}function Mf(e){let t=e.context?.gateway,n=t?.snapshot.client,r=t?.snapshot.selfUser?.identity;if(n&&t?.snapshot.phase===`connected`&&r?.type===`profile`&&zn(t.snapshot,{method:`sessions.create`,sessionScope:!0}).allowed&&!e.isCatalogTarget&&!e.nativeTerminal&&e.visibility!==`incognito`)return{client:n,ownerKey:JSON.stringify([t.connectionRevision,n.recoveryScope,r.id,e.draftOwnerKey]),params:{agentId:e.agentId,...e.visibility===`draft`?{visibility:`draft`}:{}}}}function Nf(){return(Nf=e((()=>{Tt()})))()}function Pf(e){return U(L,{get when(){return e.open},get children(){var t=Ff(),n=t.firstChild,r=n.firstChild,i=r.nextSibling;return t.addEventListener(`modal-cancel`,()=>e.onClose()),t._$owner=wo(),z(n,U(Rs,{get title(){return N(`newSession.connectMachineTitle`)},get description(){var e=If();return z(e,()=>N(`newSession.connectMachineDescription`)),e},onClose:()=>e.onClose()}),r),z(n,U(To,{fallback:(e,t)=>(()=>{var n=Lf();return z(n,U(Ta,{get error(){return e()},onRetry:()=>t(),inline:!0})),n})(),get children(){return U(Io,{get fallback(){var e=Rf(),t=e.firstChild;return z(t,()=>N(`newSession.connectMachineGenerating`)),e},get children(){return U(zf,e)}})}}),i),W(()=>({e:N(`newSession.connectMachineTitle`),t:N(`newSession.connectMachineDescription`)}),({e,t:n},r)=>{e!==r?.e&&V(t,`label`,e),n!==r?.t&&V(t,`description`,n)}),t}})}var Ff,If,Lf,Rf,zf;function Bf(){return(Bf=e((()=>{K(),R(),zo(),Vs(),ua(),M(),r(),Ff=q(`<openclaw-modal-dialog class=connect-machine-dialog><section class=oc-dialog><!><!>`,1),If=q(`<p>`),Lf=q(`<div class="oc-dialog__body connect-machine-dialog__body">`),Rf=q(`<div class="oc-dialog__body connect-machine-dialog__body"><p class=connect-machine-dialog__status role=status>`),zf=Oo(()=>v(()=>import(`./connect-machine-dialog-content-C5BHJ0Z0.js`),__vite__mapDeps([11,0,3]),import.meta.url),{export:`ConnectMachineDialogContent`},`src/pages/new-session/connect-machine-dialog-content.tsx`)})))()}function Vf(e){let t=I(()=>e.identity),n=I(()=>(e.read(),!0));return U(To,{fallback:()=>e.children(),get children(){return U(Io,{get on(){return t()},get fallback(){return e.children()},get children(){return B(()=>!!n())()?e.children():void 0}})}})}function Hf(e){let t=I(()=>e.control),n=I(()=>e.options.agent),r=I(()=>e.options.agentId),i=I(()=>e.options.context),a=I(()=>e.options.sending),o=I(()=>an({control:t(),context:i()},{read:()=>void 0,equality:`revision`,subscribe:({control:e,context:t},n)=>{let r=(t?[e,t.gateway,t.agents,t.config]:[e]).map(e=>e.subscribe(n));return()=>r.forEach(e=>e())}})),s=I(()=>an(i(),{read:e=>Object.entries(e?.sessions.state.result?.defaults??{}),equality:(e,t)=>e.length===t.length&&e.every(([e,n],r)=>e===t[r]?.[0]&&n===t[r]?.[1]),subscribe:(e,t)=>e?.sessions.subscribe(t)??(()=>{})})),c=I(()=>(o().revision(),{promise:t().metadataRead,scope:t().metadataReadScope}),{equals:(e,t)=>e.promise===t.promise&&e.scope===t.scope}),l=I(()=>c().promise),u=I(()=>(o().revision(),s().revision(),t().renderProps({agent:n(),agentId:r(),context:i(),sending:a()})));return U(ur,bo(u,{get showEffort(){return e.showEffort},renderModelCatalogStatus:e=>U(Vf,{read:l,get identity(){return c()},children:e})}))}function Uf(){return(Uf=e((()=>{K(),R(),Rn(),Za()})))()}function Wf(e,t,n=t.cloudProfiles){return{hostedEnvironment:e.hostedEnvironment?{...e.hostedEnvironment,id:e.modelControl.resolveAgentRuntime().id}:void 0,environments:e.canWrite()?t.environments:[],cloudProfiles:n,cloudProfileId:e.cloudProfileId,...e.cloudSelection,deviceId:e.deviceId,autoDevice:e.autoDevice,devicePlacement:Hu(e.modelControl)?.devicePlacement,deviceDisabledReason:Uu(e.modelControl)??t.deviceCatalogDisabledReason}}function Gf(e){let t=Xl(e.environments,e.devicePlacement,e.deviceDisabledReason),n=Zl(e.environments,t,e.deviceDisabledReason),r=t.find(t=>t.deviceId===e.deviceId),i=e.cloudProfiles.find(t=>t.id===e.cloudProfileId),a={devices:t,cloudProfiles:e.cloudProfiles,cloudMachines:[],selectedMachineId:``,operatingSystems:[],selectedOsId:``,autoDeviceDisabledReason:n};if(e.hostedEnvironment)return{...a,kind:`hosted`,label:e.hostedEnvironment.label,hostedRuntimeId:e.hostedEnvironment.id};if(e.cloudProfileId){let t=i?iu(i):``,n=e.os||t,r=i?.operatingSystems??[],o=i?au(i,n):[],s=i?ou(i,n):void 0,c=e.machineClass?o.find(t=>t.id===e.machineClass):s;return{...a,kind:`cloud`,label:i?.id??e.cloudProfileId,operatingSystems:r,selectedOsId:n,cloudMachines:o,selectedMachineId:c?.id??``}}return{...a,kind:e.deviceId?`device`:e.autoDevice?`auto-device`:`local`,label:e.deviceId?r?.label??e.deviceId:E(e.autoDevice?`newSession.autoDevice`:`newSession.local`)}}function Kf(){return(Kf=e((()=>{O(),Z(),nu(),Gu(),X()})))()}function qf(e,t,n,r,i){let a=I(()=>{n();let r=e();return{owner:r,retired:t(r)}},{equals:(e,t)=>e.owner===t.owner&&e.retired===t.retired}),o=I(()=>{let e=a(),[t,n]=yo(!1);return{...e,saving:t,setSaving:n}}),s=n=>e()===n.owner&&t(n.owner)===n.retired,c=Ro(function*(e,t){s(e)&&(e.setSaving(!0),po(r)),yield Promise.race([t,e.retired]),s(e)&&(yield ko(r))});return{saving:()=>o().saving(),submit:e=>{let t=o(),n=e();return Promise.resolve().then(()=>c(t,n)).catch(e=>{s(t)&&i(t.owner,e)}),n}}}function Jf(e,t,n,r){let{saving:i,submit:a}=qf(e,e=>e.submissionLifetime,t,n,(e,t)=>r(t));return H(()=>{let t=e();return t.presentSubmit=a,()=>{t.presentSubmit===a&&(t.presentSubmit=void 0)}}),i}function Yf(){return(Yf=e((()=>{R()})))()}function Xf(){let e=vo(),t=new Set,n=0,r,i,a=e=>!e.matches(`:disabled, [aria-disabled="true"]`)&&e.checkVisibility(),o=t=>{i?.removeAttribute(`data-highlighted`),i=t,t?(t.id||=`${e}-option-${encodeURIComponent(t.dataset.value??`row-${n++}`)}`,t.setAttribute(`data-highlighted`,``),r?.setAttribute(`aria-owns`,t.id),r?.setAttribute(`aria-activedescendant`,t.id)):(r?.removeAttribute(`aria-activedescendant`),r?.removeAttribute(`aria-owns`))};return{inputRef(e){r=e,o()},clear:()=>o(),register(e){t.add(e)},remove(e){t.delete(e),i===e&&o()},hover(e){a(e)&&o(e)},keydown(e){if(Pa(e)||e.key!==`Enter`&&e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return!1;let n=[...t].filter(a).toSorted((e,t)=>e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),r=i?n.indexOf(i):-1;if(e.key===`Enter`&&r>=0)return e.preventDefault(),i.click(),!0;if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return!1;e.preventDefault();let s=e.key===`ArrowDown`?1:-1,c=n[r<0?s===1?0:n.length-1:Math.max(0,Math.min(n.length-1,r+s))];return o(c),c?.scrollIntoView({block:`nearest`}),!0}}}function Zf(){let e=xo(Qf);if(!e)return()=>{};let t,n=lt(`pointermove`,()=>e.hover(t));return H(()=>()=>e.remove(t)),r=>{t=r,e.register(t),n(t)}}var Qf;function $f(){return($f=e((()=>{R(),Ci(),An(),Qf=So(null)})))()}function ep(e){let t=e.kind===`checkout`?null:Xf(),n,r,i;return H(()=>()=>i?.()),[(()=>{var t=ip(),i=t.firstChild,a=i.firstChild,o=a.nextSibling,s=o.nextSibling,c=s.nextSibling;return Lo(i,[{get"aria-label"(){return e.label}},()=>e.triggerAttributes,{get id(){return`new-session-${e.kind}-trigger`},type:`button`,class:`new-session-page__trigger`,"aria-haspopup":`dialog`,get"aria-controls"(){return`new-session-${e.kind}-popover`},get"aria-expanded"(){return e.params.place.browser.popoverOpen(e.kind)?`true`:`false`},get disabled(){return e.params.submitting||e.params.pendingPlacement||e.kind===`where`&&e.params.place.suggestedCloudProfile.pending},onClick:()=>r.overlay.request(!r.overlay.open)}],!0),G(()=>e=>{n=e},i),z(a,()=>e.icon),z(o,()=>e.value),z(i,(()=>{var t=B(()=>!!e.summary);return()=>t()?[` `,(()=>{var t=op();return z(t,()=>e.summary),t})()]:void 0})(),s),z(i,U(P,{name:`chevronsUpDown`,class:`new-session-page__picker-chevron`}),c),W(()=>({e:e.kind===`where`,t:e.kind===`project`,a:e.kind===`checkout`}),({e,t:n,a:r},i)=>{e!==i?.e&&t.classList.toggle(`new-session-page__select--where`,e),n!==i?.t&&t.classList.toggle(`new-session-page__select--project`,n),r!==i?.a&&t.classList.toggle(`new-session-page__select--checkout`,r)}),t})(),U(jt,{sameRoot:!0,get lazy(){return e.lazy},get onBeforeShow(){return e.onBeforeShow},get id(){return`new-session-${e.kind}-popover`},get label(){return e.label},anchor:n,get class(){return[`new-session-page__select`,`new-session-page__${e.kind}-popover`,`new-session-page__picker-popover`]},get open(){return e.params.place.browser.popoverOpen(e.kind)},placement:`bottom-start`,onOpenChange:n=>{n||t?.clear(),e.params.place.browser.popoverCallbacks(e.kind)[n?`onPopoverShow`:`onPopoverHide`]()},ref:t=>{r=t;let a=t.overlay.surface,o=[w(a,`overlay-after-hide`,t=>{if(t.target===a){let t=a.ownerDocument.activeElement;(!t||t===a.ownerDocument.body||a.contains(t))&&n.focus(),e.params.place.browser.popoverCallbacks(e.kind).onPopoverAfterHide(),e.onAfterHide?.()}}),w(a,`click`,e=>{!e.defaultPrevented&&e.target instanceof Element&&e.target.closest(`[data-popover="close"]`)&&t.overlay.request(!1,`return`)})];i=()=>o.forEach(e=>e()),e.ref?.(t)},get children(){var n=ap();return z(n,U(To,{fallback:(t,n)=>U(tp,{get error(){return t()},retry:n,isOpen:()=>e.params.place.browser.popoverOpen(e.kind)}),get children(){return U(Io,{get fallback(){return U(rp,{})},get children(){return U(Qf,{value:t,get children(){return e.children}})}})}})),n}})]}function tp(e){let t=!0;H(()=>()=>{t=!1});let n=async()=>{let n=qa(e.error)&&await Ve({canReload:()=>t&&e.isOpen()});t&&e.isOpen()&&!n&&e.retry()};return U(Ta,{get error(){return e.error},get stale(){return qa(e.error)},onRetry:()=>void n(),inline:!0})}function np(e,t){return io((e,t)=>{e.toggleAttribute(`data-fade-start`,!t.atStart),e.toggleAttribute(`data-fade-end`,!t.atEnd)},{presented:e,content:t})}function rp(e){var t=sp(),n=t.firstChild;return z(n,()=>N(`common.loading`)),z(t,U(go,{get each(){return B(()=>!!e.tray)()?e.checkout?[112,84,72]:[112,84]:[148,116,132]},keyed:e=>e,children:(e,t)=>(()=>{var n=cp(),r=n.firstChild.nextSibling;return W(()=>({e:`${t()*90}ms`,t:`${e()}px`}),({e,t},i)=>{e!==i?.e&&Fo(n,`animation-delay`,e),t!==i?.t&&Fo(r,`width`,t)}),n})()}),null),W(()=>({e:!!e.tray,t:!!e.section,a:e.section}),({e,t:n,a:r},i)=>{e!==i?.e&&t.classList.toggle(`new-session-page__skeletons--tray`,e),n!==i?.t&&t.classList.toggle(`new-session-page__environment-skeletons`,n),r!==i?.a&&V(t,`data-section`,r)}),t}var ip,ap,op,sp,cp;function lp(){return(lp=e((()=>{K(),R(),sr(),F(),ua(),la(),M(),pr(),$f(),ip=q(`<span class=new-session-page__select><button><span class=new-session-page__target-icon aria-hidden=true></span><span class=new-session-page__trigger-label></span><!><!>`),ap=q(`<div class=new-session-page__picker-panel>`),op=q(`<span class=new-session-page__trigger-summary>`),sp=q(`<div class=new-session-page__skeletons><span class=sr-only role=status>`),cp=q(`<span class=new-session-page__skeleton-row aria-hidden=true><span class=new-session-page__skeleton-icon></span><span class=new-session-page__skeleton-bar>`)})))()}function up(e){let t=I(()=>{let t=e.params.place,n=t.cloudProfileId?`cloud`:t.remotePlacement?`remote`:`local`,r=t.worktreeName.trim();if(t.worktree&&!t.remoteRepository&&r)return N(`newSession.checkoutWorktreeNamed`,{name:r});if(n!==`cloud`&&!t.remoteRepository&&!t.worktree)return(t.repository.kind===`git`?t.repository.headBranch:void 0)||N(`newSession.checkoutCurrent`);let i=n===`cloud`?[`newSession.checkoutCloud`,`newSession.checkoutCloudFrom`]:t.remoteRepository?[`newSession.checkoutRepository`,`newSession.checkoutRepositoryFrom`]:[`newSession.checkoutWorktree`,`newSession.checkoutWorktreeFrom`];return t.baseRef?N(i[1],{branch:t.baseRef}):N(i[0])}),n,r=!1;return U(ep,{lazy:!0,kind:`checkout`,get label(){return`${N(`newSession.checkout`)}: ${t()}`},get value(){return t()},get icon(){return U(P,{name:`gitBranch`})},get triggerAttributes(){return{title:`${N(`newSession.checkout`)}: ${t()}`,"data-worktree":String(e.params.place.worktree)}},get params(){return e.params},ref:e=>{n=e},onAfterHide:()=>{r&&(r=!1,e.params.onFocusComposer())},get children(){return U(dp,{get params(){return e.params},get folderLabel(){return e.folderLabel},onClose:()=>n.hide(),onConfirm:()=>{n.hide()&&(r=!0)}})}})}var dp;function fp(){return(fp=e((()=>{K(),R(),F(),Z(),M(),lp(),r(),X(),dp=Oo(()=>v(()=>import(`./checkout-picker-content-BBpDSG-w.js`),__vite__mapDeps([12,0,3]),import.meta.url),{export:`CheckoutPickerContent`},`src/pages/new-session/checkout-picker-content.tsx`)})))()}function pp(e){let t=()=>{let t=e.params.place.deviceFolder;return t?Pt(t.path.trim())||N(`newSession.deviceFolder`):e.state.label};return U(ep,{lazy:!0,kind:`project`,get label(){return`${N(`newSession.what`)}: ${t()}`},get value(){return t()},get icon(){return U(P,{get name(){return e.params.place.browser.projectId||e.params.place.browser.remoteProject?`book`:`folder`}})},get triggerAttributes(){return{"data-project-id":e.params.place.browser.projectId||void 0}},get params(){return e.params},get children(){return U(mp,{get params(){return e.params},get state(){return e.state},get nativeTerminal(){return e.nativeTerminal},get focus(){return e.focus}})}})}var mp;function hp(){return(hp=e((()=>{K(),R(),F(),M(),lp(),r(),mp=Oo(()=>v(()=>import(`./project-picker-content-BbhoFMgx.js`),__vite__mapDeps([13,12,0,3]),import.meta.url),{export:`ProjectPickerContent`},`src/pages/new-session/project-picker-content.tsx`)})))()}function gp(e){let t=gn(()=>e.params.hostId),n=()=>!e.params.hosts||e.params.hosts.length===1&&e.params.hosts[0]?.hostId===e.params.hostId;return B(()=>B(()=>!!n())()?void 0:B(()=>!e.params.hosts?.length)()?(()=>{var t=_p();return G(()=>t=>e.ref?.(t),t),z(t,()=>N(`newSession.nativeHostsUnavailable`)),t})():(()=>{var n=vp(),r=n.firstChild,i=r.nextSibling,a=i.firstChild,o=a.nextSibling;return G(()=>t=>e.ref?.(t),n),z(r,()=>N(`newSession.where`)),i.addEventListener(`change`,t=>e.params.onSelect(t.currentTarget.value)),G(()=>t,i),z(i,(()=>{var t=B(()=>!e.params.hosts?.some(t=>t.hostId===e.params.hostId));return()=>t()?(()=>{var t=yp();return z(t,()=>N(`newSession.chooseNativeHost`)),W(()=>e.params.hostId,e=>{t.value=e}),t})():void 0})(),a),z(i,U(go,{get each(){return e.params.hosts},keyed:e=>e.hostId,children:t=>(()=>{var n=bp();return z(n,()=>t().label),W(()=>({e:t().hostId,t:t().hostId===e.params.hostId}),({e,t},r)=>{n.value=e,n.selected=t}),n})()}),o),W(()=>({e:N(`newSession.where`),t:e.params.submitting}),({e,t},n)=>{e!==n?.e&&V(i,`aria-label`,e),t!==n?.t&&V(i,`disabled`,t)}),n})())}var _p,vp,yp,bp;function xp(){return(xp=e((()=>{K(),R(),M(),$a(),_p=q(`<span class=new-session-page__catalog-unavailable role=status>`),vp=q(`<div class="new-session-page__select new-session-page__menu-field"><span></span><select class=new-session-page__trigger><!><!>`),yp=q(`<option selected disabled>`),bp=q(`<option>`)})))()}function Sp(){return U($r,{get children(){return[Tp(),Ep()]}})}function Cp(e){return U($r,{get children(){return B(()=>e.form===`laptop`)()?[Dp(),Op()]:B(()=>e.form===`mini`)()?[kp(),Ap()]:[jp(),Mp()]}})}function wp(e){let t=()=>{let t=e.device?.platform?.trim();if(t&&!/^(?:darwin|macos|mac os(?: x)?)\b/i.test(t))return;let n=ds(e.device?.label);return n===`laptop`||n===`mini`||n===`studio`?n:void 0};return U(L,{get when(){return t()},get fallback(){return U(P,{name:`monitor`})},children:e=>(()=>{var t=Np();return z(t,U(Cp,{get form(){return e()}})),W(()=>e(),e=>{V(t,`data-form`,e)}),t})()})}var Tp,Ep,Dp,Op,kp,Ap,jp,Mp,Np;function Pp(){return(Pp=e((()=>{K(),R(),F(),$n(),$o(),Tp=q(`<svg><rect x=2 y=7 width=14 height=11></svg>`,2),Ep=q(`<svg><path d="M6 7V3h16v12h-6M6 22h6M9 18v4"></svg>`,2),Dp=q(`<svg><path d="M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z"></svg>`,2),Op=q(`<svg><path d="M20.054 15.987H3.946"></svg>`,2),kp=q(`<svg><path d="M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"></svg>`,2),Ap=q(`<svg><path d="M21.946 12.013H2.054M6 16h.01M10 16h.01"></svg>`,2),jp=q(`<svg><path d="m3 8 3-4h12l3 4v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z"></svg>`,2),Mp=q(`<svg><path d="M3 8h18M6 15h2M11 15h2M17 15h.01"></svg>`,2),Np=q(`<span class=new-session-page__device-icon>`)})))()}function Fp(e){let t=I(()=>e.state.kind),n=I(()=>t()===`hosted`?U(P,{name:`cloud`}):t()===`cloud`?U(ts,{get profile(){return e.state.cloudProfiles.find(t=>t.id===e.params.place.cloudProfileId)}}):t()===`local`?U(P,{name:`home`}):t()===`auto-device`?U(Sp,{}):U(wp,{get device(){return e.state.devices.find(t=>t.deviceId===e.params.place.deviceId)}})),r=I(()=>{let t=e.params.place.cloudSelection,n=rs(e.state.cloudProfiles.find(t=>t.id===e.params.place.cloudProfileId)),r=e.params.gateway.gatewayName.trim()||N(`newSession.local`);return{cloudSelection:t,cloudPresentation:n,label:e.state.kind===`local`?r:e.state.label,configurationSummary:e.state.kind===`cloud`?[e.state.operatingSystems.find(t=>t.id===e.state.selectedOsId)?.label,e.state.cloudMachines.find(t=>t.id===e.state.selectedMachineId)?.label].filter(Boolean).join(` · `):``}});return U(ep,{lazy:!0,ref(t){var n=e.ref;typeof n==`function`||Array.isArray(n)?Ao(n,t):e.ref=t},kind:`where`,get label(){return`${N(`newSession.where`)}: ${r().label}`},get value(){return r().label},get icon(){return n()},get summary(){return r().configurationSummary},get triggerAttributes(){return{"aria-label":`${N(`newSession.where`)}: ${r().label}${r().configurationSummary?`, ${r().configurationSummary}`:``}`,"aria-description":e.state.kind===`cloud`&&r().cloudPresentation.label?N(`newSession.cloudWorkerProvider`,{provider:r().cloudPresentation.label}):void 0,"data-cloud-profile":e.params.place.cloudProfileId||void 0,"data-hosted-runtime":e.state.hostedRuntimeId||void 0,"data-machine-class":r().cloudSelection.machineClass||void 0,"data-os":r().cloudSelection.os||void 0,"data-device-id":e.params.place.deviceId||void 0,"data-auto-device":e.params.place.autoDevice?`true`:void 0}},get params(){return e.params},get children(){return U(Ip,{get params(){return e.params},get state(){return e.state}})}})}var Ip;function Lp(){return(Lp=e((()=>{K(),R(),ns(),ss(),F(),M(),lp(),Pp(),r(),Ip=Oo(()=>v(()=>import(`./where-picker-content-B_f4jx4b.js`),__vite__mapDeps([12,0,3]),import.meta.url),{export:`WherePickerContent`},`src/pages/new-session/where-picker-content.tsx`)})))()}function Rp(){let e=Fi(`(max-width: 768px)`),t=Fi(`(prefers-reduced-motion: no-preference)`);return B(()=>B(()=>!!e())()?(()=>{var e=Hp(),n=e.firstChild,r=n.firstChild,i=r.nextSibling;return z(r,U(P,{name:`gitBranch`})),W(()=>({e:N(`common.loading`),t:t()?`new-session-placeholder-pulse 1.4s ease-in-out infinite`:void 0}),({e,t},r)=>{e!==r?.e&&V(n,`aria-label`,e),t!==r?.t&&Fo(i,`animation`,t)}),e})():void 0)}function zp(e){var t=Up(),n=t.firstChild,r=e.ref;return typeof r==`function`||Array.isArray(r)?G(()=>r,t):e.ref=t,G(()=>t=>{t.focusTargetsRef=e.focusTargetsRef},n),n._$owner=wo(),W(()=>({e:e.params.variant??`compact`,t:e.params.identityTargetsRef,a:e.params.onIdentityTargetsChange,o:e.params.agents.map(t=>({value:D(t.id),label:Ur(t,e.params.agentIdentity?.get(t.id)),agent:t})),i:Object.fromEntries(e.params.agents.flatMap(t=>{let n=e.params.agentIdentity?.get(t.id);return n?[[t.id,n]]:[]})),n:D(e.params.agentId),s:N(`newSession.agent`),h:N(`newSession.agents`),r:e.params.disabled,d:e.params.onSelect}),({e,t,a:r,o:i,i:a,n:o,s,h:c,r:l,d:u},d)=>{e!==d?.e&&(n.variant=e),t!==d?.t&&(n.identityTargetsRef=t),r!==d?.a&&(n.onIdentityTargetsChange=r),i!==d?.o&&(n.options=i),a!==d?.i&&(n.identityById=a),o!==d?.n&&(n.value=o),s!==d?.s&&(n.accessibleLabel=s),c!==d?.h&&(n.menuLabel=c),l!==d?.r&&(n.disabled=l),u!==d?.d&&(n.onSelect=u)}),t}function Bp(e){let t=()=>e.gateway.cloudProfiles.find(t=>t.id===e.gateway.requiredProfile),n=I(()=>({promise:e.gateway.cloudProfilesRead}),{equals:(e,t)=>e.promise===t.promise}),r=I(()=>n().promise?.then(()=>null));var i=Wp(),a=i.firstChild,o=a.nextSibling;return G(()=>t=>e.ref?.(t),i),z(i,(()=>{var n=B(()=>!e.gateway.placementPolicyReady);return()=>n()?N(`newSession.placementNotReady`):B(()=>!t())()?N(`newSession.requiredWorkerUnavailable`):N(t()?.inference===`worker`?`newSession.openClawWorker`:`newSession.requiredWorker`)})(),a),z(i,U(Io,{get on(){return n()},get children(){return[B(()=>r()),B(()=>B(()=>!(e.gateway.placementPolicyReady&&t()))()?(()=>{var t=Gp();t._$$click=()=>void e.gateway.retryRequiredPlacement();var n=e.retryRef;return typeof n==`function`||Array.isArray(n)?G(()=>n,t):e.retryRef=t,z(t,()=>N(`common.retry`)),t})():void 0)]}}),o),i}function Vp(e){let t,n,r,i,a;H(()=>{e.ref?.(()=>[t,n,r?.overlay.trigger?.parentElement??void 0,r?.overlay.surface,i,a].filter(e=>e?.isConnected===!0))});let o=gn(()=>e.params.place.folder),s=gn(()=>e.params.place.deviceFolder?.path??``),c=I(()=>{let{context:t,data:n,gateway:r,place:i}=e.params,a=i.browser,o=A(n),s=o?[]:r.cloudProfiles,c=o?[]:a.projects,l=o?[]:a.resolveProjectRecents({sessions:t?.sessions.state.result?.sessions??[],workspace:i.workspacePath(),workspaceRoots:i.knownWorkspaceRoots(),isAdmin:i.isAdmin()});return{nativeTerminal:o,browser:a,whereState:Gf(Wf(i,r,s)),projectState:Fl({folder:i.deviceFolder?.path??i.folder,workspace:i.workspacePath(),projectId:a.projectId,selectedRemoteProject:a.remoteProject,projects:c,recents:l,projectQuery:a.projectQuery,freshWorkspace:i.freshWorkspace})}});return[B(()=>B(()=>!!e.params.place.requiredPlacement)()?U(Bp,{get gateway(){return e.params.gateway},ref:e=>{t=e}}):[B(()=>B(()=>!!c().nativeTerminal)()?U(gp,{ref:e=>{n=e},get params(){return{hosts:e.params.data?.terminalHosts,hostId:e.params.place.terminalHostId,submitting:e.params.submitting,onSelect:t=>e.params.place.selectTerminalHost(t)}}}):U(Fp,{get params(){return e.params},get state(){return c().whereState},ref:e=>{r=e}})),(()=>{var t=Kp(),n=t.firstChild,r=n.nextSibling;return G(()=>e=>{i=e},t),z(t,(()=>{var t=B(()=>!!e.params.place.hostedEnvironment);return()=>t()?(()=>{var e=qp();return z(e,()=>N(`newSession.hostedWorkspace`)),W(()=>N(`newSession.hostedHint`),t=>{V(e,`title`,t)}),e})():B(()=>!!(c().nativeTerminal&&e.params.place.terminalOnNode))()?(()=>{var t=Jp(),n=t.firstChild,r=n.nextSibling;return z(n,()=>N(`newSession.terminalNodeFolder`)),r._$$input=t=>e.params.place.applyFolder(t.currentTarget.value),G(()=>o,r),W(()=>({e:N(`newSession.terminalNodeFolder`),t:e.params.submitting}),({e,t},n)=>{e!==n?.e&&V(r,`aria-label`,e),t!==n?.t&&V(r,`disabled`,t)}),t})():U(pp,{get params(){return e.params},get state(){return c().projectState},get nativeTerminal(){return c().nativeTerminal},get focus(){return c().browser.projectFocus}})})(),n),z(t,(()=>{var t=B(()=>!(!e.params.place.checkoutVisible||c().nativeTerminal&&e.params.place.terminalOnNode));return()=>t()?B(()=>!!e.params.place.repositoryState.checkoutPending)()?U(Rp,{}):U(up,{get params(){return e.params},get folderLabel(){return c().projectState.label}}):void 0})(),r),t})(),B(()=>B(()=>!!e.params.place.deviceFolder)()?(()=>{var t=Yp(),n=t.firstChild,r=n.nextSibling,i=r.nextSibling;return G(()=>e=>{a=e},t),z(n,()=>N(`newSession.deviceFolderPath`)),r._$$input=t=>e.params.place.setDeviceFolderPath(t.currentTarget.value),G(()=>s,r),z(i,()=>e.params.place.deviceFolderRuntimeUnsupportedReason??N(`newSession.deviceFolderDescription`)),W(()=>({e:N(`newSession.deviceFolderPath`),t:N(`newSession.deviceFolderPathPlaceholder`),a:e.params.submitting||e.params.pendingPlacement}),({e,t,a:n},i)=>{e!==i?.e&&V(r,`aria-label`,e),t!==i?.t&&V(r,`placeholder`,t),n!==i?.a&&V(r,`disabled`,n)}),t})():void 0)]),` `]}var Hp,Up,Wp,Gp,Kp,qp,Jp,Yp;function Xp(){return(Xp=e((()=>{K(),R(),F(),Z(),ra(),M(),$a(),Gr(),_(),Q(),fp(),Ko(),Il(),hp(),xp(),Kf(),Lp(),Hp=q(`<span class=new-session-page__select><span class="new-session-page__trigger new-session-page__checkout-skeleton"role=status style=pointer-events:none><span class=new-session-page__target-icon aria-hidden=true></span><span class=new-session-page__skeleton-bar aria-hidden=true style=width:80px>`),Up=q(`<span class="new-session-page__select new-session-page__select--agent"><openclaw-agent-select>`,1),Wp=q(`<span class=new-session-page__select role=status data-required-placement><!><!>`),Gp=q(`<button type=button class="btn btn--sm">`),Kp=q(`<div class=new-session-page__workspace><!><!>`),qp=q(`<span class="new-session-page__select new-session-page__hosted-workspace">`),Jp=q(`<label class="new-session-page__select new-session-page__menu-field"><span></span><input>`),Yp=q(`<label class="new-session-page__select new-session-page__menu-field new-session-page__device-folder"><span></span><input><span class=muted>`),X(),Po([`click`,`input`])})))()}function Zp(e){let t=I(()=>(e.renderRevision,e.control.prepare(e.ownerKey,e.inputDeviceId))),n=U(vn,bo(()=>t().voice.microphonePicker));return[U(Ua,bo(()=>t().voice,{get idleLabel(){return e.idleLabel},microphonePicker:n})),U(cr,{readDictation:()=>t().voice.readDictation(),get onSend(){return t().onSubmit}})]}function Qp(){return(Qp=e((()=>{K(),R(),Ya()})))()}function $p(e){return e.pendingMessage?e.completion?.label??e.statusLabel??N(`newSession.starting`):void 0}function em(e){return U(xr,{tone:`danger`,class:`new-session-page__error new-session-page__alert`,get action(){return U(L,{get when(){return e.action},children:e=>(()=>{var t=nm();return t._$$click=()=>e().onClick(),z(t,()=>e().label),W(()=>e().disabled,e=>{V(t,`disabled`,e)}),t})()})},get children(){return j(e.message)}})}function tm(e){let t=ai(`scroll`),n=I(()=>Oe(!0,e.pendingMessage&&Be(e.pendingMessage.__openclaw)?e.userId:null));return[(()=>{var t=rm();return z(t,()=>$p(e)),t})(),(()=>{var r=im(),i=r.firstChild,a=i.nextSibling,o=a.nextSibling;return No(r,`mousedown`,Aa,!0),G(()=>t,r),z(r,U(L,{get when(){return e.error},children:t=>U(em,{get message(){return t()},get action(){return e.errorAction}})}),i),z(r,U(L,{get when(){return e.pendingMessage},get fallback(){return e.renderDraft()},children:t=>U(To,{fallback:(e,t)=>U(Ta,{get error(){return e()},onRetry:t,inline:!0}),get children(){return U(Io,{get fallback(){return U(Wi,{})},get children(){return U(am,{get message(){return t()},get avatarPlacement(){return n()},get onOpenImage(){return e.onOpenImage},get statusLabel(){return e.statusLabel},get completion(){return e.completion}})}})}})}),a),z(r,U(L,{get when(){return B(()=>!!e.pendingMessage)()?e.showDraft:e.pendingMessage},get children(){return e.renderDraft()}}),o),W(()=>({e:Mo([e.inChat?``:`new-session-page__scroll`,{"chat-thread":!!(e.pendingMessage||e.inChat),"chat-thread--annotations":!!(e.pendingMessage||e.inChat),"chat-thread--direct":!!(e.pendingMessage||e.inChat)&&n()===`footer`}]),t:e.submitting&&!e.pendingMessage,a:e.submitting?`true`:`false`}),({e,t,a:n},i)=>{jo(r,e,i?.e),t!==i?.t&&V(r,`inert`,t),n!==i?.a&&V(r,`aria-busy`,n)}),r})()]}var nm,rm,im,am,om;function sm(){return(sm=e((()=>{K(),R(),br(),ar(),Fr(),ua(),va(),Z(),Ka(),k(),M(),cn(),r(),nm=q(`<button class="btn btn--sm"type=button>`),rm=q(`<div class=sr-only role=status aria-live=polite>`),im=q(`<div><!><!><!>`),sa(X),am=Oo(()=>v(()=>import(`./draft-submission-view-DpPbx-0a.js`),__vite__mapDeps([4,6,7,8,9,0,3,10]),import.meta.url),{export:`NewSessionSubmission`},`src/pages/new-session/draft-submission-view.tsx`),om=()=>void am.preload().catch(()=>void 0),Po([`click`,`mousedown`])})))()}function cm(e){var t=um();return t._$$click=()=>e.onRetry(),z(t,(()=>{var t=B(()=>!!e.retrying);return()=>t()?N(`common.loading`):N(`lazyView.retry`)})()),W(()=>e.retrying,e=>{V(t,`disabled`,e)}),t}function lm(e){let t=I(()=>({promise:e.retryRead}),{equals:(e,t)=>e.promise===t.promise}),n=I(()=>t().promise?.then(()=>null)),r,i;var a=dm(),o=a.firstChild,s=o.nextSibling,c=s.nextSibling;return G(()=>()=>e.ref?.(()=>[r,i].filter(e=>e?.isConnected===!0)),a),z(a,(()=>{var t=B(()=>!!A(e.data));return()=>t()?(()=>{var t=fm(),n=t.firstChild,i=n.nextSibling;return G(()=>e=>{r=e},t),z(n,U(P,{name:`terminal`})),z(i,()=>e.data?.catalogLabel||e.data?.catalogId||``),W(()=>e.data?.startTerminal&&e.data.catalogLabel?N(`newSession.nativeTerminalHintTooltip`):N(`newSession.catalogUnavailable`),e=>{V(t,`title`,e)}),t})():e.agentSelect})(),o),z(a,()=>e.placeSelect,s),z(a,(()=>{var t=B(()=>!!(qc(e.data)||e.groupPending===!0));return()=>t()?(()=>{var t=pm(),r=t.firstChild,a=r.nextSibling;return G(()=>e=>{i=e},t),z(t,()=>N(`newSession.catalogUnavailable`),r),z(t,U(To,{fallback:(t,r)=>{let i=()=>{e.onRetry(),r()};return U(Io,{get fallback(){return U(cm,{retrying:!0,onRetry:i})},get children(){return U(cm,{get retrying(){return Eo(n)||e.retrying},onRetry:i})}})},get children(){return U(Io,{get fallback(){return U(cm,{retrying:!0,get onRetry(){return e.onRetry}})},get children(){return[B(()=>_o(n)),U(cm,{get retrying(){return Eo(n)||e.retrying},get onRetry(){return e.onRetry}})]}})}}),a),t})():void 0})(),c),a}var um,dm,fm,pm;function mm(){return(mm=e((()=>{K(),R(),F(),M(),Q(),um=q(`<button class="btn btn--sm"type=button>`),dm=q(`<div class=new-session-page__triggers><!><!><!>`),fm=q(`<span class="new-session-page__trigger new-session-page__runtime"><span class=new-session-page__target-icon aria-hidden=true></span><span class=new-session-page__trigger-label>`),pm=q(`<span class=new-session-page__catalog-unavailable><!><!>`),Po([`click`])})))()}var hm;function gm(){return(gm=e((()=>{R(),hm=So()})))()}function _m(e){let t=xo(hm),n=I(()=>{let n=e.options,r=n.submitting||n.messageLocked===!0;return{attachments:e.attachments,inputHandle:e.inputHandle,capabilityMenu:n.capabilityMenu,disabled:r,open:t.capabilityMenuOpen,view:t.capabilityMenuView,toolOverrides:n.toolOverrides,onOpenChange:e=>{t.capabilityMenuOpen=e,e||(t.capabilityMenuView=`root`),n.onChange()},onViewChange:e=>{t.capabilityMenuView=e,n.onChange()}}});return U(Fa,{get menu(){return n()}})}function vm(e){let t=xo(hm),n=I(()=>Rr(e.options.toolOverrides));return U(L,{get when(){return n()>0},get children(){var r=bm();return r._$$click=()=>{t.capabilityMenuView=`root`,t.capabilityMenuOpen=!0,e.options.onChange()},z(r,()=>N(n()===1?`chat.composer.overrides.countOne`:`chat.composer.overrides.count`,{count:String(n())})),W(()=>e.options.submitting||e.options.messageLocked===!0,e=>{V(r,`disabled`,e)}),r}})}function ym(e){let t=()=>e.options.submitting?N(`newSession.starting`):N(e.options.nativeTerminal?`newSession.startInTerminal`:`newSession.start`),n=()=>e.options.submitting||e.options.attachmentDraft.reads.pendingReads>0,r=()=>!Yn()&&!e.options.nativeTerminal&&!n()&&e.options.submitDisabledReason==null;var i=Cm(),a=i.firstChild;return i._$$pointerdown=t=>{t.button===0&&!e.options.canSubmit&&e.options.onBlockedSubmit?.()},i._$owner=wo(),z(i,U(L,{get when(){return r()},get children(){var t=Sm(),n=t.firstChild,r=n.nextSibling;return z(t,U(Qt,{get label(){return N(`chat.runControls.send`)},get combo(){return B(()=>!!e.options.requiresModifier)()?Li.modifiedEnter:Li.sendMessage}}),n),z(t,U(L,{get when(){return e.options.onBackgroundSubmit},get children(){return[xm(),U(Qt,{get label(){return N(`newSession.backgroundSend`)},get combo(){return B(()=>!!e.options.requiresModifier)()?{modifiers:[`mod`,`shift`],key:`Enter`}:Li.modifiedEnter}})]}}),r),t}}),a),a._$$click=()=>e.onSubmit(),z(a,U(P,{get name(){return B(()=>!!n())()?`loader`:e.options.nativeTerminal?`squareTerminal`:`arrowUp`}})),W(()=>({e:r()?``:e.options.submitDisabledReason??t(),t:!!n(),a:!e.options.canSubmit,o:e.options.canSubmit?`false`:`true`,i:n()?`true`:`false`,n:t()}),({e,t,a:n,o:r,i:o,n:s},c)=>{e!==c?.e&&(i.content=e),t!==c?.t&&a.classList.toggle(`new-session-page__start-submit--busy`,t),n!==c?.a&&V(a,`disabled`,n),r!==c?.o&&V(a,`aria-disabled`,r),o!==c?.i&&V(a,`aria-busy`,o),s!==c?.n&&V(a,`aria-label`,s)}),i}var bm,xm,Sm,Cm;function wm(){return(wm=e((()=>{K(),R(),F(),yt(),Z(),da(),M(),Er(),gm(),bm=q(`<button type=button class=new-session-page__selection-status>`),xm=q(`<span class=muted aria-hidden=true>·`),Sm=q(`<span slot=content class=new-session-page__start-shortcuts><!><!>`),Cm=q(`<openclaw-tooltip><button type=button class="chat-send-btn new-session-page__start-submit">`,1),X(),Po([`click`,`pointerdown`])})))()}function Tm(e,t){let n=I(()=>N(e().nativeTerminal?`newSession.nativeTerminalPrompt`:`newSession.messagePlaceholder`)),r=I(()=>e().message.length>0),i=!globalThis.requestAnimationFrame||(globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1),[a,o]=Do({target:``,text:``}),s=!1;return Co(()=>[n(),r()],([e,n])=>{if(s||=n,s||i)return;let r,a,c=0,l=n=>{if(!t.getTextarea()?.isConnected)return;r??=n;let i=Math.min(e.length,Math.floor(Math.max(0,n-r-180)/26));s=i===e.length,c!==i&&(c=i,o(t=>{t.target=e,t.text=e.slice(0,c)})),s||(a=requestAnimationFrame(l))};return a=requestAnimationFrame(l),()=>cancelAnimationFrame(a)}),()=>e().dictationActive?``:s||r()||i?n():a.target===n()?a.text:``}function Em(){return(Em=e((()=>{R(),M()})))()}function Dm(e,t){t.emojiMenu.close(),t.mentionMenu.close(),t.skillMenu.reset(),t.slashMenu.reset(),e.onSubmit()}function Om(e,t){let{attachmentDraft:n,context:r}=e,i=n.reads.readSignal,a=r?.gateway,o=e.nativeTerminal?null:a?.snapshot.client??null,s=Mf(e),{skillMenu:c,slashMenu:l,mentionMenu:u,emojiMenu:d}=t,f=c.state,p=l.state,m=e.submitting||e.messageLocked===!0||e.dictationActive===!0,h={paneId:`new-session`,getDraft:()=>t.getTextarea()?.value??e.message,commitDraft:e.onInput,getTextarea:t.getTextarea,refreshCommands:o?()=>t.refreshSkillCommands(o):void 0},g={...h,resolveArgOptions:e=>e.argOptions??[],runCommand:()=>Dm(e,t),canRun:e=>!e,commandFilter:e=>e.executeLocal!==!0},_={paneId:h.paneId,getDraft:h.getDraft,getTextarea:h.getTextarea,getMentions:()=>e.getMentions?.()??e.mentions??[],commitDraft:e.onInput},v=n=>{if(za(n)||e.dictationActive||e.submitting||e.messageLocked||t.composing||Pa(n)||t.emojiMenu.handleKeydown(n,`new-session`)||t.mentionMenu.handleKeydown(n,_)||c.handleKeydown(n,h)||l.handleKeydown(n,g)||n.key!==`Enter`)return;let r=n.metaKey||n.ctrlKey,i=r&&(n.shiftKey||!e.requiresModifier),a=!!(!n.altKey&&i&&e.onBackgroundSubmit);(a||!n.shiftKey&&(!e.requiresModifier||r))&&(n.repeat?n.preventDefault():(e.canSubmit||e.submitDisabledReason!==void 0)&&(n.preventDefault(),a?(t.skillMenu.reset(),t.slashMenu.reset(),t.mentionMenu.close(),e.onBackgroundSubmit?.()):Dm(e,t)))},y=(n,r=f.skillMenuOpen||p.slashMenuOpen)=>{d.update(n,!m&&!e.nativeTerminal&&!t.composing&&!r&&!u.open)},b=(n,r)=>{if(e.nativeTerminal||t.composing||r?.isComposing){d.close();return}let i=l.update(n.value,g),a=c.update(n.value,n.selectionStart,h);r?.inputType===`insertFromPaste`||r?.inputType===`insertFromDrop`?u.close():u.update(n,r?r.inputType===`insertText`&&r.data?.includes(`@`)===!0?`trigger`:`input`:`selection`),y(n,i||a)},x=e=>{let t=e.currentTarget;t instanceof HTMLTextAreaElement&&(e.type===`keyup`?(u.update(t),y(t)):b(t))},S={attachmentReads:n.reads,attachmentLimits:st(a?.snapshot.hello?.policy),uploadConfig:r?.config,attachments:n.attachments,get disabled(){return e.submitting||e.messageLocked===!0||e.dictationActive===!0},getAttachments:()=>n.attachments,draft:e.message,getDraft:()=>e.message,onAttachmentsChange:t=>{!e.submitting&&!e.messageLocked&&n.replace(t)},onDraftChange:e.onInput,onPendingReadsChange:e=>n.reads.updatePending(i,e),onOpenImage:e.onOpenImage,onOpenSidebar:e.onOpenSidebar,readSignal:i},ee=It({...S,canCompose:!m&&!e.nativeTerminal}),te=e.dictationPreview??e.message;t.syncDraft(te);let ne=N(e.nativeTerminal?`newSession.nativeTerminalPrompt`:`newSession.messagePlaceholder`),{skillMenuVisible:C,slashMenuVisible:re,menuVisible:w,menuListboxId:ie,activeMenuOptionId:ae,activeMenuOptionLabel:oe}=ht(h.paneId,!e.nativeTerminal&&!m,f,p,u,d),se=Ae(h.paneId,`active-menu-announcement`),ce=e.requiresModifier?`Control+Enter Meta+Enter`:`Enter Control+Enter Meta+Enter`,T=e.onBackgroundSubmit?`${ce} Control+Shift+Enter Meta+Shift+Enter`:ce;return{attachmentProps:S,attachmentDropHandlers:ee,commandClient:o,mentionDirectory:m?void 0:s,composerLocked:m,visibleMessage:te,messagePlaceholder:ne,keyShortcuts:T,skillMenuVisible:C,slashMenuVisible:re,menuVisible:w,menuListboxId:ie,activeMenuOptionId:ae,activeMenuOptionLabel:oe,menuAnnouncementId:se,skillMenuHost:h,slashMenuHost:g,mentionMenuHost:_,handleComposerKeydown:v,handleSelect:x,updateMenus:b}}function km(e){let t=xo(hm),n=gn(()=>e.frame.visibleMessage,Sa),r=vr(()=>e.options.getMentions?.()??e.options.mentions??[],t.mentionMenu.selectedAvatarUrls),i,a,o=!1;H(()=>(t.ref(i),o&&document.activeElement===document.body&&Bi(i,{preventScroll:!0}),()=>{t.getTextarea()===i&&t.ref(),a?.()}));var s=jm();return s.addEventListener(`paste`,t=>{e.options.nativeTerminal&&t.clipboardData?.files.length?(t.preventDefault(),e.options.onUnsupportedAttachment?.()):!e.frame.composerLocked&&!e.options.nativeTerminal&&Vt(t,e.frame.attachmentProps)}),s.addEventListener(`compositionstart`,n=>{Qe(n),t.composing=!0,t.emojiMenu.close(),t.mentionMenu.close(),e.options.onChange()}),s._$$keydown=t=>{Qe(t),e.frame.handleComposerKeydown(t)},s.addEventListener(`compositionend`,n=>{Tr(n),t.composing=!1,e.frame.updateMenus(n.currentTarget)}),s.addEventListener(`blur`,e=>{Qe(e),_r(e),t.composing=!1,t.emojiMenu.close()}),s._$$keyup=n=>{_r(n),t.emojiMenu.handleKeyup(n),(n.key.startsWith(`Arrow`)||n.key===`Home`||n.key===`End`)&&e.frame.handleSelect(n)},s._$$pointerup=t=>e.frame.handleSelect(t),s.addEventListener(`focus`,t=>e.frame.handleSelect(t)),s.addEventListener(`select`,t=>e.frame.handleSelect(t)),No(s,`pointerdown`,Qe,!0),No(s,`wheel`,Qe),No(s,`scroll`,qe),s._$$beforeinput=n=>{Qe(n);let r=n.currentTarget;t.mentionInput={value:r.value,start:r.selectionStart,end:r.selectionEnd,inputType:n.inputType},t.emojiMenu.complete(n,!e.frame.composerLocked&&!e.options.nativeTerminal&&!t.composing)},s._$$input=n=>{if(Qe(n),e.options.dictationActive)return;let r=n.currentTarget;fn(r,{nativeInput:!0});let i=e.frame.mentionMenuHost.getMentions(),a=li(e.options.message,r.value,i,t.mentionInput);e.options.onInput(r.value,i.length||a.length?a:void 0),t.mentionInput=void 0,e.frame.updateMenus(r,n)},G(()=>[t=>{o=Oa(e.input.read()),a=e.input.bind(t),i=t,n(t)},r],s),W(()=>({e:JSON.stringify(e.options.mentions??[]),t:globalThis.matchMedia?.(`(max-width: 560px)`)?.matches??!1,a:e.options.submitting||e.options.messageLocked,o:e.options.dictationActive,i:e.placeholder,n:e.frame.messagePlaceholder,s:Yn()?void 0:e.frame.keyShortcuts,h:e.frame.menuVisible?e.frame.menuListboxId:void 0,r:e.frame.menuVisible?`listbox`:void 0,d:e.frame.activeMenuOptionId??void 0,l:e.frame.menuAnnouncementId}),({e,t,a:n,o:r,i,n:a,s:o,h:c,r:l,d:u,l:d},f)=>{e!==f?.e&&V(s,`data-composer-mentions`,e),t!==f?.t&&V(s,`autofocus`,t),n!==f?.a&&V(s,`disabled`,n),r!==f?.o&&V(s,`readonly`,r),i!==f?.i&&V(s,`placeholder`,i),a!==f?.n&&V(s,`aria-label`,a),o!==f?.s&&V(s,`aria-keyshortcuts`,o),c!==f?.h&&V(s,`aria-controls`,c),l!==f?.r&&V(s,`aria-haspopup`,l),u!==f?.d&&V(s,`aria-activedescendant`,u),d!==f?.l&&V(s,`aria-describedby`,d)}),s}function Am(e){let t=xo(hm),n=$e(async()=>{Fm(!0),await Im.preload()}),r=n.Boundary;H(()=>(n.schedule(),n.dispose));let i=oo(),a=Ct(),o=ai(`composer`),s=I(()=>{let t=e.options.draftSource;return t?Hn(t,e=>e.read()):void 0}),c=I(()=>{let t=s()?.read();return t?{...e.options,message:t.draft,mentions:t.mentions}:e.options}),l=I(()=>Om(c(),t)),u=Tm(c,t);Co(()=>[l().commandClient,c().agentId,c().draftOwnerKey,c().commandProjectId,l().mentionDirectory,l().composerLocked||c().nativeTerminal||t.composing],([e,n,r,i,a,o])=>{t.syncSkillCommandOwner(e,{agentId:n,draftOwnerKey:r,commandProjectId:i}),t.mentionMenu.syncDirectory(a),o&&t.emojiMenu.close()});let d=Ee(),f,p,m,h,g,_=()=>{let t=d.read();if(!f||!t||!p)return null;let n=e.surroundings?.();return{root:n?.root??f,composer:f,editor:t,footer:p,controls:[m,h,g].filter(e=>e?.isConnected===!0),obstacles:n?.obstacles??[]}};var v=Nm(),y=v.firstChild,b=y.firstChild,x=b.nextSibling,S=x.nextSibling,ee=S.nextSibling,te=ee.nextSibling,ne=te.nextSibling,C=ne.nextSibling,re=C.nextSibling,w=re.firstChild,ie=w.firstChild,ae=ie.nextSibling,oe=ae.nextSibling,se=re.nextSibling,ce=se.firstChild,T=ce.firstChild,le=T.nextSibling,ue=le.nextSibling,de=ce.nextSibling.firstChild,fe=de.nextSibling,pe=fe.firstChild,E=pe.nextSibling,D=y.nextSibling;return v.addEventListener(`dragover`,e=>l().attachmentDropHandlers.onDragover(e)),v.addEventListener(`dragleave`,e=>l().attachmentDropHandlers.onDragleave(e)),v.addEventListener(`dragenter`,e=>l().attachmentDropHandlers.onDragenter(e)),v.addEventListener(`drop`,e=>{c().nativeTerminal&&e.dataTransfer?.files.length?(e.preventDefault(),c().onUnsupportedAttachment?.()):l().attachmentDropHandlers.onDrop(e)}),v._$$keydown=()=>void Qi(),v.addEventListener(`pointerenter`,()=>void Qi()),G(()=>i,v),z(v,U(L,{get when(){return c().dictationError},children:e=>U(xr,{tone:`danger`,class:`new-session-page__error new-session-page__alert`,get children(){return e()}})}),y),y.addEventListener(`openclaw-composer-dismiss-invocations`,()=>{t.mentionMenu.close(),t.emojiMenu.dismiss(t.getTextarea()),c().onChange()}),G(()=>e=>{f=e,o(e)},y),z(y,U(r,{get children(){return U(L,{get when(){return Pm()},get children(){return U(Im,{composerElements:_,get seed(){return cs(`${t.critterVisit}:${c().draftOwnerKey}`)},get mode(){return us(!c().context?.gateway.snapshot.offlineStable,c().context?.sessions.state.result?.sessions)},get runOutcome(){return os(c().context?.sessions.state.result?.sessions)},get visitsEnabled(){return c().context?.theme.settings.lobsterPetVisits!==!1},get residentEnabled(){return c().context?.theme.branding.mascot!==`none`},get critters(){return c().context?.theme.branding.critters},get critterArtwork(){return c().context?.theme.branding.artwork?.critters},get soundsEnabled(){return c().context?.theme.settings.lobsterPetSounds===!0},get gatewayVersion(){return c().context?.config.current.serverVersion??c().context?.gateway.snapshot.hello?.server?.version??null},onVisitsDisabled:()=>c().context?.theme.refresh(),get floorEnabled(){return B(()=>!(l().composerLocked||l().visibleMessage.length!==0||c().attachmentDraft.attachments.length!==0||c().attachmentDraft.reads.pendingReads!==0||l().menuVisible))()?!t.capabilityMenuOpen:!l().composerLocked&&l().visibleMessage.length===0&&c().attachmentDraft.attachments.length===0&&c().attachmentDraft.reads.pendingReads===0&&!l().menuVisible}})}})}}),b),z(y,U(L,{get when(){return l().slashMenuVisible},get children(){return U(Cs,{get menu(){return t.slashMenu},get host(){return l().slashMenuHost},get draft(){return l().visibleMessage}})}}),x),z(y,U(bs,{get args(){return[t.mentionMenu,l().mentionMenuHost]}}),S),z(y,U(ys,{get args(){return[t.emojiMenu,`new-session`,t.getTextarea()]}}),ee),z(y,U(L,{get when(){return!c().nativeTerminal},get children(){return U(nn,bo(()=>l().attachmentProps,{inputHandle:a}))}}),te),z(y,U(fi,bo(()=>l().attachmentProps,{get readRevision(){return l()}})),ne),z(y,U(zt,{get pendingReads(){return c().attachmentDraft.reads.pendingReads}}),C),z(C,()=>c().dictationStatus),z(w,U(L,{get when(){return l().skillMenuVisible},get children(){return U(vs,{get menu(){return t.skillMenu},get host(){return l().skillMenuHost}})}}),ie),z(w,U(L,{get when(){return c().draftOwnerKey},keyed:!0,children:e=>U(km,{get options(){return c()},get frame(){return l()},get placeholder(){return u()},input:d})}),ae),z(ae,u),z(oe,()=>l().activeMenuOptionLabel),G(()=>e=>p=e,se),G(()=>e=>{m=e},ce),z(ce,U(L,{get when(){return!c().nativeTerminal},get children(){return U(_m,{get options(){return c()},get attachments(){return l().attachmentProps},inputHandle:a})}}),T),z(ce,()=>c().permissionControl,le),z(ce,U(L,{get when(){return!c().nativeTerminal},get children(){return U(vm,{get options(){return c()}})}}),ue),z(de,U(L,{get when(){return!c().isCatalogTarget},get children(){var e=Mm();return G(()=>e=>{h=e},e),z(e,U(Hf,{get control(){return c().modelControl},get options(){return{agent:c().agent,agentId:c().agentId,context:c().context,sending:c().submitting}}})),e}})),G(()=>e=>{g=e},fe),z(fe,()=>c().voiceControl,pe),z(fe,U(L,{get when(){return!c().dictationActive},get children(){return U(ym,{get options(){return c()},onSubmit:()=>Dm(c(),t)})}}),E),z(v,U(ii,{options:c}),D),z(D,()=>e.contextControls),W(()=>({e:!!c().dictationActive,t:l().menuAnnouncementId}),({e,t},n)=>{e!==n?.e&&y.classList.toggle(`agent-chat__input--dictating`,e),t!==n?.t&&V(oe,`id`,t)}),v}var jm,Mm,Nm,Pm,Fm,Im;function Lm(){return(Lm=e((()=>{K(),R(),Pe(),fs(),ar(),Je(),Fr(),Z(),Wt(),ma(),Ci(),wi(),Ea(),M(),$a(),Rn(),On(),it(),en(),Ut(),Kt(),Pn(),gs(),_s(),Le(),xs(),Ss(),ir(),wm(),Em(),gm(),Nf(),Uf(),r(),jm=q(`<textarea class=new-session-page__message rows=1 enterkeyhint=enter aria-autocomplete=list>`),Mm=q(`<div class=chat-composer-model-control>`),Nm=q(`<div class="agent-chat__composer-shell new-session-page__composer"><div class="agent-chat__input agent-chat__input--mobile-toolbar"><!><!><!><!><!><!><div class=agent-chat__composer-lede></div><div class=agent-chat__composer-input-row><div class=agent-chat__composer-combobox><!><span class=agent-chat__composer-placeholder aria-hidden=true></span><span class=sr-only role=status aria-live=polite aria-atomic=true></span></div></div><div class=agent-chat__composer-footer><div class=agent-chat__composer-lead><!><!><!></div><div class=agent-chat__composer-trail><div class=agent-chat__composer-controls></div><div class=agent-chat__composer-actions><!><!></div></div></div></div><div class=new-session-page__context-tray>`),X(),[Pm,Fm]=ho(!1),Im=Oo(()=>v(()=>import(`./lobster-pet-DStHVtXv.js`),__vite__mapDeps([14,15,16,0,3,17]),import.meta.url),{export:`LobsterPet`},`src/components/lobster-pet.tsx`),Po([`input`,`beforeinput`,`pointerdown`,`pointerup`,`keyup`,`keydown`])})))()}function Rm(e){let t=()=>e.mode===`draft`,n=()=>e.submission.visibility===e.mode,r=()=>e.submission.incognitoDisabledReason(),i=()=>e.submission.submitting||!!e.submission.pendingPlacement.sessionKey||!t()&&!!r(),a=()=>N(t()?`newSession.draft`:`sessionsView.incognitoLabel`),o=()=>t()?N(`newSession.draftDescription`):r()??N(`sessionsView.incognitoDescriptionTooltip`),s=()=>`new-session-page__${e.mode}-toggle`;var c=Um(),l=c.firstChild,u=l.firstChild,d=u.nextSibling;return c._$owner=wo(),l._$$click=()=>{(t()||!i())&&e.submission.setVisibility(n()?`normal`:e.mode)},z(l,U(P,{get name(){return t()?`draft`:`incognito`}}),u),z(l,(()=>{var t=B(()=>!(!n()||e.inHeader));return()=>t()?(()=>{var t=Wm();return z(t,a),W(()=>[`new-session-page__${e.mode}-toggle-label`],(e,n)=>{jo(t,e,n)}),t})():void 0})(),d),W(()=>({e:o(),t:Mo([e.inHeader?`mobile-header__control`:`shell-chrome-controls__button`,s(),{[`${s()}--active`]:n()}]),a:t()?`${a()}: ${o()}`:a(),o:n()?`true`:`false`,i:i(),n:o()}),({e,t,a:n,o:r,i,n:a},o)=>{e!==o?.e&&(c.content=e),jo(l,t,o?.t),n!==o?.a&&V(l,`aria-label`,n),r!==o?.o&&V(l,`aria-checked`,r),i!==o?.i&&V(l,`disabled`,i),a!==o?.n&&V(l,`title`,a)}),c}function zm(e){return[B(()=>B(()=>!!(e.draftAvailable||e.submission.visibility===`draft`))()?U(Rm,{get submission(){return e.submission},mode:`draft`,get inHeader(){return e.inHeader}}):void 0),U(Rm,{get submission(){return e.submission},mode:`incognito`,get inHeader(){return e.inHeader}})]}function Bm(e){var t=Gm();return z(t,U(zm,{get submission(){return e.submission},get draftAvailable(){return e.draftAvailable}})),t}function Vm(e){var t=Km(),n=t.firstChild,r=n.nextSibling,i=r.firstChild,a=i.nextSibling;return G(()=>t=>e.ref?.(t),t),z(n,U(P,{name:`incognito`})),z(r,()=>N(`sessionsView.incognitoDescription`),i),z(r,()=>N(`sessionsView.incognitoLimits`),a),W(()=>({e:!!e.active,t:e.active?`false`:`true`}),({e,t:n},r)=>{e!==r?.e&&t.classList.toggle(`new-session-page__incognito-notice--visible`,e),n!==r?.t&&V(t,`aria-hidden`,n)}),t}function Hm(e){var t=Jm(),n=t.firstChild;return z(n,()=>e.hint),z(t,U(jt,{id:`new-session-incognito-note`,lazy:`while-open`,get label(){return N(`sessionsView.incognitoLabel`)},class:`new-session-page__incognito-note`,triggerClass:`new-session-page__incognito-status`,get trigger(){return[(()=>{var e=Wm();return z(e,()=>N(`sessionsView.incognitoLabel`)),e})(),U(P,{name:`info`})]},placement:`bottom`,get open(){return e.noteOpen},get onOpenChange(){return e.onNoteOpenChange},get children(){var t=qm(),n=t.firstChild,r=n.nextSibling;return t._$$click=()=>e.onNoteOpenChange(!1),z(n,()=>N(`sessionsView.incognitoDescription`)),z(r,()=>N(`sessionsView.incognitoLimits`)),t}}),null),t}var Um,Wm,Gm,Km,qm,Jm,Ym;function Xm(){return(Xm=e((()=>{K(),F(),la(),Pn(),Z(),M(),Um=q(`<openclaw-tooltip><button type=button role=switch><!><!>`,1),Wm=q(`<span>`),Gm=q(`<div class=new-session-page__incognito-rail>`),Km=q(`<div class=new-session-page__incognito-notice role=status><span class=new-session-page__incognito-notice-icon aria-hidden=true></span><span> <!>`),qm=q(`<div><p></p><p>`),Jm=q(`<span class=new-session-page__welcome-hint><span class=new-session-page__welcome-hint-text>`),X(),Ym=`(max-width: 768px), (max-width: 932px) and (max-height: 500px) and (orientation: landscape)`,Po([`click`])})))()}function Zm(e){let t=()=>{let t=e.shell.gatewayStatus;return t?.kind&&t.kind!==`connected`?{kind:`gateway`,status:t.kind,onRetry:t.onRetry}:void 0};return U(dt,{active:!0,get title(){return N(`newSession.title`)},titlePending:!1,incognito:!1,get navDrawerOpen(){return e.shell.navDrawerOpen},panelsOpen:!1,compactActions:!0,get notice(){return t()},get draftControls(){return[U(L,{get when(){return!A(e.page().data)},get children(){return U(zm,{inHeader:!0,get submission(){return e.submission},get draftAvailable(){return e.page().submission.capabilities.canStartAsDraft(e.page().context)}})}}),(()=>{var e=Qm();return e._$$click=()=>window.dispatchEvent(new Event(We)),z(e,U(P,{name:`search`})),W(()=>N(`chat.openCommandPalette`),t=>{V(e,`aria-label`,t)}),e})()]}})}var Qm;function $m(){return($m=e((()=>{K(),R(),hi(),F(),M(),Mt(),Q(),Xm(),Qm=q(`<button type=button class="mobile-header__control mobile-header__search">`),Po([`click`])})))()}function eh(e,t){return e?.client===t?.client&&e?.agentId===t?.agentId&&e?.ownerKey===t?.ownerKey&&e?.message===t?.message&&e?.model===t?.model}function th(e){let t=null,n=null,r,i=!1,a=!1,o=0,s=!1,c=!1,l=null;return{dispose(){s=!0,u(null),l=null},synchronize:()=>u(p()),setComposing(e){c=e,u(p())},takePreparedTitle(){let e=p(),r=eh(t,e)?n??void 0:void 0;return l=e??l,u(null),r}};function u(e){let i=e&&e.message.length>=12&&!e.message.startsWith(`/`)?e:null;eh(t,i)||(clearTimeout(r),t=i,n=null,a=i!==null,o=Date.now()+1e3,d())}function d(){a&&!i&&(r=setTimeout(()=>void f(),Math.max(0,o-Date.now())))}async function f(){let e=t;if(e&&a){a=!1,i=!0;try{let r=await e.client.request(`sessions.title.prepare`,{agentId:e.agentId,message:be(e.message,1e3),...e.model?{model:e.model}:{}},{timeoutMs:2e4});t===e&&(n=r.title)}catch{}finally{i=!1,d()}}}function p(){let{context:t,data:n,place:r,submission:i,dictating:a}=e(),o=t?.gateway.snapshot;if(s||A(n)||c||a||i.submitting||i.visibility===`incognito`||i.pendingPlacement.sessionKey||!r.agentId||!r.modelControl.accountSelectionReady()||!ae(o,`sessions.title.prepare`,`operator.write`)||!o?.client)return null;let u={client:o.client,ownerKey:Uc(n),agentId:r.agentId,message:i.message.trim(),model:r.modelControl.modelForSubmission()};return eh(u,l)?null:u}}function nh(){return(nh=e((()=>{se(),Q()})))()}function rh(e){let t=ai(`welcome`);return U(L,{get when(){return!e.modelSetupRequired},get fallback(){var n=uh(),r=n.firstChild,i=r.firstChild,a=r.nextSibling,o=a.nextSibling;return G(()=>t,n),i.size=112,i._$owner=wo(),z(a,()=>N(`modelSetup.required.title`)),z(o,()=>N(`modelSetup.required.body`)),z(n,U(L,{get when(){return e.onModelSetup},get children(){var t=lh();return t._$$click=()=>e.onModelSetup?.(),z(t,()=>N(`modelSetup.required.action`)),t}}),null),n},get children(){var n=ch(),r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=a.firstChild,s=o.nextSibling,c=s.nextSibling,l=r.nextSibling,u=l.nextSibling;return G(()=>t,n),z(i,U(Xt,{get agent(){return wn(e)}})),z(o,()=>e.assistantName||N(`chat.messages.agentName`)),z(a,U(L,{get when(){return e.assistantNameControl},get children(){var t=ih();return z(t,()=>e.assistantNameControl),t}}),s),z(a,U(L,{get when(){return e.hint},get children(){var t=ah();return z(t,()=>e.hint),t}}),c),z(n,()=>e.composer,l),z(n,U(L,{get when(){return!e.hideSecondaryContent},get children(){var t=sh(),n=t.firstChild;return z(n,U(L,{get when(){return e.preparedRecents?.length},get fallback(){var t=dh();return z(t,U(go,{get each(){return gt(e.operatorAuth)},children:t=>(()=>{var n=fh();return n._$$click=()=>{e.onDraftChange(N(t)),e.onSend()},z(n,()=>N(t)),n})()})),t},get children(){var t=oh(),n=t.firstChild;return z(n,()=>N(`chat.welcome.recentSessions`)),z(t,U(go,{get each(){return e.preparedRecents},children:t=>(()=>{var n=ph(),r=n.firstChild,i=r.nextSibling;return n._$$click=()=>e.onOpenSession?.(t.key),z(r,()=>t.name),z(n,U(L,{get when(){return t.subtitle},children:e=>(()=>{var t=mh();return z(t,e),t})()}),i),z(i,()=>oi(t.updatedAt,{fallback:``})),n})()}),null),t}})),W(()=>({e:!!e.fadeSecondaryContent,t:e.fadeSecondaryContent?`true`:`false`,a:e.fadeSecondaryContent}),({e,t:n,a:r},i)=>{e!==i?.e&&t.classList.toggle(`agent-chat__welcome-secondary--hidden`,e),n!==i?.t&&V(t,`aria-hidden`,n),r!==i?.a&&V(t,`inert`,r)}),t}}),u),W(()=>({e:e.assistantName||N(`chat.messages.agentName`),t:Mo(e.assistantNameControl?`sr-only`:void 0)}),({e,t},n)=>{e!==n?.e&&V(i,`aria-label`,e),jo(o,t,n?.t)}),n}})}var ih,ah,oh,sh,ch,lh,uh,dh,fh,ph,mh;function hh(){return(hh=e((()=>{K(),R(),ar(),mi(),Oc(),Tn(),Or(),M(),lo(),ih=q(`<div class=agent-chat__welcome-name>`),ah=q(`<p class=agent-chat__hint>`),oh=q(`<div class=agent-chat__recents><div class=agent-chat__recents-title>`),sh=q(`<div class=agent-chat__welcome-secondary><div class=agent-chat__welcome-secondary-inner>`),ch=q(`<div class=agent-chat__welcome style=--agent-color:var(--accent)><div class=agent-chat__welcome-identity><span class=agent-chat__welcome-avatar role=img></span><div class=agent-chat__welcome-identity-copy><h2></h2><!><!></div></div><!><!>`),lh=q(`<button class="btn primary"type=button>`),uh=q(`<div class="agent-chat__welcome agent-chat__welcome--setup"role=alert><div class=agent-chat__welcome-clawd aria-hidden=true><openclaw-mascot mood=idle></openclaw-mascot></div><h2></h2><p class=agent-chat__hint>`,1),dh=q(`<div class=agent-chat__suggestions>`),fh=q(`<button type=button class=agent-chat__suggestion>`),ph=q(`<button type=button class=agent-chat__recent><span class=agent-chat__recent-name></span><span class=agent-chat__recent-time>`),mh=q(`<span class=agent-chat__recent-sub>`),vt(),Po([`click`])})))()}function gh(e){let t=I(()=>e.sessions),n=I(()=>{let e=t();return e?Hn(e,e=>e.state.result):void 0}),r=bt(),i=un(()=>r),a=()=>i.options(e.options),o=I(()=>({sessionKey:a().sessionKey,defaultAgentId:Ce(a().sessionHost??{})}),{equals:(e,t)=>e.sessionKey===t.sessionKey&&e.defaultAgentId===t.defaultAgentId}),s=I(()=>a().hideSecondaryContent||a().modelSetupRequired),c=I(()=>!s()&&!a().fadeSecondaryContent),l=In(()=>{if(s())return[];Dn();let e=o();return Re(n()?.read(),e.sessionKey,e.defaultAgentId)},c);return U(rh,bo(a,{get assistantNameControl(){return e.assistantNameControl},get composer(){return B(()=>!!i.active())()?i.step():e.composer},get preparedRecents(){return l()}}))}function _h(){return(_h=e((()=>{K(),R(),co(),$t(),M(),Gn(),Rn(),_(),lo(),hh()})))()}function vh(e,t,n,r){t.draftPersistence.persistNow();let i=e?.gateway.snapshot.client;if(!e||!i||t.submitting||t.pendingPlacement.sessionKey)return;let a=n??Wc(window.location.search);e.chatAttachmentHandoff.prepare({reviewPrivateDraft:mn,owner:i,paneId:Sh,scopeKey:a,message:r===a?t.message:``,mentions:r===a?t.mentions:void 0,newSessionDraft:t.draftPersistence.captureSubmission(),attachments:t.attachmentDraft.take(),fallbacks:{}})}function yh(e,t,n,r,i){let a=e?.gateway.snapshot.client;e&&a?.recoveryScopeReady&&t.draftPersistence.setOwner(e.gateway.connection.gatewayUrl,a.recoveryScope,!0),t.draftPersistence.selectRoute(n);let o=e&&a?e.chatAttachmentHandoff.consume({owner:a,paneId:Sh,scopeKey:n}):null;return o?(t.restoreDraftState({message:r||o.message||``,mentions:r?i:o.mentions,attachments:o.attachments,visibility:o.newSessionDraft?.incognito?`incognito`:t.visibility}),!r&&o.newSessionDraft&&t.draftPersistence.adoptHandoff(o.newSessionDraft)):r&&t.restoreMessage(r,i),bh(t,n),n}function bh(e,t){e.pendingPlacement.sessionKey||e.draftPersistence.activateRoute(t)}function xh(e,t,n){e.restorePendingPlacementRecovery(t,n),e.draftPersistence.setOwner(t,n,!!e.pendingPlacement.sessionKey)}var Sh;function Ch(){return(Ch=e((()=>{dr(),Q(),Sh=`new-session-draft`})))()}var wh;function Th(){return(Th=e((()=>{Te(),ue(),ea(),O(),ra(),d(),ma(),ao(),_(),_d(),Rc(),Q(),Vc(),wd(),Ch(),jf(),Zd(),wh=class{get submissionLifetime(){return this.submissionLifetimeValue.promise}submit(e=!1){let t=this.submissionLifetime,n=this.submission.composerTextarea.getTextarea(),r=e&&this.host.ownerDocument.activeElement===n,i=async()=>{await this.submission.submit(void 0,e),r&&this.submissionLifetime===t&&(this.host.ownerDocument.activeElement===n||this.host.ownerDocument.activeElement===this.host.ownerDocument.body)&&this.focusComposer()};return!e&&this.presentSubmit?this.presentSubmit(i):i()}get data(){return this.host.data}constructor(e){this.host=e,this.submissionLifetimeValue=Promise.withResolvers(),this.retireSubmissionPresentation=()=>{this.submissionLifetimeValue.resolve(),this.submissionLifetimeValue=Promise.withResolvers(),this.listeners.publish()},this.listeners=oe(),this.contextSubscriptions=[],this.isConnected=!1,this.pendingChange=!1,this.changed=()=>{!this.pendingChange&&this.isConnected&&(this.pendingChange=!0,queueMicrotask(()=>{try{this.isConnected&&(this.synchronize(),this.titlePreparation?.synchronize())}finally{this.pendingChange=!1}})),this.listeners.publish()},this.subscribe=this.listeners.subscribe,this.retainedForHandoff=null,this.openedFor=null,this.openedGroupDefaults=``,this.openedAgentId=``,this.messageOwnerKey=``,this.attachmentPanel=null,this.closeAttachmentPanel=()=>{this.attachmentPanel&&(this.attachmentPanel=null,this.changed())},this.openAttachmentPanel=e=>{e.kind===`attachment`&&(this.attachmentPanel={content:e,ownerKey:this.routeOwnerKey(),agentId:this.place.agentId},this.changed())},this.imageLightbox=null,this.readAgentIdentityTargets=()=>[],this.dictationError=null,this.flushDraft=()=>this.submission.draftPersistence.persistNow(),this.setImageLightbox=e=>{this.imageLightbox=e,this.changed()},this.draft=new Af(()=>({context:this.context,data:this.data,isConnected:this.isConnected}),{changed:this.changed,activeElement:()=>this.host.ownerDocument.activeElement,onInvalidate:()=>{this.retireSubmissionPresentation(),this.closeAttachmentPanel(),this.connectMachine?.close()},onRecoveryReady:(e,t)=>xh(this.submission,e,t),closeTransientUi:()=>{this.closeAttachmentPanel(),this.draft.browser.close(),or(this.host)},takePreparedTitle:()=>this.titlePreparation?.takePreparedTitle(),onAccepted:e=>Pc(()=>this.context,e),updateComplete:()=>this.host.updateComplete,retainForHandoff:()=>{if(!this.data||!this.isConnected)return;let e={};return this.retainedForHandoff=e,{page:this.host,data:this.data,synchronizeGateway:()=>{this.context&&this.gateway.synchronize(this.context.gateway)},release:()=>{this.retainedForHandoff===e&&(this.retainedForHandoff=null,this.isConnected||this.disposeDraft())}}}}),this.gateway=this.draft.gateway,this.browser=this.draft.browser,this.place=this.draft.place,this.submission=this.draft.submission,this.connectMachine=new Bc(()=>({client:this.gateway.client,connected:this.gateway.connected}),this.changed),this.dictation=new gd({textarea:this.submission.composerTextarea,getClient:()=>this.gateway.client,prepareSession:()=>this.submission.sessionStartup.prepareDictationSession(),getSessionKey:()=>this.submission.sessionStartup.dictationSessionKey(),isConnected:()=>this.gateway.connected,canCommit:()=>!this.submission.submitting&&!this.submission.pendingPlacement.sessionKey,onMessage:e=>this.setMessageFromUser(e),onError:e=>{this.dictationError=e,this.changed()},onSubmit:()=>void this.submit()});let t=!1;this.dictation.subscribe(()=>{let e=this.dictation.dictation?.connecting===!0;e&&!t&&(this.dictationError=null),t=e,this.changed()})}focusComposer(){let e=this.context,t=this.routeOwnerKey(),n=document.activeElement;this.host.updateComplete.then(()=>{this.isConnected&&!this.retainedForHandoff&&this.context===e&&this.routeOwnerKey()===t&&(document.activeElement===n||document.activeElement===document.body)&&!document.openClawModalLayers?.size&&Bi(this.submission.composerTextarea.getTextarea(),{preventScroll:!0})})}connect(){if(!this.isConnected){this.isConnected=!0;try{let e=this.context;if(e){this.contextSubscriptions=[e.theme,e.agents,e.agentIdentity,e.placementStartup,e.runtimeConfig,e.config].map(e=>e.subscribe(this.changed));let t=e.router.getState().location;this.contextSubscriptions.push(e.router.subscribe(e=>{e.location!==t&&(t=e.location,this.retireSubmissionPresentation(),this.browser.close())}))}this.draft.connect(),this.submission.draftPersistence.connect(),this.changed()}catch(e){throw this.disconnect(),e}}}disconnect(){if(this.retireSubmissionPresentation(),this.isConnected){this.isConnected=!1,this.browser.close();for(let e of this.contextSubscriptions.splice(0))e();this.closeAttachmentPanel(),this.dictation.dispose(),this.connectMachine.close(),this.retainedForHandoff||this.disposeDraft()}}disposeDraft(){try{Kd(this.data,this.host),vh(this.context,this.submission,this.openedFor,this.messageOwnerKey)}finally{this.draft.disconnect()}}synchronize(){this.draft.synchronize();let e=this.attachmentPanel;e&&(e.ownerKey!==this.routeOwnerKey()||e.agentId!==this.place.agentId||this.submission.submitting||this.submission.pendingPlacement.sessionKey||!this.submission.attachmentDraft.attachments.some(t=>t.id===e.content.sourceIdentity))&&this.closeAttachmentPanel(),this.connectMachine.open&&!this.place.isAdmin()&&this.connectMachine.close(),this.gateway.retryPendingCatalogTarget(),this.context?.agentIdentity.ensure([...new Set([this.place.agentId,...this.readAgentIdentityTargets()])]);let t=this.draft.agentsReady();this.place.modelControl.loadCatalogTargets(this.context,t&&this.place.agentId?this.place.selectedAgent()?.id??``:``,this.context?.config.current.cliAgentsEnabled===!0&&!A(this.data));let n=this.routeOwnerKey(),r=this.data?.agentId??``,i=Jc(this.data);if(this.openedFor!==n){this.openedFor!==null&&this.submission.visibility===`incognito`&&vh(this.context,this.submission,this.openedFor,this.messageOwnerKey);let e=this.messageOwnerKey===n?this.submission.message:``,a=this.messageOwnerKey===n?this.submission.mentions:void 0;this.openedFor=n,this.openedGroupDefaults=i,this.openedAgentId=r,this.place.agentsHydrated=t,this.resetDraft(),this.messageOwnerKey=yh(this.context,this.submission,n,e,a),this.focusComposer()}else this.openedGroupDefaults!==i&&(this.openedGroupDefaults=i,this.place.adoptGroupDefaults()),this.openedAgentId!==r&&(this.openedAgentId=r,this.place.agentsHydrated=!1),this.draft.synchronizeSelections(),bh(this.submission,n),this.submission.synchronizeSubmission()}resetDraft(){this.retireSubmissionPresentation(),this.place.resetDraft(),this.submission.resetDraft(),this.messageOwnerKey=Uc(this.data),this.agentPicker&&or(this.agentPicker),this.browser.close(),this.connectMachine.close(),this.place.adoptAgentDefaults()}routeOwnerKey(){return this.data?Uc(this.data):Wc(window.location.search)}setMessageFromUser(e,t){!this.submission.submitting&&!this.submission.pendingPlacement.sessionKey&&(this.submission.setMessage(e,t),this.messageOwnerKey=Wc(window.location.search))}openConnectMachine(){this.place.isAdmin()&&(this.browser.close(),this.connectMachine.start())}composerOptions(){let{context:e,gateway:t,place:n,submission:r,dictation:i}=this,a=this.routeOwnerKey(),o=A(this.data),s=r.capabilities,c=e?.theme.settings,l=i.active;return{agent:n.selectedAgent(),agentId:n.agentId,attachmentDraft:r.attachmentDraft,draftSource:r.composerDraft,canSubmit:!r.submitting&&!l&&r.canSubmit(),submitDisabledReason:r.submitDisabledReason(),onBlockedSubmit:()=>r.noteBlockedSubmitAttempt(),get dictationActive(){return i.active},dictationPreview:i.previewDraft(),dictationError:this.dictationError,context:e,isCatalogTarget:o,draftOwnerKey:a,commandProjectId:Sd(n),get message(){return r.message},mentions:r.mentions,getMentions:()=>r.mentions,...s.composerProps(e,t,n.agentId),modelControl:n.modelControl,requiresModifier:c?.chatSendShortcut===`modifier-enter`,onChange:this.changed,get submitting(){return r.submitting},chatMessageMaxWidth:c?.chatMessageMaxWidth,onComposerWidthChange:e=>te({chatMessageMaxWidth:e}),get messageLocked(){return!!r.pendingPlacement.sessionKey},nativeTerminal:o,onUnsupportedAttachment:()=>r.setError(E(`newSession.terminalAttachmentsUnsupported`)),onInput:(e,t)=>this.setMessageFromUser(e,t),onOpenImage:this.setImageLightbox,onOpenSidebar:this.openAttachmentPanel,onSubmit:()=>void this.submit(),onBackgroundSubmit:r.visibility===`draft`||o?void 0:()=>void this.submit(!0)}}welcomeHint(){return E(A(this.data)?`newSession.nativeTerminalHint`:this.place.requiredPlacement?`newSession.requiredWorkerHint`:`newSession.hint`)}welcomeOptions(){let e=this.place.selectedAgent(),t=this.context?.agentIdentity.get(this.place.agentId),n=this.context?.gateway.snapshot;return{currentAgentId:this.place.agentId,assistantName:e?Ur(e,t):``,assistantAvatar:ro(e??{},t),assistantAvatarUrl:b(e??{},t),hint:this.welcomeHint(),hideSecondaryContent:this.submission.visibility===`incognito`,fadeSecondaryContent:this.submission.message.trim().length>0,modelSetupRequired:this.submission.requiresModelSetup(),onModelSetup:()=>this.context?.navigate(`model-setup`),sessionKey:ie({agentId:this.place.agentId||`main`,mainKey:this.context?.agents.state.agentsList?.mainKey}),sessionHost:{assistantAgentId:n?.assistantAgentId??null,agentsList:this.context?.agents.state.agentsList??null,hello:n?.hello??null},operatorAuth:n?.hello?.auth??null,onDraftChange:e=>this.setMessageFromUser(e),onSend:()=>void this.submit(),onOpenSession:e=>{let{context:t,submission:n}=this;!t||n.submitting||n.pendingPlacement.sessionKey||(Nr({selection:t.agentSelection,gateway:t.gateway,sessionKey:e,agentId:this.place.agentId}),t.navigate(`chat`,ot({context:t,face:`chat`,sessionKey:e}).options))}}}}})))()}function Eh(e){return U(L,{get when(){return qd(e.data)},get fallback(){var t=jh();return t._$owner=wo(),W(()=>e.data,e=>{t.data=e}),t},keyed:!0,children:e=>e})}function Dh(e){let t=()=>e.page().place,n=()=>e.page().submission;return U(L,{get when(){return t().agents().length>1},get children(){return U(zp,{ref:t=>{e.page().agentPicker=t,e.ref?.(t)},get params(){return{agents:t().agents(),agentId:t().agentId,agentIdentity:e.page().context?.agentIdentity,disabled:n().submitting||!!n().pendingPlacement.sessionKey,onSelect:e=>t().selectAgentId(e),identityTargetsRef:t=>{e.page().readAgentIdentityTargets=t},onIdentityTargetsChange:()=>e.page().changed()}}})}})}function Oh(e){let t=()=>e.page().submission,n=()=>e.page().place,r,i,a,o=()=>[],s=()=>[],c=()=>r?{root:r,obstacles:[i,...o(),...s(),...t().visibility===`incognito`?[a]:[]].filter(e=>e?.isConnected===!0)}:void 0,l=I(()=>({context:e.page().context,data:e.page().data,gateway:e.page().gateway,place:n(),submitting:t().submitting,pendingPlacement:!!t().pendingPlacement.sessionKey,onConnectMachine:()=>e.page().openConnectMachine(),onNavigate:(t,n)=>e.page().context?.navigate(t,n),onFocusComposer:()=>Bi(t().composerTextarea.getTextarea(),{preventScroll:!0}),onChange:()=>e.page().changed()})),u=U(L,{get when(){return!A(e.page().data)},get children(){return U(Vi,{get canSelectFull(){return n().isAdmin()},get defaultMode(){return n().selectedAgent()?.newSessionPermissionMode??n().selectedAgent()?.defaultPermissionMode},get disabled(){return t().submitting||!!t().pendingPlacement.sessionKey},get disabledReason(){return B(()=>!!t().submitting)()?N(`newSession.starting`):void 0},get mode(){return t().permissionMode},onSelect:e=>t().setPermissionMode(e??void 0)})}}),d=U(Xe,{readDictation:()=>e.page().dictation.dictation}),f=U(Zp,{get control(){return e.page().dictation},get ownerKey(){return e.page().routeOwnerKey()},get inputDeviceId(){return e.page().context?.theme.settings.realtimeTalkInputDeviceId},get idleLabel(){return N(`newSession.dictate`)},get renderRevision(){return e.revision()}});var p=Nh(),m=p.firstChild,h=m.nextSibling,g=h.nextSibling,_=g.nextSibling,v=_.nextSibling,y=v.nextSibling,b=y.nextSibling;return p._$$focusout=()=>e.page().titlePreparation?.setComposing(!1),p.addEventListener(`compositionend`,()=>e.page().titlePreparation?.setComposing(!1)),p.addEventListener(`compositionstart`,()=>e.page().titlePreparation?.setComposing(!0)),G(()=>e=>{r=e},p),z(p,U(lm,{ref:e=>{o=e},get data(){return e.page().data},get groupPending(){return Yc(e.page().data,e.page().context?.sessions)},get retrying(){return e.page().gateway.catalogRetrying||!!(e.page().data?.group&&e.page().context?.sessions.groupsStatus()===`loading`)},get retryRead(){return e.page().gateway.catalogRetryRead},onRetry:()=>e.page().gateway.handleCatalogRetry(),get agentSelect(){return U(L,{get when(){return!!e.page().submission.completedSubmission},get children(){return U(Dh,{get page(){return e.page},ref:e=>{i=e}})}})},placeSelect:null}),m),z(p,U(L,{get when(){return B(()=>!!n().worktree)()?!df(n().worktreeName):n().worktree},get children(){return U(em,{get message(){return N(`newSession.worktreeNameInvalid`)}})}}),h),z(p,U(L,{get when(){return B(()=>!!A(e.page().data))()?t().capabilities.toolOverrides:A(e.page().data)},get children(){return U(em,{get message(){return N(`newSession.terminalCapabilityOverridesUnsupported`)},get action(){return{label:N(`common.reset`),onClick:()=>t().capabilities.setToolOverrides(null)}}})}}),g),z(p,U(L,{get when(){return t().submissionOutcomeUnknown},get children(){return U(em,{get message(){return N(t().submissionOutcomeUnknown===`gateway-changed`?`newSession.createOutcomeUnknown`:`newSession.placementSetupInterrupted`)},get action(){return B(()=>!!t().pendingPlacement.sessionKey)()?{label:N(`common.reset`),onClick:()=>t().clearPendingPlacementRecovery()}:void 0}})}}),_),z(p,U(Am,{get contextControls(){var e=Ph();return z(e,U(Io,{get fallback(){return U(rp,{tray:!0,get checkout(){return n().checkoutVisible}})},get children(){return U(Vp,{get params(){return l()},ref:e=>{s=e}})}})),e},surroundings:c,get options(){return Object.assign(e.options(),{permissionControl:u,dictationStatus:d,voiceControl:f})}}),v),z(p,U(L,{get when(){return t().blockedSubmitNotice()},get children(){var e=Mh(),n=e.firstChild.firstChild,r=n.nextSibling;return z(n,U(P,{name:`info`})),z(r,()=>t().blockedSubmitNotice()),e}}),y),z(p,U(L,{get when(){return!A(e.page().data)},get children(){return U(Vm,{get active(){return t().visibility===`incognito`},ref:e=>{a=e}})}}),b),W(()=>e.submitting?`true`:`false`,e=>{V(p,`aria-busy`,e)}),p}function kh(e,t){let n=bt(),r=()=>Ah(t,e),i=e=>(H(()=>{let e=!0;return n&&!Hh.has(t)&&dn(Vr(n.gateway,()=>e&&t.isConnected)),()=>{e=!1}}),U(Ta,{get error(){return e.error},get onRetry(){return e.reset}}));return U(_a,{get children(){return U(To,{fallback:(e,t)=>U(i,{get error(){return e()},reset:t}),get children(){return U(r,{})}})}})}function Ah(e,t){let n=Vh.get(e)??new wh(e);Vh.set(e,n),n.context=bt();let r=Hn(n,e=>e),i=r.read,a=()=>i().isConnected,o=n.context,s=o?Hn(o.sessions,e=>({defaults:Object.entries(e.state.result?.defaults??{}),groupStatus:e.groupsStatus(),petMode:us(!o.gateway.snapshot.offlineStable,e.state.result?.sessions),runOutcome:os(e.state.result?.sessions)}),(e,t)=>e.groupStatus===t.groupStatus&&e.petMode===t.petMode&&e.runOutcome===t.runOutcome&&e.defaults.length===t.defaults.length&&e.defaults.every(([e,n],r)=>e===t.defaults[r]?.[0]&&n===t.defaults[r]?.[1])):void 0;H(()=>s?.subscribe(n.changed)),H(()=>(n.connect(),()=>n.disconnect()));let c=I(()=>({value:r.revision()})),l=I(()=>i().submission.error),u=Jf(()=>n,r.revision,l,e=>n.submission.setError(j(e)));H(()=>{let e=th(()=>({context:n.context,data:n.data,place:n.place,submission:n.submission,dictating:n.dictation.active}));return n.titlePreparation=e,e.synchronize(),()=>{e.dispose(),n.titlePreparation===e&&(n.titlePreparation=void 0)}});let d=I(()=>i().composerOptions()),f=()=>U(hm,{get value(){return n.submission.composerTextarea},get children(){return U(Oh,{page:i,revision:c,options:d,get submitting(){return u()||i().submission.submitting}})}});H(()=>{let t=e.ownerDocument,r=e=>{e.target instanceof Element&&e.target.closest(`.chat-composer-model-control`)||(i.forEach(e=>e()),Bh())},i=[`pointerdown`,`keydown`].map(t=>w(e,t,r,!0)),a=[nt(t),w(t,`keydown`,t=>Ke(e,t,n.submission.composerTextarea.getTextarea()),!0),w(t.defaultView,`beforeunload`,n.flushDraft),...i];return()=>a.forEach(e=>e())});let p=Qr(Ym),[m,h]=ho(!1),g={get visibility(){return i().submission.visibility},get submitting(){return i().submission.submitting},get pendingPlacement(){return i().submission.pendingPlacement},incognitoDisabledReason:()=>i().submission.incognitoDisabledReason(),setVisibility:e=>{n.submission.setVisibility(e),h(n.submission.visibility===`incognito`&&p.read())}},_=()=>i().submission.completedSubmission,v=I(()=>{let e=i().submission,t=e.creationComposer;return e.pendingMessage||t?.hasInput?t:void 0}),y=()=>{let e=i().context?.gateway.snapshot.selfUser?.identity;return e?.type===`profile`?e.id:null},b=()=>{let e=_();if(!e)return;let t=i().context?.placementStartup.get(e.key);return{label:e.error??t?.error??$i(null,t)??N(`newSession.created`),onOpen:()=>void n.submission.openSubmittedSession(),disabled:i().context?.gateway.snapshot.phase!==`connected`}},x=()=>Kr(e.closest(`.shell--onboarding`)!==null),[S,ee]=ho(x());H(()=>w(e.ownerDocument.defaultView,`resize`,()=>ee(x())));let te=()=>i().attachmentPanel,ne=()=>i().imageLightbox,C=()=>{let e=te();return e?{...e.content}:null};return U(L,{get when(){return a()},children:r=>{let a=mo(()=>U(L,{get when(){return B(()=>!A(i().data))()&&i().place.agents().length>1},get children(){return U(Dh,{page:i})}})),o=mo(()=>U(L,{get when(){return!A(i().data)},get fallback(){return i().welcomeHint()},get children(){return U(Hm,{get hint(){return i().welcomeHint()},get noteOpen(){return m()},onNoteOpenChange:h})}}));return H(()=>{Hh.add(e)}),[(()=>{var e=Fh(),r=e.firstChild,s=r.nextSibling,c=s.nextSibling,p=c.nextSibling,m=p.nextSibling,h=m.nextSibling,x=h.nextSibling;return z(e,U(L,{get when(){return S()},get children(){return U(Zm,{page:i,shell:t,submission:g})}}),r),z(e,U(ka,{get context(){return i().context},surface:`new-session`}),s),z(e,U(L,{get when(){return B(()=>!S())()&&!A(i().data)},get children(){return U(Bm,{submission:g,get draftAvailable(){return i().submission.capabilities.canStartAsDraft(i().context)}})}}),c),z(e,U(tm,{get error(){return l()},get pendingMessage(){return i().submission.pendingMessage},get userId(){return y()},get submitting(){return u()||i().submission.submitting},get statusLabel(){return B(()=>i().context?.gateway.snapshot.phase===`connected`)()?void 0:N(`connection.reconnecting`)},get completion(){return b()},get showDraft(){return!!_()},renderDraft:()=>U(L,{get when(){return!!_()},get fallback(){return U(gh,{get sessions(){return i().context?.sessions},get options(){return{...i().welcomeOptions(),hint:o()}},get assistantNameControl(){return a()},get composer(){return U(f,{})}})},get children(){return U(f,{})}}),get onOpenImage(){return n.setImageLightbox}}),p),z(e,U(L,{get when(){return v()},children:e=>U(To,{fallback:(e,t)=>U(Ta,{get error(){return e()},onRetry:t,inline:!0}),get children(){return U(Io,{get fallback(){return U(Wi,{})},get children(){return U(Rh,{get composer(){return e()},get onOpenImage(){return n.setImageLightbox}})}})}})}),m),z(e,U(Pf,bo(()=>i().connectMachine.view(i().place.isAdmin(),()=>{n.connectMachine.close(),n.context?.navigate(`devices`)}))),h),z(e,U(yr,{get item(){return ne()},onClose:()=>n.setImageLightbox(null)}),x),W(()=>({e:!!i().submission.pendingMessage,t:i().submission.visibility===`incognito`,a:!!S(),o:d().chatMessageMaxWidth??`48rem`}),({e:t,t:n,a:r,o:i},a)=>{t!==a?.e&&e.classList.toggle(`chat`,t),n!==a?.t&&e.classList.toggle(`new-session-page--incognito`,n),r!==a?.a&&e.classList.toggle(`new-session-page--chat-header`,r),i!==a?.o&&Fo(e,`--chat-thread-max-width`,i)}),e})(),U(L,{get when(){return te()},children:e=>{let t=mo(()=>U(zh,{get content(){return C()},get"onChat-detail-panel-close"(){return n.closeAttachmentPanel}})),r=()=>(()=>{var e=Ih();return z(e,()=>N(`common.loading`)),e})();var i=Lh();return z(i,U(To,{fallback:(e,i)=>{let a=!0,[o,s]=ho(!1),c=qa(e()),l=()=>a&&n.isConnected&&n.attachmentPanel!==null;H(()=>()=>{a=!1,c&&eo()});let u=async()=>{l()&&(s(!0),!(c&&await Ve({canReload:l}))&&l()&&(s(!1),i()))};return U(L,{get when(){return B(()=>!o())()&&!Eo(t)},get fallback(){return r()},get children(){return U(Ta,{get error(){return e()},stale:c,onRetry:()=>void u(),get onClose(){return n.closeAttachmentPanel}})}})},get children(){return U(Io,{get fallback(){return r()},get children(){return t()}})}})),i}})]}})}var jh,Mh,Nh,Ph,Fh,Ih,Lh,Rh,zh,Bh,Vh,Hh;function Uh(){return(Uh=e((()=>{K(),R(),Kn(),Pr(),sr(),Ti(),fs(),ar(),Ui(),F(),ua(),va(),Z(),ma(),k(),$t(),M(),Gr(),Rn(),Ft(),Gt(),Ca(),ha(),bn(),Yt(),Qp(),mm(),Q(),gm(),Lm(),Bf(),pf(),sm(),$m(),nh(),_h(),Xm(),Zd(),Th(),lp(),Yf(),Xp(),r(),jh=q(`<openclaw-new-session-page>`,1),Mh=q(`<div class="new-session-page__blocked-submit agent-chat__composer-status"data-tone=info role=status><div class=agent-chat__composer-status-band><span class=agent-chat__composer-status-icon aria-hidden=true></span><span class=agent-chat__composer-status-text>`),Nh=q(`<div class=new-session-page__draft><!><!><!><!><!><!><!>`),Ph=q(`<div class=new-session-page__triggers>`),Fh=q(`<div class=new-session-page><!><!><!><!><!><!><!>`),Ih=q(`<div role=status>`),Lh=q(`<aside class=new-session-attachment-panel>`),X(),Rh=Oo(()=>v(()=>import(`./creation-composer-render-DL-0_oYL.js`).then(e=>(e.r(),e.n)),__vite__mapDeps([5,4,6,7,8,9,0,3,10]),import.meta.url),{export:`CreationComposer`},`src/pages/new-session/creation-composer-render.tsx`),zh=Oo(async()=>(await v(()=>import(`./control-ui-boot-chat-styles-DMRbEm40.js`).then(e=>(e.g(),e._)),__vite__mapDeps([4,7,8,9,0,3,10]),import.meta.url),v(()=>import(`./chat-detail-panel-DgSCl_Hb.js`),__vite__mapDeps([4,18,6,7,8,9,5,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,0,3,10,35,36]),import.meta.url)),{export:`ChatDetailPanel`}),Bh=()=>{om(),Rh.preload().catch(()=>void 0)},Vh=new WeakMap,Hh=new WeakSet,ci(`openclaw-new-session-page`,kh,{properties:{data:{default:void 0,attribute:!1},navDrawerOpen:{default:!1,attribute:!1},gatewayStatus:{default:null,attribute:!1}},propertyChanged:(e,t)=>{if(t!==`data`)return;let n=Vh.get(e);n?.retireSubmissionPresentation(),n?.browser.close(),n?.changed()},disconnected:e=>{let t=Vh.get(e);t?.retireSubmissionPresentation(),t?.browser.close()},methods:{focusComposer:e=>Vh.get(e)?.focusComposer()}}),Po([`focusout`])})))()}var Wh=t({load:()=>Gh});async function Gh(e,t,n){let r=n&&n!==`preload`&&Gd(e,t);if(r)return r;let i=Bo(t),a=``,o=!1,s;if(i.group){let t=await e.sessions.groupsLoad(),n=t?.find(e=>e.name===i.group);s=t===null?`unavailable`:n?`resolved`:`missing`,a=n?.cwd??``,o=n?.worktree===!0}let c={...i,requestedAgentId:i.agentId,groupStatus:s,groupCwd:a,groupWorktree:o,catalogLabel:``,startTerminal:!1};if(!i.catalogId)return c;let l=(e=``)=>({...c,agentId:e}),u=e.gateway.snapshot,d=e.agents.state;if(u.phase!==`connected`||!u.client||!d.connected||d.client!==u.client)return l();let f=d.agentsList??await e.agents.ensureList(),p=e.gateway.snapshot,m=e.agents.state;if(p.phase!==`connected`||!p.client||p.client!==u.client||!m.connected||m.client!==p.client||!f||m.agentsList!==f)return l();let h=ki(f.agents),g=h.some(e=>e.id===f.defaultId)?f.defaultId:h[0]?.id,_=g?Qc(i,h,g):``,v=l(_);if(!_)return v;let y=await el(p,i.catalogId,_);return y?{...v,...y}:v}function Kh(){return(Kh=e((()=>{ra(),Q(),Zd(),Yo()})))()}export{au as $,Bf as A,kc as At,uf as B,Ws as Bt,Yf as C,Bc as Ct,Hf as D,Rc as Dt,Gf as E,X as Et,Cf as F,ic as Ft,gd as G,Ls as Gt,Hd as H,Rs as Ht,_f as I,Zs as It,Wu as J,hd as K,js as Kt,pf as L,Xs as Lt,Mf as M,Qs as Mt,Af as N,J as Nt,Uf as O,Pc as Ot,jf as P,Ys as Pt,lu as Q,df as R,Js as Rt,Jf as S,al as St,Kf as T,Z as Tt,bd as U,Vs as Ut,Vd as V,Hs as Vt,xd as W,As as Wt,Gu as X,Hu as Y,cu as Z,lp as _,bl as _t,tm as a,nu as at,Zf as b,sl as bt,Qp as c,Jl as ct,Xp as d,Il as dt,ou as et,Sp as f,Pl as ft,np as g,wl as gt,rp as h,Nl as ht,Uh as i,eu as it,Nf as j,Oc as jt,Pf as k,Ac as kt,zp as l,Wl as lt,Pp as m,Ml as mt,Wh as n,ru as nt,sm as o,Xl as ot,wp as p,Fl as pt,_d as q,Eh as r,su as rt,Zp as s,ql as st,Kh as t,iu as tt,Bp as u,Kl as ut,Qf as v,yl as vt,Wf as w,Vc as wt,qf as x,ol as xt,$f as y,il as yt,lf as z,Ks as zt};