granclaw 0.0.1-beta.102 → 0.0.1-beta.103

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.
@@ -87,7 +87,7 @@ Esto eliminará permanentemente:
87
87
  • Memoria de sesión de Claude
88
88
  • Archivos del espacio de trabajo
89
89
 
90
- Esta acción no se puede deshacer.`,guardian:"Guardián",comingSoon:"Próximamente",guardianBlurb1:"Configura un agente guardián para controlar lo que puede hacer tu agente principal.",guardianBlurb2:"Define restricciones, bloquea acciones y exige aprobación antes de operaciones sensibles.",guardianChatBlurb:"Chat del guardián.<br />Configura restricciones aquí.",guardianDisconnected:"○ desconectado",errorCreditLimit:"La clave API ha alcanzado su límite de gasto. Recarga créditos o aumenta el límite de la clave en el panel de tu proveedor.",errorRateLimit:"Límite de solicitudes excedido. El proveedor está limitando las peticiones — intenta de nuevo en unos segundos.",errorAuth:"Autenticación fallida. La clave API puede ser inválida o estar expirada — revisa Configuración.",errorNoProvider:"Sin proveedor configurado. Ve a Configuración para agregar uno.",errorNoKey:"Falta la clave API del proveedor. Ve a Configuración para reconfigurar.",errorTimeout:"El agente tardó demasiado en responder. Intenta de nuevo o simplifica tu solicitud.",errorGeneric:"Algo salió mal: {message}"},NM={sessionExpiredLabel:"toma de control",sessionExpired:"Sesión expirada",sessionExpiredBlurb:"Este enlace de toma de control ya fue usado o expiró.",completeLabel:"completo",controlReturned:"Control devuelto al agente",closeTab:"Puedes cerrar esta pestaña.",connecting:"conectando…",agentNeedsHelp:"El agente necesita tu ayuda",liveLabel:"en vivo",waitingStream:"esperando transmisión del navegador…",browserStarting:"iniciando el navegador — la transmisión comenzará cuando cargue una página",browserNotReady:"el navegador está entre páginas — esperando la próxima navegación",whatDidYouDo:"¿Qué hiciste?",optional:"(opcional)",describeActionPlaceholder:"Describe tu acción para el agente…",returning:"Devolviendo…",completed:"Completado",urlBarPlaceholder:"Escribe una URL y pulsa Intro para navegar…"},jM={title:"Habilidades",subtitle:"Habilidades que tu agente puede invocar. Las habilidades invocables por el usuario se pueden activar desde el chat con /barra-comando.",empty:"No hay habilidades instaladas todavía. Viven en .pi/skills/ dentro del workspace del agente.",loading:"Cargando habilidades…",selectSkill:"Selecciona una habilidad a la izquierda para ver su definición completa.",userInvocable:"invocable por usuario",allowedTools:"Herramientas permitidas",loadError:"No se pudo cargar la habilidad: {error}"},PM={editedBy:"editado por {name}",relativeNow:"ahora",relativeMinutes:"hace {n}m",relativeHours:"hace {n}h",relativeDays:"hace {n}d",titlePlaceholder:"Título de tarea…",descPlaceholder:"Descripción (markdown)…",add:"Agregar",cancel:"Cancelar",searchPlaceholder:"Buscar tareas…",clearAll:"Limpiar todo",clearConfirm:"¿Eliminar TODAS las tareas? No se puede deshacer.",columnLabelPlaceholder:"Nombre de columna…",deleteColumnConfirm:"¿Eliminar esta columna? Las tareas se moverán a la primera columna."},TM={saving:"guardando…",close:"Cerrar",status:"Estado",tags:"Etiquetas",addTag:"agregar…",sourceLabel:"fuente",editedByLabel:"editado por",created:"creado",updated:"actualizado",description:"Descripción",descPlaceholder:"Agregar una descripción…",save:"Guardar",cancel:"Cancelar",descEmpty:"Sin descripción — clic para agregar",commentsLabel:"Comentarios ({count})",noComments:"Sin comentarios aún",addComment:"Agregar comentario",commentPlaceholder:"Escribe un comentario… (markdown soportado)",publishComment:"Publicar comentario",publishing:"Publicando…",dangerZone:"Zona peligrosa",deleteTask:"[PELIGROSO] Eliminar tarea",deleting:"eliminando…",deleteConfirm:'¿Eliminar tarea "{title}"? Esta acción no se puede deshacer.'},MM={backToRuns:"← Volver a ejecuciones",loading:"Cargando…",waitingResponse:"Esperando respuesta…",triggering:"Iniciando…",runNow:"Ejecutar ahora",runHistory:"Historial de ejecuciones",noRuns:"Sin ejecuciones aún.",loadingList:"Cargando programados…",emptyIcon:"⏰",emptyText:"Sin programados aún. Pídele al agente que configure tareas recurrentes.",title:"Programados",activeCountOne:"{count} activo",activeCountOther:"{count} activos",next:"Próximo: {time}",last:"Último: {time}",pause:"Pausar",resume:"Reanudar",delete:"Eliminar",deleteConfirm:'¿Eliminar programado "{name}"?'},RM={title:"Flujos de trabajo",emptyText:"Sin flujos de trabajo aún. Pídele al agente que cree uno via chat.",running:"Ejecutando…",run:"Ejecutar",createdOn:"{id} · Creado {date}",back:"← Volver a flujos",run_button:"Ejecutar",stepsTitle:"Pasos ({count})",conditionsOne:"{count} condición",conditionsOther:"{count} condiciones",stepTimeout:"Límite de tiempo: {seconds}s",stepId:"ID: {id}",runHistoryTitle:"Historial de ejecuciones ({count})",noRuns:"Sin ejecuciones aún.",runStatus:{running:"en ejecución",completed:"completado",failed:"fallido",cancelled:"cancelado"},newWorkflow:"Nuevo flujo",editWorkflow:"Editar flujo",edit:"Editar",delete:"Eliminar",cancel:"Cancelar",save:"Guardar",saving:"Guardando…",addStep:"Añadir paso",addStepTitle:"Añadir paso",editStepTitle:"Editar paso",moveUp:"Subir",moveDown:"Bajar",noSteps:'Aún no hay pasos. Haz clic en "Añadir paso" para empezar.',confirmDelete:'¿Eliminar el flujo "{name}"? Esto no se puede deshacer.',confirmDeleteStep:'¿Eliminar el paso "{name}"?',formName:"Nombre",formNamePlaceholder:"Resumen diario de LinkedIn",formDescription:"Descripción",formDescriptionPlaceholder:"¿Qué hace este flujo?",formStatus:"Estado",stepNameLabel:"Nombre del paso",stepNamePlaceholder:"Recoger últimas publicaciones",stepTimeoutLabel:"Tiempo límite (segundos)",stepPromptLabel:"Prompt",stepPromptPlaceholder:"Resume la salida del paso anterior…"},DM={loading:"Cargando ejecución…",back:"← Volver al flujo",runLabel:"Ejecución —",errorPrefix:"Error:",input:"Entrada",output:"Salida",activity:"Actividad",cancel:"Cancelar ejecución",cancelling:"Cancelando…"},AM={loading:"Cargando monitor…",title:"Monitor",idle:"inactivo",claudeSessionsOne:"{count} sesión claude",claudeSessionsOther:"{count} sesiones claude",processes:"Procesos",agentProcess:"Proceso del Agente",guardianProcess:"Guardián (Big Brother)",browserDaemon:"Demonio de Navegador",activeClaudeSessions:"Sesiones Claude Activas — {count}",jobQueue:"Cola de trabajos — {processing} en proceso, {pending} en espera",noActiveJobs:"Sin trabajos activos",processing:"procesando",queued:"en cola",terminate:"Terminar",cancel:"Cancelar",runningWorkflows:"Flujos de trabajo en ejecución",cpu:"CPU",mem:"MEM",rss:"RSS",uptime:"Tiempo activo"},LM={title:"Integraciones",blurb:"Conecta servicios externos. Cada integración almacena un token como secreto y se activa automáticamente.",moreSoon:"Más integraciones próximamente. Para otras claves API y credenciales, usa la sección de Secretos en la barra lateral.",connected:"Conectado",disconnect:"Desconectar",connect:"Conectar",saveAndConnect:"Guardar y conectar",saving:"Guardando…",cancel:"Cancelar",newPrefix:"Nuevo {label}",pasteNewToken:"Pega el nuevo token",updateToken:"Actualizar token",rotateToken:"Rotar token",errorSave:"Error al guardar — revisa la consola",disconnectConfirm:"¿Desconectar {name}? El agente dejará de usarlo inmediatamente.",telegramDescription:"Recibe y responde mensajes a través de un bot de Telegram.",telegramHelp:"Crea un bot mediante @BotFather en Telegram, luego pega el token aquí.",telegramTokenLabel:"Token del bot"},IM={loading:"Escaneando sesiones…",title:"Uso",totalTokens:"Tokens totales",cachedSuffix:"{amount} en caché",sessions:"Sesiones",modelsCount:"{count} modelos",estCost:"Costo est.",periodDays:"Período de {days} días",avgDay:"Prom/Día",sessionsPerDay:"{count} sesiones/día",dailyTokenUsage:"Uso diario de tokens",noUsageData:"Sin datos de uso",dailyCost:"Costo estimado diario",noCostData:"Sin datos de costo",byModel:"Por modelo",modelSessionsBlurb:"{sessions} sesiones · {input} entrada · {output} salida",tokenBreakdown:"Desglose de tokens",inputTokens:"Tokens de entrada",outputTokens:"Tokens de salida",cacheRead:"Lectura de caché",cacheWrite:"Escritura de caché",toolInvocations:"Invocaciones de herramientas",dailyBreakdown:"Desglose diario",date:"Fecha",tableSessions:"Sesiones",tableInput:"Entrada",tableOutput:"Salida",tableCache:"Caché",tableCost:"Costo"},OM={searchPlaceholder:"Buscar registros…",apply:"Aplicar",live:"En vivo",loading:"cargando…",noResults:'sin resultados para "{query}"',noEntries:"sin entradas de registro",loadOlder:"Cargar {count} entradas anteriores…"},FM={views:{chat:"Chat",tasks:"Tareas",skills:"Habilidades",browser:"Navegador",files:"Archivos",workflows:"Flujos de trabajo",schedules:"Programados",monitor:"Monitor",usage:"Uso",logs:"Registros",integrations:"Integraciones",guardian:"Guardián"},comingSoon:"Pronto",secrets:"Secretos",noSecrets:"Sin secretos configurados",updating:"Actualizando {name}",newValue:"nuevo valor",save:"Guardar",secretNamePlaceholder:"NOMBRE",secretValuePlaceholder:"valor",guardrails:"Restricciones",guardrailsBlurb:"Configurado via chat guardián",exportAgent:"📦 Exportar agente",exportTitle:"Descargar una copia de seguridad completa del espacio de trabajo del agente como zip",wipeAgent:"🗑 Borrar agente",wiping:"borrando…"},$M={workspace:"espacio-de-trabajo",savingLabel:"guardando…",saveButton:"Guardar",emptyDir:"Directorio vacío"},zM={common:wM,shell:kM,dashboard:SM,settings:CM,chat:EM,takeover:NM,skillsView:jM,tasks:PM,taskDetail:TM,schedules:MM,workflows:RM,runDetail:DM,monitor:AM,integrations:LM,usage:IM,logs:OM,agentSettings:FM,files:$M},Oy={en:_M,es:zM},tS="granclaw:lang";function BM(){if(typeof window>"u")return"en";try{const t=window.localStorage.getItem(tS);if(t==="en"||t==="es")return t}catch{}return(typeof navigator<"u"?navigator.language:"").toLowerCase().startsWith("es")?"es":"en"}function Fy(e,t){const n=t.split(".");let r=e;for(const i of n)if(r&&typeof r=="object"&&i in r)r=r[i];else return;return typeof r=="string"?r:void 0}function WM(e,t){return t?e.replace(/\{(\w+)\}/g,(n,r)=>{const i=t[r];return i==null?`{${r}}`:String(i)}):e}const nS=E.createContext(null);function HM({children:e}){const[t,n]=E.useState(()=>BM()),r=E.useCallback(o=>{n(o);try{window.localStorage.setItem(tS,o)}catch{}},[]);E.useEffect(()=>{try{document.documentElement.lang=t}catch{}},[t]);const i=E.useCallback((o,a)=>{const l=Oy[t],c=Fy(l,o)??Fy(Oy.en,o)??o;return WM(c,a)},[t]),s=E.useMemo(()=>({lang:t,setLang:r,t:i}),[t,r,i]);return f.jsx(nS.Provider,{value:s,children:e})}function we(){const e=E.useContext(nS);if(!e)throw new Error("useT must be used inside <LanguageProvider>");return e}function VM({className:e}){const{lang:t,setLang:n}=we();return f.jsx("div",{className:`flex items-center gap-0.5 rounded-full bg-surface-container/40 p-[2px] ${e??""}`,children:["en","es"].map(r=>f.jsx("button",{onClick:()=>n(r),className:`px-2 py-[2px] rounded-full text-[10px] font-mono uppercase tracking-wider transition-colors ${t===r?"bg-primary/30 text-primary":"text-on-surface-variant/70 hover:text-on-surface"}`,"aria-pressed":t===r,children:r},r))})}function UM(){const e=ss(),t=os(),n=e.pathname.includes("/chat"),{t:r}=we();return f.jsxs("div",{className:"flex h-screen flex-col overflow-hidden bg-surface",children:[f.jsxs("header",{className:"flex h-11 flex-shrink-0 items-center justify-between border-b border-outline-variant/20 bg-surface-low px-3 sm:px-5",children:[f.jsxs("button",{onClick:()=>t("/dashboard"),className:"flex items-center gap-2 hover:opacity-80 transition-opacity min-w-0",children:[f.jsx("img",{src:"/granclaw-logo.png",alt:"GranClaw",className:"h-6 w-6 rounded flex-shrink-0"}),f.jsx("span",{className:"font-display font-semibold text-on-surface tracking-tight truncate",children:"GranClaw"}),f.jsxs("span",{className:"text-xs font-mono text-on-surface/60 flex-shrink-0",children:["v","0.0.1-beta.102"]})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f.jsx(VM,{}),f.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-secondary-container/20 px-2 sm:px-3 py-1 text-xs font-mono text-secondary flex-shrink-0",children:[f.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-secondary animate-pulse flex-shrink-0"}),f.jsx("span",{className:"hidden sm:inline",children:r("shell.systemPrefix")}),r("shell.onlineSuffix")]})]})]}),f.jsx("main",{className:`flex-1 overflow-auto min-w-0 ${n?"":"p-3 sm:p-5"}`,children:f.jsx(BP,{})})]})}const ie="";async function $y(){const e=await fetch(`${ie}/agents`);if(!e.ok)throw new Error(`fetchAgents: ${e.status}`);return e.json()}async function qM(e,t,n,r,i){const s=await fetch(`${ie}/agents`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,name:t,model:n,provider:r,...i?{workspaceDir:i}:{}})});if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Error(o.error)}}async function GM(e){const t=await fetch(`${ie}/agents/${e}`,{method:"DELETE"});if(!t.ok)throw new Error(`deleteAgent: ${t.status}`)}async function zy(e){const t=await fetch(`${ie}/agents/${e}`);if(!t.ok)throw new Error(`fetchAgent: ${t.status}`);return t.json()}async function By(e,t="ui"){const n=await fetch(`${ie}/agents/${e}/messages?channelId=${t}&sortBy=desc&limit=200`,{cache:"no-store"});if(!n.ok)throw new Error(`fetchMessages: ${n.status}`);return(await n.json()).reverse()}async function KM(e){const t=await fetch(`${ie}/agents/${e}/reset`,{method:"DELETE"});if(!t.ok)throw new Error(`resetAgent: ${t.status}`)}async function YM(e,t=""){const n=await fetch(`${ie}/agents/${e}/files?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`fetchFiles: ${n.status}`);return(await n.json()).entries}async function XM(e,t){const n=await fetch(`${ie}/agents/${e}/files/read?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`readFile: ${n.status}`);return(await n.json()).content}async function JM(e,t,n){const r=await fetch(`${ie}/agents/${e}/files/write?path=${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n})});if(!r.ok)throw new Error(`writeFile: ${r.status}`)}async function QM(e){const t=await fetch(`${ie}/agents/${e}/secrets`);if(!t.ok)throw new Error(`fetchSecrets: ${t.status}`);return t.json()}async function Rp(e,t,n){const r=await fetch(`${ie}/agents/${e}/secrets`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,value:n})});if(!r.ok)throw new Error(`addSecret: ${r.status}`)}async function rS(e,t){const n=await fetch(`${ie}/agents/${e}/secrets/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteSecret: ${n.status}`)}async function ZM(e){const t=await fetch(`${ie}/agents/${e}/skills`);if(!t.ok)throw new Error(`fetchSkills: ${t.status}`);return(await t.json()).skills}async function eR(e,t){const n=t.split("/").map(encodeURIComponent).join("/"),r=await fetch(`${ie}/agents/${e}/skills/${n}`);if(!r.ok)throw new Error(`fetchSkillDetail: ${r.status}`);return r.json()}async function tR(e,t){const n=new URLSearchParams,r=n.toString()?`?${n.toString()}`:"",i=await fetch(`${ie}/agents/${e}/tasks${r}`);if(!i.ok)throw new Error(`fetchTasks: ${i.status}`);return i.json()}async function nR(e,t){const n=await fetch(`${ie}/agents/${e}/tasks/${t}`);if(!n.ok)throw new Error(`fetchTask: ${n.status}`);return n.json()}async function rR(e,t){const n=await fetch(`${ie}/agents/${e}/tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`createTask: ${n.status}`);return n.json()}async function Wy(e,t,n){const r=await fetch(`${ie}/agents/${e}/tasks/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error(`updateTask: ${r.status}`);return r.json()}async function iR(e,t){const n=await fetch(`${ie}/agents/${e}/tasks/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteTask: ${n.status}`)}async function sR(e){const t=await fetch(`${ie}/agents/${e}/tasks`,{method:"DELETE"});if(!t.ok)throw new Error(`clearTasks: ${t.status}`);return t.json()}async function oR(e,t,n){const r=await fetch(`${ie}/agents/${e}/tasks/${t}/comments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:n})});if(!r.ok)throw new Error(`addTaskComment: ${r.status}`);return r.json()}async function aR(e){const t=await fetch(`${ie}/agents/${e}/task-columns`);if(!t.ok)throw new Error(`fetchColumns: ${t.status}`);return t.json()}async function lR(e,t){const n=await fetch(`${ie}/agents/${e}/task-columns`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({label:t})});if(!n.ok)throw new Error(`createColumn: ${n.status}`);return n.json()}async function cR(e,t){const n=await fetch(`${ie}/agents/${e}/task-columns/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteColumn: ${n.status}`)}async function uR(e){const t=await fetch(`${ie}/agents/${e}/browser-sessions`);if(!t.ok)throw new Error(`fetchBrowserSessions: ${t.status}`);return t.json()}async function iS(e,t){const n=await fetch(`${ie}/agents/${e}/browser-sessions/${t}`);if(!n.ok)throw new Error(`fetchBrowserSession: ${n.status}`);return n.json()}function dR(e,t){return`${ie}/agents/${e}/browser-sessions/${t}/video`}function sS(e,t){const n=window.location;return`${n.protocol==="https:"?"wss:":"ws:"}//${n.host}/browser-live/${e}/${t}`}function fR(e){return`${ie}/agents/${e}/export`}async function Hy(e,t){const n=new URL(`${ie}/agents/import`,window.location.origin);t!=null&&t.id&&n.searchParams.set("id",t.id);const r=await fetch(n.toString().replace(window.location.origin,""),{method:"POST",headers:{"Content-Type":"application/zip"},body:e});if(!r.ok){const i=await r.json().catch(()=>({error:r.statusText}));throw new Error(i.error)}return r.json()}async function Vy(e,t){const n=await fetch(`${ie}/agents/${e}/monitor/jobs/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`killJob: ${n.status}`)}async function hR(e){const t=await fetch(`${ie}/agents/${e}/monitor`);if(!t.ok)throw new Error(`fetchMonitor: ${t.status}`);return t.json()}async function pR(e,t=30){const n=await fetch(`${ie}/agents/${e}/usage?days=${t}`);if(!n.ok)throw new Error(`fetchUsage: ${n.status}`);return n.json()}async function gR(e){const t=await fetch(`${ie}/agents/${e}/schedules`);if(!t.ok)throw new Error(`fetchSchedules: ${t.status}`);return t.json()}async function mR(e,t,n){const r=await fetch(`${ie}/agents/${e}/schedules/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error(`updateSchedule: ${r.status}`);return r.json()}async function xR(e,t){const n=await fetch(`${ie}/agents/${e}/schedules/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteSchedule: ${n.status}`)}async function vR(e,t){const n=await fetch(`${ie}/agents/${e}/schedules/${t}/trigger`,{method:"POST"});if(!n.ok)throw new Error(`triggerSchedule: ${n.status}`);return n.json()}async function yR(e,t){const n=await fetch(`${ie}/agents/${e}/schedules/${t}/runs`);if(!n.ok)throw new Error(`fetchScheduleRuns: ${n.status}`);return n.json()}async function bR(e,t){const n=await fetch(`${ie}/agents/${e}/messages?channelId=${encodeURIComponent(t)}&sortBy=asc&limit=200`);if(!n.ok)throw new Error(`fetchScheduleRunMessages: ${n.status}`);return n.json()}async function _R(e){const t=await fetch(`${ie}/agents/${e}/workflows`);if(!t.ok)throw new Error(`fetchWorkflows: ${t.status}`);return t.json()}async function Uy(e,t){const n=await fetch(`${ie}/agents/${e}/workflows/${t}`);if(!n.ok)throw new Error(`fetchWorkflow: ${n.status}`);return n.json()}async function Sf(e,t){const n=await fetch(`${ie}/agents/${e}/workflows/${t}/runs`);if(!n.ok)throw new Error(`fetchWorkflowRuns: ${n.status}`);return n.json()}async function wR(e,t,n){const r=await fetch(`${ie}/agents/${e}/workflows/${t}/runs/${n}`);if(!r.ok)throw new Error(`fetchWorkflowRun: ${r.status}`);return r.json()}async function kR(e,t){const n=await fetch(`${ie}/agents/${e}/workflows/${t}/run`,{method:"POST"});if(!n.ok)throw new Error(`triggerWorkflowRun: ${n.status}`);return n.json()}async function SR(e,t,n){const r=await fetch(`${ie}/agents/${e}/workflows/${t}/runs/${n}/cancel`,{method:"POST"});if(!r.ok)throw new Error(`cancelWorkflowRun: ${r.status}`)}async function CR(e,t){const n=await fetch(`${ie}/agents/${e}/workflows`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`createWorkflow: ${n.status}`);return n.json()}async function ER(e,t,n){const r=await fetch(`${ie}/agents/${e}/workflows/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error(`updateWorkflow: ${r.status}`);return r.json()}async function NR(e,t){const n=await fetch(`${ie}/agents/${e}/workflows/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteWorkflow: ${n.status}`)}async function jR(e,t,n){const r=await fetch(`${ie}/agents/${e}/workflows/${t}/steps`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error(`createStep: ${r.status}`);return r.json()}async function Cf(e,t,n,r){const i=await fetch(`${ie}/agents/${e}/workflows/${t}/steps/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok)throw new Error(`updateStep: ${i.status}`);return i.json()}async function PR(e,t,n){const r=await fetch(`${ie}/agents/${e}/workflows/${t}/steps/${n}`,{method:"DELETE"});if(!r.ok)throw new Error(`deleteStep: ${r.status}`)}async function TR(e){const t=new URLSearchParams;e!=null&&e.agentId&&t.set("agentId",e.agentId),e!=null&&e.type&&t.set("type",e.type),e!=null&&e.search&&t.set("search",e.search),(e==null?void 0:e.limit)!=null&&t.set("limit",String(e.limit)),(e==null?void 0:e.offset)!=null&&t.set("offset",String(e.offset));const n=await fetch(`${ie}/logs?${t}`);if(!n.ok)throw new Error(`fetchLogs: ${n.status}`);return n.json()}async function oS(){const e=await fetch(`${ie}/settings/provider`);if(!e.ok)throw new Error("Failed to fetch provider settings");return e.json()}const Ef={showWorkspaceDirConfig:!0,showBraveSearchConfig:!0,enableIntegrations:!1};async function aS(){try{const e=await fetch(`${ie}/settings/app`);if(!e.ok)return{...Ef};const t=await e.json();return{...Ef,...t}}catch{return{...Ef}}}async function qy(e,t,n){if(!(await fetch(`${ie}/settings/provider`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,model:t,apiKey:n})})).ok)throw new Error("Failed to save provider settings")}async function MR(e){if(!(await fetch(`${ie}/settings/providers/${encodeURIComponent(e)}`,{method:"DELETE"})).ok)throw new Error("Failed to remove provider")}async function RR(){const e=await fetch(`${ie}/settings/search`);return e.ok?e.json():{provider:"brave",configured:!1}}async function DR(e,t){const n=await fetch(`${ie}/settings/search`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:t})});if(!n.ok)throw new Error(`Failed to save search settings: ${n.status}`)}async function AR(){const e=await fetch(`${ie}/settings/search`,{method:"DELETE"});if(!e.ok&&e.status!==204&&e.status!==404)throw new Error(`Failed to clear search settings: ${e.status}`)}const LR={google:[{value:"gemini-2.5-flash",label:"Gemini 2.5 Flash — fast + smart (recommended)"},{value:"gemini-2.5-pro",label:"Gemini 2.5 Pro — most capable"},{value:"gemini-2.5-flash-lite",label:"Gemini 2.5 Flash Lite — cheapest"},{value:"gemini-3-flash-preview",label:"Gemini 3 Flash — preview"},{value:"gemini-3.1-pro-preview",label:"Gemini 3.1 Pro — preview"}],openai:[{value:"gpt-4.1",label:"GPT-4.1 — recommended, 1M ctx"},{value:"gpt-4.1-mini",label:"GPT-4.1 Mini — fast, efficient"},{value:"gpt-4.1-nano",label:"GPT-4.1 Nano — cheapest"}],anthropic:[{value:"claude-sonnet-4-6",label:"Claude Sonnet 4.6 — recommended"},{value:"claude-opus-4-6",label:"Claude Opus 4.6 — most capable"},{value:"claude-haiku-4-5-20251001",label:"Claude Haiku 4.5 — fastest"}],groq:[{value:"openai/gpt-oss-120b",label:"GPT-OSS 120B — flagship, ~500 tok/s"},{value:"openai/gpt-oss-20b",label:"GPT-OSS 20B — fast, efficient"},{value:"llama-3.3-70b-versatile",label:"Llama 3.3 70B — versatile"},{value:"llama-3.1-8b-instant",label:"Llama 3.1 8B — fastest/cheapest"}],openrouter:[{value:"google/gemini-2.5-flash",label:"Gemini 2.5 Flash — best price/perf ($0.30/$2.50 /M)"},{value:"google/gemini-3-flash-preview",label:"Gemini 3 Flash — fast, 1M ctx ($0.50/$3 /M)"},{value:"google/gemini-3.1-pro-preview",label:"Gemini 3.1 Pro — frontier ($2/$12 /M)"},{value:"deepseek/deepseek-v3.2",label:"DeepSeek V3.2 — cheap output ($0.26/$0.38 /M)"},{value:"xiaomi/mimo-v2-pro",label:"MiMo V2 Pro — agentic, 1T params ($1/$3 /M)"},{value:"qwen/qwen3.6-plus",label:"Qwen 3.6 Plus — throughput leader ($0.33/$1.95 /M)"},{value:"minimax/minimax-m2.7",label:"MiniMax M2.7 — agentic ($0.30/$1.20 /M)"},{value:"x-ai/grok-4",label:"Grok 4 — reasoning, 256k ctx ($3/$15 /M)"}],freetier:[{value:"z-ai/glm-5-turbo",label:"GLM 5 Turbo — enterprise default"}]},lS=[{value:"google",label:"Google Gemini"},{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"groq",label:"Groq"},{value:"openrouter",label:"OpenRouter"}];function fd(e){return LR[e]??[]}function Dp(e){var t;return((t=fd(e)[0])==null?void 0:t.value)??""}const Ui="inline-flex items-center justify-center gap-2 bg-primary text-on-primary px-5 py-2.5 text-sm font-label font-semibold uppercase tracking-widest rounded shadow-sm transition-all hover:bg-surface-tint hover:shadow-md active:scale-[0.98] disabled:opacity-40 disabled:pointer-events-none",km="inline-flex items-center justify-center gap-2 border border-outline-variant text-on-surface px-5 py-2.5 text-sm font-label font-semibold uppercase tracking-widest rounded transition-all hover:bg-surface-container hover:border-outline active:scale-[0.98] disabled:opacity-40 disabled:pointer-events-none",qr="inline-flex items-center justify-center gap-1.5 text-on-surface-variant px-2.5 py-1.5 text-xs font-label font-medium uppercase tracking-wider rounded transition-colors hover:bg-surface-container hover:text-on-surface disabled:opacity-40 disabled:pointer-events-none",Mu="inline-flex items-center justify-center gap-1.5 text-error px-2.5 py-1.5 text-xs font-label font-medium uppercase tracking-wider rounded transition-colors hover:bg-error/10 disabled:opacity-40 disabled:pointer-events-none",rr="w-full bg-surface-container-lowest text-on-surface placeholder:text-on-surface-variant border border-outline-variant rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 transition-colors",Gy=rr.replace("text-sm","text-sm font-mono"),tl="bg-surface-container-lowest border border-outline-variant/40 rounded-xl shadow-callout",Sm="inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-label font-medium uppercase tracking-wider",jc=`${Sm} bg-surface-container border border-outline-variant/40 text-on-surface-variant`,Ap=`${Sm} bg-success/10 border border-success/20 text-success`,Ky=`${Sm} bg-warning/10 border border-warning/20 text-warning`;function IR({agent:e,onDelete:t}){const n=os(),{t:r}=we(),i=e.status==="active",s=e.busy===!0;return f.jsxs("div",{onClick:()=>n(`/agents/${e.id}/chat`),className:"group flex items-center gap-4 rounded-xl bg-surface-container-lowest border border-outline-variant/40 p-4 cursor-pointer transition-all hover:border-primary/40 hover:shadow-callout",children:[f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f.jsx("span",{className:"font-headline text-lg font-bold text-on-surface",children:e.name}),s?f.jsxs("span",{"data-testid":"busy-badge",className:"inline-flex items-center gap-1 rounded-full bg-secondary/15 border border-secondary/30 px-2 py-0.5 text-[10px] font-label font-semibold uppercase tracking-wider text-secondary",children:[f.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-secondary animate-pulse"}),"busy"]}):f.jsx("span",{className:i?Ap:jc,children:e.status})]}),f.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[f.jsx("span",{className:"font-mono text-[10px] text-primary/70",children:e.model}),f.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant/60 hidden sm:inline",children:["id: ",e.id]})]})]}),f.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:f.jsx("button",{onClick:o=>{o.stopPropagation(),t()},className:`${Mu} sm:opacity-0 sm:group-hover:opacity-100`,children:r("dashboard.delete")})})]})}function OR(){const{t:e}=we(),[t,n]=E.useState([]),[r,i]=E.useState(!0),[s,o]=E.useState(null),[a,l]=E.useState({showWorkspaceDirConfig:!0,showBraveSearchConfig:!0,enableIntegrations:!1}),[c,u]=E.useState(!1),[d,h]=E.useState(""),[p,g]=E.useState(""),[m,y]=E.useState(""),[x,v]=E.useState(""),[b,S]=E.useState(""),[C,_]=E.useState(!1),[N,j]=E.useState(!1),[T,w]=E.useState(null),M=E.useRef(null);async function D(k){var U,P;const L=(U=k.target.files)==null?void 0:U[0];if(L){j(!0),w(null);try{let J;try{J=await Hy(L)}catch(oe){const le=oe instanceof Error?oe.message:String(oe);if(le.includes("already exists")){const R=(P=prompt(`${le}
90
+ Esta acción no se puede deshacer.`,guardian:"Guardián",comingSoon:"Próximamente",guardianBlurb1:"Configura un agente guardián para controlar lo que puede hacer tu agente principal.",guardianBlurb2:"Define restricciones, bloquea acciones y exige aprobación antes de operaciones sensibles.",guardianChatBlurb:"Chat del guardián.<br />Configura restricciones aquí.",guardianDisconnected:"○ desconectado",errorCreditLimit:"La clave API ha alcanzado su límite de gasto. Recarga créditos o aumenta el límite de la clave en el panel de tu proveedor.",errorRateLimit:"Límite de solicitudes excedido. El proveedor está limitando las peticiones — intenta de nuevo en unos segundos.",errorAuth:"Autenticación fallida. La clave API puede ser inválida o estar expirada — revisa Configuración.",errorNoProvider:"Sin proveedor configurado. Ve a Configuración para agregar uno.",errorNoKey:"Falta la clave API del proveedor. Ve a Configuración para reconfigurar.",errorTimeout:"El agente tardó demasiado en responder. Intenta de nuevo o simplifica tu solicitud.",errorGeneric:"Algo salió mal: {message}"},NM={sessionExpiredLabel:"toma de control",sessionExpired:"Sesión expirada",sessionExpiredBlurb:"Este enlace de toma de control ya fue usado o expiró.",completeLabel:"completo",controlReturned:"Control devuelto al agente",closeTab:"Puedes cerrar esta pestaña.",connecting:"conectando…",agentNeedsHelp:"El agente necesita tu ayuda",liveLabel:"en vivo",waitingStream:"esperando transmisión del navegador…",browserStarting:"iniciando el navegador — la transmisión comenzará cuando cargue una página",browserNotReady:"el navegador está entre páginas — esperando la próxima navegación",whatDidYouDo:"¿Qué hiciste?",optional:"(opcional)",describeActionPlaceholder:"Describe tu acción para el agente…",returning:"Devolviendo…",completed:"Completado",urlBarPlaceholder:"Escribe una URL y pulsa Intro para navegar…"},jM={title:"Habilidades",subtitle:"Habilidades que tu agente puede invocar. Las habilidades invocables por el usuario se pueden activar desde el chat con /barra-comando.",empty:"No hay habilidades instaladas todavía. Viven en .pi/skills/ dentro del workspace del agente.",loading:"Cargando habilidades…",selectSkill:"Selecciona una habilidad a la izquierda para ver su definición completa.",userInvocable:"invocable por usuario",allowedTools:"Herramientas permitidas",loadError:"No se pudo cargar la habilidad: {error}"},PM={editedBy:"editado por {name}",relativeNow:"ahora",relativeMinutes:"hace {n}m",relativeHours:"hace {n}h",relativeDays:"hace {n}d",titlePlaceholder:"Título de tarea…",descPlaceholder:"Descripción (markdown)…",add:"Agregar",cancel:"Cancelar",searchPlaceholder:"Buscar tareas…",clearAll:"Limpiar todo",clearConfirm:"¿Eliminar TODAS las tareas? No se puede deshacer.",columnLabelPlaceholder:"Nombre de columna…",deleteColumnConfirm:"¿Eliminar esta columna? Las tareas se moverán a la primera columna."},TM={saving:"guardando…",close:"Cerrar",status:"Estado",tags:"Etiquetas",addTag:"agregar…",sourceLabel:"fuente",editedByLabel:"editado por",created:"creado",updated:"actualizado",description:"Descripción",descPlaceholder:"Agregar una descripción…",save:"Guardar",cancel:"Cancelar",descEmpty:"Sin descripción — clic para agregar",commentsLabel:"Comentarios ({count})",noComments:"Sin comentarios aún",addComment:"Agregar comentario",commentPlaceholder:"Escribe un comentario… (markdown soportado)",publishComment:"Publicar comentario",publishing:"Publicando…",dangerZone:"Zona peligrosa",deleteTask:"[PELIGROSO] Eliminar tarea",deleting:"eliminando…",deleteConfirm:'¿Eliminar tarea "{title}"? Esta acción no se puede deshacer.'},MM={backToRuns:"← Volver a ejecuciones",loading:"Cargando…",waitingResponse:"Esperando respuesta…",triggering:"Iniciando…",runNow:"Ejecutar ahora",runHistory:"Historial de ejecuciones",noRuns:"Sin ejecuciones aún.",loadingList:"Cargando programados…",emptyIcon:"⏰",emptyText:"Sin programados aún. Pídele al agente que configure tareas recurrentes.",title:"Programados",activeCountOne:"{count} activo",activeCountOther:"{count} activos",next:"Próximo: {time}",last:"Último: {time}",pause:"Pausar",resume:"Reanudar",delete:"Eliminar",deleteConfirm:'¿Eliminar programado "{name}"?'},RM={title:"Flujos de trabajo",emptyText:"Sin flujos de trabajo aún. Pídele al agente que cree uno via chat.",running:"Ejecutando…",run:"Ejecutar",createdOn:"{id} · Creado {date}",back:"← Volver a flujos",run_button:"Ejecutar",stepsTitle:"Pasos ({count})",conditionsOne:"{count} condición",conditionsOther:"{count} condiciones",stepTimeout:"Límite de tiempo: {seconds}s",stepId:"ID: {id}",runHistoryTitle:"Historial de ejecuciones ({count})",noRuns:"Sin ejecuciones aún.",runStatus:{running:"en ejecución",completed:"completado",failed:"fallido",cancelled:"cancelado"},newWorkflow:"Nuevo flujo",editWorkflow:"Editar flujo",edit:"Editar",delete:"Eliminar",cancel:"Cancelar",save:"Guardar",saving:"Guardando…",addStep:"Añadir paso",addStepTitle:"Añadir paso",editStepTitle:"Editar paso",moveUp:"Subir",moveDown:"Bajar",noSteps:'Aún no hay pasos. Haz clic en "Añadir paso" para empezar.',confirmDelete:'¿Eliminar el flujo "{name}"? Esto no se puede deshacer.',confirmDeleteStep:'¿Eliminar el paso "{name}"?',formName:"Nombre",formNamePlaceholder:"Resumen diario de LinkedIn",formDescription:"Descripción",formDescriptionPlaceholder:"¿Qué hace este flujo?",formStatus:"Estado",stepNameLabel:"Nombre del paso",stepNamePlaceholder:"Recoger últimas publicaciones",stepTimeoutLabel:"Tiempo límite (segundos)",stepPromptLabel:"Prompt",stepPromptPlaceholder:"Resume la salida del paso anterior…"},DM={loading:"Cargando ejecución…",back:"← Volver al flujo",runLabel:"Ejecución —",errorPrefix:"Error:",input:"Entrada",output:"Salida",activity:"Actividad",cancel:"Cancelar ejecución",cancelling:"Cancelando…"},AM={loading:"Cargando monitor…",title:"Monitor",idle:"inactivo",claudeSessionsOne:"{count} sesión claude",claudeSessionsOther:"{count} sesiones claude",processes:"Procesos",agentProcess:"Proceso del Agente",guardianProcess:"Guardián (Big Brother)",browserDaemon:"Demonio de Navegador",activeClaudeSessions:"Sesiones Claude Activas — {count}",jobQueue:"Cola de trabajos — {processing} en proceso, {pending} en espera",noActiveJobs:"Sin trabajos activos",processing:"procesando",queued:"en cola",terminate:"Terminar",cancel:"Cancelar",runningWorkflows:"Flujos de trabajo en ejecución",cpu:"CPU",mem:"MEM",rss:"RSS",uptime:"Tiempo activo"},LM={title:"Integraciones",blurb:"Conecta servicios externos. Cada integración almacena un token como secreto y se activa automáticamente.",moreSoon:"Más integraciones próximamente. Para otras claves API y credenciales, usa la sección de Secretos en la barra lateral.",connected:"Conectado",disconnect:"Desconectar",connect:"Conectar",saveAndConnect:"Guardar y conectar",saving:"Guardando…",cancel:"Cancelar",newPrefix:"Nuevo {label}",pasteNewToken:"Pega el nuevo token",updateToken:"Actualizar token",rotateToken:"Rotar token",errorSave:"Error al guardar — revisa la consola",disconnectConfirm:"¿Desconectar {name}? El agente dejará de usarlo inmediatamente.",telegramDescription:"Recibe y responde mensajes a través de un bot de Telegram.",telegramHelp:"Crea un bot mediante @BotFather en Telegram, luego pega el token aquí.",telegramTokenLabel:"Token del bot"},IM={loading:"Escaneando sesiones…",title:"Uso",totalTokens:"Tokens totales",cachedSuffix:"{amount} en caché",sessions:"Sesiones",modelsCount:"{count} modelos",estCost:"Costo est.",periodDays:"Período de {days} días",avgDay:"Prom/Día",sessionsPerDay:"{count} sesiones/día",dailyTokenUsage:"Uso diario de tokens",noUsageData:"Sin datos de uso",dailyCost:"Costo estimado diario",noCostData:"Sin datos de costo",byModel:"Por modelo",modelSessionsBlurb:"{sessions} sesiones · {input} entrada · {output} salida",tokenBreakdown:"Desglose de tokens",inputTokens:"Tokens de entrada",outputTokens:"Tokens de salida",cacheRead:"Lectura de caché",cacheWrite:"Escritura de caché",toolInvocations:"Invocaciones de herramientas",dailyBreakdown:"Desglose diario",date:"Fecha",tableSessions:"Sesiones",tableInput:"Entrada",tableOutput:"Salida",tableCache:"Caché",tableCost:"Costo"},OM={searchPlaceholder:"Buscar registros…",apply:"Aplicar",live:"En vivo",loading:"cargando…",noResults:'sin resultados para "{query}"',noEntries:"sin entradas de registro",loadOlder:"Cargar {count} entradas anteriores…"},FM={views:{chat:"Chat",tasks:"Tareas",skills:"Habilidades",browser:"Navegador",files:"Archivos",workflows:"Flujos de trabajo",schedules:"Programados",monitor:"Monitor",usage:"Uso",logs:"Registros",integrations:"Integraciones",guardian:"Guardián"},comingSoon:"Pronto",secrets:"Secretos",noSecrets:"Sin secretos configurados",updating:"Actualizando {name}",newValue:"nuevo valor",save:"Guardar",secretNamePlaceholder:"NOMBRE",secretValuePlaceholder:"valor",guardrails:"Restricciones",guardrailsBlurb:"Configurado via chat guardián",exportAgent:"📦 Exportar agente",exportTitle:"Descargar una copia de seguridad completa del espacio de trabajo del agente como zip",wipeAgent:"🗑 Borrar agente",wiping:"borrando…"},$M={workspace:"espacio-de-trabajo",savingLabel:"guardando…",saveButton:"Guardar",emptyDir:"Directorio vacío"},zM={common:wM,shell:kM,dashboard:SM,settings:CM,chat:EM,takeover:NM,skillsView:jM,tasks:PM,taskDetail:TM,schedules:MM,workflows:RM,runDetail:DM,monitor:AM,integrations:LM,usage:IM,logs:OM,agentSettings:FM,files:$M},Oy={en:_M,es:zM},tS="granclaw:lang";function BM(){if(typeof window>"u")return"en";try{const t=window.localStorage.getItem(tS);if(t==="en"||t==="es")return t}catch{}return(typeof navigator<"u"?navigator.language:"").toLowerCase().startsWith("es")?"es":"en"}function Fy(e,t){const n=t.split(".");let r=e;for(const i of n)if(r&&typeof r=="object"&&i in r)r=r[i];else return;return typeof r=="string"?r:void 0}function WM(e,t){return t?e.replace(/\{(\w+)\}/g,(n,r)=>{const i=t[r];return i==null?`{${r}}`:String(i)}):e}const nS=E.createContext(null);function HM({children:e}){const[t,n]=E.useState(()=>BM()),r=E.useCallback(o=>{n(o);try{window.localStorage.setItem(tS,o)}catch{}},[]);E.useEffect(()=>{try{document.documentElement.lang=t}catch{}},[t]);const i=E.useCallback((o,a)=>{const l=Oy[t],c=Fy(l,o)??Fy(Oy.en,o)??o;return WM(c,a)},[t]),s=E.useMemo(()=>({lang:t,setLang:r,t:i}),[t,r,i]);return f.jsx(nS.Provider,{value:s,children:e})}function we(){const e=E.useContext(nS);if(!e)throw new Error("useT must be used inside <LanguageProvider>");return e}function VM({className:e}){const{lang:t,setLang:n}=we();return f.jsx("div",{className:`flex items-center gap-0.5 rounded-full bg-surface-container/40 p-[2px] ${e??""}`,children:["en","es"].map(r=>f.jsx("button",{onClick:()=>n(r),className:`px-2 py-[2px] rounded-full text-[10px] font-mono uppercase tracking-wider transition-colors ${t===r?"bg-primary/30 text-primary":"text-on-surface-variant/70 hover:text-on-surface"}`,"aria-pressed":t===r,children:r},r))})}function UM(){const e=ss(),t=os(),n=e.pathname.includes("/chat"),{t:r}=we();return f.jsxs("div",{className:"flex h-screen flex-col overflow-hidden bg-surface",children:[f.jsxs("header",{className:"flex h-11 flex-shrink-0 items-center justify-between border-b border-outline-variant/20 bg-surface-low px-3 sm:px-5",children:[f.jsxs("button",{onClick:()=>t("/dashboard"),className:"flex items-center gap-2 hover:opacity-80 transition-opacity min-w-0",children:[f.jsx("img",{src:"/granclaw-logo.png",alt:"GranClaw",className:"h-6 w-6 rounded flex-shrink-0"}),f.jsx("span",{className:"font-display font-semibold text-on-surface tracking-tight truncate",children:"GranClaw"}),f.jsxs("span",{className:"text-xs font-mono text-on-surface/60 flex-shrink-0",children:["v","0.0.1-beta.103"]})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f.jsx(VM,{}),f.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-secondary-container/20 px-2 sm:px-3 py-1 text-xs font-mono text-secondary flex-shrink-0",children:[f.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-secondary animate-pulse flex-shrink-0"}),f.jsx("span",{className:"hidden sm:inline",children:r("shell.systemPrefix")}),r("shell.onlineSuffix")]})]})]}),f.jsx("main",{className:`flex-1 overflow-auto min-w-0 ${n?"":"p-3 sm:p-5"}`,children:f.jsx(BP,{})})]})}const ie="";async function $y(){const e=await fetch(`${ie}/agents`);if(!e.ok)throw new Error(`fetchAgents: ${e.status}`);return e.json()}async function qM(e,t,n,r,i){const s=await fetch(`${ie}/agents`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,name:t,model:n,provider:r,...i?{workspaceDir:i}:{}})});if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Error(o.error)}}async function GM(e){const t=await fetch(`${ie}/agents/${e}`,{method:"DELETE"});if(!t.ok)throw new Error(`deleteAgent: ${t.status}`)}async function zy(e){const t=await fetch(`${ie}/agents/${e}`);if(!t.ok)throw new Error(`fetchAgent: ${t.status}`);return t.json()}async function By(e,t="ui"){const n=await fetch(`${ie}/agents/${e}/messages?channelId=${t}&sortBy=desc&limit=200`,{cache:"no-store"});if(!n.ok)throw new Error(`fetchMessages: ${n.status}`);return(await n.json()).reverse()}async function KM(e){const t=await fetch(`${ie}/agents/${e}/reset`,{method:"DELETE"});if(!t.ok)throw new Error(`resetAgent: ${t.status}`)}async function YM(e,t=""){const n=await fetch(`${ie}/agents/${e}/files?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`fetchFiles: ${n.status}`);return(await n.json()).entries}async function XM(e,t){const n=await fetch(`${ie}/agents/${e}/files/read?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`readFile: ${n.status}`);return(await n.json()).content}async function JM(e,t,n){const r=await fetch(`${ie}/agents/${e}/files/write?path=${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n})});if(!r.ok)throw new Error(`writeFile: ${r.status}`)}async function QM(e){const t=await fetch(`${ie}/agents/${e}/secrets`);if(!t.ok)throw new Error(`fetchSecrets: ${t.status}`);return t.json()}async function Rp(e,t,n){const r=await fetch(`${ie}/agents/${e}/secrets`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,value:n})});if(!r.ok)throw new Error(`addSecret: ${r.status}`)}async function rS(e,t){const n=await fetch(`${ie}/agents/${e}/secrets/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteSecret: ${n.status}`)}async function ZM(e){const t=await fetch(`${ie}/agents/${e}/skills`);if(!t.ok)throw new Error(`fetchSkills: ${t.status}`);return(await t.json()).skills}async function eR(e,t){const n=t.split("/").map(encodeURIComponent).join("/"),r=await fetch(`${ie}/agents/${e}/skills/${n}`);if(!r.ok)throw new Error(`fetchSkillDetail: ${r.status}`);return r.json()}async function tR(e,t){const n=new URLSearchParams,r=n.toString()?`?${n.toString()}`:"",i=await fetch(`${ie}/agents/${e}/tasks${r}`);if(!i.ok)throw new Error(`fetchTasks: ${i.status}`);return i.json()}async function nR(e,t){const n=await fetch(`${ie}/agents/${e}/tasks/${t}`);if(!n.ok)throw new Error(`fetchTask: ${n.status}`);return n.json()}async function rR(e,t){const n=await fetch(`${ie}/agents/${e}/tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`createTask: ${n.status}`);return n.json()}async function Wy(e,t,n){const r=await fetch(`${ie}/agents/${e}/tasks/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error(`updateTask: ${r.status}`);return r.json()}async function iR(e,t){const n=await fetch(`${ie}/agents/${e}/tasks/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteTask: ${n.status}`)}async function sR(e){const t=await fetch(`${ie}/agents/${e}/tasks`,{method:"DELETE"});if(!t.ok)throw new Error(`clearTasks: ${t.status}`);return t.json()}async function oR(e,t,n){const r=await fetch(`${ie}/agents/${e}/tasks/${t}/comments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:n})});if(!r.ok)throw new Error(`addTaskComment: ${r.status}`);return r.json()}async function aR(e){const t=await fetch(`${ie}/agents/${e}/task-columns`);if(!t.ok)throw new Error(`fetchColumns: ${t.status}`);return t.json()}async function lR(e,t){const n=await fetch(`${ie}/agents/${e}/task-columns`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({label:t})});if(!n.ok)throw new Error(`createColumn: ${n.status}`);return n.json()}async function cR(e,t){const n=await fetch(`${ie}/agents/${e}/task-columns/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteColumn: ${n.status}`)}async function uR(e){const t=await fetch(`${ie}/agents/${e}/browser-sessions`);if(!t.ok)throw new Error(`fetchBrowserSessions: ${t.status}`);return t.json()}async function iS(e,t){const n=await fetch(`${ie}/agents/${e}/browser-sessions/${t}`);if(!n.ok)throw new Error(`fetchBrowserSession: ${n.status}`);return n.json()}function dR(e,t){return`${ie}/agents/${e}/browser-sessions/${t}/video`}function sS(e,t){const n=window.location;return`${n.protocol==="https:"?"wss:":"ws:"}//${n.host}/browser-live/${e}/${t}`}function fR(e){return`${ie}/agents/${e}/export`}async function Hy(e,t){const n=new URL(`${ie}/agents/import`,window.location.origin);t!=null&&t.id&&n.searchParams.set("id",t.id);const r=await fetch(n.toString().replace(window.location.origin,""),{method:"POST",headers:{"Content-Type":"application/zip"},body:e});if(!r.ok){const i=await r.json().catch(()=>({error:r.statusText}));throw new Error(i.error)}return r.json()}async function Vy(e,t){const n=await fetch(`${ie}/agents/${e}/monitor/jobs/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`killJob: ${n.status}`)}async function hR(e){const t=await fetch(`${ie}/agents/${e}/monitor`);if(!t.ok)throw new Error(`fetchMonitor: ${t.status}`);return t.json()}async function pR(e,t=30){const n=await fetch(`${ie}/agents/${e}/usage?days=${t}`);if(!n.ok)throw new Error(`fetchUsage: ${n.status}`);return n.json()}async function gR(e){const t=await fetch(`${ie}/agents/${e}/schedules`);if(!t.ok)throw new Error(`fetchSchedules: ${t.status}`);return t.json()}async function mR(e,t,n){const r=await fetch(`${ie}/agents/${e}/schedules/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error(`updateSchedule: ${r.status}`);return r.json()}async function xR(e,t){const n=await fetch(`${ie}/agents/${e}/schedules/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteSchedule: ${n.status}`)}async function vR(e,t){const n=await fetch(`${ie}/agents/${e}/schedules/${t}/trigger`,{method:"POST"});if(!n.ok)throw new Error(`triggerSchedule: ${n.status}`);return n.json()}async function yR(e,t){const n=await fetch(`${ie}/agents/${e}/schedules/${t}/runs`);if(!n.ok)throw new Error(`fetchScheduleRuns: ${n.status}`);return n.json()}async function bR(e,t){const n=await fetch(`${ie}/agents/${e}/messages?channelId=${encodeURIComponent(t)}&sortBy=asc&limit=200`);if(!n.ok)throw new Error(`fetchScheduleRunMessages: ${n.status}`);return n.json()}async function _R(e){const t=await fetch(`${ie}/agents/${e}/workflows`);if(!t.ok)throw new Error(`fetchWorkflows: ${t.status}`);return t.json()}async function Uy(e,t){const n=await fetch(`${ie}/agents/${e}/workflows/${t}`);if(!n.ok)throw new Error(`fetchWorkflow: ${n.status}`);return n.json()}async function Sf(e,t){const n=await fetch(`${ie}/agents/${e}/workflows/${t}/runs`);if(!n.ok)throw new Error(`fetchWorkflowRuns: ${n.status}`);return n.json()}async function wR(e,t,n){const r=await fetch(`${ie}/agents/${e}/workflows/${t}/runs/${n}`);if(!r.ok)throw new Error(`fetchWorkflowRun: ${r.status}`);return r.json()}async function kR(e,t){const n=await fetch(`${ie}/agents/${e}/workflows/${t}/run`,{method:"POST"});if(!n.ok)throw new Error(`triggerWorkflowRun: ${n.status}`);return n.json()}async function SR(e,t,n){const r=await fetch(`${ie}/agents/${e}/workflows/${t}/runs/${n}/cancel`,{method:"POST"});if(!r.ok)throw new Error(`cancelWorkflowRun: ${r.status}`)}async function CR(e,t){const n=await fetch(`${ie}/agents/${e}/workflows`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`createWorkflow: ${n.status}`);return n.json()}async function ER(e,t,n){const r=await fetch(`${ie}/agents/${e}/workflows/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error(`updateWorkflow: ${r.status}`);return r.json()}async function NR(e,t){const n=await fetch(`${ie}/agents/${e}/workflows/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteWorkflow: ${n.status}`)}async function jR(e,t,n){const r=await fetch(`${ie}/agents/${e}/workflows/${t}/steps`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error(`createStep: ${r.status}`);return r.json()}async function Cf(e,t,n,r){const i=await fetch(`${ie}/agents/${e}/workflows/${t}/steps/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok)throw new Error(`updateStep: ${i.status}`);return i.json()}async function PR(e,t,n){const r=await fetch(`${ie}/agents/${e}/workflows/${t}/steps/${n}`,{method:"DELETE"});if(!r.ok)throw new Error(`deleteStep: ${r.status}`)}async function TR(e){const t=new URLSearchParams;e!=null&&e.agentId&&t.set("agentId",e.agentId),e!=null&&e.type&&t.set("type",e.type),e!=null&&e.search&&t.set("search",e.search),(e==null?void 0:e.limit)!=null&&t.set("limit",String(e.limit)),(e==null?void 0:e.offset)!=null&&t.set("offset",String(e.offset));const n=await fetch(`${ie}/logs?${t}`);if(!n.ok)throw new Error(`fetchLogs: ${n.status}`);return n.json()}async function oS(){const e=await fetch(`${ie}/settings/provider`);if(!e.ok)throw new Error("Failed to fetch provider settings");return e.json()}const Ef={showWorkspaceDirConfig:!0,showBraveSearchConfig:!0,enableIntegrations:!1};async function aS(){try{const e=await fetch(`${ie}/settings/app`);if(!e.ok)return{...Ef};const t=await e.json();return{...Ef,...t}}catch{return{...Ef}}}async function qy(e,t,n){if(!(await fetch(`${ie}/settings/provider`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,model:t,apiKey:n})})).ok)throw new Error("Failed to save provider settings")}async function MR(e){if(!(await fetch(`${ie}/settings/providers/${encodeURIComponent(e)}`,{method:"DELETE"})).ok)throw new Error("Failed to remove provider")}async function RR(){const e=await fetch(`${ie}/settings/search`);return e.ok?e.json():{provider:"brave",configured:!1}}async function DR(e,t){const n=await fetch(`${ie}/settings/search`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:t})});if(!n.ok)throw new Error(`Failed to save search settings: ${n.status}`)}async function AR(){const e=await fetch(`${ie}/settings/search`,{method:"DELETE"});if(!e.ok&&e.status!==204&&e.status!==404)throw new Error(`Failed to clear search settings: ${e.status}`)}const LR={google:[{value:"gemini-2.5-flash",label:"Gemini 2.5 Flash — fast + smart (recommended)"},{value:"gemini-2.5-pro",label:"Gemini 2.5 Pro — most capable"},{value:"gemini-2.5-flash-lite",label:"Gemini 2.5 Flash Lite — cheapest"},{value:"gemini-3-flash-preview",label:"Gemini 3 Flash — preview"},{value:"gemini-3.1-pro-preview",label:"Gemini 3.1 Pro — preview"}],openai:[{value:"gpt-4.1",label:"GPT-4.1 — recommended, 1M ctx"},{value:"gpt-4.1-mini",label:"GPT-4.1 Mini — fast, efficient"},{value:"gpt-4.1-nano",label:"GPT-4.1 Nano — cheapest"}],anthropic:[{value:"claude-sonnet-4-6",label:"Claude Sonnet 4.6 — recommended"},{value:"claude-opus-4-6",label:"Claude Opus 4.6 — most capable"},{value:"claude-haiku-4-5-20251001",label:"Claude Haiku 4.5 — fastest"}],groq:[{value:"openai/gpt-oss-120b",label:"GPT-OSS 120B — flagship, ~500 tok/s"},{value:"openai/gpt-oss-20b",label:"GPT-OSS 20B — fast, efficient"},{value:"llama-3.3-70b-versatile",label:"Llama 3.3 70B — versatile"},{value:"llama-3.1-8b-instant",label:"Llama 3.1 8B — fastest/cheapest"}],openrouter:[{value:"google/gemini-2.5-flash",label:"Gemini 2.5 Flash — best price/perf ($0.30/$2.50 /M)"},{value:"google/gemini-3-flash-preview",label:"Gemini 3 Flash — fast, 1M ctx ($0.50/$3 /M)"},{value:"google/gemini-3.1-pro-preview",label:"Gemini 3.1 Pro — frontier ($2/$12 /M)"},{value:"deepseek/deepseek-v3.2",label:"DeepSeek V3.2 — cheap output ($0.26/$0.38 /M)"},{value:"xiaomi/mimo-v2-pro",label:"MiMo V2 Pro — agentic, 1T params ($1/$3 /M)"},{value:"qwen/qwen3.6-plus",label:"Qwen 3.6 Plus — throughput leader ($0.33/$1.95 /M)"},{value:"minimax/minimax-m2.7",label:"MiniMax M2.7 — agentic ($0.30/$1.20 /M)"},{value:"x-ai/grok-4",label:"Grok 4 — reasoning, 256k ctx ($3/$15 /M)"}],freetier:[{value:"z-ai/glm-5-turbo",label:"GLM 5 Turbo — enterprise default"}]},lS=[{value:"google",label:"Google Gemini"},{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"groq",label:"Groq"},{value:"openrouter",label:"OpenRouter"}];function fd(e){return LR[e]??[]}function Dp(e){var t;return((t=fd(e)[0])==null?void 0:t.value)??""}const Ui="inline-flex items-center justify-center gap-2 bg-primary text-on-primary px-5 py-2.5 text-sm font-label font-semibold uppercase tracking-widest rounded shadow-sm transition-all hover:bg-surface-tint hover:shadow-md active:scale-[0.98] disabled:opacity-40 disabled:pointer-events-none",km="inline-flex items-center justify-center gap-2 border border-outline-variant text-on-surface px-5 py-2.5 text-sm font-label font-semibold uppercase tracking-widest rounded transition-all hover:bg-surface-container hover:border-outline active:scale-[0.98] disabled:opacity-40 disabled:pointer-events-none",qr="inline-flex items-center justify-center gap-1.5 text-on-surface-variant px-2.5 py-1.5 text-xs font-label font-medium uppercase tracking-wider rounded transition-colors hover:bg-surface-container hover:text-on-surface disabled:opacity-40 disabled:pointer-events-none",Mu="inline-flex items-center justify-center gap-1.5 text-error px-2.5 py-1.5 text-xs font-label font-medium uppercase tracking-wider rounded transition-colors hover:bg-error/10 disabled:opacity-40 disabled:pointer-events-none",rr="w-full bg-surface-container-lowest text-on-surface placeholder:text-on-surface-variant border border-outline-variant rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 transition-colors",Gy=rr.replace("text-sm","text-sm font-mono"),tl="bg-surface-container-lowest border border-outline-variant/40 rounded-xl shadow-callout",Sm="inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-label font-medium uppercase tracking-wider",jc=`${Sm} bg-surface-container border border-outline-variant/40 text-on-surface-variant`,Ap=`${Sm} bg-success/10 border border-success/20 text-success`,Ky=`${Sm} bg-warning/10 border border-warning/20 text-warning`;function IR({agent:e,onDelete:t}){const n=os(),{t:r}=we(),i=e.status==="active",s=e.busy===!0;return f.jsxs("div",{onClick:()=>n(`/agents/${e.id}/chat`),className:"group flex items-center gap-4 rounded-xl bg-surface-container-lowest border border-outline-variant/40 p-4 cursor-pointer transition-all hover:border-primary/40 hover:shadow-callout",children:[f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f.jsx("span",{className:"font-headline text-lg font-bold text-on-surface",children:e.name}),s?f.jsxs("span",{"data-testid":"busy-badge",className:"inline-flex items-center gap-1 rounded-full bg-secondary/15 border border-secondary/30 px-2 py-0.5 text-[10px] font-label font-semibold uppercase tracking-wider text-secondary",children:[f.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-secondary animate-pulse"}),"busy"]}):f.jsx("span",{className:i?Ap:jc,children:e.status})]}),f.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[f.jsx("span",{className:"font-mono text-[10px] text-primary/70",children:e.model}),f.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant/60 hidden sm:inline",children:["id: ",e.id]})]})]}),f.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:f.jsx("button",{onClick:o=>{o.stopPropagation(),t()},className:`${Mu} sm:opacity-0 sm:group-hover:opacity-100`,children:r("dashboard.delete")})})]})}function OR(){const{t:e}=we(),[t,n]=E.useState([]),[r,i]=E.useState(!0),[s,o]=E.useState(null),[a,l]=E.useState({showWorkspaceDirConfig:!0,showBraveSearchConfig:!0,enableIntegrations:!1}),[c,u]=E.useState(!1),[d,h]=E.useState(""),[p,g]=E.useState(""),[m,y]=E.useState(""),[x,v]=E.useState(""),[b,S]=E.useState(""),[C,_]=E.useState(!1),[N,j]=E.useState(!1),[T,w]=E.useState(null),M=E.useRef(null);async function D(k){var U,P;const L=(U=k.target.files)==null?void 0:U[0];if(L){j(!0),w(null);try{let J;try{J=await Hy(L)}catch(oe){const le=oe instanceof Error?oe.message:String(oe);if(le.includes("already exists")){const R=(P=prompt(`${le}
91
91
 
92
92
  Enter a new id for the imported agent:`,""))==null?void 0:P.trim();if(!R){j(!1);return}J=await Hy(L,{id:R})}else throw oe}await F(),B(`/agents/${J.id}/chat`)}catch(J){w(J instanceof Error?J.message:e("dashboard.importFailed"))}finally{j(!1),M.current&&(M.current.value="")}}}const F=()=>{Promise.all([$y(),oS(),aS()]).then(([k,L,U])=>{var P;if(n(k),o(L),l(U),!m){const J=(P=L.providers)==null?void 0:P[0];J&&(y(J.provider),v(J.model))}}).catch(console.error).finally(()=>i(!1))};E.useEffect(()=>{F();const k=setInterval(()=>{$y().then(n).catch(()=>{})},2e3);return()=>clearInterval(k)},[]);const B=os(),$=(s==null?void 0:s.providers)??[],V=m?fd(m):[];function Y(k){y(k),v(Dp(k))}async function I(){if(!(!d.trim()||!p.trim())){_(!0),w(null);try{const k=d.trim();await qM(k,p.trim(),x,m||void 0,b.trim()||void 0),B(`/agents/${k}/chat`)}catch(k){w(k instanceof Error?k.message:e("common.errorCreate")),_(!1)}}}async function z(k,L){confirm(e("dashboard.deleteConfirm",{name:L,id:k}))&&(await GM(k),F())}return r?f.jsx("div",{className:"font-mono text-xs text-on-surface-variant p-8",children:e("dashboard.loadingAgents")}):s&&!s.configured&&t.length===0?f.jsx("div",{className:"max-w-3xl mx-auto py-16 px-4",children:f.jsxs("div",{className:"text-center",children:[f.jsxs("h1",{className:"font-headline text-4xl font-bold text-on-surface mb-4",children:[e("dashboard.getStartedWith")," ",f.jsx("span",{className:"highlight-marker",children:"GranClaw"})]}),f.jsx("p",{className:"font-mono text-xs text-on-surface-variant mb-8",children:e("dashboard.configureProviderBlurb")}),f.jsx(kv,{to:"/settings",className:Ui,children:e("dashboard.configureProvider")})]})}):f.jsxs("div",{className:"max-w-4xl mx-auto py-6 sm:py-8 px-4",children:[s&&!s.configured&&f.jsxs("div",{className:"rounded-xl bg-warning/10 border border-warning/30 px-4 py-3 mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2",children:[f.jsx("p",{className:"font-mono text-[11px] text-warning",children:e("dashboard.noProviderWarning")}),f.jsx(kv,{to:"/settings",className:"font-label text-[11px] font-semibold uppercase tracking-widest text-primary hover:text-surface-tint flex-shrink-0",children:e("dashboard.configureArrow")})]}),f.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4 mb-6 sm:mb-8",children:[f.jsxs("div",{children:[f.jsx("h1",{className:"font-headline text-3xl sm:text-4xl font-bold text-on-surface",children:e("dashboard.title")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface-variant mt-1",children:e(t.length===1?"dashboard.agentsCountOne":"dashboard.agentsCountOther",{count:t.length})})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f.jsx("input",{ref:M,type:"file",accept:".zip,application/zip",onChange:D,className:"hidden"}),f.jsx("button",{onClick:()=>{var k;return(k=M.current)==null?void 0:k.click()},disabled:N||!(s!=null&&s.configured),className:km,title:e("dashboard.importTitle"),children:e(N?"dashboard.importing":"dashboard.import")}),f.jsx("button",{onClick:()=>u(k=>!k),disabled:!(s!=null&&s.configured),className:Ui,children:e(c?"dashboard.cancel":"dashboard.newAgent")})]})]}),c&&f.jsxs("div",{className:`${tl} p-5 mb-6 space-y-3`,children:[f.jsx("p",{className:"font-label text-[10px] font-semibold uppercase tracking-widest text-on-surface-variant",children:e("dashboard.createNewAgent")}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[f.jsx("input",{className:Gy,placeholder:e("dashboard.agentIdPlaceholder"),value:d,onChange:k=>h(k.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))}),f.jsx("input",{className:rr,placeholder:e("dashboard.displayNamePlaceholder"),value:p,onChange:k=>g(k.target.value)})]}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[f.jsx("select",{className:`${rr} appearance-none`,value:m,onChange:k=>Y(k.target.value),children:$.map(k=>f.jsx("option",{value:k.provider,children:k.label??k.provider},k.provider))}),f.jsx("select",{className:`${rr} appearance-none`,value:x,onChange:k=>v(k.target.value),children:V.map(k=>f.jsx("option",{value:k.value,children:k.label},k.value))})]}),a.showWorkspaceDirConfig&&f.jsx("input",{className:Gy,placeholder:e("dashboard.workspacePlaceholder",{id:d||e("dashboard.workspacePlaceholderDefault")}),value:b,onChange:k=>S(k.target.value)}),f.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[f.jsx("button",{onClick:I,disabled:C||!d.trim()||!p.trim()||!x,className:Ui,children:e(C?"dashboard.creating":"dashboard.create")}),T&&f.jsx("span",{className:"font-mono text-[10px] text-error",children:T})]})]}),f.jsx("div",{className:"space-y-3",children:t.length===0?f.jsxs("div",{className:"text-center py-16",children:[f.jsx("span",{className:"text-3xl opacity-30",children:"🤖"}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface-variant mt-3",children:e("dashboard.noAgents")})]}):t.map(k=>f.jsx(IR,{agent:k,onDelete:()=>z(k.id,k.name)},k.id))})]})}function FR(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const $R=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,zR=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,BR={};function Yy(e,t){return(BR.jsx?zR:$R).test(e)}const WR=/[ \t\n\f\r]/g;function HR(e){return typeof e=="object"?e.type==="text"?Xy(e.value):!1:Xy(e)}function Xy(e){return e.replace(WR,"")===""}class xl{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}xl.prototype.normal={};xl.prototype.property={};xl.prototype.space=void 0;function cS(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new xl(n,r,t)}function Lp(e){return e.toLowerCase()}class Zt{constructor(t,n){this.attribute=n,this.property=t}}Zt.prototype.attribute="";Zt.prototype.booleanish=!1;Zt.prototype.boolean=!1;Zt.prototype.commaOrSpaceSeparated=!1;Zt.prototype.commaSeparated=!1;Zt.prototype.defined=!1;Zt.prototype.mustUseProperty=!1;Zt.prototype.number=!1;Zt.prototype.overloadedBoolean=!1;Zt.prototype.property="";Zt.prototype.spaceSeparated=!1;Zt.prototype.space=void 0;let VR=0;const fe=as(),st=as(),Ip=as(),H=as(),Le=as(),Gs=as(),nn=as();function as(){return 2**++VR}const Op=Object.freeze(Object.defineProperty({__proto__:null,boolean:fe,booleanish:st,commaOrSpaceSeparated:nn,commaSeparated:Gs,number:H,overloadedBoolean:Ip,spaceSeparated:Le},Symbol.toStringTag,{value:"Module"})),Nf=Object.keys(Op);class Cm extends Zt{constructor(t,n,r,i){let s=-1;if(super(t,n),Jy(this,"space",i),typeof r=="number")for(;++s<Nf.length;){const o=Nf[s];Jy(this,Nf[s],(r&Op[o])===Op[o])}}}Cm.prototype.defined=!0;function Jy(e,t,n){n&&(e[t]=n)}function xo(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Cm(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Lp(r)]=r,n[Lp(s.attribute)]=r}return new xl(t,n,e.space)}const uS=xo({properties:{ariaActiveDescendant:null,ariaAtomic:st,ariaAutoComplete:null,ariaBusy:st,ariaChecked:st,ariaColCount:H,ariaColIndex:H,ariaColSpan:H,ariaControls:Le,ariaCurrent:null,ariaDescribedBy:Le,ariaDetails:null,ariaDisabled:st,ariaDropEffect:Le,ariaErrorMessage:null,ariaExpanded:st,ariaFlowTo:Le,ariaGrabbed:st,ariaHasPopup:null,ariaHidden:st,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Le,ariaLevel:H,ariaLive:null,ariaModal:st,ariaMultiLine:st,ariaMultiSelectable:st,ariaOrientation:null,ariaOwns:Le,ariaPlaceholder:null,ariaPosInSet:H,ariaPressed:st,ariaReadOnly:st,ariaRelevant:null,ariaRequired:st,ariaRoleDescription:Le,ariaRowCount:H,ariaRowIndex:H,ariaRowSpan:H,ariaSelected:st,ariaSetSize:H,ariaSort:null,ariaValueMax:H,ariaValueMin:H,ariaValueNow:H,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function dS(e,t){return t in e?e[t]:t}function fS(e,t){return dS(e,t.toLowerCase())}const UR=xo({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Gs,acceptCharset:Le,accessKey:Le,action:null,allow:null,allowFullScreen:fe,allowPaymentRequest:fe,allowUserMedia:fe,alt:null,as:null,async:fe,autoCapitalize:null,autoComplete:Le,autoFocus:fe,autoPlay:fe,blocking:Le,capture:null,charSet:null,checked:fe,cite:null,className:Le,cols:H,colSpan:null,content:null,contentEditable:st,controls:fe,controlsList:Le,coords:H|Gs,crossOrigin:null,data:null,dateTime:null,decoding:null,default:fe,defer:fe,dir:null,dirName:null,disabled:fe,download:Ip,draggable:st,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:fe,formTarget:null,headers:Le,height:H,hidden:Ip,high:H,href:null,hrefLang:null,htmlFor:Le,httpEquiv:Le,id:null,imageSizes:null,imageSrcSet:null,inert:fe,inputMode:null,integrity:null,is:null,isMap:fe,itemId:null,itemProp:Le,itemRef:Le,itemScope:fe,itemType:Le,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:fe,low:H,manifest:null,max:null,maxLength:H,media:null,method:null,min:null,minLength:H,multiple:fe,muted:fe,name:null,nonce:null,noModule:fe,noValidate:fe,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:fe,optimum:H,pattern:null,ping:Le,placeholder:null,playsInline:fe,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:fe,referrerPolicy:null,rel:Le,required:fe,reversed:fe,rows:H,rowSpan:H,sandbox:Le,scope:null,scoped:fe,seamless:fe,selected:fe,shadowRootClonable:fe,shadowRootDelegatesFocus:fe,shadowRootMode:null,shape:null,size:H,sizes:null,slot:null,span:H,spellCheck:st,src:null,srcDoc:null,srcLang:null,srcSet:null,start:H,step:null,style:null,tabIndex:H,target:null,title:null,translate:null,type:null,typeMustMatch:fe,useMap:null,value:st,width:H,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Le,axis:null,background:null,bgColor:null,border:H,borderColor:null,bottomMargin:H,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:fe,declare:fe,event:null,face:null,frame:null,frameBorder:null,hSpace:H,leftMargin:H,link:null,longDesc:null,lowSrc:null,marginHeight:H,marginWidth:H,noResize:fe,noHref:fe,noShade:fe,noWrap:fe,object:null,profile:null,prompt:null,rev:null,rightMargin:H,rules:null,scheme:null,scrolling:st,standby:null,summary:null,text:null,topMargin:H,valueType:null,version:null,vAlign:null,vLink:null,vSpace:H,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:fe,disableRemotePlayback:fe,prefix:null,property:null,results:H,security:null,unselectable:null},space:"html",transform:fS}),qR=xo({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:nn,accentHeight:H,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:H,amplitude:H,arabicForm:null,ascent:H,attributeName:null,attributeType:null,azimuth:H,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:H,by:null,calcMode:null,capHeight:H,className:Le,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:H,diffuseConstant:H,direction:null,display:null,dur:null,divisor:H,dominantBaseline:null,download:fe,dx:null,dy:null,edgeMode:null,editable:null,elevation:H,enableBackground:null,end:null,event:null,exponent:H,externalResourcesRequired:null,fill:null,fillOpacity:H,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Gs,g2:Gs,glyphName:Gs,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:H,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:H,horizOriginX:H,horizOriginY:H,id:null,ideographic:H,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:H,k:H,k1:H,k2:H,k3:H,k4:H,kernelMatrix:nn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:H,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:H,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:H,overlineThickness:H,paintOrder:null,panose1:null,path:null,pathLength:H,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Le,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:H,pointsAtY:H,pointsAtZ:H,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:nn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:nn,rev:nn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:nn,requiredFeatures:nn,requiredFonts:nn,requiredFormats:nn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:H,specularExponent:H,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:H,strikethroughThickness:H,string:null,stroke:null,strokeDashArray:nn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:H,strokeOpacity:H,strokeWidth:null,style:null,surfaceScale:H,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:nn,tabIndex:H,tableValues:null,target:null,targetX:H,targetY:H,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:nn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:H,underlineThickness:H,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:H,values:null,vAlphabetic:H,vMathematical:H,vectorEffect:null,vHanging:H,vIdeographic:H,version:null,vertAdvY:H,vertOriginX:H,vertOriginY:H,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:H,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:dS}),hS=xo({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),pS=xo({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:fS}),gS=xo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),GR={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},KR=/[A-Z]/g,Qy=/-[a-z]/g,YR=/^data[-\w.:]+$/i;function XR(e,t){const n=Lp(t);let r=t,i=Zt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&YR.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Qy,QR);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Qy.test(s)){let o=s.replace(KR,JR);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Cm}return new i(r,t)}function JR(e){return"-"+e.toLowerCase()}function QR(e){return e.charAt(1).toUpperCase()}const ZR=cS([uS,UR,hS,pS,gS],"html"),Em=cS([uS,qR,hS,pS,gS],"svg");function eD(e){return e.join(" ").trim()}var Nm={},Zy=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,tD=/\n/g,nD=/^\s*/,rD=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,iD=/^:\s*/,sD=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,oD=/^[;\s]*/,aD=/^\s+|\s+$/g,lD=`
93
93
  `,e0="/",t0="*",Ii="",cD="comment",uD="declaration";function dD(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function i(g){var m=g.match(tD);m&&(n+=m.length);var y=g.lastIndexOf(lD);r=~y?g.length-y:r+g.length}function s(){var g={line:n,column:r};return function(m){return m.position=new o(g),c(),m}}function o(g){this.start=g,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function a(g){var m=new Error(t.source+":"+n+":"+r+": "+g);if(m.reason=g,m.filename=t.source,m.line=n,m.column=r,m.source=e,!t.silent)throw m}function l(g){var m=g.exec(e);if(m){var y=m[0];return i(y),e=e.slice(y.length),m}}function c(){l(nD)}function u(g){var m;for(g=g||[];m=d();)m!==!1&&g.push(m);return g}function d(){var g=s();if(!(e0!=e.charAt(0)||t0!=e.charAt(1))){for(var m=2;Ii!=e.charAt(m)&&(t0!=e.charAt(m)||e0!=e.charAt(m+1));)++m;if(m+=2,Ii===e.charAt(m-1))return a("End of comment missing");var y=e.slice(2,m-2);return r+=2,i(y),e=e.slice(m),r+=2,g({type:cD,comment:y})}}function h(){var g=s(),m=l(rD);if(m){if(d(),!l(iD))return a("property missing ':'");var y=l(sD),x=g({type:uD,property:n0(m[0].replace(Zy,Ii)),value:y?n0(y[0].replace(Zy,Ii)):Ii});return l(oD),x}}function p(){var g=[];u(g);for(var m;m=h();)m!==!1&&(g.push(m),u(g));return g}return c(),p()}function n0(e){return e?e.replace(aD,Ii):Ii}var fD=dD,hD=Wc&&Wc.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Nm,"__esModule",{value:!0});Nm.default=gD;const pD=hD(fD);function gD(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,pD.default)(e),i=typeof t=="function";return r.forEach(s=>{if(s.type!=="declaration")return;const{property:o,value:a}=s;i?t(o,a,s):a&&(n=n||{},n[o]=a)}),n}var hd={};Object.defineProperty(hd,"__esModule",{value:!0});hd.camelCase=void 0;var mD=/^--[a-zA-Z0-9_-]+$/,xD=/-([a-z])/g,vD=/^[^-]+$/,yD=/^-(webkit|moz|ms|o|khtml)-/,bD=/^-(ms)-/,_D=function(e){return!e||vD.test(e)||mD.test(e)},wD=function(e,t){return t.toUpperCase()},r0=function(e,t){return"".concat(t,"-")},kD=function(e,t){return t===void 0&&(t={}),_D(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(bD,r0):e=e.replace(yD,r0),e.replace(xD,wD))};hd.camelCase=kD;var SD=Wc&&Wc.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},CD=SD(Nm),ED=hd;function Fp(e,t){var n={};return!e||typeof e!="string"||(0,CD.default)(e,function(r,i){r&&i&&(n[(0,ED.camelCase)(r,t)]=i)}),n}Fp.default=Fp;var ND=Fp;const jD=ug(ND),mS=xS("end"),jm=xS("start");function xS(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function PD(e){const t=jm(e),n=mS(e);if(t&&n)return{start:t,end:n}}function wa(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?i0(e.position):"start"in e||"end"in e?i0(e):"line"in e||"column"in e?$p(e):""}function $p(e){return s0(e&&e.line)+":"+s0(e&&e.column)}function i0(e){return $p(e&&e.start)+"-"+$p(e&&e.end)}function s0(e){return e&&typeof e=="number"?e:1}class Dt extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=wa(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Dt.prototype.file="";Dt.prototype.name="";Dt.prototype.reason="";Dt.prototype.message="";Dt.prototype.stack="";Dt.prototype.column=void 0;Dt.prototype.line=void 0;Dt.prototype.ancestors=void 0;Dt.prototype.cause=void 0;Dt.prototype.fatal=void 0;Dt.prototype.place=void 0;Dt.prototype.ruleId=void 0;Dt.prototype.source=void 0;const Pm={}.hasOwnProperty,TD=new Map,MD=/[A-Z]/g,RD=new Set(["table","tbody","thead","tfoot","tr"]),DD=new Set(["td","th"]),vS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function AD(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=WD(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=BD(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Em:ZR,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=yS(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function yS(e,t,n){if(t.type==="element")return LD(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return ID(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return FD(e,t,n);if(t.type==="mdxjsEsm")return OD(e,t);if(t.type==="root")return $D(e,t,n);if(t.type==="text")return zD(e,t)}function LD(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Em,e.schema=i),e.ancestors.push(t);const s=_S(e,t.tagName,!1),o=HD(e,t);let a=Mm(e,t);return RD.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!HR(l):!0})),bS(e,o,s,t),Tm(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function ID(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}nl(e,t.position)}function OD(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);nl(e,t.position)}function FD(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Em,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:_S(e,t.name,!0),o=VD(e,t),a=Mm(e,t);return bS(e,o,s,t),Tm(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function $D(e,t,n){const r={};return Tm(r,Mm(e,t)),e.create(t,e.Fragment,r,n)}function zD(e,t){return t.value}function bS(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Tm(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function BD(e,t,n){return r;function r(i,s,o,a){const c=Array.isArray(o.children)?n:t;return a?c(s,o,a):c(s,o)}}function WD(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=jm(r);return t(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function HD(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Pm.call(t.properties,i)){const s=UD(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&DD.has(t.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function VD(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else nl(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else nl(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Mm(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:TD;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const c=i.get(l)||0;o=l+"-"+c,i.set(l,c+1)}}const a=yS(e,s,o);a!==void 0&&n.push(a)}return n}function UD(e,t,n){const r=XR(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?FR(n):eD(n)),r.property==="style"){let i=typeof n=="object"?n:qD(e,String(n));return e.stylePropertyNameCase==="css"&&(i=GD(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?GR[r.property]||r.property:r.attribute,n]}}function qD(e,t){try{return jD(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Dt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=vS+"#cannot-parse-style-attribute",i}}function _S(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=Yy(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=Yy(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Pm.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);nl(e)}function nl(e,t){const n=new Dt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=vS+"#cannot-handle-mdx-estrees-without-createevaluater",n}function GD(e){const t={};let n;for(n in e)Pm.call(e,n)&&(t[KD(n)]=e[n]);return t}function KD(e){let t=e.replace(MD,YD);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function YD(e){return"-"+e.toLowerCase()}const jf={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},XD={};function Rm(e,t){const n=XD,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return wS(e,r,i)}function wS(e,t,n){if(JD(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return o0(e.children,t,n)}return Array.isArray(e)?o0(e,t,n):""}function o0(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=wS(e[i],t,n);return r.join("")}function JD(e){return!!(e&&typeof e=="object")}const a0=document.createElement("i");function Dm(e){const t="&"+e+";";a0.innerHTML=t;const n=a0.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function dn(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function wn(e,t){return e.length>0?(dn(e,e.length,0,t),e):t}const l0={}.hasOwnProperty;function kS(e){const t={};let n=-1;for(;++n<e.length;)QD(t,e[n]);return t}function QD(e,t){let n;for(n in t){const i=(l0.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){l0.call(i,o)||(i[o]=[]);const a=s[o];ZD(i[o],Array.isArray(a)?a:a?[a]:[])}}}function ZD(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);dn(e,0,0,r)}function SS(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function $n(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const $t=bi(/[A-Za-z]/),Pt=bi(/[\dA-Za-z]/),eA=bi(/[#-'*+\--9=?A-Z^-~]/);function Ru(e){return e!==null&&(e<32||e===127)}const zp=bi(/\d/),tA=bi(/[\dA-Fa-f]/),nA=bi(/[!-/:-@[-`{-~]/);function ae(e){return e!==null&&e<-2}function Ae(e){return e!==null&&(e<0||e===32)}function pe(e){return e===-2||e===-1||e===32}const pd=bi(new RegExp("\\p{P}|\\p{S}","u")),es=bi(/\s/);function bi(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function vo(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&Pt(e.charCodeAt(n+1))&&Pt(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function _e(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return pe(l)?(e.enter(n),a(l)):t(l)}function a(l){return pe(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const rA={tokenize:iA};function iA(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),_e(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return ae(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const sA={tokenize:oA},c0={tokenize:aA};function oA(e){const t=this,n=[];let r=0,i,s,o;return a;function a(b){if(r<n.length){const S=n[r];return t.containerState=S[1],e.attempt(S[0].continuation,l,c)(b)}return c(b)}function l(b){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();const S=t.events.length;let C=S,_;for(;C--;)if(t.events[C][0]==="exit"&&t.events[C][1].type==="chunkFlow"){_=t.events[C][1].end;break}x(r);let N=S;for(;N<t.events.length;)t.events[N][1].end={..._},N++;return dn(t.events,C+1,0,t.events.slice(S)),t.events.length=N,c(b)}return a(b)}function c(b){if(r===n.length){if(!i)return h(b);if(i.currentConstruct&&i.currentConstruct.concrete)return g(b);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(c0,u,d)(b)}function u(b){return i&&v(),x(r),h(b)}function d(b){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(b)}function h(b){return t.containerState={},e.attempt(c0,p,g)(b)}function p(b){return r++,n.push([t.currentConstruct,t.containerState]),h(b)}function g(b){if(b===null){i&&v(),x(0),e.consume(b);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),m(b)}function m(b){if(b===null){y(e.exit("chunkFlow"),!0),x(0),e.consume(b);return}return ae(b)?(e.consume(b),y(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(b),m)}function y(b,S){const C=t.sliceStream(b);if(S&&C.push(null),b.previous=s,s&&(s.next=b),s=b,i.defineSkip(b.start),i.write(C),t.parser.lazy[b.start.line]){let _=i.events.length;for(;_--;)if(i.events[_][1].start.offset<o&&(!i.events[_][1].end||i.events[_][1].end.offset>o))return;const N=t.events.length;let j=N,T,w;for(;j--;)if(t.events[j][0]==="exit"&&t.events[j][1].type==="chunkFlow"){if(T){w=t.events[j][1].end;break}T=!0}for(x(r),_=N;_<t.events.length;)t.events[_][1].end={...w},_++;dn(t.events,j+1,0,t.events.slice(N)),t.events.length=_}}function x(b){let S=n.length;for(;S-- >b;){const C=n[S];t.containerState=C[1],C[0].exit.call(t,e)}n.length=b}function v(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function aA(e,t,n){return _e(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ao(e){if(e===null||Ae(e)||es(e))return 1;if(pd(e))return 2}function gd(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const Bp={name:"attention",resolveAll:lA,tokenize:cA};function lA(e,t){let n=-1,r,i,s,o,a,l,c,u;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d={...e[r][1].end},h={...e[n][1].start};u0(d,-l),u0(h,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=wn(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=wn(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=wn(c,gd(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=wn(c,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,c=wn(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,dn(e,r-1,n-r+3,c),n=r+c.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function cA(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=ao(r);let s;return o;function o(l){return s=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===s)return e.consume(l),a;const c=e.exit("attentionSequence"),u=ao(l),d=!u||u===2&&i||n.includes(l),h=!i||i===2&&u||n.includes(r);return c._open=!!(s===42?d:d&&(i||!h)),c._close=!!(s===42?h:h&&(u||!d)),t(l)}}function u0(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const uA={name:"autolink",tokenize:dA};function dA(e,t,n){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return $t(p)?(e.consume(p),o):p===64?n(p):c(p)}function o(p){return p===43||p===45||p===46||Pt(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||Pt(p))&&r++<32?(e.consume(p),a):(r=0,c(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||Ru(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),u):eA(p)?(e.consume(p),c):n(p)}function u(p){return Pt(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,u):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):h(p)}function h(p){if((p===45||Pt(p))&&r++<63){const g=p===45?h:d;return e.consume(p),g}return n(p)}}const vl={partial:!0,tokenize:fA};function fA(e,t,n){return r;function r(s){return pe(s)?_e(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||ae(s)?t(s):n(s)}}const CS={continuation:{tokenize:pA},exit:gA,name:"blockQuote",tokenize:hA};function hA(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return pe(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function pA(e,t,n){const r=this;return i;function i(o){return pe(o)?_e(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(CS,t,n)(o)}}function gA(e){e.exit("blockQuote")}const ES={name:"characterEscape",tokenize:mA};function mA(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return nA(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const NS={name:"characterReference",tokenize:xA};function xA(e,t,n){const r=this;let i=0,s,o;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,o=Pt,u(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=tA,u):(e.enter("characterReferenceValue"),s=7,o=zp,u(d))}function u(d){if(d===59&&i){const h=e.exit("characterReferenceValue");return o===Pt&&!Dm(r.sliceSerialize(h))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(d)&&i++<s?(e.consume(d),u):n(d)}}const d0={partial:!0,tokenize:yA},f0={concrete:!0,name:"codeFenced",tokenize:vA};function vA(e,t,n){const r=this,i={partial:!0,tokenize:C};let s=0,o=0,a;return l;function l(_){return c(_)}function c(_){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,a=_,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(_)}function u(_){return _===a?(o++,e.consume(_),u):o<3?n(_):(e.exit("codeFencedFenceSequence"),pe(_)?_e(e,d,"whitespace")(_):d(_))}function d(_){return _===null||ae(_)?(e.exit("codeFencedFence"),r.interrupt?t(_):e.check(d0,m,S)(_)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(_))}function h(_){return _===null||ae(_)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(_)):pe(_)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),_e(e,p,"whitespace")(_)):_===96&&_===a?n(_):(e.consume(_),h)}function p(_){return _===null||ae(_)?d(_):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(_))}function g(_){return _===null||ae(_)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(_)):_===96&&_===a?n(_):(e.consume(_),g)}function m(_){return e.attempt(i,S,y)(_)}function y(_){return e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),x}function x(_){return s>0&&pe(_)?_e(e,v,"linePrefix",s+1)(_):v(_)}function v(_){return _===null||ae(_)?e.check(d0,m,S)(_):(e.enter("codeFlowValue"),b(_))}function b(_){return _===null||ae(_)?(e.exit("codeFlowValue"),v(_)):(e.consume(_),b)}function S(_){return e.exit("codeFenced"),t(_)}function C(_,N,j){let T=0;return w;function w($){return _.enter("lineEnding"),_.consume($),_.exit("lineEnding"),M}function M($){return _.enter("codeFencedFence"),pe($)?_e(_,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)($):D($)}function D($){return $===a?(_.enter("codeFencedFenceSequence"),F($)):j($)}function F($){return $===a?(T++,_.consume($),F):T>=o?(_.exit("codeFencedFenceSequence"),pe($)?_e(_,B,"whitespace")($):B($)):j($)}function B($){return $===null||ae($)?(_.exit("codeFencedFence"),N($)):j($)}}}function yA(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Pf={name:"codeIndented",tokenize:_A},bA={partial:!0,tokenize:wA};function _A(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),_e(e,s,"linePrefix",5)(c)}function s(c){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?o(c):n(c)}function o(c){return c===null?l(c):ae(c)?e.attempt(bA,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||ae(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function wA(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):ae(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):_e(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):ae(o)?i(o):n(o)}}const kA={name:"codeText",previous:CA,resolve:SA,tokenize:EA};function SA(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function CA(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function EA(e,t,n){let r=0,i,s;return o;function o(d){return e.enter("codeText"),e.enter("codeTextSequence"),a(d)}function a(d){return d===96?(e.consume(d),r++,a):(e.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),l):d===96?(s=e.enter("codeTextSequence"),i=0,u(d)):ae(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(d))}function c(d){return d===null||d===32||d===96||ae(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),c)}function u(d){return d===96?(e.consume(d),i++,u):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(s.type="codeTextData",c(d))}}class NA{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&$o(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),$o(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),$o(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);$o(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);$o(this.left,n.reverse())}}}function $o(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function jS(e){const t={};let n=-1,r,i,s,o,a,l,c;const u=new NA(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type==="chunkFlow"&&u.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,jA(u,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=u.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},a=u.slice(i,n),a.unshift(r),u.splice(i,n-i+1,a))}}return dn(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function jA(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],c={};let u,d,h=-1,p=n,g=0,m=0;const y=[m];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++h<a.length;)a[h][0]==="exit"&&a[h-1][0]==="enter"&&a[h][1].type===a[h-1][1].type&&a[h][1].start.line!==a[h][1].end.line&&(m=h+1,y.push(m),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):y.pop(),h=y.length;h--;){const x=a.slice(y[h],y[h+1]),v=s.pop();l.push([v,v+x.length-1]),e.splice(v,2,x)}for(l.reverse(),h=-1;++h<l.length;)c[g+l[h][0]]=g+l[h][1],g+=l[h][1]-l[h][0]-1;return c}const PA={resolve:MA,tokenize:RA},TA={partial:!0,tokenize:DA};function MA(e){return jS(e),e}function RA(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):ae(a)?e.check(TA,o,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function DA(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),_e(e,s,"linePrefix")}function s(o){if(o===null||ae(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function PS(e,t,n,r,i,s,o,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return d;function d(x){return x===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(x),e.exit(s),h):x===null||x===32||x===41||Ru(x)?n(x):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),m(x))}function h(x){return x===62?(e.enter(s),e.consume(x),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===62?(e.exit("chunkString"),e.exit(a),h(x)):x===null||x===60||ae(x)?n(x):(e.consume(x),x===92?g:p)}function g(x){return x===60||x===62||x===92?(e.consume(x),p):p(x)}function m(x){return!u&&(x===null||x===41||Ae(x))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(x)):u<c&&x===40?(e.consume(x),u++,m):x===41?(e.consume(x),u--,m):x===null||x===32||x===40||Ru(x)?n(x):(e.consume(x),x===92?y:m)}function y(x){return x===40||x===41||x===92?(e.consume(x),m):m(x)}}function TS(e,t,n,r,i,s){const o=this;let a=0,l;return c;function c(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),u}function u(p){return a>999||p===null||p===91||p===93&&!l||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):ae(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||ae(p)||a++>999?(e.exit("chunkString"),u(p)):(e.consume(p),l||(l=!pe(p)),p===92?h:d)}function h(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function MS(e,t,n,r,i,s){let o;return a;function a(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),o=h===40?41:h,l):n(h)}function l(h){return h===o?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(s),c(h))}function c(h){return h===o?(e.exit(s),l(o)):h===null?n(h):ae(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),_e(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(h))}function u(h){return h===o||h===null||ae(h)?(e.exit("chunkString"),c(h)):(e.consume(h),h===92?d:u)}function d(h){return h===o||h===92?(e.consume(h),u):u(h)}}function ka(e,t){let n;return r;function r(i){return ae(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):pe(i)?_e(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const AA={name:"definition",tokenize:IA},LA={partial:!0,tokenize:OA};function IA(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return TS.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=$n(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return Ae(p)?ka(e,c)(p):c(p)}function c(p){return PS(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function u(p){return e.attempt(LA,d,d)(p)}function d(p){return pe(p)?_e(e,h,"whitespace")(p):h(p)}function h(p){return p===null||ae(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function OA(e,t,n){return r;function r(a){return Ae(a)?ka(e,i)(a):n(a)}function i(a){return MS(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return pe(a)?_e(e,o,"whitespace")(a):o(a)}function o(a){return a===null||ae(a)?t(a):n(a)}}const FA={name:"hardBreakEscape",tokenize:$A};function $A(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return ae(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const zA={name:"headingAtx",resolve:BA,tokenize:WA};function BA(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},dn(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function WA(e,t,n){let r=0;return i;function i(u){return e.enter("atxHeading"),s(u)}function s(u){return e.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&r++<6?(e.consume(u),o):u===null||Ae(u)?(e.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||ae(u)?(e.exit("atxHeading"),t(u)):pe(u)?_e(e,a,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||Ae(u)?(e.exit("atxHeadingText"),a(u)):(e.consume(u),c)}}const HA=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],h0=["pre","script","style","textarea"],VA={concrete:!0,name:"htmlFlow",resolveTo:GA,tokenize:KA},UA={partial:!0,tokenize:XA},qA={partial:!0,tokenize:YA};function GA(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function KA(e,t,n){const r=this;let i,s,o,a,l;return c;function c(P){return u(P)}function u(P){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(P),d}function d(P){return P===33?(e.consume(P),h):P===47?(e.consume(P),s=!0,m):P===63?(e.consume(P),i=3,r.interrupt?t:k):$t(P)?(e.consume(P),o=String.fromCharCode(P),y):n(P)}function h(P){return P===45?(e.consume(P),i=2,p):P===91?(e.consume(P),i=5,a=0,g):$t(P)?(e.consume(P),i=4,r.interrupt?t:k):n(P)}function p(P){return P===45?(e.consume(P),r.interrupt?t:k):n(P)}function g(P){const J="CDATA[";return P===J.charCodeAt(a++)?(e.consume(P),a===J.length?r.interrupt?t:D:g):n(P)}function m(P){return $t(P)?(e.consume(P),o=String.fromCharCode(P),y):n(P)}function y(P){if(P===null||P===47||P===62||Ae(P)){const J=P===47,oe=o.toLowerCase();return!J&&!s&&h0.includes(oe)?(i=1,r.interrupt?t(P):D(P)):HA.includes(o.toLowerCase())?(i=6,J?(e.consume(P),x):r.interrupt?t(P):D(P)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(P):s?v(P):b(P))}return P===45||Pt(P)?(e.consume(P),o+=String.fromCharCode(P),y):n(P)}function x(P){return P===62?(e.consume(P),r.interrupt?t:D):n(P)}function v(P){return pe(P)?(e.consume(P),v):w(P)}function b(P){return P===47?(e.consume(P),w):P===58||P===95||$t(P)?(e.consume(P),S):pe(P)?(e.consume(P),b):w(P)}function S(P){return P===45||P===46||P===58||P===95||Pt(P)?(e.consume(P),S):C(P)}function C(P){return P===61?(e.consume(P),_):pe(P)?(e.consume(P),C):b(P)}function _(P){return P===null||P===60||P===61||P===62||P===96?n(P):P===34||P===39?(e.consume(P),l=P,N):pe(P)?(e.consume(P),_):j(P)}function N(P){return P===l?(e.consume(P),l=null,T):P===null||ae(P)?n(P):(e.consume(P),N)}function j(P){return P===null||P===34||P===39||P===47||P===60||P===61||P===62||P===96||Ae(P)?C(P):(e.consume(P),j)}function T(P){return P===47||P===62||pe(P)?b(P):n(P)}function w(P){return P===62?(e.consume(P),M):n(P)}function M(P){return P===null||ae(P)?D(P):pe(P)?(e.consume(P),M):n(P)}function D(P){return P===45&&i===2?(e.consume(P),V):P===60&&i===1?(e.consume(P),Y):P===62&&i===4?(e.consume(P),L):P===63&&i===3?(e.consume(P),k):P===93&&i===5?(e.consume(P),z):ae(P)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(UA,U,F)(P)):P===null||ae(P)?(e.exit("htmlFlowData"),F(P)):(e.consume(P),D)}function F(P){return e.check(qA,B,U)(P)}function B(P){return e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),$}function $(P){return P===null||ae(P)?F(P):(e.enter("htmlFlowData"),D(P))}function V(P){return P===45?(e.consume(P),k):D(P)}function Y(P){return P===47?(e.consume(P),o="",I):D(P)}function I(P){if(P===62){const J=o.toLowerCase();return h0.includes(J)?(e.consume(P),L):D(P)}return $t(P)&&o.length<8?(e.consume(P),o+=String.fromCharCode(P),I):D(P)}function z(P){return P===93?(e.consume(P),k):D(P)}function k(P){return P===62?(e.consume(P),L):P===45&&i===2?(e.consume(P),k):D(P)}function L(P){return P===null||ae(P)?(e.exit("htmlFlowData"),U(P)):(e.consume(P),L)}function U(P){return e.exit("htmlFlow"),t(P)}}function YA(e,t,n){const r=this;return i;function i(o){return ae(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function XA(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(vl,t,n)}}const JA={name:"htmlText",tokenize:QA};function QA(e,t,n){const r=this;let i,s,o;return a;function a(k){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(k),l}function l(k){return k===33?(e.consume(k),c):k===47?(e.consume(k),C):k===63?(e.consume(k),b):$t(k)?(e.consume(k),j):n(k)}function c(k){return k===45?(e.consume(k),u):k===91?(e.consume(k),s=0,g):$t(k)?(e.consume(k),v):n(k)}function u(k){return k===45?(e.consume(k),p):n(k)}function d(k){return k===null?n(k):k===45?(e.consume(k),h):ae(k)?(o=d,Y(k)):(e.consume(k),d)}function h(k){return k===45?(e.consume(k),p):d(k)}function p(k){return k===62?V(k):k===45?h(k):d(k)}function g(k){const L="CDATA[";return k===L.charCodeAt(s++)?(e.consume(k),s===L.length?m:g):n(k)}function m(k){return k===null?n(k):k===93?(e.consume(k),y):ae(k)?(o=m,Y(k)):(e.consume(k),m)}function y(k){return k===93?(e.consume(k),x):m(k)}function x(k){return k===62?V(k):k===93?(e.consume(k),x):m(k)}function v(k){return k===null||k===62?V(k):ae(k)?(o=v,Y(k)):(e.consume(k),v)}function b(k){return k===null?n(k):k===63?(e.consume(k),S):ae(k)?(o=b,Y(k)):(e.consume(k),b)}function S(k){return k===62?V(k):b(k)}function C(k){return $t(k)?(e.consume(k),_):n(k)}function _(k){return k===45||Pt(k)?(e.consume(k),_):N(k)}function N(k){return ae(k)?(o=N,Y(k)):pe(k)?(e.consume(k),N):V(k)}function j(k){return k===45||Pt(k)?(e.consume(k),j):k===47||k===62||Ae(k)?T(k):n(k)}function T(k){return k===47?(e.consume(k),V):k===58||k===95||$t(k)?(e.consume(k),w):ae(k)?(o=T,Y(k)):pe(k)?(e.consume(k),T):V(k)}function w(k){return k===45||k===46||k===58||k===95||Pt(k)?(e.consume(k),w):M(k)}function M(k){return k===61?(e.consume(k),D):ae(k)?(o=M,Y(k)):pe(k)?(e.consume(k),M):T(k)}function D(k){return k===null||k===60||k===61||k===62||k===96?n(k):k===34||k===39?(e.consume(k),i=k,F):ae(k)?(o=D,Y(k)):pe(k)?(e.consume(k),D):(e.consume(k),B)}function F(k){return k===i?(e.consume(k),i=void 0,$):k===null?n(k):ae(k)?(o=F,Y(k)):(e.consume(k),F)}function B(k){return k===null||k===34||k===39||k===60||k===61||k===96?n(k):k===47||k===62||Ae(k)?T(k):(e.consume(k),B)}function $(k){return k===47||k===62||Ae(k)?T(k):n(k)}function V(k){return k===62?(e.consume(k),e.exit("htmlTextData"),e.exit("htmlText"),t):n(k)}function Y(k){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),I}function I(k){return pe(k)?_e(e,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):z(k)}function z(k){return e.enter("htmlTextData"),o(k)}}const Am={name:"labelEnd",resolveAll:nL,resolveTo:rL,tokenize:iL},ZA={tokenize:sL},eL={tokenize:oL},tL={tokenize:aL};function nL(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&dn(e,0,e.length,n),e}function rL(e,t){let n=e.length,r=0,i,s,o,a;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},u={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",c,t]],a=wn(a,e.slice(s+1,s+r+3)),a=wn(a,[["enter",u,t]]),a=wn(a,gd(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=wn(a,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),a=wn(a,e.slice(o+1)),a=wn(a,[["exit",l,t]]),dn(e,s,e.length,a),e}function iL(e,t,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(h){return s?s._inactive?d(h):(o=r.parser.defined.includes($n(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),l):n(h)}function l(h){return h===40?e.attempt(ZA,u,o?u:d)(h):h===91?e.attempt(eL,u,o?c:d)(h):o?u(h):d(h)}function c(h){return e.attempt(tL,u,d)(h)}function u(h){return t(h)}function d(h){return s._balanced=!0,n(h)}}function sL(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return Ae(d)?ka(e,s)(d):s(d)}function s(d){return d===41?u(d):PS(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return Ae(d)?ka(e,l)(d):u(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?MS(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):u(d)}function c(d){return Ae(d)?ka(e,u)(d):u(d)}function u(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function oL(e,t,n){const r=this;return i;function i(a){return TS.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes($n(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function aL(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const lL={name:"labelStartImage",resolveAll:Am.resolveAll,tokenize:cL};function cL(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const uL={name:"labelStartLink",resolveAll:Am.resolveAll,tokenize:dL};function dL(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Tf={name:"lineEnding",tokenize:fL};function fL(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),_e(e,t,"linePrefix")}}const Pc={name:"thematicBreak",tokenize:hL};function hL(e,t,n){let r=0,i;return s;function s(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,a(c)}function a(c){return c===i?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||ae(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),pe(c)?_e(e,a,"whitespace")(c):a(c))}}const Vt={continuation:{tokenize:xL},exit:yL,name:"list",tokenize:mL},pL={partial:!0,tokenize:bL},gL={partial:!0,tokenize:vL};function mL(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(p){const g=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:zp(p)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(Pc,n,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return zp(p)&&++o<10?(e.consume(p),l):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):n(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(vl,r.interrupt?n:u,e.attempt(pL,h,d))}function u(p){return r.containerState.initialBlankLine=!0,s++,h(p)}function d(p){return pe(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),h):n(p)}function h(p){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function xL(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(vl,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,_e(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!pe(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(gL,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,_e(e,e.attempt(Vt,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function vL(e,t,n){const r=this;return _e(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function yL(e){e.exit(this.containerState.type)}function bL(e,t,n){const r=this;return _e(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!pe(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const p0={name:"setextUnderline",resolveTo:_L,tokenize:wL};function _L(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function wL(e,t,n){const r=this;let i;return s;function s(c){let u=r.events.length,d;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){d=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=c,o(c)):n(c)}function o(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),pe(c)?_e(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||ae(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const kL={tokenize:SL};function SL(e){const t=this,n=e.attempt(vl,r,e.attempt(this.parser.constructs.flowInitial,i,_e(e,e.attempt(this.parser.constructs.flow,i,e.attempt(PA,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const CL={resolveAll:DS()},EL=RS("string"),NL=RS("text");function RS(e){return{resolveAll:DS(e==="text"?jL:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(u){return c(u)?s(u):a(u)}function a(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),l}function l(u){return c(u)?(n.exit("data"),s(u)):(n.consume(u),l)}function c(u){if(u===null)return!0;const d=i[u];let h=-1;if(d)for(;++h<d.length;){const p=d[h];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function DS(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function jL(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,o=-1,a=0,l;for(;s--;){const c=i[s];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(c===-2)l=!0,a++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const c={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const PL={42:Vt,43:Vt,45:Vt,48:Vt,49:Vt,50:Vt,51:Vt,52:Vt,53:Vt,54:Vt,55:Vt,56:Vt,57:Vt,62:CS},TL={91:AA},ML={[-2]:Pf,[-1]:Pf,32:Pf},RL={35:zA,42:Pc,45:[p0,Pc],60:VA,61:p0,95:Pc,96:f0,126:f0},DL={38:NS,92:ES},AL={[-5]:Tf,[-4]:Tf,[-3]:Tf,33:lL,38:NS,42:Bp,60:[uA,JA],91:uL,92:[FA,ES],93:Am,95:Bp,96:kA},LL={null:[Bp,CL]},IL={null:[42,95]},OL={null:[]},FL=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:IL,contentInitial:TL,disable:OL,document:PL,flow:RL,flowInitial:ML,insideSpan:LL,string:DL,text:AL},Symbol.toStringTag,{value:"Module"}));function $L(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:N(C),check:N(_),consume:v,enter:b,exit:S,interrupt:N(_,{interrupt:!0})},c={code:null,containerState:{},defineSkip:m,events:[],now:g,parser:e,previous:null,sliceSerialize:h,sliceStream:p,write:d};let u=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function d(M){return o=wn(o,M),y(),o[o.length-1]!==null?[]:(j(t,0),c.events=gd(s,c.events,c),c.events)}function h(M,D){return BL(p(M),D)}function p(M){return zL(o,M)}function g(){const{_bufferIndex:M,_index:D,line:F,column:B,offset:$}=r;return{_bufferIndex:M,_index:D,line:F,column:B,offset:$}}function m(M){i[M.line]=M.column,w()}function y(){let M;for(;r._index<o.length;){const D=o[r._index];if(typeof D=="string")for(M=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===M&&r._bufferIndex<D.length;)x(D.charCodeAt(r._bufferIndex));else x(D)}}function x(M){u=u(M)}function v(M){ae(M)?(r.line++,r.column=1,r.offset+=M===-3?2:1,w()):M!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=M}function b(M,D){const F=D||{};return F.type=M,F.start=g(),c.events.push(["enter",F,c]),a.push(F),F}function S(M){const D=a.pop();return D.end=g(),c.events.push(["exit",D,c]),D}function C(M,D){j(M,D.from)}function _(M,D){D.restore()}function N(M,D){return F;function F(B,$,V){let Y,I,z,k;return Array.isArray(B)?U(B):"tokenize"in B?U([B]):L(B);function L(le){return R;function R(se){const ne=se!==null&&le[se],je=se!==null&&le.null,Ze=[...Array.isArray(ne)?ne:ne?[ne]:[],...Array.isArray(je)?je:je?[je]:[]];return U(Ze)(se)}}function U(le){return Y=le,I=0,le.length===0?V:P(le[I])}function P(le){return R;function R(se){return k=T(),z=le,le.partial||(c.currentConstruct=le),le.name&&c.parser.constructs.disable.null.includes(le.name)?oe():le.tokenize.call(D?Object.assign(Object.create(c),D):c,l,J,oe)(se)}}function J(le){return M(z,k),$}function oe(le){return k.restore(),++I<Y.length?P(Y[I]):V}}}function j(M,D){M.resolveAll&&!s.includes(M)&&s.push(M),M.resolve&&dn(c.events,D,c.events.length-D,M.resolve(c.events.slice(D),c)),M.resolveTo&&(c.events=M.resolveTo(c.events,c))}function T(){const M=g(),D=c.previous,F=c.currentConstruct,B=c.events.length,$=Array.from(a);return{from:B,restore:V};function V(){r=M,c.previous=D,c.currentConstruct=F,c.events.length=B,a=$,w()}}function w(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function zL(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function BL(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
@@ -119,7 +119,7 @@ Enter a new id for the imported agent:`,""))==null?void 0:P.trim();if(!R){j(!1);
119
119
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:h,table:o,tableCell:l,tableRow:a}};function o(p,g,m,y){return c(u(p,m,y),p.align)}function a(p,g,m,y){const x=d(p,m,y),v=c([x]);return v.slice(0,v.indexOf(`
120
120
  `))}function l(p,g,m,y){const x=m.enter("tableCell"),v=m.enter("phrasing"),b=m.containerPhrasing(p,{...y,before:s,after:s});return v(),x(),b}function c(p,g){return eF(p,{align:g,alignDelimiters:r,padding:n,stringLength:i})}function u(p,g,m){const y=p.children;let x=-1;const v=[],b=g.enter("table");for(;++x<y.length;)v[x]=d(y[x],g,m);return b(),v}function d(p,g,m){const y=p.children;let x=-1;const v=[],b=g.enter("tableRow");for(;++x<y.length;)v[x]=l(y[x],p,g,m);return b(),v}function h(p,g,m){let y=oC.inlineCode(p,g,m);return m.stack.includes("tableCell")&&(y=y.replace(/\|/g,"\\$&")),y}}function BF(){return{exit:{taskListCheckValueChecked:W0,taskListCheckValueUnchecked:W0,paragraph:HF}}}function WF(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:VF}}}function W0(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function HF(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function VF(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=oC.listItem(e,t,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+o}}function UF(){return[kO(),VO(),KO(),AF(),BF()]}function qF(e){return{extensions:[SO(),UO(e),YO(),zF(e),WF()]}}const GF={tokenize:ZF,partial:!0},aC={tokenize:e$,partial:!0},lC={tokenize:t$,partial:!0},cC={tokenize:n$,partial:!0},KF={tokenize:r$,partial:!0},uC={name:"wwwAutolink",tokenize:JF,previous:fC},dC={name:"protocolAutolink",tokenize:QF,previous:hC},Mr={name:"emailAutolink",tokenize:XF,previous:pC},or={};function YF(){return{text:or}}let Ei=48;for(;Ei<123;)or[Ei]=Mr,Ei++,Ei===58?Ei=65:Ei===91&&(Ei=97);or[43]=Mr;or[45]=Mr;or[46]=Mr;or[95]=Mr;or[72]=[Mr,dC];or[104]=[Mr,dC];or[87]=[Mr,uC];or[119]=[Mr,uC];function XF(e,t,n){const r=this;let i,s;return o;function o(d){return!qp(d)||!pC.call(r,r.previous)||Hm(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(d))}function a(d){return qp(d)?(e.consume(d),a):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(KF,u,c)(d):d===45||d===95||Pt(d)?(s=!0,e.consume(d),l):u(d)}function c(d){return e.consume(d),i=!0,l}function u(d){return s&&i&&$t(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function JF(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!fC.call(r,r.previous)||Hm(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(GF,e.attempt(aC,e.attempt(lC,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function QF(e,t,n){const r=this;let i="",s=!1;return o;function o(d){return(d===72||d===104)&&hC.call(r,r.previous)&&!Hm(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),a):n(d)}function a(d){if($t(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),a;if(d===58){const h=i.toLowerCase();if(h==="http"||h==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),s?c:(s=!0,l)):n(d)}function c(d){return d===null||Ru(d)||Ae(d)||es(d)||pd(d)?n(d):e.attempt(aC,e.attempt(lC,u),n)(d)}function u(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function ZF(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function e$(e,t,n){let r,i,s;return o;function o(c){return c===46||c===95?e.check(cC,l,a)(c):c===null||Ae(c)||es(c)||c!==45&&pd(c)?l(c):(s=!0,e.consume(c),o)}function a(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),o}function l(c){return i||r||!s?n(c):t(c)}}function t$(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(cC,t,s)(o):o===null||Ae(o)||es(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function n$(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),i):a===60||a===null||Ae(a)||es(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||Ae(a)||es(a)?t(a):r(a)}function s(a){return $t(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):$t(a)?(e.consume(a),o):n(a)}}function r$(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return Pt(s)?n(s):t(s)}}function fC(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Ae(e)}function hC(e){return!$t(e)}function pC(e){return!(e===47||qp(e))}function qp(e){return e===43||e===45||e===46||e===95||Pt(e)}function Hm(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const i$={tokenize:f$,partial:!0};function s$(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:c$,continuation:{tokenize:u$},exit:d$}},text:{91:{name:"gfmFootnoteCall",tokenize:l$},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:o$,resolveTo:a$}}}}function o$(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const c=$n(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function a$(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function l$(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(d){if(s>999||d===93&&!o||d===null||d===91||Ae(d))return n(d);if(d===93){e.exit("chunkString");const h=e.exit("gfmFootnoteCallString");return i.includes($n(r.sliceSerialize(h)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return Ae(d)||(o=!0),s++,e.consume(d),d===92?u:c}function u(d){return d===91||d===92||d===93?(e.consume(d),s++,c):c(d)}}function c$(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(g)}function u(g){if(o>999||g===93&&!a||g===null||g===91||Ae(g))return n(g);if(g===93){e.exit("chunkString");const m=e.exit("gfmFootnoteDefinitionLabelString");return s=$n(r.sliceSerialize(m)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),h}return Ae(g)||(a=!0),o++,e.consume(g),g===92?d:u}function d(g){return g===91||g===92||g===93?(e.consume(g),o++,u):u(g)}function h(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),i.includes(s)||i.push(s),_e(e,p,"gfmFootnoteDefinitionWhitespace")):n(g)}function p(g){return t(g)}}function u$(e,t,n){return e.check(vl,t,e.attempt(i$,t,n))}function d$(e){e.exit("gfmFootnoteDefinition")}function f$(e,t,n){const r=this;return _e(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function h$(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},d={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},h=[["enter",u,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",d,a]],p=a.parser.constructs.insideSpan.null;p&&dn(h,h.length,0,gd(p,o.slice(c+1,l),a)),dn(h,h.length,0,[["exit",d,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",u,a]]),dn(o,c-1,l-c+3,h),l=c+h.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const c=this.previous,u=this.events;let d=0;return h;function h(g){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(g):(o.enter("strikethroughSequenceTemporary"),p(g))}function p(g){const m=ao(c);if(g===126)return d>1?l(g):(o.consume(g),d++,p);if(d<2&&!n)return l(g);const y=o.exit("strikethroughSequenceTemporary"),x=ao(g);return y._open=!x||x===2&&!!m,y._close=!m||m===2&&!!x,a(g)}}}class p${constructor(){this.map=[]}add(t,n,r){g$(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function g$(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function m$(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function x$(){return{flow:{null:{name:"table",tokenize:v$,resolveAll:y$}}}}function v$(e,t,n){const r=this;let i=0,s=0,o;return a;function a(w){let M=r.events.length-1;for(;M>-1;){const B=r.events[M][1].type;if(B==="lineEnding"||B==="linePrefix")M--;else break}const D=M>-1?r.events[M][1].type:null,F=D==="tableHead"||D==="tableRow"?_:l;return F===_&&r.parser.lazy[r.now().line]?n(w):F(w)}function l(w){return e.enter("tableHead"),e.enter("tableRow"),c(w)}function c(w){return w===124||(o=!0,s+=1),u(w)}function u(w){return w===null?n(w):ae(w)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),p):n(w):pe(w)?_e(e,u,"whitespace")(w):(s+=1,o&&(o=!1,i+=1),w===124?(e.enter("tableCellDivider"),e.consume(w),e.exit("tableCellDivider"),o=!0,u):(e.enter("data"),d(w)))}function d(w){return w===null||w===124||Ae(w)?(e.exit("data"),u(w)):(e.consume(w),w===92?h:d)}function h(w){return w===92||w===124?(e.consume(w),d):d(w)}function p(w){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(w):(e.enter("tableDelimiterRow"),o=!1,pe(w)?_e(e,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(w):g(w))}function g(w){return w===45||w===58?y(w):w===124?(o=!0,e.enter("tableCellDivider"),e.consume(w),e.exit("tableCellDivider"),m):C(w)}function m(w){return pe(w)?_e(e,y,"whitespace")(w):y(w)}function y(w){return w===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(w),e.exit("tableDelimiterMarker"),x):w===45?(s+=1,x(w)):w===null||ae(w)?S(w):C(w)}function x(w){return w===45?(e.enter("tableDelimiterFiller"),v(w)):C(w)}function v(w){return w===45?(e.consume(w),v):w===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(w),e.exit("tableDelimiterMarker"),b):(e.exit("tableDelimiterFiller"),b(w))}function b(w){return pe(w)?_e(e,S,"whitespace")(w):S(w)}function S(w){return w===124?g(w):w===null||ae(w)?!o||i!==s?C(w):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(w)):C(w)}function C(w){return n(w)}function _(w){return e.enter("tableRow"),N(w)}function N(w){return w===124?(e.enter("tableCellDivider"),e.consume(w),e.exit("tableCellDivider"),N):w===null||ae(w)?(e.exit("tableRow"),t(w)):pe(w)?_e(e,N,"whitespace")(w):(e.enter("data"),j(w))}function j(w){return w===null||w===124||Ae(w)?(e.exit("data"),N(w)):(e.consume(w),w===92?T:j)}function T(w){return w===92||w===124?(e.consume(w),j):j(w)}}function y$(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,c,u,d;const h=new p$;for(;++n<e.length;){const p=e[n],g=p[1];p[0]==="enter"?g.type==="tableHead"?(a=!1,l!==0&&(H0(h,t,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},h.add(n,0,[["enter",c,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,d=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,u={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},h.add(n,0,[["enter",u,t]])),i=g.type==="tableDelimiterRow"?2:u?3:1):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],d=Ql(h,t,s,i,void 0,d),s=[0,0,0,0]),o[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],d=Ql(h,t,s,i,void 0,d)),s=o,o=[s[1],n,0,0])):g.type==="tableHead"?(a=!0,l=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],d=Ql(h,t,s,i,n,d)):o[1]!==0&&(d=Ql(h,t,o,i,n,d)),i=0):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&H0(h,t,l,c,u),h.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=m$(t.events,n))}return e}function Ql(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},ws(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=ws(t.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=ws(t.events,n[2]),u=ws(t.events,n[3]),d={type:a,start:Object.assign({},c),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const h=t.events[n[2]],p=t.events[n[3]];if(h[1].end=Object.assign({},p[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,m=n[3]-n[2]-1;e.add(g,m,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return i!==void 0&&(s.end=Object.assign({},ws(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function H0(e,t,n,r,i){const s=[],o=ws(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function ws(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const b$={name:"tasklistCheck",tokenize:w$};function _$(){return{text:{91:b$}}}function w$(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return Ae(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return ae(l)?t(l):pe(l)?e.check({tokenize:k$},t,n)(l):n(l)}}function k$(e,t,n){return _e(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function S$(e){return kS([YF(),s$(),h$(e),x$(),_$()])}const C$={};function gC(e){const t=this,n=e||C$,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(S$(n)),s.push(UF()),o.push(qF(n))}function E$(e){US(e,[/\r?\n|\r/g,N$])}function N$(){return{type:"break"}}function j$(){return function(e){E$(e)}}let Mc=[];const Rc=[];function P$(e){Mc.some(t=>t.id===e.id)||(Mc=[...Mc,e],Rc.forEach(t=>t()))}function mC(){return Mc}function xC(e){return Rc.push(e),()=>{const t=Rc.indexOf(e);t>=0&&Rc.splice(t,1)}}function V0({title:e,icon:t,count:n,defaultOpen:r=!1,children:i,accentClass:s}){const[o,a]=E.useState(r);return f.jsxs("div",{className:`rounded-md overflow-hidden transition-colors ${o?"bg-surface-container-high":"bg-surface-container"}`,children:[f.jsxs("button",{onClick:()=>a(l=>!l),className:"w-full flex items-center gap-3 px-4 py-3 group transition-colors hover:brightness-110",children:[f.jsx("span",{className:"text-[13px] opacity-60 group-hover:opacity-100 transition-opacity",children:t}),f.jsx("span",{className:`text-[11px] uppercase tracking-[0.14em] font-medium flex-1 text-left ${s??"text-on-surface-variant"}`,children:e}),n!==void 0&&n>0&&f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/70 tabular-nums",children:n}),f.jsx("svg",{className:"w-3 h-3 text-on-surface-variant/70 transition-transform duration-200",style:{transform:o?"rotate(90deg)":"none"},viewBox:"0 0 16 16",fill:"currentColor",children:f.jsx("path",{d:"M6 3l5 5-5 5V3z"})})]}),f.jsx("div",{className:"grid transition-[grid-template-rows] duration-200",style:{gridTemplateRows:o?"1fr":"0fr"},children:f.jsx("div",{className:"overflow-hidden",children:f.jsx("div",{className:"px-4 pb-4 pt-0.5",children:i})})})]})}function xn({icon:e,label:t,active:n,onClick:r}){return f.jsxs("button",{onClick:r,className:`w-full rounded-md flex items-center gap-3 px-4 py-3 transition-colors ${n?"bg-surface-container-high border border-outline-variant/40 text-on-surface":"bg-surface-container-low text-on-surface-variant hover:bg-surface-container hover:text-on-surface"}`,children:[f.jsx("span",{className:"text-[13px]",children:e}),f.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] font-medium",children:t}),n&&f.jsx("span",{className:"ml-auto h-1.5 w-1.5 rounded-full bg-secondary"})]})}const Wf="rounded bg-surface-container px-2.5 py-[7px] text-[11px] text-on-surface placeholder:text-on-surface-variant/60 outline-none focus:ring-1 focus:ring-primary/25 font-mono transition-shadow";function T$({agentId:e,agent:t,agentDisplayName:n,connected:r,secretNames:i,setSecretNames:s,isWiping:o,isSending:a,onWipe:l,mainView:c,onViewChange:u}){const{t:d}=we(),[h,p]=E.useState({name:"",value:""}),g=E.useSyncExternalStore(xC,mC),m=i.includes(h.name);return f.jsxs("aside",{className:"w-72 flex-shrink-0 flex flex-col gap-1 overflow-y-auto pr-1 pb-4 scrollbar-thin",children:[f.jsx("div",{className:"rounded-md bg-surface-container-lowest border border-outline-variant/40 px-3 py-2.5 relative overflow-hidden",children:f.jsxs("div",{className:"flex items-center justify-between relative",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("p",{className:"font-headline text-[15px] font-semibold text-on-surface tracking-[-0.01em] truncate",children:n??t.name}),f.jsx("p",{className:"font-mono text-[9px] text-primary/50 mt-0.5 truncate",children:t.model})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:[f.jsx("span",{className:`font-mono text-[9px] ${r?"text-secondary/80":"text-on-surface-variant/70"}`,title:r?"WS connected":"WS disconnected",children:r?"●":"○"}),f.jsx("span",{className:`rounded-full px-1.5 py-[2px] text-[8px] font-semibold uppercase tracking-[0.1em]
121
121
  ${t.status==="active"?"bg-secondary-container text-on-primary":"bg-surface-container text-on-surface-variant/60"}`,children:t.status})]})]})}),f.jsx(xn,{icon:"💬",label:d("agentSettings.views.chat"),active:c==="chat",onClick:()=>u("chat")}),f.jsx(xn,{icon:"▦",label:d("agentSettings.views.tasks"),active:c==="tasks",onClick:()=>u("tasks")}),f.jsx(xn,{icon:"🧩",label:d("agentSettings.views.skills"),active:c==="skills",onClick:()=>u("skills")}),f.jsx(xn,{icon:"🌐",label:d("agentSettings.views.browser"),active:c==="browser",onClick:()=>u("browser")}),f.jsx(xn,{icon:"📂",label:d("agentSettings.views.files"),active:c==="files",onClick:()=>u("files")}),f.jsx(xn,{icon:"⚡",label:d("agentSettings.views.workflows"),active:c==="workflows",onClick:()=>u("workflows")}),f.jsx(xn,{icon:"⏰",label:d("agentSettings.views.schedules"),active:c==="schedules",onClick:()=>u("schedules")}),f.jsx(xn,{icon:"📡",label:d("agentSettings.views.monitor"),active:c==="monitor",onClick:()=>u("monitor")}),f.jsx(xn,{icon:"📊",label:d("agentSettings.views.usage"),active:c==="usage",onClick:()=>u("usage")}),f.jsx(xn,{icon:"📋",label:d("agentSettings.views.logs"),active:c==="logs",onClick:()=>u("logs")}),f.jsx(xn,{icon:"🔌",label:d("agentSettings.views.integrations"),active:c==="integrations",onClick:()=>u("integrations")}),g.map(y=>f.jsx(xn,{icon:y.icon,label:y.label,active:c===y.id,onClick:()=>u(y.id)},y.id)),f.jsxs("div",{"data-testid":"guardian-coming-soon",className:"w-full rounded-md flex items-center gap-3 px-4 py-3 bg-surface-container-lowest cursor-default opacity-50 relative",children:[f.jsx("span",{className:"text-[13px]",children:"🛡"}),f.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] font-medium text-on-surface-variant/70",children:d("agentSettings.views.guardian")}),f.jsx("span",{className:"ml-auto rounded-full bg-amber-400/10 border border-amber-400/20 px-1.5 py-[1px] font-mono text-[7px] text-warning uppercase tracking-widest",children:d("agentSettings.comingSoon")})]}),f.jsx("div",{className:"h-px bg-surface-container mx-2 my-1"}),f.jsx(V0,{title:d("agentSettings.secrets"),icon:f.jsx("span",{children:"🔐"}),count:i.length,children:f.jsxs("div",{className:"space-y-2.5",children:[i.length>0&&f.jsx("div",{className:"flex flex-col",children:i.map(y=>f.jsxs("div",{className:"group flex items-center justify-between py-[5px] px-2 -mx-2 rounded transition-colors hover:bg-surface-container/50",children:[f.jsxs("span",{className:`font-mono text-[11px] cursor-pointer transition-colors ${h.name===y?"text-primary":"text-on-surface/70 hover:text-primary/80"}`,onClick:()=>p({name:y,value:""}),title:"Click to update value",children:[f.jsx("span",{className:"text-on-surface-variant/60",children:"🔒 "}),y]}),f.jsx("button",{onClick:async()=>{await rS(e,y),s(x=>x.filter(v=>v!==y)),h.name===y&&p({name:"",value:""})},className:"text-[9px] text-transparent group-hover:text-on-surface-variant/70 hover:!text-error transition-colors flex-shrink-0 ml-2",title:`Remove ${y}`,children:"×"})]},y))}),i.length===0&&f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant italic",children:d("agentSettings.noSecrets")}),m?f.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.jsx("p",{className:"font-mono text-[9px] text-primary/50",children:d("agentSettings.updating",{name:h.name})}),f.jsxs("div",{className:"flex gap-1.5",children:[f.jsx("input",{type:"password",className:`${Wf} flex-1 min-w-0`,placeholder:d("agentSettings.newValue"),value:h.value,onChange:y=>p(x=>({...x,value:y.target.value}))}),f.jsx("button",{onClick:async()=>{h.value.trim()&&(await Rp(e,h.name.trim(),h.value.trim()),p({name:"",value:""}))},disabled:!h.value.trim(),className:"rounded bg-surface-container px-2.5 py-[7px] text-[11px] text-on-surface-variant transition-all disabled:opacity-20 hover:bg-surface-container hover:text-on-surface flex-shrink-0",children:d("agentSettings.save")}),f.jsx("button",{onClick:()=>p({name:"",value:""}),className:"rounded bg-surface-container px-2.5 py-[7px] text-[11px] text-on-surface-variant/60 hover:text-on-surface-variant/70 transition-colors flex-shrink-0",children:"×"})]})]}):f.jsxs("div",{className:"flex gap-1.5",children:[f.jsx("input",{className:`${Wf} flex-1 min-w-0`,placeholder:d("agentSettings.secretNamePlaceholder"),value:h.name,onChange:y=>p(x=>({...x,name:y.target.value}))}),f.jsx("input",{type:"password",className:`${Wf} flex-1 min-w-0`,placeholder:d("agentSettings.secretValuePlaceholder"),value:h.value,onChange:y=>p(x=>({...x,value:y.target.value}))}),f.jsx("button",{onClick:async()=>{!h.name.trim()||!h.value.trim()||(await Rp(e,h.name.trim(),h.value.trim()),s(y=>[...y.filter(x=>x!==h.name.trim()),h.name.trim()]),p({name:"",value:""}))},disabled:!h.name.trim()||!h.value.trim(),className:"rounded bg-surface-container px-2.5 py-[7px] text-[11px] text-on-surface-variant transition-all disabled:opacity-20 hover:bg-surface-container hover:text-on-surface flex-shrink-0",children:"+"})]})]})}),t.guardrails&&t.guardrails.length>0&&f.jsx(V0,{title:d("agentSettings.guardrails"),icon:f.jsx("span",{children:"🛡"}),count:t.guardrails.length,accentClass:"text-warning/60",children:f.jsxs("div",{className:"space-y-2.5",children:[f.jsx("div",{className:"flex flex-col gap-2",children:t.guardrails.map((y,x)=>f.jsxs("div",{className:"flex items-start gap-2.5",children:[f.jsx("span",{className:"text-amber-500/30 text-[8px] mt-[3px] select-none",children:"●"}),f.jsx("span",{className:"font-mono text-[11px] text-warning/50 leading-relaxed",children:y})]},x))}),f.jsx("p",{className:"font-mono text-[8px] text-on-surface-variant/20 uppercase tracking-[0.15em]",children:d("agentSettings.guardrailsBlurb")})]})}),f.jsxs("div",{className:"mt-auto pt-1 space-y-1",children:[f.jsx("a",{href:fR(e),download:!0,className:"block w-full rounded-md bg-surface-container-lowest px-3 py-2 font-mono text-[10px] text-on-surface-variant/70 transition-all hover:bg-surface-container-lowest border border-outline-variant/40 hover:text-on-surface-variant/70",title:d("agentSettings.exportTitle"),children:d("agentSettings.exportAgent")}),f.jsx("button",{onClick:l,disabled:o||a,className:"w-full rounded-md bg-surface-container-lowest px-3 py-2 text-left font-mono text-[10px] text-error/40 transition-all hover:bg-error/10 hover:text-error disabled:opacity-20",children:d(o?"agentSettings.wiping":"agentSettings.wipeAgent")})]})]})}function M$({agentId:e}){const{t}=we(),[n,r]=E.useState(""),[i,s]=E.useState([]),[o,a]=E.useState(null),[l,c]=E.useState(""),[u,d]=E.useState(""),[h,p]=E.useState(!1),[g,m]=E.useState(null),y=l!==u,x=E.useCallback(async _=>{try{m(null);const N=await YM(e,_);s(N),r(_),a(null),c(""),d("")}catch(N){m(String(N))}},[e]);E.useEffect(()=>{x("")},[x]);const v=async _=>{try{m(null);const N=await XM(e,_);a(_),c(N),d(N)}catch(N){m(String(N))}},b=async()=>{if(!(!o||!y)){p(!0);try{await JM(e,o,l),d(l)}catch(_){m(String(_))}finally{p(!1)}}},S=_=>{const N=n?`${n}/${_.name}`:_.name;_.type==="directory"?x(N):v(N)},C=n?n.split("/"):[];return f.jsxs("div",{className:"flex flex-1 flex-col rounded-md overflow-hidden min-w-0 bg-surface-container-high",children:[f.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 bg-surface-container",children:[f.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0 overflow-x-auto",children:[f.jsx("button",{onClick:()=>x(""),className:"font-mono text-[11px] text-primary/60 hover:text-primary transition-colors flex-shrink-0",children:t("files.workspace")}),C.map((_,N)=>f.jsxs("span",{className:"flex items-center gap-1 flex-shrink-0",children:[f.jsx("span",{className:"text-on-surface-variant/20 text-[10px]",children:"/"}),f.jsx("button",{onClick:()=>x(C.slice(0,N+1).join("/")),className:"font-mono text-[11px] text-on-surface-variant/60 hover:text-on-surface transition-colors",children:_})]},N)),o&&f.jsxs("span",{className:"flex items-center gap-1 flex-shrink-0",children:[f.jsx("span",{className:"text-on-surface-variant/20 text-[10px]",children:"/"}),f.jsx("span",{className:"font-mono text-[11px] text-on-surface",children:o.split("/").pop()}),y&&f.jsx("span",{className:"text-primary text-[9px]",children:"●"})]})]}),o&&f.jsx("button",{onClick:b,disabled:!y||h,className:`rounded px-3 py-1 text-[11px] font-medium transition-all disabled:opacity-20
122
- bg-primary/20 text-primary hover:bg-primary/30`,children:t(h?"files.savingLabel":"files.saveButton")}),o&&f.jsx("button",{onClick:()=>{a(null),c(""),d("")},className:"rounded px-2 py-1 text-[11px] text-on-surface-variant/70 hover:text-on-surface-variant transition-colors",children:"×"})]}),g&&f.jsx("div",{className:"px-4 py-2 bg-error/10",children:f.jsx("p",{className:"font-mono text-[10px] text-error/70",children:g})}),o?f.jsx("textarea",{className:"flex-1 w-full resize-none bg-transparent px-4 py-3 font-mono text-[12px] text-on-surface/90 leading-relaxed outline-none",style:{tabSize:2},value:l,onChange:_=>c(_.target.value),spellCheck:!1}):f.jsx("div",{className:"flex-1 overflow-y-auto",children:i.length===0?f.jsx("p",{className:"font-mono text-[11px] text-on-surface-variant/60 p-4 italic",children:t("files.emptyDir")}):f.jsxs("div",{className:"flex flex-col",children:[n&&f.jsxs("button",{onClick:()=>{const _=n.split("/").slice(0,-1).join("/");x(_)},className:"flex items-center gap-3 px-4 py-2 text-left transition-colors hover:bg-surface-container/50",children:[f.jsx("span",{className:"text-[13px] opacity-40",children:"↩"}),f.jsx("span",{className:"font-mono text-[11px] text-on-surface-variant",children:".."})]}),i.map(_=>f.jsxs("button",{onClick:()=>S(_),className:"group flex items-center gap-3 px-4 py-2 text-left transition-colors hover:bg-surface-container/50",children:[f.jsx("span",{className:"text-[13px] opacity-50 group-hover:opacity-80 transition-opacity",children:_.type==="directory"?"📁":"📄"}),f.jsx("span",{className:`font-mono text-[11px] flex-1 truncate ${_.type==="directory"?"text-primary/70":"text-on-surface/70"}`,children:_.name}),_.size!==void 0&&f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/25 tabular-nums",children:_.size<1024?`${_.size}B`:`${(_.size/1024).toFixed(1)}K`})]},_.name))]})})]})}function vC(){const{t:e}=we();return t=>{const n=Date.now()-t*1e3,r=Math.floor(n/1e3);if(r<60)return e("tasks.relativeNow");const i=Math.floor(r/60);if(i<60)return e("tasks.relativeMinutes",{n:i});const s=Math.floor(i/60);if(s<24)return e("tasks.relativeHours",{n:s});const o=Math.floor(s/24);return e("tasks.relativeDays",{n:o})}}const Hf="rounded bg-surface-container px-2.5 py-[7px] text-[11px] text-on-surface placeholder:text-on-surface-variant/60 outline-none focus:ring-1 focus:ring-primary/25 transition-shadow w-full";function Gp({source:e}){return f.jsx("span",{className:`rounded-full px-1.5 py-[2px] text-[8px] font-semibold uppercase tracking-[0.08em] ${e==="agent"?"bg-secondary-container text-on-primary":"bg-primary text-on-surface"}`,children:e})}function R$({comment:e}){const t=vC();return f.jsxs("div",{className:"flex flex-col gap-1 py-3",style:{borderTop:"1px solid rgba(255,255,255,0.04)"},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Gp,{source:e.source}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60",children:t(e.createdAt)})]}),f.jsx("div",{className:"text-[12px] text-on-surface/80 leading-relaxed prose prose-sm dark:prose-invert max-w-none",children:f.jsx(yd,{children:e.body})})]})}function D$({task:e,columns:t,onClose:n,onUpdate:r,onAddComment:i,onDelete:s}){const{t:o}=we(),a=vC(),[l,c]=E.useState(!1),[u,d]=E.useState(e.title),[h,p]=E.useState(!1),[g,m]=E.useState(e.description),[y,x]=E.useState(""),[v,b]=E.useState(!1),[S,C]=E.useState(!1),[_,N]=E.useState(!1),[j,T]=E.useState(""),[w,M]=E.useState(e.id);e.id!==w&&(M(e.id),d(e.title),m(e.description),c(!1),p(!1),x(""),T(""));const D=async()=>{if(c(!1),u.trim()&&u.trim()!==e.title){C(!0);try{await r(e.id,{title:u.trim()})}finally{C(!1)}}else d(e.title)},F=async()=>{if(p(!1),g!==e.description){C(!0);try{await r(e.id,{description:g})}finally{C(!1)}}},B=async k=>{C(!0);try{await r(e.id,{status:k})}finally{C(!1)}},$=async k=>{const L=k.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"");if(!(!L||e.tags.includes(L))){C(!0);try{await r(e.id,{tags:[...e.tags,L]})}finally{C(!1)}}},V=async k=>{C(!0);try{await r(e.id,{tags:e.tags.filter(L=>L!==k)})}finally{C(!1)}},Y=async()=>{if(y.trim()){b(!0);try{await i(e.id,y.trim()),x("")}finally{b(!1)}}},I=async()=>{if(confirm(o("taskDetail.deleteConfirm",{title:e.title}))){N(!0);try{await s(e.id)}finally{N(!1)}}},z=e.updatedBy!==null&&e.updatedBy!==e.source;return f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"fixed inset-0 z-40",style:{background:"rgba(0,0,0,0.35)"},onClick:n}),f.jsxs("div",{className:"fixed inset-y-0 right-0 w-[min(840px,92vw)] z-50 flex flex-col overflow-hidden bg-surface-container",style:{boxShadow:"-8px 0 40px rgba(0,0,0,0.5)"},children:[f.jsxs("div",{className:"flex items-center justify-between px-5 py-4 flex-shrink-0",style:{borderBottom:"1px solid rgba(255,255,255,0.05)"},children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx("span",{className:"font-mono text-[10px] text-primary/40 flex-shrink-0",children:e.id}),S&&f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60 animate-pulse",children:o("taskDetail.saving")})]}),f.jsx("button",{onClick:n,className:"text-on-surface-variant/70 hover:text-on-surface transition-colors text-[18px] leading-none flex-shrink-0","aria-label":o("taskDetail.close"),children:"×"})]}),f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsxs("div",{className:"px-5 py-4 flex flex-col gap-5",children:[f.jsx("div",{children:l?f.jsx("input",{autoFocus:!0,className:`${Hf} text-[15px] font-semibold font-headline`,value:u,onChange:k=>d(k.target.value),onBlur:D,onKeyDown:k=>{k.key==="Enter"&&D(),k.key==="Escape"&&(c(!1),d(e.title))}}):f.jsx("h2",{className:"font-headline text-[17px] font-semibold text-on-surface tracking-[-0.01em] cursor-pointer hover:text-primary/90 transition-colors",onClick:()=>c(!0),title:"Click to edit",children:e.title})}),f.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold",children:o("taskDetail.status")}),f.jsx("select",{value:e.status,onChange:k=>void B(k.target.value),className:"rounded bg-surface-container px-2.5 py-[7px] text-[11px] text-on-surface outline-none focus:ring-1 focus:ring-primary/25 cursor-pointer font-mono transition-shadow",children:t.map(k=>f.jsx("option",{value:k.id,children:k.label},k.id))})]}),f.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold",children:o("taskDetail.tags")}),f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.tags.map(k=>f.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-primary/10 px-2 py-[2px] text-[10px] font-mono text-primary/70",children:[k,f.jsx("button",{onClick:()=>void V(k),className:"text-primary/40 hover:text-error/70 transition-colors leading-none",children:"×"})]},k)),f.jsx("input",{className:"rounded bg-surface-container px-2 py-[4px] text-[10px] text-on-surface placeholder:text-on-surface-variant/40 outline-none focus:ring-1 focus:ring-primary/25 font-mono w-24",placeholder:o("taskDetail.addTag"),value:j,onChange:k=>T(k.target.value),onKeyDown:k=>{k.key==="Enter"&&j.trim()&&($(j),T("")),k.key==="Escape"&&T("")}})]})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"text-[8px] uppercase tracking-[0.15em] text-on-surface-variant/60",children:o("taskDetail.sourceLabel")}),f.jsx(Gp,{source:e.source})]}),z&&e.updatedBy&&f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"text-[8px] uppercase tracking-[0.15em] text-on-surface-variant/60",children:o("taskDetail.editedByLabel")}),f.jsx(Gp,{source:e.updatedBy})]})]}),f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsxs("p",{className:"font-mono text-[10px] text-on-surface-variant/60",children:[f.jsx("span",{className:"text-on-surface-variant/20",children:o("taskDetail.created")})," ",a(e.createdAt)]}),f.jsxs("p",{className:"font-mono text-[10px] text-on-surface-variant/60",children:[f.jsx("span",{className:"text-on-surface-variant/20",children:o("taskDetail.updated")})," ",a(e.updatedAt)]})]}),f.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold",children:o("taskDetail.description")}),h?f.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.jsx("textarea",{autoFocus:!0,className:`${Hf} min-h-[360px] resize-y font-mono text-[12px] leading-relaxed`,value:g,onChange:k=>m(k.target.value),placeholder:o("taskDetail.descPlaceholder")}),f.jsxs("div",{className:"flex gap-1.5",children:[f.jsx("button",{onClick:F,className:"flex-1 rounded bg-primary/15 px-2 py-1.5 text-[10px] text-primary/70 hover:bg-primary/25 transition-colors",children:o("taskDetail.save")}),f.jsx("button",{onClick:()=>{p(!1),m(e.description)},className:"rounded bg-surface-container px-2 py-1.5 text-[10px] text-on-surface-variant/70 hover:text-on-surface-variant/70 transition-colors",children:o("taskDetail.cancel")})]})]}):f.jsx("div",{className:"cursor-pointer group",onClick:()=>p(!0),title:"Click to edit",children:e.description?f.jsx("div",{className:"text-[12px] text-on-surface/70 leading-relaxed prose prose-sm dark:prose-invert max-w-none group-hover:text-on-surface/90 transition-colors",children:f.jsx(yd,{children:e.description})}):f.jsx("p",{className:"font-mono text-[11px] text-on-surface-variant/25 italic group-hover:text-on-surface-variant/70 transition-colors",children:o("taskDetail.descEmpty")})})]}),f.jsxs("div",{className:"flex flex-col gap-0",children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold mb-1",children:o("taskDetail.commentsLabel",{count:e.comments.length})}),e.comments.length===0&&f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant/25 italic py-2",children:o("taskDetail.noComments")}),e.comments.map(k=>f.jsx(R$,{comment:k},k.id))]}),f.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold",children:o("taskDetail.addComment")}),f.jsx("textarea",{className:`${Hf} min-h-[200px] resize-y font-mono text-[12px] leading-relaxed`,placeholder:o("taskDetail.commentPlaceholder"),value:y,onChange:k=>x(k.target.value)}),f.jsx("button",{disabled:!y.trim()||v,onClick:Y,className:"self-end rounded bg-primary/15 px-3 py-1.5 text-[10px] text-primary/70 hover:bg-primary/25 transition-colors disabled:opacity-30",children:o(v?"taskDetail.publishing":"taskDetail.publishComment")})]}),f.jsxs("div",{className:"mt-2 pt-4",style:{borderTop:"1px solid rgba(255,255,255,0.04)"},children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-error/30 font-semibold mb-2",children:o("taskDetail.dangerZone")}),f.jsx("button",{onClick:I,disabled:_,className:"w-full rounded bg-red-950/15 px-3 py-2 text-left font-mono text-[11px] text-error/60 transition-all hover:bg-red-950/30 hover:text-error disabled:opacity-20",children:o(_?"taskDetail.deleting":"taskDetail.deleteTask")})]}),f.jsx("div",{className:"h-4"})]})})]})]})}function A$(){const{t:e}=we();return t=>{const n=Date.now()-t*1e3,r=Math.floor(n/1e3);if(r<60)return e("tasks.relativeNow");const i=Math.floor(r/60);if(i<60)return e("tasks.relativeMinutes",{n:i});const s=Math.floor(i/60);if(s<24)return e("tasks.relativeHours",{n:s});const o=Math.floor(s/24);return e("tasks.relativeDays",{n:o})}}function L$(e){return e.replace(/#{1,6}\s/g,"").replace(/(\*\*|__)(.*?)\1/g,"$2").replace(/(\*|_)(.*?)\1/g,"$2").replace(/`{1,3}[^`]*`{1,3}/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/^\s*[-*+]\s/gm,"").replace(/^\s*\d+\.\s/gm,"").replace(/\n+/g," ").trim()}function I$({task:e,onDragStart:t,onClick:n}){const{t:r}=we(),i=A$(),s=L$(e.description).slice(0,120),o=e.updatedBy!==null&&e.updatedBy!==e.source;return f.jsxs("div",{draggable:!0,onDragStart:()=>t(e.id),onClick:()=>n(e),className:"rounded-md p-3 cursor-pointer transition-colors hover:brightness-110 select-none bg-surface-container-high",children:[f.jsxs("div",{className:"flex items-center justify-between mb-1.5 gap-1",children:[f.jsx("span",{className:"font-mono text-[9px] text-primary/40 truncate",children:e.id}),f.jsx("span",{className:`flex-shrink-0 rounded-full px-1.5 py-[2px] text-[8px] font-semibold uppercase tracking-[0.08em] ${e.source==="agent"?"bg-secondary-container text-on-primary":"bg-primary text-on-surface"}`,children:e.source})]}),f.jsx("p",{className:"text-[12px] font-semibold text-on-surface leading-tight mb-1",children:e.title}),s&&f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant leading-snug line-clamp-2 mb-2",children:s}),e.tags.length>0&&f.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:e.tags.map(a=>f.jsx("span",{className:"rounded-full bg-primary/10 px-1.5 py-[1px] text-[8px] font-mono text-primary/60",children:a},a))}),f.jsxs("div",{className:"flex items-center justify-between gap-1 mt-1",children:[f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60",children:i(e.createdAt)}),o&&f.jsx("span",{className:"font-mono text-[8px] text-warning/50 truncate",children:r("tasks.editedBy",{name:e.updatedBy??""})})]})]})}function O$({agentId:e}){const{t}=we(),[n,r]=E.useState([]),[i,s]=E.useState([]),[o,a]=E.useState(null),[l,c]=E.useState(null),[u,d]=E.useState(null),[h,p]=E.useState(""),[g,m]=E.useState(""),[y,x]=E.useState(""),[v,b]=E.useState(null),[S,C]=E.useState(!1),[_,N]=E.useState(""),j=E.useMemo(()=>{const L=new Set;for(const U of n)for(const P of U.tags)L.add(P);return Array.from(L).sort()},[n]),T=E.useMemo(()=>{let L=n;if(y.trim()){const U=y.toLowerCase();L=L.filter(P=>P.title.toLowerCase().includes(U)||P.description.toLowerCase().includes(U))}return v&&(L=L.filter(U=>U.tags.includes(v))),L},[n,y,v]),w=E.useCallback(async()=>{try{r(await tR(e))}catch{}},[e]),M=E.useCallback(async()=>{try{s(await aR(e))}catch{}},[e]);E.useEffect(()=>{w(),M();const L=setInterval(()=>{w()},4e3);return()=>clearInterval(L)},[w,M]);const D=E.useCallback(async L=>{try{const U=await nR(e,L.id);a(U)}catch{a({...L,comments:[]})}},[e]),F=E.useCallback(async L=>{if(!l)return;const U=n.find(P=>P.id===l);if(!U||U.status===L){c(null);return}try{const P=await Wy(e,l,{status:L});r(J=>J.map(oe=>oe.id===l?P:oe)),a(J=>J&&J.id===l?{...J,...P}:J)}catch{}c(null)},[e,l,n]),B=E.useCallback(async(L,U,P)=>{if(U.trim()){try{const J=await rR(e,{title:U.trim(),description:P.trim()||void 0,status:L});r(oe=>[...oe,J])}catch{}d(null),p(""),m("")}},[e]),$=E.useCallback(async(L,U)=>{const P=await Wy(e,L,U);r(J=>J.map(oe=>oe.id===L?P:oe)),a(J=>J&&J.id===L?{...J,...P}:J)},[e]),V=E.useCallback(async(L,U)=>{const P=await oR(e,L,U);a(J=>J&&J.id===L?{...J,comments:[...J.comments,P]}:J)},[e]),Y=E.useCallback(async L=>{await iR(e,L),r(U=>U.filter(P=>P.id!==L)),a(null)},[e]),I=E.useCallback(async()=>{if(confirm(t("tasks.clearConfirm")))try{await sR(e),r([]),a(null)}catch{}},[e,t]),z=E.useCallback(async()=>{if(_.trim())try{const L=await lR(e,_.trim());s(U=>[...U,L]),N(""),C(!1)}catch{}},[e,_]),k=E.useCallback(async L=>{if(confirm(t("tasks.deleteColumnConfirm")))try{await cR(e,L),s(U=>U.filter(P=>P.id!==L)),w()}catch{}},[e,t,w]);return f.jsxs("div",{className:"flex flex-col flex-1 overflow-hidden",children:[f.jsxs("div",{className:"flex items-center gap-2 px-3 pt-3 pb-1 flex-shrink-0 flex-wrap",children:[f.jsx("input",{className:"rounded bg-surface-container px-2.5 py-[6px] text-[11px] text-on-surface placeholder:text-on-surface-variant/60 outline-none focus:ring-1 focus:ring-primary/25 w-48 font-mono",placeholder:t("tasks.searchPlaceholder"),value:y,onChange:L=>x(L.target.value)}),j.length>0&&f.jsx("div",{className:"flex gap-1 flex-wrap",children:j.map(L=>f.jsx("button",{onClick:()=>b(v===L?null:L),className:`rounded-full px-2 py-[2px] text-[9px] font-mono transition-colors ${v===L?"bg-primary/25 text-primary":"bg-surface-container text-on-surface-variant/60 hover:text-on-surface-variant"}`,children:L},L))}),f.jsx("div",{className:"flex-1"}),f.jsx("button",{onClick:I,className:"rounded bg-red-950/15 px-2.5 py-[5px] text-[9px] font-mono text-error/50 hover:bg-red-950/30 hover:text-error/70 transition-colors",children:t("tasks.clearAll")})]}),f.jsxs("div",{className:"flex flex-1 gap-2 overflow-x-auto p-3 relative",children:[i.map(L=>{const U=T.filter(P=>P.status===L.id);return f.jsx(F$,{columnId:L.id,label:L.label,tasks:U,canDelete:i.length>1,addingTask:u===L.id,newTitle:u===L.id?h:"",newDesc:u===L.id?g:"",onNewTitleChange:P=>p(P),onNewDescChange:P=>m(P),onStartAdding:()=>{d(L.id),p(""),m("")},onCancelAdding:()=>{d(null),p(""),m("")},onConfirmAdding:()=>B(L.id,h,g),onDragStart:P=>c(P),onDrop:F,onCardClick:D,onDeleteColumn:()=>k(L.id)},L.id)}),S?f.jsxs("div",{className:"w-56 flex-shrink-0 flex flex-col gap-2 rounded-md p-3 bg-surface-container",children:[f.jsx("input",{autoFocus:!0,className:"rounded bg-surface-container-high px-2.5 py-[7px] text-[11px] text-on-surface placeholder:text-on-surface-variant/60 outline-none focus:ring-1 focus:ring-primary/25 w-full",placeholder:t("tasks.columnLabelPlaceholder"),value:_,onChange:L=>N(L.target.value),onKeyDown:L=>{L.key==="Enter"&&z(),L.key==="Escape"&&(C(!1),N(""))}}),f.jsxs("div",{className:"flex gap-1.5",children:[f.jsx("button",{disabled:!_.trim(),onClick:z,className:"flex-1 rounded bg-primary/15 px-2 py-1 text-[10px] text-primary/70 hover:bg-primary/25 transition-colors disabled:opacity-30",children:t("tasks.add")}),f.jsx("button",{onClick:()=>{C(!1),N("")},className:"rounded bg-surface-container-high px-2 py-1 text-[10px] text-on-surface-variant/70 hover:text-on-surface-variant transition-colors",children:t("tasks.cancel")})]})]}):f.jsx("button",{onClick:()=>C(!0),className:"w-10 flex-shrink-0 rounded-md flex items-center justify-center text-on-surface-variant/30 hover:text-on-surface-variant/60 hover:bg-surface-container transition-colors text-[16px]",children:"+"})]}),o&&f.jsx(D$,{task:o,columns:i,onClose:()=>a(null),onUpdate:$,onAddComment:V,onDelete:Y})]})}function F$({columnId:e,label:t,tasks:n,canDelete:r,addingTask:i,newTitle:s,newDesc:o,onNewTitleChange:a,onNewDescChange:l,onStartAdding:c,onCancelAdding:u,onConfirmAdding:d,onDragStart:h,onDrop:p,onCardClick:g,onDeleteColumn:m}){const{t:y}=we(),[x,v]=E.useState(!1);return f.jsxs("div",{className:"w-56 flex-shrink-0 flex flex-col gap-0 rounded-md overflow-hidden bg-surface-container",onDragOver:b=>{b.preventDefault(),v(!0)},onDragLeave:()=>v(!1),onDrop:()=>{v(!1),p(e)},children:[f.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5 flex-shrink-0",style:{borderBottom:x?"1px solid rgba(160,120,255,0.25)":"1px solid rgba(255,255,255,0.04)",background:x?"rgba(160,120,255,0.05)":void 0,transition:"background 0.15s, border-color 0.15s"},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"font-mono text-[9px] uppercase tracking-[0.15em] text-on-surface-variant",children:t}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/25 tabular-nums",children:n.length})]}),f.jsxs("div",{className:"flex items-center gap-0.5",children:[f.jsx("button",{onClick:c,className:"text-[12px] text-on-surface-variant/60 hover:text-primary/70 transition-colors leading-none w-5 h-5 flex items-center justify-center rounded hover:bg-primary/10",children:"+"}),r&&f.jsx("button",{onClick:m,className:"text-[10px] text-on-surface-variant/30 hover:text-error/60 transition-colors leading-none w-5 h-5 flex items-center justify-center rounded hover:bg-red-950/20",children:"×"})]})]}),f.jsxs("div",{className:"flex flex-col gap-1.5 p-2 overflow-y-auto flex-1",children:[n.map(b=>f.jsx(I$,{task:b,onDragStart:h,onClick:g},b.id)),i&&f.jsxs("div",{className:"rounded-md p-2.5 flex flex-col gap-2 bg-surface-container-high",children:[f.jsx("input",{autoFocus:!0,className:"rounded bg-surface-container px-2.5 py-[7px] text-[11px] text-on-surface placeholder:text-on-surface-variant/60 outline-none focus:ring-1 focus:ring-primary/25 w-full",placeholder:y("tasks.titlePlaceholder"),value:s,onChange:b=>a(b.target.value),onKeyDown:b=>{b.key==="Escape"&&u()}}),f.jsx("textarea",{className:"rounded bg-surface-container px-2.5 py-[7px] text-[11px] text-on-surface placeholder:text-on-surface-variant/60 outline-none focus:ring-1 focus:ring-primary/25 w-full resize-y min-h-[48px] font-mono",placeholder:y("tasks.descPlaceholder"),value:o,onChange:b=>l(b.target.value),onKeyDown:b=>{b.key==="Escape"&&u()},rows:2}),f.jsxs("div",{className:"flex gap-1.5",children:[f.jsx("button",{disabled:!s.trim(),onClick:d,className:"flex-1 rounded bg-primary/15 px-2 py-1 text-[10px] text-primary/70 hover:bg-primary/25 transition-colors disabled:opacity-30",children:y("tasks.add")}),f.jsx("button",{onClick:u,className:"rounded bg-surface-container px-2 py-1 text-[10px] text-on-surface-variant/70 hover:text-on-surface-variant/70 transition-colors",children:y("tasks.cancel")})]})]})]})]})}function $$({status:e}){const t=e==="active"?"bg-secondary-container text-on-primary":e==="stale"||e==="crashed"?"bg-amber-500/20 text-warning":"bg-surface-container text-on-surface-variant/60";return f.jsx("span",{className:`rounded-full px-1.5 py-[2px] text-[8px] font-semibold uppercase tracking-[0.1em] ${t}`,children:e})}function yC({commands:e,activeIndex:t,onJump:n}){const r=E.useRef(null);return E.useEffect(()=>{var i;(i=r.current)==null||i.scrollIntoView({behavior:"smooth",block:"nearest"})},[t]),e.length===0?null:f.jsxs("div",{className:"w-56 flex-shrink-0 flex flex-col border-l border-outline-variant/30 overflow-hidden bg-surface-container",children:[f.jsx("div",{className:"px-3 py-2 border-b border-outline-variant/30",children:f.jsxs("span",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold",children:["Events (",e.length,")"]})}),f.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-thin",children:e.map((i,s)=>{const o=s===t;return f.jsxs("div",{ref:o?r:void 0,onClick:()=>n(s),className:`px-3 py-2 border-b border-outline-variant/20 transition-colors cursor-pointer hover:bg-surface-container/50 ${o?"bg-primary/10 border-l-2 border-l-primary":""}`,children:[f.jsx("p",{className:`font-mono text-[10px] leading-snug break-all ${o?"text-primary":"text-on-surface-variant"}`,children:i.args}),f.jsx("p",{className:"font-mono text-[8px] text-on-surface-variant/20 mt-0.5",children:new Date(i.timestamp).toLocaleTimeString()})]},s)})})]})}function z$({agentId:e,session:t}){const[n,r]=E.useState(null),[i,s]=E.useState("connecting"),[o,a]=E.useState(null),[l,c]=E.useState(null),[u,d]=E.useState(!1);return E.useEffect(()=>{const h=new WebSocket(sS(e,t.id));let p=!0;return h.onmessage=g=>{if(p)try{const m=JSON.parse(g.data);m.type==="frame"&&m.data?r(`data:image/jpeg;base64,${m.data}`):m.type==="attached"?(s("attached"),m.url!=null&&m.title!=null&&m.index!=null&&c({index:m.index,url:m.url,title:m.title})):m.type==="tab_changed"&&m.url!=null&&m.title!=null&&m.index!=null?(c({index:m.index,url:m.url,title:m.title}),d(!0),window.setTimeout(()=>d(!1),900)):m.type==="unavailable"?(r(null),s("error"),a(m.reason??"stream unavailable")):(m.type==="error"||m.type==="detached")&&(s("error"),a(m.reason??"stream ended"))}catch{}},h.onclose=()=>{p&&s("closed")},h.onerror=()=>{p&&(s("error"),a("websocket error"))},()=>{p=!1;try{h.close()}catch{}}},[e,t.id]),f.jsxs("div",{className:"flex-1 flex items-center justify-center overflow-hidden relative bg-surface-container-lowest",children:[n?f.jsx("img",{src:n,alt:"live browser frame",className:"max-w-full max-h-full object-contain select-none",draggable:!1}):f.jsxs("div",{className:"flex flex-col items-center justify-center text-center p-8",children:[f.jsx("span",{className:"text-[32px] opacity-10 mb-3",children:"📺"}),f.jsxs("p",{className:"font-mono text-[10px] text-on-surface-variant/35",children:[i==="connecting"&&"connecting to live stream…",i==="attached"&&"waiting for first frame…",i==="error"&&`live stream unavailable${o?` — ${o}`:""}`,i==="closed"&&"live stream closed"]})]}),f.jsxs("div",{className:"absolute top-3 left-3 flex items-center gap-2 max-w-[60%]",children:[f.jsxs("div",{className:"flex items-center gap-1.5 rounded-full bg-black/60 px-2 py-1 flex-shrink-0",children:[f.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-secondary animate-pulse inline-block"}),f.jsx("span",{className:"text-[8px] uppercase tracking-[0.15em] text-secondary/70 font-semibold",children:"live"})]}),l&&f.jsxs("div",{className:`flex items-center gap-1.5 rounded-full bg-black/60 px-2.5 py-1 min-w-0 transition-all duration-500 ${u?"ring-1 ring-primary/60 bg-primary/25":""}`,title:l.url,children:[f.jsxs("span",{className:"text-[8px] uppercase tracking-[0.15em] text-on-surface-variant/70 font-semibold flex-shrink-0",children:["tab ",l.index]}),f.jsx("span",{className:"w-1 h-1 rounded-full bg-on-surface-variant/30 flex-shrink-0"}),f.jsx("span",{className:"text-[10px] text-on-surface/90 truncate",children:l.title||l.url})]})]})]})}function B$({agentId:e,session:t}){const n=E.useRef(null),[r,i]=E.useState(0),[s,o]=E.useState(0),a=t.createdAt,l=t.closedAt!=null?t.closedAt-t.createdAt:0,c=t.commands.map(y=>Math.max(0,(y.timestamp-a)/1e3));let u=-1;for(let y=0;y<c.length;y++)c[y]<=s+.01&&(u=y);const d=E.useCallback(y=>{const x=n.current;if(!x)return;const v=c[y]??0;x.currentTime=Math.min(v,x.duration||v),x.play().catch(()=>{})},[c]),h=()=>{var x;const y=((x=n.current)==null?void 0:x.duration)??0;i(Number.isFinite(y)?y:0)},p=()=>{var y;o(((y=n.current)==null?void 0:y.currentTime)??0)},g=t.videoValid?dR(e,t.id):null,m=r||l/1e3;return f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"flex-1 flex items-center justify-center overflow-hidden relative bg-surface-container-lowest",style:{minHeight:0},children:g?f.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[f.jsx("video",{ref:n,src:g,controls:!0,preload:"metadata",onLoadedMetadata:h,onTimeUpdate:p,className:"max-w-full max-h-full object-contain"}),m>0&&t.commands.length>0&&f.jsx("div",{className:"absolute left-0 right-0 bottom-[42px] pointer-events-none px-[12px]",children:f.jsx("div",{className:"relative h-2",children:c.map((y,x)=>{const v=Math.min(1,y/m)*100,b=x===u;return f.jsx("button",{onClick:()=>d(x),style:{left:`${v}%`},className:`absolute top-0 -translate-x-1/2 rounded-full pointer-events-auto transition-all ${b?"w-2.5 h-2.5 bg-primary ring-2 ring-primary/30":"w-1.5 h-1.5 bg-primary/50 hover:bg-primary/80"}`,title:t.commands[x].args},x)})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center text-center p-8",children:[f.jsx("span",{className:"text-[32px] opacity-10 mb-3",children:"🎞"}),f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant/25",children:"recording unavailable"}),(t.status==="stale"||t.status==="crashed")&&f.jsx("p",{className:"font-mono text-[9px] text-warning/50 mt-2",children:"session was abandoned before finalizing"})]})}),f.jsx(yC,{commands:t.commands,activeIndex:u,onJump:d})]})}function W$({agentId:e,session:t,onBack:n}){const[r,i]=E.useState(t);E.useEffect(()=>{if(r.status!=="active")return;const o=setInterval(()=>{iS(e,r.id).then(i).catch(()=>{})},3e3);return()=>clearInterval(o)},[e,r.id,r.status]),E.useEffect(()=>{const o=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[n]);const s=r.status==="active";return f.jsxs("div",{className:"flex flex-1 flex-col h-full min-w-0 rounded-lg bg-surface-container-lowest",children:[f.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-outline-variant/30 flex-shrink-0",children:[f.jsx("button",{onClick:n,className:"flex items-center justify-center w-6 h-6 rounded transition-colors hover:bg-surface-container text-on-surface-variant hover:text-on-surface",title:"Back to sessions",children:f.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:f.jsx("path",{d:"M10 3L5 8l5 5V3z"})})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("p",{className:"text-[11px] font-medium text-on-surface truncate",children:r.name??"Unnamed session"}),f.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant/60 truncate",children:r.id})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f.jsx($$,{status:r.status}),f.jsxs("span",{className:"font-mono text-[9px] text-on-surface-variant/70 tabular-nums",children:[r.commands.length," cmd",r.commands.length===1?"":"s"]})]})]}),f.jsx("div",{className:"flex-1 flex min-h-0",children:s?f.jsxs(f.Fragment,{children:[f.jsx(z$,{agentId:e,session:r}),f.jsx(yC,{commands:r.commands,activeIndex:r.commands.length-1,onJump:()=>{}})]}):f.jsx(B$,{agentId:e,session:r})})]})}function H$(e){const t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function V$(e,t){const r=(t??Date.now())-e,i=Math.floor(r/1e3);if(i<60)return`${i}s`;const s=Math.floor(i/60);return s<60?`${s}m ${i%60}s`:`${Math.floor(s/60)}h ${s%60}m`}function U$({status:e}){const t=e==="active"?"bg-secondary-container text-on-primary":e==="stale"||e==="crashed"?"bg-amber-500/20 text-warning":"bg-surface-container text-on-surface-variant/60";return f.jsx("span",{className:`rounded-full px-1.5 py-[2px] text-[8px] font-semibold uppercase tracking-[0.1em] ${t}`,children:e})}function q$({session:e,onClick:t}){const n=e.status==="active";return f.jsx("button",{onClick:t,className:`w-full text-left rounded-md transition-colors hover:brightness-110 ${n?"bg-surface-container-high":"bg-surface-container"}`,children:f.jsxs("div",{className:"p-3",children:[n&&f.jsx("div",{className:"absolute top-3 right-3 w-1.5 h-1.5 rounded-full bg-secondary animate-pulse",style:{position:"absolute"}}),f.jsxs("div",{className:"flex items-start justify-between gap-2 relative",children:[f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("p",{className:"text-[11px] font-medium text-on-surface truncate",children:e.name??"Unnamed session"}),f.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant/60 mt-0.5 truncate",children:e.id})]}),f.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[f.jsx(U$,{status:e.status}),n&&f.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-secondary animate-pulse inline-block"})]})]}),f.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60",children:e.videoValid?"video":"no recording"}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/20",children:"·"}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60",children:V$(e.createdAt,e.closedAt)}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/20",children:"·"}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60",children:H$(e.createdAt)})]})]})})}function G$({agentId:e}){const[t,n]=E.useState([]),[r,i]=E.useState(null),[s,o]=E.useState(!1);E.useEffect(()=>{let l=!1;const c=()=>{uR(e).then(d=>{if(!l){const h=[...d].sort((p,g)=>p.status==="active"&&g.status!=="active"?-1:p.status!=="active"&&g.status==="active"?1:g.createdAt-p.createdAt);n(h)}}).catch(console.error)};c();const u=setInterval(c,5e3);return()=>{l=!0,clearInterval(u)}},[e]);const a=async l=>{o(!0);try{const c=await iS(e,l.id);i(c)}catch(c){console.error("Failed to load session",c)}finally{o(!1)}};return r?f.jsx(W$,{agentId:e,session:r,onBack:()=>i(null)}):f.jsxs("div",{className:"flex flex-1 flex-col h-full min-w-0 rounded-lg bg-surface-container-lowest",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-outline-variant/30",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-[13px] opacity-60",children:"🌐"}),f.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] font-medium text-on-surface-variant",children:"Browser Sessions"})]}),f.jsxs("span",{className:"font-mono text-[9px] text-on-surface-variant/60 tabular-nums",children:[t.length," sessions"]})]}),s&&f.jsx("div",{className:"flex items-center justify-center py-8",children:f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant/60 animate-pulse",children:"loading session…"})}),!s&&f.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-1.5 scrollbar-thin",children:t.length===0?f.jsx("div",{className:"flex items-center justify-center flex-1",children:f.jsxs("div",{className:"max-w-lg w-full mx-auto text-center px-8",children:[f.jsx("img",{src:"/browser-onboarding.png",alt:"",className:"w-44 h-44 mx-auto mb-6 opacity-90"}),f.jsx("h2",{className:"font-headline text-xl font-semibold text-on-surface mb-3",children:"Browser sessions"}),f.jsx("p",{className:"text-[13px] text-on-surface-variant leading-relaxed mb-8 max-w-sm mx-auto",children:"When the agent needs your credentials or hits a captcha, it will hand off control to you."}),f.jsxs("div",{className:"flex flex-col gap-4 max-w-xs mx-auto text-left mb-8",children:[f.jsxs("div",{className:"flex items-start gap-4",children:[f.jsx("span",{className:"w-7 h-7 rounded-full bg-primary/15 text-primary text-[12px] font-bold flex items-center justify-center flex-shrink-0 mt-0.5",children:"1"}),f.jsxs("div",{children:[f.jsx("p",{className:"text-[13px] text-on-surface/80 font-medium",children:"Agent requests takeover"}),f.jsx("p",{className:"text-[11px] text-on-surface-variant/70 mt-0.5",children:"You'll receive a link in chat when the agent needs you"})]})]}),f.jsxs("div",{className:"flex items-start gap-4",children:[f.jsx("span",{className:"w-7 h-7 rounded-full bg-primary/15 text-primary text-[12px] font-bold flex items-center justify-center flex-shrink-0 mt-0.5",children:"2"}),f.jsxs("div",{children:[f.jsx("p",{className:"text-[13px] text-on-surface/80 font-medium",children:"Open the link and take control"}),f.jsx("p",{className:"text-[11px] text-on-surface-variant/70 mt-0.5",children:"Log in, solve the captcha, or complete whatever action is needed"})]})]}),f.jsxs("div",{className:"flex items-start gap-4",children:[f.jsx("span",{className:"w-7 h-7 rounded-full bg-primary/15 text-primary text-[12px] font-bold flex items-center justify-center flex-shrink-0 mt-0.5",children:"3"}),f.jsxs("div",{children:[f.jsx("p",{className:"text-[13px] text-on-surface/80 font-medium",children:"Click Completed"}),f.jsx("p",{className:"text-[11px] text-on-surface-variant/70 mt-0.5",children:"Session and logins are saved — the agent resumes automatically"})]})]})]}),f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant/20",children:"Sessions will appear here once the agent starts browsing."})]})}):t.map(l=>f.jsx(q$,{session:l,onClick:()=>void a(l)},l.id))})]})}const U0=1e3,K$=1e4,Y$=3e5;function q0(e,t,n){const r=E.useRef(null),i=E.useRef(null),s=E.useRef(t);s.current=t;const o=E.useRef(n);o.current=n;const[a,l]=E.useState(!1),c=E.useRef(null),u=E.useRef(U0),d=E.useRef(!0),h=E.useRef(null),p=E.useCallback(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{const v=i.current;v&&(v({type:"error",message:"Stream timeout — no response for 5 minutes"}),v({type:"done",sessionId:""}),i.current=null)},Y$)},[]),g=E.useCallback(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);E.useEffect(()=>{if(d.current=!0,!e)return;let v=null;function b(){if(!d.current)return;const C=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/agents/${encodeURIComponent(e)}`,_=new WebSocket(C);r.current=_,_.onopen=()=>{if(!d.current)return;l(!0),u.current=U0;const N=h.current??"ui";_.send(JSON.stringify({type:"subscribe",channelId:N}))},_.onmessage=N=>{let j;try{j=JSON.parse(N.data)}catch{return}const T=i.current??s.current??null;j.type==="chunk"?(p(),T==null||T(j.chunk),(j.chunk.type==="done"||j.chunk.type==="error")&&g()):j.type==="blocked"?T==null||T({type:"blocked",reason:j.reason}):j.type==="pending_approval"?T==null||T({type:"pending_approval",reason:j.reason}):j.type==="error"&&(T==null||T({type:"error",message:j.message}),g())},_.onclose=()=>{d.current&&(l(!1),console.warn(`[ws] ${e} disconnected — reconnecting in ${u.current}ms`),v=setTimeout(()=>{u.current=Math.min(u.current*2,K$),b()},u.current))}}return b(),()=>{var S;d.current=!1,v&&clearTimeout(v),g(),(S=r.current)==null||S.close(),l(!1)}},[e,p,g]);const m=E.useCallback((v,b)=>{var C,_;i.current=b,p();const S=()=>{var N;return(N=r.current)==null?void 0:N.send(JSON.stringify({type:"message",text:v}))};((C=r.current)==null?void 0:C.readyState)===WebSocket.OPEN?S():(_=r.current)==null||_.addEventListener("open",S,{once:!0})},[p]),y=E.useCallback(()=>{var v;((v=r.current)==null?void 0:v.readyState)===WebSocket.OPEN&&r.current.send(JSON.stringify({type:"stop"})),g(),i.current=null},[g]),x=E.useCallback(v=>{var b;h.current=v,((b=r.current)==null?void 0:b.readyState)===WebSocket.OPEN&&r.current.send(JSON.stringify({type:"subscribe",channelId:v}))},[]);return{sendMessage:m,stopMessage:y,subscribeToChannel:x,connected:a}}const G0={pending:"text-on-surface-variant",running:"text-warning",completed:"text-success",failed:"text-error",skipped:"text-on-surface-variant/60"},X$={pending:"○",running:"◉",completed:"●",failed:"✕",skipped:"—"},J$={tool_call:"→",tool_result:"←",error:"✕"},Q$={tool_call:"text-primary",tool_result:"text-success",error:"text-error"};function K0(e){if(e==null)return"";if(typeof e=="string")return e.length>200?e.slice(0,200)+"…":e;try{const t=JSON.stringify(e);return t.length>200?t.slice(0,200)+"…":t}catch{return String(e)}}function Z$({agentId:e,workflowId:t,runId:n,steps:r,onBack:i}){const{t:s}=we(),[o,a]=E.useState(null),[l,c]=E.useState(new Set),[u,d]=E.useState(!1),h=E.useCallback(async()=>{try{const m=await wR(e,t,n);a(m)}catch{}},[e,t,n]);E.useEffect(()=>{h();const m=setInterval(()=>{h()},1500);return()=>clearInterval(m)},[h]);const p=m=>{c(y=>{const x=new Set(y);return x.has(m)?x.delete(m):x.add(m),x})};if(!o)return f.jsx("div",{className:"p-4 font-mono text-sm text-on-surface-variant",children:s("runDetail.loading")});const g=new Map(r.map(m=>[m.id,m]));return f.jsxs("div",{className:"p-4",children:[f.jsx("button",{onClick:i,className:`${qr} mb-3`,children:s("runDetail.back")}),f.jsxs("div",{className:"flex items-center justify-between mb-4",children:[f.jsxs("h2",{className:"font-headline text-xl font-bold text-on-surface",children:[s("runDetail.runLabel")," ",f.jsx("span",{className:G0[o.status],children:o.status})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[o.status==="running"&&f.jsx("button",{disabled:u,onClick:async()=>{d(!0);try{await SR(e,t,n),await h()}catch{}d(!1)},className:Mu,children:s(u?"runDetail.cancelling":"runDetail.cancel")}),f.jsxs("span",{className:"font-mono text-[11px] text-on-surface-variant",children:[new Date(o.startedAt).toLocaleString(),o.finishedAt&&` · ${((o.finishedAt-o.startedAt)/1e3).toFixed(1)}s`]})]})]}),f.jsx("div",{className:"flex flex-col gap-1",children:o.steps.map(m=>{const y=g.get(m.stepId),x=l.has(m.id);return f.jsxs("div",{className:`${tl} overflow-hidden`,children:[f.jsxs("div",{onClick:()=>p(m.id),className:"flex items-center gap-2 px-3 py-2 cursor-pointer",children:[f.jsx("span",{className:`text-sm ${G0[m.status]}`,children:X$[m.status]}),f.jsx("span",{className:"text-sm text-on-surface flex-1",children:(y==null?void 0:y.name)??m.stepId}),m.durationMs!==null&&f.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant",children:[(m.durationMs/1e3).toFixed(1),"s"]}),f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:x?"▾":"▸"})]}),x&&f.jsxs("div",{className:"px-3 pb-3 text-sm space-y-2",children:[m.error&&f.jsxs("div",{className:"text-error whitespace-pre-wrap font-mono text-xs",children:[s("runDetail.errorPrefix")," ",m.error]}),m.events&&m.events.length>0&&f.jsxs("div",{children:[f.jsx("div",{className:"font-label text-[10px] font-semibold uppercase tracking-widest text-on-surface-variant mb-1",children:s("runDetail.activity")}),f.jsx("div",{className:"flex flex-col gap-1 bg-surface-container-low p-2 rounded",children:m.events.map((v,b)=>{const S=m.startedAt?((v.ts-m.startedAt)/1e3).toFixed(1):"";return f.jsxs("div",{className:"flex items-start gap-2 font-mono text-[11px]",children:[f.jsx("span",{className:"text-on-surface-variant/60 w-10 text-right shrink-0",children:S&&`+${S}s`}),f.jsx("span",{className:`shrink-0 ${Q$[v.type]}`,children:J$[v.type]}),v.type==="tool_call"&&f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("span",{className:"text-on-surface font-semibold",children:v.tool}),v.input!==void 0&&v.input!==null&&f.jsx("span",{className:"text-on-surface-variant ml-2 break-all",children:K0(v.input)})]}),v.type==="tool_result"&&f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("span",{className:"text-on-surface",children:v.tool}),v.output!==void 0&&v.output!==null&&f.jsx("span",{className:"text-on-surface-variant ml-2 break-all",children:K0(v.output)})]}),v.type==="error"&&f.jsx("div",{className:"flex-1 min-w-0 text-error break-all",children:v.message})]},b)})})]}),m.input!==null&&f.jsxs("div",{children:[f.jsx("div",{className:"font-label text-[10px] font-semibold uppercase tracking-widest text-on-surface-variant mb-1",children:s("runDetail.input")}),f.jsx("pre",{className:"font-mono text-xs text-on-surface bg-surface-container-low p-2 rounded overflow-auto max-h-52 whitespace-pre-wrap break-words",children:typeof m.input=="string"?m.input:JSON.stringify(m.input,null,2)})]}),m.output!==null&&f.jsxs("div",{children:[f.jsx("div",{className:"font-label text-[10px] font-semibold uppercase tracking-widest text-on-surface-variant mb-1",children:s("runDetail.output")}),f.jsx("pre",{className:"font-mono text-xs text-on-surface bg-surface-container-low p-2 rounded overflow-auto max-h-52 whitespace-pre-wrap break-words",children:typeof m.output=="string"?m.output:JSON.stringify(m.output,null,2)})]})]})]},m.id)})})]})}function bC({title:e,initial:t,allowStatus:n,onSave:r,onCancel:i}){const{t:s}=we(),[o,a]=E.useState((t==null?void 0:t.name)??""),[l,c]=E.useState((t==null?void 0:t.description)??""),[u,d]=E.useState((t==null?void 0:t.status)??"active"),[h,p]=E.useState(!1),g=async m=>{if(m.preventDefault(),!(!o.trim()||h)){p(!0);try{await r({name:o.trim(),description:l.trim(),status:n?u:void 0})}finally{p(!1)}}};return f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"fixed inset-0 z-40",style:{background:"rgba(0,0,0,0.4)"},onClick:i}),f.jsx("form",{onSubmit:g,className:"fixed inset-0 z-50 flex items-center justify-center p-4 pointer-events-none",children:f.jsxs("div",{className:"bg-surface-container-lowest border border-outline-variant/40 rounded-xl shadow-callout p-5 w-full max-w-md pointer-events-auto",children:[f.jsx("h3",{className:"font-headline text-lg font-bold text-on-surface mb-4",children:e}),f.jsxs("div",{className:"flex flex-col gap-3 mb-5",children:[f.jsxs("div",{children:[f.jsx("label",{className:"font-label text-[11px] font-semibold uppercase tracking-widest text-on-surface-variant block mb-1",children:s("workflows.formName")}),f.jsx("input",{autoFocus:!0,className:rr,value:o,onChange:m=>a(m.target.value),placeholder:s("workflows.formNamePlaceholder")})]}),f.jsxs("div",{children:[f.jsx("label",{className:"font-label text-[11px] font-semibold uppercase tracking-widest text-on-surface-variant block mb-1",children:s("workflows.formDescription")}),f.jsx("textarea",{rows:3,className:rr,value:l,onChange:m=>c(m.target.value),placeholder:s("workflows.formDescriptionPlaceholder")})]}),n&&f.jsxs("div",{children:[f.jsx("label",{className:"font-label text-[11px] font-semibold uppercase tracking-widest text-on-surface-variant block mb-1",children:s("workflows.formStatus")}),f.jsxs("select",{className:rr,value:u,onChange:m=>d(m.target.value),children:[f.jsx("option",{value:"active",children:"active"}),f.jsx("option",{value:"paused",children:"paused"}),f.jsx("option",{value:"archived",children:"archived"})]})]})]}),f.jsxs("div",{className:"flex items-center justify-end gap-2",children:[f.jsx("button",{type:"button",onClick:i,className:qr,children:s("workflows.cancel")}),f.jsx("button",{type:"submit",disabled:!o.trim()||h,className:Ui,children:s(h?"workflows.saving":"workflows.save")})]})]})})]})}function Y0({title:e,initial:t,onSave:n,onCancel:r}){const{t:i}=we(),s=t==null?void 0:t.config,[o,a]=E.useState((t==null?void 0:t.name)??""),[l,c]=E.useState((s==null?void 0:s.prompt)??""),[u,d]=E.useState(s!=null&&s.timeout_ms?String(s.timeout_ms/1e3):""),[h,p]=E.useState(!1),g=async m=>{if(m.preventDefault(),!o.trim()||!l.trim()||h)return;const y=u?Math.round(Number(u)*1e3):void 0,x={prompt:l,timeout_ms:y};p(!0);try{await n({name:o.trim(),config:x})}finally{p(!1)}};return f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"fixed inset-0 z-40",style:{background:"rgba(0,0,0,0.4)"},onClick:r}),f.jsx("form",{onSubmit:g,className:"fixed inset-0 z-50 flex items-center justify-center p-4 pointer-events-none overflow-y-auto",children:f.jsxs("div",{className:"bg-surface-container-lowest border border-outline-variant/40 rounded-xl shadow-callout p-5 w-full max-w-2xl pointer-events-auto my-8",children:[f.jsx("h3",{className:"font-headline text-lg font-bold text-on-surface mb-4",children:e}),f.jsxs("div",{className:"flex flex-col gap-3 mb-5",children:[f.jsxs("div",{children:[f.jsx("label",{className:"font-label text-[11px] font-semibold uppercase tracking-widest text-on-surface-variant block mb-1",children:i("workflows.stepNameLabel")}),f.jsx("input",{autoFocus:!0,className:rr,value:o,onChange:m=>a(m.target.value),placeholder:i("workflows.stepNamePlaceholder")})]}),f.jsxs("div",{children:[f.jsx("label",{className:"font-label text-[11px] font-semibold uppercase tracking-widest text-on-surface-variant block mb-1",children:i("workflows.stepPromptLabel")}),f.jsx("textarea",{rows:10,className:rr,value:l,onChange:m=>c(m.target.value),placeholder:i("workflows.stepPromptPlaceholder")})]}),f.jsxs("div",{children:[f.jsx("label",{className:"font-label text-[11px] font-semibold uppercase tracking-widest text-on-surface-variant block mb-1",children:i("workflows.stepTimeoutLabel")}),f.jsx("input",{className:rr,type:"number",min:0,value:u,onChange:m=>d(m.target.value),placeholder:"300"})]})]}),f.jsxs("div",{className:"flex items-center justify-end gap-2",children:[f.jsx("button",{type:"button",onClick:r,className:qr,children:i("workflows.cancel")}),f.jsx("button",{type:"submit",disabled:!o.trim()||!l.trim()||h,className:Ui,children:i(h?"workflows.saving":"workflows.save")})]})]})})]})}const e5={running:"bg-warning",completed:"bg-success",failed:"bg-error",cancelled:"bg-outline"};function t5({agentId:e,workflow:t,runs:n,onBack:r,onRun:i,onRefresh:s,onDeleted:o}){const{t:a}=we(),[l,c]=E.useState(null),[u,d]=E.useState(new Set),[h,p]=E.useState(!1),[g,m]=E.useState(!1),[y,x]=E.useState(null),v=w=>{d(M=>{const D=new Set(M);return D.has(w)?D.delete(w):D.add(w),D})},b=async w=>{await ER(e,t.id,w),p(!1),await s()},S=async()=>{window.confirm(a("workflows.confirmDelete",{name:t.name}))&&(await NR(e,t.id),await o())},C=async w=>{await jR(e,t.id,w),m(!1),await s()},_=async w=>{y&&(await Cf(e,t.id,y.id,w),x(null),await s())},N=async w=>{window.confirm(a("workflows.confirmDeleteStep",{name:w.name}))&&(await PR(e,t.id,w.id),await s())},j=async(w,M)=>{const D=[...t.steps].sort((V,Y)=>V.position-Y.position),B=D.findIndex(V=>V.id===w.id)+M;if(B<0||B>=D.length)return;const $=D[B];await Promise.all([Cf(e,t.id,w.id,{position:$.position}),Cf(e,t.id,$.id,{position:w.position})]),await s()};if(l)return f.jsx(Z$,{agentId:e,workflowId:t.id,runId:l,steps:t.steps,onBack:()=>{c(null),s()}});const T=[...t.steps].sort((w,M)=>w.position-M.position);return f.jsxs("div",{className:"p-4",children:[f.jsx("button",{onClick:()=>void r(),className:`${qr} mb-3`,children:a("workflows.back")}),f.jsxs("div",{className:"flex items-center justify-between mb-4 gap-2 flex-wrap",children:[f.jsx("h2",{className:"font-headline text-xl font-bold text-on-surface",children:t.name}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:()=>p(!0),className:qr,children:a("workflows.edit")}),f.jsx("button",{onClick:()=>void S(),className:Mu,children:a("workflows.delete")}),f.jsx("button",{onClick:i,className:Ui,children:a("workflows.run_button")})]})]}),t.description&&f.jsx("p",{className:"text-sm text-on-surface-variant mb-4",children:t.description}),f.jsxs("div",{className:"flex items-center justify-between mb-2",children:[f.jsx("h3",{className:"font-label text-[11px] font-semibold uppercase tracking-widest text-on-surface-variant",children:a("workflows.stepsTitle",{count:T.length})}),f.jsx("button",{onClick:()=>m(!0),className:km,children:a("workflows.addStep")})]}),f.jsxs("div",{className:"flex flex-col gap-1 mb-6",children:[T.length===0&&f.jsx("p",{className:"text-xs text-on-surface-variant py-2",children:a("workflows.noSteps")}),T.map((w,M)=>{const D=w.config,F=D.prompt??D.script??"",B=u.has(w.id),$=D.timeout_ms;return f.jsxs("div",{className:`${tl} p-3 transition-colors hover:border-primary/40`,children:[f.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",onClick:()=>v(w.id),children:[f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant w-5 text-center",children:M+1}),f.jsx("span",{className:"text-sm text-on-surface flex-1",children:w.name}),w.transitions&&f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:a(w.transitions.conditions.length===1?"workflows.conditionsOne":"workflows.conditionsOther",{count:w.transitions.conditions.length})}),f.jsxs("div",{className:"flex items-center gap-0.5",onClick:V=>V.stopPropagation(),children:[f.jsx("button",{onClick:()=>void j(w,-1),disabled:M===0,className:qr,title:a("workflows.moveUp"),children:"↑"}),f.jsx("button",{onClick:()=>void j(w,1),disabled:M===T.length-1,className:qr,title:a("workflows.moveDown"),children:"↓"}),f.jsx("button",{onClick:()=>x(w),className:qr,title:a("workflows.edit"),children:"✎"}),f.jsx("button",{onClick:()=>void N(w),className:Mu,title:a("workflows.delete"),children:"✕"})]}),f.jsx("span",{className:"text-[10px] text-on-surface-variant transition-transform",style:{transform:B?"rotate(90deg)":"none"},children:"▶"})]}),!B&&F&&f.jsx("p",{className:"mt-1 ml-7 text-xs text-on-surface-variant truncate",children:F}),B&&f.jsxs("div",{className:"mt-2 ml-7",children:[F&&f.jsx("pre",{className:"font-mono text-xs text-on-surface-variant whitespace-pre-wrap break-words leading-relaxed p-2 bg-surface-container-low rounded max-h-80 overflow-auto",children:F}),f.jsxs("div",{className:"flex gap-4 mt-1.5 font-mono text-[10px] text-on-surface-variant",children:[$&&f.jsx("span",{children:a("workflows.stepTimeout",{seconds:$/1e3})}),f.jsx("span",{children:a("workflows.stepId",{id:w.id.slice(0,8)})})]})]})]},w.id)})]}),f.jsx("h3",{className:"font-label text-[11px] font-semibold uppercase tracking-widest text-on-surface-variant mb-2",children:a("workflows.runHistoryTitle",{count:n.length})}),n.length===0?f.jsx("p",{className:"text-xs text-on-surface-variant",children:a("workflows.noRuns")}):f.jsx("div",{className:"flex flex-col gap-1",children:n.map(w=>f.jsxs("div",{onClick:()=>c(w.id),className:`${tl} flex items-center justify-between p-2.5 cursor-pointer transition-colors hover:border-primary/40`,children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:`h-2 w-2 rounded-full ${e5[w.status]??"bg-outline"}`}),f.jsx("span",{className:"text-sm text-on-surface",children:w.status}),f.jsxs("span",{className:"font-mono text-[11px] text-on-surface-variant",children:["(",w.trigger,")"]})]}),f.jsxs("div",{className:"font-mono text-[10px] text-on-surface-variant",children:[new Date(w.startedAt).toLocaleString(),w.finishedAt&&` · ${((w.finishedAt-w.startedAt)/1e3).toFixed(1)}s`]})]},w.id))}),h&&f.jsx(bC,{title:a("workflows.editWorkflow"),initial:{name:t.name,description:t.description,status:t.status},allowStatus:!0,onSave:b,onCancel:()=>p(!1)}),g&&f.jsx(Y0,{title:a("workflows.addStepTitle"),onSave:C,onCancel:()=>m(!1)}),y&&f.jsx(Y0,{title:a("workflows.editStepTitle"),initial:y,onSave:_,onCancel:()=>x(null)})]})}function n5({agentId:e}){const{t}=we(),[n,r]=E.useState([]),[i,s]=E.useState(null),[o,a]=E.useState([]),[l,c]=E.useState(null),[u,d]=E.useState(!1),h=E.useCallback(async()=>{try{const b=await _R(e);r(b)}catch{}},[e]);E.useEffect(()=>{h();const b=setInterval(()=>{h()},4e3);return()=>clearInterval(b)},[h]);const p=async b=>{const[S,C]=await Promise.all([Uy(e,b),Sf(e,b)]);s(S),a(C)},g=async b=>{c(b);try{await kR(e,b);const S=await Sf(e,b);a(S)}catch(S){console.error("Failed to trigger workflow:",S)}finally{c(null)}},m=async b=>{const S=await CR(e,b);d(!1),await h(),await p(S.id)};if(i)return f.jsx(t5,{agentId:e,workflow:i,runs:o,onBack:async()=>{s(null),await h()},onRun:()=>g(i.id),onRefresh:async()=>{const[b,S]=await Promise.all([Uy(e,i.id),Sf(e,i.id)]);s(b),a(S)},onDeleted:async()=>{s(null),await h()}});const y={active:Ap,paused:Ky,archived:jc},x=b=>b==="running"?"inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-mono font-medium bg-primary/15 text-primary":b==="completed"?`${Ap} text-[10px]`:b==="failed"?`${Ky} text-[10px]`:b==="cancelled"?`${jc} text-[10px]`:"",v=b=>{const S=Date.now()-b,C=Math.floor(S/1e3);if(C<60)return`${C}s`;const _=Math.floor(C/60);if(_<60)return`${_}m`;const N=Math.floor(_/60);return N<24?`${N}h`:`${Math.floor(N/24)}d`};return f.jsxs("div",{className:"p-3 sm:p-4 min-w-0",children:[f.jsxs("div",{className:"flex items-center justify-between mb-4",children:[f.jsx("h2",{className:"font-headline text-xl font-bold text-on-surface",children:t("workflows.title")}),f.jsx("button",{onClick:()=>d(!0),className:km,children:t("workflows.newWorkflow")})]}),n.length===0?f.jsx("p",{className:"font-mono text-xs text-on-surface-variant",children:t("workflows.emptyText")}):f.jsx("div",{className:"flex flex-col gap-2",children:n.map(b=>f.jsxs("div",{onClick:()=>p(b.id),className:`${tl} p-4 cursor-pointer transition-colors hover:border-primary/40`,children:[f.jsxs("div",{className:"flex items-center justify-between gap-3",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[f.jsx("span",{className:"font-headline font-bold text-on-surface truncate",children:b.name}),f.jsx("span",{className:y[b.status]??jc,children:b.status}),b.lastRun&&f.jsxs("span",{className:x(b.lastRun.status),children:[b.lastRun.status==="running"&&f.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-pulse"}),t(`workflows.runStatus.${b.lastRun.status}`),f.jsxs("span",{className:"opacity-60",children:["· ",v(b.lastRun.finishedAt??b.lastRun.startedAt)]})]})]}),f.jsx("button",{onClick:S=>{S.stopPropagation(),g(b.id)},disabled:l===b.id||b.status!=="active",className:Ui,children:l===b.id?t("workflows.running"):t("workflows.run")})]}),b.description&&f.jsx("p",{className:"mt-1.5 text-sm text-on-surface-variant",children:b.description}),f.jsx("div",{className:"mt-1 font-mono text-[10px] text-on-surface-variant/60",children:t("workflows.createdOn",{id:b.id,date:new Date(b.createdAt).toLocaleDateString()})})]},b.id))}),u&&f.jsx(bC,{title:t("workflows.newWorkflow"),onSave:m,onCancel:()=>d(!1)})]})}function r5(e){const t=e.split(" ");if(t.length!==5)return e;const[n,r,i,s,o]=t;if(i==="*"&&s==="*"&&o==="*"){if(r!=="*"&&n!=="*")return`Daily at ${r.padStart(2,"0")}:${n.padStart(2,"0")}`;if(r==="*"&&n==="0")return"Every hour";if(r==="*")return`Every hour at :${n.padStart(2,"0")}`}if(i==="*"&&s==="*"&&o!=="*"){const a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],l=o.split(",").map(c=>a[Number(c)]??c).join(", ");if(r!=="*"&&n!=="*")return`${l} at ${r.padStart(2,"0")}:${n.padStart(2,"0")}`}return e}function X0(e){if(!e)return"—";const t=e-Date.now(),n=Math.abs(t);if(n<6e4)return t>0?"in <1m":"<1m ago";if(n<36e5){const i=Math.round(n/6e4);return t>0?`in ${i}m`:`${i}m ago`}if(n<864e5){const i=Math.round(n/36e5);return t>0?`in ${i}h`:`${i}h ago`}const r=Math.round(n/864e5);return t>0?`in ${r}d`:`${r}d ago`}function i5({agentId:e,run:t,onBack:n}){const{t:r}=we(),[i,s]=E.useState([]),[o,a]=E.useState(!0),l=E.useCallback(async()=>{try{const c=await bR(e,t.channelId);s(c)}catch{}a(!1)},[e,t.channelId]);return E.useEffect(()=>{l();const c=setInterval(()=>{l()},2e3);return()=>clearInterval(c)},[l]),f.jsxs("div",{className:"p-4 flex flex-col gap-3",children:[f.jsx("button",{onClick:n,className:"text-[10px] text-on-surface-variant hover:text-on-surface transition-colors self-start",children:r("schedules.backToRuns")}),f.jsxs("div",{className:"text-[9px] font-mono text-on-surface-variant/60",children:[new Date(t.startedAt).toLocaleString()," · ",t.channelId]}),o&&f.jsx("div",{className:"text-xs text-on-surface-variant/70",children:r("schedules.loading")}),!o&&i.length===0&&f.jsx("div",{className:"text-xs text-on-surface-variant/70 animate-pulse",children:r("schedules.waitingResponse")}),f.jsx("div",{className:"space-y-2",children:i.map(c=>f.jsxs("div",{className:`rounded-md p-2.5 text-[11px] leading-relaxed whitespace-pre-wrap ${c.role==="user"?"bg-surface-container-lowest border border-outline-variant/40 text-on-surface-variant/70":c.role==="tool_call"?"bg-surface-container-low text-on-surface-variant/70 font-mono text-[10px]":"bg-surface-container text-on-surface/90"}`,children:[c.role==="tool_call"&&f.jsx("span",{className:"text-info/60 mr-1",children:"⚙"}),c.content]},c.id))})]})}function s5({agentId:e,schedule:t,onBack:n}){const{t:r}=we(),[i,s]=E.useState([]),[o,a]=E.useState(null),[l,c]=E.useState(!1),u=E.useCallback(async()=>{try{s(await yR(e,t.id))}catch{}},[e,t.id]);E.useEffect(()=>{u()},[u]);async function d(){c(!0);try{await vR(e,t.id),await u()}finally{c(!1)}}return o?f.jsx(i5,{agentId:e,run:o,onBack:()=>a(null)}):f.jsxs("div",{className:"p-4 flex flex-col gap-3",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:n,className:"text-[10px] text-on-surface-variant hover:text-on-surface transition-colors",children:"←"}),f.jsx("span",{className:"text-xs text-on-surface font-medium flex-1 truncate",children:t.name}),f.jsx("button",{onClick:d,disabled:l,className:"text-[9px] px-2 py-0.5 rounded bg-surface-container text-on-surface-variant/60 hover:text-on-surface transition-colors disabled:opacity-40",children:r(l?"schedules.triggering":"schedules.runNow")})]}),f.jsx("span",{className:"text-[10px] uppercase tracking-[0.14em] text-on-surface-variant/70 font-medium",children:r("schedules.runHistory")}),i.length===0&&f.jsx("p",{className:"text-[10px] text-on-surface-variant/60",children:r("schedules.noRuns")}),i.map(h=>f.jsxs("button",{onClick:()=>a(h),className:"text-left rounded-md bg-surface-container-low border border-outline-variant/40 p-2.5 hover:bg-surface-container-highest transition-colors",children:[f.jsx("div",{className:"text-[10px] text-on-surface/80",children:new Date(h.startedAt).toLocaleString()}),f.jsx("div",{className:"text-[9px] font-mono text-on-surface-variant/60 mt-0.5",children:h.channelId})]},h.id))]})}function o5({agentId:e}){const{t}=we(),[n,r]=E.useState([]),[i,s]=E.useState(!0),[o,a]=E.useState(null),l=()=>{gR(e).then(r).catch(console.error).finally(()=>s(!1))};E.useEffect(()=>{l()},[e]),E.useEffect(()=>{const h=setInterval(()=>r(p=>[...p]),3e4);return()=>clearInterval(h)},[]);async function c(h){const p=h.status==="active"?"paused":"active";await mR(e,h.id,{status:p}),l()}async function u(h){confirm(t("schedules.deleteConfirm",{name:h.name}))&&(await xR(e,h.id),l())}if(o)return f.jsx(s5,{agentId:e,schedule:o,onBack:()=>a(null)});if(i)return f.jsx("div",{className:"text-on-surface-variant/70 text-xs p-6",children:t("schedules.loadingList")});if(n.length===0)return f.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center p-6 gap-3",children:[f.jsx("span",{className:"text-3xl opacity-30",children:"⏰"}),f.jsx("p",{className:"text-on-surface-variant text-xs",children:t("schedules.emptyText")})]});const d=n.filter(h=>h.status==="active").length;return f.jsxs("div",{className:"p-3 sm:p-4 space-y-2 min-w-0",children:[f.jsxs("div",{className:"flex items-center justify-between mb-3",children:[f.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] text-on-surface-variant/60 font-medium",children:t("schedules.title")}),f.jsx("span",{className:"text-[9px] font-mono text-on-surface-variant/60",children:t(d===1?"schedules.activeCountOne":"schedules.activeCountOther",{count:d})})]}),n.map(h=>f.jsxs("div",{onClick:()=>a(h),className:"rounded-md bg-surface-container-low border border-outline-variant/40 p-3 space-y-2 cursor-pointer hover:bg-surface-container-highest transition-colors",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${h.status==="active"?"bg-green-500":"bg-yellow-500/50"}`}),f.jsx("span",{className:"text-xs text-on-surface font-medium flex-1 truncate",children:h.name}),f.jsx("span",{className:"text-[9px] font-mono text-on-surface-variant/70",children:h.id})]}),f.jsx("p",{className:"text-[10px] text-on-surface-variant font-mono leading-relaxed break-words",style:{whiteSpace:"pre-wrap"},children:h.message}),f.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-on-surface-variant/70",children:[f.jsx("span",{title:h.cron,children:r5(h.cron)}),f.jsx("span",{children:h.timezone}),f.jsx("span",{title:h.nextRun?new Date(h.nextRun).toISOString():"",children:t("schedules.next",{time:X0(h.nextRun)})}),h.lastRun&&f.jsx("span",{title:new Date(h.lastRun).toISOString(),children:t("schedules.last",{time:X0(h.lastRun)})})]}),f.jsxs("div",{className:"flex items-center gap-2 pt-1",onClick:p=>p.stopPropagation(),children:[f.jsx("button",{onClick:()=>c(h),className:"text-[9px] px-2 py-0.5 rounded bg-surface-container text-on-surface-variant/60 hover:text-on-surface transition-colors",children:h.status==="active"?t("schedules.pause"):t("schedules.resume")}),f.jsx("button",{onClick:()=>u(h),className:"text-[9px] px-2 py-0.5 rounded bg-surface-container text-error/60 hover:text-error transition-colors ml-auto",children:t("schedules.delete")})]})]},h.id))]})}function J0(e){const t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);return r<60?`${r}m ago`:`${Math.floor(r/60)}h ${r%60}m ago`}function ks({tone:e,pulse:t}){const n=e==="success"?"bg-success":e==="warning"?"bg-warning":e==="primary"?"bg-primary":e==="info"?"bg-info":e==="muted"?"bg-outline":"bg-outline/50";return f.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full flex-shrink-0 ${t?"animate-pulse":""} ${n}`})}function Q0({info:e,label:t,extra:n}){const{t:r}=we();return e?f.jsxs("div",{className:"rounded bg-surface-container-lowest border border-outline-variant/40 p-3 space-y-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(ks,{tone:"success",pulse:!0}),f.jsx("span",{className:"font-label text-[10px] uppercase tracking-wider text-on-surface font-semibold",children:t}),f.jsxs("span",{className:"font-mono text-[9px] text-on-surface-variant/60 ml-auto",children:["PID ",e.pid]})]}),f.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:r("monitor.cpu")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:e.cpu})]}),f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:r("monitor.mem")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:e.mem})]}),f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:r("monitor.rss")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:e.rss})]}),f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:r("monitor.uptime")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:e.elapsed})]})]}),n,f.jsx("p",{className:"font-mono text-[8px] text-on-surface-variant/20 truncate",title:e.command,children:e.command})]}):null}function a5({agentId:e}){const{t}=we(),[n,r]=E.useState(null);if(E.useEffect(()=>{const c=()=>hR(e).then(r).catch(console.error);c();const u=setInterval(c,2e3);return()=>clearInterval(u)},[e]),!n)return f.jsx("div",{className:"text-on-surface-variant/70 text-xs p-6",children:t("monitor.loading")});const i=n.jobs.processing,s=n.jobs.pending,o=n.workflows,a=n.claudeProcesses.length,l=i.length===0&&o.length===0&&a===0;return f.jsxs("div",{className:"flex flex-col h-full min-w-0 bg-surface-container-lowest",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-outline-variant/30",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-[13px] opacity-60",children:"📡"}),f.jsx("span",{className:"font-label text-[11px] uppercase tracking-[0.14em] font-semibold text-on-surface",children:t("monitor.title")})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("span",{className:`font-mono text-[9px] ${l?"text-on-surface-variant/60":"text-secondary"}`,children:l?t("monitor.idle"):t(a===1?"monitor.claudeSessionsOne":"monitor.claudeSessionsOther",{count:a})}),f.jsx("span",{className:`h-1.5 w-1.5 rounded-full animate-pulse ${l?"bg-outline/50":"bg-success"}`})]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scrollbar-thin",children:[f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[9px] uppercase tracking-[0.18em] text-on-surface-variant font-semibold mb-2",children:t("monitor.processes")}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Q0,{info:n.agent,label:t("monitor.agentProcess"),extra:n.agent?f.jsxs("span",{className:"font-mono text-[9px] text-primary/40",children:["pid ",n.agent.pid]}):void 0}),f.jsx(Q0,{info:n.guardian,label:t("monitor.guardianProcess")}),n.browserProcess&&f.jsxs("div",{className:"rounded bg-surface-container-lowest border border-outline-variant/40 p-3",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(ks,{tone:"warning",pulse:!0}),f.jsx("span",{className:"font-label text-[10px] uppercase tracking-wider text-on-surface font-semibold",children:t("monitor.browserDaemon")}),f.jsxs("span",{className:"font-mono text-[9px] text-on-surface-variant/60 ml-auto",children:["PID ",n.browserProcess.pid]})]}),f.jsxs("div",{className:"grid grid-cols-3 gap-2 mt-2",children:[f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:t("monitor.cpu")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:n.browserProcess.cpu})]}),f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:t("monitor.mem")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:n.browserProcess.mem})]}),f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:t("monitor.rss")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:n.browserProcess.rss})]})]})]})]})]}),a>0&&f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[9px] uppercase tracking-[0.18em] text-on-surface-variant font-semibold mb-2",children:t("monitor.activeClaudeSessions",{count:a})}),f.jsx("div",{className:"space-y-1.5",children:n.claudeProcesses.map(c=>f.jsxs("div",{className:"rounded bg-surface-container-lowest border border-outline-variant/40 p-3",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[f.jsx(ks,{tone:"primary",pulse:!0}),f.jsx("span",{className:"font-mono text-[10px] text-on-surface/70",children:"claude"}),f.jsxs("span",{className:"font-mono text-[9px] text-on-surface-variant/60 ml-auto",children:["PID ",c.pid]})]}),f.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:t("monitor.cpu")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:c.cpu})]}),f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:t("monitor.mem")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:c.mem})]}),f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:t("monitor.rss")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:c.rss})]}),f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:t("monitor.uptime")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:c.elapsed})]})]}),f.jsx("p",{className:"font-mono text-[8px] text-on-surface-variant/20 mt-1.5 break-all leading-relaxed",style:{whiteSpace:"pre-wrap"},children:c.command})]},c.pid))})]}),f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[9px] uppercase tracking-[0.18em] text-on-surface-variant font-semibold mb-2",children:t("monitor.jobQueue",{processing:i.length,pending:s.length})}),i.length===0&&s.length===0?f.jsx("p",{className:"text-[10px] text-on-surface-variant italic",children:t("monitor.noActiveJobs")}):f.jsxs("div",{className:"space-y-1.5",children:[i.map(c=>f.jsxs("div",{className:"rounded bg-surface-container-lowest border border-outline-variant/40 p-2.5",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx(ks,{tone:"success",pulse:!0}),f.jsx("span",{className:"font-mono text-[9px] text-secondary/70 uppercase",children:t("monitor.processing")}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60 ml-auto",children:c.channelId}),f.jsx("button",{onClick:()=>Vy(e,c.id).catch(console.error),className:"text-[8px] px-1.5 py-0.5 rounded bg-red-950/30 text-error/60 hover:text-error hover:bg-red-950/50 transition-colors",children:t("monitor.terminate")})]}),f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant leading-relaxed break-words",style:{whiteSpace:"pre-wrap"},children:c.message}),f.jsx("span",{className:"font-mono text-[8px] text-on-surface-variant/20 mt-1 block",children:J0(c.createdAt)})]},c.id)),s.map(c=>f.jsxs("div",{className:"rounded bg-surface-container-lowest p-2.5",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx(ks,{tone:"muted"}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/70 uppercase",children:t("monitor.queued")}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60 ml-auto",children:c.channelId}),f.jsx("button",{onClick:()=>Vy(e,c.id).catch(console.error),className:"text-[8px] px-1.5 py-0.5 rounded bg-surface-container text-on-surface-variant/70 hover:text-error transition-colors",children:t("monitor.cancel")})]}),f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant/70 leading-relaxed break-words",style:{whiteSpace:"pre-wrap"},children:c.message})]},c.id))]})]}),o.length>0&&f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[9px] uppercase tracking-[0.18em] text-on-surface-variant font-semibold mb-2",children:t("monitor.runningWorkflows")}),f.jsx("div",{className:"space-y-1.5",children:o.map(c=>f.jsxs("div",{className:"rounded bg-surface-container-lowest border border-outline-variant/40 p-2.5 flex items-center gap-2",children:[f.jsx(ks,{tone:"warning",pulse:!0}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("span",{className:"font-mono text-[10px] text-on-surface/70",children:c.workflowName}),f.jsx("span",{className:"font-mono text-[8px] text-on-surface-variant/60 ml-2",children:c.runId.slice(0,8)})]}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60 flex-shrink-0",children:J0(c.startedAt)})]},c.runId))})]})]})]})}/*!
122
+ bg-primary/20 text-primary hover:bg-primary/30`,children:t(h?"files.savingLabel":"files.saveButton")}),o&&f.jsx("button",{onClick:()=>{a(null),c(""),d("")},className:"rounded px-2 py-1 text-[11px] text-on-surface-variant/70 hover:text-on-surface-variant transition-colors",children:"×"})]}),g&&f.jsx("div",{className:"px-4 py-2 bg-error/10",children:f.jsx("p",{className:"font-mono text-[10px] text-error/70",children:g})}),o?f.jsx("textarea",{className:"flex-1 w-full resize-none bg-transparent px-4 py-3 font-mono text-[12px] text-on-surface/90 leading-relaxed outline-none",style:{tabSize:2},value:l,onChange:_=>c(_.target.value),spellCheck:!1}):f.jsx("div",{className:"flex-1 overflow-y-auto",children:i.length===0?f.jsx("p",{className:"font-mono text-[11px] text-on-surface-variant/60 p-4 italic",children:t("files.emptyDir")}):f.jsxs("div",{className:"flex flex-col",children:[n&&f.jsxs("button",{onClick:()=>{const _=n.split("/").slice(0,-1).join("/");x(_)},className:"flex items-center gap-3 px-4 py-2 text-left transition-colors hover:bg-surface-container/50",children:[f.jsx("span",{className:"text-[13px] opacity-40",children:"↩"}),f.jsx("span",{className:"font-mono text-[11px] text-on-surface-variant",children:".."})]}),i.map(_=>f.jsxs("button",{onClick:()=>S(_),className:"group flex items-center gap-3 px-4 py-2 text-left transition-colors hover:bg-surface-container/50",children:[f.jsx("span",{className:"text-[13px] opacity-50 group-hover:opacity-80 transition-opacity",children:_.type==="directory"?"📁":"📄"}),f.jsx("span",{className:`font-mono text-[11px] flex-1 truncate ${_.type==="directory"?"text-primary/70":"text-on-surface/70"}`,children:_.name}),_.size!==void 0&&f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/25 tabular-nums",children:_.size<1024?`${_.size}B`:`${(_.size/1024).toFixed(1)}K`})]},_.name))]})})]})}function vC(){const{t:e}=we();return t=>{const n=Date.now()-t*1e3,r=Math.floor(n/1e3);if(r<60)return e("tasks.relativeNow");const i=Math.floor(r/60);if(i<60)return e("tasks.relativeMinutes",{n:i});const s=Math.floor(i/60);if(s<24)return e("tasks.relativeHours",{n:s});const o=Math.floor(s/24);return e("tasks.relativeDays",{n:o})}}const Hf="rounded bg-surface-container px-2.5 py-[7px] text-[11px] text-on-surface placeholder:text-on-surface-variant/60 outline-none focus:ring-1 focus:ring-primary/25 transition-shadow w-full";function Gp({source:e}){return f.jsx("span",{className:`rounded-full px-1.5 py-[2px] text-[8px] font-semibold uppercase tracking-[0.08em] ${e==="agent"?"bg-secondary-container text-on-primary":"bg-primary text-on-surface"}`,children:e})}function R$({comment:e}){const t=vC();return f.jsxs("div",{className:"flex flex-col gap-1 py-3",style:{borderTop:"1px solid rgba(255,255,255,0.04)"},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Gp,{source:e.source}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60",children:t(e.createdAt)})]}),f.jsx("div",{className:"text-[12px] text-on-surface/80 leading-relaxed prose prose-sm dark:prose-invert max-w-none",children:f.jsx(yd,{children:e.body})})]})}function D$({task:e,columns:t,onClose:n,onUpdate:r,onAddComment:i,onDelete:s}){const{t:o}=we(),a=vC(),[l,c]=E.useState(!1),[u,d]=E.useState(e.title),[h,p]=E.useState(!1),[g,m]=E.useState(e.description),[y,x]=E.useState(""),[v,b]=E.useState(!1),[S,C]=E.useState(!1),[_,N]=E.useState(!1),[j,T]=E.useState(""),[w,M]=E.useState(e.id);e.id!==w&&(M(e.id),d(e.title),m(e.description),c(!1),p(!1),x(""),T(""));const D=async()=>{if(c(!1),u.trim()&&u.trim()!==e.title){C(!0);try{await r(e.id,{title:u.trim()})}finally{C(!1)}}else d(e.title)},F=async()=>{if(p(!1),g!==e.description){C(!0);try{await r(e.id,{description:g})}finally{C(!1)}}},B=async k=>{C(!0);try{await r(e.id,{status:k})}finally{C(!1)}},$=async k=>{const L=k.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"");if(!(!L||e.tags.includes(L))){C(!0);try{await r(e.id,{tags:[...e.tags,L]})}finally{C(!1)}}},V=async k=>{C(!0);try{await r(e.id,{tags:e.tags.filter(L=>L!==k)})}finally{C(!1)}},Y=async()=>{if(y.trim()){b(!0);try{await i(e.id,y.trim()),x("")}finally{b(!1)}}},I=async()=>{if(confirm(o("taskDetail.deleteConfirm",{title:e.title}))){N(!0);try{await s(e.id)}finally{N(!1)}}},z=e.updatedBy!==null&&e.updatedBy!==e.source;return f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"fixed inset-0 z-40",style:{background:"rgba(0,0,0,0.35)"},onClick:n}),f.jsxs("div",{className:"fixed inset-y-0 right-0 w-[min(840px,92vw)] z-50 flex flex-col overflow-hidden bg-surface-container",style:{boxShadow:"-8px 0 40px rgba(0,0,0,0.5)"},children:[f.jsxs("div",{className:"flex items-center justify-between px-5 py-4 flex-shrink-0",style:{borderBottom:"1px solid rgba(255,255,255,0.05)"},children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx("span",{className:"font-mono text-[10px] text-primary/40 flex-shrink-0",children:e.id}),S&&f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60 animate-pulse",children:o("taskDetail.saving")})]}),f.jsx("button",{onClick:n,className:"text-on-surface-variant/70 hover:text-on-surface transition-colors text-[18px] leading-none flex-shrink-0","aria-label":o("taskDetail.close"),children:"×"})]}),f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsxs("div",{className:"px-5 py-4 flex flex-col gap-5",children:[f.jsx("div",{children:l?f.jsx("input",{autoFocus:!0,className:`${Hf} text-[15px] font-semibold font-headline`,value:u,onChange:k=>d(k.target.value),onBlur:D,onKeyDown:k=>{k.key==="Enter"&&D(),k.key==="Escape"&&(c(!1),d(e.title))}}):f.jsx("h2",{className:"font-headline text-[17px] font-semibold text-on-surface tracking-[-0.01em] cursor-pointer hover:text-primary/90 transition-colors",onClick:()=>c(!0),title:"Click to edit",children:e.title})}),f.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold",children:o("taskDetail.status")}),f.jsx("select",{value:e.status,onChange:k=>void B(k.target.value),className:"rounded bg-surface-container px-2.5 py-[7px] text-[11px] text-on-surface outline-none focus:ring-1 focus:ring-primary/25 cursor-pointer font-mono transition-shadow",children:t.map(k=>f.jsx("option",{value:k.id,children:k.label},k.id))})]}),f.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold",children:o("taskDetail.tags")}),f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.tags.map(k=>f.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-primary/10 px-2 py-[2px] text-[10px] font-mono text-primary/70",children:[k,f.jsx("button",{onClick:()=>void V(k),className:"text-primary/40 hover:text-error/70 transition-colors leading-none",children:"×"})]},k)),f.jsx("input",{className:"rounded bg-surface-container px-2 py-[4px] text-[10px] text-on-surface placeholder:text-on-surface-variant/40 outline-none focus:ring-1 focus:ring-primary/25 font-mono w-24",placeholder:o("taskDetail.addTag"),value:j,onChange:k=>T(k.target.value),onKeyDown:k=>{k.key==="Enter"&&j.trim()&&($(j),T("")),k.key==="Escape"&&T("")}})]})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"text-[8px] uppercase tracking-[0.15em] text-on-surface-variant/60",children:o("taskDetail.sourceLabel")}),f.jsx(Gp,{source:e.source})]}),z&&e.updatedBy&&f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"text-[8px] uppercase tracking-[0.15em] text-on-surface-variant/60",children:o("taskDetail.editedByLabel")}),f.jsx(Gp,{source:e.updatedBy})]})]}),f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsxs("p",{className:"font-mono text-[10px] text-on-surface-variant/60",children:[f.jsx("span",{className:"text-on-surface-variant/20",children:o("taskDetail.created")})," ",a(e.createdAt)]}),f.jsxs("p",{className:"font-mono text-[10px] text-on-surface-variant/60",children:[f.jsx("span",{className:"text-on-surface-variant/20",children:o("taskDetail.updated")})," ",a(e.updatedAt)]})]}),f.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold",children:o("taskDetail.description")}),h?f.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.jsx("textarea",{autoFocus:!0,className:`${Hf} min-h-[360px] resize-y font-mono text-[12px] leading-relaxed`,value:g,onChange:k=>m(k.target.value),placeholder:o("taskDetail.descPlaceholder")}),f.jsxs("div",{className:"flex gap-1.5",children:[f.jsx("button",{onClick:F,className:"flex-1 rounded bg-primary/15 px-2 py-1.5 text-[10px] text-primary/70 hover:bg-primary/25 transition-colors",children:o("taskDetail.save")}),f.jsx("button",{onClick:()=>{p(!1),m(e.description)},className:"rounded bg-surface-container px-2 py-1.5 text-[10px] text-on-surface-variant/70 hover:text-on-surface-variant/70 transition-colors",children:o("taskDetail.cancel")})]})]}):f.jsx("div",{className:"cursor-pointer group",onClick:()=>p(!0),title:"Click to edit",children:e.description?f.jsx("div",{className:"text-[12px] text-on-surface/70 leading-relaxed prose prose-sm dark:prose-invert max-w-none group-hover:text-on-surface/90 transition-colors",children:f.jsx(yd,{children:e.description})}):f.jsx("p",{className:"font-mono text-[11px] text-on-surface-variant/25 italic group-hover:text-on-surface-variant/70 transition-colors",children:o("taskDetail.descEmpty")})})]}),f.jsxs("div",{className:"flex flex-col gap-0",children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold mb-1",children:o("taskDetail.commentsLabel",{count:e.comments.length})}),e.comments.length===0&&f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant/25 italic py-2",children:o("taskDetail.noComments")}),e.comments.map(k=>f.jsx(R$,{comment:k},k.id))]}),f.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold",children:o("taskDetail.addComment")}),f.jsx("textarea",{className:`${Hf} min-h-[200px] resize-y font-mono text-[12px] leading-relaxed`,placeholder:o("taskDetail.commentPlaceholder"),value:y,onChange:k=>x(k.target.value)}),f.jsx("button",{disabled:!y.trim()||v,onClick:Y,className:"self-end rounded bg-primary/15 px-3 py-1.5 text-[10px] text-primary/70 hover:bg-primary/25 transition-colors disabled:opacity-30",children:o(v?"taskDetail.publishing":"taskDetail.publishComment")})]}),f.jsxs("div",{className:"mt-2 pt-4",style:{borderTop:"1px solid rgba(255,255,255,0.04)"},children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-error/30 font-semibold mb-2",children:o("taskDetail.dangerZone")}),f.jsx("button",{onClick:I,disabled:_,className:"w-full rounded bg-red-950/15 px-3 py-2 text-left font-mono text-[11px] text-error/60 transition-all hover:bg-red-950/30 hover:text-error disabled:opacity-20",children:o(_?"taskDetail.deleting":"taskDetail.deleteTask")})]}),f.jsx("div",{className:"h-4"})]})})]})]})}function A$(){const{t:e}=we();return t=>{const n=Date.now()-t*1e3,r=Math.floor(n/1e3);if(r<60)return e("tasks.relativeNow");const i=Math.floor(r/60);if(i<60)return e("tasks.relativeMinutes",{n:i});const s=Math.floor(i/60);if(s<24)return e("tasks.relativeHours",{n:s});const o=Math.floor(s/24);return e("tasks.relativeDays",{n:o})}}function L$(e){return e.replace(/#{1,6}\s/g,"").replace(/(\*\*|__)(.*?)\1/g,"$2").replace(/(\*|_)(.*?)\1/g,"$2").replace(/`{1,3}[^`]*`{1,3}/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/^\s*[-*+]\s/gm,"").replace(/^\s*\d+\.\s/gm,"").replace(/\n+/g," ").trim()}function I$({task:e,onDragStart:t,onClick:n}){const{t:r}=we(),i=A$(),s=L$(e.description).slice(0,120),o=e.updatedBy!==null&&e.updatedBy!==e.source;return f.jsxs("div",{draggable:!0,onDragStart:()=>t(e.id),onClick:()=>n(e),className:"rounded-md p-3 cursor-pointer transition-colors hover:brightness-110 select-none bg-surface-container-high",children:[f.jsxs("div",{className:"flex items-center justify-between mb-1.5 gap-1",children:[f.jsx("span",{className:"font-mono text-[9px] text-primary/40 truncate",children:e.id}),f.jsx("span",{className:`flex-shrink-0 rounded-full px-1.5 py-[2px] text-[8px] font-semibold uppercase tracking-[0.08em] ${e.source==="agent"?"bg-secondary-container text-on-primary":"bg-primary text-on-surface"}`,children:e.source})]}),f.jsx("p",{className:"text-[12px] font-semibold text-on-surface leading-tight mb-1",children:e.title}),s&&f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant leading-snug line-clamp-2 mb-2",children:s}),e.tags.length>0&&f.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:e.tags.map(a=>f.jsx("span",{className:"rounded-full bg-primary/10 px-1.5 py-[1px] text-[8px] font-mono text-primary/60",children:a},a))}),f.jsxs("div",{className:"flex items-center justify-between gap-1 mt-1",children:[f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60",children:i(e.createdAt)}),o&&f.jsx("span",{className:"font-mono text-[8px] text-warning/50 truncate",children:r("tasks.editedBy",{name:e.updatedBy??""})})]})]})}function O$({agentId:e}){const{t}=we(),[n,r]=E.useState([]),[i,s]=E.useState([]),[o,a]=E.useState(null),[l,c]=E.useState(null),[u,d]=E.useState(null),[h,p]=E.useState(""),[g,m]=E.useState(""),[y,x]=E.useState(""),[v,b]=E.useState(null),[S,C]=E.useState(!1),[_,N]=E.useState(""),j=E.useMemo(()=>{const L=new Set;for(const U of n)for(const P of U.tags)L.add(P);return Array.from(L).sort()},[n]),T=E.useMemo(()=>{let L=n;if(y.trim()){const U=y.toLowerCase();L=L.filter(P=>P.title.toLowerCase().includes(U)||P.description.toLowerCase().includes(U))}return v&&(L=L.filter(U=>U.tags.includes(v))),L},[n,y,v]),w=E.useCallback(async()=>{try{r(await tR(e))}catch{}},[e]),M=E.useCallback(async()=>{try{s(await aR(e))}catch{}},[e]);E.useEffect(()=>{w(),M();const L=setInterval(()=>{w()},4e3);return()=>clearInterval(L)},[w,M]);const D=E.useCallback(async L=>{try{const U=await nR(e,L.id);a(U)}catch{a({...L,comments:[]})}},[e]),F=E.useCallback(async L=>{if(!l)return;const U=n.find(P=>P.id===l);if(!U||U.status===L){c(null);return}try{const P=await Wy(e,l,{status:L});r(J=>J.map(oe=>oe.id===l?P:oe)),a(J=>J&&J.id===l?{...J,...P}:J)}catch{}c(null)},[e,l,n]),B=E.useCallback(async(L,U,P)=>{if(U.trim()){try{const J=await rR(e,{title:U.trim(),description:P.trim()||void 0,status:L});r(oe=>[...oe,J])}catch{}d(null),p(""),m("")}},[e]),$=E.useCallback(async(L,U)=>{const P=await Wy(e,L,U);r(J=>J.map(oe=>oe.id===L?P:oe)),a(J=>J&&J.id===L?{...J,...P}:J)},[e]),V=E.useCallback(async(L,U)=>{const P=await oR(e,L,U);a(J=>J&&J.id===L?{...J,comments:[...J.comments,P]}:J)},[e]),Y=E.useCallback(async L=>{await iR(e,L),r(U=>U.filter(P=>P.id!==L)),a(null)},[e]),I=E.useCallback(async()=>{if(confirm(t("tasks.clearConfirm")))try{await sR(e),r([]),a(null)}catch{}},[e,t]),z=E.useCallback(async()=>{if(_.trim())try{const L=await lR(e,_.trim());s(U=>[...U,L]),N(""),C(!1)}catch{}},[e,_]),k=E.useCallback(async L=>{if(confirm(t("tasks.deleteColumnConfirm")))try{await cR(e,L),s(U=>U.filter(P=>P.id!==L)),w()}catch{}},[e,t,w]);return f.jsxs("div",{className:"flex flex-col flex-1 overflow-hidden",children:[f.jsxs("div",{className:"flex items-center gap-2 px-3 pt-3 pb-1 flex-shrink-0 flex-wrap",children:[f.jsx("input",{className:"rounded bg-surface-container px-2.5 py-[6px] text-[11px] text-on-surface placeholder:text-on-surface-variant/60 outline-none focus:ring-1 focus:ring-primary/25 w-48 font-mono",placeholder:t("tasks.searchPlaceholder"),value:y,onChange:L=>x(L.target.value)}),j.length>0&&f.jsx("div",{className:"flex gap-1 flex-wrap",children:j.map(L=>f.jsx("button",{onClick:()=>b(v===L?null:L),className:`rounded-full px-2 py-[2px] text-[9px] font-mono transition-colors ${v===L?"bg-primary/25 text-primary":"bg-surface-container text-on-surface-variant/60 hover:text-on-surface-variant"}`,children:L},L))}),f.jsx("div",{className:"flex-1"}),f.jsx("button",{onClick:I,className:"rounded bg-red-950/15 px-2.5 py-[5px] text-[9px] font-mono text-error/50 hover:bg-red-950/30 hover:text-error/70 transition-colors",children:t("tasks.clearAll")})]}),f.jsxs("div",{className:"flex flex-1 gap-2 overflow-x-auto p-3 relative",children:[i.map(L=>{const U=T.filter(P=>P.status===L.id);return f.jsx(F$,{columnId:L.id,label:L.label,tasks:U,canDelete:i.length>1,addingTask:u===L.id,newTitle:u===L.id?h:"",newDesc:u===L.id?g:"",onNewTitleChange:P=>p(P),onNewDescChange:P=>m(P),onStartAdding:()=>{d(L.id),p(""),m("")},onCancelAdding:()=>{d(null),p(""),m("")},onConfirmAdding:()=>B(L.id,h,g),onDragStart:P=>c(P),onDrop:F,onCardClick:D,onDeleteColumn:()=>k(L.id)},L.id)}),S?f.jsxs("div",{className:"w-56 flex-shrink-0 flex flex-col gap-2 rounded-md p-3 bg-surface-container",children:[f.jsx("input",{autoFocus:!0,className:"rounded bg-surface-container-high px-2.5 py-[7px] text-[11px] text-on-surface placeholder:text-on-surface-variant/60 outline-none focus:ring-1 focus:ring-primary/25 w-full",placeholder:t("tasks.columnLabelPlaceholder"),value:_,onChange:L=>N(L.target.value),onKeyDown:L=>{L.key==="Enter"&&z(),L.key==="Escape"&&(C(!1),N(""))}}),f.jsxs("div",{className:"flex gap-1.5",children:[f.jsx("button",{disabled:!_.trim(),onClick:z,className:"flex-1 rounded bg-primary/15 px-2 py-1 text-[10px] text-primary/70 hover:bg-primary/25 transition-colors disabled:opacity-30",children:t("tasks.add")}),f.jsx("button",{onClick:()=>{C(!1),N("")},className:"rounded bg-surface-container-high px-2 py-1 text-[10px] text-on-surface-variant/70 hover:text-on-surface-variant transition-colors",children:t("tasks.cancel")})]})]}):f.jsx("button",{onClick:()=>C(!0),className:"w-10 flex-shrink-0 rounded-md flex items-center justify-center text-on-surface-variant/30 hover:text-on-surface-variant/60 hover:bg-surface-container transition-colors text-[16px]",children:"+"})]}),o&&f.jsx(D$,{task:o,columns:i,onClose:()=>a(null),onUpdate:$,onAddComment:V,onDelete:Y})]})}function F$({columnId:e,label:t,tasks:n,canDelete:r,addingTask:i,newTitle:s,newDesc:o,onNewTitleChange:a,onNewDescChange:l,onStartAdding:c,onCancelAdding:u,onConfirmAdding:d,onDragStart:h,onDrop:p,onCardClick:g,onDeleteColumn:m}){const{t:y}=we(),[x,v]=E.useState(!1);return f.jsxs("div",{className:"w-56 flex-shrink-0 flex flex-col gap-0 rounded-md overflow-hidden bg-surface-container",onDragOver:b=>{b.preventDefault(),v(!0)},onDragLeave:()=>v(!1),onDrop:()=>{v(!1),p(e)},children:[f.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5 flex-shrink-0",style:{borderBottom:x?"1px solid rgba(160,120,255,0.25)":"1px solid rgba(255,255,255,0.04)",background:x?"rgba(160,120,255,0.05)":void 0,transition:"background 0.15s, border-color 0.15s"},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"font-mono text-[9px] uppercase tracking-[0.15em] text-on-surface-variant",children:t}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/25 tabular-nums",children:n.length})]}),f.jsxs("div",{className:"flex items-center gap-0.5",children:[f.jsx("button",{onClick:c,className:"text-[12px] text-on-surface-variant/60 hover:text-primary/70 transition-colors leading-none w-5 h-5 flex items-center justify-center rounded hover:bg-primary/10",children:"+"}),r&&f.jsx("button",{onClick:m,className:"text-[10px] text-on-surface-variant/30 hover:text-error/60 transition-colors leading-none w-5 h-5 flex items-center justify-center rounded hover:bg-red-950/20",children:"×"})]})]}),f.jsxs("div",{className:"flex flex-col gap-1.5 p-2 overflow-y-auto flex-1",children:[n.map(b=>f.jsx(I$,{task:b,onDragStart:h,onClick:g},b.id)),i&&f.jsxs("div",{className:"rounded-md p-2.5 flex flex-col gap-2 bg-surface-container-high",children:[f.jsx("input",{autoFocus:!0,className:"rounded bg-surface-container px-2.5 py-[7px] text-[11px] text-on-surface placeholder:text-on-surface-variant/60 outline-none focus:ring-1 focus:ring-primary/25 w-full",placeholder:y("tasks.titlePlaceholder"),value:s,onChange:b=>a(b.target.value),onKeyDown:b=>{b.key==="Escape"&&u()}}),f.jsx("textarea",{className:"rounded bg-surface-container px-2.5 py-[7px] text-[11px] text-on-surface placeholder:text-on-surface-variant/60 outline-none focus:ring-1 focus:ring-primary/25 w-full resize-y min-h-[48px] font-mono",placeholder:y("tasks.descPlaceholder"),value:o,onChange:b=>l(b.target.value),onKeyDown:b=>{b.key==="Escape"&&u()},rows:2}),f.jsxs("div",{className:"flex gap-1.5",children:[f.jsx("button",{disabled:!s.trim(),onClick:d,className:"flex-1 rounded bg-primary/15 px-2 py-1 text-[10px] text-primary/70 hover:bg-primary/25 transition-colors disabled:opacity-30",children:y("tasks.add")}),f.jsx("button",{onClick:u,className:"rounded bg-surface-container px-2 py-1 text-[10px] text-on-surface-variant/70 hover:text-on-surface-variant/70 transition-colors",children:y("tasks.cancel")})]})]})]})]})}function $$({status:e}){const t=e==="active"?"bg-secondary-container text-on-primary":e==="stale"||e==="crashed"?"bg-amber-500/20 text-warning":"bg-surface-container text-on-surface-variant/60";return f.jsx("span",{className:`rounded-full px-1.5 py-[2px] text-[8px] font-semibold uppercase tracking-[0.1em] ${t}`,children:e})}function yC({commands:e,activeIndex:t,onJump:n}){const r=E.useRef(null);return E.useEffect(()=>{var i;(i=r.current)==null||i.scrollIntoView({behavior:"smooth",block:"nearest"})},[t]),e.length===0?null:f.jsxs("div",{className:"w-56 flex-shrink-0 flex flex-col border-l border-outline-variant/30 overflow-hidden bg-surface-container",children:[f.jsx("div",{className:"px-3 py-2 border-b border-outline-variant/30",children:f.jsxs("span",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold",children:["Events (",e.length,")"]})}),f.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-thin",children:e.map((i,s)=>{const o=s===t;return f.jsxs("div",{ref:o?r:void 0,onClick:()=>n(s),className:`px-3 py-2 border-b border-outline-variant/20 transition-colors cursor-pointer hover:bg-surface-container/50 ${o?"bg-primary/10 border-l-2 border-l-primary":""}`,children:[f.jsx("p",{className:`font-mono text-[10px] leading-snug break-all ${o?"text-primary":"text-on-surface-variant"}`,children:i.args}),f.jsx("p",{className:"font-mono text-[8px] text-on-surface-variant/20 mt-0.5",children:new Date(i.timestamp).toLocaleTimeString()})]},s)})})]})}function z$({agentId:e,session:t}){const[n,r]=E.useState(null),[i,s]=E.useState("connecting"),[o,a]=E.useState(null),[l,c]=E.useState(null),[u,d]=E.useState(!1);return E.useEffect(()=>{const h=new WebSocket(sS(e,t.id));let p=!0;return h.onmessage=g=>{if(p)try{const m=JSON.parse(g.data);m.type==="frame"&&m.data?r(`data:image/jpeg;base64,${m.data}`):m.type==="attached"?(s("attached"),m.url!=null&&m.title!=null&&m.index!=null&&c({index:m.index,url:m.url,title:m.title})):m.type==="tab_changed"&&m.url!=null&&m.title!=null&&m.index!=null?(c({index:m.index,url:m.url,title:m.title}),d(!0),window.setTimeout(()=>d(!1),900)):m.type==="unavailable"?(r(null),s("error"),a(m.reason??"stream unavailable")):(m.type==="error"||m.type==="detached")&&(s("error"),a(m.reason??"stream ended"))}catch{}},h.onclose=()=>{p&&s("closed")},h.onerror=()=>{p&&(s("error"),a("websocket error"))},()=>{p=!1;try{h.close()}catch{}}},[e,t.id]),f.jsxs("div",{className:"flex-1 flex items-center justify-center overflow-hidden relative bg-surface-container-lowest",children:[n?f.jsx("img",{src:n,alt:"live browser frame",className:"max-w-full max-h-full object-contain select-none",draggable:!1}):f.jsxs("div",{className:"flex flex-col items-center justify-center text-center p-8",children:[f.jsx("span",{className:"text-[32px] opacity-10 mb-3",children:"📺"}),f.jsxs("p",{className:"font-mono text-[10px] text-on-surface-variant/35",children:[i==="connecting"&&"connecting to live stream…",i==="attached"&&"waiting for first frame…",i==="error"&&`live stream unavailable${o?` — ${o}`:""}`,i==="closed"&&"live stream closed"]})]}),f.jsxs("div",{className:"absolute top-3 left-3 flex items-center gap-2 max-w-[60%]",children:[f.jsxs("div",{className:"flex items-center gap-1.5 rounded-full bg-black/60 px-2 py-1 flex-shrink-0",children:[f.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-secondary animate-pulse inline-block"}),f.jsx("span",{className:"text-[8px] uppercase tracking-[0.15em] text-secondary/70 font-semibold",children:"live"})]}),l&&f.jsxs("div",{className:`flex items-center gap-1.5 rounded-full bg-black/60 px-2.5 py-1 min-w-0 transition-all duration-500 ${u?"ring-1 ring-primary/60 bg-primary/25":""}`,title:l.url,children:[f.jsxs("span",{className:"text-[8px] uppercase tracking-[0.15em] text-on-surface-variant/70 font-semibold flex-shrink-0",children:["tab ",l.index]}),f.jsx("span",{className:"w-1 h-1 rounded-full bg-on-surface-variant/30 flex-shrink-0"}),f.jsx("span",{className:"text-[10px] text-on-surface/90 truncate",children:l.title||l.url})]})]})]})}function B$({agentId:e,session:t}){const n=E.useRef(null),[r,i]=E.useState(0),[s,o]=E.useState(0),a=t.createdAt,l=t.closedAt!=null?t.closedAt-t.createdAt:0,c=t.commands.map(y=>Math.max(0,(y.timestamp-a)/1e3));let u=-1;for(let y=0;y<c.length;y++)c[y]<=s+.01&&(u=y);const d=E.useCallback(y=>{const x=n.current;if(!x)return;const v=c[y]??0;x.currentTime=Math.min(v,x.duration||v),x.play().catch(()=>{})},[c]),h=()=>{var x;const y=((x=n.current)==null?void 0:x.duration)??0;i(Number.isFinite(y)?y:0)},p=()=>{var y;o(((y=n.current)==null?void 0:y.currentTime)??0)},g=t.videoValid?dR(e,t.id):null,m=r||l/1e3;return f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"flex-1 flex items-center justify-center overflow-hidden relative bg-surface-container-lowest",style:{minHeight:0},children:g?f.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[f.jsx("video",{ref:n,src:g,controls:!0,preload:"metadata",onLoadedMetadata:h,onTimeUpdate:p,className:"max-w-full max-h-full object-contain"}),m>0&&t.commands.length>0&&f.jsx("div",{className:"absolute left-0 right-0 bottom-[42px] pointer-events-none px-[12px]",children:f.jsx("div",{className:"relative h-2",children:c.map((y,x)=>{const v=Math.min(1,y/m)*100,b=x===u;return f.jsx("button",{onClick:()=>d(x),style:{left:`${v}%`},className:`absolute top-0 -translate-x-1/2 rounded-full pointer-events-auto transition-all ${b?"w-2.5 h-2.5 bg-primary ring-2 ring-primary/30":"w-1.5 h-1.5 bg-primary/50 hover:bg-primary/80"}`,title:t.commands[x].args},x)})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center text-center p-8",children:[f.jsx("span",{className:"text-[32px] opacity-10 mb-3",children:"🎞"}),f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant/25",children:"recording unavailable"}),(t.status==="stale"||t.status==="crashed")&&f.jsx("p",{className:"font-mono text-[9px] text-warning/50 mt-2",children:"session was abandoned before finalizing"})]})}),f.jsx(yC,{commands:t.commands,activeIndex:u,onJump:d})]})}function W$({agentId:e,session:t,onBack:n}){const[r,i]=E.useState(t);E.useEffect(()=>{if(r.status!=="active")return;const o=setInterval(()=>{iS(e,r.id).then(i).catch(()=>{})},3e3);return()=>clearInterval(o)},[e,r.id,r.status]),E.useEffect(()=>{const o=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[n]);const s=r.status==="active";return f.jsxs("div",{className:"flex flex-1 flex-col h-full min-w-0 rounded-lg bg-surface-container-lowest",children:[f.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-outline-variant/30 flex-shrink-0",children:[f.jsx("button",{onClick:n,className:"flex items-center justify-center w-6 h-6 rounded transition-colors hover:bg-surface-container text-on-surface-variant hover:text-on-surface",title:"Back to sessions",children:f.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:f.jsx("path",{d:"M10 3L5 8l5 5V3z"})})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("p",{className:"text-[11px] font-medium text-on-surface truncate",children:r.name??"Unnamed session"}),f.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant/60 truncate",children:r.id})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f.jsx($$,{status:r.status}),f.jsxs("span",{className:"font-mono text-[9px] text-on-surface-variant/70 tabular-nums",children:[r.commands.length," cmd",r.commands.length===1?"":"s"]})]})]}),f.jsx("div",{className:"flex-1 flex min-h-0",children:s?f.jsxs(f.Fragment,{children:[f.jsx(z$,{agentId:e,session:r}),f.jsx(yC,{commands:r.commands,activeIndex:r.commands.length-1,onJump:()=>{}})]}):f.jsx(B$,{agentId:e,session:r})})]})}function H$(e){const t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function V$(e,t){const r=(t??Date.now())-e,i=Math.floor(r/1e3);if(i<60)return`${i}s`;const s=Math.floor(i/60);return s<60?`${s}m ${i%60}s`:`${Math.floor(s/60)}h ${s%60}m`}function U$({status:e}){const t=e==="active"?"bg-secondary-container text-on-primary":e==="stale"||e==="crashed"?"bg-amber-500/20 text-warning":"bg-surface-container text-on-surface-variant/60";return f.jsx("span",{className:`rounded-full px-1.5 py-[2px] text-[8px] font-semibold uppercase tracking-[0.1em] ${t}`,children:e})}function q$({session:e,onClick:t}){const n=e.status==="active";return f.jsx("button",{onClick:t,className:`w-full text-left rounded-md transition-colors hover:brightness-110 ${n?"bg-surface-container-high":"bg-surface-container"}`,children:f.jsxs("div",{className:"p-3",children:[n&&f.jsx("div",{className:"absolute top-3 right-3 w-1.5 h-1.5 rounded-full bg-secondary animate-pulse",style:{position:"absolute"}}),f.jsxs("div",{className:"flex items-start justify-between gap-2 relative",children:[f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("p",{className:"text-[11px] font-medium text-on-surface truncate",children:e.name??"Unnamed session"}),f.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant/60 mt-0.5 truncate",children:e.id})]}),f.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[f.jsx(U$,{status:e.status}),n&&f.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-secondary animate-pulse inline-block"})]})]}),f.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60",children:e.videoValid?"video":"no recording"}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/20",children:"·"}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60",children:V$(e.createdAt,e.closedAt)}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/20",children:"·"}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60",children:H$(e.createdAt)})]})]})})}function G$({agentId:e}){const[t,n]=E.useState([]),[r,i]=E.useState(null),[s,o]=E.useState(!1);E.useEffect(()=>{let l=!1;const c=()=>{uR(e).then(d=>{if(!l){const h=[...d].sort((p,g)=>p.status==="active"&&g.status!=="active"?-1:p.status!=="active"&&g.status==="active"?1:g.createdAt-p.createdAt);n(h)}}).catch(console.error)};c();const u=setInterval(c,5e3);return()=>{l=!0,clearInterval(u)}},[e]);const a=async l=>{o(!0);try{const c=await iS(e,l.id);i(c)}catch(c){console.error("Failed to load session",c)}finally{o(!1)}};return r?f.jsx(W$,{agentId:e,session:r,onBack:()=>i(null)}):f.jsxs("div",{className:"flex flex-1 flex-col h-full min-w-0 rounded-lg bg-surface-container-lowest",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-outline-variant/30",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-[13px] opacity-60",children:"🌐"}),f.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] font-medium text-on-surface-variant",children:"Browser Sessions"})]}),f.jsxs("span",{className:"font-mono text-[9px] text-on-surface-variant/60 tabular-nums",children:[t.length," sessions"]})]}),s&&f.jsx("div",{className:"flex items-center justify-center py-8",children:f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant/60 animate-pulse",children:"loading session…"})}),!s&&f.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-1.5 scrollbar-thin",children:t.length===0?f.jsx("div",{className:"flex items-center justify-center flex-1",children:f.jsxs("div",{className:"max-w-lg w-full mx-auto text-center px-8",children:[f.jsx("img",{src:"/browser-onboarding.png",alt:"",className:"w-44 h-44 mx-auto mb-6 opacity-90"}),f.jsx("h2",{className:"font-headline text-xl font-semibold text-on-surface mb-3",children:"Browser sessions"}),f.jsx("p",{className:"text-[13px] text-on-surface-variant leading-relaxed mb-8 max-w-sm mx-auto",children:"When the agent needs your credentials or hits a captcha, it will hand off control to you."}),f.jsxs("div",{className:"flex flex-col gap-4 max-w-xs mx-auto text-left mb-8",children:[f.jsxs("div",{className:"flex items-start gap-4",children:[f.jsx("span",{className:"w-7 h-7 rounded-full bg-primary/15 text-primary text-[12px] font-bold flex items-center justify-center flex-shrink-0 mt-0.5",children:"1"}),f.jsxs("div",{children:[f.jsx("p",{className:"text-[13px] text-on-surface/80 font-medium",children:"Agent requests takeover"}),f.jsx("p",{className:"text-[11px] text-on-surface-variant/70 mt-0.5",children:"You'll receive a link in chat when the agent needs you"})]})]}),f.jsxs("div",{className:"flex items-start gap-4",children:[f.jsx("span",{className:"w-7 h-7 rounded-full bg-primary/15 text-primary text-[12px] font-bold flex items-center justify-center flex-shrink-0 mt-0.5",children:"2"}),f.jsxs("div",{children:[f.jsx("p",{className:"text-[13px] text-on-surface/80 font-medium",children:"Open the link and take control"}),f.jsx("p",{className:"text-[11px] text-on-surface-variant/70 mt-0.5",children:"Log in, solve the captcha, or complete whatever action is needed"})]})]}),f.jsxs("div",{className:"flex items-start gap-4",children:[f.jsx("span",{className:"w-7 h-7 rounded-full bg-primary/15 text-primary text-[12px] font-bold flex items-center justify-center flex-shrink-0 mt-0.5",children:"3"}),f.jsxs("div",{children:[f.jsx("p",{className:"text-[13px] text-on-surface/80 font-medium",children:"Click Completed"}),f.jsx("p",{className:"text-[11px] text-on-surface-variant/70 mt-0.5",children:"Session and logins are saved — the agent resumes automatically"})]})]})]}),f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant/20",children:"Sessions will appear here once the agent starts browsing."})]})}):t.map(l=>f.jsx(q$,{session:l,onClick:()=>void a(l)},l.id))})]})}const U0=1e3,K$=1e4,Y$=3e5;function q0(e,t,n){const r=E.useRef(null),i=E.useRef(null),s=E.useRef(t);s.current=t;const o=E.useRef(n);o.current=n;const[a,l]=E.useState(!1),c=E.useRef(null),u=E.useRef(U0),d=E.useRef(!0),h=E.useRef(null),p=E.useCallback(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{const v=i.current;v&&(v({type:"error",message:"Stream timeout — no response for 5 minutes"}),v({type:"done",sessionId:""}),i.current=null)},Y$)},[]),g=E.useCallback(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);E.useEffect(()=>{if(d.current=!0,!e)return;let v=null;function b(){if(!d.current)return;const C=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/agents/${encodeURIComponent(e)}`,_=new WebSocket(C);r.current=_,_.onopen=()=>{if(!d.current)return;l(!0),u.current=U0;const N=h.current??"ui";_.send(JSON.stringify({type:"subscribe",channelId:N}))},_.onmessage=N=>{let j;try{j=JSON.parse(N.data)}catch{return}const T=i.current??s.current??null;j.type==="chunk"?(p(),T==null||T(j.chunk),(j.chunk.type==="done"||j.chunk.type==="error")&&g()):j.type==="blocked"?T==null||T({type:"blocked",reason:j.reason}):j.type==="pending_approval"?T==null||T({type:"pending_approval",reason:j.reason}):j.type==="error"&&(T==null||T({type:"error",message:j.message}),g())},_.onclose=()=>{d.current&&(l(!1),console.warn(`[ws] ${e} disconnected — reconnecting in ${u.current}ms`),v=setTimeout(()=>{u.current=Math.min(u.current*2,K$),b()},u.current))}}return b(),()=>{var S;d.current=!1,v&&clearTimeout(v),g(),(S=r.current)==null||S.close(),l(!1)}},[e,p,g]);const m=E.useCallback((v,b)=>{var C,_;i.current=b,p();const S=()=>{var N;return(N=r.current)==null?void 0:N.send(JSON.stringify({type:"message",text:v}))};((C=r.current)==null?void 0:C.readyState)===WebSocket.OPEN?S():(_=r.current)==null||_.addEventListener("open",S,{once:!0})},[p]),y=E.useCallback(()=>{var v;((v=r.current)==null?void 0:v.readyState)===WebSocket.OPEN&&r.current.send(JSON.stringify({type:"stop"})),g(),i.current=null},[g]),x=E.useCallback(v=>{var b;h.current=v,((b=r.current)==null?void 0:b.readyState)===WebSocket.OPEN&&r.current.send(JSON.stringify({type:"subscribe",channelId:v}))},[]);return{sendMessage:m,stopMessage:y,subscribeToChannel:x,connected:a}}const G0={pending:"text-on-surface-variant",running:"text-warning",completed:"text-success",failed:"text-error",skipped:"text-on-surface-variant/60"},X$={pending:"○",running:"◉",completed:"●",failed:"✕",skipped:"—"},J$={tool_call:"→",tool_result:"←",error:"✕"},Q$={tool_call:"text-primary",tool_result:"text-success",error:"text-error"};function K0(e){if(e==null)return"";if(typeof e=="string")return e.length>200?e.slice(0,200)+"…":e;try{const t=JSON.stringify(e);return t.length>200?t.slice(0,200)+"…":t}catch{return String(e)}}function Z$({agentId:e,workflowId:t,runId:n,steps:r,onBack:i}){const{t:s}=we(),[o,a]=E.useState(null),[l,c]=E.useState(new Set),[u,d]=E.useState(!1),h=E.useCallback(async()=>{try{const m=await wR(e,t,n);a(m)}catch{}},[e,t,n]);E.useEffect(()=>{h();const m=setInterval(()=>{h()},1500);return()=>clearInterval(m)},[h]);const p=m=>{c(y=>{const x=new Set(y);return x.has(m)?x.delete(m):x.add(m),x})};if(!o)return f.jsx("div",{className:"p-4 font-mono text-sm text-on-surface-variant",children:s("runDetail.loading")});const g=new Map(r.map(m=>[m.id,m]));return f.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[f.jsxs("div",{className:"flex-shrink-0",children:[f.jsx("button",{onClick:i,className:`${qr} mb-3`,children:s("runDetail.back")}),f.jsxs("div",{className:"flex items-center justify-between mb-4",children:[f.jsxs("h2",{className:"font-headline text-xl font-bold text-on-surface",children:[s("runDetail.runLabel")," ",f.jsx("span",{className:G0[o.status],children:o.status})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[o.status==="running"&&f.jsx("button",{disabled:u,onClick:async()=>{d(!0);try{await SR(e,t,n),await h()}catch{}d(!1)},className:Mu,children:s(u?"runDetail.cancelling":"runDetail.cancel")}),f.jsxs("span",{className:"font-mono text-[11px] text-on-surface-variant",children:[new Date(o.startedAt).toLocaleString(),o.finishedAt&&` · ${((o.finishedAt-o.startedAt)/1e3).toFixed(1)}s`]})]})]})]}),f.jsx("div",{className:"flex-1 overflow-y-auto flex flex-col gap-1",children:o.steps.map(m=>{const y=g.get(m.stepId),x=l.has(m.id);return f.jsxs("div",{className:`${tl} overflow-hidden`,children:[f.jsxs("div",{onClick:()=>p(m.id),className:"flex items-center gap-2 px-3 py-2 cursor-pointer",children:[f.jsx("span",{className:`text-sm ${G0[m.status]}`,children:X$[m.status]}),f.jsx("span",{className:"text-sm text-on-surface flex-1",children:(y==null?void 0:y.name)??m.stepId}),m.durationMs!==null&&f.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant",children:[(m.durationMs/1e3).toFixed(1),"s"]}),f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:x?"▾":"▸"})]}),x&&f.jsxs("div",{className:"px-3 pb-3 text-sm space-y-2",children:[m.error&&f.jsxs("div",{className:"text-error whitespace-pre-wrap font-mono text-xs",children:[s("runDetail.errorPrefix")," ",m.error]}),m.events&&m.events.length>0&&f.jsxs("div",{children:[f.jsx("div",{className:"font-label text-[10px] font-semibold uppercase tracking-widest text-on-surface-variant mb-1",children:s("runDetail.activity")}),f.jsx("div",{className:"flex flex-col gap-1 bg-surface-container-low p-2 rounded",children:m.events.map((v,b)=>{const S=m.startedAt?((v.ts-m.startedAt)/1e3).toFixed(1):"";return f.jsxs("div",{className:"flex items-start gap-2 font-mono text-[11px]",children:[f.jsx("span",{className:"text-on-surface-variant/60 w-10 text-right shrink-0",children:S&&`+${S}s`}),f.jsx("span",{className:`shrink-0 ${Q$[v.type]}`,children:J$[v.type]}),v.type==="tool_call"&&f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("span",{className:"text-on-surface font-semibold",children:v.tool}),v.input!==void 0&&v.input!==null&&f.jsx("span",{className:"text-on-surface-variant ml-2 break-all",children:K0(v.input)})]}),v.type==="tool_result"&&f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("span",{className:"text-on-surface",children:v.tool}),v.output!==void 0&&v.output!==null&&f.jsx("span",{className:"text-on-surface-variant ml-2 break-all",children:K0(v.output)})]}),v.type==="error"&&f.jsx("div",{className:"flex-1 min-w-0 text-error break-all",children:v.message})]},b)})})]}),m.input!==null&&f.jsxs("div",{children:[f.jsx("div",{className:"font-label text-[10px] font-semibold uppercase tracking-widest text-on-surface-variant mb-1",children:s("runDetail.input")}),f.jsx("pre",{className:"font-mono text-xs text-on-surface bg-surface-container-low p-2 rounded overflow-auto max-h-52 whitespace-pre-wrap break-words",children:typeof m.input=="string"?m.input:JSON.stringify(m.input,null,2)})]}),m.output!==null&&f.jsxs("div",{children:[f.jsx("div",{className:"font-label text-[10px] font-semibold uppercase tracking-widest text-on-surface-variant mb-1",children:s("runDetail.output")}),f.jsx("pre",{className:"font-mono text-xs text-on-surface bg-surface-container-low p-2 rounded overflow-auto max-h-52 whitespace-pre-wrap break-words",children:typeof m.output=="string"?m.output:JSON.stringify(m.output,null,2)})]})]})]},m.id)})})]})}function bC({title:e,initial:t,allowStatus:n,onSave:r,onCancel:i}){const{t:s}=we(),[o,a]=E.useState((t==null?void 0:t.name)??""),[l,c]=E.useState((t==null?void 0:t.description)??""),[u,d]=E.useState((t==null?void 0:t.status)??"active"),[h,p]=E.useState(!1),g=async m=>{if(m.preventDefault(),!(!o.trim()||h)){p(!0);try{await r({name:o.trim(),description:l.trim(),status:n?u:void 0})}finally{p(!1)}}};return f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"fixed inset-0 z-40",style:{background:"rgba(0,0,0,0.4)"},onClick:i}),f.jsx("form",{onSubmit:g,className:"fixed inset-0 z-50 flex items-center justify-center p-4 pointer-events-none",children:f.jsxs("div",{className:"bg-surface-container-lowest border border-outline-variant/40 rounded-xl shadow-callout p-5 w-full max-w-md pointer-events-auto",children:[f.jsx("h3",{className:"font-headline text-lg font-bold text-on-surface mb-4",children:e}),f.jsxs("div",{className:"flex flex-col gap-3 mb-5",children:[f.jsxs("div",{children:[f.jsx("label",{className:"font-label text-[11px] font-semibold uppercase tracking-widest text-on-surface-variant block mb-1",children:s("workflows.formName")}),f.jsx("input",{autoFocus:!0,className:rr,value:o,onChange:m=>a(m.target.value),placeholder:s("workflows.formNamePlaceholder")})]}),f.jsxs("div",{children:[f.jsx("label",{className:"font-label text-[11px] font-semibold uppercase tracking-widest text-on-surface-variant block mb-1",children:s("workflows.formDescription")}),f.jsx("textarea",{rows:3,className:rr,value:l,onChange:m=>c(m.target.value),placeholder:s("workflows.formDescriptionPlaceholder")})]}),n&&f.jsxs("div",{children:[f.jsx("label",{className:"font-label text-[11px] font-semibold uppercase tracking-widest text-on-surface-variant block mb-1",children:s("workflows.formStatus")}),f.jsxs("select",{className:rr,value:u,onChange:m=>d(m.target.value),children:[f.jsx("option",{value:"active",children:"active"}),f.jsx("option",{value:"paused",children:"paused"}),f.jsx("option",{value:"archived",children:"archived"})]})]})]}),f.jsxs("div",{className:"flex items-center justify-end gap-2",children:[f.jsx("button",{type:"button",onClick:i,className:qr,children:s("workflows.cancel")}),f.jsx("button",{type:"submit",disabled:!o.trim()||h,className:Ui,children:s(h?"workflows.saving":"workflows.save")})]})]})})]})}function Y0({title:e,initial:t,onSave:n,onCancel:r}){const{t:i}=we(),s=t==null?void 0:t.config,[o,a]=E.useState((t==null?void 0:t.name)??""),[l,c]=E.useState((s==null?void 0:s.prompt)??""),[u,d]=E.useState(s!=null&&s.timeout_ms?String(s.timeout_ms/1e3):""),[h,p]=E.useState(!1),g=async m=>{if(m.preventDefault(),!o.trim()||!l.trim()||h)return;const y=u?Math.round(Number(u)*1e3):void 0,x={prompt:l,timeout_ms:y};p(!0);try{await n({name:o.trim(),config:x})}finally{p(!1)}};return f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"fixed inset-0 z-40",style:{background:"rgba(0,0,0,0.4)"},onClick:r}),f.jsx("form",{onSubmit:g,className:"fixed inset-0 z-50 flex items-center justify-center p-4 pointer-events-none overflow-y-auto",children:f.jsxs("div",{className:"bg-surface-container-lowest border border-outline-variant/40 rounded-xl shadow-callout p-5 w-full max-w-2xl pointer-events-auto my-8",children:[f.jsx("h3",{className:"font-headline text-lg font-bold text-on-surface mb-4",children:e}),f.jsxs("div",{className:"flex flex-col gap-3 mb-5",children:[f.jsxs("div",{children:[f.jsx("label",{className:"font-label text-[11px] font-semibold uppercase tracking-widest text-on-surface-variant block mb-1",children:i("workflows.stepNameLabel")}),f.jsx("input",{autoFocus:!0,className:rr,value:o,onChange:m=>a(m.target.value),placeholder:i("workflows.stepNamePlaceholder")})]}),f.jsxs("div",{children:[f.jsx("label",{className:"font-label text-[11px] font-semibold uppercase tracking-widest text-on-surface-variant block mb-1",children:i("workflows.stepPromptLabel")}),f.jsx("textarea",{rows:10,className:rr,value:l,onChange:m=>c(m.target.value),placeholder:i("workflows.stepPromptPlaceholder")})]}),f.jsxs("div",{children:[f.jsx("label",{className:"font-label text-[11px] font-semibold uppercase tracking-widest text-on-surface-variant block mb-1",children:i("workflows.stepTimeoutLabel")}),f.jsx("input",{className:rr,type:"number",min:0,value:u,onChange:m=>d(m.target.value),placeholder:"300"})]})]}),f.jsxs("div",{className:"flex items-center justify-end gap-2",children:[f.jsx("button",{type:"button",onClick:r,className:qr,children:i("workflows.cancel")}),f.jsx("button",{type:"submit",disabled:!o.trim()||!l.trim()||h,className:Ui,children:i(h?"workflows.saving":"workflows.save")})]})]})})]})}const e5={running:"bg-warning",completed:"bg-success",failed:"bg-error",cancelled:"bg-outline"};function t5({agentId:e,workflow:t,runs:n,onBack:r,onRun:i,onRefresh:s,onDeleted:o}){const{t:a}=we(),[l,c]=E.useState(null),[u,d]=E.useState(new Set),[h,p]=E.useState(!1),[g,m]=E.useState(!1),[y,x]=E.useState(null),v=w=>{d(M=>{const D=new Set(M);return D.has(w)?D.delete(w):D.add(w),D})},b=async w=>{await ER(e,t.id,w),p(!1),await s()},S=async()=>{window.confirm(a("workflows.confirmDelete",{name:t.name}))&&(await NR(e,t.id),await o())},C=async w=>{await jR(e,t.id,w),m(!1),await s()},_=async w=>{y&&(await Cf(e,t.id,y.id,w),x(null),await s())},N=async w=>{window.confirm(a("workflows.confirmDeleteStep",{name:w.name}))&&(await PR(e,t.id,w.id),await s())},j=async(w,M)=>{const D=[...t.steps].sort((V,Y)=>V.position-Y.position),B=D.findIndex(V=>V.id===w.id)+M;if(B<0||B>=D.length)return;const $=D[B];await Promise.all([Cf(e,t.id,w.id,{position:$.position}),Cf(e,t.id,$.id,{position:w.position})]),await s()};if(l)return f.jsx(Z$,{agentId:e,workflowId:t.id,runId:l,steps:t.steps,onBack:()=>{c(null),s()}});const T=[...t.steps].sort((w,M)=>w.position-M.position);return f.jsxs("div",{className:"p-4",children:[f.jsx("button",{onClick:()=>void r(),className:`${qr} mb-3`,children:a("workflows.back")}),f.jsxs("div",{className:"flex items-center justify-between mb-4 gap-2 flex-wrap",children:[f.jsx("h2",{className:"font-headline text-xl font-bold text-on-surface",children:t.name}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:()=>p(!0),className:qr,children:a("workflows.edit")}),f.jsx("button",{onClick:()=>void S(),className:Mu,children:a("workflows.delete")}),f.jsx("button",{onClick:i,className:Ui,children:a("workflows.run_button")})]})]}),t.description&&f.jsx("p",{className:"text-sm text-on-surface-variant mb-4",children:t.description}),f.jsxs("div",{className:"flex items-center justify-between mb-2",children:[f.jsx("h3",{className:"font-label text-[11px] font-semibold uppercase tracking-widest text-on-surface-variant",children:a("workflows.stepsTitle",{count:T.length})}),f.jsx("button",{onClick:()=>m(!0),className:km,children:a("workflows.addStep")})]}),f.jsxs("div",{className:"flex flex-col gap-1 mb-6",children:[T.length===0&&f.jsx("p",{className:"text-xs text-on-surface-variant py-2",children:a("workflows.noSteps")}),T.map((w,M)=>{const D=w.config,F=D.prompt??D.script??"",B=u.has(w.id),$=D.timeout_ms;return f.jsxs("div",{className:`${tl} p-3 transition-colors hover:border-primary/40`,children:[f.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",onClick:()=>v(w.id),children:[f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant w-5 text-center",children:M+1}),f.jsx("span",{className:"text-sm text-on-surface flex-1",children:w.name}),w.transitions&&f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:a(w.transitions.conditions.length===1?"workflows.conditionsOne":"workflows.conditionsOther",{count:w.transitions.conditions.length})}),f.jsxs("div",{className:"flex items-center gap-0.5",onClick:V=>V.stopPropagation(),children:[f.jsx("button",{onClick:()=>void j(w,-1),disabled:M===0,className:qr,title:a("workflows.moveUp"),children:"↑"}),f.jsx("button",{onClick:()=>void j(w,1),disabled:M===T.length-1,className:qr,title:a("workflows.moveDown"),children:"↓"}),f.jsx("button",{onClick:()=>x(w),className:qr,title:a("workflows.edit"),children:"✎"}),f.jsx("button",{onClick:()=>void N(w),className:Mu,title:a("workflows.delete"),children:"✕"})]}),f.jsx("span",{className:"text-[10px] text-on-surface-variant transition-transform",style:{transform:B?"rotate(90deg)":"none"},children:"▶"})]}),!B&&F&&f.jsx("p",{className:"mt-1 ml-7 text-xs text-on-surface-variant truncate",children:F}),B&&f.jsxs("div",{className:"mt-2 ml-7",children:[F&&f.jsx("pre",{className:"font-mono text-xs text-on-surface-variant whitespace-pre-wrap break-words leading-relaxed p-2 bg-surface-container-low rounded max-h-80 overflow-auto",children:F}),f.jsxs("div",{className:"flex gap-4 mt-1.5 font-mono text-[10px] text-on-surface-variant",children:[$&&f.jsx("span",{children:a("workflows.stepTimeout",{seconds:$/1e3})}),f.jsx("span",{children:a("workflows.stepId",{id:w.id.slice(0,8)})})]})]})]},w.id)})]}),f.jsx("h3",{className:"font-label text-[11px] font-semibold uppercase tracking-widest text-on-surface-variant mb-2",children:a("workflows.runHistoryTitle",{count:n.length})}),n.length===0?f.jsx("p",{className:"text-xs text-on-surface-variant",children:a("workflows.noRuns")}):f.jsx("div",{className:"flex flex-col gap-1",children:n.map(w=>f.jsxs("div",{onClick:()=>c(w.id),className:`${tl} flex items-center justify-between p-2.5 cursor-pointer transition-colors hover:border-primary/40`,children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:`h-2 w-2 rounded-full ${e5[w.status]??"bg-outline"}`}),f.jsx("span",{className:"text-sm text-on-surface",children:w.status}),f.jsxs("span",{className:"font-mono text-[11px] text-on-surface-variant",children:["(",w.trigger,")"]})]}),f.jsxs("div",{className:"font-mono text-[10px] text-on-surface-variant",children:[new Date(w.startedAt).toLocaleString(),w.finishedAt&&` · ${((w.finishedAt-w.startedAt)/1e3).toFixed(1)}s`]})]},w.id))}),h&&f.jsx(bC,{title:a("workflows.editWorkflow"),initial:{name:t.name,description:t.description,status:t.status},allowStatus:!0,onSave:b,onCancel:()=>p(!1)}),g&&f.jsx(Y0,{title:a("workflows.addStepTitle"),onSave:C,onCancel:()=>m(!1)}),y&&f.jsx(Y0,{title:a("workflows.editStepTitle"),initial:y,onSave:_,onCancel:()=>x(null)})]})}function n5({agentId:e}){const{t}=we(),[n,r]=E.useState([]),[i,s]=E.useState(null),[o,a]=E.useState([]),[l,c]=E.useState(null),[u,d]=E.useState(!1),h=E.useCallback(async()=>{try{const b=await _R(e);r(b)}catch{}},[e]);E.useEffect(()=>{h();const b=setInterval(()=>{h()},4e3);return()=>clearInterval(b)},[h]);const p=async b=>{const[S,C]=await Promise.all([Uy(e,b),Sf(e,b)]);s(S),a(C)},g=async b=>{c(b);try{await kR(e,b);const S=await Sf(e,b);a(S)}catch(S){console.error("Failed to trigger workflow:",S)}finally{c(null)}},m=async b=>{const S=await CR(e,b);d(!1),await h(),await p(S.id)};if(i)return f.jsx(t5,{agentId:e,workflow:i,runs:o,onBack:async()=>{s(null),await h()},onRun:()=>g(i.id),onRefresh:async()=>{const[b,S]=await Promise.all([Uy(e,i.id),Sf(e,i.id)]);s(b),a(S)},onDeleted:async()=>{s(null),await h()}});const y={active:Ap,paused:Ky,archived:jc},x=b=>b==="running"?"inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-mono font-medium bg-primary/15 text-primary":b==="completed"?`${Ap} text-[10px]`:b==="failed"?`${Ky} text-[10px]`:b==="cancelled"?`${jc} text-[10px]`:"",v=b=>{const S=Date.now()-b,C=Math.floor(S/1e3);if(C<60)return`${C}s`;const _=Math.floor(C/60);if(_<60)return`${_}m`;const N=Math.floor(_/60);return N<24?`${N}h`:`${Math.floor(N/24)}d`};return f.jsxs("div",{className:"p-3 sm:p-4 min-w-0",children:[f.jsxs("div",{className:"flex items-center justify-between mb-4",children:[f.jsx("h2",{className:"font-headline text-xl font-bold text-on-surface",children:t("workflows.title")}),f.jsx("button",{onClick:()=>d(!0),className:km,children:t("workflows.newWorkflow")})]}),n.length===0?f.jsx("p",{className:"font-mono text-xs text-on-surface-variant",children:t("workflows.emptyText")}):f.jsx("div",{className:"flex flex-col gap-2",children:n.map(b=>f.jsxs("div",{onClick:()=>p(b.id),className:`${tl} p-4 cursor-pointer transition-colors hover:border-primary/40`,children:[f.jsxs("div",{className:"flex items-center justify-between gap-3",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[f.jsx("span",{className:"font-headline font-bold text-on-surface truncate",children:b.name}),f.jsx("span",{className:y[b.status]??jc,children:b.status}),b.lastRun&&f.jsxs("span",{className:x(b.lastRun.status),children:[b.lastRun.status==="running"&&f.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-pulse"}),t(`workflows.runStatus.${b.lastRun.status}`),f.jsxs("span",{className:"opacity-60",children:["· ",v(b.lastRun.finishedAt??b.lastRun.startedAt)]})]})]}),f.jsx("button",{onClick:S=>{S.stopPropagation(),g(b.id)},disabled:l===b.id||b.status!=="active",className:Ui,children:l===b.id?t("workflows.running"):t("workflows.run")})]}),b.description&&f.jsx("p",{className:"mt-1.5 text-sm text-on-surface-variant",children:b.description}),f.jsx("div",{className:"mt-1 font-mono text-[10px] text-on-surface-variant/60",children:t("workflows.createdOn",{id:b.id,date:new Date(b.createdAt).toLocaleDateString()})})]},b.id))}),u&&f.jsx(bC,{title:t("workflows.newWorkflow"),onSave:m,onCancel:()=>d(!1)})]})}function r5(e){const t=e.split(" ");if(t.length!==5)return e;const[n,r,i,s,o]=t;if(i==="*"&&s==="*"&&o==="*"){if(r!=="*"&&n!=="*")return`Daily at ${r.padStart(2,"0")}:${n.padStart(2,"0")}`;if(r==="*"&&n==="0")return"Every hour";if(r==="*")return`Every hour at :${n.padStart(2,"0")}`}if(i==="*"&&s==="*"&&o!=="*"){const a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],l=o.split(",").map(c=>a[Number(c)]??c).join(", ");if(r!=="*"&&n!=="*")return`${l} at ${r.padStart(2,"0")}:${n.padStart(2,"0")}`}return e}function X0(e){if(!e)return"—";const t=e-Date.now(),n=Math.abs(t);if(n<6e4)return t>0?"in <1m":"<1m ago";if(n<36e5){const i=Math.round(n/6e4);return t>0?`in ${i}m`:`${i}m ago`}if(n<864e5){const i=Math.round(n/36e5);return t>0?`in ${i}h`:`${i}h ago`}const r=Math.round(n/864e5);return t>0?`in ${r}d`:`${r}d ago`}function i5({agentId:e,run:t,onBack:n}){const{t:r}=we(),[i,s]=E.useState([]),[o,a]=E.useState(!0),l=E.useCallback(async()=>{try{const c=await bR(e,t.channelId);s(c)}catch{}a(!1)},[e,t.channelId]);return E.useEffect(()=>{l();const c=setInterval(()=>{l()},2e3);return()=>clearInterval(c)},[l]),f.jsxs("div",{className:"p-4 flex flex-col gap-3",children:[f.jsx("button",{onClick:n,className:"text-[10px] text-on-surface-variant hover:text-on-surface transition-colors self-start",children:r("schedules.backToRuns")}),f.jsxs("div",{className:"text-[9px] font-mono text-on-surface-variant/60",children:[new Date(t.startedAt).toLocaleString()," · ",t.channelId]}),o&&f.jsx("div",{className:"text-xs text-on-surface-variant/70",children:r("schedules.loading")}),!o&&i.length===0&&f.jsx("div",{className:"text-xs text-on-surface-variant/70 animate-pulse",children:r("schedules.waitingResponse")}),f.jsx("div",{className:"space-y-2",children:i.map(c=>f.jsxs("div",{className:`rounded-md p-2.5 text-[11px] leading-relaxed whitespace-pre-wrap ${c.role==="user"?"bg-surface-container-lowest border border-outline-variant/40 text-on-surface-variant/70":c.role==="tool_call"?"bg-surface-container-low text-on-surface-variant/70 font-mono text-[10px]":"bg-surface-container text-on-surface/90"}`,children:[c.role==="tool_call"&&f.jsx("span",{className:"text-info/60 mr-1",children:"⚙"}),c.content]},c.id))})]})}function s5({agentId:e,schedule:t,onBack:n}){const{t:r}=we(),[i,s]=E.useState([]),[o,a]=E.useState(null),[l,c]=E.useState(!1),u=E.useCallback(async()=>{try{s(await yR(e,t.id))}catch{}},[e,t.id]);E.useEffect(()=>{u()},[u]);async function d(){c(!0);try{await vR(e,t.id),await u()}finally{c(!1)}}return o?f.jsx(i5,{agentId:e,run:o,onBack:()=>a(null)}):f.jsxs("div",{className:"p-4 flex flex-col gap-3",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:n,className:"text-[10px] text-on-surface-variant hover:text-on-surface transition-colors",children:"←"}),f.jsx("span",{className:"text-xs text-on-surface font-medium flex-1 truncate",children:t.name}),f.jsx("button",{onClick:d,disabled:l,className:"text-[9px] px-2 py-0.5 rounded bg-surface-container text-on-surface-variant/60 hover:text-on-surface transition-colors disabled:opacity-40",children:r(l?"schedules.triggering":"schedules.runNow")})]}),f.jsx("span",{className:"text-[10px] uppercase tracking-[0.14em] text-on-surface-variant/70 font-medium",children:r("schedules.runHistory")}),i.length===0&&f.jsx("p",{className:"text-[10px] text-on-surface-variant/60",children:r("schedules.noRuns")}),i.map(h=>f.jsxs("button",{onClick:()=>a(h),className:"text-left rounded-md bg-surface-container-low border border-outline-variant/40 p-2.5 hover:bg-surface-container-highest transition-colors",children:[f.jsx("div",{className:"text-[10px] text-on-surface/80",children:new Date(h.startedAt).toLocaleString()}),f.jsx("div",{className:"text-[9px] font-mono text-on-surface-variant/60 mt-0.5",children:h.channelId})]},h.id))]})}function o5({agentId:e}){const{t}=we(),[n,r]=E.useState([]),[i,s]=E.useState(!0),[o,a]=E.useState(null),l=()=>{gR(e).then(r).catch(console.error).finally(()=>s(!1))};E.useEffect(()=>{l()},[e]),E.useEffect(()=>{const h=setInterval(()=>r(p=>[...p]),3e4);return()=>clearInterval(h)},[]);async function c(h){const p=h.status==="active"?"paused":"active";await mR(e,h.id,{status:p}),l()}async function u(h){confirm(t("schedules.deleteConfirm",{name:h.name}))&&(await xR(e,h.id),l())}if(o)return f.jsx(s5,{agentId:e,schedule:o,onBack:()=>a(null)});if(i)return f.jsx("div",{className:"text-on-surface-variant/70 text-xs p-6",children:t("schedules.loadingList")});if(n.length===0)return f.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center p-6 gap-3",children:[f.jsx("span",{className:"text-3xl opacity-30",children:"⏰"}),f.jsx("p",{className:"text-on-surface-variant text-xs",children:t("schedules.emptyText")})]});const d=n.filter(h=>h.status==="active").length;return f.jsxs("div",{className:"p-3 sm:p-4 space-y-2 min-w-0",children:[f.jsxs("div",{className:"flex items-center justify-between mb-3",children:[f.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] text-on-surface-variant/60 font-medium",children:t("schedules.title")}),f.jsx("span",{className:"text-[9px] font-mono text-on-surface-variant/60",children:t(d===1?"schedules.activeCountOne":"schedules.activeCountOther",{count:d})})]}),n.map(h=>f.jsxs("div",{onClick:()=>a(h),className:"rounded-md bg-surface-container-low border border-outline-variant/40 p-3 space-y-2 cursor-pointer hover:bg-surface-container-highest transition-colors",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${h.status==="active"?"bg-green-500":"bg-yellow-500/50"}`}),f.jsx("span",{className:"text-xs text-on-surface font-medium flex-1 truncate",children:h.name}),f.jsx("span",{className:"text-[9px] font-mono text-on-surface-variant/70",children:h.id})]}),f.jsx("p",{className:"text-[10px] text-on-surface-variant font-mono leading-relaxed break-words",style:{whiteSpace:"pre-wrap"},children:h.message}),f.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-on-surface-variant/70",children:[f.jsx("span",{title:h.cron,children:r5(h.cron)}),f.jsx("span",{children:h.timezone}),f.jsx("span",{title:h.nextRun?new Date(h.nextRun).toISOString():"",children:t("schedules.next",{time:X0(h.nextRun)})}),h.lastRun&&f.jsx("span",{title:new Date(h.lastRun).toISOString(),children:t("schedules.last",{time:X0(h.lastRun)})})]}),f.jsxs("div",{className:"flex items-center gap-2 pt-1",onClick:p=>p.stopPropagation(),children:[f.jsx("button",{onClick:()=>c(h),className:"text-[9px] px-2 py-0.5 rounded bg-surface-container text-on-surface-variant/60 hover:text-on-surface transition-colors",children:h.status==="active"?t("schedules.pause"):t("schedules.resume")}),f.jsx("button",{onClick:()=>u(h),className:"text-[9px] px-2 py-0.5 rounded bg-surface-container text-error/60 hover:text-error transition-colors ml-auto",children:t("schedules.delete")})]})]},h.id))]})}function J0(e){const t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);return r<60?`${r}m ago`:`${Math.floor(r/60)}h ${r%60}m ago`}function ks({tone:e,pulse:t}){const n=e==="success"?"bg-success":e==="warning"?"bg-warning":e==="primary"?"bg-primary":e==="info"?"bg-info":e==="muted"?"bg-outline":"bg-outline/50";return f.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full flex-shrink-0 ${t?"animate-pulse":""} ${n}`})}function Q0({info:e,label:t,extra:n}){const{t:r}=we();return e?f.jsxs("div",{className:"rounded bg-surface-container-lowest border border-outline-variant/40 p-3 space-y-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(ks,{tone:"success",pulse:!0}),f.jsx("span",{className:"font-label text-[10px] uppercase tracking-wider text-on-surface font-semibold",children:t}),f.jsxs("span",{className:"font-mono text-[9px] text-on-surface-variant/60 ml-auto",children:["PID ",e.pid]})]}),f.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:r("monitor.cpu")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:e.cpu})]}),f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:r("monitor.mem")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:e.mem})]}),f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:r("monitor.rss")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:e.rss})]}),f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:r("monitor.uptime")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:e.elapsed})]})]}),n,f.jsx("p",{className:"font-mono text-[8px] text-on-surface-variant/20 truncate",title:e.command,children:e.command})]}):null}function a5({agentId:e}){const{t}=we(),[n,r]=E.useState(null);if(E.useEffect(()=>{const c=()=>hR(e).then(r).catch(console.error);c();const u=setInterval(c,2e3);return()=>clearInterval(u)},[e]),!n)return f.jsx("div",{className:"text-on-surface-variant/70 text-xs p-6",children:t("monitor.loading")});const i=n.jobs.processing,s=n.jobs.pending,o=n.workflows,a=n.claudeProcesses.length,l=i.length===0&&o.length===0&&a===0;return f.jsxs("div",{className:"flex flex-col h-full min-w-0 bg-surface-container-lowest",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-outline-variant/30",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-[13px] opacity-60",children:"📡"}),f.jsx("span",{className:"font-label text-[11px] uppercase tracking-[0.14em] font-semibold text-on-surface",children:t("monitor.title")})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("span",{className:`font-mono text-[9px] ${l?"text-on-surface-variant/60":"text-secondary"}`,children:l?t("monitor.idle"):t(a===1?"monitor.claudeSessionsOne":"monitor.claudeSessionsOther",{count:a})}),f.jsx("span",{className:`h-1.5 w-1.5 rounded-full animate-pulse ${l?"bg-outline/50":"bg-success"}`})]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scrollbar-thin",children:[f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[9px] uppercase tracking-[0.18em] text-on-surface-variant font-semibold mb-2",children:t("monitor.processes")}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Q0,{info:n.agent,label:t("monitor.agentProcess"),extra:n.agent?f.jsxs("span",{className:"font-mono text-[9px] text-primary/40",children:["pid ",n.agent.pid]}):void 0}),f.jsx(Q0,{info:n.guardian,label:t("monitor.guardianProcess")}),n.browserProcess&&f.jsxs("div",{className:"rounded bg-surface-container-lowest border border-outline-variant/40 p-3",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(ks,{tone:"warning",pulse:!0}),f.jsx("span",{className:"font-label text-[10px] uppercase tracking-wider text-on-surface font-semibold",children:t("monitor.browserDaemon")}),f.jsxs("span",{className:"font-mono text-[9px] text-on-surface-variant/60 ml-auto",children:["PID ",n.browserProcess.pid]})]}),f.jsxs("div",{className:"grid grid-cols-3 gap-2 mt-2",children:[f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:t("monitor.cpu")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:n.browserProcess.cpu})]}),f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:t("monitor.mem")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:n.browserProcess.mem})]}),f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:t("monitor.rss")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:n.browserProcess.rss})]})]})]})]})]}),a>0&&f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[9px] uppercase tracking-[0.18em] text-on-surface-variant font-semibold mb-2",children:t("monitor.activeClaudeSessions",{count:a})}),f.jsx("div",{className:"space-y-1.5",children:n.claudeProcesses.map(c=>f.jsxs("div",{className:"rounded bg-surface-container-lowest border border-outline-variant/40 p-3",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[f.jsx(ks,{tone:"primary",pulse:!0}),f.jsx("span",{className:"font-mono text-[10px] text-on-surface/70",children:"claude"}),f.jsxs("span",{className:"font-mono text-[9px] text-on-surface-variant/60 ml-auto",children:["PID ",c.pid]})]}),f.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:t("monitor.cpu")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:c.cpu})]}),f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:t("monitor.mem")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:c.mem})]}),f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:t("monitor.rss")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:c.rss})]}),f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant mb-0.5",children:t("monitor.uptime")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface/80",children:c.elapsed})]})]}),f.jsx("p",{className:"font-mono text-[8px] text-on-surface-variant/20 mt-1.5 break-all leading-relaxed",style:{whiteSpace:"pre-wrap"},children:c.command})]},c.pid))})]}),f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[9px] uppercase tracking-[0.18em] text-on-surface-variant font-semibold mb-2",children:t("monitor.jobQueue",{processing:i.length,pending:s.length})}),i.length===0&&s.length===0?f.jsx("p",{className:"text-[10px] text-on-surface-variant italic",children:t("monitor.noActiveJobs")}):f.jsxs("div",{className:"space-y-1.5",children:[i.map(c=>f.jsxs("div",{className:"rounded bg-surface-container-lowest border border-outline-variant/40 p-2.5",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx(ks,{tone:"success",pulse:!0}),f.jsx("span",{className:"font-mono text-[9px] text-secondary/70 uppercase",children:t("monitor.processing")}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60 ml-auto",children:c.channelId}),f.jsx("button",{onClick:()=>Vy(e,c.id).catch(console.error),className:"text-[8px] px-1.5 py-0.5 rounded bg-red-950/30 text-error/60 hover:text-error hover:bg-red-950/50 transition-colors",children:t("monitor.terminate")})]}),f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant leading-relaxed break-words",style:{whiteSpace:"pre-wrap"},children:c.message}),f.jsx("span",{className:"font-mono text-[8px] text-on-surface-variant/20 mt-1 block",children:J0(c.createdAt)})]},c.id)),s.map(c=>f.jsxs("div",{className:"rounded bg-surface-container-lowest p-2.5",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx(ks,{tone:"muted"}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/70 uppercase",children:t("monitor.queued")}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60 ml-auto",children:c.channelId}),f.jsx("button",{onClick:()=>Vy(e,c.id).catch(console.error),className:"text-[8px] px-1.5 py-0.5 rounded bg-surface-container text-on-surface-variant/70 hover:text-error transition-colors",children:t("monitor.cancel")})]}),f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant/70 leading-relaxed break-words",style:{whiteSpace:"pre-wrap"},children:c.message})]},c.id))]})]}),o.length>0&&f.jsxs("div",{children:[f.jsx("p",{className:"font-label text-[9px] uppercase tracking-[0.18em] text-on-surface-variant font-semibold mb-2",children:t("monitor.runningWorkflows")}),f.jsx("div",{className:"space-y-1.5",children:o.map(c=>f.jsxs("div",{className:"rounded bg-surface-container-lowest border border-outline-variant/40 p-2.5 flex items-center gap-2",children:[f.jsx(ks,{tone:"warning",pulse:!0}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("span",{className:"font-mono text-[10px] text-on-surface/70",children:c.workflowName}),f.jsx("span",{className:"font-mono text-[8px] text-on-surface-variant/60 ml-2",children:c.runId.slice(0,8)})]}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60 flex-shrink-0",children:J0(c.startedAt)})]},c.runId))})]})]})]})}/*!
123
123
  * @kurkle/color v0.3.4
124
124
  * https://github.com/kurkle/color#readme
125
125
  * (c) 2024 Jukka Kurkela
@@ -27,7 +27,7 @@
27
27
  } catch (_) { /* SSR / blocked storage — ignore */ }
28
28
  })();
29
29
  </script>
30
- <script type="module" crossorigin src="/assets/index-elos3wsq.js"></script>
30
+ <script type="module" crossorigin src="/assets/index-DSpa2QbO.js"></script>
31
31
  <link rel="stylesheet" crossorigin href="/assets/index-DMFjON8a.css">
32
32
  </head>
33
33
  <body class="bg-background text-on-surface">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "granclaw",
3
- "version": "0.0.1-beta.102",
3
+ "version": "0.0.1-beta.103",
4
4
  "description": "A personal AI assistant you run on your own machine.",
5
5
  "license": "MIT",
6
6
  "repository": {