@gientech/modual 2.3.14 → 2.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,176 @@
1
+ import{jsxs as p,jsx as c,Fragment as Du}from"react/jsx-runtime";import zu,{useState as x,useRef as S,useEffect as eu,useCallback as d,useMemo as Tu}from"react";import M from"styled-components";import du from"axios";import{parseFile as mu,Fviewer as iu}from"@mxmweb/fviewer";import{c as K}from"./createLucideIcon-Bj5DlX2s.js";import{X as ue}from"./x-CdZQbi--.js";/**
2
+ * @license lucide-react v0.456.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const ee=K("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
7
+ * @license lucide-react v0.456.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const oe=K("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
12
+ * @license lucide-react v0.456.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const te=K("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
17
+ * @license lucide-react v0.456.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const ne=K("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
22
+ * @license lucide-react v0.456.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const re=K("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
27
+ * @license lucide-react v0.456.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const ae=K("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/**
32
+ * @license lucide-react v0.456.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const ce=K("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/**
37
+ * @license lucide-react v0.456.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const se=K("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),le=M.div`
42
+ display: flex;
43
+ align-items: center;
44
+ padding: 0px 12px;
45
+ justify-content: space-between;
46
+ padding: ${t=>t.$theme.space.padding};
47
+ border-bottom: 1px solid ${t=>t.$theme.colors.border};
48
+ background: ${t=>t.$theme.colors.background};
49
+ min-height: 52px;
50
+ `,de=M.div`
51
+ display: flex;
52
+ align-items: center;
53
+ gap: 8px;
54
+ flex: 1;
55
+ min-width: 0;
56
+ `,ie=M.div`
57
+ font-size: 14px;
58
+ font-weight: 500;
59
+ color: ${t=>t.$theme.colors.text};
60
+ white-space: nowrap;
61
+ overflow: hidden;
62
+ text-overflow: ellipsis;
63
+ `,Fe=M.div`
64
+ font-size: 12px;
65
+ color: ${t=>t.$theme.colors.disabledText};
66
+ white-space: nowrap;
67
+ `,he=M.div`
68
+ display: flex;
69
+ align-items: center;
70
+ gap: 4px;
71
+ `,j=M.button`
72
+ display: flex;
73
+ align-items: center;
74
+ justify-content: center;
75
+ width: 32px;
76
+ height: 32px;
77
+ border: none;
78
+ border-radius: ${t=>t.$theme.space.radius};
79
+ background: ${t=>t.$active?t.$theme.colors.primary+"20":"transparent"};
80
+ color: ${t=>t.$active?t.$theme.colors.primary:t.$theme.colors.text};
81
+ cursor: pointer;
82
+ transition: all 0.2s ease;
83
+
84
+ &:hover {
85
+ background: ${t=>t.$theme.colors.primary+"10"};
86
+ color: ${t=>t.$theme.colors.primary};
87
+ }
88
+
89
+ &:disabled {
90
+ opacity: 0.5;
91
+ cursor: not-allowed;
92
+ }
93
+ `,ge=M.div`
94
+ font-size: 12px;
95
+ color: ${t=>t.$theme.colors.disabledText};
96
+ min-width: 40px;
97
+ text-align: center;
98
+ `,De={colors:{primary:"#007bff",secondary:"#6c757d",success:"#008000",warning:"#FFA500",error:"#FF0000",info:"#0000FF",background:"#f8f9fa",text:"#343a40",border:"#dee2e6",disabled:"#808080",disabledBackground:"#F5F5F5",disabledText:"#808080"},space:{sidebar:"md",size:"md",radius:"md",padding:"md",margin:"md",shadow:"md",lineHeight:"md"}},Lu=zu.memo(({fileName:t="\u672A\u77E5\u6587\u4EF6",currentPage:l=1,totalPage:o=0,tools:D={annotation:!0,download:!0,zoom:!0,close:!0,navigation:!0,rotate:!0},styles:A,onPrevPage:ou,onNextPage:g,onZoomIn:U,onZoomOut:m,onAnnotationToggle:P,onDownload:h,onRotateLeft:s,onRotateRight:N,onClose:$,scale:B=1,isAnnotating:W=!1,className:tu})=>{const i=(A==null?void 0:A.theme)||De;return console.log("Header\u7EC4\u4EF6\u6E32\u67D3 - currentPage:",l,"totalPage:",o),p(le,{$theme:i,className:tu,children:[c(de,{$theme:i,children:c(ie,{$theme:i,children:t})}),p(he,{$theme:i,children:[D.navigation&&p(Du,{children:[c(j,{$theme:i,onClick:ou,disabled:l<=1,title:"\u4E0A\u4E00\u9875",children:c(ee,{size:16})}),o>0&&p(Fe,{$theme:i,children:[l," / ",o]}),c(j,{$theme:i,onClick:g,disabled:!o||l>=o,title:"\u4E0B\u4E00\u9875",children:c(oe,{size:16})})]}),D.zoom&&p(Du,{children:[c(j,{$theme:i,onClick:m,disabled:B<=.3,title:"\u7F29\u5C0F",children:c(se,{size:16})}),p(ge,{$theme:i,children:[Math.round(B*100),"%"]}),c(j,{$theme:i,onClick:U,disabled:B>=3,title:"\u653E\u5927",children:c(ce,{size:16})})]}),D.annotation&&c(j,{$theme:i,$active:W,onClick:P,title:W?"\u9000\u51FA\u6807\u6CE8":"\u5F00\u59CB\u6807\u6CE8",children:c(ne,{size:16})}),D.download&&c(j,{$theme:i,onClick:h,title:"\u4E0B\u8F7D",children:c(te,{size:16})}),D.rotate&&p(Du,{children:[c(j,{$theme:i,onClick:s,title:"\u5411\u5DE6\u65CB\u8F6C",children:c(re,{size:16})}),c(j,{$theme:i,onClick:N,title:"\u5411\u53F3\u65CB\u8F6C",children:c(ae,{size:16})})]}),D.close&&c(j,{$theme:i,onClick:$,title:"\u5173\u95ED",children:c(ue,{size:16})})]})]})}),fu=M.div`
99
+ display: flex;
100
+ flex-direction: column;
101
+ height: 100%;
102
+ width: 100%;
103
+ background: ${t=>t.$theme.colors.background};
104
+ border: 1px solid ${t=>t.$theme.colors.border};
105
+ border-radius: ${t=>t.$theme.space.radius};
106
+ overflow: hidden;
107
+ min-height: 0;
108
+ position: relative; // 添加相对定位,用于loading遮罩的绝对定位
109
+
110
+ /* 添加动画样式 */
111
+ @keyframes spin {
112
+ 0% {
113
+ transform: rotate(0deg);
114
+ }
115
+ 100% {
116
+ transform: rotate(360deg);
117
+ }
118
+ }
119
+ `,me=({status:t,theme:l})=>p("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"40px",background:l.colors.background},children:[p("div",{style:{position:"relative",width:"80px",height:"80px",marginBottom:"24px"},children:[c("div",{style:{width:"60px",height:"80px",background:l.colors.primary,borderRadius:"8px 8px 0 0",position:"relative",margin:"0 auto"},children:c("div",{style:{position:"absolute",top:"0",right:"0",width:"0",height:"0",borderStyle:"solid",borderWidth:"0 20px 20px 0",borderColor:`transparent ${l.colors.background} transparent transparent`}})}),c("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"20px",height:"20px",borderRadius:"50%",background:l.colors.background,animation:"pulse 1.5s ease-in-out infinite"}})]}),c("div",{style:{fontSize:"16px",fontWeight:"500",color:l.colors.text,marginBottom:"8px",textAlign:"center"},children:t}),c("div",{style:{width:"200px",height:"4px",background:l.colors.border,borderRadius:"2px",overflow:"hidden",position:"relative"},children:c("div",{style:{width:"30%",height:"100%",background:l.colors.primary,borderRadius:"2px",animation:"loading-progress 2s ease-in-out infinite"}})}),c("style",{children:`
120
+ @keyframes pulse {
121
+ 0%, 100% {
122
+ opacity: 1;
123
+ transform: translate(-50%, -50%) scale(1);
124
+ }
125
+ 50% {
126
+ opacity: 0.5;
127
+ transform: translate(-50%, -50%) scale(1.1);
128
+ }
129
+ }
130
+
131
+ @keyframes loading-progress {
132
+ 0% {
133
+ transform: translateX(-100%);
134
+ }
135
+ 50% {
136
+ transform: translateX(0%);
137
+ }
138
+ 100% {
139
+ transform: translateX(100%);
140
+ }
141
+ }
142
+ `})]}),fe=M.div`
143
+ display: flex;
144
+ flex-direction: column;
145
+ align-items: center;
146
+ justify-content: center;
147
+ height: 100%;
148
+ color: ${t=>t.$theme.colors.error};
149
+ text-align: center;
150
+ padding: 20px;
151
+ `,Ce="http://10.15.12.13:9005/proxy/index/knowledgeBase/file/stream",b=300*1e3,Be={colors:{primary:"#007bff",secondary:"#6c757d",success:"#008000",warning:"#FFA500",error:"#FF0000",info:"#0000FF",background:"#f8f9fa",text:"#343a40",border:"#dee2e6",disabled:"#808080",disabledBackground:"#F5F5F5",disabledText:"#808080"},space:{sidebar:"12px",size:"12px",radius:"4px",padding:"8px 12px",margin:"4px",shadow:"0 2px 4px rgba(0,0,0,0.1)",lineHeight:"1.5"}};function Su(t){const l=new TextDecoder("utf-8",{fatal:!1}).decode(t),o=(l.match(/\uFFFD/g)||[]).length;if(o===0||l.length<20)return l;try{const D=new TextDecoder("gb18030",{fatal:!1}).decode(t);return(D.match(/\uFFFD/g)||[]).length<o?D:l}catch{return l}}const Re=({convertedFilePath:t,fileName:l,fileType:o,csrfToken:D,initialPage:A=1,initialZoom:ou=1,totalPages:g,annotations:U=[],pageSize:m=5,streamApiUrl:P=Ce,authorization:h,eventsEmit:s=()=>{},tools:N,styles:$,customComponents:B,className:W,headerClass:tu,contentClass:i})=>{const[nu,f]=x(!0),[Cu,C]=x("\u6B63\u5728\u52A0\u8F7D\u6587\u6863..."),[ru,I]=x(null),[R,X]=x(A),[w,Y]=x(g||0),[y,Bu]=x(ou),[z,Fu]=x(0),[Ku,wu]=x(null),[Eu,ku]=x(null),[q,xu]=x(""),[pu,au]=x(null),[$u,bu]=x(null),[hu,cu]=x({}),J=S(!1),T=S(!1),Q=S({}),_=S({}),V=S(null),Xu=S(null),Z=S(A),Au=S(0);Au.current+=1,console.log("[GientechStreamReader] render count:",Au.current),console.log("[GientechStreamReader] props snapshot (early):",{fileType:o,currentPage:R,totalPages:w,hasMarkdown:!!q,hasImage:!!Eu,hasText:!!pu,hasHtml:!!$u,isLoading:nu,error:ru});const G=($==null?void 0:$.theme)||Be;eu(()=>{J.current=!1,T.current=!1},[o,t]);const H=d(()=>{const u={annotation:!0,download:!0,zoom:!0,close:!0,navigation:!0,rotate:!1};let e;switch(o){case"pdf":case"pdf_slides":e={...u,annotation:!1,download:!1,navigation:!0,rotate:!1};break;case"image":e={...u,annotation:!1,download:!1,navigation:!1,rotate:!0,zoom:!0};break;case"markdown":case"markdown_table":e={...u,annotation:!1,download:!1,navigation:!1,rotate:!1,zoom:!1};break;case"text":case"html":case"unknown":e={...u,annotation:!1,download:!1,navigation:!1,rotate:!1,zoom:!1};break;default:e=u}return N?{...e,...N}:e},[o,N])(),L=d((u,e)=>{const r=Math.floor((u-1)/e)*e+1;return`${r}-${r+e-1}`},[]),Pu=d(async u=>{var E;if(!(o==="pdf"||o==="pdf_slides"))return console.log(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u662FPDF\uFF0C\u8DF3\u8FC7\u7F13\u5B58\u68C0\u67E5`),null;console.log(`\u68C0\u67E5\u9875\u9762 ${u} \u662F\u5426\u5728\u7F13\u5B58\u4E2D`);const r=Q.current[u];if(r&&Date.now()-r.timestamp<b)return console.log(`\u4F7F\u7528\u5355\u4E2A\u9875\u9762\u7F13\u5B58: ${u}`),r.pdfDocument?(console.log(`\u76F4\u63A5\u8FD4\u56DE\u7F13\u5B58\u7684PDF\u6587\u6863: ${u}`),r.pdfDocument):null;const n=L(u,m),a=_.current[n];if(console.log(`\u68C0\u67E5chunk\u7F13\u5B58: ${n}, \u5B58\u5728: ${!!a}, \u5305\u542B\u9875\u9762: ${((E=a==null?void 0:a.pages)==null?void 0:E.join(", "))||"\u65E0"}`),a&&Date.now()-a.timestamp<b){if(a.pages.includes(u))return console.log(`\u4F7F\u7528chunk\u7F13\u5B58: ${u} (chunk: ${n})`),a.pdfDocument?(console.log(`\u76F4\u63A5\u8FD4\u56DE\u7F13\u5B58\u7684PDF\u6587\u6863: ${u}`),a.pdfDocument):null;console.log(`\u9875\u9762 ${u} \u4E0D\u5728chunk ${n} \u4E2D\uFF0Cchunk\u5305\u542B: ${a.pages.join(", ")}`)}return console.log(`\u9875\u9762 ${u} \u4E0D\u5728\u4EFB\u4F55\u7F13\u5B58\u4E2D\uFF0C\u9700\u8981\u91CD\u65B0\u8BF7\u6C42`),null},[m,L,o]),Ru=d(async u=>{var e;try{if(!(o==="pdf"||o==="pdf_slides"))throw console.log(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u9700\u8981\u5206\u9875\u53C2\u6570\uFF0C\u83B7\u53D6\u5B8C\u6574\u5185\u5BB9`),new Error(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u652F\u6301\u5206\u9875\u52A0\u8F7D`);const n=Math.floor((u-1)/m)*m+1,a=L(u,m);console.log(`\u8BF7\u6C42PDF chunk\u6570\u636E: ${n} (\u5305\u542B\u9875\u9762 ${n}-${n+m-1})`);const E={"Content-Type":"application/json"};h&&(E.Authorization=h),D&&(E["X-CSRF-TOKEN-IN"]=D);const k={convertedFilePath:t,pageNo:n,pageSize:m},F=await du.post(P,k,{headers:E,responseType:"arraybuffer"}),O=F.headers["x-csrf-token-out"]||F.headers["X-CSRF-TOKEN-OUT"];O&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",O),s("request_finish",O));const uu=Array.from({length:m},(Ee,Nu)=>n+Nu);return _.current[a]={data:F.data,pages:uu,timestamp:Date.now(),totalPages:g},console.log(`\u7F13\u5B58PDF chunk\u6570\u636E: ${a}, \u5305\u542B\u9875\u9762: ${uu.join(", ")}, \u8BF7\u6C42\u7684\u9875\u9762: ${u}`),console.log("\u5F53\u524D\u6240\u6709\u7F13\u5B58:",Object.keys(_.current)),F.data}catch(r){throw console.error("\u83B7\u53D6PDF stream\u6570\u636E\u5931\u8D25:",r),new Error(`PDF\u8BF7\u6C42\u5931\u8D25: ${((e=r.response)==null?void 0:e.status)||"\u7F51\u7EDC\u9519\u8BEF"}`)}},[P,t,m,h,L,g,w,o,s]),gu=d(async(u,e=!1)=>{var n;if(!u)return;if(!(o==="pdf"||o==="pdf_slides"))return console.log(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u662FPDF\uFF0C\u8DF3\u8FC7PDF\u52A0\u8F7D\u903B\u8F91`),null;try{e?(f(!0),C("\u6B63\u5728\u52A0\u8F7DPDF\u6587\u6863...")):(f(!0),C(`\u6B63\u5728\u52A0\u8F7D\u7B2C ${u} \u9875...`)),I(null),console.log(`\u5F00\u59CB\u52A0\u8F7DPDF\u9875\u9762: ${u}, \u521D\u59CB\u52A0\u8F7D: ${e}`);const a=await Pu(u);if(a)return console.log(`\u4F7F\u7528\u7F13\u5B58\u7684PDF\u6587\u6863: ${u}`),wu(a),f(!1),C(""),console.log(`\u9875\u9762 ${u} \u52A0\u8F7D\u5B8C\u6210\uFF08\u4F7F\u7528\u7F13\u5B58\uFF09`),a;const E=await Ru(u),k=await mu(E,{fileName:l||"Stream\u6587\u6863",fileType:"pdf",token:h});if(k.error)throw new Error(k.error);if(k.type!=="pdf"||!((n=k.content)!=null&&n.document))throw new Error("\u89E3\u6790\u7ED3\u679C\u4E0D\u662F\u6709\u6548\u7684PDF\u6587\u6863");const F=k.content.document;console.log("\u8BBE\u7F6EPDF\u6587\u6863:",F),console.log("PDF\u6587\u6863\u7C7B\u578B:",typeof F),console.log("PDF\u6587\u6863\u65B9\u6CD5:",F?Object.getOwnPropertyNames(Object.getPrototypeOf(F)):"\u65E0\u6587\u6863"),console.log("PDF\u6587\u6863\u9875\u6570:",F?F.numPages:"\u65E0\u9875\u6570"),console.log("\u5F53\u524D\u8BF7\u6C42\u7684\u9875\u9762:",u),console.log("PDF\u6587\u6863\u5305\u542B\u7684\u9875\u9762\u8303\u56F4:",F?`1-${F.numPages}`:"\u65E0\u9875\u6570"),wu(F);const O=L(u,m);if(_.current[O]&&(_.current[O].pdfDocument=F,console.log(`\u7F13\u5B58PDF\u6587\u6863\u5230chunk: ${O}`)),g)console.log(`\u4F7F\u7528\u7528\u6237\u4F20\u5165\u7684\u603B\u9875\u6570: ${g}`),Y(g);else if(F&&F.numPages){const uu=F.numPages;console.log(`\u7528\u6237\u672A\u4F20\u5165\u603B\u9875\u6570\uFF0C\u4ECEPDF\u6587\u6863\u83B7\u53D6\u5B9E\u9645\u603B\u9875\u6570: ${uu}`),Y(uu)}return f(!1),C(""),console.log(`\u9875\u9762 ${u} \u52A0\u8F7D\u5B8C\u6210`),F}catch(a){throw console.error("PDF\u52A0\u8F7D\u5931\u8D25:",a),I(a.message||"PDF\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),C(""),a}},[Ru,l,h,w,Pu,L,m,o]),yu=d(u=>{if(!(o==="pdf"||o==="pdf_slides"))return!1;const r=Q.current[u];if(r&&Date.now()-r.timestamp<b)return!!r.pdfDocument;const n=L(u,m),a=_.current[n];return a&&Date.now()-a.timestamp<b?a.pages.includes(u)&&!!a.pdfDocument:!1},[m,L,o]),_u=d(()=>{console.log("\u68C0\u67E5markdown\u5185\u5BB9\u662F\u5426\u5728\u7F13\u5B58\u4E2D");const u=V.current;return u&&Date.now()-u.timestamp<b?(console.log("\u4F7F\u7528markdown\u5185\u5BB9\u7F13\u5B58"),u.data):(console.log("markdown\u5185\u5BB9\u4E0D\u5728\u7F13\u5B58\u4E2D\uFF0C\u9700\u8981\u91CD\u65B0\u8BF7\u6C42"),null)},[]),vu=d(async()=>{var u;try{console.log("\u8BF7\u6C42\u5B8C\u6574markdown\u6570\u636E");const e={"Content-Type":"application/json"};h&&(e.Authorization=h),D&&(e["X-CSRF-TOKEN-IN"]=D);const r={convertedFilePath:t};console.log("\u53D1\u9001markdown\u8BF7\u6C42:",r);const n=await du.post(P,r,{headers:e,responseType:"text"}),a=n.headers["x-csrf-token-out"]||n.headers["X-CSRF-TOKEN-OUT"];return a&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",a),s("request_finish",a)),console.log("markdown\u54CD\u5E94\u72B6\u6001:",n.status),console.log("markdown\u54CD\u5E94\u6570\u636E\u957F\u5EA6:",((u=n.data)==null?void 0:u.length)||0),n.data}catch(e){throw console.error("\u83B7\u53D6markdown\u6570\u636E\u5931\u8D25:",e),new Error(`\u83B7\u53D6markdown\u6570\u636E\u5931\u8D25: ${e.message}`)}},[t,h,P,s]),qu=d(async()=>{try{f(!0),C("\u6B63\u5728\u52A0\u8F7Dmarkdown\u6587\u6863..."),I(null),console.log("\u5F00\u59CB\u52A0\u8F7D\u5B8C\u6574markdown\u6587\u6863");const u=_u();if(u)return console.log("\u4F7F\u7528\u7F13\u5B58\u7684markdown\u5185\u5BB9"),xu(u),f(!1),C(""),u;const e=await vu();return V.current={data:e,timestamp:Date.now()},xu(e),f(!1),C(""),console.log("\u5B8C\u6574markdown\u6587\u6863\u52A0\u8F7D\u5B8C\u6210"),e}catch(u){throw console.error("markdown\u52A0\u8F7D\u5931\u8D25:",u),I(u.message||"markdown\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),C(""),u}},[vu,_u]),Iu=d(async()=>{try{const u={"Content-Type":"application/json"};h&&(u.Authorization=h),D&&(u["X-CSRF-TOKEN-IN"]=D);const e={convertedFilePath:t},r=await du.post(P,e,{headers:u,responseType:"arraybuffer"}),n=r.headers["x-csrf-token-out"]||r.headers["X-CSRF-TOKEN-OUT"];return n&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",n),s("request_finish",n)),r.data}catch(u){throw console.error("\u83B7\u53D6\u56FE\u7247\u6570\u636E\u5931\u8D25:",u),new Error(`\u83B7\u53D6\u56FE\u7247\u6570\u636E\u5931\u8D25: ${u.message}`)}},[t,h,P,s]),Zu=d(async()=>{try{f(!0),C("\u6B63\u5728\u52A0\u8F7D\u56FE\u7247..."),I(null);const u=await Iu(),e=await mu(u,{fileName:l||"\u56FE\u7247",fileType:"image",token:h});if(e.error)throw new Error(e.error);if(e.type!=="image"||!e.content)throw new Error("\u89E3\u6790\u7ED3\u679C\u4E0D\u662F\u6709\u6548\u7684\u56FE\u7247");return ku(e.content),f(!1),C(""),e.content}catch(u){throw console.error("\u56FE\u7247\u52A0\u8F7D\u5931\u8D25:",u),I(u.message||"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),C(""),u}},[h,l,Iu]),Ou=d(async()=>{var u;try{console.log(`\u8BF7\u6C42\u901A\u7528\u6587\u4EF6\u6570\u636E\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`);const e={"Content-Type":"application/json"};h&&(e.Authorization=h),D&&(e["X-CSRF-TOKEN-IN"]=D);const r={convertedFilePath:t};console.log("\u53D1\u9001\u901A\u7528\u6587\u4EF6\u8BF7\u6C42:",r);const n=await du.post(P,r,{headers:e,responseType:"arraybuffer"}),a=n.headers["x-csrf-token-out"]||n.headers["X-CSRF-TOKEN-OUT"];return a&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",a),s("request_finish",a)),console.log("\u901A\u7528\u6587\u4EF6\u54CD\u5E94\u72B6\u6001:",n.status),console.log("\u901A\u7528\u6587\u4EF6\u54CD\u5E94\u6570\u636E\u957F\u5EA6:",((u=n.data)==null?void 0:u.byteLength)||0),n.data}catch(e){throw console.error("\u83B7\u53D6\u901A\u7528\u6587\u4EF6\u6570\u636E\u5931\u8D25:",e),new Error(`\u83B7\u53D6\u901A\u7528\u6587\u4EF6\u6570\u636E\u5931\u8D25: ${e.message}`)}},[t,h,P,s]),Gu=d(async()=>{try{if(console.log("=== loadGenericDocument \u88AB\u8C03\u7528 ==="),console.log("\u8C03\u7528\u6808:",new Error().stack),console.log("\u5F53\u524D\u65F6\u95F4:",new Date().toISOString()),J.current){console.log(`\u901A\u7528\u6587\u6863\u6B63\u5728\u52A0\u8F7D\u4E2D\uFF0C\u5FFD\u7565\u91CD\u590D\u8BF7\u6C42\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`);return}if(T.current){console.log(`\u901A\u7528\u6587\u6863\u5DF2\u7ECF\u52A0\u8F7D\u8FC7\uFF0C\u5FFD\u7565\u91CD\u590D\u8BF7\u6C42\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`);return}const u=`${o}_${t}`,e=hu[u];if(console.log(`\u68C0\u67E5\u901A\u7528\u6587\u6863\u7F13\u5B58\uFF0Ckey: ${u}, \u7F13\u5B58\u5B58\u5728: ${!!e}, \u7F13\u5B58\u65F6\u95F4: ${e?Date.now()-e.timestamp:"N/A"}ms`),e&&Date.now()-e.timestamp<b)return console.log(`\u4F7F\u7528\u7F13\u5B58\u7684\u901A\u7528\u6587\u6863\u5185\u5BB9\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`),o==="text"&&e.content?au(e.content):o==="html"&&e.content&&bu(e.content),X(1),Y(g||1),f(!1),C(""),e.content;J.current=!0,f(!0),C(`\u6B63\u5728\u52A0\u8F7D${o}\u6587\u6863...`),I(null),console.log(`\u5F00\u59CB\u52A0\u8F7D\u901A\u7528\u6587\u6863\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`);const r=await Ou();if(o==="text"){const k={type:"text",content:Su(r)};au(k);const F=`text_${t}`;return cu(O=>({...O,[F]:{content:k,timestamp:Date.now()}})),f(!1),C(""),J.current=!1,T.current=!0,console.log(`\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5B8C\u6210\uFF08text \u76F4\u89E3\uFF09\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`),k}const n=await mu(r,{fileName:l||`${o}\u6587\u6863`,fileType:o,token:h});if(n.error)throw new Error(n.error);let a=null;if(n.type==="text"&&n.content)au(n.content),a=n.content;else if(n.type==="html"&&n.content)bu(n.content),a=n.content;else if(n.type==="image"&&n.content)ku(n.content),a=n.content;else{const E=Su(r);au({type:"text",content:E}),a={type:"text",content:E}}if(a){const E=`${o}_${t}`,k={...hu,[E]:{content:a,timestamp:Date.now()}};cu(k),console.log(`\u901A\u7528\u6587\u6863\u5185\u5BB9\u5DF2\u7F13\u5B58\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}, \u7F13\u5B58\u952E: ${E}`),console.log("\u5F53\u524D\u7F13\u5B58\u72B6\u6001:",k)}return f(!1),C(""),J.current=!1,T.current=!0,console.log(`\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5B8C\u6210\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`),n}catch(u){throw console.error("\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5931\u8D25:",u),I(u.message||"\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),C(""),J.current=!1,T.current=!0,u}},[Ou,l,h,o,t,hu,g]),su=d(async u=>{if(u===Z.current)return;if(nu){console.log("\u9875\u9762\u6B63\u5728\u52A0\u8F7D\u4E2D\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42");return}if(!(o==="pdf"||o==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}console.log("PDF\u9875\u9762\u53D8\u5316:",u,"\u5F53\u524D\u9875:",Z.current),console.log(`\u9875\u9762 ${u} \u662F\u5426\u5728\u7F13\u5B58\u4E2D:`,yu(u)),Z.current=u,X(u);try{await gu(u,!1),s("pageChange",{pageNumber:u,totalPages:g||w})}catch(r){console.error("PDF\u9875\u9762\u52A0\u8F7D\u5931\u8D25:",r);const n=Z.current;X(n)}},[gu,w,s,yu,nu,o]);eu(()=>{Z.current=R,console.log("\u5F53\u524D\u9875\u72B6\u6001\u66F4\u65B0:",R)},[R]);const lu=d(u=>{Bu(u),s("zoomChange",{scale:u})},[s]),ju=d(()=>{s("viewer:close")},[s]),Hu=d(()=>{const u=Math.min(3,y+.1);lu(u)},[y,lu]),Uu=d(()=>{const u=Math.max(.3,y-.1);lu(u)},[y,lu]),Wu=d(()=>{const u=(z-90+360)%360;Fu(u),s("rotateChange",{rotation:u})},[z,s]),Yu=d(()=>{const u=(z+90)%360;Fu(u),s("rotateChange",{rotation:u})},[z,s]),Ju=d(()=>{if(!(o==="pdf"||o==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}const e=Z.current-1;e>=1&&su(e)},[su,o]),Qu=d(()=>{if(!(o==="pdf"||o==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}const e=Z.current+1,r=g||w;r&&e<=r&&su(e)},[w,su,o]),Mu=d(()=>{const u=Date.now();Object.keys(Q.current).forEach(e=>{const r=Q.current[parseInt(e)];u-r.timestamp>b&&(delete Q.current[parseInt(e)],console.log(`\u6E05\u7406\u8FC7\u671F\u9875\u9762\u7F13\u5B58: ${e}`))}),Object.keys(_.current).forEach(e=>{const r=_.current[e];u-r.timestamp>b&&(delete _.current[e],console.log(`\u6E05\u7406\u8FC7\u671Fchunk\u7F13\u5B58: ${e}`))}),V.current&&u-V.current.timestamp>b&&(V.current=null,console.log("\u6E05\u7406\u8FC7\u671Fmarkdown\u5185\u5BB9\u7F13\u5B58")),cu(e=>{const r={...e};return Object.keys(r).forEach(n=>{u-r[n].timestamp>b&&(delete r[n],console.log(`\u6E05\u7406\u8FC7\u671F\u901A\u7528\u6587\u4EF6\u7F13\u5B58: ${n}`))}),r})},[]),v=d(()=>{if(l)return l;try{const u=new URL(t);return decodeURIComponent(u.pathname.split("/").pop()||"")||"Stream\u6587\u6863"}catch{const u=t.split("/");return decodeURIComponent(u[u.length-1])||"Stream\u6587\u6863"}},[t,l]);eu(()=>{const u=setInterval(Mu,b);return()=>clearInterval(u)},[Mu]),eu(()=>()=>{Q.current={},_.current={},V.current=null,cu({}),console.log("\u7EC4\u4EF6\u5378\u8F7D\uFF0C\u6E05\u7406\u6240\u6709\u7F13\u5B58")},[]),eu(()=>{console.log("=== useEffect \u88AB\u89E6\u53D1 ==="),console.log("\u89E6\u53D1\u65F6\u95F4:",new Date().toISOString()),console.log("\u89E6\u53D1\u539F\u56E0:",{initialPage:A,fileType:o}),(async()=>{try{const e=o==="pdf"||o==="pdf_slides",r=e&&A||1;console.log("\u5F00\u59CB\u521D\u59CB\u52A0\u8F7D\uFF0C\u6587\u4EF6\u7C7B\u578B:",o,"\u6709\u6548\u9875\u7801:",r,"\u662F\u5426PDF:",e),o==="markdown"||o==="markdown_table"?(await qu(),X(1),Y(g||1),s("pageChange",{pageNumber:1,totalPages:g||1})):o==="image"?(await Zu(),X(1),Y(g||1),Fu(0),s("pageChange",{pageNumber:1,totalPages:g||1})):e?(await gu(r,!0),X(r),setTimeout(()=>{s("pageChange",{pageNumber:r,totalPages:g||w})},0)):(console.log("=== \u521D\u59CB\u52A0\u8F7D\uFF1A\u4F7F\u7528\u901A\u7528\u52A0\u8F7D\u51FD\u6570\u5904\u7406\u6587\u4EF6\u7C7B\u578B ===",o),await Gu(),X(1),Y(g||1),s("pageChange",{pageNumber:1,totalPages:g||1}))}catch(e){console.error("\u521D\u59CB\u52A0\u8F7D\u5931\u8D25:",e),I((e==null?void 0:e.message)||"\u6587\u4EF6\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),C("")}})()},[A,o,t]);const Vu=Tu(()=>Math.floor((R-1)/m)*m+1,[R,m]);return ru?c(fu,{$theme:G,className:W,children:B!=null&&B.ErrorComponent?c(B.ErrorComponent,{error:ru,theme:G}):p(fe,{$theme:G,children:[c("div",{children:"\u52A0\u8F7D\u5931\u8D25"}),c("div",{style:{fontSize:"12px",marginTop:"8px"},children:ru})]})}):nu?p(fu,{$theme:G,className:W,children:[c(Lu,{fileName:v(),currentPage:R,totalPage:w,scale:y,isAnnotating:!1,tools:H,styles:$,onPrevPage:()=>{},onNextPage:()=>{},onZoomIn:()=>{},onZoomOut:()=>{},onAnnotationToggle:()=>{},onDownload:()=>{},onClose:ju,className:tu}),B!=null&&B.LoadingComponent?c(B.LoadingComponent,{status:Cu,theme:G}):c(me,{status:Cu,theme:G})]}):p(fu,{$theme:G,className:W,children:[c(Lu,{fileName:v(),currentPage:R,totalPage:w,scale:y,isAnnotating:!1,tools:{...H,navigation:o==="pdf"||o==="pdf_slides"?H.navigation:!1,rotate:o==="image"},styles:$,onPrevPage:Ju,onNextPage:Qu,onZoomIn:Hu,onZoomOut:Uu,onRotateLeft:o==="image"?Wu:void 0,onRotateRight:o==="image"?Yu:void 0,onAnnotationToggle:()=>{},onDownload:()=>{},onClose:ju,className:tu}),o==="markdown"||o==="markdown_table"?p("div",{ref:Xu,style:{flex:1,overflow:"auto",position:"relative"},className:["gientech-stream-reader-content",i].filter(Boolean).join(" "),children:[c("style",{children:`
152
+ .gientech-stream-reader-content {
153
+ -webkit-overflow-scrolling: touch;
154
+ overscroll-behavior: contain;
155
+ min-height: 0;
156
+ }
157
+ .gientech-stream-reader-content table {
158
+ display: block;
159
+ max-width: 100%;
160
+ overflow-x: auto;
161
+ white-space: nowrap;
162
+ border-collapse: collapse;
163
+ -webkit-overflow-scrolling: touch;
164
+ }
165
+ .gientech-stream-reader-content thead,
166
+ .gientech-stream-reader-content tbody,
167
+ .gientech-stream-reader-content tr {
168
+ width: max-content;
169
+ }
170
+ .gientech-stream-reader-content th,
171
+ .gientech-stream-reader-content td {
172
+ max-width: 60vw;
173
+ overflow: hidden;
174
+ text-overflow: ellipsis;
175
+ }
176
+ `}),c(iu,{data:{content:q,...v()&&{fileName:v()},...o&&{fileType:o},...w&&{totalPages:w}},annotationData:U,totalPage:w,currentPage:R,scale:y,eventsEmit:(u,e)=>{console.log("Fviewer\u4E8B\u4EF6:",u,e),s(u==="md_annotation_add"?"md_annotation_add":u==="table_annotation_add"?"table_annotation_add":u,e)},styles:$,tools:H,customComponents:B,contentClass:i}),(console.log("=== \u4F20\u9012\u7ED9Fviewer\u7684markdown\u5185\u5BB9 ==="),console.log("markdownContent:",q),console.log("markdownContent\u957F\u5EA6:",q.length),console.log("markdownContent\u524D100\u5B57\u7B26:",q.substring(0,100)),console.log("markdownContent\u540E100\u5B57\u7B26:",q.substring(q.length-100)),null)]}):o==="image"?c(iu,{data:{content:Eu,...v()&&{fileName:v()},...o&&{fileType:o}},annotationData:U,totalPage:1,currentPage:1,scale:y,rotation:z,eventsEmit:s,styles:$,tools:{...H,navigation:!1,rotate:!0},customComponents:B,contentClass:i}):o==="pdf"||o==="pdf_slides"?c(iu,{data:{content:{document:Ku},...v()&&{fileName:v()},...o&&{fileType:o},...w&&{totalPages:w},pdfStartPage:Vu},annotationData:U,totalPage:w,currentPage:R,scale:y,initialZoom:ou,eventsEmit:(u,e)=>{console.log("Fviewer\u4E8B\u4EF6:",u,e),u==="scaleChange"&&console.log("\u6536\u5230\u7F29\u653E\u53D8\u5316\u4E8B\u4EF6:",e),s(u,e)},styles:$,tools:H,customComponents:B,contentClass:i,setScale:Bu}):c(iu,{data:{content:pu||$u||{type:"text",content:"\u6587\u4EF6\u5185\u5BB9\u52A0\u8F7D\u4E2D..."},...v()&&{fileName:v()},...o&&{fileType:o}},annotationData:U,totalPage:1,currentPage:1,scale:y,eventsEmit:s,styles:$,tools:{...H,navigation:!1},customComponents:B,contentClass:i})]})};export{oe as C,Re as G,ee as a};