@standardagents/builder 0.9.10 → 0.9.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,20 @@
1
- import{m as $e,c as l,o,a as e,r as v,d as se,b as ye,e as je,w as ie,n as st,f as Je,g as xe,h as z,u as Re,i as oe,j as M,k as Q,l as F,F as ce,p as fe,q as I,s as Te,t as de,v as Ze,x as tt,y as V,R as $t,z as ke,T as ht,A as Be,B as _e,C as Ee,D as ho,E as Me,L as Ut,G as gt,H as nt,I as rt,J as go,K as bo,P as ct,M as Ct,N as xo,O as Nt,Q as yo,S as De,U as Rt,V as ko,W as wo,X as pt,Y as Oe,Z as qe,_ as _o,$ as $o,a0 as Bt,a1 as qt,a2 as Co,a3 as Vo,a4 as So,a5 as To,a6 as Mo}from"./vue.js";import{f as Io}from"./vendor.js";import{W as Lo,a as Eo,e as Vt}from"./monaco.js";(function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))c(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const r of u.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&c(r)}).observe(document,{childList:!0,subtree:!0});function s(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function c(a){if(a.ep)return;a.ep=!0;const u=s(a);fetch(a.href,u)}})();const Ao={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Po(t,i){return o(),l("svg",Ao,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M12 8V4H8"}),e("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),e("path",{d:"M2 14h2m16 0h2m-7-1v2m-6-2v2"})],-1)])])}const St=$e({name:"lucide-bot",render:Po}),Oo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function jo(t,i){return o(),l("svg",Oo,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"},null,-1)])])}const Tt=$e({name:"lucide-message-square",render:jo}),Do={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Uo(t,i){return o(),l("svg",Do,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M12 20v2m0-20v2m5 16v2m0-20v2M2 12h2m-2 5h2M2 7h2m16 5h2m-2 5h2M20 7h2M7 20v2M7 2v2"}),e("rect",{width:"16",height:"16",x:"4",y:"4",rx:"2"}),e("rect",{width:"8",height:"8",x:"8",y:"8",rx:"1"})],-1)])])}const No=$e({name:"lucide-cpu",render:Uo}),Ro={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Bo(t,i){return o(),l("svg",Ro,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e("path",{d:"M6 6h.01M6 18h.01"})],-1)])])}const qo=$e({name:"lucide-server",render:Bo}),Fo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function zo(t,i){return o(),l("svg",Fo,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z"},null,-1)])])}const Ho=$e({name:"lucide-wrench",render:zo}),Wo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Jo(t,i){return o(),l("svg",Wo,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0a2.34 2.34 0 0 0 3.319 1.915a2.34 2.34 0 0 1 2.33 4.033a2.34 2.34 0 0 0 0 3.831a2.34 2.34 0 0 1-2.33 4.033a2.34 2.34 0 0 0-3.319 1.915a2.34 2.34 0 0 1-4.659 0a2.34 2.34 0 0 0-3.32-1.915a2.34 2.34 0 0 1-2.33-4.033a2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}),e("circle",{cx:"12",cy:"12",r:"3"})],-1)])])}const Zo=$e({name:"lucide-settings",render:Jo}),Ko={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Go(t,i){return o(),l("svg",Ko,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m15 18l-6-6l6-6"},null,-1)])])}const Xo=$e({name:"lucide-chevron-left",render:Go}),Yo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Qo(t,i){return o(),l("svg",Yo,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("circle",{cx:"12",cy:"12",r:"4"}),e("path",{d:"M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"})],-1)])])}const ea=$e({name:"lucide-sun",render:Qo}),ta={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function oa(t,i){return o(),l("svg",ta,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"},null,-1)])])}const aa=$e({name:"lucide-moon",render:oa}),la={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function sa(t,i){return o(),l("svg",la,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"},null,-1)])])}const na=$e({name:"lucide-activity",render:sa}),ra={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ia(t,i){return o(),l("svg",ra,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),e("path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3m-6 4.2h5.7"})],-1)])])}const da=$e({name:"lucide-function-square",render:ia}),ua={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ca(t,i){return o(),l("svg",ua,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m16 17l5-5l-5-5m5 5H9m0 9H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"},null,-1)])])}const pa=$e({name:"lucide-log-out",render:ca}),ma={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function va(t,i){return o(),l("svg",ma,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2M16 3.128a4 4 0 0 1 0 7.744M22 21v-2a4 4 0 0 0-3-3.87"}),e("circle",{cx:"9",cy:"7",r:"4"})],-1)])])}const fa=$e({name:"lucide-users",render:va}),ha={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ga(t,i){return o(),l("svg",ha,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"m15.5 7.5l2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4m2-2l-9.6 9.6"}),e("circle",{cx:"7.5",cy:"15.5",r:"5.5"})],-1)])])}const ba=$e({name:"lucide-key",render:ga}),xa={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ya(t,i){return o(),l("svg",xa,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 7v14m-9-3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4a4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3a3 3 0 0 0-3-3z"},null,-1)])])}const ka=$e({name:"lucide-book-open",render:ya}),wa={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function _a(t,i){return o(),l("svg",wa,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 3h6v6m-11 5L21 3m-3 10v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"},null,-1)])])}const $a=$e({name:"lucide-external-link",render:_a}),Ft="agentbuilder-accent-theme",zt=["amber","lime","emerald","sky","blue","indigo","purple","fuchsia","pink","white"],mt=v("purple");let Mt=!1;function Ht(t){typeof document>"u"||(t==="purple"?delete document.documentElement.dataset.accent:document.documentElement.dataset.accent=t)}function Ca(t){try{localStorage.setItem(Ft,t)}catch{}}function Va(){try{const t=localStorage.getItem(Ft);if(t&&zt.includes(t))return t}catch{}return"purple"}function Wt(){if(Mt)return;Mt=!0;const t=Va();mt.value=t,Ht(t)}function Sa(){Wt();function t(i){mt.value=i,Ht(i),Ca(i)}return{theme:mt,themes:zt,setTheme:t}}const Ke=se({__name:"DropShadow",props:{offsetX:{default:8},offsetY:{default:8},intensity:{default:.5},pattern:{default:"crosshatch"}},setup(t){const i=t,s=v(),c=v(),a=v(),u=v(0),r=(n,d,h,$,g,m)=>{n.beginPath(),n.moveTo(d+m,h),n.lineTo(d+$-m,h),n.quadraticCurveTo(d+$,h,d+$,h+m),n.lineTo(d+$,h+g-m),n.quadraticCurveTo(d+$,h+g,d+$-m,h+g),n.lineTo(d+m,h+g),n.quadraticCurveTo(d,h+g,d,h+g-m),n.lineTo(d,h+m),n.quadraticCurveTo(d,h,d+m,h),n.closePath()},p=async()=>{if(await xe(),!s.value||!c.value||!a.value)return;const n=s.value.getContext("2d");if(!n)return;const d=a.value.getBoundingClientRect(),h=a.value.firstElementChild;if(h){const C=getComputedStyle(h);u.value=parseFloat(C.borderRadius)||0}const $=d.width+i.offsetX+4,g=d.height+i.offsetY+4;s.value.width=$,s.value.height=g,s.value.style.width=`${$}px`,s.value.style.height=`${g}px`,n.clearRect(0,0,s.value.width,s.value.height);const m=document.documentElement.classList.contains("dark");if(n.fillStyle=m?"#6b7280":"black",n.globalAlpha=i.intensity,n.save(),r(n,i.offsetX,i.offsetY,d.width,d.height,u.value),n.clip(),i.pattern==="crosshatch"){const C=m?4:3;n.lineWidth=1,n.strokeStyle=m?"#6b7280":"black";for(let w=-d.height;w<d.width;w+=C)n.beginPath(),n.moveTo(i.offsetX+w,i.offsetY),n.lineTo(i.offsetX+w+d.height,i.offsetY+d.height),n.stroke();for(let w=0;w<d.width+d.height;w+=C)n.beginPath(),n.moveTo(i.offsetX+w,i.offsetY+d.height),n.lineTo(i.offsetX+w-d.height,i.offsetY),n.stroke()}else if(i.pattern==="dots"){const w=m?3:2,E=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];for(let A=0;A<d.width;A+=w)for(let q=0;q<d.height;q+=w){const J=Math.floor(A/w)%4,X=Math.floor(q/w)%4;E[X][J]/16<i.intensity&&n.fillRect(i.offsetX+A,i.offsetY+q,1,1)}}else if(i.pattern==="diagonal"){const C=m?5:4;n.lineWidth=1,n.strokeStyle=m?"#6b7280":"black";for(let w=-d.height;w<d.width;w+=C)n.beginPath(),n.moveTo(i.offsetX+w,i.offsetY),n.lineTo(i.offsetX+w+d.height,i.offsetY+d.height),n.stroke()}n.restore()};let f=null,b=null;return ye(()=>{f=new ResizeObserver(()=>{p()}),a.value&&f.observe(a.value),p(),b=new MutationObserver(()=>{p()}),b.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]})}),je(()=>{a.value&&f&&f.unobserve(a.value),b&&b.disconnect()}),ie(()=>[i.offsetX,i.offsetY,i.intensity,i.pattern],()=>{p()}),(n,d)=>(o(),l("div",{ref_key:"container",ref:c,class:"relative",style:st({paddingRight:`${t.offsetX}px`,paddingBottom:`${t.offsetY}px`})},[e("canvas",{ref_key:"canvas",ref:s,class:"absolute top-0 left-0 pointer-events-none"},null,512),e("div",{ref_key:"contentEl",ref:a,class:"relative"},[Je(n.$slots,"default")],512)],4))}}),Jt="/agents/assets/img/agent-builder-logo-light.svg",Zt="/agents/assets/img/agent-builder-logo-dark.svg",Ta="data:image/svg+xml,%3csvg%20width='100%25'%20height='100%25'%20viewBox='0%200%20150%20150'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20xmlns:serif='http://www.serif.com/'%20style='fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;'%3e%3cg%20id='Artboard1'%20transform='matrix(1,0,0,1,1,1)'%3e%3crect%20x='-1'%20y='-1'%20width='150'%20height='150'%20style='fill:none;'/%3e%3cg%20transform='matrix(1.034881,0,0,1.034881,4.124225,0)'%3e%3cpath%20d='M133.816,92.912L108.064,59.193C103.573,53.307%20101.473,45.937%20102.197,38.566L105.475,5.046L99.553,4.466L96.312,37.643C95.895,41.808%2091.44,44.27%2087.71,42.369L30.34,13.394L27.659,18.7L84.686,47.494C87.184,48.762%2087.076,52.347%2084.504,53.452L0.387,89.671L2.741,95.139L86.189,59.211C88.76,58.106%2091.422,60.587%2090.48,63.231L62.918,141.119L68.532,143.111L96.384,64.408C97.507,61.257%20101.672,60.605%20103.7,63.249L129.107,96.498L133.834,92.876L133.816,92.912Z'%20style='fill:rgb(31,41,55);fill-opacity:0.5;fill-rule:nonzero;'/%3e%3c/g%3e%3cg%20transform='matrix(1.034881,0,0,1.034881,4.124225,0)'%3e%3cpath%20d='M133.925,90.214L107.648,7.346C106.036,2.257%20100.875,-0.821%2095.624,0.193L32.64,12.344C29.959,12.869%2027.605,14.408%2026.066,16.6C25.523,17.36%2025.07,18.211%2024.744,19.117L0.622,86.284C-0.917,90.594%200.459,95.375%204.081,98.164L59.568,141.137C61.469,142.604%2063.733,143.346%2066.015,143.346C68.079,143.346%2070.144,142.731%2071.937,141.517L129.832,102.111C133.707,99.468%20135.355,94.687%20133.943,90.232L133.925,90.214ZM116.92,85.922L47.127,53.923C44.374,52.673%2043.994,48.925%2046.421,47.132L94.175,11.873C97.416,9.483%20102.034,10.95%20103.284,14.771C108.173,29.548%20118.64,62.054%20124.218,79.457C125.631,83.876%20121.121,87.859%20116.902,85.94L116.92,85.922ZM79.162,15.567L42.455,42.659C40.083,44.415%2036.696,43.057%2036.189,40.16L33.781,26.342C33.038,22.05%2035.845,17.94%2040.119,17.089C49.409,15.241%2065.254,12.145%2076.681,9.917C79.995,9.265%2081.879,13.557%2079.162,15.567ZM29.126,34.238L31.716,49.069C31.915,50.21%2031.607,51.388%2030.865,52.275L16.559,69.587C15.291,71.127%2012.846,69.732%2013.516,67.849L25.704,33.93C26.32,32.21%2028.8,32.427%2029.126,34.22L29.126,34.238ZM12.882,83.386L29.543,63.231C31.517,60.84%2035.356,61.547%2036.352,64.499L56.308,123.661C57.322,126.668%2053.809,129.149%2051.31,127.193C41.223,119.297%2024.4,106.132%2014.404,98.164C9.84,94.542%209.152,87.878%2012.864,83.386L12.882,83.386ZM63.498,126.305L43.161,66.002C42.056,62.706%2045.407,59.681%2048.576,61.13L117.337,92.677C121.375,94.524%20121.864,100.083%20118.206,102.6C107.358,110.061%2088.326,123.064%2076.826,130.815C71.991,134.074%2065.381,131.829%2063.516,126.305L63.498,126.305Z'%20style='fill:rgb(31,41,55);fill-rule:nonzero;'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",Ma="data:image/svg+xml,%3csvg%20width='100%25'%20height='100%25'%20viewBox='0%200%20150%20150'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20xmlns:serif='http://www.serif.com/'%20style='fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;'%3e%3cg%20id='Artboard1'%20transform='matrix(1,0,0,1,1,1)'%3e%3crect%20x='-1'%20y='-1'%20width='150'%20height='150'%20style='fill:none;'/%3e%3cg%20transform='matrix(1.034881,0,0,1.034881,4.124225,0)'%3e%3cpath%20d='M133.816,92.912L108.064,59.193C103.573,53.307%20101.473,45.937%20102.197,38.566L105.475,5.046L99.553,4.466L96.312,37.643C95.895,41.808%2091.44,44.27%2087.71,42.369L30.34,13.394L27.659,18.7L84.686,47.494C87.184,48.762%2087.076,52.347%2084.504,53.452L0.387,89.671L2.741,95.139L86.189,59.211C88.76,58.106%2091.422,60.587%2090.48,63.231L62.918,141.119L68.532,143.111L96.384,64.408C97.507,61.257%20101.672,60.605%20103.7,63.249L129.107,96.498L133.834,92.876L133.816,92.912Z'%20style='fill:rgb(249,250,251);fill-opacity:0.5;fill-rule:nonzero;'/%3e%3c/g%3e%3cg%20transform='matrix(1.034881,0,0,1.034881,4.124225,0)'%3e%3cpath%20d='M133.925,90.214L107.648,7.346C106.036,2.257%20100.875,-0.821%2095.624,0.193L32.64,12.344C29.959,12.869%2027.605,14.408%2026.066,16.6C25.523,17.36%2025.07,18.211%2024.744,19.117L0.622,86.284C-0.917,90.594%200.459,95.375%204.081,98.164L59.568,141.137C61.469,142.604%2063.733,143.346%2066.015,143.346C68.079,143.346%2070.144,142.731%2071.937,141.517L129.832,102.111C133.707,99.468%20135.355,94.687%20133.943,90.232L133.925,90.214ZM116.92,85.922L47.127,53.923C44.374,52.673%2043.994,48.925%2046.421,47.132L94.175,11.873C97.416,9.483%20102.034,10.95%20103.284,14.771C108.173,29.548%20118.64,62.054%20124.218,79.457C125.631,83.876%20121.121,87.859%20116.902,85.94L116.92,85.922ZM79.162,15.567L42.455,42.659C40.083,44.415%2036.696,43.057%2036.189,40.16L33.781,26.342C33.038,22.05%2035.845,17.94%2040.119,17.089C49.409,15.241%2065.254,12.145%2076.681,9.917C79.995,9.265%2081.879,13.557%2079.162,15.567ZM29.126,34.238L31.716,49.069C31.915,50.21%2031.607,51.388%2030.865,52.275L16.559,69.587C15.291,71.127%2012.846,69.732%2013.516,67.849L25.704,33.93C26.32,32.21%2028.8,32.427%2029.126,34.22L29.126,34.238ZM12.882,83.386L29.543,63.231C31.517,60.84%2035.356,61.547%2036.352,64.499L56.308,123.661C57.322,126.668%2053.809,129.149%2051.31,127.193C41.223,119.297%2024.4,106.132%2014.404,98.164C9.84,94.542%209.152,87.878%2012.864,83.386L12.882,83.386ZM63.498,126.305L43.161,66.002C42.056,62.706%2045.407,59.681%2048.576,61.13L117.337,92.677C121.375,94.524%20121.864,100.083%20118.206,102.6C107.358,110.061%2088.326,123.064%2076.826,130.815C71.991,134.074%2065.381,131.829%2063.516,126.305L63.498,126.305Z'%20style='fill:rgb(249,250,251);fill-rule:nonzero;'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e";function Ia(){return window.__AGENTBUILDER_CONFIG__||{mountPoint:"/agentbuilder"}}function Ge(){return Ia().mountPoint}function te(t){const i=Ge(),s=t.startsWith("/")?t:`/${t}`;return i==="/"?s:`${i}${s}`}const La=["src"],Ea=["src"],Aa={class:"flex-1 flex flex-col justify-between pt-2 pb-4"},Pa={class:"flex flex-col gap-1 px-2"},Oa={key:0},ja=["onClick","title"],Da={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis text-left"},Ua={key:0,class:"ml-4 space-y-0.5"},Na=["onClick"],Ra={class:"whitespace-nowrap overflow-hidden text-ellipsis"},Ba=["onClick","title"],qa={key:0,class:"whitespace-nowrap overflow-hidden text-ellipsis"},Fa={class:"flex flex-col gap-1 px-2"},za=["title"],Ha={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis"},Wa={class:"relative settings-menu-container"},Ja={key:0,class:"absolute bottom-full mb-2 left-0 z-50"},Za={class:"bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-600 rounded-lg py-2 min-w-[200px]"},Ka={class:"px-4 py-3 border-b border-neutral-200 dark:border-neutral-700"},Ga=["title"],Xa={class:"relative z-10 flex items-center justify-center w-8 h-full"},Ya={class:"relative z-10 flex items-center justify-center w-8 h-full"},Qa={class:"px-4 pt-3 pb-4 border-b border-neutral-200 dark:border-neutral-700"},el={class:"grid grid-cols-5 gap-3"},tl=["onClick","title"],ol={key:0,class:"w-2 h-2 rounded-full bg-white shadow-sm"},al={key:0,class:"text-sm overflow-hidden whitespace-nowrap max-w-0 group-hover:max-w-[60px] group-hover:ml-2 transition-all duration-200"},ll=se({__name:"Sidebar",props:{isCollapsed:{type:Boolean},isDark:{type:Boolean}},emits:["toggle-sidebar","toggle-theme"],setup(t,{emit:i}){function s(N){if(N.startsWith("/src/")||N.startsWith("data:"))return N;const U=Ge();return U==="/"?N.replace("/agents/","/"):N.replace("/agents/",`${U}/`)}const c=s(Jt),a=s(Zt),u=s(Ta),r=s(Ma),p=t,f=Re(),b=Ze(),n=z(()=>f.name);function d(N){const U=f.path;return U===N.path||U.startsWith(N.path+"/")}const h=z(()=>p.isDark?a:c),$=z(()=>p.isDark?r:u),g=[{id:"threads",label:"Threads",icon:na,path:"/threads"},{id:"agents",label:"Agents",icon:St,path:"/agents"},{id:"prompts",label:"Prompts",icon:Tt,path:"/prompts"},{id:"tools",label:"Tools",icon:Ho,path:"/tools",hasSubnav:!0,subnav:[{id:"tools-functions",label:"Functions",icon:da,path:"/tools#functions"},{id:"tools-prompts",label:"Prompts",icon:Tt,path:"/tools#prompts"},{id:"tools-agents",label:"Agents",icon:St,path:"/tools#agents"}]},{id:"models",label:"Models",icon:No,path:"/models"},{id:"providers",label:"Providers",icon:qo,path:"/providers"}],m=N=>{b.push(N)},C=N=>{b.push(N),E.value=!1},w=z(()=>typeof n.value=="string"&&(n.value==="tools"||n.value.startsWith("tools-"))),E=v(!1),{theme:A,themes:q,setTheme:J}=Sa(),X={amber:"bg-amber-500",lime:"bg-lime-500",emerald:"bg-emerald-500",sky:"bg-sky-500",blue:"bg-blue-500",indigo:"bg-indigo-500",purple:"bg-purple-500",fuchsia:"bg-fuchsia-500",pink:"bg-pink-500",white:"bg-neutral-400 dark:bg-neutral-500"},P=z(()=>n.value==="users"||n.value==="api-keys"),_=()=>{E.value=!E.value},O=()=>{localStorage.removeItem("auth_token"),b.push("/login")},D=N=>{const U=N.target;E.value&&!U.closest(".settings-menu-container")&&(E.value=!1)};return ye(()=>{document.addEventListener("click",D)}),je(()=>{document.removeEventListener("click",D)}),(N,U)=>(o(),l("aside",{class:oe(["flex flex-col transition-all duration-300 pt-2.5",t.isCollapsed?"w-16":"w-60"])},[e("div",{class:oe(`flex items-center justify-between ${t.isCollapsed?"px-2 py-4":"p-4"}`)},[t.isCollapsed?M("",!0):(o(),l("img",{key:0,src:h.value,alt:"AgentBuilder",class:"h-8 mr-2 mt-0.5"},null,8,La)),e("button",{onClick:U[0]||(U[0]=L=>N.$emit("toggle-sidebar")),class:oe(`p-1 rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors ${t.isCollapsed?"m-auto":"border border-black/20 dark:border-white/20 opacity-50 hover:opacity-100"}`),"aria-label":"Toggle sidebar"},[t.isCollapsed?(o(),l("img",{key:1,src:$.value,alt:"AgentBuilder",class:"w-7 h-7 m-auto"},null,8,Ea)):(o(),Q(F(Xo),{key:0,class:"w-5 h-5"}))],2)],2),e("nav",Aa,[e("div",Pa,[(o(),l(ce,null,fe(g,L=>(o(),l(ce,{key:L.id},[L.hasSubnav?(o(),l("div",Oa,[e("button",{onClick:T=>m(L.path),class:oe(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all w-full",w.value?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10",t.isCollapsed&&"justify-center"]),title:t.isCollapsed?L.label:void 0},[(o(),Q(tt(L.icon),{class:"w-5 h-5 flex-shrink-0"})),t.isCollapsed?M("",!0):(o(),l("span",Da,V(L.label),1))],10,ja),!t.isCollapsed&&L.subnav?(o(),l("div",Ua,[(o(!0),l(ce,null,fe(L.subnav,T=>(o(),l("button",{key:T.id,onClick:j=>m(T.path),class:oe(["flex items-center gap-3 px-3 py-1.5 text-sm transition-all w-full",n.value===T.id?"bg-black text-white dark:bg-white dark:text-black rounded":"hover:underline"])},[(o(),Q(tt(T.icon),{class:"w-4 h-4 flex-shrink-0"})),e("span",Ra,V(T.label),1)],10,Na))),128))])):M("",!0)])):(o(),l("button",{key:1,onClick:T=>m(L.path),class:oe(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all",d(L)?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10",t.isCollapsed&&"justify-center"]),title:t.isCollapsed?L.label:void 0},[(o(),Q(tt(L.icon),{class:"w-5 h-5 flex-shrink-0"})),t.isCollapsed?M("",!0):(o(),l("span",qa,V(L.label),1))],10,Ba))],64))),64))]),e("div",Fa,[e("a",{href:"https://docs.standardagentbuilder.com/",target:"_blank",rel:"noopener noreferrer",class:oe(["flex items-center gap-3 px-3 py-2 rounded text-sm transition-all","hover:bg-black/5 dark:hover:bg-white/10 text-neutral-600 dark:text-neutral-400 hover:text-black dark:hover:text-white",t.isCollapsed&&"justify-center"]),title:t.isCollapsed?"Documentation":void 0},[I(F(ka),{class:"w-5 h-5 flex-shrink-0"}),t.isCollapsed?M("",!0):(o(),l("span",Ha," Docs ")),t.isCollapsed?M("",!0):(o(),Q(F($a),{key:1,class:"w-3 h-3 flex-shrink-0 opacity-50"}))],10,za),e("div",{class:oe(["flex items-center gap-1 pt-2 mt-1 border-t border-black/10 dark:border-white/10",t.isCollapsed?"flex-col":"justify-between"])},[e("div",Wa,[e("button",{onClick:Te(_,["stop"]),class:oe(["p-2 rounded transition-colors flex items-center",E.value||P.value?"bg-black/10 dark:bg-white/10 text-black dark:text-white":"hover:bg-black/5 dark:hover:bg-white/10 text-neutral-600 dark:text-neutral-400 hover:text-black dark:hover:text-white"]),title:"Settings"},[I(F(Zo),{class:"w-5 h-5 flex-shrink-0"})],2),E.value?(o(),l("div",Ja,[I(Ke,{"offset-x":6,"offset-y":6,intensity:.4},{default:de(()=>[e("div",Za,[e("div",Ka,[U[4]||(U[4]=e("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Appearance ",-1)),e("button",{onClick:U[1]||(U[1]=Te(L=>N.$emit("toggle-theme"),["stop"])),class:"relative flex items-center h-7 rounded-full bg-neutral-200 dark:bg-neutral-800 hover:bg-neutral-300 dark:hover:bg-neutral-700 transition-colors",title:t.isDark?"Switch to light mode":"Switch to dark mode"},[e("span",{class:oe(["absolute top-0.5 h-6 w-8 rounded-full bg-white dark:bg-black shadow-sm transition-transform duration-200",t.isDark?"translate-x-[calc(100%-2px)]":"translate-x-0.5"])},null,2),e("span",Xa,[I(F(ea),{class:oe(["w-4 h-4",t.isDark?"text-neutral-500":"text-black"])},null,8,["class"])]),e("span",Ya,[I(F(aa),{class:oe(["w-4 h-4",t.isDark?"text-white":"text-neutral-400"])},null,8,["class"])])],8,Ga)]),e("div",Qa,[U[5]||(U[5]=e("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Accent Color ",-1)),e("div",el,[(o(!0),l(ce,null,fe(F(q),L=>(o(),l("button",{key:L,onClick:Te(T=>F(J)(L),["stop"]),class:oe(["w-6 h-6 rounded-full transition-all flex items-center justify-center ring-1 ring-black/10 dark:ring-white/10",[X[L],F(A)===L?"ring-2 ring-black/50 dark:ring-white/50":"hover:scale-110"]]),title:L.charAt(0).toUpperCase()+L.slice(1)},[F(A)===L?(o(),l("span",ol)):M("",!0)],10,tl))),128))])]),e("button",{onClick:U[2]||(U[2]=L=>C("/settings/users")),class:oe(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",n.value==="users"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[I(F(fa),{class:"w-4 h-4 flex-shrink-0"}),U[6]||(U[6]=e("span",{class:"whitespace-nowrap"},"Users",-1))],2),e("button",{onClick:U[3]||(U[3]=L=>C("/settings/api-keys")),class:oe(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",n.value==="api-keys"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[I(F(ba),{class:"w-4 h-4 flex-shrink-0"}),U[7]||(U[7]=e("span",{class:"whitespace-nowrap"},"API Keys",-1))],2)])]),_:1})])):M("",!0)]),e("button",{onClick:O,class:"group p-2 rounded hover:bg-red-500/10 transition-colors text-neutral-600 dark:text-neutral-400 hover:text-red-600 dark:hover:text-red-400 flex items-center",title:"Logout"},[I(F(pa),{class:"w-5 h-5 flex-shrink-0"}),t.isCollapsed?M("",!0):(o(),l("span",al,"Logout"))])],2)])])],2))}}),sl={class:"warning-banner-container"},nl={key:0,class:"warning-banner flex items-center justify-between gap-3 px-4 py-2 bg-amber-50 dark:bg-amber-900/30 border-b border-amber-200 dark:border-amber-800 text-amber-800 dark:text-amber-200 text-sm"},rl={class:"flex items-center gap-2"},il=["onClick"],dl=se({__name:"WarningBanner",setup(t){const i=v([]),s=v(new Set),c=async()=>{if(localStorage.getItem("auth_token"))try{const f=await fetch(te("/api/diagnostics"));if(f.ok){const b=await f.json();i.value=b.warnings||[]}}catch{}},a=p=>{const f=`${p.type}:${p.details?.name||p.message}`;s.value.add(f)},u=p=>{const f=`${p.type}:${p.details?.name||p.message}`;return!s.value.has(f)},r=p=>{if(p.type==="duplicate_tool_name"){const f=p.details?.sources?.join(" and ")||"multiple sources";return`Duplicate tool name "${p.details?.name}" (defined as both ${f}). This may cause unexpected behavior.`}return p.message};return ye(()=>{c()}),(p,f)=>(o(),l("div",sl,[(o(!0),l(ce,null,fe(i.value,b=>(o(),l(ce,{key:`${b.type}:${b.details?.name}`},[u(b)?(o(),l("div",nl,[e("div",rl,[f[0]||(f[0]=e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 flex-shrink-0",viewBox:"0 0 20 20",fill:"currentColor"},[e("path",{"fill-rule":"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z","clip-rule":"evenodd"})],-1)),e("span",null,V(r(b)),1)]),e("button",{onClick:n=>a(b),class:"text-amber-600 dark:text-amber-400 hover:text-amber-800 dark:hover:text-amber-200 p-1",title:"Dismiss"},[...f[1]||(f[1]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor"},[e("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)])],8,il)])):M("",!0)],64))),128))]))}}),ul={key:2,class:"flex-1 overflow-auto my-3 mr-4 border border-neutral-300 dark:border-neutral-700 rounded-xl bg-white dark:bg-neutral-900 flex flex-col"},cl={class:"flex-1 overflow-auto"},pl=se({__name:"App",setup(t){Wt();const i=Re(),s=v(!1),c=v(!1),a=z(()=>i.name!=="login"),u=()=>{s.value=!s.value},r=()=>{c.value=!c.value,c.value?(document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark")):(document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light"))};return ye(()=>{const p=localStorage.getItem("theme");(p==="dark"||!p&&window.matchMedia("(prefers-color-scheme: dark)").matches)&&(c.value=!0,document.documentElement.classList.add("dark"))}),(p,f)=>(o(),l("div",{class:oe(["app-container relative flex h-screen font-sans bg-neutral-50/80 text-black dark:bg-black dark:text-white",{"is-dark":c.value}])},[a.value?(o(),Q(ll,{key:0,"is-collapsed":s.value,"is-dark":c.value,onToggleSidebar:u,onToggleTheme:r},null,8,["is-collapsed","is-dark"])):M("",!0),a.value?(o(),l("main",ul,[I(dl),e("div",cl,[I(F($t))])])):(o(),Q(F($t),{key:1}))],2))}}),Fe=(t,i)=>{const s=t.__vccOpts||t;for(const[c,a]of i)s[c]=a;return s},ml=Fe(pl,[["__scopeId","data-v-75e555ae"]]),vl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function fl(t,i){return o(),l("svg",vl,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 11v6m4-6v6m5-11v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"},null,-1)])])}const hl=$e({name:"lucide-trash-2",render:fl}),gl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function bl(t,i){return o(),l("svg",gl,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e("path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"})],-1)])])}const xl=$e({name:"lucide-edit",render:bl}),yl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function kl(t,i){return o(),l("svg",yl,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),e("circle",{cx:"12",cy:"12",r:"3"})],-1)])])}const vt=$e({name:"lucide-eye",render:kl}),wl={class:"w-full"},_l={class:"border border-black dark:border-neutral-300 rounded overflow-hidden"},$l={class:"overflow-x-auto"},Cl={class:"w-full"},Vl={class:"border-b border-black dark:border-neutral-300"},Sl={key:0,class:"px-4 py-3 text-right font-medium text-sm"},Tl={key:0},Ml=["colspan"],Il={key:1},Ll=["colspan"],El=["innerHTML"],Al={key:0,class:"px-4 py-3 text-right"},Pl={class:"inline-flex gap-1"},Ol=["onClick","title"],Ne=se({__name:"DataTable",props:{columns:{},data:{},actions:{},emptyMessage:{default:"No data available"},loading:{type:Boolean,default:!1}},setup(t){const i=u=>{switch(u){case"edit":return xl;case"delete":return hl;case"view":return vt;default:return null}},s=(u,r)=>{const p=u[r.key];return r.formatter?r.formatter(p):p??"-"},c=u=>{switch(u){case"center":return"text-center";case"right":return"text-right";default:return"text-left"}},a=(u,r)=>{if(u.confirm){const p=u.confirmMessage||`Are you sure you want to ${u.label.toLowerCase()}?`;confirm(p)&&u.handler(r)}else u.handler(r)};return(u,r)=>(o(),l("div",wl,[e("div",_l,[e("div",$l,[e("table",Cl,[e("thead",Vl,[e("tr",null,[(o(!0),l(ce,null,fe(t.columns,p=>(o(),l("th",{key:p.key,class:oe(["px-4 py-3 font-medium text-sm",c(p.align),p.width||""])},V(p.label),3))),128)),t.actions&&t.actions.length>0?(o(),l("th",Sl," Actions ")):M("",!0)])]),e("tbody",null,[t.loading?(o(),l("tr",Tl,[e("td",{colspan:t.columns.length+(t.actions?1:0),class:"px-4 py-8 text-center text-neutral-500"},[...r[0]||(r[0]=[e("div",{class:"inline-flex items-center gap-2"},[e("svg",{class:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]),ke(" Loading... ")],-1)])],8,Ml)])):t.data.length===0?(o(),l("tr",Il,[e("td",{colspan:t.columns.length+(t.actions?1:0),class:"px-4 py-8 text-center text-neutral-500"},V(t.emptyMessage),9,Ll)])):(o(!0),l(ce,{key:2},fe(t.data,(p,f)=>(o(),l("tr",{key:f,class:"border-t border-neutral-200 dark:border-neutral-800 hover:bg-black/5 dark:hover:bg-white/5 transition-colors"},[(o(!0),l(ce,null,fe(t.columns,b=>(o(),l("td",{key:b.key,class:oe(["px-4 py-3 text-sm",c(b.align)])},[Je(u.$slots,`cell-${b.key}`,{value:p[b.key],row:p,column:b},()=>[b.html?(o(),l("span",{key:0,innerHTML:s(p,b)},null,8,El)):(o(),l(ce,{key:1},[ke(V(s(p,b)),1)],64))])],2))),128)),t.actions&&t.actions.length>0?(o(),l("td",Al,[e("div",Pl,[(o(!0),l(ce,null,fe(t.actions,(b,n)=>(o(),l("button",{key:n,onClick:d=>a(b,p),class:"p-1.5 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",title:b.label},[(o(),Q(tt(i(b.icon)),{class:"w-4 h-4"}))],8,Ol))),128))])])):M("",!0)]))),128))])])])])]))}}),jl=se({__name:"AgentsDataTable",emits:["add","edit","delete"],setup(t,{expose:i,emit:s}){const c=s,a=v([]),u=v(!1),r=[{key:"title",label:"Title",width:"w-1/5"},{key:"type",label:"Type",width:"w-1/12",formatter:n=>n==="dual_ai"?"Dual AI":"AI+Human"},{key:"side_a_agent_prompt_name",label:"Side A",width:"w-1/5",formatter:n=>n||"-"},{key:"side_b_agent_prompt_name",label:"Side B",width:"w-1/5",formatter:n=>n||"Human"},{key:"created_at",label:"Created",width:"w-1/6",formatter:n=>n?new Date(n*1e3).toLocaleDateString():"-"}],p=[{icon:"edit",label:"Edit",handler:n=>c("edit",n)},{icon:"delete",label:"Delete",handler:async n=>{await b(n)},confirm:!0,confirmMessage:"Are you sure you want to delete this agent?"}],f=async()=>{u.value=!0;try{const n=await fetch(te("/api/agents"));if(n.ok){const d=await n.json();a.value=d.agents||[]}}catch(n){console.error("Error fetching agents:",n)}finally{u.value=!1}},b=async n=>{try{const d=await fetch(te(`/api/agents/${n.id}`),{method:"DELETE"});if(d.ok)await f();else{const h=await d.json();alert(h.error||"Failed to delete agent")}}catch(d){console.error("Error deleting agent:",d),alert("Failed to delete agent")}};return ye(()=>{f()}),i({refresh:f}),(n,d)=>(o(),l("div",null,[I(Ne,{columns:r,data:a.value,actions:p,loading:u.value,"empty-message":"No agents available. Create your first agent to get started."},null,8,["data","loading"])]))}}),Dl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ul(t,i){return o(),l("svg",Dl,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M18 6L6 18M6 6l12 12"},null,-1)])])}const Kt=$e({name:"lucide-x",render:Ul}),Nl={key:0,class:"w-full max-w-md"},Rl={class:"flex items-center justify-between p-4 border-b-2 border-red-600 flex-shrink-0"},Bl={class:"text-xl font-bold text-red-600"},ql={class:"p-6"},Fl={class:"text-neutral-700 dark:text-neutral-300 mb-6"},zl={class:"flex justify-end gap-3"},Gt=se({__name:"ConfirmDialog",props:{modelValue:{type:Boolean},title:{default:"Confirm Action"},message:{default:"Are you sure you want to continue? You will lose any unsaved changes."},confirmText:{default:"Continue"},cancelText:{default:"Cancel"}},emits:["update:modelValue","confirm","cancel"],setup(t,{emit:i}){const s=t,c=i,a=()=>{c("update:modelValue",!1)},u=()=>{c("confirm"),a()},r=()=>{c("cancel"),a()},p=f=>{f.key==="Escape"&&s.modelValue&&r()};return ie(()=>s.modelValue,f=>{f?(document.addEventListener("keydown",p),document.body.style.overflow="hidden"):(document.removeEventListener("keydown",p),document.body.style.overflow="")}),(f,b)=>(o(),Q(ht,{to:"body"},[I(Be,{"enter-active-class":"transition-opacity duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-200","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:de(()=>[t.modelValue?(o(),l("div",{key:0,class:"fixed inset-0 z-[60] flex items-center justify-center p-4 bg-white/80 dark:bg-black/80 backdrop-blur-sm dark:text-white",onClick:r},[I(Be,{"enter-active-class":"transition-all duration-200","enter-from-class":"opacity-0 scale-95","enter-to-class":"opacity-100 scale-100","leave-active-class":"transition-all duration-200","leave-from-class":"opacity-100 scale-100","leave-to-class":"opacity-0 scale-95"},{default:de(()=>[t.modelValue?(o(),l("div",Nl,[I(Ke,{"offset-x":12,"offset-y":12,intensity:.4},{default:de(()=>[e("div",{class:"bg-white dark:bg-black border-2 border-red-600 flex flex-col",onClick:b[0]||(b[0]=Te(()=>{},["stop"]))},[e("div",Rl,[e("h2",Bl,V(t.title),1),e("button",{onClick:r,class:"p-1 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors","aria-label":"Close dialog"},[I(F(Kt),{class:"w-5 h-5 text-red-600"})])]),e("div",ql,[e("p",Fl,V(t.message),1),e("div",zl,[e("button",{onClick:r,class:"px-4 py-2 border-2 border-black dark:border-white bg-white dark:bg-black text-black dark:text-white hover:bg-neutral-50 dark:hover:bg-neutral-900 transition-colors"},V(t.cancelText),1),e("button",{onClick:u,class:"px-4 py-2 border-2 border-red-600 bg-red-600 text-white hover:bg-red-700 hover:border-red-700 transition-colors"},V(t.confirmText),1)])])])]),_:1})])):M("",!0)]),_:1})])):M("",!0)]),_:1})]))}}),Hl={class:"flex items-center justify-between p-4 border-b-2 border-black dark:border-neutral-300 flex-shrink-0"},Wl={class:"text-xl font-bold"},Jl={class:"overflow-y-auto flex-1"},Zl={class:"p-6"},Kl={key:0,class:"p-6 border-t-2 border-black dark:border-neutral-300 flex-shrink-0"},Ae=se({__name:"Modal",props:{modelValue:{type:Boolean},title:{},width:{default:"max-w-lg"},minHeight:{default:"min-h-[24rem]"},hasChanges:{type:Boolean,default:void 0}},emits:["update:modelValue","close"],setup(t,{emit:i}){const s=t,c=i,a=v(),u=v(!1),r=v(new Map),p=()=>a.value&&(a.value.querySelector("input")||a.value.querySelector("textarea")||a.value.querySelector("select")||a.value.querySelector("[contenteditable]")||a.value.querySelector(".monaco-editor")),f=()=>{if(!a.value)return;a.value.querySelectorAll(".monaco-editor-container").forEach(q=>{const J=q.__monacoEditor;if(J&&typeof J.getValue=="function"){const X=J.getValue();r.value.set(q,X)}})},b=()=>{if(!a.value)return!1;const A=a.value.querySelectorAll(".monaco-editor-container");for(const q of A){const J=q.__monacoEditor;if(J&&typeof J.getValue=="function"){const X=J.getValue(),P=r.value.get(q);if(P===void 0||(J.getRawOptions?.()||{}).readOnly===!0)continue;if(X!==P)return!0}}return!1},n=()=>{if(s.hasChanges!==void 0)return s.hasChanges;if(!a.value)return!1;if(b())return!0;const A=a.value.querySelectorAll("form");for(const J of A){const P=J.querySelectorAll("input, textarea, select");for(const _ of P){const O=_;if(O.type==="checkbox"||O.type==="radio"){const D=O;if(D.checked!==D.defaultChecked)return!0}else if(O.tagName==="SELECT"){const D=O;if(D.value!==D.defaultValue)return!0}else if(O.value!==O.defaultValue)return!0}}const q=a.value.querySelectorAll("input:not(form input), textarea:not(form textarea), select:not(form select)");for(const J of q){const X=J;if(X.type==="checkbox"||X.type==="radio"){const P=X;if(P.checked!==P.defaultChecked)return!0}else if(X.tagName==="SELECT"){const P=X;if(P.value!==P.defaultValue)return!0}else if(X.value!==X.defaultValue)return!0}return!1},d=()=>{p()&&n()?u.value=!0:h()},h=()=>{c("update:modelValue",!1),c("close")},$=()=>{u.value=!1,h()},g=()=>{u.value=!1},m=A=>{A.key==="Escape"&&s.modelValue&&(p()||h())};ie(()=>s.modelValue,async A=>{A?(document.addEventListener("keydown",m),document.body.style.overflow="hidden",await xe(),setTimeout(()=>{f()},100)):(document.removeEventListener("keydown",m),document.body.style.overflow="",r.value.clear())});const C=v(!1),w=A=>{C.value=A.target===A.currentTarget},E=A=>{A.target===A.currentTarget&&C.value&&(p()||h()),C.value=!1};return(A,q)=>(o(),Q(ht,{to:"body"},[I(Be,{"enter-active-class":"transition-opacity duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-200","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:de(()=>[t.modelValue?(o(),l("div",{key:0,class:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-white/80 dark:bg-black/80 backdrop-blur-sm dark:text-white",onMousedown:w,onClick:E},[I(Be,{"enter-active-class":"transition-all duration-200","enter-from-class":"opacity-0 scale-95","enter-to-class":"opacity-100 scale-100","leave-active-class":"transition-all duration-200","leave-from-class":"opacity-100 scale-100","leave-to-class":"opacity-0 scale-95"},{default:de(()=>[t.modelValue?(o(),l("div",{key:0,class:oe(["w-full",t.width,"max-h-[85vh] flex flex-col"])},[I(Ke,{"offset-x":12,"offset-y":12,intensity:.4},{default:de(()=>[e("div",{ref_key:"modalRef",ref:a,class:oe(["bg-white dark:bg-black border-2 border-black dark:border-neutral-300 flex flex-col max-h-[85vh]",t.minHeight])},[e("div",Hl,[e("h2",Wl,V(t.title),1),e("button",{onClick:d,class:"p-1 hover:bg-black/5 dark:hover:bg-white/10 rounded transition-colors","aria-label":"Close modal"},[I(F(Kt),{class:"w-5 h-5"})])]),e("div",Jl,[e("div",Zl,[Je(A.$slots,"default")])]),A.$slots.footer?(o(),l("div",Kl,[Je(A.$slots,"footer")])):M("",!0)],2)]),_:3})],2)):M("",!0)]),_:3})],32)):M("",!0)]),_:3}),I(Gt,{modelValue:u.value,"onUpdate:modelValue":q[0]||(q[0]=J=>u.value=J),title:"Unsaved Changes",message:"You have unsaved changes that will be lost. Are you sure you want to close?","confirm-text":"Close Anyway","cancel-text":"Keep Editing",onConfirm:$,onCancel:g},null,8,["modelValue"])]))}}),Gl={class:"space-y-1.5"},Xl={key:0,class:"block text-sm font-medium text-neutral-700 dark:text-neutral-300"},Yl={key:0,class:"text-red-500"},Ql=["type","value","placeholder","disabled"],es={key:1,class:"text-xs text-red-500 dark:text-red-400"},Ce=se({__name:"TextInput",props:{modelValue:{},label:{},placeholder:{},type:{default:"text"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","focus","click"],setup(t,{expose:i,emit:s}){const c=t,a=s,u=v(null),r=z(()=>["w-full px-3 py-2.5 bg-neutral-50 dark:bg-neutral-950 border rounded-md text-sm","focus:outline-none focus:ring-2 focus:ring-neutral-400 dark:focus:ring-neutral-500 focus:border-transparent","transition-colors placeholder:text-neutral-400 dark:placeholder:text-neutral-500",c.error?"border-red-500 dark:border-red-400":"border-neutral-300 dark:border-neutral-800",c.disabled?"opacity-50 cursor-not-allowed":""]),p=n=>{const d=n.target;a("update:modelValue",d.value)},f=n=>{a("focus",n)},b=n=>{a("click",n)};return i({inputRef:u}),(n,d)=>(o(),l("div",Gl,[t.label?(o(),l("label",Xl,[ke(V(t.label)+" ",1),t.required?(o(),l("span",Yl,"*")):M("",!0)])):M("",!0),e("input",{ref_key:"inputRef",ref:u,type:t.type,value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,class:oe(r.value),onInput:p,onFocus:f,onClick:b},null,42,Ql),t.error?(o(),l("p",es,V(t.error),1)):M("",!0)]))}}),ts={class:"space-y-1"},os={key:0,class:"block text-sm font-medium"},as={key:0,class:"text-red-500"},ls=["value","placeholder","disabled","rows"],ss={key:1,class:"text-xs text-red-500 dark:text-red-400"},Xt=se({__name:"TextareaInput",props:{modelValue:{},label:{},placeholder:{},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},rows:{default:4}},emits:["update:modelValue"],setup(t,{emit:i}){const s=t,c=i,a=z(()=>["w-full px-3 py-2 bg-white dark:bg-black border rounded font-mono text-sm","focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white","transition-colors resize-y",s.error?"border-red-500 dark:border-red-400":"border-black dark:border-neutral-300",s.disabled?"opacity-50 cursor-not-allowed":""]),u=r=>{const p=r.target;c("update:modelValue",p.value)};return(r,p)=>(o(),l("div",ts,[t.label?(o(),l("label",os,[ke(V(t.label)+" ",1),t.required?(o(),l("span",as,"*")):M("",!0)])):M("",!0),e("textarea",{value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,rows:t.rows,class:oe(a.value),onInput:u},null,42,ls),t.error?(o(),l("p",ss,V(t.error),1)):M("",!0)]))}}),ns={key:0,class:"block text-sm font-medium mb-2"},rs={key:0,class:"text-red-500"},is=["disabled","aria-expanded"],ds={class:"flex items-center justify-between gap-1"},us={key:0,class:"flex items-center gap-2 text-neutral-400 flex-1 min-w-0"},cs={key:1,class:"flex items-center gap-2 flex-1 min-w-0"},ps=["src","alt"],ms={class:"block truncate"},vs={key:2,class:"block truncate text-neutral-400 flex-1 min-w-0"},fs={class:"bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded-lg overflow-hidden"},hs={class:"p-2 border-b border-neutral-200 dark:border-neutral-700"},gs=["placeholder"],bs={class:"max-h-60 overflow-y-auto"},xs={key:0,class:"px-4 py-3 text-sm text-neutral-500 dark:text-neutral-400"},ys=["onClick","onMouseenter"],ks={class:"flex-shrink-0 w-5 h-5 mt-0.5"},ws=["src","alt"],_s={key:1,class:"w-full h-full bg-neutral-200 dark:bg-neutral-700 rounded"},$s={class:"flex-1 min-w-0"},Cs={class:"text-sm font-medium text-black dark:text-white"},Vs={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},Ss={key:2,class:"mt-1 text-xs text-red-500 dark:text-red-400"},ge=se({__name:"SelectInput",props:{modelValue:{},options:{},placeholder:{default:"Select an option"},searchPlaceholder:{default:"Search..."},label:{},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},error:{},required:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{emit:i}){const s=t,c=i,a=v(!1),u=v(""),r=v(),p=v(),f=v(),b=v(),n=v(-1),d=z(()=>s.options.find(_=>_.value===s.modelValue)),h=z(()=>["w-full px-3 py-2 text-left rounded focus:outline-none focus:ring-2 bg-white dark:bg-black disabled:opacity-50 disabled:cursor-not-allowed font-mono text-sm overflow-hidden",s.error?"border border-red-500 dark:border-red-400 focus:ring-red-500 dark:focus:ring-red-400":"border border-black dark:border-neutral-300 focus:ring-black dark:focus:ring-white"]),$=z(()=>{if(!u.value)return s.options;const _=u.value.toLowerCase();return s.options.filter(O=>O.label.toLowerCase().includes(_)||O.value.toLowerCase().includes(_)||O.description&&O.description.toLowerCase().includes(_))});ie($,()=>{n.value=-1});const g=()=>{s.disabled||(a.value?w():(a.value=!0,u.value="",n.value=-1,xe(()=>{if(b.value&&(b.value.setAttribute("popover","auto"),b.value.addEventListener("toggle",P),"showPopover"in b.value))try{b.value.showPopover()}catch{}E(),setTimeout(()=>r.value?.focus(),0)})))},m=_=>{c("update:modelValue",_.value),w(),u.value="",n.value=-1},C=_=>{_.stopPropagation(),c("update:modelValue","")},w=()=>{if(b.value){if("hidePopover"in b.value)try{b.value.hidePopover()}catch{}b.value.removeEventListener("toggle",P)}a.value=!1,n.value=-1},E=()=>{if(!f.value||!b.value)return;const _=f.value.getBoundingClientRect();b.value.offsetWidth||_.width,b.value.style.position="fixed",b.value.style.top=`${_.bottom+8}px`,b.value.style.left=`${_.left}px`,b.value.style.width=`${_.width}px`,b.value.style.margin="0"},A=_=>{p.value&&!p.value.contains(_.target)&&b.value&&!b.value.contains(_.target)&&w()},q=_=>{_.key==="Escape"&&a.value&&(w(),f.value?.focus())},J=_=>{if(!a.value)return;const O=$.value;if(O.length!==0)switch(_.key){case"ArrowDown":_.preventDefault(),n.value=n.value<O.length-1?n.value+1:0,X();break;case"ArrowUp":_.preventDefault(),n.value=n.value>0?n.value-1:O.length-1,X();break;case"Enter":_.preventDefault(),n.value>=0&&n.value<O.length&&m(O[n.value]);break}},X=()=>{xe(()=>{const _=b.value?.querySelector(".highlighted-option");_&&_.scrollIntoView({block:"nearest",behavior:"smooth"})})},P=_=>{_.target===b.value&&(a.value=_.newState==="open",a.value&&E())};return ye(()=>{document.addEventListener("click",A),document.addEventListener("keydown",q);const _=()=>{a.value&&E()};window.addEventListener("resize",_),window.addEventListener("scroll",_,!0)}),je(()=>{document.removeEventListener("click",A),document.removeEventListener("keydown",q),window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}),(_,O)=>(o(),l("div",{ref_key:"dropdownRef",ref:p,class:"relative"},[t.label?(o(),l("label",ns,[ke(V(t.label)+" ",1),t.required?(o(),l("span",rs,"*")):M("",!0)])):M("",!0),e("button",{ref_key:"buttonRef",ref:f,type:"button",onClick:g,disabled:t.disabled,"aria-expanded":a.value,"aria-haspopup":!0,class:oe(h.value)},[e("div",ds,[t.loading?(o(),l("span",us,[...O[1]||(O[1]=[e("svg",{class:"animate-spin h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})],-1),ke(" Loading... ",-1)])])):d.value?(o(),l("span",cs,[d.value.icon?(o(),l("img",{key:0,src:d.value.icon,alt:d.value.label,class:"w-5 h-5 flex-shrink-0"},null,8,ps)):M("",!0),e("span",ms,V(d.value.label),1)])):(o(),l("span",vs,V(t.placeholder),1)),d.value&&!t.disabled?(o(),l("button",{key:3,type:"button",onClick:C,class:"flex-shrink-0 p-0.5 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors","aria-label":"Clear selection"},[...O[2]||(O[2]=[e("svg",{class:"h-4 w-4 text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[e("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)])])):M("",!0),O[3]||(O[3]=e("svg",{class:"h-5 w-5 text-neutral-400 flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[e("path",{"fill-rule":"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1))])],10,is),a.value?(o(),l("div",{key:1,ref_key:"popoverRef",ref:b,class:"dropdown-popover"},[I(Ke,{"offset-x":4,"offset-y":4,intensity:.3},{default:de(()=>[e("div",fs,[e("div",hs,[_e(e("input",{ref_key:"searchInput",ref:r,"onUpdate:modelValue":O[0]||(O[0]=D=>u.value=D),type:"text",placeholder:t.searchPlaceholder,onKeydown:J,class:"w-full px-3 py-1.5 text-sm border border-neutral-300 dark:border-neutral-600 rounded focus:outline-none focus:ring-1 focus:ring-black dark:focus:ring-white bg-white dark:bg-black text-black dark:text-white placeholder:text-neutral-400 dark:placeholder:text-neutral-500"},null,40,gs),[[Ee,u.value]])]),e("div",bs,[$.value.length===0?(o(),l("div",xs," No options found ")):M("",!0),(o(!0),l(ce,null,fe($.value,(D,N)=>(o(),l("button",{key:D.value,type:"button",onClick:U=>m(D),onMouseenter:U=>n.value=N,class:oe(["w-full px-4 py-2 text-left hover:bg-neutral-100 dark:hover:bg-neutral-900 focus:bg-neutral-100 dark:focus:bg-neutral-900 focus:outline-none flex items-start gap-3",{"bg-neutral-50 dark:bg-neutral-900":D.value===t.modelValue,"bg-neutral-100 dark:bg-neutral-800 highlighted-option":N===n.value}])},[e("div",ks,[D.icon?(o(),l("img",{key:0,src:D.icon,alt:D.label,class:"w-full h-full"},null,8,ws)):(o(),l("div",_s))]),e("div",$s,[e("div",Cs,V(D.label),1),D.description?(o(),l("div",Vs,V(D.description),1)):M("",!0)])],42,ys))),128))])])]),_:1})],512)):M("",!0),t.error?(o(),l("p",Ss,V(t.error),1)):M("",!0)],512))}}),Ts={class:"flex items-start"},Ms=["for"],Is=["id","checked","disabled"],Ls={class:"flex items-center h-5"},Es={class:"flex-1"},As={key:0,class:"text-red-500"},Ps={key:1,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-1"},Os={key:2,class:"text-xs text-red-500 dark:text-red-400 mt-1"},Ve=se({__name:"CheckboxInput",props:{modelValue:{type:Boolean,default:!1},label:{},helpText:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},error:{}},emits:["update:modelValue"],setup(t,{emit:i}){const s=t,c=i,a=ho(),u=z(()=>["w-5 h-5 border-2 rounded relative flex-shrink-0","transition-all duration-150",s.error?"border-red-500 dark:border-red-400":"border-black dark:border-neutral-300",s.disabled?"opacity-50":"hover:scale-110",s.modelValue?"bg-black dark:bg-white":"bg-white dark:bg-black","before:content-[''] before:absolute before:inset-0 before:m-auto before:w-2.5 before:h-1.5 before:border-white dark:before:border-black before:border-b-2 before:border-l-2 before:rotate-[-45deg]",s.modelValue?"before:block":"before:hidden"]),r=p=>{if(!s.disabled){const f=p.target;c("update:modelValue",f.checked)}};return(p,f)=>(o(),l("div",Ts,[e("label",{for:F(a),class:oe(["flex items-start space-x-3 cursor-pointer select-none",{"cursor-not-allowed":t.disabled}])},[e("input",{id:F(a),type:"checkbox",checked:t.modelValue,disabled:t.disabled,onChange:r,class:"absolute left-[-9999px]"},null,40,Is),e("div",Ls,[e("span",{class:oe(u.value)},null,2)]),e("div",Es,[t.label?(o(),l("span",{key:0,class:oe(["block text-sm font-medium",{"opacity-50":t.disabled}])},[ke(V(t.label)+" ",1),t.required?(o(),l("span",As,"*")):M("",!0)],2)):M("",!0),t.helpText?(o(),l("p",Ps,V(t.helpText),1)):M("",!0),t.error?(o(),l("p",Os,V(t.error),1)):M("",!0)])],10,Ms)]))}}),js={key:0,class:"min-h-[400px] flex items-center justify-center"},Ds={key:1,class:"space-y-6 pr-2 pb-4"},Us={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Ns={key:1,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Rs={key:0},Bs={key:1},qs={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Fs={key:2},zs={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Hs={class:"grid grid-cols-2 gap-6"},Ws={class:"space-y-4 p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},Js={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Zs={class:"space-y-3"},Ks={class:"flex items-start"},Gs={key:0,class:"ml-8 mt-2 space-y-2"},Xs={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"},Ys={key:1},Qs={key:0,class:"mt-3 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded"},en={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},tn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},on={class:"space-y-4 p-4 bg-neutral-100 dark:bg-neutral-800 rounded-lg"},an={class:"font-semibold text-base mb-4 text-neutral-800 dark:text-neutral-200"},ln={key:0,class:"flex flex-col items-center justify-center py-8"},sn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},nn={class:"space-y-3"},rn={class:"flex items-start"},dn={key:0,class:"ml-8 mt-2 space-y-2"},un={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"},cn={key:1},pn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},mn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},vn={class:"flex justify-between"},fn=["disabled"],hn=se({__name:"AgentModal",props:{modelValue:{type:Boolean},editAgent:{},mode:{}},emits:["update:modelValue","save"],setup(t,{emit:i}){const s=t,c=i,a=z(()=>s.mode==="edit"),u=v(!1),r=v(""),p=v(""),f=v(""),b=v(null),n=v(""),d=v("dual_ai"),h=v(!1),$=v(""),g=v(""),m=v(null),C=v(""),w=v(""),E=v(""),A=v(""),q=v(!0),J=v(!1),X=v(""),P=v(""),_=v(""),O=v(""),D=v(!1),N=v(null),U=v(""),L=v(""),T=v(""),j=v(""),S=v(""),x=v(""),y=v(!0),k=v(!1),R=v(""),K=v(""),H=v(""),W=v(""),G=v(null),ue=v(""),he=v(""),Z=v(""),{data:ee,execute:ae}=Me(te("/api/prompts"),{immediate:!1}).json(),{data:pe,execute:ve}=Me(te("/api/tools?schema=true"),{immediate:!1}).json(),we=v(null),Se=v(!1),re=v(null),ne=v(!1),me=v(!1),Le=z(()=>{if(!ee.value)return[{value:"",label:"Select a prompt..."}];const le=ee.value?.prompts||[];return[{value:"",label:"None"},...le.map(B=>({value:B.id,label:B.name}))]}),Xe=le=>pe.value?pe.value[le]:null,yt=z(()=>!we.value||!we.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...we.value.tools.map(le=>{const B=typeof le=="string"?le:le.name;return{value:B,label:B}})]),kt=z(()=>!re.value||!re.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...re.value.tools.map(le=>{const B=typeof le=="string"?le:le.name;return{value:B,label:B}})]),lo=z(()=>{if(!X.value)return[];const le=Xe(X.value);return!le||!le.schema||!le.schema.properties?[]:Object.keys(le.schema.properties).map(B=>({value:B,label:B}))}),so=z(()=>{if(!R.value)return[];const le=Xe(R.value);return!le||!le.schema||!le.schema.properties?[]:Object.keys(le.schema.properties).map(B=>({value:B,label:B}))}),no=[{value:"dual_ai",label:"AI + AI (Subagent)"},{value:"ai_human",label:"AI + Human"}],wt=z({get(){return p.value},set(le){const B=b.value?.inputRef,Y=B?.selectionStart??le.length;let Pe=le.toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_]/g,"");if(Pe.endsWith("_agent")||(Pe=Pe+"_agent"),p.value=Pe,B){B.value=Pe;const Ie=Math.min(Y,Pe.length-6);B.setSelectionRange(Ie,Ie)}}}),_t=async()=>{await xe();const le=b.value?.inputRef;if(le&&p.value.endsWith("_agent")){const B=p.value.length-6;le.setSelectionRange(B,B)}},ro=le=>!le||le==="_agent"?(f.value="Name is required",!1):/^[a-z][a-z0-9_]*_agent$/.test(le)?(f.value="",!0):(f.value="Name must start with a letter",!1),Ye=()=>{p.value="",r.value="",f.value="",n.value="",d.value="dual_ai",h.value=!1,$.value="",g.value="",m.value=null,C.value="",E.value="",A.value="",q.value=!0,J.value=!1,X.value="",P.value="",_.value="",O.value="",D.value=!1,N.value=null,U.value="",L.value="",T.value="",we.value=null,S.value="",x.value="",y.value=!0,k.value=!1,R.value="",K.value="",H.value="",W.value="",G.value=null,ue.value="",he.value="",Z.value="",re.value=null},io=async()=>{if(s.editAgent?.id){u.value=!0,me.value=!0;try{const le=await fetch(te(`/api/agents/${s.editAgent.id}`));if(le.ok){const B=await le.json(),Y=B.agent||B;p.value=Y.name||"",r.value=Y.name||"",n.value=Y.title||"",d.value=Y.type||"dual_ai",h.value=Y.expose_as_tool||!1,$.value=Y.tool_description||"",m.value=Y.max_session_turns;const Pe=Y.side_a_stop_tool||"",Ie=Y.side_a_stop_tool_response_property||"",po=Y.side_b_stop_tool||"",mo=Y.side_b_stop_tool_response_property||"",vo=Y.side_a_end_conversation_tool||"",fo=Y.side_b_end_conversation_tool||"";w.value=Y.side_a_label||"",j.value=Y.side_b_label||"",E.value=Y.side_a_agent_prompt||"",S.value=Y.side_b_agent_prompt||"",q.value=!!Y.side_a_stop_on_response,J.value=!!Y.side_a_stop_tool,D.value=!!Y.side_a_manual_stop_condition,N.value=Y.side_a_max_turns,y.value=!!Y.side_b_stop_on_response,k.value=!!Y.side_b_stop_tool,G.value=Y.side_b_max_turns,await xe(),X.value=Pe,_.value=Ie,R.value=po,H.value=mo,L.value=vo,he.value=fo}}catch(le){console.error("Error loading agent data:",le)}finally{u.value=!1,me.value=!1}}},uo=async()=>{f.value="",C.value="",A.value="",P.value="",O.value="",U.value="",T.value="",x.value="",K.value="",W.value="",ue.value="",Z.value="";let le=!1;ro(p.value)||(le=!0);const B=p.value;d.value==="dual_ai"&&m.value!==null&&m.value!==void 0&&m.value<=0&&(C.value="Max session turns must be a positive number",le=!0),E.value||(A.value="Please select an agent prompt",le=!0);const Y=q.value||X.value,Pe=d.value==="ai_human"&&D.value;if(!Y&&!Pe&&(A.value="At least one stop condition is required (or check manual stop condition for ai_human agents)",le=!0),X.value&&!_.value&&(O.value="Response property required when using stop tool",le=!0),N.value!==null&&N.value<=0&&(U.value="Max turns must be a positive number",le=!0),d.value==="dual_ai"&&!L.value&&!he.value&&(T.value="At least one side must have an end conversation tool",Z.value="At least one side must have an end conversation tool",le=!0),d.value==="dual_ai"&&(S.value||(x.value="Please select an agent prompt",le=!0),R.value&&!H.value&&(W.value="Response property required when using stop tool",le=!0),G.value!==null&&G.value<=0&&(ue.value="Max turns must be a positive number",le=!0)),le)return;const Ie={name:B,title:n.value||null,type:d.value,expose_as_tool:h.value,tool_description:h.value?$.value:null,max_session_turns:d.value==="dual_ai"?m.value:null,side_a_label:w.value||null,side_a_agent_prompt:E.value,side_a_stop_on_response:q.value,side_a_stop_tool:X.value||null,side_a_stop_tool_response_property:_.value||null,side_a_manual_stop_condition:D.value,side_a_max_turns:N.value,side_a_end_conversation_tool:L.value||null};d.value==="dual_ai"&&(Ie.side_b_label=j.value||null,Ie.side_b_agent_prompt=S.value,Ie.side_b_stop_on_response=y.value,Ie.side_b_stop_tool=R.value||null,Ie.side_b_stop_tool_response_property=H.value||null,Ie.side_b_max_turns=G.value,Ie.side_b_end_conversation_tool=he.value||null),a.value&&s.editAgent?.id&&(Ie.id=s.editAgent.id),c("save",Ie),Ye(),c("update:modelValue",!1)},co=()=>{Ye(),c("update:modelValue",!1)};return ie(E,async le=>{if(me.value||(X.value="",_.value=""),!le){we.value=null;return}Se.value=!0;try{const B=await fetch(te(`/api/prompts/${le}`));B.ok&&(we.value=await B.json())}catch(B){console.error("Error fetching Side A prompt:",B)}finally{Se.value=!1}}),ie(S,async le=>{if(me.value||(R.value="",H.value=""),!le){re.value=null;return}ne.value=!0;try{const B=await fetch(te(`/api/prompts/${le}`));B.ok&&(re.value=await B.json())}catch(B){console.error("Error fetching Side B prompt:",B)}finally{ne.value=!1}}),ie(J,le=>{le||(X.value="",_.value="")}),ie(k,le=>{le||(R.value="",H.value="")}),ie(()=>s.modelValue,async le=>{le&&(await Promise.all([ae(),ve()]),a.value?(Ye(),await io()):Ye())}),(le,B)=>(o(),Q(Ae,{"model-value":t.modelValue,"onUpdate:modelValue":B[23]||(B[23]=Y=>le.$emit("update:modelValue",Y)),title:a.value?"Edit Agent":"Create Agent",width:"max-w-6xl"},{footer:de(()=>[e("div",vn,[e("button",{onClick:co,type:"button",class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors"}," Cancel "),e("button",{onClick:uo,type:"button",class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity",disabled:u.value},V(a.value?"Update Agent":"Create Agent"),9,fn)])]),default:de(()=>[u.value?(o(),l("div",js,[...B[24]||(B[24]=[e("span",{class:"text-neutral-500"},"Loading agent data...",-1)])])):(o(),l("div",Ds,[e("div",null,[I(Ce,{ref_key:"nameInputRef",ref:b,modelValue:wt.value,"onUpdate:modelValue":B[0]||(B[0]=Y=>wt.value=Y),label:"Agent Name",placeholder:"research_agent",error:f.value,required:"",disabled:a.value,onFocus:_t,onClick:_t},null,8,["modelValue","error","disabled"]),!f.value&&!a.value?(o(),l("p",Us," Names are automatically formatted to snake_case with the _agent suffix ")):M("",!0),a.value?(o(),l("p",Ns," Agent names cannot be changed after creation (used as foreign key for threads) ")):M("",!0)]),e("div",null,[I(Ce,{modelValue:n.value,"onUpdate:modelValue":B[1]||(B[1]=Y=>n.value=Y),label:"Display Title (Optional)",placeholder:"Research Assistant"},null,8,["modelValue"]),B[25]||(B[25]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Human-readable title shown in the UI. If not set, the name will be used. ",-1))]),e("div",null,[I(ge,{modelValue:d.value,"onUpdate:modelValue":B[2]||(B[2]=Y=>d.value=Y),label:"Agent Type",options:no},null,8,["modelValue"]),B[26]||(B[26]=e("p",{class:"mt-1 text-sm text-neutral-500 dark:text-neutral-400"}," Choose between two AI agents conversing, or an AI agent conversing with a human ",-1))]),d.value==="dual_ai"?(o(),l("div",Rs,[I(Ve,{modelValue:h.value,"onUpdate:modelValue":B[3]||(B[3]=Y=>h.value=Y),label:"Expose as Tool"},null,8,["modelValue"]),B[27]||(B[27]=e("p",{class:"mt-1 text-sm text-neutral-500 dark:text-neutral-400"}," Make this subagent available as a tool that can be called by other prompts or agents. When called, it will execute as a subagent. ",-1))])):M("",!0),h.value&&d.value==="dual_ai"?(o(),l("div",Bs,[I(Xt,{modelValue:$.value,"onUpdate:modelValue":B[4]||(B[4]=Y=>$.value=Y),label:"Tool Description",placeholder:"Describe what this agent does when called as a tool",error:g.value,rows:3},null,8,["modelValue","error"]),g.value?M("",!0):(o(),l("p",qs," This description helps other agents understand when to use this agent "))])):M("",!0),d.value==="dual_ai"?(o(),l("div",Fs,[I(Ce,{"model-value":m.value?.toString()||"","onUpdate:modelValue":B[5]||(B[5]=Y=>m.value=Y?parseInt(Y):null),label:"Max Session Turns",type:"number",error:C.value,placeholder:"Unlimited"},null,8,["model-value","error"]),C.value?M("",!0):(o(),l("p",zs," Maximum number of back-and-forth exchanges between the two agents before the conversation ends "))])):M("",!0),e("div",Hs,[e("div",Ws,[B[34]||(B[34]=e("h4",{class:"font-semibold text-base mb-4 text-neutral-800 dark:text-neutral-200"}," Side A (AI) ",-1)),e("div",null,[I(Ce,{modelValue:w.value,"onUpdate:modelValue":B[6]||(B[6]=Y=>w.value=Y),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer, Support"},null,8,["modelValue"]),B[28]||(B[28]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Custom label for this side (shows in message bubbles and toggle) ",-1))]),e("div",null,[I(ge,{modelValue:E.value,"onUpdate:modelValue":B[7]||(B[7]=Y=>E.value=Y),label:"Agent Prompt",options:Le.value,error:A.value,required:""},null,8,["modelValue","options","error"]),A.value?M("",!0):(o(),l("p",Js," The prompt that defines this agent's behavior "))]),e("div",Zs,[B[31]||(B[31]=e("label",{class:"block text-sm font-medium"}," Stop Conditions ",-1)),B[32]||(B[32]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"}," Optional. If no stop conditions are set, the agent will continue until programmatically stopped or end conversation tool is called. ",-1)),e("div",Ks,[I(Ve,{modelValue:q.value,"onUpdate:modelValue":B[8]||(B[8]=Y=>q.value=Y),label:"Stop when agent returns content"},null,8,["modelValue"])]),B[33]||(B[33]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-2 ml-6"}," Agent stops when it returns a response without calling tools ",-1)),e("div",null,[I(Ve,{modelValue:J.value,"onUpdate:modelValue":B[9]||(B[9]=Y=>J.value=Y),label:"Stop on specific tool call"},null,8,["modelValue"]),J.value?(o(),l("div",Gs,[I(ge,{modelValue:X.value,"onUpdate:modelValue":B[10]||(B[10]=Y=>X.value=Y),label:"Stop Tool",options:yt.value,error:P.value,placeholder:"Select a tool...",disabled:Se.value||!E.value},null,8,["modelValue","options","error","disabled"]),P.value?M("",!0):(o(),l("p",Xs," Agent stops when this tool is called ")),X.value?(o(),l("div",Ys,[I(ge,{modelValue:_.value,"onUpdate:modelValue":B[11]||(B[11]=Y=>_.value=Y),label:"Response Property",options:lo.value,error:O.value,placeholder:"Select property..."},null,8,["modelValue","options","error"]),B[29]||(B[29]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Property from tool arguments to return as final response ",-1))])):M("",!0)])):M("",!0)]),d.value==="ai_human"&&!q.value&&!J.value?(o(),l("div",Qs,[I(Ve,{modelValue:D.value,"onUpdate:modelValue":B[12]||(B[12]=Y=>D.value=Y),label:"I have manually implemented a stop condition"},null,8,["modelValue"]),B[30]||(B[30]=e("p",{class:"mt-2 text-xs text-yellow-800 dark:text-yellow-200"}," ⚠️ Warning: Only check this if you have implemented a custom stop condition in your code (e.g., via hooks or custom logic). Without a stop condition, the agent may run indefinitely. ",-1))])):M("",!0)]),e("div",null,[I(Ce,{"model-value":N.value?.toString()||"","onUpdate:modelValue":B[13]||(B[13]=Y=>N.value=Y?parseInt(Y):null),label:"Max Turns",type:"number",error:U.value,placeholder:"Unlimited"},null,8,["model-value","error"]),U.value?M("",!0):(o(),l("p",en," Maximum turns this side can take before yielding (safety limit) "))]),e("div",null,[I(ge,{modelValue:L.value,"onUpdate:modelValue":B[14]||(B[14]=Y=>L.value=Y),label:"End Conversation Tool",options:yt.value,error:T.value,placeholder:"Select a tool...",disabled:Se.value||!E.value},null,8,["modelValue","options","error","disabled"]),T.value?M("",!0):(o(),l("p",tn," Tool that ends the entire conversation when called "))])]),e("div",on,[e("h4",an," Side B ("+V(d.value==="ai_human"?"Human":"AI")+") ",1),e("div",null,[I(Ce,{modelValue:j.value,"onUpdate:modelValue":B[15]||(B[15]=Y=>j.value=Y),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer, Support"},null,8,["modelValue"]),B[35]||(B[35]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Custom label for this side (shows in message bubbles and toggle) ",-1))]),d.value==="ai_human"?(o(),l("div",ln,[...B[36]||(B[36]=[e("svg",{class:"w-20 h-20 mb-4 text-neutral-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})],-1),e("h5",{class:"font-medium text-lg mb-2"},"Human User",-1),e("p",{class:"text-sm text-neutral-500 dark:text-neutral-400 text-center max-w-xs"}," This side of the conversation will be handled by a human user through the interface ",-1)])])):(o(),l(ce,{key:1},[e("div",null,[I(ge,{modelValue:S.value,"onUpdate:modelValue":B[16]||(B[16]=Y=>S.value=Y),label:"Agent Prompt",options:Le.value,error:x.value,required:""},null,8,["modelValue","options","error"]),x.value?M("",!0):(o(),l("p",sn," The prompt that defines this agent's behavior "))]),e("div",nn,[B[38]||(B[38]=e("label",{class:"block text-sm font-medium"}," Stop Conditions ",-1)),B[39]||(B[39]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"}," Optional. If no stop conditions are set, the agent will continue until programmatically stopped or end conversation tool is called. ",-1)),e("div",rn,[I(Ve,{modelValue:y.value,"onUpdate:modelValue":B[17]||(B[17]=Y=>y.value=Y),label:"Stop when agent returns content"},null,8,["modelValue"])]),B[40]||(B[40]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-2 ml-6"}," Agent stops when it returns a response without calling tools ",-1)),e("div",null,[I(Ve,{modelValue:k.value,"onUpdate:modelValue":B[18]||(B[18]=Y=>k.value=Y),label:"Stop on specific tool call"},null,8,["modelValue"]),k.value?(o(),l("div",dn,[I(ge,{modelValue:R.value,"onUpdate:modelValue":B[19]||(B[19]=Y=>R.value=Y),label:"Stop Tool",options:kt.value,error:K.value,placeholder:"Select a tool...",disabled:ne.value||!S.value},null,8,["modelValue","options","error","disabled"]),K.value?M("",!0):(o(),l("p",un," Agent stops when this tool is called ")),R.value?(o(),l("div",cn,[I(ge,{modelValue:H.value,"onUpdate:modelValue":B[20]||(B[20]=Y=>H.value=Y),label:"Response Property",options:so.value,error:W.value,placeholder:"Select property..."},null,8,["modelValue","options","error"]),B[37]||(B[37]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Property from tool arguments to return as final response ",-1))])):M("",!0)])):M("",!0)])]),e("div",null,[I(Ce,{"model-value":G.value?.toString()||"","onUpdate:modelValue":B[21]||(B[21]=Y=>G.value=Y?parseInt(Y):null),label:"Max Turns",type:"number",error:ue.value,placeholder:"Unlimited"},null,8,["model-value","error"]),ue.value?M("",!0):(o(),l("p",pn," Maximum turns this side can take before yielding (safety limit) "))]),e("div",null,[I(ge,{modelValue:he.value,"onUpdate:modelValue":B[22]||(B[22]=Y=>he.value=Y),label:"End Conversation Tool",options:kt.value,error:Z.value,placeholder:"Select a tool...",disabled:ne.value||!S.value},null,8,["modelValue","options","error","disabled"]),Z.value?M("",!0):(o(),l("p",mn," Tool that ends the entire conversation when called "))])],64))])])]))]),_:1},8,["model-value","title"]))}}),gn={},bn={class:"p-8 w-full max-w-7xl mx-auto"};function xn(t,i){return o(),l("div",bn,[Je(t.$slots,"default")])}const ze=Fe(gn,[["render",xn]]),yn=se({__name:"AgentsView",setup(t){const i=Ze(),s=Re(),c=v(!1),a=v("add"),u=v(null),r=v(null);ie(()=>s.query.refresh,()=>{s.query.refresh&&(r.value?.refresh(),i.replace({path:"/agents",query:{}}))});const p=()=>{a.value="add",u.value=null,c.value=!0},f=n=>{a.value="edit",u.value=n,c.value=!0},b=async n=>{try{const d=a.value==="edit"&&u.value?.id,{originalName:h,...$}=n,g=te(d?`/api/agents/${u.value.id}`:"/api/agents"),C=await fetch(g,{method:d?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($)});if(C.ok)r.value?.refresh(),c.value=!1,u.value=null;else{const w=await C.json();alert(w.error||`Failed to ${d?"update":"create"} agent`)}}catch(d){console.error(`Error ${a.value==="edit"?"updating":"creating"} agent:`,d),alert(`Failed to ${a.value==="edit"?"update":"create"} agent`)}};return(n,d)=>(o(),Q(ze,null,{default:de(()=>[e("div",{class:"flex justify-between items-center mb-6"},[d[1]||(d[1]=e("h1",{class:"text-3xl font-bold"},"Agents",-1)),e("button",{onClick:p,class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Create Agent ")]),d[2]||(d[2]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-6"}," Configure and manage your AI agents. ",-1)),I(jl,{ref_key:"dataTableRef",ref:r,onAdd:p,onEdit:f},null,512),I(hn,{modelValue:c.value,"onUpdate:modelValue":d[0]||(d[0]=h=>c.value=h),mode:a.value,editAgent:u.value,onSave:b},null,8,["modelValue","mode","editAgent"])]),_:1}))}});function kn(t){const{limit:i=50,offset:s=0,agentId:c=null,userId:a=null,autoFetch:u=!0}={},r=z(()=>{const C=new URLSearchParams,w=typeof i=="number"?i:i.value,E=typeof s=="number"?s:s.value,A=typeof c=="string"?c:c?.value,q=typeof a=="string"?a:a?.value;return C.append("limit",w.toString()),C.append("offset",E.toString()),A&&C.append("agent_id",A),q&&C.append("user_id",q),te(`/api/threads?${C.toString()}`)}),{data:p,error:f,isFetching:b,isFinished:n,execute:d,abort:h}=Me(r,{immediate:u}).get().json(),$=z(()=>p.value?.threads||[]),g=z(()=>p.value?.total||0),m=z(()=>p.value?.hasMore||!1);return{threads:$,total:g,hasMore:m,error:f,isFetching:b,isFinished:n,refetch:d,abort:h}}function bt(t){const i=z(()=>!!(typeof t=="string"?t:t?.value)),s=z(()=>{const n=typeof t=="string"?t:t?.value;return te(n?`/api/threads/${n}`:"/api/threads/placeholder")}),{data:c,error:a,isFetching:u,isFinished:r,execute:p,abort:f}=Me(s,{immediate:!1}).get().json();return ie(i,n=>{n&&p()},{immediate:!0}),{thread:z(()=>c.value?{id:c.value.thread.id,agent_id:c.value.thread.agent_id,user_id:c.value.thread.user_id,tags:c.value.thread.tags||[],created_at:c.value.thread.created_at,agent:c.value.agent||{id:"",title:"Unknown",type:"unknown"},stats:c.value.stats}:null),error:a,isFetching:u,isFinished:r,refetch:p,abort:f}}function wn(t){const{autoConnect:i=!0,onEvent:s}=t||{},c=v(null),a=v(!1),u=v(null),r=()=>{c.value&&c.value.close();const f=window.location.protocol==="https:"?"wss:":"ws:",b=window.location.host;let n=`${f}//${b}${te("/api/events")}`;const d=localStorage.getItem("auth_token");d&&(n+=`?token=${encodeURIComponent(d)}`);try{c.value=new WebSocket(n),c.value.onopen=()=>{a.value=!0,u.value=null,console.log("[AgentBuilderEvents] WebSocket connected")},c.value.onmessage=h=>{try{const $=JSON.parse(h.data);console.log("[AgentBuilderEvents] Received event:",$.type),s&&s($)}catch($){console.error("[AgentBuilderEvents] Failed to parse WebSocket message:",$)}},c.value.onerror=h=>{u.value="WebSocket connection error",a.value=!1,console.error("[AgentBuilderEvents] WebSocket error:",h)},c.value.onclose=()=>{a.value=!1,console.log("[AgentBuilderEvents] WebSocket disconnected")}}catch(h){u.value=h.message||"Failed to create WebSocket",console.error("[AgentBuilderEvents] WebSocket creation error:",h)}},p=()=>{c.value&&(c.value.close(),c.value=null,a.value=!1)};return i&&r(),je(()=>{p()}),{wsConnected:a,wsError:u,connect:r,disconnect:p}}const _n={class:"inline-flex items-center justify-center"},be=se({__name:"Loader",props:{size:{default:"md"}},setup(t){const i=t,s=z(()=>{switch(i.size){case"xs":return"w-3 h-3 border";case"sm":return"w-3.5 h-3.5 border";case"md":default:return"w-4 h-4 border-2"}});return(c,a)=>(o(),l("div",_n,[e("div",{class:oe([s.value,"border-black/20 dark:border-white/20 border-t-black dark:border-t-white rounded-full animate-spin"])},null,2)]))}});function $n(t){const s=Date.now()*1e3-t,c=Math.floor(s/1e6);if(c<60)return c===1?"1 second ago":`${c} seconds ago`;const a=Math.floor(c/60);if(a<60)return a===1?"1 minute ago":`${a} minutes ago`;const u=Math.floor(a/60);if(u<24)return u===1?"1 hour ago":`${u} hours ago`;const r=Math.floor(u/24);if(r<30)return r===1?"1 day ago":`${r} days ago`;const p=Math.floor(r/30);if(p<12)return p===1?"1 month ago":`${p} months ago`;const f=Math.floor(p/12);return f===1?"1 year ago":`${f} years ago`}function Cn(t){const i=v("");let s=null;const c=()=>typeof t=="function"?t():typeof t=="number"?t:t.value,a=()=>{const u=c();i.value=$n(u);const p=Date.now()*1e3-u,f=Math.floor(p/1e6);s!==null&&(clearInterval(s),s=null),f<60?s=setInterval(a,1e3):f<3600?s=setInterval(a,6e4):f<86400&&(s=setInterval(a,6e5))};return a(),je(()=>{s!==null&&clearInterval(s)}),i}const ot=se({__name:"TimeAgo",props:{timestamp:{}},setup(t){const i=t,s=Cn(()=>i.timestamp);return(c,a)=>(o(),l("span",null,V(F(s)),1))}}),Vn={class:"relative inline-flex items-center"},Sn={key:0,class:"inline-block w-2 h-2 rounded-full bg-green-500 dark:bg-green-400"},Tn={key:1,class:"inline-block w-2 h-2 rounded-full bg-red-500 dark:bg-red-400"},Mn={key:2,class:"inline-block w-2 h-2 rounded-full bg-neutral-400 dark:bg-neutral-600"},In={key:0},Ln={key:1},En={key:2},xt=se({__name:"StatusDot",props:{connected:{type:Boolean},error:{type:Boolean}},setup(t){const i=v(!1),s=v(null);return(c,a)=>(o(),l("div",Vn,[e("span",{class:"p-0.5 cursor-default outline-none",tabindex:"-1",onMouseenter:a[0]||(a[0]=u=>i.value=!0),onMouseleave:a[1]||(a[1]=u=>i.value=!1)},[t.connected?(o(),l("span",Sn)):t.error?(o(),l("span",Tn)):(o(),l("span",Mn))],32),I(Be,{"enter-active-class":"transition-opacity duration-150","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-100","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:de(()=>[i.value?(o(),l("div",{key:0,ref_key:"popoverRef",ref:s,class:oe(["absolute top-full left-1/2 -translate-x-1/2 mt-1 px-2 py-1 text-xs rounded shadow-lg whitespace-nowrap z-50 border",{"bg-green-50 dark:bg-green-950 border-green-200 dark:border-green-800 text-green-700 dark:text-green-300":t.connected,"bg-red-50 dark:bg-red-950 border-red-200 dark:border-red-800 text-red-700 dark:text-red-300":!t.connected&&t.error,"bg-neutral-50 dark:bg-neutral-900 border-neutral-200 dark:border-neutral-700 text-neutral-600 dark:text-neutral-400":!t.connected&&!t.error}])},[t.connected?(o(),l("span",In,"Live - Connected")):t.error?(o(),l("span",Ln,"Connection Error")):(o(),l("span",En,"Offline"))],2)):M("",!0)]),_:1})]))}}),An={class:"flex flex-col flex-1"},Pn={class:"p-4 border-b border-neutral-300 dark:border-neutral-700"},On={class:"flex items-center justify-between"},jn={class:"flex items-center gap-2"},Dn={class:"flex items-center gap-2"},Un={class:"flex-1 overflow-y-auto text-xs"},Nn={key:0,class:"p-2 flex justify-center"},Rn={key:1,class:"p-2 text-red-600 dark:text-red-400"},Bn={key:2,class:"text-neutral-500 dark:text-neutral-400 text-center py-12 text-base"},qn={key:3},Fn=["id","onClick"],zn={class:"flex items-center gap-2 mb-1"},Hn={class:"font-medium truncate flex-1 min-w-0"},Wn={class:"flex-shrink-0 text-neutral-500 dark:text-neutral-400"},Jn={key:0,class:"flex flex-wrap gap-1"},Zn=se({__name:"ThreadListPane",props:{selectedThreadId:{}},emits:["selectThread","collapse","createThread","threadsLoaded"],setup(t,{expose:i,emit:s}){const c=s;v("");const{threads:a,isFetching:u,isFinished:r,error:p,refetch:f}=kn(),b=v([]),n=v(new Set),d=z(()=>{const w=a.value.filter(q=>!n.value.has(q.id)),E=new Set(w.map(q=>q.id));return[...b.value.filter(q=>!E.has(q.id)&&!n.value.has(q.id)),...w].sort((q,J)=>J.created_at-q.created_at)}),h=async w=>{if(w.type==="thread_created"){const E={id:w.thread.id,agent_id:w.thread.agent_name,user_id:w.thread.user_id,tags:w.thread.tags||[],created_at:w.thread.created_at,agent:{title:w.thread.agent_name,type:"ai_human"}};b.value.unshift(E)}else w.type==="thread_deleted"&&(n.value.add(w.threadId),b.value=b.value.filter(E=>E.id!==w.threadId))},{wsConnected:$,wsError:g}=wn({onEvent:h});ie(a,()=>{b.value=[]});const m=v(!1);ie(()=>({threads:a.value,finished:r.value}),({threads:w,finished:E})=>{E&&!m.value&&(m.value=!0,c("threadsLoaded",w[0]?.id??null))},{immediate:!0}),i({refetch:f});const C=w=>{c("selectThread",w)};return(w,E)=>(o(),l("div",An,[e("div",Pn,[e("div",On,[e("div",jn,[I(F(Ut),{size:20,class:"shrink-0"}),E[2]||(E[2]=e("h2",{class:"text-xl font-bold"},"Threads",-1)),I(xt,{connected:F($),error:F(g)},null,8,["connected","error"])]),e("div",Dn,[e("button",{onClick:E[0]||(E[0]=A=>c("createThread")),type:"button",class:"px-2 py-1 text-xs bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity whitespace-nowrap"}," + New "),e("button",{onClick:E[1]||(E[1]=A=>c("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[I(F(gt),{size:20})])])])]),e("div",Un,[F(u)?(o(),l("div",Nn,[I(be)])):F(p)?(o(),l("div",Rn," Error: "+V(F(p)),1)):d.value.length===0?(o(),l("div",Bn," No threads found ")):(o(),l("div",qn,[(o(!0),l(ce,null,fe(d.value,A=>(o(),l("button",{key:A.id,id:`thread-${A.id}`,class:oe(["w-full text-left px-2 py-2 border-b border-neutral-200 dark:border-neutral-800 cursor-pointer transition-colors relative hover:ring-2 hover:ring-inset hover:ring-accent-400 dark:hover:ring-accent-400",{"bg-accent-100 dark:bg-accent-900 dark:text-white ring-2 ring-inset ring-accent-400 dark:ring-accent-400":t.selectedThreadId===A.id}]),onClick:q=>C(A.id)},[e("div",zn,[e("span",Hn,V(A.agent.title),1),e("span",Wn,[I(ot,{timestamp:A.created_at*1e6},null,8,["timestamp"])])]),A.tags.length>0?(o(),l("div",Jn,[(o(!0),l(ce,null,fe(A.tags,q=>(o(),l("span",{key:q,class:"inline-block px-1.5 py-0.5 rounded text-[10px] bg-neutral-200 dark:bg-neutral-800 text-neutral-700 dark:text-neutral-300"},V(q),1))),128))])):M("",!0)],10,Fn))),128))]))])]))}}),Qe=150;function Kn(t,i={}){const{enableWebSocket:s=!0,autoConnect:c=!0}=i,a=v([]),u=v(null),r=v(!1),p=v(!1),f=v(null),b=v(!1),n=v(null),d=v(!1),h=v(!1),$=v(0),g=v(0);let m=null,C=null;function w(T){if(!u.value?.agent)return null;const j=u.value.agent,S=T==="assistant"?"A":"B";return S==="A"&&j.side_a_label?j.side_a_label:S==="B"&&j.side_b_label?j.side_b_label:null}function E(T,j){return T==="system"||j==="system"?!1:T!==j}const A=z(()=>{const T=[],j=a.value.filter(y=>(y.depth??0)===0),S=new Map;for(let y=0;y<j.length;y++){const k=j[y],R=k.role;if(R==="tool"){const Z=k.tool_call_id;if(Z&&S.has(Z)){const ee=S.get(Z),ae=T[ee],pe=ae.items.find(ve=>ve.type==="tool_call"&&ve.tool_call_id===Z);if(pe){pe.response=k.content||"",pe.response_log_id=k.log_id;const ve=(k.content||"").toLowerCase(),we=ve.length,Se=ve.includes("failed")||ve.includes("error"),re=we<500;Se&&re?pe.response_status="failed":pe.response_status="success"}ae.updated_at=k.created_at,S.delete(Z)}continue}const K=w(R==="tool"?"assistant":R),H=T[T.length-1],W=H?.role;H&&E(R,W)&&H.type==="work"&&!H.isComplete&&(H.isComplete=!0);let G=null;if(k.tool_calls)if(typeof k.tool_calls=="string")try{G=JSON.parse(k.tool_calls)}catch(Z){console.error("Failed to parse tool_calls:",Z)}else Array.isArray(k.tool_calls)&&(G=k.tool_calls);const ue=G&&G.length>0,he=H?.type==="work"&&H.role===R&&!H.isComplete;if(ue){let Z,ee;he?(Z=H,ee=T.length-1):(Z={type:"work",id:k.id,role:R,items:[],created_at:k.created_at,updated_at:k.created_at,isComplete:!1,sideLabel:K,isExpanded:!1,request_sent_at:k.request_sent_at,response_completed_at:k.response_completed_at,status:k.status||"completed"},T.push(Z),ee=T.length-1),k.reasoning_content&&Z.items.push({id:`${k.id}-reasoning`,type:"reasoning",content:k.reasoning_content,created_at:k.created_at,log_id:k.log_id}),k.content&&Z.items.push({id:`${k.id}-content`,type:"content",content:k.content,created_at:k.created_at,log_id:k.log_id}),G.forEach(ae=>{Z.items.push({id:ae.id,type:"tool_call",content:ae.function.name,created_at:k.created_at,tool_name:ae.function.name,tool_call_id:ae.id,tool_arguments:ae.function.arguments,log_id:k.log_id,response:null,response_status:"pending",response_log_id:null}),S.set(ae.id,ee)}),Z.updated_at=k.created_at,k.response_completed_at&&(Z.response_completed_at=k.response_completed_at),k.status&&k.status!=="completed"?Z.status=k.status:k.status==="completed"&&Z.status==="pending"&&(Z.status="completed")}else he&&k.status!=="pending"&&(H.isComplete=!0),(k.content||R==="system"||k.status==="pending")&&T.push({type:"text",id:k.id,role:R,content:k.content||"",created_at:k.created_at,log_id:k.log_id,sideLabel:K,isOptimistic:k.isOptimistic,status:k.status})}const x=T[T.length-1];return x?.type==="work"&&!x.isComplete&&(x.isComplete=!0),T});async function q(){if(!t.value){a.value=[],u.value=null,h.value=!1,$.value=0,g.value=0;return}r.value=!0,f.value=null;try{const T=await fetch(te(`/api/threads/${t.value}/messages?limit=${Qe}&includeSilent=true`));if(!T.ok)throw new Error(`Failed to fetch messages: ${T.statusText}`);const j=await T.json();a.value=j.messages||[],h.value=j.hasMore||!1,$.value=j.total||0,g.value=Qe,console.log(`Loaded ${a.value.length} messages, total: ${$.value}, hasMore: ${h.value}`);const S=await fetch(te(`/api/threads/${t.value}`));if(S.ok){const x=await S.json();u.value=x}}catch(T){f.value=T instanceof Error?T.message:"Unknown error",console.error("Error fetching messages:",T)}finally{r.value=!1}}async function J(){if(!(!t.value||p.value||!h.value)){p.value=!0;try{const T=await fetch(te(`/api/threads/${t.value}/messages?limit=${Qe}&offset=${g.value}`));if(!T.ok)throw new Error(`Failed to fetch more messages: ${T.statusText}`);const j=await T.json(),S=j.messages||[];a.value=[...S,...a.value],h.value=j.hasMore||!1,g.value+=Qe,console.log(`Loaded ${S.length} more messages, offset now: ${g.value}, hasMore: ${h.value}`)}catch(T){f.value=T instanceof Error?T.message:"Unknown error",console.error("Error loading more messages:",T)}finally{p.value=!1}}}function X(){if(!(!s||!t.value||m))try{let j=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${te(`/api/threads/${t.value}/stream?includeSilent=true`)}`;const S=localStorage.getItem("auth_token");S&&(j+=`&token=${encodeURIComponent(S)}`),m=new WebSocket(j),m.onopen=()=>{b.value=!0,n.value=null,console.log("WebSocket connected")},m.onmessage=x=>{try{if(x.data==="pong")return;const y=JSON.parse(x.data);if(y.type==="message_data"&&y.message_id){const k=y.message_id,R=y.data,K=a.value.findIndex(H=>H.id===k);if(K>=0)a.value[K]={...a.value[K],...R,id:k};else{const H={id:k,...R},W=a.value.filter(G=>{if(!G.isOptimistic)return!0;if(G.id===k)return!1;const ue=G.content===H.content,he=G.role===H.role,Z=Math.abs(G.created_at-H.created_at)<5e6;return!(ue&&he&&Z)});W.push(H),a.value=W.sort((G,ue)=>G.created_at-ue.created_at)}if(R.status==="pending")d.value=!0;else if(R.status==="completed"||R.status==="failed"){const H=a.value.some(W=>{if((W.depth??0)>0)return!1;if(W.status==="pending"||W.role==="tool"&&W.tool_call_id&&!W.tool_status)return!0;if(W.tool_calls)try{const ue=JSON.parse(W.tool_calls);if(Array.isArray(ue)&&ue.length>0&&!ue.every(Z=>a.value.some(ee=>(ee.depth??0)===0&&ee.role==="tool"&&ee.tool_call_id===Z.id&&ee.tool_status)))return!0}catch{}return!1});d.value=H}}else if(y.type==="message_chunk"){const k=y.message_id,R=y.chunk,K=a.value.findIndex(H=>H.id===k);if(K>=0){const H=a.value[K].content||"",W={...a.value[K],content:H+R};a.value.splice(K,1,W)}else{const H={id:k,role:"assistant",content:R,created_at:Date.now()*1e3,status:"pending"};a.value.push(H),a.value=a.value.sort((W,G)=>W.created_at-G.created_at)}}else y.type==="event"?console.log("📡",y.eventType,y.data):y.type==="error"&&(n.value=y.error||"WebSocket error",console.error("WebSocket error:",y.error))}catch(y){console.error("Error parsing WebSocket message:",y)}},m.onerror=x=>{n.value="WebSocket connection error",console.error("WebSocket error:",x)},m.onclose=()=>{b.value=!1,m=null,t.value&&s&&(C=setTimeout(()=>{console.log("Attempting WebSocket reconnect..."),X()},3e3))}}catch(T){n.value=T instanceof Error?T.message:"Unknown error",console.error("Error connecting WebSocket:",T)}}function P(){C&&(clearTimeout(C),C=null),m&&(m.close(),m=null,b.value=!1)}async function _(){await q()}function O(T){a.value.push({...T,isOptimistic:!0})}function D(T){a.value=a.value.filter(j=>j.id!==T)}async function N(T){if(!t.value)return;const j=[...a.value];a.value=a.value.filter(S=>S.id!==T);try{if(!(await fetch(te(`/api/threads/${t.value}/messages/${T}`),{method:"DELETE"})).ok)throw a.value=j,new Error("Failed to delete message")}catch(S){throw a.value=j,S}}async function U(T,j){if(!t.value)return;const S=[...a.value];a.value=a.value.map(x=>x.id===T?{...x,content:j}:x);try{if(!(await fetch(te(`/api/threads/${t.value}/messages/${T}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:j})})).ok)throw a.value=S,new Error("Failed to update message")}catch(x){throw a.value=S,x}}async function L(){if(t.value){d.value=!1;try{if(!(await fetch(te(`/api/threads/${t.value}/stop`),{method:"POST"})).ok)throw new Error("Failed to stop thread")}catch(T){throw console.error("Error stopping thread:",T),T}}}return ie(t,async(T,j)=>{T!==j&&(P(),T?(await q(),c&&s&&X()):(a.value=[],u.value=null))},{immediate:c}),je(()=>{P()}),{messages:A,threadInfo:u,isFetching:r,isLoadingMore:p,error:f,wsConnected:b,wsError:n,isExecuting:d,hasMore:h,totalMessages:$,refetch:_,loadMoreMessages:J,connectWebSocket:X,disconnectWebSocket:P,addOptimisticMessage:O,removeOptimisticMessage:D,deleteMessageById:N,updateMessageContent:U,stopThread:L}}const Gn=["onMouseenter","onMouseleave","onClick"],Xn=["onClick"],Yn={key:0,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"3",stroke:"currentColor",class:"w-3 h-3 text-white"},Qn={key:1,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2.5",stroke:"currentColor",class:"w-3 h-3 text-white"},er={key:0,class:"w-full text-center text-xs text-neutral-400 dark:text-neutral-500 py-1"},tr=["contenteditable","onInput"],or={key:1,class:"flex gap-1 items-center min-h-[1.5rem]"},ar={key:0,class:"opacity-50"},lr={key:1,class:"opacity-50 italic text-neutral-500 dark:text-neutral-400"},sr=["onClick"],nr={key:0,class:"space-y-1"},rr={class:"flex items-start gap-2"},ir={class:"flex-1 min-w-0"},dr={key:0,class:"truncate opacity-80"},ur={key:1,class:"italic opacity-60"},cr={class:"flex items-center gap-2 pl-5 opacity-60"},pr={class:"text-[10px]"},mr={class:"text-[10px]"},vr={key:1,class:"space-y-2"},fr={class:"flex items-center gap-2 pb-1 border-b border-current opacity-70"},hr={class:"text-[10px] italic"},gr={class:"text-[10px] ml-auto"},br={key:0,class:"space-y-1"},xr=["onClick"],yr={class:"font-mono text-[11px] flex-shrink-0"},kr={key:2,class:"text-[10px] opacity-60 px-2 truncate flex-1 min-w-0"},wr={key:3,class:"text-[10px] text-green-600 dark:text-green-400 ml-auto flex-shrink-0"},_r={key:0,class:"pl-4 space-y-2 text-[10px]"},$r={key:0},Cr={class:"w-full border-collapse"},Vr={class:"py-0.5 pr-2 opacity-65 align-top"},Sr={class:"py-0.5 opacity-85 break-all"},Tr={key:1},Mr=["onClick"],Ir={class:"whitespace-pre-wrap break-all"},Lr={key:1,class:"text-[10px]"},Er=["onClick"],Ar={key:0,class:"mt-1 pl-4 whitespace-pre-wrap opacity-80"},Pr={key:2,class:"text-[10px] opacity-80 pl-4 pb-2"},Or=se({__name:"AgentMessages",props:{messages:{},selectedMessageId:{},selectedLogId:{},hoveredLogId:{},isEditMode:{type:Boolean},selectedForDelete:{},editedMessages:{}},emits:["messageClick","messageHover","selectionChange","messageEdit"],setup(t,{expose:i,emit:s}){const c=t,a=s;function u(x){const y=c.selectedForDelete?.has(x)??!1;a("selectionChange",x,!y)}function r(x,y){const R=x.target.innerText;a("messageEdit",y,R)}function p(x){return c.editedMessages?.has(x)??!1}const f=v(new Map);function b(x,y){y?f.value.set(x,y):f.value.delete(x)}function n(x){const y=c.messages.findIndex(k=>k.log_id===x);if(y<=0)return-1;for(let k=y-1;k>=0;k--){const R=c.messages[k];if(R.role==="user")return k;if(R.role==="assistant"&&R.log_id)break}return-1}function d(x,y){const R=c.messages.findIndex(he=>he.log_id===x);if(R===-1)return;const K=f.value.get(R);if(!K)return;const H=n(x),W=H!==-1?f.value.get(H):null,G=y.getBoundingClientRect(),ue=K.getBoundingClientRect();if(ue.top<G.top){const ee=(W||K).getBoundingClientRect().top-G.top-10;y.scrollBy({top:ee,behavior:"smooth"})}else if(ue.bottom>G.bottom){const he=ue.bottom-G.bottom+10;y.scrollBy({top:he,behavior:"smooth"})}else if(W){const he=W.getBoundingClientRect();if(he.top<G.top){const Z=he.top-G.top-10;y.scrollBy({top:Z,behavior:"smooth"})}}}i({scrollToLogId:d});function h(x){const y=c.messages[x];if(y.log_id)return y.log_id;if(y.role==="user")for(let k=x+1;k<c.messages.length;k++){const R=c.messages[k];if(R.log_id)return R.log_id;if(R.role==="user")break}return null}function $(x,y){return y?h(x)===y:!1}function g(x){const y=h(x);y&&a("messageHover",y)}function m(x){h(x)&&a("messageHover",null)}function C(x){const y=c.messages[x],k=h(x);k&&a("messageClick",y.id,k)}const w=v(new Set),E=v(new Set),A=v(new Set);function q(x){w.value.has(x)?w.value.delete(x):w.value.add(x)}function J(x){E.value.has(x)?E.value.delete(x):E.value.add(x)}function X(x){A.value.has(x)?A.value.delete(x):A.value.add(x)}function P(x){if(!x)return{};try{return JSON.parse(x)}catch{return{raw:x}}}function _(x){if(!x)return null;const y=P(x),k=Object.keys(y);if(k.length===0)return null;const R=y[k[0]];return typeof R=="string"?R:JSON.stringify(R)}function O(x){return new Date(x/1e3).toLocaleTimeString()}function D(x){const y=Math.round(x/1e6);if(y<1)return"< 1s";if(y<60)return`${y}s`;const k=Math.floor(y/60),R=y%60;return`${k}m ${R}s`}function N(x){if(x.status==="pending")return"...";if(!x.isComplete)return"Working...";let y;return x.request_sent_at&&x.response_completed_at?y=x.response_completed_at-x.request_sent_at:y=x.updated_at-x.created_at,`Worked for ${D(y)}`}function U(x){const y=x.filter(k=>k.type==="content");if(y.length===0){const k=x.filter(R=>R.type==="reasoning");return k.length>0?k[k.length-1].content:null}return y[y.length-1].content}function L(x){const k=x.trim().split(`
2
- `)[0];return k.length>60?k.substring(0,60):k}function T(x){return c.selectedMessageId===x.id?!0:c.selectedLogId?x.items.some(y=>y.log_id===c.selectedLogId):!1}function j(x){return!!(c.selectedLogId&&x.log_id===c.selectedLogId)}function S(x){return x?x.trim():""}return(x,y)=>(o(),l("div",null,[(o(!0),l(ce,null,fe(t.messages,(k,R)=>(o(),l("div",{key:k.id,ref_for:!0,ref:K=>b(R,K),class:"flex items-center gap-2 pb-3",onMouseenter:K=>g(R),onMouseleave:K=>m(R),onClick:K=>t.isEditMode?u(k.id):C(R)},[t.isEditMode&&k.role!=="system"?(o(),l("button",{key:0,onClick:Te(K=>u(k.id),["stop"]),class:oe(["flex-shrink-0 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",{"border-red-500 bg-red-500":t.selectedForDelete?.has(k.id),"border-green-500 bg-green-500":!t.selectedForDelete?.has(k.id)&&p(k.id),"border-neutral-400 dark:border-neutral-500 bg-transparent hover:border-neutral-500 dark:hover:border-neutral-400":!t.selectedForDelete?.has(k.id)&&!p(k.id)}])},[t.selectedForDelete?.has(k.id)?(o(),l("svg",Yn,[...y[1]||(y[1]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 12.75l6 6 9-13.5"},null,-1)])])):p(k.id)?(o(),l("svg",Qn,[...y[2]||(y[2]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125"},null,-1)])])):M("",!0)],10,Xn)):M("",!0),e("div",{class:oe(["flex-1 flex items-center gap-2",{"justify-start":k.role==="assistant","justify-end":k.role==="user","justify-center":k.role==="system","cursor-pointer":h(R)&&!t.isEditMode}])},[k.type==="text"&&k.role==="system"&&k.content?.includes("Execution stopped")?(o(),l("div",er,V(k.content),1)):k.type==="text"?(o(),l("div",{key:1,class:oe(["max-w-[80%] rounded-2xl px-4 py-2 text-sm transition-all min-h-[2.5rem]",[k.silent?"bg-neutral-300 text-neutral-500 dark:bg-neutral-700 dark:text-neutral-400 opacity-70 border-2 border-dashed border-neutral-400 dark:border-neutral-500":!t.isEditMode&&k.role!=="user"&&$(R,t.selectedLogId)?"bg-accent-200 text-accent-950 dark:bg-accent-200 dark:text-accent-950 ring-2 ring-accent-400 dark:ring-accent-400":k.role==="assistant"?"bg-neutral-800 text-white dark:bg-neutral-300 dark:text-black":k.role==="user"?"bg-neutral-200 text-black dark:bg-neutral-800 dark:text-white":"bg-neutral-100 text-neutral-600 dark:bg-neutral-900 dark:text-neutral-400 text-xs",{"opacity-60":k.isOptimistic},{"ring-2 ring-accent-400 dark:ring-accent-400 !bg-accent-200 !text-accent-950 dark:!bg-accent-200 dark:!text-accent-950":!t.isEditMode&&k.role!=="user"&&h(R)&&!k.silent&&!$(R,t.selectedLogId)&&$(R,t.hoveredLogId)},{"ring-2 ring-green-500 dark:ring-green-400":t.isEditMode&&p(k.id),"border border-dashed border-neutral-400 dark:border-neutral-500":t.isEditMode&&k.role!=="system"&&!p(k.id)}]])},[k.content||t.isEditMode?(o(),l("div",{key:0,class:"whitespace-pre-wrap text-sm outline-none",contenteditable:t.isEditMode&&k.role!=="system",onInput:K=>r(K,k.id),onClick:y[0]||(y[0]=Te(()=>{},["stop"]))},V(S(k.content)),41,tr)):k.status==="pending"?(o(),l("div",or,[...y[3]||(y[3]=[e("span",{class:"typing-dot",style:{"animation-delay":"0ms"}},null,-1),e("span",{class:"typing-dot",style:{"animation-delay":"150ms"}},null,-1),e("span",{class:"typing-dot",style:{"animation-delay":"300ms"}},null,-1)])])):M("",!0),k.status!=="pending"?(o(),l("div",{key:2,class:oe(["text-[10px] mt-1 opacity-50 flex gap-2",{"justify-start":k.role==="assistant","justify-end":k.role!=="assistant"}])},[k.sideLabel?(o(),l("span",ar,V(k.sideLabel),1)):M("",!0),e("span",null,V(O(k.created_at)),1),k.silent?(o(),l("span",lr," silent ")):M("",!0)],2)):M("",!0)],2)):k.type==="work"?(o(),l("div",{key:2,class:oe(["max-w-[80%] min-w-[200px] rounded-lg px-3 py-2 text-xs transition-all border",{"cursor-pointer":!t.isEditMode,"bg-neutral-50 text-neutral-700 border-neutral-200 dark:bg-neutral-900 dark:text-neutral-300 dark:border-neutral-700":k.role==="assistant"&&!k.silent,"bg-accent-50 text-accent-700 border-accent-200 dark:bg-accent-50 dark:text-accent-700 dark:border-accent-200":k.role==="user"&&!k.silent,"bg-neutral-200 text-neutral-500 border-neutral-400 dark:bg-neutral-800 dark:text-neutral-400 dark:border-neutral-600 opacity-70 border-dashed":k.silent,"ring-2 ring-accent-500":!t.isEditMode&&T(k)}]),onClick:K=>!t.isEditMode&&q(k.id)},[w.value.has(k.id)?(o(),l("div",vr,[e("div",fr,[I(F(rt),{size:14,class:"flex-shrink-0"}),e("span",hr,V(N(k)),1),e("span",gr,V(k.items.length)+" operation"+V(k.items.length!==1?"s":""),1)]),(o(!0),l(ce,null,fe(k.items,K=>(o(),l("div",{key:K.id,class:"mb-1"},[K.type==="tool_call"?(o(),l("div",br,[e("div",{onClick:Te(H=>J(K.id),["stop"]),class:oe(["flex items-center gap-2 cursor-pointer hover:opacity-70 transition-opacity",{"ring-1 ring-accent-500":j(K)}])},[E.value.has(K.id)?(o(),Q(F(rt),{key:1,size:12,class:"flex-shrink-0 opacity-50"})):(o(),Q(F(nt),{key:0,size:12,class:"flex-shrink-0 opacity-50"})),e("span",yr,V(K.tool_name),1),_(K.tool_arguments)?(o(),l("span",kr,V(_(K.tool_arguments)),1)):M("",!0),K.response_status==="success"?(o(),l("span",wr,"✓")):K.response_status==="failed"?(o(),Q(F(go),{key:4,size:12,class:"ml-auto text-red-600 dark:text-red-400"})):M("",!0)],10,xr),E.value.has(K.id)?(o(),l("div",_r,[K.tool_arguments?(o(),l("div",$r,[y[4]||(y[4]=e("div",{class:"font-semibold mb-1 opacity-70"},"Arguments:",-1)),e("table",Cr,[e("tbody",null,[(o(!0),l(ce,null,fe(P(K.tool_arguments),(H,W)=>(o(),l("tr",{key:W,class:"border-b border-current border-opacity-10"},[e("td",Vr,V(W),1),e("td",Sr,V(typeof H=="object"?JSON.stringify(H):H),1)]))),128))])])])):M("",!0),K.response?(o(),l("div",Tr,[y[5]||(y[5]=e("div",{class:"font-semibold mb-1 opacity-70"},"Response:",-1)),e("div",{class:oe(["opacity-80 cursor-pointer hover:opacity-100",{"ring-1 ring-accent-500":t.selectedLogId&&K.response_log_id===t.selectedLogId}]),onClick:Te(H=>K.response_log_id&&a("messageClick",k.id,K.response_log_id),["stop"])},[e("div",Ir,V(S(K.response)),1)],10,Mr)])):M("",!0)])):M("",!0)])):K.type==="reasoning"?(o(),l("div",Lr,[e("button",{onClick:Te(H=>X(K.id),["stop"]),class:"flex items-center gap-1 opacity-70 hover:opacity-100 transition-opacity"},[A.value.has(K.id)?(o(),Q(F(rt),{key:1,size:12,class:"flex-shrink-0"})):(o(),Q(F(nt),{key:0,size:12,class:"flex-shrink-0"})),y[6]||(y[6]=e("span",{class:"font-semibold"},"Reasoning",-1))],8,Er),A.value.has(K.id)?(o(),l("div",Ar,V(S(K.content)),1)):M("",!0)])):K.type==="content"?(o(),l("div",Pr,V(S(K.content)),1)):M("",!0)]))),128))])):(o(),l("div",nr,[e("div",rr,[I(F(nt),{size:14,class:"flex-shrink-0 mt-0.5 opacity-50"}),e("div",ir,[U(k.items)?(o(),l("div",dr,V(L(U(k.items)))+"... ",1)):(o(),l("div",ur,V(N(k)),1))])]),e("div",cr,[e("span",pr,V(k.items.length)+" operation"+V(k.items.length!==1?"s":""),1),e("span",mr,"• "+V(N(k)),1)])]))],10,sr)):M("",!0)],2)],40,Gn))),128))]))}}),jr=Fe(Or,[["__scopeId","data-v-c57c5570"]]),Dr={key:0,class:"overflow-hidden border-b border-neutral-300 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-900"},Ur={class:"max-h-[400px] overflow-y-auto"},Nr={class:"flex items-center justify-between px-4 py-2 border-b border-neutral-200 dark:border-neutral-800 sticky top-0 bg-neutral-50 dark:bg-neutral-900"},Rr={class:"p-4"},Br={key:0,class:"flex justify-center py-4"},qr={key:1,class:"text-red-600 dark:text-red-400 text-center py-4 text-sm"},Fr={key:2,class:"space-y-3 text-sm"},zr={class:"flex items-start gap-2"},Hr={class:"font-mono text-xs break-all"},Wr={class:"flex items-start gap-2"},Jr={class:"flex-1"},Zr={key:0,class:"flex items-center gap-2"},Kr={class:"text-xs text-neutral-500"},Gr={key:1,class:"space-y-2"},Xr={class:"flex gap-2"},Yr=["disabled"],Qr=["disabled"],ei={class:"flex items-start gap-2"},ti={key:0,class:"flex items-start gap-2"},oi={class:"font-mono text-xs"},ai={class:"flex items-start gap-2"},li={class:"flex-1 flex items-center gap-2 flex-wrap"},si={key:1,class:"text-neutral-500 dark:text-neutral-500 italic text-xs"},ni={class:"flex items-start gap-2"},ri=["disabled"],ii={key:1,class:"flex justify-center py-2"},di={key:1,class:"p-3 rounded border border-neutral-200 dark:border-neutral-700 bg-neutral-100 dark:bg-neutral-800 space-y-2"},ui={class:"flex items-center gap-4 text-xs"},ci={class:"font-mono font-bold ml-1"},pi={class:"font-mono font-bold ml-1"},mi={key:0,class:"text-xs"},vi={class:"w-full"},fi={class:"py-1"},hi={class:"text-right py-1 font-mono"},gi={class:"text-right py-1 font-mono"},bi={class:"pt-2 border-t border-neutral-200 dark:border-neutral-800 flex justify-end"},xi=["disabled"],yi={key:0},ki={key:1},wi=se({__name:"MetadataSlidePane",props:{threadId:{},show:{type:Boolean}},emits:["close","threadDeleted","editThread"],setup(t,{emit:i}){const s=t,c=i,{thread:a,isFetching:u,error:r}=bt(z(()=>s.threadId)),p=v(!1),f=v(!1),b=v(!1),n=v(!1),d=v(""),h=v(!1),$=v(!1),g=v(null),{data:m,isFetching:C}=Me(te("/api/agents"),{refetch:!0}).json(),w=z(()=>m.value?.agents?m.value.agents.filter(D=>D.type==="ai_human").map(D=>({value:D.id,label:D.title,description:`Type: ${D.type}`})):[]),E=z(()=>a.value?.agent.type==="ai_human"),A=D=>new Date(D*1e3).toLocaleString(),q=()=>{a.value&&(d.value=a.value.agent.id,b.value=!0)},J=()=>{b.value=!1,d.value=""},X=async()=>{if(!(!s.threadId||!d.value)){n.value=!0;try{const D=await fetch(te(`/api/threads/${s.threadId}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent_id:d.value})});if(!D.ok){const N=await D.json();throw new Error(N.error||"Failed to update agent")}window.location.reload()}catch(D){console.error("Error updating agent:",D),alert(`Failed to update agent: ${D.message}`)}finally{n.value=!1}}},P=async()=>{if(s.threadId){$.value=!0,h.value=!0;try{const D=await fetch(te(`/api/threads/${s.threadId}/cost`));if(!D.ok){const N=await D.json();throw new Error(N.error||"Failed to fetch cost breakdown")}g.value=await D.json()}catch(D){console.error("Error fetching cost breakdown:",D),alert(`Failed to fetch cost breakdown: ${D.message}`),h.value=!1}finally{$.value=!1}}},_=D=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:6}).format(D),O=async()=>{if(s.threadId){f.value=!0;try{const D=await fetch(te(`/api/threads/${s.threadId}`),{method:"DELETE"});if(!D.ok){const N=await D.json();throw new Error(N.error||"Failed to delete thread")}c("threadDeleted",s.threadId)}catch(D){console.error("Error deleting thread:",D),alert(`Failed to delete thread: ${D.message}`)}finally{f.value=!1}}};return ie(()=>s.show,D=>{D||(b.value=!1,d.value="")}),(D,N)=>(o(),Q(Be,{"enter-active-class":"transition-all duration-300 ease-out","enter-from-class":"max-h-0 opacity-0","enter-to-class":"max-h-[400px] opacity-100","leave-active-class":"transition-all duration-200 ease-in","leave-from-class":"max-h-[400px] opacity-100","leave-to-class":"max-h-0 opacity-0"},{default:de(()=>[t.show&&t.threadId?(o(),l("div",Dr,[e("div",Ur,[e("div",Nr,[N[6]||(N[6]=e("span",{class:"text-sm font-medium text-neutral-600 dark:text-neutral-400"},"Thread Info",-1)),e("button",{onClick:N[0]||(N[0]=U=>c("close")),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors",title:"Close metadata"},[I(F(bo),{size:16})])]),e("div",Rr,[F(u)?(o(),l("div",Br,[I(be)])):F(r)?(o(),l("div",qr," Error loading metadata: "+V(F(r)),1)):F(a)?(o(),l("div",Fr,[e("div",zr,[N[7]||(N[7]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"ID",-1)),e("span",Hr,V(F(a).id),1)]),e("div",Wr,[N[8]||(N[8]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"Agent",-1)),e("div",Jr,[b.value?(o(),l("div",Gr,[I(ge,{modelValue:d.value,"onUpdate:modelValue":N[1]||(N[1]=U=>d.value=U),options:w.value,loading:F(C),placeholder:"Select an agent"},null,8,["modelValue","options","loading"]),e("div",Xr,[e("button",{onClick:X,disabled:n.value||!d.value,class:"px-2 py-1 text-xs bg-black dark:bg-white text-white dark:text-black hover:bg-black/80 dark:hover:bg-white/80 transition-colors disabled:opacity-50 disabled:cursor-not-allowed rounded"},V(n.value?"Saving...":"Save"),9,Yr),e("button",{onClick:J,disabled:n.value,class:"px-2 py-1 text-xs border border-black dark:border-neutral-300 hover:bg-black/5 dark:hover:bg-white/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed rounded"}," Cancel ",8,Qr)])])):(o(),l("div",Zr,[e("span",null,V(F(a).agent.title),1),e("span",Kr,"("+V(F(a).agent.type)+")",1),E.value?(o(),l("button",{key:0,onClick:q,type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors",title:"Change agent"},[I(F(ct),{size:12})])):M("",!0)]))])]),e("div",ei,[N[9]||(N[9]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"Created",-1)),e("span",null,V(A(F(a).created_at)),1)]),F(a).user_id?(o(),l("div",ti,[N[10]||(N[10]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"User",-1)),e("span",oi,V(F(a).user_id),1)])):M("",!0),e("div",ai,[N[11]||(N[11]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"Tags",-1)),e("div",li,[F(a).tags?.length>0?(o(!0),l(ce,{key:0},fe(F(a).tags,U=>(o(),l("span",{key:U,class:"inline-block px-2 py-0.5 text-xs rounded bg-black text-white dark:bg-white dark:text-black"},V(U),1))),128)):(o(),l("span",si,"No tags")),e("button",{onClick:N[2]||(N[2]=U=>c("editThread")),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors",title:"Edit tags"},[I(F(ct),{size:12})])])]),e("div",ni,[N[14]||(N[14]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 shrink-0 text-left"},"Cost",-1)),!h.value&&!$.value?(o(),l("button",{key:0,onClick:P,disabled:$.value,type:"button",class:"flex items-center gap-1 px-2 py-1 text-xs border border-black dark:border-white rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"},[I(F(Ct),{size:12}),N[12]||(N[12]=e("span",null,"View Costs",-1))],8,ri)):M("",!0),$.value?(o(),l("div",ii,[I(be)])):M("",!0),h.value?(o(),l("button",{key:2,onClick:N[3]||(N[3]=U=>h.value=!1),type:"button",class:"flex items-center gap-1 px-2 py-1 text-xs border border-black dark:border-white rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors"},[I(F(Ct),{size:12}),N[13]||(N[13]=e("span",null,"Hide Costs",-1))])):M("",!0)]),h.value&&g.value?(o(),l("div",di,[e("div",ui,[e("div",null,[N[15]||(N[15]=e("span",{class:"text-neutral-500"},"Total:",-1)),e("span",ci,V(_(g.value.totalCost)),1)]),e("div",null,[N[16]||(N[16]=e("span",{class:"text-neutral-500"},"Avg/msg:",-1)),e("span",pi,V(_(g.value.avgCostPerMessage)),1)])]),g.value.modelBreakdown.length>0?(o(),l("div",mi,[e("table",vi,[N[17]||(N[17]=e("thead",null,[e("tr",{class:"border-b border-neutral-300 dark:border-neutral-600"},[e("th",{class:"text-left py-1 font-medium text-neutral-500"}," Model "),e("th",{class:"text-right py-1 font-medium text-neutral-500"}," Reqs "),e("th",{class:"text-right py-1 font-medium text-neutral-500"}," Cost ")])],-1)),e("tbody",null,[(o(!0),l(ce,null,fe(g.value.modelBreakdown,U=>(o(),l("tr",{key:U.modelName},[e("td",fi,V(U.modelName),1),e("td",hi,V(U.requestCount),1),e("td",gi,V(_(U.totalCost)),1)]))),128))])])])):M("",!0)])):M("",!0),e("div",bi,[e("button",{onClick:N[4]||(N[4]=U=>p.value=!0),disabled:f.value,class:"flex items-center gap-1 px-2 py-1 text-xs text-red-600 border border-red-600 rounded hover:bg-red-50 dark:hover:bg-red-950/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"},[I(F(xo),{size:12}),f.value?(o(),l("span",yi,"Deleting...")):(o(),l("span",ki,"Delete Thread"))],8,xi)])])):M("",!0)])]),I(Gt,{modelValue:p.value,"onUpdate:modelValue":N[5]||(N[5]=U=>p.value=U),title:"Delete Thread?",message:"Are you sure you want to delete this thread? This will permanently delete all messages, logs, and associated data. This action cannot be undone.","confirm-text":"Delete Thread","cancel-text":"Cancel",onConfirm:O},null,8,["modelValue"])])):M("",!0)]),_:1}))}}),_i={class:"flex flex-col h-full"},$i={class:"p-4 border-b border-neutral-300 dark:border-neutral-700"},Ci={class:"flex items-center justify-between"},Vi={class:"flex items-center gap-2"},Si={class:"flex items-center gap-2"},Ti={class:"flex-1 flex flex-col overflow-hidden relative"},Mi={key:0,class:"text-neutral-500 dark:text-neutral-400 text-center py-8"},Ii={key:1,class:"flex justify-center py-2"},Li={key:2,class:"flex justify-center py-8"},Ei={key:3,class:"text-red-600 dark:text-red-400 text-center py-8"},Ai={key:4,class:"text-neutral-500 dark:text-neutral-400 text-center py-8"},Pi={key:0,class:"p-3 bg-white dark:bg-neutral-900 border-t border-neutral-300 dark:border-neutral-700"},Oi={class:"flex items-center justify-end gap-2"},ji=["disabled"],Di={key:1,class:"p-3 bg-white dark:bg-neutral-900 border-t border-neutral-300 dark:border-neutral-700"},Ui={class:"flex items-start gap-2"},Ni={class:"flex-1 flex items-start gap-2 p-2 rounded-2xl border border-neutral-300 dark:border-neutral-700 bg-white dark:bg-neutral-900"},Ri=["disabled"],Bi=["disabled"],qi={key:0,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",class:"w-4 h-4"},Fi={key:1,class:"w-4 h-4"},zi=se({__name:"MessagesPane",props:{threadId:{},selectedMessageId:{},selectedLogId:{},hoveredLogId:{}},emits:["collapse","messageClick","messageHover","threadDeleted","editThread","logsDeleted"],setup(t,{expose:i,emit:s}){const c=t,a=s,u=v(!1),r=()=>{u.value=!u.value},p=v(!1),f=v(new Set),b=v(new Map),n=()=>{p.value=!p.value,p.value||(f.value=new Set,b.value=new Map)},d=(re,ne)=>{const me=new Set(f.value);ne?me.add(re):me.delete(re),f.value=me},h=(re,ne)=>{const me=new Map(b.value);me.set(re,ne),b.value=me},$=()=>{p.value=!1,f.value=new Set,b.value=new Map},g=z(()=>f.value.size),m=z(()=>{let re=0;for(const[ne]of b.value)f.value.has(ne)||re++;return re}),C=z(()=>{const re=g.value,ne=m.value;return re>0&&ne>0?`Delete (${re}), Update (${ne})`:re>0?`Delete (${re})`:ne>0?`Save changes (${ne})`:"Delete"}),w=z(()=>g.value>0||m.value>0),E=async()=>{if(!c.threadId||!w.value)return;const re=[];for(const ne of f.value){const me=A.value.find(Le=>Le.id===ne);me&&"log_id"in me&&me.log_id&&re.push(me.log_id)}try{for(const[ne,me]of b.value)f.value.has(ne)||await S(ne,me);for(const ne of f.value)await j(ne);re.length>0&&a("logsDeleted",re)}catch(ne){console.error("Error applying changes:",ne)}finally{$()}},{messages:A,threadInfo:q,isFetching:J,isLoadingMore:X,error:P,wsConnected:_,wsError:O,isExecuting:D,hasMore:N,loadMoreMessages:U,addOptimisticMessage:L,removeOptimisticMessage:T,deleteMessageById:j,updateMessageContent:S,stopThread:x}=Kn(z(()=>c.threadId),{enableWebSocket:!0}),{thread:y}=bt(z(()=>c.threadId)),k=v(null),R=v(null);i({scrollToLogId:re=>{R.value&&k.value&&R.value.scrollToLogId(re,k.value)}}),typeof window<"u"&&(window.__testLoadMoreMessages=U);const H=v(""),W=v(null),G=v("B"),ue=v(!1),he=v(!1),Z=async()=>{await xe(),k.value&&(k.value.scrollTop=k.value.scrollHeight)},ee=async re=>{re.target.scrollTop<100&&N.value&&!X.value&&!he.value&&(he.value=!0,await U(),he.value=!1)};ie(()=>A.value.length,async()=>{!X.value&&!he.value&&await Z()}),ie(()=>c.threadId,async re=>{re&&await Z()}),ie(J,async(re,ne)=>{ne&&!re&&await Z()});const ae=z(()=>{const re=q.value?.agent||y.value?.agent;if(!re)return"ai A";const ne=re.type;return G.value==="A"&&re.side_a_label?re.side_a_label:G.value==="B"&&re.side_b_label?re.side_b_label:ne==="ai_human"?G.value==="A"?"ai":"human":G.value==="A"?"ai A":"ai B"}),pe=()=>{G.value=G.value==="A"?"B":"A"},ve=async()=>{if(!H.value.trim()||!c.threadId||ue.value)return;const re=H.value,ne=G.value==="A"?"assistant":"user",me=`optimistic-${Date.now()}`,Le={id:me,role:ne,content:re,created_at:Date.now()*1e3,isOptimistic:!0};L(Le),H.value="",W.value&&(W.value.style.height="auto",W.value.style.height="24px"),ue.value=!0;try{if(!(await fetch(te(`/api/threads/${c.threadId}/message`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:re,role:ne})})).ok)throw new Error("Failed to send message");await Z()}catch(Xe){console.error("Error sending message:",Xe),T(me)}finally{ue.value=!1,await xe(),W.value&&W.value.focus()}},we=re=>{re.key==="Enter"&&!re.shiftKey&&(re.preventDefault(),ve())},Se=async()=>{if(c.threadId)try{await x()}catch(re){console.error("Error stopping thread:",re)}};return(re,ne)=>(o(),l("div",_i,[e("div",$i,[e("div",Ci,[e("div",Vi,[I(F(Nt),{size:20,class:"shrink-0"}),ne[8]||(ne[8]=e("h2",{class:"text-xl font-bold"},"Messages",-1)),t.threadId?(o(),Q(xt,{key:0,connected:F(_),error:F(O)},null,8,["connected","error"])):M("",!0)]),e("div",Si,[t.threadId?(o(),l("button",{key:0,onClick:r,type:"button",class:oe(["p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",{"bg-neutral-200 dark:bg-neutral-800":u.value}]),title:"Toggle metadata"},[I(F(yo),{size:20})],2)):M("",!0),t.threadId&&F(A).length>0?(o(),l("button",{key:1,onClick:n,type:"button",class:oe(["p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",{"bg-neutral-200 dark:bg-neutral-800":p.value}]),title:"Edit messages"},[I(F(ct),{size:20})],2)):M("",!0),e("button",{onClick:ne[0]||(ne[0]=me=>a("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[I(F(gt),{size:20})])])])]),e("div",Ti,[I(wi,{"thread-id":t.threadId,show:u.value,onClose:ne[1]||(ne[1]=me=>u.value=!1),onThreadDeleted:ne[2]||(ne[2]=me=>a("threadDeleted",me)),onEditThread:ne[3]||(ne[3]=me=>a("editThread"))},null,8,["thread-id","show"]),e("div",{ref_key:"messagesContainer",ref:k,class:"flex-1 overflow-y-auto p-4 space-y-4",onScroll:ee},[t.threadId?M("",!0):(o(),l("div",Mi," Select a thread to view messages ")),F(X)?(o(),l("div",Ii,[I(be,{size:"sm"}),ne[9]||(ne[9]=e("span",{class:"ml-2 text-xs text-neutral-500"},"Loading older messages...",-1))])):F(J)?(o(),l("div",Li,[I(be)])):F(P)?(o(),l("div",Ei," Error loading messages: "+V(F(P)),1)):t.threadId&&F(A).length===0?(o(),l("div",Ai," No messages yet ")):(o(),Q(jr,{key:5,ref_key:"agentMessagesRef",ref:R,messages:F(A),selectedMessageId:t.selectedMessageId,selectedLogId:t.selectedLogId,hoveredLogId:t.hoveredLogId,isEditMode:p.value,selectedForDelete:f.value,editedMessages:b.value,onMessageClick:ne[4]||(ne[4]=(me,Le)=>a("messageClick",me,Le)),onMessageHover:ne[5]||(ne[5]=me=>a("messageHover",me)),onSelectionChange:d,onMessageEdit:h},null,8,["messages","selectedMessageId","selectedLogId","hoveredLogId","isEditMode","selectedForDelete","editedMessages"]))],544),t.threadId&&p.value?(o(),l("div",Pi,[e("div",Oi,[e("button",{onClick:$,class:"px-4 py-2 rounded-lg font-medium text-sm transition-colors bg-neutral-200 text-black hover:bg-neutral-300 dark:bg-neutral-700 dark:text-white dark:hover:bg-neutral-600"}," Cancel "),e("button",{onClick:E,disabled:!w.value,class:oe(["px-4 py-2 rounded-lg font-medium text-sm transition-colors",{"bg-red-600 text-white hover:bg-red-700":w.value&&g.value>0,"bg-black text-white hover:bg-neutral-800 dark:bg-white dark:text-black dark:hover:bg-neutral-200":w.value&&g.value===0,"bg-neutral-200 text-neutral-400 dark:bg-neutral-700 dark:text-neutral-500 cursor-not-allowed":!w.value}])},V(C.value),11,ji)])])):t.threadId?(o(),l("div",Di,[e("div",Ui,[e("button",{onClick:pe,class:oe(["flex-shrink-0 px-2 h-7 rounded-md flex items-center justify-center font-medium text-xs transition-colors mt-2.5",{"bg-black text-white dark:bg-white dark:text-black":G.value==="A","bg-neutral-300 text-black dark:bg-neutral-600 dark:text-white":G.value==="B"}]),title:"Toggle between sides"},V(ae.value),3),e("div",Ni,[_e(e("textarea",{ref_key:"messageTextarea",ref:W,"onUpdate:modelValue":ne[6]||(ne[6]=me=>H.value=me),onKeydown:we,disabled:ue.value,placeholder:"Type a message...",rows:"1",class:"flex-1 bg-transparent text-black dark:text-white resize-none focus:outline-none disabled:opacity-50 mt-0.5",style:{"max-height":"120px","min-height":"24px"},onInput:ne[7]||(ne[7]=me=>{const Le=me.target;Le.style.height="auto",Le.style.height=Math.min(Le.scrollHeight,120)+"px"})},null,40,Ri),[[Ee,H.value]]),F(D)?(o(),l("button",{key:1,id:"stop-thread-button",onClick:Se,class:"flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center transition-all bg-red-600 text-white dark:bg-red-500 hover:bg-red-700 dark:hover:bg-red-600",title:"Stop execution"},[...ne[11]||(ne[11]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",class:"w-4 h-4"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5.25 7.5A2.25 2.25 0 017.5 5.25h9a2.25 2.25 0 012.25 2.25v9a2.25 2.25 0 01-2.25 2.25h-9a2.25 2.25 0 01-2.25-2.25v-9z"})],-1)])])):(o(),l("button",{key:0,id:"send-message-button",onClick:ve,disabled:!H.value.trim()||ue.value,class:oe(["flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center transition-all",{"bg-black text-white dark:bg-white dark:text-black":H.value.trim()&&!ue.value,"bg-neutral-200 text-neutral-400 dark:bg-neutral-700 dark:text-neutral-600":!H.value.trim()||ue.value}]),title:"Send message (Enter)"},[ue.value?(o(),l("div",Fi,[I(be)])):(o(),l("svg",qi,[...ne[10]||(ne[10]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 10.5 12 3m0 0 7.5 7.5M12 3v18"},null,-1)])]))],10,Bi))])])])):M("",!0)])]))}});function Hi(t,i){const{limit:s=100,offset:c=0,order:a="desc",autoFetch:u=!0,enableWebSocket:r=!1}=i||{};z(()=>!!(typeof t=="string"?t:t?.value));const p=z(()=>{const O=typeof t=="string"?t:t?.value;if(!O)return te("/api/threads/placeholder/logs");const D=new URLSearchParams,N=typeof s=="number"?s:s.value,U=typeof c=="number"?c:c.value,L=typeof a=="string"?a:a.value;return D.append("limit",N.toString()),D.append("offset",U.toString()),D.append("order",L),te(`/api/threads/${O}/logs?${D.toString()}`)}),{data:f,error:b,isFetching:n,isFinished:d,execute:h,abort:$}=Me(p,{immediate:!1}).get().json();ie([p,()=>u],([O,D])=>{O&&!O.includes("placeholder")&&D&&h()},{immediate:!0});const g=z(()=>!b.value||b.value.toString().includes("aborted")||b.value.toString().includes("abort")?null:b.value),m=z(()=>f.value?.logs||[]),C=z(()=>f.value?.total||0),w=z(()=>f.value?.hasMore||!1),E=v(null),A=v(!1),q=v(null),J=v([]),X=()=>{const O=typeof t=="string"?t:t?.value;if(!O||!r)return;E.value&&E.value.close(),J.value=[];const D=window.location.protocol==="https:"?"wss:":"ws:",N=window.location.host;let U=`${D}//${N}${te(`/api/threads/${O}/logs`)}`;const L=localStorage.getItem("auth_token");L&&(U+=`?token=${encodeURIComponent(L)}`);try{E.value=new WebSocket(U),E.value.onopen=()=>{A.value=!0,q.value=null,console.log("WebSocket connected for logs")},E.value.onmessage=T=>{try{const j=JSON.parse(T.data);if(j.type==="log_data"){const S=J.value.findIndex(y=>y.id===j.log_id),x=m.value.find(y=>y.id===j.log_id);S>=0?(J.value[S]={...J.value[S],...j.data},console.log("[WebSocket] Updated existing realtime log:",j.log_id)):x?(J.value.push({...x,...j.data}),console.log("[WebSocket] Updated HTTP log:",j.log_id)):(J.value.push({id:j.log_id,...j.data}),console.log("[WebSocket] Added new log:",j.log_id))}}catch(j){console.error("Failed to parse WebSocket message:",j)}},E.value.onerror=T=>{q.value="WebSocket connection error",A.value=!1,console.error("WebSocket error:",T)},E.value.onclose=()=>{A.value=!1,console.log("WebSocket disconnected")}}catch(T){q.value=T.message||"Failed to create WebSocket",console.error("WebSocket creation error:",T)}},P=()=>{E.value&&(E.value.close(),E.value=null,A.value=!1),J.value=[]};return je(()=>{P()}),{logs:z(()=>{if(!r)return m.value;const O=new Map;m.value.forEach(U=>O.set(U.id,U)),J.value.forEach(U=>O.set(U.id,U));const D=typeof a=="string"?a:a.value;return Array.from(O.values()).sort((U,L)=>D==="desc"?L.created_at-U.created_at:U.created_at-L.created_at)}),total:C,hasMore:w,error:g,isFetching:n,isFinished:d,refetch:h,abort:$,wsConnected:A,wsError:q,connectWebSocket:X,disconnectWebSocket:P}}function Wi(t,i){const s=z(()=>{const p=t.value,f=i.value;return!p||!f?null:te(`/api/threads/${p}/logs/${f}`)}),{data:c,error:a,isFetching:u,execute:r}=Me(s,{immediate:!1}).get().json();return ie([t,i],([p,f])=>{p&&f&&r()},{immediate:!0}),{logDetails:c,error:a,isFetching:u,refetch:r}}const Ji=["disabled","title"],Zi={key:1,xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},Ki={key:2,xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},Gi={key:3},it=se({__name:"CopyButton",props:{content:{},variant:{},size:{},disabled:{type:Boolean}},setup(t){const i=t,s=v(!1),c=v(!1),a=async()=>{s.value=!0;try{await navigator.clipboard.writeText(i.content),c.value=!0,setTimeout(()=>{c.value=!1},2e3)}catch(p){console.error("Failed to copy:",p),alert(`Failed to copy: ${p instanceof Error?p.message:"Unknown error"}`)}finally{s.value=!1}},u={xs:"p-1 text-xs",sm:"px-2 py-1 text-xs"},r={solid:"bg-black text-white dark:bg-white dark:text-black",ghost:"bg-white dark:bg-neutral-950 border border-neutral-300 dark:border-neutral-700 text-neutral-700 dark:text-neutral-300 hover:bg-neutral-50 dark:hover:bg-neutral-900"};return(p,f)=>(o(),l("button",{onClick:a,disabled:s.value||t.disabled,class:oe([u[t.size||"sm"],r[t.variant||"solid"],"font-medium rounded hover:opacity-80 disabled:opacity-50 disabled:cursor-not-allowed transition-all"]),title:t.disabled?"No content to copy":c.value?"Copied!":"Copy to clipboard"},[s.value?(o(),Q(be,{key:0,size:"xs"})):t.variant==="ghost"&&!c.value?(o(),l("svg",Zi,[...f[0]||(f[0]=[e("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"},null,-1),e("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"},null,-1)])])):t.variant==="ghost"&&c.value?(o(),l("svg",Ki,[...f[1]||(f[1]=[e("polyline",{points:"20 6 9 17 4 12"},null,-1)])])):(o(),l("span",Gi,V(c.value?"Copied!":"Copy"),1))],10,Ji))}}),dt="__shiki_highlighter__";let et=null;async function Xi(){return typeof window<"u"&&window[dt]?window[dt]:et||(et=Io({themes:["min-light","github-dark-high-contrast"],langs:["json","markdown"]}).then(t=>(typeof window<"u"&&(window[dt]=t),t)),et)}const Yi={class:"code-block"},Qi={key:0,class:"text-xs text-neutral-500 p-2"},ed=["innerHTML"],He=se({__name:"CodeBlock",props:{code:{},language:{}},setup(t){const i=t,s=v(""),c=v(!0),a=async()=>{const u=i.code??"";if(!u){s.value='<pre class="shiki"><code></code></pre>',c.value=!1;return}try{const r=await Xi();if(i.language==="json"||i.language==="markdown")s.value=r.codeToHtml(u,{lang:i.language,themes:{light:"min-light",dark:"github-dark-high-contrast"}});else{const p=u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");s.value=`<pre class="shiki shiki-text"><code>${p}</code></pre>`}}catch{const p=u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");s.value=`<pre class="shiki"><code>${p}</code></pre>`}finally{c.value=!1}};return ye(()=>{a()}),ie(()=>i.code,()=>{a()}),(u,r)=>(o(),l("div",Yi,[c.value?(o(),l("div",Qi,"Loading...")):(o(),l("div",{key:1,innerHTML:s.value,class:"code-content"},null,8,ed))]))}}),td={class:"p-4 h-full overflow-y-auto"},od={class:"flex items-center justify-between mb-3"},ad={class:"flex items-center gap-2"},ld={class:"flex items-center gap-1"},sd=["disabled"],nd=["disabled"],rd={class:"text-lg font-bold"},id={class:"flex items-center gap-2"},dd=["disabled","title"],ud={key:1},cd={class:"@container border-b border-neutral-300 dark:border-neutral-700 pb-3"},pd={class:"hidden @[600px]:block"},md={class:"w-full text-xs"},vd={class:"py-1 font-mono"},fd={class:"py-1 font-mono"},hd={key:1},gd={class:"py-1 font-mono"},bd={key:1},xd={class:"py-1 font-mono"},yd={key:1},kd={class:"py-1 font-mono"},wd={key:1},_d={class:"py-1 font-mono text-xs"},$d={class:"@[600px]:hidden space-y-2"},Cd={class:"w-full text-xs"},Vd={class:"py-1 font-mono"},Sd={class:"py-1 font-mono"},Td={key:1},Md={class:"w-full text-xs"},Id={class:"py-1 font-mono"},Ld={key:1},Ed={class:"py-1 font-mono"},Ad={key:1},Pd={class:"py-1 font-mono"},Od={key:1},jd={class:"py-1 font-mono text-xs"},Dd={class:"sticky -top-4 z-10 bg-white dark:bg-neutral-900 border-b border-neutral-300 dark:border-neutral-700 mb-3 pt-3 -mx-4 px-4"},Ud={class:"flex gap-4"},Nd={key:0,class:"text-red-600 dark:text-red-400"},Rd={class:"space-y-3"},Bd={class:"space-y-2"},qd={key:0,class:"border border-neutral-300 dark:border-neutral-700 rounded overflow-hidden"},Fd={class:"text-neutral-500 text-xs"},zd={class:"relative bg-white dark:bg-neutral-900 border-t border-neutral-300 dark:border-neutral-700"},Hd={class:"absolute top-[5px] right-[5px]"},Wd={key:1,class:"border border-neutral-300 dark:border-neutral-700 rounded overflow-hidden"},Jd={class:"text-xs font-semibold"},Zd={class:"text-neutral-500 text-xs"},Kd={class:"relative bg-white dark:bg-neutral-900 border-t border-neutral-300 dark:border-neutral-700"},Gd={class:"absolute top-[5px] right-[5px]"},Xd={key:2,class:"border border-neutral-300 dark:border-neutral-700 rounded overflow-hidden"},Yd={class:"text-neutral-500 text-xs"},Qd={class:"relative bg-white dark:bg-neutral-900 border-t border-neutral-300 dark:border-neutral-700"},eu={class:"absolute top-[5px] right-[5px]"},tu={key:3},ou={class:"border border-neutral-300 dark:border-neutral-700 rounded overflow-hidden"},au={class:"text-xs font-semibold"},lu={class:"text-neutral-500 text-xs"},su={class:"border-t border-neutral-300 dark:border-neutral-700"},nu=["onClick"],ru={class:"font-mono"},iu={class:"text-neutral-500"},du={class:"px-2 py-2 bg-white dark:bg-neutral-950 border-t border-neutral-200 dark:border-neutral-800"},uu={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mb-2"},cu={key:0,class:"mb-4"},pu={class:"text-xs font-semibold text-red-600 dark:text-red-400 mb-1"},mu={class:"space-y-2"},vu={class:"px-2 py-1 bg-red-100 dark:bg-red-900/30 text-xs font-medium text-red-800 dark:text-red-200"},fu={class:"text-xs bg-red-50 dark:bg-red-950 p-2 overflow-x-auto text-red-900 dark:text-red-100"},hu={key:1,class:"mb-4"},gu={class:"text-xs font-semibold text-red-600 dark:text-red-400 mb-1"},bu={class:"text-xs bg-red-50 dark:bg-red-950 p-2 rounded overflow-x-auto text-red-900 dark:text-red-100 border border-red-300 dark:border-red-700"},xu={key:2,class:"mb-4"},yu={class:"w-full text-xs border border-neutral-300 dark:border-neutral-700 rounded"},ku={class:"border-b border-neutral-200 dark:border-neutral-800"},wu={class:"py-1 px-2 font-mono"},_u={key:1},$u={class:"border-b border-neutral-200 dark:border-neutral-800"},Cu={class:"py-1 px-2 font-mono"},Vu={key:1},Su={key:0,class:"border-b border-neutral-200 dark:border-neutral-800"},Tu={class:"py-1 px-2 font-mono"},Mu={key:1},Iu={class:"border-b border-neutral-200 dark:border-neutral-800"},Lu={class:"py-1 px-2 font-mono"},Eu={key:1},Au={key:1,class:"border-b border-neutral-200 dark:border-neutral-800"},Pu={class:"py-1 px-2 font-mono text-accent-600 dark:text-accent-400"},Ou={class:"border-b border-neutral-200 dark:border-neutral-800"},ju={class:"py-1 px-2 font-mono font-semibold"},Du={key:1},Uu={class:"py-1 px-2 font-mono font-semibold"},Nu={key:1},Ru={key:3,class:"mb-4"},Bu={class:"text-xs font-semibold mb-1"},qu={class:"border border-neutral-300 dark:border-neutral-700 rounded overflow-hidden"},Fu=["onClick"],zu={class:"font-mono"},Hu={class:"text-neutral-500"},Wu={class:"px-2 py-2 bg-white dark:bg-neutral-950 border-t border-neutral-200 dark:border-neutral-800"},Ju={class:"text-xs mb-2"},Zu={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-neutral-200 dark:border-neutral-800"},Ku={class:"text-xs mb-2"},Gu={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-neutral-200 dark:border-neutral-800"},Xu={class:"text-xs mb-2"},Yu={class:"rounded overflow-hidden border border-neutral-200 dark:border-neutral-800 bg-white dark:bg-black"},Qu={key:0,class:"text-xs"},ec={class:"text-xs overflow-x-auto bg-green-50 dark:bg-green-950/20 p-2 rounded border border-green-300 dark:border-green-700 whitespace-pre-wrap"},tc={key:1,class:"text-xs"},oc={key:4,class:"mb-4"},ac={class:"border border-accent-300 dark:border-accent-700 rounded overflow-hidden bg-accent-50 dark:bg-accent-950/20"},lc={class:"text-xs p-2 overflow-x-auto whitespace-pre-wrap max-h-96 text-accent-900 dark:text-accent-100"},sc={key:5,class:"mb-4"},nc={class:"text-xs font-semibold mb-1"},rc={class:"border border-purple-300 dark:border-purple-700 rounded overflow-hidden bg-purple-50 dark:bg-purple-950/20"},ic={class:"divide-y divide-purple-200 dark:divide-purple-800"},dc={class:"flex items-center gap-2 mb-1"},uc={class:"text-xs font-semibold text-purple-700 dark:text-purple-300"},cc={key:0,class:"text-xs font-mono text-purple-600 dark:text-purple-400"},pc={key:1,class:"text-xs text-purple-500 dark:text-purple-500"},mc={key:2,class:"text-xs text-purple-500 dark:text-purple-500"},vc={key:0,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},fc={class:"text-purple-900 dark:text-purple-100 whitespace-pre-wrap"},hc={key:1,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},gc={class:"font-mono text-purple-700 dark:text-purple-300 break-all"},bc={key:2,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},xc={class:"text-purple-900 dark:text-purple-100 whitespace-pre-wrap"},yc={key:0,class:"mt-2 pt-2 border-t border-purple-200 dark:border-purple-800"},kc={class:"font-mono text-purple-700 dark:text-purple-300 text-xs break-all"},wc={key:3,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},_c={class:"text-purple-900 dark:text-purple-100 overflow-x-auto"},$c={key:6,class:"mb-4"},Cc={class:"bg-white dark:bg-neutral-900 rounded overflow-hidden border border-neutral-300 dark:border-neutral-700"},Vc=se({__name:"LogDetails",props:{log:{},hasPrevious:{type:Boolean},hasNext:{type:Boolean}},emits:["close","previous","next"],setup(t,{emit:i}){const s=t,c=i,a=v("request"),u=v(new Set),r=v(new Set),p=v(!1),f=v(!1),b=v(null),n=v(new Set),d=P=>{if(!P)return"N/A";try{return JSON.stringify(JSON.parse(P),null,2)}catch{return P}},h=z(()=>{if(!s.log.tools_schema)return[];try{const P=JSON.parse(s.log.tools_schema);return Array.isArray(P)?P:[]}catch{return[]}}),$=z(()=>{if(!s.log.response_body)return[];try{const _=JSON.parse(s.log.response_body)?.choices?.[0]?.message?.tool_calls;return Array.isArray(_)?_:[]}catch{return[]}}),g=z(()=>{if(!s.log.tool_results)return new Map;try{const P=JSON.parse(s.log.tool_results),_=new Map;return Array.isArray(P)&&P.forEach(O=>{O.tool_call_id&&_.set(O.tool_call_id,{content:O.content,status:O.status,tool_name:O.tool_name,timestamp:O.timestamp})}),_}catch{return new Map}}),m=z(()=>{if(!s.log.response_body)return[];try{const _=JSON.parse(s.log.response_body)?.choices?.[0]?.message?.reasoning_details;return Array.isArray(_)?_:[]}catch{return[]}}),C=P=>{u.value.has(P)?u.value.delete(P):u.value.add(P)},w=P=>{r.value.has(P)?r.value.delete(P):r.value.add(P)},E=P=>{n.value.has(P)?n.value.delete(P):n.value.add(P)},A=P=>!n.value.has(P),q=z(()=>{if(!s.log.errors)return[];try{const P=JSON.parse(s.log.errors);return Array.isArray(P)?P:[]}catch{return[]}}),J=()=>{xe(()=>{b.value&&(b.value.scrollTop=b.value.scrollHeight)})};ie(()=>s.log.message_history,()=>{J()},{immediate:!0});const X=async()=>{p.value=!0;try{if(!s.log.request_body||!s.log.model)throw new Error("Missing request data");const P=await fetch(te(`/api/models/${s.log.model}/curl-data`));if(!P.ok)throw new Error("Failed to fetch model data");const _=await P.json(),O=d(s.log.request_body);let D=`curl -X POST '${_.endpoint}' \\
3
- `;D+=` -H 'Content-Type: application/json' \\
4
- `,_.sdk?.toLowerCase()==="openrouter"?(D+=` -H 'Authorization: Bearer ${_.api_key}' \\
5
- `,D+=` -H 'HTTP-Referer: https://agentkit.local' \\
6
- `,D+=` -H 'X-Title: AgentKit' \\
7
- `):_.sdk?.toLowerCase()==="openai"&&(D+=` -H 'Authorization: Bearer ${_.api_key}' \\
8
- `),D+=` -d '${O.replace(/'/g,"'\\''")}'`,await navigator.clipboard.writeText(D),f.value=!0,setTimeout(()=>{f.value=!1},2e3)}catch(P){console.error("Failed to copy cURL command:",P),alert(`Failed to copy cURL: ${P instanceof Error?P.message:"Unknown error"}`)}finally{p.value=!1}};return(P,_)=>(o(),l("div",td,[e("div",od,[e("div",ad,[e("div",ld,[e("button",{onClick:_[0]||(_[0]=O=>c("previous")),disabled:!t.hasPrevious,class:"w-7 h-7 flex items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:text-neutral-200 dark:hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent dark:disabled:hover:bg-transparent transition-all","aria-label":"Previous log",title:"Previous log"},[..._[9]||(_[9]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("polyline",{points:"15 18 9 12 15 6"})],-1)])],8,sd),e("button",{onClick:_[1]||(_[1]=O=>c("next")),disabled:!t.hasNext,class:"w-7 h-7 flex items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:text-neutral-200 dark:hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent dark:disabled:hover:bg-transparent transition-all","aria-label":"Next log",title:"Next log"},[..._[10]||(_[10]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("polyline",{points:"9 18 15 12 9 6"})],-1)])],8,nd)]),e("h3",rd,V(t.log.prompt_name||t.log.model_name||t.log.model),1)]),e("div",id,[e("button",{onClick:X,disabled:p.value||!t.log.request_body,class:"px-3 py-1 text-xs font-medium bg-black text-white dark:bg-white dark:text-black rounded hover:opacity-80 disabled:opacity-50 disabled:cursor-not-allowed transition-opacity",title:t.log.request_body?"Copy cURL command":"No request data available"},[p.value?(o(),Q(be,{key:0,size:"xs"})):(o(),l("span",ud,V(f.value?"Copied!":"Copy cURL"),1))],8,dd),e("button",{onClick:_[2]||(_[2]=O=>c("close")),class:"w-7 h-7 flex items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:text-neutral-200 dark:hover:bg-neutral-800 transition-all","aria-label":"Close details",title:"Close"},[..._[11]||(_[11]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])])])]),e("div",cd,[e("div",pd,[e("table",md,[_[12]||(_[12]=e("thead",null,[e("tr",{class:"border-b border-neutral-200 dark:border-neutral-800"},[e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Status "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Provider "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Prompt "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Latency "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Tokens "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Cost "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Created ")])],-1)),e("tbody",null,[e("tr",null,[e("td",{class:oe(["py-1 font-mono",t.log.error?"text-red-600 dark:text-red-400":t.log.is_complete?"text-green-600 dark:text-green-400":"text-yellow-600 dark:text-yellow-400"])},V(t.log.error?"ERROR":t.log.is_complete?"SUCCESS":"LOADING"),3),e("td",vd,V(t.log.provider),1),e("td",fd,[!t.log.is_complete&&!t.log.prompt_name?(o(),Q(be,{key:0,size:"xs"})):(o(),l("span",hd,V(t.log.prompt_name||"—"),1))]),e("td",gd,[!t.log.is_complete&&!t.log.latency_ms?(o(),Q(be,{key:0,size:"xs"})):(o(),l("span",bd,V(t.log.latency_ms?`${t.log.latency_ms}ms`:"—"),1))]),e("td",xd,[!t.log.is_complete&&!t.log.total_tokens?(o(),Q(be,{key:0,size:"xs"})):(o(),l("span",yd,V(t.log.total_tokens?`${t.log.input_tokens}/${t.log.output_tokens} (${t.log.total_tokens})`:"—"),1))]),e("td",kd,[!t.log.is_complete&&!t.log.cost_total?(o(),Q(be,{key:0,size:"xs"})):(o(),l("span",wd,V(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))]),e("td",_d,[I(ot,{timestamp:t.log.created_at},null,8,["timestamp"])])])])])]),e("div",$d,[e("table",Cd,[_[13]||(_[13]=e("thead",null,[e("tr",{class:"border-b border-neutral-200 dark:border-neutral-800"},[e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Status "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Provider "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Prompt ")])],-1)),e("tbody",null,[e("tr",null,[e("td",{class:oe(["py-1 font-mono",t.log.error?"text-red-600 dark:text-red-400":t.log.is_complete?"text-green-600 dark:text-green-400":"text-yellow-600 dark:text-yellow-400"])},V(t.log.error?"ERROR":t.log.is_complete?"SUCCESS":"LOADING"),3),e("td",Vd,V(t.log.provider),1),e("td",Sd,[!t.log.is_complete&&!t.log.prompt_name?(o(),Q(be,{key:0,size:"xs"})):(o(),l("span",Td,V(t.log.prompt_name||"—"),1))])])])]),e("table",Md,[_[14]||(_[14]=e("thead",null,[e("tr",{class:"border-b border-neutral-200 dark:border-neutral-800"},[e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Latency "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Tokens "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Cost "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Created ")])],-1)),e("tbody",null,[e("tr",null,[e("td",Id,[!t.log.is_complete&&!t.log.latency_ms?(o(),Q(be,{key:0,size:"xs"})):(o(),l("span",Ld,V(t.log.latency_ms?`${t.log.latency_ms}ms`:"—"),1))]),e("td",Ed,[!t.log.is_complete&&!t.log.total_tokens?(o(),Q(be,{key:0,size:"xs"})):(o(),l("span",Ad,V(t.log.total_tokens?`${t.log.input_tokens}/${t.log.output_tokens} (${t.log.total_tokens})`:"—"),1))]),e("td",Pd,[!t.log.is_complete&&!t.log.cost_total?(o(),Q(be,{key:0,size:"xs"})):(o(),l("span",Od,V(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))]),e("td",jd,[I(ot,{timestamp:t.log.created_at},null,8,["timestamp"])])])])])])]),e("div",Dd,[e("div",Ud,[e("button",{onClick:_[3]||(_[3]=O=>a.value="request"),class:oe(["pb-2 px-1 text-sm font-medium border-b-2 transition-colors",a.value==="request"?"border-black dark:border-white text-black dark:text-white":"border-transparent text-neutral-500 dark:text-neutral-400 hover:text-black dark:hover:text-white"])}," Request ",2),e("button",{onClick:_[4]||(_[4]=O=>a.value="response"),class:oe(["pb-2 px-1 text-sm font-medium border-b-2 transition-colors flex items-center gap-1",a.value==="response"?"border-black dark:border-white text-black dark:text-white":"border-transparent text-neutral-500 dark:text-neutral-400 hover:text-black dark:hover:text-white"])},[_[15]||(_[15]=ke(" Response ",-1)),t.log.error||q.value.length>0?(o(),l("span",Nd,"⚠")):M("",!0)],2)])]),e("div",Rd,[_e(e("div",Bd,[t.log.system_prompt?(o(),l("div",qd,[e("button",{onClick:_[5]||(_[5]=O=>E("system_prompt")),class:"w-full px-3 py-2 text-left bg-neutral-50 dark:bg-neutral-950 hover:bg-neutral-100 dark:hover:bg-neutral-950 transition-colors flex items-center justify-between"},[_[16]||(_[16]=e("span",{class:"text-xs font-semibold"},"System Prompt",-1)),e("span",Fd,V(A("system_prompt")?"▼":"▶"),1)]),_e(e("div",zd,[I(He,{code:t.log.system_prompt,language:"markdown"},null,8,["code"]),e("div",Hd,[I(it,{content:t.log.system_prompt,variant:"ghost",size:"xs"},null,8,["content"])])],512),[[De,A("system_prompt")]])])):M("",!0),t.log.message_history?(o(),l("div",Wd,[e("button",{onClick:_[6]||(_[6]=O=>E("messages")),class:"w-full px-3 py-2 text-left bg-neutral-50 dark:bg-neutral-950 hover:bg-neutral-100 dark:hover:bg-neutral-950 transition-colors flex items-center justify-between"},[e("span",Jd,"Messages ("+V(t.log.message_history_length||0)+" messages)",1),e("span",Zd,V(A("messages")?"▼":"▶"),1)]),_e(e("div",Kd,[I(He,{code:d(t.log.message_history),language:"json"},null,8,["code"]),e("div",Gd,[I(it,{content:d(t.log.message_history),variant:"ghost",size:"xs"},null,8,["content"])])],512),[[De,A("messages")]])])):M("",!0),t.log.request_body?(o(),l("div",Xd,[e("button",{onClick:_[7]||(_[7]=O=>E("request_body")),class:"w-full px-3 py-2 text-left bg-neutral-50 dark:bg-neutral-950 hover:bg-neutral-100 dark:hover:bg-neutral-950 transition-colors flex items-center justify-between"},[_[17]||(_[17]=e("span",{class:"text-xs font-semibold"},"Full Request Body",-1)),e("span",Yd,V(A("request_body")?"▼":"▶"),1)]),_e(e("div",Qd,[I(He,{code:d(t.log.request_body),language:"json"},null,8,["code"]),e("div",eu,[I(it,{content:d(t.log.request_body),variant:"ghost",size:"xs"},null,8,["content"])])],512),[[De,A("request_body")]])])):M("",!0),h.value.length>0?(o(),l("div",tu,[e("div",ou,[e("button",{onClick:_[8]||(_[8]=O=>E("tools")),class:"w-full px-3 py-2 text-left bg-neutral-50 dark:bg-neutral-900 hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors flex items-center justify-between"},[e("span",au,"Available Tools ("+V(h.value.length)+")",1),e("span",lu,V(A("tools")?"▼":"▶"),1)]),_e(e("div",su,[(o(!0),l(ce,null,fe(h.value,(O,D)=>(o(),l("div",{key:D,class:"border-b border-neutral-200 dark:border-neutral-800 last:border-b-0"},[e("button",{onClick:N=>C(D),class:"w-full px-2 py-1.5 text-left hover:bg-neutral-50 dark:hover:bg-neutral-900 transition-colors flex items-center justify-between text-xs"},[e("span",ru,V(O.function?.name||O.name||"Unknown"),1),e("span",iu,V(u.value.has(D)?"▼":"▶"),1)],8,nu),_e(e("div",du,[O.function?.description||O.description?(o(),l("div",uu,V(O.function?.description||O.description),1)):M("",!0),I(He,{code:JSON.stringify(O,null,2),language:"json"},null,8,["code"])],512),[[De,u.value.has(D)]])]))),128))],512),[[De,A("tools")]])])])):M("",!0)],512),[[De,a.value==="request"]]),_e(e("div",null,[q.value.length>0?(o(),l("div",cu,[e("div",pu,V(q.value.length>1?`Errors (${q.value.length})`:"Error"),1),e("div",mu,[(o(!0),l(ce,null,fe(q.value,(O,D)=>(o(),l("div",{key:D,class:"border border-red-300 dark:border-red-700 rounded overflow-hidden"},[e("div",vu,V(O.type||"error"),1),e("pre",fu,V(O.message),1)]))),128))])])):t.log.error?(o(),l("div",hu,[e("div",gu," Error "+V(t.log.error_type?`(${t.log.error_type})`:""),1),e("pre",bu,V(t.log.error),1)])):M("",!0),t.log.is_complete||!t.log.error?(o(),l("div",xu,[_[25]||(_[25]=e("div",{class:"text-xs font-semibold mb-1"},"Response Stats",-1)),e("table",yu,[e("tbody",null,[e("tr",ku,[_[18]||(_[18]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Finish Reason ",-1)),e("td",wu,[!t.log.is_complete&&!t.log.finish_reason?(o(),Q(be,{key:0,size:"xs"})):(o(),l("span",_u,V(t.log.finish_reason||"—"),1))])]),e("tr",$u,[_[19]||(_[19]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Input Tokens ",-1)),e("td",Cu,[!t.log.is_complete&&!t.log.input_tokens?(o(),Q(be,{key:0,size:"xs"})):(o(),l("span",Vu,V(t.log.input_tokens||"—"),1))])]),t.log.cached_tokens||!t.log.is_complete?(o(),l("tr",Su,[_[20]||(_[20]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Cached Tokens ",-1)),e("td",Tu,[!t.log.is_complete&&!t.log.cached_tokens?(o(),Q(be,{key:0,size:"xs"})):(o(),l("span",Mu,V(t.log.cached_tokens||0),1))])])):M("",!0),e("tr",Iu,[_[21]||(_[21]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Output Tokens ",-1)),e("td",Lu,[!t.log.is_complete&&!t.log.output_tokens?(o(),Q(be,{key:0,size:"xs"})):(o(),l("span",Eu,V(t.log.output_tokens||"—"),1))])]),t.log.reasoning_tokens&&t.log.reasoning_tokens>0?(o(),l("tr",Au,[_[22]||(_[22]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Reasoning Tokens ",-1)),e("td",Pu,V(t.log.reasoning_tokens),1)])):M("",!0),e("tr",Ou,[_[23]||(_[23]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Total Tokens ",-1)),e("td",ju,[!t.log.is_complete&&!t.log.total_tokens?(o(),Q(be,{key:0,size:"xs"})):(o(),l("span",Du,V(t.log.total_tokens||"—"),1))])]),e("tr",null,[_[24]||(_[24]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Total Cost ",-1)),e("td",Uu,[!t.log.is_complete&&!t.log.cost_total?(o(),Q(be,{key:0,size:"xs"})):(o(),l("span",Nu,V(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))])])])])])):M("",!0),$.value.length>0?(o(),l("div",Ru,[e("div",Bu," Tools Called ("+V($.value.length)+") ",1),e("div",qu,[(o(!0),l(ce,null,fe($.value,(O,D)=>(o(),l("div",{key:D,class:"border-b border-neutral-200 dark:border-neutral-800 last:border-b-0"},[e("button",{onClick:N=>w(D),class:"w-full px-2 py-1.5 text-left hover:bg-neutral-50 dark:hover:bg-neutral-900 transition-colors flex items-center justify-between text-xs"},[e("span",zu,V(O.function?.name||"Unknown"),1),e("span",Hu,V(r.value.has(D)?"▼":"▶"),1)],8,Fu),_e(e("div",Wu,[e("div",Ju,[_[26]||(_[26]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Tool Call ID ",-1)),e("div",Zu,V(O.id),1)]),e("div",Ku,[_[27]||(_[27]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Function Name ",-1)),e("div",Gu,V(O.function?.name),1)]),e("div",Xu,[_[28]||(_[28]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Arguments ",-1)),e("div",Yu,[I(He,{code:d(O.function?.arguments||"{}"),language:"json"},null,8,["code"])])]),g.value.has(O.id)?(o(),l("div",Qu,[_[29]||(_[29]=e("div",{class:"font-semibold text-green-600 dark:text-green-400 mb-1"}," Result ",-1)),e("pre",ec,V(g.value.get(O.id)?.content||"No content"),1)])):(o(),l("div",tc,[..._[30]||(_[30]=[e("div",{class:"font-semibold text-neutral-500 dark:text-neutral-500 mb-1"}," Result ",-1),e("div",{class:"text-xs text-neutral-500 dark:text-neutral-500 italic"}," No result available ",-1)])]))],512),[[De,r.value.has(D)]])]))),128))])])):M("",!0),t.log.reasoning_content?(o(),l("div",oc,[_[32]||(_[32]=e("div",{class:"text-xs font-semibold mb-1"},"Reasoning Content",-1)),e("div",ac,[_[31]||(_[31]=e("div",{class:"px-2 py-1.5 bg-accent-100 dark:bg-accent-900/30 text-xs text-accent-800 dark:text-accent-200 border-b border-accent-300 dark:border-accent-700"}," Internal reasoning output (not displayed to users) ",-1)),e("pre",lc,V(t.log.reasoning_content),1)])])):M("",!0),m.value.length>0?(o(),l("div",sc,[e("div",nc," Reasoning Details ("+V(m.value.length)+" blocks) ",1),e("div",rc,[_[37]||(_[37]=e("div",{class:"px-2 py-1.5 bg-purple-100 dark:bg-purple-900/30 text-xs text-purple-800 dark:text-purple-200 border-b border-purple-300 dark:border-purple-700"}," Structured reasoning blocks from OpenRouter (preserved for multi-turn continuity) ",-1)),e("div",ic,[(o(!0),l(ce,null,fe(m.value,(O,D)=>(o(),l("div",{key:D,class:"p-2"},[e("div",dc,[e("span",uc,V(O.type||"unknown"),1),O.id?(o(),l("span",cc," ID: "+V(O.id),1)):M("",!0),O.format?(o(),l("span",pc," Format: "+V(O.format),1)):M("",!0),O.index!==void 0?(o(),l("span",mc," Index: "+V(O.index),1)):M("",!0)]),O.type==="reasoning.summary"&&O.summary?(o(),l("div",vc,[_[33]||(_[33]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Summary: ",-1)),e("div",fc,V(O.summary),1)])):M("",!0),O.type==="reasoning.encrypted"&&O.data?(o(),l("div",hc,[_[34]||(_[34]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Encrypted Data: ",-1)),e("div",gc,V(O.data),1)])):M("",!0),O.type==="reasoning.text"&&O.text?(o(),l("div",bc,[_[36]||(_[36]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Reasoning Text: ",-1)),e("div",xc,V(O.text),1),O.signature?(o(),l("div",yc,[_[35]||(_[35]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Signature: ",-1)),e("div",kc,V(O.signature),1)])):M("",!0)])):M("",!0),["reasoning.summary","reasoning.encrypted","reasoning.text"].includes(O.type)?M("",!0):(o(),l("div",wc,[e("pre",_c,V(JSON.stringify(O,null,2)),1)]))]))),128))])])])):M("",!0),t.log.response_body?(o(),l("div",$c,[_[38]||(_[38]=e("div",{class:"text-xs font-semibold mb-1"},"Full Response Body",-1)),e("div",Cc,[I(He,{code:d(t.log.response_body),language:"json"},null,8,["code"])])])):M("",!0)],512),[[De,a.value==="response"]])])]))}}),Sc={class:"flex flex-col h-full"},Tc={class:"p-4 border-b border-neutral-300 dark:border-neutral-700"},Mc={class:"flex items-center justify-between"},Ic={class:"flex items-center gap-2"},Lc={class:"flex items-center gap-2"},Ec={key:0,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},Ac={key:1,class:"flex justify-center py-12"},Pc={key:2,class:"text-red-600 dark:text-red-400 text-center py-12"},Oc={key:3,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},jc={key:4},Dc={key:0,class:"border-b border-neutral-300 dark:border-neutral-700 bg-white dark:bg-black sticky top-0 z-10"},Uc=["disabled"],Nc={key:1},Rc={key:2},Bc={class:"w-full text-sm"},qc=["onClick","onMouseenter"],Fc={class:"px-3 py-2 text-xs"},zc={class:"flex items-center gap-1"},Hc={key:0,class:"text-neutral-400 dark:text-neutral-600 mr-1"},Wc={key:3},Jc={class:"px-3 py-2"},Zc={class:"flex items-center gap-2"},Kc={key:0,class:"text-red-600 dark:text-red-400",title:"Error"},Gc={class:"font-mono text-xs"},Xc={class:"px-3 py-2 font-mono text-xs"},Yc={key:1},Qc={class:"px-3 py-2 text-xs text-neutral-600 dark:text-neutral-400"},e0={key:1},t0={class:"px-3 py-2 text-right text-xs text-neutral-500 dark:text-neutral-500"},o0={key:0,class:"log-details-panel relative shrink-0 bg-neutral-100 dark:bg-neutral-950 border-t border-neutral-300 dark:border-neutral-700 overflow-hidden"},a0={class:"m-2 border h-[calc(100%-1rem)] border-neutral-300 shrink-0 dark:border-neutral-700 rounded-xl bg-white dark:bg-neutral-900 overflow-auto"},l0={key:0,class:"absolute inset-0 bg-white/50 dark:bg-black/50 flex items-center justify-center"},It=20,s0=20,n0=se({__name:"LogsPane",props:{threadId:{},selectedLogId:{},hoveredLogId:{}},emits:["collapse","logClick","logHover","logsLoaded"],setup(t,{expose:i,emit:s}){const c=t,a=s,u=v(0),r=v(It),{logs:p,hasMore:f,isFetching:b,error:n,wsConnected:d,wsError:h,connectWebSocket:$,disconnectWebSocket:g,refetch:m}=Hi(z(()=>c.threadId),{limit:z(()=>r.value),offset:z(()=>u.value),enableWebSocket:!0,order:"desc"}),C=v([]),w=v(!0),E=v(null),A=v(null),q=v(!1),J=v(!1),X=v(new Map),P=async()=>{await xe(),A.value&&(A.value.scrollTop=A.value.scrollHeight)},_=v(null);ie(p,async Z=>{if(u.value===0)C.value=[...Z].reverse(),w.value&&C.value.length>0&&(await P(),w.value=!1);else{const ee=[...Z].reverse(),ae=new Map;C.value.forEach(pe=>ae.set(pe.id,pe)),ee.forEach(pe=>ae.set(pe.id,pe)),C.value=Array.from(ae.values()).sort((pe,ve)=>pe.created_at-ve.created_at)}},{deep:!0,immediate:!0}),ie(b,(Z,ee)=>{if(ee&&!Z&&u.value===0&&c.threadId&&_.value!==c.threadId&&C.value.length>0){_.value=c.threadId;const ae=C.value[C.value.length-1];a("logsLoaded",ae?.id??null)}});const{logDetails:O,isFetching:D}=Wi(z(()=>c.threadId),z(()=>E.value)),N=z(()=>{if(!E.value)return null;const ee=C.value.find(ae=>ae.id===E.value);return ee?O.value?{...O.value,...ee}:ee:null}),U=z(()=>E.value?he.value.findIndex(Z=>Z.id===E.value):-1),L=z(()=>U.value>0),T=z(()=>U.value>=0&&U.value<he.value.length-1),j=()=>{if(L.value){const Z=he.value[U.value-1];y(Z)}},S=()=>{if(T.value){const Z=he.value[U.value+1];y(Z)}},x=Z=>{if(!A.value)return;const ee=X.value.get(Z);if(!ee)return;const ae=A.value,pe=ee.getBoundingClientRect(),ve=ae.getBoundingClientRect(),we=ae.querySelectorAll(".sticky");let Se=0;we.forEach(me=>{Se+=me.getBoundingClientRect().height}),Se+=16;const re=pe.top<ve.top+Se,ne=pe.bottom>ve.bottom;re?ae.scrollBy({top:pe.top-ve.top-Se,behavior:"smooth"}):ne&&ae.scrollBy({top:pe.bottom-ve.bottom,behavior:"smooth"})},y=Z=>{a("logClick",Z.id),E.value=Z.id},k=(Z,ee)=>{ee?X.value.set(Z,ee):X.value.delete(Z)};ie(E,async Z=>{Z&&(await xe(),x(Z))}),ie(()=>c.selectedLogId,Z=>{Z&&(E.value=Z)}),i({scrollToLog:async Z=>{await xe();const ee=X.value.get(Z);if(ee&&A.value){const ae=A.value,pe=ee.getBoundingClientRect(),ve=ae.getBoundingClientRect(),we=ae.querySelector("thead"),Se=ae.querySelector(":scope > div > div.sticky");let re=0;we&&(re+=we.getBoundingClientRect().height),Se&&(re+=Se.getBoundingClientRect().height),re+=40;const ne=pe.top<ve.top+re,me=pe.bottom>ve.bottom;ne?ae.scrollBy({top:pe.top-ve.top-re,behavior:"smooth"}):me&&ae.scrollBy({top:pe.bottom-ve.bottom,behavior:"smooth"})}},removeLogsByIds:Z=>{if(Z.length===0)return;const ee=new Set(Z);C.value=C.value.filter(ae=>!ee.has(ae.id))}});const H=async()=>{if(J.value||!f.value||b.value)return;J.value=!0;const Z=A.value?.scrollHeight||0;if(u.value+=r.value,r.value=s0,await m(),await xe(),A.value){const ee=A.value.scrollHeight;A.value.scrollTop+=ee-Z}J.value=!1};ie(()=>c.threadId,async Z=>{Z?(g(),$()):g(),u.value=0,r.value=It,C.value=[],E.value=null,q.value=!1,w.value=!0},{immediate:!0}),ie(C,async()=>{q.value||await P()},{deep:!0});const W=()=>{if(!A.value)return;const{scrollTop:Z,scrollHeight:ee,clientHeight:ae}=A.value,pe=ee-Z-ae<50;q.value=!pe},G=Z=>{if(!Z.tools_called)return"—";try{const ee=JSON.parse(Z.tools_called);return Array.isArray(ee)?ee.join(", "):Z.tools_called}catch{return Z.tools_called}},ue=Z=>Z==null?"—":`$${Z.toFixed(6)}`,he=z(()=>{const Z=new Map,ee=new Map;C.value.forEach(ve=>{Z.set(ve.id,ve);const we=ve.parent_log_id;we&&(ee.has(we)||ee.set(we,[]),ee.get(we).push(ve))});const ae=[],pe=(ve,we)=>{ae.push({...ve,depth:we}),(ee.get(ve.id)||[]).forEach(re=>{pe(re,we+1)})};return C.value.forEach(ve=>{ve.parent_log_id||pe(ve,0)}),ae});return(Z,ee)=>(o(),l("div",Sc,[e("div",Tc,[e("div",Mc,[e("div",Ic,[I(F(Rt),{size:20,class:"shrink-0"}),ee[4]||(ee[4]=e("h2",{class:"text-xl font-bold"},"Logs",-1)),t.threadId?(o(),Q(xt,{key:0,connected:F(d),error:F(h)},null,8,["connected","error"])):M("",!0)]),e("div",Lc,[e("button",{onClick:ee[0]||(ee[0]=ae=>a("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[I(F(gt),{size:20})])])])]),e("div",{ref_key:"logsScrollContainer",ref:A,class:"logs-list-container flex-1 overflow-y-auto overflow-x-auto",onScroll:W},[t.threadId?F(b)&&u.value===0?(o(),l("div",Ac,[I(be)])):F(n)?(o(),l("div",Pc," Error loading logs: "+V(F(n)),1)):C.value.length===0?(o(),l("div",Oc," No logs yet ")):(o(),l("div",jc,[F(f)?(o(),l("div",Dc,[e("button",{onClick:H,disabled:J.value,type:"button",class:"w-full px-3 py-2 text-xs font-medium text-neutral-700 dark:text-neutral-300 hover:bg-neutral-100 dark:hover:bg-neutral-900 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"},[J.value?(o(),Q(be,{key:0,size:"xs"})):M("",!0),J.value?(o(),l("span",Nc,"Loading older logs...")):(o(),l("span",Rc,"Load previous logs"))],8,Uc)])):M("",!0),e("table",Bc,[e("thead",{class:oe(["border-b border-neutral-300 dark:border-neutral-700 sticky bg-white z-[10] dark:bg-black",{"top-0":!F(f),"top-[34px]":F(f)}])},[...ee[5]||(ee[5]=[e("tr",null,[e("th",{class:"text-left px-3 py-2 font-semibold"},"Prompt"),e("th",{class:"text-left px-3 py-2 font-semibold"},"Model"),e("th",{class:"text-left px-3 py-2 font-semibold"},"Cost"),e("th",{class:"text-left px-3 py-2 font-semibold"},"Tools Called"),e("th",{class:"text-right px-3 py-2 font-semibold"},"Called At")],-1)])],2),e("tbody",null,[(o(!0),l(ce,null,fe(he.value,ae=>(o(),l("tr",{key:ae.id,ref_for:!0,ref:pe=>k(ae.id,pe),class:oe(["border-b border-neutral-200 dark:border-neutral-800 cursor-pointer transition-colors relative",{"last:border-b-0":N.value,"bg-red-50 dark:bg-red-950/20":ae.error,"bg-accent-100 dark:bg-accent-900 dark:text-white":E.value===ae.id,"ring-2 ring-inset ring-accent-400 dark:ring-accent-400":ae.id===c.selectedLogId||ae.id!==c.selectedLogId&&ae.id===c.hoveredLogId}]),onClick:pe=>y(ae),onMouseenter:pe=>a("logHover",ae.id),onMouseleave:ee[1]||(ee[1]=pe=>a("logHover",null))},[e("td",Fc,[e("div",zc,[ae.depth>0?(o(),l("span",Hc,"└─")):M("",!0),ae.retry_of_log_id?(o(),Q(F(ko),{key:1,size:14,class:"text-neutral-500 dark:text-neutral-400 flex-shrink-0"})):M("",!0),!ae.is_complete&&!ae.prompt_name?(o(),Q(be,{key:2,size:"xs"})):(o(),l("span",Wc,V(ae.prompt_name||"—"),1))])]),e("td",Jc,[e("div",Zc,[ae.error?(o(),l("span",Kc," ✕ ")):M("",!0),e("span",Gc,V(ae.model_name||ae.model),1)])]),e("td",Xc,[!ae.is_complete&&!ae.cost_total?(o(),Q(be,{key:0,size:"xs"})):(o(),l("span",Yc,V(ue(ae.cost_total)),1))]),e("td",Qc,[!ae.is_complete&&G(ae)==="—"?(o(),Q(be,{key:0,size:"xs"})):(o(),l("span",e0,V(G(ae)),1))]),e("td",t0,[I(ot,{timestamp:ae.created_at},null,8,["timestamp"])])],42,qc))),128))])])])):(o(),l("div",Ec," Select a thread to view logs "))],544),I(Be,{name:"slide-up",onAfterEnter:ee[3]||(ee[3]=()=>E.value&&x(E.value))},{default:de(()=>[N.value?(o(),l("div",o0,[e("div",a0,[I(Vc,{log:N.value,"has-previous":L.value,"has-next":T.value,onClose:ee[2]||(ee[2]=ae=>E.value=null),onPrevious:j,onNext:S},null,8,["log","has-previous","has-next"]),F(D)?(o(),l("div",l0,[I(be)])):M("",!0)])])):M("",!0)]),_:1})]))}}),r0=Fe(n0,[["__scopeId","data-v-e4ddd93e"]]),i0={class:"space-y-4"},d0={key:0,class:"p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded text-sm text-red-800 dark:text-red-200"},u0={class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},c0={key:0},p0={key:1},m0={key:1,class:"space-y-4 p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},v0={key:3,class:"flex items-center gap-2"},f0=["onUpdate:modelValue","id"],h0=["for"],g0={key:0,class:"text-red-500"},b0={key:5,class:"text-xs text-neutral-500 dark:text-neutral-400 mt-1"},x0={key:2,class:"p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg text-center text-sm text-neutral-500"},y0={key:3},k0={key:0,class:"space-y-3 mb-4 max-h-64 overflow-y-auto p-2"},w0={class:"text-xs font-medium mb-1 opacity-70"},_0={class:"text-sm whitespace-pre-wrap"},$0=["onClick"],C0={key:1,class:"text-center py-8 text-neutral-500 dark:text-neutral-400 text-sm"},V0={class:"space-y-2"},S0={class:"flex items-stretch border border-black dark:border-neutral-300 rounded overflow-hidden bg-white dark:bg-neutral-900"},T0=["disabled","title"],M0={class:"flex-1 relative"},I0=["disabled","title"],L0={class:"text-xs text-neutral-500 dark:text-neutral-400"},E0={class:"flex justify-between"},A0=["disabled"],P0=["disabled"],O0=se({__name:"CreateThreadModal",props:{modelValue:{type:Boolean},editThread:{}},emits:["update:modelValue","thread-created","thread-updated"],setup(t,{emit:i}){const s=t,c=i,a=z(()=>!!s.editThread),u=v(""),r=v(""),p=v({}),f=v([]),b=v(""),n=v(!1),d=v(""),h=v(null),{data:$,isFetching:g,execute:m}=Me(te("/api/agents"),{immediate:!1}).json(),C=z(()=>$.value?($.value?.agents||[]).map(x=>({value:x.id,label:x.title})):[]),w=z(()=>!u.value||!$.value?null:($.value?.agents||[]).find(x=>x.id===u.value)),E=z(()=>w.value&&w.value.type==="ai_human"?"AI":"Side A"),A=z(()=>w.value&&w.value.type==="ai_human"?"Human":"Side B"),{data:q,isFetching:J,execute:X}=Me(z(()=>w.value?.side_a_system_prompt?te(`/api/prompts/${w.value.side_a_system_prompt}`):""),{immediate:!1}).json(),P=z(()=>{if(!q.value)return null;const S=q.value?.required_schema;if(!S)return null;try{return typeof S=="string"?JSON.parse(S):S}catch{return null}}),_=z(()=>{const S=P.value;return!S||!S.properties?[]:Object.entries(S.properties).map(([x,y])=>({name:x,type:y.type||"string",description:y.description||"",required:S.required?.includes(x)||!1,enum:y.enum}))});ie(u,async S=>{S&&w.value?.side_a_system_prompt?(await X(),p.value={}):p.value={}});const O=()=>{const S=h.value;S&&(S.style.height="auto",S.style.height=`${S.scrollHeight}px`)},D=S=>{b.value.trim()&&(f.value.push({id:crypto.randomUUID(),role:S,content:b.value.trim()}),b.value="",setTimeout(()=>O(),0))},N=S=>{f.value=f.value.filter(x=>x.id!==S)},U=()=>{u.value="",r.value="",p.value={},f.value=[],b.value="",d.value=""},L=()=>{s.editThread&&(u.value=s.editThread.agent_id,r.value=s.editThread.tags?.join(", ")||"")},T=async()=>{if(!u.value){d.value="Please select an agent";return}if(!a.value&&_.value.length>0){for(const S of _.value)if(S.required&&!p.value[S.name]){d.value=`Please provide ${S.name}`;return}}n.value=!0,d.value="";try{const S=r.value.split(",").map(x=>x.trim()).filter(x=>x.length>0);if(a.value){const x=await fetch(te(`/api/threads/${s.editThread.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tags:S})});if(!x.ok){const y=await x.json();throw new Error(y.error||"Failed to update thread")}c("thread-updated"),U(),c("update:modelValue",!1)}else{const x={agent_id:u.value,tags:S.length>0?S:void 0};f.value.length>0&&(x.initial_messages=f.value.map(K=>({role:K.role,content:K.content}))),Object.keys(p.value).length>0&&(x.data=p.value);const y=await fetch(te("/api/threads"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!y.ok){const K=await y.json();throw new Error(K.error||"Failed to create thread")}const R=(await y.json()).threadId;if(!R)throw new Error("Thread created but ID not found in response");c("thread-created",R),U(),c("update:modelValue",!1)}}catch(S){console.error(`Error ${a.value?"updating":"creating"} thread:`,S),d.value=S.message||`Failed to ${a.value?"update":"create"} thread`}finally{n.value=!1}},j=()=>{U(),c("update:modelValue",!1)};return ie(()=>s.modelValue,async S=>{S&&(await m(),U(),a.value&&L())}),(S,x)=>(o(),Q(Ae,{"model-value":t.modelValue,"onUpdate:modelValue":x[7]||(x[7]=y=>S.$emit("update:modelValue",y)),title:a.value?"Edit Thread":"Create New Thread",width:"max-w-3xl"},{footer:de(()=>[e("div",E0,[e("button",{onClick:j,type:"button",disabled:n.value,class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors disabled:opacity-50"}," Cancel ",8,A0),e("button",{onClick:T,type:"button",disabled:n.value||F(g),class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity disabled:opacity-50"},[a.value?(o(),l(ce,{key:0},[ke(V(n.value?"Updating...":"Update Thread"),1)],64)):(o(),l(ce,{key:1},[ke(V(n.value?"Creating...":"Create Thread"),1)],64))],8,P0)])]),default:de(()=>[e("div",i0,[d.value?(o(),l("div",d0,V(d.value),1)):M("",!0),e("div",null,[I(ge,{modelValue:u.value,"onUpdate:modelValue":x[0]||(x[0]=y=>u.value=y),label:"Agent",options:C.value,disabled:F(g)||a.value,placeholder:"Select an agent...",required:""},null,8,["modelValue","options","disabled"]),e("p",u0,[a.value?(o(),l("span",c0,"Agent cannot be changed after thread creation")):(o(),l("span",p0,"Choose which agent will handle this conversation"))])]),!a.value&&_.value.length>0&&!F(J)?(o(),l("div",m0,[x[8]||(x[8]=e("h4",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Required Information ",-1)),(o(!0),l(ce,null,fe(_.value,y=>(o(),l("div",{key:y.name,class:"space-y-2"},[y.enum?(o(),Q(ge,{key:0,modelValue:p.value[y.name],"onUpdate:modelValue":k=>p.value[y.name]=k,label:y.name,options:[{value:"",label:"Select..."},...y.enum.map(k=>({value:k,label:k}))],required:y.required},null,8,["modelValue","onUpdate:modelValue","label","options","required"])):y.type==="string"?(o(),Q(Ce,{key:1,modelValue:p.value[y.name],"onUpdate:modelValue":k=>p.value[y.name]=k,label:y.name,placeholder:y.description,required:y.required},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])):y.type==="number"||y.type==="integer"?(o(),Q(Ce,{key:2,modelValue:p.value[y.name],"onUpdate:modelValue":k=>p.value[y.name]=k,modelModifiers:{number:!0},label:y.name,placeholder:y.description,type:"number",required:y.required},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])):y.type==="boolean"?(o(),l("div",v0,[_e(e("input",{"onUpdate:modelValue":k=>p.value[y.name]=k,type:"checkbox",id:`field-${y.name}`,class:"w-4 h-4"},null,8,f0),[[wo,p.value[y.name]]]),e("label",{for:`field-${y.name}`,class:"text-sm"},[ke(V(y.name)+" ",1),y.required?(o(),l("span",g0,"*")):M("",!0)],8,h0)])):(o(),Q(Xt,{key:4,modelValue:p.value[y.name],"onUpdate:modelValue":k=>p.value[y.name]=k,label:y.name,placeholder:y.description||`Enter ${y.name} (JSON format)`,required:y.required,rows:3},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])),y.description?(o(),l("p",b0,V(y.description),1)):M("",!0)]))),128))])):M("",!0),!a.value&&F(J)?(o(),l("div",x0," Loading agent requirements... ")):M("",!0),a.value?M("",!0):(o(),l("div",y0,[x[11]||(x[11]=e("h4",{class:"text-sm font-medium mb-3"},"Initial Conversation",-1)),f.value.length>0?(o(),l("div",k0,[(o(!0),l(ce,null,fe(f.value,y=>(o(),l("div",{key:y.id,class:oe(["flex items-start gap-2",{"justify-start":y.role==="assistant","justify-end":y.role==="user"}])},[e("div",{class:oe(["max-w-[80%] rounded-2xl px-4 py-2 break-words",{"bg-black text-white dark:bg-white dark:text-black":y.role==="assistant","bg-neutral-200 text-black dark:bg-neutral-800 dark:text-white":y.role==="user"}])},[e("div",w0,V(y.role==="assistant"?E.value:A.value),1),e("div",_0,V(y.content),1)],2),e("button",{onClick:k=>N(y.id),type:"button",class:"text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-200 text-xs mt-2"}," ✕ ",8,$0)],2))),128))])):(o(),l("div",C0," No messages yet. Add messages to start the conversation. ")),e("div",V0,[e("div",S0,[e("button",{onClick:x[1]||(x[1]=y=>D("assistant")),type:"button",disabled:!b.value.trim(),title:`Add as ${E.value}`,class:"px-3 py-2 bg-black text-white dark:bg-white dark:text-black text-sm hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap inline-flex items-center gap-1 border-r border-black dark:border-neutral-300 flex-shrink-0"},[x[9]||(x[9]=e("svg",{class:"w-[1em] h-[1em]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 10l7-7m0 0l7 7m-7-7v18"})],-1)),e("span",null,V(E.value),1)],8,T0),e("div",M0,[_e(e("textarea",{"onUpdate:modelValue":x[2]||(x[2]=y=>b.value=y),placeholder:"Type a message...",class:"w-full px-3 py-2 bg-transparent border-0 font-mono text-sm focus:outline-none resize-none overflow-hidden",rows:"1",ref_key:"textareaRef",ref:h,onInput:O,onKeydown:[x[3]||(x[3]=pt(Te(y=>D("user"),["meta"]),["enter"])),x[4]||(x[4]=pt(Te(y=>D("user"),["ctrl"]),["enter"]))]},null,544),[[Ee,b.value]])]),e("button",{onClick:x[5]||(x[5]=y=>D("user")),type:"button",disabled:!b.value.trim(),title:`Add as ${A.value}`,class:"px-3 py-2 bg-black text-white dark:bg-white dark:text-black text-sm hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap inline-flex items-center gap-1 border-l border-black dark:border-neutral-300 flex-shrink-0"},[x[10]||(x[10]=e("svg",{class:"w-[1em] h-[1em]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 10l7-7m0 0l7 7m-7-7v18"})],-1)),e("span",null,V(A.value),1)],8,I0)]),e("p",L0," Type a message and click "+V(E.value)+" (left) or "+V(A.value)+" (right) to add. Or press Cmd+Enter (Mac) / Ctrl+Enter (Windows) to add as "+V(A.value)+". ",1)])])),e("div",null,[I(Ce,{modelValue:r.value,"onUpdate:modelValue":x[6]||(x[6]=y=>r.value=y),label:"Tags",placeholder:"research, urgent, production"},null,8,["modelValue"]),x[12]||(x[12]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Comma-separated tags to help organize and search threads ",-1))])])]),_:1},8,["model-value","title"]))}}),j0={class:"flex h-full overflow-hidden"},D0={key:0,class:"flex flex-col items-center p-4"},U0={key:0,class:"flex flex-col items-center p-4"},N0={key:0,class:"flex flex-col items-center p-4"},Lt=se({__name:"ThreadsView",setup(t){const i=Re(),s=Ze(),c=v(typeof i.params.id=="string"?i.params.id:null),a=v({threadList:!1,messages:!1,logs:!1}),u=v(!1),r=v(null),p=v(null),{thread:f}=bt(z(()=>c.value)),b=v(null),n=v(null),d=v(null),h=U=>{d.value=U},$=U=>{d.value=U},g=v(null),m=v(null);ie(()=>i.params.id,U=>{c.value=typeof U=="string"?U:null,b.value=null,n.value=null});const C=U=>{s.push(`/threads/${U}`)},w=U=>{window.location.href="/threads"},E=()=>{f.value&&(r.value=f.value,u.value=!0)},A=()=>{r.value=null,u.value=!0},q=U=>{p.value?.refetch(),s.push(`/threads/${U}`)},J=()=>{window.location.reload()},X=U=>{a.value[U]=!a.value[U]},P=(U,L)=>{b.value=U,n.value=L,L&&m.value?.scrollToLog(L)},_=U=>{n.value=U,b.value=null,g.value?.scrollToLogId(U)},O=U=>{U&&(n.value=U)},D=U=>{m.value?.removeLogsByIds(U)},N=U=>{U&&!c.value&&s.push(`/threads/${U}`)};return(U,L)=>(o(),l("div",j0,[e("div",{class:oe([a.value.threadList?"w-[60px]":"w-[320px]","border-r border-neutral-300 dark:border-neutral-700 flex-shrink-0 overflow-hidden transition-all duration-200"])},[a.value.threadList?(o(),l("div",D0,[e("button",{onClick:L[0]||(L[0]=T=>X("threadList")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Threads pane"},[I(F(Ut),{size:20})])])):(o(),Q(Zn,{key:1,ref_key:"threadListPaneRef",ref:p,"selected-thread-id":c.value,onSelectThread:C,onCollapse:L[1]||(L[1]=T=>X("threadList")),onCreateThread:A,onThreadsLoaded:N},null,8,["selected-thread-id"]))],2),e("div",{class:oe([a.value.messages?"w-[60px]":"w-[380px]","border-r border-neutral-300 dark:border-neutral-700 flex-shrink-0 overflow-hidden transition-all duration-200"])},[a.value.messages?(o(),l("div",U0,[e("button",{onClick:L[2]||(L[2]=T=>X("messages")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Messages pane"},[I(F(Nt),{size:20})])])):(o(),Q(zi,{key:1,ref_key:"messagesPaneRef",ref:g,"thread-id":c.value,"selected-message-id":b.value,"selected-log-id":n.value,"hovered-log-id":d.value,onCollapse:L[3]||(L[3]=T=>X("messages")),onMessageClick:P,onMessageHover:h,onThreadDeleted:w,onEditThread:E,onLogsDeleted:D},null,8,["thread-id","selected-message-id","selected-log-id","hovered-log-id"]))],2),e("div",{class:oe([a.value.logs?"w-[60px]":"flex-1","overflow-hidden transition-all duration-200"])},[a.value.logs?(o(),l("div",N0,[e("button",{onClick:L[4]||(L[4]=T=>X("logs")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Logs pane"},[I(F(Rt),{size:20})])])):(o(),Q(r0,{key:1,ref_key:"logsPaneRef",ref:m,"thread-id":c.value,"selected-log-id":n.value,"hovered-log-id":d.value,onCollapse:L[5]||(L[5]=T=>X("logs")),onLogClick:_,onLogHover:$,onLogsLoaded:O},null,8,["thread-id","selected-log-id","hovered-log-id"]))],2),I(O0,{modelValue:u.value,"onUpdate:modelValue":L[6]||(L[6]=T=>u.value=T),"edit-thread":r.value,onThreadCreated:q,onThreadUpdated:J},null,8,["modelValue","edit-thread"])]))}}),R0=se({__name:"PromptsDataTable",emits:["add","edit","delete"],setup(t,{expose:i,emit:s}){const c=s,a=v([]),u=v(!1),r=[{key:"name",label:"Name",width:"w-1/4"},{key:"tool_description",label:"Description",width:"w-2/5"},{key:"model_name",label:"Model",width:"w-1/5",formatter:(n,d)=>n||d.model_id||"-"},{key:"created_at",label:"Created",width:"w-1/6",formatter:n=>n?new Date(n*1e3).toLocaleDateString():"-"}],p=[{icon:"edit",label:"Edit",handler:n=>c("edit",n)},{icon:"delete",label:"Delete",handler:async n=>{await b(n)},confirm:!0,confirmMessage:"Are you sure you want to delete this prompt?"}],f=async()=>{u.value=!0;try{const n=await fetch(te("/api/prompts"));if(n.ok){const d=await n.json();a.value=d.prompts||[]}}catch(n){console.error("Error fetching prompts:",n)}finally{u.value=!1}},b=async n=>{try{const d=await fetch(te(`/api/prompts/${n.id}`),{method:"DELETE"});if(d.ok)await f();else{const h=await d.json();alert(h.error||"Failed to delete prompt")}}catch(d){console.error("Error deleting prompt:",d),alert("Failed to delete prompt")}};return ye(()=>{f()}),i({refresh:f}),(n,d)=>(o(),l("div",null,[I(Ne,{columns:r,data:a.value,actions:p,loading:u.value,"empty-message":"No prompts available. Create your first prompt to get started."},null,8,["data","loading"])]))}}),B0={class:"space-y-4"},q0={key:0,class:"mt-1 text-sm text-red-500"},F0={key:1,class:"mt-1 text-sm text-neutral-500 dark:text-neutral-400"},z0={class:"px-1 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded"},H0=["value"],W0=se({__name:"PromptBasicInfo",props:{name:{},toolDescription:{}},emits:["update:name","update:toolDescription"],setup(t,{emit:i}){const s=t,c=i,a=v(""),u=p=>{let f=p.replace(/[^a-zA-Z0-9\s_]/g,"");return f=f.trim().toLowerCase().replace(/\s+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),f?/^[a-z][a-z0-9_]*$/.test(f)?a.value="":a.value="Name must start with a letter and contain only lowercase letters, numbers, and underscores":a.value="Name is required",f},r=p=>{const f=u(p);c("update:name",f)};return ie(()=>s.name,p=>{p&&u(p)},{immediate:!0}),(p,f)=>(o(),l("div",B0,[e("div",null,[I(Ce,{"model-value":t.name,"onUpdate:modelValue":r,label:"Prompt Name",placeholder:"Enter a unique name (will be converted to snake_case)"},null,8,["model-value"]),a.value?(o(),l("p",q0,V(a.value),1)):t.name?(o(),l("p",F0,[f[1]||(f[1]=ke(" Will be saved as: ",-1)),e("code",z0,V(t.name),1)])):M("",!0)]),e("div",null,[f[2]||(f[2]=e("label",{class:"block text-sm font-medium mb-2"},"Tool Description",-1)),e("textarea",{value:t.toolDescription,onInput:f[0]||(f[0]=b=>c("update:toolDescription",b.target.value)),placeholder:"Describe what this prompt does (shown when used as a tool)",class:"w-full px-3 py-2 border border-black dark:border-white rounded bg-transparent resize-none",rows:"3"},null,40,H0)])]))}}),J0="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3crect%20width='48'%20height='48'%20fill='%23F0EFEA'/%3e%3cpath%20d='M32.84%2010H26.72L37.88%2038H44L32.84%2010Z'%20fill='black'/%3e%3cpath%20d='M15.16%2010L4%2038H10.24L12.5224%2032.12H24.1976L26.48%2038H32.72L21.56%2010H15.16ZM14.5408%2026.92L18.36%2017.08L22.1793%2026.92H14.5408Z'%20fill='black'/%3e%3c/svg%3e",ft="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3crect%20width='48'%20height='48'%20rx='24'%20fill='white'/%3e%3cpath%20d='M19.3418%2018.5599V14.7599C19.3418%2014.4399%2019.4608%2014.1998%2019.7382%2014.04L27.3102%209.63997C28.3409%209.03999%2029.5699%208.76014%2030.8383%208.76014C35.5954%208.76014%2038.6085%2012.4802%2038.6085%2016.4401C38.6085%2016.72%2038.6085%2017.04%2038.5687%2017.3601L30.7194%2012.72C30.2437%2012.4401%2029.7678%2012.4401%2029.2922%2012.72L19.3418%2018.5599ZM37.0226%2033.36V24.2799C37.0226%2023.7197%2036.7846%2023.3197%2036.309%2023.0398L26.3586%2017.1998L29.6093%2015.3197C29.8868%2015.1599%2030.1247%2015.1599%2030.4022%2015.3197L37.9741%2019.7197C40.1547%2020.9999%2041.6213%2023.7197%2041.6213%2026.3596C41.6213%2029.3995%2039.8375%2032.1999%2037.0226%2033.36ZM17.0029%2025.3601L13.7522%2023.4402C13.4748%2023.2804%2013.3557%2023.0402%2013.3557%2022.7202V13.9203C13.3557%209.64039%2016.6065%206.40016%2021.0069%206.40016C22.6722%206.40016%2024.2179%206.96029%2025.5265%207.96025L17.7168%2012.5204C17.2412%2012.8003%2017.0033%2013.2002%2017.0033%2013.7605L17.0029%2025.3601ZM24%2029.44L19.3418%2026.8001V21.2003L24%2018.5604L28.6578%2021.2003V26.8001L24%2029.44ZM26.993%2041.6002C25.3278%2041.6002%2023.7821%2041.04%2022.4735%2040.0402L30.2831%2035.4799C30.7588%2035.2001%2030.9967%2034.8001%2030.9967%2034.2399V22.6399L34.2873%2024.5598C34.5646%2024.7196%2034.6837%2024.9597%2034.6837%2025.2798V34.0797C34.6837%2038.3596%2031.3931%2041.6002%2026.993%2041.6002ZM17.5975%2032.6802L10.0255%2028.2803C7.84493%2027.0001%206.37833%2024.2803%206.37833%2021.6404C6.37833%2018.5604%208.20193%2015.8004%2011.0164%2014.6403V23.7602C11.0164%2024.3204%2011.2544%2024.7204%2011.73%2025.0003L21.641%2030.8001L18.3902%2032.6802C18.1129%2032.84%2017.8749%2032.84%2017.5975%2032.6802ZM17.1617%2039.2402C12.682%2039.2402%209.39151%2035.8402%209.39151%2031.6401C9.39151%2031.3201%209.43125%2031.0001%209.47066%2030.68L17.2803%2035.2402C17.7559%2035.5201%2018.2319%2035.5201%2018.7074%2035.2402L28.6578%2029.4404V33.2404C28.6578%2033.5605%2028.5388%2033.8005%2028.2614%2033.9604L20.6894%2038.3604C19.6586%2038.9603%2018.4301%2039.2402%2017.1617%2039.2402ZM26.993%2044C31.7899%2044%2035.7936%2040.5601%2036.7057%2036C41.1457%2034.8399%2044%2030.6399%2044%2026.36C44%2023.5598%2042.8108%2020.8401%2040.6701%2018.88C40.8683%2018.0399%2040.9872%2017.1998%2040.9872%2016.3602C40.9872%2010.6403%2036.3885%206.35998%2031.0763%206.35998C30.0062%206.35998%2028.9754%206.51979%2027.9446%206.88001C26.1604%205.11992%2023.7025%204%2021.0069%204C16.2101%204%2012.2064%207.4398%2011.2943%2012C6.8543%2013.1601%204%2017.3601%204%2021.6399C4%2024.4401%205.18916%2027.1599%207.32995%2029.1199C7.13174%2029.96%207.01277%2030.8001%207.01277%2031.6398C7.01277%2037.3597%2011.6114%2041.6399%2016.9236%2041.6399C17.9938%2041.6399%2019.0246%2041.4801%2020.0554%2041.1199C21.8392%2042.88%2024.2971%2044%2026.993%2044Z'%20fill='black'/%3e%3c/svg%3e",Z0="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%3e%3cpath%20fill='%234285F4'%20d='M14.9%208.161c0-.476-.039-.954-.121-1.422h-6.64v2.695h3.802a3.24%203.24%200%2001-1.407%202.127v1.75h2.269c1.332-1.22%202.097-3.02%202.097-5.15z'/%3e%3cpath%20fill='%2334A853'%20d='M8.14%2015c1.898%200%203.499-.62%204.665-1.69l-2.268-1.749c-.631.427-1.446.669-2.395.669-1.836%200-3.393-1.232-3.952-2.888H1.85v1.803A7.044%207.044%200%20008.14%2015z'/%3e%3cpath%20fill='%23FBBC04'%20d='M4.187%209.342a4.17%204.17%200%20010-2.68V4.859H1.849a6.97%206.97%200%20000%206.286l2.338-1.803z'/%3e%3cpath%20fill='%23EA4335'%20d='M8.14%203.77a3.837%203.837%200%20012.7%201.05l2.01-1.999a6.786%206.786%200%2000-4.71-1.82%207.042%207.042%200%2000-6.29%203.858L4.186%206.66c.556-1.658%202.116-2.89%203.952-2.89z'/%3e%3c/svg%3e",Et="/agents/assets/img/meta.svg",K0="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M17.8962%2017.7465V14.9519C18.1789%2014.9346%2018.4615%2014.9174%2018.7442%2014.9174C26.5881%2014.6758%2031.7291%2021.5072%2031.7291%2021.5072C31.7291%2021.5072%2026.1818%2029.0287%2020.2282%2029.0287C19.4332%2029.0287%2018.6559%2028.9079%2017.9139%2028.6664V20.1789C20.9702%2020.5412%2021.5885%2021.8523%2023.4082%2024.8367L27.4891%2021.49C27.4891%2021.49%2024.5035%2017.6775%2019.4862%2017.6775C18.9562%2017.6603%2018.4262%2017.6948%2017.8962%2017.7465ZM17.8962%208.5V12.6747L18.7442%2012.623C29.6445%2012.2607%2036.7641%2021.352%2036.7641%2021.352C36.7641%2021.352%2028.6021%2031.047%2020.1045%2031.047C19.3625%2031.047%2018.6382%2030.978%2017.9139%2030.8573V33.4449C18.5145%2033.5139%2019.1329%2033.5657%2019.7335%2033.5657C27.6481%2033.5657%2033.3721%2029.6152%2038.9194%2024.9574C39.8381%2025.682%2043.601%2027.4243%2044.3784%2028.1834C39.1137%2032.4961%2026.8355%2035.9636%2019.8749%2035.9636C19.2035%2035.9636%2018.5675%2035.9291%2017.9315%2035.86V39.5H48V8.5L17.8962%208.5ZM17.8962%2028.6664V30.8745C10.5823%2029.5979%208.55061%2022.1628%208.55061%2022.1628C8.55061%2022.1628%2012.0662%2018.3676%2017.8962%2017.7465V20.1617H17.8785C14.8222%2019.7994%2012.4196%2022.594%2012.4196%2022.594C12.4196%2022.594%2013.7799%2027.3036%2017.8962%2028.6664ZM4.9113%2021.8523C4.9113%2021.8523%209.2396%2015.6074%2017.9139%2014.9519V12.6747C8.30327%2013.4338%200%2021.3692%200%2021.3692C0%2021.3692%204.6993%2034.6525%2017.8962%2035.86V33.4449C8.21494%2032.2718%204.9113%2021.8523%204.9113%2021.8523Z'%20fill='%2376B900'/%3e%3c/svg%3e",G0="data:image/svg+xml,%3csvg%20version='1.2'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201513%20975'%20width='1513'%20height='975'%3e%3ctitle%3eae99cd49-2667-464e-b9db-b39cee0126e1-svg%3c/title%3e%3cstyle%3e%20.s0%20{%20fill:%20%23ff5a00%20}%20%3c/style%3e%3cg%20id='%23ff5a00ff'%3e%3cpath%20id='Layer'%20class='s0'%20d='m989.5%200h67.8c95.3%205.4%20196.5%2023.1%20272.4%2085.5%2060.6%2049.1%2086.3%20133%2071.4%20208.6-11.4%2056.4-37.4%20108.4-65.4%20158.1-56.8%2098.4-126.6%20188.2-193%20280.1-11.9%2015.2-21.2%2033.8-20%2053.6%201.1%2015.7%2013.1%2028.4%2027.2%2034%2027.3%2011.1%2057.5%208.9%2086.2%207.3%2090.7-9.5%20178.1-37%20264.6-64.6%206.6-4.1%208.8%202.6%2011.3%207.4-91.9%2061.3-190.8%20112.4-294.8%20150-57.5%2019.3-118.3%2037.6-179.6%2030.4-32.2-3.2-64.5-22.4-74.6-54.5-12.5-41.8-7.9-88.1%2010.2-127.6%2027.5-61.7%2070.2-114.7%20110.7-168.2%2067.1-88%20136.4-175.5%20189.1-273.3%2017.4-34.7%2036-76.8%2018.7-115.1-16.3-35.3-51.7-56.1-85.6-71.8-60.2-26.9-124.4-43.1-187.7-61.1q-14.3%209.4-28.5%2019c22%2016.8%2044%2033.6%2065.8%2050.7-83.3%2015-166.3%2031.8-248.3%2052.7-124.9%2031-246.8%2072.5-367.6%20116.5%2011.8%2023.5%2023.5%2047.1%2034.7%2070.9-27.3%2030.2-54.4%2060.7-81.7%2090.9%2065.6%2019.6%20136.3%2022.3%20203.2%207.5%2057.2-12.8%20111-40.2%20154.7-79.3-11.9-14.8-26.9-26.7-43.1-36.5%2053.1%201.1%20101.4%2047.4%20101.5%20101.1q-15.6%200.1-31%200.2c-2.2-11.7-5.3-23-9.4-34.1-60.3%2054.5-138.2%2088.6-218.9%2097.4-71.1%208.2-143.8-1.6-210.7-26.6%204.5%2041.4%209%2082.6%2013.2%20124-38%2014.8-73.3%2036.2-104.9%2062-25.1%2021.9-50%2047.1-59.6%2079.9-9.2%2028.9%205.8%2061.7%2031.1%2077.2%2030.7%2019%2066.5%2027.8%20101.9%2032.9%2046.7%206.1%2093.9%205.6%20140.8%202.3%2092.1-6.8%20183.1-24.1%20272.7-45.8%208.9-3.6%2013.1%2011.1%204%2013.4-71.5%2036.8-146.3%2067.8-224.3%2087.8-73.3%2018.9-148.8%2028.6-224.4%2031.2-77.1-2.4-159-17.3-220.1-67.8-45.4-36.8-69.3-95.2-69.5-153.1v-3.1c1.5-61.2%2022.2-120.4%2052-173.4%2039.2-74.8%2087.5-145%20144.6-207.3%2098.7-108.7%20222.5-192.8%20355.6-253.7%20137.9-62.5%20285.5-107.4%20437.3-115.7z'/%3e%3c/g%3e%3c/svg%3e",X0="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M47.4964%209.43757C46.988%209.19072%2046.769%209.66115%2046.4717%209.90013C46.37%209.97722%2046.284%2010.0774%2046.1979%2010.1699C45.4548%2010.9562%2044.5866%2011.4729%2043.4523%2011.4112C41.794%2011.3186%2040.3781%2011.8353%2039.1265%2013.092C38.8605%2011.5423%2037.9767%2010.617%2036.6312%2010.0234C35.9273%209.71497%2035.2154%209.40651%2034.7226%208.7357C34.3784%208.25783%2034.2845%207.7258%2034.1124%207.20147C34.0029%206.8854%2033.8934%206.56146%2033.5257%206.50747C33.1268%206.44587%2032.9703%206.77725%2032.8138%207.05499C32.1881%208.18844%2031.9456%209.43749%2031.969%2010.7019C32.0237%2013.5471%2033.2363%2015.8137%2035.6455%2017.4252C35.9193%2017.6103%2035.9896%2017.7952%2035.9036%2018.0652C35.7393%2018.6204%2035.5437%2019.16%2035.3717%2019.7151C35.2622%2020.0699%2035.0978%2020.147%2034.7146%2019.9926C33.3926%2019.4453%2032.2505%2018.6357%2031.2414%2017.6566C29.5284%2016.0143%2027.9795%2014.2024%2026.0475%2012.7837C25.5938%2012.4521%2025.1401%2012.1438%2024.6707%2011.8507C22.6994%209.95412%2024.9289%208.39653%2025.4451%208.21163C25.9848%208.01885%2025.6329%207.35566%2023.8884%207.36353C22.144%207.37114%2020.5483%207.94946%2018.5146%208.72047C18.2173%208.83615%2017.9043%208.92086%2017.5836%208.99025C15.7376%208.64338%2013.8211%208.56612%2011.8186%208.78986C8.04819%209.20613%205.03671%2010.9718%202.823%2013.9865C0.16347%2017.6103%20-0.462297%2021.7274%200.304303%2026.0221C1.11002%2030.5478%203.44099%2034.295%207.02367%2037.225C10.7393%2040.2626%2015.0181%2041.7507%2019.8992%2041.4655C22.8639%2041.2959%2026.1649%2040.9027%2029.8884%2037.7801C30.827%2038.2427%2031.8126%2038.4276%2033.4475%2038.5664C34.7069%2038.6821%2035.9194%2038.5048%2036.858%2038.3121C38.3286%2038.0037%2038.227%2036.6544%2037.6951%2036.4077C33.385%2034.4185%2034.3314%2035.228%2033.471%2034.5726C35.6613%2032.0052%2038.9624%2029.3374%2040.253%2020.6942C40.3546%2020.0081%2040.2686%2019.5763%2040.253%2019.0211C40.2451%2018.682%2040.3234%2018.551%2040.7145%2018.5123C41.794%2018.3889%2042.8422%2018.096%2043.8043%2017.5717C46.5969%2016.0606%2047.7233%2013.5779%2047.9892%2010.6017C48.0284%2010.1468%2047.9814%209.67638%2047.4964%209.43757ZM23.1611%2036.2225C18.984%2032.969%2016.9581%2031.8971%2016.1211%2031.9434C15.3388%2031.9897%2015.4797%2032.8764%2015.6517%2033.4547C15.8316%2034.0252%2016.0663%2034.4185%2016.3948%2034.9196C16.6216%2035.2511%2016.7782%2035.7445%2016.168%2036.1147C14.8226%2036.9397%2012.4836%2035.8371%2012.3741%2035.7832C9.65202%2034.1948%207.37571%2032.0975%205.77205%2029.2295C4.22322%2026.4691%203.32373%2023.5086%203.17504%2020.3474C3.13592%2019.5841%203.36276%2019.3141%204.12936%2019.1755C5.13843%2018.9904%206.17884%2018.9517%207.1879%2019.0982C11.4512%2019.7151%2015.0807%2021.6041%2018.1235%2024.5956C19.86%2026.2995%2021.1742%2028.3352%2022.5275%2030.3243C23.9668%2032.4368%2025.5156%2034.4493%2027.4868%2036.0992C28.183%2036.6775%2028.7384%2037.1169%2029.2703%2037.4408C27.6668%2037.6181%2024.9915%2037.6568%2023.1611%2036.2225ZM25.1636%2023.4623C25.1636%2023.123%2025.4374%2022.8532%2025.7817%2022.8532C25.8599%2022.8532%2025.9303%2022.8685%2025.9929%2022.8916C26.079%2022.9225%2026.1572%2022.9688%2026.2198%2023.038C26.3293%2023.1461%2026.3919%2023.3002%2026.3919%2023.4622C26.3919%2023.8014%2026.1181%2024.0712%2025.774%2024.0712C25.4299%2024.0712%2025.1636%2023.8015%2025.1636%2023.4623ZM31.3824%2026.6235C30.9835%2026.7854%2030.5846%2026.9241%2030.2013%2026.9395C29.6068%2026.9703%2028.9575%2026.7313%2028.6056%2026.4383C28.058%2025.9834%2027.6669%2025.7291%2027.5026%2024.9349C27.4322%2024.5956%2027.4713%2024.0713%2027.534%2023.7707C27.6747%2023.123%2027.5183%2022.7067%2027.0568%2022.3288C26.6813%2022.0204%2026.2041%2021.9357%2025.68%2021.9357C25.4844%2021.9357%2025.3046%2021.8508%2025.1716%2021.7814C24.9525%2021.6735%2024.7727%2021.4036%2024.9447%2021.0721C24.9995%2020.9643%2025.2655%2020.702%2025.3281%2020.6558C26.04%2020.2548%2026.8613%2020.3859%2027.6201%2020.6866C28.3242%2020.9719%2028.8561%2021.4962%2029.6226%2022.2363C30.4048%2023.1306%2030.5456%2023.3776%2030.9915%2024.0482C31.3436%2024.5725%2031.6643%2025.1122%2031.8833%2025.7291C32.0162%2026.1146%2031.844%2026.4307%2031.3824%2026.6235Z'%20fill='%234D6BFE'/%3e%3c/svg%3e",Y0="data:image/svg+xml,%3csvg%20version='1.2'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201513%20975'%20width='1513'%20height='975'%3e%3ctitle%3eae99cd49-2667-464e-b9db-b39cee0126e1-svg%3c/title%3e%3cstyle%3e%20.s0%20{%20fill:%20%23ff5a00%20}%20%3c/style%3e%3cg%20id='%23ff5a00ff'%3e%3cpath%20id='Layer'%20class='s0'%20d='m989.5%200h67.8c95.3%205.4%20196.5%2023.1%20272.4%2085.5%2060.6%2049.1%2086.3%20133%2071.4%20208.6-11.4%2056.4-37.4%20108.4-65.4%20158.1-56.8%2098.4-126.6%20188.2-193%20280.1-11.9%2015.2-21.2%2033.8-20%2053.6%201.1%2015.7%2013.1%2028.4%2027.2%2034%2027.3%2011.1%2057.5%208.9%2086.2%207.3%2090.7-9.5%20178.1-37%20264.6-64.6%206.6-4.1%208.8%202.6%2011.3%207.4-91.9%2061.3-190.8%20112.4-294.8%20150-57.5%2019.3-118.3%2037.6-179.6%2030.4-32.2-3.2-64.5-22.4-74.6-54.5-12.5-41.8-7.9-88.1%2010.2-127.6%2027.5-61.7%2070.2-114.7%20110.7-168.2%2067.1-88%20136.4-175.5%20189.1-273.3%2017.4-34.7%2036-76.8%2018.7-115.1-16.3-35.3-51.7-56.1-85.6-71.8-60.2-26.9-124.4-43.1-187.7-61.1q-14.3%209.4-28.5%2019c22%2016.8%2044%2033.6%2065.8%2050.7-83.3%2015-166.3%2031.8-248.3%2052.7-124.9%2031-246.8%2072.5-367.6%20116.5%2011.8%2023.5%2023.5%2047.1%2034.7%2070.9-27.3%2030.2-54.4%2060.7-81.7%2090.9%2065.6%2019.6%20136.3%2022.3%20203.2%207.5%2057.2-12.8%20111-40.2%20154.7-79.3-11.9-14.8-26.9-26.7-43.1-36.5%2053.1%201.1%20101.4%2047.4%20101.5%20101.1q-15.6%200.1-31%200.2c-2.2-11.7-5.3-23-9.4-34.1-60.3%2054.5-138.2%2088.6-218.9%2097.4-71.1%208.2-143.8-1.6-210.7-26.6%204.5%2041.4%209%2082.6%2013.2%20124-38%2014.8-73.3%2036.2-104.9%2062-25.1%2021.9-50%2047.1-59.6%2079.9-9.2%2028.9%205.8%2061.7%2031.1%2077.2%2030.7%2019%2066.5%2027.8%20101.9%2032.9%2046.7%206.1%2093.9%205.6%20140.8%202.3%2092.1-6.8%20183.1-24.1%20272.7-45.8%208.9-3.6%2013.1%2011.1%204%2013.4-71.5%2036.8-146.3%2067.8-224.3%2087.8-73.3%2018.9-148.8%2028.6-224.4%2031.2-77.1-2.4-159-17.3-220.1-67.8-45.4-36.8-69.3-95.2-69.5-153.1v-3.1c1.5-61.2%2022.2-120.4%2052-173.4%2039.2-74.8%2087.5-145%20144.6-207.3%2098.7-108.7%20222.5-192.8%20355.6-253.7%20137.9-62.5%20285.5-107.4%20437.3-115.7z'/%3e%3c/g%3e%3c/svg%3e",Q0="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBmaWxsPSJub25lIj4KICA8cmVjdCB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIGZpbGw9IiNGRjZCNkIiLz4KICA8dGV4dCB4PSI1MCUiIHk9IjUwJSIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZmlsbD0id2hpdGUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZm9udC13ZWlnaHQ9ImJvbGQiPk1NPC90ZXh0Pgo8L3N2Zz4=",e2="/agents/assets/img/moonshotai.svg",t2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3crect%20width='48'%20height='48'%20fill='black'/%3e%3cpath%20d='M10.008%2019.311L24.0672%2040H30.3165L16.2557%2019.311H10.008ZM16.2509%2030.8017L10%2040H16.2541L19.3771%2035.4017L16.2509%2030.8017ZM31.7459%208L20.941%2023.8993L24.0672%2028.5009L38%208H31.7459ZM32.8777%2017.8382V40H38V10.3008L32.8777%2017.8382Z'%20fill='white'/%3e%3c/svg%3e",o2="/agents/assets/img/zai.svg",a2="/agents/assets/img/zai.svg",l2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBmaWxsPSJub25lIj4KICA8cmVjdCB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIGZpbGw9IiNBOEU2QTMiLz4KICA8dGV4dCB4PSI1MCUiIHk9IjUwJSIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZmlsbD0iIzJDM0U1MCIgZm9udC1mYW1pbHk9IkFyaWFsLCBzYW5zLXNlcmlmIiBmb250LXNpemU9IjE0IiBmb250LXdlaWdodD0iYm9sZCI+RVhBPC90ZXh0Pgo8L3N2Zz4=",Yt="data:image/svg+xml,%3csvg%20fill='currentColor'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eOpenRouter%3c/title%3e%3cpath%20d='M16.804%201.957l7.22%204.105v.087L16.73%2010.21l.017-2.117-.821-.03c-1.059-.028-1.611.002-2.268.11-1.064.175-2.038.577-3.147%201.352L8.345%2011.03c-.284.195-.495.336-.68.455l-.515.322-.397.234.385.23.53.338c.476.314%201.17.796%202.701%201.866%201.11.775%202.083%201.177%203.147%201.352l.3.045c.694.091%201.375.094%202.825.033l.022-2.159%207.22%204.105v.087L16.589%2022l.014-1.862-.635.022c-1.386.042-2.137.002-3.138-.162-1.694-.28-3.26-.926-4.881-2.059l-2.158-1.5a21.997%2021.997%200%2000-.755-.498l-.467-.28a55.927%2055.927%200%2000-.76-.43C2.908%2014.73.563%2014.116%200%2014.116V9.888l.14.004c.564-.007%202.91-.622%203.809-1.124l1.016-.58.438-.274c.428-.28%201.072-.726%202.686-1.853%201.621-1.133%203.186-1.78%204.881-2.059%201.152-.19%201.974-.213%203.814-.138l.02-1.907z'%3e%3c/path%3e%3c/svg%3e";function s2(t){const i=Ge();return i==="/"?t.replace("/agents/","/"):t.replace("/agents/",`${i}/`)}const n2={anthropic:J0,openai:ft,"openai-sdk":ft,google:Z0,meta:Et,"meta-llama":Et,nvidia:K0,alibaba:G0,deepseek:X0,qwen:Y0,minimax:Q0,moonshotai:e2,"x-ai":t2,"z-ai":o2,zai:a2,exaone:l2,openrouter:Yt},r2=new Proxy(n2,{get(t,i){const s=t[i];return s?s2(s):void 0}});function i2(t){if(t&&t.includes("/"))return t.split("/")[0].toLowerCase()}function at(t){return r2[t.toLowerCase()]}function We(t,i){const s=i2(t);if(s){const c=at(s);if(c)return c}if(i)return at(i)}const d2={class:"space-y-4"},u2=se({__name:"PromptModelSelect",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:i}){const s=i,c=v([]),a=v(!1),u=z(()=>c.value.map(p=>({value:p.id,label:p.name,description:p.model||p.provider,icon:We(p.model||p.name,p.provider_id||p.provider)}))),r=async()=>{a.value=!0;try{const p=await fetch(te("/api/models"));if(p.ok){const f=await p.json();c.value=f.models||[]}}catch(p){console.error("Error fetching models:",p)}finally{a.value=!1}};return ye(()=>{r()}),(p,f)=>(o(),l("div",d2,[I(ge,{"model-value":t.modelValue,"onUpdate:modelValue":f[0]||(f[0]=b=>s("update:modelValue",b)),options:u.value,label:"Model",placeholder:"Select a model for this prompt","search-placeholder":"Search models...",loading:a.value},null,8,["model-value","options","loading"])]))}}),c2=["data-property-id","data-nested-property-id"],p2={class:"p-3 space-y-3"},m2={class:"flex items-start gap-2"},v2={key:0,class:"drag-handle cursor-move text-neutral-400 hover:text-neutral-600 dark:text-neutral-600 dark:hover:text-neutral-400 mt-2"},f2={class:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2"},h2={class:"flex items-center gap-2 mt-2"},g2=["disabled"],b2={key:0,class:"ml-6"},x2={key:0,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg space-y-2"},y2={class:"flex items-center justify-between mb-2"},k2=["disabled"],w2={key:0,class:"space-y-1"},_2=["onClick","disabled"],$2={key:1,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},C2={class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"},V2={class:"space-y-2"},S2={class:"flex items-center justify-between"},T2=["disabled"],M2={class:"space-y-2"},I2={key:2,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},L2={key:0,class:"mb-2"},E2=["disabled"],A2={key:1,class:"space-y-2"},P2=se({__name:"PropertyEditor",props:Oe({propertyId:{},isNested:{type:Boolean,default:!1},parentId:{},disabled:{type:Boolean,default:!1},enableDrag:{type:Boolean,default:!0}},{modelValue:{required:!0},modelModifiers:{}}),emits:Oe(["remove","description-keydown","add-top-level"],["update:modelValue"]),setup(t,{emit:i}){const s=t,c=i,a=qe(t,"modelValue"),u=v(!1);v();const r=[{value:"string",label:"String",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z'/%3E%3C/svg%3E"},{value:"number",label:"Number",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M7 20l4-16m2 16l4-16M6 9h14M4 15h14'/%3E%3C/svg%3E"},{value:"boolean",label:"Boolean",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z'/%3E%3C/svg%3E"},{value:"object",label:"Object",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10'/%3E%3C/svg%3E"},{value:"array",label:"Array",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 6h16M4 10h16M4 14h16M4 18h16'/%3E%3C/svg%3E"},{value:"enum",label:"Enum",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4'/%3E%3C/svg%3E"},{value:"anyOf",label:"Any Of (Multiple Types)",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E"}],p=z(()=>["object","array","enum","anyOf"].includes(a.value.type));ie(()=>a.value.type,async(g,m)=>{if(["object","array","enum","anyOf"].includes(g)&&(u.value=!0,g==="anyOf"&&!a.value.anyOf&&(a.value.anyOf=[]),g==="object"&&!a.value.properties&&(a.value.properties=[{id:crypto.randomUUID(),name:"property1",type:"string",description:""}]),g==="array"&&!a.value.items&&(a.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""}),g==="enum"&&!a.value.enum&&(a.value.enum=["value1"])),m!==void 0){await xe();const C=s.isNested?`[data-nested-property-id="${s.propertyId}"] input[placeholder="Description"]`:`[data-property-id="${s.propertyId}"] input[placeholder="Description"]`,w=document.querySelector(C);w&&w.focus()}});const f=g=>{g.shiftKey&&a.value.type==="object"&&a.value.properties?h():c("add-top-level")},b=()=>{a.value.items||(a.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""})},n=()=>{a.value.enum||(a.value.enum=[]),a.value.enum.push(`value${a.value.enum.length+1}`)},d=g=>{a.value.enum&&a.value.enum.splice(g,1)},h=async()=>{const g={id:crypto.randomUUID(),name:a.value.type==="anyOf"?"":`property${(a.value.properties?.length||a.value.anyOf?.length||0)+1}`,type:"string",description:""};a.value.type==="anyOf"?(a.value.anyOf||(a.value.anyOf=[]),a.value.anyOf.push(g)):(a.value.properties||(a.value.properties=[]),a.value.properties.push(g)),await xe();const m=document.querySelector(`[data-nested-property-id="${g.id}"] input[placeholder="Property name"]`);m&&(m.focus(),m.select())},$=g=>{a.value.type==="anyOf"&&a.value.anyOf?a.value.anyOf=a.value.anyOf.filter(m=>m.id!==g):a.value.properties&&(a.value.properties=a.value.properties.filter(m=>m.id!==g))};return(g,m)=>{const C=_o("PropertyEditor",!0);return o(),l("div",{"data-property-id":t.isNested?void 0:t.propertyId,"data-nested-property-id":t.isNested?t.propertyId:void 0,class:oe(["border rounded-lg",t.isNested?"border-neutral-100 dark:border-neutral-900":"border-neutral-200 dark:border-neutral-800"])},[e("div",p2,[e("div",m2,[t.enableDrag?(o(),l("div",v2,[...m[10]||(m[10]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8h16M4 16h16"})],-1)])])):M("",!0),e("div",f2,[I(Ce,{modelValue:a.value.name,"onUpdate:modelValue":m[0]||(m[0]=w=>a.value.name=w),placeholder:"Property name",disabled:t.disabled},null,8,["modelValue","disabled"]),I(ge,{modelValue:a.value.type,"onUpdate:modelValue":m[1]||(m[1]=w=>a.value.type=w),options:r,disabled:t.disabled},null,8,["modelValue","disabled"]),I(Ce,{modelValue:a.value.description,"onUpdate:modelValue":m[2]||(m[2]=w=>a.value.description=w),placeholder:"Description",disabled:t.disabled,onKeydown:m[3]||(m[3]=pt(Te(w=>f(w),["prevent"]),["enter"]))},null,8,["modelValue","disabled"])]),e("div",h2,[p.value?(o(),l("button",{key:0,onClick:m[4]||(m[4]=w=>u.value=!u.value),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors"},[(o(),l("svg",{class:oe(["w-4 h-4 transition-transform",u.value?"rotate-90":""]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...m[11]||(m[11]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))])):M("",!0),e("button",{onClick:m[5]||(m[5]=w=>g.$emit("remove")),type:"button",disabled:t.disabled,class:"p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors disabled:opacity-50"},[...m[12]||(m[12]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,g2)])]),u.value&&p.value?(o(),l("div",b2,[a.value.type==="enum"?(o(),l("div",x2,[e("div",y2,[m[13]||(m[13]=e("h4",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400"}," Enum Values ",-1)),e("button",{onClick:n,type:"button",disabled:t.disabled,class:"px-2 py-0.5 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"}," Add Value ",8,k2)]),a.value.enum?(o(),l("div",w2,[(o(!0),l(ce,null,fe(a.value.enum,(w,E)=>(o(),l("div",{key:E,class:"flex items-center gap-2"},[I(Ce,{modelValue:a.value.enum[E],"onUpdate:modelValue":A=>a.value.enum[E]=A,placeholder:"Enum value",disabled:t.disabled,class:"flex-1"},null,8,["modelValue","onUpdate:modelValue","disabled"]),e("button",{onClick:A=>d(E),type:"button",disabled:t.disabled,class:"p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors disabled:opacity-50"},[...m[14]||(m[14]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,_2)]))),128))])):M("",!0)])):M("",!0),a.value.type==="object"||a.value.type==="anyOf"?(o(),l("div",$2,[e("h4",C2,V(a.value.type==="anyOf"?"Type Options":"Nested Properties"),1),e("div",V2,[e("div",S2,[e("button",{onClick:h,type:"button",disabled:t.disabled,class:"px-2 py-0.5 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"}," Add "+V(a.value.type==="anyOf"?"Type Option":"Property"),9,T2)]),e("div",M2,[(o(!0),l(ce,null,fe(a.value.type==="anyOf"?a.value.anyOf:a.value.properties,(w,E)=>(o(),Q(C,{key:w.id,modelValue:(a.value.type==="anyOf"?a.value.anyOf:a.value.properties)[E],"onUpdate:modelValue":A=>(a.value.type==="anyOf"?a.value.anyOf:a.value.properties)[E]=A,"property-id":w.id,"is-nested":!0,"parent-id":t.propertyId,disabled:t.disabled,"enable-drag":!1,onRemove:A=>$(w.id),onAddTopLevel:m[6]||(m[6]=A=>c("add-top-level"))},null,8,["modelValue","onUpdate:modelValue","property-id","parent-id","disabled","onRemove"]))),128))])])])):M("",!0),a.value.type==="array"?(o(),l("div",I2,[m[15]||(m[15]=e("h4",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Array Item Type ",-1)),a.value.items?M("",!0):(o(),l("div",L2,[e("button",{onClick:b,type:"button",disabled:t.disabled,class:"px-2 py-0.5 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"}," Define Item Type ",8,E2)])),a.value.items?(o(),l("div",A2,[I(C,{modelValue:a.value.items,"onUpdate:modelValue":m[7]||(m[7]=w=>a.value.items=w),"property-id":a.value.items.id,"is-nested":!0,"parent-id":t.propertyId,disabled:t.disabled,"enable-drag":!1,onRemove:m[8]||(m[8]=w=>a.value.items=null),onAddTopLevel:m[9]||(m[9]=w=>c("add-top-level"))},null,8,["modelValue","property-id","parent-id","disabled"])])):M("",!0)])):M("",!0)])):M("",!0)])],10,c2)}}}),O2={class:"space-y-2"},j2=["disabled"],D2=se({__name:"PropertyList",props:Oe({disabled:{type:Boolean,default:!1},parentId:{},isNested:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:Oe(["add-property","description-keydown"],["update:modelValue"]),setup(t,{expose:i,emit:s}){const c=t,a=s,u=qe(t,"modelValue"),r=v();let p=!1;ye(async()=>{}),je(()=>{});const f=async()=>{if(p)return;p=!0;const n={id:crypto.randomUUID(),name:`property${u.value.length+1}`,type:"string",description:"",required:!1};u.value=[...u.value,n],await xe();const d=c.parentId?`[data-nested-property-id="${n.id}"]`:`[data-property-id="${n.id}"]`,h=document.querySelector(`${d} input[placeholder="Property name"]`);h&&(h.focus(),h.select()),a("add-property"),p=!1},b=n=>{u.value=u.value.filter(d=>d.id!==n)};return i({addProperty:f}),(n,d)=>(o(),l("div",O2,[e("div",{ref_key:"dragAreaRef",ref:r,class:"space-y-2"},[(o(!0),l(ce,null,fe(u.value,h=>(o(),Q(P2,{key:h.id,modelValue:u.value[u.value.indexOf(h)],"onUpdate:modelValue":$=>u.value[u.value.indexOf(h)]=$,"property-id":h.id,"is-nested":t.isNested,"parent-id":t.parentId,disabled:t.disabled,"enable-drag":!t.isNested,onRemove:$=>b(h.id),onAddTopLevel:d[0]||(d[0]=$=>n.$emit("add-property"))},null,8,["modelValue","onUpdate:modelValue","property-id","is-nested","parent-id","disabled","enable-drag","onRemove"]))),128))],512),e("div",{class:oe(t.isNested?"mt-2":"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-800")},[e("button",{onClick:f,type:"button",disabled:t.disabled,class:oe(t.isNested?"px-2 py-1 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50":"w-full px-3 py-2 text-sm bg-neutral-50 dark:bg-neutral-900 hover:bg-neutral-100 dark:hover:bg-neutral-800 text-neutral-700 dark:text-neutral-300 rounded transition-colors disabled:opacity-50 border border-dashed border-neutral-300 dark:border-neutral-700")},[...d[1]||(d[1]=[e("span",{class:"flex items-center justify-center gap-2"},[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})]),ke(" Add Property ")],-1)])],10,j2)],2)]))}}),U2={class:"space-y-4"},N2={key:0,class:"flex items-center justify-between"},R2={class:"text-sm font-medium"},B2={key:0,class:"text-red-500"},q2={class:"space-y-2 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4"},F2={key:0,class:"flex items-center justify-between mb-2"},z2={key:1,class:"text-center py-12"},H2=["disabled"],W2={class:"mt-4 text-center"},J2={key:3,class:"mt-4"},Z2={class:"bg-neutral-50 dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4 overflow-x-auto"},K2={class:"text-xs leading-relaxed"},G2=["innerHTML"],Qt=se({__name:"JSONSchemaInput",props:Oe({label:{},disabled:{type:Boolean,default:!1},required:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>({type:"object",properties:{},required:[]})},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const i=qe(t,"modelValue"),s=v([]),c=v(),a=v(!1),u=()=>{if(i.value?.properties){const g=[];i.value.required;for(const[m,C]of Object.entries(i.value.properties)){const w=C,E={id:crypto.randomUUID(),name:m,type:w.type||"string",description:w.description||""};w.enum&&(E.enum=w.enum),w.anyOf&&(E.type="anyOf",E.anyOf=r(w.anyOf)),w.type==="array"&&w.items&&(E.items=p(w.items)),w.type==="object"&&w.properties&&(E.properties=f(w.properties,w.required||[])),g.push(E)}s.value=g}},r=g=>g.map(m=>typeof m=="object"&&m.type?{id:crypto.randomUUID(),name:"",type:m.type,description:m.description||"",properties:m.properties?f(m.properties,m.required||[]):void 0,items:m.items?p(m.items):void 0,enum:m.enum}:{id:crypto.randomUUID(),name:"",type:"string",description:""}),p=g=>{const m={id:crypto.randomUUID(),name:"",type:g.type||"string",description:g.description||""};return g.enum&&(m.enum=g.enum),g.anyOf&&(m.type="anyOf",m.anyOf=r(g.anyOf)),g.type==="array"&&g.items&&(m.items=p(g.items)),g.type==="object"&&g.properties&&(m.properties=f(g.properties,g.required||[])),m},f=(g,m)=>{const C=[];for(const[w,E]of Object.entries(g)){const A=E,q={id:crypto.randomUUID(),name:w,type:A.type||"string",description:A.description||""};A.enum&&(q.enum=A.enum),A.anyOf&&(q.type="anyOf",q.anyOf=r(A.anyOf)),A.type==="array"&&A.items&&(q.items=p(A.items)),A.type==="object"&&A.properties&&(q.properties=f(A.properties,A.required||[])),C.push(q)}return C};u();const b=()=>{const g={type:"object",properties:{},required:[],additionalProperties:!1},{properties:m}=d(s.value);g.properties=m,g.required=Object.keys(m),i.value=g},n=g=>{const m={type:g.type==="anyOf"?void 0:g.type,description:g.description};if(g.type==="enum"&&g.enum&&(m.enum=g.enum,m.type="string"),g.type==="anyOf"&&g.anyOf&&(delete m.type,m.anyOf=g.anyOf.map(n)),g.type==="object"&&g.properties){const{properties:C}=d(g.properties);m.properties=C,m.required=Object.keys(C),m.additionalProperties=!1}return g.type==="array"&&g.items&&(m.items=n(g.items)),m},d=g=>{const m={},C=[];for(const w of g){const E={type:w.type==="anyOf"?void 0:w.type,description:w.description};if(C.push(w.name),w.type==="enum"&&w.enum&&(E.enum=w.enum,E.type="string"),w.type==="anyOf"&&w.anyOf&&w.anyOf.length>0&&(delete E.type,E.anyOf=w.anyOf.map(n)),w.type==="array"&&w.items&&(E.items=n(w.items)),w.type==="object"&&w.properties){const{properties:A}=d(w.properties);E.properties=A,E.required=Object.keys(A),E.additionalProperties=!1}m[w.name]=E}return{properties:m,required:C}};ie(s,()=>{b()},{deep:!0}),b();const h=z(()=>JSON.stringify(i.value,null,2).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"([^"]+)":/g,'<span class="text-blue-600 dark:text-blue-400">"$1"</span>:').replace(/:"([^"]*)"/g,':<span class="text-green-600 dark:text-green-400">"$1"</span>').replace(/:(\d+)/g,':<span class="text-yellow-600 dark:text-yellow-400">$1</span>').replace(/:(true|false)/g,':<span class="text-purple-600 dark:text-purple-400">$1</span>').replace(/:(null)/g,':<span class="text-red-600 dark:text-red-400">$1</span>')),$=async()=>{if(s.value.length===0){const g={id:crypto.randomUUID(),name:"property1",type:"string",description:""};s.value.push(g),await xe();const m=document.querySelector(`[data-property-id="${g.id}"] input[placeholder="Property name"]`);m&&(m.focus(),m.select())}else c.value&&c.value.addProperty()};return(g,m)=>(o(),l("div",U2,[t.label?(o(),l("div",N2,[e("label",R2,[ke(V(t.label)+" ",1),t.required?(o(),l("span",B2,"*")):M("",!0)])])):M("",!0),e("div",q2,[s.value.length>0?(o(),l("div",F2,[...m[2]||(m[2]=[e("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Properties ",-1)])])):M("",!0),s.value.length===0?(o(),l("div",z2,[m[4]||(m[4]=e("div",{class:"mb-4"},[e("svg",{class:"w-12 h-12 mx-auto text-neutral-400 dark:text-neutral-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})])],-1)),m[5]||(m[5]=e("p",{class:"text-neutral-500 dark:text-neutral-400 text-sm mb-4"}," No properties defined ",-1)),e("button",{onClick:$,type:"button",disabled:t.disabled,class:"px-4 py-2 bg-black dark:bg-white text-white dark:text-black rounded hover:bg-neutral-800 dark:hover:bg-neutral-200 transition-colors disabled:opacity-50 font-medium text-sm"},[...m[3]||(m[3]=[e("span",{class:"flex items-center gap-2"},[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})]),ke(" Add Property ")],-1)])],8,H2)])):M("",!0),s.value.length>0?(o(),Q(D2,{key:2,ref_key:"propertyListRef",ref:c,modelValue:s.value,"onUpdate:modelValue":m[0]||(m[0]=C=>s.value=C),disabled:t.disabled,onAddProperty:$},null,8,["modelValue","disabled"])):M("",!0),e("div",W2,[e("button",{onClick:m[1]||(m[1]=C=>a.value=!a.value),type:"button",class:"text-xs text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-100 hover:underline transition-colors"},V(a.value?"Hide":"Show")+" JSON Schema ",1)]),a.value?(o(),l("div",J2,[e("div",Z2,[e("pre",K2,[e("code",{class:"font-mono",innerHTML:h.value},null,8,G2)])])])):M("",!0)])]))}}),X2={class:"prompt-input-container relative"},Y2=["contenteditable","data-placeholder"],Q2={class:"bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded-lg overflow-hidden min-w-[240px] max-w-[320px]"},ep={key:0,class:"p-3 text-sm text-neutral-500"},tp={key:1,class:"p-3 text-sm text-neutral-500"},op={key:2,class:"max-h-[220px] overflow-y-auto"},ap=["onClick"],lp={class:"font-medium flex items-center gap-2"},sp=["title"],np={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},rp={key:1,class:"text-xs text-red-600 dark:text-red-400 mt-1"},ip={class:"text-xs mt-1"},dp=se({__name:"PromptInput",props:{modelValue:{},search:{},placeholder:{default:"Type @ to insert variables or prompts..."},disabled:{type:Boolean,default:!1},maxLength:{},allowedTypes:{default:()=>["variable","prompt"]}},emits:["update:modelValue","segment-click"],setup(t,{emit:i}){const s=t,c=i,a=v(),u=v(),r=$o({segments:s.modelValue&&s.modelValue.length?s.modelValue:[{type:"string",value:""}],dialogOpen:!1,dialogPosition:{x:0,y:0},searchQuery:"",searchResults:[],selectedIndex:0,isSearching:!1,atTriggerIndex:-1,isComposing:!1,ignoreNextWatch:!1}),p=()=>Math.random().toString(36).slice(2)+Date.now().toString(36),f=L=>L.type==="string"?"":`@${L.type==="variable"?L.label||L.value:L.label||L.id}`,b=()=>{const L=window.getSelection();if(!L||!L.rangeCount||!a.value)return null;const T=L.getRangeAt(0);let j=0;const S=Array.from(a.value.childNodes);for(let x=0;x<S.length;x++){const y=S[x];if(y===T.startContainer||y.contains?.(T.startContainer)){if(y.nodeType===Node.TEXT_NODE)return{segmentIndex:j,offset:T.startOffset};if(y.nodeType===Node.ELEMENT_NODE&&y.classList?.contains("prompt-tag"))return{segmentIndex:j,offset:0}}(y.nodeType===Node.TEXT_NODE||y.nodeType===Node.ELEMENT_NODE&&y.classList?.contains("prompt-tag"))&&j++}return{segmentIndex:0,offset:0}},n=()=>{if(!a.value)return;const L=r.segments.map(T=>{if(T.type==="string")return(T.value||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")||"";{const j=T._uid||(T._uid=p()),S=f(T),x=T.type==="variable"?{type:"variable",value:T.value,label:T.label,schema:T.schema,meta:T.meta}:{type:"prompt",id:T.id,label:T.label,schema:T.schema,meta:T.meta},y=encodeURIComponent(JSON.stringify(x)),k=T.type==="prompt"&&T.meta&&!T.meta.isValid,R=k?'<span class="prompt-tag-warning" title="'+(T.meta.validationMessage||"").replace(/"/g,"&quot;")+'">⚠️</span>':"";return`<span class="prompt-tag prompt-tag-clickable${k?" prompt-tag-invalid":""}" contenteditable="false" data-segment-uid="${j}" data-segment="${y}">${S}${R}</span>`}}).join("");a.value.innerHTML=L||"<br>"},d=()=>{const L=[];for(const T of r.segments)T.type==="string"&&L.length>0&&L[L.length-1].type==="string"?L[L.length-1].value+=T.value:L.push(T);r.segments=L.length?L:[{type:"string",value:""}]},h=L=>{const T=L.dataset.segmentUid;let j=r.segments.find(S=>S._uid===T);if(!j){const S=L.dataset.segment;if(S)try{const x=JSON.parse(decodeURIComponent(S));x&&(x.type==="variable"||x.type==="prompt")&&(j=x.type==="variable"?{type:"variable",value:x.value,label:x.label,schema:x.schema,meta:x.meta,_uid:T}:{type:"prompt",id:x.id,label:x.label,schema:x.schema,meta:x.meta,_uid:T})}catch{}}return j||null},$=L=>{const T=L.target;if(T.classList?.contains("prompt-tag")){const j=h(T);j&&c("segment-click",j,L)}},g=L=>{if(r.isComposing)return;const T=L.target,j=[];let S="";const x=()=>{S.length>0&&(j.push({type:"string",value:S}),S="")},y=H=>{if(H.nodeType===Node.TEXT_NODE){const W=(H.textContent||"").replace(/\u00A0/g," ");S+=W;return}if(H.nodeType===Node.ELEMENT_NODE){const W=H;if(W.classList?.contains("prompt-tag")){x();const ue=h(W);ue&&j.push(ue);return}if(W.tagName==="BR"){S+=`
9
- `;return}const G=Array.from(W.childNodes);for(const ue of G)y(ue);(W.tagName==="DIV"||W.tagName==="P"||W.tagName==="LI")&&W.nextSibling&&(S+=`
10
- `);return}},k=Array.from(T.childNodes);for(const H of k)y(H);x();const K=j.some(H=>H.type!=="string")?j:[{type:"string",value:(T.innerText||"").replace(/\r\n/g,`
11
- `)}];r.segments=K.length?K:[{type:"string",value:""}],d(),m(),D()},m=()=>{const L=window.getSelection();if(!L||!L.rangeCount||!a.value)return;const T=L.getRangeAt(0);if(T.startContainer.nodeType!==Node.TEXT_NODE){r.dialogOpen&&w();return}const S=T.startContainer.textContent||"",x=T.startOffset;if(x>0&&S[x-1]==="@")r.atTriggerIndex=x-1,r.searchQuery="",C(),q("");else if(r.dialogOpen&&r.atTriggerIndex>=0)if(T.startContainer.nodeType===Node.TEXT_NODE){const y=T.startContainer.textContent||"",k=T.startOffset;if(k<=r.atTriggerIndex){w();return}const R=y.substring(0,k);if(R.length>r.atTriggerIndex&&R[r.atTriggerIndex]==="@"){const K=R.substring(r.atTriggerIndex+1);K.includes(" ")||K.includes(`
12
- `)||K.length>r.searchQuery.length+5?w():(r.searchQuery=K,q(K))}else w()}else w()},C=async()=>{r.dialogOpen=!0,r.selectedIndex=0,await xe(),E()},w=()=>{r.dialogOpen=!1,r.searchResults=[],r.searchQuery="",r.atTriggerIndex=-1,r.isSearching=!1},E=()=>{if(!u.value||!a.value)return;const L=window.getSelection();if(!L||!L.rangeCount)return;const j=L.getRangeAt(0).getBoundingClientRect(),S=a.value.getBoundingClientRect();r.dialogPosition={x:j.left-S.left,y:j.bottom-S.top+4}};let A=null;const q=async L=>{if(!s.search){r.searchResults=[];return}A&&clearTimeout(A),r.isSearching=!0,A=setTimeout(async()=>{try{const T=await s.search(L);r.searchResults=(T||[]).filter(j=>s.allowedTypes?.includes(j.type))}catch(T){console.error("Search error:",T),r.searchResults=[]}finally{r.isSearching=!1}},200)},J=L=>L.type==="variable"?{type:"variable",value:L.value??L.id??"",label:L.label,schema:L.schema,_uid:p(),meta:L.meta}:{type:"prompt",id:L.id??L.value??"",label:L.label,schema:L.schema,_uid:p(),meta:L.meta},X=L=>{if(r.atTriggerIndex<0||!a.value)return;const T=window.getSelection();if(!T||!T.rangeCount)return;const j=T.getRangeAt(0);if(j.startContainer.nodeType!==Node.TEXT_NODE)return;const S=j.startContainer,x=S.data.slice(0,r.atTriggerIndex),y=S.data.slice(j.startOffset),k=document.createElement("span"),R=J(L),K=R.type==="prompt"&&R.meta&&!R.meta.isValid;k.className=`prompt-tag${K?" prompt-tag-invalid":""}`,k.setAttribute("contenteditable","false");const H=R._uid||(R._uid=p());k.dataset.segmentUid=H;const W=R.type==="variable"?{type:"variable",value:R.value,label:R.label,schema:R.schema}:{type:"prompt",id:R.id,label:R.label,schema:R.schema};if(k.dataset.segment=encodeURIComponent(JSON.stringify(W)),k.textContent=f(R),K){const ee=document.createElement("span");ee.className="prompt-tag-warning",ee.textContent="⚠️",ee.setAttribute("title",R.meta.validationMessage||"Validation error"),k.appendChild(ee)}const G=S.parentNode,ue=document.createTextNode(y),he=document.createTextNode(x);G.insertBefore(he,S),G.insertBefore(k,S),G.insertBefore(ue,S),G.removeChild(S),w(),g({target:a.value});const Z=window.getSelection();if(Z){const ee=document.createRange();ee.setStart(ue,0),ee.collapse(!0),Z.removeAllRanges(),Z.addRange(ee)}a.value.focus()},P=L=>{if((L.key==="ArrowLeft"||L.key==="ArrowRight")&&setTimeout(()=>m(),0),r.dialogOpen)L.key==="ArrowDown"?(L.preventDefault(),r.selectedIndex=Math.min(r.selectedIndex+1,r.searchResults.length-1)):L.key==="ArrowUp"?(L.preventDefault(),r.selectedIndex=Math.max(r.selectedIndex-1,0)):L.key==="Enter"?(L.preventDefault(),r.searchResults[r.selectedIndex]&&X(r.searchResults[r.selectedIndex])):(L.key==="Escape"||L.key==="Esc")&&(L.preventDefault(),w());else if(L.key==="Backspace"||L.key==="Delete"){const T=b();if(L.key==="Backspace"){const j=window.getSelection();if(j&&j.rangeCount){const S=j.getRangeAt(0);if(S.collapsed&&S.startContainer.nodeType===Node.TEXT_NODE&&S.startOffset===0){let x=S.startContainer;for(;x&&x!==a.value;){const y=x.previousSibling;if(y&&y.nodeType===Node.ELEMENT_NODE&&y.classList?.contains("prompt-tag")){L.preventDefault(),y.parentNode?.removeChild(y),g({target:a.value});return}x=x.parentNode}}}}if(!T)return;if(L.key==="Backspace"&&T.offset===0&&T.segmentIndex>0)r.segments[T.segmentIndex-1].type!=="string"&&(L.preventDefault(),r.segments.splice(T.segmentIndex-1,1),d(),D(),n());else if(L.key==="Delete"&&T.segmentIndex<r.segments.length-1){const j=r.segments[T.segmentIndex];j.type==="string"&&(j.value?.length??0)===T.offset&&r.segments[T.segmentIndex+1].type!=="string"&&(L.preventDefault(),r.segments.splice(T.segmentIndex+1,1),d(),D(),n())}}},_=L=>{L.preventDefault();const T=L.clipboardData?.getData("text/plain")||"";document.execCommand("insertText",!1,T)},O=L=>{if(!r.dialogOpen)return;const T=u.value;T&&(T.contains(L.target)||w())},D=()=>{r.ignoreNextWatch=!0;const L=r.segments.map(T=>{const{_uid:j,...S}=T||{};return S});c("update:modelValue",L)},N=()=>{const L=window.getSelection();if(!L||!a.value)return;const T=L.anchorNode;T&&a.value.contains(T)&&m()},U=L=>{(L.key==="Escape"||L.key==="Esc")&&r.dialogOpen&&(L.preventDefault(),w())};return ye(()=>{s.modelValue&&s.modelValue.length&&(r.segments=JSON.parse(JSON.stringify(s.modelValue))),n(),document.addEventListener("mousedown",O),document.addEventListener("selectionchange",N),document.addEventListener("keydown",U,!0)}),je(()=>{document.removeEventListener("mousedown",O),document.removeEventListener("selectionchange",N),document.removeEventListener("keydown",U,!0)}),ie(()=>s.modelValue,L=>{if(r.ignoreNextWatch){r.ignoreNextWatch=!1;return}L&&(r.segments=JSON.parse(JSON.stringify(L)),n())},{deep:!0}),(L,T)=>(o(),l("div",X2,[e("div",{ref_key:"editorRef",ref:a,contenteditable:!t.disabled,onInput:g,onKeydown:P,onPaste:_,onClick:$,onKeyup:T[0]||(T[0]=j=>{j.key==="Escape"?(j.preventDefault(),w()):(j.key==="ArrowLeft"||j.key==="ArrowRight")&&m()}),onCompositionstart:T[1]||(T[1]=j=>r.isComposing=!0),onCompositionend:T[2]||(T[2]=j=>r.isComposing=!1),class:oe(["prompt-input-editor","min-h-[100px] p-3 border-2 rounded-lg","border-black dark:border-neutral-300","bg-white dark:bg-black","focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white",t.disabled?"opacity-50 cursor-not-allowed":""]),"data-placeholder":t.placeholder},[_e(e("div",null,[Je(L.$slots,"segment",{segment:null},void 0,!0)],512),[[De,!1]])],42,Y2),r.dialogOpen?(o(),l("div",{key:0,ref_key:"dialogRef",ref:u,class:"absolute z-50",style:st({left:`${r.dialogPosition.x}px`,top:`${r.dialogPosition.y}px`})},[I(Ke,{"offset-x":2,"offset-y":2,intensity:.3},{default:de(()=>[e("div",Q2,[r.isSearching?(o(),l("div",ep," Searching... ")):r.searchResults.length===0?(o(),l("div",tp," No results found ")):(o(),l("div",op,[(o(!0),l(ce,null,fe(r.searchResults,(j,S)=>(o(),l("button",{key:j.id||j.value||S,type:"button",onClick:x=>X(j),class:oe(["w-full px-3 py-2 text-left text-sm","hover:bg-neutral-100 dark:hover:bg-neutral-900","focus:bg-neutral-100 dark:focus:bg-neutral-900 focus:outline-none",r.selectedIndex===S?"bg-neutral-100 dark:bg-neutral-900":""])},[e("div",lp,[ke(V(j.label||j.id||j.value)+" ",1),j.type==="prompt"&&j.meta&&!j.meta.isValid?(o(),l("span",{key:0,title:j.meta.validationMessage,class:"text-red-500"},"⚠️",8,sp)):M("",!0)]),j.description?(o(),l("div",np,V(j.description),1)):M("",!0),j.type==="prompt"&&j.meta&&!j.meta.isValid?(o(),l("div",rp,V(j.meta.validationMessage),1)):M("",!0),e("div",ip,[e("span",{class:oe(["inline-block px-1.5 py-0.5 rounded",j.type==="variable"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-purple-100 dark:bg-purple-900 text-purple-700 dark:text-purple-300"])},V(j.type),3)])],10,ap))),128))]))])]),_:1})],4)):M("",!0)]))}}),eo=Fe(dp,[["__scopeId","data-v-7ee6148f"]]);function At(t,i){if(!i||!i.properties||Object.keys(i.properties).length===0)return!0;if(!t||!t.properties)return Object.keys(i.properties);const s=[],c=t.properties||{},a=i.properties||{};return(i.required||[]).forEach(r=>{r in c||s.push(r)}),Object.keys(a).forEach(r=>{!(r in c)&&!s.includes(r)&&s.push(r)}),s.length>0?s:!0}function Pt(t){return t.length===0?"":t.length===1?`Missing required field: ${t[0]}`:`Missing required fields: ${t.join(", ")}`}const up={class:"space-y-4"},cp=se({__name:"PromptTemplate",props:{promptText:{},beforeTool:{},afterTool:{},requiredSchema:{},currentPromptName:{}},emits:["update:promptText","update:beforeTool","update:afterTool"],setup(t,{emit:i}){const s=t,c=i,a=v([]),u=v(!1),r=h=>h.type==="text"?{type:"string",value:h.content||""}:h.type==="include"?{type:"prompt",id:h.prompt||"",label:h.prompt||""}:h.type==="string"?{type:"string",value:h.value||""}:h.type==="prompt"?{type:"prompt",id:h.id||"",label:h.label||h.id||""}:h.type==="variable"?{type:"variable",value:h.value||"",label:h.label||h.value||""}:{type:"string",value:""},p=z(()=>{if(!s.promptText)return[{type:"string",value:""}];let h=[];try{const g=JSON.parse(s.promptText);Array.isArray(g)?h=g.map(r):h=[{type:"string",value:s.promptText}]}catch{h=[{type:"string",value:s.promptText}]}const $=s.requiredSchema?JSON.parse(s.requiredSchema):{};return h.map(g=>{if(g.type==="prompt"&&g.schema){const m=At($,g.schema),C=m===!0,w=C?[]:m;return{...g,meta:{isValid:C,missingFields:w,validationMessage:C?"":Pt(w)}}}return g})}),f=z(()=>{try{const h=JSON.parse(s.requiredSchema);if(h.properties&&typeof h.properties=="object")return Object.keys(h.properties)}catch{return[]}return[]}),b=async h=>{u.value=!0;try{const $=new URLSearchParams;h&&$.set("search",h);const g=await fetch(te(`/api/prompts${$.toString()?"?"+$.toString():""}`));if(g.ok){const m=await g.json();a.value=m.prompts||[]}}catch($){console.error("Error fetching prompts:",$)}finally{u.value=!1}},n=async h=>{const $=[];return f.value.forEach(g=>{(!h||g.toLowerCase().includes(h.toLowerCase()))&&$.push({type:"variable",value:g,label:g,description:"Schema property"})}),h!==void 0&&await b(h),a.value.forEach(g=>{if(!(s.currentPromptName&&g.name===s.currentPromptName)&&(!h||g.name.toLowerCase().includes(h.toLowerCase()))){const m=s.requiredSchema?JSON.parse(s.requiredSchema):{},C=At(m,g.required_schema),w=C===!0,E=w?[]:C;$.push({type:"prompt",id:g.name,label:g.name,description:g.tool_description||"Available prompt",schema:g.required_schema,meta:{isValid:w,missingFields:E,validationMessage:w?"":Pt(E)}})}}),$},d=h=>{const $=h.map(g=>{const{type:m,value:C,label:w,id:E,schema:A}=g;return m==="string"?{type:m,value:C||""}:m==="variable"?{type:m,value:C||"",label:w}:m==="prompt"?{type:m,id:E||"",label:w,schema:A}:g});c("update:promptText",JSON.stringify($))};return ye(()=>{b()}),(h,$)=>(o(),l("div",up,[e("div",null,[$[0]||($[0]=e("label",{class:"block text-sm font-medium mb-2"},"Prompt Template",-1)),$[1]||($[1]=e("p",{class:"text-sm text-neutral-600 dark:text-neutral-400 mb-2"}," Type @ to insert schema properties or other prompts ",-1)),I(eo,{"model-value":p.value,"onUpdate:modelValue":d,search:n,placeholder:"Enter your prompt template... Type @ to insert variables or prompts"},null,8,["model-value"])])]))}}),pp={class:"space-y-3"},mp={class:"space-y-2 pl-4 border-l-2 border-accent-200 dark:border-accent-700"},vp={class:"space-y-1"},fp={class:"space-y-2 pl-4 border-l-2 border-neutral-200 dark:border-neutral-700"},hp=se({__name:"PromptToolOptions",props:{toolName:{},toolConfig:{},disabled:{type:Boolean}},emits:["update:option"],setup(t,{emit:i}){const s=t,c=i,a=v(null),u=v(!0),r=z(()=>a.value?.properties?Object.entries(a.value.properties).map(([b,n])=>({value:b,label:b,description:n.description||n.type||""})):[]),p=async()=>{try{const b=await fetch(te(`/api/prompts/${encodeURIComponent(s.toolName)}`));if(b.ok){const n=await b.json();n?.prompt?.required_schema&&(a.value=n.prompt.required_schema)}}catch(b){console.error("Error fetching prompt schema:",b)}finally{u.value=!1}};ye(()=>{p()});const f=(b,n)=>{c("update:option",b,n)};return(b,n)=>(o(),l("div",pp,[e("div",mp,[n[6]||(n[6]=e("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Initialization Options: ",-1)),e("div",vp,[n[4]||(n[4]=e("label",{class:"block text-xs font-medium text-neutral-700 dark:text-neutral-300"}," User message property ",-1)),I(ge,{"model-value":t.toolConfig.init_user_message_property||"","onUpdate:modelValue":n[0]||(n[0]=d=>f("init_user_message_property",d||null)),placeholder:"Don't inject a user message",options:r.value,disabled:t.disabled||u.value||r.value.length===0,loading:u.value},null,8,["model-value","options","disabled","loading"]),n[5]||(n[5]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"}," Select which argument property should be used as the most recent user message for this sub-prompt. If not set no additional user message will be injected. ",-1))])]),e("div",fp,[n[7]||(n[7]=e("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Sub-Prompt Response Options: ",-1)),I(Ve,{"model-value":t.toolConfig.include_text_response,"onUpdate:modelValue":n[1]||(n[1]=d=>f("include_text_response",d)),label:"Include text response","help-text":"Include the final text content from the sub-prompt",disabled:t.disabled},null,8,["model-value","disabled"]),I(Ve,{"model-value":t.toolConfig.include_tool_calls,"onUpdate:modelValue":n[2]||(n[2]=d=>f("include_tool_calls",d)),label:"Include tool calls and responses","help-text":"Include tool calls executed by the sub-prompt and their responses",disabled:t.disabled},null,8,["model-value","disabled"]),I(Ve,{"model-value":t.toolConfig.include_errors,"onUpdate:modelValue":n[3]||(n[3]=d=>f("include_errors",d)),label:"Include errors","help-text":"Include error information if the sub-prompt fails",disabled:t.disabled},null,8,["model-value","disabled"])])]))}});async function Ue(t,i={}){const s=localStorage.getItem("auth_token"),c={"Content-Type":"application/json",...i.headers};s&&(c.Authorization=`Bearer ${s}`);const a=t.startsWith("/")?t:`/${t}`,u=await fetch(te(`/api${a}`),{...i,headers:c});if(u.status===401)throw localStorage.removeItem("auth_token"),window.location.href=te("/login"),new Error("Unauthorized");return u}const gp={class:"space-y-4"},bp={class:"block text-sm font-medium mb-2"},xp={key:0,class:"text-red-500"},yp={class:"flex items-start justify-between"},kp={class:"flex items-center gap-2 flex-1"},wp={class:"flex-1"},_p={class:"font-medium text-sm"},$p={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-1"},Cp=["onClick","disabled","aria-label"],Vp={key:1,class:"text-xs text-red-500 dark:text-red-400 mt-1"},Sp={key:0,class:"text-center py-8 text-sm text-neutral-500 dark:text-neutral-400 border border-dashed border-neutral-300 dark:border-neutral-600 rounded-lg"},Tp=se({__name:"ToolSelectorWithOptions",props:Oe({label:{default:"Available Tools"},placeholder:{default:"Select a tool"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const i=qe(t,"modelValue"),s=v([]),c=v(!1),a=v();Bt(async()=>{a.value,await xe(),a.value&&i.value.length>0&&await qt({parent:a,values:i,dragHandle:".drag-handle"})});const u=z(()=>{const d=new Set(i.value.map(h=>h.name));return s.value.filter(h=>!d.has(h.name)).map(h=>{let $=h.name;return h.type==="prompt"?$=`${h.name} (prompt)`:h.type==="mcp"&&($=`${h.name} (mcp)`),{value:h.name,label:$,description:h.description}})}),r=async()=>{c.value=!0;try{const d=await Ue("/tools");if(d.ok){const h=await d.json();s.value=Object.entries(h).map(([$,g])=>({name:$,description:g.description||"",type:g.type,model:g.model}))}}catch(d){console.error("Error fetching tools:",d)}finally{c.value=!1}},p=d=>{d&&(i.value.find(h=>h.name===d)||(i.value=[...i.value,{name:d,include_text_response:!0,include_tool_calls:!0,include_errors:!0,init_user_message_property:null}]))},f=d=>{i.value=i.value.filter(h=>h.name!==d)},b=d=>s.value.find(h=>h.name===d),n=(d,h,$)=>{i.value=i.value.map(g=>g.name===d?{...g,[h]:$}:g)};return ye(()=>{r()}),(d,h)=>(o(),l("div",gp,[e("div",null,[e("label",bp,[ke(V(t.label)+" ",1),t.required?(o(),l("span",xp,"*")):M("",!0)]),i.value.length>0?(o(),l("div",{key:0,class:"space-y-3 mb-4",ref_key:"dragAreaRef",ref:a},[(o(!0),l(ce,null,fe(i.value,$=>(o(),l("div",{key:$.name,class:"border border-neutral-300 dark:border-neutral-600 rounded-lg p-4"},[e("div",yp,[e("div",kp,[h[0]||(h[0]=e("div",{class:"drag-handle cursor-move text-neutral-400 hover:text-neutral-600 dark:text-neutral-600 dark:hover:text-neutral-400"},[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8h16M4 16h16"})])],-1)),e("div",wp,[e("h4",_p,V($.name),1),b($.name)?.description?(o(),l("p",$p,V(b($.name)?.description),1)):M("",!0)])]),e("button",{onClick:g=>f($.name),type:"button",disabled:t.disabled,class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors text-neutral-500 hover:text-red-500","aria-label":`Remove ${$.name}`},[...h[1]||(h[1]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,Cp)]),b($.name)?.type==="prompt"?(o(),Q(hp,{key:0,"tool-name":$.name,"tool-config":$,disabled:t.disabled,"onUpdate:option":(g,m)=>n($.name,g,m)},null,8,["tool-name","tool-config","disabled","onUpdate:option"])):M("",!0)]))),128))],512)):M("",!0),I(ge,{"model-value":"","onUpdate:modelValue":p,placeholder:i.value.length>0?"Add another tool...":t.placeholder,"search-placeholder":"Search tools...",options:u.value,disabled:t.disabled||c.value||u.value.length===0,loading:c.value},null,8,["placeholder","options","disabled","loading"]),t.error?(o(),l("p",Vp,V(t.error),1)):M("",!0)]),i.value.length===0&&!c.value&&u.value.length===0?(o(),l("div",Sp," No tools available. Create tools in your agentbuilder/tools directory. ")):M("",!0)]))}}),Mp={class:"space-y-2"},Ip={key:0,class:"space-y-2"},Lp={key:0,class:"block text-sm font-medium"},Ep={key:0,class:"text-red-500"},Ap=["src","alt"],Pp={class:"flex-1 text-sm"},Op={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 ml-1"},jp=["onClick","aria-label"],Dp={key:1,class:"text-xs text-red-500 dark:text-red-400"},lt=se({__name:"MultipleSelectionsInput",props:Oe({label:{},placeholder:{default:"Select an option"},searchPlaceholder:{default:"Search..."},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},options:{},addLabel:{default:"Add another"},loading:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:Oe(["removeItem"],["update:modelValue"]),setup(t,{emit:i}){const s=t,c=i,a=qe(t,"modelValue"),u=v();Bt(async()=>{u.value,await xe(),await qt({parent:u,values:a,dragHandle:".drag-handle"})});const r=z(()=>Array.isArray(a.value)?a.value.length>0&&typeof a.value[0]=="object"?a.value:a.value.map(n=>{const d=s.options.find(h=>h.value===n);return{id:n,label:d?.label||n,description:d?.description,icon:d?.icon}}):[]),p=z(()=>{const n=r.value.map(d=>d.id);return s.options.filter(d=>!n.includes(d.value))}),f=n=>{if(!n)return;const d=s.options.find(h=>h.value===n);if(d)if(a.value.length===0||typeof a.value[0]=="string")a.value=[...a.value,n];else{const h={id:n,label:d.label,description:d.description,icon:d.icon};a.value=[...a.value,h]}},b=n=>{typeof a.value[0]=="string"?a.value=a.value.filter(d=>d!==n):a.value=a.value.filter(d=>d.id!==n),c("removeItem",n)};return(n,d)=>(o(),l("div",Mp,[r.value.length>0?(o(),l("div",Ip,[t.label?(o(),l("label",Lp,[ke(V(t.label)+" ",1),t.required?(o(),l("span",Ep,"*")):M("",!0)])):M("",!0),e("div",{class:"space-y-1",ref_key:"dragAreaRef",ref:u},[(o(!0),l(ce,null,fe(r.value,h=>(o(),l("div",{key:h.id,class:oe(["flex items-center gap-2 px-3 py-2 bg-neutral-50 dark:bg-neutral-900 rounded border","border-neutral-200 dark:border-neutral-800",t.disabled?"opacity-50":""])},[d[1]||(d[1]=e("div",{class:"drag-handle cursor-move text-neutral-400 hover:text-neutral-600 dark:text-neutral-600 dark:hover:text-neutral-400"},[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8h16M4 16h16"})])],-1)),h.icon?(o(),l("img",{key:0,src:h.icon,alt:h.label,class:"w-4 h-4 flex-shrink-0"},null,8,Ap)):M("",!0),e("span",Pp,[ke(V(h.label)+" ",1),h.description?(o(),l("span",Op," ("+V(h.description)+") ",1)):M("",!0)]),t.disabled?M("",!0):(o(),l("button",{key:1,onClick:$=>b(h.id),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors","aria-label":`Remove ${h.label}`},[...d[0]||(d[0]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,jp))],2))),128))],512)])):M("",!0),I(ge,{"model-value":"","onUpdate:modelValue":f,label:r.value.length>0?t.addLabel:t.label,options:p.value,placeholder:t.placeholder,"search-placeholder":t.searchPlaceholder,disabled:t.disabled||p.value.length===0,loading:t.loading},null,8,["label","options","placeholder","search-placeholder","disabled","loading"]),t.error?(o(),l("p",Dp,V(t.error),1)):M("",!0)]))}}),Up={key:2,class:"text-xs text-red-500 dark:text-red-400 mt-1"},Np=se({__name:"AgentSelectorInput",props:Oe({label:{default:"Handoff Agents"},placeholder:{default:"Select an agent"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},allowMultiple:{type:Boolean,default:!0},agentType:{default:"ai_human"}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const i=t,s=qe(t,"modelValue"),c=v([]),a=v(!1),u=z(()=>c.value.map(f=>({value:f.id,label:f.title,description:f.tool_description||`Handoff to ${f.title} agent`}))),r=async()=>{a.value=!0;try{const f=te(`/api/agents${i.agentType?`?type=${i.agentType}`:""}`),b=await fetch(f);if(b.ok){const n=await b.json();c.value=n.agents||[]}}catch(f){console.error("Error fetching agents:",f)}finally{a.value=!1}},p=f=>{};return ye(()=>{r()}),ie(()=>i.allowMultiple,()=>{i.allowMultiple&&typeof s.value=="string"?s.value=s.value?[s.value]:[]:!i.allowMultiple&&Array.isArray(s.value)&&(s.value=s.value[0]||"")},{immediate:!0}),(f,b)=>(o(),l(ce,null,[t.allowMultiple?(o(),Q(lt,{key:0,modelValue:s.value,"onUpdate:modelValue":b[0]||(b[0]=n=>s.value=n),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search agents...",error:t.error,required:t.required,disabled:t.disabled,options:u.value,loading:a.value,"add-label":"Add another agent",onRemoveItem:p},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(o(),Q(ge,{key:1,modelValue:s.value,"onUpdate:modelValue":b[1]||(b[1]=n=>s.value=n),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search agents...",options:u.value,disabled:t.disabled,loading:a.value},null,8,["modelValue","label","placeholder","options","disabled","loading"])),!t.allowMultiple&&t.error?(o(),l("p",Up,V(t.error),1)):M("",!0)],64))}}),Rp={key:0,class:"min-h-[400px] flex items-center justify-center"},Bp={key:1,class:"space-y-6 pr-2 pb-4"},qp={class:"space-y-4"},Fp={class:"space-y-4"},zp={class:"flex justify-between"},Hp={class:"flex gap-2"},Wp=["disabled"],to=se({__name:"PromptModal",props:{modelValue:{type:Boolean},editPrompt:{},mode:{}},emits:["update:modelValue","save"],setup(t,{emit:i}){const s=t,c=i,a=z(()=>s.mode==="edit"),u=v(!1),r=z(()=>w.value.length===1),p=v(""),f=v(""),b=v(""),n=v(""),d=v({type:"object",properties:{},required:[],additionalProperties:!1}),h=v(""),$=v(!1),g=v(!1),m=v(""),C=v(""),w=v([]),E=v([]),A=v(!1),q=v("auto"),J=v(null),X=v(null),P=v(!1),_=v(!1),O=z({get:()=>J.value||"",set:j=>J.value=j||null}),D=z({get:()=>q.value,set:j=>q.value=j}),N=()=>{f.value="",p.value="",b.value="",n.value="",d.value={type:"object",properties:{},required:[],additionalProperties:!1},h.value="",$.value=!1,g.value=!1,m.value="",C.value="",w.value=[],E.value=[],A.value=!1,q.value="auto",J.value=null,X.value=null,P.value=!1,_.value=!1},U=async()=>{if(s.editPrompt?.id){u.value=!0;try{const j=await Ue(`/prompts/${s.editPrompt.id}`);if(j.ok){const S=await j.json(),x=S.prompt||S;f.value=x.name||"",p.value=x.name||"",b.value=x.tool_description||"",n.value=x.model_id||"";let y=x.required_schema;if(typeof y=="string")try{y=JSON.parse(y)}catch{y=null}d.value=y||{type:"object",properties:{},required:[],additionalProperties:!1},h.value=x.prompt||"",$.value=x.include_chat||!1,g.value=x.include_past_tools||!1,m.value=x.before_tool||"",C.value=x.after_tool||"";const k=x.tools||[];w.value=k.map(K=>typeof K=="string"?{name:K,include_text_response:!0,include_tool_calls:!0,include_errors:!0,init_user_message_property:null}:K),E.value=x.prompts||x.handoff_agents||[],A.value=x.parallel_tool_calls||!1,q.value=x.tool_choice||"auto";const R=x.reasoning||{};J.value=R.effort||x.reasoning_effort||null,X.value=R.maxTokens||x.reasoning_max_tokens||null,P.value=R.exclude||x.reasoning_exclude||!1,_.value=x.include_reasoning||!1}}catch(j){console.error("Error loading prompt data:",j)}finally{u.value=!1}}},L=async()=>{const j=/^[a-z][a-z0-9_]*$/;if(!f.value||!j.test(f.value)){alert("Please enter a valid name (lowercase letters, numbers, and underscores only, must start with a letter)");return}if(!b.value){alert("Please enter a description");return}if(!n.value){alert("Please select a model");return}if(!h.value){alert("Please enter the prompt template");return}const S={name:f.value,tool_description:b.value,prompt:h.value,required_schema:d.value,model_id:n.value,include_chat:$.value,include_past_tools:g.value,before_tool:m.value||null,after_tool:C.value||null,parallel_tool_calls:A.value,tool_choice:q.value,tools:w.value,handoff_agents:E.value,reasoning_effort:J.value,reasoning_max_tokens:X.value,reasoning_exclude:P.value,include_reasoning:_.value};a.value&&s.editPrompt?.id&&(S.id=s.editPrompt.id,p.value&&p.value!==f.value&&(S.originalName=p.value)),c("save",S),N(),c("update:modelValue",!1)},T=()=>{N(),c("update:modelValue",!1)};return ie(()=>w.value.length,j=>{q.value==="function"&&j!==1&&(q.value="auto")}),ie(()=>s.modelValue,async j=>{j&&(a.value?(N(),await xe(),await U()):N())}),ie(()=>s.editPrompt,async j=>{j&&a.value&&s.modelValue&&(await xe(),await U())},{immediate:!0}),(j,S)=>(o(),Q(Ae,{"model-value":t.modelValue,"onUpdate:modelValue":S[17]||(S[17]=x=>j.$emit("update:modelValue",x)),title:a.value?"Edit Prompt":"Add Prompt",width:"max-w-4xl"},{footer:de(()=>[e("div",zp,[e("button",{onClick:T,type:"button",class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors"}," Cancel "),e("div",Hp,[e("button",{onClick:L,type:"button",class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity",disabled:u.value},V(a.value?"Update Prompt":"Create Prompt"),9,Wp)])])]),default:de(()=>[u.value?(o(),l("div",Rp,[...S[18]||(S[18]=[e("span",{class:"text-neutral-500"},"Loading prompt data...",-1)])])):(o(),l("div",Bp,[e("div",null,[I(W0,{name:f.value,"onUpdate:name":S[0]||(S[0]=x=>f.value=x),"tool-description":b.value,"onUpdate:toolDescription":S[1]||(S[1]=x=>b.value=x)},null,8,["name","tool-description"])]),e("div",null,[I(u2,{modelValue:n.value,"onUpdate:modelValue":S[2]||(S[2]=x=>n.value=x)},null,8,["modelValue"])]),e("div",null,[I(Qt,{modelValue:d.value,"onUpdate:modelValue":S[3]||(S[3]=x=>d.value=x),label:"Required Schema (Optional)"},null,8,["modelValue"])]),e("div",null,[I(cp,{"prompt-text":h.value,"onUpdate:promptText":S[4]||(S[4]=x=>h.value=x),"before-tool":m.value,"onUpdate:beforeTool":S[5]||(S[5]=x=>m.value=x),"after-tool":C.value,"onUpdate:afterTool":S[6]||(S[6]=x=>C.value=x),"required-schema":JSON.stringify(d.value,null,2),"current-prompt-name":a.value?f.value:void 0},null,8,["prompt-text","before-tool","after-tool","required-schema","current-prompt-name"])]),e("div",null,[I(Tp,{modelValue:w.value,"onUpdate:modelValue":S[7]||(S[7]=x=>w.value=x)},null,8,["modelValue"])]),e("div",qp,[S[20]||(S[20]=e("h3",{class:"text-sm font-medium text-neutral-900 dark:text-neutral-100"}," Tool Configuration ",-1)),e("div",null,[I(Ve,{modelValue:A.value,"onUpdate:modelValue":S[8]||(S[8]=x=>A.value=x),label:"Allow parallel tool calls","help-text":"Allow the model to call multiple tools simultaneously in a single turn"},null,8,["modelValue"])]),e("div",null,[I(ge,{modelValue:D.value,"onUpdate:modelValue":S[9]||(S[9]=x=>D.value=x),label:"Tool Choice",options:[{value:"auto",label:"Auto",description:"Model decides"},{value:"none",label:"None",description:"No tools allowed"},{value:"required",label:"Required",description:"Must call a tool"},{value:"function",label:"Function",description:r.value?"Call specific tool":"Requires exactly 1 tool"}].filter(x=>x.value!=="function"||r.value),placeholder:"Select tool choice"},null,8,["modelValue","options"]),S[19]||(S[19]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Controls whether and how the model can call tools ",-1))])]),e("div",null,[I(Np,{modelValue:E.value,"onUpdate:modelValue":S[10]||(S[10]=x=>E.value=x),"allow-multiple":!0,label:"Handoff Agents (Optional)",placeholder:"Select AI + Human agents to hand off to","agent-type":"ai_human"},null,8,["modelValue"]),S[21]||(S[21]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," AI + Human agents that this prompt can hand off conversations to. These will be exposed as tools. ",-1))]),e("div",Fp,[S[25]||(S[25]=e("h3",{class:"text-sm font-medium text-neutral-900 dark:text-neutral-100"}," Context & Reasoning Configuration ",-1)),e("div",null,[I(Ve,{modelValue:$.value,"onUpdate:modelValue":S[11]||(S[11]=x=>$.value=x),label:"Include chat history","help-text":"Expose chat history to the LLM when this prompt is used as a full prompt (not a partial in another prompt)"},null,8,["modelValue"])]),e("div",null,[I(Ve,{modelValue:g.value,"onUpdate:modelValue":S[12]||(S[12]=x=>g.value=x),label:"Include past tool calls","help-text":"Include prior tool call history in this prompt. Uncheck to remove past tool calls"},null,8,["modelValue"])]),e("div",null,[I(Ve,{modelValue:_.value,"onUpdate:modelValue":S[13]||(S[13]=x=>_.value=x),label:"Include reasoning in message history","help-text":"When loading message history, include reasoning_details from previous responses. Required for multi-turn reasoning continuity."},null,8,["modelValue"])]),S[26]||(S[26]=e("hr",{class:"border-neutral-300 dark:border-neutral-600"},null,-1)),S[27]||(S[27]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"}," Configure extended reasoning for models like o1, o3, Gemini Thinking, and others. Reasoning is enabled automatically when either field is set. ",-1)),e("div",null,[I(ge,{modelValue:O.value,"onUpdate:modelValue":S[14]||(S[14]=x=>O.value=x),label:"Reasoning Effort",options:[{value:"",label:"None",description:"Disabled"},{value:"low",label:"Low",description:"~20% of max_tokens"},{value:"medium",label:"Medium",description:"~50% of max_tokens"},{value:"high",label:"High",description:"~80% of max_tokens"}],placeholder:"Select reasoning effort"},null,8,["modelValue"]),S[22]||(S[22]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Controls reasoning capacity allocation. Supported by OpenAI o-series and Grok models. ",-1))]),e("div",null,[S[23]||(S[23]=e("label",{class:"block text-sm font-medium text-neutral-700 dark:text-neutral-300 mb-2"}," Max Reasoning Tokens ",-1)),_e(e("input",{"onUpdate:modelValue":S[15]||(S[15]=x=>X.value=x),type:"number",min:"1024",max:"32000",step:"1024",placeholder:"Leave empty to disable or use effort level",class:"w-full px-3 py-2 text-sm border border-neutral-300 dark:border-neutral-600 rounded bg-white dark:bg-neutral-800 text-neutral-900 dark:text-neutral-100 focus:ring-2 focus:ring-accent-500 focus:border-transparent"},null,512),[[Ee,X.value,void 0,{number:!0}]]),S[24]||(S[24]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Directly specify reasoning token limit (1024-32000). Supported by Anthropic, Gemini Thinking, and some Qwen models. ",-1))]),e("div",null,[I(Ve,{modelValue:P.value,"onUpdate:modelValue":S[16]||(S[16]=x=>P.value=x),label:"Exclude reasoning from response","help-text":"Use reasoning internally but don't return it in the response (saves tokens and cost)"},null,8,["modelValue"])])])]))]),_:1},8,["model-value","title"]))}}),Jp=se({__name:"PromptsView",setup(t){const i=Ze(),s=Re(),c=v(!1),a=v(null);ie(()=>s.query.refresh,()=>{s.query.refresh&&(a.value?.refresh(),i.replace({path:"/prompts",query:{}}))});const u=()=>{c.value=!0},r=f=>{i.push(`/prompts/${f.id}`)},p=async f=>{try{const b=await fetch(te("/api/prompts"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(b.ok)c.value=!1,await new Promise(n=>setTimeout(n,100)),await a.value?.refresh();else{const n=await b.json();alert(n.error||"Failed to create prompt")}}catch(b){console.error("Error creating prompt:",b),alert("Failed to create prompt")}};return(f,b)=>(o(),Q(ze,null,{default:de(()=>[e("div",{class:"flex justify-between items-center mb-6"},[b[1]||(b[1]=e("h1",{class:"text-3xl font-bold"},"Prompts",-1)),e("button",{onClick:u,class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Create Prompt ")]),b[2]||(b[2]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-6"}," Define and manage prompt templates for your agents. ",-1)),I(R0,{ref_key:"dataTableRef",ref:a,onAdd:u,onEdit:r},null,512),I(to,{modelValue:c.value,"onUpdate:modelValue":b[0]||(b[0]=n=>c.value=n),mode:"add",onSave:p},null,8,["modelValue"])]),_:1}))}}),Zp={class:"p-8"},Kp={key:0,class:"flex items-center justify-center min-h-[400px]"},Gp={key:2,class:"flex items-center justify-center min-h-[400px]"},Xp=se({__name:"PromptEditView",setup(t){const i=Ze(),s=Re(),c=v(!0),a=v(null),u=v(!0),r=async()=>{const b=s.params.id;if(!b){i.push("/prompts");return}u.value=!0;try{const n=await fetch(te(`/api/prompts/${b}`));if(n.ok){const d=await n.json();a.value=d.prompt||d}else alert("Prompt not found"),i.push("/prompts")}catch(n){console.error("Error loading prompt:",n),alert("Failed to load prompt"),i.push("/prompts")}finally{u.value=!1}},p=async b=>{try{const{originalName:n,...d}=b,h=n||d.id,$=await fetch(te(`/api/prompts/${h}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)});if($.ok)i.push({path:"/prompts",query:{refresh:Date.now().toString()}});else{const g=await $.json();alert(g.error||"Failed to update prompt")}}catch(n){console.error("Error updating prompt:",n),alert("Failed to update prompt")}},f=b=>{b||i.push("/prompts")};return ye(()=>{r()}),ie(c,b=>{b||i.push("/prompts")}),(b,n)=>(o(),l("div",Zp,[u.value?(o(),l("div",Kp,[...n[1]||(n[1]=[e("span",{class:"text-neutral-500"},"Loading prompt...",-1)])])):a.value?(o(),Q(to,{key:1,modelValue:c.value,"onUpdate:modelValue":[n[0]||(n[0]=d=>c.value=d),f],mode:"edit","edit-prompt":a.value,onSave:p},null,8,["modelValue","edit-prompt"])):(o(),l("div",Gp,[...n[2]||(n[2]=[e("span",{class:"text-neutral-500"},"Prompt not found",-1)])]))]))}}),Yp={class:"border-2 border-black dark:border-neutral-300 rounded-lg overflow-hidden"},Qp={key:0,class:"px-4 py-2 border-b-2 border-black dark:border-neutral-300 bg-neutral-50 dark:bg-neutral-900"},e1={class:"flex items-center justify-between"},t1={class:"text-sm font-medium"},o1={class:"flex items-center gap-2"},a1={key:1,class:"px-4 py-8 flex items-center justify-center"},l1={key:2,class:"px-4 py-8 text-center text-neutral-500"},s1={key:3,class:"divide-y divide-neutral-200 dark:divide-neutral-700"},n1=["onClick"],r1={class:"flex items-start gap-3"},i1={class:"flex-shrink-0 mt-0.5"},d1=["checked","onClick"],u1={class:"flex-1 min-w-0"},c1={class:"flex items-center gap-2"},p1={class:"text-sm font-medium"},m1={key:0,class:"text-xs px-1.5 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded"},v1={class:"mt-1 text-xs text-neutral-600 dark:text-neutral-400 space-y-0.5"},f1={key:0},h1={key:0},g1={key:1},b1={key:2},x1=se({__name:"ExposedSelectList",props:{providers:{default:()=>[]},modelValue:{default:()=>[]},label:{},loading:{type:Boolean}},emits:["update:modelValue"],setup(t,{emit:i}){function s(n){if(n===0)return"$0.00";const d=Math.abs(n);let h;return d<1e-4?h=d.toExponential(3):d<.001||d<.01||d<.1?h=d.toFixed(4):d<1?h=d.toFixed(3):d<10||d<100?h=d.toFixed(2):d<1e3?h=d.toFixed(1):h=d.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:0}),h.includes(".")&&(h=h.replace(/\.?0+$/,""),!h.includes(".")&&d<100&&(h=d.toFixed(2))),n<0?`-$${h}`:`$${h}`}const c=t,a=i,u=n=>c.modelValue.includes(n),r=n=>{const d=[...c.modelValue],h=d.indexOf(n);h>-1?d.splice(h,1):d.push(n),a("update:modelValue",d)},p=()=>{a("update:modelValue",c.providers.map(n=>n.id))},f=()=>{a("update:modelValue",[])},b=z(()=>c.providers.length>0&&c.modelValue.length===c.providers.length);return z(()=>c.modelValue.length>0&&c.modelValue.length<c.providers.length),(n,d)=>(o(),l("div",Yp,[t.label?(o(),l("div",Qp,[e("div",e1,[e("span",t1,V(t.label),1),e("div",o1,[e("button",{type:"button",onClick:d[0]||(d[0]=h=>b.value?f():p()),class:"text-xs px-2 py-1 border border-neutral-400 dark:border-neutral-600 rounded hover:bg-neutral-100 dark:hover:bg-neutral-800"},V(b.value?"Deselect All":"Select All"),1)])])])):M("",!0),t.loading?(o(),l("div",a1,[...d[1]||(d[1]=[e("div",{class:"flex items-center gap-2 text-neutral-500"},[e("svg",{class:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]),e("span",null,"Loading providers...")],-1)])])):t.providers.length===0?(o(),l("div",l1," No providers available ")):(o(),l("div",s1,[(o(!0),l(ce,null,fe(t.providers,h=>(o(),l("div",{key:h.id,class:"px-4 py-3 hover:bg-neutral-50 dark:hover:bg-neutral-900 cursor-pointer",onClick:$=>r(h.id)},[e("div",r1,[e("div",i1,[e("input",{type:"checkbox",checked:u(h.id),onClick:Te($=>r(h.id),["stop"]),class:"w-4 h-4 border-2 border-black dark:border-neutral-300 rounded focus:ring-2 focus:ring-black dark:focus:ring-white"},null,8,d1)]),e("div",u1,[e("div",c1,[e("span",p1,V(h.name),1),h.quantization?(o(),l("span",m1,V(h.quantization),1)):M("",!0)]),e("div",v1,[e("div",null,V(s(h.pricing.prompt*1e6))+"/M input • "+V(s(h.pricing.completion*1e6))+"/M output ",1),h.maxPromptTokens||h.maxCompletionTokens?(o(),l("div",f1,[h.maxPromptTokens?(o(),l("span",h1," Max prompt: "+V(h.maxPromptTokens.toLocaleString())+" tokens ",1)):M("",!0),h.maxPromptTokens&&h.maxCompletionTokens?(o(),l("span",g1," • ")):M("",!0),h.maxCompletionTokens?(o(),l("span",b1," Max completion: "+V(h.maxCompletionTokens.toLocaleString())+" tokens ",1)):M("",!0)])):M("",!0)])])])],8,n1))),128))]))]))}}),y1={key:2,class:"text-xs text-red-500 dark:text-red-400 mt-1"},k1=se({__name:"ModelSelectorInput",props:Oe({label:{},placeholder:{default:"Select a model"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},allowMultiple:{type:Boolean,default:!1}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const i=t,s=qe(t,"modelValue"),c=v([]),a=v(!1),u=z(()=>c.value.map(f=>({value:f.id,label:f.name,description:f.provider_id||f.provider,icon:We(f.model||f.name,f.provider_id||f.provider)}))),r=async()=>{a.value=!0;try{const f=await fetch(te("/api/models"));if(f.ok){const b=await f.json();c.value=b.models||[]}}catch(f){console.error("Error fetching models:",f)}finally{a.value=!1}},p=f=>{};return ye(()=>{r()}),ie(()=>i.allowMultiple,()=>{i.allowMultiple&&typeof s.value=="string"?s.value=s.value?[s.value]:[]:!i.allowMultiple&&Array.isArray(s.value)&&(s.value=s.value[0]||"")}),(f,b)=>(o(),l(ce,null,[t.allowMultiple?(o(),Q(lt,{key:0,modelValue:s.value,"onUpdate:modelValue":b[0]||(b[0]=n=>s.value=n),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search models...",error:t.error,required:t.required,disabled:t.disabled,options:u.value,loading:a.value,"add-label":"Add another model",onRemoveItem:p},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(o(),Q(ge,{key:1,modelValue:s.value,"onUpdate:modelValue":b[1]||(b[1]=n=>s.value=n),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search models...",options:u.value,disabled:t.disabled,loading:a.value},null,8,["modelValue","label","placeholder","options","disabled","loading"])),!t.allowMultiple&&t.error?(o(),l("p",y1,V(t.error),1)):M("",!0)],64))}}),w1={class:"space-y-4"},_1={key:0},$1={key:1},C1=["value"],V1={key:0,class:"mt-1 text-xs text-red-500"},S1={key:1,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},T1={class:"px-1 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded"},M1={key:2,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},I1={key:2},L1={key:3},E1={class:"flex justify-end gap-2"},A1=["disabled"],P1=se({__name:"ModelModal",props:{modelValue:{type:Boolean},editModel:{},mode:{default:"add"}},emits:["update:modelValue","save"],setup(t,{emit:i}){const s=t,c=i,a=v([]),u=v(""),r=v(""),p=v([]),f=v(!1),b=v(!1),n=v([]),d=v([]),h=v(!1),$=v([]),g=z(()=>s.mode==="edit"),m=v(""),C=v(""),w=v(""),E=y=>{let k=y.replace(/[^a-zA-Z0-9\s_-]/g,"");return k=k.trim().toLowerCase().replace(/[\s-]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),k?/^[a-z][a-z0-9_]*$/.test(k)?w.value="":w.value="Name must start with a letter and contain only lowercase letters, numbers, and underscores":w.value="Name is required",k},A=y=>{const k=y.target.value;C.value=E(k)},q=v(!1),J=v(null),X=z(()=>a.value.filter(y=>y.hasApiKey).map(y=>({value:y.name,label:y.name,description:y.sdk==="openai-sdk"?"OpenAI SDK":y.sdk==="openrouter"?"OpenRouter":y.sdk,icon:at(y.sdk)}))),P=z(()=>p.value.map(y=>({...y,icon:y.iconId?at(y.iconId):void 0}))),_=z(()=>!g.value||!J.value||q.value?!1:C.value!==J.value.name||u.value!==J.value.provider||r.value!==J.value.model||JSON.stringify(d.value.sort())!==JSON.stringify(J.value.endpoints.sort())||JSON.stringify($.value)!==JSON.stringify(J.value.fallbacks)),O=z(()=>a.value.find(k=>k.name===u.value)?.sdk==="openrouter"),D=async()=>{f.value=!0;try{const y=await fetch(te("/api/providers"));if(y.ok){const k=await y.json();a.value=k.providers||[]}}catch(y){console.error("Error fetching providers:",y)}finally{f.value=!1}},N=async()=>{if(!u.value){p.value=[];return}b.value=!0;try{const y=await fetch(te("/api/models/available"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:u.value})});if(y.ok){const k=await y.json();p.value=k.models||[]}else{const k=await y.json();console.error("Error fetching models:",k),p.value=[],alert(k.error||"Failed to fetch available models")}}catch(y){console.error("Error fetching models:",y),p.value=[]}finally{b.value=!1}},U=()=>{C.value="",m.value="",u.value="",r.value="",p.value=[],$.value=[],n.value=[],d.value=[],J.value=null,q.value=!1},L=async()=>{if(s.editModel){q.value=!0;try{await D(),C.value=s.editModel.name||"",m.value=s.editModel.name||"",u.value=s.editModel.provider_id||s.editModel.provider,await N(),r.value=s.editModel.model,await j(),s.editModel.included_providers&&s.editModel.included_providers.length>0&&(d.value=s.editModel.included_providers),await T(),J.value={name:C.value,provider:u.value,model:r.value,endpoints:[...d.value],fallbacks:[...$.value]}}finally{q.value=!1}}};ie(()=>s.modelValue,async y=>{y?g.value&&s.editModel?await L():(await D(),U()):U()});const T=async()=>{if(s.editModel?.id){if(s.editModel.fallbacks&&Array.isArray(s.editModel.fallbacks)){$.value=s.editModel.fallbacks.map(y=>typeof y=="string"?y:y.id);return}try{const y=await fetch(te(`/api/models/${s.editModel.id}/fallbacks`));if(y.ok){const k=await y.json();$.value=k.fallbacks.map(R=>R.fallback_model_id)}}catch(y){console.error("Error loading fallbacks:",y)}}};ie(u,async(y,k)=>{q.value||g.value&&!k&&y===(s.editModel?.provider_id||s.editModel?.provider)||(r.value="",n.value=[],d.value=[],u.value&&await N())});const j=async()=>{if(!r.value||!u.value){n.value=[];return}const y=a.value.find(R=>R.name===u.value);if(!y||y.sdk!=="openrouter"){n.value=[];return}const k=P.value.find(R=>R.value===r.value);if(!k?.slug){console.error("Model slug not found"),n.value=[];return}h.value=!0;try{const R=await fetch(te("/api/models/endpoints"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:u.value,modelSlug:k.slug})});if(R.ok){const K=await R.json();n.value=K.endpoints||[],g.value||(d.value=n.value.map(H=>H.id))}else{const K=await R.json();console.error("Error fetching endpoints:",K),n.value=[]}}catch(R){console.error("Error fetching endpoints:",R),n.value=[]}finally{h.value=!1}};ie(r,async(y,k)=>{q.value||g.value&&!k&&y===s.editModel?.model||(r.value?(await j(),k&&y!==k&&(d.value=n.value.map(R=>R.id))):(n.value=[],d.value=[]))});const S=()=>{if(!u.value||!r.value){alert("Please select a provider and model");return}if(!C.value){alert("Please enter a name for the model");return}if(w.value){alert(w.value);return}const y=O.value?d.value:[],k={name:C.value,model:r.value,provider:u.value,included_providers:y,fallbacks:$.value};g.value&&s.editModel?.id&&(k.id=s.editModel.id,m.value&&m.value!==C.value&&(k.originalName=m.value)),c("save",k)},x=()=>{U(),c("update:modelValue",!1)};return(y,k)=>(o(),Q(Ae,{"model-value":t.modelValue,"onUpdate:modelValue":k[4]||(k[4]=R=>y.$emit("update:modelValue",R)),title:g.value?"Edit Model":"Add Model",width:"max-w-2xl","min-height":"min-h-[36rem]","has-changes":_.value},{footer:de(()=>[e("div",E1,[e("button",{onClick:x,type:"button",class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors"}," Cancel "),e("button",{onClick:S,type:"button",class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity",disabled:!u.value||!r.value},V(g.value?"Update Model":"Add Model"),9,A1)])]),default:de(()=>[e("div",w1,[I(ge,{modelValue:u.value,"onUpdate:modelValue":k[0]||(k[0]=R=>u.value=R),options:X.value,label:"Provider",placeholder:"Select a provider",disabled:f.value||g.value&&!!s.editModel},null,8,["modelValue","options","disabled"]),u.value?(o(),l("div",_1,[I(ge,{modelValue:r.value,"onUpdate:modelValue":k[1]||(k[1]=R=>r.value=R),options:P.value,label:"Model",placeholder:"Select a model","search-placeholder":"Search models...",loading:b.value},null,8,["modelValue","options","loading"])])):M("",!0),r.value?(o(),l("div",$1,[k[6]||(k[6]=e("label",{class:"block text-sm font-medium mb-2"},"Name",-1)),e("input",{value:C.value,onInput:A,type:"text",class:oe(["w-full px-3 py-2 text-sm border rounded bg-white dark:bg-neutral-800 text-neutral-900 dark:text-neutral-100 focus:ring-2 focus:ring-accent-500 focus:border-transparent",w.value?"border-red-500":"border-neutral-300 dark:border-neutral-600"]),placeholder:"e.g., coding_model, planning_model, fast_response"},null,42,C1),w.value?(o(),l("p",V1,V(w.value),1)):C.value?(o(),l("p",S1,[k[5]||(k[5]=ke(" Will be saved as: ",-1)),e("code",T1,V(C.value),1)])):(o(),l("p",M1," A descriptive name for this model (e.g., coding_model, planning_model). This becomes the filename and reference ID. "))])):M("",!0),r.value&&O.value?(o(),l("div",I1,[k[7]||(k[7]=e("label",{class:"block text-sm font-medium mb-2"}," Available Providers ",-1)),I(x1,{modelValue:d.value,"onUpdate:modelValue":k[2]||(k[2]=R=>d.value=R),providers:n.value,loading:h.value},null,8,["modelValue","providers","loading"]),k[8]||(k[8]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Select which providers can be used for this model ",-1))])):M("",!0),r.value?(o(),l("div",L1,[I(k1,{modelValue:$.value,"onUpdate:modelValue":k[3]||(k[3]=R=>$.value=R),label:"Fallback Models",placeholder:"Add fallback model...","allow-multiple":!0},null,8,["modelValue"]),k[9]||(k[9]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Fallback models will be used in order if the primary model fails ",-1))])):M("",!0)])]),_:1},8,["model-value","title","has-changes"]))}}),O1={class:"flex justify-between items-center mb-6"},j1={class:"flex items-center gap-2"},D1=["src","alt"],U1={class:"text-sm text-neutral-600 dark:text-neutral-400 font-mono"},N1={key:0,class:"space-y-0.5"},R1=["title"],B1={class:"shrink-0 font-mono pr-2"},q1=["src","alt"],F1={class:"truncate"},z1={key:1,class:"text-neutral-400 dark:text-neutral-600 text-sm"},H1=se({__name:"ModelsView",setup(t){const i=v(!1),s=v([]),c=v(!1),a=v(null),u=v("add"),r=[{key:"name",label:"Name",width:"w-1/4"},{key:"model",label:"Model",width:"w-1/4"},{key:"provider",label:"Provider",width:"w-1/4"},{key:"fallbacks",label:"Fallbacks",width:"w-1/4"}],p=[{icon:"edit",label:"Edit",handler:d=>{a.value=d,u.value="edit",i.value=!0}},{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this model? This action cannot be undone.",handler:async d=>{await n(d.id)}}],f=async()=>{c.value=!0;try{const d=await fetch(te("/api/models"));if(!d.ok)throw new Error("Failed to fetch models");const h=await d.json();s.value=h.models||[]}catch(d){console.error("Error fetching models:",d),s.value=[]}finally{c.value=!1}},b=async d=>{try{if(a.value){const{originalName:h,...$}=d,g=h||a.value.id,m=await fetch(te(`/api/models/${g}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify($)});if(!m.ok){const C=await m.json();alert(C.error||"Failed to update model");return}}else{const h=await fetch(te("/api/models"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)});if(!h.ok){const $=await h.json();alert($.error||"Failed to add model");return}}await f(),i.value=!1,a.value=null,u.value="add"}catch(h){console.error("Error saving model:",h),alert("Failed to save model")}},n=async d=>{try{const h=await fetch(te(`/api/models/${d}`),{method:"DELETE"});if(!h.ok){const $=await h.json();alert($.error||"Failed to delete model");return}await f()}catch(h){console.error("Error deleting model:",h),alert("Failed to delete model")}};return ye(()=>{f()}),(d,h)=>(o(),Q(ze,null,{default:de(()=>[e("div",O1,[h[3]||(h[3]=e("h1",{class:"text-3xl font-bold"},"Models",-1)),e("button",{onClick:h[0]||(h[0]=()=>{u.value="add",a.value=null,i.value=!0}),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Add Model ")]),h[4]||(h[4]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-8"}," Configure AI models from your connected providers. Models define which AI capabilities are available to your agents. ",-1)),I(Ne,{columns:r,data:s.value,actions:p,loading:c.value,"empty-message":"No models configured yet. Add your first model to get started."},{"cell-name":de(({value:$,row:g})=>[e("div",j1,[F(We)(g.model,g.provider)?(o(),l("img",{key:0,src:F(We)(g.model,g.provider),class:"w-5 h-5 shrink-0",alt:g.provider},null,8,D1)):M("",!0),e("span",null,V($),1)])]),"cell-model":de(({value:$})=>[e("span",U1,V($||"—"),1)]),"cell-fallbacks":de(({value:$})=>[$&&$.length>0?(o(),l("div",N1,[(o(!0),l(ce,null,fe($,(g,m)=>(o(),l("div",{key:g.id,class:"text-sm text-neutral-600 dark:text-neutral-400 flex items-center",title:g.name},[e("span",B1,V(m===$.length-1?"└─":"├─"),1),F(We)(g.model,g.provider)?(o(),l("img",{key:0,src:F(We)(g.model,g.provider),class:"w-4 h-4 shrink-0 mr-1.5",alt:g.provider},null,8,q1)):M("",!0),e("span",F1,V(g.name),1)],8,R1))),128))])):(o(),l("span",z1," None "))]),_:1},8,["data","loading"]),I(P1,{modelValue:i.value,"onUpdate:modelValue":[h[1]||(h[1]=$=>i.value=$),h[2]||(h[2]=$=>{i.value=$,$||(a.value=null,u.value="add")})],"edit-model":a.value,mode:u.value,onSave:b},null,8,["modelValue","edit-model","mode"])]),_:1}))}}),W1={class:"space-y-4"},J1={class:"space-y-1"},Z1={class:"relative"},K1={key:0,class:"flex items-center gap-2"},G1=["src","alt"],X1={key:1,class:"text-neutral-500"},Y1={key:0,class:"absolute z-10 w-full mt-1 bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded shadow-lg"},Q1=["onClick"],em=["src","alt"],tm={key:0,class:"text-xs text-red-500 dark:text-red-400"},om=se({__name:"AddProviderModal",props:{modelValue:{type:Boolean}},emits:["update:modelValue","save"],setup(t,{emit:i}){const s=i,c=v({name:"",type:"",apiKey:"",baseUrl:""}),a=[{value:"openai",label:"OpenAI",icon:ft,sdk:"openai-sdk"},{value:"openrouter",label:"OpenRouter",icon:Yt,sdk:"openrouter"}],u=v(!1),r=z(()=>a.find(g=>g.value===c.value.type)),p=()=>{setTimeout(()=>{u.value=!1},200)},f=v({});ie(()=>c.value.type,g=>{if(g&&!c.value.name){const m=a.find(C=>C.value===g);m&&(c.value.name=m.label)}});const b=z(()=>c.value.type==="custom"||c.value.type==="openai"),n=()=>{f.value={};let g=!0;return c.value.name||(f.value.name="Provider name is required",g=!1),c.value.type||(f.value.type="Provider type is required",g=!1),c.value.apiKey||(f.value.apiKey="API key is required",g=!1),b.value&&c.value.type==="custom"&&!c.value.baseUrl&&(f.value.baseUrl="Base URL is required for custom providers",g=!1),g},d=()=>{n()&&(s("save",{...c.value}),$(),s("update:modelValue",!1))},h=()=>{$(),s("update:modelValue",!1)},$=()=>{c.value={name:"",type:"",apiKey:""},f.value={}};return(g,m)=>(o(),Q(Ae,{"model-value":t.modelValue,"onUpdate:modelValue":m[4]||(m[4]=C=>g.$emit("update:modelValue",C)),title:"Add Provider",width:"max-w-md"},{footer:de(()=>[e("div",{class:"flex gap-2 justify-end"},[e("button",{onClick:h,class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors"}," Cancel "),e("button",{onClick:d,class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Add Provider ")])]),default:de(()=>[e("div",W1,[e("div",J1,[m[6]||(m[6]=e("label",{class:"block text-sm font-medium"},[ke(" Provider Type "),e("span",{class:"text-red-500"},"*")],-1)),e("div",Z1,[e("button",{type:"button",onClick:m[0]||(m[0]=C=>u.value=!u.value),onBlur:p,class:oe(["w-full px-3 py-2 bg-white dark:bg-black border rounded font-mono text-sm text-left focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white transition-colors",[f.value.type?"border-red-500 dark:border-red-400":"border-black dark:border-neutral-300"]])},[r.value?(o(),l("div",K1,[e("img",{src:r.value.icon,alt:r.value.label,class:"w-5 h-5"},null,8,G1),e("span",null,V(r.value.label),1)])):(o(),l("span",X1,"Select a provider")),m[5]||(m[5]=e("div",{class:"absolute inset-y-0 right-0 flex items-center px-2 pointer-events-none"},[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 9l-7 7-7-7"})])],-1))],34),u.value?(o(),l("div",Y1,[(o(),l(ce,null,fe(a,C=>e("button",{key:C.value,type:"button",onClick:w=>{c.value.type=C.value,u.value=!1},class:"w-full px-3 py-2 text-left hover:bg-black/5 dark:hover:bg-white/10 transition-colors flex items-center gap-2"},[e("img",{src:C.icon,alt:C.label,class:"w-5 h-5"},null,8,em),e("span",null,V(C.label),1)],8,Q1)),64))])):M("",!0)]),f.value.type?(o(),l("p",tm,V(f.value.type),1)):M("",!0)]),I(Ce,{modelValue:c.value.name,"onUpdate:modelValue":m[1]||(m[1]=C=>c.value.name=C),label:"Provider Name",placeholder:"e.g., My OpenAI Provider",error:f.value.name,required:""},null,8,["modelValue","error"]),I(Ce,{modelValue:c.value.apiKey,"onUpdate:modelValue":m[2]||(m[2]=C=>c.value.apiKey=C),label:"API Key",type:"password",placeholder:"sk-...",error:f.value.apiKey,required:""},null,8,["modelValue","error"]),b.value?(o(),Q(Ce,{key:0,modelValue:c.value.baseUrl,"onUpdate:modelValue":m[3]||(m[3]=C=>c.value.baseUrl=C),label:"Base URL",placeholder:"https://api.example.com",error:f.value.baseUrl,required:c.value.type==="custom"},null,8,["modelValue","error","required"])):M("",!0)])]),_:1},8,["model-value"]))}}),am={class:"flex justify-between items-center mb-6"},lm=se({__name:"ProvidersView",setup(t){const i=v(!1),s=v([]),c=v(!1),a=[{key:"name",label:"Name",width:"w-1/3"},{key:"sdk",label:"SDK Type",width:"w-1/3",formatter:b=>({"openai-sdk":"OpenAI SDK",openrouter:"OpenRouter",openai:"OpenAI"})[b]||b},{key:"hasApiKey",label:"API Key",width:"w-1/3",formatter:b=>b?"✓ Configured":"✗ Not configured"}],u=[{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this provider? This action cannot be undone.",handler:async b=>{await f(b.name)}}],r=async()=>{c.value=!0;try{const b=await fetch(te("/api/providers"));if(!b.ok)throw new Error("Failed to fetch providers");const n=await b.json();s.value=n.providers||[]}catch(b){console.error("Error fetching providers:",b),s.value=[]}finally{c.value=!1}},p=async b=>{try{const n=await fetch(te("/api/providers"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!n.ok){const d=await n.json();alert(d.error||"Failed to add provider");return}await r(),i.value=!1}catch(n){console.error("Error adding provider:",n),alert("Failed to add provider")}},f=async b=>{try{const n=await fetch(te(`/api/providers/${encodeURIComponent(b)}`),{method:"DELETE"});if(!n.ok){const d=await n.json();d.modelCount?alert(`${d.error}
1
+ import{m as _e,c as a,o,a as e,r as v,d as se,b as xe,e as Be,w as ue,n as pt,f as He,g as ge,h as K,u as ze,i as le,j as L,k as ee,l as Z,F as pe,p as fe,q as E,s as we,t as de,v as et,x as it,y as C,R as Tt,z as ye,T as _t,A as We,B as Se,C as Oe,D as go,E as Ee,L as qt,G as $t,H as mt,I as vt,J as bo,K as xo,P as bt,M as Mt,N as yo,O as Ft,Q as ko,S as Ye,U as zt,V as wo,W as _o,X as xt,Y as Ne,Z as Je,_ as $o,$ as Co,a0 as Ht,a1 as Wt,a2 as Vo,a3 as So,a4 as To,a5 as Mo,a6 as Lo}from"./vue.js";import{f as Io}from"./vendor.js";import{W as Eo,a as Ao,e as Lt}from"./monaco.js";(function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))u(l);new MutationObserver(l=>{for(const c of l)if(c.type==="childList")for(const r of c.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&u(r)}).observe(document,{childList:!0,subtree:!0});function n(l){const c={};return l.integrity&&(c.integrity=l.integrity),l.referrerPolicy&&(c.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?c.credentials="include":l.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function u(l){if(l.ep)return;l.ep=!0;const c=n(l);fetch(l.href,c)}})();const Po={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Oo(t,i){return o(),a("svg",Po,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M12 8V4H8"}),e("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),e("path",{d:"M2 14h2m16 0h2m-7-1v2m-6-2v2"})],-1)])])}const It=_e({name:"lucide-bot",render:Oo}),jo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Do(t,i){return o(),a("svg",jo,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"},null,-1)])])}const Et=_e({name:"lucide-message-square",render:Do}),Uo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ro(t,i){return o(),a("svg",Uo,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M12 20v2m0-20v2m5 16v2m0-20v2M2 12h2m-2 5h2M2 7h2m16 5h2m-2 5h2M20 7h2M7 20v2M7 2v2"}),e("rect",{width:"16",height:"16",x:"4",y:"4",rx:"2"}),e("rect",{width:"8",height:"8",x:"8",y:"8",rx:"1"})],-1)])])}const No=_e({name:"lucide-cpu",render:Ro}),Bo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function qo(t,i){return o(),a("svg",Bo,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e("path",{d:"M6 6h.01M6 18h.01"})],-1)])])}const Fo=_e({name:"lucide-server",render:qo}),zo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ho(t,i){return o(),a("svg",zo,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z"},null,-1)])])}const Wo=_e({name:"lucide-wrench",render:Ho}),Jo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Zo(t,i){return o(),a("svg",Jo,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0a2.34 2.34 0 0 0 3.319 1.915a2.34 2.34 0 0 1 2.33 4.033a2.34 2.34 0 0 0 0 3.831a2.34 2.34 0 0 1-2.33 4.033a2.34 2.34 0 0 0-3.319 1.915a2.34 2.34 0 0 1-4.659 0a2.34 2.34 0 0 0-3.32-1.915a2.34 2.34 0 0 1-2.33-4.033a2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}),e("circle",{cx:"12",cy:"12",r:"3"})],-1)])])}const Ko=_e({name:"lucide-settings",render:Zo}),Go={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Xo(t,i){return o(),a("svg",Go,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m15 18l-6-6l6-6"},null,-1)])])}const Yo=_e({name:"lucide-chevron-left",render:Xo}),Qo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function el(t,i){return o(),a("svg",Qo,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("circle",{cx:"12",cy:"12",r:"4"}),e("path",{d:"M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"})],-1)])])}const tl=_e({name:"lucide-sun",render:el}),ol={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ll(t,i){return o(),a("svg",ol,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"},null,-1)])])}const al=_e({name:"lucide-moon",render:ll}),sl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function nl(t,i){return o(),a("svg",sl,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"},null,-1)])])}const rl=_e({name:"lucide-activity",render:nl}),il={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function dl(t,i){return o(),a("svg",il,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),e("path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3m-6 4.2h5.7"})],-1)])])}const ul=_e({name:"lucide-function-square",render:dl}),cl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function pl(t,i){return o(),a("svg",cl,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m16 17l5-5l-5-5m5 5H9m0 9H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"},null,-1)])])}const ml=_e({name:"lucide-log-out",render:pl}),vl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function fl(t,i){return o(),a("svg",vl,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2M16 3.128a4 4 0 0 1 0 7.744M22 21v-2a4 4 0 0 0-3-3.87"}),e("circle",{cx:"9",cy:"7",r:"4"})],-1)])])}const hl=_e({name:"lucide-users",render:fl}),gl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function bl(t,i){return o(),a("svg",gl,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"m15.5 7.5l2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4m2-2l-9.6 9.6"}),e("circle",{cx:"7.5",cy:"15.5",r:"5.5"})],-1)])])}const xl=_e({name:"lucide-key",render:bl}),yl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function kl(t,i){return o(),a("svg",yl,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 7v14m-9-3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4a4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3a3 3 0 0 0-3-3z"},null,-1)])])}const wl=_e({name:"lucide-book-open",render:kl}),_l={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function $l(t,i){return o(),a("svg",_l,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 3h6v6m-11 5L21 3m-3 10v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"},null,-1)])])}const Cl=_e({name:"lucide-external-link",render:$l}),Jt="agentbuilder-accent-theme",Zt=["amber","lime","emerald","sky","blue","indigo","purple","fuchsia","pink","white"],yt=v("purple");let At=!1;function Kt(t){typeof document>"u"||(t==="purple"?delete document.documentElement.dataset.accent:document.documentElement.dataset.accent=t)}function Vl(t){try{localStorage.setItem(Jt,t)}catch{}}function Sl(){try{const t=localStorage.getItem(Jt);if(t&&Zt.includes(t))return t}catch{}return"purple"}function Gt(){if(At)return;At=!0;const t=Sl();yt.value=t,Kt(t)}function Tl(){Gt();function t(i){yt.value=i,Kt(i),Vl(i)}return{theme:yt,themes:Zt,setTheme:t}}const tt=se({__name:"DropShadow",props:{offsetX:{default:8},offsetY:{default:8},intensity:{default:.5},pattern:{default:"crosshatch"}},setup(t){const i=t,n=v(),u=v(),l=v(),c=v(0),r=(s,d,h,$,g,m)=>{s.beginPath(),s.moveTo(d+m,h),s.lineTo(d+$-m,h),s.quadraticCurveTo(d+$,h,d+$,h+m),s.lineTo(d+$,h+g-m),s.quadraticCurveTo(d+$,h+g,d+$-m,h+g),s.lineTo(d+m,h+g),s.quadraticCurveTo(d,h+g,d,h+g-m),s.lineTo(d,h+m),s.quadraticCurveTo(d,h,d+m,h),s.closePath()},p=async()=>{if(await ge(),!n.value||!u.value||!l.value)return;const s=n.value.getContext("2d");if(!s)return;const d=l.value.getBoundingClientRect(),h=l.value.firstElementChild;if(h){const w=getComputedStyle(h);c.value=parseFloat(w.borderRadius)||0}const $=d.width+i.offsetX+4,g=d.height+i.offsetY+4;n.value.width=$,n.value.height=g,n.value.style.width=`${$}px`,n.value.style.height=`${g}px`,s.clearRect(0,0,n.value.width,n.value.height);const m=document.documentElement.classList.contains("dark");if(s.fillStyle=m?"#6b7280":"black",s.globalAlpha=i.intensity,s.save(),r(s,i.offsetX,i.offsetY,d.width,d.height,c.value),s.clip(),i.pattern==="crosshatch"){const w=m?4:3;s.lineWidth=1,s.strokeStyle=m?"#6b7280":"black";for(let k=-d.height;k<d.width;k+=w)s.beginPath(),s.moveTo(i.offsetX+k,i.offsetY),s.lineTo(i.offsetX+k+d.height,i.offsetY+d.height),s.stroke();for(let k=0;k<d.width+d.height;k+=w)s.beginPath(),s.moveTo(i.offsetX+k,i.offsetY+d.height),s.lineTo(i.offsetX+k-d.height,i.offsetY),s.stroke()}else if(i.pattern==="dots"){const k=m?3:2,O=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];for(let D=0;D<d.width;D+=k)for(let F=0;F<d.height;F+=k){const X=Math.floor(D/k)%4,te=Math.floor(F/k)%4;O[te][X]/16<i.intensity&&s.fillRect(i.offsetX+D,i.offsetY+F,1,1)}}else if(i.pattern==="diagonal"){const w=m?5:4;s.lineWidth=1,s.strokeStyle=m?"#6b7280":"black";for(let k=-d.height;k<d.width;k+=w)s.beginPath(),s.moveTo(i.offsetX+k,i.offsetY),s.lineTo(i.offsetX+k+d.height,i.offsetY+d.height),s.stroke()}s.restore()};let f=null,b=null;return xe(()=>{f=new ResizeObserver(()=>{p()}),l.value&&f.observe(l.value),p(),b=new MutationObserver(()=>{p()}),b.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]})}),Be(()=>{l.value&&f&&f.unobserve(l.value),b&&b.disconnect()}),ue(()=>[i.offsetX,i.offsetY,i.intensity,i.pattern],()=>{p()}),(s,d)=>(o(),a("div",{ref_key:"container",ref:u,class:"relative",style:pt({paddingRight:`${t.offsetX}px`,paddingBottom:`${t.offsetY}px`})},[e("canvas",{ref_key:"canvas",ref:n,class:"absolute top-0 left-0 pointer-events-none"},null,512),e("div",{ref_key:"contentEl",ref:l,class:"relative"},[He(s.$slots,"default")],512)],4))}}),Xt="/agents/assets/img/agent-builder-logo-light.svg",Yt="/agents/assets/img/agent-builder-logo-dark.svg",Ml="data:image/svg+xml,%3csvg%20width='100%25'%20height='100%25'%20viewBox='0%200%20150%20150'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20xmlns:serif='http://www.serif.com/'%20style='fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;'%3e%3cg%20id='Artboard1'%20transform='matrix(1,0,0,1,1,1)'%3e%3crect%20x='-1'%20y='-1'%20width='150'%20height='150'%20style='fill:none;'/%3e%3cg%20transform='matrix(1.034881,0,0,1.034881,4.124225,0)'%3e%3cpath%20d='M133.816,92.912L108.064,59.193C103.573,53.307%20101.473,45.937%20102.197,38.566L105.475,5.046L99.553,4.466L96.312,37.643C95.895,41.808%2091.44,44.27%2087.71,42.369L30.34,13.394L27.659,18.7L84.686,47.494C87.184,48.762%2087.076,52.347%2084.504,53.452L0.387,89.671L2.741,95.139L86.189,59.211C88.76,58.106%2091.422,60.587%2090.48,63.231L62.918,141.119L68.532,143.111L96.384,64.408C97.507,61.257%20101.672,60.605%20103.7,63.249L129.107,96.498L133.834,92.876L133.816,92.912Z'%20style='fill:rgb(31,41,55);fill-opacity:0.5;fill-rule:nonzero;'/%3e%3c/g%3e%3cg%20transform='matrix(1.034881,0,0,1.034881,4.124225,0)'%3e%3cpath%20d='M133.925,90.214L107.648,7.346C106.036,2.257%20100.875,-0.821%2095.624,0.193L32.64,12.344C29.959,12.869%2027.605,14.408%2026.066,16.6C25.523,17.36%2025.07,18.211%2024.744,19.117L0.622,86.284C-0.917,90.594%200.459,95.375%204.081,98.164L59.568,141.137C61.469,142.604%2063.733,143.346%2066.015,143.346C68.079,143.346%2070.144,142.731%2071.937,141.517L129.832,102.111C133.707,99.468%20135.355,94.687%20133.943,90.232L133.925,90.214ZM116.92,85.922L47.127,53.923C44.374,52.673%2043.994,48.925%2046.421,47.132L94.175,11.873C97.416,9.483%20102.034,10.95%20103.284,14.771C108.173,29.548%20118.64,62.054%20124.218,79.457C125.631,83.876%20121.121,87.859%20116.902,85.94L116.92,85.922ZM79.162,15.567L42.455,42.659C40.083,44.415%2036.696,43.057%2036.189,40.16L33.781,26.342C33.038,22.05%2035.845,17.94%2040.119,17.089C49.409,15.241%2065.254,12.145%2076.681,9.917C79.995,9.265%2081.879,13.557%2079.162,15.567ZM29.126,34.238L31.716,49.069C31.915,50.21%2031.607,51.388%2030.865,52.275L16.559,69.587C15.291,71.127%2012.846,69.732%2013.516,67.849L25.704,33.93C26.32,32.21%2028.8,32.427%2029.126,34.22L29.126,34.238ZM12.882,83.386L29.543,63.231C31.517,60.84%2035.356,61.547%2036.352,64.499L56.308,123.661C57.322,126.668%2053.809,129.149%2051.31,127.193C41.223,119.297%2024.4,106.132%2014.404,98.164C9.84,94.542%209.152,87.878%2012.864,83.386L12.882,83.386ZM63.498,126.305L43.161,66.002C42.056,62.706%2045.407,59.681%2048.576,61.13L117.337,92.677C121.375,94.524%20121.864,100.083%20118.206,102.6C107.358,110.061%2088.326,123.064%2076.826,130.815C71.991,134.074%2065.381,131.829%2063.516,126.305L63.498,126.305Z'%20style='fill:rgb(31,41,55);fill-rule:nonzero;'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",Ll="data:image/svg+xml,%3csvg%20width='100%25'%20height='100%25'%20viewBox='0%200%20150%20150'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20xmlns:serif='http://www.serif.com/'%20style='fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;'%3e%3cg%20id='Artboard1'%20transform='matrix(1,0,0,1,1,1)'%3e%3crect%20x='-1'%20y='-1'%20width='150'%20height='150'%20style='fill:none;'/%3e%3cg%20transform='matrix(1.034881,0,0,1.034881,4.124225,0)'%3e%3cpath%20d='M133.816,92.912L108.064,59.193C103.573,53.307%20101.473,45.937%20102.197,38.566L105.475,5.046L99.553,4.466L96.312,37.643C95.895,41.808%2091.44,44.27%2087.71,42.369L30.34,13.394L27.659,18.7L84.686,47.494C87.184,48.762%2087.076,52.347%2084.504,53.452L0.387,89.671L2.741,95.139L86.189,59.211C88.76,58.106%2091.422,60.587%2090.48,63.231L62.918,141.119L68.532,143.111L96.384,64.408C97.507,61.257%20101.672,60.605%20103.7,63.249L129.107,96.498L133.834,92.876L133.816,92.912Z'%20style='fill:rgb(249,250,251);fill-opacity:0.5;fill-rule:nonzero;'/%3e%3c/g%3e%3cg%20transform='matrix(1.034881,0,0,1.034881,4.124225,0)'%3e%3cpath%20d='M133.925,90.214L107.648,7.346C106.036,2.257%20100.875,-0.821%2095.624,0.193L32.64,12.344C29.959,12.869%2027.605,14.408%2026.066,16.6C25.523,17.36%2025.07,18.211%2024.744,19.117L0.622,86.284C-0.917,90.594%200.459,95.375%204.081,98.164L59.568,141.137C61.469,142.604%2063.733,143.346%2066.015,143.346C68.079,143.346%2070.144,142.731%2071.937,141.517L129.832,102.111C133.707,99.468%20135.355,94.687%20133.943,90.232L133.925,90.214ZM116.92,85.922L47.127,53.923C44.374,52.673%2043.994,48.925%2046.421,47.132L94.175,11.873C97.416,9.483%20102.034,10.95%20103.284,14.771C108.173,29.548%20118.64,62.054%20124.218,79.457C125.631,83.876%20121.121,87.859%20116.902,85.94L116.92,85.922ZM79.162,15.567L42.455,42.659C40.083,44.415%2036.696,43.057%2036.189,40.16L33.781,26.342C33.038,22.05%2035.845,17.94%2040.119,17.089C49.409,15.241%2065.254,12.145%2076.681,9.917C79.995,9.265%2081.879,13.557%2079.162,15.567ZM29.126,34.238L31.716,49.069C31.915,50.21%2031.607,51.388%2030.865,52.275L16.559,69.587C15.291,71.127%2012.846,69.732%2013.516,67.849L25.704,33.93C26.32,32.21%2028.8,32.427%2029.126,34.22L29.126,34.238ZM12.882,83.386L29.543,63.231C31.517,60.84%2035.356,61.547%2036.352,64.499L56.308,123.661C57.322,126.668%2053.809,129.149%2051.31,127.193C41.223,119.297%2024.4,106.132%2014.404,98.164C9.84,94.542%209.152,87.878%2012.864,83.386L12.882,83.386ZM63.498,126.305L43.161,66.002C42.056,62.706%2045.407,59.681%2048.576,61.13L117.337,92.677C121.375,94.524%20121.864,100.083%20118.206,102.6C107.358,110.061%2088.326,123.064%2076.826,130.815C71.991,134.074%2065.381,131.829%2063.516,126.305L63.498,126.305Z'%20style='fill:rgb(249,250,251);fill-rule:nonzero;'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e";function Il(){return window.__AGENTBUILDER_CONFIG__||{mountPoint:"/agentbuilder"}}function ot(){return Il().mountPoint}function ae(t){const i=ot(),n=t.startsWith("/")?t:`/${t}`;return i==="/"?n:`${i}${n}`}const El=["src"],Al=["src"],Pl={class:"flex-1 flex flex-col justify-between pt-2 pb-4"},Ol={class:"flex flex-col gap-1 px-2"},jl={key:0},Dl=["onClick","title"],Ul={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis text-left"},Rl={key:0,class:"ml-4 space-y-0.5"},Nl=["onClick"],Bl={class:"whitespace-nowrap overflow-hidden text-ellipsis"},ql=["onClick","title"],Fl={key:0,class:"whitespace-nowrap overflow-hidden text-ellipsis"},zl={class:"flex flex-col gap-1 px-2"},Hl=["title"],Wl={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis"},Jl={class:"relative settings-menu-container"},Zl={key:0,class:"absolute bottom-full mb-2 left-0 z-50"},Kl={class:"bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-600 rounded-lg py-2 min-w-[200px]"},Gl={class:"px-4 py-3 border-b border-neutral-200 dark:border-neutral-700"},Xl=["title"],Yl={class:"relative z-10 flex items-center justify-center w-8 h-full"},Ql={class:"relative z-10 flex items-center justify-center w-8 h-full"},ea={class:"px-4 pt-3 pb-4 border-b border-neutral-200 dark:border-neutral-700"},ta={class:"grid grid-cols-5 gap-3"},oa=["onClick","title"],la={key:0,class:"w-2 h-2 rounded-full bg-white shadow-sm"},aa={key:0,class:"text-sm overflow-hidden whitespace-nowrap max-w-0 group-hover:max-w-[60px] group-hover:ml-2 transition-all duration-200"},sa=se({__name:"Sidebar",props:{isCollapsed:{type:Boolean},isDark:{type:Boolean}},emits:["toggle-sidebar","toggle-theme"],setup(t,{emit:i}){function n(N){if(N.startsWith("/src/")||N.startsWith("data:"))return N;const U=ot();return U==="/"?N.replace("/agents/","/"):N.replace("/agents/",`${U}/`)}const u=n(Xt),l=n(Yt),c=n(Ml),r=n(Ll),p=t,f=ze(),b=et(),s=K(()=>f.name);function d(N){const U=f.path;return U===N.path||U.startsWith(N.path+"/")}const h=K(()=>p.isDark?l:u),$=K(()=>p.isDark?r:c),g=[{id:"threads",label:"Threads",icon:rl,path:"/threads"},{id:"agents",label:"Agents",icon:It,path:"/agents"},{id:"prompts",label:"Prompts",icon:Et,path:"/prompts"},{id:"tools",label:"Tools",icon:Wo,path:"/tools",hasSubnav:!0,subnav:[{id:"tools-functions",label:"Functions",icon:ul,path:"/tools#functions"},{id:"tools-prompts",label:"Prompts",icon:Et,path:"/tools#prompts"},{id:"tools-agents",label:"Agents",icon:It,path:"/tools#agents"}]},{id:"models",label:"Models",icon:No,path:"/models"},{id:"providers",label:"Providers",icon:Fo,path:"/providers"}],m=N=>{b.push(N)},w=N=>{b.push(N),O.value=!1},k=K(()=>typeof s.value=="string"&&(s.value==="tools"||s.value.startsWith("tools-"))),O=v(!1),{theme:D,themes:F,setTheme:X}=Tl(),te={amber:"bg-amber-500",lime:"bg-lime-500",emerald:"bg-emerald-500",sky:"bg-sky-500",blue:"bg-blue-500",indigo:"bg-indigo-500",purple:"bg-purple-500",fuchsia:"bg-fuchsia-500",pink:"bg-pink-500",white:"bg-neutral-400 dark:bg-neutral-500"},R=K(()=>s.value==="users"||s.value==="api-keys"),j=()=>{O.value=!O.value},W=()=>{localStorage.removeItem("auth_token"),b.push("/login")},B=N=>{const U=N.target;O.value&&!U.closest(".settings-menu-container")&&(O.value=!1)};return xe(()=>{document.addEventListener("click",B)}),Be(()=>{document.removeEventListener("click",B)}),(N,U)=>(o(),a("aside",{class:le(["flex flex-col transition-all duration-300 pt-2.5",t.isCollapsed?"w-16":"w-60"])},[e("div",{class:le(`flex items-center justify-between ${t.isCollapsed?"px-2 py-4":"p-4"}`)},[t.isCollapsed?L("",!0):(o(),a("img",{key:0,src:h.value,alt:"AgentBuilder",class:"h-8 mr-2 mt-0.5"},null,8,El)),e("button",{onClick:U[0]||(U[0]=y=>N.$emit("toggle-sidebar")),class:le(`p-1 rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors ${t.isCollapsed?"m-auto":"border border-black/20 dark:border-white/20 opacity-50 hover:opacity-100"}`),"aria-label":"Toggle sidebar"},[t.isCollapsed?(o(),a("img",{key:1,src:$.value,alt:"AgentBuilder",class:"w-7 h-7 m-auto"},null,8,Al)):(o(),ee(Z(Yo),{key:0,class:"w-5 h-5"}))],2)],2),e("nav",Pl,[e("div",Ol,[(o(),a(pe,null,fe(g,y=>(o(),a(pe,{key:y.id},[y.hasSubnav?(o(),a("div",jl,[e("button",{onClick:x=>m(y.path),class:le(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all w-full",k.value?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10",t.isCollapsed&&"justify-center"]),title:t.isCollapsed?y.label:void 0},[(o(),ee(it(y.icon),{class:"w-5 h-5 flex-shrink-0"})),t.isCollapsed?L("",!0):(o(),a("span",Ul,C(y.label),1))],10,Dl),!t.isCollapsed&&y.subnav?(o(),a("div",Rl,[(o(!0),a(pe,null,fe(y.subnav,x=>(o(),a("button",{key:x.id,onClick:V=>m(x.path),class:le(["flex items-center gap-3 px-3 py-1.5 text-sm transition-all w-full",s.value===x.id?"bg-black text-white dark:bg-white dark:text-black rounded":"hover:underline"])},[(o(),ee(it(x.icon),{class:"w-4 h-4 flex-shrink-0"})),e("span",Bl,C(x.label),1)],10,Nl))),128))])):L("",!0)])):(o(),a("button",{key:1,onClick:x=>m(y.path),class:le(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all",d(y)?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10",t.isCollapsed&&"justify-center"]),title:t.isCollapsed?y.label:void 0},[(o(),ee(it(y.icon),{class:"w-5 h-5 flex-shrink-0"})),t.isCollapsed?L("",!0):(o(),a("span",Fl,C(y.label),1))],10,ql))],64))),64))]),e("div",zl,[e("a",{href:"https://docs.standardagentbuilder.com/",target:"_blank",rel:"noopener noreferrer",class:le(["flex items-center gap-3 px-3 py-2 rounded text-sm transition-all","hover:bg-black/5 dark:hover:bg-white/10 text-neutral-600 dark:text-neutral-400 hover:text-black dark:hover:text-white",t.isCollapsed&&"justify-center"]),title:t.isCollapsed?"Documentation":void 0},[E(Z(wl),{class:"w-5 h-5 flex-shrink-0"}),t.isCollapsed?L("",!0):(o(),a("span",Wl," Docs ")),t.isCollapsed?L("",!0):(o(),ee(Z(Cl),{key:1,class:"w-3 h-3 flex-shrink-0 opacity-50"}))],10,Hl),e("div",{class:le(["flex items-center gap-1 pt-2 mt-1 border-t border-black/10 dark:border-white/10",t.isCollapsed?"flex-col":"justify-between"])},[e("div",Jl,[e("button",{onClick:we(j,["stop"]),class:le(["p-2 rounded transition-colors flex items-center",O.value||R.value?"bg-black/10 dark:bg-white/10 text-black dark:text-white":"hover:bg-black/5 dark:hover:bg-white/10 text-neutral-600 dark:text-neutral-400 hover:text-black dark:hover:text-white"]),title:"Settings"},[E(Z(Ko),{class:"w-5 h-5 flex-shrink-0"})],2),O.value?(o(),a("div",Zl,[E(tt,{"offset-x":6,"offset-y":6,intensity:.4},{default:de(()=>[e("div",Kl,[e("div",Gl,[U[4]||(U[4]=e("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Appearance ",-1)),e("button",{onClick:U[1]||(U[1]=we(y=>N.$emit("toggle-theme"),["stop"])),class:"relative flex items-center h-7 rounded-full bg-neutral-200 dark:bg-neutral-800 hover:bg-neutral-300 dark:hover:bg-neutral-700 transition-colors",title:t.isDark?"Switch to light mode":"Switch to dark mode"},[e("span",{class:le(["absolute top-0.5 h-6 w-8 rounded-full bg-white dark:bg-black shadow-sm transition-transform duration-200",t.isDark?"translate-x-[calc(100%-2px)]":"translate-x-0.5"])},null,2),e("span",Yl,[E(Z(tl),{class:le(["w-4 h-4",t.isDark?"text-neutral-500":"text-black"])},null,8,["class"])]),e("span",Ql,[E(Z(al),{class:le(["w-4 h-4",t.isDark?"text-white":"text-neutral-400"])},null,8,["class"])])],8,Xl)]),e("div",ea,[U[5]||(U[5]=e("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Accent Color ",-1)),e("div",ta,[(o(!0),a(pe,null,fe(Z(F),y=>(o(),a("button",{key:y,onClick:we(x=>Z(X)(y),["stop"]),class:le(["w-6 h-6 rounded-full transition-all flex items-center justify-center ring-1 ring-black/10 dark:ring-white/10",[te[y],Z(D)===y?"ring-2 ring-black/50 dark:ring-white/50":"hover:scale-110"]]),title:y.charAt(0).toUpperCase()+y.slice(1)},[Z(D)===y?(o(),a("span",la)):L("",!0)],10,oa))),128))])]),e("button",{onClick:U[2]||(U[2]=y=>w("/settings/users")),class:le(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",s.value==="users"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[E(Z(hl),{class:"w-4 h-4 flex-shrink-0"}),U[6]||(U[6]=e("span",{class:"whitespace-nowrap"},"Users",-1))],2),e("button",{onClick:U[3]||(U[3]=y=>w("/settings/api-keys")),class:le(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",s.value==="api-keys"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[E(Z(xl),{class:"w-4 h-4 flex-shrink-0"}),U[7]||(U[7]=e("span",{class:"whitespace-nowrap"},"API Keys",-1))],2)])]),_:1})])):L("",!0)]),e("button",{onClick:W,class:"group p-2 rounded hover:bg-red-500/10 transition-colors text-neutral-600 dark:text-neutral-400 hover:text-red-600 dark:hover:text-red-400 flex items-center",title:"Logout"},[E(Z(ml),{class:"w-5 h-5 flex-shrink-0"}),t.isCollapsed?L("",!0):(o(),a("span",aa,"Logout"))])],2)])])],2))}}),na={class:"warning-banner-container"},ra={key:0,class:"warning-banner flex items-center justify-between gap-3 px-4 py-2 bg-amber-50 dark:bg-amber-900/30 border-b border-amber-200 dark:border-amber-800 text-amber-800 dark:text-amber-200 text-sm"},ia={class:"flex items-center gap-2"},da=["onClick"],ua=se({__name:"WarningBanner",setup(t){const i=v([]),n=v(new Set),u=async()=>{if(localStorage.getItem("auth_token"))try{const f=await fetch(ae("/api/diagnostics"));if(f.ok){const b=await f.json();i.value=b.warnings||[]}}catch{}},l=p=>{const f=`${p.type}:${p.details?.name||p.message}`;n.value.add(f)},c=p=>{const f=`${p.type}:${p.details?.name||p.message}`;return!n.value.has(f)},r=p=>{if(p.type==="duplicate_tool_name"){const f=p.details?.sources?.join(" and ")||"multiple sources";return`Duplicate tool name "${p.details?.name}" (defined as both ${f}). This may cause unexpected behavior.`}return p.message};return xe(()=>{u()}),(p,f)=>(o(),a("div",na,[(o(!0),a(pe,null,fe(i.value,b=>(o(),a(pe,{key:`${b.type}:${b.details?.name}`},[c(b)?(o(),a("div",ra,[e("div",ia,[f[0]||(f[0]=e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 flex-shrink-0",viewBox:"0 0 20 20",fill:"currentColor"},[e("path",{"fill-rule":"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z","clip-rule":"evenodd"})],-1)),e("span",null,C(r(b)),1)]),e("button",{onClick:s=>l(b),class:"text-amber-600 dark:text-amber-400 hover:text-amber-800 dark:hover:text-amber-200 p-1",title:"Dismiss"},[...f[1]||(f[1]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor"},[e("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)])],8,da)])):L("",!0)],64))),128))]))}}),ca={key:2,class:"flex-1 overflow-auto my-3 mr-4 border border-neutral-300 dark:border-neutral-700 rounded-xl bg-white dark:bg-neutral-900 flex flex-col"},pa={class:"flex-1 overflow-auto"},ma=se({__name:"App",setup(t){Gt();const i=ze(),n=v(!1),u=v(!1),l=K(()=>i.name!=="login"),c=()=>{n.value=!n.value},r=()=>{u.value=!u.value,u.value?(document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark")):(document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light"))};return xe(()=>{const p=localStorage.getItem("theme");(p==="dark"||!p&&window.matchMedia("(prefers-color-scheme: dark)").matches)&&(u.value=!0,document.documentElement.classList.add("dark"))}),(p,f)=>(o(),a("div",{class:le(["app-container relative flex h-screen font-sans bg-neutral-50/80 text-black dark:bg-black dark:text-white",{"is-dark":u.value}])},[l.value?(o(),ee(sa,{key:0,"is-collapsed":n.value,"is-dark":u.value,onToggleSidebar:c,onToggleTheme:r},null,8,["is-collapsed","is-dark"])):L("",!0),l.value?(o(),a("main",ca,[E(ua),e("div",pa,[E(Z(Tt))])])):(o(),ee(Z(Tt),{key:1}))],2))}}),Ze=(t,i)=>{const n=t.__vccOpts||t;for(const[u,l]of i)n[u]=l;return n},va=Ze(ma,[["__scopeId","data-v-2125e5d3"]]),fa={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ha(t,i){return o(),a("svg",fa,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 11v6m4-6v6m5-11v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"},null,-1)])])}const ga=_e({name:"lucide-trash-2",render:ha}),ba={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function xa(t,i){return o(),a("svg",ba,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e("path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"})],-1)])])}const ya=_e({name:"lucide-edit",render:xa}),ka={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function wa(t,i){return o(),a("svg",ka,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),e("circle",{cx:"12",cy:"12",r:"3"})],-1)])])}const kt=_e({name:"lucide-eye",render:wa}),_a={class:"w-full"},$a={class:"border border-black dark:border-neutral-300 rounded overflow-hidden"},Ca={class:"overflow-x-auto"},Va={class:"w-full"},Sa={class:"border-b border-black dark:border-neutral-300"},Ta={key:0,class:"px-4 py-3 text-right font-medium text-sm"},Ma={key:0},La=["colspan"],Ia={key:1},Ea=["colspan"],Aa=["innerHTML"],Pa={key:0,class:"px-4 py-3 text-right"},Oa={class:"inline-flex gap-1"},ja=["onClick","title"],Fe=se({__name:"DataTable",props:{columns:{},data:{},actions:{},emptyMessage:{default:"No data available"},loading:{type:Boolean,default:!1}},setup(t){const i=c=>{switch(c){case"edit":return ya;case"delete":return ga;case"view":return kt;default:return null}},n=(c,r)=>{const p=c[r.key];return r.formatter?r.formatter(p):p??"-"},u=c=>{switch(c){case"center":return"text-center";case"right":return"text-right";default:return"text-left"}},l=(c,r)=>{if(c.confirm){const p=c.confirmMessage||`Are you sure you want to ${c.label.toLowerCase()}?`;confirm(p)&&c.handler(r)}else c.handler(r)};return(c,r)=>(o(),a("div",_a,[e("div",$a,[e("div",Ca,[e("table",Va,[e("thead",Sa,[e("tr",null,[(o(!0),a(pe,null,fe(t.columns,p=>(o(),a("th",{key:p.key,class:le(["px-4 py-3 font-medium text-sm",u(p.align),p.width||""])},C(p.label),3))),128)),t.actions&&t.actions.length>0?(o(),a("th",Ta," Actions ")):L("",!0)])]),e("tbody",null,[t.loading?(o(),a("tr",Ma,[e("td",{colspan:t.columns.length+(t.actions?1:0),class:"px-4 py-8 text-center text-neutral-500"},[...r[0]||(r[0]=[e("div",{class:"inline-flex items-center gap-2"},[e("svg",{class:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]),ye(" Loading... ")],-1)])],8,La)])):t.data.length===0?(o(),a("tr",Ia,[e("td",{colspan:t.columns.length+(t.actions?1:0),class:"px-4 py-8 text-center text-neutral-500"},C(t.emptyMessage),9,Ea)])):(o(!0),a(pe,{key:2},fe(t.data,(p,f)=>(o(),a("tr",{key:f,class:"border-t border-neutral-200 dark:border-neutral-800 hover:bg-black/5 dark:hover:bg-white/5 transition-colors"},[(o(!0),a(pe,null,fe(t.columns,b=>(o(),a("td",{key:b.key,class:le(["px-4 py-3 text-sm",u(b.align)])},[He(c.$slots,`cell-${b.key}`,{value:p[b.key],row:p,column:b},()=>[b.html?(o(),a("span",{key:0,innerHTML:n(p,b)},null,8,Aa)):(o(),a(pe,{key:1},[ye(C(n(p,b)),1)],64))])],2))),128)),t.actions&&t.actions.length>0?(o(),a("td",Pa,[e("div",Oa,[(o(!0),a(pe,null,fe(t.actions,(b,s)=>(o(),a("button",{key:s,onClick:d=>l(b,p),class:"p-1.5 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",title:b.label},[(o(),ee(it(i(b.icon)),{class:"w-4 h-4"}))],8,ja))),128))])])):L("",!0)]))),128))])])])])]))}}),Da=se({__name:"AgentsDataTable",emits:["add","edit","delete"],setup(t,{expose:i,emit:n}){const u=n,l=v([]),c=v(!1),r=[{key:"title",label:"Title",width:"w-1/5"},{key:"type",label:"Type",width:"w-1/12",formatter:s=>s==="dual_ai"?"Dual AI":"AI+Human"},{key:"side_a_agent_prompt_name",label:"Side A",width:"w-1/5",formatter:s=>s||"-"},{key:"side_b_agent_prompt_name",label:"Side B",width:"w-1/5",formatter:s=>s||"Human"},{key:"created_at",label:"Created",width:"w-1/6",formatter:s=>s?new Date(s*1e3).toLocaleDateString():"-"}],p=[{icon:"edit",label:"Edit",handler:s=>u("edit",s)},{icon:"delete",label:"Delete",handler:async s=>{await b(s)},confirm:!0,confirmMessage:"Are you sure you want to delete this agent?"}],f=async()=>{c.value=!0;try{const s=await fetch(ae("/api/agents"));if(s.ok){const d=await s.json();l.value=d.agents||[]}}catch(s){console.error("Error fetching agents:",s)}finally{c.value=!1}},b=async s=>{try{const d=await fetch(ae(`/api/agents/${s.id}`),{method:"DELETE"});if(d.ok)await f();else{const h=await d.json();alert(h.error||"Failed to delete agent")}}catch(d){console.error("Error deleting agent:",d),alert("Failed to delete agent")}};return xe(()=>{f()}),i({refresh:f}),(s,d)=>(o(),a("div",null,[E(Fe,{columns:r,data:l.value,actions:p,loading:c.value,"empty-message":"No agents available. Create your first agent to get started."},null,8,["data","loading"])]))}}),Ua={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ra(t,i){return o(),a("svg",Ua,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M18 6L6 18M6 6l12 12"},null,-1)])])}const Qt=_e({name:"lucide-x",render:Ra}),Na={key:0,class:"w-full max-w-md"},Ba={class:"flex items-center justify-between p-4 border-b-2 border-red-600 flex-shrink-0"},qa={class:"text-xl font-bold text-red-600"},Fa={class:"p-6"},za={class:"text-neutral-700 dark:text-neutral-300 mb-6"},Ha={class:"flex justify-end gap-3"},eo=se({__name:"ConfirmDialog",props:{modelValue:{type:Boolean},title:{default:"Confirm Action"},message:{default:"Are you sure you want to continue? You will lose any unsaved changes."},confirmText:{default:"Continue"},cancelText:{default:"Cancel"}},emits:["update:modelValue","confirm","cancel"],setup(t,{emit:i}){const n=t,u=i,l=()=>{u("update:modelValue",!1)},c=()=>{u("confirm"),l()},r=()=>{u("cancel"),l()},p=f=>{f.key==="Escape"&&n.modelValue&&r()};return ue(()=>n.modelValue,f=>{f?(document.addEventListener("keydown",p),document.body.style.overflow="hidden"):(document.removeEventListener("keydown",p),document.body.style.overflow="")}),(f,b)=>(o(),ee(_t,{to:"body"},[E(We,{"enter-active-class":"transition-opacity duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-200","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:de(()=>[t.modelValue?(o(),a("div",{key:0,class:"fixed inset-0 z-[60] flex items-center justify-center p-4 bg-white/80 dark:bg-black/80 backdrop-blur-sm dark:text-white",onClick:r},[E(We,{"enter-active-class":"transition-all duration-200","enter-from-class":"opacity-0 scale-95","enter-to-class":"opacity-100 scale-100","leave-active-class":"transition-all duration-200","leave-from-class":"opacity-100 scale-100","leave-to-class":"opacity-0 scale-95"},{default:de(()=>[t.modelValue?(o(),a("div",Na,[E(tt,{"offset-x":12,"offset-y":12,intensity:.4},{default:de(()=>[e("div",{class:"bg-white dark:bg-black border-2 border-red-600 flex flex-col",onClick:b[0]||(b[0]=we(()=>{},["stop"]))},[e("div",Ba,[e("h2",qa,C(t.title),1),e("button",{onClick:r,class:"p-1 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors","aria-label":"Close dialog"},[E(Z(Qt),{class:"w-5 h-5 text-red-600"})])]),e("div",Fa,[e("p",za,C(t.message),1),e("div",Ha,[e("button",{onClick:r,class:"px-4 py-2 border-2 border-black dark:border-white bg-white dark:bg-black text-black dark:text-white hover:bg-neutral-50 dark:hover:bg-neutral-900 transition-colors"},C(t.cancelText),1),e("button",{onClick:c,class:"px-4 py-2 border-2 border-red-600 bg-red-600 text-white hover:bg-red-700 hover:border-red-700 transition-colors"},C(t.confirmText),1)])])])]),_:1})])):L("",!0)]),_:1})])):L("",!0)]),_:1})]))}}),Wa={class:"flex items-center justify-between p-4 border-b-2 border-black dark:border-neutral-300 flex-shrink-0"},Ja={class:"text-xl font-bold"},Za={class:"overflow-y-auto flex-1"},Ka={class:"p-6"},Ga={key:0,class:"p-6 border-t-2 border-black dark:border-neutral-300 flex-shrink-0"},je=se({__name:"Modal",props:{modelValue:{type:Boolean},title:{},width:{default:"max-w-lg"},minHeight:{default:"min-h-[24rem]"},hasChanges:{type:Boolean,default:void 0}},emits:["update:modelValue","close"],setup(t,{emit:i}){const n=t,u=i,l=v(),c=v(!1),r=v(new Map),p=()=>l.value&&(l.value.querySelector("input")||l.value.querySelector("textarea")||l.value.querySelector("select")||l.value.querySelector("[contenteditable]")||l.value.querySelector(".monaco-editor")),f=()=>{if(!l.value)return;l.value.querySelectorAll(".monaco-editor-container").forEach(F=>{const X=F.__monacoEditor;if(X&&typeof X.getValue=="function"){const te=X.getValue();r.value.set(F,te)}})},b=()=>{if(!l.value)return!1;const D=l.value.querySelectorAll(".monaco-editor-container");for(const F of D){const X=F.__monacoEditor;if(X&&typeof X.getValue=="function"){const te=X.getValue(),R=r.value.get(F);if(R===void 0||(X.getRawOptions?.()||{}).readOnly===!0)continue;if(te!==R)return!0}}return!1},s=()=>{if(n.hasChanges!==void 0)return n.hasChanges;if(!l.value)return!1;if(b())return!0;const D=l.value.querySelectorAll("form");for(const X of D){const R=X.querySelectorAll("input, textarea, select");for(const j of R){const W=j;if(W.type==="checkbox"||W.type==="radio"){const B=W;if(B.checked!==B.defaultChecked)return!0}else if(W.tagName==="SELECT"){const B=W;if(B.value!==B.defaultValue)return!0}else if(W.value!==W.defaultValue)return!0}}const F=l.value.querySelectorAll("input:not(form input), textarea:not(form textarea), select:not(form select)");for(const X of F){const te=X;if(te.type==="checkbox"||te.type==="radio"){const R=te;if(R.checked!==R.defaultChecked)return!0}else if(te.tagName==="SELECT"){const R=te;if(R.value!==R.defaultValue)return!0}else if(te.value!==te.defaultValue)return!0}return!1},d=()=>{p()&&s()?c.value=!0:h()},h=()=>{u("update:modelValue",!1),u("close")},$=()=>{c.value=!1,h()},g=()=>{c.value=!1},m=D=>{D.key==="Escape"&&n.modelValue&&(p()||h())};ue(()=>n.modelValue,async D=>{D?(document.addEventListener("keydown",m),document.body.style.overflow="hidden",await ge(),setTimeout(()=>{f()},100)):(document.removeEventListener("keydown",m),document.body.style.overflow="",r.value.clear())});const w=v(!1),k=D=>{w.value=D.target===D.currentTarget},O=D=>{D.target===D.currentTarget&&w.value&&(p()||h()),w.value=!1};return(D,F)=>(o(),ee(_t,{to:"body"},[E(We,{"enter-active-class":"transition-opacity duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-200","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:de(()=>[t.modelValue?(o(),a("div",{key:0,class:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-white/80 dark:bg-black/80 backdrop-blur-sm dark:text-white",onMousedown:k,onClick:O},[E(We,{"enter-active-class":"transition-all duration-200","enter-from-class":"opacity-0 scale-95","enter-to-class":"opacity-100 scale-100","leave-active-class":"transition-all duration-200","leave-from-class":"opacity-100 scale-100","leave-to-class":"opacity-0 scale-95"},{default:de(()=>[t.modelValue?(o(),a("div",{key:0,class:le(["w-full",t.width,"max-h-[85vh] flex flex-col"])},[E(tt,{"offset-x":12,"offset-y":12,intensity:.4},{default:de(()=>[e("div",{ref_key:"modalRef",ref:l,class:le(["bg-white dark:bg-black border-2 border-black dark:border-neutral-300 flex flex-col max-h-[85vh]",t.minHeight])},[e("div",Wa,[e("h2",Ja,C(t.title),1),e("button",{onClick:d,class:"p-1 hover:bg-black/5 dark:hover:bg-white/10 rounded transition-colors","aria-label":"Close modal"},[E(Z(Qt),{class:"w-5 h-5"})])]),e("div",Za,[e("div",Ka,[He(D.$slots,"default")])]),D.$slots.footer?(o(),a("div",Ga,[He(D.$slots,"footer")])):L("",!0)],2)]),_:3})],2)):L("",!0)]),_:3})],32)):L("",!0)]),_:3}),E(eo,{modelValue:c.value,"onUpdate:modelValue":F[0]||(F[0]=X=>c.value=X),title:"Unsaved Changes",message:"You have unsaved changes that will be lost. Are you sure you want to close?","confirm-text":"Close Anyway","cancel-text":"Keep Editing",onConfirm:$,onCancel:g},null,8,["modelValue"])]))}}),Xa={class:"space-y-1.5"},Ya={key:0,class:"block text-sm font-medium text-neutral-700 dark:text-neutral-300"},Qa={key:0,class:"text-red-500"},es=["type","value","placeholder","disabled"],ts={key:1,class:"text-xs text-red-500 dark:text-red-400"},Ce=se({__name:"TextInput",props:{modelValue:{},label:{},placeholder:{},type:{default:"text"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","focus","click"],setup(t,{expose:i,emit:n}){const u=t,l=n,c=v(null),r=K(()=>["w-full px-3 py-2.5 bg-neutral-50 dark:bg-neutral-950 border rounded-md text-sm","focus:outline-none focus:ring-2 focus:ring-neutral-400 dark:focus:ring-neutral-500 focus:border-transparent","transition-colors placeholder:text-neutral-400 dark:placeholder:text-neutral-500",u.error?"border-red-500 dark:border-red-400":"border-neutral-300 dark:border-neutral-800",u.disabled?"opacity-50 cursor-not-allowed":""]),p=s=>{const d=s.target;l("update:modelValue",d.value)},f=s=>{l("focus",s)},b=s=>{l("click",s)};return i({inputRef:c}),(s,d)=>(o(),a("div",Xa,[t.label?(o(),a("label",Ya,[ye(C(t.label)+" ",1),t.required?(o(),a("span",Qa,"*")):L("",!0)])):L("",!0),e("input",{ref_key:"inputRef",ref:c,type:t.type,value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,class:le(r.value),onInput:p,onFocus:f,onClick:b},null,42,es),t.error?(o(),a("p",ts,C(t.error),1)):L("",!0)]))}}),os={class:"space-y-1"},ls={key:0,class:"block text-sm font-medium"},as={key:0,class:"text-red-500"},ss=["value","placeholder","disabled","rows"],ns={key:1,class:"text-xs text-red-500 dark:text-red-400"},to=se({__name:"TextareaInput",props:{modelValue:{},label:{},placeholder:{},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},rows:{default:4}},emits:["update:modelValue"],setup(t,{emit:i}){const n=t,u=i,l=K(()=>["w-full px-3 py-2 bg-white dark:bg-black border rounded font-mono text-sm","focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white","transition-colors resize-y",n.error?"border-red-500 dark:border-red-400":"border-black dark:border-neutral-300",n.disabled?"opacity-50 cursor-not-allowed":""]),c=r=>{const p=r.target;u("update:modelValue",p.value)};return(r,p)=>(o(),a("div",os,[t.label?(o(),a("label",ls,[ye(C(t.label)+" ",1),t.required?(o(),a("span",as,"*")):L("",!0)])):L("",!0),e("textarea",{value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,rows:t.rows,class:le(l.value),onInput:c},null,42,ss),t.error?(o(),a("p",ns,C(t.error),1)):L("",!0)]))}}),rs={key:0,class:"block text-sm font-medium mb-2"},is={key:0,class:"text-red-500"},ds=["disabled","aria-expanded"],us={class:"flex items-center justify-between gap-1"},cs={key:0,class:"flex items-center gap-2 text-neutral-400 flex-1 min-w-0"},ps={key:1,class:"flex items-center gap-2 flex-1 min-w-0"},ms=["src","alt"],vs={class:"block truncate"},fs={key:2,class:"block truncate text-neutral-400 flex-1 min-w-0"},hs={class:"bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded-lg overflow-hidden"},gs={class:"p-2 border-b border-neutral-200 dark:border-neutral-700"},bs=["placeholder"],xs={class:"max-h-60 overflow-y-auto"},ys={key:0,class:"px-4 py-3 text-sm text-neutral-500 dark:text-neutral-400"},ks=["onClick","onMouseenter"],ws={class:"flex-shrink-0 w-5 h-5 mt-0.5"},_s=["src","alt"],$s={key:1,class:"w-full h-full bg-neutral-200 dark:bg-neutral-700 rounded"},Cs={class:"flex-1 min-w-0"},Vs={class:"text-sm font-medium text-black dark:text-white"},Ss={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},Ts={key:2,class:"mt-1 text-xs text-red-500 dark:text-red-400"},he=se({__name:"SelectInput",props:{modelValue:{},options:{},placeholder:{default:"Select an option"},searchPlaceholder:{default:"Search..."},label:{},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},error:{},required:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{emit:i}){const n=t,u=i,l=v(!1),c=v(""),r=v(),p=v(),f=v(),b=v(),s=v(-1),d=K(()=>n.options.find(j=>j.value===n.modelValue)),h=K(()=>["w-full px-3 py-2 text-left rounded focus:outline-none focus:ring-2 bg-white dark:bg-black disabled:opacity-50 disabled:cursor-not-allowed font-mono text-sm overflow-hidden",n.error?"border border-red-500 dark:border-red-400 focus:ring-red-500 dark:focus:ring-red-400":"border border-black dark:border-neutral-300 focus:ring-black dark:focus:ring-white"]),$=K(()=>{if(!c.value)return n.options;const j=c.value.toLowerCase();return n.options.filter(W=>W.label.toLowerCase().includes(j)||W.value.toLowerCase().includes(j)||W.description&&W.description.toLowerCase().includes(j))});ue($,()=>{s.value=-1});const g=()=>{n.disabled||(l.value?k():(l.value=!0,c.value="",s.value=-1,ge(()=>{if(b.value&&(b.value.setAttribute("popover","auto"),b.value.addEventListener("toggle",R),"showPopover"in b.value))try{b.value.showPopover()}catch{}O(),setTimeout(()=>r.value?.focus(),0)})))},m=j=>{u("update:modelValue",j.value),k(),c.value="",s.value=-1},w=j=>{j.stopPropagation(),u("update:modelValue","")},k=()=>{if(b.value){if("hidePopover"in b.value)try{b.value.hidePopover()}catch{}b.value.removeEventListener("toggle",R)}l.value=!1,s.value=-1},O=()=>{if(!f.value||!b.value)return;const j=f.value.getBoundingClientRect();b.value.offsetWidth||j.width,b.value.style.position="fixed",b.value.style.top=`${j.bottom+8}px`,b.value.style.left=`${j.left}px`,b.value.style.width=`${j.width}px`,b.value.style.margin="0"},D=j=>{p.value&&!p.value.contains(j.target)&&b.value&&!b.value.contains(j.target)&&k()},F=j=>{j.key==="Escape"&&l.value&&(k(),f.value?.focus())},X=j=>{if(!l.value)return;const W=$.value;if(W.length!==0)switch(j.key){case"ArrowDown":j.preventDefault(),s.value=s.value<W.length-1?s.value+1:0,te();break;case"ArrowUp":j.preventDefault(),s.value=s.value>0?s.value-1:W.length-1,te();break;case"Enter":j.preventDefault(),s.value>=0&&s.value<W.length&&m(W[s.value]);break}},te=()=>{ge(()=>{const j=b.value?.querySelector(".highlighted-option");j&&j.scrollIntoView({block:"nearest",behavior:"smooth"})})},R=j=>{j.target===b.value&&(l.value=j.newState==="open",l.value&&O())};return xe(()=>{document.addEventListener("click",D),document.addEventListener("keydown",F);const j=()=>{l.value&&O()};window.addEventListener("resize",j),window.addEventListener("scroll",j,!0)}),Be(()=>{document.removeEventListener("click",D),document.removeEventListener("keydown",F),window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}),(j,W)=>(o(),a("div",{ref_key:"dropdownRef",ref:p,class:"relative"},[t.label?(o(),a("label",rs,[ye(C(t.label)+" ",1),t.required?(o(),a("span",is,"*")):L("",!0)])):L("",!0),e("button",{ref_key:"buttonRef",ref:f,type:"button",onClick:g,disabled:t.disabled,"aria-expanded":l.value,"aria-haspopup":!0,class:le(h.value)},[e("div",us,[t.loading?(o(),a("span",cs,[...W[1]||(W[1]=[e("svg",{class:"animate-spin h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})],-1),ye(" Loading... ",-1)])])):d.value?(o(),a("span",ps,[d.value.icon?(o(),a("img",{key:0,src:d.value.icon,alt:d.value.label,class:"w-5 h-5 flex-shrink-0"},null,8,ms)):L("",!0),e("span",vs,C(d.value.label),1)])):(o(),a("span",fs,C(t.placeholder),1)),d.value&&!t.disabled?(o(),a("button",{key:3,type:"button",onClick:w,class:"flex-shrink-0 p-0.5 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors","aria-label":"Clear selection"},[...W[2]||(W[2]=[e("svg",{class:"h-4 w-4 text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[e("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)])])):L("",!0),W[3]||(W[3]=e("svg",{class:"h-5 w-5 text-neutral-400 flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[e("path",{"fill-rule":"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1))])],10,ds),l.value?(o(),a("div",{key:1,ref_key:"popoverRef",ref:b,class:"dropdown-popover"},[E(tt,{"offset-x":4,"offset-y":4,intensity:.3},{default:de(()=>[e("div",hs,[e("div",gs,[Se(e("input",{ref_key:"searchInput",ref:r,"onUpdate:modelValue":W[0]||(W[0]=B=>c.value=B),type:"text",placeholder:t.searchPlaceholder,onKeydown:X,class:"w-full px-3 py-1.5 text-sm border border-neutral-300 dark:border-neutral-600 rounded focus:outline-none focus:ring-1 focus:ring-black dark:focus:ring-white bg-white dark:bg-black text-black dark:text-white placeholder:text-neutral-400 dark:placeholder:text-neutral-500"},null,40,bs),[[Oe,c.value]])]),e("div",xs,[$.value.length===0?(o(),a("div",ys," No options found ")):L("",!0),(o(!0),a(pe,null,fe($.value,(B,N)=>(o(),a("button",{key:B.value,type:"button",onClick:U=>m(B),onMouseenter:U=>s.value=N,class:le(["w-full px-4 py-2 text-left hover:bg-neutral-100 dark:hover:bg-neutral-900 focus:bg-neutral-100 dark:focus:bg-neutral-900 focus:outline-none flex items-start gap-3",{"bg-neutral-50 dark:bg-neutral-900":B.value===t.modelValue,"bg-neutral-100 dark:bg-neutral-800 highlighted-option":N===s.value}])},[e("div",ws,[B.icon?(o(),a("img",{key:0,src:B.icon,alt:B.label,class:"w-full h-full"},null,8,_s)):(o(),a("div",$s))]),e("div",Cs,[e("div",Vs,C(B.label),1),B.description?(o(),a("div",Ss,C(B.description),1)):L("",!0)])],42,ks))),128))])])]),_:1})],512)):L("",!0),t.error?(o(),a("p",Ts,C(t.error),1)):L("",!0)],512))}}),Ms={class:"flex items-start"},Ls=["for"],Is=["id","checked","disabled"],Es={class:"flex items-center h-5"},As={class:"flex-1"},Ps={key:0,class:"text-red-500"},Os={key:1,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-1"},js={key:2,class:"text-xs text-red-500 dark:text-red-400 mt-1"},Te=se({__name:"CheckboxInput",props:{modelValue:{type:Boolean,default:!1},label:{},helpText:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},error:{}},emits:["update:modelValue"],setup(t,{emit:i}){const n=t,u=i,l=go(),c=K(()=>["w-5 h-5 border-2 rounded relative flex-shrink-0","transition-all duration-150",n.error?"border-red-500 dark:border-red-400":"border-black dark:border-neutral-300",n.disabled?"opacity-50":"hover:scale-110",n.modelValue?"bg-black dark:bg-white":"bg-white dark:bg-black","before:content-[''] before:absolute before:inset-0 before:m-auto before:w-2.5 before:h-1.5 before:border-white dark:before:border-black before:border-b-2 before:border-l-2 before:rotate-[-45deg]",n.modelValue?"before:block":"before:hidden"]),r=p=>{if(!n.disabled){const f=p.target;u("update:modelValue",f.checked)}};return(p,f)=>(o(),a("div",Ms,[e("label",{for:Z(l),class:le(["flex items-start space-x-3 cursor-pointer select-none",{"cursor-not-allowed":t.disabled}])},[e("input",{id:Z(l),type:"checkbox",checked:t.modelValue,disabled:t.disabled,onChange:r,class:"absolute left-[-9999px]"},null,40,Is),e("div",Es,[e("span",{class:le(c.value)},null,2)]),e("div",As,[t.label?(o(),a("span",{key:0,class:le(["block text-sm font-medium",{"opacity-50":t.disabled}])},[ye(C(t.label)+" ",1),t.required?(o(),a("span",Ps,"*")):L("",!0)],2)):L("",!0),t.helpText?(o(),a("p",Os,C(t.helpText),1)):L("",!0),t.error?(o(),a("p",js,C(t.error),1)):L("",!0)])],10,Ls)]))}}),Ds={key:0,class:"min-h-[400px] flex items-center justify-center"},Us={key:1,class:"space-y-6 pr-2 pb-4"},Rs={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Ns={key:1,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Bs={key:0},qs={key:1},Fs={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},zs={key:2},Hs={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Ws={class:"grid grid-cols-2 gap-6"},Js={class:"space-y-4 p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},Zs={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Ks={class:"space-y-3"},Gs={class:"flex items-start"},Xs={key:0,class:"ml-8 mt-2 space-y-2"},Ys={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"},Qs={key:1},en={key:0,class:"mt-3 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded"},tn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},on={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},ln={class:"space-y-4 p-4 bg-neutral-100 dark:bg-neutral-800 rounded-lg"},an={class:"font-semibold text-base mb-4 text-neutral-800 dark:text-neutral-200"},sn={key:0,class:"flex flex-col items-center justify-center py-8"},nn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},rn={class:"space-y-3"},dn={class:"flex items-start"},un={key:0,class:"ml-8 mt-2 space-y-2"},cn={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"},pn={key:1},mn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},vn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},fn={class:"flex justify-between"},hn=["disabled"],gn=se({__name:"AgentModal",props:{modelValue:{type:Boolean},editAgent:{},mode:{}},emits:["update:modelValue","save"],setup(t,{emit:i}){const n=t,u=i,l=K(()=>n.mode==="edit"),c=v(!1),r=v(""),p=v(""),f=v(""),b=v(null),s=v(""),d=v("dual_ai"),h=v(!1),$=v(""),g=v(""),m=v(null),w=v(""),k=v(""),O=v(""),D=v(""),F=v(!0),X=v(!1),te=v(""),R=v(""),j=v(""),W=v(""),B=v(!1),N=v(null),U=v(""),y=v(""),x=v(""),V=v(""),_=v(""),T=v(""),S=v(!0),P=v(!1),J=v(""),re=v(""),A=v(""),I=v(""),M=v(null),oe=v(""),Y=v(""),ie=v(""),{data:ve,execute:ke}=Ee(ae("/api/prompts"),{immediate:!1}).json(),{data:Ie,execute:$e}=Ee(ae("/api/tools?schema=true"),{immediate:!1}).json(),Me=v(null),Pe=v(!1),Le=v(null),z=v(!1),H=v(!1),G=K(()=>{if(!ve.value)return[{value:"",label:"Select a prompt..."}];const ne=ve.value?.prompts||[];return[{value:"",label:"None"},...ne.map(q=>({value:q.id,label:q.name}))]}),ce=ne=>Ie.value?Ie.value[ne]:null,me=K(()=>!Me.value||!Me.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...Me.value.tools.map(ne=>{const q=typeof ne=="string"?ne:ne.name;return{value:q,label:q}})]),Ve=K(()=>!Le.value||!Le.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...Le.value.tools.map(ne=>{const q=typeof ne=="string"?ne:ne.name;return{value:q,label:q}})]),Ue=K(()=>{if(!te.value)return[];const ne=ce(te.value);return!ne||!ne.schema||!ne.schema.properties?[]:Object.keys(ne.schema.properties).map(q=>({value:q,label:q}))}),De=K(()=>{if(!J.value)return[];const ne=ce(J.value);return!ne||!ne.schema||!ne.schema.properties?[]:Object.keys(ne.schema.properties).map(q=>({value:q,label:q}))}),lt=[{value:"dual_ai",label:"AI + AI (Subagent)"},{value:"ai_human",label:"AI + Human"}],Ge=K({get(){return p.value},set(ne){const q=b.value?.inputRef,Q=q?.selectionStart??ne.length;let Re=ne.toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_]/g,"");if(Re.endsWith("_agent")||(Re=Re+"_agent"),p.value=Re,q){q.value=Re;const Ae=Math.min(Q,Re.length-6);q.setSelectionRange(Ae,Ae)}}}),St=async()=>{await ge();const ne=b.value?.inputRef;if(ne&&p.value.endsWith("_agent")){const q=p.value.length-6;ne.setSelectionRange(q,q)}},io=ne=>!ne||ne==="_agent"?(f.value="Name is required",!1):/^[a-z][a-z0-9_]*_agent$/.test(ne)?(f.value="",!0):(f.value="Name must start with a letter",!1),at=()=>{p.value="",r.value="",f.value="",s.value="",d.value="dual_ai",h.value=!1,$.value="",g.value="",m.value=null,w.value="",O.value="",D.value="",F.value=!0,X.value=!1,te.value="",R.value="",j.value="",W.value="",B.value=!1,N.value=null,U.value="",y.value="",x.value="",Me.value=null,_.value="",T.value="",S.value=!0,P.value=!1,J.value="",re.value="",A.value="",I.value="",M.value=null,oe.value="",Y.value="",ie.value="",Le.value=null},uo=async()=>{if(n.editAgent?.id){c.value=!0,H.value=!0;try{const ne=await fetch(ae(`/api/agents/${n.editAgent.id}`));if(ne.ok){const q=await ne.json(),Q=q.agent||q;p.value=Q.name||"",r.value=Q.name||"",s.value=Q.title||"",d.value=Q.type||"dual_ai",h.value=Q.expose_as_tool||!1,$.value=Q.tool_description||"",m.value=Q.max_session_turns;const Re=Q.side_a_stop_tool||"",Ae=Q.side_a_stop_tool_response_property||"",mo=Q.side_b_stop_tool||"",vo=Q.side_b_stop_tool_response_property||"",fo=Q.side_a_end_conversation_tool||"",ho=Q.side_b_end_conversation_tool||"";k.value=Q.side_a_label||"",V.value=Q.side_b_label||"",O.value=Q.side_a_agent_prompt||"",_.value=Q.side_b_agent_prompt||"",F.value=!!Q.side_a_stop_on_response,X.value=!!Q.side_a_stop_tool,B.value=!!Q.side_a_manual_stop_condition,N.value=Q.side_a_max_turns,S.value=!!Q.side_b_stop_on_response,P.value=!!Q.side_b_stop_tool,M.value=Q.side_b_max_turns,await ge(),te.value=Re,j.value=Ae,J.value=mo,A.value=vo,y.value=fo,Y.value=ho}}catch(ne){console.error("Error loading agent data:",ne)}finally{c.value=!1,H.value=!1}}},co=async()=>{f.value="",w.value="",D.value="",R.value="",W.value="",U.value="",x.value="",T.value="",re.value="",I.value="",oe.value="",ie.value="";let ne=!1;io(p.value)||(ne=!0);const q=p.value;d.value==="dual_ai"&&m.value!==null&&m.value!==void 0&&m.value<=0&&(w.value="Max session turns must be a positive number",ne=!0),O.value||(D.value="Please select an agent prompt",ne=!0);const Q=F.value||te.value,Re=d.value==="ai_human"&&B.value;if(!Q&&!Re&&(D.value="At least one stop condition is required (or check manual stop condition for ai_human agents)",ne=!0),te.value&&!j.value&&(W.value="Response property required when using stop tool",ne=!0),N.value!==null&&N.value<=0&&(U.value="Max turns must be a positive number",ne=!0),d.value==="dual_ai"&&!y.value&&!Y.value&&(x.value="At least one side must have an end conversation tool",ie.value="At least one side must have an end conversation tool",ne=!0),d.value==="dual_ai"&&(_.value||(T.value="Please select an agent prompt",ne=!0),J.value&&!A.value&&(I.value="Response property required when using stop tool",ne=!0),M.value!==null&&M.value<=0&&(oe.value="Max turns must be a positive number",ne=!0)),ne)return;const Ae={name:q,title:s.value||null,type:d.value,expose_as_tool:h.value,tool_description:h.value?$.value:null,max_session_turns:d.value==="dual_ai"?m.value:null,side_a_label:k.value||null,side_a_agent_prompt:O.value,side_a_stop_on_response:F.value,side_a_stop_tool:te.value||null,side_a_stop_tool_response_property:j.value||null,side_a_manual_stop_condition:B.value,side_a_max_turns:N.value,side_a_end_conversation_tool:y.value||null};d.value==="dual_ai"&&(Ae.side_b_label=V.value||null,Ae.side_b_agent_prompt=_.value,Ae.side_b_stop_on_response=S.value,Ae.side_b_stop_tool=J.value||null,Ae.side_b_stop_tool_response_property=A.value||null,Ae.side_b_max_turns=M.value,Ae.side_b_end_conversation_tool=Y.value||null),l.value&&n.editAgent?.id&&(Ae.id=n.editAgent.id),u("save",Ae),at(),u("update:modelValue",!1)},po=()=>{at(),u("update:modelValue",!1)};return ue(O,async ne=>{if(H.value||(te.value="",j.value=""),!ne){Me.value=null;return}Pe.value=!0;try{const q=await fetch(ae(`/api/prompts/${ne}`));q.ok&&(Me.value=await q.json())}catch(q){console.error("Error fetching Side A prompt:",q)}finally{Pe.value=!1}}),ue(_,async ne=>{if(H.value||(J.value="",A.value=""),!ne){Le.value=null;return}z.value=!0;try{const q=await fetch(ae(`/api/prompts/${ne}`));q.ok&&(Le.value=await q.json())}catch(q){console.error("Error fetching Side B prompt:",q)}finally{z.value=!1}}),ue(X,ne=>{ne||(te.value="",j.value="")}),ue(P,ne=>{ne||(J.value="",A.value="")}),ue(()=>n.modelValue,async ne=>{ne&&(await Promise.all([ke(),$e()]),l.value?(at(),await uo()):at())}),(ne,q)=>(o(),ee(je,{"model-value":t.modelValue,"onUpdate:modelValue":q[23]||(q[23]=Q=>ne.$emit("update:modelValue",Q)),title:l.value?"Edit Agent":"Create Agent",width:"max-w-6xl"},{footer:de(()=>[e("div",fn,[e("button",{onClick:po,type:"button",class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors"}," Cancel "),e("button",{onClick:co,type:"button",class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity",disabled:c.value},C(l.value?"Update Agent":"Create Agent"),9,hn)])]),default:de(()=>[c.value?(o(),a("div",Ds,[...q[24]||(q[24]=[e("span",{class:"text-neutral-500"},"Loading agent data...",-1)])])):(o(),a("div",Us,[e("div",null,[E(Ce,{ref_key:"nameInputRef",ref:b,modelValue:Ge.value,"onUpdate:modelValue":q[0]||(q[0]=Q=>Ge.value=Q),label:"Agent Name",placeholder:"research_agent",error:f.value,required:"",disabled:l.value,onFocus:St,onClick:St},null,8,["modelValue","error","disabled"]),!f.value&&!l.value?(o(),a("p",Rs," Names are automatically formatted to snake_case with the _agent suffix ")):L("",!0),l.value?(o(),a("p",Ns," Agent names cannot be changed after creation (used as foreign key for threads) ")):L("",!0)]),e("div",null,[E(Ce,{modelValue:s.value,"onUpdate:modelValue":q[1]||(q[1]=Q=>s.value=Q),label:"Display Title (Optional)",placeholder:"Research Assistant"},null,8,["modelValue"]),q[25]||(q[25]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Human-readable title shown in the UI. If not set, the name will be used. ",-1))]),e("div",null,[E(he,{modelValue:d.value,"onUpdate:modelValue":q[2]||(q[2]=Q=>d.value=Q),label:"Agent Type",options:lt},null,8,["modelValue"]),q[26]||(q[26]=e("p",{class:"mt-1 text-sm text-neutral-500 dark:text-neutral-400"}," Choose between two AI agents conversing, or an AI agent conversing with a human ",-1))]),d.value==="dual_ai"?(o(),a("div",Bs,[E(Te,{modelValue:h.value,"onUpdate:modelValue":q[3]||(q[3]=Q=>h.value=Q),label:"Expose as Tool"},null,8,["modelValue"]),q[27]||(q[27]=e("p",{class:"mt-1 text-sm text-neutral-500 dark:text-neutral-400"}," Make this subagent available as a tool that can be called by other prompts or agents. When called, it will execute as a subagent. ",-1))])):L("",!0),h.value&&d.value==="dual_ai"?(o(),a("div",qs,[E(to,{modelValue:$.value,"onUpdate:modelValue":q[4]||(q[4]=Q=>$.value=Q),label:"Tool Description",placeholder:"Describe what this agent does when called as a tool",error:g.value,rows:3},null,8,["modelValue","error"]),g.value?L("",!0):(o(),a("p",Fs," This description helps other agents understand when to use this agent "))])):L("",!0),d.value==="dual_ai"?(o(),a("div",zs,[E(Ce,{"model-value":m.value?.toString()||"","onUpdate:modelValue":q[5]||(q[5]=Q=>m.value=Q?parseInt(Q):null),label:"Max Session Turns",type:"number",error:w.value,placeholder:"Unlimited"},null,8,["model-value","error"]),w.value?L("",!0):(o(),a("p",Hs," Maximum number of back-and-forth exchanges between the two agents before the conversation ends "))])):L("",!0),e("div",Ws,[e("div",Js,[q[34]||(q[34]=e("h4",{class:"font-semibold text-base mb-4 text-neutral-800 dark:text-neutral-200"}," Side A (AI) ",-1)),e("div",null,[E(Ce,{modelValue:k.value,"onUpdate:modelValue":q[6]||(q[6]=Q=>k.value=Q),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer, Support"},null,8,["modelValue"]),q[28]||(q[28]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Custom label for this side (shows in message bubbles and toggle) ",-1))]),e("div",null,[E(he,{modelValue:O.value,"onUpdate:modelValue":q[7]||(q[7]=Q=>O.value=Q),label:"Agent Prompt",options:G.value,error:D.value,required:""},null,8,["modelValue","options","error"]),D.value?L("",!0):(o(),a("p",Zs," The prompt that defines this agent's behavior "))]),e("div",Ks,[q[31]||(q[31]=e("label",{class:"block text-sm font-medium"}," Stop Conditions ",-1)),q[32]||(q[32]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"}," Optional. If no stop conditions are set, the agent will continue until programmatically stopped or end conversation tool is called. ",-1)),e("div",Gs,[E(Te,{modelValue:F.value,"onUpdate:modelValue":q[8]||(q[8]=Q=>F.value=Q),label:"Stop when agent returns content"},null,8,["modelValue"])]),q[33]||(q[33]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-2 ml-6"}," Agent stops when it returns a response without calling tools ",-1)),e("div",null,[E(Te,{modelValue:X.value,"onUpdate:modelValue":q[9]||(q[9]=Q=>X.value=Q),label:"Stop on specific tool call"},null,8,["modelValue"]),X.value?(o(),a("div",Xs,[E(he,{modelValue:te.value,"onUpdate:modelValue":q[10]||(q[10]=Q=>te.value=Q),label:"Stop Tool",options:me.value,error:R.value,placeholder:"Select a tool...",disabled:Pe.value||!O.value},null,8,["modelValue","options","error","disabled"]),R.value?L("",!0):(o(),a("p",Ys," Agent stops when this tool is called ")),te.value?(o(),a("div",Qs,[E(he,{modelValue:j.value,"onUpdate:modelValue":q[11]||(q[11]=Q=>j.value=Q),label:"Response Property",options:Ue.value,error:W.value,placeholder:"Select property..."},null,8,["modelValue","options","error"]),q[29]||(q[29]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Property from tool arguments to return as final response ",-1))])):L("",!0)])):L("",!0)]),d.value==="ai_human"&&!F.value&&!X.value?(o(),a("div",en,[E(Te,{modelValue:B.value,"onUpdate:modelValue":q[12]||(q[12]=Q=>B.value=Q),label:"I have manually implemented a stop condition"},null,8,["modelValue"]),q[30]||(q[30]=e("p",{class:"mt-2 text-xs text-yellow-800 dark:text-yellow-200"}," ⚠️ Warning: Only check this if you have implemented a custom stop condition in your code (e.g., via hooks or custom logic). Without a stop condition, the agent may run indefinitely. ",-1))])):L("",!0)]),e("div",null,[E(Ce,{"model-value":N.value?.toString()||"","onUpdate:modelValue":q[13]||(q[13]=Q=>N.value=Q?parseInt(Q):null),label:"Max Turns",type:"number",error:U.value,placeholder:"Unlimited"},null,8,["model-value","error"]),U.value?L("",!0):(o(),a("p",tn," Maximum turns this side can take before yielding (safety limit) "))]),e("div",null,[E(he,{modelValue:y.value,"onUpdate:modelValue":q[14]||(q[14]=Q=>y.value=Q),label:"End Conversation Tool",options:me.value,error:x.value,placeholder:"Select a tool...",disabled:Pe.value||!O.value},null,8,["modelValue","options","error","disabled"]),x.value?L("",!0):(o(),a("p",on," Tool that ends the entire conversation when called "))])]),e("div",ln,[e("h4",an," Side B ("+C(d.value==="ai_human"?"Human":"AI")+") ",1),e("div",null,[E(Ce,{modelValue:V.value,"onUpdate:modelValue":q[15]||(q[15]=Q=>V.value=Q),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer, Support"},null,8,["modelValue"]),q[35]||(q[35]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Custom label for this side (shows in message bubbles and toggle) ",-1))]),d.value==="ai_human"?(o(),a("div",sn,[...q[36]||(q[36]=[e("svg",{class:"w-20 h-20 mb-4 text-neutral-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})],-1),e("h5",{class:"font-medium text-lg mb-2"},"Human User",-1),e("p",{class:"text-sm text-neutral-500 dark:text-neutral-400 text-center max-w-xs"}," This side of the conversation will be handled by a human user through the interface ",-1)])])):(o(),a(pe,{key:1},[e("div",null,[E(he,{modelValue:_.value,"onUpdate:modelValue":q[16]||(q[16]=Q=>_.value=Q),label:"Agent Prompt",options:G.value,error:T.value,required:""},null,8,["modelValue","options","error"]),T.value?L("",!0):(o(),a("p",nn," The prompt that defines this agent's behavior "))]),e("div",rn,[q[38]||(q[38]=e("label",{class:"block text-sm font-medium"}," Stop Conditions ",-1)),q[39]||(q[39]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"}," Optional. If no stop conditions are set, the agent will continue until programmatically stopped or end conversation tool is called. ",-1)),e("div",dn,[E(Te,{modelValue:S.value,"onUpdate:modelValue":q[17]||(q[17]=Q=>S.value=Q),label:"Stop when agent returns content"},null,8,["modelValue"])]),q[40]||(q[40]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-2 ml-6"}," Agent stops when it returns a response without calling tools ",-1)),e("div",null,[E(Te,{modelValue:P.value,"onUpdate:modelValue":q[18]||(q[18]=Q=>P.value=Q),label:"Stop on specific tool call"},null,8,["modelValue"]),P.value?(o(),a("div",un,[E(he,{modelValue:J.value,"onUpdate:modelValue":q[19]||(q[19]=Q=>J.value=Q),label:"Stop Tool",options:Ve.value,error:re.value,placeholder:"Select a tool...",disabled:z.value||!_.value},null,8,["modelValue","options","error","disabled"]),re.value?L("",!0):(o(),a("p",cn," Agent stops when this tool is called ")),J.value?(o(),a("div",pn,[E(he,{modelValue:A.value,"onUpdate:modelValue":q[20]||(q[20]=Q=>A.value=Q),label:"Response Property",options:De.value,error:I.value,placeholder:"Select property..."},null,8,["modelValue","options","error"]),q[37]||(q[37]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Property from tool arguments to return as final response ",-1))])):L("",!0)])):L("",!0)])]),e("div",null,[E(Ce,{"model-value":M.value?.toString()||"","onUpdate:modelValue":q[21]||(q[21]=Q=>M.value=Q?parseInt(Q):null),label:"Max Turns",type:"number",error:oe.value,placeholder:"Unlimited"},null,8,["model-value","error"]),oe.value?L("",!0):(o(),a("p",mn," Maximum turns this side can take before yielding (safety limit) "))]),e("div",null,[E(he,{modelValue:Y.value,"onUpdate:modelValue":q[22]||(q[22]=Q=>Y.value=Q),label:"End Conversation Tool",options:Ve.value,error:ie.value,placeholder:"Select a tool...",disabled:z.value||!_.value},null,8,["modelValue","options","error","disabled"]),ie.value?L("",!0):(o(),a("p",vn," Tool that ends the entire conversation when called "))])],64))])])]))]),_:1},8,["model-value","title"]))}}),bn={},xn={class:"p-8 w-full max-w-7xl mx-auto"};function yn(t,i){return o(),a("div",xn,[He(t.$slots,"default")])}const Ke=Ze(bn,[["render",yn]]),kn=se({__name:"AgentsView",setup(t){const i=et(),n=ze(),u=v(!1),l=v("add"),c=v(null),r=v(null);ue(()=>n.query.refresh,()=>{n.query.refresh&&(r.value?.refresh(),i.replace({path:"/agents",query:{}}))});const p=()=>{l.value="add",c.value=null,u.value=!0},f=s=>{l.value="edit",c.value=s,u.value=!0},b=async s=>{try{const d=l.value==="edit"&&c.value?.id,{originalName:h,...$}=s,g=ae(d?`/api/agents/${c.value.id}`:"/api/agents"),w=await fetch(g,{method:d?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($)});if(w.ok)r.value?.refresh(),u.value=!1,c.value=null;else{const k=await w.json();alert(k.error||`Failed to ${d?"update":"create"} agent`)}}catch(d){console.error(`Error ${l.value==="edit"?"updating":"creating"} agent:`,d),alert(`Failed to ${l.value==="edit"?"update":"create"} agent`)}};return(s,d)=>(o(),ee(Ke,null,{default:de(()=>[e("div",{class:"flex justify-between items-center mb-6"},[d[1]||(d[1]=e("h1",{class:"text-3xl font-bold"},"Agents",-1)),e("button",{onClick:p,class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Create Agent ")]),d[2]||(d[2]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-6"}," Configure and manage your AI agents. ",-1)),E(Da,{ref_key:"dataTableRef",ref:r,onAdd:p,onEdit:f},null,512),E(gn,{modelValue:u.value,"onUpdate:modelValue":d[0]||(d[0]=h=>u.value=h),mode:l.value,editAgent:c.value,onSave:b},null,8,["modelValue","mode","editAgent"])]),_:1}))}});function wn(t){const{limit:i=50,offset:n=0,agentId:u=null,userId:l=null,autoFetch:c=!0}={},r=K(()=>{const w=new URLSearchParams,k=typeof i=="number"?i:i.value,O=typeof n=="number"?n:n.value,D=typeof u=="string"?u:u?.value,F=typeof l=="string"?l:l?.value;return w.append("limit",k.toString()),w.append("offset",O.toString()),D&&w.append("agent_id",D),F&&w.append("user_id",F),ae(`/api/threads?${w.toString()}`)}),{data:p,error:f,isFetching:b,isFinished:s,execute:d,abort:h}=Ee(r,{immediate:c}).get().json(),$=K(()=>p.value?.threads||[]),g=K(()=>p.value?.total||0),m=K(()=>p.value?.hasMore||!1);return{threads:$,total:g,hasMore:m,error:f,isFetching:b,isFinished:s,refetch:d,abort:h}}function Ct(t){const i=K(()=>!!(typeof t=="string"?t:t?.value)),n=K(()=>{const s=typeof t=="string"?t:t?.value;return ae(s?`/api/threads/${s}`:"/api/threads/placeholder")}),{data:u,error:l,isFetching:c,isFinished:r,execute:p,abort:f}=Ee(n,{immediate:!1}).get().json();return ue(i,s=>{s&&p()},{immediate:!0}),{thread:K(()=>u.value?{id:u.value.thread.id,agent_id:u.value.thread.agent_id,user_id:u.value.thread.user_id,tags:u.value.thread.tags||[],created_at:u.value.thread.created_at,agent:u.value.agent||{id:"",title:"Unknown",type:"unknown"},stats:u.value.stats}:null),error:l,isFetching:c,isFinished:r,refetch:p,abort:f}}function _n(t){const{autoConnect:i=!0,onEvent:n}=t||{},u=v(null),l=v(!1),c=v(null),r=()=>{u.value&&u.value.close();const f=window.location.protocol==="https:"?"wss:":"ws:",b=window.location.host;let s=`${f}//${b}${ae("/api/events")}`;const d=localStorage.getItem("auth_token");d&&(s+=`?token=${encodeURIComponent(d)}`);try{u.value=new WebSocket(s),u.value.onopen=()=>{l.value=!0,c.value=null,console.log("[AgentBuilderEvents] WebSocket connected")},u.value.onmessage=h=>{try{const $=JSON.parse(h.data);console.log("[AgentBuilderEvents] Received event:",$.type),n&&n($)}catch($){console.error("[AgentBuilderEvents] Failed to parse WebSocket message:",$)}},u.value.onerror=h=>{c.value="WebSocket connection error",l.value=!1,console.error("[AgentBuilderEvents] WebSocket error:",h)},u.value.onclose=()=>{l.value=!1,console.log("[AgentBuilderEvents] WebSocket disconnected")}}catch(h){c.value=h.message||"Failed to create WebSocket",console.error("[AgentBuilderEvents] WebSocket creation error:",h)}},p=()=>{u.value&&(u.value.close(),u.value=null,l.value=!1)};return i&&r(),Be(()=>{p()}),{wsConnected:l,wsError:c,connect:r,disconnect:p}}const $n={class:"inline-flex items-center justify-center"},be=se({__name:"Loader",props:{size:{default:"md"}},setup(t){const i=t,n=K(()=>{switch(i.size){case"xs":return"w-3 h-3 border";case"sm":return"w-3.5 h-3.5 border";case"md":default:return"w-4 h-4 border-2"}});return(u,l)=>(o(),a("div",$n,[e("div",{class:le([n.value,"border-black/20 dark:border-white/20 border-t-black dark:border-t-white rounded-full animate-spin"])},null,2)]))}});function Cn(t){const n=Date.now()*1e3-t,u=Math.floor(n/1e6);if(u<60)return u===1?"1 second ago":`${u} seconds ago`;const l=Math.floor(u/60);if(l<60)return l===1?"1 minute ago":`${l} minutes ago`;const c=Math.floor(l/60);if(c<24)return c===1?"1 hour ago":`${c} hours ago`;const r=Math.floor(c/24);if(r<30)return r===1?"1 day ago":`${r} days ago`;const p=Math.floor(r/30);if(p<12)return p===1?"1 month ago":`${p} months ago`;const f=Math.floor(p/12);return f===1?"1 year ago":`${f} years ago`}function Vn(t){const i=v("");let n=null;const u=()=>typeof t=="function"?t():typeof t=="number"?t:t.value,l=()=>{const c=u();i.value=Cn(c);const p=Date.now()*1e3-c,f=Math.floor(p/1e6);n!==null&&(clearInterval(n),n=null),f<60?n=setInterval(l,1e3):f<3600?n=setInterval(l,6e4):f<86400&&(n=setInterval(l,6e5))};return l(),Be(()=>{n!==null&&clearInterval(n)}),i}const dt=se({__name:"TimeAgo",props:{timestamp:{}},setup(t){const i=t,n=Vn(()=>i.timestamp);return(u,l)=>(o(),a("span",null,C(Z(n)),1))}}),Sn={class:"relative inline-flex items-center"},Tn={key:0,class:"inline-block w-2 h-2 rounded-full bg-green-500 dark:bg-green-400"},Mn={key:1,class:"inline-block w-2 h-2 rounded-full bg-red-500 dark:bg-red-400"},Ln={key:2,class:"inline-block w-2 h-2 rounded-full bg-neutral-400 dark:bg-neutral-600"},In={key:0},En={key:1},An={key:2},Vt=se({__name:"StatusDot",props:{connected:{type:Boolean},error:{type:Boolean}},setup(t){const i=v(!1),n=v(null);return(u,l)=>(o(),a("div",Sn,[e("span",{class:"p-0.5 cursor-default outline-none",tabindex:"-1",onMouseenter:l[0]||(l[0]=c=>i.value=!0),onMouseleave:l[1]||(l[1]=c=>i.value=!1)},[t.connected?(o(),a("span",Tn)):t.error?(o(),a("span",Mn)):(o(),a("span",Ln))],32),E(We,{"enter-active-class":"transition-opacity duration-150","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-100","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:de(()=>[i.value?(o(),a("div",{key:0,ref_key:"popoverRef",ref:n,class:le(["absolute top-full left-1/2 -translate-x-1/2 mt-1 px-2 py-1 text-xs rounded shadow-lg whitespace-nowrap z-50 border",{"bg-green-50 dark:bg-green-950 border-green-200 dark:border-green-800 text-green-700 dark:text-green-300":t.connected,"bg-red-50 dark:bg-red-950 border-red-200 dark:border-red-800 text-red-700 dark:text-red-300":!t.connected&&t.error,"bg-neutral-50 dark:bg-neutral-900 border-neutral-200 dark:border-neutral-700 text-neutral-600 dark:text-neutral-400":!t.connected&&!t.error}])},[t.connected?(o(),a("span",In,"Live - Connected")):t.error?(o(),a("span",En,"Connection Error")):(o(),a("span",An,"Offline"))],2)):L("",!0)]),_:1})]))}}),Pn={class:"flex flex-col flex-1"},On={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},jn={class:"flex items-center justify-between"},Dn={class:"flex items-center gap-2"},Un={class:"flex items-center gap-2"},Rn={class:"flex-1 overflow-y-auto text-xs"},Nn={key:0,class:"p-2 flex justify-center"},Bn={key:1,class:"p-2 text-red-600 dark:text-red-400"},qn={key:2,class:"text-neutral-500 dark:text-neutral-400 text-center py-12 text-base"},Fn={key:3},zn=["id","onClick"],Hn={class:"flex items-center gap-2 mb-1"},Wn={class:"font-medium truncate flex-1 min-w-0"},Jn={class:"flex-shrink-0 text-neutral-500 dark:text-neutral-400"},Zn={key:0,class:"flex flex-wrap gap-1"},Kn=se({__name:"ThreadListPane",props:{selectedThreadId:{}},emits:["selectThread","collapse","createThread","threadsLoaded"],setup(t,{expose:i,emit:n}){const u=n;v("");const{threads:l,isFetching:c,isFinished:r,error:p,refetch:f}=wn(),b=v([]),s=v(new Set),d=K(()=>{const k=l.value.filter(F=>!s.value.has(F.id)),O=new Set(k.map(F=>F.id));return[...b.value.filter(F=>!O.has(F.id)&&!s.value.has(F.id)),...k].sort((F,X)=>X.created_at-F.created_at)}),h=async k=>{if(k.type==="thread_created"){const O={id:k.thread.id,agent_id:k.thread.agent_name,user_id:k.thread.user_id,tags:k.thread.tags||[],created_at:k.thread.created_at,agent:{title:k.thread.agent_name,type:"ai_human"}};b.value.unshift(O)}else k.type==="thread_deleted"&&(s.value.add(k.threadId),b.value=b.value.filter(O=>O.id!==k.threadId))},{wsConnected:$,wsError:g}=_n({onEvent:h});ue(l,()=>{b.value=[]});const m=v(!1);ue(()=>({threads:l.value,finished:r.value}),({threads:k,finished:O})=>{O&&!m.value&&(m.value=!0,u("threadsLoaded",k[0]?.id??null))},{immediate:!0}),i({refetch:f});const w=k=>{u("selectThread",k)};return(k,O)=>(o(),a("div",Pn,[e("div",On,[e("div",jn,[e("div",Dn,[E(Z(qt),{size:18,class:"shrink-0"}),O[2]||(O[2]=e("h2",{class:"text-base font-bold"},"Threads",-1)),E(Vt,{connected:Z($),error:Z(g)},null,8,["connected","error"])]),e("div",Un,[e("button",{onClick:O[0]||(O[0]=D=>u("createThread")),type:"button",class:"px-2 py-1 text-xs bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity whitespace-nowrap"}," + New "),e("button",{onClick:O[1]||(O[1]=D=>u("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[E(Z($t),{size:20})])])])]),e("div",Rn,[Z(c)?(o(),a("div",Nn,[E(be)])):Z(p)?(o(),a("div",Bn," Error: "+C(Z(p)),1)):d.value.length===0?(o(),a("div",qn," No threads found ")):(o(),a("div",Fn,[(o(!0),a(pe,null,fe(d.value,D=>(o(),a("button",{key:D.id,id:`thread-${D.id}`,class:le(["w-full text-left px-2 py-2 border-b border-neutral-200 dark:border-neutral-800 cursor-pointer transition-colors relative hover:ring-2 hover:ring-inset hover:ring-accent-400 dark:hover:ring-accent-400",{"bg-accent-100 dark:bg-accent-900 dark:text-white ring-2 ring-inset ring-accent-400 dark:ring-accent-400":t.selectedThreadId===D.id}]),onClick:F=>w(D.id)},[e("div",Hn,[e("span",Wn,C(D.agent.title),1),e("span",Jn,[E(dt,{timestamp:D.created_at*1e6},null,8,["timestamp"])])]),D.tags.length>0?(o(),a("div",Zn,[(o(!0),a(pe,null,fe(D.tags,F=>(o(),a("span",{key:F,class:le(["inline-block px-1.5 py-0.5 rounded text-[10px]",t.selectedThreadId===D.id?"bg-accent-400 dark:bg-accent-950 text-accent-950 dark:text-accent-200":"bg-neutral-200 dark:bg-neutral-800 text-neutral-700 dark:text-neutral-300"])},C(F),3))),128))])):L("",!0)],10,zn))),128))]))])]))}}),st=150;function Gn(t,i={}){const{enableWebSocket:n=!0,autoConnect:u=!0}=i,l=v([]),c=v(null),r=v(!1),p=v(!1),f=v(null),b=v(!1),s=v(null),d=v(!1),h=v(!1),$=v(0),g=v(0);let m=null,w=null;function k(x){if(!c.value?.agent)return null;const V=c.value.agent,_=x==="assistant"?"A":"B";return _==="A"&&V.side_a_label?V.side_a_label:_==="B"&&V.side_b_label?V.side_b_label:null}function O(x,V){return x==="system"||V==="system"?!1:x!==V}const D=K(()=>{const x=[],V=l.value.filter(S=>(S.depth??0)===0),_=new Map;for(let S=0;S<V.length;S++){const P=V[S],J=P.role;if(J==="tool"){const ie=P.tool_call_id;if(ie&&_.has(ie)){const ve=_.get(ie),ke=x[ve],Ie=ke.items.find($e=>$e.type==="tool_call"&&$e.tool_call_id===ie);if(Ie){Ie.response=P.content||"",Ie.response_log_id=P.log_id;const $e=(P.content||"").toLowerCase(),Me=$e.length,Pe=$e.includes("failed")||$e.includes("error"),Le=Me<500;Pe&&Le?Ie.response_status="failed":Ie.response_status="success"}ke.updated_at=P.created_at,_.delete(ie)}continue}const re=k(J==="tool"?"assistant":J),A=x[x.length-1],I=A?.role;A&&O(J,I)&&A.type==="work"&&!A.isComplete&&(A.isComplete=!0);let M=null;if(P.tool_calls)if(typeof P.tool_calls=="string")try{M=JSON.parse(P.tool_calls)}catch(ie){console.error("Failed to parse tool_calls:",ie)}else Array.isArray(P.tool_calls)&&(M=P.tool_calls);const oe=M&&M.length>0,Y=A?.type==="work"&&A.role===J&&!A.isComplete;if(oe){let ie,ve;Y?(ie=A,ve=x.length-1):(ie={type:"work",id:P.id,role:J,items:[],created_at:P.created_at,updated_at:P.created_at,isComplete:!1,sideLabel:re,isExpanded:!1,request_sent_at:P.request_sent_at,response_completed_at:P.response_completed_at,status:P.status||"completed"},x.push(ie),ve=x.length-1),P.reasoning_content&&ie.items.push({id:`${P.id}-reasoning`,type:"reasoning",content:P.reasoning_content,created_at:P.created_at,log_id:P.log_id}),P.content&&ie.items.push({id:`${P.id}-content`,type:"content",content:P.content,created_at:P.created_at,log_id:P.log_id}),M.forEach(ke=>{ie.items.push({id:ke.id,type:"tool_call",content:ke.function.name,created_at:P.created_at,tool_name:ke.function.name,tool_call_id:ke.id,tool_arguments:ke.function.arguments,log_id:P.log_id,response:null,response_status:"pending",response_log_id:null}),_.set(ke.id,ve)}),ie.updated_at=P.created_at,P.response_completed_at&&(ie.response_completed_at=P.response_completed_at),P.status&&P.status!=="completed"?ie.status=P.status:P.status==="completed"&&ie.status==="pending"&&(ie.status="completed")}else Y&&P.status!=="pending"&&(A.isComplete=!0),(P.content||J==="system"||P.status==="pending")&&x.push({type:"text",id:P.id,role:J,content:P.content||"",created_at:P.created_at,log_id:P.log_id,sideLabel:re,isOptimistic:P.isOptimistic,status:P.status})}const T=x[x.length-1];return T?.type==="work"&&!T.isComplete&&(T.isComplete=!0),x});async function F(){if(!t.value){l.value=[],c.value=null,h.value=!1,$.value=0,g.value=0;return}r.value=!0,f.value=null;try{const x=await fetch(ae(`/api/threads/${t.value}/messages?limit=${st}&includeSilent=true`));if(!x.ok)throw new Error(`Failed to fetch messages: ${x.statusText}`);const V=await x.json();l.value=V.messages||[],h.value=V.hasMore||!1,$.value=V.total||0,g.value=st,console.log(`Loaded ${l.value.length} messages, total: ${$.value}, hasMore: ${h.value}`);const _=await fetch(ae(`/api/threads/${t.value}`));if(_.ok){const T=await _.json();c.value=T}}catch(x){f.value=x instanceof Error?x.message:"Unknown error",console.error("Error fetching messages:",x)}finally{r.value=!1}}async function X(){if(!(!t.value||p.value||!h.value)){p.value=!0;try{const x=await fetch(ae(`/api/threads/${t.value}/messages?limit=${st}&offset=${g.value}`));if(!x.ok)throw new Error(`Failed to fetch more messages: ${x.statusText}`);const V=await x.json(),_=V.messages||[];l.value=[..._,...l.value],h.value=V.hasMore||!1,g.value+=st,console.log(`Loaded ${_.length} more messages, offset now: ${g.value}, hasMore: ${h.value}`)}catch(x){f.value=x instanceof Error?x.message:"Unknown error",console.error("Error loading more messages:",x)}finally{p.value=!1}}}function te(){if(!(!n||!t.value||m))try{let V=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${ae(`/api/threads/${t.value}/stream?includeSilent=true`)}`;const _=localStorage.getItem("auth_token");_&&(V+=`&token=${encodeURIComponent(_)}`),m=new WebSocket(V),m.onopen=()=>{b.value=!0,s.value=null,console.log("WebSocket connected")},m.onmessage=T=>{try{if(T.data==="pong")return;const S=JSON.parse(T.data);if(S.type==="message_data"&&S.message_id){const P=S.message_id,J=S.data,re=l.value.findIndex(A=>A.id===P);if(re>=0)l.value[re]={...l.value[re],...J,id:P};else{const A={id:P,...J},I=l.value.filter(M=>{if(!M.isOptimistic)return!0;if(M.id===P)return!1;const oe=M.content===A.content,Y=M.role===A.role,ie=Math.abs(M.created_at-A.created_at)<5e6;return!(oe&&Y&&ie)});I.push(A),l.value=I.sort((M,oe)=>M.created_at-oe.created_at)}if(J.status==="pending")d.value=!0;else if(J.status==="completed"||J.status==="failed"){const A=l.value.some(I=>{if((I.depth??0)>0)return!1;if(I.status==="pending"||I.role==="tool"&&I.tool_call_id&&!I.tool_status)return!0;if(I.tool_calls)try{const oe=JSON.parse(I.tool_calls);if(Array.isArray(oe)&&oe.length>0&&!oe.every(ie=>l.value.some(ve=>(ve.depth??0)===0&&ve.role==="tool"&&ve.tool_call_id===ie.id&&ve.tool_status)))return!0}catch{}return!1});d.value=A}}else if(S.type==="message_chunk"){const P=S.message_id,J=S.chunk,re=l.value.findIndex(A=>A.id===P);if(re>=0){const A=l.value[re].content||"",I={...l.value[re],content:A+J};l.value.splice(re,1,I)}else{const A={id:P,role:"assistant",content:J,created_at:Date.now()*1e3,status:"pending"};l.value.push(A),l.value=l.value.sort((I,M)=>I.created_at-M.created_at)}}else S.type==="event"?console.log("📡",S.eventType,S.data):S.type==="error"&&(s.value=S.error||"WebSocket error",console.error("WebSocket error:",S.error))}catch(S){console.error("Error parsing WebSocket message:",S)}},m.onerror=T=>{s.value="WebSocket connection error",console.error("WebSocket error:",T)},m.onclose=()=>{b.value=!1,m=null,t.value&&n&&(w=setTimeout(()=>{console.log("Attempting WebSocket reconnect..."),te()},3e3))}}catch(x){s.value=x instanceof Error?x.message:"Unknown error",console.error("Error connecting WebSocket:",x)}}function R(){w&&(clearTimeout(w),w=null),m&&(m.close(),m=null,b.value=!1)}async function j(){await F()}function W(x){l.value.push({...x,isOptimistic:!0})}function B(x){l.value=l.value.filter(V=>V.id!==x)}async function N(x){if(!t.value)return;const V=[...l.value];l.value=l.value.filter(_=>_.id!==x);try{if(!(await fetch(ae(`/api/threads/${t.value}/messages/${x}`),{method:"DELETE"})).ok)throw l.value=V,new Error("Failed to delete message")}catch(_){throw l.value=V,_}}async function U(x,V){if(!t.value)return;const _=[...l.value];l.value=l.value.map(T=>T.id===x?{...T,content:V}:T);try{if(!(await fetch(ae(`/api/threads/${t.value}/messages/${x}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:V})})).ok)throw l.value=_,new Error("Failed to update message")}catch(T){throw l.value=_,T}}async function y(){if(t.value){d.value=!1;try{if(!(await fetch(ae(`/api/threads/${t.value}/stop`),{method:"POST"})).ok)throw new Error("Failed to stop thread")}catch(x){throw console.error("Error stopping thread:",x),x}}}return ue(t,async(x,V)=>{x!==V&&(R(),x?(await F(),u&&n&&te()):(l.value=[],c.value=null))},{immediate:u}),Be(()=>{R()}),{messages:D,threadInfo:c,isFetching:r,isLoadingMore:p,error:f,wsConnected:b,wsError:s,isExecuting:d,hasMore:h,totalMessages:$,refetch:j,loadMoreMessages:X,connectWebSocket:te,disconnectWebSocket:R,addOptimisticMessage:W,removeOptimisticMessage:B,deleteMessageById:N,updateMessageContent:U,stopThread:y}}const Xn=["onMouseenter","onMouseleave","onClick"],Yn=["onClick"],Qn={key:0,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"3",stroke:"currentColor",class:"w-3 h-3 text-white"},er={key:1,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2.5",stroke:"currentColor",class:"w-3 h-3 text-white"},tr={key:0,class:"w-full text-center text-xs text-neutral-400 dark:text-neutral-500 py-1"},or=["contenteditable","onInput"],lr={key:1,class:"flex gap-1 items-center min-h-[1.5rem]"},ar={key:0,class:"opacity-50"},sr={key:1,class:"opacity-50 italic text-neutral-500 dark:text-neutral-400"},nr=["onClick","onMouseenter"],rr={key:0,class:"space-y-1"},ir={class:"flex items-start gap-2"},dr={class:"flex-1 min-w-0"},ur={key:0,class:"truncate opacity-80"},cr={key:1,class:"italic opacity-60"},pr={class:"flex items-center gap-2 pl-5 opacity-60"},mr={class:"text-[10px]"},vr={class:"text-[10px]"},fr={key:1,class:"space-y-2"},hr={class:"flex items-center gap-2 pb-1 border-b border-current opacity-70"},gr={class:"text-[10px] italic"},br={class:"text-[10px] ml-auto"},xr={key:0,class:"space-y-1"},yr=["onClick","onMouseenter"],kr={class:"font-mono text-[11px] flex-shrink-0"},wr={key:2,class:"text-[10px] opacity-60 px-2 truncate flex-1 min-w-0"},_r={key:3,class:"text-[10px] text-green-600 dark:text-green-400 ml-auto flex-shrink-0"},$r={key:0,class:"pl-4 space-y-2 text-[10px]"},Cr={key:0},Vr={class:"w-full border-collapse"},Sr={class:"py-0.5 pr-2 opacity-65 align-top"},Tr={class:"py-0.5 opacity-85 break-all"},Mr={key:1},Lr=["onClick","onMouseenter"],Ir={class:"whitespace-pre-wrap break-all"},Er={key:1,class:"text-[10px]"},Ar=["onClick"],Pr={key:0,class:"mt-1 pl-4 whitespace-pre-wrap break-words opacity-80"},Or={key:2,class:"text-[10px] opacity-80 pl-4 pb-2 break-words"},jr=se({__name:"AgentMessages",props:{messages:{},selectedMessageId:{},selectedLogId:{},hoveredLogId:{},isEditMode:{type:Boolean},selectedForDelete:{},editedMessages:{}},emits:["messageClick","messageHover","selectionChange","messageEdit"],setup(t,{expose:i,emit:n}){const u=t,l=n;function c(A){const I=u.selectedForDelete?.has(A)??!1;l("selectionChange",A,!I)}function r(A,I){const oe=A.target.innerText;l("messageEdit",I,oe)}function p(A){return u.editedMessages?.has(A)??!1}const f=v(new Map);function b(A,I){I?f.value.set(A,I):f.value.delete(A)}function s(A){const I=u.messages.findIndex(M=>M.log_id===A);if(I<=0)return-1;for(let M=I-1;M>=0;M--){const oe=u.messages[M];if(oe.role==="user")return M;if(oe.role==="assistant"&&oe.log_id)break}return-1}function d(A){for(let I=0;I<u.messages.length;I++){const M=u.messages[I];if(M.log_id===A||M.type==="work"&&M.items&&M.items.some(ie=>ie.log_id===A||ie.response_log_id===A))return I}return-1}function h(A,I){const oe=d(A);if(oe===-1)return!1;const Y=f.value.get(oe);if(!Y)return!1;const ie=u.messages[oe];let ve=null;if(ie.role==="assistant"&&ie.log_id){const $e=s(ie.log_id);ve=$e!==-1?f.value.get($e):null}const ke=I.getBoundingClientRect(),Ie=Y.getBoundingClientRect();if(Ie.top<ke.top){const Pe=(ve||Y).getBoundingClientRect().top-ke.top-10;I.scrollBy({top:Pe,behavior:"smooth"})}else if(Ie.bottom>ke.bottom){const $e=Ie.bottom-ke.bottom+10;I.scrollBy({top:$e,behavior:"smooth"})}else if(ve){const $e=ve.getBoundingClientRect();if($e.top<ke.top){const Me=$e.top-ke.top-10;I.scrollBy({top:Me,behavior:"smooth"})}}return!0}function $(A){for(const I of u.messages){if(I.type!=="work")continue;if(I.items.some(Y=>Y.log_id===A||Y.response_log_id===A))return!0}return!1}i({scrollToLogId:h,hasWorkblockForLogId:$});function g(A){const I=u.messages[A];if(I.log_id)return I.log_id;if(I.role==="user")for(let M=A+1;M<u.messages.length;M++){const oe=u.messages[M];if(oe.log_id)return oe.log_id;if(oe.role==="user")break}return null}function m(A,I){return I?g(A)===I:!1}function w(A){const I=g(A);I&&l("messageHover",I)}function k(A){g(A)&&l("messageHover",null)}function O(A){const I=u.messages[A],M=g(A);M&&l("messageClick",I.id,M)}const D=v(new Set),F=v(new Set),X=v(new Set);function te(A){D.value.has(A)?D.value.delete(A):D.value.add(A)}function R(A){F.value.has(A)?F.value.delete(A):F.value.add(A)}function j(A){X.value.has(A)?X.value.delete(A):X.value.add(A)}function W(A){if(!A)return{};try{return JSON.parse(A)}catch{return{raw:A}}}function B(A){if(!A)return null;const I=W(A),M=Object.keys(I);if(M.length===0)return null;const oe=I[M[0]];return typeof oe=="string"?oe:JSON.stringify(oe)}function N(A){return new Date(A/1e3).toLocaleTimeString()}function U(A){const I=Math.round(A/1e6);if(I<1)return"< 1s";if(I<60)return`${I}s`;const M=Math.floor(I/60),oe=I%60;return`${M}m ${oe}s`}function y(A){if(A.status==="pending")return"...";if(!A.isComplete)return"Working...";let I;return A.request_sent_at&&A.response_completed_at?I=A.response_completed_at-A.request_sent_at:I=A.updated_at-A.created_at,`Worked for ${U(I)}`}function x(A){const I=A.filter(M=>M.type==="content");if(I.length===0){const M=A.filter(oe=>oe.type==="reasoning");return M.length>0?M[M.length-1].content:null}return I[I.length-1].content}function V(A){const M=A.trim().split(`
2
+ `)[0];return M.length>60?M.substring(0,60):M}function _(A){return u.selectedMessageId===A.id?!0:u.selectedLogId?A.items.some(I=>I.log_id===u.selectedLogId||I.response_log_id===u.selectedLogId):!1}function T(A){return!!(u.selectedLogId&&(A.log_id===u.selectedLogId||A.response_log_id===u.selectedLogId))}function S(A){return u.hoveredLogId?A.items.some(I=>I.log_id===u.hoveredLogId||I.response_log_id===u.hoveredLogId):!1}function P(A){return!!(u.hoveredLogId&&(A.log_id===u.hoveredLogId||A.response_log_id===u.hoveredLogId))}function J(A){const I=[];for(const M of A.items)M.log_id&&I.push(M.log_id),M.response_log_id&&I.push(M.response_log_id);return I}function re(A){return A?A.trim():""}return(A,I)=>(o(),a("div",null,[(o(!0),a(pe,null,fe(t.messages,(M,oe)=>(o(),a("div",{key:M.id,ref_for:!0,ref:Y=>b(oe,Y),class:"flex items-center gap-2 pb-3",onMouseenter:Y=>w(oe),onMouseleave:Y=>k(oe),onClick:Y=>t.isEditMode?c(M.id):O(oe)},[t.isEditMode&&M.role!=="system"?(o(),a("button",{key:0,onClick:we(Y=>c(M.id),["stop"]),class:le(["flex-shrink-0 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",{"border-red-500 bg-red-500":t.selectedForDelete?.has(M.id),"border-green-500 bg-green-500":!t.selectedForDelete?.has(M.id)&&p(M.id),"border-neutral-400 dark:border-neutral-500 bg-transparent hover:border-neutral-500 dark:hover:border-neutral-400":!t.selectedForDelete?.has(M.id)&&!p(M.id)}])},[t.selectedForDelete?.has(M.id)?(o(),a("svg",Qn,[...I[4]||(I[4]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 12.75l6 6 9-13.5"},null,-1)])])):p(M.id)?(o(),a("svg",er,[...I[5]||(I[5]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125"},null,-1)])])):L("",!0)],10,Yn)):L("",!0),e("div",{class:le(["flex-1 flex items-center gap-2 min-w-0",{"justify-start":M.role==="assistant","justify-end":M.role==="user","justify-center":M.role==="system","cursor-pointer":g(oe)&&!t.isEditMode}])},[M.type==="text"&&M.role==="system"&&M.content?.includes("Execution stopped")?(o(),a("div",tr,C(M.content),1)):M.type==="text"?(o(),a("div",{key:1,class:le(["max-w-[80%] rounded-2xl px-4 py-2 text-sm transition-all min-h-[2.5rem]",[M.silent?"bg-neutral-300 text-neutral-500 dark:bg-neutral-700 dark:text-neutral-400 opacity-70 border-2 border-dashed border-neutral-400 dark:border-neutral-500":!t.isEditMode&&M.role!=="user"&&m(oe,t.selectedLogId)?"bg-accent-200 text-accent-950 dark:bg-accent-200 dark:text-accent-950 ring-2 ring-accent-400 dark:ring-accent-400":M.role==="assistant"?"bg-neutral-800 text-white dark:bg-neutral-300 dark:text-black":M.role==="user"?"bg-neutral-200 text-black dark:bg-neutral-800 dark:text-white":"bg-neutral-100 text-neutral-600 dark:bg-neutral-900 dark:text-neutral-400 text-xs",{"opacity-60":M.isOptimistic},{"ring-2 ring-accent-400 dark:ring-accent-400 !bg-accent-200 !text-accent-950 dark:!bg-accent-200 dark:!text-accent-950":!t.isEditMode&&M.role!=="user"&&g(oe)&&!M.silent&&!m(oe,t.selectedLogId)&&m(oe,t.hoveredLogId)},{"ring-2 ring-green-500 dark:ring-green-400":t.isEditMode&&p(M.id),"border border-dashed border-neutral-400 dark:border-neutral-500":t.isEditMode&&M.role!=="system"&&!p(M.id)}]])},[M.content||t.isEditMode?(o(),a("div",{key:0,class:"whitespace-pre-wrap break-words text-sm outline-none",contenteditable:t.isEditMode&&M.role!=="system",onInput:Y=>r(Y,M.id),onClick:I[0]||(I[0]=Y=>t.isEditMode&&Y.stopPropagation())},C(re(M.content)),41,or)):M.status==="pending"?(o(),a("div",lr,[...I[6]||(I[6]=[e("span",{class:"typing-dot",style:{"animation-delay":"0ms"}},null,-1),e("span",{class:"typing-dot",style:{"animation-delay":"150ms"}},null,-1),e("span",{class:"typing-dot",style:{"animation-delay":"300ms"}},null,-1)])])):L("",!0),M.status!=="pending"?(o(),a("div",{key:2,class:le(["text-[10px] mt-1 opacity-50 flex gap-2",{"justify-start":M.role==="assistant","justify-end":M.role!=="assistant"}])},[M.sideLabel?(o(),a("span",ar,C(M.sideLabel),1)):L("",!0),e("span",null,C(N(M.created_at)),1),M.silent?(o(),a("span",sr," silent ")):L("",!0)],2)):L("",!0)],2)):M.type==="work"?(o(),a("div",{key:2,class:le(["w-full rounded-lg px-3 py-2 text-xs transition-all border overflow-hidden",{"cursor-pointer":!t.isEditMode,"bg-neutral-50 text-neutral-700 border-neutral-200 dark:bg-neutral-900 dark:text-neutral-300 dark:border-neutral-700":M.role==="assistant"&&!M.silent,"bg-accent-50 text-accent-700 border-accent-200 dark:bg-accent-50 dark:text-accent-700 dark:border-accent-200":M.role==="user"&&!M.silent,"bg-neutral-200 text-neutral-500 border-neutral-400 dark:bg-neutral-800 dark:text-neutral-400 dark:border-neutral-600 opacity-70 border-dashed":M.silent,"ring-2 ring-accent-500":!t.isEditMode&&_(M),"ring-2 ring-accent-400":!t.isEditMode&&!_(M)&&S(M)}]),onClick:Y=>!t.isEditMode&&(te(M.id),J(M)[0]&&l("messageClick",M.id,J(M)[0])),onMouseenter:Y=>!t.isEditMode&&J(M)[0]&&l("messageHover",J(M)[0]),onMouseleave:I[3]||(I[3]=Y=>!t.isEditMode&&l("messageHover",null))},[D.value.has(M.id)?(o(),a("div",fr,[e("div",hr,[E(Z(vt),{size:14,class:"flex-shrink-0"}),e("span",gr,C(y(M)),1),e("span",br,C(M.items.length)+" operation"+C(M.items.length!==1?"s":""),1)]),(o(!0),a(pe,null,fe(M.items,Y=>(o(),a("div",{key:Y.id,class:"mb-1"},[Y.type==="tool_call"?(o(),a("div",xr,[e("div",{onClick:we(ie=>{R(Y.id),Y.log_id&&l("messageClick",M.id,Y.log_id)},["stop"]),onMouseenter:we(ie=>Y.log_id&&l("messageHover",Y.log_id),["stop"]),onMouseleave:I[1]||(I[1]=we(ie=>l("messageHover",null),["stop"])),class:le(["flex items-center gap-2 cursor-pointer hover:opacity-70 transition-opacity min-w-0",{"ring-1 ring-accent-500":T(Y),"ring-1 ring-accent-400":!T(Y)&&P(Y)}])},[F.value.has(Y.id)?(o(),ee(Z(vt),{key:1,size:12,class:"flex-shrink-0 opacity-50"})):(o(),ee(Z(mt),{key:0,size:12,class:"flex-shrink-0 opacity-50"})),e("span",kr,C(Y.tool_name),1),B(Y.tool_arguments)?(o(),a("span",wr,C(B(Y.tool_arguments)),1)):L("",!0),Y.response_status==="success"?(o(),a("span",_r,"✓")):Y.response_status==="failed"?(o(),ee(Z(bo),{key:4,size:12,class:"ml-auto text-red-600 dark:text-red-400"})):L("",!0)],42,yr),F.value.has(Y.id)?(o(),a("div",$r,[Y.tool_arguments?(o(),a("div",Cr,[I[7]||(I[7]=e("div",{class:"font-semibold mb-1 opacity-70"},"Arguments:",-1)),e("table",Vr,[e("tbody",null,[(o(!0),a(pe,null,fe(W(Y.tool_arguments),(ie,ve)=>(o(),a("tr",{key:ve,class:"border-b border-current border-opacity-10"},[e("td",Sr,C(ve),1),e("td",Tr,C(typeof ie=="object"?JSON.stringify(ie):ie),1)]))),128))])])])):L("",!0),Y.response?(o(),a("div",Mr,[I[8]||(I[8]=e("div",{class:"font-semibold mb-1 opacity-70"},"Response:",-1)),e("div",{class:le(["opacity-80 cursor-pointer hover:opacity-100",{"ring-1 ring-accent-500":t.selectedLogId&&Y.response_log_id===t.selectedLogId,"ring-1 ring-accent-400":t.hoveredLogId&&Y.response_log_id===t.hoveredLogId&&Y.response_log_id!==t.selectedLogId}]),onClick:we(ie=>Y.response_log_id&&l("messageClick",M.id,Y.response_log_id),["stop"]),onMouseenter:we(ie=>Y.response_log_id&&l("messageHover",Y.response_log_id),["stop"]),onMouseleave:I[2]||(I[2]=we(ie=>l("messageHover",null),["stop"]))},[e("div",Ir,C(re(Y.response)),1)],42,Lr)])):L("",!0)])):L("",!0)])):Y.type==="reasoning"?(o(),a("div",Er,[e("button",{onClick:we(ie=>j(Y.id),["stop"]),class:"flex items-center gap-1 opacity-70 hover:opacity-100 transition-opacity"},[X.value.has(Y.id)?(o(),ee(Z(vt),{key:1,size:12,class:"flex-shrink-0"})):(o(),ee(Z(mt),{key:0,size:12,class:"flex-shrink-0"})),I[9]||(I[9]=e("span",{class:"font-semibold"},"Reasoning",-1))],8,Ar),X.value.has(Y.id)?(o(),a("div",Pr,C(re(Y.content)),1)):L("",!0)])):Y.type==="content"?(o(),a("div",Or,C(re(Y.content)),1)):L("",!0)]))),128))])):(o(),a("div",rr,[e("div",ir,[E(Z(mt),{size:14,class:"flex-shrink-0 mt-0.5 opacity-50"}),e("div",dr,[x(M.items)?(o(),a("div",ur,C(V(x(M.items)))+"... ",1)):(o(),a("div",cr,C(y(M)),1))])]),e("div",pr,[e("span",mr,C(M.items.length)+" operation"+C(M.items.length!==1?"s":""),1),e("span",vr,"• "+C(y(M)),1)])]))],42,nr)):L("",!0)],2)],40,Xn))),128))]))}}),Dr=Ze(jr,[["__scopeId","data-v-84fabff1"]]),Ur={key:0,class:"overflow-hidden border-b border-neutral-300 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-900"},Rr={class:"max-h-[400px] overflow-y-auto"},Nr={class:"flex items-center justify-between px-4 py-2 border-b border-neutral-200 dark:border-neutral-800 sticky top-0 bg-neutral-50 dark:bg-neutral-900"},Br={class:"p-4"},qr={key:0,class:"flex justify-center py-4"},Fr={key:1,class:"text-red-600 dark:text-red-400 text-center py-4 text-sm"},zr={key:2,class:"space-y-3 text-sm"},Hr={class:"flex items-start gap-2"},Wr={class:"font-mono text-xs break-all"},Jr={class:"flex items-start gap-2"},Zr={class:"flex-1"},Kr={key:0,class:"flex items-center gap-2"},Gr={class:"text-xs text-neutral-500"},Xr={key:1,class:"space-y-2"},Yr={class:"flex gap-2"},Qr=["disabled"],ei=["disabled"],ti={class:"flex items-start gap-2"},oi={key:0,class:"flex items-start gap-2"},li={class:"font-mono text-xs"},ai={class:"flex items-start gap-2"},si={class:"flex-1 flex items-center gap-2 flex-wrap"},ni={key:1,class:"text-neutral-500 dark:text-neutral-500 italic text-xs"},ri={class:"flex items-start gap-2"},ii=["disabled"],di={key:1,class:"flex justify-center py-2"},ui={key:1,class:"p-3 rounded border border-neutral-200 dark:border-neutral-700 bg-neutral-100 dark:bg-neutral-800 space-y-2"},ci={class:"flex items-center gap-4 text-xs"},pi={class:"font-mono font-bold ml-1"},mi={class:"font-mono font-bold ml-1"},vi={key:0,class:"text-xs"},fi={class:"w-full"},hi={class:"py-1"},gi={class:"text-right py-1 font-mono"},bi={class:"text-right py-1 font-mono"},xi={class:"pt-2 border-t border-neutral-200 dark:border-neutral-800 flex justify-end"},yi=["disabled"],ki={key:0},wi={key:1},_i=se({__name:"MetadataSlidePane",props:{threadId:{},show:{type:Boolean}},emits:["close","threadDeleted","editThread"],setup(t,{emit:i}){const n=t,u=i,{thread:l,isFetching:c,error:r}=Ct(K(()=>n.threadId)),p=v(!1),f=v(!1),b=v(!1),s=v(!1),d=v(""),h=v(!1),$=v(!1),g=v(null),{data:m,isFetching:w}=Ee(ae("/api/agents"),{refetch:!0}).json(),k=K(()=>m.value?.agents?m.value.agents.filter(B=>B.type==="ai_human").map(B=>({value:B.id,label:B.title,description:`Type: ${B.type}`})):[]),O=K(()=>l.value?.agent.type==="ai_human"),D=B=>new Date(B*1e3).toLocaleString(),F=()=>{l.value&&(d.value=l.value.agent.id,b.value=!0)},X=()=>{b.value=!1,d.value=""},te=async()=>{if(!(!n.threadId||!d.value)){s.value=!0;try{const B=await fetch(ae(`/api/threads/${n.threadId}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent_id:d.value})});if(!B.ok){const N=await B.json();throw new Error(N.error||"Failed to update agent")}window.location.reload()}catch(B){console.error("Error updating agent:",B),alert(`Failed to update agent: ${B.message}`)}finally{s.value=!1}}},R=async()=>{if(n.threadId){$.value=!0,h.value=!0;try{const B=await fetch(ae(`/api/threads/${n.threadId}/cost`));if(!B.ok){const N=await B.json();throw new Error(N.error||"Failed to fetch cost breakdown")}g.value=await B.json()}catch(B){console.error("Error fetching cost breakdown:",B),alert(`Failed to fetch cost breakdown: ${B.message}`),h.value=!1}finally{$.value=!1}}},j=B=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:6}).format(B),W=async()=>{if(n.threadId){f.value=!0;try{const B=await fetch(ae(`/api/threads/${n.threadId}`),{method:"DELETE"});if(!B.ok){const N=await B.json();throw new Error(N.error||"Failed to delete thread")}u("threadDeleted",n.threadId)}catch(B){console.error("Error deleting thread:",B),alert(`Failed to delete thread: ${B.message}`)}finally{f.value=!1}}};return ue(()=>n.show,B=>{B||(b.value=!1,d.value="")}),(B,N)=>(o(),ee(We,{"enter-active-class":"transition-all duration-300 ease-out","enter-from-class":"max-h-0 opacity-0","enter-to-class":"max-h-[400px] opacity-100","leave-active-class":"transition-all duration-200 ease-in","leave-from-class":"max-h-[400px] opacity-100","leave-to-class":"max-h-0 opacity-0"},{default:de(()=>[t.show&&t.threadId?(o(),a("div",Ur,[e("div",Rr,[e("div",Nr,[N[6]||(N[6]=e("span",{class:"text-sm font-medium text-neutral-600 dark:text-neutral-400"},"Thread Info",-1)),e("button",{onClick:N[0]||(N[0]=U=>u("close")),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors",title:"Close metadata"},[E(Z(xo),{size:16})])]),e("div",Br,[Z(c)?(o(),a("div",qr,[E(be)])):Z(r)?(o(),a("div",Fr," Error loading metadata: "+C(Z(r)),1)):Z(l)?(o(),a("div",zr,[e("div",Hr,[N[7]||(N[7]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"ID",-1)),e("span",Wr,C(Z(l).id),1)]),e("div",Jr,[N[8]||(N[8]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"Agent",-1)),e("div",Zr,[b.value?(o(),a("div",Xr,[E(he,{modelValue:d.value,"onUpdate:modelValue":N[1]||(N[1]=U=>d.value=U),options:k.value,loading:Z(w),placeholder:"Select an agent"},null,8,["modelValue","options","loading"]),e("div",Yr,[e("button",{onClick:te,disabled:s.value||!d.value,class:"px-2 py-1 text-xs bg-black dark:bg-white text-white dark:text-black hover:bg-black/80 dark:hover:bg-white/80 transition-colors disabled:opacity-50 disabled:cursor-not-allowed rounded"},C(s.value?"Saving...":"Save"),9,Qr),e("button",{onClick:X,disabled:s.value,class:"px-2 py-1 text-xs border border-black dark:border-neutral-300 hover:bg-black/5 dark:hover:bg-white/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed rounded"}," Cancel ",8,ei)])])):(o(),a("div",Kr,[e("span",null,C(Z(l).agent.title),1),e("span",Gr,"("+C(Z(l).agent.type)+")",1),O.value?(o(),a("button",{key:0,onClick:F,type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors",title:"Change agent"},[E(Z(bt),{size:12})])):L("",!0)]))])]),e("div",ti,[N[9]||(N[9]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"Created",-1)),e("span",null,C(D(Z(l).created_at)),1)]),Z(l).user_id?(o(),a("div",oi,[N[10]||(N[10]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"User",-1)),e("span",li,C(Z(l).user_id),1)])):L("",!0),e("div",ai,[N[11]||(N[11]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"Tags",-1)),e("div",si,[Z(l).tags?.length>0?(o(!0),a(pe,{key:0},fe(Z(l).tags,U=>(o(),a("span",{key:U,class:"inline-block px-2 py-0.5 text-xs rounded bg-black text-white dark:bg-white dark:text-black"},C(U),1))),128)):(o(),a("span",ni,"No tags")),e("button",{onClick:N[2]||(N[2]=U=>u("editThread")),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors",title:"Edit tags"},[E(Z(bt),{size:12})])])]),e("div",ri,[N[14]||(N[14]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 shrink-0 text-left"},"Cost",-1)),!h.value&&!$.value?(o(),a("button",{key:0,onClick:R,disabled:$.value,type:"button",class:"flex items-center gap-1 px-2 py-1 text-xs border border-black dark:border-white rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"},[E(Z(Mt),{size:12}),N[12]||(N[12]=e("span",null,"View Costs",-1))],8,ii)):L("",!0),$.value?(o(),a("div",di,[E(be)])):L("",!0),h.value?(o(),a("button",{key:2,onClick:N[3]||(N[3]=U=>h.value=!1),type:"button",class:"flex items-center gap-1 px-2 py-1 text-xs border border-black dark:border-white rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors"},[E(Z(Mt),{size:12}),N[13]||(N[13]=e("span",null,"Hide Costs",-1))])):L("",!0)]),h.value&&g.value?(o(),a("div",ui,[e("div",ci,[e("div",null,[N[15]||(N[15]=e("span",{class:"text-neutral-500"},"Total:",-1)),e("span",pi,C(j(g.value.totalCost)),1)]),e("div",null,[N[16]||(N[16]=e("span",{class:"text-neutral-500"},"Avg/msg:",-1)),e("span",mi,C(j(g.value.avgCostPerMessage)),1)])]),g.value.modelBreakdown.length>0?(o(),a("div",vi,[e("table",fi,[N[17]||(N[17]=e("thead",null,[e("tr",{class:"border-b border-neutral-300 dark:border-neutral-600"},[e("th",{class:"text-left py-1 font-medium text-neutral-500"}," Model "),e("th",{class:"text-right py-1 font-medium text-neutral-500"}," Reqs "),e("th",{class:"text-right py-1 font-medium text-neutral-500"}," Cost ")])],-1)),e("tbody",null,[(o(!0),a(pe,null,fe(g.value.modelBreakdown,U=>(o(),a("tr",{key:U.modelName},[e("td",hi,C(U.modelName),1),e("td",gi,C(U.requestCount),1),e("td",bi,C(j(U.totalCost)),1)]))),128))])])])):L("",!0)])):L("",!0),e("div",xi,[e("button",{onClick:N[4]||(N[4]=U=>p.value=!0),disabled:f.value,class:"flex items-center gap-1 px-2 py-1 text-xs text-red-600 border border-red-600 rounded hover:bg-red-50 dark:hover:bg-red-950/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"},[E(Z(yo),{size:12}),f.value?(o(),a("span",ki,"Deleting...")):(o(),a("span",wi,"Delete Thread"))],8,yi)])])):L("",!0)])]),E(eo,{modelValue:p.value,"onUpdate:modelValue":N[5]||(N[5]=U=>p.value=U),title:"Delete Thread?",message:"Are you sure you want to delete this thread? This will permanently delete all messages, logs, and associated data. This action cannot be undone.","confirm-text":"Delete Thread","cancel-text":"Cancel",onConfirm:W},null,8,["modelValue"])])):L("",!0)]),_:1}))}}),$i={class:"flex flex-col h-full"},Ci={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},Vi={class:"flex items-center justify-between"},Si={class:"flex items-center gap-2"},Ti={class:"flex items-center gap-2"},Mi={class:"flex-1 flex flex-col overflow-hidden relative"},Li={key:0,class:"text-neutral-500 dark:text-neutral-400 text-center py-8"},Ii={key:1,class:"flex justify-center py-2"},Ei={key:2,class:"flex justify-center py-8"},Ai={key:3,class:"text-red-600 dark:text-red-400 text-center py-8"},Pi={key:4,class:"text-neutral-500 dark:text-neutral-400 text-center py-8"},Oi={key:0,class:"p-3 bg-white dark:bg-neutral-900 border-t border-neutral-300 dark:border-neutral-700"},ji={class:"flex items-center justify-end gap-2"},Di=["disabled"],Ui={key:1,class:"p-3 bg-white dark:bg-neutral-900 border-t border-neutral-300 dark:border-neutral-700"},Ri={class:"flex items-start gap-2"},Ni={class:"flex-1 flex items-start gap-2 p-2 rounded-2xl border border-neutral-300 dark:border-neutral-700 bg-white dark:bg-neutral-900"},Bi=["disabled"],qi=["disabled"],Fi={key:0,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",class:"w-4 h-4"},zi={key:1,class:"w-4 h-4"},Hi=se({__name:"MessagesPane",props:{threadId:{},selectedMessageId:{},selectedLogId:{},hoveredLogId:{}},emits:["collapse","messageClick","messageHover","threadDeleted","editThread","logsDeleted"],setup(t,{expose:i,emit:n}){const u=t,l=n,c=v(!1),r=()=>{c.value=!c.value},p=v(!1),f=v(new Set),b=v(new Map),s=()=>{p.value=!p.value,p.value||(f.value=new Set,b.value=new Map)},d=(z,H)=>{const G=new Set(f.value);H?G.add(z):G.delete(z),f.value=G},h=(z,H)=>{const G=new Map(b.value);G.set(z,H),b.value=G},$=()=>{p.value=!1,f.value=new Set,b.value=new Map},g=K(()=>f.value.size),m=K(()=>{let z=0;for(const[H]of b.value)f.value.has(H)||z++;return z}),w=K(()=>{const z=g.value,H=m.value;return z>0&&H>0?`Delete (${z}), Update (${H})`:z>0?`Delete (${z})`:H>0?`Save changes (${H})`:"Delete"}),k=K(()=>g.value>0||m.value>0),O=async()=>{if(!u.threadId||!k.value)return;const z=[];for(const H of f.value){const G=D.value.find(ce=>ce.id===H);G&&"log_id"in G&&G.log_id&&z.push(G.log_id)}try{for(const[H,G]of b.value)f.value.has(H)||await _(H,G);for(const H of f.value)await V(H);z.length>0&&l("logsDeleted",z)}catch(H){console.error("Error applying changes:",H)}finally{$()}},{messages:D,threadInfo:F,isFetching:X,isLoadingMore:te,error:R,wsConnected:j,wsError:W,isExecuting:B,hasMore:N,loadMoreMessages:U,addOptimisticMessage:y,removeOptimisticMessage:x,deleteMessageById:V,updateMessageContent:_,stopThread:T}=Gn(K(()=>u.threadId),{enableWebSocket:!0}),{thread:S}=Ct(K(()=>u.threadId)),P=v(null),J=v(null);i({scrollToLogId:z=>J.value&&P.value?J.value.scrollToLogId(z,P.value):!1,hasWorkblockForLogId:z=>J.value?J.value.hasWorkblockForLogId(z):!1}),typeof window<"u"&&(window.__testLoadMoreMessages=U);const I=v(""),M=v(null),oe=v("B"),Y=v(!1),ie=v(!1),ve=async()=>{await ge(),P.value&&(P.value.scrollTop=P.value.scrollHeight)},ke=async z=>{z.target.scrollTop<100&&N.value&&!te.value&&!ie.value&&(ie.value=!0,await U(),ie.value=!1)};ue(()=>D.value.length,async()=>{!te.value&&!ie.value&&await ve()}),ue(()=>u.threadId,async z=>{z&&await ve()}),ue(X,async(z,H)=>{H&&!z&&await ve()});const Ie=K(()=>{const z=F.value?.agent||S.value?.agent;if(!z)return"ai A";const H=z.type;return oe.value==="A"&&z.side_a_label?z.side_a_label:oe.value==="B"&&z.side_b_label?z.side_b_label:H==="ai_human"?oe.value==="A"?"ai":"human":oe.value==="A"?"ai A":"ai B"}),$e=()=>{oe.value=oe.value==="A"?"B":"A"},Me=async()=>{if(!I.value.trim()||!u.threadId||Y.value)return;const z=I.value,H=oe.value==="A"?"assistant":"user",G=`optimistic-${Date.now()}`,ce={id:G,role:H,content:z,created_at:Date.now()*1e3,isOptimistic:!0};y(ce),I.value="",M.value&&(M.value.style.height="auto",M.value.style.height="24px"),Y.value=!0;try{if(!(await fetch(ae(`/api/threads/${u.threadId}/message`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:z,role:H})})).ok)throw new Error("Failed to send message");await ve()}catch(me){console.error("Error sending message:",me),x(G)}finally{Y.value=!1,await ge(),M.value&&M.value.focus()}},Pe=z=>{z.key==="Enter"&&!z.shiftKey&&(z.preventDefault(),Me())},Le=async()=>{if(u.threadId)try{await T()}catch(z){console.error("Error stopping thread:",z)}};return(z,H)=>(o(),a("div",$i,[e("div",Ci,[e("div",Vi,[e("div",Si,[E(Z(Ft),{size:18,class:"shrink-0"}),H[8]||(H[8]=e("h2",{class:"text-base font-bold"},"Messages",-1)),t.threadId?(o(),ee(Vt,{key:0,connected:Z(j),error:Z(W)},null,8,["connected","error"])):L("",!0)]),e("div",Ti,[t.threadId?(o(),a("button",{key:0,onClick:r,type:"button",class:le(["p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",{"bg-neutral-200 dark:bg-neutral-800":c.value}]),title:"Toggle metadata"},[E(Z(ko),{size:20})],2)):L("",!0),t.threadId&&Z(D).length>0?(o(),a("button",{key:1,onClick:s,type:"button",class:le(["p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",{"bg-neutral-200 dark:bg-neutral-800":p.value}]),title:"Edit messages"},[E(Z(bt),{size:20})],2)):L("",!0),e("button",{onClick:H[0]||(H[0]=G=>l("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[E(Z($t),{size:20})])])])]),e("div",Mi,[E(_i,{"thread-id":t.threadId,show:c.value,onClose:H[1]||(H[1]=G=>c.value=!1),onThreadDeleted:H[2]||(H[2]=G=>l("threadDeleted",G)),onEditThread:H[3]||(H[3]=G=>l("editThread"))},null,8,["thread-id","show"]),e("div",{ref_key:"messagesContainer",ref:P,class:"flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-4",onScroll:ke},[t.threadId?L("",!0):(o(),a("div",Li," Select a thread to view messages ")),Z(te)?(o(),a("div",Ii,[E(be,{size:"sm"}),H[9]||(H[9]=e("span",{class:"ml-2 text-xs text-neutral-500"},"Loading older messages...",-1))])):Z(X)?(o(),a("div",Ei,[E(be)])):Z(R)?(o(),a("div",Ai," Error loading messages: "+C(Z(R)),1)):t.threadId&&Z(D).length===0?(o(),a("div",Pi," No messages yet ")):(o(),ee(Dr,{key:5,ref_key:"agentMessagesRef",ref:J,messages:Z(D),selectedMessageId:t.selectedMessageId,selectedLogId:t.selectedLogId,hoveredLogId:t.hoveredLogId,isEditMode:p.value,selectedForDelete:f.value,editedMessages:b.value,onMessageClick:H[4]||(H[4]=(G,ce)=>l("messageClick",G,ce)),onMessageHover:H[5]||(H[5]=G=>l("messageHover",G)),onSelectionChange:d,onMessageEdit:h},null,8,["messages","selectedMessageId","selectedLogId","hoveredLogId","isEditMode","selectedForDelete","editedMessages"]))],544),t.threadId&&p.value?(o(),a("div",Oi,[e("div",ji,[e("button",{onClick:$,class:"px-4 py-2 rounded-lg font-medium text-sm transition-colors bg-neutral-200 text-black hover:bg-neutral-300 dark:bg-neutral-700 dark:text-white dark:hover:bg-neutral-600"}," Cancel "),e("button",{onClick:O,disabled:!k.value,class:le(["px-4 py-2 rounded-lg font-medium text-sm transition-colors",{"bg-red-600 text-white hover:bg-red-700":k.value&&g.value>0,"bg-black text-white hover:bg-neutral-800 dark:bg-white dark:text-black dark:hover:bg-neutral-200":k.value&&g.value===0,"bg-neutral-200 text-neutral-400 dark:bg-neutral-700 dark:text-neutral-500 cursor-not-allowed":!k.value}])},C(w.value),11,Di)])])):t.threadId?(o(),a("div",Ui,[e("div",Ri,[e("button",{onClick:$e,class:le(["flex-shrink-0 px-2 h-7 rounded-md flex items-center justify-center font-medium text-xs transition-colors mt-2.5",{"bg-black text-white dark:bg-white dark:text-black":oe.value==="A","bg-neutral-300 text-black dark:bg-neutral-600 dark:text-white":oe.value==="B"}]),title:"Toggle between sides"},C(Ie.value),3),e("div",Ni,[Se(e("textarea",{ref_key:"messageTextarea",ref:M,"onUpdate:modelValue":H[6]||(H[6]=G=>I.value=G),onKeydown:Pe,disabled:Y.value,placeholder:"Type a message...",rows:"1",class:"flex-1 bg-transparent text-black dark:text-white resize-none focus:outline-none disabled:opacity-50 mt-0.5",style:{"max-height":"120px","min-height":"24px"},onInput:H[7]||(H[7]=G=>{const ce=G.target;ce.style.height="auto",ce.style.height=Math.min(ce.scrollHeight,120)+"px"})},null,40,Bi),[[Oe,I.value]]),Z(B)?(o(),a("button",{key:1,id:"stop-thread-button",onClick:Le,class:"flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center transition-all bg-red-600 text-white dark:bg-red-500 hover:bg-red-700 dark:hover:bg-red-600",title:"Stop execution"},[...H[11]||(H[11]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",class:"w-4 h-4"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5.25 7.5A2.25 2.25 0 017.5 5.25h9a2.25 2.25 0 012.25 2.25v9a2.25 2.25 0 01-2.25 2.25h-9a2.25 2.25 0 01-2.25-2.25v-9z"})],-1)])])):(o(),a("button",{key:0,id:"send-message-button",onClick:Me,disabled:!I.value.trim()||Y.value,class:le(["flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center transition-all",{"bg-black text-white dark:bg-white dark:text-black":I.value.trim()&&!Y.value,"bg-neutral-200 text-neutral-400 dark:bg-neutral-700 dark:text-neutral-600":!I.value.trim()||Y.value}]),title:"Send message (Enter)"},[Y.value?(o(),a("div",zi,[E(be)])):(o(),a("svg",Fi,[...H[10]||(H[10]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 10.5 12 3m0 0 7.5 7.5M12 3v18"},null,-1)])]))],10,qi))])])])):L("",!0)])]))}});function Wi(t,i){const{limit:n=100,offset:u=0,order:l="desc",autoFetch:c=!0,enableWebSocket:r=!1}=i||{};K(()=>!!(typeof t=="string"?t:t?.value));const p=K(()=>{const W=typeof t=="string"?t:t?.value;if(!W)return ae("/api/threads/placeholder/logs");const B=new URLSearchParams,N=typeof n=="number"?n:n.value,U=typeof u=="number"?u:u.value,y=typeof l=="string"?l:l.value;return B.append("limit",N.toString()),B.append("offset",U.toString()),B.append("order",y),ae(`/api/threads/${W}/logs?${B.toString()}`)}),{data:f,error:b,isFetching:s,isFinished:d,execute:h,abort:$}=Ee(p,{immediate:!1}).get().json();ue([p,()=>c],([W,B])=>{W&&!W.includes("placeholder")&&B&&h()},{immediate:!0});const g=K(()=>!b.value||b.value.toString().includes("aborted")||b.value.toString().includes("abort")?null:b.value),m=K(()=>f.value?.logs||[]),w=K(()=>f.value?.total||0),k=K(()=>f.value?.hasMore||!1),O=v(null),D=v(!1),F=v(null),X=v([]),te=()=>{const W=typeof t=="string"?t:t?.value;if(!W||!r)return;O.value&&O.value.close(),X.value=[];const B=window.location.protocol==="https:"?"wss:":"ws:",N=window.location.host;let U=`${B}//${N}${ae(`/api/threads/${W}/logs`)}`;const y=localStorage.getItem("auth_token");y&&(U+=`?token=${encodeURIComponent(y)}`);try{O.value=new WebSocket(U),O.value.onopen=()=>{D.value=!0,F.value=null,console.log("WebSocket connected for logs")},O.value.onmessage=x=>{try{const V=JSON.parse(x.data);if(V.type==="log_data"){const _=X.value.findIndex(S=>S.id===V.log_id),T=m.value.find(S=>S.id===V.log_id);_>=0?(X.value[_]={...X.value[_],...V.data},console.log("[WebSocket] Updated existing realtime log:",V.log_id)):T?(X.value.push({...T,...V.data}),console.log("[WebSocket] Updated HTTP log:",V.log_id)):(X.value.push({id:V.log_id,...V.data}),console.log("[WebSocket] Added new log:",V.log_id))}}catch(V){console.error("Failed to parse WebSocket message:",V)}},O.value.onerror=x=>{F.value="WebSocket connection error",D.value=!1,console.error("WebSocket error:",x)},O.value.onclose=()=>{D.value=!1,console.log("WebSocket disconnected")}}catch(x){F.value=x.message||"Failed to create WebSocket",console.error("WebSocket creation error:",x)}},R=()=>{O.value&&(O.value.close(),O.value=null,D.value=!1),X.value=[]};return Be(()=>{R()}),{logs:K(()=>{if(!r)return m.value;const W=new Map;m.value.forEach(U=>W.set(U.id,U)),X.value.forEach(U=>W.set(U.id,U));const B=typeof l=="string"?l:l.value;return Array.from(W.values()).sort((U,y)=>B==="desc"?y.created_at-U.created_at:U.created_at-y.created_at)}),total:w,hasMore:k,error:g,isFetching:s,isFinished:d,refetch:h,abort:$,wsConnected:D,wsError:F,connectWebSocket:te,disconnectWebSocket:R}}function Ji(t,i){const n=K(()=>{const p=t.value,f=i.value;return!p||!f?null:ae(`/api/threads/${p}/logs/${f}`)}),{data:u,error:l,isFetching:c,execute:r}=Ee(n,{immediate:!1}).get().json();return ue([t,i],([p,f])=>{p&&f&&r()},{immediate:!0}),{logDetails:u,error:l,isFetching:c,refetch:r}}const Zi=["disabled","title"],Ki={key:1,xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},Gi={key:2,xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},Xi={key:3},ft=se({__name:"CopyButton",props:{content:{},variant:{},size:{},disabled:{type:Boolean}},setup(t){const i=t,n=v(!1),u=v(!1),l=async()=>{n.value=!0;try{await navigator.clipboard.writeText(i.content),u.value=!0,setTimeout(()=>{u.value=!1},2e3)}catch(p){console.error("Failed to copy:",p),alert(`Failed to copy: ${p instanceof Error?p.message:"Unknown error"}`)}finally{n.value=!1}},c={xs:"p-1 text-xs",sm:"px-2 py-1 text-xs"},r={solid:"bg-black text-white dark:bg-white dark:text-black",ghost:"bg-white dark:bg-neutral-950 border border-neutral-300 dark:border-neutral-700 text-neutral-700 dark:text-neutral-300 hover:bg-neutral-50 dark:hover:bg-neutral-900"};return(p,f)=>(o(),a("button",{onClick:l,disabled:n.value||t.disabled,class:le([c[t.size||"sm"],r[t.variant||"solid"],"font-medium rounded hover:opacity-80 disabled:opacity-50 disabled:cursor-not-allowed transition-all"]),title:t.disabled?"No content to copy":u.value?"Copied!":"Copy to clipboard"},[n.value?(o(),ee(be,{key:0,size:"xs"})):t.variant==="ghost"&&!u.value?(o(),a("svg",Ki,[...f[0]||(f[0]=[e("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"},null,-1),e("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"},null,-1)])])):t.variant==="ghost"&&u.value?(o(),a("svg",Gi,[...f[1]||(f[1]=[e("polyline",{points:"20 6 9 17 4 12"},null,-1)])])):(o(),a("span",Xi,C(u.value?"Copied!":"Copy"),1))],10,Zi))}}),ht="__shiki_highlighter__";let nt=null;async function Yi(){return typeof window<"u"&&window[ht]?window[ht]:nt||(nt=Io({themes:["min-light","github-dark-high-contrast"],langs:["json","markdown"]}).then(t=>(typeof window<"u"&&(window[ht]=t),t)),nt)}const Qi={class:"code-block"},ed={key:0,class:"text-xs text-neutral-500 p-2"},td=["innerHTML"],Xe=se({__name:"CodeBlock",props:{code:{},language:{}},setup(t){const i=t,n=v(""),u=v(!0),l=async()=>{const c=i.code??"";if(!c){n.value='<pre class="shiki"><code></code></pre>',u.value=!1;return}try{const r=await Yi();if(i.language==="json"||i.language==="markdown")n.value=r.codeToHtml(c,{lang:i.language,themes:{light:"min-light",dark:"github-dark-high-contrast"}});else{const p=c.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");n.value=`<pre class="shiki shiki-text"><code>${p}</code></pre>`}}catch{const p=c.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");n.value=`<pre class="shiki"><code>${p}</code></pre>`}finally{u.value=!1}};return xe(()=>{l()}),ue(()=>i.code,()=>{l()}),(c,r)=>(o(),a("div",Qi,[u.value?(o(),a("div",ed,"Loading...")):(o(),a("div",{key:1,innerHTML:n.value,class:"code-content"},null,8,td))]))}}),od={class:"text-xs font-semibold"},ld={class:"flex items-center gap-2"},ad={class:"text-neutral-500 text-xs"},rt=se({__name:"CollapsibleSection",props:{title:{},sectionId:{},expanded:{type:Boolean},scrollContainer:{}},emits:["toggle"],setup(t,{expose:i,emit:n}){const u=t,l=n,c=v(null),r=v(!1),p=()=>{ge(()=>{if(!c.value||!u.scrollContainer){r.value=!1;return}const s=u.scrollContainer.clientHeight;r.value=c.value.scrollHeight>s*2})};ue(()=>u.expanded,s=>{s?p():r.value=!1});const f=()=>{if(c.value&&u.scrollContainer){const h=c.value.offsetTop-88;u.scrollContainer.scrollTo({top:Math.max(0,h),behavior:"smooth"})}},b=()=>{if(c.value&&u.scrollContainer){const s=c.value.offsetTop+c.value.offsetHeight,d=u.scrollContainer.clientHeight,h=s-d+10;u.scrollContainer.scrollTo({top:Math.max(0,h),behavior:"smooth"})}};return i({checkHeight:p,contentRef:c}),(s,d)=>(o(),a("div",null,[e("div",{class:"sticky top-[27px] z-5 w-full px-3 py-2 bg-neutral-50 dark:bg-neutral-950 flex items-center justify-between border border-neutral-300 dark:border-neutral-700 rounded cursor-pointer hover:bg-neutral-100 dark:hover:bg-neutral-950 transition-colors",onClick:d[0]||(d[0]=h=>l("toggle"))},[e("span",od,C(t.title),1),e("div",ld,[r.value&&t.expanded?(o(),a(pe,{key:0},[e("button",{onClick:we(f,["stop"]),class:"text-[10px] text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300"},"↑ Top"),e("button",{onClick:we(b,["stop"]),class:"text-[10px] text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300"},"↓ Bottom")],64)):L("",!0),e("span",ad,C(t.expanded?"▼":"▶"),1)])]),Se(e("div",{ref_key:"contentRef",ref:c,class:"border-x border-b border-neutral-300 dark:border-neutral-700 rounded-b"},[He(s.$slots,"default")],512),[[Ye,t.expanded]])]))}}),sd={class:"flex items-center justify-between mb-3"},nd={class:"flex items-center gap-2"},rd={class:"flex items-center gap-1"},id=["disabled"],dd=["disabled"],ud={class:"text-lg font-bold"},cd={class:"flex items-center gap-2"},pd=["disabled","title"],md={key:1},vd={class:"@container border-b border-neutral-300 dark:border-neutral-700 pb-3"},fd={class:"hidden @[600px]:block"},hd={class:"w-full text-xs"},gd={class:"py-1 font-mono"},bd={class:"py-1 font-mono"},xd={key:1},yd={class:"py-1 font-mono"},kd={key:1},wd={class:"py-1 font-mono"},_d={key:1},$d={class:"py-1 font-mono"},Cd={key:1},Vd={class:"py-1 font-mono text-xs"},Sd={class:"@[600px]:hidden space-y-2"},Td={class:"w-full text-xs"},Md={class:"py-1 font-mono"},Ld={class:"py-1 font-mono"},Id={key:1},Ed={class:"w-full text-xs"},Ad={class:"py-1 font-mono"},Pd={key:1},Od={class:"py-1 font-mono"},jd={key:1},Dd={class:"py-1 font-mono"},Ud={key:1},Rd={class:"py-1 font-mono text-xs"},Nd={class:"sticky -top-4 z-10 bg-white dark:bg-neutral-900 border-b border-neutral-300 dark:border-neutral-700 mb-3 pt-3 -mx-4 px-4"},Bd={class:"flex gap-4"},qd={key:0,class:"text-red-600 dark:text-red-400"},Fd={class:"space-y-3"},zd={class:"space-y-2"},Hd=["onClick"],Wd={class:"font-mono"},Jd={class:"text-neutral-500"},Zd={class:"px-2 py-2 bg-white dark:bg-neutral-950 border-t border-neutral-200 dark:border-neutral-800"},Kd={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mb-2"},Gd={class:"relative bg-white dark:bg-neutral-900"},Xd={class:"absolute top-[5px] right-[5px]"},Yd={class:"relative bg-white dark:bg-neutral-900"},Qd={class:"absolute top-[5px] right-[5px]"},eu={class:"relative bg-white dark:bg-neutral-900"},tu={class:"absolute top-[5px] right-[5px]"},ou={key:0,class:"mb-4"},lu={class:"text-xs font-semibold text-red-600 dark:text-red-400 mb-1"},au={class:"space-y-2"},su={class:"px-2 py-1 bg-red-100 dark:bg-red-900/30 text-xs font-medium text-red-800 dark:text-red-200"},nu={class:"text-xs bg-red-50 dark:bg-red-950 p-2 overflow-x-auto text-red-900 dark:text-red-100"},ru={key:1,class:"mb-4"},iu={class:"text-xs font-semibold text-red-600 dark:text-red-400 mb-1"},du={class:"text-xs bg-red-50 dark:bg-red-950 p-2 rounded overflow-x-auto text-red-900 dark:text-red-100 border border-red-300 dark:border-red-700"},uu={key:2,class:"mb-4"},cu={class:"w-full text-xs border border-neutral-300 dark:border-neutral-700 rounded"},pu={class:"border-b border-neutral-200 dark:border-neutral-800"},mu={class:"py-1 px-2 font-mono"},vu={key:1},fu={class:"border-b border-neutral-200 dark:border-neutral-800"},hu={class:"py-1 px-2 font-mono"},gu={key:1},bu={key:0,class:"border-b border-neutral-200 dark:border-neutral-800"},xu={class:"py-1 px-2 font-mono"},yu={key:1},ku={class:"border-b border-neutral-200 dark:border-neutral-800"},wu={class:"py-1 px-2 font-mono"},_u={key:1},$u={key:1,class:"border-b border-neutral-200 dark:border-neutral-800"},Cu={class:"py-1 px-2 font-mono text-accent-600 dark:text-accent-400"},Vu={class:"border-b border-neutral-200 dark:border-neutral-800"},Su={class:"py-1 px-2 font-mono font-semibold"},Tu={key:1},Mu={class:"py-1 px-2 font-mono font-semibold"},Lu={key:1},Iu={key:3,class:"mb-4"},Eu={class:"text-xs font-semibold mb-1"},Au={class:"border border-neutral-300 dark:border-neutral-700 rounded overflow-hidden"},Pu=["onClick"],Ou={class:"font-mono"},ju={class:"text-neutral-500"},Du={class:"px-2 py-2 bg-white dark:bg-neutral-950 border-t border-neutral-200 dark:border-neutral-800"},Uu={class:"text-xs mb-2"},Ru={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-neutral-200 dark:border-neutral-800"},Nu={class:"text-xs mb-2"},Bu={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-neutral-200 dark:border-neutral-800"},qu={class:"text-xs mb-2"},Fu={class:"rounded overflow-hidden border border-neutral-200 dark:border-neutral-800 bg-white dark:bg-black"},zu={key:0,class:"text-xs"},Hu={class:"text-xs overflow-x-auto bg-green-50 dark:bg-green-950/20 p-2 rounded border border-green-300 dark:border-green-700 whitespace-pre-wrap"},Wu={key:1,class:"text-xs"},Ju={key:4,class:"mb-4"},Zu={class:"border border-accent-300 dark:border-accent-700 rounded overflow-hidden bg-accent-50 dark:bg-accent-950/20"},Ku={class:"text-xs p-2 overflow-x-auto whitespace-pre-wrap max-h-96 text-accent-900 dark:text-accent-100"},Gu={key:5,class:"mb-4"},Xu={class:"text-xs font-semibold mb-1"},Yu={class:"border border-purple-300 dark:border-purple-700 rounded overflow-hidden bg-purple-50 dark:bg-purple-950/20"},Qu={class:"divide-y divide-purple-200 dark:divide-purple-800"},ec={class:"flex items-center gap-2 mb-1"},tc={class:"text-xs font-semibold text-purple-700 dark:text-purple-300"},oc={key:0,class:"text-xs font-mono text-purple-600 dark:text-purple-400"},lc={key:1,class:"text-xs text-purple-500 dark:text-purple-500"},ac={key:2,class:"text-xs text-purple-500 dark:text-purple-500"},sc={key:0,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},nc={class:"text-purple-900 dark:text-purple-100 whitespace-pre-wrap"},rc={key:1,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},ic={class:"font-mono text-purple-700 dark:text-purple-300 break-all"},dc={key:2,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},uc={class:"text-purple-900 dark:text-purple-100 whitespace-pre-wrap"},cc={key:0,class:"mt-2 pt-2 border-t border-purple-200 dark:border-purple-800"},pc={class:"font-mono text-purple-700 dark:text-purple-300 text-xs break-all"},mc={key:3,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},vc={class:"text-purple-900 dark:text-purple-100 overflow-x-auto"},fc={key:6,class:"mb-4"},hc={class:"bg-white dark:bg-neutral-900 rounded overflow-hidden border border-neutral-300 dark:border-neutral-700"},gc=se({__name:"LogDetails",props:{log:{},hasPrevious:{type:Boolean},hasNext:{type:Boolean}},emits:["close","previous","next"],setup(t,{emit:i}){const n=t,u=i,l=v("request"),c=v(new Set),r=v(new Set),p=v(!1),f=v(!1),b=v(null),s=v(null),d=v(null),h=v(null),$=v(null),g=v(null),m=v(new Set(["system_prompt","request_body","tools"])),w=U=>{if(!U)return"N/A";try{return JSON.stringify(JSON.parse(U),null,2)}catch{return U}},k=K(()=>{if(!n.log.tools_schema)return[];try{const U=JSON.parse(n.log.tools_schema);return Array.isArray(U)?U:[]}catch{return[]}}),O=K(()=>{if(!n.log.response_body)return[];try{const y=JSON.parse(n.log.response_body)?.choices?.[0]?.message?.tool_calls;return Array.isArray(y)?y:[]}catch{return[]}}),D=K(()=>{if(!n.log.tool_results)return new Map;try{const U=JSON.parse(n.log.tool_results),y=new Map;return Array.isArray(U)&&U.forEach(x=>{x.tool_call_id&&y.set(x.tool_call_id,{content:x.content,status:x.status,tool_name:x.tool_name,timestamp:x.timestamp})}),y}catch{return new Map}}),F=K(()=>{if(!n.log.response_body)return[];try{const y=JSON.parse(n.log.response_body)?.choices?.[0]?.message?.reasoning_details;return Array.isArray(y)?y:[]}catch{return[]}}),X=U=>{c.value.has(U)?c.value.delete(U):c.value.add(U)},te=U=>{r.value.has(U)?r.value.delete(U):r.value.add(U)},R=U=>{m.value.has(U)?m.value.delete(U):m.value.add(U)},j=U=>!m.value.has(U),W=K(()=>{if(!n.log.errors)return[];try{const U=JSON.parse(n.log.errors);return Array.isArray(U)?U:[]}catch{return[]}}),B=()=>{ge(()=>{b.value&&(b.value.scrollTop=b.value.scrollHeight)})};ue(()=>n.log.message_history,()=>{B()},{immediate:!0}),ue(()=>n.log,()=>{ge(()=>{d.value?.checkHeight(),h.value?.checkHeight(),$.value?.checkHeight(),g.value?.checkHeight()})});const N=async()=>{p.value=!0;try{if(!n.log.request_body||!n.log.model)throw new Error("Missing request data");const U=await fetch(ae(`/api/models/${n.log.model}/curl-data`));if(!U.ok)throw new Error("Failed to fetch model data");const y=await U.json(),x=w(n.log.request_body);let V=`curl -X POST '${y.endpoint}' \\
3
+ `;V+=` -H 'Content-Type: application/json' \\
4
+ `,y.sdk?.toLowerCase()==="openrouter"?(V+=` -H 'Authorization: Bearer ${y.api_key}' \\
5
+ `,V+=` -H 'HTTP-Referer: https://agentkit.local' \\
6
+ `,V+=` -H 'X-Title: AgentKit' \\
7
+ `):y.sdk?.toLowerCase()==="openai"&&(V+=` -H 'Authorization: Bearer ${y.api_key}' \\
8
+ `),V+=` -d '${x.replace(/'/g,"'\\''")}'`,await navigator.clipboard.writeText(V),f.value=!0,setTimeout(()=>{f.value=!1},2e3)}catch(U){console.error("Failed to copy cURL command:",U),alert(`Failed to copy cURL: ${U instanceof Error?U.message:"Unknown error"}`)}finally{p.value=!1}};return(U,y)=>(o(),a("div",{ref_key:"scrollContainer",ref:s,class:"p-4 h-full overflow-y-auto"},[e("div",sd,[e("div",nd,[e("div",rd,[e("button",{onClick:y[0]||(y[0]=x=>u("previous")),disabled:!t.hasPrevious,class:"w-7 h-7 flex items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:text-neutral-200 dark:hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent dark:disabled:hover:bg-transparent transition-all","aria-label":"Previous log",title:"Previous log"},[...y[9]||(y[9]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("polyline",{points:"15 18 9 12 15 6"})],-1)])],8,id),e("button",{onClick:y[1]||(y[1]=x=>u("next")),disabled:!t.hasNext,class:"w-7 h-7 flex items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:text-neutral-200 dark:hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent dark:disabled:hover:bg-transparent transition-all","aria-label":"Next log",title:"Next log"},[...y[10]||(y[10]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("polyline",{points:"9 18 15 12 9 6"})],-1)])],8,dd)]),e("h3",ud,C(t.log.prompt_name||t.log.model_name||t.log.model),1)]),e("div",cd,[e("button",{onClick:N,disabled:p.value||!t.log.request_body,class:"px-3 py-1 text-xs font-medium bg-black text-white dark:bg-white dark:text-black rounded hover:opacity-80 disabled:opacity-50 disabled:cursor-not-allowed transition-opacity",title:t.log.request_body?"Copy cURL command":"No request data available"},[p.value?(o(),ee(be,{key:0,size:"xs"})):(o(),a("span",md,C(f.value?"Copied!":"Copy cURL"),1))],8,pd),e("button",{onClick:y[2]||(y[2]=x=>u("close")),class:"w-7 h-7 flex items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:text-neutral-200 dark:hover:bg-neutral-800 transition-all","aria-label":"Close details",title:"Close"},[...y[11]||(y[11]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])])])]),e("div",vd,[e("div",fd,[e("table",hd,[y[12]||(y[12]=e("thead",null,[e("tr",{class:"border-b border-neutral-200 dark:border-neutral-800"},[e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Status "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Provider "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Prompt "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Latency "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Tokens "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Cost "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Created ")])],-1)),e("tbody",null,[e("tr",null,[e("td",{class:le(["py-1 font-mono",t.log.error?"text-red-600 dark:text-red-400":t.log.is_complete?"text-green-600 dark:text-green-400":"text-yellow-600 dark:text-yellow-400"])},C(t.log.error?"ERROR":t.log.is_complete?"SUCCESS":"LOADING"),3),e("td",gd,C(t.log.provider),1),e("td",bd,[!t.log.is_complete&&!t.log.prompt_name?(o(),ee(be,{key:0,size:"xs"})):(o(),a("span",xd,C(t.log.prompt_name||"—"),1))]),e("td",yd,[!t.log.is_complete&&!t.log.latency_ms?(o(),ee(be,{key:0,size:"xs"})):(o(),a("span",kd,C(t.log.latency_ms?`${t.log.latency_ms}ms`:"—"),1))]),e("td",wd,[!t.log.is_complete&&!t.log.total_tokens?(o(),ee(be,{key:0,size:"xs"})):(o(),a("span",_d,C(t.log.total_tokens?`${t.log.input_tokens}/${t.log.output_tokens} (${t.log.total_tokens})`:"—"),1))]),e("td",$d,[!t.log.is_complete&&!t.log.cost_total?(o(),ee(be,{key:0,size:"xs"})):(o(),a("span",Cd,C(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))]),e("td",Vd,[E(dt,{timestamp:t.log.created_at},null,8,["timestamp"])])])])])]),e("div",Sd,[e("table",Td,[y[13]||(y[13]=e("thead",null,[e("tr",{class:"border-b border-neutral-200 dark:border-neutral-800"},[e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Status "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Provider "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Prompt ")])],-1)),e("tbody",null,[e("tr",null,[e("td",{class:le(["py-1 font-mono",t.log.error?"text-red-600 dark:text-red-400":t.log.is_complete?"text-green-600 dark:text-green-400":"text-yellow-600 dark:text-yellow-400"])},C(t.log.error?"ERROR":t.log.is_complete?"SUCCESS":"LOADING"),3),e("td",Md,C(t.log.provider),1),e("td",Ld,[!t.log.is_complete&&!t.log.prompt_name?(o(),ee(be,{key:0,size:"xs"})):(o(),a("span",Id,C(t.log.prompt_name||"—"),1))])])])]),e("table",Ed,[y[14]||(y[14]=e("thead",null,[e("tr",{class:"border-b border-neutral-200 dark:border-neutral-800"},[e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Latency "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Tokens "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Cost "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Created ")])],-1)),e("tbody",null,[e("tr",null,[e("td",Ad,[!t.log.is_complete&&!t.log.latency_ms?(o(),ee(be,{key:0,size:"xs"})):(o(),a("span",Pd,C(t.log.latency_ms?`${t.log.latency_ms}ms`:"—"),1))]),e("td",Od,[!t.log.is_complete&&!t.log.total_tokens?(o(),ee(be,{key:0,size:"xs"})):(o(),a("span",jd,C(t.log.total_tokens?`${t.log.input_tokens}/${t.log.output_tokens} (${t.log.total_tokens})`:"—"),1))]),e("td",Dd,[!t.log.is_complete&&!t.log.cost_total?(o(),ee(be,{key:0,size:"xs"})):(o(),a("span",Ud,C(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))]),e("td",Rd,[E(dt,{timestamp:t.log.created_at},null,8,["timestamp"])])])])])])]),e("div",Nd,[e("div",Bd,[e("button",{onClick:y[3]||(y[3]=x=>l.value="request"),class:le(["pb-2 px-1 text-sm font-medium border-b-2 transition-colors",l.value==="request"?"border-black dark:border-white text-black dark:text-white":"border-transparent text-neutral-500 dark:text-neutral-400 hover:text-black dark:hover:text-white"])}," Request ",2),e("button",{onClick:y[4]||(y[4]=x=>l.value="response"),class:le(["pb-2 px-1 text-sm font-medium border-b-2 transition-colors flex items-center gap-1",l.value==="response"?"border-black dark:border-white text-black dark:text-white":"border-transparent text-neutral-500 dark:text-neutral-400 hover:text-black dark:hover:text-white"])},[y[15]||(y[15]=ye(" Response ",-1)),t.log.error||W.value.length>0?(o(),a("span",qd,"⚠")):L("",!0)],2)])]),e("div",Fd,[Se(e("div",zd,[k.value.length>0?(o(),ee(rt,{key:0,ref_key:"toolsSectionRef",ref:d,title:`Available Tools (${k.value.length})`,"section-id":"tools",expanded:j("tools"),"scroll-container":s.value,onToggle:y[5]||(y[5]=x=>R("tools"))},{default:de(()=>[(o(!0),a(pe,null,fe(k.value,(x,V)=>(o(),a("div",{key:V,class:"border-b border-neutral-200 dark:border-neutral-800 last:border-b-0"},[e("button",{onClick:_=>X(V),class:"w-full px-2 py-1.5 text-left hover:bg-neutral-50 dark:hover:bg-neutral-900 transition-colors flex items-center justify-between text-xs"},[e("span",Wd,C(x.function?.name||x.name||"Unknown"),1),e("span",Jd,C(c.value.has(V)?"▼":"▶"),1)],8,Hd),Se(e("div",Zd,[x.function?.description||x.description?(o(),a("div",Kd,C(x.function?.description||x.description),1)):L("",!0),E(Xe,{code:JSON.stringify(x,null,2),language:"json"},null,8,["code"])],512),[[Ye,c.value.has(V)]])]))),128))]),_:1},8,["title","expanded","scroll-container"])):L("",!0),t.log.message_history?(o(),ee(rt,{key:1,ref_key:"messagesSectionRef",ref:h,title:`Messages (${t.log.message_history_length||0} messages)`,"section-id":"messages",expanded:j("messages"),"scroll-container":s.value,onToggle:y[6]||(y[6]=x=>R("messages"))},{default:de(()=>[e("div",Gd,[E(Xe,{code:w(t.log.message_history),language:"json"},null,8,["code"]),e("div",Xd,[E(ft,{content:w(t.log.message_history),variant:"ghost",size:"xs"},null,8,["content"])])])]),_:1},8,["title","expanded","scroll-container"])):L("",!0),t.log.system_prompt?(o(),ee(rt,{key:2,ref_key:"systemPromptSectionRef",ref:$,title:"System Prompt","section-id":"system_prompt",expanded:j("system_prompt"),"scroll-container":s.value,onToggle:y[7]||(y[7]=x=>R("system_prompt"))},{default:de(()=>[e("div",Yd,[E(Xe,{code:t.log.system_prompt,language:"markdown"},null,8,["code"]),e("div",Qd,[E(ft,{content:t.log.system_prompt,variant:"ghost",size:"xs"},null,8,["content"])])])]),_:1},8,["expanded","scroll-container"])):L("",!0),t.log.request_body?(o(),ee(rt,{key:3,ref_key:"requestBodySectionRef",ref:g,title:"Full Request Body","section-id":"request_body",expanded:j("request_body"),"scroll-container":s.value,onToggle:y[8]||(y[8]=x=>R("request_body"))},{default:de(()=>[e("div",eu,[E(Xe,{code:w(t.log.request_body),language:"json"},null,8,["code"]),e("div",tu,[E(ft,{content:w(t.log.request_body),variant:"ghost",size:"xs"},null,8,["content"])])])]),_:1},8,["expanded","scroll-container"])):L("",!0)],512),[[Ye,l.value==="request"]]),Se(e("div",null,[W.value.length>0?(o(),a("div",ou,[e("div",lu,C(W.value.length>1?`Errors (${W.value.length})`:"Error"),1),e("div",au,[(o(!0),a(pe,null,fe(W.value,(x,V)=>(o(),a("div",{key:V,class:"border border-red-300 dark:border-red-700 rounded overflow-hidden"},[e("div",su,C(x.type||"error"),1),e("pre",nu,C(x.message),1)]))),128))])])):t.log.error?(o(),a("div",ru,[e("div",iu," Error "+C(t.log.error_type?`(${t.log.error_type})`:""),1),e("pre",du,C(t.log.error),1)])):L("",!0),t.log.is_complete||!t.log.error?(o(),a("div",uu,[y[23]||(y[23]=e("div",{class:"text-xs font-semibold mb-1"},"Response Stats",-1)),e("table",cu,[e("tbody",null,[e("tr",pu,[y[16]||(y[16]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Finish Reason ",-1)),e("td",mu,[!t.log.is_complete&&!t.log.finish_reason?(o(),ee(be,{key:0,size:"xs"})):(o(),a("span",vu,C(t.log.finish_reason||"—"),1))])]),e("tr",fu,[y[17]||(y[17]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Input Tokens ",-1)),e("td",hu,[!t.log.is_complete&&!t.log.input_tokens?(o(),ee(be,{key:0,size:"xs"})):(o(),a("span",gu,C(t.log.input_tokens||"—"),1))])]),t.log.cached_tokens||!t.log.is_complete?(o(),a("tr",bu,[y[18]||(y[18]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Cached Tokens ",-1)),e("td",xu,[!t.log.is_complete&&!t.log.cached_tokens?(o(),ee(be,{key:0,size:"xs"})):(o(),a("span",yu,C(t.log.cached_tokens||0),1))])])):L("",!0),e("tr",ku,[y[19]||(y[19]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Output Tokens ",-1)),e("td",wu,[!t.log.is_complete&&!t.log.output_tokens?(o(),ee(be,{key:0,size:"xs"})):(o(),a("span",_u,C(t.log.output_tokens||"—"),1))])]),t.log.reasoning_tokens&&t.log.reasoning_tokens>0?(o(),a("tr",$u,[y[20]||(y[20]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Reasoning Tokens ",-1)),e("td",Cu,C(t.log.reasoning_tokens),1)])):L("",!0),e("tr",Vu,[y[21]||(y[21]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Total Tokens ",-1)),e("td",Su,[!t.log.is_complete&&!t.log.total_tokens?(o(),ee(be,{key:0,size:"xs"})):(o(),a("span",Tu,C(t.log.total_tokens||"—"),1))])]),e("tr",null,[y[22]||(y[22]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Total Cost ",-1)),e("td",Mu,[!t.log.is_complete&&!t.log.cost_total?(o(),ee(be,{key:0,size:"xs"})):(o(),a("span",Lu,C(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))])])])])])):L("",!0),O.value.length>0?(o(),a("div",Iu,[e("div",Eu," Tools Called ("+C(O.value.length)+") ",1),e("div",Au,[(o(!0),a(pe,null,fe(O.value,(x,V)=>(o(),a("div",{key:V,class:"border-b border-neutral-200 dark:border-neutral-800 last:border-b-0"},[e("button",{onClick:_=>te(V),class:"w-full px-2 py-1.5 text-left hover:bg-neutral-50 dark:hover:bg-neutral-900 transition-colors flex items-center justify-between text-xs"},[e("span",Ou,C(x.function?.name||"Unknown"),1),e("span",ju,C(r.value.has(V)?"▼":"▶"),1)],8,Pu),Se(e("div",Du,[e("div",Uu,[y[24]||(y[24]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Tool Call ID ",-1)),e("div",Ru,C(x.id),1)]),e("div",Nu,[y[25]||(y[25]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Function Name ",-1)),e("div",Bu,C(x.function?.name),1)]),e("div",qu,[y[26]||(y[26]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Arguments ",-1)),e("div",Fu,[E(Xe,{code:w(x.function?.arguments||"{}"),language:"json"},null,8,["code"])])]),D.value.has(x.id)?(o(),a("div",zu,[y[27]||(y[27]=e("div",{class:"font-semibold text-green-600 dark:text-green-400 mb-1"}," Result ",-1)),e("pre",Hu,C(D.value.get(x.id)?.content||"No content"),1)])):(o(),a("div",Wu,[...y[28]||(y[28]=[e("div",{class:"font-semibold text-neutral-500 dark:text-neutral-500 mb-1"}," Result ",-1),e("div",{class:"text-xs text-neutral-500 dark:text-neutral-500 italic"}," No result available ",-1)])]))],512),[[Ye,r.value.has(V)]])]))),128))])])):L("",!0),t.log.reasoning_content?(o(),a("div",Ju,[y[30]||(y[30]=e("div",{class:"text-xs font-semibold mb-1"},"Reasoning Content",-1)),e("div",Zu,[y[29]||(y[29]=e("div",{class:"px-2 py-1.5 bg-accent-100 dark:bg-accent-900/30 text-xs text-accent-800 dark:text-accent-200 border-b border-accent-300 dark:border-accent-700"}," Internal reasoning output (not displayed to users) ",-1)),e("pre",Ku,C(t.log.reasoning_content),1)])])):L("",!0),F.value.length>0?(o(),a("div",Gu,[e("div",Xu," Reasoning Details ("+C(F.value.length)+" blocks) ",1),e("div",Yu,[y[35]||(y[35]=e("div",{class:"px-2 py-1.5 bg-purple-100 dark:bg-purple-900/30 text-xs text-purple-800 dark:text-purple-200 border-b border-purple-300 dark:border-purple-700"}," Structured reasoning blocks from OpenRouter (preserved for multi-turn continuity) ",-1)),e("div",Qu,[(o(!0),a(pe,null,fe(F.value,(x,V)=>(o(),a("div",{key:V,class:"p-2"},[e("div",ec,[e("span",tc,C(x.type||"unknown"),1),x.id?(o(),a("span",oc," ID: "+C(x.id),1)):L("",!0),x.format?(o(),a("span",lc," Format: "+C(x.format),1)):L("",!0),x.index!==void 0?(o(),a("span",ac," Index: "+C(x.index),1)):L("",!0)]),x.type==="reasoning.summary"&&x.summary?(o(),a("div",sc,[y[31]||(y[31]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Summary: ",-1)),e("div",nc,C(x.summary),1)])):L("",!0),x.type==="reasoning.encrypted"&&x.data?(o(),a("div",rc,[y[32]||(y[32]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Encrypted Data: ",-1)),e("div",ic,C(x.data),1)])):L("",!0),x.type==="reasoning.text"&&x.text?(o(),a("div",dc,[y[34]||(y[34]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Reasoning Text: ",-1)),e("div",uc,C(x.text),1),x.signature?(o(),a("div",cc,[y[33]||(y[33]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Signature: ",-1)),e("div",pc,C(x.signature),1)])):L("",!0)])):L("",!0),["reasoning.summary","reasoning.encrypted","reasoning.text"].includes(x.type)?L("",!0):(o(),a("div",mc,[e("pre",vc,C(JSON.stringify(x,null,2)),1)]))]))),128))])])])):L("",!0),t.log.response_body?(o(),a("div",fc,[y[36]||(y[36]=e("div",{class:"text-xs font-semibold mb-1"},"Full Response Body",-1)),e("div",hc,[E(Xe,{code:w(t.log.response_body),language:"json"},null,8,["code"])])])):L("",!0)],512),[[Ye,l.value==="response"]])])],512))}}),bc={class:"flex flex-col h-full"},xc={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},yc={class:"flex items-center justify-between"},kc={class:"flex items-center gap-2"},wc={class:"flex items-center gap-2"},_c={key:0,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},$c={key:1,class:"flex justify-center py-12"},Cc={key:2,class:"text-red-600 dark:text-red-400 text-center py-12"},Vc={key:3,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},Sc={key:4},Tc={key:0,class:"border-b border-neutral-300 dark:border-neutral-700 bg-white dark:bg-black sticky top-0 z-10"},Mc=["disabled"],Lc={key:1},Ic={key:2},Ec={key:3},Ac={class:"w-full text-sm"},Pc=["onClick","onMouseenter"],Oc={class:"px-3 py-2 text-xs"},jc={class:"flex items-center gap-1"},Dc={key:0,class:"text-neutral-400 dark:text-neutral-600 mr-1"},Uc={key:3},Rc={class:"px-3 py-2"},Nc={class:"flex items-center gap-2"},Bc={key:0,class:"text-red-600 dark:text-red-400",title:"Error"},qc={class:"font-mono text-xs"},Fc={class:"px-3 py-2 font-mono text-xs"},zc={key:1},Hc={key:1},Wc={key:0,class:"log-details-panel relative shrink-0 bg-neutral-100 dark:bg-neutral-950 border-t border-neutral-300 dark:border-neutral-700 overflow-hidden"},Jc={class:"m-2 border h-[calc(100%-1rem)] border-neutral-300 shrink-0 dark:border-neutral-700 rounded-xl bg-white dark:bg-neutral-900 overflow-auto"},Zc={key:0,class:"flex flex-col items-center justify-center h-full gap-3 text-neutral-500 dark:text-neutral-400"},Kc={key:2,class:"absolute inset-0 bg-white/50 dark:bg-black/50 flex items-center justify-center"},Pt=20,Gc=20,Xc=se({__name:"LogsPane",props:{threadId:{},selectedLogId:{},hoveredLogId:{}},emits:["collapse","logClick","logHover","logsLoaded"],setup(t,{expose:i,emit:n}){const u=t,l=n,c=v(0),r=v(Pt),{logs:p,hasMore:f,isFetching:b,error:s,wsConnected:d,wsError:h,connectWebSocket:$,disconnectWebSocket:g,refetch:m}=Wi(K(()=>u.threadId),{limit:K(()=>r.value),offset:K(()=>c.value),enableWebSocket:!0,order:"desc"}),w=v([]),k=v(!0),O=v(null),D=v(null),F=v(!1),X=v(!1),te=v(new Map),R=async()=>{await ge(),D.value&&(D.value.scrollTop=D.value.scrollHeight)},j=v(null);ue(p,async z=>{if(c.value===0)w.value=[...z].reverse(),k.value&&w.value.length>0&&(await R(),k.value=!1);else{const H=[...z].reverse(),G=new Map;w.value.forEach(ce=>G.set(ce.id,ce)),H.forEach(ce=>G.set(ce.id,ce)),w.value=Array.from(G.values()).sort((ce,me)=>ce.created_at-me.created_at)}},{deep:!0,immediate:!0}),ue(b,(z,H)=>{if(H&&!z&&c.value===0&&u.threadId&&j.value!==u.threadId&&w.value.length>0){j.value=u.threadId;const G=w.value[w.value.length-1];l("logsLoaded",G?.id??null)}});const{logDetails:W,isFetching:B}=Ji(K(()=>u.threadId),K(()=>O.value)),N=K(()=>{if(!O.value)return null;const H=w.value.find(G=>G.id===O.value);return H?W.value?{...W.value,...H}:H:null}),U=K(()=>O.value?Le.value.findIndex(z=>z.id===O.value):-1),y=K(()=>U.value>0),x=K(()=>U.value>=0&&U.value<Le.value.length-1),V=()=>{if(y.value){const z=Le.value[U.value-1];S(z)}},_=()=>{if(x.value){const z=Le.value[U.value+1];S(z)}},T=z=>{if(!D.value)return;const H=te.value.get(z);if(!H)return;const G=D.value,ce=H.getBoundingClientRect(),me=G.getBoundingClientRect(),Ve=G.querySelectorAll(".sticky");let Ue=0;Ve.forEach(Ge=>{Ue+=Ge.getBoundingClientRect().height}),Ue+=16;const De=ce.top<me.top+Ue,lt=ce.bottom>me.bottom;De?G.scrollBy({top:ce.top-me.top-Ue,behavior:"smooth"}):lt&&G.scrollBy({top:ce.bottom-me.bottom,behavior:"smooth"})},S=z=>{l("logClick",z.id),O.value=z.id},P=(z,H)=>{H?te.value.set(z,H):te.value.delete(z)};ue(O,async z=>{z&&(await ge(),T(z))}),ue(()=>u.selectedLogId,z=>{z&&(O.value=z)},{immediate:!0});const J=z=>{O.value=z},re=async z=>{await ge();const H=te.value.get(z);if(H&&D.value){const G=D.value,ce=H.getBoundingClientRect(),me=G.getBoundingClientRect(),Ve=G.querySelector("thead"),Ue=G.querySelector(":scope > div > div.sticky");let De=0;Ve&&(De+=Ve.getBoundingClientRect().height),Ue&&(De+=Ue.getBoundingClientRect().height),De+=40;const lt=ce.top<me.top+De,Ge=ce.bottom>me.bottom;lt?G.scrollBy({top:ce.top-me.top-De,behavior:"smooth"}):Ge&&G.scrollBy({top:ce.bottom-me.bottom,behavior:"smooth"})}},A=z=>{if(z.length===0)return;const H=new Set(z);w.value=w.value.filter(G=>!H.has(G.id))},I=v(!1),M=z=>w.value.some(H=>H.id===z),oe=z=>w.value.find(H=>H.id===z)??null,Y=(z,H=3e3)=>new Promise(G=>{const ce=Date.now(),me=ue(w,()=>{w.value.length!==z&&(me(),G(!0))},{deep:!0}),Ve=setInterval(()=>{w.value.length!==z?(clearInterval(Ve),me(),G(!0)):Date.now()-ce>H&&(clearInterval(Ve),me(),G(!1))},50)});i({scrollToLog:re,selectLogById:J,removeLogsByIds:A,loadUntilLogId:async z=>{if(M(z))return!0;if(!f.value)return!1;I.value=!0;const H=100,G=50;try{let ce=0;for(;f.value&&!M(z)&&ce<G;){ce++;const me=w.value.length;if(c.value+=r.value,r.value=H,await m(),!await Y(me))break}return M(z)}finally{I.value=!1}},hasLog:M,getLog:oe,setLoadingForLog:z=>{I.value=z},waitForLogRow:async(z,H=2e3)=>{const G=Date.now();for(;Date.now()-G<H;){if(te.value.has(z))return!0;if(!Le.value.some(me=>me.id===z)){await ge(),await new Promise(me=>setTimeout(me,16));continue}await ge(),await new Promise(me=>setTimeout(me,16))}return!1}});const Ie=async()=>{if(X.value||!f.value||b.value)return;X.value=!0;const z=D.value?.scrollHeight||0;if(c.value+=r.value,r.value=Gc,await m(),await ge(),D.value){const H=D.value.scrollHeight;D.value.scrollTop+=H-z}X.value=!1};ue(()=>u.threadId,async z=>{z?(g(),$()):g(),c.value=0,r.value=Pt,w.value=[],O.value=null,F.value=!1,k.value=!0},{immediate:!0}),ue(w,async()=>{F.value||await R()},{deep:!0});const $e=()=>{if(!D.value)return;const{scrollTop:z,scrollHeight:H,clientHeight:G}=D.value,ce=H-z-G<50;F.value=!ce},Me=z=>{if(!z.tools_called)return"—";try{const H=JSON.parse(z.tools_called);return Array.isArray(H)?H.join(", "):z.tools_called}catch{return z.tools_called}},Pe=z=>z==null?"—":`$${z.toFixed(6)}`,Le=K(()=>{const z=new Map,H=new Map;w.value.forEach(me=>{z.set(me.id,me);const Ve=me.parent_log_id;Ve&&(H.has(Ve)||H.set(Ve,[]),H.get(Ve).push(me))});const G=[],ce=(me,Ve)=>{G.push({...me,depth:Ve}),(H.get(me.id)||[]).forEach(De=>{ce(De,Ve+1)})};return w.value.forEach(me=>{me.parent_log_id||ce(me,0)}),G});return(z,H)=>(o(),a("div",bc,[e("div",xc,[e("div",yc,[e("div",kc,[E(Z(zt),{size:18,class:"shrink-0"}),H[4]||(H[4]=e("h2",{class:"text-base font-bold"},"Logs",-1)),t.threadId?(o(),ee(Vt,{key:0,connected:Z(d),error:Z(h)},null,8,["connected","error"])):L("",!0)]),e("div",wc,[e("button",{onClick:H[0]||(H[0]=G=>l("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[E(Z($t),{size:20})])])])]),e("div",{ref_key:"logsScrollContainer",ref:D,class:"logs-list-container flex-1 overflow-y-auto overflow-x-auto",onScroll:$e},[t.threadId?Z(b)&&c.value===0?(o(),a("div",$c,[E(be)])):Z(s)?(o(),a("div",Cc," Error loading logs: "+C(Z(s)),1)):w.value.length===0?(o(),a("div",Vc," No logs yet ")):(o(),a("div",Sc,[Z(f)?(o(),a("div",Tc,[e("button",{onClick:Ie,disabled:X.value||I.value,type:"button",class:"w-full px-3 py-2 text-xs font-medium text-neutral-700 dark:text-neutral-300 hover:bg-neutral-100 dark:hover:bg-neutral-900 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"},[X.value||I.value?(o(),ee(be,{key:0,size:"xs"})):L("",!0),I.value?(o(),a("span",Lc,"Loading to find log...")):X.value?(o(),a("span",Ic,"Loading older logs...")):(o(),a("span",Ec,"Load previous logs"))],8,Mc)])):L("",!0),e("table",Ac,[e("thead",{class:le(["border-b border-neutral-300 dark:border-neutral-700 sticky bg-white z-[10] dark:bg-black",{"top-0":!Z(f),"top-[34px]":Z(f)}])},[...H[5]||(H[5]=[e("tr",null,[e("th",{class:"text-left px-3 py-1.5 text-xs font-semibold"},"Prompt"),e("th",{class:"text-left px-3 py-1.5 text-xs font-semibold"},"Model"),e("th",{class:"text-left px-3 py-1.5 text-xs font-semibold"},"Cost"),e("th",{class:"text-left px-3 py-1.5 text-xs font-semibold"},"Tools Called"),e("th",{class:"text-right px-3 py-1.5 text-xs font-semibold"},"Called At")],-1)])],2),e("tbody",null,[(o(!0),a(pe,null,fe(Le.value,G=>(o(),a("tr",{key:G.id,ref_for:!0,ref:ce=>P(G.id,ce),class:le(["border-b border-neutral-200 dark:border-neutral-800 cursor-pointer transition-colors relative",{"last:border-b-0":N.value,"bg-red-50 dark:bg-red-950/20":G.error,"bg-accent-100 dark:bg-accent-900 dark:text-white":O.value===G.id,"ring-2 ring-inset ring-accent-400 dark:ring-accent-400":G.id===u.selectedLogId||G.id!==u.selectedLogId&&G.id===u.hoveredLogId}]),onClick:ce=>S(G),onMouseenter:ce=>l("logHover",G.id),onMouseleave:H[1]||(H[1]=ce=>l("logHover",null))},[e("td",Oc,[e("div",jc,[G.depth>0?(o(),a("span",Dc,"└─")):L("",!0),G.retry_of_log_id?(o(),ee(Z(wo),{key:1,size:14,class:"text-neutral-500 dark:text-neutral-400 flex-shrink-0"})):L("",!0),!G.is_complete&&!G.prompt_name?(o(),ee(be,{key:2,size:"xs"})):(o(),a("span",Uc,C(G.prompt_name||"—"),1))])]),e("td",Rc,[e("div",Nc,[G.error?(o(),a("span",Bc," ✕ ")):L("",!0),e("span",qc,C(G.model_name||G.model),1)])]),e("td",Fc,[!G.is_complete&&!G.cost_total?(o(),ee(be,{key:0,size:"xs"})):(o(),a("span",zc,C(Pe(G.cost_total)),1))]),e("td",{class:le(["px-3 py-2 text-xs",O.value===G.id?"text-neutral-800 dark:text-neutral-100":"text-neutral-600 dark:text-neutral-400"])},[!G.is_complete&&Me(G)==="—"?(o(),ee(be,{key:0,size:"xs"})):(o(),a("span",Hc,C(Me(G)),1))],2),e("td",{class:le(["px-3 py-2 text-right text-xs",O.value===G.id?"text-neutral-800 dark:text-neutral-100":"text-neutral-500 dark:text-neutral-500"])},[E(dt,{timestamp:G.created_at},null,8,["timestamp"])],2)],42,Pc))),128))])])])):(o(),a("div",_c," Select a thread to view logs "))],544),E(We,{name:"slide-up",onAfterEnter:H[3]||(H[3]=()=>O.value&&T(O.value))},{default:de(()=>[N.value||I.value&&O.value?(o(),a("div",Wc,[e("div",Jc,[I.value&&!N.value?(o(),a("div",Zc,[E(be),H[6]||(H[6]=e("span",{class:"text-sm"},"Loading log...",-1))])):N.value?(o(),ee(gc,{key:1,log:N.value,"has-previous":y.value,"has-next":x.value,onClose:H[2]||(H[2]=G=>O.value=null),onPrevious:V,onNext:_},null,8,["log","has-previous","has-next"])):L("",!0),Z(B)&&N.value?(o(),a("div",Kc,[E(be)])):L("",!0)])])):L("",!0)]),_:1})]))}}),Yc=Ze(Xc,[["__scopeId","data-v-fd2bcb0e"]]),Qc={class:"space-y-4"},e0={key:0,class:"p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded text-sm text-red-800 dark:text-red-200"},t0={class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},o0={key:0},l0={key:1},a0={key:1,class:"space-y-4 p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},s0={key:3,class:"flex items-center gap-2"},n0=["onUpdate:modelValue","id"],r0=["for"],i0={key:0,class:"text-red-500"},d0={key:5,class:"text-xs text-neutral-500 dark:text-neutral-400 mt-1"},u0={key:2,class:"p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg text-center text-sm text-neutral-500"},c0={key:3},p0={key:0,class:"space-y-3 mb-4 max-h-64 overflow-y-auto p-2"},m0={class:"text-xs font-medium mb-1 opacity-70"},v0={class:"text-sm whitespace-pre-wrap"},f0=["onClick"],h0={key:1,class:"text-center py-8 text-neutral-500 dark:text-neutral-400 text-sm"},g0={class:"space-y-2"},b0={class:"flex items-stretch border border-black dark:border-neutral-300 rounded overflow-hidden bg-white dark:bg-neutral-900"},x0=["disabled","title"],y0={class:"flex-1 relative"},k0=["disabled","title"],w0={class:"text-xs text-neutral-500 dark:text-neutral-400"},_0={class:"flex justify-between"},$0=["disabled"],C0=["disabled"],V0=se({__name:"CreateThreadModal",props:{modelValue:{type:Boolean},editThread:{}},emits:["update:modelValue","thread-created","thread-updated"],setup(t,{emit:i}){const n=t,u=i,l=K(()=>!!n.editThread),c=v(""),r=v(""),p=v({}),f=v([]),b=v(""),s=v(!1),d=v(""),h=v(null),{data:$,isFetching:g,execute:m}=Ee(ae("/api/agents"),{immediate:!1}).json(),w=K(()=>$.value?($.value?.agents||[]).map(T=>({value:T.id,label:T.title})):[]),k=K(()=>!c.value||!$.value?null:($.value?.agents||[]).find(T=>T.id===c.value)),O=K(()=>k.value&&k.value.type==="ai_human"?"AI":"Side A"),D=K(()=>k.value&&k.value.type==="ai_human"?"Human":"Side B"),{data:F,isFetching:X,execute:te}=Ee(K(()=>k.value?.side_a_system_prompt?ae(`/api/prompts/${k.value.side_a_system_prompt}`):""),{immediate:!1}).json(),R=K(()=>{if(!F.value)return null;const _=F.value?.required_schema;if(!_)return null;try{return typeof _=="string"?JSON.parse(_):_}catch{return null}}),j=K(()=>{const _=R.value;return!_||!_.properties?[]:Object.entries(_.properties).map(([T,S])=>({name:T,type:S.type||"string",description:S.description||"",required:_.required?.includes(T)||!1,enum:S.enum}))});ue(c,async _=>{_&&k.value?.side_a_system_prompt?(await te(),p.value={}):p.value={}});const W=()=>{const _=h.value;_&&(_.style.height="auto",_.style.height=`${_.scrollHeight}px`)},B=_=>{b.value.trim()&&(f.value.push({id:crypto.randomUUID(),role:_,content:b.value.trim()}),b.value="",setTimeout(()=>W(),0))},N=_=>{f.value=f.value.filter(T=>T.id!==_)},U=()=>{c.value="",r.value="",p.value={},f.value=[],b.value="",d.value=""},y=()=>{n.editThread&&(c.value=n.editThread.agent_id,r.value=n.editThread.tags?.join(", ")||"")},x=async()=>{if(!c.value){d.value="Please select an agent";return}if(!l.value&&j.value.length>0){for(const _ of j.value)if(_.required&&!p.value[_.name]){d.value=`Please provide ${_.name}`;return}}s.value=!0,d.value="";try{const _=r.value.split(",").map(T=>T.trim()).filter(T=>T.length>0);if(l.value){const T=await fetch(ae(`/api/threads/${n.editThread.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tags:_})});if(!T.ok){const S=await T.json();throw new Error(S.error||"Failed to update thread")}u("thread-updated"),U(),u("update:modelValue",!1)}else{const T={agent_id:c.value,tags:_.length>0?_:void 0};f.value.length>0&&(T.initial_messages=f.value.map(re=>({role:re.role,content:re.content}))),Object.keys(p.value).length>0&&(T.data=p.value);const S=await fetch(ae("/api/threads"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T)});if(!S.ok){const re=await S.json();throw new Error(re.error||"Failed to create thread")}const J=(await S.json()).threadId;if(!J)throw new Error("Thread created but ID not found in response");u("thread-created",J),U(),u("update:modelValue",!1)}}catch(_){console.error(`Error ${l.value?"updating":"creating"} thread:`,_),d.value=_.message||`Failed to ${l.value?"update":"create"} thread`}finally{s.value=!1}},V=()=>{U(),u("update:modelValue",!1)};return ue(()=>n.modelValue,async _=>{_&&(await m(),U(),l.value&&y())}),(_,T)=>(o(),ee(je,{"model-value":t.modelValue,"onUpdate:modelValue":T[7]||(T[7]=S=>_.$emit("update:modelValue",S)),title:l.value?"Edit Thread":"Create New Thread",width:"max-w-3xl"},{footer:de(()=>[e("div",_0,[e("button",{onClick:V,type:"button",disabled:s.value,class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors disabled:opacity-50"}," Cancel ",8,$0),e("button",{onClick:x,type:"button",disabled:s.value||Z(g),class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity disabled:opacity-50"},[l.value?(o(),a(pe,{key:0},[ye(C(s.value?"Updating...":"Update Thread"),1)],64)):(o(),a(pe,{key:1},[ye(C(s.value?"Creating...":"Create Thread"),1)],64))],8,C0)])]),default:de(()=>[e("div",Qc,[d.value?(o(),a("div",e0,C(d.value),1)):L("",!0),e("div",null,[E(he,{modelValue:c.value,"onUpdate:modelValue":T[0]||(T[0]=S=>c.value=S),label:"Agent",options:w.value,disabled:Z(g)||l.value,placeholder:"Select an agent...",required:""},null,8,["modelValue","options","disabled"]),e("p",t0,[l.value?(o(),a("span",o0,"Agent cannot be changed after thread creation")):(o(),a("span",l0,"Choose which agent will handle this conversation"))])]),!l.value&&j.value.length>0&&!Z(X)?(o(),a("div",a0,[T[8]||(T[8]=e("h4",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Required Information ",-1)),(o(!0),a(pe,null,fe(j.value,S=>(o(),a("div",{key:S.name,class:"space-y-2"},[S.enum?(o(),ee(he,{key:0,modelValue:p.value[S.name],"onUpdate:modelValue":P=>p.value[S.name]=P,label:S.name,options:[{value:"",label:"Select..."},...S.enum.map(P=>({value:P,label:P}))],required:S.required},null,8,["modelValue","onUpdate:modelValue","label","options","required"])):S.type==="string"?(o(),ee(Ce,{key:1,modelValue:p.value[S.name],"onUpdate:modelValue":P=>p.value[S.name]=P,label:S.name,placeholder:S.description,required:S.required},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])):S.type==="number"||S.type==="integer"?(o(),ee(Ce,{key:2,modelValue:p.value[S.name],"onUpdate:modelValue":P=>p.value[S.name]=P,modelModifiers:{number:!0},label:S.name,placeholder:S.description,type:"number",required:S.required},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])):S.type==="boolean"?(o(),a("div",s0,[Se(e("input",{"onUpdate:modelValue":P=>p.value[S.name]=P,type:"checkbox",id:`field-${S.name}`,class:"w-4 h-4"},null,8,n0),[[_o,p.value[S.name]]]),e("label",{for:`field-${S.name}`,class:"text-sm"},[ye(C(S.name)+" ",1),S.required?(o(),a("span",i0,"*")):L("",!0)],8,r0)])):(o(),ee(to,{key:4,modelValue:p.value[S.name],"onUpdate:modelValue":P=>p.value[S.name]=P,label:S.name,placeholder:S.description||`Enter ${S.name} (JSON format)`,required:S.required,rows:3},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])),S.description?(o(),a("p",d0,C(S.description),1)):L("",!0)]))),128))])):L("",!0),!l.value&&Z(X)?(o(),a("div",u0," Loading agent requirements... ")):L("",!0),l.value?L("",!0):(o(),a("div",c0,[T[11]||(T[11]=e("h4",{class:"text-sm font-medium mb-3"},"Initial Conversation",-1)),f.value.length>0?(o(),a("div",p0,[(o(!0),a(pe,null,fe(f.value,S=>(o(),a("div",{key:S.id,class:le(["flex items-start gap-2",{"justify-start":S.role==="assistant","justify-end":S.role==="user"}])},[e("div",{class:le(["max-w-[80%] rounded-2xl px-4 py-2 break-words",{"bg-black text-white dark:bg-white dark:text-black":S.role==="assistant","bg-neutral-200 text-black dark:bg-neutral-800 dark:text-white":S.role==="user"}])},[e("div",m0,C(S.role==="assistant"?O.value:D.value),1),e("div",v0,C(S.content),1)],2),e("button",{onClick:P=>N(S.id),type:"button",class:"text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-200 text-xs mt-2"}," ✕ ",8,f0)],2))),128))])):(o(),a("div",h0," No messages yet. Add messages to start the conversation. ")),e("div",g0,[e("div",b0,[e("button",{onClick:T[1]||(T[1]=S=>B("assistant")),type:"button",disabled:!b.value.trim(),title:`Add as ${O.value}`,class:"px-3 py-2 bg-black text-white dark:bg-white dark:text-black text-sm hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap inline-flex items-center gap-1 border-r border-black dark:border-neutral-300 flex-shrink-0"},[T[9]||(T[9]=e("svg",{class:"w-[1em] h-[1em]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 10l7-7m0 0l7 7m-7-7v18"})],-1)),e("span",null,C(O.value),1)],8,x0),e("div",y0,[Se(e("textarea",{"onUpdate:modelValue":T[2]||(T[2]=S=>b.value=S),placeholder:"Type a message...",class:"w-full px-3 py-2 bg-transparent border-0 font-mono text-sm focus:outline-none resize-none overflow-hidden",rows:"1",ref_key:"textareaRef",ref:h,onInput:W,onKeydown:[T[3]||(T[3]=xt(we(S=>B("user"),["meta"]),["enter"])),T[4]||(T[4]=xt(we(S=>B("user"),["ctrl"]),["enter"]))]},null,544),[[Oe,b.value]])]),e("button",{onClick:T[5]||(T[5]=S=>B("user")),type:"button",disabled:!b.value.trim(),title:`Add as ${D.value}`,class:"px-3 py-2 bg-black text-white dark:bg-white dark:text-black text-sm hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap inline-flex items-center gap-1 border-l border-black dark:border-neutral-300 flex-shrink-0"},[T[10]||(T[10]=e("svg",{class:"w-[1em] h-[1em]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 10l7-7m0 0l7 7m-7-7v18"})],-1)),e("span",null,C(D.value),1)],8,k0)]),e("p",w0," Type a message and click "+C(O.value)+" (left) or "+C(D.value)+" (right) to add. Or press Cmd+Enter (Mac) / Ctrl+Enter (Windows) to add as "+C(D.value)+". ",1)])])),e("div",null,[E(Ce,{modelValue:r.value,"onUpdate:modelValue":T[6]||(T[6]=S=>r.value=S),label:"Tags",placeholder:"research, urgent, production"},null,8,["modelValue"]),T[12]||(T[12]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Comma-separated tags to help organize and search threads ",-1))])])]),_:1},8,["model-value","title"]))}}),S0={class:"flex h-full overflow-hidden"},T0={key:0,class:"flex flex-col items-center p-4"},M0={key:0,class:"flex flex-col items-center p-4"},L0={key:0,class:"flex flex-col items-center p-4"},Ot=se({__name:"ThreadsView",setup(t){const i=ze(),n=et(),u=v(typeof i.params.id=="string"?i.params.id:null),l=v({threadList:!1,messages:!1,logs:!1}),c=v(!1),r=v(null),p=v(null),{thread:f}=Ct(K(()=>u.value)),b=v(null),s=v(null),d=v(null),h=v(null),$=v(null),g=x=>{h.value=x,$.value=x},m=x=>{if(h.value=x,!x){$.value=null;return}$.value=x;const V=w.value,_=k.value;if(!V||!_||V.hasWorkblockForLogId(x))return;let T=x;const S=10;for(let P=0;P<S&&T;P++){const J=_.getLog(T);if(!J)break;const re=J.parent_log_id;if(!re)break;if(V.hasWorkblockForLogId(re)){$.value=re;return}T=re}},w=v(null),k=v(null);ue(()=>i.params.id,x=>{u.value=typeof x=="string"?x:null,b.value=null,s.value=null,d.value=null});const O=x=>{n.push(`/threads/${x}`)},D=x=>{window.location.href="/threads"},F=()=>{f.value&&(r.value=f.value,c.value=!0)},X=()=>{r.value=null,c.value=!0},te=x=>{p.value?.refetch(),n.push(`/threads/${x}`)},R=()=>{window.location.reload()},j=x=>{l.value[x]=!l.value[x]},W=async(x,V)=>{if(b.value=x,!V){s.value=null,d.value=null;return}const _=k.value;if(!_){s.value=V,d.value=V;return}const T=!_.hasLog(V);if(T&&_.setLoadingForLog(!0),s.value=V,d.value=V,T&&!await _.loadUntilLogId(V)){console.warn(`Could not find log ${V} after loading all available logs`),_.setLoadingForLog(!1);return}if(!await _.waitForLogRow(V)){console.warn(`Log row ${V} not rendered in time`);return}_.scrollToLog(V),_.selectLogById(V)},B=x=>{s.value=x,d.value=x,b.value=null;const V=w.value,_=k.value;if(!V||!_)return;let T=V.scrollToLogId(x);if(T)return;let S=x;const P=10;for(let J=0;J<P&&S;J++){const re=_.getLog(S);if(!re)break;const A=re.parent_log_id;if(!A)break;if(T=V.scrollToLogId(A),T){d.value=A;return}S=A}},N=x=>{x&&(s.value=x)},U=x=>{k.value?.removeLogsByIds(x)},y=x=>{x&&!u.value&&n.push(`/threads/${x}`)};return(x,V)=>(o(),a("div",S0,[e("div",{class:le([l.value.threadList?"w-[60px]":"w-[320px]","border-r border-neutral-300 dark:border-neutral-700 flex-shrink-0 overflow-hidden transition-all duration-200"])},[l.value.threadList?(o(),a("div",T0,[e("button",{onClick:V[0]||(V[0]=_=>j("threadList")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Threads pane"},[E(Z(qt),{size:20})])])):(o(),ee(Kn,{key:1,ref_key:"threadListPaneRef",ref:p,"selected-thread-id":u.value,onSelectThread:O,onCollapse:V[1]||(V[1]=_=>j("threadList")),onCreateThread:X,onThreadsLoaded:y},null,8,["selected-thread-id"]))],2),e("div",{class:le([l.value.messages?"w-[60px]":"w-[380px]","border-r border-neutral-300 dark:border-neutral-700 flex-shrink-0 overflow-hidden transition-all duration-200"])},[l.value.messages?(o(),a("div",M0,[e("button",{onClick:V[2]||(V[2]=_=>j("messages")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Messages pane"},[E(Z(Ft),{size:20})])])):(o(),ee(Hi,{key:1,ref_key:"messagesPaneRef",ref:w,"thread-id":u.value,"selected-message-id":b.value,"selected-log-id":d.value,"hovered-log-id":$.value,onCollapse:V[3]||(V[3]=_=>j("messages")),onMessageClick:W,onMessageHover:g,onThreadDeleted:D,onEditThread:F,onLogsDeleted:U},null,8,["thread-id","selected-message-id","selected-log-id","hovered-log-id"]))],2),e("div",{class:le([l.value.logs?"w-[60px]":"flex-1","overflow-hidden transition-all duration-200"])},[l.value.logs?(o(),a("div",L0,[e("button",{onClick:V[4]||(V[4]=_=>j("logs")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Logs pane"},[E(Z(zt),{size:20})])])):(o(),ee(Yc,{key:1,ref_key:"logsPaneRef",ref:k,"thread-id":u.value,"selected-log-id":s.value,"hovered-log-id":h.value,onCollapse:V[5]||(V[5]=_=>j("logs")),onLogClick:B,onLogHover:m,onLogsLoaded:N},null,8,["thread-id","selected-log-id","hovered-log-id"]))],2),E(V0,{modelValue:c.value,"onUpdate:modelValue":V[6]||(V[6]=_=>c.value=_),"edit-thread":r.value,onThreadCreated:te,onThreadUpdated:R},null,8,["modelValue","edit-thread"])]))}}),I0=se({__name:"PromptsDataTable",emits:["add","edit","delete"],setup(t,{expose:i,emit:n}){const u=n,l=v([]),c=v(!1),r=[{key:"name",label:"Name",width:"w-1/4"},{key:"tool_description",label:"Description",width:"w-2/5"},{key:"model_name",label:"Model",width:"w-1/5",formatter:(s,d)=>s||d.model_id||"-"},{key:"created_at",label:"Created",width:"w-1/6",formatter:s=>s?new Date(s*1e3).toLocaleDateString():"-"}],p=[{icon:"edit",label:"Edit",handler:s=>u("edit",s)},{icon:"delete",label:"Delete",handler:async s=>{await b(s)},confirm:!0,confirmMessage:"Are you sure you want to delete this prompt?"}],f=async()=>{c.value=!0;try{const s=await fetch(ae("/api/prompts"));if(s.ok){const d=await s.json();l.value=d.prompts||[]}}catch(s){console.error("Error fetching prompts:",s)}finally{c.value=!1}},b=async s=>{try{const d=await fetch(ae(`/api/prompts/${s.id}`),{method:"DELETE"});if(d.ok)await f();else{const h=await d.json();alert(h.error||"Failed to delete prompt")}}catch(d){console.error("Error deleting prompt:",d),alert("Failed to delete prompt")}};return xe(()=>{f()}),i({refresh:f}),(s,d)=>(o(),a("div",null,[E(Fe,{columns:r,data:l.value,actions:p,loading:c.value,"empty-message":"No prompts available. Create your first prompt to get started."},null,8,["data","loading"])]))}}),E0={class:"space-y-4"},A0={key:0,class:"mt-1 text-sm text-red-500"},P0={key:1,class:"mt-1 text-sm text-neutral-500 dark:text-neutral-400"},O0={class:"px-1 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded"},j0=["value"],D0=se({__name:"PromptBasicInfo",props:{name:{},toolDescription:{}},emits:["update:name","update:toolDescription"],setup(t,{emit:i}){const n=t,u=i,l=v(""),c=p=>{let f=p.replace(/[^a-zA-Z0-9\s_]/g,"");return f=f.trim().toLowerCase().replace(/\s+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),f?/^[a-z][a-z0-9_]*$/.test(f)?l.value="":l.value="Name must start with a letter and contain only lowercase letters, numbers, and underscores":l.value="Name is required",f},r=p=>{const f=c(p);u("update:name",f)};return ue(()=>n.name,p=>{p&&c(p)},{immediate:!0}),(p,f)=>(o(),a("div",E0,[e("div",null,[E(Ce,{"model-value":t.name,"onUpdate:modelValue":r,label:"Prompt Name",placeholder:"Enter a unique name (will be converted to snake_case)"},null,8,["model-value"]),l.value?(o(),a("p",A0,C(l.value),1)):t.name?(o(),a("p",P0,[f[1]||(f[1]=ye(" Will be saved as: ",-1)),e("code",O0,C(t.name),1)])):L("",!0)]),e("div",null,[f[2]||(f[2]=e("label",{class:"block text-sm font-medium mb-2"},"Tool Description",-1)),e("textarea",{value:t.toolDescription,onInput:f[0]||(f[0]=b=>u("update:toolDescription",b.target.value)),placeholder:"Describe what this prompt does (shown when used as a tool)",class:"w-full px-3 py-2 border border-black dark:border-white rounded bg-transparent resize-none",rows:"3"},null,40,j0)])]))}}),U0="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3crect%20width='48'%20height='48'%20fill='%23F0EFEA'/%3e%3cpath%20d='M32.84%2010H26.72L37.88%2038H44L32.84%2010Z'%20fill='black'/%3e%3cpath%20d='M15.16%2010L4%2038H10.24L12.5224%2032.12H24.1976L26.48%2038H32.72L21.56%2010H15.16ZM14.5408%2026.92L18.36%2017.08L22.1793%2026.92H14.5408Z'%20fill='black'/%3e%3c/svg%3e",wt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3crect%20width='48'%20height='48'%20rx='24'%20fill='white'/%3e%3cpath%20d='M19.3418%2018.5599V14.7599C19.3418%2014.4399%2019.4608%2014.1998%2019.7382%2014.04L27.3102%209.63997C28.3409%209.03999%2029.5699%208.76014%2030.8383%208.76014C35.5954%208.76014%2038.6085%2012.4802%2038.6085%2016.4401C38.6085%2016.72%2038.6085%2017.04%2038.5687%2017.3601L30.7194%2012.72C30.2437%2012.4401%2029.7678%2012.4401%2029.2922%2012.72L19.3418%2018.5599ZM37.0226%2033.36V24.2799C37.0226%2023.7197%2036.7846%2023.3197%2036.309%2023.0398L26.3586%2017.1998L29.6093%2015.3197C29.8868%2015.1599%2030.1247%2015.1599%2030.4022%2015.3197L37.9741%2019.7197C40.1547%2020.9999%2041.6213%2023.7197%2041.6213%2026.3596C41.6213%2029.3995%2039.8375%2032.1999%2037.0226%2033.36ZM17.0029%2025.3601L13.7522%2023.4402C13.4748%2023.2804%2013.3557%2023.0402%2013.3557%2022.7202V13.9203C13.3557%209.64039%2016.6065%206.40016%2021.0069%206.40016C22.6722%206.40016%2024.2179%206.96029%2025.5265%207.96025L17.7168%2012.5204C17.2412%2012.8003%2017.0033%2013.2002%2017.0033%2013.7605L17.0029%2025.3601ZM24%2029.44L19.3418%2026.8001V21.2003L24%2018.5604L28.6578%2021.2003V26.8001L24%2029.44ZM26.993%2041.6002C25.3278%2041.6002%2023.7821%2041.04%2022.4735%2040.0402L30.2831%2035.4799C30.7588%2035.2001%2030.9967%2034.8001%2030.9967%2034.2399V22.6399L34.2873%2024.5598C34.5646%2024.7196%2034.6837%2024.9597%2034.6837%2025.2798V34.0797C34.6837%2038.3596%2031.3931%2041.6002%2026.993%2041.6002ZM17.5975%2032.6802L10.0255%2028.2803C7.84493%2027.0001%206.37833%2024.2803%206.37833%2021.6404C6.37833%2018.5604%208.20193%2015.8004%2011.0164%2014.6403V23.7602C11.0164%2024.3204%2011.2544%2024.7204%2011.73%2025.0003L21.641%2030.8001L18.3902%2032.6802C18.1129%2032.84%2017.8749%2032.84%2017.5975%2032.6802ZM17.1617%2039.2402C12.682%2039.2402%209.39151%2035.8402%209.39151%2031.6401C9.39151%2031.3201%209.43125%2031.0001%209.47066%2030.68L17.2803%2035.2402C17.7559%2035.5201%2018.2319%2035.5201%2018.7074%2035.2402L28.6578%2029.4404V33.2404C28.6578%2033.5605%2028.5388%2033.8005%2028.2614%2033.9604L20.6894%2038.3604C19.6586%2038.9603%2018.4301%2039.2402%2017.1617%2039.2402ZM26.993%2044C31.7899%2044%2035.7936%2040.5601%2036.7057%2036C41.1457%2034.8399%2044%2030.6399%2044%2026.36C44%2023.5598%2042.8108%2020.8401%2040.6701%2018.88C40.8683%2018.0399%2040.9872%2017.1998%2040.9872%2016.3602C40.9872%2010.6403%2036.3885%206.35998%2031.0763%206.35998C30.0062%206.35998%2028.9754%206.51979%2027.9446%206.88001C26.1604%205.11992%2023.7025%204%2021.0069%204C16.2101%204%2012.2064%207.4398%2011.2943%2012C6.8543%2013.1601%204%2017.3601%204%2021.6399C4%2024.4401%205.18916%2027.1599%207.32995%2029.1199C7.13174%2029.96%207.01277%2030.8001%207.01277%2031.6398C7.01277%2037.3597%2011.6114%2041.6399%2016.9236%2041.6399C17.9938%2041.6399%2019.0246%2041.4801%2020.0554%2041.1199C21.8392%2042.88%2024.2971%2044%2026.993%2044Z'%20fill='black'/%3e%3c/svg%3e",R0="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%3e%3cpath%20fill='%234285F4'%20d='M14.9%208.161c0-.476-.039-.954-.121-1.422h-6.64v2.695h3.802a3.24%203.24%200%2001-1.407%202.127v1.75h2.269c1.332-1.22%202.097-3.02%202.097-5.15z'/%3e%3cpath%20fill='%2334A853'%20d='M8.14%2015c1.898%200%203.499-.62%204.665-1.69l-2.268-1.749c-.631.427-1.446.669-2.395.669-1.836%200-3.393-1.232-3.952-2.888H1.85v1.803A7.044%207.044%200%20008.14%2015z'/%3e%3cpath%20fill='%23FBBC04'%20d='M4.187%209.342a4.17%204.17%200%20010-2.68V4.859H1.849a6.97%206.97%200%20000%206.286l2.338-1.803z'/%3e%3cpath%20fill='%23EA4335'%20d='M8.14%203.77a3.837%203.837%200%20012.7%201.05l2.01-1.999a6.786%206.786%200%2000-4.71-1.82%207.042%207.042%200%2000-6.29%203.858L4.186%206.66c.556-1.658%202.116-2.89%203.952-2.89z'/%3e%3c/svg%3e",jt="/agents/assets/img/meta.svg",N0="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M17.8962%2017.7465V14.9519C18.1789%2014.9346%2018.4615%2014.9174%2018.7442%2014.9174C26.5881%2014.6758%2031.7291%2021.5072%2031.7291%2021.5072C31.7291%2021.5072%2026.1818%2029.0287%2020.2282%2029.0287C19.4332%2029.0287%2018.6559%2028.9079%2017.9139%2028.6664V20.1789C20.9702%2020.5412%2021.5885%2021.8523%2023.4082%2024.8367L27.4891%2021.49C27.4891%2021.49%2024.5035%2017.6775%2019.4862%2017.6775C18.9562%2017.6603%2018.4262%2017.6948%2017.8962%2017.7465ZM17.8962%208.5V12.6747L18.7442%2012.623C29.6445%2012.2607%2036.7641%2021.352%2036.7641%2021.352C36.7641%2021.352%2028.6021%2031.047%2020.1045%2031.047C19.3625%2031.047%2018.6382%2030.978%2017.9139%2030.8573V33.4449C18.5145%2033.5139%2019.1329%2033.5657%2019.7335%2033.5657C27.6481%2033.5657%2033.3721%2029.6152%2038.9194%2024.9574C39.8381%2025.682%2043.601%2027.4243%2044.3784%2028.1834C39.1137%2032.4961%2026.8355%2035.9636%2019.8749%2035.9636C19.2035%2035.9636%2018.5675%2035.9291%2017.9315%2035.86V39.5H48V8.5L17.8962%208.5ZM17.8962%2028.6664V30.8745C10.5823%2029.5979%208.55061%2022.1628%208.55061%2022.1628C8.55061%2022.1628%2012.0662%2018.3676%2017.8962%2017.7465V20.1617H17.8785C14.8222%2019.7994%2012.4196%2022.594%2012.4196%2022.594C12.4196%2022.594%2013.7799%2027.3036%2017.8962%2028.6664ZM4.9113%2021.8523C4.9113%2021.8523%209.2396%2015.6074%2017.9139%2014.9519V12.6747C8.30327%2013.4338%200%2021.3692%200%2021.3692C0%2021.3692%204.6993%2034.6525%2017.8962%2035.86V33.4449C8.21494%2032.2718%204.9113%2021.8523%204.9113%2021.8523Z'%20fill='%2376B900'/%3e%3c/svg%3e",B0="data:image/svg+xml,%3csvg%20version='1.2'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201513%20975'%20width='1513'%20height='975'%3e%3ctitle%3eae99cd49-2667-464e-b9db-b39cee0126e1-svg%3c/title%3e%3cstyle%3e%20.s0%20{%20fill:%20%23ff5a00%20}%20%3c/style%3e%3cg%20id='%23ff5a00ff'%3e%3cpath%20id='Layer'%20class='s0'%20d='m989.5%200h67.8c95.3%205.4%20196.5%2023.1%20272.4%2085.5%2060.6%2049.1%2086.3%20133%2071.4%20208.6-11.4%2056.4-37.4%20108.4-65.4%20158.1-56.8%2098.4-126.6%20188.2-193%20280.1-11.9%2015.2-21.2%2033.8-20%2053.6%201.1%2015.7%2013.1%2028.4%2027.2%2034%2027.3%2011.1%2057.5%208.9%2086.2%207.3%2090.7-9.5%20178.1-37%20264.6-64.6%206.6-4.1%208.8%202.6%2011.3%207.4-91.9%2061.3-190.8%20112.4-294.8%20150-57.5%2019.3-118.3%2037.6-179.6%2030.4-32.2-3.2-64.5-22.4-74.6-54.5-12.5-41.8-7.9-88.1%2010.2-127.6%2027.5-61.7%2070.2-114.7%20110.7-168.2%2067.1-88%20136.4-175.5%20189.1-273.3%2017.4-34.7%2036-76.8%2018.7-115.1-16.3-35.3-51.7-56.1-85.6-71.8-60.2-26.9-124.4-43.1-187.7-61.1q-14.3%209.4-28.5%2019c22%2016.8%2044%2033.6%2065.8%2050.7-83.3%2015-166.3%2031.8-248.3%2052.7-124.9%2031-246.8%2072.5-367.6%20116.5%2011.8%2023.5%2023.5%2047.1%2034.7%2070.9-27.3%2030.2-54.4%2060.7-81.7%2090.9%2065.6%2019.6%20136.3%2022.3%20203.2%207.5%2057.2-12.8%20111-40.2%20154.7-79.3-11.9-14.8-26.9-26.7-43.1-36.5%2053.1%201.1%20101.4%2047.4%20101.5%20101.1q-15.6%200.1-31%200.2c-2.2-11.7-5.3-23-9.4-34.1-60.3%2054.5-138.2%2088.6-218.9%2097.4-71.1%208.2-143.8-1.6-210.7-26.6%204.5%2041.4%209%2082.6%2013.2%20124-38%2014.8-73.3%2036.2-104.9%2062-25.1%2021.9-50%2047.1-59.6%2079.9-9.2%2028.9%205.8%2061.7%2031.1%2077.2%2030.7%2019%2066.5%2027.8%20101.9%2032.9%2046.7%206.1%2093.9%205.6%20140.8%202.3%2092.1-6.8%20183.1-24.1%20272.7-45.8%208.9-3.6%2013.1%2011.1%204%2013.4-71.5%2036.8-146.3%2067.8-224.3%2087.8-73.3%2018.9-148.8%2028.6-224.4%2031.2-77.1-2.4-159-17.3-220.1-67.8-45.4-36.8-69.3-95.2-69.5-153.1v-3.1c1.5-61.2%2022.2-120.4%2052-173.4%2039.2-74.8%2087.5-145%20144.6-207.3%2098.7-108.7%20222.5-192.8%20355.6-253.7%20137.9-62.5%20285.5-107.4%20437.3-115.7z'/%3e%3c/g%3e%3c/svg%3e",q0="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M47.4964%209.43757C46.988%209.19072%2046.769%209.66115%2046.4717%209.90013C46.37%209.97722%2046.284%2010.0774%2046.1979%2010.1699C45.4548%2010.9562%2044.5866%2011.4729%2043.4523%2011.4112C41.794%2011.3186%2040.3781%2011.8353%2039.1265%2013.092C38.8605%2011.5423%2037.9767%2010.617%2036.6312%2010.0234C35.9273%209.71497%2035.2154%209.40651%2034.7226%208.7357C34.3784%208.25783%2034.2845%207.7258%2034.1124%207.20147C34.0029%206.8854%2033.8934%206.56146%2033.5257%206.50747C33.1268%206.44587%2032.9703%206.77725%2032.8138%207.05499C32.1881%208.18844%2031.9456%209.43749%2031.969%2010.7019C32.0237%2013.5471%2033.2363%2015.8137%2035.6455%2017.4252C35.9193%2017.6103%2035.9896%2017.7952%2035.9036%2018.0652C35.7393%2018.6204%2035.5437%2019.16%2035.3717%2019.7151C35.2622%2020.0699%2035.0978%2020.147%2034.7146%2019.9926C33.3926%2019.4453%2032.2505%2018.6357%2031.2414%2017.6566C29.5284%2016.0143%2027.9795%2014.2024%2026.0475%2012.7837C25.5938%2012.4521%2025.1401%2012.1438%2024.6707%2011.8507C22.6994%209.95412%2024.9289%208.39653%2025.4451%208.21163C25.9848%208.01885%2025.6329%207.35566%2023.8884%207.36353C22.144%207.37114%2020.5483%207.94946%2018.5146%208.72047C18.2173%208.83615%2017.9043%208.92086%2017.5836%208.99025C15.7376%208.64338%2013.8211%208.56612%2011.8186%208.78986C8.04819%209.20613%205.03671%2010.9718%202.823%2013.9865C0.16347%2017.6103%20-0.462297%2021.7274%200.304303%2026.0221C1.11002%2030.5478%203.44099%2034.295%207.02367%2037.225C10.7393%2040.2626%2015.0181%2041.7507%2019.8992%2041.4655C22.8639%2041.2959%2026.1649%2040.9027%2029.8884%2037.7801C30.827%2038.2427%2031.8126%2038.4276%2033.4475%2038.5664C34.7069%2038.6821%2035.9194%2038.5048%2036.858%2038.3121C38.3286%2038.0037%2038.227%2036.6544%2037.6951%2036.4077C33.385%2034.4185%2034.3314%2035.228%2033.471%2034.5726C35.6613%2032.0052%2038.9624%2029.3374%2040.253%2020.6942C40.3546%2020.0081%2040.2686%2019.5763%2040.253%2019.0211C40.2451%2018.682%2040.3234%2018.551%2040.7145%2018.5123C41.794%2018.3889%2042.8422%2018.096%2043.8043%2017.5717C46.5969%2016.0606%2047.7233%2013.5779%2047.9892%2010.6017C48.0284%2010.1468%2047.9814%209.67638%2047.4964%209.43757ZM23.1611%2036.2225C18.984%2032.969%2016.9581%2031.8971%2016.1211%2031.9434C15.3388%2031.9897%2015.4797%2032.8764%2015.6517%2033.4547C15.8316%2034.0252%2016.0663%2034.4185%2016.3948%2034.9196C16.6216%2035.2511%2016.7782%2035.7445%2016.168%2036.1147C14.8226%2036.9397%2012.4836%2035.8371%2012.3741%2035.7832C9.65202%2034.1948%207.37571%2032.0975%205.77205%2029.2295C4.22322%2026.4691%203.32373%2023.5086%203.17504%2020.3474C3.13592%2019.5841%203.36276%2019.3141%204.12936%2019.1755C5.13843%2018.9904%206.17884%2018.9517%207.1879%2019.0982C11.4512%2019.7151%2015.0807%2021.6041%2018.1235%2024.5956C19.86%2026.2995%2021.1742%2028.3352%2022.5275%2030.3243C23.9668%2032.4368%2025.5156%2034.4493%2027.4868%2036.0992C28.183%2036.6775%2028.7384%2037.1169%2029.2703%2037.4408C27.6668%2037.6181%2024.9915%2037.6568%2023.1611%2036.2225ZM25.1636%2023.4623C25.1636%2023.123%2025.4374%2022.8532%2025.7817%2022.8532C25.8599%2022.8532%2025.9303%2022.8685%2025.9929%2022.8916C26.079%2022.9225%2026.1572%2022.9688%2026.2198%2023.038C26.3293%2023.1461%2026.3919%2023.3002%2026.3919%2023.4622C26.3919%2023.8014%2026.1181%2024.0712%2025.774%2024.0712C25.4299%2024.0712%2025.1636%2023.8015%2025.1636%2023.4623ZM31.3824%2026.6235C30.9835%2026.7854%2030.5846%2026.9241%2030.2013%2026.9395C29.6068%2026.9703%2028.9575%2026.7313%2028.6056%2026.4383C28.058%2025.9834%2027.6669%2025.7291%2027.5026%2024.9349C27.4322%2024.5956%2027.4713%2024.0713%2027.534%2023.7707C27.6747%2023.123%2027.5183%2022.7067%2027.0568%2022.3288C26.6813%2022.0204%2026.2041%2021.9357%2025.68%2021.9357C25.4844%2021.9357%2025.3046%2021.8508%2025.1716%2021.7814C24.9525%2021.6735%2024.7727%2021.4036%2024.9447%2021.0721C24.9995%2020.9643%2025.2655%2020.702%2025.3281%2020.6558C26.04%2020.2548%2026.8613%2020.3859%2027.6201%2020.6866C28.3242%2020.9719%2028.8561%2021.4962%2029.6226%2022.2363C30.4048%2023.1306%2030.5456%2023.3776%2030.9915%2024.0482C31.3436%2024.5725%2031.6643%2025.1122%2031.8833%2025.7291C32.0162%2026.1146%2031.844%2026.4307%2031.3824%2026.6235Z'%20fill='%234D6BFE'/%3e%3c/svg%3e",F0="data:image/svg+xml,%3csvg%20version='1.2'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201513%20975'%20width='1513'%20height='975'%3e%3ctitle%3eae99cd49-2667-464e-b9db-b39cee0126e1-svg%3c/title%3e%3cstyle%3e%20.s0%20{%20fill:%20%23ff5a00%20}%20%3c/style%3e%3cg%20id='%23ff5a00ff'%3e%3cpath%20id='Layer'%20class='s0'%20d='m989.5%200h67.8c95.3%205.4%20196.5%2023.1%20272.4%2085.5%2060.6%2049.1%2086.3%20133%2071.4%20208.6-11.4%2056.4-37.4%20108.4-65.4%20158.1-56.8%2098.4-126.6%20188.2-193%20280.1-11.9%2015.2-21.2%2033.8-20%2053.6%201.1%2015.7%2013.1%2028.4%2027.2%2034%2027.3%2011.1%2057.5%208.9%2086.2%207.3%2090.7-9.5%20178.1-37%20264.6-64.6%206.6-4.1%208.8%202.6%2011.3%207.4-91.9%2061.3-190.8%20112.4-294.8%20150-57.5%2019.3-118.3%2037.6-179.6%2030.4-32.2-3.2-64.5-22.4-74.6-54.5-12.5-41.8-7.9-88.1%2010.2-127.6%2027.5-61.7%2070.2-114.7%20110.7-168.2%2067.1-88%20136.4-175.5%20189.1-273.3%2017.4-34.7%2036-76.8%2018.7-115.1-16.3-35.3-51.7-56.1-85.6-71.8-60.2-26.9-124.4-43.1-187.7-61.1q-14.3%209.4-28.5%2019c22%2016.8%2044%2033.6%2065.8%2050.7-83.3%2015-166.3%2031.8-248.3%2052.7-124.9%2031-246.8%2072.5-367.6%20116.5%2011.8%2023.5%2023.5%2047.1%2034.7%2070.9-27.3%2030.2-54.4%2060.7-81.7%2090.9%2065.6%2019.6%20136.3%2022.3%20203.2%207.5%2057.2-12.8%20111-40.2%20154.7-79.3-11.9-14.8-26.9-26.7-43.1-36.5%2053.1%201.1%20101.4%2047.4%20101.5%20101.1q-15.6%200.1-31%200.2c-2.2-11.7-5.3-23-9.4-34.1-60.3%2054.5-138.2%2088.6-218.9%2097.4-71.1%208.2-143.8-1.6-210.7-26.6%204.5%2041.4%209%2082.6%2013.2%20124-38%2014.8-73.3%2036.2-104.9%2062-25.1%2021.9-50%2047.1-59.6%2079.9-9.2%2028.9%205.8%2061.7%2031.1%2077.2%2030.7%2019%2066.5%2027.8%20101.9%2032.9%2046.7%206.1%2093.9%205.6%20140.8%202.3%2092.1-6.8%20183.1-24.1%20272.7-45.8%208.9-3.6%2013.1%2011.1%204%2013.4-71.5%2036.8-146.3%2067.8-224.3%2087.8-73.3%2018.9-148.8%2028.6-224.4%2031.2-77.1-2.4-159-17.3-220.1-67.8-45.4-36.8-69.3-95.2-69.5-153.1v-3.1c1.5-61.2%2022.2-120.4%2052-173.4%2039.2-74.8%2087.5-145%20144.6-207.3%2098.7-108.7%20222.5-192.8%20355.6-253.7%20137.9-62.5%20285.5-107.4%20437.3-115.7z'/%3e%3c/g%3e%3c/svg%3e",z0="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBmaWxsPSJub25lIj4KICA8cmVjdCB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIGZpbGw9IiNGRjZCNkIiLz4KICA8dGV4dCB4PSI1MCUiIHk9IjUwJSIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZmlsbD0id2hpdGUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZm9udC13ZWlnaHQ9ImJvbGQiPk1NPC90ZXh0Pgo8L3N2Zz4=",H0="/agents/assets/img/moonshotai.svg",W0="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3crect%20width='48'%20height='48'%20fill='black'/%3e%3cpath%20d='M10.008%2019.311L24.0672%2040H30.3165L16.2557%2019.311H10.008ZM16.2509%2030.8017L10%2040H16.2541L19.3771%2035.4017L16.2509%2030.8017ZM31.7459%208L20.941%2023.8993L24.0672%2028.5009L38%208H31.7459ZM32.8777%2017.8382V40H38V10.3008L32.8777%2017.8382Z'%20fill='white'/%3e%3c/svg%3e",J0="/agents/assets/img/zai.svg",Z0="/agents/assets/img/zai.svg",K0="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBmaWxsPSJub25lIj4KICA8cmVjdCB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIGZpbGw9IiNBOEU2QTMiLz4KICA8dGV4dCB4PSI1MCUiIHk9IjUwJSIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZmlsbD0iIzJDM0U1MCIgZm9udC1mYW1pbHk9IkFyaWFsLCBzYW5zLXNlcmlmIiBmb250LXNpemU9IjE0IiBmb250LXdlaWdodD0iYm9sZCI+RVhBPC90ZXh0Pgo8L3N2Zz4=",oo="data:image/svg+xml,%3csvg%20fill='currentColor'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eOpenRouter%3c/title%3e%3cpath%20d='M16.804%201.957l7.22%204.105v.087L16.73%2010.21l.017-2.117-.821-.03c-1.059-.028-1.611.002-2.268.11-1.064.175-2.038.577-3.147%201.352L8.345%2011.03c-.284.195-.495.336-.68.455l-.515.322-.397.234.385.23.53.338c.476.314%201.17.796%202.701%201.866%201.11.775%202.083%201.177%203.147%201.352l.3.045c.694.091%201.375.094%202.825.033l.022-2.159%207.22%204.105v.087L16.589%2022l.014-1.862-.635.022c-1.386.042-2.137.002-3.138-.162-1.694-.28-3.26-.926-4.881-2.059l-2.158-1.5a21.997%2021.997%200%2000-.755-.498l-.467-.28a55.927%2055.927%200%2000-.76-.43C2.908%2014.73.563%2014.116%200%2014.116V9.888l.14.004c.564-.007%202.91-.622%203.809-1.124l1.016-.58.438-.274c.428-.28%201.072-.726%202.686-1.853%201.621-1.133%203.186-1.78%204.881-2.059%201.152-.19%201.974-.213%203.814-.138l.02-1.907z'%3e%3c/path%3e%3c/svg%3e";function G0(t){const i=ot();return i==="/"?t.replace("/agents/","/"):t.replace("/agents/",`${i}/`)}const X0={anthropic:U0,openai:wt,"openai-sdk":wt,google:R0,meta:jt,"meta-llama":jt,nvidia:N0,alibaba:B0,deepseek:q0,qwen:F0,minimax:z0,moonshotai:H0,"x-ai":W0,"z-ai":J0,zai:Z0,exaone:K0,openrouter:oo},Y0=new Proxy(X0,{get(t,i){const n=t[i];return n?G0(n):void 0}});function Q0(t){if(t&&t.includes("/"))return t.split("/")[0].toLowerCase()}function ut(t){return Y0[t.toLowerCase()]}function Qe(t,i){const n=Q0(t);if(n){const u=ut(n);if(u)return u}if(i)return ut(i)}const e2={class:"space-y-4"},t2=se({__name:"PromptModelSelect",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:i}){const n=i,u=v([]),l=v(!1),c=K(()=>u.value.map(p=>({value:p.id,label:p.name,description:p.model||p.provider,icon:Qe(p.model||p.name,p.provider_id||p.provider)}))),r=async()=>{l.value=!0;try{const p=await fetch(ae("/api/models"));if(p.ok){const f=await p.json();u.value=f.models||[]}}catch(p){console.error("Error fetching models:",p)}finally{l.value=!1}};return xe(()=>{r()}),(p,f)=>(o(),a("div",e2,[E(he,{"model-value":t.modelValue,"onUpdate:modelValue":f[0]||(f[0]=b=>n("update:modelValue",b)),options:c.value,label:"Model",placeholder:"Select a model for this prompt","search-placeholder":"Search models...",loading:l.value},null,8,["model-value","options","loading"])]))}}),o2=["data-property-id","data-nested-property-id"],l2={class:"p-3 space-y-3"},a2={class:"flex items-start gap-2"},s2={key:0,class:"drag-handle cursor-move text-neutral-400 hover:text-neutral-600 dark:text-neutral-600 dark:hover:text-neutral-400 mt-2"},n2={class:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2"},r2={class:"flex items-center gap-2 mt-2"},i2=["disabled"],d2={key:0,class:"ml-6"},u2={key:0,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg space-y-2"},c2={class:"flex items-center justify-between mb-2"},p2=["disabled"],m2={key:0,class:"space-y-1"},v2=["onClick","disabled"],f2={key:1,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},h2={class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"},g2={class:"space-y-2"},b2={class:"flex items-center justify-between"},x2=["disabled"],y2={class:"space-y-2"},k2={key:2,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},w2={key:0,class:"mb-2"},_2=["disabled"],$2={key:1,class:"space-y-2"},C2=se({__name:"PropertyEditor",props:Ne({propertyId:{},isNested:{type:Boolean,default:!1},parentId:{},disabled:{type:Boolean,default:!1},enableDrag:{type:Boolean,default:!0}},{modelValue:{required:!0},modelModifiers:{}}),emits:Ne(["remove","description-keydown","add-top-level"],["update:modelValue"]),setup(t,{emit:i}){const n=t,u=i,l=Je(t,"modelValue"),c=v(!1);v();const r=[{value:"string",label:"String",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z'/%3E%3C/svg%3E"},{value:"number",label:"Number",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M7 20l4-16m2 16l4-16M6 9h14M4 15h14'/%3E%3C/svg%3E"},{value:"boolean",label:"Boolean",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z'/%3E%3C/svg%3E"},{value:"object",label:"Object",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10'/%3E%3C/svg%3E"},{value:"array",label:"Array",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 6h16M4 10h16M4 14h16M4 18h16'/%3E%3C/svg%3E"},{value:"enum",label:"Enum",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4'/%3E%3C/svg%3E"},{value:"anyOf",label:"Any Of (Multiple Types)",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E"}],p=K(()=>["object","array","enum","anyOf"].includes(l.value.type));ue(()=>l.value.type,async(g,m)=>{if(["object","array","enum","anyOf"].includes(g)&&(c.value=!0,g==="anyOf"&&!l.value.anyOf&&(l.value.anyOf=[]),g==="object"&&!l.value.properties&&(l.value.properties=[{id:crypto.randomUUID(),name:"property1",type:"string",description:""}]),g==="array"&&!l.value.items&&(l.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""}),g==="enum"&&!l.value.enum&&(l.value.enum=["value1"])),m!==void 0){await ge();const w=n.isNested?`[data-nested-property-id="${n.propertyId}"] input[placeholder="Description"]`:`[data-property-id="${n.propertyId}"] input[placeholder="Description"]`,k=document.querySelector(w);k&&k.focus()}});const f=g=>{g.shiftKey&&l.value.type==="object"&&l.value.properties?h():u("add-top-level")},b=()=>{l.value.items||(l.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""})},s=()=>{l.value.enum||(l.value.enum=[]),l.value.enum.push(`value${l.value.enum.length+1}`)},d=g=>{l.value.enum&&l.value.enum.splice(g,1)},h=async()=>{const g={id:crypto.randomUUID(),name:l.value.type==="anyOf"?"":`property${(l.value.properties?.length||l.value.anyOf?.length||0)+1}`,type:"string",description:""};l.value.type==="anyOf"?(l.value.anyOf||(l.value.anyOf=[]),l.value.anyOf.push(g)):(l.value.properties||(l.value.properties=[]),l.value.properties.push(g)),await ge();const m=document.querySelector(`[data-nested-property-id="${g.id}"] input[placeholder="Property name"]`);m&&(m.focus(),m.select())},$=g=>{l.value.type==="anyOf"&&l.value.anyOf?l.value.anyOf=l.value.anyOf.filter(m=>m.id!==g):l.value.properties&&(l.value.properties=l.value.properties.filter(m=>m.id!==g))};return(g,m)=>{const w=$o("PropertyEditor",!0);return o(),a("div",{"data-property-id":t.isNested?void 0:t.propertyId,"data-nested-property-id":t.isNested?t.propertyId:void 0,class:le(["border rounded-lg",t.isNested?"border-neutral-100 dark:border-neutral-900":"border-neutral-200 dark:border-neutral-800"])},[e("div",l2,[e("div",a2,[t.enableDrag?(o(),a("div",s2,[...m[10]||(m[10]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8h16M4 16h16"})],-1)])])):L("",!0),e("div",n2,[E(Ce,{modelValue:l.value.name,"onUpdate:modelValue":m[0]||(m[0]=k=>l.value.name=k),placeholder:"Property name",disabled:t.disabled},null,8,["modelValue","disabled"]),E(he,{modelValue:l.value.type,"onUpdate:modelValue":m[1]||(m[1]=k=>l.value.type=k),options:r,disabled:t.disabled},null,8,["modelValue","disabled"]),E(Ce,{modelValue:l.value.description,"onUpdate:modelValue":m[2]||(m[2]=k=>l.value.description=k),placeholder:"Description",disabled:t.disabled,onKeydown:m[3]||(m[3]=xt(we(k=>f(k),["prevent"]),["enter"]))},null,8,["modelValue","disabled"])]),e("div",r2,[p.value?(o(),a("button",{key:0,onClick:m[4]||(m[4]=k=>c.value=!c.value),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors"},[(o(),a("svg",{class:le(["w-4 h-4 transition-transform",c.value?"rotate-90":""]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...m[11]||(m[11]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))])):L("",!0),e("button",{onClick:m[5]||(m[5]=k=>g.$emit("remove")),type:"button",disabled:t.disabled,class:"p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors disabled:opacity-50"},[...m[12]||(m[12]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,i2)])]),c.value&&p.value?(o(),a("div",d2,[l.value.type==="enum"?(o(),a("div",u2,[e("div",c2,[m[13]||(m[13]=e("h4",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400"}," Enum Values ",-1)),e("button",{onClick:s,type:"button",disabled:t.disabled,class:"px-2 py-0.5 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"}," Add Value ",8,p2)]),l.value.enum?(o(),a("div",m2,[(o(!0),a(pe,null,fe(l.value.enum,(k,O)=>(o(),a("div",{key:O,class:"flex items-center gap-2"},[E(Ce,{modelValue:l.value.enum[O],"onUpdate:modelValue":D=>l.value.enum[O]=D,placeholder:"Enum value",disabled:t.disabled,class:"flex-1"},null,8,["modelValue","onUpdate:modelValue","disabled"]),e("button",{onClick:D=>d(O),type:"button",disabled:t.disabled,class:"p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors disabled:opacity-50"},[...m[14]||(m[14]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,v2)]))),128))])):L("",!0)])):L("",!0),l.value.type==="object"||l.value.type==="anyOf"?(o(),a("div",f2,[e("h4",h2,C(l.value.type==="anyOf"?"Type Options":"Nested Properties"),1),e("div",g2,[e("div",b2,[e("button",{onClick:h,type:"button",disabled:t.disabled,class:"px-2 py-0.5 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"}," Add "+C(l.value.type==="anyOf"?"Type Option":"Property"),9,x2)]),e("div",y2,[(o(!0),a(pe,null,fe(l.value.type==="anyOf"?l.value.anyOf:l.value.properties,(k,O)=>(o(),ee(w,{key:k.id,modelValue:(l.value.type==="anyOf"?l.value.anyOf:l.value.properties)[O],"onUpdate:modelValue":D=>(l.value.type==="anyOf"?l.value.anyOf:l.value.properties)[O]=D,"property-id":k.id,"is-nested":!0,"parent-id":t.propertyId,disabled:t.disabled,"enable-drag":!1,onRemove:D=>$(k.id),onAddTopLevel:m[6]||(m[6]=D=>u("add-top-level"))},null,8,["modelValue","onUpdate:modelValue","property-id","parent-id","disabled","onRemove"]))),128))])])])):L("",!0),l.value.type==="array"?(o(),a("div",k2,[m[15]||(m[15]=e("h4",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Array Item Type ",-1)),l.value.items?L("",!0):(o(),a("div",w2,[e("button",{onClick:b,type:"button",disabled:t.disabled,class:"px-2 py-0.5 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"}," Define Item Type ",8,_2)])),l.value.items?(o(),a("div",$2,[E(w,{modelValue:l.value.items,"onUpdate:modelValue":m[7]||(m[7]=k=>l.value.items=k),"property-id":l.value.items.id,"is-nested":!0,"parent-id":t.propertyId,disabled:t.disabled,"enable-drag":!1,onRemove:m[8]||(m[8]=k=>l.value.items=null),onAddTopLevel:m[9]||(m[9]=k=>u("add-top-level"))},null,8,["modelValue","property-id","parent-id","disabled"])])):L("",!0)])):L("",!0)])):L("",!0)])],10,o2)}}}),V2={class:"space-y-2"},S2=["disabled"],T2=se({__name:"PropertyList",props:Ne({disabled:{type:Boolean,default:!1},parentId:{},isNested:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:Ne(["add-property","description-keydown"],["update:modelValue"]),setup(t,{expose:i,emit:n}){const u=t,l=n,c=Je(t,"modelValue"),r=v();let p=!1;xe(async()=>{}),Be(()=>{});const f=async()=>{if(p)return;p=!0;const s={id:crypto.randomUUID(),name:`property${c.value.length+1}`,type:"string",description:"",required:!1};c.value=[...c.value,s],await ge();const d=u.parentId?`[data-nested-property-id="${s.id}"]`:`[data-property-id="${s.id}"]`,h=document.querySelector(`${d} input[placeholder="Property name"]`);h&&(h.focus(),h.select()),l("add-property"),p=!1},b=s=>{c.value=c.value.filter(d=>d.id!==s)};return i({addProperty:f}),(s,d)=>(o(),a("div",V2,[e("div",{ref_key:"dragAreaRef",ref:r,class:"space-y-2"},[(o(!0),a(pe,null,fe(c.value,h=>(o(),ee(C2,{key:h.id,modelValue:c.value[c.value.indexOf(h)],"onUpdate:modelValue":$=>c.value[c.value.indexOf(h)]=$,"property-id":h.id,"is-nested":t.isNested,"parent-id":t.parentId,disabled:t.disabled,"enable-drag":!t.isNested,onRemove:$=>b(h.id),onAddTopLevel:d[0]||(d[0]=$=>s.$emit("add-property"))},null,8,["modelValue","onUpdate:modelValue","property-id","is-nested","parent-id","disabled","enable-drag","onRemove"]))),128))],512),e("div",{class:le(t.isNested?"mt-2":"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-800")},[e("button",{onClick:f,type:"button",disabled:t.disabled,class:le(t.isNested?"px-2 py-1 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50":"w-full px-3 py-2 text-sm bg-neutral-50 dark:bg-neutral-900 hover:bg-neutral-100 dark:hover:bg-neutral-800 text-neutral-700 dark:text-neutral-300 rounded transition-colors disabled:opacity-50 border border-dashed border-neutral-300 dark:border-neutral-700")},[...d[1]||(d[1]=[e("span",{class:"flex items-center justify-center gap-2"},[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})]),ye(" Add Property ")],-1)])],10,S2)],2)]))}}),M2={class:"space-y-4"},L2={key:0,class:"flex items-center justify-between"},I2={class:"text-sm font-medium"},E2={key:0,class:"text-red-500"},A2={class:"space-y-2 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4"},P2={key:0,class:"flex items-center justify-between mb-2"},O2={key:1,class:"text-center py-12"},j2=["disabled"],D2={class:"mt-4 text-center"},U2={key:3,class:"mt-4"},R2={class:"bg-neutral-50 dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4 overflow-x-auto"},N2={class:"text-xs leading-relaxed"},B2=["innerHTML"],lo=se({__name:"JSONSchemaInput",props:Ne({label:{},disabled:{type:Boolean,default:!1},required:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>({type:"object",properties:{},required:[]})},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const i=Je(t,"modelValue"),n=v([]),u=v(),l=v(!1),c=()=>{if(i.value?.properties){const g=[];i.value.required;for(const[m,w]of Object.entries(i.value.properties)){const k=w,O={id:crypto.randomUUID(),name:m,type:k.type||"string",description:k.description||""};k.enum&&(O.enum=k.enum),k.anyOf&&(O.type="anyOf",O.anyOf=r(k.anyOf)),k.type==="array"&&k.items&&(O.items=p(k.items)),k.type==="object"&&k.properties&&(O.properties=f(k.properties,k.required||[])),g.push(O)}n.value=g}},r=g=>g.map(m=>typeof m=="object"&&m.type?{id:crypto.randomUUID(),name:"",type:m.type,description:m.description||"",properties:m.properties?f(m.properties,m.required||[]):void 0,items:m.items?p(m.items):void 0,enum:m.enum}:{id:crypto.randomUUID(),name:"",type:"string",description:""}),p=g=>{const m={id:crypto.randomUUID(),name:"",type:g.type||"string",description:g.description||""};return g.enum&&(m.enum=g.enum),g.anyOf&&(m.type="anyOf",m.anyOf=r(g.anyOf)),g.type==="array"&&g.items&&(m.items=p(g.items)),g.type==="object"&&g.properties&&(m.properties=f(g.properties,g.required||[])),m},f=(g,m)=>{const w=[];for(const[k,O]of Object.entries(g)){const D=O,F={id:crypto.randomUUID(),name:k,type:D.type||"string",description:D.description||""};D.enum&&(F.enum=D.enum),D.anyOf&&(F.type="anyOf",F.anyOf=r(D.anyOf)),D.type==="array"&&D.items&&(F.items=p(D.items)),D.type==="object"&&D.properties&&(F.properties=f(D.properties,D.required||[])),w.push(F)}return w};c();const b=()=>{const g={type:"object",properties:{},required:[],additionalProperties:!1},{properties:m}=d(n.value);g.properties=m,g.required=Object.keys(m),i.value=g},s=g=>{const m={type:g.type==="anyOf"?void 0:g.type,description:g.description};if(g.type==="enum"&&g.enum&&(m.enum=g.enum,m.type="string"),g.type==="anyOf"&&g.anyOf&&(delete m.type,m.anyOf=g.anyOf.map(s)),g.type==="object"&&g.properties){const{properties:w}=d(g.properties);m.properties=w,m.required=Object.keys(w),m.additionalProperties=!1}return g.type==="array"&&g.items&&(m.items=s(g.items)),m},d=g=>{const m={},w=[];for(const k of g){const O={type:k.type==="anyOf"?void 0:k.type,description:k.description};if(w.push(k.name),k.type==="enum"&&k.enum&&(O.enum=k.enum,O.type="string"),k.type==="anyOf"&&k.anyOf&&k.anyOf.length>0&&(delete O.type,O.anyOf=k.anyOf.map(s)),k.type==="array"&&k.items&&(O.items=s(k.items)),k.type==="object"&&k.properties){const{properties:D}=d(k.properties);O.properties=D,O.required=Object.keys(D),O.additionalProperties=!1}m[k.name]=O}return{properties:m,required:w}};ue(n,()=>{b()},{deep:!0}),b();const h=K(()=>JSON.stringify(i.value,null,2).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"([^"]+)":/g,'<span class="text-blue-600 dark:text-blue-400">"$1"</span>:').replace(/:"([^"]*)"/g,':<span class="text-green-600 dark:text-green-400">"$1"</span>').replace(/:(\d+)/g,':<span class="text-yellow-600 dark:text-yellow-400">$1</span>').replace(/:(true|false)/g,':<span class="text-purple-600 dark:text-purple-400">$1</span>').replace(/:(null)/g,':<span class="text-red-600 dark:text-red-400">$1</span>')),$=async()=>{if(n.value.length===0){const g={id:crypto.randomUUID(),name:"property1",type:"string",description:""};n.value.push(g),await ge();const m=document.querySelector(`[data-property-id="${g.id}"] input[placeholder="Property name"]`);m&&(m.focus(),m.select())}else u.value&&u.value.addProperty()};return(g,m)=>(o(),a("div",M2,[t.label?(o(),a("div",L2,[e("label",I2,[ye(C(t.label)+" ",1),t.required?(o(),a("span",E2,"*")):L("",!0)])])):L("",!0),e("div",A2,[n.value.length>0?(o(),a("div",P2,[...m[2]||(m[2]=[e("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Properties ",-1)])])):L("",!0),n.value.length===0?(o(),a("div",O2,[m[4]||(m[4]=e("div",{class:"mb-4"},[e("svg",{class:"w-12 h-12 mx-auto text-neutral-400 dark:text-neutral-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})])],-1)),m[5]||(m[5]=e("p",{class:"text-neutral-500 dark:text-neutral-400 text-sm mb-4"}," No properties defined ",-1)),e("button",{onClick:$,type:"button",disabled:t.disabled,class:"px-4 py-2 bg-black dark:bg-white text-white dark:text-black rounded hover:bg-neutral-800 dark:hover:bg-neutral-200 transition-colors disabled:opacity-50 font-medium text-sm"},[...m[3]||(m[3]=[e("span",{class:"flex items-center gap-2"},[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})]),ye(" Add Property ")],-1)])],8,j2)])):L("",!0),n.value.length>0?(o(),ee(T2,{key:2,ref_key:"propertyListRef",ref:u,modelValue:n.value,"onUpdate:modelValue":m[0]||(m[0]=w=>n.value=w),disabled:t.disabled,onAddProperty:$},null,8,["modelValue","disabled"])):L("",!0),e("div",D2,[e("button",{onClick:m[1]||(m[1]=w=>l.value=!l.value),type:"button",class:"text-xs text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-100 hover:underline transition-colors"},C(l.value?"Hide":"Show")+" JSON Schema ",1)]),l.value?(o(),a("div",U2,[e("div",R2,[e("pre",N2,[e("code",{class:"font-mono",innerHTML:h.value},null,8,B2)])])])):L("",!0)])]))}}),q2={class:"prompt-input-container relative"},F2=["contenteditable","data-placeholder"],z2={class:"bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded-lg overflow-hidden min-w-[240px] max-w-[320px]"},H2={key:0,class:"p-3 text-sm text-neutral-500"},W2={key:1,class:"p-3 text-sm text-neutral-500"},J2={key:2,class:"max-h-[220px] overflow-y-auto"},Z2=["onClick"],K2={class:"font-medium flex items-center gap-2"},G2=["title"],X2={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},Y2={key:1,class:"text-xs text-red-600 dark:text-red-400 mt-1"},Q2={class:"text-xs mt-1"},ep=se({__name:"PromptInput",props:{modelValue:{},search:{},placeholder:{default:"Type @ to insert variables or prompts..."},disabled:{type:Boolean,default:!1},maxLength:{},allowedTypes:{default:()=>["variable","prompt"]}},emits:["update:modelValue","segment-click"],setup(t,{emit:i}){const n=t,u=i,l=v(),c=v(),r=Co({segments:n.modelValue&&n.modelValue.length?n.modelValue:[{type:"string",value:""}],dialogOpen:!1,dialogPosition:{x:0,y:0},searchQuery:"",searchResults:[],selectedIndex:0,isSearching:!1,atTriggerIndex:-1,isComposing:!1,ignoreNextWatch:!1}),p=()=>Math.random().toString(36).slice(2)+Date.now().toString(36),f=y=>y.type==="string"?"":`@${y.type==="variable"?y.label||y.value:y.label||y.id}`,b=()=>{const y=window.getSelection();if(!y||!y.rangeCount||!l.value)return null;const x=y.getRangeAt(0);let V=0;const _=Array.from(l.value.childNodes);for(let T=0;T<_.length;T++){const S=_[T];if(S===x.startContainer||S.contains?.(x.startContainer)){if(S.nodeType===Node.TEXT_NODE)return{segmentIndex:V,offset:x.startOffset};if(S.nodeType===Node.ELEMENT_NODE&&S.classList?.contains("prompt-tag"))return{segmentIndex:V,offset:0}}(S.nodeType===Node.TEXT_NODE||S.nodeType===Node.ELEMENT_NODE&&S.classList?.contains("prompt-tag"))&&V++}return{segmentIndex:0,offset:0}},s=()=>{if(!l.value)return;const y=r.segments.map(x=>{if(x.type==="string")return(x.value||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")||"";{const V=x._uid||(x._uid=p()),_=f(x),T=x.type==="variable"?{type:"variable",value:x.value,label:x.label,schema:x.schema,meta:x.meta}:{type:"prompt",id:x.id,label:x.label,schema:x.schema,meta:x.meta},S=encodeURIComponent(JSON.stringify(T)),P=x.type==="prompt"&&x.meta&&!x.meta.isValid,J=P?'<span class="prompt-tag-warning" title="'+(x.meta.validationMessage||"").replace(/"/g,"&quot;")+'">⚠️</span>':"";return`<span class="prompt-tag prompt-tag-clickable${P?" prompt-tag-invalid":""}" contenteditable="false" data-segment-uid="${V}" data-segment="${S}">${_}${J}</span>`}}).join("");l.value.innerHTML=y||"<br>"},d=()=>{const y=[];for(const x of r.segments)x.type==="string"&&y.length>0&&y[y.length-1].type==="string"?y[y.length-1].value+=x.value:y.push(x);r.segments=y.length?y:[{type:"string",value:""}]},h=y=>{const x=y.dataset.segmentUid;let V=r.segments.find(_=>_._uid===x);if(!V){const _=y.dataset.segment;if(_)try{const T=JSON.parse(decodeURIComponent(_));T&&(T.type==="variable"||T.type==="prompt")&&(V=T.type==="variable"?{type:"variable",value:T.value,label:T.label,schema:T.schema,meta:T.meta,_uid:x}:{type:"prompt",id:T.id,label:T.label,schema:T.schema,meta:T.meta,_uid:x})}catch{}}return V||null},$=y=>{const x=y.target;if(x.classList?.contains("prompt-tag")){const V=h(x);V&&u("segment-click",V,y)}},g=y=>{if(r.isComposing)return;const x=y.target,V=[];let _="";const T=()=>{_.length>0&&(V.push({type:"string",value:_}),_="")},S=A=>{if(A.nodeType===Node.TEXT_NODE){const I=(A.textContent||"").replace(/\u00A0/g," ");_+=I;return}if(A.nodeType===Node.ELEMENT_NODE){const I=A;if(I.classList?.contains("prompt-tag")){T();const oe=h(I);oe&&V.push(oe);return}if(I.tagName==="BR"){_+=`
9
+ `;return}const M=Array.from(I.childNodes);for(const oe of M)S(oe);(I.tagName==="DIV"||I.tagName==="P"||I.tagName==="LI")&&I.nextSibling&&(_+=`
10
+ `);return}},P=Array.from(x.childNodes);for(const A of P)S(A);T();const re=V.some(A=>A.type!=="string")?V:[{type:"string",value:(x.innerText||"").replace(/\r\n/g,`
11
+ `)}];r.segments=re.length?re:[{type:"string",value:""}],d(),m(),B()},m=()=>{const y=window.getSelection();if(!y||!y.rangeCount||!l.value)return;const x=y.getRangeAt(0);if(x.startContainer.nodeType!==Node.TEXT_NODE){r.dialogOpen&&k();return}const _=x.startContainer.textContent||"",T=x.startOffset;if(T>0&&_[T-1]==="@")r.atTriggerIndex=T-1,r.searchQuery="",w(),F("");else if(r.dialogOpen&&r.atTriggerIndex>=0)if(x.startContainer.nodeType===Node.TEXT_NODE){const S=x.startContainer.textContent||"",P=x.startOffset;if(P<=r.atTriggerIndex){k();return}const J=S.substring(0,P);if(J.length>r.atTriggerIndex&&J[r.atTriggerIndex]==="@"){const re=J.substring(r.atTriggerIndex+1);re.includes(" ")||re.includes(`
12
+ `)||re.length>r.searchQuery.length+5?k():(r.searchQuery=re,F(re))}else k()}else k()},w=async()=>{r.dialogOpen=!0,r.selectedIndex=0,await ge(),O()},k=()=>{r.dialogOpen=!1,r.searchResults=[],r.searchQuery="",r.atTriggerIndex=-1,r.isSearching=!1},O=()=>{if(!c.value||!l.value)return;const y=window.getSelection();if(!y||!y.rangeCount)return;const V=y.getRangeAt(0).getBoundingClientRect(),_=l.value.getBoundingClientRect();r.dialogPosition={x:V.left-_.left,y:V.bottom-_.top+4}};let D=null;const F=async y=>{if(!n.search){r.searchResults=[];return}D&&clearTimeout(D),r.isSearching=!0,D=setTimeout(async()=>{try{const x=await n.search(y);r.searchResults=(x||[]).filter(V=>n.allowedTypes?.includes(V.type))}catch(x){console.error("Search error:",x),r.searchResults=[]}finally{r.isSearching=!1}},200)},X=y=>y.type==="variable"?{type:"variable",value:y.value??y.id??"",label:y.label,schema:y.schema,_uid:p(),meta:y.meta}:{type:"prompt",id:y.id??y.value??"",label:y.label,schema:y.schema,_uid:p(),meta:y.meta},te=y=>{if(r.atTriggerIndex<0||!l.value)return;const x=window.getSelection();if(!x||!x.rangeCount)return;const V=x.getRangeAt(0);if(V.startContainer.nodeType!==Node.TEXT_NODE)return;const _=V.startContainer,T=_.data.slice(0,r.atTriggerIndex),S=_.data.slice(V.startOffset),P=document.createElement("span"),J=X(y),re=J.type==="prompt"&&J.meta&&!J.meta.isValid;P.className=`prompt-tag${re?" prompt-tag-invalid":""}`,P.setAttribute("contenteditable","false");const A=J._uid||(J._uid=p());P.dataset.segmentUid=A;const I=J.type==="variable"?{type:"variable",value:J.value,label:J.label,schema:J.schema}:{type:"prompt",id:J.id,label:J.label,schema:J.schema};if(P.dataset.segment=encodeURIComponent(JSON.stringify(I)),P.textContent=f(J),re){const ve=document.createElement("span");ve.className="prompt-tag-warning",ve.textContent="⚠️",ve.setAttribute("title",J.meta.validationMessage||"Validation error"),P.appendChild(ve)}const M=_.parentNode,oe=document.createTextNode(S),Y=document.createTextNode(T);M.insertBefore(Y,_),M.insertBefore(P,_),M.insertBefore(oe,_),M.removeChild(_),k(),g({target:l.value});const ie=window.getSelection();if(ie){const ve=document.createRange();ve.setStart(oe,0),ve.collapse(!0),ie.removeAllRanges(),ie.addRange(ve)}l.value.focus()},R=y=>{if((y.key==="ArrowLeft"||y.key==="ArrowRight")&&setTimeout(()=>m(),0),r.dialogOpen)y.key==="ArrowDown"?(y.preventDefault(),r.selectedIndex=Math.min(r.selectedIndex+1,r.searchResults.length-1)):y.key==="ArrowUp"?(y.preventDefault(),r.selectedIndex=Math.max(r.selectedIndex-1,0)):y.key==="Enter"?(y.preventDefault(),r.searchResults[r.selectedIndex]&&te(r.searchResults[r.selectedIndex])):(y.key==="Escape"||y.key==="Esc")&&(y.preventDefault(),k());else if(y.key==="Backspace"||y.key==="Delete"){const x=b();if(y.key==="Backspace"){const V=window.getSelection();if(V&&V.rangeCount){const _=V.getRangeAt(0);if(_.collapsed&&_.startContainer.nodeType===Node.TEXT_NODE&&_.startOffset===0){let T=_.startContainer;for(;T&&T!==l.value;){const S=T.previousSibling;if(S&&S.nodeType===Node.ELEMENT_NODE&&S.classList?.contains("prompt-tag")){y.preventDefault(),S.parentNode?.removeChild(S),g({target:l.value});return}T=T.parentNode}}}}if(!x)return;if(y.key==="Backspace"&&x.offset===0&&x.segmentIndex>0)r.segments[x.segmentIndex-1].type!=="string"&&(y.preventDefault(),r.segments.splice(x.segmentIndex-1,1),d(),B(),s());else if(y.key==="Delete"&&x.segmentIndex<r.segments.length-1){const V=r.segments[x.segmentIndex];V.type==="string"&&(V.value?.length??0)===x.offset&&r.segments[x.segmentIndex+1].type!=="string"&&(y.preventDefault(),r.segments.splice(x.segmentIndex+1,1),d(),B(),s())}}},j=y=>{y.preventDefault();const x=y.clipboardData?.getData("text/plain")||"";document.execCommand("insertText",!1,x)},W=y=>{if(!r.dialogOpen)return;const x=c.value;x&&(x.contains(y.target)||k())},B=()=>{r.ignoreNextWatch=!0;const y=r.segments.map(x=>{const{_uid:V,..._}=x||{};return _});u("update:modelValue",y)},N=()=>{const y=window.getSelection();if(!y||!l.value)return;const x=y.anchorNode;x&&l.value.contains(x)&&m()},U=y=>{(y.key==="Escape"||y.key==="Esc")&&r.dialogOpen&&(y.preventDefault(),k())};return xe(()=>{n.modelValue&&n.modelValue.length&&(r.segments=JSON.parse(JSON.stringify(n.modelValue))),s(),document.addEventListener("mousedown",W),document.addEventListener("selectionchange",N),document.addEventListener("keydown",U,!0)}),Be(()=>{document.removeEventListener("mousedown",W),document.removeEventListener("selectionchange",N),document.removeEventListener("keydown",U,!0)}),ue(()=>n.modelValue,y=>{if(r.ignoreNextWatch){r.ignoreNextWatch=!1;return}y&&(r.segments=JSON.parse(JSON.stringify(y)),s())},{deep:!0}),(y,x)=>(o(),a("div",q2,[e("div",{ref_key:"editorRef",ref:l,contenteditable:!t.disabled,onInput:g,onKeydown:R,onPaste:j,onClick:$,onKeyup:x[0]||(x[0]=V=>{V.key==="Escape"?(V.preventDefault(),k()):(V.key==="ArrowLeft"||V.key==="ArrowRight")&&m()}),onCompositionstart:x[1]||(x[1]=V=>r.isComposing=!0),onCompositionend:x[2]||(x[2]=V=>r.isComposing=!1),class:le(["prompt-input-editor","min-h-[100px] p-3 border-2 rounded-lg","border-black dark:border-neutral-300","bg-white dark:bg-black","focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white",t.disabled?"opacity-50 cursor-not-allowed":""]),"data-placeholder":t.placeholder},[Se(e("div",null,[He(y.$slots,"segment",{segment:null},void 0,!0)],512),[[Ye,!1]])],42,F2),r.dialogOpen?(o(),a("div",{key:0,ref_key:"dialogRef",ref:c,class:"absolute z-50",style:pt({left:`${r.dialogPosition.x}px`,top:`${r.dialogPosition.y}px`})},[E(tt,{"offset-x":2,"offset-y":2,intensity:.3},{default:de(()=>[e("div",z2,[r.isSearching?(o(),a("div",H2," Searching... ")):r.searchResults.length===0?(o(),a("div",W2," No results found ")):(o(),a("div",J2,[(o(!0),a(pe,null,fe(r.searchResults,(V,_)=>(o(),a("button",{key:V.id||V.value||_,type:"button",onClick:T=>te(V),class:le(["w-full px-3 py-2 text-left text-sm","hover:bg-neutral-100 dark:hover:bg-neutral-900","focus:bg-neutral-100 dark:focus:bg-neutral-900 focus:outline-none",r.selectedIndex===_?"bg-neutral-100 dark:bg-neutral-900":""])},[e("div",K2,[ye(C(V.label||V.id||V.value)+" ",1),V.type==="prompt"&&V.meta&&!V.meta.isValid?(o(),a("span",{key:0,title:V.meta.validationMessage,class:"text-red-500"},"⚠️",8,G2)):L("",!0)]),V.description?(o(),a("div",X2,C(V.description),1)):L("",!0),V.type==="prompt"&&V.meta&&!V.meta.isValid?(o(),a("div",Y2,C(V.meta.validationMessage),1)):L("",!0),e("div",Q2,[e("span",{class:le(["inline-block px-1.5 py-0.5 rounded",V.type==="variable"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-purple-100 dark:bg-purple-900 text-purple-700 dark:text-purple-300"])},C(V.type),3)])],10,Z2))),128))]))])]),_:1})],4)):L("",!0)]))}}),ao=Ze(ep,[["__scopeId","data-v-7ee6148f"]]);function Dt(t,i){if(!i||!i.properties||Object.keys(i.properties).length===0)return!0;if(!t||!t.properties)return Object.keys(i.properties);const n=[],u=t.properties||{},l=i.properties||{};return(i.required||[]).forEach(r=>{r in u||n.push(r)}),Object.keys(l).forEach(r=>{!(r in u)&&!n.includes(r)&&n.push(r)}),n.length>0?n:!0}function Ut(t){return t.length===0?"":t.length===1?`Missing required field: ${t[0]}`:`Missing required fields: ${t.join(", ")}`}const tp={class:"space-y-4"},op=se({__name:"PromptTemplate",props:{promptText:{},beforeTool:{},afterTool:{},requiredSchema:{},currentPromptName:{}},emits:["update:promptText","update:beforeTool","update:afterTool"],setup(t,{emit:i}){const n=t,u=i,l=v([]),c=v(!1),r=h=>h.type==="text"?{type:"string",value:h.content||""}:h.type==="include"?{type:"prompt",id:h.prompt||"",label:h.prompt||""}:h.type==="string"?{type:"string",value:h.value||""}:h.type==="prompt"?{type:"prompt",id:h.id||"",label:h.label||h.id||""}:h.type==="variable"?{type:"variable",value:h.value||"",label:h.label||h.value||""}:{type:"string",value:""},p=K(()=>{if(!n.promptText)return[{type:"string",value:""}];let h=[];try{const g=JSON.parse(n.promptText);Array.isArray(g)?h=g.map(r):h=[{type:"string",value:n.promptText}]}catch{h=[{type:"string",value:n.promptText}]}const $=n.requiredSchema?JSON.parse(n.requiredSchema):{};return h.map(g=>{if(g.type==="prompt"&&g.schema){const m=Dt($,g.schema),w=m===!0,k=w?[]:m;return{...g,meta:{isValid:w,missingFields:k,validationMessage:w?"":Ut(k)}}}return g})}),f=K(()=>{try{const h=JSON.parse(n.requiredSchema);if(h.properties&&typeof h.properties=="object")return Object.keys(h.properties)}catch{return[]}return[]}),b=async h=>{c.value=!0;try{const $=new URLSearchParams;h&&$.set("search",h);const g=await fetch(ae(`/api/prompts${$.toString()?"?"+$.toString():""}`));if(g.ok){const m=await g.json();l.value=m.prompts||[]}}catch($){console.error("Error fetching prompts:",$)}finally{c.value=!1}},s=async h=>{const $=[];return f.value.forEach(g=>{(!h||g.toLowerCase().includes(h.toLowerCase()))&&$.push({type:"variable",value:g,label:g,description:"Schema property"})}),h!==void 0&&await b(h),l.value.forEach(g=>{if(!(n.currentPromptName&&g.name===n.currentPromptName)&&(!h||g.name.toLowerCase().includes(h.toLowerCase()))){const m=n.requiredSchema?JSON.parse(n.requiredSchema):{},w=Dt(m,g.required_schema),k=w===!0,O=k?[]:w;$.push({type:"prompt",id:g.name,label:g.name,description:g.tool_description||"Available prompt",schema:g.required_schema,meta:{isValid:k,missingFields:O,validationMessage:k?"":Ut(O)}})}}),$},d=h=>{const $=h.map(g=>{const{type:m,value:w,label:k,id:O,schema:D}=g;return m==="string"?{type:m,value:w||""}:m==="variable"?{type:m,value:w||"",label:k}:m==="prompt"?{type:m,id:O||"",label:k,schema:D}:g});u("update:promptText",JSON.stringify($))};return xe(()=>{b()}),(h,$)=>(o(),a("div",tp,[e("div",null,[$[0]||($[0]=e("label",{class:"block text-sm font-medium mb-2"},"Prompt Template",-1)),$[1]||($[1]=e("p",{class:"text-sm text-neutral-600 dark:text-neutral-400 mb-2"}," Type @ to insert schema properties or other prompts ",-1)),E(ao,{"model-value":p.value,"onUpdate:modelValue":d,search:s,placeholder:"Enter your prompt template... Type @ to insert variables or prompts"},null,8,["model-value"])])]))}}),lp={class:"space-y-3"},ap={class:"space-y-2 pl-4 border-l-2 border-accent-200 dark:border-accent-700"},sp={class:"space-y-1"},np={class:"space-y-2 pl-4 border-l-2 border-neutral-200 dark:border-neutral-700"},rp=se({__name:"PromptToolOptions",props:{toolName:{},toolConfig:{},disabled:{type:Boolean}},emits:["update:option"],setup(t,{emit:i}){const n=t,u=i,l=v(null),c=v(!0),r=K(()=>l.value?.properties?Object.entries(l.value.properties).map(([b,s])=>({value:b,label:b,description:s.description||s.type||""})):[]),p=async()=>{try{const b=await fetch(ae(`/api/prompts/${encodeURIComponent(n.toolName)}`));if(b.ok){const s=await b.json();s?.prompt?.required_schema&&(l.value=s.prompt.required_schema)}}catch(b){console.error("Error fetching prompt schema:",b)}finally{c.value=!1}};xe(()=>{p()});const f=(b,s)=>{u("update:option",b,s)};return(b,s)=>(o(),a("div",lp,[e("div",ap,[s[6]||(s[6]=e("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Initialization Options: ",-1)),e("div",sp,[s[4]||(s[4]=e("label",{class:"block text-xs font-medium text-neutral-700 dark:text-neutral-300"}," User message property ",-1)),E(he,{"model-value":t.toolConfig.init_user_message_property||"","onUpdate:modelValue":s[0]||(s[0]=d=>f("init_user_message_property",d||null)),placeholder:"Don't inject a user message",options:r.value,disabled:t.disabled||c.value||r.value.length===0,loading:c.value},null,8,["model-value","options","disabled","loading"]),s[5]||(s[5]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"}," Select which argument property should be used as the most recent user message for this sub-prompt. If not set no additional user message will be injected. ",-1))])]),e("div",np,[s[7]||(s[7]=e("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Sub-Prompt Response Options: ",-1)),E(Te,{"model-value":t.toolConfig.include_text_response,"onUpdate:modelValue":s[1]||(s[1]=d=>f("include_text_response",d)),label:"Include text response","help-text":"Include the final text content from the sub-prompt",disabled:t.disabled},null,8,["model-value","disabled"]),E(Te,{"model-value":t.toolConfig.include_tool_calls,"onUpdate:modelValue":s[2]||(s[2]=d=>f("include_tool_calls",d)),label:"Include tool calls and responses","help-text":"Include tool calls executed by the sub-prompt and their responses",disabled:t.disabled},null,8,["model-value","disabled"]),E(Te,{"model-value":t.toolConfig.include_errors,"onUpdate:modelValue":s[3]||(s[3]=d=>f("include_errors",d)),label:"Include errors","help-text":"Include error information if the sub-prompt fails",disabled:t.disabled},null,8,["model-value","disabled"])])]))}});async function qe(t,i={}){const n=localStorage.getItem("auth_token"),u={"Content-Type":"application/json",...i.headers};n&&(u.Authorization=`Bearer ${n}`);const l=t.startsWith("/")?t:`/${t}`,c=await fetch(ae(`/api${l}`),{...i,headers:u});if(c.status===401)throw localStorage.removeItem("auth_token"),window.location.href=ae("/login"),new Error("Unauthorized");return c}const ip={class:"space-y-4"},dp={class:"block text-sm font-medium mb-2"},up={key:0,class:"text-red-500"},cp={class:"flex items-start justify-between"},pp={class:"flex items-center gap-2 flex-1"},mp={class:"flex-1"},vp={class:"font-medium text-sm"},fp={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-1"},hp=["onClick","disabled","aria-label"],gp={key:1,class:"text-xs text-red-500 dark:text-red-400 mt-1"},bp={key:0,class:"text-center py-8 text-sm text-neutral-500 dark:text-neutral-400 border border-dashed border-neutral-300 dark:border-neutral-600 rounded-lg"},xp=se({__name:"ToolSelectorWithOptions",props:Ne({label:{default:"Available Tools"},placeholder:{default:"Select a tool"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const i=Je(t,"modelValue"),n=v([]),u=v(!1),l=v();Ht(async()=>{l.value,await ge(),l.value&&i.value.length>0&&await Wt({parent:l,values:i,dragHandle:".drag-handle"})});const c=K(()=>{const d=new Set(i.value.map(h=>h.name));return n.value.filter(h=>!d.has(h.name)).map(h=>{let $=h.name;return h.type==="prompt"?$=`${h.name} (prompt)`:h.type==="mcp"&&($=`${h.name} (mcp)`),{value:h.name,label:$,description:h.description}})}),r=async()=>{u.value=!0;try{const d=await qe("/tools");if(d.ok){const h=await d.json();n.value=Object.entries(h).map(([$,g])=>({name:$,description:g.description||"",type:g.type,model:g.model}))}}catch(d){console.error("Error fetching tools:",d)}finally{u.value=!1}},p=d=>{d&&(i.value.find(h=>h.name===d)||(i.value=[...i.value,{name:d,include_text_response:!0,include_tool_calls:!0,include_errors:!0,init_user_message_property:null}]))},f=d=>{i.value=i.value.filter(h=>h.name!==d)},b=d=>n.value.find(h=>h.name===d),s=(d,h,$)=>{i.value=i.value.map(g=>g.name===d?{...g,[h]:$}:g)};return xe(()=>{r()}),(d,h)=>(o(),a("div",ip,[e("div",null,[e("label",dp,[ye(C(t.label)+" ",1),t.required?(o(),a("span",up,"*")):L("",!0)]),i.value.length>0?(o(),a("div",{key:0,class:"space-y-3 mb-4",ref_key:"dragAreaRef",ref:l},[(o(!0),a(pe,null,fe(i.value,$=>(o(),a("div",{key:$.name,class:"border border-neutral-300 dark:border-neutral-600 rounded-lg p-4"},[e("div",cp,[e("div",pp,[h[0]||(h[0]=e("div",{class:"drag-handle cursor-move text-neutral-400 hover:text-neutral-600 dark:text-neutral-600 dark:hover:text-neutral-400"},[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8h16M4 16h16"})])],-1)),e("div",mp,[e("h4",vp,C($.name),1),b($.name)?.description?(o(),a("p",fp,C(b($.name)?.description),1)):L("",!0)])]),e("button",{onClick:g=>f($.name),type:"button",disabled:t.disabled,class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors text-neutral-500 hover:text-red-500","aria-label":`Remove ${$.name}`},[...h[1]||(h[1]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,hp)]),b($.name)?.type==="prompt"?(o(),ee(rp,{key:0,"tool-name":$.name,"tool-config":$,disabled:t.disabled,"onUpdate:option":(g,m)=>s($.name,g,m)},null,8,["tool-name","tool-config","disabled","onUpdate:option"])):L("",!0)]))),128))],512)):L("",!0),E(he,{"model-value":"","onUpdate:modelValue":p,placeholder:i.value.length>0?"Add another tool...":t.placeholder,"search-placeholder":"Search tools...",options:c.value,disabled:t.disabled||u.value||c.value.length===0,loading:u.value},null,8,["placeholder","options","disabled","loading"]),t.error?(o(),a("p",gp,C(t.error),1)):L("",!0)]),i.value.length===0&&!u.value&&c.value.length===0?(o(),a("div",bp," No tools available. Create tools in your agentbuilder/tools directory. ")):L("",!0)]))}}),yp={class:"space-y-2"},kp={key:0,class:"space-y-2"},wp={key:0,class:"block text-sm font-medium"},_p={key:0,class:"text-red-500"},$p=["src","alt"],Cp={class:"flex-1 text-sm"},Vp={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 ml-1"},Sp=["onClick","aria-label"],Tp={key:1,class:"text-xs text-red-500 dark:text-red-400"},ct=se({__name:"MultipleSelectionsInput",props:Ne({label:{},placeholder:{default:"Select an option"},searchPlaceholder:{default:"Search..."},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},options:{},addLabel:{default:"Add another"},loading:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:Ne(["removeItem"],["update:modelValue"]),setup(t,{emit:i}){const n=t,u=i,l=Je(t,"modelValue"),c=v();Ht(async()=>{c.value,await ge(),await Wt({parent:c,values:l,dragHandle:".drag-handle"})});const r=K(()=>Array.isArray(l.value)?l.value.length>0&&typeof l.value[0]=="object"?l.value:l.value.map(s=>{const d=n.options.find(h=>h.value===s);return{id:s,label:d?.label||s,description:d?.description,icon:d?.icon}}):[]),p=K(()=>{const s=r.value.map(d=>d.id);return n.options.filter(d=>!s.includes(d.value))}),f=s=>{if(!s)return;const d=n.options.find(h=>h.value===s);if(d)if(l.value.length===0||typeof l.value[0]=="string")l.value=[...l.value,s];else{const h={id:s,label:d.label,description:d.description,icon:d.icon};l.value=[...l.value,h]}},b=s=>{typeof l.value[0]=="string"?l.value=l.value.filter(d=>d!==s):l.value=l.value.filter(d=>d.id!==s),u("removeItem",s)};return(s,d)=>(o(),a("div",yp,[r.value.length>0?(o(),a("div",kp,[t.label?(o(),a("label",wp,[ye(C(t.label)+" ",1),t.required?(o(),a("span",_p,"*")):L("",!0)])):L("",!0),e("div",{class:"space-y-1",ref_key:"dragAreaRef",ref:c},[(o(!0),a(pe,null,fe(r.value,h=>(o(),a("div",{key:h.id,class:le(["flex items-center gap-2 px-3 py-2 bg-neutral-50 dark:bg-neutral-900 rounded border","border-neutral-200 dark:border-neutral-800",t.disabled?"opacity-50":""])},[d[1]||(d[1]=e("div",{class:"drag-handle cursor-move text-neutral-400 hover:text-neutral-600 dark:text-neutral-600 dark:hover:text-neutral-400"},[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8h16M4 16h16"})])],-1)),h.icon?(o(),a("img",{key:0,src:h.icon,alt:h.label,class:"w-4 h-4 flex-shrink-0"},null,8,$p)):L("",!0),e("span",Cp,[ye(C(h.label)+" ",1),h.description?(o(),a("span",Vp," ("+C(h.description)+") ",1)):L("",!0)]),t.disabled?L("",!0):(o(),a("button",{key:1,onClick:$=>b(h.id),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors","aria-label":`Remove ${h.label}`},[...d[0]||(d[0]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,Sp))],2))),128))],512)])):L("",!0),E(he,{"model-value":"","onUpdate:modelValue":f,label:r.value.length>0?t.addLabel:t.label,options:p.value,placeholder:t.placeholder,"search-placeholder":t.searchPlaceholder,disabled:t.disabled||p.value.length===0,loading:t.loading},null,8,["label","options","placeholder","search-placeholder","disabled","loading"]),t.error?(o(),a("p",Tp,C(t.error),1)):L("",!0)]))}}),Mp={key:2,class:"text-xs text-red-500 dark:text-red-400 mt-1"},Lp=se({__name:"AgentSelectorInput",props:Ne({label:{default:"Handoff Agents"},placeholder:{default:"Select an agent"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},allowMultiple:{type:Boolean,default:!0},agentType:{default:"ai_human"}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const i=t,n=Je(t,"modelValue"),u=v([]),l=v(!1),c=K(()=>u.value.map(f=>({value:f.id,label:f.title,description:f.tool_description||`Handoff to ${f.title} agent`}))),r=async()=>{l.value=!0;try{const f=ae(`/api/agents${i.agentType?`?type=${i.agentType}`:""}`),b=await fetch(f);if(b.ok){const s=await b.json();u.value=s.agents||[]}}catch(f){console.error("Error fetching agents:",f)}finally{l.value=!1}},p=f=>{};return xe(()=>{r()}),ue(()=>i.allowMultiple,()=>{i.allowMultiple&&typeof n.value=="string"?n.value=n.value?[n.value]:[]:!i.allowMultiple&&Array.isArray(n.value)&&(n.value=n.value[0]||"")},{immediate:!0}),(f,b)=>(o(),a(pe,null,[t.allowMultiple?(o(),ee(ct,{key:0,modelValue:n.value,"onUpdate:modelValue":b[0]||(b[0]=s=>n.value=s),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search agents...",error:t.error,required:t.required,disabled:t.disabled,options:c.value,loading:l.value,"add-label":"Add another agent",onRemoveItem:p},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(o(),ee(he,{key:1,modelValue:n.value,"onUpdate:modelValue":b[1]||(b[1]=s=>n.value=s),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search agents...",options:c.value,disabled:t.disabled,loading:l.value},null,8,["modelValue","label","placeholder","options","disabled","loading"])),!t.allowMultiple&&t.error?(o(),a("p",Mp,C(t.error),1)):L("",!0)],64))}}),Ip={key:0,class:"min-h-[400px] flex items-center justify-center"},Ep={key:1,class:"space-y-6 pr-2 pb-4"},Ap={class:"space-y-4"},Pp={class:"space-y-4"},Op={class:"flex justify-between"},jp={class:"flex gap-2"},Dp=["disabled"],so=se({__name:"PromptModal",props:{modelValue:{type:Boolean},editPrompt:{},mode:{}},emits:["update:modelValue","save"],setup(t,{emit:i}){const n=t,u=i,l=K(()=>n.mode==="edit"),c=v(!1),r=K(()=>k.value.length===1),p=v(""),f=v(""),b=v(""),s=v(""),d=v({type:"object",properties:{},required:[],additionalProperties:!1}),h=v(""),$=v(!1),g=v(!1),m=v(""),w=v(""),k=v([]),O=v([]),D=v(!1),F=v("auto"),X=v(null),te=v(null),R=v(!1),j=v(!1),W=K({get:()=>X.value||"",set:V=>X.value=V||null}),B=K({get:()=>F.value,set:V=>F.value=V}),N=()=>{f.value="",p.value="",b.value="",s.value="",d.value={type:"object",properties:{},required:[],additionalProperties:!1},h.value="",$.value=!1,g.value=!1,m.value="",w.value="",k.value=[],O.value=[],D.value=!1,F.value="auto",X.value=null,te.value=null,R.value=!1,j.value=!1},U=async()=>{if(n.editPrompt?.id){c.value=!0;try{const V=await qe(`/prompts/${n.editPrompt.id}`);if(V.ok){const _=await V.json(),T=_.prompt||_;f.value=T.name||"",p.value=T.name||"",b.value=T.tool_description||"",s.value=T.model_id||"";let S=T.required_schema;if(typeof S=="string")try{S=JSON.parse(S)}catch{S=null}d.value=S||{type:"object",properties:{},required:[],additionalProperties:!1},h.value=T.prompt||"",$.value=T.include_chat||!1,g.value=T.include_past_tools||!1,m.value=T.before_tool||"",w.value=T.after_tool||"";const P=T.tools||[];k.value=P.map(re=>typeof re=="string"?{name:re,include_text_response:!0,include_tool_calls:!0,include_errors:!0,init_user_message_property:null}:re),O.value=T.prompts||T.handoff_agents||[],D.value=T.parallel_tool_calls||!1,F.value=T.tool_choice||"auto";const J=T.reasoning||{};X.value=J.effort||T.reasoning_effort||null,te.value=J.maxTokens||T.reasoning_max_tokens||null,R.value=J.exclude||T.reasoning_exclude||!1,j.value=T.include_reasoning||!1}}catch(V){console.error("Error loading prompt data:",V)}finally{c.value=!1}}},y=async()=>{const V=/^[a-z][a-z0-9_]*$/;if(!f.value||!V.test(f.value)){alert("Please enter a valid name (lowercase letters, numbers, and underscores only, must start with a letter)");return}if(!b.value){alert("Please enter a description");return}if(!s.value){alert("Please select a model");return}if(!h.value){alert("Please enter the prompt template");return}const _={name:f.value,tool_description:b.value,prompt:h.value,required_schema:d.value,model_id:s.value,include_chat:$.value,include_past_tools:g.value,before_tool:m.value||null,after_tool:w.value||null,parallel_tool_calls:D.value,tool_choice:F.value,tools:k.value,handoff_agents:O.value,reasoning_effort:X.value,reasoning_max_tokens:te.value,reasoning_exclude:R.value,include_reasoning:j.value};l.value&&n.editPrompt?.id&&(_.id=n.editPrompt.id,p.value&&p.value!==f.value&&(_.originalName=p.value)),u("save",_),N(),u("update:modelValue",!1)},x=()=>{N(),u("update:modelValue",!1)};return ue(()=>k.value.length,V=>{F.value==="function"&&V!==1&&(F.value="auto")}),ue(()=>n.modelValue,async V=>{V&&(l.value?(N(),await ge(),await U()):N())}),ue(()=>n.editPrompt,async V=>{V&&l.value&&n.modelValue&&(await ge(),await U())},{immediate:!0}),(V,_)=>(o(),ee(je,{"model-value":t.modelValue,"onUpdate:modelValue":_[17]||(_[17]=T=>V.$emit("update:modelValue",T)),title:l.value?"Edit Prompt":"Add Prompt",width:"max-w-4xl"},{footer:de(()=>[e("div",Op,[e("button",{onClick:x,type:"button",class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors"}," Cancel "),e("div",jp,[e("button",{onClick:y,type:"button",class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity",disabled:c.value},C(l.value?"Update Prompt":"Create Prompt"),9,Dp)])])]),default:de(()=>[c.value?(o(),a("div",Ip,[..._[18]||(_[18]=[e("span",{class:"text-neutral-500"},"Loading prompt data...",-1)])])):(o(),a("div",Ep,[e("div",null,[E(D0,{name:f.value,"onUpdate:name":_[0]||(_[0]=T=>f.value=T),"tool-description":b.value,"onUpdate:toolDescription":_[1]||(_[1]=T=>b.value=T)},null,8,["name","tool-description"])]),e("div",null,[E(t2,{modelValue:s.value,"onUpdate:modelValue":_[2]||(_[2]=T=>s.value=T)},null,8,["modelValue"])]),e("div",null,[E(lo,{modelValue:d.value,"onUpdate:modelValue":_[3]||(_[3]=T=>d.value=T),label:"Required Schema (Optional)"},null,8,["modelValue"])]),e("div",null,[E(op,{"prompt-text":h.value,"onUpdate:promptText":_[4]||(_[4]=T=>h.value=T),"before-tool":m.value,"onUpdate:beforeTool":_[5]||(_[5]=T=>m.value=T),"after-tool":w.value,"onUpdate:afterTool":_[6]||(_[6]=T=>w.value=T),"required-schema":JSON.stringify(d.value,null,2),"current-prompt-name":l.value?f.value:void 0},null,8,["prompt-text","before-tool","after-tool","required-schema","current-prompt-name"])]),e("div",null,[E(xp,{modelValue:k.value,"onUpdate:modelValue":_[7]||(_[7]=T=>k.value=T)},null,8,["modelValue"])]),e("div",Ap,[_[20]||(_[20]=e("h3",{class:"text-sm font-medium text-neutral-900 dark:text-neutral-100"}," Tool Configuration ",-1)),e("div",null,[E(Te,{modelValue:D.value,"onUpdate:modelValue":_[8]||(_[8]=T=>D.value=T),label:"Allow parallel tool calls","help-text":"Allow the model to call multiple tools simultaneously in a single turn"},null,8,["modelValue"])]),e("div",null,[E(he,{modelValue:B.value,"onUpdate:modelValue":_[9]||(_[9]=T=>B.value=T),label:"Tool Choice",options:[{value:"auto",label:"Auto",description:"Model decides"},{value:"none",label:"None",description:"No tools allowed"},{value:"required",label:"Required",description:"Must call a tool"},{value:"function",label:"Function",description:r.value?"Call specific tool":"Requires exactly 1 tool"}].filter(T=>T.value!=="function"||r.value),placeholder:"Select tool choice"},null,8,["modelValue","options"]),_[19]||(_[19]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Controls whether and how the model can call tools ",-1))])]),e("div",null,[E(Lp,{modelValue:O.value,"onUpdate:modelValue":_[10]||(_[10]=T=>O.value=T),"allow-multiple":!0,label:"Handoff Agents (Optional)",placeholder:"Select AI + Human agents to hand off to","agent-type":"ai_human"},null,8,["modelValue"]),_[21]||(_[21]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," AI + Human agents that this prompt can hand off conversations to. These will be exposed as tools. ",-1))]),e("div",Pp,[_[25]||(_[25]=e("h3",{class:"text-sm font-medium text-neutral-900 dark:text-neutral-100"}," Context & Reasoning Configuration ",-1)),e("div",null,[E(Te,{modelValue:$.value,"onUpdate:modelValue":_[11]||(_[11]=T=>$.value=T),label:"Include chat history","help-text":"Expose chat history to the LLM when this prompt is used as a full prompt (not a partial in another prompt)"},null,8,["modelValue"])]),e("div",null,[E(Te,{modelValue:g.value,"onUpdate:modelValue":_[12]||(_[12]=T=>g.value=T),label:"Include past tool calls","help-text":"Include prior tool call history in this prompt. Uncheck to remove past tool calls"},null,8,["modelValue"])]),e("div",null,[E(Te,{modelValue:j.value,"onUpdate:modelValue":_[13]||(_[13]=T=>j.value=T),label:"Include reasoning in message history","help-text":"When loading message history, include reasoning_details from previous responses. Required for multi-turn reasoning continuity."},null,8,["modelValue"])]),_[26]||(_[26]=e("hr",{class:"border-neutral-300 dark:border-neutral-600"},null,-1)),_[27]||(_[27]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"}," Configure extended reasoning for models like o1, o3, Gemini Thinking, and others. Reasoning is enabled automatically when either field is set. ",-1)),e("div",null,[E(he,{modelValue:W.value,"onUpdate:modelValue":_[14]||(_[14]=T=>W.value=T),label:"Reasoning Effort",options:[{value:"",label:"None",description:"Disabled"},{value:"low",label:"Low",description:"~20% of max_tokens"},{value:"medium",label:"Medium",description:"~50% of max_tokens"},{value:"high",label:"High",description:"~80% of max_tokens"}],placeholder:"Select reasoning effort"},null,8,["modelValue"]),_[22]||(_[22]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Controls reasoning capacity allocation. Supported by OpenAI o-series and Grok models. ",-1))]),e("div",null,[_[23]||(_[23]=e("label",{class:"block text-sm font-medium text-neutral-700 dark:text-neutral-300 mb-2"}," Max Reasoning Tokens ",-1)),Se(e("input",{"onUpdate:modelValue":_[15]||(_[15]=T=>te.value=T),type:"number",min:"1024",max:"32000",step:"1024",placeholder:"Leave empty to disable or use effort level",class:"w-full px-3 py-2 text-sm border border-neutral-300 dark:border-neutral-600 rounded bg-white dark:bg-neutral-800 text-neutral-900 dark:text-neutral-100 focus:ring-2 focus:ring-accent-500 focus:border-transparent"},null,512),[[Oe,te.value,void 0,{number:!0}]]),_[24]||(_[24]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Directly specify reasoning token limit (1024-32000). Supported by Anthropic, Gemini Thinking, and some Qwen models. ",-1))]),e("div",null,[E(Te,{modelValue:R.value,"onUpdate:modelValue":_[16]||(_[16]=T=>R.value=T),label:"Exclude reasoning from response","help-text":"Use reasoning internally but don't return it in the response (saves tokens and cost)"},null,8,["modelValue"])])])]))]),_:1},8,["model-value","title"]))}}),Up=se({__name:"PromptsView",setup(t){const i=et(),n=ze(),u=v(!1),l=v(null);ue(()=>n.query.refresh,()=>{n.query.refresh&&(l.value?.refresh(),i.replace({path:"/prompts",query:{}}))});const c=()=>{u.value=!0},r=f=>{i.push(`/prompts/${f.id}`)},p=async f=>{try{const b=await fetch(ae("/api/prompts"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(b.ok)u.value=!1,await new Promise(s=>setTimeout(s,100)),await l.value?.refresh();else{const s=await b.json();alert(s.error||"Failed to create prompt")}}catch(b){console.error("Error creating prompt:",b),alert("Failed to create prompt")}};return(f,b)=>(o(),ee(Ke,null,{default:de(()=>[e("div",{class:"flex justify-between items-center mb-6"},[b[1]||(b[1]=e("h1",{class:"text-3xl font-bold"},"Prompts",-1)),e("button",{onClick:c,class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Create Prompt ")]),b[2]||(b[2]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-6"}," Define and manage prompt templates for your agents. ",-1)),E(I0,{ref_key:"dataTableRef",ref:l,onAdd:c,onEdit:r},null,512),E(so,{modelValue:u.value,"onUpdate:modelValue":b[0]||(b[0]=s=>u.value=s),mode:"add",onSave:p},null,8,["modelValue"])]),_:1}))}}),Rp={class:"p-8"},Np={key:0,class:"flex items-center justify-center min-h-[400px]"},Bp={key:2,class:"flex items-center justify-center min-h-[400px]"},qp=se({__name:"PromptEditView",setup(t){const i=et(),n=ze(),u=v(!0),l=v(null),c=v(!0),r=async()=>{const b=n.params.id;if(!b){i.push("/prompts");return}c.value=!0;try{const s=await fetch(ae(`/api/prompts/${b}`));if(s.ok){const d=await s.json();l.value=d.prompt||d}else alert("Prompt not found"),i.push("/prompts")}catch(s){console.error("Error loading prompt:",s),alert("Failed to load prompt"),i.push("/prompts")}finally{c.value=!1}},p=async b=>{try{const{originalName:s,...d}=b,h=s||d.id,$=await fetch(ae(`/api/prompts/${h}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)});if($.ok)i.push({path:"/prompts",query:{refresh:Date.now().toString()}});else{const g=await $.json();alert(g.error||"Failed to update prompt")}}catch(s){console.error("Error updating prompt:",s),alert("Failed to update prompt")}},f=b=>{b||i.push("/prompts")};return xe(()=>{r()}),ue(u,b=>{b||i.push("/prompts")}),(b,s)=>(o(),a("div",Rp,[c.value?(o(),a("div",Np,[...s[1]||(s[1]=[e("span",{class:"text-neutral-500"},"Loading prompt...",-1)])])):l.value?(o(),ee(so,{key:1,modelValue:u.value,"onUpdate:modelValue":[s[0]||(s[0]=d=>u.value=d),f],mode:"edit","edit-prompt":l.value,onSave:p},null,8,["modelValue","edit-prompt"])):(o(),a("div",Bp,[...s[2]||(s[2]=[e("span",{class:"text-neutral-500"},"Prompt not found",-1)])]))]))}}),Fp={class:"border-2 border-black dark:border-neutral-300 rounded-lg overflow-hidden"},zp={key:0,class:"px-4 py-2 border-b-2 border-black dark:border-neutral-300 bg-neutral-50 dark:bg-neutral-900"},Hp={class:"flex items-center justify-between"},Wp={class:"text-sm font-medium"},Jp={class:"flex items-center gap-2"},Zp={key:1,class:"px-4 py-8 flex items-center justify-center"},Kp={key:2,class:"px-4 py-8 text-center text-neutral-500"},Gp={key:3,class:"divide-y divide-neutral-200 dark:divide-neutral-700"},Xp=["onClick"],Yp={class:"flex items-start gap-3"},Qp={class:"flex-shrink-0 mt-0.5"},e1=["checked","onClick"],t1={class:"flex-1 min-w-0"},o1={class:"flex items-center gap-2"},l1={class:"text-sm font-medium"},a1={key:0,class:"text-xs px-1.5 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded"},s1={class:"mt-1 text-xs text-neutral-600 dark:text-neutral-400 space-y-0.5"},n1={key:0},r1={key:0},i1={key:1},d1={key:2},u1=se({__name:"ExposedSelectList",props:{providers:{default:()=>[]},modelValue:{default:()=>[]},label:{},loading:{type:Boolean}},emits:["update:modelValue"],setup(t,{emit:i}){function n(s){if(s===0)return"$0.00";const d=Math.abs(s);let h;return d<1e-4?h=d.toExponential(3):d<.001||d<.01||d<.1?h=d.toFixed(4):d<1?h=d.toFixed(3):d<10||d<100?h=d.toFixed(2):d<1e3?h=d.toFixed(1):h=d.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:0}),h.includes(".")&&(h=h.replace(/\.?0+$/,""),!h.includes(".")&&d<100&&(h=d.toFixed(2))),s<0?`-$${h}`:`$${h}`}const u=t,l=i,c=s=>u.modelValue.includes(s),r=s=>{const d=[...u.modelValue],h=d.indexOf(s);h>-1?d.splice(h,1):d.push(s),l("update:modelValue",d)},p=()=>{l("update:modelValue",u.providers.map(s=>s.id))},f=()=>{l("update:modelValue",[])},b=K(()=>u.providers.length>0&&u.modelValue.length===u.providers.length);return K(()=>u.modelValue.length>0&&u.modelValue.length<u.providers.length),(s,d)=>(o(),a("div",Fp,[t.label?(o(),a("div",zp,[e("div",Hp,[e("span",Wp,C(t.label),1),e("div",Jp,[e("button",{type:"button",onClick:d[0]||(d[0]=h=>b.value?f():p()),class:"text-xs px-2 py-1 border border-neutral-400 dark:border-neutral-600 rounded hover:bg-neutral-100 dark:hover:bg-neutral-800"},C(b.value?"Deselect All":"Select All"),1)])])])):L("",!0),t.loading?(o(),a("div",Zp,[...d[1]||(d[1]=[e("div",{class:"flex items-center gap-2 text-neutral-500"},[e("svg",{class:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]),e("span",null,"Loading providers...")],-1)])])):t.providers.length===0?(o(),a("div",Kp," No providers available ")):(o(),a("div",Gp,[(o(!0),a(pe,null,fe(t.providers,h=>(o(),a("div",{key:h.id,class:"px-4 py-3 hover:bg-neutral-50 dark:hover:bg-neutral-900 cursor-pointer",onClick:$=>r(h.id)},[e("div",Yp,[e("div",Qp,[e("input",{type:"checkbox",checked:c(h.id),onClick:we($=>r(h.id),["stop"]),class:"w-4 h-4 border-2 border-black dark:border-neutral-300 rounded focus:ring-2 focus:ring-black dark:focus:ring-white"},null,8,e1)]),e("div",t1,[e("div",o1,[e("span",l1,C(h.name),1),h.quantization?(o(),a("span",a1,C(h.quantization),1)):L("",!0)]),e("div",s1,[e("div",null,C(n(h.pricing.prompt*1e6))+"/M input • "+C(n(h.pricing.completion*1e6))+"/M output ",1),h.maxPromptTokens||h.maxCompletionTokens?(o(),a("div",n1,[h.maxPromptTokens?(o(),a("span",r1," Max prompt: "+C(h.maxPromptTokens.toLocaleString())+" tokens ",1)):L("",!0),h.maxPromptTokens&&h.maxCompletionTokens?(o(),a("span",i1," • ")):L("",!0),h.maxCompletionTokens?(o(),a("span",d1," Max completion: "+C(h.maxCompletionTokens.toLocaleString())+" tokens ",1)):L("",!0)])):L("",!0)])])])],8,Xp))),128))]))]))}}),c1={key:2,class:"text-xs text-red-500 dark:text-red-400 mt-1"},p1=se({__name:"ModelSelectorInput",props:Ne({label:{},placeholder:{default:"Select a model"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},allowMultiple:{type:Boolean,default:!1}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const i=t,n=Je(t,"modelValue"),u=v([]),l=v(!1),c=K(()=>u.value.map(f=>({value:f.id,label:f.name,description:f.provider_id||f.provider,icon:Qe(f.model||f.name,f.provider_id||f.provider)}))),r=async()=>{l.value=!0;try{const f=await fetch(ae("/api/models"));if(f.ok){const b=await f.json();u.value=b.models||[]}}catch(f){console.error("Error fetching models:",f)}finally{l.value=!1}},p=f=>{};return xe(()=>{r()}),ue(()=>i.allowMultiple,()=>{i.allowMultiple&&typeof n.value=="string"?n.value=n.value?[n.value]:[]:!i.allowMultiple&&Array.isArray(n.value)&&(n.value=n.value[0]||"")}),(f,b)=>(o(),a(pe,null,[t.allowMultiple?(o(),ee(ct,{key:0,modelValue:n.value,"onUpdate:modelValue":b[0]||(b[0]=s=>n.value=s),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search models...",error:t.error,required:t.required,disabled:t.disabled,options:c.value,loading:l.value,"add-label":"Add another model",onRemoveItem:p},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(o(),ee(he,{key:1,modelValue:n.value,"onUpdate:modelValue":b[1]||(b[1]=s=>n.value=s),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search models...",options:c.value,disabled:t.disabled,loading:l.value},null,8,["modelValue","label","placeholder","options","disabled","loading"])),!t.allowMultiple&&t.error?(o(),a("p",c1,C(t.error),1)):L("",!0)],64))}}),m1={class:"space-y-4"},v1={key:0},f1={key:1},h1=["value"],g1={key:0,class:"mt-1 text-xs text-red-500"},b1={key:1,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},x1={class:"px-1 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded"},y1={key:2,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},k1={key:2},w1={key:3},_1={class:"flex justify-end gap-2"},$1=["disabled"],C1=se({__name:"ModelModal",props:{modelValue:{type:Boolean},editModel:{},mode:{default:"add"}},emits:["update:modelValue","save"],setup(t,{emit:i}){const n=t,u=i,l=v([]),c=v(""),r=v(""),p=v([]),f=v(!1),b=v(!1),s=v([]),d=v([]),h=v(!1),$=v([]),g=K(()=>n.mode==="edit"),m=v(""),w=v(""),k=v(""),O=S=>{let P=S.replace(/[^a-zA-Z0-9\s_-]/g,"");return P=P.trim().toLowerCase().replace(/[\s-]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),P?/^[a-z][a-z0-9_]*$/.test(P)?k.value="":k.value="Name must start with a letter and contain only lowercase letters, numbers, and underscores":k.value="Name is required",P},D=S=>{const P=S.target.value;w.value=O(P)},F=v(!1),X=v(null),te=K(()=>l.value.filter(S=>S.hasApiKey).map(S=>({value:S.name,label:S.name,description:S.sdk==="openai-sdk"?"OpenAI SDK":S.sdk==="openrouter"?"OpenRouter":S.sdk,icon:ut(S.sdk)}))),R=K(()=>p.value.map(S=>({...S,icon:S.iconId?ut(S.iconId):void 0}))),j=K(()=>!g.value||!X.value||F.value?!1:w.value!==X.value.name||c.value!==X.value.provider||r.value!==X.value.model||JSON.stringify(d.value.sort())!==JSON.stringify(X.value.endpoints.sort())||JSON.stringify($.value)!==JSON.stringify(X.value.fallbacks)),W=K(()=>l.value.find(P=>P.name===c.value)?.sdk==="openrouter"),B=async()=>{f.value=!0;try{const S=await fetch(ae("/api/providers"));if(S.ok){const P=await S.json();l.value=P.providers||[]}}catch(S){console.error("Error fetching providers:",S)}finally{f.value=!1}},N=async()=>{if(!c.value){p.value=[];return}b.value=!0;try{const S=await fetch(ae("/api/models/available"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:c.value})});if(S.ok){const P=await S.json();p.value=P.models||[]}else{const P=await S.json();console.error("Error fetching models:",P),p.value=[],alert(P.error||"Failed to fetch available models")}}catch(S){console.error("Error fetching models:",S),p.value=[]}finally{b.value=!1}},U=()=>{w.value="",m.value="",c.value="",r.value="",p.value=[],$.value=[],s.value=[],d.value=[],X.value=null,F.value=!1},y=async()=>{if(n.editModel){F.value=!0;try{await B(),w.value=n.editModel.name||"",m.value=n.editModel.name||"",c.value=n.editModel.provider_id||n.editModel.provider,await N(),r.value=n.editModel.model,await V(),n.editModel.included_providers&&n.editModel.included_providers.length>0&&(d.value=n.editModel.included_providers),await x(),X.value={name:w.value,provider:c.value,model:r.value,endpoints:[...d.value],fallbacks:[...$.value]}}finally{F.value=!1}}};ue(()=>n.modelValue,async S=>{S?g.value&&n.editModel?await y():(await B(),U()):U()});const x=async()=>{if(n.editModel?.id){if(n.editModel.fallbacks&&Array.isArray(n.editModel.fallbacks)){$.value=n.editModel.fallbacks.map(S=>typeof S=="string"?S:S.id);return}try{const S=await fetch(ae(`/api/models/${n.editModel.id}/fallbacks`));if(S.ok){const P=await S.json();$.value=P.fallbacks.map(J=>J.fallback_model_id)}}catch(S){console.error("Error loading fallbacks:",S)}}};ue(c,async(S,P)=>{F.value||g.value&&!P&&S===(n.editModel?.provider_id||n.editModel?.provider)||(r.value="",s.value=[],d.value=[],c.value&&await N())});const V=async()=>{if(!r.value||!c.value){s.value=[];return}const S=l.value.find(J=>J.name===c.value);if(!S||S.sdk!=="openrouter"){s.value=[];return}const P=R.value.find(J=>J.value===r.value);if(!P?.slug){console.error("Model slug not found"),s.value=[];return}h.value=!0;try{const J=await fetch(ae("/api/models/endpoints"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:c.value,modelSlug:P.slug})});if(J.ok){const re=await J.json();s.value=re.endpoints||[],g.value||(d.value=s.value.map(A=>A.id))}else{const re=await J.json();console.error("Error fetching endpoints:",re),s.value=[]}}catch(J){console.error("Error fetching endpoints:",J),s.value=[]}finally{h.value=!1}};ue(r,async(S,P)=>{F.value||g.value&&!P&&S===n.editModel?.model||(r.value?(await V(),P&&S!==P&&(d.value=s.value.map(J=>J.id))):(s.value=[],d.value=[]))});const _=()=>{if(!c.value||!r.value){alert("Please select a provider and model");return}if(!w.value){alert("Please enter a name for the model");return}if(k.value){alert(k.value);return}const S=W.value?d.value:[],P={name:w.value,model:r.value,provider:c.value,included_providers:S,fallbacks:$.value};g.value&&n.editModel?.id&&(P.id=n.editModel.id,m.value&&m.value!==w.value&&(P.originalName=m.value)),u("save",P)},T=()=>{U(),u("update:modelValue",!1)};return(S,P)=>(o(),ee(je,{"model-value":t.modelValue,"onUpdate:modelValue":P[4]||(P[4]=J=>S.$emit("update:modelValue",J)),title:g.value?"Edit Model":"Add Model",width:"max-w-2xl","min-height":"min-h-[36rem]","has-changes":j.value},{footer:de(()=>[e("div",_1,[e("button",{onClick:T,type:"button",class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors"}," Cancel "),e("button",{onClick:_,type:"button",class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity",disabled:!c.value||!r.value},C(g.value?"Update Model":"Add Model"),9,$1)])]),default:de(()=>[e("div",m1,[E(he,{modelValue:c.value,"onUpdate:modelValue":P[0]||(P[0]=J=>c.value=J),options:te.value,label:"Provider",placeholder:"Select a provider",disabled:f.value||g.value&&!!n.editModel},null,8,["modelValue","options","disabled"]),c.value?(o(),a("div",v1,[E(he,{modelValue:r.value,"onUpdate:modelValue":P[1]||(P[1]=J=>r.value=J),options:R.value,label:"Model",placeholder:"Select a model","search-placeholder":"Search models...",loading:b.value},null,8,["modelValue","options","loading"])])):L("",!0),r.value?(o(),a("div",f1,[P[6]||(P[6]=e("label",{class:"block text-sm font-medium mb-2"},"Name",-1)),e("input",{value:w.value,onInput:D,type:"text",class:le(["w-full px-3 py-2 text-sm border rounded bg-white dark:bg-neutral-800 text-neutral-900 dark:text-neutral-100 focus:ring-2 focus:ring-accent-500 focus:border-transparent",k.value?"border-red-500":"border-neutral-300 dark:border-neutral-600"]),placeholder:"e.g., coding_model, planning_model, fast_response"},null,42,h1),k.value?(o(),a("p",g1,C(k.value),1)):w.value?(o(),a("p",b1,[P[5]||(P[5]=ye(" Will be saved as: ",-1)),e("code",x1,C(w.value),1)])):(o(),a("p",y1," A descriptive name for this model (e.g., coding_model, planning_model). This becomes the filename and reference ID. "))])):L("",!0),r.value&&W.value?(o(),a("div",k1,[P[7]||(P[7]=e("label",{class:"block text-sm font-medium mb-2"}," Available Providers ",-1)),E(u1,{modelValue:d.value,"onUpdate:modelValue":P[2]||(P[2]=J=>d.value=J),providers:s.value,loading:h.value},null,8,["modelValue","providers","loading"]),P[8]||(P[8]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Select which providers can be used for this model ",-1))])):L("",!0),r.value?(o(),a("div",w1,[E(p1,{modelValue:$.value,"onUpdate:modelValue":P[3]||(P[3]=J=>$.value=J),label:"Fallback Models",placeholder:"Add fallback model...","allow-multiple":!0},null,8,["modelValue"]),P[9]||(P[9]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Fallback models will be used in order if the primary model fails ",-1))])):L("",!0)])]),_:1},8,["model-value","title","has-changes"]))}}),V1={class:"flex justify-between items-center mb-6"},S1={class:"flex items-center gap-2"},T1=["src","alt"],M1={class:"text-sm text-neutral-600 dark:text-neutral-400 font-mono"},L1={key:0,class:"space-y-0.5"},I1=["title"],E1={class:"shrink-0 font-mono pr-2"},A1=["src","alt"],P1={class:"truncate"},O1={key:1,class:"text-neutral-400 dark:text-neutral-600 text-sm"},j1=se({__name:"ModelsView",setup(t){const i=v(!1),n=v([]),u=v(!1),l=v(null),c=v("add"),r=[{key:"name",label:"Name",width:"w-1/4"},{key:"model",label:"Model",width:"w-1/4"},{key:"provider",label:"Provider",width:"w-1/4"},{key:"fallbacks",label:"Fallbacks",width:"w-1/4"}],p=[{icon:"edit",label:"Edit",handler:d=>{l.value=d,c.value="edit",i.value=!0}},{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this model? This action cannot be undone.",handler:async d=>{await s(d.id)}}],f=async()=>{u.value=!0;try{const d=await fetch(ae("/api/models"));if(!d.ok)throw new Error("Failed to fetch models");const h=await d.json();n.value=h.models||[]}catch(d){console.error("Error fetching models:",d),n.value=[]}finally{u.value=!1}},b=async d=>{try{if(l.value){const{originalName:h,...$}=d,g=h||l.value.id,m=await fetch(ae(`/api/models/${g}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify($)});if(!m.ok){const w=await m.json();alert(w.error||"Failed to update model");return}}else{const h=await fetch(ae("/api/models"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)});if(!h.ok){const $=await h.json();alert($.error||"Failed to add model");return}}await f(),i.value=!1,l.value=null,c.value="add"}catch(h){console.error("Error saving model:",h),alert("Failed to save model")}},s=async d=>{try{const h=await fetch(ae(`/api/models/${d}`),{method:"DELETE"});if(!h.ok){const $=await h.json();alert($.error||"Failed to delete model");return}await f()}catch(h){console.error("Error deleting model:",h),alert("Failed to delete model")}};return xe(()=>{f()}),(d,h)=>(o(),ee(Ke,null,{default:de(()=>[e("div",V1,[h[3]||(h[3]=e("h1",{class:"text-3xl font-bold"},"Models",-1)),e("button",{onClick:h[0]||(h[0]=()=>{c.value="add",l.value=null,i.value=!0}),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Add Model ")]),h[4]||(h[4]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-8"}," Configure AI models from your connected providers. Models define which AI capabilities are available to your agents. ",-1)),E(Fe,{columns:r,data:n.value,actions:p,loading:u.value,"empty-message":"No models configured yet. Add your first model to get started."},{"cell-name":de(({value:$,row:g})=>[e("div",S1,[Z(Qe)(g.model,g.provider)?(o(),a("img",{key:0,src:Z(Qe)(g.model,g.provider),class:"w-5 h-5 shrink-0",alt:g.provider},null,8,T1)):L("",!0),e("span",null,C($),1)])]),"cell-model":de(({value:$})=>[e("span",M1,C($||"—"),1)]),"cell-fallbacks":de(({value:$})=>[$&&$.length>0?(o(),a("div",L1,[(o(!0),a(pe,null,fe($,(g,m)=>(o(),a("div",{key:g.id,class:"text-sm text-neutral-600 dark:text-neutral-400 flex items-center",title:g.name},[e("span",E1,C(m===$.length-1?"└─":"├─"),1),Z(Qe)(g.model,g.provider)?(o(),a("img",{key:0,src:Z(Qe)(g.model,g.provider),class:"w-4 h-4 shrink-0 mr-1.5",alt:g.provider},null,8,A1)):L("",!0),e("span",P1,C(g.name),1)],8,I1))),128))])):(o(),a("span",O1," None "))]),_:1},8,["data","loading"]),E(C1,{modelValue:i.value,"onUpdate:modelValue":[h[1]||(h[1]=$=>i.value=$),h[2]||(h[2]=$=>{i.value=$,$||(l.value=null,c.value="add")})],"edit-model":l.value,mode:c.value,onSave:b},null,8,["modelValue","edit-model","mode"])]),_:1}))}}),D1={class:"space-y-4"},U1={class:"space-y-1"},R1={class:"relative"},N1={key:0,class:"flex items-center gap-2"},B1=["src","alt"],q1={key:1,class:"text-neutral-500"},F1={key:0,class:"absolute z-10 w-full mt-1 bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded shadow-lg"},z1=["onClick"],H1=["src","alt"],W1={key:0,class:"text-xs text-red-500 dark:text-red-400"},J1=se({__name:"AddProviderModal",props:{modelValue:{type:Boolean}},emits:["update:modelValue","save"],setup(t,{emit:i}){const n=i,u=v({name:"",type:"",apiKey:"",baseUrl:""}),l=[{value:"openai",label:"OpenAI",icon:wt,sdk:"openai-sdk"},{value:"openrouter",label:"OpenRouter",icon:oo,sdk:"openrouter"}],c=v(!1),r=K(()=>l.find(g=>g.value===u.value.type)),p=()=>{setTimeout(()=>{c.value=!1},200)},f=v({});ue(()=>u.value.type,g=>{if(g&&!u.value.name){const m=l.find(w=>w.value===g);m&&(u.value.name=m.label)}});const b=K(()=>u.value.type==="custom"||u.value.type==="openai"),s=()=>{f.value={};let g=!0;return u.value.name||(f.value.name="Provider name is required",g=!1),u.value.type||(f.value.type="Provider type is required",g=!1),u.value.apiKey||(f.value.apiKey="API key is required",g=!1),b.value&&u.value.type==="custom"&&!u.value.baseUrl&&(f.value.baseUrl="Base URL is required for custom providers",g=!1),g},d=()=>{s()&&(n("save",{...u.value}),$(),n("update:modelValue",!1))},h=()=>{$(),n("update:modelValue",!1)},$=()=>{u.value={name:"",type:"",apiKey:""},f.value={}};return(g,m)=>(o(),ee(je,{"model-value":t.modelValue,"onUpdate:modelValue":m[4]||(m[4]=w=>g.$emit("update:modelValue",w)),title:"Add Provider",width:"max-w-md"},{footer:de(()=>[e("div",{class:"flex gap-2 justify-end"},[e("button",{onClick:h,class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors"}," Cancel "),e("button",{onClick:d,class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Add Provider ")])]),default:de(()=>[e("div",D1,[e("div",U1,[m[6]||(m[6]=e("label",{class:"block text-sm font-medium"},[ye(" Provider Type "),e("span",{class:"text-red-500"},"*")],-1)),e("div",R1,[e("button",{type:"button",onClick:m[0]||(m[0]=w=>c.value=!c.value),onBlur:p,class:le(["w-full px-3 py-2 bg-white dark:bg-black border rounded font-mono text-sm text-left focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white transition-colors",[f.value.type?"border-red-500 dark:border-red-400":"border-black dark:border-neutral-300"]])},[r.value?(o(),a("div",N1,[e("img",{src:r.value.icon,alt:r.value.label,class:"w-5 h-5"},null,8,B1),e("span",null,C(r.value.label),1)])):(o(),a("span",q1,"Select a provider")),m[5]||(m[5]=e("div",{class:"absolute inset-y-0 right-0 flex items-center px-2 pointer-events-none"},[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 9l-7 7-7-7"})])],-1))],34),c.value?(o(),a("div",F1,[(o(),a(pe,null,fe(l,w=>e("button",{key:w.value,type:"button",onClick:k=>{u.value.type=w.value,c.value=!1},class:"w-full px-3 py-2 text-left hover:bg-black/5 dark:hover:bg-white/10 transition-colors flex items-center gap-2"},[e("img",{src:w.icon,alt:w.label,class:"w-5 h-5"},null,8,H1),e("span",null,C(w.label),1)],8,z1)),64))])):L("",!0)]),f.value.type?(o(),a("p",W1,C(f.value.type),1)):L("",!0)]),E(Ce,{modelValue:u.value.name,"onUpdate:modelValue":m[1]||(m[1]=w=>u.value.name=w),label:"Provider Name",placeholder:"e.g., My OpenAI Provider",error:f.value.name,required:""},null,8,["modelValue","error"]),E(Ce,{modelValue:u.value.apiKey,"onUpdate:modelValue":m[2]||(m[2]=w=>u.value.apiKey=w),label:"API Key",type:"password",placeholder:"sk-...",error:f.value.apiKey,required:""},null,8,["modelValue","error"]),b.value?(o(),ee(Ce,{key:0,modelValue:u.value.baseUrl,"onUpdate:modelValue":m[3]||(m[3]=w=>u.value.baseUrl=w),label:"Base URL",placeholder:"https://api.example.com",error:f.value.baseUrl,required:u.value.type==="custom"},null,8,["modelValue","error","required"])):L("",!0)])]),_:1},8,["model-value"]))}}),Z1={class:"flex justify-between items-center mb-6"},K1=se({__name:"ProvidersView",setup(t){const i=v(!1),n=v([]),u=v(!1),l=[{key:"name",label:"Name",width:"w-1/3"},{key:"sdk",label:"SDK Type",width:"w-1/3",formatter:b=>({"openai-sdk":"OpenAI SDK",openrouter:"OpenRouter",openai:"OpenAI"})[b]||b},{key:"hasApiKey",label:"API Key",width:"w-1/3",formatter:b=>b?"✓ Configured":"✗ Not configured"}],c=[{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this provider? This action cannot be undone.",handler:async b=>{await f(b.name)}}],r=async()=>{u.value=!0;try{const b=await fetch(ae("/api/providers"));if(!b.ok)throw new Error("Failed to fetch providers");const s=await b.json();n.value=s.providers||[]}catch(b){console.error("Error fetching providers:",b),n.value=[]}finally{u.value=!1}},p=async b=>{try{const s=await fetch(ae("/api/providers"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!s.ok){const d=await s.json();alert(d.error||"Failed to add provider");return}await r(),i.value=!1}catch(s){console.error("Error adding provider:",s),alert("Failed to add provider")}},f=async b=>{try{const s=await fetch(ae(`/api/providers/${encodeURIComponent(b)}`),{method:"DELETE"});if(!s.ok){const d=await s.json();d.modelCount?alert(`${d.error}
13
13
 
14
- This provider has ${d.modelCount} associated model(s).`):alert(d.error||"Failed to delete provider");return}await r()}catch(n){console.error("Error deleting provider:",n),alert("Failed to delete provider")}};return ye(()=>{r()}),(b,n)=>(o(),Q(ze,null,{default:de(()=>[e("div",am,[n[2]||(n[2]=e("h1",{class:"text-3xl font-bold"},"Providers",-1)),e("button",{onClick:n[0]||(n[0]=d=>i.value=!0),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Add Provider ")]),n[3]||(n[3]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-8"}," Manage API providers and authentication keys. All API keys are encrypted at rest. ",-1)),I(Ne,{columns:a,data:s.value,actions:u,loading:c.value,"empty-message":"No providers configured yet. Add your first provider to get started."},null,8,["data","loading"]),I(om,{modelValue:i.value,"onUpdate:modelValue":n[1]||(n[1]=d=>i.value=d),onSave:p},null,8,["modelValue"])]),_:1}))}}),sm={class:"json-viewer overflow-auto"},nm=["innerHTML"],rm=se({__name:"JsonViewer",props:{value:{}},setup(t){const i=t;function s(u){return u.replace(/"([^"\\]|\\.)*"/g,r=>`<span class="json-string">${c(r)}</span>`).replace(/\b(-?\d+\.?\d*)\b/g,'<span class="json-number">$1</span>').replace(/\b(true|false|null)\b/g,'<span class="json-boolean">$1</span>')}function c(u){return u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const a=z(()=>{try{const u=JSON.stringify(i.value,null,2);return s(u)}catch{return c(String(i.value))}});return(u,r)=>(o(),l("div",sm,[e("pre",{class:"p-4 text-sm font-mono leading-relaxed",innerHTML:a.value},null,8,nm)]))}}),im=Fe(rm,[["__scopeId","data-v-5118293b"]]),dm={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function um(t,i){return o(),l("svg",dm,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("circle",{cx:"12",cy:"12",r:"10"}),e("path",{d:"M12 16v-4m0-4h.01"})],-1)])])}const cm=$e({name:"lucide-info",render:um}),pm={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function mm(t,i){return o(),l("svg",pm,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m21.73 18l-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3M12 9v4m0 4h.01"},null,-1)])])}const Ot=$e({name:"lucide-triangle-alert",render:mm}),vm={class:"mb-6 p-4 border border-black/20 dark:border-white/20 rounded bg-black/5 dark:bg-white/5"},fm={class:"flex items-start gap-3"},hm={class:"text-sm"},gm={class:"font-medium mb-1"},bm={class:"px-1.5 py-0.5 bg-black/10 dark:bg-white/10 rounded font-mono text-xs"},xm={id:"functions"},ym=["onClick"],km={key:1,class:"text-left font-medium text-red-600 dark:text-red-400"},wm={key:2,class:"relative group"},_m={key:3,class:"relative group"},$m={class:"flex justify-end"},Cm=["onClick"],Vm={key:1,class:"text-neutral-400 text-sm"},Sm={id:"prompts",class:"mt-12"},Tm=["onClick"],Mm={class:"text-neutral-600 dark:text-neutral-400"},Im={class:"text-sm text-neutral-500 dark:text-neutral-400"},Lm={id:"agents",class:"mt-12"},Em=["onClick"],Am={class:"text-neutral-600 dark:text-neutral-400"},Pm={class:"text-sm text-neutral-500 dark:text-neutral-400"},Om={class:"flex items-center gap-2"},jm={key:0,class:"space-y-4"},Dm={class:"text-lg font-medium mb-2"},Um={class:"text-sm text-neutral-600 dark:text-neutral-400 mb-4"},Nm={key:0,class:"h-96 flex items-center justify-center border border-black/20 dark:border-white/20 rounded bg-black/5 dark:bg-white/5"},Rm=se({__name:"ToolsView",setup(t){const i=v(null),s=v(!1),{data:c}=Me(te("/api/config")).json(),{data:a,error:u,isFetching:r,execute:p}=Me(te("/api/tools?type=tools"),{immediate:!1}).json(),{data:f,error:b,isFetching:n,execute:d}=Me(te("/api/tools?type=prompts&schema=true"),{immediate:!1}).json(),{data:h,error:$,isFetching:g,execute:m}=Me(te("/api/tools?type=agents&schema=true"),{immediate:!1}).json(),{data:C,error:w,isFetching:E,execute:A}=Me(()=>i.value?te(`/api/tools/${i.value.name}`):null,{immediate:!1}).json(),q=v([]),J=v([]),X=v([]),P=Re(),_=async()=>{const H=P.hash;if(H){await xe();const W=document.getElementById(H.slice(1));W&&W.scrollIntoView({behavior:"smooth"})}};ie(()=>P.hash,_);const O=async H=>{i.value=H,await A(),C.value?i.value={...H,schema:C.value.schema||null}:w.value&&console.error("Error fetching tool schema:",w.value),s.value=!0},D=async H=>{if(i.value=H,s.value=!0,!H.schema&&H.type==="prompt"){const W=await fetch(te("/api/tools?type=prompts&schema=true"));if(W.ok){const G=await W.json();G[H.name]&&(i.value={...H,schema:G[H.name].schema||null})}}},N=[{key:"name",label:"Prompt Name",width:"w-1/3"},{key:"description",label:"Description",width:"w-1/2"},{key:"model",label:"Model",width:"w-1/6"}],U=[{key:"name",label:"Tool Name",width:"w-1/3"},{key:"description",label:"Description",width:"w-1/2"},{key:"actions",label:"Actions",width:"w-1/6"}],L=H=>/^[a-z][a-z0-9_]*[a-z0-9]$/.test(H)||/^[a-z]$/.test(H),T=H=>H.hasError&&H.error?H.error:H.description||"No description available",j=()=>{a.value&&(q.value=Object.entries(a.value).map(([H,W])=>({name:H,description:W.description||"No description available",schema:null,hasError:W.hasError||!1,error:W.error,type:W.type||"tool"})))},S=()=>{f.value&&(J.value=Object.entries(f.value).map(([H,W])=>({name:H,description:W.description||"No description available",schema:W.schema||null,hasError:!1,type:"prompt",model:W.model})))},x=()=>{h.value&&(X.value=Object.entries(h.value).map(([H,W])=>({name:H,description:W.description||"No description available",schema:W.schema||null,hasError:!1,type:"agent",model:W.model})))},y=async()=>{await p(),j()},k=async()=>{await d(),S()},R=async()=>{await m(),x()},K=()=>{s.value=!1,i.value=null};return ye(()=>{y(),k(),R(),_()}),(H,W)=>(o(),Q(ze,null,{default:de(()=>[W[11]||(W[11]=e("div",{class:"flex justify-between items-center mb-6"},[e("h1",{class:"text-3xl font-bold"},"Tools")],-1)),W[12]||(W[12]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-6"}," Tools are the fundamental building blocks of how your business logic is exposed to your agents. Your prompts can expose tools for the agents to call. There are 3 types of tools: functions, prompts, and agents. Functions are actual code in your AgentKit codebase. Prompts are any prompts created in the prompts table (which can themselves expose tools). Agents are multi-turn conversations that can be invoked as tools. ",-1)),e("div",vm,[e("div",fm,[I(F(cm),{class:"w-5 h-5 mt-0.5 text-black/60 dark:text-white/60 flex-shrink-0"}),e("div",hm,[e("p",gm,[W[1]||(W[1]=ke(" To create or modify tools, edit the ",-1)),e("code",bm,V(F(c)?.toolsDir||"agentbuilder/tools")+"/",1),W[2]||(W[2]=ke(" directory of your codebase. ",-1))]),W[3]||(W[3]=e("p",{class:"text-black/70 dark:text-white/70"}," Changes will be automatically detected. ",-1))])])]),e("div",xm,[I(Ne,{columns:U,data:q.value,loading:F(r),"empty-message":`No tools found. Add tool files to the ${F(c)?.toolsDir||"agentbuilder/tools"}/ directory.`},{"cell-name":de(({row:G})=>[e("div",{class:oe(["flex items-center gap-2",{"text-red-600 dark:text-red-400":G.hasError}])},[G.hasError?(o(),l("span",km,V(G.name),1)):(o(),l("button",{key:0,onClick:ue=>O(G),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},V(G.name),9,ym)),G.hasError?(o(),l("div",wm,[I(F(Ot),{class:"w-4 h-4 text-red-500"}),W[4]||(W[4]=e("div",{class:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-black dark:bg-white text-white dark:text-black text-xs rounded whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10"},[ke(" This tool has validation errors "),e("div",{class:"absolute top-full left-1/2 transform -translate-x-1/2 border-4 border-transparent border-t-black dark:border-t-white"})],-1))])):L(G.name)?M("",!0):(o(),l("div",_m,[I(F(Ot),{class:"w-4 h-4 text-amber-500"}),W[5]||(W[5]=e("div",{class:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-black dark:bg-white text-white dark:text-black text-xs rounded whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10"},[ke(" Tool name should be in snake_case format (e.g., 'log_name', 'send_email') "),e("div",{class:"absolute top-full left-1/2 transform -translate-x-1/2 border-4 border-transparent border-t-black dark:border-t-white"})],-1))]))],2)]),"cell-description":de(({row:G})=>[e("span",{class:oe({"text-red-600 dark:text-red-400":G.hasError,"text-neutral-600 dark:text-neutral-400":!G.hasError})},V(T(G)),3)]),"cell-actions":de(({row:G})=>[e("div",$m,[G.hasError?(o(),l("span",Vm,"—")):(o(),l("button",{key:0,onClick:ue=>O(G),class:"p-1.5 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",title:"View Schema"},[I(F(vt),{class:"w-4 h-4"})],8,Cm))])]),_:1},8,["data","loading","empty-message"])]),e("div",Sm,[W[6]||(W[6]=e("h2",{class:"text-2xl font-bold mb-4"},"Prompts",-1)),W[7]||(W[7]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-6"}," Prompts that are exposed as tools can be called by other prompts and agents. These allow you to create reusable, composable prompt chains. ",-1)),I(Ne,{columns:N,data:J.value,loading:F(n),"empty-message":"No prompts are currently exposed as tools. Mark a prompt as 'Expose as tool' to see it here."},{"cell-name":de(({row:G})=>[e("button",{onClick:ue=>D(G),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},V(G.name),9,Tm)]),"cell-description":de(({row:G})=>[e("span",Mm,V(G.description),1)]),"cell-model":de(({row:G})=>[e("span",Im,V(G.model||"-"),1)]),_:1},8,["data","loading"])]),e("div",Lm,[W[8]||(W[8]=e("h2",{class:"text-2xl font-bold mb-4"},"Agents",-1)),W[9]||(W[9]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-6"}," Agents that are exposed as tools can be called by other prompts and agents. When an agent is called as a tool, it uses the Side A system prompt's requirements as the tool's input schema. ",-1)),I(Ne,{columns:N,data:X.value,loading:F(g),"empty-message":"No agents are currently exposed as tools. Mark an agent as 'Expose as tool' to see it here."},{"cell-name":de(({row:G})=>[e("button",{onClick:ue=>D(G),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},V(G.name),9,Em)]),"cell-description":de(({row:G})=>[e("span",Am,V(G.description),1)]),"cell-model":de(({row:G})=>[e("span",Pm,V(G.model||"-"),1)]),_:1},8,["data","loading"])]),I(Ae,{modelValue:s.value,"onUpdate:modelValue":W[0]||(W[0]=G=>s.value=G),onClose:K,width:"max-w-4xl"},{header:de(()=>[e("div",Om,[I(F(vt),{class:"w-5 h-5"}),e("span",null,V(i.value?.name)+" Schema",1)])]),footer:de(()=>[e("button",{onClick:K,class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Close ")]),default:de(()=>[i.value?(o(),l("div",jm,[e("div",null,[e("h3",Dm,V(i.value.type==="prompt"?"Required Schema":"JSON Schema"),1),e("p",Um,V(i.value.type==="prompt"?"This is the JSON schema that defines the input parameters for this prompt.":"This is the automatically generated JSON schema for the tool's arguments."),1)]),i.value.schema===null?(o(),l("div",Nm,[...W[10]||(W[10]=[e("p",{class:"text-neutral-500 dark:text-neutral-400"}," No parameters required ",-1)])])):(o(),Q(im,{key:1,value:i.value.schema,class:"h-96 border border-black/20 dark:border-white/20 rounded"},null,8,["value"]))])):M("",!0)]),_:1},8,["modelValue"])]),_:1}))}}),Bm={class:"flex justify-between items-center mb-6"},qm={class:"flex justify-end gap-2 mt-4"},Fm={class:"flex justify-end gap-2 mt-4"},zm=se({__name:"UsersView",setup(t){const i=v(!1),s=v(!1),c=v([]),a=v(!1),u=v(null),r=v({username:"",password:"",role:"admin"}),p=v({username:"",password:"",role:"admin"}),f=[{value:"admin",label:"Admin"}],b=[{key:"username",label:"Username",width:"w-1/3"},{key:"role",label:"Role",width:"w-1/4"},{key:"created_at",label:"Created",width:"w-1/3",formatter:m=>new Date(m*1e3).toLocaleString()}],n=[{icon:"edit",label:"Edit",handler:async m=>{u.value=m,p.value={username:m.username,password:"",role:m.role},s.value=!0}},{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this user? This action cannot be undone.",handler:async m=>{await g(m.id)}}],d=async()=>{a.value=!0;try{const m=await Ue("/users");if(!m.ok)throw new Error("Failed to fetch users");const C=await m.json();c.value=C.users||[]}catch(m){console.error("Error fetching users:",m),c.value=[]}finally{a.value=!1}},h=async()=>{if(!r.value.username||!r.value.password){alert("Username and password are required");return}try{const m=await Ue("/users",{method:"POST",body:JSON.stringify(r.value)});if(!m.ok){const C=await m.json();alert(C.error||"Failed to add user");return}await d(),i.value=!1,r.value={username:"",password:"",role:"admin"}}catch(m){console.error("Error adding user:",m),alert("Failed to add user")}},$=async()=>{if(!p.value.username){alert("Username is required");return}try{const m={username:p.value.username,role:p.value.role};p.value.password&&(m.password=p.value.password);const C=await Ue(`/users/${u.value.id}`,{method:"PUT",body:JSON.stringify(m)});if(!C.ok){const w=await C.json();alert(w.error||"Failed to update user");return}await d(),s.value=!1,u.value=null}catch(m){console.error("Error updating user:",m),alert("Failed to update user")}},g=async m=>{try{const C=await Ue(`/users/${m}`,{method:"DELETE"});if(!C.ok){const w=await C.json();alert(w.error||"Failed to delete user");return}await d()}catch(C){console.error("Error deleting user:",C),alert("Failed to delete user")}};return ye(()=>{d()}),(m,C)=>(o(),Q(ze,null,{default:de(()=>[e("div",Bm,[C[13]||(C[13]=e("div",null,[e("h1",{class:"text-3xl font-bold"},"Users"),e("p",{class:"text-neutral-600 dark:text-neutral-400 mt-2"}," Manage user accounts and permissions ")],-1)),e("button",{onClick:C[0]||(C[0]=w=>i.value=!0),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Add User ")]),I(Ne,{columns:b,data:c.value,actions:n,loading:a.value,"empty-message":"No users found"},null,8,["data","loading"]),I(Ae,{modelValue:i.value,"onUpdate:modelValue":C[5]||(C[5]=w=>i.value=w),title:"Add User",onClose:C[6]||(C[6]=w=>i.value=!1)},{default:de(()=>[e("form",{onSubmit:Te(h,["prevent"]),class:"space-y-4"},[e("div",null,[C[14]||(C[14]=e("label",{class:"block text-sm font-medium mb-1"},"Username",-1)),_e(e("input",{"onUpdate:modelValue":C[1]||(C[1]=w=>r.value.username=w),type:"text",required:"",class:"w-full px-3 py-2 border border-neutral-300 dark:border-neutral-600 rounded-md dark:bg-neutral-700"},null,512),[[Ee,r.value.username]])]),e("div",null,[C[15]||(C[15]=e("label",{class:"block text-sm font-medium mb-1"},"Password",-1)),_e(e("input",{"onUpdate:modelValue":C[2]||(C[2]=w=>r.value.password=w),type:"password",required:"",class:"w-full px-3 py-2 border border-neutral-300 dark:border-neutral-600 rounded-md dark:bg-neutral-700"},null,512),[[Ee,r.value.password]])]),e("div",null,[I(ge,{modelValue:r.value.role,"onUpdate:modelValue":C[3]||(C[3]=w=>r.value.role=w),options:f,label:"Role",placeholder:"Select role"},null,8,["modelValue"])]),e("div",qm,[e("button",{type:"button",onClick:C[4]||(C[4]=w=>i.value=!1),class:"px-4 py-2 border border-neutral-300 dark:border-neutral-600 rounded hover:bg-neutral-50 dark:hover:bg-neutral-700"}," Cancel "),C[16]||(C[16]=e("button",{type:"submit",class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Add User ",-1))])],32)]),_:1},8,["modelValue"]),I(Ae,{modelValue:s.value,"onUpdate:modelValue":C[11]||(C[11]=w=>s.value=w),title:"Edit User",onClose:C[12]||(C[12]=w=>s.value=!1)},{default:de(()=>[e("form",{onSubmit:Te($,["prevent"]),class:"space-y-4"},[e("div",null,[C[17]||(C[17]=e("label",{class:"block text-sm font-medium mb-1"},"Username",-1)),_e(e("input",{"onUpdate:modelValue":C[7]||(C[7]=w=>p.value.username=w),type:"text",required:"",class:"w-full px-3 py-2 border border-neutral-300 dark:border-neutral-600 rounded-md dark:bg-neutral-700"},null,512),[[Ee,p.value.username]])]),e("div",null,[C[18]||(C[18]=e("label",{class:"block text-sm font-medium mb-1"},"Password (leave blank to keep current)",-1)),_e(e("input",{"onUpdate:modelValue":C[8]||(C[8]=w=>p.value.password=w),type:"password",class:"w-full px-3 py-2 border border-neutral-300 dark:border-neutral-600 rounded-md dark:bg-neutral-700"},null,512),[[Ee,p.value.password]])]),e("div",null,[I(ge,{modelValue:p.value.role,"onUpdate:modelValue":C[9]||(C[9]=w=>p.value.role=w),options:f,label:"Role",placeholder:"Select role"},null,8,["modelValue"])]),e("div",Fm,[e("button",{type:"button",onClick:C[10]||(C[10]=w=>s.value=!1),class:"px-4 py-2 border border-neutral-300 dark:border-neutral-600 rounded hover:bg-neutral-50 dark:hover:bg-neutral-700"}," Cancel "),C[19]||(C[19]=e("button",{type:"submit",class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Update User ",-1))])],32)]),_:1},8,["modelValue"])]),_:1}))}}),Hm={class:"flex justify-between items-center mb-6"},Wm={class:"flex justify-end gap-2 mt-4"},Jm={class:"space-y-4"},Zm={class:"flex gap-2"},Km=["value"],Gm={class:"bg-accent-50 dark:bg-accent-900/30 border border-accent-200 dark:border-accent-800 text-accent-800 dark:text-accent-400 px-4 py-3 rounded"},Xm={class:"block mt-2 bg-white dark:bg-neutral-800 px-3 py-2 rounded text-xs"},Ym={class:"flex justify-end mt-4"},Qm=se({__name:"ApiKeysView",setup(t){const i=v(!1),s=v(!1),c=v([]),a=v(!1),u=v(""),r=v({name:""}),p=[{key:"name",label:"Name",width:"w-1/3"},{key:"keyPreview",label:"API Key",width:"w-1/3",html:!0,formatter:$=>`<code class="bg-neutral-100 dark:bg-neutral-800 px-2 py-1 rounded text-sm">${$}</code>`},{key:"createdAt",label:"Created",width:"w-1/6",formatter:$=>new Date($*1e3).toLocaleDateString()},{key:"lastUsedAt",label:"Last Used",width:"w-1/6",formatter:$=>$?new Date($*1e3).toLocaleDateString():"Never"}],f=[{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this API key? This action cannot be undone.",handler:async $=>{await d($.id)}}],b=async()=>{a.value=!0;try{const $=await Ue("/api-keys");if(!$.ok)throw new Error("Failed to fetch API keys");const g=await $.json();c.value=(g.keys||[]).map(m=>({...m,keyPreview:`${m.key_prefix}...${m.last_five}`,createdAt:m.created_at,lastUsedAt:m.last_used_at}))}catch($){console.error("Error fetching API keys:",$),c.value=[]}finally{a.value=!1}},n=async()=>{if(!r.value.name){alert("Name is required");return}try{const $=await Ue("/api-keys",{method:"POST",body:JSON.stringify(r.value)}),g=await $.json();if(!$.ok){alert(g.error||"Failed to create API key");return}u.value=g.key,i.value=!1,s.value=!0,await b(),r.value={name:""}}catch($){console.error("Error creating API key:",$),alert("Failed to create API key")}},d=async $=>{try{const g=await Ue(`/api-keys/${$}`,{method:"DELETE"});if(!g.ok){const m=await g.json();alert(m.error||"Failed to delete API key");return}await b()}catch(g){console.error("Error deleting API key:",g),alert("Failed to delete API key")}},h=async $=>{try{await navigator.clipboard.writeText($),alert("API key copied to clipboard!")}catch(g){console.error("Failed to copy:",g)}};return ye(()=>{b()}),($,g)=>(o(),Q(ze,null,{default:de(()=>[e("div",Hm,[g[9]||(g[9]=e("div",null,[e("h1",{class:"text-3xl font-bold"},"API Keys"),e("p",{class:"text-neutral-600 dark:text-neutral-400 mt-2"}," Manage API keys for programmatic access ")],-1)),e("button",{onClick:g[0]||(g[0]=m=>i.value=!0),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Create API Key ")]),I(Ne,{columns:p,data:c.value,actions:f,loading:a.value,"empty-message":"No API keys found"},null,8,["data","loading"]),I(Ae,{modelValue:i.value,"onUpdate:modelValue":g[3]||(g[3]=m=>i.value=m),title:"Create API Key",onClose:g[4]||(g[4]=m=>i.value=!1)},{default:de(()=>[e("form",{onSubmit:Te(n,["prevent"]),class:"space-y-4"},[e("div",null,[g[10]||(g[10]=e("label",{class:"block text-sm font-medium mb-1"},"Name",-1)),_e(e("input",{"onUpdate:modelValue":g[1]||(g[1]=m=>r.value.name=m),type:"text",required:"",placeholder:"e.g., Production API Key",class:"w-full px-3 py-2 border border-neutral-300 dark:border-neutral-600 rounded-md dark:bg-neutral-700"},null,512),[[Ee,r.value.name]]),g[11]||(g[11]=e("p",{class:"text-sm text-neutral-500 dark:text-neutral-400 mt-1"}," A descriptive name to help you identify this key ",-1))]),e("div",Wm,[e("button",{type:"button",onClick:g[2]||(g[2]=m=>i.value=!1),class:"px-4 py-2 border border-neutral-300 dark:border-neutral-600 rounded hover:bg-neutral-50 dark:hover:bg-neutral-700"}," Cancel "),g[12]||(g[12]=e("button",{type:"submit",class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Create Key ",-1))])],32)]),_:1},8,["modelValue"]),I(Ae,{modelValue:s.value,"onUpdate:modelValue":g[7]||(g[7]=m=>s.value=m),title:"API Key Created",onClose:g[8]||(g[8]=m=>s.value=!1)},{default:de(()=>[e("div",Jm,[g[15]||(g[15]=e("div",{class:"bg-yellow-50 dark:bg-yellow-900/30 border border-yellow-200 dark:border-yellow-800 text-yellow-800 dark:text-yellow-400 px-4 py-3 rounded"},[e("p",{class:"font-semibold"},"Important: Save this key now!"),e("p",{class:"text-sm mt-1"}," You won't be able to see it again. If you lose this key, you'll need to create a new one. ")],-1)),e("div",null,[g[13]||(g[13]=e("label",{class:"block text-sm font-medium mb-2"},"Your new API key:",-1)),e("div",Zm,[e("input",{value:u.value,type:"text",readonly:"",class:"flex-1 px-3 py-2 border border-neutral-300 dark:border-neutral-600 rounded-md dark:bg-neutral-700 font-mono text-sm"},null,8,Km),e("button",{onClick:g[5]||(g[5]=m=>h(u.value)),class:"px-4 py-2 bg-neutral-200 dark:bg-neutral-700 rounded hover:bg-neutral-300 dark:hover:bg-neutral-600"}," Copy ")])]),e("div",Gm,[g[14]||(g[14]=e("p",{class:"text-sm"}," Use this key in the Authorization header of your API requests: ",-1)),e("code",Xm," Authorization: Bearer "+V(u.value),1)]),e("div",Ym,[e("button",{onClick:g[6]||(g[6]=m=>s.value=!1),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Done ")])])]),_:1},8,["modelValue"])]),_:1}))}}),ev={class:"login-container flex-1 flex items-center justify-center px-4"},tv={class:"max-w-md w-full space-y-8"},ov={class:"flex justify-center"},av=["src"],lv={class:"bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-700 py-8 px-6 rounded-lg"},sv={key:0,class:"bg-red-50 dark:bg-red-950 border border-red-500 text-red-700 dark:text-red-400 px-4 py-3"},nv=["disabled"],rv={key:0,class:"mt-6"},iv=se({__name:"LoginView",setup(t){function i(w){if(w.startsWith("/src/")||w.startsWith("data:"))return w;const E=Ge();return E==="/"?w.replace("/agents/","/"):w.replace("/agents/",`${E}/`)}const s=i(Jt),c=i(Zt),a=Ze(),u=Re(),r=v(""),p=v(""),f=v(""),b=v(!1),n=v(!1),d=v(!1),h=v(!1),$=z(()=>h.value?c:s);ye(async()=>{const w=localStorage.getItem("theme");h.value=w==="dark"||!w&&window.matchMedia("(prefers-color-scheme: dark)").matches;const E=u.query.token,A=u.query.error;if(E){localStorage.setItem("auth_token",E),a.push("/");return}A&&(A==="oauth_failed"?f.value="OAuth authentication failed. Please try again.":A==="oauth_not_configured"&&(f.value="OAuth provider is not configured."));try{const q=await fetch(te("/api/auth/config"));if(q.ok){const J=await q.json();n.value=J.github||!1,d.value=J.google||!1}}catch(q){console.error("Failed to fetch auth config:",q)}});async function g(){f.value="",b.value=!0;try{const w=await fetch(te("/api/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r.value,password:p.value})}),E=await w.json();w.ok?(localStorage.setItem("auth_token",E.token),a.push("/")):f.value=E.error||"Login failed"}catch{f.value="Network error. Please try again."}finally{b.value=!1}}function m(){window.location.href=te("/api/auth/oauth/github")}function C(){window.location.href=te("/api/auth/oauth/google")}return(w,E)=>(o(),l("div",ev,[e("div",tv,[e("div",ov,[e("img",{src:$.value,alt:"AgentBuilder",class:"h-16 pointer-events-none select-none"},null,8,av)]),I(Ke,{offsetX:8,offsetY:8,intensity:.2,pattern:"crosshatch"},{default:de(()=>[e("div",lv,[e("form",{class:"space-y-6",onSubmit:Te(g,["prevent"])},[f.value?(o(),l("div",sv,V(f.value),1)):M("",!0),I(Ce,{modelValue:r.value,"onUpdate:modelValue":E[0]||(E[0]=A=>r.value=A),label:"Username",type:"text",disabled:b.value,placeholder:"Enter your username"},null,8,["modelValue","disabled"]),I(Ce,{modelValue:p.value,"onUpdate:modelValue":E[1]||(E[1]=A=>p.value=A),label:"Password",type:"password",disabled:b.value,placeholder:"Enter your password"},null,8,["modelValue","disabled"]),e("div",null,[e("button",{type:"submit",disabled:b.value,class:"w-full px-4 py-2.5 bg-neutral-900 text-white dark:bg-neutral-100 dark:text-neutral-900 rounded-md font-medium hover:bg-neutral-800 dark:hover:bg-neutral-200 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"},V(b.value?"Signing in...":"Sign in"),9,nv)])],32),n.value||d.value?(o(),l("div",rv,[E[4]||(E[4]=e("div",{class:"relative"},[e("div",{class:"absolute inset-0 flex items-center"},[e("div",{class:"w-full border-t border-neutral-300 dark:border-neutral-600"})]),e("div",{class:"relative flex justify-center text-sm"},[e("span",{class:"px-2 bg-white dark:bg-neutral-900 text-neutral-500 dark:text-neutral-400"},"Or continue with")])],-1)),e("div",{class:oe(["mt-6 grid gap-3",n.value&&d.value?"grid-cols-2":"grid-cols-1"])},[n.value?(o(),l("button",{key:0,onClick:m,type:"button",class:"w-full inline-flex justify-center items-center px-4 py-2.5 border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-700 dark:text-neutral-200 rounded-md font-medium hover:bg-neutral-50 dark:hover:bg-neutral-700 transition-colors"},[...E[2]||(E[2]=[e("svg",{class:"h-5 w-5",fill:"currentColor",viewBox:"0 0 20 20"},[e("path",{"fill-rule":"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z","clip-rule":"evenodd"})],-1),e("span",{class:"ml-2"},"GitHub",-1)])])):M("",!0),d.value?(o(),l("button",{key:1,onClick:C,type:"button",class:"w-full inline-flex justify-center items-center px-4 py-2.5 border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-700 dark:text-neutral-200 rounded-md font-medium hover:bg-neutral-50 dark:hover:bg-neutral-700 transition-colors"},[...E[3]||(E[3]=[e("svg",{class:"h-5 w-5",viewBox:"0 0 24 24"},[e("path",{fill:"currentColor",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),e("path",{fill:"currentColor",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),e("path",{fill:"currentColor",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),e("path",{fill:"currentColor",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})],-1),e("span",{class:"ml-2"},"Google",-1)])])):M("",!0)],2)])):M("",!0)])]),_:1})])]))}}),dv={class:"space-y-1"},uv={key:0,class:"block text-sm font-medium"},cv={key:0,class:"text-red-500"},pv=["value","placeholder","disabled"],mv={key:1,class:"text-xs text-red-500 dark:text-red-400"},ut=se({__name:"MultilineInput",props:{modelValue:{},label:{},placeholder:{},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","focus","blur"],setup(t,{expose:i,emit:s}){const c=t,a=s,u=v(null),r=z(()=>["w-full px-3 py-2 bg-white dark:bg-black border rounded font-mono text-sm","focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white","transition-colors resize-none overflow-hidden",c.error?"border-red-500 dark:border-red-400":"border-black dark:border-neutral-300",c.disabled?"opacity-50 cursor-not-allowed":""]),p=()=>{const d=u.value;d&&(d.style.height="auto",d.style.height=`${d.scrollHeight+2}px`)},f=d=>{const h=d.target;a("update:modelValue",h.value),p()},b=d=>{a("focus",d)},n=d=>{a("blur",d)};return ye(()=>{p()}),ie(()=>c.modelValue,async()=>{await xe(),p()}),i({textareaRef:u,adjustHeight:p}),(d,h)=>(o(),l("div",dv,[t.label?(o(),l("label",uv,[ke(V(t.label)+" ",1),t.required?(o(),l("span",cv,"*")):M("",!0)])):M("",!0),e("textarea",{ref_key:"textareaRef",ref:u,value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,class:oe(r.value),rows:"1",onInput:f,onFocus:b,onBlur:n},null,42,pv),t.error?(o(),l("p",mv,V(t.error),1)):M("",!0)]))}}),vv={class:"p-8 space-y-6"},fv={class:"mt-12"},hv={class:"mb-6"},gv={class:"mb-6"},bv={class:"mb-6"},xv={class:"mt-8"},yv={class:"border-2 border-red-500 p-4 h-32 overflow-hidden relative"},kv={class:"mt-12"},wv={class:"mb-6"},_v={class:"border-2 border-accent-500 p-4 h-32 overflow-hidden relative"},$v={class:"mt-12"},Cv={class:"mb-6"},Vv={class:"mb-6"},Sv={class:"mt-12"},Tv={class:"mb-6"},Mv={class:"mt-2 text-sm"},Iv={class:"mb-6"},Lv={class:"mt-2 text-sm"},Ev={class:"mb-6"},Av={class:"mb-6"},Pv={class:"mt-12"},Ov={class:"mb-6"},jv={class:"mt-4 p-4 bg-neutral-100 dark:bg-neutral-900 rounded"},Dv={class:"text-xs overflow-x-auto"},Uv=se({__name:"TestView",setup(t){const i=v(""),s=v(""),c=v(""),a=v(`Line 1
14
+ This provider has ${d.modelCount} associated model(s).`):alert(d.error||"Failed to delete provider");return}await r()}catch(s){console.error("Error deleting provider:",s),alert("Failed to delete provider")}};return xe(()=>{r()}),(b,s)=>(o(),ee(Ke,null,{default:de(()=>[e("div",Z1,[s[2]||(s[2]=e("h1",{class:"text-3xl font-bold"},"Providers",-1)),e("button",{onClick:s[0]||(s[0]=d=>i.value=!0),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Add Provider ")]),s[3]||(s[3]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-8"}," Manage API providers and authentication keys. All API keys are encrypted at rest. ",-1)),E(Fe,{columns:l,data:n.value,actions:c,loading:u.value,"empty-message":"No providers configured yet. Add your first provider to get started."},null,8,["data","loading"]),E(J1,{modelValue:i.value,"onUpdate:modelValue":s[1]||(s[1]=d=>i.value=d),onSave:p},null,8,["modelValue"])]),_:1}))}}),G1={class:"json-viewer overflow-auto"},X1=["innerHTML"],Y1=se({__name:"JsonViewer",props:{value:{}},setup(t){const i=t;function n(c){return c.replace(/"([^"\\]|\\.)*"/g,r=>`<span class="json-string">${u(r)}</span>`).replace(/\b(-?\d+\.?\d*)\b/g,'<span class="json-number">$1</span>').replace(/\b(true|false|null)\b/g,'<span class="json-boolean">$1</span>')}function u(c){return c.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const l=K(()=>{try{const c=JSON.stringify(i.value,null,2);return n(c)}catch{return u(String(i.value))}});return(c,r)=>(o(),a("div",G1,[e("pre",{class:"p-4 text-sm font-mono leading-relaxed",innerHTML:l.value},null,8,X1)]))}}),Q1=Ze(Y1,[["__scopeId","data-v-5118293b"]]),em={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function tm(t,i){return o(),a("svg",em,[...i[0]||(i[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("circle",{cx:"12",cy:"12",r:"10"}),e("path",{d:"M12 16v-4m0-4h.01"})],-1)])])}const om=_e({name:"lucide-info",render:tm}),lm={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function am(t,i){return o(),a("svg",lm,[...i[0]||(i[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m21.73 18l-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3M12 9v4m0 4h.01"},null,-1)])])}const Rt=_e({name:"lucide-triangle-alert",render:am}),sm={class:"mb-6 p-4 border border-black/20 dark:border-white/20 rounded bg-black/5 dark:bg-white/5"},nm={class:"flex items-start gap-3"},rm={class:"text-sm"},im={class:"font-medium mb-1"},dm={class:"px-1.5 py-0.5 bg-black/10 dark:bg-white/10 rounded font-mono text-xs"},um={id:"functions"},cm=["onClick"],pm={key:1,class:"text-left font-medium text-red-600 dark:text-red-400"},mm={key:2,class:"relative group"},vm={key:3,class:"relative group"},fm={class:"flex justify-end"},hm=["onClick"],gm={key:1,class:"text-neutral-400 text-sm"},bm={id:"prompts",class:"mt-12"},xm=["onClick"],ym={class:"text-neutral-600 dark:text-neutral-400"},km={class:"text-sm text-neutral-500 dark:text-neutral-400"},wm={id:"agents",class:"mt-12"},_m=["onClick"],$m={class:"text-neutral-600 dark:text-neutral-400"},Cm={class:"text-sm text-neutral-500 dark:text-neutral-400"},Vm={class:"flex items-center gap-2"},Sm={key:0,class:"space-y-4"},Tm={class:"text-lg font-medium mb-2"},Mm={class:"text-sm text-neutral-600 dark:text-neutral-400 mb-4"},Lm={key:0,class:"h-96 flex items-center justify-center border border-black/20 dark:border-white/20 rounded bg-black/5 dark:bg-white/5"},Im=se({__name:"ToolsView",setup(t){const i=v(null),n=v(!1),{data:u}=Ee(ae("/api/config")).json(),{data:l,error:c,isFetching:r,execute:p}=Ee(ae("/api/tools?type=tools"),{immediate:!1}).json(),{data:f,error:b,isFetching:s,execute:d}=Ee(ae("/api/tools?type=prompts&schema=true"),{immediate:!1}).json(),{data:h,error:$,isFetching:g,execute:m}=Ee(ae("/api/tools?type=agents&schema=true"),{immediate:!1}).json(),{data:w,error:k,isFetching:O,execute:D}=Ee(()=>i.value?ae(`/api/tools/${i.value.name}`):null,{immediate:!1}).json(),F=v([]),X=v([]),te=v([]),R=ze(),j=async()=>{const A=R.hash;if(A){await ge();const I=document.getElementById(A.slice(1));I&&I.scrollIntoView({behavior:"smooth"})}};ue(()=>R.hash,j);const W=async A=>{i.value=A,await D(),w.value?i.value={...A,schema:w.value.schema||null}:k.value&&console.error("Error fetching tool schema:",k.value),n.value=!0},B=async A=>{if(i.value=A,n.value=!0,!A.schema&&A.type==="prompt"){const I=await fetch(ae("/api/tools?type=prompts&schema=true"));if(I.ok){const M=await I.json();M[A.name]&&(i.value={...A,schema:M[A.name].schema||null})}}},N=[{key:"name",label:"Prompt Name",width:"w-1/3"},{key:"description",label:"Description",width:"w-1/2"},{key:"model",label:"Model",width:"w-1/6"}],U=[{key:"name",label:"Tool Name",width:"w-1/3"},{key:"description",label:"Description",width:"w-1/2"},{key:"actions",label:"Actions",width:"w-1/6"}],y=A=>/^[a-z][a-z0-9_]*[a-z0-9]$/.test(A)||/^[a-z]$/.test(A),x=A=>A.hasError&&A.error?A.error:A.description||"No description available",V=()=>{l.value&&(F.value=Object.entries(l.value).map(([A,I])=>({name:A,description:I.description||"No description available",schema:null,hasError:I.hasError||!1,error:I.error,type:I.type||"tool"})))},_=()=>{f.value&&(X.value=Object.entries(f.value).map(([A,I])=>({name:A,description:I.description||"No description available",schema:I.schema||null,hasError:!1,type:"prompt",model:I.model})))},T=()=>{h.value&&(te.value=Object.entries(h.value).map(([A,I])=>({name:A,description:I.description||"No description available",schema:I.schema||null,hasError:!1,type:"agent",model:I.model})))},S=async()=>{await p(),V()},P=async()=>{await d(),_()},J=async()=>{await m(),T()},re=()=>{n.value=!1,i.value=null};return xe(()=>{S(),P(),J(),j()}),(A,I)=>(o(),ee(Ke,null,{default:de(()=>[I[11]||(I[11]=e("div",{class:"flex justify-between items-center mb-6"},[e("h1",{class:"text-3xl font-bold"},"Tools")],-1)),I[12]||(I[12]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-6"}," Tools are the fundamental building blocks of how your business logic is exposed to your agents. Your prompts can expose tools for the agents to call. There are 3 types of tools: functions, prompts, and agents. Functions are actual code in your AgentKit codebase. Prompts are any prompts created in the prompts table (which can themselves expose tools). Agents are multi-turn conversations that can be invoked as tools. ",-1)),e("div",sm,[e("div",nm,[E(Z(om),{class:"w-5 h-5 mt-0.5 text-black/60 dark:text-white/60 flex-shrink-0"}),e("div",rm,[e("p",im,[I[1]||(I[1]=ye(" To create or modify tools, edit the ",-1)),e("code",dm,C(Z(u)?.toolsDir||"agentbuilder/tools")+"/",1),I[2]||(I[2]=ye(" directory of your codebase. ",-1))]),I[3]||(I[3]=e("p",{class:"text-black/70 dark:text-white/70"}," Changes will be automatically detected. ",-1))])])]),e("div",um,[E(Fe,{columns:U,data:F.value,loading:Z(r),"empty-message":`No tools found. Add tool files to the ${Z(u)?.toolsDir||"agentbuilder/tools"}/ directory.`},{"cell-name":de(({row:M})=>[e("div",{class:le(["flex items-center gap-2",{"text-red-600 dark:text-red-400":M.hasError}])},[M.hasError?(o(),a("span",pm,C(M.name),1)):(o(),a("button",{key:0,onClick:oe=>W(M),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},C(M.name),9,cm)),M.hasError?(o(),a("div",mm,[E(Z(Rt),{class:"w-4 h-4 text-red-500"}),I[4]||(I[4]=e("div",{class:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-black dark:bg-white text-white dark:text-black text-xs rounded whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10"},[ye(" This tool has validation errors "),e("div",{class:"absolute top-full left-1/2 transform -translate-x-1/2 border-4 border-transparent border-t-black dark:border-t-white"})],-1))])):y(M.name)?L("",!0):(o(),a("div",vm,[E(Z(Rt),{class:"w-4 h-4 text-amber-500"}),I[5]||(I[5]=e("div",{class:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-black dark:bg-white text-white dark:text-black text-xs rounded whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10"},[ye(" Tool name should be in snake_case format (e.g., 'log_name', 'send_email') "),e("div",{class:"absolute top-full left-1/2 transform -translate-x-1/2 border-4 border-transparent border-t-black dark:border-t-white"})],-1))]))],2)]),"cell-description":de(({row:M})=>[e("span",{class:le({"text-red-600 dark:text-red-400":M.hasError,"text-neutral-600 dark:text-neutral-400":!M.hasError})},C(x(M)),3)]),"cell-actions":de(({row:M})=>[e("div",fm,[M.hasError?(o(),a("span",gm,"—")):(o(),a("button",{key:0,onClick:oe=>W(M),class:"p-1.5 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",title:"View Schema"},[E(Z(kt),{class:"w-4 h-4"})],8,hm))])]),_:1},8,["data","loading","empty-message"])]),e("div",bm,[I[6]||(I[6]=e("h2",{class:"text-2xl font-bold mb-4"},"Prompts",-1)),I[7]||(I[7]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-6"}," Prompts that are exposed as tools can be called by other prompts and agents. These allow you to create reusable, composable prompt chains. ",-1)),E(Fe,{columns:N,data:X.value,loading:Z(s),"empty-message":"No prompts are currently exposed as tools. Mark a prompt as 'Expose as tool' to see it here."},{"cell-name":de(({row:M})=>[e("button",{onClick:oe=>B(M),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},C(M.name),9,xm)]),"cell-description":de(({row:M})=>[e("span",ym,C(M.description),1)]),"cell-model":de(({row:M})=>[e("span",km,C(M.model||"-"),1)]),_:1},8,["data","loading"])]),e("div",wm,[I[8]||(I[8]=e("h2",{class:"text-2xl font-bold mb-4"},"Agents",-1)),I[9]||(I[9]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-6"}," Agents that are exposed as tools can be called by other prompts and agents. When an agent is called as a tool, it uses the Side A system prompt's requirements as the tool's input schema. ",-1)),E(Fe,{columns:N,data:te.value,loading:Z(g),"empty-message":"No agents are currently exposed as tools. Mark an agent as 'Expose as tool' to see it here."},{"cell-name":de(({row:M})=>[e("button",{onClick:oe=>B(M),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},C(M.name),9,_m)]),"cell-description":de(({row:M})=>[e("span",$m,C(M.description),1)]),"cell-model":de(({row:M})=>[e("span",Cm,C(M.model||"-"),1)]),_:1},8,["data","loading"])]),E(je,{modelValue:n.value,"onUpdate:modelValue":I[0]||(I[0]=M=>n.value=M),onClose:re,width:"max-w-4xl"},{header:de(()=>[e("div",Vm,[E(Z(kt),{class:"w-5 h-5"}),e("span",null,C(i.value?.name)+" Schema",1)])]),footer:de(()=>[e("button",{onClick:re,class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Close ")]),default:de(()=>[i.value?(o(),a("div",Sm,[e("div",null,[e("h3",Tm,C(i.value.type==="prompt"?"Required Schema":"JSON Schema"),1),e("p",Mm,C(i.value.type==="prompt"?"This is the JSON schema that defines the input parameters for this prompt.":"This is the automatically generated JSON schema for the tool's arguments."),1)]),i.value.schema===null?(o(),a("div",Lm,[...I[10]||(I[10]=[e("p",{class:"text-neutral-500 dark:text-neutral-400"}," No parameters required ",-1)])])):(o(),ee(Q1,{key:1,value:i.value.schema,class:"h-96 border border-black/20 dark:border-white/20 rounded"},null,8,["value"]))])):L("",!0)]),_:1},8,["modelValue"])]),_:1}))}}),Em={class:"flex justify-between items-center mb-6"},Am={class:"flex justify-end gap-2 mt-4"},Pm={class:"flex justify-end gap-2 mt-4"},Om=se({__name:"UsersView",setup(t){const i=v(!1),n=v(!1),u=v([]),l=v(!1),c=v(null),r=v({username:"",password:"",role:"admin"}),p=v({username:"",password:"",role:"admin"}),f=[{value:"admin",label:"Admin"}],b=[{key:"username",label:"Username",width:"w-1/3"},{key:"role",label:"Role",width:"w-1/4"},{key:"created_at",label:"Created",width:"w-1/3",formatter:m=>new Date(m*1e3).toLocaleString()}],s=[{icon:"edit",label:"Edit",handler:async m=>{c.value=m,p.value={username:m.username,password:"",role:m.role},n.value=!0}},{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this user? This action cannot be undone.",handler:async m=>{await g(m.id)}}],d=async()=>{l.value=!0;try{const m=await qe("/users");if(!m.ok)throw new Error("Failed to fetch users");const w=await m.json();u.value=w.users||[]}catch(m){console.error("Error fetching users:",m),u.value=[]}finally{l.value=!1}},h=async()=>{if(!r.value.username||!r.value.password){alert("Username and password are required");return}try{const m=await qe("/users",{method:"POST",body:JSON.stringify(r.value)});if(!m.ok){const w=await m.json();alert(w.error||"Failed to add user");return}await d(),i.value=!1,r.value={username:"",password:"",role:"admin"}}catch(m){console.error("Error adding user:",m),alert("Failed to add user")}},$=async()=>{if(!p.value.username){alert("Username is required");return}try{const m={username:p.value.username,role:p.value.role};p.value.password&&(m.password=p.value.password);const w=await qe(`/users/${c.value.id}`,{method:"PUT",body:JSON.stringify(m)});if(!w.ok){const k=await w.json();alert(k.error||"Failed to update user");return}await d(),n.value=!1,c.value=null}catch(m){console.error("Error updating user:",m),alert("Failed to update user")}},g=async m=>{try{const w=await qe(`/users/${m}`,{method:"DELETE"});if(!w.ok){const k=await w.json();alert(k.error||"Failed to delete user");return}await d()}catch(w){console.error("Error deleting user:",w),alert("Failed to delete user")}};return xe(()=>{d()}),(m,w)=>(o(),ee(Ke,null,{default:de(()=>[e("div",Em,[w[13]||(w[13]=e("div",null,[e("h1",{class:"text-3xl font-bold"},"Users"),e("p",{class:"text-neutral-600 dark:text-neutral-400 mt-2"}," Manage user accounts and permissions ")],-1)),e("button",{onClick:w[0]||(w[0]=k=>i.value=!0),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Add User ")]),E(Fe,{columns:b,data:u.value,actions:s,loading:l.value,"empty-message":"No users found"},null,8,["data","loading"]),E(je,{modelValue:i.value,"onUpdate:modelValue":w[5]||(w[5]=k=>i.value=k),title:"Add User",onClose:w[6]||(w[6]=k=>i.value=!1)},{default:de(()=>[e("form",{onSubmit:we(h,["prevent"]),class:"space-y-4"},[e("div",null,[w[14]||(w[14]=e("label",{class:"block text-sm font-medium mb-1"},"Username",-1)),Se(e("input",{"onUpdate:modelValue":w[1]||(w[1]=k=>r.value.username=k),type:"text",required:"",class:"w-full px-3 py-2 border border-neutral-300 dark:border-neutral-600 rounded-md dark:bg-neutral-700"},null,512),[[Oe,r.value.username]])]),e("div",null,[w[15]||(w[15]=e("label",{class:"block text-sm font-medium mb-1"},"Password",-1)),Se(e("input",{"onUpdate:modelValue":w[2]||(w[2]=k=>r.value.password=k),type:"password",required:"",class:"w-full px-3 py-2 border border-neutral-300 dark:border-neutral-600 rounded-md dark:bg-neutral-700"},null,512),[[Oe,r.value.password]])]),e("div",null,[E(he,{modelValue:r.value.role,"onUpdate:modelValue":w[3]||(w[3]=k=>r.value.role=k),options:f,label:"Role",placeholder:"Select role"},null,8,["modelValue"])]),e("div",Am,[e("button",{type:"button",onClick:w[4]||(w[4]=k=>i.value=!1),class:"px-4 py-2 border border-neutral-300 dark:border-neutral-600 rounded hover:bg-neutral-50 dark:hover:bg-neutral-700"}," Cancel "),w[16]||(w[16]=e("button",{type:"submit",class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Add User ",-1))])],32)]),_:1},8,["modelValue"]),E(je,{modelValue:n.value,"onUpdate:modelValue":w[11]||(w[11]=k=>n.value=k),title:"Edit User",onClose:w[12]||(w[12]=k=>n.value=!1)},{default:de(()=>[e("form",{onSubmit:we($,["prevent"]),class:"space-y-4"},[e("div",null,[w[17]||(w[17]=e("label",{class:"block text-sm font-medium mb-1"},"Username",-1)),Se(e("input",{"onUpdate:modelValue":w[7]||(w[7]=k=>p.value.username=k),type:"text",required:"",class:"w-full px-3 py-2 border border-neutral-300 dark:border-neutral-600 rounded-md dark:bg-neutral-700"},null,512),[[Oe,p.value.username]])]),e("div",null,[w[18]||(w[18]=e("label",{class:"block text-sm font-medium mb-1"},"Password (leave blank to keep current)",-1)),Se(e("input",{"onUpdate:modelValue":w[8]||(w[8]=k=>p.value.password=k),type:"password",class:"w-full px-3 py-2 border border-neutral-300 dark:border-neutral-600 rounded-md dark:bg-neutral-700"},null,512),[[Oe,p.value.password]])]),e("div",null,[E(he,{modelValue:p.value.role,"onUpdate:modelValue":w[9]||(w[9]=k=>p.value.role=k),options:f,label:"Role",placeholder:"Select role"},null,8,["modelValue"])]),e("div",Pm,[e("button",{type:"button",onClick:w[10]||(w[10]=k=>n.value=!1),class:"px-4 py-2 border border-neutral-300 dark:border-neutral-600 rounded hover:bg-neutral-50 dark:hover:bg-neutral-700"}," Cancel "),w[19]||(w[19]=e("button",{type:"submit",class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Update User ",-1))])],32)]),_:1},8,["modelValue"])]),_:1}))}}),jm={class:"flex justify-between items-center mb-6"},Dm={class:"flex justify-end gap-2 mt-4"},Um={class:"space-y-4"},Rm={class:"flex gap-2"},Nm=["value"],Bm={class:"bg-accent-50 dark:bg-accent-900/30 border border-accent-200 dark:border-accent-800 text-accent-800 dark:text-accent-400 px-4 py-3 rounded"},qm={class:"block mt-2 bg-white dark:bg-neutral-800 px-3 py-2 rounded text-xs"},Fm={class:"flex justify-end mt-4"},zm=se({__name:"ApiKeysView",setup(t){const i=v(!1),n=v(!1),u=v([]),l=v(!1),c=v(""),r=v({name:""}),p=[{key:"name",label:"Name",width:"w-1/3"},{key:"keyPreview",label:"API Key",width:"w-1/3",html:!0,formatter:$=>`<code class="bg-neutral-100 dark:bg-neutral-800 px-2 py-1 rounded text-sm">${$}</code>`},{key:"createdAt",label:"Created",width:"w-1/6",formatter:$=>new Date($*1e3).toLocaleDateString()},{key:"lastUsedAt",label:"Last Used",width:"w-1/6",formatter:$=>$?new Date($*1e3).toLocaleDateString():"Never"}],f=[{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this API key? This action cannot be undone.",handler:async $=>{await d($.id)}}],b=async()=>{l.value=!0;try{const $=await qe("/api-keys");if(!$.ok)throw new Error("Failed to fetch API keys");const g=await $.json();u.value=(g.keys||[]).map(m=>({...m,keyPreview:`${m.key_prefix}...${m.last_five}`,createdAt:m.created_at,lastUsedAt:m.last_used_at}))}catch($){console.error("Error fetching API keys:",$),u.value=[]}finally{l.value=!1}},s=async()=>{if(!r.value.name){alert("Name is required");return}try{const $=await qe("/api-keys",{method:"POST",body:JSON.stringify(r.value)}),g=await $.json();if(!$.ok){alert(g.error||"Failed to create API key");return}c.value=g.key,i.value=!1,n.value=!0,await b(),r.value={name:""}}catch($){console.error("Error creating API key:",$),alert("Failed to create API key")}},d=async $=>{try{const g=await qe(`/api-keys/${$}`,{method:"DELETE"});if(!g.ok){const m=await g.json();alert(m.error||"Failed to delete API key");return}await b()}catch(g){console.error("Error deleting API key:",g),alert("Failed to delete API key")}},h=async $=>{try{await navigator.clipboard.writeText($),alert("API key copied to clipboard!")}catch(g){console.error("Failed to copy:",g)}};return xe(()=>{b()}),($,g)=>(o(),ee(Ke,null,{default:de(()=>[e("div",jm,[g[9]||(g[9]=e("div",null,[e("h1",{class:"text-3xl font-bold"},"API Keys"),e("p",{class:"text-neutral-600 dark:text-neutral-400 mt-2"}," Manage API keys for programmatic access ")],-1)),e("button",{onClick:g[0]||(g[0]=m=>i.value=!0),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Create API Key ")]),E(Fe,{columns:p,data:u.value,actions:f,loading:l.value,"empty-message":"No API keys found"},null,8,["data","loading"]),E(je,{modelValue:i.value,"onUpdate:modelValue":g[3]||(g[3]=m=>i.value=m),title:"Create API Key",onClose:g[4]||(g[4]=m=>i.value=!1)},{default:de(()=>[e("form",{onSubmit:we(s,["prevent"]),class:"space-y-4"},[e("div",null,[g[10]||(g[10]=e("label",{class:"block text-sm font-medium mb-1"},"Name",-1)),Se(e("input",{"onUpdate:modelValue":g[1]||(g[1]=m=>r.value.name=m),type:"text",required:"",placeholder:"e.g., Production API Key",class:"w-full px-3 py-2 border border-neutral-300 dark:border-neutral-600 rounded-md dark:bg-neutral-700"},null,512),[[Oe,r.value.name]]),g[11]||(g[11]=e("p",{class:"text-sm text-neutral-500 dark:text-neutral-400 mt-1"}," A descriptive name to help you identify this key ",-1))]),e("div",Dm,[e("button",{type:"button",onClick:g[2]||(g[2]=m=>i.value=!1),class:"px-4 py-2 border border-neutral-300 dark:border-neutral-600 rounded hover:bg-neutral-50 dark:hover:bg-neutral-700"}," Cancel "),g[12]||(g[12]=e("button",{type:"submit",class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Create Key ",-1))])],32)]),_:1},8,["modelValue"]),E(je,{modelValue:n.value,"onUpdate:modelValue":g[7]||(g[7]=m=>n.value=m),title:"API Key Created",onClose:g[8]||(g[8]=m=>n.value=!1)},{default:de(()=>[e("div",Um,[g[15]||(g[15]=e("div",{class:"bg-yellow-50 dark:bg-yellow-900/30 border border-yellow-200 dark:border-yellow-800 text-yellow-800 dark:text-yellow-400 px-4 py-3 rounded"},[e("p",{class:"font-semibold"},"Important: Save this key now!"),e("p",{class:"text-sm mt-1"}," You won't be able to see it again. If you lose this key, you'll need to create a new one. ")],-1)),e("div",null,[g[13]||(g[13]=e("label",{class:"block text-sm font-medium mb-2"},"Your new API key:",-1)),e("div",Rm,[e("input",{value:c.value,type:"text",readonly:"",class:"flex-1 px-3 py-2 border border-neutral-300 dark:border-neutral-600 rounded-md dark:bg-neutral-700 font-mono text-sm"},null,8,Nm),e("button",{onClick:g[5]||(g[5]=m=>h(c.value)),class:"px-4 py-2 bg-neutral-200 dark:bg-neutral-700 rounded hover:bg-neutral-300 dark:hover:bg-neutral-600"}," Copy ")])]),e("div",Bm,[g[14]||(g[14]=e("p",{class:"text-sm"}," Use this key in the Authorization header of your API requests: ",-1)),e("code",qm," Authorization: Bearer "+C(c.value),1)]),e("div",Fm,[e("button",{onClick:g[6]||(g[6]=m=>n.value=!1),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Done ")])])]),_:1},8,["modelValue"])]),_:1}))}}),Hm={class:"login-container flex-1 flex items-center justify-center px-4"},Wm={class:"max-w-md w-full space-y-8"},Jm={class:"flex justify-center"},Zm=["src"],Km={class:"bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-700 py-8 px-6 rounded-lg"},Gm={key:0,class:"bg-red-50 dark:bg-red-950 border border-red-500 text-red-700 dark:text-red-400 px-4 py-3"},Xm=["disabled"],Ym={key:0,class:"mt-6"},Qm=se({__name:"LoginView",setup(t){function i(k){if(k.startsWith("/src/")||k.startsWith("data:"))return k;const O=ot();return O==="/"?k.replace("/agents/","/"):k.replace("/agents/",`${O}/`)}const n=i(Xt),u=i(Yt),l=et(),c=ze(),r=v(""),p=v(""),f=v(""),b=v(!1),s=v(!1),d=v(!1),h=v(!1),$=K(()=>h.value?u:n);xe(async()=>{const k=localStorage.getItem("theme");h.value=k==="dark"||!k&&window.matchMedia("(prefers-color-scheme: dark)").matches;const O=c.query.token,D=c.query.error;if(O){localStorage.setItem("auth_token",O),l.push("/");return}D&&(D==="oauth_failed"?f.value="OAuth authentication failed. Please try again.":D==="oauth_not_configured"&&(f.value="OAuth provider is not configured."));try{const F=await fetch(ae("/api/auth/config"));if(F.ok){const X=await F.json();s.value=X.github||!1,d.value=X.google||!1}}catch(F){console.error("Failed to fetch auth config:",F)}});async function g(){f.value="",b.value=!0;try{const k=await fetch(ae("/api/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r.value,password:p.value})}),O=await k.json();k.ok?(localStorage.setItem("auth_token",O.token),l.push("/")):f.value=O.error||"Login failed"}catch{f.value="Network error. Please try again."}finally{b.value=!1}}function m(){window.location.href=ae("/api/auth/oauth/github")}function w(){window.location.href=ae("/api/auth/oauth/google")}return(k,O)=>(o(),a("div",Hm,[e("div",Wm,[e("div",Jm,[e("img",{src:$.value,alt:"AgentBuilder",class:"h-16 pointer-events-none select-none"},null,8,Zm)]),E(tt,{offsetX:8,offsetY:8,intensity:.2,pattern:"crosshatch"},{default:de(()=>[e("div",Km,[e("form",{class:"space-y-6",onSubmit:we(g,["prevent"])},[f.value?(o(),a("div",Gm,C(f.value),1)):L("",!0),E(Ce,{modelValue:r.value,"onUpdate:modelValue":O[0]||(O[0]=D=>r.value=D),label:"Username",type:"text",disabled:b.value,placeholder:"Enter your username"},null,8,["modelValue","disabled"]),E(Ce,{modelValue:p.value,"onUpdate:modelValue":O[1]||(O[1]=D=>p.value=D),label:"Password",type:"password",disabled:b.value,placeholder:"Enter your password"},null,8,["modelValue","disabled"]),e("div",null,[e("button",{type:"submit",disabled:b.value,class:"w-full px-4 py-2.5 bg-neutral-900 text-white dark:bg-neutral-100 dark:text-neutral-900 rounded-md font-medium hover:bg-neutral-800 dark:hover:bg-neutral-200 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"},C(b.value?"Signing in...":"Sign in"),9,Xm)])],32),s.value||d.value?(o(),a("div",Ym,[O[4]||(O[4]=e("div",{class:"relative"},[e("div",{class:"absolute inset-0 flex items-center"},[e("div",{class:"w-full border-t border-neutral-300 dark:border-neutral-600"})]),e("div",{class:"relative flex justify-center text-sm"},[e("span",{class:"px-2 bg-white dark:bg-neutral-900 text-neutral-500 dark:text-neutral-400"},"Or continue with")])],-1)),e("div",{class:le(["mt-6 grid gap-3",s.value&&d.value?"grid-cols-2":"grid-cols-1"])},[s.value?(o(),a("button",{key:0,onClick:m,type:"button",class:"w-full inline-flex justify-center items-center px-4 py-2.5 border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-700 dark:text-neutral-200 rounded-md font-medium hover:bg-neutral-50 dark:hover:bg-neutral-700 transition-colors"},[...O[2]||(O[2]=[e("svg",{class:"h-5 w-5",fill:"currentColor",viewBox:"0 0 20 20"},[e("path",{"fill-rule":"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z","clip-rule":"evenodd"})],-1),e("span",{class:"ml-2"},"GitHub",-1)])])):L("",!0),d.value?(o(),a("button",{key:1,onClick:w,type:"button",class:"w-full inline-flex justify-center items-center px-4 py-2.5 border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-700 dark:text-neutral-200 rounded-md font-medium hover:bg-neutral-50 dark:hover:bg-neutral-700 transition-colors"},[...O[3]||(O[3]=[e("svg",{class:"h-5 w-5",viewBox:"0 0 24 24"},[e("path",{fill:"currentColor",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),e("path",{fill:"currentColor",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),e("path",{fill:"currentColor",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),e("path",{fill:"currentColor",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})],-1),e("span",{class:"ml-2"},"Google",-1)])])):L("",!0)],2)])):L("",!0)])]),_:1})])]))}}),ev={class:"space-y-1"},tv={key:0,class:"block text-sm font-medium"},ov={key:0,class:"text-red-500"},lv=["value","placeholder","disabled"],av={key:1,class:"text-xs text-red-500 dark:text-red-400"},gt=se({__name:"MultilineInput",props:{modelValue:{},label:{},placeholder:{},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","focus","blur"],setup(t,{expose:i,emit:n}){const u=t,l=n,c=v(null),r=K(()=>["w-full px-3 py-2 bg-white dark:bg-black border rounded font-mono text-sm","focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white","transition-colors resize-none overflow-hidden",u.error?"border-red-500 dark:border-red-400":"border-black dark:border-neutral-300",u.disabled?"opacity-50 cursor-not-allowed":""]),p=()=>{const d=c.value;d&&(d.style.height="auto",d.style.height=`${d.scrollHeight+2}px`)},f=d=>{const h=d.target;l("update:modelValue",h.value),p()},b=d=>{l("focus",d)},s=d=>{l("blur",d)};return xe(()=>{p()}),ue(()=>u.modelValue,async()=>{await ge(),p()}),i({textareaRef:c,adjustHeight:p}),(d,h)=>(o(),a("div",ev,[t.label?(o(),a("label",tv,[ye(C(t.label)+" ",1),t.required?(o(),a("span",ov,"*")):L("",!0)])):L("",!0),e("textarea",{ref_key:"textareaRef",ref:c,value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,class:le(r.value),rows:"1",onInput:f,onFocus:b,onBlur:s},null,42,lv),t.error?(o(),a("p",av,C(t.error),1)):L("",!0)]))}}),sv={class:"p-8 space-y-6"},nv={class:"mt-12"},rv={class:"mb-6"},iv={class:"mb-6"},dv={class:"mb-6"},uv={class:"mt-8"},cv={class:"border-2 border-red-500 p-4 h-32 overflow-hidden relative"},pv={class:"mt-12"},mv={class:"mb-6"},vv={class:"border-2 border-accent-500 p-4 h-32 overflow-hidden relative"},fv={class:"mt-12"},hv={class:"mb-6"},gv={class:"mb-6"},bv={class:"mt-12"},xv={class:"mb-6"},yv={class:"mt-2 text-sm"},kv={class:"mb-6"},wv={class:"mt-2 text-sm"},_v={class:"mb-6"},$v={class:"mb-6"},Cv={class:"mt-12"},Vv={class:"mb-6"},Sv={class:"mt-4 p-4 bg-neutral-100 dark:bg-neutral-900 rounded"},Tv={class:"text-xs overflow-x-auto"},Mv=se({__name:"TestView",setup(t){const i=v(""),n=v(""),u=v(""),l=v(`Line 1
15
15
  Line 2
16
- Line 3`),u=v(""),r=v(""),p=v("option2"),f=v(""),b=v(""),n=v(""),d=v([]),h=v(["test1","test2"]),$=v(!1),g=v(!0),m=v(!1),C=v(!1),w=v({type:"object",properties:{},required:[]}),E=v(0);ye(()=>{window.resetJSONSchema=()=>{w.value={type:"object",properties:{},required:[]},E.value++}});const A=[{value:"option1",label:"Option One"},{value:"option2",label:"Option Two"},{value:"option3",label:"Option Three"},{value:"option4",label:"Option Four"}],q=[{value:"item1",label:"Item One",description:"First item description"},{value:"item2",label:"Item Two",description:"Second item description"},{value:"item3",label:"Item Three",description:"Third item description"},{value:"item4",label:"Item Four",description:"Fourth item description"}],J=[{value:"test1",label:"Test Item 1",description:"First test item"},{value:"test2",label:"Test Item 2",description:"Second test item"},{value:"test3",label:"Test Item 3",description:"Third test item"},{value:"test4",label:"Test Item 4",description:"Fourth test item"},{value:"test5",label:"Test Item 5",description:"Fifth test item"}];return(X,P)=>(o(),l("div",vv,[P[30]||(P[30]=e("h1",{class:"text-2xl font-bold"},"Component Test Page",-1)),e("div",null,[I(Ce,{modelValue:i.value,"onUpdate:modelValue":P[0]||(P[0]=_=>i.value=_),label:"Test Label",placeholder:"Enter text..."},null,8,["modelValue"]),e("p",null,V(i.value),1)]),e("div",null,[I(Ce,{modelValue:s.value,"onUpdate:modelValue":P[1]||(P[1]=_=>s.value=_),label:"Email",error:"Invalid email address",required:""},null,8,["modelValue"])]),e("div",fv,[P[18]||(P[18]=e("h2",{class:"text-xl font-bold mb-4"},"MultilineInput Tests",-1)),e("div",hv,[I(ut,{modelValue:c.value,"onUpdate:modelValue":P[2]||(P[2]=_=>c.value=_),label:"Multiline Text",placeholder:"Type multiple lines..."},null,8,["modelValue"]),e("p",null,V(c.value),1)]),e("div",gv,[I(ut,{modelValue:a.value,"onUpdate:modelValue":P[3]||(P[3]=_=>a.value=_),label:"Pre-filled Multiline",placeholder:"Already has content..."},null,8,["modelValue"]),e("pre",null,V(a.value),1)]),e("div",bv,[I(ut,{modelValue:u.value,"onUpdate:modelValue":P[4]||(P[4]=_=>u.value=_),label:"Required Field",error:"This field is required",required:""},null,8,["modelValue"])])]),e("div",null,[I(ge,{modelValue:r.value,"onUpdate:modelValue":P[5]||(P[5]=_=>r.value=_),options:A,label:"Select Option",placeholder:"Choose an option..."},null,8,["modelValue"]),e("p",null,V(r.value),1)]),e("div",null,[I(ge,{modelValue:r.value,"onUpdate:modelValue":P[6]||(P[6]=_=>r.value=_),options:A,label:"Required Select",placeholder:"Please select an option"},null,8,["modelValue"])]),e("div",null,[I(ge,{modelValue:p.value,"onUpdate:modelValue":P[7]||(P[7]=_=>p.value=_),options:A,label:"Disabled Select",disabled:""},null,8,["modelValue"])]),e("div",xv,[P[20]||(P[20]=e("h2",{class:"text-lg font-semibold mb-2"},"Overflow Test",-1)),e("div",yv,[P[19]||(P[19]=e("p",{class:"text-sm text-neutral-600 mb-2"}," This container has overflow:hidden and limited height ",-1)),I(ge,{modelValue:f.value,"onUpdate:modelValue":P[8]||(P[8]=_=>f.value=_),options:A,label:"Select in Overflow Container",placeholder:"Should break out of container..."},null,8,["modelValue"])]),P[21]||(P[21]=e("p",{class:"mt-2 text-sm text-neutral-500"}," The dropdown should appear above the red border (in top layer) ",-1))]),e("div",kv,[P[25]||(P[25]=e("h2",{class:"text-xl font-bold mb-4"},"DropdownList Tests",-1)),e("div",wv,[I(ge,{modelValue:b.value,"onUpdate:modelValue":P[9]||(P[9]=_=>b.value=_),options:q,label:"Select Item",placeholder:"Choose an item..."},null,8,["modelValue"]),e("p",null,V(b.value),1)]),e("div",null,[P[23]||(P[23]=e("h3",{class:"text-lg font-semibold mb-2"},"DropdownList Overflow Test",-1)),e("div",_v,[P[22]||(P[22]=e("p",{class:"text-sm text-neutral-600 mb-2"}," This container has overflow:hidden and limited height ",-1)),I(ge,{modelValue:n.value,"onUpdate:modelValue":P[10]||(P[10]=_=>n.value=_),options:q,label:"Dropdown in Overflow Container",placeholder:"Should use popover API..."},null,8,["modelValue"])]),P[24]||(P[24]=e("p",{class:"mt-2 text-sm text-neutral-500"}," The dropdown should appear above the blue border (using Popover API) ",-1))])]),e("div",$v,[P[26]||(P[26]=e("h2",{class:"text-xl font-bold mb-4"},"MultipleSelectionsInput Tests",-1)),e("div",Cv,[I(lt,{modelValue:d.value,"onUpdate:modelValue":P[11]||(P[11]=_=>d.value=_),options:J,label:"Select Multiple Items",placeholder:"Choose items...","add-label":"Add another"},null,8,["modelValue"]),e("p",null,V(d.value),1)]),e("div",Vv,[I(lt,{modelValue:h.value,"onUpdate:modelValue":P[12]||(P[12]=_=>h.value=_),options:J,label:"Disabled Multiple Select",placeholder:"Cannot select...",disabled:""},null,8,["modelValue"])])]),e("div",Sv,[P[27]||(P[27]=e("h2",{class:"text-xl font-bold mb-4"},"CheckboxInput Tests",-1)),e("div",Tv,[I(Ve,{modelValue:$.value,"onUpdate:modelValue":P[13]||(P[13]=_=>$.value=_),label:"Basic Checkbox"},null,8,["modelValue"]),e("p",Mv," Value: "+V($.value),1)]),e("div",Iv,[I(Ve,{modelValue:g.value,"onUpdate:modelValue":P[14]||(P[14]=_=>g.value=_),label:"Checkbox with Help Text",helpText:"This is helpful information about what this checkbox does. Notice how the checkbox stays aligned with the label.",required:""},null,8,["modelValue"]),e("p",Lv," Value: "+V(g.value),1)]),e("div",Ev,[I(Ve,{modelValue:m.value,"onUpdate:modelValue":P[15]||(P[15]=_=>m.value=_),label:"Disabled Checkbox",helpText:"This checkbox is disabled and cannot be changed.",disabled:""},null,8,["modelValue"])]),e("div",Av,[I(Ve,{modelValue:C.value,"onUpdate:modelValue":P[16]||(P[16]=_=>C.value=_),label:"Checkbox with Error",error:"You must accept the terms and conditions",required:""},null,8,["modelValue"])])]),e("div",Pv,[P[29]||(P[29]=e("h2",{class:"text-xl font-bold mb-4"},"JSONSchemaInput Tests",-1)),e("div",Ov,[(o(),Q(Qt,{key:E.value,modelValue:w.value,"onUpdate:modelValue":P[17]||(P[17]=_=>w.value=_),label:"JSON Schema Builder"},null,8,["modelValue"])),e("div",jv,[P[28]||(P[28]=e("p",{class:"text-sm font-mono mb-2"},"Generated Schema:",-1)),e("pre",Dv,V(JSON.stringify(w.value,null,2)),1)])])])]))}}),Nv={class:"relative"},Rv=["value","placeholder","rows"],Bv={class:"bg-white dark:bg-black rounded-lg"},qv={class:"px-3 py-2 border-b border-black dark:border-neutral-300"},Fv={class:"text-xs font-medium text-neutral-600 dark:text-neutral-400"},zv={key:0,class:"max-h-[200px] overflow-y-auto"},Hv=["onClick"],Wv={class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},Jv={class:"flex-1"},Zv={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-0.5"},Kv={key:1,class:"px-3 py-4 text-sm text-neutral-500 dark:text-neutral-400 text-center"},Gv=se({__name:"ReferenceInput",props:{modelValue:{},search:{type:Function},placeholder:{},rows:{}},emits:["update:modelValue"],setup(t,{emit:i}){const s=t,c=i,a=v(null),u=v(null),r=v(!1),p=v(""),f=v([]),b=v(0),n=v(-1),d=v(-1),h=v(0),$=v({top:0,left:0}),g=async _=>{const O=_.target,D=O.value,N=O.selectionStart;c("update:modelValue",D),D[N-1]==="@"&&!r.value?m(N):r.value&&await w(D,N)},m=async _=>{n.value=_-1,d.value=_,p.value="",h.value=0,r.value=!0,b.value=0,await C(),await E("")},C=async()=>{if(!a.value)return;await xe();const _=a.value.getBoundingClientRect(),O=window.getComputedStyle(a.value),D=parseInt(O.lineHeight||"20"),N=parseInt(O.paddingTop||"8"),L=s.modelValue.substring(0,d.value).split(`
17
- `),T=L.length,j=L[L.length-1],x=Math.min(j.length*8,200);$.value={top:_.top+N+T*D+4,left:_.left+N+x}},w=async(_,O)=>{if(O<=n.value){q();return}const D=n.value+1,N=_.substring(D,O);if(f.value.length===0?h.value++:h.value=0,f.value.length===0&&h.value>=5){q();return}p.value=N,await E(N)},E=async _=>{if(!s.search){f.value=[];return}const O=await s.search(_);f.value=Array.isArray(O)?O:[],b.value>=f.value.length&&(b.value=0)},A=_=>{if(!a.value)return;const O=s.modelValue,D=O.substring(0,n.value),N=O.substring(d.value+p.value.length),U=`@${_.value}`,L=D+U+N;c("update:modelValue",L),xe(()=>{if(!a.value)return;const T=D.length+U.length;a.value.focus(),a.value.setSelectionRange(T,T)}),q()},q=()=>{r.value=!1,p.value="",f.value=[],b.value=0,n.value=-1,d.value=-1,h.value=0},J=_=>{if(r.value)switch(_.key){case"Escape":_.preventDefault(),q();break;case"ArrowDown":_.preventDefault(),b.value=Math.min(b.value+1,f.value.length-1);break;case"ArrowUp":_.preventDefault(),b.value=Math.max(b.value-1,0);break;case"Enter":f.value.length>0&&(_.preventDefault(),A(f.value[b.value]));break;case"Tab":f.value.length>0&&(_.preventDefault(),A(f.value[b.value]));break}},X=()=>{if(!r.value||!a.value)return;a.value.selectionStart<=n.value&&q()},P=_=>{if(!u.value||!r.value)return;const O=_.target;!u.value.contains(O)&&O!==a.value&&q()};return ie(r,_=>{_?document.addEventListener("click",P):document.removeEventListener("click",P)}),(_,O)=>(o(),l("div",Nv,[e("textarea",{ref_key:"textarea",ref:a,value:t.modelValue,onInput:g,onKeydown:J,onSelect:X,placeholder:t.placeholder||"Type @ to insert references...",rows:t.rows||10,class:"w-full px-3 py-2 border border-black dark:border-neutral-300 rounded bg-transparent font-mono text-sm resize-none focus:outline-none focus:ring-1 focus:ring-black dark:focus:ring-white"},null,40,Rv),(o(),Q(ht,{to:"body"},[r.value?(o(),l("div",{key:0,ref_key:"searchDialog",ref:u,class:"fixed z-50 min-w-[200px] max-w-[400px] bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded-lg",style:st({top:`${$.value.top}px`,left:`${$.value.left}px`,boxShadow:"4px 4px 0 0 rgba(0, 0, 0, 0.25)",backgroundImage:`
16
+ Line 3`),c=v(""),r=v(""),p=v("option2"),f=v(""),b=v(""),s=v(""),d=v([]),h=v(["test1","test2"]),$=v(!1),g=v(!0),m=v(!1),w=v(!1),k=v({type:"object",properties:{},required:[]}),O=v(0);xe(()=>{window.resetJSONSchema=()=>{k.value={type:"object",properties:{},required:[]},O.value++}});const D=[{value:"option1",label:"Option One"},{value:"option2",label:"Option Two"},{value:"option3",label:"Option Three"},{value:"option4",label:"Option Four"}],F=[{value:"item1",label:"Item One",description:"First item description"},{value:"item2",label:"Item Two",description:"Second item description"},{value:"item3",label:"Item Three",description:"Third item description"},{value:"item4",label:"Item Four",description:"Fourth item description"}],X=[{value:"test1",label:"Test Item 1",description:"First test item"},{value:"test2",label:"Test Item 2",description:"Second test item"},{value:"test3",label:"Test Item 3",description:"Third test item"},{value:"test4",label:"Test Item 4",description:"Fourth test item"},{value:"test5",label:"Test Item 5",description:"Fifth test item"}];return(te,R)=>(o(),a("div",sv,[R[30]||(R[30]=e("h1",{class:"text-2xl font-bold"},"Component Test Page",-1)),e("div",null,[E(Ce,{modelValue:i.value,"onUpdate:modelValue":R[0]||(R[0]=j=>i.value=j),label:"Test Label",placeholder:"Enter text..."},null,8,["modelValue"]),e("p",null,C(i.value),1)]),e("div",null,[E(Ce,{modelValue:n.value,"onUpdate:modelValue":R[1]||(R[1]=j=>n.value=j),label:"Email",error:"Invalid email address",required:""},null,8,["modelValue"])]),e("div",nv,[R[18]||(R[18]=e("h2",{class:"text-xl font-bold mb-4"},"MultilineInput Tests",-1)),e("div",rv,[E(gt,{modelValue:u.value,"onUpdate:modelValue":R[2]||(R[2]=j=>u.value=j),label:"Multiline Text",placeholder:"Type multiple lines..."},null,8,["modelValue"]),e("p",null,C(u.value),1)]),e("div",iv,[E(gt,{modelValue:l.value,"onUpdate:modelValue":R[3]||(R[3]=j=>l.value=j),label:"Pre-filled Multiline",placeholder:"Already has content..."},null,8,["modelValue"]),e("pre",null,C(l.value),1)]),e("div",dv,[E(gt,{modelValue:c.value,"onUpdate:modelValue":R[4]||(R[4]=j=>c.value=j),label:"Required Field",error:"This field is required",required:""},null,8,["modelValue"])])]),e("div",null,[E(he,{modelValue:r.value,"onUpdate:modelValue":R[5]||(R[5]=j=>r.value=j),options:D,label:"Select Option",placeholder:"Choose an option..."},null,8,["modelValue"]),e("p",null,C(r.value),1)]),e("div",null,[E(he,{modelValue:r.value,"onUpdate:modelValue":R[6]||(R[6]=j=>r.value=j),options:D,label:"Required Select",placeholder:"Please select an option"},null,8,["modelValue"])]),e("div",null,[E(he,{modelValue:p.value,"onUpdate:modelValue":R[7]||(R[7]=j=>p.value=j),options:D,label:"Disabled Select",disabled:""},null,8,["modelValue"])]),e("div",uv,[R[20]||(R[20]=e("h2",{class:"text-lg font-semibold mb-2"},"Overflow Test",-1)),e("div",cv,[R[19]||(R[19]=e("p",{class:"text-sm text-neutral-600 mb-2"}," This container has overflow:hidden and limited height ",-1)),E(he,{modelValue:f.value,"onUpdate:modelValue":R[8]||(R[8]=j=>f.value=j),options:D,label:"Select in Overflow Container",placeholder:"Should break out of container..."},null,8,["modelValue"])]),R[21]||(R[21]=e("p",{class:"mt-2 text-sm text-neutral-500"}," The dropdown should appear above the red border (in top layer) ",-1))]),e("div",pv,[R[25]||(R[25]=e("h2",{class:"text-xl font-bold mb-4"},"DropdownList Tests",-1)),e("div",mv,[E(he,{modelValue:b.value,"onUpdate:modelValue":R[9]||(R[9]=j=>b.value=j),options:F,label:"Select Item",placeholder:"Choose an item..."},null,8,["modelValue"]),e("p",null,C(b.value),1)]),e("div",null,[R[23]||(R[23]=e("h3",{class:"text-lg font-semibold mb-2"},"DropdownList Overflow Test",-1)),e("div",vv,[R[22]||(R[22]=e("p",{class:"text-sm text-neutral-600 mb-2"}," This container has overflow:hidden and limited height ",-1)),E(he,{modelValue:s.value,"onUpdate:modelValue":R[10]||(R[10]=j=>s.value=j),options:F,label:"Dropdown in Overflow Container",placeholder:"Should use popover API..."},null,8,["modelValue"])]),R[24]||(R[24]=e("p",{class:"mt-2 text-sm text-neutral-500"}," The dropdown should appear above the blue border (using Popover API) ",-1))])]),e("div",fv,[R[26]||(R[26]=e("h2",{class:"text-xl font-bold mb-4"},"MultipleSelectionsInput Tests",-1)),e("div",hv,[E(ct,{modelValue:d.value,"onUpdate:modelValue":R[11]||(R[11]=j=>d.value=j),options:X,label:"Select Multiple Items",placeholder:"Choose items...","add-label":"Add another"},null,8,["modelValue"]),e("p",null,C(d.value),1)]),e("div",gv,[E(ct,{modelValue:h.value,"onUpdate:modelValue":R[12]||(R[12]=j=>h.value=j),options:X,label:"Disabled Multiple Select",placeholder:"Cannot select...",disabled:""},null,8,["modelValue"])])]),e("div",bv,[R[27]||(R[27]=e("h2",{class:"text-xl font-bold mb-4"},"CheckboxInput Tests",-1)),e("div",xv,[E(Te,{modelValue:$.value,"onUpdate:modelValue":R[13]||(R[13]=j=>$.value=j),label:"Basic Checkbox"},null,8,["modelValue"]),e("p",yv," Value: "+C($.value),1)]),e("div",kv,[E(Te,{modelValue:g.value,"onUpdate:modelValue":R[14]||(R[14]=j=>g.value=j),label:"Checkbox with Help Text",helpText:"This is helpful information about what this checkbox does. Notice how the checkbox stays aligned with the label.",required:""},null,8,["modelValue"]),e("p",wv," Value: "+C(g.value),1)]),e("div",_v,[E(Te,{modelValue:m.value,"onUpdate:modelValue":R[15]||(R[15]=j=>m.value=j),label:"Disabled Checkbox",helpText:"This checkbox is disabled and cannot be changed.",disabled:""},null,8,["modelValue"])]),e("div",$v,[E(Te,{modelValue:w.value,"onUpdate:modelValue":R[16]||(R[16]=j=>w.value=j),label:"Checkbox with Error",error:"You must accept the terms and conditions",required:""},null,8,["modelValue"])])]),e("div",Cv,[R[29]||(R[29]=e("h2",{class:"text-xl font-bold mb-4"},"JSONSchemaInput Tests",-1)),e("div",Vv,[(o(),ee(lo,{key:O.value,modelValue:k.value,"onUpdate:modelValue":R[17]||(R[17]=j=>k.value=j),label:"JSON Schema Builder"},null,8,["modelValue"])),e("div",Sv,[R[28]||(R[28]=e("p",{class:"text-sm font-mono mb-2"},"Generated Schema:",-1)),e("pre",Tv,C(JSON.stringify(k.value,null,2)),1)])])])]))}}),Lv={class:"relative"},Iv=["value","placeholder","rows"],Ev={class:"bg-white dark:bg-black rounded-lg"},Av={class:"px-3 py-2 border-b border-black dark:border-neutral-300"},Pv={class:"text-xs font-medium text-neutral-600 dark:text-neutral-400"},Ov={key:0,class:"max-h-[200px] overflow-y-auto"},jv=["onClick"],Dv={class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},Uv={class:"flex-1"},Rv={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-0.5"},Nv={key:1,class:"px-3 py-4 text-sm text-neutral-500 dark:text-neutral-400 text-center"},Bv=se({__name:"ReferenceInput",props:{modelValue:{},search:{type:Function},placeholder:{},rows:{}},emits:["update:modelValue"],setup(t,{emit:i}){const n=t,u=i,l=v(null),c=v(null),r=v(!1),p=v(""),f=v([]),b=v(0),s=v(-1),d=v(-1),h=v(0),$=v({top:0,left:0}),g=async j=>{const W=j.target,B=W.value,N=W.selectionStart;u("update:modelValue",B),B[N-1]==="@"&&!r.value?m(N):r.value&&await k(B,N)},m=async j=>{s.value=j-1,d.value=j,p.value="",h.value=0,r.value=!0,b.value=0,await w(),await O("")},w=async()=>{if(!l.value)return;await ge();const j=l.value.getBoundingClientRect(),W=window.getComputedStyle(l.value),B=parseInt(W.lineHeight||"20"),N=parseInt(W.paddingTop||"8"),y=n.modelValue.substring(0,d.value).split(`
17
+ `),x=y.length,V=y[y.length-1],T=Math.min(V.length*8,200);$.value={top:j.top+N+x*B+4,left:j.left+N+T}},k=async(j,W)=>{if(W<=s.value){F();return}const B=s.value+1,N=j.substring(B,W);if(f.value.length===0?h.value++:h.value=0,f.value.length===0&&h.value>=5){F();return}p.value=N,await O(N)},O=async j=>{if(!n.search){f.value=[];return}const W=await n.search(j);f.value=Array.isArray(W)?W:[],b.value>=f.value.length&&(b.value=0)},D=j=>{if(!l.value)return;const W=n.modelValue,B=W.substring(0,s.value),N=W.substring(d.value+p.value.length),U=`@${j.value}`,y=B+U+N;u("update:modelValue",y),ge(()=>{if(!l.value)return;const x=B.length+U.length;l.value.focus(),l.value.setSelectionRange(x,x)}),F()},F=()=>{r.value=!1,p.value="",f.value=[],b.value=0,s.value=-1,d.value=-1,h.value=0},X=j=>{if(r.value)switch(j.key){case"Escape":j.preventDefault(),F();break;case"ArrowDown":j.preventDefault(),b.value=Math.min(b.value+1,f.value.length-1);break;case"ArrowUp":j.preventDefault(),b.value=Math.max(b.value-1,0);break;case"Enter":f.value.length>0&&(j.preventDefault(),D(f.value[b.value]));break;case"Tab":f.value.length>0&&(j.preventDefault(),D(f.value[b.value]));break}},te=()=>{if(!r.value||!l.value)return;l.value.selectionStart<=s.value&&F()},R=j=>{if(!c.value||!r.value)return;const W=j.target;!c.value.contains(W)&&W!==l.value&&F()};return ue(r,j=>{j?document.addEventListener("click",R):document.removeEventListener("click",R)}),(j,W)=>(o(),a("div",Lv,[e("textarea",{ref_key:"textarea",ref:l,value:t.modelValue,onInput:g,onKeydown:X,onSelect:te,placeholder:t.placeholder||"Type @ to insert references...",rows:t.rows||10,class:"w-full px-3 py-2 border border-black dark:border-neutral-300 rounded bg-transparent font-mono text-sm resize-none focus:outline-none focus:ring-1 focus:ring-black dark:focus:ring-white"},null,40,Iv),(o(),ee(_t,{to:"body"},[r.value?(o(),a("div",{key:0,ref_key:"searchDialog",ref:c,class:"fixed z-50 min-w-[200px] max-w-[400px] bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded-lg",style:pt({top:`${$.value.top}px`,left:`${$.value.left}px`,boxShadow:"4px 4px 0 0 rgba(0, 0, 0, 0.25)",backgroundImage:`
18
18
  repeating-linear-gradient(
19
19
  45deg,
20
20
  transparent,
@@ -22,18 +22,18 @@ Line 3`),u=v(""),r=v(""),p=v("option2"),f=v(""),b=v(""),n=v(""),d=v([]),h=v(["te
22
22
  rgba(0, 0, 0, 0.03) 2px,
23
23
  rgba(0, 0, 0, 0.03) 4px
24
24
  )
25
- `})},[e("div",Bv,[e("div",qv,[e("div",Fv," Search: "+V(p.value||"..."),1)]),f.value.length>0?(o(),l("div",zv,[(o(!0),l(ce,null,fe(f.value,(D,N)=>(o(),l("button",{key:`${D.type}-${D.value}`,onClick:U=>A(D),class:oe(["w-full px-3 py-2 text-left hover:bg-black/5 dark:hover:bg-white/10 transition-colors flex items-start gap-2 text-sm",{"bg-black/10 dark:bg-white/10":N===b.value}])},[e("span",Wv,V(D.type),1),e("div",Jv,[e("div",null,V(D.label),1),D.description?(o(),l("div",Zv,V(D.description),1)):M("",!0)])],10,Hv))),128))])):(o(),l("div",Kv," No results found ")),O[0]||(O[0]=e("div",{class:"px-3 py-2 border-t border-neutral-200 dark:border-neutral-700 text-xs text-neutral-500 dark:text-neutral-400"},[e("div",null,"↑↓ Navigate • Enter/Tab Select • Esc Cancel")],-1))])],4)):M("",!0)]))]))}}),Xv={class:"min-h-screen bg-white dark:bg-black p-8"},Yv={class:"max-w-4xl mx-auto space-y-8"},Qv={class:"space-y-4"},ef={class:"block"},tf={class:"p-4 border border-neutral-300 dark:border-neutral-700 rounded"},of={class:"text-sm font-mono whitespace-pre-wrap"},af=se({__name:"TestReferenceInput",setup(t){const i=v("Hello, type @ to see search suggestions"),s=async c=>{await new Promise(u=>setTimeout(u,100));const a=[{type:"variable",value:"userName",label:"userName",description:"Current user name"},{type:"variable",value:"userEmail",label:"userEmail",description:"Current user email"},{type:"function",value:"getCurrentDate()",label:"getCurrentDate",description:"Get current date"},{type:"prompt",value:"{{prompt:welcome}}",label:"welcome",description:"Welcome message prompt"},{type:"prompt",value:"{{prompt:goodbye}}",label:"goodbye",description:"Goodbye message prompt"}];return c?a.filter(u=>u.label.toLowerCase().includes(c.toLowerCase())):a};return(c,a)=>(o(),l("div",Xv,[e("div",Yv,[a[4]||(a[4]=e("div",null,[e("h1",{class:"text-2xl font-bold mb-2"},"ReferenceInput Component Test"),e("p",{class:"text-neutral-600 dark:text-neutral-400"}," Type @ to trigger search mode and test the reference input functionality ")],-1)),e("div",Qv,[e("label",ef,[a[1]||(a[1]=e("span",{class:"text-sm font-medium mb-2 block"},"Test Reference Input",-1)),I(Gv,{modelValue:i.value,"onUpdate:modelValue":a[0]||(a[0]=u=>i.value=u),search:s,placeholder:"Type @ to insert references...",rows:10},null,8,["modelValue"])]),e("div",tf,[a[2]||(a[2]=e("h3",{class:"text-sm font-medium mb-2"},"Current Value:",-1)),e("pre",of,V(i.value),1)]),a[3]||(a[3]=e("div",{class:"p-4 bg-neutral-100 dark:bg-neutral-900 rounded"},[e("h3",{class:"text-sm font-medium mb-2"},"Test Instructions:"),e("ul",{class:"text-sm space-y-1 list-disc list-inside"},[e("li",null,"Type @ anywhere in the textarea to trigger search mode"),e("li",null,"Type characters after @ to filter results"),e("li",null,"Use arrow keys to navigate results"),e("li",null,"Press Enter or Tab to select a result"),e("li",null,"Press Escape to cancel search mode"),e("li",null,"Search exits if no results and you type 5+ more characters"),e("li",null,"Moving cursor before @ also exits search mode")])],-1))])])]))}}),lf={class:"p-8 space-y-8"},sf={class:"space-y-2 mb-4"},nf={class:"mt-4 p-2 bg-neutral-100 rounded"},rf=se({__name:"DebugView",setup(t){const i=v([{id:"1",name:"Item 1"}]),s=()=>{console.log("Adding item...");const u={id:crypto.randomUUID(),name:`Item ${i.value.length+1}`};i.value.push(u),console.log("Item added, total:",i.value.length)};ie(i,()=>{console.log("Items changed:",i.value.length)},{deep:!0});const c={props:["modelValue"],emits:["update:modelValue"],template:`
25
+ `})},[e("div",Ev,[e("div",Av,[e("div",Pv," Search: "+C(p.value||"..."),1)]),f.value.length>0?(o(),a("div",Ov,[(o(!0),a(pe,null,fe(f.value,(B,N)=>(o(),a("button",{key:`${B.type}-${B.value}`,onClick:U=>D(B),class:le(["w-full px-3 py-2 text-left hover:bg-black/5 dark:hover:bg-white/10 transition-colors flex items-start gap-2 text-sm",{"bg-black/10 dark:bg-white/10":N===b.value}])},[e("span",Dv,C(B.type),1),e("div",Uv,[e("div",null,C(B.label),1),B.description?(o(),a("div",Rv,C(B.description),1)):L("",!0)])],10,jv))),128))])):(o(),a("div",Nv," No results found ")),W[0]||(W[0]=e("div",{class:"px-3 py-2 border-t border-neutral-200 dark:border-neutral-700 text-xs text-neutral-500 dark:text-neutral-400"},[e("div",null,"↑↓ Navigate • Enter/Tab Select • Esc Cancel")],-1))])],4)):L("",!0)]))]))}}),qv={class:"min-h-screen bg-white dark:bg-black p-8"},Fv={class:"max-w-4xl mx-auto space-y-8"},zv={class:"space-y-4"},Hv={class:"block"},Wv={class:"p-4 border border-neutral-300 dark:border-neutral-700 rounded"},Jv={class:"text-sm font-mono whitespace-pre-wrap"},Zv=se({__name:"TestReferenceInput",setup(t){const i=v("Hello, type @ to see search suggestions"),n=async u=>{await new Promise(c=>setTimeout(c,100));const l=[{type:"variable",value:"userName",label:"userName",description:"Current user name"},{type:"variable",value:"userEmail",label:"userEmail",description:"Current user email"},{type:"function",value:"getCurrentDate()",label:"getCurrentDate",description:"Get current date"},{type:"prompt",value:"{{prompt:welcome}}",label:"welcome",description:"Welcome message prompt"},{type:"prompt",value:"{{prompt:goodbye}}",label:"goodbye",description:"Goodbye message prompt"}];return u?l.filter(c=>c.label.toLowerCase().includes(u.toLowerCase())):l};return(u,l)=>(o(),a("div",qv,[e("div",Fv,[l[4]||(l[4]=e("div",null,[e("h1",{class:"text-2xl font-bold mb-2"},"ReferenceInput Component Test"),e("p",{class:"text-neutral-600 dark:text-neutral-400"}," Type @ to trigger search mode and test the reference input functionality ")],-1)),e("div",zv,[e("label",Hv,[l[1]||(l[1]=e("span",{class:"text-sm font-medium mb-2 block"},"Test Reference Input",-1)),E(Bv,{modelValue:i.value,"onUpdate:modelValue":l[0]||(l[0]=c=>i.value=c),search:n,placeholder:"Type @ to insert references...",rows:10},null,8,["modelValue"])]),e("div",Wv,[l[2]||(l[2]=e("h3",{class:"text-sm font-medium mb-2"},"Current Value:",-1)),e("pre",Jv,C(i.value),1)]),l[3]||(l[3]=e("div",{class:"p-4 bg-neutral-100 dark:bg-neutral-900 rounded"},[e("h3",{class:"text-sm font-medium mb-2"},"Test Instructions:"),e("ul",{class:"text-sm space-y-1 list-disc list-inside"},[e("li",null,"Type @ anywhere in the textarea to trigger search mode"),e("li",null,"Type characters after @ to filter results"),e("li",null,"Use arrow keys to navigate results"),e("li",null,"Press Enter or Tab to select a result"),e("li",null,"Press Escape to cancel search mode"),e("li",null,"Search exits if no results and you type 5+ more characters"),e("li",null,"Moving cursor before @ also exits search mode")])],-1))])])]))}}),Kv={class:"p-8 space-y-8"},Gv={class:"space-y-2 mb-4"},Xv={class:"mt-4 p-2 bg-neutral-100 rounded"},Yv=se({__name:"DebugView",setup(t){const i=v([{id:"1",name:"Item 1"}]),n=()=>{console.log("Adding item...");const c={id:crypto.randomUUID(),name:`Item ${i.value.length+1}`};i.value.push(c),console.log("Item added, total:",i.value.length)};ue(i,()=>{console.log("Items changed:",i.value.length)},{deep:!0});const u={props:["modelValue"],emits:["update:modelValue"],template:`
26
26
  <div>
27
27
  <div v-for="item in modelValue" :key="item.id">
28
28
  {{ item.name }}
29
29
  </div>
30
30
  <button @click="addChild">Add in Child</button>
31
31
  </div>
32
- `,setup(u,{emit:r}){return{addChild:()=>{console.log("Child adding item...");const f={id:crypto.randomUUID(),name:`Child Item ${u.modelValue.length+1}`};r("update:modelValue",[...u.modelValue,f])}}}},a=v([{id:"1",name:"Parent Item 1"}]);return(u,r)=>(o(),l("div",lf,[e("div",null,[r[1]||(r[1]=e("h2",{class:"text-xl font-bold mb-4"},"Direct Array Test",-1)),e("div",sf,[(o(!0),l(ce,null,fe(i.value,p=>(o(),l("div",{key:p.id,class:"p-2 border"},V(p.name),1))),128))]),e("button",{onClick:s,class:"px-4 py-2 bg-black text-white rounded"}," Add Item ")]),e("div",null,[r[2]||(r[2]=e("h2",{class:"text-xl font-bold mb-4"},"Parent-Child Test",-1)),I(c,{modelValue:a.value,"onUpdate:modelValue":r[0]||(r[0]=p=>a.value=p)},null,8,["modelValue"]),e("pre",nf,V(JSON.stringify(a.value,null,2)),1)])]))}}),df={class:"min-h-screen bg-white dark:bg-black p-8"},uf={class:"max-w-4xl mx-auto"},cf={class:"space-y-8"},pf={class:"space-y-4"},mf={class:"space-y-4"},vf={class:"p-4 bg-neutral-100 dark:bg-neutral-900 rounded-lg"},ff={class:"text-sm text-black dark:text-white"},hf=se({__name:"TestPromptInput",setup(t){const i=v([{type:"string",value:""}]),s=r=>{i.value=r};ye(()=>{window.setPromptSegments=s}),Co(()=>{delete window.setPromptSegments});const c=async r=>{await new Promise(b=>setTimeout(b,300));const p=(r||"").toLowerCase();return[{type:"variable",value:"first_name",label:"First Name",description:"The user's first name"},{type:"variable",value:"current_date",label:"current_date",description:"Today's date in ISO format"},{type:"variable",value:"system_time",label:"system_time",description:"Current system time"},{type:"variable",value:"api_key",label:"api_key",description:"API key for external services"},{type:"variable",value:"workspace_id",label:"workspace_id",description:"Current workspace identifier"},{type:"prompt",id:"7102973",label:"Onboarding Prompt",schema:{type:"object",properties:{first_name:{type:"string",description:"the first name of the user"}},required:["first_name"],additionalProperties:!1}},{type:"prompt",id:"error_handler",label:"Error Handler",description:"Error handling prompt",schema:{type:"object",properties:{error_message:{type:"string"}},required:["error_message"]}},{type:"prompt",id:"code_review",label:"Code Review",description:"Code review assistant prompt"},{type:"prompt",id:"data_analysis",label:"Data Analysis",description:"Data analysis insights generator"},{type:"prompt",id:"summary_generator",label:"Summary Generator",description:"Creates concise summaries of long text"}].filter(b=>(b.label||b.id||b.value||"").toLowerCase().includes(p)).slice(0,8)},a=r=>{i.value=r,console.log("Updated:",r)},u=(r,p)=>{console.log("Segment clicked:",r),r.type==="prompt"?alert(`Prompt clicked: ${r.label||r.id}
32
+ `,setup(c,{emit:r}){return{addChild:()=>{console.log("Child adding item...");const f={id:crypto.randomUUID(),name:`Child Item ${c.modelValue.length+1}`};r("update:modelValue",[...c.modelValue,f])}}}},l=v([{id:"1",name:"Parent Item 1"}]);return(c,r)=>(o(),a("div",Kv,[e("div",null,[r[1]||(r[1]=e("h2",{class:"text-xl font-bold mb-4"},"Direct Array Test",-1)),e("div",Gv,[(o(!0),a(pe,null,fe(i.value,p=>(o(),a("div",{key:p.id,class:"p-2 border"},C(p.name),1))),128))]),e("button",{onClick:n,class:"px-4 py-2 bg-black text-white rounded"}," Add Item ")]),e("div",null,[r[2]||(r[2]=e("h2",{class:"text-xl font-bold mb-4"},"Parent-Child Test",-1)),E(u,{modelValue:l.value,"onUpdate:modelValue":r[0]||(r[0]=p=>l.value=p)},null,8,["modelValue"]),e("pre",Xv,C(JSON.stringify(l.value,null,2)),1)])]))}}),Qv={class:"min-h-screen bg-white dark:bg-black p-8"},ef={class:"max-w-4xl mx-auto"},tf={class:"space-y-8"},of={class:"space-y-4"},lf={class:"space-y-4"},af={class:"p-4 bg-neutral-100 dark:bg-neutral-900 rounded-lg"},sf={class:"text-sm text-black dark:text-white"},nf=se({__name:"TestPromptInput",setup(t){const i=v([{type:"string",value:""}]),n=r=>{i.value=r};xe(()=>{window.setPromptSegments=n}),Vo(()=>{delete window.setPromptSegments});const u=async r=>{await new Promise(b=>setTimeout(b,300));const p=(r||"").toLowerCase();return[{type:"variable",value:"first_name",label:"First Name",description:"The user's first name"},{type:"variable",value:"current_date",label:"current_date",description:"Today's date in ISO format"},{type:"variable",value:"system_time",label:"system_time",description:"Current system time"},{type:"variable",value:"api_key",label:"api_key",description:"API key for external services"},{type:"variable",value:"workspace_id",label:"workspace_id",description:"Current workspace identifier"},{type:"prompt",id:"7102973",label:"Onboarding Prompt",schema:{type:"object",properties:{first_name:{type:"string",description:"the first name of the user"}},required:["first_name"],additionalProperties:!1}},{type:"prompt",id:"error_handler",label:"Error Handler",description:"Error handling prompt",schema:{type:"object",properties:{error_message:{type:"string"}},required:["error_message"]}},{type:"prompt",id:"code_review",label:"Code Review",description:"Code review assistant prompt"},{type:"prompt",id:"data_analysis",label:"Data Analysis",description:"Data analysis insights generator"},{type:"prompt",id:"summary_generator",label:"Summary Generator",description:"Creates concise summaries of long text"}].filter(b=>(b.label||b.id||b.value||"").toLowerCase().includes(p)).slice(0,8)},l=r=>{i.value=r,console.log("Updated:",r)},c=(r,p)=>{console.log("Segment clicked:",r),r.type==="prompt"?alert(`Prompt clicked: ${r.label||r.id}
33
33
 
34
34
  In a real app, this could:
35
35
  - Show a modal with prompt details
36
36
  - Expand inline to show the full prompt
37
37
  - Navigate to the prompt editor`):r.type==="variable"&&alert(`Variable clicked: ${r.label||r.value}
38
38
 
39
- Description: ${r.meta?.description||"No description"}`)};return(r,p)=>(o(),l("div",df,[e("div",uf,[p[5]||(p[5]=e("h1",{class:"text-3xl font-bold mb-8 text-black dark:text-white"}," PromptInput Component Test ",-1)),e("div",cf,[e("div",pf,[p[0]||(p[0]=e("h2",{class:"text-xl font-semibold text-black dark:text-white"}," Basic Usage ",-1)),p[1]||(p[1]=e("p",{class:"text-neutral-600 dark:text-neutral-400"}," Type @ to trigger the autocomplete menu. Use arrow keys to navigate and Enter to select. ",-1)),e("div",null,[I(eo,{"model-value":i.value,search:c,placeholder:"Type @ to insert variables or prompts...","onUpdate:modelValue":a,onSegmentClick:u},null,8,["model-value"])])]),e("div",mf,[p[3]||(p[3]=e("h2",{class:"text-xl font-semibold text-black dark:text-white"}," Current Value ",-1)),e("div",vf,[p[2]||(p[2]=e("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300 mb-2"}," Segments (value): ",-1)),e("pre",ff,V(JSON.stringify(i.value,null,2)),1)])]),p[4]||(p[4]=Vo('<div class="space-y-4"><h2 class="text-xl font-semibold text-black dark:text-white"> Testing Instructions </h2><ul class="list-disc list-inside space-y-2 text-neutral-600 dark:text-neutral-400"><li>Type @ anywhere in the text to open the search dialog</li><li>Continue typing to search for variables or prompts</li><li>Use arrow keys (↑↓) to navigate results</li><li>Press Enter to select a result or click with mouse</li><li>Press Escape to close the dialog</li><li>Click outside the dialog to close it</li><li>Use Backspace/Delete to remove tags</li><li> The dialog will auto-close after typing 5+ characters without selection </li><li><strong>NEW: Click on any tag to see action handling!</strong></li></ul></div><div class="space-y-4"><h2 class="text-xl font-semibold text-black dark:text-white"> Test Scenarios </h2><div class="grid grid-cols-1 md:grid-cols-2 gap-4"><div class="p-4 border-2 border-neutral-300 dark:border-neutral-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2"> Variables </h3><p class="text-sm text-neutral-600 dark:text-neutral-400"> Try: @user, @date, @time, @api, @work </p></div><div class="p-4 border-2 border-neutral-300 dark:border-neutral-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2"> Prompts </h3><p class="text-sm text-neutral-600 dark:text-neutral-400"> Try: @greet, @error, @code, @data, @summ </p></div><div class="p-4 border-2 border-neutral-300 dark:border-neutral-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2"> Mixed Content </h3><p class="text-sm text-neutral-600 dark:text-neutral-400"> Mix text with multiple tags and test editing </p></div><div class="p-4 border-2 border-neutral-300 dark:border-neutral-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2"> Edge Cases </h3><p class="text-sm text-neutral-600 dark:text-neutral-400"> Test @ at start/end, multiple @@ symbols, etc. </p></div></div></div>',2))])])]))}}),gf={class:"relative"},bf={key:0,class:"mt-1 text-sm text-red-500"},xf=se({__name:"JsonEditor",props:{modelValue:{},placeholder:{},error:{},rows:{},readonly:{type:Boolean}},emits:["update:modelValue","blur"],setup(t,{emit:i}){self.MonacoEnvironment={getWorker($,g){return g==="json"?new Lo:new Eo}};const s=t,c=i,a=v(null);let u=null,r=!1;const p=v(!1),f={minimap:{enabled:!1},fontSize:14,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:24,padding:{top:12,bottom:12},scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,readOnly:s.readonly,quickSuggestions:{other:"on",comments:"off",strings:"on"},suggestOnTriggerCharacters:!0,acceptSuggestionOnCommitCharacter:!0,tabSize:2,detectIndentation:!1,renderLineHighlight:"none",scrollbar:{vertical:"auto",horizontal:"hidden",verticalScrollbarSize:10}},b=()=>{if(!(!u||s.readonly))try{const $=u.getValue(),g=JSON.parse($),m=JSON.stringify(g,null,2);m!==$&&(r=!0,u.setValue(m),r=!1)}catch{}},n=()=>{p.value=document.documentElement.classList.contains("dark"),u&&Vt.setTheme(p.value?"vs-dark":"vs")},d=()=>{a.value&&(u=Vt.create(a.value,{value:s.modelValue||"{}",language:"json",theme:p.value?"vs-dark":"vs",...f})(a.value).__monacoEditor=u,u.onDidChangeModelContent(()=>{if(!r){const $=u.getValue();c("update:modelValue",$)}}),u.onDidBlurEditorText(()=>{c("blur"),b()}))};ye(async()=>{n(),await xe(),d();const $=new MutationObserver(n);$.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),je(()=>{$.disconnect(),u&&u.dispose()})}),ie(()=>s.modelValue,$=>{u&&u.getValue()!==$&&(r=!0,u.setValue($||""),r=!1)}),ie(()=>s.readonly,$=>{u&&u.updateOptions({readOnly:$})});const h=s.rows?`${s.rows*1.5}rem`:"18rem";return($,g)=>(o(),l("div",gf,[e("div",{class:oe(["border rounded overflow-hidden bg-white dark:bg-black",[t.error?"border-red-500":"border-black dark:border-neutral-300"]])},[e("div",{ref_key:"containerRef",ref:a,class:"monaco-editor-container",style:st({height:F(h)})},null,4)],2),t.error?(o(),l("div",bf,V(t.error),1)):M("",!0)]))}}),jt=Fe(xf,[["__scopeId","data-v-1393c576"]]),yf={class:"p-8"},kf={class:"space-y-4"},wf={class:"space-y-4"},_f={class:"space-y-4"},$f=se({__name:"TestJsonEditorModal",setup(t){const i=v(!1),s=v(JSON.stringify({name:"Test",value:123},null,2)),c=v(!1),a=v(JSON.stringify({editable:!0,count:0},null,2));return(u,r)=>(o(),l("div",yf,[r[13]||(r[13]=e("h1",{class:"text-3xl font-bold mb-6"},"JsonEditor in Modal Test",-1)),e("div",kf,[e("div",null,[r[7]||(r[7]=e("h2",{class:"text-xl font-semibold mb-2"}," Read-only JsonEditor in Modal ",-1)),r[8]||(r[8]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-4"}," This should NOT show unsaved changes warning when closing ",-1)),e("button",{onClick:r[0]||(r[0]=p=>i.value=!0),class:"px-4 py-2 bg-black dark:bg-white text-white dark:text-black border-2 border-black dark:border-white"}," Open Read-only Modal ")]),e("div",null,[r[9]||(r[9]=e("h2",{class:"text-xl font-semibold mb-2"},"Editable JsonEditor in Modal",-1)),r[10]||(r[10]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-4"}," This should NOT show unsaved changes warning on initial close, but SHOULD show it after editing ",-1)),e("button",{onClick:r[1]||(r[1]=p=>c.value=!0),class:"px-4 py-2 bg-black dark:bg-white text-white dark:text-black border-2 border-black dark:border-white"}," Open Editable Modal ")])]),I(Ae,{modelValue:i.value,"onUpdate:modelValue":r[3]||(r[3]=p=>i.value=p),title:"Read-only JSON Schema",width:"max-w-4xl"},{footer:de(()=>[e("button",{onClick:r[2]||(r[2]=p=>i.value=!1),class:"px-4 py-2 border-2 border-black dark:border-white bg-white dark:bg-black text-black dark:text-white"}," Close ")]),default:de(()=>[e("div",wf,[r[11]||(r[11]=e("p",{class:"text-sm text-neutral-600 dark:text-neutral-400"}," This is a read-only JSON editor. No changes can be made. ",-1)),I(jt,{"model-value":s.value,readonly:!0},null,8,["model-value"])])]),_:1},8,["modelValue"]),I(Ae,{modelValue:c.value,"onUpdate:modelValue":r[6]||(r[6]=p=>c.value=p),title:"Editable JSON Schema",width:"max-w-4xl"},{footer:de(()=>[e("button",{onClick:r[5]||(r[5]=p=>c.value=!1),class:"px-4 py-2 border-2 border-black dark:border-white bg-white dark:bg-black text-black dark:text-white"}," Close ")]),default:de(()=>[e("div",_f,[r[12]||(r[12]=e("p",{class:"text-sm text-neutral-600 dark:text-neutral-400"}," This is an editable JSON editor. Changes will be tracked. ",-1)),I(jt,{modelValue:a.value,"onUpdate:modelValue":r[4]||(r[4]=p=>a.value=p)},null,8,["modelValue"])])]),_:1},8,["modelValue"])]))}}),Cf={class:"p-8 max-w-2xl mx-auto"},Vf={class:"mb-6"},Sf={class:"p-4 bg-neutral-100 dark:bg-neutral-800 rounded font-mono text-sm"},Tf={key:0},Mf={class:"whitespace-pre-wrap"},If={key:1,class:"text-neutral-500"},Lf={class:"mb-6"},Ef={class:"space-y-2"},Af={class:"mt-6"},Pf={class:"p-4 bg-green-50 dark:bg-green-900 rounded min-h-[100px]"},Of={key:0,class:"font-mono"},jf={key:1,class:"text-neutral-500"},Df="10000000-0000-0000-0000-000000000101",Dt="10000000-0000-0000-0000-000000000102",Uf=se({__name:"TestPromptInterpolation",setup(t){const i=v([]),s=v(null),c=v(null),a=v(""),u=v("Alice Johnson"),r=v("alice@example.com"),p=v("28"),{data:f,error:b}=Me(te(`/api/prompts/${Df}`)).json(),{data:n,error:d}=Me(te(`/api/prompts/${Dt}`)).json();ie(f,g=>{if(g){s.value=g;try{i.value=JSON.parse(g.prompt)}catch(m){console.error("Failed to parse prompt A:",m)}}},{immediate:!0}),ie(n,g=>{g&&(c.value=g)},{immediate:!0});function h(g,m){return g.map(C=>{if(C.type==="string")return C.value||"";if(C.type==="variable"){const w=m[C.value];return w===void 0?`{{${C.value}}}`:typeof w=="string"?w:JSON.stringify(w)}else if(C.type==="prompt"){if(C.id===Dt&&c.value)try{const w=JSON.parse(c.value.prompt);return h(w,m)}catch{return`[Error loading prompt: ${C.label}]`}return""}return""}).join("")}function $(){const g={name:u.value,email:r.value,age:p.value};a.value=h(i.value,g)}return(g,m)=>(o(),l("div",Cf,[m[11]||(m[11]=e("h1",{class:"text-2xl font-bold mb-6"},"Prompt Interpolation Test",-1)),e("div",Vf,[m[4]||(m[4]=e("h2",{class:"text-lg font-semibold mb-2"},"Prompt Template",-1)),e("div",Sf,[s.value?(o(),l("div",Tf,[m[3]||(m[3]=e("div",{class:"font-bold mb-2"},"Prompt A:",-1)),e("pre",Mf,V(JSON.stringify(i.value,null,2)),1)])):(o(),l("div",If,"Loading..."))])]),e("div",Lf,[m[8]||(m[8]=e("h2",{class:"text-lg font-semibold mb-2"},"Context Values",-1)),e("div",Ef,[e("div",null,[m[5]||(m[5]=e("label",{class:"block text-sm mb-1"},"Name:",-1)),_e(e("input",{"onUpdate:modelValue":m[0]||(m[0]=C=>u.value=C),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[Ee,u.value]])]),e("div",null,[m[6]||(m[6]=e("label",{class:"block text-sm mb-1"},"Email:",-1)),_e(e("input",{"onUpdate:modelValue":m[1]||(m[1]=C=>r.value=C),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[Ee,r.value]])]),e("div",null,[m[7]||(m[7]=e("label",{class:"block text-sm mb-1"},"Age:",-1)),_e(e("input",{"onUpdate:modelValue":m[2]||(m[2]=C=>p.value=C),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[Ee,p.value]])])])]),e("button",{onClick:$,class:"px-4 py-2 bg-black text-white rounded hover:bg-neutral-800"}," Render Prompt "),e("div",Af,[m[9]||(m[9]=e("h2",{class:"text-lg font-semibold mb-2"},"Rendered Output",-1)),e("div",Pf,[a.value?(o(),l("div",Of,V(a.value),1)):(o(),l("div",jf,' Click "Render Prompt" to see output '))]),m[10]||(m[10]=e("div",{class:"mt-4 p-4 bg-accent-50 dark:bg-accent-900 rounded text-sm"},[e("div",{class:"font-semibold mb-1"}," Expected Output (when feature is implemented): "),e("div",{class:"font-mono"}," User Profile: Alice Johnson <alice@example.com> (Age: 28) ")],-1))])]))}}),oo=So({history:To(Ge()),routes:[{path:"/login",name:"login",component:iv,meta:{public:!0}},{path:"/",redirect:"/threads"},{path:"/agents",name:"agents",component:yn},{path:"/threads",name:"threads",component:Lt},{path:"/threads/:id",name:"thread-detail",component:Lt},{path:"/prompts",name:"prompts",component:Jp},{path:"/prompts/:id",name:"prompt-edit",component:Xp},{path:"/models",name:"models",component:H1},{path:"/providers",name:"providers",component:lm},{path:"/tools",name:"tools",component:Rm},{path:"/settings/users",name:"users",component:zm},{path:"/settings/api-keys",name:"api-keys",component:Qm},{path:"/test",name:"test",component:Uv},{path:"/test-reference-input",name:"test-reference-input",component:af},{path:"/debug",name:"debug",component:rf},{path:"/test-prompt-input",name:"test-prompt-input",component:hf},{path:"/test-json-editor-modal",name:"test-json-editor-modal",component:$f},{path:"/test-prompt-interpolation",name:"test-prompt-interpolation",component:Uf}]});oo.beforeEach(async(t,i,s)=>{const c=t.meta.public===!0,a=localStorage.getItem("auth_token");!c&&!a?s({name:"login"}):c&&a&&t.name==="login"?s({name:"threads"}):s()});const Nf=window.fetch;window.fetch=async function(t,i){const s=typeof t=="string"?t:t instanceof URL?t.toString():t.url,c=Ge(),a=c==="/"?"/api/":`${c}/api/`,u=s.includes(a)||c==="/"&&s.startsWith("/api/");if(u){const f=localStorage.getItem("auth_token");f&&i?i.headers={...i.headers,Authorization:`Bearer ${f}`}:f&&(i={...i,headers:{Authorization:`Bearer ${f}`}})}const r=await Nf(t,i),p=s.includes("/api/auth/");return r.status===401&&u&&!p&&(localStorage.removeItem("auth_token"),window.location.href=te("/login")),r};const ao=Mo(ml);ao.use(oo);ao.mount("#app");
39
+ Description: ${r.meta?.description||"No description"}`)};return(r,p)=>(o(),a("div",Qv,[e("div",ef,[p[5]||(p[5]=e("h1",{class:"text-3xl font-bold mb-8 text-black dark:text-white"}," PromptInput Component Test ",-1)),e("div",tf,[e("div",of,[p[0]||(p[0]=e("h2",{class:"text-xl font-semibold text-black dark:text-white"}," Basic Usage ",-1)),p[1]||(p[1]=e("p",{class:"text-neutral-600 dark:text-neutral-400"}," Type @ to trigger the autocomplete menu. Use arrow keys to navigate and Enter to select. ",-1)),e("div",null,[E(ao,{"model-value":i.value,search:u,placeholder:"Type @ to insert variables or prompts...","onUpdate:modelValue":l,onSegmentClick:c},null,8,["model-value"])])]),e("div",lf,[p[3]||(p[3]=e("h2",{class:"text-xl font-semibold text-black dark:text-white"}," Current Value ",-1)),e("div",af,[p[2]||(p[2]=e("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300 mb-2"}," Segments (value): ",-1)),e("pre",sf,C(JSON.stringify(i.value,null,2)),1)])]),p[4]||(p[4]=So('<div class="space-y-4"><h2 class="text-xl font-semibold text-black dark:text-white"> Testing Instructions </h2><ul class="list-disc list-inside space-y-2 text-neutral-600 dark:text-neutral-400"><li>Type @ anywhere in the text to open the search dialog</li><li>Continue typing to search for variables or prompts</li><li>Use arrow keys (↑↓) to navigate results</li><li>Press Enter to select a result or click with mouse</li><li>Press Escape to close the dialog</li><li>Click outside the dialog to close it</li><li>Use Backspace/Delete to remove tags</li><li> The dialog will auto-close after typing 5+ characters without selection </li><li><strong>NEW: Click on any tag to see action handling!</strong></li></ul></div><div class="space-y-4"><h2 class="text-xl font-semibold text-black dark:text-white"> Test Scenarios </h2><div class="grid grid-cols-1 md:grid-cols-2 gap-4"><div class="p-4 border-2 border-neutral-300 dark:border-neutral-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2"> Variables </h3><p class="text-sm text-neutral-600 dark:text-neutral-400"> Try: @user, @date, @time, @api, @work </p></div><div class="p-4 border-2 border-neutral-300 dark:border-neutral-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2"> Prompts </h3><p class="text-sm text-neutral-600 dark:text-neutral-400"> Try: @greet, @error, @code, @data, @summ </p></div><div class="p-4 border-2 border-neutral-300 dark:border-neutral-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2"> Mixed Content </h3><p class="text-sm text-neutral-600 dark:text-neutral-400"> Mix text with multiple tags and test editing </p></div><div class="p-4 border-2 border-neutral-300 dark:border-neutral-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2"> Edge Cases </h3><p class="text-sm text-neutral-600 dark:text-neutral-400"> Test @ at start/end, multiple @@ symbols, etc. </p></div></div></div>',2))])])]))}}),rf={class:"relative"},df={key:0,class:"mt-1 text-sm text-red-500"},uf=se({__name:"JsonEditor",props:{modelValue:{},placeholder:{},error:{},rows:{},readonly:{type:Boolean}},emits:["update:modelValue","blur"],setup(t,{emit:i}){self.MonacoEnvironment={getWorker($,g){return g==="json"?new Eo:new Ao}};const n=t,u=i,l=v(null);let c=null,r=!1;const p=v(!1),f={minimap:{enabled:!1},fontSize:14,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:24,padding:{top:12,bottom:12},scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,readOnly:n.readonly,quickSuggestions:{other:"on",comments:"off",strings:"on"},suggestOnTriggerCharacters:!0,acceptSuggestionOnCommitCharacter:!0,tabSize:2,detectIndentation:!1,renderLineHighlight:"none",scrollbar:{vertical:"auto",horizontal:"hidden",verticalScrollbarSize:10}},b=()=>{if(!(!c||n.readonly))try{const $=c.getValue(),g=JSON.parse($),m=JSON.stringify(g,null,2);m!==$&&(r=!0,c.setValue(m),r=!1)}catch{}},s=()=>{p.value=document.documentElement.classList.contains("dark"),c&&Lt.setTheme(p.value?"vs-dark":"vs")},d=()=>{l.value&&(c=Lt.create(l.value,{value:n.modelValue||"{}",language:"json",theme:p.value?"vs-dark":"vs",...f})(l.value).__monacoEditor=c,c.onDidChangeModelContent(()=>{if(!r){const $=c.getValue();u("update:modelValue",$)}}),c.onDidBlurEditorText(()=>{u("blur"),b()}))};xe(async()=>{s(),await ge(),d();const $=new MutationObserver(s);$.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),Be(()=>{$.disconnect(),c&&c.dispose()})}),ue(()=>n.modelValue,$=>{c&&c.getValue()!==$&&(r=!0,c.setValue($||""),r=!1)}),ue(()=>n.readonly,$=>{c&&c.updateOptions({readOnly:$})});const h=n.rows?`${n.rows*1.5}rem`:"18rem";return($,g)=>(o(),a("div",rf,[e("div",{class:le(["border rounded overflow-hidden bg-white dark:bg-black",[t.error?"border-red-500":"border-black dark:border-neutral-300"]])},[e("div",{ref_key:"containerRef",ref:l,class:"monaco-editor-container",style:pt({height:Z(h)})},null,4)],2),t.error?(o(),a("div",df,C(t.error),1)):L("",!0)]))}}),Nt=Ze(uf,[["__scopeId","data-v-1393c576"]]),cf={class:"p-8"},pf={class:"space-y-4"},mf={class:"space-y-4"},vf={class:"space-y-4"},ff=se({__name:"TestJsonEditorModal",setup(t){const i=v(!1),n=v(JSON.stringify({name:"Test",value:123},null,2)),u=v(!1),l=v(JSON.stringify({editable:!0,count:0},null,2));return(c,r)=>(o(),a("div",cf,[r[13]||(r[13]=e("h1",{class:"text-3xl font-bold mb-6"},"JsonEditor in Modal Test",-1)),e("div",pf,[e("div",null,[r[7]||(r[7]=e("h2",{class:"text-xl font-semibold mb-2"}," Read-only JsonEditor in Modal ",-1)),r[8]||(r[8]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-4"}," This should NOT show unsaved changes warning when closing ",-1)),e("button",{onClick:r[0]||(r[0]=p=>i.value=!0),class:"px-4 py-2 bg-black dark:bg-white text-white dark:text-black border-2 border-black dark:border-white"}," Open Read-only Modal ")]),e("div",null,[r[9]||(r[9]=e("h2",{class:"text-xl font-semibold mb-2"},"Editable JsonEditor in Modal",-1)),r[10]||(r[10]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-4"}," This should NOT show unsaved changes warning on initial close, but SHOULD show it after editing ",-1)),e("button",{onClick:r[1]||(r[1]=p=>u.value=!0),class:"px-4 py-2 bg-black dark:bg-white text-white dark:text-black border-2 border-black dark:border-white"}," Open Editable Modal ")])]),E(je,{modelValue:i.value,"onUpdate:modelValue":r[3]||(r[3]=p=>i.value=p),title:"Read-only JSON Schema",width:"max-w-4xl"},{footer:de(()=>[e("button",{onClick:r[2]||(r[2]=p=>i.value=!1),class:"px-4 py-2 border-2 border-black dark:border-white bg-white dark:bg-black text-black dark:text-white"}," Close ")]),default:de(()=>[e("div",mf,[r[11]||(r[11]=e("p",{class:"text-sm text-neutral-600 dark:text-neutral-400"}," This is a read-only JSON editor. No changes can be made. ",-1)),E(Nt,{"model-value":n.value,readonly:!0},null,8,["model-value"])])]),_:1},8,["modelValue"]),E(je,{modelValue:u.value,"onUpdate:modelValue":r[6]||(r[6]=p=>u.value=p),title:"Editable JSON Schema",width:"max-w-4xl"},{footer:de(()=>[e("button",{onClick:r[5]||(r[5]=p=>u.value=!1),class:"px-4 py-2 border-2 border-black dark:border-white bg-white dark:bg-black text-black dark:text-white"}," Close ")]),default:de(()=>[e("div",vf,[r[12]||(r[12]=e("p",{class:"text-sm text-neutral-600 dark:text-neutral-400"}," This is an editable JSON editor. Changes will be tracked. ",-1)),E(Nt,{modelValue:l.value,"onUpdate:modelValue":r[4]||(r[4]=p=>l.value=p)},null,8,["modelValue"])])]),_:1},8,["modelValue"])]))}}),hf={class:"p-8 max-w-2xl mx-auto"},gf={class:"mb-6"},bf={class:"p-4 bg-neutral-100 dark:bg-neutral-800 rounded font-mono text-sm"},xf={key:0},yf={class:"whitespace-pre-wrap"},kf={key:1,class:"text-neutral-500"},wf={class:"mb-6"},_f={class:"space-y-2"},$f={class:"mt-6"},Cf={class:"p-4 bg-green-50 dark:bg-green-900 rounded min-h-[100px]"},Vf={key:0,class:"font-mono"},Sf={key:1,class:"text-neutral-500"},Tf="10000000-0000-0000-0000-000000000101",Bt="10000000-0000-0000-0000-000000000102",Mf=se({__name:"TestPromptInterpolation",setup(t){const i=v([]),n=v(null),u=v(null),l=v(""),c=v("Alice Johnson"),r=v("alice@example.com"),p=v("28"),{data:f,error:b}=Ee(ae(`/api/prompts/${Tf}`)).json(),{data:s,error:d}=Ee(ae(`/api/prompts/${Bt}`)).json();ue(f,g=>{if(g){n.value=g;try{i.value=JSON.parse(g.prompt)}catch(m){console.error("Failed to parse prompt A:",m)}}},{immediate:!0}),ue(s,g=>{g&&(u.value=g)},{immediate:!0});function h(g,m){return g.map(w=>{if(w.type==="string")return w.value||"";if(w.type==="variable"){const k=m[w.value];return k===void 0?`{{${w.value}}}`:typeof k=="string"?k:JSON.stringify(k)}else if(w.type==="prompt"){if(w.id===Bt&&u.value)try{const k=JSON.parse(u.value.prompt);return h(k,m)}catch{return`[Error loading prompt: ${w.label}]`}return""}return""}).join("")}function $(){const g={name:c.value,email:r.value,age:p.value};l.value=h(i.value,g)}return(g,m)=>(o(),a("div",hf,[m[11]||(m[11]=e("h1",{class:"text-2xl font-bold mb-6"},"Prompt Interpolation Test",-1)),e("div",gf,[m[4]||(m[4]=e("h2",{class:"text-lg font-semibold mb-2"},"Prompt Template",-1)),e("div",bf,[n.value?(o(),a("div",xf,[m[3]||(m[3]=e("div",{class:"font-bold mb-2"},"Prompt A:",-1)),e("pre",yf,C(JSON.stringify(i.value,null,2)),1)])):(o(),a("div",kf,"Loading..."))])]),e("div",wf,[m[8]||(m[8]=e("h2",{class:"text-lg font-semibold mb-2"},"Context Values",-1)),e("div",_f,[e("div",null,[m[5]||(m[5]=e("label",{class:"block text-sm mb-1"},"Name:",-1)),Se(e("input",{"onUpdate:modelValue":m[0]||(m[0]=w=>c.value=w),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[Oe,c.value]])]),e("div",null,[m[6]||(m[6]=e("label",{class:"block text-sm mb-1"},"Email:",-1)),Se(e("input",{"onUpdate:modelValue":m[1]||(m[1]=w=>r.value=w),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[Oe,r.value]])]),e("div",null,[m[7]||(m[7]=e("label",{class:"block text-sm mb-1"},"Age:",-1)),Se(e("input",{"onUpdate:modelValue":m[2]||(m[2]=w=>p.value=w),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[Oe,p.value]])])])]),e("button",{onClick:$,class:"px-4 py-2 bg-black text-white rounded hover:bg-neutral-800"}," Render Prompt "),e("div",$f,[m[9]||(m[9]=e("h2",{class:"text-lg font-semibold mb-2"},"Rendered Output",-1)),e("div",Cf,[l.value?(o(),a("div",Vf,C(l.value),1)):(o(),a("div",Sf,' Click "Render Prompt" to see output '))]),m[10]||(m[10]=e("div",{class:"mt-4 p-4 bg-accent-50 dark:bg-accent-900 rounded text-sm"},[e("div",{class:"font-semibold mb-1"}," Expected Output (when feature is implemented): "),e("div",{class:"font-mono"}," User Profile: Alice Johnson <alice@example.com> (Age: 28) ")],-1))])]))}}),no=To({history:Mo(ot()),routes:[{path:"/login",name:"login",component:Qm,meta:{public:!0}},{path:"/",redirect:"/threads"},{path:"/agents",name:"agents",component:kn},{path:"/threads",name:"threads",component:Ot},{path:"/threads/:id",name:"thread-detail",component:Ot},{path:"/prompts",name:"prompts",component:Up},{path:"/prompts/:id",name:"prompt-edit",component:qp},{path:"/models",name:"models",component:j1},{path:"/providers",name:"providers",component:K1},{path:"/tools",name:"tools",component:Im},{path:"/settings/users",name:"users",component:Om},{path:"/settings/api-keys",name:"api-keys",component:zm},{path:"/test",name:"test",component:Mv},{path:"/test-reference-input",name:"test-reference-input",component:Zv},{path:"/debug",name:"debug",component:Yv},{path:"/test-prompt-input",name:"test-prompt-input",component:nf},{path:"/test-json-editor-modal",name:"test-json-editor-modal",component:ff},{path:"/test-prompt-interpolation",name:"test-prompt-interpolation",component:Mf}]});no.beforeEach(async(t,i,n)=>{const u=t.meta.public===!0,l=localStorage.getItem("auth_token");!u&&!l?n({name:"login"}):u&&l&&t.name==="login"?n({name:"threads"}):n()});const Lf=window.fetch;window.fetch=async function(t,i){const n=typeof t=="string"?t:t instanceof URL?t.toString():t.url,u=ot(),l=u==="/"?"/api/":`${u}/api/`,c=n.includes(l)||u==="/"&&n.startsWith("/api/");if(c){const f=localStorage.getItem("auth_token");f&&i?i.headers={...i.headers,Authorization:`Bearer ${f}`}:f&&(i={...i,headers:{Authorization:`Bearer ${f}`}})}const r=await Lf(t,i),p=n.includes("/api/auth/");return r.status===401&&c&&!p&&(localStorage.removeItem("auth_token"),window.location.href=ae("/login")),r};const ro=Lo(va);ro.use(no);ro.mount("#app");