import{u as H,E as L,b as U,a as y,F as p,G as I,H as a,j as n}from"./index-D7HdQSq1.js";import{r as i}from"./vendor-antd-DoyqoZ7x.js";import{S as q}from"./logo-DuzqZi6-.js";import{c as $}from"./account-595yhp2R.js";import{u as j,m as b,R as G,f as P}from"./RenderHistoryList-DesUqR0c.js";import"./vendor-firebase-D-efta1e.js";const W="_shareWrapper_5kgns_1",z="_header_5kgns_11",O="_logo_5kgns_20",Q="_content_5kgns_24",D="_normalContent_5kgns_32",V="_hidden_5kgns_43",X="_fullpageContent_5kgns_47",Y="_errorContainer_5kgns_76",B="_errorText_5kgns_82",J="_loadingContainer_5kgns_88",K="_spinner_5kgns_95",Z="_loadingText_5kgns_103",ee="_content_list_5kgns_128",t={shareWrapper:W,header:z,logo:O,content:Q,normalContent:D,hidden:V,fullpageContent:X,errorContainer:Y,errorText:B,loadingContainer:J,spinner:K,loadingText:Z,content_list:ee};function ie(){const{t:S}=H(),{shareSessionId:u}=L(),[h,m]=i.useState(!0),[T,v]=i.useState([]),[f,x]=i.useState(""),[d,_]=i.useState(!1),[r,g]=i.useState(null),w=j(s=>s.getModelShowName),F=j(s=>s.init);i.useEffect(()=>{F()},[]),i.useEffect(()=>{u&&R()},[u]);const R=async()=>{m(!0),x("");try{const{history:s}=await U.getShareContent({share_session_id:u}),l=A(s||[]);v(l)}catch(s){y.error("Fetch share content error:",s),x(S("share_not_found")||"Share link not found or expired")}finally{m(!1)}},A=s=>{const l=[];return s.forEach(e=>{var k,N;if(e.role===p.USER){const o={role:p.USER,questionId:e.questionId||"",messages:[],id:e.id};switch(e.messageType){case a.FILE:case a.IMAGE:case a.PDF:o.messages=[{...e,type:a.USER_FILE_LIST,content:((N=(k=e.content_dict)==null?void 0:k.files)==null?void 0:N.map(c=>({file_key:c.file_key,original_file_type:c.type,file_type:$(c.type),file_name:c.file_name,file_url:c.url_full,file_size:c.file_size})))||[]}];break;case a.TEXT:o.messages=[{...e,type:a.USER_QUESTION}];break;default:if(e.messageType&&!I(e.messageType)){y.warn('[Share] Ignoring unknown user message type: "'.concat(e.messageType,'"'),{type:e.messageType,content:e.content});return}o.messages=[{...e,type:e.messageType||a.USER_QUESTION}];break}l.push(o);return}const M=(e.content_dict||[]).filter(o=>I(o.type)?!0:(y.warn('[Share] Ignoring unknown message type: "'.concat(o.type,'"'),{type:o.type,content:o.content}),!1)),E={...e,messages:b(M)},C=l.find(o=>o.question_id===e.questionId&&o.role===p.ASSISTANT);if(!C){l.push({role:p.ASSISTANT,question_id:e.questionId,datasource:[E],id:e.id});return}C.datasource.push(E)}),l};return n.jsxs("div",{className:t.shareWrapper,children:[n.jsx("div",{className:t.header,children:n.jsx(q,{className:t.logo})}),n.jsxs("div",{className:t.content,children:[n.jsxs("div",{className:"".concat(t.normalContent," ").concat(d?t.hidden:""),children:[h&&n.jsxs("div",{className:t.loadingContainer,children:[n.jsx("div",{className:t.spinner}),n.jsx("div",{className:t.loadingText,children:S("loading")})]}),!h&&f&&n.jsx("div",{className:t.errorContainer,children:n.jsx("div",{className:t.errorText,children:f})}),!h&&!f&&T.length>0&&n.jsx("div",{className:t.content_list,children:n.jsx(G,{history_list:T,assistantDialogProps:{isShowFullpage:d,fullpageDatasource:r,onToggleFullpage:s=>{s?(g(s),_(!0)):(g(null),_(!1))}}})})]}),n.jsx("div",{className:"".concat(t.fullpageContent," ").concat(d?"":t.hidden),children:d&&r&&n.jsx(P,{datasource:r,isShowFullpage:d,fullpageDatasource:r,onToggleFullpage:s=>{s?(g(s),_(!0)):(g(null),_(!1))},modelShowName:w(r==null?void 0:r.provider,r==null?void 0:r.agent)})})]})]})}export{ie as default};
