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-CsyI_p0I.js";import{t as h}from"./date-CTxYulDo.js";import{t as g}from"./spin-CZX9Vgqv.js";import{t as _}from"./FolderPickerModal-C7Fm4Ozo.js";import{t as v}from"./PdfViewer-CgljlNFj.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-DviMUsk6.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,ct as O,in as k,ln as A,n as j,rt as M,un as ne,ut as N}from"./index-BKbbykJJ.js";import{t as re}from"./SEO-B0qVOp3A.js";import{t as ie}from"./geo-seo-lB38yKik.js";import{t as P}from"./seo-text-Do_deNpV.js";import{t as F}from"./ReportDetailHeader-DSHRDQlo.js";var I=t(e(),1),L=n(),R=5;function ae(){let{hasActiveVipMembership:e}=T(),t=x(e=>e.open),[n,r]=(0,I.useState)(null),[i,a]=(0,I.useState)(null),[o,s]=(0,I.useState)(R),c=(0,I.useRef)(R);(0,I.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=R,s(R),a(`counting`)}catch(e){console.error(e)}})(),()=>{t=!0}},[e]),(0,I.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=()=>j(n),u=()=>a(null);return!n||i===null?null:(0,L.jsx)(C,{mode:`popLayout`,children:i===`counting`||i===`fullscreen`?(0,L.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,L.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,L.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,L.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,L.jsxs)(`div`,{className:`absolute top-4 right-4 flex items-center gap-2`,children:[(0,L.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,L.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,L.jsx)(O,{size:13}),`VIP去广告`]})]})]})]},`ad-fullscreen`):(0,L.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,L.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl shadow-[0_16px_40px_rgba(15,23,42,0.35)] border border-slate-200`,children:[(0,L.jsx)(`img`,{src:n.image,alt:`广告`,className:`w-52 h-36 object-cover transition-transform duration-300 group-hover:scale-105 select-none`}),(0,L.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,L.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,L.jsx)(y,{size:13}),`点击放大`]})}),(0,L.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,L.jsx)(b,{size:13,strokeWidth:2.5})})]})},`ad-minimized`)})}function z(e){return e.level1||e.level2||e.level3||``}function B({item:e,depth:t,index:n}){let r=z(e),i=e.children;return!r&&(!i||i.length===0)?null:(0,L.jsxs)(`li`,{children:[r&&(0,L.jsxs)(`div`,{className:`flex gap-2 ${t===0?`items-start`:`items-baseline`}`,children:[t===0?(0,L.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,L.jsx)(`span`,{className:`mt-2 h-1 w-1 shrink-0 rounded-full ${t===1?`bg-slate-400`:`bg-slate-300`}`}),(0,L.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,L.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,L.jsx)(B,{item:e,depth:t+1,index:n},`${t}-${n}-${z(e)}`))})]})}function V({icon:e,children:t}){return(0,L.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`flex h-6 w-6 items-center justify-center rounded-md bg-blue-50 text-blue-600`,children:e}),(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-slate-800`,children:t})]})}function H({analysis:e,loading:t}){if(t)return(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-20`,children:(0,L.jsx)(g,{size:`small`,description:`åŠ è½½ä¸...`})});let n=e?.reportBrief?.trim(),r=e?.outline?.filter(e=>z(e)||e.children?.length)??[];return!n&&r.length===0?(0,L.jsx)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 px-6`,children:(0,L.jsx)(E,{image:E.PRESENTED_IMAGE_SIMPLE,description:`æš‚æ— AI 解读`,className:`m-0!`})}):(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-6 overflow-y-auto px-4 py-4`,children:[n&&(0,L.jsxs)(`section`,{children:[(0,L.jsx)(V,{icon:(0,L.jsx)(M,{className:`h-3.5 w-3.5`}),children:`文档摘è¦`}),(0,L.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,L.jsx)(`p`,{className:`text-[13px] leading-6 whitespace-pre-wrap text-slate-600`,children:n})})]}),r.length>0&&(0,L.jsxs)(`section`,{children:[(0,L.jsx)(V,{icon:(0,L.jsx)(D,{className:`h-3.5 w-3.5`}),children:`ç« èŠ‚é€Ÿè§ˆ`}),(0,L.jsx)(`div`,{className:`rounded-xl border border-slate-100 bg-white px-3.5 py-3.5`,children:(0,L.jsx)(`ul`,{className:`space-y-3.5`,children:r.map((e,t)=>(0,L.jsx)(B,{item:e,depth:0,index:t},`${t}-${z(e)}`))})})]})]})}var U=[{key:`recommend`,label:`相似推è`},{key:`ai`,label:`AI 解读`}];function W({report:e}){return(0,L.jsxs)(k,{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,L.jsx)(`p`,{className:`line-clamp-2 text-sm font-medium leading-snug text-slate-800`,children:e.title}),(0,L.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2 text-xs text-slate-400`,children:[(0,L.jsx)(`span`,{className:`shrink-0`,children:h(e.publishAt)}),e.orgName&&(0,L.jsx)(`span`,{className:`truncate`,title:e.orgName,children:e.orgName})]})]})}function G({title:e,reports:t,loading:n,emptyText:r,showMore:i,onMore:a}){return(0,L.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-slate-100 px-4 py-3`,children:[(0,L.jsx)(M,{className:`h-4 w-4 shrink-0 text-blue-600`}),(0,L.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-slate-800`,title:e,children:e}),i&&(0,L.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,L.jsx)(N,{className:`h-3.5 w-3.5`})]})]}),(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 py-2`,children:[n&&(0,L.jsx)(`div`,{className:`flex items-center justify-center py-15`,children:(0,L.jsx)(g,{size:`small`,description:`åŠ è½½ä¸...`})}),!n&&t.length===0&&(0,L.jsx)(E,{image:E.PRESENTED_IMAGE_SIMPLE,description:r,className:`py-6`}),!n&&t.map(e=>(0,L.jsx)(W,{report:e},e.id))]})]})}function oe({reportId:e,orgName:t,orgIds:n,hotReports:r,orgReports:i,hotLoading:a,orgLoading:o,showAiGuide:s,aiAnalysis:c,aiLoading:l}){let u=A(),[d,f]=(0,I.useState)(`recommend`),[m,h]=(0,I.useState)(null),g=n?.[0];(0,I.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,L.jsxs)(`aside`,{className:`flex h-full w-80 shrink-0 flex-col border-l border-slate-200 bg-white`,children:[s&&(0,L.jsx)(`div`,{className:`flex shrink-0 gap-1 border-b border-slate-200 bg-slate-50/80 px-2 pt-2`,children:U.map(e=>{let t=d===e.key;return(0,L.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,L.jsx)(w,{className:`h-3.5 w-3.5 ${t?`text-blue-500`:``}`}),e.label,t&&(0,L.jsx)(`span`,{className:`absolute inset-x-3 bottom-0 h-0.5 rounded-full bg-blue-600`})]},e.key)})}),d===`recommend`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(G,{title:`快速跳转`,reports:r,loading:a,emptyText:`æš‚æ— çƒé—¨ç ”报`}),(0,L.jsx)(`div`,{className:`h-px shrink-0 bg-slate-100`}),m&&(0,L.jsx)(`div`,{className:`shrink-0 border-b border-slate-100`,children:(0,L.jsx)(`img`,{src:m.image,alt:`广告`,onClick:()=>j(m),className:`w-full object-cover select-none ${m.uri?`cursor-pointer`:``}`})}),(0,L.jsx)(G,{title:_,reports:i,loading:o,emptyText:t?`æš‚æ— ${t}相关报告`:`æš‚æ— åŒæœºæž„报告`,showMore:!0,onMore:v})]}),d===`ai`&&(0,L.jsx)(H,{analysis:c,loading:l})]})}var se=4;function K(){let{id:e}=ne(),t=Number(e),n=A(),f=x(e=>e.open),{user:p}=ee(),[h,y]=(0,I.useState)(null),[b,S]=(0,I.useState)(null),[C,w]=(0,I.useState)(!0),[T,E]=(0,I.useState)(!1),[D,O]=(0,I.useState)([]),[j,M]=(0,I.useState)([]),[N,R]=(0,I.useState)(!0),[z,B]=(0,I.useState)(!1),[V,H]=(0,I.useState)(null),[U,W]=(0,I.useState)(!1),[G,K]=(0,I.useState)(null),[ce,q]=(0,I.useState)(!1),J=!!G?.dictId,Y=(0,I.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,I.useEffect)(()=>{e&&(async()=>{w(!0),E(!1),y(null),S(null),M([]),H(null),K(null),q(!1);try{let[e,n]=await Promise.all([m(t),i(t,{action:`view`,format:`pdf`})]);y(e),S(n.fileUrl),B(!!e.orgIds?.length)}catch(e){console.error(e),E(!0)}finally{w(!1)}})()},[e,t]),(0,I.useEffect)(()=>{let e=({reportId:e})=>{e===t&&Y()};return d.on(`report:quotaUnlocked`,e),()=>d.off(`report:quotaUnlocked`,e)},[t,Y]),(0,I.useEffect)(()=>{h?.id!=null&&(async()=>{try{await a({reportId:h.id})}catch(e){console.error(e)}})()},[h?.id]),(0,I.useEffect)(()=>{h?.id!=null&&(async()=>{try{K(await s(h.id))}catch(e){console.error(e),K(null)}})()},[h?.id]),(0,I.useEffect)(()=>{e&&(async()=>{R(!0),O([]);try{let e=await o({userId:p?.id??0,curReportId:t});O(e.filter(e=>e.id!==t))}catch(e){console.error(e),O([])}finally{R(!1)}})()},[e,t,p?.id]);let X=h?.orgIds?.join(`,`);if((0,I.useEffect)(()=>{X&&e&&(async()=>{M([]);try{let e=await u({orgIds:X,page:1,limit:se,sort:`publish_at`,order:`DESC`});M(e.data.filter(e=>e.id!==t))}catch(e){console.error(e),M([])}finally{B(!1)}})()},[X,e,t]),(0,I.useEffect)(()=>{h?.id!=null&&h.aiStatus&4&&(async()=>{W(!0),H(null);try{H(await l(h.id,{all:!0}))}catch(e){console.error(e),H(null)}finally{W(!1)}})()},[h?.id,h?.aiStatus]),C)return(0,L.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-slate-50`,children:(0,L.jsx)(g,{description:`åŠ è½½ä¸...`})});if(T||!h)return(0,L.jsxs)(`div`,{className:`flex h-screen flex-col items-center justify-center gap-4 bg-slate-50`,children:[(0,L.jsx)(`p`,{className:`text-base font-medium text-slate-600`,children:`ç ”æŠ¥åŠ è½½å¤±è´¥ï¼Œè¯·ç¨åŽé‡è¯•`}),(0,L.jsx)(k,{to:`/search`,className:`text-sm font-medium text-blue-600 hover:underline`,children:`返回æœç´¢`})]});let le=()=>{f(`reportDownload`,{report:h})},ue=()=>{n(`/profile/subscription`)},de=()=>{if(J){n(`/favorites`);return}q(!0)},fe=async e=>{try{await c(e,t),K({dictId:e}),q(!1),r.success(`æ”¶è—æˆåŠŸ`)}catch(e){console.error(e),r.error(`æ”¶è—失败,请é‡è¯•`)}},Z=`/report/${h.id}`,Q=h.orgName?`ã€${h.orgName}】${h.title}`:h.title,$=P(h.highlight?.content?.join(` `)??``)||h.title;return(0,L.jsxs)(`div`,{className:`flex h-screen flex-col bg-slate-50`,children:[(0,L.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,L.jsx)(F,{detail:h,isFavorited:J,onDownload:le,onFavorite:de,onSubscribe:ue}),(0,L.jsxs)(`div`,{className:`mx-auto flex min-h-0 w-full max-w-7xl flex-1 px-4 py-2`,children:[(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(v,{fileUrl:b})}),(0,L.jsx)(oe,{reportId:h.id,orgName:h.orgName,orgIds:h.orgIds,hotReports:D,orgReports:j,hotLoading:N,orgLoading:z,showAiGuide:!!(h.aiStatus&4),aiAnalysis:V,aiLoading:U},h.id)]}),ce&&(0,L.jsx)(_,{title:`æ”¶è—`,allowManage:!0,onClose:()=>q(!1),onConfirm:fe}),(0,L.jsx)(ae,{})]})}export{K as default};