openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 3.46 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{BA as t,dj as n,ds as r,mj as i,n_ as a,pj as o,r_ as s,us as c,zA as l}from"./control-ui-boot-shared-DFTSUQQ0.js";import{B as u,C as d,H as f,O as p,Rt as m,U as h,a as g,d as _,g as v,gt as y,j as b,l as x,s as S,u as C,x as w}from"./solid-runtime-C416s-HC.js";import{Fo as T,Po as E}from"./control-ui-boot-chat-DewxEbIm.js";function D(e){let t=`chat-source-${f()}`,[n,r]=u(!1),[a,o]=u(0),[s,d]=u(),h=E(()=>o(e=>e+1));y(()=>(r(!0),()=>h.dispose()));let S=()=>{if(!n())return null;a();let t=e.fetchFavicon?h.read(new URL(e.source.url).hostname,e.fetchFavicon):null;return t&&t!==s()?t:null},C;var w=M();return _(w,b(c,{id:t,triggerId:`${t}:trigger`,triggerClass:`chat-source-card`,triggerAriaLabel:null,get trigger(){return[(()=>{var t=N();return _(t,()=>e.source.title),t})(),(()=>{var t=P(),n=t.firstChild;return _(n,b(p,{get when(){return S()},get fallback(){return b(l,{name:`globe`})},children:e=>(()=>{var t=F();return t.addEventListener(`error`,()=>d(e())),x(()=>e(),e=>{v(t,`src`,e)}),t})()})),_(t,()=>e.source.domain,null),t})()]},get label(){return e.source.title},class:`chat-source-popover`,placement:`bottom-start`,ref:t=>{C=t,t.overlay.surface.dataset.sourceUrl=e.source.url},get children(){var t=j(),n=t.firstChild,r=n.firstChild,a=r.nextSibling,o=n.nextSibling,s=o.firstChild,c=m();return _(r,()=>e.source.domain),a._$$click=()=>C?.overlay.request(!1,`return`),_(a,b(l,{name:`x`})),_(t,b(p,{get when(){return e.source.excerpt},get fallback(){var e=I();return _(e,()=>i(`chat.messages.sourcePreviews.unavailable`)),e},get children(){return[(()=>{var t=k();return _(t,()=>i(e.source.excerptKind===`page`?`chat.messages.sourcePreviews.pageExcerpt`:`chat.messages.sourcePreviews.searchSnippet`)),t})(),(()=>{var t=A();return _(t,()=>e.source.excerpt),t})()]}}),o),_(o,()=>i(`chat.messages.sourcePreviews.open`),s),_(s,b(l,{name:`externalLink`})),x(()=>({e:e.source.title,t:i(`common.close`),a:e.source.url}),({e,t:n,a:r},i)=>{e!==i?.e&&v(t,`aria-label`,e),n!==i?.t&&v(a,`aria-label`,n),r!==i?.a&&v(o,`href`,r),g(o,c)}),t}})),w}function O(e){return b(p,{get when(){return e.sources.length>0},get children(){var t=L(),n=t.firstChild,r=n.firstChild,a=r.nextSibling;return t._$owner=m(),_(r,()=>i(`chat.messages.sourcePreviews.label`)),_(a,b(d,{get each(){return e.sources},keyed:e=>e.url,children:t=>b(D,{get source(){return t()},get fetchFavicon(){return e.fetchFavicon}})})),x(()=>i(`chat.messages.sourcePreviews.label`),e=>{v(n,`aria-label`,e)}),t}})}var k,A,j,M,N,P,F,I,L;function R(){return(R=e((()=>{C(),h(),t(),r(),a(),n(),T(),k=w(`<div class=chat-source-popover__kind>`),A=w(`<p class=chat-source-popover__excerpt>`),j=w(`<section><div class=chat-source-popover__header><span class=chat-source-card__domain></span><button class=chat-source-popover__close type=button></button></div><a class=chat-source-popover__open target=_blank rel="noopener noreferrer"><span aria-hidden=true>`),M=w(`<div class=chat-source-strip__item>`),N=w(`<span class=chat-source-card__title>`),P=w(`<span class=chat-source-card__domain><span class=chat-source-card__icon aria-hidden=true>`),F=w(`<img width=14 height=14 decoding=async alt>`),I=w(`<p class=chat-source-popover__unavailable>`),L=w(`<openclaw-chat-sources><div class=chat-source-strip role=group><div class=chat-source-strip__label></div><div class=chat-source-strip__cards>`,1),o(s),S([`click`])})))()}R();export{O as ChatSourcePreviews};