@gientech/modual 2.2.30 → 2.2.31-fix.1

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.
@@ -1,4 +1,4 @@
1
- import{jsxs as x,jsx as s,Fragment as gu}from"react/jsx-runtime";import zu,{useState as $,useRef as S,useEffect as ou,useCallback as d,useMemo as Tu}from"react";import M from"styled-components";import du from"axios";import{parseFile as Cu,Fviewer as Fu}from"@mxmweb/fviewer";import{c as K,X as uo}from"./x-CX-iE6EL.js";/**
1
+ import{jsxs as x,jsx as s,Fragment as gu}from"react/jsx-runtime";import zu,{useState as $,useRef as S,useEffect as ou,useCallback as d,useMemo as Tu}from"react";import M from"styled-components";import du from"axios";import{parseFile as Cu,Fviewer as Fu}from"@mxmweb/fviewer";import{c as K}from"./createLucideIcon-Bj5DlX2s.js";import{X as uo}from"./x-CdZQbi--.js";/**
2
2
  * @license lucide-react v0.456.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -148,4 +148,4 @@ import{jsxs as x,jsx as s,Fragment as gu}from"react/jsx-runtime";import zu,{useS
148
148
  color: ${t=>t.$theme.colors.error};
149
149
  text-align: center;
150
150
  padding: 20px;
151
- `,Bo="http://10.15.12.13:9005/proxy/index/knowledgeBase/file/stream",A=300*1e3,Eo={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),e=(l.match(/\uFFFD/g)||[]).length;if(e===0||l.length<20)return l;try{const g=new TextDecoder("gb18030",{fatal:!1}).decode(t);return(g.match(/\uFFFD/g)||[]).length<e?g:l}catch{return l}}const Ro=({convertedFilePath:t,fileName:l,fileType:e,csrfToken:g,initialPage:b=1,initialZoom:eu=1,totalPages:h,annotations:U=[],pageSize:C=5,streamApiUrl:P=Bo,authorization:D,eventsEmit:c=()=>{},tools:N,styles:p,customComponents:B,className:W,headerClass:tu,contentClass:F})=>{const[nu,f]=$(!0),[mu,m]=$("\u6B63\u5728\u52A0\u8F7D\u6587\u6863..."),[ru,v]=$(null),[R,X]=$(b),[E,Y]=$(h||0),[y,Bu]=$(eu),[z,iu]=$(0),[Ku,Eu]=$(null),[wu,ku]=$(null),[q,$u]=$(""),[xu,au]=$(null),[pu,Au]=$(null),[Du,su]=$({}),J=S(!1),T=S(!1),Q=S({}),_=S({}),V=S(null),Xu=S(null),Z=S(b),bu=S(0);bu.current+=1,console.log("[GientechStreamReader] render count:",bu.current),console.log("[GientechStreamReader] props snapshot (early):",{fileType:e,currentPage:R,totalPages:E,hasMarkdown:!!q,hasImage:!!wu,hasText:!!xu,hasHtml:!!pu,isLoading:nu,error:ru});const G=(p==null?void 0:p.theme)||Eo;ou(()=>{J.current=!1,T.current=!1},[e,t]);const H=d(()=>{const u={annotation:!0,download:!0,zoom:!0,close:!0,navigation:!0,rotate:!1};let o;switch(e){case"pdf":case"pdf_slides":o={...u,annotation:!1,download:!1,navigation:!0,rotate:!1};break;case"image":o={...u,annotation:!1,download:!1,navigation:!1,rotate:!0,zoom:!0};break;case"markdown":case"markdown_table":o={...u,annotation:!1,download:!1,navigation:!1,rotate:!1,zoom:!1};break;case"text":case"html":case"unknown":o={...u,annotation:!1,download:!1,navigation:!1,rotate:!1,zoom:!1};break;default:o=u}return N?{...o,...N}:o},[e,N])(),L=d((u,o)=>{const r=Math.floor((u-1)/o)*o+1;return`${r}-${r+o-1}`},[]),Pu=d(async u=>{var w;if(!(e==="pdf"||e==="pdf_slides"))return console.log(`\u6587\u4EF6\u7C7B\u578B ${e} \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<A)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,C),a=_.current[n];if(console.log(`\u68C0\u67E5chunk\u7F13\u5B58: ${n}, \u5B58\u5728: ${!!a}, \u5305\u542B\u9875\u9762: ${((w=a==null?void 0:a.pages)==null?void 0:w.join(", "))||"\u65E0"}`),a&&Date.now()-a.timestamp<A){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},[C,L,e]),Ru=d(async u=>{var o;try{if(!(e==="pdf"||e==="pdf_slides"))throw console.log(`\u6587\u4EF6\u7C7B\u578B ${e} \u4E0D\u9700\u8981\u5206\u9875\u53C2\u6570\uFF0C\u83B7\u53D6\u5B8C\u6574\u5185\u5BB9`),new Error(`\u6587\u4EF6\u7C7B\u578B ${e} \u4E0D\u652F\u6301\u5206\u9875\u52A0\u8F7D`);const n=Math.floor((u-1)/C)*C+1,a=L(u,C);console.log(`\u8BF7\u6C42PDF chunk\u6570\u636E: ${n} (\u5305\u542B\u9875\u9762 ${n}-${n+C-1})`);const w={"Content-Type":"application/json"};D&&(w.Authorization=D),g&&(w["X-CSRF-TOKEN-IN"]=g);const k={convertedFilePath:t,pageNo:n,pageSize:C},i=await du.post(P,k,{headers:w,responseType:"arraybuffer"}),O=i.headers["x-csrf-token-out"]||i.headers["X-CSRF-TOKEN-OUT"];O&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",O),c("request_finish",O));const uu=Array.from({length:C},(ko,Nu)=>n+Nu);return _.current[a]={data:i.data,pages:uu,timestamp:Date.now(),totalPages:h},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)),i.data}catch(r){throw console.error("\u83B7\u53D6PDF stream\u6570\u636E\u5931\u8D25:",r),new Error(`PDF\u8BF7\u6C42\u5931\u8D25: ${((o=r.response)==null?void 0:o.status)||"\u7F51\u7EDC\u9519\u8BEF"}`)}},[P,t,C,D,L,h,E,e,c]),hu=d(async(u,o=!1)=>{var n;if(!u)return;if(!(e==="pdf"||e==="pdf_slides"))return console.log(`\u6587\u4EF6\u7C7B\u578B ${e} \u4E0D\u662FPDF\uFF0C\u8DF3\u8FC7PDF\u52A0\u8F7D\u903B\u8F91`),null;try{o?(f(!0),m("\u6B63\u5728\u52A0\u8F7DPDF\u6587\u6863...")):(f(!0),m(`\u6B63\u5728\u52A0\u8F7D\u7B2C ${u} \u9875...`)),v(null),console.log(`\u5F00\u59CB\u52A0\u8F7DPDF\u9875\u9762: ${u}, \u521D\u59CB\u52A0\u8F7D: ${o}`);const a=await Pu(u);if(a)return console.log(`\u4F7F\u7528\u7F13\u5B58\u7684PDF\u6587\u6863: ${u}`),Eu(a),f(!1),m(""),console.log(`\u9875\u9762 ${u} \u52A0\u8F7D\u5B8C\u6210\uFF08\u4F7F\u7528\u7F13\u5B58\uFF09`),a;const w=await Ru(u),k=await Cu(w,{fileName:l||"Stream\u6587\u6863",fileType:"pdf",token:D});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 i=k.content.document;console.log("\u8BBE\u7F6EPDF\u6587\u6863:",i),console.log("PDF\u6587\u6863\u7C7B\u578B:",typeof i),console.log("PDF\u6587\u6863\u65B9\u6CD5:",i?Object.getOwnPropertyNames(Object.getPrototypeOf(i)):"\u65E0\u6587\u6863"),console.log("PDF\u6587\u6863\u9875\u6570:",i?i.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:",i?`1-${i.numPages}`:"\u65E0\u9875\u6570"),Eu(i);const O=L(u,C);if(_.current[O]&&(_.current[O].pdfDocument=i,console.log(`\u7F13\u5B58PDF\u6587\u6863\u5230chunk: ${O}`)),h)console.log(`\u4F7F\u7528\u7528\u6237\u4F20\u5165\u7684\u603B\u9875\u6570: ${h}`),Y(h);else if(i&&i.numPages){const uu=i.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),m(""),console.log(`\u9875\u9762 ${u} \u52A0\u8F7D\u5B8C\u6210`),i}catch(a){throw console.error("PDF\u52A0\u8F7D\u5931\u8D25:",a),v(a.message||"PDF\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),m(""),a}},[Ru,l,D,E,Pu,L,C,e]),yu=d(u=>{if(!(e==="pdf"||e==="pdf_slides"))return!1;const r=Q.current[u];if(r&&Date.now()-r.timestamp<A)return!!r.pdfDocument;const n=L(u,C),a=_.current[n];return a&&Date.now()-a.timestamp<A?a.pages.includes(u)&&!!a.pdfDocument:!1},[C,L,e]),_u=d(()=>{console.log("\u68C0\u67E5markdown\u5185\u5BB9\u662F\u5426\u5728\u7F13\u5B58\u4E2D");const u=V.current;return u&&Date.now()-u.timestamp<A?(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)},[]),Iu=d(async()=>{var u;try{console.log("\u8BF7\u6C42\u5B8C\u6574markdown\u6570\u636E");const o={"Content-Type":"application/json"};D&&(o.Authorization=D),g&&(o["X-CSRF-TOKEN-IN"]=g);const r={convertedFilePath:t};console.log("\u53D1\u9001markdown\u8BF7\u6C42:",r);const n=await du.post(P,r,{headers:o,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),c("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(o){throw console.error("\u83B7\u53D6markdown\u6570\u636E\u5931\u8D25:",o),new Error(`\u83B7\u53D6markdown\u6570\u636E\u5931\u8D25: ${o.message}`)}},[t,D,P,c]),qu=d(async()=>{try{f(!0),m("\u6B63\u5728\u52A0\u8F7Dmarkdown\u6587\u6863..."),v(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"),$u(u),f(!1),m(""),u;const o=await Iu();return V.current={data:o,timestamp:Date.now()},$u(o),f(!1),m(""),console.log("\u5B8C\u6574markdown\u6587\u6863\u52A0\u8F7D\u5B8C\u6210"),o}catch(u){throw console.error("markdown\u52A0\u8F7D\u5931\u8D25:",u),v(u.message||"markdown\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),m(""),u}},[Iu,_u]),vu=d(async()=>{try{const u={"Content-Type":"application/json"};D&&(u.Authorization=D),g&&(u["X-CSRF-TOKEN-IN"]=g);const o={convertedFilePath:t},r=await du.post(P,o,{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),c("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,D,P,c]),Zu=d(async()=>{try{f(!0),m("\u6B63\u5728\u52A0\u8F7D\u56FE\u7247..."),v(null);const u=await vu(),o=await Cu(u,{fileName:l||"\u56FE\u7247",fileType:"image",token:D});if(o.error)throw new Error(o.error);if(o.type!=="image"||!o.content)throw new Error("\u89E3\u6790\u7ED3\u679C\u4E0D\u662F\u6709\u6548\u7684\u56FE\u7247");return ku(o.content),f(!1),m(""),o.content}catch(u){throw console.error("\u56FE\u7247\u52A0\u8F7D\u5931\u8D25:",u),v(u.message||"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),m(""),u}},[D,l,vu]),Ou=d(async()=>{var u;try{console.log(`\u8BF7\u6C42\u901A\u7528\u6587\u4EF6\u6570\u636E\uFF0C\u6587\u4EF6\u7C7B\u578B: ${e}`);const o={"Content-Type":"application/json"};D&&(o.Authorization=D),g&&(o["X-CSRF-TOKEN-IN"]=g);const r={convertedFilePath:t};console.log("\u53D1\u9001\u901A\u7528\u6587\u4EF6\u8BF7\u6C42:",r);const n=await du.post(P,r,{headers:o,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),c("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(o){throw console.error("\u83B7\u53D6\u901A\u7528\u6587\u4EF6\u6570\u636E\u5931\u8D25:",o),new Error(`\u83B7\u53D6\u901A\u7528\u6587\u4EF6\u6570\u636E\u5931\u8D25: ${o.message}`)}},[t,D,P,c]),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: ${e}`);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: ${e}`);return}const u=`${e}_${t}`,o=Du[u];if(console.log(`\u68C0\u67E5\u901A\u7528\u6587\u6863\u7F13\u5B58\uFF0Ckey: ${u}, \u7F13\u5B58\u5B58\u5728: ${!!o}, \u7F13\u5B58\u65F6\u95F4: ${o?Date.now()-o.timestamp:"N/A"}ms`),o&&Date.now()-o.timestamp<A)return console.log(`\u4F7F\u7528\u7F13\u5B58\u7684\u901A\u7528\u6587\u6863\u5185\u5BB9\uFF0C\u6587\u4EF6\u7C7B\u578B: ${e}`),e==="text"&&o.content?au(o.content):e==="html"&&o.content&&Au(o.content),X(1),Y(h||1),f(!1),m(""),o.content;J.current=!0,f(!0),m(`\u6B63\u5728\u52A0\u8F7D${e}\u6587\u6863...`),v(null),console.log(`\u5F00\u59CB\u52A0\u8F7D\u901A\u7528\u6587\u6863\uFF0C\u6587\u4EF6\u7C7B\u578B: ${e}`);const r=await Ou();if(e==="text"){const k={type:"text",content:Su(r)};au(k);const i=`text_${t}`;return su(O=>({...O,[i]:{content:k,timestamp:Date.now()}})),f(!1),m(""),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: ${e}`),k}const n=await Cu(r,{fileName:l||`${e}\u6587\u6863`,fileType:e,token:D});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)Au(n.content),a=n.content;else if(n.type==="image"&&n.content)ku(n.content),a=n.content;else{const w=Su(r);au({type:"text",content:w}),a={type:"text",content:w}}if(a){const w=`${e}_${t}`,k={...Du,[w]:{content:a,timestamp:Date.now()}};su(k),console.log(`\u901A\u7528\u6587\u6863\u5185\u5BB9\u5DF2\u7F13\u5B58\uFF0C\u6587\u4EF6\u7C7B\u578B: ${e}, \u7F13\u5B58\u952E: ${w}`),console.log("\u5F53\u524D\u7F13\u5B58\u72B6\u6001:",k)}return f(!1),m(""),J.current=!1,T.current=!0,console.log(`\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5B8C\u6210\uFF0C\u6587\u4EF6\u7C7B\u578B: ${e}`),n}catch(u){throw console.error("\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5931\u8D25:",u),v(u.message||"\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),m(""),J.current=!1,T.current=!0,u}},[Ou,l,D,e,t,Du,h]),cu=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(!(e==="pdf"||e==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${e} \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 hu(u,!1),c("pageChange",{pageNumber:u,totalPages:h||E})}catch(r){console.error("PDF\u9875\u9762\u52A0\u8F7D\u5931\u8D25:",r);const n=Z.current;X(n)}},[hu,E,c,yu,nu,e]);ou(()=>{Z.current=R,console.log("\u5F53\u524D\u9875\u72B6\u6001\u66F4\u65B0:",R)},[R]);const lu=d(u=>{Bu(u),c("zoomChange",{scale:u})},[c]),ju=d(()=>{c("viewer:close")},[c]),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;iu(u),c("rotateChange",{rotation:u})},[z,c]),Yu=d(()=>{const u=(z+90)%360;iu(u),c("rotateChange",{rotation:u})},[z,c]),Ju=d(()=>{if(!(e==="pdf"||e==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${e} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}const o=Z.current-1;o>=1&&cu(o)},[cu,e]),Qu=d(()=>{if(!(e==="pdf"||e==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${e} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}const o=Z.current+1,r=h||E;r&&o<=r&&cu(o)},[E,cu,e]),Mu=d(()=>{const u=Date.now();Object.keys(Q.current).forEach(o=>{const r=Q.current[parseInt(o)];u-r.timestamp>A&&(delete Q.current[parseInt(o)],console.log(`\u6E05\u7406\u8FC7\u671F\u9875\u9762\u7F13\u5B58: ${o}`))}),Object.keys(_.current).forEach(o=>{const r=_.current[o];u-r.timestamp>A&&(delete _.current[o],console.log(`\u6E05\u7406\u8FC7\u671Fchunk\u7F13\u5B58: ${o}`))}),V.current&&u-V.current.timestamp>A&&(V.current=null,console.log("\u6E05\u7406\u8FC7\u671Fmarkdown\u5185\u5BB9\u7F13\u5B58")),su(o=>{const r={...o};return Object.keys(r).forEach(n=>{u-r[n].timestamp>A&&(delete r[n],console.log(`\u6E05\u7406\u8FC7\u671F\u901A\u7528\u6587\u4EF6\u7F13\u5B58: ${n}`))}),r})},[]),I=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]);ou(()=>{const u=setInterval(Mu,A);return()=>clearInterval(u)},[Mu]),ou(()=>()=>{Q.current={},_.current={},V.current=null,su({}),console.log("\u7EC4\u4EF6\u5378\u8F7D\uFF0C\u6E05\u7406\u6240\u6709\u7F13\u5B58")},[]),ou(()=>{console.log("=== useEffect \u88AB\u89E6\u53D1 ==="),console.log("\u89E6\u53D1\u65F6\u95F4:",new Date().toISOString()),console.log("\u89E6\u53D1\u539F\u56E0:",{initialPage:b,fileType:e}),(async()=>{try{const o=e==="pdf"||e==="pdf_slides",r=o&&b||1;console.log("\u5F00\u59CB\u521D\u59CB\u52A0\u8F7D\uFF0C\u6587\u4EF6\u7C7B\u578B:",e,"\u6709\u6548\u9875\u7801:",r,"\u662F\u5426PDF:",o),e==="markdown"||e==="markdown_table"?(await qu(),X(1),Y(h||1),c("pageChange",{pageNumber:1,totalPages:h||1})):e==="image"?(await Zu(),X(1),Y(h||1),iu(0),c("pageChange",{pageNumber:1,totalPages:h||1})):o?(await hu(r,!0),X(r),setTimeout(()=>{c("pageChange",{pageNumber:r,totalPages:h||E})},0)):(console.log("=== \u521D\u59CB\u52A0\u8F7D\uFF1A\u4F7F\u7528\u901A\u7528\u52A0\u8F7D\u51FD\u6570\u5904\u7406\u6587\u4EF6\u7C7B\u578B ===",e),await Gu(),X(1),Y(h||1),c("pageChange",{pageNumber:1,totalPages:h||1}))}catch(o){console.error("\u521D\u59CB\u52A0\u8F7D\u5931\u8D25:",o),v((o==null?void 0:o.message)||"\u6587\u4EF6\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),m("")}})()},[b,e,t]);const Vu=Tu(()=>Math.floor((R-1)/C)*C+1,[R,C]);return ru?s(fu,{$theme:G,className:W,children:B!=null&&B.ErrorComponent?s(B.ErrorComponent,{error:ru,theme:G}):x(mo,{$theme:G,children:[s("div",{children:"\u52A0\u8F7D\u5931\u8D25"}),s("div",{style:{fontSize:"12px",marginTop:"8px"},children:ru})]})}):nu?x(fu,{$theme:G,className:W,children:[s(Lu,{fileName:I(),currentPage:R,totalPage:E,scale:y,isAnnotating:!1,tools:H,styles:p,onPrevPage:()=>{},onNextPage:()=>{},onZoomIn:()=>{},onZoomOut:()=>{},onAnnotationToggle:()=>{},onDownload:()=>{},onClose:ju,className:tu}),B!=null&&B.LoadingComponent?s(B.LoadingComponent,{status:mu,theme:G}):s(fo,{status:mu,theme:G})]}):x(fu,{$theme:G,className:W,children:[s(Lu,{fileName:I(),currentPage:R,totalPage:E,scale:y,isAnnotating:!1,tools:{...H,navigation:e==="pdf"||e==="pdf_slides"?H.navigation:!1,rotate:e==="image"},styles:p,onPrevPage:Ju,onNextPage:Qu,onZoomIn:Hu,onZoomOut:Uu,onRotateLeft:e==="image"?Wu:void 0,onRotateRight:e==="image"?Yu:void 0,onAnnotationToggle:()=>{},onDownload:()=>{},onClose:ju,className:tu}),e==="markdown"||e==="markdown_table"?x("div",{ref:Xu,style:{flex:1,overflow:"auto",position:"relative"},className:F,children:[s(Fu,{data:{content:q,...I()&&{fileName:I()},...e&&{fileType:e},...E&&{totalPages:E}},annotationData:U,totalPage:E,currentPage:R,scale:y,eventsEmit:(u,o)=>{console.log("Fviewer\u4E8B\u4EF6:",u,o),c(u==="md_annotation_add"?"md_annotation_add":u==="table_annotation_add"?"table_annotation_add":u,o)},styles:p,tools:H,customComponents:B,contentClass:F}),(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)]}):e==="image"?s(Fu,{data:{content:wu,...I()&&{fileName:I()},...e&&{fileType:e}},annotationData:U,totalPage:1,currentPage:1,scale:y,rotation:z,eventsEmit:c,styles:p,tools:{...H,navigation:!1,rotate:!0},customComponents:B,contentClass:F}):e==="pdf"||e==="pdf_slides"?s(Fu,{data:{content:{document:Ku},...I()&&{fileName:I()},...e&&{fileType:e},...E&&{totalPages:E},pdfStartPage:Vu},annotationData:U,totalPage:E,currentPage:R,scale:y,initialZoom:eu,eventsEmit:(u,o)=>{console.log("Fviewer\u4E8B\u4EF6:",u,o),u==="scaleChange"&&console.log("\u6536\u5230\u7F29\u653E\u53D8\u5316\u4E8B\u4EF6:",o),c(u,o)},styles:p,tools:H,customComponents:B,contentClass:F,setScale:Bu}):s(Fu,{data:{content:xu||pu||{type:"text",content:"\u6587\u4EF6\u5185\u5BB9\u52A0\u8F7D\u4E2D..."},...I()&&{fileName:I()},...e&&{fileType:e}},annotationData:U,totalPage:1,currentPage:1,scale:y,eventsEmit:c,styles:p,tools:{...H,navigation:!1},customComponents:B,contentClass:F})]})};export{eo as C,Ro as G,oo as a};
151
+ `,Bo="http://10.15.12.13:9005/proxy/index/knowledgeBase/file/stream",A=300*1e3,Eo={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),e=(l.match(/\uFFFD/g)||[]).length;if(e===0||l.length<20)return l;try{const g=new TextDecoder("gb18030",{fatal:!1}).decode(t);return(g.match(/\uFFFD/g)||[]).length<e?g:l}catch{return l}}const yo=({convertedFilePath:t,fileName:l,fileType:e,csrfToken:g,initialPage:b=1,initialZoom:eu=1,totalPages:h,annotations:U=[],pageSize:C=5,streamApiUrl:P=Bo,authorization:D,eventsEmit:c=()=>{},tools:N,styles:p,customComponents:B,className:W,headerClass:tu,contentClass:F})=>{const[nu,f]=$(!0),[mu,m]=$("\u6B63\u5728\u52A0\u8F7D\u6587\u6863..."),[ru,v]=$(null),[R,X]=$(b),[E,Y]=$(h||0),[y,Bu]=$(eu),[z,iu]=$(0),[Ku,Eu]=$(null),[wu,ku]=$(null),[q,$u]=$(""),[xu,au]=$(null),[pu,Au]=$(null),[Du,su]=$({}),J=S(!1),T=S(!1),Q=S({}),_=S({}),V=S(null),Xu=S(null),Z=S(b),bu=S(0);bu.current+=1,console.log("[GientechStreamReader] render count:",bu.current),console.log("[GientechStreamReader] props snapshot (early):",{fileType:e,currentPage:R,totalPages:E,hasMarkdown:!!q,hasImage:!!wu,hasText:!!xu,hasHtml:!!pu,isLoading:nu,error:ru});const G=(p==null?void 0:p.theme)||Eo;ou(()=>{J.current=!1,T.current=!1},[e,t]);const H=d(()=>{const u={annotation:!0,download:!0,zoom:!0,close:!0,navigation:!0,rotate:!1};let o;switch(e){case"pdf":case"pdf_slides":o={...u,annotation:!1,download:!1,navigation:!0,rotate:!1};break;case"image":o={...u,annotation:!1,download:!1,navigation:!1,rotate:!0,zoom:!0};break;case"markdown":case"markdown_table":o={...u,annotation:!1,download:!1,navigation:!1,rotate:!1,zoom:!1};break;case"text":case"html":case"unknown":o={...u,annotation:!1,download:!1,navigation:!1,rotate:!1,zoom:!1};break;default:o=u}return N?{...o,...N}:o},[e,N])(),L=d((u,o)=>{const r=Math.floor((u-1)/o)*o+1;return`${r}-${r+o-1}`},[]),Pu=d(async u=>{var w;if(!(e==="pdf"||e==="pdf_slides"))return console.log(`\u6587\u4EF6\u7C7B\u578B ${e} \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<A)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,C),a=_.current[n];if(console.log(`\u68C0\u67E5chunk\u7F13\u5B58: ${n}, \u5B58\u5728: ${!!a}, \u5305\u542B\u9875\u9762: ${((w=a==null?void 0:a.pages)==null?void 0:w.join(", "))||"\u65E0"}`),a&&Date.now()-a.timestamp<A){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},[C,L,e]),Ru=d(async u=>{var o;try{if(!(e==="pdf"||e==="pdf_slides"))throw console.log(`\u6587\u4EF6\u7C7B\u578B ${e} \u4E0D\u9700\u8981\u5206\u9875\u53C2\u6570\uFF0C\u83B7\u53D6\u5B8C\u6574\u5185\u5BB9`),new Error(`\u6587\u4EF6\u7C7B\u578B ${e} \u4E0D\u652F\u6301\u5206\u9875\u52A0\u8F7D`);const n=Math.floor((u-1)/C)*C+1,a=L(u,C);console.log(`\u8BF7\u6C42PDF chunk\u6570\u636E: ${n} (\u5305\u542B\u9875\u9762 ${n}-${n+C-1})`);const w={"Content-Type":"application/json"};D&&(w.Authorization=D),g&&(w["X-CSRF-TOKEN-IN"]=g);const k={convertedFilePath:t,pageNo:n,pageSize:C},i=await du.post(P,k,{headers:w,responseType:"arraybuffer"}),O=i.headers["x-csrf-token-out"]||i.headers["X-CSRF-TOKEN-OUT"];O&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",O),c("request_finish",O));const uu=Array.from({length:C},(ko,Nu)=>n+Nu);return _.current[a]={data:i.data,pages:uu,timestamp:Date.now(),totalPages:h},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)),i.data}catch(r){throw console.error("\u83B7\u53D6PDF stream\u6570\u636E\u5931\u8D25:",r),new Error(`PDF\u8BF7\u6C42\u5931\u8D25: ${((o=r.response)==null?void 0:o.status)||"\u7F51\u7EDC\u9519\u8BEF"}`)}},[P,t,C,D,L,h,E,e,c]),hu=d(async(u,o=!1)=>{var n;if(!u)return;if(!(e==="pdf"||e==="pdf_slides"))return console.log(`\u6587\u4EF6\u7C7B\u578B ${e} \u4E0D\u662FPDF\uFF0C\u8DF3\u8FC7PDF\u52A0\u8F7D\u903B\u8F91`),null;try{o?(f(!0),m("\u6B63\u5728\u52A0\u8F7DPDF\u6587\u6863...")):(f(!0),m(`\u6B63\u5728\u52A0\u8F7D\u7B2C ${u} \u9875...`)),v(null),console.log(`\u5F00\u59CB\u52A0\u8F7DPDF\u9875\u9762: ${u}, \u521D\u59CB\u52A0\u8F7D: ${o}`);const a=await Pu(u);if(a)return console.log(`\u4F7F\u7528\u7F13\u5B58\u7684PDF\u6587\u6863: ${u}`),Eu(a),f(!1),m(""),console.log(`\u9875\u9762 ${u} \u52A0\u8F7D\u5B8C\u6210\uFF08\u4F7F\u7528\u7F13\u5B58\uFF09`),a;const w=await Ru(u),k=await Cu(w,{fileName:l||"Stream\u6587\u6863",fileType:"pdf",token:D});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 i=k.content.document;console.log("\u8BBE\u7F6EPDF\u6587\u6863:",i),console.log("PDF\u6587\u6863\u7C7B\u578B:",typeof i),console.log("PDF\u6587\u6863\u65B9\u6CD5:",i?Object.getOwnPropertyNames(Object.getPrototypeOf(i)):"\u65E0\u6587\u6863"),console.log("PDF\u6587\u6863\u9875\u6570:",i?i.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:",i?`1-${i.numPages}`:"\u65E0\u9875\u6570"),Eu(i);const O=L(u,C);if(_.current[O]&&(_.current[O].pdfDocument=i,console.log(`\u7F13\u5B58PDF\u6587\u6863\u5230chunk: ${O}`)),h)console.log(`\u4F7F\u7528\u7528\u6237\u4F20\u5165\u7684\u603B\u9875\u6570: ${h}`),Y(h);else if(i&&i.numPages){const uu=i.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),m(""),console.log(`\u9875\u9762 ${u} \u52A0\u8F7D\u5B8C\u6210`),i}catch(a){throw console.error("PDF\u52A0\u8F7D\u5931\u8D25:",a),v(a.message||"PDF\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),m(""),a}},[Ru,l,D,E,Pu,L,C,e]),yu=d(u=>{if(!(e==="pdf"||e==="pdf_slides"))return!1;const r=Q.current[u];if(r&&Date.now()-r.timestamp<A)return!!r.pdfDocument;const n=L(u,C),a=_.current[n];return a&&Date.now()-a.timestamp<A?a.pages.includes(u)&&!!a.pdfDocument:!1},[C,L,e]),_u=d(()=>{console.log("\u68C0\u67E5markdown\u5185\u5BB9\u662F\u5426\u5728\u7F13\u5B58\u4E2D");const u=V.current;return u&&Date.now()-u.timestamp<A?(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)},[]),Iu=d(async()=>{var u;try{console.log("\u8BF7\u6C42\u5B8C\u6574markdown\u6570\u636E");const o={"Content-Type":"application/json"};D&&(o.Authorization=D),g&&(o["X-CSRF-TOKEN-IN"]=g);const r={convertedFilePath:t};console.log("\u53D1\u9001markdown\u8BF7\u6C42:",r);const n=await du.post(P,r,{headers:o,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),c("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(o){throw console.error("\u83B7\u53D6markdown\u6570\u636E\u5931\u8D25:",o),new Error(`\u83B7\u53D6markdown\u6570\u636E\u5931\u8D25: ${o.message}`)}},[t,D,P,c]),qu=d(async()=>{try{f(!0),m("\u6B63\u5728\u52A0\u8F7Dmarkdown\u6587\u6863..."),v(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"),$u(u),f(!1),m(""),u;const o=await Iu();return V.current={data:o,timestamp:Date.now()},$u(o),f(!1),m(""),console.log("\u5B8C\u6574markdown\u6587\u6863\u52A0\u8F7D\u5B8C\u6210"),o}catch(u){throw console.error("markdown\u52A0\u8F7D\u5931\u8D25:",u),v(u.message||"markdown\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),m(""),u}},[Iu,_u]),vu=d(async()=>{try{const u={"Content-Type":"application/json"};D&&(u.Authorization=D),g&&(u["X-CSRF-TOKEN-IN"]=g);const o={convertedFilePath:t},r=await du.post(P,o,{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),c("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,D,P,c]),Zu=d(async()=>{try{f(!0),m("\u6B63\u5728\u52A0\u8F7D\u56FE\u7247..."),v(null);const u=await vu(),o=await Cu(u,{fileName:l||"\u56FE\u7247",fileType:"image",token:D});if(o.error)throw new Error(o.error);if(o.type!=="image"||!o.content)throw new Error("\u89E3\u6790\u7ED3\u679C\u4E0D\u662F\u6709\u6548\u7684\u56FE\u7247");return ku(o.content),f(!1),m(""),o.content}catch(u){throw console.error("\u56FE\u7247\u52A0\u8F7D\u5931\u8D25:",u),v(u.message||"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),m(""),u}},[D,l,vu]),Ou=d(async()=>{var u;try{console.log(`\u8BF7\u6C42\u901A\u7528\u6587\u4EF6\u6570\u636E\uFF0C\u6587\u4EF6\u7C7B\u578B: ${e}`);const o={"Content-Type":"application/json"};D&&(o.Authorization=D),g&&(o["X-CSRF-TOKEN-IN"]=g);const r={convertedFilePath:t};console.log("\u53D1\u9001\u901A\u7528\u6587\u4EF6\u8BF7\u6C42:",r);const n=await du.post(P,r,{headers:o,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),c("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(o){throw console.error("\u83B7\u53D6\u901A\u7528\u6587\u4EF6\u6570\u636E\u5931\u8D25:",o),new Error(`\u83B7\u53D6\u901A\u7528\u6587\u4EF6\u6570\u636E\u5931\u8D25: ${o.message}`)}},[t,D,P,c]),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: ${e}`);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: ${e}`);return}const u=`${e}_${t}`,o=Du[u];if(console.log(`\u68C0\u67E5\u901A\u7528\u6587\u6863\u7F13\u5B58\uFF0Ckey: ${u}, \u7F13\u5B58\u5B58\u5728: ${!!o}, \u7F13\u5B58\u65F6\u95F4: ${o?Date.now()-o.timestamp:"N/A"}ms`),o&&Date.now()-o.timestamp<A)return console.log(`\u4F7F\u7528\u7F13\u5B58\u7684\u901A\u7528\u6587\u6863\u5185\u5BB9\uFF0C\u6587\u4EF6\u7C7B\u578B: ${e}`),e==="text"&&o.content?au(o.content):e==="html"&&o.content&&Au(o.content),X(1),Y(h||1),f(!1),m(""),o.content;J.current=!0,f(!0),m(`\u6B63\u5728\u52A0\u8F7D${e}\u6587\u6863...`),v(null),console.log(`\u5F00\u59CB\u52A0\u8F7D\u901A\u7528\u6587\u6863\uFF0C\u6587\u4EF6\u7C7B\u578B: ${e}`);const r=await Ou();if(e==="text"){const k={type:"text",content:Su(r)};au(k);const i=`text_${t}`;return su(O=>({...O,[i]:{content:k,timestamp:Date.now()}})),f(!1),m(""),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: ${e}`),k}const n=await Cu(r,{fileName:l||`${e}\u6587\u6863`,fileType:e,token:D});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)Au(n.content),a=n.content;else if(n.type==="image"&&n.content)ku(n.content),a=n.content;else{const w=Su(r);au({type:"text",content:w}),a={type:"text",content:w}}if(a){const w=`${e}_${t}`,k={...Du,[w]:{content:a,timestamp:Date.now()}};su(k),console.log(`\u901A\u7528\u6587\u6863\u5185\u5BB9\u5DF2\u7F13\u5B58\uFF0C\u6587\u4EF6\u7C7B\u578B: ${e}, \u7F13\u5B58\u952E: ${w}`),console.log("\u5F53\u524D\u7F13\u5B58\u72B6\u6001:",k)}return f(!1),m(""),J.current=!1,T.current=!0,console.log(`\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5B8C\u6210\uFF0C\u6587\u4EF6\u7C7B\u578B: ${e}`),n}catch(u){throw console.error("\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5931\u8D25:",u),v(u.message||"\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),m(""),J.current=!1,T.current=!0,u}},[Ou,l,D,e,t,Du,h]),cu=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(!(e==="pdf"||e==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${e} \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 hu(u,!1),c("pageChange",{pageNumber:u,totalPages:h||E})}catch(r){console.error("PDF\u9875\u9762\u52A0\u8F7D\u5931\u8D25:",r);const n=Z.current;X(n)}},[hu,E,c,yu,nu,e]);ou(()=>{Z.current=R,console.log("\u5F53\u524D\u9875\u72B6\u6001\u66F4\u65B0:",R)},[R]);const lu=d(u=>{Bu(u),c("zoomChange",{scale:u})},[c]),ju=d(()=>{c("viewer:close")},[c]),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;iu(u),c("rotateChange",{rotation:u})},[z,c]),Yu=d(()=>{const u=(z+90)%360;iu(u),c("rotateChange",{rotation:u})},[z,c]),Ju=d(()=>{if(!(e==="pdf"||e==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${e} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}const o=Z.current-1;o>=1&&cu(o)},[cu,e]),Qu=d(()=>{if(!(e==="pdf"||e==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${e} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}const o=Z.current+1,r=h||E;r&&o<=r&&cu(o)},[E,cu,e]),Mu=d(()=>{const u=Date.now();Object.keys(Q.current).forEach(o=>{const r=Q.current[parseInt(o)];u-r.timestamp>A&&(delete Q.current[parseInt(o)],console.log(`\u6E05\u7406\u8FC7\u671F\u9875\u9762\u7F13\u5B58: ${o}`))}),Object.keys(_.current).forEach(o=>{const r=_.current[o];u-r.timestamp>A&&(delete _.current[o],console.log(`\u6E05\u7406\u8FC7\u671Fchunk\u7F13\u5B58: ${o}`))}),V.current&&u-V.current.timestamp>A&&(V.current=null,console.log("\u6E05\u7406\u8FC7\u671Fmarkdown\u5185\u5BB9\u7F13\u5B58")),su(o=>{const r={...o};return Object.keys(r).forEach(n=>{u-r[n].timestamp>A&&(delete r[n],console.log(`\u6E05\u7406\u8FC7\u671F\u901A\u7528\u6587\u4EF6\u7F13\u5B58: ${n}`))}),r})},[]),I=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]);ou(()=>{const u=setInterval(Mu,A);return()=>clearInterval(u)},[Mu]),ou(()=>()=>{Q.current={},_.current={},V.current=null,su({}),console.log("\u7EC4\u4EF6\u5378\u8F7D\uFF0C\u6E05\u7406\u6240\u6709\u7F13\u5B58")},[]),ou(()=>{console.log("=== useEffect \u88AB\u89E6\u53D1 ==="),console.log("\u89E6\u53D1\u65F6\u95F4:",new Date().toISOString()),console.log("\u89E6\u53D1\u539F\u56E0:",{initialPage:b,fileType:e}),(async()=>{try{const o=e==="pdf"||e==="pdf_slides",r=o&&b||1;console.log("\u5F00\u59CB\u521D\u59CB\u52A0\u8F7D\uFF0C\u6587\u4EF6\u7C7B\u578B:",e,"\u6709\u6548\u9875\u7801:",r,"\u662F\u5426PDF:",o),e==="markdown"||e==="markdown_table"?(await qu(),X(1),Y(h||1),c("pageChange",{pageNumber:1,totalPages:h||1})):e==="image"?(await Zu(),X(1),Y(h||1),iu(0),c("pageChange",{pageNumber:1,totalPages:h||1})):o?(await hu(r,!0),X(r),setTimeout(()=>{c("pageChange",{pageNumber:r,totalPages:h||E})},0)):(console.log("=== \u521D\u59CB\u52A0\u8F7D\uFF1A\u4F7F\u7528\u901A\u7528\u52A0\u8F7D\u51FD\u6570\u5904\u7406\u6587\u4EF6\u7C7B\u578B ===",e),await Gu(),X(1),Y(h||1),c("pageChange",{pageNumber:1,totalPages:h||1}))}catch(o){console.error("\u521D\u59CB\u52A0\u8F7D\u5931\u8D25:",o),v((o==null?void 0:o.message)||"\u6587\u4EF6\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),m("")}})()},[b,e,t]);const Vu=Tu(()=>Math.floor((R-1)/C)*C+1,[R,C]);return ru?s(fu,{$theme:G,className:W,children:B!=null&&B.ErrorComponent?s(B.ErrorComponent,{error:ru,theme:G}):x(mo,{$theme:G,children:[s("div",{children:"\u52A0\u8F7D\u5931\u8D25"}),s("div",{style:{fontSize:"12px",marginTop:"8px"},children:ru})]})}):nu?x(fu,{$theme:G,className:W,children:[s(Lu,{fileName:I(),currentPage:R,totalPage:E,scale:y,isAnnotating:!1,tools:H,styles:p,onPrevPage:()=>{},onNextPage:()=>{},onZoomIn:()=>{},onZoomOut:()=>{},onAnnotationToggle:()=>{},onDownload:()=>{},onClose:ju,className:tu}),B!=null&&B.LoadingComponent?s(B.LoadingComponent,{status:mu,theme:G}):s(fo,{status:mu,theme:G})]}):x(fu,{$theme:G,className:W,children:[s(Lu,{fileName:I(),currentPage:R,totalPage:E,scale:y,isAnnotating:!1,tools:{...H,navigation:e==="pdf"||e==="pdf_slides"?H.navigation:!1,rotate:e==="image"},styles:p,onPrevPage:Ju,onNextPage:Qu,onZoomIn:Hu,onZoomOut:Uu,onRotateLeft:e==="image"?Wu:void 0,onRotateRight:e==="image"?Yu:void 0,onAnnotationToggle:()=>{},onDownload:()=>{},onClose:ju,className:tu}),e==="markdown"||e==="markdown_table"?x("div",{ref:Xu,style:{flex:1,overflow:"auto",position:"relative"},className:F,children:[s(Fu,{data:{content:q,...I()&&{fileName:I()},...e&&{fileType:e},...E&&{totalPages:E}},annotationData:U,totalPage:E,currentPage:R,scale:y,eventsEmit:(u,o)=>{console.log("Fviewer\u4E8B\u4EF6:",u,o),c(u==="md_annotation_add"?"md_annotation_add":u==="table_annotation_add"?"table_annotation_add":u,o)},styles:p,tools:H,customComponents:B,contentClass:F}),(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)]}):e==="image"?s(Fu,{data:{content:wu,...I()&&{fileName:I()},...e&&{fileType:e}},annotationData:U,totalPage:1,currentPage:1,scale:y,rotation:z,eventsEmit:c,styles:p,tools:{...H,navigation:!1,rotate:!0},customComponents:B,contentClass:F}):e==="pdf"||e==="pdf_slides"?s(Fu,{data:{content:{document:Ku},...I()&&{fileName:I()},...e&&{fileType:e},...E&&{totalPages:E},pdfStartPage:Vu},annotationData:U,totalPage:E,currentPage:R,scale:y,initialZoom:eu,eventsEmit:(u,o)=>{console.log("Fviewer\u4E8B\u4EF6:",u,o),u==="scaleChange"&&console.log("\u6536\u5230\u7F29\u653E\u53D8\u5316\u4E8B\u4EF6:",o),c(u,o)},styles:p,tools:H,customComponents:B,contentClass:F,setScale:Bu}):s(Fu,{data:{content:xu||pu||{type:"text",content:"\u6587\u4EF6\u5185\u5BB9\u52A0\u8F7D\u4E2D..."},...I()&&{fileName:I()},...e&&{fileType:e}},annotationData:U,totalPage:1,currentPage:1,scale:y,eventsEmit:c,styles:p,tools:{...H,navigation:!1},customComponents:B,contentClass:F})]})};export{eo as C,yo as G,oo as a};
@@ -1,4 +1,4 @@
1
- import{c}from"./x-CX-iE6EL.js";/**
1
+ import{c}from"./createLucideIcon-Bj5DlX2s.js";/**
2
2
  * @license lucide-react v0.456.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1 @@
1
+ import{g as l}from"./dayjs.min-9C0uSO6x.js";import u from"react-dom";function s(e,i){for(var n=0;n<i.length;n++){const t=i[n];if(typeof t!="string"&&!Array.isArray(t)){for(const r in t)if(r!=="default"&&!(r in e)){const a=Object.getOwnPropertyDescriptor(t,r);a&&Object.defineProperty(e,r,a.get?a:{enumerable:!0,get:()=>t[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var o={},c;function p(){if(c)return o;c=1;var e=u;return o.createRoot=e.createRoot,o.hydrateRoot=e.hydrateRoot,o}var f=p();const d=l(f),y=s({__proto__:null,default:d},[f]);export{y as c};
@@ -3,7 +3,7 @@ import{forwardRef as i,createElement as a}from"react";/**
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const w=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),c=(...t)=>t.filter((e,r,o)=>!!e&&e.trim()!==""&&o.indexOf(e)===r).join(" ").trim();/**
6
+ */const p=r=>r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),c=(...r)=>r.filter((e,t,o)=>!!e&&e.trim()!==""&&o.indexOf(e)===t).join(" ").trim();/**
7
7
  * @license lucide-react v0.456.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
@@ -13,14 +13,9 @@ import{forwardRef as i,createElement as a}from"react";/**
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const h=i(({color:t="currentColor",size:e=24,strokeWidth:r=2,absoluteStrokeWidth:o,className:s="",children:n,iconNode:u,...d},l)=>a("svg",{ref:l,...f,width:e,height:e,stroke:t,strokeWidth:o?Number(r)*24/Number(e):r,className:c("lucide",s),...d},[...u.map(([m,p])=>a(m,p)),...Array.isArray(n)?n:[n]]));/**
16
+ */const g=i(({color:r="currentColor",size:e=24,strokeWidth:t=2,absoluteStrokeWidth:o,className:s="",children:n,iconNode:u,...l},m)=>a("svg",{ref:m,...f,width:e,height:e,stroke:r,strokeWidth:o?Number(t)*24/Number(e):t,className:c("lucide",s),...l},[...u.map(([d,w])=>a(d,w)),...Array.isArray(n)?n:[n]]));/**
17
17
  * @license lucide-react v0.456.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const k=(t,e)=>{const r=i(({className:o,...s},n)=>a(h,{ref:n,iconNode:e,className:c(`lucide-${w(t)}`,o),...s}));return r.displayName=`${t}`,r};/**
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 g=k("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);export{g as X,k as c};
21
+ */const C=(r,e)=>{const t=i(({className:o,...s},n)=>a(g,{ref:n,iconNode:e,className:c(`lucide-${p(r)}`,o),...s}));return t.displayName=`${r}`,t};export{C as c};