1import{s as n}from"./index-Bh9u9ili.js";import{d as C,a as E,g as h}from"./index-Bh9u9ili.js";async function v(o,r,e){try{console.log("Attempting to save conversation:",{title:o,messageCount:r.length,userId:e}),console.log("Supabase client status check before saving:",n?"Client initialized":"Client not initialized");const s={title:o};e&&(s.user_id=e);const{data:t,error:a}=await n.from("conversations").insert([s]).select("id").single();if(a)return console.error("Error saving conversation:",a),null;console.log("Conversation record created with ID:",t.id);const i=t.id,l=r.map((g,u)=>({conversation_id:i,role:g.role,content:g.content,message_order:u}));console.log("Saving messages:",l.length);const{error:c}=await n.from("messages").insert(l);return c?(console.error("Error saving messages:",c),null):(console.log("Messages saved successfully"),i)}catch(s){return console.error("Error in saveConversation:",s),null}}async function f(o,r){try{if(console.log("Updating conversation:",o,r),r.title){const{error:e}=await n.from("conversations").update({title:r.title,updated_at:new Date().toISOString()}).eq("id",o);if(e)return console.error("Error updating conversation title:",e),!1;console.log("Title updated successfully")}if(r.messages){const{error:e}=await n.from("messages").delete().eq("conversation_id",o);if(e)return console.error("Error deleting existing messages:",e),!1;const s=r.messages.map((a,i)=>({conversation_id:o,role:a.role,content:a.content,message_order:i})),{error:t}=await n.from("messages").insert(s);if(t)return console.error("Error inserting updated messages:",t),!1;console.log("Messages updated successfully:",s.length)}return!0}catch(e){return console.error("Error in updateConversation:",e),!1}}export{C as deleteConversation,E as getConversation,h as getConversations,v as saveConversation,f as updateConversation};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.