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