openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 9.18 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{ta as t}from"./_4____________________________.js";import{$n as n,Ba as r,GN as i,Ix as a,JN as o,Lx as s,Ra as c,XM as l,er as u,fN as d,oS as f,pN as p,qN as m,sS as h,za as g,zx as _}from"./_2_____________________________.js";import{C as ee,J as te,O as v,U as ne,d as y,f as b,g as x,gt as S,j as C,l as w,m as T,s as E,u as D,v as O,x as k}from"./_6____________________.js";import{lr as A}from"./control-ui-boot-chat-styles-DMRbEm40.js";import{B as j,z as re}from"./markdown-runtime-CtlJb8xA.js";import{V as ie,z as ae}from"./control-ui-boot-chat-CqvkfPXD.js";import{a as M,i as N,r as P}from"./chat-attachment-preview-chip-4QygB_YJ.js";import{n as oe,t as se}from"./chat-pasted-text-8A_I1JBU.js";function ce(e){let n=/^data:([^,]*),(.*)$/s.exec(e);if(!n)return null;let r=n[1],i=n[2];try{return r.toLowerCase().includes(`;base64`)?new TextDecoder().decode(t(i)):decodeURIComponent(i.replace(/\+/g,`%20`))}catch{return null}}function le(e,t){return e.trim()?`${e.replace(/\s+$/u,``)}\n\n${t}`:t}function F(e,t){let n=a(e),i=n?ce(n):null;i&&t.onDraftChange&&(r(e,t),t.onDraftChange(le(t.getDraft?.()??t.draft??``,i)))}function I(e){let t=()=>e.controls.readSignal?.aborted?void 0:c(e.controls).find(t=>t.id===e.attachment.id),n=()=>e.attachment.fileName?.trim()?o(`chat.composer.removeNamedAttachment`,{name:e.attachment.fileName}):o(`chat.composer.removeAttachment`),i=()=>{t()&&!e.controls.disabled&&r(e.attachment,e.controls)},l=()=>(()=>{var n=L();return n._$$click=()=>{let n=t();n&&!e.controls.disabled&&F(n,e.controls)},y(n,()=>o(`chat.attachments.showInTextField`)),w(()=>e.controls.disabled,e=>{x(n,`disabled`,e)}),n})(),u=l(),f=C(P,{get label(){return n()},get disabled(){return e.controls.disabled},onClick:i});return C(se,{get src(){return a(e.attachment)??void 0},get sizeBytes(){return e.attachment.sizeBytes},get scope(){return e.attachment.id},onOpen:()=>{t()&&e.controls.onOpenSidebar?.({kind:`attachment`,attachmentKind:`document`,title:e.attachment.fileName??o(`chat.attachments.pastedText`),mimeType:`text/plain`,plainText:!0,sourceIdentity:e.attachment.id,resolveSource:()=>{let e=t();if(!e)return{status:`unavailable`};let n=s(e);return n?{status:`ready`,src:n,sizeBytes:e.sizeBytes}:{status:`unavailable`}},renderActions:()=>[b(l),(()=>{var t=R();return t._$$click=i,y(t,C(d,{name:`trash`})),w(()=>({e:n(),t:e.controls.disabled}),({e,t:n},r)=>{e!==r?.e&&x(t,`aria-label`,e),n!==r?.t&&x(t,`disabled`,n)}),t})()]})},composerAction:u,composerRemoveAction:f})}var L,R;function z(){return(z=e((()=>{D(),p(),f(),i(),_(),g(),M(),oe(),L=k(`<button class=chat-attachment-text-action type=button>`),R=k(`<button class="btn btn--sm"type=button>`),m(h),E([`click`])})))()}function B(e){let t=()=>s(e.attachment);return C(v,{get when(){return t()},children:t=>C(v,{get when(){return e.controls.onOpenImage},get fallback(){var n=G();return w(()=>({e:t(),t:e.alt}),({e,t},r)=>{e!==r?.e&&x(n,`src`,e),t!==r?.t&&x(n,`alt`,t)}),n},get children(){var n=W(),r=n.firstChild;return n._$$click=()=>e.controls.onOpenImage?.({src:t(),title:e.title}),T(()=>[e.buttonRef],n),w(()=>({e:o(`chat.imageLightbox.open`,{title:e.title}),t:t(),a:e.alt}),({e,t,a:i},a)=>{e!==a?.e&&x(n,`aria-label`,e),t!==a?.t&&x(r,`src`,t),i!==a?.a&&x(r,`alt`,i)}),n}})})}function V(e){let t,n;S(()=>{let r=t??n;return r?e.controls.registerBrowserAnnotationFocus?.(e.attachment.id,r):void 0});let i=()=>e.annotation.title.trim()||e.annotation.displayUrl.trim()||e.attachment.fileName||o(`chat.attachments.attachedFile`);var a=K(),s=a.firstChild,c=s.nextSibling.firstChild,l=c.nextSibling.firstChild;return y(s,C(B,{buttonRef:e=>{t=e},get attachment(){return e.attachment},get alt(){return o(`chat.composer.browserAnnotationPreview`)},get title(){return i()},get controls(){return e.controls}})),y(c,i),y(l,()=>o(e.annotation.markedRegionCount===1?`chat.composer.browserAnnotationRegion`:`chat.composer.browserAnnotationRegions`,{count:String(e.annotation.markedRegionCount)})),y(a,C(P,{buttonRef:e=>{n=e},get label(){return o(`chat.composer.removeBrowserAnnotation`,{name:i()})},get disabled(){return e.controls.disabled},class:`chat-attachment-remove chat-browser-annotation-card__remove`,onClick:()=>e.controls.onRemoveAttachment?e.controls.onRemoveAttachment(e.attachment):r(e.attachment,e.controls)}),null),w(()=>({e:e.attachment.id,t:`${o(`chat.composer.browserAnnotation`)}: ${i()}`,a:i()}),({e,t,a:n},r)=>{e!==r?.e&&x(a,`data-attachment-id`,e),t!==r?.t&&x(a,`aria-label`,t),n!==r?.a&&x(c,`title`,n)}),a}function H(e){let t=()=>e.entry.attachment,n=()=>e.entry.state===`reading`,i=()=>e.entry.state===`error`,a=()=>!!(e.entry.preparation||e.entry.errorMessage&&t().mimeType.startsWith(`video/`)),c=()=>o(e.entry.errorMessage??`chat.attachments.readFailed`,{names:t().fileName??o(`chat.attachments.attachedFile`),more:``}),l=()=>{let e=t().fileName;return e?.trim()?o(`chat.composer.removeNamedAttachment`,{name:e}):o(`chat.composer.removeAttachment`)};return C(v,{get when(){return t().browserAnnotation},get fallback(){return C(v,{get when(){return A(t())},get fallback(){var u=J(),d=u.firstChild,f=d.nextSibling,p=f.nextSibling;return y(u,(()=>{var r=b(()=>!!a());return()=>r()?C(N,{get attachment(){return t()},get videoPreparation(){return{state:i()?`error`:e.entry.preparation??`offer`,progress:e.entry.progress}},get metadata(){return b(()=>e.entry.preparation===`compressing`)()?(()=>{var t=Y();return y(t,()=>o(`chat.attachments.compressing`,{progress:String(Math.floor((e.entry.progress??0)*100))})),t})():(()=>{var t=X(),n=t.firstChild,r=n.firstChild;return y(t,(()=>{var e=b(()=>!!i());return()=>e()?(()=>{var e=Z();return y(e,c),e})():i()})(),n),n._$$click=()=>e.entry.read.compress?.(),y(r,()=>o(i()?`chat.attachments.retryCompression`:`chat.attachments.compressToFit`)),w(()=>({e:i()?c():o(`chat.attachments.compressionHint`),t:e.controls.disabled}),({e,t},r)=>{e!==r?.e&&x(n,`title`,e),t!==r?.t&&x(n,`disabled`,t)}),t})()}}):b(()=>!!n())()?void 0:b(()=>!!(t().mimeType.startsWith(`image/`)&&s(t())))()?C(B,{get attachment(){return t()},get alt(){return t().fileName?.trim()||o(`chat.composer.attachmentPreview`)},get title(){return t().fileName?.trim()||o(`chat.imageLightbox.untitled`)},get controls(){return e.controls}}):C(N,{get attachment(){return t()}})})(),d),y(u,C(v,{get when(){return b(()=>!!n())()?!a():n()},get children(){var t=q(),n=t.firstChild.nextSibling.firstChild.nextSibling.firstChild;return w(()=>({e:e.entry.progress===void 0?`true`:`false`,t:e.entry.progress===void 0?void 0:`scaleX(${e.entry.progress})`}),({e,t:r},i)=>{e!==i?.e&&x(t,`data-indeterminate`,e),r!==i?.t&&O(n,`transform`,r)}),t}}),f),y(u,C(P,{get label(){return l()},get disabled(){return e.controls.disabled},onClick:()=>{e.controls.attachmentReads?.remove(e.entry.read),r(t(),e.controls)}}),p),w(()=>({e:!!a(),t:!!t().mimeType.startsWith(`video/`),a:!t().mimeType.startsWith(`image/`),o:!!i(),i:n()&&e.entry.preparation!==`offer`?`true`:`false`}),({e,t,a:n,o:r,i},a)=>{e!==a?.e&&u.classList.toggle(`chat-attachment-thumb--preparation`,e),t!==a?.t&&u.classList.toggle(`chat-attachment-thumb--video`,t),n!==a?.a&&u.classList.toggle(`chat-attachment-thumb--file`,n),r!==a?.o&&u.classList.toggle(`chat-attachment-thumb--error`,r),i!==a?.i&&x(u,`aria-busy`,i)}),u},get children(){return C(I,{get attachment(){return t()},get controls(){return e.controls}})}})},children:n=>C(V,{get attachment(){return t()},get annotation(){return n()},get controls(){return e.controls}})})}function U(e){var t=Q(),n=t.firstChild,r=n.nextSibling,i=u(!0);return(typeof i==`function`||Array.isArray(i))&&T(()=>i,t),y(t,C(ae,te(()=>e.controls)),n),y(t,C(ee,{get each(){return e.entries.filter(({attachment:e})=>!e.selectionAnnotation)},keyed:e=>e.attachment.id,children:t=>C(H,{get entry(){return t()},get controls(){return e.controls}})}),r),w(()=>e.controls.disabled?`true`:void 0,e=>{x(t,`data-disabled`,e)}),t}var W,G,K,q,J,Y,X,Z,Q;function $(){return($=e((()=>{D(),ne(),n(),l(),f(),re(),i(),_(),g(),M(),z(),ie(),W=k(`<button type=button class="chat-message-image-button chat-attachment-image-button"><img>`),G=k(`<img>`),K=k(`<div class="chat-attachment-thumb chat-attachment-thumb--browser-annotation"role=group><div class=chat-browser-annotation-card__preview></div><div class="chat-attachment-file__body chat-browser-annotation-card__body"><span class="chat-attachment-file__name chat-browser-annotation-card__identity"></span><span class="chat-attachment-file__meta chat-browser-annotation-card__meta"><span>`),q=k(`<span class=chat-attachment-loading data-state=reading aria-hidden=true><span class=chat-attachment-loading__icon></span><span class=chat-attachment-loading__body><span class=chat-attachment-loading__title></span><span class=chat-attachment-loading__line><span>`),J=k(`<div class=chat-attachment-thumb><!><!><!>`),Y=k(`<span class=chat-attachment-file__type role=status>`),X=k(`<span class=chat-attachment-file__type><button type=button class=chat-attachment-compress><span>`),Z=k(`<span class=sr-only role=status>`),Q=k(`<div class=chat-attachments-preview><!><!>`),m(h),m(j),E([`click`])})))()}$();export{U as AttachmentPreviewStrip};