const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./BiCEaioG2.js","./CG84LPq-.js","./DrKWWDpL.js","./DsQIgu-4.js","./2PQNgpBd.js","./DsanjglN.js","./CbGRcr-D.js","./DgZn9uJn.js","./CudpqN6Z.js","./DYP3EJMY.js","./DTkg6Mnx.js","./DIQmuJJZ.js","./D7w7HllH.js","./DB5ifLM-.js","./CX8DOZuw2.js","./DOqzs8kl2.js","./CxlOpib82.js","./BmWTAsFW.js","./DeO5NWhN.js","./Czb-RtcG.js","./C0nwgWmB.js","./B5XQZRTz.js","./CWxOfblT.js","./CVwAhlPZ.js","./BVC3q6GM.js","./B8PRMiR2.js","./BDDiPmhF.js","./BYJC6_MM.js","./bG-fsHMS.js","./D-eE9s2f.js","./DlZwu-Y7.js","./Cx_-1PHK2.js","./B_DA9RKE2.js","./DOPTvi6T.js","./CvaH7m0y.js","./O2P-f9sv.js","./BQ9wXJVQ2.js","./OnYyYdSr2.js"])))=>i.map(i=>d[i]);
import"./DrKWWDpL.js";import{n as e,t}from"./DsQIgu-4.js";import{t as n}from"./DYP3EJMY.js";import"./DIQmuJJZ.js";import"./CxlOpib82.js";import"./CX8DOZuw2.js";import"./kwfd020K.js";import{D as r,P as i,_ as a,j as o,t as s,v as c,w as l}from"./DsanjglN.js";import"./D-eE9s2f.js";import"./bG-fsHMS.js";import"./ImGf_A8f.js";import{f as u}from"./CvaH7m0y.js";import"./DOPTvi6T.js";import"./CG84LPq-.js";import"./Ca833_kK2.js";import"./Dn7LRnjg2.js";import"./0aZs3VHW2.js";import{t as d}from"./7cNciA-b.js";import"./CLr_XgCb2.js";import"./BFyEzYu52.js";import"./D_sriNfV2.js";import"./X_DUeLZp2.js";import"./DmLgVuva2.js";import"./yMgjaRvh2.js";import"./o6gedrVd.js";import"./BClSAfhn.js";import"./C5cNeu21.js";import"./DFB29SWc.js";import"./BZoHU8hk.js";import"./BnD013za.js";import"./Cz47RMnI.js";import"./BDuP5L5N.js";import"./BTn_GkPS.js";n();function f(e,t){let n=e;if(t.taskId){let e=t.taskId;n=n.filter(t=>t.id.startsWith(e)||t.linked_tasks?.includes(e))}return t.status&&(n=n.filter(e=>e.status===t.status)),t.agent_type&&(n=n.filter(e=>e.agent_type===t.agent_type)),t.topic&&(n=n.filter(e=>e.topics.includes(t.topic))),t.actionable!==void 0&&(n=n.filter(e=>e.actionable===t.actionable)),t.dateAfter&&(n=n.filter(e=>e.date>t.dateAfter)),t.dateBefore&&(n=n.filter(e=>e.date<t.dateBefore)),t.offset&&t.offset>0&&(n=n.slice(t.offset)),t.limit&&t.limit>0&&(n=n.slice(0,t.limit)),n}e();async function p(e){let{getDb:n}=await t(async()=>{let{getDb:e}=await import(`./BiCEaioG2.js`);return{getDb:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37]),import.meta.url);return n(e)}function m(e){return typeof e==`number`&&e>0?e:void 0}function h(e){return typeof e==`number`&&e>0?e:void 0}function g(e,t){return e??(t===void 0?void 0:50)}function _(e){let t=[o(u.archivedAt)];if(e.status){let n=e.status===`completed`?`active`:e.status;t.push(l(u.status,n))}return e.agent_type&&t.push(l(u.type,e.agent_type)),e.dateAfter&&t.push(r(u.createdAt,`${e.dateAfter} 00:00:00`)),e.dateBefore&&t.push(i(u.createdAt,`${e.dateBefore} 23:59:59`)),{conditions:t,requiresInMemoryFiltering:e.taskId!==void 0||e.topic!==void 0||e.actionable!==void 0}}function v(e,t){return f(e,{taskId:t.taskId,topic:t.topic,actionable:t.actionable})}function y(e){let t={};if(e.metadataJson)try{t=JSON.parse(e.metadataJson)}catch{}return{id:e.id,file:t.file??e.sourceFile??``,title:t.title??e.type,date:e.createdAt.slice(0,10),status:e.status===`active`?`completed`:e.status,agent_type:e.type,topics:t.topics??[],key_findings:t.key_findings??[],actionable:t.actionable??!0,needs_followup:t.needs_followup??[],linked_tasks:t.linked_tasks??(e.taskId?[e.taskId]:[]),confidence:t.confidence,file_checksum:t.file_checksum,duration_seconds:t.duration_seconds}}async function b(e,t){try{let n=await p(t),r={...e};e.type&&(r.agent_type=e.type);let i=m(e.limit),l=h(e.offset),f=g(i,l),{conditions:b,requiresInMemoryFiltering:x}=_(r),S=c(...b),C=(await n.select({count:s()}).from(u).where(o(u.archivedAt)).get())?.count??0;if(!x){let e=(await n.select({count:s()}).from(u).where(S).get())?.count??0,t=n.select().from(u).where(S).orderBy(a(u.createdAt));return f!==void 0&&(t=t.limit(f)),l!==void 0&&(t=t.offset(l)),{success:!0,data:{entries:(await t).map(y),total:C,filtered:e},page:d({total:e,limit:f,offset:l})}}let w=v((await n.select().from(u).where(S).orderBy(a(u.createdAt))).map(y),r),T=w.length,E=l??0;return{success:!0,data:{entries:f===void 0?w.slice(E):w.slice(E,E+f),total:C,filtered:T},page:d({total:T,limit:f,offset:l})}}catch(e){return{success:!1,error:{code:`E_MANIFEST_LIST`,message:e instanceof Error?e.message:String(e)}}}}export{b as pipelineManifestList};