UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

2 lines • 8.94 kB
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./dist-CKGuiyqz.js","./code-language-DiXU7oGo.js","./control-ui-connection-D5QrEAFW.css"])))=>i.map(i=>d[i]); import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{lu as t,uu as n}from"./control-ui-connection-Bfj9beF_.js";import{BA as r,bh as i,dj as a,mj as o,pj as s,xh as c,zA as l}from"./control-ui-boot-shared-DFTSUQQ0.js";import{B as u,C as d,Dt as f,F as p,O as m,U as h,d as g,f as _,g as v,gt as y,j as b,l as x,o as S,p as C,s as w,u as T,x as E}from"./solid-runtime-C416s-HC.js";import{Sl as D,_l as O}from"./control-ui-boot-chat-DewxEbIm.js";import{dt as k,ut as A}from"./control-ui-boot-chat-styles-CEPkk0Pv.js";import{n as j,t as M}from"./en-chat-session-optional-iBUVV79A.js";function N(){return{remaining:z}}function P(e){let t=Array.from(e.trim().replace(/\s+/gu,` `)),n=new Map;for(let e=0;e<t.length;e++){let r=t[e]+(t[e+1]??``);n.set(r,(n.get(r)??0)+1)}return n}function F(e,t=N()){let n=[];for(let r=0;r<e.length;){let i=e[r];if(i.kind!==`add`&&i.kind!==`del`){n.push({kind:`span`,line:i}),r++;continue}let a=[],o=[];for(;r<e.length;){let t=e[r];if(t.kind===`del`)a.push(t);else if(t.kind===`add`)o.push(t);else break;r++}let s=a.length*o.length,c=a.reduce((e,t)=>e+t.text.length,0),l=o.reduce((e,t)=>e+t.text.length,0),u=s+c*o.length+c+l;if(!s||s>R||u>t.remaining||[...a,...o].some(e=>e.text.length>B)){for(let e=0;e<Math.max(a.length,o.length);e++)n.push({kind:`pair`,left:a[e],right:o[e]});continue}t.remaining-=u;let d=a.map(e=>P(e.text)),f=o.map(e=>P(e.text)),p=e=>[...e.values()].reduce((e,t)=>e+t,0),m=d.map(p),h=f.map(p),g=o.length+1,_=new Float64Array((a.length+1)*g),v=new Float64Array(_.length);for(let e=a.length-1;e>=0;e--)for(let t=o.length-1;t>=0;t--){let n=0;for(let[r,i]of d[e])n+=Math.min(i,f[t].get(r)??0);let r=m[e]+h[t],i=r?2*n/r:1,a=i>=.5?i:0,o=e*g+t;v[o]=a,_[o]=Math.max(_[o+g],_[o+1],a?a+_[o+g+1]:0)}let y=0,b=0;for(;y<a.length||b<o.length;){let e=y*g+b;y<a.length&&b<o.length&&v[e]>0&&_[e]===v[e]+_[e+g+1]?n.push({kind:`pair`,left:a[y++],right:o[b++]}):y<a.length&&(b===o.length||_[e+g]>=_[e+1])?n.push({kind:`pair`,left:a[y++]}):n.push({kind:`pair`,right:o[b++]})}}return n}function I(e,t,n){let r=e.at(-1);r?.to===t?r.to=n:e.push({from:t,to:n})}function L(e){let t=new Map,n=H;for(let r of e){if(r.kind!==`pair`||!r.left||!r.right)continue;let e=r.left,i=r.right;if(e.text.length>B||i.text.length>B)continue;let a=e=>e.match(/\s+|[\p{L}\p{M}\p{N}_]+|[^\s\p{L}\p{M}\p{N}_]/gu)??[],o=a(e.text),s=a(i.text),c=0;for(;c<o.length&&o[c]===s[c];)c++;let l=o.length,u=s.length;for(;l>c&&u>c&&o[l-1]===s[u-1];)l--,u--;let d=o.slice(c,l),f=s.slice(c,u),p=(d.length+1)*(f.length+1);if(p>V||p>n)continue;n-=p;let m=[],h=[],g=o.slice(0,c).join(``).length,_=g;D(d,f,(e,t)=>{e===`ctx`?(g+=t.length,_+=t.length):e===`del`?(I(m,g,g+t.length),g+=t.length):(I(h,_,_+t.length),_+=t.length)}),m.length&&t.set(e,m),h.length&&t.set(i,h)}return t}var R,z,B,V,H;function U(){return(U=e((()=>{O(),R=4096,z=262144,B=2048,V=65536,H=262144})))()}function ee(e,t){let n=new Map,r=[0],i=[0],a=[0],o=[0];e.forEach((e,t)=>{let s=e.kind===`pair`?e.left:e.line,c=e.kind===`pair`?e.right:e.line;s&&n.set(s,t),c&&n.set(c,t),r.push(r[t]+Number(!!s)),i.push(i[t]+Number(!!c)),a.push(a[t]+Number(c?.kind===`add`)),o.push(o[t]+Number(s?.kind===`del`))});let s=new Map;for(let r of t){let t=n.get(r.start),i=n.get(r.end);if(t===void 0||i===void 0||i<=t)continue;let c=t+`:`+i,l=s.get(c),u=r.side===`old`?1:2;if(l)l.sides|=u,l.fold.function||=r.function;else{let n=e[t];s.set(c,{sides:u,fold:{key:n.kind===`span`?n.line:n.right??n.left,from:t,to:i,function:r.function,count:i-t,added:a[i+1]-a[t+1],removed:o[i+1]-o[t+1]}})}}let c=[...s.values()].filter(({fold:e,sides:t})=>t===3||(t===1?i:r)[e.to+1]===(t===1?i:r)[e.from+1]).map(({fold:e})=>e).toSorted((e,t)=>e.from-t.from||t.to-e.to),l=[],u=[];for(let e of c){for(;u.length&&u.at(-1).to<e.from;)u.pop();u.length&&(e.to>u.at(-1).to||e.from===u.at(-1).from)||(l.push(e),u.push(e))}return l}function W(e){let n=p(()=>e.lines),[r,i]=u(e=>{let t=new Set(n());return new Set([...e??[]].filter(e=>t.has(e)))}),a=p(()=>e.rows??F(e.lines)),o=p(()=>e.wordDiffs===!1?null:L(a())),s=p(()=>({lines:n(),path:e.file.path,oldPath:e.file.oldPath??e.file.path}),{equals:(e,t)=>e.lines===t.lines&&e.path===t.path&&e.oldPath===t.oldPath}),[c,l]=u(null);function f(){return b(m,{get when(){return _(()=>e.active===!1)()?null:s()},keyed:!0,children:e=>(y(()=>{if(c()?.source===e)return;let n=!0;return t(async()=>{let{analyzeDiffSyntax:e}=await import(`./chat-diff-highlight.runtime-DxtrDSKd.js`);return{analyzeDiffSyntax:e}},__vite__mapDeps([0,1,2]),import.meta.url).then(async({analyzeDiffSyntax:t})=>{if(!n)return;let r=await t(e.lines,e.path,e.oldPath);n&&l({source:e,...r})}).catch(()=>void 0),()=>{n=!1}}),null)})}let h=p(()=>{let e=c();return e?.source===s()?e:null}),v=p(()=>h()?.highlighted??new Map),w=p(()=>h()?.folds??[]),T=p(()=>{let e=new Map(v());for(let[t,n]of o()??[]){let r=[],i=0,a=0;for(let e of v().get(t)??[{text:t.text,classes:``}]){let o=i+e.text.length,s=i;for(;s<o;){let c=n[a];if(c&&c.to<=s){a++;continue}let l=c&&c.from<=s,u=Math.min(o,c?l?c.to:c.from:o);r.push({text:e.text.slice(s-i,u-i),classes:[e.classes,l?`chat-diff__change--`+t.kind:``].filter(Boolean).join(` `)}),s=u}i=o}e.set(t,r)}return e}),E=p(()=>ee(a(),w()));return{SyntaxLifetime:f,visibility:p(()=>{let t=new Set,n=new Map,i=new Map,o=new Map(e.lines.map((e,t)=>[e,t])),s=[],c=new Map,l=-1,u=0;for(let e=0;e<a().length;e++){let d=a()[e],f=d.kind===`span`?[d.line]:[d.left,d.right].filter(e=>!!e);for(;u<E().length&&E()[u].from<e;)u++;let p=E()[u]?.from===e?E()[u]:void 0;if(e<=l)f.forEach(e=>t.add(e));else if(s.push(d),p&&(f.forEach(e=>n.set(e,p)),r().has(p.key))){l=p.to;let e=f.reduce((e,t)=>o.get(e)>o.get(t)?e:t);i.set(e,p),c.set(d,p)}}return{lines:e.lines.filter(e=>!t.has(e)),rows:s,starts:n,placeholders:i,rowPlaceholders:c}}),closed:r,toggle:e=>i(t=>{let n=new Set(t);return n.has(e.key)?n.delete(e.key):n.add(e.key),n}),collapse:e=>i(new Set(E().filter(t=>!e||t.function).map(e=>e.key))),expand:()=>i(new Set),renderLine:e=>_(()=>_(()=>!!T().has(e))()?b(d,{get each(){return T().get(e)},children:e=>e.classes?(()=>{var t=q();return g(t,()=>e.text),x(()=>C(e.classes),(e,n)=>{S(t,e,n)}),t})():e.text}):e.text)}}function G(e){let t=()=>e.presentation.visibility().starts.get(e.line);return _(()=>_(()=>!!t())()?(()=>{var n=J();return n._$$click=()=>e.presentation.toggle(t()),g(n,b(l,{get name(){return e.presentation.closed().has(t().key)?`chevronRight`:`chevronDown`}})),x(()=>({e:o(e.presentation.closed().has(t().key)?`chat.sessionDiff.expandCodeRegion`:`chat.sessionDiff.collapseCodeRegion`,{line:String(e.line.lineNo??``)}),t:e.presentation.closed().has(t().key)?`false`:`true`}),({e,t},r)=>{e!==r?.e&&v(n,`aria-label`,e),t!==r?.t&&v(n,`aria-expanded`,t)}),n})():t())}function K(e){var t=Y(),n=t.firstChild,r=n.nextSibling;return t._$$click=()=>e.presentation.toggle(e.fold),g(t,b(l,{name:`chevronRight`}),n),g(n,()=>o(`chat.sessionDiff.foldedLines`,{count:String(e.fold.count)})),g(t,b(A,{get stat(){return{added:e.fold.added,removed:e.fold.removed}}}),r),t}function te(e){let t=f(()=>e.presentation),n=t??W({get lines(){return e.lines},get file(){return e.file??{path:``}}}),r=n.renderLine,i=p(()=>e.lines.some(e=>e.lineNo!==void 0));return[!t&&b(n.SyntaxLifetime,{}),(()=>{var t=X();return g(t,b(d,{get each(){return n.visibility().lines},children:t=>[(()=>{var a=Z(),o=a.firstChild,s=o.nextSibling;return g(a,(()=>{var r=_(()=>!!i());return()=>r()?(()=>{var r=Q(),i=r.firstChild,a=i.nextSibling;return g(r,(()=>{var r=_(()=>!!(e.presentation&&t.kind!==`skip`));return()=>r()?b(G,{line:t,presentation:n}):e.presentation&&t.kind!==`skip`})(),i),g(r,(()=>{var e=_(()=>t.kind===`skip`);return()=>e()?``:t.lineNo??``})(),a),r})():i()})(),o),g(o,(()=>{var e=_(()=>t.kind===`add`);return()=>e()?`+`:t.kind===`del`?`-`:``})()),g(s,(()=>{var n=_(()=>t.kind===`skip`);return()=>n()?(e.renderSkip?.(t)??t.text)||`⋯`:r(t)})()),x(()=>C([`chat-diff__row`,t.kind!==`ctx`&&`chat-diff__row--${t.kind}`]),(e,t)=>{S(a,e,t)}),a})(),_(()=>_(()=>!!n.visibility().placeholders.get(t))()?b(K,{get fold(){return n.visibility().placeholders.get(t)},presentation:n}):n.visibility().placeholders.get(t))]})),x(()=>o((e.outcome??`succeeded`)===`succeeded`?`chat.toolCards.fileChanges`:`chat.toolCards.attemptedChanges`),e=>{v(t,`aria-label`,e)}),t})()]}var q,J,Y,X,Z,Q;function $(){return($=e((()=>{T(),h(),r(),M(),i(),U(),a(),k(),n(),q=E(`<span>`),J=E(`<button type=button class=session-diff__code-toggle>`),Y=E(`<button type=button class=session-diff__code-placeholder><span></span><!>`),X=E(`<div class="chat-diff code-highlight"role=figure>`),Z=E(`<div><span class=chat-diff__sign></span><span class=chat-diff__text>`),Q=E(`<span class=chat-diff__gutter><!><!>`),s(c),s(j),w([`click`])})))()}export{$ as a,F as c,W as i,K as n,N as o,G as r,U as s,te as t};