(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8811],{53633:function(e,t,r){Promise.resolve().then(r.bind(r,43385))},43385:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return eb}});var s=r(57437),i=r(2265),n=r(14123),o=r(70996),l=r(521),a=r(47553),d=r(78796),c=r(69340),x=r(25810),h=r(13856),m=r(16595),u=r(13449),g=r(60187),j=r(4360),p=r(58055),b=r(25730),f=r(72760),y=r(31631),C=r(13821),v=r(48860),w=r(34096),k=r(27924),S=r(16152),z=r(19674),I=r(26262),E=r(97244),A=r(27247),H=r(69050),N=r(64556),W=r(87461),D=r(10883),F=r(4964),O=r(70185),R=r(3137),M=r(16654),_=r(50017),L=r(52710),P=r(60643),G=r(61507),U=r(6314),T=r(32817),B=r(34442),X=r(11887),V=r(49089),Z=r(30166),J=r(238),Y=r(48614),Q=r(49270),$=r(20517),q=r(58489),K=r(20698),ee=r(19683);let et=(0,Z.default)(()=>Promise.all([r.e(8092),r.e(6687),r.e(5423)]).then(r.bind(r,95423)).then(e=>e.Prism),{loadableGenerated:{webpack:()=>[95423]},ssr:!1}),{atomDark:er}=(0,Z.default)(()=>r.e(6965).then(r.bind(r,26965)),{loadableGenerated:{webpack:()=>[26965]},ssr:!1}),es=i.memo(e=>{let{message:t,renderMarkdown:r}=e;return(0,s.jsx)(o.xu,{alignSelf:"user"===t.role?"flex-end":"flex-start",bg:"user"===t.role?"blue.500":(0,n.ff)("gray.100","gray.700"),color:"user"===t.role?"white":(0,n.ff)("gray.800","white"),borderRadius:"md",p:"2",maxW:"80%",overflowX:"auto",position:"relative",children:(0,s.jsx)(o.xu,{fontSize:{base:"xs",md:"sm"},children:r(t.content)})})});var ei=e=>{let{messages:t=[],model:r={}}=e,a=(0,i.useRef)(null),h=(0,d.p)(),[g,f]=(0,i.useState)(""),[z,E]=(0,i.useState)(!1),{isOpen:A,onOpen:H,onClose:N}=(0,c.q)();(0,n.ff)("gray.50","gray.900");let W=(0,n.ff)("white","gray.800"),F=(0,n.ff)("gray.200","gray.700"),O=(0,i.useMemo)(()=>e=>(0,s.jsx)("div",{className:"blog-content",children:(0,s.jsx)(K.U,{components:{code(e){let{node:t,inline:r,className:i,children:n,...l}=e,a=/language-(\w+)/.exec(i||""),d=String(n).replace(/\n$/,"");return!r&&a?(0,s.jsxs)(o.xu,{position:"relative",children:[(0,s.jsx)(et,{style:er,language:a[1],PreTag:"div",...l,children:d}),(0,s.jsx)(b.h,{icon:(0,s.jsx)(q.T,{}),"aria-label":"Copy code",size:"sm",position:"absolute",top:"2",right:"2",variant:"outline",colorScheme:"blue",onClick:()=>{navigator.clipboard.writeText(d),h({title:"Code copied",status:"success",duration:2e3,isClosable:!0})}})]}):(0,s.jsx)("code",{className:i,...l,children:n})}},remarkPlugins:[ee.Z],children:e})}),[h]),R=(0,i.useMemo)(()=>t,[t]);return(0,s.jsxs)(l.W,{maxW:"container.xl",h:{base:"calc(100vh - 6rem)",md:"calc(100vh - 2rem)"},pt:4,children:[(0,s.jsxs)(I.g,{spacing:"4",h:"full",children:[(0,s.jsx)(u.k,{w:"full",justify:"space-between",align:"center",children:(0,s.jsxs)(p.U,{className:"bg-gray-50",children:[(0,s.jsx)(m.E,{rounded:"md",src:r.icon,alt:r.label,boxSize:{base:"10px",md:"26px"},mr:"2px"}),(0,s.jsx)(y.X,{as:"h1",size:{base:"sm",md:"md"},color:"gray.700",children:r.label})]})}),(0,s.jsx)(o.xu,{flex:"1",w:"full",overflowY:"auto",bg:W,p:"4",borderRadius:"lg",borderWidth:"1px",borderColor:F,children:(0,s.jsxs)(I.g,{spacing:"2",align:"stretch",children:[R.map((e,t)=>(0,s.jsx)(es,{message:e,renderMarkdown:O},t)),(0,s.jsx)("div",{ref:a})]})})]}),(0,s.jsxs)(C.u_,{isOpen:A,onClose:N,children:[(0,s.jsx)(v.Z,{bg:"none",backdropFilter:"auto",backdropInvert:"10%",backdropBlur:"2px"}),(0,s.jsxs)(w.h,{my:"auto",maxH:"90vh",overflowY:"auto",children:[(0,s.jsx)(Q.x,{children:"Share Conversation"}),(0,s.jsx)(k.o,{}),(0,s.jsxs)(S.f,{children:[(0,s.jsx)(j.x,{mb:4,children:"Your conversation has been shared! Use the link below to share it with others:"}),(0,s.jsx)(D.I,{value:g,isReadOnly:!0})]}),(0,s.jsxs)($.m,{children:[(0,s.jsx)(x.z,{colorScheme:"blue",mr:3,onClick:()=>{navigator.clipboard.writeText(g),h({title:"Copied to clipboard",description:"The share link has been copied to your clipboard.",status:"success",duration:3e3,isClosable:!0}),N()},children:"Copy Link"}),(0,s.jsx)(x.z,{variant:"ghost",onClick:N,children:"Close"})]})]})]})]})},en=r(31971);r(33145),r(27648);var eo=r(97082),el=r(26554),ea=r(78440),ed=r(54281);r(36556);let ec={customNode:e=>{let{data:t}=e,r=(0,n.ff)("white","gray.700"),i=(0,n.ff)("gray.200","gray.600"),l=(0,n.ff)("gray.800","white");return(0,s.jsxs)(o.xu,{padding:"10px",borderRadius:"md",width:"200px",fontSize:"sm",color:l,textAlign:"center",border:"1px solid",borderColor:i,backgroundColor:r,boxShadow:"md",children:[(0,s.jsx)(j.x,{fontWeight:"bold",mb:2,children:t.label}),(0,s.jsx)(j.x,{fontSize:"xs",noOfLines:3,children:t.details})]})}};var ex=e=>{let{nodes:t,edges:r,isPreview:n=!1}=e,[l,a,d]=(0,eo.Rr)(t),[c,x,h]=(0,eo.ll)(r.map(e=>({...e,type:"smoothstep",animated:!0,markerEnd:{type:eo.QZ.ArrowClosed}}))),m=(0,i.useCallback)(e=>{e.fitView({padding:.2})},[]);return(0,s.jsx)(o.xu,{height:n?"200px":"70vh",width:"100%",children:(0,s.jsxs)(eo.x$,{nodes:l,edges:c,onNodesChange:d,onEdgesChange:h,nodeTypes:ec,fitView:!0,onInit:m,minZoom:.1,maxZoom:1.5,defaultZoom:.5,attributionPosition:"bottom-right",children:[(0,s.jsx)(el.Z,{}),(0,s.jsx)(ea.a,{}),(0,s.jsx)(ed.A,{color:"#aaa",gap:16})]})})},eh=r(55710),em=r(52093),eu=r(60002);let eg=(0,Z.default)(()=>r.e(3359).then(r.bind(r,53359)).then(e=>e.CSVLink),{loadableGenerated:{webpack:()=>[53359]},ssr:!1}),ej=(0,J.E)(o.xu);var ep=()=>{let[e,t]=(0,i.useState)([]),[r,a]=(0,i.useState)([]),[Z,Q]=(0,i.useState)([]),[$,q]=(0,i.useState)([]),[K,ee]=(0,i.useState)([]),[et,er]=(0,i.useState)(null),[es,el]=(0,i.useState)(null),[ea,ed]=(0,i.useState)(null),[ec,ep]=(0,i.useState)(null),[eb,ef]=(0,i.useState)(!0),[ey,eC]=(0,i.useState)(""),[ev,ew]=(0,i.useState)("desc"),[ek,eS]=(0,i.useState)(1),[ez]=(0,i.useState)(12),[eI,eE]=(0,i.useState)("list"),[eA,eH]=(0,i.useState)(6),eN=(0,d.p)(),{colorMode:eW}=(0,n.If)(),eD=(0,eu.x)(eW),eF=eD.bgColor,eO=eD.cardBgColor,eR=eD.borderColor,eM=eD.textColor,e_=eD.inputBgColor,eL=eD.inputBorderColor;eD.hoverBgColor;let eP=eD.iconColor,{isOpen:eG,onOpen:eU,onClose:eT}=(0,c.q)(),[eB,eX]=(0,i.useState)(null),eV=(0,i.useCallback)(e=>{eB===e?eX(null):eX(e)},[eB]),eZ=(0,i.useCallback)(e=>{window.open(e,"_blank")},[]),eJ=(0,i.useCallback)(async()=>{ef(!0);try{let e=await fetch("/api/get-user-history");if(e.ok){let r=await e.json();t(r.messageHistory||[]),a(r.imagesHistory||[]),Q(r.videosHistory||[]),q(r.mindmapHistory||[]),ee(r.musicHistory||[])}else throw Error("Failed to fetch history")}catch(e){console.error("Error fetching history:",e),eN({title:"Error",description:"Failed to fetch history. Please try again.",status:"error",duration:3e3,isClosable:!0})}finally{ef(!1)}},[eN]);(0,i.useEffect)(()=>{eJ()},[eJ]);let eY=(0,i.useCallback)(e=>{er(e),eE("conversation")},[]);(0,i.useCallback)(e=>{el(e),eE("image")},[]),(0,i.useCallback)(e=>{ed(e),eE("video")},[]);let eQ=(0,i.useCallback)(e=>{ep(e),eE("mindmap")},[]),e$=(0,i.useCallback)(e=>e.messages.map(e=>({role:e.role,content:e.content})),[]),eq=(0,i.useMemo)(()=>{let t=e=>e.filter(e=>{var t,r;return(null===(t=e.title)||void 0===t?void 0:t.toLowerCase().includes(ey.toLowerCase()))||(null===(r=e.prompt)||void 0===r?void 0:r.toLowerCase().includes(ey.toLowerCase()))}).sort((e,t)=>{let r=new Date(e.createdAt||e.timestamp),s=new Date(t.createdAt||t.timestamp);return"asc"===ev?r-s:s-r});return{messages:t(e),images:t(r),videos:t(Z),mindmaps:t($),music:t(K)}},[e,r,Z,$,K,ey,ev]),eK=(0,i.useMemo)(()=>{let e=e=>e.slice(0,eA);return{messages:e(eq.messages),images:e(eq.images),videos:e(eq.videos),mindmaps:e(eq.mindmaps),music:e(eq.music)}},[eq,eA]),e0=()=>{eH(e=>e+6)},e1=()=>{let e=eD.buttonBgColor,t=eD.buttonHoverBgColor,r=eD.buttonTextColor;return(0,s.jsx)(J.E.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},children:(0,s.jsx)(x.z,{onClick:e0,bg:e,color:r,_hover:{bg:t,transform:"translateY(-2px)",boxShadow:"sm"},_active:{bg:t,transform:"translateY(0)",boxShadow:"none"},size:"md",height:"40px",width:"140px",border:"2px",borderColor:e,leftIcon:(0,s.jsx)(h.J,{as:V.wEH,fontSize:"sm"}),children:"Load More"})})},e2=i.memo(e=>{var t;let{item:r,type:n}=e,[l,a]=(0,i.useState)(!1),[c,z]=(0,i.useState)(!1),[I,E]=(0,i.useState)(!1),A=(0,i.useRef)(null),H=(0,i.useRef)(!1);(0,d.p)();let N=(0,i.useMemo)(()=>{try{let e=new Date(r.timestamp||r.updatedAt);if(isNaN(e.getTime()))throw Error("Invalid date");return{timeAgo:(0,eh.Q)(e,{addSuffix:!0}),exact:(0,em.WU)(e,"PPpp")}}catch(e){return console.warn("Error formatting date:",e),{timeAgo:"Date unavailable",exact:"Date unavailable"}}},[r.timestamp,r.updatedAt]),W=(0,i.useCallback)(()=>{A.current||(A.current=new Audio(r.audio),A.current.addEventListener("canplaythrough",()=>E(!1)),A.current.addEventListener("ended",()=>{H.current=!1})),H.current?(A.current.pause(),H.current=!1):(E(!0),A.current.play().then(()=>{H.current=!0,E(!1)}).catch(e=>{console.error("Error playing audio:",e),E(!1)}))},[r.audio]),D=(0,i.useCallback)(()=>{window.open(r.audio,"_blank")},[r.audio]);return(0,i.useEffect)(()=>()=>{A.current&&(A.current.pause(),A.current=null)},[]),(0,s.jsxs)(ej,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3},bg:eO,p:4,borderRadius:"lg",borderWidth:"1px",borderColor:eR,position:"relative",children:[(0,s.jsxs)(u.k,{direction:"column",height:"100%",justify:"space-between",children:["image"===n||"video"===n||"music"===n?(0,s.jsxs)(o.xu,{position:"relative",onMouseEnter:()=>z(!0),onMouseLeave:()=>z(!1),children:["image"===n?(0,s.jsx)(m.E,{src:r.image,alt:"Generated Image",objectFit:"cover",borderRadius:"md",w:"100%",h:"200px"}):"video"===n?(0,s.jsx)("video",{src:r.video,loop:!0,muted:!0,playsInline:!0,style:{width:"100%",height:"200px",objectFit:"cover",borderRadius:"0.375rem"},onMouseEnter:e=>e.target.play(),onMouseLeave:e=>{e.target.pause(),e.target.currentTime=0}}):(0,s.jsx)(u.k,{align:"center",justify:"center",bg:"gray.100",borderRadius:"md",w:"100%",h:"200px",children:(0,s.jsx)(h.J,{as:V.HcQ,boxSize:12,color:"gray.500"})}),(0,s.jsx)(g.u,{label:N.exact,placement:"top",children:(0,s.jsx)(j.x,{position:"absolute",top:2,left:2,fontSize:"xs",color:"white",bg:"rgba(0,0,0,0.7)",px:2,py:1,borderRadius:"md",children:N.timeAgo})}),"music"===n&&(0,s.jsxs)(p.U,{position:"absolute",top:2,right:2,spacing:2,children:[(0,s.jsx)(b.h,{icon:I?(0,s.jsx)(f.$,{}):H.current?(0,s.jsx)(V.Wh,{}):(0,s.jsx)(V.gmG,{}),size:"sm",bg:"rgba(0,0,0,0.7)",color:"white",_hover:{bg:"rgba(0,0,0,0.9)",transform:"scale(1.1)"},_active:{bg:"rgba(0,0,0,1)",transform:"scale(0.95)"},onClick:W,"aria-label":H.current?"Pause Audio":"Play Audio",isDisabled:I}),(0,s.jsx)(b.h,{icon:(0,s.jsx)(V.aBF,{}),size:"sm",bg:"rgba(0,0,0,0.7)",color:"white",_hover:{bg:"rgba(0,0,0,0.9)",transform:"scale(1.1)"},_active:{bg:"rgba(0,0,0,1)",transform:"scale(0.95)"},onClick:D,"aria-label":"Download Audio"})]}),(0,s.jsx)(o.xu,{position:"absolute",bottom:0,left:0,right:0,p:2,bg:"rgba(0,0,0,0.7)",color:"white",borderBottomRadius:"md",children:(0,s.jsx)(j.x,{fontSize:"sm",fontWeight:"bold",noOfLines:2,children:r.prompt||"Untitled ".concat(n.charAt(0).toUpperCase()+n.slice(1)," Generation")})})]}):null,"image"!==n&&"video"!==n&&"music"!==n&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(y.X,{size:"md",mb:2,children:"chat"===n?r.title||"Untitled Conversation":r.prompt||"Untitled ".concat(n.charAt(0).toUpperCase()+n.slice(1)," Generation")}),"chat"===n&&(0,s.jsx)(j.x,{fontSize:"sm",mb:4,color:eM,noOfLines:3,children:r.messages&&(null===(t=r.messages[0])||void 0===t?void 0:t.content)})]}),"mindmap"===n&&(0,s.jsx)(o.xu,{height:"200px",children:(0,s.jsx)(eo.tV,{children:(0,s.jsx)(ex,{nodes:r.nodes,edges:r.edges,isPreview:!0})})}),"image"!==n&&"video"!==n&&"music"!==n&&(0,s.jsxs)(p.U,{justifyContent:"space-between",mt:2,children:[(0,s.jsx)(g.u,{label:N.exact,placement:"top",children:(0,s.jsx)(j.x,{fontSize:"sm",color:"gray.500",children:N.timeAgo})}),(0,s.jsxs)(p.U,{children:["mindmap"===n&&(0,s.jsx)(g.u,{label:"View Mindmap",children:(0,s.jsx)(b.h,{icon:(0,s.jsx)(V.Qkp,{}),size:"sm",variant:"ghost",onClick:()=>eQ(r)})}),"chat"===n&&(0,s.jsx)(x.z,{rightIcon:(0,s.jsx)(V.dSq,{}),onClick:()=>eY(r),colorScheme:"blue",size:"sm",variant:"outline",children:"Read Full"})]})]})]}),(0,s.jsxs)(C.u_,{isOpen:l,onClose:()=>a(!1),size:"xl",isCentered:!0,children:[(0,s.jsx)(v.Z,{backdropFilter:"blur(4px)"}),(0,s.jsxs)(w.h,{children:[(0,s.jsx)(k.o,{}),(0,s.jsx)(S.f,{p:0,children:(0,s.jsxs)(o.xu,{position:"relative",children:["image"===n?(0,s.jsx)(m.E,{src:r.image,alt:"Enlarged Generated Image",objectFit:"contain",w:"100%",h:"auto",maxH:"80vh"}):(0,s.jsx)("video",{src:r.video,controls:!0,preload:"metadata",autoPlay:!1,style:{width:"100%",height:"auto",maxHeight:"80vh"}}),(0,s.jsx)(j.x,{position:"absolute",top:2,left:2,fontSize:"sm",color:"white",bg:"rgba(0,0,0,0.7)",px:2,py:1,borderRadius:"md",children:N.exact})]})})]})]})]})},[eO,eM,eY,eQ,eV,eZ,eB]),e4=()=>(0,s.jsxs)(o.xu,{bg:eO,p:5,borderRadius:"lg",borderColor:eR,children:[(0,s.jsxs)(u.k,{alignItems:"center",mb:4,children:[(0,s.jsx)(z.s,{size:"40px",mr:4,startColor:eD.skeletonStartColor,endColor:eD.skeletonEndColor}),(0,s.jsxs)(I.g,{align:"start",spacing:1,flex:1,children:[(0,s.jsx)(E.O,{height:"24px",width:"80%",startColor:eD.skeletonStartColor,endColor:eD.skeletonEndColor}),(0,s.jsx)(E.O,{height:"20px",width:"40%",startColor:eD.skeletonStartColor,endColor:eD.skeletonEndColor})]})]}),(0,s.jsx)(A.N,{mt:"4",noOfLines:2,spacing:"4",startColor:eD.skeletonStartColor,endColor:eD.skeletonEndColor}),(0,s.jsxs)(u.k,{mt:4,justifyContent:"space-between",children:[(0,s.jsx)(E.O,{height:"32px",width:"45%",startColor:eD.skeletonStartColor,endColor:eD.skeletonEndColor}),(0,s.jsx)(E.O,{height:"32px",width:"45%",startColor:eD.skeletonStartColor,endColor:eD.skeletonEndColor})]})]}),e6=e=>{let t="data:text/json;charset=utf-8,"+encodeURIComponent(JSON.stringify(e)),r=document.createElement("a");r.setAttribute("href",t),r.setAttribute("download","mindmap_".concat(e.title,".json")),document.body.appendChild(r),r.click(),r.remove()};return(0,s.jsxs)(l.W,{maxW:"container.xl",py:8,bg:eF,children:[(0,s.jsxs)(u.k,{alignItems:"center",mb:3,gap:"3",children:[(0,s.jsx)(h.J,{as:V.ceS,boxSize:6,color:eP}),(0,s.jsx)(y.X,{as:"h1",fontSize:{base:"xl",md:"3xl"},fontWeight:"semibold",color:eM,children:"History"})]}),(0,s.jsx)(j.x,{mb:4,fontSize:"lg",color:eM,children:"Browse your past conversations and image generations"}),"conversation"===eI||"image"===eI||"video"===eI?(0,s.jsxs)(H.a,{mb:4,children:[(0,s.jsx)(N.g,{children:(0,s.jsx)(W.A,{onClick:()=>eE("list"),children:"History"})}),"conversation"===eI&&(0,s.jsx)(N.g,{isCurrentPage:!0,children:(0,s.jsx)(W.A,{children:null==et?void 0:et.title})}),"image"===eI&&(0,s.jsx)(N.g,{isCurrentPage:!0,children:(0,s.jsx)(W.A,{children:"Image Details"})}),"video"===eI&&(0,s.jsx)(N.g,{isCurrentPage:!0,children:(0,s.jsx)(W.A,{children:"Video Details"})})]}):null,(()=>{switch(eI){case"conversation":return(0,s.jsxs)(o.xu,{children:[(0,s.jsxs)(u.k,{justifyContent:"space-between",alignItems:"center",mb:4,children:[(0,s.jsx)(y.X,{size:"lg",children:null==et?void 0:et.title}),(0,s.jsxs)(p.U,{spacing:2,children:[(0,s.jsx)(en.Z,{threadId:null==et?void 0:et.threadId}),(0,s.jsx)(eg,{data:e$(et),filename:"conversation_".concat(null==et?void 0:et.createdAt,".csv"),children:(0,s.jsx)(x.z,{leftIcon:(0,s.jsx)(V.u$v,{}),colorScheme:"green",size:"sm",variant:"outline",children:"Export CSV"})}),(0,s.jsx)(x.z,{leftIcon:(0,s.jsx)(V.x_l,{}),onClick:()=>eE("list"),variant:"outline",children:"Back"})]})]}),(0,s.jsx)(ei,{messages:(null==et?void 0:et.messages)||[],model:X.C.find(e=>e.label===(null==et?void 0:et.model))||X.C[0]})]});case"image":return(0,s.jsxs)(o.xu,{children:[(0,s.jsxs)(u.k,{justifyContent:"space-between",alignItems:"center",mb:4,children:[(0,s.jsx)(y.X,{size:"lg",children:"Image Details"}),(0,s.jsx)(x.z,{leftIcon:(0,s.jsx)(V.x_l,{}),onClick:()=>eE("list"),children:"Back to History"})]}),(0,s.jsx)(m.E,{src:null==es?void 0:es.image,alt:"Generated Image",w:"100%",h:"auto",mb:4}),(0,s.jsx)(j.x,{fontWeight:"bold",children:"Prompt:"}),(0,s.jsx)(j.x,{mb:2,children:null==es?void 0:es.prompt}),(0,s.jsx)(j.x,{fontWeight:"bold",children:"Date:"}),(0,s.jsx)(j.x,{mb:4,children:new Date(null==es?void 0:es.timestamp).toLocaleString()}),(0,s.jsx)(x.z,{as:"a",href:null==es?void 0:es.image,download:!0,colorScheme:"green",children:"Download Image"})]});case"video":return(0,s.jsxs)(o.xu,{children:[(0,s.jsxs)(u.k,{justifyContent:"space-between",alignItems:"center",mb:4,children:[(0,s.jsx)(y.X,{size:"lg",children:"Video Details"}),(0,s.jsx)(x.z,{leftIcon:(0,s.jsx)(V.x_l,{}),onClick:()=>eE("list"),children:"Back to History"})]}),(0,s.jsx)("video",{src:null==ea?void 0:ea.video,controls:!0,width:"100%"}),(0,s.jsx)(j.x,{fontWeight:"bold",children:"Prompt:"}),(0,s.jsx)(j.x,{mb:2,children:null==ea?void 0:ea.prompt}),(0,s.jsx)(j.x,{fontWeight:"bold",children:"Date:"}),(0,s.jsx)(j.x,{mb:4,children:new Date(null==ea?void 0:ea.timestamp).toLocaleString()}),(0,s.jsx)(x.z,{as:"a",href:null==ea?void 0:ea.video,download:!0,colorScheme:"green",children:"Download Video"})]});case"mindmap":return(0,s.jsx)(J.E.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.5},children:(0,s.jsxs)(o.xu,{children:[(0,s.jsxs)(u.k,{justifyContent:"space-between",alignItems:"center",mb:4,children:[(0,s.jsxs)(y.X,{size:"lg",children:["Mindmap: ",null==ec?void 0:ec.title]}),(0,s.jsx)(x.z,{leftIcon:(0,s.jsx)(V.x_l,{}),onClick:()=>eE("list"),children:"Back to History"})]}),(0,s.jsx)(o.xu,{borderWidth:"1px",borderRadius:"lg",overflow:"hidden",boxShadow:"xl",bg:eO,borderColor:eR,children:(0,s.jsx)(eo.tV,{children:(0,s.jsx)(ex,{nodes:null==ec?void 0:ec.nodes,edges:null==ec?void 0:ec.edges})})}),(0,s.jsxs)(I.g,{align:"start",spacing:2,mt:4,children:[(0,s.jsxs)(j.x,{children:[(0,s.jsx)("strong",{children:"Created:"})," ",new Date(null==ec?void 0:ec.createdAt).toLocaleString()]}),(0,s.jsxs)(j.x,{children:[(0,s.jsx)("strong",{children:"Last Updated:"})," ",new Date(null==ec?void 0:ec.updatedAt).toLocaleString()]}),(0,s.jsxs)(j.x,{children:[(0,s.jsx)("strong",{children:"Number of Nodes:"})," ",null==ec?void 0:ec.nodes.length]}),(0,s.jsxs)(j.x,{children:[(0,s.jsx)("strong",{children:"Number of Connections:"})," ",null==ec?void 0:ec.edges.length]})]}),(0,s.jsx)(p.U,{spacing:4,mt:4,children:(0,s.jsx)(x.z,{colorScheme:"green",onClick:()=>e6(ec),children:"Export Mindmap"})})]})});default:return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(u.k,{mb:4,justifyContent:"space-between",flexWrap:"wrap",children:[(0,s.jsx)(D.I,{placeholder:"Search history...",value:ey,onChange:e=>eC(e.target.value),width:{base:"100%",md:"300px"},mb:{base:2,md:0},bg:e_,borderColor:eL}),(0,s.jsxs)(p.U,{children:[(0,s.jsxs)(F.P,{value:ev,onChange:e=>ew(e.target.value),width:{base:"100%",md:"200px"},bg:e_,borderColor:eL,children:[(0,s.jsx)("option",{value:"desc",children:"Newest First"}),(0,s.jsx)("option",{value:"asc",children:"Oldest First"})]}),(0,s.jsx)(g.u,{label:"Sort Order",children:(0,s.jsx)(x.z,{onClick:()=>ew("asc"===ev?"desc":"asc"),children:(0,s.jsx)(h.J,{as:V.roE})})})]})]}),(0,s.jsxs)(O.m,{isFitted:!0,variant:"enclosed",children:[(0,s.jsxs)(R.t,{mb:"1em",children:[(0,s.jsx)(M.O,{children:"Chat History"}),(0,s.jsx)(M.O,{children:"Image Generation History"}),(0,s.jsx)(M.O,{children:"Video Generation History"}),(0,s.jsx)(M.O,{children:"Mindmap History"}),(0,s.jsx)(M.O,{children:"Music Generation History"})]}),(0,s.jsxs)(_.n,{children:[(0,s.jsx)(L.x,{children:eb?(0,s.jsx)(P.r,{templateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:6,children:[...Array(6)].map((e,t)=>(0,s.jsx)(e4,{},t))}):0===eK.messages.length?(0,s.jsxs)(G.b,{status:"info",variant:"subtle",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",height:"200px",borderRadius:"lg",bg:eO,color:eM,children:[(0,s.jsx)(U.z,{boxSize:"40px",mr:0}),(0,s.jsx)(T.C,{mt:4,mb:1,fontSize:"lg",children:"No Chat History Found"}),(0,s.jsx)(B.X,{maxWidth:"sm",children:ey?"No results match your search. Try different keywords.":"Start a new chat to begin building your conversation history."})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Y.M,{children:(0,s.jsx)(P.r,{templateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:6,children:eK.messages.map((e,t)=>(0,s.jsx)(e2,{item:e,type:"chat"},e.createdAt+t))})}),eq.messages.length>eA&&(0,s.jsx)(u.k,{justifyContent:"center",mt:8,mb:4,children:(0,s.jsx)(e1,{})})]})}),(0,s.jsx)(L.x,{children:eb?(0,s.jsx)(P.r,{templateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:6,children:[...Array(6)].map((e,t)=>(0,s.jsx)(e4,{},t))}):0===eK.images.length?(0,s.jsxs)(G.b,{status:"info",variant:"subtle",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",height:"200px",borderRadius:"lg",bg:eO,color:eM,children:[(0,s.jsx)(U.z,{boxSize:"40px",mr:0}),(0,s.jsx)(T.C,{mt:4,mb:1,fontSize:"lg",children:"No Image Generation History Found"}),(0,s.jsx)(B.X,{maxWidth:"sm",children:ey?"No results match your search. Try different keywords.":"Generate an image to start building your image generation history."})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Y.M,{children:(0,s.jsx)(P.r,{templateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:6,children:eK.images.map((e,t)=>(0,s.jsx)(e2,{item:e,type:"image"},e.timestamp+t))})}),eq.images.length>eA&&(0,s.jsx)(u.k,{justifyContent:"center",mt:8,mb:4,children:(0,s.jsx)(e1,{})})]})}),(0,s.jsx)(L.x,{children:eb?(0,s.jsx)(P.r,{templateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:6,children:[...Array(6)].map((e,t)=>(0,s.jsx)(e4,{},t))}):0===eK.videos.length?(0,s.jsxs)(G.b,{status:"info",variant:"subtle",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",height:"200px",borderRadius:"lg",bg:eO,color:eM,children:[(0,s.jsx)(U.z,{boxSize:"40px",mr:0}),(0,s.jsx)(T.C,{mt:4,mb:1,fontSize:"lg",children:"No Video Generation History Found"}),(0,s.jsx)(B.X,{maxWidth:"sm",children:ey?"No results match your search. Try different keywords.":"Generate a video to start building your video generation history."})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Y.M,{children:(0,s.jsx)(P.r,{templateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:6,children:eK.videos.map((e,t)=>(0,s.jsx)(e2,{item:e,type:"video"},e.timestamp+t))})}),eq.videos.length>eA&&(0,s.jsx)(u.k,{justifyContent:"center",mt:8,mb:4,children:(0,s.jsx)(e1,{})})]})}),(0,s.jsx)(L.x,{children:eb?(0,s.jsx)(P.r,{templateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:6,children:[...Array(6)].map((e,t)=>(0,s.jsx)(e4,{},t))}):0===eK.mindmaps.length?(0,s.jsxs)(G.b,{status:"info",variant:"subtle",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",height:"200px",borderRadius:"lg",bg:eO,color:eM,children:[(0,s.jsx)(U.z,{boxSize:"40px",mr:0}),(0,s.jsx)(T.C,{mt:4,mb:1,fontSize:"lg",children:"No Mindmap History Found"}),(0,s.jsx)(B.X,{maxWidth:"sm",children:ey?"No results match your search. Try different keywords.":"Create a mindmap to start building your mindmap history."})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Y.M,{children:(0,s.jsx)(P.r,{templateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:6,children:eK.mindmaps.map((e,t)=>(0,s.jsx)(e2,{item:e,type:"mindmap"},e.threadId+t))})}),eq.mindmaps.length>eA&&(0,s.jsx)(u.k,{justifyContent:"center",mt:8,mb:4,children:(0,s.jsx)(e1,{})})]})}),(0,s.jsx)(L.x,{children:eb?(0,s.jsx)(P.r,{templateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:6,children:[...Array(6)].map((e,t)=>(0,s.jsx)(e4,{},t))}):0===eK.music.length?(0,s.jsxs)(G.b,{status:"info",variant:"subtle",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",height:"200px",borderRadius:"lg",bg:eO,color:eM,children:[(0,s.jsx)(U.z,{boxSize:"40px",mr:0}),(0,s.jsx)(T.C,{mt:4,mb:1,fontSize:"lg",children:"No Music Generation History Found"}),(0,s.jsx)(B.X,{maxWidth:"sm",children:ey?"No results match your search. Try different keywords.":"Generate music to start building your music generation history."})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Y.M,{children:(0,s.jsx)(P.r,{templateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:6,children:eK.music.map((e,t)=>(0,s.jsx)(e2,{item:e,type:"music"},e.timestamp+t))})}),eq.music.length>eA&&(0,s.jsx)(u.k,{justifyContent:"center",mt:8,mb:4,children:(0,s.jsx)(e1,{})})]})})]})]})]})}})()]})},eb=()=>{let{colorMode:e}=(0,n.If)(),t=(0,eu.x)(e);return(0,s.jsxs)(o.xu,{display:"flex",bg:t.bgColor,minHeight:"100vh",children:[(0,s.jsx)(a.Z,{}),(0,s.jsx)(l.W,{maxW:"container.xl",pt:4,bg:t.bgColor,children:(0,s.jsx)(ep,{})})]})}},31971:function(e,t,r){"use strict";var s=r(57437),i=r(2265),n=r(78796),o=r(60187),l=r(25810),a=r(61273);t.Z=e=>{let{threadId:t}=e,[r,d]=(0,i.useState)(!1),[c,x]=(0,i.useState)(!1),h=(0,n.p)(),m=async()=>{if(!r){x(!0);try{if(!t)throw Error("No thread ID available");let e="".concat(window.location.origin,"/shared-pages/").concat(t);await navigator.clipboard.writeText(e),d(!0),h({title:"Conversation shared successfully",description:"The share link has been copied to your clipboard.",status:"success",duration:3e3,isClosable:!0})}catch(e){console.error("Error sharing conversation:",e),h({title:"Error",description:"Failed to share conversation. Please try again.",status:"error",duration:3e3,isClosable:!0})}finally{x(!1)}}};return(0,s.jsx)(o.u,{label:"Share conversation",children:(0,s.jsx)(l.z,{leftIcon:r?(0,s.jsx)(a.l_A,{}):(0,s.jsx)(a.OcW,{}),onClick:m,isLoading:c,variant:"outline",size:{base:"sm",md:"md"},colorScheme:r?"green":"gray",children:r?"Shared":"Share"})})}}},function(e){e.O(0,[1627,7699,8310,5505,3665,9212,5452,7240,780,9997,6137,6580,1760,9784,6971,5567,2972,5878,6349,605,4680,210,698,806,9683,5401,580,9721,7553,2971,2117,1744],function(){return e(e.s=53633)}),_N_E=e.O()}]);