UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 1.8 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Ja as t,Tr as n,Ya as r,do as i,po as a}from"./control-ui-connection-Bfj9beF_.js";import{MC as o,PC as s,jC as c}from"./control-ui-boot-shared-DFTSUQQ0.js";function l(e,t){return`${n(t)}${u}${encodeURIComponent(e)}`}var u;function d(){return(d=e((()=>{u=`/__openclaw__/users/background/`})))()}function f(e,t){let n=e.gateway,a=n.snapshot,o=a.selfUser?.id;if(!r(t)||a.phase!==`connected`||!a.client||!o)return null;let c=s({hello:a.hello,settings:n.connection,password:n.connection.password}),u=new URL(i(n.connection.gatewayUrl));u.protocol=u.protocol.replace(/^ws/u,`http`);let d=u.origin===location.origin?e.resourceBasePath:``,f=new URL(l(t,d),u.origin).href;return{client:a.client,auth:c,url:f,identity:JSON.stringify([n.connectionRevision,n.connection.gatewayUrl,o,f,c])}}function p(e,t){return f(e,t)?.identity??null}async function m(e,t,n){let r=f(e,t);if(!r)throw new DOMException(`Background image has no current profile`,`AbortError`);let i=AbortSignal.any([n.signal,...e.lifecycleAbortSignal?[e.lifecycleAbortSignal]:[],AbortSignal.timeout(3e4)]),a=()=>{let a=f(e,t);return!i.aborted&&n.isCurrent()&&a?.client===r.client&&a.identity===r.identity},o=()=>{if(i.throwIfAborted(),!a())throw new DOMException(`Background image belongs to a retired profile`,`AbortError`)},s=await c(r.url,{credentials:`include`,cache:`no-store`,redirect:`error`,signal:i},r.auth,a);if(o(),!s.ok||s.headers.get(`content-type`)?.split(`;`,1)[0]?.trim()!==`image/jpeg`)throw s.body?.cancel(),Error(`Background image unavailable`);let l=await s.blob();if(o(),!l.size||l.size>2097152)throw Error(`Background image exceeds its serving limit`);return URL.createObjectURL(l)}function h(){return(h=e((()=>{t(),d(),o(),a()})))()}export{h as n,m as r,p as t};