openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
16 lines • 3.51 kB
JavaScript
import{n as e}from"./rolldown-runtime-8BhlS34s.js";import{Ic as t,Lc as n,Nu as r,Pu as i,So as a,To as o,ju as s,kl as c,zl as l,zu as u}from"./control-ui-core-CBJ5efDh.js";import{Ai as d,ki as f}from"./control-ui-core-DtLivg_r.js";import{G as p,J as m,W as h,Z as g,at as _}from"./lit-runtime-IOnANfcZ.js";import{Ur as v,Wr as y,Zr as b,mt as x}from"./ui-CmSP4d14.js";import{m as S,p as C}from"./control-ui-boot-chat-XPUNenUd.js";import{L as w,R as T,h as E,v as D}from"./control-ui-boot-chat-CmENwCKi.js";function O(e,t){let n=e?.props?.sessionKey,r=typeof n==`string`?n.trim():``;return r?{sessionKey:r,agentId:l(r)?.agentId??t.agentId}:t}var k;function A(){return(A=e((()=>{y(),h(),g(),d(),T(),E(),i(),r(),n(),C(),c(),a(),k=class extends s{constructor(){super(),this.session={sessionKey:``},this.active=!0,this.progressCard=new w(this,{gateway:()=>this.active&&O(this.widget,this.session).sessionKey?this.context?.gateway:void 0,target:()=>O(this.widget,this.session)}),new t(this).effect(()=>this.context?.agentSelection,e=>(this.bindSessionList(),e.subscribe(()=>this.bindSessionList())))}connectedCallback(){super.connectedCallback(),this.bindSessionList()}disconnectedCallback(){this.releaseSessionList(),super.disconnectedCallback()}willUpdate(){this.bindSessionList()}render(){let e=this.progressCard.error,t=this.progressCard.card,n=e?m`<div
class=${t?`callout info`:`board-widget__plugin-loading`}
data-test-id="session-progress-error"
role="alert"
>
<span
>${u(e===`access-denied`?`sessionProgressCard.widgetAccessDenied`:`sessionProgressCard.widgetUnavailable`)}</span
>
${e===`unavailable`?m`<button class="btn btn--sm" type="button" =${this.progressCard.retry}>
${u(`common.retry`)}
</button>`:null}
</div>`:p;if(e&&!t)return n;if(this.progressCard.loading)return m`<p class="board-widget__plugin-loading">
${u(`sessionProgressCard.widgetLoading`)}
</p>`;if(t===null)return m`<p class="board-widget__plugin-loading">
${u(`sessionProgressCard.widgetEmpty`)}
</p>`;let r=S(this.context?.gateway.snapshot??{},O(this.widget,this.session)),i=o(r.agentId),a=this.context?.sessions.listSnapshot(i).result?.sessions.find(e=>e.key===r.sessionKey&&(e.agentId??l(e.key)?.agentId)===r.agentId);return m`${n}${D(t,`board`,void 0,a?.status,a?.startedAt,a?.endedAt,x(a??{}))}`}bindSessionList(){let e=this.context;if(!this.isConnected||!e)return;let t=e.sessions,n=S(e.gateway.snapshot,O(this.widget,this.session)).agentId;if(!(this.active&&O(this.widget,this.session).sessionKey)){this.releaseSessionList();return}if(t===this.observedSessions&&n===this.observedTargetAgentId)return;this.releaseSessionList(),this.observedSessions=t,this.observedTargetAgentId=n;let r=o(n);this.unsubscribeList=t.subscribeList(r,()=>this.requestUpdate());let i=t.listSnapshot(r);this.requestUpdate(),!i.result&&!i.loading&&!i.error&&e.gateway.snapshot.phase===`connected`&&t.refreshList(r)}releaseSessionList(){this.unsubscribeList?.(),this.unsubscribeList=void 0,this.observedSessions=void 0,this.observedTargetAgentId=void 0}},b([v({context:f,subscribe:!0})],k.prototype,`context`,void 0),b([_({attribute:!1})],k.prototype,`widget`,void 0),b([_({attribute:!1})],k.prototype,`session`,void 0),b([_({attribute:!1})],k.prototype,`active`,void 0),customElements.get(`openclaw-session-progress-widget`)||customElements.define(`openclaw-session-progress-widget`,k)})))()}A();