import{t as e}from"./url-D6jvVYIA.js";import{t}from"./fetch-BaFNUtkE.js";import{z as n}from"./index-qNrVJp-y.js";function r(e){let t=e.payload;return t.kind===`systemEvent`?t.text??``:t.message??``}function i(e){if(!e||typeof e!=`object`)return``;let t=e.agents?.defaults?.model;if(t==null)return``;if(typeof t==`string`)return t.trim();if(typeof t==`object`&&t&&`primary`in t){let e=t.primary;return typeof e==`string`?e.trim():``}return``}async function a(e,n){let r=await t(e,n),i=await r.json().catch(()=>({}));if(!r.ok){let e=typeof i.error==`string`?i.error:`HTTP ${r.status}`;throw Error(e)}return i}async function o(){return(await a(e(`/api/cron`))).jobs||[]}async function s(n){let r=await t(e(`/api/cron/${encodeURIComponent(n)}`));if(r.status===404)return null;let i=await r.json().catch(()=>({}));if(!r.ok)throw Error(typeof i.error==`string`?i.error:`HTTP ${r.status}`);return i.job??null}async function c(t,n){return a(e(`/api/cron`),{method:`POST`,body:JSON.stringify({schedule:t,...n})})}async function l(t,n){return(await a(e(`/api/cron/${encodeURIComponent(t)}`),{method:`PATCH`,body:JSON.stringify(n)})).updated}async function u(t){return(await a(e(`/api/cron/${encodeURIComponent(t)}`),{method:`DELETE`})).removed}async function d(t,n){return(await a(e(`/api/cron/${encodeURIComponent(t)}/toggle`),{method:`POST`,body:JSON.stringify({enabled:n})})).toggled}async function f(t){await a(e(`/api/cron/${encodeURIComponent(t)}/run`),{method:`POST`})}async function p(t,n=10){return(await a(e(`/api/cron/${encodeURIComponent(t)}/history?limit=${n}`))).history||[]}async function m(t=40){return(await a(e(`/api/cron/runs/history?limit=${t}`))).runs||[]}async function h(){return(await a(e(`/api/channels/status`))).payload?.channels||[]}async function g(){return(await n()).map(e=>({id:e.id,name:e.name,provider:e.provider}))}async function _(){let t=(await a(e(`/api/config`))).payload?.config;return{model:i(t)}}async function v(t){return(await a(e(`/api/sessions/chat-ids${t?`?channel=${encodeURIComponent(t)}`:``}`))).payload?.chatIds||[]}export{_ as a,g as c,u as d,f,h as i,v as l,l as m,r as n,p as o,d as p,m as r,s,c as t,o as u};