const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./BlapV1mo.js","./bG-fsHMS.js","./DrKWWDpL.js","./DsQIgu-4.js","./DTkg6Mnx.js","./DYP3EJMY.js","./DeO5NWhN.js","./DgZn9uJn.js","./CbGRcr-D.js","./CudpqN6Z.js","./CX8DOZuw2.js","./DOqzs8kl2.js","./DIQmuJJZ.js","./D7w7HllH.js","./DB5ifLM-.js","./CxlOpib82.js","./Czb-RtcG.js","./C0nwgWmB.js","./D-eE9s2f.js","./CWxOfblT.js","./DlZwu-Y7.js"])))=>i.map(i=>d[i]);
import{n as e,t}from"./DsQIgu-4.js";import{n}from"./Dn7LRnjg2.js";import{t as r}from"./CvFbqtf9.js";import{r as i,t as a}from"./Ouh6Dj2I2.js";e();function o(e){return e.startsWith(`D-`)||/^D\d/.test(e)?`decision`:e.startsWith(`P-`)||/^P\d/.test(e)?`pattern`:e.startsWith(`L-`)||/^L\d/.test(e)?`learning`:e.startsWith(`O-`)||e.startsWith(`O`)||e.startsWith(`CM-`)?`observation`:null}async function s(e,s,c){if(!e?.trim()||!i())return[];let l=c??10,u=await a(e);if(!u)return[];let{getBrainDb:d,getBrainNativeDb:f,isBrainVecLoaded:p}=await t(async()=>{let{getBrainDb:e,getBrainNativeDb:t,isBrainVecLoaded:n}=await import(`./BlapV1mo.js`);return{getBrainDb:e,getBrainNativeDb:t,isBrainVecLoaded:n}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]),import.meta.url);await d(s);let m=f();if(!m||!p())return[];let h;try{h=r(m.prepare(`SELECT id, distance FROM brain_embeddings WHERE embedding MATCH ? ORDER BY distance LIMIT ?`),new Float32Array(u.buffer,u.byteOffset,u.length),l)}catch{return[]}if(h.length===0)return[];let g=await n(s),_=[];for(let e of h){let t=o(e.id);if(t)try{switch(t){case`observation`:{let t=await g.getObservation(e.id);t&&_.push({id:e.id,distance:e.distance,type:`observation`,title:t.title,text:t.narrative??t.title});break}case`decision`:{let t=await g.getDecision(e.id);t&&_.push({id:e.id,distance:e.distance,type:`decision`,title:t.decision,text:`${t.decision} — ${t.rationale}`});break}case`pattern`:{let t=await g.getPattern(e.id);t&&_.push({id:e.id,distance:e.distance,type:`pattern`,title:t.pattern,text:`${t.pattern} — ${t.context}`});break}case`learning`:{let t=await g.getLearning(e.id);t&&_.push({id:e.id,distance:e.distance,type:`learning`,title:t.insight,text:`${t.insight} (source: ${t.source})`});break}}}catch{}}return _}export{s as t};