UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 3.85 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Qt as t,Xt as n,et as r,tt as i}from"./control-ui-connection-Bfj9beF_.js";import{E_ as a,J as o,T_ as s,Y as c,dj as l,mj as u,pj as d}from"./control-ui-boot-shared-DFTSUQQ0.js";import{d as f,f as p,g as m,l as h,m as g,o as _,p as v,s as y,u as b,x}from"./solid-runtime-C416s-HC.js";import{n as S,r as C}from"./sidebar-attention-focus-JGT2Nou0.js";function w(e){switch(e.phase){case`guidance`:return u(e.reason===`role`?`connection.scopeUpgrade.roleGuidance`:`connection.scopeUpgrade.guidance`);case`available`:return u(`connection.scopeUpgrade.limited`);case`requesting`:return u(`connection.scopeUpgrade.requesting`);case`pending`:return u(`connection.scopeUpgrade.pending`,{command:`openclaw devices approve ${e.requestId}`});case`rejected`:return u(e.expired?`connection.scopeUpgrade.expired`:`connection.scopeUpgrade.rejected`);case`error`:return u(`connection.scopeUpgrade.error`,{error:e.message})}return e}function T(e){let t=()=>e.state.phase===`error`?e.state.retryable:e.state.phase===`pending`||e.state.phase===`rejected`,n=()=>e.inbox?`sidebar-issues-panel__action sidebar-issues-panel__action--primary`:`btn primary`;return p(()=>p(()=>e.state.phase===`available`||e.state.phase===`requesting`)()?(()=>{var t=E();t._$$click=()=>e.onRequest();var r=C();return(typeof r==`function`||Array.isArray(r))&&g(()=>r,t),f(t,()=>u(e.state.phase===`available`?`connection.scopeUpgrade.request`:`connection.scopeUpgrade.requestingAction`)),h(()=>({e:v(n()),t:e.state.phase===`requesting`}),({e,t:n},r)=>{_(t,e,r?.e),n!==r?.t&&m(t,`disabled`,n)}),t})():p(()=>!!(t()||e.state.phase===`error`))()?[p(()=>p(()=>!!t())()?(()=>{var t=E();t._$$click=()=>e.onRetry();var r=C();return(typeof r==`function`||Array.isArray(r))&&g(()=>r,t),f(t,()=>u(`connection.scopeUpgrade.retry`)),h(()=>v(n()),(e,n)=>{_(t,e,n)}),t})():null),(()=>{var t=E();t._$$click=()=>e.onCancel();var n=C();return(typeof n==`function`||Array.isArray(n))&&g(()=>n,t),f(t,()=>u(`connection.scopeUpgrade.cancel`)),h(()=>v(e.inbox?`sidebar-issues-panel__action`:`btn`),(e,n)=>{_(t,e,n)}),t})()]:null)}var E;function D(){return(D=e((()=>{b(),s(),l(),S(),E=x(`<button type=button>`),d(a),y([`click`])})))()}var O;function k(){return(k=e((()=>{i(),t(),o(),O=class{constructor(e,t){this.onChange=t,this.operation=null,this.value={phase:`hidden`},this.current=e,this.sync(e)}get state(){return this.value}sync(e){this.current=e;let t=e.client,n=c(e);!t||n.phase!==`available`?(this.retireOperation(),this.setState(n)):(this.operation&&this.operation.client!==t&&(this.retireOperation(),this.setState({phase:`available`})),(this.value.phase===`hidden`||this.value.phase===`guidance`)&&this.setState({phase:`available`}))}request(){this.start(!1)}retry(){this.start(!0)}cancel(){this.retireOperation(),this.setState(c(this.current))}dispose(){this.retireOperation()}start(e){let t=this.current.client;if(!t||c(this.current).phase!==`available`)return;if(this.operation){if(!e)return;this.retireOperation()}let i={client:t};this.operation=i,this.setState({phase:`requesting`}),t.requestScopeUpgrade({onPending:e=>{this.isCurrent(i)&&this.setState({phase:`pending`,requestId:e})}}).then(e=>{this.isCurrent(i)&&e.status!==`approved`&&this.setState({phase:`rejected`,requestId:e.requestId,expired:e.status===`expired`})}).catch(e=>{!this.isCurrent(i)||e instanceof Error&&e.name===`AbortError`||this.setState({phase:`error`,message:n(e),retryable:!(e instanceof r)||e.retryable})}).finally(()=>{this.isCurrent(i)&&(this.operation=null)})}isCurrent(e){return this.operation===e&&this.current.client===e.client}retireOperation(){let e=this.operation;this.operation=null,e?.client.cancelScopeUpgrade()}setState(e){JSON.stringify(this.value)!==JSON.stringify(e)&&(this.value=e,this.onChange())}}})))()}export{w as a,D as i,k as n,T as r,O as t};