openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 3.27 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Cw as t,GN as n,JN as r,Kk as i,an as a,qk as o,sn as s,ww as c}from"./_2_____________________________.js";import{F as l,U as u,g as d,gt as f,l as p,m,s as h,u as g,x as _}from"./_6____________________.js";function v(e){let n=()=>e.options(),a=l(()=>({width:n().chatMessageMaxWidth??void 0,transcript:n().getTranscriptElement?.()}),{equals:(e,t)=>e.width===t.width&&e.transcript===t.transcript}),o=i(),c,u=()=>c?.parentElement,h=()=>c?.previousElementSibling,g=!1,_=!1,v,b=null,x=480,S=!0,C=()=>{let e=u().parentElement;for(;e.parentElement&&getComputedStyle(e).display===`contents`;)e=e.parentElement;return e},w=e=>{let t=C(),n=getComputedStyle(t),r=getComputedStyle(u()),i=Number.parseFloat(r.getPropertyValue(`--chat-composer-inline-inset`))||(Number.parseFloat(r.getPropertyValue(`--chat-composer-side-inset`))||36)/2,a=t.clientWidth-Number.parseFloat(n.paddingLeft)-Number.parseFloat(n.paddingRight)-2*i;return e?.isConnected&&(a=Math.min(a,s(e))),Math.max(0,a)},T=e=>{let t=w(n().getTranscriptElement?.());return Math.round(Math.max(Math.min(x,t),Math.min(t,e)))},E=()=>!g&&c?.isConnected&&!!n().onComposerWidthChange,D=e=>{E()&&(b=e,n().onComposerWidthChange?.(e))},O=e=>{let t=u(),n=h();if(g||!c?.isConnected||!t||!n)return;let r=w(e),i=n.getBoundingClientRect(),a=t.getBoundingClientRect();c.style.top=`${i.top-a.top+18}px`,c.style.bottom=`${Math.max(0,a.bottom-i.bottom)+18}px`;let o=Math.round(a.width);S&&r>=480&&(x=Math.min(480,o),S=!1),c.setAttribute(`aria-valuenow`,String(o)),c.setAttribute(`aria-valuemin`,String(Math.min(x,r,o))),c.setAttribute(`aria-valuemax`,String(Math.round(r)))},k=t(a,e=>{if(!e)return;let t=e.width;t!==b&&(v=t,S=!0),b=t,O(e.transcript)},{targets:e=>[u(),h(),u()&&C(),e?.transcript].filter(e=>!!e),changeTiming:`sync`});f(()=>(k(),()=>{g=!0,o.cancel()}));let A=e=>{if(!E()||e.button!==0||!e.isPrimary||_)return;e.preventDefault(),e.stopPropagation();let t=u(),n=t.closest(`.chat, .new-session-page`)??t.parentElement,r=t.getBoundingClientRect().width,i=e.clientX,a=n.style.getPropertyValue(`--chat-thread-max-width`),s=r,l=!1,d=e=>{_=!1,a?n.style.setProperty(`--chat-thread-max-width`,a):n.style.removeProperty(`--chat-thread-max-width`),e&&l&&Math.abs(s-r)>=3&&D(`${s}px`)};_=o.start(e,c,{move:e=>{let t=e.clientX-i;!l&&Math.abs(t)<3||(l=!0,s=T(r-2*t),n.style.setProperty(`--chat-thread-max-width`,`${s}px`))},end:()=>d(!0),cancel:()=>d(!1)})};var j=y();return j._$$keydown=e=>{if(!(!E()||e.ctrlKey||e.altKey||e.metaKey||_)){if(e.key===`Enter`||e.key===`Home`)e.preventDefault(),D(v);else if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault();let t=u().getBoundingClientRect().width,n=T(t+(e.key===`ArrowLeft`?20:-20));Math.abs(n-t)>=1&&D(`${n}px`)}}},j._$$dblclick=e=>{E()&&(e.preventDefault(),e.stopPropagation(),o.cancel(),D(v))},j._$$pointerdown=A,m(()=>e=>{c=e,k()},j),p(()=>r(`common.resizeMessageWidth`),e=>{d(j,`aria-label`,e)}),j}var y;function b(){return(b=e((()=>{g(),u(),n(),c(),o(),a(),y=_(`<div class=agent-chat__composer-width-edge role=separator aria-orientation=vertical tabindex=0 style=position:absolute;left:-8px;width:8px;cursor:ew-resize;touch-action:none>`),h([`pointerdown`,`dblclick`,`keydown`])})))()}b();export{v as ResizeEdge};