import{p as i}from"./useEvent-D91BmmQi.js";import{Gn as o,Kn as h,na as r}from"./cells-CJLUCcQg.js";import{d as m}from"./arrays-DbOq36rN.js";var d="marimo:ai:chatState:v5";const u=i(null),v=i(null),C=r("marimo:ai:includeOtherCells",!0,h);function f(a){let t=new Map;for(let[s,e]of a.entries()){if(e.messages.length===0)continue;let c=m(e.messages,l=>l.id);t.set(s,{...e,messages:c})}return t}const n=r(d,{chats:new Map,activeChatId:null},o({toSerializable:a=>({chats:[...f(a.chats).entries()],activeChatId:a.activeChatId}),fromSerializable:a=>({chats:new Map(a.chats),activeChatId:a.activeChatId})})),p=i(a=>{let t=a(n);return t.activeChatId?t.chats.get(t.activeChatId):null},(a,t,s)=>{t(n,e=>({...e,activeChatId:s}))});export{v as a,C as i,u as n,n as r,p as t};
