1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8121],{36992:(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>g});var r=o(37876),s=o(89099),n=o(14232),a=o(77328),l=o.n(a),i=o(30207),c=o(22021),d=o(17210),u=o(77985),w=o(79984),f=o(98711),h=o(80862);let m="userConversations";function g(){let e=(0,s.useRouter)(),{id:t,scrollTo:o}=e.query,{messages:a,setMessages:g,setCurrentConversationId:v,setSidebarRefreshTrigger:y}=(0,u.Y)(),[b,p]=(0,n.useState)(!1),[x,E]=(0,n.useState)("BranchPrompt"),S=(0,n.useRef)(!1),k=(0,n.useRef)(!1),_=(0,n.useRef)(0),{isSignedIn:N,user:T}=(0,w.Jd)();return(0,n.useEffect)(()=>{t&&(async()=>{try{let o=await fetch("/api/conversations/".concat(t));if(!o.ok){console.error("Failed to fetch conversation"),e.push("/");return}let r=await o.json();if(E(r.title||"New Conversation"),N&&T&&!r.userId)try{(await fetch("/api/conversations/".concat(t,"/associate"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:T.id})})).ok?y(e=>e+1):console.error("Failed to associate conversation with user")}catch(e){console.error("Error associating conversation with user:",e)}if(!N&&null===r.userId)try{if(!(0,f.lT)()){let e=JSON.parse(localStorage.getItem(m)||"[]");e.includes(t)||(e.push(t),localStorage.setItem(m,JSON.stringify(e)),y(e=>e+1))}}catch(e){console.error("Error adding conversation to localStorage:",e)}v(t)}catch(t){console.error("Error fetching messages:",t),E("Conversation Not Found"),e.push("/")}})()},[t,e,g,v,N,T,y]),(0,n.useEffect)(()=>{let e=e=>{e.detail&&e.detail.conversationId===t&&e.detail.title&&E(e.detail.title)};return window.addEventListener("conversationUpdated",e),()=>{window.removeEventListener("conversationUpdated",e)}},[t]),(0,n.useEffect)(()=>{o&&p(!0)},[o]),(0,n.useEffect)(()=>{a.length>_.current&&p(!1),_.current=a.length},[a]),(0,n.useEffect)(()=>{if(!o||!a.length||S.current||k.current)return;let e=()=>{setTimeout(()=>{let e=Array.from(document.querySelectorAll("[data-message-id]")).find(e=>{let t=e.getAttribute("data-message-id");return t&&t.includes(o)});if(e){e.scrollIntoView({behavior:"smooth",block:"start"}),e.style.boxShadow="0 0 0 2px rgba(234, 179, 8, 0.5)",e.style.transition="box-shadow 0.3s ease-in-out",e.classList.add("bg-yellow-50","dark:bg-yellow-900/10"),setTimeout(()=>{e.classList.add("bg-yellow-100","dark:bg-yellow-900/30"),e.classList.add("border-l-4","border-yellow-500","dark:border-yellow-600")},100),setTimeout(()=>{e.classList.remove("bg-yellow-50","bg-yellow-100","dark:bg-yellow-900/10","dark:bg-yellow-900/30"),e.classList.remove("border-l-4","border-yellow-500","dark:border-yellow-600"),e.style.boxShadow="none"},3e3),S.current=!0;{k.current=!0;let e=new URL(window.location.href);e.searchParams.delete("scrollTo"),window.history.replaceState({},"",e),setTimeout(()=>{k.current=!1},100)}}},500)};(async()=>{let t=await (0,h.xS)(a,o);if(t){let e=new CustomEvent("expandBranches",{detail:{messageId:t._id,fromCommand:!1}});window.dispatchEvent(e),setTimeout(()=>{let e=new CustomEvent("scrollToMessage",{detail:{messageId:o}});window.dispatchEvent(e)},1500)}else e()})()},[o,a,t]),(0,n.useEffect)(()=>{S.current=!1,_.current=0},[t]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(l(),{children:[(0,r.jsxs)("title",{children:[x," - BranchPrompt"]}),(0,r.jsx)("meta",{name:"description",content:"AI conversation: ".concat(x)})]}),(0,r.jsxs)(i.A,{children:[(0,r.jsx)(d.A,{}),(0,r.jsx)("div",{className:"flex flex-col h-full",children:(0,r.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:(0,r.jsx)(c.A,{disableAutoScroll:b})})})]})]})}},88594:(e,t,o)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/conversation/[id]",function(){return o(36992)}])}},e=>{var t=t=>e(e.s=t);e.O(0,[347,1327,2333,3302,9397,8230,3474,3005,3,5979,3431,3312,8127,6658,9591,6743,7475,636,6593,8792],()=>t(88594)),_N_E=e.O()}]);
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.