UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

2 lines • 8.93 kB
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./dist-Bqm7i9hf.js","./code-language-DNKLVSzs.js","./_1____________________________.css"])))=>i.map(i=>d[i]); import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{$u as t,Qu as n}from"./_4____________________________.js";import{GN as r,JN as i,fN as a,pN as o,qN as s}from"./_2_____________________________.js";import{ei as c}from"./deferred-ui-support-DZEPWjAk.js";import{B as l,C as u,Dt as d,F as f,O as p,U as m,d as h,f as g,g as _,gt as v,j as y,l as b,o as x,p as S,s as C,u as w,x as T}from"./_6____________________.js";import{ai as E,co as D,oi as O,so as k}from"./control-ui-boot-chat-styles-DMRbEm40.js";import{n as A,t as j}from"./en-chat-session-optional-Dhpd_jPf.js";function M(){return{remaining:R}}function N(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 P(e,t=M()){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>L||u>t.remaining||[...a,...o].some(e=>e.text.length>z)){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=>N(e.text)),f=o.map(e=>N(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 F(e,t,n){let r=e.at(-1);r?.to===t?r.to=n:e.push({from:t,to:n})}function I(e){let t=new Map,n=V;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>z||i.text.length>z)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),l=0;for(;l<o.length&&o[l]===s[l];)l++;let u=o.length,d=s.length;for(;u>l&&d>l&&o[u-1]===s[d-1];)u--,d--;let f=o.slice(l,u),p=s.slice(l,d),m=(f.length+1)*(p.length+1);if(m>B||m>n)continue;n-=m;let h=[],g=[],_=o.slice(0,l).join(``).length,v=_;c(f,p,(e,t)=>{e===`ctx`?(_+=t.length,v+=t.length):e===`del`?(F(h,_,_+t.length),_+=t.length):(F(g,v,v+t.length),v+=t.length)}),h.length&&t.set(e,h),g.length&&t.set(i,g)}return t}var L,R,z,B,V;function H(){return(H=e((()=>{L=4096,R=262144,z=2048,B=65536,V=262144})))()}function U(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 t=f(()=>e.lines),[r,i]=l(e=>{let n=new Set(t());return new Set([...e??[]].filter(e=>n.has(e)))}),a=f(()=>e.rows??P(e.lines)),o=f(()=>e.wordDiffs===!1?null:I(a())),s=f(()=>({lines:t(),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,d]=l(null);function m(){return y(p,{get when(){return g(()=>e.active===!1)()?null:s()},keyed:!0,children:e=>(v(()=>{if(c()?.source===e)return;let t=!0;return n(async()=>{let{analyzeDiffSyntax:e}=await import(`./chat-diff-highlight.runtime-D9ypjmaV.js`);return{analyzeDiffSyntax:e}},__vite__mapDeps([0,1,2]),import.meta.url).then(async({analyzeDiffSyntax:n})=>{if(!t)return;let r=await n(e.lines,e.path,e.oldPath);t&&d({source:e,...r})}).catch(()=>void 0),()=>{t=!1}}),null)})}let _=f(()=>{let e=c();return e?.source===s()?e:null}),C=f(()=>_()?.highlighted??new Map),w=f(()=>_()?.folds??[]),T=f(()=>{let e=new Map(C());for(let[t,n]of o()??[]){let r=[],i=0,a=0;for(let e of C().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=f(()=>U(a(),w()));return{SyntaxLifetime:m,visibility:f(()=>{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=>g(()=>g(()=>!!T().has(e))()?y(u,{get each(){return T().get(e)},children:e=>e.classes?(()=>{var t=q();return h(t,()=>e.text),b(()=>S(e.classes),(e,n)=>{x(t,e,n)}),t})():e.text}):e.text)}}function G(e){let t=()=>e.presentation.visibility().starts.get(e.line);return g(()=>g(()=>!!t())()?(()=>{var n=J();return n._$$click=()=>e.presentation.toggle(t()),h(n,y(a,{get name(){return e.presentation.closed().has(t().key)?`chevronRight`:`chevronDown`}})),b(()=>({e:i(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&&_(n,`aria-label`,e),t!==r?.t&&_(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),h(t,y(a,{name:`chevronRight`}),n),h(n,()=>i(`chat.sessionDiff.foldedLines`,{count:String(e.fold.count)})),h(t,y(E,{get stat(){return{added:e.fold.added,removed:e.fold.removed}}}),r),t}function ee(e){let t=d(()=>e.presentation),n=t??W({get lines(){return e.lines},get file(){return e.file??{path:``}}}),r=n.renderLine,a=f(()=>e.lines.some(e=>e.lineNo!==void 0));return[!t&&y(n.SyntaxLifetime,{}),(()=>{var t=X();return h(t,y(u,{get each(){return n.visibility().lines},children:t=>[(()=>{var i=Z(),o=i.firstChild,s=o.nextSibling;return h(i,(()=>{var r=g(()=>!!a());return()=>r()?(()=>{var r=Q(),i=r.firstChild,a=i.nextSibling;return h(r,(()=>{var r=g(()=>!!(e.presentation&&t.kind!==`skip`));return()=>r()?y(G,{line:t,presentation:n}):e.presentation&&t.kind!==`skip`})(),i),h(r,(()=>{var e=g(()=>t.kind===`skip`);return()=>e()?``:t.lineNo??``})(),a),r})():a()})(),o),h(o,(()=>{var e=g(()=>t.kind===`add`);return()=>e()?`+`:t.kind===`del`?`-`:``})()),h(s,(()=>{var n=g(()=>t.kind===`skip`);return()=>n()?(e.renderSkip?.(t)??t.text)||`⋯`:r(t)})()),b(()=>S([`chat-diff__row`,t.kind!==`ctx`&&`chat-diff__row--${t.kind}`]),(e,t)=>{x(i,e,t)}),i})(),g(()=>g(()=>!!n.visibility().placeholders.get(t))()?y(K,{get fold(){return n.visibility().placeholders.get(t)},presentation:n}):n.visibility().placeholders.get(t))]})),b(()=>i((e.outcome??`succeeded`)===`succeeded`?`chat.toolCards.fileChanges`:`chat.toolCards.attemptedChanges`),e=>{_(t,`aria-label`,e)}),t})()]}var q,J,Y,X,Z,Q;function $(){return($=e((()=>{w(),m(),o(),j(),k(),H(),r(),O(),t(),q=T(`<span>`),J=T(`<button type=button class=session-diff__code-toggle>`),Y=T(`<button type=button class=session-diff__code-placeholder><span></span><!>`),X=T(`<div class="chat-diff code-highlight"role=figure>`),Z=T(`<div><span class=chat-diff__sign></span><span class=chat-diff__text>`),Q=T(`<span class=chat-diff__gutter><!><!>`),s(D),s(A),C([`click`])})))()}export{$ as a,P as c,W as i,K as n,M as o,G as r,H as s,ee as t};