@standardagents/builder 0.11.12 → 0.12.1

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,29 +1,60 @@
1
- import{d as me,i as Xt,c as J,t as Aa,r as v,w as fe,o as Me,a as Be,p as Pa,m as De,b as o,e as a,f as e,n as ot,g as et,h as Te,u as Ye,j as ae,k as V,l as ne,q as X,F as ve,s as ke,v as A,x as Ee,y as be,z as lt,A as Ze,B as S,R as Lt,C as Ce,T as it,D as Xe,E as Ie,G as Oe,H as Da,I as Ue,J as ja,X as ft,K as nt,S as Yt,L as Oa,M as Ua,N as Qt,O as Ra,P as Tt,Q as Na,U as Zt,V as Ke,W as ea,Y as mt,Z as Fa,_ as ta,$ as kt,a0 as At,a1 as Ba,a2 as qa,a3 as za,a4 as Ha,a5 as Wa,a6 as aa,a7 as Pt,a8 as Ja,a9 as Ka,aa as Ga,ab as Xa,ac as Ya,ad as oa,ae as Qa,af as la,ag as Za,ah as eo,ai as sa,aj as wt,ak as We,al as st,am as to,an as ao,ao as na,ap as ra,aq as oo,ar as lo,as as so,at as no,au as ro}from"./vue.js";import{f as io}from"./vendor.js";import{W as uo,a as co,e as Dt}from"./monaco.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))i(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const r of u.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&i(r)}).observe(document,{childList:!0,subtree:!0});function s(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function i(l){if(l.ep)return;l.ep=!0;const u=s(l);fetch(l.href,u)}})();var ia=class{endpoint;token;constructor(t){this.endpoint=t.replace(/\/$/,""),this.token=typeof localStorage<"u"?localStorage.getItem("agentbuilder_auth_token"):null}getEndpoint(){return this.endpoint}async createThread(t){const n=await fetch(`${this.endpoint}/threads`,{method:"POST",headers:{...this.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`Failed to create thread: ${n.statusText}`);return n.json()}async getThread(t){const n=await fetch(`${this.endpoint}/threads/${t}`,{method:"GET",headers:this.getHeaders()});if(!n.ok)throw new Error(`Failed to get thread: ${n.statusText}`);return n.json()}async getMessages(t,n={}){const s=new URLSearchParams;n.limit!==void 0&&s.set("limit",String(n.limit)),n.offset!==void 0&&s.set("offset",String(n.offset)),n.depth!==void 0&&s.set("depth",String(n.depth)),n.includeSilent!==void 0&&s.set("includeSilent",String(n.includeSilent));const i=s.toString(),l=`${this.endpoint}/threads/${t}/messages${i?`?${i}`:""}`,u=await fetch(l,{method:"GET",headers:this.getHeaders()});if(!u.ok)throw new Error(`Failed to get messages: ${u.statusText}`);return(await u.json()).messages||[]}async sendMessage(t,n){const s=await fetch(`${this.endpoint}/threads/${t}/messages`,{method:"POST",headers:{...this.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify(n)});if(!s.ok)throw new Error(`Failed to send message: ${s.statusText}`);return s.json()}async stopExecution(t){const n=await fetch(`${this.endpoint}/threads/${t}/stop`,{method:"POST",headers:this.getHeaders()});if(!n.ok)throw new Error(`Failed to stop execution: ${n.statusText}`);await n.json()}async deleteMessage(t,n){const s=await fetch(`${this.endpoint}/threads/${t}/messages/${n}`,{method:"DELETE",headers:this.getHeaders()});if(!s.ok)throw new Error(`Failed to delete message: ${s.statusText}`);return s.json()}async uploadFile(t,n,s){const i=encodeURIComponent(n.name),l=`${this.endpoint}/threads/${t}/fs/${i}`;if(s?.thumbnail){const r=await this.fileToBase64(n),c=await fetch(l,{method:"POST",headers:{...this.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify({data:r,mimeType:n.type,thumbnail:s.thumbnail,metadata:{width:s.width,height:s.height}})});if(!c.ok)throw new Error(`Failed to upload file: ${c.statusText}`);return c.json()}const u=await fetch(l,{method:"POST",headers:{...this.getHeaders(),"Content-Type":n.type},body:n});if(!u.ok)throw new Error(`Failed to upload file: ${u.statusText}`);return u.json()}fileToBase64(t){return new Promise((n,s)=>{const i=new FileReader;i.onload=()=>{const u=i.result.split(",")[1];n(u)},i.onerror=()=>s(new Error("Failed to read file")),i.readAsDataURL(t)})}getFileUrl(t,n){const i=(n.startsWith("/")?n.slice(1):n).split("/").map(l=>encodeURIComponent(l)).join("/");return`${this.endpoint}/threads/${t}/fs/${i}`}getThumbnailUrl(t,n){return`${this.getFileUrl(t,n)}?thumbnail=true`}async listFiles(t){const n=await fetch(`${this.endpoint}/threads/${t}/fs?find=**/*&type=file`,{method:"GET",headers:this.getHeaders()});if(!n.ok)throw new Error(`Failed to list files: ${n.statusText}`);return(await n.json()).files||[]}connectMessageWebSocket(t,n={},s={}){const i=new URLSearchParams;this.token&&i.set("token",this.token),s.includeSilent!==void 0&&i.set("includeSilent",String(s.includeSilent)),s.depth!==void 0&&i.set("depth",String(s.depth));const l=this.endpoint.startsWith("https")?"wss":"ws",r=`${this.endpoint.replace(/^https?/,l)}/threads/${t}/stream?${i.toString()}`,c=new WebSocket(r);return c.onopen=()=>{n.onOpen?.()},c.onmessage=f=>{try{if(typeof f.data=="string"&&f.data==="pong")return;const g=JSON.parse(f.data);switch(g.type){case"message_data":n.onMessage?.(g);break;case"message_chunk":n.onChunk?.(g);break;case"event":n.onEvent?.(g);break;case"error":n.onError?.(g);break}}catch(g){console.error("Failed to parse WebSocket message:",g)}},c.onerror=f=>{console.error("WebSocket error:",f),n.onError?.({type:"error",error:"WebSocket connection error"})},c.onclose=f=>{console.log(`[AgentBuilderClient] Message WebSocket closed - code: ${f.code}, reason: ${f.reason||"none"}, wasClean: ${f.wasClean}`),n.onClose?.()},c}connectLogWebSocket(t,n={}){const s=new URLSearchParams;this.token&&s.set("token",this.token);const i=this.endpoint.startsWith("https")?"wss":"ws",u=`${this.endpoint.replace(/^https?/,i)}/threads/${t}?${s.toString()}`,r=new WebSocket(u);return r.onopen=()=>{n.onOpen?.()},r.onmessage=c=>{try{if(typeof c.data=="string"&&c.data==="pong")return;const f=JSON.parse(c.data);switch(f.type){case"log_data":n.onLog?.(f);break;case"custom":n.onCustom?.(f);break;case"stopped_by_user":n.onStopped?.(f);break}}catch(f){console.error("Failed to parse WebSocket message:",f)}},r.onerror=c=>{console.error("WebSocket error:",c)},r.onclose=()=>{n.onClose?.()},r}getHeaders(){const t={};return this.token&&(t.Authorization=`Bearer ${this.token}`),t}},po=class{client;threadId;callbacks;options;ws=null;status="disconnected";reconnectAttempts=0;reconnectTimeout=null;heartbeatInterval=null;isReconnecting=!1;shouldReconnect=!0;constructor(t,n,s={},i={}){this.client=t,this.threadId=n,this.callbacks=s,this.options={depth:i.depth??0,includeSilent:i.includeSilent??!1,heartbeatInterval:i.heartbeatInterval??3e4,maxReconnectDelay:i.maxReconnectDelay??3e4}}getStatus(){return this.status}getThreadId(){return this.threadId}connect(){this.ws&&this.ws.readyState!==WebSocket.CLOSED||(this.shouldReconnect=!0,this.isReconnecting=!1,this.setStatus("connecting"),this.ws=this.client.connectMessageWebSocket(this.threadId,{onOpen:()=>{this.setStatus("connected"),this.reconnectAttempts=0,this.isReconnecting=!1,this.startHeartbeat()},onMessage:t=>{this.callbacks.onMessage?.(t)},onChunk:t=>{this.callbacks.onChunk?.(t)},onEvent:t=>{this.callbacks.onEvent?.(t)},onError:t=>{this.callbacks.onError?.(t)},onClose:()=>{this.clearTimers(),this.scheduleReconnect()}},{depth:this.options.depth,includeSilent:this.options.includeSilent}))}disconnect(){this.shouldReconnect=!1,this.clearTimers(),this.ws&&(this.ws.close(),this.ws=null),this.reconnectAttempts=0,this.isReconnecting=!1,this.setStatus("disconnected")}updateCallbacks(t){this.callbacks={...this.callbacks,...t}}updateOptions(t){this.options={...this.options,...t}}setStatus(t){this.status!==t&&(this.status=t,this.callbacks.onStatusChange?.(t))}startHeartbeat(){this.clearHeartbeat(),this.heartbeatInterval=setInterval(()=>{this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send("ping")},this.options.heartbeatInterval)}clearHeartbeat(){this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}clearReconnectTimeout(){this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null)}clearTimers(){this.clearHeartbeat(),this.clearReconnectTimeout()}scheduleReconnect(){if(!this.shouldReconnect||this.isReconnecting){this.setStatus("disconnected");return}this.isReconnecting=!0,this.setStatus("reconnecting");const t=Math.min(1e3*Math.pow(2,this.reconnectAttempts),this.options.maxReconnectDelay);this.reconnectAttempts++,this.reconnectTimeout=setTimeout(()=>{this.shouldReconnect&&this.connect()},t)}};function jt(t){return t.toLowerCase().startsWith("image/")}var Ot=256;function mo(t){return new Promise((n,s)=>{const i=new Image,l=URL.createObjectURL(t);i.onload=()=>{URL.revokeObjectURL(l),n(i)},i.onerror=()=>{URL.revokeObjectURL(l),s(new Error("Failed to load image"))},i.src=l})}function vo(t){const{width:n,height:s}=t,i=n/s;let l,u;i>1?(l=Math.min(Ot,n),u=Math.floor(l/i)):(u=Math.min(Ot,s),l=Math.floor(u*i));const r=document.createElement("canvas");r.width=l,r.height=u;const c=r.getContext("2d");if(!c)throw new Error("Failed to get canvas context");return c.drawImage(t,0,0,l,u),r.toDataURL("image/webp",.8).split(",")[1]}async function fo(t){const n=await mo(t);return{thumbnail:vo(n),width:n.width,height:n.height}}function ho(){return`pending-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function go(t){return new Promise((n,s)=>{const i=new FileReader;i.onload=()=>n(i.result),i.onerror=s,i.readAsDataURL(t)})}var bo=class{createPendingFile(t){return{id:ho(),name:t.name,mimeType:t.type,size:t.size,isImage:jt(t.type),localPreviewUrl:null,status:"uploading"}}queueFiles(t){return Array.from(t).map(n=>({pending:this.createPendingFile(n),file:n}))}async executeUpload(t,n,s,i,l,u={}){const{generateThumbnail:r=!0,generatePreview:c=!0}=u,f=jt(n.type);f&&c&&go(n).then(g=>l({localPreviewUrl:g})).catch(g=>console.error("Failed to generate preview:",g));try{let g;if(f&&r)try{const p=await fo(n);g={thumbnail:p.thumbnail,width:p.width,height:p.height}}catch(p){console.warn("Failed to generate thumbnail:",p)}const d=await i.uploadFile(t,n,g);return l({id:d.id,status:"ready",path:d.path,width:d.width,height:d.height}),d}catch(g){throw l({status:"error",error:g instanceof Error?g.message:"Failed to upload file"}),g}}async executeUploads(t,n,s,i,l={}){const u=n.map(({pending:r,file:c})=>this.executeUpload(t,c,r.id,s,f=>i(r.id,f),l).catch(f=>f instanceof Error?f:new Error(String(f))));return Promise.all(u)}};function xo(t){if(t.length===0)return[];const n=[];let s=0;for(;s<t.length;){const i=t[s];if(i.role==="assistant"&&i.tool_calls){let l;try{l=JSON.parse(i.tool_calls)}catch{n.push(i),s++;continue}const u=[],r=[],c=[];let f=i.reasoning_content||null,g="completed";const d=i.id,p=i.created_at,h=i.depth;i.status==="pending"?g="pending":i.status==="failed"&&(g="failed"),i.content&&r.push(i.content);for(const k of l)u.push({id:k.id||i.id,type:"tool_call",name:k.function?.name,content:k.function?.arguments||null,status:null,tool_call_id:k.id});let _=s+1;for(;_<t.length;){const k=t[_];if(k.role==="tool"){const D=k.tool_status||"pending";if(u.push({id:k.id,type:"tool_result",name:k.name||void 0,content:k.content,status:D,tool_call_id:k.tool_call_id||void 0}),k.attachments)try{let q;typeof k.attachments=="string"?q=JSON.parse(k.attachments):Array.isArray(k.attachments)?q=k.attachments:q=[],c.push(...q)}catch{}_++}else if(k.role==="assistant"&&k.tool_calls){let D;try{D=JSON.parse(k.tool_calls)}catch{break}k.status==="pending"?g="pending":k.status==="failed"&&g!=="pending"&&(g="failed"),k.content&&r.push(k.content),!f&&k.reasoning_content&&(f=k.reasoning_content);for(const q of D)u.push({id:q.id||k.id,type:"tool_call",name:q.function?.name,content:q.function?.arguments||null,status:null,tool_call_id:q.id});_++}else break}const b=new Set(u.filter(k=>k.type==="tool_call").map(k=>k.tool_call_id)),m=u.filter(k=>k.type==="tool_result"&&k.tool_call_id&&!b.has(k.tool_call_id));for(const k of m){const D=u.indexOf(k),q=k.content?.match(/Tool not found: (\w+)/)?.[1]||"unknown_tool",B={id:`synthetic-${k.tool_call_id}`,type:"tool_call",name:q,content:null,status:k.status,tool_call_id:k.tool_call_id};u.splice(D,0,B)}for(const k of u)if(k.type==="tool_call"&&k.tool_call_id&&k.status===null){const D=u.find(q=>q.type==="tool_result"&&q.tool_call_id===k.tool_call_id);D?k.status=D.status:k.status="pending"}const y=r.length>0?r.join(""):null,x={id:d,type:"workblock",content:y,reasoning_content:f,workItems:u,status:g,created_at:p,depth:h,attachments:c.length>0?c:void 0};n.push(x),s=_}else n.push(i),s++}return n}var da=Symbol("StandardAgents"),ua=Symbol("Thread"),yo={install(t,n){if(!n?.endpoint)throw new Error("StandardAgentsPlugin requires an endpoint option");const i={client:new ia(n.endpoint),endpoint:n.endpoint};t.provide(da,i)}};function ko(){const t=Xt(da);if(!t)throw new Error("useStandardAgents must be used within a component where StandardAgentsPlugin is installed");return t}var Ut=new bo;function wo(t){return new Promise((n,s)=>{const i=new FileReader;i.onload=()=>{const u=i.result.split(",")[1];n(u)},i.onerror=()=>s(new Error("Failed to read file")),i.readAsDataURL(t)})}function _o(t,n={}){const{preload:s=!0,live:i=!0,useWorkblocks:l=!1,depth:u=0,includeSilent:r=!1,endpoint:c}=n,f=J(()=>Aa(t)),g=ko(),d=c?new ia(c):g.client,p={preload:s,live:i,useWorkblocks:l,depth:u,includeSilent:r},h=v([]),_=v("disconnected"),b=v(s),m=v(null),y=v([]),x=v([]),k=v([]),D=J(()=>{const I=new Set(x.value.map(O=>O.path));return[...y.value.filter(O=>!O.path||!I.has(O.path)),...x.value]}),q=new Map;let B=null;const F=J(()=>l?xo(h.value):h.value);async function T(){b.value=!0,m.value=null;try{const I=await d.getMessages(f.value,{depth:u,includeSilent:r});h.value=I}catch(I){m.value=I instanceof Error?I:new Error(String(I))}finally{b.value=!1}}async function $(){try{const I=await d.listFiles(f.value);x.value=I.filter(le=>!le.isDirectory).map(le=>({id:le.path,name:le.name,path:le.path,mimeType:le.mimeType,size:le.size,isImage:le.mimeType.startsWith("image/"),status:"committed",localPreviewUrl:null}))}catch(I){console.error("Failed to load files:",I)}}function K(I){if(I.file.isDirectory)return;const le={id:I.path,name:I.file.name,path:I.path,mimeType:I.file.mimeType,size:I.file.size,isImage:I.file.mimeType?.startsWith("image/")||!1,status:"committed",localPreviewUrl:null},O=x.value.findIndex(W=>W.path===I.path);O>=0?x.value[O]=le:x.value=[...x.value,le]}function oe(I){if(I.file.isDirectory)return;const le={id:I.path,name:I.file.name,path:I.path,mimeType:I.file.mimeType,size:I.file.size,isImage:I.file.mimeType?.startsWith("image/")||!1,status:"committed",localPreviewUrl:null},O=x.value.findIndex(W=>W.path===I.path);O>=0?x.value[O]=le:x.value=[...x.value,le]}function te(I){x.value=x.value.filter(le=>le.path!==I.path)}function H(){i&&(B=new po(d,f.value,{onStatusChange:I=>{_.value=I},onMessage:I=>{if(I.type==="message_data"){const le=h.value.findIndex(O=>O.id===I.data.id);le>=0?h.value[le]=I.data:h.value=[...h.value,I.data]}},onChunk:I=>{const le=h.value.findIndex(O=>O.id===I.message_id);if(le>=0){const O=h.value[le];h.value[le]={...O,content:(O.content||"")+I.chunk}}},onEvent:I=>{I.eventType==="file_created"?K(I.data):I.eventType==="file_updated"?oe(I.data):I.eventType==="file_deleted"&&te(I.data);const le=q.get(I.eventType);le&&le.forEach(O=>{try{O(I.data)}catch(W){console.error(`Error in event listener for "${I.eventType}":`,W)}})},onError:I=>{m.value=I instanceof Error?I:new Error(String(I))}},{depth:u,includeSilent:r}),B.connect())}async function P(I){const le=`optimistic-${crypto.randomUUID()}`,O=k.value.map(z=>({id:z.id,type:"file",path:"",name:z.name,mimeType:z.mimeType,size:z.size,width:z.width,height:z.height,localPreviewUrl:z.previewUrl||void 0})),W={id:le,role:I.role,content:I.content,attachments:O.length>0?JSON.stringify(O):null,created_at:Date.now()*1e3,status:"pending"};h.value=[...h.value,W];const ce=[...k.value];k.value=[];try{const z=await Promise.all(ce.map(async Q=>({name:Q.name,mimeType:Q.mimeType,data:await wo(Q.file),width:Q.width,height:Q.height}))),N=await d.sendMessage(f.value,{...I,attachments:z.length>0?z:void 0});return h.value=h.value.filter(Q=>Q.id!==le),ce.forEach(Q=>{Q.previewUrl&&URL.revokeObjectURL(Q.previewUrl)}),N}catch(z){throw k.value=ce,h.value=h.value.filter(N=>N.id!==le),m.value=z instanceof Error?z:new Error(String(z)),z}}async function C(){try{await d.stopExecution(f.value)}catch(I){throw m.value=I instanceof Error?I:new Error(String(I)),I}}async function L(I){const le=[...h.value];h.value=h.value.filter(O=>O.id!==I);try{await d.deleteMessage(f.value,I)}catch(O){throw h.value=le,m.value=O instanceof Error?O:new Error(String(O)),O}}function G(I){const le=Ut.queueFiles(I);y.value=[...y.value,...le.map(O=>O.pending)];for(const{pending:O,file:W}of le)Ut.executeUpload(f.value,W,O.id,d,ce=>{y.value=y.value.map(z=>z.id===O.id?{...z,...ce}:z)}).catch(()=>{})}function ee(I){y.value=y.value.filter(le=>le.id!==I)}function E(I){return I.path?d.getFileUrl(f.value,I.path):""}function U(I){return I.path?d.getThumbnailUrl(f.value,I.path):""}function Z(I){return I.isImage?I.localPreviewUrl?I.localPreviewUrl:I.path?U(I):null:null}function se(I){const O=(I instanceof FileList?Array.from(I):Array.isArray(I)?I:[I]).map(W=>{const ce=W.type.startsWith("image/");return{id:crypto.randomUUID(),file:W,name:W.name,mimeType:W.type,size:W.size,isImage:ce,previewUrl:ce?URL.createObjectURL(W):null}});k.value=[...k.value,...O]}function j(I){const le=k.value.find(O=>O.id===I);le?.previewUrl&&URL.revokeObjectURL(le.previewUrl),k.value=k.value.filter(O=>O.id!==I)}function M(){k.value.forEach(I=>{I.previewUrl&&URL.revokeObjectURL(I.previewUrl)}),k.value=[]}function w(I,le){return q.has(I)||q.set(I,new Set),q.get(I).add(le),()=>{const O=q.get(I);O&&(O.delete(le),O.size===0&&q.delete(I))}}function R(){B?.disconnect(),B=null,_.value="disconnected"}return fe(f,(I,le)=>{I!==le&&(R(),h.value=[],m.value=null,y.value=[],x.value=[],k.value.forEach(O=>{O.previewUrl&&URL.revokeObjectURL(O.previewUrl)}),k.value=[],s&&T(),$(),H())}),Me(()=>{s&&T(),$(),H()}),Be(()=>{B?.disconnect(),q.clear(),k.value.forEach(I=>{I.previewUrl&&URL.revokeObjectURL(I.previewUrl)})}),{threadId:f,options:p,messages:h,workblocks:F,status:_,connectionStatus:_,isLoading:b,loading:b,error:m,sendMessage:P,stopExecution:C,deleteMessage:L,onEvent:w,subscribeToEvent:w,files:D,addFiles:G,removeFile:ee,getFileUrl:E,getThumbnailUrl:U,getPreviewUrl:Z,attachments:k,addAttachment:se,removeAttachment:j,clearAttachments:M}}var $o=me({name:"ThreadProvider",props:{threadId:{type:String,required:!0},preload:{type:Boolean,default:void 0},live:{type:Boolean,default:void 0},useWorkblocks:{type:Boolean,default:void 0},depth:{type:Number,default:void 0},includeSilent:{type:Boolean,default:void 0},endpoint:{type:String,default:void 0}},setup(t,{slots:n}){const s={};t.preload!==void 0&&(s.preload=t.preload),t.live!==void 0&&(s.live=t.live),t.useWorkblocks!==void 0&&(s.useWorkblocks=t.useWorkblocks),t.depth!==void 0&&(s.depth=t.depth),t.includeSilent!==void 0&&(s.includeSilent=t.includeSilent),t.endpoint!==void 0&&(s.endpoint=t.endpoint);const i=_o(()=>t.threadId,s);return Pa(ua,i),()=>n.default?.()}});function ca(){const t=Xt(ua);if(!t)throw new Error('useThread must be used within a <ThreadProvider>. Wrap your component with <ThreadProvider threadId="...">.');return t}const Co={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function To(t,n){return a(),o("svg",Co,[...n[0]||(n[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 Rt=De({name:"lucide-bot",render:To}),So={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Vo(t,n){return a(),o("svg",So,[...n[0]||(n[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 Nt=De({name:"lucide-message-square",render:Vo}),Mo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Io(t,n){return a(),o("svg",Mo,[...n[0]||(n[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 Eo=De({name:"lucide-cpu",render:Io}),Lo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ao(t,n){return a(),o("svg",Lo,[...n[0]||(n[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 Po=De({name:"lucide-server",render:Ao}),Do={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function jo(t,n){return a(),o("svg",Do,[...n[0]||(n[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 Oo=De({name:"lucide-wrench",render:jo}),Uo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ro(t,n){return a(),o("svg",Uo,[...n[0]||(n[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 No=De({name:"lucide-settings",render:Ro}),Fo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Bo(t,n){return a(),o("svg",Fo,[...n[0]||(n[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 qo=De({name:"lucide-chevron-left",render:Bo}),zo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ho(t,n){return a(),o("svg",zo,[...n[0]||(n[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 Wo=De({name:"lucide-sun",render:Ho}),Jo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ko(t,n){return a(),o("svg",Jo,[...n[0]||(n[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 Go=De({name:"lucide-moon",render:Ko}),Xo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Yo(t,n){return a(),o("svg",Xo,[...n[0]||(n[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 Qo=De({name:"lucide-activity",render:Yo}),Zo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function el(t,n){return a(),o("svg",Zo,[...n[0]||(n[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 tl=De({name:"lucide-function-square",render:el}),al={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ol(t,n){return a(),o("svg",al,[...n[0]||(n[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 ll=De({name:"lucide-log-out",render:ol}),sl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function nl(t,n){return a(),o("svg",sl,[...n[0]||(n[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 rl=De({name:"lucide-users",render:nl}),il={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function dl(t,n){return a(),o("svg",il,[...n[0]||(n[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 ul=De({name:"lucide-key",render:dl}),cl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function pl(t,n){return a(),o("svg",cl,[...n[0]||(n[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 ml=De({name:"lucide-book-open",render:pl}),vl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function fl(t,n){return a(),o("svg",vl,[...n[0]||(n[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 hl=De({name:"lucide-external-link",render:fl}),pa="agentbuilder-accent-theme",ma=["amber","lime","emerald","sky","blue","indigo","purple","fuchsia","pink","white"],_t=v("purple");let Ft=!1;function va(t){typeof document>"u"||(t==="purple"?delete document.documentElement.dataset.accent:document.documentElement.dataset.accent=t)}function gl(t){try{localStorage.setItem(pa,t)}catch{}}function bl(){try{const t=localStorage.getItem(pa);if(t&&ma.includes(t))return t}catch{}return"purple"}function fa(){if(Ft)return;Ft=!0;const t=bl();_t.value=t,va(t)}function xl(){fa();function t(n){_t.value=n,va(n),gl(n)}return{theme:_t,themes:ma,setTheme:t}}const Qe=me({__name:"DropShadow",props:{offsetX:{default:8},offsetY:{default:8},intensity:{default:.5},pattern:{default:"crosshatch"}},setup(t){const n=t,s=v(),i=v(),l=v(),u=v(0),r=(d,p,h,_,b,m)=>{d.beginPath(),d.moveTo(p+m,h),d.lineTo(p+_-m,h),d.quadraticCurveTo(p+_,h,p+_,h+m),d.lineTo(p+_,h+b-m),d.quadraticCurveTo(p+_,h+b,p+_-m,h+b),d.lineTo(p+m,h+b),d.quadraticCurveTo(p,h+b,p,h+b-m),d.lineTo(p,h+m),d.quadraticCurveTo(p,h,p+m,h),d.closePath()},c=async()=>{if(await Te(),!s.value||!i.value||!l.value)return;const d=s.value.getContext("2d");if(!d)return;const p=l.value.getBoundingClientRect(),h=l.value.firstElementChild;if(h){const y=getComputedStyle(h);u.value=parseFloat(y.borderRadius)||0}const _=p.width+n.offsetX+4,b=p.height+n.offsetY+4;s.value.width=_,s.value.height=b,s.value.style.width=`${_}px`,s.value.style.height=`${b}px`,d.clearRect(0,0,s.value.width,s.value.height);const m=document.documentElement.classList.contains("dark");if(d.fillStyle=m?"#6b7280":"black",d.globalAlpha=n.intensity,d.save(),r(d,n.offsetX,n.offsetY,p.width,p.height,u.value),d.clip(),n.pattern==="crosshatch"){const y=m?4:3;d.lineWidth=1,d.strokeStyle=m?"#6b7280":"black";for(let x=-p.height;x<p.width;x+=y)d.beginPath(),d.moveTo(n.offsetX+x,n.offsetY),d.lineTo(n.offsetX+x+p.height,n.offsetY+p.height),d.stroke();for(let x=0;x<p.width+p.height;x+=y)d.beginPath(),d.moveTo(n.offsetX+x,n.offsetY+p.height),d.lineTo(n.offsetX+x-p.height,n.offsetY),d.stroke()}else if(n.pattern==="dots"){const x=m?3:2,k=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];for(let D=0;D<p.width;D+=x)for(let q=0;q<p.height;q+=x){const B=Math.floor(D/x)%4,F=Math.floor(q/x)%4;k[F][B]/16<n.intensity&&d.fillRect(n.offsetX+D,n.offsetY+q,1,1)}}else if(n.pattern==="diagonal"){const y=m?5:4;d.lineWidth=1,d.strokeStyle=m?"#6b7280":"black";for(let x=-p.height;x<p.width;x+=y)d.beginPath(),d.moveTo(n.offsetX+x,n.offsetY),d.lineTo(n.offsetX+x+p.height,n.offsetY+p.height),d.stroke()}d.restore()};let f=null,g=null;return Me(()=>{f=new ResizeObserver(()=>{c()}),l.value&&f.observe(l.value),c(),g=new MutationObserver(()=>{c()}),g.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]})}),Be(()=>{l.value&&f&&f.unobserve(l.value),g&&g.disconnect()}),fe(()=>[n.offsetX,n.offsetY,n.intensity,n.pattern],()=>{c()}),(d,p)=>(a(),o("div",{ref_key:"container",ref:i,class:"relative",style:ot({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:l,class:"relative"},[et(d.$slots,"default")],512)],4))}}),ha="/agents/assets/img/agent-builder-logo-light.svg",ga="/agents/assets/img/agent-builder-logo-dark.svg",yl="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",kl="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 wl(){return window.__AGENTBUILDER_CONFIG__||{mountPoint:"/agentbuilder"}}function dt(){return wl().mountPoint}function ue(t){const n=dt(),s=t.startsWith("/")?t:`/${t}`;return n==="/"?s:`${n}${s}`}const _l=["src"],$l=["src"],Cl={class:"flex-1 flex flex-col justify-between pt-2 pb-4"},Tl={class:"flex flex-col gap-1 px-2"},Sl={key:0},Vl=["onClick","title"],Ml={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis text-left"},Il={key:0,class:"ml-4 space-y-0.5"},El=["onClick"],Ll={class:"whitespace-nowrap overflow-hidden text-ellipsis"},Al=["onClick","title"],Pl={key:0,class:"whitespace-nowrap overflow-hidden text-ellipsis"},Dl={class:"flex flex-col gap-1 px-2"},jl=["title"],Ol={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis"},Ul={class:"relative settings-menu-container"},Rl={key:0,class:"absolute bottom-full mb-2 left-0 z-50"},Nl={class:"bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-600 rounded-lg py-2 min-w-[200px]"},Fl={class:"px-4 py-3 border-b border-neutral-200 dark:border-neutral-700"},Bl=["title"],ql={class:"relative z-10 flex items-center justify-center w-8 h-full"},zl={class:"relative z-10 flex items-center justify-center w-8 h-full"},Hl={class:"px-4 pt-3 pb-4 border-b border-neutral-200 dark:border-neutral-700"},Wl={class:"grid grid-cols-5 gap-3"},Jl=["onClick","title"],Kl={key:0,class:"w-2 h-2 rounded-full bg-white shadow-sm"},Gl={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"},Xl=me({__name:"Sidebar",props:{isCollapsed:{type:Boolean},isDark:{type:Boolean}},emits:["toggle-sidebar","toggle-theme"],setup(t,{emit:n}){function s(te){if(te.startsWith("/src/")||te.startsWith("data:"))return te;const H=dt();return H==="/"?te.replace("/agents/","/"):te.replace("/agents/",`${H}/`)}const i=s(ha),l=s(ga),u=s(yl),r=s(kl),c=t,f=Ye(),g=lt(),d=J(()=>f.name);function p(te){const H=f.path;return H===te.path||H.startsWith(te.path+"/")}const h=J(()=>c.isDark?l:i),_=J(()=>c.isDark?r:u),b=[{id:"threads",label:"Threads",icon:Qo,path:"/threads"},{id:"agents",label:"Agents",icon:Rt,path:"/agents"},{id:"prompts",label:"Prompts",icon:Nt,path:"/prompts"},{id:"tools",label:"Tools",icon:Oo,path:"/tools",hasSubnav:!0,subnav:[{id:"tools-functions",label:"Functions",icon:tl,path:"/tools#functions"},{id:"tools-prompts",label:"Prompts",icon:Nt,path:"/tools#prompts"},{id:"tools-agents",label:"Agents",icon:Rt,path:"/tools#agents"}]},{id:"models",label:"Models",icon:Eo,path:"/models"},{id:"providers",label:"Providers",icon:Po,path:"/providers"}],m=te=>{g.push(te)},y=te=>{g.push(te),k.value=!1},x=J(()=>typeof d.value=="string"&&(d.value==="tools"||d.value.startsWith("tools-"))),k=v(!1),{theme:D,themes:q,setTheme:B}=xl(),F={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"},T=J(()=>d.value==="users"||d.value==="api-keys"),$=()=>{k.value=!k.value},K=()=>{localStorage.removeItem("auth_token"),g.push("/login")},oe=te=>{const H=te.target;k.value&&!H.closest(".settings-menu-container")&&(k.value=!1)};return Me(()=>{document.addEventListener("click",oe)}),Be(()=>{document.removeEventListener("click",oe)}),(te,H)=>(a(),o("aside",{class:ae(["flex flex-col transition-all duration-300 pt-2.5",t.isCollapsed?"w-16":"w-60"])},[e("div",{class:ae(`flex items-center justify-between ${t.isCollapsed?"px-2 py-4":"p-4"}`)},[t.isCollapsed?V("",!0):(a(),o("img",{key:0,src:h.value,alt:"AgentBuilder",class:"h-8 mr-2 mt-0.5"},null,8,_l)),e("button",{onClick:H[0]||(H[0]=P=>te.$emit("toggle-sidebar")),class:ae(`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?(a(),o("img",{key:1,src:_.value,alt:"AgentBuilder",class:"w-7 h-7 m-auto"},null,8,$l)):(a(),ne(X(qo),{key:0,class:"w-5 h-5"}))],2)],2),e("nav",Cl,[e("div",Tl,[(a(),o(ve,null,ke(b,P=>(a(),o(ve,{key:P.id},[P.hasSubnav?(a(),o("div",Sl,[e("button",{onClick:C=>m(P.path),class:ae(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all w-full",x.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?P.label:void 0},[(a(),ne(Ze(P.icon),{class:"w-5 h-5 flex-shrink-0"})),t.isCollapsed?V("",!0):(a(),o("span",Ml,S(P.label),1))],10,Vl),!t.isCollapsed&&P.subnav?(a(),o("div",Il,[(a(!0),o(ve,null,ke(P.subnav,C=>(a(),o("button",{key:C.id,onClick:L=>m(C.path),class:ae(["flex items-center gap-3 px-3 py-1.5 text-sm transition-all w-full",d.value===C.id?"bg-black text-white dark:bg-white dark:text-black rounded":"hover:underline"])},[(a(),ne(Ze(C.icon),{class:"w-4 h-4 flex-shrink-0"})),e("span",Ll,S(C.label),1)],10,El))),128))])):V("",!0)])):(a(),o("button",{key:1,onClick:C=>m(P.path),class:ae(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all",p(P)?"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?P.label:void 0},[(a(),ne(Ze(P.icon),{class:"w-5 h-5 flex-shrink-0"})),t.isCollapsed?V("",!0):(a(),o("span",Pl,S(P.label),1))],10,Al))],64))),64))]),e("div",Dl,[e("a",{href:"https://docs.standardagentbuilder.com/",target:"_blank",rel:"noopener noreferrer",class:ae(["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},[A(X(ml),{class:"w-5 h-5 flex-shrink-0"}),t.isCollapsed?V("",!0):(a(),o("span",Ol," Docs ")),t.isCollapsed?V("",!0):(a(),ne(X(hl),{key:1,class:"w-3 h-3 flex-shrink-0 opacity-50"}))],10,jl),e("div",{class:ae(["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",Ul,[e("button",{onClick:Ee($,["stop"]),class:ae(["p-2 rounded transition-colors flex items-center",k.value||T.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"},[A(X(No),{class:"w-5 h-5 flex-shrink-0"})],2),k.value?(a(),o("div",Rl,[A(Qe,{"offset-x":6,"offset-y":6,intensity:.4},{default:be(()=>[e("div",Nl,[e("div",Fl,[H[4]||(H[4]=e("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Appearance ",-1)),e("button",{onClick:H[1]||(H[1]=Ee(P=>te.$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:ae(["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",ql,[A(X(Wo),{class:ae(["w-4 h-4",t.isDark?"text-neutral-500":"text-black"])},null,8,["class"])]),e("span",zl,[A(X(Go),{class:ae(["w-4 h-4",t.isDark?"text-white":"text-neutral-400"])},null,8,["class"])])],8,Bl)]),e("div",Hl,[H[5]||(H[5]=e("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Accent Color ",-1)),e("div",Wl,[(a(!0),o(ve,null,ke(X(q),P=>(a(),o("button",{key:P,onClick:Ee(C=>X(B)(P),["stop"]),class:ae(["w-6 h-6 rounded-full transition-all flex items-center justify-center ring-1 ring-black/10 dark:ring-white/10",[F[P],X(D)===P?"ring-2 ring-black/50 dark:ring-white/50":"hover:scale-110"]]),title:P.charAt(0).toUpperCase()+P.slice(1)},[X(D)===P?(a(),o("span",Kl)):V("",!0)],10,Jl))),128))])]),e("button",{onClick:H[2]||(H[2]=P=>y("/settings/users")),class:ae(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",d.value==="users"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[A(X(rl),{class:"w-4 h-4 flex-shrink-0"}),H[6]||(H[6]=e("span",{class:"whitespace-nowrap"},"Users",-1))],2),e("button",{onClick:H[3]||(H[3]=P=>y("/settings/api-keys")),class:ae(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",d.value==="api-keys"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[A(X(ul),{class:"w-4 h-4 flex-shrink-0"}),H[7]||(H[7]=e("span",{class:"whitespace-nowrap"},"API Keys",-1))],2)])]),_:1})])):V("",!0)]),e("button",{onClick:K,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"},[A(X(ll),{class:"w-5 h-5 flex-shrink-0"}),t.isCollapsed?V("",!0):(a(),o("span",Gl,"Logout"))])],2)])])],2))}}),Yl={class:"warning-banner-container"},Ql={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"},Zl={class:"flex items-center gap-2"},es=["onClick"],ts=me({__name:"WarningBanner",setup(t){const n=v([]),s=v(new Set),i=async()=>{if(localStorage.getItem("auth_token"))try{const f=await fetch(ue("/api/diagnostics"));if(f.ok){const g=await f.json();n.value=g.warnings||[]}}catch{}},l=c=>{const f=`${c.type}:${c.details?.name||c.message}`;s.value.add(f)},u=c=>{const f=`${c.type}:${c.details?.name||c.message}`;return!s.value.has(f)},r=c=>{if(c.type==="duplicate_tool_name"){const f=c.details?.sources?.join(" and ")||"multiple sources";return`Duplicate tool name "${c.details?.name}" (defined as both ${f}). This may cause unexpected behavior.`}return c.message};return Me(()=>{i()}),(c,f)=>(a(),o("div",Yl,[(a(!0),o(ve,null,ke(n.value,g=>(a(),o(ve,{key:`${g.type}:${g.details?.name}`},[u(g)?(a(),o("div",Ql,[e("div",Zl,[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,S(r(g)),1)]),e("button",{onClick:d=>l(g),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,es)])):V("",!0)],64))),128))]))}}),as={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"},os={class:"flex-1 overflow-auto"},ls=me({__name:"App",setup(t){fa();const n=Ye(),s=v(!1),i=v(!1),l=J(()=>n.name!=="login"),u=()=>{s.value=!s.value},r=()=>{i.value=!i.value,i.value?(document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark")):(document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light"))};return Me(()=>{const c=localStorage.getItem("theme");(c==="dark"||!c&&window.matchMedia("(prefers-color-scheme: dark)").matches)&&(i.value=!0,document.documentElement.classList.add("dark"))}),(c,f)=>(a(),o("div",{class:ae(["app-container relative flex h-screen font-sans bg-neutral-50/80 text-black dark:bg-black dark:text-white",{"is-dark":i.value}])},[l.value?(a(),ne(Xl,{key:0,"is-collapsed":s.value,"is-dark":i.value,onToggleSidebar:u,onToggleTheme:r},null,8,["is-collapsed","is-dark"])):V("",!0),l.value?(a(),o("main",as,[A(ts),e("div",os,[A(X(Lt))])])):(a(),ne(X(Lt),{key:1}))],2))}}),tt=(t,n)=>{const s=t.__vccOpts||t;for(const[i,l]of n)s[i]=l;return s},ss=tt(ls,[["__scopeId","data-v-2125e5d3"]]),ns={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function rs(t,n){return a(),o("svg",ns,[...n[0]||(n[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 is=De({name:"lucide-trash-2",render:rs}),ds={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function us(t,n){return a(),o("svg",ds,[...n[0]||(n[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 cs=De({name:"lucide-edit",render:us}),ps={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ms(t,n){return a(),o("svg",ps,[...n[0]||(n[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 $t=De({name:"lucide-eye",render:ms}),vs={class:"w-full"},fs={class:"border border-black dark:border-neutral-300 rounded overflow-hidden"},hs={class:"overflow-x-auto"},gs={class:"w-full"},bs={class:"border-b border-black dark:border-neutral-300"},xs={key:0,class:"px-4 py-3 text-right font-medium text-sm"},ys={key:0},ks=["colspan"],ws={key:1},_s=["colspan"],$s=["innerHTML"],Cs={key:0,class:"px-4 py-3 text-right"},Ts={class:"inline-flex gap-1"},Ss=["onClick","title"],Ge=me({__name:"DataTable",props:{columns:{},data:{},actions:{},emptyMessage:{default:"No data available"},loading:{type:Boolean,default:!1}},setup(t){const n=u=>{switch(u){case"edit":return cs;case"delete":return is;case"view":return $t;default:return null}},s=(u,r)=>{const c=u[r.key];return r.formatter?r.formatter(c):c??"-"},i=u=>{switch(u){case"center":return"text-center";case"right":return"text-right";default:return"text-left"}},l=(u,r)=>{if(u.confirm){const c=u.confirmMessage||`Are you sure you want to ${u.label.toLowerCase()}?`;confirm(c)&&u.handler(r)}else u.handler(r)};return(u,r)=>(a(),o("div",vs,[e("div",fs,[e("div",hs,[e("table",gs,[e("thead",bs,[e("tr",null,[(a(!0),o(ve,null,ke(t.columns,c=>(a(),o("th",{key:c.key,class:ae(["px-4 py-3 font-medium text-sm",i(c.align),c.width||""])},S(c.label),3))),128)),t.actions&&t.actions.length>0?(a(),o("th",xs," Actions ")):V("",!0)])]),e("tbody",null,[t.loading?(a(),o("tr",ys,[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"})]),Ce(" Loading... ")],-1)])],8,ks)])):t.data.length===0?(a(),o("tr",ws,[e("td",{colspan:t.columns.length+(t.actions?1:0),class:"px-4 py-8 text-center text-neutral-500"},S(t.emptyMessage),9,_s)])):(a(!0),o(ve,{key:2},ke(t.data,(c,f)=>(a(),o("tr",{key:f,class:"border-t border-neutral-200 dark:border-neutral-800 hover:bg-black/5 dark:hover:bg-white/5 transition-colors"},[(a(!0),o(ve,null,ke(t.columns,g=>(a(),o("td",{key:g.key,class:ae(["px-4 py-3 text-sm",i(g.align)])},[et(u.$slots,`cell-${g.key}`,{value:c[g.key],row:c,column:g},()=>[g.html?(a(),o("span",{key:0,innerHTML:s(c,g)},null,8,$s)):(a(),o(ve,{key:1},[Ce(S(s(c,g)),1)],64))])],2))),128)),t.actions&&t.actions.length>0?(a(),o("td",Cs,[e("div",Ts,[(a(!0),o(ve,null,ke(t.actions,(g,d)=>(a(),o("button",{key:d,onClick:p=>l(g,c),class:"p-1.5 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",title:g.label},[(a(),ne(Ze(n(g.icon)),{class:"w-4 h-4"}))],8,Ss))),128))])])):V("",!0)]))),128))])])])])]))}}),Vs=me({__name:"AgentsDataTable",emits:["add","edit","delete"],setup(t,{expose:n,emit:s}){const i=s,l=v([]),u=v(!1),r=[{key:"title",label:"Title",width:"w-1/5"},{key:"type",label:"Type",width:"w-1/12",formatter:d=>d==="dual_ai"?"Dual AI":"AI+Human"},{key:"side_a_agent_prompt_name",label:"Side A",width:"w-1/5",formatter:d=>d||"-"},{key:"side_b_agent_prompt_name",label:"Side B",width:"w-1/5",formatter:d=>d||"Human"},{key:"created_at",label:"Created",width:"w-1/6",formatter:d=>d?new Date(d*1e3).toLocaleDateString():"-"}],c=[{icon:"edit",label:"Edit",handler:d=>i("edit",d)},{icon:"delete",label:"Delete",handler:async d=>{await g(d)},confirm:!0,confirmMessage:"Are you sure you want to delete this agent?"}],f=async()=>{u.value=!0;try{const d=await fetch(ue("/api/agents"));if(d.ok){const p=await d.json();l.value=p.agents||[]}}catch(d){console.error("Error fetching agents:",d)}finally{u.value=!1}},g=async d=>{try{const p=await fetch(ue(`/api/agents/${d.id}`),{method:"DELETE"});if(p.ok)await f();else{const h=await p.json();alert(h.error||"Failed to delete agent")}}catch(p){console.error("Error deleting agent:",p),alert("Failed to delete agent")}};return Me(()=>{f()}),n({refresh:f}),(d,p)=>(a(),o("div",null,[A(Ge,{columns:r,data:l.value,actions:c,loading:u.value,"empty-message":"No agents available. Create your first agent to get started."},null,8,["data","loading"])]))}}),Ms={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Is(t,n){return a(),o("svg",Ms,[...n[0]||(n[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 ba=De({name:"lucide-x",render:Is}),Es={key:0,class:"w-full max-w-md"},Ls={class:"flex items-center justify-between p-4 border-b-2 border-red-600 flex-shrink-0"},As={class:"text-xl font-bold text-red-600"},Ps={class:"p-6"},Ds={class:"text-neutral-700 dark:text-neutral-300 mb-6"},js={class:"flex justify-end gap-3"},xa=me({__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:n}){const s=t,i=n,l=()=>{i("update:modelValue",!1)},u=()=>{i("confirm"),l()},r=()=>{i("cancel"),l()},c=f=>{f.key==="Escape"&&s.modelValue&&r()};return fe(()=>s.modelValue,f=>{f?(document.addEventListener("keydown",c),document.body.style.overflow="hidden"):(document.removeEventListener("keydown",c),document.body.style.overflow="")}),(f,g)=>(a(),ne(it,{to:"body"},[A(Xe,{"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:be(()=>[t.modelValue?(a(),o("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},[A(Xe,{"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:be(()=>[t.modelValue?(a(),o("div",Es,[A(Qe,{"offset-x":12,"offset-y":12,intensity:.4},{default:be(()=>[e("div",{class:"bg-white dark:bg-black border-2 border-red-600 flex flex-col",onClick:g[0]||(g[0]=Ee(()=>{},["stop"]))},[e("div",Ls,[e("h2",As,S(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"},[A(X(ba),{class:"w-5 h-5 text-red-600"})])]),e("div",Ps,[e("p",Ds,S(t.message),1),e("div",js,[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"},S(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"},S(t.confirmText),1)])])])]),_:1})])):V("",!0)]),_:1})])):V("",!0)]),_:1})]))}}),Os={class:"flex items-center justify-between p-4 border-b-2 border-black dark:border-neutral-300 flex-shrink-0"},Us={class:"text-xl font-bold"},Rs={class:"overflow-y-auto flex-1"},Ns={class:"p-6"},Fs={key:0,class:"p-6 border-t-2 border-black dark:border-neutral-300 flex-shrink-0"},He=me({__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:n}){const s=t,i=n,l=v(),u=v(!1),r=v(new Map),c=()=>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(q=>{const B=q.__monacoEditor;if(B&&typeof B.getValue=="function"){const F=B.getValue();r.value.set(q,F)}})},g=()=>{if(!l.value)return!1;const D=l.value.querySelectorAll(".monaco-editor-container");for(const q of D){const B=q.__monacoEditor;if(B&&typeof B.getValue=="function"){const F=B.getValue(),T=r.value.get(q);if(T===void 0||(B.getRawOptions?.()||{}).readOnly===!0)continue;if(F!==T)return!0}}return!1},d=()=>{if(s.hasChanges!==void 0)return s.hasChanges;if(!l.value)return!1;if(g())return!0;const D=l.value.querySelectorAll("form");for(const B of D){const T=B.querySelectorAll("input, textarea, select");for(const $ of T){const K=$;if(K.type==="checkbox"||K.type==="radio"){const oe=K;if(oe.checked!==oe.defaultChecked)return!0}else if(K.tagName==="SELECT"){const oe=K;if(oe.value!==oe.defaultValue)return!0}else if(K.value!==K.defaultValue)return!0}}const q=l.value.querySelectorAll("input:not(form input), textarea:not(form textarea), select:not(form select)");for(const B of q){const F=B;if(F.type==="checkbox"||F.type==="radio"){const T=F;if(T.checked!==T.defaultChecked)return!0}else if(F.tagName==="SELECT"){const T=F;if(T.value!==T.defaultValue)return!0}else if(F.value!==F.defaultValue)return!0}return!1},p=()=>{c()&&d()?u.value=!0:h()},h=()=>{i("update:modelValue",!1),i("close")},_=()=>{u.value=!1,h()},b=()=>{u.value=!1},m=D=>{D.key==="Escape"&&s.modelValue&&(c()||h())};fe(()=>s.modelValue,async D=>{D?(document.addEventListener("keydown",m),document.body.style.overflow="hidden",await Te(),setTimeout(()=>{f()},100)):(document.removeEventListener("keydown",m),document.body.style.overflow="",r.value.clear())});const y=v(!1),x=D=>{y.value=D.target===D.currentTarget},k=D=>{D.target===D.currentTarget&&y.value&&(c()||h()),y.value=!1};return(D,q)=>(a(),ne(it,{to:"body"},[A(Xe,{"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:be(()=>[t.modelValue?(a(),o("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:x,onClick:k},[A(Xe,{"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:be(()=>[t.modelValue?(a(),o("div",{key:0,class:ae(["w-full",t.width,"max-h-[85vh] flex flex-col"])},[A(Qe,{"offset-x":12,"offset-y":12,intensity:.4},{default:be(()=>[e("div",{ref_key:"modalRef",ref:l,class:ae(["bg-white dark:bg-black border-2 border-black dark:border-neutral-300 flex flex-col max-h-[85vh]",t.minHeight])},[e("div",Os,[e("h2",Us,S(t.title),1),e("button",{onClick:p,class:"p-1 hover:bg-black/5 dark:hover:bg-white/10 rounded transition-colors","aria-label":"Close modal"},[A(X(ba),{class:"w-5 h-5"})])]),e("div",Rs,[e("div",Ns,[et(D.$slots,"default")])]),D.$slots.footer?(a(),o("div",Fs,[et(D.$slots,"footer")])):V("",!0)],2)]),_:3})],2)):V("",!0)]),_:3})],32)):V("",!0)]),_:3}),A(xa,{modelValue:u.value,"onUpdate:modelValue":q[0]||(q[0]=B=>u.value=B),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:b},null,8,["modelValue"])]))}}),Bs={class:"space-y-1.5"},qs={key:0,class:"block text-sm font-medium text-neutral-700 dark:text-neutral-300"},zs={key:0,class:"text-red-500"},Hs=["type","value","placeholder","disabled"],Ws={key:1,class:"text-xs text-red-500 dark:text-red-400"},Le=me({__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:n,emit:s}){const i=t,l=s,u=v(null),r=J(()=>["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",i.error?"border-red-500 dark:border-red-400":"border-neutral-300 dark:border-neutral-800",i.disabled?"opacity-50 cursor-not-allowed":""]),c=d=>{const p=d.target;l("update:modelValue",p.value)},f=d=>{l("focus",d)},g=d=>{l("click",d)};return n({inputRef:u}),(d,p)=>(a(),o("div",Bs,[t.label?(a(),o("label",qs,[Ce(S(t.label)+" ",1),t.required?(a(),o("span",zs,"*")):V("",!0)])):V("",!0),e("input",{ref_key:"inputRef",ref:u,type:t.type,value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,class:ae(r.value),onInput:c,onFocus:f,onClick:g},null,42,Hs),t.error?(a(),o("p",Ws,S(t.error),1)):V("",!0)]))}}),Js={class:"space-y-1"},Ks={key:0,class:"block text-sm font-medium"},Gs={key:0,class:"text-red-500"},Xs=["value","placeholder","disabled","rows"],Ys={key:1,class:"text-xs text-red-500 dark:text-red-400"},ya=me({__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:n}){const s=t,i=n,l=J(()=>["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 c=r.target;i("update:modelValue",c.value)};return(r,c)=>(a(),o("div",Js,[t.label?(a(),o("label",Ks,[Ce(S(t.label)+" ",1),t.required?(a(),o("span",Gs,"*")):V("",!0)])):V("",!0),e("textarea",{value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,rows:t.rows,class:ae(l.value),onInput:u},null,42,Xs),t.error?(a(),o("p",Ys,S(t.error),1)):V("",!0)]))}}),Qs={key:0,class:"block text-sm font-medium mb-2"},Zs={key:0,class:"text-red-500"},en=["disabled","aria-expanded"],tn={class:"flex items-center justify-between gap-1"},an={key:0,class:"flex items-center gap-2 text-neutral-400 flex-1 min-w-0"},on={key:1,class:"flex items-center gap-2 flex-1 min-w-0"},ln=["src","alt"],sn={class:"block truncate"},nn={key:2,class:"block truncate text-neutral-400 flex-1 min-w-0"},rn={class:"bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded-lg overflow-hidden"},dn={class:"p-2 border-b border-neutral-200 dark:border-neutral-700"},un=["placeholder"],cn={class:"max-h-60 overflow-y-auto"},pn={key:0,class:"px-4 py-3 text-sm text-neutral-500 dark:text-neutral-400"},mn=["onClick","onMouseenter"],vn={class:"flex-shrink-0 w-5 h-5 mt-0.5"},fn=["src","alt"],hn={key:1,class:"w-full h-full bg-neutral-200 dark:bg-neutral-700 rounded"},gn={class:"flex-1 min-w-0"},bn={class:"text-sm font-medium text-black dark:text-white"},xn={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},yn={key:2,class:"mt-1 text-xs text-red-500 dark:text-red-400"},Ve=me({__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:n}){const s=t,i=n,l=v(!1),u=v(""),r=v(),c=v(),f=v(),g=v(),d=v(-1),p=J(()=>s.options.find($=>$.value===s.modelValue)),h=J(()=>["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"]),_=J(()=>{if(!u.value)return s.options;const $=u.value.toLowerCase();return s.options.filter(K=>K.label.toLowerCase().includes($)||K.value.toLowerCase().includes($)||K.description&&K.description.toLowerCase().includes($))});fe(_,()=>{d.value=-1});const b=()=>{s.disabled||(l.value?x():(l.value=!0,u.value="",d.value=-1,Te(()=>{if(g.value&&(g.value.setAttribute("popover","auto"),g.value.addEventListener("toggle",T),"showPopover"in g.value))try{g.value.showPopover()}catch{}k(),setTimeout(()=>r.value?.focus(),0)})))},m=$=>{i("update:modelValue",$.value),x(),u.value="",d.value=-1},y=$=>{$.stopPropagation(),i("update:modelValue","")},x=()=>{if(g.value){if("hidePopover"in g.value)try{g.value.hidePopover()}catch{}g.value.removeEventListener("toggle",T)}l.value=!1,d.value=-1},k=()=>{if(!f.value||!g.value)return;const $=f.value.getBoundingClientRect();g.value.offsetWidth||$.width,g.value.style.position="fixed",g.value.style.top=`${$.bottom+8}px`,g.value.style.left=`${$.left}px`,g.value.style.width=`${$.width}px`,g.value.style.margin="0"},D=$=>{c.value&&!c.value.contains($.target)&&g.value&&!g.value.contains($.target)&&x()},q=$=>{$.key==="Escape"&&l.value&&(x(),f.value?.focus())},B=$=>{if(!l.value)return;const K=_.value;if(K.length!==0)switch($.key){case"ArrowDown":$.preventDefault(),d.value=d.value<K.length-1?d.value+1:0,F();break;case"ArrowUp":$.preventDefault(),d.value=d.value>0?d.value-1:K.length-1,F();break;case"Enter":$.preventDefault(),d.value>=0&&d.value<K.length&&m(K[d.value]);break}},F=()=>{Te(()=>{const $=g.value?.querySelector(".highlighted-option");$&&$.scrollIntoView({block:"nearest",behavior:"smooth"})})},T=$=>{$.target===g.value&&(l.value=$.newState==="open",l.value&&k())};return Me(()=>{document.addEventListener("click",D),document.addEventListener("keydown",q);const $=()=>{l.value&&k()};window.addEventListener("resize",$),window.addEventListener("scroll",$,!0)}),Be(()=>{document.removeEventListener("click",D),document.removeEventListener("keydown",q),window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0)}),($,K)=>(a(),o("div",{ref_key:"dropdownRef",ref:c,class:"relative"},[t.label?(a(),o("label",Qs,[Ce(S(t.label)+" ",1),t.required?(a(),o("span",Zs,"*")):V("",!0)])):V("",!0),e("button",{ref_key:"buttonRef",ref:f,type:"button",onClick:b,disabled:t.disabled,"aria-expanded":l.value,"aria-haspopup":!0,class:ae(h.value)},[e("div",tn,[t.loading?(a(),o("span",an,[...K[1]||(K[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),Ce(" Loading... ",-1)])])):p.value?(a(),o("span",on,[p.value.icon?(a(),o("img",{key:0,src:p.value.icon,alt:p.value.label,class:"w-5 h-5 flex-shrink-0"},null,8,ln)):V("",!0),e("span",sn,S(p.value.label),1)])):(a(),o("span",nn,S(t.placeholder),1)),p.value&&!t.disabled?(a(),o("button",{key:3,type:"button",onClick:y,class:"flex-shrink-0 p-0.5 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors","aria-label":"Clear selection"},[...K[2]||(K[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)])])):V("",!0),K[3]||(K[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,en),l.value?(a(),o("div",{key:1,ref_key:"popoverRef",ref:g,class:"dropdown-popover"},[A(Qe,{"offset-x":4,"offset-y":4,intensity:.3},{default:be(()=>[e("div",rn,[e("div",dn,[Ie(e("input",{ref_key:"searchInput",ref:r,"onUpdate:modelValue":K[0]||(K[0]=oe=>u.value=oe),type:"text",placeholder:t.searchPlaceholder,onKeydown:B,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,un),[[Oe,u.value]])]),e("div",cn,[_.value.length===0?(a(),o("div",pn," No options found ")):V("",!0),(a(!0),o(ve,null,ke(_.value,(oe,te)=>(a(),o("button",{key:oe.value,type:"button",onClick:H=>m(oe),onMouseenter:H=>d.value=te,class:ae(["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":oe.value===t.modelValue,"bg-neutral-100 dark:bg-neutral-800 highlighted-option":te===d.value}])},[e("div",vn,[oe.icon?(a(),o("img",{key:0,src:oe.icon,alt:oe.label,class:"w-full h-full"},null,8,fn)):(a(),o("div",hn))]),e("div",gn,[e("div",bn,S(oe.label),1),oe.description?(a(),o("div",xn,S(oe.description),1)):V("",!0)])],42,mn))),128))])])]),_:1})],512)):V("",!0),t.error?(a(),o("p",yn,S(t.error),1)):V("",!0)],512))}}),kn={class:"flex items-start"},wn=["for"],_n=["id","checked","disabled"],$n={class:"flex items-center h-5"},Cn={class:"flex-1"},Tn={key:0,class:"text-red-500"},Sn={key:1,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-1"},Vn={key:2,class:"text-xs text-red-500 dark:text-red-400 mt-1"},Pe=me({__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:n}){const s=t,i=n,l=Da(),u=J(()=>["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=c=>{if(!s.disabled){const f=c.target;i("update:modelValue",f.checked)}};return(c,f)=>(a(),o("div",kn,[e("label",{for:X(l),class:ae(["flex items-start space-x-3 cursor-pointer select-none",{"cursor-not-allowed":t.disabled}])},[e("input",{id:X(l),type:"checkbox",checked:t.modelValue,disabled:t.disabled,onChange:r,class:"absolute left-[-9999px]"},null,40,_n),e("div",$n,[e("span",{class:ae(u.value)},null,2)]),e("div",Cn,[t.label?(a(),o("span",{key:0,class:ae(["block text-sm font-medium",{"opacity-50":t.disabled}])},[Ce(S(t.label)+" ",1),t.required?(a(),o("span",Tn,"*")):V("",!0)],2)):V("",!0),t.helpText?(a(),o("p",Sn,S(t.helpText),1)):V("",!0),t.error?(a(),o("p",Vn,S(t.error),1)):V("",!0)])],10,wn)]))}}),Mn={class:"space-y-4"},In={class:"flex items-start gap-2"},En={class:"flex-1"},Ln=["onClick","disabled","title"],An={key:0,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Pn={key:1,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Dn={key:0,class:"text-xs text-neutral-400 dark:text-neutral-500 mt-1"},jn={key:0,class:"text-amber-500 dark:text-amber-400 ml-1"},On={class:"flex-1"},Un={class:"flex-1"},Rn=["onClick","disabled"],Nn=["disabled"],ka=me({__name:"TenvPropertyList",props:{modelValue:{},inherited:{default:()=>[]},allowCustom:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{emit:n}){const s=t,i=n,l=v(new Set),u=v([]),r=J(()=>new Set(s.inherited.map(m=>m.name)));fe(()=>s.modelValue,m=>{const y=Object.keys(m).filter(k=>!r.value.has(k)),x=new Set(u.value.map(k=>k.name));for(const k of y)x.has(k)||u.value.push({id:crypto.randomUUID(),name:k,value:String(m[k]??"")})},{immediate:!0,deep:!0});const c=m=>{if(l.value.has(m)){l.value.delete(m);const y=s.inherited.find(x=>x.name===m);y&&f(m,y.value)}else l.value.add(m)},f=(m,y)=>{const x={...s.modelValue};y===void 0||y===""?delete x[m]:x[m]=y,i("update:modelValue",x)},g=m=>s.modelValue[m.name]!==void 0?String(s.modelValue[m.name]):m.value!==void 0?String(m.value):"",d=(m,y)=>{f(m.name,y||void 0)},p=()=>{u.value.push({id:crypto.randomUUID(),name:"",value:""})},h=m=>{const y=u.value.find(x=>x.id===m);if(y&&y.name){const x={...s.modelValue};delete x[y.name],i("update:modelValue",x)}u.value=u.value.filter(x=>x.id!==m)},_=(m,y,x)=>{const k=u.value.find(q=>q.id===m);if(!k)return;k.name=x;const D={...s.modelValue};y&&delete D[y],x&&k.value&&(D[x]=k.value),i("update:modelValue",D)},b=(m,y)=>{const x=u.value.find(k=>k.id===m);x&&(x.value=y,x.name&&f(x.name,y||void 0))};return(m,y)=>(a(),o("div",Mn,[(a(!0),o(ve,null,ke(t.inherited,x=>(a(),o("div",{key:x.name,class:"relative"},[e("div",In,[e("div",En,[A(Le,{"model-value":g(x),label:x.name,placeholder:x.description||"Enter value...",disabled:t.disabled||!l.value.has(x.name),required:x.required,"onUpdate:modelValue":k=>d(x,k)},null,8,["model-value","label","placeholder","disabled","required","onUpdate:modelValue"])]),e("button",{type:"button",onClick:k=>c(x.name),disabled:t.disabled,class:"mt-7 p-2 text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300 transition-colors disabled:opacity-50",title:l.value.has(x.name)?"Lock (use inherited value)":"Unlock to override"},[l.value.has(x.name)?(a(),o("svg",Pn,[...y[1]||(y[1]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 11V7a4 4 0 118 0m-4 8v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2z"},null,-1)])])):(a(),o("svg",An,[...y[0]||(y[0]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"},null,-1)])]))],8,Ln)]),x.source?(a(),o("p",Dn,[Ce(" From: "+S(x.source)+" ",1),x.required?(a(),o("span",jn,"(required)")):V("",!0)])):V("",!0)]))),128)),(a(!0),o(ve,null,ke(u.value,x=>(a(),o("div",{key:x.id,class:"flex items-start gap-2"},[e("div",On,[A(Le,{"model-value":x.name,label:"Name",placeholder:"Variable name",disabled:t.disabled,"onUpdate:modelValue":k=>_(x.id,x.name,k)},null,8,["model-value","disabled","onUpdate:modelValue"])]),e("div",Un,[A(Le,{"model-value":x.value,label:"Value",placeholder:"Variable value",disabled:t.disabled,"onUpdate:modelValue":k=>b(x.id,k)},null,8,["model-value","disabled","onUpdate:modelValue"])]),e("button",{type:"button",onClick:k=>h(x.id),disabled:t.disabled,class:"mt-7 p-2 text-red-400 hover:text-red-600 dark:hover:text-red-300 transition-colors disabled:opacity-50",title:"Remove"},[...y[2]||(y[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:"M6 18L18 6M6 6l12 12"})],-1)])],8,Rn)]))),128)),t.allowCustom?(a(),o("button",{key:0,type:"button",onClick:p,disabled:t.disabled,class:"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"},[...y[3]||(y[3]=[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"})]),Ce(" Add custom variable ")],-1)])],8,Nn)):V("",!0)]))}});async function ze(t,n={}){const s=localStorage.getItem("auth_token"),i={"Content-Type":"application/json",...n.headers};s&&(i.Authorization=`Bearer ${s}`);const l=t.startsWith("/")?t:`/${t}`,u=await fetch(ue(`/api${l}`),{...n,headers:i});if(u.status===401)throw localStorage.removeItem("auth_token"),window.location.href=ue("/login"),new Error("Unauthorized");return u}const Fn={key:0,class:"min-h-[400px] flex items-center justify-center"},Bn={key:1,class:"space-y-6 pr-2 pb-4"},qn={key:0,class:"p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg"},zn={class:"text-sm text-red-800 dark:text-red-200"},Hn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Wn={key:1,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Jn={key:1},Kn={key:2},Gn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Xn={key:3},Yn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Qn={class:"grid grid-cols-2 gap-6"},Zn={class:"space-y-4 p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},er={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},tr={class:"space-y-3"},ar={class:"flex items-start"},or={key:0,class:"ml-8 mt-2 space-y-2"},lr={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"},sr={key:1},nr={key:0,class:"mt-3 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded"},rr={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},ir={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},dr={class:"space-y-4 p-4 bg-neutral-100 dark:bg-neutral-800 rounded-lg"},ur={class:"font-semibold text-base mb-4 text-neutral-800 dark:text-neutral-200"},cr={key:0,class:"flex flex-col items-center justify-center py-8"},pr={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},mr={class:"space-y-3"},vr={class:"flex items-start"},fr={key:0,class:"ml-8 mt-2 space-y-2"},hr={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"},gr={key:1},br={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},xr={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},yr={key:4,class:"space-y-3"},kr={class:"flex items-center justify-between"},wr={key:0,class:"text-xs text-neutral-500"},_r={class:"flex justify-between"},$r=["disabled"],Cr=me({__name:"AgentModal",props:{modelValue:{type:Boolean},editAgent:{},mode:{},apiError:{}},emits:["update:modelValue","save"],setup(t,{emit:n}){const s=t,i=n,l=J(()=>s.mode==="edit"),u=v(!1),r=v(""),c=v(""),f=v(""),g=v(null),d=v(""),p=v("dual_ai"),h=v(!1),_=v(""),b=v(""),m=v(null),y=v(""),x=v(""),k=v(""),D=v(""),q=v(!0),B=v(!1),F=v(""),T=v(""),$=v(""),K=v(""),oe=v(!1),te=v(null),H=v(""),P=v(""),C=v(""),L=v(""),G=v(""),ee=v(""),E=v(!0),U=v(!1),Z=v(""),se=v(""),j=v(""),M=v(""),w=v(null),R=v(""),I=v(""),le=v(""),O=v([]),W=v({}),ce=v(!1),{data:z,execute:N}=Ue(ue("/api/prompts"),{immediate:!1}).json(),{data:Q,execute:we}=Ue(ue("/api/tools?schema=true"),{immediate:!1}).json(),de=v(null),pe=v(!1),ie=v(null),ye=v(!1),_e=v(!1),Ae=J(()=>{if(!z.value)return[{value:"",label:"Select a prompt..."}];const ge=z.value?.prompts||[];return[{value:"",label:"None"},...ge.map(Y=>({value:Y.id,label:Y.name}))]}),Fe=ge=>Q.value?Q.value[ge]:null,Re=J(()=>!de.value||!de.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...de.value.tools.map(ge=>{const Y=typeof ge=="string"?ge:ge.name;return{value:Y,label:Y}})]),xe=J(()=>!ie.value||!ie.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...ie.value.tools.map(ge=>{const Y=typeof ge=="string"?ge:ge.name;return{value:Y,label:Y}})]),he=J(()=>{if(!F.value)return[];const ge=Fe(F.value);return!ge||!ge.schema||!ge.schema.properties?[]:Object.keys(ge.schema.properties).map(Y=>({value:Y,label:Y}))}),$e=J(()=>{if(!Z.value)return[];const ge=Fe(Z.value);return!ge||!ge.schema||!ge.schema.properties?[]:Object.keys(ge.schema.properties).map(Y=>({value:Y,label:Y}))}),Ne=async()=>{const ge=[k.value,G.value].filter(Boolean);if(ge.length===0){O.value=[];return}ce.value=!0;try{const Y=[],re=new Set;for(const qe of ge){const je=await ze(`/prompts/${qe}/tenvs`);if(je.ok){const gt=await je.json();for(const Je of gt.tenvs||[])re.has(Je.name)||(re.add(Je.name),Y.push({name:Je.name,value:Je.value,required:Je.required,description:Je.description,source:Je.source}))}}O.value=Y}catch(Y){console.error("Error fetching tenvs from prompts:",Y),O.value=[]}finally{ce.value=!1}},ht=[{value:"dual_ai",label:"AI + AI (Subagent)"},{value:"ai_human",label:"AI + Human"}],It=J({get(){return c.value},set(ge){const Y=g.value?.inputRef,re=Y?.selectionStart??ge.length;let qe=ge.toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_]/g,"");if(qe.endsWith("_agent")||(qe=qe+"_agent"),c.value=qe,Y){Y.value=qe;const je=Math.min(re,qe.length-6);Y.setSelectionRange(je,je)}}}),Et=async()=>{await Te();const ge=g.value?.inputRef;if(ge&&c.value.endsWith("_agent")){const Y=c.value.length-6;ge.setSelectionRange(Y,Y)}},Sa=ge=>!ge||ge==="_agent"?(f.value="Name is required",!1):/^[a-z][a-z0-9_]*_agent$/.test(ge)?(f.value="",!0):(f.value="Name must start with a letter",!1),ut=()=>{c.value="",r.value="",f.value="",d.value="",p.value="dual_ai",h.value=!1,_.value="",b.value="",m.value=null,y.value="",k.value="",D.value="",q.value=!0,B.value=!1,F.value="",T.value="",$.value="",K.value="",oe.value=!1,te.value=null,H.value="",P.value="",C.value="",de.value=null,G.value="",ee.value="",E.value=!0,U.value=!1,Z.value="",se.value="",j.value="",M.value="",w.value=null,R.value="",I.value="",le.value="",ie.value=null,O.value=[],W.value={}},Va=async()=>{if(s.editAgent?.id){u.value=!0,_e.value=!0;try{const ge=await fetch(ue(`/api/agents/${s.editAgent.id}`));if(ge.ok){const Y=await ge.json(),re=Y.agent||Y;c.value=re.name||"",r.value=re.name||"",d.value=re.title||"",p.value=re.type||"dual_ai",h.value=re.expose_as_tool||!1,_.value=re.tool_description||"",m.value=re.max_session_turns;const qe=re.side_a_stop_tool||"",je=re.side_a_stop_tool_response_property||"",gt=re.side_b_stop_tool||"",Je=re.side_b_stop_tool_response_property||"",Ea=re.side_a_end_conversation_tool||"",La=re.side_b_end_conversation_tool||"";x.value=re.side_a_label||"",L.value=re.side_b_label||"",k.value=re.side_a_agent_prompt||"",G.value=re.side_b_agent_prompt||"",q.value=!!re.side_a_stop_on_response,B.value=!!re.side_a_stop_tool,oe.value=!!re.side_a_manual_stop_condition,te.value=re.side_a_max_steps,E.value=!!re.side_b_stop_on_response,U.value=!!re.side_b_stop_tool,w.value=re.side_b_max_steps,await Te(),F.value=qe,$.value=je,Z.value=gt,j.value=Je,P.value=Ea,I.value=La,re.tenvs&&typeof re.tenvs=="object"&&(W.value=re.tenvs),await Ne()}}catch(ge){console.error("Error loading agent data:",ge)}finally{u.value=!1,_e.value=!1}}},Ma=async()=>{f.value="",y.value="",D.value="",T.value="",K.value="",H.value="",C.value="",ee.value="",se.value="",M.value="",R.value="",le.value="";let ge=!1;Sa(c.value)||(ge=!0);const Y=c.value;p.value==="dual_ai"&&m.value!==null&&m.value!==void 0&&m.value<=0&&(y.value="Max session turns must be a positive number",ge=!0),k.value||(D.value="Please select an agent prompt",ge=!0);const re=q.value||F.value,qe=p.value==="ai_human"&&oe.value;if(!re&&!qe&&(D.value="At least one stop condition is required (or check manual stop condition for ai_human agents)",ge=!0),F.value&&!$.value&&(K.value="Response property required when using stop tool",ge=!0),te.value!==null&&te.value<=0&&(H.value="Max steps must be a positive number",ge=!0),p.value==="dual_ai"&&!P.value&&!I.value&&(C.value="At least one side must have an end conversation tool",le.value="At least one side must have an end conversation tool",ge=!0),p.value==="dual_ai"&&(G.value||(ee.value="Please select an agent prompt",ge=!0),Z.value&&!j.value&&(M.value="Response property required when using stop tool",ge=!0),w.value!==null&&w.value<=0&&(R.value="Max steps must be a positive number",ge=!0)),ge)return;const je={name:Y,title:d.value||null,type:p.value,expose_as_tool:h.value,tool_description:h.value?_.value:null,max_session_turns:p.value==="dual_ai"?m.value:null,side_a_label:x.value||null,side_a_agent_prompt:k.value,side_a_stop_on_response:q.value,side_a_stop_tool:F.value||null,side_a_stop_tool_response_property:$.value||null,side_a_manual_stop_condition:oe.value,side_a_max_steps:te.value,side_a_end_conversation_tool:P.value||null};p.value==="dual_ai"&&(je.side_b_label=L.value||null,je.side_b_agent_prompt=G.value,je.side_b_stop_on_response=E.value,je.side_b_stop_tool=Z.value||null,je.side_b_stop_tool_response_property=j.value||null,je.side_b_max_steps=w.value,je.side_b_end_conversation_tool=I.value||null),Object.keys(W.value).length>0&&(je.tenvs=W.value),l.value&&s.editAgent?.id&&(je.id=s.editAgent.id),i("save",je)},Ia=()=>{ut(),i("update:modelValue",!1)};return fe(k,async ge=>{if(_e.value||(F.value="",$.value=""),!ge){de.value=null;return}pe.value=!0;try{const Y=await fetch(ue(`/api/prompts/${ge}`));Y.ok&&(de.value=await Y.json())}catch(Y){console.error("Error fetching Side A prompt:",Y)}finally{pe.value=!1}_e.value||await Ne()}),fe(G,async ge=>{if(_e.value||(Z.value="",j.value=""),!ge){ie.value=null;return}ye.value=!0;try{const Y=await fetch(ue(`/api/prompts/${ge}`));Y.ok&&(ie.value=await Y.json())}catch(Y){console.error("Error fetching Side B prompt:",Y)}finally{ye.value=!1}_e.value||await Ne()}),fe(B,ge=>{ge||(F.value="",$.value="")}),fe(U,ge=>{ge||(Z.value="",j.value="")}),fe(()=>s.modelValue,async ge=>{ge?(await Promise.all([N(),we()]),l.value?(ut(),await Va()):ut()):ut()}),(ge,Y)=>(a(),ne(He,{"model-value":t.modelValue,"onUpdate:modelValue":Y[24]||(Y[24]=re=>ge.$emit("update:modelValue",re)),title:l.value?"Edit Agent":"Create Agent",width:"max-w-6xl"},{footer:be(()=>[e("div",_r,[e("button",{onClick:Ia,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:Ma,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},S(l.value?"Update Agent":"Create Agent"),9,$r)])]),default:be(()=>[u.value?(a(),o("div",Fn,[...Y[25]||(Y[25]=[e("span",{class:"text-neutral-500"},"Loading agent data...",-1)])])):(a(),o("div",Bn,[t.apiError?(a(),o("div",qn,[e("p",zn,S(t.apiError),1)])):V("",!0),e("div",null,[A(Le,{ref_key:"nameInputRef",ref:g,modelValue:It.value,"onUpdate:modelValue":Y[0]||(Y[0]=re=>It.value=re),label:"Agent Name",error:f.value,required:"",disabled:l.value,onFocus:Et,onClick:Et},null,8,["modelValue","error","disabled"]),!f.value&&!l.value?(a(),o("p",Hn," Automatically formatted to snake_case with _agent suffix (e.g., research_agent) ")):V("",!0),l.value?(a(),o("p",Wn," Agent names cannot be changed after creation (used as foreign key for threads) ")):V("",!0)]),e("div",null,[A(Le,{modelValue:d.value,"onUpdate:modelValue":Y[1]||(Y[1]=re=>d.value=re),label:"Display Title (Optional)"},null,8,["modelValue"]),Y[26]||(Y[26]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Human-readable title shown in the UI (e.g., Research Assistant). If not set, the name will be used. ",-1))]),e("div",null,[A(Ve,{modelValue:p.value,"onUpdate:modelValue":Y[2]||(Y[2]=re=>p.value=re),label:"Agent Type",options:ht},null,8,["modelValue"]),Y[27]||(Y[27]=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))]),p.value==="dual_ai"?(a(),o("div",Jn,[A(Pe,{modelValue:h.value,"onUpdate:modelValue":Y[3]||(Y[3]=re=>h.value=re),label:"Expose as Tool"},null,8,["modelValue"]),Y[28]||(Y[28]=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))])):V("",!0),h.value&&p.value==="dual_ai"?(a(),o("div",Kn,[A(ya,{modelValue:_.value,"onUpdate:modelValue":Y[4]||(Y[4]=re=>_.value=re),label:"Tool Description",placeholder:"Describe what this agent does when called as a tool",error:b.value,rows:3},null,8,["modelValue","error"]),b.value?V("",!0):(a(),o("p",Gn," This description helps other agents understand when to use this agent "))])):V("",!0),p.value==="dual_ai"?(a(),o("div",Xn,[A(Le,{"model-value":m.value?.toString()||"","onUpdate:modelValue":Y[5]||(Y[5]=re=>m.value=re?parseInt(re):null),label:"Max Session Turns",type:"number",error:y.value,placeholder:"Unlimited"},null,8,["model-value","error"]),y.value?V("",!0):(a(),o("p",Yn," Maximum number of back-and-forth exchanges between the two agents before the conversation ends "))])):V("",!0),e("div",Qn,[e("div",Zn,[Y[35]||(Y[35]=e("h4",{class:"font-semibold text-base mb-4 text-neutral-800 dark:text-neutral-200"}," Side A (AI) ",-1)),e("div",null,[A(Le,{modelValue:x.value,"onUpdate:modelValue":Y[6]||(Y[6]=re=>x.value=re),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer, Support"},null,8,["modelValue"]),Y[29]||(Y[29]=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,[A(Ve,{modelValue:k.value,"onUpdate:modelValue":Y[7]||(Y[7]=re=>k.value=re),label:"Agent Prompt",options:Ae.value,error:D.value,required:""},null,8,["modelValue","options","error"]),D.value?V("",!0):(a(),o("p",er," The prompt that defines this agent's behavior "))]),e("div",tr,[Y[32]||(Y[32]=e("label",{class:"block text-sm font-medium"}," Stop Conditions ",-1)),Y[33]||(Y[33]=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",ar,[A(Pe,{modelValue:q.value,"onUpdate:modelValue":Y[8]||(Y[8]=re=>q.value=re),label:"Stop when agent returns content"},null,8,["modelValue"])]),Y[34]||(Y[34]=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,[A(Pe,{modelValue:B.value,"onUpdate:modelValue":Y[9]||(Y[9]=re=>B.value=re),label:"Stop on specific tool call"},null,8,["modelValue"]),B.value?(a(),o("div",or,[A(Ve,{modelValue:F.value,"onUpdate:modelValue":Y[10]||(Y[10]=re=>F.value=re),label:"Stop Tool",options:Re.value,error:T.value,placeholder:"Select a tool...",disabled:pe.value||!k.value},null,8,["modelValue","options","error","disabled"]),T.value?V("",!0):(a(),o("p",lr," Agent stops when this tool is called ")),F.value?(a(),o("div",sr,[A(Ve,{modelValue:$.value,"onUpdate:modelValue":Y[11]||(Y[11]=re=>$.value=re),label:"Response Property",options:he.value,error:K.value,placeholder:"Select property..."},null,8,["modelValue","options","error"]),Y[30]||(Y[30]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Property from tool arguments to return as final response ",-1))])):V("",!0)])):V("",!0)]),p.value==="ai_human"&&!q.value&&!B.value?(a(),o("div",nr,[A(Pe,{modelValue:oe.value,"onUpdate:modelValue":Y[12]||(Y[12]=re=>oe.value=re),label:"I have manually implemented a stop condition"},null,8,["modelValue"]),Y[31]||(Y[31]=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))])):V("",!0)]),e("div",null,[A(Le,{"model-value":te.value?.toString()||"","onUpdate:modelValue":Y[13]||(Y[13]=re=>te.value=re?parseInt(re):null),label:"Max Steps",type:"number",error:H.value,placeholder:"Unlimited"},null,8,["model-value","error"]),H.value?V("",!0):(a(),o("p",rr," Maximum steps this side can take before yielding (safety limit) "))]),e("div",null,[A(Ve,{modelValue:P.value,"onUpdate:modelValue":Y[14]||(Y[14]=re=>P.value=re),label:"End Conversation Tool",options:Re.value,error:C.value,placeholder:"Select a tool...",disabled:pe.value||!k.value},null,8,["modelValue","options","error","disabled"]),C.value?V("",!0):(a(),o("p",ir," Tool that ends the entire conversation when called "))])]),e("div",dr,[e("h4",ur," Side B ("+S(p.value==="ai_human"?"Human":"AI")+") ",1),e("div",null,[A(Le,{modelValue:L.value,"onUpdate:modelValue":Y[15]||(Y[15]=re=>L.value=re),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer, Support"},null,8,["modelValue"]),Y[36]||(Y[36]=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))]),p.value==="ai_human"?(a(),o("div",cr,[...Y[37]||(Y[37]=[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)])])):(a(),o(ve,{key:1},[e("div",null,[A(Ve,{modelValue:G.value,"onUpdate:modelValue":Y[16]||(Y[16]=re=>G.value=re),label:"Agent Prompt",options:Ae.value,error:ee.value,required:""},null,8,["modelValue","options","error"]),ee.value?V("",!0):(a(),o("p",pr," The prompt that defines this agent's behavior "))]),e("div",mr,[Y[39]||(Y[39]=e("label",{class:"block text-sm font-medium"}," Stop Conditions ",-1)),Y[40]||(Y[40]=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",vr,[A(Pe,{modelValue:E.value,"onUpdate:modelValue":Y[17]||(Y[17]=re=>E.value=re),label:"Stop when agent returns content"},null,8,["modelValue"])]),Y[41]||(Y[41]=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,[A(Pe,{modelValue:U.value,"onUpdate:modelValue":Y[18]||(Y[18]=re=>U.value=re),label:"Stop on specific tool call"},null,8,["modelValue"]),U.value?(a(),o("div",fr,[A(Ve,{modelValue:Z.value,"onUpdate:modelValue":Y[19]||(Y[19]=re=>Z.value=re),label:"Stop Tool",options:xe.value,error:se.value,placeholder:"Select a tool...",disabled:ye.value||!G.value},null,8,["modelValue","options","error","disabled"]),se.value?V("",!0):(a(),o("p",hr," Agent stops when this tool is called ")),Z.value?(a(),o("div",gr,[A(Ve,{modelValue:j.value,"onUpdate:modelValue":Y[20]||(Y[20]=re=>j.value=re),label:"Response Property",options:$e.value,error:M.value,placeholder:"Select property..."},null,8,["modelValue","options","error"]),Y[38]||(Y[38]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Property from tool arguments to return as final response ",-1))])):V("",!0)])):V("",!0)])]),e("div",null,[A(Le,{"model-value":w.value?.toString()||"","onUpdate:modelValue":Y[21]||(Y[21]=re=>w.value=re?parseInt(re):null),label:"Max Steps",type:"number",error:R.value,placeholder:"Unlimited"},null,8,["model-value","error"]),R.value?V("",!0):(a(),o("p",br," Maximum steps this side can take before yielding (safety limit) "))]),e("div",null,[A(Ve,{modelValue:I.value,"onUpdate:modelValue":Y[22]||(Y[22]=re=>I.value=re),label:"End Conversation Tool",options:xe.value,error:le.value,placeholder:"Select a tool...",disabled:ye.value||!G.value},null,8,["modelValue","options","error","disabled"]),le.value?V("",!0):(a(),o("p",xr," Tool that ends the entire conversation when called "))])],64))])]),O.value.length>0||Object.keys(W.value).length>0?(a(),o("div",yr,[e("div",kr,[Y[42]||(Y[42]=e("label",{class:"block text-sm font-medium"},"Thread Environment Variables",-1)),ce.value?(a(),o("span",wr,"Loading...")):V("",!0)]),Y[43]||(Y[43]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"}," Configure values for tools that require thread environment variables. Values from prompts are shown locked - click to unlock and override. ",-1)),A(ka,{modelValue:W.value,"onUpdate:modelValue":Y[23]||(Y[23]=re=>W.value=re),inherited:O.value,"allow-custom":!0,disabled:u.value},null,8,["modelValue","inherited","disabled"])])):V("",!0)]))]),_:1},8,["model-value","title"]))}}),Tr={},Sr={class:"p-8 w-full max-w-7xl mx-auto"};function Vr(t,n){return a(),o("div",Sr,[et(t.$slots,"default")])}const at=tt(Tr,[["render",Vr]]),Mr=me({__name:"AgentsView",setup(t){const n=lt(),s=Ye(),i=v(!1),l=v("add"),u=v(null),r=v(null),c=v(null);fe(()=>s.query.refresh,()=>{s.query.refresh&&(r.value?.refresh(),n.replace({path:"/agents",query:{}}))});const f=()=>{l.value="add",u.value=null,c.value=null,i.value=!0},g=p=>{l.value="edit",u.value=p,c.value=null,i.value=!0},d=async p=>{c.value=null;try{const h=l.value==="edit"&&u.value?.id,{originalName:_,...b}=p,m=ue(h?`/api/agents/${u.value.id}`:"/api/agents"),x=await fetch(m,{method:h?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(x.ok)r.value?.refresh(),i.value=!1,u.value=null;else{const k=await x.json();c.value=k.error||`Failed to ${h?"update":"create"} agent`}}catch(h){console.error(`Error ${l.value==="edit"?"updating":"creating"} agent:`,h),c.value=`Failed to ${l.value==="edit"?"update":"create"} agent`}};return(p,h)=>(a(),ne(at,null,{default:be(()=>[e("div",{class:"flex justify-between items-center mb-6"},[h[1]||(h[1]=e("h1",{class:"text-3xl font-bold"},"Agents",-1)),e("button",{onClick:f,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 ")]),h[2]||(h[2]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-6"}," Configure and manage your AI agents. ",-1)),A(Vs,{ref_key:"dataTableRef",ref:r,onAdd:f,onEdit:g},null,512),A(Cr,{modelValue:i.value,"onUpdate:modelValue":h[0]||(h[0]=_=>i.value=_),mode:l.value,editAgent:u.value,apiError:c.value,onSave:d},null,8,["modelValue","mode","editAgent","apiError"])]),_:1}))}});function Ir(t){const{limit:n=50,offset:s=0,agentId:i=null,userId:l=null,search:u=null,startDate:r=null,endDate:c=null,autoFetch:f=!0}=t||{},g=J(()=>{const D=new URLSearchParams,q=typeof n=="number"?n:n.value,B=typeof s=="number"?s:s.value,F=typeof i=="string"?i:i?.value,T=typeof l=="string"?l:l?.value,$=typeof u=="string"?u:u?.value,K=typeof r=="number"?r:r?.value,oe=typeof c=="number"?c:c?.value;return D.append("limit",q.toString()),D.append("offset",B.toString()),F&&D.append("agent_id",F),T&&D.append("user_id",T),$&&D.append("search",$),K&&D.append("startDate",K.toString()),oe&&D.append("endDate",oe.toString()),ue(`/api/threads?${D.toString()}`)}),{data:d,error:p,isFetching:h,isFinished:_,execute:b,abort:m}=Ue(g,{immediate:f,refetch:!0}).get().json(),y=J(()=>d.value?.threads||[]),x=J(()=>d.value?.total||0),k=J(()=>d.value?.hasMore||!1);return{threads:y,total:x,hasMore:k,error:p,isFetching:h,isFinished:_,refetch:b,abort:m}}function St(t){const n=J(()=>!!(typeof t=="string"?t:t?.value)),s=J(()=>{const d=typeof t=="string"?t:t?.value;return ue(d?`/api/threads/${d}`:"/api/threads/placeholder")}),{data:i,error:l,isFetching:u,isFinished:r,execute:c,abort:f}=Ue(s,{immediate:!1,refetch:!0}).get().json();return fe(n,d=>{d&&c()},{immediate:!0}),{thread:J(()=>i.value?{id:i.value.thread.id,agent_id:i.value.thread.agent_id,user_id:i.value.thread.user_id,tags:i.value.thread.tags||[],created_at:i.value.thread.created_at,agent:i.value.agent||{id:"",title:"Unknown",type:"unknown"},stats:i.value.stats}:null),error:l,isFetching:u,isFinished:r,refetch:c,abort:f}}function Er(t){const{autoConnect:n=!0,onEvent:s}=t||{},i=v(null),l=v(!1),u=v(null);let r=0,c=null,f=null,g=!0;const d=3e4,p=3e4,h=()=>{c&&(clearTimeout(c),c=null),f&&(clearInterval(f),f=null)},_=()=>{f&&clearInterval(f),f=setInterval(()=>{i.value&&i.value.readyState===WebSocket.OPEN&&i.value.send("ping")},p)},b=()=>{if(!g)return;const k=Math.min(1e3*Math.pow(2,r),d);r++,console.log(`[AgentBuilderEvents] Scheduling reconnect in ${k}ms (attempt ${r})`),c=setTimeout(()=>{g&&m()},k)},m=()=>{i.value&&i.value.close();const k=window.location.protocol==="https:"?"wss:":"ws:",D=window.location.host;let q=`${k}//${D}${ue("/api/events")}`;const B=localStorage.getItem("auth_token");B&&(q+=`?token=${encodeURIComponent(B)}`);try{i.value=new WebSocket(q),i.value.onopen=()=>{l.value=!0,u.value=null,r=0,_(),console.log("[AgentBuilderEvents] WebSocket connected")},i.value.onmessage=F=>{try{const T=JSON.parse(F.data);s&&s(T)}catch(T){console.error("[AgentBuilderEvents] Failed to parse WebSocket message:",T)}},i.value.onerror=F=>{u.value="WebSocket connection error",console.error("[AgentBuilderEvents] WebSocket error:",F)},i.value.onclose=()=>{l.value=!1,h(),console.log("[AgentBuilderEvents] WebSocket disconnected"),b()}}catch(F){u.value=F.message||"Failed to create WebSocket",console.error("[AgentBuilderEvents] WebSocket creation error:",F),b()}},y=()=>{g=!0,r=0,m()},x=()=>{g=!1,h(),i.value&&(i.value.close(),i.value=null),l.value=!1,r=0};return n&&y(),Be(()=>{x()}),{wsConnected:l,wsError:u,connect:y,disconnect:x}}const Lr={class:"inline-flex items-center justify-center"},Se=me({__name:"Loader",props:{size:{default:"md"}},setup(t){const n=t,s=J(()=>{switch(n.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(i,l)=>(a(),o("div",Lr,[e("div",{class:ae([s.value,"border-black/20 dark:border-white/20 border-t-black dark:border-t-white rounded-full animate-spin"])},null,2)]))}});function Ar(t){const s=Date.now()*1e3-t,i=Math.floor(s/1e6);if(i<60)return i===1?"1 second ago":`${i} seconds ago`;const l=Math.floor(i/60);if(l<60)return l===1?"1 minute ago":`${l} minutes ago`;const u=Math.floor(l/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 c=Math.floor(r/30);if(c<12)return c===1?"1 month ago":`${c} months ago`;const f=Math.floor(c/12);return f===1?"1 year ago":`${f} years ago`}function Pr(t){const n=v("");let s=null;const i=()=>typeof t=="function"?t():typeof t=="number"?t:t.value,l=()=>{const u=i();n.value=Ar(u);const c=Date.now()*1e3-u,f=Math.floor(c/1e6);s!==null&&(clearInterval(s),s=null),f<60?s=setInterval(l,1e3):f<3600?s=setInterval(l,6e4):f<86400&&(s=setInterval(l,6e5))};return l(),Be(()=>{s!==null&&clearInterval(s)}),n}const rt=me({__name:"TimeAgo",props:{timestamp:{}},setup(t){const n=t,s=Pr(()=>n.timestamp);return(i,l)=>(a(),o("span",null,S(X(s)),1))}}),Dr={class:"relative inline-flex items-center"},jr={key:0,class:"inline-block w-2 h-2 rounded-full bg-green-500 dark:bg-green-400"},Or={key:1,class:"inline-block w-2 h-2 rounded-full bg-neutral-400 dark:bg-neutral-600"},Ur={key:0},Rr={key:1},Vt=me({__name:"StatusDot",props:{connected:{type:Boolean},error:{type:Boolean}},setup(t){const n=v(!1),s=v(null);return(i,l)=>(a(),o("div",Dr,[e("span",{class:"p-0.5 cursor-default outline-none",tabindex:"-1",onMouseenter:l[0]||(l[0]=u=>n.value=!0),onMouseleave:l[1]||(l[1]=u=>n.value=!1)},[t.connected?(a(),o("span",jr)):(a(),o("span",Or))],32),A(Xe,{"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:be(()=>[n.value?(a(),o("div",{key:0,ref_key:"popoverRef",ref:s,class:ae(["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-neutral-50 dark:bg-neutral-900 border-neutral-200 dark:border-neutral-700 text-neutral-600 dark:text-neutral-400":!t.connected}])},[t.connected?(a(),o("span",Ur,"Live - Connected")):(a(),o("span",Rr,"Offline"))],2)):V("",!0)]),_:1})]))}});function Nr(){const t=ue("/api/agents"),{data:n,error:s,isFetching:i,isFinished:l,execute:u}=Ue(t,{immediate:!0}).get().json();return{agents:J(()=>n.value?.agents||[]),error:s,isFetching:i,isFinished:l,refetch:u}}const Fr={class:"relative min-w-0"},Br={class:"truncate min-w-0 text-left"},qr={class:"w-56 bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded-lg overflow-hidden"},zr={class:"p-2 border-b-2 border-black dark:border-neutral-300"},Hr={class:"relative"},Wr={class:"max-h-48 overflow-y-auto"},Jr={key:0,class:"px-3 py-4 text-sm font-mono text-center text-neutral-500"},Kr=["onClick"],Gr={class:"truncate"},Xr={key:0,class:"px-3 py-4 text-sm font-mono text-center text-neutral-500"},Yr=me({__name:"AgentFilterDropdown",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:n}){const s=t,i=n,{agents:l,isFetching:u}=Nr(),r=v(!1),c=v(""),f=v(null),g=v(null),d=J(()=>{if(!c.value)return l.value;const F=c.value.toLowerCase();return l.value.filter(T=>T.name.toLowerCase().includes(F)||T.title.toLowerCase().includes(F))}),p=J(()=>s.modelValue&&l.value.find(F=>F.name===s.modelValue)||null),h=J(()=>p.value?p.value.title||p.value.name:"All agents"),_=J(()=>s.modelValue!==null);function b(){if(!f.value||!g.value)return;const F=f.value.getBoundingClientRect();g.value.style.position="fixed",g.value.style.top=`${F.bottom+8}px`,g.value.style.left=`${F.left}px`,g.value.style.margin="0"}function m(){r.value?y():(r.value=!0,Te(()=>{if(g.value&&(g.value.setAttribute("popover","auto"),g.value.addEventListener("toggle",x),"showPopover"in g.value))try{g.value.showPopover()}catch{}b()}))}function y(){if(g.value){if("hidePopover"in g.value)try{g.value.hidePopover()}catch{}g.value.removeEventListener("toggle",x)}r.value=!1,c.value=""}function x(F){F.target===g.value&&(r.value=F.newState==="open",r.value&&b())}function k(F){i("update:modelValue",F?.name||null),y()}function D(F){F.stopPropagation(),i("update:modelValue",null)}const q=F=>{const T=F.target;g.value&&!g.value.contains(T)&&f.value&&!f.value.contains(T)&&y()},B=F=>{F.key==="Escape"&&r.value&&(y(),f.value?.focus())};return Me(()=>{document.addEventListener("click",q),document.addEventListener("keydown",B),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0)}),Be(()=>{document.removeEventListener("click",q),document.removeEventListener("keydown",B),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0)}),(F,T)=>(a(),o("div",Fr,[e("button",{ref_key:"triggerRef",ref:f,type:"button",onClick:m,class:ae(["w-full flex items-center gap-1.5 px-2 py-1 text-xs font-mono rounded border-2 transition-colors min-w-0",[_.value?"border-accent-500 bg-accent-50 dark:bg-accent-950/50 text-accent-700 dark:text-accent-300":"border-neutral-300 dark:border-neutral-600 hover:border-accent-400 dark:hover:border-accent-500 bg-white dark:bg-black"]])},[A(X(ja),{size:12,class:"shrink-0"}),e("span",Br,S(h.value),1),_.value?(a(),ne(X(ft),{key:0,size:12,class:"shrink-0 opacity-60 hover:opacity-100",onClick:D})):(a(),ne(X(nt),{key:1,size:12,class:ae(["shrink-0 opacity-60",r.value?"rotate-180":""])},null,8,["class"]))],2),r.value?(a(),o("div",{key:0,ref_key:"popoverRef",ref:g,class:"dropdown-popover z-[9999]"},[A(Qe,{"offset-x":4,"offset-y":4,intensity:.3},{default:be(()=>[e("div",qr,[e("div",zr,[e("div",Hr,[A(X(Yt),{size:12,class:"absolute left-2 top-1/2 -translate-y-1/2 opacity-60"}),Ie(e("input",{"onUpdate:modelValue":T[0]||(T[0]=$=>c.value=$),type:"text",placeholder:"Search agents...",class:"w-full pl-7 pr-2 py-1.5 text-xs font-mono bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white placeholder:text-neutral-400",onClick:T[1]||(T[1]=Ee(()=>{},["stop"]))},null,512),[[Oe,c.value]])])]),e("div",Wr,[e("button",{type:"button",onClick:T[2]||(T[2]=$=>k(null)),class:ae(["w-full flex items-center gap-2 px-3 py-2 text-sm font-mono text-left hover:bg-neutral-100 dark:hover:bg-neutral-900 transition-colors",t.modelValue?"":"bg-accent-50 dark:bg-accent-950/30"])},[e("span",{class:ae(["w-2 h-2 rounded-full border-2 border-accent-500",t.modelValue?"":"bg-accent-500"])},null,2),T[3]||(T[3]=Ce(" All agents ",-1))],2),X(u)?(a(),o("div",Jr," Loading... ")):(a(),o(ve,{key:1},[(a(!0),o(ve,null,ke(d.value,$=>(a(),o("button",{key:$.id,type:"button",onClick:K=>k($),class:ae(["w-full flex items-center gap-2 px-3 py-2 text-sm font-mono text-left hover:bg-neutral-100 dark:hover:bg-neutral-900 transition-colors",t.modelValue===$.name?"bg-accent-50 dark:bg-accent-950/30":""])},[e("span",{class:ae(["w-2 h-2 rounded-full border-2 border-accent-500",t.modelValue===$.name?"bg-accent-500":""])},null,2),e("span",Gr,S($.title||$.name),1)],10,Kr))),128)),d.value.length===0&&!X(u)?(a(),o("div",Xr," No agents found ")):V("",!0)],64))])])]),_:1})],512)):V("",!0)]))}}),Qr={class:"relative min-w-0"},Zr={class:"truncate flex-1 text-left"},ei={class:"w-52 bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded-lg overflow-hidden"},ti={key:0},ai=["onClick"],oi={class:"border-t-2 border-black dark:border-neutral-300"},li={key:1,class:"p-3 space-y-3"},si={class:"flex items-center justify-between"},ni={class:"space-y-2"},ri=me({__name:"DateFilterDropdown",props:{startDate:{},endDate:{}},emits:["update:startDate","update:endDate"],setup(t,{emit:n}){const s=t,i=n,l=v(!1),u=v(!1),r=v(null),c=v(null),f=v(""),g=v(""),d=[{label:"All time",value:"all",getRange:()=>({startDate:null,endDate:null})},{label:"Today",value:"today",getRange:()=>{const T=new Date,$=new Date(T.getFullYear(),T.getMonth(),T.getDate());return{startDate:Math.floor($.getTime()/1e3),endDate:null}}},{label:"Last 3 days",value:"3days",getRange:()=>{const T=new Date,$=new Date(T.getFullYear(),T.getMonth(),T.getDate()-2);return{startDate:Math.floor($.getTime()/1e3),endDate:null}}},{label:"Last 7 days",value:"7days",getRange:()=>{const T=new Date,$=new Date(T.getFullYear(),T.getMonth(),T.getDate()-6);return{startDate:Math.floor($.getTime()/1e3),endDate:null}}},{label:"Last 30 days",value:"30days",getRange:()=>{const T=new Date,$=new Date(T.getFullYear(),T.getMonth(),T.getDate()-29);return{startDate:Math.floor($.getTime()/1e3),endDate:null}}}],p=J(()=>{if(!s.startDate&&!s.endDate)return"all";for(const T of d){const $=T.getRange();if($.startDate===s.startDate&&$.endDate===s.endDate)return T.value}return"custom"}),h=J(()=>{if(!s.startDate&&!s.endDate)return"All time";const T=d.find(K=>K.value===p.value);if(T&&p.value!=="custom")return T.label;const $=K=>new Date(K*1e3).toLocaleDateString("en-US",{month:"short",day:"numeric"});return s.startDate&&s.endDate?`${$(s.startDate)} - ${$(s.endDate)}`:s.startDate?`From ${$(s.startDate)}`:s.endDate?`Until ${$(s.endDate)}`:"Custom"}),_=J(()=>s.startDate!==null||s.endDate!==null);function b(){if(!r.value||!c.value)return;const T=r.value.getBoundingClientRect();c.value.style.position="fixed",c.value.style.top=`${T.bottom+8}px`,c.value.style.left=`${T.left}px`,c.value.style.margin="0"}function m(){l.value?y():(l.value=!0,Te(()=>{if(c.value&&(c.value.setAttribute("popover","auto"),c.value.addEventListener("toggle",x),"showPopover"in c.value))try{c.value.showPopover()}catch{}b()}))}function y(){if(c.value){if("hidePopover"in c.value)try{c.value.hidePopover()}catch{}c.value.removeEventListener("toggle",x)}l.value=!1,u.value=!1}function x(T){T.target===c.value&&(l.value=T.newState==="open",l.value&&b())}function k(T){const $=T.getRange();i("update:startDate",$.startDate),i("update:endDate",$.endDate),y()}function D(){const T=f.value?Math.floor(new Date(f.value).getTime()/1e3):null,$=g.value?Math.floor(new Date(g.value+"T23:59:59").getTime()/1e3):null;i("update:startDate",T),i("update:endDate",$),y()}function q(T){T.stopPropagation(),i("update:startDate",null),i("update:endDate",null)}const B=T=>{const $=T.target;c.value&&!c.value.contains($)&&r.value&&!r.value.contains($)&&y()},F=T=>{T.key==="Escape"&&l.value&&(y(),r.value?.focus())};return Me(()=>{document.addEventListener("click",B),document.addEventListener("keydown",F),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0)}),Be(()=>{document.removeEventListener("click",B),document.removeEventListener("keydown",F),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0)}),fe(u,T=>{T&&(s.startDate&&(f.value=new Date(s.startDate*1e3).toISOString().split("T")[0]),s.endDate?g.value=new Date(s.endDate*1e3).toISOString().split("T")[0]:g.value=new Date().toISOString().split("T")[0])}),(T,$)=>(a(),o("div",Qr,[e("button",{ref_key:"triggerRef",ref:r,type:"button",onClick:m,class:ae(["w-full flex items-center gap-1.5 px-2 py-1 text-xs font-mono rounded border-2 transition-colors min-w-0",[_.value?"border-accent-500 bg-accent-50 dark:bg-accent-950/50 text-accent-700 dark:text-accent-300":"border-neutral-300 dark:border-neutral-600 hover:border-accent-400 dark:hover:border-accent-500 bg-white dark:bg-black"]])},[A(X(Oa),{size:12,class:"shrink-0"}),e("span",Zr,S(h.value),1),_.value?(a(),ne(X(ft),{key:0,size:12,class:"shrink-0 opacity-60 hover:opacity-100",onClick:q})):(a(),ne(X(nt),{key:1,size:12,class:ae(["shrink-0 opacity-60",l.value?"rotate-180":""])},null,8,["class"]))],2),l.value?(a(),o("div",{key:0,ref_key:"popoverRef",ref:c,class:"dropdown-popover z-[9999]"},[A(Qe,{"offset-x":4,"offset-y":4,intensity:.3},{default:be(()=>[e("div",ei,[u.value?(a(),o("div",li,[e("div",si,[$[7]||($[7]=e("span",{class:"text-sm font-mono font-bold"},"Custom range",-1)),e("button",{type:"button",onClick:$[1]||($[1]=Ee(K=>u.value=!1,["stop"])),class:"text-xs font-mono text-neutral-500 hover:text-black dark:hover:text-white"}," ← Back ")]),e("div",ni,[e("div",null,[$[8]||($[8]=e("label",{class:"block text-xs font-mono text-neutral-500 mb-1"},"FROM",-1)),Ie(e("input",{"onUpdate:modelValue":$[2]||($[2]=K=>f.value=K),type:"date",class:"w-full px-2 py-1.5 text-sm font-mono bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white",onClick:$[3]||($[3]=Ee(()=>{},["stop"]))},null,512),[[Oe,f.value]])]),e("div",null,[$[9]||($[9]=e("label",{class:"block text-xs font-mono text-neutral-500 mb-1"},"TO",-1)),Ie(e("input",{"onUpdate:modelValue":$[4]||($[4]=K=>g.value=K),type:"date",class:"w-full px-2 py-1.5 text-sm font-mono bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white",onClick:$[5]||($[5]=Ee(()=>{},["stop"]))},null,512),[[Oe,g.value]])])]),e("button",{type:"button",onClick:D,class:"w-full py-2 text-sm font-mono font-bold bg-black dark:bg-white text-white dark:text-black rounded hover:opacity-90 transition-opacity"}," Apply ")])):(a(),o("div",ti,[(a(),o(ve,null,ke(d,K=>e("button",{key:K.value,type:"button",onClick:oe=>k(K),class:ae(["w-full px-3 py-2 text-left text-sm font-mono hover:bg-neutral-100 dark:hover:bg-neutral-900 transition-colors flex items-center gap-2",p.value===K.value?"bg-accent-50 dark:bg-accent-950/30":""])},[e("span",{class:ae(["w-2 h-2 rounded-full border-2 border-accent-500",p.value===K.value?"bg-accent-500":""])},null,2),Ce(" "+S(K.label),1)],10,ai)),64)),e("div",oi,[e("button",{type:"button",onClick:$[0]||($[0]=Ee(K=>u.value=!0,["stop"])),class:ae(["w-full px-3 py-2 text-left text-sm font-mono hover:bg-neutral-100 dark:hover:bg-neutral-900 transition-colors flex items-center gap-2",p.value==="custom"?"bg-accent-50 dark:bg-accent-950/30":""])},[e("span",{class:ae(["w-2 h-2 rounded-full border-2 border-accent-500",p.value==="custom"?"bg-accent-500":""])},null,2),$[6]||($[6]=Ce(" Custom range... ",-1))],2)])]))])]),_:1})],512)):V("",!0)]))}}),ii={class:"flex flex-col flex-1 min-h-0 overflow-visible"},di={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},ui={class:"flex items-center justify-between"},ci={class:"flex items-center gap-2"},pi={key:0,class:"text-xs font-mono text-neutral-500 dark:text-neutral-400"},mi={class:"flex items-center gap-2"},vi=["title"],fi={key:0,class:"absolute -top-1 -right-1 w-3.5 h-3.5 flex items-center justify-center text-[8px] font-bold font-mono bg-accent-500 text-white rounded-full"},hi={key:0,class:"border-b-2 border-neutral-300 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-900/50"},gi={class:"p-3 space-y-2"},bi={class:"relative"},xi={class:"flex items-center gap-2 w-full"},yi={key:0,class:"flex justify-end"},ki={key:0,class:"p-4 flex justify-center"},wi={key:1,class:"p-4 text-red-600 dark:text-red-400"},_i={key:2,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},$i={key:1,class:"text-base"},Ci={key:3},Ti=["id","onClick"],Si={class:"flex items-center gap-2 mb-1"},Vi={class:"flex-shrink-0 text-neutral-400 dark:text-neutral-500 text-[10px]"},Mi={class:"flex items-center gap-2"},Ii={class:"text-[10px] text-neutral-400 dark:text-neutral-500 font-mono truncate max-w-[80px]"},Ei={key:0,class:"flex flex-wrap gap-1 flex-1 min-w-0"},Li={key:0,class:"text-[10px] text-neutral-400"},Ai={key:0,class:"p-3 flex justify-center"},Pi={key:1,class:"p-3 text-center text-[10px] text-neutral-400 dark:text-neutral-500"},Di=50,ji=me({__name:"ThreadListPane",props:{selectedThreadId:{}},emits:["selectThread","collapse","createThread","threadsLoaded"],setup(t,{expose:n,emit:s}){const i=s,l=v(!1),u=v(""),r=v(null),c=v(null),f=v(null),g=v(null),d=v(0),p=v([]),h=v(!1),_=Na(E=>{r.value=E||null},300);fe(u,E=>{_(E)});const b=J(()=>{let E=0;return r.value&&E++,c.value&&E++,(f.value||g.value)&&E++,E});function m(){u.value="",r.value=null,c.value=null,f.value=null,g.value=null}const{threads:y,total:x,hasMore:k,isFetching:D,isFinished:q,error:B,refetch:F}=Ir({limit:Di,offset:d,search:r,agentId:c,startDate:f,endDate:g});fe([r,c,f,g],()=>{d.value=0,p.value=[],h.value=!1}),fe(y,E=>{if(d.value===0)p.value=[...E];else{const U=new Set(p.value.map(se=>se.id)),Z=E.filter(se=>!U.has(se.id));p.value=[...p.value,...Z]}h.value=!1});const T=v([]),$=v(new Set),K=J(()=>{const E=p.value.filter(se=>!$.value.has(se.id)),U=new Set(E.map(se=>se.id));return[...T.value.filter(se=>!U.has(se.id)&&!$.value.has(se.id)),...E].sort((se,j)=>j.created_at-se.created_at)}),oe=v(null);function te(){h.value||D.value||!k.value||(h.value=!0,d.value=p.value.length)}const{arrivedState:H}=Ua(oe,{offset:{bottom:100}});fe(()=>H.bottom,E=>{E&&k.value&&!D.value&&!h.value&&te()});const P=async E=>{if(E.type==="thread_created"){const U={id:E.thread.id,agent_id:E.thread.agent_name,user_id:E.thread.user_id,tags:E.thread.tags||[],created_at:E.thread.created_at,agent:{name:E.thread.agent_name,title:void 0,type:"ai_human"}};T.value.unshift(U)}else E.type==="thread_deleted"&&($.value.add(E.threadId),T.value=T.value.filter(U=>U.id!==E.threadId))},{wsConnected:C,wsError:L}=Er({onEvent:P});fe(()=>d.value,E=>{E===0&&(T.value=[])});const G=v(!1);fe(()=>({threads:p.value,finished:q.value}),({threads:E,finished:U})=>{U&&!G.value&&E.length>0&&(G.value=!0,i("threadsLoaded",E[0]?.id??null))},{immediate:!0}),n({refetch:F});const ee=E=>{i("selectThread",E)};return(E,U)=>(a(),o("div",ii,[e("div",di,[e("div",ui,[e("div",ci,[A(X(Qt),{size:18,class:"shrink-0"}),U[8]||(U[8]=e("h2",{class:"text-base font-bold"},"Threads",-1)),!X(D)&&X(x)>0?(a(),o("span",pi," ("+S(X(x))+") ",1)):V("",!0),A(Vt,{connected:X(C),error:X(L)},null,8,["connected","error"])]),e("div",mi,[e("button",{onClick:U[0]||(U[0]=Z=>l.value=!l.value),type:"button",class:ae(["relative p-1 rounded transition-colors hover:bg-neutral-100 dark:hover:bg-neutral-900",[l.value||b.value>0?"text-accent-600 dark:text-accent-400":""]]),title:l.value?"Hide filters":"Show filters"},[A(X(Ra),{size:18}),b.value>0?(a(),o("span",fi,S(b.value),1)):V("",!0)],10,vi),e("button",{onClick:U[1]||(U[1]=Z=>i("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:U[2]||(U[2]=Z=>i("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[A(X(Tt),{size:20})])])])]),A(Xe,{"enter-active-class":"transition-all duration-200 ease-out","enter-from-class":"opacity-0 -translate-y-2 max-h-0","enter-to-class":"opacity-100 translate-y-0 max-h-60","leave-active-class":"transition-all duration-150 ease-in","leave-from-class":"opacity-100 translate-y-0 max-h-60","leave-to-class":"opacity-0 -translate-y-2 max-h-0"},{default:be(()=>[l.value?(a(),o("div",hi,[e("div",gi,[e("div",bi,[A(X(Yt),{size:14,class:"absolute left-2.5 top-1/2 -translate-y-1/2 opacity-60"}),Ie(e("input",{"onUpdate:modelValue":U[3]||(U[3]=Z=>u.value=Z),type:"text",placeholder:"Search by tag or thread ID...",class:"w-full pl-8 pr-8 py-1.5 text-xs font-mono bg-white dark:bg-black border-2 border-neutral-300 dark:border-neutral-600 rounded focus:outline-none focus:border-black dark:focus:border-neutral-300 focus:ring-2 focus:ring-black/20 dark:focus:ring-white/20 placeholder:text-neutral-400"},null,512),[[Oe,u.value]]),u.value?(a(),o("button",{key:0,onClick:U[4]||(U[4]=Z=>u.value=""),type:"button",class:"absolute right-2 top-1/2 -translate-y-1/2 p-0.5 opacity-60 hover:opacity-100 transition-opacity"},[A(X(ft),{size:14})])):V("",!0)]),e("div",xi,[A(Yr,{modelValue:c.value,"onUpdate:modelValue":U[5]||(U[5]=Z=>c.value=Z),class:"flex-1 min-w-0"},null,8,["modelValue"]),A(ri,{startDate:f.value,"onUpdate:startDate":U[6]||(U[6]=Z=>f.value=Z),endDate:g.value,"onUpdate:endDate":U[7]||(U[7]=Z=>g.value=Z),class:"flex-1 min-w-0"},null,8,["startDate","endDate"])]),b.value>0?(a(),o("div",yi,[e("button",{onClick:m,type:"button",class:"text-xs font-mono text-neutral-500 hover:text-black dark:hover:text-white transition-colors"}," Clear all ")])):V("",!0)])])):V("",!0)]),_:1}),e("div",{ref_key:"scrollContainerRef",ref:oe,class:"flex-1 overflow-y-auto text-xs min-h-0"},[X(D)&&p.value.length===0?(a(),o("div",ki,[A(Se)])):X(B)?(a(),o("div",wi," Error: "+S(X(B)),1)):K.value.length===0?(a(),o("div",_i,[b.value>0?(a(),o(ve,{key:0},[U[9]||(U[9]=e("p",{class:"text-base mb-2"},"No matching threads",-1)),e("button",{onClick:m,type:"button",class:"text-xs text-accent-600 dark:text-accent-400 hover:underline"}," Clear filters ")],64)):(a(),o("p",$i,"No threads found"))])):(a(),o("div",Ci,[(a(!0),o(ve,null,ke(K.value,Z=>(a(),o("button",{key:Z.id,id:`thread-${Z.id}`,class:ae(["w-full text-left px-3 py-2.5 border-b border-neutral-200 dark:border-neutral-800 cursor-pointer transition-colors relative hover:bg-neutral-50 dark:hover:bg-neutral-800/50",{"bg-accent-50 dark:bg-accent-950/50 border-l-2 border-l-accent-500":t.selectedThreadId===Z.id}]),onClick:se=>ee(Z.id)},[e("div",Si,[e("span",{class:ae(["font-medium truncate flex-1 min-w-0",t.selectedThreadId===Z.id?"text-accent-700 dark:text-accent-300":""])},S(Z.agent.title||Z.agent.name),3),e("span",Vi,[A(rt,{timestamp:Z.created_at*1e6},null,8,["timestamp"])])]),e("div",Mi,[e("span",Ii,S(Z.id.slice(0,8)),1),Z.tags.length>0?(a(),o("div",Ei,[(a(!0),o(ve,null,ke(Z.tags.slice(0,3),se=>(a(),o("span",{key:se,class:ae(["inline-block px-1.5 py-0.5 rounded text-[10px] truncate max-w-[60px]",t.selectedThreadId===Z.id?"bg-accent-200 dark:bg-accent-900 text-accent-800 dark:text-accent-200":"bg-neutral-200 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400"])},S(se),3))),128)),Z.tags.length>3?(a(),o("span",Li," +"+S(Z.tags.length-3),1)):V("",!0)])):V("",!0)])],10,Ti))),128)),h.value||X(D)&&p.value.length>0?(a(),o("div",Ai,[A(Se)])):!X(k)&&K.value.length>0?(a(),o("div",Pi," All "+S(X(x))+" threads loaded ",1)):V("",!0)]))],512)]))}});function Oi(t,n={}){const s=v(null),i=v(!1),l=v(null);let u=null;try{u=ca()}catch{}const r=u?.workblocks??J(()=>[]),c=u?.messages??v([]),f=J(()=>u?.status.value==="connected"),g=v(null);u?.loading??v(!1);const d=J(()=>c.value.some(E=>E.status==="pending")),p=v(!1),h=v(0),_=v(!1);function b(E){if(!s.value?.agent)return null;const U=s.value.agent,Z=E==="assistant"?"A":"B";return Z==="A"&&U.side_a_label?U.side_a_label:Z==="B"&&U.side_b_label?U.side_b_label:null}function m(E){return{id:E.id||`att-${E.path||E.name||Math.random().toString(36).slice(2)}`,type:"file",path:E.path||"",name:E.name||E.path?.split("/").pop()||"attachment",mimeType:E.mimeType||E.mediaType||"application/octet-stream",width:E.width,height:E.height,description:E.description}}function y(E){if(E){if(Array.isArray(E))return E.length>0?E.map(m):void 0;try{const U=JSON.parse(E);return Array.isArray(U)&&U.length>0?U.map(m):void 0}catch(U){console.error("Failed to parse attachments:",U);return}}}function x(E,U){const Z=[];E.reasoning_content&&Z.push({id:`${E.id}-reasoning`,type:"reasoning",content:E.reasoning_content,created_at:E.created_at}),E.content&&Z.push({id:`${E.id}-content`,type:"content",content:E.content,created_at:E.created_at});const se=E.workItems.filter(I=>I.type==="tool_call"),j=E.workItems.filter(I=>I.type==="tool_result"),M=new Map;for(const I of j)I.tool_call_id&&M.set(I.tool_call_id,I);for(const I of se){const le=I.tool_call_id||I.id,O=M.get(le);let W="pending";if(O){const ce=(O.content||"").toLowerCase(),z=ce.includes("failed")||ce.includes("error"),N=ce.length<500;W=O.status==="error"||z&&N?"failed":"success"}Z.push({id:I.id,type:"tool_call",content:I.name||"",created_at:E.created_at,tool_name:I.name,tool_call_id:le,tool_arguments:I.content||void 0,response:O?.content||null,response_status:W,response_log_id:null,log_id:null})}const w=Z.some(I=>I.type==="tool_call"&&I.response_status==="pending"),R=E.status!=="pending"&&!w;return{type:"work",id:E.id,role:"assistant",items:Z,created_at:E.created_at,updated_at:E.created_at,isComplete:R,sideLabel:b("assistant"),status:E.status}}const k=J(()=>{const E=[],Z=r.value.filter(j=>(j.depth??0)===0);let se=[];for(let j=0;j<Z.length;j++){const M=Z[j];if(E[E.length-1]?.role,M.type==="workblock"){const R=x(M);E.push(R);const I=M;I.attachments&&I.attachments.length>0&&se.push(...I.attachments.map(m))}else{const R=M,I=R.role;if(R.role==="tool")continue;const le=y(R.attachments);let O;if((se.length>0||le)&&(O=[...se,...le||[]],se=[]),R.content||I==="system"||R.status==="pending"||O?.length){const W={type:"text",id:R.id,role:I,content:R.content||"",attachments:O?.length?O:void 0,created_at:R.created_at,log_id:R.log_id||null,sideLabel:b(I),isOptimistic:R.isOptimistic,status:R.status,silent:R.silent};E.push(W)}}}return E});async function D(){if(!t.value){s.value=null;return}try{const E=await fetch(ue(`/api/threads/${t.value}`));E.ok&&(s.value=await E.json())}catch(E){console.error("Error fetching thread info:",E)}}async function q(E){if(t.value){if(u?.deleteMessage){await u.deleteMessage(E);return}try{if(!(await fetch(ue(`/api/threads/${t.value}/messages/${E}`),{method:"DELETE"})).ok)throw new Error("Failed to delete message")}catch(U){throw U}}}async function B(E,U){if(t.value)try{if(!(await fetch(ue(`/api/threads/${t.value}/messages/${E}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:U})})).ok)throw new Error("Failed to update message")}catch(Z){throw Z}}fe(t,async E=>{E?(i.value=!0,await D(),i.value=!1):s.value=null},{immediate:!0});const F=u?.sendMessage,T=u?.stopExecution,$=u?.attachments??v([]),K=u?.addAttachment??(()=>{}),oe=u?.removeAttachment??(()=>{}),te=u?.clearAttachments??(()=>{});function H(){console.warn("loadMoreMessages is deprecated - SDK handles all messages")}function P(){console.warn("connectWebSocket is deprecated - SDK handles WebSocket")}function C(){console.warn("disconnectWebSocket is deprecated - SDK handles WebSocket")}function L(){console.warn("addOptimisticMessage is deprecated - SDK handles optimistic updates")}function G(){console.warn("removeOptimisticMessage is deprecated - SDK handles optimistic updates")}async function ee(){console.warn("refetch is deprecated - SDK handles message loading")}return{messages:k,threadInfo:s,isFetching:i,isLoadingMore:_,error:l,wsConnected:f,wsError:g,isExecuting:d,hasMore:p,totalMessages:h,sendMessage:F,stopThread:T,attachments:$,addAttachment:K,removeAttachment:oe,clearAttachments:te,deleteMessageById:q,updateMessageContent:B,refetch:ee,loadMoreMessages:H,connectWebSocket:P,disconnectWebSocket:C,addOptimisticMessage:L,removeOptimisticMessage:G}}const Ui={key:0,class:"absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-800"},Ri={key:1,class:"absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-800 text-neutral-400"},Ni=["src","alt"],Fi={class:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center"},Bi={key:0,class:"text-white text-[10px]"},qi={class:"text-xs text-neutral-600 dark:text-neutral-300 truncate max-w-[100px]"},zi=me({__name:"FileAttachment",props:{attachment:{},threadId:{},showRemove:{type:Boolean}},emits:["remove"],setup(t,{emit:n}){const s=t,i=n,l=v(!0),u=v(!1),r=J(()=>s.attachment.mimeType.startsWith("image/")),c=J(()=>!!s.attachment.thumbnailBase64),f=J(()=>{if(!s.threadId||!s.attachment.path)return"";const b=s.attachment.path.startsWith("/")?s.attachment.path.slice(1):s.attachment.path;return ue(`/api/threads/${s.threadId}/fs/${b}`)}),g=J(()=>r.value?s.attachment.thumbnailBase64?`data:image/webp;base64,${s.attachment.thumbnailBase64}`:f.value:"");function d(){l.value=!1,u.value=!1}function p(){l.value=!1,u.value=!0}function h(){i("remove",s.attachment.id)}function _(){f.value&&window.open(f.value,"_blank")}return(b,m)=>(a(),o("div",{class:ae(["relative group inline-flex items-center rounded-lg overflow-hidden border border-neutral-200 dark:border-neutral-700",{"w-[104px] h-[104px]":r.value,"px-2 py-1 bg-neutral-100 dark:bg-neutral-800":!r.value,"cursor-pointer":r.value&&f.value}]),onClick:m[0]||(m[0]=y=>r.value&&f.value?_():void 0)},[r.value?(a(),o(ve,{key:0},[l.value&&!u.value&&!c.value?(a(),o("div",Ui,[...m[1]||(m[1]=[e("div",{class:"w-4 h-4 border-2 border-neutral-300 border-t-neutral-600 rounded-full animate-spin"},null,-1)])])):V("",!0),u.value&&!c.value?(a(),o("div",Ri,[A(X(Zt),{size:24})])):V("",!0),Ie(e("img",{src:g.value||f.value,alt:t.attachment.name,class:"w-full h-full object-cover",onLoad:d,onError:p},null,40,Ni),[[Ke,!l.value&&!u.value||c.value]]),e("div",Fi,[f.value?(a(),o("span",Bi,"Click to view")):V("",!0)])],64)):(a(),o(ve,{key:1},[A(X(ea),{size:14,class:"text-neutral-500 mr-1 flex-shrink-0"}),e("span",qi,S(t.attachment.name),1)],64)),t.showRemove?(a(),o("button",{key:2,onClick:Ee(h,["stop"]),class:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-red-500 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity"},[A(X(ft),{size:10})])):V("",!0)],2))}}),Hi=["onMouseenter","onMouseleave","onClick"],Wi=["onClick"],Ji={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"},Ki={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"},Gi={key:0,class:"w-full text-center text-xs text-neutral-400 dark:text-neutral-500 py-1"},Xi=["contenteditable","onInput"],Yi={key:1,class:"flex gap-1 items-center min-h-[1.5rem]"},Qi={key:0,class:"opacity-50"},Zi={key:1,class:"opacity-50 italic text-neutral-500 dark:text-neutral-400"},ed={key:0,class:"flex flex-wrap gap-2"},td=["onClick","onMouseenter"],ad={key:0,class:"space-y-1"},od={class:"flex items-start gap-2"},ld={class:"flex-1 min-w-0"},sd={key:0,class:"truncate opacity-80"},nd={key:1,class:"italic opacity-60"},rd={class:"flex items-center gap-2 pl-5 opacity-60"},id={class:"text-[10px]"},dd={class:"text-[10px]"},ud={key:1,class:"space-y-2"},cd={class:"flex items-center gap-2 pb-1 border-b border-current opacity-70"},pd={class:"text-[10px] italic"},md={class:"text-[10px] ml-auto"},vd={key:0,class:"space-y-1"},fd=["onClick","onMouseenter"],hd={class:"font-mono text-[11px] flex-shrink-0"},gd={key:2,class:"text-[10px] opacity-60 px-2 truncate flex-1 min-w-0"},bd={key:3,class:"text-[10px] text-green-600 dark:text-green-400 ml-auto flex-shrink-0"},xd={key:0,class:"pl-4 space-y-2 text-[10px]"},yd={key:0},kd={class:"w-full border-collapse"},wd={class:"py-0.5 pr-2 opacity-65 align-top"},_d={class:"py-0.5 opacity-85 break-all"},$d={key:1},Cd=["onClick","onMouseenter"],Td={class:"whitespace-pre-wrap break-all"},Sd={key:1,class:"text-[10px]"},Vd=["onClick"],Md={key:0,class:"mt-1 pl-4 whitespace-pre-wrap break-words opacity-80"},Id={key:2,class:"text-[10px] opacity-80 pl-4 pb-2 break-words"},Ed=me({__name:"AgentMessages",props:{messages:{},threadId:{},selectedMessageId:{},selectedLogId:{},hoveredLogId:{},isEditMode:{type:Boolean},selectedForDelete:{},editedMessages:{}},emits:["messageClick","messageHover","selectionChange","messageEdit"],setup(t,{expose:n,emit:s}){const i=t,l=s;function u(j){const M=i.selectedForDelete?.has(j)??!1;l("selectionChange",j,!M)}function r(j,M){const R=j.target.innerText;l("messageEdit",M,R)}function c(j){return i.editedMessages?.has(j)??!1}const f=v(new Map);function g(j,M){M?f.value.set(j,M):f.value.delete(j)}function d(j){const M=i.messages.findIndex(w=>w.log_id===j);if(M<=0)return-1;for(let w=M-1;w>=0;w--){const R=i.messages[w];if(R.role==="user")return w;if(R.role==="assistant"&&R.log_id)break}return-1}function p(j){for(let M=0;M<i.messages.length;M++){const w=i.messages[M];if(w.log_id===j||w.type==="work"&&w.items&&w.items.some(le=>le.log_id===j||le.response_log_id===j))return M}return-1}function h(j,M){const R=p(j);if(R===-1)return!1;const I=f.value.get(R);if(!I)return!1;const le=i.messages[R];let O=null;if(le.role==="assistant"&&le.log_id){const z=d(le.log_id);O=z!==-1?f.value.get(z):null}const W=M.getBoundingClientRect(),ce=I.getBoundingClientRect();if(ce.top<W.top){const Q=(O||I).getBoundingClientRect().top-W.top-10;M.scrollBy({top:Q,behavior:"smooth"})}else if(ce.bottom>W.bottom){const z=ce.bottom-W.bottom+10;M.scrollBy({top:z,behavior:"smooth"})}else if(O){const z=O.getBoundingClientRect();if(z.top<W.top){const N=z.top-W.top-10;M.scrollBy({top:N,behavior:"smooth"})}}return!0}function _(j){for(const M of i.messages){if(M.type!=="work")continue;if(M.items.some(I=>I.log_id===j||I.response_log_id===j))return!0}return!1}n({scrollToLogId:h,hasWorkblockForLogId:_});function b(j){const M=i.messages[j];if(M.log_id)return M.log_id;if(M.role==="user")for(let w=j+1;w<i.messages.length;w++){const R=i.messages[w];if(R.log_id)return R.log_id;if(R.role==="user")break}return null}function m(j,M){return M?b(j)===M:!1}function y(j){const M=b(j);M&&l("messageHover",M)}function x(j){b(j)&&l("messageHover",null)}function k(j){const M=i.messages[j],w=b(j);w&&l("messageClick",M.id,w)}const D=v(new Set),q=v(new Set),B=v(new Set);function F(j){D.value.has(j)?D.value.delete(j):D.value.add(j)}function T(j){q.value.has(j)?q.value.delete(j):q.value.add(j)}function $(j){B.value.has(j)?B.value.delete(j):B.value.add(j)}function K(j){if(!j)return{};try{return JSON.parse(j)}catch{return{raw:j}}}function oe(j){if(!j)return null;const M=K(j),w=Object.keys(M);if(w.length===0)return null;const R=M[w[0]];return typeof R=="string"?R:JSON.stringify(R)}function te(j){return new Date(j/1e3).toLocaleTimeString()}function H(j){const M=Math.round(j/1e6);if(M<1)return"< 1s";if(M<60)return`${M}s`;const w=Math.floor(M/60),R=M%60;return`${w}m ${R}s`}function P(j){if(j.status==="pending")return"...";if(!j.isComplete)return"Working...";let M;return j.request_sent_at&&j.response_completed_at?M=j.response_completed_at-j.request_sent_at:M=j.updated_at-j.created_at,`Worked for ${H(M)}`}function C(j){const M=j.filter(w=>w.type==="content");if(M.length===0){const w=j.filter(R=>R.type==="reasoning");return w.length>0?w[w.length-1].content:null}return M[M.length-1].content}function L(j){const w=j.trim().split(`
2
- `)[0];return w.length>60?w.substring(0,60):w}function G(j){return i.selectedMessageId===j.id?!0:i.selectedLogId?j.items.some(M=>M.log_id===i.selectedLogId||M.response_log_id===i.selectedLogId):!1}function ee(j){return!!(i.selectedLogId&&(j.log_id===i.selectedLogId||j.response_log_id===i.selectedLogId))}function E(j){return i.hoveredLogId?j.items.some(M=>M.log_id===i.hoveredLogId||M.response_log_id===i.hoveredLogId):!1}function U(j){return!!(i.hoveredLogId&&(j.log_id===i.hoveredLogId||j.response_log_id===i.hoveredLogId))}function Z(j){const M=[];for(const w of j.items)w.log_id&&M.push(w.log_id),w.response_log_id&&M.push(w.response_log_id);return M}function se(j){return j?j.trim():""}return(j,M)=>(a(),o("div",null,[(a(!0),o(ve,null,ke(t.messages,(w,R)=>(a(),o("div",{key:w.id,ref_for:!0,ref:I=>g(R,I),class:"flex items-center gap-2 pb-3",onMouseenter:I=>y(R),onMouseleave:I=>x(R),onClick:I=>t.isEditMode?u(w.id):k(R)},[t.isEditMode&&w.role!=="system"?(a(),o("button",{key:0,onClick:Ee(I=>u(w.id),["stop"]),class:ae(["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(w.id),"border-green-500 bg-green-500":!t.selectedForDelete?.has(w.id)&&c(w.id),"border-neutral-400 dark:border-neutral-500 bg-transparent hover:border-neutral-500 dark:hover:border-neutral-400":!t.selectedForDelete?.has(w.id)&&!c(w.id)}])},[t.selectedForDelete?.has(w.id)?(a(),o("svg",Ji,[...M[4]||(M[4]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 12.75l6 6 9-13.5"},null,-1)])])):c(w.id)?(a(),o("svg",Ki,[...M[5]||(M[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)])])):V("",!0)],10,Wi)):V("",!0),e("div",{class:ae(["flex-1 flex items-center gap-2 min-w-0",{"justify-start":w.role==="assistant","justify-end":w.role==="user","justify-center":w.role==="system","cursor-pointer":b(R)&&!t.isEditMode}])},[w.type==="text"&&w.role==="system"&&w.content?.includes("Execution stopped")?(a(),o("div",Gi,S(w.content),1)):w.type==="text"?(a(),o("div",{key:1,class:ae(["max-w-[80%] flex flex-col gap-2",{"items-start":w.role==="assistant","items-end":w.role==="user"}])},[e("div",{class:ae(["rounded-2xl px-4 py-2 text-sm transition-all min-h-[2.5rem]",[w.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&&w.role!=="user"&&m(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":w.role==="assistant"?"bg-neutral-800 text-white dark:bg-neutral-300 dark:text-black":w.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":w.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&&w.role!=="user"&&b(R)&&!w.silent&&!m(R,t.selectedLogId)&&m(R,t.hoveredLogId)},{"ring-2 ring-green-500 dark:ring-green-400":t.isEditMode&&c(w.id),"border border-dashed border-neutral-400 dark:border-neutral-500":t.isEditMode&&w.role!=="system"&&!c(w.id)}]])},[w.content||t.isEditMode?(a(),o("div",{key:0,class:"whitespace-pre-wrap break-words text-sm outline-none",contenteditable:t.isEditMode&&w.role!=="system",onInput:I=>r(I,w.id),onClick:M[0]||(M[0]=I=>t.isEditMode&&I.stopPropagation())},S(se(w.content)),41,Xi)):w.status==="pending"?(a(),o("div",Yi,[...M[6]||(M[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)])])):V("",!0),w.status!=="pending"?(a(),o("div",{key:2,class:ae(["text-[10px] mt-1 opacity-50 flex gap-2",{"justify-start":w.role==="assistant","justify-end":w.role!=="assistant"}])},[w.sideLabel?(a(),o("span",Qi,S(w.sideLabel),1)):V("",!0),e("span",null,S(te(w.created_at)),1),w.silent?(a(),o("span",Zi," silent ")):V("",!0)],2)):V("",!0)],2),w.attachments?.length&&t.threadId?(a(),o("div",ed,[(a(!0),o(ve,null,ke(w.attachments,I=>(a(),ne(zi,{key:I.id,attachment:I,threadId:t.threadId},null,8,["attachment","threadId"]))),128))])):V("",!0)],2)):w.type==="work"?(a(),o("div",{key:2,class:ae(["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":w.role==="assistant"&&!w.silent,"bg-accent-50 text-accent-700 border-accent-200 dark:bg-accent-50 dark:text-accent-700 dark:border-accent-200":w.role==="user"&&!w.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":w.silent,"ring-2 ring-accent-500":!t.isEditMode&&G(w),"ring-2 ring-accent-400":!t.isEditMode&&!G(w)&&E(w)}]),onClick:I=>!t.isEditMode&&(F(w.id),Z(w)[0]&&l("messageClick",w.id,Z(w)[0])),onMouseenter:I=>!t.isEditMode&&Z(w)[0]&&l("messageHover",Z(w)[0]),onMouseleave:M[3]||(M[3]=I=>!t.isEditMode&&l("messageHover",null))},[D.value.has(w.id)?(a(),o("div",ud,[e("div",cd,[A(X(nt),{size:14,class:"flex-shrink-0"}),e("span",pd,S(P(w)),1),e("span",md,S(w.items.length)+" operation"+S(w.items.length!==1?"s":""),1)]),(a(!0),o(ve,null,ke(w.items,I=>(a(),o("div",{key:I.id,class:"mb-1"},[I.type==="tool_call"?(a(),o("div",vd,[e("div",{onClick:Ee(le=>{T(I.id),I.log_id&&l("messageClick",w.id,I.log_id)},["stop"]),onMouseenter:Ee(le=>I.log_id&&l("messageHover",I.log_id),["stop"]),onMouseleave:M[1]||(M[1]=Ee(le=>l("messageHover",null),["stop"])),class:ae(["flex items-center gap-2 cursor-pointer hover:opacity-70 transition-opacity min-w-0",{"ring-1 ring-accent-500":ee(I),"ring-1 ring-accent-400":!ee(I)&&U(I)}])},[q.value.has(I.id)?(a(),ne(X(nt),{key:1,size:12,class:"flex-shrink-0 opacity-50"})):(a(),ne(X(mt),{key:0,size:12,class:"flex-shrink-0 opacity-50"})),e("span",hd,S(I.tool_name),1),oe(I.tool_arguments)?(a(),o("span",gd,S(oe(I.tool_arguments)),1)):V("",!0),I.response_status==="success"?(a(),o("span",bd,"✓")):I.response_status==="failed"?(a(),ne(X(Fa),{key:4,size:12,class:"ml-auto text-red-600 dark:text-red-400"})):V("",!0)],42,fd),q.value.has(I.id)?(a(),o("div",xd,[I.tool_arguments?(a(),o("div",yd,[M[7]||(M[7]=e("div",{class:"font-semibold mb-1 opacity-70"},"Arguments:",-1)),e("table",kd,[e("tbody",null,[(a(!0),o(ve,null,ke(K(I.tool_arguments),(le,O)=>(a(),o("tr",{key:O,class:"border-b border-current border-opacity-10"},[e("td",wd,S(O),1),e("td",_d,S(typeof le=="object"?JSON.stringify(le):le),1)]))),128))])])])):V("",!0),I.response?(a(),o("div",$d,[M[8]||(M[8]=e("div",{class:"font-semibold mb-1 opacity-70"},"Response:",-1)),e("div",{class:ae(["opacity-80 cursor-pointer hover:opacity-100",{"ring-1 ring-accent-500":t.selectedLogId&&I.response_log_id===t.selectedLogId,"ring-1 ring-accent-400":t.hoveredLogId&&I.response_log_id===t.hoveredLogId&&I.response_log_id!==t.selectedLogId}]),onClick:Ee(le=>I.response_log_id&&l("messageClick",w.id,I.response_log_id),["stop"]),onMouseenter:Ee(le=>I.response_log_id&&l("messageHover",I.response_log_id),["stop"]),onMouseleave:M[2]||(M[2]=Ee(le=>l("messageHover",null),["stop"]))},[e("div",Td,S(se(I.response)),1)],42,Cd)])):V("",!0)])):V("",!0)])):I.type==="reasoning"?(a(),o("div",Sd,[e("button",{onClick:Ee(le=>$(I.id),["stop"]),class:"flex items-center gap-1 opacity-70 hover:opacity-100 transition-opacity"},[B.value.has(I.id)?(a(),ne(X(nt),{key:1,size:12,class:"flex-shrink-0"})):(a(),ne(X(mt),{key:0,size:12,class:"flex-shrink-0"})),M[9]||(M[9]=e("span",{class:"font-semibold"},"Reasoning",-1))],8,Vd),B.value.has(I.id)?(a(),o("div",Md,S(se(I.content)),1)):V("",!0)])):I.type==="content"?(a(),o("div",Id,S(se(I.content)),1)):V("",!0)]))),128))])):(a(),o("div",ad,[e("div",od,[A(X(mt),{size:14,class:"flex-shrink-0 mt-0.5 opacity-50"}),e("div",ld,[C(w.items)?(a(),o("div",sd,S(L(C(w.items)))+"... ",1)):(a(),o("div",nd,S(P(w)),1))])]),e("div",rd,[e("span",id,S(w.items.length)+" operation"+S(w.items.length!==1?"s":""),1),e("span",dd,"• "+S(P(w)),1)])]))],42,td)):V("",!0)],2)],40,Hi))),128))]))}}),Ld=tt(Ed,[["__scopeId","data-v-884a0fa7"]]),Ad={key:0,class:"overflow-hidden border-b border-neutral-300 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-900"},Pd={class:"max-h-[400px] overflow-y-auto"},Dd={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"},jd={class:"p-4"},Od={key:0,class:"flex justify-center py-4"},Ud={key:1,class:"text-red-600 dark:text-red-400 text-center py-4 text-sm"},Rd={key:2,class:"space-y-3 text-sm"},Nd={class:"flex items-start gap-2"},Fd={class:"font-mono text-xs break-all"},Bd={class:"flex items-start gap-2"},qd={class:"flex-1"},zd={key:0,class:"flex items-center gap-2"},Hd={class:"text-xs text-neutral-500"},Wd={key:1,class:"space-y-2"},Jd={class:"flex gap-2"},Kd=["disabled"],Gd=["disabled"],Xd={class:"flex items-start gap-2"},Yd={key:0,class:"flex items-start gap-2"},Qd={class:"font-mono text-xs"},Zd={class:"flex items-start gap-2"},eu={class:"flex-1 flex items-center gap-2 flex-wrap"},tu={key:1,class:"text-neutral-500 dark:text-neutral-500 italic text-xs"},au={class:"flex items-start gap-2"},ou=["disabled"],lu={key:1,class:"flex justify-center py-2"},su={key:1,class:"p-3 rounded border border-neutral-200 dark:border-neutral-700 bg-neutral-100 dark:bg-neutral-800 space-y-2"},nu={class:"flex items-center gap-4 text-xs"},ru={class:"font-mono font-bold ml-1"},iu={class:"font-mono font-bold ml-1"},du={key:0,class:"text-xs"},uu={class:"w-full"},cu={class:"py-1"},pu={class:"text-right py-1 font-mono"},mu={class:"text-right py-1 font-mono"},vu={class:"flex items-start gap-2"},fu={class:"flex items-center gap-2"},hu=["disabled"],gu={key:0},bu={key:1},xu={class:"pt-2 border-t border-neutral-200 dark:border-neutral-800 flex justify-end"},yu=["disabled"],ku={key:0},wu={key:1},_u=me({__name:"MetadataSlidePane",props:{threadId:{},show:{type:Boolean}},emits:["close","threadDeleted","editThread"],setup(t,{emit:n}){const s=t,i=n,{thread:l,isFetching:u,error:r}=St(J(()=>s.threadId)),c=v(!1),f=v(!1),g=v(!1),d=v(!1),p=v(""),h=v(!1),_=v(!1),b=v(!1),m=v("a"),y=v(null),{data:x,isFetching:k}=Ue(ue("/api/agents"),{refetch:!0}).json(),D=J(()=>x.value?.agents?x.value.agents.filter(C=>C.type==="ai_human").map(C=>({value:C.id,label:C.title,description:`Type: ${C.type}`})):[]),q=J(()=>l.value?.agent.type==="ai_human"),B=C=>new Date(C*1e3).toLocaleString(),F=()=>{l.value&&(p.value=l.value.agent.id,g.value=!0)},T=()=>{g.value=!1,p.value=""},$=async()=>{if(!(!s.threadId||!p.value)){d.value=!0;try{const C=await fetch(ue(`/api/threads/${s.threadId}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent_id:p.value})});if(!C.ok){const L=await C.json();throw new Error(L.error||"Failed to update agent")}window.location.reload()}catch(C){console.error("Error updating agent:",C),alert(`Failed to update agent: ${C.message}`)}finally{d.value=!1}}},K=async()=>{if(s.threadId){_.value=!0,h.value=!0;try{const C=await fetch(ue(`/api/threads/${s.threadId}/cost`));if(!C.ok){const L=await C.json();throw new Error(L.error||"Failed to fetch cost breakdown")}y.value=await C.json()}catch(C){console.error("Error fetching cost breakdown:",C),alert(`Failed to fetch cost breakdown: ${C.message}`),h.value=!1}finally{_.value=!1}}},oe=C=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:6}).format(C),te=J(()=>l.value?.agent.type==="dual_ai"),H=async()=>{if(s.threadId){b.value=!0;try{const C=await fetch(ue(`/api/threads/${s.threadId}/continue`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({side:m.value})});if(!C.ok){const L=await C.json();throw new Error(L.error||"Failed to continue execution")}}catch(C){console.error("Error continuing execution:",C),alert(`Failed to continue execution: ${C.message}`)}finally{b.value=!1}}},P=async()=>{if(s.threadId){f.value=!0;try{const C=await fetch(ue(`/api/threads/${s.threadId}`),{method:"DELETE"});if(!C.ok){const L=await C.json();throw new Error(L.error||"Failed to delete thread")}i("threadDeleted",s.threadId)}catch(C){console.error("Error deleting thread:",C),alert(`Failed to delete thread: ${C.message}`)}finally{f.value=!1}}};return fe(()=>s.show,C=>{C||(g.value=!1,p.value="")}),fe(()=>s.threadId,()=>{g.value=!1,p.value="",h.value=!1,y.value=null}),(C,L)=>(a(),ne(Xe,{"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:be(()=>[t.show&&t.threadId?(a(),o("div",Ad,[e("div",Pd,[e("div",Dd,[L[7]||(L[7]=e("span",{class:"text-sm font-medium text-neutral-600 dark:text-neutral-400"},"Thread Info",-1)),e("button",{onClick:L[0]||(L[0]=G=>i("close")),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors",title:"Close metadata"},[A(X(ta),{size:16})])]),e("div",jd,[X(u)?(a(),o("div",Od,[A(Se)])):X(r)?(a(),o("div",Ud," Error loading metadata: "+S(X(r)),1)):X(l)?(a(),o("div",Rd,[e("div",Nd,[L[8]||(L[8]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"ID",-1)),e("span",Fd,S(X(l).id),1)]),e("div",Bd,[L[9]||(L[9]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"Agent",-1)),e("div",qd,[g.value?(a(),o("div",Wd,[A(Ve,{modelValue:p.value,"onUpdate:modelValue":L[1]||(L[1]=G=>p.value=G),options:D.value,loading:X(k),placeholder:"Select an agent"},null,8,["modelValue","options","loading"]),e("div",Jd,[e("button",{onClick:$,disabled:d.value||!p.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"},S(d.value?"Saving...":"Save"),9,Kd),e("button",{onClick:T,disabled:d.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,Gd)])])):(a(),o("div",zd,[e("span",null,S(X(l).agent.title),1),e("span",Hd,"("+S(X(l).agent.type)+")",1),q.value?(a(),o("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"},[A(X(kt),{size:12})])):V("",!0)]))])]),e("div",Xd,[L[10]||(L[10]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"Created",-1)),e("span",null,S(B(X(l).created_at)),1)]),X(l).user_id?(a(),o("div",Yd,[L[11]||(L[11]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"User",-1)),e("span",Qd,S(X(l).user_id),1)])):V("",!0),e("div",Zd,[L[12]||(L[12]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"Tags",-1)),e("div",eu,[X(l).tags?.length>0?(a(!0),o(ve,{key:0},ke(X(l).tags,G=>(a(),o("span",{key:G,class:"inline-block px-2 py-0.5 text-xs rounded bg-black text-white dark:bg-white dark:text-black"},S(G),1))),128)):(a(),o("span",tu,"No tags")),e("button",{onClick:L[2]||(L[2]=G=>i("editThread")),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors",title:"Edit tags"},[A(X(kt),{size:12})])])]),e("div",au,[L[15]||(L[15]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 shrink-0 text-left"},"Cost",-1)),!h.value&&!_.value?(a(),o("button",{key:0,onClick:K,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"},[A(X(At),{size:12}),L[13]||(L[13]=e("span",null,"View Costs",-1))],8,ou)):V("",!0),_.value?(a(),o("div",lu,[A(Se)])):V("",!0),h.value?(a(),o("button",{key:2,onClick:L[3]||(L[3]=G=>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"},[A(X(At),{size:12}),L[14]||(L[14]=e("span",null,"Hide Costs",-1))])):V("",!0)]),h.value&&y.value?(a(),o("div",su,[e("div",nu,[e("div",null,[L[16]||(L[16]=e("span",{class:"text-neutral-500"},"Total:",-1)),e("span",ru,S(oe(y.value.totalCost)),1)]),e("div",null,[L[17]||(L[17]=e("span",{class:"text-neutral-500"},"Avg/msg:",-1)),e("span",iu,S(oe(y.value.avgCostPerMessage)),1)])]),y.value.modelBreakdown.length>0?(a(),o("div",du,[e("table",uu,[L[18]||(L[18]=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,[(a(!0),o(ve,null,ke(y.value.modelBreakdown,G=>(a(),o("tr",{key:G.modelName},[e("td",cu,S(G.modelName),1),e("td",pu,S(G.requestCount),1),e("td",mu,S(oe(G.totalCost)),1)]))),128))])])])):V("",!0)])):V("",!0),e("div",vu,[L[20]||(L[20]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 shrink-0 text-left"},"Debug",-1)),e("div",fu,[te.value?Ie((a(),o("select",{key:0,"onUpdate:modelValue":L[4]||(L[4]=G=>m.value=G),class:"text-xs px-1 py-0.5 border border-neutral-300 dark:border-neutral-600 rounded bg-white dark:bg-neutral-800"},[...L[19]||(L[19]=[e("option",{value:"a"},"Side A",-1),e("option",{value:"b"},"Side B",-1)])],512)),[[Ba,m.value]]):V("",!0),e("button",{onClick:H,disabled:b.value,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"},[A(X(qa),{size:12}),b.value?(a(),o("span",gu,"Running...")):(a(),o("span",bu,"Continue"))],8,hu)])]),e("div",xu,[e("button",{onClick:L[5]||(L[5]=G=>c.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"},[A(X(za),{size:12}),f.value?(a(),o("span",ku,"Deleting...")):(a(),o("span",wu,"Delete Thread"))],8,yu)])])):V("",!0)])]),A(xa,{modelValue:c.value,"onUpdate:modelValue":L[6]||(L[6]=G=>c.value=G),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:P},null,8,["modelValue"])])):V("",!0)]),_:1}))}}),$u={key:0,class:"overflow-hidden border-b border-neutral-300 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-900"},Cu={class:"max-h-[400px] overflow-y-auto"},Tu={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"},Su={class:"flex items-center gap-1"},Vu={class:"p-2"},Mu={key:0,class:"px-3 py-6 text-center text-neutral-500 dark:text-neutral-400 text-sm"},Iu=["onClick"],Eu={class:"text-xs truncate"},Lu={class:"text-[10px] text-neutral-400 ml-auto"},Au=["href","onMouseenter"],Pu={class:"shrink-0 text-neutral-500 dark:text-neutral-400"},Du={class:"flex-1 min-w-0"},ju={class:"shrink-0 text-[10px] text-neutral-400 dark:text-neutral-500 ml-auto"},Ou={key:0,class:"text-blue-500"},Uu={key:1,class:"text-red-500"},Ru={key:2},Nu=["href","onMouseenter"],Fu={class:"shrink-0 text-neutral-500 dark:text-neutral-400"},Bu={class:"flex-1 min-w-0"},qu={class:"shrink-0 text-[10px] text-neutral-400 dark:text-neutral-500 ml-auto"},zu={key:0,class:"text-blue-500"},Hu={key:1,class:"text-red-500"},Wu={key:2},Ju={class:"px-4 py-1.5 border-t border-neutral-200 dark:border-neutral-700 text-[10px] text-neutral-400 dark:text-neutral-500"},Ku=["src","alt"],Gu=me({__name:"FilesSlidePane",props:{threadId:{},show:{type:Boolean}},emits:["close"],setup(t,{emit:n}){const s=t,i=n;let l=null;try{l=ca()}catch{}const u=l?.files??v([]),r=l?.addFiles??(()=>{}),c=v(null),f=v(new Set(["/attachments"])),g=v(null),d=v({x:0,y:0});function p(B){if(B===0)return"0 B";const F=1024,T=["B","KB","MB","GB"],$=Math.floor(Math.log(B)/Math.log(F));return parseFloat((B/Math.pow(F,$)).toFixed(1))+" "+T[$]}function h(B){const F=B.startsWith("/")?B.slice(1):B;return ue(`/api/threads/${s.threadId}/fs/${F}`)}function _(B,F){return F?Zt:B.startsWith("audio/")?Ja:B.startsWith("video/")?Ka:B.startsWith("text/")?Ga:B.includes("javascript")||B.includes("json")||B.includes("xml")?Xa:ea}function b(B){const F=B.target;F.files?.length&&(r(F.files),F.value="")}function m(){c.value?.click()}function y(B){f.value.has(B)?f.value.delete(B):f.value.add(B),f.value=new Set(f.value)}function x(B){d.value={x:B.clientX,y:B.clientY}}function k(B){g.value=B}const D=J(()=>{const B=[],F=new Map,T=[...u.value].sort(($,K)=>$.status==="uploading"&&K.status!=="uploading"?-1:K.status==="uploading"&&$.status!=="uploading"?1:($.path||$.name).localeCompare(K.path||K.name));for(const $ of T){const K=$.path||`/${$.name}`,oe=K.split("/").filter(Boolean);if(oe.length===1)B.push({type:"file",name:$.name,path:K,file:$});else{const te="/"+oe.slice(0,-1).join("/"),H=oe[oe.length-2];if(!F.has(te)){const P={type:"directory",name:H,path:te,children:[]};F.set(te,P),B.push(P)}F.get(te).children.push({type:"file",name:$.name,path:K,file:$})}}return B}),q=J(()=>u.value.length);return Me(()=>{document.addEventListener("mousemove",x)}),Be(()=>{document.removeEventListener("mousemove",x)}),(B,F)=>(a(),ne(Xe,{"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:be(()=>[t.show?(a(),o("div",$u,[e("div",Cu,[e("div",Tu,[F[4]||(F[4]=e("span",{class:"text-sm font-medium text-neutral-600 dark:text-neutral-400"}," Thread Files ",-1)),e("div",Su,[e("input",{ref_key:"fileInput",ref:c,type:"file",multiple:"",class:"hidden",onChange:b},null,544),e("button",{onClick:m,type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300",title:"Upload files"},[A(X(Ha),{size:16})]),e("button",{onClick:F[0]||(F[0]=T=>i("close")),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors",title:"Close files"},[A(X(ta),{size:16})])])]),e("div",Vu,[D.value.length===0?(a(),o("div",Mu," No files yet ")):V("",!0),(a(!0),o(ve,null,ke(D.value,T=>(a(),o(ve,{key:T.path},[T.type==="directory"?(a(),o(ve,{key:0},[e("button",{onClick:$=>y(T.path),type:"button",class:"w-full flex items-center gap-1.5 px-2 py-1.5 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors text-left"},[A(X(mt),{size:12,class:ae(["shrink-0 text-neutral-400 transition-transform",{"rotate-90":f.value.has(T.path)}])},null,8,["class"]),(a(),ne(Ze(f.value.has(T.path)?X(Wa):X(aa)),{size:14,class:"shrink-0",style:{color:"var(--accent-500)"}})),e("span",Eu,S(T.name),1),e("span",Lu,S(T.children?.length),1)],8,Iu),f.value.has(T.path)?(a(!0),o(ve,{key:0},ke(T.children,$=>(a(),o("a",{key:$.path,href:$.path?h($.path):void 0,target:"_blank",rel:"noopener noreferrer",class:ae(["flex items-center gap-2 pl-7 pr-2 py-1 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors cursor-pointer",{"pointer-events-none":$.file?.status==="uploading"}]),onMouseenter:K=>$.file?.isImage?k($.path):null,onMouseleave:F[1]||(F[1]=K=>k(null))},[e("div",Pu,[$.file?.status==="uploading"?(a(),ne(X(Pt),{key:0,size:12,class:"animate-spin"})):(a(),ne(Ze(_($.file?.mimeType||"",$.file?.isImage||!1)),{key:1,size:12}))]),e("div",Du,[e("div",{class:ae(["text-[11px] truncate",{"text-neutral-400":$.file?.status==="uploading"}])},S($.name),3)]),e("div",ju,[$.file?.status==="uploading"?(a(),o("span",Ou,"...")):$.file?.status==="error"?(a(),o("span",Uu,"err")):(a(),o("span",Ru,S(p($.file?.size||0)),1))])],42,Au))),128)):V("",!0)],64)):(a(),o("a",{key:1,href:T.path?h(T.path):void 0,target:"_blank",rel:"noopener noreferrer",class:ae(["flex items-center gap-2 px-2 py-1.5 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors cursor-pointer",{"pointer-events-none":T.file?.status==="uploading"}]),onMouseenter:$=>T.file?.isImage?k(T.path):null,onMouseleave:F[2]||(F[2]=$=>k(null))},[e("div",Fu,[T.file?.status==="uploading"?(a(),ne(X(Pt),{key:0,size:14,class:"animate-spin"})):(a(),ne(Ze(_(T.file?.mimeType||"",T.file?.isImage||!1)),{key:1,size:14}))]),e("div",Bu,[e("div",{class:ae(["text-xs truncate",{"text-neutral-400":T.file?.status==="uploading"}])},S(T.name),3)]),e("div",qu,[T.file?.status==="uploading"?(a(),o("span",zu,"...")):T.file?.status==="error"?(a(),o("span",Hu,"err")):(a(),o("span",Wu,S(p(T.file?.size||0)),1))])],42,Nu))],64))),128))]),e("div",Ju,S(q.value)+" file"+S(q.value!==1?"s":""),1)]),(a(),ne(it,{to:"body"},[g.value?(a(),o("div",{key:0,class:"fixed z-50 bg-white dark:bg-neutral-800 border border-neutral-300 dark:border-neutral-600 rounded-lg shadow-lg p-1 pointer-events-none",style:ot({left:`${d.value.x+16}px`,top:`${d.value.y-80}px`})},[e("img",{src:h(g.value),alt:g.value,class:"max-w-[200px] max-h-[150px] rounded object-contain",onError:F[3]||(F[3]=T=>T.target.style.display="none")},null,40,Ku)],4)):V("",!0)]))])):V("",!0)]),_:1}))}}),Xu=["accept"],Yu=["disabled"],Qu=me({__name:"FileUpload",props:{isProcessing:{type:Boolean},accept:{}},emits:["filesSelected"],setup(t,{expose:n,emit:s}){const i=t,l=s,u=v(null),r=J(()=>i.accept||"image/*,.pdf,.txt,.md,.json,.csv");function c(){u.value?.click()}function f(d){const p=d.target;p.files&&p.files.length>0&&(l("filesSelected",p.files),p.value="")}function g(d){const p=d.clipboardData?.items;if(!p)return;const h=[];for(let _=0;_<p.length;_++){const b=p[_];if(b.kind==="file"){const m=b.getAsFile();m&&h.push(m)}}if(h.length>0){const _=new DataTransfer;h.forEach(b=>_.items.add(b)),l("filesSelected",_.files)}}return n({handlePaste:g}),(d,p)=>(a(),o(ve,null,[e("input",{ref_key:"fileInputRef",ref:u,type:"file",accept:r.value,multiple:"",class:"hidden",onChange:f},null,40,Xu),e("button",{type:"button",onClick:c,class:ae(["p-1.5 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded-lg transition-colors text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300",{"opacity-50 cursor-not-allowed":t.isProcessing}]),disabled:t.isProcessing,title:"Attach files"},[A(X(Ya),{size:18})],10,Yu)],64))}}),Zu={class:"flex flex-col h-full"},ec={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},tc={class:"flex items-center justify-between"},ac={class:"flex items-center gap-2"},oc={class:"flex items-center gap-2"},lc={class:"flex-1 flex flex-col overflow-hidden relative"},sc={key:0,class:"text-neutral-500 dark:text-neutral-400 text-center py-8"},nc={key:1,class:"flex justify-center py-2"},rc={key:2,class:"flex justify-center py-8"},ic={key:3,class:"text-red-600 dark:text-red-400 text-center py-8"},dc={key:4,class:"text-neutral-500 dark:text-neutral-400 text-center py-8"},uc={key:1,class:"p-3 bg-white dark:bg-neutral-900 border-t border-neutral-300 dark:border-neutral-700"},cc={class:"flex items-center justify-end gap-2"},pc=["disabled"],mc={key:2,class:"p-3 bg-white dark:bg-neutral-900 border-t border-neutral-300 dark:border-neutral-700"},vc={key:0,class:"mb-2 flex flex-wrap gap-2"},fc={key:0,class:"w-16 h-16 rounded-lg overflow-hidden border border-neutral-200 dark:border-neutral-700 bg-neutral-100 dark:bg-neutral-800"},hc=["src","alt"],gc={key:1,class:"w-full h-full flex items-center justify-center"},bc={key:1,class:"h-16 px-3 rounded-lg border border-neutral-200 dark:border-neutral-700 bg-neutral-100 dark:bg-neutral-800 flex items-center gap-2"},xc=["title"],yc=["onClick"],kc={class:"flex items-start gap-2"},wc={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"},_c=["disabled"],$c=["disabled"],Cc={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"},Tc={key:1,class:"w-4 h-4"},Bt=me({__name:"MessagesPane",props:{threadId:{},selectedMessageId:{},selectedLogId:{},hoveredLogId:{}},emits:["collapse","messageClick","messageHover","threadDeleted","editThread","logsDeleted"],setup(t,{expose:n,emit:s}){const i=t,l=s,u=v(!1),r=()=>{u.value=!u.value},c=v(!1),f=()=>{c.value=!c.value},g=v(!1),d=v(new Set),p=v(new Map),h=()=>{g.value=!g.value,g.value||(d.value=new Set,p.value=new Map)},_=(xe,he)=>{const $e=new Set(d.value);he?$e.add(xe):$e.delete(xe),d.value=$e},b=(xe,he)=>{const $e=new Map(p.value);$e.set(xe,he),p.value=$e},m=()=>{g.value=!1,d.value=new Set,p.value=new Map},y=J(()=>d.value.size),x=J(()=>{let xe=0;for(const[he]of p.value)d.value.has(he)||xe++;return xe}),k=J(()=>{const xe=y.value,he=x.value;return xe>0&&he>0?`Delete (${xe}), Update (${he})`:xe>0?`Delete (${xe})`:he>0?`Save changes (${he})`:"Delete"}),D=J(()=>y.value>0||x.value>0),q=async()=>{if(!i.threadId||!D.value)return;const xe=[];for(const he of d.value){const $e=B.value.find(Ne=>Ne.id===he);$e&&"log_id"in $e&&$e.log_id&&xe.push($e.log_id)}try{for(const[he,$e]of p.value)d.value.has(he)||await G(he,$e);for(const he of d.value)await L(he);xe.length>0&&l("logsDeleted",xe)}catch(he){console.error("Error applying changes:",he)}finally{m()}},{messages:B,threadInfo:F,isFetching:T,isLoadingMore:$,error:K,wsConnected:oe,wsError:te,isExecuting:H,hasMore:P,loadMoreMessages:C,deleteMessageById:L,updateMessageContent:G,stopThread:ee,sendMessage:E,attachments:U,addAttachment:Z,removeAttachment:se}=Oi(J(()=>i.threadId),{}),{thread:j}=St(J(()=>i.threadId)),M=J(()=>U.value.length>0),w=J(()=>!1),R=v(null),I=xe=>{Z(xe)},le=v(null),O=v(null);n({scrollToLogId:xe=>O.value&&le.value?O.value.scrollToLogId(xe,le.value):!1,hasWorkblockForLogId:xe=>O.value?O.value.hasWorkblockForLogId(xe):!1}),typeof window<"u"&&(window.__testLoadMoreMessages=C);const z=v(""),N=v(null),Q=v("B"),we=v(!1),de=v(!1),pe=async()=>{await Te(),le.value&&(le.value.scrollTop=le.value.scrollHeight)},ie=async xe=>{xe.target.scrollTop<100&&P.value&&!$.value&&!de.value&&(de.value=!0,await C(),de.value=!1)};fe(()=>B.value.length,async()=>{!$.value&&!de.value&&await pe()}),fe(()=>i.threadId,async xe=>{xe&&await pe()}),fe(T,async(xe,he)=>{he&&!xe&&await pe()});const ye=J(()=>{const xe=F.value?.agent||j.value?.agent;if(!xe)return"ai A";const he=xe.type;return Q.value==="A"&&xe.side_a_label?xe.side_a_label:Q.value==="B"&&xe.side_b_label?xe.side_b_label:he==="ai_human"?Q.value==="A"?"ai":"human":Q.value==="A"?"ai A":"ai B"}),_e=()=>{Q.value=Q.value==="A"?"B":"A"},Ae=async()=>{const xe=z.value.trim().length>0,he=M.value;if(!xe&&!he||!i.threadId||we.value||!E)return;const $e=z.value,Ne=Q.value==="A"?"assistant":"user";z.value="",N.value&&(N.value.style.height="auto",N.value.style.height="24px"),we.value=!0;try{await E({role:Ne,content:$e}),await pe()}catch(ht){console.error("Error sending message:",ht)}finally{we.value=!1,await Te(),N.value&&N.value.focus()}},Fe=xe=>{xe.key==="Enter"&&!xe.shiftKey&&(xe.preventDefault(),Ae())},Re=async()=>{if(i.threadId)try{await ee()}catch(xe){console.error("Error stopping thread:",xe)}};return(xe,he)=>(a(),o("div",Zu,[e("div",ec,[e("div",tc,[e("div",ac,[A(X(oa),{size:18,class:"shrink-0"}),he[10]||(he[10]=e("h2",{class:"text-base font-bold"},"Messages",-1)),t.threadId?(a(),ne(Vt,{key:0,connected:X(oe),error:X(te)},null,8,["connected","error"])):V("",!0)]),e("div",oc,[t.threadId?(a(),o("button",{key:0,onClick:f,type:"button",class:ae(["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 files"},[A(X(aa),{size:20})],2)):V("",!0),t.threadId?(a(),o("button",{key:1,onClick:r,type:"button",class:ae(["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"},[A(X(Qa),{size:20})],2)):V("",!0),t.threadId&&X(B).length>0?(a(),o("button",{key:2,onClick:h,type:"button",class:ae(["p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",{"bg-neutral-200 dark:bg-neutral-800":g.value}]),title:"Edit messages"},[A(X(kt),{size:20})],2)):V("",!0),e("button",{onClick:he[0]||(he[0]=$e=>l("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[A(X(Tt),{size:20})])])])]),e("div",lc,[A(_u,{"thread-id":t.threadId,show:u.value,onClose:he[1]||(he[1]=$e=>u.value=!1),onThreadDeleted:he[2]||(he[2]=$e=>l("threadDeleted",$e)),onEditThread:he[3]||(he[3]=$e=>l("editThread"))},null,8,["thread-id","show"]),t.threadId?(a(),ne(Gu,{key:0,"thread-id":t.threadId,show:c.value,onClose:he[4]||(he[4]=$e=>c.value=!1)},null,8,["thread-id","show"])):V("",!0),e("div",{ref_key:"messagesContainer",ref:le,class:"flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-4",onScroll:ie},[t.threadId?V("",!0):(a(),o("div",sc," Select a thread to view messages ")),X($)?(a(),o("div",nc,[A(Se,{size:"sm"}),he[11]||(he[11]=e("span",{class:"ml-2 text-xs text-neutral-500"},"Loading older messages...",-1))])):X(T)?(a(),o("div",rc,[A(Se)])):X(K)?(a(),o("div",ic," Error loading messages: "+S(X(K)),1)):t.threadId&&X(B).length===0?(a(),o("div",dc," No messages yet ")):(a(),ne(Ld,{key:5,ref_key:"agentMessagesRef",ref:O,messages:X(B),threadId:t.threadId,selectedMessageId:t.selectedMessageId,selectedLogId:t.selectedLogId,hoveredLogId:t.hoveredLogId,isEditMode:g.value,selectedForDelete:d.value,editedMessages:p.value,onMessageClick:he[5]||(he[5]=($e,Ne)=>l("messageClick",$e,Ne)),onMessageHover:he[6]||(he[6]=$e=>l("messageHover",$e)),onSelectionChange:_,onMessageEdit:b},null,8,["messages","threadId","selectedMessageId","selectedLogId","hoveredLogId","isEditMode","selectedForDelete","editedMessages"]))],544),t.threadId&&g.value?(a(),o("div",uc,[e("div",cc,[e("button",{onClick:m,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:q,disabled:!D.value,class:ae(["px-4 py-2 rounded-lg font-medium text-sm transition-colors",{"bg-red-600 text-white hover:bg-red-700":D.value&&y.value>0,"bg-black text-white hover:bg-neutral-800 dark:bg-white dark:text-black dark:hover:bg-neutral-200":D.value&&y.value===0,"bg-neutral-200 text-neutral-400 dark:bg-neutral-700 dark:text-neutral-500 cursor-not-allowed":!D.value}])},S(k.value),11,pc)])])):t.threadId?(a(),o("div",mc,[X(U).length>0?(a(),o("div",vc,[(a(!0),o(ve,null,ke(X(U),$e=>(a(),o("div",{key:$e.id,class:"relative group"},[$e.isImage?(a(),o("div",fc,[$e.previewUrl?(a(),o("img",{key:0,src:$e.previewUrl,alt:$e.name,class:"w-full h-full object-cover"},null,8,hc)):(a(),o("div",gc,[...he[12]||(he[12]=[e("div",{class:"w-4 h-4 border-2 border-neutral-300 border-t-neutral-600 rounded-full animate-spin"},null,-1)])]))])):(a(),o("div",bc,[e("span",{class:"text-xs text-neutral-600 dark:text-neutral-300 max-w-[80px] truncate",title:$e.name},S($e.name),9,xc)])),e("button",{onClick:Ee(Ne=>X(se)($e.id),["stop"]),class:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-neutral-600 dark:bg-neutral-500 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-500"},[...he[13]||(he[13]=[e("span",{class:"text-[10px] font-bold leading-none"},"x",-1)])],8,yc)]))),128))])):V("",!0),e("div",kc,[e("button",{onClick:_e,class:ae(["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":Q.value==="A","bg-neutral-300 text-black dark:bg-neutral-600 dark:text-white":Q.value==="B"}]),title:"Toggle between sides"},S(ye.value),3),e("div",wc,[A(Qu,{ref_key:"fileUploadRef",ref:R,"is-processing":!1,onFilesSelected:I},null,512),Ie(e("textarea",{ref_key:"messageTextarea",ref:N,"onUpdate:modelValue":he[7]||(he[7]=$e=>z.value=$e),onKeydown:Fe,onPaste:he[8]||(he[8]=$e=>R.value?.handlePaste($e)),disabled:we.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:he[9]||(he[9]=$e=>{const Ne=$e.target;Ne.style.height="auto",Ne.style.height=Math.min(Ne.scrollHeight,120)+"px"})},null,40,_c),[[Oe,z.value]]),X(H)?(a(),o("button",{key:1,id:"stop-thread-button",onClick:Re,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"},[...he[15]||(he[15]=[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)])])):(a(),o("button",{key:0,id:"send-message-button",onClick:Ae,disabled:!z.value.trim()&&!M.value||we.value||w.value,class:ae(["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":(z.value.trim()||M.value)&&!we.value&&!w.value,"bg-neutral-200 text-neutral-400 dark:bg-neutral-700 dark:text-neutral-600":!z.value.trim()&&!M.value||we.value||w.value}]),title:"Send message (Enter)"},[we.value?(a(),o("div",Tc,[A(Se)])):(a(),o("svg",Cc,[...he[14]||(he[14]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 10.5 12 3m0 0 7.5 7.5M12 3v18"},null,-1)])]))],10,$c))])])])):V("",!0)])]))}});function Sc(t,n){const{limit:s=100,offset:i=0,order:l="desc",autoFetch:u=!0,enableWebSocket:r=!1}=n||{};J(()=>!!(typeof t=="string"?t:t?.value));const c=J(()=>{const se=typeof t=="string"?t:t?.value;if(!se)return ue("/api/threads/placeholder/logs");const j=new URLSearchParams,M=typeof s=="number"?s:s.value,w=typeof i=="number"?i:i.value,R=typeof l=="string"?l:l.value;return j.append("limit",M.toString()),j.append("offset",w.toString()),j.append("order",R),ue(`/api/threads/${se}/logs?${j.toString()}`)}),{data:f,error:g,isFetching:d,isFinished:p,execute:h,abort:_}=Ue(c,{immediate:!1}).get().json();fe([c,()=>u],([se,j])=>{se&&!se.includes("placeholder")&&j&&h()},{immediate:!0});const b=J(()=>!g.value||g.value.toString().includes("aborted")||g.value.toString().includes("abort")?null:g.value),m=J(()=>f.value?.logs||[]),y=J(()=>f.value?.total||0),x=J(()=>f.value?.hasMore||!1),k=v(null),D=v(!1),q=v(null),B=v([]),F=new Map;let T=0,$=null,K=null,oe=!0,te=null;const H=3e4,P=3e4,C=()=>{$&&(clearTimeout($),$=null),K&&(clearInterval(K),K=null)},L=()=>{K&&clearInterval(K),K=setInterval(()=>{k.value&&k.value.readyState===WebSocket.OPEN&&k.value.send("ping")},P)},G=()=>{if(!oe||!r)return;const se=Math.min(1e3*Math.pow(2,T),H);T++,console.log(`[Logs WebSocket] Scheduling reconnect in ${se}ms (attempt ${T})`),$=setTimeout(()=>{oe&&ee()},se)},ee=()=>{const se=typeof t=="string"?t:t?.value;if(!se||!r)return;k.value&&(te=null,k.value.close()),T===0&&(B.value=[]);const j=window.location.protocol==="https:"?"wss:":"ws:",M=window.location.host;let w=`${j}//${M}${ue(`/api/threads/${se}/logs`)}`;const R=localStorage.getItem("auth_token");R&&(w+=`?token=${encodeURIComponent(R)}`);try{const I=new WebSocket(w);k.value=I,te=I,I.onopen=()=>{te===I&&(D.value=!0,q.value=null,T=0,L(),console.log("[Logs WebSocket] Connected"))},I.onmessage=le=>{if(te===I&&le.data!=="pong")try{const O=JSON.parse(le.data);if(O.type==="log_data"){const W=B.value.findIndex(z=>z.id===O.log_id),ce=m.value.find(z=>z.id===O.log_id);if(W>=0){B.value[W]={...B.value[W],...O.data};const z=F.get(O.log_id);z&&(B.value[W].queued_tools=z,F.delete(O.log_id))}else if(ce){const z={...ce,...O.data},N=F.get(O.log_id);N&&(z.queued_tools=N,F.delete(O.log_id)),B.value.push(z)}else{const z={id:O.log_id,...O.data},N=F.get(O.log_id);N&&(z.queued_tools=N,F.delete(O.log_id)),B.value.push(z)}}else if(O.type==="log_queued_tools"){const W=B.value.findIndex(z=>z.id===O.log_id),ce=m.value.find(z=>z.id===O.log_id);W>=0?B.value[W]={...B.value[W],queued_tools:O.queued_tools}:ce?B.value.push({...ce,queued_tools:O.queued_tools}):F.set(O.log_id,O.queued_tools)}}catch(O){console.error("[Logs WebSocket] Failed to parse message:",O)}},I.onerror=le=>{te===I&&(q.value="WebSocket connection error",console.error("[Logs WebSocket] Error:",le))},I.onclose=()=>{te===I&&(D.value=!1,C(),console.log("[Logs WebSocket] Disconnected"),G())}}catch(I){q.value=I.message||"Failed to create WebSocket",console.error("[Logs WebSocket] Creation error:",I),G()}},E=()=>{oe=!1,C(),te=null,k.value&&(k.value.close(),k.value=null),D.value=!1,T=0,B.value=[],F.clear()},U=()=>{oe=!0,T=0,ee()};return Be(()=>{E()}),{logs:J(()=>{if(!r)return m.value;const se=new Map;m.value.forEach(w=>se.set(w.id,w)),B.value.forEach(w=>se.set(w.id,w));const j=typeof l=="string"?l:l.value;return Array.from(se.values()).sort((w,R)=>j==="desc"?R.created_at-w.created_at:w.created_at-R.created_at)}),total:y,hasMore:x,error:b,isFetching:d,isFinished:p,refetch:h,abort:_,wsConnected:D,wsError:q,connectWebSocket:U,disconnectWebSocket:E}}function Vc(t,n){const s=J(()=>{const c=t.value,f=n.value;return!c||!f?null:ue(`/api/threads/${c}/logs/${f}`)}),{data:i,error:l,isFetching:u,execute:r}=Ue(s,{immediate:!1}).get().json();return fe([t,n],([c,f])=>{c&&f&&r()},{immediate:!0}),{logDetails:i,error:l,isFetching:u,refetch:r}}const Mc=["disabled","title"],Ic={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"},Ec={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"},Lc={key:3},wa=me({__name:"CopyButton",props:{content:{},variant:{},size:{},disabled:{type:Boolean}},setup(t){const n=t,s=v(!1),i=v(!1),l=async()=>{s.value=!0;try{await navigator.clipboard.writeText(n.content),i.value=!0,setTimeout(()=>{i.value=!1},2e3)}catch(c){console.error("Failed to copy:",c),alert(`Failed to copy: ${c instanceof Error?c.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(c,f)=>(a(),o("button",{onClick:l,disabled:s.value||t.disabled,class:ae([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":i.value?"Copied!":"Copy to clipboard"},[s.value?(a(),ne(Se,{key:0,size:"xs"})):t.variant==="ghost"&&!i.value?(a(),o("svg",Ic,[...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"&&i.value?(a(),o("svg",Ec,[...f[1]||(f[1]=[e("polyline",{points:"20 6 9 17 4 12"},null,-1)])])):(a(),o("span",Lc,S(i.value?"Copied!":"Copy"),1))],10,Mc))}}),bt="__shiki_highlighter__";let ct=null;async function Ac(){return typeof window<"u"&&window[bt]?window[bt]:ct||(ct=io({themes:["min-light","github-dark-high-contrast"],langs:["json","markdown"]}).then(t=>(typeof window<"u"&&(window[bt]=t),t)),ct)}const Pc={class:"code-block"},Dc={key:0,class:"text-xs text-neutral-500 p-2"},jc=["innerHTML"],xt=me({__name:"CodeBlock",props:{code:{},language:{}},setup(t){const n=t,s=v(""),i=v(!0),l=async()=>{const u=n.code??"";if(!u){s.value='<pre class="shiki"><code></code></pre>',i.value=!1;return}try{const r=await Ac();if(n.language==="json"||n.language==="markdown")s.value=r.codeToHtml(u,{lang:n.language,themes:{light:"min-light",dark:"github-dark-high-contrast"}});else{const c=u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");s.value=`<pre class="shiki shiki-text"><code>${c}</code></pre>`}}catch{const c=u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");s.value=`<pre class="shiki"><code>${c}</code></pre>`}finally{i.value=!1}};return Me(()=>{l()}),fe(()=>n.code,()=>{l()}),(u,r)=>(a(),o("div",Pc,[i.value?(a(),o("div",Dc,"Loading...")):(a(),o("div",{key:1,innerHTML:s.value,class:"code-content"},null,8,jc))]))}}),Oc={class:"json-viewer relative bg-white dark:bg-neutral-900"},Uc={key:0,class:"absolute top-[5px] right-[5px] z-10"},Rc=["innerHTML"],Nc=["src","alt"],Fc=me({__name:"JsonViewer",props:{json:{},threadId:{},showCopyButton:{type:Boolean}},setup(t){const n=t,s=v(null),i=v(null),l=h=>[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp"].some(b=>h.toLowerCase().endsWith(b)),u=h=>n.threadId?ue(`/api/threads/${n.threadId}/fs${h}`):null,r=J(()=>{if(!n.json)return"";if(typeof n.json=="string")try{return JSON.stringify(JSON.parse(n.json),null,2)}catch{return n.json}return JSON.stringify(n.json,null,2)}),c=h=>h.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),f=(h,_=0)=>{const b=" ".repeat(_),m=y=>`<span class="json-punct">${y}</span>`;if(h===null)return'<span class="json-null">null</span>';if(typeof h=="boolean")return`<span class="json-boolean">${h}</span>`;if(typeof h=="number")return`<span class="json-number">${h}</span>`;if(typeof h=="string"){const y=c(h);return n.threadId&&l(h)&&h.startsWith("/attachments/")?`${m('"')}<span class="json-image-path" data-path="${c(h)}">${y}</span>${m('"')}`:`${m('"')}<span class="json-string">${y}</span>${m('"')}`}if(Array.isArray(h)){if(h.length===0)return`${m("[")}${m("]")}`;const y=h.map((x,k)=>{const D=k<h.length-1?m(","):"";return`${b} ${f(x,_+1)}${D}`});return`${m("[")}
3
- ${y.join(`
1
+ import{d as me,i as $r,c as B,t as ba,r as p,w as ge,o as Pe,a as Ye,p as xa,b as n,e as r,n as st,f as e,g as je,h as Le,j as ya,k as I,l as Ae,m as ae,q as w,s as D,F as ve,u as ye,v as Z,x as C,y as Ke,z as H,A as Ie,B as Ue,C as ka,D as wa,I as Cr,E as _a,G as $a,T as Sr,H as T,J as Qe,K as Ze,L as it,M as Be,N as Ca,O as Re,P as gt,Q as Tr,R as Ir,S as ut,U as bt,V as tr,W as kt,X as et,Y as zr,Z as Sa,_ as Vr,$ as Ne,a0 as Oe,a1 as Mr,a2 as nt,a3 as vt,a4 as Jt,a5 as rr,a6 as Ta,a7 as Yt,a8 as Ia,a9 as Er,aa as za,ab as Lr,ac as Pr,ad as Ar,ae as Va,af as Ma,ag as Ea,ah as La,ai as Pa,aj as Aa,ak as Nt,al as ja,am as Da,an as ar,ao as Oa,ap as Ra,aq as Ua,ar as Ba,as as Fa,at as jr,au as Na,av as qa,aw as Ha,ax as Wa,ay as Ka,az as Ja,aA as Ya,aB as Ga,aC as Za,aD as Xa,aE as Qa}from"./vue.js";import{a6 as eo,a7 as to,a8 as ro,a9 as Vt,aa as ao,r as Mt}from"./vendor.js";import{W as oo,a as no,e as or}from"./monaco.js";(function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))i(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const s of u.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&i(s)}).observe(document,{childList:!0,subtree:!0});function a(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function i(l){if(l.ep)return;l.ep=!0;const u=a(l);fetch(l.href,u)}})();var Dr=class{endpoint;token;constructor(t){this.endpoint=t.replace(/\/$/,""),this.token=typeof localStorage<"u"?localStorage.getItem("agentbuilder_auth_token"):null}getEndpoint(){return this.endpoint}async createThread(t){const o=await fetch(`${this.endpoint}/threads`,{method:"POST",headers:{...this.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!o.ok)throw new Error(`Failed to create thread: ${o.statusText}`);return o.json()}async getThread(t){const o=await fetch(`${this.endpoint}/threads/${t}`,{method:"GET",headers:this.getHeaders()});if(!o.ok)throw new Error(`Failed to get thread: ${o.statusText}`);return o.json()}async getMessages(t,o={}){const a=new URLSearchParams;o.limit!==void 0&&a.set("limit",String(o.limit)),o.offset!==void 0&&a.set("offset",String(o.offset)),o.depth!==void 0&&a.set("depth",String(o.depth)),o.includeSilent!==void 0&&a.set("includeSilent",String(o.includeSilent));const i=a.toString(),l=`${this.endpoint}/threads/${t}/messages${i?`?${i}`:""}`,u=await fetch(l,{method:"GET",headers:this.getHeaders()});if(!u.ok)throw new Error(`Failed to get messages: ${u.statusText}`);return(await u.json()).messages||[]}async sendMessage(t,o){const a=await fetch(`${this.endpoint}/threads/${t}/messages`,{method:"POST",headers:{...this.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify(o)});if(!a.ok)throw new Error(`Failed to send message: ${a.statusText}`);return a.json()}async stopExecution(t){const o=await fetch(`${this.endpoint}/threads/${t}/stop`,{method:"POST",headers:this.getHeaders()});if(!o.ok)throw new Error(`Failed to stop execution: ${o.statusText}`);await o.json()}async deleteMessage(t,o){const a=await fetch(`${this.endpoint}/threads/${t}/messages/${o}`,{method:"DELETE",headers:this.getHeaders()});if(!a.ok)throw new Error(`Failed to delete message: ${a.statusText}`);return a.json()}async uploadFile(t,o,a){const i=encodeURIComponent(o.name),l=`${this.endpoint}/threads/${t}/fs/${i}`;if(a?.thumbnail){const s=await this.fileToBase64(o),m=await fetch(l,{method:"POST",headers:{...this.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify({data:s,mimeType:o.type,thumbnail:a.thumbnail,metadata:{width:a.width,height:a.height}})});if(!m.ok)throw new Error(`Failed to upload file: ${m.statusText}`);return m.json()}const u=await fetch(l,{method:"POST",headers:{...this.getHeaders(),"Content-Type":o.type},body:o});if(!u.ok)throw new Error(`Failed to upload file: ${u.statusText}`);return u.json()}fileToBase64(t){return new Promise((o,a)=>{const i=new FileReader;i.onload=()=>{const u=i.result.split(",")[1];o(u)},i.onerror=()=>a(new Error("Failed to read file")),i.readAsDataURL(t)})}getFileUrl(t,o){const i=(o.startsWith("/")?o.slice(1):o).split("/").map(l=>encodeURIComponent(l)).join("/");return`${this.endpoint}/threads/${t}/fs/${i}`}getThumbnailUrl(t,o){return`${this.getFileUrl(t,o)}?thumbnail=true`}async listFiles(t){const o=await fetch(`${this.endpoint}/threads/${t}/fs?find=**/*&type=file`,{method:"GET",headers:this.getHeaders()});if(!o.ok)throw new Error(`Failed to list files: ${o.statusText}`);return(await o.json()).files||[]}connectMessageWebSocket(t,o={},a={}){const i=new URLSearchParams;this.token&&i.set("token",this.token),a.includeSilent!==void 0&&i.set("includeSilent",String(a.includeSilent)),a.depth!==void 0&&i.set("depth",String(a.depth));const l=this.endpoint.startsWith("https")?"wss":"ws",s=`${this.endpoint.replace(/^https?/,l)}/threads/${t}/stream?${i.toString()}`,m=new WebSocket(s);return m.onopen=()=>{o.onOpen?.()},m.onmessage=h=>{try{if(typeof h.data=="string"&&h.data==="pong")return;const x=JSON.parse(h.data);switch(x.type){case"message_data":o.onMessage?.(x);break;case"message_chunk":o.onChunk?.(x);break;case"event":o.onEvent?.(x);break;case"error":o.onError?.(x);break}}catch(x){console.error("Failed to parse WebSocket message:",x)}},m.onerror=h=>{console.error("WebSocket error:",h),o.onError?.({type:"error",error:"WebSocket connection error"})},m.onclose=h=>{console.log(`[AgentBuilderClient] Message WebSocket closed - code: ${h.code}, reason: ${h.reason||"none"}, wasClean: ${h.wasClean}`),o.onClose?.()},m}connectLogWebSocket(t,o={}){const a=new URLSearchParams;this.token&&a.set("token",this.token);const i=this.endpoint.startsWith("https")?"wss":"ws",u=`${this.endpoint.replace(/^https?/,i)}/threads/${t}?${a.toString()}`,s=new WebSocket(u);return s.onopen=()=>{o.onOpen?.()},s.onmessage=m=>{try{if(typeof m.data=="string"&&m.data==="pong")return;const h=JSON.parse(m.data);switch(h.type){case"log_data":o.onLog?.(h);break;case"custom":o.onCustom?.(h);break;case"stopped_by_user":o.onStopped?.(h);break}}catch(h){console.error("Failed to parse WebSocket message:",h)}},s.onerror=m=>{console.error("WebSocket error:",m)},s.onclose=()=>{o.onClose?.()},s}getHeaders(){const t={};return this.token&&(t.Authorization=`Bearer ${this.token}`),t}},lo=class{client;threadId;callbacks;options;ws=null;status="disconnected";reconnectAttempts=0;reconnectTimeout=null;heartbeatInterval=null;isReconnecting=!1;shouldReconnect=!0;constructor(t,o,a={},i={}){this.client=t,this.threadId=o,this.callbacks=a,this.options={depth:i.depth??0,includeSilent:i.includeSilent??!1,heartbeatInterval:i.heartbeatInterval??3e4,maxReconnectDelay:i.maxReconnectDelay??3e4}}getStatus(){return this.status}getThreadId(){return this.threadId}connect(){this.ws&&this.ws.readyState!==WebSocket.CLOSED||(this.shouldReconnect=!0,this.isReconnecting=!1,this.setStatus("connecting"),this.ws=this.client.connectMessageWebSocket(this.threadId,{onOpen:()=>{this.setStatus("connected"),this.reconnectAttempts=0,this.isReconnecting=!1,this.startHeartbeat()},onMessage:t=>{this.callbacks.onMessage?.(t)},onChunk:t=>{this.callbacks.onChunk?.(t)},onEvent:t=>{this.callbacks.onEvent?.(t)},onError:t=>{this.callbacks.onError?.(t)},onClose:()=>{this.clearTimers(),this.scheduleReconnect()}},{depth:this.options.depth,includeSilent:this.options.includeSilent}))}disconnect(){this.shouldReconnect=!1,this.clearTimers(),this.ws&&(this.ws.close(),this.ws=null),this.reconnectAttempts=0,this.isReconnecting=!1,this.setStatus("disconnected")}updateCallbacks(t){this.callbacks={...this.callbacks,...t}}updateOptions(t){this.options={...this.options,...t}}setStatus(t){this.status!==t&&(this.status=t,this.callbacks.onStatusChange?.(t))}startHeartbeat(){this.clearHeartbeat(),this.heartbeatInterval=setInterval(()=>{this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send("ping")},this.options.heartbeatInterval)}clearHeartbeat(){this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}clearReconnectTimeout(){this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null)}clearTimers(){this.clearHeartbeat(),this.clearReconnectTimeout()}scheduleReconnect(){if(!this.shouldReconnect||this.isReconnecting){this.setStatus("disconnected");return}this.isReconnecting=!0,this.setStatus("reconnecting");const t=Math.min(1e3*Math.pow(2,this.reconnectAttempts),this.options.maxReconnectDelay);this.reconnectAttempts++,this.reconnectTimeout=setTimeout(()=>{this.shouldReconnect&&this.connect()},t)}};function nr(t){return t.toLowerCase().startsWith("image/")}var lr=256;function so(t){return new Promise((o,a)=>{const i=new Image,l=URL.createObjectURL(t);i.onload=()=>{URL.revokeObjectURL(l),o(i)},i.onerror=()=>{URL.revokeObjectURL(l),a(new Error("Failed to load image"))},i.src=l})}function io(t){const{width:o,height:a}=t,i=o/a;let l,u;i>1?(l=Math.min(lr,o),u=Math.floor(l/i)):(u=Math.min(lr,a),l=Math.floor(u*i));const s=document.createElement("canvas");s.width=l,s.height=u;const m=s.getContext("2d");if(!m)throw new Error("Failed to get canvas context");return m.drawImage(t,0,0,l,u),s.toDataURL("image/webp",.8).split(",")[1]}async function uo(t){const o=await so(t);return{thumbnail:io(o),width:o.width,height:o.height}}function co(){return`pending-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function po(t){return new Promise((o,a)=>{const i=new FileReader;i.onload=()=>o(i.result),i.onerror=a,i.readAsDataURL(t)})}var mo=class{createPendingFile(t){return{id:co(),name:t.name,mimeType:t.type,size:t.size,isImage:nr(t.type),localPreviewUrl:null,status:"uploading"}}queueFiles(t){return Array.from(t).map(o=>({pending:this.createPendingFile(o),file:o}))}async executeUpload(t,o,a,i,l,u={}){const{generateThumbnail:s=!0,generatePreview:m=!0}=u,h=nr(o.type);h&&m&&po(o).then(x=>l({localPreviewUrl:x})).catch(x=>console.error("Failed to generate preview:",x));try{let x;if(h&&s)try{const f=await uo(o);x={thumbnail:f.thumbnail,width:f.width,height:f.height}}catch(f){console.warn("Failed to generate thumbnail:",f)}const c=await i.uploadFile(t,o,x);return l({id:c.id,status:"ready",path:c.path,width:c.width,height:c.height}),c}catch(x){throw l({status:"error",error:x instanceof Error?x.message:"Failed to upload file"}),x}}async executeUploads(t,o,a,i,l={}){const u=o.map(({pending:s,file:m})=>this.executeUpload(t,m,s.id,a,h=>i(s.id,h),l).catch(h=>h instanceof Error?h:new Error(String(h))));return Promise.all(u)}};function vo(t){if(t.length===0)return[];const o=[];let a=0;for(;a<t.length;){const i=t[a];if(i.role==="assistant"&&i.tool_calls){let l;try{l=JSON.parse(i.tool_calls)}catch{o.push(i),a++;continue}const u=[],s=[],m=[];let h=i.reasoning_content||null,x="completed";const c=i.id,f=i.created_at,y=i.depth;i.status==="pending"?x="pending":i.status==="failed"&&(x="failed"),i.content&&s.push(i.content);for(const _ of l)u.push({id:_.id||i.id,type:"tool_call",name:_.function?.name,content:_.function?.arguments||null,status:null,tool_call_id:_.id});let b=a+1;for(;b<t.length;){const _=t[b];if(_.role==="tool"){const L=_.tool_status||"pending";if(u.push({id:_.id,type:"tool_result",name:_.name||void 0,content:_.content,status:L,tool_call_id:_.tool_call_id||void 0}),_.attachments)try{let R;typeof _.attachments=="string"?R=JSON.parse(_.attachments):Array.isArray(_.attachments)?R=_.attachments:R=[],m.push(...R)}catch{}b++}else if(_.role==="assistant"&&_.tool_calls){let L;try{L=JSON.parse(_.tool_calls)}catch{break}_.status==="pending"?x="pending":_.status==="failed"&&x!=="pending"&&(x="failed"),_.content&&s.push(_.content),!h&&_.reasoning_content&&(h=_.reasoning_content);for(const R of L)u.push({id:R.id||_.id,type:"tool_call",name:R.function?.name,content:R.function?.arguments||null,status:null,tool_call_id:R.id});b++}else break}const v=new Set(u.filter(_=>_.type==="tool_call").map(_=>_.tool_call_id)),d=u.filter(_=>_.type==="tool_result"&&_.tool_call_id&&!v.has(_.tool_call_id));for(const _ of d){const L=u.indexOf(_),R=_.content?.match(/Tool not found: (\w+)/)?.[1]||"unknown_tool",K={id:`synthetic-${_.tool_call_id}`,type:"tool_call",name:R,content:null,status:_.status,tool_call_id:_.tool_call_id};u.splice(L,0,K)}for(const _ of u)if(_.type==="tool_call"&&_.tool_call_id&&_.status===null){const L=u.find(R=>R.type==="tool_result"&&R.tool_call_id===_.tool_call_id);L?_.status=L.status:_.status="pending"}const k=s.length>0?s.join(""):null,g={id:c,type:"workblock",content:k,reasoning_content:h,workItems:u,status:x,created_at:f,depth:y,attachments:m.length>0?m:void 0};o.push(g),a=b}else o.push(i),a++}return o}var Or=Symbol("StandardAgents"),Rr=Symbol("Thread"),fo={install(t,o){if(!o?.endpoint)throw new Error("StandardAgentsPlugin requires an endpoint option");const i={client:new Dr(o.endpoint),endpoint:o.endpoint};t.provide(Or,i)}};function ho(){const t=$r(Or);if(!t)throw new Error("useStandardAgents must be used within a component where StandardAgentsPlugin is installed");return t}var sr=new mo;function go(t){return new Promise((o,a)=>{const i=new FileReader;i.onload=()=>{const u=i.result.split(",")[1];o(u)},i.onerror=()=>a(new Error("Failed to read file")),i.readAsDataURL(t)})}function bo(t,o={}){const{preload:a=!0,live:i=!0,useWorkblocks:l=!1,depth:u=0,includeSilent:s=!1,endpoint:m}=o,h=B(()=>ba(t)),x=ho(),c=m?new Dr(m):x.client,f={preload:a,live:i,useWorkblocks:l,depth:u,includeSilent:s},y=p([]),b=p("disconnected"),v=p(a),d=p(null),k=p([]),g=p([]),_=p([]),L=B(()=>{const A=new Set(g.value.map(ue=>ue.path));return[...k.value.filter(ue=>!ue.path||!A.has(ue.path)),...g.value]}),R=new Map;let K=null;const Y=B(()=>l?vo(y.value):y.value);async function z(){v.value=!0,d.value=null;try{const A=await c.getMessages(h.value,{depth:u,includeSilent:s});y.value=A}catch(A){d.value=A instanceof Error?A:new Error(String(A))}finally{v.value=!1}}async function P(){try{const A=await c.listFiles(h.value);g.value=A.filter(ce=>!ce.isDirectory).map(ce=>({id:ce.path,name:ce.name,path:ce.path,mimeType:ce.mimeType,size:ce.size,isImage:ce.mimeType.startsWith("image/"),status:"committed",localPreviewUrl:null}))}catch(A){console.error("Failed to load files:",A)}}function G(A){if(A.file.isDirectory)return;const ce={id:A.path,name:A.file.name,path:A.path,mimeType:A.file.mimeType,size:A.file.size,isImage:A.file.mimeType?.startsWith("image/")||!1,status:"committed",localPreviewUrl:null},ue=g.value.findIndex(ke=>ke.path===A.path);ue>=0?g.value[ue]=ce:g.value=[...g.value,ce]}function ee(A){if(A.file.isDirectory)return;const ce={id:A.path,name:A.file.name,path:A.path,mimeType:A.file.mimeType,size:A.file.size,isImage:A.file.mimeType?.startsWith("image/")||!1,status:"committed",localPreviewUrl:null},ue=g.value.findIndex(ke=>ke.path===A.path);ue>=0?g.value[ue]=ce:g.value=[...g.value,ce]}function se(A){g.value=g.value.filter(ce=>ce.path!==A.path)}function de(){i&&(K=new lo(c,h.value,{onStatusChange:A=>{b.value=A},onMessage:A=>{if(A.type==="message_data"){const ce=y.value.findIndex(ue=>ue.id===A.data.id);ce>=0?y.value[ce]=A.data:y.value=[...y.value,A.data]}},onChunk:A=>{const ce=y.value.findIndex(ue=>ue.id===A.message_id);if(ce>=0){const ue=y.value[ce];y.value[ce]={...ue,content:(ue.content||"")+A.chunk}}},onEvent:A=>{A.eventType==="file_created"?G(A.data):A.eventType==="file_updated"?ee(A.data):A.eventType==="file_deleted"&&se(A.data);const ce=R.get(A.eventType);ce&&ce.forEach(ue=>{try{ue(A.data)}catch(ke){console.error(`Error in event listener for "${A.eventType}":`,ke)}})},onError:A=>{d.value=A instanceof Error?A:new Error(String(A))}},{depth:u,includeSilent:s}),K.connect())}async function Q(A){const ce=`optimistic-${crypto.randomUUID()}`,ue=_.value.map(O=>({id:O.id,type:"file",path:"",name:O.name,mimeType:O.mimeType,size:O.size,width:O.width,height:O.height,localPreviewUrl:O.previewUrl||void 0})),ke={id:ce,role:A.role,content:A.content,attachments:ue.length>0?JSON.stringify(ue):null,created_at:Date.now()*1e3,status:"pending"};y.value=[...y.value,ke];const be=[..._.value];_.value=[];try{const O=await Promise.all(be.map(async j=>({name:j.name,mimeType:j.mimeType,data:await go(j.file),width:j.width,height:j.height}))),$=await c.sendMessage(h.value,{...A,attachments:O.length>0?O:void 0});return y.value=y.value.filter(j=>j.id!==ce),be.forEach(j=>{j.previewUrl&&URL.revokeObjectURL(j.previewUrl)}),$}catch(O){throw _.value=be,y.value=y.value.filter($=>$.id!==ce),d.value=O instanceof Error?O:new Error(String(O)),O}}async function E(){try{await c.stopExecution(h.value)}catch(A){throw d.value=A instanceof Error?A:new Error(String(A)),A}}async function S(A){const ce=[...y.value];y.value=y.value.filter(ue=>ue.id!==A);try{await c.deleteMessage(h.value,A)}catch(ue){throw y.value=ce,d.value=ue instanceof Error?ue:new Error(String(ue)),ue}}function V(A){const ce=sr.queueFiles(A);k.value=[...k.value,...ce.map(ue=>ue.pending)];for(const{pending:ue,file:ke}of ce)sr.executeUpload(h.value,ke,ue.id,c,be=>{k.value=k.value.map(O=>O.id===ue.id?{...O,...be}:O)}).catch(()=>{})}function re(A){k.value=k.value.filter(ce=>ce.id!==A)}function F(A){return A.path?c.getFileUrl(h.value,A.path):""}function q(A){return A.path?c.getThumbnailUrl(h.value,A.path):""}function N(A){return A.isImage?A.localPreviewUrl?A.localPreviewUrl:A.path?q(A):null:null}function J(A){const ue=(A instanceof FileList?Array.from(A):Array.isArray(A)?A:[A]).map(ke=>{const be=ke.type.startsWith("image/");return{id:crypto.randomUUID(),file:ke,name:ke.name,mimeType:ke.type,size:ke.size,isImage:be,previewUrl:be?URL.createObjectURL(ke):null}});_.value=[..._.value,...ue]}function U(A){const ce=_.value.find(ue=>ue.id===A);ce?.previewUrl&&URL.revokeObjectURL(ce.previewUrl),_.value=_.value.filter(ue=>ue.id!==A)}function W(){_.value.forEach(A=>{A.previewUrl&&URL.revokeObjectURL(A.previewUrl)}),_.value=[]}function M(A,ce){return R.has(A)||R.set(A,new Set),R.get(A).add(ce),()=>{const ue=R.get(A);ue&&(ue.delete(ce),ue.size===0&&R.delete(A))}}function ne(){K?.disconnect(),K=null,b.value="disconnected"}return ge(h,(A,ce)=>{A!==ce&&(ne(),y.value=[],d.value=null,k.value=[],g.value=[],_.value.forEach(ue=>{ue.previewUrl&&URL.revokeObjectURL(ue.previewUrl)}),_.value=[],a&&z(),P(),de())}),Pe(()=>{a&&z(),P(),de()}),Ye(()=>{K?.disconnect(),R.clear(),_.value.forEach(A=>{A.previewUrl&&URL.revokeObjectURL(A.previewUrl)})}),{threadId:h,options:f,messages:y,workblocks:Y,status:b,connectionStatus:b,isLoading:v,loading:v,error:d,sendMessage:Q,stopExecution:E,deleteMessage:S,onEvent:M,subscribeToEvent:M,files:L,addFiles:V,removeFile:re,getFileUrl:F,getThumbnailUrl:q,getPreviewUrl:N,attachments:_,addAttachment:J,removeAttachment:U,clearAttachments:W}}var xo=me({name:"ThreadProvider",props:{threadId:{type:String,required:!0},preload:{type:Boolean,default:void 0},live:{type:Boolean,default:void 0},useWorkblocks:{type:Boolean,default:void 0},depth:{type:Number,default:void 0},includeSilent:{type:Boolean,default:void 0},endpoint:{type:String,default:void 0}},setup(t,{slots:o}){const a={};t.preload!==void 0&&(a.preload=t.preload),t.live!==void 0&&(a.live=t.live),t.useWorkblocks!==void 0&&(a.useWorkblocks=t.useWorkblocks),t.depth!==void 0&&(a.depth=t.depth),t.includeSilent!==void 0&&(a.includeSilent=t.includeSilent),t.endpoint!==void 0&&(a.endpoint=t.endpoint);const i=bo(()=>t.threadId,a);return xa(Rr,i),()=>o.default?.()}});function Ur(){const t=$r(Rr);if(!t)throw new Error('useThread must be used within a <ThreadProvider>. Wrap your component with <ThreadProvider threadId="...">.');return t}function yo(t,o){const a=`${o.props.type}__${t}`,i=`formkit-${t}`,l=o.props.family?`family:${o.props.family}__${t}`:"",u=`${a}__${l}`;if(!(u in dt)){const s=dt[a]??ko[t]??{};s[i]=!0,l in dt?dt[u]={...dt[l],...s}:dt[u]=s}return dt[u]??{[i]:!0}}const dt={"family:button__wrapper":{"group-data-[disabled=true]:grayscale":!0},"family:button__input":{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"font-bold":!0,"rounded-sm":!0,"outline-hidden":!0,flex:!0,"!text-xs":!0,"px-7":!0,"py-3":!0,"items-center":!0,"mb-1.5":!0,"text-xs":!0,"ring-accent-400":!0,"focus-visible:ring-2":!0,"focus-visible:ring-offset-2":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"shadow-none":!0,"group-data-[prefix-icon]:pl-5":!0,"group-data-[suffix-icon]:pr-5":!0,border:!0,"border-accent-500":!0,"text-accent-500":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"dark:border-accent-500":!0},"family:box__wrapper":{"inline-flex":!0,"items-center":!0,"mb-1":!0,"group-data-[multiple]:mb-0":!0},"family:box__legend":{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"dark:text-zinc-300":!0,"mb-2":!0},"family:box__input":{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,peer:!0,"pointer-events-none":!0,absolute:!0,"h-0":!0,"w-0":!0,"overflow-hidden":!0,"opacity-0":!0},"family:box__decorator":{"mr-1.5":!0,"bg-white":!0,"ring-accent-400":!0,"peer-checked:border-accent-500":!0,relative:!0,block:!0,"text-base":!0,"w-[1em]":!0,"aspect-[1/1]":!0,border:!0,"border-zinc-300":!0,"text-transparent":!0,"peer-checked:bg-accent-50":!0,"peer-checked:text-accent-500":!0,"peer-focus-visible:ring-2":!0,"peer-focus-visible:ring-offset-1":!0,"select-none":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"peer-disabled:bg-zinc-100":!0,"group-data-[disabled]:grayscale":!0,"shadow-none":!0,"peer-disabled:cursor-not-allowed":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"dark:border-zinc-700":!0,"dark:bg-transparent":!0,"dark:ring-offset-accent-400":!0,"dark:peer-focus-visible:ring-1":!0,"dark:peer-disabled:bg-zinc-600/50":!0,"dark:peer-checked:bg-accent-800":!0,"dark:peer-checked:text-accent-300":!0},"family:box__decoratorIcon":{absolute:!0,"left-1/2":!0,"top-1/2":!0,flex:!0,"h-full":!0,"w-full":!0,"-translate-x-1/2":!0,"-translate-y-1/2":!0},"family:box__option":{"mb-1.5":!0,"last:mb-0":!0,"data-[disabled]:opacity-50":!0,"data-[disabled]:select-none":!0,"group-data-[disabled]:data-[disabled]:opacity-100":!0},"family:box__label":{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"mb-1":!0,"!mb-0":!0,"!font-normal":!0,"!text-sm":!0,"dark:text-zinc-300":!0},"family:box__optionHelp":{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"-mt-1":!0,"mb-1.5":!0,"ml-[min(2em,1.7rem)]":!0,relative:!0,"left-px":!0},"family:box__help":{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-zinc-400":!0,"mb-1":!0,"group-data-[multiple]:mb-2":!0,"group-data-[multiple]:-mt-1.5":!0},"family:text__wrapper":{flex:!0,"flex-col":!0,"items-start":!0,"justify-start":!0,"mb-1.5":!0,"last:mb-0":!0},"family:text__label":{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"dark:text-zinc-300":!0,"!inline-flex":!0,"mb-1":!0},"family:text__inner":{"text-sm":!0,flex:!0,"items-center":!0,"w-full":!0,"py-2":!0,"px-3":!0,"rounded-sm":!0,border:!0,"border-zinc-300":!0,"bg-white":!0,"focus-within:ring-1":!0,"focus-within:!ring-accent-400":!0,"focus-within:!border-accent-400":!0,"group-data-[invalid]:border-red-400":!0,"group-data-[invalid]:ring-1":!0,"group-data-[invalid]:ring-red-400":!0,"group-data-[disabled]:bg-zinc-100":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"shadow-none":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"dark:bg-transparent":!0,"dark:border-zinc-700":!0,"dark:group-data-[disabled]:bg-zinc-800/5":!0,"dark:group-data-[invalid]:border-red-400":!0,"dark:group-data-[invalid]:ring-red-400":!0},"family:text__input":{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"text-sm":!0,"text-zinc-700":!0,"min-w-0":!0,"min-h-[1.5em]":!0,grow:!0,"outline-hidden":!0,"bg-transparent":!0,"selection:bg-accent-100":!0,"placeholder:text-zinc-400":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"dark:placeholder-zinc-400/50":!0,"dark:text-zinc-300":!0,"border-none":!0,"p-0":!0,"focus:ring-0":!0},"family:text__prefixIcon":{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},"family:text__suffixIcon":{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},"family:dropdown__wrapper":{"mb-1.5":!0},"family:dropdown__inner":{relative:!0,flex:!0,"items-center":!0,"w-full":!0,"py-2":!0,"px-3":!0,"text-sm":!0,"bg-white":!0,border:!0,"border-zinc-300":!0,"rounded-sm":!0,"group-data-[is-multiline]:!rounded-sm":!0,"focus-within:ring-1":!0,"focus-within:!ring-accent-400":!0,"focus-within:!border-accent-400":!0,"group-data-[invalid]:border-red-400":!0,"group-data-[invalid]:ring-1":!0,"group-data-[invalid]:ring-red-400":!0,"group-data-[disabled]:bg-zinc-100":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"shadow-none":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"dark:bg-transparent":!0,"dark:border-zinc-700":!0,"dark:group-data-[disabled]:bg-zinc-700/40":!0,"dark:group-data-[invalid]:border-red-400":!0,"dark:group-data-[invalid]:ring-red-400":!0},"family:dropdown__input":{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,grow:!0,"p-2":!0,"pr-0":!0,"pl-3":!0,"text-sm":!0,"text-zinc-700":!0,"text-ellipsis":!0,"min-w-0":!0,"outline-hidden":!0,"bg-transparent":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"group-data-[prefix-icon]:!pl-0":!0,"group-data-[suffix-icon]:!pr-0":!0,"placeholder:text-zinc-400":!0,"selection:bg-accent-100":!0,"dark:placeholder:text-zinc-500":!0,"dark:text-zinc-300":!0,"border-none":!0,"focus:ring-0":!0,"bg-none":!0},"family:dropdown__listboxButton":{"w-[2.5em]":!0,"self-stretch":!0,"text-sm":!0,flex:!0,"items-center":!0,"text-zinc-700":!0,"z-10":!0,"dark:text-zinc-300":!0,"data-[disabled]:cursor-not-allowed":!0},"family:dropdown__removeSelection":{"w-[2.5em]":!0,"self-stretch":!0,"text-sm":!0,flex:!0,"items-center":!0,"text-zinc-700":!0,"hover:text-red-400":!0,"z-10":!0,"dark:text-zinc-300":!0},"family:dropdown__controlLabel":{absolute:!0,"opacity-0":!0,"pointer-events-none":!0,"text-[0px]":!0},"family:dropdown__selectIcon":{"text-sm":!0,"inline-flex":!0,"justify-center":!0,"w-[2.5em]":!0,relative:!0,"my-auto":!0,"[&>svg]:w-[1em]":!0,"[&>svg]:mx-auto":!0},"family:dropdown__closeIcon":{"text-sm":!0,"w-[0.75em]":!0,relative:!0,"m-auto":!0},"family:dropdown__prefixIcon":{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"!ml-2":!0,"!mr-0":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},"family:dropdown__suffixIcon":{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"!mr-2":!0,"!ml-0":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},"family:dropdown__dropdownWrapper":{"rounded-sm":!0,"shadow-md":!0,"mt-1":!0,"overflow-clip":!0,"empty:hidden":!0,border:!0,"border-zinc-200":!0,"dark:border-zinc-700":!0,"group-data-[expanded]:opacity-100":!0,"group-data-[overscroll]:m-0":!0,"group-data-[overscroll]:shadow-none":!0,"group-data-[overscroll]:border-none":!0},"family:dropdown__listitemGroup":{"group/optgroup":!0,"last:pb-0":!0,"border-t":!0,"border-b":!0,"-mb-px":!0,"border-zinc-200":!0,"dark:border-zinc-700":!0},"family:dropdown__groupLabel":{block:!0,"pt-1.5":!0,"pb-1":!0,"px-2.5":!0,"font-bold":!0,"pointer-events-none":!0,"text-zinc-500":!0,"dark:text-zinc-500":!0},"family:dropdown__listbox":{"bg-white":!0,"rounded-sm":!0,"empty:hidden":!0,"dark:bg-zinc-800":!0,"group-data-[overscroll]:shadow-md":!0,"group-data-[overscroll]:border":!0,"group-data-[overscroll]:border-zinc-200":!0,"group-data-[overscroll]:dark:border-zinc-700":!0},"family:dropdown__listitem":{relative:!0,flex:!0,"items-center":!0,"px-2":!0,"py-1.5":!0,"first:pt-2":!0,"last:pb-2":!0,"text-zinc-700":!0,"text-sm":!0,"data-[is-active]:bg-accent-100":!0,"dark:text-zinc-200":!0,"dark:data-[is-active]:text-zinc-700":!0,"before:content-['']":!0,"before:absolute":!0,"before:inset-0":!0,"data-[is-active]:first:before:rounded-sm":!0,"data-[is-active]:first:before:rounded-b-none":!0,"data-[is-active]:last:before:rounded-sm":!0,"data-[is-active]:last:before:rounded-t-none":!0,"data-[is-active]:first:last:before:rounded-sm":!0,"data-[is-active]:before:ring-1":!0,"data-[is-active]:before:ring-accent-400":!0,"data-[is-active]:before:ring-inset":!0,"data-[is-active]:before:ring-offset-accent-100":!0,"group-[&]/optgroup:first:before:!rounded-none":!0,"group-[&]/optgroup:last:before:!rounded-none":!0},"family:dropdown__selectedIcon":{flex:!0,absolute:!0,"items-center":!0,"text-accent-500":!0,"left-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0},"family:dropdown__option":{"ml-[1.5em]":!0},"family:dropdown__loadMore":{"data-[is-active]:bg-accent-100":!0},"family:dropdown__loadMoreInner":{flex:!0,"text-xs":!0,"text-zinc-500":!0,"p-2":!0,"items-center":!0,"justify-center":!0,"[&>span]:mr-2":!0,"cursor-pointer":!0,"dark:text-zinc-200":!0,"dark:hover:text-accent-400":!0},"family:dropdown__selectionWrapper":{grow:!0,flex:!0,"items-center":!0,"text-zinc-700":!0},"family:dropdown__selection":{grow:!0,"text-zinc-700":!0,"group-data-[multiple]:p-2":!0,"dark:text-zinc-300":!0},"family:dropdown__tagsWrapper":{"w-full":!0},"family:dropdown__tagWrapper":{"group/tag":!0,"rounded-sm":!0,"mr-1":!0,"mb-1":!0,"outline-hidden":!0,"data-[active-selection=true]:ring-2":!0,"data-[active-selection=true]:ring-accent-400":!0},"family:dropdown__tags":{"inline-flex":!0,"flex-wrap":!0,"items-center":!0,"w-full":!0,"-mb-1":!0,"empty:mb-0":!0},"family:dropdown__tag":{flex:!0,"items-center":!0,"cursor-default":!0,"rounded-sm":!0,"text-xs":!0,"px-1.5":!0,"py-0.5":!0,"bg-accent-500":!0,"text-white":!0,"[&>[type=button]]:!w-[0.5em]":!0,"[&>[type=button]]:aspect-[1/1]":!0,"[&>[type=button]]:!text-inherit":!0,"[&>[type=button]]:cursor-pointer":!0,"group-data-[active-selection=true]/tag:bg-accent-300":!0,"group-data-[active-selection=true]/tag:text-zinc-700":!0},"family:dropdown__tagLabel":{"mr-1":!0},"family:dropdown__emptyMessage":{flex:!0,"items-center":!0,"px-2":!0,"py-1.5":!0,"first:pt-2":!0,"last:pb-2":!0,"text-zinc-700":!0,"text-xs":!0,"aria-selected:text-white":!0,"aria-selected:bg-accent-500":!0},button__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"bg-accent-50":!0,"hover:bg-accent-100":!0,"dark:text-accent-500":!0,"dark:bg-transparent":!0,"dark:hover:bg-accent-50/5":!0},checkbox__decorator:{"rounded-sm":!0},checkbox__decoratorIcon:{"max-w-[66.66%]":!0},color__inner:{"!w-auto":!0,"!p-1.5":!0,"!inline-flex":!0,"group-data-[prefix-icon]:border":!0,"group-data-[prefix-icon]:border-zinc-300":!0,"group-data-[suffix-icon]:border":!0,"group-data-[suffix-icon]:border-zinc-300":!0,"dark:group-data-[prefix-icon]:border-zinc-700":!0,"dark:group-data-[suffix-icon]:border-zinc-700":!0},color__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"!w-14":!0,"bg-transparent":!0,"cursor-pointer":!0,"rounded-sm":!0,"overflow-clip":!0,"[&::-webkit-color-swatch-wrapper]:p-0":!0,"[&::-webkit-color-swatch]:border-none":!0,"[&::-moz-color-swatch]:border-none":!0,"group-data-[prefix-icon]:mx-2":!0,"group-data-[suffix-icon]:mx-2":!0},color__prefixIcon:{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"group-data-[prefix-icon]:m-1.5":!0,"group-data-[prefix-icon]:mr-0":!0},color__suffixIcon:{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"group-data-[suffix-icon]:m-1.5":!0,"group-data-[prefix-icon]:ml-0":!0},date__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"focus:[&::-webkit-datetime-edit-day-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-month-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-year-field]:bg-accent-100":!0},"datetime-local__input":{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"focus:[&::-webkit-datetime-edit-day-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-month-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-year-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-hour-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-minute-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-ampm-field]:bg-accent-100":!0},file__fileList:{"group/list":!0,peer:!0,"w-full":!0,"min-w-0":!0,"data-[has-multiple]:mb-[1.25em]":!0},file__fileItemIcon:{"h-[1em]":!0,"w-[1em]":!0,"mr-2":!0,"shrink-0":!0},file__fileItem:{flex:!0,"min-w-0":!0,"items-center":!0,"text-zinc-700":!0,"mb-1.5":!0,"last:mb-0":!0,"dark:text-zinc-300":!0},file__fileName:{truncate:!0,"min-w-0":!0,"w-full":!0,shrink:!0,"leading-5":!0,"group-data-[has-multiple]/list:text-xs":!0},file__fileRemove:{"right-2":!0,"ring-accent-400":!0,"rounded-sm":!0,"z-20":!0,flex:!0,"appearance-none":!0,"items-center":!0,"text-[0px]":!0,"outline-hidden":!0,"hover:!text-red-400":!0,"focus-visible:ring-2":!0,"group-data-[disabled]:pointer-events-none":!0,"group-data-[disabled]:!text-zinc-500":!0,"peer-data-[has-multiple]:absolute":!0,"peer-data-[has-multiple]:bottom-[max(0.5em,8px)]":!0,"peer-data-[has-multiple]:left-3":!0,"peer-data-[has-multiple]:text-accent-500":!0,"peer-data-[has-multiple]:text-[11px]":!0,"[line-height:1em]":!0,"peer-data-[has-multiple]:whitespace-nowrap":!0,"group-data-[prefix-icon]:peer-data-[has-multiple]:left-2":!0,"dark:hover:!text-red-400":!0},file__fileRemoveIcon:{block:!0,"text-base":!0,"w-[0.75em]":!0,relative:!0,"z-10":!0},file__inner:{relative:!0,"cursor-pointer":!0,"group-data-[has-multiple]:rounded-sm":!0},file__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"cursor-pointer":!0,"text-transparent":!0,absolute:!0,"inset-0":!0,"opacity-0":!0,"z-10":!0,"file:pointer-events-none":!0,"file:w-0":!0,"file:h-0":!0,"file:overflow-hidden":!0},file__noFiles:{flex:!0,"w-full":!0,"items-center":!0,"text-zinc-400":!0,"dark:text-zinc-500":!0},file__noFilesIcon:{"w-[1em]":!0,"mr-2":!0},form__form:{"group/form":!0},form__actions:{"":!0},form__summaryInner:{"group/summary":!0,border:!0,"border-zinc-300":!0,"bg-white":!0,"rounded-sm":!0,"py-2":!0,"px-3":!0,"shadow-none":!0,"dark:bg-transparent":!0,"dark:border-zinc-700":!0},form__summaryHeader:{"text-base":!0,"text-zinc-700":!0,"font-bold":!0,"mb-2":!0,"dark:text-zinc-300":!0},form__messages:{"":!0},form__message:{"text-red-500":!0,"mb-1.5":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-red-400":!0,"group-[&]/summary:text-xs":!0},form__messageLink:{"group-[&]/summary:outline-hidden":!0,"group-[&]/summary:focus-visible:ring-2":!0,"group-[&]/summary:ring-accent-500":!0},month__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"focus:[&::-webkit-datetime-edit-month-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-year-field]:bg-accent-100":!0},radio__decorator:{"rounded-full":!0},radio__decoratorIcon:{"max-w-[50%]":!0},range__inner:{relative:!0,"!border-none":!0,"!ring-0":!0,"!px-0":!0,"!bg-transparent":!0,"!shadow-none":!0},range__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"group/input":!0,"cursor-pointer":!0,"[&::-webkit-slider-runnable-track]:bg-zinc-300/50":!0,"[&::-webkit-slider-runnable-track]:h-[0.25em]":!0,"[&::-webkit-slider-runnable-track]:rounded-sm":!0,"dark:[&::-webkit-slider-runnable-track]:bg-zinc-600/50":!0,"[&::-webkit-slider-thumb]:appearance-none":!0,"[&::-webkit-slider-thumb]:w-[0.85em]":!0,"[&::-webkit-slider-thumb]:aspect-[1/1]":!0,"[&::-webkit-slider-thumb]:bg-accent-500":!0,"[&::-webkit-slider-thumb]:rounded-full":!0,"[&::-webkit-slider-thumb]:relative":!0,"[&::-webkit-slider-thumb]:top-1/2":!0,"[&::-webkit-slider-thumb]:-translate-y-1/2":!0,"[&::-webkit-slider-thumb]:group-data-[disabled]:bg-zinc-500":!0,"[&::-webkit-slider-thumb]:group-data-[disabled]:!ring-zinc-200":!0,"[&::-webkit-slider-thumb]:focus-visible:ring-2":!0,"[&::-webkit-slider-thumb]:focus:!ring-accent-400":!0,"[&::-webkit-slider-thumb]:focus:ring-offset-2":!0,"[&::-webkit-slider-thumb]:shadow-none":!0,"dark:[&::-webkit-slider-thumb]:group-data-[disabled]:!ring-zinc-700":!0,"dark:[&::-webkit-slider-thumb]:focus:ring-offset-zinc-700":!0,"[&::-moz-range-track]:bg-zinc-300/50":!0,"[&::-moz-range-track]:h-[0.25]":!0,"[&::-moz-range-track]:rounded-sm":!0,"dark:[&::-moz-range-track]:bg-zinc-600/50":!0,"[&::-moz-range-thumb]:appearance-none":!0,"[&::-moz-range-thumb]:border-none":!0,"[&::-moz-range-thumb]:w-[0.85em]":!0,"[&::-moz-range-thumb]:h-[0.85em]":!0,"[&::-moz-range-thumb]:bg-accent-500":!0,"[&::-moz-range-thumb]:rounded-full":!0,"[&::-moz-range-thumb]:group-data-[disabled]:bg-zinc-500":!0,"[&::-moz-range-thumb]:group-data-[disabled]:!ring-zinc-300":!0,"[&::-moz-range-thumb]:focus-visible:ring-2":!0,"[&::-moz-range-thumb]:focus:!ring-accent-400":!0,"[&::-moz-range-thumb]:focus:ring-offset-2":!0,"[&::-moz-range-thumb]:shadow-none":!0,"dark:[&::-moz-range-thumb]:group-data-[disabled]:!ring-zinc-500":!0,"dark:[&::-moz-range-thumb]:focus:ring-offset-zinc-700":!0},select__wrapper:{"mb-1.5":!0},select__inner:{relative:!0,flex:!0,"items-center":!0,"bg-white":!0,border:!0,"border-zinc-300":!0,"rounded-sm":!0,"focus-within:ring-1":!0,"focus-within:!ring-accent-400":!0,"focus-within:!border-accent-400":!0,"group-data-[invalid]:border-red-400":!0,"group-data-[invalid]:ring-1":!0,"group-data-[invalid]:ring-red-400":!0,"group-data-[disabled]:bg-zinc-100":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"shadow-none":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"group-data-[multiple]:rounded-sm":!0,"dark:bg-transparent":!0,"dark:border-zinc-700":!0,"dark:group-data-[disabled]:bg-zinc-800/5":!0,"dark:group-data-[invalid]:border-red-400":!0,"dark:group-data-[invalid]:ring-red-400":!0},select__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,grow:!0,"p-2":!0,"py-2":!0,"px-3":!0,"pr-[2em]":!0,"text-sm":!0,"text-zinc-700":!0,"text-ellipsis":!0,"min-w-0":!0,"outline-hidden":!0,"bg-transparent":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"group-data-[prefix-icon]:!pl-0":!0,"group-data-[suffix-icon]:!pr-0":!0,"data-[placeholder]:text-zinc-400":!0,"group-data-[multiple]:!p-0":!0,"selection:bg-accent-100":!0,"dark:data-[placeholder]:text-zinc-400/50":!0,"dark:text-zinc-300":!0,"border-none":!0,"focus:ring-0":!0,"bg-none":!0},select__selectIcon:{absolute:!0,"w-[1em]":!0,"text-zinc-700":!0,"pointer-events-none":!0,"right-2":!0,"group-data-[suffix-icon]:mr-[1.5em]":!0,"dark:text-zinc-300":!0},select__optGroup:{"bg-white":!0,"text-zinc-700":!0,"group/optgroup":!0,"group-data-[multiple]:px-1.5":!0,"pt-1.5":!0,"font-bold":!0,"text-xs":!0,"dark:bg-zinc-800":!0,"dark:text-zinc-300":!0},select__option:{"bg-white":!0,"text-zinc-700":!0,"group-data-[disabled]:opacity-50":!0,"group-data-[disabled]:select-none":!0,"group-data-[multiple]:checked:bg-accent-100":!0,"group-data-[multiple]:focus:bg-accent-100":!0,"group-data-[multiple]:text-xs":!0,"group-data-[multiple]:outline-hidden":!0,"group-data-[multiple]:border-none":!0,"group-data-[multiple]:py-1.5":!0,"group-data-[multiple]:px-2":!0,"dark:bg-zinc-800":!0,"dark:text-zinc-300":!0,"dark:group-data-[multiple]:focus:bg-accent-700":!0,"dark:group-data-[multiple]:checked:bg-accent-700":!0},select__prefixIcon:{flex:!0,"items-center":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"ml-2":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},select__suffixIcon:{flex:!0,"items-center":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"mr-2":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},submit__outer:{group:!0,"max-w-none":!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"text-sm":!0,"data-[disabled]:opacity-100":!0},submit__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"bg-accent-500":!0,"!text-white":!0,"active:text-accent-100":!0,"active:bg-accent-600":!0,"hover:bg-accent-600":!0,"disabled:border-zinc-300":!0,"disabled:bg-zinc-400":!0,"disabled:text-zinc-100":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"dark:disabled:border-zinc-100":!0,"dark:disabled:bg-zinc-500":!0,"dark:disabled:text-zinc-200":!0,"dark:text-white":!0,"dark:ring-offset-accent-400":!0,"before:transition-all":!0,"group-data-[loading=true]/form:before:content['']":!0,"group-data-[loading=true]/form:before:block":!0,"group-data-[loading=true]/form:before:animate-spin":!0,"group-data-[loading=true]/form:before:w-5":!0,"group-data-[loading=true]/form:before:h-5":!0,"group-data-[loading=true]/form:before:rounded-full":!0,"group-data-[loading=true]/form:before:mr-3":!0,"group-data-[loading=true]/form:before:-ml-1.5":!0,"group-data-[loading=true]/form:before:border-2":!0,"group-data-[loading=true]/form:before:border-solid":!0,"group-data-[loading=true]/form:before:border-white":!0,"group-data-[loading=true]/form:before:border-r-transparent":!0},submit__prefixIcon:{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"text-zinc-100":!0},submit__suffixIcon:{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"text-zinc-100":!0},textarea__inner:{flex:!0,"items-center":!0,"mb-1.5":!0,"bg-white":!0,border:!0,"border-zinc-300":!0,"rounded-sm":!0,"focus-within:ring-1":!0,"focus-within:!ring-accent-400":!0,"focus-within:!border-accent-400":!0,"group-data-[invalid]:border-red-400":!0,"group-data-[invalid]:ring-1":!0,"group-data-[invalid]:ring-red-400":!0,"group-data-[disabled]:bg-zinc-100":!0,"shadow-none":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"dark:border-zinc-700":!0,"dark:group-data-[disabled]:bg-zinc-800/5":!0,"dark:group-data-[invalid]:border-red-400":!0,"dark:group-data-[invalid]:ring-red-400":!0,"dark:bg-transparent":!0},textarea__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"text-sm":!0,"h-24":!0,"text-zinc-700":!0,"min-w-0":!0,grow:!0,shrink:!0,"!py-2":!0,"!px-3":!0,"outline-hidden":!0,"bg-transparent":!0,"selection:bg-accent-100":!0,"placeholder:text-zinc-400":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"dark:placeholder-zinc-400/50":!0,"dark:text-zinc-300":!0,"p-0":!0,"border-none":!0,"focus:ring-0":!0},textarea__prefixIcon:{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"!ml-2":!0,"!mr-0":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},textarea__suffixIcon:{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"!mr-2":!0,"!ml-0":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},time__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"focus:[&::-webkit-datetime-edit-hour-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-minute-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-ampm-field]:bg-accent-100":!0},week__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"focus:[&::-webkit-datetime-edit-week-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-year-field]:bg-accent-100":!0},autocomplete__selections:{flex:!0,absolute:!0,"inset-0":!0,"group-data-[multiple]:static":!0,"group-data-[multiple]:block":!0,"group-data-[empty]:hidden":!0,"group-data-[multiple]:mt-1.5":!0},autocomplete__selectionWrapper:{"bg-zinc-100":!0,"rounded-sm":!0,"group-data-[multiple]:border":!0,"group-data-[multiple]:border-zinc-200":!0,"group-data-[multiple]:mb-1.5":!0,"outline-hidden":!0,"data-[active-selection=true]:ring-2":!0,"data-[active-selection=true]:ring-accent-400":!0,"dark:bg-zinc-600":!0,"dark:group-data-[multiple]:border-zinc-700":!0,"[&.formkit-dropZone]:opacity-25":!0,"[&.formkit-touchDropZone]:opacity-25":!0,"[&.formkit-touchDragging]:!flex":!0,"[&.formkit-longTouch]:opacity-25":!0},autocomplete__selection:{"rounded-sm":!0,just:!0,"pl-2":!0,"[&>*]:ml-0":!0,"dark:text-zinc-200":!0},colorpicker__outer:{group:!0,"max-w-none":!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"data-[disabled]:opacity-50":!0,"text-sm":!0,"data-[disabled]:cursor-not-allowed":!0,"data-[disabled]:pointer-events-none":!0},colorpicker__help:{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-zinc-400":!0,"group-data-[inline]:-mt-1":!0,"group-data-[inline]:mb-2":!0},colorpicker__inner:{relative:!0,"inline-flex":!0,"!w-auto":!0,"pl-2":!0,"group-data-[inline]:border-none":!0,"group-data-[inline]:shadow-none":!0,"group-data-[inline]:p-0":!0,"group-data-[inline]:bg-transparent":!0,"group-data-[inline]:outline-hidden":!0,"group-data-[inline]:!ring-0":!0,"group-data-[inline]:!w-full":!0,"group-data-[inline]:rounded-sm":!0},colorpicker__swatchPreview:{"w-full":!0,flex:!0,"justify-start":!0,"items-center":!0,"rounded-sm":!0,"text-sm":!0,"cursor-pointer":!0,"outline-hidden":!0},colorpicker__canvasSwatchPreviewWrapper:{relative:!0,"before:content-['']":!0,"before:absolute":!0,"before:inset-0":!0,"before:rounded-sm":!0,"before:shadow-[inset_0_0_0_1px_rgba(0,0,0,0.2)]":!0,"before:z-[2]":!0},colorpicker__canvasSwatchPreview:{"text-sm":!0,"rounded-sm":!0,"aspect-[1/1]":!0,"shrink-0":!0,grow:!0,"!w-[1.5em]":!0},colorpicker__valueString:{"text-sm":!0,"text-zinc-700":!0,"selection:bg-accent-100":!0,"font-mono":!0,"inline-block":!0,"ml-2":!0,"mr-1.5":!0,"dark:text-zinc-300":!0,"dark:selection:text-zinc-700":!0},colorpicker__panel:{absolute:!0,"left-0":!0,"top-full":!0,"z-[99]":!0,flex:!0,"w-[100vw]":!0,"max-w-[18.5em]":!0,"touch-manipulation":!0,"flex-col":!0,"rounded-sm":!0,border:!0,"bg-white":!0,"p-2":!0,"shadow-xs":!0,"group-data-[inline]:static":!0,"group-data-[inline]:max-w-none":!0,"border-zinc-300":!0,"group-data-[inline]:z-auto":!0,"group-data-[inline]:w-full":!0,"group-data-[inline]:shadow-none":!0,"group-data-[inline]:group-data-[disabled]:!cursor-not-allowed":!0,"group-data-[inline]:group-data-[disabled]:!pointer-events-none":!0,"group-data-[inline]:[&:has([id^=swatches]:first-child:last-child)]:w-auto":!0,"group-data-[inline]:[&:has([id^=swatches]:first-child:last-child)_[id^=swatches]>div]:w-[1.5em]":!0,"dark:bg-zinc-800":!0,"dark:border-zinc-700":!0,"dark:group-data-[inline]:bg-transparent":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:!fixed":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:top-auto":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:max-w-none":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:bottom-0":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:left-0":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:rounded-none":!0},colorpicker__panelClose:{flex:!0,"justify-end":!0,"items-center":!0,"text-zinc-600":!0,"mb-1.5":!0,"-mt-1":!0,"border-none":!0,"bg-none":!0,"border-b":!0,"border-zinc-200":!0,"w-[calc(100%+1rem)]":!0,"-ml-2":!0,"pt-0":!0,"pr-2":!0,"pb-1.5":!0,"pl-2":!0,"dark:border-zinc-800":!0},colorpicker__closeIcon:{"w-[2rem]":!0,"aspect-[1/1]":!0,"p-1":!0,"rounded-sm":!0,border:!0,"[&>svg]:w-full":!0,"[&>svg]:aspect-[1/1]":!0,"[&>svg]:max-w-none":!0,"[&>svg]:max-h-none":!0},colorpicker__controlGroup:{grid:!0,"[grid-template-areas:'a_a_a'_'b_c_e'_'b_d_e']":!0,"mb-2":!0},colorpicker__LS:{"[grid-area:a]":!0,relative:!0,"mb-2":!0},colorpicker__canvas:{block:!0,"w-full":!0},colorpicker__canvasLS:{"aspect-[2/1]":!0,"cursor-pointer":!0,"rounded-xs":!0},colorpicker__canvasHue:{"rounded-xs":!0},colorpicker__canvasAlpha:{"rounded-xs":!0},colorpicker__preview:{"rounded-sm":!0,"after:rounded-sm":!0,relative:!0,"inline-flex":!0,"aspect-[1/1]":!0,"overflow-hidden":!0,"[grid-area:b]":!0,"mr-2":!0,"after:absolute":!0,"after:left-0":!0,"after:top-0":!0,"after:h-full":!0,"after:w-full":!0,"after:shadow-[inset_0_0_0_1px_rgba(0,0,0,0.2)]":!0,"after:content-['']":!0,"w-[2em]":!0,"dark:after:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.25)]":!0},colorpicker__hue:{"[grid-area:c]":!0,relative:!0,"inline-flex":!0,"h-3/4":!0},colorpicker__alpha:{"[grid-area:d]":!0,relative:!0,"inline-flex":!0,"h-3/4":!0},colorpicker__eyeDropper:{"[grid-area:e]":!0,"w-[2em]":!0,"ml-2":!0,"inline-flex":!0,"self-center":!0,"justify-center":!0,"justify-self-center":!0,"aspect-[1/1]":!0,"rounded-sm":!0,border:!0,"border-zinc-200":!0,"cursor-pointer":!0,"content-center":!0,"items-center":!0,"text-zinc-600":!0,"dark:border-zinc-800":!0},colorpicker__eyeDropperIcon:{"w-auto":!0,"[&>svg]:w-[1em]":!0,"dark:text-zinc-400":!0},colorpicker__control:{absolute:!0,"bg-white":!0,"shadow-[0_0_0_2px_rgba(255,255,255,1),0_0_0_3px_rgba(0,0,0,0.2)]":!0,"-translate-y-1/2":!0,"-translate-x-1/2":!0,"pointer-events-none":!0,"data-[prevent-focus-style]:shadow-[0_0_0_2px_rgba(255,255,255,1),0_0_0_3px_rgba(0,0,0,0.2)]":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-offset-2":!0,"focus-visible:ring-accent-400":!0},colorpicker__controlLS:{"w-[10px]":!0,"h-[10px]":!0,"rounded-full":!0},colorpicker__controlHue:{"w-[4px]":!0,"h-[calc(100%-2px)]":!0,"top-1/2":!0,"rounded-sm":!0},colorpicker__controlAlpha:{"w-[4px]":!0,"h-[calc(100%-2px)]":!0,"top-1/2":!0,"rounded-sm":!0},colorpicker__formatField:{flex:!0,"items-center":!0,"justify-center":!0,grow:!0},colorpicker__colorField:{"bg-transparent":!0,"text-zinc-700":!0,border:!0,"border-zinc-200":!0,"dark:border-zinc-800":!0,"dark:text-zinc-300":!0,"dark:selection:text-zinc-700":!0},colorpicker__colorInputGroup:{flex:!0,"items-center":!0,"justify-center":!0,grow:!0},colorpicker__fieldGroup:{flex:!0,"flex-col":!0,"items-center":!0,"justify-center":!0,"w-full":!0,"mr-1":!0,"[&>input]:p-1":!0,"[&>input]:text-sm":!0,"[&>input]:text-zinc-700":!0,"[&>input]:selection:bg-accent-100":!0,"[&>input]:m-0":!0,"[&>input]:grow":!0,"[&>input]:shrink":!0,"[&>input]:w-full":!0,"[&>input]:border":!0,"[&>input]:border-zinc-200":!0,"[&>input]:rounded-sm":!0,"[&>input]:text-center":!0,"[&>input]:appearance-none":!0,"[&>input::-webkit-outer-spin-button]:appearance-none":!0,"[&>input::-webkit-inner-spin-button]:appearance-none":!0,"[&>input::-webkit-inner-spin-button]:m-0":!0,"[&>input:focus]:outline-hidden":!0,"[&>input:focus]:ring-1":!0,"[&>input:focus]:ring-accent-500":!0,"[&>input:focus]:border-accent-500":!0,"max-[431px]:[&>input]:text-base":!0},colorpicker__fieldLabel:{"text-xs":!0,"text-zinc-500":!0,"mt-1.5":!0,"dark:text-zinc-400":!0},colorpicker__formatSwitcher:{flex:!0,"justify-end":!0,"self-start":!0,uppercase:!0,"shrink-0":!0,"p-1":!0,"mt-0.5":!0,"text-zinc-600":!0,"rounded-sm":!0,"select-none":!0,"dark:text-zinc-400":!0},colorpicker__switchIcon:{"[&>svg]:w-3":!0},colorpicker__swatches:{"inline-flex":!0,"flex-wrap":!0,"w-full":!0,"justify-self-center":!0,"min-w-0":!0,"mx-auto":!0,"px-[1px]":!0,"pt-2":!0,"pb-2":!0,"mt-2":!0,"-mb-2":!0,"border-t":!0,"border-zinc-200":!0,"overflow-auto":!0,"max-h-[200px]":!0,"select-none":!0,"first:-mt-[3px]":!0,"first:last:-mb-[3px]":!0,"first:last:pb-[2px]":!0,"first:pt-px":!0,"first:border-t-0":!0,"dark:border-zinc-800":!0},colorpicker__swatchGroup:{flex:!0,"flex-wrap":!0,"w-full":!0,"mb-2":!0,"last:mb-0":!0},colorpicker__swatchGroupLabel:{"ml-1":!0,block:!0,"w-full":!0,"text-xs":!0,"text-zinc-500":!0,"dark:text-zinc-400":!0},colorpicker__swatch:{relative:!0,"text-sm":!0,"w-[calc((100%/10)-0.5em)]":!0,"max-w-[22px]":!0,"m-[0.16em]":!0,"cursor-pointer":!0,"before:content-['']":!0,"before:absolute":!0,"before:inset-0":!0,"before:rounded-sm":!0,"before:shadow-[inset_0_0_0_1px_rgba(0,0,0,0.2)]":!0,"before:pointer-events-none":!0,"before:z-[2]":!0,"dark:before:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.25)]":!0,"data-[active=true]:after:content-['']":!0,"data-[active=true]:after:block":!0,"data-[active=true]:after:absolute":!0,"data-[active=true]:after:w-1.5":!0,"data-[active=true]:after:h-1.5":!0,"data-[active=true]:after:top-1/2":!0,"data-[active=true]:after:left-1/2":!0,"data-[active=true]:after:pointer-events-none":!0,"data-[active=true]:after:rounded-full":!0,"data-[active=true]:after:-translate-x-1/2":!0,"data-[active=true]:after:-translate-y-1/2":!0,"data-[active=true]:after:bg-white":!0,"data-[active=true]:after:z-[2]":!0,"data-[active=true]:after:ring-1":!0,"data-[active=true]:after:ring-[rgba(0,0,0,0.33)]":!0,"[&>canvas]:block":!0,"[&>canvas]:w-full":!0,"[&>canvas]:aspect-[1/1]":!0,"[&>canvas]:rounded-sm":!0,"[&>canvas:focus-visible]:outline-hidden":!0,"[&>canvas:focus-visible]:ring-2":!0,"[&>canvas:focus-visible]:ring-accent-400":!0,"[&>canvas:focus-visible]:ring-offset-2":!0,"[&>canvas:focus-visible]:ring-offset-white":!0,"dark:[&>canvas:focus-visible]:ring-offset-zinc-700":!0},datepicker__inner:{relative:!0},datepicker__removeSelection:{"self-stretch":!0,"text-sm":!0,flex:!0,"items-center":!0,"ml-1":!0,"mr-2":!0,"text-zinc-700":!0,"hover:text-red-400":!0,"z-10":!0,"dark:text-zinc-300":!0},datepicker__clearIcon:{"[&>svg]:w-[0.75em]":!0},datepicker__panelWrapper:{"group/panel":!0,absolute:!0,"min-w-[20em]":!0,"top-[calc(100%_+_0.5em)]":!0,"left-0":!0,"shadow-[0_0_1.25em_rgba(0,0,0,.25)]":!0,"rounded-sm":!0,"p-4":!0,"bg-white":!0,"z-10":!0,"dark:bg-zinc-800":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:!fixed":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:top-auto":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:max-w-none":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:bottom-0":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:left-0":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:rounded-none":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:w-full":!0},datepicker__panelHeader:{grid:!0,"grid-cols-[2.5em_1fr_2.5em]":!0,"justify-center":!0,"items-center":!0,"border-b-2":!0,"border-zinc-200":!0,"mb-2":!0,"pb-2.5":!0,"dark:border-zinc-700":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:grid-cols-[2.5em_1fr_2.5em_2.5em]":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:group-data-[panel=time]/panel:grid-cols-[2.5em_1fr_2.5em]":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:group-data-[panel=month]/panel:grid-cols-[2.5em_1fr_2.5em]":!0},datepicker__panelClose:{"aspect-[1/1]":!0,border:!0,"border-zinc-200":!0,"rounded-sm":!0,flex:!0,"items-center":!0,"justify-center":!0,"text-zinc-700":!0,"[&_svg]:w-[1.25em]":!0,"dark:text-zinc-300":!0,"dark:border-zinc-800":!0,"[@media(max-width:431px)_and_(hover:none)]:group-data-[panel=time]/panel:col-start-3":!0,"[@media(max-width:431px)_and_(hover:none)]:group-data-[panel=month]/panel:col-start-3":!0},datepicker__panel:{flex:!0,"justify-center":!0},datepicker__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"placeholder:text-zinc-400":!0},datepicker__monthsHeader:{flex:!0,"items-center":!0,"justify-center":!0,"col-start-2":!0,"col-end-2":!0},datepicker__timeHeader:{flex:!0,"items-center":!0,"justify-center":!0,"col-start-2":!0,"col-end-2":!0},datepicker__months:{grid:!0,"grid-cols-3":!0,"w-full":!0},datepicker__month:{"m-1.5":!0,"p-1.5":!0,"text-center":!0,"text-zinc-700":!0,"rounded-sm":!0,"bg-zinc-200":!0,"aria-selected:!bg-accent-500":!0,"aria-selected:!text-white":!0,"focus:outline":!0,"focus:outline-2":!0,"focus:outline-accent-500":!0,"focus:outline-offset-2":!0,"focus:bg-white":!0,"focus:text-zinc-700":!0,"data-[is-extra=true]:opacity-25":!0,"group-data-[disabled=true]:opacity-50":!0,"group-data-[disabled=true]:cursor-default":!0,"group-data-[disabled=true]:pointer-events-none":!0,"dark:bg-zinc-700":!0,"dark:text-zinc-300":!0},datepicker__yearsHeader:{flex:!0,"items-center":!0,"justify-center":!0,"text-zinc-700":!0,"col-start-2":!0,"col-end-2":!0,"dark:text-zinc-300":!0},datepicker__years:{grid:!0,"grid-cols-5":!0,"w-full":!0},datepicker__year:{"text-sm":!0,"text-center":!0,"text-zinc-700":!0,"items-center":!0,"m-1.5":!0,"p-1.5":!0,"rounded-sm":!0,"bg-zinc-200":!0,"aria-selected:!bg-accent-500":!0,"aria-selected:!text-white":!0,"focus:outline":!0,"focus:outline-2":!0,"focus:outline-accent-500":!0,"focus:outline-offset-2":!0,"focus:bg-white":!0,"data-[is-extra=true]:opacity-25":!0,"group-data-[disabled=true]:opacity-50":!0,"group-data-[disabled=true]:cursor-default":!0,"group-data-[disabled=true]:pointer-events-none":!0,"dark:bg-zinc-700":!0,"dark:text-zinc-300":!0},datepicker__weekDays:{grid:!0,"grid-cols-7":!0},datepicker__weekDay:{"w-[2.25em]":!0,"text-zinc-700":!0,"m-1.5":!0,"rounded-sm":!0,"font-medium":!0,lowercase:!0,"dark:text-zinc-500":!0},datepicker__calendarWeeks:{"":!0},datepicker__week:{grid:!0,"grid-cols-7":!0,"group-data-[disabled=true]:opacity-50":!0,"group-data-[disabled=true]:cursor-default":!0,"group-data-[disabled=true]:pointer-events-none":!0},datepicker__dayCell:{flex:!0,"items-center":!0,"justify-center":!0,"text-center":!0,"text-zinc-700":!0,"w-[2.25em]":!0,"h-[2.25em]":!0,"m-1":!0,"p-2":!0,"rounded-sm":!0,"bg-zinc-200":!0,"aria-selected:bg-accent-500":!0,"aria-selected:text-white":!0,"focus:outline":!0,"focus:outline-2":!0,"focus:outline-accent-500":!0,"focus:outline-offset-2":!0,"focus:bg-white":!0,"data-[is-extra=true]:opacity-25":!0,"data-[disabled=true]:opacity-50":!0,"data-[disabled=true]:cursor-default":!0,"data-[disabled=true]:pointer-events-none":!0,"dark:bg-zinc-600":!0,"dark:text-zinc-300":!0,"dark:aria-selected:bg-accent-500":!0,"dark:aria-selected:text-white":!0,"dark:focus:outline-accent-500":!0,"dark:focus:bg-zinc-200":!0,"dark:focus:text-zinc-700":!0},datepicker__timeInput:{"w-full":!0,"border-2":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"text-zinc-700":!0,"border-zinc-200":!0,"rounded-sm":!0,"p-1.5":!0,"my-2.5":!0,"focus-visible:outline-accent-500":!0,"dark:text-zinc-300":!0,"dark:bg-transparent":!0,"dark:border-zinc-700":!0},datepicker__daysHeader:{flex:!0,"items-center":!0,"justify-center":!0},datepicker__prev:{"mr-auto":!0,"px-2.5":!0,"py-0.5":!0,"hover:bg-zinc-100":!0,"rounded-sm":!0,"col-start-1":!0,"col-end-1":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-accent-400":!0,"focus-visible:ring-offset-2":!0},datepicker__prevLabel:{hidden:!0},datepicker__prevIcon:{flex:!0,"w-[0.75em]":!0,"select-none":!0,"text-zinc-700":!0,"[&>svg]:w-full":!0,"dark:text-zinc-300":!0},datepicker__dayButton:{"appearance-none":!0,"text-zinc-700":!0,"cursor-pointer":!0,"px-2.5":!0,"py-0.5":!0,"border-2":!0,"border-zinc-200":!0,"rounded-sm":!0,"mx-1":!0,"hover:border-accent-500":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-accent-400":!0,"focus-visible:ring-offset-2":!0,"dark:text-zinc-300":!0,"dark:border-zinc-700":!0,"dark:hover:border-accent-400":!0},datepicker__monthButton:{"appearance-none":!0,"text-zinc-700":!0,"cursor-pointer":!0,"px-2.5":!0,"py-0.5":!0,"border-2":!0,"border-zinc-200":!0,"rounded-sm":!0,"mx-1":!0,"hover:border-accent-500":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-accent-400":!0,"focus-visible:ring-offset-2":!0,"dark:text-zinc-300":!0,"dark:border-zinc-700":!0,"dark:hover:border-accent-400":!0},datepicker__yearButton:{"appearance-none":!0,"text-zinc-700":!0,"cursor-pointer":!0,"px-2.5":!0,"py-0.5":!0,"border-2":!0,"border-zinc-200":!0,"rounded-sm":!0,"mx-1":!0,"hover:border-accent-500":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-accent-400":!0,"focus-visible:ring-offset-2":!0,"dark:text-zinc-300":!0,"dark:border-zinc-700":!0,"dark:hover:border-accent-400":!0},datepicker__next:{"ml-auto":!0,"px-2.5":!0,"py-0.5":!0,"rounded-sm":!0,"hover:bg-zinc-100":!0,"hover:rounded-sm":!0,"col-start-3":!0,"col-end-3":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-accent-400":!0,"focus-visible:ring-offset-2":!0},datepicker__nextLabel:{hidden:!0},datepicker__nextIcon:{flex:!0,"w-[0.75em]":!0,"select-none":!0,"text-zinc-700":!0,"[&>svg]:w-full":!0,"dark:text-zinc-300":!0},datepicker__openButton:{"appearance-none":!0,"border-0":!0,"bg-transparent":!0,flex:!0,"p-0":!0,"self-stretch":!0,"cursor-pointer":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-accent-400":!0,"focus-visible:ring-offset-2":!0,"focus-visible:rounded-sm":!0},datepicker__calendarIcon:{"text-zinc-600":!0,"focus-visible:text-accent-500":!0,flex:!0,"w-[1em]":!0,"grow-0":!0,"shrink-0":!0,"self-stretch":!0,"select-none":!0,"[&>svg]:w-full":!0,"[&>svg]:m-auto":!0,"[&>svg]:max-h-[1em]":!0,"[&>svg]:max-w-[1em]":!0},dropdown__placeholder:{"text-zinc-400":!0,grow:!0,"dark:text-zinc-400/50":!0},dropdown__selector:{flex:!0,grow:!0,"justify-between":!0,"w-full":!0,"py-2":!0,"pl-3":!0,"pr-0":!0,"text-sm":!0,"text-zinc-700":!0,"text-left":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"group-data-[prefix-icon]:!pl-0":!0,"group-data-[suffix-icon]:!pr-0":!0,"data-[placeholder]:text-zinc-400":!0,"selection:bg-accent-100":!0,"dark:data-[placeholder]:text-zinc-400/50":!0,"dark:text-zinc-300":!0},dropdown__selectIcon:{"shrink-0":!0},dropdown__selectionsWrapper:{"w-[85%]":!0,"overflow-hidden":!0},dropdown__selection:{"[&>*]:ml-0":!0},dropdown__selections:{"inline-flex":!0,"items-center":!0},dropdown__selectionsItem:{"whitespace-nowrap":!0,"mr-1":!0},dropdown__tagWrapper:{"[&.formkit-dropZone_.formkit-tag]:opacity-25":!0,"[&.formkit-touchDropZone_.formkit-tag]:opacity-25":!0},dropdown__truncationCount:{flex:!0,"items-center":!0,"justify-center":!0,"h-[1.5em]":!0,"rounded-sm":!0,"bg-zinc-400":!0,"text-white":!0,"whitespace-nowrap":!0,"text-[11px]":!0,"[line-height:1em]":!0,"tracking-tighter":!0,"leading-0":!0,"py-1":!0,"px-1":!0,"shrink-0":!0,"my-auto":!0},mask__inner:{relative:!0},mask__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"group-data-[has-overlay]:!caret-zinc-700":!0,"dark:group-data-[has-overlay]:!caret-zinc-300":!0},rating__inner:{"text-zinc-300":!0},rating__itemsWrapper:{relative:!0,"inline-flex":!0,"focus:border-accent-500":!0},rating__onItemRow:{"h-full":!0,"w-full":!0},rating__offItemRow:{"h-full":!0,"w-full":!0},rating__onItemWrapper:{"[&>*]:w-full":!0,"[&>*]:h-full":!0,"w-full":!0,"h-full":!0,"text-yellow-400":!0},rating__offItemWrapper:{"text-zinc-300":!0,"w-full":!0,"h-full":!0,"[&>*]:w-full":!0,"[&>*]:h-full":!0,"dark:text-zinc-600":!0},rating__ratingItem:{relative:!0,"focus-within:outline":!0,"focus-within:outline-accent-500":!0,"w-[1.5em]":!0,"h-[1.5em]":!0},rating__itemLabelInner:{"h-px":!0,"w-px":!0,"overflow-hidden":!0,absolute:!0,"white-space-nowrap":!0},rating__itemLabel:{absolute:!0,"h-full":!0},rating__ratingIcon:{"w-[1.5em]":!0,"h-[1.5em]":!0,flex:!0},rating__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"outline-hidden":!0},rating__messages:{"mt-1.5":!0},repeater__outer:{"min-w-0":!0,grow:!0,"mb-4":!0,"text-sm":!0,"group/repeater":!0,"max-w-full":!0},repeater__fieldset:{"min-w-0":!0},repeater__legend:{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"dark:text-zinc-300":!0,"mb-2":!0},repeater__content:{"min-w-0":!0,grow:!0,"p-5":!0,flex:!0,"flex-col":!0,"align-center":!0,"[&>div[data-type]]:max-w-none":!0,"[&>div[data-type]:last-child]:mb-0":!0},repeater__addButton:{"!mb-0":!0,"group-data-[disabled]/repeater:pointer-events-none":!0,"group-data-[disabled]/repeater:opacity-50":!0,"group-data-[disabled]/repeater:grayscale":!0},repeater__controlLabel:{absolute:!0,"opacity-0":!0,"pointer-events-none":!0,"text-[0px]":!0},repeater__controls:{flex:!0,"flex-col":!0,"items-center":!0,"justify-center":!0,"bg-zinc-50":!0,"p-2":!0,"[&>li]:aspect-[1/1]":!0,"dark:bg-zinc-800":!0,"rounded-sm":!0,"rounded-tl-none":!0,"rounded-bl-none":!0},repeater__downControl:{"w-[1.5em]":!0,"h-[1.5em]":!0,"my-1.5":!0,"mx-auto":!0,flex:!0,"items-center":!0,"appearance-none":!0,"justify-center":!0,"aspect-[1/1]":!0,"text-zinc-500":!0,"hover:text-accent-500":!0,"disabled:hover:text-inherit":!0,"disabled:opacity-25":!0,"disabled:!text-zinc-500":!0,"dark:text-zinc-300":!0,"dark:disabled:!text-zinc-300":!0,"dark:hover:text-accent-400":!0},repeater__upControl:{"w-[1.5em]":!0,"h-[1.5em]":!0,"my-1.5":!0,"mx-auto":!0,flex:!0,"items-center":!0,"appearance-none":!0,"justify-center":!0,"aspect-[1/1]":!0,"text-zinc-500":!0,"hover:text-accent-500":!0,"disabled:hover:text-inherit":!0,"disabled:opacity-25":!0,"disabled:!text-zinc-500":!0,"dark:text-zinc-300":!0,"dark:disabled:!text-zinc-300":!0,"dark:hover:text-accent-400":!0},repeater__removeControl:{"w-[1.5em]":!0,"h-[1.5em]":!0,"my-1.5":!0,"mx-auto":!0,flex:!0,"items-center":!0,"appearance-none":!0,"justify-center":!0,"aspect-[1/1]":!0,"text-zinc-500":!0,"hover:text-accent-500":!0,"disabled:hover:text-inherit":!0,"disabled:opacity-25":!0,"disabled:!text-zinc-500":!0,"dark:text-zinc-300":!0,"dark:disabled:!text-zinc-300":!0,"dark:hover:text-accent-400":!0},repeater__insertControl:{"w-[1.5em]":!0,"h-[1.5em]":!0,"my-1.5":!0,"mx-auto":!0,flex:!0,"items-center":!0,"appearance-none":!0,"justify-center":!0,"aspect-[1/1]":!0,"text-zinc-500":!0,"hover:text-accent-500":!0,"disabled:hover:text-inherit":!0,"disabled:opacity-25":!0,"disabled:!text-zinc-500":!0,"dark:text-zinc-300":!0,"dark:disabled:!text-zinc-300":!0,"dark:hover:text-accent-400":!0},repeater__help:{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-zinc-400":!0,"mb-2":!0,"-mt-1":!0},repeater__item:{flex:!0,relative:!0,"w-full":!0,"mb-2":!0,"bg-white":!0,border:!0,"border-zinc-200":!0,"rounded-sm":!0,"shadow-none":!0,"dark:border-zinc-700":!0,"dark:bg-transparent":!0,"[&.formkit-dropZone]:opacity-30":!0,"[&.formkit-dropZone]:blur-[2px]":!0},repeater__dragHandleWrapper:{relative:!0,"w-8":!0,"bg-zinc-50":!0,"rounded-sm":!0,"rounded-tr-none":!0,"rounded-br-none":!0,"dark:bg-zinc-800":!0},repeater__dragHandle:{"w-full":!0,"h-full":!0,flex:!0,absolute:!0,"top-0":!0,"left-0":!0,"cursor-grab":!0,"active:cursor-grabbing":!0},repeater__dragHandleIcon:{"w-2":!0,"m-auto":!0,"text-zinc-400":!0,"dark:text-zinc-600":!0,"[&>svg>path]:fill-current":!0},repeater__moveDownIcon:{block:!0,"w-[0.75em]":!0,"aspect-[1/1]":!0},repeater__moveUpIcon:{block:!0,"w-[0.75em]":!0,"aspect-[1/1]":!0},repeater__removeIcon:{block:!0,"w-[1.25em]":!0,"aspect-[1/1]":!0},repeater__addIcon:{block:!0,"w-[1.25em]":!0,"aspect-[1/1]":!0},slider__outer:{group:!0,"max-w-none":!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"data-[disabled]:opacity-50":!0,"text-sm":!0,"data-[disabled]:pointer-events-none":!0},slider__help:{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-zinc-400":!0,"-mt-0.5":!0,"mb-1.5":!0},slider__sliderInner:{flex:!0,"items-center":!0,"[&>[data-type=number]]:mb-0":!0,"[&>[data-type=number]]:ml-2.5":!0,"[&>[data-type=number]]:shrink":!0,"[&>[data-type=number]]:grow-0":!0,"[&[data-has-mark-labels=true]_[id^=track]]:mb-5":!0},slider__track:{grow:!0,relative:!0,"z-20":!0,"py-2.5":!0,"select-none":!0},slider__trackWrapper:{"px-[2px]":!0,"rounded-full":!0,"bg-zinc-300":!0,"dark:bg-zinc-500":!0},slider__trackInner:{"h-1.5":!0,"mx-0.5":!0,relative:!0},slider__prefixIcon:{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},slider__suffixIcon:{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},slider__fill:{"h-full":!0,"rounded-full":!0,absolute:!0,"top-0":!0,"-mx-1":!0,"bg-accent-500":!0,"group-data-[disabled]:bg-zinc-500":!0},slider__marks:{absolute:!0,"pointer-events-none":!0,"inset-0":!0},slider__mark:{absolute:!0,"top-1/2":!0,"w-[3px]":!0,"h-[3px]":!0,"rounded-full":!0,"-translate-x-1/2":!0,"-translate-y-1/2":!0,"bg-zinc-400":!0,"data-[active=true]:bg-white":!0},slider__markLabel:{absolute:!0,"top-[calc(100%+0.5em)]":!0,"left-1/2":!0,"text-zinc-400":!0,"text-[11px]":!0,"[line-height:1em]":!0,"-translate-x-1/2":!0},slider__handles:{"m-0":!0,"p-0":!0,"list-none":!0},slider__handle:{group:!0,"select-none":!0,"w-4":!0,"h-4":!0,"rounded-full":!0,"bg-white":!0,absolute:!0,"top-1/2":!0,"left-0":!0,"z-30":!0,"-translate-x-1/2":!0,"-translate-y-1/2":!0,"shadow-[inset_0_0_0_1px_rgba(0,0,0,0.1),0_1px_2px_0_rgba(0,0,0,0.5)]":!0,"focus-visible:outline-0":!0,"focus-visible:ring-2":!0,"ring-accent-500":!0,"data-[is-target=true]:z-20":!0,"dark:bg-zinc-200":!0},slider__tooltip:{absolute:!0,"bottom-full":!0,"left-1/2":!0,"-translate-x-1/2":!0,"-translate-y-[4px]":!0,"bg-accent-500":!0,"text-white":!0,"py-1":!0,"px-1.5":!0,"text-xs":!0,"leading-none":!0,"whitespace-nowrap":!0,"rounded-sm":!0,"opacity-0":!0,"pointer-events-none":!0,"transition-opacity":!0,'after:content-[""]':!0,"after:absolute":!0,"after:top-full":!0,"after:left-1/2":!0,"after:-translate-x-1/2":!0,"after:-translate-y-[1px]":!0,"after:border-4":!0,"after:border-transparent":!0,"after:border-t-accent-500":!0,"group-hover:opacity-100":!0,"group-focus-visible:opacity-100":!0,"group-data-[show-tooltip=true]:opacity-100":!0},slider__linkedValues:{flex:!0,"items-start":!0,"justify-between":!0},slider__minValue:{grow:!0,"!max-w-[45%]":!0,"mb-0":!0,"[&>div>div]:relative":!0,'[&>div>div::after]:content-[""]':!0,"[&>div>div::after]:absolute":!0,"[&>div>div::after]:top-1/2":!0,"[&>div>div::after]:left-[105.5%]":!0,"[&>div>div::after]:w-[12%]":!0,"[&>div>div::after]:h-[1px]":!0,"[&>div>div::after]:bg-zinc-300":!0,"dark:[&>div>div::after]:bg-zinc-700":!0},slider__maxValue:{grow:!0,"!max-w-[45%]":!0,"mb-0":!0,relative:!0},slider__chart:{relative:!0,"z-20":!0,"mb-2":!0,flex:!0,"justify-between":!0,"items-center":!0,"w-full":!0,"aspect-[3/1]":!0},slider__chartBar:{absolute:!0,"bottom-0":!0,"h-full":!0,"bg-zinc-400":!0,"data-[active=false]:bg-zinc-300":!0,"dark:bg-zinc-500":!0,"dark:data-[active=false]:bg-zinc-600":!0},taglist__inner:{"py-2":!0,"pr-0":!0,"pl-0":!0},taglist__tags:{"pl-3":!0},taglist__tagWrapper:{"[&.formkit-dropZone_.formkit-tag]:opacity-25":!0,"[&.formkit-touchDropZone_.formkit-tag]:opacity-25":!0},taglist__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"!p-0":!0,"!w-[0%]":!0,"min-w-[1em]":!0,"inline-block":!0,"-mt-1":!0,"first:mt-0":!0,"first:mb-1":!0},taglist__listboxButton:{"ml-auto":!0,"shrink-0":!0},toggle__outer:{group:!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"data-[disabled]:opacity-50":!0,"text-sm":!0,"max-w-none":!0},toggle__altLabel:{block:!0,"w-full":!0,"mb-1.5":!0,"font-bold":!0,"text-[11px]":!0,"[line-height:1em]":!0,"text-zinc-700":!0,"dark:text-zinc-300":!0},toggle__inner:{peer:!0,"inline-block":!0,"mr-2":!0},toggle__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,peer:!0,absolute:!0,"opacity-0":!0,"w-0":!0,"h-0":!0},toggle__label:{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"mb-1":!0,"dark:text-zinc-300":!0,"peer-first:font-normal":!0,"peer-first:mb-0":!0},toggle__innerLabel:{absolute:!0,"text-zinc-200":!0,"text-[10px]":!0,"font-bold":!0,"select-none":!0,"left-full":!0,"top-1/2":!0,"-translate-x-full":!0,"-translate-y-1/2":!0,"px-1":!0},toggle__thumb:{relative:!0,"p-0.5":!0,"left-0":!0,"aspect-[1/1]":!0,"rounded-full":!0,"transition-all":!0,"w-[1.25em]":!0,"bg-zinc-50":!0,"text-zinc-600":!0,"shadow-base":!0},toggle__track:{"p-0.5":!0,"min-w-[3em]":!0,relative:!0,"cursor-pointer":!0,"select-none":!0,"rounded-full":!0,"transition-all":!0,"bg-zinc-400":!0,"peer-checked:bg-accent-500":!0,"peer-checked:[&>div:last-child]:left-full":!0,"peer-checked:[&>div:last-child]:-translate-x-full":!0,"peer-checked:[&>div:first-child:not(:last-child)]:left-0":!0,"peer-checked:[&>div:first-child:not(:last-child)]:translate-x-0":!0,"shadow-none":!0,"peer-focus-visible:ring-2":!0,"peer-focus-visible:ring-accent-400":!0,"peer-focus-visible:ring-offset-2":!0,"dark:bg-zinc-500":!0},toggle__valueLabel:{"font-bold":!0,"text-[11px]":!0,"[line-height:1em]":!0,"text-zinc-700":!0,"dark:text-zinc-300":!0},toggle__wrapper:{flex:!0,"flex-wrap":!0,"items-center":!0,"mb-1.5":!0},togglebuttons__wrapper:{"mb-1.5":!0},togglebuttons__options:{"group/options":!0,"inline-flex":!0,"data-[vertical=true]:flex-col":!0},togglebuttons__option:{"group/option":!0},togglebuttons__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"!px-4":!0,"!mb-0":!0,relative:!0,"focus:z-10":!0,"group-data-[vertical=true]/options:w-full":!0,"justify-center":!0,"bg-accent-50":!0,"disabled:opacity-50":!0,"disabled:cursor-not-allowed":!0,"group-data-[disabled]:disabled:opacity-100":!0,"dark:bg-transparent":!0,"dark:disabled:bg-transparent":!0,"dark:disabled:text-accent-500":!0,"dark:text-accent-500":!0,"aria-[pressed=true]:bg-accent-500":!0,"aria-[pressed=true]:text-white":!0,"dark:aria-[pressed=true]:bg-accent-500":!0,"dark:aria-[pressed=true]:text-white":!0,"group-[&]/option:!rounded-none":!0,"group-data-[vertical=false]/options:group-first/option:!rounded-sm":!0,"group-data-[vertical=true]/options:group-first/option:!rounded-sm":!0,"group-data-[vertical=false]/options:group-first/option:!rounded-tr-none":!0,"group-data-[vertical=false]/options:group-first/option:!rounded-br-none":!0,"group-data-[vertical=true]/options:group-first/option:!rounded-bl-none":!0,"group-data-[vertical=true]/options:group-first/option:!rounded-br-none":!0,"group-data-[vertical=false]/options:group-last/option:!rounded-sm":!0,"group-data-[vertical=true]/options:group-last/option:!rounded-sm":!0,"group-data-[vertical=false]/options:group-last/option:!rounded-tl-none":!0,"group-data-[vertical=false]/options:group-last/option:!rounded-bl-none":!0,"group-data-[vertical=true]/options:group-last/option:!rounded-tl-none":!0,"group-data-[vertical=true]/options:group-last/option:!rounded-tr-none":!0,"group-data-[vertical=false]/options:group-[&]/option:!border-r-0":!0,"group-data-[vertical=false]/options:group-last/option:!border-r":!0,"group-data-[vertical=false]/options:group-[&]/option:aria-[pressed=true]:border-x-accent-500":!0,"group-data-[vertical=false]/options:group-first/option:aria-[pressed=true]:border-l-accent-500":!0,"group-data-[vertical=false]/options:group-last/option:aria-[pressed=true]:border-r-accent-500":!0,"dark:group-data-[vertical=false]/options:group-[&]/option:aria-[pressed=true]:border-x-accent-500":!0,"dark:group-data-[vertical=false]/options:group-first/option:aria-[pressed=true]:border-l-accent-500":!0,"dark:group-data-[vertical=false]/options:group-last/option:aria-[pressed=true]:border-r-accent-500":!0,"group-data-[vertical=true]/options:group-[&]/option:!border-b-0":!0,"group-data-[vertical=true]/options:group-last/option:!border-b":!0,"group-data-[vertical=true]/options:group-[&]/option:aria-[pressed=true]:border-y-accent-500":!0,"group-data-[vertical=true]/options:group-first/option:aria-[pressed=true]:border-t-accent-500":!0,"group-data-[vertical=true]/options:group-last/option:aria-[pressed=true]:border-b-accent-500":!0,"dark:group-data-[vertical=true]/options:group-[&]/option:aria-[pressed=true]:border-y-accent-500":!0,"dark:group-data-[vertical=true]/options:group-first/option:aria-[pressed=true]:border-t-accent-500":!0,"dark:group-data-[vertical=true]/options:group-last/option:aria-[pressed=true]:border-b-accent-500":!0},transferlist__outer:{group:!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"data-[disabled]:opacity-50":!0,"text-sm":!0,"max-w-none":!0,"[&_.dnd-placeholder]:bg-accent-500":!0,"[&_.dnd-placeholder]:text-white":!0},transferlist__wrapper:{flex:!0,"flex-col":!0,"sm:flex-row":!0,"justify-between":!0,"w-full":!0,"max-w-none":!0},transferlist__help:{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-zinc-400":!0,"pb-2":!0},transferlist__transferlist:{grow:!0,shrink:!0,"min-w-0":!0,"shadow-none":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"aspect-[4/5]":!0,flex:!0,"flex-col":!0,"h-[350px]":!0,border:!0,"border-zinc-200":!0,"rounded-sm":!0,"overflow-hidden":!0,"select-none":!0,"[&:has(:focus-visible)]:ring-1":!0,"[&:has(:focus-visible)]:ring-accent-400":!0,"dark:border-zinc-800":!0,"dark:bg-zinc-900/50":!0},transferlist__transferlistHeader:{flex:!0,"bg-zinc-100":!0,"text-zinc-600":!0,"text-xs":!0,"justify-between":!0,"items-center":!0,"border-b":!0,"border-zinc-200":!0,"py-2":!0,"px-2.5":!0,"dark:bg-zinc-700":!0,"dark:border-zinc-800":!0,"dark:text-zinc-400":!0},transferlist__transferlistHeaderItemCount:{"ml-auto":!0,"text-xs":!0,"min-w-[1.5em]":!0,"[line-height:1.5em]":!0,"px-2":!0,"text-center":!0,"rounded-lg":!0,"bg-zinc-200":!0,"text-zinc-700":!0,"dark:bg-zinc-500":!0,"dark:text-zinc-300":!0},transferlist__transferlistListItems:{"list-none":!0,"bg-white":!0,"h-full":!0,"overflow-x-hidden":!0,"overflow-y-auto":!0,"dark:bg-transparent":!0,"outline-hidden":!0},transferlist__transferlistListItem:{"py-2":!0,"px-2":!0,"text-zinc-700":!0,"ring-1":!0,"ring-zinc-200":!0,"aria-selected:bg-accent-100":!0,"data-[is-active=true]:bg-accent-100":!0,"data-[is-active=true]:ring-accent-200":!0,"aria-selected:ring-accent-200":!0,relative:!0,flex:!0,"cursor-pointer":!0,"items-center":!0,"bg-white":!0,"pl-[1.5em]":!0,"first:-mt-px":!0,"first:border-t":!0,"aria-selected:z-[2]":!0,"aria-selected:border-transparent":!0,"aria-selected:ring-1":!0,"data-[is-active=true]:z-[2]":!0,"data-[is-active=true]:border-transparent":!0,"data-[is-active=true]:ring-1":!0,"group-data-[is-max=true]:cursor-not-allowed":!0,"dark:bg-zinc-800":!0,"dark:text-zinc-300":!0,"dark:data-[is-active=true]:bg-accent-800":!0,"dark:aria-selected:bg-accent-800":!0,"dark:ring-zinc-700":!0,"dark:data-[is-active=true]:ring-accent-600":!0,"dark:aria-selected:ring-accent-600":!0,"[&.formkit-dropZone]:bg-accent-100":!0,"[&.formkit-selectionDropZone]:bg-accent-100":!0,"[&.formkit-touchDropZone]:bg-accent-100":!0,"[&.formkit-touchSelectionDropZone]:bg-accent-100":!0,"[&.formkit-longTouch]:bg-accent-100":!0,"dark:[&.formkit-dropZone]:bg-accent-900":!0,"dark:[&.formkit-selectionDropZone]:bg-accent-900":!0,"dark:[&.formkit-touchDropZone]:bg-accent-900":!0,"dark:[&.formkit-touchSelectionDropZone]:bg-accent-900":!0,"dark:[&.formkit-longTouch]:bg-accent-900":!0},transferlist__transferlistOption:{"text-xs":!0},transferlist__transferControls:{"inline-flex":!0,"grow-0":!0,shrink:!0,border:!0,"border-zinc-200":!0,"flex-row":!0,"sm:flex-col":!0,"justify-center":!0,"my-2":!0,"sm:my-auto":!0,"mx-auto":!0,"sm:mx-2":!0,"rounded-sm":!0,"overflow-clip":!0,"shadow-none":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"dark:border-zinc-800":!0},transferlist__sourceEmptyMessage:{"appearance-none":!0,"border-none":!0,"w-full":!0,"my-2":!0,"text-center":!0,"text-zinc-500":!0,italic:!0},transferlist__sourceListItems:{"group-data-[is-max=true]:opacity-50":!0},transferlist__targetEmptyMessage:{"appearance-none":!0,"border-none":!0,"w-full":!0,"my-2":!0,"text-center":!0,"text-zinc-500":!0,italic:!0},transferlist__emptyMessageInner:{flex:!0,"items-center":!0,"justify-center":!0,"p-2":!0,"text-sm":!0},transferlist__transferlistControls:{"bg-white":!0,"p-2":!0,"border-b":!0,"border-zinc-200":!0,"dark:bg-zinc-700":!0,"dark:border-zinc-700":!0},transferlist__transferlistSearch:{flex:!0,border:!0,"border-zinc-200":!0,"rounded-sm":!0,"items-center":!0,"text-zinc-700":!0,"selection:bg-accent-100":!0,"dark:border-zinc-800":!0,"dark:text-zinc-300":!0,"dark:selection:bg-accent-100":!0,"dark:selection:text-zinc-700":!0,"dark:bg-zinc-800":!0},transferlist__transferlistSearchInput:{"border-none":!0,"px-2":!0,"py-1.5":!0,"w-full":!0,"bg-transparent":!0,"outline-hidden":!0,"text-xs":!0},transferlist__transferlistSearchClear:{flex:!0,"w-[0.75em]":!0,"mr-2":!0,"[&_svg]:w-full":!0},transferlist__controlLabel:{absolute:!0,"opacity-0":!0,"pointer-events-none":!0,"text-[0px]":!0},transferlist__selectedIcon:{"w-[0.75em]":!0,absolute:!0,"left-[0.5em]":!0,"select-none":!0,"text-accent-500":!0,"dark:text-accent-400":!0},transferlist__transferlistButton:{"sm:w-5":!0,relative:!0,flex:!0,"justify-center":!0,"text-sm":!0,"shrink-0":!0,"box-content":!0,"text-zinc-700":!0,"disabled:bg-zinc-200":!0,"disabled:!text-zinc-400":!0,"bg-zinc-50":!0,"hover:text-accent-500":!0,"cursor-pointer":!0,"appearance-none":!0,"border-none":!0,"p-2.5":!0,"hover:z-10":!0,"disabled:cursor-not-allowed":!0,"disabled:opacity-50":!0,"disabled:hover:text-current":!0,"disabled:hover:outline-hidden":!0,"focus-visible:ring-1":!0,"focus-visible:ring-accent-400":!0,"focus-visible:z-10":!0,"dark:bg-zinc-800":!0,"dark:text-zinc-400":!0,"dark:disabled:!text-zinc-600":!0,"dark:disabled:bg-zinc-900":!0,"dark:disabled:hover:text-current":!0,"dark:disabled:hover:outline-hidden":!0,"dark:hover:text-accent-400":!0},transferlist__fastForwardIcon:{"w-4":!0,flex:!0,"select-none":!0,"[&>svg]:m-auto":!0,"[&>svg]:w-full":!0,"[&>svg]:max-w-[1rem]":!0,"[&>svg]:max-h-[1rem]":!0,"rotate-90":!0,"sm:rotate-0":!0},transferlist__moveRightIcon:{"w-4":!0,flex:!0,"select-none":!0,"[&>svg]:m-auto":!0,"[&>svg]:w-full":!0,"[&>svg]:max-w-[1rem]":!0,"[&>svg]:max-h-[1rem]":!0,"rotate-90":!0,"sm:rotate-0":!0},transferlist__moveLeftIcon:{"w-4":!0,flex:!0,"select-none":!0,"[&>svg]:m-auto":!0,"[&>svg]:w-full":!0,"[&>svg]:max-w-[1rem]":!0,"[&>svg]:max-h-[1rem]":!0,"rotate-90":!0,"sm:rotate-0":!0},transferlist__rewindIcon:{"w-4":!0,flex:!0,"select-none":!0,"[&>svg]:m-auto":!0,"[&>svg]:w-full":!0,"[&>svg]:max-w-[1rem]":!0,"[&>svg]:max-h-[1rem]":!0,"rotate-90":!0,"sm:rotate-0":!0},transferlist__messages:{"mt-2":!0},barcode__barcodeIcon:{"w-[1.5em]":!0,"text-zinc-700":!0,"cursor-pointer":!0,"dark:text-zinc-300":!0},barcode__dialog:{"border-none":!0,"outline-hidden":!0,"overflow-clip":!0,"p-0":!0,"bg-black":!0,"rounded-sm":!0,"w-[100%-2rem]":!0,"max-w-[30rem]":!0,"[&::backdrop]:bg-zinc-800/50":!0},barcode__video:{"w-full":!0,"aspect-[1/1]":!0,"object-cover":!0,block:!0,"pointer-events-none":!0},barcode__closeIcon:{"cursor-pointer":!0,absolute:!0,"bg-white":!0,"color-zinc-700":!0,"w-[1.5em]":!0,"h-[1.5em]":!0,"rounded-sm":!0,flex:!0,"top-2":!0,"right-2":!0,"z-20":!0,"[&>svg]:w-[1.25em]":!0,"[&>svg]:h-[1.25em]":!0,"[&>svg]:m-auto":!0},barcode__overlay:{"text-zinc-700":!0,"dark:text-zinc-300":!0,absolute:!0,"top-1/2":!0,"left-1/2":!0,"w-[min(20em,75%)]":!0,"aspect-[1/1]":!0,"-translate-x-1/2":!0,"-translate-y-1/2":!0,"rounded-sm":!0,"pointer-events-none":!0,"shadow-[0_0_0_999em_rgba(0,0,0,0.5)]":!0},barcode__overlayDecorators:{absolute:!0,"inset-0":!0,"z-10":!0},barcode__overlayDecoratorTopLeft:{absolute:!0,"w-[1.5rem]":!0,"h-[1.5rem]":!0,"rounded-sm":!0,"top-0":!0,"left-0":!0,"border-l-4":!0,"border-t-4":!0,"rounded-tr-none":!0,"rounded-bl-none":!0},barcode__overlayDecoratorTopRight:{absolute:!0,"w-[1.5rem]":!0,"h-[1.5rem]":!0,"rounded-sm":!0,"top-0":!0,"right-0":!0,"border-r-4":!0,"border-t-4":!0,"rounded-tl-none":!0,"rounded-br-none":!0},barcode__overlayDecoratorBottomRight:{absolute:!0,"w-[1.5rem]":!0,"h-[1.5rem]":!0,"rounded-sm":!0,"bottom-0":!0,"right-0":!0,"border-r-4":!0,"border-b-4":!0,"rounded-tr-none":!0,"rounded-bl-none":!0},barcode__overlayDecoratorBottomLeft:{absolute:!0,"w-[1.5rem]":!0,"h-[1.5rem]":!0,"rounded-sm":!0,"bottom-0":!0,"left-0":!0,"border-l-4":!0,"border-b-4":!0,"rounded-tl-none":!0,"rounded-br-none":!0},"multi-step__outer":{group:!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"data-[disabled]:opacity-50":!0,"text-sm":!0,"group/multistep":!0,"max-w-[32rem]":!0},"multi-step__wrapper":{"group/wrapper":!0,"data-[tab-style=tab]:shadow-none":!0,"data-[tab-style=tab]:rounded-sm":!0},"multi-step__tabs":{flex:!0,"items-center":!0,"group-data-[tab-style=tab]/wrapper:overflow-auto":!0,"group-data-[tab-style=tab]/wrapper:border":!0,"group-data-[tab-style=tab]/wrapper:border-b-0":!0,"group-data-[tab-style=tab]/wrapper:border-zinc-200":!0,"group-data-[tab-style=tab]/wrapper:rounded-sm":!0,"group-data-[tab-style=tab]/wrapper:rounded-bl-none":!0,"group-data-[tab-style=tab]/wrapper:rounded-br-none":!0,"dark:group-data-[tab-style=tab]/wrapper:border-zinc-800":!0,"group-data-[tab-style=progress]/wrapper:my-6":!0,"group-data-[tab-style=progress]/wrapper:justify-around":!0,"group-data-[tab-style=progress]/wrapper:overflow-visible":!0,"group-data-[tab-style=progress]/wrapper:group-data-[hide-labels=true]/wrapper:mb-3.5":!0},"multi-step__tab":{"group/tab":!0,"group-data-[tab-style=tab]/wrapper:relative":!0,"group-data-[tab-style=tab]/wrapper:flex":!0,"group-data-[tab-style=tab]/wrapper:grow":!0,"group-data-[tab-style=tab]/wrapper:text-xs":!0,"group-data-[tab-style=tab]/wrapper:items-center":!0,"group-data-[tab-style=tab]/wrapper:justify-center":!0,"group-data-[tab-style=tab]/wrapper:cursor-pointer":!0,"group-data-[tab-style=tab]/wrapper:text-zinc-700":!0,"group-data-[tab-style=tab]/wrapper:bg-zinc-100":!0,"group-data-[tab-style=tab]/wrapper:py-3.5":!0,"group-data-[tab-style=tab]/wrapper:px-4":!0,"group-data-[tab-style=tab]/wrapper:border-r":!0,"group-data-[tab-style=tab]/wrapper:border-b":!0,"group-data-[tab-style=tab]/wrapper:border-zinc-200":!0,"group-data-[tab-style=tab]/wrapper:last:border-r-0":!0,"group-data-[tab-style=tab]/wrapper:shadow-[inset_0_-0.5em_0.5em_-0.5em_rgba(0,0,0,0.1)]":!0,"group-data-[tab-style=tab]/wrapper:data-[active=true]:bg-white":!0,"group-data-[tab-style=tab]/wrapper:data-[active=true]:font-bold":!0,"group-data-[tab-style=tab]/wrapper:data-[active=true]:border-b-white":!0,"group-data-[tab-style=tab]/wrapper:data-[active=true]:z-10":!0,"group-data-[tab-style=tab]/wrapper:data-[active=true]:shadow-[0_0_0.5em_0_rgba(0,0,0,0.1)]":!0,"dark:group-data-[tab-style=tab]/wrapper:text-zinc-300":!0,"dark:group-data-[tab-style=tab]/wrapper:bg-zinc-950/20":!0,"dark:group-data-[tab-style=tab]/wrapper:data-[active=true]:bg-transparent":!0,"dark:group-data-[tab-style=tab]/wrapper:data-[active=true]:border-b-transparent":!0,"dark:group-data-[tab-style=tab]/wrapper:border-zinc-800":!0,"group-data-[tab-style=progress]/wrapper:flex":!0,"group-data-[tab-style=progress]/wrapper:flex-col":!0,"group-data-[tab-style=progress]/wrapper:items-center":!0,"group-data-[tab-style=progress]/wrapper:grow":!0,"group-data-[tab-style=progress]/wrapper:shrink-0":!0,"group-data-[tab-style=progress]/wrapper:relative":!0,"group-data-[tab-style=progress]/wrapper:before:block":!0,"group-data-[tab-style=progress]/wrapper:before:text-xs":!0,"group-data-[tab-style=progress]/wrapper:before:w-[1.25rem]":!0,"group-data-[tab-style=progress]/wrapper:before:h-[1.25rem]":!0,"group-data-[tab-style=progress]/wrapper:before:border-4":!0,"group-data-[tab-style=progress]/wrapper:before:border-zinc-300":!0,"group-data-[tab-style=progress]/wrapper:before:rounded-full":!0,"group-data-[tab-style=progress]/wrapper:before:bg-white":!0,"group-data-[tab-style=progress]/wrapper:before:z-10":!0,"dark:group-data-[tab-style=progress]/wrapper:before:border-zinc-800":!0,"dark:group-data-[tab-style=progress]/wrapper:before:bg-zinc-950":!0,"group-data-[tab-style=progress]/wrapper:after:block":!0,"group-data-[tab-style=progress]/wrapper:after:h-1":!0,"group-data-[tab-style=progress]/wrapper:after:w-full":!0,"group-data-[tab-style=progress]/wrapper:after:absolute":!0,"group-data-[tab-style=progress]/wrapper:after:top-[0.5em]":!0,"group-data-[tab-style=progress]/wrapper:after:left-[calc(50%+0.5em)]":!0,"group-data-[tab-style=progress]/wrapper:after:bg-zinc-300":!0,"group-data-[tab-style=progress]/wrapper:data-[valid=true]:data-[visited=true]:after:bg-accent-500":!0,"group-data-[tab-style=progress]/wrapper:last:after:hidden":!0,"dark:group-data-[tab-style=progress]/wrapper:after:bg-zinc-800":!0,"dark:group-data-[tab-style=progress]/wrapper:data-[valid=true]:data-[visited=true]:after:bg-accent-500":!0},"multi-step__tabLabel":{"group-data-[tab-style=progress]/wrapper:absolute":!0,"group-data-[tab-style=progress]/wrapper:text-zinc-800":!0,"group-data-[tab-style=progress]/wrapper:top-full":!0,"group-data-[tab-style=progress]/wrapper:w-full":!0,"group-data-[tab-style=progress]/wrapper:whitespace-nowrap":!0,"group-data-[tab-style=progress]/wrapper:text-[11px]":!0,"[line-height:1em]":!0,"dark:group-data-[tab-style=progress]/wrapper:text-zinc-300":!0},"multi-step__badge":{"bg-red-500":!0,absolute:!0,"font-mono":!0,"font-bold":!0,flex:!0,"items-center":!0,"justify-center":!0,"aspect-[1/1]":!0,"[line-height:1.25rem]":!0,"text-white":!0,"rounded-full":!0,"group-data-[valid=true]/tab:bg-accent-500":!0,"group-data-[tab-style=tab]/wrapper:text-[0.66rem]":!0,"group-data-[tab-style=tab]/wrapper:p-1.5":!0,"group-data-[tab-style=tab]/wrapper:w-5":!0,"group-data-[tab-style=tab]/wrapper:h-5":!0,"group-data-[tab-style=tab]/wrapper:top-1.5":!0,"group-data-[tab-style=tab]/wrapper:right-1.5":!0,"group-data-[tab-style=progress]/wrapper:w-[1.25rem]":!0,"group-data-[tab-style=progress]/wrapper:h-[1.25rem]":!0,"group-data-[tab-style=progress]/wrapper:p-1":!0,"group-data-[tab-style=progress]/wrapper:text-[10px]":!0,"group-data-[tab-style=progress]/wrapper:[line-height:0]":!0,"group-data-[tab-style=progress]/wrapper:z-10":!0},"multi-step__validStepIcon":{"w-full":!0,"h-full":!0,"mt-0.5":!0},"multi-step__steps":{"px-10":!0,"pt-8":!0,"pb-4":!0,"bg-white":!0,border:!0,"border-zinc-200":!0,"rounded-sm":!0,"dark:bg-transparent":!0,"dark:border-zinc-800":!0,"group-data-[tab-style=tab]/wrapper:border-t-0":!0,"group-data-[tab-style=tab]/wrapper:rounded-tl-none":!0,"group-data-[tab-style=tab]/wrapper:rounded-tr-none":!0,"group-data-[tab-style=progress]/wrapper:shadow-none":!0,"[&_[data-type]]:max-w-none":!0},step__stepActions:{flex:!0,"justify-between":!0,"[&>*]:grow-0":!0},step__stepPrevious:{"mr-1.5":!0},step__stepNext:{"ml-auto":!0}},ko={outer:{group:!0,"max-w-none":!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"data-[disabled]:opacity-50":!0,"text-sm":!0},label:{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"mb-1":!0,"dark:text-zinc-300":!0},legend:{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"dark:text-zinc-300":!0},input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0},prefixIcon:{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0},suffixIcon:{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0},loaderIcon:{"animate-spin":!0,flex:!0,"items-center":!0,"my-auto":!0,"ml-2":!0,"text-sm":!0,"text-zinc-500":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0},loadMoreInner:{flex:!0,"text-xs":!0,"text-zinc-500":!0,"p-2":!0,"items-center":!0,"justify-center":!0,"[&>span]:mr-2":!0},help:{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-zinc-400":!0},message:{"text-red-500":!0,"mb-1.5":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-red-400":!0},overlay:{"text-zinc-700":!0,"dark:text-zinc-300":!0},overlayPlaceholder:{"text-zinc-400":!0,"dark:text-zinc-400/50":!0},overlayLiteral:{"text-zinc-700":!0,"dark:text-zinc-300":!0},overlayChar:{"text-zinc-700":!0,"dark:text-zinc-300":!0},overlayEnum:{"text-zinc-700":!0,"dark:text-zinc-300":!0},searchInput__input:{"w-full":!0,"bg-transparent":!0,border:!0,"border-zinc-200":!0,"dark:border-zinc-700":!0,"rounded-lg":!0,"focus:outline-none":!0,"focus:ring-2":!0,"focus:ring-accent-500/30":!0,"focus:border-accent-500":!0,"dark:focus:border-accent-400":!0,"transition-all":!0,"placeholder:text-zinc-400":!0,"disabled:opacity-50":!0,"disabled:cursor-not-allowed":!0,"pl-9":!0,"pr-9":!0,"py-2":!0,"text-sm":!0},"searchInput__input--sm":{"pl-7":!0,"pr-7":!0,"py-1.5":!0,"text-xs":!0},searchInput__icon:{absolute:!0,"left-3":!0,"top-1/2":!0,"-translate-y-1/2":!0,"text-zinc-400":!0,"w-4":!0,"h-4":!0},"searchInput__icon--sm":{"left-2":!0,"w-3.5":!0,"h-3.5":!0},searchInput__clearButton:{absolute:!0,"right-2.5":!0,"top-1/2":!0,"-translate-y-1/2":!0,"p-1":!0,"rounded-md":!0,"hover:bg-zinc-100":!0,"dark:hover:bg-zinc-800":!0,"transition-colors":!0},searchInput__clearIcon:{"w-3.5":!0,"h-3.5":!0,"text-zinc-400":!0,"hover:text-zinc-600":!0,"dark:hover:text-zinc-300":!0},selectSearch__button:{"w-full":!0,"min-w-[200px]":!0,"px-3":!0,"py-2":!0,"text-left":!0,"rounded-lg":!0,"focus:outline-none":!0,"focus:ring-2":!0,"focus:ring-accent-500/30":!0,"bg-transparent":!0,"disabled:opacity-50":!0,"disabled:cursor-not-allowed":!0,"text-sm":!0,"overflow-hidden":!0,"transition-colors":!0,border:!0,"border-zinc-200":!0,"dark:border-zinc-700":!0,"focus:border-accent-500":!0,"dark:focus:border-accent-400":!0}};function wo(t){const o=String(t.value||"");return o?/^[a-z][a-z0-9_]*$/.test(o):!0}function _o(t){const o=t.value;if(o===""||o===null||o===void 0)return!0;const a=Number(o);return a>0&&Number.isInteger(a)}function $o(t){const o=t.value;return o===""||o===null||o===void 0?!0:Number(o)>=0}function Co(t){const o=String(t.value||"");if(!o.trim())return!0;try{return JSON.parse(o),!0}catch{return!1}}function So(t){const o=String(t.value||"");if(!o)return!0;try{return new URL(o),!0}catch{return!1}}function To(t){const o=String(t.value||"");return o?o.length>=10&&!/\s/.test(o):!0}const Io={snakeCase:wo,positiveInteger:_o,nonNegative:$o,validJson:Co,validUrl:So,apiKey:To},zo={snakeCase({name:t}){return`${t} must be in snake_case format (lowercase letters, numbers, and underscores, starting with a letter).`},positiveInteger({name:t}){return`${t} must be a positive whole number.`},nonNegative({name:t}){return`${t} must be zero or greater.`},validJson({name:t}){return`${t} must be valid JSON.`},validUrl({name:t}){return`${t} must be a valid URL.`},apiKey({name:t}){return`${t} must be at least 10 characters with no spaces.`}},wt=me({__name:"DropShadow",props:{offsetX:{default:8},offsetY:{default:8},intensity:{default:.5},pattern:{default:"crosshatch"}},setup(t){const o=t,a=p(),i=p(),l=p(),u=p(0),s=(c,f,y,b,v,d)=>{c.beginPath(),c.moveTo(f+d,y),c.lineTo(f+b-d,y),c.quadraticCurveTo(f+b,y,f+b,y+d),c.lineTo(f+b,y+v-d),c.quadraticCurveTo(f+b,y+v,f+b-d,y+v),c.lineTo(f+d,y+v),c.quadraticCurveTo(f,y+v,f,y+v-d),c.lineTo(f,y+d),c.quadraticCurveTo(f,y,f+d,y),c.closePath()},m=async()=>{if(await Le(),!a.value||!i.value||!l.value)return;const c=a.value.getContext("2d");if(!c)return;const f=l.value.getBoundingClientRect(),y=l.value.firstElementChild;if(y){const k=getComputedStyle(y);u.value=parseFloat(k.borderRadius)||0}const b=f.width+o.offsetX+4,v=f.height+o.offsetY+4;a.value.width=b,a.value.height=v,a.value.style.width=`${b}px`,a.value.style.height=`${v}px`,c.clearRect(0,0,a.value.width,a.value.height);const d=document.documentElement.classList.contains("dark");if(c.fillStyle=d?"#6b7280":"black",c.globalAlpha=o.intensity,c.save(),s(c,o.offsetX,o.offsetY,f.width,f.height,u.value),c.clip(),o.pattern==="crosshatch"){const k=d?4:3;c.lineWidth=1,c.strokeStyle=d?"#6b7280":"black";for(let g=-f.height;g<f.width;g+=k)c.beginPath(),c.moveTo(o.offsetX+g,o.offsetY),c.lineTo(o.offsetX+g+f.height,o.offsetY+f.height),c.stroke();for(let g=0;g<f.width+f.height;g+=k)c.beginPath(),c.moveTo(o.offsetX+g,o.offsetY+f.height),c.lineTo(o.offsetX+g-f.height,o.offsetY),c.stroke()}else if(o.pattern==="dots"){const g=d?3:2,_=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];for(let L=0;L<f.width;L+=g)for(let R=0;R<f.height;R+=g){const K=Math.floor(L/g)%4,Y=Math.floor(R/g)%4;_[Y][K]/16<o.intensity&&c.fillRect(o.offsetX+L,o.offsetY+R,1,1)}}else if(o.pattern==="diagonal"){const k=d?5:4;c.lineWidth=1,c.strokeStyle=d?"#6b7280":"black";for(let g=-f.height;g<f.width;g+=k)c.beginPath(),c.moveTo(o.offsetX+g,o.offsetY),c.lineTo(o.offsetX+g+f.height,o.offsetY+f.height),c.stroke()}c.restore()};let h=null,x=null;return Pe(()=>{h=new ResizeObserver(()=>{m()}),l.value&&h.observe(l.value),m(),x=new MutationObserver(()=>{m()}),x.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]})}),Ye(()=>{l.value&&h&&h.unobserve(l.value),x&&x.disconnect()}),ge(()=>[o.offsetX,o.offsetY,o.intensity,o.pattern],()=>{m()}),(c,f)=>(r(),n("div",{ref_key:"container",ref:i,class:"relative",style:st({paddingRight:`${t.offsetX}px`,paddingBottom:`${t.offsetY}px`})},[e("canvas",{ref_key:"canvas",ref:a,class:"absolute top-0 left-0 pointer-events-none"},null,512),e("div",{ref_key:"contentEl",ref:l,class:"relative"},[je(c.$slots,"default")],512)],4))}}),Vo={class:"prompt-input-container relative"},Mo=["contenteditable","data-placeholder"],Eo={class:"bg-white dark:bg-zinc-900 border border-zinc-300 dark:border-zinc-700 rounded-sm overflow-hidden min-w-[240px] max-w-[320px]"},Lo={key:0,class:"p-3 text-sm text-neutral-500"},Po={key:1,class:"p-3 text-sm text-neutral-500"},Ao={key:2,class:"max-h-[220px] overflow-y-auto"},jo=["onClick"],Do={class:"font-medium flex items-center gap-2"},Oo=["title"],Ro={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},Uo={key:1,class:"text-xs text-red-600 dark:text-red-400 mt-1"},Bo={class:"text-xs mt-1"},Fo=me({__name:"PromptInput",props:{modelValue:{},search:{},placeholder:{default:"Type @ to insert variables or prompts..."},disabled:{type:Boolean,default:!1},maxLength:{},allowedTypes:{default:()=>["variable","prompt"]},editorClass:{}},emits:["update:modelValue","segment-click"],setup(t,{emit:o}){const a=t,i=o,l=p(),u=p(),s=ya({segments:a.modelValue&&a.modelValue.length?a.modelValue:[{type:"string",value:""}],dialogOpen:!1,dialogPosition:{x:0,y:0},searchQuery:"",searchResults:[],selectedIndex:0,isSearching:!1,atTriggerIndex:-1,isComposing:!1,ignoreNextWatch:!1}),m=()=>Math.random().toString(36).slice(2)+Date.now().toString(36),h=E=>E.type==="string"?"":`@${E.type==="variable"?E.label||E.value:E.label||E.id}`,x=()=>{const E=window.getSelection();if(!E||!E.rangeCount||!l.value)return null;const S=E.getRangeAt(0);let V=0;const re=Array.from(l.value.childNodes);for(let F=0;F<re.length;F++){const q=re[F];if(q===S.startContainer||q.contains?.(S.startContainer)){if(q.nodeType===Node.TEXT_NODE)return{segmentIndex:V,offset:S.startOffset};if(q.nodeType===Node.ELEMENT_NODE&&q.classList?.contains("prompt-tag"))return{segmentIndex:V,offset:0}}(q.nodeType===Node.TEXT_NODE||q.nodeType===Node.ELEMENT_NODE&&q.classList?.contains("prompt-tag"))&&V++}return{segmentIndex:0,offset:0}},c=()=>{if(!l.value)return;const E=s.segments.map(S=>{if(S.type==="string")return(S.value||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")||"";{const V=S._uid||(S._uid=m()),re=h(S),F=S.type==="variable"?{type:"variable",value:S.value,label:S.label,schema:S.schema,meta:S.meta}:{type:"prompt",id:S.id,label:S.label,schema:S.schema,meta:S.meta},q=encodeURIComponent(JSON.stringify(F)),N=S.type==="prompt"&&S.meta&&!S.meta.isValid,J=N?'<span class="prompt-tag-warning" title="'+(S.meta.validationMessage||"").replace(/"/g,"&quot;")+'">⚠️</span>':"";return`<span class="prompt-tag prompt-tag-clickable${N?" prompt-tag-invalid":""}" contenteditable="false" data-segment-uid="${V}" data-segment="${q}">${re}${J}</span>`}}).join("");l.value.innerHTML=E||"<br>"},f=()=>{const E=[];for(const S of s.segments)S.type==="string"&&E.length>0&&E[E.length-1].type==="string"?E[E.length-1].value+=S.value:E.push(S);s.segments=E.length?E:[{type:"string",value:""}]},y=E=>{const S=E.dataset.segmentUid;let V=s.segments.find(re=>re._uid===S);if(!V){const re=E.dataset.segment;if(re)try{const F=JSON.parse(decodeURIComponent(re));F&&(F.type==="variable"||F.type==="prompt")&&(V=F.type==="variable"?{type:"variable",value:F.value,label:F.label,schema:F.schema,meta:F.meta,_uid:S}:{type:"prompt",id:F.id,label:F.label,schema:F.schema,meta:F.meta,_uid:S})}catch{}}return V||null},b=E=>{const S=E.target;if(S.classList?.contains("prompt-tag")){const V=y(S);V&&i("segment-click",V,E)}},v=E=>{if(s.isComposing)return;const S=E.target,V=[];let re="";const F=()=>{re.length>0&&(V.push({type:"string",value:re}),re="")},q=W=>{if(W.nodeType===Node.TEXT_NODE){const M=(W.textContent||"").replace(/\u00A0/g," ");re+=M;return}if(W.nodeType===Node.ELEMENT_NODE){const M=W;if(M.classList?.contains("prompt-tag")){F();const A=y(M);A&&V.push(A);return}if(M.tagName==="BR"){re+=`
2
+ `;return}const ne=Array.from(M.childNodes);for(const A of ne)q(A);(M.tagName==="DIV"||M.tagName==="P"||M.tagName==="LI")&&M.nextSibling&&(re+=`
3
+ `);return}},N=Array.from(S.childNodes);for(const W of N)q(W);F();const U=V.some(W=>W.type!=="string")?V:[{type:"string",value:(S.innerText||"").replace(/\r\n/g,`
4
+ `)}];s.segments=U.length?U:[{type:"string",value:""}],f(),d(),ee()},d=()=>{const E=window.getSelection();if(!E||!E.rangeCount||!l.value)return;const S=E.getRangeAt(0);if(S.startContainer.nodeType!==Node.TEXT_NODE){s.dialogOpen&&g();return}const re=S.startContainer.textContent||"",F=S.startOffset;if(F>0&&re[F-1]==="@")s.atTriggerIndex=F-1,s.searchQuery="",k(),R("");else if(s.dialogOpen&&s.atTriggerIndex>=0)if(S.startContainer.nodeType===Node.TEXT_NODE){const q=S.startContainer.textContent||"",N=S.startOffset;if(N<=s.atTriggerIndex){g();return}const J=q.substring(0,N);if(J.length>s.atTriggerIndex&&J[s.atTriggerIndex]==="@"){const U=J.substring(s.atTriggerIndex+1);U.includes(" ")||U.includes(`
5
+ `)||U.length>s.searchQuery.length+5?g():(s.searchQuery=U,R(U))}else g()}else g()},k=async()=>{s.dialogOpen=!0,s.selectedIndex=0,await Le(),_()},g=()=>{s.dialogOpen=!1,s.searchResults=[],s.searchQuery="",s.atTriggerIndex=-1,s.isSearching=!1},_=()=>{if(!u.value||!l.value)return;const E=window.getSelection();if(!E||!E.rangeCount)return;const V=E.getRangeAt(0).getBoundingClientRect(),re=l.value.getBoundingClientRect();s.dialogPosition={x:V.left-re.left,y:V.bottom-re.top+4}};let L=null;const R=async E=>{if(!a.search){s.searchResults=[];return}L&&clearTimeout(L),s.isSearching=!0,L=setTimeout(async()=>{try{const S=await a.search(E);s.searchResults=(S||[]).filter(V=>a.allowedTypes?.includes(V.type))}catch(S){console.error("Search error:",S),s.searchResults=[]}finally{s.isSearching=!1}},200)},K=E=>E.type==="variable"?{type:"variable",value:E.value??E.id??"",label:E.label,schema:E.schema,_uid:m(),meta:E.meta}:{type:"prompt",id:E.id??E.value??"",label:E.label,schema:E.schema,_uid:m(),meta:E.meta},Y=E=>{if(s.atTriggerIndex<0||!l.value)return;const S=window.getSelection();if(!S||!S.rangeCount)return;const V=S.getRangeAt(0);if(V.startContainer.nodeType!==Node.TEXT_NODE)return;const re=V.startContainer,F=re.data.slice(0,s.atTriggerIndex),q=re.data.slice(V.startOffset),N=document.createElement("span"),J=K(E),U=J.type==="prompt"&&J.meta&&!J.meta.isValid;N.className=`prompt-tag${U?" prompt-tag-invalid":""}`,N.setAttribute("contenteditable","false");const W=J._uid||(J._uid=m());N.dataset.segmentUid=W;const M=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(N.dataset.segment=encodeURIComponent(JSON.stringify(M)),N.textContent=h(J),U){const ke=document.createElement("span");ke.className="prompt-tag-warning",ke.textContent="⚠️",ke.setAttribute("title",J.meta.validationMessage||"Validation error"),N.appendChild(ke)}const ne=re.parentNode,A=document.createTextNode(q),ce=document.createTextNode(F);ne.insertBefore(ce,re),ne.insertBefore(N,re),ne.insertBefore(A,re),ne.removeChild(re),g(),v({target:l.value});const ue=window.getSelection();if(ue){const ke=document.createRange();ke.setStart(A,0),ke.collapse(!0),ue.removeAllRanges(),ue.addRange(ke)}l.value.focus()},z=E=>{if((E.key==="ArrowLeft"||E.key==="ArrowRight")&&setTimeout(()=>d(),0),s.dialogOpen)E.key==="ArrowDown"?(E.preventDefault(),s.selectedIndex=Math.min(s.selectedIndex+1,s.searchResults.length-1)):E.key==="ArrowUp"?(E.preventDefault(),s.selectedIndex=Math.max(s.selectedIndex-1,0)):E.key==="Enter"?(E.preventDefault(),s.searchResults[s.selectedIndex]&&Y(s.searchResults[s.selectedIndex])):(E.key==="Escape"||E.key==="Esc")&&(E.preventDefault(),g());else if(E.key==="Backspace"||E.key==="Delete"){const S=x();if(E.key==="Backspace"){const V=window.getSelection();if(V&&V.rangeCount){const re=V.getRangeAt(0);if(re.collapsed&&re.startContainer.nodeType===Node.TEXT_NODE&&re.startOffset===0){let F=re.startContainer;for(;F&&F!==l.value;){const q=F.previousSibling;if(q&&q.nodeType===Node.ELEMENT_NODE&&q.classList?.contains("prompt-tag")){E.preventDefault(),q.parentNode?.removeChild(q),v({target:l.value});return}F=F.parentNode}}}}if(!S)return;if(E.key==="Backspace"&&S.offset===0&&S.segmentIndex>0)s.segments[S.segmentIndex-1].type!=="string"&&(E.preventDefault(),s.segments.splice(S.segmentIndex-1,1),f(),ee(),c());else if(E.key==="Delete"&&S.segmentIndex<s.segments.length-1){const V=s.segments[S.segmentIndex];V.type==="string"&&(V.value?.length??0)===S.offset&&s.segments[S.segmentIndex+1].type!=="string"&&(E.preventDefault(),s.segments.splice(S.segmentIndex+1,1),f(),ee(),c())}}},P=E=>{E.preventDefault();const S=E.clipboardData?.getData("text/plain")||"";document.execCommand("insertText",!1,S)},G=E=>{if(!s.dialogOpen)return;const S=u.value;S&&(S.contains(E.target)||g())},ee=()=>{s.ignoreNextWatch=!0;const E=s.segments.map(S=>{const{_uid:V,...re}=S||{};return re});i("update:modelValue",E)},se=()=>{const E=window.getSelection();if(!E||!l.value)return;const S=E.anchorNode;S&&l.value.contains(S)&&d()},de=E=>{(E.key==="Escape"||E.key==="Esc")&&s.dialogOpen&&(E.preventDefault(),g())};Pe(()=>{a.modelValue&&a.modelValue.length&&(s.segments=JSON.parse(JSON.stringify(a.modelValue))),c(),document.addEventListener("mousedown",G),document.addEventListener("selectionchange",se),document.addEventListener("keydown",de,!0)}),Ye(()=>{document.removeEventListener("mousedown",G),document.removeEventListener("selectionchange",se),document.removeEventListener("keydown",de,!0)}),ge(()=>a.modelValue,E=>{if(s.ignoreNextWatch){s.ignoreNextWatch=!1;return}E&&(s.segments=JSON.parse(JSON.stringify(E)),c())},{deep:!0});const Q=B(()=>{const E=["prompt-input-editor","min-h-[100px]",a.disabled?"opacity-50 cursor-not-allowed":""];return a.editorClass?[...E,a.editorClass,"!h-auto"]:[...E,"py-2 px-3","rounded-sm","border border-zinc-300 dark:border-zinc-700","bg-white dark:bg-transparent","text-sm text-zinc-700 dark:text-zinc-300","focus:outline-none focus:ring-1 focus:ring-accent-400 focus:border-accent-400"]});return(E,S)=>(r(),n("div",Vo,[e("div",{ref_key:"editorRef",ref:l,contenteditable:!t.disabled,onInput:v,onKeydown:z,onPaste:P,onClick:b,onKeyup:S[0]||(S[0]=V=>{V.key==="Escape"?(V.preventDefault(),g()):(V.key==="ArrowLeft"||V.key==="ArrowRight")&&d()}),onCompositionstart:S[1]||(S[1]=V=>s.isComposing=!0),onCompositionend:S[2]||(S[2]=V=>s.isComposing=!1),class:ae(Q.value),"data-placeholder":t.placeholder},[Ae(e("div",null,[je(E.$slots,"segment",{segment:null},void 0,!0)],512),[[Ke,!1]])],42,Mo),s.dialogOpen?(r(),n("div",{key:0,ref_key:"dialogRef",ref:u,class:"absolute z-50",style:st({left:`${s.dialogPosition.x}px`,top:`${s.dialogPosition.y}px`})},[w(wt,{"offset-x":4,"offset-y":4,intensity:.3},{default:D(()=>[e("div",Eo,[s.isSearching?(r(),n("div",Lo," Searching... ")):s.searchResults.length===0?(r(),n("div",Po," No results found ")):(r(),n("div",Ao,[(r(!0),n(ve,null,ye(s.searchResults,(V,re)=>(r(),n("button",{key:V.id||V.value||re,type:"button",onClick:F=>Y(V),class:ae(["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",s.selectedIndex===re?"bg-neutral-100 dark:bg-neutral-900":""])},[e("div",Do,[Z(C(V.label||V.id||V.value)+" ",1),V.type==="prompt"&&V.meta&&!V.meta.isValid?(r(),n("span",{key:0,title:V.meta.validationMessage,class:"text-red-500"},"⚠️",8,Oo)):I("",!0)]),V.description?(r(),n("div",Ro,C(V.description),1)):I("",!0),V.type==="prompt"&&V.meta&&!V.meta.isValid?(r(),n("div",Uo,C(V.meta.validationMessage),1)):I("",!0),e("div",Bo,[e("span",{class:ae(["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,jo))),128))]))])]),_:1})],4)):I("",!0)]))}}),Xe=(t,o)=>{const a=t.__vccOpts||t;for(const[i,l]of o)a[i]=l;return a},Gt=Xe(Fo,[["__scopeId","data-v-daddc895"]]),No=me({__name:"PromptInputWrapper",props:{context:{}},emits:["segment-click"],setup(t,{emit:o}){const a=t,i=(b,v)=>{const d=a.context;return d[b]!==void 0?d[b]:d.attrs?.[b]!==void 0?d.attrs[b]:v},l=B(()=>a.context.classes??{}),u=B(()=>a.context._value??[]),s=b=>{a.context.node.input(b)},m=B(()=>i("search",void 0)),h=B(()=>i("placeholder","Type @ to insert variables or prompts...")),x=B(()=>i("maxLength",void 0)),c=B(()=>i("allowedTypes",["variable","prompt"])),f=B(()=>a.context.disabled??!1),y=(b,v)=>{const d=a.context;d.attrs?.["onSegment-click"]&&d.attrs["onSegment-click"](b,v)};return(b,v)=>(r(),H(Gt,{"model-value":u.value,search:m.value,placeholder:h.value,disabled:f.value,"max-length":x.value,"allowed-types":c.value,"editor-class":l.value.inner,"onUpdate:modelValue":s,onSegmentClick:y},null,8,["model-value","search","placeholder","disabled","max-length","allowed-types","editor-class"]))}}),qo={type:"input",family:"text",props:["search","placeholder","maxLength","allowedTypes"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$el:"p",if:"$help",attrs:{class:"$classes.help"},children:"$help"},{$cmp:Ie(No),props:{context:"$node.context"}}]},Ho={class:"inline-flex items-center justify-center"},Ee=me({__name:"Loader",props:{size:{default:"md"}},setup(t){const o=t,a=B(()=>{switch(o.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(i,l)=>(r(),n("div",Ho,[e("div",{class:ae([a.value,"border-black/20 dark:border-white/20 border-t-black dark:border-t-white rounded-full animate-spin"])},null,2)]))}}),Wo=["type","disabled"],Ko="inline-flex items-center justify-center gap-2 font-medium rounded transition-all disabled:opacity-50 disabled:cursor-not-allowed",De=me({__name:"UiButton",props:{variant:{default:"primary"},size:{default:"md"},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},iconLeft:{},iconRight:{},fullWidth:{type:Boolean,default:!1},type:{default:"button"}},emits:["click"],setup(t,{emit:o}){const a=t,i=o,l=B(()=>{switch(a.variant){case"primary":return"bg-black text-white dark:bg-white dark:text-black hover:opacity-90";case"secondary":return"border-2 border-black dark:border-neutral-300 bg-white dark:bg-black text-black dark:text-white hover:bg-neutral-50 dark:hover:bg-neutral-900";case"ghost":return"border border-black dark:border-white hover:bg-black/5 dark:hover:bg-white/10";case"danger":return"border-2 border-red-600 bg-red-600 text-white hover:bg-red-700 hover:border-red-700";case"link":return"text-accent-600 dark:text-accent-400 hover:underline p-0";default:return""}}),u=B(()=>{if(a.variant==="link")return"text-sm";switch(a.size){case"xs":return"px-2 py-1 text-xs";case"sm":return"px-3 py-1.5 text-sm";case"md":return"px-4 py-2 text-sm";case"lg":return"px-6 py-3 text-base";default:return""}}),s=B(()=>a.size==="xs"||a.size==="sm"?"xs":"sm"),m=h=>{!a.disabled&&!a.loading&&i("click",h)};return(h,x)=>(r(),n("button",{type:t.type,disabled:t.disabled||t.loading,class:ae([Ko,l.value,u.value,t.fullWidth?"w-full":""]),onClick:m},[t.loading?(r(),H(Ee,{key:0,size:s.value},null,8,["size"])):t.iconLeft?(r(),H(Ue(t.iconLeft),{key:1,class:"w-4 h-4"})):I("",!0),je(h.$slots,"default"),t.iconRight&&!t.loading?(r(),H(Ue(t.iconRight),{key:2,class:"w-4 h-4"})):I("",!0)],10,Wo))}}),Jo=["disabled","aria-label","title"],Yo="inline-flex items-center justify-center rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed",Br=me({__name:"UiIconButton",props:{icon:{},label:{},size:{default:"sm"},variant:{default:"default"},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},emits:["click"],setup(t,{emit:o}){const a=t,i=o,l=B(()=>{switch(a.variant){case"default":return"hover:bg-black/10 dark:hover:bg-white/10";case"ghost":return"hover:bg-black/5 dark:hover:bg-white/5";case"danger":return"text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20";default:return""}}),u=B(()=>{switch(a.size){case"xs":return"p-0.5";case"sm":return"p-1";case"md":return"p-1.5";default:return""}}),s=B(()=>{switch(a.size){case"xs":return"w-3.5 h-3.5";case"sm":return"w-4 h-4";case"md":return"w-5 h-5";default:return""}}),m=h=>{!a.disabled&&!a.loading&&i("click",h)};return(h,x)=>(r(),n("button",{type:"button",disabled:t.disabled||t.loading,"aria-label":t.label,title:t.label,class:ae([Yo,l.value,u.value]),onClick:m},[t.loading?(r(),H(Ee,{key:0,size:"xs"})):(r(),H(Ue(t.icon),{key:1,class:ae(s.value)},null,8,["class"]))],10,Jo))}}),Go=["for"],Zo={key:0,class:"text-red-500 ml-0.5"},Fr=me({__name:"UiLabel",props:{required:{type:Boolean,default:!1},htmlFor:{}},setup(t){return(o,a)=>(r(),n("label",{for:t.htmlFor,class:"block text-sm font-medium text-neutral-700 dark:text-neutral-300"},[je(o.$slots,"default"),t.required?(r(),n("span",Zo,"*")):I("",!0)],8,Go))}}),Xo={class:"text-xs text-red-500 dark:text-red-400"},tt=me({__name:"UiErrorText",setup(t){return(o,a)=>(r(),n("p",Xo,[je(o.$slots,"default")]))}}),Qo={class:"text-xs text-neutral-500 dark:text-neutral-400"},ze=me({__name:"UiHelpText",setup(t){return(o,a)=>(r(),n("p",Qo,[je(o.$slots,"default")]))}}),en={class:"space-y-1.5"},ct=me({__name:"UiFormField",props:{label:{},error:{},helpText:{},required:{type:Boolean,default:!1},htmlFor:{}},setup(t){return(o,a)=>(r(),n("div",en,[je(o.$slots,"label",{},()=>[t.label?(r(),H(Fr,{key:0,"html-for":t.htmlFor,required:t.required},{default:D(()=>[Z(C(t.label),1)]),_:1},8,["html-for","required"])):I("",!0)]),je(o.$slots,"default"),je(o.$slots,"error",{},()=>[t.error?(r(),H(tt,{key:0},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)]),je(o.$slots,"help",{},()=>[t.helpText&&!t.error?(r(),H(ze,{key:0},{default:D(()=>[Z(C(t.helpText),1)]),_:1})):I("",!0)])]))}}),tn={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function rn(t,o){return r(),n("svg",tn,[...o[0]||(o[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 Pt=Ie({name:"lucide-x",render:rn}),an={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function on(t,o){return r(),n("svg",an,[...o[0]||(o[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)])])}Ie({name:"lucide-info",render:on});const nn={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ln(t,o){return r(),n("svg",nn,[...o[0]||(o[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:"m9 12l2 2l4-4"})],-1)])])}Ie({name:"lucide-circle-check",render:ln});const sn={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function un(t,o){return r(),n("svg",sn,[...o[0]||(o[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 ir=Ie({name:"lucide-triangle-alert",render:un}),dn={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function cn(t,o){return r(),n("svg",dn,[...o[0]||(o[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:"m15 9l-6 6m0-6l6 6"})],-1)])])}Ie({name:"lucide-circle-x",render:cn});const ft=me({__name:"UiBadge",props:{variant:{default:"default"},size:{default:"sm"},pill:{type:Boolean,default:!1}},setup(t){const o=t,a=B(()=>{switch(o.variant){case"default":return"bg-neutral-100 dark:bg-neutral-800 text-neutral-700 dark:text-neutral-300";case"primary":return"bg-black dark:bg-white text-white dark:text-black";case"secondary":return"bg-neutral-200 dark:bg-neutral-700 text-neutral-600 dark:text-neutral-300";case"success":return"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300";case"warning":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300";case"error":return"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300";case"accent":return"bg-accent-100 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300";default:return""}}),i=B(()=>{switch(o.size){case"sm":return"px-2 py-0.5 text-xs";case"md":return"px-2.5 py-1 text-sm";default:return""}});return(l,u)=>(r(),n("span",{class:ae(["inline-flex items-center font-medium",a.value,i.value,t.pill?"rounded-full":"rounded"])},[je(l.$slots,"default")],2))}}),pn={key:0,class:"border-b border-neutral-200 dark:border-neutral-700"},mn={key:1,class:"border-t border-neutral-200 dark:border-neutral-700"},At=me({__name:"UiDropdownPanel",props:{width:{},maxHeight:{},shadow:{type:[Boolean,Object],default:!0}},setup(t){const o=t,a=B(()=>o.shadow===!0?{offsetX:6,offsetY:6,intensity:.4}:o.shadow&&typeof o.shadow=="object"?o.shadow:null),i=B(()=>!!o.shadow),l=B(()=>["bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-600 rounded-lg overflow-hidden",o.width]),u=B(()=>[o.maxHeight?"overflow-y-auto":"",o.maxHeight]);return(s,m)=>(r(),H(Ue(i.value?wt:"template"),ka(wa(i.value?a.value:{})),{default:D(()=>[e("div",{class:ae(l.value)},[s.$slots.header?(r(),n("div",pn,[je(s.$slots,"header")])):I("",!0),e("div",{class:ae(u.value)},[je(s.$slots,"default")],2),s.$slots.footer?(r(),n("div",mn,[je(s.$slots,"footer")])):I("",!0)],2)]),_:3},16))}}),vn={class:"flex items-start gap-3"},fn={class:"flex-1 text-sm"},Fe=me({__name:"UiAlertBox",props:{variant:{default:"info"},showIcon:{type:Boolean,default:!0}},setup(t){const o=t,a=B(()=>{switch(o.variant){case"warning":return"bg-amber-50 dark:bg-amber-900/20 border-amber-200 dark:border-amber-800 text-amber-800 dark:text-amber-300";case"success":return"bg-emerald-50 dark:bg-emerald-900/20 border-emerald-200 dark:border-emerald-800 text-emerald-800 dark:text-emerald-300";case"error":return"bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800 text-red-800 dark:text-red-300";case"info":default:return"bg-neutral-50 dark:bg-neutral-900/50 border-neutral-200 dark:border-neutral-700 text-neutral-700 dark:text-neutral-300"}}),i=B(()=>{switch(o.variant){case"warning":return Sr;case"success":return $a;case"error":return _a;case"info":default:return Cr}}),l=B(()=>{switch(o.variant){case"warning":return"text-amber-500 dark:text-amber-400";case"success":return"text-emerald-500 dark:text-emerald-400";case"error":return"text-red-500 dark:text-red-400";case"info":default:return"text-neutral-500 dark:text-neutral-400"}});return(u,s)=>(r(),n("div",{class:ae(["px-4 py-3 border rounded-lg",a.value])},[e("div",vn,[t.showIcon?(r(),H(Ue(i.value),{key:0,class:ae(["w-5 h-5 mt-0.5 flex-shrink-0",l.value])},null,8,["class"])):I("",!0),e("div",fn,[je(u.$slots,"default")])])],2))}}),ur=me({__name:"UiMenuItem",props:{active:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},as:{default:"button"}},emits:["click"],setup(t,{emit:o}){const a=t,i=o;function l(u){a.disabled||i("click",u)}return(u,s)=>(r(),H(Ue(t.as),{type:t.as==="button"?"button":void 0,disabled:t.as==="button"?t.disabled:void 0,onClick:l,class:ae(["w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors",[t.disabled?"opacity-50 cursor-not-allowed":"hover:bg-neutral-100 dark:hover:bg-neutral-800 cursor-pointer",t.active?"bg-accent-50 dark:bg-accent-950/30":""]])},{default:D(()=>[je(u.$slots,"default")]),_:3},8,["type","disabled","class"]))}}),hn={class:"relative inline-flex group"},dr=me({__name:"UiTooltip",props:{content:{},position:{default:"top"}},setup(t){const o=t,a=B(()=>{switch(o.position){case"bottom":return"top-full mt-2 left-1/2 -translate-x-1/2";case"left":return"right-full mr-2 top-1/2 -translate-y-1/2";case"right":return"left-full ml-2 top-1/2 -translate-y-1/2";case"top":default:return"bottom-full mb-2 left-1/2 -translate-x-1/2"}}),i=B(()=>{switch(o.position){case"bottom":return"bottom-full left-1/2 -translate-x-1/2 border-b-black dark:border-b-white border-t-transparent border-l-transparent border-r-transparent";case"left":return"left-full top-1/2 -translate-y-1/2 border-l-black dark:border-l-white border-t-transparent border-b-transparent border-r-transparent";case"right":return"right-full top-1/2 -translate-y-1/2 border-r-black dark:border-r-white border-t-transparent border-b-transparent border-l-transparent";case"top":default:return"top-full left-1/2 -translate-x-1/2 border-t-black dark:border-t-white border-b-transparent border-l-transparent border-r-transparent"}});return(l,u)=>(r(),n("div",hn,[je(l.$slots,"default"),e("div",{class:ae(["absolute z-50 px-3 py-2 text-xs whitespace-nowrap bg-black dark:bg-white text-white dark:text-black rounded opacity-0 invisible group-hover:opacity-100 group-hover:visible group-focus-within:opacity-100 group-focus-within:visible transition-opacity pointer-events-none",a.value]),role:"tooltip"},[Z(C(t.content)+" ",1),e("div",{class:ae(["absolute border-4",i.value])},null,2)],2)]))}}),Nr=me({__name:"UiCodeBlock",props:{inline:{type:Boolean,default:!0}},setup(t){return(o,a)=>(r(),H(Ue(t.inline?"code":"pre"),{class:ae(["font-mono text-xs bg-neutral-100 dark:bg-neutral-800 rounded",t.inline?"px-1.5 py-0.5":"px-3 py-2 overflow-x-auto"])},{default:D(()=>[je(o.$slots,"default")]),_:3},8,["class"]))}}),gn={key:0,class:"block text-zinc-700 dark:text-zinc-300 text-xs font-bold mb-1"},bn={key:0,class:"text-red-500"},xn=["disabled","aria-expanded"],yn={key:0,class:"flex items-center gap-2 text-zinc-400 flex-1 min-w-0"},kn=["src","alt"],wn={class:"block truncate"},_n={key:2,class:"block truncate text-zinc-400 flex-1 min-w-0"},$n=["placeholder"],Cn=["onClick","onMouseenter"],Sn=["src","alt"],Tn={key:1,class:"w-full h-full bg-zinc-200 dark:bg-zinc-700 rounded"},In={class:"flex-1 min-w-0"},Ge=me({__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},triggerClass:{},size:{default:"md"},activeHighlight:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{emit:o}){const a=t,i=o,l=p(!1),u=p(""),s=p(),m=p(),h=p(),x=p(),c=p(-1),f=B(()=>a.options.find(G=>G.value===a.modelValue)),y=B(()=>{const G=a.activeHighlight&&f.value,ee=a.size==="sm"?"!text-xs !py-1 !px-2":"",se=G?"!border-accent-500 !bg-accent-50 dark:!bg-accent-950/50 !text-accent-700 dark:!text-accent-300":"";return a.triggerClass?[a.triggerClass,"text-left cursor-pointer",ee,se,a.error?"!border-red-500 dark:!border-red-400":""]:["w-full min-w-[200px] px-3 py-2 text-left rounded-lg focus:outline-none focus:ring-2 focus:ring-accent-500/30 bg-transparent disabled:opacity-50 disabled:cursor-not-allowed text-sm overflow-hidden transition-colors",ee,se,a.error?"border border-red-500 dark:border-red-400 focus:border-red-500 dark:focus:border-red-400":"border border-zinc-200 dark:border-zinc-700 focus:border-accent-500 dark:focus:border-accent-400"]}),b=B(()=>{if(!u.value)return a.options;const G=u.value.toLowerCase();return a.options.filter(ee=>ee.label.toLowerCase().includes(G)||ee.value.toLowerCase().includes(G)||ee.description&&ee.description.toLowerCase().includes(G))});ge(b,()=>{c.value=-1});const v=()=>{a.disabled||(l.value?g():(l.value=!0,u.value="",c.value=-1,Le(()=>{if(x.value&&(x.value.setAttribute("popover","auto"),x.value.addEventListener("toggle",z),"showPopover"in x.value))try{x.value.showPopover()}catch{}_(),setTimeout(()=>s.value?.focus(),0)})))},d=G=>{i("update:modelValue",G.value),g(),u.value="",c.value=-1},k=G=>{G.stopPropagation(),i("update:modelValue","")},g=()=>{if(x.value){if("hidePopover"in x.value)try{x.value.hidePopover()}catch{}x.value.removeEventListener("toggle",z)}l.value=!1,c.value=-1},_=()=>{if(!h.value||!x.value)return;const G=h.value.getBoundingClientRect(),ee=window.innerWidth;x.value.style.position="fixed",x.value.style.top=`${G.bottom+8}px`,x.value.style.left=`${G.left}px`,x.value.style.margin="0",x.value.style.width="max-content";const se=x.value.offsetWidth,de=G.width,Q=Math.min(400,ee-G.left-16),E=Math.max(de,Math.min(se,Q));x.value.style.width=`${E}px`},L=G=>{m.value&&!m.value.contains(G.target)&&x.value&&!x.value.contains(G.target)&&g()},R=G=>{G.key==="Escape"&&l.value&&(g(),h.value?.focus())},K=G=>{if(!l.value)return;const ee=b.value;if(ee.length!==0)switch(G.key){case"ArrowDown":G.preventDefault(),c.value=c.value<ee.length-1?c.value+1:0,Y();break;case"ArrowUp":G.preventDefault(),c.value=c.value>0?c.value-1:ee.length-1,Y();break;case"Enter":G.preventDefault(),c.value>=0&&c.value<ee.length&&d(ee[c.value]);break}},Y=()=>{Le(()=>{const G=x.value?.querySelector(".highlighted-option");G&&G.scrollIntoView({block:"nearest",behavior:"smooth"})})},z=G=>{G.target===x.value&&(l.value=G.newState==="open",l.value&&_())},P=()=>{l.value&&_()};return Pe(()=>{document.addEventListener("click",L),document.addEventListener("keydown",R),window.addEventListener("resize",P),window.addEventListener("scroll",P,!0)}),Ye(()=>{document.removeEventListener("click",L),document.removeEventListener("keydown",R),window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}),(G,ee)=>(r(),n("div",{ref_key:"dropdownRef",ref:m,class:"relative"},[t.label?(r(),n("label",gn,[Z(C(t.label)+" ",1),t.required?(r(),n("span",bn,"*")):I("",!0)])):I("",!0),e("button",{ref_key:"buttonRef",ref:h,type:"button",onClick:v,disabled:t.disabled,"aria-expanded":l.value,"aria-haspopup":!0,class:ae(y.value)},[e("div",{class:ae(["flex items-center gap-1 w-full",t.size==="sm"?"min-h-[1.25em]":"min-h-[1.5em]"])},[t.loading?(r(),n("span",yn,[w(Ee,{size:"xs"}),ee[1]||(ee[1]=Z(" Loading... ",-1))])):f.value?(r(),n("span",{key:1,class:ae(["flex items-center flex-1 min-w-0",t.size==="sm"?"gap-1.5":"gap-2"])},[f.value.icon?(r(),n("img",{key:0,src:f.value.icon,alt:f.value.label,class:ae(["flex-shrink-0",[t.size==="sm"?"w-4 h-4":"w-5 h-5",f.value.icon.startsWith("data:image/svg+xml")?"dark:invert":""]])},null,10,kn)):I("",!0),e("span",wn,C(f.value.label),1)],2)):(r(),n("span",_n,C(t.placeholder),1)),f.value&&!t.disabled?(r(),n("button",{key:3,type:"button",onClick:k,class:"flex-shrink-0 p-0.5 hover:bg-zinc-100 dark:hover:bg-zinc-800 rounded transition-colors","aria-label":"Clear selection"},[(r(),n("svg",{class:ae(["text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300",t.size==="sm"?"h-3 w-3":"h-4 w-4"]),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[...ee[2]||(ee[2]=[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"},null,-1)])],2))])):I("",!0),(r(),n("svg",{class:ae(["text-zinc-400 flex-shrink-0",t.size==="sm"?"h-3.5 w-3.5":"h-5 w-5"]),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[...ee[3]||(ee[3]=[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"},null,-1)])],2))],2)],10,xn),l.value?(r(),n("div",{key:1,ref_key:"popoverRef",ref:x,class:"dropdown-popover z-[9999]"},[w(T(At),{"max-height":t.size==="sm"?"max-h-48":"max-h-60",shadow:{offsetX:4,offsetY:4,intensity:.3}},{header:D(()=>[e("div",{class:ae(t.size==="sm"?"p-1.5":"p-2")},[Ae(e("input",{ref_key:"searchInput",ref:s,"onUpdate:modelValue":ee[0]||(ee[0]=se=>u.value=se),type:"text",placeholder:t.searchPlaceholder,onKeydown:K,class:ae(["w-full border border-zinc-300 dark:border-zinc-600 rounded-sm focus:outline-none focus:ring-1 focus:ring-accent-400 focus:border-accent-400 bg-transparent text-zinc-700 dark:text-zinc-200 placeholder:text-zinc-400 dark:placeholder:text-zinc-500",t.size==="sm"?"px-2 py-1 text-xs":"px-3 py-1.5 text-sm"])},null,42,$n),[[Qe,u.value]])],2)]),default:D(()=>[b.value.length===0?(r(),n("div",{key:0,class:ae(["text-zinc-500 dark:text-zinc-400",t.size==="sm"?"px-3 py-2 text-xs":"px-4 py-3 text-sm"])}," No options found ",2)):I("",!0),(r(!0),n(ve,null,ye(b.value,(se,de)=>(r(),n("button",{key:se.value,type:"button",onClick:Q=>d(se),onMouseenter:Q=>c.value=de,class:ae(["w-full text-left hover:bg-zinc-100 dark:hover:bg-zinc-800 focus:bg-zinc-100 dark:focus:bg-zinc-800 focus:outline-none flex items-start",[t.size==="sm"?"px-2.5 py-1.5 gap-2":"px-4 py-2 gap-3",{"bg-zinc-50 dark:bg-zinc-900":se.value===t.modelValue,"bg-zinc-100 dark:bg-zinc-800 highlighted-option":de===c.value}]])},[e("div",{class:ae(["flex-shrink-0 mt-0.5",t.size==="sm"?"w-4 h-4":"w-5 h-5"])},[se.icon?(r(),n("img",{key:0,src:se.icon,alt:se.label,class:ae(["w-full h-full",se.icon.startsWith("data:image/svg+xml")?"dark:invert":""])},null,10,Sn)):(r(),n("div",Tn))],2),e("div",In,[e("div",{class:ae(["font-medium text-black dark:text-white",t.size==="sm"?"text-xs":"text-sm"])},C(se.label),3),se.description?(r(),n("div",{key:0,class:ae(["text-zinc-500 dark:text-zinc-400 mt-0.5",t.size==="sm"?"text-[10px]":"text-xs"])},C(se.description),3)):I("",!0)])],42,Cn))),128))]),_:1},8,["max-height"])],512)):I("",!0),t.error?(r(),H(T(tt),{key:2,class:"mt-1"},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)],512))}}),zn=["type","value","placeholder","disabled"],lt=me({__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:o,emit:a}){const i=t,l=a,u=p(null),s=B(()=>["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",i.error?"border-red-500 dark:border-red-400":"border-neutral-300 dark:border-neutral-800",i.disabled?"opacity-50 cursor-not-allowed":""]),m=c=>{const f=c.target;l("update:modelValue",f.value)},h=c=>{l("focus",c)},x=c=>{l("click",c)};return o({inputRef:u}),(c,f)=>(r(),H(T(ct),{label:t.label,error:t.error,required:t.required},{default:D(()=>[e("input",{ref_key:"inputRef",ref:u,type:t.type,value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,class:ae(s.value),onInput:m,onFocus:h,onClick:x},null,42,zn)]),_:1},8,["label","error","required"]))}}),Vn=["data-property-id","data-nested-property-id"],Mn={class:"p-3 space-y-3"},En={class:"flex items-start gap-2"},Ln={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"},Pn={class:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2"},An={class:"flex items-center gap-2 mt-2"},jn=["disabled"],Dn={key:0},On={key:0,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg space-y-2"},Rn={class:"flex items-center justify-between mb-2"},Un=["disabled"],Bn={key:0,class:"space-y-1"},Fn=["onClick","disabled"],Nn={key:1,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},qn={class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"},Hn={class:"space-y-2"},Wn={class:"flex items-center justify-between"},Kn=["disabled"],Jn={class:"space-y-2"},Yn={key:2,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},Gn={key:0,class:"mb-2"},Zn=["disabled"],Xn={key:1,class:"space-y-2"},Qn=me({__name:"PropertyEditor",props:Ze({propertyId:{},isNested:{type:Boolean,default:!1},parentId:{},disabled:{type:Boolean,default:!1},enableDrag:{type:Boolean,default:!0}},{modelValue:{required:!0},modelModifiers:{}}),emits:Ze(["remove","description-keydown","add-top-level"],["update:modelValue"]),setup(t,{emit:o}){const a=t,i=o,l=it(t,"modelValue"),u=p(["object","array","enum","anyOf"].includes(l.value.type));p();const s=[{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"}],m=B(()=>["object","array","enum","anyOf"].includes(l.value.type));ge(()=>l.value.type,async(v,d)=>{if(["object","array","enum","anyOf"].includes(v)&&(u.value=!0,v==="anyOf"&&!l.value.anyOf&&(l.value.anyOf=[]),v==="object"&&!l.value.properties&&(l.value.properties=[{id:crypto.randomUUID(),name:"property1",type:"string",description:""}]),v==="array"&&!l.value.items&&(l.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""}),v==="enum"&&!l.value.enum&&(l.value.enum=["value1"])),d!==void 0){await Le();const k=a.isNested?`[data-nested-property-id="${a.propertyId}"] input[placeholder="Description"]`:`[data-property-id="${a.propertyId}"] input[placeholder="Description"]`,g=document.querySelector(k);g&&g.focus()}},{immediate:!0,flush:"sync"});const h=v=>{v.shiftKey&&l.value.type==="object"&&l.value.properties?y():i("add-top-level")},x=()=>{l.value.items||(l.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""})},c=()=>{l.value.enum||(l.value.enum=[]),l.value.enum.push(`value${l.value.enum.length+1}`)},f=v=>{l.value.enum&&l.value.enum.splice(v,1)},y=async()=>{const v={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(v)):(l.value.properties||(l.value.properties=[]),l.value.properties.push(v)),await Le();const d=document.querySelector(`[data-nested-property-id="${v.id}"] input[placeholder="Property name"]`);d&&(d.focus(),d.select())},b=v=>{l.value.type==="anyOf"&&l.value.anyOf?l.value.anyOf=l.value.anyOf.filter(d=>d.id!==v):l.value.properties&&(l.value.properties=l.value.properties.filter(d=>d.id!==v))};return(v,d)=>{const k=Be("PropertyEditor",!0);return r(),n("div",{"data-property-id":t.isNested?void 0:t.propertyId,"data-nested-property-id":t.isNested?t.propertyId:void 0,class:ae(["border rounded-lg",t.isNested?"border-neutral-100 dark:border-neutral-900":"border-neutral-200 dark:border-neutral-800"])},[e("div",Mn,[e("div",En,[t.enableDrag?(r(),n("div",Ln,[...d[10]||(d[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)])])):I("",!0),e("div",Pn,[w(lt,{modelValue:l.value.name,"onUpdate:modelValue":d[0]||(d[0]=g=>l.value.name=g),placeholder:"Property name",disabled:t.disabled},null,8,["modelValue","disabled"]),w(Ge,{modelValue:l.value.type,"onUpdate:modelValue":d[1]||(d[1]=g=>l.value.type=g),options:s,disabled:t.disabled},null,8,["modelValue","disabled"]),w(lt,{modelValue:l.value.description,"onUpdate:modelValue":d[2]||(d[2]=g=>l.value.description=g),placeholder:"Description",disabled:t.disabled,onKeydown:d[3]||(d[3]=Ca(Re(g=>h(g),["prevent"]),["enter"]))},null,8,["modelValue","disabled"])]),e("div",An,[m.value?(r(),n("button",{key:0,onClick:d[4]||(d[4]=g=>u.value=!u.value),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors"},[(r(),n("svg",{class:ae(["w-4 h-4 transition-transform",u.value?"rotate-90":""]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...d[11]||(d[11]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))])):I("",!0),e("button",{onClick:d[5]||(d[5]=g=>v.$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"},[...d[12]||(d[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,jn)])]),u.value&&m.value?(r(),n("div",Dn,[l.value.type==="enum"?(r(),n("div",On,[e("div",Rn,[d[13]||(d[13]=e("h4",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400"}," Enum Values ",-1)),e("button",{onClick:c,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,Un)]),l.value.enum?(r(),n("div",Bn,[(r(!0),n(ve,null,ye(l.value.enum,(g,_)=>(r(),n("div",{key:_,class:"flex items-center gap-2"},[w(lt,{modelValue:l.value.enum[_],"onUpdate:modelValue":L=>l.value.enum[_]=L,placeholder:"Enum value",disabled:t.disabled,class:"flex-1"},null,8,["modelValue","onUpdate:modelValue","disabled"]),e("button",{onClick:L=>f(_),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"},[...d[14]||(d[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,Fn)]))),128))])):I("",!0)])):I("",!0),l.value.type==="object"||l.value.type==="anyOf"?(r(),n("div",Nn,[e("h4",qn,C(l.value.type==="anyOf"?"Type Options":"Nested Properties"),1),e("div",Hn,[e("div",Wn,[e("button",{onClick:y,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,Kn)]),e("div",Jn,[(r(!0),n(ve,null,ye(l.value.type==="anyOf"?l.value.anyOf:l.value.properties,(g,_)=>(r(),H(k,{key:g.id,modelValue:(l.value.type==="anyOf"?l.value.anyOf:l.value.properties)[_],"onUpdate:modelValue":L=>(l.value.type==="anyOf"?l.value.anyOf:l.value.properties)[_]=L,"property-id":g.id,"is-nested":!0,"parent-id":t.propertyId,disabled:t.disabled,"enable-drag":!1,onRemove:L=>b(g.id),onAddTopLevel:d[6]||(d[6]=L=>i("add-top-level"))},null,8,["modelValue","onUpdate:modelValue","property-id","parent-id","disabled","onRemove"]))),128))])])])):I("",!0),l.value.type==="array"?(r(),n("div",Yn,[d[15]||(d[15]=e("h4",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Array Item Type ",-1)),l.value.items?I("",!0):(r(),n("div",Gn,[e("button",{onClick:x,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,Zn)])),l.value.items?(r(),n("div",Xn,[(r(),H(k,{key:`${l.value.items.id}-${l.value.items.type}`,modelValue:l.value.items,"onUpdate:modelValue":d[7]||(d[7]=g=>l.value.items=g),"property-id":l.value.items.id,"is-nested":!0,"parent-id":t.propertyId,disabled:t.disabled,"enable-drag":!1,onRemove:d[8]||(d[8]=g=>l.value.items=null),onAddTopLevel:d[9]||(d[9]=g=>i("add-top-level"))},null,8,["modelValue","property-id","parent-id","disabled"]))])):I("",!0)])):I("",!0)])):I("",!0)])],10,Vn)}}}),el={class:"space-y-2"},tl=["disabled"],rl=me({__name:"PropertyList",props:Ze({disabled:{type:Boolean,default:!1},parentId:{},isNested:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:Ze(["add-property","description-keydown"],["update:modelValue"]),setup(t,{expose:o,emit:a}){const i=t,l=a,u=it(t,"modelValue"),s=p();let m=!1;Pe(async()=>{}),Ye(()=>{});const h=async()=>{if(m)return;m=!0;const c={id:crypto.randomUUID(),name:`property${u.value.length+1}`,type:"string",description:"",required:!1};u.value=[...u.value,c],await Le();const f=i.parentId?`[data-nested-property-id="${c.id}"]`:`[data-property-id="${c.id}"]`,y=document.querySelector(`${f} input[placeholder="Property name"]`);y&&(y.focus(),y.select()),l("add-property"),m=!1},x=c=>{u.value=u.value.filter(f=>f.id!==c)};return o({addProperty:h}),(c,f)=>(r(),n("div",el,[e("div",{ref_key:"dragAreaRef",ref:s,class:"space-y-2"},[(r(!0),n(ve,null,ye(u.value,y=>(r(),H(Qn,{key:y.id,modelValue:u.value[u.value.indexOf(y)],"onUpdate:modelValue":b=>u.value[u.value.indexOf(y)]=b,"property-id":y.id,"is-nested":t.isNested,"parent-id":t.parentId,disabled:t.disabled,"enable-drag":!t.isNested,onRemove:b=>x(y.id),onAddTopLevel:f[0]||(f[0]=b=>c.$emit("add-property"))},null,8,["modelValue","onUpdate:modelValue","property-id","is-nested","parent-id","disabled","enable-drag","onRemove"]))),128))],512),e("div",{class:ae(t.isNested?"mt-2":"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-800")},[e("button",{onClick:h,type:"button",disabled:t.disabled,class:ae(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")},[...f[1]||(f[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"})]),Z(" Add Property ")],-1)])],10,tl)],2)]))}}),al={class:"space-y-4"},ol={key:0,class:"flex items-center justify-between"},nl={class:"text-sm font-medium"},ll={key:0,class:"text-red-500"},sl={class:"space-y-2 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4"},il={key:0,class:"flex items-center justify-between mb-2"},ul={key:1,class:"text-center py-12"},dl=["disabled"],cl={class:"mt-4 text-center"},pl={key:3,class:"mt-4"},ml={class:"bg-neutral-50 dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4 overflow-x-auto"},vl={class:"text-xs leading-relaxed"},fl=["innerHTML"],qr=me({__name:"JSONSchemaInput",props:Ze({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 o=it(t,"modelValue"),a=p([]),i=p(),l=p(!1),u=()=>{if(o.value?.properties){const v=[];o.value.required;for(const[d,k]of Object.entries(o.value.properties)){const g=k,_={id:crypto.randomUUID(),name:d,type:g.type||"string",description:g.description||""};g.enum&&(_.enum=g.enum),g.anyOf&&(_.type="anyOf",_.anyOf=s(g.anyOf)),g.type==="array"&&g.items&&(_.items=m(g.items)),g.type==="object"&&g.properties&&(_.properties=h(g.properties,g.required||[])),v.push(_)}a.value=v}},s=v=>v.map(d=>typeof d=="object"&&d.type?{id:crypto.randomUUID(),name:"",type:d.type,description:d.description||"",properties:d.properties?h(d.properties,d.required||[]):void 0,items:d.items?m(d.items):void 0,enum:d.enum}:{id:crypto.randomUUID(),name:"",type:"string",description:""}),m=v=>{const d={id:crypto.randomUUID(),name:"",type:v.type||"string",description:v.description||""};return v.enum&&(d.enum=v.enum),v.anyOf&&(d.type="anyOf",d.anyOf=s(v.anyOf)),v.type==="array"&&v.items&&(d.items=m(v.items)),v.type==="object"&&v.properties&&(d.properties=h(v.properties,v.required||[])),d},h=(v,d)=>{const k=[];for(const[g,_]of Object.entries(v)){const L=_,R={id:crypto.randomUUID(),name:g,type:L.type||"string",description:L.description||""};L.enum&&(R.enum=L.enum),L.anyOf&&(R.type="anyOf",R.anyOf=s(L.anyOf)),L.type==="array"&&L.items&&(R.items=m(L.items)),L.type==="object"&&L.properties&&(R.properties=h(L.properties,L.required||[])),k.push(R)}return k};u();const x=()=>{const v={type:"object",properties:{},required:[],additionalProperties:!1},{properties:d}=f(a.value);v.properties=d,v.required=Object.keys(d),o.value=v},c=v=>{const d={type:v.type==="anyOf"?void 0:v.type,description:v.description};if(v.type==="enum"&&v.enum&&(d.enum=v.enum,d.type="string"),v.type==="anyOf"&&v.anyOf&&(delete d.type,d.anyOf=v.anyOf.map(c)),v.type==="object"&&v.properties){const{properties:k}=f(v.properties);d.properties=k,d.required=Object.keys(k),d.additionalProperties=!1}return v.type==="array"&&v.items&&(d.items=c(v.items)),d},f=v=>{const d={},k=[];for(const g of v){const _={type:g.type==="anyOf"?void 0:g.type,description:g.description};if(k.push(g.name),g.type==="enum"&&g.enum&&(_.enum=g.enum,_.type="string"),g.type==="anyOf"&&g.anyOf&&g.anyOf.length>0&&(delete _.type,_.anyOf=g.anyOf.map(c)),g.type==="array"&&g.items&&(_.items=c(g.items)),g.type==="object"&&g.properties){const{properties:L}=f(g.properties);_.properties=L,_.required=Object.keys(L),_.additionalProperties=!1}d[g.name]=_}return{properties:d,required:k}};ge(a,()=>{x()},{deep:!0}),x();const y=B(()=>JSON.stringify(o.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>')),b=async()=>{if(a.value.length===0){const v={id:crypto.randomUUID(),name:"property1",type:"string",description:""};a.value.push(v),await Le();const d=document.querySelector(`[data-property-id="${v.id}"] input[placeholder="Property name"]`);d&&(d.focus(),d.select())}else i.value&&i.value.addProperty()};return(v,d)=>(r(),n("div",al,[t.label?(r(),n("div",ol,[e("label",nl,[Z(C(t.label)+" ",1),t.required?(r(),n("span",ll,"*")):I("",!0)])])):I("",!0),e("div",sl,[a.value.length>0?(r(),n("div",il,[...d[2]||(d[2]=[e("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Properties ",-1)])])):I("",!0),a.value.length===0?(r(),n("div",ul,[d[4]||(d[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)),d[5]||(d[5]=e("p",{class:"text-neutral-500 dark:text-neutral-400 text-sm mb-4"}," No properties defined ",-1)),e("button",{onClick:b,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"},[...d[3]||(d[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"})]),Z(" Add Property ")],-1)])],8,dl)])):I("",!0),a.value.length>0?(r(),H(rl,{key:2,ref_key:"propertyListRef",ref:i,modelValue:a.value,"onUpdate:modelValue":d[0]||(d[0]=k=>a.value=k),disabled:t.disabled,onAddProperty:b},null,8,["modelValue","disabled"])):I("",!0),e("div",cl,[e("button",{onClick:d[1]||(d[1]=k=>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?(r(),n("div",pl,[e("div",ml,[e("pre",vl,[e("code",{class:"font-mono",innerHTML:y.value},null,8,fl)])])])):I("",!0)])]))}}),hl=gt(Ie(qr),{props:["label","disabled","required"],family:"text",features:[]}),gl={class:"space-y-2"},bl={key:0,class:"space-y-2"},xl={key:0,class:"block text-sm font-medium"},yl={key:0,class:"text-red-500"},kl=["src","alt"],wl={class:"flex-1 text-sm"},_l={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 ml-1"},$l=["onClick","aria-label"],ht=me({__name:"MultipleSelectionsInput",props:Ze({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:Ze(["removeItem"],["update:modelValue"]),setup(t,{emit:o}){const a=t,i=o,l=it(t,"modelValue"),u=p();Tr(async()=>{u.value,await Le(),await Ir({parent:u,values:l,dragHandle:".drag-handle"})});const s=B(()=>Array.isArray(l.value)?l.value.length>0&&typeof l.value[0]=="object"?l.value:l.value.map(c=>{const f=a.options.find(y=>y.value===c);return{id:c,label:f?.label||c,description:f?.description,icon:f?.icon}}):[]),m=B(()=>{const c=s.value.map(f=>f.id);return a.options.filter(f=>!c.includes(f.value))}),h=c=>{if(!c)return;const f=a.options.find(y=>y.value===c);if(f)if(l.value.length===0||typeof l.value[0]=="string")l.value=[...l.value,c];else{const y={id:c,label:f.label,description:f.description,icon:f.icon};l.value=[...l.value,y]}},x=c=>{typeof l.value[0]=="string"?l.value=l.value.filter(f=>f!==c):l.value=l.value.filter(f=>f.id!==c),i("removeItem",c)};return(c,f)=>(r(),n("div",gl,[s.value.length>0?(r(),n("div",bl,[t.label?(r(),n("label",xl,[Z(C(t.label)+" ",1),t.required?(r(),n("span",yl,"*")):I("",!0)])):I("",!0),e("div",{class:"space-y-1",ref_key:"dragAreaRef",ref:u},[(r(!0),n(ve,null,ye(s.value,y=>(r(),n("div",{key:y.id,class:ae(["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":""])},[f[1]||(f[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)),y.icon?(r(),n("img",{key:0,src:y.icon,alt:y.label,class:"w-4 h-4 flex-shrink-0"},null,8,kl)):I("",!0),e("span",wl,[Z(C(y.label)+" ",1),y.description?(r(),n("span",_l," ("+C(y.description)+") ",1)):I("",!0)]),t.disabled?I("",!0):(r(),n("button",{key:1,onClick:b=>x(y.id),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors","aria-label":`Remove ${y.label}`},[...f[0]||(f[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,$l))],2))),128))],512)])):I("",!0),w(Ge,{"model-value":"","onUpdate:modelValue":h,label:s.value.length>0?t.addLabel:t.label,options:m.value,placeholder:t.placeholder,"search-placeholder":t.searchPlaceholder,disabled:t.disabled||m.value.length===0,loading:t.loading},null,8,["label","options","placeholder","search-placeholder","disabled","loading"]),t.error?(r(),H(T(tt),{key:1},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)]))}});function Cl(){return window.__AGENTBUILDER_CONFIG__||{mountPoint:"/agentbuilder"}}function _t(){return Cl().mountPoint}function fe(t){const o=_t(),a=t.startsWith("/")?t:`/${t}`;return o==="/"?a:`${o}${a}`}const Sl=me({__name:"ModelSelectorInput",props:Ze({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 o=t,a=it(t,"modelValue"),i=p([]),l=p(!1),u=B(()=>i.value.map(h=>({value:h.id,label:h.name,description:h.provider_id||h.provider,icon:h.iconId}))),s=async()=>{l.value=!0;try{const h=await fetch(fe("/api/models"));if(h.ok){const x=await h.json();i.value=x.models||[]}}catch(h){console.error("Error fetching models:",h)}finally{l.value=!1}},m=h=>{};return Pe(()=>{s()}),ge(()=>o.allowMultiple,()=>{o.allowMultiple&&typeof a.value=="string"?a.value=a.value?[a.value]:[]:!o.allowMultiple&&Array.isArray(a.value)&&(a.value=a.value[0]||"")}),(h,x)=>(r(),n(ve,null,[t.allowMultiple?(r(),H(ht,{key:0,modelValue:a.value,"onUpdate:modelValue":x[0]||(x[0]=c=>a.value=c),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search models...",error:t.error,required:t.required,disabled:t.disabled,options:u.value,loading:l.value,"add-label":"Add another model",onRemoveItem:m},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(r(),H(Ge,{key:1,modelValue:a.value,"onUpdate:modelValue":x[1]||(x[1]=c=>a.value=c),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search models...",options:u.value,disabled:t.disabled,loading:l.value},null,8,["modelValue","label","placeholder","options","disabled","loading"])),!t.allowMultiple&&t.error?(r(),H(T(tt),{key:2,class:"mt-1"},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)],64))}}),Tl=me({__name:"AgentSelectorInput",props:Ze({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 o=t,a=it(t,"modelValue"),i=p([]),l=p(!1),u=B(()=>i.value.map(h=>({value:h.id,label:h.title,description:h.tool_description||`Handoff to ${h.title} agent`}))),s=async()=>{l.value=!0;try{const h=fe(`/api/agents${o.agentType?`?type=${o.agentType}`:""}`),x=await fetch(h);if(x.ok){const c=await x.json();i.value=c.agents||[]}}catch(h){console.error("Error fetching agents:",h)}finally{l.value=!1}},m=h=>{};return Pe(()=>{s()}),ge(()=>o.allowMultiple,()=>{o.allowMultiple&&typeof a.value=="string"?a.value=a.value?[a.value]:[]:!o.allowMultiple&&Array.isArray(a.value)&&(a.value=a.value[0]||"")},{immediate:!0}),(h,x)=>(r(),n(ve,null,[t.allowMultiple?(r(),H(ht,{key:0,modelValue:a.value,"onUpdate:modelValue":x[0]||(x[0]=c=>a.value=c),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search agents...",error:t.error,required:t.required,disabled:t.disabled,options:u.value,loading:l.value,"add-label":"Add another agent",onRemoveItem:m},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(r(),H(Ge,{key:1,modelValue:a.value,"onUpdate:modelValue":x[1]||(x[1]=c=>a.value=c),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search agents...",options:u.value,disabled:t.disabled,loading:l.value},null,8,["modelValue","label","placeholder","options","disabled","loading"])),!t.allowMultiple&&t.error?(r(),H(T(tt),{key:2,class:"mt-1"},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)],64))}}),Il=me({__name:"ToolSelectorInput",props:Ze({label:{default:"Available Tools"},placeholder:{default:"Select a tool"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},allowMultiple:{type:Boolean,default:!0}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const o=t,a=it(t,"modelValue"),i=p([]),l=p(!1),u=B(()=>i.value.map(h=>{let x=h.name;return h.type==="prompt"?x=`${h.name} (prompt)`:h.type==="mcp"&&(x=`${h.name} (mcp)`),{value:h.name,label:x,description:h.description}})),s=async()=>{l.value=!0;try{const h=await fetch(fe("/api/tools"));if(h.ok){const x=await h.json();i.value=Object.entries(x).map(([c,f])=>({name:c,description:f.description||"",type:f.type,model:f.model}))}}catch(h){console.error("Error fetching tools:",h)}finally{l.value=!1}},m=h=>{};return Pe(()=>{s()}),ge(()=>o.allowMultiple,()=>{o.allowMultiple&&typeof a.value=="string"?a.value=a.value?[a.value]:[]:!o.allowMultiple&&Array.isArray(a.value)&&(a.value=a.value[0]||"")},{immediate:!0}),(h,x)=>(r(),n(ve,null,[t.allowMultiple?(r(),H(ht,{key:0,modelValue:a.value,"onUpdate:modelValue":x[0]||(x[0]=c=>a.value=c),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search tools...",error:t.error,required:t.required,disabled:t.disabled,options:u.value,loading:l.value,"add-label":"Add another tool",onRemoveItem:m},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(r(),H(Ge,{key:1,modelValue:a.value,"onUpdate:modelValue":x[1]||(x[1]=c=>a.value=c),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search tools...",options:u.value,disabled:t.disabled,loading:l.value},null,8,["modelValue","label","placeholder","options","disabled","loading"])),!t.allowMultiple&&t.error?(r(),H(T(tt),{key:2,class:"mt-1"},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)],64))}}),zl=gt(Ie(Sl),{props:["label","placeholder","error","required","disabled","allowMultiple"],family:"dropdown",features:[]}),Vl=gt(Ie(Tl),{props:["label","placeholder","error","required","disabled","allowMultiple","agentType"],family:"dropdown",features:[]}),Ml=gt(Ie(Il),{props:["label","placeholder","error","required","disabled","allowMultiple"],family:"dropdown",features:[]}),El={class:"space-y-4"},Ll={class:"flex items-start gap-2"},Pl={class:"flex-1"},Al=["onClick","disabled","title"],jl={key:0,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Dl={key:1,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Ol={key:0,class:"text-xs text-neutral-400 dark:text-neutral-500 mt-1"},Rl={key:0,class:"text-amber-500 dark:text-amber-400 ml-1"},Ul={class:"flex-1"},Bl={class:"flex-1"},Fl=["onClick","disabled"],Nl=["disabled"],Zt=me({__name:"TenvPropertyList",props:{modelValue:{},inherited:{default:()=>[]},allowCustom:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{emit:o}){const a=t,i=o,l=p(new Set),u=p([]),s=B(()=>new Set(a.inherited.map(d=>d.name)));ge(()=>a.modelValue,d=>{const k=Object.keys(d).filter(_=>!s.value.has(_)),g=new Set(u.value.map(_=>_.name));for(const _ of k)g.has(_)||u.value.push({id:crypto.randomUUID(),name:_,value:String(d[_]??"")})},{immediate:!0,deep:!0});const m=d=>{if(l.value.has(d)){l.value.delete(d);const k=a.inherited.find(g=>g.name===d);k&&h(d,k.value)}else l.value.add(d)},h=(d,k)=>{const g={...a.modelValue};k===void 0||k===""?delete g[d]:g[d]=k,i("update:modelValue",g)},x=d=>a.modelValue[d.name]!==void 0?String(a.modelValue[d.name]):d.value!==void 0?String(d.value):"",c=(d,k)=>{h(d.name,k||void 0)},f=()=>{u.value.push({id:crypto.randomUUID(),name:"",value:""})},y=d=>{const k=u.value.find(g=>g.id===d);if(k&&k.name){const g={...a.modelValue};delete g[k.name],i("update:modelValue",g)}u.value=u.value.filter(g=>g.id!==d)},b=(d,k,g)=>{const _=u.value.find(R=>R.id===d);if(!_)return;_.name=g;const L={...a.modelValue};k&&delete L[k],g&&_.value&&(L[g]=_.value),i("update:modelValue",L)},v=(d,k)=>{const g=u.value.find(_=>_.id===d);g&&(g.value=k,g.name&&h(g.name,k||void 0))};return(d,k)=>(r(),n("div",El,[(r(!0),n(ve,null,ye(t.inherited,g=>(r(),n("div",{key:g.name,class:"relative"},[e("div",Ll,[e("div",Pl,[w(lt,{"model-value":x(g),label:g.name,placeholder:g.description||"Enter value...",disabled:t.disabled||!l.value.has(g.name),required:g.required,"onUpdate:modelValue":_=>c(g,_)},null,8,["model-value","label","placeholder","disabled","required","onUpdate:modelValue"])]),e("button",{type:"button",onClick:_=>m(g.name),disabled:t.disabled,class:"mt-7 p-2 text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300 transition-colors disabled:opacity-50",title:l.value.has(g.name)?"Lock (use inherited value)":"Unlock to override"},[l.value.has(g.name)?(r(),n("svg",Dl,[...k[1]||(k[1]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 11V7a4 4 0 118 0m-4 8v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2z"},null,-1)])])):(r(),n("svg",jl,[...k[0]||(k[0]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"},null,-1)])]))],8,Al)]),g.source?(r(),n("p",Ol,[Z(" From: "+C(g.source)+" ",1),g.required?(r(),n("span",Rl,"(required)")):I("",!0)])):I("",!0)]))),128)),(r(!0),n(ve,null,ye(u.value,g=>(r(),n("div",{key:g.id,class:"flex items-start gap-2"},[e("div",Ul,[w(lt,{"model-value":g.name,label:"Name",placeholder:"Variable name",disabled:t.disabled,"onUpdate:modelValue":_=>b(g.id,g.name,_)},null,8,["model-value","disabled","onUpdate:modelValue"])]),e("div",Bl,[w(lt,{"model-value":g.value,label:"Value",placeholder:"Variable value",disabled:t.disabled,"onUpdate:modelValue":_=>v(g.id,_)},null,8,["model-value","disabled","onUpdate:modelValue"])]),e("button",{type:"button",onClick:_=>y(g.id),disabled:t.disabled,class:"mt-7 p-2 text-red-400 hover:text-red-600 dark:hover:text-red-300 transition-colors disabled:opacity-50",title:"Remove"},[...k[2]||(k[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:"M6 18L18 6M6 6l12 12"})],-1)])],8,Fl)]))),128)),t.allowCustom?(r(),n("button",{key:0,type:"button",onClick:f,disabled:t.disabled,class:"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"},[...k[3]||(k[3]=[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"})]),Z(" Add custom variable ")],-1)])],8,Nl)):I("",!0)]))}}),ql=gt(Ie(Zt),{props:["inherited","allowCustom","disabled"],family:"text",features:[]}),Hl={class:"space-y-3 mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-700"},Wl={class:"space-y-2 pl-4 border-l-2 border-accent-200 dark:border-accent-700"},Kl={class:"space-y-2 pl-4 border-l-2 border-neutral-200 dark:border-neutral-700"},Jl=me({__name:"PromptToolOptions",props:{toolName:{},toolConfig:{},toolType:{default:"prompt"},disabled:{type:Boolean}},emits:["update:option"],setup(t,{emit:o}){const a=t,i=o,l=p(null),u=p(!0),s=B(()=>l.value?.properties?Object.entries(l.value.properties).map(([x,c])=>({value:x,label:x,attrs:{description:c.description||c.type||""}})):[]),m=async()=>{try{let x=a.toolName;if(a.toolType==="handoff"||a.toolType==="subagent"){const f=await fetch(fe(`/api/agents/${encodeURIComponent(a.toolName)}`));if(f.ok){if(x=(await f.json())?.agent?.side_a_agent_prompt,!x){u.value=!1;return}}else{u.value=!1;return}}const c=await fetch(fe(`/api/prompts/${encodeURIComponent(x)}`));if(c.ok){const f=await c.json();f?.prompt?.required_schema&&(l.value=f.prompt.required_schema)}}catch(x){console.error("Error fetching prompt schema:",x)}finally{u.value=!1}};Pe(()=>{m()});const h=(x,c)=>{i("update:option",x,c)};return(x,c)=>{const f=Be("FormKit");return r(),n("div",Hl,[e("div",Wl,[c[5]||(c[5]=e("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Initialization Options: ",-1)),w(f,{type:"selectSearch",value:t.toolConfig.init_user_message_property||"",onInput:c[0]||(c[0]=y=>h("init_user_message_property",y||null)),label:"User message property",placeholder:"Don't inject a user message",options:s.value,disabled:t.disabled||u.value||s.value.length===0,loading:u.value,help:"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.","outer-class":"$reset mb-2"},null,8,["value","options","disabled","loading"]),w(f,{type:"selectSearch",value:t.toolConfig.init_attachments_property||"",onInput:c[1]||(c[1]=y=>h("init_attachments_property",y||null)),label:"Attachments property",placeholder:"Don't attach files",options:s.value,disabled:t.disabled||u.value||s.value.length===0,loading:u.value,help:"Select which argument contains attachment path(s). Accepts a single path string or an array of paths.","outer-class":"$reset mb-0"},null,8,["value","options","disabled","loading"])]),e("div",Kl,[c[6]||(c[6]=e("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Sub-Prompt Response Options: ",-1)),w(f,{type:"checkbox",value:t.toolConfig.include_text_response,onInput:c[2]||(c[2]=y=>h("include_text_response",y)),label:"Include text response",help:"Include the final text content from the sub-prompt",disabled:t.disabled,"outer-class":"$reset mb-1"},null,8,["value","disabled"]),w(f,{type:"checkbox",value:t.toolConfig.include_tool_calls,onInput:c[3]||(c[3]=y=>h("include_tool_calls",y)),label:"Include tool calls and responses",help:"Include tool calls executed by the sub-prompt and their responses",disabled:t.disabled,"outer-class":"$reset mb-1"},null,8,["value","disabled"]),w(f,{type:"checkbox",value:t.toolConfig.include_errors,onInput:c[4]||(c[4]=y=>h("include_errors",y)),label:"Include errors",help:"Include error information if the sub-prompt fails",disabled:t.disabled,"outer-class":"$reset mb-0"},null,8,["value","disabled"])])])}}});async function Je(t,o={}){const a=localStorage.getItem("auth_token"),i={"Content-Type":"application/json",...o.headers};a&&(i.Authorization=`Bearer ${a}`);const l=t.startsWith("/")?t:`/${t}`,u=await fetch(fe(`/api${l}`),{...o,headers:i});if(u.status===401)throw localStorage.removeItem("auth_token"),window.location.href=fe("/login"),new Error("Unauthorized");return u}const Yl={class:"space-y-4"},Gl={class:"block text-sm font-medium mb-2"},Zl={key:0,class:"text-red-500"},Xl={class:"flex items-start justify-between"},Ql={class:"flex items-center gap-2 flex-1"},es={class:"flex-1"},ts={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},rs={key:1,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},as={key:2,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},os={key:3,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},ns={key:4,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},ls={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-1"},ss={key:1,class:"text-xs text-amber-600 dark:text-amber-400 mt-1 flex items-center gap-1"},is=["onClick","disabled","aria-label"],us={key:0,class:"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-700"},ds={class:"space-y-2"},cs={key:0,class:"text-xs text-amber-500 dark:text-amber-400 whitespace-nowrap",title:"Required at agent or thread level"},ps={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"},Hr=me({__name:"ToolSelectorWithOptions",props:Ze({label:{default:"Available Tools"},placeholder:{default:"Select a tool"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelId:{},providerId:{}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:Ze(["unavailable-tools"],["update:modelValue"]),setup(t,{expose:o,emit:a}){const i=t,l=it(t,"modelValue"),u=p([]),s=p([]),m=p(!1),h=p(!1),x=p(),c=p(""),f=B(()=>[...u.value,...s.value]),y=B(()=>new Set(f.value.map(Q=>k(Q)))),b=Q=>(Q.startsWith("provider:"),y.value.has(Q)),v=B(()=>l.value.filter(Q=>!b(Q.name)).map(Q=>Q.name)),d=a;ge(v,Q=>{Q.length>0&&d("unavailable-tools",Q)},{immediate:!0}),Tr(async()=>{x.value,await Le(),x.value&&l.value.length>0&&await Ir({parent:x,values:l,dragHandle:".drag-handle"})});const k=Q=>Q.type==="provider"?`provider:${Q.name}`:Q.type==="mcp"?`mcp:${Q.name}`:Q.name,g=Q=>Q.startsWith("provider:")?Q.slice(9):Q.startsWith("mcp:")?Q.slice(4):Q,_=Q=>Q.startsWith("provider:")?"provider":Q.startsWith("mcp:")?"mcp":"tool",L=B(()=>{const Q=new Set(l.value.map(E=>E.name));return f.value.filter(E=>!Q.has(k(E))).map(E=>{let S=E.name;return E.type==="prompt"?S=`${E.name} (prompt)`:E.type==="mcp"?S=`${E.name} (mcp)`:E.type==="provider"?S=`${E.name} (provider)`:E.type==="handoff"?S=`${E.name} (handoff agent)`:E.type==="subagent"&&(S=`${E.name} (subagent)`),{value:k(E),label:S,attrs:{description:E.description}}})}),R=async()=>{m.value=!0;try{const Q=await Je("/tools");if(Q.ok){const E=await Q.json();u.value=Object.entries(E).map(([S,V])=>({name:S,description:V.description||"",type:V.type,model:V.model}))}}catch(Q){console.error("Error fetching tools:",Q)}finally{m.value=!1}},K=async()=>{if(!i.providerId||!i.modelId){s.value=[];return}h.value=!0;try{const Q=await Je(`/providers/${i.providerId}/tools?model=${encodeURIComponent(i.modelId)}`);if(Q.ok){const E=await Q.json();s.value=(E.tools||[]).map(S=>({name:S.name,description:S.description||"",type:"provider",tenvs:S.tenvs||[]}))}else s.value=[]}catch(Q){console.error("Error fetching provider tools:",Q),s.value=[]}finally{h.value=!1}};ge([()=>i.providerId,()=>i.modelId],async([Q,E])=>{Q&&E?await K():s.value=[]},{immediate:!0});const Y=Q=>{if(!Q||l.value.find(V=>V.name===Q))return;const E=P(Q),S={};if(E?.tenvs&&E.tenvs.length>0)for(const V of E.tenvs)S[V.name]="";l.value=[...l.value,{name:Q,include_text_response:!0,include_tool_calls:!0,include_errors:!0,init_user_message_property:null,init_attachments_property:null,...Object.keys(S).length>0?{tenvs:S}:{}}],Le(()=>{c.value=""})},z=Q=>{l.value=l.value.filter(E=>E.name!==Q)},P=Q=>{const E=f.value.find(S=>k(S)===Q);return E||f.value.find(S=>S.name===Q)},G=(Q,E,S)=>{l.value=l.value.map(V=>{if(V.name===Q){const re={...V.tenvs||{},[E]:S||void 0};for(const F of Object.keys(re))re[F]||delete re[F];return{...V,tenvs:Object.keys(re).length>0?re:void 0}}return V})},ee=(Q,E,S)=>{l.value=l.value.map(V=>V.name===Q?{...V,[E]:S}:V)};return o({removeUnavailableTools:()=>{l.value=l.value.filter(Q=>b(Q.name))},getAvailableToolsOnly:()=>l.value.filter(Q=>b(Q.name)),unavailableTools:v}),Pe(()=>{R()}),(Q,E)=>{const S=Be("FormKit");return r(),n("div",Yl,[e("div",null,[e("label",Gl,[Z(C(t.label)+" ",1),t.required?(r(),n("span",Zl,"*")):I("",!0)]),l.value.length>0?(r(),n("div",{key:0,class:"space-y-3 mb-4",ref_key:"dragAreaRef",ref:x},[(r(!0),n(ve,null,ye(l.value,V=>(r(),n("div",{key:V.name,class:ae(["border rounded-lg p-4 transition-colors",b(V.name)?"border-neutral-300 dark:border-neutral-600":"border-amber-300 dark:border-amber-700 bg-amber-50 dark:bg-amber-900/20 opacity-75"])},[e("div",Xl,[e("div",Ql,[e("div",{class:ae(["drag-handle",b(V.name)?"cursor-move text-neutral-400 hover:text-neutral-600 dark:text-neutral-600 dark:hover:text-neutral-400":"cursor-not-allowed text-neutral-300 dark:text-neutral-700"])},[...E[1]||(E[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:"M4 8h16M4 16h16"})],-1)])],2),e("div",es,[e("h4",{class:ae(["font-medium text-sm",!b(V.name)&&"text-neutral-500 dark:text-neutral-400"])},[Z(C(g(V.name))+" ",1),_(V.name)==="provider"?(r(),n("span",ts,"(provider)")):_(V.name)==="mcp"?(r(),n("span",rs,"(mcp)")):P(V.name)?.type==="prompt"?(r(),n("span",as,"(prompt)")):P(V.name)?.type==="handoff"?(r(),n("span",os,"(handoff agent)")):P(V.name)?.type==="subagent"?(r(),n("span",ns,"(subagent)")):I("",!0)],2),P(V.name)?.description?(r(),n("p",ls,C(P(V.name)?.description),1)):I("",!0),b(V.name)?I("",!0):(r(),n("p",ss,[...E[2]||(E[2]=[e("svg",{class:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})],-1),Z(" Not available for selected model - will be removed on save ",-1)])]))])]),e("button",{onClick:re=>z(V.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 ${g(V.name)}`},[...E[3]||(E[3]=[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,is)]),P(V.name)?.type==="provider"&&P(V.name)?.tenvs?.length?(r(),n("div",us,[E[4]||(E[4]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 mb-2 font-medium"},[Z(" Environment Variables "),e("span",{class:"text-neutral-400"},"(optional at prompt level)")],-1)),e("div",ds,[(r(!0),n(ve,null,ye(P(V.name)?.tenvs,re=>(r(),n("div",{key:re.name,class:"flex items-center gap-2"},[w(S,{type:"text",value:V.tenvs?.[re.name]||"",onInput:F=>G(V.name,re.name,F),label:re.name,placeholder:re.description||"Enter value...",disabled:t.disabled,"outer-class":"$reset flex-1 mb-0"},null,8,["value","onInput","label","placeholder","disabled"]),re.required?(r(),n("span",cs," required* ")):I("",!0)]))),128))])])):I("",!0),P(V.name)?.type==="prompt"||P(V.name)?.type==="handoff"||P(V.name)?.type==="subagent"?(r(),H(Jl,{key:1,"tool-name":V.name,"tool-config":V,"tool-type":P(V.name)?.type,disabled:t.disabled,"onUpdate:option":(re,F)=>ee(V.name,re,F)},null,8,["tool-name","tool-config","tool-type","disabled","onUpdate:option"])):I("",!0)],2))),128))],512)):I("",!0),w(S,{type:"selectSearch",modelValue:c.value,"onUpdate:modelValue":E[0]||(E[0]=V=>c.value=V),onInput:Y,placeholder:l.value.length>0?"Add another tool...":t.placeholder,"search-placeholder":"Search tools...",options:L.value,disabled:t.disabled||m.value||L.value.length===0,loading:m.value,"outer-class":"$reset"},null,8,["modelValue","placeholder","options","disabled","loading"]),t.error?(r(),H(T(tt),{key:1,class:"mt-1"},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)]),l.value.length===0&&!m.value&&L.value.length===0?(r(),n("div",ps," No tools available. Create tools in your agentbuilder/tools directory. ")):I("",!0)])}}}),ms=gt(Ie(Hr),{props:["label","placeholder","error","required","disabled","modelId","providerId"],family:"dropdown",features:[]}),vs=me({__name:"SelectInputWrapper",props:{context:{}},setup(t){const o=t,a=(b,v)=>{const d=o.context;return d[b]!==void 0?d[b]:d.attrs?.[b]!==void 0?d.attrs[b]:v},i=B(()=>o.context.classes??{}),l=B(()=>a("options",[])),u=B(()=>o.context._value??""),s=b=>{o.context.node.input(b)},m=B(()=>a("placeholder","Select an option")),h=B(()=>a("searchPlaceholder","Search...")),x=B(()=>a("loading",!1)),c=B(()=>o.context.disabled??!1),f=B(()=>a("size","md")),y=B(()=>a("activeHighlight",!1));return(b,v)=>(r(),H(Ge,{"model-value":u.value,options:l.value,placeholder:m.value,"search-placeholder":h.value,loading:x.value,disabled:c.value,"trigger-class":i.value.inner,size:f.value,"active-highlight":y.value,"onUpdate:modelValue":s},null,8,["model-value","options","placeholder","search-placeholder","loading","disabled","trigger-class","size","active-highlight"]))}}),fs={type:"input",family:"dropdown",props:["options","placeholder","searchPlaceholder","loading","size","activeHighlight"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$cmp:Ie(vs),props:{context:"$node.context"}}]},hs={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function gs(t,o){return r(),n("svg",hs,[...o[0]||(o[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"m21 21l-4.34-4.34"}),e("circle",{cx:"11",cy:"11",r:"8"})],-1)])])}const bs=Ie({name:"lucide-search",render:gs}),xs=["data-suffix-icon"],ys=["id","value","placeholder","disabled"],ks=me({__name:"SearchInputWrapper",props:{context:{}},setup(t){const o=t,a=(x,c)=>{const f=o.context;return f[x]!==void 0?f[x]:f.attrs?.[x]!==void 0?f.attrs[x]:c},i=B(()=>o.context.classes??{}),l=B(()=>o.context._value??""),u=x=>{const c=x.target.value;o.context.node.input(c)},s=()=>{o.context.node.input("")},m=B(()=>a("placeholder","Search...")),h=B(()=>o.context.disabled??!1);return(x,c)=>(r(),n("div",{class:ae(i.value.inner),"data-prefix-icon":"true","data-suffix-icon":!!l.value},[e("span",{class:ae(i.value.prefixIcon)},[w(T(bs))],2),e("input",{type:"text",id:t.context.id,value:l.value,onInput:u,placeholder:m.value,disabled:h.value,class:ae(i.value.input)},null,42,ys),l.value?(r(),n("button",{key:0,type:"button",onClick:s,class:ae([i.value.suffixIcon,"hover:text-zinc-600 dark:hover:text-zinc-300 cursor-pointer"])},[w(T(Pt))],2)):I("",!0)],10,xs))}}),ws={type:"input",family:"text",props:["placeholder","size"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$cmp:Ie(ks),props:{context:"$node.context"}}]},_s=me({__name:"SortableMultiSelectWrapper",props:{context:{}},setup(t){const o=t,a=B(()=>o.context.options??[]),i=B(()=>o.context.placeholder??"Select an option"),l=B(()=>o.context.searchPlaceholder??"Search..."),u=B(()=>o.context.addLabel??"Add another"),s=B(()=>o.context.loading??!1),m=B(()=>o.context.disabled??!1),h=B({get:()=>o.context._value??[],set:x=>o.context.node.input(x)});return(x,c)=>(r(),H(ht,{modelValue:h.value,"onUpdate:modelValue":c[0]||(c[0]=f=>h.value=f),options:a.value,placeholder:i.value,"search-placeholder":l.value,"add-label":u.value,loading:s.value,disabled:m.value},null,8,["modelValue","options","placeholder","search-placeholder","add-label","loading","disabled"]))}}),$s={type:"input",family:"dropdown",props:["options","placeholder","searchPlaceholder","addLabel","loading"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$cmp:Ie(_s),props:{context:"$node.context"}}]},Cs={class:"flex items-center gap-2 py-1 pl-2 pr-1"},Ss={class:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2"},Ts={class:"flex items-center gap-0.5 shrink-0"},Is={key:1,class:"w-7"},zs={class:"pl-2 pb-1"},Vs={key:0},Ms={class:"space-y-1.5"},Es=["onClick"],Ls=["onClick"],Ps={key:1},As=["onClick"],js={key:2},Ds=["onClick"],Os={key:3},Rs={class:"flex items-center gap-2 py-1 pl-2 pr-1"},Us={class:"flex-1 grid grid-cols-1 md:grid-cols-2 gap-2"},Bs={class:"flex items-center gap-0.5 shrink-0"},Fs={key:1,class:"w-7"},Ns={class:"pl-2 pb-1"},qs={key:0},Hs={class:"space-y-1.5"},Ws=["onClick"],Ks=["onClick"],Js={key:1},Ys=["onClick"],Gs={key:2},Zs=["onClick"],Xs={key:3},Qs=["onClick"],ei=me({__name:"SchemaPropertyRow",props:{typeOptions:{},depth:{},index:{}},emits:["remove"],setup(t){const o=t,a=p(!1),i=p("string"),l=p("string"),u=p(!1),s=v=>{i.value=v,x(v)&&(a.value=!0)},m=v=>{l.value=v,x(v)&&(u.value=!0)},h=v=>{v.value?.type&&(l.value=v.value.type,x(l.value)&&(u.value=!0)),v.on("input",({payload:d})=>{d?.type&&d.type!==l.value&&m(d.type)})},x=v=>["object","array","enum","anyOf"].includes(v),c=["#3b82f6","#8b5cf6","#ec4899","#f97316","#10b981"],f=B(()=>o.depth||0),y=v=>c[v%c.length],b=B(()=>y(f.value));return(v,d)=>{const k=Be("FormKit"),g=Be("SchemaPropertyRow",!0);return r(),H(k,{type:"group",index:t.index,onNode:d[3]||(d[3]=_=>{_.value?.type&&(i.value=_.value.type,x(i.value)&&(a.value=!0)),_.on("input",({payload:L})=>{L?.type&&L.type!==i.value&&s(L.type)})})},{default:D(({value:_})=>[e("div",{class:ae(["schema-row",f.value>0?"border-l-[3px] ml-2":""]),style:st(f.value>0?{borderColor:b.value}:{})},[e("div",Cs,[e("div",Ss,[w(k,{type:"text",name:"name",placeholder:"Property name","outer-class":"$reset"}),w(k,{type:"selectSearch",name:"type",options:t.typeOptions,placeholder:"Type","outer-class":"$reset",onInput:s},null,8,["options"]),w(k,{type:"text",name:"description",placeholder:"Description","outer-class":"$reset"})]),e("div",Ts,[x(i.value)?(r(),n("button",{key:0,onClick:d[0]||(d[0]=L=>a.value=!a.value),type:"button",class:"p-1.5 text-neutral-500 dark:text-white/70 hover:text-neutral-700 dark:hover:text-white hover:bg-neutral-100 dark:hover:bg-neutral-700 rounded transition-colors"},[(r(),n("svg",{class:ae(["w-4 h-4 transition-transform duration-150",a.value?"rotate-90":""]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...d[4]||(d[4]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))])):(r(),n("div",Is)),e("button",{onClick:d[1]||(d[1]=L=>v.$emit("remove")),type:"button",class:"p-1.5 text-neutral-500 dark:text-white/70 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 rounded transition-colors"},[...d[5]||(d[5]=[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)])])])]),Ae(e("div",zs,[i.value==="enum"?(r(),n("div",Vs,[d[7]||(d[7]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Enum Values ",-1)),w(k,{type:"list",name:"enumValues",dynamic:""},{default:D(({items:L,value:R,node:K})=>[e("div",Ms,[(r(!0),n(ve,null,ye(L,(Y,z)=>(r(),n("div",{key:Y,class:"flex items-center gap-2"},[w(k,{type:"group",index:z},{default:D(()=>[w(k,{type:"text",name:"value",placeholder:"Value","outer-class":"$reset flex-1"})]),_:1},8,["index"]),e("button",{onClick:P=>K.input(R.filter((G,ee)=>ee!==z)),type:"button",class:"p-1 text-neutral-500 dark:text-white/70 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 rounded"},[...d[6]||(d[6]=[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,Es)]))),128))]),e("button",{onClick:Y=>K.input((R||[]).concat({value:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Add Value ",8,Ls)]),_:1})])):I("",!0),i.value==="object"?(r(),n("div",Ps,[w(k,{type:"list",name:"properties",dynamic:""},{default:D(({items:L,value:R,node:K})=>[e("div",null,[(r(!0),n(ve,null,ye(L,(Y,z)=>(r(),H(g,{key:Y,index:z,"type-options":t.typeOptions,depth:f.value+1,onRemove:P=>K.input(R.filter((G,ee)=>ee!==z))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:Y=>K.input((R||[]).concat({name:"",type:"string",description:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Add Nested Property ",8,As)]),_:1})])):I("",!0),i.value==="anyOf"?(r(),n("div",js,[d[8]||(d[8]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Type Options ",-1)),w(k,{type:"list",name:"anyOfTypes",dynamic:""},{default:D(({items:L,value:R,node:K})=>[e("div",null,[(r(!0),n(ve,null,ye(L,(Y,z)=>(r(),H(g,{key:Y,index:z,"type-options":t.typeOptions,depth:f.value+1,onRemove:P=>K.input(R.filter((G,ee)=>ee!==z))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:Y=>K.input((R||[]).concat({name:"",type:"string",description:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Add Type ",8,Ds)]),_:1})])):I("",!0),i.value==="array"?(r(),n("div",Os,[d[14]||(d[14]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Array Item Type ",-1)),w(k,{type:"group",name:"items",onNode:h},{default:D(({value:L,node:R})=>[e("div",{class:"schema-row border-l-[3px] ml-2",style:st({borderColor:y(f.value+1)})},[e("div",Rs,[e("div",Us,[w(k,{type:"selectSearch",name:"type",options:t.typeOptions,placeholder:"Item type","outer-class":"$reset",onInput:m},null,8,["options"]),w(k,{type:"text",name:"description",placeholder:"Description","outer-class":"$reset"})]),e("div",Bs,[x(l.value)?(r(),n("button",{key:0,onClick:d[2]||(d[2]=K=>u.value=!u.value),type:"button",class:"p-1.5 text-neutral-500 dark:text-white/70 hover:text-neutral-700 dark:hover:text-white hover:bg-neutral-100 dark:hover:bg-neutral-700 rounded transition-colors"},[(r(),n("svg",{class:ae(["w-4 h-4 transition-transform duration-150",u.value?"rotate-90":""]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...d[9]||(d[9]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))])):(r(),n("div",Fs))])]),Ae(e("div",Ns,[l.value==="enum"?(r(),n("div",qs,[d[11]||(d[11]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Enum Values ",-1)),w(k,{type:"list",name:"enumValues",dynamic:""},{default:D(({items:K,value:Y,node:z})=>[e("div",Hs,[(r(!0),n(ve,null,ye(K,(P,G)=>(r(),n("div",{key:P,class:"flex items-center gap-2"},[w(k,{type:"group",index:G},{default:D(()=>[w(k,{type:"text",name:"value",placeholder:"Value","outer-class":"$reset flex-1"})]),_:1},8,["index"]),e("button",{onClick:ee=>z.input(Y.filter((se,de)=>de!==G)),type:"button",class:"p-1 text-neutral-500 dark:text-white/70 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 rounded"},[...d[10]||(d[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:"M6 18L18 6M6 6l12 12"})],-1)])],8,Ws)]))),128))]),e("button",{onClick:P=>z.input((Y||[]).concat({value:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Add Value ",8,Ks)]),_:1})])):I("",!0),l.value==="object"?(r(),n("div",Js,[w(k,{type:"list",name:"properties",dynamic:""},{default:D(({items:K,value:Y,node:z})=>[e("div",null,[(r(!0),n(ve,null,ye(K,(P,G)=>(r(),H(g,{key:P,index:G,"type-options":t.typeOptions,depth:f.value+2,onRemove:ee=>z.input(Y.filter((se,de)=>de!==G))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:P=>z.input((Y||[]).concat({name:"",type:"string",description:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Add Nested Property ",8,Ys)]),_:1})])):I("",!0),l.value==="anyOf"?(r(),n("div",Gs,[d[12]||(d[12]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Type Options ",-1)),w(k,{type:"list",name:"anyOfTypes",dynamic:""},{default:D(({items:K,value:Y,node:z})=>[e("div",null,[(r(!0),n(ve,null,ye(K,(P,G)=>(r(),H(g,{key:P,index:G,"type-options":t.typeOptions,depth:f.value+2,onRemove:ee=>z.input(Y.filter((se,de)=>de!==G))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:P=>z.input((Y||[]).concat({name:"",type:"string",description:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Add Type ",8,Zs)]),_:1})])):I("",!0),l.value==="array"?(r(),n("div",Xs,[d[13]||(d[13]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Nested Array Item Type ",-1)),w(k,{type:"list",name:"items",dynamic:""},{default:D(({items:K,value:Y,node:z})=>[e("div",null,[(r(!0),n(ve,null,ye(K,(P,G)=>(r(),H(g,{key:P,index:G,"type-options":t.typeOptions,depth:f.value+2,onRemove:ee=>z.input(Y.filter((se,de)=>de!==G))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:P=>z.input((Y||[]).concat({type:"string",description:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Define Nested Item ",8,Qs)]),_:1})])):I("",!0)],512),[[Ke,u.value&&x(l.value)]])],4)]),_:1})])):I("",!0)],512),[[Ke,a.value&&x(i.value)]])],6)]),_:1},8,["index"])}}}),ti=Xe(ei,[["__scopeId","data-v-a52ecd3f"]]),ri={"data-schema-editor":"",class:"space-y-4"},ai={class:"space-y-2 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4"},oi={key:0,class:"flex items-center justify-between mb-2"},ni={key:1,class:"text-center py-12"},li={class:"divide-y divide-neutral-100 dark:divide-neutral-800"},si={class:"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-800"},ii=["onClick"],ui={class:"mt-4 text-center"},di={key:3,class:"mt-4"},ci={class:"bg-neutral-50 dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4 overflow-x-auto"},pi={class:"text-xs leading-relaxed"},mi=["innerHTML"],vi=me({__name:"FormKitSchemaEditor",props:{context:{}},setup(t){const o=[{value:"string",label:"String",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' 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' 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' 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' 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' 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' 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",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' 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"}],a=t,i=p(!1),l=x=>x?.properties?Object.entries(x.properties).map(([c,f])=>{const y={name:c,type:f.enum?"enum":f.anyOf?"anyOf":f.type||"string",description:f.description||""};return f.enum&&(y.enumValues=f.enum.map(b=>({value:b}))),f.anyOf&&(y.anyOfTypes=f.anyOf.map(b=>({type:b.type||"string",description:b.description||""}))),f.type==="object"&&f.properties&&(y.properties=l(f)),f.type==="array"&&f.items&&(y.items={type:f.items.type||"string",description:f.items.description||""},f.items.properties&&(y.items.properties=l(f.items))),y}):[],u=x=>{const c={type:"object",properties:{},required:[],additionalProperties:!1};for(const f of x||[]){if(!f.name)continue;const y={type:f.type==="enum"||f.type==="anyOf"?void 0:f.type,description:f.description||void 0};if(f.type==="enum"&&f.enumValues&&(y.type="string",y.enum=f.enumValues.map(b=>b.value)),f.type==="anyOf"&&f.anyOfTypes&&(y.anyOf=f.anyOfTypes.map(b=>({type:b.type,description:b.description||void 0}))),f.type==="object"&&f.properties){const b=u(f.properties);y.properties=b.properties,y.required=b.required,y.additionalProperties=!1}if(f.type==="array"&&f.items&&(y.items={type:f.items.type,description:f.items.description||void 0},f.items.properties)){const b=u(f.items.properties);y.items.properties=b.properties,y.items.required=b.required}Object.keys(y).forEach(b=>y[b]===void 0&&delete y[b]),c.properties[f.name]=y,c.required.push(f.name)}return c},s=B({get:()=>{const x=a.context._value;return l(x)},set:x=>{const c=u(x);a.context.node.input(c)}}),m=B(()=>{const x=a.context._value||{type:"object",properties:{},required:[]};return JSON.stringify(x,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>')}),h=()=>{s.value=[{name:"property1",type:"string",description:""}]};return(x,c)=>{const f=Be("FormKit");return r(),n("div",ri,[e("div",ai,[s.value.length>0?(r(),n("div",oi,[...c[3]||(c[3]=[e("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Properties ",-1)])])):I("",!0),s.value.length===0?(r(),n("div",ni,[c[5]||(c[5]=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)),c[6]||(c[6]=e("p",{class:"text-neutral-500 dark:text-neutral-400 text-sm mb-4"}," No properties defined ",-1)),e("button",{onClick:c[0]||(c[0]=y=>h()),type:"button",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 font-medium text-sm"},[...c[4]||(c[4]=[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"})]),Z(" Add Property ")],-1)])])])):I("",!0),s.value.length>0?(r(),H(f,{key:2,type:"list",value:s.value,onInput:c[1]||(c[1]=y=>s.value=y),dynamic:""},{default:D(({items:y,value:b,node:v})=>[e("div",li,[(r(!0),n(ve,null,ye(y,(d,k)=>(r(),H(ti,{key:d,index:k,"type-options":o,depth:0,onRemove:g=>v.input(b.filter((_,L)=>L!==k))},null,8,["index","onRemove"]))),128))]),e("div",si,[e("button",{onClick:d=>v.input(b.concat({name:`property${b.length+1}`,type:"string",description:""})),type:"button",class:"px-3 py-1.5 text-xs font-medium text-neutral-700 dark:text-neutral-300 bg-white dark:bg-neutral-800 border border-neutral-300 dark:border-neutral-600 rounded-md hover:bg-neutral-50 dark:hover:bg-neutral-700 transition-colors shadow-sm"}," + Add Property ",8,ii)])]),_:1},8,["value"])):I("",!0),e("div",ui,[e("button",{onClick:c[2]||(c[2]=y=>i.value=!i.value),type:"button",class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-100 underline underline-offset-2 transition-colors"},C(i.value?"Hide":"Show")+" JSON Schema ",1)]),i.value?(r(),n("div",di,[e("div",ci,[e("pre",pi,[e("code",{class:"font-mono",innerHTML:m.value},null,8,mi)])])])):I("",!0)])])}}}),fi={type:"input",family:"text",props:["label","disabled","required"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$cmp:Ie(vi),props:{context:"$node.context"}}]},hi={promptInput:qo,jsonSchema:hl,modelSelector:zl,agentSelector:Vl,toolSelector:Ml,tenvPropertyList:ql,toolSelectorWithOptions:ms,selectSearch:fs,searchInput:ws,sortableMultiSelect:$s,schemaEditor:fi},gi=eo("fk-2d3e4e0bb",ro),bi={config:{rootClasses:yo},plugins:[gi],rules:Io,messages:{en:zo},inputs:hi,icons:{...to}},xi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function yi(t,o){return r(),n("svg",xi,[...o[0]||(o[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 mt=Ie({name:"lucide-bot",render:yi}),ki={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function wi(t,o){return r(),n("svg",ki,[...o[0]||(o[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=Ie({name:"lucide-message-square",render:wi}),_i={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function $i(t,o){return r(),n("svg",_i,[...o[0]||(o[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 Ci=Ie({name:"lucide-cpu",render:$i}),Si={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ti(t,o){return r(),n("svg",Si,[...o[0]||(o[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 Ii=Ie({name:"lucide-server",render:Ti}),zi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Vi(t,o){return r(),n("svg",zi,[...o[0]||(o[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 qt=Ie({name:"lucide-wrench",render:Vi}),Mi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ei(t,o){return r(),n("svg",Mi,[...o[0]||(o[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 Ht=Ie({name:"lucide-settings",render:Ei}),Li={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Pi(t,o){return r(),n("svg",Li,[...o[0]||(o[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 Wr=Ie({name:"lucide-chevron-left",render:Pi}),Ai={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ji(t,o){return r(),n("svg",Ai,[...o[0]||(o[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 Di=Ie({name:"lucide-sun",render:ji}),Oi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ri(t,o){return r(),n("svg",Oi,[...o[0]||(o[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 Ui=Ie({name:"lucide-moon",render:Ri}),Bi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Fi(t,o){return r(),n("svg",Bi,[...o[0]||(o[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 Ni=Ie({name:"lucide-activity",render:Fi}),qi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Hi(t,o){return r(),n("svg",qi,[...o[0]||(o[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 Wi=Ie({name:"lucide-function-square",render:Hi}),Ki={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ji(t,o){return r(),n("svg",Ki,[...o[0]||(o[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 Yi=Ie({name:"lucide-log-out",render:Ji}),Gi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Zi(t,o){return r(),n("svg",Gi,[...o[0]||(o[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 Xi=Ie({name:"lucide-users",render:Zi}),Qi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function eu(t,o){return r(),n("svg",Qi,[...o[0]||(o[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 tu=Ie({name:"lucide-key",render:eu}),ru={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function au(t,o){return r(),n("svg",ru,[...o[0]||(o[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 ou=Ie({name:"lucide-book-open",render:au}),nu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function lu(t,o){return r(),n("svg",nu,[...o[0]||(o[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 su=Ie({name:"lucide-external-link",render:lu}),Kr="agentbuilder-accent-theme",Jr=["amber","lime","emerald","sky","blue","indigo","purple","fuchsia","pink","white"],Wt=p("purple");let cr=!1;function Yr(t){typeof document>"u"||(t==="purple"?delete document.documentElement.dataset.accent:document.documentElement.dataset.accent=t)}function iu(t){try{localStorage.setItem(Kr,t)}catch{}}function uu(){try{const t=localStorage.getItem(Kr);if(t&&Jr.includes(t))return t}catch{}return"purple"}function Gr(){if(cr)return;cr=!0;const t=uu();Wt.value=t,Yr(t)}function du(){Gr();function t(o){Wt.value=o,Yr(o),iu(o)}return{theme:Wt,themes:Jr,setTheme:t}}const Zr="/agents/assets/img/agent-builder-logo-light.svg",Xr="/agents/assets/img/agent-builder-logo-dark.svg",cu="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",pu="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",mu=["src"],vu=["src"],fu={class:"flex-1 flex flex-col justify-between pt-2 pb-4"},hu={class:"flex flex-col gap-1 px-2"},gu={key:0},bu=["onClick","title"],xu={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis text-left"},yu={key:0,class:"ml-4 space-y-0.5"},ku=["onClick"],wu={class:"whitespace-nowrap overflow-hidden text-ellipsis"},_u=["onClick","title"],$u={key:0,class:"whitespace-nowrap overflow-hidden text-ellipsis"},Cu={class:"flex flex-col gap-1 px-2"},Su=["title"],Tu={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis"},Iu={class:"relative settings-menu-container"},zu={key:0,class:"absolute bottom-full mb-2 left-0 z-50"},Vu={class:"px-4 py-3 border-b border-neutral-200 dark:border-neutral-700"},Mu=["title"],Eu={class:"relative z-10 flex items-center justify-center w-8 h-full"},Lu={class:"relative z-10 flex items-center justify-center w-8 h-full"},Pu={class:"px-4 pt-3 pb-4 border-b border-neutral-200 dark:border-neutral-700"},Au={class:"grid grid-cols-5 gap-3"},ju=["onClick","title"],Du={key:0,class:"w-2 h-2 rounded-full bg-white shadow-sm"},Ou={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"},Ru=me({__name:"Sidebar",props:{isCollapsed:{type:Boolean},isDark:{type:Boolean}},emits:["toggle-sidebar","toggle-theme"],setup(t,{emit:o}){function a(se){if(se.startsWith("/src/")||se.startsWith("data:"))return se;const de=_t();return de==="/"?se.replace("/agents/","/"):se.replace("/agents/",`${de}/`)}const i=a(Zr),l=a(Xr),u=a(cu),s=a(pu),m=t,h=ut(),x=bt(),c=B(()=>h.name);function f(se){const de=h.path;return de===se.path||de.startsWith(se.path+"/")}const y=B(()=>m.isDark?l:i),b=B(()=>m.isDark?s:u),v=[{id:"threads",label:"Threads",icon:Ni,path:"/threads"},{id:"agents",label:"Agents",icon:mt,path:"/agents"},{id:"prompts",label:"Prompts",icon:Et,path:"/prompts"},{id:"tools",label:"Tools",icon:qt,path:"/tools",hasSubnav:!0,subnav:[{id:"tools-functions",label:"Functions",icon:Wi,path:"/tools#functions"},{id:"tools-prompts",label:"Prompts",icon:Et,path:"/tools#prompts"},{id:"tools-agents",label:"Agents",icon:mt,path:"/tools#agents"}]},{id:"models",label:"Models",icon:Ci,path:"/models"},{id:"providers",label:"Providers",icon:Ii,path:"/providers"}],d=se=>{x.push(se)},k=se=>{x.push(se),_.value=!1},g=B(()=>typeof c.value=="string"&&(c.value==="tools"||c.value.startsWith("tools-"))),_=p(!1),{theme:L,themes:R,setTheme:K}=du(),Y={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"},z=B(()=>c.value==="users"||c.value==="api-keys"),P=()=>{_.value=!_.value},G=()=>{localStorage.removeItem("auth_token"),x.push("/login")},ee=se=>{const de=se.target;_.value&&!de.closest(".settings-menu-container")&&(_.value=!1)};return Pe(()=>{document.addEventListener("click",ee)}),Ye(()=>{document.removeEventListener("click",ee)}),(se,de)=>(r(),n("aside",{class:ae(["flex flex-col transition-all duration-300 pt-2.5",t.isCollapsed?"w-16":"w-60"])},[e("div",{class:ae(`flex items-center justify-between ${t.isCollapsed?"px-2 py-4":"p-4"}`)},[t.isCollapsed?I("",!0):(r(),n("img",{key:0,src:y.value,alt:"AgentBuilder",class:"h-8 mr-2 mt-0.5"},null,8,mu)),e("button",{onClick:de[0]||(de[0]=Q=>se.$emit("toggle-sidebar")),class:ae(`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?(r(),n("img",{key:1,src:b.value,alt:"AgentBuilder",class:"w-7 h-7 m-auto"},null,8,vu)):(r(),H(T(Wr),{key:0,class:"w-5 h-5"}))],2)],2),e("nav",fu,[e("div",hu,[(r(),n(ve,null,ye(v,Q=>(r(),n(ve,{key:Q.id},[Q.hasSubnav?(r(),n("div",gu,[e("button",{onClick:E=>d(Q.path),class:ae(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all w-full",g.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?Q.label:void 0},[(r(),H(Ue(Q.icon),{class:"w-5 h-5 flex-shrink-0"})),t.isCollapsed?I("",!0):(r(),n("span",xu,C(Q.label),1))],10,bu),!t.isCollapsed&&Q.subnav?(r(),n("div",yu,[(r(!0),n(ve,null,ye(Q.subnav,E=>(r(),n("button",{key:E.id,onClick:S=>d(E.path),class:ae(["flex items-center gap-3 px-3 py-1.5 text-sm transition-all w-full",c.value===E.id?"bg-black text-white dark:bg-white dark:text-black rounded":"hover:underline"])},[(r(),H(Ue(E.icon),{class:"w-4 h-4 flex-shrink-0"})),e("span",wu,C(E.label),1)],10,ku))),128))])):I("",!0)])):(r(),n("button",{key:1,onClick:E=>d(Q.path),class:ae(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all",f(Q)?"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?Q.label:void 0},[(r(),H(Ue(Q.icon),{class:"w-5 h-5 flex-shrink-0"})),t.isCollapsed?I("",!0):(r(),n("span",$u,C(Q.label),1))],10,_u))],64))),64))]),e("div",Cu,[e("a",{href:"https://docs.standardagentbuilder.com/",target:"_blank",rel:"noopener noreferrer",class:ae(["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},[w(T(ou),{class:"w-5 h-5 flex-shrink-0"}),t.isCollapsed?I("",!0):(r(),n("span",Tu," Docs ")),t.isCollapsed?I("",!0):(r(),H(T(su),{key:1,class:"w-3 h-3 flex-shrink-0 opacity-50"}))],10,Su),e("div",{class:ae(["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",Iu,[e("button",{onClick:Re(P,["stop"]),class:ae(["p-2 rounded transition-colors flex items-center",_.value||z.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"},[w(T(Ht),{class:"w-5 h-5 flex-shrink-0"})],2),_.value?(r(),n("div",zu,[w(T(At),{width:"min-w-[200px]",shadow:{offsetX:6,offsetY:6,intensity:.4}},{default:D(()=>[e("div",Vu,[de[4]||(de[4]=e("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Appearance ",-1)),e("button",{onClick:de[1]||(de[1]=Re(Q=>se.$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:ae(["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",Eu,[w(T(Di),{class:ae(["w-4 h-4",t.isDark?"text-neutral-500":"text-black"])},null,8,["class"])]),e("span",Lu,[w(T(Ui),{class:ae(["w-4 h-4",t.isDark?"text-white":"text-neutral-400"])},null,8,["class"])])],8,Mu)]),e("div",Pu,[de[5]||(de[5]=e("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Accent Color ",-1)),e("div",Au,[(r(!0),n(ve,null,ye(T(R),Q=>(r(),n("button",{key:Q,onClick:Re(E=>T(K)(Q),["stop"]),class:ae(["w-6 h-6 rounded-full transition-all flex items-center justify-center ring-1 ring-black/10 dark:ring-white/10",[Y[Q],T(L)===Q?"ring-2 ring-black/50 dark:ring-white/50":"hover:scale-110"]]),title:Q.charAt(0).toUpperCase()+Q.slice(1)},[T(L)===Q?(r(),n("span",Du)):I("",!0)],10,ju))),128))])]),e("button",{onClick:de[2]||(de[2]=Q=>k("/settings/users")),class:ae(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",c.value==="users"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[w(T(Xi),{class:"w-4 h-4 flex-shrink-0"}),de[6]||(de[6]=e("span",{class:"whitespace-nowrap"},"Users",-1))],2),e("button",{onClick:de[3]||(de[3]=Q=>k("/settings/api-keys")),class:ae(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",c.value==="api-keys"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[w(T(tu),{class:"w-4 h-4 flex-shrink-0"}),de[7]||(de[7]=e("span",{class:"whitespace-nowrap"},"API Keys",-1))],2)]),_:1})])):I("",!0)]),e("button",{onClick:G,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"},[w(T(Yi),{class:"w-5 h-5 flex-shrink-0"}),t.isCollapsed?I("",!0):(r(),n("span",Ou,"Logout"))])],2)])])],2))}}),Uu={class:"warning-banner-container"},Bu={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"},Fu={class:"flex items-center gap-2"},Nu=["onClick"],qu=me({__name:"WarningBanner",setup(t){const o=p([]),a=p(new Set),i=async()=>{if(localStorage.getItem("auth_token"))try{const h=await fetch(fe("/api/diagnostics"));if(h.ok){const x=await h.json();o.value=x.warnings||[]}}catch{}},l=m=>{const h=`${m.type}:${m.details?.name||m.message}`;a.value.add(h)},u=m=>{const h=`${m.type}:${m.details?.name||m.message}`;return!a.value.has(h)},s=m=>{if(m.type==="duplicate_tool_name"){const h=m.details?.sources?.join(" and ")||"multiple sources";return`Duplicate tool name "${m.details?.name}" (defined as both ${h}). This may cause unexpected behavior.`}return m.message};return Pe(()=>{i()}),(m,h)=>(r(),n("div",Uu,[(r(!0),n(ve,null,ye(o.value,x=>(r(),n(ve,{key:`${x.type}:${x.details?.name}`},[u(x)?(r(),n("div",Bu,[e("div",Fu,[h[0]||(h[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(s(x)),1)]),e("button",{onClick:c=>l(x),class:"text-amber-600 dark:text-amber-400 hover:text-amber-800 dark:hover:text-amber-200 p-1",title:"Dismiss"},[...h[1]||(h[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,Nu)])):I("",!0)],64))),128))]))}}),Hu={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"},Wu={class:"flex-1 overflow-auto"},Ku=me({__name:"App",setup(t){Gr();const o=ut(),a=p(!1),i=p(!1),l=B(()=>o.name!=="login"),u=()=>{a.value=!a.value},s=()=>{i.value=!i.value,i.value?(document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark")):(document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light"))};return Pe(()=>{const m=localStorage.getItem("theme");(m==="dark"||!m&&window.matchMedia("(prefers-color-scheme: dark)").matches)&&(i.value=!0,document.documentElement.classList.add("dark"))}),(m,h)=>(r(),n("div",{class:ae(["app-container relative flex h-screen font-sans bg-neutral-50/80 text-black dark:bg-black dark:text-white",{"is-dark":i.value}])},[l.value?(r(),H(Ru,{key:0,"is-collapsed":a.value,"is-dark":i.value,onToggleSidebar:u,onToggleTheme:s},null,8,["is-collapsed","is-dark"])):I("",!0),l.value?(r(),n("main",Hu,[w(qu),e("div",Wu,[w(T(tr))])])):(r(),H(T(tr),{key:1}))],2))}}),Ju=Xe(Ku,[["__scopeId","data-v-2125e5d3"]]),Yu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Gu(t,o){return r(),n("svg",Yu,[...o[0]||(o[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 Zu=Ie({name:"lucide-trash-2",render:Gu}),Xu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Qu(t,o){return r(),n("svg",Xu,[...o[0]||(o[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 ed=Ie({name:"lucide-edit",render:Qu}),td={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function rd(t,o){return r(),n("svg",td,[...o[0]||(o[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=Ie({name:"lucide-eye",render:rd}),ad={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function od(t,o){return r(),n("svg",ad,[...o[0]||(o[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m18 15l-6-6l-6 6"},null,-1)])])}const nd=Ie({name:"lucide-chevron-up",render:od}),ld={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function sd(t,o){return r(),n("svg",ld,[...o[0]||(o[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m6 9l6 6l6-6"},null,-1)])])}const id=Ie({name:"lucide-chevron-down",render:sd}),ud={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function dd(t,o){return r(),n("svg",ud,[...o[0]||(o[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m7 15l5 5l5-5M7 9l5-5l5 5"},null,-1)])])}const cd=Ie({name:"lucide-chevrons-up-down",render:dd}),pd={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function md(t,o){return r(),n("svg",pd,[...o[0]||(o[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M22 12h-6l-2 3h-4l-2-3H2"}),e("path",{d:"M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11"})],-1)])])}const vd=Ie({name:"lucide-inbox",render:md}),fd={key:0,class:"w-full max-w-md"},hd={class:"flex items-center justify-between p-4 border-b border-red-200 dark:border-red-900 flex-shrink-0"},gd={class:"text-xl font-bold text-red-600"},bd={class:"p-6"},xd={class:"text-neutral-700 dark:text-neutral-300 mb-6"},yd={class:"flex justify-end gap-3"},Xt=me({__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:o}){const a=t,i=o,l=()=>{i("update:modelValue",!1)},u=()=>{i("confirm"),l()},s=()=>{i("cancel"),l()},m=h=>{h.key==="Escape"&&a.modelValue&&s()};return ge(()=>a.modelValue,h=>{h?(document.addEventListener("keydown",m),document.body.style.overflow="hidden"):(document.removeEventListener("keydown",m),document.body.style.overflow="")}),(h,x)=>(r(),H(kt,{to:"body"},[w(et,{"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:D(()=>[t.modelValue?(r(),n("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:s},[w(et,{"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:D(()=>[t.modelValue?(r(),n("div",fd,[w(wt,{"offset-x":8,"offset-y":8,intensity:.35},{default:D(()=>[e("div",{class:"bg-white dark:bg-neutral-900 border border-red-400 dark:border-red-500 rounded-lg flex flex-col",onClick:x[0]||(x[0]=Re(()=>{},["stop"]))},[e("div",hd,[e("h2",gd,C(t.title),1),w(T(Br),{icon:T(Pt),label:"Close dialog",variant:"danger",onClick:s},null,8,["icon"])]),e("div",bd,[e("p",xd,C(t.message),1),e("div",yd,[w(T(De),{variant:"secondary",onClick:s},{default:D(()=>[Z(C(t.cancelText),1)]),_:1}),w(T(De),{variant:"danger",onClick:u},{default:D(()=>[Z(C(t.confirmText),1)]),_:1})])])])]),_:1})])):I("",!0)]),_:1})])):I("",!0)]),_:1})]))}}),kd={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function wd(t,o){return r(),n("svg",kd,[...o[0]||(o[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])])}const _d=Ie({name:"lucide-chevron-right",render:wd}),$d={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Cd(t,o){return r(),n("svg",$d,[...o[0]||(o[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m11 17l-5-5l5-5m7 10l-5-5l5-5"},null,-1)])])}const Sd=Ie({name:"lucide-chevrons-left",render:Cd}),Td={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Id(t,o){return r(),n("svg",Td,[...o[0]||(o[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m6 17l5-5l-5-5m7 10l5-5l-5-5"},null,-1)])])}const zd=Ie({name:"lucide-chevrons-right",render:Id}),Vd={key:0,class:"flex flex-wrap items-center justify-between gap-4 px-4 py-2.5 text-sm bg-neutral-50 dark:bg-neutral-800/50 border-t border-neutral-300 dark:border-neutral-700"},Md={class:"text-neutral-500 dark:text-neutral-400 text-xs font-medium"},Ed={class:"text-neutral-700 dark:text-neutral-300"},Ld={class:"text-neutral-700 dark:text-neutral-300"},Pd={class:"text-neutral-700 dark:text-neutral-300"},Ad={class:"flex items-center gap-0.5"},jd=["disabled"],Dd=["disabled"],Od={class:"flex items-center gap-0.5 mx-1"},Rd={key:0,class:"px-2 text-neutral-400 dark:text-neutral-500 text-xs"},Ud=["onClick"],Bd=["disabled"],Fd=["disabled"],Nd={class:"flex items-center gap-2"},qd=["value"],Hd=["value"],Wd=me({__name:"DataTablePagination",props:{page:{},pageSize:{},totalItems:{},pageSizeOptions:{default:()=>[10,25,50,100]}},emits:["update:page","update:pageSize"],setup(t,{emit:o}){const a=t,i=o,l=B(()=>Math.ceil(a.totalItems/a.pageSize)),u=B(()=>a.totalItems===0?0:(a.page-1)*a.pageSize+1),s=B(()=>Math.min(a.page*a.pageSize,a.totalItems)),m=B(()=>a.page>1),h=B(()=>a.page<l.value),x=B(()=>{const k=[],g=l.value,_=a.page;if(g<=7)for(let L=1;L<=g;L++)k.push(L);else{k.push(1),_>3&&k.push("...");const L=Math.max(2,_-1),R=Math.min(g-1,_+1);for(let K=L;K<=R;K++)k.includes(K)||k.push(K);_<g-2&&k.push("..."),k.includes(g)||k.push(g)}return k}),c=k=>{k>=1&&k<=l.value&&i("update:page",k)},f=()=>c(1),y=()=>c(a.page-1),b=()=>c(a.page+1),v=()=>c(l.value),d=k=>{const g=k.target;i("update:pageSize",parseInt(g.value,10)),i("update:page",1)};return(k,g)=>t.totalItems>0?(r(),n("div",Vd,[e("div",Md,[g[0]||(g[0]=Z(" Showing ",-1)),e("span",Ed,C(u.value),1),g[1]||(g[1]=Z(" to ",-1)),e("span",Ld,C(s.value),1),g[2]||(g[2]=Z(" of ",-1)),e("span",Pd,C(t.totalItems),1)]),e("div",Ad,[e("button",{type:"button",onClick:f,disabled:!m.value,class:"p-1.5 rounded-md transition-all duration-150 hover:bg-neutral-200 dark:hover:bg-neutral-700 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent",title:"First page"},[w(T(Sd),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,jd),e("button",{type:"button",onClick:y,disabled:!m.value,class:"p-1.5 rounded-md transition-all duration-150 hover:bg-neutral-200 dark:hover:bg-neutral-700 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent",title:"Previous page"},[w(T(Wr),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,Dd),e("div",Od,[(r(!0),n(ve,null,ye(x.value,(_,L)=>(r(),n(ve,{key:L},[_==="..."?(r(),n("span",Rd," ... ")):(r(),n("button",{key:1,type:"button",onClick:R=>c(_),class:ae(["min-w-[1.75rem] px-2 py-1 rounded-md text-xs font-medium transition-all duration-150",_===t.page?"bg-accent-600 text-white shadow-sm":"text-neutral-600 dark:text-neutral-400 hover:bg-neutral-200 dark:hover:bg-neutral-700 hover:text-neutral-900 dark:hover:text-neutral-200"])},C(_),11,Ud))],64))),128))]),e("button",{type:"button",onClick:b,disabled:!h.value,class:"p-1.5 rounded-md transition-all duration-150 hover:bg-neutral-200 dark:hover:bg-neutral-700 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent",title:"Next page"},[w(T(_d),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,Bd),e("button",{type:"button",onClick:v,disabled:!h.value,class:"p-1.5 rounded-md transition-all duration-150 hover:bg-neutral-200 dark:hover:bg-neutral-700 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent",title:"Last page"},[w(T(zd),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,Fd)]),e("div",Nd,[e("select",{value:t.pageSize,onChange:d,class:"px-2 py-1 rounded-md border border-neutral-200 dark:border-neutral-700 bg-white dark:bg-neutral-800 text-xs font-medium text-neutral-700 dark:text-neutral-300 focus:outline-none focus:ring-2 focus:ring-accent-500/30 focus:border-accent-500 dark:focus:border-accent-400 cursor-pointer transition-all"},[(r(!0),n(ve,null,ye(t.pageSizeOptions,_=>(r(),n("option",{key:_,value:_},C(_),9,Hd))),128))],40,qd),g[3]||(g[3]=e("span",{class:"text-neutral-500 dark:text-neutral-400 text-xs"},"per page",-1))])])):I("",!0)}}),Kd={class:"w-full"},Jd={key:0,class:"flex flex-wrap items-start justify-between gap-4 mb-5"},Yd={class:"flex items-center gap-3"},Gd={class:"flex items-center gap-2"},Zd={key:0,class:"text-xl font-bold tracking-tight"},Xd={key:1,class:"text-xs font-mono text-neutral-400 dark:text-neutral-500"},Qd={key:0,class:"text-sm text-neutral-500 dark:text-neutral-400 mt-0.5"},ec={key:0,class:"flex items-center gap-2"},tc={key:1,class:"mb-4"},rc={class:"flex flex-wrap items-center gap-3"},ac={key:0,class:"flex-1 min-w-[200px] max-w-md"},oc={key:2,class:"flex items-center gap-2 ml-auto"},nc={class:"text-sm text-neutral-500 dark:text-neutral-400 font-medium"},lc={class:"flex items-center gap-1.5"},sc=["onClick"],ic={class:"rounded-xl border border-neutral-300 dark:border-neutral-700 overflow-hidden bg-white dark:bg-transparent"},uc={class:"overflow-x-auto"},dc={class:"w-full"},cc={class:"bg-neutral-50 dark:bg-neutral-800/50 border-b border-neutral-300 dark:border-neutral-700"},pc={key:0,class:"px-4 py-2.5 w-12"},mc={class:"flex items-center justify-center"},vc=["checked","indeterminate"],fc=["onClick"],hc={key:1,class:"px-4 py-2.5 text-right font-medium text-xs uppercase tracking-wide text-neutral-500 dark:text-neutral-400 w-24"},gc={class:"divide-y divide-neutral-200 dark:divide-neutral-800"},bc={key:0},xc=["colspan"],yc={class:"flex flex-col items-center justify-center gap-3 text-neutral-400"},kc={key:1},wc=["colspan"],_c={class:"flex flex-col items-center justify-center gap-3 text-neutral-400"},$c={class:"w-12 h-12 rounded-full bg-neutral-100 dark:bg-neutral-800 flex items-center justify-center"},Cc={class:"text-sm"},Sc=["onClick"],Tc={key:0,class:"absolute left-0 top-0 bottom-0 w-0.5 bg-accent-500"},Ic={class:"flex items-center justify-center"},zc=["checked","onChange"],Vc=["innerHTML"],Mc={class:"inline-flex gap-0.5"},Ec=["disabled","onClick","title"],Lc=["disabled","onClick","title"],ot=me({__name:"DataTable",props:{columns:{},data:{},actions:{},emptyMessage:{default:"No data available"},loading:{type:Boolean,default:!1},title:{},description:{},primaryAction:{},sortable:{type:Boolean,default:!1},sortKey:{},sortDirection:{default:"asc"},searchable:{type:Boolean,default:!1},searchQuery:{default:""},searchPlaceholder:{default:"Search..."},paginated:{type:Boolean,default:!1},page:{default:1},pageSize:{default:10},totalItems:{default:0},pageSizeOptions:{default:()=>[10,25,50,100]},selectable:{type:Boolean,default:!1},selectedRows:{default:()=>[]},rowKey:{default:"id"},bulkActions:{default:()=>[]}},emits:["update:sortKey","update:sortDirection","sort","update:searchQuery","search","update:page","update:pageSize","page-change","update:selectedRows","selection-change","row-click"],setup(t,{emit:o}){const a=t,i=o,l=p(!1),u=p(""),s=p(null),m=$=>{if(typeof $!="string")return $;switch($){case"edit":return ed;case"delete":return Zu;case"view":return Kt;default:return null}},h=($,j)=>{const he=$[j.key];return j.formatter?j.formatter(he,$):he??"-"},x=$=>{switch($){case"center":return"text-center";case"right":return"text-right";default:return"text-left"}},c=($,j)=>j.cellClass?typeof j.cellClass=="function"?j.cellClass($):j.cellClass:"",f=async($,j)=>{if($.confirm){const he=typeof $.confirmMessage=="function"?$.confirmMessage(j):$.confirmMessage||`Are you sure you want to ${$.label.toLowerCase()}?`;u.value=he,s.value=async()=>{await $.handler(j)},l.value=!0}else await $.handler(j)},y=async()=>{s.value&&(await s.value(),s.value=null),l.value=!1},b=()=>{s.value=null,l.value=!1},v=($,j)=>$.visible===void 0?!0:typeof $.visible=="function"?$.visible(j):$.visible,d=($,j)=>$.disabled===void 0?!1:typeof $.disabled=="function"?$.disabled(j):$.disabled,k=p(null),g=p("asc"),_=B(()=>a.sortKey??k.value),L=B(()=>a.sortKey!==void 0?a.sortDirection:g.value),R=$=>a.sortable&&$.sortable===!0,K=$=>{if(!R($))return;const j=$.key;let he="asc";_.value===j&&(he=L.value==="asc"?"desc":"asc"),k.value=j,g.value=he,i("update:sortKey",j),i("update:sortDirection",he),i("sort",{key:j,direction:he})},Y=$=>_.value!==$.key?cd:L.value==="asc"?nd:id,z=B(()=>{if(!_.value||!a.sortable)return S.value;const $=_.value,j=L.value;return[...S.value].sort((he,X)=>{const pe=he[$],le=X[$];if(pe==null&&le==null)return 0;if(pe==null)return j==="asc"?1:-1;if(le==null)return j==="asc"?-1:1;let we=0;return typeof pe=="string"&&typeof le=="string"?we=pe.localeCompare(le,void 0,{sensitivity:"base"}):typeof pe=="number"&&typeof le=="number"?we=pe-le:we=String(pe).localeCompare(String(le)),j==="asc"?we:-we})}),P=p(a.searchQuery),G=p({}),ee=zr($=>{i("update:searchQuery",$),i("search",$)},300),se=$=>{P.value=$,ee($)},de=()=>{P.value="",i("update:searchQuery",""),i("search","")},Q=B(()=>a.columns.filter($=>$.filterable===!0).map($=>{const j=new Map;a.data.forEach(X=>{const pe=X[$.key];if(pe!=null){const le=$.formatter?$.formatter(pe,X):String(pe);if(!j.has(le)){const we=$.filterIcon?$.filterIcon(pe,X):void 0;j.set(le,{value:le,icon:we})}}});const he=Array.from(j.entries()).sort((X,pe)=>X[0].localeCompare(pe[0]));return{key:$.key,label:$.label,options:he.map(([X,pe])=>({value:X,label:X,icon:pe.icon}))}})),E=($,j)=>{if(j===""){const{[$]:he,...X}=G.value;G.value=X}else G.value={...G.value,[$]:j}},S=B(()=>{let $=a.data;const j=Object.entries(G.value);if(j.length>0&&($=$.filter(he=>j.every(([X,pe])=>{const le=a.columns.find(ie=>ie.key===X);if(!le)return!0;const we=he[X];return we==null?!1:(le.formatter?le.formatter(we,he):String(we))===pe}))),a.searchable&&P.value.trim()){const he=P.value.toLowerCase().trim();$=$.filter(X=>a.columns.some(pe=>{if(pe.searchable===!1)return!1;const le=X[pe.key];return le==null?!1:(pe.formatter?pe.formatter(le,X):String(le)).toLowerCase().includes(he)}))}return $}),V=B(()=>{let $=0;return P.value&&$++,$+=Object.keys(G.value).length,$}),re=()=>{de(),G.value={}},F=$=>$[a.rowKey],q=$=>{const j=F($);return a.selectedRows.some(he=>he[a.rowKey]===j)},N=B(()=>z.value.length>0&&a.selectedRows.length===z.value.length),J=B(()=>a.selectedRows.length>0&&a.selectedRows.length<z.value.length),U=$=>{const j=F($);let he;q($)?he=a.selectedRows.filter(X=>X[a.rowKey]!==j):he=[...a.selectedRows,$],i("update:selectedRows",he),i("selection-change",he)},W=()=>{const $=N.value?[]:[...z.value];i("update:selectedRows",$),i("selection-change",$)},M=async $=>{if($.confirm){const j=$.confirmMessage||`Are you sure you want to ${$.label.toLowerCase()} ${a.selectedRows.length} item(s)?`;u.value=j,s.value=async()=>{await $.handler(a.selectedRows)},l.value=!0}else await $.handler(a.selectedRows)},ne=$=>{i("update:page",$),i("page-change",$)},A=$=>{i("update:pageSize",$)},ce=B(()=>a.title||a.description||a.primaryAction),ue=B(()=>a.actions&&a.actions.length>0),ke=B(()=>a.actions?.filter($=>$.variant!=="danger")||[]),be=B(()=>a.actions?.filter($=>$.variant==="danger")||[]),O=B(()=>{let $=a.columns.length;return a.selectable&&$++,ue.value&&$++,$});return($,j)=>{const he=Be("FormKit");return r(),n("div",Kd,[ce.value?(r(),n("div",Jd,[e("div",Yd,[e("div",null,[e("div",Gd,[t.title?(r(),n("h2",Zd,C(t.title),1)):I("",!0),!t.loading&&t.data.length>0?(r(),n("span",Xd,[V.value>0&&S.value.length!==t.data.length?(r(),n(ve,{key:0},[Z(" ("+C(S.value.length)+" of "+C(t.data.length)+") ",1)],64)):(r(),n(ve,{key:1},[Z(" ("+C(t.data.length)+") ",1)],64))])):I("",!0)]),t.description?(r(),n("p",Qd,C(t.description),1)):I("",!0)])]),t.primaryAction?(r(),n("div",ec,[je($.$slots,"header-actions"),w(T(De),{onClick:t.primaryAction.handler},{default:D(()=>[t.primaryAction.icon?(r(),H(Ue(t.primaryAction.icon),{key:0,class:"w-4 h-4 mr-2"})):I("",!0),Z(" "+C(t.primaryAction.label),1)]),_:1},8,["onClick"])])):I("",!0)])):I("",!0),t.searchable||Q.value.length>0?(r(),n("div",tc,[e("div",rc,[t.searchable?(r(),n("div",ac,[w(he,{type:"searchInput",value:P.value,placeholder:t.searchPlaceholder,onInput:se},null,8,["value","placeholder"])])):I("",!0),(r(!0),n(ve,null,ye(Q.value,X=>(r(),n("div",{key:X.key,class:"min-w-[220px]"},[w(he,{type:"selectSearch",value:G.value[X.key]||"",options:X.options,placeholder:`All ${X.label}s`,onInput:pe=>E(X.key,pe)},null,8,["value","options","placeholder","onInput"])]))),128)),V.value>0?(r(),n("button",{key:1,type:"button",onClick:re,class:"px-3 py-2 text-sm font-medium text-neutral-500 hover:text-neutral-700 dark:text-neutral-400 dark:hover:text-neutral-200 transition-colors"}," Clear filters ")):I("",!0),t.selectable&&t.selectedRows.length>0&&t.bulkActions.length>0?(r(),n("div",oc,[e("span",nc,C(t.selectedRows.length)+" selected ",1),e("div",lc,[(r(!0),n(ve,null,ye(t.bulkActions,(X,pe)=>(r(),n("button",{key:pe,type:"button",onClick:le=>M(X),class:ae(["inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-150",X.variant==="danger"?"bg-red-100 text-red-700 hover:bg-red-200 dark:bg-red-900/30 dark:text-red-400 dark:hover:bg-red-900/50":"bg-neutral-100 text-neutral-700 hover:bg-neutral-200 dark:bg-neutral-800 dark:text-neutral-300 dark:hover:bg-neutral-700"])},[(r(),H(Ue(X.icon),{class:"w-4 h-4"})),Z(" "+C(X.label),1)],10,sc))),128))])])):I("",!0)])])):I("",!0),je($.$slots,"toolbar"),e("div",ic,[e("div",uc,[e("table",dc,[e("thead",cc,[e("tr",null,[t.selectable?(r(),n("th",pc,[e("div",mc,[e("input",{type:"checkbox",checked:N.value,indeterminate:J.value,onChange:W,class:"w-4 h-4 rounded border-neutral-300 dark:border-neutral-600 text-accent-600 focus:ring-accent-500 focus:ring-offset-0 cursor-pointer transition-colors"},null,40,vc)])])):I("",!0),(r(!0),n(ve,null,ye(t.columns,X=>(r(),n("th",{key:X.key,class:ae(["px-4 py-2.5 font-medium text-xs uppercase tracking-wide text-neutral-500 dark:text-neutral-400",x(X.align),X.width||"",R(X)?"cursor-pointer select-none group":""]),onClick:pe=>K(X)},[e("div",{class:ae(["inline-flex items-center gap-1",X.align==="right"?"flex-row-reverse":"",R(X)?"hover:text-neutral-700 dark:hover:text-neutral-200 transition-colors":""])},[e("span",null,C(X.label),1),R(X)?(r(),n("span",{key:0,class:ae(["inline-flex items-center justify-center w-5 h-5 rounded transition-all duration-150",_.value===X.key?"bg-accent-100 dark:bg-accent-900/50":"group-hover:bg-neutral-200 dark:group-hover:bg-neutral-700"])},[(r(),H(Ue(Y(X)),{class:ae(["w-3.5 h-3.5",_.value===X.key?"text-accent-600 dark:text-accent-400":"text-neutral-400 dark:text-neutral-500"])},null,8,["class"]))],2)):I("",!0)],2)],10,fc))),128)),ue.value?(r(),n("th",hc," Actions ")):I("",!0)])]),e("tbody",gc,[t.loading?(r(),n("tr",bc,[e("td",{colspan:O.value,class:"px-4 py-16"},[je($.$slots,"loading",{},()=>[e("div",yc,[w(Ee,{size:"md"}),j[3]||(j[3]=e("span",{class:"text-sm"},"Loading data...",-1))])])],8,xc)])):z.value.length===0?(r(),n("tr",kc,[e("td",{colspan:O.value,class:"px-4 py-16"},[je($.$slots,"empty",{},()=>[e("div",_c,[e("div",$c,[w(T(vd),{class:"w-6 h-6"})]),e("p",Cc,C(t.emptyMessage),1),V.value>0?(r(),n("button",{key:0,onClick:re,type:"button",class:"text-xs text-accent-600 dark:text-accent-400 hover:underline font-medium"}," Clear filters ")):I("",!0)])])],8,wc)])):(r(!0),n(ve,{key:2},ye(z.value,(X,pe)=>(r(),n("tr",{key:X[t.rowKey]??pe,class:ae(["transition-all duration-150 cursor-pointer relative",q(X)?"bg-accent-50 dark:bg-accent-950/30":"hover:bg-neutral-50 dark:hover:bg-neutral-900/50"]),onClick:le=>i("row-click",X)},[q(X)?(r(),n("div",Tc)):I("",!0),t.selectable?(r(),n("td",{key:1,class:"px-4 py-3",onClick:j[0]||(j[0]=Re(()=>{},["stop"]))},[e("div",Ic,[e("input",{type:"checkbox",checked:q(X),onChange:le=>U(X),class:"w-4 h-4 rounded border-neutral-300 dark:border-neutral-600 text-accent-600 focus:ring-accent-500 focus:ring-offset-0 cursor-pointer transition-colors"},null,40,zc)])])):I("",!0),(r(!0),n(ve,null,ye(t.columns,le=>(r(),n("td",{key:le.key,class:ae(["px-4 py-3 text-sm",x(le.align),c(X,le),q(X)?"text-accent-900 dark:text-accent-100":"text-neutral-700 dark:text-neutral-300"])},[je($.$slots,`cell-${le.key}`,{value:X[le.key],row:X,column:le},()=>[le.html?(r(),n("span",{key:0,innerHTML:h(X,le)},null,8,Vc)):(r(),n(ve,{key:1},[Z(C(h(X,le)),1)],64))])],2))),128)),ue.value?(r(),n("td",{key:2,class:"px-4 py-3 text-right",onClick:j[1]||(j[1]=Re(()=>{},["stop"]))},[e("div",Mc,[(r(!0),n(ve,null,ye(ke.value,(le,we)=>Ae((r(),n("button",{key:`non-delete-${we}`,disabled:d(le,X),onClick:oe=>f(le,X),class:ae(["p-1.5 rounded-md transition-all duration-150",d(le,X)?"opacity-30 cursor-not-allowed":"text-neutral-400 hover:text-neutral-700 hover:bg-neutral-100 dark:hover:text-neutral-200 dark:hover:bg-neutral-800"]),title:le.label},[(r(),H(Ue(m(le.icon)),{class:"w-4 h-4"}))],10,Ec)),[[Ke,v(le,X)]])),128)),je($.$slots,"extra-actions",{row:X}),(r(!0),n(ve,null,ye(be.value,(le,we)=>Ae((r(),n("button",{key:`delete-${we}`,disabled:d(le,X),onClick:oe=>f(le,X),class:ae(["p-1.5 rounded-md transition-all duration-150",d(le,X)?"opacity-30 cursor-not-allowed":"text-neutral-400 hover:text-red-600 hover:bg-red-50 dark:hover:text-red-400 dark:hover:bg-red-900/30"]),title:le.label},[(r(),H(Ue(m(le.icon)),{class:"w-4 h-4"}))],10,Lc)),[[Ke,v(le,X)]])),128))])])):I("",!0)],10,Sc))),128))])])]),t.paginated?(r(),H(Wd,{key:0,page:t.page,"page-size":t.pageSize,"total-items":t.totalItems,"page-size-options":t.pageSizeOptions,"onUpdate:page":ne,"onUpdate:pageSize":A},null,8,["page","page-size","total-items","page-size-options"])):I("",!0)]),w(Xt,{modelValue:l.value,"onUpdate:modelValue":j[2]||(j[2]=X=>l.value=X),title:"Confirm Action",message:u.value,"confirm-text":"Confirm","cancel-text":"Cancel",onConfirm:y,onCancel:b},null,8,["modelValue","message"])])}}}),Pc={},Ac={xmlns:"http://www.w3.org/2000/svg",viewBox:"-12 -12 408 408",width:"1em",height:"1em",fill:"currentColor",stroke:"currentColor","stroke-width":"24","stroke-linejoin":"round","aria-hidden":"true"};function jc(t,o){return r(),n("svg",Ac,[...o[0]||(o[0]=[e("path",{d:"M384,171.75v9.75c-1.68,7.91-4.76,14.74-10.77,20.88l-113.42,115.85c-10.42,10.65-25.58,13.8-39.31,8.04-12.9-5.41-21.53-18.19-21.52-33.02l.03-43.8h-26.55c-32.35.02-67.19,7.63-94.92,24.63s-44.76,42.35-51.3,73.05c-1.42,6.68-5.61,11.51-12.38,12.08-6.37.54-11.26-3.83-13.86-9.7v-46.5c.42-1.2.55-2.61.71-4.61,7.99-103.74,94.18-186.48,198.25-192.75l.08-45.6c.02-14.6,8.87-27.11,21.33-32.38,13.91-5.89,29.05-2.63,39.51,8.05l112.3,114.71c6.23,6.36,9.94,13.03,11.82,21.33ZM211.97,223.41c7.34,0,13.01,5.78,13.01,12.84v56.98c.01,4.38,2.23,7.69,5.66,9.09,4.03,1.65,7.66.72,10.83-2.51l113.71-116.2c3.69-3.77,3.73-9.48.04-13.25l-113.69-116.21c-3.21-3.28-6.81-4.26-11.03-2.51-3.33,1.38-5.52,4.74-5.52,9.15l.03,56.96c0,7.8-5.62,13.53-13.58,13.54-48.85.09-95.31,19.31-130.18,53.54-26.49,26-45.26,59.26-51.99,96.82,34.96-40.83,86.25-56.16,137.95-58.21l44.76-.03Z"},null,-1)])])}const Dc=Xe(Pc,[["render",jc]]),Oc={},Rc={xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor"};function Uc(t,o){return r(),n("svg",Rc,[...o[0]||(o[0]=[e("path",{d:"M4 4h16v16H4V4zm2 2v12h4v-10h3v10h5V6H6z"},null,-1)])])}const Bc=Xe(Oc,[["render",Uc]]),Fc={class:"py-1"},Nc=me({__name:"ShareDropdown",props:{packageId:{}},emits:["download","publish"],setup(t,{emit:o}){const a=o,i=p(null),l=p(null);function u(){if(!i.value||!l.value)return;const x=i.value.getBoundingClientRect();let f=x.right-160;const y=8;f<y&&(f=y),l.value.style.top=`${x.bottom+4}px`,l.value.style.left=`${f}px`}function s(){l.value&&(l.value.matches(":popover-open")?l.value.hidePopover():(u(),l.value.showPopover()))}function m(x){l.value?.hidePopover(),a(x)}function h(){l.value?.matches(":popover-open")&&u()}return Pe(()=>{window.addEventListener("scroll",h,!0),window.addEventListener("resize",h)}),Ye(()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}),(x,c)=>(r(),n(ve,null,[e("button",{ref_key:"triggerButton",ref:i,type:"button",onClick:s,class:"p-1.5 rounded-md transition-all duration-150 text-neutral-400 hover:text-neutral-700 hover:bg-neutral-100 dark:hover:text-neutral-200 dark:hover:bg-neutral-800",title:"Share"},[w(Dc,{class:"w-4 h-4"})],512),e("div",{ref_key:"popoverEl",ref:l,popover:"auto",class:"w-40 p-0 m-0 border-0 bg-transparent overflow-visible"},[w(T(At),{width:"w-40",shadow:{offsetX:4,offsetY:4,intensity:.3}},{default:D(()=>[e("div",Fc,[w(T(ur),{onClick:c[0]||(c[0]=f=>m("download"))},{default:D(()=>[w(T(Sa),{class:"w-4 h-4 text-neutral-500"}),c[2]||(c[2]=e("span",null,"Download",-1))]),_:1}),w(T(ur),{onClick:c[1]||(c[1]=f=>m("publish"))},{default:D(()=>[w(Bc,{class:"w-4 h-4 text-neutral-500"}),c[3]||(c[3]=e("span",null,"Publish",-1))]),_:1})])]),_:1})],512)],64))}}),qc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Hc(t,o){return r(),n("svg",qc,[...o[0]||(o[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73zm1 .27V12"}),e("path",{d:"M3.29 7L12 12l8.71-5M7.5 4.27l9 5.15"})],-1)])])}const pr=Ie({name:"lucide-package",render:Hc}),Wc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Kc(t,o){return r(),n("svg",Wc,[...o[0]||(o[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M12 22v-9m3.17-10.79a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.66 1.66 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z"}),e("path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13"}),e("path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.64 1.64 0 0 0 1.63 0z"})],-1)])])}const Jc=Ie({name:"lucide-package-open",render:Kc}),Yc={class:"flex items-center gap-2"},Gc=me({__name:"AgentsDataTable",props:{title:{},description:{},primaryAction:{}},emits:["add","edit","delete","pack","unpack","publish"],setup(t,{expose:o,emit:a}){const i=a,l=p([]),u=p(!1),s=[{key:"title",label:"Title",width:"w-1/5",sortable:!0},{key:"type",label:"Type",width:"w-1/12",sortable:!0,formatter:b=>b==="dual_ai"?"Dual AI":"AI+Human"},{key:"side_a_agent_prompt_name",label:"Side A",width:"w-1/5",formatter:b=>b||"-"},{key:"side_b_agent_prompt_name",label:"Side B",width:"w-1/5",formatter:b=>b||"Human"},{key:"created_at",label:"Created",width:"w-1/6",sortable:!0,searchable:!1,formatter:b=>b?new Date(b*1e3).toLocaleDateString():"-"}],m=[{icon:pr,label:"Pack",handler:b=>i("pack",b),visible:b=>!b.packed},{icon:Jc,label:"Unpack",handler:b=>i("unpack",b),visible:b=>!!b.packed},{icon:"edit",label:"Edit",handler:b=>i("edit",b),visible:b=>!b.packed},{icon:"delete",label:"Delete",handler:async b=>{await x(b)},confirm:!0,confirmMessage:"Are you sure you want to delete this agent?",variant:"danger",visible:b=>!b.packed},{icon:"delete",label:"Delete Package",handler:async b=>{await c(b)},confirm:!0,confirmMessage:"Are you sure you want to delete this packed agent and all its contents?",variant:"danger",visible:b=>!!b.packed&&b.source==="local"}],h=async()=>{u.value=!0;try{const b=await fetch(fe("/api/agents"));if(b.ok){const v=await b.json();l.value=v.agents||[]}}catch(b){console.error("Error fetching agents:",b)}finally{u.value=!1}},x=async b=>{try{const v=await fetch(fe(`/api/agents/${b.id}`),{method:"DELETE"});if(v.ok)await h();else{const d=await v.json();alert(d.error||"Failed to delete agent")}}catch(v){console.error("Error deleting agent:",v),alert("Failed to delete agent")}},c=async b=>{if(b.packageId)try{const v=await fetch(fe(`/api/pack/${encodeURIComponent(b.packageId)}`),{method:"DELETE"});if(v.ok)await h();else{const d=await v.json();alert(d.error||"Failed to delete packed agent")}}catch(v){console.error("Error deleting packed agent:",v),alert("Failed to delete packed agent")}},f=b=>{b.packageId&&(window.location.href=fe(`/api/pack/${encodeURIComponent(b.packageId)}/download`))},y=b=>{i("publish",b)};return Pe(()=>{h()}),o({refresh:h}),(b,v)=>(r(),n("div",null,[w(ot,{title:t.title,description:t.description,"primary-action":t.primaryAction,columns:s,data:l.value,actions:m,loading:u.value,sortable:"",searchable:"","search-placeholder":"Search agents...","empty-message":"No agents available. Create your first agent to get started."},{"cell-title":D(({row:d})=>[e("div",Yc,[d.packed?(r(),H(T(pr),{key:0,class:"w-4 h-4 text-blue-500 flex-shrink-0",title:`Packed agent from ${d.packageId}`},null,8,["title"])):I("",!0),e("span",null,C(d.title),1)])]),"extra-actions":D(({row:d})=>[d.packed?(r(),H(Nc,{key:0,"package-id":d.packageId,onDownload:k=>f(d),onPublish:k=>y(d)},null,8,["package-id","onDownload","onPublish"])):I("",!0)]),_:1},8,["title","description","primary-action","data","loading"])]))}}),Zc={class:"flex items-center justify-between p-4 border-b border-neutral-200 dark:border-neutral-700 flex-shrink-0"},Xc={class:"text-xl font-bold"},Qc={key:0,class:"p-6 border-t border-neutral-200 dark:border-neutral-700 flex-shrink-0"},He=me({__name:"Modal",props:{modelValue:{type:Boolean},title:{},width:{default:"max-w-lg"},minHeight:{default:"min-h-[24rem]"},hasChanges:{type:Boolean,default:void 0},contentPadding:{type:Boolean,default:!0}},emits:["update:modelValue","close"],setup(t,{emit:o}){const a=t,i=o,l=p(),u=p(!1),s=p(new Map),m=()=>l.value&&(l.value.querySelector("input")||l.value.querySelector("textarea")||l.value.querySelector("select")||l.value.querySelector("[contenteditable]")||l.value.querySelector(".monaco-editor")),h=()=>{if(!l.value)return;l.value.querySelectorAll(".monaco-editor-container").forEach(K=>{const Y=K.__monacoEditor;if(Y&&typeof Y.getValue=="function"){const z=Y.getValue();s.value.set(K,z)}})},x=()=>{if(!l.value)return!1;const R=l.value.querySelectorAll(".monaco-editor-container");for(const K of R){const Y=K.__monacoEditor;if(Y&&typeof Y.getValue=="function"){const z=Y.getValue(),P=s.value.get(K);if(P===void 0||(Y.getRawOptions?.()||{}).readOnly===!0)continue;if(z!==P)return!0}}return!1},c=R=>{const K=R;return K.type==="checkbox"||K.type==="radio"?K.checked!==K.defaultChecked:(K.tagName==="SELECT",K.value!==K.defaultValue)},f=()=>{if(a.hasChanges!==void 0)return a.hasChanges;if(!l.value)return!1;if(x())return!0;const R=l.value.querySelectorAll("input, textarea, select");for(const K of R)if(c(K))return!0;return!1},y=()=>{m()&&f()?u.value=!0:b()},b=()=>{i("update:modelValue",!1),i("close")},v=()=>{u.value=!1,b()},d=()=>{u.value=!1},k=R=>{R.key==="Escape"&&a.modelValue&&(m()||b())};ge(()=>a.modelValue,async R=>{R?(document.addEventListener("keydown",k),document.body.style.overflow="hidden",await Le(),setTimeout(()=>{h()},100)):(document.removeEventListener("keydown",k),document.body.style.overflow="",s.value.clear())});const g=p(!1),_=R=>{g.value=R.target===R.currentTarget},L=R=>{R.target===R.currentTarget&&g.value&&(m()||b()),g.value=!1};return(R,K)=>(r(),H(kt,{to:"body"},[w(et,{"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:D(()=>[t.modelValue?(r(),n("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:_,onClick:L},[w(et,{"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:D(()=>[t.modelValue?(r(),n("div",{key:0,class:ae(["w-full",t.width,"max-h-[85vh] flex flex-col"])},[w(wt,{"offset-x":8,"offset-y":8,intensity:.35},{default:D(()=>[e("div",{ref_key:"modalRef",ref:l,class:ae(["bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-600 rounded-lg flex flex-col max-h-[85vh]",t.minHeight])},[e("div",Zc,[e("h2",Xc,C(t.title),1),w(T(Br),{icon:T(Pt),label:"Close modal",variant:"ghost",onClick:y},null,8,["icon"])]),e("div",{class:ae(["flex-1 min-h-0",t.contentPadding?"overflow-y-auto p-6":"overflow-hidden flex flex-col"])},[je(R.$slots,"default")],2),R.$slots.footer?(r(),n("div",Qc,[je(R.$slots,"footer")])):I("",!0)],2)]),_:3})],2)):I("",!0)]),_:3})],32)):I("",!0)]),_:3}),w(Xt,{modelValue:u.value,"onUpdate:modelValue":K[0]||(K[0]=Y=>u.value=Y),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:v,onCancel:d},null,8,["modelValue"])]))}}),e0=["id"],t0={class:"px-5 py-3 border-b border-neutral-100 dark:border-neutral-800"},r0={class:"text-sm font-semibold text-neutral-900 dark:text-neutral-100 flex items-center gap-2"},a0={class:"p-5"},o0={key:0,class:"px-5 py-3 border-t border-neutral-100 dark:border-neutral-800 bg-neutral-50 dark:bg-neutral-800/50"},rt=me({__name:"ModalCard",props:{id:{},title:{},icon:{}},setup(t){return(o,a)=>(r(),n("section",{id:t.id,class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-700 overflow-hidden"},[e("div",t0,[e("h3",r0,[t.icon?(r(),H(Ue(t.icon),{key:0,class:"w-4 h-4 text-neutral-500"})):I("",!0),Z(" "+C(t.title),1)])]),e("div",a0,[je(o.$slots,"default")]),o.$slots.footer?(r(),n("div",o0,[je(o.$slots,"footer")])):I("",!0)],8,e0))}}),n0={class:"flex flex-col gap-1 px-2"},l0=["onClick"],s0={class:"whitespace-nowrap overflow-hidden text-ellipsis"},Qr=me({__name:"ModalTabs",props:{tabs:{},activeTab:{}},emits:["select"],setup(t,{emit:o}){const a=o;return(i,l)=>(r(),n("div",n0,[(r(!0),n(ve,null,ye(t.tabs,u=>(r(),n("button",{key:u.id,type:"button",onClick:Re(s=>a("select",u.id),["prevent"]),class:ae(["flex items-center gap-3 px-3 py-2.5 rounded text-sm font-medium transition-all w-full text-left",t.activeTab===u.id?"bg-black text-white dark:bg-white dark:text-black":"text-neutral-600 dark:text-neutral-400 hover:bg-black/5 dark:hover:bg-white/10"])},[(r(),H(Ue(u.icon),{class:"w-4 h-4 flex-shrink-0"})),e("span",s0,C(u.label),1)],10,l0))),128))]))}}),i0={class:"text-sm font-semibold text-neutral-900 dark:text-neutral-100 pl-3 border-l-2 border-neutral-300 dark:border-neutral-600"},xt=me({__name:"ModalSubHeader",props:{title:{}},setup(t){return(o,a)=>(r(),n("h4",i0,C(t.title),1))}});function ea(t,o){const a=p(o[0]),i=()=>{const u=t.value;if(!u)return;const s=o.filter(f=>document.getElementById(`section-${f}`)!==null);if(s.length===0)return;if(u.scrollHeight-u.scrollTop-u.clientHeight<50){a.value=s[s.length-1];return}const h=u.getBoundingClientRect(),x=h.top+h.height*.3;let c=s[0];for(const f of s)document.getElementById(`section-${f}`).getBoundingClientRect().top<=x&&(c=f);a.value=c},l=u=>{const s=document.getElementById(`section-${u}`);if(s&&t.value){const m=t.value.getBoundingClientRect().top,h=s.getBoundingClientRect().top,x=t.value.scrollTop+(h-m);t.value.scrollTo({top:x,behavior:"smooth"})}};return ge(t,(u,s)=>{s&&s.removeEventListener("scroll",i),u&&(u.addEventListener("scroll",i),i())}),Vr(()=>{t.value?.removeEventListener("scroll",i)}),{activeTab:a,scrollToSection:l}}const u0={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function d0(t,o){return r(),n("svg",u0,[...o[0]||(o[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),e("path",{d:"M14 2v4a2 2 0 0 0 2 2h4M10 9H8m8 4H8m8 4H8"})],-1)])])}const Lt=Ie({name:"lucide-file-text",render:d0}),c0={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function p0(t,o){return r(),n("svg",c0,[...o[0]||(o[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}),e("circle",{cx:"12",cy:"7",r:"4"})],-1)])])}const mr=Ie({name:"lucide-user",render:p0}),m0={key:0,class:"min-h-[500px] flex items-center justify-center"},v0={class:"flex flex-1 min-h-0"},f0={class:"w-44 flex-shrink-0 border-r border-neutral-200 dark:border-neutral-700 py-4"},h0={class:"space-y-4"},g0={class:"space-y-5"},b0={class:"grid grid-cols-2 gap-4"},x0={key:0},y0={key:1},k0={key:2},w0={class:"space-y-5"},_0={class:"grid grid-cols-2 gap-4"},$0={class:"space-y-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},C0={key:0,class:"ml-6 mt-3 space-y-3"},S0={key:2},T0={class:"grid grid-cols-2 gap-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},I0={class:"space-y-5"},z0={class:"grid grid-cols-2 gap-4"},V0={class:"space-y-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},M0={key:0,class:"ml-6 mt-3 space-y-3"},E0={key:2},L0={class:"grid grid-cols-2 gap-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},P0={class:"space-y-3"},A0={key:0,class:"text-xs text-neutral-500"},j0={class:"flex justify-between"},D0=me({__name:"AgentModal",props:{modelValue:{type:Boolean},editAgent:{},mode:{},apiError:{}},emits:["update:modelValue","save"],setup(t,{emit:o}){const a=t,i=o,l=B(()=>a.mode==="edit"),u=p(!1),s=p(null),m=["basics","side-a","side-b","env"],{activeTab:h,scrollToSection:x}=ea(s,m),c=B(()=>{const Ce=[{id:"basics",label:"Basics",icon:Lt},{id:"side-a",label:"Side A",icon:mt},{id:"side-b",label:"Side B",icon:d.value==="ai_human"?mr:mt}];return($.value.length>0||Object.keys(j.value).length>0)&&Ce.push({id:"env",label:"Environment",icon:Ht}),Ce}),f=p(""),y=p(""),b=p(""),v=p(""),d=p("dual_ai"),k=p(!1),g=p(""),_=p(""),L=p(null),R=p(""),K=p(""),Y=p(""),z=p(""),P=p(!0),G=p(!1),ee=p(""),se=p(""),de=p(""),Q=p(""),E=p(!1),S=p(null),V=p(""),re=p(""),F=p(""),q=p(""),N=p(""),J=p(""),U=p(!0),W=p(!1),M=p(""),ne=p(""),A=p(""),ce=p(""),ue=p(null),ke=p(""),be=p(""),O=p(""),$=p([]),j=p({}),he=p(!1),{data:X,execute:pe}=Ne(fe("/api/prompts"),{immediate:!1}).json(),{data:le,execute:we}=Ne(fe("/api/tools?schema=true"),{immediate:!1}).json(),oe=p(null),ie=p(!1),Ve=p(null),_e=p(!1),$e=p(!1),xe=B(()=>{if(!X.value)return[{value:"",label:"Select a prompt..."}];const Ce=X.value?.prompts||[];return[{value:"",label:"None"},...Ce.map(te=>({value:te.id,label:te.name}))]}),Me=Ce=>le.value?le.value[Ce]:null,We=B(()=>!oe.value||!oe.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...oe.value.tools.map(Ce=>{const te=typeof Ce=="string"?Ce:Ce.name;return{value:te,label:te}})]),$t=B(()=>!Ve.value||!Ve.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...Ve.value.tools.map(Ce=>{const te=typeof Ce=="string"?Ce:Ce.name;return{value:te,label:te}})]),ia=B(()=>{if(!ee.value)return[];const Ce=Me(ee.value);return!Ce||!Ce.schema||!Ce.schema.properties?[]:Object.keys(Ce.schema.properties).map(te=>({value:te,label:te}))}),ua=B(()=>{if(!M.value)return[];const Ce=Me(M.value);return!Ce||!Ce.schema||!Ce.schema.properties?[]:Object.keys(Ce.schema.properties).map(te=>({value:te,label:te}))}),Ot=async()=>{const Ce=[Y.value,N.value].filter(Boolean);if(Ce.length===0){$.value=[];return}he.value=!0;try{const te=[],Se=new Set;for(const Te of Ce){const qe=await Je(`/prompts/${Te}/tenvs`);if(qe.ok){const Rt=await qe.json();for(const at of Rt.tenvs||[])Se.has(at.name)||(Se.add(at.name),te.push({name:at.name,value:at.value,required:at.required,description:at.description,source:at.source}))}}$.value=te}catch(te){console.error("Error fetching tenvs from prompts:",te),$.value=[]}finally{he.value=!1}},da=[{value:"dual_ai",label:"AI + AI (Subagent)"},{value:"ai_human",label:"AI + Human"}],ca=Ce=>{let te=Ce.toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_]/g,"");return!te.endsWith("_agent")&&te.length>0&&(te=te+"_agent"),te},pa=Ce=>!Ce||Ce==="_agent"?(b.value="Name is required",!1):/^[a-z][a-z0-9_]*_agent$/.test(Ce)?(b.value="",!0):(b.value="Name must start with a letter",!1),Ct=()=>{y.value="",f.value="",b.value="",v.value="",d.value="dual_ai",k.value=!1,g.value="",_.value="",L.value=null,R.value="",K.value="",Y.value="",z.value="",P.value=!0,G.value=!1,ee.value="",se.value="",de.value="",Q.value="",E.value=!1,S.value=null,V.value="",re.value="",F.value="",oe.value=null,q.value="",N.value="",J.value="",U.value=!0,W.value=!1,M.value="",ne.value="",A.value="",ce.value="",ue.value=null,ke.value="",be.value="",O.value="",Ve.value=null,$.value=[],j.value={}},ma=async()=>{if(a.editAgent?.id){u.value=!0,$e.value=!0;try{const Ce=await fetch(fe(`/api/agents/${a.editAgent.id}`));if(Ce.ok){const te=await Ce.json(),Se=te.agent||te;y.value=Se.name||"",f.value=Se.name||"",v.value=Se.title||"",d.value=Se.type||"dual_ai",k.value=Se.expose_as_tool||!1,g.value=Se.tool_description||"",L.value=Se.max_session_turns;const Te=Se.side_a_stop_tool||"",qe=Se.side_a_stop_tool_response_property||"",Rt=Se.side_b_stop_tool||"",at=Se.side_b_stop_tool_response_property||"",ha=Se.side_a_end_conversation_tool||"",ga=Se.side_b_end_conversation_tool||"";K.value=Se.side_a_label||"",q.value=Se.side_b_label||"",Y.value=Se.side_a_agent_prompt||"",N.value=Se.side_b_agent_prompt||"",P.value=!!Se.side_a_stop_on_response,G.value=!!Se.side_a_stop_tool,E.value=!!Se.side_a_manual_stop_condition,S.value=Se.side_a_max_steps,U.value=!!Se.side_b_stop_on_response,W.value=!!Se.side_b_stop_tool,ue.value=Se.side_b_max_steps,await Le(),ee.value=Te,de.value=qe,M.value=Rt,A.value=at,re.value=ha,be.value=ga,Se.tenvs&&typeof Se.tenvs=="object"&&(j.value=Se.tenvs),await Ot()}}catch(Ce){console.error("Error loading agent data:",Ce)}finally{u.value=!1,$e.value=!1}}},va=async()=>{b.value="",R.value="",z.value="",se.value="",Q.value="",V.value="",F.value="",J.value="",ne.value="",ce.value="",ke.value="",O.value="";let Ce=!1;pa(y.value)||(Ce=!0);const te=y.value;d.value==="dual_ai"&&L.value!==null&&L.value!==void 0&&L.value<=0&&(R.value="Max session turns must be a positive number",Ce=!0),Y.value||(z.value="Please select an agent prompt",Ce=!0);const Se=P.value||ee.value,Te=d.value==="ai_human"&&E.value;if(!Se&&!Te&&(z.value="At least one stop condition is required (or check manual stop condition for ai_human agents)",Ce=!0),ee.value&&!de.value&&(Q.value="Response property required when using stop tool",Ce=!0),S.value!==null&&S.value<=0&&(V.value="Max steps must be a positive number",Ce=!0),d.value==="dual_ai"&&!re.value&&!be.value&&(F.value="At least one side must have an end conversation tool",O.value="At least one side must have an end conversation tool",Ce=!0),d.value==="dual_ai"&&(N.value||(J.value="Please select an agent prompt",Ce=!0),M.value&&!A.value&&(ce.value="Response property required when using stop tool",Ce=!0),ue.value!==null&&ue.value<=0&&(ke.value="Max steps must be a positive number",Ce=!0)),Ce)return;const qe={name:te,title:v.value||null,type:d.value,expose_as_tool:k.value,tool_description:k.value?g.value:null,max_session_turns:d.value==="dual_ai"?L.value:null,side_a_label:K.value||null,side_a_agent_prompt:Y.value,side_a_stop_on_response:P.value,side_a_stop_tool:ee.value||null,side_a_stop_tool_response_property:de.value||null,side_a_manual_stop_condition:E.value,side_a_max_steps:S.value,side_a_end_conversation_tool:re.value||null};d.value==="dual_ai"&&(qe.side_b_label=q.value||null,qe.side_b_agent_prompt=N.value,qe.side_b_stop_on_response=U.value,qe.side_b_stop_tool=M.value||null,qe.side_b_stop_tool_response_property=A.value||null,qe.side_b_max_steps=ue.value,qe.side_b_end_conversation_tool=be.value||null),Object.keys(j.value).length>0&&(qe.tenvs=j.value),l.value&&a.editAgent?.id&&(qe.id=a.editAgent.id),i("save",qe)},fa=()=>{Ct(),i("update:modelValue",!1)};return ge(Y,async Ce=>{if($e.value||(ee.value="",de.value=""),!Ce){oe.value=null;return}ie.value=!0;try{const te=await fetch(fe(`/api/prompts/${Ce}`));te.ok&&(oe.value=await te.json())}catch(te){console.error("Error fetching Side A prompt:",te)}finally{ie.value=!1}$e.value||await Ot()}),ge(N,async Ce=>{if($e.value||(M.value="",A.value=""),!Ce){Ve.value=null;return}_e.value=!0;try{const te=await fetch(fe(`/api/prompts/${Ce}`));te.ok&&(Ve.value=await te.json())}catch(te){console.error("Error fetching Side B prompt:",te)}finally{_e.value=!1}$e.value||await Ot()}),ge(G,Ce=>{Ce||(ee.value="",de.value="")}),ge(W,Ce=>{Ce||(M.value="",A.value="")}),ge(()=>a.modelValue,async Ce=>{Ce?(await Promise.all([pe(),we()]),l.value?(Ct(),await ma()):Ct()):Ct()}),(Ce,te)=>{const Se=Be("FormKit");return r(),H(He,{"model-value":t.modelValue,"onUpdate:modelValue":te[26]||(te[26]=Te=>Ce.$emit("update:modelValue",Te)),title:l.value?"Edit Agent":"Create Agent",width:"max-w-5xl","content-padding":!1},{footer:D(()=>[e("div",j0,[w(T(De),{variant:"ghost",size:"sm",onClick:fa},{default:D(()=>[...te[55]||(te[55]=[Z(" Cancel ",-1)])]),_:1}),w(T(De),{variant:"primary",size:"sm",disabled:u.value,loading:u.value,onClick:va},{default:D(()=>[Z(C(l.value?"Update Agent":"Create Agent"),1)]),_:1},8,["disabled","loading"])])]),default:D(()=>[u.value?(r(),n("div",m0,[...te[27]||(te[27]=[e("span",{class:"text-neutral-500"},"Loading agent data...",-1)])])):(r(),H(Se,{key:1,type:"form",actions:!1,"form-class":"$reset flex-1 min-h-0 flex flex-col"},{default:D(()=>[e("div",v0,[e("nav",f0,[w(T(Qr),{tabs:c.value,"active-tab":T(h),onSelect:T(x)},null,8,["tabs","active-tab","onSelect"])]),e("div",{ref_key:"contentRef",ref:s,class:"flex-1 overflow-y-auto p-5 bg-neutral-100 dark:bg-neutral-950"},[e("div",h0,[t.apiError?(r(),H(T(Fe),{key:0,variant:"error"},{default:D(()=>[Z(C(t.apiError),1)]),_:1})):I("",!0),w(T(rt),{id:"section-basics",title:"Basics",icon:T(Lt)},{default:D(()=>[e("div",g0,[e("div",null,[w(Se,{type:"text",modelValue:y.value,"onUpdate:modelValue":te[0]||(te[0]=Te=>y.value=Te),label:"Agent Name",disabled:l.value,validation:"required","validation-messages":{required:"Name is required"},"outer-class":"$reset",onBlur:te[1]||(te[1]=Te=>y.value=ca(y.value))},null,8,["modelValue","disabled"]),b.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(b.value),1)]),_:1})):l.value?(r(),H(T(ze),{key:2,class:"mt-1"},{default:D(()=>[...te[29]||(te[29]=[Z(" Agent names cannot be changed after creation (used as foreign key for threads) ",-1)])]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[28]||(te[28]=[Z(" Automatically formatted to snake_case with _agent suffix (e.g., research_agent) ",-1)])]),_:1}))]),e("div",b0,[e("div",null,[w(Se,{type:"text",modelValue:v.value,"onUpdate:modelValue":te[2]||(te[2]=Te=>v.value=Te),label:"Display Title (Optional)","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...te[30]||(te[30]=[Z(" Human-readable title shown in the UI ",-1)])]),_:1})]),e("div",null,[w(Se,{type:"selectSearch",modelValue:d.value,"onUpdate:modelValue":te[3]||(te[3]=Te=>d.value=Te),label:"Agent Type",options:da,"outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...te[31]||(te[31]=[Z(" AI + AI or AI + Human conversation ",-1)])]),_:1})])]),d.value==="dual_ai"?(r(),n("div",x0,[w(Se,{type:"checkbox",modelValue:k.value,"onUpdate:modelValue":te[4]||(te[4]=Te=>k.value=Te),label:"Expose as Tool","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...te[32]||(te[32]=[Z(" Make this subagent available as a tool that can be called by other prompts or agents ",-1)])]),_:1})])):I("",!0),k.value&&d.value==="dual_ai"?(r(),n("div",y0,[w(Se,{type:"textarea",modelValue:g.value,"onUpdate:modelValue":te[5]||(te[5]=Te=>g.value=Te),label:"Tool Description",placeholder:"Describe what this agent does when called as a tool",rows:3,"outer-class":"$reset"},null,8,["modelValue"]),_.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(_.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[33]||(te[33]=[Z(" This description helps other agents understand when to use this agent ",-1)])]),_:1}))])):I("",!0),d.value==="dual_ai"?(r(),n("div",k0,[w(Se,{type:"number",modelValue:L.value,"onUpdate:modelValue":te[6]||(te[6]=Te=>L.value=Te),label:"Max Session Turns",placeholder:"Unlimited","outer-class":"$reset"},null,8,["modelValue"]),R.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(R.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[34]||(te[34]=[Z(" Maximum number of back-and-forth exchanges between the two agents before the conversation ends ",-1)])]),_:1}))])):I("",!0)])]),_:1},8,["icon"]),w(T(rt),{id:"section-side-a",title:"Side A (AI)",icon:T(mt)},{default:D(()=>[e("div",w0,[e("div",_0,[e("div",null,[w(Se,{type:"text",modelValue:K.value,"onUpdate:modelValue":te[7]||(te[7]=Te=>K.value=Te),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...te[35]||(te[35]=[Z(" Custom label for this side ",-1)])]),_:1})]),e("div",null,[w(Se,{type:"selectSearch",modelValue:Y.value,"onUpdate:modelValue":te[8]||(te[8]=Te=>Y.value=Te),label:"Agent Prompt",options:xe.value,validation:"required","validation-messages":{required:"Please select an agent prompt"},"outer-class":"$reset"},null,8,["modelValue","options"]),z.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(z.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[36]||(te[36]=[Z(" Defines this agent's behavior ",-1)])]),_:1}))])]),e("div",$0,[w(T(xt),{title:"Stop Conditions"}),w(T(ze),null,{default:D(()=>[...te[37]||(te[37]=[Z(" Optional. If no stop conditions are set, the agent will continue until programmatically stopped or end conversation tool is called. ",-1)])]),_:1}),e("div",null,[w(Se,{type:"checkbox",modelValue:P.value,"onUpdate:modelValue":te[9]||(te[9]=Te=>P.value=Te),label:"Stop when agent returns content","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"ml-6"},{default:D(()=>[...te[38]||(te[38]=[Z(" Agent stops when it returns a response without calling tools ",-1)])]),_:1})]),e("div",null,[w(Se,{type:"checkbox",modelValue:G.value,"onUpdate:modelValue":te[10]||(te[10]=Te=>G.value=Te),label:"Stop on specific tool call","outer-class":"$reset"},null,8,["modelValue"]),G.value?(r(),n("div",C0,[w(Se,{type:"selectSearch",modelValue:ee.value,"onUpdate:modelValue":te[11]||(te[11]=Te=>ee.value=Te),label:"Stop Tool",options:We.value,placeholder:"Select a tool...",disabled:ie.value||!Y.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),se.value?(r(),H(T(ze),{key:0,class:"text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(se.value),1)]),_:1})):(r(),H(T(ze),{key:1},{default:D(()=>[...te[39]||(te[39]=[Z(" Agent stops when this tool is called ",-1)])]),_:1})),ee.value?(r(),n("div",S0,[w(Se,{type:"selectSearch",modelValue:de.value,"onUpdate:modelValue":te[12]||(te[12]=Te=>de.value=Te),label:"Response Property",options:ia.value,placeholder:"Select property...","outer-class":"$reset"},null,8,["modelValue","options"]),Q.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(Q.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[40]||(te[40]=[Z(" Property from tool arguments to return as final response ",-1)])]),_:1}))])):I("",!0)])):I("",!0)]),d.value==="ai_human"&&!P.value&&!G.value?(r(),H(T(Fe),{key:0,variant:"warning",class:"mt-3"},{default:D(()=>[w(Se,{type:"checkbox",modelValue:E.value,"onUpdate:modelValue":te[13]||(te[13]=Te=>E.value=Te),label:"I have manually implemented a stop condition","outer-class":"$reset"},null,8,["modelValue"]),te[41]||(te[41]=e("p",{class:"mt-2 text-xs"}," 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))]),_:1})):I("",!0)]),e("div",T0,[e("div",null,[w(Se,{type:"number",modelValue:S.value,"onUpdate:modelValue":te[14]||(te[14]=Te=>S.value=Te),label:"Max Steps",placeholder:"Unlimited","outer-class":"$reset"},null,8,["modelValue"]),V.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(V.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[42]||(te[42]=[Z(" Safety limit before yielding ",-1)])]),_:1}))]),e("div",null,[w(Se,{type:"selectSearch",modelValue:re.value,"onUpdate:modelValue":te[15]||(te[15]=Te=>re.value=Te),label:"End Conversation Tool",options:We.value,placeholder:"Select a tool...",disabled:ie.value||!Y.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),F.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(F.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[43]||(te[43]=[Z(" Ends entire conversation when called ",-1)])]),_:1}))])])])]),_:1},8,["icon"]),w(T(rt),{id:"section-side-b",title:d.value==="ai_human"?"Side B (Human)":"Side B (AI)",icon:d.value==="ai_human"?T(mr):T(mt)},{default:D(()=>[e("div",I0,[d.value==="ai_human"?(r(),n(ve,{key:0},[e("div",null,[w(Se,{type:"text",modelValue:q.value,"onUpdate:modelValue":te[16]||(te[16]=Te=>q.value=Te),label:"Side Label (Optional)",placeholder:"e.g., Customer, User","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...te[44]||(te[44]=[Z(" Custom label for this side ",-1)])]),_:1})]),te[45]||(te[45]=e("div",{class:"flex flex-col items-center justify-center py-8 bg-neutral-50 dark:bg-neutral-800/50 rounded-lg"},[e("svg",{class:"w-16 h-16 mb-4 text-neutral-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})]),e("h5",{class:"font-medium text-lg mb-2 text-neutral-700 dark:text-neutral-300"},"Human User"),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))],64)):(r(),n(ve,{key:1},[e("div",z0,[e("div",null,[w(Se,{type:"text",modelValue:q.value,"onUpdate:modelValue":te[17]||(te[17]=Te=>q.value=Te),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...te[46]||(te[46]=[Z(" Custom label for this side ",-1)])]),_:1})]),e("div",null,[w(Se,{type:"selectSearch",modelValue:N.value,"onUpdate:modelValue":te[18]||(te[18]=Te=>N.value=Te),label:"Agent Prompt",options:xe.value,validation:"required","validation-messages":{required:"Please select an agent prompt"},"outer-class":"$reset"},null,8,["modelValue","options"]),J.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(J.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[47]||(te[47]=[Z(" Defines this agent's behavior ",-1)])]),_:1}))])]),e("div",V0,[w(T(xt),{title:"Stop Conditions"}),w(T(ze),null,{default:D(()=>[...te[48]||(te[48]=[Z(" Optional. If no stop conditions are set, the agent will continue until programmatically stopped or end conversation tool is called. ",-1)])]),_:1}),e("div",null,[w(Se,{type:"checkbox",modelValue:U.value,"onUpdate:modelValue":te[19]||(te[19]=Te=>U.value=Te),label:"Stop when agent returns content","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"ml-6"},{default:D(()=>[...te[49]||(te[49]=[Z(" Agent stops when it returns a response without calling tools ",-1)])]),_:1})]),e("div",null,[w(Se,{type:"checkbox",modelValue:W.value,"onUpdate:modelValue":te[20]||(te[20]=Te=>W.value=Te),label:"Stop on specific tool call","outer-class":"$reset"},null,8,["modelValue"]),W.value?(r(),n("div",M0,[w(Se,{type:"selectSearch",modelValue:M.value,"onUpdate:modelValue":te[21]||(te[21]=Te=>M.value=Te),label:"Stop Tool",options:$t.value,placeholder:"Select a tool...",disabled:_e.value||!N.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),ne.value?(r(),H(T(ze),{key:0,class:"text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(ne.value),1)]),_:1})):(r(),H(T(ze),{key:1},{default:D(()=>[...te[50]||(te[50]=[Z(" Agent stops when this tool is called ",-1)])]),_:1})),M.value?(r(),n("div",E0,[w(Se,{type:"selectSearch",modelValue:A.value,"onUpdate:modelValue":te[22]||(te[22]=Te=>A.value=Te),label:"Response Property",options:ua.value,placeholder:"Select property...","outer-class":"$reset"},null,8,["modelValue","options"]),ce.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(ce.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[51]||(te[51]=[Z(" Property from tool arguments to return as final response ",-1)])]),_:1}))])):I("",!0)])):I("",!0)])]),e("div",L0,[e("div",null,[w(Se,{type:"number",modelValue:ue.value,"onUpdate:modelValue":te[23]||(te[23]=Te=>ue.value=Te),label:"Max Steps",placeholder:"Unlimited","outer-class":"$reset"},null,8,["modelValue"]),ke.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(ke.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[52]||(te[52]=[Z(" Safety limit before yielding ",-1)])]),_:1}))]),e("div",null,[w(Se,{type:"selectSearch",modelValue:be.value,"onUpdate:modelValue":te[24]||(te[24]=Te=>be.value=Te),label:"End Conversation Tool",options:$t.value,placeholder:"Select a tool...",disabled:_e.value||!N.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),O.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(O.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[53]||(te[53]=[Z(" Ends entire conversation when called ",-1)])]),_:1}))])])],64))])]),_:1},8,["title","icon"]),$.value.length>0||Object.keys(j.value).length>0?(r(),H(T(rt),{key:1,id:"section-env",title:"Environment",icon:T(Ht)},{default:D(()=>[e("div",P0,[te[54]||(te[54]=e("p",{class:"text-sm text-neutral-500 dark:text-neutral-400"}," Configure values for tools that require thread environment variables. Values from prompts are shown locked - click to unlock and override. ",-1)),he.value?(r(),n("span",A0,"Loading...")):I("",!0),w(Zt,{modelValue:j.value,"onUpdate:modelValue":te[25]||(te[25]=Te=>j.value=Te),inherited:$.value,"allow-custom":!0,disabled:u.value},null,8,["modelValue","inherited","disabled"])])]),_:1},8,["icon"])):I("",!0)])],512)])]),_:1}))]),_:1},8,["model-value","title"])}}}),ta=me({__name:"ExtractCopyToggle",props:{value:{},disabled:{type:Boolean}},emits:["update:value"],setup(t,{emit:o}){const a=o,i=l=>{a("update:value",l)};return(l,u)=>{const s=Be("FormKit");return r(),H(s,{type:"toggle",value:t.value,"on-value":"extract","off-value":"copy","on-value-label":"extract","off-value-label":"copy",disabled:t.disabled,classes:{outer:"$remove:mb-4",wrapper:"$remove:items-center flex-row-reverse justify-end items-center",inner:"h-5",track:"h-5 w-10 rounded-full",thumb:"h-4 w-4",valueLabel:"text-xs text-neutral-600 dark:text-neutral-400 mr-2 flex items-center font-normal"},onInput:i},null,8,["value","disabled"])}}}),O0={class:"font-mono text-sm"},R0={class:"flex items-center gap-2 py-1.5"},U0={class:"text-neutral-600 dark:text-neutral-400"},B0={class:"ml-auto"},ra=me({name:"TreeChildren",props:{children:{type:Array,required:!0},getSelection:{type:Function,required:!0},setSelection:{type:Function,required:!0},isShared:{type:Function,required:!0},getTypeColor:{type:Function,required:!0}},setup(t){return()=>t.children.length===0?null:Oe("div",{class:"ml-4"},t.children.map((o,a)=>Oe("div",{class:"relative",key:o.uid},[a<t.children.length-1?Oe("div",{class:"absolute left-0 top-0 bottom-0 border-l border-neutral-300 dark:border-neutral-700"}):Oe("div",{class:"absolute left-0 top-0 h-3 border-l border-neutral-300 dark:border-neutral-700"}),Oe("div",{class:"absolute left-0 top-3 w-4 border-t border-neutral-300 dark:border-neutral-700"}),Oe("div",{class:"pl-5"},[Oe("div",{class:"flex items-center gap-2 py-1.5"},[Oe("span",{class:"text-neutral-600 dark:text-neutral-400"},o.name),Oe(ft,{variant:t.getTypeColor(o.type),size:"sm"},()=>o.type),t.isShared(o)?Oe("span",{class:"text-xs text-amber-600 dark:text-amber-400",title:`Used by: ${o.sharedWith.join(", ")}`},`(used in ${o.sharedWith.length} other${o.sharedWith.length>1?"s":""})`):null,o.isDuplicate?null:Oe("div",{class:"ml-auto"},[Oe(ta,{value:t.getSelection(o),disabled:t.isShared(o),"onUpdate:value":i=>t.setSelection(o,i),title:t.isShared(o)?"Cannot extract items shared with other agents":""})])]),o.children.length>0?Oe(ra,{children:o.children,getSelection:t.getSelection,setSelection:t.setSelection,isShared:t.isShared,getTypeColor:t.getTypeColor}):null])])))}}),F0=me({__name:"DependencyTree",props:{analysis:{},selections:{}},emits:["update:selection"],setup(t,{emit:o}){const a=t,i=o,l=B(()=>{const c=a.analysis,f=[];let y=0;const b=(L,R)=>{for(const K of L){const Y=`${R}:${K.name}`;f.push({...K,type:R,uid:`${Y}:${y++}`})}};b(c.constituents.agents,"agent"),b(c.constituents.prompts,"prompt"),b(c.constituents.tools,"tool"),b(c.constituents.models,"model"),b(c.constituents.hooks,"hook");const v=new Map,d=`agent:${c.agent}`;for(const L of f){const R=L.parentKey||d;`${L.type}:${L.name}`===d&&!L.parentKey||(v.has(R)||v.set(R,[]),v.get(R).push(L))}const k=new Set,g=L=>{const R=`${L.type}:${L.name}`,K=k.has(R);k.add(R);const Y=[],z=v.get(R)||[];for(const P of z)Y.push(g(P));return{name:L.name,type:L.type,filePath:L.filePath,sharedWith:L.sharedWith,discoveredVia:L.discoveredVia,children:Y,uid:L.uid,isDuplicate:K}},_=f.find(L=>L.type==="agent"&&L.name===c.agent&&!L.parentKey);return _?g(_):{name:c.agent,type:"agent",filePath:"",sharedWith:[],discoveredVia:"static",children:[],uid:"root",isDuplicate:!1}}),u=c=>`${c.type}:${c.name}`,s=c=>a.selections.get(u(c))||"extract",m=(c,f)=>{i("update:selection",u(c),f)},h=c=>c.sharedWith.length>0,x=c=>{switch(c){case"agent":return"accent";case"prompt":return"secondary";case"tool":return"success";case"model":return"warning";case"hook":return"default"}};return(c,f)=>(r(),n("div",O0,[e("div",R0,[e("span",U0,C(l.value.name),1),w(T(ft),{variant:x(l.value.type),size:"sm"},{default:D(()=>[Z(C(l.value.type),1)]),_:1},8,["variant"]),e("div",B0,[w(ta,{value:s(l.value),"onUpdate:value":f[0]||(f[0]=y=>m(l.value,y))},null,8,["value"])])]),(r(),H(Ue(T(ra)),{children:l.value.children,"get-selection":s,"set-selection":m,"is-shared":h,"get-type-color":x},null,8,["children"]))]))}}),N0={key:0,class:"flex items-center justify-center py-12"},q0={key:1,class:"py-4"},H0={key:2,class:"py-4 space-y-4"},W0={class:"space-y-2"},K0={class:"text-sm opacity-80"},J0={class:"text-sm opacity-80"},Y0={key:3,class:"space-y-6"},G0={class:"space-y-4"},Z0={class:"grid grid-cols-2 gap-4"},X0={class:"col-span-2"},Q0=["value"],ep={class:"col-span-2"},tp={class:"col-span-2"},rp={key:0,class:"mt-3 space-y-3"},ap={class:"flex gap-2 border-b border-neutral-200 dark:border-neutral-700"},op={key:0},np=["innerHTML"],lp={class:"space-y-4"},sp={class:"list-disc list-inside space-y-1"},ip={class:"border border-neutral-200 dark:border-neutral-700 rounded-lg p-4 bg-neutral-50 dark:bg-neutral-900/50"},up={class:"flex justify-between"},dp=me({__name:"PackModal",props:{modelValue:{type:Boolean},agent:{}},emits:["update:modelValue","packed"],setup(t,{emit:o}){Vt.setOptions({gfm:!0,breaks:!0});const a=[{value:"MIT",label:"MIT"},{value:"Apache-2.0",label:"Apache 2.0"},{value:"ISC",label:"ISC"},{value:"GPL-3.0",label:"GPL 3.0"},{value:"BSD-3-Clause",label:"BSD 3-Clause"},{value:"Unlicensed",label:"Unlicensed / Proprietary"}],i=t,l=o,u=B({get:()=>i.modelValue,set:q=>l("update:modelValue",q)}),s=p(null),m=p(!1),h=p(!1),x=p(null),c=p(null),f=p(""),y=p("1.0.0"),b=p("MIT"),v=p(""),d=p(""),k=p("edit"),g=p(!1),_=p(null),L=p(null),R=B(()=>d.value?Vt(d.value):""),K=p(new Map);ge(()=>i.modelValue,async q=>{q&&i.agent?await Promise.all([z(),P()]):Y()});const Y=()=>{s.value=null,x.value=null,c.value=null,K.value=new Map,f.value="",y.value="1.0.0",b.value="MIT",v.value="",d.value="",k.value="edit",g.value=!1,_.value=null,L.value=null},z=async()=>{if(i.agent){m.value=!0,x.value=null;try{const q=await fetch(fe(`/api/pack/${i.agent.id}/analyze`)),N=await q.json();if(!q.ok){x.value=N.error||"Failed to analyze agent";return}if(s.value=N,N.generatedReadme)d.value=N.generatedReadme;else{const J=G(i.agent?.id||"agent");d.value=ee(J,i.agent?.id||"agent",N.agentDescription)}de(N)}catch(q){x.value=q instanceof Error?q.message:"Failed to analyze agent"}finally{m.value=!1}}},P=async()=>{if(i.agent)try{const q=await fetch(fe(`/api/pack/${i.agent.id}/metadata`));if(q.ok){const N=await q.json();f.value=N.packageName,y.value=se(N.version),b.value=N.license||"MIT",v.value=N.licenseOwner||""}else f.value=G(i.agent.id),y.value="1.0.0",b.value="MIT",v.value=""}catch{f.value=G(i.agent?.id||"agent"),y.value="1.0.0",b.value="MIT",v.value=""}},G=q=>`standardagent-${q.toLowerCase().replace(/_/g,"-")}`,ee=(q,N,J)=>`# ${q}
6
+
7
+ ${J||"A Standard Agent package."}
8
+
9
+ ## Installation
10
+
11
+ \`\`\`bash
12
+ npm install ${q}
13
+ \`\`\`
14
+
15
+ ## Usage
16
+
17
+ This is a [Standard Agent](https://standardagentbuilder.com) package. To use it:
18
+
19
+ 1. Install in your Standard Agents project
20
+ 2. The agent will be automatically discovered and available
21
+
22
+ \`\`\`typescript
23
+ // Create a thread with this agent
24
+ const thread = await client.createThread({
25
+ agent_id: '${q}/${N}'
26
+ });
27
+ \`\`\`
28
+
29
+ ## License
30
+
31
+ MIT
32
+ `,se=q=>{const N=q.split(".");if(N.length<3)return`${q}.1`;const J=parseInt(N[2],10);return`${N[0]}.${N[1]}.${J+1}`},de=q=>{const N=new Map,J=new Set;for(const U of q.constituents.agents){const W=`agent:${U.name}`;J.has(W)||(J.add(W),N.set(W,U.sharedWith.length>0?"copy":"extract"))}for(const U of q.constituents.prompts){const W=`prompt:${U.name}`;J.has(W)||(J.add(W),N.set(W,U.sharedWith.length>0?"copy":"extract"))}for(const U of q.constituents.tools){const W=`tool:${U.name}`;J.has(W)||(J.add(W),N.set(W,U.sharedWith.length>0?"copy":"extract"))}for(const U of q.constituents.models){const W=`model:${U.name}`;J.has(W)||(J.add(W),N.set(W,U.sharedWith.length>0?"copy":"extract"))}for(const U of q.constituents.hooks){const W=`hook:${U.name}`;J.has(W)||(J.add(W),N.set(W,U.sharedWith.length>0?"copy":"extract"))}K.value=N},Q=(q,N)=>{K.value.set(q,N),K.value=new Map(K.value)},E=q=>q?q.length>214?"Package name must be 214 characters or less":q.startsWith(".")||q.startsWith("_")?"Cannot start with . or _":q!==q.toLowerCase()?"Must be lowercase":/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(q)?null:"Only lowercase letters, numbers, hyphens, underscores, and dots":"Package name is required",S=q=>/^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?$/.test(q)?null:"Invalid version format (use X.Y.Z)";ge(f,q=>{_.value=E(q)}),ge(y,q=>{L.value=S(q)});const V=B(()=>!E(f.value)&&!S(y.value)),re=async()=>{if(!(!i.agent||!s.value)&&(_.value=E(f.value),L.value=S(y.value),!(_.value||L.value))){h.value=!0,x.value=null,c.value=null;try{const q=Array.from(K.value.entries()).map(([U,W])=>{const[M,ne]=U.split(":");let A="";const ce=M==="agent"?"agents":M+"s",ke=(s.value?.constituents[ce]||[]).find(be=>be.name===ne);return ke&&(A=ke.filePath),{name:ne,type:M,filePath:A,mode:W}}),N=await fetch(fe(`/api/pack/${i.agent.id}`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({itemSelections:q,packageName:f.value,version:y.value,license:b.value,licenseOwner:v.value,readme:d.value})}),J=await N.json();if(!N.ok){x.value=J.error||"Failed to pack agent";return}c.value={success:!0,outputPath:J.outputPath,filesCreated:J.filesCreated,packageId:J.packageId},setTimeout(()=>{l("packed",{outputPath:J.outputPath,packageId:J.packageId})},1500)}catch(q){x.value=q instanceof Error?q.message:"Failed to pack agent"}finally{h.value=!1}}},F=()=>{u.value=!1};return(q,N)=>(r(),H(He,{modelValue:u.value,"onUpdate:modelValue":N[8]||(N[8]=J=>u.value=J),title:`Pack Agent: ${t.agent?.title||t.agent?.id||""}`,width:"max-w-2xl","min-height":"min-h-[20rem]"},{footer:D(()=>[e("div",up,[w(T(De),{variant:"ghost",onClick:F},{default:D(()=>[...N[15]||(N[15]=[Z(" Cancel ",-1)])]),_:1}),w(T(De),{variant:"primary",disabled:m.value||h.value||!s.value||c.value?.success||!V.value,onClick:re},{default:D(()=>[h.value?(r(),n(ve,{key:0},[w(Ee,{size:"sm",class:"mr-2"}),N[16]||(N[16]=Z(" Packing... ",-1))],64)):(r(),n(ve,{key:1},[Z(" Pack Agent ")],64))]),_:1},8,["disabled"])])]),default:D(()=>[m.value?(r(),n("div",N0,[w(Ee,{size:"lg"})])):x.value&&!s.value?(r(),n("div",q0,[w(T(Fe),{variant:"error"},{default:D(()=>[Z(C(x.value),1)]),_:1})])):c.value?.success?(r(),n("div",H0,[w(T(Fe),{variant:"success"},{default:D(()=>[e("div",W0,[N[9]||(N[9]=e("p",{class:"font-medium"},"Agent packed successfully!",-1)),e("p",K0," Output: "+C(c.value.outputPath),1),e("p",J0,C(c.value.filesCreated?.length)+" files created ",1)])]),_:1})])):s.value?(r(),n("div",Y0,[e("div",G0,[N[11]||(N[11]=e("h3",{class:"text-sm font-semibold text-neutral-700 dark:text-neutral-300 uppercase tracking-wider"}," Package Details ",-1)),e("div",Z0,[e("div",X0,[w(T(ct),{label:"Package Name",error:_.value||void 0,"help-text":"npm package name (lowercase, no spaces)",required:""},{default:D(()=>[Ae(e("input",{"onUpdate:modelValue":N[0]||(N[0]=J=>f.value=J),type:"text",class:ae(["w-full px-3 py-2 rounded-md border text-sm bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed",{"border-red-500 dark:border-red-500":_.value}]),placeholder:"standardagent-my-agent"},null,2),[[Qe,f.value]])]),_:1},8,["error"])]),w(T(ct),{label:"Version",error:L.value||void 0,"help-text":"Semver format (X.Y.Z)",required:""},{default:D(()=>[Ae(e("input",{"onUpdate:modelValue":N[1]||(N[1]=J=>y.value=J),type:"text",class:ae(["w-full px-3 py-2 rounded-md border text-sm bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed",{"border-red-500 dark:border-red-500":L.value}]),placeholder:"1.0.0"},null,2),[[Qe,y.value]])]),_:1},8,["error"]),w(T(ct),{label:"License"},{default:D(()=>[Ae(e("select",{"onUpdate:modelValue":N[2]||(N[2]=J=>b.value=J),class:"w-full px-3 py-2 rounded-md border text-sm bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent"},[(r(),n(ve,null,ye(a,J=>e("option",{key:J.value,value:J.value},C(J.label),9,Q0)),64))],512),[[Mr,b.value]])]),_:1}),e("div",ep,[w(T(ct),{label:"License Owner","help-text":"Copyright holder name (e.g., your name or company)"},{default:D(()=>[Ae(e("input",{"onUpdate:modelValue":N[3]||(N[3]=J=>v.value=J),type:"text",class:"w-full px-3 py-2 rounded-md border text-sm bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent",placeholder:"Your Name or Company"},null,512),[[Qe,v.value]])]),_:1})]),e("div",tp,[e("button",{type:"button",class:"flex items-center gap-2 text-sm font-medium text-neutral-700 dark:text-neutral-300 hover:text-neutral-900 dark:hover:text-neutral-100",onClick:N[4]||(N[4]=J=>g.value=!g.value)},[(r(),H(Ue(g.value?T(nt):T(vt)),{class:"w-4 h-4"})),N[10]||(N[10]=Z(" README ",-1))]),g.value?(r(),n("div",rp,[e("div",ap,[e("button",{type:"button",class:ae(["px-3 py-1.5 text-sm font-medium border-b-2 -mb-px transition-colors",k.value==="edit"?"border-primary-500 text-primary-600 dark:text-primary-400":"border-transparent text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300"]),onClick:N[5]||(N[5]=J=>k.value="edit")}," Edit ",2),e("button",{type:"button",class:ae(["px-3 py-1.5 text-sm font-medium border-b-2 -mb-px transition-colors",k.value==="preview"?"border-primary-500 text-primary-600 dark:text-primary-400":"border-transparent text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300"]),onClick:N[6]||(N[6]=J=>k.value="preview")}," Preview ",2)]),k.value==="edit"?(r(),n("div",op,[Ae(e("textarea",{"onUpdate:modelValue":N[7]||(N[7]=J=>d.value=J),rows:"10",class:"w-full px-3 py-2 rounded-md border text-sm font-mono bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent resize-y",placeholder:`# Package Name
33
+
34
+ Description...`},null,512),[[Qe,d.value]])])):(r(),n("div",{key:1,class:"prose prose-sm dark:prose-invert max-w-none p-4 rounded-md border border-neutral-200 dark:border-neutral-700 bg-white dark:bg-neutral-800 min-h-[200px] max-h-[400px] overflow-y-auto",innerHTML:R.value},null,8,np))])):I("",!0)])])]),N[14]||(N[14]=e("hr",{class:"border-neutral-200 dark:border-neutral-700"},null,-1)),e("div",lp,[N[13]||(N[13]=e("h3",{class:"text-sm font-semibold text-neutral-700 dark:text-neutral-300 uppercase tracking-wider"}," Items to Include ",-1)),w(T(Fe),{variant:"info"},{default:D(()=>[...N[12]||(N[12]=[e("div",{class:"space-y-1"},[e("p",null,[e("strong",null,"Extract"),Z(": Moves the file into the package and removes it from your workspace. Use this for items only used by this agent. ")]),e("p",null,[e("strong",null,"Copy"),Z(": Copies the file into the package but keeps the original. Required for items shared with other agents. ")])],-1)])]),_:1}),x.value?(r(),H(T(Fe),{key:0,variant:"error"},{default:D(()=>[Z(C(x.value),1)]),_:1})):I("",!0),s.value.warnings.length>0?(r(),H(T(Fe),{key:1,variant:"warning"},{default:D(()=>[e("ul",sp,[(r(!0),n(ve,null,ye(s.value.warnings,J=>(r(),n("li",{key:J},C(J),1))),128))])]),_:1})):I("",!0),e("div",ip,[w(F0,{analysis:s.value,selections:K.value,"onUpdate:selection":Q},null,8,["analysis","selections"])])])])):I("",!0)]),_:1},8,["modelValue","title"]))}}),cp={class:"font-mono text-sm"},pp={class:"mb-3 text-xs text-neutral-500 dark:text-neutral-400"},mp={class:"flex items-center gap-2 py-1.5"},vp={class:"text-neutral-600 dark:text-neutral-400"},fp={key:0,class:"ml-auto text-xs text-amber-600 dark:text-amber-400"},hp={key:1,class:"ml-auto text-xs text-emerald-600 dark:text-emerald-400"},gp={key:0,class:"text-center py-8 text-neutral-500 dark:text-neutral-400"},aa=me({name:"TreeChildren",props:{children:{type:Array,required:!0},getTypeColor:{type:Function,required:!0}},setup(t){return()=>t.children.length===0?null:Oe("div",{class:"ml-4"},t.children.map((o,a)=>Oe("div",{class:"relative",key:o.uid},[a<t.children.length-1?Oe("div",{class:"absolute left-0 top-0 bottom-0 border-l border-neutral-300 dark:border-neutral-700"}):Oe("div",{class:"absolute left-0 top-0 h-3 border-l border-neutral-300 dark:border-neutral-700"}),Oe("div",{class:"absolute left-0 top-3 w-4 border-t border-neutral-300 dark:border-neutral-700"}),Oe("div",{class:"pl-5"},[Oe("div",{class:"flex items-center gap-2 py-1.5"},[Oe("span",{class:"text-neutral-600 dark:text-neutral-400"},o.name),Oe(ft,{variant:t.getTypeColor(o.type),size:"sm"},()=>o.type),o.isDuplicate?null:o.existsGlobally?Oe("span",{class:"ml-auto text-xs text-amber-600 dark:text-amber-400"},"already exists"):Oe("span",{class:"ml-auto text-xs text-emerald-600 dark:text-emerald-400"},"will unpack")]),o.children.length>0?Oe(aa,{children:o.children,getTypeColor:t.getTypeColor}):null])])))}}),bp=me({__name:"UnpackTree",props:{analysis:{}},setup(t){const o=t,a=B(()=>{const s=o.analysis,m=[];let h=0;for(const v of s.items)m.push({...v,uid:`${v.type}:${v.name}:${h++}`});const x=new Map,c=[];for(const v of m)v.parentKey?(x.has(v.parentKey)||x.set(v.parentKey,[]),x.get(v.parentKey).push(v)):c.push(v);const f=new Set,y=v=>{const d=`${v.type}:${v.name}`,k=f.has(d);f.add(d);const g=[],_=x.get(d)||[];for(const L of _)g.push(y(L));return{name:v.name,type:v.type,existsGlobally:v.existsGlobally,action:v.action,children:g,uid:v.uid,isDuplicate:k}},b=[];for(const v of c)v.type==="agent"&&b.push(y(v));if(b.length===0)for(const v of c)b.push(y(v));return b}),i=s=>{switch(s){case"agent":return"accent";case"prompt":return"secondary";case"tool":return"success";case"model":return"warning";case"hook":return"default"}},l=B(()=>{const s=new Set;for(const m of o.analysis.items)s.add(`${m.type}:${m.name}`);return s.size}),u=B(()=>{const s=new Set;let m=0;for(const h of o.analysis.items){const x=`${h.type}:${h.name}`;s.has(x)||(s.add(x),h.existsGlobally||m++)}return m});return(s,m)=>(r(),n("div",cp,[e("div",pp,C(u.value)+" of "+C(l.value)+" items will be unpacked ",1),(r(!0),n(ve,null,ye(a.value,h=>(r(),n("div",{key:h.uid},[e("div",mp,[e("span",vp,C(h.name),1),w(T(ft),{variant:i(h.type),size:"sm"},{default:D(()=>[Z(C(h.type),1)]),_:2},1032,["variant"]),h.existsGlobally?(r(),n("span",fp," already exists ")):(r(),n("span",hp," will unpack "))]),(r(),H(Ue(T(aa)),{children:h.children,"get-type-color":i},null,8,["children"]))]))),128)),a.value.length===0?(r(),n("div",gp," No items found in this package. ")):I("",!0)]))}}),xp={key:0,class:"flex items-center justify-center py-12"},yp={key:1,class:"py-4"},kp={key:2,class:"py-4"},wp={class:"space-y-2"},_p={class:"text-sm opacity-80"},$p={key:0,class:"text-sm opacity-80"},Cp={key:1,class:"text-sm opacity-80"},Sp={key:3,class:"space-y-4"},Tp={class:"text-sm text-neutral-600 dark:text-neutral-400"},Ip={class:"font-mono"},zp={class:"list-disc list-inside space-y-1"},Vp={class:"border border-neutral-200 dark:border-neutral-700 rounded-lg p-4 bg-neutral-50 dark:bg-neutral-900/50 max-h-80 overflow-y-auto"},Mp={key:2,class:"flex items-center gap-2"},Ep={class:"flex items-center gap-2 cursor-pointer"},Lp={class:"flex justify-between"},Pp=me({__name:"UnpackModal",props:{modelValue:{type:Boolean},agent:{}},emits:["update:modelValue","unpacked"],setup(t,{emit:o}){const a=t,i=o,l=B({get:()=>a.modelValue,set:k=>i("update:modelValue",k)}),u=p(null),s=p(!1),m=p(!1),h=p(null),x=p(null),c=p(!1);ge(()=>a.modelValue,async k=>{k&&a.agent?.packageId?await f():(u.value=null,h.value=null,x.value=null,c.value=!1)});const f=async()=>{if(a.agent?.packageId){s.value=!0,h.value=null;try{const k=await fetch(fe(`/api/unpack/${encodeURIComponent(a.agent.packageId)}/analyze`)),g=await k.json();if(!k.ok){h.value=g.error||"Failed to analyze package";return}u.value=g}catch(k){h.value=k instanceof Error?k.message:"Failed to analyze package"}finally{s.value=!1}}},y=async()=>{if(!(!a.agent?.packageId||!u.value)){m.value=!0,h.value=null,x.value=null;try{const k=u.value.items.filter((L,R,K)=>K.findIndex(Y=>Y.type===L.type&&Y.name===L.name)===R).map(L=>({name:L.name,type:L.type,action:L.existsGlobally?"skip":"generate"})),g=await fetch(fe(`/api/unpack/${encodeURIComponent(a.agent.packageId)}`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({itemSelections:k,deletePackage:c.value})}),_=await g.json();if(!g.ok){h.value=_.error||"Failed to unpack agent";return}x.value={success:!0,filesGenerated:_.filesGenerated,filesSkipped:_.filesSkipped,packageDeleted:_.packageDeleted},setTimeout(()=>{i("unpacked")},1500)}catch(k){h.value=k instanceof Error?k.message:"Failed to unpack agent"}finally{m.value=!1}}},b=()=>{l.value=!1},v=B(()=>{if(!u.value)return 0;const k=new Set;let g=0;for(const _ of u.value.items){const L=`${_.type}:${_.name}`;k.has(L)||(k.add(L),_.existsGlobally||g++)}return g}),d=B(()=>u.value?.source==="local");return(k,g)=>(r(),H(He,{modelValue:l.value,"onUpdate:modelValue":g[1]||(g[1]=_=>l.value=_),title:`Unpack: ${t.agent?.title||t.agent?.id||""}`,width:"max-w-2xl","min-height":"min-h-[20rem]"},{footer:D(()=>[e("div",Lp,[w(T(De),{variant:"ghost",onClick:b},{default:D(()=>[...g[6]||(g[6]=[Z(" Cancel ",-1)])]),_:1}),w(T(De),{variant:"primary",disabled:s.value||m.value||!u.value||x.value?.success||v.value===0,onClick:y},{default:D(()=>[m.value?(r(),n(ve,{key:0},[w(Ee,{size:"sm",class:"mr-2"}),g[7]||(g[7]=Z(" Unpacking... ",-1))],64)):(r(),n(ve,{key:1},[Z(" Unpack "+C(v.value)+" "+C(v.value===1?"item":"items"),1)],64))]),_:1},8,["disabled"])])]),default:D(()=>[s.value?(r(),n("div",xp,[w(Ee,{size:"lg"})])):h.value&&!u.value?(r(),n("div",yp,[w(T(Fe),{variant:"error"},{default:D(()=>[Z(C(h.value),1)]),_:1})])):x.value?.success?(r(),n("div",kp,[w(T(Fe),{variant:"success"},{default:D(()=>[e("div",wp,[g[2]||(g[2]=e("p",{class:"font-medium"},"Agent unpacked successfully!",-1)),e("p",_p,C(x.value.filesGenerated?.length||0)+" files unpacked ",1),(x.value.filesSkipped?.length||0)>0?(r(),n("p",$p,C(x.value.filesSkipped?.length)+" files skipped (already exist) ",1)):I("",!0),x.value.packageDeleted?(r(),n("p",Cp," Package was deleted from agents/packed/ ")):I("",!0)])]),_:1})])):u.value?(r(),n("div",Sp,[e("div",Tp,[e("p",null,[g[3]||(g[3]=Z("Package: ",-1)),e("span",Ip,C(u.value.packageId),1),Z(" v"+C(u.value.version),1)]),e("p",null,"Source: "+C(u.value.source==="npm"?"npm package":"local (agents/packed/)"),1)]),h.value?(r(),H(T(Fe),{key:0,variant:"error"},{default:D(()=>[Z(C(h.value),1)]),_:1})):I("",!0),u.value.warnings.length>0?(r(),H(T(Fe),{key:1,variant:"warning"},{default:D(()=>[e("ul",zp,[(r(!0),n(ve,null,ye(u.value.warnings,_=>(r(),n("li",{key:_},C(_),1))),128))])]),_:1})):I("",!0),e("div",Vp,[w(bp,{analysis:u.value},null,8,["analysis"])]),d.value?(r(),n("div",Mp,[e("label",Ep,[Ae(e("input",{"onUpdate:modelValue":g[0]||(g[0]=_=>c.value=_),type:"checkbox",class:"w-4 h-4 rounded border-neutral-300 dark:border-neutral-600 text-primary-600 focus:ring-primary-500"},null,512),[[Jt,c.value]]),g[4]||(g[4]=e("span",{class:"text-sm text-neutral-700 dark:text-neutral-300"},"Delete package after unpacking",-1))]),g[5]||(g[5]=e("span",{class:"text-xs text-neutral-500"},"(removes from agents/packed/)",-1))])):I("",!0)])):I("",!0)]),_:1},8,["modelValue","title"]))}}),Ap={key:0,class:"space-y-4"},jp={class:"space-y-2"},Dp={class:"font-medium"},Op={key:0,class:"text-sm opacity-80"},Rp={key:1,class:"text-sm opacity-70"},Up={key:2,class:"text-sm"},Bp=["href"],Fp={key:0,class:"space-y-2"},Np={class:"text-xs bg-neutral-100 dark:bg-neutral-800 p-3 rounded-md overflow-x-auto max-h-40 whitespace-pre-wrap"},qp={key:1,class:"space-y-4"},Hp={class:"space-y-3"},Wp={key:0,class:"flex items-center gap-2 text-neutral-500"},Kp={key:2,class:"p-4 rounded-lg border border-neutral-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-900/50"},Jp={class:"flex items-center gap-3 mb-3"},Yp={class:"text-lg font-semibold text-neutral-900 dark:text-neutral-100"},Gp={key:0,class:"text-sm text-neutral-600 dark:text-neutral-400 mb-3"},Zp={key:1,class:"mt-3"},Xp=["innerHTML"],Qp={key:0,class:"border-neutral-200 dark:border-neutral-700"},em={key:1,class:"flex items-center gap-2 text-neutral-500"},tm={class:"space-y-2 text-sm"},rm={class:"bg-neutral-200 dark:bg-neutral-700 px-1 rounded"},am={class:"list-decimal list-inside space-y-1 ml-2"},om={class:"whitespace-pre-wrap text-sm"},nm={class:"space-y-2"},lm={class:"flex items-center gap-4"},sm={class:"flex items-center gap-2 cursor-pointer"},im={class:"flex items-center gap-2 cursor-pointer"},um={key:0},dm={key:0,class:"mt-1 text-xs text-red-500"},cm={class:"flex items-center gap-2 cursor-pointer"},pm={class:"flex justify-between"},mm="https://registry.npmjs.org",vm=me({__name:"PublishModal",props:{modelValue:{type:Boolean},packageId:{},outputPath:{}},emits:["update:modelValue","published"],setup(t,{emit:o}){Vt.setOptions({gfm:!0,breaks:!0});const a=t,i=o,l=B({get:()=>a.modelValue,set:E=>i("update:modelValue",E)}),u=p(null),s=p(!1),m=p(null),h=p(!1),x=p(null),c=p(!1),f=B(()=>u.value?.readme?Vt(u.value.readme):""),y=p(""),b=p("default"),v=p(""),d=p(!1),k=p(!1),g=p(null),_=p(null),L=p(null),R=p(null),K=async()=>{s.value=!0,m.value=null;try{const E=await fetch(fe(`/api/pack/${encodeURIComponent(a.packageId)}/packed-info`));if(E.ok)u.value=await E.json();else{const S=await E.json();m.value=S.error||"Failed to load package info"}}catch(E){console.error("Failed to fetch package info:",E),m.value=E instanceof Error?E.message:"Failed to load package info"}finally{s.value=!1}},Y=async()=>{c.value=!0;try{const E=await fetch(fe("/api/pack/npm-token-status"));E.ok&&(x.value=await E.json())}catch(E){console.error("Failed to fetch npm token status:",E)}finally{c.value=!1}};ge(()=>a.modelValue,E=>{E&&(y.value="",b.value="default",v.value="",d.value=!1,g.value=null,_.value=null,L.value=null,R.value=null,x.value=null,u.value=null,m.value=null,h.value=!1,K(),Y())});const z=E=>x.value?.hasToken?null:!E||E.trim().length===0?"npm token is required":E.trim().length<10?"Token appears to be too short":null,P=E=>{if(!E)return null;try{return new URL(E).protocol!=="https:"?"Registry must use HTTPS":null}catch{return"Invalid URL format"}};ge(y,E=>{E&&(L.value=z(E))}),ge(v,E=>{b.value==="custom"&&E&&(R.value=P(E))}),ge(b,E=>{E==="default"?R.value=null:v.value&&(R.value=P(v.value))});const G=B(()=>b.value==="default"?mm:v.value),ee=B(()=>{const E=x.value?.hasToken||!z(y.value),S=b.value==="default"||!P(v.value);return E&&S}),se=async()=>{if(x.value?.hasToken||(L.value=z(y.value)),b.value==="custom"&&(R.value=P(v.value)),!(L.value||R.value)){k.value=!0,g.value=null,_.value=null;try{const E={registry:G.value,dryRun:d.value};y.value.trim()&&(E.token=y.value.trim());const S=await fetch(fe(`/api/pack/${encodeURIComponent(a.packageId)}/publish`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)}),V=await S.json();if(!S.ok){g.value=V.error||"Failed to publish package",V.output&&(g.value+=`
35
+
36
+ `+V.output);return}_.value={success:!0,packageName:V.packageName,version:V.version,output:V.output,url:V.url,tokenSource:V.tokenSource},d.value||i("published",{packageName:V.packageName,version:V.version,url:V.url})}catch(E){g.value=E instanceof Error?E.message:"Failed to publish package"}finally{k.value=!1}}},de=()=>{l.value=!1},Q=()=>d.value?"Dry run completed successfully!":"Package published successfully!";return(E,S)=>(r(),H(He,{modelValue:l.value,"onUpdate:modelValue":S[6]||(S[6]=V=>l.value=V),title:"Publish to npm",width:"max-w-lg","min-height":"min-h-[16rem]"},{footer:D(()=>[e("div",pm,[w(T(De),{variant:"ghost",onClick:de},{default:D(()=>[Z(C(_.value?.success?"Close":"Cancel"),1)]),_:1}),_.value?.success?I("",!0):(r(),H(T(De),{key:0,variant:"primary",disabled:k.value||c.value||!ee.value,onClick:se},{default:D(()=>[k.value?(r(),n(ve,{key:0},[w(Ee,{size:"sm",class:"mr-2"}),S[22]||(S[22]=Z(" Publishing... ",-1))],64)):(r(),n(ve,{key:1},[Z(C(d.value?"Validate":"Publish"),1)],64))]),_:1},8,["disabled"]))])]),default:D(()=>[_.value?.success?(r(),n("div",Ap,[w(T(Fe),{variant:d.value?"info":"success"},{default:D(()=>[e("div",jp,[e("p",Dp,C(Q()),1),_.value.packageName?(r(),n("p",Op," Package: "+C(_.value.packageName)+"@"+C(_.value.version),1)):I("",!0),_.value.tokenSource==="environment"?(r(),n("p",Rp," Token: from NPM_TOKEN environment variable ")):I("",!0),_.value.url&&!d.value?(r(),n("p",Up,[e("a",{href:_.value.url,target:"_blank",rel:"noopener noreferrer",class:"text-primary-600 dark:text-primary-400 hover:underline"}," View on npm ",8,Bp)])):I("",!0)])]),_:1},8,["variant"]),_.value.output?(r(),n("div",Fp,[S[7]||(S[7]=e("p",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"},"Output:",-1)),e("pre",Np,C(_.value.output),1)])):I("",!0)])):(r(),n("div",qp,[e("div",Hp,[s.value?(r(),n("div",Wp,[w(Ee,{size:"sm"}),S[8]||(S[8]=e("span",{class:"text-sm"},"Loading package info...",-1))])):m.value?(r(),H(T(Fe),{key:1,variant:"error"},{default:D(()=>[Z(C(m.value),1)]),_:1})):u.value?(r(),n("div",Kp,[e("div",Jp,[e("h3",Yp,C(u.value.packageName),1),w(T(ft),{variant:"secondary"},{default:D(()=>[Z("v"+C(u.value.version),1)]),_:1}),u.value.license?(r(),H(T(ft),{key:0,variant:"default"},{default:D(()=>[Z(C(u.value.license),1)]),_:1})):I("",!0)]),u.value.author?(r(),n("p",Gp," by "+C(u.value.author),1)):I("",!0),u.value.readme?(r(),n("div",Zp,[e("button",{type:"button",class:"flex items-center gap-2 text-sm font-medium text-neutral-600 dark:text-neutral-400 hover:text-neutral-800 dark:hover:text-neutral-200",onClick:S[0]||(S[0]=V=>h.value=!h.value)},[(r(),H(Ue(h.value?T(nt):T(vt)),{class:"w-4 h-4"})),S[9]||(S[9]=Z(" README ",-1))]),h.value?(r(),n("div",{key:0,class:"mt-2 prose prose-sm dark:prose-invert max-w-none p-3 rounded-md border border-neutral-200 dark:border-neutral-700 bg-white dark:bg-neutral-800 max-h-[200px] overflow-y-auto",innerHTML:f.value},null,8,Xp)):I("",!0)])):I("",!0)])):I("",!0)]),u.value?(r(),n("hr",Qp)):I("",!0),c.value?(r(),n("div",em,[w(Ee,{size:"sm"}),S[10]||(S[10]=e("span",{class:"text-sm"},"Checking npm token configuration...",-1))])):x.value?.hasToken?(r(),H(T(Fe),{key:2,variant:"success"},{default:D(()=>[...S[11]||(S[11]=[e("p",{class:"text-sm"},[e("strong",null,"NPM_TOKEN found"),Z(" in your environment. Your token will be used automatically. ")],-1)])]),_:1})):x.value&&!x.value.hasToken?(r(),H(T(Fe),{key:3,variant:"warning"},{default:D(()=>[e("div",tm,[S[17]||(S[17]=e("p",null,[e("strong",null,"No NPM_TOKEN configured.")],-1)),e("p",null,[S[12]||(S[12]=Z("To publish packages, create an npm token and add it to your ",-1)),e("code",rm,C(x.value.envFile),1),S[13]||(S[13]=Z(" file:",-1))]),e("ol",am,[S[15]||(S[15]=e("li",null,[Z("Run: "),e("code",{class:"bg-neutral-200 dark:bg-neutral-700 px-1 rounded"},"npm token create")],-1)),e("li",null,[Z("Add to "+C(x.value.envFile)+": ",1),S[14]||(S[14]=e("code",{class:"bg-neutral-200 dark:bg-neutral-700 px-1 rounded"},"NPM_TOKEN=npm_xxxxx",-1))]),S[16]||(S[16]=e("li",null,"Restart the dev server",-1))]),S[18]||(S[18]=e("p",{class:"pt-2"},"Or enter a token below for this session only:",-1))])]),_:1})):I("",!0),g.value?(r(),H(T(Fe),{key:4,variant:"error"},{default:D(()=>[e("pre",om,C(g.value),1)]),_:1})):I("",!0),!x.value?.hasToken&&!c.value?(r(),H(T(ct),{key:5,label:"npm Token",error:L.value||void 0,"help-text":"Create a token at npmjs.com/settings/tokens",required:!x.value?.hasToken},{default:D(()=>[Ae(e("input",{"onUpdate:modelValue":S[1]||(S[1]=V=>y.value=V),type:"password",autocomplete:"off",class:ae(["w-full px-3 py-2 rounded-md border text-sm font-mono bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent",{"border-red-500 dark:border-red-500":L.value}]),placeholder:"npm_xxxxxxxxxxxx"},null,2),[[Qe,y.value]])]),_:1},8,["error","required"])):I("",!0),w(T(ct),{label:"Registry"},{default:D(()=>[e("div",nm,[e("div",lm,[e("label",sm,[Ae(e("input",{"onUpdate:modelValue":S[2]||(S[2]=V=>b.value=V),type:"radio",value:"default",class:"text-primary-500 focus:ring-primary-500"},null,512),[[rr,b.value]]),S[19]||(S[19]=e("span",{class:"text-sm text-neutral-700 dark:text-neutral-300"},"npm (default)",-1))]),e("label",im,[Ae(e("input",{"onUpdate:modelValue":S[3]||(S[3]=V=>b.value=V),type:"radio",value:"custom",class:"text-primary-500 focus:ring-primary-500"},null,512),[[rr,b.value]]),S[20]||(S[20]=e("span",{class:"text-sm text-neutral-700 dark:text-neutral-300"},"Custom registry",-1))])]),b.value==="custom"?(r(),n("div",um,[Ae(e("input",{"onUpdate:modelValue":S[4]||(S[4]=V=>v.value=V),type:"url",class:ae(["w-full px-3 py-2 rounded-md border text-sm bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent",{"border-red-500 dark:border-red-500":R.value}]),placeholder:"https://registry.example.com"},null,2),[[Qe,v.value]]),R.value?(r(),n("p",dm,C(R.value),1)):I("",!0)])):I("",!0)])]),_:1}),e("label",cm,[Ae(e("input",{"onUpdate:modelValue":S[5]||(S[5]=V=>d.value=V),type:"checkbox",class:"rounded text-primary-500 focus:ring-primary-500"},null,512),[[Jt,d.value]]),S[21]||(S[21]=e("span",{class:"text-sm text-neutral-700 dark:text-neutral-300"}," Dry run (validate without publishing) ",-1))])]))]),_:1},8,["modelValue"]))}}),fm={},hm={class:"p-8 w-full max-w-7xl mx-auto"};function gm(t,o){return r(),n("div",hm,[je(t.$slots,"default")])}const pt=Xe(fm,[["render",gm]]),bm={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function xm(t,o){return r(),n("svg",bm,[...o[0]||(o[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14m-7-7v14"},null,-1)])])}const jt=Ie({name:"lucide-plus",render:xm}),ym=me({__name:"AgentsView",setup(t){const o=bt(),a=ut(),i=p(!1),l=p("add"),u=p(null),s=p(null),m=p(null),h=p(!1),x=p(null),c=p(!1),f=p(null),y=p(!1),b=p(null);ge(()=>a.query.refresh,()=>{a.query.refresh&&(s.value?.refresh(),o.replace({path:"/agents",query:{}}))});const v=()=>{l.value="add",u.value=null,m.value=null,i.value=!0},d=z=>{l.value="edit",u.value=z,m.value=null,i.value=!0},k=async z=>{m.value=null;try{const P=l.value==="edit"&&u.value?.id,{originalName:G,...ee}=z,se=fe(P?`/api/agents/${u.value.id}`:"/api/agents"),Q=await fetch(se,{method:P?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ee)});if(Q.ok)s.value?.refresh(),i.value=!1,u.value=null;else{const E=await Q.json();m.value=E.error||`Failed to ${P?"update":"create"} agent`}}catch(P){console.error(`Error ${l.value==="edit"?"updating":"creating"} agent:`,P),m.value=`Failed to ${l.value==="edit"?"update":"create"} agent`}},g=z=>{x.value=z,h.value=!0},_=()=>{h.value=!1,x.value=null,s.value?.refresh()},L=z=>{f.value=z,c.value=!0},R=()=>{c.value=!1,f.value=null,s.value?.refresh()},K=z=>{b.value=z,y.value=!0},Y=()=>{y.value=!1,b.value=null};return(z,P)=>(r(),H(pt,null,{default:D(()=>[w(Gc,{ref_key:"dataTableRef",ref:s,title:"Agents",description:"Configure and manage your AI agents.","primary-action":{label:"Create Agent",icon:T(jt),handler:v},onAdd:v,onEdit:d,onPack:g,onUnpack:L,onPublish:K},null,8,["primary-action"]),w(D0,{modelValue:i.value,"onUpdate:modelValue":P[0]||(P[0]=G=>i.value=G),mode:l.value,editAgent:u.value,apiError:m.value,onSave:k},null,8,["modelValue","mode","editAgent","apiError"]),w(dp,{modelValue:h.value,"onUpdate:modelValue":P[1]||(P[1]=G=>h.value=G),agent:x.value,onPacked:_},null,8,["modelValue","agent"]),w(Pp,{modelValue:c.value,"onUpdate:modelValue":P[2]||(P[2]=G=>c.value=G),agent:f.value,onUnpacked:R},null,8,["modelValue","agent"]),w(vm,{modelValue:y.value,"onUpdate:modelValue":P[3]||(P[3]=G=>y.value=G),"package-id":b.value?.packageId??"","output-path":"agents/packed/"+(b.value?.packageId??""),onPublished:Y},null,8,["modelValue","package-id","output-path"])]),_:1}))}});function km(t){const{limit:o=50,offset:a=0,agentId:i=null,userId:l=null,search:u=null,startDate:s=null,endDate:m=null,autoFetch:h=!0}=t||{},x=B(()=>{const L=new URLSearchParams,R=typeof o=="number"?o:o.value,K=typeof a=="number"?a:a.value,Y=typeof i=="string"?i:i?.value,z=typeof l=="string"?l:l?.value,P=typeof u=="string"?u:u?.value,G=typeof s=="number"?s:s?.value,ee=typeof m=="number"?m:m?.value;return L.append("limit",R.toString()),L.append("offset",K.toString()),Y&&L.append("agent_id",Y),z&&L.append("user_id",z),P&&L.append("search",P),G&&L.append("startDate",G.toString()),ee&&L.append("endDate",ee.toString()),fe(`/api/threads?${L.toString()}`)}),{data:c,error:f,isFetching:y,isFinished:b,execute:v,abort:d}=Ne(x,{immediate:h,refetch:!0}).get().json(),k=B(()=>c.value?.threads||[]),g=B(()=>c.value?.total||0),_=B(()=>c.value?.hasMore||!1);return{threads:k,total:g,hasMore:_,error:f,isFetching:y,isFinished:b,refetch:v,abort:d}}function Qt(t){const o=B(()=>!!(typeof t=="string"?t:t?.value)),a=B(()=>{const c=typeof t=="string"?t:t?.value;return fe(c?`/api/threads/${c}`:"/api/threads/placeholder")}),{data:i,error:l,isFetching:u,isFinished:s,execute:m,abort:h}=Ne(a,{immediate:!1,refetch:!0}).get().json();return ge(o,c=>{c&&m()},{immediate:!0}),{thread:B(()=>i.value?{id:i.value.thread.id,agent_id:i.value.thread.agent_id,user_id:i.value.thread.user_id,tags:i.value.thread.tags||[],created_at:i.value.thread.created_at,agent:i.value.agent||{id:"",title:"Unknown",type:"unknown"},stats:i.value.stats}:null),error:l,isFetching:u,isFinished:s,refetch:m,abort:h}}function oa(){const t=fe("/api/agents"),{data:o,error:a,isFetching:i,isFinished:l,execute:u}=Ne(t,{immediate:!0}).get().json();return{agents:B(()=>o.value?.agents||[]),error:a,isFetching:i,isFinished:l,refetch:u}}function wm(t){const{autoConnect:o=!0,onEvent:a}=t||{},i=p(null),l=p(!1),u=p(null);let s=0,m=null,h=null,x=!0;const c=3e4,f=3e4,y=()=>{m&&(clearTimeout(m),m=null),h&&(clearInterval(h),h=null)},b=()=>{h&&clearInterval(h),h=setInterval(()=>{i.value&&i.value.readyState===WebSocket.OPEN&&i.value.send("ping")},f)},v=()=>{if(!x)return;const _=Math.min(1e3*Math.pow(2,s),c);s++,console.log(`[AgentBuilderEvents] Scheduling reconnect in ${_}ms (attempt ${s})`),m=setTimeout(()=>{x&&d()},_)},d=()=>{i.value&&i.value.close();const _=window.location.protocol==="https:"?"wss:":"ws:",L=window.location.host;let R=`${_}//${L}${fe("/api/events")}`;const K=localStorage.getItem("auth_token");K&&(R+=`?token=${encodeURIComponent(K)}`);try{i.value=new WebSocket(R),i.value.onopen=()=>{l.value=!0,u.value=null,s=0,b(),console.log("[AgentBuilderEvents] WebSocket connected")},i.value.onmessage=Y=>{try{if(typeof Y.data=="string"&&Y.data==="pong")return;const z=JSON.parse(Y.data);a&&a(z)}catch(z){console.error("[AgentBuilderEvents] Failed to parse WebSocket message:",z)}},i.value.onerror=Y=>{u.value="WebSocket connection error",console.error("[AgentBuilderEvents] WebSocket error:",Y)},i.value.onclose=()=>{l.value=!1,y(),console.log("[AgentBuilderEvents] WebSocket disconnected"),v()}}catch(Y){u.value=Y.message||"Failed to create WebSocket",console.error("[AgentBuilderEvents] WebSocket creation error:",Y),v()}},k=()=>{x=!0,s=0,d()},g=()=>{x=!1,y(),i.value&&(i.value.close(),i.value=null),l.value=!1,s=0};return o&&k(),Ye(()=>{g()}),{wsConnected:l,wsError:u,connect:k,disconnect:g}}function _m(t){const a=Date.now()*1e3-t,i=Math.floor(a/1e6);if(i<60)return i===1?"1 second ago":`${i} seconds ago`;const l=Math.floor(i/60);if(l<60)return l===1?"1 minute ago":`${l} minutes ago`;const u=Math.floor(l/60);if(u<24)return u===1?"1 hour ago":`${u} hours ago`;const s=Math.floor(u/24);if(s<30)return s===1?"1 day ago":`${s} days ago`;const m=Math.floor(s/30);if(m<12)return m===1?"1 month ago":`${m} months ago`;const h=Math.floor(m/12);return h===1?"1 year ago":`${h} years ago`}function $m(t){const o=p("");let a=null;const i=()=>typeof t=="function"?t():typeof t=="number"?t:t.value,l=()=>{const u=i();o.value=_m(u);const m=Date.now()*1e3-u,h=Math.floor(m/1e6);a!==null&&(clearInterval(a),a=null),h<60?a=setInterval(l,1e3):h<3600?a=setInterval(l,6e4):h<86400&&(a=setInterval(l,6e5))};return l(),Ye(()=>{a!==null&&clearInterval(a)}),o}const yt=me({__name:"TimeAgo",props:{timestamp:{}},setup(t){const o=t,a=$m(()=>o.timestamp);return(i,l)=>(r(),n("span",null,C(T(a)),1))}}),Cm={class:"relative inline-flex items-center"},Sm={key:0,class:"inline-block w-2 h-2 rounded-full bg-green-500 dark:bg-green-400"},Tm={key:1,class:"inline-block w-2 h-2 rounded-full bg-neutral-400 dark:bg-neutral-600"},Im={key:0},zm={key:1},er=me({__name:"StatusDot",props:{connected:{type:Boolean},error:{type:Boolean}},setup(t){const o=p(!1),a=p(null);return(i,l)=>(r(),n("div",Cm,[e("span",{class:"p-0.5 cursor-default outline-none",tabindex:"-1",onMouseenter:l[0]||(l[0]=u=>o.value=!0),onMouseleave:l[1]||(l[1]=u=>o.value=!1)},[t.connected?(r(),n("span",Sm)):(r(),n("span",Tm))],32),w(et,{"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:D(()=>[o.value?(r(),n("div",{key:0,ref_key:"popoverRef",ref:a,class:ae(["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-neutral-50 dark:bg-neutral-900 border-neutral-200 dark:border-neutral-700 text-neutral-600 dark:text-neutral-400":!t.connected}])},[t.connected?(r(),n("span",Im,"Live - Connected")):(r(),n("span",zm,"Offline"))],2)):I("",!0)]),_:1})]))}}),Vm={class:"relative min-w-0"},Mm={class:"truncate flex-1 text-left"},Em={key:0},Lm=["onClick"],Pm={class:"border-t border-neutral-200 dark:border-neutral-700"},Am={class:"flex items-center justify-between"},jm={class:"space-y-4 date-filter-inputs"},Dm=me({__name:"DateFilterDropdown",props:{startDate:{},endDate:{}},emits:["update:startDate","update:endDate"],setup(t,{emit:o}){const a=t,i=o,l=p(!1),u=p(!1),s=p(null),m=p(null),h=p(""),x=p(""),c=[{label:"All time",value:"all",getRange:()=>({startDate:null,endDate:null})},{label:"Today",value:"today",getRange:()=>{const z=new Date,P=new Date(z.getFullYear(),z.getMonth(),z.getDate());return{startDate:Math.floor(P.getTime()/1e3),endDate:null}}},{label:"Last 3 days",value:"3days",getRange:()=>{const z=new Date,P=new Date(z.getFullYear(),z.getMonth(),z.getDate()-2);return{startDate:Math.floor(P.getTime()/1e3),endDate:null}}},{label:"Last 7 days",value:"7days",getRange:()=>{const z=new Date,P=new Date(z.getFullYear(),z.getMonth(),z.getDate()-6);return{startDate:Math.floor(P.getTime()/1e3),endDate:null}}},{label:"Last 30 days",value:"30days",getRange:()=>{const z=new Date,P=new Date(z.getFullYear(),z.getMonth(),z.getDate()-29);return{startDate:Math.floor(P.getTime()/1e3),endDate:null}}}],f=B(()=>{if(!a.startDate&&!a.endDate)return"all";for(const z of c){const P=z.getRange();if(P.startDate===a.startDate&&P.endDate===a.endDate)return z.value}return"custom"}),y=B(()=>{if(!a.startDate&&!a.endDate)return"All time";const z=c.find(G=>G.value===f.value);if(z&&f.value!=="custom")return z.label;const P=G=>new Date(G*1e3).toLocaleDateString("en-US",{month:"short",day:"numeric"});return a.startDate&&a.endDate?`${P(a.startDate)} - ${P(a.endDate)}`:a.startDate?`From ${P(a.startDate)}`:a.endDate?`Until ${P(a.endDate)}`:"Custom"}),b=B(()=>a.startDate!==null||a.endDate!==null);function v(){if(!s.value||!m.value)return;const z=s.value.getBoundingClientRect();m.value.style.position="fixed",m.value.style.top=`${z.bottom+8}px`,m.value.style.left=`${z.left}px`;const P=u.value?280:180;m.value.style.minWidth=`${z.width}px`,m.value.style.maxWidth=`${Math.max(z.width,P)}px`,m.value.style.width="auto",m.value.style.margin="0"}function d(){l.value?k():(l.value=!0,Le(()=>{if(m.value&&(m.value.setAttribute("popover","auto"),m.value.addEventListener("toggle",g),"showPopover"in m.value))try{m.value.showPopover()}catch{}v()}))}function k(){if(m.value){if("hidePopover"in m.value)try{m.value.hidePopover()}catch{}m.value.removeEventListener("toggle",g)}l.value=!1,u.value=!1}function g(z){z.target===m.value&&(l.value=z.newState==="open",l.value&&v())}function _(z){const P=z.getRange();i("update:startDate",P.startDate),i("update:endDate",P.endDate),k()}function L(){const z=h.value?Math.floor(new Date(h.value).getTime()/1e3):null,P=x.value?Math.floor(new Date(x.value+"T23:59:59").getTime()/1e3):null;i("update:startDate",z),i("update:endDate",P),k()}function R(z){z.stopPropagation(),i("update:startDate",null),i("update:endDate",null)}const K=z=>{const P=z.target;m.value&&!m.value.contains(P)&&s.value&&!s.value.contains(P)&&k()},Y=z=>{z.key==="Escape"&&l.value&&(k(),s.value?.focus())};return Pe(()=>{document.addEventListener("click",K),document.addEventListener("keydown",Y),window.addEventListener("resize",v),window.addEventListener("scroll",v,!0)}),Ye(()=>{document.removeEventListener("click",K),document.removeEventListener("keydown",Y),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0)}),ge(u,z=>{z&&(a.startDate&&(h.value=new Date(a.startDate*1e3).toISOString().split("T")[0]),a.endDate?x.value=new Date(a.endDate*1e3).toISOString().split("T")[0]:x.value=new Date().toISOString().split("T")[0]),Le(v)}),(z,P)=>{const G=Be("FormKit");return r(),n("div",Vm,[e("button",{ref_key:"triggerRef",ref:s,type:"button",onClick:d,class:ae(["w-full flex items-center gap-1 px-2 py-1 text-xs rounded-sm border transition-colors min-w-0 focus:outline-none focus:ring-2 focus:ring-accent-500/30",[b.value?"border-accent-500 bg-accent-50 dark:bg-accent-950/50 text-accent-700 dark:text-accent-300":"border-zinc-300 dark:border-zinc-600 hover:border-accent-400 dark:hover:border-accent-500 bg-white dark:bg-transparent text-zinc-700 dark:text-zinc-300"]])},[w(T(Ta),{size:14,class:"shrink-0 text-zinc-400"}),e("span",Mm,C(y.value),1),b.value?(r(),H(T(Yt),{key:0,size:14,class:"shrink-0 text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-200",onClick:R})):(r(),H(T(nt),{key:1,size:14,class:ae(["shrink-0 text-zinc-400",l.value?"rotate-180":""])},null,8,["class"]))],2),l.value?(r(),n("div",{key:0,ref_key:"popoverRef",ref:m,class:"dropdown-popover z-[9999]"},[w(T(At),{"max-height":u.value?void 0:"max-h-48",shadow:{offsetX:4,offsetY:4,intensity:.3}},{default:D(()=>[u.value?(r(),n("div",{key:1,class:"p-2.5 space-y-2.5",onClick:P[4]||(P[4]=Re(()=>{},["stop"]))},[e("div",Am,[P[6]||(P[6]=e("span",{class:"text-xs font-medium"},"Custom range",-1)),e("button",{type:"button",onClick:P[1]||(P[1]=Re(ee=>u.value=!1,["stop"])),class:"text-[10px] text-neutral-500 hover:text-black dark:hover:text-white"}," ← Back ")]),e("div",jm,[w(G,{modelValue:h.value,"onUpdate:modelValue":P[2]||(P[2]=ee=>h.value=ee),type:"datepicker",label:"From","picker-only":"",popover:"",format:"MMM D, YYYY","value-format":"YYYY-MM-DD",sequence:["day"]},null,8,["modelValue"]),w(G,{modelValue:x.value,"onUpdate:modelValue":P[3]||(P[3]=ee=>x.value=ee),type:"datepicker",label:"To","picker-only":"",popover:"",format:"MMM D, YYYY","value-format":"YYYY-MM-DD",sequence:["day"]},null,8,["modelValue"])]),e("button",{type:"button",onClick:L,class:"w-full py-1.5 text-xs font-medium bg-black dark:bg-white text-white dark:text-black rounded-sm hover:opacity-90 transition-opacity"}," Apply ")])):(r(),n("div",Em,[(r(),n(ve,null,ye(c,ee=>e("button",{key:ee.value,type:"button",onClick:se=>_(ee),class:ae(["w-full px-2.5 py-1.5 text-left text-xs hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors flex items-center gap-2",f.value===ee.value?"bg-accent-50 dark:bg-accent-950/30":""])},[e("span",{class:ae(["w-1.5 h-1.5 rounded-full border border-accent-500",f.value===ee.value?"bg-accent-500":""])},null,2),Z(" "+C(ee.label),1)],10,Lm)),64)),e("div",Pm,[e("button",{type:"button",onClick:P[0]||(P[0]=Re(ee=>u.value=!0,["stop"])),class:ae(["w-full px-2.5 py-1.5 text-left text-xs hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors flex items-center gap-2",f.value==="custom"?"bg-accent-50 dark:bg-accent-950/30":""])},[e("span",{class:ae(["w-1.5 h-1.5 rounded-full border border-accent-500",f.value==="custom"?"bg-accent-500":""])},null,2),P[5]||(P[5]=Z(" Custom range... ",-1))],2)])]))]),_:1},8,["max-height"])],512)):I("",!0)])}}}),Om=Xe(Dm,[["__scopeId","data-v-88032ecc"]]),Rm={class:"flex flex-col flex-1 min-h-0 overflow-visible"},Um={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},Bm={class:"flex items-center justify-between"},Fm={class:"flex items-center gap-2"},Nm={key:0,class:"text-xs font-mono text-neutral-500 dark:text-neutral-400"},qm={class:"flex items-center gap-2"},Hm=["title"],Wm={key:0,class:"absolute -top-1 -right-1 w-3.5 h-3.5 flex items-center justify-center text-[8px] font-bold font-mono bg-accent-500 text-white rounded-full"},Km={key:0,class:"bg-neutral-100 dark:bg-neutral-950 border-b border-neutral-200 dark:border-neutral-800"},Jm={class:"p-2"},Ym={class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 p-2.5 space-y-2"},Gm={class:"flex items-center gap-2 w-full"},Zm={class:"flex-1 min-w-0"},Xm={key:0,class:"flex justify-end"},Qm={key:0,class:"p-4 flex justify-center"},ev={key:1,class:"p-4 text-red-600 dark:text-red-400"},tv={key:2,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},rv={key:1,class:"text-base"},av={key:3},ov=["id","onClick"],nv={class:"flex items-center gap-2 mb-1"},lv={class:"flex-shrink-0 text-neutral-400 dark:text-neutral-500 text-[10px]"},sv={class:"flex items-center gap-2"},iv={class:"text-[10px] text-neutral-400 dark:text-neutral-500 font-mono truncate max-w-[80px]"},uv={key:0,class:"flex flex-wrap gap-1 flex-1 min-w-0"},dv={key:0,class:"text-[10px] text-neutral-400"},cv={key:0,class:"p-3 flex justify-center"},pv={key:1,class:"p-3 text-center text-[10px] text-neutral-400 dark:text-neutral-500"},mv=50,vv=me({__name:"ThreadListPane",props:{selectedThreadId:{}},emits:["selectThread","collapse","createThread","threadsLoaded"],setup(t,{expose:o,emit:a}){const i=a,l=p(!1),u=p(""),s=p(null),m=p(null),h=p(null),x=p(null),{agents:c,isFetching:f}=oa(),y=B(()=>c.value.map(J=>({value:J.name,label:J.title||J.name}))),b=p(0),v=p([]),d=p(!1),k=zr(J=>{s.value=J||null},300);ge(u,J=>{k(J)});const g=B(()=>{let J=0;return s.value&&J++,m.value&&J++,(h.value||x.value)&&J++,J});function _(){u.value="",s.value=null,m.value=null,h.value=null,x.value=null}const{threads:L,total:R,hasMore:K,isFetching:Y,isFinished:z,error:P,refetch:G}=km({limit:mv,offset:b,search:s,agentId:m,startDate:h,endDate:x});ge([s,m,h,x],()=>{b.value=0,v.value=[],d.value=!1}),ge(L,J=>{if(b.value===0)v.value=[...J];else{const U=new Set(v.value.map(M=>M.id)),W=J.filter(M=>!U.has(M.id));v.value=[...v.value,...W]}d.value=!1});const ee=p([]),se=p(new Set),de=B(()=>{const J=v.value.filter(M=>!se.value.has(M.id)),U=new Set(J.map(M=>M.id));return[...ee.value.filter(M=>!U.has(M.id)&&!se.value.has(M.id)),...J].sort((M,ne)=>ne.created_at-M.created_at)}),Q=p(null);function E(){d.value||Y.value||!K.value||(d.value=!0,b.value=v.value.length)}const{arrivedState:S}=Ia(Q,{offset:{bottom:100}});ge(()=>S.bottom,J=>{J&&K.value&&!Y.value&&!d.value&&E()});const V=async J=>{if(J.type==="thread_created"){const U={id:J.thread.id,agent_id:J.thread.agent_name,user_id:J.thread.user_id,tags:J.thread.tags||[],created_at:J.thread.created_at,agent:{name:J.thread.agent_name,title:void 0,type:"ai_human"}};ee.value.unshift(U)}else J.type==="thread_deleted"&&(se.value.add(J.threadId),ee.value=ee.value.filter(U=>U.id!==J.threadId))},{wsConnected:re,wsError:F}=wm({onEvent:V});ge(()=>b.value,J=>{J===0&&(ee.value=[])});const q=p(!1);ge(()=>({threads:v.value,finished:z.value}),({threads:J,finished:U})=>{U&&!q.value&&J.length>0&&(q.value=!0,i("threadsLoaded",J[0]?.id??null))},{immediate:!0}),o({refetch:G});const N=J=>{i("selectThread",J)};return(J,U)=>{const W=Be("FormKit");return r(),n("div",Rm,[e("div",Um,[e("div",Bm,[e("div",Fm,[w(T(Er),{size:18,class:"shrink-0"}),U[7]||(U[7]=e("h2",{class:"text-base font-bold"},"Threads",-1)),!T(Y)&&T(R)>0?(r(),n("span",Nm," ("+C(T(R))+") ",1)):I("",!0),w(er,{connected:T(re),error:T(F)},null,8,["connected","error"])]),e("div",qm,[e("button",{onClick:U[0]||(U[0]=M=>l.value=!l.value),type:"button",class:ae(["relative p-1 rounded transition-colors hover:bg-neutral-100 dark:hover:bg-neutral-900",[l.value||g.value>0?"text-accent-600 dark:text-accent-400":""]]),title:l.value?"Hide filters":"Show filters"},[w(T(za),{size:18}),g.value>0?(r(),n("span",Wm,C(g.value),1)):I("",!0)],10,Hm),e("button",{onClick:U[1]||(U[1]=M=>i("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:U[2]||(U[2]=M=>i("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[w(T(Lr),{size:20})])])])]),w(et,{"enter-active-class":"transition-all duration-200 ease-out","enter-from-class":"opacity-0 -translate-y-2 max-h-0","enter-to-class":"opacity-100 translate-y-0 max-h-60","leave-active-class":"transition-all duration-150 ease-in","leave-from-class":"opacity-100 translate-y-0 max-h-60","leave-to-class":"opacity-0 -translate-y-2 max-h-0"},{default:D(()=>[l.value?(r(),n("div",Km,[e("div",Jm,[e("div",Ym,[w(W,{type:"searchInput",modelValue:u.value,"onUpdate:modelValue":U[3]||(U[3]=M=>u.value=M),placeholder:"Search by tag or thread ID...",size:"sm"},null,8,["modelValue"]),e("div",Gm,[e("div",Zm,[w(W,{type:"selectSearch",size:"sm","active-highlight":"",value:m.value||"",options:y.value,placeholder:"All agents","search-placeholder":"Search agents...",loading:T(f),onInput:U[4]||(U[4]=M=>m.value=M||null)},null,8,["value","options","loading"])]),w(Om,{startDate:h.value,"onUpdate:startDate":U[5]||(U[5]=M=>h.value=M),endDate:x.value,"onUpdate:endDate":U[6]||(U[6]=M=>x.value=M),class:"flex-1 min-w-0"},null,8,["startDate","endDate"])]),g.value>0?(r(),n("div",Xm,[e("button",{onClick:_,type:"button",class:"text-xs font-mono text-neutral-500 hover:text-neutral-900 dark:hover:text-neutral-100 transition-colors"}," Clear all ")])):I("",!0)])])])):I("",!0)]),_:1}),e("div",{ref_key:"scrollContainerRef",ref:Q,class:"flex-1 overflow-y-auto text-xs min-h-0"},[T(Y)&&v.value.length===0?(r(),n("div",Qm,[w(Ee)])):T(P)?(r(),n("div",ev," Error: "+C(T(P)),1)):de.value.length===0?(r(),n("div",tv,[g.value>0?(r(),n(ve,{key:0},[U[8]||(U[8]=e("p",{class:"text-base mb-2"},"No matching threads",-1)),e("button",{onClick:_,type:"button",class:"text-xs text-accent-600 dark:text-accent-400 hover:underline"}," Clear filters ")],64)):(r(),n("p",rv,"No threads found"))])):(r(),n("div",av,[(r(!0),n(ve,null,ye(de.value,M=>(r(),n("button",{key:M.id,id:`thread-${M.id}`,class:ae(["w-full text-left px-3 py-2.5 border-b border-neutral-200 dark:border-neutral-800 cursor-pointer transition-colors relative hover:bg-neutral-50 dark:hover:bg-neutral-800/50",{"bg-accent-50 dark:bg-accent-950/50 border-l-2 border-l-accent-500":t.selectedThreadId===M.id}]),onClick:ne=>N(M.id)},[e("div",nv,[e("span",{class:ae(["font-medium truncate flex-1 min-w-0",t.selectedThreadId===M.id?"text-accent-700 dark:text-accent-300":""])},C(M.agent.title||M.agent.name),3),e("span",lv,[w(yt,{timestamp:M.created_at*1e6},null,8,["timestamp"])])]),e("div",sv,[e("span",iv,C(M.id.slice(0,8)),1),M.tags.length>0?(r(),n("div",uv,[(r(!0),n(ve,null,ye(M.tags.slice(0,3),ne=>(r(),n("span",{key:ne,class:ae(["inline-block px-1.5 py-0.5 rounded text-[10px] truncate max-w-[60px]",t.selectedThreadId===M.id?"bg-accent-200 dark:bg-accent-900 text-accent-800 dark:text-accent-200":"bg-neutral-200 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400"])},C(ne),3))),128)),M.tags.length>3?(r(),n("span",dv," +"+C(M.tags.length-3),1)):I("",!0)])):I("",!0)])],10,ov))),128)),d.value||T(Y)&&v.value.length>0?(r(),n("div",cv,[w(Ee)])):!T(K)&&de.value.length>0?(r(),n("div",pv," All "+C(T(R))+" threads loaded ",1)):I("",!0)]))],512)])}}});function fv(t,o={}){const a=p(null),i=p(!1),l=p(null);let u=null;try{u=Ur()}catch{}const s=u?.workblocks??B(()=>[]),m=u?.messages??p([]),h=B(()=>u?.status.value==="connected"),x=p(null);u?.loading??p(!1);const c=B(()=>m.value.some(F=>F.status==="pending")),f=p(!1),y=p(0),b=p(!1);function v(F){if(!a.value?.agent)return null;const q=a.value.agent,N=F==="assistant"?"A":"B";return N==="A"&&q.side_a_label?q.side_a_label:N==="B"&&q.side_b_label?q.side_b_label:null}function d(F){return{id:F.id||`att-${F.path||F.name||Math.random().toString(36).slice(2)}`,type:"file",path:F.path||"",name:F.name||F.path?.split("/").pop()||"attachment",mimeType:F.mimeType||F.mediaType||"application/octet-stream",width:F.width,height:F.height,description:F.description}}function k(F){if(F){if(Array.isArray(F))return F.length>0?F.map(d):void 0;try{const q=JSON.parse(F);return Array.isArray(q)&&q.length>0?q.map(d):void 0}catch(q){console.error("Failed to parse attachments:",q);return}}}function g(F,q){const N=[];F.reasoning_content&&N.push({id:`${F.id}-reasoning`,type:"reasoning",content:F.reasoning_content,created_at:F.created_at}),F.content&&N.push({id:`${F.id}-content`,type:"content",content:F.content,created_at:F.created_at});const J=F.workItems.filter(A=>A.type==="tool_call"),U=F.workItems.filter(A=>A.type==="tool_result"),W=new Map;for(const A of U)A.tool_call_id&&W.set(A.tool_call_id,A);for(const A of J){const ce=A.tool_call_id||A.id,ue=W.get(ce);let ke="pending";if(ue){const be=(ue.content||"").toLowerCase(),O=be.includes("failed")||be.includes("error"),$=be.length<500;ke=ue.status==="error"||O&&$?"failed":"success"}N.push({id:A.id,type:"tool_call",content:A.name||"",created_at:F.created_at,tool_name:A.name,tool_call_id:ce,tool_arguments:A.content||void 0,response:ue?.content||null,response_status:ke,response_log_id:null,log_id:null})}const M=N.some(A=>A.type==="tool_call"&&A.response_status==="pending"),ne=F.status!=="pending"&&!M;return{type:"work",id:F.id,role:"assistant",items:N,created_at:F.created_at,updated_at:F.created_at,isComplete:ne,sideLabel:v("assistant"),status:F.status}}const _=B(()=>{const F=[],N=s.value.filter(U=>(U.depth??0)===0);let J=[];for(let U=0;U<N.length;U++){const W=N[U];if(F[F.length-1]?.role,W.type==="workblock"){const ne=g(W);F.push(ne);const A=W;A.attachments&&A.attachments.length>0&&J.push(...A.attachments.map(d))}else{const ne=W,A=ne.role;if(ne.role==="tool")continue;const ce=k(ne.attachments);let ue;if((J.length>0||ce)&&(ue=[...J,...ce||[]],J=[]),ne.content||A==="system"||ne.status==="pending"||ue?.length){const ke={type:"text",id:ne.id,role:A,content:ne.content||"",attachments:ue?.length?ue:void 0,created_at:ne.created_at,log_id:ne.log_id||null,sideLabel:v(A),isOptimistic:ne.isOptimistic,status:ne.status,silent:ne.silent};F.push(ke)}}}return F});async function L(){if(!t.value){a.value=null;return}try{const F=await fetch(fe(`/api/threads/${t.value}`));F.ok&&(a.value=await F.json())}catch(F){console.error("Error fetching thread info:",F)}}async function R(F){if(t.value){if(u?.deleteMessage){await u.deleteMessage(F);return}try{if(!(await fetch(fe(`/api/threads/${t.value}/messages/${F}`),{method:"DELETE"})).ok)throw new Error("Failed to delete message")}catch(q){throw q}}}async function K(F,q){if(t.value)try{if(!(await fetch(fe(`/api/threads/${t.value}/messages/${F}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:q})})).ok)throw new Error("Failed to update message")}catch(N){throw N}}ge(t,async F=>{F?(i.value=!0,await L(),i.value=!1):a.value=null},{immediate:!0});const Y=u?.sendMessage,z=u?.stopExecution,P=u?.attachments??p([]),G=u?.addAttachment??(()=>{}),ee=u?.removeAttachment??(()=>{}),se=u?.clearAttachments??(()=>{});function de(){console.warn("loadMoreMessages is deprecated - SDK handles all messages")}function Q(){console.warn("connectWebSocket is deprecated - SDK handles WebSocket")}function E(){console.warn("disconnectWebSocket is deprecated - SDK handles WebSocket")}function S(){console.warn("addOptimisticMessage is deprecated - SDK handles optimistic updates")}function V(){console.warn("removeOptimisticMessage is deprecated - SDK handles optimistic updates")}async function re(){console.warn("refetch is deprecated - SDK handles message loading")}return{messages:_,threadInfo:a,isFetching:i,isLoadingMore:b,error:l,wsConnected:h,wsError:x,isExecuting:c,hasMore:f,totalMessages:y,sendMessage:Y,stopThread:z,attachments:P,addAttachment:G,removeAttachment:ee,clearAttachments:se,deleteMessageById:R,updateMessageContent:K,refetch:re,loadMoreMessages:de,connectWebSocket:Q,disconnectWebSocket:E,addOptimisticMessage:S,removeOptimisticMessage:V}}const hv={key:0,class:"absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-800"},gv={key:1,class:"absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-800 text-neutral-400"},bv=["src","alt"],xv={class:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center"},yv={key:0,class:"text-white text-[10px]"},kv={class:"text-xs text-neutral-600 dark:text-neutral-300 truncate max-w-[100px]"},wv=me({__name:"FileAttachment",props:{attachment:{},threadId:{},showRemove:{type:Boolean}},emits:["remove"],setup(t,{emit:o}){const a=t,i=o,l=p(!0),u=p(!1),s=B(()=>a.attachment.mimeType.startsWith("image/")),m=B(()=>!!a.attachment.thumbnailBase64),h=B(()=>{if(!a.threadId||!a.attachment.path)return"";const v=a.attachment.path.startsWith("/")?a.attachment.path.slice(1):a.attachment.path;return fe(`/api/threads/${a.threadId}/fs/${v}`)}),x=B(()=>s.value?a.attachment.thumbnailBase64?`data:image/webp;base64,${a.attachment.thumbnailBase64}`:h.value:"");function c(){l.value=!1,u.value=!1}function f(){l.value=!1,u.value=!0}function y(){i("remove",a.attachment.id)}function b(){h.value&&window.open(h.value,"_blank")}return(v,d)=>(r(),n("div",{class:ae(["relative group inline-flex items-center rounded-lg overflow-hidden border border-neutral-200 dark:border-neutral-700",{"w-[104px] h-[104px]":s.value,"px-2 py-1 bg-neutral-100 dark:bg-neutral-800":!s.value,"cursor-pointer":s.value&&h.value}]),onClick:d[0]||(d[0]=k=>s.value&&h.value?b():void 0)},[s.value?(r(),n(ve,{key:0},[l.value&&!u.value&&!m.value?(r(),n("div",hv,[...d[1]||(d[1]=[e("div",{class:"w-4 h-4 border-2 border-neutral-300 border-t-neutral-600 rounded-full animate-spin"},null,-1)])])):I("",!0),u.value&&!m.value?(r(),n("div",gv,[w(T(Pr),{size:24})])):I("",!0),Ae(e("img",{src:x.value||h.value,alt:t.attachment.name,class:"w-full h-full object-cover",onLoad:c,onError:f},null,40,bv),[[Ke,!l.value&&!u.value||m.value]]),e("div",xv,[h.value?(r(),n("span",yv,"Click to view")):I("",!0)])],64)):(r(),n(ve,{key:1},[w(T(Ar),{size:14,class:"text-neutral-500 mr-1 flex-shrink-0"}),e("span",kv,C(t.attachment.name),1)],64)),t.showRemove?(r(),n("button",{key:2,onClick:Re(y,["stop"]),class:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-red-500 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity"},[w(T(Yt),{size:10})])):I("",!0)],2))}}),_v=["onMouseenter","onMouseleave","onClick"],$v=["onClick"],Cv={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"},Sv={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"},Tv={key:0,class:"w-full text-center text-xs text-neutral-400 dark:text-neutral-500 py-1"},Iv=["contenteditable","onInput"],zv={key:1,class:"flex gap-1 items-center min-h-[1.5rem]"},Vv={key:0,class:"opacity-50"},Mv={key:1,class:"opacity-50 italic text-neutral-500 dark:text-neutral-400"},Ev={key:0,class:"flex flex-wrap gap-2"},Lv=["onClick","onMouseenter"],Pv={key:0,class:"space-y-1"},Av={class:"flex items-start gap-2"},jv={class:"flex-1 min-w-0"},Dv={key:0,class:"truncate opacity-80"},Ov={key:1,class:"italic opacity-60"},Rv={class:"flex items-center gap-2 pl-5 opacity-60"},Uv={class:"text-[10px]"},Bv={class:"text-[10px]"},Fv={key:1,class:"space-y-2"},Nv={class:"flex items-center gap-2 pb-1 border-b border-current opacity-70"},qv={class:"text-[10px] italic"},Hv={class:"text-[10px] ml-auto"},Wv={key:0,class:"space-y-1"},Kv=["onClick","onMouseenter"],Jv={class:"font-mono text-[11px] flex-shrink-0"},Yv={key:2,class:"text-[10px] opacity-60 px-2 truncate flex-1 min-w-0"},Gv={key:3,class:"text-[10px] text-green-600 dark:text-green-400 ml-auto flex-shrink-0"},Zv={key:0,class:"pl-4 space-y-2 text-[10px]"},Xv={key:0},Qv={class:"w-full border-collapse"},ef={class:"py-0.5 pr-2 opacity-65 align-top"},tf={class:"py-0.5 opacity-85 break-all"},rf={key:1},af=["onClick","onMouseenter"],of={class:"whitespace-pre-wrap break-all"},nf={key:1,class:"text-[10px]"},lf=["onClick"],sf={key:0,class:"mt-1 pl-4 whitespace-pre-wrap break-words opacity-80"},uf={key:2,class:"text-[10px] opacity-80 pl-4 pb-2 break-words"},df=me({__name:"AgentMessages",props:{messages:{},threadId:{},selectedMessageId:{},selectedLogId:{},hoveredLogId:{},isEditMode:{type:Boolean},selectedForDelete:{},editedMessages:{}},emits:["messageClick","messageHover","selectionChange","messageEdit"],setup(t,{expose:o,emit:a}){const i=t,l=a;function u(U){const W=i.selectedForDelete?.has(U)??!1;l("selectionChange",U,!W)}function s(U,W){const ne=U.target.innerText;l("messageEdit",W,ne)}function m(U){return i.editedMessages?.has(U)??!1}const h=p(new Map);function x(U,W){W?h.value.set(U,W):h.value.delete(U)}function c(U){const W=i.messages.findIndex(M=>M.log_id===U);if(W<=0)return-1;for(let M=W-1;M>=0;M--){const ne=i.messages[M];if(ne.role==="user")return M;if(ne.role==="assistant"&&ne.log_id)break}return-1}function f(U){for(let W=0;W<i.messages.length;W++){const M=i.messages[W];if(M.log_id===U||M.type==="work"&&M.items&&M.items.some(ce=>ce.log_id===U||ce.response_log_id===U))return W}return-1}function y(U,W){const ne=f(U);if(ne===-1)return!1;const A=h.value.get(ne);if(!A)return!1;const ce=i.messages[ne];let ue=null;if(ce.role==="assistant"&&ce.log_id){const O=c(ce.log_id);ue=O!==-1?h.value.get(O):null}const ke=W.getBoundingClientRect(),be=A.getBoundingClientRect();if(be.top<ke.top){const j=(ue||A).getBoundingClientRect().top-ke.top-10;W.scrollBy({top:j,behavior:"smooth"})}else if(be.bottom>ke.bottom){const O=be.bottom-ke.bottom+10;W.scrollBy({top:O,behavior:"smooth"})}else if(ue){const O=ue.getBoundingClientRect();if(O.top<ke.top){const $=O.top-ke.top-10;W.scrollBy({top:$,behavior:"smooth"})}}return!0}function b(U){for(const W of i.messages){if(W.type!=="work")continue;if(W.items.some(A=>A.log_id===U||A.response_log_id===U))return!0}return!1}o({scrollToLogId:y,hasWorkblockForLogId:b});function v(U){const W=i.messages[U];if(W.log_id)return W.log_id;if(W.role==="user")for(let M=U+1;M<i.messages.length;M++){const ne=i.messages[M];if(ne.log_id)return ne.log_id;if(ne.role==="user")break}return null}function d(U,W){return W?v(U)===W:!1}function k(U){const W=v(U);W&&l("messageHover",W)}function g(U){v(U)&&l("messageHover",null)}function _(U){const W=i.messages[U],M=v(U);M&&l("messageClick",W.id,M)}const L=p(new Set),R=p(new Set),K=p(new Set);function Y(U){L.value.has(U)?L.value.delete(U):L.value.add(U)}function z(U){R.value.has(U)?R.value.delete(U):R.value.add(U)}function P(U){K.value.has(U)?K.value.delete(U):K.value.add(U)}function G(U){if(!U)return{};try{return JSON.parse(U)}catch{return{raw:U}}}function ee(U){if(!U)return null;const W=G(U),M=Object.keys(W);if(M.length===0)return null;const ne=W[M[0]];return typeof ne=="string"?ne:JSON.stringify(ne)}function se(U){return new Date(U/1e3).toLocaleTimeString()}function de(U){const W=Math.round(U/1e6);if(W<1)return"< 1s";if(W<60)return`${W}s`;const M=Math.floor(W/60),ne=W%60;return`${M}m ${ne}s`}function Q(U){if(U.status==="pending")return"...";if(!U.isComplete)return"Working...";let W;return U.request_sent_at&&U.response_completed_at?W=U.response_completed_at-U.request_sent_at:W=U.updated_at-U.created_at,`Worked for ${de(W)}`}function E(U){const W=U.filter(M=>M.type==="content");if(W.length===0){const M=U.filter(ne=>ne.type==="reasoning");return M.length>0?M[M.length-1].content:null}return W[W.length-1].content}function S(U){const M=U.trim().split(`
37
+ `)[0];return M.length>60?M.substring(0,60):M}function V(U){return i.selectedMessageId===U.id?!0:i.selectedLogId?U.items.some(W=>W.log_id===i.selectedLogId||W.response_log_id===i.selectedLogId):!1}function re(U){return!!(i.selectedLogId&&(U.log_id===i.selectedLogId||U.response_log_id===i.selectedLogId))}function F(U){return i.hoveredLogId?U.items.some(W=>W.log_id===i.hoveredLogId||W.response_log_id===i.hoveredLogId):!1}function q(U){return!!(i.hoveredLogId&&(U.log_id===i.hoveredLogId||U.response_log_id===i.hoveredLogId))}function N(U){const W=[];for(const M of U.items)M.log_id&&W.push(M.log_id),M.response_log_id&&W.push(M.response_log_id);return W}function J(U){return U?U.trim():""}return(U,W)=>(r(),n("div",null,[(r(!0),n(ve,null,ye(t.messages,(M,ne)=>(r(),n("div",{key:M.id,ref_for:!0,ref:A=>x(ne,A),class:"flex items-center gap-2 pb-3",onMouseenter:A=>k(ne),onMouseleave:A=>g(ne),onClick:A=>t.isEditMode?u(M.id):_(ne)},[t.isEditMode&&M.role!=="system"?(r(),n("button",{key:0,onClick:Re(A=>u(M.id),["stop"]),class:ae(["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)&&m(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)&&!m(M.id)}])},[t.selectedForDelete?.has(M.id)?(r(),n("svg",Cv,[...W[4]||(W[4]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 12.75l6 6 9-13.5"},null,-1)])])):m(M.id)?(r(),n("svg",Sv,[...W[5]||(W[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)])])):I("",!0)],10,$v)):I("",!0),e("div",{class:ae(["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":v(ne)&&!t.isEditMode}])},[M.type==="text"&&M.role==="system"&&M.content?.includes("Execution stopped")?(r(),n("div",Tv,C(M.content),1)):M.type==="text"?(r(),n("div",{key:1,class:ae(["max-w-[80%] flex flex-col gap-2",{"items-start":M.role==="assistant","items-end":M.role==="user"}])},[e("div",{class:ae(["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"&&d(ne,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"&&v(ne)&&!M.silent&&!d(ne,t.selectedLogId)&&d(ne,t.hoveredLogId)},{"ring-2 ring-green-500 dark:ring-green-400":t.isEditMode&&m(M.id),"border border-dashed border-neutral-400 dark:border-neutral-500":t.isEditMode&&M.role!=="system"&&!m(M.id)}]])},[M.content||t.isEditMode?(r(),n("div",{key:0,class:"whitespace-pre-wrap break-words text-sm outline-none",contenteditable:t.isEditMode&&M.role!=="system",onInput:A=>s(A,M.id),onClick:W[0]||(W[0]=A=>t.isEditMode&&A.stopPropagation())},C(J(M.content)),41,Iv)):M.status==="pending"?(r(),n("div",zv,[...W[6]||(W[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)])])):I("",!0),M.status!=="pending"?(r(),n("div",{key:2,class:ae(["text-[10px] mt-1 opacity-50 flex gap-2",{"justify-start":M.role==="assistant","justify-end":M.role!=="assistant"}])},[M.sideLabel?(r(),n("span",Vv,C(M.sideLabel),1)):I("",!0),e("span",null,C(se(M.created_at)),1),M.silent?(r(),n("span",Mv," silent ")):I("",!0)],2)):I("",!0)],2),M.attachments?.length&&t.threadId?(r(),n("div",Ev,[(r(!0),n(ve,null,ye(M.attachments,A=>(r(),H(wv,{key:A.id,attachment:A,threadId:t.threadId},null,8,["attachment","threadId"]))),128))])):I("",!0)],2)):M.type==="work"?(r(),n("div",{key:2,class:ae(["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&&V(M),"ring-2 ring-accent-400":!t.isEditMode&&!V(M)&&F(M)}]),onClick:A=>!t.isEditMode&&(Y(M.id),N(M)[0]&&l("messageClick",M.id,N(M)[0])),onMouseenter:A=>!t.isEditMode&&N(M)[0]&&l("messageHover",N(M)[0]),onMouseleave:W[3]||(W[3]=A=>!t.isEditMode&&l("messageHover",null))},[L.value.has(M.id)?(r(),n("div",Fv,[e("div",Nv,[w(T(nt),{size:14,class:"flex-shrink-0"}),e("span",qv,C(Q(M)),1),e("span",Hv,C(M.items.length)+" operation"+C(M.items.length!==1?"s":""),1)]),(r(!0),n(ve,null,ye(M.items,A=>(r(),n("div",{key:A.id,class:"mb-1"},[A.type==="tool_call"?(r(),n("div",Wv,[e("div",{onClick:Re(ce=>{z(A.id),A.log_id&&l("messageClick",M.id,A.log_id)},["stop"]),onMouseenter:Re(ce=>A.log_id&&l("messageHover",A.log_id),["stop"]),onMouseleave:W[1]||(W[1]=Re(ce=>l("messageHover",null),["stop"])),class:ae(["flex items-center gap-2 cursor-pointer hover:opacity-70 transition-opacity min-w-0",{"ring-1 ring-accent-500":re(A),"ring-1 ring-accent-400":!re(A)&&q(A)}])},[R.value.has(A.id)?(r(),H(T(nt),{key:1,size:12,class:"flex-shrink-0 opacity-50"})):(r(),H(T(vt),{key:0,size:12,class:"flex-shrink-0 opacity-50"})),e("span",Jv,C(A.tool_name),1),ee(A.tool_arguments)?(r(),n("span",Yv,C(ee(A.tool_arguments)),1)):I("",!0),A.response_status==="success"?(r(),n("span",Gv,"✓")):A.response_status==="failed"?(r(),H(T(Sr),{key:4,size:12,class:"ml-auto text-red-600 dark:text-red-400"})):I("",!0)],42,Kv),R.value.has(A.id)?(r(),n("div",Zv,[A.tool_arguments?(r(),n("div",Xv,[W[7]||(W[7]=e("div",{class:"font-semibold mb-1 opacity-70"},"Arguments:",-1)),e("table",Qv,[e("tbody",null,[(r(!0),n(ve,null,ye(G(A.tool_arguments),(ce,ue)=>(r(),n("tr",{key:ue,class:"border-b border-current border-opacity-10"},[e("td",ef,C(ue),1),e("td",tf,C(typeof ce=="object"?JSON.stringify(ce):ce),1)]))),128))])])])):I("",!0),A.response?(r(),n("div",rf,[W[8]||(W[8]=e("div",{class:"font-semibold mb-1 opacity-70"},"Response:",-1)),e("div",{class:ae(["opacity-80 cursor-pointer hover:opacity-100",{"ring-1 ring-accent-500":t.selectedLogId&&A.response_log_id===t.selectedLogId,"ring-1 ring-accent-400":t.hoveredLogId&&A.response_log_id===t.hoveredLogId&&A.response_log_id!==t.selectedLogId}]),onClick:Re(ce=>A.response_log_id&&l("messageClick",M.id,A.response_log_id),["stop"]),onMouseenter:Re(ce=>A.response_log_id&&l("messageHover",A.response_log_id),["stop"]),onMouseleave:W[2]||(W[2]=Re(ce=>l("messageHover",null),["stop"]))},[e("div",of,C(J(A.response)),1)],42,af)])):I("",!0)])):I("",!0)])):A.type==="reasoning"?(r(),n("div",nf,[e("button",{onClick:Re(ce=>P(A.id),["stop"]),class:"flex items-center gap-1 opacity-70 hover:opacity-100 transition-opacity"},[K.value.has(A.id)?(r(),H(T(nt),{key:1,size:12,class:"flex-shrink-0"})):(r(),H(T(vt),{key:0,size:12,class:"flex-shrink-0"})),W[9]||(W[9]=e("span",{class:"font-semibold"},"Reasoning",-1))],8,lf),K.value.has(A.id)?(r(),n("div",sf,C(J(A.content)),1)):I("",!0)])):A.type==="content"?(r(),n("div",uf,C(J(A.content)),1)):I("",!0)]))),128))])):(r(),n("div",Pv,[e("div",Av,[w(T(vt),{size:14,class:"flex-shrink-0 mt-0.5 opacity-50"}),e("div",jv,[E(M.items)?(r(),n("div",Dv,C(S(E(M.items)))+"... ",1)):(r(),n("div",Ov,C(Q(M)),1))])]),e("div",Rv,[e("span",Uv,C(M.items.length)+" operation"+C(M.items.length!==1?"s":""),1),e("span",Bv,"• "+C(Q(M)),1)])]))],42,Lv)):I("",!0)],2)],40,_v))),128))]))}}),cf=Xe(df,[["__scopeId","data-v-884a0fa7"]]),pf=["onClick"],mf=["value","placeholder","disabled"],vf=me({__name:"TagInput",props:{modelValue:{},placeholder:{},disabled:{type:Boolean}},emits:["update:modelValue"],setup(t,{emit:o}){const a=t,i=o,l=p(""),u=p(null),s=f=>{const y=f.trim().toLowerCase();y&&!a.modelValue.includes(y)&&i("update:modelValue",[...a.modelValue,y]),l.value="",Le(()=>u.value?.focus())},m=f=>{const y=[...a.modelValue];y.splice(f,1),i("update:modelValue",y)},h=f=>{const y=f.target.value;if(y.includes(",")){const b=y.split(",");b.forEach((v,d)=>{d<b.length-1?s(v):l.value=v})}else l.value=y},x=f=>{f.key==="Enter"?(f.preventDefault(),s(l.value)):f.key==="Backspace"&&!l.value&&a.modelValue.length>0&&m(a.modelValue.length-1)},c=()=>{u.value?.focus()};return(f,y)=>(r(),n("div",{class:ae(["flex flex-wrap items-center gap-1.5 min-h-[32px] px-2 py-1.5 bg-white dark:bg-neutral-950 border border-neutral-200 dark:border-neutral-800 rounded-md cursor-text focus-within:ring-2 focus-within:ring-accent-500/20 focus-within:border-accent-500 transition-colors",{"opacity-50 cursor-not-allowed":t.disabled}]),onClick:c},[(r(!0),n(ve,null,ye(t.modelValue,(b,v)=>(r(),n("span",{key:b,class:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium bg-accent-100 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300 rounded"},[Z(C(b)+" ",1),t.disabled?I("",!0):(r(),n("button",{key:0,type:"button",onClick:Re(d=>m(v),["stop"]),class:"hover:text-accent-900 dark:hover:text-accent-100 transition-colors"},[w(T(Yt),{size:12})],8,pf))]))),128)),e("input",{ref_key:"inputRef",ref:u,type:"text",value:l.value,placeholder:t.modelValue.length===0?t.placeholder:"",disabled:t.disabled,class:"flex-1 min-w-[60px] bg-transparent border-none outline-none text-xs text-neutral-900 dark:text-neutral-100 placeholder:text-neutral-400 disabled:cursor-not-allowed",onInput:h,onKeydown:x},null,40,mf)],2))}}),ff={key:0,class:"overflow-hidden bg-neutral-100 dark:bg-neutral-950"},hf={class:"max-h-[500px] overflow-y-auto p-3 space-y-3"},gf={key:0,class:"flex justify-center py-6"},bf={key:1,class:"text-red-600 dark:text-red-400 text-center py-4 text-xs"},xf={class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},yf={class:"p-3 space-y-2"},kf={class:"text-[10px] text-neutral-500 dark:text-neutral-400"},wf=["title"],_f={class:"flex-1 text-[11px] font-mono text-neutral-600 dark:text-neutral-400 truncate"},$f={class:"flex items-center gap-2"},Cf={class:"flex-1 flex items-center gap-1.5"},Sf={key:1,class:"text-xs text-neutral-700 dark:text-neutral-200"},Tf={class:"text-[9px] px-1.5 py-0.5 rounded bg-neutral-100 dark:bg-neutral-800 text-neutral-500 dark:text-neutral-400 uppercase tracking-wide shrink-0"},If={class:"flex items-start gap-2"},zf={class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},Vf=["disabled"],Mf={key:0,class:"overflow-hidden border-t border-neutral-100 dark:border-neutral-800"},Ef={class:"p-3 space-y-3"},Lf={class:"flex gap-4 text-xs"},Pf={class:"ml-1 font-mono font-semibold text-neutral-800 dark:text-neutral-100"},Af={class:"ml-1 font-mono text-neutral-600 dark:text-neutral-400"},jf={key:0,class:"w-full text-[11px]"},Df=["title"],Of={class:"text-right py-1.5 font-mono text-neutral-600 dark:text-neutral-400"},Rf={class:"text-right py-1.5 font-mono text-neutral-600 dark:text-neutral-400"},Uf={class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},Bf={key:0,class:"overflow-hidden border-t border-neutral-100 dark:border-neutral-800"},Ff={class:"p-3 space-y-3"},Nf={class:"flex items-center gap-2"},qf=["disabled"],Hf={class:"pt-2 border-t border-neutral-100 dark:border-neutral-800"},Wf=["disabled"],Kf=me({__name:"MetadataSlidePane",props:{threadId:{},show:{type:Boolean}},emits:["close","threadDeleted","editThread","threadUpdated"],setup(t,{emit:o}){const a=t,i=o,{thread:l,isFetching:u,error:s,refetch:m}=Qt(B(()=>a.threadId)),{agents:h,isFetching:x}=oa(),c=p(!1),f=p(!1),y=p(!1),b=p(!1),v=p(!1),d=p(!1),k=p(!1),g=p(!1),_=p("a"),L=p(!1),R=p(""),K=p([]),Y=p(!1),z=p(null),P=B(()=>h.value?h.value.filter(q=>q.type==="ai_human").map(q=>({value:q.id,label:q.title})):[]),G=B(()=>l.value?.agent.type==="ai_human"),ee=B(()=>l.value?.agent.type==="dual_ai"),se=q=>new Date(q*1e3).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),de=async()=>{l.value&&(await navigator.clipboard.writeText(l.value.id),L.value=!0,setTimeout(()=>{L.value=!1},2e3))},Q=async q=>{if(!(!a.threadId||!q||q===l.value?.agent.id)){y.value=!0;try{const N=await fetch(fe(`/api/threads/${a.threadId}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent_id:q})});if(!N.ok){const J=await N.json();throw new Error(J.error||"Failed to update agent")}await m(),i("threadUpdated")}catch(N){console.error("Error updating agent:",N),R.value=l.value?.agent.id||""}finally{y.value=!1}}},E=async q=>{if(a.threadId){K.value=q,Y.value=!0,b.value=!0;try{const N=await fetch(fe(`/api/threads/${a.threadId}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tags:q})});if(!N.ok){const J=await N.json();throw new Error(J.error||"Failed to update tags")}i("threadUpdated")}catch(N){console.error("Error updating tags:",N),K.value=l.value?.tags||[]}finally{b.value=!1,Y.value=!1}}},S=async()=>{if(v.value){v.value=!1;return}if(a.threadId){k.value=!0,v.value=!0;try{const q=await fetch(fe(`/api/threads/${a.threadId}/cost`));if(!q.ok){const N=await q.json();throw new Error(N.error||"Failed to fetch cost breakdown")}z.value=await q.json()}catch(q){console.error("Error fetching cost breakdown:",q),v.value=!1}finally{k.value=!1}}},V=q=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:6}).format(q),re=async()=>{if(a.threadId){g.value=!0;try{const q=await fetch(fe(`/api/threads/${a.threadId}/continue`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({side:_.value})});if(!q.ok){const N=await q.json();throw new Error(N.error||"Failed to continue execution")}}catch(q){console.error("Error continuing execution:",q)}finally{g.value=!1}}},F=async()=>{if(a.threadId){f.value=!0;try{const q=await fetch(fe(`/api/threads/${a.threadId}`),{method:"DELETE"});if(!q.ok){const N=await q.json();throw new Error(N.error||"Failed to delete thread")}i("threadDeleted",a.threadId)}catch(q){console.error("Error deleting thread:",q)}finally{f.value=!1}}};return ge(()=>l.value,q=>{q&&(R.value=q.agent.id,Y.value||(K.value=q.tags||[]))},{immediate:!0}),ge(()=>a.show,q=>{q||(v.value=!1,d.value=!1,z.value=null)}),ge(()=>a.threadId,()=>{v.value=!1,d.value=!1,z.value=null}),(q,N)=>{const J=Be("FormKit");return r(),H(et,{"enter-active-class":"transition-all duration-300 ease-out","enter-from-class":"max-h-0 opacity-0","enter-to-class":"max-h-[500px] opacity-100","leave-active-class":"transition-all duration-200 ease-in","leave-from-class":"max-h-[500px] opacity-100","leave-to-class":"max-h-0 opacity-0"},{default:D(()=>[t.show&&t.threadId?(r(),n("div",ff,[e("div",hf,[T(u)?(r(),n("div",gf,[w(Ee)])):T(s)?(r(),n("div",bf," Error: "+C(T(s)),1)):T(l)?(r(),n(ve,{key:2},[e("div",xf,[e("div",yf,[e("div",kf,[N[5]||(N[5]=e("span",{class:"font-medium uppercase tracking-wide"},"Created",-1)),N[6]||(N[6]=e("span",{class:"mx-1"},"·",-1)),Z(" "+C(se(T(l).created_at)),1)]),e("div",{class:"flex items-center gap-1 px-2 py-1.5 bg-neutral-50 dark:bg-neutral-950 rounded border border-neutral-200 dark:border-neutral-800 cursor-pointer hover:border-neutral-300 dark:hover:border-neutral-700 transition-colors group",onClick:de,title:L.value?"Copied!":"Click to copy"},[e("code",_f,C(T(l).id),1),e("span",{class:ae(["shrink-0 transition-colors",L.value?"text-green-600 dark:text-green-400":"text-neutral-400 group-hover:text-neutral-600 dark:group-hover:text-neutral-300"])},[L.value?(r(),H(T(Va),{key:0,size:12})):(r(),H(T(Ma),{key:1,size:12}))],2)],8,wf),e("div",$f,[N[7]||(N[7]=e("label",{class:"shrink-0 text-[10px] font-medium text-neutral-500 dark:text-neutral-400 uppercase tracking-wide w-10"},"Agent",-1)),e("div",Cf,[G.value?(r(),H(J,{key:0,type:"selectSearch",modelValue:R.value,"onUpdate:modelValue":N[0]||(N[0]=U=>R.value=U),options:P.value,loading:T(x)||y.value,disabled:y.value,size:"sm",placeholder:"Select...",onInput:Q,"outer-class":"!mb-0 flex-1"},null,8,["modelValue","options","loading","disabled"])):(r(),n("span",Sf,C(T(l).agent.title),1)),e("span",Tf,C(T(l).agent.type.replace("_"," ")),1)])]),e("div",If,[N[8]||(N[8]=e("label",{class:"shrink-0 text-[10px] font-medium text-neutral-500 dark:text-neutral-400 uppercase tracking-wide w-10 pt-2"},"Tags",-1)),w(vf,{"model-value":K.value,"onUpdate:modelValue":E,disabled:b.value,placeholder:"Add tags...",class:"flex-1"},null,8,["model-value","disabled"])])])]),e("div",zf,[e("button",{onClick:S,disabled:k.value,type:"button",class:"w-full flex items-center gap-2 px-3 py-2.5 text-left hover:bg-neutral-50 dark:hover:bg-neutral-800 transition-colors disabled:opacity-50"},[w(T(Ea),{size:14,class:"shrink-0 text-neutral-400"}),N[9]||(N[9]=e("span",{class:"flex-1 text-xs font-medium text-neutral-700 dark:text-neutral-200"},"Usage & Cost",-1)),k.value?(r(),H(Ee,{key:0,size:"xs"})):(r(),H(T(nt),{key:1,size:14,class:ae(["shrink-0 text-neutral-400 transition-transform duration-200",{"-rotate-180":v.value}])},null,8,["class"]))],8,Vf),w(et,{"enter-active-class":"transition-all duration-200 ease-out","enter-from-class":"opacity-0 max-h-0","enter-to-class":"opacity-100 max-h-[250px]","leave-active-class":"transition-all duration-150 ease-in","leave-from-class":"opacity-100 max-h-[250px]","leave-to-class":"opacity-0 max-h-0"},{default:D(()=>[v.value&&z.value?(r(),n("div",Mf,[e("div",Ef,[e("div",Lf,[e("div",null,[N[10]||(N[10]=e("span",{class:"text-neutral-500 dark:text-neutral-400"},"Total:",-1)),e("span",Pf,C(V(z.value.totalCost)),1)]),e("div",null,[N[11]||(N[11]=e("span",{class:"text-neutral-500 dark:text-neutral-400"},"Per msg:",-1)),e("span",Af,C(V(z.value.avgCostPerMessage)),1)])]),z.value.modelBreakdown.length>0?(r(),n("table",jf,[N[12]||(N[12]=e("thead",null,[e("tr",{class:"border-b border-neutral-200 dark:border-neutral-800"},[e("th",{class:"text-left py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px]"},"Model"),e("th",{class:"text-right py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px] w-14"},"Reqs"),e("th",{class:"text-right py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px]"},"Cost")])],-1)),e("tbody",null,[(r(!0),n(ve,null,ye(z.value.modelBreakdown,U=>(r(),n("tr",{key:U.modelName},[e("td",{class:"py-1.5 truncate max-w-[120px] text-neutral-700 dark:text-neutral-300",title:U.modelName},C(U.modelName),9,Df),e("td",Of,C(U.requestCount),1),e("td",Rf,C(V(U.totalCost)),1)]))),128))])])):I("",!0)])])):I("",!0)]),_:1})]),e("div",Uf,[e("button",{onClick:N[1]||(N[1]=U=>d.value=!d.value),type:"button",class:"w-full flex items-center gap-2 px-3 py-2.5 text-left hover:bg-neutral-50 dark:hover:bg-neutral-800 transition-colors"},[w(T(La),{size:14,class:"shrink-0 text-neutral-400"}),N[13]||(N[13]=e("span",{class:"flex-1 text-xs font-medium text-neutral-700 dark:text-neutral-200"},"Developer Tools",-1)),w(T(nt),{size:14,class:ae(["shrink-0 text-neutral-400 transition-transform duration-200",{"-rotate-180":d.value}])},null,8,["class"])]),w(et,{"enter-active-class":"transition-all duration-200 ease-out","enter-from-class":"opacity-0 max-h-0","enter-to-class":"opacity-100 max-h-[150px]","leave-active-class":"transition-all duration-150 ease-in","leave-from-class":"opacity-100 max-h-[150px]","leave-to-class":"opacity-0 max-h-0"},{default:D(()=>[d.value?(r(),n("div",Bf,[e("div",Ff,[e("div",Nf,[ee.value?Ae((r(),n("select",{key:0,"onUpdate:modelValue":N[2]||(N[2]=U=>_.value=U),class:"text-xs px-2 py-1.5 border border-neutral-200 dark:border-neutral-700 rounded bg-white dark:bg-neutral-800 text-neutral-700 dark:text-neutral-300"},[...N[14]||(N[14]=[e("option",{value:"a"},"Side A",-1),e("option",{value:"b"},"Side B",-1)])],512)),[[Mr,_.value]]):I("",!0),e("button",{onClick:re,disabled:g.value,class:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-neutral-800 dark:bg-neutral-200 text-white dark:text-neutral-900 rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"},[w(T(Pa),{size:12}),e("span",null,C(g.value?"Running...":"Continue"),1)],8,qf),N[15]||(N[15]=e("span",{class:"text-[10px] text-neutral-500 dark:text-neutral-400"},"Resume without new message",-1))]),e("div",Hf,[e("button",{onClick:N[3]||(N[3]=U=>c.value=!0),disabled:f.value,class:"flex items-center gap-1.5 text-xs font-medium text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 transition-colors disabled:opacity-50"},[w(T(Aa),{size:12}),e("span",null,C(f.value?"Deleting...":"Delete Thread"),1)],8,Wf)])])])):I("",!0)]),_:1})])],64)):I("",!0)]),w(Xt,{modelValue:c.value,"onUpdate:modelValue":N[4]||(N[4]=U=>c.value=U),title:"Delete Thread?",message:"This will permanently delete all messages, logs, and associated data. This action cannot be undone.","confirm-text":"Delete","cancel-text":"Cancel",onConfirm:F},null,8,["modelValue"])])):I("",!0)]),_:1})}}}),Jf=Xe(Kf,[["__scopeId","data-v-f3c52505"]]),Yf={key:0,class:"overflow-hidden bg-neutral-100 dark:bg-neutral-950"},Gf={class:"max-h-[400px] overflow-y-auto p-3 space-y-3"},Zf={class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},Xf={class:"flex items-center justify-between px-3 py-2 border-b border-neutral-100 dark:border-neutral-800"},Qf={class:"flex items-center gap-2"},eh={class:"text-[10px] text-neutral-400"},th={class:"flex items-center gap-1"},rh={class:"p-2"},ah={key:0,class:"px-2 py-4 text-center text-neutral-400 text-xs"},oh=["onClick"],nh={class:"text-xs text-neutral-700 dark:text-neutral-300 truncate"},lh={class:"text-[10px] text-neutral-400 ml-auto"},sh=["href","onMouseenter"],ih={class:"shrink-0 text-neutral-400"},uh={class:"flex-1 min-w-0"},dh={class:"shrink-0 text-[10px] text-neutral-400 ml-auto"},ch={key:0,class:"text-blue-500"},ph={key:1,class:"text-red-500"},mh={key:2},vh=["href","onMouseenter"],fh={class:"shrink-0 text-neutral-400"},hh={class:"flex-1 min-w-0"},gh={class:"shrink-0 text-[10px] text-neutral-400 ml-auto"},bh={key:0,class:"text-blue-500"},xh={key:1,class:"text-red-500"},yh={key:2},kh=["src","alt"],wh=me({__name:"FilesSlidePane",props:{threadId:{},show:{type:Boolean}},emits:["close"],setup(t,{emit:o}){const a=t;let i=null;try{i=Ur()}catch{}const l=i?.files??p([]),u=i?.addFiles??(()=>{}),s=p(null),m=p(new Set(["/attachments"])),h=p(null),x=p({x:0,y:0});function c(R){if(R===0)return"0 B";const K=1024,Y=["B","KB","MB","GB"],z=Math.floor(Math.log(R)/Math.log(K));return parseFloat((R/Math.pow(K,z)).toFixed(1))+" "+Y[z]}function f(R){const K=R.startsWith("/")?R.slice(1):R;return fe(`/api/threads/${a.threadId}/fs/${K}`)}function y(R,K){return K?Pr:R.startsWith("audio/")?Oa:R.startsWith("video/")?Ra:R.startsWith("text/")?Ua:R.includes("javascript")||R.includes("json")||R.includes("xml")?Ba:Ar}function b(R){const K=R.target;K.files?.length&&(u(K.files),K.value="")}function v(){s.value?.click()}function d(R){m.value.has(R)?m.value.delete(R):m.value.add(R),m.value=new Set(m.value)}function k(R){x.value={x:R.clientX,y:R.clientY}}function g(R){h.value=R}const _=B(()=>{const R=[],K=new Map,Y=[...l.value].sort((z,P)=>z.status==="uploading"&&P.status!=="uploading"?-1:P.status==="uploading"&&z.status!=="uploading"?1:(z.path||z.name).localeCompare(P.path||P.name));for(const z of Y){const P=z.path||`/${z.name}`,G=P.split("/").filter(Boolean);if(G.length===1)R.push({type:"file",name:z.name,path:P,file:z});else{const ee="/"+G.slice(0,-1).join("/"),se=G[G.length-2];if(!K.has(ee)){const de={type:"directory",name:se,path:ee,children:[]};K.set(ee,de),R.push(de)}K.get(ee).children.push({type:"file",name:z.name,path:P,file:z})}}return R}),L=B(()=>l.value.length);return Pe(()=>{document.addEventListener("mousemove",k)}),Ye(()=>{document.removeEventListener("mousemove",k)}),(R,K)=>(r(),H(et,{"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:D(()=>[t.show?(r(),n("div",Yf,[e("div",Gf,[e("div",Zf,[e("div",Xf,[e("div",Qf,[w(T(Nt),{size:14,class:"text-neutral-400"}),K[3]||(K[3]=e("span",{class:"text-xs font-medium text-neutral-700 dark:text-neutral-200"},"Files",-1)),e("span",eh,C(L.value),1)]),e("div",th,[e("input",{ref_key:"fileInput",ref:s,type:"file",multiple:"",class:"hidden",onChange:b},null,544),e("button",{onClick:v,type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-700 rounded transition-colors text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300",title:"Upload files"},[w(T(ja),{size:14})])])]),e("div",rh,[_.value.length===0?(r(),n("div",ah," No files yet ")):I("",!0),(r(!0),n(ve,null,ye(_.value,Y=>(r(),n(ve,{key:Y.path},[Y.type==="directory"?(r(),n(ve,{key:0},[e("button",{onClick:z=>d(Y.path),type:"button",class:"w-full flex items-center gap-1.5 px-2 py-1.5 hover:bg-neutral-50 dark:hover:bg-neutral-700/50 rounded transition-colors text-left"},[w(T(vt),{size:12,class:ae(["shrink-0 text-neutral-400 transition-transform",{"rotate-90":m.value.has(Y.path)}])},null,8,["class"]),(r(),H(Ue(m.value.has(Y.path)?T(Da):T(Nt)),{size:14,class:"shrink-0",style:{color:"var(--accent-500)"}})),e("span",nh,C(Y.name),1),e("span",lh,C(Y.children?.length),1)],8,oh),m.value.has(Y.path)?(r(!0),n(ve,{key:0},ye(Y.children,z=>(r(),n("a",{key:z.path,href:z.path?f(z.path):void 0,target:"_blank",rel:"noopener noreferrer",class:ae(["flex items-center gap-2 pl-7 pr-2 py-1 hover:bg-neutral-50 dark:hover:bg-neutral-700/50 rounded transition-colors cursor-pointer",{"pointer-events-none":z.file?.status==="uploading"}]),onMouseenter:P=>z.file?.isImage?g(z.path):null,onMouseleave:K[0]||(K[0]=P=>g(null))},[e("div",ih,[z.file?.status==="uploading"?(r(),H(T(ar),{key:0,size:12,class:"animate-spin"})):(r(),H(Ue(y(z.file?.mimeType||"",z.file?.isImage||!1)),{key:1,size:12}))]),e("div",uh,[e("div",{class:ae(["text-[11px] text-neutral-600 dark:text-neutral-400 truncate",{"opacity-50":z.file?.status==="uploading"}])},C(z.name),3)]),e("div",dh,[z.file?.status==="uploading"?(r(),n("span",ch,"...")):z.file?.status==="error"?(r(),n("span",ph,"err")):(r(),n("span",mh,C(c(z.file?.size||0)),1))])],42,sh))),128)):I("",!0)],64)):(r(),n("a",{key:1,href:Y.path?f(Y.path):void 0,target:"_blank",rel:"noopener noreferrer",class:ae(["flex items-center gap-2 px-2 py-1.5 hover:bg-neutral-50 dark:hover:bg-neutral-700/50 rounded transition-colors cursor-pointer",{"pointer-events-none":Y.file?.status==="uploading"}]),onMouseenter:z=>Y.file?.isImage?g(Y.path):null,onMouseleave:K[1]||(K[1]=z=>g(null))},[e("div",fh,[Y.file?.status==="uploading"?(r(),H(T(ar),{key:0,size:14,class:"animate-spin"})):(r(),H(Ue(y(Y.file?.mimeType||"",Y.file?.isImage||!1)),{key:1,size:14}))]),e("div",hh,[e("div",{class:ae(["text-xs text-neutral-600 dark:text-neutral-400 truncate",{"opacity-50":Y.file?.status==="uploading"}])},C(Y.name),3)]),e("div",gh,[Y.file?.status==="uploading"?(r(),n("span",bh,"...")):Y.file?.status==="error"?(r(),n("span",xh,"err")):(r(),n("span",yh,C(c(Y.file?.size||0)),1))])],42,vh))],64))),128))])])]),(r(),H(kt,{to:"body"},[h.value?(r(),n("div",{key:0,class:"fixed z-50 bg-white dark:bg-neutral-800 border border-neutral-200 dark:border-neutral-700 rounded-lg shadow-lg p-1 pointer-events-none",style:st({left:`${x.value.x+16}px`,top:`${x.value.y-80}px`})},[e("img",{src:f(h.value),alt:h.value,class:"max-w-[200px] max-h-[150px] rounded object-contain",onError:K[2]||(K[2]=Y=>Y.target.style.display="none")},null,40,kh)],4)):I("",!0)]))])):I("",!0)]),_:1}))}}),_h=["accept"],$h=["disabled"],Ch=me({__name:"FileUpload",props:{isProcessing:{type:Boolean},accept:{}},emits:["filesSelected"],setup(t,{expose:o,emit:a}){const i=t,l=a,u=p(null),s=B(()=>i.accept||"image/*,.pdf,.txt,.md,.json,.csv");function m(){u.value?.click()}function h(c){const f=c.target;f.files&&f.files.length>0&&(l("filesSelected",f.files),f.value="")}function x(c){const f=c.clipboardData?.items;if(!f)return;const y=[];for(let b=0;b<f.length;b++){const v=f[b];if(v.kind==="file"){const d=v.getAsFile();d&&y.push(d)}}if(y.length>0){const b=new DataTransfer;y.forEach(v=>b.items.add(v)),l("filesSelected",b.files)}}return o({handlePaste:x}),(c,f)=>(r(),n(ve,null,[e("input",{ref_key:"fileInputRef",ref:u,type:"file",accept:s.value,multiple:"",class:"hidden",onChange:h},null,40,_h),e("button",{type:"button",onClick:m,class:ae(["p-1.5 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded-lg transition-colors text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300",{"opacity-50 cursor-not-allowed":t.isProcessing}]),disabled:t.isProcessing,title:"Attach files"},[w(T(Fa),{size:18})],10,$h)],64))}}),Sh={class:"flex flex-col h-full"},Th={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},Ih={class:"flex items-center justify-between"},zh={class:"flex items-center gap-2"},Vh={class:"flex items-center gap-2"},Mh={class:"flex-1 flex flex-col overflow-hidden relative"},Eh={key:0,class:"text-neutral-500 dark:text-neutral-400 text-center py-8"},Lh={key:1,class:"flex justify-center py-2"},Ph={key:2,class:"flex justify-center py-8"},Ah={key:3,class:"text-red-600 dark:text-red-400 text-center py-8"},jh={key:4,class:"text-neutral-500 dark:text-neutral-400 text-center py-8"},Dh={key:1,class:"p-3 bg-white dark:bg-neutral-900 border-t border-neutral-300 dark:border-neutral-700"},Oh={class:"flex items-center justify-end gap-2"},Rh=["disabled"],Uh={key:2,class:"p-3 bg-white dark:bg-neutral-900 border-t border-neutral-300 dark:border-neutral-700"},Bh={key:0,class:"mb-2 flex flex-wrap gap-2"},Fh={key:0,class:"w-16 h-16 rounded-lg overflow-hidden border border-neutral-200 dark:border-neutral-700 bg-neutral-100 dark:bg-neutral-800"},Nh=["src","alt"],qh={key:1,class:"w-full h-full flex items-center justify-center"},Hh={key:1,class:"h-16 px-3 rounded-lg border border-neutral-200 dark:border-neutral-700 bg-neutral-100 dark:bg-neutral-800 flex items-center gap-2"},Wh=["title"],Kh=["onClick"],Jh={class:"flex items-start gap-2"},Yh={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"},Gh=["disabled"],Zh=["disabled"],Xh={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"},Qh={key:1,class:"w-4 h-4"},vr=me({__name:"MessagesPane",props:{threadId:{},selectedMessageId:{},selectedLogId:{},hoveredLogId:{}},emits:["collapse","messageClick","messageHover","threadDeleted","editThread","logsDeleted","threadUpdated"],setup(t,{expose:o,emit:a}){const i=t,l=a,u=p(!1),s=()=>{u.value||(m.value=!1),u.value=!u.value},m=p(!1),h=()=>{m.value||(u.value=!1),m.value=!m.value},x=p(!1),c=p(new Set),f=p(new Map),y=()=>{x.value=!x.value,x.value||(c.value=new Set,f.value=new Map)},b=($e,xe)=>{const Me=new Set(c.value);xe?Me.add($e):Me.delete($e),c.value=Me},v=($e,xe)=>{const Me=new Map(f.value);Me.set($e,xe),f.value=Me},d=()=>{x.value=!1,c.value=new Set,f.value=new Map},k=B(()=>c.value.size),g=B(()=>{let $e=0;for(const[xe]of f.value)c.value.has(xe)||$e++;return $e}),_=B(()=>{const $e=k.value,xe=g.value;return $e>0&&xe>0?`Delete (${$e}), Update (${xe})`:$e>0?`Delete (${$e})`:xe>0?`Save changes (${xe})`:"Delete"}),L=B(()=>k.value>0||g.value>0),R=async()=>{if(!i.threadId||!L.value)return;const $e=[];for(const xe of c.value){const Me=K.value.find(We=>We.id===xe);Me&&"log_id"in Me&&Me.log_id&&$e.push(Me.log_id)}try{for(const[xe,Me]of f.value)c.value.has(xe)||await V(xe,Me);for(const xe of c.value)await S(xe);$e.length>0&&l("logsDeleted",$e)}catch(xe){console.error("Error applying changes:",xe)}finally{d()}},{messages:K,threadInfo:Y,isFetching:z,isLoadingMore:P,error:G,wsConnected:ee,wsError:se,isExecuting:de,hasMore:Q,loadMoreMessages:E,deleteMessageById:S,updateMessageContent:V,stopThread:re,sendMessage:F,attachments:q,addAttachment:N,removeAttachment:J}=fv(B(()=>i.threadId),{}),{thread:U}=Qt(B(()=>i.threadId)),W=B(()=>q.value.length>0),M=B(()=>!1),ne=p(null),A=$e=>{N($e)},ce=p(null),ue=p(null);o({scrollToLogId:$e=>ue.value&&ce.value?ue.value.scrollToLogId($e,ce.value):!1,hasWorkblockForLogId:$e=>ue.value?ue.value.hasWorkblockForLogId($e):!1}),typeof window<"u"&&(window.__testLoadMoreMessages=E);const O=p(""),$=p(null),j=p("B"),he=p(!1),X=p(!1),pe=async()=>{await Le(),ce.value&&(ce.value.scrollTop=ce.value.scrollHeight)},le=async $e=>{$e.target.scrollTop<100&&Q.value&&!P.value&&!X.value&&(X.value=!0,await E(),X.value=!1)};ge(()=>K.value.length,async()=>{!P.value&&!X.value&&await pe()}),ge(()=>i.threadId,async $e=>{$e&&await pe()}),ge(z,async($e,xe)=>{xe&&!$e&&await pe()});const we=B(()=>{const $e=Y.value?.agent||U.value?.agent;if(!$e)return"ai A";const xe=$e.type;return j.value==="A"&&$e.side_a_label?$e.side_a_label:j.value==="B"&&$e.side_b_label?$e.side_b_label:xe==="ai_human"?j.value==="A"?"ai":"human":j.value==="A"?"ai A":"ai B"}),oe=()=>{j.value=j.value==="A"?"B":"A"},ie=async()=>{const $e=O.value.trim().length>0,xe=W.value;if(!$e&&!xe||!i.threadId||he.value||!F)return;const Me=O.value,We=j.value==="A"?"assistant":"user";O.value="",$.value&&($.value.style.height="auto",$.value.style.height="24px"),he.value=!0;try{await F({role:We,content:Me}),await pe()}catch($t){console.error("Error sending message:",$t)}finally{he.value=!1,await Le(),$.value&&$.value.focus()}},Ve=$e=>{$e.key==="Enter"&&!$e.shiftKey&&($e.preventDefault(),ie())},_e=async()=>{if(i.threadId)try{await re()}catch($e){console.error("Error stopping thread:",$e)}};return($e,xe)=>(r(),n("div",Sh,[e("div",Th,[e("div",Ih,[e("div",zh,[w(T(jr),{size:18,class:"shrink-0"}),xe[11]||(xe[11]=e("h2",{class:"text-base font-bold"},"Messages",-1)),t.threadId?(r(),H(er,{key:0,connected:T(ee),error:T(se)},null,8,["connected","error"])):I("",!0)]),e("div",Vh,[t.threadId?(r(),n("button",{key:0,onClick:h,type:"button",class:ae(["p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",[m.value?"text-accent-600 dark:text-accent-400":""]]),title:"Toggle files"},[w(T(Nt),{size:20})],2)):I("",!0),t.threadId?(r(),n("button",{key:1,onClick:s,type:"button",class:ae(["p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",[u.value?"text-accent-600 dark:text-accent-400":""]]),title:"Toggle thread info"},[w(T(Cr),{size:20})],2)):I("",!0),t.threadId&&T(K).length>0?(r(),n("button",{key:2,onClick:y,type:"button",class:ae(["p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",{"bg-neutral-200 dark:bg-neutral-800":x.value}]),title:"Edit messages"},[w(T(Na),{size:20})],2)):I("",!0),e("button",{onClick:xe[0]||(xe[0]=Me=>l("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[w(T(Lr),{size:20})])])])]),e("div",Mh,[w(Jf,{"thread-id":t.threadId,show:u.value,onClose:xe[1]||(xe[1]=Me=>u.value=!1),onThreadDeleted:xe[2]||(xe[2]=Me=>l("threadDeleted",Me)),onEditThread:xe[3]||(xe[3]=Me=>l("editThread")),onThreadUpdated:xe[4]||(xe[4]=Me=>l("threadUpdated"))},null,8,["thread-id","show"]),t.threadId?(r(),H(wh,{key:0,"thread-id":t.threadId,show:m.value,onClose:xe[5]||(xe[5]=Me=>m.value=!1)},null,8,["thread-id","show"])):I("",!0),e("div",{ref_key:"messagesContainer",ref:ce,class:"flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-4",onScroll:le},[t.threadId?I("",!0):(r(),n("div",Eh," Select a thread to view messages ")),T(P)?(r(),n("div",Lh,[w(Ee,{size:"sm"}),xe[12]||(xe[12]=e("span",{class:"ml-2 text-xs text-neutral-500"},"Loading older messages...",-1))])):T(z)?(r(),n("div",Ph,[w(Ee)])):T(G)?(r(),n("div",Ah," Error loading messages: "+C(T(G)),1)):t.threadId&&T(K).length===0?(r(),n("div",jh," No messages yet ")):(r(),H(cf,{key:5,ref_key:"agentMessagesRef",ref:ue,messages:T(K),threadId:t.threadId,selectedMessageId:t.selectedMessageId,selectedLogId:t.selectedLogId,hoveredLogId:t.hoveredLogId,isEditMode:x.value,selectedForDelete:c.value,editedMessages:f.value,onMessageClick:xe[6]||(xe[6]=(Me,We)=>l("messageClick",Me,We)),onMessageHover:xe[7]||(xe[7]=Me=>l("messageHover",Me)),onSelectionChange:b,onMessageEdit:v},null,8,["messages","threadId","selectedMessageId","selectedLogId","hoveredLogId","isEditMode","selectedForDelete","editedMessages"]))],544),t.threadId&&x.value?(r(),n("div",Dh,[e("div",Oh,[e("button",{onClick:d,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:R,disabled:!L.value,class:ae(["px-4 py-2 rounded-lg font-medium text-sm transition-colors",{"bg-red-600 text-white hover:bg-red-700":L.value&&k.value>0,"bg-black text-white hover:bg-neutral-800 dark:bg-white dark:text-black dark:hover:bg-neutral-200":L.value&&k.value===0,"bg-neutral-200 text-neutral-400 dark:bg-neutral-700 dark:text-neutral-500 cursor-not-allowed":!L.value}])},C(_.value),11,Rh)])])):t.threadId?(r(),n("div",Uh,[T(q).length>0?(r(),n("div",Bh,[(r(!0),n(ve,null,ye(T(q),Me=>(r(),n("div",{key:Me.id,class:"relative group"},[Me.isImage?(r(),n("div",Fh,[Me.previewUrl?(r(),n("img",{key:0,src:Me.previewUrl,alt:Me.name,class:"w-full h-full object-cover"},null,8,Nh)):(r(),n("div",qh,[...xe[13]||(xe[13]=[e("div",{class:"w-4 h-4 border-2 border-neutral-300 border-t-neutral-600 rounded-full animate-spin"},null,-1)])]))])):(r(),n("div",Hh,[e("span",{class:"text-xs text-neutral-600 dark:text-neutral-300 max-w-[80px] truncate",title:Me.name},C(Me.name),9,Wh)])),e("button",{onClick:Re(We=>T(J)(Me.id),["stop"]),class:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-neutral-600 dark:bg-neutral-500 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-500"},[...xe[14]||(xe[14]=[e("span",{class:"text-[10px] font-bold leading-none"},"x",-1)])],8,Kh)]))),128))])):I("",!0),e("div",Jh,[e("button",{onClick:oe,class:ae(["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":j.value==="A","bg-neutral-300 text-black dark:bg-neutral-600 dark:text-white":j.value==="B"}]),title:"Toggle between sides"},C(we.value),3),e("div",Yh,[w(Ch,{ref_key:"fileUploadRef",ref:ne,"is-processing":!1,onFilesSelected:A},null,512),Ae(e("textarea",{ref_key:"messageTextarea",ref:$,"onUpdate:modelValue":xe[8]||(xe[8]=Me=>O.value=Me),onKeydown:Ve,onPaste:xe[9]||(xe[9]=Me=>ne.value?.handlePaste(Me)),disabled:he.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:xe[10]||(xe[10]=Me=>{const We=Me.target;We.style.height="auto",We.style.height=Math.min(We.scrollHeight,120)+"px"})},null,40,Gh),[[Qe,O.value]]),T(de)?(r(),n("button",{key:1,id:"stop-thread-button",onClick:_e,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"},[...xe[16]||(xe[16]=[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)])])):(r(),n("button",{key:0,id:"send-message-button",onClick:ie,disabled:!O.value.trim()&&!W.value||he.value||M.value,class:ae(["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":(O.value.trim()||W.value)&&!he.value&&!M.value,"bg-neutral-200 text-neutral-400 dark:bg-neutral-700 dark:text-neutral-600":!O.value.trim()&&!W.value||he.value||M.value}]),title:"Send message (Enter)"},[he.value?(r(),n("div",Qh,[w(Ee)])):(r(),n("svg",Xh,[...xe[15]||(xe[15]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 10.5 12 3m0 0 7.5 7.5M12 3v18"},null,-1)])]))],10,Zh))])])])):I("",!0)])]))}});function eg(t,o){const{limit:a=100,offset:i=0,order:l="desc",autoFetch:u=!0,enableWebSocket:s=!1}=o||{};B(()=>!!(typeof t=="string"?t:t?.value));const m=B(()=>{const J=typeof t=="string"?t:t?.value;if(!J)return fe("/api/threads/placeholder/logs");const U=new URLSearchParams,W=typeof a=="number"?a:a.value,M=typeof i=="number"?i:i.value,ne=typeof l=="string"?l:l.value;return U.append("limit",W.toString()),U.append("offset",M.toString()),U.append("order",ne),fe(`/api/threads/${J}/logs?${U.toString()}`)}),{data:h,error:x,isFetching:c,isFinished:f,execute:y,abort:b}=Ne(m,{immediate:!1}).get().json();ge([m,()=>u],([J,U])=>{J&&!J.includes("placeholder")&&U&&y()},{immediate:!0});const v=B(()=>!x.value||x.value.toString().includes("aborted")||x.value.toString().includes("abort")?null:x.value),d=B(()=>h.value?.logs||[]),k=B(()=>h.value?.total||0),g=B(()=>h.value?.hasMore||!1),_=p(null),L=p(!1),R=p(null),K=p([]),Y=new Map;let z=0,P=null,G=null,ee=!0,se=null;const de=3e4,Q=3e4,E=()=>{P&&(clearTimeout(P),P=null),G&&(clearInterval(G),G=null)},S=()=>{G&&clearInterval(G),G=setInterval(()=>{_.value&&_.value.readyState===WebSocket.OPEN&&_.value.send("ping")},Q)},V=()=>{if(!ee||!s)return;const J=Math.min(1e3*Math.pow(2,z),de);z++,console.log(`[Logs WebSocket] Scheduling reconnect in ${J}ms (attempt ${z})`),P=setTimeout(()=>{ee&&re()},J)},re=()=>{const J=typeof t=="string"?t:t?.value;if(!J||!s)return;_.value&&(se=null,_.value.close()),z===0&&(K.value=[]);const U=window.location.protocol==="https:"?"wss:":"ws:",W=window.location.host;let M=`${U}//${W}${fe(`/api/threads/${J}/logs`)}`;const ne=localStorage.getItem("auth_token");ne&&(M+=`?token=${encodeURIComponent(ne)}`);try{const A=new WebSocket(M);_.value=A,se=A,A.onopen=()=>{se===A&&(L.value=!0,R.value=null,z=0,S(),console.log("[Logs WebSocket] Connected"))},A.onmessage=ce=>{if(se===A&&ce.data!=="pong")try{const ue=JSON.parse(ce.data);if(ue.type==="log_data"){const ke=K.value.findIndex(O=>O.id===ue.log_id),be=d.value.find(O=>O.id===ue.log_id);if(ke>=0){K.value[ke]={...K.value[ke],...ue.data};const O=Y.get(ue.log_id);O&&(K.value[ke].queued_tools=O,Y.delete(ue.log_id))}else if(be){const O={...be,...ue.data},$=Y.get(ue.log_id);$&&(O.queued_tools=$,Y.delete(ue.log_id)),K.value.push(O)}else{const O={id:ue.log_id,...ue.data},$=Y.get(ue.log_id);$&&(O.queued_tools=$,Y.delete(ue.log_id)),K.value.push(O)}}else if(ue.type==="log_queued_tools"){const ke=K.value.findIndex(O=>O.id===ue.log_id),be=d.value.find(O=>O.id===ue.log_id);ke>=0?K.value[ke]={...K.value[ke],queued_tools:ue.queued_tools}:be?K.value.push({...be,queued_tools:ue.queued_tools}):Y.set(ue.log_id,ue.queued_tools)}}catch(ue){console.error("[Logs WebSocket] Failed to parse message:",ue)}},A.onerror=ce=>{se===A&&(R.value="WebSocket connection error",console.error("[Logs WebSocket] Error:",ce))},A.onclose=()=>{se===A&&(L.value=!1,E(),console.log("[Logs WebSocket] Disconnected"),V())}}catch(A){R.value=A.message||"Failed to create WebSocket",console.error("[Logs WebSocket] Creation error:",A),V()}},F=()=>{ee=!1,E(),se=null,_.value&&(_.value.close(),_.value=null),L.value=!1,z=0,K.value=[],Y.clear()},q=()=>{ee=!0,z=0,re()};return Ye(()=>{F()}),{logs:B(()=>{if(!s)return d.value;const J=new Map;d.value.forEach(M=>J.set(M.id,M)),K.value.forEach(M=>J.set(M.id,M));const U=typeof l=="string"?l:l.value;return Array.from(J.values()).sort((M,ne)=>U==="desc"?ne.created_at-M.created_at:M.created_at-ne.created_at)}),total:k,hasMore:g,error:v,isFetching:c,isFinished:f,refetch:y,abort:b,wsConnected:L,wsError:R,connectWebSocket:q,disconnectWebSocket:F}}function tg(t,o){const a=B(()=>{const m=t.value,h=o.value;return!m||!h?null:fe(`/api/threads/${m}/logs/${h}`)}),{data:i,error:l,isFetching:u,execute:s}=Ne(a,{immediate:!1}).get().json();return ge([t,o],([m,h])=>{m&&h&&s()},{immediate:!0}),{logDetails:i,error:l,isFetching:u,refetch:s}}const rg=["disabled","title"],ag={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"},og={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"},ng={key:3},na=me({__name:"CopyButton",props:{content:{},variant:{},size:{},disabled:{type:Boolean}},setup(t){const o=t,a=p(!1),i=p(!1),l=async()=>{a.value=!0;try{await navigator.clipboard.writeText(o.content),i.value=!0,setTimeout(()=>{i.value=!1},2e3)}catch(m){console.error("Failed to copy:",m),alert(`Failed to copy: ${m instanceof Error?m.message:"Unknown error"}`)}finally{a.value=!1}},u={xs:"p-1 text-xs",sm:"px-2 py-1 text-xs"},s={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(m,h)=>(r(),n("button",{onClick:l,disabled:a.value||t.disabled,class:ae([u[t.size||"sm"],s[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":i.value?"Copied!":"Copy to clipboard"},[a.value?(r(),H(Ee,{key:0,size:"xs"})):t.variant==="ghost"&&!i.value?(r(),n("svg",ag,[...h[0]||(h[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"&&i.value?(r(),n("svg",og,[...h[1]||(h[1]=[e("polyline",{points:"20 6 9 17 4 12"},null,-1)])])):(r(),n("span",ng,C(i.value?"Copied!":"Copy"),1))],10,rg))}}),Ut="__shiki_highlighter__";let St=null;async function lg(){return typeof window<"u"&&window[Ut]?window[Ut]:St||(St=ao({themes:["min-light","github-dark-high-contrast"],langs:["json","markdown"]}).then(t=>(typeof window<"u"&&(window[Ut]=t),t)),St)}const sg={class:"code-block"},ig={key:0,class:"text-xs text-neutral-500 p-2"},ug=["innerHTML"],Bt=me({__name:"CodeBlock",props:{code:{},language:{}},setup(t){const o=t,a=p(""),i=p(!0),l=async()=>{const u=o.code??"";if(!u){a.value='<pre class="shiki"><code></code></pre>',i.value=!1;return}try{const s=await lg();if(o.language==="json"||o.language==="markdown")a.value=s.codeToHtml(u,{lang:o.language,themes:{light:"min-light",dark:"github-dark-high-contrast"}});else{const m=u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");a.value=`<pre class="shiki shiki-text"><code>${m}</code></pre>`}}catch{const m=u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");a.value=`<pre class="shiki"><code>${m}</code></pre>`}finally{i.value=!1}};return Pe(()=>{l()}),ge(()=>o.code,()=>{l()}),(u,s)=>(r(),n("div",sg,[i.value?(r(),n("div",ig,"Loading...")):(r(),n("div",{key:1,innerHTML:a.value,class:"code-content"},null,8,ug))]))}}),dg={class:"json-viewer relative bg-white dark:bg-neutral-900"},cg={key:0,class:"absolute top-[5px] right-[5px] z-10"},pg=["innerHTML"],mg=["src","alt"],vg=me({__name:"JsonViewer",props:{json:{},threadId:{},showCopyButton:{type:Boolean}},setup(t){const o=t,a=p(null),i=p(null),l=y=>[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp"].some(v=>y.toLowerCase().endsWith(v)),u=y=>o.threadId?fe(`/api/threads/${o.threadId}/fs${y}`):null,s=B(()=>{if(!o.json)return"";if(typeof o.json=="string")try{return JSON.stringify(JSON.parse(o.json),null,2)}catch{return o.json}return JSON.stringify(o.json,null,2)}),m=y=>y.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),h=(y,b=0)=>{const v=" ".repeat(b),d=k=>`<span class="json-punct">${k}</span>`;if(y===null)return'<span class="json-null">null</span>';if(typeof y=="boolean")return`<span class="json-boolean">${y}</span>`;if(typeof y=="number")return`<span class="json-number">${y}</span>`;if(typeof y=="string"){const k=m(y);return o.threadId&&l(y)&&y.startsWith("/attachments/")?`${d('"')}<span class="json-image-path" data-path="${m(y)}">${k}</span>${d('"')}`:`${d('"')}<span class="json-string">${k}</span>${d('"')}`}if(Array.isArray(y)){if(y.length===0)return`${d("[")}${d("]")}`;const k=y.map((g,_)=>{const L=_<y.length-1?d(","):"";return`${v} ${h(g,b+1)}${L}`});return`${d("[")}
38
+ ${k.join(`
4
39
  `)}
5
- ${b}${m("]")}`}if(typeof h=="object"){const y=Object.entries(h);if(y.length===0)return`${m("{")}${m("}")}`;const x=y.map(([k,D],q)=>{const B=q<y.length-1?m(","):"",F=`${m('"')}<span class="json-key">${c(k)}</span>${m('"')}`;return`${b} ${F}${m(":")} ${f(D,_+1)}${B}`});return`${m("{")}
6
- ${x.join(`
40
+ ${v}${d("]")}`}if(typeof y=="object"){const k=Object.entries(y);if(k.length===0)return`${d("{")}${d("}")}`;const g=k.map(([_,L],R)=>{const K=R<k.length-1?d(","):"",Y=`${d('"')}<span class="json-key">${m(_)}</span>${d('"')}`;return`${v} ${Y}${d(":")} ${h(L,b+1)}${K}`});return`${d("{")}
41
+ ${g.join(`
7
42
  `)}
8
- ${b}${m("}")}`}return String(h)},g=J(()=>{if(!n.json)return'<span class="json-null">null</span>';let h;if(typeof n.json=="string")try{h=JSON.parse(n.json)}catch{return c(n.json)}else h=n.json;return f(h)}),d=h=>{const _=h.target;if(_.classList.contains("json-image-path")){const b=_.dataset.path;if(b&&n.threadId){s.value=b;const m=_.getBoundingClientRect();i.value={x:m.left,y:m.top}}}},p=h=>{h.target.classList.contains("json-image-path")&&(s.value=null,i.value=null)};return(h,_)=>(a(),o("div",Oc,[t.showCopyButton?(a(),o("div",Uc,[A(wa,{content:r.value,variant:"ghost",size:"xs"},null,8,["content"])])):V("",!0),e("pre",{class:"text-xs font-mono p-3 overflow-x-auto",onMouseover:d,onMouseout:p,innerHTML:g.value},null,40,Rc),(a(),ne(it,{to:"body"},[s.value&&i.value&&t.threadId?(a(),o("div",{key:0,class:"fixed z-50 bg-white dark:bg-neutral-800 border border-neutral-300 dark:border-neutral-600 rounded-lg shadow-lg p-1 pointer-events-none",style:ot({left:`${i.value.x}px`,top:`${i.value.y-160}px`})},[e("img",{src:u(s.value),alt:s.value,class:"max-w-[200px] max-h-[150px] rounded object-contain",onError:_[0]||(_[0]=b=>b.target.style.display="none")},null,40,Nc)],4)):V("",!0)]))]))}}),vt=tt(Fc,[["__scopeId","data-v-fc06e7bc"]]),Bc={class:"text-xs font-semibold"},qc={key:0,class:"font-normal text-neutral-500 dark:text-neutral-400"},zc={class:"flex items-center gap-2"},Hc={class:"text-neutral-500 text-xs"},pt=me({__name:"CollapsibleSection",props:{title:{},subtitle:{},sectionId:{},expanded:{type:Boolean},scrollContainer:{}},emits:["toggle"],setup(t,{expose:n,emit:s}){const i=t,l=s,u=v(null),r=v(!1),c=()=>{Te(()=>{if(!u.value||!i.scrollContainer){r.value=!1;return}const d=i.scrollContainer.clientHeight;r.value=u.value.scrollHeight>d*2})};fe(()=>i.expanded,d=>{d?c():r.value=!1});const f=()=>{if(u.value&&i.scrollContainer){const h=u.value.offsetTop-88;i.scrollContainer.scrollTo({top:Math.max(0,h),behavior:"smooth"})}},g=()=>{if(u.value&&i.scrollContainer){const d=u.value.offsetTop+u.value.offsetHeight,p=i.scrollContainer.clientHeight,h=d-p+10;i.scrollContainer.scrollTo({top:Math.max(0,h),behavior:"smooth"})}};return n({checkHeight:c,contentRef:u}),(d,p)=>(a(),o("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:p[0]||(p[0]=h=>l("toggle"))},[e("span",Bc,[Ce(S(t.title)+" ",1),t.subtitle?(a(),o("span",qc,"("+S(t.subtitle)+")",1)):V("",!0)]),e("div",zc,[r.value&&t.expanded?(a(),o(ve,{key:0},[e("button",{onClick:Ee(f,["stop"]),class:"text-[10px] text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300"},"↑ Top"),e("button",{onClick:Ee(g,["stop"]),class:"text-[10px] text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300"},"↓ Bottom")],64)):V("",!0),e("span",Hc,S(t.expanded?"▼":"▶"),1)])]),Ie(e("div",{ref_key:"contentRef",ref:u,class:"border-x border-b border-neutral-300 dark:border-neutral-700 rounded-b"},[et(d.$slots,"default")],512),[[Ke,t.expanded]])]))}}),Wc={class:"flex items-center justify-between mb-3"},Jc={class:"flex items-center gap-2"},Kc={class:"flex items-center gap-1"},Gc=["disabled"],Xc=["disabled"],Yc={class:"text-lg font-bold"},Qc={class:"flex items-center gap-2"},Zc=["disabled","title"],e0={key:1},t0={class:"@container border-b border-neutral-300 dark:border-neutral-700 pb-3"},a0={class:"hidden @[600px]:block"},o0={class:"w-full text-xs"},l0={class:"py-1 font-mono"},s0={class:"py-1 font-mono"},n0={key:1},r0={class:"py-1 font-mono"},i0={key:1},d0={class:"py-1 font-mono"},u0={key:1},c0={class:"py-1 font-mono"},p0={key:1},m0={class:"py-1 font-mono text-xs"},v0={class:"@[600px]:hidden space-y-2"},f0={class:"w-full text-xs"},h0={class:"py-1 font-mono"},g0={class:"py-1 font-mono"},b0={key:1},x0={class:"w-full text-xs"},y0={class:"py-1 font-mono"},k0={key:1},w0={class:"py-1 font-mono"},_0={key:1},$0={class:"py-1 font-mono"},C0={key:1},T0={class:"py-1 font-mono text-xs"},S0={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"},V0={class:"flex gap-4"},M0={key:0,class:"text-red-600 dark:text-red-400"},I0={class:"space-y-3"},E0={class:"space-y-2"},L0={class:"flex items-center gap-1 pb-2 mb-2 border-b border-neutral-200 dark:border-neutral-700"},A0=["onClick"],P0={key:1,class:"text-xs text-red-600 dark:text-red-400 ml-2"},D0=["onClick"],j0={class:"font-mono"},O0={class:"text-neutral-500"},U0={class:"px-2 py-2 bg-white dark:bg-neutral-950 border-t border-neutral-200 dark:border-neutral-800"},R0={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mb-2"},N0={class:"relative bg-white dark:bg-neutral-900"},F0={class:"absolute top-[5px] right-[5px]"},B0={key:0,class:"mb-4"},q0={class:"text-xs font-semibold text-red-600 dark:text-red-400 mb-1"},z0={class:"space-y-2"},H0={class:"px-2 py-1 bg-red-100 dark:bg-red-900/30 text-xs font-medium text-red-800 dark:text-red-200"},W0={class:"text-xs bg-red-50 dark:bg-red-950 p-2 overflow-x-auto text-red-900 dark:text-red-100"},J0={key:1,class:"mb-4"},K0={class:"text-xs font-semibold text-red-600 dark:text-red-400 mb-1"},G0={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"},X0={key:2,class:"mb-4"},Y0={class:"w-full text-xs border border-neutral-300 dark:border-neutral-700 rounded"},Q0={class:"border-b border-neutral-200 dark:border-neutral-800"},Z0={class:"py-1 px-2 font-mono"},ep={key:1},tp={class:"border-b border-neutral-200 dark:border-neutral-800"},ap={class:"py-1 px-2 font-mono"},op={key:1},lp={key:0,class:"border-b border-neutral-200 dark:border-neutral-800"},sp={class:"py-1 px-2 font-mono"},np={key:1},rp={class:"border-b border-neutral-200 dark:border-neutral-800"},ip={class:"py-1 px-2 font-mono"},dp={key:1},up={key:1,class:"border-b border-neutral-200 dark:border-neutral-800"},cp={class:"py-1 px-2 font-mono text-accent-600 dark:text-accent-400"},pp={class:"border-b border-neutral-200 dark:border-neutral-800"},mp={class:"py-1 px-2 font-mono font-semibold"},vp={key:1},fp={class:"py-1 px-2 font-mono font-semibold"},hp={key:1},gp={key:3,class:"mb-4"},bp={class:"text-xs font-semibold mb-1"},xp={class:"border border-neutral-300 dark:border-neutral-700 rounded overflow-hidden"},yp=["onClick"],kp={class:"flex items-center gap-2"},wp={class:"font-mono"},_p={key:0,class:"px-1.5 py-0.5 text-[10px] bg-emerald-100 dark:bg-emerald-900/40 text-emerald-700 dark:text-emerald-300 rounded font-medium border border-emerald-200 dark:border-emerald-800",title:"Programmatically called with state.queueTool()"},$p={key:1,class:"px-1.5 py-0.5 text-[10px] bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 rounded font-medium"},Cp={class:"text-neutral-500"},Tp={key:0,class:"text-xs mb-2"},Sp={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-emerald-200 dark:border-emerald-800"},Vp={class:"text-xs mb-2"},Mp={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-neutral-200 dark:border-neutral-800"},Ip={class:"text-xs mb-2"},Ep={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-neutral-200 dark:border-neutral-800"},Lp={class:"text-xs mb-2"},Ap={class:"rounded overflow-hidden border border-neutral-200 dark:border-neutral-800 bg-white dark:bg-black"},Pp={key:1,class:"text-xs"},Dp={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"},jp={key:2,class:"text-xs"},Op={class:"text-xs mb-2"},Up={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-purple-200 dark:border-purple-800"},Rp={key:0,class:"text-sm mt-2"},Np={key:0,class:"text-neutral-600 dark:text-neutral-400"},Fp={key:1,class:"text-neutral-600 dark:text-neutral-400"},Bp=["href"],qp={key:2,class:"ml-4 mt-1 space-y-0.5"},zp=["href"],Hp={key:0,class:"text-xs text-neutral-500"},Wp={key:1,class:"text-sm text-neutral-600 dark:text-neutral-400 mt-2"},Jp={key:0},Kp={class:"font-mono text-xs"},Gp={key:1},Xp={key:2,class:"text-sm mt-2"},Yp={class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800 overflow-x-auto"},Qp={key:3,class:"text-sm mt-2"},Zp={class:"font-medium text-neutral-600 dark:text-neutral-400 mb-1"},em={key:4,class:"mb-4"},tm={class:"text-xs font-semibold mb-1"},am={class:"border border-emerald-300 dark:border-emerald-700 rounded overflow-hidden bg-emerald-50 dark:bg-emerald-950/20"},om={class:"p-2 flex flex-wrap gap-2"},lm=["src","alt"],sm={key:1,class:"w-[100px] h-[100px] flex items-center justify-center bg-emerald-100 dark:bg-emerald-900 rounded text-xs text-emerald-600 dark:text-emerald-400"},nm={key:5,class:"mb-4"},rm={class:"border border-accent-300 dark:border-accent-700 rounded overflow-hidden bg-accent-50 dark:bg-accent-950/20"},im={class:"text-accent-600 dark:text-accent-400"},dm={key:6,class:"mb-4"},um={class:"border border-purple-300 dark:border-purple-700 rounded overflow-hidden bg-purple-50 dark:bg-purple-950/20"},cm={class:"flex items-center gap-2"},pm={class:"px-1.5 py-0.5 text-[10px] bg-purple-200 dark:bg-purple-800 text-purple-700 dark:text-purple-300 rounded"},mm={class:"text-purple-600 dark:text-purple-400"},vm={class:"divide-y divide-purple-200 dark:divide-purple-800 border-t border-purple-300 dark:border-purple-700"},fm={class:"flex items-center gap-2 mb-1"},hm={class:"text-xs font-semibold text-purple-700 dark:text-purple-300"},gm={key:0,class:"text-xs font-mono text-purple-600 dark:text-purple-400"},bm={key:1,class:"text-xs text-purple-500 dark:text-purple-500"},xm={key:2,class:"text-xs text-purple-500 dark:text-purple-500"},ym={key:0,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},km={class:"text-purple-900 dark:text-purple-100 whitespace-pre-wrap"},wm={key:1,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},_m={class:"font-mono text-purple-700 dark:text-purple-300 break-all"},$m={key:2,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},Cm={class:"text-purple-900 dark:text-purple-100 whitespace-pre-wrap"},Tm={key:0,class:"mt-2 pt-2 border-t border-purple-200 dark:border-purple-800"},Sm={class:"font-mono text-purple-700 dark:text-purple-300 text-xs break-all"},Vm={key:3,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},Mm={class:"text-purple-900 dark:text-purple-100 overflow-x-auto"},Im={key:7,class:"mb-4"},Em={class:"rounded overflow-hidden border border-neutral-300 dark:border-neutral-700"},Lm=me({__name:"LogDetails",props:{log:{},threadId:{},hasPrevious:{type:Boolean},hasNext:{type:Boolean}},emits:["close","previous","next"],setup(t,{emit:n}){const s=t,i=n,l=v("request"),u=v(new Set),r=v(new Set),c=v(!1),f=v(!1),g=v(!0),d=v(!0),p=v(null),h=v(null),_=v(null),b=v(null),m=v(null),y=v(new Set(["system_prompt","request_body","tools"])),x=z=>s.threadId?z.startsWith("data:")||z.startsWith("http")?z:ue(`/api/threads/${s.threadId}/fs${z}`):null,k=z=>{if(!z)return"N/A";try{return JSON.stringify(JSON.parse(z),null,2)}catch{return z}},D=J(()=>{if(!s.log.tools_schema)return[];try{const z=JSON.parse(s.log.tools_schema);return Array.isArray(z)?z:[]}catch{return[]}}),q=J(()=>{if(!s.log.response_body)return[];try{const N=JSON.parse(s.log.response_body)?.choices?.[0]?.message?.tool_calls;return Array.isArray(N)?N:[]}catch{return[]}}),B=J(()=>{if(!s.log.tool_results)return new Map;try{const z=JSON.parse(s.log.tool_results),N=new Map;return Array.isArray(z)&&z.forEach(Q=>{Q.tool_call_id&&N.set(Q.tool_call_id,{content:Q.content,status:Q.status,tool_name:Q.tool_name,timestamp:Q.timestamp})}),N}catch{return new Map}}),F=J(()=>{if(!s.log.response_body)return[];try{const N=JSON.parse(s.log.response_body)?.choices?.[0]?.message?.reasoning_details;return Array.isArray(N)?N:[]}catch{return[]}}),T=J(()=>s.log.reasoning_content?s.log.reasoning_content.replace(/\\n/g,`
43
+ ${v}${d("}")}`}return String(y)},x=B(()=>{if(!o.json)return'<span class="json-null">null</span>';let y;if(typeof o.json=="string")try{y=JSON.parse(o.json)}catch{return m(o.json)}else y=o.json;return h(y)}),c=y=>{const b=y.target;if(b.classList.contains("json-image-path")){const v=b.dataset.path;if(v&&o.threadId){a.value=v;const d=b.getBoundingClientRect();i.value={x:d.left,y:d.top}}}},f=y=>{y.target.classList.contains("json-image-path")&&(a.value=null,i.value=null)};return(y,b)=>(r(),n("div",dg,[t.showCopyButton?(r(),n("div",cg,[w(na,{content:s.value,variant:"ghost",size:"xs"},null,8,["content"])])):I("",!0),e("pre",{class:"text-xs font-mono p-3 overflow-x-auto",onMouseover:c,onMouseout:f,innerHTML:x.value},null,40,pg),(r(),H(kt,{to:"body"},[a.value&&i.value&&t.threadId?(r(),n("div",{key:0,class:"fixed z-50 bg-white dark:bg-neutral-800 border border-neutral-300 dark:border-neutral-600 rounded-lg shadow-lg p-1 pointer-events-none",style:st({left:`${i.value.x}px`,top:`${i.value.y-160}px`})},[e("img",{src:u(a.value),alt:a.value,class:"max-w-[200px] max-h-[150px] rounded object-contain",onError:b[0]||(b[0]=v=>v.target.style.display="none")},null,40,mg)],4)):I("",!0)]))]))}}),zt=Xe(vg,[["__scopeId","data-v-fc06e7bc"]]),fg={class:"text-xs font-semibold"},hg={key:0,class:"font-normal text-neutral-500 dark:text-neutral-400"},gg={class:"flex items-center gap-2"},bg={class:"text-neutral-500 text-xs"},Tt=me({__name:"CollapsibleSection",props:{title:{},subtitle:{},sectionId:{},expanded:{type:Boolean},scrollContainer:{}},emits:["toggle"],setup(t,{expose:o,emit:a}){const i=t,l=a,u=p(null),s=p(!1),m=()=>{Le(()=>{if(!u.value||!i.scrollContainer){s.value=!1;return}const c=i.scrollContainer.clientHeight;s.value=u.value.scrollHeight>c*2})};ge(()=>i.expanded,c=>{c?m():s.value=!1});const h=()=>{if(u.value&&i.scrollContainer){const y=u.value.offsetTop-88;i.scrollContainer.scrollTo({top:Math.max(0,y),behavior:"smooth"})}},x=()=>{if(u.value&&i.scrollContainer){const c=u.value.offsetTop+u.value.offsetHeight,f=i.scrollContainer.clientHeight,y=c-f+10;i.scrollContainer.scrollTo({top:Math.max(0,y),behavior:"smooth"})}};return o({checkHeight:m,contentRef:u}),(c,f)=>(r(),n("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:f[0]||(f[0]=y=>l("toggle"))},[e("span",fg,[Z(C(t.title)+" ",1),t.subtitle?(r(),n("span",hg,"("+C(t.subtitle)+")",1)):I("",!0)]),e("div",gg,[s.value&&t.expanded?(r(),n(ve,{key:0},[e("button",{onClick:Re(h,["stop"]),class:"text-[10px] text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300"},"↑ Top"),e("button",{onClick:Re(x,["stop"]),class:"text-[10px] text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300"},"↓ Bottom")],64)):I("",!0),e("span",bg,C(t.expanded?"▼":"▶"),1)])]),Ae(e("div",{ref_key:"contentRef",ref:u,class:"border-x border-b border-neutral-300 dark:border-neutral-700 rounded-b"},[je(c.$slots,"default")],512),[[Ke,t.expanded]])]))}}),xg={class:"flex items-center justify-between mb-3"},yg={class:"flex items-center gap-2"},kg={class:"flex items-center gap-1"},wg=["disabled"],_g=["disabled"],$g={class:"text-lg font-bold"},Cg={class:"flex items-center gap-2"},Sg=["disabled","title"],Tg={key:1},Ig={class:"@container border-b border-neutral-300 dark:border-neutral-700 pb-3"},zg={class:"hidden @[600px]:block"},Vg={class:"w-full text-xs"},Mg={class:"py-1 font-mono"},Eg={class:"py-1 font-mono"},Lg={key:1},Pg={class:"py-1 font-mono"},Ag={key:1},jg={class:"py-1 font-mono"},Dg={key:1},Og={class:"py-1 font-mono"},Rg={key:1},Ug={class:"py-1 font-mono text-xs"},Bg={class:"@[600px]:hidden space-y-2"},Fg={class:"w-full text-xs"},Ng={class:"py-1 font-mono"},qg={class:"py-1 font-mono"},Hg={key:1},Wg={class:"w-full text-xs"},Kg={class:"py-1 font-mono"},Jg={key:1},Yg={class:"py-1 font-mono"},Gg={key:1},Zg={class:"py-1 font-mono"},Xg={key:1},Qg={class:"py-1 font-mono text-xs"},eb={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"},tb={class:"flex gap-4"},rb={key:0,class:"text-red-600 dark:text-red-400"},ab={class:"space-y-3"},ob={class:"space-y-2"},nb={class:"flex items-center gap-1 pb-2 mb-2 border-b border-neutral-200 dark:border-neutral-700"},lb=["onClick"],sb={key:1,class:"text-xs text-red-600 dark:text-red-400 ml-2"},ib=["onClick"],ub={class:"font-mono"},db={class:"text-neutral-500"},cb={class:"px-2 py-2 bg-white dark:bg-neutral-950 border-t border-neutral-200 dark:border-neutral-800"},pb={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mb-2"},mb={class:"relative bg-white dark:bg-neutral-900"},vb={class:"absolute top-[5px] right-[5px]"},fb={key:0,class:"mb-4"},hb={class:"text-xs font-semibold text-red-600 dark:text-red-400 mb-1"},gb={class:"space-y-2"},bb={class:"px-2 py-1 bg-red-100 dark:bg-red-900/30 text-xs font-medium text-red-800 dark:text-red-200"},xb={class:"text-xs bg-red-50 dark:bg-red-950 p-2 overflow-x-auto text-red-900 dark:text-red-100"},yb={key:1,class:"mb-4"},kb={class:"text-xs font-semibold text-red-600 dark:text-red-400 mb-1"},wb={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"},_b={key:2,class:"mb-4"},$b={class:"w-full text-xs border border-neutral-300 dark:border-neutral-700 rounded"},Cb={class:"border-b border-neutral-200 dark:border-neutral-800"},Sb={class:"py-1 px-2 font-mono"},Tb={key:1},Ib={class:"border-b border-neutral-200 dark:border-neutral-800"},zb={class:"py-1 px-2 font-mono"},Vb={key:1},Mb={key:0,class:"border-b border-neutral-200 dark:border-neutral-800"},Eb={class:"py-1 px-2 font-mono"},Lb={key:1},Pb={class:"border-b border-neutral-200 dark:border-neutral-800"},Ab={class:"py-1 px-2 font-mono"},jb={key:1},Db={key:1,class:"border-b border-neutral-200 dark:border-neutral-800"},Ob={class:"py-1 px-2 font-mono text-accent-600 dark:text-accent-400"},Rb={class:"border-b border-neutral-200 dark:border-neutral-800"},Ub={class:"py-1 px-2 font-mono font-semibold"},Bb={key:1},Fb={class:"py-1 px-2 font-mono font-semibold"},Nb={key:1},qb={key:3,class:"mb-4"},Hb={class:"text-xs font-semibold mb-1"},Wb={class:"border border-neutral-300 dark:border-neutral-700 rounded overflow-hidden"},Kb=["onClick"],Jb={class:"flex items-center gap-2"},Yb={class:"font-mono"},Gb={key:0,class:"px-1.5 py-0.5 text-[10px] bg-emerald-100 dark:bg-emerald-900/40 text-emerald-700 dark:text-emerald-300 rounded font-medium border border-emerald-200 dark:border-emerald-800",title:"Programmatically called with state.queueTool()"},Zb={key:1,class:"px-1.5 py-0.5 text-[10px] bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 rounded font-medium"},Xb={class:"text-neutral-500"},Qb={key:0,class:"text-xs mb-2"},e1={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-emerald-200 dark:border-emerald-800"},t1={class:"text-xs mb-2"},r1={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-neutral-200 dark:border-neutral-800"},a1={class:"text-xs mb-2"},o1={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-neutral-200 dark:border-neutral-800"},n1={class:"text-xs mb-2"},l1={class:"rounded overflow-hidden border border-neutral-200 dark:border-neutral-800 bg-white dark:bg-black"},s1={key:1,class:"text-xs"},i1={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"},u1={key:2,class:"text-xs"},d1={class:"text-xs mb-2"},c1={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-purple-200 dark:border-purple-800"},p1={key:0,class:"text-sm mt-2"},m1={key:0,class:"text-neutral-600 dark:text-neutral-400"},v1={key:1,class:"text-neutral-600 dark:text-neutral-400"},f1=["href"],h1={key:2,class:"ml-4 mt-1 space-y-0.5"},g1=["href"],b1={key:0,class:"text-xs text-neutral-500"},x1={key:1,class:"text-sm text-neutral-600 dark:text-neutral-400 mt-2"},y1={key:0},k1={class:"font-mono text-xs"},w1={key:1},_1={key:2,class:"text-sm mt-2"},$1={class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800 overflow-x-auto"},C1={key:3,class:"text-sm mt-2"},S1={class:"font-medium text-neutral-600 dark:text-neutral-400 mb-1"},T1={key:4,class:"mb-4"},I1={class:"text-xs font-semibold mb-1"},z1={class:"border border-emerald-300 dark:border-emerald-700 rounded overflow-hidden bg-emerald-50 dark:bg-emerald-950/20"},V1={class:"p-2 flex flex-wrap gap-2"},M1=["src","alt"],E1={key:1,class:"w-[100px] h-[100px] flex items-center justify-center bg-emerald-100 dark:bg-emerald-900 rounded text-xs text-emerald-600 dark:text-emerald-400"},L1={key:5,class:"mb-4"},P1={class:"border border-accent-300 dark:border-accent-700 rounded overflow-hidden bg-accent-50 dark:bg-accent-950/20"},A1={class:"text-accent-600 dark:text-accent-400"},j1={key:6,class:"mb-4"},D1={class:"border border-purple-300 dark:border-purple-700 rounded overflow-hidden bg-purple-50 dark:bg-purple-950/20"},O1={class:"flex items-center gap-2"},R1={class:"px-1.5 py-0.5 text-[10px] bg-purple-200 dark:bg-purple-800 text-purple-700 dark:text-purple-300 rounded"},U1={class:"text-purple-600 dark:text-purple-400"},B1={class:"divide-y divide-purple-200 dark:divide-purple-800 border-t border-purple-300 dark:border-purple-700"},F1={class:"flex items-center gap-2 mb-1"},N1={class:"text-xs font-semibold text-purple-700 dark:text-purple-300"},q1={key:0,class:"text-xs font-mono text-purple-600 dark:text-purple-400"},H1={key:1,class:"text-xs text-purple-500 dark:text-purple-500"},W1={key:2,class:"text-xs text-purple-500 dark:text-purple-500"},K1={key:0,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},J1={class:"text-purple-900 dark:text-purple-100 whitespace-pre-wrap"},Y1={key:1,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},G1={class:"font-mono text-purple-700 dark:text-purple-300 break-all"},Z1={key:2,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},X1={class:"text-purple-900 dark:text-purple-100 whitespace-pre-wrap"},Q1={key:0,class:"mt-2 pt-2 border-t border-purple-200 dark:border-purple-800"},ex={class:"font-mono text-purple-700 dark:text-purple-300 text-xs break-all"},tx={key:3,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},rx={class:"text-purple-900 dark:text-purple-100 overflow-x-auto"},ax={key:7,class:"mb-4"},ox={class:"rounded overflow-hidden border border-neutral-300 dark:border-neutral-700"},nx=me({__name:"LogDetails",props:{log:{},threadId:{},hasPrevious:{type:Boolean},hasNext:{type:Boolean}},emits:["close","previous","next"],setup(t,{emit:o}){const a=t,i=o,l=p("request"),u=p(new Set),s=p(new Set),m=p(!1),h=p(!1),x=p(!0),c=p(!0),f=p(null),y=p(null),b=p(null),v=p(null),d=p(null),k=p(new Set(["system_prompt","request_body","tools"])),g=O=>a.threadId?O.startsWith("data:")||O.startsWith("http")?O:fe(`/api/threads/${a.threadId}/fs${O}`):null,_=O=>{if(!O)return"N/A";try{return JSON.stringify(JSON.parse(O),null,2)}catch{return O}},L=B(()=>{if(!a.log.tools_schema)return[];try{const O=JSON.parse(a.log.tools_schema);return Array.isArray(O)?O:[]}catch{return[]}}),R=B(()=>{if(!a.log.response_body)return[];try{const $=JSON.parse(a.log.response_body)?.choices?.[0]?.message?.tool_calls;return Array.isArray($)?$:[]}catch{return[]}}),K=B(()=>{if(!a.log.tool_results)return new Map;try{const O=JSON.parse(a.log.tool_results),$=new Map;return Array.isArray(O)&&O.forEach(j=>{j.tool_call_id&&$.set(j.tool_call_id,{content:j.content,status:j.status,tool_name:j.tool_name,timestamp:j.timestamp})}),$}catch{return new Map}}),Y=B(()=>{if(!a.log.response_body)return[];try{const $=JSON.parse(a.log.response_body)?.choices?.[0]?.message?.reasoning_details;return Array.isArray($)?$:[]}catch{return[]}}),z=B(()=>a.log.reasoning_content?a.log.reasoning_content.replace(/\\n/g,`
9
44
  `).replace(/\\t/g," ").replace(/\n{3,}/g,`
10
45
 
11
- `).trim():""),$=J(()=>{if(!s.log.response_body)return[];try{const N=JSON.parse(s.log.response_body)?.choices?.[0]?.message?.images;return Array.isArray(N)?N:[]}catch{return[]}}),K=J(()=>{if(!s.log.provider_tools)return[];try{const z=JSON.parse(s.log.provider_tools);return Array.isArray(z)?z:[]}catch{return[]}}),oe=J(()=>{if(!s.log.queued_tools)return[];try{const z=JSON.parse(s.log.queued_tools);return Array.isArray(z)?z:[]}catch{return[]}}),te=J(()=>{const z=[];for(const N of q.value)z.push({id:N.id||`tool-${z.length}`,name:N.function?.name||"Unknown",isProvider:!1,isQueued:!1,function:N.function});for(const N of oe.value)z.push({id:N.id||`queued-${z.length}`,name:N.function?.name||"Unknown",isProvider:!1,isQueued:!0,function:N.function,queuedAt:N.queued_at});for(const N of K.value)z.push({id:N.id,name:N.type,isProvider:!0,isQueued:!1,providerType:N.type,status:N.status,result:N.result});return z}),H=z=>{u.value.has(z)?u.value.delete(z):u.value.add(z)},P=z=>{r.value.has(z)?r.value.delete(z):r.value.add(z)},C=()=>{g.value=!g.value},L=()=>{d.value=!d.value},G=z=>{y.value.has(z)?y.value.delete(z):y.value.add(z)},ee=z=>!y.value.has(z),E=J(()=>{if(!s.log.errors)return[];try{const z=JSON.parse(s.log.errors);return Array.isArray(z)?z:[]}catch{return[]}}),U=v("standard"),Z=v(null),se=v(!1),j=v(null),M=["openai","openrouter"],w=()=>(s.log.actual_provider||s.log.provider)?.toLowerCase(),R=()=>{const z=w();z&&M.includes(z)?U.value=z:U.value="standard"},I=z=>z.charAt(0).toUpperCase()+z.slice(1);fe(U,async z=>{if(z==="standard"){Z.value=null,j.value=null;return}if(!s.threadId||!s.log.id){j.value="Missing thread or log ID";return}se.value=!0,j.value=null;try{const N=await fetch(ue(`/api/threads/${s.threadId}/logs/${s.log.id}/inspect/${z}`));if(!N.ok){const Q=await N.json();throw new Error(Q.error||"Failed to inspect")}Z.value=await N.json()}catch(N){j.value=N.message||"Failed to fetch inspected request",Z.value=null}finally{se.value=!1}}),fe(()=>s.log.id,async()=>{if(Z.value=null,j.value=null,R(),U.value!=="standard"&&s.threadId&&s.log.id){se.value=!0;try{const z=await fetch(ue(`/api/threads/${s.threadId}/logs/${s.log.id}/inspect/${U.value}`));if(!z.ok){const N=await z.json();throw new Error(N.error||"Failed to fetch inspected request")}Z.value=await z.json()}catch(z){j.value=z.message||"Failed to fetch inspected request"}finally{se.value=!1}}},{immediate:!0});const le=J(()=>{if(U.value==="standard"||!Z.value)return s.log.message_history;const z=Z.value.messagesPath,N=z?Z.value.body?.[z]:Z.value.body;return JSON.stringify(N,null,2)}),O=J(()=>U.value==="standard"||!Z.value?s.log.request_body:JSON.stringify(Z.value.body,null,2)),W=J(()=>U.value==="standard"||!Z.value?null:`${U.value} format`);fe(()=>s.log,()=>{Te(()=>{h.value?.checkHeight(),_.value?.checkHeight(),b.value?.checkHeight(),m.value?.checkHeight()})});const ce=async()=>{c.value=!0;try{if(!s.log.request_body||!s.log.model)throw new Error("Missing request data");const z=await fetch(ue(`/api/models/${s.log.model}/curl-data`));if(!z.ok)throw new Error("Failed to fetch model data");const N=await z.json(),Q=k(s.log.request_body);let we=`curl -X POST '${N.endpoint}' \\
12
- `;we+=` -H 'Content-Type: application/json' \\
13
- `,N.sdk?.toLowerCase()==="openrouter"?(we+=` -H 'Authorization: Bearer ${N.api_key}' \\
14
- `,we+=` -H 'HTTP-Referer: https://agentkit.local' \\
15
- `,we+=` -H 'X-Title: AgentKit' \\
16
- `):N.sdk?.toLowerCase()==="openai"&&(we+=` -H 'Authorization: Bearer ${N.api_key}' \\
17
- `),we+=` -d '${Q.replace(/'/g,"'\\''")}'`,await navigator.clipboard.writeText(we),f.value=!0,setTimeout(()=>{f.value=!1},2e3)}catch(z){console.error("Failed to copy cURL command:",z),alert(`Failed to copy cURL: ${z instanceof Error?z.message:"Unknown error"}`)}finally{c.value=!1}};return(z,N)=>(a(),o("div",{ref_key:"scrollContainer",ref:p,class:"p-4 h-full overflow-y-auto"},[e("div",Wc,[e("div",Jc,[e("div",Kc,[e("button",{onClick:N[0]||(N[0]=Q=>i("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"},[...N[10]||(N[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:"15 18 9 12 15 6"})],-1)])],8,Gc),e("button",{onClick:N[1]||(N[1]=Q=>i("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"},[...N[11]||(N[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("polyline",{points:"9 18 15 12 9 6"})],-1)])],8,Xc)]),e("h3",Yc,S(t.log.prompt_name||t.log.model_name||t.log.model),1)]),e("div",Qc,[e("button",{onClick:ce,disabled:c.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"},[c.value?(a(),ne(Se,{key:0,size:"xs"})):(a(),o("span",e0,S(f.value?"Copied!":"Copy cURL"),1))],8,Zc),e("button",{onClick:N[2]||(N[2]=Q=>i("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"},[...N[12]||(N[12]=[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",t0,[e("div",a0,[e("table",o0,[N[13]||(N[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 "),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:ae(["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"])},S(t.log.error?"ERROR":t.log.is_complete?"SUCCESS":"LOADING"),3),e("td",l0,S(t.log.actual_provider||t.log.provider),1),e("td",s0,[!t.log.is_complete&&!t.log.prompt_name?(a(),ne(Se,{key:0,size:"xs"})):(a(),o("span",n0,S(t.log.prompt_name||"—"),1))]),e("td",r0,[!t.log.is_complete&&!t.log.latency_ms?(a(),ne(Se,{key:0,size:"xs"})):(a(),o("span",i0,S(t.log.latency_ms?`${t.log.latency_ms}ms`:"—"),1))]),e("td",d0,[!t.log.is_complete&&!t.log.total_tokens?(a(),ne(Se,{key:0,size:"xs"})):(a(),o("span",u0,S(t.log.total_tokens?`${t.log.input_tokens}/${t.log.output_tokens} (${t.log.total_tokens})`:"—"),1))]),e("td",c0,[!t.log.is_complete&&!t.log.cost_total?(a(),ne(Se,{key:0,size:"xs"})):(a(),o("span",p0,S(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))]),e("td",m0,[A(rt,{timestamp:t.log.created_at},null,8,["timestamp"])])])])])]),e("div",v0,[e("table",f0,[N[14]||(N[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"}," 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:ae(["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"])},S(t.log.error?"ERROR":t.log.is_complete?"SUCCESS":"LOADING"),3),e("td",h0,S(t.log.actual_provider||t.log.provider),1),e("td",g0,[!t.log.is_complete&&!t.log.prompt_name?(a(),ne(Se,{key:0,size:"xs"})):(a(),o("span",b0,S(t.log.prompt_name||"—"),1))])])])]),e("table",x0,[N[15]||(N[15]=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",y0,[!t.log.is_complete&&!t.log.latency_ms?(a(),ne(Se,{key:0,size:"xs"})):(a(),o("span",k0,S(t.log.latency_ms?`${t.log.latency_ms}ms`:"—"),1))]),e("td",w0,[!t.log.is_complete&&!t.log.total_tokens?(a(),ne(Se,{key:0,size:"xs"})):(a(),o("span",_0,S(t.log.total_tokens?`${t.log.input_tokens}/${t.log.output_tokens} (${t.log.total_tokens})`:"—"),1))]),e("td",$0,[!t.log.is_complete&&!t.log.cost_total?(a(),ne(Se,{key:0,size:"xs"})):(a(),o("span",C0,S(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))]),e("td",T0,[A(rt,{timestamp:t.log.created_at},null,8,["timestamp"])])])])])])]),e("div",S0,[e("div",V0,[e("button",{onClick:N[3]||(N[3]=Q=>l.value="request"),class:ae(["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:N[4]||(N[4]=Q=>l.value="response"),class:ae(["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"])},[N[16]||(N[16]=Ce(" Response ",-1)),t.log.error||E.value.length>0?(a(),o("span",M0,"⚠")):V("",!0)],2)])]),e("div",I0,[Ie(e("div",E0,[e("div",L0,[N[17]||(N[17]=e("span",{class:"text-xs text-neutral-500 dark:text-neutral-400 mr-2"},"View as:",-1)),e("button",{onClick:N[5]||(N[5]=Q=>U.value="standard"),class:ae(["px-2 py-1 text-xs rounded transition-colors",U.value==="standard"?"bg-black text-white dark:bg-white dark:text-black":"bg-neutral-100 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400 hover:bg-neutral-200 dark:hover:bg-neutral-700"])}," Standard Agents ",2),(a(),o(ve,null,ke(M,Q=>e("button",{key:Q,onClick:we=>U.value=Q,class:ae(["px-2 py-1 text-xs rounded transition-colors",U.value===Q?"bg-black text-white dark:bg-white dark:text-black":"bg-neutral-100 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400 hover:bg-neutral-200 dark:hover:bg-neutral-700"])},S(I(Q)),11,A0)),64)),se.value?(a(),ne(Se,{key:0,size:"xs",class:"ml-2"})):V("",!0),j.value?(a(),o("span",P0,S(j.value),1)):V("",!0)]),D.value.length>0?(a(),ne(pt,{key:0,ref_key:"toolsSectionRef",ref:h,title:`Available Tools (${D.value.length})`,"section-id":"tools",expanded:ee("tools"),"scroll-container":p.value,onToggle:N[6]||(N[6]=Q=>G("tools"))},{default:be(()=>[(a(!0),o(ve,null,ke(D.value,(Q,we)=>(a(),o("div",{key:we,class:"border-b border-neutral-200 dark:border-neutral-800 last:border-b-0"},[e("button",{onClick:de=>H(we),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",j0,S(Q.function?.name||Q.name||"Unknown"),1),e("span",O0,S(u.value.has(we)?"▼":"▶"),1)],8,D0),Ie(e("div",U0,[Q.function?.description||Q.description?(a(),o("div",R0,S(Q.function?.description||Q.description),1)):V("",!0),A(xt,{code:JSON.stringify(Q,null,2),language:"json"},null,8,["code"])],512),[[Ke,u.value.has(we)]])]))),128))]),_:1},8,["title","expanded","scroll-container"])):V("",!0),t.log.message_history?(a(),ne(pt,{key:1,ref_key:"messagesSectionRef",ref:_,title:`Messages (${t.log.message_history_length||0} messages)`,subtitle:W.value,"section-id":"messages",expanded:ee("messages"),"scroll-container":p.value,onToggle:N[7]||(N[7]=Q=>G("messages"))},{default:be(()=>[A(vt,{json:le.value,"thread-id":t.threadId,"show-copy-button":""},null,8,["json","thread-id"])]),_:1},8,["title","subtitle","expanded","scroll-container"])):V("",!0),t.log.system_prompt?(a(),ne(pt,{key:2,ref_key:"systemPromptSectionRef",ref:b,title:"System Prompt","section-id":"system_prompt",expanded:ee("system_prompt"),"scroll-container":p.value,onToggle:N[8]||(N[8]=Q=>G("system_prompt"))},{default:be(()=>[e("div",N0,[A(xt,{code:t.log.system_prompt,language:"markdown"},null,8,["code"]),e("div",F0,[A(wa,{content:t.log.system_prompt,variant:"ghost",size:"xs"},null,8,["content"])])])]),_:1},8,["expanded","scroll-container"])):V("",!0),t.log.request_body?(a(),ne(pt,{key:3,ref_key:"requestBodySectionRef",ref:m,title:"Full Request Body",subtitle:W.value,"section-id":"request_body",expanded:ee("request_body"),"scroll-container":p.value,onToggle:N[9]||(N[9]=Q=>G("request_body"))},{default:be(()=>[A(vt,{json:O.value,"thread-id":t.threadId,"show-copy-button":""},null,8,["json","thread-id"])]),_:1},8,["subtitle","expanded","scroll-container"])):V("",!0)],512),[[Ke,l.value==="request"]]),Ie(e("div",null,[E.value.length>0?(a(),o("div",B0,[e("div",q0,S(E.value.length>1?`Errors (${E.value.length})`:"Error"),1),e("div",z0,[(a(!0),o(ve,null,ke(E.value,(Q,we)=>(a(),o("div",{key:we,class:"border border-red-300 dark:border-red-700 rounded overflow-hidden"},[e("div",H0,S(Q.type||"error"),1),e("pre",W0,S(Q.message),1)]))),128))])])):t.log.error?(a(),o("div",J0,[e("div",K0," Error "+S(t.log.error_type?`(${t.log.error_type})`:""),1),e("pre",G0,S(t.log.error),1)])):V("",!0),t.log.is_complete||!t.log.error?(a(),o("div",X0,[N[25]||(N[25]=e("div",{class:"text-xs font-semibold mb-1"},"Response Stats",-1)),e("table",Y0,[e("tbody",null,[e("tr",Q0,[N[18]||(N[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",Z0,[!t.log.is_complete&&!t.log.finish_reason?(a(),ne(Se,{key:0,size:"xs"})):(a(),o("span",ep,S(t.log.finish_reason||"—"),1))])]),e("tr",tp,[N[19]||(N[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",ap,[!t.log.is_complete&&!t.log.input_tokens?(a(),ne(Se,{key:0,size:"xs"})):(a(),o("span",op,S(t.log.input_tokens||"—"),1))])]),t.log.cached_tokens||!t.log.is_complete?(a(),o("tr",lp,[N[20]||(N[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",sp,[!t.log.is_complete&&!t.log.cached_tokens?(a(),ne(Se,{key:0,size:"xs"})):(a(),o("span",np,S(t.log.cached_tokens||0),1))])])):V("",!0),e("tr",rp,[N[21]||(N[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",ip,[!t.log.is_complete&&!t.log.output_tokens?(a(),ne(Se,{key:0,size:"xs"})):(a(),o("span",dp,S(t.log.output_tokens||"—"),1))])]),t.log.reasoning_tokens&&t.log.reasoning_tokens>0?(a(),o("tr",up,[N[22]||(N[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",cp,S(t.log.reasoning_tokens),1)])):V("",!0),e("tr",pp,[N[23]||(N[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",mp,[!t.log.is_complete&&!t.log.total_tokens?(a(),ne(Se,{key:0,size:"xs"})):(a(),o("span",vp,S(t.log.total_tokens||"—"),1))])]),e("tr",null,[N[24]||(N[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",fp,[!t.log.is_complete&&!t.log.cost_total?(a(),ne(Se,{key:0,size:"xs"})):(a(),o("span",hp,S(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))])])])])])):V("",!0),te.value.length>0?(a(),o("div",gp,[e("div",bp," Tools Called ("+S(te.value.length)+") ",1),e("div",xp,[(a(!0),o(ve,null,ke(te.value,Q=>(a(),o("div",{key:Q.id,class:"border-b border-neutral-200 dark:border-neutral-800 last:border-b-0"},[e("button",{onClick:we=>P(Q.id),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("div",kp,[e("span",wp,S(Q.name),1),Q.isQueued?(a(),o("span",_p," programmatically invoked ")):V("",!0),Q.isProvider?(a(),o("span",$p," provider ")):V("",!0),Q.isProvider&&Q.status?(a(),o("span",{key:2,class:ae([Q.status==="completed"?"text-green-600 dark:text-green-400":Q.status==="failed"?"text-red-600 dark:text-red-400":"text-yellow-600 dark:text-yellow-400","text-[10px]"])},S(Q.status),3)):V("",!0)]),e("span",Cp,S(r.value.has(Q.id)?"▼":"▶"),1)],8,yp),Ie(e("div",{class:ae(["px-2 py-2 border-t border-neutral-200 dark:border-neutral-800",Q.isProvider?"bg-purple-50 dark:bg-purple-900/10":Q.isQueued?"bg-emerald-50 dark:bg-emerald-900/10":"bg-white dark:bg-neutral-950"])},[Q.isProvider?(a(),o(ve,{key:1},[e("div",Op,[N[32]||(N[32]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Provider Tool ID ",-1)),e("div",Up,S(Q.id),1)]),Q.providerType==="web_search"&&Q.result?.actions?(a(),o("div",Rp,[(a(!0),o(ve,null,ke(Q.result.actions,(we,de)=>(a(),o("div",{key:de,class:"mb-2"},[we.type==="search"?(a(),o("div",Np,[N[33]||(N[33]=e("span",{class:"font-medium"},"Searched:",-1)),Ce(' "'+S(we.query)+'" ',1)])):V("",!0),we.type==="open"?(a(),o("div",Fp,[N[34]||(N[34]=e("span",{class:"font-medium"},"Opened:",-1)),e("a",{href:we.url,target:"_blank",class:"text-blue-600 hover:underline ml-1"},S(we.url),9,Bp)])):V("",!0),we.sources?.length?(a(),o("div",qp,[(a(!0),o(ve,null,ke(we.sources.slice(0,5),(pe,ie)=>(a(),o("a",{key:ie,href:pe.url,target:"_blank",class:"block text-blue-600 hover:underline text-xs truncate"},S(pe.title||pe.url),9,zp))),128)),we.sources.length>5?(a(),o("span",Hp," ... and "+S(we.sources.length-5)+" more ",1)):V("",!0)])):V("",!0)]))),128))])):V("",!0),Q.providerType==="image_generation"?(a(),o("div",Wp,[Q.result?.imagePath?(a(),o("span",Jp,[N[35]||(N[35]=Ce(" Stored at: ",-1)),e("span",Kp,S(Q.result.imagePath),1)])):(a(),o("span",Gp," See Generated Images section below "))])):V("",!0),Q.providerType==="code_interpreter"&&Q.result?.output?(a(),o("div",Xp,[N[36]||(N[36]=e("div",{class:"font-medium text-neutral-600 dark:text-neutral-400 mb-1"},"Output:",-1)),e("pre",Yp,S(Q.result.output),1)])):V("",!0),Q.providerType==="file_search"&&Q.result?.results?.length?(a(),o("div",Qp,[e("div",Zp," Found "+S(Q.result.results.length)+" result(s) ",1)])):V("",!0)],64)):(a(),o(ve,{key:0},[Q.isQueued&&Q.queuedAt?(a(),o("div",Tp,[N[26]||(N[26]=e("div",{class:"font-semibold text-emerald-600 dark:text-emerald-400 mb-1"}," Invoked At ",-1)),e("div",Sp,[A(rt,{timestamp:Q.queuedAt},null,8,["timestamp"])])])):V("",!0),e("div",Vp,[N[27]||(N[27]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Tool Call ID ",-1)),e("div",Mp,S(Q.id),1)]),e("div",Ip,[N[28]||(N[28]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Function Name ",-1)),e("div",Ep,S(Q.function?.name),1)]),e("div",Lp,[N[29]||(N[29]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Arguments ",-1)),e("div",Ap,[A(xt,{code:k(Q.function?.arguments||"{}"),language:"json"},null,8,["code"])])]),B.value.has(Q.id)?(a(),o("div",Pp,[N[30]||(N[30]=e("div",{class:"font-semibold text-green-600 dark:text-green-400 mb-1"}," Result ",-1)),e("pre",Dp,S(B.value.get(Q.id)?.content||"No content"),1)])):(a(),o("div",jp,[...N[31]||(N[31]=[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)])]))],64))],2),[[Ke,r.value.has(Q.id)]])]))),128))])])):V("",!0),$.value.length>0?(a(),o("div",em,[e("div",tm," Generated Images ("+S($.value.length)+") ",1),e("div",am,[N[37]||(N[37]=e("div",{class:"px-2 py-1.5 bg-emerald-100 dark:bg-emerald-900/30 text-xs text-emerald-800 dark:text-emerald-200 border-b border-emerald-300 dark:border-emerald-700"}," Images returned by the model ",-1)),e("div",om,[(a(!0),o(ve,null,ke($.value,(Q,we)=>(a(),o("div",{key:we,class:"relative"},[Q.image_url?.url?(a(),o("img",{key:0,src:x(Q.image_url.url)||Q.image_url.url,alt:`Generated image ${we+1}`,class:"max-w-[300px] max-h-[300px] rounded border border-emerald-200 dark:border-emerald-800 object-contain"},null,8,lm)):(a(),o("div",sm," No URL "))]))),128))])])])):V("",!0),t.log.reasoning_content?(a(),o("div",nm,[e("div",rm,[e("button",{onClick:C,class:"w-full px-2 py-1.5 bg-accent-100 dark:bg-accent-900/30 text-xs text-accent-800 dark:text-accent-200 flex items-center justify-between hover:bg-accent-200 dark:hover:bg-accent-900/50 transition-colors"},[N[38]||(N[38]=e("div",{class:"flex items-center gap-2"},[e("span",{class:"font-semibold"},"Reasoning Content"),e("span",{class:"text-accent-600 dark:text-accent-400 font-normal"}," Internal reasoning output (not displayed to users) ")],-1)),e("span",im,S(g.value?"▶":"▼"),1)]),Ie(e("pre",{class:"text-xs p-2 overflow-x-auto whitespace-pre-wrap max-h-96 text-accent-900 dark:text-accent-100 border-t border-accent-300 dark:border-accent-700"},S(T.value),513),[[Ke,!g.value]])])])):V("",!0),F.value.length>0?(a(),o("div",dm,[e("div",um,[e("button",{onClick:L,class:"w-full px-2 py-1.5 bg-purple-100 dark:bg-purple-900/30 text-xs text-purple-800 dark:text-purple-200 flex items-center justify-between hover:bg-purple-200 dark:hover:bg-purple-900/50 transition-colors"},[e("div",cm,[N[39]||(N[39]=e("span",{class:"font-semibold"},"Reasoning Details",-1)),e("span",pm,S(F.value.length)+" blocks ",1),N[40]||(N[40]=e("span",{class:"text-purple-600 dark:text-purple-400 font-normal"}," Structured reasoning from OpenRouter ",-1))]),e("span",mm,S(d.value?"▶":"▼"),1)]),Ie(e("div",vm,[(a(!0),o(ve,null,ke(F.value,(Q,we)=>(a(),o("div",{key:we,class:"p-2"},[e("div",fm,[e("span",hm,S(Q.type||"unknown"),1),Q.id?(a(),o("span",gm," ID: "+S(Q.id),1)):V("",!0),Q.format?(a(),o("span",bm," Format: "+S(Q.format),1)):V("",!0),Q.index!==void 0?(a(),o("span",xm," Index: "+S(Q.index),1)):V("",!0)]),Q.type==="reasoning.summary"&&Q.summary?(a(),o("div",ym,[N[41]||(N[41]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Summary: ",-1)),e("div",km,S(Q.summary),1)])):V("",!0),Q.type==="reasoning.encrypted"&&Q.data?(a(),o("div",wm,[N[42]||(N[42]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Encrypted Data: ",-1)),e("div",_m,S(Q.data),1)])):V("",!0),Q.type==="reasoning.text"&&Q.text?(a(),o("div",$m,[N[44]||(N[44]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Reasoning Text: ",-1)),e("div",Cm,S(Q.text),1),Q.signature?(a(),o("div",Tm,[N[43]||(N[43]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Signature: ",-1)),e("div",Sm,S(Q.signature),1)])):V("",!0)])):V("",!0),["reasoning.summary","reasoning.encrypted","reasoning.text"].includes(Q.type)?V("",!0):(a(),o("div",Vm,[e("pre",Mm,S(JSON.stringify(Q,null,2)),1)]))]))),128))],512),[[Ke,!d.value]])])])):V("",!0),t.log.response_body?(a(),o("div",Im,[N[45]||(N[45]=e("div",{class:"text-xs font-semibold mb-1"},"Full Response Body",-1)),e("div",Em,[A(vt,{json:t.log.response_body,"thread-id":t.threadId,"show-copy-button":""},null,8,["json","thread-id"])])])):V("",!0)],512),[[Ke,l.value==="response"]])])],512))}}),Am={class:"flex flex-col h-full"},Pm={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},Dm={class:"flex items-center justify-between"},jm={class:"flex items-center gap-2"},Om={class:"flex items-center gap-2"},Um={key:0,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},Rm={key:1,class:"flex justify-center py-12"},Nm={key:2,class:"text-red-600 dark:text-red-400 text-center py-12"},Fm={key:3,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},Bm={key:4},qm={key:0,class:"border-b border-neutral-300 dark:border-neutral-700 bg-white dark:bg-black sticky top-0 z-10"},zm=["disabled"],Hm={key:1},Wm={key:2},Jm={key:3},Km={class:"w-full text-sm"},Gm=["onClick","onMouseenter"],Xm={class:"px-3 py-2 text-xs"},Ym={class:"flex items-center gap-1"},Qm={key:0,class:"text-neutral-400 dark:text-neutral-600 mr-1"},Zm={key:3},ev={class:"px-3 py-2"},tv={class:"flex items-center gap-2"},av={key:0,class:"text-red-600 dark:text-red-400",title:"Error"},ov={class:"font-mono text-xs"},lv={class:"px-3 py-2 font-mono text-xs"},sv={key:1},nv={key:1,class:"text-neutral-400"},rv={key:2},iv={key:0,class:"text-emerald-600 dark:text-emerald-400",title:"Programmatically called with state.queueTool()"},dv={key:1},uv={key:2},cv={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"},pv={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"},mv={key:0,class:"flex flex-col items-center justify-center h-full gap-3 text-neutral-500 dark:text-neutral-400"},vv={key:2,class:"absolute inset-0 bg-white/50 dark:bg-black/50 flex items-center justify-center"},qt=20,fv=20,hv=me({__name:"LogsPane",props:{threadId:{},selectedLogId:{},hoveredLogId:{}},emits:["collapse","logClick","logHover","logsLoaded"],setup(t,{expose:n,emit:s}){const i=t,l=s,u=v(0),r=v(qt),{logs:c,hasMore:f,isFetching:g,error:d,wsConnected:p,wsError:h,connectWebSocket:_,disconnectWebSocket:b,refetch:m}=Sc(J(()=>i.threadId),{limit:J(()=>r.value),offset:J(()=>u.value),enableWebSocket:!0,order:"desc"}),y=v([]),x=v(!0),k=v(null),D=v(null),q=v(!1),B=v(!1),F=v(new Map),T=async()=>{await Te(),D.value&&(D.value.scrollTop=D.value.scrollHeight)},$=v(null);fe(c,async de=>{if(u.value===0)y.value=[...de].reverse(),x.value&&y.value.length>0&&(await T(),x.value=!1);else{const pe=[...de].reverse(),ie=new Map;y.value.forEach(ye=>ie.set(ye.id,ye)),pe.forEach(ye=>ie.set(ye.id,ye)),y.value=Array.from(ie.values()).sort((ye,_e)=>ye.created_at-_e.created_at)}},{deep:!0,immediate:!0}),fe(g,(de,pe)=>{if(pe&&!de&&u.value===0&&i.threadId&&$.value!==i.threadId&&y.value.length>0){$.value=i.threadId;const ie=y.value[y.value.length-1];l("logsLoaded",ie?.id??null)}});const{logDetails:K,isFetching:oe}=Vc(J(()=>i.threadId),J(()=>k.value)),te=J(()=>{if(!k.value)return null;const pe=y.value.find(ie=>ie.id===k.value);return pe?K.value?{...K.value,...pe}:pe:null}),H=J(()=>k.value?we.value.findIndex(de=>de.id===k.value):-1),P=J(()=>H.value>0),C=J(()=>H.value>=0&&H.value<we.value.length-1),L=()=>{if(P.value){const de=we.value[H.value-1];E(de)}},G=()=>{if(C.value){const de=we.value[H.value+1];E(de)}},ee=de=>{if(!D.value)return;const pe=F.value.get(de);if(!pe)return;const ie=D.value,ye=pe.getBoundingClientRect(),_e=ie.getBoundingClientRect(),Ae=ie.querySelectorAll(".sticky");let Fe=0;Ae.forEach(he=>{Fe+=he.getBoundingClientRect().height}),Fe+=16;const Re=ye.top<_e.top+Fe,xe=ye.bottom>_e.bottom;Re?ie.scrollBy({top:ye.top-_e.top-Fe,behavior:"smooth"}):xe&&ie.scrollBy({top:ye.bottom-_e.bottom,behavior:"smooth"})},E=de=>{l("logClick",de.id),k.value=de.id},U=(de,pe)=>{pe?F.value.set(de,pe):F.value.delete(de)};fe(k,async de=>{de&&(await Te(),ee(de))}),fe(()=>i.selectedLogId,de=>{de&&(k.value=de)},{immediate:!0});const Z=de=>{k.value=de},se=async de=>{await Te();const pe=F.value.get(de);if(pe&&D.value){const ie=D.value,ye=pe.getBoundingClientRect(),_e=ie.getBoundingClientRect(),Ae=ie.querySelector("thead"),Fe=ie.querySelector(":scope > div > div.sticky");let Re=0;Ae&&(Re+=Ae.getBoundingClientRect().height),Fe&&(Re+=Fe.getBoundingClientRect().height),Re+=40;const xe=ye.top<_e.top+Re,he=ye.bottom>_e.bottom;xe?ie.scrollBy({top:ye.top-_e.top-Re,behavior:"smooth"}):he&&ie.scrollBy({top:ye.bottom-_e.bottom,behavior:"smooth"})}},j=de=>{if(de.length===0)return;const pe=new Set(de);y.value=y.value.filter(ie=>!pe.has(ie.id))},M=v(!1),w=de=>y.value.some(pe=>pe.id===de),R=de=>y.value.find(pe=>pe.id===de)??null,I=(de,pe=3e3)=>new Promise(ie=>{const ye=Date.now(),_e=fe(y,()=>{y.value.length!==de&&(_e(),ie(!0))},{deep:!0}),Ae=setInterval(()=>{y.value.length!==de?(clearInterval(Ae),_e(),ie(!0)):Date.now()-ye>pe&&(clearInterval(Ae),_e(),ie(!1))},50)});n({scrollToLog:se,selectLogById:Z,removeLogsByIds:j,loadUntilLogId:async de=>{if(w(de))return!0;if(!f.value)return!1;M.value=!0;const pe=100,ie=50;try{let ye=0;for(;f.value&&!w(de)&&ye<ie;){ye++;const _e=y.value.length;if(u.value+=r.value,r.value=pe,await m(),!await I(_e))break}return w(de)}finally{M.value=!1}},hasLog:w,getLog:R,setLoadingForLog:de=>{M.value=de},waitForLogRow:async(de,pe=2e3)=>{const ie=Date.now();for(;Date.now()-ie<pe;){if(F.value.has(de))return!0;if(!we.value.some(_e=>_e.id===de)){await Te(),await new Promise(_e=>setTimeout(_e,16));continue}await Te(),await new Promise(_e=>setTimeout(_e,16))}return!1}});const ce=async()=>{if(B.value||!f.value||g.value)return;B.value=!0;const de=D.value?.scrollHeight||0;if(u.value+=r.value,r.value=fv,await m(),await Te(),D.value){const pe=D.value.scrollHeight;D.value.scrollTop+=pe-de}B.value=!1};fe(()=>i.threadId,async de=>{de?(b(),_()):b(),u.value=0,r.value=qt,y.value=[],k.value=null,q.value=!1,x.value=!0},{immediate:!0}),fe(y,async()=>{q.value||await T()},{deep:!0});const z=()=>{if(!D.value)return;const{scrollTop:de,scrollHeight:pe,clientHeight:ie}=D.value,ye=pe-de-ie<50;q.value=!ye},N=de=>{const pe=[];if(de.tools_called)try{const ie=JSON.parse(de.tools_called);Array.isArray(ie)&&pe.push(...ie.map(ye=>({name:ye,isProgrammatic:!1})))}catch{}if(de.provider_tools)try{const ie=JSON.parse(de.provider_tools);Array.isArray(ie)&&pe.push(...ie.map(ye=>({name:ye.type,isProgrammatic:!1})))}catch{}if(de.queued_tools)try{const ie=JSON.parse(de.queued_tools);Array.isArray(ie)&&pe.push(...ie.map(ye=>({name:ye.function?.name||"unknown",isProgrammatic:!0})))}catch{}return pe},Q=de=>de==null?"—":`$${de.toFixed(6)}`,we=J(()=>{const de=new Map,pe=new Map;y.value.forEach(_e=>{de.set(_e.id,_e);const Ae=_e.parent_log_id;Ae&&(pe.has(Ae)||pe.set(Ae,[]),pe.get(Ae).push(_e))});const ie=[],ye=(_e,Ae)=>{ie.push({..._e,depth:Ae}),(pe.get(_e.id)||[]).forEach(Re=>{ye(Re,Ae+1)})};return y.value.forEach(_e=>{_e.parent_log_id||ye(_e,0)}),ie});return(de,pe)=>(a(),o("div",Am,[e("div",Pm,[e("div",Dm,[e("div",jm,[A(X(la),{size:18,class:"shrink-0"}),pe[4]||(pe[4]=e("h2",{class:"text-base font-bold"},"Logs",-1)),t.threadId?(a(),ne(Vt,{key:0,connected:X(p),error:X(h)},null,8,["connected","error"])):V("",!0)]),e("div",Om,[e("button",{onClick:pe[0]||(pe[0]=ie=>l("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[A(X(Tt),{size:20})])])])]),e("div",{ref_key:"logsScrollContainer",ref:D,class:"logs-list-container flex-1 overflow-y-auto overflow-x-auto",onScroll:z},[t.threadId?X(g)&&u.value===0?(a(),o("div",Rm,[A(Se)])):X(d)?(a(),o("div",Nm," Error loading logs: "+S(X(d)),1)):y.value.length===0?(a(),o("div",Fm," No logs yet ")):(a(),o("div",Bm,[X(f)?(a(),o("div",qm,[e("button",{onClick:ce,disabled:B.value||M.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"},[B.value||M.value?(a(),ne(Se,{key:0,size:"xs"})):V("",!0),M.value?(a(),o("span",Hm,"Loading to find log...")):B.value?(a(),o("span",Wm,"Loading older logs...")):(a(),o("span",Jm,"Load previous logs"))],8,zm)])):V("",!0),e("table",Km,[e("thead",{class:ae(["border-b border-neutral-300 dark:border-neutral-700 sticky bg-white z-[10] dark:bg-black",{"top-0":!X(f),"top-[34px]":X(f)}])},[...pe[5]||(pe[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,[(a(!0),o(ve,null,ke(we.value,ie=>(a(),o("tr",{key:ie.id,ref_for:!0,ref:ye=>U(ie.id,ye),class:ae(["border-b border-neutral-200 dark:border-neutral-800 cursor-pointer transition-colors relative",{"last:border-b-0":te.value,"bg-red-50 dark:bg-red-950/20":ie.error,"bg-accent-100 dark:bg-accent-900 dark:text-white":k.value===ie.id,"ring-2 ring-inset ring-accent-400 dark:ring-accent-400":ie.id===i.selectedLogId||ie.id!==i.selectedLogId&&ie.id===i.hoveredLogId}]),onClick:ye=>E(ie),onMouseenter:ye=>l("logHover",ie.id),onMouseleave:pe[1]||(pe[1]=ye=>l("logHover",null))},[e("td",Xm,[e("div",Ym,[ie.depth>0?(a(),o("span",Qm,"└─")):V("",!0),ie.retry_of_log_id?(a(),ne(X(Za),{key:1,size:14,class:"text-neutral-500 dark:text-neutral-400 flex-shrink-0"})):V("",!0),!ie.is_complete&&!ie.prompt_name?(a(),ne(Se,{key:2,size:"xs"})):(a(),o("span",Zm,S(ie.prompt_name||"—"),1))])]),e("td",ev,[e("div",tv,[ie.error?(a(),o("span",av," ✕ ")):V("",!0),e("span",ov,S(ie.model_name||ie.model),1)])]),e("td",lv,[!ie.is_complete&&!ie.cost_total?(a(),ne(Se,{key:0,size:"xs"})):(a(),o("span",sv,S(Q(ie.cost_total)),1))]),e("td",{class:ae(["px-3 py-2 text-xs",k.value===ie.id?"text-neutral-800 dark:text-neutral-100":"text-neutral-600 dark:text-neutral-400"])},[!ie.is_complete&&N(ie).length===0?(a(),ne(Se,{key:0,size:"xs"})):N(ie).length===0?(a(),o("span",nv,"—")):(a(),o("span",rv,[(a(!0),o(ve,null,ke(N(ie),(ye,_e)=>(a(),o(ve,{key:_e},[ye.isProgrammatic?(a(),o("span",iv,[A(X(eo),{size:11,class:"inline-block -mt-0.5 mr-0.5"}),Ce(S(ye.name),1)])):(a(),o("span",dv,S(ye.name),1)),_e<N(ie).length-1?(a(),o("span",uv,", ")):V("",!0)],64))),128))]))],2),e("td",{class:ae(["px-3 py-2 text-right text-xs",k.value===ie.id?"text-neutral-800 dark:text-neutral-100":"text-neutral-500 dark:text-neutral-500"])},[A(rt,{timestamp:ie.created_at},null,8,["timestamp"])],2)],42,Gm))),128))])])])):(a(),o("div",Um," Select a thread to view logs "))],544),A(Xe,{name:"slide-up",onAfterEnter:pe[3]||(pe[3]=()=>k.value&&ee(k.value))},{default:be(()=>[te.value||M.value&&k.value?(a(),o("div",cv,[e("div",pv,[M.value&&!te.value?(a(),o("div",mv,[A(Se),pe[6]||(pe[6]=e("span",{class:"text-sm"},"Loading log...",-1))])):te.value?(a(),ne(Lm,{key:1,log:te.value,"thread-id":t.threadId,"has-previous":P.value,"has-next":C.value,onClose:pe[2]||(pe[2]=ie=>k.value=null),onPrevious:L,onNext:G},null,8,["log","thread-id","has-previous","has-next"])):V("",!0),X(oe)&&te.value?(a(),o("div",vv,[A(Se)])):V("",!0)])])):V("",!0)]),_:1})]))}}),gv=tt(hv,[["__scopeId","data-v-63163597"]]),bv={class:"space-y-4"},xv={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"},yv={class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},kv={key:0},wv={key:1},_v={key:1,class:"space-y-4 p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},$v={key:3,class:"flex items-center gap-2"},Cv=["onUpdate:modelValue","id"],Tv=["for"],Sv={key:0,class:"text-red-500"},Vv={key:5,class:"text-xs text-neutral-500 dark:text-neutral-400 mt-1"},Mv={key:2,class:"p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg text-center text-sm text-neutral-500"},Iv={key:3,class:"space-y-4"},Ev={key:0,class:"p-4 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-700 rounded-lg"},Lv={class:"space-y-3"},Av={key:0,class:"text-xs text-amber-500 dark:text-amber-400 mt-1"},Pv={key:1,class:"p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},Dv={key:4,class:"p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg text-center text-sm text-neutral-500"},jv={key:5},Ov={key:0,class:"space-y-3 mb-4 max-h-64 overflow-y-auto p-2"},Uv={class:"text-xs font-medium mb-1 opacity-70"},Rv={class:"text-sm whitespace-pre-wrap"},Nv=["onClick"],Fv={key:1,class:"text-center py-8 text-neutral-500 dark:text-neutral-400 text-sm"},Bv={class:"space-y-2"},qv={class:"flex items-stretch border border-black dark:border-neutral-300 rounded overflow-hidden bg-white dark:bg-neutral-900"},zv=["disabled","title"],Hv={class:"flex-1 relative"},Wv=["disabled","title"],Jv={class:"text-xs text-neutral-500 dark:text-neutral-400"},Kv={class:"flex justify-between"},Gv=["disabled"],Xv=["disabled"],Yv=me({__name:"CreateThreadModal",props:{modelValue:{type:Boolean},editThread:{}},emits:["update:modelValue","thread-created","thread-updated"],setup(t,{emit:n}){const s=t,i=n,l=J(()=>!!s.editThread),u=v(""),r=v(""),c=v({}),f=v([]),g=v(""),d=v(!1),p=v(""),h=v(null),_=v({}),b=v([]),m=v(!1),{data:y,isFetching:x,execute:k}=Ue(ue("/api/agents"),{immediate:!1}).json(),D=J(()=>y.value?(y.value?.agents||[]).map(w=>({value:w.id,label:w.title})):[]),q=J(()=>!u.value||!y.value?null:(y.value?.agents||[]).find(w=>w.id===u.value)),B=J(()=>q.value&&q.value.type==="ai_human"?"AI":"Side A"),F=J(()=>q.value&&q.value.type==="ai_human"?"Human":"Side B"),{data:T,isFetching:$,execute:K}=Ue(J(()=>q.value?.side_a_system_prompt?ue(`/api/prompts/${q.value.side_a_system_prompt}`):""),{immediate:!1}).json(),oe=J(()=>{if(!T.value)return null;const M=T.value?.required_schema;if(!M)return null;try{return typeof M=="string"?JSON.parse(M):M}catch{return null}}),te=J(()=>b.value.filter(M=>M.required&&!M.value&&!_.value[M.name])),H=J(()=>b.value.filter(M=>M.value!==void 0||!M.required)),P=J(()=>b.value.length>0),C=async M=>{if(!M){b.value=[],_.value={};return}m.value=!0;try{const w=await fetch(ue(`/api/agents/${M}/tenvs`));if(w.ok){const R=await w.json();b.value=R.tenvs||[],_.value=R.merged||{}}else b.value=[],_.value={}}catch(w){console.error("Error fetching agent tenvs:",w),b.value=[],_.value={}}finally{m.value=!1}},L=J(()=>{const M=oe.value;return!M||!M.properties?[]:Object.entries(M.properties).map(([w,R])=>({name:w,type:R.type||"string",description:R.description||"",required:M.required?.includes(w)||!1,enum:R.enum}))});fe(u,async M=>{M&&q.value?.side_a_system_prompt?(await K(),c.value={}):c.value={},M?await C(M):(b.value=[],_.value={})});const G=()=>{const M=h.value;M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},ee=M=>{g.value.trim()&&(f.value.push({id:crypto.randomUUID(),role:M,content:g.value.trim()}),g.value="",setTimeout(()=>G(),0))},E=M=>{f.value=f.value.filter(w=>w.id!==M)},U=()=>{u.value="",r.value="",c.value={},f.value=[],g.value="",p.value="",_.value={},b.value=[]},Z=()=>{s.editThread&&(u.value=s.editThread.agent_id,r.value=s.editThread.tags?.join(", ")||"")},se=async()=>{if(!u.value){p.value="Please select an agent";return}if(!l.value&&L.value.length>0){for(const M of L.value)if(M.required&&!c.value[M.name]){p.value=`Please provide ${M.name}`;return}}if(!l.value&&te.value.length>0){for(const M of te.value)if(!_.value[M.name]){p.value=`Please provide required environment variable: ${M.name}`;return}}d.value=!0,p.value="";try{const M=r.value.split(",").map(w=>w.trim()).filter(w=>w.length>0);if(l.value){const w=await fetch(ue(`/api/threads/${s.editThread.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tags:M})});if(!w.ok){const R=await w.json();throw new Error(R.error||"Failed to update thread")}i("thread-updated"),U(),i("update:modelValue",!1)}else{const w={agent_id:u.value,tags:M.length>0?M:void 0};f.value.length>0&&(w.initial_messages=f.value.map(O=>({role:O.role,content:O.content}))),Object.keys(c.value).length>0&&(w.data=c.value),Object.keys(_.value).length>0&&(w.tenvs=_.value);const R=await fetch(ue("/api/threads"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(!R.ok){const O=await R.json();throw new Error(O.error||"Failed to create thread")}const le=(await R.json()).threadId;if(!le)throw new Error("Thread created but ID not found in response");i("thread-created",le),U(),i("update:modelValue",!1)}}catch(M){console.error(`Error ${l.value?"updating":"creating"} thread:`,M),p.value=M.message||`Failed to ${l.value?"update":"create"} thread`}finally{d.value=!1}},j=()=>{U(),i("update:modelValue",!1)};return fe(()=>s.modelValue,async M=>{M&&(await k(),U(),l.value&&Z())}),(M,w)=>(a(),ne(He,{"model-value":t.modelValue,"onUpdate:modelValue":w[8]||(w[8]=R=>M.$emit("update:modelValue",R)),title:l.value?"Edit Thread":"Create New Thread",width:"max-w-3xl"},{footer:be(()=>[e("div",Kv,[e("button",{onClick:j,type:"button",disabled:d.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,Gv),e("button",{onClick:se,type:"button",disabled:d.value||X(x),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?(a(),o(ve,{key:0},[Ce(S(d.value?"Updating...":"Update Thread"),1)],64)):(a(),o(ve,{key:1},[Ce(S(d.value?"Creating...":"Create Thread"),1)],64))],8,Xv)])]),default:be(()=>[e("div",bv,[p.value?(a(),o("div",xv,S(p.value),1)):V("",!0),e("div",null,[A(Ve,{modelValue:u.value,"onUpdate:modelValue":w[0]||(w[0]=R=>u.value=R),label:"Agent",options:D.value,disabled:X(x)||l.value,placeholder:"Select an agent...",required:""},null,8,["modelValue","options","disabled"]),e("p",yv,[l.value?(a(),o("span",kv,"Agent cannot be changed after thread creation")):(a(),o("span",wv,"Choose which agent will handle this conversation"))])]),!l.value&&L.value.length>0&&!X($)?(a(),o("div",_v,[w[9]||(w[9]=e("h4",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Required Information ",-1)),(a(!0),o(ve,null,ke(L.value,R=>(a(),o("div",{key:R.name,class:"space-y-2"},[R.enum?(a(),ne(Ve,{key:0,modelValue:c.value[R.name],"onUpdate:modelValue":I=>c.value[R.name]=I,label:R.name,options:[{value:"",label:"Select..."},...R.enum.map(I=>({value:I,label:I}))],required:R.required},null,8,["modelValue","onUpdate:modelValue","label","options","required"])):R.type==="string"?(a(),ne(Le,{key:1,modelValue:c.value[R.name],"onUpdate:modelValue":I=>c.value[R.name]=I,label:R.name,placeholder:R.description,required:R.required},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])):R.type==="number"||R.type==="integer"?(a(),ne(Le,{key:2,modelValue:c.value[R.name],"onUpdate:modelValue":I=>c.value[R.name]=I,modelModifiers:{number:!0},label:R.name,placeholder:R.description,type:"number",required:R.required},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])):R.type==="boolean"?(a(),o("div",$v,[Ie(e("input",{"onUpdate:modelValue":I=>c.value[R.name]=I,type:"checkbox",id:`field-${R.name}`,class:"w-4 h-4"},null,8,Cv),[[sa,c.value[R.name]]]),e("label",{for:`field-${R.name}`,class:"text-sm"},[Ce(S(R.name)+" ",1),R.required?(a(),o("span",Sv,"*")):V("",!0)],8,Tv)])):(a(),ne(ya,{key:4,modelValue:c.value[R.name],"onUpdate:modelValue":I=>c.value[R.name]=I,label:R.name,placeholder:R.description||`Enter ${R.name} (JSON format)`,required:R.required,rows:3},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])),R.description?(a(),o("p",Vv,S(R.description),1)):V("",!0)]))),128))])):V("",!0),!l.value&&X($)?(a(),o("div",Mv," Loading agent requirements... ")):V("",!0),!l.value&&P.value&&!m.value?(a(),o("div",Iv,[te.value.length>0?(a(),o("div",Ev,[w[10]||(w[10]=e("h4",{class:"text-sm font-medium text-amber-800 dark:text-amber-200 mb-3"}," Required Environment Variables ",-1)),w[11]||(w[11]=e("p",{class:"text-xs text-amber-600 dark:text-amber-300 mb-3"}," These values are required by the agent's tools and must be provided. ",-1)),e("div",Lv,[(a(!0),o(ve,null,ke(te.value,R=>(a(),o("div",{key:R.name},[A(Le,{"model-value":_.value[R.name]||"","onUpdate:modelValue":I=>_.value[R.name]=I,label:R.name,placeholder:R.description||"Enter value...",required:""},null,8,["model-value","onUpdate:modelValue","label","placeholder"]),R.source?(a(),o("p",Av," Required by: "+S(R.source),1)):V("",!0)]))),128))])])):V("",!0),H.value.length>0?(a(),o("div",Pv,[w[12]||(w[12]=e("h4",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300 mb-3"}," Environment Configuration ",-1)),w[13]||(w[13]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 mb-3"}," Values inherited from the agent. Click the lock icon to override. ",-1)),A(ka,{modelValue:_.value,"onUpdate:modelValue":w[1]||(w[1]=R=>_.value=R),inherited:H.value,"allow-custom":!0},null,8,["modelValue","inherited"])])):V("",!0)])):V("",!0),!l.value&&m.value?(a(),o("div",Dv," Loading environment configuration... ")):V("",!0),l.value?V("",!0):(a(),o("div",jv,[w[16]||(w[16]=e("h4",{class:"text-sm font-medium mb-3"},"Initial Conversation",-1)),f.value.length>0?(a(),o("div",Ov,[(a(!0),o(ve,null,ke(f.value,R=>(a(),o("div",{key:R.id,class:ae(["flex items-start gap-2",{"justify-start":R.role==="assistant","justify-end":R.role==="user"}])},[e("div",{class:ae(["max-w-[80%] rounded-2xl px-4 py-2 break-words",{"bg-black text-white dark:bg-white dark:text-black":R.role==="assistant","bg-neutral-200 text-black dark:bg-neutral-800 dark:text-white":R.role==="user"}])},[e("div",Uv,S(R.role==="assistant"?B.value:F.value),1),e("div",Rv,S(R.content),1)],2),e("button",{onClick:I=>E(R.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,Nv)],2))),128))])):(a(),o("div",Fv," No messages yet. Add messages to start the conversation. ")),e("div",Bv,[e("div",qv,[e("button",{onClick:w[2]||(w[2]=R=>ee("assistant")),type:"button",disabled:!g.value.trim(),title:`Add as ${B.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"},[w[14]||(w[14]=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,S(B.value),1)],8,zv),e("div",Hv,[Ie(e("textarea",{"onUpdate:modelValue":w[3]||(w[3]=R=>g.value=R),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:G,onKeydown:[w[4]||(w[4]=wt(Ee(R=>ee("user"),["meta"]),["enter"])),w[5]||(w[5]=wt(Ee(R=>ee("user"),["ctrl"]),["enter"]))]},null,544),[[Oe,g.value]])]),e("button",{onClick:w[6]||(w[6]=R=>ee("user")),type:"button",disabled:!g.value.trim(),title:`Add as ${F.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"},[w[15]||(w[15]=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,S(F.value),1)],8,Wv)]),e("p",Jv," Type a message and click "+S(B.value)+" (left) or "+S(F.value)+" (right) to add. Or press Cmd+Enter (Mac) / Ctrl+Enter (Windows) to add as "+S(F.value)+". ",1)])])),e("div",null,[A(Le,{modelValue:r.value,"onUpdate:modelValue":w[7]||(w[7]=R=>r.value=R),label:"Tags",placeholder:"research, urgent, production"},null,8,["modelValue"]),w[17]||(w[17]=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"]))}}),Qv={class:"flex h-full overflow-hidden"},Zv={key:0,class:"flex flex-col items-center p-4"},ef={key:0,class:"flex flex-col items-center p-4"},tf={key:0,class:"flex flex-col items-center p-4"},zt=me({__name:"ThreadsView",setup(t){const n=Ye(),s=lt(),i=v(typeof n.params.id=="string"?n.params.id:null),l=v({threadList:!1,messages:!1,logs:!1}),u=v(!1),r=v(null),c=v(null),{thread:f}=St(J(()=>i.value)),g=v(null),d=v(null),p=v(null),h=v(null),_=v(null),b=C=>{h.value=C,_.value=C},m=C=>{if(h.value=C,!C){_.value=null;return}_.value=C;const L=y.value,G=x.value;if(!L||!G||L.hasWorkblockForLogId(C))return;let ee=C;const E=10;for(let U=0;U<E&&ee;U++){const Z=G.getLog(ee);if(!Z)break;const se=Z.parent_log_id;if(!se)break;if(L.hasWorkblockForLogId(se)){_.value=se;return}ee=se}},y=v(null),x=v(null);fe(()=>n.params.id,C=>{i.value=typeof C=="string"?C:null,g.value=null,d.value=null,p.value=null});const k=C=>{s.push(`/threads/${C}`)},D=C=>{window.location.href="/threads"},q=()=>{f.value&&(r.value=f.value,u.value=!0)},B=()=>{r.value=null,u.value=!0},F=C=>{c.value?.refetch(),s.push(`/threads/${C}`)},T=()=>{window.location.reload()},$=C=>{l.value[C]=!l.value[C]},K=async(C,L)=>{if(g.value=C,!L){d.value=null,p.value=null;return}const G=x.value;if(!G){d.value=L,p.value=L;return}const ee=!G.hasLog(L);if(ee&&G.setLoadingForLog(!0),d.value=L,p.value=L,ee&&!await G.loadUntilLogId(L)){console.warn(`Could not find log ${L} after loading all available logs`),G.setLoadingForLog(!1);return}if(!await G.waitForLogRow(L)){console.warn(`Log row ${L} not rendered in time`);return}G.scrollToLog(L),G.selectLogById(L)},oe=C=>{d.value=C,p.value=C,g.value=null;const L=y.value,G=x.value;if(!L||!G)return;let ee=L.scrollToLogId(C);if(ee)return;let E=C;const U=10;for(let Z=0;Z<U&&E;Z++){const se=G.getLog(E);if(!se)break;const j=se.parent_log_id;if(!j)break;if(ee=L.scrollToLogId(j),ee){p.value=j;return}E=j}},te=C=>{C&&(d.value=C)},H=C=>{x.value?.removeLogsByIds(C)},P=C=>{C&&!i.value&&s.push(`/threads/${C}`)};return(C,L)=>(a(),o("div",Qv,[e("div",{class:ae([l.value.threadList?"w-[60px]":"w-[320px]","border-r border-neutral-300 dark:border-neutral-700 flex-shrink-0 transition-all duration-200 flex flex-col min-h-0"])},[l.value.threadList?(a(),o("div",Zv,[e("button",{onClick:L[0]||(L[0]=G=>$("threadList")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Threads pane"},[A(X(Qt),{size:20})])])):(a(),ne(ji,{key:1,ref_key:"threadListPaneRef",ref:c,"selected-thread-id":i.value,onSelectThread:k,onCollapse:L[1]||(L[1]=G=>$("threadList")),onCreateThread:B,onThreadsLoaded:P},null,8,["selected-thread-id"]))],2),e("div",{class:ae([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 flex flex-col min-h-0"])},[l.value.messages?(a(),o("div",ef,[e("button",{onClick:L[2]||(L[2]=G=>$("messages")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Messages pane"},[A(X(oa),{size:20})])])):i.value?(a(),ne(X($o),{key:1,"thread-id":i.value,preload:!0,live:!0,"include-silent":!0,"use-workblocks":!0},{default:be(()=>[A(Bt,{ref_key:"messagesPaneRef",ref:y,"thread-id":i.value,"selected-message-id":g.value,"selected-log-id":p.value,"hovered-log-id":_.value,onCollapse:L[3]||(L[3]=G=>$("messages")),onMessageClick:K,onMessageHover:b,onThreadDeleted:D,onEditThread:q,onLogsDeleted:H},null,8,["thread-id","selected-message-id","selected-log-id","hovered-log-id"])]),_:1},8,["thread-id"])):l.value.messages?V("",!0):(a(),ne(Bt,{key:2,ref_key:"messagesPaneRef",ref:y,"thread-id":null,"selected-message-id":g.value,"selected-log-id":p.value,"hovered-log-id":_.value,onCollapse:L[4]||(L[4]=G=>$("messages")),onMessageClick:K,onMessageHover:b,onThreadDeleted:D,onEditThread:q,onLogsDeleted:H},null,8,["selected-message-id","selected-log-id","hovered-log-id"]))],2),e("div",{class:ae([l.value.logs?"w-[60px]":"flex-1","overflow-hidden transition-all duration-200 flex flex-col min-h-0"])},[l.value.logs?(a(),o("div",tf,[e("button",{onClick:L[5]||(L[5]=G=>$("logs")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Logs pane"},[A(X(la),{size:20})])])):(a(),ne(gv,{key:1,ref_key:"logsPaneRef",ref:x,"thread-id":i.value,"selected-log-id":d.value,"hovered-log-id":h.value,onCollapse:L[6]||(L[6]=G=>$("logs")),onLogClick:oe,onLogHover:m,onLogsLoaded:te},null,8,["thread-id","selected-log-id","hovered-log-id"]))],2),A(Yv,{modelValue:u.value,"onUpdate:modelValue":L[7]||(L[7]=G=>u.value=G),"edit-thread":r.value,onThreadCreated:F,onThreadUpdated:T},null,8,["modelValue","edit-thread"])]))}}),af=me({__name:"PromptsDataTable",emits:["add","edit","delete"],setup(t,{expose:n,emit:s}){const i=s,l=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:(d,p)=>d||p.model_id||"-"},{key:"created_at",label:"Created",width:"w-1/6",formatter:d=>d?new Date(d*1e3).toLocaleDateString():"-"}],c=[{icon:"edit",label:"Edit",handler:d=>i("edit",d)},{icon:"delete",label:"Delete",handler:async d=>{await g(d)},confirm:!0,confirmMessage:"Are you sure you want to delete this prompt?"}],f=async()=>{u.value=!0;try{const d=await fetch(ue("/api/prompts"));if(d.ok){const p=await d.json();l.value=p.prompts||[]}}catch(d){console.error("Error fetching prompts:",d)}finally{u.value=!1}},g=async d=>{try{const p=await fetch(ue(`/api/prompts/${d.id}`),{method:"DELETE"});if(p.ok)await f();else{const h=await p.json();alert(h.error||"Failed to delete prompt")}}catch(p){console.error("Error deleting prompt:",p),alert("Failed to delete prompt")}};return Me(()=>{f()}),n({refresh:f}),(d,p)=>(a(),o("div",null,[A(Ge,{columns:r,data:l.value,actions:c,loading:u.value,"empty-message":"No prompts available. Create your first prompt to get started."},null,8,["data","loading"])]))}}),of={class:"space-y-4"},lf={key:0,class:"mt-1 text-sm text-red-500"},sf={key:1,class:"mt-1 text-sm text-neutral-500 dark:text-neutral-400"},nf={class:"px-1 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded"},rf=["value"],df=me({__name:"PromptBasicInfo",props:{name:{},toolDescription:{}},emits:["update:name","update:toolDescription"],setup(t,{emit:n}){const s=t,i=n,l=v(""),u=c=>{let f=c.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=c=>{const f=u(c);i("update:name",f)};return fe(()=>s.name,c=>{c&&u(c)},{immediate:!0}),(c,f)=>(a(),o("div",of,[e("div",null,[A(Le,{"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?(a(),o("p",lf,S(l.value),1)):t.name?(a(),o("p",sf,[f[1]||(f[1]=Ce(" Will be saved as: ",-1)),e("code",nf,S(t.name),1)])):V("",!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]=g=>i("update:toolDescription",g.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,rf)])]))}}),uf={class:"space-y-4"},cf=me({__name:"PromptModelSelect",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:n}){const s=n,i=v([]),l=v(!1),u=J(()=>i.value.map(c=>({value:c.id,label:c.name,description:c.model||c.provider,icon:c.provider?`/api/providers/${c.provider}/icon?model=${encodeURIComponent(c.model||"")}`:void 0}))),r=async()=>{l.value=!0;try{const c=await fetch(ue("/api/models"));if(c.ok){const f=await c.json();i.value=f.models||[]}}catch(c){console.error("Error fetching models:",c)}finally{l.value=!1}};return Me(()=>{r()}),(c,f)=>(a(),o("div",uf,[A(Ve,{"model-value":t.modelValue,"onUpdate:modelValue":f[0]||(f[0]=g=>s("update:modelValue",g)),options:u.value,label:"Model",placeholder:"Select a model for this prompt","search-placeholder":"Search models...",loading:l.value},null,8,["model-value","options","loading"])]))}}),pf=["data-property-id","data-nested-property-id"],mf={class:"p-3 space-y-3"},vf={class:"flex items-start gap-2"},ff={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"},hf={class:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2"},gf={class:"flex items-center gap-2 mt-2"},bf=["disabled"],xf={key:0,class:"ml-6"},yf={key:0,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg space-y-2"},kf={class:"flex items-center justify-between mb-2"},wf=["disabled"],_f={key:0,class:"space-y-1"},$f=["onClick","disabled"],Cf={key:1,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},Tf={class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"},Sf={class:"space-y-2"},Vf={class:"flex items-center justify-between"},Mf=["disabled"],If={class:"space-y-2"},Ef={key:2,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},Lf={key:0,class:"mb-2"},Af=["disabled"],Pf={key:1,class:"space-y-2"},Df=me({__name:"PropertyEditor",props:We({propertyId:{},isNested:{type:Boolean,default:!1},parentId:{},disabled:{type:Boolean,default:!1},enableDrag:{type:Boolean,default:!0}},{modelValue:{required:!0},modelModifiers:{}}),emits:We(["remove","description-keydown","add-top-level"],["update:modelValue"]),setup(t,{emit:n}){const s=t,i=n,l=st(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"}],c=J(()=>["object","array","enum","anyOf"].includes(l.value.type));fe(()=>l.value.type,async(b,m)=>{if(["object","array","enum","anyOf"].includes(b)&&(u.value=!0,b==="anyOf"&&!l.value.anyOf&&(l.value.anyOf=[]),b==="object"&&!l.value.properties&&(l.value.properties=[{id:crypto.randomUUID(),name:"property1",type:"string",description:""}]),b==="array"&&!l.value.items&&(l.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""}),b==="enum"&&!l.value.enum&&(l.value.enum=["value1"])),m!==void 0){await Te();const y=s.isNested?`[data-nested-property-id="${s.propertyId}"] input[placeholder="Description"]`:`[data-property-id="${s.propertyId}"] input[placeholder="Description"]`,x=document.querySelector(y);x&&x.focus()}});const f=b=>{b.shiftKey&&l.value.type==="object"&&l.value.properties?h():i("add-top-level")},g=()=>{l.value.items||(l.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""})},d=()=>{l.value.enum||(l.value.enum=[]),l.value.enum.push(`value${l.value.enum.length+1}`)},p=b=>{l.value.enum&&l.value.enum.splice(b,1)},h=async()=>{const b={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(b)):(l.value.properties||(l.value.properties=[]),l.value.properties.push(b)),await Te();const m=document.querySelector(`[data-nested-property-id="${b.id}"] input[placeholder="Property name"]`);m&&(m.focus(),m.select())},_=b=>{l.value.type==="anyOf"&&l.value.anyOf?l.value.anyOf=l.value.anyOf.filter(m=>m.id!==b):l.value.properties&&(l.value.properties=l.value.properties.filter(m=>m.id!==b))};return(b,m)=>{const y=to("PropertyEditor",!0);return a(),o("div",{"data-property-id":t.isNested?void 0:t.propertyId,"data-nested-property-id":t.isNested?t.propertyId:void 0,class:ae(["border rounded-lg",t.isNested?"border-neutral-100 dark:border-neutral-900":"border-neutral-200 dark:border-neutral-800"])},[e("div",mf,[e("div",vf,[t.enableDrag?(a(),o("div",ff,[...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)])])):V("",!0),e("div",hf,[A(Le,{modelValue:l.value.name,"onUpdate:modelValue":m[0]||(m[0]=x=>l.value.name=x),placeholder:"Property name",disabled:t.disabled},null,8,["modelValue","disabled"]),A(Ve,{modelValue:l.value.type,"onUpdate:modelValue":m[1]||(m[1]=x=>l.value.type=x),options:r,disabled:t.disabled},null,8,["modelValue","disabled"]),A(Le,{modelValue:l.value.description,"onUpdate:modelValue":m[2]||(m[2]=x=>l.value.description=x),placeholder:"Description",disabled:t.disabled,onKeydown:m[3]||(m[3]=wt(Ee(x=>f(x),["prevent"]),["enter"]))},null,8,["modelValue","disabled"])]),e("div",gf,[c.value?(a(),o("button",{key:0,onClick:m[4]||(m[4]=x=>u.value=!u.value),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors"},[(a(),o("svg",{class:ae(["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))])):V("",!0),e("button",{onClick:m[5]||(m[5]=x=>b.$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,bf)])]),u.value&&c.value?(a(),o("div",xf,[l.value.type==="enum"?(a(),o("div",yf,[e("div",kf,[m[13]||(m[13]=e("h4",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400"}," Enum Values ",-1)),e("button",{onClick:d,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,wf)]),l.value.enum?(a(),o("div",_f,[(a(!0),o(ve,null,ke(l.value.enum,(x,k)=>(a(),o("div",{key:k,class:"flex items-center gap-2"},[A(Le,{modelValue:l.value.enum[k],"onUpdate:modelValue":D=>l.value.enum[k]=D,placeholder:"Enum value",disabled:t.disabled,class:"flex-1"},null,8,["modelValue","onUpdate:modelValue","disabled"]),e("button",{onClick:D=>p(k),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,$f)]))),128))])):V("",!0)])):V("",!0),l.value.type==="object"||l.value.type==="anyOf"?(a(),o("div",Cf,[e("h4",Tf,S(l.value.type==="anyOf"?"Type Options":"Nested Properties"),1),e("div",Sf,[e("div",Vf,[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 "+S(l.value.type==="anyOf"?"Type Option":"Property"),9,Mf)]),e("div",If,[(a(!0),o(ve,null,ke(l.value.type==="anyOf"?l.value.anyOf:l.value.properties,(x,k)=>(a(),ne(y,{key:x.id,modelValue:(l.value.type==="anyOf"?l.value.anyOf:l.value.properties)[k],"onUpdate:modelValue":D=>(l.value.type==="anyOf"?l.value.anyOf:l.value.properties)[k]=D,"property-id":x.id,"is-nested":!0,"parent-id":t.propertyId,disabled:t.disabled,"enable-drag":!1,onRemove:D=>_(x.id),onAddTopLevel:m[6]||(m[6]=D=>i("add-top-level"))},null,8,["modelValue","onUpdate:modelValue","property-id","parent-id","disabled","onRemove"]))),128))])])])):V("",!0),l.value.type==="array"?(a(),o("div",Ef,[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?V("",!0):(a(),o("div",Lf,[e("button",{onClick:g,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,Af)])),l.value.items?(a(),o("div",Pf,[A(y,{modelValue:l.value.items,"onUpdate:modelValue":m[7]||(m[7]=x=>l.value.items=x),"property-id":l.value.items.id,"is-nested":!0,"parent-id":t.propertyId,disabled:t.disabled,"enable-drag":!1,onRemove:m[8]||(m[8]=x=>l.value.items=null),onAddTopLevel:m[9]||(m[9]=x=>i("add-top-level"))},null,8,["modelValue","property-id","parent-id","disabled"])])):V("",!0)])):V("",!0)])):V("",!0)])],10,pf)}}}),jf={class:"space-y-2"},Of=["disabled"],Uf=me({__name:"PropertyList",props:We({disabled:{type:Boolean,default:!1},parentId:{},isNested:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:We(["add-property","description-keydown"],["update:modelValue"]),setup(t,{expose:n,emit:s}){const i=t,l=s,u=st(t,"modelValue"),r=v();let c=!1;Me(async()=>{}),Be(()=>{});const f=async()=>{if(c)return;c=!0;const d={id:crypto.randomUUID(),name:`property${u.value.length+1}`,type:"string",description:"",required:!1};u.value=[...u.value,d],await Te();const p=i.parentId?`[data-nested-property-id="${d.id}"]`:`[data-property-id="${d.id}"]`,h=document.querySelector(`${p} input[placeholder="Property name"]`);h&&(h.focus(),h.select()),l("add-property"),c=!1},g=d=>{u.value=u.value.filter(p=>p.id!==d)};return n({addProperty:f}),(d,p)=>(a(),o("div",jf,[e("div",{ref_key:"dragAreaRef",ref:r,class:"space-y-2"},[(a(!0),o(ve,null,ke(u.value,h=>(a(),ne(Df,{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:_=>g(h.id),onAddTopLevel:p[0]||(p[0]=_=>d.$emit("add-property"))},null,8,["modelValue","onUpdate:modelValue","property-id","is-nested","parent-id","disabled","enable-drag","onRemove"]))),128))],512),e("div",{class:ae(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:ae(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")},[...p[1]||(p[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"})]),Ce(" Add Property ")],-1)])],10,Of)],2)]))}}),Rf={class:"space-y-4"},Nf={key:0,class:"flex items-center justify-between"},Ff={class:"text-sm font-medium"},Bf={key:0,class:"text-red-500"},qf={class:"space-y-2 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4"},zf={key:0,class:"flex items-center justify-between mb-2"},Hf={key:1,class:"text-center py-12"},Wf=["disabled"],Jf={class:"mt-4 text-center"},Kf={key:3,class:"mt-4"},Gf={class:"bg-neutral-50 dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4 overflow-x-auto"},Xf={class:"text-xs leading-relaxed"},Yf=["innerHTML"],_a=me({__name:"JSONSchemaInput",props:We({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 n=st(t,"modelValue"),s=v([]),i=v(),l=v(!1),u=()=>{if(n.value?.properties){const b=[];n.value.required;for(const[m,y]of Object.entries(n.value.properties)){const x=y,k={id:crypto.randomUUID(),name:m,type:x.type||"string",description:x.description||""};x.enum&&(k.enum=x.enum),x.anyOf&&(k.type="anyOf",k.anyOf=r(x.anyOf)),x.type==="array"&&x.items&&(k.items=c(x.items)),x.type==="object"&&x.properties&&(k.properties=f(x.properties,x.required||[])),b.push(k)}s.value=b}},r=b=>b.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?c(m.items):void 0,enum:m.enum}:{id:crypto.randomUUID(),name:"",type:"string",description:""}),c=b=>{const m={id:crypto.randomUUID(),name:"",type:b.type||"string",description:b.description||""};return b.enum&&(m.enum=b.enum),b.anyOf&&(m.type="anyOf",m.anyOf=r(b.anyOf)),b.type==="array"&&b.items&&(m.items=c(b.items)),b.type==="object"&&b.properties&&(m.properties=f(b.properties,b.required||[])),m},f=(b,m)=>{const y=[];for(const[x,k]of Object.entries(b)){const D=k,q={id:crypto.randomUUID(),name:x,type:D.type||"string",description:D.description||""};D.enum&&(q.enum=D.enum),D.anyOf&&(q.type="anyOf",q.anyOf=r(D.anyOf)),D.type==="array"&&D.items&&(q.items=c(D.items)),D.type==="object"&&D.properties&&(q.properties=f(D.properties,D.required||[])),y.push(q)}return y};u();const g=()=>{const b={type:"object",properties:{},required:[],additionalProperties:!1},{properties:m}=p(s.value);b.properties=m,b.required=Object.keys(m),n.value=b},d=b=>{const m={type:b.type==="anyOf"?void 0:b.type,description:b.description};if(b.type==="enum"&&b.enum&&(m.enum=b.enum,m.type="string"),b.type==="anyOf"&&b.anyOf&&(delete m.type,m.anyOf=b.anyOf.map(d)),b.type==="object"&&b.properties){const{properties:y}=p(b.properties);m.properties=y,m.required=Object.keys(y),m.additionalProperties=!1}return b.type==="array"&&b.items&&(m.items=d(b.items)),m},p=b=>{const m={},y=[];for(const x of b){const k={type:x.type==="anyOf"?void 0:x.type,description:x.description};if(y.push(x.name),x.type==="enum"&&x.enum&&(k.enum=x.enum,k.type="string"),x.type==="anyOf"&&x.anyOf&&x.anyOf.length>0&&(delete k.type,k.anyOf=x.anyOf.map(d)),x.type==="array"&&x.items&&(k.items=d(x.items)),x.type==="object"&&x.properties){const{properties:D}=p(x.properties);k.properties=D,k.required=Object.keys(D),k.additionalProperties=!1}m[x.name]=k}return{properties:m,required:y}};fe(s,()=>{g()},{deep:!0}),g();const h=J(()=>JSON.stringify(n.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 b={id:crypto.randomUUID(),name:"property1",type:"string",description:""};s.value.push(b),await Te();const m=document.querySelector(`[data-property-id="${b.id}"] input[placeholder="Property name"]`);m&&(m.focus(),m.select())}else i.value&&i.value.addProperty()};return(b,m)=>(a(),o("div",Rf,[t.label?(a(),o("div",Nf,[e("label",Ff,[Ce(S(t.label)+" ",1),t.required?(a(),o("span",Bf,"*")):V("",!0)])])):V("",!0),e("div",qf,[s.value.length>0?(a(),o("div",zf,[...m[2]||(m[2]=[e("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Properties ",-1)])])):V("",!0),s.value.length===0?(a(),o("div",Hf,[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"})]),Ce(" Add Property ")],-1)])],8,Wf)])):V("",!0),s.value.length>0?(a(),ne(Uf,{key:2,ref_key:"propertyListRef",ref:i,modelValue:s.value,"onUpdate:modelValue":m[0]||(m[0]=y=>s.value=y),disabled:t.disabled,onAddProperty:_},null,8,["modelValue","disabled"])):V("",!0),e("div",Jf,[e("button",{onClick:m[1]||(m[1]=y=>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"},S(l.value?"Hide":"Show")+" JSON Schema ",1)]),l.value?(a(),o("div",Kf,[e("div",Gf,[e("pre",Xf,[e("code",{class:"font-mono",innerHTML:h.value},null,8,Yf)])])])):V("",!0)])]))}}),Qf={class:"prompt-input-container relative"},Zf=["contenteditable","data-placeholder"],eh={class:"bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded-lg overflow-hidden min-w-[240px] max-w-[320px]"},th={key:0,class:"p-3 text-sm text-neutral-500"},ah={key:1,class:"p-3 text-sm text-neutral-500"},oh={key:2,class:"max-h-[220px] overflow-y-auto"},lh=["onClick"],sh={class:"font-medium flex items-center gap-2"},nh=["title"],rh={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},ih={key:1,class:"text-xs text-red-600 dark:text-red-400 mt-1"},dh={class:"text-xs mt-1"},uh=me({__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:n}){const s=t,i=n,l=v(),u=v(),r=ao({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}),c=()=>Math.random().toString(36).slice(2)+Date.now().toString(36),f=P=>P.type==="string"?"":`@${P.type==="variable"?P.label||P.value:P.label||P.id}`,g=()=>{const P=window.getSelection();if(!P||!P.rangeCount||!l.value)return null;const C=P.getRangeAt(0);let L=0;const G=Array.from(l.value.childNodes);for(let ee=0;ee<G.length;ee++){const E=G[ee];if(E===C.startContainer||E.contains?.(C.startContainer)){if(E.nodeType===Node.TEXT_NODE)return{segmentIndex:L,offset:C.startOffset};if(E.nodeType===Node.ELEMENT_NODE&&E.classList?.contains("prompt-tag"))return{segmentIndex:L,offset:0}}(E.nodeType===Node.TEXT_NODE||E.nodeType===Node.ELEMENT_NODE&&E.classList?.contains("prompt-tag"))&&L++}return{segmentIndex:0,offset:0}},d=()=>{if(!l.value)return;const P=r.segments.map(C=>{if(C.type==="string")return(C.value||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")||"";{const L=C._uid||(C._uid=c()),G=f(C),ee=C.type==="variable"?{type:"variable",value:C.value,label:C.label,schema:C.schema,meta:C.meta}:{type:"prompt",id:C.id,label:C.label,schema:C.schema,meta:C.meta},E=encodeURIComponent(JSON.stringify(ee)),U=C.type==="prompt"&&C.meta&&!C.meta.isValid,Z=U?'<span class="prompt-tag-warning" title="'+(C.meta.validationMessage||"").replace(/"/g,"&quot;")+'">⚠️</span>':"";return`<span class="prompt-tag prompt-tag-clickable${U?" prompt-tag-invalid":""}" contenteditable="false" data-segment-uid="${L}" data-segment="${E}">${G}${Z}</span>`}}).join("");l.value.innerHTML=P||"<br>"},p=()=>{const P=[];for(const C of r.segments)C.type==="string"&&P.length>0&&P[P.length-1].type==="string"?P[P.length-1].value+=C.value:P.push(C);r.segments=P.length?P:[{type:"string",value:""}]},h=P=>{const C=P.dataset.segmentUid;let L=r.segments.find(G=>G._uid===C);if(!L){const G=P.dataset.segment;if(G)try{const ee=JSON.parse(decodeURIComponent(G));ee&&(ee.type==="variable"||ee.type==="prompt")&&(L=ee.type==="variable"?{type:"variable",value:ee.value,label:ee.label,schema:ee.schema,meta:ee.meta,_uid:C}:{type:"prompt",id:ee.id,label:ee.label,schema:ee.schema,meta:ee.meta,_uid:C})}catch{}}return L||null},_=P=>{const C=P.target;if(C.classList?.contains("prompt-tag")){const L=h(C);L&&i("segment-click",L,P)}},b=P=>{if(r.isComposing)return;const C=P.target,L=[];let G="";const ee=()=>{G.length>0&&(L.push({type:"string",value:G}),G="")},E=j=>{if(j.nodeType===Node.TEXT_NODE){const M=(j.textContent||"").replace(/\u00A0/g," ");G+=M;return}if(j.nodeType===Node.ELEMENT_NODE){const M=j;if(M.classList?.contains("prompt-tag")){ee();const R=h(M);R&&L.push(R);return}if(M.tagName==="BR"){G+=`
18
- `;return}const w=Array.from(M.childNodes);for(const R of w)E(R);(M.tagName==="DIV"||M.tagName==="P"||M.tagName==="LI")&&M.nextSibling&&(G+=`
19
- `);return}},U=Array.from(C.childNodes);for(const j of U)E(j);ee();const se=L.some(j=>j.type!=="string")?L:[{type:"string",value:(C.innerText||"").replace(/\r\n/g,`
20
- `)}];r.segments=se.length?se:[{type:"string",value:""}],p(),m(),oe()},m=()=>{const P=window.getSelection();if(!P||!P.rangeCount||!l.value)return;const C=P.getRangeAt(0);if(C.startContainer.nodeType!==Node.TEXT_NODE){r.dialogOpen&&x();return}const G=C.startContainer.textContent||"",ee=C.startOffset;if(ee>0&&G[ee-1]==="@")r.atTriggerIndex=ee-1,r.searchQuery="",y(),q("");else if(r.dialogOpen&&r.atTriggerIndex>=0)if(C.startContainer.nodeType===Node.TEXT_NODE){const E=C.startContainer.textContent||"",U=C.startOffset;if(U<=r.atTriggerIndex){x();return}const Z=E.substring(0,U);if(Z.length>r.atTriggerIndex&&Z[r.atTriggerIndex]==="@"){const se=Z.substring(r.atTriggerIndex+1);se.includes(" ")||se.includes(`
21
- `)||se.length>r.searchQuery.length+5?x():(r.searchQuery=se,q(se))}else x()}else x()},y=async()=>{r.dialogOpen=!0,r.selectedIndex=0,await Te(),k()},x=()=>{r.dialogOpen=!1,r.searchResults=[],r.searchQuery="",r.atTriggerIndex=-1,r.isSearching=!1},k=()=>{if(!u.value||!l.value)return;const P=window.getSelection();if(!P||!P.rangeCount)return;const L=P.getRangeAt(0).getBoundingClientRect(),G=l.value.getBoundingClientRect();r.dialogPosition={x:L.left-G.left,y:L.bottom-G.top+4}};let D=null;const q=async P=>{if(!s.search){r.searchResults=[];return}D&&clearTimeout(D),r.isSearching=!0,D=setTimeout(async()=>{try{const C=await s.search(P);r.searchResults=(C||[]).filter(L=>s.allowedTypes?.includes(L.type))}catch(C){console.error("Search error:",C),r.searchResults=[]}finally{r.isSearching=!1}},200)},B=P=>P.type==="variable"?{type:"variable",value:P.value??P.id??"",label:P.label,schema:P.schema,_uid:c(),meta:P.meta}:{type:"prompt",id:P.id??P.value??"",label:P.label,schema:P.schema,_uid:c(),meta:P.meta},F=P=>{if(r.atTriggerIndex<0||!l.value)return;const C=window.getSelection();if(!C||!C.rangeCount)return;const L=C.getRangeAt(0);if(L.startContainer.nodeType!==Node.TEXT_NODE)return;const G=L.startContainer,ee=G.data.slice(0,r.atTriggerIndex),E=G.data.slice(L.startOffset),U=document.createElement("span"),Z=B(P),se=Z.type==="prompt"&&Z.meta&&!Z.meta.isValid;U.className=`prompt-tag${se?" prompt-tag-invalid":""}`,U.setAttribute("contenteditable","false");const j=Z._uid||(Z._uid=c());U.dataset.segmentUid=j;const M=Z.type==="variable"?{type:"variable",value:Z.value,label:Z.label,schema:Z.schema}:{type:"prompt",id:Z.id,label:Z.label,schema:Z.schema};if(U.dataset.segment=encodeURIComponent(JSON.stringify(M)),U.textContent=f(Z),se){const O=document.createElement("span");O.className="prompt-tag-warning",O.textContent="⚠️",O.setAttribute("title",Z.meta.validationMessage||"Validation error"),U.appendChild(O)}const w=G.parentNode,R=document.createTextNode(E),I=document.createTextNode(ee);w.insertBefore(I,G),w.insertBefore(U,G),w.insertBefore(R,G),w.removeChild(G),x(),b({target:l.value});const le=window.getSelection();if(le){const O=document.createRange();O.setStart(R,0),O.collapse(!0),le.removeAllRanges(),le.addRange(O)}l.value.focus()},T=P=>{if((P.key==="ArrowLeft"||P.key==="ArrowRight")&&setTimeout(()=>m(),0),r.dialogOpen)P.key==="ArrowDown"?(P.preventDefault(),r.selectedIndex=Math.min(r.selectedIndex+1,r.searchResults.length-1)):P.key==="ArrowUp"?(P.preventDefault(),r.selectedIndex=Math.max(r.selectedIndex-1,0)):P.key==="Enter"?(P.preventDefault(),r.searchResults[r.selectedIndex]&&F(r.searchResults[r.selectedIndex])):(P.key==="Escape"||P.key==="Esc")&&(P.preventDefault(),x());else if(P.key==="Backspace"||P.key==="Delete"){const C=g();if(P.key==="Backspace"){const L=window.getSelection();if(L&&L.rangeCount){const G=L.getRangeAt(0);if(G.collapsed&&G.startContainer.nodeType===Node.TEXT_NODE&&G.startOffset===0){let ee=G.startContainer;for(;ee&&ee!==l.value;){const E=ee.previousSibling;if(E&&E.nodeType===Node.ELEMENT_NODE&&E.classList?.contains("prompt-tag")){P.preventDefault(),E.parentNode?.removeChild(E),b({target:l.value});return}ee=ee.parentNode}}}}if(!C)return;if(P.key==="Backspace"&&C.offset===0&&C.segmentIndex>0)r.segments[C.segmentIndex-1].type!=="string"&&(P.preventDefault(),r.segments.splice(C.segmentIndex-1,1),p(),oe(),d());else if(P.key==="Delete"&&C.segmentIndex<r.segments.length-1){const L=r.segments[C.segmentIndex];L.type==="string"&&(L.value?.length??0)===C.offset&&r.segments[C.segmentIndex+1].type!=="string"&&(P.preventDefault(),r.segments.splice(C.segmentIndex+1,1),p(),oe(),d())}}},$=P=>{P.preventDefault();const C=P.clipboardData?.getData("text/plain")||"";document.execCommand("insertText",!1,C)},K=P=>{if(!r.dialogOpen)return;const C=u.value;C&&(C.contains(P.target)||x())},oe=()=>{r.ignoreNextWatch=!0;const P=r.segments.map(C=>{const{_uid:L,...G}=C||{};return G});i("update:modelValue",P)},te=()=>{const P=window.getSelection();if(!P||!l.value)return;const C=P.anchorNode;C&&l.value.contains(C)&&m()},H=P=>{(P.key==="Escape"||P.key==="Esc")&&r.dialogOpen&&(P.preventDefault(),x())};return Me(()=>{s.modelValue&&s.modelValue.length&&(r.segments=JSON.parse(JSON.stringify(s.modelValue))),d(),document.addEventListener("mousedown",K),document.addEventListener("selectionchange",te),document.addEventListener("keydown",H,!0)}),Be(()=>{document.removeEventListener("mousedown",K),document.removeEventListener("selectionchange",te),document.removeEventListener("keydown",H,!0)}),fe(()=>s.modelValue,P=>{if(r.ignoreNextWatch){r.ignoreNextWatch=!1;return}P&&(r.segments=JSON.parse(JSON.stringify(P)),d())},{deep:!0}),(P,C)=>(a(),o("div",Qf,[e("div",{ref_key:"editorRef",ref:l,contenteditable:!t.disabled,onInput:b,onKeydown:T,onPaste:$,onClick:_,onKeyup:C[0]||(C[0]=L=>{L.key==="Escape"?(L.preventDefault(),x()):(L.key==="ArrowLeft"||L.key==="ArrowRight")&&m()}),onCompositionstart:C[1]||(C[1]=L=>r.isComposing=!0),onCompositionend:C[2]||(C[2]=L=>r.isComposing=!1),class:ae(["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},[Ie(e("div",null,[et(P.$slots,"segment",{segment:null},void 0,!0)],512),[[Ke,!1]])],42,Zf),r.dialogOpen?(a(),o("div",{key:0,ref_key:"dialogRef",ref:u,class:"absolute z-50",style:ot({left:`${r.dialogPosition.x}px`,top:`${r.dialogPosition.y}px`})},[A(Qe,{"offset-x":2,"offset-y":2,intensity:.3},{default:be(()=>[e("div",eh,[r.isSearching?(a(),o("div",th," Searching... ")):r.searchResults.length===0?(a(),o("div",ah," No results found ")):(a(),o("div",oh,[(a(!0),o(ve,null,ke(r.searchResults,(L,G)=>(a(),o("button",{key:L.id||L.value||G,type:"button",onClick:ee=>F(L),class:ae(["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===G?"bg-neutral-100 dark:bg-neutral-900":""])},[e("div",sh,[Ce(S(L.label||L.id||L.value)+" ",1),L.type==="prompt"&&L.meta&&!L.meta.isValid?(a(),o("span",{key:0,title:L.meta.validationMessage,class:"text-red-500"},"⚠️",8,nh)):V("",!0)]),L.description?(a(),o("div",rh,S(L.description),1)):V("",!0),L.type==="prompt"&&L.meta&&!L.meta.isValid?(a(),o("div",ih,S(L.meta.validationMessage),1)):V("",!0),e("div",dh,[e("span",{class:ae(["inline-block px-1.5 py-0.5 rounded",L.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"])},S(L.type),3)])],10,lh))),128))]))])]),_:1})],4)):V("",!0)]))}}),$a=tt(uh,[["__scopeId","data-v-7ee6148f"]]);function Ht(t,n){if(!n||!n.properties||Object.keys(n.properties).length===0)return!0;if(!t||!t.properties)return Object.keys(n.properties);const s=[],i=t.properties||{},l=n.properties||{};return(n.required||[]).forEach(r=>{r in i||s.push(r)}),Object.keys(l).forEach(r=>{!(r in i)&&!s.includes(r)&&s.push(r)}),s.length>0?s:!0}function Wt(t){return t.length===0?"":t.length===1?`Missing required field: ${t[0]}`:`Missing required fields: ${t.join(", ")}`}const ch={class:"space-y-4"},ph=me({__name:"PromptTemplate",props:{promptText:{},beforeTool:{},afterTool:{},requiredSchema:{},currentPromptName:{}},emits:["update:promptText","update:beforeTool","update:afterTool"],setup(t,{emit:n}){const s=t,i=n,l=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:""},c=J(()=>{if(!s.promptText)return[{type:"string",value:""}];let h=[];try{const b=JSON.parse(s.promptText);Array.isArray(b)?h=b.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(b=>{if(b.type==="prompt"&&b.schema){const m=Ht(_,b.schema),y=m===!0,x=y?[]:m;return{...b,meta:{isValid:y,missingFields:x,validationMessage:y?"":Wt(x)}}}return b})}),f=J(()=>{try{const h=JSON.parse(s.requiredSchema);if(h.properties&&typeof h.properties=="object")return Object.keys(h.properties)}catch{return[]}return[]}),g=async h=>{u.value=!0;try{const _=new URLSearchParams;h&&_.set("search",h);const b=await fetch(ue(`/api/prompts${_.toString()?"?"+_.toString():""}`));if(b.ok){const m=await b.json();l.value=m.prompts||[]}}catch(_){console.error("Error fetching prompts:",_)}finally{u.value=!1}},d=async h=>{const _=[];return f.value.forEach(b=>{(!h||b.toLowerCase().includes(h.toLowerCase()))&&_.push({type:"variable",value:b,label:b,description:"Schema property"})}),h!==void 0&&await g(h),l.value.forEach(b=>{if(!(s.currentPromptName&&b.name===s.currentPromptName)&&(!h||b.name.toLowerCase().includes(h.toLowerCase()))){const m=s.requiredSchema?JSON.parse(s.requiredSchema):{},y=Ht(m,b.required_schema),x=y===!0,k=x?[]:y;_.push({type:"prompt",id:b.name,label:b.name,description:b.tool_description||"Available prompt",schema:b.required_schema,meta:{isValid:x,missingFields:k,validationMessage:x?"":Wt(k)}})}}),_},p=h=>{const _=h.map(b=>{const{type:m,value:y,label:x,id:k,schema:D}=b;return m==="string"?{type:m,value:y||""}:m==="variable"?{type:m,value:y||"",label:x}:m==="prompt"?{type:m,id:k||"",label:x,schema:D}:b});i("update:promptText",JSON.stringify(_))};return Me(()=>{g()}),(h,_)=>(a(),o("div",ch,[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)),A($a,{"model-value":c.value,"onUpdate:modelValue":p,search:d,placeholder:"Enter your prompt template... Type @ to insert variables or prompts"},null,8,["model-value"])])]))}}),mh={class:"space-y-3"},vh={class:"space-y-2 pl-4 border-l-2 border-accent-200 dark:border-accent-700"},fh={class:"space-y-1"},hh={class:"space-y-1 mt-3"},gh={class:"space-y-2 pl-4 border-l-2 border-neutral-200 dark:border-neutral-700"},bh=me({__name:"PromptToolOptions",props:{toolName:{},toolConfig:{},toolType:{default:"prompt"},disabled:{type:Boolean}},emits:["update:option"],setup(t,{emit:n}){const s=t,i=n,l=v(null),u=v(!0),r=J(()=>l.value?.properties?Object.entries(l.value.properties).map(([g,d])=>({value:g,label:g,description:d.description||d.type||""})):[]),c=async()=>{try{let g=s.toolName;if(s.toolType==="handoff"||s.toolType==="subagent"){const p=await fetch(ue(`/api/agents/${encodeURIComponent(s.toolName)}`));if(p.ok){if(g=(await p.json())?.agent?.side_a_agent_prompt,!g){u.value=!1;return}}else{u.value=!1;return}}const d=await fetch(ue(`/api/prompts/${encodeURIComponent(g)}`));if(d.ok){const p=await d.json();p?.prompt?.required_schema&&(l.value=p.prompt.required_schema)}}catch(g){console.error("Error fetching prompt schema:",g)}finally{u.value=!1}};Me(()=>{c()});const f=(g,d)=>{i("update:option",g,d)};return(g,d)=>(a(),o("div",mh,[e("div",vh,[d[9]||(d[9]=e("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Initialization Options: ",-1)),e("div",fh,[d[5]||(d[5]=e("label",{class:"block text-xs font-medium text-neutral-700 dark:text-neutral-300"}," User message property ",-1)),A(Ve,{"model-value":t.toolConfig.init_user_message_property||"","onUpdate:modelValue":d[0]||(d[0]=p=>f("init_user_message_property",p||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"]),d[6]||(d[6]=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",hh,[d[7]||(d[7]=e("label",{class:"block text-xs font-medium text-neutral-700 dark:text-neutral-300"}," Attachments property ",-1)),A(Ve,{"model-value":t.toolConfig.init_attachments_property||"","onUpdate:modelValue":d[1]||(d[1]=p=>f("init_attachments_property",p||null)),placeholder:"Don't attach files",options:r.value,disabled:t.disabled||u.value||r.value.length===0,loading:u.value},null,8,["model-value","options","disabled","loading"]),d[8]||(d[8]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"},' Select which argument contains attachment path(s). Accepts a single path string or an array of paths (e.g., "/attachments/123.jpg" or ["/attachments/a.jpg", "/attachments/b.jpg"]). ',-1))])]),e("div",gh,[d[10]||(d[10]=e("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Sub-Prompt Response Options: ",-1)),A(Pe,{"model-value":t.toolConfig.include_text_response,"onUpdate:modelValue":d[2]||(d[2]=p=>f("include_text_response",p)),label:"Include text response","help-text":"Include the final text content from the sub-prompt",disabled:t.disabled},null,8,["model-value","disabled"]),A(Pe,{"model-value":t.toolConfig.include_tool_calls,"onUpdate:modelValue":d[3]||(d[3]=p=>f("include_tool_calls",p)),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"]),A(Pe,{"model-value":t.toolConfig.include_errors,"onUpdate:modelValue":d[4]||(d[4]=p=>f("include_errors",p)),label:"Include errors","help-text":"Include error information if the sub-prompt fails",disabled:t.disabled},null,8,["model-value","disabled"])])]))}}),xh={class:"space-y-4"},yh={class:"block text-sm font-medium mb-2"},kh={key:0,class:"text-red-500"},wh={class:"flex items-start justify-between"},_h={class:"flex items-center gap-2 flex-1"},$h={class:"flex-1"},Ch={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},Th={key:1,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},Sh={key:2,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},Vh={key:3,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},Mh={key:4,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},Ih={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-1"},Eh={key:1,class:"text-xs text-amber-600 dark:text-amber-400 mt-1 flex items-center gap-1"},Lh=["onClick","disabled","aria-label"],Ah={key:0,class:"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-700"},Ph={class:"space-y-2"},Dh={key:0,class:"text-xs text-amber-500 dark:text-amber-400 whitespace-nowrap",title:"Required at agent or thread level"},jh={key:1,class:"text-xs text-red-500 dark:text-red-400 mt-1"},Oh={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"},Uh=me({__name:"ToolSelectorWithOptions",props:We({label:{default:"Available Tools"},placeholder:{default:"Select a tool"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelId:{},providerId:{}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:We(["unavailable-tools"],["update:modelValue"]),setup(t,{expose:n,emit:s}){const i=t,l=st(t,"modelValue"),u=v([]),r=v([]),c=v(!1),f=v(!1),g=v(),d=J(()=>[...u.value,...r.value]),p=J(()=>new Set(d.value.map(H=>m(H)))),h=H=>(H.startsWith("provider:"),p.value.has(H)),_=J(()=>l.value.filter(H=>!h(H.name)).map(H=>H.name)),b=s;fe(_,H=>{H.length>0&&b("unavailable-tools",H)},{immediate:!0}),na(async()=>{g.value,await Te(),g.value&&l.value.length>0&&await ra({parent:g,values:l,dragHandle:".drag-handle"})});const m=H=>H.type==="provider"?`provider:${H.name}`:H.type==="mcp"?`mcp:${H.name}`:H.name,y=H=>H.startsWith("provider:")?H.slice(9):H.startsWith("mcp:")?H.slice(4):H,x=H=>H.startsWith("provider:")?"provider":H.startsWith("mcp:")?"mcp":"tool",k=J(()=>{const H=new Set(l.value.map(P=>P.name));return d.value.filter(P=>!H.has(m(P))).map(P=>{let C=P.name;return P.type==="prompt"?C=`${P.name} (prompt)`:P.type==="mcp"?C=`${P.name} (mcp)`:P.type==="provider"?C=`${P.name} (provider)`:P.type==="handoff"?C=`${P.name} (handoff agent)`:P.type==="subagent"&&(C=`${P.name} (subagent)`),{value:m(P),label:C,description:P.description}})}),D=async()=>{c.value=!0;try{const H=await ze("/tools");if(H.ok){const P=await H.json();u.value=Object.entries(P).map(([C,L])=>({name:C,description:L.description||"",type:L.type,model:L.model}))}}catch(H){console.error("Error fetching tools:",H)}finally{c.value=!1}},q=async()=>{if(!i.providerId||!i.modelId){r.value=[];return}f.value=!0;try{const H=await ze(`/providers/${i.providerId}/tools?model=${encodeURIComponent(i.modelId)}`);if(H.ok){const P=await H.json();r.value=(P.tools||[]).map(C=>({name:C.name,description:C.description||"",type:"provider",tenvs:C.tenvs||[]}))}else r.value=[]}catch(H){console.error("Error fetching provider tools:",H),r.value=[]}finally{f.value=!1}};fe([()=>i.providerId,()=>i.modelId],async([H,P])=>{H&&P?await q():r.value=[]},{immediate:!0});const B=H=>{if(!H||l.value.find(L=>L.name===H))return;const P=T(H),C={};if(P?.tenvs&&P.tenvs.length>0)for(const L of P.tenvs)C[L.name]="";l.value=[...l.value,{name:H,include_text_response:!0,include_tool_calls:!0,include_errors:!0,init_user_message_property:null,init_attachments_property:null,...Object.keys(C).length>0?{tenvs:C}:{}}]},F=H=>{l.value=l.value.filter(P=>P.name!==H)},T=H=>{const P=d.value.find(C=>m(C)===H);return P||d.value.find(C=>C.name===H)},$=(H,P,C)=>{l.value=l.value.map(L=>{if(L.name===H){const G={...L.tenvs||{},[P]:C||void 0};for(const ee of Object.keys(G))G[ee]||delete G[ee];return{...L,tenvs:Object.keys(G).length>0?G:void 0}}return L})},K=(H,P,C)=>{l.value=l.value.map(L=>L.name===H?{...L,[P]:C}:L)};return n({removeUnavailableTools:()=>{l.value=l.value.filter(H=>h(H.name))},getAvailableToolsOnly:()=>l.value.filter(H=>h(H.name)),unavailableTools:_}),Me(()=>{D()}),(H,P)=>(a(),o("div",xh,[e("div",null,[e("label",yh,[Ce(S(t.label)+" ",1),t.required?(a(),o("span",kh,"*")):V("",!0)]),l.value.length>0?(a(),o("div",{key:0,class:"space-y-3 mb-4",ref_key:"dragAreaRef",ref:g},[(a(!0),o(ve,null,ke(l.value,C=>(a(),o("div",{key:C.name,class:ae(["border rounded-lg p-4 transition-colors",h(C.name)?"border-neutral-300 dark:border-neutral-600":"border-amber-300 dark:border-amber-700 bg-amber-50 dark:bg-amber-900/20 opacity-75"])},[e("div",wh,[e("div",_h,[e("div",{class:ae(["drag-handle",h(C.name)?"cursor-move text-neutral-400 hover:text-neutral-600 dark:text-neutral-600 dark:hover:text-neutral-400":"cursor-not-allowed text-neutral-300 dark:text-neutral-700"])},[...P[0]||(P[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:"M4 8h16M4 16h16"})],-1)])],2),e("div",$h,[e("h4",{class:ae(["font-medium text-sm",!h(C.name)&&"text-neutral-500 dark:text-neutral-400"])},[Ce(S(y(C.name))+" ",1),x(C.name)==="provider"?(a(),o("span",Ch,"(provider)")):x(C.name)==="mcp"?(a(),o("span",Th,"(mcp)")):T(C.name)?.type==="prompt"?(a(),o("span",Sh,"(prompt)")):T(C.name)?.type==="handoff"?(a(),o("span",Vh,"(handoff agent)")):T(C.name)?.type==="subagent"?(a(),o("span",Mh,"(subagent)")):V("",!0)],2),T(C.name)?.description?(a(),o("p",Ih,S(T(C.name)?.description),1)):V("",!0),h(C.name)?V("",!0):(a(),o("p",Eh,[...P[1]||(P[1]=[e("svg",{class:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})],-1),Ce(" Not available for selected model - will be removed on save ",-1)])]))])]),e("button",{onClick:L=>F(C.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 ${y(C.name)}`},[...P[2]||(P[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:"M6 18L18 6M6 6l12 12"})],-1)])],8,Lh)]),T(C.name)?.type==="provider"&&T(C.name)?.tenvs?.length?(a(),o("div",Ah,[P[3]||(P[3]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 mb-2 font-medium"},[Ce(" Environment Variables "),e("span",{class:"text-neutral-400"},"(optional at prompt level)")],-1)),e("div",Ph,[(a(!0),o(ve,null,ke(T(C.name)?.tenvs,L=>(a(),o("div",{key:L.name,class:"flex items-center gap-2"},[A(Le,{"model-value":C.tenvs?.[L.name]||"","onUpdate:modelValue":G=>$(C.name,L.name,G),label:L.name,placeholder:L.description||"Enter value...",disabled:t.disabled,size:"sm",class:"flex-1"},null,8,["model-value","onUpdate:modelValue","label","placeholder","disabled"]),L.required?(a(),o("span",Dh," required* ")):V("",!0)]))),128))])])):V("",!0),T(C.name)?.type==="prompt"||T(C.name)?.type==="handoff"||T(C.name)?.type==="subagent"?(a(),ne(bh,{key:1,"tool-name":C.name,"tool-config":C,"tool-type":T(C.name)?.type,disabled:t.disabled,"onUpdate:option":(L,G)=>K(C.name,L,G)},null,8,["tool-name","tool-config","tool-type","disabled","onUpdate:option"])):V("",!0)],2))),128))],512)):V("",!0),A(Ve,{"model-value":"","onUpdate:modelValue":B,placeholder:l.value.length>0?"Add another tool...":t.placeholder,"search-placeholder":"Search tools...",options:k.value,disabled:t.disabled||c.value||k.value.length===0,loading:c.value},null,8,["placeholder","options","disabled","loading"]),t.error?(a(),o("p",jh,S(t.error),1)):V("",!0)]),l.value.length===0&&!c.value&&k.value.length===0?(a(),o("div",Oh," No tools available. Create tools in your agentbuilder/tools directory. ")):V("",!0)]))}}),Rh={key:0,class:"min-h-[400px] flex items-center justify-center"},Nh={key:1,class:"space-y-6 pr-2 pb-4"},Fh={class:"space-y-4"},Bh={class:"space-y-4"},qh={class:"flex justify-between"},zh={class:"flex gap-2"},Hh=["disabled"],Ca=me({__name:"PromptModal",props:{modelValue:{type:Boolean},editPrompt:{},mode:{}},emits:["update:modelValue","save"],setup(t,{emit:n}){const s=t,i=n,l=J(()=>s.mode==="edit"),u=v(!1),r=J(()=>k.value.length===1),c=v(""),f=v(null),g=v(""),d=v(""),p=v(""),h=v({type:"object",properties:{},required:[],additionalProperties:!1}),_=v(""),b=v(!1),m=v(!1),y=v(""),x=v(""),k=v([]),D=v(!1),q=v(null),B=v("auto"),F=v(null),T=v(null),$=v(!1),K=v(!1),oe=J({get:()=>F.value||"",set:ee=>F.value=ee||null}),te=J({get:()=>B.value,set:ee=>B.value=ee}),H=()=>{g.value="",c.value="",d.value="",p.value="",f.value=null,h.value={type:"object",properties:{},required:[],additionalProperties:!1},_.value="",b.value=!1,m.value=!1,y.value="",x.value="",k.value=[],D.value=!1,B.value="auto",F.value=null,T.value=null,$.value=!1,K.value=!1},P=async ee=>{if(!ee){f.value=null;return}try{const E=await ze(`/models/${ee}`);if(E.ok){const U=await E.json();f.value=U.model||U}}catch(E){console.error("Error fetching model info:",E),f.value=null}};fe(p,async ee=>{ee?await P(ee):f.value=null});const C=async()=>{if(s.editPrompt?.id){u.value=!0;try{const ee=await ze(`/prompts/${s.editPrompt.id}`);if(ee.ok){const E=await ee.json(),U=E.prompt||E;g.value=U.name||"",c.value=U.name||"",d.value=U.tool_description||"",p.value=U.model_id||"",U.model_id&&await P(U.model_id);let Z=U.required_schema;if(typeof Z=="string")try{Z=JSON.parse(Z)}catch{Z=null}h.value=Z||{type:"object",properties:{},required:[],additionalProperties:!1},_.value=U.prompt||"",b.value=U.include_chat||!1,m.value=U.include_past_tools||!1,y.value=U.before_tool||"",x.value=U.after_tool||"";const se=U.tools||[];k.value=se.map(M=>typeof M=="string"?{name:M,include_text_response:!0,include_tool_calls:!0,include_errors:!0,init_user_message_property:null}:M),D.value=U.parallel_tool_calls||!1,B.value=U.tool_choice||"auto";const j=U.reasoning||{};F.value=j.effort||U.reasoning_effort||null,T.value=j.maxTokens||U.reasoning_max_tokens||null,$.value=j.exclude||U.reasoning_exclude||!1,K.value=j.include||U.include_reasoning||!1}}catch(ee){console.error("Error loading prompt data:",ee)}finally{u.value=!1}}},L=async()=>{const ee=/^[a-z][a-z0-9_]*$/;if(!g.value||!ee.test(g.value)){alert("Please enter a valid name (lowercase letters, numbers, and underscores only, must start with a letter)");return}if(!d.value){alert("Please enter a description");return}if(!p.value){alert("Please select a model");return}if(!_.value){alert("Please enter the prompt template");return}q.value?.removeUnavailableTools();const E={name:g.value,tool_description:d.value,prompt:_.value,required_schema:h.value,model_id:p.value,include_chat:b.value,include_past_tools:m.value,before_tool:y.value||null,after_tool:x.value||null,parallel_tool_calls:D.value,tool_choice:B.value,tools:k.value,reasoning_effort:F.value,reasoning_max_tokens:T.value,reasoning_exclude:$.value,include_reasoning:K.value};l.value&&s.editPrompt?.id&&(E.id=s.editPrompt.id,c.value&&c.value!==g.value&&(E.originalName=c.value)),i("save",E),H(),i("update:modelValue",!1)},G=()=>{H(),i("update:modelValue",!1)};return fe(()=>k.value.length,ee=>{B.value==="function"&&ee!==1&&(B.value="auto")}),fe(()=>s.modelValue,async ee=>{ee&&(l.value?(H(),await Te(),await C()):H())}),fe(()=>s.editPrompt,async ee=>{ee&&l.value&&s.modelValue&&(await Te(),await C())},{immediate:!0}),(ee,E)=>(a(),ne(He,{"model-value":t.modelValue,"onUpdate:modelValue":E[16]||(E[16]=U=>ee.$emit("update:modelValue",U)),title:l.value?"Edit Prompt":"Add Prompt",width:"max-w-4xl"},{footer:be(()=>[e("div",qh,[e("button",{onClick:G,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",zh,[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},S(l.value?"Update Prompt":"Create Prompt"),9,Hh)])])]),default:be(()=>[u.value?(a(),o("div",Rh,[...E[17]||(E[17]=[e("span",{class:"text-neutral-500"},"Loading prompt data...",-1)])])):(a(),o("div",Nh,[e("div",null,[A(df,{name:g.value,"onUpdate:name":E[0]||(E[0]=U=>g.value=U),"tool-description":d.value,"onUpdate:toolDescription":E[1]||(E[1]=U=>d.value=U)},null,8,["name","tool-description"])]),e("div",null,[A(cf,{modelValue:p.value,"onUpdate:modelValue":E[2]||(E[2]=U=>p.value=U)},null,8,["modelValue"])]),e("div",null,[A(_a,{modelValue:h.value,"onUpdate:modelValue":E[3]||(E[3]=U=>h.value=U),label:"Required Schema (Optional)"},null,8,["modelValue"])]),e("div",null,[A(ph,{"prompt-text":_.value,"onUpdate:promptText":E[4]||(E[4]=U=>_.value=U),"before-tool":y.value,"onUpdate:beforeTool":E[5]||(E[5]=U=>y.value=U),"after-tool":x.value,"onUpdate:afterTool":E[6]||(E[6]=U=>x.value=U),"required-schema":JSON.stringify(h.value,null,2),"current-prompt-name":l.value?g.value:void 0},null,8,["prompt-text","before-tool","after-tool","required-schema","current-prompt-name"])]),e("div",null,[A(Uh,{ref_key:"toolSelectorRef",ref:q,modelValue:k.value,"onUpdate:modelValue":E[7]||(E[7]=U=>k.value=U),"provider-id":f.value?.provider_id||f.value?.provider,"model-id":f.value?.model},null,8,["modelValue","provider-id","model-id"])]),e("div",Fh,[E[19]||(E[19]=e("h3",{class:"text-sm font-medium text-neutral-900 dark:text-neutral-100"}," Tool Configuration ",-1)),e("div",null,[A(Pe,{modelValue:D.value,"onUpdate:modelValue":E[8]||(E[8]=U=>D.value=U),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,[A(Ve,{modelValue:te.value,"onUpdate:modelValue":E[9]||(E[9]=U=>te.value=U),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(U=>U.value!=="function"||r.value),placeholder:"Select tool choice"},null,8,["modelValue","options"]),E[18]||(E[18]=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",Bh,[E[23]||(E[23]=e("h3",{class:"text-sm font-medium text-neutral-900 dark:text-neutral-100"}," Context & Reasoning Configuration ",-1)),e("div",null,[A(Pe,{modelValue:b.value,"onUpdate:modelValue":E[10]||(E[10]=U=>b.value=U),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,[A(Pe,{modelValue:m.value,"onUpdate:modelValue":E[11]||(E[11]=U=>m.value=U),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,[A(Pe,{modelValue:K.value,"onUpdate:modelValue":E[12]||(E[12]=U=>K.value=U),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"])]),E[24]||(E[24]=e("hr",{class:"border-neutral-300 dark:border-neutral-600"},null,-1)),E[25]||(E[25]=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,[A(Ve,{modelValue:oe.value,"onUpdate:modelValue":E[13]||(E[13]=U=>oe.value=U),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"]),E[20]||(E[20]=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,[E[21]||(E[21]=e("label",{class:"block text-sm font-medium text-neutral-700 dark:text-neutral-300 mb-2"}," Max Reasoning Tokens ",-1)),Ie(e("input",{"onUpdate:modelValue":E[14]||(E[14]=U=>T.value=U),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,T.value,void 0,{number:!0}]]),E[22]||(E[22]=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,[A(Pe,{modelValue:$.value,"onUpdate:modelValue":E[15]||(E[15]=U=>$.value=U),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"]))}}),Wh=me({__name:"PromptsView",setup(t){const n=lt(),s=Ye(),i=v(!1),l=v(null);fe(()=>s.query.refresh,()=>{s.query.refresh&&(l.value?.refresh(),n.replace({path:"/prompts",query:{}}))});const u=()=>{i.value=!0},r=f=>{n.push(`/prompts/${f.id}`)},c=async f=>{try{const g=await fetch(ue("/api/prompts"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(g.ok)i.value=!1,await new Promise(d=>setTimeout(d,100)),await l.value?.refresh();else{const d=await g.json();alert(d.error||"Failed to create prompt")}}catch(g){console.error("Error creating prompt:",g),alert("Failed to create prompt")}};return(f,g)=>(a(),ne(at,null,{default:be(()=>[e("div",{class:"flex justify-between items-center mb-6"},[g[1]||(g[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 ")]),g[2]||(g[2]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-6"}," Define and manage prompt templates for your agents. ",-1)),A(af,{ref_key:"dataTableRef",ref:l,onAdd:u,onEdit:r},null,512),A(Ca,{modelValue:i.value,"onUpdate:modelValue":g[0]||(g[0]=d=>i.value=d),mode:"add",onSave:c},null,8,["modelValue"])]),_:1}))}}),Jh={class:"p-8"},Kh={key:0,class:"flex items-center justify-center min-h-[400px]"},Gh={key:2,class:"flex items-center justify-center min-h-[400px]"},Xh=me({__name:"PromptEditView",setup(t){const n=lt(),s=Ye(),i=v(!0),l=v(null),u=v(!0),r=async()=>{const g=s.params.id;if(!g){n.push("/prompts");return}u.value=!0;try{const d=await fetch(ue(`/api/prompts/${g}`));if(d.ok){const p=await d.json();l.value=p.prompt||p}else alert("Prompt not found"),n.push("/prompts")}catch(d){console.error("Error loading prompt:",d),alert("Failed to load prompt"),n.push("/prompts")}finally{u.value=!1}},c=async g=>{try{const{originalName:d,...p}=g,h=d||p.id,_=await fetch(ue(`/api/prompts/${h}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});if(_.ok)n.push({path:"/prompts",query:{refresh:Date.now().toString()}});else{const b=await _.json();alert(b.error||"Failed to update prompt")}}catch(d){console.error("Error updating prompt:",d),alert("Failed to update prompt")}},f=g=>{g||n.push("/prompts")};return Me(()=>{r()}),fe(i,g=>{g||n.push("/prompts")}),(g,d)=>(a(),o("div",Jh,[u.value?(a(),o("div",Kh,[...d[1]||(d[1]=[e("span",{class:"text-neutral-500"},"Loading prompt...",-1)])])):l.value?(a(),ne(Ca,{key:1,modelValue:i.value,"onUpdate:modelValue":[d[0]||(d[0]=p=>i.value=p),f],mode:"edit","edit-prompt":l.value,onSave:c},null,8,["modelValue","edit-prompt"])):(a(),o("div",Gh,[...d[2]||(d[2]=[e("span",{class:"text-neutral-500"},"Prompt not found",-1)])]))]))}}),Yh={class:"border-2 border-black dark:border-neutral-300 rounded-lg overflow-hidden"},Qh={key:0,class:"px-4 py-2 border-b-2 border-black dark:border-neutral-300 bg-neutral-50 dark:bg-neutral-900"},Zh={class:"flex items-center justify-between"},eg={class:"text-sm font-medium"},tg={class:"flex items-center gap-2"},ag={key:1,class:"px-4 py-8 flex items-center justify-center"},og={key:2,class:"px-4 py-8 text-center text-neutral-500"},lg={key:3,class:"divide-y divide-neutral-200 dark:divide-neutral-700"},sg=["onClick"],ng={class:"flex items-start gap-3"},rg={class:"flex-shrink-0 mt-0.5"},ig=["checked","onClick"],dg={class:"flex-1 min-w-0"},ug={class:"flex items-center gap-2"},cg={class:"text-sm font-medium"},pg={key:0,class:"text-xs px-1.5 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded"},mg={class:"mt-1 text-xs text-neutral-600 dark:text-neutral-400 space-y-0.5"},vg={key:0},fg={key:0},hg={key:1},gg={key:2},bg=me({__name:"ExposedSelectList",props:{providers:{default:()=>[]},modelValue:{default:()=>[]},label:{},loading:{type:Boolean}},emits:["update:modelValue"],setup(t,{emit:n}){function s(d){if(d===0)return"$0.00";const p=Math.abs(d);let h;return p<1e-4?h=p.toExponential(3):p<.001||p<.01||p<.1?h=p.toFixed(4):p<1?h=p.toFixed(3):p<10||p<100?h=p.toFixed(2):p<1e3?h=p.toFixed(1):h=p.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:0}),h.includes(".")&&(h=h.replace(/\.?0+$/,""),!h.includes(".")&&p<100&&(h=p.toFixed(2))),d<0?`-$${h}`:`$${h}`}const i=t,l=n,u=d=>i.modelValue.includes(d),r=d=>{const p=[...i.modelValue],h=p.indexOf(d);h>-1?p.splice(h,1):p.push(d),l("update:modelValue",p)},c=()=>{l("update:modelValue",i.providers.map(d=>d.id))},f=()=>{l("update:modelValue",[])},g=J(()=>i.providers.length>0&&i.modelValue.length===i.providers.length);return J(()=>i.modelValue.length>0&&i.modelValue.length<i.providers.length),(d,p)=>(a(),o("div",Yh,[t.label?(a(),o("div",Qh,[e("div",Zh,[e("span",eg,S(t.label),1),e("div",tg,[e("button",{type:"button",onClick:p[0]||(p[0]=h=>g.value?f():c()),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"},S(g.value?"Deselect All":"Select All"),1)])])])):V("",!0),t.loading?(a(),o("div",ag,[...p[1]||(p[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?(a(),o("div",og," No providers available ")):(a(),o("div",lg,[(a(!0),o(ve,null,ke(t.providers,h=>(a(),o("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",ng,[e("div",rg,[e("input",{type:"checkbox",checked:u(h.id),onClick:Ee(_=>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,ig)]),e("div",dg,[e("div",ug,[e("span",cg,S(h.name),1),h.quantization?(a(),o("span",pg,S(h.quantization),1)):V("",!0)]),e("div",mg,[e("div",null,S(s(h.pricing.prompt*1e6))+"/M input • "+S(s(h.pricing.completion*1e6))+"/M output ",1),h.maxPromptTokens||h.maxCompletionTokens?(a(),o("div",vg,[h.maxPromptTokens?(a(),o("span",fg," Max prompt: "+S(h.maxPromptTokens.toLocaleString())+" tokens ",1)):V("",!0),h.maxPromptTokens&&h.maxCompletionTokens?(a(),o("span",hg," • ")):V("",!0),h.maxCompletionTokens?(a(),o("span",gg," Max completion: "+S(h.maxCompletionTokens.toLocaleString())+" tokens ",1)):V("",!0)])):V("",!0)])])])],8,sg))),128))]))]))}}),xg={class:"space-y-2"},yg={key:0,class:"space-y-2"},kg={key:0,class:"block text-sm font-medium"},wg={key:0,class:"text-red-500"},_g=["src","alt"],$g={class:"flex-1 text-sm"},Cg={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 ml-1"},Tg=["onClick","aria-label"],Sg={key:1,class:"text-xs text-red-500 dark:text-red-400"},Ct=me({__name:"MultipleSelectionsInput",props:We({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:We(["removeItem"],["update:modelValue"]),setup(t,{emit:n}){const s=t,i=n,l=st(t,"modelValue"),u=v();na(async()=>{u.value,await Te(),await ra({parent:u,values:l,dragHandle:".drag-handle"})});const r=J(()=>Array.isArray(l.value)?l.value.length>0&&typeof l.value[0]=="object"?l.value:l.value.map(d=>{const p=s.options.find(h=>h.value===d);return{id:d,label:p?.label||d,description:p?.description,icon:p?.icon}}):[]),c=J(()=>{const d=r.value.map(p=>p.id);return s.options.filter(p=>!d.includes(p.value))}),f=d=>{if(!d)return;const p=s.options.find(h=>h.value===d);if(p)if(l.value.length===0||typeof l.value[0]=="string")l.value=[...l.value,d];else{const h={id:d,label:p.label,description:p.description,icon:p.icon};l.value=[...l.value,h]}},g=d=>{typeof l.value[0]=="string"?l.value=l.value.filter(p=>p!==d):l.value=l.value.filter(p=>p.id!==d),i("removeItem",d)};return(d,p)=>(a(),o("div",xg,[r.value.length>0?(a(),o("div",yg,[t.label?(a(),o("label",kg,[Ce(S(t.label)+" ",1),t.required?(a(),o("span",wg,"*")):V("",!0)])):V("",!0),e("div",{class:"space-y-1",ref_key:"dragAreaRef",ref:u},[(a(!0),o(ve,null,ke(r.value,h=>(a(),o("div",{key:h.id,class:ae(["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":""])},[p[1]||(p[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?(a(),o("img",{key:0,src:h.icon,alt:h.label,class:"w-4 h-4 flex-shrink-0"},null,8,_g)):V("",!0),e("span",$g,[Ce(S(h.label)+" ",1),h.description?(a(),o("span",Cg," ("+S(h.description)+") ",1)):V("",!0)]),t.disabled?V("",!0):(a(),o("button",{key:1,onClick:_=>g(h.id),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors","aria-label":`Remove ${h.label}`},[...p[0]||(p[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,Tg))],2))),128))],512)])):V("",!0),A(Ve,{"model-value":"","onUpdate:modelValue":f,label:r.value.length>0?t.addLabel:t.label,options:c.value,placeholder:t.placeholder,"search-placeholder":t.searchPlaceholder,disabled:t.disabled||c.value.length===0,loading:t.loading},null,8,["label","options","placeholder","search-placeholder","disabled","loading"]),t.error?(a(),o("p",Sg,S(t.error),1)):V("",!0)]))}}),Vg={key:2,class:"text-xs text-red-500 dark:text-red-400 mt-1"},Mg=me({__name:"ModelSelectorInput",props:We({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 n=t,s=st(t,"modelValue"),i=v([]),l=v(!1),u=J(()=>i.value.map(f=>({value:f.id,label:f.name,description:f.provider_id||f.provider,icon:f.iconId}))),r=async()=>{l.value=!0;try{const f=await fetch(ue("/api/models"));if(f.ok){const g=await f.json();i.value=g.models||[]}}catch(f){console.error("Error fetching models:",f)}finally{l.value=!1}},c=f=>{};return Me(()=>{r()}),fe(()=>n.allowMultiple,()=>{n.allowMultiple&&typeof s.value=="string"?s.value=s.value?[s.value]:[]:!n.allowMultiple&&Array.isArray(s.value)&&(s.value=s.value[0]||"")}),(f,g)=>(a(),o(ve,null,[t.allowMultiple?(a(),ne(Ct,{key:0,modelValue:s.value,"onUpdate:modelValue":g[0]||(g[0]=d=>s.value=d),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search models...",error:t.error,required:t.required,disabled:t.disabled,options:u.value,loading:l.value,"add-label":"Add another model",onRemoveItem:c},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(a(),ne(Ve,{key:1,modelValue:s.value,"onUpdate:modelValue":g[1]||(g[1]=d=>s.value=d),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search models...",options:u.value,disabled:t.disabled,loading:l.value},null,8,["modelValue","label","placeholder","options","disabled","loading"])),!t.allowMultiple&&t.error?(a(),o("p",Vg,S(t.error),1)):V("",!0)],64))}}),Ig={class:"space-y-4"},Eg={key:0},Lg={key:1},Ag=["value"],Pg={key:0,class:"mt-1 text-xs text-red-500"},Dg={key:1,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},jg={class:"px-1 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded"},Og={key:2,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Ug={key:2,class:"space-y-3"},Rg={class:"flex items-center justify-between"},Ng={key:0,class:"text-sm text-neutral-500 dark:text-neutral-400"},Fg={key:1,class:"space-y-2"},Bg={class:"grid grid-cols-2 gap-x-4 gap-y-2"},qg={class:"grid grid-cols-2 gap-4 pt-2"},zg={key:3,class:"space-y-3"},Hg={key:0,class:"text-sm text-neutral-500 dark:text-neutral-400"},Wg={key:1,class:"space-y-2"},Jg={class:"grid grid-cols-1 gap-2"},Kg=["value"],Gg={class:"flex-1 min-w-0"},Xg={class:"font-medium text-sm"},Yg={class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},Qg={key:0,class:"mt-1"},Zg={class:"text-xs text-amber-600 dark:text-amber-400"},eb={key:4},tb={key:5},ab={class:"flex justify-end gap-2"},ob=["disabled"],lb=me({__name:"ModelModal",props:{modelValue:{type:Boolean},editModel:{},mode:{default:"add"}},emits:["update:modelValue","save"],setup(t,{emit:n}){const s=t,i=n,l=v([]),u=v(""),r=v(""),c=v([]),f=v(!1),g=v(!1),d=v([]),p=v([]),h=v(!1),_=v({supportsImages:!1,supportsToolCalls:!0,supportsStreaming:!0,supportsJsonMode:!0}),b=v(null),m=v(!1),y=v([]),x=v([]),k=v(!1),D=v([]),q=J(()=>s.mode==="edit"),B=v(""),F=v(""),T=v(""),$=O=>{let W=O.replace(/[^a-zA-Z0-9\s_-]/g,"");return W=W.trim().toLowerCase().replace(/[\s-]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),W?/^[a-z][a-z0-9_]*$/.test(W)?T.value="":T.value="Name must start with a letter and contain only lowercase letters, numbers, and underscores":T.value="Name is required",W},K=O=>{const W=O.target.value;F.value=$(W)},oe=v(!1),te=v(null),H=J(()=>l.value.filter(O=>O.hasApiKey).map(O=>({value:O.name,label:O.name,description:O.sdk==="openai-sdk"?"OpenAI SDK":O.sdk==="openrouter"?"OpenRouter":O.sdk,icon:O.iconId}))),P=J(()=>c.value.map(O=>({...O,icon:O.iconId}))),C=J(()=>!q.value||!te.value||oe.value?!1:F.value!==te.value.name||u.value!==te.value.provider||r.value!==te.value.model||JSON.stringify(p.value.sort())!==JSON.stringify(te.value.endpoints.sort())||JSON.stringify(D.value)!==JSON.stringify(te.value.fallbacks)||JSON.stringify(_.value)!==JSON.stringify(te.value.capabilities)||JSON.stringify(x.value.sort())!==JSON.stringify(te.value.providerTools.sort())),L=J(()=>l.value.find(W=>W.name===u.value)?.sdk==="openrouter"),G=async()=>{f.value=!0;try{const O=await fetch(ue("/api/providers"));if(O.ok){const W=await O.json();l.value=W.providers||[]}}catch(O){console.error("Error fetching providers:",O)}finally{f.value=!1}},ee=async()=>{if(!u.value){c.value=[];return}g.value=!0;try{const O=await fetch(ue("/api/models/available"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:u.value})});if(O.ok){const W=await O.json();c.value=W.models||[]}else{const W=await O.json();console.error("Error fetching models:",W),c.value=[],alert(W.error||"Failed to fetch available models")}}catch(O){console.error("Error fetching models:",O),c.value=[]}finally{g.value=!1}},E=async()=>{if(!(!u.value||!r.value)){m.value=!0;try{const O=await fetch(ue("/api/models/capabilities"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:u.value,modelId:r.value})});if(O.ok){const W=await O.json();W.capabilities&&(b.value=W.capabilities,_.value={supportsImages:W.capabilities.supportsImages??!1,supportsToolCalls:W.capabilities.supportsToolCalls??!0,supportsStreaming:W.capabilities.supportsStreaming??!0,supportsJsonMode:W.capabilities.supportsJsonMode??!0,maxContextTokens:W.capabilities.maxContextTokens,maxOutputTokens:W.capabilities.maxOutputTokens})}}catch(O){console.error("Error fetching capabilities:",O)}finally{m.value=!1}}},U=async()=>{if(!u.value||!r.value){y.value=[];return}k.value=!0;try{const O=await fetch(ue(`/api/providers/${u.value}/tools?model=${encodeURIComponent(r.value)}`));if(O.ok){const W=await O.json();y.value=W.tools||[],q.value||(x.value=y.value.map(ce=>ce.name))}else y.value=[]}catch(O){console.error("Error fetching provider tools:",O),y.value=[]}finally{k.value=!1}},Z=()=>{_.value={supportsImages:!1,supportsToolCalls:!0,supportsStreaming:!0,supportsJsonMode:!0},b.value=null},se=()=>{b.value&&(_.value={supportsImages:b.value.supportsImages??!1,supportsToolCalls:b.value.supportsToolCalls??!0,supportsStreaming:b.value.supportsStreaming??!0,supportsJsonMode:b.value.supportsJsonMode??!0,maxContextTokens:b.value.maxContextTokens,maxOutputTokens:b.value.maxOutputTokens})},j=()=>{F.value="",B.value="",u.value="",r.value="",c.value=[],D.value=[],d.value=[],p.value=[],y.value=[],x.value=[],Z(),te.value=null,oe.value=!1},M=async()=>{if(s.editModel){oe.value=!0;try{await G(),F.value=s.editModel.name||"",B.value=s.editModel.name||"",u.value=s.editModel.provider_id||s.editModel.provider,await ee(),r.value=s.editModel.model,await R(),s.editModel.included_providers&&s.editModel.included_providers.length>0&&(p.value=s.editModel.included_providers),await w(),s.editModel.capabilities?_.value={supportsImages:s.editModel.capabilities.supportsImages??!1,supportsToolCalls:s.editModel.capabilities.supportsToolCalls??!0,supportsStreaming:s.editModel.capabilities.supportsStreaming??!0,supportsJsonMode:s.editModel.capabilities.supportsJsonMode??!0,maxContextTokens:s.editModel.capabilities.maxContextTokens,maxOutputTokens:s.editModel.capabilities.maxOutputTokens}:await E(),await U(),s.editModel.providerTools&&Array.isArray(s.editModel.providerTools)&&(x.value=s.editModel.providerTools),te.value={name:F.value,provider:u.value,model:r.value,endpoints:[...p.value],fallbacks:[...D.value],capabilities:{..._.value},providerTools:[...x.value]}}finally{oe.value=!1}}};fe(()=>s.modelValue,async O=>{O?q.value&&s.editModel?await M():(await G(),j()):j()});const w=async()=>{if(s.editModel?.id){if(s.editModel.fallbacks&&Array.isArray(s.editModel.fallbacks)){D.value=s.editModel.fallbacks.map(O=>typeof O=="string"?O:O.id);return}try{const O=await fetch(ue(`/api/models/${s.editModel.id}/fallbacks`));if(O.ok){const W=await O.json();D.value=W.fallbacks.map(ce=>ce.fallback_model_id)}}catch(O){console.error("Error loading fallbacks:",O)}}};fe(u,async(O,W)=>{oe.value||q.value&&!W&&O===(s.editModel?.provider_id||s.editModel?.provider)||(r.value="",d.value=[],p.value=[],u.value&&await ee())});const R=async()=>{if(!r.value||!u.value){d.value=[];return}const O=l.value.find(ce=>ce.name===u.value);if(!O||O.sdk!=="openrouter"){d.value=[];return}const W=P.value.find(ce=>ce.value===r.value);if(!W?.slug){console.error("Model slug not found"),d.value=[];return}h.value=!0;try{const ce=await fetch(ue("/api/models/endpoints"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:u.value,modelSlug:W.slug})});if(ce.ok){const z=await ce.json();d.value=z.endpoints||[],q.value||(p.value=d.value.map(N=>N.id))}else{const z=await ce.json();console.error("Error fetching endpoints:",z),d.value=[]}}catch(ce){console.error("Error fetching endpoints:",ce),d.value=[]}finally{h.value=!1}};fe(r,async(O,W)=>{oe.value||q.value&&!W&&O===s.editModel?.model||(r.value?(await R(),await E(),await U(),W&&O!==W&&(p.value=d.value.map(ce=>ce.id))):(d.value=[],p.value=[],y.value=[],x.value=[],Z()))});const I=()=>{if(!u.value||!r.value){alert("Please select a provider and model");return}if(!F.value){alert("Please enter a name for the model");return}if(T.value){alert(T.value);return}const O=L.value?p.value:[],W={name:F.value,model:r.value,provider:u.value,included_providers:O,fallbacks:D.value,capabilities:_.value,providerTools:x.value};q.value&&s.editModel?.id&&(W.id=s.editModel.id,B.value&&B.value!==F.value&&(W.originalName=B.value)),i("save",W)},le=()=>{j(),i("update:modelValue",!1)};return(O,W)=>(a(),ne(He,{"model-value":t.modelValue,"onUpdate:modelValue":W[11]||(W[11]=ce=>O.$emit("update:modelValue",ce)),title:q.value?"Edit Model":"Add Model",width:"max-w-2xl","min-height":"min-h-[36rem]","has-changes":C.value},{footer:be(()=>[e("div",ab,[e("button",{onClick:le,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:I,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},S(q.value?"Update Model":"Add Model"),9,ob)])]),default:be(()=>[e("div",Ig,[A(Ve,{modelValue:u.value,"onUpdate:modelValue":W[0]||(W[0]=ce=>u.value=ce),options:H.value,label:"Provider",placeholder:"Select a provider",disabled:f.value||q.value&&!!s.editModel},null,8,["modelValue","options","disabled"]),u.value?(a(),o("div",Eg,[A(Ve,{modelValue:r.value,"onUpdate:modelValue":W[1]||(W[1]=ce=>r.value=ce),options:P.value,label:"Model",placeholder:"Select a model","search-placeholder":"Search models...",loading:g.value},null,8,["modelValue","options","loading"])])):V("",!0),r.value?(a(),o("div",Lg,[W[13]||(W[13]=e("label",{class:"block text-sm font-medium mb-2"},"Name",-1)),e("input",{value:F.value,onInput:K,type:"text",class:ae(["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",T.value?"border-red-500":"border-neutral-300 dark:border-neutral-600"]),placeholder:"e.g., coding_model, planning_model, fast_response"},null,42,Ag),T.value?(a(),o("p",Pg,S(T.value),1)):F.value?(a(),o("p",Dg,[W[12]||(W[12]=Ce(" Will be saved as: ",-1)),e("code",jg,S(F.value),1)])):(a(),o("p",Og," A descriptive name for this model (e.g., coding_model, planning_model). This becomes the filename and reference ID. "))])):V("",!0),r.value?(a(),o("div",Ug,[e("div",Rg,[W[14]||(W[14]=e("label",{class:"block text-sm font-medium"},"Model Capabilities",-1)),b.value?(a(),o("button",{key:0,onClick:se,type:"button",class:"text-xs text-accent-600 dark:text-accent-400 hover:underline"}," Reset to detected ")):V("",!0)]),m.value?(a(),o("div",Ng," Detecting capabilities... ")):(a(),o("div",Fg,[e("div",Bg,[A(Pe,{modelValue:_.value.supportsImages,"onUpdate:modelValue":W[2]||(W[2]=ce=>_.value.supportsImages=ce),label:"Vision/Images","help-text":"Can process image inputs"},null,8,["modelValue"]),A(Pe,{modelValue:_.value.supportsToolCalls,"onUpdate:modelValue":W[3]||(W[3]=ce=>_.value.supportsToolCalls=ce),label:"Tool Calls","help-text":"Supports function calling"},null,8,["modelValue"]),A(Pe,{modelValue:_.value.supportsStreaming,"onUpdate:modelValue":W[4]||(W[4]=ce=>_.value.supportsStreaming=ce),label:"Streaming","help-text":"Supports streaming responses"},null,8,["modelValue"]),A(Pe,{modelValue:_.value.supportsJsonMode,"onUpdate:modelValue":W[5]||(W[5]=ce=>_.value.supportsJsonMode=ce),label:"JSON Mode","help-text":"Supports structured output"},null,8,["modelValue"])]),e("div",qg,[e("div",null,[W[15]||(W[15]=e("label",{class:"block text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-1"}," Max Context Tokens ",-1)),Ie(e("input",{"onUpdate:modelValue":W[6]||(W[6]=ce=>_.value.maxContextTokens=ce),type:"number",class:"w-full px-2 py-1.5 text-sm border rounded bg-white dark:bg-neutral-800 text-neutral-900 dark:text-neutral-100 border-neutral-300 dark:border-neutral-600 focus:ring-1 focus:ring-accent-500 focus:border-transparent",placeholder:"e.g., 128000"},null,512),[[Oe,_.value.maxContextTokens,void 0,{number:!0}]])]),e("div",null,[W[16]||(W[16]=e("label",{class:"block text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-1"}," Max Output Tokens ",-1)),Ie(e("input",{"onUpdate:modelValue":W[7]||(W[7]=ce=>_.value.maxOutputTokens=ce),type:"number",class:"w-full px-2 py-1.5 text-sm border rounded bg-white dark:bg-neutral-800 text-neutral-900 dark:text-neutral-100 border-neutral-300 dark:border-neutral-600 focus:ring-1 focus:ring-accent-500 focus:border-transparent",placeholder:"e.g., 16384"},null,512),[[Oe,_.value.maxOutputTokens,void 0,{number:!0}]])])])])),W[17]||(W[17]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"}," Capabilities are auto-detected from the provider. You can override them if needed. ",-1))])):V("",!0),r.value&&y.value.length>0?(a(),o("div",zg,[W[19]||(W[19]=e("label",{class:"block text-sm font-medium"},"Provider Tools",-1)),k.value?(a(),o("div",Hg," Loading provider tools... ")):(a(),o("div",Wg,[W[18]||(W[18]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"}," Built-in tools available for this model. Select which tools to enable. ",-1)),e("div",Jg,[(a(!0),o(ve,null,ke(y.value,ce=>(a(),o("label",{key:ce.name,class:ae(["flex items-start gap-3 p-3 border rounded cursor-pointer hover:bg-neutral-50 dark:hover:bg-neutral-800/50 transition-colors",x.value.includes(ce.name)?"border-black dark:border-white":"border-neutral-200 dark:border-neutral-700"])},[Ie(e("input",{type:"checkbox",value:ce.name,"onUpdate:modelValue":W[8]||(W[8]=z=>x.value=z),class:"mt-0.5 h-4 w-4 rounded border-neutral-300 dark:border-neutral-600 text-black dark:text-white focus:ring-black dark:focus:ring-white accent-black dark:accent-white"},null,8,Kg),[[sa,x.value]]),e("div",Gg,[e("div",Xg,S(ce.name),1),e("div",Yg,S(ce.description),1),ce.tenvs&&ce.tenvs.length>0?(a(),o("div",Qg,[e("span",Zg," Requires: "+S(ce.tenvs.filter(z=>z.required).map(z=>z.name).join(", ")||"none (optional config available)"),1)])):V("",!0)])],2))),128))])]))])):V("",!0),r.value&&L.value?(a(),o("div",eb,[W[20]||(W[20]=e("label",{class:"block text-sm font-medium mb-2"}," Available Providers ",-1)),A(bg,{modelValue:p.value,"onUpdate:modelValue":W[9]||(W[9]=ce=>p.value=ce),providers:d.value,loading:h.value},null,8,["modelValue","providers","loading"]),W[21]||(W[21]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Select which providers can be used for this model ",-1))])):V("",!0),r.value?(a(),o("div",tb,[A(Mg,{modelValue:D.value,"onUpdate:modelValue":W[10]||(W[10]=ce=>D.value=ce),label:"Fallback Models",placeholder:"Add fallback model...","allow-multiple":!0},null,8,["modelValue"]),W[22]||(W[22]=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))])):V("",!0)])]),_:1},8,["model-value","title","has-changes"]))}}),sb={class:"flex justify-between items-center mb-6"},nb={class:"flex items-center gap-2"},rb=["src","alt"],ib={class:"text-sm text-neutral-600 dark:text-neutral-400 font-mono"},db={key:0,class:"space-y-0.5"},ub=["title"],cb={class:"shrink-0 font-mono pr-2"},pb=["src","alt"],mb={class:"truncate"},vb={key:1,class:"text-neutral-400 dark:text-neutral-600 text-sm"},fb=me({__name:"ModelsView",setup(t){const n=v(!1),s=v([]),i=v(!1),l=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"}],c=[{icon:"edit",label:"Edit",handler:p=>{l.value=p,u.value="edit",n.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 p=>{await d(p.id)}}],f=async()=>{i.value=!0;try{const p=await fetch(ue("/api/models"));if(!p.ok)throw new Error("Failed to fetch models");const h=await p.json();s.value=h.models||[]}catch(p){console.error("Error fetching models:",p),s.value=[]}finally{i.value=!1}},g=async p=>{try{if(l.value){const{originalName:h,..._}=p,b=h||l.value.id,m=await fetch(ue(`/api/models/${b}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)});if(!m.ok){const y=await m.json();alert(y.error||"Failed to update model");return}}else{const h=await fetch(ue("/api/models"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});if(!h.ok){const _=await h.json();alert(_.error||"Failed to add model");return}}await f(),n.value=!1,l.value=null,u.value="add"}catch(h){console.error("Error saving model:",h),alert("Failed to save model")}},d=async p=>{try{const h=await fetch(ue(`/api/models/${p}`),{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 Me(()=>{f()}),(p,h)=>(a(),ne(at,null,{default:be(()=>[e("div",sb,[h[3]||(h[3]=e("h1",{class:"text-3xl font-bold"},"Models",-1)),e("button",{onClick:h[0]||(h[0]=()=>{u.value="add",l.value=null,n.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)),A(Ge,{columns:r,data:s.value,actions:c,loading:i.value,"empty-message":"No models configured yet. Add your first model to get started."},{"cell-name":be(({value:_,row:b})=>[e("div",nb,[b.provider?(a(),o("img",{key:0,src:`/api/providers/${b.provider}/icon?model=${encodeURIComponent(b.model||"")}`,class:"w-5 h-5 shrink-0",alt:b.provider},null,8,rb)):V("",!0),e("span",null,S(_),1)])]),"cell-model":be(({value:_})=>[e("span",ib,S(_||"—"),1)]),"cell-fallbacks":be(({value:_})=>[_&&_.length>0?(a(),o("div",db,[(a(!0),o(ve,null,ke(_,(b,m)=>(a(),o("div",{key:b.id,class:"text-sm text-neutral-600 dark:text-neutral-400 flex items-center",title:b.name},[e("span",cb,S(m===_.length-1?"└─":"├─"),1),b.provider?(a(),o("img",{key:0,src:`/api/providers/${b.provider}/icon?model=${encodeURIComponent(b.model||"")}`,class:"w-4 h-4 shrink-0 mr-1.5",alt:b.provider},null,8,pb)):V("",!0),e("span",mb,S(b.name),1)],8,ub))),128))])):(a(),o("span",vb," None "))]),_:1},8,["data","loading"]),A(lb,{modelValue:n.value,"onUpdate:modelValue":[h[1]||(h[1]=_=>n.value=_),h[2]||(h[2]=_=>{n.value=_,_||(l.value=null,u.value="add")})],"edit-model":l.value,mode:u.value,onSave:g},null,8,["modelValue","edit-model","mode"])]),_:1}))}}),hb={class:"space-y-4"},gb={class:"space-y-1"},bb={class:"relative"},xb={key:0,class:"flex items-center gap-2"},yb=["src","alt"],kb={key:1,class:"text-neutral-500"},wb={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"},_b=["onClick"],$b=["src","alt"],Cb={key:0,class:"text-xs text-red-500 dark:text-red-400"},Tb=me({__name:"AddProviderModal",props:{modelValue:{type:Boolean}},emits:["update:modelValue","save"],setup(t,{emit:n}){const s=n,i=v({name:"",type:"",apiKey:"",baseUrl:""}),l=v([]),u=v(!1),r=async()=>{u.value=!0;try{const y=await fetch(ue("/api/providers"));if(y.ok){const x=await y.json();l.value=(x.providers||[]).map(k=>({value:k.name,label:k.label||k.name,icon:k.iconId,sdk:k.sdk}))}}catch(y){console.error("Error fetching providers:",y)}finally{u.value=!1}};Me(()=>{r()});const c=v(!1),f=J(()=>l.find(y=>y.value===i.value.type)),g=()=>{setTimeout(()=>{c.value=!1},200)},d=v({});fe(()=>i.value.type,y=>{if(y&&!i.value.name){const x=l.find(k=>k.value===y);x&&(i.value.name=x.label)}});const p=J(()=>i.value.type==="custom"||i.value.type==="openai"),h=()=>{d.value={};let y=!0;return i.value.name||(d.value.name="Provider name is required",y=!1),i.value.type||(d.value.type="Provider type is required",y=!1),i.value.apiKey||(d.value.apiKey="API key is required",y=!1),p.value&&i.value.type==="custom"&&!i.value.baseUrl&&(d.value.baseUrl="Base URL is required for custom providers",y=!1),y},_=()=>{h()&&(s("save",{...i.value}),m(),s("update:modelValue",!1))},b=()=>{m(),s("update:modelValue",!1)},m=()=>{i.value={name:"",type:"",apiKey:""},d.value={}};return(y,x)=>(a(),ne(He,{"model-value":t.modelValue,"onUpdate:modelValue":x[4]||(x[4]=k=>y.$emit("update:modelValue",k)),title:"Add Provider",width:"max-w-md"},{footer:be(()=>[e("div",{class:"flex gap-2 justify-end"},[e("button",{onClick:b,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:_,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:be(()=>[e("div",hb,[e("div",gb,[x[6]||(x[6]=e("label",{class:"block text-sm font-medium"},[Ce(" Provider Type "),e("span",{class:"text-red-500"},"*")],-1)),e("div",bb,[e("button",{type:"button",onClick:x[0]||(x[0]=k=>c.value=!c.value),onBlur:g,class:ae(["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",[d.value.type?"border-red-500 dark:border-red-400":"border-black dark:border-neutral-300"]])},[f.value?(a(),o("div",xb,[e("img",{src:f.value.icon,alt:f.value.label,class:"w-5 h-5"},null,8,yb),e("span",null,S(f.value.label),1)])):(a(),o("span",kb,"Select a provider")),x[5]||(x[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?(a(),o("div",wb,[(a(!0),o(ve,null,ke(l.value,k=>(a(),o("button",{key:k.value,type:"button",onClick:D=>{i.value.type=k.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:k.icon,alt:k.label,class:"w-5 h-5"},null,8,$b),e("span",null,S(k.label),1)],8,_b))),128))])):V("",!0)]),d.value.type?(a(),o("p",Cb,S(d.value.type),1)):V("",!0)]),A(Le,{modelValue:i.value.name,"onUpdate:modelValue":x[1]||(x[1]=k=>i.value.name=k),label:"Provider Name",placeholder:"e.g., My OpenAI Provider",error:d.value.name,required:""},null,8,["modelValue","error"]),A(Le,{modelValue:i.value.apiKey,"onUpdate:modelValue":x[2]||(x[2]=k=>i.value.apiKey=k),label:"API Key",type:"password",placeholder:"sk-...",error:d.value.apiKey,required:""},null,8,["modelValue","error"]),p.value?(a(),ne(Le,{key:0,modelValue:i.value.baseUrl,"onUpdate:modelValue":x[3]||(x[3]=k=>i.value.baseUrl=k),label:"Base URL",placeholder:"https://api.example.com",error:d.value.baseUrl,required:i.value.type==="custom"},null,8,["modelValue","error","required"])):V("",!0)])]),_:1},8,["model-value"]))}}),Sb={class:"flex justify-between items-center mb-6"},Vb=me({__name:"ProvidersView",setup(t){const n=v(!1),s=v([]),i=v(!1),l=[{key:"name",label:"Name",width:"w-1/3"},{key:"sdk",label:"SDK Type",width:"w-1/3",formatter:g=>({"openai-sdk":"OpenAI SDK",openrouter:"OpenRouter",openai:"OpenAI"})[g]||g},{key:"hasApiKey",label:"API Key",width:"w-1/3",formatter:g=>g?"✓ 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 g=>{await f(g.name)}}],r=async()=>{i.value=!0;try{const g=await fetch(ue("/api/providers"));if(!g.ok)throw new Error("Failed to fetch providers");const d=await g.json();s.value=d.providers||[]}catch(g){console.error("Error fetching providers:",g),s.value=[]}finally{i.value=!1}},c=async g=>{try{const d=await fetch(ue("/api/providers"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(!d.ok){const p=await d.json();alert(p.error||"Failed to add provider");return}await r(),n.value=!1}catch(d){console.error("Error adding provider:",d),alert("Failed to add provider")}},f=async g=>{try{const d=await fetch(ue(`/api/providers/${encodeURIComponent(g)}`),{method:"DELETE"});if(!d.ok){const p=await d.json();p.modelCount?alert(`${p.error}
22
-
23
- This provider has ${p.modelCount} associated model(s).`):alert(p.error||"Failed to delete provider");return}await r()}catch(d){console.error("Error deleting provider:",d),alert("Failed to delete provider")}};return Me(()=>{r()}),(g,d)=>(a(),ne(at,null,{default:be(()=>[e("div",Sb,[d[2]||(d[2]=e("h1",{class:"text-3xl font-bold"},"Providers",-1)),e("button",{onClick:d[0]||(d[0]=p=>n.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 ")]),d[3]||(d[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)),A(Ge,{columns:l,data:s.value,actions:u,loading:i.value,"empty-message":"No providers configured yet. Add your first provider to get started."},null,8,["data","loading"]),A(Tb,{modelValue:n.value,"onUpdate:modelValue":d[1]||(d[1]=p=>n.value=p),onSave:c},null,8,["modelValue"])]),_:1}))}}),Mb={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ib(t,n){return a(),o("svg",Mb,[...n[0]||(n[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 Eb=De({name:"lucide-info",render:Ib}),Lb={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ab(t,n){return a(),o("svg",Lb,[...n[0]||(n[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 Jt=De({name:"lucide-triangle-alert",render:Ab}),Pb={class:"mb-6 p-4 border border-black/20 dark:border-white/20 rounded bg-black/5 dark:bg-white/5"},Db={class:"flex items-start gap-3"},jb={class:"text-sm"},Ob={class:"font-medium mb-1"},Ub={class:"px-1.5 py-0.5 bg-black/10 dark:bg-white/10 rounded font-mono text-xs"},Rb={id:"functions"},Nb=["onClick"],Fb={key:1,class:"text-left font-medium text-red-600 dark:text-red-400"},Bb={key:2,class:"relative group"},qb={key:3,class:"relative group"},zb={class:"flex justify-end"},Hb=["onClick"],Wb={key:1,class:"text-neutral-400 text-sm"},Jb={id:"prompts",class:"mt-12"},Kb=["onClick"],Gb={class:"text-neutral-600 dark:text-neutral-400"},Xb={class:"text-sm text-neutral-500 dark:text-neutral-400"},Yb={id:"agents",class:"mt-12"},Qb=["onClick"],Zb={class:"text-neutral-600 dark:text-neutral-400"},e1={class:"text-sm text-neutral-500 dark:text-neutral-400"},t1={class:"flex items-center gap-2"},a1={key:0,class:"space-y-4"},o1={class:"text-lg font-medium mb-2"},l1={class:"text-sm text-neutral-600 dark:text-neutral-400 mb-4"},s1={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"},n1=me({__name:"ToolsView",setup(t){const n=v(null),s=v(!1),{data:i}=Ue(ue("/api/config")).json(),{data:l,error:u,isFetching:r,execute:c}=Ue(ue("/api/tools?type=tools"),{immediate:!1}).json(),{data:f,error:g,isFetching:d,execute:p}=Ue(ue("/api/tools?type=prompts&schema=true"),{immediate:!1}).json(),{data:h,error:_,isFetching:b,execute:m}=Ue(ue("/api/tools?type=agents&schema=true"),{immediate:!1}).json(),{data:y,error:x,isFetching:k,execute:D}=Ue(()=>n.value?ue(`/api/tools/${n.value.name}`):null,{immediate:!1}).json(),q=v([]),B=v([]),F=v([]),T=Ye(),$=async()=>{const j=T.hash;if(j){await Te();const M=document.getElementById(j.slice(1));M&&M.scrollIntoView({behavior:"smooth"})}};fe(()=>T.hash,$);const K=async j=>{n.value=j,await D(),y.value?n.value={...j,schema:y.value.schema||null}:x.value&&console.error("Error fetching tool schema:",x.value),s.value=!0},oe=async j=>{if(n.value=j,s.value=!0,!j.schema&&j.type==="prompt"){const M=await fetch(ue("/api/tools?type=prompts&schema=true"));if(M.ok){const w=await M.json();w[j.name]&&(n.value={...j,schema:w[j.name].schema||null})}}},te=[{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"}],H=[{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"}],P=j=>/^[a-z][a-z0-9_]*[a-z0-9]$/.test(j)||/^[a-z]$/.test(j),C=j=>j.hasError&&j.error?j.error:j.description||"No description available",L=()=>{l.value&&(q.value=Object.entries(l.value).map(([j,M])=>({name:j,description:M.description||"No description available",schema:null,hasError:M.hasError||!1,error:M.error,type:M.type||"tool"})))},G=()=>{f.value&&(B.value=Object.entries(f.value).map(([j,M])=>({name:j,description:M.description||"No description available",schema:M.schema||null,hasError:!1,type:"prompt",model:M.model})))},ee=()=>{h.value&&(F.value=Object.entries(h.value).map(([j,M])=>({name:j,description:M.description||"No description available",schema:M.schema||null,hasError:!1,type:"agent",model:M.model})))},E=async()=>{await c(),L()},U=async()=>{await p(),G()},Z=async()=>{await m(),ee()},se=()=>{s.value=!1,n.value=null};return Me(()=>{E(),U(),Z(),$()}),(j,M)=>(a(),ne(at,null,{default:be(()=>[M[11]||(M[11]=e("div",{class:"flex justify-between items-center mb-6"},[e("h1",{class:"text-3xl font-bold"},"Tools")],-1)),M[12]||(M[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",Pb,[e("div",Db,[A(X(Eb),{class:"w-5 h-5 mt-0.5 text-black/60 dark:text-white/60 flex-shrink-0"}),e("div",jb,[e("p",Ob,[M[1]||(M[1]=Ce(" To create or modify tools, edit the ",-1)),e("code",Ub,S(X(i)?.toolsDir||"agentbuilder/tools")+"/",1),M[2]||(M[2]=Ce(" directory of your codebase. ",-1))]),M[3]||(M[3]=e("p",{class:"text-black/70 dark:text-white/70"}," Changes will be automatically detected. ",-1))])])]),e("div",Rb,[A(Ge,{columns:H,data:q.value,loading:X(r),"empty-message":`No tools found. Add tool files to the ${X(i)?.toolsDir||"agentbuilder/tools"}/ directory.`},{"cell-name":be(({row:w})=>[e("div",{class:ae(["flex items-center gap-2",{"text-red-600 dark:text-red-400":w.hasError}])},[w.hasError?(a(),o("span",Fb,S(w.name),1)):(a(),o("button",{key:0,onClick:R=>K(w),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},S(w.name),9,Nb)),w.hasError?(a(),o("div",Bb,[A(X(Jt),{class:"w-4 h-4 text-red-500"}),M[4]||(M[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"},[Ce(" 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))])):P(w.name)?V("",!0):(a(),o("div",qb,[A(X(Jt),{class:"w-4 h-4 text-amber-500"}),M[5]||(M[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"},[Ce(" 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":be(({row:w})=>[e("span",{class:ae({"text-red-600 dark:text-red-400":w.hasError,"text-neutral-600 dark:text-neutral-400":!w.hasError})},S(C(w)),3)]),"cell-actions":be(({row:w})=>[e("div",zb,[w.hasError?(a(),o("span",Wb,"—")):(a(),o("button",{key:0,onClick:R=>K(w),class:"p-1.5 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",title:"View Schema"},[A(X($t),{class:"w-4 h-4"})],8,Hb))])]),_:1},8,["data","loading","empty-message"])]),e("div",Jb,[M[6]||(M[6]=e("h2",{class:"text-2xl font-bold mb-4"},"Prompts",-1)),M[7]||(M[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)),A(Ge,{columns:te,data:B.value,loading:X(d),"empty-message":"No prompts are currently exposed as tools. Mark a prompt as 'Expose as tool' to see it here."},{"cell-name":be(({row:w})=>[e("button",{onClick:R=>oe(w),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},S(w.name),9,Kb)]),"cell-description":be(({row:w})=>[e("span",Gb,S(w.description),1)]),"cell-model":be(({row:w})=>[e("span",Xb,S(w.model||"-"),1)]),_:1},8,["data","loading"])]),e("div",Yb,[M[8]||(M[8]=e("h2",{class:"text-2xl font-bold mb-4"},"Agents",-1)),M[9]||(M[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)),A(Ge,{columns:te,data:F.value,loading:X(b),"empty-message":"No agents are currently exposed as tools. Mark an agent as 'Expose as tool' to see it here."},{"cell-name":be(({row:w})=>[e("button",{onClick:R=>oe(w),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},S(w.name),9,Qb)]),"cell-description":be(({row:w})=>[e("span",Zb,S(w.description),1)]),"cell-model":be(({row:w})=>[e("span",e1,S(w.model||"-"),1)]),_:1},8,["data","loading"])]),A(He,{modelValue:s.value,"onUpdate:modelValue":M[0]||(M[0]=w=>s.value=w),onClose:se,width:"max-w-4xl"},{header:be(()=>[e("div",t1,[A(X($t),{class:"w-5 h-5"}),e("span",null,S(n.value?.name)+" Schema",1)])]),footer:be(()=>[e("button",{onClick:se,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:be(()=>[n.value?(a(),o("div",a1,[e("div",null,[e("h3",o1,S(n.value.type==="prompt"?"Required Schema":"JSON Schema"),1),e("p",l1,S(n.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)]),n.value.schema===null?(a(),o("div",s1,[...M[10]||(M[10]=[e("p",{class:"text-neutral-500 dark:text-neutral-400"}," No parameters required ",-1)])])):(a(),ne(vt,{key:1,value:n.value.schema,class:"h-96 border border-black/20 dark:border-white/20 rounded"},null,8,["value"]))])):V("",!0)]),_:1},8,["modelValue"])]),_:1}))}}),r1={class:"flex justify-between items-center mb-6"},i1={class:"flex justify-end gap-2 mt-4"},d1={class:"flex justify-end gap-2 mt-4"},u1=me({__name:"UsersView",setup(t){const n=v(!1),s=v(!1),i=v([]),l=v(!1),u=v(null),r=v({username:"",password:"",role:"admin"}),c=v({username:"",password:"",role:"admin"}),f=[{value:"admin",label:"Admin"}],g=[{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()}],d=[{icon:"edit",label:"Edit",handler:async m=>{u.value=m,c.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 b(m.id)}}],p=async()=>{l.value=!0;try{const m=await ze("/users");if(!m.ok)throw new Error("Failed to fetch users");const y=await m.json();i.value=y.users||[]}catch(m){console.error("Error fetching users:",m),i.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 ze("/users",{method:"POST",body:JSON.stringify(r.value)});if(!m.ok){const y=await m.json();alert(y.error||"Failed to add user");return}await p(),n.value=!1,r.value={username:"",password:"",role:"admin"}}catch(m){console.error("Error adding user:",m),alert("Failed to add user")}},_=async()=>{if(!c.value.username){alert("Username is required");return}try{const m={username:c.value.username,role:c.value.role};c.value.password&&(m.password=c.value.password);const y=await ze(`/users/${u.value.id}`,{method:"PUT",body:JSON.stringify(m)});if(!y.ok){const x=await y.json();alert(x.error||"Failed to update user");return}await p(),s.value=!1,u.value=null}catch(m){console.error("Error updating user:",m),alert("Failed to update user")}},b=async m=>{try{const y=await ze(`/users/${m}`,{method:"DELETE"});if(!y.ok){const x=await y.json();alert(x.error||"Failed to delete user");return}await p()}catch(y){console.error("Error deleting user:",y),alert("Failed to delete user")}};return Me(()=>{p()}),(m,y)=>(a(),ne(at,null,{default:be(()=>[e("div",r1,[y[13]||(y[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:y[0]||(y[0]=x=>n.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 ")]),A(Ge,{columns:g,data:i.value,actions:d,loading:l.value,"empty-message":"No users found"},null,8,["data","loading"]),A(He,{modelValue:n.value,"onUpdate:modelValue":y[5]||(y[5]=x=>n.value=x),title:"Add User",onClose:y[6]||(y[6]=x=>n.value=!1)},{default:be(()=>[e("form",{onSubmit:Ee(h,["prevent"]),class:"space-y-4"},[e("div",null,[y[14]||(y[14]=e("label",{class:"block text-sm font-medium mb-1"},"Username",-1)),Ie(e("input",{"onUpdate:modelValue":y[1]||(y[1]=x=>r.value.username=x),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,[y[15]||(y[15]=e("label",{class:"block text-sm font-medium mb-1"},"Password",-1)),Ie(e("input",{"onUpdate:modelValue":y[2]||(y[2]=x=>r.value.password=x),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,[A(Ve,{modelValue:r.value.role,"onUpdate:modelValue":y[3]||(y[3]=x=>r.value.role=x),options:f,label:"Role",placeholder:"Select role"},null,8,["modelValue"])]),e("div",i1,[e("button",{type:"button",onClick:y[4]||(y[4]=x=>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 "),y[16]||(y[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"]),A(He,{modelValue:s.value,"onUpdate:modelValue":y[11]||(y[11]=x=>s.value=x),title:"Edit User",onClose:y[12]||(y[12]=x=>s.value=!1)},{default:be(()=>[e("form",{onSubmit:Ee(_,["prevent"]),class:"space-y-4"},[e("div",null,[y[17]||(y[17]=e("label",{class:"block text-sm font-medium mb-1"},"Username",-1)),Ie(e("input",{"onUpdate:modelValue":y[7]||(y[7]=x=>c.value.username=x),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,c.value.username]])]),e("div",null,[y[18]||(y[18]=e("label",{class:"block text-sm font-medium mb-1"},"Password (leave blank to keep current)",-1)),Ie(e("input",{"onUpdate:modelValue":y[8]||(y[8]=x=>c.value.password=x),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,c.value.password]])]),e("div",null,[A(Ve,{modelValue:c.value.role,"onUpdate:modelValue":y[9]||(y[9]=x=>c.value.role=x),options:f,label:"Role",placeholder:"Select role"},null,8,["modelValue"])]),e("div",d1,[e("button",{type:"button",onClick:y[10]||(y[10]=x=>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 "),y[19]||(y[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}))}}),c1={class:"flex justify-between items-center mb-6"},p1={class:"flex justify-end gap-2 mt-4"},m1={class:"space-y-4"},v1={class:"flex gap-2"},f1=["value"],h1={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"},g1={class:"block mt-2 bg-white dark:bg-neutral-800 px-3 py-2 rounded text-xs"},b1={class:"flex justify-end mt-4"},x1=me({__name:"ApiKeysView",setup(t){const n=v(!1),s=v(!1),i=v([]),l=v(!1),u=v(""),r=v({name:""}),c=[{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 p(_.id)}}],g=async()=>{l.value=!0;try{const _=await ze("/api-keys");if(!_.ok)throw new Error("Failed to fetch API keys");const b=await _.json();i.value=(b.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:",_),i.value=[]}finally{l.value=!1}},d=async()=>{if(!r.value.name){alert("Name is required");return}try{const _=await ze("/api-keys",{method:"POST",body:JSON.stringify(r.value)}),b=await _.json();if(!_.ok){alert(b.error||"Failed to create API key");return}u.value=b.key,n.value=!1,s.value=!0,await g(),r.value={name:""}}catch(_){console.error("Error creating API key:",_),alert("Failed to create API key")}},p=async _=>{try{const b=await ze(`/api-keys/${_}`,{method:"DELETE"});if(!b.ok){const m=await b.json();alert(m.error||"Failed to delete API key");return}await g()}catch(b){console.error("Error deleting API key:",b),alert("Failed to delete API key")}},h=async _=>{try{await navigator.clipboard.writeText(_),alert("API key copied to clipboard!")}catch(b){console.error("Failed to copy:",b)}};return Me(()=>{g()}),(_,b)=>(a(),ne(at,null,{default:be(()=>[e("div",c1,[b[9]||(b[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:b[0]||(b[0]=m=>n.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 ")]),A(Ge,{columns:c,data:i.value,actions:f,loading:l.value,"empty-message":"No API keys found"},null,8,["data","loading"]),A(He,{modelValue:n.value,"onUpdate:modelValue":b[3]||(b[3]=m=>n.value=m),title:"Create API Key",onClose:b[4]||(b[4]=m=>n.value=!1)},{default:be(()=>[e("form",{onSubmit:Ee(d,["prevent"]),class:"space-y-4"},[e("div",null,[b[10]||(b[10]=e("label",{class:"block text-sm font-medium mb-1"},"Name",-1)),Ie(e("input",{"onUpdate:modelValue":b[1]||(b[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]]),b[11]||(b[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",p1,[e("button",{type:"button",onClick:b[2]||(b[2]=m=>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 "),b[12]||(b[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"]),A(He,{modelValue:s.value,"onUpdate:modelValue":b[7]||(b[7]=m=>s.value=m),title:"API Key Created",onClose:b[8]||(b[8]=m=>s.value=!1)},{default:be(()=>[e("div",m1,[b[15]||(b[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,[b[13]||(b[13]=e("label",{class:"block text-sm font-medium mb-2"},"Your new API key:",-1)),e("div",v1,[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,f1),e("button",{onClick:b[5]||(b[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",h1,[b[14]||(b[14]=e("p",{class:"text-sm"}," Use this key in the Authorization header of your API requests: ",-1)),e("code",g1," Authorization: Bearer "+S(u.value),1)]),e("div",b1,[e("button",{onClick:b[6]||(b[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}))}}),y1={class:"login-container flex-1 flex items-center justify-center px-4"},k1={class:"max-w-md w-full space-y-8"},w1={class:"flex justify-center"},_1=["src"],$1={class:"bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-700 py-8 px-6 rounded-lg"},C1={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"},T1=["disabled"],S1={key:0,class:"mt-6"},V1=me({__name:"LoginView",setup(t){function n(x){if(x.startsWith("/src/")||x.startsWith("data:"))return x;const k=dt();return k==="/"?x.replace("/agents/","/"):x.replace("/agents/",`${k}/`)}const s=n(ha),i=n(ga),l=lt(),u=Ye(),r=v(""),c=v(""),f=v(""),g=v(!1),d=v(!1),p=v(!1),h=v(!1),_=J(()=>h.value?i:s);Me(async()=>{const x=localStorage.getItem("theme");h.value=x==="dark"||!x&&window.matchMedia("(prefers-color-scheme: dark)").matches;const k=u.query.token,D=u.query.error;if(k){localStorage.setItem("auth_token",k),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 q=await fetch(ue("/api/auth/config"));if(q.ok){const B=await q.json();d.value=B.github||!1,p.value=B.google||!1}}catch(q){console.error("Failed to fetch auth config:",q)}});async function b(){f.value="",g.value=!0;try{const x=await fetch(ue("/api/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r.value,password:c.value})}),k=await x.json();x.ok?(localStorage.setItem("auth_token",k.token),l.push("/")):f.value=k.error||"Login failed"}catch{f.value="Network error. Please try again."}finally{g.value=!1}}function m(){window.location.href=ue("/api/auth/oauth/github")}function y(){window.location.href=ue("/api/auth/oauth/google")}return(x,k)=>(a(),o("div",y1,[e("div",k1,[e("div",w1,[e("img",{src:_.value,alt:"AgentBuilder",class:"h-16 pointer-events-none select-none"},null,8,_1)]),A(Qe,{offsetX:8,offsetY:8,intensity:.2,pattern:"crosshatch"},{default:be(()=>[e("div",$1,[e("form",{class:"space-y-6",onSubmit:Ee(b,["prevent"])},[f.value?(a(),o("div",C1,S(f.value),1)):V("",!0),A(Le,{modelValue:r.value,"onUpdate:modelValue":k[0]||(k[0]=D=>r.value=D),label:"Username",type:"text",disabled:g.value,placeholder:"Enter your username"},null,8,["modelValue","disabled"]),A(Le,{modelValue:c.value,"onUpdate:modelValue":k[1]||(k[1]=D=>c.value=D),label:"Password",type:"password",disabled:g.value,placeholder:"Enter your password"},null,8,["modelValue","disabled"]),e("div",null,[e("button",{type:"submit",disabled:g.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"},S(g.value?"Signing in...":"Sign in"),9,T1)])],32),d.value||p.value?(a(),o("div",S1,[k[4]||(k[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:ae(["mt-6 grid gap-3",d.value&&p.value?"grid-cols-2":"grid-cols-1"])},[d.value?(a(),o("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"},[...k[2]||(k[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)])])):V("",!0),p.value?(a(),o("button",{key:1,onClick:y,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"},[...k[3]||(k[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)])])):V("",!0)],2)])):V("",!0)])]),_:1})])]))}}),M1={class:"space-y-1"},I1={key:0,class:"block text-sm font-medium"},E1={key:0,class:"text-red-500"},L1=["value","placeholder","disabled"],A1={key:1,class:"text-xs text-red-500 dark:text-red-400"},yt=me({__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:n,emit:s}){const i=t,l=s,u=v(null),r=J(()=>["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",i.error?"border-red-500 dark:border-red-400":"border-black dark:border-neutral-300",i.disabled?"opacity-50 cursor-not-allowed":""]),c=()=>{const p=u.value;p&&(p.style.height="auto",p.style.height=`${p.scrollHeight+2}px`)},f=p=>{const h=p.target;l("update:modelValue",h.value),c()},g=p=>{l("focus",p)},d=p=>{l("blur",p)};return Me(()=>{c()}),fe(()=>i.modelValue,async()=>{await Te(),c()}),n({textareaRef:u,adjustHeight:c}),(p,h)=>(a(),o("div",M1,[t.label?(a(),o("label",I1,[Ce(S(t.label)+" ",1),t.required?(a(),o("span",E1,"*")):V("",!0)])):V("",!0),e("textarea",{ref_key:"textareaRef",ref:u,value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,class:ae(r.value),rows:"1",onInput:f,onFocus:g,onBlur:d},null,42,L1),t.error?(a(),o("p",A1,S(t.error),1)):V("",!0)]))}}),P1={class:"p-8 space-y-6"},D1={class:"mt-12"},j1={class:"mb-6"},O1={class:"mb-6"},U1={class:"mb-6"},R1={class:"mt-8"},N1={class:"border-2 border-red-500 p-4 h-32 overflow-hidden relative"},F1={class:"mt-12"},B1={class:"mb-6"},q1={class:"border-2 border-accent-500 p-4 h-32 overflow-hidden relative"},z1={class:"mt-12"},H1={class:"mb-6"},W1={class:"mb-6"},J1={class:"mt-12"},K1={class:"mb-6"},G1={class:"mt-2 text-sm"},X1={class:"mb-6"},Y1={class:"mt-2 text-sm"},Q1={class:"mb-6"},Z1={class:"mb-6"},ex={class:"mt-12"},tx={class:"mb-6"},ax={class:"mt-4 p-4 bg-neutral-100 dark:bg-neutral-900 rounded"},ox={class:"text-xs overflow-x-auto"},lx=me({__name:"TestView",setup(t){const n=v(""),s=v(""),i=v(""),l=v(`Line 1
46
+ `).trim():""),P=B(()=>{if(!a.log.response_body)return[];try{const $=JSON.parse(a.log.response_body)?.choices?.[0]?.message?.images;return Array.isArray($)?$:[]}catch{return[]}}),G=B(()=>{if(!a.log.provider_tools)return[];try{const O=JSON.parse(a.log.provider_tools);return Array.isArray(O)?O:[]}catch{return[]}}),ee=B(()=>{if(!a.log.queued_tools)return[];try{const O=JSON.parse(a.log.queued_tools);return Array.isArray(O)?O:[]}catch{return[]}}),se=B(()=>{const O=[];for(const $ of R.value)O.push({id:$.id||`tool-${O.length}`,name:$.function?.name||"Unknown",isProvider:!1,isQueued:!1,function:$.function});for(const $ of ee.value)O.push({id:$.id||`queued-${O.length}`,name:$.function?.name||"Unknown",isProvider:!1,isQueued:!0,function:$.function,queuedAt:$.queued_at});for(const $ of G.value)O.push({id:$.id,name:$.type,isProvider:!0,isQueued:!1,providerType:$.type,status:$.status,result:$.result});return O}),de=O=>{u.value.has(O)?u.value.delete(O):u.value.add(O)},Q=O=>{s.value.has(O)?s.value.delete(O):s.value.add(O)},E=()=>{x.value=!x.value},S=()=>{c.value=!c.value},V=O=>{k.value.has(O)?k.value.delete(O):k.value.add(O)},re=O=>!k.value.has(O),F=B(()=>{if(!a.log.errors)return[];try{const O=JSON.parse(a.log.errors);return Array.isArray(O)?O:[]}catch{return[]}}),q=p("standard"),N=p(null),J=p(!1),U=p(null),W=["openai","openrouter"],M=()=>(a.log.actual_provider||a.log.provider)?.toLowerCase(),ne=()=>{const O=M();O&&W.includes(O)?q.value=O:q.value="standard"},A=O=>O.charAt(0).toUpperCase()+O.slice(1);ge(q,async O=>{if(O==="standard"){N.value=null,U.value=null;return}if(!a.threadId||!a.log.id){U.value="Missing thread or log ID";return}J.value=!0,U.value=null;try{const $=await fetch(fe(`/api/threads/${a.threadId}/logs/${a.log.id}/inspect/${O}`));if(!$.ok){const j=await $.json();throw new Error(j.error||"Failed to inspect")}N.value=await $.json()}catch($){U.value=$.message||"Failed to fetch inspected request",N.value=null}finally{J.value=!1}}),ge(()=>a.log.id,async()=>{if(N.value=null,U.value=null,ne(),q.value!=="standard"&&a.threadId&&a.log.id){J.value=!0;try{const O=await fetch(fe(`/api/threads/${a.threadId}/logs/${a.log.id}/inspect/${q.value}`));if(!O.ok){const $=await O.json();throw new Error($.error||"Failed to fetch inspected request")}N.value=await O.json()}catch(O){U.value=O.message||"Failed to fetch inspected request"}finally{J.value=!1}}},{immediate:!0});const ce=B(()=>{if(q.value==="standard"||!N.value)return a.log.message_history;const O=N.value.messagesPath,$=O?N.value.body?.[O]:N.value.body;return JSON.stringify($,null,2)}),ue=B(()=>q.value==="standard"||!N.value?a.log.request_body:JSON.stringify(N.value.body,null,2)),ke=B(()=>q.value==="standard"||!N.value?null:`${q.value} format`);ge(()=>a.log,()=>{Le(()=>{y.value?.checkHeight(),b.value?.checkHeight(),v.value?.checkHeight(),d.value?.checkHeight()})});const be=async()=>{m.value=!0;try{if(!a.log.request_body||!a.log.model)throw new Error("Missing request data");const O=await fetch(fe(`/api/models/${a.log.model}/curl-data`));if(!O.ok)throw new Error("Failed to fetch model data");const $=await O.json(),j=_(a.log.request_body);let he=`curl -X POST '${$.endpoint}' \\
47
+ `;he+=` -H 'Content-Type: application/json' \\
48
+ `,$.sdk?.toLowerCase()==="openrouter"?(he+=` -H 'Authorization: Bearer ${$.api_key}' \\
49
+ `,he+=` -H 'HTTP-Referer: https://agentkit.local' \\
50
+ `,he+=` -H 'X-Title: AgentKit' \\
51
+ `):$.sdk?.toLowerCase()==="openai"&&(he+=` -H 'Authorization: Bearer ${$.api_key}' \\
52
+ `),he+=` -d '${j.replace(/'/g,"'\\''")}'`,await navigator.clipboard.writeText(he),h.value=!0,setTimeout(()=>{h.value=!1},2e3)}catch(O){console.error("Failed to copy cURL command:",O),alert(`Failed to copy cURL: ${O instanceof Error?O.message:"Unknown error"}`)}finally{m.value=!1}};return(O,$)=>(r(),n("div",{ref_key:"scrollContainer",ref:f,class:"p-4 h-full overflow-y-auto"},[e("div",xg,[e("div",yg,[e("div",kg,[e("button",{onClick:$[0]||($[0]=j=>i("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"},[...$[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:"15 18 9 12 15 6"})],-1)])],8,wg),e("button",{onClick:$[1]||($[1]=j=>i("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"},[...$[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("polyline",{points:"9 18 15 12 9 6"})],-1)])],8,_g)]),e("h3",$g,C(t.log.prompt_name||t.log.model_name||t.log.model),1)]),e("div",Cg,[e("button",{onClick:be,disabled:m.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"},[m.value?(r(),H(Ee,{key:0,size:"xs"})):(r(),n("span",Tg,C(h.value?"Copied!":"Copy cURL"),1))],8,Sg),e("button",{onClick:$[2]||($[2]=j=>i("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"},[...$[12]||($[12]=[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",Ig,[e("div",zg,[e("table",Vg,[$[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 "),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:ae(["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",Mg,C(t.log.actual_provider||t.log.provider),1),e("td",Eg,[!t.log.is_complete&&!t.log.prompt_name?(r(),H(Ee,{key:0,size:"xs"})):(r(),n("span",Lg,C(t.log.prompt_name||"—"),1))]),e("td",Pg,[!t.log.is_complete&&!t.log.latency_ms?(r(),H(Ee,{key:0,size:"xs"})):(r(),n("span",Ag,C(t.log.latency_ms?`${t.log.latency_ms}ms`:"—"),1))]),e("td",jg,[!t.log.is_complete&&!t.log.total_tokens?(r(),H(Ee,{key:0,size:"xs"})):(r(),n("span",Dg,C(t.log.total_tokens?`${t.log.input_tokens}/${t.log.output_tokens} (${t.log.total_tokens})`:"—"),1))]),e("td",Og,[!t.log.is_complete&&!t.log.cost_total?(r(),H(Ee,{key:0,size:"xs"})):(r(),n("span",Rg,C(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))]),e("td",Ug,[w(yt,{timestamp:t.log.created_at},null,8,["timestamp"])])])])])]),e("div",Bg,[e("table",Fg,[$[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"}," 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:ae(["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",Ng,C(t.log.actual_provider||t.log.provider),1),e("td",qg,[!t.log.is_complete&&!t.log.prompt_name?(r(),H(Ee,{key:0,size:"xs"})):(r(),n("span",Hg,C(t.log.prompt_name||"—"),1))])])])]),e("table",Wg,[$[15]||($[15]=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",Kg,[!t.log.is_complete&&!t.log.latency_ms?(r(),H(Ee,{key:0,size:"xs"})):(r(),n("span",Jg,C(t.log.latency_ms?`${t.log.latency_ms}ms`:"—"),1))]),e("td",Yg,[!t.log.is_complete&&!t.log.total_tokens?(r(),H(Ee,{key:0,size:"xs"})):(r(),n("span",Gg,C(t.log.total_tokens?`${t.log.input_tokens}/${t.log.output_tokens} (${t.log.total_tokens})`:"—"),1))]),e("td",Zg,[!t.log.is_complete&&!t.log.cost_total?(r(),H(Ee,{key:0,size:"xs"})):(r(),n("span",Xg,C(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))]),e("td",Qg,[w(yt,{timestamp:t.log.created_at},null,8,["timestamp"])])])])])])]),e("div",eb,[e("div",tb,[e("button",{onClick:$[3]||($[3]=j=>l.value="request"),class:ae(["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:$[4]||($[4]=j=>l.value="response"),class:ae(["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"])},[$[16]||($[16]=Z(" Response ",-1)),t.log.error||F.value.length>0?(r(),n("span",rb,"⚠")):I("",!0)],2)])]),e("div",ab,[Ae(e("div",ob,[e("div",nb,[$[17]||($[17]=e("span",{class:"text-xs text-neutral-500 dark:text-neutral-400 mr-2"},"View as:",-1)),e("button",{onClick:$[5]||($[5]=j=>q.value="standard"),class:ae(["px-2 py-1 text-xs rounded transition-colors",q.value==="standard"?"bg-black text-white dark:bg-white dark:text-black":"bg-neutral-100 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400 hover:bg-neutral-200 dark:hover:bg-neutral-700"])}," Standard Agents ",2),(r(),n(ve,null,ye(W,j=>e("button",{key:j,onClick:he=>q.value=j,class:ae(["px-2 py-1 text-xs rounded transition-colors",q.value===j?"bg-black text-white dark:bg-white dark:text-black":"bg-neutral-100 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400 hover:bg-neutral-200 dark:hover:bg-neutral-700"])},C(A(j)),11,lb)),64)),J.value?(r(),H(Ee,{key:0,size:"xs",class:"ml-2"})):I("",!0),U.value?(r(),n("span",sb,C(U.value),1)):I("",!0)]),L.value.length>0?(r(),H(Tt,{key:0,ref_key:"toolsSectionRef",ref:y,title:`Available Tools (${L.value.length})`,"section-id":"tools",expanded:re("tools"),"scroll-container":f.value,onToggle:$[6]||($[6]=j=>V("tools"))},{default:D(()=>[(r(!0),n(ve,null,ye(L.value,(j,he)=>(r(),n("div",{key:he,class:"border-b border-neutral-200 dark:border-neutral-800 last:border-b-0"},[e("button",{onClick:X=>de(he),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",ub,C(j.function?.name||j.name||"Unknown"),1),e("span",db,C(u.value.has(he)?"▼":"▶"),1)],8,ib),Ae(e("div",cb,[j.function?.description||j.description?(r(),n("div",pb,C(j.function?.description||j.description),1)):I("",!0),w(Bt,{code:JSON.stringify(j,null,2),language:"json"},null,8,["code"])],512),[[Ke,u.value.has(he)]])]))),128))]),_:1},8,["title","expanded","scroll-container"])):I("",!0),t.log.message_history?(r(),H(Tt,{key:1,ref_key:"messagesSectionRef",ref:b,title:`Messages (${t.log.message_history_length||0} messages)`,subtitle:ke.value,"section-id":"messages",expanded:re("messages"),"scroll-container":f.value,onToggle:$[7]||($[7]=j=>V("messages"))},{default:D(()=>[w(zt,{json:ce.value,"thread-id":t.threadId,"show-copy-button":""},null,8,["json","thread-id"])]),_:1},8,["title","subtitle","expanded","scroll-container"])):I("",!0),t.log.system_prompt?(r(),H(Tt,{key:2,ref_key:"systemPromptSectionRef",ref:v,title:"System Prompt","section-id":"system_prompt",expanded:re("system_prompt"),"scroll-container":f.value,onToggle:$[8]||($[8]=j=>V("system_prompt"))},{default:D(()=>[e("div",mb,[w(Bt,{code:t.log.system_prompt,language:"markdown"},null,8,["code"]),e("div",vb,[w(na,{content:t.log.system_prompt,variant:"ghost",size:"xs"},null,8,["content"])])])]),_:1},8,["expanded","scroll-container"])):I("",!0),t.log.request_body?(r(),H(Tt,{key:3,ref_key:"requestBodySectionRef",ref:d,title:"Full Request Body",subtitle:ke.value,"section-id":"request_body",expanded:re("request_body"),"scroll-container":f.value,onToggle:$[9]||($[9]=j=>V("request_body"))},{default:D(()=>[w(zt,{json:ue.value,"thread-id":t.threadId,"show-copy-button":""},null,8,["json","thread-id"])]),_:1},8,["subtitle","expanded","scroll-container"])):I("",!0)],512),[[Ke,l.value==="request"]]),Ae(e("div",null,[F.value.length>0?(r(),n("div",fb,[e("div",hb,C(F.value.length>1?`Errors (${F.value.length})`:"Error"),1),e("div",gb,[(r(!0),n(ve,null,ye(F.value,(j,he)=>(r(),n("div",{key:he,class:"border border-red-300 dark:border-red-700 rounded overflow-hidden"},[e("div",bb,C(j.type||"error"),1),e("pre",xb,C(j.message),1)]))),128))])])):t.log.error?(r(),n("div",yb,[e("div",kb," Error "+C(t.log.error_type?`(${t.log.error_type})`:""),1),e("pre",wb,C(t.log.error),1)])):I("",!0),t.log.is_complete||!t.log.error?(r(),n("div",_b,[$[25]||($[25]=e("div",{class:"text-xs font-semibold mb-1"},"Response Stats",-1)),e("table",$b,[e("tbody",null,[e("tr",Cb,[$[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",Sb,[!t.log.is_complete&&!t.log.finish_reason?(r(),H(Ee,{key:0,size:"xs"})):(r(),n("span",Tb,C(t.log.finish_reason||"—"),1))])]),e("tr",Ib,[$[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",zb,[!t.log.is_complete&&!t.log.input_tokens?(r(),H(Ee,{key:0,size:"xs"})):(r(),n("span",Vb,C(t.log.input_tokens||"—"),1))])]),t.log.cached_tokens||!t.log.is_complete?(r(),n("tr",Mb,[$[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",Eb,[!t.log.is_complete&&!t.log.cached_tokens?(r(),H(Ee,{key:0,size:"xs"})):(r(),n("span",Lb,C(t.log.cached_tokens||0),1))])])):I("",!0),e("tr",Pb,[$[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",Ab,[!t.log.is_complete&&!t.log.output_tokens?(r(),H(Ee,{key:0,size:"xs"})):(r(),n("span",jb,C(t.log.output_tokens||"—"),1))])]),t.log.reasoning_tokens&&t.log.reasoning_tokens>0?(r(),n("tr",Db,[$[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",Ob,C(t.log.reasoning_tokens),1)])):I("",!0),e("tr",Rb,[$[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",Ub,[!t.log.is_complete&&!t.log.total_tokens?(r(),H(Ee,{key:0,size:"xs"})):(r(),n("span",Bb,C(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",Fb,[!t.log.is_complete&&!t.log.cost_total?(r(),H(Ee,{key:0,size:"xs"})):(r(),n("span",Nb,C(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))])])])])])):I("",!0),se.value.length>0?(r(),n("div",qb,[e("div",Hb," Tools Called ("+C(se.value.length)+") ",1),e("div",Wb,[(r(!0),n(ve,null,ye(se.value,j=>(r(),n("div",{key:j.id,class:"border-b border-neutral-200 dark:border-neutral-800 last:border-b-0"},[e("button",{onClick:he=>Q(j.id),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("div",Jb,[e("span",Yb,C(j.name),1),j.isQueued?(r(),n("span",Gb," programmatically invoked ")):I("",!0),j.isProvider?(r(),n("span",Zb," provider ")):I("",!0),j.isProvider&&j.status?(r(),n("span",{key:2,class:ae([j.status==="completed"?"text-green-600 dark:text-green-400":j.status==="failed"?"text-red-600 dark:text-red-400":"text-yellow-600 dark:text-yellow-400","text-[10px]"])},C(j.status),3)):I("",!0)]),e("span",Xb,C(s.value.has(j.id)?"▼":"▶"),1)],8,Kb),Ae(e("div",{class:ae(["px-2 py-2 border-t border-neutral-200 dark:border-neutral-800",j.isProvider?"bg-purple-50 dark:bg-purple-900/10":j.isQueued?"bg-emerald-50 dark:bg-emerald-900/10":"bg-white dark:bg-neutral-950"])},[j.isProvider?(r(),n(ve,{key:1},[e("div",d1,[$[32]||($[32]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Provider Tool ID ",-1)),e("div",c1,C(j.id),1)]),j.providerType==="web_search"&&j.result?.actions?(r(),n("div",p1,[(r(!0),n(ve,null,ye(j.result.actions,(he,X)=>(r(),n("div",{key:X,class:"mb-2"},[he.type==="search"?(r(),n("div",m1,[$[33]||($[33]=e("span",{class:"font-medium"},"Searched:",-1)),Z(' "'+C(he.query)+'" ',1)])):I("",!0),he.type==="open"?(r(),n("div",v1,[$[34]||($[34]=e("span",{class:"font-medium"},"Opened:",-1)),e("a",{href:he.url,target:"_blank",class:"text-blue-600 hover:underline ml-1"},C(he.url),9,f1)])):I("",!0),he.sources?.length?(r(),n("div",h1,[(r(!0),n(ve,null,ye(he.sources.slice(0,5),(pe,le)=>(r(),n("a",{key:le,href:pe.url,target:"_blank",class:"block text-blue-600 hover:underline text-xs truncate"},C(pe.title||pe.url),9,g1))),128)),he.sources.length>5?(r(),n("span",b1," ... and "+C(he.sources.length-5)+" more ",1)):I("",!0)])):I("",!0)]))),128))])):I("",!0),j.providerType==="image_generation"?(r(),n("div",x1,[j.result?.imagePath?(r(),n("span",y1,[$[35]||($[35]=Z(" Stored at: ",-1)),e("span",k1,C(j.result.imagePath),1)])):(r(),n("span",w1," See Generated Images section below "))])):I("",!0),j.providerType==="code_interpreter"&&j.result?.output?(r(),n("div",_1,[$[36]||($[36]=e("div",{class:"font-medium text-neutral-600 dark:text-neutral-400 mb-1"},"Output:",-1)),e("pre",$1,C(j.result.output),1)])):I("",!0),j.providerType==="file_search"&&j.result?.results?.length?(r(),n("div",C1,[e("div",S1," Found "+C(j.result.results.length)+" result(s) ",1)])):I("",!0)],64)):(r(),n(ve,{key:0},[j.isQueued&&j.queuedAt?(r(),n("div",Qb,[$[26]||($[26]=e("div",{class:"font-semibold text-emerald-600 dark:text-emerald-400 mb-1"}," Invoked At ",-1)),e("div",e1,[w(yt,{timestamp:j.queuedAt},null,8,["timestamp"])])])):I("",!0),e("div",t1,[$[27]||($[27]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Tool Call ID ",-1)),e("div",r1,C(j.id),1)]),e("div",a1,[$[28]||($[28]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Function Name ",-1)),e("div",o1,C(j.function?.name),1)]),e("div",n1,[$[29]||($[29]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Arguments ",-1)),e("div",l1,[w(Bt,{code:_(j.function?.arguments||"{}"),language:"json"},null,8,["code"])])]),K.value.has(j.id)?(r(),n("div",s1,[$[30]||($[30]=e("div",{class:"font-semibold text-green-600 dark:text-green-400 mb-1"}," Result ",-1)),e("pre",i1,C(K.value.get(j.id)?.content||"No content"),1)])):(r(),n("div",u1,[...$[31]||($[31]=[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)])]))],64))],2),[[Ke,s.value.has(j.id)]])]))),128))])])):I("",!0),P.value.length>0?(r(),n("div",T1,[e("div",I1," Generated Images ("+C(P.value.length)+") ",1),e("div",z1,[$[37]||($[37]=e("div",{class:"px-2 py-1.5 bg-emerald-100 dark:bg-emerald-900/30 text-xs text-emerald-800 dark:text-emerald-200 border-b border-emerald-300 dark:border-emerald-700"}," Images returned by the model ",-1)),e("div",V1,[(r(!0),n(ve,null,ye(P.value,(j,he)=>(r(),n("div",{key:he,class:"relative"},[j.image_url?.url?(r(),n("img",{key:0,src:g(j.image_url.url)||j.image_url.url,alt:`Generated image ${he+1}`,class:"max-w-[300px] max-h-[300px] rounded border border-emerald-200 dark:border-emerald-800 object-contain"},null,8,M1)):(r(),n("div",E1," No URL "))]))),128))])])])):I("",!0),t.log.reasoning_content?(r(),n("div",L1,[e("div",P1,[e("button",{onClick:E,class:"w-full px-2 py-1.5 bg-accent-100 dark:bg-accent-900/30 text-xs text-accent-800 dark:text-accent-200 flex items-center justify-between hover:bg-accent-200 dark:hover:bg-accent-900/50 transition-colors"},[$[38]||($[38]=e("div",{class:"flex items-center gap-2"},[e("span",{class:"font-semibold"},"Reasoning Content"),e("span",{class:"text-accent-600 dark:text-accent-400 font-normal"}," Internal reasoning output (not displayed to users) ")],-1)),e("span",A1,C(x.value?"▶":"▼"),1)]),Ae(e("pre",{class:"text-xs p-2 overflow-x-auto whitespace-pre-wrap max-h-96 text-accent-900 dark:text-accent-100 border-t border-accent-300 dark:border-accent-700"},C(z.value),513),[[Ke,!x.value]])])])):I("",!0),Y.value.length>0?(r(),n("div",j1,[e("div",D1,[e("button",{onClick:S,class:"w-full px-2 py-1.5 bg-purple-100 dark:bg-purple-900/30 text-xs text-purple-800 dark:text-purple-200 flex items-center justify-between hover:bg-purple-200 dark:hover:bg-purple-900/50 transition-colors"},[e("div",O1,[$[39]||($[39]=e("span",{class:"font-semibold"},"Reasoning Details",-1)),e("span",R1,C(Y.value.length)+" blocks ",1),$[40]||($[40]=e("span",{class:"text-purple-600 dark:text-purple-400 font-normal"}," Structured reasoning from OpenRouter ",-1))]),e("span",U1,C(c.value?"▶":"▼"),1)]),Ae(e("div",B1,[(r(!0),n(ve,null,ye(Y.value,(j,he)=>(r(),n("div",{key:he,class:"p-2"},[e("div",F1,[e("span",N1,C(j.type||"unknown"),1),j.id?(r(),n("span",q1," ID: "+C(j.id),1)):I("",!0),j.format?(r(),n("span",H1," Format: "+C(j.format),1)):I("",!0),j.index!==void 0?(r(),n("span",W1," Index: "+C(j.index),1)):I("",!0)]),j.type==="reasoning.summary"&&j.summary?(r(),n("div",K1,[$[41]||($[41]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Summary: ",-1)),e("div",J1,C(j.summary),1)])):I("",!0),j.type==="reasoning.encrypted"&&j.data?(r(),n("div",Y1,[$[42]||($[42]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Encrypted Data: ",-1)),e("div",G1,C(j.data),1)])):I("",!0),j.type==="reasoning.text"&&j.text?(r(),n("div",Z1,[$[44]||($[44]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Reasoning Text: ",-1)),e("div",X1,C(j.text),1),j.signature?(r(),n("div",Q1,[$[43]||($[43]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Signature: ",-1)),e("div",ex,C(j.signature),1)])):I("",!0)])):I("",!0),["reasoning.summary","reasoning.encrypted","reasoning.text"].includes(j.type)?I("",!0):(r(),n("div",tx,[e("pre",rx,C(JSON.stringify(j,null,2)),1)]))]))),128))],512),[[Ke,!c.value]])])])):I("",!0),t.log.response_body?(r(),n("div",ax,[$[45]||($[45]=e("div",{class:"text-xs font-semibold mb-1"},"Full Response Body",-1)),e("div",ox,[w(zt,{json:t.log.response_body,"thread-id":t.threadId,"show-copy-button":""},null,8,["json","thread-id"])])])):I("",!0)],512),[[Ke,l.value==="response"]])])],512))}}),lx={class:"flex flex-col h-full"},sx={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},ix={class:"flex items-center justify-between"},ux={class:"flex items-center gap-2"},dx={key:0,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},cx={key:1,class:"flex justify-center py-12"},px={key:2,class:"text-red-600 dark:text-red-400 text-center py-12"},mx={key:3,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},vx={key:4},fx={key:0,class:"border-b border-neutral-300 dark:border-neutral-700 bg-white dark:bg-black sticky top-0 z-10"},hx=["disabled"],gx={key:1},bx={key:2},xx={key:3},yx={class:"w-full text-sm"},kx=["onClick","onMouseenter"],wx={class:"px-3 py-2 text-xs"},_x={class:"flex items-center gap-1"},$x={key:0,class:"text-neutral-400 dark:text-neutral-600 mr-1"},Cx={key:3},Sx={class:"px-3 py-2"},Tx={class:"flex items-center gap-2"},Ix={key:0,class:"text-red-600 dark:text-red-400",title:"Error"},zx={class:"font-mono text-xs"},Vx={class:"px-3 py-2 font-mono text-xs"},Mx={key:1},Ex={key:1,class:"text-neutral-400"},Lx={key:2},Px={key:0,class:"text-emerald-600 dark:text-emerald-400",title:"Programmatically called with state.queueTool()"},Ax={key:1},jx={key:2},Dx={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"},Ox={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"},Rx={key:0,class:"flex flex-col items-center justify-center h-full gap-3 text-neutral-500 dark:text-neutral-400"},Ux={key:2,class:"absolute inset-0 bg-white/50 dark:bg-black/50 flex items-center justify-center"},fr=20,Bx=20,Fx=me({__name:"LogsPane",props:{threadId:{},selectedLogId:{},hoveredLogId:{}},emits:["logClick","logHover","logsLoaded"],setup(t,{expose:o,emit:a}){const i=t,l=a,u=p(0),s=p(fr),{logs:m,hasMore:h,isFetching:x,error:c,wsConnected:f,wsError:y,connectWebSocket:b,disconnectWebSocket:v,refetch:d}=eg(B(()=>i.threadId),{limit:B(()=>s.value),offset:B(()=>u.value),enableWebSocket:!0,order:"desc"}),k=p([]),g=p(!0),_=p(null),L=p(null),R=p(!1),K=p(!1),Y=p(new Map),z=async()=>{await Le(),L.value&&(L.value.scrollTop=L.value.scrollHeight)},P=p(null);ge(m,async X=>{if(u.value===0)k.value=[...X].reverse(),g.value&&k.value.length>0&&(await z(),g.value=!1);else{const pe=[...X].reverse(),le=new Map;k.value.forEach(we=>le.set(we.id,we)),pe.forEach(we=>le.set(we.id,we)),k.value=Array.from(le.values()).sort((we,oe)=>we.created_at-oe.created_at)}},{deep:!0,immediate:!0}),ge(x,(X,pe)=>{if(pe&&!X&&u.value===0&&i.threadId&&P.value!==i.threadId&&k.value.length>0){P.value=i.threadId;const le=k.value[k.value.length-1];l("logsLoaded",le?.id??null)}});const{logDetails:G,isFetching:ee}=tg(B(()=>i.threadId),B(()=>_.value)),se=B(()=>{if(!_.value)return null;const pe=k.value.find(le=>le.id===_.value);return pe?G.value?{...G.value,...pe}:pe:null}),de=B(()=>_.value?he.value.findIndex(X=>X.id===_.value):-1),Q=B(()=>de.value>0),E=B(()=>de.value>=0&&de.value<he.value.length-1),S=()=>{if(Q.value){const X=he.value[de.value-1];F(X)}},V=()=>{if(E.value){const X=he.value[de.value+1];F(X)}},re=X=>{if(!L.value)return;const pe=Y.value.get(X);if(!pe)return;const le=L.value,we=pe.getBoundingClientRect(),oe=le.getBoundingClientRect(),ie=le.querySelectorAll(".sticky");let Ve=0;ie.forEach(xe=>{Ve+=xe.getBoundingClientRect().height}),Ve+=16;const _e=we.top<oe.top+Ve,$e=we.bottom>oe.bottom;_e?le.scrollBy({top:we.top-oe.top-Ve,behavior:"smooth"}):$e&&le.scrollBy({top:we.bottom-oe.bottom,behavior:"smooth"})},F=X=>{l("logClick",X.id),_.value=X.id},q=(X,pe)=>{pe?Y.value.set(X,pe):Y.value.delete(X)};ge(_,async X=>{X&&(await Le(),re(X))}),ge(()=>i.selectedLogId,X=>{X&&(_.value=X)},{immediate:!0});const N=X=>{_.value=X},J=async X=>{await Le();const pe=Y.value.get(X);if(pe&&L.value){const le=L.value,we=pe.getBoundingClientRect(),oe=le.getBoundingClientRect(),ie=le.querySelector("thead"),Ve=le.querySelector(":scope > div > div.sticky");let _e=0;ie&&(_e+=ie.getBoundingClientRect().height),Ve&&(_e+=Ve.getBoundingClientRect().height),_e+=40;const $e=we.top<oe.top+_e,xe=we.bottom>oe.bottom;$e?le.scrollBy({top:we.top-oe.top-_e,behavior:"smooth"}):xe&&le.scrollBy({top:we.bottom-oe.bottom,behavior:"smooth"})}},U=X=>{if(X.length===0)return;const pe=new Set(X);k.value=k.value.filter(le=>!pe.has(le.id))},W=p(!1),M=X=>k.value.some(pe=>pe.id===X),ne=X=>k.value.find(pe=>pe.id===X)??null,A=(X,pe=3e3)=>new Promise(le=>{const we=Date.now(),oe=ge(k,()=>{k.value.length!==X&&(oe(),le(!0))},{deep:!0}),ie=setInterval(()=>{k.value.length!==X?(clearInterval(ie),oe(),le(!0)):Date.now()-we>pe&&(clearInterval(ie),oe(),le(!1))},50)});o({scrollToLog:J,selectLogById:N,removeLogsByIds:U,loadUntilLogId:async X=>{if(M(X))return!0;if(!h.value)return!1;W.value=!0;const pe=100,le=50;try{let we=0;for(;h.value&&!M(X)&&we<le;){we++;const oe=k.value.length;if(u.value+=s.value,s.value=pe,await d(),!await A(oe))break}return M(X)}finally{W.value=!1}},hasLog:M,getLog:ne,setLoadingForLog:X=>{W.value=X},waitForLogRow:async(X,pe=2e3)=>{const le=Date.now();for(;Date.now()-le<pe;){if(Y.value.has(X))return!0;if(!he.value.some(oe=>oe.id===X)){await Le(),await new Promise(oe=>setTimeout(oe,16));continue}await Le(),await new Promise(oe=>setTimeout(oe,16))}return!1}});const be=async()=>{if(K.value||!h.value||x.value)return;K.value=!0;const X=L.value?.scrollHeight||0;if(u.value+=s.value,s.value=Bx,await d(),await Le(),L.value){const pe=L.value.scrollHeight;L.value.scrollTop+=pe-X}K.value=!1};ge(()=>i.threadId,async X=>{X?(v(),b()):v(),u.value=0,s.value=fr,k.value=[],_.value=null,R.value=!1,g.value=!0},{immediate:!0}),ge(k,async()=>{R.value||await z()},{deep:!0});const O=()=>{if(!L.value)return;const{scrollTop:X,scrollHeight:pe,clientHeight:le}=L.value,we=pe-X-le<50;R.value=!we},$=X=>{const pe=[];if(X.tools_called)try{const le=JSON.parse(X.tools_called);Array.isArray(le)&&pe.push(...le.map(we=>({name:we,isProgrammatic:!1})))}catch{}if(X.provider_tools)try{const le=JSON.parse(X.provider_tools);Array.isArray(le)&&pe.push(...le.map(we=>({name:we.type,isProgrammatic:!1})))}catch{}if(X.queued_tools)try{const le=JSON.parse(X.queued_tools);Array.isArray(le)&&pe.push(...le.map(we=>({name:we.function?.name||"unknown",isProgrammatic:!0})))}catch{}return pe},j=X=>X==null?"—":`$${X.toFixed(6)}`,he=B(()=>{const X=new Map,pe=new Map;k.value.forEach(oe=>{X.set(oe.id,oe);const ie=oe.parent_log_id;ie&&(pe.has(ie)||pe.set(ie,[]),pe.get(ie).push(oe))});const le=[],we=(oe,ie)=>{le.push({...oe,depth:ie}),(pe.get(oe.id)||[]).forEach(_e=>{we(_e,ie+1)})};return k.value.forEach(oe=>{oe.parent_log_id||we(oe,0)}),le});return(X,pe)=>(r(),n("div",lx,[e("div",sx,[e("div",ix,[e("div",ux,[w(T(qa),{size:18,class:"shrink-0"}),pe[3]||(pe[3]=e("h2",{class:"text-base font-bold"},"Logs",-1)),t.threadId?(r(),H(er,{key:0,connected:T(f),error:T(y)},null,8,["connected","error"])):I("",!0)])])]),e("div",{ref_key:"logsScrollContainer",ref:L,class:"logs-list-container flex-1 overflow-y-auto overflow-x-auto",onScroll:O},[t.threadId?T(x)&&u.value===0?(r(),n("div",cx,[w(Ee)])):T(c)?(r(),n("div",px," Error loading logs: "+C(T(c)),1)):k.value.length===0?(r(),n("div",mx," No logs yet ")):(r(),n("div",vx,[T(h)?(r(),n("div",fx,[e("button",{onClick:be,disabled:K.value||W.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"},[K.value||W.value?(r(),H(Ee,{key:0,size:"xs"})):I("",!0),W.value?(r(),n("span",gx,"Loading to find log...")):K.value?(r(),n("span",bx,"Loading older logs...")):(r(),n("span",xx,"Load previous logs"))],8,hx)])):I("",!0),e("table",yx,[e("thead",{class:ae(["border-b border-neutral-300 dark:border-neutral-700 sticky bg-white z-[10] dark:bg-black",{"top-0":!T(h),"top-[34px]":T(h)}])},[...pe[4]||(pe[4]=[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,[(r(!0),n(ve,null,ye(he.value,le=>(r(),n("tr",{key:le.id,ref_for:!0,ref:we=>q(le.id,we),class:ae(["border-b border-neutral-200 dark:border-neutral-800 cursor-pointer transition-colors relative",{"last:border-b-0":se.value,"bg-red-50 dark:bg-red-950/20":le.error,"bg-accent-100 dark:bg-accent-900 dark:text-white":_.value===le.id,"ring-2 ring-inset ring-accent-400 dark:ring-accent-400":le.id===i.selectedLogId||le.id!==i.selectedLogId&&le.id===i.hoveredLogId}]),onClick:we=>F(le),onMouseenter:we=>l("logHover",le.id),onMouseleave:pe[0]||(pe[0]=we=>l("logHover",null))},[e("td",wx,[e("div",_x,[le.depth>0?(r(),n("span",$x,"└─")):I("",!0),le.retry_of_log_id?(r(),H(T(Ha),{key:1,size:14,class:"text-neutral-500 dark:text-neutral-400 flex-shrink-0"})):I("",!0),!le.is_complete&&!le.prompt_name?(r(),H(Ee,{key:2,size:"xs"})):(r(),n("span",Cx,C(le.prompt_name||"—"),1))])]),e("td",Sx,[e("div",Tx,[le.error?(r(),n("span",Ix," ✕ ")):I("",!0),e("span",zx,C(le.model_name||le.model),1)])]),e("td",Vx,[!le.is_complete&&!le.cost_total?(r(),H(Ee,{key:0,size:"xs"})):(r(),n("span",Mx,C(j(le.cost_total)),1))]),e("td",{class:ae(["px-3 py-2 text-xs",_.value===le.id?"text-neutral-800 dark:text-neutral-100":"text-neutral-600 dark:text-neutral-400"])},[!le.is_complete&&$(le).length===0?(r(),H(Ee,{key:0,size:"xs"})):$(le).length===0?(r(),n("span",Ex,"—")):(r(),n("span",Lx,[(r(!0),n(ve,null,ye($(le),(we,oe)=>(r(),n(ve,{key:oe},[we.isProgrammatic?(r(),n("span",Px,[w(T(Wa),{size:11,class:"inline-block -mt-0.5 mr-0.5"}),Z(C(we.name),1)])):(r(),n("span",Ax,C(we.name),1)),oe<$(le).length-1?(r(),n("span",jx,", ")):I("",!0)],64))),128))]))],2),e("td",{class:ae(["px-3 py-2 text-right text-xs",_.value===le.id?"text-neutral-800 dark:text-neutral-100":"text-neutral-500 dark:text-neutral-500"])},[w(yt,{timestamp:le.created_at},null,8,["timestamp"])],2)],42,kx))),128))])])])):(r(),n("div",dx," Select a thread to view logs "))],544),w(et,{name:"slide-up",onAfterEnter:pe[2]||(pe[2]=()=>_.value&&re(_.value))},{default:D(()=>[se.value||W.value&&_.value?(r(),n("div",Dx,[e("div",Ox,[W.value&&!se.value?(r(),n("div",Rx,[w(Ee),pe[5]||(pe[5]=e("span",{class:"text-sm"},"Loading log...",-1))])):se.value?(r(),H(nx,{key:1,log:se.value,"thread-id":t.threadId,"has-previous":Q.value,"has-next":E.value,onClose:pe[1]||(pe[1]=le=>_.value=null),onPrevious:S,onNext:V},null,8,["log","thread-id","has-previous","has-next"])):I("",!0),T(ee)&&se.value?(r(),n("div",Ux,[w(Ee)])):I("",!0)])])):I("",!0)]),_:1})]))}}),Nx=Xe(Fx,[["__scopeId","data-v-f8e4fdfe"]]),qx={class:"space-y-4"},Hx={key:0},Wx={key:1},Kx={key:1,class:"space-y-4 p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},Jx={key:2,class:"p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg text-center text-sm text-neutral-500"},Yx={key:3,class:"space-y-4"},Gx={key:0,class:"p-4 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-700 rounded-lg"},Zx={class:"space-y-3"},Xx={key:0,class:"text-xs text-amber-500 dark:text-amber-400 mt-1"},Qx={key:1,class:"p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},ey={key:4,class:"p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg text-center text-sm text-neutral-500"},ty={class:"flex justify-between"},ry=me({__name:"CreateThreadModal",props:{modelValue:{type:Boolean},editThread:{}},emits:["update:modelValue","thread-created","thread-updated"],setup(t,{emit:o}){const a=t,i=o,l=B(()=>!!a.editThread),u=p(""),s=p(""),m=p({}),h=p(!1),x=p(""),c=p({}),f=p([]),y=p(!1),{data:b,isFetching:v,execute:d}=Ne(fe("/api/agents"),{immediate:!1}).json(),k=B(()=>b.value?(b.value?.agents||[]).map(V=>({value:V.id,label:V.title})):[]),g=B(()=>!u.value||!b.value?null:(b.value?.agents||[]).find(V=>V.id===u.value)),{data:_,isFetching:L,execute:R}=Ne(B(()=>g.value?.side_a_system_prompt?fe(`/api/prompts/${g.value.side_a_system_prompt}`):""),{immediate:!1}).json(),K=B(()=>{if(!_.value)return null;const S=_.value?.required_schema;if(!S)return null;try{return typeof S=="string"?JSON.parse(S):S}catch{return null}}),Y=B(()=>f.value.filter(S=>S.required&&!S.value&&!c.value[S.name])),z=B(()=>f.value.filter(S=>S.value!==void 0||!S.required)),P=B(()=>f.value.length>0),G=async S=>{if(!S){f.value=[],c.value={};return}y.value=!0;try{const V=await fetch(fe(`/api/agents/${S}/tenvs`));if(V.ok){const re=await V.json();f.value=re.tenvs||[],c.value=re.merged||{}}else f.value=[],c.value={}}catch(V){console.error("Error fetching agent tenvs:",V),f.value=[],c.value={}}finally{y.value=!1}},ee=B(()=>{const S=K.value;return!S||!S.properties?[]:Object.entries(S.properties).map(([V,re])=>({name:V,type:re.type||"string",description:re.description||"",required:S.required?.includes(V)||!1,enum:re.enum}))});ge(u,async S=>{S&&g.value?.side_a_system_prompt?(await R(),m.value={}):m.value={},S?await G(S):(f.value=[],c.value={})});const se=()=>{u.value="",s.value="",m.value={},x.value="",c.value={},f.value=[]},de=()=>{a.editThread&&(u.value=a.editThread.agent_id,s.value=a.editThread.tags?.join(", ")||"")},Q=async()=>{if(!u.value){x.value="Please select an agent";return}if(!l.value&&ee.value.length>0){for(const S of ee.value)if(S.required&&!m.value[S.name]){x.value=`Please provide ${S.name}`;return}}if(!l.value&&Y.value.length>0){for(const S of Y.value)if(!c.value[S.name]){x.value=`Please provide required environment variable: ${S.name}`;return}}h.value=!0,x.value="";try{const S=s.value.split(",").map(V=>V.trim()).filter(V=>V.length>0);if(l.value){const V=await fetch(fe(`/api/threads/${a.editThread.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tags:S})});if(!V.ok){const re=await V.json();throw new Error(re.error||"Failed to update thread")}i("thread-updated"),se(),i("update:modelValue",!1)}else{const V={agent_id:u.value,tags:S.length>0?S:void 0};Object.keys(m.value).length>0&&(V.data=m.value),Object.keys(c.value).length>0&&(V.tenvs=c.value);const re=await fetch(fe("/api/threads"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(V)});if(!re.ok){const N=await re.json();throw new Error(N.error||"Failed to create thread")}const q=(await re.json()).threadId;if(!q)throw new Error("Thread created but ID not found in response");i("thread-created",q),se(),i("update:modelValue",!1)}}catch(S){console.error(`Error ${l.value?"updating":"creating"} thread:`,S),x.value=S.message||`Failed to ${l.value?"update":"create"} thread`}finally{h.value=!1}},E=()=>{se(),i("update:modelValue",!1)};return ge(()=>a.modelValue,async S=>{S&&(await d(),se(),l.value&&de())}),(S,V)=>{const re=Be("FormKit");return r(),H(He,{"model-value":t.modelValue,"onUpdate:modelValue":V[3]||(V[3]=F=>S.$emit("update:modelValue",F)),title:l.value?"Edit Thread":"Create New Thread",width:"max-w-3xl"},{footer:D(()=>[e("div",ty,[w(T(De),{variant:"ghost",size:"sm",disabled:h.value,onClick:E},{default:D(()=>[...V[10]||(V[10]=[Z(" Cancel ",-1)])]),_:1},8,["disabled"]),w(T(De),{variant:"primary",size:"sm",disabled:h.value||T(v),loading:h.value,onClick:Q},{default:D(()=>[l.value?(r(),n(ve,{key:0},[Z(C(h.value?"Updating...":"Update Thread"),1)],64)):(r(),n(ve,{key:1},[Z(C(h.value?"Creating...":"Create Thread"),1)],64))]),_:1},8,["disabled","loading"])])]),default:D(()=>[e("div",qx,[x.value?(r(),H(T(Fe),{key:0,variant:"error"},{default:D(()=>[Z(C(x.value),1)]),_:1})):I("",!0),e("div",null,[w(re,{type:"selectSearch",modelValue:u.value,"onUpdate:modelValue":V[0]||(V[0]=F=>u.value=F),label:"Agent",options:k.value,disabled:T(v)||l.value,placeholder:"Select an agent...",validation:"required"},null,8,["modelValue","options","disabled"]),w(T(ze),{class:"mt-1"},{default:D(()=>[l.value?(r(),n("span",Hx,"Agent cannot be changed after thread creation")):(r(),n("span",Wx,"Choose which agent will handle this conversation"))]),_:1})]),!l.value&&ee.value.length>0&&!T(L)?(r(),n("div",Kx,[V[4]||(V[4]=e("h4",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Required Information ",-1)),(r(!0),n(ve,null,ye(ee.value,F=>(r(),n("div",{key:F.name,class:"space-y-2"},[F.enum?(r(),H(re,{key:0,type:"selectSearch",modelValue:m.value[F.name],"onUpdate:modelValue":q=>m.value[F.name]=q,label:F.name,options:[{value:"",label:"Select..."},...F.enum.map(q=>({value:q,label:q}))],validation:F.required?"required":""},null,8,["modelValue","onUpdate:modelValue","label","options","validation"])):F.type==="string"?(r(),H(re,{key:1,type:"text",modelValue:m.value[F.name],"onUpdate:modelValue":q=>m.value[F.name]=q,label:F.name,placeholder:F.description,validation:F.required?"required":""},null,8,["modelValue","onUpdate:modelValue","label","placeholder","validation"])):F.type==="number"||F.type==="integer"?(r(),H(re,{key:2,type:"number",modelValue:m.value[F.name],"onUpdate:modelValue":q=>m.value[F.name]=q,label:F.name,placeholder:F.description,validation:F.required?"required":""},null,8,["modelValue","onUpdate:modelValue","label","placeholder","validation"])):F.type==="boolean"?(r(),H(re,{key:3,type:"checkbox",modelValue:m.value[F.name],"onUpdate:modelValue":q=>m.value[F.name]=q,label:F.name,validation:F.required?"required":""},null,8,["modelValue","onUpdate:modelValue","label","validation"])):(r(),H(re,{key:4,type:"textarea",modelValue:m.value[F.name],"onUpdate:modelValue":q=>m.value[F.name]=q,label:F.name,placeholder:F.description||`Enter ${F.name} (JSON format)`,validation:F.required?"required":"",rows:3},null,8,["modelValue","onUpdate:modelValue","label","placeholder","validation"])),F.description?(r(),H(T(ze),{key:5,class:"mt-1"},{default:D(()=>[Z(C(F.description),1)]),_:2},1024)):I("",!0)]))),128))])):I("",!0),!l.value&&T(L)?(r(),n("div",Jx," Loading agent requirements... ")):I("",!0),!l.value&&P.value&&!y.value?(r(),n("div",Yx,[Y.value.length>0?(r(),n("div",Gx,[V[5]||(V[5]=e("h4",{class:"text-sm font-medium text-amber-800 dark:text-amber-200 mb-3"}," Required Environment Variables ",-1)),V[6]||(V[6]=e("p",{class:"text-xs text-amber-600 dark:text-amber-300 mb-3"}," These values are required by the agent's tools and must be provided. ",-1)),e("div",Zx,[(r(!0),n(ve,null,ye(Y.value,F=>(r(),n("div",{key:F.name},[w(re,{type:"text","model-value":c.value[F.name]||"",onInput:q=>c.value[F.name]=q,label:F.name,placeholder:F.description||"Enter value...",validation:"required"},null,8,["model-value","onInput","label","placeholder"]),F.source?(r(),n("p",Xx," Required by: "+C(F.source),1)):I("",!0)]))),128))])])):I("",!0),z.value.length>0?(r(),n("div",Qx,[V[7]||(V[7]=e("h4",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300 mb-3"}," Environment Configuration ",-1)),V[8]||(V[8]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 mb-3"}," Values inherited from the agent. Click the lock icon to override. ",-1)),w(Zt,{modelValue:c.value,"onUpdate:modelValue":V[1]||(V[1]=F=>c.value=F),inherited:z.value,"allow-custom":!0},null,8,["modelValue","inherited"])])):I("",!0)])):I("",!0),!l.value&&y.value?(r(),n("div",ey," Loading environment configuration... ")):I("",!0),e("div",null,[w(re,{type:"text",modelValue:s.value,"onUpdate:modelValue":V[2]||(V[2]=F=>s.value=F),label:"Tags",placeholder:"research, urgent, production"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...V[9]||(V[9]=[Z(" Comma-separated tags to help organize and search threads ",-1)])]),_:1})])])]),_:1},8,["model-value","title"])}}}),ay={class:"flex h-full overflow-hidden"},oy={key:0,class:"flex flex-col items-center p-4"},ny={key:0,class:"flex flex-col items-center p-4"},ly={class:"flex-1 overflow-hidden flex flex-col min-h-0"},hr=me({__name:"ThreadsView",setup(t){const o=ut(),a=bt(),i=p(typeof o.params.id=="string"?o.params.id:null),l=p({threadList:!1,messages:!1}),u=p(!1),s=p(null),m=p(null),{thread:h}=Qt(B(()=>i.value)),x=p(null),c=p(null),f=p(null),y=p(null),b=p(null),v=S=>{y.value=S,b.value=S},d=S=>{const V=g.value,re=_.value;if(!V||!re)return null;if(V.hasWorkblockForLogId(S))return S;let F=S;const q=10;for(let N=0;N<q&&F;N++){const J=re.getLog(F);if(!J)break;const U=J.parent_log_id;if(!U)break;if(V.hasWorkblockForLogId(U))return U;F=U}return null},k=S=>{if(y.value=S,!S){b.value=null;return}b.value=d(S)??S},g=p(null),_=p(null);ge(()=>o.params.id,S=>{i.value=typeof S=="string"?S:null,x.value=null,c.value=null,f.value=null});const L=S=>{a.push(`/threads/${S}`)},R=S=>{window.location.href="/threads"},K=()=>{h.value&&(s.value=h.value,u.value=!0)},Y=()=>{s.value=null,u.value=!0},z=S=>{m.value?.refetch(),a.push(`/threads/${S}`)},P=()=>{m.value?.refetch()},G=S=>{l.value[S]=!l.value[S]},ee=async(S,V)=>{if(x.value=S,!V){c.value=null,f.value=null;return}const re=_.value;if(!re){c.value=V,f.value=V;return}const F=!re.hasLog(V);if(F&&re.setLoadingForLog(!0),c.value=V,f.value=V,F&&!await re.loadUntilLogId(V)){console.warn(`Could not find log ${V} after loading all available logs`),re.setLoadingForLog(!1);return}if(!await re.waitForLogRow(V)){console.warn(`Log row ${V} not rendered in time`);return}re.scrollToLog(V),re.selectLogById(V)},se=S=>{c.value=S,x.value=null;const V=g.value;if(!V){f.value=S;return}if(V.scrollToLogId(S)){f.value=S;return}const re=d(S);re&&re!==S&&V.scrollToLogId(re),f.value=re??S},de=S=>{S&&(c.value=S)},Q=S=>{_.value?.removeLogsByIds(S)},E=S=>{S&&!i.value&&a.push(`/threads/${S}`)};return(S,V)=>(r(),n("div",ay,[e("div",{class:ae([l.value.threadList?"w-[60px]":"w-[320px]","border-r border-neutral-300 dark:border-neutral-700 flex-shrink-0 transition-all duration-200 flex flex-col min-h-0"])},[l.value.threadList?(r(),n("div",oy,[e("button",{onClick:V[0]||(V[0]=re=>G("threadList")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Threads pane"},[w(T(Er),{size:20})])])):(r(),H(vv,{key:1,ref_key:"threadListPaneRef",ref:m,"selected-thread-id":i.value,onSelectThread:L,onCollapse:V[1]||(V[1]=re=>G("threadList")),onCreateThread:Y,onThreadsLoaded:E},null,8,["selected-thread-id"]))],2),e("div",{class:ae([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 flex flex-col min-h-0"])},[l.value.messages?(r(),n("div",ny,[e("button",{onClick:V[2]||(V[2]=re=>G("messages")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Messages pane"},[w(T(jr),{size:20})])])):i.value?(r(),H(T(xo),{key:1,"thread-id":i.value,preload:!0,live:!0,"include-silent":!0,"use-workblocks":!0},{default:D(()=>[w(vr,{ref_key:"messagesPaneRef",ref:g,"thread-id":i.value,"selected-message-id":x.value,"selected-log-id":f.value,"hovered-log-id":b.value,onCollapse:V[3]||(V[3]=re=>G("messages")),onMessageClick:ee,onMessageHover:v,onThreadDeleted:R,onEditThread:K,onLogsDeleted:Q,onThreadUpdated:P},null,8,["thread-id","selected-message-id","selected-log-id","hovered-log-id"])]),_:1},8,["thread-id"])):l.value.messages?I("",!0):(r(),H(vr,{key:2,ref_key:"messagesPaneRef",ref:g,"thread-id":null,"selected-message-id":x.value,"selected-log-id":f.value,"hovered-log-id":b.value,onCollapse:V[4]||(V[4]=re=>G("messages")),onMessageClick:ee,onMessageHover:v,onThreadDeleted:R,onEditThread:K,onLogsDeleted:Q,onThreadUpdated:P},null,8,["selected-message-id","selected-log-id","hovered-log-id"]))],2),e("div",ly,[w(Nx,{ref_key:"logsPaneRef",ref:_,"thread-id":i.value,"selected-log-id":c.value,"hovered-log-id":y.value,onLogClick:se,onLogHover:k,onLogsLoaded:de},null,8,["thread-id","selected-log-id","hovered-log-id"])]),w(ry,{modelValue:u.value,"onUpdate:modelValue":V[5]||(V[5]=re=>u.value=re),"edit-thread":s.value,onThreadCreated:z,onThreadUpdated:P},null,8,["modelValue","edit-thread"])]))}}),sy=me({__name:"PromptsDataTable",props:{title:{},description:{},primaryAction:{}},emits:["add","edit","delete"],setup(t,{expose:o,emit:a}){const i=a,l=p([]),u=p(!1),s=[{key:"name",label:"Name",width:"w-1/4",sortable:!0},{key:"tool_description",label:"Description",width:"w-2/5"},{key:"model_name",label:"Model",width:"w-1/5",sortable:!0,filterable:!0,formatter:(c,f)=>c||f.model_id||"-",filterIcon:(c,f)=>f.model_provider?`/api/providers/${f.model_provider}/icon?model=${encodeURIComponent(f.model_id||"")}`:void 0},{key:"created_at",label:"Created",width:"w-1/6",sortable:!0,searchable:!1,formatter:c=>c?new Date(c*1e3).toLocaleDateString():"-"}],m=[{icon:"edit",label:"Edit",handler:c=>i("edit",c)},{icon:"delete",label:"Delete",handler:async c=>{await x(c)},confirm:!0,confirmMessage:"Are you sure you want to delete this prompt?",variant:"danger"}],h=async()=>{u.value=!0;try{const c=await fetch(fe("/api/prompts"));if(c.ok){const f=await c.json();l.value=f.prompts||[]}}catch(c){console.error("Error fetching prompts:",c)}finally{u.value=!1}},x=async c=>{try{const f=await fetch(fe(`/api/prompts/${c.id}`),{method:"DELETE"});if(f.ok)await h();else{const y=await f.json();alert(y.error||"Failed to delete prompt")}}catch(f){console.error("Error deleting prompt:",f),alert("Failed to delete prompt")}};return Pe(()=>{h()}),o({refresh:h}),(c,f)=>(r(),n("div",null,[w(ot,{title:t.title,description:t.description,"primary-action":t.primaryAction,columns:s,data:l.value,actions:m,loading:u.value,sortable:"",searchable:"","search-placeholder":"Search prompts...","empty-message":"No prompts available. Create your first prompt to get started."},null,8,["title","description","primary-action","data","loading"])]))}}),iy={class:"space-y-4"},uy={key:0,class:"mt-1 text-sm text-red-500"},dy={key:1,class:"-mt-2 text-sm text-neutral-500 dark:text-neutral-400"},cy={class:"px-1 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded"},py=me({__name:"PromptBasicInfo",props:{name:{},toolDescription:{}},emits:["update:name","update:toolDescription"],setup(t,{emit:o}){const a=t,i=o,l=p(""),u=m=>{let h=m.replace(/[^a-zA-Z0-9\s_]/g,"");return h=h.trim().toLowerCase().replace(/\s+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),h?/^[a-z][a-z0-9_]*$/.test(h)?l.value="":l.value="Name must start with a letter and contain only lowercase letters, numbers, and underscores":l.value="Name is required",h},s=m=>{const h=u(m);i("update:name",h)};return ge(()=>a.name,m=>{m&&u(m)},{immediate:!0}),(m,h)=>{const x=Be("FormKit");return r(),n("div",iy,[w(x,{type:"text",value:t.name,onInput:s,label:"Prompt Name",placeholder:"Enter a unique name (will be converted to snake_case)","outer-class":"$reset"},null,8,["value"]),l.value?(r(),n("p",uy,C(l.value),1)):t.name?(r(),n("p",dy,[h[1]||(h[1]=Z(" Will be saved as: ",-1)),e("code",cy,C(t.name),1)])):I("",!0),w(x,{type:"textarea",value:t.toolDescription,onInput:h[0]||(h[0]=c=>i("update:toolDescription",c)),label:"Tool Description",placeholder:"Describe what this prompt does (shown when used as a tool)",rows:"3","outer-class":"$reset"},null,8,["value"])])}}}),my={class:"space-y-4"},vy=me({__name:"PromptModelSelect",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:o}){const a=o,i=p([]),l=p(!1),u=B(()=>i.value.map(m=>({value:m.id,label:m.name,description:m.model||m.provider,icon:m.provider?`/api/providers/${m.provider}/icon?model=${encodeURIComponent(m.model||"")}`:void 0}))),s=async()=>{l.value=!0;try{const m=await fetch(fe("/api/models"));if(m.ok){const h=await m.json();i.value=h.models||[]}}catch(m){console.error("Error fetching models:",m)}finally{l.value=!1}};return Pe(()=>{s()}),(m,h)=>{const x=Be("FormKit");return r(),n("div",my,[w(x,{type:"selectSearch",value:t.modelValue,onInput:h[0]||(h[0]=c=>a("update:modelValue",c)),options:u.value,label:"Model",placeholder:"Select a model for this prompt","search-placeholder":"Search models...",loading:l.value,"outer-class":"$reset"},null,8,["value","options","loading"])])}}});function gr(t,o){if(!o||!o.properties||Object.keys(o.properties).length===0)return!0;if(!t||!t.properties)return Object.keys(o.properties);const a=[],i=t.properties||{},l=o.properties||{};return(o.required||[]).forEach(s=>{s in i||a.push(s)}),Object.keys(l).forEach(s=>{!(s in i)&&!a.includes(s)&&a.push(s)}),a.length>0?a:!0}function br(t){return t.length===0?"":t.length===1?`Missing required field: ${t[0]}`:`Missing required fields: ${t.join(", ")}`}const fy=me({__name:"PromptTemplate",props:{promptText:{},beforeTool:{},afterTool:{},requiredSchema:{},currentPromptName:{}},emits:["update:promptText","update:beforeTool","update:afterTool"],setup(t,{emit:o}){const a=t,i=o,l=p([]),u=p(!1),s=y=>y.type==="text"?{type:"string",value:y.content||""}:y.type==="include"?{type:"prompt",id:y.prompt||"",label:y.prompt||""}:y.type==="string"?{type:"string",value:y.value||""}:y.type==="prompt"?{type:"prompt",id:y.id||"",label:y.label||y.id||""}:y.type==="variable"?{type:"variable",value:y.value||"",label:y.label||y.value||""}:{type:"string",value:""},m=B(()=>{if(!a.promptText)return[{type:"string",value:""}];let y=[];try{const v=JSON.parse(a.promptText);Array.isArray(v)?y=v.map(s):y=[{type:"string",value:a.promptText}]}catch{y=[{type:"string",value:a.promptText}]}const b=a.requiredSchema?JSON.parse(a.requiredSchema):{};return y.map(v=>{if(v.type==="prompt"&&v.schema){const d=gr(b,v.schema),k=d===!0,g=k?[]:d;return{...v,meta:{isValid:k,missingFields:g,validationMessage:k?"":br(g)}}}return v})}),h=B(()=>{try{const y=JSON.parse(a.requiredSchema);if(y.properties&&typeof y.properties=="object")return Object.keys(y.properties)}catch{return[]}return[]}),x=async y=>{u.value=!0;try{const b=new URLSearchParams;y&&b.set("search",y);const v=await fetch(fe(`/api/prompts${b.toString()?"?"+b.toString():""}`));if(v.ok){const d=await v.json();l.value=d.prompts||[]}}catch(b){console.error("Error fetching prompts:",b)}finally{u.value=!1}},c=async y=>{const b=[];return h.value.forEach(v=>{(!y||v.toLowerCase().includes(y.toLowerCase()))&&b.push({type:"variable",value:v,label:v,description:"Schema property"})}),y!==void 0&&await x(y),l.value.forEach(v=>{if(!(a.currentPromptName&&v.name===a.currentPromptName)&&(!y||v.name.toLowerCase().includes(y.toLowerCase()))){const d=a.requiredSchema?JSON.parse(a.requiredSchema):{},k=gr(d,v.required_schema),g=k===!0,_=g?[]:k;b.push({type:"prompt",id:v.name,label:v.name,description:v.tool_description||"Available prompt",schema:v.required_schema,meta:{isValid:g,missingFields:_,validationMessage:g?"":br(_)}})}}),b},f=y=>{const b=y.map(v=>{const{type:d,value:k,label:g,id:_,schema:L}=v;return d==="string"?{type:d,value:k||""}:d==="variable"?{type:d,value:k||"",label:g}:d==="prompt"?{type:d,id:_||"",label:g,schema:L}:v});i("update:promptText",JSON.stringify(b))};return Pe(()=>{x()}),(y,b)=>(r(),n("div",null,[w(Gt,{"model-value":m.value,"onUpdate:modelValue":f,search:c,placeholder:"Enter your prompt template... Type @ to insert variables or prompts"},null,8,["model-value"])]))}}),hy={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function gy(t,o){return r(),n("svg",hy,[...o[0]||(o[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2a2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1m8 0h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1"},null,-1)])])}const xr=Ie({name:"lucide-braces",render:gy}),by={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function xy(t,o){return r(),n("svg",by,[...o[0]||(o[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 5H3m9 14H3M14 3v4m2 10v4m5-9h-9m9 7h-5m5-14h-7m-6 5v4m0-2H3"},null,-1)])])}const yr=Ie({name:"lucide-sliders-horizontal",render:xy}),yy={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ky(t,o){return r(),n("svg",yy,[...o[0]||(o[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"},null,-1)])])}const kr=Ie({name:"lucide-zap",render:ky}),wy={key:0,class:"min-h-[500px] flex items-center justify-center"},_y={class:"flex flex-1 min-h-0"},$y={class:"w-44 flex-shrink-0 border-r border-neutral-200 dark:border-neutral-700 py-4"},Cy={class:"space-y-4"},Sy={class:"space-y-5"},Ty={key:0,class:"mb-4 py-6 px-4 border border-dashed border-neutral-300 dark:border-neutral-600 rounded-lg text-center"},Iy={key:0,class:"py-6 px-4 border border-dashed border-neutral-300 dark:border-neutral-600 rounded-lg text-center"},zy={key:1,class:"space-y-2"},Vy=["checked","onChange"],My={class:"flex-1 min-w-0"},Ey={class:"font-medium text-sm"},Ly={class:"text-xs text-neutral-500 dark:text-neutral-400"},Py={class:"mb-6"},Ay={class:"grid grid-cols-2 gap-6 items-start"},jy={class:"flex flex-col"},Dy={class:"space-y-4 mb-6 mt-6 pt-6 border-t border-neutral-100 dark:border-neutral-800"},Oy={class:"pt-6 border-t border-neutral-100 dark:border-neutral-800"},Ry={class:"grid grid-cols-2 gap-6 mb-4"},Uy={class:"flex justify-between items-center"},By={class:"flex items-center gap-3"},la=me({__name:"PromptModal",props:{modelValue:{type:Boolean},editPrompt:{},mode:{}},emits:["update:modelValue","save"],setup(t,{emit:o}){const a=t,i=o,l=B(()=>a.mode==="edit"),u=p(!1),s=p(null),m=["basics","schema","prompt","tools","hooks","behavior"],{activeTab:h,scrollToSection:x}=ea(s,m),c=[{id:"basics",label:"Basics",icon:Lt},{id:"schema",label:"Schema",icon:xr},{id:"prompt",label:"Prompt",icon:Et},{id:"tools",label:"Tools",icon:qt},{id:"hooks",label:"Hooks",icon:kr},{id:"behavior",label:"Behavior",icon:yr}],f=B(()=>z.value.length===1),y=p(""),b=p(null),v=p(""),d=p(""),k=p(""),g=p({type:"object",properties:{},required:[],additionalProperties:!1}),_=p(""),L=p(!1),R=p(!1),K=p(""),Y=p(""),z=p([]),P=p(!1),G=p(null),ee=p("auto"),se=p(""),de=p(null),Q=p(!1),E=p(!1),S=p([]),V=p([]),re=p(null),F=p(!0),q=p(!1),N=be=>{re.value=be,be.on("commit",()=>{F.value=be.context?.state.valid??!0,q.value=be.context?.state.submitted??!1})},J={sparkles:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z'/%3E%3Cpath d='M20 3v4'/%3E%3Cpath d='M22 5h-4'/%3E%3C/svg%3E",ban:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m4.9 4.9 14.2 14.2'/%3E%3C/svg%3E",checkCircle:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E",target:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Ccircle cx='12' cy='12' r='6'/%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3C/svg%3E",signalNone:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Crect x='5' y='15' width='3' height='5' rx='1' fill='currentColor' opacity='0.2'/%3E%3Crect x='10.5' y='10' width='3' height='10' rx='1' fill='currentColor' opacity='0.2'/%3E%3Crect x='16' y='5' width='3' height='15' rx='1' fill='currentColor' opacity='0.2'/%3E%3C/svg%3E",signalLow:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Crect x='5' y='15' width='3' height='5' rx='1' fill='currentColor'/%3E%3Crect x='10.5' y='10' width='3' height='10' rx='1' fill='currentColor' opacity='0.2'/%3E%3Crect x='16' y='5' width='3' height='15' rx='1' fill='currentColor' opacity='0.2'/%3E%3C/svg%3E",signalMedium:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Crect x='5' y='15' width='3' height='5' rx='1' fill='currentColor'/%3E%3Crect x='10.5' y='10' width='3' height='10' rx='1' fill='currentColor'/%3E%3Crect x='16' y='5' width='3' height='15' rx='1' fill='currentColor' opacity='0.2'/%3E%3C/svg%3E",signalHigh:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Crect x='5' y='15' width='3' height='5' rx='1' fill='currentColor'/%3E%3Crect x='10.5' y='10' width='3' height='10' rx='1' fill='currentColor'/%3E%3Crect x='16' y='5' width='3' height='15' rx='1' fill='currentColor'/%3E%3C/svg%3E"},U=B(()=>{const be=[{value:"auto",label:"Auto",description:"Model decides",icon:J.sparkles},{value:"none",label:"None",description:"No tools allowed",icon:J.ban},{value:"required",label:"Required",description:"Must call a tool",icon:J.checkCircle}];return f.value&&be.push({value:"function",label:"Function",description:"Call specific tool",icon:J.target}),be}),W=[{value:"",label:"None",description:"Disabled",icon:J.signalNone},{value:"low",label:"Low",description:"~20% of max_tokens",icon:J.signalLow},{value:"medium",label:"Medium",description:"~50% of max_tokens",icon:J.signalMedium},{value:"high",label:"High",description:"~80% of max_tokens",icon:J.signalHigh}],M=()=>{v.value="",y.value="",d.value="",k.value="",b.value=null,g.value={type:"object",properties:{},required:[],additionalProperties:!1},_.value="",L.value=!1,R.value=!1,K.value="",Y.value="",z.value=[],P.value=!1,ee.value="auto",se.value="",de.value=null,Q.value=!1,E.value=!1,S.value=[]},ne=async be=>{if(!be){b.value=null;return}try{const O=await Je(`/models/${be}`);if(O.ok){const $=await O.json();b.value=$.model||$}}catch(O){console.error("Error fetching model info:",O),b.value=null}};ge(k,async be=>{be?await ne(be):b.value=null});const A=async()=>{try{const be=await Je("/hooks");if(be.ok){const O=await be.json();V.value=O.hooks||[]}}catch(be){console.error("Error fetching hooks:",be),V.value=[]}},ce=async()=>{if(a.editPrompt?.id){u.value=!0;try{const be=await Je(`/prompts/${a.editPrompt.id}`);if(be.ok){const O=await be.json(),$=O.prompt||O;v.value=$.name||"",y.value=$.name||"",d.value=$.tool_description||"",k.value=$.model_id||"",$.model_id&&await ne($.model_id);let j=$.required_schema;if(typeof j=="string")try{j=JSON.parse(j)}catch{j=null}g.value=j||{type:"object",properties:{},required:[],additionalProperties:!1},_.value=$.prompt||"",L.value=$.include_chat||!1,R.value=$.include_past_tools||!1,K.value=$.before_tool||"",Y.value=$.after_tool||"";const he=$.tools||[];z.value=he.map(pe=>typeof pe=="string"?{name:pe,include_text_response:!0,include_tool_calls:!0,include_errors:!0,init_user_message_property:null}:pe),P.value=$.parallel_tool_calls||!1,ee.value=$.tool_choice||"auto";const X=$.reasoning||{};se.value=X.effort||$.reasoning_effort||"",de.value=X.maxTokens||$.reasoning_max_tokens||null,Q.value=X.exclude||$.reasoning_exclude||!1,E.value=X.include||$.include_reasoning||!1,S.value=$.hooks||[]}}catch(be){console.error("Error loading prompt data:",be)}finally{u.value=!1}}},ue=async()=>{const be=/^[a-z][a-z0-9_]*$/;if(!v.value||!be.test(v.value)){alert("Please enter a valid name (lowercase letters, numbers, and underscores only, must start with a letter)");return}if(!d.value){alert("Please enter a description");return}if(!k.value){alert("Please select a model");return}if(!_.value){alert("Please enter the prompt template");return}G.value?.removeUnavailableTools();const O={name:v.value,tool_description:d.value,prompt:_.value,required_schema:g.value,model_id:k.value,include_chat:L.value,include_past_tools:R.value,before_tool:K.value||null,after_tool:Y.value||null,parallel_tool_calls:P.value,tool_choice:ee.value,tools:z.value,reasoning_effort:se.value||null,reasoning_max_tokens:de.value,reasoning_exclude:Q.value,include_reasoning:E.value,hooks:S.value.length>0?S.value:null};l.value&&a.editPrompt?.id&&(O.id=a.editPrompt.id,y.value&&y.value!==v.value&&(O.originalName=y.value)),i("save",O),M(),i("update:modelValue",!1)},ke=()=>{M(),i("update:modelValue",!1)};return ge(()=>z.value.length,be=>{ee.value==="function"&&be!==1&&(ee.value="auto")}),ge(()=>a.modelValue,async be=>{be&&(await A(),l.value?(M(),await Le(),await ce()):M())}),ge(()=>a.editPrompt,async be=>{be&&l.value&&a.modelValue&&(await Le(),await ce())},{immediate:!0}),(be,O)=>{const $=Be("FormKit");return r(),H(He,{"model-value":t.modelValue,"onUpdate:modelValue":O[16]||(O[16]=j=>be.$emit("update:modelValue",j)),title:l.value?"Edit Prompt":"Add Prompt",width:"max-w-5xl","content-padding":!1},{footer:D(()=>[e("div",Uy,[w(T(De),{variant:"ghost",size:"sm",onClick:ke},{default:D(()=>[...O[27]||(O[27]=[Z(" Cancel ",-1)])]),_:1}),e("div",By,[q.value&&!F.value?(r(),H(T(tt),{key:0},{default:D(()=>[...O[28]||(O[28]=[Z(" Please fix the errors above ",-1)])]),_:1})):I("",!0),w(T(De),{variant:"primary",size:"sm",disabled:u.value,loading:u.value,onClick:ue},{default:D(()=>[Z(C(l.value?"Update Prompt":"Create Prompt"),1)]),_:1},8,["disabled","loading"])])])]),default:D(()=>[u.value?(r(),n("div",wy,[...O[17]||(O[17]=[e("span",{class:"text-neutral-500"},"Loading prompt data...",-1)])])):(r(),H($,{key:1,type:"form",actions:!1,onNode:N,"form-class":"$reset flex-1 min-h-0 flex flex-col"},{default:D(()=>[e("div",_y,[e("nav",$y,[w(T(Qr),{tabs:c,"active-tab":T(h),onSelect:T(x)},null,8,["active-tab","onSelect"])]),e("div",{ref_key:"contentRef",ref:s,class:"flex-1 overflow-y-auto p-5 bg-neutral-100 dark:bg-neutral-950"},[e("div",Cy,[w(T(rt),{id:"section-basics",title:"Basics",icon:T(Lt)},{default:D(()=>[e("div",Sy,[w(py,{name:v.value,"onUpdate:name":O[0]||(O[0]=j=>v.value=j),"tool-description":d.value,"onUpdate:toolDescription":O[1]||(O[1]=j=>d.value=j)},null,8,["name","tool-description"]),w(vy,{modelValue:k.value,"onUpdate:modelValue":O[2]||(O[2]=j=>k.value=j)},null,8,["modelValue"])])]),_:1},8,["icon"]),w(T(rt),{id:"section-schema",title:"Schema",icon:T(xr)},{default:D(()=>[w($,{type:"schemaEditor",modelValue:g.value,"onUpdate:modelValue":O[3]||(O[3]=j=>g.value=j),label:"","outer-class":"$reset"},null,8,["modelValue"])]),_:1},8,["icon"]),w(T(rt),{id:"section-prompt",title:"Prompt",icon:T(Et)},{footer:D(()=>[...O[18]||(O[18]=[e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"},[Z(" Type "),e("kbd",{class:"px-1.5 py-0.5 rounded bg-neutral-200 dark:bg-neutral-700 font-mono text-xs"},"@"),Z(" to insert schema properties or other prompts ")],-1)])]),default:D(()=>[w(fy,{"prompt-text":_.value,"onUpdate:promptText":O[4]||(O[4]=j=>_.value=j),"before-tool":K.value,"onUpdate:beforeTool":O[5]||(O[5]=j=>K.value=j),"after-tool":Y.value,"onUpdate:afterTool":O[6]||(O[6]=j=>Y.value=j),"required-schema":JSON.stringify(g.value,null,2),"current-prompt-name":l.value?v.value:void 0},null,8,["prompt-text","before-tool","after-tool","required-schema","current-prompt-name"])]),_:1},8,["icon"]),w(T(rt),{id:"section-tools",title:"Tools",icon:T(qt)},{default:D(()=>[z.value.length===0?(r(),n("div",Ty,[...O[19]||(O[19]=[e("p",{class:"text-sm text-neutral-500 dark:text-neutral-400"}," No tools selected. This prompt will run without tool access. ",-1)])])):I("",!0),w(Hr,{ref_key:"toolSelectorRef",ref:G,modelValue:z.value,"onUpdate:modelValue":O[7]||(O[7]=j=>z.value=j),"provider-id":b.value?.provider_id||b.value?.provider,"model-id":b.value?.model},null,8,["modelValue","provider-id","model-id"])]),_:1},8,["icon"]),w(T(rt),{id:"section-hooks",title:"Hooks",icon:T(kr)},{default:D(()=>[O[21]||(O[21]=e("p",{class:"text-sm text-neutral-500 dark:text-neutral-400 mb-4"}," Select hooks to run when this prompt is active. Hooks execute in the order listed. ",-1)),V.value.length===0?(r(),n("div",Iy,[...O[20]||(O[20]=[e("p",{class:"text-sm text-neutral-500 dark:text-neutral-400"},[Z(" No hooks available. Create hooks in "),e("code",{class:"px-1.5 py-0.5 rounded bg-neutral-200 dark:bg-neutral-700 font-mono text-xs"},"agents/hooks/"),Z(" to enable them here. ")],-1)])])):(r(),n("div",zy,[(r(!0),n(ve,null,ye(V.value,j=>(r(),n("label",{key:j.id,class:ae(["flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors",S.value.includes(j.id)?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-neutral-200 dark:border-neutral-700 hover:border-neutral-300 dark:hover:border-neutral-600"])},[e("input",{type:"checkbox",checked:S.value.includes(j.id),onChange:he=>S.value.includes(j.id)?S.value=S.value.filter(X=>X!==j.id):S.value=[...S.value,j.id],class:"w-4 h-4 rounded border-neutral-300 text-blue-600 focus:ring-blue-500"},null,40,Vy),e("div",My,[e("div",Ey,C(j.id),1),e("div",Ly,C(j.hook),1)])],2))),128))]))]),_:1},8,["icon"]),w(T(rt),{id:"section-behavior",title:"Behavior",icon:T(yr)},{default:D(()=>[e("div",Py,[w(T(xt),{title:"Tool Behavior",class:"mb-4"}),e("div",Ay,[e("div",null,[w($,{type:"selectSearch",modelValue:ee.value,"onUpdate:modelValue":O[8]||(O[8]=j=>ee.value=j),label:"Tool Choice",options:U.value,placeholder:"Select tool choice","outer-class":"$reset"},null,8,["modelValue","options"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...O[22]||(O[22]=[Z(" Controls whether and how the model can call tools ",-1)])]),_:1})]),e("div",jy,[O[24]||(O[24]=e("div",{class:"h-7"},null,-1)),w($,{type:"checkbox",modelValue:P.value,"onUpdate:modelValue":O[9]||(O[9]=j=>P.value=j),label:"Allow parallel tool calls","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...O[23]||(O[23]=[Z(" Allow the model to call multiple tools simultaneously ",-1)])]),_:1})])])]),e("div",Dy,[w(T(xt),{title:"Context"}),w($,{type:"checkbox",modelValue:L.value,"onUpdate:modelValue":O[10]||(O[10]=j=>L.value=j),label:"Include chat history",help:"Expose chat history to the LLM when this prompt is used as a full prompt","outer-class":"$reset"},null,8,["modelValue"]),w($,{type:"checkbox",modelValue:R.value,"onUpdate:modelValue":O[11]||(O[11]=j=>R.value=j),label:"Include past tool calls",help:"Include prior tool call history in this prompt","outer-class":"$reset"},null,8,["modelValue"]),w($,{type:"checkbox",modelValue:E.value,"onUpdate:modelValue":O[12]||(O[12]=j=>E.value=j),label:"Include reasoning in history",help:"Include reasoning_details from previous responses","outer-class":"$reset"},null,8,["modelValue"])]),e("div",Oy,[w(T(xt),{title:"Reasoning",class:"mb-2"}),O[26]||(O[26]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 mb-4"}," Configure extended reasoning for models like o1, o3, Gemini Thinking, and others. Reasoning is enabled automatically when either field is set. ",-1)),e("div",Ry,[e("div",null,[w($,{type:"selectSearch",modelValue:se.value,"onUpdate:modelValue":O[13]||(O[13]=j=>se.value=j),label:"Reasoning Effort",options:W,placeholder:"Select reasoning effort","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...O[25]||(O[25]=[Z(" Controls reasoning capacity. Supported by OpenAI o-series and Grok. ",-1)])]),_:1})]),w($,{type:"unit",modelValue:de.value,"onUpdate:modelValue":O[14]||(O[14]=j=>de.value=j),label:"Max Reasoning Tokens",min:0,step:1,decimals:0,validation:"min:1024|max:32000","validation-messages":{min:"Recommended minimum is 1,024 tokens",max:"Recommended maximum is 32,000 tokens"},"validation-visibility":"live",placeholder:"Leave empty to disable",help:"Specify reasoning token limit (1024-32000)","outer-class":"$reset"},null,8,["modelValue"])]),w($,{type:"checkbox",modelValue:Q.value,"onUpdate:modelValue":O[15]||(O[15]=j=>Q.value=j),label:"Exclude reasoning from response",help:"Use reasoning internally but don't return it in the response (saves tokens and cost)","outer-class":"$reset"},null,8,["modelValue"])])]),_:1},8,["icon"])])],512)])]),_:1}))]),_:1},8,["model-value","title"])}}}),Fy=me({__name:"PromptsView",setup(t){const o=bt(),a=ut(),i=p(!1),l=p(null);ge(()=>a.query.refresh,()=>{a.query.refresh&&(l.value?.refresh(),o.replace({path:"/prompts",query:{}}))});const u=()=>{i.value=!0},s=h=>{o.push(`/prompts/${h.id}`)},m=async h=>{try{const x=await fetch(fe("/api/prompts"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)});if(x.ok)i.value=!1,await new Promise(c=>setTimeout(c,100)),await l.value?.refresh();else{const c=await x.json();alert(c.error||"Failed to create prompt")}}catch(x){console.error("Error creating prompt:",x),alert("Failed to create prompt")}};return(h,x)=>(r(),H(pt,null,{default:D(()=>[w(sy,{ref_key:"dataTableRef",ref:l,title:"Prompts",description:"Define and manage prompt templates for your agents.","primary-action":{label:"Create Prompt",icon:T(jt),handler:u},onAdd:u,onEdit:s},null,8,["primary-action"]),w(la,{modelValue:i.value,"onUpdate:modelValue":x[0]||(x[0]=c=>i.value=c),mode:"add",onSave:m},null,8,["modelValue"])]),_:1}))}}),Ny={class:"p-8"},qy={key:0,class:"flex items-center justify-center min-h-[400px]"},Hy={key:2,class:"flex items-center justify-center min-h-[400px]"},Wy=me({__name:"PromptEditView",setup(t){const o=bt(),a=ut(),i=p(!0),l=p(null),u=p(!0),s=async()=>{const x=a.params.id;if(!x){o.push("/prompts");return}u.value=!0;try{const c=await fetch(fe(`/api/prompts/${x}`));if(c.ok){const f=await c.json();l.value=f.prompt||f}else alert("Prompt not found"),o.push("/prompts")}catch(c){console.error("Error loading prompt:",c),alert("Failed to load prompt"),o.push("/prompts")}finally{u.value=!1}},m=async x=>{try{const{originalName:c,...f}=x,y=c||f.id,b=await fetch(fe(`/api/prompts/${y}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(b.ok)o.push({path:"/prompts",query:{refresh:Date.now().toString()}});else{const v=await b.json();alert(v.error||"Failed to update prompt")}}catch(c){console.error("Error updating prompt:",c),alert("Failed to update prompt")}},h=x=>{x||o.push("/prompts")};return Pe(()=>{s()}),ge(i,x=>{x||o.push("/prompts")}),(x,c)=>(r(),n("div",Ny,[u.value?(r(),n("div",qy,[...c[1]||(c[1]=[e("span",{class:"text-neutral-500"},"Loading prompt...",-1)])])):l.value?(r(),H(la,{key:1,modelValue:i.value,"onUpdate:modelValue":[c[0]||(c[0]=f=>i.value=f),h],mode:"edit","edit-prompt":l.value,onSave:m},null,8,["modelValue","edit-prompt"])):(r(),n("div",Hy,[...c[2]||(c[2]=[e("span",{class:"text-neutral-500"},"Prompt not found",-1)])]))]))}}),Ky={class:"space-y-4"},Jy={key:0},Yy={key:1},Gy={class:"px-1 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded"},Zy={key:2,class:"space-y-3"},Xy={class:"flex items-center justify-between"},Qy={key:0,class:"text-sm text-neutral-500 dark:text-neutral-400"},ek={key:1,class:"space-y-3"},tk={class:"grid grid-cols-2 gap-x-4 gap-y-2"},rk={class:"grid grid-cols-2 gap-4"},ak={key:3,class:"space-y-3"},ok={key:0,class:"text-sm text-neutral-500 dark:text-neutral-400"},nk={key:1,class:"grid grid-cols-1 gap-2"},lk=["value"],sk={class:"flex-1 min-w-0"},ik={class:"font-medium text-sm"},uk={class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},dk={key:0,class:"mt-1"},ck={class:"text-xs text-amber-600 dark:text-amber-400"},pk={key:4,class:"space-y-3"},mk={class:"flex items-center justify-between"},vk={key:0,class:"flex gap-2"},fk={key:0,class:"flex items-center gap-2 py-4"},hk={key:1,class:"py-4 text-sm text-neutral-500 dark:text-neutral-400"},gk={key:2,class:"space-y-2"},bk=["checked","onChange"],xk={class:"flex-1 min-w-0"},yk={class:"flex items-center gap-2"},kk={class:"font-medium text-sm"},wk={key:0,class:"px-1.5 py-0.5 text-xs font-medium rounded bg-neutral-100 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400"},_k={class:"flex flex-wrap gap-x-4 gap-y-1 mt-1 text-xs text-neutral-500 dark:text-neutral-400"},$k={key:0},Ck={key:1},Sk={key:5,class:"space-y-3"},Tk={class:"flex items-center justify-between gap-4"},Ik={key:1},zk={class:"flex gap-2"},Vk=me({__name:"ModelModal",props:{modelValue:{type:Boolean},editModel:{},mode:{default:"add"}},emits:["update:modelValue","save"],setup(t,{emit:o}){const a=t,i=o,l=p([]),u=p(""),s=p(""),m=p([]),h=p(!1),x=p(!1),c=p([]),f=p([]),y=p(!1),b=p({supportsImages:!1,supportsToolCalls:!0,supportsStreaming:!0,supportsJsonMode:!0}),v=p(null),d=p(!1),k=p([]),g=p([]),_=p(!1),L=p([]),R=p(!1),K=B(()=>L.value.map(oe=>({value:oe.id,label:oe.name,description:oe.provider_id||oe.provider,icon:oe.iconId}))),Y=async()=>{R.value=!0;try{const oe=await fetch(fe("/api/models"));if(oe.ok){const ie=await oe.json();L.value=ie.models||[]}}catch(oe){console.error("Error fetching configured models:",oe)}finally{R.value=!1}},z=p([]),P=B(()=>a.mode==="edit"),G=p(null),ee=p(!0),se=p(!1),de=oe=>{G.value=oe,oe.on("commit",()=>{ee.value=oe.context?.state.valid??!0,se.value=oe.context?.state.submitted??!1})},Q=p(""),E=p(""),S=oe=>{let ie=oe.replace(/[^a-zA-Z0-9\s_-]/g,"");return ie=ie.trim().toLowerCase().replace(/[\s-]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),ie},V=oe=>{E.value=S(oe)},re=p(!1),F=p(null),q=B(()=>l.value.filter(oe=>oe.hasApiKey).map(oe=>({value:oe.name,label:oe.name,description:oe.sdk==="openai-sdk"?"OpenAI SDK":oe.sdk==="openrouter"?"OpenRouter":oe.sdk,icon:oe.iconId}))),N=B(()=>m.value.map(oe=>({...oe,icon:oe.iconId}))),J=B(()=>!P.value||!F.value||re.value?!1:E.value!==F.value.name||u.value!==F.value.provider||s.value!==F.value.model||JSON.stringify(f.value.sort())!==JSON.stringify(F.value.endpoints.sort())||JSON.stringify(z.value)!==JSON.stringify(F.value.fallbacks)||JSON.stringify(b.value)!==JSON.stringify(F.value.capabilities)||JSON.stringify(g.value.sort())!==JSON.stringify(F.value.providerTools.sort())),U=B(()=>l.value.find(ie=>ie.name===u.value)?.sdk==="openrouter"),W=async()=>{h.value=!0;try{const oe=await fetch(fe("/api/providers"));if(oe.ok){const ie=await oe.json();l.value=ie.providers||[]}}catch(oe){console.error("Error fetching providers:",oe)}finally{h.value=!1}},M=async()=>{if(!u.value){m.value=[];return}x.value=!0;try{const oe=await fetch(fe("/api/models/available"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:u.value})});if(oe.ok){const ie=await oe.json();m.value=ie.models||[]}else{const ie=await oe.json();console.error("Error fetching models:",ie),m.value=[],alert(ie.error||"Failed to fetch available models")}}catch(oe){console.error("Error fetching models:",oe),m.value=[]}finally{x.value=!1}},ne=async()=>{if(!(!u.value||!s.value)){d.value=!0;try{const oe=await fetch(fe("/api/models/capabilities"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:u.value,modelId:s.value})});if(oe.ok){const ie=await oe.json();ie.capabilities&&(v.value=ie.capabilities,b.value={supportsImages:ie.capabilities.supportsImages??!1,supportsToolCalls:ie.capabilities.supportsToolCalls??!0,supportsStreaming:ie.capabilities.supportsStreaming??!0,supportsJsonMode:ie.capabilities.supportsJsonMode??!0,maxContextTokens:ie.capabilities.maxContextTokens,maxOutputTokens:ie.capabilities.maxOutputTokens})}}catch(oe){console.error("Error fetching capabilities:",oe)}finally{d.value=!1}}},A=async()=>{if(!u.value||!s.value){k.value=[];return}_.value=!0;try{const oe=await fetch(fe(`/api/providers/${u.value}/tools?model=${encodeURIComponent(s.value)}`));if(oe.ok){const ie=await oe.json();k.value=ie.tools||[],P.value||(g.value=k.value.map(Ve=>Ve.name))}else k.value=[]}catch(oe){console.error("Error fetching provider tools:",oe),k.value=[]}finally{_.value=!1}},ce=()=>{b.value={supportsImages:!1,supportsToolCalls:!0,supportsStreaming:!0,supportsJsonMode:!0},v.value=null},ue=oe=>{const ie=f.value.indexOf(oe);ie===-1?f.value.push(oe):f.value.splice(ie,1)},ke=()=>{f.value=c.value.map(oe=>oe.id)},be=()=>{f.value=[]},O=oe=>{const ie=oe*1e6;return ie>=1?`$${ie.toFixed(2)}/M`:`$${ie.toFixed(4)}/M`},$=()=>{v.value&&(b.value={supportsImages:v.value.supportsImages??!1,supportsToolCalls:v.value.supportsToolCalls??!0,supportsStreaming:v.value.supportsStreaming??!0,supportsJsonMode:v.value.supportsJsonMode??!0,maxContextTokens:v.value.maxContextTokens,maxOutputTokens:v.value.maxOutputTokens})},j=()=>{E.value="",Q.value="",u.value="",s.value="",m.value=[],z.value=[],c.value=[],f.value=[],k.value=[],g.value=[],ce(),F.value=null,re.value=!1,ee.value=!0,se.value=!1,G.value?.reset()},he=async()=>{if(a.editModel){re.value=!0;try{await W(),E.value=a.editModel.name||"",Q.value=a.editModel.name||"",u.value=a.editModel.provider_id||a.editModel.provider,await M(),s.value=a.editModel.model,await pe(),a.editModel.included_providers&&a.editModel.included_providers.length>0&&(f.value=a.editModel.included_providers),await X(),a.editModel.capabilities?b.value={supportsImages:a.editModel.capabilities.supportsImages??!1,supportsToolCalls:a.editModel.capabilities.supportsToolCalls??!0,supportsStreaming:a.editModel.capabilities.supportsStreaming??!0,supportsJsonMode:a.editModel.capabilities.supportsJsonMode??!0,maxContextTokens:a.editModel.capabilities.maxContextTokens,maxOutputTokens:a.editModel.capabilities.maxOutputTokens}:await ne(),await A(),a.editModel.providerTools&&Array.isArray(a.editModel.providerTools)&&(g.value=a.editModel.providerTools),F.value={name:E.value,provider:u.value,model:s.value,endpoints:[...f.value],fallbacks:[...z.value],capabilities:{...b.value},providerTools:[...g.value]}}finally{re.value=!1}}};ge(()=>a.modelValue,async oe=>{oe?(Y(),P.value&&a.editModel?await he():(await W(),j())):j()});const X=async()=>{if(a.editModel?.id){if(a.editModel.fallbacks&&Array.isArray(a.editModel.fallbacks)){z.value=a.editModel.fallbacks.map(oe=>typeof oe=="string"?oe:oe.id);return}try{const oe=await fetch(fe(`/api/models/${a.editModel.id}/fallbacks`));if(oe.ok){const ie=await oe.json();z.value=ie.fallbacks.map(Ve=>Ve.fallback_model_id)}}catch(oe){console.error("Error loading fallbacks:",oe)}}};ge(u,async(oe,ie)=>{re.value||P.value&&!ie&&oe===(a.editModel?.provider_id||a.editModel?.provider)||(s.value="",c.value=[],f.value=[],u.value&&await M())});const pe=async()=>{if(!s.value||!u.value){c.value=[];return}const oe=l.value.find(Ve=>Ve.name===u.value);if(!oe||oe.sdk!=="openrouter"){c.value=[];return}const ie=N.value.find(Ve=>Ve.value===s.value);if(!ie?.slug){console.error("Model slug not found"),c.value=[];return}y.value=!0;try{const Ve=await fetch(fe("/api/models/endpoints"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:u.value,modelSlug:ie.slug})});if(Ve.ok){const _e=await Ve.json();c.value=_e.endpoints||[],P.value||(f.value=c.value.map($e=>$e.id))}else{const _e=await Ve.json();console.error("Error fetching endpoints:",_e),c.value=[]}}catch(Ve){console.error("Error fetching endpoints:",Ve),c.value=[]}finally{y.value=!1}};ge(s,async(oe,ie)=>{re.value||P.value&&!ie&&oe===a.editModel?.model||(s.value?(await pe(),await ne(),await A(),ie&&oe!==ie&&(f.value=c.value.map(Ve=>Ve.id))):(c.value=[],f.value=[],k.value=[],g.value=[],ce()))});const le=()=>{const oe=U.value?f.value:[],ie={name:E.value,model:s.value,provider:u.value,included_providers:oe,fallbacks:z.value,capabilities:b.value,providerTools:g.value};P.value&&a.editModel?.id&&(ie.id=a.editModel.id,Q.value&&Q.value!==E.value&&(ie.originalName=Q.value)),i("save",ie)},we=()=>{j(),i("update:modelValue",!1)};return(oe,ie)=>{const Ve=Be("FormKit");return r(),H(He,{"model-value":t.modelValue,"onUpdate:modelValue":ie[10]||(ie[10]=_e=>oe.$emit("update:modelValue",_e)),title:P.value?"Edit Model":"Add Model",width:"max-w-2xl","min-height":"min-h-[36rem]","has-changes":J.value},{footer:D(()=>[e("div",Tk,[se.value&&!ee.value?(r(),H(T(tt),{key:0},{default:D(()=>[...ie[22]||(ie[22]=[Z(" Please fix the errors above before submitting. ",-1)])]),_:1})):(r(),n("div",Ik)),e("div",zk,[w(T(De),{variant:"ghost",size:"sm",onClick:we},{default:D(()=>[...ie[23]||(ie[23]=[Z(" Cancel ",-1)])]),_:1}),w(T(De),{variant:"primary",size:"sm",type:"submit",form:"model-form"},{default:D(()=>[Z(C(P.value?"Update Model":"Add Model"),1)]),_:1})])])]),default:D(()=>[w(Ve,{type:"form",id:"model-form",actions:!1,onSubmit:le,onNode:de},{default:D(()=>[e("div",Ky,[w(Ve,{type:"selectSearch",modelValue:u.value,"onUpdate:modelValue":ie[0]||(ie[0]=_e=>u.value=_e),options:q.value,label:"Provider",placeholder:"Select a provider",disabled:h.value||P.value&&!!a.editModel,validation:"required","validation-visibility":"submit"},null,8,["modelValue","options","disabled"]),u.value?(r(),n("div",Jy,[w(Ve,{type:"selectSearch",modelValue:s.value,"onUpdate:modelValue":ie[1]||(ie[1]=_e=>s.value=_e),options:N.value,label:"Model",placeholder:"Select a model","search-placeholder":"Search models...",loading:x.value,validation:"required","validation-visibility":"submit"},null,8,["modelValue","options","loading"])])):I("",!0),s.value?(r(),n("div",Yy,[w(Ve,{type:"text","model-value":E.value,onInput:V,label:"Name",placeholder:"e.g., coding_model, planning_model, fast_response",validation:"required|snakeCase","validation-visibility":"blur",help:E.value?void 0:"A descriptive name for this model. This becomes the filename and reference ID."},null,8,["model-value","help"]),E.value?(r(),H(T(ze),{key:0,class:"mt-1"},{default:D(()=>[ie[11]||(ie[11]=Z(" Will be saved as: ",-1)),e("code",Gy,C(E.value),1)]),_:1})):I("",!0)])):I("",!0),s.value?(r(),n("div",Zy,[e("div",Xy,[ie[12]||(ie[12]=e("label",{class:"block text-sm font-medium"},"Model Capabilities",-1)),v.value?(r(),n("button",{key:0,onClick:$,type:"button",class:"text-xs text-accent-600 dark:text-accent-400 hover:underline"}," Reset to detected ")):I("",!0)]),ie[13]||(ie[13]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"}," Auto-detected from the provider. Override if needed. ",-1)),d.value?(r(),n("div",Qy," Detecting capabilities... ")):(r(),n("div",ek,[e("div",tk,[w(Ve,{type:"checkbox",modelValue:b.value.supportsImages,"onUpdate:modelValue":ie[2]||(ie[2]=_e=>b.value.supportsImages=_e),label:"Vision/Images"},null,8,["modelValue"]),w(Ve,{type:"checkbox",modelValue:b.value.supportsToolCalls,"onUpdate:modelValue":ie[3]||(ie[3]=_e=>b.value.supportsToolCalls=_e),label:"Tool Calls"},null,8,["modelValue"]),w(Ve,{type:"checkbox",modelValue:b.value.supportsStreaming,"onUpdate:modelValue":ie[4]||(ie[4]=_e=>b.value.supportsStreaming=_e),label:"Streaming"},null,8,["modelValue"]),w(Ve,{type:"checkbox",modelValue:b.value.supportsJsonMode,"onUpdate:modelValue":ie[5]||(ie[5]=_e=>b.value.supportsJsonMode=_e),label:"JSON Mode"},null,8,["modelValue"])]),e("div",rk,[w(Ve,{type:"unit",modelValue:b.value.maxContextTokens,"onUpdate:modelValue":ie[6]||(ie[6]=_e=>b.value.maxContextTokens=_e),label:"Max Context Tokens",placeholder:"e.g., 128,000",unit:"",decimals:"0",step:"1000",min:"0"},null,8,["modelValue"]),w(Ve,{type:"unit",modelValue:b.value.maxOutputTokens,"onUpdate:modelValue":ie[7]||(ie[7]=_e=>b.value.maxOutputTokens=_e),label:"Max Output Tokens",placeholder:"e.g., 16,384",unit:"",decimals:"0",step:"1000",min:"0"},null,8,["modelValue"])])]))])):I("",!0),s.value&&k.value.length>0?(r(),n("div",ak,[ie[14]||(ie[14]=e("label",{class:"block text-sm font-medium"},"Provider Tools",-1)),ie[15]||(ie[15]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"}," Built-in tools available for this model. ",-1)),_.value?(r(),n("div",ok," Loading provider tools... ")):(r(),n("div",nk,[(r(!0),n(ve,null,ye(k.value,_e=>(r(),n("label",{key:_e.name,class:ae(["flex items-start gap-3 p-3 border rounded cursor-pointer hover:bg-neutral-50 dark:hover:bg-neutral-800/50 transition-colors",g.value.includes(_e.name)?"border-black dark:border-white":"border-neutral-200 dark:border-neutral-700"])},[Ae(e("input",{type:"checkbox",value:_e.name,"onUpdate:modelValue":ie[8]||(ie[8]=$e=>g.value=$e),class:"mt-0.5 h-4 w-4 rounded border-neutral-300 dark:border-neutral-600 text-black dark:text-white focus:ring-black dark:focus:ring-white accent-black dark:accent-white"},null,8,lk),[[Jt,g.value]]),e("div",sk,[e("div",ik,C(_e.name),1),e("div",uk,C(_e.description),1),_e.tenvs&&_e.tenvs.length>0?(r(),n("div",dk,[e("span",ck," Requires: "+C(_e.tenvs.filter($e=>$e.required).map($e=>$e.name).join(", ")||"none (optional config available)"),1)])):I("",!0)])],2))),128))]))])):I("",!0),s.value&&U.value?(r(),n("div",pk,[e("div",mk,[ie[17]||(ie[17]=e("label",{class:"block text-sm font-medium"},"Available Providers",-1)),c.value.length>0?(r(),n("div",vk,[e("button",{type:"button",onClick:ke,class:"text-xs text-accent-600 dark:text-accent-400 hover:underline"}," Select all "),ie[16]||(ie[16]=e("span",{class:"text-xs text-neutral-300 dark:text-neutral-600"},"|",-1)),e("button",{type:"button",onClick:be,class:"text-xs text-accent-600 dark:text-accent-400 hover:underline"}," Clear ")])):I("",!0)]),ie[19]||(ie[19]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"}," OpenRouter routes to the cheapest available provider. ",-1)),y.value?(r(),n("div",fk,[w(Ee,{class:"w-4 h-4"}),ie[18]||(ie[18]=e("span",{class:"text-sm text-neutral-500 dark:text-neutral-400"},"Loading providers...",-1))])):c.value.length===0?(r(),n("div",hk," No providers available for this model ")):(r(),n("div",gk,[(r(!0),n(ve,null,ye(c.value,_e=>(r(),n("label",{key:_e.id,class:ae(["flex items-start gap-3 p-3 border rounded-md cursor-pointer transition-colors",[f.value.includes(_e.id)?"border-accent-500 dark:border-accent-400 bg-accent-50/50 dark:bg-accent-900/20":"border-neutral-200 dark:border-neutral-700 hover:border-neutral-300 dark:hover:border-neutral-600"]])},[e("input",{type:"checkbox",checked:f.value.includes(_e.id),onChange:$e=>ue(_e.id),class:"mt-0.5 h-4 w-4 rounded border-neutral-300 dark:border-neutral-600 text-accent-600 dark:text-accent-500 focus:ring-accent-500 dark:focus:ring-accent-400 accent-accent-600 dark:accent-accent-500"},null,40,bk),e("div",xk,[e("div",yk,[e("span",kk,C(_e.name),1),_e.quantization&&_e.quantization!=="unknown"?(r(),n("span",wk,C(_e.quantization),1)):I("",!0)]),e("div",_k,[e("span",null," Input: "+C(O(_e.pricing.prompt)),1),e("span",null," Output: "+C(O(_e.pricing.completion)),1),_e.maxPromptTokens?(r(),n("span",$k," Max prompt: "+C(_e.maxPromptTokens.toLocaleString()),1)):I("",!0),_e.maxCompletionTokens?(r(),n("span",Ck," Max output: "+C(_e.maxCompletionTokens.toLocaleString()),1)):I("",!0)])])],2))),128))]))])):I("",!0),s.value?(r(),n("div",Sk,[ie[20]||(ie[20]=e("label",{class:"block text-sm font-medium"},"Fallback Models",-1)),ie[21]||(ie[21]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"}," Used in order if the primary model fails. ",-1)),w(Ve,{type:"sortableMultiSelect",modelValue:z.value,"onUpdate:modelValue":ie[9]||(ie[9]=_e=>z.value=_e),options:K.value,loading:R.value,placeholder:"Add fallback model...","search-placeholder":"Search models...","add-label":"Add another model"},null,8,["modelValue","options","loading"])])):I("",!0)])]),_:1})]),_:1},8,["model-value","title","has-changes"])}}}),Mk={class:"flex items-center gap-2"},Ek=["src","alt"],Lk={class:"text-sm text-neutral-600 dark:text-neutral-400 font-mono"},Pk={key:0,class:"space-y-0.5"},Ak=["title"],jk={class:"shrink-0 font-mono pr-2"},Dk=["src","alt"],Ok={class:"truncate"},Rk={key:1,class:"text-neutral-400 dark:text-neutral-600 text-sm"},Uk=me({__name:"ModelsView",setup(t){const o=p(!1),a=p([]),i=p(!1),l=p(null),u=p("add"),s=[{key:"name",label:"Name",width:"w-1/4",sortable:!0},{key:"model",label:"Model",width:"w-1/4",sortable:!0,filterable:!0,filterIcon:(y,b)=>`/api/providers/${b.provider}/icon?model=${encodeURIComponent(b.model||"")}`},{key:"provider",label:"Provider",width:"w-1/4",sortable:!0,filterable:!0,filterIcon:(y,b)=>`/api/providers/${b.provider}/icon`},{key:"fallbacks",label:"Fallbacks",width:"w-1/4"}],m=[{icon:"edit",label:"Edit",handler:y=>{l.value=y,u.value="edit",o.value=!0}},{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this model? This action cannot be undone.",variant:"danger",handler:async y=>{await c(y.id)}}],h=async()=>{i.value=!0;try{const y=await fetch(fe("/api/models"));if(!y.ok)throw new Error("Failed to fetch models");const b=await y.json();a.value=b.models||[]}catch(y){console.error("Error fetching models:",y),a.value=[]}finally{i.value=!1}},x=async y=>{try{if(l.value){const{originalName:b,...v}=y,d=b||l.value.id,k=await fetch(fe(`/api/models/${d}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(v)});if(!k.ok){const g=await k.json();alert(g.error||"Failed to update model");return}}else{const b=await fetch(fe("/api/models"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(y)});if(!b.ok){const v=await b.json();alert(v.error||"Failed to add model");return}}await h(),o.value=!1,l.value=null,u.value="add"}catch(b){console.error("Error saving model:",b),alert("Failed to save model")}},c=async y=>{try{const b=await fetch(fe(`/api/models/${y}`),{method:"DELETE"});if(!b.ok){const v=await b.json();alert(v.error||"Failed to delete model");return}await h()}catch(b){console.error("Error deleting model:",b),alert("Failed to delete model")}},f=()=>{u.value="add",l.value=null,o.value=!0};return Pe(()=>{h()}),(y,b)=>(r(),H(pt,null,{default:D(()=>[w(ot,{title:"Models",description:"Configure AI models from your connected providers. Models define which AI capabilities are available to your agents.","primary-action":{label:"Add Model",icon:T(jt),handler:f},columns:s,data:a.value,actions:m,loading:i.value,sortable:"",searchable:"","search-placeholder":"Search models...","empty-message":"No models configured yet. Add your first model to get started."},{"cell-name":D(({value:v,row:d})=>[e("div",Mk,[d.provider?(r(),n("img",{key:0,src:`/api/providers/${d.provider}/icon?model=${encodeURIComponent(d.model||"")}`,class:"w-5 h-5 shrink-0",alt:d.provider},null,8,Ek)):I("",!0),e("span",null,C(v),1)])]),"cell-model":D(({value:v})=>[e("span",Lk,C(v||"—"),1)]),"cell-fallbacks":D(({value:v})=>[v&&v.length>0?(r(),n("div",Pk,[(r(!0),n(ve,null,ye(v,(d,k)=>(r(),n("div",{key:d.id,class:"text-sm text-neutral-600 dark:text-neutral-400 flex items-center",title:d.name},[e("span",jk,C(k===v.length-1?"└─":"├─"),1),d.provider?(r(),n("img",{key:0,src:`/api/providers/${d.provider}/icon?model=${encodeURIComponent(d.model||"")}`,class:"w-4 h-4 shrink-0 mr-1.5",alt:d.provider},null,8,Dk)):I("",!0),e("span",Ok,C(d.name),1)],8,Ak))),128))])):(r(),n("span",Rk," None "))]),_:1},8,["primary-action","data","loading"]),w(Vk,{modelValue:o.value,"onUpdate:modelValue":[b[0]||(b[0]=v=>o.value=v),b[1]||(b[1]=v=>{o.value=v,v||(l.value=null,u.value="add")})],"edit-model":l.value,mode:u.value,onSave:x},null,8,["modelValue","edit-model","mode"])]),_:1}))}}),Bk={class:"space-y-4"},Fk={class:"space-y-1"},Nk={class:"relative"},qk={key:0,class:"flex items-center gap-2"},Hk=["src","alt"],Wk={key:1,class:"text-neutral-500"},Kk={key:0,class:"absolute z-10 w-full mt-1 bg-white dark:bg-black border-2 border-neutral-300 dark:border-neutral-600 rounded shadow-lg max-h-60 overflow-auto"},Jk=["onClick"],Yk=["src","alt"],Gk={key:0,class:"text-xs text-red-500 dark:text-red-400"},Zk={class:"flex gap-2 justify-end"},Xk=me({__name:"AddProviderModal",props:{modelValue:{type:Boolean}},emits:["update:modelValue","save"],setup(t,{emit:o}){const a=o,i=p([]),l=p(!1),u=p(!1),s=p(""),m=p(""),h=async()=>{l.value=!0;try{const k=await fetch(fe("/api/providers"));if(k.ok){const g=await k.json();i.value=(g.providers||[]).map(_=>({value:_.name,label:_.label||_.name,icon:_.iconId,sdk:_.sdk}))}}catch(k){console.error("Error fetching providers:",k)}finally{l.value=!1}};Pe(()=>{h()});const x=B(()=>i.value.find(k=>k.value===s.value)),c=()=>{setTimeout(()=>{u.value=!1},200)},f=k=>{s.value=k,u.value=!1,m.value=""},y=B(()=>s.value==="custom"||s.value==="openai"),b=p("");ge(s,k=>{if(k&&!b.value){const g=i.value.find(_=>_.value===k);g&&(b.value=g.label)}});const v=k=>{if(!s.value){m.value="Provider type is required";return}a("save",{name:k.name,type:s.value,apiKey:k.apiKey,baseUrl:k.baseUrl}),d()},d=()=>{Mt("add-provider-form"),s.value="",b.value="",m.value="",a("update:modelValue",!1)};return(k,g)=>{const _=Be("FormKit");return r(),H(He,{"model-value":t.modelValue,"onUpdate:modelValue":g[2]||(g[2]=L=>k.$emit("update:modelValue",L)),title:"Add Provider",width:"max-w-md"},{footer:D(()=>[e("div",Zk,[w(T(De),{variant:"ghost",size:"sm",onClick:d},{default:D(()=>[...g[5]||(g[5]=[Z(" Cancel ",-1)])]),_:1}),w(T(De),{variant:"primary",size:"sm",type:"submit",form:"add-provider-form"},{default:D(()=>[...g[6]||(g[6]=[Z(" Add Provider ",-1)])]),_:1})])]),default:D(()=>[w(_,{id:"add-provider-form",type:"form",actions:!1,onSubmit:v},{default:D(()=>[e("div",Bk,[e("div",Fk,[g[4]||(g[4]=e("label",{class:"block text-sm font-medium"},[Z(" Provider Type "),e("span",{class:"text-red-500"},"*")],-1)),e("div",Nk,[e("button",{type:"button",onClick:g[0]||(g[0]=L=>u.value=!u.value),onBlur:c,class:ae(["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-accent-500 dark:focus:ring-accent-400 transition-colors",[m.value?"border-red-500 dark:border-red-400":"border-neutral-300 dark:border-neutral-600"]])},[x.value?(r(),n("div",qk,[e("img",{src:x.value.icon,alt:x.value.label,class:"w-5 h-5"},null,8,Hk),e("span",null,C(x.value.label),1)])):(r(),n("span",Wk,"Select a provider")),g[3]||(g[3]=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?(r(),n("div",Kk,[(r(!0),n(ve,null,ye(i.value,L=>(r(),n("button",{key:L.value,type:"button",onClick:R=>f(L.value),class:"w-full px-3 py-2 text-left hover:bg-accent-50 dark:hover:bg-accent-900/20 transition-colors flex items-center gap-2"},[e("img",{src:L.icon,alt:L.label,class:"w-5 h-5"},null,8,Yk),e("span",null,C(L.label),1)],8,Jk))),128))])):I("",!0)]),m.value?(r(),n("p",Gk,C(m.value),1)):I("",!0)]),w(_,{type:"text",name:"name",label:"Provider Name",placeholder:"e.g., My OpenAI Provider",validation:"required",modelValue:b.value,"onUpdate:modelValue":g[1]||(g[1]=L=>b.value=L),"validation-messages":{required:"Provider name is required"}},null,8,["modelValue"]),w(_,{type:"password",name:"apiKey",label:"API Key",placeholder:"sk-...",validation:"required","validation-messages":{required:"API key is required"}}),y.value?(r(),H(_,{key:0,type:"text",name:"baseUrl",label:"Base URL",placeholder:"https://api.example.com",validation:s.value==="custom"?"required":"","validation-messages":{required:"Base URL is required for custom providers"}},null,8,["validation"])):I("",!0)])]),_:1})]),_:1},8,["model-value"])}}}),Qk={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function e2(t,o){return r(),n("svg",Qk,[...o[0]||(o[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])}const t2=Ie({name:"lucide-check",render:e2}),r2={class:"flex items-center gap-2"},a2=["src","alt"],o2={key:0,class:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded-full bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"},n2={key:1,class:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded-full bg-neutral-100 text-neutral-500 dark:bg-neutral-800 dark:text-neutral-400"},l2=me({__name:"ProvidersView",setup(t){const o=p(!1),a=p([]),i=p(!1),l={"openai-sdk":"OpenAI SDK",openrouter:"OpenRouter",openai:"OpenAI"},u=f=>l[f]||f,s=[{key:"name",label:"Name",width:"w-1/3",sortable:!0},{key:"sdk",label:"SDK Type",width:"w-1/3",sortable:!0,formatter:f=>u(f)},{key:"hasApiKey",label:"API Key",width:"w-1/3"}],m=[{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this provider? This action cannot be undone.",variant:"danger",handler:async f=>{await c(f.name)}}],h=async()=>{i.value=!0;try{const f=await fetch(fe("/api/providers"));if(!f.ok)throw new Error("Failed to fetch providers");const y=await f.json();a.value=y.providers||[]}catch(f){console.error("Error fetching providers:",f),a.value=[]}finally{i.value=!1}},x=async f=>{try{const y=await fetch(fe("/api/providers"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!y.ok){const b=await y.json();alert(b.error||"Failed to add provider");return}await h(),o.value=!1}catch(y){console.error("Error adding provider:",y),alert("Failed to add provider")}},c=async f=>{try{const y=await fetch(fe(`/api/providers/${encodeURIComponent(f)}`),{method:"DELETE"});if(!y.ok){const b=await y.json();b.modelCount?alert(`${b.error}
53
+
54
+ This provider has ${b.modelCount} associated model(s).`):alert(b.error||"Failed to delete provider");return}await h()}catch(y){console.error("Error deleting provider:",y),alert("Failed to delete provider")}};return Pe(()=>{h()}),(f,y)=>(r(),H(pt,null,{default:D(()=>[w(ot,{title:"Providers",description:"Manage API providers and authentication keys. All API keys are encrypted at rest.","primary-action":{label:"Add Provider",icon:T(jt),handler:()=>o.value=!0},columns:s,data:a.value,actions:m,loading:i.value,sortable:"",searchable:"","search-placeholder":"Search providers...","empty-message":"No providers configured yet. Add your first provider to get started."},{"cell-sdk":D(({value:b,row:v})=>[e("div",r2,[e("img",{src:`/api/providers/${v.name}/icon`,alt:u(b),class:"w-5 h-5"},null,8,a2),e("span",null,C(u(b)),1)])]),"cell-hasApiKey":D(({value:b})=>[b?(r(),n("span",o2,[w(T(t2),{class:"w-3.5 h-3.5"}),y[1]||(y[1]=Z(" Configured ",-1))])):(r(),n("span",n2,[w(T(Pt),{class:"w-3.5 h-3.5"}),y[2]||(y[2]=Z(" Not configured ",-1))]))]),_:1},8,["primary-action","data","loading"]),w(Xk,{modelValue:o.value,"onUpdate:modelValue":y[0]||(y[0]=b=>o.value=b),onSave:x},null,8,["modelValue"])]),_:1}))}}),s2={class:"font-medium mb-1"},i2={id:"functions"},u2=["onClick"],d2={key:1,class:"text-left font-medium text-red-600 dark:text-red-400"},c2={class:"flex justify-end"},p2=["onClick"],m2={key:1,class:"text-neutral-400 text-sm"},v2={id:"prompts",class:"mt-12"},f2=["onClick"],h2={class:"text-neutral-600 dark:text-neutral-400"},g2={class:"text-sm text-neutral-500 dark:text-neutral-400"},b2={id:"agents",class:"mt-12"},x2=["onClick"],y2={class:"text-neutral-600 dark:text-neutral-400"},k2={class:"text-sm text-neutral-500 dark:text-neutral-400"},w2={class:"flex items-center gap-2"},_2={key:0,class:"space-y-4"},$2={class:"text-lg font-medium mb-2"},C2={class:"text-sm text-neutral-600 dark:text-neutral-400 mb-4"},S2={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"},T2=me({__name:"ToolsView",setup(t){const o=p(null),a=p(!1),{data:i}=Ne(fe("/api/config")).json(),{data:l,error:u,isFetching:s,execute:m}=Ne(fe("/api/tools?type=tools"),{immediate:!1}).json(),{data:h,error:x,isFetching:c,execute:f}=Ne(fe("/api/tools?type=prompts&schema=true"),{immediate:!1}).json(),{data:y,error:b,isFetching:v,execute:d}=Ne(fe("/api/tools?type=agents&schema=true"),{immediate:!1}).json(),{data:k,error:g,isFetching:_,execute:L}=Ne(()=>o.value?fe(`/api/tools/${o.value.name}`):null,{immediate:!1}).json(),R=p([]),K=p([]),Y=p([]),z=ut(),P=async()=>{const W=z.hash;if(W){await Le();const M=document.getElementById(W.slice(1));M&&M.scrollIntoView({behavior:"smooth"})}};ge(()=>z.hash,P);const G=async W=>{o.value=W,await L(),k.value?o.value={...W,schema:k.value.schema||null}:g.value&&console.error("Error fetching tool schema:",g.value),a.value=!0},ee=async W=>{if(o.value=W,a.value=!0,!W.schema&&W.type==="prompt"){const M=await fetch(fe("/api/tools?type=prompts&schema=true"));if(M.ok){const ne=await M.json();ne[W.name]&&(o.value={...W,schema:ne[W.name].schema||null})}}},se=[{key:"name",label:"Prompt Name",width:"w-1/3",sortable:!0},{key:"description",label:"Description",width:"w-1/2"},{key:"model",label:"Model",width:"w-1/6",sortable:!0,filterable:!0}],de=[{key:"name",label:"Agent Name",width:"w-1/3",sortable:!0},{key:"description",label:"Description",width:"w-1/2"},{key:"prompt",label:"Prompt",width:"w-1/6",sortable:!0,filterable:!0}],Q=[{key:"name",label:"Tool Name",width:"w-1/3",sortable:!0},{key:"description",label:"Description",width:"w-1/2"},{key:"actions",label:"Actions",width:"w-1/6"}],E=W=>/^[a-z][a-z0-9_]*[a-z0-9]$/.test(W)||/^[a-z]$/.test(W),S=W=>W.hasError&&W.error?W.error:W.description||"No description available",V=()=>{l.value&&(R.value=Object.entries(l.value).map(([W,M])=>({name:W,description:M.description||"No description available",schema:null,hasError:M.hasError||!1,error:M.error,type:M.type||"tool"})))},re=()=>{h.value&&(K.value=Object.entries(h.value).map(([W,M])=>({name:W,description:M.description||"No description available",schema:M.schema||null,hasError:!1,type:"prompt",model:M.model})))},F=()=>{y.value&&(Y.value=Object.entries(y.value).map(([W,M])=>({name:W,description:M.description||"No description available",schema:M.schema||null,hasError:!1,type:"agent",prompt:M.prompt||M.model})))},q=async()=>{await m(),V()},N=async()=>{await f(),re()},J=async()=>{await d(),F()},U=()=>{a.value=!1,o.value=null};return Pe(()=>{q(),N(),J(),P()}),(W,M)=>(r(),H(pt,null,{default:D(()=>[M[6]||(M[6]=e("div",{class:"flex justify-between items-center mb-6"},[e("h1",{class:"text-3xl font-bold"},"Tools")],-1)),M[7]||(M[7]=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)),w(T(Fe),{variant:"info",class:"mb-6"},{default:D(()=>[e("p",s2,[M[1]||(M[1]=Z(" To create or modify tools, edit the ",-1)),w(T(Nr),null,{default:D(()=>[Z(C(T(i)?.toolsDir||"agentbuilder/tools")+"/",1)]),_:1}),M[2]||(M[2]=Z(" directory of your codebase. ",-1))]),M[3]||(M[3]=e("p",{class:"opacity-70"}," Changes will be automatically detected. ",-1))]),_:1}),e("div",i2,[w(ot,{title:"Functions",description:"Function tools defined in your codebase.",columns:Q,data:R.value,loading:T(s),sortable:"",searchable:"","search-placeholder":"Search functions...","empty-message":`No tools found. Add tool files to the ${T(i)?.toolsDir||"agentbuilder/tools"}/ directory.`},{"cell-name":D(({row:ne})=>[e("div",{class:ae(["flex items-center gap-2",{"text-red-600 dark:text-red-400":ne.hasError}])},[ne.hasError?(r(),n("span",d2,C(ne.name),1)):(r(),n("button",{key:0,onClick:A=>G(ne),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},C(ne.name),9,u2)),ne.hasError?(r(),H(T(dr),{key:2,content:"This tool has validation errors"},{default:D(()=>[w(T(ir),{class:"w-4 h-4 text-red-500"})]),_:1})):E(ne.name)?I("",!0):(r(),H(T(dr),{key:3,content:"Tool name should be in snake_case format (e.g., 'log_name', 'send_email')"},{default:D(()=>[w(T(ir),{class:"w-4 h-4 text-amber-500"})]),_:1}))],2)]),"cell-description":D(({row:ne})=>[e("span",{class:ae({"text-red-600 dark:text-red-400":ne.hasError,"text-neutral-600 dark:text-neutral-400":!ne.hasError})},C(S(ne)),3)]),"cell-actions":D(({row:ne})=>[e("div",c2,[ne.hasError?(r(),n("span",m2,"—")):(r(),n("button",{key:0,onClick:A=>G(ne),class:"p-1.5 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",title:"View Schema"},[w(T(Kt),{class:"w-4 h-4"})],8,p2))])]),_:1},8,["data","loading","empty-message"])]),e("div",v2,[w(ot,{title:"Prompts",description:"Prompts that are exposed as tools can be called by other prompts and agents. These allow you to create reusable, composable prompt chains.",columns:se,data:K.value,loading:T(c),sortable:"",searchable:"","search-placeholder":"Search prompts...","empty-message":"No prompts are currently exposed as tools. Mark a prompt as 'Expose as tool' to see it here."},{"cell-name":D(({row:ne})=>[e("button",{onClick:A=>ee(ne),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},C(ne.name),9,f2)]),"cell-description":D(({row:ne})=>[e("span",h2,C(ne.description),1)]),"cell-model":D(({row:ne})=>[e("span",g2,C(ne.model||"-"),1)]),_:1},8,["data","loading"])]),e("div",b2,[w(ot,{title:"Agents",description:"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.",columns:de,data:Y.value,loading:T(v),sortable:"",searchable:"","search-placeholder":"Search agents...","empty-message":"No agents are currently exposed as tools. Mark an agent as 'Expose as tool' to see it here."},{"cell-name":D(({row:ne})=>[e("button",{onClick:A=>ee(ne),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},C(ne.name),9,x2)]),"cell-description":D(({row:ne})=>[e("span",y2,C(ne.description),1)]),"cell-prompt":D(({row:ne})=>[e("span",k2,C(ne.prompt||"-"),1)]),_:1},8,["data","loading"])]),w(He,{modelValue:a.value,"onUpdate:modelValue":M[0]||(M[0]=ne=>a.value=ne),onClose:U,width:"max-w-4xl"},{header:D(()=>[e("div",w2,[w(T(Kt),{class:"w-5 h-5"}),e("span",null,C(o.value?.name)+" Schema",1)])]),footer:D(()=>[w(T(De),{onClick:U},{default:D(()=>[...M[5]||(M[5]=[Z(" Close ",-1)])]),_:1})]),default:D(()=>[o.value?(r(),n("div",_2,[e("div",null,[e("h3",$2,C(o.value.type==="prompt"?"Required Schema":"JSON Schema"),1),e("p",C2,C(o.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)]),o.value.schema===null?(r(),n("div",S2,[...M[4]||(M[4]=[e("p",{class:"text-neutral-500 dark:text-neutral-400"}," No parameters required ",-1)])])):(r(),H(zt,{key:1,value:o.value.schema,class:"h-96 border border-black/20 dark:border-white/20 rounded"},null,8,["value"]))])):I("",!0)]),_:1},8,["modelValue"])]),_:1}))}}),I2={class:"space-y-4"},z2={class:"flex justify-end gap-2"},V2={class:"space-y-4"},M2={class:"flex justify-end gap-2"},E2=me({__name:"UsersView",setup(t){const o=p(!1),a=p(!1),i=p([]),l=p(!1),u=p(null),s=p({username:"",role:"admin"}),m=[{value:"admin",label:"Admin"}],h=[{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:k=>new Date(k*1e3).toLocaleString()}],x=[{icon:"edit",label:"Edit",handler:async k=>{u.value=k,s.value={username:k.username,role:k.role},a.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 k=>{await b(k.id)}}],c=async()=>{l.value=!0;try{const k=await Je("/users");if(!k.ok)throw new Error("Failed to fetch users");const g=await k.json();i.value=g.users||[]}catch(k){console.error("Error fetching users:",k),i.value=[]}finally{l.value=!1}},f=async k=>{try{const g=await Je("/users",{method:"POST",body:JSON.stringify(k)});if(!g.ok){const _=await g.json();alert(_.error||"Failed to add user");return}await c(),v()}catch(g){console.error("Error adding user:",g),alert("Failed to add user")}},y=async k=>{try{const g={username:k.username,role:k.role};k.password&&(g.password=k.password);const _=await Je(`/users/${u.value.id}`,{method:"PUT",body:JSON.stringify(g)});if(!_.ok){const L=await _.json();alert(L.error||"Failed to update user");return}await c(),d()}catch(g){console.error("Error updating user:",g),alert("Failed to update user")}},b=async k=>{try{const g=await Je(`/users/${k}`,{method:"DELETE"});if(!g.ok){const _=await g.json();alert(_.error||"Failed to delete user");return}await c()}catch(g){console.error("Error deleting user:",g),alert("Failed to delete user")}},v=()=>{Mt("add-user-form"),o.value=!1},d=()=>{Mt("edit-user-form"),a.value=!1,u.value=null};return Pe(()=>{c()}),(k,g)=>{const _=Be("FormKit");return r(),H(pt,null,{default:D(()=>[w(ot,{title:"Users",description:"Manage user accounts and permissions","primary-action":{label:"Add User",handler:()=>o.value=!0},columns:h,data:i.value,actions:x,loading:l.value,"empty-message":"No users found"},null,8,["primary-action","data","loading"]),w(He,{modelValue:o.value,"onUpdate:modelValue":g[0]||(g[0]=L=>o.value=L),title:"Add User",onClose:v},{footer:D(()=>[e("div",z2,[w(T(De),{variant:"secondary",onClick:v},{default:D(()=>[...g[4]||(g[4]=[Z(" Cancel ",-1)])]),_:1}),w(T(De),{type:"submit",form:"add-user-form"},{default:D(()=>[...g[5]||(g[5]=[Z(" Add User ",-1)])]),_:1})])]),default:D(()=>[w(_,{id:"add-user-form",type:"form",actions:!1,onSubmit:f},{default:D(()=>[e("div",I2,[w(_,{type:"text",name:"username",label:"Username",validation:"required","validation-messages":{required:"Username is required"}}),w(_,{type:"password",name:"password",label:"Password",validation:"required","validation-messages":{required:"Password is required"}}),w(_,{type:"selectSearch",name:"role",label:"Role",options:m,value:"admin",placeholder:"Select role"})])]),_:1})]),_:1},8,["modelValue"]),w(He,{modelValue:a.value,"onUpdate:modelValue":g[3]||(g[3]=L=>a.value=L),title:"Edit User",onClose:d},{footer:D(()=>[e("div",M2,[w(T(De),{variant:"secondary",onClick:d},{default:D(()=>[...g[6]||(g[6]=[Z(" Cancel ",-1)])]),_:1}),w(T(De),{type:"submit",form:"edit-user-form"},{default:D(()=>[...g[7]||(g[7]=[Z(" Update User ",-1)])]),_:1})])]),default:D(()=>[w(_,{id:"edit-user-form",type:"form",actions:!1,onSubmit:y},{default:D(()=>[e("div",V2,[w(_,{type:"text",name:"username",label:"Username",validation:"required",modelValue:s.value.username,"onUpdate:modelValue":g[1]||(g[1]=L=>s.value.username=L),"validation-messages":{required:"Username is required"}},null,8,["modelValue"]),w(_,{type:"password",name:"password",label:"Password",help:"Leave blank to keep current password"}),w(_,{type:"selectSearch",name:"role",label:"Role",options:m,modelValue:s.value.role,"onUpdate:modelValue":g[2]||(g[2]=L=>s.value.role=L),placeholder:"Select role"},null,8,["modelValue"])])]),_:1})]),_:1},8,["modelValue"])]),_:1})}}}),L2={class:"flex justify-end gap-2"},P2={class:"space-y-4"},A2={class:"flex gap-2"},j2=["value"],D2={class:"flex justify-end mt-4"},O2=me({__name:"ApiKeysView",setup(t){const o=p(!1),a=p(!1),i=p([]),l=p(!1),u=p(""),s=[{key:"name",label:"Name",width:"w-1/3"},{key:"keyPreview",label:"API Key",width:"w-1/3",html:!0,formatter:b=>`<code class="bg-neutral-100 dark:bg-neutral-800 px-2 py-1 rounded text-sm">${b}</code>`},{key:"createdAt",label:"Created",width:"w-1/6",formatter:b=>new Date(b*1e3).toLocaleDateString()},{key:"lastUsedAt",label:"Last Used",width:"w-1/6",formatter:b=>b?new Date(b*1e3).toLocaleDateString():"Never"}],m=[{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this API key? This action cannot be undone.",handler:async b=>{await f(b.id)}}],h=async()=>{l.value=!0;try{const b=await Je("/api-keys");if(!b.ok)throw new Error("Failed to fetch API keys");const v=await b.json();i.value=(v.keys||[]).map(d=>({...d,keyPreview:`${d.key_prefix}...${d.last_five}`,createdAt:d.created_at,lastUsedAt:d.last_used_at}))}catch(b){console.error("Error fetching API keys:",b),i.value=[]}finally{l.value=!1}},x=async b=>{try{const v=await Je("/api-keys",{method:"POST",body:JSON.stringify(b)}),d=await v.json();if(!v.ok){alert(d.error||"Failed to create API key");return}u.value=d.key,c(),a.value=!0,await h()}catch(v){console.error("Error creating API key:",v),alert("Failed to create API key")}},c=()=>{Mt("add-api-key-form"),o.value=!1},f=async b=>{try{const v=await Je(`/api-keys/${b}`,{method:"DELETE"});if(!v.ok){const d=await v.json();alert(d.error||"Failed to delete API key");return}await h()}catch(v){console.error("Error deleting API key:",v),alert("Failed to delete API key")}},y=async b=>{try{await navigator.clipboard.writeText(b),alert("API key copied to clipboard!")}catch(v){console.error("Failed to copy:",v)}};return Pe(()=>{h()}),(b,v)=>{const d=Be("FormKit");return r(),H(pt,null,{default:D(()=>[w(ot,{title:"API Keys",description:"Manage API keys for programmatic access","primary-action":{label:"Create API Key",handler:()=>o.value=!0},columns:s,data:i.value,actions:m,loading:l.value,"empty-message":"No API keys found"},null,8,["primary-action","data","loading"]),w(He,{modelValue:o.value,"onUpdate:modelValue":v[0]||(v[0]=k=>o.value=k),title:"Create API Key",onClose:c},{footer:D(()=>[e("div",L2,[w(T(De),{variant:"secondary",onClick:c},{default:D(()=>[...v[5]||(v[5]=[Z(" Cancel ",-1)])]),_:1}),w(T(De),{type:"submit",form:"add-api-key-form"},{default:D(()=>[...v[6]||(v[6]=[Z(" Create Key ",-1)])]),_:1})])]),default:D(()=>[w(d,{id:"add-api-key-form",type:"form",actions:!1,onSubmit:x},{default:D(()=>[w(d,{type:"text",name:"name",label:"Name",placeholder:"e.g., Production API Key",help:"A descriptive name to help you identify this key",validation:"required","validation-messages":{required:"Name is required"}})]),_:1})]),_:1},8,["modelValue"]),w(He,{modelValue:a.value,"onUpdate:modelValue":v[3]||(v[3]=k=>a.value=k),title:"API Key Created",onClose:v[4]||(v[4]=k=>a.value=!1)},{default:D(()=>[e("div",P2,[w(T(Fe),{variant:"warning"},{default:D(()=>[...v[7]||(v[7]=[e("p",{class:"font-semibold"},"Important: Save this key now!",-1),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)])]),_:1}),e("div",null,[v[9]||(v[9]=e("label",{class:"block text-sm font-medium mb-2"},"Your new API key:",-1)),e("div",A2,[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,j2),w(T(De),{variant:"secondary",onClick:v[1]||(v[1]=k=>y(u.value))},{default:D(()=>[...v[8]||(v[8]=[Z(" Copy ",-1)])]),_:1})])]),w(T(Fe),{variant:"info"},{default:D(()=>[v[10]||(v[10]=e("p",{class:"text-sm"}," Use this key in the Authorization header of your API requests: ",-1)),w(T(Nr),{inline:!1,class:"mt-2"},{default:D(()=>[Z(" Authorization: Bearer "+C(u.value),1)]),_:1})]),_:1}),e("div",D2,[w(T(De),{onClick:v[2]||(v[2]=k=>a.value=!1)},{default:D(()=>[...v[11]||(v[11]=[Z(" Done ",-1)])]),_:1})])])]),_:1},8,["modelValue"])]),_:1})}}}),R2={class:"login-container flex-1 flex items-center justify-center px-4"},U2={class:"max-w-md w-full space-y-8"},B2={class:"flex justify-center"},F2=["src"],N2={class:"bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-700 py-8 px-6 rounded-lg"},q2={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 mb-6 rounded"},H2={class:"mt-6"},W2=["disabled"],K2={key:0,class:"mt-6"},J2=me({__name:"LoginView",setup(t){function o(d){if(d.startsWith("/src/")||d.startsWith("data:"))return d;const k=_t();return k==="/"?d.replace("/agents/","/"):d.replace("/agents/",`${k}/`)}const a=o(Zr),i=o(Xr),l=bt(),u=ut(),s=p(""),m=p(!1),h=p(!1),x=p(!1),c=p(!1),f=B(()=>c.value?i:a);Pe(async()=>{const d=localStorage.getItem("theme");c.value=d==="dark"||!d&&window.matchMedia("(prefers-color-scheme: dark)").matches;const k=u.query.token,g=u.query.error;if(k){localStorage.setItem("auth_token",k),l.push("/");return}g&&(g==="oauth_failed"?s.value="OAuth authentication failed. Please try again.":g==="oauth_not_configured"&&(s.value="OAuth provider is not configured."));try{const _=await fetch(fe("/api/auth/config"));if(_.ok){const L=await _.json();h.value=L.github||!1,x.value=L.google||!1}}catch(_){console.error("Failed to fetch auth config:",_)}});async function y(d){s.value="",m.value=!0;try{const k=await fetch(fe("/api/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:d.username,password:d.password})}),g=await k.json();k.ok?(localStorage.setItem("auth_token",g.token),l.push("/")):s.value=g.error||"Login failed"}catch{s.value="Network error. Please try again."}finally{m.value=!1}}function b(){window.location.href=fe("/api/auth/oauth/github")}function v(){window.location.href=fe("/api/auth/oauth/google")}return(d,k)=>{const g=Be("FormKit");return r(),n("div",R2,[e("div",U2,[e("div",B2,[e("img",{src:f.value,alt:"AgentBuilder",class:"h-16 pointer-events-none select-none"},null,8,F2)]),w(wt,{offsetX:8,offsetY:8,intensity:.2,pattern:"crosshatch"},{default:D(()=>[e("div",N2,[w(g,{type:"form",actions:!1,onSubmit:y,disabled:m.value},{default:D(()=>[s.value?(r(),n("div",q2,C(s.value),1)):I("",!0),w(g,{type:"text",name:"username",label:"Username",placeholder:"Enter your username",validation:"required","validation-messages":{required:"Username is required"}}),w(g,{type:"password",name:"password",label:"Password",placeholder:"Enter your password",validation:"required","validation-messages":{required:"Password is required"}}),e("div",H2,[e("button",{type:"submit",disabled:m.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(m.value?"Signing in...":"Sign in"),9,W2)])]),_:1},8,["disabled"]),h.value||x.value?(r(),n("div",K2,[k[2]||(k[2]=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:ae(["mt-6 grid gap-3",h.value&&x.value?"grid-cols-2":"grid-cols-1"])},[h.value?(r(),n("button",{key:0,onClick:b,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"},[...k[0]||(k[0]=[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)])])):I("",!0),x.value?(r(),n("button",{key:1,onClick:v,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"},[...k[1]||(k[1]=[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)])])):I("",!0)],2)])):I("",!0)])]),_:1})])])}}}),Y2={class:"space-y-1"},G2=["value","placeholder","disabled"],Ft=me({__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:o,emit:a}){const i=t,l=a,u=p(null),s=B(()=>["w-full px-3 py-2.5 bg-neutral-50 dark:bg-neutral-950 border rounded-md font-mono text-sm","focus:outline-none focus:ring-2 focus:ring-neutral-400 dark:focus:ring-neutral-500 focus:border-transparent","transition-colors resize-none overflow-hidden placeholder:text-neutral-400 dark:placeholder:text-neutral-500",i.error?"border-red-500 dark:border-red-400":"border-neutral-300 dark:border-neutral-600",i.disabled?"opacity-50 cursor-not-allowed":""]),m=()=>{const f=u.value;f&&(f.style.height="auto",f.style.height=`${f.scrollHeight+2}px`)},h=f=>{const y=f.target;l("update:modelValue",y.value),m()},x=f=>{l("focus",f)},c=f=>{l("blur",f)};return Pe(()=>{m()}),ge(()=>i.modelValue,async()=>{await Le(),m()}),o({textareaRef:u,adjustHeight:m}),(f,y)=>(r(),n("div",Y2,[t.label?(r(),H(T(Fr),{key:0,required:t.required},{default:D(()=>[Z(C(t.label),1)]),_:1},8,["required"])):I("",!0),e("textarea",{ref_key:"textareaRef",ref:u,value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,class:ae(s.value),rows:"1",onInput:h,onFocus:x,onBlur:c},null,42,G2),t.error?(r(),H(T(tt),{key:1},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)]))}}),Z2={class:"flex items-start"},X2=["for"],Q2=["id","checked","disabled"],ew={class:"flex items-center h-5"},tw={class:"flex-1"},rw={key:0,class:"text-red-500"},It=me({__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:o}){const a=t,i=o,l=Ka(),u=B(()=>["w-5 h-5 border-2 rounded relative flex-shrink-0","transition-all duration-150",a.error?"border-red-500 dark:border-red-400":"border-black dark:border-neutral-300",a.disabled?"opacity-50":"hover:scale-110",a.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]",a.modelValue?"before:block":"before:hidden"]),s=m=>{if(!a.disabled){const h=m.target;i("update:modelValue",h.checked)}};return(m,h)=>(r(),n("div",Z2,[e("label",{for:T(l),class:ae(["flex items-start space-x-3 cursor-pointer select-none",{"cursor-not-allowed":t.disabled}])},[e("input",{id:T(l),type:"checkbox",checked:t.modelValue,disabled:t.disabled,onChange:s,class:"absolute left-[-9999px]"},null,40,Q2),e("div",ew,[e("span",{class:ae(u.value)},null,2)]),e("div",tw,[t.label?(r(),n("span",{key:0,class:ae(["block text-sm font-medium",{"opacity-50":t.disabled}])},[Z(C(t.label)+" ",1),t.required?(r(),n("span",rw,"*")):I("",!0)],2)):I("",!0),t.helpText?(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[Z(C(t.helpText),1)]),_:1})):I("",!0),t.error?(r(),H(T(tt),{key:2,class:"mt-1"},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)])],10,X2)]))}}),aw={class:"p-8 space-y-6"},ow={class:"mt-12"},nw={class:"mb-6"},lw={class:"mb-6"},sw={class:"mb-6"},iw={class:"mt-8"},uw={class:"border-2 border-red-500 p-4 h-32 overflow-hidden relative"},dw={class:"mt-12"},cw={class:"mb-6"},pw={class:"border-2 border-accent-500 p-4 h-32 overflow-hidden relative"},mw={class:"mt-12"},vw={class:"mb-6"},fw={class:"mb-6"},hw={class:"mt-12"},gw={class:"mb-6"},bw={class:"mt-2 text-sm"},xw={class:"mb-6"},yw={class:"mt-2 text-sm"},kw={class:"mb-6"},ww={class:"mb-6"},_w={class:"mt-12"},$w={class:"mb-6"},Cw={class:"mt-4 p-4 bg-neutral-100 dark:bg-neutral-900 rounded"},Sw={class:"text-xs overflow-x-auto"},Tw=me({__name:"TestView",setup(t){const o=p(""),a=p(""),i=p(""),l=p(`Line 1
24
55
  Line 2
25
- Line 3`),u=v(""),r=v(""),c=v("option2"),f=v(""),g=v(""),d=v(""),p=v([]),h=v(["test1","test2"]),_=v(!1),b=v(!0),m=v(!1),y=v(!1),x=v({type:"object",properties:{},required:[]}),k=v(0);Me(()=>{window.resetJSONSchema=()=>{x.value={type:"object",properties:{},required:[]},k.value++}});const D=[{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"}],B=[{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(F,T)=>(a(),o("div",P1,[T[30]||(T[30]=e("h1",{class:"text-2xl font-bold"},"Component Test Page",-1)),e("div",null,[A(Le,{modelValue:n.value,"onUpdate:modelValue":T[0]||(T[0]=$=>n.value=$),label:"Test Label",placeholder:"Enter text..."},null,8,["modelValue"]),e("p",null,S(n.value),1)]),e("div",null,[A(Le,{modelValue:s.value,"onUpdate:modelValue":T[1]||(T[1]=$=>s.value=$),label:"Email",error:"Invalid email address",required:""},null,8,["modelValue"])]),e("div",D1,[T[18]||(T[18]=e("h2",{class:"text-xl font-bold mb-4"},"MultilineInput Tests",-1)),e("div",j1,[A(yt,{modelValue:i.value,"onUpdate:modelValue":T[2]||(T[2]=$=>i.value=$),label:"Multiline Text",placeholder:"Type multiple lines..."},null,8,["modelValue"]),e("p",null,S(i.value),1)]),e("div",O1,[A(yt,{modelValue:l.value,"onUpdate:modelValue":T[3]||(T[3]=$=>l.value=$),label:"Pre-filled Multiline",placeholder:"Already has content..."},null,8,["modelValue"]),e("pre",null,S(l.value),1)]),e("div",U1,[A(yt,{modelValue:u.value,"onUpdate:modelValue":T[4]||(T[4]=$=>u.value=$),label:"Required Field",error:"This field is required",required:""},null,8,["modelValue"])])]),e("div",null,[A(Ve,{modelValue:r.value,"onUpdate:modelValue":T[5]||(T[5]=$=>r.value=$),options:D,label:"Select Option",placeholder:"Choose an option..."},null,8,["modelValue"]),e("p",null,S(r.value),1)]),e("div",null,[A(Ve,{modelValue:r.value,"onUpdate:modelValue":T[6]||(T[6]=$=>r.value=$),options:D,label:"Required Select",placeholder:"Please select an option"},null,8,["modelValue"])]),e("div",null,[A(Ve,{modelValue:c.value,"onUpdate:modelValue":T[7]||(T[7]=$=>c.value=$),options:D,label:"Disabled Select",disabled:""},null,8,["modelValue"])]),e("div",R1,[T[20]||(T[20]=e("h2",{class:"text-lg font-semibold mb-2"},"Overflow Test",-1)),e("div",N1,[T[19]||(T[19]=e("p",{class:"text-sm text-neutral-600 mb-2"}," This container has overflow:hidden and limited height ",-1)),A(Ve,{modelValue:f.value,"onUpdate:modelValue":T[8]||(T[8]=$=>f.value=$),options:D,label:"Select in Overflow Container",placeholder:"Should break out of container..."},null,8,["modelValue"])]),T[21]||(T[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",F1,[T[25]||(T[25]=e("h2",{class:"text-xl font-bold mb-4"},"DropdownList Tests",-1)),e("div",B1,[A(Ve,{modelValue:g.value,"onUpdate:modelValue":T[9]||(T[9]=$=>g.value=$),options:q,label:"Select Item",placeholder:"Choose an item..."},null,8,["modelValue"]),e("p",null,S(g.value),1)]),e("div",null,[T[23]||(T[23]=e("h3",{class:"text-lg font-semibold mb-2"},"DropdownList Overflow Test",-1)),e("div",q1,[T[22]||(T[22]=e("p",{class:"text-sm text-neutral-600 mb-2"}," This container has overflow:hidden and limited height ",-1)),A(Ve,{modelValue:d.value,"onUpdate:modelValue":T[10]||(T[10]=$=>d.value=$),options:q,label:"Dropdown in Overflow Container",placeholder:"Should use popover API..."},null,8,["modelValue"])]),T[24]||(T[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",z1,[T[26]||(T[26]=e("h2",{class:"text-xl font-bold mb-4"},"MultipleSelectionsInput Tests",-1)),e("div",H1,[A(Ct,{modelValue:p.value,"onUpdate:modelValue":T[11]||(T[11]=$=>p.value=$),options:B,label:"Select Multiple Items",placeholder:"Choose items...","add-label":"Add another"},null,8,["modelValue"]),e("p",null,S(p.value),1)]),e("div",W1,[A(Ct,{modelValue:h.value,"onUpdate:modelValue":T[12]||(T[12]=$=>h.value=$),options:B,label:"Disabled Multiple Select",placeholder:"Cannot select...",disabled:""},null,8,["modelValue"])])]),e("div",J1,[T[27]||(T[27]=e("h2",{class:"text-xl font-bold mb-4"},"CheckboxInput Tests",-1)),e("div",K1,[A(Pe,{modelValue:_.value,"onUpdate:modelValue":T[13]||(T[13]=$=>_.value=$),label:"Basic Checkbox"},null,8,["modelValue"]),e("p",G1," Value: "+S(_.value),1)]),e("div",X1,[A(Pe,{modelValue:b.value,"onUpdate:modelValue":T[14]||(T[14]=$=>b.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",Y1," Value: "+S(b.value),1)]),e("div",Q1,[A(Pe,{modelValue:m.value,"onUpdate:modelValue":T[15]||(T[15]=$=>m.value=$),label:"Disabled Checkbox",helpText:"This checkbox is disabled and cannot be changed.",disabled:""},null,8,["modelValue"])]),e("div",Z1,[A(Pe,{modelValue:y.value,"onUpdate:modelValue":T[16]||(T[16]=$=>y.value=$),label:"Checkbox with Error",error:"You must accept the terms and conditions",required:""},null,8,["modelValue"])])]),e("div",ex,[T[29]||(T[29]=e("h2",{class:"text-xl font-bold mb-4"},"JSONSchemaInput Tests",-1)),e("div",tx,[(a(),ne(_a,{key:k.value,modelValue:x.value,"onUpdate:modelValue":T[17]||(T[17]=$=>x.value=$),label:"JSON Schema Builder"},null,8,["modelValue"])),e("div",ax,[T[28]||(T[28]=e("p",{class:"text-sm font-mono mb-2"},"Generated Schema:",-1)),e("pre",ox,S(JSON.stringify(x.value,null,2)),1)])])])]))}}),sx={class:"relative"},nx=["value","placeholder","rows"],rx={class:"bg-white dark:bg-black rounded-lg"},ix={class:"px-3 py-2 border-b border-black dark:border-neutral-300"},dx={class:"text-xs font-medium text-neutral-600 dark:text-neutral-400"},ux={key:0,class:"max-h-[200px] overflow-y-auto"},cx=["onClick"],px={class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},mx={class:"flex-1"},vx={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-0.5"},fx={key:1,class:"px-3 py-4 text-sm text-neutral-500 dark:text-neutral-400 text-center"},hx=me({__name:"ReferenceInput",props:{modelValue:{},search:{type:Function},placeholder:{},rows:{}},emits:["update:modelValue"],setup(t,{emit:n}){const s=t,i=n,l=v(null),u=v(null),r=v(!1),c=v(""),f=v([]),g=v(0),d=v(-1),p=v(-1),h=v(0),_=v({top:0,left:0}),b=async $=>{const K=$.target,oe=K.value,te=K.selectionStart;i("update:modelValue",oe),oe[te-1]==="@"&&!r.value?m(te):r.value&&await x(oe,te)},m=async $=>{d.value=$-1,p.value=$,c.value="",h.value=0,r.value=!0,g.value=0,await y(),await k("")},y=async()=>{if(!l.value)return;await Te();const $=l.value.getBoundingClientRect(),K=window.getComputedStyle(l.value),oe=parseInt(K.lineHeight||"20"),te=parseInt(K.paddingTop||"8"),P=s.modelValue.substring(0,p.value).split(`
26
- `),C=P.length,L=P[P.length-1],ee=Math.min(L.length*8,200);_.value={top:$.top+te+C*oe+4,left:$.left+te+ee}},x=async($,K)=>{if(K<=d.value){q();return}const oe=d.value+1,te=$.substring(oe,K);if(f.value.length===0?h.value++:h.value=0,f.value.length===0&&h.value>=5){q();return}c.value=te,await k(te)},k=async $=>{if(!s.search){f.value=[];return}const K=await s.search($);f.value=Array.isArray(K)?K:[],g.value>=f.value.length&&(g.value=0)},D=$=>{if(!l.value)return;const K=s.modelValue,oe=K.substring(0,d.value),te=K.substring(p.value+c.value.length),H=`@${$.value}`,P=oe+H+te;i("update:modelValue",P),Te(()=>{if(!l.value)return;const C=oe.length+H.length;l.value.focus(),l.value.setSelectionRange(C,C)}),q()},q=()=>{r.value=!1,c.value="",f.value=[],g.value=0,d.value=-1,p.value=-1,h.value=0},B=$=>{if(r.value)switch($.key){case"Escape":$.preventDefault(),q();break;case"ArrowDown":$.preventDefault(),g.value=Math.min(g.value+1,f.value.length-1);break;case"ArrowUp":$.preventDefault(),g.value=Math.max(g.value-1,0);break;case"Enter":f.value.length>0&&($.preventDefault(),D(f.value[g.value]));break;case"Tab":f.value.length>0&&($.preventDefault(),D(f.value[g.value]));break}},F=()=>{if(!r.value||!l.value)return;l.value.selectionStart<=d.value&&q()},T=$=>{if(!u.value||!r.value)return;const K=$.target;!u.value.contains(K)&&K!==l.value&&q()};return fe(r,$=>{$?document.addEventListener("click",T):document.removeEventListener("click",T)}),($,K)=>(a(),o("div",sx,[e("textarea",{ref_key:"textarea",ref:l,value:t.modelValue,onInput:b,onKeydown:B,onSelect:F,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,nx),(a(),ne(it,{to:"body"},[r.value?(a(),o("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:ot({top:`${_.value.top}px`,left:`${_.value.left}px`,boxShadow:"4px 4px 0 0 rgba(0, 0, 0, 0.25)",backgroundImage:`
56
+ Line 3`),u=p(""),s=p(""),m=p("option2"),h=p(""),x=p(""),c=p(""),f=p([]),y=p(["test1","test2"]),b=p(!1),v=p(!0),d=p(!1),k=p(!1),g=p({type:"object",properties:{},required:[]}),_=p(0);Pe(()=>{window.resetJSONSchema=()=>{g.value={type:"object",properties:{},required:[]},_.value++}});const L=[{value:"option1",label:"Option One"},{value:"option2",label:"Option Two"},{value:"option3",label:"Option Three"},{value:"option4",label:"Option Four"}],R=[{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"}],K=[{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(Y,z)=>(r(),n("div",aw,[z[30]||(z[30]=e("h1",{class:"text-2xl font-bold"},"Component Test Page",-1)),e("div",null,[w(lt,{modelValue:o.value,"onUpdate:modelValue":z[0]||(z[0]=P=>o.value=P),label:"Test Label",placeholder:"Enter text..."},null,8,["modelValue"]),e("p",null,C(o.value),1)]),e("div",null,[w(lt,{modelValue:a.value,"onUpdate:modelValue":z[1]||(z[1]=P=>a.value=P),label:"Email",error:"Invalid email address",required:""},null,8,["modelValue"])]),e("div",ow,[z[18]||(z[18]=e("h2",{class:"text-xl font-bold mb-4"},"MultilineInput Tests",-1)),e("div",nw,[w(Ft,{modelValue:i.value,"onUpdate:modelValue":z[2]||(z[2]=P=>i.value=P),label:"Multiline Text",placeholder:"Type multiple lines..."},null,8,["modelValue"]),e("p",null,C(i.value),1)]),e("div",lw,[w(Ft,{modelValue:l.value,"onUpdate:modelValue":z[3]||(z[3]=P=>l.value=P),label:"Pre-filled Multiline",placeholder:"Already has content..."},null,8,["modelValue"]),e("pre",null,C(l.value),1)]),e("div",sw,[w(Ft,{modelValue:u.value,"onUpdate:modelValue":z[4]||(z[4]=P=>u.value=P),label:"Required Field",error:"This field is required",required:""},null,8,["modelValue"])])]),e("div",null,[w(Ge,{modelValue:s.value,"onUpdate:modelValue":z[5]||(z[5]=P=>s.value=P),options:L,label:"Select Option",placeholder:"Choose an option..."},null,8,["modelValue"]),e("p",null,C(s.value),1)]),e("div",null,[w(Ge,{modelValue:s.value,"onUpdate:modelValue":z[6]||(z[6]=P=>s.value=P),options:L,label:"Required Select",placeholder:"Please select an option"},null,8,["modelValue"])]),e("div",null,[w(Ge,{modelValue:m.value,"onUpdate:modelValue":z[7]||(z[7]=P=>m.value=P),options:L,label:"Disabled Select",disabled:""},null,8,["modelValue"])]),e("div",iw,[z[20]||(z[20]=e("h2",{class:"text-lg font-semibold mb-2"},"Overflow Test",-1)),e("div",uw,[z[19]||(z[19]=e("p",{class:"text-sm text-neutral-600 mb-2"}," This container has overflow:hidden and limited height ",-1)),w(Ge,{modelValue:h.value,"onUpdate:modelValue":z[8]||(z[8]=P=>h.value=P),options:L,label:"Select in Overflow Container",placeholder:"Should break out of container..."},null,8,["modelValue"])]),z[21]||(z[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",dw,[z[25]||(z[25]=e("h2",{class:"text-xl font-bold mb-4"},"DropdownList Tests",-1)),e("div",cw,[w(Ge,{modelValue:x.value,"onUpdate:modelValue":z[9]||(z[9]=P=>x.value=P),options:R,label:"Select Item",placeholder:"Choose an item..."},null,8,["modelValue"]),e("p",null,C(x.value),1)]),e("div",null,[z[23]||(z[23]=e("h3",{class:"text-lg font-semibold mb-2"},"DropdownList Overflow Test",-1)),e("div",pw,[z[22]||(z[22]=e("p",{class:"text-sm text-neutral-600 mb-2"}," This container has overflow:hidden and limited height ",-1)),w(Ge,{modelValue:c.value,"onUpdate:modelValue":z[10]||(z[10]=P=>c.value=P),options:R,label:"Dropdown in Overflow Container",placeholder:"Should use popover API..."},null,8,["modelValue"])]),z[24]||(z[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",mw,[z[26]||(z[26]=e("h2",{class:"text-xl font-bold mb-4"},"MultipleSelectionsInput Tests",-1)),e("div",vw,[w(ht,{modelValue:f.value,"onUpdate:modelValue":z[11]||(z[11]=P=>f.value=P),options:K,label:"Select Multiple Items",placeholder:"Choose items...","add-label":"Add another"},null,8,["modelValue"]),e("p",null,C(f.value),1)]),e("div",fw,[w(ht,{modelValue:y.value,"onUpdate:modelValue":z[12]||(z[12]=P=>y.value=P),options:K,label:"Disabled Multiple Select",placeholder:"Cannot select...",disabled:""},null,8,["modelValue"])])]),e("div",hw,[z[27]||(z[27]=e("h2",{class:"text-xl font-bold mb-4"},"CheckboxInput Tests",-1)),e("div",gw,[w(It,{modelValue:b.value,"onUpdate:modelValue":z[13]||(z[13]=P=>b.value=P),label:"Basic Checkbox"},null,8,["modelValue"]),e("p",bw," Value: "+C(b.value),1)]),e("div",xw,[w(It,{modelValue:v.value,"onUpdate:modelValue":z[14]||(z[14]=P=>v.value=P),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",yw," Value: "+C(v.value),1)]),e("div",kw,[w(It,{modelValue:d.value,"onUpdate:modelValue":z[15]||(z[15]=P=>d.value=P),label:"Disabled Checkbox",helpText:"This checkbox is disabled and cannot be changed.",disabled:""},null,8,["modelValue"])]),e("div",ww,[w(It,{modelValue:k.value,"onUpdate:modelValue":z[16]||(z[16]=P=>k.value=P),label:"Checkbox with Error",error:"You must accept the terms and conditions",required:""},null,8,["modelValue"])])]),e("div",_w,[z[29]||(z[29]=e("h2",{class:"text-xl font-bold mb-4"},"JSONSchemaInput Tests",-1)),e("div",$w,[(r(),H(qr,{key:_.value,modelValue:g.value,"onUpdate:modelValue":z[17]||(z[17]=P=>g.value=P),label:"JSON Schema Builder"},null,8,["modelValue"])),e("div",Cw,[z[28]||(z[28]=e("p",{class:"text-sm font-mono mb-2"},"Generated Schema:",-1)),e("pre",Sw,C(JSON.stringify(g.value,null,2)),1)])])])]))}}),Iw={class:"relative"},zw=["value","placeholder","rows"],Vw={class:"bg-white dark:bg-black rounded-lg"},Mw={class:"px-3 py-2 border-b border-black dark:border-neutral-300"},Ew={class:"text-xs font-medium text-neutral-600 dark:text-neutral-400"},Lw={key:0,class:"max-h-[200px] overflow-y-auto"},Pw=["onClick"],Aw={class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},jw={class:"flex-1"},Dw={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-0.5"},Ow={key:1,class:"px-3 py-4 text-sm text-neutral-500 dark:text-neutral-400 text-center"},Rw=me({__name:"ReferenceInput",props:{modelValue:{},search:{type:Function},placeholder:{},rows:{}},emits:["update:modelValue"],setup(t,{emit:o}){const a=t,i=o,l=p(null),u=p(null),s=p(!1),m=p(""),h=p([]),x=p(0),c=p(-1),f=p(-1),y=p(0),b=p({top:0,left:0}),v=async P=>{const G=P.target,ee=G.value,se=G.selectionStart;i("update:modelValue",ee),ee[se-1]==="@"&&!s.value?d(se):s.value&&await g(ee,se)},d=async P=>{c.value=P-1,f.value=P,m.value="",y.value=0,s.value=!0,x.value=0,await k(),await _("")},k=async()=>{if(!l.value)return;await Le();const P=l.value.getBoundingClientRect(),G=window.getComputedStyle(l.value),ee=parseInt(G.lineHeight||"20"),se=parseInt(G.paddingTop||"8"),Q=a.modelValue.substring(0,f.value).split(`
57
+ `),E=Q.length,S=Q[Q.length-1],re=Math.min(S.length*8,200);b.value={top:P.top+se+E*ee+4,left:P.left+se+re}},g=async(P,G)=>{if(G<=c.value){R();return}const ee=c.value+1,se=P.substring(ee,G);if(h.value.length===0?y.value++:y.value=0,h.value.length===0&&y.value>=5){R();return}m.value=se,await _(se)},_=async P=>{if(!a.search){h.value=[];return}const G=await a.search(P);h.value=Array.isArray(G)?G:[],x.value>=h.value.length&&(x.value=0)},L=P=>{if(!l.value)return;const G=a.modelValue,ee=G.substring(0,c.value),se=G.substring(f.value+m.value.length),de=`@${P.value}`,Q=ee+de+se;i("update:modelValue",Q),Le(()=>{if(!l.value)return;const E=ee.length+de.length;l.value.focus(),l.value.setSelectionRange(E,E)}),R()},R=()=>{s.value=!1,m.value="",h.value=[],x.value=0,c.value=-1,f.value=-1,y.value=0},K=P=>{if(s.value)switch(P.key){case"Escape":P.preventDefault(),R();break;case"ArrowDown":P.preventDefault(),x.value=Math.min(x.value+1,h.value.length-1);break;case"ArrowUp":P.preventDefault(),x.value=Math.max(x.value-1,0);break;case"Enter":h.value.length>0&&(P.preventDefault(),L(h.value[x.value]));break;case"Tab":h.value.length>0&&(P.preventDefault(),L(h.value[x.value]));break}},Y=()=>{if(!s.value||!l.value)return;l.value.selectionStart<=c.value&&R()},z=P=>{if(!u.value||!s.value)return;const G=P.target;!u.value.contains(G)&&G!==l.value&&R()};return ge(s,P=>{P?document.addEventListener("click",z):document.removeEventListener("click",z)}),(P,G)=>(r(),n("div",Iw,[e("textarea",{ref_key:"textarea",ref:l,value:t.modelValue,onInput:v,onKeydown:K,onSelect:Y,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,zw),(r(),H(kt,{to:"body"},[s.value?(r(),n("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:`${b.value.top}px`,left:`${b.value.left}px`,boxShadow:"4px 4px 0 0 rgba(0, 0, 0, 0.25)",backgroundImage:`
27
58
  repeating-linear-gradient(
28
59
  45deg,
29
60
  transparent,
@@ -31,18 +62,18 @@ Line 3`),u=v(""),r=v(""),c=v("option2"),f=v(""),g=v(""),d=v(""),p=v([]),h=v(["te
31
62
  rgba(0, 0, 0, 0.03) 2px,
32
63
  rgba(0, 0, 0, 0.03) 4px
33
64
  )
34
- `})},[e("div",rx,[e("div",ix,[e("div",dx," Search: "+S(c.value||"..."),1)]),f.value.length>0?(a(),o("div",ux,[(a(!0),o(ve,null,ke(f.value,(oe,te)=>(a(),o("button",{key:`${oe.type}-${oe.value}`,onClick:H=>D(oe),class:ae(["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":te===g.value}])},[e("span",px,S(oe.type),1),e("div",mx,[e("div",null,S(oe.label),1),oe.description?(a(),o("div",vx,S(oe.description),1)):V("",!0)])],10,cx))),128))])):(a(),o("div",fx," No results found ")),K[0]||(K[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)):V("",!0)]))]))}}),gx={class:"min-h-screen bg-white dark:bg-black p-8"},bx={class:"max-w-4xl mx-auto space-y-8"},xx={class:"space-y-4"},yx={class:"block"},kx={class:"p-4 border border-neutral-300 dark:border-neutral-700 rounded"},wx={class:"text-sm font-mono whitespace-pre-wrap"},_x=me({__name:"TestReferenceInput",setup(t){const n=v("Hello, type @ to see search suggestions"),s=async i=>{await new Promise(u=>setTimeout(u,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 i?l.filter(u=>u.label.toLowerCase().includes(i.toLowerCase())):l};return(i,l)=>(a(),o("div",gx,[e("div",bx,[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",xx,[e("label",yx,[l[1]||(l[1]=e("span",{class:"text-sm font-medium mb-2 block"},"Test Reference Input",-1)),A(hx,{modelValue:n.value,"onUpdate:modelValue":l[0]||(l[0]=u=>n.value=u),search:s,placeholder:"Type @ to insert references...",rows:10},null,8,["modelValue"])]),e("div",kx,[l[2]||(l[2]=e("h3",{class:"text-sm font-medium mb-2"},"Current Value:",-1)),e("pre",wx,S(n.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))])])]))}}),$x={class:"p-8 space-y-8"},Cx={class:"space-y-2 mb-4"},Tx={class:"mt-4 p-2 bg-neutral-100 rounded"},Sx=me({__name:"DebugView",setup(t){const n=v([{id:"1",name:"Item 1"}]),s=()=>{console.log("Adding item...");const u={id:crypto.randomUUID(),name:`Item ${n.value.length+1}`};n.value.push(u),console.log("Item added, total:",n.value.length)};fe(n,()=>{console.log("Items changed:",n.value.length)},{deep:!0});const i={props:["modelValue"],emits:["update:modelValue"],template:`
65
+ `})},[e("div",Vw,[e("div",Mw,[e("div",Ew," Search: "+C(m.value||"..."),1)]),h.value.length>0?(r(),n("div",Lw,[(r(!0),n(ve,null,ye(h.value,(ee,se)=>(r(),n("button",{key:`${ee.type}-${ee.value}`,onClick:de=>L(ee),class:ae(["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":se===x.value}])},[e("span",Aw,C(ee.type),1),e("div",jw,[e("div",null,C(ee.label),1),ee.description?(r(),n("div",Dw,C(ee.description),1)):I("",!0)])],10,Pw))),128))])):(r(),n("div",Ow," No results found ")),G[0]||(G[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)):I("",!0)]))]))}}),Uw={class:"min-h-screen bg-white dark:bg-black p-8"},Bw={class:"max-w-4xl mx-auto space-y-8"},Fw={class:"space-y-4"},Nw={class:"block"},qw={class:"p-4 border border-neutral-300 dark:border-neutral-700 rounded"},Hw={class:"text-sm font-mono whitespace-pre-wrap"},Ww=me({__name:"TestReferenceInput",setup(t){const o=p("Hello, type @ to see search suggestions"),a=async i=>{await new Promise(u=>setTimeout(u,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 i?l.filter(u=>u.label.toLowerCase().includes(i.toLowerCase())):l};return(i,l)=>(r(),n("div",Uw,[e("div",Bw,[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",Fw,[e("label",Nw,[l[1]||(l[1]=e("span",{class:"text-sm font-medium mb-2 block"},"Test Reference Input",-1)),w(Rw,{modelValue:o.value,"onUpdate:modelValue":l[0]||(l[0]=u=>o.value=u),search:a,placeholder:"Type @ to insert references...",rows:10},null,8,["modelValue"])]),e("div",qw,[l[2]||(l[2]=e("h3",{class:"text-sm font-medium mb-2"},"Current Value:",-1)),e("pre",Hw,C(o.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))])])]))}}),Kw={class:"p-8 space-y-8"},Jw={class:"space-y-2 mb-4"},Yw={class:"mt-4 p-2 bg-neutral-100 rounded"},Gw=me({__name:"DebugView",setup(t){const o=p([{id:"1",name:"Item 1"}]),a=()=>{console.log("Adding item...");const u={id:crypto.randomUUID(),name:`Item ${o.value.length+1}`};o.value.push(u),console.log("Item added, total:",o.value.length)};ge(o,()=>{console.log("Items changed:",o.value.length)},{deep:!0});const i={props:["modelValue"],emits:["update:modelValue"],template:`
35
66
  <div>
36
67
  <div v-for="item in modelValue" :key="item.id">
37
68
  {{ item.name }}
38
69
  </div>
39
70
  <button @click="addChild">Add in Child</button>
40
71
  </div>
41
- `,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])}}}},l=v([{id:"1",name:"Parent Item 1"}]);return(u,r)=>(a(),o("div",$x,[e("div",null,[r[1]||(r[1]=e("h2",{class:"text-xl font-bold mb-4"},"Direct Array Test",-1)),e("div",Cx,[(a(!0),o(ve,null,ke(n.value,c=>(a(),o("div",{key:c.id,class:"p-2 border"},S(c.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)),A(i,{modelValue:l.value,"onUpdate:modelValue":r[0]||(r[0]=c=>l.value=c)},null,8,["modelValue"]),e("pre",Tx,S(JSON.stringify(l.value,null,2)),1)])]))}}),Vx={class:"min-h-screen bg-white dark:bg-black p-8"},Mx={class:"max-w-4xl mx-auto"},Ix={class:"space-y-8"},Ex={class:"space-y-4"},Lx={class:"space-y-4"},Ax={class:"p-4 bg-neutral-100 dark:bg-neutral-900 rounded-lg"},Px={class:"text-sm text-black dark:text-white"},Dx=me({__name:"TestPromptInput",setup(t){const n=v([{type:"string",value:""}]),s=r=>{n.value=r};Me(()=>{window.setPromptSegments=s}),oo(()=>{delete window.setPromptSegments});const i=async r=>{await new Promise(g=>setTimeout(g,300));const c=(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(g=>(g.label||g.id||g.value||"").toLowerCase().includes(c)).slice(0,8)},l=r=>{n.value=r,console.log("Updated:",r)},u=(r,c)=>{console.log("Segment clicked:",r),r.type==="prompt"?alert(`Prompt clicked: ${r.label||r.id}
72
+ `,setup(u,{emit:s}){return{addChild:()=>{console.log("Child adding item...");const h={id:crypto.randomUUID(),name:`Child Item ${u.modelValue.length+1}`};s("update:modelValue",[...u.modelValue,h])}}}},l=p([{id:"1",name:"Parent Item 1"}]);return(u,s)=>(r(),n("div",Kw,[e("div",null,[s[1]||(s[1]=e("h2",{class:"text-xl font-bold mb-4"},"Direct Array Test",-1)),e("div",Jw,[(r(!0),n(ve,null,ye(o.value,m=>(r(),n("div",{key:m.id,class:"p-2 border"},C(m.name),1))),128))]),e("button",{onClick:a,class:"px-4 py-2 bg-black text-white rounded"}," Add Item ")]),e("div",null,[s[2]||(s[2]=e("h2",{class:"text-xl font-bold mb-4"},"Parent-Child Test",-1)),w(i,{modelValue:l.value,"onUpdate:modelValue":s[0]||(s[0]=m=>l.value=m)},null,8,["modelValue"]),e("pre",Yw,C(JSON.stringify(l.value,null,2)),1)])]))}}),Zw={class:"min-h-screen bg-white dark:bg-black p-8"},Xw={class:"max-w-4xl mx-auto"},Qw={class:"space-y-8"},e4={class:"space-y-4"},t4={class:"space-y-4"},r4={class:"p-4 bg-neutral-100 dark:bg-neutral-900 rounded-lg"},a4={class:"text-sm text-black dark:text-white"},o4=me({__name:"TestPromptInput",setup(t){const o=p([{type:"string",value:""}]),a=s=>{o.value=s};Pe(()=>{window.setPromptSegments=a}),Vr(()=>{delete window.setPromptSegments});const i=async s=>{await new Promise(x=>setTimeout(x,300));const m=(s||"").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(x=>(x.label||x.id||x.value||"").toLowerCase().includes(m)).slice(0,8)},l=s=>{o.value=s,console.log("Updated:",s)},u=(s,m)=>{console.log("Segment clicked:",s),s.type==="prompt"?alert(`Prompt clicked: ${s.label||s.id}
42
73
 
43
74
  In a real app, this could:
44
75
  - Show a modal with prompt details
45
76
  - Expand inline to show the full prompt
46
- - Navigate to the prompt editor`):r.type==="variable"&&alert(`Variable clicked: ${r.label||r.value}
77
+ - Navigate to the prompt editor`):s.type==="variable"&&alert(`Variable clicked: ${s.label||s.value}
47
78
 
48
- Description: ${r.meta?.description||"No description"}`)};return(r,c)=>(a(),o("div",Vx,[e("div",Mx,[c[5]||(c[5]=e("h1",{class:"text-3xl font-bold mb-8 text-black dark:text-white"}," PromptInput Component Test ",-1)),e("div",Ix,[e("div",Ex,[c[0]||(c[0]=e("h2",{class:"text-xl font-semibold text-black dark:text-white"}," Basic Usage ",-1)),c[1]||(c[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,[A($a,{"model-value":n.value,search:i,placeholder:"Type @ to insert variables or prompts...","onUpdate:modelValue":l,onSegmentClick:u},null,8,["model-value"])])]),e("div",Lx,[c[3]||(c[3]=e("h2",{class:"text-xl font-semibold text-black dark:text-white"}," Current Value ",-1)),e("div",Ax,[c[2]||(c[2]=e("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300 mb-2"}," Segments (value): ",-1)),e("pre",Px,S(JSON.stringify(n.value,null,2)),1)])]),c[4]||(c[4]=lo('<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))])])]))}}),jx={class:"relative"},Ox={key:0,class:"mt-1 text-sm text-red-500"},Ux=me({__name:"JsonEditor",props:{modelValue:{},placeholder:{},error:{},rows:{},readonly:{type:Boolean}},emits:["update:modelValue","blur"],setup(t,{emit:n}){self.MonacoEnvironment={getWorker(_,b){return b==="json"?new uo:new co}};const s=t,i=n,l=v(null);let u=null,r=!1;const c=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}},g=()=>{if(!(!u||s.readonly))try{const _=u.getValue(),b=JSON.parse(_),m=JSON.stringify(b,null,2);m!==_&&(r=!0,u.setValue(m),r=!1)}catch{}},d=()=>{c.value=document.documentElement.classList.contains("dark"),u&&Dt.setTheme(c.value?"vs-dark":"vs")},p=()=>{l.value&&(u=Dt.create(l.value,{value:s.modelValue||"{}",language:"json",theme:c.value?"vs-dark":"vs",...f})(l.value).__monacoEditor=u,u.onDidChangeModelContent(()=>{if(!r){const _=u.getValue();i("update:modelValue",_)}}),u.onDidBlurEditorText(()=>{i("blur"),g()}))};Me(async()=>{d(),await Te(),p();const _=new MutationObserver(d);_.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),Be(()=>{_.disconnect(),u&&u.dispose()})}),fe(()=>s.modelValue,_=>{u&&u.getValue()!==_&&(r=!0,u.setValue(_||""),r=!1)}),fe(()=>s.readonly,_=>{u&&u.updateOptions({readOnly:_})});const h=s.rows?`${s.rows*1.5}rem`:"18rem";return(_,b)=>(a(),o("div",jx,[e("div",{class:ae(["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:ot({height:X(h)})},null,4)],2),t.error?(a(),o("div",Ox,S(t.error),1)):V("",!0)]))}}),Kt=tt(Ux,[["__scopeId","data-v-1393c576"]]),Rx={class:"p-8"},Nx={class:"space-y-4"},Fx={class:"space-y-4"},Bx={class:"space-y-4"},qx=me({__name:"TestJsonEditorModal",setup(t){const n=v(!1),s=v(JSON.stringify({name:"Test",value:123},null,2)),i=v(!1),l=v(JSON.stringify({editable:!0,count:0},null,2));return(u,r)=>(a(),o("div",Rx,[r[13]||(r[13]=e("h1",{class:"text-3xl font-bold mb-6"},"JsonEditor in Modal Test",-1)),e("div",Nx,[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]=c=>n.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]=c=>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 Editable Modal ")])]),A(He,{modelValue:n.value,"onUpdate:modelValue":r[3]||(r[3]=c=>n.value=c),title:"Read-only JSON Schema",width:"max-w-4xl"},{footer:be(()=>[e("button",{onClick:r[2]||(r[2]=c=>n.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:be(()=>[e("div",Fx,[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)),A(Kt,{"model-value":s.value,readonly:!0},null,8,["model-value"])])]),_:1},8,["modelValue"]),A(He,{modelValue:i.value,"onUpdate:modelValue":r[6]||(r[6]=c=>i.value=c),title:"Editable JSON Schema",width:"max-w-4xl"},{footer:be(()=>[e("button",{onClick:r[5]||(r[5]=c=>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:be(()=>[e("div",Bx,[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)),A(Kt,{modelValue:l.value,"onUpdate:modelValue":r[4]||(r[4]=c=>l.value=c)},null,8,["modelValue"])])]),_:1},8,["modelValue"])]))}}),zx={class:"p-8 max-w-2xl mx-auto"},Hx={class:"mb-6"},Wx={class:"p-4 bg-neutral-100 dark:bg-neutral-800 rounded font-mono text-sm"},Jx={key:0},Kx={class:"whitespace-pre-wrap"},Gx={key:1,class:"text-neutral-500"},Xx={class:"mb-6"},Yx={class:"space-y-2"},Qx={class:"mt-6"},Zx={class:"p-4 bg-green-50 dark:bg-green-900 rounded min-h-[100px]"},ey={key:0,class:"font-mono"},ty={key:1,class:"text-neutral-500"},ay="10000000-0000-0000-0000-000000000101",Gt="10000000-0000-0000-0000-000000000102",oy=me({__name:"TestPromptInterpolation",setup(t){const n=v([]),s=v(null),i=v(null),l=v(""),u=v("Alice Johnson"),r=v("alice@example.com"),c=v("28"),{data:f,error:g}=Ue(ue(`/api/prompts/${ay}`)).json(),{data:d,error:p}=Ue(ue(`/api/prompts/${Gt}`)).json();fe(f,b=>{if(b){s.value=b;try{n.value=JSON.parse(b.prompt)}catch(m){console.error("Failed to parse prompt A:",m)}}},{immediate:!0}),fe(d,b=>{b&&(i.value=b)},{immediate:!0});function h(b,m){return b.map(y=>{if(y.type==="string")return y.value||"";if(y.type==="variable"){const x=m[y.value];return x===void 0?`{{${y.value}}}`:typeof x=="string"?x:JSON.stringify(x)}else if(y.type==="prompt"){if(y.id===Gt&&i.value)try{const x=JSON.parse(i.value.prompt);return h(x,m)}catch{return`[Error loading prompt: ${y.label}]`}return""}return""}).join("")}function _(){const b={name:u.value,email:r.value,age:c.value};l.value=h(n.value,b)}return(b,m)=>(a(),o("div",zx,[m[11]||(m[11]=e("h1",{class:"text-2xl font-bold mb-6"},"Prompt Interpolation Test",-1)),e("div",Hx,[m[4]||(m[4]=e("h2",{class:"text-lg font-semibold mb-2"},"Prompt Template",-1)),e("div",Wx,[s.value?(a(),o("div",Jx,[m[3]||(m[3]=e("div",{class:"font-bold mb-2"},"Prompt A:",-1)),e("pre",Kx,S(JSON.stringify(n.value,null,2)),1)])):(a(),o("div",Gx,"Loading..."))])]),e("div",Xx,[m[8]||(m[8]=e("h2",{class:"text-lg font-semibold mb-2"},"Context Values",-1)),e("div",Yx,[e("div",null,[m[5]||(m[5]=e("label",{class:"block text-sm mb-1"},"Name:",-1)),Ie(e("input",{"onUpdate:modelValue":m[0]||(m[0]=y=>u.value=y),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[Oe,u.value]])]),e("div",null,[m[6]||(m[6]=e("label",{class:"block text-sm mb-1"},"Email:",-1)),Ie(e("input",{"onUpdate:modelValue":m[1]||(m[1]=y=>r.value=y),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)),Ie(e("input",{"onUpdate:modelValue":m[2]||(m[2]=y=>c.value=y),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[Oe,c.value]])])])]),e("button",{onClick:_,class:"px-4 py-2 bg-black text-white rounded hover:bg-neutral-800"}," Render Prompt "),e("div",Qx,[m[9]||(m[9]=e("h2",{class:"text-lg font-semibold mb-2"},"Rendered Output",-1)),e("div",Zx,[l.value?(a(),o("div",ey,S(l.value),1)):(a(),o("div",ty,' 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))])]))}}),Ta=so({history:no(dt()),routes:[{path:"/login",name:"login",component:V1,meta:{public:!0}},{path:"/",redirect:"/threads"},{path:"/agents",name:"agents",component:Mr},{path:"/threads",name:"threads",component:zt},{path:"/threads/:id",name:"thread-detail",component:zt},{path:"/prompts",name:"prompts",component:Wh},{path:"/prompts/:id",name:"prompt-edit",component:Xh},{path:"/models",name:"models",component:fb},{path:"/providers",name:"providers",component:Vb},{path:"/tools",name:"tools",component:n1},{path:"/settings/users",name:"users",component:u1},{path:"/settings/api-keys",name:"api-keys",component:x1},{path:"/test",name:"test",component:lx},{path:"/test-reference-input",name:"test-reference-input",component:_x},{path:"/debug",name:"debug",component:Sx},{path:"/test-prompt-input",name:"test-prompt-input",component:Dx},{path:"/test-json-editor-modal",name:"test-json-editor-modal",component:qx},{path:"/test-prompt-interpolation",name:"test-prompt-interpolation",component:oy}]});Ta.beforeEach(async(t,n,s)=>{const i=t.meta.public===!0,l=localStorage.getItem("auth_token");!i&&!l?s({name:"login"}):i&&l&&t.name==="login"?s({name:"threads"}):s()});const ly=window.fetch;window.fetch=async function(t,n){const s=typeof t=="string"?t:t instanceof URL?t.toString():t.url,i=dt(),l=i==="/"?"/api/":`${i}/api/`,u=s.includes(l)||i==="/"&&s.startsWith("/api/");if(u){const f=localStorage.getItem("auth_token");f&&n?n.headers={...n.headers,Authorization:`Bearer ${f}`}:f&&(n={...n,headers:{Authorization:`Bearer ${f}`}})}const r=await ly(t,n),c=s.includes("/api/auth/");return r.status===401&&u&&!c&&(localStorage.removeItem("auth_token"),window.location.href=ue("/login")),r};const Mt=ro(ss);Mt.use(yo,{endpoint:ue("/api")});Mt.use(Ta);Mt.mount("#app");
79
+ Description: ${s.meta?.description||"No description"}`)};return(s,m)=>(r(),n("div",Zw,[e("div",Xw,[m[5]||(m[5]=e("h1",{class:"text-3xl font-bold mb-8 text-black dark:text-white"}," PromptInput Component Test ",-1)),e("div",Qw,[e("div",e4,[m[0]||(m[0]=e("h2",{class:"text-xl font-semibold text-black dark:text-white"}," Basic Usage ",-1)),m[1]||(m[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,[w(Gt,{"model-value":o.value,search:i,placeholder:"Type @ to insert variables or prompts...","onUpdate:modelValue":l,onSegmentClick:u},null,8,["model-value"])])]),e("div",t4,[m[3]||(m[3]=e("h2",{class:"text-xl font-semibold text-black dark:text-white"}," Current Value ",-1)),e("div",r4,[m[2]||(m[2]=e("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300 mb-2"}," Segments (value): ",-1)),e("pre",a4,C(JSON.stringify(o.value,null,2)),1)])]),m[4]||(m[4]=Ja('<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))])])]))}}),n4={class:"relative"},l4={key:0,class:"mt-1 text-sm text-red-500"},s4=me({__name:"JsonEditor",props:{modelValue:{},placeholder:{},error:{},rows:{},readonly:{type:Boolean}},emits:["update:modelValue","blur"],setup(t,{emit:o}){self.MonacoEnvironment={getWorker(b,v){return v==="json"?new oo:new no}};const a=t,i=o,l=p(null);let u=null,s=!1;const m=p(!1),h={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:a.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}},x=()=>{if(!(!u||a.readonly))try{const b=u.getValue(),v=JSON.parse(b),d=JSON.stringify(v,null,2);d!==b&&(s=!0,u.setValue(d),s=!1)}catch{}},c=()=>{m.value=document.documentElement.classList.contains("dark"),u&&or.setTheme(m.value?"vs-dark":"vs")},f=()=>{l.value&&(u=or.create(l.value,{value:a.modelValue||"{}",language:"json",theme:m.value?"vs-dark":"vs",...h})(l.value).__monacoEditor=u,u.onDidChangeModelContent(()=>{if(!s){const b=u.getValue();i("update:modelValue",b)}}),u.onDidBlurEditorText(()=>{i("blur"),x()}))};Pe(async()=>{c(),await Le(),f();const b=new MutationObserver(c);b.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),Ye(()=>{b.disconnect(),u&&u.dispose()})}),ge(()=>a.modelValue,b=>{u&&u.getValue()!==b&&(s=!0,u.setValue(b||""),s=!1)}),ge(()=>a.readonly,b=>{u&&u.updateOptions({readOnly:b})});const y=a.rows?`${a.rows*1.5}rem`:"18rem";return(b,v)=>(r(),n("div",n4,[e("div",{class:ae(["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:st({height:T(y)})},null,4)],2),t.error?(r(),n("div",l4,C(t.error),1)):I("",!0)]))}}),wr=Xe(s4,[["__scopeId","data-v-1393c576"]]),i4={class:"p-8"},u4={class:"space-y-4"},d4={class:"space-y-4"},c4={class:"space-y-4"},p4=me({__name:"TestJsonEditorModal",setup(t){const o=p(!1),a=p(JSON.stringify({name:"Test",value:123},null,2)),i=p(!1),l=p(JSON.stringify({editable:!0,count:0},null,2));return(u,s)=>(r(),n("div",i4,[s[13]||(s[13]=e("h1",{class:"text-3xl font-bold mb-6"},"JsonEditor in Modal Test",-1)),e("div",u4,[e("div",null,[s[7]||(s[7]=e("h2",{class:"text-xl font-semibold mb-2"}," Read-only JsonEditor in Modal ",-1)),s[8]||(s[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:s[0]||(s[0]=m=>o.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,[s[9]||(s[9]=e("h2",{class:"text-xl font-semibold mb-2"},"Editable JsonEditor in Modal",-1)),s[10]||(s[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:s[1]||(s[1]=m=>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 Editable Modal ")])]),w(He,{modelValue:o.value,"onUpdate:modelValue":s[3]||(s[3]=m=>o.value=m),title:"Read-only JSON Schema",width:"max-w-4xl"},{footer:D(()=>[e("button",{onClick:s[2]||(s[2]=m=>o.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:D(()=>[e("div",d4,[s[11]||(s[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)),w(wr,{"model-value":a.value,readonly:!0},null,8,["model-value"])])]),_:1},8,["modelValue"]),w(He,{modelValue:i.value,"onUpdate:modelValue":s[6]||(s[6]=m=>i.value=m),title:"Editable JSON Schema",width:"max-w-4xl"},{footer:D(()=>[e("button",{onClick:s[5]||(s[5]=m=>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:D(()=>[e("div",c4,[s[12]||(s[12]=e("p",{class:"text-sm text-neutral-600 dark:text-neutral-400"}," This is an editable JSON editor. Changes will be tracked. ",-1)),w(wr,{modelValue:l.value,"onUpdate:modelValue":s[4]||(s[4]=m=>l.value=m)},null,8,["modelValue"])])]),_:1},8,["modelValue"])]))}}),m4={class:"p-8 max-w-2xl mx-auto"},v4={class:"mb-6"},f4={class:"p-4 bg-neutral-100 dark:bg-neutral-800 rounded font-mono text-sm"},h4={key:0},g4={class:"whitespace-pre-wrap"},b4={key:1,class:"text-neutral-500"},x4={class:"mb-6"},y4={class:"space-y-2"},k4={class:"mt-6"},w4={class:"p-4 bg-green-50 dark:bg-green-900 rounded min-h-[100px]"},_4={key:0,class:"font-mono"},$4={key:1,class:"text-neutral-500"},C4="10000000-0000-0000-0000-000000000101",_r="10000000-0000-0000-0000-000000000102",S4=me({__name:"TestPromptInterpolation",setup(t){const o=p([]),a=p(null),i=p(null),l=p(""),u=p("Alice Johnson"),s=p("alice@example.com"),m=p("28"),{data:h,error:x}=Ne(fe(`/api/prompts/${C4}`)).json(),{data:c,error:f}=Ne(fe(`/api/prompts/${_r}`)).json();ge(h,v=>{if(v){a.value=v;try{o.value=JSON.parse(v.prompt)}catch(d){console.error("Failed to parse prompt A:",d)}}},{immediate:!0}),ge(c,v=>{v&&(i.value=v)},{immediate:!0});function y(v,d){return v.map(k=>{if(k.type==="string")return k.value||"";if(k.type==="variable"){const g=d[k.value];return g===void 0?`{{${k.value}}}`:typeof g=="string"?g:JSON.stringify(g)}else if(k.type==="prompt"){if(k.id===_r&&i.value)try{const g=JSON.parse(i.value.prompt);return y(g,d)}catch{return`[Error loading prompt: ${k.label}]`}return""}return""}).join("")}function b(){const v={name:u.value,email:s.value,age:m.value};l.value=y(o.value,v)}return(v,d)=>(r(),n("div",m4,[d[11]||(d[11]=e("h1",{class:"text-2xl font-bold mb-6"},"Prompt Interpolation Test",-1)),e("div",v4,[d[4]||(d[4]=e("h2",{class:"text-lg font-semibold mb-2"},"Prompt Template",-1)),e("div",f4,[a.value?(r(),n("div",h4,[d[3]||(d[3]=e("div",{class:"font-bold mb-2"},"Prompt A:",-1)),e("pre",g4,C(JSON.stringify(o.value,null,2)),1)])):(r(),n("div",b4,"Loading..."))])]),e("div",x4,[d[8]||(d[8]=e("h2",{class:"text-lg font-semibold mb-2"},"Context Values",-1)),e("div",y4,[e("div",null,[d[5]||(d[5]=e("label",{class:"block text-sm mb-1"},"Name:",-1)),Ae(e("input",{"onUpdate:modelValue":d[0]||(d[0]=k=>u.value=k),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[Qe,u.value]])]),e("div",null,[d[6]||(d[6]=e("label",{class:"block text-sm mb-1"},"Email:",-1)),Ae(e("input",{"onUpdate:modelValue":d[1]||(d[1]=k=>s.value=k),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[Qe,s.value]])]),e("div",null,[d[7]||(d[7]=e("label",{class:"block text-sm mb-1"},"Age:",-1)),Ae(e("input",{"onUpdate:modelValue":d[2]||(d[2]=k=>m.value=k),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[Qe,m.value]])])])]),e("button",{onClick:b,class:"px-4 py-2 bg-black text-white rounded hover:bg-neutral-800"}," Render Prompt "),e("div",k4,[d[9]||(d[9]=e("h2",{class:"text-lg font-semibold mb-2"},"Rendered Output",-1)),e("div",w4,[l.value?(r(),n("div",_4,C(l.value),1)):(r(),n("div",$4,' Click "Render Prompt" to see output '))]),d[10]||(d[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))])]))}}),sa=Ya({history:Ga(_t()),routes:[{path:"/login",name:"login",component:J2,meta:{public:!0}},{path:"/",redirect:"/threads"},{path:"/agents",name:"agents",component:ym},{path:"/threads",name:"threads",component:hr},{path:"/threads/:id",name:"thread-detail",component:hr},{path:"/prompts",name:"prompts",component:Fy},{path:"/prompts/:id",name:"prompt-edit",component:Wy},{path:"/models",name:"models",component:Uk},{path:"/providers",name:"providers",component:l2},{path:"/tools",name:"tools",component:T2},{path:"/settings/users",name:"users",component:E2},{path:"/settings/api-keys",name:"api-keys",component:O2},{path:"/test",name:"test",component:Tw},{path:"/test-reference-input",name:"test-reference-input",component:Ww},{path:"/debug",name:"debug",component:Gw},{path:"/test-prompt-input",name:"test-prompt-input",component:o4},{path:"/test-json-editor-modal",name:"test-json-editor-modal",component:p4},{path:"/test-prompt-interpolation",name:"test-prompt-interpolation",component:S4}]});sa.beforeEach(async(t,o,a)=>{const i=t.meta.public===!0,l=localStorage.getItem("auth_token");!i&&!l?a({name:"login"}):i&&l&&t.name==="login"?a({name:"threads"}):a()});const T4=window.fetch;window.fetch=async function(t,o){const a=typeof t=="string"?t:t instanceof URL?t.toString():t.url,i=_t(),l=i==="/"?"/api/":`${i}/api/`,u=a.includes(l)||i==="/"&&a.startsWith("/api/");if(u){const h=localStorage.getItem("auth_token");h&&o?o.headers={...o.headers,Authorization:`Bearer ${h}`}:h&&(o={...o,headers:{Authorization:`Bearer ${h}`}})}const s=await T4(t,o),m=a.includes("/api/auth/");return s.status===401&&u&&!m&&(localStorage.removeItem("auth_token"),window.location.href=fe("/login")),s};const Dt=Za(Ju);Dt.use(fo,{endpoint:fe("/api")});Dt.use(Xa,Qa(bi));Dt.use(sa);Dt.mount("#app");