@gientech/modual 1.7.9 → 1.8.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
- var Xn=Object.defineProperty;var Sn=m=>{throw TypeError(m)};var Gn=(m,a,A)=>a in m?Xn(m,a,{enumerable:!0,configurable:!0,writable:!0,value:A}):m[a]=A;var ee=(m,a,A)=>Gn(m,typeof a!="symbol"?a+"":a,A),an=(m,a,A)=>a.has(m)||Sn("Cannot "+A);var R=(m,a,A)=>(an(m,a,"read from private field"),A?A.call(m):a.get(m)),Ot=(m,a,A)=>a.has(m)?Sn("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(m):a.set(m,A),It=(m,a,A,f)=>(an(m,a,"write to private field"),f?f.call(m,A):a.set(m,A),A),Dt=(m,a,A)=>(an(m,a,"access private method"),A);var on=(m,a,A,f)=>({set _(_){It(m,a,_,A)},get _(){return R(m,a,f)}});import{jsxs,jsx,Fragment}from"react/jsx-runtime";import React__default,{forwardRef,createElement,useState,useRef,useEffect,useCallback,useMemo}from"react";import{c as createLucideIcon,X as getAugmentedNamespace,W as dt$1,a as axios}from"./index-C0f77Ai0.js";import{H as Hv,u as ua}from"./index-CbDqv9y2.js";import{C as ChevronRight}from"./index-BtzZe0dg.js";import{X}from"./x-B50yFeY5.js";/**
1
+ var Xn=Object.defineProperty;var Sn=m=>{throw TypeError(m)};var Gn=(m,a,A)=>a in m?Xn(m,a,{enumerable:!0,configurable:!0,writable:!0,value:A}):m[a]=A;var ee=(m,a,A)=>Gn(m,typeof a!="symbol"?a+"":a,A),an=(m,a,A)=>a.has(m)||Sn("Cannot "+A);var R=(m,a,A)=>(an(m,a,"read from private field"),A?A.call(m):a.get(m)),Ot=(m,a,A)=>a.has(m)?Sn("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(m):a.set(m,A),It=(m,a,A,f)=>(an(m,a,"write to private field"),f?f.call(m,A):a.set(m,A),A),Dt=(m,a,A)=>(an(m,a,"access private method"),A);var on=(m,a,A,f)=>({set _(_){It(m,a,_,A)},get _(){return R(m,a,f)}});import{jsxs,jsx,Fragment}from"react/jsx-runtime";import React__default,{forwardRef,createElement,useState,useRef,useEffect,useCallback,useMemo}from"react";import{c as createLucideIcon,X as getAugmentedNamespace,W as dt$1,a as axios}from"./index-C0f77Ai0.js";import{H as Hv,l as la}from"./index-6rZwr24p.js";import{C as ChevronRight}from"./index-BtzZe0dg.js";import{X}from"./x-B50yFeY5.js";/**
2
2
  * @license lucide-react v0.456.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -167,7 +167,7 @@ var Xn=Object.defineProperty;var Sn=m=>{throw TypeError(m)};var Gn=(m,a,A)=>a in
167
167
  0% { transform: rotate(0deg); }
168
168
  100% { transform: rotate(360deg); }
169
169
  }
170
- `))},Ie=(m,a)=>{var A,f,_,V,q;console.log("=== Fviewer renderTextContent ==="),console.log("data:",m),console.log("data.content:",m.content);let Y="";typeof m.content=="string"?Y=m.content:(A=m.content)!=null&&A.text?Y=m.content.text:(f=m.content)!=null&&f.content&&(Y=m.content.content),console.log("\u5B9E\u9645\u6587\u672C\u5185\u5BB9:",Y);const M=useRef(null),b=useRef(null);return useEffect(()=>{if(M.current&&b.current&&Y){const w=setTimeout(()=>{var P;const S=((P=M.current)==null?void 0:P.scrollHeight)||0,F=Math.max(S+80,200);b.current&&(b.current.style.minHeight=`${F}px`,console.log("\u6587\u672C\u7EB8\u5F20\u9AD8\u5EA6\u8C03\u6574\u5B8C\u6210:",F))},100);return()=>clearTimeout(w)}},[Y]),React__default.createElement("div",{style:{height:"100%",overflow:"auto",backgroundColor:"#f5f5f5",padding:"20px",display:"flex",justifyContent:"center",position:"relative"}},React__default.createElement("div",{ref:b,style:{width:"100%",maxWidth:"800px",backgroundColor:"white",boxShadow:"0 4px 8px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06)",borderRadius:"8px",padding:"40px",margin:"20px 0",position:"relative",transform:`scale(${a.scale||1})`,transition:"transform 0.2s ease-in-out",transformOrigin:"top center"}},React__default.createElement("div",{ref:M,style:{width:"100%",overflow:"visible"}},React__default.createElement(Hv,{dataSource:{type:ua.TEXT,content:Y},size:"md",theme:{primaryColor:((q=(V=(_=a.styles)==null?void 0:_.theme)==null?void 0:V.colors)==null?void 0:q.primary)||"#007bff",backgroundColor:"transparent",textColor:"#333",borderColor:"transparent",borderRadius:"0",padding:"0"},style:{border:"none",background:"transparent",width:"100%",height:"auto",overflow:"visible"}})),React__default.createElement("div",{style:{position:"absolute",top:"0",left:"0",right:"0",height:"2px",background:"linear-gradient(90deg, #e0e0e0 0%, #f0f0f0 50%, #e0e0e0 100%)",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}})))},je=({data:m,parentProps:a,isTableMode:A=!1})=>{var f,_,V,q,Y,M,b,w,P,S,F,l;const t=useRef(null),r=useRef(null),o=useRef(null),v=useRef(!1);useRef(0),useRef(null);const[g]=useState(!1),u=(B,U)=>{console.log("=== Markdownit\u6EDA\u52A8\u4E8B\u4EF6\u89E6\u53D1 ==="),console.log("\u6EDA\u52A8\u4F4D\u7F6E:",{scrollTop:B,scrollHeight:U}),a.eventsEmit&&a.eventsEmit("markdown_scroll",{scrollTop:B,scrollHeight:U})},n=()=>{console.log("=== Markdownit\u6EDA\u52A8\u5230\u9876\u90E8 ==="),a.eventsEmit&&a.eventsEmit("markdown_scroll_to_top")},i=()=>{console.log("=== Markdownit\u6EDA\u52A8\u5230\u5E95\u90E8 ==="),a.eventsEmit&&a.eventsEmit("markdown_scroll_to_bottom")},e=useRef();e.current=B=>{var U,G;try{if(!A)return;const Q=typeof m.content=="string"?m.content:((U=m.content)==null?void 0:U.content)||"";if(!Q||I.length===0)return;const xt=JSON.stringify(I.map(H=>({o:H.offsets,c:H.color}))),Rt=`${Q.length}:${Q.substring(0,64)}:${Q.substring(Q.length-64)}|${xt}`;if(((G=B.dataset)==null?void 0:G.tableAnnoRuntimeSig)===Rt)return;setTimeout(()=>{bt(),B.dataset&&(B.dataset.tableAnnoRuntimeSig=Rt)},50)}catch(Q){console.warn("[MarkdownRendered] apply failed",Q)}};const E=React__default.useCallback(B=>{var U;return(U=e.current)==null?void 0:U.call(e,B)},[]),x=useCallback(()=>{var B;if(!g||!t.current)return;const U=window.getSelection();if(!U||U.isCollapsed)return;const G=U.getRangeAt(0),Q=G.toString().trim();if(!Q)return;const xt=t.current;let Rt=0,H=0;const h=document.createTreeWalker(xt,NodeFilter.SHOW_TEXT,{acceptNode:O=>{var $;return($=O.parentElement)!=null&&$.closest("pre")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let c=h.nextNode();for(;c;){if(c===G.startContainer){H=Rt+G.startOffset;break}Rt+=((B=c.textContent)==null?void 0:B.length)||0,c=h.nextNode()}console.log("\u9009\u4E2D\u6587\u672C\u4FE1\u606F:",{text:Q,startOffset:H,charCount:Rt,container:G.startContainer.textContent});const T={id:`md-anno-${Date.now()}`,start:H,end:H+Q.length,color:"#FFE599"};console.log("\u521B\u5EFA\u65B0\u6807\u6CE8:",T),a.eventsEmit&&a.eventsEmit("md_annotation_add",T),U.removeAllRanges()},[g,a.eventsEmit]),j=A?[]:(a.annotationData||[]).filter(B=>"start"in B&&"end"in B&&!("pageNumber"in B)),I=A?(a.annotationData||[]).filter(B=>"offsets"in B&&Array.isArray(B.offsets)):[],yt=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u6E05\u7A7A\u6240\u6709\u6807\u6CE8 ==="),!t.current){console.log("markdownRef\u4E0D\u5B58\u5728\uFF0C\u65E0\u6CD5\u6E05\u7A7A\u6807\u6CE8");return}const B=t.current.querySelectorAll(".md-annotation");console.log("\u6E05\u7A7AMarkdown\u6807\u6CE8\u6570\u91CF:",B.length),B.length>0&&B.forEach(U=>{const G=U.parentNode;G&&G.replaceChild(document.createTextNode(U.textContent||""),U)}),console.log("\u6240\u6709\u6807\u6CE8\u5DF2\u6E05\u7A7A")},[]),wt=useCallback(()=>{t.current&&(t.current.querySelectorAll("table").forEach(B=>{Array.from(B.rows).forEach(U=>{Array.from(U.cells).forEach(G=>{G.getAttribute("data-table-annotated")==="1"&&(G.style.removeProperty("background"),G.style.removeProperty("background-color"),G.removeAttribute("data-table-annotated"),G.removeAttribute("title"))})})}),console.log("\u5DF2\u6E05\u7A7A\u6240\u6709\u8868\u683C\u6807\u6CE8"))},[]),bt=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u5E94\u7528\u8868\u683C\u6807\u6CE8 ==="),console.log("tableAnnotations:",I),!t.current){console.log("markdownRef\u4E0D\u5B58\u5728\uFF0C\u9000\u51FA");return}if(wt(),!I.length){console.log("\u6CA1\u6709\u8868\u683C\u6807\u6CE8\u6570\u636E\uFF0C\u4EC5\u6E05\u7A7A\u65E7\u6807\u6CE8");return}const B=t.current.querySelectorAll("table");if(console.log("\u627E\u5230\u8868\u683C\u6570\u91CF:",B.length),B.length===0){console.log("\u6CA1\u6709\u627E\u5230\u8868\u683C\u5143\u7D20");return}v.current=!0,I.forEach((U,G)=>{const Q=U.offsets;if(console.log("\u5904\u7406\u8868\u683C\u6807\u6CE8:",U),!Array.isArray(Q)||!Q.length||!Array.isArray(Q[0])||Q[0].length!==2){console.warn("[TableAnnotation] annotation.offsets is not valid",U);return}Q.forEach((xt,Rt)=>{const[H,h]=xt;if(typeof H!="number"||typeof h!="number"){console.warn("[TableAnnotation] offset is not [number, number]",xt);return}B.forEach((c,T)=>{var O;const $=Array.from(c.rows),W=$[H];if(!W){console.warn("[TableAnnotation] row out of range",{row:H,tableIndex:T,totalRows:$.length});return}const s=(O=W.cells)==null?void 0:O[h];if(!s){console.warn("[TableAnnotation] cell is undefined",{row:H,col:h,tableIndex:T});return}const d=U.color||"rgba(255, 229, 153, 0.5)",C=getComputedStyle(s).backgroundColor;s.getAttribute("data-table-annotated")==="1"&&(C===d||s.style.backgroundColor===d)||(s.style.setProperty("background",d,"important"),s.style.setProperty("background-color",d,"important"),s.setAttribute("data-table-annotated","1")),U.content&&(s.title=U.content),Rt===0&&G===0&&setTimeout(()=>{s.scrollIntoView({behavior:"smooth",block:"start"})},300)})})}),requestAnimationFrame(()=>{v.current=!1})},[I,wt]),K=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u5E94\u7528Markdown\u6807\u6CE8 ==="),!t.current||!j.length){console.log("\u6761\u4EF6\u4E0D\u6EE1\u8DB3\uFF0C\u8DF3\u8FC7\u6807\u6CE8\u5E94\u7528");return}r.current&&clearTimeout(r.current);const B=()=>{var U;console.log("\u5F00\u59CB\u5E94\u7528\u6807\u6CE8...");const G=(U=t.current)==null?void 0:U.querySelectorAll(".md-annotation");console.log("\u79FB\u9664\u73B0\u6709\u6807\u6CE8\u6570\u91CF:",(G==null?void 0:G.length)||0),G==null||G.forEach(T=>{const O=T.parentNode;O&&O.replaceChild(document.createTextNode(T.textContent||""),T)});const Q=document.createTreeWalker(t.current,NodeFilter.SHOW_TEXT,{acceptNode:T=>{var O;return(O=T.parentElement)!=null&&O.closest("pre")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),xt=[];let Rt;for(;Rt=Q.nextNode();)xt.push(Rt);if(console.log("\u627E\u5230\u6587\u672C\u8282\u70B9\u6570\u91CF:",xt.length),xt.length===0){console.log("\u6CA1\u6709\u627E\u5230\u6587\u672C\u8282\u70B9\uFF0C\u5EF6\u8FDF\u91CD\u8BD5..."),r.current=setTimeout(()=>{B()},200);return}let H=0;const h=xt.map(T=>{var O;const $=H;return H+=((O=T.textContent)==null?void 0:O.length)||0,{node:T,start:$,end:H,text:T.textContent}});console.log("\u6587\u672C\u8282\u70B9\u4F4D\u7F6E:",h),console.log("\u603B\u6587\u672C\u957F\u5EA6:",H);const c=[...j].sort((T,O)=>O.start-T.start);console.log("\u6392\u5E8F\u540E\u7684\u6807\u6CE8:",c),c.forEach(T=>{const{start:O,end:$,color:W}=T;console.log("\u5904\u7406\u6807\u6CE8:",{annotation:T,nodePositions:h});const s=h.filter(d=>O<d.end&&$>d.start);console.log("\u76F8\u5173\u8282\u70B9\u6570\u91CF:",s.length),s.forEach(({node:d,start:C})=>{var y,k,N,D,p,L;const _t=Math.max(0,O-C),z=Math.min(((y=d.textContent)==null?void 0:y.length)||0,$-C);if(console.log("\u672C\u5730\u4F4D\u7F6E:",{localStart:_t,localEnd:z,nodeTextLength:(k=d.textContent)==null?void 0:k.length}),_t>=z){console.log("\u672C\u5730\u4F4D\u7F6E\u65E0\u6548\uFF0C\u8DF3\u8FC7");return}const Z=((N=d.textContent)==null?void 0:N.slice(0,_t))||"",At=((D=d.textContent)==null?void 0:D.slice(_t,z))||"",kt=((p=d.textContent)==null?void 0:p.slice(z))||"";console.log("\u5206\u5272\u6587\u672C:",{before:Z,annotatedText:At,after:kt});const Mt=document.createElement("span");Mt.className="md-annotation",Mt.style.backgroundColor=W||"#FFE599",Mt.textContent=At;const St=document.createDocumentFragment();Z&&St.appendChild(document.createTextNode(Z)),St.appendChild(Mt),kt&&St.appendChild(document.createTextNode(kt)),(L=d.parentNode)==null||L.replaceChild(St,d),console.log("\u6210\u529F\u5E94\u7528\u6807\u6CE8:",At)})})};r.current=setTimeout(()=>{B()},100)},[j]);return useEffect(()=>{var B;if(A){console.log("[MarkdownContentView] table mode: skip effect, wait for onRendered");return}const U=typeof m.content=="string"?m.content:((B=m.content)==null?void 0:B.content)||"";if(!U||typeof U!="string"){console.log("Markdown\u5185\u5BB9\u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B\uFF0C\u8DF3\u8FC7\u6807\u6CE8\u5E94\u7528");return}if(console.log("=== \u5F00\u59CB\u5E94\u7528Markdown\u6807\u6CE8\u9AD8\u4EAE ==="),console.log("markdownRef.current:",t.current),console.log("isTableMode:",A),console.log("mdAnnotations:",j),console.log("tableAnnotations:",I),console.log("data.content:",m.content),console.log("\u5B9E\u9645\u5185\u5BB9:",U),!t.current){console.log("markdownRef\u4E0D\u5B58\u5728\uFF0C\u9000\u51FA\u6807\u6CE8\u5E94\u7528");return}if(A||yt(),!A&&j.length>0){K();return}console.log("\u6CA1\u6709\u9700\u8981\u5E94\u7528\u7684\u6807\u6CE8")},[A,I,j]),useEffect(()=>{if(!A)return document.addEventListener("mouseup",x),()=>{document.removeEventListener("mouseup",x)}},[x,A]),useEffect(()=>{var B;const U=typeof m.content=="string"?m.content:((B=m.content)==null?void 0:B.content)||"";if(!U||typeof U!="string"){console.log("Markdown\u5185\u5BB9\u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B\uFF0C\u8DF3\u8FC7\u8C03\u8BD5\u4FE1\u606F\u6253\u5370");return}console.log("=== Markdown\u5185\u5BB9\u4FE1\u606F ==="),console.log("isTableMode:",A),console.log("\u5185\u5BB9\u957F\u5EA6:",U.length||0),typeof U=="string"?(console.log("\u5185\u5BB9\u524D100\u5B57\u7B26:",U.substring(0,100)),console.log("\u5185\u5BB9\u540E100\u5B57\u7B26:",U.substring(U.length-100))):(console.log("\u5185\u5BB9\u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B:",typeof U),console.log("\u5185\u5BB9\u503C:",U)),console.log("\u6807\u6CE8\u6570\u636E:",j),console.log("\u8868\u683C\u6807\u6CE8\u6570\u636E:",I)},[j,I,A]),useEffect(()=>{if(A&&t.current){const B=setTimeout(()=>{var U;const G=(U=t.current)==null?void 0:U.querySelectorAll("table");G&&G.length>0&&(console.log("\u8C03\u6574\u8868\u683C\u5C3A\u5BF8\uFF0C\u627E\u5230\u8868\u683C\u6570\u91CF:",G.length),G.forEach((Q,xt)=>{if(Q instanceof HTMLTableElement){Q.style.width="100%",Q.style.minWidth="100%",Q.style.tableLayout="auto";const Rt=Q.closest(".markdown-table-mode");Rt&&Rt instanceof HTMLElement&&(Rt.style.width="100%",Rt.style.overflowX="auto"),console.log(`\u8868\u683C ${xt+1} \u5C3A\u5BF8\u8C03\u6574\u5B8C\u6210`)}}))},500);return()=>clearTimeout(B)}},[A,m.content]),useEffect(()=>()=>{r.current&&clearTimeout(r.current),o.current&&(o.current.disconnect(),o.current=null)},[]),React__default.createElement("div",{style:{height:"100%",width:"100%",overflow:"auto"},className:`markdown-container markdown-scrollbar ${A?"markdown-table-mode":""}`},React__default.createElement("style",null,Le),React__default.createElement("div",{ref:t},React__default.createElement(Hv,{dataSource:{type:ua.MARKDOWN,content:(()=>{var B,U;return typeof m.content=="string"?m.content:(B=m.content)!=null&&B.text?m.content.text:(U=m.content)!=null&&U.content?m.content.content:""})()},size:"md",onScroll:A?void 0:u,onScrollToTop:A?void 0:n,onScrollToBottom:A?void 0:i,onRendered:E,theme:{primaryColor:((V=(_=(f=a.styles)==null?void 0:f.theme)==null?void 0:_.colors)==null?void 0:V.primary)||"#007bff",backgroundColor:((M=(Y=(q=a.styles)==null?void 0:q.theme)==null?void 0:Y.colors)==null?void 0:M.background)||"#f8f9fa",textColor:((P=(w=(b=a.styles)==null?void 0:b.theme)==null?void 0:w.colors)==null?void 0:P.text)||"#343a40",borderColor:((l=(F=(S=a.styles)==null?void 0:S.theme)==null?void 0:F.colors)==null?void 0:l.border)||"#dee2e6",borderRadius:A?"0px":"8px",padding:A?"0px":"20px"},style:{height:"100%",border:"none",background:"transparent",overflowY:A?"visible":"scroll"}})))},Oe=({markdown:m,onRendered:a,tableAnnotations:A=[]})=>{const f=useRef(null),_=q=>{const Y=q.split(/\r?\n/).filter(S=>S.trim().length>0);let M=-1;for(let S=0;S<Y.length-1;S++){const F=Y[S].trim(),l=Y[S+1].trim();if(F.startsWith("|")&&F.endsWith("|")&&l.replace(/\s|:|\|/g,"").match(/^[-]+$/)){M=S;break}}if(M===-1)return null;const b=Y[M].split("|").slice(1,-1).map(S=>S.trim()),w=[];for(let S=M+2;S<Y.length;S++){const F=Y[S].trim();if(!F.startsWith("|")||!F.endsWith("|"))break;w.push(F)}const P=w.map(S=>S.split("|").slice(1,-1).map(F=>F.trim()));return{headers:b,rows:P}},V=React__default.useMemo(()=>_(m),[m]);return useEffect(()=>{const q=()=>{try{if(!f.current)return;const M=f.current.querySelectorAll("table");if(M.forEach(b=>{Array.from(b.rows).forEach(w=>{Array.from(w.cells).forEach(P=>{P.getAttribute("data-table-annotated")==="1"&&(P.style.removeProperty("background"),P.style.removeProperty("background-color"),P.removeAttribute("data-table-annotated"),P.removeAttribute("title"))})})}),!A.length||!M||M.length===0)return;A.forEach((b,w)=>{(b.offsets||[]).forEach((P,S)=>{const[F,l]=P;M.forEach(t=>{var r;const o=Array.from(t.rows)[F];if(!o)return;const v=(r=o.cells)==null?void 0:r[l];if(!v)return;const g=b.color||"rgba(255, 229, 153, 0.5)";v.getAttribute("data-table-annotated")==="1"||(v.style.setProperty("background",g,"important"),v.style.setProperty("background-color",g,"important"),v.setAttribute("data-table-annotated","1"),b.content&&(v.title=b.content)),w===0&&S===0&&setTimeout(()=>v.scrollIntoView({behavior:"smooth",block:"start"}),50)})})})}catch(M){console.warn("[MinimalMarkdownTable] apply annotations failed",M)}},Y=requestAnimationFrame(()=>{q(),a&&a()});return()=>cancelAnimationFrame(Y)},[m,A,a]),V?React__default.createElement("div",{ref:f,className:"markdown-table-mode z-mdtbl-wrapper"},React__default.createElement("style",null,`
170
+ `))},Ie=(m,a)=>{var A,f,_,V,q;console.log("=== Fviewer renderTextContent ==="),console.log("data:",m),console.log("data.content:",m.content);let Y="";typeof m.content=="string"?Y=m.content:(A=m.content)!=null&&A.text?Y=m.content.text:(f=m.content)!=null&&f.content&&(Y=m.content.content),console.log("\u5B9E\u9645\u6587\u672C\u5185\u5BB9:",Y);const M=useRef(null),b=useRef(null);return useEffect(()=>{if(M.current&&b.current&&Y){const w=setTimeout(()=>{var P;const S=((P=M.current)==null?void 0:P.scrollHeight)||0,F=Math.max(S+80,200);b.current&&(b.current.style.minHeight=`${F}px`,console.log("\u6587\u672C\u7EB8\u5F20\u9AD8\u5EA6\u8C03\u6574\u5B8C\u6210:",F))},100);return()=>clearTimeout(w)}},[Y]),React__default.createElement("div",{style:{height:"100%",overflow:"auto",backgroundColor:"#f5f5f5",padding:"20px",display:"flex",justifyContent:"center",position:"relative"}},React__default.createElement("div",{ref:b,style:{width:"100%",maxWidth:"800px",backgroundColor:"white",boxShadow:"0 4px 8px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06)",borderRadius:"8px",padding:"40px",margin:"20px 0",position:"relative",transform:`scale(${a.scale||1})`,transition:"transform 0.2s ease-in-out",transformOrigin:"top center"}},React__default.createElement("div",{ref:M,style:{width:"100%",overflow:"visible"}},React__default.createElement(Hv,{dataSource:{type:la.TEXT,content:Y},size:"md",theme:{primaryColor:((q=(V=(_=a.styles)==null?void 0:_.theme)==null?void 0:V.colors)==null?void 0:q.primary)||"#007bff",backgroundColor:"transparent",textColor:"#333",borderColor:"transparent",borderRadius:"0",padding:"0"},style:{border:"none",background:"transparent",width:"100%",height:"auto",overflow:"visible"}})),React__default.createElement("div",{style:{position:"absolute",top:"0",left:"0",right:"0",height:"2px",background:"linear-gradient(90deg, #e0e0e0 0%, #f0f0f0 50%, #e0e0e0 100%)",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}})))},je=({data:m,parentProps:a,isTableMode:A=!1})=>{var f,_,V,q,Y,M,b,w,P,S,F,l;const t=useRef(null),r=useRef(null),o=useRef(null),v=useRef(!1);useRef(0),useRef(null);const[g]=useState(!1),u=(B,U)=>{console.log("=== Markdownit\u6EDA\u52A8\u4E8B\u4EF6\u89E6\u53D1 ==="),console.log("\u6EDA\u52A8\u4F4D\u7F6E:",{scrollTop:B,scrollHeight:U}),a.eventsEmit&&a.eventsEmit("markdown_scroll",{scrollTop:B,scrollHeight:U})},n=()=>{console.log("=== Markdownit\u6EDA\u52A8\u5230\u9876\u90E8 ==="),a.eventsEmit&&a.eventsEmit("markdown_scroll_to_top")},i=()=>{console.log("=== Markdownit\u6EDA\u52A8\u5230\u5E95\u90E8 ==="),a.eventsEmit&&a.eventsEmit("markdown_scroll_to_bottom")},e=useRef();e.current=B=>{var U,G;try{if(!A)return;const Q=typeof m.content=="string"?m.content:((U=m.content)==null?void 0:U.content)||"";if(!Q||I.length===0)return;const xt=JSON.stringify(I.map(H=>({o:H.offsets,c:H.color}))),Rt=`${Q.length}:${Q.substring(0,64)}:${Q.substring(Q.length-64)}|${xt}`;if(((G=B.dataset)==null?void 0:G.tableAnnoRuntimeSig)===Rt)return;setTimeout(()=>{bt(),B.dataset&&(B.dataset.tableAnnoRuntimeSig=Rt)},50)}catch(Q){console.warn("[MarkdownRendered] apply failed",Q)}};const E=React__default.useCallback(B=>{var U;return(U=e.current)==null?void 0:U.call(e,B)},[]),x=useCallback(()=>{var B;if(!g||!t.current)return;const U=window.getSelection();if(!U||U.isCollapsed)return;const G=U.getRangeAt(0),Q=G.toString().trim();if(!Q)return;const xt=t.current;let Rt=0,H=0;const h=document.createTreeWalker(xt,NodeFilter.SHOW_TEXT,{acceptNode:O=>{var $;return($=O.parentElement)!=null&&$.closest("pre")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let c=h.nextNode();for(;c;){if(c===G.startContainer){H=Rt+G.startOffset;break}Rt+=((B=c.textContent)==null?void 0:B.length)||0,c=h.nextNode()}console.log("\u9009\u4E2D\u6587\u672C\u4FE1\u606F:",{text:Q,startOffset:H,charCount:Rt,container:G.startContainer.textContent});const T={id:`md-anno-${Date.now()}`,start:H,end:H+Q.length,color:"#FFE599"};console.log("\u521B\u5EFA\u65B0\u6807\u6CE8:",T),a.eventsEmit&&a.eventsEmit("md_annotation_add",T),U.removeAllRanges()},[g,a.eventsEmit]),j=A?[]:(a.annotationData||[]).filter(B=>"start"in B&&"end"in B&&!("pageNumber"in B)),I=A?(a.annotationData||[]).filter(B=>"offsets"in B&&Array.isArray(B.offsets)):[],yt=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u6E05\u7A7A\u6240\u6709\u6807\u6CE8 ==="),!t.current){console.log("markdownRef\u4E0D\u5B58\u5728\uFF0C\u65E0\u6CD5\u6E05\u7A7A\u6807\u6CE8");return}const B=t.current.querySelectorAll(".md-annotation");console.log("\u6E05\u7A7AMarkdown\u6807\u6CE8\u6570\u91CF:",B.length),B.length>0&&B.forEach(U=>{const G=U.parentNode;G&&G.replaceChild(document.createTextNode(U.textContent||""),U)}),console.log("\u6240\u6709\u6807\u6CE8\u5DF2\u6E05\u7A7A")},[]),wt=useCallback(()=>{t.current&&(t.current.querySelectorAll("table").forEach(B=>{Array.from(B.rows).forEach(U=>{Array.from(U.cells).forEach(G=>{G.getAttribute("data-table-annotated")==="1"&&(G.style.removeProperty("background"),G.style.removeProperty("background-color"),G.removeAttribute("data-table-annotated"),G.removeAttribute("title"))})})}),console.log("\u5DF2\u6E05\u7A7A\u6240\u6709\u8868\u683C\u6807\u6CE8"))},[]),bt=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u5E94\u7528\u8868\u683C\u6807\u6CE8 ==="),console.log("tableAnnotations:",I),!t.current){console.log("markdownRef\u4E0D\u5B58\u5728\uFF0C\u9000\u51FA");return}if(wt(),!I.length){console.log("\u6CA1\u6709\u8868\u683C\u6807\u6CE8\u6570\u636E\uFF0C\u4EC5\u6E05\u7A7A\u65E7\u6807\u6CE8");return}const B=t.current.querySelectorAll("table");if(console.log("\u627E\u5230\u8868\u683C\u6570\u91CF:",B.length),B.length===0){console.log("\u6CA1\u6709\u627E\u5230\u8868\u683C\u5143\u7D20");return}v.current=!0,I.forEach((U,G)=>{const Q=U.offsets;if(console.log("\u5904\u7406\u8868\u683C\u6807\u6CE8:",U),!Array.isArray(Q)||!Q.length||!Array.isArray(Q[0])||Q[0].length!==2){console.warn("[TableAnnotation] annotation.offsets is not valid",U);return}Q.forEach((xt,Rt)=>{const[H,h]=xt;if(typeof H!="number"||typeof h!="number"){console.warn("[TableAnnotation] offset is not [number, number]",xt);return}B.forEach((c,T)=>{var O;const $=Array.from(c.rows),W=$[H];if(!W){console.warn("[TableAnnotation] row out of range",{row:H,tableIndex:T,totalRows:$.length});return}const s=(O=W.cells)==null?void 0:O[h];if(!s){console.warn("[TableAnnotation] cell is undefined",{row:H,col:h,tableIndex:T});return}const d=U.color||"rgba(255, 229, 153, 0.5)",C=getComputedStyle(s).backgroundColor;s.getAttribute("data-table-annotated")==="1"&&(C===d||s.style.backgroundColor===d)||(s.style.setProperty("background",d,"important"),s.style.setProperty("background-color",d,"important"),s.setAttribute("data-table-annotated","1")),U.content&&(s.title=U.content),Rt===0&&G===0&&setTimeout(()=>{s.scrollIntoView({behavior:"smooth",block:"start"})},300)})})}),requestAnimationFrame(()=>{v.current=!1})},[I,wt]),K=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u5E94\u7528Markdown\u6807\u6CE8 ==="),!t.current||!j.length){console.log("\u6761\u4EF6\u4E0D\u6EE1\u8DB3\uFF0C\u8DF3\u8FC7\u6807\u6CE8\u5E94\u7528");return}r.current&&clearTimeout(r.current);const B=()=>{var U;console.log("\u5F00\u59CB\u5E94\u7528\u6807\u6CE8...");const G=(U=t.current)==null?void 0:U.querySelectorAll(".md-annotation");console.log("\u79FB\u9664\u73B0\u6709\u6807\u6CE8\u6570\u91CF:",(G==null?void 0:G.length)||0),G==null||G.forEach(T=>{const O=T.parentNode;O&&O.replaceChild(document.createTextNode(T.textContent||""),T)});const Q=document.createTreeWalker(t.current,NodeFilter.SHOW_TEXT,{acceptNode:T=>{var O;return(O=T.parentElement)!=null&&O.closest("pre")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),xt=[];let Rt;for(;Rt=Q.nextNode();)xt.push(Rt);if(console.log("\u627E\u5230\u6587\u672C\u8282\u70B9\u6570\u91CF:",xt.length),xt.length===0){console.log("\u6CA1\u6709\u627E\u5230\u6587\u672C\u8282\u70B9\uFF0C\u5EF6\u8FDF\u91CD\u8BD5..."),r.current=setTimeout(()=>{B()},200);return}let H=0;const h=xt.map(T=>{var O;const $=H;return H+=((O=T.textContent)==null?void 0:O.length)||0,{node:T,start:$,end:H,text:T.textContent}});console.log("\u6587\u672C\u8282\u70B9\u4F4D\u7F6E:",h),console.log("\u603B\u6587\u672C\u957F\u5EA6:",H);const c=[...j].sort((T,O)=>O.start-T.start);console.log("\u6392\u5E8F\u540E\u7684\u6807\u6CE8:",c),c.forEach(T=>{const{start:O,end:$,color:W}=T;console.log("\u5904\u7406\u6807\u6CE8:",{annotation:T,nodePositions:h});const s=h.filter(d=>O<d.end&&$>d.start);console.log("\u76F8\u5173\u8282\u70B9\u6570\u91CF:",s.length),s.forEach(({node:d,start:C})=>{var y,k,N,D,p,L;const _t=Math.max(0,O-C),z=Math.min(((y=d.textContent)==null?void 0:y.length)||0,$-C);if(console.log("\u672C\u5730\u4F4D\u7F6E:",{localStart:_t,localEnd:z,nodeTextLength:(k=d.textContent)==null?void 0:k.length}),_t>=z){console.log("\u672C\u5730\u4F4D\u7F6E\u65E0\u6548\uFF0C\u8DF3\u8FC7");return}const Z=((N=d.textContent)==null?void 0:N.slice(0,_t))||"",At=((D=d.textContent)==null?void 0:D.slice(_t,z))||"",kt=((p=d.textContent)==null?void 0:p.slice(z))||"";console.log("\u5206\u5272\u6587\u672C:",{before:Z,annotatedText:At,after:kt});const Mt=document.createElement("span");Mt.className="md-annotation",Mt.style.backgroundColor=W||"#FFE599",Mt.textContent=At;const St=document.createDocumentFragment();Z&&St.appendChild(document.createTextNode(Z)),St.appendChild(Mt),kt&&St.appendChild(document.createTextNode(kt)),(L=d.parentNode)==null||L.replaceChild(St,d),console.log("\u6210\u529F\u5E94\u7528\u6807\u6CE8:",At)})})};r.current=setTimeout(()=>{B()},100)},[j]);return useEffect(()=>{var B;if(A){console.log("[MarkdownContentView] table mode: skip effect, wait for onRendered");return}const U=typeof m.content=="string"?m.content:((B=m.content)==null?void 0:B.content)||"";if(!U||typeof U!="string"){console.log("Markdown\u5185\u5BB9\u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B\uFF0C\u8DF3\u8FC7\u6807\u6CE8\u5E94\u7528");return}if(console.log("=== \u5F00\u59CB\u5E94\u7528Markdown\u6807\u6CE8\u9AD8\u4EAE ==="),console.log("markdownRef.current:",t.current),console.log("isTableMode:",A),console.log("mdAnnotations:",j),console.log("tableAnnotations:",I),console.log("data.content:",m.content),console.log("\u5B9E\u9645\u5185\u5BB9:",U),!t.current){console.log("markdownRef\u4E0D\u5B58\u5728\uFF0C\u9000\u51FA\u6807\u6CE8\u5E94\u7528");return}if(A||yt(),!A&&j.length>0){K();return}console.log("\u6CA1\u6709\u9700\u8981\u5E94\u7528\u7684\u6807\u6CE8")},[A,I,j]),useEffect(()=>{if(!A)return document.addEventListener("mouseup",x),()=>{document.removeEventListener("mouseup",x)}},[x,A]),useEffect(()=>{var B;const U=typeof m.content=="string"?m.content:((B=m.content)==null?void 0:B.content)||"";if(!U||typeof U!="string"){console.log("Markdown\u5185\u5BB9\u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B\uFF0C\u8DF3\u8FC7\u8C03\u8BD5\u4FE1\u606F\u6253\u5370");return}console.log("=== Markdown\u5185\u5BB9\u4FE1\u606F ==="),console.log("isTableMode:",A),console.log("\u5185\u5BB9\u957F\u5EA6:",U.length||0),typeof U=="string"?(console.log("\u5185\u5BB9\u524D100\u5B57\u7B26:",U.substring(0,100)),console.log("\u5185\u5BB9\u540E100\u5B57\u7B26:",U.substring(U.length-100))):(console.log("\u5185\u5BB9\u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B:",typeof U),console.log("\u5185\u5BB9\u503C:",U)),console.log("\u6807\u6CE8\u6570\u636E:",j),console.log("\u8868\u683C\u6807\u6CE8\u6570\u636E:",I)},[j,I,A]),useEffect(()=>{if(A&&t.current){const B=setTimeout(()=>{var U;const G=(U=t.current)==null?void 0:U.querySelectorAll("table");G&&G.length>0&&(console.log("\u8C03\u6574\u8868\u683C\u5C3A\u5BF8\uFF0C\u627E\u5230\u8868\u683C\u6570\u91CF:",G.length),G.forEach((Q,xt)=>{if(Q instanceof HTMLTableElement){Q.style.width="100%",Q.style.minWidth="100%",Q.style.tableLayout="auto";const Rt=Q.closest(".markdown-table-mode");Rt&&Rt instanceof HTMLElement&&(Rt.style.width="100%",Rt.style.overflowX="auto"),console.log(`\u8868\u683C ${xt+1} \u5C3A\u5BF8\u8C03\u6574\u5B8C\u6210`)}}))},500);return()=>clearTimeout(B)}},[A,m.content]),useEffect(()=>()=>{r.current&&clearTimeout(r.current),o.current&&(o.current.disconnect(),o.current=null)},[]),React__default.createElement("div",{style:{height:"100%",width:"100%",overflow:"auto"},className:`markdown-container markdown-scrollbar ${A?"markdown-table-mode":""}`},React__default.createElement("style",null,Le),React__default.createElement("div",{ref:t},React__default.createElement(Hv,{dataSource:{type:la.MARKDOWN,content:(()=>{var B,U;return typeof m.content=="string"?m.content:(B=m.content)!=null&&B.text?m.content.text:(U=m.content)!=null&&U.content?m.content.content:""})()},size:"md",onScroll:A?void 0:u,onScrollToTop:A?void 0:n,onScrollToBottom:A?void 0:i,onRendered:E,theme:{primaryColor:((V=(_=(f=a.styles)==null?void 0:f.theme)==null?void 0:_.colors)==null?void 0:V.primary)||"#007bff",backgroundColor:((M=(Y=(q=a.styles)==null?void 0:q.theme)==null?void 0:Y.colors)==null?void 0:M.background)||"#f8f9fa",textColor:((P=(w=(b=a.styles)==null?void 0:b.theme)==null?void 0:w.colors)==null?void 0:P.text)||"#343a40",borderColor:((l=(F=(S=a.styles)==null?void 0:S.theme)==null?void 0:F.colors)==null?void 0:l.border)||"#dee2e6",borderRadius:A?"0px":"8px",padding:A?"0px":"20px"},style:{height:"100%",border:"none",background:"transparent",overflowY:A?"visible":"scroll"}})))},Oe=({markdown:m,onRendered:a,tableAnnotations:A=[]})=>{const f=useRef(null),_=q=>{const Y=q.split(/\r?\n/).filter(S=>S.trim().length>0);let M=-1;for(let S=0;S<Y.length-1;S++){const F=Y[S].trim(),l=Y[S+1].trim();if(F.startsWith("|")&&F.endsWith("|")&&l.replace(/\s|:|\|/g,"").match(/^[-]+$/)){M=S;break}}if(M===-1)return null;const b=Y[M].split("|").slice(1,-1).map(S=>S.trim()),w=[];for(let S=M+2;S<Y.length;S++){const F=Y[S].trim();if(!F.startsWith("|")||!F.endsWith("|"))break;w.push(F)}const P=w.map(S=>S.split("|").slice(1,-1).map(F=>F.trim()));return{headers:b,rows:P}},V=React__default.useMemo(()=>_(m),[m]);return useEffect(()=>{const q=()=>{try{if(!f.current)return;const M=f.current.querySelectorAll("table");if(M.forEach(b=>{Array.from(b.rows).forEach(w=>{Array.from(w.cells).forEach(P=>{P.getAttribute("data-table-annotated")==="1"&&(P.style.removeProperty("background"),P.style.removeProperty("background-color"),P.removeAttribute("data-table-annotated"),P.removeAttribute("title"))})})}),!A.length||!M||M.length===0)return;A.forEach((b,w)=>{(b.offsets||[]).forEach((P,S)=>{const[F,l]=P;M.forEach(t=>{var r;const o=Array.from(t.rows)[F];if(!o)return;const v=(r=o.cells)==null?void 0:r[l];if(!v)return;const g=b.color||"rgba(255, 229, 153, 0.5)";v.getAttribute("data-table-annotated")==="1"||(v.style.setProperty("background",g,"important"),v.style.setProperty("background-color",g,"important"),v.setAttribute("data-table-annotated","1"),b.content&&(v.title=b.content)),w===0&&S===0&&setTimeout(()=>v.scrollIntoView({behavior:"smooth",block:"start"}),50)})})})}catch(M){console.warn("[MinimalMarkdownTable] apply annotations failed",M)}},Y=requestAnimationFrame(()=>{q(),a&&a()});return()=>cancelAnimationFrame(Y)},[m,A,a]),V?React__default.createElement("div",{ref:f,className:"markdown-table-mode z-mdtbl-wrapper"},React__default.createElement("style",null,`
171
171
  .z-mdtbl-wrapper { overflow: auto; position: relative; }
172
172
  .z-mdtbl { border-collapse: separate; border-spacing: 0; background: transparent; box-shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06); border-radius: 8px; }
173
173
  .z-mdtbl th, .z-mdtbl td { border: 1px solid #e5e7eb; padding: 10px 14px; font-size: 13px; line-height: 1.4; color: inherit; }