1import{j as l}from"./compiler-runtime-DLkwNwoZ.js";import{a as E,D as x,C,b as T,c as w}from"./mermaid-NA5CF7SZ-BYHONDfP.js";import{r as g}from"./index-CUC4KNaM.js";import{u as D,a as O}from"./toolkit-B3pGKKyQ.js";import{c as P}from"./useChatVisibilty-D9XDTMoK.js";import{r as I}from"./index-BBaSafD8.js";import"./db-BN6iLDKu.js";import{u as _}from"./organization-szs4jqGw.js";import{u as M}from"./use-observer-0gWpml5H.js";import"./index-DB3SPp4H.js";import"./createLucideIcon-CbC9zL1n.js";import"./icon-BdCD8k7S.js";import"./index-D5LfJevP.js";import"./index-CtSaI5qA.js";import"./input-Df1evK8t.js";import"./select-DPiKqYvh.js";import"./x-CQwKumby.js";import"./button-BycSCIeG.js";import"./apps-BfGSF3-X.js";import"./tooltip-CT2zBBu4.js";import"./useActiveOrganizationId-DK3TAB39.js";import"./tool-provider-LoI_Mv7x.js";import"./IframeMessageHandler-Dbye1oVo.js";import"./ui-react-BYRFogo2.js";import"./progress-DWcrln2z.js";import"./projectMetadata-4xj6nUcZ.js";import"./useQuery-N1zTHCAY.js";import"./useBaseQuery-CxWYwM2s.js";import"./context-D6OF2xnR.js";import"./dropdown-menu-CK9VtS4n.js";import"./sheet-2XKcy-eh.js";import"./menubar-C3zmiCP4.js";import"./index-CO39ccDC.js";import"./use-toast-BwDM5S4O.js";import"./skeleton-KxdAIOGD.js";import"./jotai-atoms-Bzf1iqT4.js";import"./dnd-context-B8gte3KA.js";import"./table-tZ4KSXGk.js";import"./promise-cache-D2fLeNqp.js";import"./jspdf.es.min-BBYhigS-.js";import"./devtools-Bo2lEyOu.js";import"./useSuspenseQuery-DJp6Bkmm.js";import"./avatar-W33v-7X3.js";import"./useMutation-DBGsYuom.js";import"./SupabaseStorageClient-DsF9fvP-.js";import"./alert-BueLOHcc.js";import"./purify.es-DDpmou9H.js";import"./card-DGAT9qsW.js";import"./separator-DdidCF-D.js";import"./sidebar-Ch-wQvTp.js";import"./theme-CPV7D_Sg.js";import"./client-Da_-_RI5.js";import"./collapsible-DIGxNEi5.js";import"./loader-circle-DawacAv4.js";import"./useRunWorkflowTrigger-CSa73H_5.js";import"./formatDistance-Bp_8j7la.js";import"./constructNow-CI4RUJkd.js";function N(){var c=typeof SuppressedError=="function"?SuppressedError:function(o,t){var r=Error();return r.name="SuppressedError",r.error=o,r.suppressed=t,r},n={},s=[];function e(o,t){if(t!=null){if(Object(t)!==t)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(o)var r=t[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(r===void 0&&(r=t[Symbol.dispose||Symbol.for("Symbol.dispose")],o))var a=r;if(typeof r!="function")throw new TypeError("Object is not disposable.");a&&(r=function(){try{a.call(t)}catch(p){return Promise.reject(p)}}),s.push({v:t,d:r,a:o})}else o&&s.push({d:t,a:o});return t}return{e:n,u:e.bind(null,!1),a:e.bind(null,!0),d:function(){var o,t=this.e,r=0;function a(){for(;o=s.pop();)try{if(!o.a&&r===1)return r=0,s.push(o),Promise.resolve().then(a);if(o.d){var i=o.d.call(o.v);if(o.a)return r|=2,Promise.resolve(i).then(a,p)}else r|=1}catch(d){return p(d)}if(r===1)return t!==n?Promise.reject(t):Promise.resolve();if(t!==n)throw t}function p(i){return t=t!==n?new c(i,t):i,a()}return a()}}}function zt(){try{var c=N();const n=c.u(M()),{id:s}=D(),e=O(),t=I.auth.me?.id,r=_(),[a,p]=g.useState(!0),[i,d]=g.useState(null);if(g.useEffect(()=>{if(!s){e("/chat");return}(async()=>{try{const m=await fetch("/api/chat/get",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:s})});if(!m.ok){e("/chat");return}const f=m.headers.get("content-type");if(!f||!f.includes("application/json")){console.error("Expected JSON response but got:",f),e("/chat");return}const u=await m.json();if(u.visibility==="private"&&(!t||t!==u.user_id||r!==u.organization_id)){e("/chat");return}const h=await fetch("/api/chat/get-messages",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:s})});if(!h.ok){console.error("Failed to fetch messages"),e("/chat");return}const y=h.headers.get("content-type");if(!y||!y.includes("application/json")){console.error("Expected JSON response but got:",y),e("/chat");return}const S=await h.json(),j=P(S);d({chat:u,messages:j}),p(!1)}
1catch(m){console.error("Error loading chat:",m),e("/chat")}})()},[s,t,e]),a||!i)return l.jsx("div",{className:"flex h-dvh"});const v=E.get("chat-model")||x,b=t!==i.chat.user_id;return l.jsxs(C,{context:null,children:[l.jsx(T,{autoResume:!0,id:i.chat.id,initialChatModel:v,initialMessages:i.messages,initialVisibilityType:i.chat.visibility,isReadonly:b},i.chat.id),l.jsx(w,{})]})}catch(n){c.e=n}finally{c.d()}}export{zt as default};
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.