PageSourceSearch

https://cridergpt.com/assets/VisionMemoryPanel-Bjkbqqr5.js

js cridergpt.com collected 2026-09-24 14:40:57 UTC 8,043 bytes, 1 lines download raw bytes

1import{u as q,a as k,r as o,s as y,j as e,C as w,e as N,L,b as E,c as S,I as D,d as p,bW as P,E as B,G as R,H as T,J as z,N as $,al as A,a6 as G,B as C,l as H,bX as J,T as O}from"./index-CgMUx9S8.js";import{u as W}from"./useAIMemory-B5E4TnN2.js";import{f as M}from"./format-DyALWzzL.js";function X(a,h){const n=`${a} ${h}`.toLowerCase(),c=[];let r="general";return n.match(/ffa|sae|project|livestock|crop|field|harvest|plant/i)?(r="FFA Project",c.push("agriculture","ffa")):n.match(/receipt|invoice|bill|payment|purchase|total|price|\$|subtotal/i)?(r="Receipt",c.push("finance","document")):n.match(/document|paper|form|contract|agreement|letter/i)?(r="Document",c.push("document")):n.match(/tractor|plow|combine|equipment|machinery|tool|welding|vehicle/i)?(r="Farm Equipment",c.push("equipment","machinery")):n.match(/field|farm|barn|pasture|fence|land|outdoor/i)?(r="Field Photo",c.push("outdoor","farm")):n.match(/meme|funny|humor|joke|caption/i)&&(r="Meme",c.push("entertainment")),{category:r,tags:c}}function K(){const{user:a}=q(),{toast:h}=k(),{storeMemory:n}=W(),[c,r]=o.useState(!1),j=o.useCallback(async(i,t,l)=>{if(a)try{const{category:m,tags:f}=X(l||"",t),{error:x}=await y.from("vision_memory").insert({user_id:a.id,image_url:i,thumbnail_url:i,ai_response:t,category:m,tags:f,metadata:{user_input:l||""}});if(x)throw console.error("Error saving vision memory:",x),h({title:"Error",description:"Failed to save to vision memory",variant:"destructive"}),x;await n(`Vision analysis: ${m}`,t,"image",{category:m,tags:f,imageUrl:i,thumbnailUrl:i}),h({title:"Success",description:"Image analysis saved to memory"})}catch(m){throw console.error("Failed to save vision memory:",m),m}},[a,h,n]),g=o.useCallback(async(i=10)=>{if(!a)return[];r(!0);try{const{data:t,error:l}=await y.from("vision_memory").select("*").order("created_at",{ascending:!1}).limit(i);if(l)throw l;return t||[]}catch(t){return console.error("Error fetching vision memory:",t),[]}finally{r(!1)}},[a]),v=o.useCallback(async i=>{if(!a)return[];r(!0);try{const{data:t,error:l}=await y.from("vision_memory").select("*").eq("category",i).order("created_at",{ascending:!1});if(l)throw l;return t||[]}catch(t){return console.error("Error fetching memories by category:",t),[]}finally{r(!1)}},[a]),u=o.useCallback(async(i,t)=>{if(!a)return[];r(!0);try{const{data:l,error:m}=await y.from("vision_memory").select("*").gte("created_at",i).lte("created_at",t).order("created_at",{ascending:!1});if(m)throw m;return l||[]}catch(l){return console.error("Error fetching memories by date:",l),[]}finally{r(!1)}},[a]),b=o.useCallback(async i=>{if(a)try{const{error:t}=await y.from("vision_memory").delete().eq("id",i);if(t)throw t}catch(t){throw console.error("Error deleting vision memory:",t),t}},[a]);return{saveVisionMemory:j,getRecentMemories:g,getMemoriesByCategory:v,getMemoriesByDateRange:u,deleteMemory:b,isLoading:c}}const Q=["All Categories","Receipt","Document","Meme","FFA Project","Field Photo","Farm Equipment","general"];function ee(){const[a,h]=o.useState([]),[n,c]=o.useState([]),[r,j]=o.useState("All Categories"),[g,v]=o.useState(""),[u,b]=o.useState(null),{getRecentMemories:i,getMemoriesByCategory:t,deleteMemory:l,isLoading:m}=K(),{toast:f}=k();o.useEffect(()=>{x()},[]),o.useEffect(()=>{V()},[a,r,g]);const x=async()=>{const s=await i(50);h(s)},V=()=>{let s=a;r!=="All Categories"&&(s=s.filter(d=>d.category===r)),g&&(s=s.filter(d=>M(new Date(d.created_at),"yyyy-MM-dd")===g)),c(s)},I=async s=>{try{await l(s),f({title:"Memory Deleted",description:"Vision memory entry removed successfully."}),x()}catch{f({title:"Error",description:"Failed to delete memory entry.",variant:"destructive"})}},_=s=>{const d={Receipt:"bg-green-500/20 text-green-700 border-green-500/30",Document:"bg-blue-500/20 text-blue-700 border-blue-500/30",Meme:"bg-purple-500/20 text-purple-700 border-purple-500/30","FFA Project":"bg-yellow-500/20 text-yellow-700 border-yellow-500/30","Field Photo":"bg-emerald-500/20 text-emerald-700 border-emerald-500/30","Farm Equipment":"bg-orange-500/20 text-orange-700 border-orange-500/30",general:"bg-gray-500/20 text-gray-700 border-gray-500/30"};return d[s]||d.general};return m&&a.length===0?e.jsx(w,{className:"w-full",children:e.jsxs(N,{className:"flex items-center justify-center p-8",children:[e.jsx(L,{className:"h-6 w-6 animate-spin mr-2"}),e.jsx("span",{children:"Loading vision memory..."})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs(w,{children:[e.jsx(E,{children:e.jsxs(S,{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-5 w-5"}),"Vision Memory Dashboard",e.jsxs(p,{variant:"secondary",className:"ml-auto",children:[a.length," memories"]})]})}),e.jsxs(N,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-[200px]",children:[e.jsx(P,{className:"h-4 w-4"}),e.jsxs(B,{value:r,onValueChange:j,children:[e.jsx(R,{children:e.jsx(T,{placeholder:"Filter by category"})}),e.jsx(z,{children:Q.map(s=>e.jsx($,{value:s,children:s},s))})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-[200px]",children:[e.jsx(A,{className:"h-4 w-4"}),e.jsx(G,{type:"date",value:g,onChange:s=>v(s.target.value),placeholder:"Filter by date"})]}),(r!=="All Categories"||g)&&e.jsx(C,{variant:"outline",onClick:()=>{j("All Categories"),v("")},children:"Clear Filters"})]}),e.jsx(H,{className:"h-[600px]",children:n.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(D,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No vision memories found."}),e.jsx("p",{className:"text-sm mt-2",children:"Upload images in the main chat to start building your memory!"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:n.map(s=>e.jsxs(w,{className:"overflow-hidden hover:shadow-lg transition-shadow",children:[e.jsxs("div",{className:"relative aspect-video bg-muted",children:[e.jsx("img",{src:s.thumbnail_url||s.image_url,alt:"Memory thumbnail",className:"w-full h-full object-cover"}),e.jsx(p,{className:`absolute top-2 right-2 ${_(s.category)}`,children:s.category})]}),e.jsxs(N,{className:"p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(A,{className:"h-3 w-3"}),M(new Date(s.created_at),"MMM dd, yyyy")]}),e.jsx("span",{children:M(new Date(s.created_at),"h:mm a")})]}),e.jsx("p",{className:"text-sm line-clamp-3",children:s.ai_response}),s.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:s.tags.map((d,F)=>e.jsx(p,{variant:"outline",className:"text-xs",children:d},F))}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(C,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>b(s),children:[e.jsx(J,{className:"h-3 w-3 mr-1"}),"View"]}
1),e.jsx(C,{size:"sm",variant:"destructive",onClick:()=>I(s.id),children:e.jsx(O,{className:"h-3 w-3"})})]})]})]},s.id))})})]})]}),u&&e.jsxs(w,{className:"fixed inset-4 z-50 overflow-auto",children:[e.jsx(E,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(S,{children:"Vision Memory Detail"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:M(new Date(u.created_at),"MMMM dd, yyyy - h:mm a")})]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>b(null),children:"Close"})]})}),e.jsxs(N,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx(p,{className:_(u.category),children:u.category}),u.tags.map((s,d)=>e.jsx(p,{variant:"outline",children:s},d))]}),e.jsx("img",{src:u.image_url,alt:"Full resolution",className:"w-full rounded-lg"}),e.jsxs("div",{className:"p-4 bg-muted rounded-lg",children:[e.jsx("h4",{className:"font-semibold mb-2",children:"AI Analysis:"}),e.jsx("p",{className:"whitespace-pre-wrap",children:u.ai_response})]})]})]})]})}export{ee as VisionMemoryPanel};

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.