openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1,936 lines • 351 kB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./user-prefs-request-Cs35VjAf.js","./session-snapshot-database-BBKeXATO.js","./control-ui-core-DI-Q_yCI.css","./control-ui-boot-shared-gZIpWrfw.js","./control-ui-boot-shared-SQHdJTzb.js","./plugin-contracts-runtime-ByiEPbv_.js","./config-runtime-BecGLziM.js","./markdown-runtime-ORQpioyT.js","./sidebar-update-runtime-DQZboSgD.js","./control-ui-boot-shared-styles-DUf4zEvn.css","./control-ui-boot-shared-DIWJGbGi.css","./sidebar-update-runtime-Bpn2ByHA.css","./chat-detail-panel-DYod9DCg.js","./control-ui-boot-chat-CGYcTLro.js","./control-ui-boot-chat-Ye5j4vAg.js","./control-ui-boot-chat-CmENwCKi.js","./control-ui-boot-chat-XPUNenUd.js","./control-ui-boot-chat-k_u3nGjS.js","./control-ui-boot-chat-styles-BcslGtWC.js","./control-ui-boot-chat-B-b-JQel.js","./control-ui-boot-chat-BD9CwLj7.js","./chat-transcript-styles-B0IJwY9P.css","./control-ui-boot-chat-styles-SRk09zDG.css","./control-ui-boot-chat-C2DT0d4M.css","./control-ui-boot-chat-DhbON6pC.css"])))=>i.map(i=>d[i]);
import{n as e,r as t}from"./rolldown-runtime-8BhlS34s.js";import{$t as n,Ct as r,Gu as i,Hr as a,Ic as o,Ku as s,Lc as c,Nu as l,Ps as u,Pu as d,Qt as f,St as p,V as m,Vr as h,W as g,Wc as _,Wu as v,X as y,Xc as b,_u as x,ac as S,ar as ee,cu as te,eu as ne,fl as re,fu as ie,g as ae,h as oe,hl as se,iu as ce,jt as le,ju as ue,kl as C,kt as de,lc as fe,ll as pe,lu as me,m as he,nc as ge,or as _e,ou as ve,p as ye,rt as be,sn as xe,uc as Se,ul as Ce,uu as we,vu as Te,wl as Ee,wt as De,xu as Oe,yu as ke,z as Ae,zu as w}from"./control-ui-core-CBJ5efDh.js";import{$n as je,Ai as Me,At as Ne,Ca as Pe,Cr as Fe,Ei as Ie,Fi as Le,Ft as Re,Gn as ze,Jt as Be,Kn as Ve,Lt as He,Sa as Ue,Ti as We,To as Ge,Tr as Ke,Ui as qe,Vi as Je,Xi as Ye,Zi as Xe,ca as T,di as Ze,dr as Qe,er as $e,fi as et,go as tt,hn as nt,ki as rt,la as it,mr as at,pr as ot,qi as st,qr as ct,qt as lt,sa as E,ua as D,ur as ut,wn as dt,wr as ft,yr as pt,zi as mt}from"./control-ui-core-DtLivg_r.js";import{E as ht,G as O,J as k,W as A,X as j,Z as gt,_ as _t,at as M,i as vt,k as yt,n as bt,o as xt,rt as N,t as St,y as Ct}from"./lit-runtime-IOnANfcZ.js";import{Fn as wt,Jt as Tt,Nn as Et,Pn as Dt,nr as Ot}from"./control-ui-boot-shared-CkXlyZBY.js";import{c as kt,d as At,l as jt}from"./gateway-runtime-C77LeWZN.js";import{$ as Mt,$i as Nt,B as Pt,Di as Ft,Dt as It,Ea as Lt,Ei as Rt,It as zt,K as Bt,Lr as Vt,Ma as Ht,Ot as Ut,T as Wt,U as Gt,Z as Kt,b as qt,ct as Jt,da as Yt,di as Xt,et as Zt,ga as P,ha as F,ii as Qt,ja as $t,ka as en,ma as tn,na as nn,ot as rn,pa as an,q as on,st as sn,tt as cn,v as ln,zr as un,zt as dn}from"./control-ui-boot-shared-UG5ko-VG.js";import{Bi as fn,It as pn,Ki as mn,Kt as hn,Lr as gn,Mt as _n,Ni as vn,Po as I,Rr as yn,Ui as bn,Ur as xn,Wr as Sn,Wt as Cn,Zr as L,_o as wn,ba as Tn,bo as En,ci as Dn,da as On,go as kn,ho as An,ia as jn,in as Mn,jt as Nn,ma as Pn,mt as Fn,na as In,pa as R,ro as Ln,uo as z,wa as B,zr as Rn,zt as zn}from"./ui-CmSP4d14.js";import{B as Bn,F as V,M as Vn,N as Hn,V as Un,d as Wn,j as Gn,u as Kn}from"./control-ui-boot-shared-VLPz5vN2.js";import{$t as qn,Bi as Jn,Di as Yn,F as Xn,Fi as Zn,Gi as Qn,Hi as $n,Ji as er,Ki as tr,M as nr,Mi as rr,N as ir,P as ar,Qi as or,Qt as sr,Si as cr,T as lr,Ui as ur,Vi as dr,Wi as fr,Zi as pr,ct as mr,ki as hr,qi as gr,ut as _r,w as vr,yi as yr,zi as br}from"./control-ui-boot-shared-XreXSF7h.js";import{$o as xr,$r as Sr,An as Cr,Ap as wr,At as Tr,B as Er,Bs as Dr,Bt as Or,Co as kr,D as Ar,Dn as jr,E as Mr,En as Nr,Ep as Pr,Et as Fr,F as Ir,Fp as H,Fr as Lr,Ft as Rr,G as zr,Gf as Br,H as Vr,Hn as Hr,Ht as Ur,I as Wr,Ip as Gr,Ir as Kr,J as qr,Jo as Jr,Jp as Yr,K as Xr,Kp as Zr,Kr as Qr,Ks as $r,Lr as ei,Lt as ti,M as ni,Mn as ri,Mp as U,Mr as ii,Mt as ai,N as oi,Nn as si,Np as ci,Nt as li,Oa as ui,Ot as di,P as fi,Pn as pi,Pp as mi,Pt as hi,Q as gi,Qo as _i,Rr as vi,Rt as yi,Sn as bi,St as xi,Su as Si,T as Ci,To as wi,U as Ti,Ui as Ei,Un as Di,Ut as Oi,V as ki,Vn as Ai,Vt as ji,W as Mi,Wf as Ni,Wi as Pi,Wn as Fi,X as Ii,Yo as Li,Zo as Ri,Zr as zi,_c as Bi,_i as Vi,_o as Hi,am as Ui,as as Wi,bc as Gi,bu as Ki,cm as qi,ct as Ji,dl as Yi,dt as Xi,ei as Zi,fn as Qi,gi as $i,go as ea,ha as ta,im as na,is as ra,it as ia,j as aa,jn as oa,jp as sa,jr as ca,jt as la,ka as ua,kn as da,ko as fa,kt as pa,ll as ma,lt as ha,ma as ga,mi as _a,mo as va,ns as ya,nt as ba,om as xa,os as Sa,pa as Ca,pi as wa,q as Ta,qr as Ea,qs as Da,rm as Oa,rs as ka,rt as Aa,st as ja,tt as Ma,um as Na,un as Pa,ut as Fa,v as Ia,vc as La,vo as Ra,w as za,wn as Ba,wo as Va,wp as Ha,xn as Ua,xo as Wa,xt as Ga,xu as Ka,y as qa,yc as Ja,yo as Ya,z as Xa,zr as Za,zs as Qa,zt as $a}from"./control-ui-boot-shared-dOnP4mAA.js";import{d as eo,f as to}from"./control-ui-boot-shared-Q8KG_noF.js";import"./control-ui-boot-shared-styles-BXPMRytW.js";import"./chat-transcript-styles-BN-TorbW.js";import"./control-ui-boot-new-styles-cChqenO3.js";var no,ro;function io(){return(io=e((()=>{i(),no={sessionsView:{placementFactService:`Service`,placementFactProfile:`Profile`,placementFactMachine:`Machine`,placementFactState:`State`,placementFactDisk:`Disk`,placementFactInference:`Inference`,inferenceWorker:`Direct from worker`,placementDiskFree:`{free} free`,runsOnDevice:`Runs on device`,runsOnWorker:`Runs on worker`,stopWorker:`Stop worker…`,stopWorkerConfirm:`Stop the worker for "{session}"?`,stopWorkerConfirmAction:`Stop worker`,deviceOffline:`Device offline`,waitingForDevice:`Waiting for device to reconnect; retry after it returns.`,continueOnGatewayMenu:`Continue on Gateway…`,continueOnGatewayAction:`Continue on Gateway`,continueOnGatewayConfirm:`Continue "{session}" on the Gateway? Unsynced device files and in-flight work may be lost. OpenClaw will continue from the last Gateway-synced state and will not replay the interrupted turn.`,discardWorkspaceDeleteConfirm:`The device for "{session}" is offline and has changes that have not synced. Reconnect it to keep those changes. To delete this session now, discard unsynced device files and in-flight work, then retry deletion once. The last Gateway-synced workspace is used; interrupted work is not replayed.`,discardWorkspaceDeleteAction:`Discard changes and delete`,discardWorkspaceArchiveConfirm:`The device for "{session}" is offline and has changes that have not synced. Reconnect it to keep those changes. To archive this session now, discard unsynced device files and in-flight work, then retry archiving once. The last Gateway-synced workspace is used; interrupted work is not replayed.`,discardWorkspaceArchiveAction:`Discard changes and archive`,workspaceRecoveryBatchHint:`Recover each offline session separately before retrying this selection.`,stopDeviceWorker:`Stop device worker…`,offlineDeviceStopUnavailable:`Reconnect the device to stop and sync its workspace, or Continue on Gateway.`,stopDeviceWorkerConfirm:`Stop the device worker for "{session}"?`,stopDeviceWorkerConfirmAction:`Stop device worker`,restartSession:`Restart session…`,restartingSession:`Restarting session…`,restartSessionTitle:`Restart session`,restartSessionDescription:`Choose where "{session}" should restart.`,restartSessionWarning:`The session restarts from its last saved workspace on the selected destination. Changes that the previous worker did not upload may be lost.`,restartSessionAction:`Restart session`,chooseWorker:`Choose worker…`,dispatchingSession:`Starting worker…`,repositoryWorkerRequiredLabel:`Worker required`,repositoryWorkerRequiredTitle:`Repository worker required`,repositoryWorkerRequiredPrompt:`Choose a device or cloud worker before sending another message in this repository session.`,dispatchSessionTitle:`Choose a worker`,dispatchSessionDescription:`Choose where "{session}" should continue.`,dispatchSessionNotice:`This repository exists only on workers, so the Gateway cannot run this session locally.`,dispatchSessionAction:`Continue on worker`,stoppingSession:`Stopping session…`,finishingSessionMove:`Finishing session move…`,syncingCloudFiles:`Worker · syncing files`,syncingCloudFilesComposer:`Send now; your message starts automatically after workspace sync.`,syncingCloudFilesDetail:`Finalizing worker workspace`,failedSessionTitle:`Runner failed`,failedSessionRestartPrompt:`Restart this session to continue.`,failedSessionStopPrompt:`Stop the failed worker before restarting this session.`,failedSessionUnavailable:`This session's runner failed and cannot accept messages.`}},ro=Object.assign(()=>{Object.assign(v.sessionsView,no.sessionsView)},{catalog:no})})))()}function ao(e){e.target&&co.set(e.target,e.timeStamp)}function oo(e){e.target&&co.delete(e.target)}function so(e){if(e.isComposing||e.keyCode===229)return!0;if(e.key!==`Enter`)return oo(e),!1;let t=e.target?co.get(e.target):void 0;return t!==void 0&&Math.abs(e.timeStamp-t)<100}var co;function lo(){return(lo=e((()=>{co=new WeakMap})))()}var uo;function fo(){return(fo=e((()=>{Qe(),r(),Ua(),uo=class{constructor(e,t={}){this.notify=e,this.options=t,this.failed=!1}get pending(){return this.controller!==void 0}get snapshot(){let e=this.binding;return Nr(e&&this.owns(e)?e.client:null,e?.scope)}bind(e,t){let n=e.snapshot.client,r=this.binding;if(r&&this.owns(r)&&r.gateway===e&&de(le(r.scope))===de(le(t))||(this.clear(),!n))return!1;let i={gateway:e,client:n,scope:t,presentationKey:ut(e).key};this.binding=i;let a=da(n,()=>{this.owns(i)&&(this.failed&&Ba(n,t)&&(this.failed=!1),this.notify())}),o=Cr(e,()=>{this.owns(i)?this.read():this.notify()},t);return this.unsubscribe=()=>{a(),o()},!0}owns(e){return this.binding===e&&e.gateway.snapshot.client===e.client&&e.gateway.snapshot.phase===`connected`&&ut(e.gateway).key===e.presentationKey}read(){let e=this.binding;if(!e||!this.owns(e))return Promise.resolve(void 0);this.controller?.abort(),this.controller=void 0;let t=Ba(e.client,e.scope);if(t)return this.failed=!1,this.options.onResult?.(t),this.notify(),Promise.resolve(t);let n=new AbortController;return this.controller=n,this.failed=!1,this.notify(),bi(e.client,{...e.scope,signal:n.signal,timeoutMs:this.options.timeoutMs}).then(t=>{if(this.owns(e)&&this.controller===n)return this.controller=void 0,this.options.onResult?.(t),this.notify(),t},()=>{this.owns(e)&&this.controller===n&&(this.controller=void 0,this.failed=!0,this.options.onError?.(),this.notify())})}clear(){this.binding=void 0,this.controller?.abort(),this.controller=void 0,this.unsubscribe?.(),this.unsubscribe=void 0,this.failed=!1}}})))()}function po(e){return/^[A-Za-z0-9_/:=.,@%+-]+$/.test(e)?e:`'${e.replaceAll(`'`,`'\\''`)}'`}var mo;function ho(){return(ho=e((()=>{A(),vr(),T(),ct(),d(),F(),y(),Oe(),g(),P(),mo=class{constructor(e,t){this.gateway=e,this.requestUpdate=t,this.openValue=!1,this.loadingValue=!1,this.errorValue=null,this.setupValue=null,this.requestId=0}get open(){return this.openValue}start(){this.openValue=!0,this.errorValue=null,this.setupValue=null,this.requestUpdate(),this.refresh()}close(){this.requestId+=1,this.openValue=!1,this.loadingValue=!1,this.errorValue=null,this.setupValue=null}render(e,t){if(!this.open||!e)return O;let n=()=>{this.close(),this.requestUpdate()},{loadingValue:r,errorValue:i,setupValue:a}=this,o=w(`newSession.connectMachineTitle`),s=a?.joinUrl?.trim(),c=s?`npx -y openclaw connect ${po(s)} --service`:null,l=a?.expiresAtMs?m(a.expiresAtMs,{hour:`numeric`,minute:`2-digit`},``):``;return k`
<openclaw-modal-dialog
class="connect-machine-dialog"
label=${o}
description=${w(`newSession.connectMachineDescription`)}
@modal-cancel=${n}
>
<section class="exec-approval-card connect-machine-dialog__card">
<header class="exec-approval-header">
<div>
<h2 class="exec-approval-title">${o}</h2>
<p class="exec-approval-sub">${w(`newSession.connectMachineDescription`)}</p>
</div>
<button
class="btn btn--icon btn--ghost"
type="button"
aria-label=${w(`common.dismiss`)}
@click=${n}
>
${E.x}
</button>
</header>
<div class="connect-machine-dialog__body">
${r&&!c?k`<p class="connect-machine-dialog__status" role="status">
${w(`newSession.connectMachineGenerating`)}
</p>`:O}
${i?k`<p class="exec-approval-error" role="alert">
${w(`newSession.connectMachineFailed`)} ${i}
</p>`:O}
${c?k`
${lr(`${c} --session-host`)}
<p class="connect-machine-dialog__hint">
${w(`newSession.connectMachineTeamHint`)}
</p>
<details>
<summary>${w(`newSession.connectMachineCommandOnly`)}</summary>
${lr(c)}
</details>
<p class="connect-machine-dialog__hint">
${l?w(`newSession.connectMachineSingleUseExpires`,{time:l}):w(`newSession.connectMachineSingleUse`)}
</p>
`:O}
</div>
<footer class="exec-approval-actions connect-machine-dialog__actions">
${c||i?k`<button
class="btn"
type="button"
?disabled=${r}
@click=${()=>void this.refresh()}
>
${E.refresh}
${w(r?`newSession.connectMachineRefreshing`:`newSession.connectMachineFreshCode`)}
</button>`:O}
<button class="btn btn--ghost" type="button" @click=${t}>
${w(`newSession.connectMachineManageDevices`)}
</button>
</footer>
</section>
</openclaw-modal-dialog>
`}async refresh(){if(!this.openValue||this.loadingValue)return;let{client:e,connected:t}=this.gateway();if(!t||!e){this.errorValue=w(`newSession.connectMachineUnavailable`),this.requestUpdate();return}let n=++this.requestId;this.loadingValue=!0,this.errorValue=null,this.requestUpdate();try{let t=await be(e);if(!this.stillCurrent(n,e))return;if(!t.joinUrl?.trim()){this.setupValue=null,this.errorValue=w(`newSession.connectMachineMissingUrl`);return}this.setupValue=t}catch(t){this.stillCurrent(n,e)&&(this.errorValue=ke(t))}finally{n===this.requestId&&(this.loadingValue=!1,this.requestUpdate())}}stillCurrent(e,t){let n=this.gateway();return e===this.requestId&&t===n.client&&n.connected&&this.openValue}}})))()}function go(e){if(!e||e.length>2048||An(e))return;let t=Rn(e);return t?gn(t.provider,t.modelId):void 0}function _o(e,t){let n=new URLSearchParams(_e(e)),r=go(t);return r&&n.set(`model`,r),n.size>0?`?${n.toString()}`:``}function vo(e){let t=ee(e),n=t.catalogId?void 0:go(new URLSearchParams(e).get(`model`));return{...t,...n?{requestedModel:n}:{}}}function yo(){return(yo=e((()=>{yn(),kn()})))()}function bo(e,t,n,r){return JSON.stringify([e,t,n,...r?[r]:[]])}function xo(e){return bo(e?.requestedAgentId??``,e?.catalogId??``,e?.group??``,e?.requestedModel)}function So(e){let t=vo(e);return bo(t.agentId,t.catalogId,t.group??``,t.requestedModel)}function Co(e,t){return!e?.requestedAgentId||z(e.requestedAgentId)===z(t)?e?.requestedModel:void 0}function W(e){return!!e?.catalogId}function wo(e){return!!(e?.catalogId&&e.startTerminal&&e.catalogLabel)}function To(e){return W(e)&&!wo(e)||!!(e?.group&&e.groupStatus!==`resolved`)}function Eo(e){return JSON.stringify([e?.groupStatus??``,e?.groupCwd??``,e?.groupWorktree===!0,e?.groupCatalogGeneration??-1,e?.groupDefaultsStatus??`idle`])}function Do(e,t){let n=e?.group?.trim();if(!n)return!1;let r=t.groupsGeneration(),i=t.groupsStatus();if(e?.groupCatalogGeneration!==r||e.groupDefaultsStatus!==i)return!0;if(i!==`ready`)return!1;let a=t.state.groupSettings.find(e=>e.name===n);return a?e.groupStatus!==`resolved`||(e.groupCwd??``)!==(a.cwd??``)||e.groupWorktree!==(a.worktree===!0):e.groupStatus===`resolved`}function Oo(e,t){let n=t.state.groupSettings.find(t=>t.name===e?.group);return JSON.stringify([e?.group??``,t.groupsGeneration(),t.groupsStatus(),!!n,n?.cwd??``,n?.worktree===!0])}function ko(e,t){return!(!e?.group||t&&!Do(e,t))}function Ao(e,t){return To(e)||ko(e,t)}function jo(e,t){return e?.groupStatus===`resolved`&&!ko(e,t)?e.group:void 0}function Mo(e,t,n){let r=e?.agentId?.trim(),i=r?z(r):void 0;return i&&t.some(e=>z(e.id)===i)?i:n&&z(n)}function No(e,t){return!W(e)||wo(e)&&!!t}async function Po(e,t,n){try{let r=(await e.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}}function Fo(e){if(!W(e))return O;let t=wo(e),n=e?.catalogLabel||e?.catalogId||``;return k`<span
class="new-session-page__trigger new-session-page__runtime"
title=${w(t?`newSession.nativeTerminalHint`:`newSession.catalogUnavailable`)}
>
<span class="new-session-page__target-icon" aria-hidden="true">${E.terminal}</span>
<span class="new-session-page__trigger-label">${n}</span>
</span>`}function Io(e){let t=To(e.data)||e.groupPending===!0;return k`
<div class="new-session-page__triggers">
${Fo(e.data)} ${W(e.data)?O:e.agentSelect}
${e.placeSelect}
${t?k`<span class="new-session-page__catalog-unavailable">
${w(`newSession.catalogUnavailable`)}
<button
class="btn btn--sm"
type="button"
?disabled=${e.retrying}
@click=${e.onRetry}
>
${e.retrying?w(`common.loading`):w(`lazyView.retry`)}
</button>
</span>`:O}
</div>
`}var Lo,Ro;function G(){return(G=e((()=>{A(),T(),d(),F(),jt(),C(),yo(),P(),Lo=class{constructor(e,t){this.readData=e,this.revalidate=t,this.pending=null,this.lastKey=``}synchronize(e){if(this.pending)return;let t=this.readData(),n=Oo(t,e);if(this.lastKey===n||!Do(t,e))return;let r=this.revalidate();r&&(this.lastKey=n,this.pending=r,r.catch(()=>void 0).finally(()=>{this.pending===r&&(this.pending=null,this.synchronize(e))}))}},Ro=class{constructor(e){this.notify=e,this.state={status:`idle`}}clear(){let e=this.state;this.state={status:`idle`},e.status===`loading`&&e.controller.abort(),e.status!==`idle`&&this.notify()}startRequest(e){let t=new AbortController,n={status:`loading`,owner:e,controller:t};this.state=n,this.notify(),e.client.request(`sessions.catalog.list`,{agentId:e.agentId,metadataOnly:!0},{signal:t.signal}).then(t=>{this.state===n&&(this.state={status:`ready`,owner:e,targets:t.catalogs.filter(e=>e.capabilities.startTerminal===!0).map(({id:e,label:t})=>({value:e,label:t}))},this.notify())},()=>{this.state===n&&(this.state={status:`error`,owner:e},this.notify())})}load(e,t,n){let r=e?.gateway.snapshot,i=r?.client,a=t.trim()?z(t):``;if(!n||r?.phase!==`connected`||!i||!a||At(r,`sessions.catalog.list`)!==!0){this.clear();return}let o={agentId:a,client:i},s=this.state;(s.status===`idle`||s.owner.client!==o.client||s.owner.agentId!==o.agentId)&&(this.clear(),this.startRequest(o))}retry(e,t){let n=this.state;n.status===`error`&&n.owner.client===e&&n.owner.agentId===t&&this.startRequest(n.owner)}groups(){let e=this.state;if(!(e.status===`idle`||e.status===`ready`&&!e.targets.length))return[{errorLabel:w(`newSession.cliAgentsUnavailable`),id:`cliAgents`,label:w(`newSession.cliAgentsGroup`),options:e.status===`ready`?e.targets:[],status:e.status}]}}})))()}var zo;function Bo(){return(Bo=e((()=>{zo=[1e3,3e3,1e4,3e4,6e4]})))()}function Vo(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0?Math.trunc(e):void 0}function Ho(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0&&e<=65536?e:void 0}function Uo(e){return e===`persistent`||e===`disposable`?e:void 0}function Wo(e){let t=(Array.isArray(e)?e:[]).flatMap(e=>{if(!B(e))return[];if(e.code===`worker-host-unavailable`){let t=I(e.message);return t&&t.length<=1024?[{code:`worker-host-unavailable`,message:t}]:[]}return e.code===`update-required`&&e.action===`update-and-reconnect`&&e.updateCommand===`openclaw update`&&e.headlessReconnectCommand===`openclaw node restart`?[{code:e.code,action:e.action,updateCommand:e.updateCommand,headlessReconnectCommand:e.headlessReconnectCommand}]:[]});return t.length>0?t:void 0}function Go(e){return Array.isArray(e)?e.length===1&&(e[0]===`worker-turn`||e[0]===`remote-exec`)?[e[0]]:e.length===2&&e[0]===`worker-turn`&&e[1]===`remote-exec`?[`worker-turn`,`remote-exec`]:[]:[]}function Ko(e,t){return e.executionModes?.includes(t)===!0}function qo(e){return(Array.isArray(e)?e:[]).flatMap(e=>{let t=Tn(e);if(!t)return[];let n=I(t.id),r=I(t.providerId);if(!n||!r)return[];let i=Uo(t.trust),a=Jo(t.machines,`machine`),o=Jo(t.operatingSystems,`os`);return[{id:n,providerId:r,...t.inference===`worker`?{inference:t.inference}:{},...typeof t.providerDisplayId==`string`&&/^[a-z][a-z0-9-]{0,63}$/.test(t.providerDisplayId)&&t.providerDisplayId.trim()===t.providerDisplayId?{providerDisplayId:t.providerDisplayId}:{},trust:i,...Object.hasOwn(t,`executionModes`)?{executionModes:Go(t.executionModes)}:{},...a.length>0?{machines:a}:{},...o.length>0?{operatingSystems:o}:{}}]}).toSorted((e,t)=>e.id.localeCompare(t.id))}function Jo(e,t){let n=t===`machine`,r=new Map,i=n?64:8,a=n?128:64;for(let t of(Array.isArray(e)?e:[]).slice(0,i)){if(!B(t))continue;let e=I(t.id),i=I(t.label),o=n?I(t.os):void 0,s=n?void 0:I(t.disabledReason)?.slice(0,256),c=n?JSON.stringify([o,e]):e??``;if(!e||e.length>a||!i||i.length>a||r.has(c)||n&&t.os!==void 0&&(!o||o.length>64))continue;let l=n?Ho(t.cpu):void 0,u=n?Ho(t.memoryGb):void 0;r.set(c,{id:e,label:i,...o?{os:o}:{},...l===void 0?{}:{cpu:l},...u===void 0?{}:{memoryGb:u},...typeof t.default==`boolean`?{default:t.default}:{},...s?{disabledReason:s}:{}})}return[...r.values()]}function Yo(e){return e.operatingSystems?.find(e=>e.default)?.id??e.operatingSystems?.[0]?.id??e.machines?.find(e=>e.os)?.os??``}function Xo(e,t){return(e.machines??[]).filter(e=>!e.os||e.os===t)}function Zo(e,t=Yo(e)){let n=Xo(e,t);return n.find(e=>e.default)??n[0]}function Qo(e){if(!B(e)||Object.keys(e).some(e=>e!==`command`&&e!==`state`&&e!==`message`))return;let t=I(e.command),n=e.state,r=I(e.message);return t&&t.length<=128&&(n===`invocable`||n===`pending-approval`||n===`undeclared`||n===`unauthorized`)?{command:t,state:n,...r?{message:r}:{}}:void 0}function $o(e){return(Array.isArray(e)?e:[]).flatMap(e=>{let t=Tn(e);if(!t)return[];let n=I(t.id),r=I(t.type),i=es.find(e=>e===t.status);if(!n||r!==`local`&&r!==`node`&&r!==`worker`||!i)return[];let a=I(t.label),o=I(t.platform),s=Uo(t.trust),c=wn(t.capabilities),l=Array.isArray(t.invocableCommands)?En(t.invocableCommands).filter(e=>e.length<=128).slice(0,128):void 0,u=Qo(t.requiredNodeCommand),d=Vo(t.lastConnectedAtMs),f=Vo(t.lastDisconnectedAtMs),p=Vo(t.lastSeenAtMs),m=I(t.lastSeenReason),h=Wo(t.issues),g=wt(t.workerSlots);return[{id:n,type:r,status:i,...a?{label:a}:{},...o?{platform:o}:{},...typeof t.sessionHost==`boolean`?{sessionHost:t.sessionHost}:{},...g?{workerSlots:g}:{},...d===void 0?{}:{lastConnectedAtMs:d},...f===void 0?{}:{lastDisconnectedAtMs:f},...p===void 0?{}:{lastSeenAtMs:p},...m?{lastSeenReason:m}:{},...s?{trust:s}:{},...c?{capabilities:c}:{},...l?{invocableCommands:l}:{},...u?{requiredNodeCommand:u}:{},...h?{issues:h}:{}}]}).toSorted((e,t)=>e.id.localeCompare(t.id))}var es;function ts(){return(ts=e((()=>{kn(),Dt(),es=[`available`,`unavailable`,`starting`,`stopping`,`error`]})))()}async function ns(e,t){let n=await e.request(`environments.list`,t?{runtimeId:t}:{});return{profiles:qo(n?.profiles),environments:$o(n?.environments)}}function rs(e,t){return t===`enable-session-hosting`?k`<div>${w(`newSession.sessionHostingAction`)}</div>
<code class="new-session-page__command"
>openclaw config set nodeHost.workerRuns.enabled true</code
>
<code class="new-session-page__command">openclaw node install --force</code>`:t===`update-device`?k`<div>${w(`newSession.updateAction`)}</div>
<code class="new-session-page__command">openclaw update</code>
<div>${w(`newSession.reconnectAction`)}</div>
<code class="new-session-page__command">openclaw node restart</code>`:e}function K(e,t){return k`<div class="new-session-page__card-row">
<span class="new-session-page__card-icon" aria-hidden="true">${e}</span><span>${t}</span>
</div>`}function q(e,t){let n=e.disabled?e.title||e.description:void 0,r=e.compact?void 0:e.description,i=e.compact&&e.disabled&&!e.hideDetails,a=e.compact&&!e.disabled&&!e.hideDetails,o=[e.suggested?w(`newSession.machineDefault`):void 0,e.accessibleProvider?w(`newSession.cloudWorkerProvider`,{provider:e.accessibleProvider}):void 0].filter(Boolean).join(`, `),s=[o,e.accessibleProvider?n:void 0].filter(Boolean).join(`, `),c=k`
<button
type="button"
class="session-menu__item ${r?`session-menu__item--described`:``} ${e.compact?`new-session-page__environment-option`:``}"
data-suggested=${e.suggested?`true`:O}
aria-description=${s||O}
data-value=${e.value}
data-popover=${e.keepOpen||i?O:`close`}
aria-pressed=${String(e.checked)}
title=${e.compact?O:e.title??O}
?disabled=${t||!!e.disabled&&!i}
aria-disabled=${i?`true`:O}
@click=${t=>{if(e.disabled){t.preventDefault(),t.stopPropagation();return}e.onSelect()}}
>
${e.icon?k`<span class="session-menu__icon" aria-hidden="true">${e.icon}</span>`:O}
<span class="session-menu__text">
${e.label}
${e.selectedSummary?k`<span class="new-session-page__selected-summary"
>${e.selectedSummary}</span
>`:O}
${r?k`<span class="session-menu__description">${r}</span>`:O}
</span>
${!e.compact&&e.facts?.length?k`<span class="new-session-page__menu-meta">
<span class="new-session-page__menu-facts">
${e.facts.map(e=>k`<span class="new-session-page__menu-fact">${e}</span>`)}
</span>
</span>`:O}
${!e.compact&&e.sub?k`<span class="session-menu__sub">${e.sub}</span>`:O}
<span class="session-menu__check" aria-hidden="true"
>${e.checked?E.check:O}</span
>
${e.hasSubmenu?k`<span class="new-session-page__submenu-chevron" aria-hidden="true"
>${E.chevronRight}</span
>`:O}
</button>
`;return e.compact&&!e.hideDetails?k`<openclaw-tooltip
class="new-session-page__environment-details"
placement="right-start"
?open-on-click=${i||a}
>
<div class="new-session-page__environment-detail-trigger">
${c}
${a?k`<button
type="button"
class="new-session-page__touch-details"
aria-label=${w(`newSession.environmentDetails`,{name:e.label})}
?disabled=${t}
>
${E.info}
</button>`:O}
</div>
<div slot="content" class="new-session-page__environment-card">
${o?k`<span hidden>${o}, </span>`:O}
${n?k`<span>${rs(n,e.remediation)}</span>`:k`
<strong>${e.label}</strong>
${e.summary?K(E.info,e.summary):O}
${e.platform?K(E.layers,e.platform):O}
${e.sub?K(E.info,e.sub):O}
${e.capabilityLabels?.length?K(E.info,e.capabilityLabels.join(`, `)):O}
${e.trust?K(e.trust===`persistent`?E.repeat:E.clock,w(e.trust===`persistent`?`newSession.persistentEnvironmentHint`:`newSession.disposableEnvironmentHint`)):O}
${e.provider?K(E.server,e.provider):O}
${e.hardware?K(E.info,e.hardware):O}
${[...new Set([e.description,...e.facts??[],e.provider&&!e.disabled?void 0:e.title].filter(Boolean))].map(e=>K(E.info,e))}
${e.capacityLabel?k`<div class="new-session-page__card-row">
<span class="new-session-page__card-icon" aria-hidden="true"
>${E.activity}</span
><span class="new-session-page__capacity-caption"
>${e.capacityLabel}</span
>
</div>`:O}
`}
</div>
</openclaw-tooltip>`:c}function is(e){return e.profiles.toSorted(yr).map(t=>{let n=Yn(t),r=e.profileDisabledReason?.(t),i=e.selectedId===t.id,a=(i?e.selectedOs:void 0)||Yo(t),o=t.operatingSystems?.find(e=>e.id===a),s=Xo(t,a),c=(i&&e.selectedMachine?s.find(t=>t.id===e.selectedMachine):void 0)??Zo(t,a),l=e.compact&&!e.disabled&&!r&&((t.operatingSystems?.some(e=>!e.disabledReason)??!1)||s.length>0),u=q({value:`cloud:${t.id}`,label:e.compact?t.id:w(`newSession.cloudWorker`,{profile:t.id}),hasSubmenu:l,selectedSummary:e.compact&&i?[o?.label,c?.label,t.inference===`worker`?w(`sessionsView.inferenceWorker`):void 0].filter(Boolean).join(` · `):void 0,description:t.inference===`worker`?w(`sessionsView.inferenceWorker`):void 0,icon:n.icon,accessibleProvider:n.label,compact:e.compact,facts:!e.compact&&t.trust===`disposable`?[w(`newSession.environmentDisposable`)]:!e.compact&&t.trust===`persistent`?[w(`newSession.environmentPersistent`)]:void 0,trust:e.compact?t.trust:void 0,provider:e.compact?n.label:void 0,platform:e.compact?o?.label:void 0,hardware:e.compact&&c?as(c):void 0,hideDetails:e.compact&&!e.disabled&&!r,keepOpen:e.compact,checked:e.selectedId===t.id,disabled:e.disabled||!!r,title:(e.disabled?e.disabledReason:r)??w(`newSession.cloudWorkerProvider`,{provider:n.label}),onSelect:()=>e.compact&&!i?e.onSelect(t.id,!0):e.onSelect(t.id)},e.submitting);return l?k`<openclaw-tooltip
class="new-session-page__environment-details new-session-page__cloud-config-card"
placement="right"
open-on-click
>
${u}
<div slot="content">
<span hidden
>${w(`newSession.cloudWorkerProvider`,{provider:n.label})}</span
>
${os({profile:t,operatingSystems:t.operatingSystems??[],machines:s,suggested:!i,selectedOs:i?a:``,selectedMachine:i?c?.id??``:``,submitting:e.submitting,onSelectOs:n=>{i||e.onSelect(t.id,!0),e.onSelectOs?.(n)},onSelectMachine:n=>{i||e.onSelect(t.id,!0),e.onSelectMachine?.(n)}})}
</div>
</openclaw-tooltip>`:u})}function as(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?w(`newSession.machineShape`,{cpu:t,memory:n}):t?w(`newSession.machineCpu`,{cpu:t}):n?w(`newSession.machineMemory`,{memory:n}):void 0}function os(e){let t=e.operatingSystems.filter(e=>!e.disabledReason),n=t.length===1?t[0]:void 0,r=e.machines.length===1?e.machines[0]:void 0,i=[[t.length,w(`newSession.operatingSystem`),()=>n?k`<span class="new-session-page__fixed-os" data-value=${`os:${n.id}`}
>${n.label}</span
>`:cs({kind:`os`,choices:t,selectedId:e.selectedOs,suggestedId:e.suggested?Yo(e.profile):void 0,submitting:e.submitting,onSelect:e.onSelectOs})],[e.machines.length,w(`newSession.machine`),()=>r?ss(r):cs({kind:`machine`,choices:e.machines,selectedId:e.selectedMachine,suggestedId:e.suggested?Zo(e.profile,e.selectedOs)?.id:void 0,submitting:e.submitting,onSelect:e.onSelectMachine})]];return k`<section
class="new-session-page__cloud-configuration"
aria-label=${e.profile.id}
>
${i.map(([e,t,n])=>e?k`<div class="new-session-page__environment-heading">${t}</div>
<div class="new-session-page__cloud-choice-list" role="group" aria-label=${t}>
${n()}
</div>`:O)}
</section>`}function ss(e){let t=as(e);return k`<span class="new-session-page__fixed-machine" data-value=${`machine:${e.id}`}>
<span>${e.label}</span>${t?k`<span>${t}</span>`:O}
</span>`}function cs(e){return e.choices.map(t=>q({suggested:e.suggestedId===t.id,value:`${e.kind}:${t.id}`,label:t.label,...e.kind===`machine`?{sub:as(t)}:{description:t.disabledReason,disabled:!!t.disabledReason,title:t.disabledReason},checked:e.selectedId===t.id||!e.selectedId&&e.suggestedId===t.id,keepOpen:!0,onSelect:()=>e.onSelect(t.id)},e.submitting))}function ls(){return(ls=e((()=>{A(),Le(),T(),cr(),d(),F(),io(),ts(),P(),ro()})))()}function us(e){if(!B(e)||typeof e.agentId!=`string`||!e.agentId.trim())return null;let t=hs(e.selection);if(!t||!B(e.selection))return null;for(let n of[`folder`,`projectId`,`baseRef`]){let r=e.selection[n];typeof r==`string`&&(t[n]=r.trim())}return delete t.model,delete t.agentRuntime,delete t.thinkingLevel,delete t.fastMode,delete t.worktreeName,{agentId:z(e.agentId),selection:t}}function ds(e){return e.cloudProfileId?{kind:`cloud`,id:e.cloudProfileId}:e.deviceId?{kind:`device`,id:e.deviceId}:e.autoDevice?{kind:`auto-device`}:{kind:`local`}}function fs(e){return!!(e?.model||e?.thinkingLevel||e?.fastMode!==void 0)}function ps(e,t){let n=e?.folder??``,r=!!n&&n===e?.workspace&&e.workspace!==t,i=n&&!r?n:t;return{folder:i,workspaceMoved:r,freshWorkspace:e?.freshWorkspace??!(e?.worktree===!0||e?.projectId||i&&i!==t)}}function ms(e){return`${ws}${Mn(e)}`}function hs(e){if(!B(e))return null;let t={};for(let n of[`workspace`,`folder`,`projectId`,`baseRef`,`worktreeName`,`model`,`thinkingLevel`]){let r=I(e[n]);r&&(t[n]=r)}let n=I(e.agentRuntime);if(t.model&&n&&(t.agentRuntime=n),(typeof e.fastMode==`boolean`||e.fastMode===`auto`||e.fastMode===`ultrafast`)&&(t.fastMode=e.fastMode),typeof e.worktree==`boolean`&&(t.worktree=e.worktree),typeof e.freshWorkspace==`boolean`?t.freshWorkspace=e.freshWorkspace:t.worktree===!0&&(t.freshWorkspace=!1),typeof e.defaultRepositoryOptOut==`boolean`&&(t.defaultRepositoryOptOut=e.defaultRepositoryOptOut),e.remoteProject===null)t.remoteProject=null;else if(B(e.remoteProject)){let n=I(e.remoteProject.identity)?.slice(0,200),r=I(e.remoteProject.cloneUrl)?.slice(0,2048),i=I(e.remoteProject.defaultBranch)?.slice(0,255);n&&r&&(t.remoteProject={identity:n,cloneUrl:r,...i?{defaultBranch:i}:{}})}let r=_s(e.where);return r&&(t.where=r),Object.keys(t).length?t:null}function gs(e){let t=hs(e);return t?(delete t.remoteProject,delete t.defaultRepositoryOptOut,Object.keys(t).length?t:null):null}function _s(e){if(!B(e)||typeof e.kind!=`string`)return;if(e.kind===`local`||e.kind===`auto-device`)return{kind:e.kind};let t=I(e.id);return t&&(e.kind===`device`||e.kind===`cloud`)?{kind:e.kind,id:t}:void 0}function vs(e,t){try{let n=JSON.parse(e.getItem(ms(t))??`null`);return B(n)?n:{}}catch{return{}}}function ys(e,t){let n=s(),r=z(t);return!n||!e||!r?null:gs(vs(n,e).agents?.[r])}function bs(e){let t=s();if(!t||!e)return{};let n=Object.entries(vs(t,e).agents??{}).flatMap(([e,t])=>{let n=z(e),r=gs(t);return n&&r?[[n,r]]:[]});return Object.fromEntries(n)}function xs(e){return Object.fromEntries(Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[`${Ts}${e}`,t]))}function Ss(e){return Object.fromEntries(Object.entries(e).flatMap(([e,t])=>{if(!e.startsWith(Ts))return[];let n=z(e.slice(15)),r=hs(t);return n&&r?[[n,r]]:[]}))}function Cs(e,t,n){let r=s(),i=z(t);if(!r||!e||!i)return!1;let a=vs(r,e),o=Object.fromEntries(Object.entries(a.agents??{}).flatMap(([e,t])=>{let n=gs(t);return n?[[e,n]]:[]})),c=gs(n);c?o[i]=c:delete o[i];try{return r.setItem(ms(e),JSON.stringify({...a,agents:o})),!0}catch{return!1}}var ws,Ts,Es,Ds;function Os(){return(Os=e((()=>{C(),ws=`openclaw.new-session.preferences.v1:`,Ts=`new-session.v1:`,Es=`new-session.migration.v1`,Ds=`new-session.palette.v1`})))()}var ks;function As(){return(As=e((()=>{Ot(),Re(),d(),F(),jt(),C(),x(),G(),Os(),Pn(),P(),ks=class e{static{this.preferenceWriters=new WeakMap}constructor(e,t){this.read=e,this.callbacks=t,this.preferenceModeValue=`local`,this.identityPreferences={},this.preferenceLoad=Promise.resolve()}get loading(){return this.preferenceModeValue===`loading`}synchronize(){let e=this.read(),t=e.source;if(!t)return;let n={...e,profileId:t.snapshot.selfUser?.id};if(this.preferenceScope&&[`source`,`client`,`connected`,`recoveryScope`,`connectionEpoch`,`profileId`].every(e=>n[e]===this.preferenceScope?.[e]))return;this.disconnect(),this.preferenceScope=n,this.identityPreferences={};let{client:r,connected:i,recoveryScope:a,profileId:o}=n;if(i){let e=this.preferenceWrites(t).listeners,i=(e,i,s)=>{let c=t.snapshot;this.preferenceScope===n&&c.client===r&&c.hello?.auth?.recoveryScope===a&&c.selfUser?.id===o&&(this.identityPreferences={...this.identityPreferences,[e]:i},s?this.adoptPreferences():this.callbacks.requestUpdate())};e.add(i),this.stopPreferencePublication=()=>e.delete(i)}let s=i&&r&&o&&At(t.snapshot,`users.prefs.get`)===!0&&At(t.snapshot,`users.prefs.set`)===!0;this.preferenceModeValue=s?`loading`:`local`,this.preferenceLoad=s?this.loadIdentityPreferences({client:r,profileId:o,gatewayUrl:e.gatewayUrl,scope:n}):Promise.resolve()}disconnect(){this.stopPreferencePublication?.(),this.stopPreferencePublication=void 0,this.preferenceScope=void 0}adoptPreferences(){this.read().agentsHydrated&&this.callbacks.onAdoptAgentDefaults(),this.callbacks.requestUpdate()}readPreference(e){return this.preferenceModeValue===`remote`?this.identityPreferences[z(e)]??null:ys(this.read().gatewayUrl,e)}preferenceWrites(t){let n=e.preferenceWriters.get(t);return n||(n={agents:new Map,revision:{},listeners:new Set},e.preferenceWriters.set(t,n)),n}capturePreferenceConsumption(e,t,n){return this.preparePreferenceWrite(e,t,{worktreeName:``},n)}persistPreference(e,t,n){return this.preparePreferenceWrite(e,t,n)?.()}preparePreferenceWrite(e,t,n,r){let{source:i,client:a,gatewayUrl:o,recoveryScope:s,bootId:c,data:l,pendingPlacementSessionKey:u}=this.read(),d=r!==void 0,f=!W(l)&&!l?.group&&(d||!u);if(!f&&!d||!i)return;let p=this.preferenceScope,m=i.snapshot.selfUser?.id,h=this.preferenceLoad,g=z(e),_=this.preferenceWrites(i),v=_.agents.get(g);v||(v={selection:{},write:Promise.resolve()},_.agents.set(g,v));let y=v.selection,b=()=>!!(a&&i.snapshot.client===a&&i.snapshot.phase===`connected`&&i.connection.gatewayUrl===o&&a.recoveryScope===s&&(i.snapshot.hello?.auth?.recoveryScope??``)===s&&i.snapshot.hello?.server?.bootId===c&&i.snapshot.selfUser?.id===m),x=d?n:{workspace:t,...n},S=e=>r?!e||e.worktreeName!==r.worktreeName||e.worktree!==!0||(e.workspace??t)!==t||ps(e,t).folder!==r.folder||(e.projectId??``)!==(r.projectId??``)?`superseded`:r.selectedBaseRef===void 0?!e.baseRef&&r.baseRef?`unconfirmed`:(e.baseRef??``)===(r.baseRef??``)?`match`:`superseded`:(e.baseRef??``)===r.selectedBaseRef?`match`:`superseded`:`match`;return async e=>{if(d&&(!b()||v.selection!==y))return;let t=Object.keys(n).some(e=>![`model`,`agentRuntime`,`thinkingLevel`,`fastMode`].includes(e))?{}:v.selection;if(v.selection=t,e?.(),!f)return;let r=()=>b()&&(d?v.selection===t:this.preferenceScope===p),i=this.preferenceModeValue!==`local`,s=async()=>{if(!(i&&(await h,!a||!r())))try{for(let e=0;e<3;e+=1){let e;if(this.preferenceModeValue!==`local`){if(!a||!m||!r())return;let{loadUserPreferences:t}=await R(async()=>{let{loadUserPreferences:e}=await import(`./user-prefs-request-Cs35VjAf.js`).then(e=>(e.t(),e.r));return{loadUserPreferences:e}},__vite__mapDeps([0,1,2]),import.meta.url),n=await t(a,m);if(!r())return;if(n.status!==`ok`)return!1;e=n.entries}let t=e?Ss(e)[g]:ys(o,g),n=S(t);if(n!==`match`)return n===`superseded`;let i={...t,...x};if(e&&a){let t=xs({[g]:i}),n=await He(a,{entries:t,expectedEntries:Object.fromEntries(Object.keys(t).map(t=>[t,e[t]??null]))});if(!b()||n.status!==`ok`&&!r())return;if(n.status===`conflict`)continue;if(n.status!==`ok`)return!1;Cs(o,g,i)}else{if(!Cs(o,g,i))return!1;i=ys(o,g)??{}}_.revision={};for(let e of _.listeners)e(g,i,d);return e&&this.preferenceScope===p&&(this.identityPreferences={...this.identityPreferences,[g]:i},this.callbacks.requestUpdate()),!0}return!1}catch{return!1}},c=i?v.write.then(s,s):s();return v.write=c.then(e=>{e===!1&&r()&&Te({message:w(d?`newSession.worktreeNameClearUnconfirmed`:`newSession.preferenceSaveUnconfirmed`)})}),v.write}}async loadIdentityPreferences(e){let t=this.read().source,n=t?this.preferenceWrites(t):void 0,r=n?.revision,i=0;try{let{loadUserPreferences:t}=await R(async()=>{let{loadUserPreferences:e}=await import(`./user-prefs-request-Cs35VjAf.js`).then(e=>(e.t(),e.r));return{loadUserPreferences:e}},__vite__mapDeps([0,1,2]),import.meta.url),a=async()=>{let n=await t(e.client,e.profileId);if(n.status!==`ok`)throw Error(`User preferences unavailable`);return n.entries};if(this.preferenceScope!==e.scope)return;let o=await a(),s=bs(e.gatewayUrl);for(;this.preferenceScope===e.scope;){if(n?.revision!==r)return this.loadIdentityPreferences(e);let t=Ss(o);if(o[`new-session.migration.v1`]!==!0&&i<3){let n=Object.fromEntries(Object.entries(s).filter(([e])=>!Object.hasOwn(t,e))),r=Object.entries(xs(n)),c=Object.fromEntries(r.slice(0,31));r.length<32&&(c[Es]=!0);let l=await He(e.client,{entries:c,expectedEntries:{...Object.fromEntries(Object.keys(c).map(e=>[e,o[e]??null])),[Es]:o[`new-session.migration.v1`]??null}}).catch(()=>null);if(this.preferenceScope!==e.scope)return;if(l?.status===`conflict`){i+=1,o=await a();continue}if(l?.status===`ok`){o={...o,...c};continue}i===0&&(t={...s,...t})}if(n?.revision!==r)return this.loadIdentityPreferences(e);this.identityPreferences=t,this.preferenceModeValue=`remote`;for(let[n,r]of Object.entries(t))Cs(e.gatewayUrl,n,r);this.adoptPreferences();return}}catch{this.preferenceScope===e.scope&&(this.preferenceModeValue=i>0?`remote`:`local`,this.callbacks.requestUpdate())}}}})))()}function js(e){let t=Ms.get(e.client);t||(t=new WeakMap,Ms.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 Ns(e,()=>{t.get(r)===a&&t.delete(r)});i=a,n.set(r,i)}return i}var Ms,Ns;function Ps(){return(Ps=e((()=>{Re(),Os(),Pn(),Ms=new WeakMap,Ns=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 He(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 R(async()=>{let{loadUserPreferences:e}=await import(`./user-prefs-request-Cs35VjAf.js`).then(e=>(e.t(),e.r));return{loadUserPreferences:e}},__vite__mapDeps([0,1,2]),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=us(t.entries[Ds]),this.mode=`remote`}catch{this.mode=`local`}finally{this.publish(`loaded`)}}}})))()}function Fs(e){return e.gatewayIdentityChanged||!e.placementDraftOwned?`gateway-changed`:`placement-interrupted`}var Is,Ls;function Rs(){return(Rs=e((()=>{na(),_n(),Is=new WeakMap,Ls=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=Is.get(e);return t||(t=new Map,Is.set(e,t)),t}claimKey(e,t,n){return JSON.stringify([e,t,n])}clear(){this.persistent&&Oa(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=Ui(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:${Nn()}`,n=xa({...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:Nn(),message:e.message,...e.mentions?.length?{mentions:e.mentions.map(e=>({...e}))}:{},attachments:e.attachments,target:e.target,agentId:e.agentId,gatewayUrl:e.gatewayUrl,recoveryScope:e.recoveryScope,phase:`creating`,createParams:n};return r&&!Na(i)?null:(this.apply(i,!1,r),n)}promoteToDispatching(e){let t=this.sessionKey,n=this.snapshot(e,`dispatching`);return!n||this.persistent&&!qi(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.map(e=>({...e}))}:{},attachments:this.attachments?[...this.attachments]:void 0,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 zs,Bs;function Vs(){return(Vs=e((()=>{Gn(),ot(),ft(),d(),F(),jt(),C(),ga(),c(),G(),Bo(),ls(),As(),Ps(),Rs(),P(),zs=[0,1e3,3e3],Bs=class{constructor(e,t,n){this.read=t,this.callbacks=n,this.cloudProfilesValue=[],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.handleCatalogRetry=()=>{let{context:e,data:t}=this.read();if(!this.gatewayConnectedValue||t?.group&&e?.sessions.groupsStatus()===`loading`||!t?.startTerminal&&!Ao(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.callbacks.requestUpdate(),n.catch(()=>void 0).then(()=>this.callbacks.updateComplete()).finally(()=>{this.catalogRetryingValue=!1,this.catalogRevalidationPending?(this.catalogRevalidationPending=!1,this.handleCatalogRetry()):this.retryPendingCatalogTarget(),this.callbacks.requestUpdate()}))},this.preferences=new ks(()=>({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}),n),this.gatewayNameTask=new Vn(e,{args:()=>[this.read().isConnected&&this.gatewayConnectedValue?this.gatewaySource:null,Ca(this.read().context?.gateway.snapshot)&&document.visibilityState!==`hidden`,this.gatewayConnectionEpochValue],task:async([e,t,n],{signal:r})=>{if(!e||!t)return``;try{let{value:t}=await ta(e,r,{fresh:!0});return I(t.machineName)??I(t.hostname)?.split(`.`,1)[0]??``}catch{return``}}}),new o(e).watch(()=>document,(e,t)=>(e.addEventListener(`visibilitychange`,t),()=>e.removeEventListener(`visibilitychange`,t))),this.cloudProfileTask=new Vn(e,{args:()=>[this.read().isConnected&&this.gatewayConnectedValue?this.gatewayClientValue:null,this.gatewayConnectionEpochValue,Fe(this.read().context?.gateway.snapshot.hello?.auth??null),this.read().isAdmin,this.gatewayRecoveryScopeValue,this.read().runtimeId],task:async([e,t,n,r,i,a])=>{if(!e)return Hn;if(!n)return{profiles:[],environments:[]};let o=await ns(e,a);return{...o,profiles:r?o.profiles:[]}},onComplete:e=>{this.resetCloudProfileRetry(),this.environmentsValue=e.environments,this.applyCloudProfiles(e.profiles),this.cloudProfilesReadyValue=!0},onError:()=>{this.scheduleCloudProfileRetry()}})}get gatewayName(){return this.gatewayNameTask.status===V.COMPLETE?this.gatewayNameTask.value??``:``}get cloudProfiles(){return this.cloudProfilesValue}get environments(){return this.environmentsValue}get cloudProfilesReady(){return this.cloudProfilesReadyValue}get cloudProfilesPending(){return this.cloudProfileTask.status===V.PENDING}get deviceCatalogDisabledReason(){return this.cloudProfilesReadyValue&&this.cloudProfileTask.status===V.COMPLETE?void 0:w(`newSession.placementNotReady`)}get catalogRetrying(){return this.catalogRetryingValue}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`}resolvedGroupCategory(){let e=this.read();return At(e.context?.gateway.snapshot??{},`sessions.groups.defaults`)===!0?jo(e.data,e.context?.sessions):void 0}refreshCloudProfiles(){if(this.cloudProfileTask.status===V.PENDING){let e=this.cloudProfileRefresh??this.cloudProfileTask.taskComplete.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.cloudProfileTask.run()}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=!r&&(s||this.gatewayClientValue!==t.client),l=!r&&this.gatewayConnectedValue!==n,u=n&&(c||!this.gatewayConnectedValue),d=n&&t.client?.recoveryScopeReady===!0&&!this.gatewayRecoveryScopeReady,f=n?t.hello?.auth?.recoveryScope??``:at({client:t.client})??``,p=!r&&this.gatewayRecoveryScopeValue!==f;if(this.gatewaySource=e,this.gatewayClientValue=t.client,this.gatewayUrlValue=e.connection.gatewayUrl,this.gatewayBootIdValue=i,this.gatewayRecoveryScopeValue=f,this.gatewayRecoveryScopeReady=t.client?.recoveryScopeReady===!0,this.gatewayConnectedValue=n,this.read().visibility===`draft`&&!this.read().canStartAsDraft&&this.callbacks.onVisibilityRetired(),o||a||c||l||p){let e=s||o||p,t=o||p;this.invalidateDiscovery(e,Fs({gatewayIdentityChanged:t,placementDraftOwned:!!this.read().pendingPlacement.sessionKey}))}if(r||o||p||d||u){let e=this.read().pendingPlacement;e.gatewayUrl&&(e.gatewayUrl!==this.gatewayUrlValue||e.recoveryScope!==this.gatewayRecoveryScopeValue)&&this.callbacks.onPendingPlacementReset(),f&&(!n||t.client?.recoveryScopeReady)&&this.callbacks.onRecoveryReady(this.gatewayUrlValue,this.gatewayRecoveryScopeValue)}u&&(this.gatewayConnectionEpochValue+=1,!r&&this.read().data?.startTerminal?this.handleCatalogRetry():this.retryPendingCatalogTarget()),this.preferences.synchronize(),this.synchronizeIdentityPreferences(t.selfUser?.id),this.callbacks.requestUpdate()}invalidateDiscovery(e,t){this.cloudProfileRefresh=null,this.cloudProfileTask.run([null,-1,!1,!1,``]),this.cloudProfilesValue=[],this.cloudProfilesReadyValue=!1,e&&(this.environmentsValue=null),this.resetCloudProfileRetry(),this.callbacks.onInvalidate(e,t),this.callbacks.requestUpdate()}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||!Ao(t,e?.sessions)){globalThis.clearTimeout(this.catalogRetryTimer),this.catalogRetryTimer=void 0,this.catalogRetryScope=``,this.catalogRetryAttempt=0;return}let n=`${this.gatewayConnectionEpochValue}:${xo(t)}`;if(this.catalogRetryScope!==n&&(globalThis.clearTimeout(this.catalogRetryTimer),this.catalogRetryTimer=void 0,this.catalogRetryScope=n,this.catalogRetryAttempt=0),this.catalogRetryTimer||this.catalogRetryAttempt>=zs.length)return;let r=zs[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`||!Ao(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){let t=this.read();if(W(t.data)||t.data?.group||t.pendingPlacement.sessionKey)return null;let n=this.preferences.readPreference(e);if(this.callbacks.preferenceScope!==`palette`)return n;let r=this.callbacks.readPalettePreference?.();return{...n,...r?.agentId===z(e)?r.selection:{},worktreeName:``}}capturePreferenceConsumption(e,t,n){if(this.callbacks.preferenceScope!==`palette`)return this.preferences.capturePreferenceConsumption(e,t,n)}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.cloudProfileRefresh=null,this.gatewaySource=null,this.gatewayClientValue=null,this.gatewayConnectedValue=!1,this.gatewayConnectionEpochValue=0,this.catalogRetryScope=``,this.catalogRetryAttempt=0,globalThis.clearTimeout(this.catalogRetryTimer),this.catalogRetryTimer=void 0,this.gatewayNameTask.run([null,!1,-1]),this.cloudProfileTask.run([null,-1,!1,!1,``]),this.resetCloudProfileRetry()}applyCloudProfiles(e){let t=e.length>0&&!this.gatewayRecoveryScopeValue;this.cloudProfilesValue=t?[]:e;let n=this.read(),r=!!n.pendingPlacement.sessionKey,i=Fe(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(w(`newSession.catalogUnavailable`)):t?this.callbacks.onCloudState(w(`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)return;if(this.cloudProfileRetryAttempt>=zo.length){this.cloudProfilesReadyValue||=(this.applyCloudProfiles([]),!0);return}let e=zo[this.cloudProfileRetryAttempt];this.cloudProfileRetryAttempt+=1,this.cloudProfileRetryTimer=globalThis.setTimeout(()=>{this.cloudProfileRetryTimer=void 0,this.gatewayConnectedValue&&this.cloudProfileTask.run()},e)}synchronizeIdentityPreferences(e){let t=this.gatewayConnectedValue?this.gatewayClientValue:null,n=this.read().context,r=n?.gateway.snapshot.hello,i=n&&At(n.gateway.snapshot,`users.prefs.get`)===!0&&At(n.gateway.snapshot,`users.prefs.set`)===!0,a=this.callbacks.preferenceScope===`palette`&&t&&r&&e&&i?js({client:t,hello:r,profileId:e,gatewayUrl:this.gatewayUrlValue}):void 0;if(a===this.identityPreferences||(this.stopPreferences?.(),this.stopPreferences=void 0,this.identityPreferences=a,!a))return;let o=()=>{this.identityPreferences===a&&this.callbacks.requestUpdate()};this.stopPreferences=a.subscribe(o,()=>this.identityPreferences===a&&this.gatewayConnectedValue&&this.read().context?.gateway.snapshot.client===t&&this.read().context?.gateway.snapshot.hello===r&&this.read().context?.gateway.connection.gatewayUrl===this.gatewayUrlValue),a.mode!==`loading`&&o()}}})))()}function Hs(e){return e instanceof $e&&e.gatewayCode===`INVALID_REQUEST`&&/^(?:Error:\s+)?(?:ENOENT|ENOTDIR):/u.test(e.message)}var Us;function Ws(){return(Ws=e((()=>{je(),Us=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=>{if(i()){if(!this.read().isAdmin||Hs(e)){this.restore();return}this.state=`failed`,this.callbacks.onFailed()}})}}})))()}function Gs(e){if(!ni(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 Ks(e,t){if(!t)return[...e];let n=t.toLowerCase(),r=[],i=[],a=[],o=[];for(let s of e){if(s.hidden&&!t.startsWith(`.`))continue;let e=s.name.toLowerCase();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 qs(e){let{listing:t,draft:n,loading:r}=e,i=Gs(n);if(t&&Ir(n,t.path)||!i){let e=t?.entries??[];return{entries:e,empty:t&&e.length===0&&!r?`no-subfolders`:`none`}}if(t&&Ir(i.directory,t.path)){let e=Ks(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 Js(){return(Js=e((()=>{aa()})))()}var Ys;function Xs(){return(Xs=e((()=>{pn(),d(),F(),Ws(),aa(),Js(),P(),Ys=class{constructor(e,t,n){this.listDirectory=e,this.requestUpdate=t,this.onListing=n,this.listing=null,this.draft=``,this.loading=!1,this.error=null,this.activeIndex=-1,this.token=0,this.listingGenerationValue=0}get listingGeneration(){return this.listingGenerationValue}navigate(e,t=`navigation`){return this.cancelPending(),this.draft=e??``,this.activeIndex=-1,this.error=null,this.loading=!0,this.requestUpdate(),this.load(e,t,this.token)}setDraft(e){this.cancelPending(),this.draft=e,this.activeIndex=-1,this.error=null;let t=Gs(e.trim());if(this.loading=!(!t||this.draftInLoadedDirectory()),t&&this.loading){let e=this.token;this.timer=globalThis.setTimeout(()=>{this.timer=void 0,this.load(t.directory,`typing`,e)},300)}this.requestUpdate()}draftInLoadedDirectory(){if(!this.listing)return!1;let e=this.draft.trim(),t=Gs(e);return!t||Ir(e,this.listing.path)||Ir(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.requestUpdate())}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||ni(e)?e:null}reset(){this.cancelPending(),this.listing=null,this.listingGenerationValue+=1,this.draft=``,this.loading=!1,this.error=null,this.activeIndex=-1}view(){let e=this.draft.trim();return qs({listing:this.listing,draft:e,loading:this.loading})}cancelPending(){this.token+=1,globalThis.clearTimeout(this.timer),this.timer=void 0}async load(e,t,n){let r=this.draft;try{let i=await this.listDirectory(e);if(n!==this.token)return;this.listing=i,this.listingGenerationValue+=1,t!==`typing`&&this.draft===r&&(this.draft=i.path),this.activeIndex=-1,this.onListing?.(i)}catch(r){if(n!==this.token)return;t===`initial`&&e&&Hs(r)?(this.draft=``,await this.load(void 0,`navigation`,n)):t!==`typing`&&(this.error=zn(r)?.missingScope?w(`newSession.browseRequiresAdmin`):w(`newSession.browserLoadFailed`))}finally{n===this.token&&(this.loading=!1,this.requestUpdate())}}}})))()}function Zs(e,t,n){return k`
<span class="new-session-page__target-icon" aria-hidden="true">${e}</span>
<span class="new-session-page__trigger-label">${t}</span>
${n?k`<span class="new-session-page__trigger-summary">${n}</span>`:O}
<span
class="new-session-page__trigger-chevron new-session-page__trigger-chevron--desktop"
aria-hidden="true"
>${E.chevronDown}</span
>
<span
class="new-session-page__trigger-chevron new-session-page__trigger-chevron--mobile"
aria-hidden="true"
>${E.chevronsUpDown}</span
>
`}function Qs(){return(Qs=e((()=>{A(),T()})))()}function $s(e){let{browser:t,id:n}=e,{entries:r,empty:i}=t.view(),a=t.highlightedEntry(),o=t.usablePath(),s=e.registerProjectPath;return k`
<div
class="new-session-page__browser"
@keydown=${t=>{t.key===`Escape`&&(t.preventDefault(),t.stopImmediatePropagation(),e.onBack())}}
>
<div class="new-session-page__browser-head">
<button
type="button"
class="new-session-page__browser-nav"
title=${w(`newSession.browserUp`)}
aria-label=${w(`newSession.browserUp`)}
@click=${()=>{t.listing?.parent?t.navigate(t.listing.parent):e.onBack()}}
>
${E.arrowLeft}
</button>
<input
class="new-session-page__browser-path"
type="text"
role="combobox"
aria-expanded="true"
aria-autocomplete="list"
aria-controls=${`${n}-list`}
aria-activedescendant=${a?`${n}-option-${t.activeIndex}`:O}
aria-label=${w(`newSession.folder`)}
placeholder=${e.label}
.value=${t.draft}
@input=${e=>{t.setDraft(e.target.value)}}
@keydown=${e=>{switch(e.key){case`ArrowDown`:case`ArrowUp`:e.preventDefault(),t.moveHighlight(e.key===`ArrowDown`?1:-1),requestAnimationFrame(()=>document.getElementById(`${n}-option-${t.activeIndex}`)?.scrollIntoView({block:`nearest`}));break;case`Enter`:e.preventDefault(),t.activate();break;case`Tab`:!e.shiftKey&&t.completeHighlighted()&&e.preventDefault()}}}
/>
${t.loading?k`<span class="new-session-page__browser-loading" role="status"
>${w(`common.loading`)}</span
>`:O}
<button
type="button"
class="new-session-page__browser-nav"
title=${w(`common.close`)}
aria-label=${w(`common.close`)}
@click=${e.onClose}
>
${E.x}
</button>
</div>
${t.error?k`<div class="new-session-page__error" role="alert">${t.error}</div>`:O}
<div
class="new-session-page__browser-list"
role="listbox"
id=${`${n}-list`}
aria-label=${w(`newSession.folder`)}
>
${i===`none`?O:k`<div class="new-session-page__browser-empty">
${w(i===`no-matches`?`newSession.browserNoMatches`:`newSession.browserEmpty`)}
</div>`}
${r.map((e,r)=>k`
<button
type="button"
role="option"
id=${`${n}-option-${r}`}
aria-selected=${r===t.activeIndex}
class="new-session-page__browser-entry ${r===t.activeIndex?`new-session-page__browser-entry--active`:``} ${e.hidden?`new-session-page__browser-entry--hidden`:``}"
title=${e.hidden?w(`newSession.hiddenFolder`):O}
@click=${()=>void t.navigate(e.path)}
>
<span class="new-session-page__target-icon" aria-hidden="true">${E.folder}</span>
<span>${e.name}</span>
</button>
`)}
</div>
<div class="new-session-page__browser-actions">
${s?k`
<button
type="button"
class="new-session-page__browser-register"
?disabled=${e.registeringProject}
@click=${()=>e.onRegisterProject(s)}
>
${w(`newSession.registerProject`)}
</button>
`:O}
<button
type="button"
class="new-session-page__browser-use"
?disabled=${o===null||e.registeringProject}
@click=${()=>{o!==null&&(e.onApplyFolder(o),e.onClose())}}
>
${w(`newSession.browserUse`)}
</button>
</div>
</div>
`}function ec(){return(ec=e((()=>{A(),T(),d(),F(),P()})))()}function tc(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 nc(e){let t=e.trim();return!t||t.startsWith(`-`)||/\s/u.test(t)?null:/^(?:https:\/\/|ssh:\/\/git@|git@[^:]+:)/iu.test(t)?t:null}function rc(e){let t=e.folder.trim(),n=e.projects.find(t=>t.id===e.projectId),r=e.projectQuery.trim().toLowerCase(),i=r?e.projects.filter(e=>[e.displayName,e.originUrl??``,e.repoRoot??``].join(`
`).toLowerCase().includes(r)):e.projects;return{label:e.freshWorkspace?w(`newSession.newWorkspace`):n?n.displayName:e.selectedRemoteProject?.identity?e.selectedRemoteProject.identity:t?fe(t):fe(e.workspace)||w(`newSession.folderPlaceholder`),localProjects:i,recents:r?[]:e.recents.filter(e=>e.kind!==`project`),showWorkspace:!r||[fe(e.workspace),e.workspace].join(`
`).toLowerCase().includes(r)}}function ic(e){let t=e.folder.trim(),n=nc(e.projectQuery),r=t=>e.onSelectRemoteProject({identity:t,cloneUrl:t}),i=e.projectQuery.trim(),a=!e.browseAvailable&&!e.isAdmin,o=e.state.recents,s=tc(o,e=>e.displayName,[e=>e.kind===`folder`?fi(e.folder):void 0,e=>e.kind===`folder`?e.folder:void 0,e=>e.kind===`folder`?e.folder:e.url]),c=k`
<button
type="button"
class="session-menu__item"
data-value="browse"
aria-pressed="false"
aria-disabled=${a?`true`:O}
?disabled=${e.submitting||e.pendingPlacement||!e.browseAvailable&&!a}
@click=${()=>{e.browseAvailable&&!e.submitting&&!e.pendingPlacement&&e.onBrowse()}}
>
<span class="session-menu__check" aria-hidden="true"></span>
<span class="session-menu__text">${w(`newSession.browse`)}</span>
<span class="new-session-page__menu-chevron" aria-hidden="true">${E.chevronRight}</span>
</button>
`;return k`
<span class="new-session-page__select">
<button
id="new-session-project-trigger"
type="button"
class="new-session-page__trigger ${e.popoverHiding?`new-session-page__trigger--hiding`:``}"
aria-label="${w(`newSession.what`)}: ${e.state.label}"
data-project-id=${e.projectId||O}
aria-haspopup="dialog"
aria-expanded=${String(e.popoverOpen)}
?disabled=${e.submitting||e.pendingPlacement}
@click=${e.onGuardTransition}
>
${Zs(e.projectId?E.gitBranch:E.folder,e.state.label)}
</button>
</span>
<wa-popover
${yt(_r)}
class="new-session-page__select new-session-page__project-popover new-session-page__picker-popover"
for="new-session-project-trigger"
placement="bottom-start"
without-arrow
@wa-show=${e.onPopoverShow}
@wa-hide=${e.onPopoverHide}
@wa-after-hide=${e.onPopoverAfterHide}
>
${e.browserOpen?$s({browser:e.browser,id:`new-session-place-browser`,label:e.gatewayLabel,registerProjectPath:e.registerProjectPath,registeringProject:e.registeringProject,onBack:e.onBrowserBack,onRegisterProject:e.onRegisterProject,onClose:e.onClose,onApplyFolder:e.onApplyFolder}):k`
<div class="new-session-page__picker-root">
<div class="new-session-page__menu-title">${w(`newSession.projects`)}</div>
${e.onNewWorkspace&&!i?q({value:`new-workspace`,label:w(`newSession.newWorkspace`),icon:E.folder,sub:w(`newSession.newWorkspaceDescription`),checked:e.freshWorkspace===!0,onSelect:e.onNewWorkspace},e.submitting||e.pendingPlacement):O}
${e.workspace&&e.state.showWorkspace?q({value:`workspace`,label:fe(e.workspace),icon:E.folder,checked:!e.freshWorkspace&&!e.projectId&&t===e.workspace,onSelect:()=>e.onApplyFolder(e.workspace)},e.submitting):O}
<label class="new-session-page__project-search">
<span class="sr-only">${w(`newSession.projectSearchPlaceholder`)}</span>
<input
type="search"
placeholder=${w(`newSession.projectSearchPlaceholder`)}
.value=${e.projectQuery}
?disabled=${e.submitting||e.pendingPlacement}
@input=${t=>e.onProjectQueryInput(t.target instanceof HTMLInputElement?t.target.value:``)}
@keydown=${t=>{t.key===`Enter`&&n&&e.projectAddAvailable&&(t.preventDefault(),r(n))}}
/>
</label>
${e.state.localProjects.map(t=>q({value:`project:${t.id}`,label:t.displayName,icon:E.gitBranch,checked:e.projectId===t.id,title:t.repoRoot,onSelect:()=>e.onSelectProject(t.id)},e.submitting))}
${n&&e.projectAddAvailable?q({value:`project-clone-url`,label:n,icon:E.gitBranch,sub:w(`newSession.cloneProject`),checked:e.selectedRemoteProject?.cloneUrl===n,onSelect:()=>r(n)},e.submitting):O}
${!n&&i.length>=2&&e.projectSearchAvailable?k`
<div class="new-session-page__menu-title">
${w(`newSession.githubProjects`)}
</div>
${e.projectSearchCredentialMissing?k`<div class="new-session-page__menu-note">
${w(`newSession.githubTokenHint`)}
</div>`:O}
${e.projectSearchLoading?k`<div class="new-session-page__project-status" role="status">
${w(`common.loading`)}
</div>`:O}
${e.projectSearchError?k`<div class="new-session-page__project-error" role="alert">
${e.projectSearchError}
</div>`:O}
${e.remoteProjects.map(t=>q({value:`remote-project:${t.fullName}`,label:t.fullName,icon:E.gitBranch,sub:t.description??w(`newSession.cloneProject`),checked:e.selectedRemoteProject?.cloneUrl===t.cloneUrl,title:t.webUrl,onSelect:()=>e.onSelectRemoteProject({identity:t.fullName,cloneUrl:t.cloneUrl,...t.defaultBranch?{defaultBranch:t.defaultBranch}:{}})},e.submitting||!e.projectAddAvailable))}
`:O}
${e.projects.length===0&&e.canWrite&&!e.isAdmin?k`<div class="new-session-page__menu-note">
${w(`newSession.projectsAdminHint`)}
</div>`:O}
${e.state.recents.length>0?k`
<div class="new-session-page__menu-title">
${w(`newSession.recentFolders`)}
</div>
${o.map((n,r)=>q({value:n.kind===`repository`?`repository:${n.url}`:`recent:${n.folder}`,label:n.displayName,icon:n.kind===`folder`?E.folder:E.gitBranch,sub:s[r],checked:n.kind===`repository`?e.selectedRemoteProject?.cloneUrl===n.url:!e.freshWorkspace&&!e.projectId&&t===n.folder,title:n.kind===`repository`?n.url:n.folder,onSelect:()=>n.kind===`repository`?e.onSelectRemoteProject({identity:n.displayName,cloneUrl:n.url}):e.onApplyFolder(n.folder)},e.submitting))}
`:O}
${a?k`<openclaw-tooltip .content=${w(`newSession.browseRequiresAdmin`)}>
${c}
</openclaw-tooltip>`:c}
</div>
`}
</wa-popover>
`}function ac(){return(ac=e((()=>{A(),ht(),T(),mr(),d(),F(),ls(),aa(),Qs(),ec(),P()})))()}function oc(e,t){let n=new Set,r=[];for(let i of e){let e=I(i.execCwd)??I(i.worktree?.repoRoot),a=I(i.execNode);if(e&&!a&&e!==t.workspace&&t.allowGatewayFolder(e)&&!n.has(e)&&(n.add(e),r.push({folder:e}),r.length>=4))break}return r}function sc(){return(sc=e((()=>{})))()}var cc;function lc(){return(lc=e((()=>{Gn(),Oe(),jt(),Hi(),aa(),Xs(),ac(),sc(),cc=class{constructor(e,t,n,r){this.host=e,this.gateway=t,this.read=n,this.callbacks=r,this.lastProjectResult=null,this.projectSelection=null,this.projectQueryValue=``,this.environmentQueryValue=``,this.debouncedProjectQuery=``,this.browserOpenValue=!1,this.browserProjectPathValue=null,this.browserRegistrationId=null,this.browserRegistrationCounter=0,this.openPopoverValue=null,this.focusRequestId=0,this.hidingPopovers=new Set,this.browser=new Ys(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`,e?{path:e}:{})},this.callbacks.requestUpdate,e=>{this.browserProjectPathValue=null,this.callbacks.onApprovedListing(e);let t=this.read(),n=t.context?.gateway.snapshot.client;t.isAdmin&&n&&n.request(`worktrees.branches`,{repoRoot:e.path,includeRepositoryStatus:!0}).then(t=>{this.browser.listing===e&&t.repositoryStatus===`git`&&(this.browserProjectPathValue=e.path,this.callbacks.requestUpdate())}).catch(()=>void 0)}),e.addController({hostUpdate:()=>this.bindProjectCatalog()}),this.projectSearchTask=new Vn(e,{args:()=>[this.read().context&&this.gateway.connected?this.gateway.client:null,this.read().context?kt(this.read().context?.gateway.snapshot,`projects.searchRemote`,`operator.read`):!1,this.debouncedProjectQuery,this.gateway.connectionEpoch],task:([e,t,n],{signal:r})=>!e||!t||n.length<2||nc(n)?Hn:e.request(`projects.searchRemote`,{query:n},{signal:r})})}get projects(){return this.projectCatalog?.snapshot.result?.projects??[]}get projectsReady(){return this.projectCatalog?.snapshot.ready??!1}get projectsLoading(){return this.projectCatalog?.loading??!1}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 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.requestUpdate()}get projectSearchResult(){return this.projectSearchTask.status===V.COMPLETE&&this.debouncedProjectQuery===this.projectQueryValue.trim()?this.projectSearchTask.value??null:null}get projectSearchLoading(){return this.debouncedProjectQuery.length>=2&&this.debouncedProjectQuery===this.projectQueryValue.trim()&&this.projectSearchTask.status===V.PENDING}get projectSearchError(){return this.projectSearchTask.status!==V.ERROR||this.debouncedProjectQuery!==this.projectQueryValue.trim()?null:ke(this.projectSearchTask.error)}get browserOpen(){return this.browserOpenValue}get browserProjectPath(){return this.browser.loading||!this.browser.draftInLoadedDirectory()?null:this.browserProjectPathValue}get browserRegistering(){return this.browserRegistrationId!==null}popoverOpen(e){return this.openPopoverValue===e}popoverHiding(e){return this.hidingPopovers.has(e)}popoverCallbacks(e){return{popoverOpen:this.popoverOpen(e),popoverHiding:this.popoverHiding(e),onGuardTransition:t=>this.guardPopoverTransition(t,e),onPopoverShow:()=>this.transitionPopover(e,!0),onPopoverHide:()=>this.transitionPopover(e,!1),onPopoverAfterHide:()=>this.onPopoverAfterHide(e)}}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?Ra(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.requestUpdate()};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||oi(e.workspaceRoots,t);return this.projectRecents?.filter(e=>e.kind===`project`?this.projects.some(t=>t.id===e.projectId):e.kind===`repository`||!e.execNode&&t(e.folder))??oc(e.sessions,{workspace:e.workspace,allowGatewayFolder:t}).map(e=>({kind:`folder`,folder:e.folder,displayName:fe(e.folder)}))}changeProjectQuery(e){this.projectQueryValue=e,this.clearProjectSearchTimer(),this.debouncedProjectQuery=``,this.projectSearchTask.run([null,!1,``,this.gateway.connectionEpoch]);let t=e.trim(),n=this.read().context;if(t.length<2||nc(t)||!this.gateway.connected||!this.gateway.client||!n||!kt(n.gateway.snapshot,`projects.searchRemote`,`operator.read`)){this.callbacks.requestUpdate();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.projectSearchTask.run([r,!0,t,i]),this.callbacks.requestUpdate())},300),this.callbacks.requestUpdate()}resetProjectSearch(){this.clearProjectSearchTimer(),this.projectQueryValue=``,this.debouncedProjectQuery=``,this.callbacks.requestUpdate()}resetProjects(e=!0){this.projectCatalog&&this.refreshProjects(!0),e&&(this.clearProjectSelection(),this.resetProjectSearch())}close(){this.resetBrowser(!0);for(let e of[`where`,`project`,`checkout`]){let t=this.callbacks.querySelector(`.new-session-page__${e}-popover`);t&&(t.open=!1)}}showRoot(){let e=this.browserOpenValue;this.resetBrowser(!1),e&&this.focusProjectView(`[data-value="browse"]`)}selectGatewayBrowser(e){this.browserOpenValue=!0,this.browserProjectPathValue=null,this.browser.navigate(e&&ni(e)?e:void 0,`initial`),this.focusProjectView(`.new-session-page__browser-path`)}async registerBrowserProject(e){let t=this.read(),n=t.context?.gateway.snapshot,r=n?.client;if(n?.phase!==`connected`||!r||!t.isAdmin||this.browserProjectPath!==e||this.browserRegistering)return;let i=this.browser.listingGeneration,a=++this.browserRegistrationCounter;this.browserRegistrationId=a;let o=()=>this.browserRegistrationId===a&&this.browser.listingGeneration===i&&this.browserProjectPath===e&&r===this.gateway.client;this.browser.error=null,this.callbacks.requestUpdate();try{let t=await r.request(`projects.register`,{path:e});if(!o()||(await this.refreshProjects(!0),!o()))return;this.callbacks.onSelectProject(t.id),this.close()}catch(e){o()&&(this.browser.error=ke(e))}finally{this.browserRegistrationId===a&&(this.browserRegistrationId=null,this.callbacks.requestUpdate())}}transitionPopover(e,t){t?(this.openPopoverValue=e,e===`where`&&(this.environmentQueryValue=``)):(this.openPopoverValue===e&&(this.openPopoverValue=null),this.hidingPopovers.add(e)),e===`project`?this.showRoot():this.callbacks.requestUpdate()}onPopoverAfterHide(e){this.hidingPopovers.delete(e);let t=`${this.callbacks.pickerIdPrefix??`new-session`}-${e}-trigger`,n=this.callbacks.activeElement(),r=this.callbacks.querySelector(`.new-session-page__${e}-popover`),i=this.callbacks.body();(!n||n===i||r?.contains(n))&&this.callbacks.querySelector(`#${t}`)?.focus(),this.callbacks.requestUpdate()}guardPopoverTransition(e,t){this.hidingPopovers.has(t)&&(e.preventDefault(),e.stopImmediatePropagation())}clearPopoverHiding(){this.hidingPopovers.clear(),this.callbacks.requestUpdate()}disconnect(){this.focusRequestId+=1,this.environmentQueryValue=``,this.browser.reset(),this.clearProjectSearchTimer(),this.projectCatalogCleanup?.(),this.projectCatalogCleanup=void 0,this.projectCatalogGateway=void 0,this.projectCatalog=void 0,this.projectSearchTask.run([null,!1,``,-1])}resetBrowser(e){this.focusRequestId+=1,this.browser.reset(),this.browserOpenValue=!1,this.browserProjectPathValue=null,this.browserRegistrationId=null,e&&(this.openPopoverValue=null),this.callbacks.requestUpdate()}clearProjectSearchTimer(){globalThis.clearTimeout(this.projectSearchTimer),this.projectSearchTimer=void 0}focusProjectView(e){let t=++this.focusRequestId,n=this.callbacks.activeElement();this.host.updateComplete.then(()=>{if(t!==this.focusRequestId||this.openPopoverValue!==`project`||this.hidingPopovers.has(`project`))return;let r=this.callbacks.activeElement();if(r&&r!==n&&r!==this.callbacks.body())return;let i=this.callbacks.querySelector(`.new-session-page__project-popover`)?.querySelector(e);i?.isConnected&&i.focus({preventScroll:!0})})}}})))()}function uc(e){let t=e?.issues?.find(e=>e.code===`update-required`);return t?w(`newSession.nodeUpdateRequired`,{updateCommand:t.updateCommand,restartCommand:t.headlessReconnectCommand}):e?.issues?.find(e=>e.code===`worker-host-unavailable`)?.message}function dc(e){if(e.connected)return;let t=e.environment;if(t?.lastConnectedAtMs===void 0)return w(`newSession.neverConnected`);if(t.lastDisconnectedAtMs!==void 0){let n=zt(Math.max(0,e.nowMs-t.lastDisconnectedAtMs))??w(`common.justNow`);return w(`newSession.offlineFor`,{duration:n})}let n=t.lastSeenAtMs??t.lastConnectedAtMs;return w(`newSession.lastSeen`,{time:Ae(n)})}function fc(e,t={}){let n=dc({environment:e,connected:t.connected??!0,nowMs:t.nowMs??Date.now()}),r=uc(e)??n,i=r?[r]:[];e?.platform&&i.push(Dr(e.platform));for(let t of pc(e?.capabilities))if(i.includes(t)||i.push(t),i.length>=4)break;return i}function pc(e=[]){return[...new Set(e.flatMap(e=>{let t=e.split(`.`,1)[0]?.toLowerCase(),n=Object.entries(mc).find(([e])=>e===t)?.[1];return n?[w(n)]:[]}))]}var mc;function hc(){return(hc=e((()=>{d(),F(),dn(),g(),Qa(),P(),mc={camera:`newSession.capabilityCamera`,location:`newSession.capabilityLocation`,talk:`newSession.capabilityTalk`,screen:`newSession.capabilityScreenCapture`,canvas:`newSession.capabilityCanvas`,microphone:`newSession.capabilityVoice`,voice:`newSession.capabilityVoice`}})))()}function gc(e,t){let n=uc(e);if(n!==void 0)return n;if(e.status!==`available`)return w(`newSession.deviceUnavailable`);if(e.sessionHost!==!0)return w(`newSession.sessionHostingDisabled`);if(t.requiredNodeCommands.length>0){let t=e.requiredNodeCommand;if(!t)return w(`newSession.placementNotReady`);if(t.state!==`invocable`&&t.message)return t.message;if(t.state===`pending-approval`)return w(`newSession.nodeCommandPendingApproval`,{command:t.command});if(t.state===`undeclared`)return w(`newSession.nodeCommandUndeclared`,{command:t.command});if(t.state===`unauthorized`)return w(`newSession.nodeCommandUnauthorized`,{command:t.command})}if(t.consumesWorkerSlot)return e.workerSlots?Et(e.workerSlots)===0?w(`newSession.deviceNoSlots`):void 0:w(`newSession.deviceCapacityUnavailable`)}function _c(e,t=bc,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??gc(e,t),a=fc(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,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=tc(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 vc(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?gc(t,bc):w(`newSession.noSessionHosts`)}return t.some(e=>e.selectable)?void 0:t.find(e=>r.has(`node:${e.deviceId}`))?.disabledReason}function yc(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?vc(t,e):n.deviceId?r?.disabledReason??w(`newSession.nodeUnavailable`):void 0}}var bc;function xc(){return(xc=e((()=>{Dt(),d(),F(),hc(),P(),bc={requiredNodeCommands:[],consumesWorkerSlot:!0}})))()}var Sc;function Cc(){return(Cc=e((()=>{ts(),Sc=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&&Yo(n)||``;return{machineClass:this.resolve(e)||n&&Zo(n,r)?.id||``,os:r}}selectedOs(e){return this.resolveOs(e.id)||Yo(e)}machines(e){return Xo(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,Xo(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 wc(){return{deviceId:``,autoDevice:!1,cloudProfileId:``,freshWorkspace:!0,folderSelectedByUser:!1,preferredWhereRestore:null,preferredProjectRestore:``,preferredRemoteProjectRestore:null,configuredDefaultRepositoryPending:!1,configuredDefaultRepositoryOptOut:!1,whereSelectedByUser:!1,projectSelectedByUser:!1}}function Tc(e,t){e.projectSelectedByUser=!0,e.preferredProjectRestore=``,e.preferredRemoteProjectRestore=null,e.configuredDefaultRepositoryPending=!1,e.configuredDefaultRepositoryOptOut=t}function Ec(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 Dc(e,t,n){return t&&!(e.configuredDefaultRepositoryPending&&n)&&e.preferredWhereRestore===null&&!e.preferredProjectRestore&&!e.preferredRemoteProjectRestore}function Oc(e){let{state:t,browser:n,gateway:r,modelControl:i,repositoryState:a,isAdmin:o,persistPreference:s,requestUpdate:c}=e,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=>to(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){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 kc(){return(kc=e((()=>{eo()})))()}function Ac(e){if(e.remoteProject)return{kind:`pending-clone`,cloneUrl:e.remoteProject.cloneUrl};let t=e.selectedProject?.repoRoot??(e.folder.trim()||e.workspace);return!t||e.selectedProject&&!e.selectedProject.repoRoot?{kind:`idle`}:!e.selectedProject&&t===e.workspace&&!e.workspaceGit?{kind:`direct`,repoRoot:t}:{kind:`checking`,repoRoot:t}}var jc;function Mc(){return(Mc=e((()=>{C(),jc=class{constructor(e,t){this.read=e,this.callbacks=t,this.worktreeValue=!1,this.details={worktreeName:``},this.repositoryValue={kind:`idle`},this.requestToken=0,this.selectionRevision=0,this.preferredWorktreeRestore=!1,this.worktreeSelectedByUser=!1,this.selectedDetails=new Set}get worktree(){return this.worktreeValue}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.requestToken+=1,this.repositoryValue={kind:`idle`}}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.worktreeValue===e||this.read().remotePlacement||e&&!this.available()?!1:(this.selectWorktree(e,!1),this.callbacks.persistPreference({folder:this.read().folder.trim()||this.read().workspace,worktree:this.worktreeValue}),this.callbacks.requestUpdate(),!0)}setDetail(e,t,n){n||(this.selectionRevision+=1,this.details[e]=t,this.selectedDetails.add(e),this.callbacks.persistPreference({[e]:t}),this.callbacks.requestUpdate())}captureSubmittedName(e,t){let n=e.worktreeName?.trim();if(!e.worktree||!n)return;let r=this.selectionRevision,i=this.read(),a=z(t.agentId),o=i.agents.find(e=>z(e.id)===a),s={agentId:a,workspace:I(o?.workspace)??``},c=s.agentId===i.agentId,l=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 l&&(()=>l(()=>{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.requestUpdate())}))}available(){let e=this.repositoryValue;return e.kind===`git`||e.kind===`pending-clone`}matchesCurrentRepo(){let e=this.read(),t=this.repositoryValue;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(){let e=++this.requestToken,t=this.read(),n=Ac(t);if(n.kind!==`checking`)return this.adoptResolvedRepository(n);let r=t.gateway?.client;if(t.gateway?.phase!==`connected`||!r)return this.adoptResolvedRepository({kind:`idle`});let{repoRoot:i}=n;this.repositoryValue=n,r.request(`worktrees.branches`,{repoRoot:i,includeRepositoryStatus:!0}).then(t=>{e===this.requestToken&&this.adoptResolvedRepository(t?.repositoryStatus===`git`?{kind:`git`,repoRoot:i,branches:t.branches,...t.defaultBranch?{defaultBranch:t.defaultBranch}:{},...t.headBranch?{headBranch:t.headBranch}:{},...t.branchesUnavailable?{branchesUnavailable:!0}:{}}:{kind:t?.repositoryStatus===`not_git`?`direct`:`unavailable`,repoRoot:i})}).catch(()=>{e===this.requestToken&&this.adoptResolvedRepository({kind:`unavailable`,repoRoot:i})})}synchronize(){this.matchesCurrentRepo()||this.load()}adoptResolvedRepository(e){if(this.repositoryValue=e,e.kind===`direct`){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.callbacks.requestUpdate()}}})))()}function Nc(){return{catalog:[],hasSnapshot:!1,status:`idle`}}function Pc(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=J(o?.restricted?o.defaultModel:s??a?.model,o?.restricted||s?void 0:a?.modelProvider,r.catalog),l=J(t,void 0,r.catalog,n.agentRuntime),u=l?.entry??c?.entry,d=n.contextWindow||u?.contextWindowDefault,f=Wt(Fc(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:Fc(l,void 0,n)}}function Fc(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 J(e,t,n,r){let i=me(e,t,n);if(!i)return null;let a=i.toLowerCase(),o=n.find(e=>ce(e.id,e.provider).toLowerCase()===a);if(o)return{entry:va(o,r),model:o.id,provider:te(o.provider)||null};let s=i.indexOf(`/`);return{model:s>0?i.slice(s+1):i,provider:te(s>0?i.slice(0,s):t??``)||null}}function Ic(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?J(i,void 0,t.catalog,e.agentRuntime)?.entry?.unavailableReason:rn(i,void 0,t.catalog)}function Lc(e,t,n){let r=J(e.model,void 0,t,n);return r?.entry?.available===!0&&r.entry.manualSelectionAllowed!==!1&&r.provider===e.provider}function Rc(e){let{metadata:t,model:n,agentRuntime:r}=e;if(t.retired||e.initialModelPending||!t.hasSnapshot&&(n||r))return w(t.status===`error`?`chat.modelControls.modelsUnavailable`:`chat.modelControls.loadingModels`);if(t.modelSelectionPolicy?.restricted&&!n&&!t.modelSelectionPolicy.defaultModel)return w(t.catalog.length?`chat.modelControls.selectionRequired`:`chat.modelControls.noPermittedModels`);if(r&&t.hasSnapshot&&!J(n,void 0,t.catalog,r)?.entry)return w(`chat.modelControls.modelsUnavailable`);let i=Kt(Ic(e),!n&&!r&&!e.accountSelected?e.inference:void 0);if(e.accountSelected){if(t.status===`error`)return w(`chat.modelControls.modelsUnavailable`);if(e.metadataPending||!t.hasSnapshot)return w(`chat.modelControls.loadingModels`);if(!e.accountReady)return i??w(`chat.modelControls.modelsUnavailable`)}return i}function zc(e){if(e.retired)return;let t=e.modelSelectionPolicy,n=e.model||(t?.restricted?t.defaultModel??``:``),r;if(n)r=J(n,void 0,e.catalog,e.agentRuntime)?.entry?.agentRuntime;else if(!t?.restricted){let t=e.agent?.model?.primary;r=J(t??e.defaults?.model,t?void 0:e.defaults?.modelProvider,e.catalog)?.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 Bc(e){let t=e.model.trim(),n=t?J(t,void 0,e.catalog,e.agentRuntime):null;if(t&&(!n?.entry||n.entry.available===!1||n.entry.manualSelectionAllowed===!1))return{model:``,thinkingLevel:``,repaired:!0};let r=n?.entry?ce(n.entry.id,n.entry.provider):``,i=e.modelSelectionPolicy,a=i?.restricted?void 0:e.agent,o=i?.restricted?void 0:e.defaults,s=i?.restricted?i.defaultModel:a?.model?.primary,c=r?null:J(s??o?.model,s?void 0:o?.modelProvider,e.catalog),l=(n??c)?.provider,u=n?.entry??c?.entry,d=u?.supportsFastMode??(!l||Zt(l))?e.fastMode:void 0,f={model:r,...r&&e.agentRuntime?{agentRuntime:e.agentRuntime}:{},fastMode:d},p=d!==e.fastMode;if(!e.thinkingLevel)return{...f,thinkingLevel:``,repaired:p};let m=Wt(Fc(n??c,r?void 0:a,{agentRuntime:e.agentRuntime}),r?void 0:o,e.catalog)?.thinkingLevels,h=qt(e.thinkingLevel),g=m?.some(e=>qt(e.id)===h);return u?.reasoning===!1||m!==void 0&&!g?{...f,thinkingLevel:``,repaired:!0}:{...f,thinkingLevel:e.thinkingLevel,repaired:p}}function Vc(e){return e&&!e.devicePlacement?w(`newSession.deviceRuntimeUnsupported`):void 0}function Hc(e,t){return e?.cloudPlacementSupported===!1?w(`newSession.cloudRuntimeUnsupported`,{runtime:e.id}):e&&t&&e.cloudPlacementExecutionMode&&!Ko(t,e.cloudPlacementExecutionMode)?w(`newSession.cloudProfileRuntimeUnsupported`,{runtime:e.id}):void 0}function Uc(){return(Uc=e((()=>{d(),sn(),F(),ve(),Mt(),ln(),ts(),P(),Jt()})))()}var Wc;function Gc(){return(Gc=e((()=>{Uc(),Wc=class{constructor(e){this.onSelectionChange=e,this.selectionOrigin=`none`,this.fastModeSelected=!1,this.selected=``,this.contextWindow=``,this.thinkingLevel=``}resetSelection(e=``){this.selected=e,this.agentRuntime=void 0,this.contextWindow=``,this.thinkingLevel=``,this.fastMode=void 0,this.selectionOrigin=`none`,this.fastModeSelected=!1}applyModelSelection(e){this.selected=e.model,this.agentRuntime=e.agentRuntime,this.thinkingLevel=e.thinkingLevel,this.fastMode=e.fastMode}draftSelection(e){return this.selectionOrigin===`none`?void 0:{agentId:e,model:this.selected,agentRuntime:this.agentRuntime,thinkingLevel:this.thinkingLevel}}preferenceForDraft(e,t){let n=this.fastModeSelected||e===void 0?this.fastMode:e?.fastMode;return this.selectionOrigin===`none`?t.initialModel?t.initialModelPending?{model:t.initialModel}:void 0:t.policy===`configured`||t.policy===null?{fastMode:n}:this.fastModeSelected?{...e,fastMode:n}:e:{model:this.selected,agentRuntime:this.agentRuntime,thinkingLevel:this.thinkingLevel,fastMode:n}}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.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.contextWindow=``,!0)}restoreModelPreference(e,t,n){if(!e)return;let r=Bc({model:e.model??``,agentRuntime:e.agentRuntime,thinkingLevel:e.thinkingLevel??``,fastMode:e.fastMode,...t});this.applyModelSelection(r),r.repaired&&n&&this.persistSelection(e.agentRuntime?this.agentRuntime??``:void 0)}persistSelection(e=this.agentRuntime){this.onSelectionChange({model:this.selected,...e===void 0?{}:{agentRuntime:e},thinkingLevel:this.thinkingLevel,fastMode:this.fastMode})}}})))()}var Kc;function qc(){return(qc=e((()=>{hn(),ft(),ve(),Mt(),ln(),r(),fo(),Ua(),C(),ui(),za(),Ia(),G(),Gc(),Uc(),Os(),Kc=class extends Wc{constructor(e,t=()=>void 0,n=()=>void 0){super(t),this.notify=e,this.onCatalogTargetSelect=n,this.selectionGeneration=0,this.initialModelPending=!1,this.agentId=``,this.metadataState=Nc(),this.restoringPreference=!1,this.pendingSelectionGeneration=0,this.catalogTargets=new Ro(e),this.metadataReader=new uo(()=>{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`});return}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:Cn,onResult:e=>{this.ownsMetadata()&&this.publishMetadataCatalog(e)},onError:()=>{this.ownsMetadata()&&this.metadataFailed()}})}get catalog(){return this.metadataState.catalog}get effectiveModel(){return this.draftAccount?.model??this.selected}clearMetadataSubscription(){this.metadataReader.clear(),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||p(this.metadataClient))},this.notify()}assignMetadataCatalog(e,t=!1){this.metadataState={...this.metadataState,catalog:e.models,displayOnly:t,...jr(e)}}publishMetadataCatalog(e){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=Bc({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()}metadataFailed(){!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.restoringPreference=!1,this.updateMetadataState({...this.metadataState,status:`error`})}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=Nc(),!0):!1}invalidate(e=!1){if(!e&&this.metadataClient&&De(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(Nc());return}this.updateMetadataState({...this.metadataState,status:this.metadataState.hasSnapshot?this.metadataState.status:`idle`})}reset(){this.invalidate(!0)}load(e,t,n,r={}){let i=e?.gateway.snapshot,a=i?.client,o=t.trim()?z(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=Nc()),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}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;if(this.pendingPreference=this.preferenceForDraft(r.preference,{policy:e.config?.current.newSessionModelDefaults,initialModel:this.initialModel,initialModelPending:this.initialModelPending}),this.pendingAgent=r.agent,this.pendingSelectionGeneration=c,this.applyPendingDraftSelection(),this.restoringPreference=!this.draftAccount&&fs(this.pendingPreference),this.metadataReader.pending){this.notify();return}if(!d&&this.metadataState.status!==`idle`){this.metadataState.status===`ready`&&this.metadataState.hasSnapshot&&!this.draftAccount&&this.pendingSelectionGeneration===this.selectionGeneration&&this.restorePreference(),this.restoringPreference=!1;return}this.metadataReader.read()}isRestoringPreference(){return this.restoringPreference}requiresModelSetup(e){return ua({...e,modelSelectionPolicy:this.metadataState.modelSelectionPolicy,catalogInitialized:this.metadataState.hasSnapshot&&!this.metadataState.retired})}modelUnavailableReason(e){return Ic({model:this.effectiveModel,agentRuntime:this.agentRuntime,metadata:this.metadataState,agent:e})}modelSelectionBlockedReason(e,t){let n=this.resolveAgentRuntime({agent:e,context:this.pendingContext});return Rc({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})}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:Lc(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.pendingContext?.config?.current.newSessionModelDefaults!==`configured`&&this.pendingContext?.config?.current.newSessionModelDefaults!==null)}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())}applyPendingDraftSelection(){let e=this.takeDraftSelection(this.agentId,this.pendingContext?.config?.current.newSessionModelDefaults===`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 zc({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})}devicePlacementUnsupportedReason(){return Vc(this.resolveAgentRuntime())}autoPlacementSelectionMode(){return this.resolveAgentRuntime()?.cloudPlacementExecutionMode===`remote-exec`?`eligible-order`:`least-busy`}cloudRuntimeUnsupportedReason(e){return Hc(this.resolveAgentRuntime(),e)}render(e){let t=e.context?.gateway.snapshot,n=`new-session:${z(e.agentId)}`,r=e.context?.sessions.state.result??null,i=e.agent!==void 0,{defaultTarget:a,...o}=Pc({model:this.effectiveModel,selection:this,metadata:this.metadataState,agent:e.agent,defaults:r?.defaults}),s=t?.client,c=this.metadataScope,l=this.metadataState.accountSelection,u=()=>!!(s&&c&&this.ownsMetadata(s,c)&&this.metadataState.accountSelection===l);return qa({...o,renderAccountSection:n=>Ci({owner:this,client:s,selection:u()&&t?.selfUser?l:void 0,model:n,disabled:e.sending||!n||!Fe(t?.hello?.auth??null),ownsSelection:u,onSelect:e=>u()?this.selectDraftAccount(e,n):Promise.resolve(!1),onAutomatic:this.draftAccount?()=>{u()&&(this.selectionGeneration+=1,this.clearDraftAccount(),this.load(e.context,e.agentId,!0,{agent:e.agent}))}:void 0,onManage:()=>e.context?.navigate(`profile`),onRequestUpdate:this.notify}),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,selectedAgentRuntime:this.agentRuntime,sessionsResult:i?r:null,stream:null,onModelSelect:(t,n,r)=>{this.selectionGeneration+=1,this.initialModelPending=!1,this.restoringPreference=!1;let i=Bc({model:t,agentRuntime:r??void 0,thinkingLevel:this.thinkingLevel,fastMode:this.fastMode,agent:e.agent,defaults:e.context?.sessions.state.result?.defaults,modelSelectionPolicy:this.metadataState.modelSelectionPolicy,catalog:this.catalog});if(i.model===this.effectiveModel&&i.agentRuntime===this.agentRuntime&&i.fastMode===this.fastMode&&qt(i.thinkingLevel)===qt(this.thinkingLevel))return;this.metadataState.displayOnly=!1;let o=this.agentRuntime!==i.agentRuntime;this.applyModelSelection(i),this.markExplicitSelection();let s=J(i.model,void 0,this.catalog,this.agentRuntime)??a;this.draftAccount&&this.draftAccount.provider!==s?.provider?(this.clearDraftAccount(),this.load(e.context,e.agentId,!0,{agent:e.agent})):this.draftAccount&&s&&(this.draftAccount={...this.draftAccount,model:ce(s.model,s.provider)}),this.contextWindow=``,this.persistSelection(o?this.agentRuntime??``:void 0),this.onDraftSelectionChange?.()},onModelPickerTargetSelect:(e,t)=>{e===`cliAgents`&&this.onCatalogTargetSelect(t)},onModelPickerTargetRetry:e=>{e===`cliAgents`&&this.catalogTargets.retry(this.metadataClient,this.agentId)},onThinkingSelect:e=>{this.selectionGeneration+=1,this.restoringPreference=!1,this.thinkingLevel=e,this.markExplicitSelection(),this.persistSelection(),this.onDraftSelectionChange?.()},onFastModeSelect:e=>{this.selectionGeneration+=1,this.restoringPreference=!1,this.fastModeSelected=!0,this.fastMode=cn(e),this.persistSelection(),this.notify()},onContextWindowSelect:e=>{this.selectionGeneration+=1,this.restoringPreference=!1,this.contextWindow=e,this.notify()},onModelSetup:()=>e.context?.navigate(`model-setup`),onProviderSettings:t=>ea(e.context,e.agentId,t),onModelPickerOpen:()=>{let e=this.metadataClient,t=this.metadataScope;!this.metadataReader.pending&&e&&t&&this.metadataReader.read(),this.catalogTargets.retry(e,this.agentId)},onRequestUpdate:this.notify})}}})))()}var Jc;function Yc(){return(Yc=e((()=>{ft(),d(),F(),pe(),C(),G(),xc(),Cc(),kc(),Mc(),Ws(),qc(),Os(),P(),Jc=class{get terminalOnNode(){return this.terminalHostId.startsWith(`node:`)}selectTerminalHost(e){this.read().submitting||(this.terminalHostInitialized=!0,e!==this.terminalHostId&&(this.terminalHostId=e,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.requestUpdate()))}synchronizeTerminalHosts(){let e=this.read().data?.terminalHosts;!this.terminalHostInitialized&&e?.length&&this.selectTerminalHost(e.find(e=>e.hostId===this.terminalHostId)?.hostId??e[0].hostId)}constructor(e,t,n,r){this.gateway=e,this.browser=t,this.read=n,this.callbacks=r,this.terminalHostId=`gateway:local`,this.terminalHostInitialized=!1,this.agentIdValue=``,this.folderValue=``,this.cloudMachines=new Sc,this.agentsHydratedValue=!1,this.agentSelectedByUser=!1,this.routeModelIntentActive=!0,this.selection=wc(),this.folderValidation=new Us(()=>({gateway:this.read().context?.gateway.snapshot,folder:this.folderValue,selectedByUser:this.selection.folderSelectedByUser,isAdmin:this.isAdmin()}),{onApprovedRootsChange:r.requestUpdate,onVerified:()=>{this.callbacks.onClearError(w(`newSession.browserLoadFailed`)),this.repositoryState.load()},onMissing:()=>{this.callbacks.onClearError(w(`newSession.browserLoadFailed`)),this.folderValue=this.workspacePath(),this.repositoryState.rejectPreferredWorktree(),this.persistPreference({folder:this.folderValue,worktree:!1}),this.repositoryState.load()},onFailed:()=>this.callbacks.onError(w(`newSession.browserLoadFailed`))}),this.repositoryState=new jc(()=>({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.snapshot}),{requestUpdate:r.requestUpdate,persistPreference:e=>this.persistPreference(e),capturePreferenceConsumption:(e,t)=>this.gateway.capturePreferenceConsumption(e.agentId,e.workspace,t)}),this.modelControl=new Kc(r.requestUpdate,e=>this.persistPreference(e),e=>this.read().context?.navigate(`new-session`,{search:_e(this.agentIdValue,{catalogId:e})}))}get agentId(){return this.agentIdValue}get folder(){return this.folderValue}get worktree(){return(this.remotePlacement||this.repositoryState.worktree)&&!this.remoteRepository}get checkoutVisible(){return!this.freshWorkspace&&this.repository.kind!==`direct`&&(this.worktreeAvailable()||this.worktree)}get freshWorkspace(){return this.remotePlacement&&this.selection.freshWorkspace}get remoteRepository(){return 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.selection.deviceId}get autoDevice(){return this.selection.autoDevice}get remotePlacement(){return!!(this.selection.deviceId||this.selection.autoDevice||this.selection.cloudProfileId)}get cloudProfileId(){return this.selection.cloudProfileId}get cloudSelection(){return this.cloudMachines.selection(this.selection.cloudProfileId,this.gateway.cloudProfiles)}get agentsHydrated(){return this.agentsHydratedValue}preferenceSelection(){let e=this.selection.preferredWhereRestore??ds(this);return{workspace:this.workspacePath(),folder:this.folderValue,projectId:this.selection.preferredProjectRestore||this.browser.projectId,remoteProject:this.selection.preferredRemoteProjectRestore??this.browser.remoteProject,defaultRepositoryOptOut:this.selection.configuredDefaultRepositoryOptOut,where:e,worktree:(e.kind!==`local`||this.repositoryState.preferenceWorktree)&&!this.remoteRepository,freshWorkspace:this.selection.freshWorkspace,baseRef:this.repositoryState.baseRef,worktreeName:this.repositoryState.worktreeName}}get placementPreferenceReady(){return Dc(this.selection,this.freshWorkspace||this.repositoryState.preferenceReady,this.browser.projectsLoading||this.browser.projectsReady)}canAdoptGroupDefaults(){return!this.selection.folderSelectedByUser&&!this.selection.whereSelectedByUser&&!this.selection.projectSelectedByUser&&!this.repositoryState.hasUserSelection}adoptGroupDefaults(){this.read().data?.groupStatus===`resolved`&&this.canAdoptGroupDefaults()&&this.adoptAgentDefaults({preserveSelectedAgent:!0})}setAgentsHydrated(e){this.agentsHydratedValue=e}agents(){return Ce(this.read().context?.agents.state.agentsList?.agents??[])}selectedAgent(){let e=z(this.agentIdValue);return this.agents().find(t=>z(t.id)===e)}devicePlacementRuntime(){return this.modelControl.resolveAgentRuntime({agent:this.selectedAgent(),context:this.read().context})}devices(){return _c(this.gateway.environments,this.devicePlacementRuntime()?.devicePlacement,this.gateway.deviceCatalogDisabledReason)}devicePlacement(){return yc(this.devices(),this.gateway.environments,this)}isAdmin(){return pt(this.read().context?.gateway.snapshot.hello?.auth??null)}canWrite(){return Fe(this.read().context?.gateway.snapshot.hello?.auth??null)}workspacePath(){return I(this.selectedAgent()?.workspace)??``}knownWorkspaceRoots(){return this.folderValidation.knownWorkspaceRoots(this.workspacePath())}recordGatewayApprovedListing(e){this.folderValidation.recordApprovedListing(e)}folderSubmissionBlocked(){return this.freshWorkspace?!1:this.browser.projectId||this.browser.remoteProject?!this.browser.remoteProject&&!this.browser.selectedProject():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=Mo(t.data,n,i),this.agentSelectedByUser=!1),W(t.data)&&this.terminalOnNode){this.callbacks.requestUpdate();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=ps(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),Ec(this.selection,a,r,W(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,!W(t.data),{agent:this.selectedAgent(),preference:a,initialModel:this.routeModelIntentActive?Co(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.requestUpdate()}resetPlaceSelection(){this.folderValidation.reset(),Object.assign(this.selection,wc()),this.repositoryState.reset()}resetDraft(){this.routeModelIntentActive=!0,this.terminalHostId=`gateway:local`,this.terminalHostInitialized=!1,this.agentSelectedByUser=!1,this.folderValue=``,this.browser.clearProjectSelection(),this.resetPlaceSelection(),this.browser.resetProjectSearch(),this.modelControl.reset(),this.cloudMachines.clear(),this.callbacks.requestUpdate()}invalidateGatewayDiscovery(e){if(this.repositoryState.invalidate(),this.agentsHydratedValue=!1,this.modelControl.invalidate(e),this.browser.close(),this.folderValidation.reset(),this.browser.resetProjectSearch(),this.browser.resetProjects(e),!e){this.callbacks.requestUpdate();return}this.agentIdValue=``,this.agentSelectedByUser=!1,this.folderValue=``,this.resetPlaceSelection(),this.cloudMachines.clear(),this.callbacks.requestUpdate()}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.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.requestUpdate()}clearCloudProfile(){this.selection.cloudProfileId=``,this.browser.close(),this.callbacks.requestUpdate()}clearProjectSelection(){(this.browser.projectId||this.browser.remoteProject)&&this.repositoryState.clearDetails(!0),this.browser.clearProjectSelection(),Tc(this.selection,!0),this.persistPreference({projectId:``,remoteProject:null,defaultRepositoryOptOut:!0}),this.repositoryState.load(),this.callbacks.requestUpdate()}selectAgentId(e){let t=this.read();t.submitting||t.pendingPlacementSessionKey||W(t.data)||z(e)!==z(this.agentIdValue)&&(this.agentIdValue=z(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();if(!(t.submitting||t.pendingPlacementSessionKey)){if(this.browser.clearProjectSelection(),this.folderValidation.cancel(),this.callbacks.onError(null),this.folderValue=e.trim(),this.selection.freshWorkspace=!1,this.selection.folderSelectedByUser=!0,Tc(this.selection,!0),W(t.data)&&this.terminalOnNode){this.callbacks.requestUpdate();return}this.repositoryState.selectWorktree(!1),this.agentsHydratedValue&&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.folderValue=this.workspacePath(),this.selection.folderSelectedByUser=!0,Tc(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.requestUpdate())}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.browser.selectProject(e),this.selection.freshWorkspace=!1,this.folderValidation.cancel(),this.browser.resetProjectSearch(),this.callbacks.onError(null),this.selection.folderSelectedByUser=!1,Tc(this.selection,!1),this.repositoryState.selectWorktree(!1),this.persistPreference({projectId:e.kind===`local`?e.id:``,remoteProject:e.kind===`remote`?e.project:null,defaultRepositoryOptOut:!1,...e.kind===`local`?{where:ds(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())}selectDevice(e,t=!1){let n=this.read();n.submitting||n.pendingPlacementSessionKey||e&&this.devices().find(t=>t.deviceId===e)?.selectable!==!0||t&&!this.devices().some(e=>e.selectable)||(this.selection.whereSelectedByUser=!0,this.selection.preferredWhereRestore=null,(e!==this.selection.deviceId||t!==this.selection.autoDevice||this.selection.cloudProfileId)&&(this.folderValidation.cancel(),this.selection.deviceId=e,this.selection.autoDevice=t,this.selection.cloudProfileId=``,this.persistPreference({where:ds({cloudProfileId:``,deviceId:e,autoDevice:t}),projectId:this.browser.projectId,folder:this.folderValue,worktree:!!(e||t)||this.worktree,freshWorkspace:this.selection.freshWorkspace}),this.browser.close(),this.repositoryState.synchronize(),this.callbacks.requestUpdate()))}selectCloudProfile(e){let t=this.read(),n=this.gateway.cloudProfiles.find(t=>t.id===e);t.submitting||t.pendingPlacementSessionKey||!this.isAdmin()||!n||this.modelControl.cloudRuntimeUnsupportedReason(n)||(this.selection.cloudProfileId=e,this.selection.deviceId=``,this.selection.autoDevice=!1,this.selection.whereSelectedByUser=!0,this.selection.preferredWhereRestore=null,this.callbacks.onError(null),this.persistPreference({where:{kind:`cloud`,id:e},projectId:this.browser.projectId,worktree:!0,freshWorkspace:this.selection.freshWorkspace}),this.repositoryState.synchronize(),this.callbacks.requestUpdate())}selectWorktree(e){!this.read().submitting&&this.repositoryState.select(e)&&e&&this.selection.freshWorkspace&&(this.selection.freshWorkspace=!1,this.persistPreference({freshWorkspace:!1}))}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(){Oc({state:this.selection,browser:this.browser,gateway:this.gateway,where:ds(this),modelControl:this.modelControl,repositoryState:this.repositoryState,isAdmin:()=>this.isAdmin(),persistPreference:e=>this.persistPreference(e),requestUpdate:this.callbacks.requestUpdate})}browseAvailable(){return this.gateway.connected&&(this.isAdmin()||!!this.workspacePath())}worktreeAvailable(){return this.repositoryState.available()}persistPreference(e){this.gateway.persistPreference(this.agentIdValue,this.workspacePath(),e)}}})))()}var Xc;function Zc(){return(Zc=e((()=>{Zr(),Ea(),Xc=class{constructor(e,t){this.notify=e,this.onUserChange=t,this.attachments=[],this.reads=new Qr(e)}replace(e){this.attachments=e,this.onUserChange(),this.notify()}restore(e){Yr(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&&xe(this.attachments),this.attachments=[],this.notify()}}})))()}function Qc(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 $c(e,t,n){Ie({selection:e.agentSelection,gateway:e.gateway,sessionKey:t,agentId:n}),e.navigate(`chat`,b({context:e,face:`chat`,sessionKey:t,agentId:n}).options)}function el(){return(el=e((()=>{We(),_()})))()}async function tl(e){let t;for(;!t;)try{let n=await e.client.request(`agent.wait`,{runId:e.runId,timeoutMs:3e4},{timeoutMs:null});if(e.context.gateway.snapshot.client!==e.client)return;let r=n.status===`timeout`&&n.endedAt===void 0&&!n.error&&!n.stopReason&&n.providerStarted!==!0;if(n.status===`pending`||n.pendingError===!0)await mn(il);else if(r){let n=e.context.placementStartup.get(e.key)?.initialTurn;n?.sendState===`failed`&&n.sendRunId===e.runId?t={status:`error`,error:n.sendError}:await mn(il)}else t=n}catch{let t=e.context.gateway.snapshot,n=t.phase===`connecting`||t.phase===`starting`||t.phase===`reconnecting`;if(t.client!==e.client||!n)return;await mn(il)}if(!e.isCurrentOwner())return;let n=e.context.gateway.snapshot;if(ne(n,e.key,e.agentId))return;let r=e.context.sessions.state.result?.sessions.find(t=>Ee(t.key,e.key)),i=t.status===`ok`?w(`sessionsView.statusDone`):t.status===`timeout`?w(`sessionsView.statusTimeout`):t.stopReason===`rpc`?w(`sessionsView.statusKilled`):w(`sessionsView.statusFailed`),a=b({face:`chat`,sessionKey:e.key,fallbackAgentId:e.agentId,exactKey:!0});e.context.nativeNotifications?.backgroundSessionCompleted({runId:e.runId,path:a.options.pathname,...a.options.search?{search:a.options.search}:{}}),Te({fifo:!0,message:`${S(e.key,r)}: ${i}`,actionLabel:w(`sessionsView.openSession`),onAction:()=>{e.isCurrentOwner()&&$c(e.context,e.key,e.agentId)}})}function nl(e){let t=Qc(e.context);return(n,r)=>{let i=r?.trim();return e.enabled?(i&&tl({agentId:e.agentId,client:e.client,context:e.context,key:n,runId:i,isCurrentOwner:t}),!0):!1}}function rl(e,t,n,r){Xn({connected:e.gateway.snapshot.phase===`connected`,directComposerSend:r&&ir(),message:t,hasAttachments:n,isCommand:nn(t)!==null})&&nr(e)}var il;function al(){return(al=e((()=>{bn(),ar(),d(),Nt(),ge(),_(),C(),x(),el(),il=1e3})))()}var ol;function sl(){return(sl=e((()=>{ft(),d(),Pt(),si(),ol=class{constructor(e,t){this.notify=e,this.onMutation=t,this.toolOverridesValue=null,this.skillCatalog=new oa(e)}get toolOverrides(){return this.toolOverridesValue}setToolOverrides(e){let t=pi(e)>0?e:null;t!==this.toolOverridesValue&&(this.onMutation(),this.toolOverridesValue=t,this.notify())}reset(){this.toolOverridesValue=null}restoreToolOverrides(e){e!==void 0&&this.setToolOverrides(e)}canStartAsDraft(e){let t=e?.gateway.snapshot.hello?.policy;return t?.allowedSessionVisibilities?.includes(`draft`)===!0&&t?.hasMultipleSessionSharingIdentities===!0}composerProps(e,t,n){if(!e)return{toolOverrides:this.toolOverridesValue,capabilityMenu:void 0};this.skillCatalog.synchronize(t.client,t.connectionEpoch);let r=e.runtimeConfig.state,i=r.configSnapshot?.runtimeConfig??null,a=t.connected&&!!t.client,o=Ke(e.gateway.snapshot),s=a?i?o.canAdmin?null:w(`chat.composer.menu.adminBlocked`):r.lastError??w(`common.loading`):w(`chat.composer.menu.offlineBlocked`);return{toolOverrides:this.toolOverridesValue,capabilityMenu:{basePath:e.basePath,skills:this.skillCatalog.rows(n,this.toolOverridesValue),skillsLoading:this.skillCatalog.isLoading(n),skillsError:this.skillCatalog.hasError(n),mcpServers:Gt(i)??[],toolsEffectiveResult:null,toolsEffectiveLoading:!1,toolsEffectiveError:!1,toolAccessMutationBlockedReason:s,webSearchBaseEnabled:ri(i),mutationBlockedReason:s,canAdmin:o.canAdmin&&a,adminBlockedReason:o.canAdmin?a?null:w(`chat.composer.menu.offlineBlocked`):w(`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)}}}}})))()}var cl;function ll(){return(ll=e((()=>{kr(),Oi(),ji(),Rr(),pa(),Fa(),cl=class{constructor(){this.critterVisit=Math.random(),this.textarea=null,this.placeholderFrame=null,this.placeholderStartedAt=null,this.placeholderText=``,this.placeholderTarget=``,this.placeholderEntered=!1,this.capturedSelection=null,this.skillCommandClient=null,this.skillCommandAgentId=``,this.skillCommandDraftOwnerKey=``,this.skillMenuState=li(),this.slashMenuState=Fr(),this.mentionMenu=new Or,this.emojiMenu=new Ur,this.composing=!1,this.capabilityMenuOpen=!1,this.capabilityMenuView=`root`,this.ref=e=>{let t=e instanceof HTMLTextAreaElement?e:null;this.textarea&&this.textarea!==t&&Wa(this.textarea),this.textarea&&!t&&this.resetPlaceholder(),this.textarea=t,t&&(Va(t),fa(t))},this.getTextarea=()=>this.textarea}syncDraft(e){this.textarea?.isConnected&&this.textarea.value!==e&&fa(this.textarea)}getPlaceholder(e,t,n){if(t.length>0||this.placeholderEntered)return this.placeholderEntered=!0,this.placeholderFrame!==null&&(globalThis.cancelAnimationFrame?.(this.placeholderFrame),this.placeholderFrame=null),e;this.placeholderTarget!==e&&(this.resetPlaceholder(),this.placeholderTarget=e);let r=globalThis.requestAnimationFrame?.bind(globalThis);if(!r||(globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1))return this.placeholderText=e,this.placeholderEntered=!0,e;if(this.placeholderFrame===null){let t=i=>{this.placeholderStartedAt??=i;let a=Math.max(0,i-this.placeholderStartedAt-180),o=Math.min(e.length,Math.floor(a/26));if(o!==this.placeholderText.length&&(this.placeholderText=e.slice(0,o),n()),o<e.length){this.placeholderFrame=r(t);return}this.placeholderFrame=null,this.placeholderEntered=!0};this.placeholderFrame=r(t)}return this.placeholderText}resetPlaceholder(){this.placeholderFrame!==null&&(globalThis.cancelAnimationFrame?.(this.placeholderFrame),this.placeholderFrame=null),this.placeholderStartedAt=null,this.placeholderText=``,this.placeholderTarget=``,this.placeholderEntered=!1}captureSelection(){let e=this.textarea;this.capturedSelection=e?{start:e.selectionStart,end:e.selectionEnd,value:e.value}:null}previewTranscript(e){let t=this.textarea;if(!t)return;let n=this.capturedSelection??{start:t.selectionStart,end:t.selectionEnd,value:t.value};return Xi(n.value,e,n.start,n.end).value}insertTranscript(e,t){let n=this.textarea;if(!n)return null;let r=this.capturedSelection,i=r&&(!t||r.value===n.value)?r:{start:t?n.selectionStart:n.value.length,end:t?n.selectionEnd:n.value.length,value:n.value};this.capturedSelection=null;let a=Xi(i.value,e,i.start,i.end);return a.value===i.value?null:(n.value=a.value,Ya(n),queueMicrotask(()=>{n.isConnected&&(n.focus({preventScroll:!0}),n.selectionStart=a.caret,n.selectionEnd=a.caret)}),a.value)}syncSkillCommandOwner(e,t,n){let r=t.trim();this.ownsSkillCommands(e,r,n)||(this.skillCommandClient=e,this.skillCommandAgentId=r,this.skillCommandDraftOwnerKey=n,this.emojiMenu.close(),yi(this.skillMenuState))}ownsSkillCommands(e,t,n){return this.skillCommandClient===e&&this.skillCommandAgentId===t.trim()&&this.skillCommandDraftOwnerKey===n}disconnect(){this.emojiMenu.close(),this.composing=!1,this.mentionMenu.dispose(),this.resetPlaceholder(),this.skillCommandClient=null,this.skillCommandAgentId=``,this.skillCommandDraftOwnerKey=``,yi(this.skillMenuState),la(this.slashMenuState),this.capabilityMenuOpen=!1,this.capabilityMenuView=`root`,this.textarea&&=(Wa(this.textarea),null)}}})))()}function ul(e){let t=e.trim();return!t||fl.test(t)}function dl(e){let t=I(e.displayName),n=I(e.baseRef),r=I(e.worktreeName),i=I(e.cwd),a=I(e.workspace),o=I(e.catalogId),s=I(e.category),c=I(e.model),l=I(e.agentRuntime),u=I(e.contextWindow),d=I(e.thinkingLevel),f=e.deferInitialTurn?``:e.message,p=e.deferInitialTurn&&e.visibility!==`incognito`?fn(e.message.trim(),1e3):void 0,m=e.worktreeSource===`empty`,h=m?void 0:e.repository,g=m||h?void 0:I(e.projectId),_=!m&&!h&&!g&&(f.trim()||!e.deferInitialTurn&&e.attachments?.length)?I(e.projectGitUrl):void 0,v=!m&&!h&&!g&&!_&&i&&i!==a?i:void 0;return{agentId:z(e.agentId),message:f,...!e.deferInitialTurn&&e.mentions?.length?{mentions:e.mentions.map(e=>({...e}))}:{},...t?{displayName:t}:{},...p?{titleSource:p}:{},...e.visibility===`incognito`?{incognito:!0}:{},...e.visibility===`draft`?{visibility:`draft`}:{},...!e.deferInitialTurn&&e.attachments?.length?{attachments:e.attachments}:{},...o?{catalogId:o}:{},...s?{category:s}:{},...!o&&c?{model:c}:{},...!o&&c&&l?{agentRuntime:l}:{},...!o&&u?{contextWindow:u}:{},...!o&&d?{thinkingLevel:d}:{},...!o&&e.fastMode!==void 0?{fastMode:e.fastMode}:{},...e.toolOverrides?{toolOverrides:e.toolOverrides}:{},...e.permissionMode?{permissionMode:e.permissionMode}:{},...g?{projectId:g}:{},..._?{projectGitUrl:_}:{},...h?{repository:{...h}}:{},...v?{cwd:v}:{},...m?{worktree:!0,worktreeSource:`empty`}:{},...e.worktree&&!h&&!m?{worktree:!0,...n?{worktreeBaseRef:n}:{},...r?{worktreeName:r}:{}}:{}}}var fl;function pl(){return(pl=e((()=>{C(),fl=/^[a-z0-9][a-z0-9-]{0,63}$/})))()}function ml(e,t){return dl({...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,projectId:e.browser.remoteProject?.projectId??e.browser.projectId,projectGitUrl:e.browser.remoteProject?.cloneUrl,repository:e.remoteRepository,worktree:e.worktree,worktreeSource:e.freshWorkspace?`empty`:void 0,baseRef:e.baseRef,worktreeName:e.worktreeName,cwd:e.folder,workspace:e.workspacePath()})}function hl(){return(hl=e((()=>{pl()})))()}var gl,_l,vl,yl;function bl(){return(bl=e((()=>{Rt(),Qt(),mi(),Pn(),gl=()=>({writeId:Math.random().toString(36).slice(2),retired:!1,committedRevision:0,writes:new Set}),_l=R(()=>import(`./control-ui-boot-shared-UG5ko-VG.js`).then(e=>(e.i(),e.r)),__vite__mapDeps([1,3,4,5,6,7,8,2,9,10,11]),import.meta.url),vl=200,yl=class e{static{this.active=new Set}constructor(e,t,n){this.read=e,this.apply=t,this.onStorageError=n,this.contentReconciled=!1,this.pendingModelSelectionMutation=!1,this.gatewayOwner=``,this.recoveryScope=``,this.routeKey=``,this.revision=0,this.mutationGeneration=0,this.mutation=gl(),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=Xt(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.pendingModelSelectionMutation=!1,this.apply(``,[],!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);if(e&&!t){this.noteUserMutation(),r.finally(n);return}n()}selectRoute(e){e&&this.routeKey!==e&&(this.persistNow(),this.routeKey&&(this.pendingModelSelectionMutation=!1),this.routeKey=e,this.contentReconciled=!1,this.revision=0)}activateRoute(e){this.selectRoute(e);let t=this.scope();if(!t)return;let n=U(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=sa(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===sa(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.flushModelSelectionMutation())},()=>{this.restorePromise===s&&(this.restorePromise=void 0,this.contentReconciled=!1,H(t,this.onStorageError))})}noteDraftReplaced(){this.restoreGeneration+=1,this.mutationGeneration+=1,this.mutation=gl(),this.pendingHandoffMutation=null,this.submittedMutation=null,this.inheritedWriteIds=[],this.pristineMutationBaseline=this.mutationGeneration}noteModelSelectionMutation(){let e=!this.contentReconciled&&this.mutationGeneration===this.pristineMutationBaseline&&(this.submittedMutation===this.mutation||!this.restorePromise);this.submittedMutation=null,this.pendingModelSelectionMutation=!0,e?(this.restoredIdentity=``,this.activateRoute(this.routeKey)):this.flushModelSelectionMutation()}flushModelSelectionMutation(){this.pendingModelSelectionMutation&&!this.restorePromise&&this.restoredIdentity&&(this.contentReconciled||this.mutationGeneration>this.pristineMutationBaseline)&&!this.disconnected&&this.submittedMutation!==this.mutation&&this.noteUserMutation()}noteUserMutation(){if(this.pendingModelSelectionMutation=!1,this.mutationGeneration+=1,this.mutation=gl(),this.pendingHandoffMutation=null,this.submittedMutation=null,this.revision=Ft(this.revision),this.read().incognito)return;this.discardPending();let e=this.snapshot();e&&(this.pending=e,this.timer=globalThis.setTimeout(()=>this.persistNow(),vl))}retireActive(){this.mutationGeneration+=1,this.mutation.retired=!0,this.discardPending();let e=Ft(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 _l,i=Math.max(e,n.revision),a=await r(t,i);if(a.status===`storage-failed`)H(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.pendingModelSelectionMutation=!1,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 _l;for(let n=0;n<3;n+=1){let n=await i(r);if(n.status===`storage-failed`){H(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=Ft(a),c=`clear:${s}`,{result:l}=await Gr({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&&U(e)===U(r)&&(t.restoredIdentity=``,t.activateRoute(e.scopeKey))}return}if(l.status===`storage-failed`){H(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:Ft(Math.max(e.revision,t.revision))}:e,{result:r,payloadUnavailable:i}=await Gr(n);if(i&&H(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`&&H(e.scope,this.onStorageError);return}if(r.status===`storage-failed`){H(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&&U(e)===U(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(),storedAttachments:wr(t.attachments),writeId:i}}async restoreScope(e,t,n){let{readDurableComposerDraft:r}=await _l,i=await r(e);if(i.status===`storage-failed`)return H(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=Ft(a):this.revision<=0&&t>this.pristineMutationBaseline&&(this.revision=Ft(0)),this.pending=this.snapshot(),this.persistNow(),!0;let c=[];if(i.status===`found`)try{c=await ci(i.draft.attachments)}catch{return H(e,this.onStorageError),!1}return n()?(this.revision=a,i.status===`found`&&i.draft.mentions?this.apply(i.draft.text,c,void 0,i.draft.mentions):this.apply(i.status===`found`?i.draft.text:``,c),this.modelSelection?.restore(i.status===`found`?i.draft.modelSelection:void 0),this.mutation.committedRevision=a,!0):!1}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=U(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=U(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 xl(e,t){let{os:n,machineClass:r}=t.cloudSelection;return e.sessionKey?e.target:t.cloudProfileId?{kind:`profile`,profileId:t.cloudProfileId,...n?{os:n}:{},...r?{machineClass:r}:{}}:t.deviceId?{kind:`device`,deviceId:t.deviceId}:t.autoDevice?{kind:`auto-device`}:null}function Sl(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?.worktreeSource?{worktreeSource:e.createParams.worktreeSource}:{},...e.createParams?.repository?{repository:{...e.createParams.repository}}:{}},draft:{message:e.message,...e.mentions?.length?{mentions:e.mentions}:{},attachments:n(e.attachments),visibility:t,toolOverrides:e.createParams?.toolOverrides??null,permissionMode:e.createParams?.permissionMode}}}async function Cl(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 Ki({client:e.client,describe:e.context.sessions.describe},r,e.agentId);o?(s()&&(t.promoteToDispatching(r),t.retryAllowed=!0),e.setError(w(`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;e.context.placementStartup.start({recovery:c,persistRecovery:t.persistent,mode:n.phase===`creating`?`dispatch`:`recover`,createdAt:e.createdAt}),await e.consumeWorktreeName?.();let l=()=>e.isLifecycleCurrent()&&o(c.sessionKey);if(l()&&(await e.clearDraft(),l())){if(t.reset(),e.completeInBackground(c.sessionKey,c.messageId)){e.onAccepted();return}await e.navigate()}}function wl(){return(wl=e((()=>{d(),F(),Ka(),f(),P()})))()}var Tl;function El(){return(El=e((()=>{Tt(),_n(),Tl=class{constructor(e){this.gateway=e,this.pending=null}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:Nn()}),scope:n,startedAt:r,interrupted:!1,background:t}}return this.pending.params}clear(){this.pending=null}interrupt(){return!this.pending||!this.matchesGateway()?(this.clear(),!1):(this.pending.interrupted=!0,!0)}retireChangedOwner(){return!this.pending||this.matchesGateway()?!1:(this.clear(),!0)}resume(){return this.pending?.interrupted?Date.now()>=this.pending.startedAt+24e4?(this.clear(),{kind:`expired`}):this.matchesGateway()?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`}}matchesGateway(){return this.pending?.scope===this.gateway.sessionCreateScope}}})))()}function Dl(e,t,n,r,i=!1){let a=t.pendingPlacement,o=!r&&!!a.sessionKey,s=an(t.message,t.mentions),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;if(!r&&!o){let t=zi(u,e.gateway.snapshot.hello?.policy);if(t!==void 0)return Te({message:t}),null}let d=r?r.params.attachments:o?void 0:ca(u),f=o?a.attachments:d,p=r?.params.agentId??(o?a.agentId:z(n.agentId)),m=o?a.gatewayUrl:e.gateway.connection.gatewayUrl,h=e.gateway.snapshot.client;if(!h||!e.gateway.snapshot.hello)return null;let g=nl({enabled:i,agentId:p,client:h,context:e}),_=o?a.recoveryScope:h.recoveryScope,v=r?.params??(o?a.createParams:ml(n,{message:c,visibility:t.visibility}));return{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 Ol(){return(Ol=e((()=>{Yt(),C(),x(),ii(),Sr(),al(),hl()})))()}function kl(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()});return c.addEventListener(`abort`,l,{once:!0}),{ready:o.catch(()=>void 0),signal:c,isActive:()=>!c.aborted&&r.getState().location===s,dispose:()=>{l(),c.removeEventListener(`abort`,l)}}}function Al(e,t){let n=Pl.get(e);if(n&&n.search===t&&n.owns())return Pl.delete(e),Fl.set(n.draft.data,{page:n.draft.page,canDisplay:n.canDisplay}),n.draft.data}function jl(e,t){e&&Fl.get(e)?.page===t&&Fl.delete(e)}function Ml(e){let t=e&&typeof e==`object`?Fl.get(e):void 0;return t?.canDisplay()?t.page:void 0}function Nl(e,t){return Pl.set(e,t),()=>{Pl.get(e)===t&&Pl.delete(e)}}var Pl,Fl;function Il(){return(Il=e((()=>{Pl=new WeakMap,Fl=new WeakMap})))()}function Ll(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-`:``}${Nn()}`;return e.resumed||(n.key=a),()=>{let n=i();return n?new Rl(t,a,r,n,e.message):void 0}}var Y,Rl;function zl(){return(zl=e((()=>{Qe(),ze(),_(),_n(),Il(),Y=new WeakMap,Rl=class{constructor(e,t,n,r,i){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=ut(e.gateway);let a=Y.get(e);this.previousSessionKey=e.gateway.snapshot.sessionKey,this.previousAgentId=e.agentSelection.state.selectedId,a?.dispose(),this.returnLocation={pathname:globalThis.location.pathname,search:globalThis.location.search,hash:globalThis.location.hash},Y.set(e,this);let o={pathname:b({context:e,face:`chat`,sessionKey:t,agentId:n,exactKey:!0}).options.pathname,search:``,hash:``};this.transition=kl(e,`chat`,o),this.clearPendingCreate=e.chatSubmissions.beginCreate({creation:this.creation,message:i,canDisplay:()=>this.canDisplay()}),this.transition.signal.addEventListener(`abort`,()=>this.dispose(),{once:!0}),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 ut(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&&Y.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 Ve(this.context.gateway,this.lifetime.signal)}catch{return}if(this.disposed||Y.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:()=>Y.get(this.context)===this&&!this.disposed&&this.sameIdentity(),canDisplay:()=>this.sameIdentity()&&this.context.agentSelection.state.selectedId===t},r=()=>{};e&&(this.draft.synchronizeGateway(),r=Nl(this.context,n));try{let e=kl(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(),Y.get(this.context)===this&&Y.delete(this.context),this.draft.release())}}})))()}async function Bl(e,t){let n=t.name?.trim(),r=t.baseRef?.trim();return e.request(`worktrees.create`,{repoRoot:t.repoRoot.trim(),...n?{name:n}:{},...r?{baseRef:r}:{}})}function Vl(){return(Vl=e((()=>{})))()}function Hl(e,t){let n=a(e,{method:`sessions.catalog.startTerminal`,requiredScope:`operator.admin`});return!n.allowed||!t?n:a(e,{method:`worktrees.create`,requiredScope:`operator.admin`})}async function Ul(e){let{context:t,data:n}=e.snapshot,{place:r,flow:i}=e,a=t?.gateway.snapshot.client,o=n?.catalogId.trim()??``,s=z(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(Ni({text:l,createdAt:Date.now()},`available`),!0),r.browser.close(),e.closeTransientUi();try{let e=u.cwd;if(u.worktree){let t=await Bl(a,{repoRoot:e,name:u.worktreeName,baseRef:u.baseRef});if(!c.isCurrent())return;e=t.path}let n=await Yi(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:Ge(n.sessionId,t.basePath),search:``,hash:``})}catch(e){c.isCurrent()&&i.setError(e instanceof Error?e.message:String(e))}finally{c.isRequestCurrent()&&c.publish(null,!1)}}function Wl(e){return e.hosts?e.hosts.length===0?k`<span class="new-session-page__catalog-unavailable" role="status">
${w(`newSession.nativeHostsUnavailable`)}
</span>`:e.hosts.length===1&&e.hosts[0]?.hostId===e.hostId?O:k`<div class="new-session-page__select new-session-page__menu-field">
<span>${w(`newSession.where`)}</span>
<select
class="new-session-page__trigger"
aria-label=${w(`newSession.where`)}
.value=${e.hostId}
?disabled=${e.submitting}
@change=${t=>{t.currentTarget instanceof HTMLSelectElement&&e.onSelect(t.currentTarget.value)}}
>
${e.hosts.some(t=>t.hostId===e.hostId)?O:k`<option value=${e.hostId} selected disabled>
${w(`newSession.chooseNativeHost`)}
</option>`}
${e.hosts.map(t=>k`<option value=${t.hostId} ?selected=${t.hostId===e.hostId}>
${t.label}
</option>`)}
</select>
</div>`:O}function Gl(){return(Gl=e((()=>{A(),tt(),d(),F(),h(),ma(),C(),Br(),P()})))()}function Kl(e){let{gateway:t,place:n,pendingPlacement:r,hasInitialTurn:i,createParams:o}=e,s=!!r.sessionKey,c=xl(r,n),l=!c&&!i?n.browser.remoteProject:null;if(!s&&l&&!l.projectId){let e=a(t,{method:`projects.add`,requiredScope:`operator.write`});if(!e.allowed)return e}if(!c||!s||r.phase===`creating`){let e=a(t,{method:`sessions.create`,params:o,sessionScope:!0});if(!e.allowed||!c)return e}return a(t,{method:`sessions.dispatch`,requiredScope:c.kind===`profile`?`operator.admin`:`operator.write`,params:Si({key:r.sessionKey,agentId:r.agentId||n.agentId,target:c})})}function ql(e){let{snapshot:t,gateway:n,place:r,pendingPlacement:i}=e,a=r.selectedAgent(),o=t.context?.agents.state;return r.modelControl.requiresModelSetup({catalog:W(t.data)||r.remotePlacement||!!i.sessionKey,connected:n.connected,agentsLoaded:!!o?.agentsList,selectedAgentFound:a!==void 0,agentModel:a?.model?.primary})}function Jl(e,t,n,r){let i=W(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:w(`chat.mentions.unsupported`)};if(e.preferenceLoading||i===`session`&&t.modelControl.isRestoringPreference()||!t.placementPreferenceReady)return{gate:`preference-restore`,reason:w(`newSession.restoringPreferences`)};if(i===`session`&&n.requiresModelSetup())return{gate:`model-setup`,reason:w(`modelSetup.required.title`)};if(Ao(r.data,r.context?.sessions))return{gate:`route-pending`,reason:w(`newSession.catalogUnavailable`)};if(n.attachmentDraft.reads.pendingReads>0)return{gate:`attachment-reads`,reason:w(`newSession.readingAttachment`)};if(!a&&n.submissionOutcomeUnknown)return{gate:`outcome-unknown`,reason:w(n.submissionOutcomeUnknown===`gateway-changed`?`newSession.createOutcomeUnknown`:`newSession.placementSetupInterrupted`)};let o=r.context?.gateway,s=o?.snapshot.phase===`connected`?o.snapshot.client??null:null;if(!o||!s)return{gate:`disconnected`,reason:w(`sessionsView.actionRequiresConnection`)};let c=i===`terminal`?Hl(o.snapshot,t.worktree):n.submissionAccess();if(!c.allowed)return{gate:`access`,reason:c.reason};if(i===`terminal`){if(r.context?.config.current.cliAgentsEnabled!==!0||!r.context.config.current.terminalEnabled)return{gate:`terminal-capabilities`,reason:w(`newSession.terminalDisabled`)};if(!r.data?.terminalHosts?.some(e=>e.hostId===t.terminalHostId))return{gate:`device`,reason:w(`newSession.terminalHostUnavailable`)};if(n.attachmentDraft.attachments.length>0)return{gate:`terminal-capabilities`,reason:w(`newSession.terminalAttachmentsUnsupported`)};if(t.remotePlacement||n.pendingPlacement.sessionKey)return{gate:`device`,reason:w(`newSession.terminalPlacementUnsupported`)};if(n.capabilities.toolOverrides!==null)return{gate:`terminal-capabilities`,reason:w(`newSession.terminalCapabilityOverridesUnsupported`)}}if(t.folderSubmissionBlocked())return{gate:`folder`,reason:w(`newSession.checkingPlace`)};if(a)return n.pendingPlacement.retryAllowed&&s.recoveryScopeReady&&xl(n.pendingPlacement,t)&&n.pendingPlacement.agentId&&n.pendingPlacement.gatewayUrl===o.connection.gatewayUrl&&n.pendingPlacement.recoveryScope===s.recoveryScope?Yl(n,i,a):{gate:`placement-recovery`,reason:w(`newSession.placementNotReady`)};if(!r.context?.agents.state.agentsList)return{gate:`agents`,reason:w(r.context?.agents.state.agentsError?`newSession.agentDefaultsUnavailable`:`newSession.loadingAgentDefaults`)};let l=xl(n.pendingPlacement,t),u=l?.kind===`profile`?l.profileId:``,d=e.cloudProfiles.find(e=>e.id===u),f=i===`session`&&t.modelControl.modelSelectionBlockedReason(t.selectedAgent(),d?.inference);if(f)return{gate:`model-unavailable`,reason:f};if(t.agents().length===0)return{gate:`agents`,reason:w(`newSession.agentsUnavailable`)};if(!No(r.data,t.selectedAgent()))return{gate:`agent-not-allowed`,reason:w(`newSession.catalogUnavailable`)};let p=i===`session`?t.devicePlacement():void 0;if(p&&!p.ready)return{gate:`device`,reason:p.disabledReason??w(`newSession.nodeUnavailable`)};let m=t.modelControl.devicePlacementUnsupportedReason();if((t.deviceId||t.autoDevice)&&m)return{gate:`device-runtime`,reason:m};if(l&&(!s.recoveryScope||!s.recoveryScopeReady||e.cloudProfilesPending))return{gate:`placement-recovery`,reason:w(`newSession.placementNotReady`)};let h=()=>t.modelControl.cloudRuntimeUnsupportedReason(d);return u&&(!e.cloudProfilesReady||!d||h())?{gate:`cloud`,reason:h()??w(`newSession.placementNotReady`)}:t.worktree&&!t.freshWorkspace&&!t.worktreeAvailable()?{gate:`worktree-unavailable`,reason:t.repository.kind===`checking`?w(`newSession.checkingGit`):t.remotePlacement?w(`newSession.remoteSourceUnavailable`):w(`newSession.gitCheckUnavailable`)}:t.worktree&&!t.freshWorkspace&&!ul(t.worktreeName)?{gate:`worktree-name`,reason:w(`newSession.worktreeNameInvalid`)}:i===`terminal`&&!(t.folder.trim()||!t.terminalOnNode&&t.workspacePath())?{gate:`terminal-folder`,reason:w(`newSession.terminalNeedsFolder`)}:Yl(n,i,a)}function Yl(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 Xl;function Zl(){return(Zl=e((()=>{d(),F(),h(),Ka(),G(),pl(),wl(),Gl(),P(),Xl=new Set([`attachment-reads`,`outcome-unknown`,`worktree-name`])})))()}var Ql;function $l(){return($l=e((()=>{d(),F(),Bt(),Yt(),h(),he(),Pr(),Zc(),al(),sl(),G(),ll(),hl(),bl(),wl(),El(),Ol(),Fi(),zl(),Rs(),Hr(),Zl(),Gl(),P(),Ql=class{updateMessage(e){e!==this.messageText&&(this.messageText=e,this.callbacks.onMessageChange?.(e))}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.blockedSubmitGate=null,this.rejectedPromptError=null,this.submissionOutcomeUnknown=null,this.startedSession=new Ai,this.error=null,this.submitRequestToken=0,this.pendingPlacement=new Ls(()=>this.read().context),this.composerTextarea=new cl,this.buildDraftSessionCreateParams=(e={})=>ml(this.place,{...e,message:e.message??``,toolOverrides:this.capabilities.toolOverrides,permissionMode:this.permissionMode,visibility:e.visibility??this.visibility,catalogId:this.read().data?.catalogId,category:this.gateway.resolvedGroupCategory()}),this.submissionAccess=(e=this.pendingPlacement.createParams??this.buildDraftSessionCreateParams())=>Kl({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=()=>ql({snapshot:this.read(),gateway:this.gateway,place:this.place,pendingPlacement:this.pendingPlacement}),this.capabilities=new ol(r.requestUpdate,()=>this.startedSession.current=null),this.sessionStartup=new Tl(e),this.draftPersistence=new yl(()=>({message:this.messageText,mentions:this.mentionsValue,attachments:this.attachmentDraft.attachments,incognito:this.visibilityValue===`incognito`}),(e,t,n,r)=>{this.restoreDraftState({message:e,mentions:r,attachments:t,visibility:n?`normal`:this.visibilityValue})},()=>this.setError(Ha)),this.attachmentDraft=new Xc(r.requestUpdate,()=>{this.rejectedPromptError=null,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.submitRequestToken;return()=>e===this.submitRequestToken},publish:(e,t)=>{this.activeSubmission=e?{phase:`accepted`,message:e}:null,t!==void 0&&(this.error=t),this.callbacks.requestUpdate()}})}resumeInterruptedSubmission(){let e=this.sessionStartup.resume();e.kind===`resume`?this.submit(e):e.kind!==`wait`&&(this.activeSubmission=null,this.submissionOutcomeUnknown=`gateway-changed`,this.callbacks.requestUpdate())}setMessage(e,t){e!==this.messageText&&(this.rejectedPromptError=null),this.startedSession.current=null,this.mentionsValue=t??tn(this.messageText,e,this.mentionsValue),this.updateMessage(e),this.draftPersistence.noteUserMutation(),this.callbacks.requestUpdate()}restoreMessage(e,t=[]){this.rejectedPromptError=null,this.draftPersistence.noteDraftReplaced(),this.updateMessage(e),this.mentionsValue=t,this.callbacks.requestUpdate()}restoreDraftState(e){this.draftPersistence.noteDraftReplaced(),this.updateMessage(e.message),this.mentionsValue=e.mentions??[],this.visibilityValue=e.visibility,this.capabilities.restoreToolOverrides(e.toolOverrides),`permissionMode`in e&&(this.permissionMode=e.permissionMode),this.attachmentDraft.restore(e.attachments)}setPermissionMode(e){this.permissionMode=e,this.startedSession.current=null,this.callbacks.requestUpdate()}setVisibility(e){this.startedSession.current=null;let t=this.visibilityValue===`incognito`,n=this.callbacks.requestUpdate;this.visibilityValue=e,this.draftPersistence.transitionIncognito(t,e===`incognito`,n)}setError(e){(e!==null||this.error===w(`newSession.cloudRecoveryUnavailable`))&&(this.error=e),this.callbacks.requestUpdate()}clearError(e){(e===void 0||this.error===e)&&(this.error=null,this.callbacks.requestUpdate())}markPendingPlacementUnavailable(e){this.pendingPlacement.retryAllowed=!1,this.submissionOutcomeUnknown=e,this.callbacks.requestUpdate()}noteBlockedSubmitAttempt(){this.blockedSubmitGate=this.submitBlock()?.gate??null,this.callbacks.requestUpdate()}blockedSubmitNotice(){let e=this.blockedSubmitGate?this.submitBlock():void 0;return e?.gate===this.blockedSubmitGate&&!Xl.has(e.gate)?e.reason:void 0}incognitoDisabledReason(){let e=a(this.read().context?.gateway.snapshot,{method:`sessions.create`,params:this.buildDraftSessionCreateParams({visibility:`incognito`})});return e.allowed?void 0:e.reason}submitBlock(){return this.rejectedPromptError?{gate:`initial-turn-rejected`,reason:this.rejectedPromptError}:!W(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`}:Jl(this.gateway,this.place,this,this.read())}invalidate(e=null){this.submitRequestToken+=1,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.requestUpdate()}resetDraft(){this.startedSession.clearSubmission(),this.rejectedPromptError=null,this.sessionStartup.clear();let e=!!this.pendingPlacement.sessionKey;this.blockedSubmitGate=null,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()}clearPendingPlacementRecovery(){this.pendingPlacement.clear(),this.submissionOutcomeUnknown=null,this.callbacks.requestUpdate()}releasePendingPlacementOwner(){this.pendingPlacement.reset(),this.submissionOutcomeUnknown=null,this.callbacks.requestUpdate()}restorePendingPlacementRecovery(e,t){this.applyRecoveryDraft(this.pendingPlacement.restore(e,t))}async submit(e,t=!1){if(!e&&W(this.read().data))return this.startInTerminal();let n=e?.background??(t&&this.visibilityValue!==`draft`),r=this.read().context;if(!r||!e&&!this.canSubmit()){this.noteBlockedSubmitAttempt();return}if(!ae(r.config)&&(this.attachmentDraft.attachments.length||this.pendingPlacement.attachments?.length||e?.params.attachments?.length)){this.error=oe(),this.callbacks.requestUpdate();return}this.blockedSubmitGate=null;let i=Dl(r,this,this.place,e,n);if(!i)return;let o=this.callbacks.takePreparedTitle?.(),s=++this.submitRequestToken,c=this.draftPersistence.captureSubmission(),l=e?.startedAt??Date.now(),{hello:u,selfUser:d}=r.gateway.snapshot,f={text:i.message,mentions:i.mentions,attachments:i.attachments,createdAt:l,sender:on(u,i.client.instanceId,d)??void 0},p=this.startedSession.messageForTurn(r,this.place.agentId,f),m=this.startedSession.captureSubmission(r,i.agentId,p,()=>s===this.submitRequestToken);this.activeSubmission={phase:`creating`,message:p},this.error=null,this.place.browser.close(),this.callbacks.closeTransientUi(),this.callbacks.requestUpdate();let h,g;try{let t=this.startedSession.current;if(t&&this.startedSession.isCurrent(r,this.place.agentId)){await this.startedSession.navigate(r,t);return}this.startedSession.current=null;let u=e?null:xl(this.pendingPlacement,this.place);rl(r,i.message,!!i.apiAttachments?.length,!e&&!i.pendingPlacement);let d=!e&&!i.pendingPlacement&&!u&&!i.hasInitialTurn?this.place.browser.remoteProject:null;if(d&&!d.projectId&&!this.place.browser.projectId){let e=await i.client.request(`projects.add`,{gitUrl:d.cloneUrl},{timeoutMs:null});if(s!==this.submitRequestToken||this.gateway.client!==i.client)return;this.place.browser.recordRemoteProjectId(d.cloneUrl,e.id)}let p=e?.params??this.buildDraftSessionCreateParams({message:i.message,mentions:i.mentions,displayName:o,visibility:this.visibilityValue===`draft`&&!this.capabilities.canStartAsDraft(this.read().context)?`normal`:this.visibilityValue,attachments:i.draftAttachments}),_=Ll({context:r,params:p,resumed:!!e,enabled:!n&&!u,agentId:i.agentId,retainDraft:this.callbacks.retainForHandoff,message:this.pendingMessage}),v=u?i.pendingPlacement?this.pendingPlacement.createParams:this.pendingPlacement.stageCreate({agentId:i.agentId,target:u,message:i.message,mentions:i.mentions,attachments:i.apiAttachments,gatewayUrl:i.gatewayUrl,recoveryScope:i.recoveryScope,createParams:p,persistent:this.visibilityValue!==`incognito`}):void 0,y=e?a(r.gateway.snapshot,{method:`sessions.create`,params:p,sessionScope:!0}):this.submissionAccess(v??p);if(!y.allowed){this.sessionStartup.clear(),this.error=y.reason;return}let b=u?this.pendingPlacement.capture():null;if(u&&!b){this.error=w(`newSession.placementCreateFailed`);return}i.apiAttachments?.length&&ye(r.config);let x=i.pendingPlacement&&this.pendingPlacement.phase!==`creating`?Promise.resolve({key:this.pendingPlacement.sessionKey,initialRun:{status:`idle`}}):r.sessions.createResult(v??e?.params??this.sessionStartup.start(p,n),{reconciliation:`background`});h=_?.();let S=await x;if(S&&!u&&S.initialRun.status!==`rejected`&&(g=i.consumeWorktreeName?.()),s!==this.submitRequestToken&&!u){S&&S.initialRun.status!==`rejected`&&await this.clearSubmittedDraft(!0,c,!1);return}if(!S){if(s!==this.submitRequestToken)return;this.sessionStartup.clear(),this.error=r.sessions.state.error??w(`newSession.createFailed`),h&&await h.rollback();return}if(u&&b){await Cl({context:r,client:i.client,agentId:i.agentId,pending:this.pendingPlacement,submittedRecovery:b,sessionKey:S.key,createdAt:l,isRequestCurrent:()=>s===this.submitRequestToken,isLifecycleCurrent:()=>this.read().isConnected&&i.client.recoveryScopeReady&&s===this.submitRequestToken&&this.gateway.client===i.client&&this.gateway.gatewayUrl===i.gatewayUrl&&this.gateway.recoveryScope===i.recoveryScope,clearRecovery:()=>this.clearPendingPlacementRecovery(),setError:e=>this.setError(e),onRecoveryUnavailable:()=>{this.error=w(`newSession.placementStartFailed`,{error:`placement recovery storage is unavailable`})},clearDraft:()=>(m(S.key),this.clearSubmittedDraft(!0,c)),consumeWorktreeName:i.consumeWorktreeName,completeInBackground:i.completeInBackground,onAccepted:()=>this.callbacks.onAccepted?.({...S,agentId:i.agentId}),navigate:()=>this.startedSession.navigate(r,{client:i.client,key:S.key,agentId:i.agentId})});return}await Di({onRejectedPrompt:n&&this.callbacks.retainRejectedPrompt?e=>{this.rejectedPromptError=e,this.error=e,this.sessionStartup.clear()}:void 0,context:r,client:i.client,agentId:i.agentId,result:S,turn:f,instant:h,navigation:this.startedSession,isCurrent:()=>s===this.submitRequestToken,clearDraft:(e,t)=>(t!==!1&&m(S.key,S.initialRun.status===`rejected`?S.initialRun.error:void 0),this.clearSubmittedDraft(e,c,t)),completeInBackground:i.completeInBackground,onAccepted:()=>this.callbacks.onAccepted?.({...S,agentId:i.agentId}),finishNavigation:()=>this.sessionStartup.clear()})}catch(e){s===this.submitRequestToken&&this.gateway.client===i.client&&(this.sessionStartup.clear(),this.error=e instanceof Error?e.message:String(e),h&&await h.rollback())}finally{(g||h)&&await Promise.all([g,h?.finish()]),s===this.submitRequestToken&&(this.activeSubmission=null,this.callbacks.requestUpdate())}}startInTerminal(){return Ul({snapshot:this.read(),place:this.place,flow:this,closeTransientUi:this.callbacks.closeTransientUi,capture:e=>{this.blockedSubmitGate=null,this.error=null;let t=++this.submitRequestToken,n=this.draftPersistence.captureSubmission(),r=()=>t===this.submitRequestToken;return{isRequestCurrent:r,isCurrent:()=>r()&&this.gateway.client===e,publish:(e,t)=>{this.activeSubmission=t?{phase:`creating`,message:e}:null,this.callbacks.requestUpdate()},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.draftPersistence.noteDraftReplaced(),this.attachmentDraft.clearAfterSubmit(e),this.sessionStartup.clear()})}disconnect(){this.pendingPlacement.releaseClaim(),this.startedSession.current=null,this.draftPersistence.disconnect(),this.attachmentDraft.reset(),this.composerTextarea.disconnect()}applyRecoveryDraft(e){if(!e)return;let t=Sl(e);this.place.applyPendingPlacement(t.placement),this.restoreDraftState(t.draft)}}})))()}function eu(e){return au.has(e)}function tu(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)))}function nu(e){let t=e.querySelector(`.new-session-page__select--agent wa-dropdown`);t&&(t.open=!1)}function ru(e){for(let t of[`wa-dropdown[open]`,`wa-popover.new-session-page__picker-popover`])for(let n of e.querySelectorAll(t))n.open=!1}function iu(e){return t=>{t.target===t.currentTarget&&e(t)}}var au;function ou(){return(ou=e((()=>{au=new Set([`config.changed`,`node.pair.requested`,`node.pair.resolved`,`node.runnerInventory.changed`,`device.pair.requested`,`device.pair.resolved`])})))()}var su;function cu(){return(cu=e((()=>{Ye(),Be(),qe(),d(),x(),c(),$i(),G(),Vs(),lc(),Yc(),$l(),ou(),su=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)=>Te({message:w(e?`chat.privateDraftReload.changed`:`chat.privateDraftReload.blocked`),actionLabel:w(`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=lt(n.gateway);try{let n=await Vi({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 st({timeoutMs:0,...f})}catch{u()&&Te({message:w(`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=Xe(()=>!e(),()=>t());return()=>{r(),this.privateDraftReview?.controller.abort()}}constructor(e,t,n){this.read=t;let r=()=>{this.privateDraftReview&&!this.privateDraftReview.isCurrent()&&this.privateDraftReview.controller.abort(`draft-changed`),n.requestUpdate()};this.gateway=new Bs(e,()=>({...t(),isAdmin:this.place?.isAdmin()??!1,canStartAsDraft:this.submission?.capabilities.canStartAsDraft(t().context)??!1,visibility:this.submission?.visibility??`normal`,cloudProfileId:this.place?.cloudProfileId??``,pendingPlacement:this.submission?.pendingPlacement??{sessionKey:``,gatewayUrl:``,recoveryScope:``},agentsHydrated:this.place?.agentsHydrated??!1,runtimeId:this.place?.devicePlacementRuntime()?.id??``}),{preferenceScope:n.preferenceScope,readPalettePreference:n.readPalettePreference,requestUpdate:r,updateComplete:()=>e.updateComplete,onInvalidate:(e,t)=>{this.invalidate(e,t),n.onInvalidate()},onVisibilityRetired:()=>this.submission.setVisibility(`normal`),onCloudProfileCleared:()=>this.place.clearCloudProfile(),onCloudState:e=>this.submission.setError(e),onPendingPlacementReset:()=>this.submission.releasePendingPlacementOwner(),onRecoveryReady:n.onRecoveryReady,onAdoptAgentDefaults:()=>this.place.adoptAgentDefaults({preserveSelectedAgent:!0,preserveSelectedFolder:!0})}),this.browser=new cc(e,this.gateway,()=>({context:t().context,isAdmin:this.place?.isAdmin()??!1}),{requestUpdate:r,onProjectMissing:()=>this.place.clearProjectSelection(),onSelectProject:e=>this.place.selectProjectId(e),onApprovedListing:e=>this.place.recordGatewayApprovedListing(e),querySelector:n.querySelector,activeElement:n.activeElement,body:n.body,pickerIdPrefix:n.pickerIdPrefix}),this.place=new Jc(this.gateway,this.browser,()=>({context:t().context,data:t().data,submitting:this.submission?.submitting??!1,pendingPlacementSessionKey:this.submission?.pendingPlacement.sessionKey??``}),{requestUpdate:r,onError:e=>e===null?this.submission.clearError():this.submission.setError(e),onClearError:e=>this.submission.clearError(e)}),this.submission=new Ql(this.gateway,this.place,t,{...n,requestUpdate:r}),this.submission.draftPersistence.modelSelection={read:()=>t().context?.config?.current.newSessionModelDefaults===`configured`?this.place.modelControl.draftSelection(this.place.agentId):void 0,restore:e=>this.place.modelControl.restoreDraftSelection(e),retire:()=>{t().context?.config?.current.newSessionModelDefaults===`configured`&&this.place.modelControl.retireDraftSelection()}},this.place.modelControl.onDraftSelectionChange=()=>{t().context?.config?.current.newSessionModelDefaults===`configured`&&this.submission.draftPersistence.noteModelSelectionMutation()},this.subscriptions=new o(e).effect(()=>this.read().context,()=>this.protectPrivateDraftFromReload()).watchStore(()=>this.read().context?.gateway,e=>this.gateway.synchronize(e)).effect(()=>this.read().context?.gateway,e=>{let t=tu(Ne(e.snapshot.hello?.snapshot)??[]);return e.subscribeEvents(n=>{if(this.read().context?.gateway!==e)return;let r=n.event===`presence`?Ne(n.payload):null,i=r?tu(r):t;(eu(n.event)||i!==t)&&(t=i,this.gateway.refreshCloudProfiles(),this.gateway.handleCatalogRetry())})})}agentsReady(){let e=this.read().context?.agents.state;return!!(this.gateway.connected&&this.gateway.client&&e?.connected&&e.client===this.gateway.client&&this.place.agents().length>0)}synchronizeSelections(){let e=this.read().context?.config?.current.newSessionModelDefaults;if(!this.place.agentsHydrated&&this.agentsReady())this.place.setAgentsHydrated(!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,!W(t),{agent:this.place.selectedAgent(),preference:this.gateway.readPreference(this.place.agentId)})}e===`configured`&&this.modelDefaultsPolicy!==`configured`&&!this.submission.submitting&&this.place.modelControl.draftSelection(this.place.agentId)&&this.submission.draftPersistence.noteModelSelectionMutation(),this.modelDefaultsPolicy=e,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.subscriptions.clear(),this.gateway.invalidateDiscovery(!0,this.submission.pendingPlacement.sessionKey?`placement-interrupted`:`gateway-changed`),this.gateway.disconnect(),this.browser.disconnect(),this.submission.disconnect()}}})))()}function lu(e){let t=e.context?.gateway,n=t?.snapshot.client,r=t?.snapshot.selfUser?.identity;if(n&&t?.snapshot.phase===`connected`&&r?.type===`profile`&&Fe(t.snapshot.hello?.auth??null)&&!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 uu(){return(uu=e((()=>{ft()})))()}function du(e){yu=e.type===`pointerdown`}function fu(e,t){if(e.target!==e.currentTarget)return;let n=document.activeElement;if(n instanceof HTMLInputElement&&yu&&n.selectionStart!==n.selectionEnd){yu=!1,e.preventDefault();return}t()}function pu(e){e?.querySelector(`input`)?.removeAttribute(`aria-activedescendant`);for(let t of e?.querySelectorAll(`[data-worktree-suggestion]`)??[])t.setAttribute(`aria-selected`,`false`)}function mu(e,t){if(!(e instanceof HTMLElement))return;let n=e.closest(`.new-session-page__branch-field`);n?.querySelector(`wa-popup`)?.toggleAttribute(`active`,t),(n?.querySelector(`input`))?.setAttribute(`aria-expanded`,String(t)),t||pu(n)}function hu(e,t){let n=[...e.closest(`.new-session-page__branch-field`)?.querySelectorAll(`[data-worktree-suggestion]`)??[]];if(n.length===0)return!1;let r=n.findIndex(e=>e.getAttribute(`aria-selected`)===`true`);if(t.key===`Enter`&&!t.isComposing&&r>=0)return n[r].click(),!0;if(t.key!==`ArrowDown`&&t.key!==`ArrowUp`)return!1;let i=t.key===`ArrowDown`?1:-1,a=r<0?i===1?0:n.length-1:(r+i+n.length)%n.length;for(let[e,t]of n.entries())t.setAttribute(`aria-selected`,String(e===a));return e.setAttribute(`aria-activedescendant`,n[a].id),mu(e,!0),!0}function gu(e){let t=e.worktreeName.trim();if(e.worktree&&!e.repository&&t)return{label:w(`newSession.checkoutWorktreeNamed`,{name:t})};if(e.destination!==`cloud`&&!e.repository&&!e.worktree)return{label:e.headBranch||w(`newSession.checkoutCurrent`)};let n=e.destination===`cloud`?[`newSession.checkoutCloud`,`newSession.checkoutCloudFrom`]:e.repository?[`newSession.checkoutRepository`,`newSession.checkoutRepositoryFrom`]:[`newSession.checkoutWorktree`,`newSession.checkoutWorktreeFrom`];return{label:e.baseRef?w(n[1],{branch:e.baseRef}):w(n[0])}}function _u(e){let t=t=>{let n=t.currentTarget;if(!(n instanceof HTMLElement))return;if(hu(n,t)){t.preventDefault(),t.stopPropagation();return}if(t.key===`Escape`){t.preventDefault(),t.stopPropagation(),n.closest(`wa-popover`)?.removeAttribute(`open`);return}let r=n.closest(`wa-popover`),i=r?.querySelector(`input[data-worktree-name]`)?.value??e.worktreeName;if(!(t.key!==`Enter`||t.isComposing||!e.repository&&!ul(i))&&(yu=!1,t.preventDefault(),r)){let t=n=>{n.target===r&&(r.removeEventListener(`wa-after-hide`,t),e.onConfirm())};r.addEventListener(`wa-after-hide`,t),r.removeAttribute(`open`)}},n=(e.branches?.branches??[]).slice(0,8),r=e.worktreeName.trim(),i=k`<input
id="new-session-worktree-base-ref"
type="text"
role=${n.length?`combobox`:O}
aria-label=${w(`newSession.worktreeBaseRef`)}
aria-autocomplete=${n.length?`list`:O}
aria-controls=${n.length?`new-session-worktree-branch-suggestions`:O}
aria-expanded=${n.length?`false`:O}
?disabled=${e.submitting||e.pendingPlacement}
placeholder=${e.branchesLoading?w(`common.loading`):e.branches?.defaultBranch??w(`newSession.worktreeBaseRef`)}
.value=${e.baseRef}
@focus=${e=>mu(e.currentTarget,!0)}
@input=${t=>{t.currentTarget instanceof HTMLInputElement&&(pu(t.currentTarget.closest(`.new-session-page__branch-field`)),mu(t.currentTarget,!0),e.onBaseRefInput(t.currentTarget.value))}}
@keydown=${t}
@pointerdown=${du}
@pointerup=${du}
@pointercancel=${du}
/>`;return k`
<div class="new-session-page__menu-field">
<span>${w(`newSession.worktreeBaseRef`)}</span>
${n.length?k`<div
class="new-session-page__branch-field"
@focusout=${e=>{let t=e.currentTarget;t instanceof HTMLElement&&(!(e.relatedTarget instanceof Node)||!t.contains(e.relatedTarget))&&mu(t,!1)}}
>
${i}
<wa-popup
class="new-session-page__branch-popup"
anchor="new-session-worktree-base-ref"
placement="bottom-start"
sync="width"
>
<div
id="new-session-worktree-branch-suggestions"
class="new-session-page__branch-suggestions"
role="listbox"
aria-label=${w(`newSession.worktreeBaseRef`)}
>
${n.map((t,n)=>k`<button
id=${`new-session-worktree-branch-suggestion-${n}`}
type="button"
role="option"
aria-selected="false"
class="session-menu__item"
data-worktree-suggestion=${t.name}
tabindex="-1"
@mousedown=${e=>e.preventDefault()}
@click=${n=>{e.onBaseRefInput(t.name),mu(n.currentTarget,!1)}}
>
<span class="session-menu__text">${t.name}</span>
</button>`)}
</div>
</wa-popup>
</div>`:i}
</div>
<div class="new-session-page__menu-note">
${w(e.branches?.branchesUnavailable?`newSession.worktreeBranchesUnavailable`:`newSession.worktreeBranchesLimited`)}
</div>
${e.repository?O:k`<label class="new-session-page__menu-field">
<span>${w(`newSession.worktreeName`)}</span>
<input
type="text"
data-worktree-name
?disabled=${e.submitting||e.pendingPlacement}
placeholder=${w(`newSession.worktreeNamePlaceholder`)}
.value=${e.worktreeName}
@input=${t=>{t.currentTarget instanceof HTMLInputElement&&e.onWorktreeNameInput(t.currentTarget.value)}}
@keydown=${t}
@pointerdown=${du}
@pointerup=${du}
@pointercancel=${du}
/>
</label>
<div class="new-session-page__menu-note">
${r?w(`newSession.worktreeBranchNote`,{branch:`openclaw/${r}`}):w(`newSession.worktreeBranchFromTitleNote`)}
</div>`}
`}function vu(e){return k`
<span class="new-session-page__select">
<button
id="new-session-checkout-trigger"
type="button"
class="new-session-page__trigger ${e.popoverHiding?`new-session-page__trigger--hiding`:``}"
title="${w(`newSession.checkout`)}: ${e.state.label}"
aria-label="${w(`newSession.checkout`)}: ${e.state.label}"
data-worktree=${String(e.worktree)}
aria-haspopup="dialog"
aria-expanded=${String(e.popoverOpen)}
?disabled=${e.submitting||e.pendingPlacement}
@click=${e.onGuardTransition}
>
${Zs(E.gitBranch,e.state.label)}
</button>
</span>
<wa-popover
${yt(_r)}
class="new-session-page__select new-session-page__checkout-popover new-session-page__picker-popover"
for="new-session-checkout-trigger"
placement="bottom-start"
without-arrow
@wa-show=${iu(()=>e.onPopoverShow())}
@wa-hide=${t=>fu(t,e.onPopoverHide)}
@wa-after-hide=${iu(()=>e.onPopoverAfterHide())}
>
<div class="new-session-page__picker-root">
<div class="new-session-page__menu-title">${w(`newSession.checkout`)}</div>
${e.repository?O:k`${q({value:`checkout`,label:w(`newSession.checkoutCurrent`),icon:E.folder,sub:e.branches?.headBranch,checked:!e.worktree,disabled:e.remotePlacement,title:e.remotePlacement?w(`newSession.checkoutRemoteLocked`):void 0,onSelect:()=>e.onSelectWorktree(!1),keepOpen:!0},e.submitting)}
${q({value:`worktree`,label:w(`newSession.checkoutWorktree`),icon:E.gitBranch,sub:w(`newSession.checkoutWorktreeSub`),checked:e.worktree,disabled:!e.worktreeAvailable,title:e.worktreeAvailable?void 0:e.repositoryUnavailable?w(`newSession.gitCheckUnavailable`):w(`newSession.worktreeUnavailable`),onSelect:()=>e.onSelectWorktree(!0),keepOpen:!0},e.submitting)} `}
${e.worktree||e.repository?_u(e):O}
${e.remotePlacement?k`<div class="new-session-page__menu-note">
${w(e.repository?`newSession.placementClonesRepository`:`newSession.placementSyncsFolder`,{folder:e.folderLabel})}
</div>`:O}
</div>
</wa-popover>
`}var yu;function bu(){return(bu=e((()=>{A(),ht(),T(),mr(),d(),F(),ls(),pl(),ou(),Qs(),P(),yu=!1})))()}var xu;function Su(){return(Su=e((()=>{A(),it(),T(),xu={laptop:D(j`<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"
/>
<path d="M20.054 15.987H3.946" />`),pcCase:D(j`<rect width="14" height="20" x="5" y="2" rx="2" />
<path d="M15 14h.01M9 6h6M9 10h6" />`),macMini:D(j`<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"
/>
<path d="M21.946 12.013H2.054M6 16h.01M10 16h.01" />`),macStudio:D(j`<path d="m3 8 3-4h12l3 4v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z" />
<path d="M3 8h18M6 15h2M11 15h2M17 15h.01" />`),allInOne:E.monitor,tablet:D(j`<rect width="16" height="20" x="4" y="2" rx="2" ry="2" />
<path d="M12 18h.01" />`),watch:D(j`<circle cx="12" cy="12" r="6" />
<polyline points="12 10 12 12 13 13" />
<path d="m16.13 7.66-.81-4.05a2 2 0 0 0-2-1.61h-2.68a2 2 0 0 0-2 1.61l-.78 4.05" />
<path d="m7.88 16.36.8 4a2 2 0 0 0 2 1.61h2.72a2 2 0 0 0 2-1.61l.81-4.05" />`),smartphone:E.smartphone,browser:E.globe,terminal:E.terminal,server:E.server}})))()}function Cu(e){let t=e?.trim();if(t)return Ou.find(([e])=>t.startsWith(e))?.[1]??(Object.hasOwn(Eu,t)?Eu[t]:void 0)}function wu(e){let t=e?.replace(/[_-]+/g,` `);if(t)return ku.find(([e])=>e.test(t))?.[1]}function Tu(e){let t=e?.trim();if(!t)return;let n=Cu(t);return n===`laptop`?t.startsWith(`MacBookAir`)||Du.has(t)?`MacBook Air`:/^MacBook\d/.test(t)?`MacBook`:`MacBook Pro`:n?{mini:`Mac mini`,studio:`Mac Studio`,pro:`Mac Pro`,imac:`iMac`}[n]:void 0}var Eu,Du,Ou,ku;function Au(){return(Au=e((()=>{Eu={"Mac13,1":`studio`,"Mac13,2":`studio`,"Mac14,2":`laptop`,"Mac14,3":`mini`,"Mac14,5":`laptop`,"Mac14,6":`laptop`,"Mac14,7":`laptop`,"Mac14,8":`pro`,"Mac14,9":`laptop`,"Mac14,10":`laptop`,"Mac14,12":`mini`,"Mac14,13":`studio`,"Mac14,14":`studio`,"Mac14,15":`laptop`,"Mac15,3":`laptop`,"Mac15,4":`imac`,"Mac15,5":`imac`,"Mac15,6":`laptop`,"Mac15,7":`laptop`,"Mac15,8":`laptop`,"Mac15,9":`laptop`,"Mac15,10":`laptop`,"Mac15,11":`laptop`,"Mac15,12":`laptop`,"Mac15,13":`laptop`,"Mac15,14":`studio`,"Mac16,1":`laptop`,"Mac16,2":`imac`,"Mac16,3":`imac`,"Mac16,5":`laptop`,"Mac16,6":`laptop`,"Mac16,7":`laptop`,"Mac16,8":`laptop`,"Mac16,9":`studio`,"Mac16,10":`mini`,"Mac16,11":`mini`,"Mac16,12":`laptop`,"Mac16,13":`laptop`,"Mac17,2":`laptop`},Du=new Set([`Mac14,2`,`Mac14,15`,`Mac15,12`,`Mac15,13`,`Mac16,12`,`Mac16,13`]),Ou=[[`MacBook`,`laptop`],[`Macmini`,`mini`],[`MacPro`,`pro`],[`iMac`,`imac`]],ku=[[/\bmac\s*book(?:\s*(?:pro|air))?\b/i,`laptop`],[/\bmac\s*mini\b/i,`mini`],[/\bmac\s*studio\b/i,`studio`]]})))()}function ju(e){let t=_c(e.environments,e.devicePlacement,e.deviceDisabledReason),n=vc(e.environments,t,e.deviceDisabledReason),r=t.find(t=>t.deviceId===e.deviceId),i=e.cloudProfiles.find(t=>t.id===e.cloudProfileId);if(e.cloudProfileId){let r=i?Yo(i):``,a=e.os||r,o=i?.operatingSystems??[],s=i?Xo(i,a):[],c=i?Zo(i,a):void 0,l=e.machineClass?s.find(t=>t.id===e.machineClass):c;return{kind:`cloud`,label:i?.id??e.cloudProfileId,operatingSystems:o,selectedOsId:a,cloudMachines:s,selectedMachineId:l?.id??``,devices:t,cloudProfiles:e.cloudProfiles,autoDeviceDisabledReason:n}}return{kind:e.deviceId?`device`:e.autoDevice?`auto-device`:`local`,label:e.deviceId?r?.label??e.deviceId:w(e.autoDevice?`newSession.autoDevice`:`newSession.local`),cloudMachines:[],selectedMachineId:``,operatingSystems:[],selectedOsId:``,devices:t,cloudProfiles:e.cloudProfiles,autoDeviceDisabledReason:n}}function Mu(e){let t=e?.platform?.trim();if(t&&!/^(?:darwin|macos|mac os(?: x)?)\b/i.test(t))return E.monitor;let n=wu(e?.label),r=n===`laptop`?xu.laptop:n===`mini`?xu.macMini:n===`studio`?xu.macStudio:void 0;return r?k`<span class="new-session-page__device-icon" data-form=${n}>${r}</span>`:E.monitor}function Nu(e){return k`<div
class="new-session-page__environment-skeletons"
role="status"
aria-label=${w(`common.loading`)}
aria-busy="true"
data-section=${e}
>
<span class="skeleton new-session-page__environment-skeleton-row" aria-hidden="true"></span>
<span class="skeleton new-session-page__environment-skeleton-row" aria-hidden="true"></span>
</div>`}function Pu(e,t,n,r){return k`<div class="new-session-page__environment-heading new-session-page__devices-heading">
<span>${e}</span>
${r?k`<button
type="button"
class="new-session-page__connect-device"
data-action=${t}
aria-label=${w(t===`connect-machine`?`newSession.connectMachine`:`newSession.manageCloudWorkers`)}
?disabled=${n}
@click=${r}
>
${Lu}
</button>`:O}
</div>`}function Fu(e){let t=Yn(e.state.cloudProfiles.find(t=>t.id===e.cloudProfileId)),n=e.state.kind===`cloud`?t.icon:e.state.kind===`local`?E.home:e.state.kind===`auto-device`?Iu:Mu(e.state.devices.find(t=>t.deviceId===e.deviceId)),r=e.gatewayName.trim()||w(`newSession.local`),i=e.state.kind===`local`?r:e.state.label,a=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(` · `):``,o=e.environmentQuery.trim().toLocaleLowerCase(),s=(...e)=>e.some(e=>e?.toLocaleLowerCase().includes(o)),c=s(w(`newSession.local`),w(`newSession.gatewayHost`),e.gatewayName),l=e.state.devices.filter(e=>s(w(`newSession.device`),w(`newSession.yourDevices`),e.label,e.deviceId,...e.facts)).toSorted((e,t)=>Number(t.selectable)-Number(e.selectable)),u=e.isAdmin?e.state.cloudProfiles.filter(e=>s(w(`newSession.cloud`),e.id,e.providerId,e.providerDisplayId,Yn(e).label,e.trust===`disposable`?w(`newSession.environmentDisposable`):e.trust===`persistent`?w(`newSession.environmentPersistent`):void 0)):[],d=e.isAdmin&&!!e.cloudProfileId&&!e.state.cloudProfiles.some(t=>t.id===e.cloudProfileId)&&s(w(`newSession.cloud`),e.cloudProfileId),f=e.state.devices.length>1&&(l.length>0||s(w(`newSession.autoDeviceChoose`),w(`newSession.autoDevice`))),p=e.state.autoDeviceDisabledReason??w(e.autoPlacementMode===`eligible-order`?`newSession.autoDeviceHintEligible`:`newSession.autoDeviceHint`),m=e.submitting||e.pendingPlacement,h=e.catalogLoading&&l.length===0,g=e.isAdmin&&e.catalogLoading&&u.length===0;return k`
<span class="new-session-page__select new-session-page__select--where">
<button
id="new-session-where-trigger"
type="button"
class="new-session-page__trigger ${e.popoverHiding?`new-session-page__trigger--hiding`:``}"
aria-label="${w(`newSession.where`)}: ${i}${a?`, ${a}`:``}"
aria-description=${e.state.kind===`cloud`&&t.label?w(`newSession.cloudWorkerProvider`,{provider:t.label}):O}
data-cloud-profile=${e.cloudProfileId||O}
data-machine-class=${e.machineClass||O}
data-os=${e.os||O}
data-device-id=${e.deviceId||O}
data-auto-device=${e.autoDevice?`true`:O}
aria-haspopup="dialog"
aria-expanded=${String(e.popoverOpen)}
?disabled=${e.submitting||e.pendingPlacement}
@click=${e.onGuardTransition}
>
${Zs(n,i,a)}
</button>
</span>
<wa-popover
${yt(_r)}
class="new-session-page__select new-session-page__where-popover new-session-page__picker-popover"
for="new-session-where-trigger"
placement="bottom-start"
without-arrow
@wa-show=${iu(t=>{t.currentTarget instanceof Wn&&(t.currentTarget.popup.autoSize=`vertical`,t.currentTarget.popup.autoSizePadding=8),e.onPopoverShow()})}
@wa-hide=${iu(()=>e.onPopoverHide())}
@wa-after-hide=${iu(()=>e.onPopoverAfterHide())}
>
<div class="new-session-page__environment-layout">
<div class="new-session-page__picker-root new-session-page__environment-picker">
<label class="new-session-page__environment-search">
<span aria-hidden="true">${E.search}</span>
<input
type="search"
autofocus
aria-label=${w(`newSession.environmentSearchPlaceholder`)}
placeholder=${w(`newSession.environmentSearchPlaceholder`)}
.value=${e.environmentQuery}
?disabled=${m}
@input=${t=>{t.currentTarget instanceof HTMLInputElement&&e.onEnvironmentQueryInput(t.currentTarget.value)}}
/>
</label>
<div class="new-session-page__environment-list">
${c||l.length||f?Pu(w(`newSession.yourDevices`),`connect-machine`,m,e.isAdmin?e.onConnectMachine:void 0):O}
${f?k`<openclaw-tooltip
class="new-session-page__environment-details"
placement="right-start"
>
<button
type="button"
class="session-menu__item new-session-page__environment-option"
data-value="auto-device"
data-popover="close"
aria-pressed=${String(e.autoDevice===!0)}
aria-description=${p}
?disabled=${m||!e.autoDevice&&!!e.state.autoDeviceDisabledReason}
@click=${e.onSelectAutoDevice}
>
<span class="session-menu__icon" aria-hidden="true">${Iu}</span>
<span class="session-menu__text">${w(`newSession.autoDeviceChoose`)}</span>
<span class="session-menu__check" aria-hidden="true"
>${e.autoDevice?E.check:O}</span
>
</button>
<div slot="content" class="new-session-page__environment-card">
<strong>${w(`newSession.autoDeviceChoose`)}</strong>
<div class="new-session-page__card-row">
<span class="new-session-page__card-icon" aria-hidden="true"
>${E.info}</span
>
<span>${p}</span>
</div>
</div>
</openclaw-tooltip>`:O}
${c?q({value:`gateway`,label:r,icon:E.home,summary:w(`newSession.runsOnGateway`),compact:!0,checked:e.state.kind===`local`,onSelect:()=>e.onSelectDevice(``)},m):O}
${bt(l,e=>e.deviceId,t=>q({value:`device:${t.deviceId}`,label:t.label,sub:t.subtitle,icon:Mu(t),platform:t.platform?Dr(t.platform):void 0,capabilityLabels:pc(t.capabilities),hideDetails:t.hideDetails,remediation:t.remediation,capacityLabel:t.selectable&&t.workerSlots?w(`newSession.concurrentSessionsValue`,{used:String(t.workerSlots.total-t.workerSlots.available),total:String(t.workerSlots.total)}):void 0,compact:!0,checked:e.state.kind===`device`&&e.deviceId===t.deviceId,disabled:!t.selectable,title:t.disabledReason,onSelect:()=>e.onSelectDevice(t.deviceId)},m))}
${h?Nu(`devices`):O}
${u.length||d||g?Pu(w(`newSession.cloud`),`manage-cloud-workers`,m,e.isAdmin&&!g?e.onManageCloudWorkers:void 0):O}
${is({profiles:u,selectedId:e.cloudProfileId,selectedOs:e.state.selectedOsId,selectedMachine:e.state.selectedMachineId,onSelectOs:e.onSelectCloudOs,onSelectMachine:e.onSelectCloudMachine,submitting:m,compact:!0,disabled:!!e.cloudDisabledReason,disabledReason:e.cloudDisabledReason,profileDisabledReason:e.cloudProfileDisabledReason,onSelect:e.onSelectCloudProfile})}
${g?Nu(`cloud`):O}
${d?q({value:`cloud:${e.cloudProfileId}`,label:e.cloudProfileId,icon:E.cloud,description:w(`newSession.catalogUnavailable`),compact:!0,checked:!0,disabled:!0,title:w(`newSession.catalogUnavailable`),onSelect:()=>void 0},m):O}
${!c&&l.length===0&&u.length===0&&!d&&!h&&!g?k`<div class="new-session-page__environment-empty" role="status">
${w(`newSession.environmentSearchEmpty`)}
</div>`:O}
</div>
</div>
</div>
</wa-popover>
`}var Iu,Lu;function Ru(){return(Ru=e((()=>{Kn(),A(),ht(),St(),Su(),it(),T(),cr(),mr(),d(),F(),Au(),Qa(),ls(),xc(),ts(),ou(),Qs(),hc(),P(),Iu=D(j`<rect x="2" y="7" width="14" height="11" />
<path d="M6 7V3h16v12h-6M6 22h6M9 18v4" />`),Lu=D(j`<circle cx="12" cy="12" r="9" />
<path d="M12 8v8M8 12h8" />`)})))()}function zu(e){let t=z(e.agentId);return k`
<span class="new-session-page__select new-session-page__select--agent">
<openclaw-agent-select
.variant=${e.variant??`compact`}
.options=${e.agents.map(t=>({value:z(t.id),label:re(t,e.agentIdentity?.get(t.id)),agent:t}))}
.identityById=${Object.fromEntries(e.agents.flatMap(t=>{let n=e.agentIdentity?.get(t.id);return n?[[t.id,n]]:[]}))}
.value=${t}
.accessibleLabel=${w(`newSession.agent`)}
.menuLabel=${w(`newSession.agents`)}
.disabled=${e.disabled}
.onSelect=${e.onSelect}
@wa-show=${()=>e.onOpenChange(!0)}
@wa-hide=${()=>e.onOpenChange(!1)}
></openclaw-agent-select>
</span>
`}function Bu({context:e,data:t,gateway:n,place:r,submitting:i,pendingPlacement:a,onConnectMachine:o,onNavigate:s,onFocusComposer:c,requestUpdate:l}){let u=r.browser,{machineClass:d,os:f}=r.cloudSelection,p=W(t),m=p||!r.isAdmin()?[]:n.cloudProfiles,h=r.repository.kind===`git`?r.repository:null,g=p?[]:u.projects,_=p?[]:u.resolveProjectRecents({sessions:e?.sessions.state.result?.sessions??[],workspace:r.workspacePath(),workspaceRoots:r.knownWorkspaceRoots(),isAdmin:r.isAdmin()}),v=ju({environments:r.canWrite()?n.environments:[],cloudProfiles:m,cloudProfileId:r.cloudProfileId,machineClass:d,os:f,deviceId:r.deviceId,autoDevice:r.autoDevice,devicePlacement:r.devicePlacementRuntime()?.devicePlacement,deviceDisabledReason:r.modelControl.devicePlacementUnsupportedReason()??n.deviceCatalogDisabledReason}),y=rc({folder:r.folder,workspace:r.workspacePath(),projectId:u.projectId,selectedRemoteProject:u.remoteProject,projects:g,recents:_,projectQuery:u.projectQuery,freshWorkspace:r.freshWorkspace}),b=gu({destination:r.cloudProfileId?`cloud`:r.remotePlacement?`remote`:`local`,worktree:r.worktree,worktreeName:r.worktreeName,headBranch:h?.headBranch,baseRef:r.baseRef,repository:!!r.remoteRepository}),x=n.gatewayName?w(`newSession.gatewayNamed`,{name:n.gatewayName}):w(`newSession.gateway`),S=(e,t)=>r.cloudMachines[e===`os`?`selectOs`:`select`](r.cloudProfileId,t,m,i||a,l);return k`${p?Wl({hosts:t?.terminalHosts,hostId:r.terminalHostId,submitting:i,onSelect:e=>r.selectTerminalHost(e)}):Fu({state:v,environmentQuery:u.environmentQuery,onEnvironmentQueryInput:e=>u.changeEnvironmentQuery(e),gatewayName:n.gatewayName,cloudProfileId:r.cloudProfileId,machineClass:d,os:f,deviceId:r.deviceId,autoDevice:r.autoDevice,autoPlacementMode:r.modelControl.autoPlacementSelectionMode(),cloudDisabledReason:r.modelControl.cloudRuntimeUnsupportedReason(),cloudProfileDisabledReason:e=>r.modelControl.cloudRuntimeUnsupportedReason(e),submitting:i,pendingPlacement:a,catalogLoading:r.canWrite()&&n.cloudProfilesPending,isAdmin:r.isAdmin(),...u.popoverCallbacks(`where`),onSelectDevice:e=>r.selectDevice(e),onSelectAutoDevice:()=>r.selectDevice(``,!0),onSelectCloudProfile:(e,t)=>{t&&r.cloudMachines.applyPending(e),r.selectCloudProfile(e)},onSelectCloudOs:e=>S(`os`,e),onSelectCloudMachine:e=>S(`machine`,e),onConnectMachine:o,onManageCloudWorkers:()=>{u.close(),s(`cloud-workers`)}})}${p&&r.terminalOnNode?k`<label class="new-session-page__select new-session-page__menu-field"
><span>${w(`newSession.terminalNodeFolder`)}</span
><input
aria-label=${w(`newSession.terminalNodeFolder`)}
.value=${r.folder}
?disabled=${i}
@input=${e=>{e.currentTarget instanceof HTMLInputElement&&r.applyFolder(e.currentTarget.value)}}
/></label>`:ic({state:y,browseAvailable:r.browseAvailable(),isAdmin:r.isAdmin(),canWrite:r.canWrite(),folder:r.folder,workspace:r.workspacePath(),projects:g,projectQuery:u.projectQuery,projectSearchAvailable:!p&&kt(e?.gateway.snapshot,`projects.searchRemote`,`operator.read`),projectAddAvailable:!p&&kt(e?.gateway.snapshot,r.remotePlacement?`sessions.create`:`projects.add`,`operator.write`),remoteProjects:u.projectSearchResult?.projects??[],selectedRemoteProject:u.remoteProject,projectSearchCredentialMissing:u.projectSearchResult?.credential===`missing`,projectSearchLoading:u.projectSearchLoading,projectSearchError:u.projectSearchError,projectId:u.projectId,freshWorkspace:r.freshWorkspace,onNewWorkspace:r.remotePlacement?()=>r.selectNewWorkspace():void 0,gatewayLabel:x,submitting:i,pendingPlacement:a,...u.popoverCallbacks(`project`),browserOpen:u.browserOpen,browser:u.browser,registerProjectPath:u.browserProjectPath,registeringProject:u.browserRegistering,onSelectProject:e=>r.selectProjectId(e),onProjectQueryInput:e=>u.changeProjectQuery(e),onSelectRemoteProject:e=>r.selectRemoteProject(e),onApplyFolder:e=>r.applyFolder(e),onBrowse:()=>u.selectGatewayBrowser(r.folder.trim()||r.workspacePath()),onBrowserBack:()=>u.showRoot(),onRegisterProject:e=>void u.registerBrowserProject(e),onClose:()=>u.close()})}${r.checkoutVisible&&!(p&&r.terminalOnNode)?vu({state:b,remotePlacement:r.remotePlacement,repository:!!r.remoteRepository,folderLabel:y.label,worktree:r.worktree,worktreeAvailable:r.worktreeAvailable(),repositoryUnavailable:r.repository.kind===`unavailable`,branches:h,branchesLoading:r.repository.kind===`checking`,baseRef:r.baseRef,worktreeName:r.worktreeName,submitting:i,pendingPlacement:a,...u.popoverCallbacks(`checkout`),onSelectWorktree:e=>r.selectWorktree(e),onBaseRefInput:e=>r.setBaseRef(e),onWorktreeNameInput:e=>r.setWorktreeName(e),onConfirm:c}):O}`}function Vu(){return(Vu=e((()=>{A(),d(),F(),pe(),jt(),C(),G(),bu(),hr(),ac(),Gl(),Ru(),P()})))()}var Hu=t({LOBSTER_FAMILIARITY_TUNING:()=>ad,getLobsterFamiliarity:()=>$u,getLobsterdex:()=>Gu,getLobsterdexEntries:()=>Ku,isLobsterFirstVisitAnniversary:()=>td,lobsterHonorific:()=>ed,recordLobsterArrivalStats:()=>Zu,recordLobsterShoo:()=>Qu,recordLobsterVisit:()=>Ju,subscribeLobsterdex:()=>qu});function Uu(){try{let e=s()?.getItem(nd),t=e?JSON.parse(e):{},n=new Map;if(Array.isArray(t)){for(let e of t)typeof e==`string`&&e&&n.set(e,{firstSeenAt:null,name:null,shinySeenAt:null});return n}if(t&&typeof t==`object`)for(let[e,r]of Object.entries(t))e&&n.set(e,{firstSeenAt:typeof r?.firstSeenAt==`number`?r.firstSeenAt:null,name:typeof r?.name==`string`&&r.name?r.name:null,shinySeenAt:typeof r?.shinySeenAt==`number`?r.shinySeenAt:null});return n}catch{return new Map}}function Wu(e){let t={};for(let[n,r]of[...e.entries()].toSorted(([e],[t])=>e.localeCompare(t)))t[n]={...r.firstSeenAt===null?{}:{firstSeenAt:r.firstSeenAt},...r.name===null?{}:{name:r.name},...r.shinySeenAt===null?{}:{shinySeenAt:r.shinySeenAt}};let n=s();n&&(n.setItem(nd,JSON.stringify(t)),window.dispatchEvent(new Event(id)))}function Gu(){return new Set(Uu().keys())}function Ku(){return Uu()}function qu(e){let t=()=>e(),n=t=>{t.storageArea===s()&&(t.key===nd||t.key===null)&&e()};return window.addEventListener(id,t),window.addEventListener(`storage`,n),()=>{window.removeEventListener(id,t),window.removeEventListener(`storage`,n)}}function Ju(e,t={}){try{let n=Uu(),r=n.get(e);if(r){let e=t.shiny===!0&&r.shinySeenAt===null;if(r.firstSeenAt!==null&&r.name!==null&&!e)return}n.set(e,{firstSeenAt:r?.firstSeenAt??Date.now(),name:r?.name??t.name??null,shinySeenAt:r?.shinySeenAt??(t.shiny===!0?Date.now():null)}),Wu(n)}catch{}}function Yu(){try{let e=s()?.getItem(rd),t=e?JSON.parse(e):{},n=t&&typeof t==`object`?t:{};return{visits:typeof n.visits==`number`&&n.visits>=0?n.visits:0,shoos:typeof n.shoos==`number`&&n.shoos>=0?n.shoos:0}}catch{return{visits:0,shoos:0}}}function Xu(e){try{s()?.setItem(rd,JSON.stringify(e))}catch{}}function Zu(){let e=Yu();Xu({...e,visits:e.visits+1})}function Qu(){let e=Yu();Xu({...e,shoos:e.shoos+1})}function $u(){let{visits:e,shoos:t}=Yu();return{tier:e<3?`shy`:e<15?`regular`:`friend`,wary:t>=3&&t>e*.3,visits:e,shoos:t}}function ed(e){return od.find(([t])=>e>=t)?.[1]??null}function td(e,t){if(e===null||t.getTime()-e<sd)return!1;let n=new Date(e);return n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()}var nd,rd,id,ad,od,sd;function cd(){return(cd=e((()=>{nd=`openclaw.control.lobsterdex.v1`,rd=`openclaw.control.lobsterpet.familiarity.v1`,id=`openclaw:lobsterdex-changed`,ad={shy:{stayMul:.6,firstDelayMul:1.3,gapMul:1},regular:{stayMul:1,firstDelayMul:1,gapMul:1},friend:{stayMul:1.6,firstDelayMul:.7,gapMul:.8},waryGapMul:1.7},od=[[250,`Elder`],[100,`Captain`],[50,`Sir`]],sd=2592e7})))()}function ld(e){return dd[e]??e}function ud(e){return vn(fd[(e>>>3)%fd.length],`lobster pet name catalog entry`)}var dd,fd,pd;function md(){return(md=e((()=>{Dn(),dd={blue:`Blueberry`,gold:`Goldie`,lumen:`Glimmer`,magma:`Ember`,oilslick:`Slick`,aurora:`Borealis`,nebula:`Cosmo`,banana:`Peel`,mood:`Ringo`,bee:`Buzz`,rubberduck:`Debuggy`,watermelon:`Pips`,clawnstantine:`Clawnstantine`,clawiestardust:`Clawie Stardust`,taylorpinch:`Taylor Pinch`,clawtoodeetoo:`Clawtoo Deetoo`,leonardodepinchy:`Leonardo DaPinchy`,shellvis:`Shellvis`,alexandergrahamshell:`Alexander Graham Shell`,clawtron:`Clawtron`,selene:`Selene`,geode:`Amethyst`,ghost:`Boo`,glass:`Prism`,split:`Picasso`,sourdough:`Boule`,zombie:`Shambles`,plush:`Buttons`,balloon:`Squeaky`,cottoncandy:`Taffy`,cryptid:`Nessie`,flatpack:`Skaldjur`,tinfoil:`Mulder`,actual:`Homarus`,disco:`Boogie`,chimera:`Frankie`,blueprint:`Prototype`,phosphor:`TTY`,ascii:`Figlet`,portal:`Warp`,notexture:`Magenta`,loading:`Spinner`,eclipse:`Umbra`,heisenbug:`Segfault`,invisible:`Nobody`,pixel:`Sprite`,retro:`OG`,goldenretro:`24K`},fd=[`Pinchy`,`Barnaby`,`Thermidor`,`Clawdette`,`Sheldon`,`Scuttles`,`Bisque`,`Crusty`,`Snips`,`Bubbles`,`Clawdia`,`Ferdinand`,`Maple`,`Pearl`,`Biscuit`,`Captain`,`Ziggy`,`Noodle`,`Waffles`,`Pippin`,`Squirt`,`Chip`,`Clementine`,`Moss`],pd={crimson:{flavor:`The classic red, first in every tide pool.`,hint:`Where every story starts.`},blue:{flavor:`1 in 2 million, and knows it.`,hint:`One in two million.`},gold:{flavor:`1 in 30 million karats.`,hint:`Worth its weight.`},lumen:{flavor:`Brings its own night lights.`,hint:`Glows where it's darkest.`},magma:{flavor:`Fresh from the vent, still cooling.`,hint:`Runs hot.`},oilslick:{flavor:`Black shell, rainbow finish.`,hint:`Spilled, not stirred.`},aurora:{flavor:`Northern lights, southern claws.`,hint:`Best seen on clear nights.`},nebula:{flavor:`Not from any ocean on this planet.`,hint:`Came from very far away.`},banana:{flavor:`Banana. For scale.`,hint:`For scale.`},mood:{flavor:`Wears whatever color you're feeling.`,hint:`Matches your vibe.`},bee:{flavor:`Technically not a bee.`,hint:`Do not tell the bees.`},rubberduck:{flavor:`Listens to your bugs. Judges silently.`,hint:`Quack.`},watermelon:{flavor:`Contains 6% lobster.`,hint:`Ripe when thumped.`},clawnstantine:{flavor:`Built an empire. Still rules from the ledge.`,hint:`All tides lead here.`},clawiestardust:{flavor:`Changes shells. Never changes style.`,hint:`Something electric washed ashore.`},taylorpinch:{flavor:`Turns every tide into an era.`,hint:`Someone is shaking off the sand.`},clawtoodeetoo:{flavor:`Speaks fluent beep. Fixes things anyway.`,hint:`A resourceful little droid.`},leonardodepinchy:{flavor:`Every shell is a canvas.`,hint:`A little Renaissance is washing ashore.`},shellvis:{flavor:`The king of rock and claw.`,hint:`Someone brought blue suede claws.`},alexandergrahamshell:{flavor:`Good ideas ring a bell.`,hint:`A familiar ringing from the shore.`},clawtron:{flavor:`60% rivets, 40% love.`,hint:`Beep boop snip.`},selene:{flavor:`Carries the current moon on its belly.`,hint:`Waxes and wanes.`},geode:{flavor:`Rock outside, amethyst inside.`,hint:`Crack the surface.`},ghost:{flavor:`1 in 100 million, barely there.`,hint:`You'd walk right past it.`},glass:{flavor:`Fully transparent. Nothing to hide.`,hint:`Easy to miss, hard to forget.`},split:{flavor:`Two lobsters, one shell.`,hint:`Can't pick a side.`},sourdough:{flavor:`Started from a starter. 24-hour proof.`,hint:`Still proofing.`},zombie:{flavor:`Slightly used. Still friendly.`,hint:`It's been better.`},plush:{flavor:`Machine washable. Air dry only.`,hint:`Soft to the touch.`},balloon:{flavor:`Do not pop.`,hint:`Handle with care.`},cottoncandy:{flavor:`Pastel, like the famous Maine catch.`,hint:`Sweeter than it looks.`},cryptid:{flavor:`Every photo comes out blurry.`,hint:`Sightings unconfirmed.`},flatpack:{flavor:`Some assembly required.`,hint:`Missing one screw.`},tinfoil:{flavor:`The tide is a psyop.`,hint:`They know.`},actual:{flavor:`An actual lobster. Unsettling, honestly.`,hint:`Anatomically correct.`},disco:{flavor:`Born under a mirror ball.`,hint:`The night is still young.`},chimera:{flavor:`Borrowed parts. No refunds.`,hint:`Something's off.`},blueprint:{flavor:`Final hardware pending approval.`,hint:`Still on the drawing board.`},phosphor:{flavor:`80 columns, 24 rows, one lobster.`,hint:`Hums at sixty hertz.`},ascii:{flavor:`Renders anywhere. Even over SSH.`,hint:`chmod +x`},portal:{flavor:`Arrives before it leaves.`,hint:`Mind the gap.`},notexture:{flavor:`Texture not found.`,hint:`404.`},loading:{flavor:`Still loading. Any second now.`,hint:`…`},eclipse:{flavor:`Do not look directly at it.`,hint:`Once in a blue moon.`},heisenbug:{flavor:`Only renders right when nobody's watching.`,hint:`Cannot be reproduced.`},invisible:{flavor:`It's right there. Look closer.`,hint:`Trust me, it exists.`},pixel:{flavor:`Rendered in 1987. Still runs.`,hint:`Insert coin.`},retro:{flavor:`The original: big claw, no apologies.`,hint:`The one that started it all.`},goldenretro:{flavor:`One in a generation.`,hint:`Worth the wait.`}}})))()}function hd(e){return((e.getTime()-_d)/864e5%gd+gd)%gd/gd}var gd,_d;function vd(){return(vd=e((()=>{gd=29.53059,_d=Date.parse(`2000-01-06T18:14:00.000Z`)})))()}var yd,bd;function xd(){return(xd=e((()=>{yd=[[{id:`crimson`,shell:`#ff4f40`,claw:`#ff775f`},26],[{id:`blue`,shell:`#4a7dfc`,claw:`#7fa4ff`},7],[{id:`gold`,shell:`#f4b840`,claw:`#f9d47a`},5],[{id:`lumen`,shell:`#1d2f4e`,claw:`#2e4a77`},2],[{id:`magma`,shell:`#241214`,claw:`#3a1d18`},2],[{id:`oilslick`,shell:`#15171d`,claw:`#23262e`},2],[{id:`aurora`,shell:`#dce6f0`,claw:`#e9f0f7`},2],[{id:`nebula`,shell:`#34255c`,claw:`#4a3a7d`},2],[{id:`banana`,shell:`#f7e27d`,claw:`#f3d55b`},2],[{id:`mood`,shell:`var(--accent, #7f77dd)`,claw:`var(--accent-hover, #9a93e8)`},1.5],[{id:`bee`,shell:`#f4c531`,claw:`#2b2b23`},1.5],[{id:`rubberduck`,shell:`#ffd93b`,claw:`#ffb03b`},1.5],[{id:`watermelon`,shell:`#3f9d63`,claw:`#4fb072`},1.5],[{id:`clawnstantine`,shell:`#7546a0`,claw:`#a576c4`},1],[{id:`clawiestardust`,shell:`#f4ddd1`,claw:`#e76545`},1],[{id:`taylorpinch`,shell:`#efcc78`,claw:`#d5485c`},1],[{id:`clawtoodeetoo`,shell:`#e8edf1`,claw:`#3b68c4`},1],[{id:`leonardodepinchy`,shell:`#ddc595`,claw:`#b99161`},1],[{id:`shellvis`,shell:`#f0c49f`,claw:`#4b6694`},1],[{id:`alexandergrahamshell`,shell:`#d7c3a5`,claw:`#aa8759`},1],[{id:`clawtron`,shell:`#8d99a6`,claw:`#a2aeba`},1],[{id:`selene`,shell:`#c9ced8`,claw:`#d8dde5`},1],[{id:`geode`,shell:`#6b6474`,claw:`#7d7588`},1],[{id:`ghost`,shell:`#dce8f2`,claw:`#ecf3fa`},1],[{id:`glass`,shell:`#cfe4f4`,claw:`#e0eef8`},1],[{id:`split`,shell:`#ff4f40`,claw:`#ff775f`},1],[{id:`sourdough`,shell:`#d9a662`,claw:`#e6bc82`},1],[{id:`zombie`,shell:`#9db08a`,claw:`#86a17a`},1],[{id:`plush`,shell:`#e8967a`,claw:`#f2b09a`},1],[{id:`balloon`,shell:`#ff5c8a`,claw:`#ff7ea1`},1],[{id:`cryptid`,shell:`#6e6257`,claw:`#7d7263`},.9],[{id:`flatpack`,shell:`#d9c9a8`,claw:`#d9c9a8`},.9],[{id:`tinfoil`,shell:`#9aa4ad`,claw:`#a8b2bb`},.9],[{id:`actual`,shell:`#a63c28`,claw:`#8f3220`},.9],[{id:`cottoncandy`,shell:`#f6a8c9`,claw:`#a5c6f0`},.8],[{id:`disco`,shell:`#b8c4d8`,claw:`#cbd5e6`},.8],[{id:`chimera`,shell:`#b0685a`,claw:`#b0685a`},.75],[{id:`pixel`,shell:`#d84c3e`,claw:`#ef8f6a`},.7],[{id:`blueprint`,shell:`#123a66`,claw:`#123a66`},.7],[{id:`phosphor`,shell:`#0d2415`,claw:`#0f2b19`},.7],[{id:`ascii`,shell:`var(--lob-ascii-ink, #d8dee6)`,claw:`var(--lob-ascii-ink, #d8dee6)`},.7],[{id:`portal`,shell:`#4a9df8`,claw:`#ff9a2e`},.7],[{id:`notexture`,shell:`#ff00dc`,claw:`#111111`},.65],[{id:`loading`,shell:`#3a4150`,claw:`#454d5e`},.65],[{id:`eclipse`,shell:`#14161d`,claw:`#1d2026`},.65],[{id:`heisenbug`,shell:`#262a33`,claw:`#343945`},.6],[{id:`invisible`,shell:`rgba(127,140,160,0.07)`,claw:`rgba(127,140,160,0.07)`},.55],[{id:`retro`,shell:`#e8262c`,claw:`#f04a3e`},.5],[{id:`goldenretro`,shell:`#e8b422`,claw:`#f6cf5a`},.1]],bd=yd.map(([e])=>e)})))()}function Sd(e,t){return j`
<g class="lob-flatpack">
<path
d="M48 10 C28 10 17 25 17 41 C17 58 29 69 48 69 C67 69 79 58 79 41 C79 25 68 10 48 10 Z"
fill="var(--lob-shell)"
stroke="#8a7c5f"
stroke-width="2"
stroke-dasharray="4 3"
/>
<g class="lob-eye-open" style=${e}>
<circle cx="39" cy="34" r="4.5" fill="#0a1014" />
<circle cx="57" cy="34" r="4.5" fill="#0a1014" />
<circle cx="40.2" cy="32.8" r="1.7" fill="var(--lob-glint, #00e5cc)" />
<circle cx="58.2" cy="32.8" r="1.7" fill="var(--lob-glint, #00e5cc)" />
</g>
<g
class="lob-eye-closed"
stroke="#0a1014"
stroke-width="2.5"
stroke-linecap="round"
fill="none"
style=${t}
>
<path d="M34 35 Q39 31 44 35" />
<path d="M52 35 Q57 31 62 35" />
</g>
<g fill="none" stroke="#8a7c5f" stroke-width="1.5" stroke-dasharray="4 3">
<path d="M27 48 Q50 58 75 61" />
<path d="M68 47 Q79 58 92 70" />
</g>
<g class="lob-claw lob-claw--l">
<path
d="M76 53 C66 50 62 58 67 65 C72 72 82 68 85 60 C87 55 82 53 76 53 Z"
fill="var(--lob-claw)"
stroke="#8a7c5f"
stroke-width="1.5"
stroke-dasharray="4 3"
/>
</g>
<g class="lob-claw lob-claw--r">
<path
d="M98 65 C109 62 115 70 111 79 C107 88 96 84 91 76 C88 70 92 66 98 65 Z"
fill="var(--lob-claw)"
stroke="#8a7c5f"
stroke-width="1.5"
stroke-dasharray="4 3"
/>
</g>
<g fill="var(--lob-shell)" stroke="#8a7c5f" stroke-width="1.5" stroke-dasharray="4 3">
<rect x="15" y="88" width="15" height="6" rx="2" />
<rect x="34" y="88" width="15" height="6" rx="2" />
<rect x="53" y="88" width="15" height="6" rx="2" />
<rect x="72" y="88" width="15" height="6" rx="2" />
</g>
<g fill="none" stroke="#5f5648" stroke-width="3" stroke-linecap="round">
<path d="M84 24 L101 8" />
<path d="M93 31 L113 14" />
</g>
<g fill="#8a7c5f">
<circle cx="105" cy="29" r="3" />
<circle cx="113" cy="35" r="3" />
</g>
<path
class="lob-flatpack__allen-key"
d="M101 84 L101 99 L115 99"
fill="none"
stroke="#5f5648"
stroke-width="3"
stroke-linecap="round"
stroke-linejoin="round"
/>
</g>
`}function Cd(e,t){return j`
<!-- Skeleton placeholders stay neutral instead of inheriting palette colors. -->
<g class="lob-skeleton">
<rect class="lob-skeleton__block" style="--i:0" x="24" y="18" width="72" height="64" rx="10" fill="#2f3542" />
<rect class="lob-skeleton__block" style="--i:1" x="2" y="43" width="24" height="20" rx="8" fill="#39404f" />
<rect class="lob-skeleton__block" style="--i:2" x="94" y="43" width="24" height="20" rx="8" fill="#39404f" />
<path class="lob-skeleton__block" style="--i:3" d="M45 21 L34 7" stroke="#39404f" stroke-width="6" stroke-linecap="round" />
<path class="lob-skeleton__block" style="--i:4" d="M75 21 L86 7" stroke="#39404f" stroke-width="6" stroke-linecap="round" />
<rect class="lob-skeleton__block" style="--i:5" x="31" y="79" width="10" height="22" rx="4" fill="#2f3542" />
<rect class="lob-skeleton__block" style="--i:6" x="46" y="79" width="10" height="24" rx="4" fill="#39404f" />
<rect class="lob-skeleton__block" style="--i:7" x="64" y="79" width="10" height="24" rx="4" fill="#39404f" />
<rect class="lob-skeleton__block" style="--i:8" x="79" y="79" width="10" height="22" rx="4" fill="#2f3542" />
<g class="lob-eye-open" style=${e}>
<circle cx="47" cy="43" r="5" fill="#4a5364" />
<circle cx="73" cy="43" r="5" fill="#4a5364" />
</g>
<g class="lob-eye-closed" style=${t} fill="#4a5364">
<rect x="41" y="42" width="12" height="3" rx="1.5" />
<rect x="67" y="42" width="12" height="3" rx="1.5" />
</g>
</g>
`}function wd(e,t){return j`
<g class="lob-actual">
<g fill="none" stroke="#6f281d" stroke-linecap="round">
<path d="M47 27 Q27 5 2 3" stroke-width="2" />
<path d="M73 27 Q93 5 118 3" stroke-width="2" />
<path d="M46 29 Q34 16 22 13" stroke-width="1.3" />
<path d="M74 29 Q86 16 98 13" stroke-width="1.3" />
</g>
<g fill="none" stroke="#7f3022" stroke-width="2.2" stroke-linecap="round">
<path d="M39 48 Q22 52 10 65" />
<path d="M38 56 Q20 62 8 77" />
<path d="M40 65 Q24 72 15 88" />
<path d="M43 74 Q31 82 27 97" />
<path d="M81 48 Q98 52 110 65" />
<path d="M82 56 Q100 62 112 77" />
<path d="M80 65 Q96 72 105 88" />
<path d="M77 74 Q89 82 93 97" />
</g>
<g class="lob-actual__tail" fill="#8f3220" stroke="#6f281d" stroke-width="1.4">
<path d="M48 88 Q38 91 31 103 Q44 103 55 96 Z" />
<path d="M72 88 Q82 91 89 103 Q76 103 65 96 Z" />
<path d="M54 89 Q60 96 66 89 L69 104 Q60 101 51 104 Z" />
</g>
<g class="lob-claw lob-claw--l">
<path
d="M34 43 Q25 31 12 33 Q0 35 2 48 Q4 61 17 63 Q28 64 35 54 L30 49 Q22 54 15 50 Q10 47 13 42 Q17 37 24 42 Z"
fill="var(--lob-claw)"
stroke="#6f281d"
stroke-width="1.5"
/>
</g>
<g class="lob-claw lob-claw--r">
<path
d="M86 44 Q94 32 104 34 Q113 35 116 42 L107 45 L118 49 Q115 58 105 60 Q96 61 87 53 Z"
fill="var(--lob-claw)"
stroke="#6f281d"
stroke-width="1.5"
/>
</g>
<path
class="lob-actual__carapace"
d="M60 20 Q38 20 34 38 Q32 50 41 58 Q49 64 60 64 Q71 64 79 58 Q88 50 86 38 Q82 20 60 20 Z"
fill="var(--lob-shell)"
stroke="#6f281d"
stroke-width="1.8"
/>
<g class="lob-actual__abdomen" stroke="#6f281d" stroke-width="1.4">
<path d="M39 54 Q60 62 81 54 L79 65 Q60 72 41 65 Z" fill="#b34b35" />
<path d="M41 65 Q60 72 79 65 L76 76 Q60 82 44 76 Z" fill="#a63c28" />
<path d="M44 76 Q60 82 76 76 L72 87 Q60 92 48 87 Z" fill="#b34b35" />
<path d="M48 87 Q60 92 72 87 L67 96 Q60 99 53 96 Z" fill="#a63c28" />
</g>
<path d="M48 42 Q60 48 72 42 Q69 56 60 58 Q51 56 48 42 Z" fill="#bd6044" opacity="0.72" />
<g fill="none" stroke="#6f281d" stroke-width="2.2" stroke-linecap="round">
<path d="M47 28 L45 23" />
<path d="M73 28 L75 23" />
</g>
<g class="lob-eye-open" style=${e}>
<circle cx="45" cy="22" r="3.5" fill="#17100e" />
<circle cx="75" cy="22" r="3.5" fill="#17100e" />
<circle cx="46" cy="21" r="1" fill="#f2c6a8" />
<circle cx="76" cy="21" r="1" fill="#f2c6a8" />
</g>
<g class="lob-eye-closed" style=${t} fill="none" stroke="#17100e" stroke-width="2" stroke-linecap="round">
<path d="M41.5 22 H48.5" />
<path d="M71.5 22 H78.5" />
</g>
</g>
`}function Td(e,t){return j`
<g class="lob-balloon">
<g fill="none" stroke="var(--lob-shell)" stroke-width="4" stroke-linecap="round">
<path d="M48 13 Q45 5 42 3" />
<path d="M72 13 Q75 5 78 3" />
</g>
<g class="lob-claw lob-claw--l" fill="var(--lob-claw)">
<ellipse cx="29" cy="29" rx="9" ry="7" transform="rotate(-20 29 29)" />
<ellipse cx="20" cy="35" rx="8" ry="6" transform="rotate(18 20 35)" />
</g>
<g class="lob-claw lob-claw--r" fill="var(--lob-claw)">
<ellipse cx="91" cy="29" rx="9" ry="7" transform="rotate(20 91 29)" />
<ellipse cx="100" cy="35" rx="8" ry="6" transform="rotate(-18 100 35)" />
</g>
<ellipse cx="60" cy="29" rx="24" ry="19" fill="var(--lob-shell)" />
<circle cx="60" cy="48" r="4" fill="#d94b72" />
<ellipse cx="60" cy="61" rx="18" ry="14" fill="var(--lob-shell)" />
<circle cx="60" cy="75" r="3.5" fill="#d94b72" />
<ellipse cx="60" cy="86" rx="13" ry="10" fill="var(--lob-shell)" />
<g fill="#ffffff" opacity="0.55">
<ellipse cx="50" cy="22" rx="4" ry="10" transform="rotate(35 50 22)" />
<ellipse cx="52" cy="56" rx="3" ry="7" transform="rotate(32 52 56)" />
<ellipse cx="54" cy="82" rx="2.4" ry="5" transform="rotate(28 54 82)" />
</g>
<g class="lob-eye-open" style=${e}>
<circle cx="50" cy="30" r="4.5" fill="#0a1014" />
<circle cx="70" cy="30" r="4.5" fill="#0a1014" />
<circle cx="51.3" cy="28.7" r="1.8" fill="var(--lob-glint, #00e5cc)" />
<circle cx="71.3" cy="28.7" r="1.8" fill="var(--lob-glint, #00e5cc)" />
</g>
<g
class="lob-eye-closed"
style=${t}
fill="none"
stroke="#0a1014"
stroke-width="2.5"
stroke-linecap="round"
>
<path d="M45 31 Q50 27 55 31" />
<path d="M65 31 Q70 27 75 31" />
</g>
<path d="M55 96 L60 91 L65 96 L60 101 Z" fill="#d94b72" />
<path
d="M60 100 Q67 102 62 105 Q57 108 65 111"
fill="none"
stroke="#c9d2da"
stroke-width="1.2"
stroke-linecap="round"
/>
</g>
`}function Ed(e,t){return j`
<!-- Like pet names and lore, terminal glyph art is an English-only easter-egg channel. -->
<g
class="lob-ascii"
fill="var(--lob-shell)"
font-family="ui-monospace, SFMono-Regular, Menlo, monospace"
font-size="11"
text-anchor="middle"
xml:space="preserve"
>
<text x="60" y="17">\\ / \\ /</text>
<text x="60" y="31">{ \\_______/ }</text>
<g class="lob-eye-open" style=${e}>
<text x="60" y="45">(o) (o)</text>
</g>
<g class="lob-eye-closed" style=${t}>
<text x="60" y="45">(-) (-)</text>
</g>
<text x="60" y="59">( '---' )</text>
<text x="60" y="73"> \\ _____ /</text>
<text x="60" y="87"> (_________)</text>
<text x="60" y="101"> | | | |</text>
</g>
`}function Dd(e,t){return j`
<g class="lob-portal">
<ellipse
class="lob-portal-ring lob-portal-ring--blue"
cx="30"
cy="50"
rx="14"
ry="30"
fill="#0d1b33"
fill-opacity="0.85"
stroke="currentColor"
stroke-width="3"
transform="rotate(-12 30 50)"
/>
<!-- Fixed lobster red preserves the split-body gag while shell/claw vars carry portal identity. -->
<path d="M31 30 Q45 20 56 30 Q62 39 60 53 Q58 64 47 70 L31 67 Z" fill="#b0432f" />
<g class="lob-claw lob-claw--l">
<path
d="M52 54 Q58 48 63 51 Q67 56 63 62 Q58 67 52 63 Z"
fill="#b0432f"
/>
</g>
<g fill="none" stroke="#b0432f" stroke-width="2" stroke-linecap="round">
<path d="M42 31 Q43 16 50 7" />
<path d="M52 28 Q58 14 66 9" />
</g>
<g class="lob-eye-open" style=${e}>
<circle cx="45" cy="39" r="4" fill="#0a1014" />
<circle cx="57" cy="37" r="4" fill="#0a1014" />
<circle cx="46" cy="38" r="1.5" fill="var(--lob-glint, #00e5cc)" />
<circle cx="58" cy="36" r="1.5" fill="var(--lob-glint, #00e5cc)" />
</g>
<g
class="lob-eye-closed"
style=${t}
fill="none"
stroke="#0a1014"
stroke-width="2.2"
stroke-linecap="round"
>
<path d="M41 40 Q45 37 49 40" />
<path d="M53 38 Q57 35 61 38" />
</g>
<g class="lob-portal-rear" fill="#b0432f">
<path d="M91 44 Q82 40 75 44 L82 51 L74 56 L82 61 L75 68 Q83 70 92 64 Z" />
<path d="M88 52 Q82 49 78 45" fill="none" stroke="#7f3022" stroke-width="2" />
<path d="M88 61 Q82 64 78 69" fill="none" stroke="#7f3022" stroke-width="2" />
</g>
<ellipse
class="lob-portal-ring lob-portal-ring--orange"
cx="92"
cy="58"
rx="14"
ry="30"
fill="#0d1b33"
fill-opacity="0.85"
stroke="currentColor"
stroke-width="3"
transform="rotate(10 92 58)"
/>
</g>
`}function Od(e){return j`
<g class="lob-tinfoil" fill="none" stroke="#c9d2da" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M27 31 L38 27 L45 34 L55 25 L64 33 L75 26 L91 34" />
<path d="M20 51 L31 45 L43 54 L55 45 L68 54 L82 44 L100 53" />
<path d="M23 70 L36 64 L47 73 L60 63 L74 72 L90 65 L98 72" />
<path d="M35 86 L46 80 L58 87 L70 79 L84 85" />
</g>
${e?j`
<g class="lob-tinfoil-hat">
<path d="M43 14 L57 0 L78 15 L60 11 Z" fill="#c0c9d1" />
<path d="M57 0 L60 11 L78 15" fill="none" stroke="#7f8992" stroke-width="1.5" />
<path d="M43 14 L60 11 L53 5" fill="none" stroke="#9aa4ad" stroke-width="1.5" />
</g>
`:``}
`}var kd,Ad,jd,Md,Nd;function Pd(){return(Pd=e((()=>{A(),kd=j`
<g class="lob-watermelon">
<g fill="none" stroke="#2c7a4a" stroke-width="4" stroke-linecap="round">
<path d="M31 25 Q39 13 48 11" />
<path d="M48 22 Q54 10 60 9" />
<path d="M66 22 Q72 10 80 15" />
<path d="M82 28 Q89 20 94 30" />
</g>
<ellipse cx="60" cy="69" rx="35" ry="23" fill="#e5484d" />
<g fill="#28211c">
<ellipse cx="42" cy="62" rx="2" ry="3.4" transform="rotate(-20 42 62)" />
<ellipse cx="58" cy="58" rx="2" ry="3.4" transform="rotate(8 58 58)" />
<ellipse cx="76" cy="64" rx="2" ry="3.4" transform="rotate(24 76 64)" />
<ellipse cx="49" cy="77" rx="2" ry="3.4" transform="rotate(18 49 77)" />
<ellipse cx="68" cy="79" rx="2" ry="3.4" transform="rotate(-16 68 79)" />
<ellipse cx="84" cy="75" rx="1.8" ry="3.1" transform="rotate(30 84 75)" />
</g>
</g>
`,Ad=j`
<path
class="lob-eclipse-corona"
d="M29 31 Q40 10 61 9 Q82 9 94 31"
fill="none"
stroke="#ffe9b8"
stroke-width="2.5"
stroke-linecap="round"
/>
`,jd=[{y:12,x:44,count:4},{y:20,x:36,count:6},{y:28,x:28,count:8},{y:36,x:20,count:10},{y:44,x:16,count:11},{y:52,x:16,count:11},{y:60,x:16,count:11},{y:68,x:20,count:10},{y:76,x:24,count:9},{y:84,x:32,count:7},{y:92,x:44,count:4}],Md=j`
<g class="lob-notexture" shape-rendering="crispEdges">
${jd.flatMap((e,t)=>Array.from({length:e.count},(n,r)=>j`<rect
x=${e.x+r*8}
y=${e.y}
width="8"
height="8"
fill=${(t+r)%2==0?`#ff00dc`:`#111111`}
/>`))}
</g>
`,Nd=j`
<g class="lob-chimera-stitches" fill="none" stroke="#4a3f3a" stroke-width="1.8" stroke-linecap="round">
<path d="M18 47 L27 50 M19 51 L22 46 M23 53 L26 48" />
<path d="M93 50 L102 47 M94 48 L97 53 M98 46 L101 51" />
</g>
`})))()}function Fd(e){let t=(Math.round(e)%8+8)%8;if(t===0)return j`<g class="lob-selene-moon"><circle cx="60" cy="64" r="12" fill="#26304a" /><circle cx="60" cy="64" r="11" fill="none" stroke="#f4f7fc" stroke-width="1" /></g>`;if(t===4)return j`<g class="lob-selene-moon"><circle cx="60" cy="64" r="12" fill="#26304a" /><circle cx="60" cy="64" r="11" fill="#f4f7fc" /></g>`;let n=t<4?[-5,-9,-14][t-1]:[14,9,5][t-5];return j`
<g class="lob-selene-moon">
<circle cx="60" cy="64" r="12" fill="#26304a" />
<circle cx="60" cy="64" r="11" fill="#f4f7fc" />
<circle cx=${60+(n??0)} cy="64" r="11" fill="#26304a" />
</g>
`}function Id(e,t){return j`
<g class="lob-pixel-frame" shape-rendering="crispEdges">
<g class="lob-pixel-antennae" fill="#d84c3e">
<rect x="30" y="0" width="6" height="6" /><rect x="36" y="6" width="6" height="6" /><rect x="42" y="12" width="6" height="6" />
<rect x="84" y="0" width="6" height="6" /><rect x="78" y="6" width="6" height="6" /><rect x="72" y="12" width="6" height="6" />
</g>
<g class="lob-pixel-claws">
<path d="M18 42 H6 V48 H0 V60 H6 V66 H18 V60 H24 V48 H18 Z M6 48 H12 V60 H6 Z" fill="#d84c3e" />
<rect x="6" y="60" width="12" height="6" fill="#a83428" />
<path d="M102 42 H114 V48 H120 V60 H114 V66 H102 V60 H96 V48 H102 Z M108 48 H114 V60 H108 Z" fill="#d84c3e" />
<rect x="102" y="60" width="12" height="6" fill="#a83428" />
</g>
<!-- Main cells keep the palette variable so offline and mood-style tinting still read. -->
<g class="lob-pixel-body" fill="var(--lob-shell, #d84c3e)">
<rect x="42" y="12" width="36" height="6" /><rect x="36" y="18" width="48" height="6" />
<rect x="30" y="24" width="60" height="6" /><rect x="24" y="30" width="72" height="48" />
<rect x="30" y="78" width="60" height="12" /><rect x="36" y="90" width="48" height="6" />
<rect x="36" y="96" width="12" height="9" /><rect x="72" y="96" width="12" height="9" />
</g>
<g fill="#ef8f6a"><rect x="36" y="24" width="24" height="6" /><rect x="30" y="30" width="18" height="12" /><rect x="24" y="42" width="12" height="12" /></g>
<g fill="#a83428"><rect x="30" y="78" width="60" height="12" /><rect x="36" y="90" width="48" height="6" /><rect x="36" y="96" width="12" height="9" /><rect x="72" y="96" width="12" height="9" /></g>
<g class="lob-eye-open" style=${e}>
<rect x="42" y="30" width="6" height="6" fill="#0a1014" /><rect x="72" y="30" width="6" height="6" fill="#0a1014" />
<rect x="42" y="30" width="2.5" height="2.5" fill="#fff" /><rect x="72" y="30" width="2.5" height="2.5" fill="#fff" />
</g>
<g class="lob-eye-closed" style=${t} fill="#0a1014"><rect x="42" y="33" width="6" height="3" /><rect x="72" y="33" width="6" height="3" /></g>
</g>
`}function Ld(e){return j`
<g stroke="#0a1014" stroke-linecap="round" fill="none">
<path d="M37 24 L51 28" stroke-width="3.5" />
<path d="M69 28 L83 24" stroke-width="3.5" />
<path d=${e} stroke-width="3" />
</g>
`}function Rd(e){return j`
<svg class="lobster-bottle__svg" viewBox="0 0 48 44" aria-hidden="true">
<g transform="rotate(-16 24 30)">
<rect x="5" y="18" width="30" height="16" rx="7" fill="#7fc8b8" opacity="0.72" />
<rect x="33" y="22" width="9" height="8" rx="2.5" fill="#7fc8b8" opacity="0.72" />
${e?j`
<rect x="36" y="20" width="11" height="7" rx="1.5" fill="#f2e5c9" transform="rotate(-24 41 23)" />
<rect x="43" y="30" width="4.5" height="8" rx="1.6" fill="#8a5a2b" transform="rotate(38 45 34)" />
`:j`<rect x="41" y="21.5" width="5" height="9" rx="1.8" fill="#8a5a2b" />`}
<rect x="11" y="22" width="12" height="8" rx="1.5" fill="#f2e5c9" />
<path d="M13 24.5 L21 24.5 M13 27 L19 27" stroke="#b6a071" stroke-width="1" />
<ellipse cx="13" cy="20.5" rx="5" ry="2" fill="#ffffff" opacity="0.35" />
</g>
</svg>
`}var zd,Bd,Vd,Hd,Ud,Wd,Gd,Kd,qd,Jd,Yd,Xd,Zd,Qd,$d,ef,tf,nf,rf,af,of,sf,cf,lf,uf,df,ff,pf,mf,hf,gf,_f,vf,yf,bf,xf,Sf,Cf,wf,Tf,Ef,Df,Of,kf,Af,jf,Mf,Nf,Pf,Ff;function If(){return(If=e((()=>{A(),er(),Qn(),Pd(),zd={crown:gr.crown,sprout:j`
<g>
<path d="M60 12 Q58 4 63 1" stroke="#3f9d63" stroke-width="3" stroke-linecap="round" fill="none" />
<ellipse cx="67" cy="3" rx="5" ry="3" fill="#57c785" transform="rotate(-24 67 3)" />
</g>
`,patch:j`
<g>
<path d="M28 27 Q60 14 92 22" stroke="#101820" stroke-width="4" stroke-linecap="round" fill="none" />
<circle cx="75" cy="32" r="9" fill="#101820" />
</g>
`,santa:gr.santa,pumpkin:gr.pumpkin,party:gr.party,barnacle:j`
<g class="lob-barnacles">
<path d="M32 22 L36.5 13 L41 22 Z" fill="#cfd8de" />
<path d="M42 18 L45.5 11 L49 18 Z" fill="#b8c4cc" />
<path d="M27 26 L30 20.5 L33 26 Z" fill="#b8c4cc" />
<circle cx="36.5" cy="18.5" r="1.1" fill="#8a949d" />
<circle cx="45.5" cy="15" r="0.9" fill="#8a949d" />
</g>
`,monocle:j`
<g class="lob-monocle" fill="none" stroke="#f4b840">
<circle cx="75" cy="32" r="8.5" stroke-width="2.5" />
<path d="M81 39 Q85 48 80 56" stroke-width="1.5" />
</g>
`},Bd=j`
<g class="lob-freckles" fill="#ffffff" opacity="0.3">
<circle cx="42" cy="45" r="1.6" />
<circle cx="50" cy="41" r="1.2" />
<circle cx="70" cy="45" r="1.6" />
<circle cx="78" cy="41" r="1.2" />
<circle cx="55" cy="62" r="1.4" />
<circle cx="67" cy="66" r="1.2" />
</g>
`,Vd=j`
<g class="lob-lumen" fill="#7ef5dd">
<circle cx="36" cy="54" r="2.4" />
<circle cx="50" cy="66" r="2" />
<circle cx="66" cy="70" r="2.2" />
<circle cx="80" cy="60" r="2" />
<circle cx="88" cy="46" r="1.7" />
<circle cx="60" cy="86" r="1.7" />
</g>
`,Hd=j`
<g class="lob-magma" fill="none" stroke="#ff6a3d" stroke-width="2" stroke-linecap="round">
<path d="M40 44 L48 54 L42 66 L50 78" />
<path d="M74 40 L68 52 L78 64" />
<path d="M56 82 L62 90" />
</g>
`,Ud=j`
<g class="lob-oilsheen">
<ellipse cx="46" cy="60" rx="22" ry="11" fill="#7f77dd" opacity="0.3" transform="rotate(-14 46 60)" />
<ellipse cx="76" cy="74" rx="17" ry="8" fill="#1d9e75" opacity="0.28" transform="rotate(10 76 74)" />
</g>
`,Wd=j`
<g class="lob-aurora" fill="none" stroke-linecap="round">
<path class="lob-aurora__band1" d="M24 62 Q48 48 70 58 T102 54" stroke="#4ecfa6" stroke-width="6" opacity="0.5" />
<path class="lob-aurora__band2" d="M28 76 Q54 62 78 72 T100 68" stroke="#a184ec" stroke-width="5" opacity="0.45" />
</g>
`,Gd=j`
<g class="lob-nebula-stars">
<circle cx="38" cy="52" r="1" fill="#fff" />
<circle cx="52" cy="70" r="1.2" fill="#fff" />
<circle cx="84" cy="48" r="1.4" fill="#fff" />
<circle cx="66" cy="86" r="1" fill="#fff" />
<circle cx="72" cy="60" r="1.6" fill="#8be9fd" />
<circle cx="46" cy="40" r="1.4" fill="#ff9de2" />
<path class="lob-twinkle" d="M60 52 L61.5 55.5 L65 57 L61.5 58.5 L60 62 L58.5 58.5 L55 57 L58.5 55.5 Z" fill="#fff" />
</g>
`,Kd=j`
<g class="lob-glass-glints" fill="none" stroke="#ffffff" stroke-width="2.5" stroke-linecap="round" opacity="0.7">
<path d="M34 22 L28 32" />
<path d="M40 16 L37 22" />
</g>
`,qd=j`
<g class="lob-geode-facets">
<polygon points="70,34 80,30 78,44" fill="#9b6ff0" />
<polygon points="82,46 94,42 88,58" fill="#b48ef0" />
<polygon points="72,58 84,62 74,74" fill="#7a4fd0" />
<polygon points="86,68 96,64 90,80" fill="#9b6ff0" />
<circle class="lob-twinkle" cx="90" cy="50" r="1.8" fill="#fff" />
</g>
`,Jd=j`
<g class="lob-scanlines" stroke="#3fff7d" stroke-width="1" opacity="0.16">
<path d="M40 20 H80 M30 27 H90 M26 34 H94 M21 41 H99 M18 48 H102 M17 55 H103 M17 62 H103 M18 69 H102 M22 76 H98 M31 83 H89 M45 90 H75" />
</g>
`,Yd=j`
<g class="lob-glitch-ghosts">
<path d="M60 8 C32 8 16 32 16 52 C16 72 30 90 44 95 L44 104 L54 104 L54 96 C58 97.5 62 97.5 66 96 L66 104 L76 104 L76 95 C90 90 104 72 104 52 C104 32 88 8 60 8 Z" transform="translate(-3 0)" fill="#ff3355" opacity="0.4" />
<path d="M60 8 C32 8 16 32 16 52 C16 72 30 90 44 95 L44 104 L54 104 L54 96 C58 97.5 62 97.5 66 96 L66 104 L76 104 L76 95 C90 90 104 72 104 52 C104 32 88 8 60 8 Z" transform="translate(3 1)" fill="#22d3ee" opacity="0.4" />
</g>
`,Xd=j`
<g class="lob-blueprint" fill="none" stroke="#cfe3ff">
<path class="lob-bp-outline" d="M60 8 C32 8 16 32 16 52 C16 72 30 90 44 95 L44 104 L54 104 L54 96 C58 97.5 62 97.5 66 96 L66 104 L76 104 L76 95 C90 90 104 72 104 52 C104 32 88 8 60 8 Z" stroke-width="1.5" stroke-dasharray="5 3" />
<path d="M54 58 H66 M60 52 V64" stroke-width="1" opacity="0.7" />
<path d="M16 100 H104" stroke-width="1" stroke-dasharray="2 3" opacity="0.7" />
</g>
`,Zd=j`
<g class="lob-clawnstantine">
<path d="M18 48 Q60 62 102 48 L104 52 C104 72 90 90 76 95 Q60 98 44 95 C30 90 16 72 16 52 Z" fill="#4e296e" />
<path d="M28 61 Q30 72 39 78 M70 88 Q82 82 91 65" fill="none" stroke="#a576c4" stroke-width="1.6" stroke-linecap="round" />
<!-- The lower edge follows the shell contour so the sash wraps around it. -->
<path d="M81.5 45.5 C70 64 50 78 29.9 85.444 C32.971 88.632 36.349 91.249 39.814 93.121 C62 85 81 68 90.5 50.5 Z" fill="#e5bc62" />
<path d="M84 51 C73 68 57 80 39 87" fill="none" stroke="#fff0bc" stroke-width="1.6" stroke-linecap="round" />
<circle cx="85" cy="49" r="6" fill="#e5bc62" />
<circle cx="85" cy="49" r="3" fill="#58c8b5" />
<g class="lob-clawnstantine__laurel" fill="#e5bc62" stroke="#bd8a38" stroke-width="0.6">
<path d="M31 27 Q31 15 50 11 M89 27 Q89 15 70 11" fill="none" stroke="#e5bc62" stroke-width="2" />
<path d="M33 25 Q23 21 28 15 Q35 17 33 25 Z M37 19 Q28 13 34 9 Q41 12 37 19 Z M43 14 Q38 7 44 6 Q49 9 43 14 Z" />
<path d="M87 25 Q97 21 92 15 Q85 17 87 25 Z M83 19 Q92 13 86 9 Q79 12 83 19 Z M77 14 Q82 7 76 6 Q71 9 77 14 Z" />
</g>
</g>
`,Qd=j`
<g class="lob-clawiestardust">
<path d="M72 14 L57 49 L70 43 L51 89 L85 38 L72 44 L83 18 Z" fill="#4dc8eb" transform="translate(2.5 0)" />
<path d="M72 14 L57 49 L70 43 L51 89 L85 38 L72 44 L83 18 Z" fill="#e6393d" />
</g>
`,$d=j`
<path class="lob-microphone" d="M106 32 L112 34 L106 56 Q105 58 103 57 Q101 56 102 54 Z" fill="#343747" />
<path class="lob-microphone" d="M103 27 A7 7 0 1 1 117 27 A7 7 0 1 1 103 27 Z" fill="#666a80" />
<path class="lob-microphone" d="M106 23 L114 25 M105 27 L113 29" fill="none" stroke="#e7e7f0" stroke-width="1.5" stroke-linecap="round" />
`,ef=j`
<path class="lob-leonardodepinchy__brush" d="M107 32 L112 33 L106 57 Q104 59 102 56 Z" fill="#855233" />
<path class="lob-leonardodepinchy__brush" d="M106 27 L114 29 L112 36 L104 34 Z" fill="#b4b7b5" />
<path class="lob-leonardodepinchy__brush" d="M106 27 C105 21 110 18 111 11 C119 21 118 26 114 29 Z" fill="#e6c88e" />
<path class="lob-leonardodepinchy__brush" d="M111 11 Q114 16 115 18 Q111 21 108 22 Q110 16 111 11 Z" fill="#4a89b8" />
`,tf=j`
<path class="lob-telephone-receiver" d="M105 33 L112 34 L108 56 Q105 59 102 55 Z" fill="#4b3c30" />
<path class="lob-telephone-receiver" d="M102 29 C104 21 113 21 117 29 L117 34 Q109 39 101 34 Z" fill="#35312f" />
<path class="lob-telephone-receiver" d="M103 30 Q110 34 116 30" fill="none" stroke="#bc955c" stroke-width="2" stroke-linecap="round" />
<path class="lob-telephone-receiver" d="M105 56 Q101 63 108 65 Q115 67 110 71 Q106 74 112 77" fill="none" stroke="#574631" stroke-width="1.8" stroke-linecap="round" />
`,nf={taylorpinch:$d,shellvis:$d,leonardodepinchy:ef,alexandergrahamshell:tf},rf=j`
<g class="lob-taylorpinch">
<path d="M51 44 Q56 40 60 43 Q64 40 69 44 Q60 54 51 44 Z" fill="#c92e48" />
<path d="M16 52 Q37 50 60 62 Q83 50 104 52 C104 72 90 90 76 95 Q60 98 44 95 C30 90 16 72 16 52 Z" fill="#9c82cf" />
<path d="M22 57 Q40 56 60 68 Q80 56 98 57" fill="none" stroke="#d5c4f2" stroke-width="2" stroke-linecap="round" />
<g fill="#fff4fb">
<path d="M36 65 L37.5 69.5 L42 71 L37.5 72.5 L36 77 L34.5 72.5 L30 71 L34.5 69.5 Z" />
<path d="M79 72 L80.5 76.5 L85 78 L80.5 79.5 L79 84 L77.5 79.5 L73 78 L77.5 76.5 Z" />
<circle cx="57" cy="79" r="1.5" /><circle cx="67" cy="88" r="1.5" /><circle cx="87" cy="64" r="1.5" />
</g>
</g>
`,af=j`
<g class="lob-clawtoodeetoo">
<path d="M27 26 C35 14 45 8 60 8 C75 8 85 14 93 26 Q60 19 27 26 Z" fill="#b8c3cf" />
<g fill="#2d5cbd">
<path d="M37 17 L46 12 L46 22 L34 24 Z M54 9 H66 L67 21 H53 Z M74 12 L84 17 L86 24 L74 22 Z" />
<path d="M20 46 Q60 42 100 46 L101 53 Q60 49 19 53 Z" />
<rect x="53" y="58" width="14" height="9" rx="1.5" />
<rect x="53" y="71" width="14" height="9" rx="1.5" />
</g>
<g fill="none" stroke="#9ba8b7" stroke-width="1.5">
<rect x="32" y="59" width="13" height="25" rx="2" /><rect x="75" y="59" width="13" height="25" rx="2" />
<path d="M54 86 H66 M54 90 H66" stroke-linecap="round" />
</g>
<circle cx="87" cy="49" r="2.5" fill="#ef5261" />
</g>
`,of=j`
<g class="lob-leonardodepinchy">
<path d="M18 48 Q60 61 102 48 L104 52 C104 72 90 90 76 95 Q60 98 44 95 C30 90 16 72 16 52 Z" fill="#5f6950" />
<path d="M60 63 V93 M27 64 Q31 77 40 84 M93 64 Q89 77 80 84" fill="none" stroke="#87906e" stroke-width="1.6" stroke-linecap="round" />
<path d="M40 42 Q60 52 80 42 Q78 58 60 66 Q42 58 40 42 Z" fill="#eee3ce" />
<path d="M52 49 Q60 54 68 49" fill="none" stroke="#c7b99e" stroke-width="1.5" stroke-linecap="round" />
<path d="M25 24 C29 9 51 5 67 8 C83 4 96 10 95 20 Q71 29 25 24 Z" fill="#49352c" />
<path d="M28 23 Q61 27 91 21" fill="none" stroke="#765545" stroke-width="2" stroke-linecap="round" />
<circle cx="38" cy="72" r="3" fill="#bd644f" /><circle cx="77" cy="81" r="3" fill="#4a89b8" /><circle cx="83" cy="65" r="2.5" fill="#dfb34f" />
</g>
`,sf=j`
<g class="lob-shellvis">
<path d="M18 48 L43 47 L60 62 L77 47 L102 48 L104 52 C104 72 90 90 76 95 Q60 98 44 95 C30 90 16 72 16 52 Z" fill="#fff7e9" />
<path d="M43 49 L48 66 L60 61 L72 66 L77 49 M26 80 Q60 87 94 80" fill="none" stroke="#d7ab4c" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
<path d="M53 46 L60 50 L67 46 L64 54 L72 74 L65 71 L59 56 L51 68 L48 63 L56 53 Z" fill="#c84248" />
<rect x="56" y="80" width="8" height="6" rx="1.5" fill="#d7ab4c" />
<path d="M24 26 Q21 10 41 9 Q42 1 62 5 C76 1 96 7 96 19 L91 29 Q82 21 77 20 Q59 31 43 21 Q34 21 24 26 Z" fill="#29272d" />
<path d="M35 17 Q50 10 61 13 Q75 8 85 15" fill="none" stroke="#4d4750" stroke-width="2" stroke-linecap="round" />
<path d="M25 27 L32 25 L32 42 L26 38 Z M88 25 L95 27 L94 38 L88 42 Z" fill="#29272d" />
</g>
`,cf=j`
<g class="lob-alexandergrahamshell">
<path d="M18 48 Q60 58 102 48 L104 52 C104 72 90 90 76 95 Q60 98 44 95 C30 90 16 72 16 52 Z" fill="#3d4b53" />
<path d="M37 47 L49 73 L60 63 L71 73 L83 47" fill="#f1ebdf" />
<path d="M35 61 L45 86 M85 61 L75 86" fill="none" stroke="#65747a" stroke-width="1.6" stroke-linecap="round" />
<path d="M28 29 Q25 18 35 15 L38 32 L32 42 Z M92 29 Q95 18 85 15 L82 32 L88 42 Z" fill="#c9ceca" />
<path d="M31 38 Q40 47 47 43 Q60 52 73 43 Q80 47 89 38 Q88 59 76 66 Q71 76 60 77 Q49 76 44 66 Q32 59 31 38 Z" fill="#dfe0dc" />
<path d="M51 52 Q60 57 69 52 M49 65 Q60 72 71 65" fill="none" stroke="#b8beba" stroke-width="1.5" stroke-linecap="round" />
<path d="M50 78 L60 81 L70 78 V86 L60 83 L50 86 Z" fill="#8f3347" />
<circle cx="60" cy="91" r="1.8" fill="#bc955c" />
</g>
`,lf=j`
<g class="lob-mecha">
<g fill="none" stroke="#5f6a75" stroke-width="1.5">
<path d="M28 56 Q60 66 92 56" />
<path d="M34 74 Q60 82 86 74" />
</g>
<g fill="#5f6a75">
<circle cx="36" cy="61" r="1.4" />
<circle cx="60" cy="64" r="1.4" />
<circle cx="84" cy="61" r="1.4" />
</g>
<circle class="lob-led" cx="89" cy="7" r="3" fill="#ff4444" />
</g>
`,uf=new Set(`split.retro.lumen.magma.oilslick.aurora.nebula.glass.geode.phosphor.heisenbug.blueprint.clawnstantine.clawiestardust.taylorpinch.clawtoodeetoo.leonardodepinchy.shellvis.alexandergrahamshell.clawtron.selene.pixel.banana.bee.rubberduck.watermelon.sourdough.zombie.plush.balloon.disco.cryptid.flatpack.tinfoil.actual.chimera.notexture.loading.eclipse.ascii.portal.invisible.goldenretro`.split(`.`)),df=j`
<g fill="#8a6430">
<rect x="56" y="8" width="8" height="6" rx="2.5" />
<ellipse cx="60" cy="91" rx="6" ry="3.5" />
<circle cx="37" cy="48" r="2.5" />
<circle cx="79" cy="55" r="2" />
<circle cx="47" cy="70" r="1.8" />
<circle cx="72" cy="79" r="2.3" />
</g>
`,ff=j`
<g class="lob-bee-wings" fill="#ffffff" opacity="0.45">
<ellipse cx="38" cy="14" rx="8" ry="4.5" transform="rotate(-24 38 14)" />
<ellipse cx="82" cy="14" rx="8" ry="4.5" transform="rotate(24 82 14)" />
</g>
<g fill="#2b2b23" opacity="0.9">
<path d="M19 42 Q60 51 101 42 L103 50 Q60 60 17 50 Z" />
<path d="M17 58 Q60 67 103 58 L101 67 Q60 76 19 67 Z" />
<path d="M24 76 Q60 84 96 76 L90 85 Q60 92 30 85 Z" />
</g>
`,pf=j`
<g>
<ellipse cx="60" cy="71" rx="21" ry="14" fill="#ffffff" opacity="0.5" />
<rect x="47" y="41" width="26" height="8" rx="4" fill="#ff9a2e" />
<rect x="50" y="47" width="20" height="5" rx="2.5" fill="#e98322" />
</g>
`,mf=j`
<g fill="none" stroke="#a8763e" stroke-width="2.5" stroke-linecap="round">
<path d="M38 23 Q45 29 52 30" />
<path d="M52 17 Q59 24 66 25" />
<path d="M67 18 Q74 24 81 25" />
</g>
<g fill="#ffffff" opacity="0.5">
<circle cx="34" cy="39" r="1.2" /><circle cx="86" cy="38" r="1" />
<circle cx="45" cy="57" r="1.4" /><circle cx="74" cy="62" r="1.1" />
<circle cx="56" cy="78" r="1" /><circle cx="83" cy="75" r="1.3" />
</g>
`,hf=j`
<g fill="none" stroke="#5a6b52" stroke-width="2" stroke-linecap="round">
<path d="M32 24 Q47 19 61 23" />
<path d="M38 19 L40 26 M46 18 L47 25 M54 19 L53 26" />
<path d="M57 72 Q72 78 87 72" />
<path d="M65 72 L63 79 M73 73 L72 80 M81 71 L83 78" />
</g>
<ellipse cx="35" cy="61" rx="9" ry="6" fill="#86987a" opacity="0.8" transform="rotate(-18 35 61)" />
`,gf=j`
<g fill="none" stroke="#c97a5e" stroke-width="1.5" stroke-dasharray="3 3">
<path d="M30 32 Q60 4 90 32" />
<path d="M60 50 Q58 72 60 96" />
</g>
<g class="lob-plush-button">
<circle cx="78" cy="44" r="3.5" fill="#7a4a3a" />
<circle cx="76.8" cy="44" r="0.7" fill="#e8967a" />
<circle cx="79.2" cy="44" r="0.7" fill="#e8967a" />
</g>
`,_f=j`
<g class="lob-disco" fill="#ffffff">
<rect x="42" y="18" width="4" height="4" opacity="0.3" /><rect x="52" y="16" width="4" height="4" opacity="0.5" />
<rect x="63" y="17" width="4" height="4" opacity="0.25" /><rect x="74" y="20" width="4" height="4" opacity="0.4" />
<rect x="31" y="40" width="4" height="4" opacity="0.4" /><rect x="53" y="39" width="4" height="4" opacity="0.25" />
<rect x="65" y="42" width="4" height="4" opacity="0.5" /><rect x="86" y="40" width="4" height="4" opacity="0.3" />
<rect x="39" y="59" width="4" height="4" opacity="0.25" /><rect x="51" y="62" width="4" height="4" opacity="0.45" />
<rect x="68" y="60" width="4" height="4" opacity="0.3" /><rect x="80" y="58" width="4" height="4" opacity="0.5" />
<rect x="49" y="79" width="4" height="4" opacity="0.35" /><rect x="70" y="80" width="4" height="4" opacity="0.25" />
</g>
`,vf={lumen:Vd,magma:Hd,oilslick:Ud,aurora:Wd,nebula:Gd,glass:Kd,geode:qd,phosphor:Jd,blueprint:Xd,clawnstantine:Zd,clawiestardust:Qd,taylorpinch:rf,clawtoodeetoo:af,leonardodepinchy:of,shellvis:sf,alexandergrahamshell:cf,clawtron:lf,banana:df,bee:ff,rubberduck:pf,sourdough:mf,zombie:hf,plush:gf,disco:_f,watermelon:kd,eclipse:Ad,notexture:Md,chimera:Nd},yf=j`
<path
class="lob-split-half"
d="M60 8 C88 8 104 32 104 52 C104 72 90 90 76 95 L76 104 L66 104 L66 96 C64 96.8 62 97.1 60 97.1 L60 8 Z"
fill="var(--lob-shell2, #46536b)"
/>
`,bf=j`
<path
d="M95 55 C112 53 119 39 116 25 C113 11 99 5 91 12 C88 15 87 19 88 23 C83 27 83 36 88 43 C91 49 93 52 95 55 Z"
fill="var(--lob-claw)"
/>
<path
d="M92 14 C97 22 99 31 95 41"
class="lob-retro-claw-line"
stroke="#b8151b"
stroke-width="3"
stroke-linecap="round"
fill="none"
/>
`,xf=j`
<g class="lob-antennae" stroke="var(--lob-shell)" stroke-width="4" stroke-linecap="round" fill="none">
<path d="M50 16 Q45 4 37 1" />
<path d="M70 16 Q75 4 83 1" />
</g>
`,Sf=Ld(`M49 45 Q59 51 69 45 L72 42`),Cf=j`
<g class="lob-tail">
<ellipse cx="16" cy="84" rx="11" ry="7" transform="rotate(-32 16 84)" />
<ellipse cx="104" cy="84" rx="11" ry="7" transform="rotate(32 104 84)" />
</g>
`,wf=j`
<g class="lob-bindle">
<path d="M70 62 L99 30" stroke="#8a5a2b" stroke-width="3.5" stroke-linecap="round" />
<circle cx="101" cy="27" r="9.5" fill="#e8b04b" />
<circle cx="98" cy="24" r="1.6" fill="#b6791f" />
<circle cx="104" cy="29" r="1.6" fill="#b6791f" />
<circle cx="100" cy="32" r="1.3" fill="#b6791f" />
</g>
`,Tf=new Set([`crown`,`sprout`,`santa`,`pumpkin`,`party`]),Ef=j`
<g class="lob-cap">
<path d="M46 10 Q60 -3 74 10 L74 13 Q60 7 46 13 Z" fill="#f5f7fa" />
<path d="M45 12 Q60 6 75 12 L75 16 Q60 10.5 45 16 Z" fill="#dfe7ee" />
<circle cx="60" cy="2.5" r="1.8" fill="#3b6ea5" />
</g>
`,Df=Ld(`M50 48 Q60 42 70 48`),Of={perky:j`
<g class="lob-antennae" stroke="var(--lob-shell)" stroke-width="4" stroke-linecap="round" fill="none">
<path d="M46 14 Q38 4 31 7" />
<path d="M74 14 Q82 4 89 7" />
</g>
`,droopy:j`
<g class="lob-antennae" stroke="var(--lob-shell)" stroke-width="4" stroke-linecap="round" fill="none">
<path d="M46 14 Q36 8 34 18" />
<path d="M74 14 Q84 8 86 18" />
</g>
`},kf=tr(j`
<g stroke="#a63a2e" stroke-width="4" stroke-linecap="round" fill="none">
<path d="M22 78 L8 88" />
<path d="M28 88 L16 99" />
<path d="M98 78 L112 88" />
<path d="M92 88 L104 99" />
</g>
<g stroke="#c44536" stroke-width="3.5" stroke-linecap="round" fill="none">
<path d="M44 38 L40 24" />
<path d="M76 38 L80 24" />
</g>
<circle cx="40" cy="22" r="4.5" fill="#0a1014" />
<circle cx="80" cy="22" r="4.5" fill="#0a1014" />
<circle cx="41.5" cy="20.5" r="1.8" fill="#ffd166" />
<circle cx="81.5" cy="20.5" r="1.8" fill="#ffd166" />
<ellipse cx="60" cy="70" rx="46" ry="30" fill="#c44536" />
<ellipse cx="48" cy="60" rx="16" ry="9" fill="#ffffff" opacity="0.1" />
<path
d="M16 58 C2 52 -2 62 4 72 C10 82 20 76 24 66 C26 60 22 58 16 58 Z"
fill="#d95f4b"
/>
<path
d="M104 58 C118 52 122 62 116 72 C110 82 100 76 96 66 C94 60 98 58 104 58 Z"
fill="#d95f4b"
/>
<path d="M48 82 Q60 90 72 82" stroke="#7e2a20" stroke-width="3" stroke-linecap="round" fill="none" />
`),Af=tr(j`
<path
d="M14 96 Q32 84 58 88 L96 88 Q110 90 112 97 Q112 103 102 103 L24 103 Q14 103 14 96 Z"
fill="#c9a06a"
/>
<g stroke="#c9a06a" stroke-width="3.5" stroke-linecap="round" fill="none">
<path d="M94 88 Q96 76 91 68" />
<path d="M103 88 Q107 76 103 66" />
</g>
<circle cx="90" cy="65" r="3.6" fill="#0a1014" />
<circle cx="103" cy="63" r="3.6" fill="#0a1014" />
<circle cx="91" cy="64" r="1.3" fill="#ffd166" />
<circle cx="104" cy="62" r="1.3" fill="#ffd166" />
<circle cx="50" cy="62" r="27" fill="#8a5a2b" />
<path
d="M50 41 a21 21 0 1 1 -15 36 a14 14 0 1 0 11 -25 a8 8 0 1 0 4 14"
stroke="#5f3d1c"
stroke-width="4"
stroke-linecap="round"
fill="none"
/>
`),jf=tr(j`
<path d="M30 82 Q20 74 27 65 Q30 76 40 79 Z" fill="#f0b52e" />
<ellipse cx="58" cy="85" rx="34" ry="17" fill="#ffd23e" />
<circle cx="82" cy="50" r="18" fill="#ffd23e" />
<path d="M98 49 Q112 52 99 59 Q95 56 95 51 Z" fill="#ff8c2e" />
<circle cx="86" cy="44" r="3.6" fill="#0a1014" />
<circle cx="87" cy="43" r="1.3" fill="#ffffff" />
<path d="M44 82 Q58 72 72 82 Q58 93 44 82 Z" fill="#f0b52e" opacity="0.75" />
`),Mf=tr(j`
<g class="lob-jelly-tentacles" stroke="#9f7dfa" stroke-width="2.5" stroke-linecap="round" fill="none" opacity="0.8">
<path d="M40 58 Q35 74 42 90" />
<path d="M54 61 Q52 78 57 96" />
<path d="M68 61 Q71 78 64 94" />
<path d="M80 58 Q85 72 78 88" />
</g>
<path
d="M30 52 C30 22 90 22 90 52 L90 58 Q82 52 75 58 Q67 52 60 58 Q52 52 45 58 Q38 52 30 58 Z"
fill="#b79bff"
opacity="0.78"
/>
<ellipse cx="47" cy="37" rx="12" ry="6" fill="#ffffff" opacity="0.25" />
<circle cx="52" cy="45" r="2.6" fill="#0a1014" />
<circle cx="66" cy="45" r="2.6" fill="#0a1014" />
`),Nf={crab:kf,snail:Af,duck:jf,jellyfish:Mf},Pf=j`
<svg class="lobster-pet__balloon" viewBox="0 0 40 62" aria-hidden="true">
<path d="M20 34 Q23 46 18 60" stroke="#8a949d" stroke-width="1.5" fill="none" />
<ellipse cx="20" cy="16" rx="13" ry="15" fill="#ff5c8a" />
<path d="M17 30 L20 34.5 L23 30 Z" fill="#e0446f" />
<ellipse cx="15" cy="10" rx="4" ry="6" fill="#ffffff" opacity="0.3" />
</svg>
`,Ff={stranger:`a stranger`,crab:`definitely a lobster`,snail:`in no particular hurry`,duck:`a duck. obviously`,jellyfish:`just drifting`}})))()}function Lf(e){let t=Yf.map(e=>vn(bd.find(t=>t.id===e),`chimera donor palette ${e}`)),n=()=>{let n=Math.floor(e()*t.length);return vn(t.splice(n,1)[0],`distinct chimera donor`)};return{body:n().shell,clawLeft:n().shell,clawRight:n().shell,antennae:n().shell}}function Rf(e){return{palette:e,scale:2,accessory:`none`,antennae:`perky`,spotPct:0,facing:1,personality:`friendly`,blinkDelayS:u(e.id)%36/10,clawSize:`regular`,tailFan:!1,shiny:!1,crusherSide:null,freckles:!1,glint:null,chimeraParts:e.id===`chimera`?Xf:null}}function zf(e){return e.getMonth()===Qf.month&&e.getDate()===Qf.day}function Bf(e){let t=e.getMonth(),n=e.getDate();return t===11?[[`santa`,18]]:t===9&&n>=20?[[`pumpkin`,18]]:t===8&&n===25?[[`monocle`,24]]:[]}function Vf(e,t){let n=ld(e.palette.id);return n===e.palette.id?ud(t):n}function X(e){let t=e>>>0;return()=>{t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function Hf(e,t){let n=t.reduce((e,[,t])=>e+t,0),r=e()*n;for(let[e,n]of t)if(r-=n,r<=0)return e;return vn(t.at(-1),`weighted lobster choice fallback`)[0]}function Z(e,t,n){return t+e()*(n-t)}function Uf(e,t=new Date){let n=X(e),r=Hf(n,yd),i=Hf(n,ep),a=Hf(n,[...Zf,...Bf(t)]),o=n()<.6?`perky`:`droopy`,s=n()<.5?`left`:`right`,c=ap[s],l=Math.round(Z(n,c[0],c[1])),u=n()<.5?1:-1,d=Hf(n,$f),f=Math.round(Z(n,0,4)*10)/10;n();let p=Hf(n,tp),m=n()<.3,h=n()<1/512,g=n(),_=n()<.5?`left`:`right`,v=g<.15?_:null,y=n()<.12,b=n(),x=rp[Math.floor(n()*rp.length)]??null,S=b<.3?x:null,ee=Lf(n),te={palette:r,scale:i,accessory:a,antennae:o,spotPct:l,facing:u,personality:d,blinkDelayS:f,clawSize:p,tailFan:m,shiny:h,crusherSide:v,freckles:y,glint:S,chimeraParts:r.id===`chimera`?ee:null},ne=r.id===`clawtron`?{...te,antennae:`perky`}:te;if(r.id===`zombie`&&(ne={...te,antennae:`droopy`}),zf(t)){let e=yd.find(([e])=>e.id===`retro`)?.[0];return{...ne,palette:e??r,accessory:`party`,chimeraParts:null}}return ne}function Wf(e,t={}){let n=e.palette.id===`flatpack`,r=Jf[e.palette.id],i=Kf.has(e.palette.id),a=t.shell?void 0:nf[e.palette.id],o=t.shell||t.sleeping&&!t.reading,s=o?`display:none`:``,c=o?`opacity:1`:t.standalone||t.reading?`display:none`:``,l=Math.round(hd(new Date)*8)%8;return j`
<svg
class="lobster-pet__svg"
viewBox="0 0 120 105"
preserveAspectRatio="xMidYMax meet"
aria-hidden="true"
>
<g class=${qf[e.palette.id]??``}>
${r?r(s,c):j`
${i?xf:Of[e.antennae]}
${e.tailFan?Cf:O}
<g class="lob-claw lob-claw--l">
<path d="M20 42 C5 37 0 47 5 57 C10 67 20 62 25 52 C28 45 25 42 20 42 Z" fill="var(--lob-claw)" />
</g>
${i?O:j`
<g class="lob-claw lob-claw--r">
${a??O}
<path d="M100 42 C115 37 120 47 115 57 C110 67 100 62 95 52 C92 45 95 42 100 42 Z" fill="var(--lob-claw)" />
</g>
`}
${e.palette.id===`heisenbug`?Yd:O}
<path class="lob-standard-dome" d="M60 8 C32 8 16 32 16 52 C16 72 30 90 44 95 L44 104 L54 104 L54 96 C58 97.5 62 97.5 66 96 L66 104 L76 104 L76 95 C90 90 104 72 104 52 C104 32 88 8 60 8 Z" fill="var(--lob-shell)" />
${e.palette.id===`split`||e.palette.id===`geode`?yf:O}
${e.palette.id===`selene`?Fd(l):O}
${vf[e.palette.id]??O}
${e.palette.id===`tinfoil`?Od(!Tf.has(e.accessory)):O}
${e.freckles&&!uf.has(e.palette.id)?Bd:O}
${e.palette.id===`invisible`?O:j`<ellipse cx="48" cy="28" rx="20" ry="11" fill="#ffffff" opacity="0.1" />`}
<g class="lob-eye-open" style=${s}>
<circle cx="45" cy="32" r="5.5" fill="#0a1014" />
<circle cx="75" cy="32" r="5.5" fill="#0a1014" />
<circle cx="46.5" cy="30.5" r="2.2" fill="var(--lob-glint, #00e5cc)" />
<circle cx="76.5" cy="30.5" r="2.2" fill="var(--lob-glint, #00e5cc)" />
</g>
${t.sleeping&&!t.reading?j`<g class="lob-eye-peek"><circle cx="45" cy="32" r="4" fill="#0a1014" /><circle cx="46" cy="30.8" r="1.6" fill="var(--lob-glint, #00e5cc)" /></g>`:O}
<g class="lob-eye-closed" stroke="#0a1014" stroke-width="3" stroke-linecap="round" fill="none" style=${c}>
<path d="M39 33 Q45 28 51 33" /><path d="M69 33 Q75 28 81 33" />
</g>
`}
${i?j`
${Sf}
<g class="lob-claw lob-claw--r">${bf}</g>
`:O}
${t.grumpy&&!i&&(!r||e.palette.id===`pixel`)?Df:O}
${e.accessory===`none`||t.shell||n?O:zd[e.accessory]}
${t.bindle&&!i&&!n&&!a?wf:O}
${t.sailorCap&&!t.shell&&!n&&!Tf.has(e.accessory)&&e.palette.id!==`tinfoil`?Ef:O}
${t.reading?ip:O}
</g>
</svg>
`}function Gf(e){let t=e.crusherSide,n=(u(e.palette.id)>>>8)%34/10,r=e.chimeraParts,i=r?bd.find(e=>e.shell===r.body)?.claw:void 0,a=n=>t===null?np[e.clawSize]:t===n?np.mighty:np.dainty;return[`--lob-shell:${e.chimeraParts?.body??e.palette.shell}`,`--lob-claw:${i??e.palette.claw}`,`--lob-blink-delay:${e.blinkDelayS}s`,`--lob-breathe-delay:-${n}s`,`--lob-claw-l:${a(`left`)}`,`--lob-claw-r:${a(`right`)}`,...e.chimeraParts?[`--lob-chimera-l:${e.chimeraParts.clawLeft}`,`--lob-chimera-r:${e.chimeraParts.clawRight}`,`--lob-antennae-color:${e.chimeraParts.antennae}`]:[],...e.glint?[`--lob-glint-seed:${e.glint}`]:[]].join(`;`)}var Kf,qf,Jf,Yf,Xf,Zf,Qf,$f,ep,tp,np,rp,ip,ap;function op(){return(op=e((()=>{Dn(),A(),md(),vd(),xd(),Pd(),If(),Kf=new Set([`retro`,`goldenretro`]),qf={heisenbug:`lob-heisenbug-frame`,cryptid:`lob-cryptid-frame`,balloon:`lob-balloon-frame`},Jf={flatpack:Sd,loading:Cd,actual:wd,balloon:Td,ascii:Ed,portal:Dd,pixel:Id},Yf=[`crimson`,`blue`,`gold`,`banana`,`watermelon`],Xf={body:`#ff4f40`,clawLeft:`#4a7dfc`,clawRight:`#f4b840`,antennae:`#3f9d63`},Zf=[[`none`,62],[`sprout`,14],[`patch`,14],[`crown`,10]],Qf={month:10,day:24},$f=[[`sleepy`,25],[`zoomy`,25],[`friendly`,25],[`showoff`,25]],ep=[[1.7,25],[2,55],[2.5,20]],tp=[[`regular`,55],[`dainty`,25],[`mighty`,20]],np={dainty:.85,regular:1,mighty:1.18},rp=[`#ffd166`,`#ff8ac2`,`#b79bff`],ip=j`
<g class="lob-reading-book" transform="translate(0 2)">
<path
d="M25 62 Q43 56 59 66 L59 92 Q43 82 25 86 Z M61 66 Q77 56 95 62 L95 86 Q77 82 61 92 Z"
fill="var(--lob-claw)"
stroke="color-mix(in srgb, var(--lob-claw) 72%, #0a1014)"
stroke-width="2.5"
stroke-linejoin="round"
/>
<path d="M29 62 Q44 58 59 68 L59 88 Q44 79 29 82 Z" fill="#fffaf0" />
<path d="M61 68 Q76 58 91 62 L91 82 Q76 79 61 88 Z" fill="#fffaf0" />
<path d="M60 67 L60 89" stroke="#d7cfc0" stroke-width="1.5" />
<g stroke="#b8b0a3" stroke-width="1.25" stroke-linecap="round" opacity="0.58">
<path d="M34 67 L51 71" /><path d="M34 72 L50 75" /><path d="M67 71 L85 67" />
<path d="M68 76 L85 72" /><path d="M70 80 L83 77" />
</g>
<path
class="lob-reading-book__page-glow"
d="M31 62 Q45 59 57 68 L57 72 Q44 65 31 67 Z"
fill="#ffffff"
opacity="0"
/>
</g>
`,ap={left:[12,38],right:[60,84]}})))()}function sp(e){let t=`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}`,n=2166136261;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619);return n>>>0}function cp(e){return sp(e)%16==3}function lp(e){return(u(e)^fp)>>>0}function up(e){let t=null;for(let n of e??[]){if(!n.status||n.status===`running`)continue;let e=n.endedAt??n.lastActivityAt??n.updatedAt??0;(!t||e>t.at)&&(t={at:e,outcome:n.status===`failed`||n.status===`timeout`?`error`:n.status===`killed`?`aborted`:`ok`})}return t?.outcome??`ok`}function dp(e,t){return e?t?.some(Fn)?`busy`:`idle`:`offline`}var fp;function pp(){return(pp=e((()=>{fp=Math.trunc(Math.random()*4294967295)})))()}function mp(e){let t=e.position;return t?k`
<wa-dropdown
class="session-menu lobster-pet-dismiss-menu"
.open=${!0}
placement="top-start"
.distance=${0}
aria-label=${w(`quickSettings.appearance.lobsterVisits`)}
@wa-select=${t=>{t.preventDefault(),t.detail.item.value===`dismiss`?e.onDismiss(!1):t.detail.item.value===`dismiss-permanently`&&e.onDismiss(!0)}}
@wa-after-hide=${e.onClose}
>
<button
slot="trigger"
type="button"
tabindex="-1"
aria-hidden="true"
aria-label=${w(`quickSettings.appearance.lobsterVisits`)}
style="position: fixed; left: ${t.x}px; top: ${t.y}px; width: 1px; height: 1px; opacity: 0; pointer-events: none;"
></button>
<wa-dropdown-item class="session-menu__item" value="dismiss"
>${w(`common.dismiss`)}</wa-dropdown-item
>
<wa-dropdown-item class="session-menu__item" value="dismiss-permanently"
>${w(`common.dismissAndDontShowAgain`)}</wa-dropdown-item
>
</wa-dropdown>
`:O}function hp(){return(hp=e((()=>{A(),d(),rr()})))()}function gp(e,t,n){let r=e;if(!t)return r;try{let e=window.AudioContext;if(!e)return r;r??=new e,r.state===`suspended`&&r.resume().catch(()=>{});let t=r.currentTime,i=r.createOscillator(),a=r.createGain(),o=n===`poke`;i.type=`sine`,i.frequency.setValueAtTime(o?330:392,t),i.frequency.exponentialRampToValueAtTime(o?165:523,t+(o?.09:.18)),a.gain.setValueAtTime(1e-4,t),a.gain.exponentialRampToValueAtTime(.05,t+.02),a.gain.exponentialRampToValueAtTime(1e-4,t+(o?.12:.24)),i.connect(a).connect(r.destination),i.start(t),i.stop(t+.26)}catch{}return r}function _p(){let e=gp(null,!0,`poke`);e&&window.setTimeout(()=>void e.close().catch(()=>{}),300)}function vp(){return(vp=e((()=>{})))()}function yp(e,t,n=new Date){return e===`busy`||e===`offline`?Fp[e]:Mp(n)?Pp.sleepy:t?Pp[t]:null}function bp(e){return e===`error`?`droop`:e===`aborted`?`startle`:`cheer`}function xp(e){return e<.06?`balloon`:e<.13?`bubble`:`walk`}function Sp(e){return X((e^12317)>>>0)()<.12}function Cp(e){return X((e^30485)>>>0)()<.04}function wp(e,t){return(Object.hasOwn(Lp,e)?Lp[e]:void 0)??t?.[e]?.crossMs??12e3}function Tp(e,{critters:t=[],strangers:n=!0}={}){let r=X((e^3243)>>>0),i=r()*1e3,a=[[`crab`,15],[`snail`,12],[`duck`,12],[`jellyfish`,11],...n?[[`stranger`,45]]:[],...t.map(e=>[e,20])],o=0,s=a.find(([,e])=>(o+=e,i<o))?.[0];return s?{kind:s,atMs:Math.round(2500+r()*6500),direction:r()<.5?1:-1,floor:r()<.55,hops:r()<.35&&s!==`snail`}:null}function Ep(e){return X((e^57811)>>>0)()<.015}function Dp(e,t){if(t.length===0)return null;let n=X((e^61982)>>>0);return n()>=.08?null:t[Math.floor(n()*t.length)]??null}function Op(e,t){let n=Gu(),r={elder:!1,oldFriend:!1,friendName:null,dexComplete:bd.every(e=>n.has(e.id)),look:t};if(Ep(e))return{...r,elder:!0,look:{...t,scale:3,accessory:`barnacle`,personality:`sleepy`,clawSize:`mighty`,crusherSide:null}};if(t.palette.id===`retro`||t.palette.id===`goldenretro`)return r;let i=Dp(e,[...n].filter(e=>bd.some(t=>t.id===e)).toSorted()),a=i?bd.find(e=>e.id===i):void 0;return a?{...r,oldFriend:!0,friendName:Ku().get(a.id)?.name??null,look:{...t,palette:a,chimeraParts:a.id===`chimera`?Rf(a).chimeraParts:null}}:r}function kp(e,t){return e.elder?`Methuselah`:e.friendName??Vf(e.look,t)}function Ap(e){let t=X((e^45175)>>>0);return t()>=.03?null:{atMs:Math.round(3500+t()*6500),spotPct:Math.round(15+t()*70),fortuneIndex:Math.floor(t()*Vp.length)}}function jp(e){try{let t=s();if(!t)return!1;let n=t.getItem(Hp);return n!==e&&(t.setItem(Hp,e),n!==null)}catch{return!1}}function Mp(e=new Date){let t=e.getHours();return t>=22||t<6}function Q(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var Np,Pp,Fp,Ip,Lp,Rp,zp,Bp,Vp,Hp;function Up(){return(Up=e((()=>{cd(),op(),xd(),ur(),Np={wave:1400,snip:1e3,hop:750,spin:950,peek:1700,nap:4400,bubble:2600,scuttle:1250,startle:750,cheer:1300,molt:2600,pet:1500,droop:1600,sweep:1800},Pp={sleepy:{delayMs:[6e3,12e3],acts:[[`nap`,40],[`bubble`,20],[`wave`,12],[`scuttle`,12],[`peek`,10],[`hop`,6]]},zoomy:{delayMs:[2800,6e3],acts:[[`scuttle`,42],[`hop`,22],[`spin`,12],[`peek`,12],[`wave`,12]]},friendly:{delayMs:[3600,7500],acts:[[`wave`,32],[`snip`,22],[`scuttle`,18],[`hop`,14],[`bubble`,14]]},showoff:{delayMs:[3600,7500],acts:[[`spin`,24],[`snip`,22],[`peek`,20],[`hop`,18],[`wave`,16]]}},Fp={busy:{delayMs:[2200,4500],acts:[[`scuttle`,40],[`hop`,20],[`snip`,20],[`wave`,12],[`spin`,8]]},offline:{delayMs:[2800,5600],acts:[[`scuttle`,55],[`peek`,30],[`hop`,15]]}},Ip={walk:450,balloon:1250,bubble:700},Lp={stranger:11e3,crab:11e3,snail:9e4,duck:14e3,jellyfish:16e3,...Jn},Rp=[1800,7500],zp=[9e4,3e5],Bp=[18e5,36e5],Vp=[`the tide returns every branch to shore`,`molt before you feel ready`,`a shell is just armor you outgrew`,`somewhere, a test is green because of you`,`swim sideways when forward fails`,`the reef remembers kind commits`,`even the deep keeps a night light`,`barnacles are only patient passengers`,`no current lasts forever`,`bury your treasure in version control`,`the crab was a lobster all along`,`small claws, firm grip`,`rest is also progress`,`what washes away was never pinned`],Hp=`openclaw.control.lobsterpet.gatewayVersion.v1`})))()}var Wp;function Gp(){return(Gp=e((()=>{Up(),Wp=class{constructor(e,t){this.host=e,this.hooks=t,this.grumpyTimer=null,this.holdTimer=null,this.audioCtx=null,this.pokeTimes=[],this.lastGazeAt=0,this.handleHoldStart=e=>{e.button!==0||Q()||(this.handleHoldCancel(),this.holdTimer=window.setTimeout(()=>{this.holdTimer=null,this.hooks.onGrumpyChange(!1),this.playChirp(`pet`),this.hooks.onAct(`pet`)},600))},this.handleHoldEnd=e=>{e.button===0&&this.holdTimer!==null&&(this.handleHoldCancel(),this.pokeNow())},this.handleHoldCancel=()=>{this.holdTimer!==null&&(window.clearTimeout(this.holdTimer),this.holdTimer=null)},this.handleGaze=e=>{if(!this.hooks.canGaze()||Q())return;let t=Date.now();if(t-this.lastGazeAt<120)return;this.lastGazeAt=t;let n=this.host.querySelector(`.lobster-pet:not(.lobster-pet--shell)`);if(!n)return;let r=n.getBoundingClientRect(),i=r.left+r.width/2;this.hooks.onFacing(e.clientX<i?-1:1)},e.addController(this)}hostConnected(){document.addEventListener(`pointermove`,this.handleGaze,{passive:!0})}hostDisconnected(){document.removeEventListener(`pointermove`,this.handleGaze),this.handleHoldCancel(),this.clearGrumpyTimer(),this.audioCtx&&=(this.audioCtx.close().catch(()=>{}),null)}suspend(){this.handleHoldCancel(),this.clearGrumpyTimer(),this.hooks.onGrumpyChange(!1)}playChirp(e){this.audioCtx=gp(this.audioCtx,this.hooks.soundsEnabled(),e)}pokeNow(){this.playChirp(`poke`);let e=Date.now();if(this.pokeTimes=[...this.pokeTimes.filter(t=>e-t<6e3),e],this.pokeTimes.length>=10&&this.hooks.canHuff()){this.huffOff();return}this.pokeTimes.length>=3&&this.enterGrumpy(),this.hooks.onAct(`startle`)}clearGrumpyTimer(){this.grumpyTimer!==null&&(window.clearTimeout(this.grumpyTimer),this.grumpyTimer=null)}enterGrumpy(){this.hooks.onGrumpyChange(!0),this.clearGrumpyTimer(),this.grumpyTimer=window.setTimeout(()=>{this.grumpyTimer=null,this.hooks.onGrumpyChange(!1)},6e4)}huffOff(){this.pokeTimes=[],this.hooks.onGrumpyChange(!1),this.hooks.onHuff()}}})))()}function Kp(e){return e.hop?1100:Math.max(850,Math.min(2600,Math.abs(e.to.x-e.from.x)*8))}function qp(e,t,n,r){let i=e,a=null;for(let e of n.toSorted((e,t)=>e.left-t.left)){let n=Math.min(t,e.left-r);n>i&&(!a||n-i>a[1]-a[0])&&(a=[i,n]),i=Math.max(i,e.right+r)}return t>i&&(!a||t-i>a[1]-a[0])&&(a=[i,t]),a}function Jp(e){let{composer:t,footer:n,editor:r}=e,i={top:null,floor:null,passage:null};if(t.width<=0||t.height<=0)return i;let a=Xp+(e.twins?28:0),o=qp(t.left+a,t.right-a,e.topObstacles.filter(e=>e.height>0&&e.bottom>t.top-Zp&&e.top<t.top),a),s=o?{start:o[0]-t.left,end:o[1]-t.left,y:0}:null;if(!n||n.height<=0)return{...i,top:s};let c=Math.min(t.bottom-8,n.bottom-5);if(c-48<(r?.bottom??t.top))return{...i,top:s};let l=qp(Math.max(t.left,n.left)+a,Math.min(t.right,n.right)-a,e.controls.filter(e=>e.width>0&&e.height>0&&e.top<c&&e.bottom>c-48),a),u=l&&l[1]-l[0]>=24?{start:l[0]-t.left,end:l[1]-t.left,y:c-t.top}:null,d=Math.max(s?.start??1/0,u?.start??1/0,e.placeholderRight-t.left+a),f=Math.min(s?.end??-1/0,u?.end??-1/0);return{top:s,floor:u,passage:f-d>=28?[d,f]:null}}function Yp(e,t){return{x:e?e.start+(e.end-e.start)*t/100:0,y:e?.y??0}}var Xp,Zp,Qp;function $p(){return($p=e((()=>{Xp=38,Zp=88,Qp=class{constructor(e,t){this.host=e,this.twins=t,this.scene={top:null,floor:null,passage:null},this.resize=null,this.mutation=null,this.active=!1,this.frame=null,this.observed=[],this.scheduleMeasure=()=>{this.active&&this.frame===null&&(this.frame=requestAnimationFrame(()=>this.measure()))},e.addController(this)}planWalk(e,t,n){let r=this.scene[e];if(!r)return null;let i=Math.round(n*100);return Math.abs(i-t)<4&&(i=t>50?0:100),{anchor:e,spotPct:i,facing:i<t?-1:1,travel:{from:Yp(r,t),to:Yp(r,i),hop:!1}}}planHop(e,t){let{passage:n,floor:r}=this.scene,i=this.scene[e];if(!n||!r||!i)return null;let a=Yp(i,t),o=(n[0]+n[1])/2;if(a.x<n[0]||a.x>n[1])return{anchor:e,spotPct:(o-i.start)/(i.end-i.start)*100,facing:o<a.x?-1:1,travel:{from:a,to:{x:o,y:i.y},hop:!1}};let s=e===`top`?`floor`:`top`,c=this.scene[s];if(!c)return null;let l=a.x<o?n[1]:n[0];return{anchor:s,spotPct:(l-c.start)/(c.end-c.start)*100,facing:l<a.x?-1:1,travel:{from:a,to:{x:l,y:c.y},hop:!0}}}hostConnected(){this.active=!0,typeof ResizeObserver<`u`?this.resize=new ResizeObserver(()=>this.measure()):window.addEventListener(`resize`,this.scheduleMeasure);let e=this.host.parentElement,t=e?.closest(`.new-session-page__draft`)??e;t&&(this.mutation=new MutationObserver(e=>{e.some(e=>e.target!==this.host&&!this.host.contains(e.target))&&this.scheduleMeasure()}),this.mutation.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`class`,`style`,`hidden`,`aria-label`]})),this.scheduleMeasure()}hostDisconnected(){this.active=!1,this.frame!==null&&(cancelAnimationFrame(this.frame),this.frame=null),this.resize?.disconnect(),this.resize=null,this.mutation?.disconnect(),this.mutation=null,this.observed=[],window.removeEventListener(`resize`,this.scheduleMeasure)}measure(){if(this.frame!==null&&(cancelAnimationFrame(this.frame),this.frame=null),!this.active||!this.host.isConnected)return;let e=this.host.parentElement;if(!e?.matches(`.agent-chat__input`))return;let t=e.querySelector(`.agent-chat__composer-footer`),n=e.querySelector(`textarea`),r=Array.from(t?.querySelectorAll(`.agent-chat__composer-lead, .chat-composer-model-control, .agent-chat__composer-actions, button, wa-button, [role=button]`)??[]),i=e.closest(`.new-session-page__draft`),a=Array.from(i?.querySelectorAll(`.new-session-page__triggers > *, .new-session-page__incognito-notice--visible`)??[]),o=[e,...r,...a,...t?[t]:[],...n?[n]:[]];if(o.length!==this.observed.length||o.some((e,t)=>e!==this.observed[t])){this.resize?.disconnect();for(let e of o)this.resize?.observe(e);this.observed=o}let s=n?.getBoundingClientRect()??null,c=s?.left??0;if(n&&s){let e=getComputedStyle(n),t=n.getAttribute(`aria-label`)??n.placeholder,r=Number.parseFloat(e.fontSize)||16,i=t.length*r*.65;if(typeof CanvasRenderingContext2D<`u`){let n=document.createElement(`canvas`).getContext(`2d`);n&&(n.font=e.font,i=n.measureText(t).width)}c+=Math.min(s.width,i+(Number.parseFloat(e.paddingLeft)||0))}let l=Jp({composer:e.getBoundingClientRect(),footer:t?.getBoundingClientRect()??null,controls:r.map(e=>e.getBoundingClientRect()),topObstacles:a.map(e=>e.getBoundingClientRect()),editor:s,placeholderRight:c,twins:this.twins()});this.host.toggleAttribute(`data-scene-ready`,l.top!==null),JSON.stringify(l)!==JSON.stringify(this.scene)&&(this.scene=l,this.host.requestUpdate())}}})))()}function em(e,t){for(let n=1;n<=24;n++){let r=Uf(e+n*7919>>>0);if(r.palette.id!==t)return r}return Uf(e+1>>>0)}function tm(e,t,n,r){return[Gf(e),`--lob-scale:${t}`,`--lob-x:${n}%`,`--lob-face:${r}`].join(`;`)}function nm(e){if(!e.scene.top)return O;let t=e.scene[e.anchor]??e.scene.top,n=n=>{let r=e.anniversary&&e.look.accessory!==`party`?{...e.look,accessory:`party`}:e.look,i=[`lobster-pet`,`lobster-pet--${e.mode}`,`lobster-pet--palette-${e.look.palette.id}`,n?`lobster-pet--twin`:``,r.accessory===`party`?`lobster-pet--party`:``,e.look.shiny?`lobster-pet--shiny`:``,e.elder?`lobster-pet--elder`:``,e.presence===`leaving`?`lobster-pet--away`:``,e.entering?`lobster-pet--entering`:``,e.entering&&e.entrance!==`walk`?`lobster-pet--enter-${e.entrance}`:``,e.grumpy?`lobster-pet--grumpy`:``,e.vigil?`lobster-pet--vigil`:``,e.act?`lobster-pet--act-${e.act}`:``].filter(Boolean).join(` `),a=Yp(t,e.spotPct);n&&(a.x=Math.max(t.start,Math.min(t.end,a.x-e.facing*28)));let o=n?e.look.scale*.55:e.look.scale,s=`${tm(e.look,o,e.spotPct,e.facing)};--lob-x:${a.x}px;--lob-y:${a.y}px${n?`;--lob-act-delay:0.18s`:``}`,c=e.travel,l=c?`--lob-from-x:${c.from.x-c.to.x}px;--lob-from-y:${c.from.y-c.to.y}px;--lob-travel-ms:${Kp(c)}ms${n?`;animation-delay:0.18s`:``}`:``,u=ed(e.familiarityVisits),d=e.nameOverride??Vf(e.look,e.seed),f=u?`${u} ${d}`:d,p=e.look.shiny?`✦ ${f}`:f,m=e.movingDay&&!n,h=n?`${p} Jr.`:m?`${p} · just moved in`:e.flavor?`${p} · ${e.flavor}`:p;return k`
<div
class="lobster-pet__motion ${c?c.hop?`lobster-pet__motion--hop`:`lobster-pet__motion--walk`:``}"
style=${l}
>
<div
class=${i}
style=${s}
aria-hidden="true"
title=${h}
@pointerdown=${e.onPointerDown}
@pointerup=${e.onPointerUp}
@pointercancel=${e.onPointerCancel}
@pointerleave=${e.onPointerCancel}
@contextmenu=${e.onContextMenu}
>
<div class="lobster-pet__body">
${Wf(r,{grumpy:e.grumpy,bindle:m,sailorCap:e.sailorDay})}
${e.entering&&e.entrance===`balloon`?Pf:O}
${e.entering&&e.entrance===`bubble`?k`<span class="lobster-pet__entry-bubble"></span>`:O}
${e.look.shiny?k`
<span class="lobster-pet__sparkle" style="--i:0;left:12%;bottom:64%">✦</span>
<span class="lobster-pet__sparkle" style="--i:1;left:76%;bottom:82%">✦</span>
`:O}
<span class="lobster-pet__z" style="--i:0">z</span>
<span class="lobster-pet__z" style="--i:1">z</span>
<span class="lobster-pet__z" style="--i:2">Z</span>
<span class="lobster-pet__bubble" style="--i:0"></span>
<span class="lobster-pet__bubble" style="--i:1"></span>
<span class="lobster-pet__bubble" style="--i:2"></span>
<span class="lobster-pet__heart">♥</span>
<svg class="lobster-pet__broom" viewBox="0 0 24 40" aria-hidden="true">
<path d="M12 2 L12 24" stroke="#8a5a2b" stroke-width="3" stroke-linecap="round" />
<path d="M6 24 L18 24 L21 38 L3 38 Z" fill="#e8b04b" />
<path
d="M7.5 28 L6.5 36 M12 28 L12 36 M16.5 28 L17.5 36"
stroke="#b6791f"
stroke-width="1.5"
/>
</svg>
</div>
</div>
</div>
`},r=e.residentEnabled&&e.presence!==`out`,i=e.residentEnabled&&e.shellVisible&&e.visitsEnabled&&!e.dismissed,a=e.passer&&!jn(e.passer.kind)?e.critterArtwork?.[e.passer.kind]:void 0,o=e.passer?.kind===`stranger`&&!a,s=e.passer!==null&&e.visitsEnabled&&(e.residentEnabled||!o)&&!e.dismissed&&(e.passer.anchor===`top`||e.floorEnabled&&e.scene.floor!==null),c=e.bottle!==null&&e.visitsEnabled&&!e.dismissed;if(!r&&!i&&!s&&!c)return O;let l=tm(e.look,e.shellScale,e.shellSpotPct,e.facing),u=Yp(e.scene[e.shellAnchor],e.shellSpotPct),d=o?em(e.seed,e.look.palette.id):e.look,f=e.passer?[`lobster-pet`,`lobster-pet--passer`,o?`lobster-pet--palette-${d.palette.id}`:`lobster-pet--${e.passer.kind}`,o&&d.shiny?`lobster-pet--shiny`:``,e.passer.direction===1?`lobster-pet--passer-ltr`:`lobster-pet--passer-rtl`,e.passer.hops&&e.scene.passage?`lobster-pet--passer-hop`:``].filter(Boolean).join(` `):``,p=e.passer?e.scene[e.passer.anchor]:null,m=e.passer?.hops&&e.scene.passage?e.scene.passage:[p?.start??0,p?.end??0],h=e.passer?.direction===1?m[0]:m[1],g=e.passer?.direction===1?m[1]:m[0],_=e.passer?`${rm(e.passer.kind,e.passer.direction,d,!!a)};--lob-cross:${e.passer.crossMs}ms;--lob-cross-from:${h}px;--lob-cross-to:${g}px;--lob-y:${p?.y??0}px`:``,v=e.passer&&Object.hasOwn(im,e.passer.kind)?im[e.passer.kind]:void 0,y=e.passer&&Object.hasOwn(am,e.passer.kind)?am[e.passer.kind]:void 0,b=Yp(e.scene.top,e.bottle?.spotPct??50);return k`
${i?k`
<div
class="lobster-pet lobster-pet--shell"
style=${`${l};--lob-x:${u.x}px;--lob-y:${u.y}px`}
aria-hidden="true"
>
<div class="lobster-pet__body">${Wf(e.look,{shell:!0})}</div>
</div>
`:O}
${c&&e.bottle?k`
<div
class="lobster-bottle ${e.bottle.opened?`lobster-bottle--open`:``}"
style="--lob-x:${b.x}px"
title=${e.bottle.opened?e.bottle.fortune:`a message in a bottle`}
aria-hidden="true"
@pointerdown=${e.onBottleOpen}
>
${Rd(e.bottle.opened)}
</div>
`:O}
${r?n(!1):O}
${r&&e.twinPlanned?n(!0):O}
${s&&e.passer?k`
<div
class=${f}
style=${_}
aria-hidden="true"
title=${(a?a.title:y)??e.passer.kind}
>
<div class="lobster-pet__body">
${a?or(a.url,`lobster-pet__svg`):o?Wf(d,{standalone:!0}):v??O}
</div>
</div>
`:O}
`}function rm(e,t,n,r){if(r)return`--lob-scale:1.8;--lob-w:1;--lob-h:1;--lob-face:${t}`;if(e===`stranger`)return tm(n,Math.min(n.scale,2),0,t);if(jn(e))return fr(e,t);let i={crab:`--lob-scale:2;--lob-w:1;--lob-h:0.82;--lob-face:1`,snail:`--lob-scale:1.7;--lob-w:1;--lob-h:0.9;--lob-face:${t}`,duck:`--lob-scale:1.9;--lob-w:1;--lob-h:1;--lob-face:${t}`,jellyfish:`--lob-scale:1.7;--lob-w:0.9;--lob-h:1.1;--lob-face:1`};return(Object.hasOwn(i,e)?i[e]:void 0)??`--lob-scale:1.8;--lob-w:1;--lob-h:1;--lob-face:${t}`}var im,am;function om(){return(om=e((()=>{A(),In(),cd(),op(),$p(),If(),pr(),ur(),im={...Nf,...dr},am={...Ff,...$n}})))()}var sm;function cm(){return(cm=e((()=>{Dn(),Up(),sm=class{constructor(e,t){this.host=e,this.hooks=t,this.passer=null,this.bottle=null,this.connected=!1,this.passerTimer=null,this.passerEndTimer=null,this.passerWatchTimer=null,this.seed=null,this.passerConsumed=!1,this.crossingMs=0,this.bottleTimer=null,this.bottleEndTimer=null,this.openBottle=()=>{this.bottle&&!this.bottle.opened&&(this.bottle={...this.bottle,opened:!0},this.armBottleEbb(12e4),this.host.requestUpdate())},e.addController(this)}hostConnected(){this.connected=!0}hostUpdate(){this.hooks.visitsEnabled()||(this.clearTimers(),this.passer=null,this.bottle=null)}hostDisconnected(){this.connected=!1,this.clearTimers(),this.passer=null,this.bottle=null,this.host.requestUpdate()}reset(e){e!==this.seed&&(this.seed=e,this.passerConsumed=!1),this.clearTimers(),this.passer=null,this.bottle=null,this.connected&&this.hooks.visitsEnabled()&&(this.schedulePasser(e),this.scheduleBottle(e))}replanPasser(e){let t=this.passer,n=this.hooks.passerOptions(),r=t&&[`stranger`,`crab`,`snail`,`duck`,`jellyfish`].includes(t.kind);if(t&&(t.kind!==`stranger`||n.strangers!==!1||n.critters?.includes(t.kind))&&(r||n.critters?.includes(t.kind)))return;let i=this.passer!==null;this.clearPasserTimers(),this.passer=null,i&&this.hooks.onPasserDone(),this.connected&&this.hooks.visitsEnabled()&&this.schedulePasser(e)}passerCrossMs(){return this.passer?this.crossingMs:0}clearTimers(){this.clearPasserTimers();for(let e of[this.bottleTimer,this.bottleEndTimer])e!==null&&window.clearTimeout(e);this.bottleTimer=null,this.bottleEndTimer=null}clearPasserTimers(){for(let e of[this.passerTimer,this.passerEndTimer,this.passerWatchTimer])e!==null&&window.clearTimeout(e);this.passerTimer=null,this.passerEndTimer=null,this.passerWatchTimer=null}schedulePasser(e){if(this.passerConsumed)return;let t=Tp(e,this.hooks.passerOptions());t&&!Q()&&(this.passerTimer=window.setTimeout(()=>{if(this.passerTimer=null,this.passerConsumed=!0,!this.connected||!this.hooks.visitsEnabled()||document.hidden||Q())return;this.hooks.onPasserStart(t),this.passer=t,this.crossingMs=wp(t.kind,this.hooks.passerOptions().critterArtwork),this.host.requestUpdate();let e=this.passerCrossMs();this.hooks.onPasserFacing(t.direction===1?-1:1),this.passerWatchTimer=window.setTimeout(()=>{this.passerWatchTimer=null,this.hooks.onPasserFacing(t.direction),this.hooks.onPasserMidCross()},e/2),this.passerEndTimer=window.setTimeout(()=>{this.passerEndTimer=null,this.passer=null,this.host.requestUpdate(),this.hooks.onPasserDone()},e)},t.atMs))}scheduleBottle(e){let t=Ap(e);t&&(this.bottleTimer=window.setTimeout(()=>{this.bottleTimer=null,this.connected&&this.hooks.visitsEnabled()&&(this.bottle={spotPct:t.spotPct,opened:!1,fortune:vn(Vp[t.fortuneIndex],`lobster bottle fortune`)},this.host.requestUpdate(),this.armBottleEbb(3e5))},t.atMs))}armBottleEbb(e){this.bottleEndTimer!==null&&window.clearTimeout(this.bottleEndTimer),this.bottleEndTimer=window.setTimeout(()=>{this.bottleEndTimer=null,this.bottle=null,this.host.requestUpdate()},e)}}})))()}var lm=t({}),$;function um(){return(um=e((()=>{A(),gt(),nt(),cd(),pp(),hp(),Gp(),op(),Up(),om(),$p(),cm(),$=class extends On{constructor(...e){super(...e),this.seed=0,this.mode=`idle`,this.visitsEnabled=!0,this.residentEnabled=!0,this.floorEnabled=!1,this.runOutcome=`ok`,this.soundsEnabled=!1,this.gatewayVersion=null,this.onVisitsDisabled=()=>void 0,this.act=null,this.spotPct=80,this.facing=1,this.entering=!1,this.entrance=`walk`,this.presence=`out`,this.anchor=`top`,this.geometry=new Qp(this,()=>this.residentEnabled&&this.twinPlanned),this.travel=null,this.travelScene=this.geometry.scene,this.motionRng=X(0),this.passerAnchor=`top`,this.passerHops=!1,this.shellAnchor=`top`,this.scheduledVisiting=!1,this.dismissed=!1,this.dismissMenuPosition=null,this.grumpy=!1,this.vigil=!1,this.outcomePresenceOwner=null,this.movingDay=!1,this.movingDayChecked=!1,this.anniversary=!1,this.sailorDay=!1,this.identity=null,this.entranceRng=X(0),this.traffic=new sm(this,{visitsEnabled:()=>this.visitsEnabled&&!this.dismissed,passerOptions:()=>({critters:this.critters,strangers:this.residentEnabled,critterArtwork:this.critterArtwork}),onPasserStart:e=>{this.passerAnchor=e.floor&&this.floorEnabled&&this.geometry.scene.floor?`floor`:`top`,this.passerHops=this.passerAnchor===`floor`&&e.hops&&this.geometry.scene.passage!==null},onPasserFacing:e=>this.watchTraffic(e),onPasserMidCross:()=>this.reactToPasser(),onPasserDone:()=>this.scheduleNextAct()}),this.interactions=new Wp(this,{soundsEnabled:()=>this.soundsEnabled,canHuff:()=>this.mode!==`offline`,canGaze:()=>this.presence===`in`&&this.act===null&&!this.vigil,onGrumpyChange:e=>{this.grumpy=e},onAct:e=>this.performAct(e),onFacing:e=>{this.facing=e},onHuff:()=>{this.clearTimers(`visitTimer`,`leaveTimer`),this.scheduledVisiting=!1,this.armArrival(Z(this.visitRng,Bp[0],Bp[1]))}}),this.shellVisible=!1,this.shellSpotPct=50,this.shellScale=2,this.molted=!1,this.moltPlanned=!1,this.twinPlanned=!1,this.shellTimer=null,this.familiarity={tier:`regular`,wary:!1,visits:0,shoos:0},this.greetedThisLoad=!1,this.look=null,this.rng=X(0),this.visitRng=X(0),this.idleTimer=null,this.actEndTimer=null,this.enterTimer=null,this.visitTimer=null,this.leaveTimer=null,this.vigilTimer=null,this.restartPending=!1,this.handleVisibilityChange=()=>{document.hidden?(this.outcomePresenceOwner=null,this.clearActTimers(),this.act=null):this.scheduleNextAct()},this.openDismissMenu=e=>{this.residentEnabled&&this.visitsEnabled&&(e.preventDefault(),e.stopPropagation(),this.interactions.handleHoldCancel(),this.dismissMenuPosition={x:e.clientX,y:e.clientY})}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.hasUpdated&&(this.look=null,this.requestUpdate()),document.addEventListener(`visibilitychange`,this.handleVisibilityChange)}disconnectedCallback(){document.removeEventListener(`visibilitychange`,this.handleVisibilityChange),this.clearActTimers(),this.clearTimers(`visitTimer`,`leaveTimer`),this.restartPending=!1,this.scheduledVisiting=!1,this.presence=`out`,this.act=null,this.clearTimers(`shellTimer`,`vigilTimer`),super.disconnectedCallback()}wantsVisible(){return this.visitsEnabled&&this.residentEnabled&&!this.dismissed&&(this.mode===`offline`||this.vigil||this.outcomePresenceOwner!==null||this.scheduledVisiting)}willUpdate(e){if(!this.isConnected)return;let t=this.look===null||e.has(`seed`);if(t)this.look=Uf(this.seed),this.rng=X(this.seed^2654435769),this.motionRng=X(this.seed^987138),this.visitRng=X(this.seed^99282957),this.entranceRng=X((this.seed^57978)>>>0),this.identity=Op(this.seed,this.look),this.look=this.identity.look,this.spotPct=this.look.spotPct,this.facing=this.look.facing,this.clearActTimers(),this.act=null,this.dismissed=!1,this.dismissMenuPosition=null,this.presence=`out`,this.molted=!1,this.shellVisible=!1,this.clearTimers(`shellTimer`),this.moltPlanned=Sp(this.seed)&&!this.identity.elder,this.twinPlanned=Cp(this.seed),this.geometry.scheduleMeasure(),this.familiarity=$u(),this.sailorDay=cp(new Date),this.greetedThisLoad=!1,this.scheduleVisits(),this.traffic.reset(this.seed),this.vigil=!1,this.outcomePresenceOwner=null,this.trackVigil();else if(e.has(`mode`)){let t=e.get(`mode`)===`busy`&&this.mode===`idle`,n=t&&this.vigil?`vigil`:null;if(this.trackVigil(),this.presence===`in`&&!Q()){let e=bp(this.runOutcome);this.performAct(t?e:`startle`,n)}}(e.has(`visitsEnabled`)||e.has(`residentEnabled`))&&(this.visitsEnabled&&e.get(`visitsEnabled`)===!1&&(this.dismissed=!1,this.traffic.reset(this.seed)),!this.visitsEnabled||!this.residentEnabled?this.suspendResident():(e.get(`visitsEnabled`)===!1||e.get(`residentEnabled`)===!1)&&(this.scheduleVisits(),this.trackVigil()));let n=e.get(`critters`)??[],r=this.critters??[],i=e.has(`critters`)&&(n.length!==r.length||n.some((e,t)=>e!==r[t]));!t&&(e.has(`residentEnabled`)||i)&&(this.traffic.replanPasser(this.seed),this.geometry.scheduleMeasure()),this.residentEnabled&&!this.movingDayChecked&&this.gatewayVersion&&(this.movingDayChecked=!0,this.movingDay=jp(this.gatewayVersion)),this.toggleAttribute(`data-dex-complete`,(this.identity?.dexComplete??!1)&&this.visitsEnabled&&this.residentEnabled&&!this.dismissed),((!this.floorEnabled||!this.geometry.scene.floor)&&this.anchor===`floor`||this.travel&&this.travelScene!==this.geometry.scene)&&(this.clearActTimers(),this.act=null,this.anchor=`top`,this.restartPending=this.presence===`in`),this.setAttribute(`data-spot`,this.anchor),this.toggleAttribute(`data-floor-enabled`,this.floorEnabled),this.reconcilePresence()}reconcilePresence(){let e=this.wantsVisible();if(e&&this.presence!==`in`){this.clearTimers(`leaveTimer`),this.presence===`out`&&(this.rollPerch(),this.entrance=xp(this.entranceRng()),this.look&&(this.anniversary=td(Ku().get(this.look.palette.id)?.firstSeenAt??null,new Date),Ju(this.look.palette.id,{name:this.identity?kp(this.identity,this.seed):Vf(this.look,this.seed),shiny:this.look.shiny}),Zu())),this.presence=`in`,this.entering=!Q(),this.restartPending=!0;return}!e&&this.presence===`in`&&(this.dismissMenuPosition=null,this.outcomePresenceOwner=null,this.clearActTimers(),this.act=null,this.entering=!1,this.presence=`leaving`,this.leaveTimer=window.setTimeout(()=>{this.leaveTimer=null,this.presence=`out`},350))}updated(){this.isConnected&&this.restartPending&&(this.restartPending=!1,this.enterTimer=window.setTimeout(()=>{this.enterTimer=null,this.entering=!1,!this.greetedThisLoad&&(this.familiarity.tier===`friend`||this.identity?.oldFriend===!0)&&this.presence===`in`&&!Q()&&(this.greetedThisLoad=!0,this.performAct(`wave`))},Ip[this.entrance]),this.scheduleNextAct())}trackVigil(){this.clearTimers(`vigilTimer`),this.mode===`busy`&&this.visitsEnabled&&this.residentEnabled&&!this.dismissed?this.vigilTimer=window.setTimeout(()=>{this.vigilTimer=null,this.vigil=!0,this.clearActTimers(),this.act=null},6e5):this.vigil=!1}dismiss(e){this.dismissMenuPosition=null,this.dismissed=!0,Qu(),e&&(this.visitsEnabled=!1,dt({lobsterPetVisits:!1}),this.onVisitsDisabled())}clearActTimers(){this.travel=null,this.clearTimers(`idleTimer`,`actEndTimer`,`enterTimer`)}clearTimers(...e){for(let t of e){let e=this[t];e!==null&&(window.clearTimeout(e),this[t]=null)}}suspendResident(){this.clearActTimers(),this.clearTimers(`visitTimer`,`leaveTimer`),this.interactions.suspend(),this.clearTimers(`shellTimer`,`vigilTimer`),this.shellVisible=!1,this.vigil=!1,this.outcomePresenceOwner=null,this.dismissMenuPosition=null,this.scheduledVisiting=!1,this.presence=`out`,this.act=null,this.entering=!1,this.restartPending=!1}scheduleVisits(){if(this.clearTimers(`visitTimer`,`leaveTimer`),this.scheduledVisiting=!1,!this.visitsEnabled||!this.residentEnabled||this.visitRng()<.5)return;let e=ad[this.familiarity.tier];this.armArrival(Z(this.visitRng,Rp[0],Rp[1])*e.firstDelayMul)}armArrival(e){this.isConnected&&this.visitsEnabled&&this.residentEnabled&&(this.visitTimer=window.setTimeout(()=>{this.visitTimer=null,this.scheduledVisiting=!0,this.armDeparture(Z(this.visitRng,zp[0],zp[1])*ad[this.familiarity.tier].stayMul)},e))}armDeparture(e){this.visitTimer=window.setTimeout(()=>{this.visitTimer=null,this.scheduledVisiting=!1;let e=ad[this.familiarity.tier],t=this.familiarity.wary?ad.waryGapMul:1;this.armArrival(Z(this.visitRng,Bp[0],Bp[1])*e.gapMul*t)},e)}watchTraffic(e){this.presence===`in`&&this.act!==`scuttle`&&!this.vigil&&(this.facing=e)}reactToPasser(){let e=this.familiarity.tier===`friend`?`wave`:this.familiarity.tier===`shy`?`peek`:null;e===null||this.presence!==`in`||this.act!==null||this.vigil||this.mode!==`idle`||Q()||this.performAct(e)}rollPerch(){this.anchor=`top`,this.spotPct=Math.round(Z(this.visitRng,12,88)),this.facing=this.visitRng()<.5?1:-1}scheduleNextAct(){if(!this.isConnected||!this.visitsEnabled||!this.residentEnabled||!this.look||this.presence!==`in`||this.vigil||this.traffic.passer!==null||this.idleTimer!==null||this.actEndTimer!==null||Q())return;let e=yp(this.mode,this.look.personality);if(!e)return;let t=Z(this.rng,e.delayMs[0],e.delayMs[1]);this.idleTimer=window.setTimeout(()=>{this.idleTimer=null;let e=yp(this.mode,this.look?.personality??null);if(e&&!document.hidden&&this.presence===`in`&&this.traffic.passer===null){if(this.moltPlanned&&!this.molted&&this.mode===`idle`){this.performAct(`molt`);return}this.performAct(Hf(this.rng,e.acts))}},t)}performAct(e,t=null){if(!this.visitsEnabled||!this.residentEnabled||this.presence!==`in`)return;this.clearActTimers(),this.outcomePresenceOwner=t,this.entering=!1,e===`hop`?this.startFloorHop():e===`scuttle`&&this.applyMove(this.geometry.planWalk(this.anchor,this.spotPct,this.rng()));let n=this.travel?Kp(this.travel):Np[e];this.act=this.travel&&!this.travel.hop?`scuttle`:e,this.actEndTimer=window.setTimeout(()=>{if(this.actEndTimer=null,this.act=null,this.travel=null,e===`molt`&&this.completeMolt(),e===`droop`){this.performAct(`sweep`,t);return}this.outcomePresenceOwner=null,this.wantsVisible()&&this.scheduleNextAct()},n+(this.twinPlanned?180:0))}completeMolt(){this.molted=!0,this.look&&=(this.shellScale=this.look.scale,{...this.look,scale:this.look.scale<2?2:2.5}),this.shellSpotPct=this.spotPct,this.shellAnchor=this.anchor,this.shellVisible=!0,this.spotPct=Math.min(100,Math.max(0,this.spotPct+this.facing*9)),this.clearTimers(`shellTimer`),this.shellTimer=window.setTimeout(()=>{this.shellTimer=null,this.shellVisible=!1},6e4)}applyMove(e){e&&(this.anchor=e.anchor,this.spotPct=e.spotPct,this.facing=e.facing,this.travel=e.travel,this.travelScene=this.geometry.scene)}startFloorHop(){!this.floorEnabled||this.identity?.elder||this.anchor===`top`&&this.motionRng()>=.45||this.applyMove(this.geometry.planHop(this.anchor,this.spotPct))}render(){let e=this.look;if(!e)return O;let t=this.identity,n=t?.elder?`old as the tides`:t?.oldFriend?`an old friend`:null;return[nm({look:e,mode:this.mode,presence:this.presence,shellVisible:this.shellVisible&&(this.shellAnchor===`top`||this.floorEnabled&&this.geometry.scene.floor!==null),shellAnchor:this.shellAnchor,scene:this.geometry.scene,travel:this.travel,floorEnabled:this.floorEnabled,visitsEnabled:this.visitsEnabled,residentEnabled:this.residentEnabled,critterArtwork:this.critterArtwork,dismissed:this.dismissed,passer:this.traffic.passer?{kind:this.traffic.passer.kind,direction:this.traffic.passer.direction,crossMs:this.traffic.passerCrossMs(),anchor:this.passerAnchor,hops:this.passerHops}:null,twinPlanned:this.twinPlanned,anniversary:this.anniversary,entering:this.entering,entrance:this.entrance,grumpy:this.grumpy,vigil:this.vigil,elder:t?.elder??!1,act:this.act,spotPct:this.spotPct,facing:this.facing,anchor:this.anchor,shellScale:this.shellScale,shellSpotPct:this.shellSpotPct,familiarityVisits:this.familiarity.visits,seed:this.seed,movingDay:this.movingDay,sailorDay:this.sailorDay,nameOverride:t?kp(t,this.seed):null,flavor:n,bottle:this.traffic.bottle,onPointerDown:this.interactions.handleHoldStart,onPointerUp:this.interactions.handleHoldEnd,onPointerCancel:this.interactions.handleHoldCancel,onContextMenu:this.openDismissMenu,onBottleOpen:this.traffic.openBottle}),mp({position:this.dismissMenuPosition,onDismiss:e=>this.dismiss(e),onClose:()=>{this.dismissMenuPosition=null}})]}},L([M({attribute:!1})],$.prototype,`seed`,void 0),L([M({attribute:!1})],$.prototype,`mode`,void 0),L([M({attribute:!1})],$.prototype,`visitsEnabled`,void 0),L([M({attribute:!1})],$.prototype,`residentEnabled`,void 0),L([M({attribute:!1})],$.prototype,`critters`,void 0),L([M({attribute:!1})],$.prototype,`critterArtwork`,void 0),L([M({attribute:!1})],$.prototype,`floorEnabled`,void 0),L([M({attribute:!1})],$.prototype,`runOutcome`,void 0),L([M({attribute:!1})],$.prototype,`soundsEnabled`,void 0),L([M({attribute:!1})],$.prototype,`gatewayVersion`,void 0),L([M({attribute:!1})],$.prototype,`onVisitsDisabled`,void 0),L([N()],$.prototype,`act`,void 0),L([N()],$.prototype,`spotPct`,void 0),L([N()],$.prototype,`facing`,void 0),L([N()],$.prototype,`entering`,void 0),L([N()],$.prototype,`entrance`,void 0),L([N()],$.prototype,`presence`,void 0),L([N()],$.prototype,`anchor`,void 0),L([N()],$.prototype,`scheduledVisiting`,void 0),L([N()],$.prototype,`dismissed`,void 0),L([N()],$.prototype,`dismissMenuPosition`,void 0),L([N()],$.prototype,`grumpy`,void 0),L([N()],$.prototype,`vigil`,void 0),L([N()],$.prototype,`outcomePresenceOwner`,void 0),L([N()],$.prototype,`movingDay`,void 0),L([N()],$.prototype,`anniversary`,void 0),L([N()],$.prototype,`shellVisible`,void 0),customElements.get(`openclaw-lobster-pet`)||customElements.define(`openclaw-lobster-pet`,$)})))()}function dm(e,t){return k`
<div class="callout danger new-session-page__error new-session-page__alert" role="alert">
<span class="new-session-page__alert-icon" aria-hidden="true">${E.alertTriangle}</span>
<span class="callout__content new-session-page__alert-message"
>${ke(e)}</span
>
${t?k`<button
class="btn btn--sm"
type="button"
?disabled=${t.disabled}
@click=${t.onClick}
>
${t.label}
</button>`:O}
</div>
`}function fm(e){let{pendingMessage:t}=e,n=t?un(t):null,r=Gi(!0,n?.sender?e.userId:null),i=e.submitting&&!t;return k`
<div class="sr-only" role="status" aria-live="polite">
${t?e.completion?.label??e.statusLabel??w(`newSession.starting`):O}
</div>
<div
class="${e.inChat?``:`new-session-page__scroll`} ${t||e.inChat?`chat-thread ${r===`footer`?`chat-thread--direct`:``}`:``}"
?inert=${i}
aria-busy=${String(e.submitting)}
@mousedown=${Ue}
>
${e.error?dm(e.error,e.errorAction):O}
${t&&n?pm(t,n,r,e.onOpenImage,e.statusLabel,e.completion):e.renderDraft()}
${t&&e.showDraft?e.renderDraft():O}
</div>
`}function pm(e,t,n,r,i=w(`newSession.starting`),a){let o=`new-session-submission`,s=t.sender?en(t.sender):null,{images:c,attachments:l}=Da(e,t.content),u=ra(l),d=Ut(e,t),f=qn(d),p={onOpenImage:r},m={role:`user`,isStreaming:!1},h={codeBlockChrome:`none`};return k`<div class="new-session-page__starting chat-thread-inner">
<div
class="chat-group user ${t.sender?`chat-group--with-footer`:``} ${s===null?``:`chat-group--sender-tint`}"
style=${s===null?O:`--chat-sender-hue: ${s}`}
data-chat-row-key=${o}
>
${t.sender&&n===`gutter`?Ja(br(t.sender),$t(t.sender)??``):O}
<div class="chat-group-messages">
<div
class="chat-bubble ${c.length||u?`chat-bubble--with-images`:``} ${u?`chat-bubble--with-files`:``}"
data-message-id=${o}
data-message-text=${d||O}
>
${ka(c,p)}
${Sa(l,p,void 0,void 0,!1)}
${f?_i(f,o,m,h):d?xr(d,o,m,h):O}
</div>
</div>
${t.sender&&n===`footer`?k`<div class="chat-group-footer">
<div class="chat-group-footer__meta">
${La(t.sender)}
</div>
</div>`:O}
</div>
<div class="chat-group assistant chat-group--working">
<div class="chat-group-messages">
${a?k`<div class="callout" role="status">
<span class="callout__content">${a.label}</span>
${a.onOpen?k`<button
class="btn btn--sm"
type="button"
?disabled=${a.disabled}
@click=${a.onOpen}
>
${w(`sessionsView.openSession`)}
</button>`:O}
</div>`:Li({kind:`reading-indicator`,key:o,startedAt:e.timestamp},{startupLabel:i})}
</div>
</div>
</div>`}function mm(){return(mm=e((()=>{A(),Pe(),T(),Zn(),sr(),d(),F(),It(),Vt(),Ht(),Oe(),Lt(),Bi(),Wi(),ya(),$r(),Ri(),Jr(),P()})))()}var hm;function gm(){return(gm=e((()=>{A(),nt(),d(),F(),gi(),Fa(),Ji(),P(),hm=class{constructor(e){this.options=e,this.dictation=null,this.owner=null,this.devicePicker=new ja(e.requestUpdate)}dispose(){this.owner=null,this.dictation?.dispose(),this.dictation=null,this.devicePicker.dispose()}get active(){return this.dictation?.active===!0}previewDraft(){let e=this.dictation;return e?.active?this.options.textarea.previewTranscript(e.transcript):void 0}renderStatus(){return ba(this.dictation??void 0)}render(e,t){this.owner?.key!==e&&(this.owner={key:e},this.dictation?.dispose(),this.dictation=null);let n=this.owner,r=()=>this.owner===n,i=this.options.getClient(),a=this.options.isConnected()&&i!==null;this.devicePicker.syncCatalog(i,a);let o=this.options.canCommit(),s={client:i,connected:a,enabled:o,dictationAvailable:this.devicePicker.dictationStatus===`ready`,realtimeTalkActive:!1,onCommit:(e,t)=>{if(!r()||!this.options.canCommit())return;let n=this.options.textarea.insertTranscript(e,t);n!==null&&this.options.onMessage(n),this.options.requestUpdate()},onError:e=>{r()&&this.options.onError(e)},onStateChange:()=>{r()&&this.options.requestUpdate()},onDictationUnavailable:this.devicePicker.handleOpen};this.dictation??=new ha(s),this.dictation.update(s);let c=this.dictation;return k`
${Aa({connected:a,disabled:!o,dictation:c,idleLabel:w(`newSession.dictate`),microphonePicker:ia({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=>{dt({realtimeTalkInputDeviceId:e.trim()||void 0}),this.devicePicker.handleClose()}}),onDirectDictationStart:()=>this.options.textarea.captureSelection()})}
${Ma(c,()=>{r()&&this.options.canCommit()&&this.options.onSubmit()})}
`}}})))()}function _m(e){let t=e.visibility===`draft`,n=e.submitting||e.messageLocked,r=w(`newSession.draft`);return k`
<button
type="button"
class="new-session-page__visibility new-session-page__visibility--draft ${t?`new-session-page__visibility--active`:``}"
role="switch"
aria-label=${r}
aria-checked=${String(t)}
?disabled=${n}
title=${w(`newSession.draftDescription`)}
@click=${()=>e.onVisibilityChange?.(t?`normal`:`draft`)}
>
<span class="new-session-page__visibility-icon" aria-hidden="true">${E.pencil}</span>
<span class="new-session-page__visibility-label">${r}</span>
</button>
`}function vm(e,t){let n=e.visibility===`draft`,r=e.submitting||e.messageLocked===!0,i=e.textareaController;return zr({attachments:t,capabilityMenu:e.capabilityMenu,disabled:r,open:i.capabilityMenuOpen,view:i.capabilityMenuView,toolOverrides:e.toolOverrides,rootToggles:e.draftAvailable?[{value:`new-session-draft`,label:w(`newSession.draft`),icon:E.pencil,checked:n,disabled:r,title:w(`newSession.draftDescription`),onChange:t=>e.onVisibilityChange?.(t?`draft`:`normal`)}]:void 0,onOpenChange:t=>{i.capabilityMenuOpen=t,t||(i.capabilityMenuView=`root`),e.requestUpdate()},onViewChange:t=>{i.capabilityMenuView=t,e.requestUpdate()}})}function ym(e){let t=pi(e.toolOverrides);if(t===0)return O;let n=e.submitting||e.messageLocked===!0;return k`
<button
type="button"
class="new-session-page__selection-status"
?disabled=${n}
@click=${()=>{e.textareaController.capabilityMenuView=`root`,e.textareaController.capabilityMenuOpen=!0,e.requestUpdate()}}
>
${w(t===1?`chat.composer.overrides.countOne`:`chat.composer.overrides.count`,{count:String(t)})}
</button>
`}function bm(){return(bm=e((()=>{A(),T(),d(),F(),Mi(),P()})))()}function xm(e){e.textareaController.emojiMenu.close(),e.textareaController.mentionMenu.close(),yi(e.textareaController.skillMenuState),la(e.textareaController.slashMenuState),e.onSubmit()}function Sm(e){let t=e.submitting?w(`newSession.starting`):w(e.nativeTerminal?`newSession.startInTerminal`:`newSession.start`),n=!e.canSubmit&&e.submitDisabledReason!==void 0,r=e.submitting||e.pendingAttachmentReads>0;return k` <openclaw-tooltip content=${e.submitDisabledReason??t}>
<button
type="button"
class="chat-send-btn new-session-page__start-submit ${n?`new-session-page__start-submit--blocked`:``} ${r?`new-session-page__start-submit--busy`:``}"
?disabled=${!e.canSubmit&&!n}
aria-disabled=${String(!e.canSubmit)}
aria-busy=${String(r)}
aria-label=${t}
@click=${()=>xm(e)}
>
${r?E.loader:e.nativeTerminal?E.squareTerminal:E.arrowUp}
</button>
</openclaw-tooltip>`}function Cm(e){let t=e.textareaController.skillMenuState,n=e.textareaController.slashMenuState,r=e.textareaController.mentionMenu,i=e.textareaController.emojiMenu,a=e.submitting||e.messageLocked===!0||e.dictationActive===!0;r.syncDirectory(a?void 0:e.mentionDirectory);let o={paneId:`new-session`,getDraft:()=>e.textareaController.getTextarea()?.value??e.message,commitDraft:e.onInput,getTextarea:e.textareaController.getTextarea,refreshCommands:e.refreshCommands},s={...o,resolveArgOptions:e=>e.argOptions??[],runCommand:()=>xm(e),canRun:e=>!e,commandFilter:e=>e.executeLocal!==!0},c={paneId:o.paneId,getDraft:o.getDraft,getTextarea:o.getTextarea,getMentions:()=>e.getMentions?.()??e.mentions??[],commitDraft:e.onInput},l=t=>{if(e.dictationActive||e.submitting||e.messageLocked||e.textareaController.composing||so(t)||e.textareaController.emojiMenu.handleKeydown(t,`new-session`,e.requestUpdate)||e.textareaController.mentionMenu.handleKeydown(t,c,e.requestUpdate)||hi(t,e.textareaController.skillMenuState,o,e.requestUpdate)||di(t,e.textareaController.slashMenuState,s,e.requestUpdate)||t.key!==`Enter`)return;let n=t.metaKey||t.ctrlKey,r=n&&t.shiftKey,i=!!(!t.altKey&&r&&e.onBackgroundSubmit);if(i||!t.shiftKey&&(!e.requiresModifier||n)){if(t.repeat){t.preventDefault();return}(e.canSubmit||e.submitDisabledReason!==void 0)&&(t.preventDefault(),i?(yi(e.textareaController.skillMenuState),la(e.textareaController.slashMenuState),e.textareaController.mentionMenu.close(),e.onBackgroundSubmit?.()):xm(e))}},u=o=>{i.update(o,e.requestUpdate,!a&&!e.nativeTerminal&&!e.textareaController.composing&&!t.skillMenuOpen&&!n.slashMenuOpen&&!r.open)},d=(a,c)=>{if(e.nativeTerminal||e.textareaController.composing||c?.isComposing){i.close();return}ai(a.value,n,s,e.requestUpdate),$a(a.value,a.selectionStart,t,o,e.requestUpdate),c?.inputType===`insertFromPaste`||c?.inputType===`insertFromDrop`?r.close():r.update(a,e.requestUpdate,c?c.inputType===`insertText`&&c.data?.includes(`@`)===!0?`trigger`:`input`:`selection`),u(a)},f=t=>{let n=t.currentTarget;n instanceof HTMLTextAreaElement&&(t.type===`keyup`?(r.update(n,e.requestUpdate),u(n)):d(n))};(a||e.nativeTerminal||e.textareaController.composing)&&i.close();let p={attachmentReads:e.attachmentReads,attachmentLimits:e.attachmentLimits,uploadConfig:e.uploadConfig,attachments:e.attachments,get disabled(){return e.submitting||e.messageLocked===!0||e.dictationActive===!0},getAttachments:e.getAttachments,draft:e.message,getDraft:()=>e.message,onAttachmentsChange:e.onAttachmentsChange,onDraftChange:e.onInput,onPendingReadsChange:e.onPendingReadsChange,onOpenImage:e.onOpenImage,onOpenSidebar:e.onOpenSidebar,readSignal:e.readSignal},m=Lr({...p,canCompose:!a&&!e.nativeTerminal}),h=e.dictationPreview??e.message;e.textareaController.syncDraft(h);let g=w(e.nativeTerminal?`newSession.nativeTerminalPrompt`:`newSession.messagePlaceholder`),_=e.dictationActive?``:e.textareaController.getPlaceholder(g,e.message,e.requestUpdate),{skillMenuVisible:v,slashMenuVisible:y,menuVisible:b,menuListboxId:x,activeMenuOptionId:S,activeMenuOptionLabel:ee}=Ii(o.paneId,!e.nativeTerminal&&!a,t,n,r,i),te=wi(o.paneId,`active-menu-announcement`),ne=e.requiresModifier?`Control+Enter Meta+Enter`:`Enter Control+Enter Meta+Enter`,re=e.onBackgroundSubmit?`${ne} Control+Shift+Enter Meta+Shift+Enter`:ne;return k`
<div
class="agent-chat__composer-shell new-session-page__composer"
@drop=${t=>{e.nativeTerminal&&t.dataTransfer?.files.length?(t.preventDefault(),e.onUnsupportedAttachment?.()):m.onDrop(t)}}
@dragenter=${m.onDragenter}
@dragleave=${m.onDragleave}
@dragover=${m.onDragover}
>
<div
class="agent-chat__input agent-chat__input--mobile-toolbar${e.dictationActive?` agent-chat__input--dictating`:``}"
@openclaw-composer-dismiss-invocations=${()=>{r.close(),i.dismiss(e.textareaController.getTextarea()),e.requestUpdate()}}
>
${e.renderCritters(!a&&h.length===0&&e.attachments.length===0&&e.pendingAttachmentReads===0&&!b&&!e.textareaController.capabilityMenuOpen)}
${r.render(c,e.requestUpdate)}
${i.render(`new-session`,e.textareaController.getTextarea(),e.requestUpdate)}
${e.nativeTerminal?O:Ta(p)}
${Ti(e.message,e.mentions,()=>e.onInput(e.message,[]),r.selectedAvatarUrls)}
${vi(p)}
${Za(e.pendingAttachmentReads)}
<div class="agent-chat__composer-lede">${e.dictationStatus??O}</div>
<div class="agent-chat__composer-input-row">
<div class="agent-chat__composer-combobox">
${y?Tr(n,s,e.message,e.requestUpdate):O}
${v?ti(t,o,e.requestUpdate):O}
<textarea
${yt(e.textareaController.ref)}
class="new-session-page__message"
rows="1"
?autofocus=${globalThis.matchMedia?.(`(max-width: 560px)`)?.matches??!1}
?disabled=${e.submitting||e.messageLocked}
?readonly=${e.dictationActive}
placeholder=${_}
aria-label=${g}
aria-keyshortcuts=${re}
.value=${Un([h],()=>xt(h))}
aria-autocomplete="list"
aria-controls=${Ct(b?x:void 0)}
aria-haspopup=${Ct(b?`listbox`:void 0)}
aria-activedescendant=${Ct(S??void 0)}
aria-describedby=${te}
@input=${t=>{if(e.dictationActive)return;let n=t.target;Ya(n);let r=c.getMentions();e.onInput(n.value,r.length?tn(e.message,n.value,r,e.textareaController.mentionInput):void 0),e.textareaController.mentionInput=void 0,d(n,t)}}
@beforeinput=${t=>{let n=t.target;e.textareaController.mentionInput={value:n.value,start:n.selectionStart,end:n.selectionEnd,inputType:t.inputType},i.complete(t,e.requestUpdate,!a&&!e.nativeTerminal&&!e.textareaController.composing)}}
@select=${f}
@focus=${f}
@pointerup=${f}
@keyup=${e=>{oo(e),i.handleKeyup(e),(e.key.startsWith(`Arrow`)||e.key===`Home`||e.key===`End`)&&f(e)}}
@blur=${t=>{oo(t);let n=i.open;e.textareaController.composing=!1,i.close(),n&&e.requestUpdate()}}
@compositionend=${t=>{ao(t),e.textareaController.composing=!1,t.target instanceof HTMLTextAreaElement&&d(t.target)}}
@keydown=${l}
@compositionstart=${()=>{e.textareaController.composing=!0,i.close(),r.close(),e.requestUpdate()}}
@paste=${t=>{e.nativeTerminal&&t.clipboardData?.files.length?(t.preventDefault(),e.onUnsupportedAttachment?.()):!a&&!e.nativeTerminal&&Kr(t,p)}}
></textarea>
<span class="agent-chat__composer-placeholder" aria-hidden="true"
>${_}</span
>
<span
id=${te}
class="sr-only"
role="status"
aria-live="polite"
aria-atomic="true"
>${ee}</span
>
</div>
</div>
<div class="agent-chat__composer-footer">
<div class="agent-chat__composer-lead">
${e.nativeTerminal?O:vm(e,p)}
${e.permissionControl??O}
${!e.nativeTerminal&&e.draftAvailable?_m(e):O}
${e.nativeTerminal?O:ym(e)}
</div>
<div class="agent-chat__composer-trail">
<div class="agent-chat__composer-controls">
${e.modelControl&&e.modelControl!==O?k`<div class="chat-composer-model-control">${e.modelControl}</div>`:O}
</div>
<div class="agent-chat__composer-actions">
${e.voiceControl??O}${e.dictationActive?O:Sm(e)}
</div>
</div>
</div>
</div>
${e.blockedSubmitNotice?k`<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"
>${E.info}</span
>
<span class="agent-chat__composer-status-text">${e.blockedSubmitNotice}</span>
</div>
</div>`:O}
</div>
`}function wm(){return(wm=e((()=>{A(),Bn(),_t(),vt(),ht(),T(),d(),F(),Yt(),lo(),Le(),Xr(),ei(),kr(),qr(),Vr(),Rr(),pa(),bm(),P()})))()}function Tm(e,t,n){let r=e.worktree&&!ul(e.worktreeName),i=t.capabilities;return k`
${r?dm(w(`newSession.worktreeNameInvalid`)):O}
${n&&i.toolOverrides?dm(w(`newSession.terminalCapabilityOverridesUnsupported`),{label:w(`common.reset`),onClick:()=>i.setToolOverrides(null)}):O}
${t.submissionOutcomeUnknown?dm(w(t.submissionOutcomeUnknown===`gateway-changed`?`newSession.createOutcomeUnknown`:`newSession.placementSetupInterrupted`),t.pendingPlacement.sessionKey?{label:w(`common.reset`),onClick:()=>t.clearPendingPlacementRecovery()}:void 0):O}
`}function Em(e){let t=e.attachmentDraft.reads.readSignal,n=e.nativeTerminal?null:e.context?.gateway.snapshot.client??null,r=e.context?.gateway,i=lu(e);return e.textareaController.syncSkillCommandOwner(n,e.agentId,e.draftOwnerKey),Cm({...e,renderCritters:t=>k`<openclaw-lobster-pet
.seed=${lp(`${e.textareaController.critterVisit}:${e.draftOwnerKey}`)}
.mode=${dp(!r?.snapshot.offlineStable,e.context?.sessions.state.result?.sessions)}
.runOutcome=${up(e.context?.sessions.state.result?.sessions)}
.visitsEnabled=${e.context?.theme.settings.lobsterPetVisits!==!1}
.residentEnabled=${e.context?.theme.branding.mascot!==`none`}
.critters=${e.context?.theme.branding.critters}
.critterArtwork=${e.context?.theme.branding.artwork?.critters}
.soundsEnabled=${e.context?.theme.settings.lobsterPetSounds===!0}
.gatewayVersion=${e.context?.config.current.serverVersion??r?.snapshot.hello?.server?.version??null}
.onVisitsDisabled=${()=>e.context?.theme.refresh()}
.floorEnabled=${t}
></openclaw-lobster-pet>`,uploadConfig:e.context?.config,attachmentLimits:Zi(e.context?.gateway.snapshot.hello?.policy),attachments:e.attachmentDraft.attachments,getAttachments:()=>e.attachmentDraft.attachments,get message(){return e.message},mentionDirectory:i,modelControl:e.isCatalogTarget?O:e.modelControl.render({agent:e.agent,agentId:e.agentId,context:e.context,sending:e.submitting}),pendingAttachmentReads:e.attachmentDraft.reads.pendingReads,attachmentReads:e.attachmentDraft.reads,readSignal:t,refreshCommands:n?()=>Qi({client:n,agentId:e.agentId,shouldApply:()=>e.textareaController.ownsSkillCommands(n,e.agentId,e.draftOwnerKey)}):void 0,get dictationActive(){return e.dictationActive},get submitting(){return e.submitting},get messageLocked(){return e.messageLocked},onAttachmentsChange:t=>{!e.submitting&&!e.messageLocked&&e.attachmentDraft.replace(t)},onPendingReadsChange:n=>e.attachmentDraft.reads.updatePending(t,n)})}function Dm(){return(Dm=e((()=>{A(),pp(),d(),F(),Pa(),Sr(),wm(),pl(),mm(),uu(),P()})))()}function Om(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??So(window.location.search);e.chatAttachmentHandoff.prepare({reviewPrivateDraft:Vi,owner:i,paneId:Mm,scopeKey:a,message:r===a?t.message:``,mentions:r===a?t.mentions:void 0,newSessionDraft:t.draftPersistence.captureSubmission(),attachments:t.attachmentDraft.take(),fallbacks:{}})}function km(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:Mm,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),Am(t,n),n}function Am(e,t){e.pendingPlacement.sessionKey||e.draftPersistence.activateRoute(t)}function jm(e,t,n){e.restorePendingPlacementRecovery(t,n),e.draftPersistence.setOwner(t,n,!!e.pendingPlacement.sessionKey)}var Mm;function Nm(){return(Nm=e((()=>{$i(),G(),Mm=`new-session-draft`})))()}function Pm(e,t){return e?.client===t?.client&&e?.agentId===t?.agentId&&e?.ownerKey===t?.ownerKey&&e?.message===t?.message&&e?.model===t?.model}var Fm;function Im(){return(Im=e((()=>{jt(),G(),Fm=class{constructor(e,t){this.read=t,this.current=null,this.title=null,this.active=!1,this.pending=!1,this.readyAt=0,this.connected=!1,this.composing=!1,this.submitted=null,e.addController(this)}hostConnected(){this.connected=!0}hostUpdated(){this.sync(this.input())}hostDisconnected(){this.connected=!1,this.sync(null),this.submitted=null}setComposing(e){this.composing=e,this.hostUpdated()}takePreparedTitle(){let e=this.input(),t=Pm(this.current,e)?this.title??void 0:void 0;return this.submitted=e??this.submitted,this.sync(null),t}sync(e){let t=e&&e.message.length>=12&&!e.message.startsWith(`/`)?e:null;Pm(this.current,t)||(clearTimeout(this.timer),this.current=t,this.title=null,this.pending=t!==null,this.readyAt=Date.now()+1e3,this.schedule())}schedule(){this.pending&&!this.active&&(this.timer=setTimeout(()=>void this.prepare(),Math.max(0,this.readyAt-Date.now())))}async prepare(){let e=this.current;if(e&&this.pending){this.pending=!1,this.active=!0;try{let t=await e.client.request(`sessions.title.prepare`,{agentId:e.agentId,message:fn(e.message,1e3),...e.model?{model:e.model}:{}},{timeoutMs:2e4});this.current===e&&(this.title=t.title)}catch{}finally{this.active=!1,this.schedule()}}}input(){let{context:e,data:t,place:n,submission:r,dictating:i}=this.read(),a=e?.gateway.snapshot;if(!this.connected||W(t)||this.composing||i||r.submitting||r.visibility===`incognito`||r.pendingPlacement.sessionKey||!n.agentId||!n.modelControl.accountSelectionReady()||!kt(a,`sessions.title.prepare`,`operator.write`)||!a?.client)return null;let o={client:a.client,ownerKey:xo(t),agentId:n.agentId,message:r.message.trim(),model:n.modelControl.modelForSubmission()};return Pm(o,this.submitted)?null:o}}})))()}function Lm(e,t){let n=e.visibility,r=e.incognitoDisabledReason(),i=e.submitting||!!e.pendingPlacement.sessionKey,a=t=>{let a=t===`draft`,o=n===t,s=i||!a&&!!r,c=w(a?`newSession.draft`:`newSession.incognito`),l=a?w(`newSession.draftDescription`):r??w(`newSession.incognitoDescription`),u=`new-session-page__${t}-toggle`;return k`
<openclaw-tooltip
class=${a?`new-session-page__draft-tooltip`:O}
.content=${l}
>
<button
type="button"
class="shell-chrome-controls__button ${u} ${o?`${u}--active`:``}"
role="switch"
aria-label=${a?`${c}: ${l}`:c}
aria-checked=${String(o)}
?disabled=${s}
title=${l}
@click=${()=>{(a||!s)&&e.setVisibility(o?`normal`:t)}}
>
${a?E.pencil:zm}
${a&&o?k`<span class="new-session-page__draft-toggle-label">${c}</span>`:O}
</button>
</openclaw-tooltip>
`};return k`
<div class="new-session-page__incognito-rail">
${t?a(`draft`):O} ${a(`incognito`)}
</div>
`}function Rm(e){let t=w(`newSession.incognitoDescription`);return k`
<div
class="new-session-page__incognito-notice ${e?`new-session-page__incognito-notice--visible`:``}"
role="status"
aria-hidden=${String(!e)}
>
<span class="new-session-page__incognito-notice-icon" aria-hidden="true">
${zm}
</span>
<span>${t}</span>
</div>
`}var zm;function Bm(){return(Bm=e((()=>{A(),it(),T(),Le(),d(),F(),P(),zm=D(j` <path
d="M4 13V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5"
/>
<path d="M14 2v5a1 1 0 0 0 1 1h5" />
<path d="M10 22v-5" />
<path d="M14 19v-2" />
<path d="M18 20v-3" />
<path d="M2 13h20" />
<path d="M6 20v-3" />`)})))()}var Vm,Hm;function Um(){return(Um=e((()=>{Sn(),A(),gt(),We(),Me(),Je(),Ze(),d(),F(),pe(),we(),mr(),_(),C(),l(),c(),_a(),Pi(),Wr(),Er(),Ga(),Mr(),G(),gm(),ho(),mm(),Dm(),cu(),Nm(),Im(),Bm(),Il(),ou(),Vu(),Pn(),P(),Vm={tagName:`openclaw-chat-detail-panel`,get label(){return w(`chat.attachments.pastedText`)},loadModule:async()=>{await R(()=>import(`./control-ui-boot-shared-styles-BXPMRytW.js`).then(e=>(e.l(),e.u)),__vite__mapDeps([9]),import.meta.url),await R(()=>import(`./chat-detail-panel-DYod9DCg.js`),__vite__mapDeps([12,1,3,4,5,6,7,8,13,14,15,16,17,18,19,20,2,9,10,11,21,22,23,24]),import.meta.url)}},Hm=class extends ue{constructor(){super(),this.retainedForHandoff=null,this.openedFor=null,this.critterImport=Se(()=>R(()=>Promise.resolve().then(()=>(um(),lm)),void 0,import.meta.url)),this.openedGroupDefaults=``,this.openedAgentId=``,this.messageOwnerKey=``,this.attachmentPanel=null,this.attachmentPanelLoader=new mt(this),this.closeAttachmentPanel=()=>{this.attachmentPanel=null},this.openAttachmentPanel=e=>{e.kind===`attachment`&&(this.attachmentPanel={content:e,ownerKey:this.routeOwnerKey(),agentId:this.place.agentId})},this.imageLightbox=null,this.agentPickerOpen=!1,this.groupRouteRevalidation=new Lo(()=>this.data,()=>this.context?.revalidate(`new-session`)),this.titlePreparation=new Fm(this,()=>({context:this.context,data:this.data,place:this.place,submission:this.submission,dictating:this.dictation.active})),this.flushDraft=()=>this.submission.draftPersistence.persistNow(),this.setImageLightbox=e=>{this.imageLightbox=e},this.draft=new su(this,()=>({context:this.context,data:this.data,isConnected:this.isConnected}),{requestUpdate:()=>this.requestUpdate(),querySelector:e=>this.querySelector(e),activeElement:()=>this.ownerDocument.activeElement,body:()=>this.ownerDocument.body,onInvalidate:()=>{this.closeAttachmentPanel(),this.connectMachine?.close()},onRecoveryReady:(e,t)=>jm(this.submission,e,t),closeTransientUi:()=>{this.closeAttachmentPanel(),ru(this)},takePreparedTitle:()=>this.titlePreparation.takePreparedTitle(),retainForHandoff:()=>{if(!this.data||!this.isConnected)return;let e={};return this.retainedForHandoff=e,{page:this,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 mo(()=>({client:this.gateway.client,connected:this.gateway.connected}),()=>this.requestUpdate()),this.dictation=new hm({textarea:this.submission.composerTextarea,getClient:()=>this.gateway.client,isConnected:()=>this.gateway.connected,canCommit:()=>!this.submission.submitting&&!this.submission.pendingPlacement.sessionKey,onMessage:e=>this.setMessageFromUser(e),onError:e=>this.submission.setError(e),onSubmit:()=>void this.submission.submit(),requestUpdate:()=>this.requestUpdate()}),this.subscriptions=new o(this).effect(()=>this.ownerDocument,xi).watchStore(()=>this.context?.theme).watchStore(()=>this.context?.agents).watchStore(()=>this.context?.agentIdentity).watchStore(()=>this.context?.sessions,e=>this.groupRouteRevalidation.synchronize(e)).watchStore(()=>this.context?.placementStartup).watchStore(()=>this.context?.runtimeConfig).watch(()=>this.context?.config,(e,t)=>e.subscribe(()=>t()))}handleEvent(e){e instanceof KeyboardEvent&&wa(this,e)}focusComposer(){let e=this.context,t=this.routeOwnerKey(),n=document.activeElement;this.updateComplete.then(()=>{this.isConnected&&!this.retainedForHandoff&&this.context===e&&this.routeOwnerKey()===t&&(document.activeElement===n||document.activeElement===document.body)&&!document.openClawModalLayers?.size&&this.submission.composerTextarea.getTextarea()?.focus({preventScroll:!0})})}connectedCallback(){super.connectedCallback(),this.submission.draftPersistence.connect(),this.critterImport.schedule(),document.addEventListener(`keydown`,this,!0),window.addEventListener(`beforeunload`,this.flushDraft)}disconnectedCallback(){this.closeAttachmentPanel(),this.attachmentPanelLoader.requestWhileActive(Vm,!1),this.critterImport.dispose(),document.removeEventListener(`keydown`,this,!0),window.removeEventListener(`beforeunload`,this.flushDraft),this.subscriptions.clear(),this.dictation.dispose(),this.connectMachine.close(),this.retainedForHandoff||this.disposeDraft(),super.disconnectedCallback()}disposeDraft(){jl(this.data,this),Om(this.context,this.submission,this.openedFor,this.messageOwnerKey),this.draft.disconnect()}willUpdate(){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.attachmentPanel=null),this.attachmentPanelLoader.requestWhileActive(Vm,this.attachmentPanel!==null)}updated(){this.connectMachine.open&&!this.place.isAdmin()&&this.connectMachine.close(),this.gateway.retryPendingCatalogTarget(),this.context?.agentIdentity.ensure(this.agentPickerOpen?this.place.agents().map(e=>e.id):[this.place.agentId]);let e=this.draft.agentsReady();this.place.modelControl.loadCatalogTargets(this.context,e&&this.place.agentId?this.place.selectedAgent()?.id??``:``,this.context?.config.current.cliAgentsEnabled===!0&&!W(this.data));let t=this.routeOwnerKey(),n=this.data?.agentId??``,r=Eo(this.data);if(this.openedFor!==t){this.openedFor!==null&&this.submission.visibility===`incognito`&&Om(this.context,this.submission,this.openedFor,this.messageOwnerKey);let i=this.messageOwnerKey===t?this.submission.message:``,a=this.messageOwnerKey===t?this.submission.mentions:void 0;this.openedFor=t,this.openedGroupDefaults=r,this.openedAgentId=n,this.place.setAgentsHydrated(e),this.resetDraft(),this.messageOwnerKey=km(this.context,this.submission,t,i,a),this.focusComposer();return}this.openedGroupDefaults!==r&&(this.openedGroupDefaults=r,this.place.adoptGroupDefaults()),this.openedAgentId!==n&&(this.openedAgentId=n,this.place.setAgentsHydrated(!1)),this.draft.synchronizeSelections(),Am(this.submission,t),this.submission.resumeInterruptedSubmission()}resetDraft(){this.place.resetDraft(),this.submission.resetDraft(),this.messageOwnerKey=xo(this.data),this.browser.clearPopoverHiding(),nu(this),this.browser.close(),this.connectMachine.close(),this.place.adoptAgentDefaults()}routeOwnerKey(){return this.data?xo(this.data):So(window.location.search)}setMessageFromUser(e,t){!this.submission.submitting&&!this.submission.pendingPlacement.sessionKey&&(this.submission.setMessage(e,t),this.messageOwnerKey=So(window.location.search))}renderTargetBar(){let e=this.place.agents(),t=this.context?.sessions;return Io({data:this.data,groupPending:ko(this.data,t),agentSelect:e.length>1?zu({agents:e,agentId:this.place.agentId,agentIdentity:this.context?.agentIdentity,disabled:this.submission.submitting||!!this.submission.pendingPlacement.sessionKey,onSelect:e=>this.place.selectAgentId(e),onOpenChange:e=>{this.agentPickerOpen=e}}):O,placeSelect:Bu({context:this.context,data:this.data,gateway:this.gateway,place:this.place,submitting:this.submission.submitting,pendingPlacement:!!this.submission.pendingPlacement.sessionKey,onConnectMachine:()=>this.openConnectMachine(),onNavigate:(e,t)=>this.context?.navigate(e,t),onFocusComposer:()=>this.submission.composerTextarea.getTextarea()?.focus({preventScroll:!0}),requestUpdate:()=>this.requestUpdate()}),retrying:this.gateway.catalogRetrying||!!(this.data?.group&&t?.groupsStatus()===`loading`),onRetry:this.gateway.handleCatalogRetry})}openConnectMachine(){this.place.isAdmin()&&(this.browser.close(),this.connectMachine.start())}renderDraftBlock(){let{context:e,gateway:t,place:n,submission:r,dictation:i,titlePreparation:a}=this,o=this.routeOwnerKey(),s=W(this.data),c=r.capabilities,l=e?.theme.settings,u=i.render(o,l?.realtimeTalkInputDeviceId),d=i.active;return k`
<div
class="new-session-page__draft"
aria-busy=${String(r.submitting)}
@compositionstart=${()=>{a.setComposing(!0)}}
@compositionend=${()=>{a.setComposing(!1)}}
@focusout=${()=>{a.setComposing(!1)}}
>
${this.renderTargetBar()} ${Tm(n,r,s)}
${Em({agent:n.selectedAgent(),agentId:n.agentId,attachmentDraft:r.attachmentDraft,canSubmit:!r.submitting&&!d&&r.canSubmit(),submitDisabledReason:r.submitDisabledReason(),blockedSubmitNotice:r.blockedSubmitNotice(),get dictationActive(){return i.active},dictationPreview:i.previewDraft(),dictationStatus:i.renderStatus(),context:e,isCatalogTarget:s,draftOwnerKey:o,get message(){return r.message},mentions:r.mentions,getMentions:()=>r.mentions,visibility:r.visibility,draftAvailable:c.canStartAsDraft(e),...c.composerProps(e,t,n.agentId),modelControl:n.modelControl,permissionControl:s?void 0:ki({canSelectFull:n.isAdmin(),defaultMode:n.selectedAgent()?.defaultPermissionMode,disabled:r.submitting||!!r.pendingPlacement.sessionKey,disabledReason:r.submitting?w(`newSession.starting`):void 0,mode:r.permissionMode,onSelect:e=>r.setPermissionMode(e??void 0)}),requiresModifier:l?.chatSendShortcut===`modifier-enter`,requestUpdate:()=>this.requestUpdate(),get submitting(){return r.submitting},textareaController:r.composerTextarea,voiceControl:u,get messageLocked(){return!!r.pendingPlacement.sessionKey},nativeTerminal:s,onUnsupportedAttachment:()=>r.setError(w(`newSession.terminalAttachmentsUnsupported`)),onInput:(e,t)=>this.setMessageFromUser(e,t),onOpenImage:this.setImageLightbox,onOpenSidebar:this.openAttachmentPanel,onVisibilityChange:e=>{!r.submitting&&!r.pendingPlacement.sessionKey&&r.setVisibility(e)},onSubmit:()=>void r.submit(),onBackgroundSubmit:r.visibility===`draft`||s?void 0:()=>void r.submit(void 0,!0)})}
${s?O:Rm(r.visibility===`incognito`)}
</div>
`}renderWelcome(){let e=this.place.selectedAgent(),t=this.context?.agentIdentity.get(this.place.agentId),n=this.context?.gateway.snapshot;return Ar({currentAgentId:this.place.agentId,assistantName:e?re(e,t):``,assistantAvatar:se(e??{},t),assistantAvatarUrl:ie(e??{},t),hint:w(W(this.data)?`newSession.nativeTerminalHint`:`newSession.hint`),composer:this.renderDraftBlock(),hideSecondaryContent:this.submission.visibility===`incognito`,fadeSecondaryContent:this.submission.message.trim().length>0,modelSetupRequired:this.submission.requiresModelSetup(),onModelSetup:()=>this.context?.navigate(`model-setup`),sessions:this.context?.sessions.state.result,sessionKey:Ln({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},onDraftChange:e=>this.setMessageFromUser(e),onSend:()=>void this.submission.submit(),onOpenSession:e=>{let{context:t,submission:n}=this;!t||n.submitting||n.pendingPlacement.sessionKey||(Ie({selection:t.agentSelection,gateway:t.gateway,sessionKey:e,agentId:this.place.agentId}),t.navigate(`chat`,b({context:t,face:`chat`,sessionKey:e}).options))}})}render(){let e=this.submission.pendingMessage,t=this.submission.completedSubmission,n=t?this.context?.placementStartup.get(t.key):null,r=this.context?.gateway.snapshot.selfUser?.identity,i=this.submission.visibility===`incognito`,a=this.attachmentPanelLoader.visibleState;return k`
<div
class="new-session-page ${e?`chat`:``} ${i?`new-session-page--incognito`:``}"
>
${W(this.data)?O:Lm(this.submission,this.submission.capabilities.canStartAsDraft(this.context))}
${fm({error:this.submission.error,pendingMessage:e,userId:r?.type===`profile`?r.id:null,submitting:this.submission.submitting,statusLabel:this.context?.gateway.snapshot.phase===`connected`?void 0:w(`connection.reconnecting`),completion:t?{label:t.error??n?.error??Ei(null,n)??w(`newSession.created`),onOpen:()=>void this.submission.openSubmittedSession(),disabled:this.context?.gateway.snapshot.phase!==`connected`}:void 0,showDraft:!!t,renderDraft:()=>t?this.renderDraftBlock():this.renderWelcome(),onOpenImage:this.setImageLightbox})}
${this.connectMachine.render(this.place.isAdmin(),()=>{this.connectMachine.close(),this.context?.navigate(`devices`)})}
${Xa(this.imageLightbox,()=>this.setImageLightbox(null))}
</div>
${this.attachmentPanel?k`<aside class="new-session-attachment-panel">
${a?.status===`error`?et({error:a.error,stale:a.stale,onRetry:()=>this.attachmentPanelLoader.retry(),onClose:this.closeAttachmentPanel}):a?k`<div role="status">${w(`common.loading`)}</div>`:O}
<openclaw-chat-detail-panel
.content=${{...this.attachmentPanel.content}}
@chat-detail-panel-close=${this.closeAttachmentPanel}
></openclaw-chat-detail-panel>
</aside>`:O}
`}},L([M({attribute:!1})],Hm.prototype,`data`,void 0),L([xn({context:rt,subscribe:!0})],Hm.prototype,`context`,void 0),L([N()],Hm.prototype,`attachmentPanel`,void 0),L([N()],Hm.prototype,`imageLightbox`,void 0),L([N()],Hm.prototype,`agentPickerOpen`,void 0)})))()}var Wm=t({render:()=>Gm}),Gm;function Km(){return(Km=e((()=>{A(),Il(),Um(),customElements.get(`openclaw-new-session-page`)||customElements.define(`openclaw-new-session-page`,Hm),Gm=e=>Ml(e)??k`<openclaw-new-session-page .data=${e}></openclaw-new-session-page>`})))()}var qm=t({load:()=>Jm});async function Jm(e,t,n){let r=n&&n!==`preload`&&Al(e,t);if(r)return r;let i=vo(t),a=``,o=!1,s,c,l;if(i.group){let t=e.sessions.groupsGeneration(),n=await e.sessions.groupsLoad();c=e.sessions.groupsGeneration(),l=e.sessions.groupsStatus();let r=t===c&&l===`ready`?n:null,u=r?.find(e=>e.name===i.group);s=r===null?`unavailable`:u?`resolved`:`missing`,a=u?.cwd??``,o=u?.worktree===!0}let u={...i,requestedAgentId:i.agentId,groupStatus:s,groupCwd:a,groupWorktree:o,groupCatalogGeneration:c,groupDefaultsStatus:l,catalogLabel:``,startTerminal:!1};if(!i.catalogId)return u;let d=(e=``)=>({...u,agentId:e}),f=e.gateway.snapshot,p=e.agents.state;if(f.phase!==`connected`||!f.client||!p.connected||p.client!==f.client)return d();let m=p.agentsList??await e.agents.ensureList(),h=e.gateway.snapshot,g=e.agents.state;if(h.phase!==`connected`||!h.client||h.client!==f.client||!g.connected||g.client!==h.client||!m||g.agentsList!==m)return d();let _=Ce(m.agents),v=_.some(e=>e.id===m.defaultId)?m.defaultId:_[0]?.id,y=v?Mo(i,_,v):``,b=d(y);if(!y)return b;let x=await Po(h.client,i.catalogId,y);return x?{...b,...x}:b}function Ym(){return(Ym=e((()=>{pe(),G(),Il(),yo()})))()}export{ec as $,Au as A,ou as B,cd as C,zu as D,Vu as E,uu as F,el as G,Bl as H,lu as I,Cc as J,$c as K,su as L,Cu as M,xu as N,Ru as O,Su as P,rc as Q,cu as R,Ku as S,qu as T,Vl as U,iu as V,Qc as W,_c as X,xc as Y,ac as Z,xd as _,lo as _t,mm as a,is as at,ld as b,io as bt,_p as c,Ko as ct,Rf as d,_o as dt,$s as et,Uf as f,mo as ft,bd as g,oo as gt,Wf as h,fo as ht,Wm as i,cs as it,Tu as j,ju as k,pp as l,ts as lt,Gf as m,uo as mt,qm as n,Xs as nt,fm as o,q as ot,op as p,ho as pt,Sc as q,Km as r,ls as rt,vp as s,ns as st,Ym as t,Ys as tt,lp as u,yo as ut,pd as v,so as vt,Hu as w,Gu as x,ro as xt,md as y,ao as yt,ru as z};