"use strict";(self.webpackChunkAutoGen_Assistant=self.webpackChunkAutoGen_Assistant||[]).push([[618],{18700:function(e,t,a){a.r(t),a.d(t,{default:function(){return p}});var l=a(67294),s=a(30372),n=a(91160),r=a(15596),c=a(1642),m=a(63430),i=a(71968),o=a(51446),d=a(82313),u=a(71082),g=a(80479);var E=e=>{let{location:t}=e;const a=(0,r.RU)(),{user:s}=l.useContext(n.T),[E,p]=l.useState(!1),[v,y]=l.useState(null),[N,h]=l.useState(null),x=`${a}/gallery?user_id=${null==s?void 0:s.email}`,[f,b]=l.useState({status:!0,message:"All good"}),[w,k]=l.useState(null);l.useEffect((()=>{const e=new URLSearchParams(t.search).get("id");e?(Z(e),k(e)):Z(null)}),[]);const Z=e=>{const t=e?`${a}/gallery?gallery_id=${e}`:x;b(null),p(!0);(0,r.ZV)(t,{method:"GET",headers:{"Content-Type":"application/json"}},(t=>{console.log(t),t&&t.status?(c.ZP.success(t.message),console.log("gallery",t),e?h(t.data[0]):y(t.data)):c.ZP.error(t.message),p(!1)}),(e=>{b(e),c.ZP.error(e.message),p(!1)}))},S=e=>{let{item:t}=e;return l.createElement("div",null,l.createElement("div",{className:"mb-4 text-sm"},"This session contains ",t.messages.length," messages and was created"," ",(0,r.Sy)(t.timestamp)),l.createElement("div",{className:""},l.createElement(g.Z,{initMessages:t.messages,editable:!1})))},A=e=>{let{tags:t}=e;const a=t.map(((e,t)=>l.createElement("div",{key:"tag"+t,className:"mr-2 inline-block"},l.createElement("span",{className:"text-xs bg-secondary border px-3 p-1 rounded"},e))));return l.createElement("div",{className:"flex flex-wrap"},a)},C=null==v?void 0:v.map(((e,t)=>{const a=(null==N?void 0:N.id)===e.id;return l.createElement("div",{key:"galleryrow"+t,className:""},l.createElement(i.Zb,{active:a,onClick:()=>{h(e),(0,u.navigate)(`/gallery?id=${e.id}`)},className:"h-full p-2 cursor-pointer",title:(0,r.aF)(e.messages[0].content,20)},l.createElement("div",{className:"my-2"}," ",(0,r.aF)(e.messages[0].content,80)),l.createElement("div",{className:"text-xs"}," ",e.messages.length," messsage",e.messages.length>1&&"s"),l.createElement("div",{className:"my-2 border-t border-dashed w-full pt-2 inline-flex gap-2 "},l.createElement(A,{tags:e.tags})," "),l.createElement("div",{className:"text-xs"},(0,r.Sy)(e.timestamp))))}));return l.createElement("div",{className:" "},l.createElement("div",{className:"mb-4 text-2xl"},"Gallery"),N&&l.createElement("div",{className:"mb-4   w-full"},l.createElement(m.ZP,{type:"primary",onClick:()=>{h(null),(0,u.navigate)(`/gallery?_=${Date.now()}`),w&&(Z(null),k(null))},className:"bg-primary text-white px-2 py-1 rounded"},l.createElement(o.Z,{className:"h-4 w-4 inline mr-1"}),"Back to gallery")),!N&&l.createElement(l.Fragment,null,l.createElement("div",null,"View a collection of AutoGen agent specifications and sessions"," "),l.createElement("div",{className:"mt-4 grid gap-3 grid-cols-2 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6"},C)),v&&0===v.length&&l.createElement("div",{className:"text-sm border rounded text-secondary p-2"},l.createElement(d.Z,{className:"h-4 w-4 inline mr-1"}),"No gallery items found. Please create a chat session and publish to gallery."),N&&l.createElement("div",{className:"mt-4 border-t pt-2"},l.createElement(S,{item:N})),E&&l.createElement("div",{className:"w-full text-center boder mt-4"},l.createElement("div",null," ",l.createElement(i.F8,null)),"loading gallery"))};var p=e=>{let{location:t,data:a}=e;return l.createElement(s.Z,{meta:a.site.siteMetadata,title:"Gallery",link:"/gallery"},l.createElement("main",{style:{height:"100%"},className:" h-full "},l.createElement(E,{location:t})))}}}]);
//# sourceMappingURL=component---src-pages-gallery-index-tsx-47ea544ce2e40f417ad4.js.map