UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 5.57 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Ja as t,Ln as n,Un as r,Wa as i,lo as a}from"./control-ui-connection-Bfj9beF_.js";import{RC as o,bc as s,ej as c,hj as l,nj as u,vj as d,yc as f,zC as p}from"./control-ui-boot-shared-DFTSUQQ0.js";import{B as m,F as h,P as g,U as _,f as v,g as y,gt as b,l as x,m as S,u as C,v as w,x as T}from"./solid-runtime-C416s-HC.js";import{n as E,r as D,t as O}from"./session-background-contrast-84eNTaMy.js";import{n as k,r as A,t as j}from"./session-background-image-Cw3lDRn-.js";function M(e){let t=null,n=[],r=[];b(()=>(t=typeof ResizeObserver>`u`?null:new ResizeObserver(o),n.forEach(e=>t?.observe(e)),s));function i(t){let n;for(let i of r)i.kind===t&&e.parentElement?.contains(i.element)&&(!n||n.compareDocumentPosition(i.element)&Node.DOCUMENT_POSITION_PRECEDING)&&(n=i.element);return n}function a(a,c=[]){if(r=c,!a){s();return}let l=[e.parentElement,i(`composer`),i(`welcome`)].filter(e=>!!e);(l.length!==n.length||l.some((e,t)=>e!==n[t]))&&(s(),n=l,n.forEach(e=>t?.observe(e))),o()}function o(){let t=i(`composer`),n=e.getBoundingClientRect(),r=t?.getBoundingClientRect(),a=i(`scroll`)?.scrollTop??0,o=r?Math.max(0,r.top-n.top+a+r.height/2):n.height*.55,s=Math.round(o)+`px`;e.style.getPropertyValue(`--session-background-fade-end`)!==s&&e.style.setProperty(`--session-background-fade-end`,s)}function s(){t?.disconnect(),n=[]}return{update:a}}function N(e,t){if(e)return(t===`preview`||(t===`new-session`?e.showOnNewSession:e.showInSessions))&&e.visibility>0?e.source:{kind:`none`}}function P(e){let t=e.host,n=u(),o=()=>e.context??n,c=M(t),[l,f]=m(0),_=()=>f(e=>e+1),[C,T]=m(),E,k=typeof matchMedia==`function`?matchMedia(`(forced-colors: active), (prefers-contrast: more), (prefers-reduced-transparency: reduce)`):null,P=null,R=null,z=null,B=``,V=0,H=()=>e.surface===`preview`?e.preferenceOverride??o()?.theme.settings.background:o()?.theme.settings.background,U=()=>{let t=o(),n=t?.gateway.snapshot.selfUser?.id;if(!(t&&n&&r(t.gateway.connection.gatewayUrl,n)===null))return N(H(),e.surface)},W=()=>{let t=U();return o()&&e.presented&&!k?.matches&&t?.kind===`custom`?j(o(),t.assetId):null},G=e=>{let n=t.isConnected&&e!==`preview`?t.closest(`.new-session-page, .sidebar-region`):null;z!==n&&(z?.removeAttribute(`data-background-custom`),z?.removeAttribute(`data-background-painted`),z=n),n?.toggleAttribute(`data-background-custom`,t.hasAttribute(`data-custom`)),n?.toggleAttribute(`data-background-painted`,t.hasAttribute(`data-painted`))},K=(n=e.surface)=>{let r=P;P=null,r?.controller.abort(),T(void 0),r?.url&&(E?.removeAttribute(`src`),t.removeAttribute(`data-painted`),G(n),URL.revokeObjectURL(r.url))},q=(e,t,n)=>{P&&(P.context!==e||P.client!==e?.gateway.snapshot.client||P.identity!==t)&&K(n)},J=h(()=>d(o(),{read:e=>e,equality:`revision`,subscribe:(t,n)=>{let r=()=>{q(o(),W(),e.surface),n()},i=[t?.theme.subscribe(r),t?.gateway.subscribe(r)];return()=>i.forEach(e=>e?.())}}));b(()=>p(()=>{P?.url||(R=null,K(),_())})),b(()=>{let e=s(t.ownerDocument,[`data-theme`,`data-theme-mode`,`data-theme-background`],_),n=k&&a(k,`change`,()=>{K(),_()});return queueMicrotask(()=>{t.isConnected&&_()}),()=>{e(),n?.(),P?.controller.abort(),P?.url&&URL.revokeObjectURL(P.url),P=null,z?.removeAttribute(`data-background-custom`),z?.removeAttribute(`data-background-painted`)}});let Y=h(()=>{l(),J().revision();let n=U(),r=H()?.presentation===`full-bleed`,a=e.presented&&!k?.matches;if(a&&n?.kind===`custom`&&t.isConnected){let e=O(t);B!==e&&(V=D(t),B=e)}let s=H()?.visibility??0,c=t.ownerDocument.documentElement.dataset.themeBackground===`plugin`;return{source:n,fullBleed:r,visible:a,opacity:n?.kind===`theme`?r&&!c?s*L:Math.min(1,s/i.visibility):V*s*(o()?.theme.resolvedMode===`light`?.65:1),surface:e.surface,context:o(),identity:W(),layoutTargets:e.layoutTargets}});return g(()=>({...Y(),image:C()}),e=>{if(t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`data-presentation`,e.fullBleed?`full-bleed`:`faded`),t.setAttribute(`data-surface`,e.surface),t.toggleAttribute(`data-custom`,e.visible&&e.source?.kind===`custom`),q(e.context,e.identity,e.surface),t.toggleAttribute(`data-painted`,!!(e.visible&&e.opacity>0&&(e.source?.kind===`theme`||e.source?.kind===`custom`&&e.image))),G(e.surface),c.update((e.surface===`new-session`||e.surface===`preview`)&&e.visible&&!!(e.source&&e.source.kind!==`none`)&&!e.fullBleed,e.layoutTargets),R!==e.identity&&(R=null),!t.isConnected||!e.context||!e.identity||R===e.identity||P||e.source?.kind!==`custom`)return;let n={identity:e.identity,context:e.context,client:e.context.gateway.snapshot.client,controller:new AbortController,url:null};P=n,A(e.context,e.source.assetId,{signal:n.controller.signal,isCurrent:()=>t.isConnected&&P===n}).then(e=>{P!==n||!t.isConnected||W()!==n.identity?URL.revokeObjectURL(e):(n.url=e,T(e))}).catch(()=>{})}),v(()=>v(()=>!!(Y().visible&&Y().source&&Y().source?.kind!==`none`))()?v(()=>Y().source?.kind===`theme`)()?(()=>{var e=F();return x(()=>String(Y().opacity),t=>{w(e,`opacity`,t)}),e})():v(()=>!!C())()?(()=>{var e=I();return e.addEventListener(`error`,()=>{R=P?.identity??null,K(),_()}),S(()=>e=>E=e,e),x(()=>({e:String(Y().opacity),t:C()}),({e:t,t:n},r)=>{t!==r?.e&&w(e,`opacity`,t),n!==r?.t&&y(e,`src`,n)}),e})():void 0:void 0)}var F,I,L;function R(){return(R=e((()=>{C(),_(),t(),o(),n(),c(),f(),l(),E(),k(),F=T(`<div class="session-background__image session-background__image--theme">`),I=T(`<img class=session-background__image alt decoding=async draggable=false>`),L=.7})))()}R();export{P as SessionBackgroundContent};