import{n as e,s as t,t as n}from"./jsx-runtime-Bzw2jH9X.js";import{$t as r,Bt as i,Gt as a,Kt as o,N as s,O as c,Rt as l,Vt as u,Xt as d,en as f,it as p,zt as m}from"./services-D2mwzmR1.js";import{t as h}from"./date-CTxYulDo.js";import{t as g}from"./spin-CdYmgj0j.js";import{t as _}from"./FolderPickerModal-D3U_hRWH.js";import{t as v}from"./PdfViewer-CXAE8ny-.js";import{n as y}from"./minimize-2-B3GalKo_.js";import{t as b}from"./x-CkbzgTHo.js";import{n as x}from"./modalStore-B5-16H5z.js";import{n as ee}from"./AuthContext-BY11fAK4.js";import{t as S}from"./react-9QMQ-6_p.js";import{t as C}from"./AnimatePresence-DYGjgYfI.js";import{F as te,K as w,S as T,Vt as E,_t as D,cn as O,ct as k,ln as ne,n as A,rn as j,rt as M,ut as N}from"./index-DKB7WbJs.js";import{t as re}from"./SEO-BRfiPwJb.js";import{t as ie}from"./geo-seo-7ggcs51I.js";import{t as ae}from"./seo-text-Do_deNpV.js";import{t as oe}from"./ReportDetailHeader-Xu8piv60.js";var P=t(e(),1),F=n(),I=5;function se(){let{hasActiveVipMembership:e}=T(),t=x(e=>e.open),[n,r]=(0,P.useState)(null),[i,a]=(0,P.useState)(null),[o,s]=(0,P.useState)(I),c=(0,P.useRef)(I);(0,P.useEffect)(()=>{if(e)return;let t=!1;return(async()=>{try{let e=await p({position:`report_detail_popup`});if(t||!e)return;r(e),c.current=I,s(I),a(`counting`)}catch(e){console.error(e)}})(),()=>{t=!0}},[e]),(0,P.useEffect)(()=>{if(i!==`counting`)return;let e=setInterval(()=>{--c.current,c.current<=0?(clearInterval(e),s(0),a(`minimized`)):s(c.current)},1e3);return()=>clearInterval(e)},[i]);let l=()=>A(n),u=()=>a(null);return!n||i===null?null:(0,F.jsx)(C,{mode:`popLayout`,children:i===`counting`||i===`fullscreen`?(0,F.jsxs)(S.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},className:`fixed inset-0 ${f.global} flex items-center justify-center p-4`,children:[(0,F.jsx)(S.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},onClick:()=>{i===`fullscreen`&&a(`minimized`)},className:`absolute inset-0 bg-slate-900/70 ${i===`counting`?`pointer-events-none`:`cursor-pointer`}`}),(0,F.jsxs)(S.div,{initial:{opacity:0,scale:.92},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.92},transition:{duration:.25},onClick:e=>e.stopPropagation(),className:`relative`,children:[(0,F.jsx)(`img`,{src:n.image,alt:`广告`,onClick:l,className:`max-w-220 max-h-[80vh] w-auto h-auto rounded-2xl shadow-[0_24px_60px_rgba(15,23,42,0.4)] object-contain select-none ${n.uri?`cursor-pointer`:``}`}),(0,F.jsxs)(`div`,{className:`absolute top-4 right-4 flex items-center gap-2`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-full bg-slate-900/60 px-3 py-1.5 text-xs font-semibold text-white backdrop-blur-sm ${i===`counting`?``:`hidden`}`,children:[`剩余 `,o,` ç§’åŽè‡ªåЍ关é—`]}),(0,F.jsxs)(`button`,{type:`button`,onClick:()=>{a(`minimized`),t(`payVip`)},className:`flex items-center gap-1.5 rounded-full bg-linear-to-r from-amber-400 to-orange-500 px-3.5 py-1.5 text-xs font-bold text-white shadow-lg shadow-amber-500/30 transition-transform hover:scale-105 cursor-pointer`,children:[(0,F.jsx)(k,{size:13}),`VIP去广告`]})]})]})]},`ad-fullscreen`):(0,F.jsx)(S.div,{initial:{opacity:0,scale:.6,y:40},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.6,y:40},transition:{duration:.3},onClick:()=>a(`fullscreen`),className:`fixed bottom-6 right-6 ${f.global} group cursor-pointer`,children:(0,F.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl shadow-[0_16px_40px_rgba(15,23,42,0.35)] border border-slate-200`,children:[(0,F.jsx)(`img`,{src:n.image,alt:`广告`,className:`w-52 h-36 object-cover transition-transform duration-300 group-hover:scale-105 select-none`}),(0,F.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-slate-900/0 transition-colors duration-200 group-hover:bg-slate-900/30`,children:(0,F.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full bg-white/90 px-3 py-1 text-xs font-bold text-slate-800 opacity-0 transition-opacity duration-200 group-hover:opacity-100`,children:[(0,F.jsx)(y,{size:13}),`点击放大`]})}),(0,F.jsx)(`button`,{type:`button`,"aria-label":`å…³é—广告`,onClick:e=>{e.stopPropagation(),u()},className:`absolute top-1.5 right-1.5 flex h-6 w-6 items-center justify-center rounded-full bg-slate-900/60 text-white backdrop-blur-sm transition-colors hover:bg-slate-900/80 cursor-pointer`,children:(0,F.jsx)(b,{size:13,strokeWidth:2.5})})]})},`ad-minimized`)})}function L(e){return e.level1||e.level2||e.level3||``}function R({item:e,depth:t,index:n}){let r=L(e),i=e.children;return!r&&(!i||i.length===0)?null:(0,F.jsxs)(`li`,{children:[r&&(0,F.jsxs)(`div`,{className:`flex gap-2 ${t===0?`items-start`:`items-baseline`}`,children:[t===0?(0,F.jsx)(`span`,{className:`mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-50 text-[11px] font-semibold text-blue-600`,children:n+1}):(0,F.jsx)(`span`,{className:`mt-2 h-1 w-1 shrink-0 rounded-full ${t===1?`bg-slate-400`:`bg-slate-300`}`}),(0,F.jsx)(`p`,{className:t===0?`text-sm font-medium leading-6 text-slate-800`:t===1?`text-[13px] leading-5 text-slate-600`:`text-xs leading-5 text-slate-500`,children:r})]}),i&&i.length>0&&(0,F.jsx)(`ul`,{className:`mt-2 space-y-2 ${t===0?`ml-2.5 border-l border-slate-100 pl-4`:`pl-3`}`,children:i.map((e,n)=>(0,F.jsx)(R,{item:e,depth:t+1,index:n},`${t}-${n}-${L(e)}`))})]})}function z({icon:e,children:t}){return(0,F.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`flex h-6 w-6 items-center justify-center rounded-md bg-blue-50 text-blue-600`,children:e}),(0,F.jsx)(`h3`,{className:`text-sm font-semibold text-slate-800`,children:t})]})}function B({analysis:e,loading:t}){if(t)return(0,F.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-20`,children:(0,F.jsx)(g,{size:`small`,description:`åŠ è½½ä¸...`})});let n=e?.reportBrief?.trim(),r=e?.outline?.filter(e=>L(e)||e.children?.length)??[];return!n&&r.length===0?(0,F.jsx)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 px-6`,children:(0,F.jsx)(E,{image:E.PRESENTED_IMAGE_SIMPLE,description:`æš‚æ— AI 解读`,className:`m-0!`})}):(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-6 overflow-y-auto px-4 py-4`,children:[n&&(0,F.jsxs)(`section`,{children:[(0,F.jsx)(z,{icon:(0,F.jsx)(M,{className:`h-3.5 w-3.5`}),children:`文档摘è¦`}),(0,F.jsx)(`div`,{className:`rounded-xl border border-slate-100 bg-linear-to-br from-slate-50 to-white px-3.5 py-3`,children:(0,F.jsx)(`p`,{className:`text-[13px] leading-6 whitespace-pre-wrap text-slate-600`,children:n})})]}),r.length>0&&(0,F.jsxs)(`section`,{children:[(0,F.jsx)(z,{icon:(0,F.jsx)(D,{className:`h-3.5 w-3.5`}),children:`ç« èŠ‚é€Ÿè§ˆ`}),(0,F.jsx)(`div`,{className:`rounded-xl border border-slate-100 bg-white px-3.5 py-3.5`,children:(0,F.jsx)(`ul`,{className:`space-y-3.5`,children:r.map((e,t)=>(0,F.jsx)(R,{item:e,depth:0,index:t},`${t}-${L(e)}`))})})]})]})}var V=[{key:`recommend`,label:`相似推è`},{key:`ai`,label:`AI 解读`}];function H({report:e}){return(0,F.jsxs)(j,{to:`/report/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,className:`block cursor-pointer rounded-lg border border-transparent px-3 py-2.5 transition-colors hover:border-slate-200 hover:bg-slate-50`,children:[(0,F.jsx)(`p`,{className:`line-clamp-2 text-sm font-medium leading-snug text-slate-800`,children:e.title}),(0,F.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2 text-xs text-slate-400`,children:[(0,F.jsx)(`span`,{className:`shrink-0`,children:h(e.publishAt)}),e.orgName&&(0,F.jsx)(`span`,{className:`truncate`,title:e.orgName,children:e.orgName})]})]})}function U({title:e,reports:t,loading:n,emptyText:r,showMore:i,onMore:a}){return(0,F.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-slate-100 px-4 py-3`,children:[(0,F.jsx)(M,{className:`h-4 w-4 shrink-0 text-blue-600`}),(0,F.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-slate-800`,title:e,children:e}),i&&(0,F.jsxs)(`button`,{type:`button`,onClick:a,className:`flex shrink-0 cursor-pointer items-center gap-0.5 text-xs text-slate-400 transition-colors hover:text-blue-600`,children:[`更多`,(0,F.jsx)(N,{className:`h-3.5 w-3.5`})]})]}),(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 py-2`,children:[n&&(0,F.jsx)(`div`,{className:`flex items-center justify-center py-15`,children:(0,F.jsx)(g,{size:`small`,description:`åŠ è½½ä¸...`})}),!n&&t.length===0&&(0,F.jsx)(E,{image:E.PRESENTED_IMAGE_SIMPLE,description:r,className:`py-6`}),!n&&t.map(e=>(0,F.jsx)(H,{report:e},e.id))]})]})}function ce({reportId:e,orgName:t,orgIds:n,hotReports:r,orgReports:i,hotLoading:a,orgLoading:o,showAiGuide:s,aiAnalysis:c,aiLoading:l}){let u=O(),[d,f]=(0,P.useState)(`recommend`),[m,h]=(0,P.useState)(null),g=n?.[0];(0,P.useEffect)(()=>{(async()=>{try{h(await p({position:`report_detail`,orgId:g,reportId:e}))}catch(e){console.error(e)}})()},[g,e]);let _=t?`${t} 最新报告`:`åŒæœºæž„最新报告`,v=()=>{g!=null&&u(`/category-report?orgIds=${g}`)},y=e=>{e!==d&&f(e)};return(0,F.jsxs)(`aside`,{className:`flex h-full w-80 shrink-0 flex-col border-l border-slate-200 bg-white`,children:[s&&(0,F.jsx)(`div`,{className:`flex shrink-0 gap-1 border-b border-slate-200 bg-slate-50/80 px-2 pt-2`,children:V.map(e=>{let t=d===e.key;return(0,F.jsxs)(`button`,{type:`button`,onClick:()=>y(e.key),className:`relative flex flex-1 cursor-pointer items-center justify-center gap-1 rounded-t-lg py-2.5 text-sm font-medium transition-colors ${t?`bg-white text-blue-600`:`text-slate-500 hover:bg-white/60 hover:text-slate-800`}`,children:[e.key===`ai`&&(0,F.jsx)(w,{className:`h-3.5 w-3.5 ${t?`text-blue-500`:``}`}),e.label,t&&(0,F.jsx)(`span`,{className:`absolute inset-x-3 bottom-0 h-0.5 rounded-full bg-blue-600`})]},e.key)})}),d===`recommend`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(U,{title:`快速跳转`,reports:r,loading:a,emptyText:`æš‚æ— çƒé—¨ç ”报`}),(0,F.jsx)(`div`,{className:`h-px shrink-0 bg-slate-100`}),m&&(0,F.jsx)(`div`,{className:`shrink-0 border-b border-slate-100`,children:(0,F.jsx)(`img`,{src:m.image,alt:`广告`,onClick:()=>A(m),className:`w-full object-cover select-none ${m.uri?`cursor-pointer`:``}`})}),(0,F.jsx)(U,{title:_,reports:i,loading:o,emptyText:t?`æš‚æ— ${t}相关报告`:`æš‚æ— åŒæœºæž„报告`,showMore:!0,onMore:v})]}),d===`ai`&&(0,F.jsx)(B,{analysis:c,loading:l})]})}var W=4;function G(){let{id:e}=ne(),t=Number(e),n=O(),f=x(e=>e.open),{user:p}=ee(),[h,y]=(0,P.useState)(null),[b,S]=(0,P.useState)(null),[C,w]=(0,P.useState)(!0),[T,E]=(0,P.useState)(!1),[D,k]=(0,P.useState)([]),[A,M]=(0,P.useState)([]),[N,I]=(0,P.useState)(!0),[L,R]=(0,P.useState)(!1),[z,B]=(0,P.useState)(null),[V,H]=(0,P.useState)(!1),[U,G]=(0,P.useState)(null),[le,K]=(0,P.useState)(!1),q=!!U?.dictId,J=(0,P.useCallback)(async()=>{try{let[e,n]=await Promise.all([m(t),i(t,{action:`view`,format:`pdf`})]);y(e),S(n.fileUrl),E(!1)}catch(e){console.error(e)}},[t]);(0,P.useEffect)(()=>{e&&(async()=>{w(!0),E(!1),y(null),S(null),M([]),B(null),G(null),K(!1);try{let[e,n]=await Promise.all([m(t),i(t,{action:`view`,format:`pdf`})]);y(e),S(n.fileUrl),R(!!e.orgIds?.length)}catch(e){console.error(e),E(!0)}finally{w(!1)}})()},[e,t]),(0,P.useEffect)(()=>{let e=({reportId:e})=>{e===t&&J()};return d.on(`report:quotaUnlocked`,e),()=>d.off(`report:quotaUnlocked`,e)},[t,J]),(0,P.useEffect)(()=>{h?.id!=null&&(async()=>{try{await a({reportId:h.id})}catch(e){console.error(e)}})()},[h?.id]),(0,P.useEffect)(()=>{h?.id!=null&&(async()=>{try{G(await s(h.id))}catch(e){console.error(e),G(null)}})()},[h?.id]),(0,P.useEffect)(()=>{e&&(async()=>{I(!0),k([]);try{let e=await o({userId:p?.id??0,curReportId:t});k(e.filter(e=>e.id!==t))}catch(e){console.error(e),k([])}finally{I(!1)}})()},[e,t,p?.id]);let Y=h?.orgIds?.join(`,`);if((0,P.useEffect)(()=>{Y&&e&&(async()=>{M([]);try{let e=await u({orgIds:Y,page:1,limit:W,sort:`publish_at`,order:`DESC`});M(e.data.filter(e=>e.id!==t))}catch(e){console.error(e),M([])}finally{R(!1)}})()},[Y,e,t]),(0,P.useEffect)(()=>{h?.id!=null&&h.aiStatus&4&&(async()=>{H(!0),B(null);try{B(await l(h.id,{all:!0}))}catch(e){console.error(e),B(null)}finally{H(!1)}})()},[h?.id,h?.aiStatus]),C)return(0,F.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-slate-50`,children:(0,F.jsx)(g,{description:`åŠ è½½ä¸...`})});if(T||!h)return(0,F.jsxs)(`div`,{className:`flex h-screen flex-col items-center justify-center gap-4 bg-slate-50`,children:[(0,F.jsx)(`p`,{className:`text-base font-medium text-slate-600`,children:`ç ”æŠ¥åŠ è½½å¤±è´¥ï¼Œè¯·ç¨åŽé‡è¯•`}),(0,F.jsx)(j,{to:`/search`,className:`text-sm font-medium text-blue-600 hover:underline`,children:`返回æœç´¢`})]});let ue=()=>{f(`reportDownload`,{report:h})},de=()=>{n(`/profile/subscription`)},fe=()=>{if(q){n(`/favorites`);return}K(!0)},X=async e=>{try{await c(e,t),G({dictId:e}),K(!1),r.success(`æ”¶è—æˆåŠŸ`)}catch(e){console.error(e),r.error(`æ”¶è—失败,请é‡è¯•`)}},Z=`/report/${h.id}`,Q=h.orgName?`ã€${h.orgName}】${h.title}`:h.title,$=ae(h.highlight?.content?.join(` `)??``)||h.title;return(0,F.jsxs)(`div`,{className:`flex h-screen flex-col bg-slate-50`,children:[(0,F.jsx)(re,{title:Q,description:$,canonical:te(Z),noTitleSuffix:!0,jsonLd:ie({headline:Q,description:$,path:Z,datePublished:h.publishAt,image:h.indexImageUrl||void 0,breadcrumbs:[{name:`首页`,path:`/home`},{name:Q,path:Z}]})}),(0,F.jsx)(oe,{detail:h,isFavorited:q,onDownload:ue,onFavorite:fe,onSubscribe:de}),(0,F.jsxs)(`div`,{className:`mx-auto flex min-h-0 w-full max-w-7xl flex-1 px-4 py-2`,children:[(0,F.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,F.jsx)(v,{fileUrl:b})}),(0,F.jsx)(ce,{reportId:h.id,orgName:h.orgName,orgIds:h.orgIds,hotReports:D,orgReports:A,hotLoading:N,orgLoading:L,showAiGuide:!!(h.aiStatus&4),aiAnalysis:z,aiLoading:V},h.id)]}),le&&(0,F.jsx)(_,{title:`æ”¶è—`,allowManage:!0,onClose:()=>K(!1),onConfirm:X}),(0,F.jsx)(se,{})]})}export{G as default};