@gientech/modual 2.1.5 → 2.1.7
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.
- package/assets/{GientechStreamReader-BNmU0LBA.js → GientechStreamReader-BIqz7y-K.js} +2 -2
- package/assets/{index-CylvlTze.js → index--36xNiIQ.js} +1 -1
- package/assets/{index-DpPJXfkL.js → index-DDz1HJaH.js} +1 -1
- package/assets/index-DzFAvwdY.js +1290 -0
- package/assets/index-FiQVX63z.js +1593 -0
- package/assets/style.css +1 -1
- package/chat.js +113 -113
- package/database.js +1 -1
- package/databaseId.js +1 -1
- package/databaseTable.js +1 -1
- package/index.js +1 -1
- package/modelManage.js +1 -1
- package/package.json +1 -1
- package/sensitive.js +1 -1
- package/streamFilesReader.js +1 -1
- package/assets/index-CSTEY8Na.js +0 -1712
- package/assets/index-KS1Q_mqd.js +0 -1290
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var zn=Object.defineProperty;var Sn=m=>{throw TypeError(m)};var Gn=(m,a,A)=>a in m?zn(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{a as createLucideIcon,a7 as getAugmentedNamespace,d as dt$1,b as axios}from"./index-BRq6VK9v.js";import{
|
|
1
|
+
var zn=Object.defineProperty;var Sn=m=>{throw TypeError(m)};var Gn=(m,a,A)=>a in m?zn(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{a as createLucideIcon,a7 as getAugmentedNamespace,d as dt$1,b as axios}from"./index-BRq6VK9v.js";import{O as O7,X as Xa}from"./index-FiQVX63z.js";import{c as ChevronRight}from"./index-DzFAvwdY.js";import{X}from"./x-D-pV1NCt.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 zn=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
|
-
`))},We=(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 F=((P=M.current)==null?void 0:P.scrollHeight)||0,S=Math.max(F+80,200);b.current&&(b.current.style.minHeight=`${S}px`,console.log("\u6587\u672C\u7EB8\u5F20\u9AD8\u5EA6\u8C03\u6574\u5B8C\u6210:",S))},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(l8,{dataSource:{type:Ka.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,F,S,c;const t=useRef(null),s=useRef(null),o=useRef(null),v=useRef(!1);useRef(0),useRef(null);const[g]=useState(!1),l=(N,U)=>{console.log("=== Markdownit\u6EDA\u52A8\u4E8B\u4EF6\u89E6\u53D1 ==="),console.log("\u6EDA\u52A8\u4F4D\u7F6E:",{scrollTop:N,scrollHeight:U}),a.eventsEmit&&a.eventsEmit("markdown_scroll",{scrollTop:N,scrollHeight:U})},n=()=>{console.log("=== Markdownit\u6EDA\u52A8\u5230\u9876\u90E8 ==="),a.eventsEmit&&a.eventsEmit("markdown_scroll_to_top")},r=()=>{console.log("=== Markdownit\u6EDA\u52A8\u5230\u5E95\u90E8 ==="),a.eventsEmit&&a.eventsEmit("markdown_scroll_to_bottom")},e=useRef();e.current=N=>{var U,G;try{if(!A)return;const bt=typeof m.content=="string"?m.content:((U=m.content)==null?void 0:U.content)||"";if(!bt||O.length===0)return;const wt=JSON.stringify(O.map(H=>({o:H.offsets,c:H.color}))),Mt=`${bt.length}:${bt.substring(0,64)}:${bt.substring(bt.length-64)}|${wt}`;if(((G=N.dataset)==null?void 0:G.tableAnnoRuntimeSig)===Mt)return;setTimeout(()=>{pt(),N.dataset&&(N.dataset.tableAnnoRuntimeSig=Mt)},50)}catch(bt){console.warn("[MarkdownRendered] apply failed",bt)}};const E=React__default.useCallback(N=>{var U;return(U=e.current)==null?void 0:U.call(e,N)},[]),x=useCallback(()=>{var N;if(!g||!t.current)return;const U=window.getSelection();if(!U||U.isCollapsed)return;const G=U.getRangeAt(0),bt=G.toString().trim();if(!bt)return;const wt=t.current;let Mt=0,H=0;const h=document.createTreeWalker(wt,NodeFilter.SHOW_TEXT,{acceptNode:I=>{var $;return($=I.parentElement)!=null&&$.closest("pre")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let u=h.nextNode();for(;u;){if(u===G.startContainer){H=Mt+G.startOffset;break}Mt+=((N=u.textContent)==null?void 0:N.length)||0,u=h.nextNode()}console.log("\u9009\u4E2D\u6587\u672C\u4FE1\u606F:",{text:bt,startOffset:H,charCount:Mt,container:G.startContainer.textContent});const T={id:`md-anno-${Date.now()}`,start:H,end:H+bt.length,color:"#FFE599"};console.log("\u521B\u5EFA\u65B0\u6807\u6CE8:",T),a.eventsEmit&&a.eventsEmit("md_annotation_add",T),U.removeAllRanges()},[g,a.eventsEmit]),L=A?[]:(a.annotationData||[]).filter(N=>"start"in N&&"end"in N&&!("pageNumber"in N)),O=A?(a.annotationData||[]).filter(N=>"offsets"in N&&Array.isArray(N.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 N=t.current.querySelectorAll(".md-annotation");console.log("\u6E05\u7A7AMarkdown\u6807\u6CE8\u6570\u91CF:",N.length),N.length>0&&N.forEach(U=>{const G=U.parentNode;G&&G.replaceChild(document.createTextNode(U.textContent||""),U)}),console.log("\u6240\u6709\u6807\u6CE8\u5DF2\u6E05\u7A7A")},[]),St=useCallback(()=>{t.current&&(t.current.querySelectorAll("table").forEach(N=>{Array.from(N.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"))},[]),pt=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u5E94\u7528\u8868\u683C\u6807\u6CE8 ==="),console.log("tableAnnotations:",O),!t.current){console.log("markdownRef\u4E0D\u5B58\u5728\uFF0C\u9000\u51FA");return}if(St(),!O.length){console.log("\u6CA1\u6709\u8868\u683C\u6807\u6CE8\u6570\u636E\uFF0C\u4EC5\u6E05\u7A7A\u65E7\u6807\u6CE8");return}const N=t.current.querySelectorAll("table");if(console.log("\u627E\u5230\u8868\u683C\u6570\u91CF:",N.length),N.length===0){console.log("\u6CA1\u6709\u627E\u5230\u8868\u683C\u5143\u7D20");return}v.current=!0,O.forEach((U,G)=>{const bt=U.offsets;if(console.log("\u5904\u7406\u8868\u683C\u6807\u6CE8:",U),!Array.isArray(bt)||!bt.length||!Array.isArray(bt[0])||bt[0].length!==2){console.warn("[TableAnnotation] annotation.offsets is not valid",U);return}bt.forEach((wt,Mt)=>{const[H,h]=wt;if(typeof H!="number"||typeof h!="number"){console.warn("[TableAnnotation] offset is not [number, number]",wt);return}N.forEach((u,T)=>{var I;const $=Array.from(u.rows),W=$[H];if(!W){console.warn("[TableAnnotation] row out of range",{row:H,tableIndex:T,totalRows:$.length});return}const i=(I=W.cells)==null?void 0:I[h];if(!i){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(i).backgroundColor;i.getAttribute("data-table-annotated")==="1"&&(C===d||i.style.backgroundColor===d)||(i.style.setProperty("background",d,"important"),i.style.setProperty("background-color",d,"important"),i.setAttribute("data-table-annotated","1")),U.content&&(i.title=U.content),Mt===0&&G===0&&setTimeout(()=>{i.scrollIntoView({behavior:"smooth",block:"start"})},300)})})}),requestAnimationFrame(()=>{v.current=!1})},[O,St]),K=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u5E94\u7528Markdown\u6807\u6CE8 ==="),!t.current||!L.length){console.log("\u6761\u4EF6\u4E0D\u6EE1\u8DB3\uFF0C\u8DF3\u8FC7\u6807\u6CE8\u5E94\u7528");return}s.current&&clearTimeout(s.current);const N=()=>{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 I=T.parentNode;I&&I.replaceChild(document.createTextNode(T.textContent||""),T)});const bt=document.createTreeWalker(t.current,NodeFilter.SHOW_TEXT,{acceptNode:T=>{var I;return(I=T.parentElement)!=null&&I.closest("pre")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),wt=[];let Mt;for(;Mt=bt.nextNode();)wt.push(Mt);if(console.log("\u627E\u5230\u6587\u672C\u8282\u70B9\u6570\u91CF:",wt.length),wt.length===0){console.log("\u6CA1\u6709\u627E\u5230\u6587\u672C\u8282\u70B9\uFF0C\u5EF6\u8FDF\u91CD\u8BD5..."),s.current=setTimeout(()=>{N()},200);return}let H=0;const h=wt.map(T=>{var I;const $=H;return H+=((I=T.textContent)==null?void 0:I.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 u=[...L].sort((T,I)=>I.start-T.start);console.log("\u6392\u5E8F\u540E\u7684\u6807\u6CE8:",u),u.forEach(T=>{const{start:I,end:$,color:W}=T;console.log("\u5904\u7406\u6807\u6CE8:",{annotation:T,nodePositions:h});const i=h.filter(d=>I<d.end&&$>d.start);console.log("\u76F8\u5173\u8282\u70B9\u6570\u91CF:",i.length),i.forEach(({node:d,start:C})=>{var y,k,j,D,p,B;const _t=Math.max(0,I-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 Q=((j=d.textContent)==null?void 0:j.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:Q,annotatedText:At,after:kt});const Rt=document.createElement("span");Rt.className="md-annotation",Rt.style.backgroundColor=W||"#FFE599",Rt.textContent=At;const xt=document.createDocumentFragment();Q&&xt.appendChild(document.createTextNode(Q)),xt.appendChild(Rt),kt&&xt.appendChild(document.createTextNode(kt)),(B=d.parentNode)==null||B.replaceChild(xt,d),console.log("\u6210\u529F\u5E94\u7528\u6807\u6CE8:",At)})})};s.current=setTimeout(()=>{N()},100)},[L]);return useEffect(()=>{var N;if(A){console.log("[MarkdownContentView] table mode: skip effect, wait for onRendered");return}const U=typeof m.content=="string"?m.content:((N=m.content)==null?void 0:N.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:",L),console.log("tableAnnotations:",O),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&&L.length>0){K();return}console.log("\u6CA1\u6709\u9700\u8981\u5E94\u7528\u7684\u6807\u6CE8")},[A,O,L]),useEffect(()=>{if(!A)return document.addEventListener("mouseup",x),()=>{document.removeEventListener("mouseup",x)}},[x,A]),useEffect(()=>{var N;const U=typeof m.content=="string"?m.content:((N=m.content)==null?void 0:N.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:",L),console.log("\u8868\u683C\u6807\u6CE8\u6570\u636E:",O)},[L,O,A]),useEffect(()=>{if(A&&t.current){const N=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((bt,wt)=>{if(bt instanceof HTMLTableElement){bt.style.width="100%",bt.style.minWidth="100%",bt.style.tableLayout="auto";const Mt=bt.closest(".markdown-table-mode");Mt&&Mt instanceof HTMLElement&&(Mt.style.width="100%",Mt.style.overflowX="auto"),console.log(`\u8868\u683C ${wt+1} \u5C3A\u5BF8\u8C03\u6574\u5B8C\u6210`)}}))},500);return()=>clearTimeout(N)}},[A,m.content]),useEffect(()=>()=>{s.current&&clearTimeout(s.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(l8,{dataSource:{type:Ka.MARKDOWN,content:(()=>{var N,U;return typeof m.content=="string"?m.content:(N=m.content)!=null&&N.text?m.content.text:(U=m.content)!=null&&U.content?m.content.content:""})()},size:"md",onScroll:A?void 0:l,onScrollToTop:A?void 0:n,onScrollToBottom:A?void 0:r,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:((c=(S=(F=a.styles)==null?void 0:F.theme)==null?void 0:S.colors)==null?void 0:c.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(F=>F.trim().length>0);let M=-1;for(let F=0;F<Y.length-1;F++){const S=Y[F].trim(),c=Y[F+1].trim();if(S.startsWith("|")&&S.endsWith("|")&&c.replace(/\s|:|\|/g,"").match(/^[-]+$/)){M=F;break}}if(M===-1)return null;const b=Y[M].split("|").slice(1,-1).map(F=>F.trim()),w=[];for(let F=M+2;F<Y.length;F++){const S=Y[F].trim();if(!S.startsWith("|")||!S.endsWith("|"))break;w.push(S)}const P=w.map(F=>F.split("|").slice(1,-1).map(S=>S.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,F)=>{const[S,c]=P;M.forEach(t=>{var s;const o=Array.from(t.rows)[S];if(!o)return;const v=(s=o.cells)==null?void 0:s[c];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&&F===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
|
+
`))},We=(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 F=((P=M.current)==null?void 0:P.scrollHeight)||0,S=Math.max(F+80,200);b.current&&(b.current.style.minHeight=`${S}px`,console.log("\u6587\u672C\u7EB8\u5F20\u9AD8\u5EA6\u8C03\u6574\u5B8C\u6210:",S))},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(O7,{dataSource:{type:Xa.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,F,S,c;const t=useRef(null),s=useRef(null),o=useRef(null),v=useRef(!1);useRef(0),useRef(null);const[g]=useState(!1),l=(N,U)=>{console.log("=== Markdownit\u6EDA\u52A8\u4E8B\u4EF6\u89E6\u53D1 ==="),console.log("\u6EDA\u52A8\u4F4D\u7F6E:",{scrollTop:N,scrollHeight:U}),a.eventsEmit&&a.eventsEmit("markdown_scroll",{scrollTop:N,scrollHeight:U})},n=()=>{console.log("=== Markdownit\u6EDA\u52A8\u5230\u9876\u90E8 ==="),a.eventsEmit&&a.eventsEmit("markdown_scroll_to_top")},r=()=>{console.log("=== Markdownit\u6EDA\u52A8\u5230\u5E95\u90E8 ==="),a.eventsEmit&&a.eventsEmit("markdown_scroll_to_bottom")},e=useRef();e.current=N=>{var U,G;try{if(!A)return;const bt=typeof m.content=="string"?m.content:((U=m.content)==null?void 0:U.content)||"";if(!bt||O.length===0)return;const wt=JSON.stringify(O.map(H=>({o:H.offsets,c:H.color}))),Mt=`${bt.length}:${bt.substring(0,64)}:${bt.substring(bt.length-64)}|${wt}`;if(((G=N.dataset)==null?void 0:G.tableAnnoRuntimeSig)===Mt)return;setTimeout(()=>{pt(),N.dataset&&(N.dataset.tableAnnoRuntimeSig=Mt)},50)}catch(bt){console.warn("[MarkdownRendered] apply failed",bt)}};const E=React__default.useCallback(N=>{var U;return(U=e.current)==null?void 0:U.call(e,N)},[]),x=useCallback(()=>{var N;if(!g||!t.current)return;const U=window.getSelection();if(!U||U.isCollapsed)return;const G=U.getRangeAt(0),bt=G.toString().trim();if(!bt)return;const wt=t.current;let Mt=0,H=0;const h=document.createTreeWalker(wt,NodeFilter.SHOW_TEXT,{acceptNode:I=>{var $;return($=I.parentElement)!=null&&$.closest("pre")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let u=h.nextNode();for(;u;){if(u===G.startContainer){H=Mt+G.startOffset;break}Mt+=((N=u.textContent)==null?void 0:N.length)||0,u=h.nextNode()}console.log("\u9009\u4E2D\u6587\u672C\u4FE1\u606F:",{text:bt,startOffset:H,charCount:Mt,container:G.startContainer.textContent});const T={id:`md-anno-${Date.now()}`,start:H,end:H+bt.length,color:"#FFE599"};console.log("\u521B\u5EFA\u65B0\u6807\u6CE8:",T),a.eventsEmit&&a.eventsEmit("md_annotation_add",T),U.removeAllRanges()},[g,a.eventsEmit]),L=A?[]:(a.annotationData||[]).filter(N=>"start"in N&&"end"in N&&!("pageNumber"in N)),O=A?(a.annotationData||[]).filter(N=>"offsets"in N&&Array.isArray(N.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 N=t.current.querySelectorAll(".md-annotation");console.log("\u6E05\u7A7AMarkdown\u6807\u6CE8\u6570\u91CF:",N.length),N.length>0&&N.forEach(U=>{const G=U.parentNode;G&&G.replaceChild(document.createTextNode(U.textContent||""),U)}),console.log("\u6240\u6709\u6807\u6CE8\u5DF2\u6E05\u7A7A")},[]),St=useCallback(()=>{t.current&&(t.current.querySelectorAll("table").forEach(N=>{Array.from(N.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"))},[]),pt=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u5E94\u7528\u8868\u683C\u6807\u6CE8 ==="),console.log("tableAnnotations:",O),!t.current){console.log("markdownRef\u4E0D\u5B58\u5728\uFF0C\u9000\u51FA");return}if(St(),!O.length){console.log("\u6CA1\u6709\u8868\u683C\u6807\u6CE8\u6570\u636E\uFF0C\u4EC5\u6E05\u7A7A\u65E7\u6807\u6CE8");return}const N=t.current.querySelectorAll("table");if(console.log("\u627E\u5230\u8868\u683C\u6570\u91CF:",N.length),N.length===0){console.log("\u6CA1\u6709\u627E\u5230\u8868\u683C\u5143\u7D20");return}v.current=!0,O.forEach((U,G)=>{const bt=U.offsets;if(console.log("\u5904\u7406\u8868\u683C\u6807\u6CE8:",U),!Array.isArray(bt)||!bt.length||!Array.isArray(bt[0])||bt[0].length!==2){console.warn("[TableAnnotation] annotation.offsets is not valid",U);return}bt.forEach((wt,Mt)=>{const[H,h]=wt;if(typeof H!="number"||typeof h!="number"){console.warn("[TableAnnotation] offset is not [number, number]",wt);return}N.forEach((u,T)=>{var I;const $=Array.from(u.rows),W=$[H];if(!W){console.warn("[TableAnnotation] row out of range",{row:H,tableIndex:T,totalRows:$.length});return}const i=(I=W.cells)==null?void 0:I[h];if(!i){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(i).backgroundColor;i.getAttribute("data-table-annotated")==="1"&&(C===d||i.style.backgroundColor===d)||(i.style.setProperty("background",d,"important"),i.style.setProperty("background-color",d,"important"),i.setAttribute("data-table-annotated","1")),U.content&&(i.title=U.content),Mt===0&&G===0&&setTimeout(()=>{i.scrollIntoView({behavior:"smooth",block:"start"})},300)})})}),requestAnimationFrame(()=>{v.current=!1})},[O,St]),K=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u5E94\u7528Markdown\u6807\u6CE8 ==="),!t.current||!L.length){console.log("\u6761\u4EF6\u4E0D\u6EE1\u8DB3\uFF0C\u8DF3\u8FC7\u6807\u6CE8\u5E94\u7528");return}s.current&&clearTimeout(s.current);const N=()=>{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 I=T.parentNode;I&&I.replaceChild(document.createTextNode(T.textContent||""),T)});const bt=document.createTreeWalker(t.current,NodeFilter.SHOW_TEXT,{acceptNode:T=>{var I;return(I=T.parentElement)!=null&&I.closest("pre")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),wt=[];let Mt;for(;Mt=bt.nextNode();)wt.push(Mt);if(console.log("\u627E\u5230\u6587\u672C\u8282\u70B9\u6570\u91CF:",wt.length),wt.length===0){console.log("\u6CA1\u6709\u627E\u5230\u6587\u672C\u8282\u70B9\uFF0C\u5EF6\u8FDF\u91CD\u8BD5..."),s.current=setTimeout(()=>{N()},200);return}let H=0;const h=wt.map(T=>{var I;const $=H;return H+=((I=T.textContent)==null?void 0:I.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 u=[...L].sort((T,I)=>I.start-T.start);console.log("\u6392\u5E8F\u540E\u7684\u6807\u6CE8:",u),u.forEach(T=>{const{start:I,end:$,color:W}=T;console.log("\u5904\u7406\u6807\u6CE8:",{annotation:T,nodePositions:h});const i=h.filter(d=>I<d.end&&$>d.start);console.log("\u76F8\u5173\u8282\u70B9\u6570\u91CF:",i.length),i.forEach(({node:d,start:C})=>{var y,k,j,D,p,B;const _t=Math.max(0,I-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 Q=((j=d.textContent)==null?void 0:j.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:Q,annotatedText:At,after:kt});const Rt=document.createElement("span");Rt.className="md-annotation",Rt.style.backgroundColor=W||"#FFE599",Rt.textContent=At;const xt=document.createDocumentFragment();Q&&xt.appendChild(document.createTextNode(Q)),xt.appendChild(Rt),kt&&xt.appendChild(document.createTextNode(kt)),(B=d.parentNode)==null||B.replaceChild(xt,d),console.log("\u6210\u529F\u5E94\u7528\u6807\u6CE8:",At)})})};s.current=setTimeout(()=>{N()},100)},[L]);return useEffect(()=>{var N;if(A){console.log("[MarkdownContentView] table mode: skip effect, wait for onRendered");return}const U=typeof m.content=="string"?m.content:((N=m.content)==null?void 0:N.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:",L),console.log("tableAnnotations:",O),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&&L.length>0){K();return}console.log("\u6CA1\u6709\u9700\u8981\u5E94\u7528\u7684\u6807\u6CE8")},[A,O,L]),useEffect(()=>{if(!A)return document.addEventListener("mouseup",x),()=>{document.removeEventListener("mouseup",x)}},[x,A]),useEffect(()=>{var N;const U=typeof m.content=="string"?m.content:((N=m.content)==null?void 0:N.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:",L),console.log("\u8868\u683C\u6807\u6CE8\u6570\u636E:",O)},[L,O,A]),useEffect(()=>{if(A&&t.current){const N=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((bt,wt)=>{if(bt instanceof HTMLTableElement){bt.style.width="100%",bt.style.minWidth="100%",bt.style.tableLayout="auto";const Mt=bt.closest(".markdown-table-mode");Mt&&Mt instanceof HTMLElement&&(Mt.style.width="100%",Mt.style.overflowX="auto"),console.log(`\u8868\u683C ${wt+1} \u5C3A\u5BF8\u8C03\u6574\u5B8C\u6210`)}}))},500);return()=>clearTimeout(N)}},[A,m.content]),useEffect(()=>()=>{s.current&&clearTimeout(s.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(O7,{dataSource:{type:Xa.MARKDOWN,content:(()=>{var N,U;return typeof m.content=="string"?m.content:(N=m.content)!=null&&N.text?m.content.text:(U=m.content)!=null&&U.content?m.content.content:""})()},size:"md",onScroll:A?void 0:l,onScrollToTop:A?void 0:n,onScrollToBottom:A?void 0:r,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:((c=(S=(F=a.styles)==null?void 0:F.theme)==null?void 0:S.colors)==null?void 0:c.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(F=>F.trim().length>0);let M=-1;for(let F=0;F<Y.length-1;F++){const S=Y[F].trim(),c=Y[F+1].trim();if(S.startsWith("|")&&S.endsWith("|")&&c.replace(/\s|:|\|/g,"").match(/^[-]+$/)){M=F;break}}if(M===-1)return null;const b=Y[M].split("|").slice(1,-1).map(F=>F.trim()),w=[];for(let F=M+2;F<Y.length;F++){const S=Y[F].trim();if(!S.startsWith("|")||!S.endsWith("|"))break;w.push(S)}const P=w.map(F=>F.split("|").slice(1,-1).map(S=>S.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,F)=>{const[S,c]=P;M.forEach(t=>{var s;const o=Array.from(t.rows)[S];if(!o)return;const v=(s=o.cells)==null?void 0:s[c];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&&F===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; }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as a,jsxs as O,Fragment as he}from"react/jsx-runtime";import*as j from"react";import{isValidElement as $e,useMemo as ie,useState as h,useRef as Ce,useCallback as ue,useEffect as xe}from"react";import{u as Ve}from"./index-CpW6Dhpp.js";import{F as Pe,J as K,C as Re,T as je,U as We,m as Ue}from"./index-
|
|
1
|
+
import{jsx as a,jsxs as O,Fragment as he}from"react/jsx-runtime";import*as j from"react";import{isValidElement as $e,useMemo as ie,useState as h,useRef as Ce,useCallback as ue,useEffect as xe}from"react";import{u as Ve}from"./index-CpW6Dhpp.js";import{F as Pe,J as K,C as Re,T as je,U as We,m as Ue}from"./index-DzFAvwdY.js";import{a as He,g as Ge,m as Ze,$ as qe,a0 as Ye,r as Ke,a1 as Xe,a2 as Je,a3 as Qe,l as et,f as le,a4 as tt,u as ut,a5 as at,T as ce,Z as st,o as ot,M as nt,b as rt,a6 as it,i as be}from"./index-BRq6VK9v.js";import{O as we}from"./index-DDz1HJaH.js";/* empty css */import{s as Y,M as ye}from"./style-CRg0RQug.js";import{M as ke}from"./index-FiQVX63z.js";import{D as Ie}from"./index-BQi5haCb.js";import{X as ge}from"./x-D-pV1NCt.js";import"react-dom";import{B as De,T as Te}from"./index-BfDZSwG3.js";/**
|
|
2
2
|
* @license lucide-react v0.456.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsxs as Ee,jsx as B,Fragment as _l}from"react/jsx-runtime";import*as p from"react";import X,{forwardRef as sr,createElement as Ya,version as dm,useMemo as _t,useState as vt,useRef as Pe,useCallback as Xe,useEffect as wt,useImperativeHandle as Ki,createContext as Li,useContext as An,Children as fm,useLayoutEffect as pm,isValidElement as mm}from"react";import{l as gm,b as hm,a as vm,J as ym,i as bm}from"./index-
|
|
1
|
+
import{jsxs as Ee,jsx as B,Fragment as _l}from"react/jsx-runtime";import*as p from"react";import X,{forwardRef as sr,createElement as Ya,version as dm,useMemo as _t,useState as vt,useRef as Pe,useCallback as Xe,useEffect as wt,useImperativeHandle as Ki,createContext as Li,useContext as An,Children as fm,useLayoutEffect as pm,isValidElement as mm}from"react";import{l as gm,b as hm,a as vm,J as ym,i as bm}from"./index-DzFAvwdY.js";import{d as Ht,c as xm,h as Cm,i as Js}from"./index-BRq6VK9v.js";import"./style-CRg0RQug.js";import*as wm from"react-dom";import $s,{flushSync as Xa,createPortal as dd,unstable_batchedUpdates as km}from"react-dom";var Gr=(e=>(e.FLAT="files",e.NAV="nav",e))(Gr||{});const Em=()=>B("div",{className:"main relative h-full w-full flex items-center justify-center",children:B("div",{className:"text-2xl font-bold",children:"\u5E94\u7528\u52A0\u8F7D\u4E2D..."})}),Sm=()=>B("div",{className:"main relative h-full w-full flex items-center justify-center",children:B("div",{className:"text-2xl font-bold",children:"\u5E94\u7528\u9519\u8BEF"})}),Am=()=>B("div",{className:"main relative h-full w-full flex items-center justify-center",children:B("div",{className:"text-lg font-medium",children:"\u5BB9\u5668\u52A0\u8F7D\u4E2D..."})}),Om=()=>B("div",{className:"main relative h-full w-full flex items-center justify-center",children:B("div",{className:"text-lg font-medium",children:"\u5BB9\u5668\u9519\u8BEF"})}),Im=()=>B("div",{className:"main relative h-full w-full flex items-center justify-center",children:B("div",{className:"text-base font-medium",children:"\u5185\u5BB9\u52A0\u8F7D\u4E2D..."})}),Nm=()=>B("div",{className:"main relative h-full w-full flex items-center justify-center",children:B("div",{className:"text-base font-medium",children:"\u5185\u5BB9\u9519\u8BEF"})}),Mm=({viewType:e,cardType:t})=>Ee("div",{className:"main relative h-full w-full flex flex-col items-center justify-center",children:[B("div",{className:"text-6xl mb-4",style:{color:"#d1d5db"},children:"\u{1F4ED}"}),B("div",{className:"text-lg font-medium mb-2",style:{color:"#6b7280"},children:e==="card"?"\u6682\u65E0\u6570\u636E":e==="table"?"\u6682\u65E0\u8868\u683C\u6570\u636E":"\u6682\u65E0\u6570\u636E"}),B("div",{className:"text-sm",style:{color:"#9ca3af"},children:e==="card"?"\u70B9\u51FB\u4E0A\u65B9\u6309\u94AE\u6DFB\u52A0\u6570\u636E":e==="table"?"\u8BF7\u5148\u6DFB\u52A0\u6570\u636E\u5230\u8868\u683C\u4E2D":"\u8BF7\u5148\u6DFB\u52A0\u6570\u636E"})]}),xn=(e,t)=>{console.log("[findNodeById] Searching for id:",t,"in nodes:",e);for(const n of e){if(console.log("[findNodeById] Checking node:",n),n.id===t)return console.log("[findNodeById] Found node:",n),n;if(n.children){const r=Array.isArray(n.children)?n.children:Object.values(n.children);console.log("[findNodeById] Searching in children:",r);const o=xn(r,t);if(o)return console.log("[findNodeById] Found in children:",o),o}}return console.log("[findNodeById] Node not found for id:",t),null},Za=e=>{for(const t of e){if(t.type)return t.id;if(t.children){const n=Array.isArray(t.children)?t.children:Object.values(t.children),r=Za(n);if(r)return r}}},Pm=e=>{const t=n=>{let r=[];return n.children&&(r=Array.isArray(n.children)?n.children:Object.values(n.children)),{title:n.label,key:n.id,children:r.length>0?r.map(t):void 0,selectable:!0}};return e.map(t)},Fm=(e,t)=>Array.isArray(e)?t==="table"?e.filter(n=>n&&n.data&&Array.isArray(n.data)):e:e&&typeof e=="object"?[e]:[],Rm=e=>{const t=new Set;return e.forEach(n=>{n.adding&&t.add(n.id)}),t},Bm=(e,t)=>{const[n,r]=vt(()=>{const g=Array.isArray(e)?e:[];return console.log("[useAppState] \u521D\u59CB\u5316innerData:",g),g}),[o,i]=vt(new Set),[a,s]=vt(new Set),[l,c]=vt(""),[u,d]=vt([]);wt(()=>{if(console.log("[useAppState] \u6570\u636E\u6E90\u53D8\u5316:",{dataSource:e,activeNodeType:t}),t==="form"){const f=Array.isArray(e)?e:[];r(f);return}const g=Fm(e,t);console.log("[useAppState] \u9A8C\u8BC1\u540E\u7684\u6570\u636E:",g),r(g);const v=Rm(g);s(v),d([])},[e,t]);const m=Xe(()=>{d([]),c(""),i(new Set)},[]);return{innerData:n,setInnerData:r,pendingIds:o,setPendingIds:i,addingIds:a,setAddingIds:s,fuzzyValue:l,setFuzzyValue:c,selectedIds:u,setSelectedIds:d,resetStateOnNodeChange:m}},jm=(e,t,n,r,o,i,a)=>{const s=Xe((S,M)=>{const{tableId:P,...O}=M||{};M!=null&&M.animate?(r(S.id),e(N=>{if(P)return N.map(R=>{if(R.id===P){const T=[...R.children||[],{...S,adding:!0}];return{...R,children:T}}return R});const F={...S,adding:!0};if((O==null?void 0:O.position)==="start"||(O==null?void 0:O.position)===void 0)return[F,...N];if(typeof(O==null?void 0:O.position)=="number"){const R=[...N];return R.splice(O.position,0,F),R}return[F,...N]})):e(N=>{if(P)return N.map(F=>{if(F.id===P){const R=[...F.children||[],S];return{...F,children:R}}return F});if((O==null?void 0:O.position)==="start")return[S,...N];if(typeof(O==null?void 0:O.position)=="number"){const F=[...N];return F.splice(O.position,0,S),F}return[...N,S]})},[e,r]),l=Xe((S,M)=>{S&&e(P=>{if(!Array.isArray(P))return console.warn("[useAppFunctions] removeItem: prev\u4E0D\u662F\u6570\u7EC4\uFF0C\u91CD\u7F6E\u4E3A\u7A7A\u6570\u7EC4"),[];if(M)return P.map(N=>{if(N.id===M&&N.children){const F=N.children.map(R=>R.id===S?{...R,removing:!0}:R);return{...N,children:F}}return N});const O=P.map(N=>N.id===S?{...N,removing:!0}:N);return console.log("[useAppFunctions] removeItem \u8BBE\u7F6Eremoving",S,O),O})},[e]),c=Xe((S,M)=>{e(P=>Array.isArray(P)?P.map(O=>{if(O.id===M&&O.children){const N=O.children.filter(F=>F.id!==S);if(N.length===0){const{children:F,...R}=O;return R}return{...O,children:N}}return O}):[])},[e]),u=Xe((S,M)=>{!S||S.length===0||e(P=>{if(!Array.isArray(P))return console.warn("[useAppFunctions] removeItems: prev\u4E0D\u662F\u6570\u7EC4\uFF0C\u91CD\u7F6E\u4E3A\u7A7A\u6570\u7EC4"),[];if(M)return P.map(N=>{if(N.id===M&&N.children){const F=N.children.map(R=>S.includes(R.id)?{...R,removing:!0}:R);return{...N,children:F}}return N});const O=P.map(N=>S.includes(N.id)?{...N,removing:!0}:N);return console.log("[useAppFunctions] removeItems \u8BBE\u7F6Eremoving",S,O),O})},[e]),d=Xe(S=>{e(M=>{const P=M.find(O=>O.id===S);return P?P.hasOwnProperty("children")?(console.error(`[addSubTable] \u884C ${S} \u5DF2\u7ECF\u6709\u5B50table\u529F\u80FD\uFF0C\u65E0\u9700\u91CD\u590D\u6DFB\u52A0`),M):M.map(O=>O.id===S?{...O,children:[]}:O):(console.error(`[addSubTable] \u672A\u627E\u5230ID\u4E3A ${S} \u7684\u884C`),M)})},[e]),m=Xe(S=>{e(M=>{const P=M.find(N=>N.id===S);if(!P)return console.error(`[deleteSubTable] \u672A\u627E\u5230ID\u4E3A ${S} \u7684\u884C`),M;if(!P.hasOwnProperty("children"))return console.error(`[deleteSubTable] \u884C ${S} \u6CA1\u6709\u5B50table\u529F\u80FD`),M;const O=(P.children||[]).filter(N=>!N.removing).length;return O>0?(console.error(`[deleteSubTable] \u884C ${S} \u7684\u5B50table\u8FD8\u6709 ${O} \u6761\u6570\u636E\uFF0C\u65E0\u6CD5\u5220\u9664\u5B50table\u529F\u80FD\u3002\u8BF7\u5148\u5220\u9664\u6240\u6709\u5B50table\u6570\u636E\u3002`),M):M.map(N=>{if(N.id===S&&N.hasOwnProperty("children")){const{children:F,...R}=N;return R}return N})})},[e]),g=Xe((S,M,P)=>{M&&e(O=>O.map(N=>P&&N.id===P&&N.children?{...N,children:N.children.map(F=>F.id===M&&typeof F=="object"?v(F,S):F)}:N.id===M&&typeof N=="object"?v(N,S):N))},[e]),v=Xe((S,M)=>{if(Array.isArray(M)){const P=[...S.data];return M.forEach(O=>{const N=P.findIndex(F=>F.columnId===O.columnId);N>=0?P[N]={...P[N],value:O.value}:P.push(O)}),{...S,data:P}}else if(typeof M=="object")return{...S,...M};return S},[]),f=Xe(S=>{if(!S)return;const M=document.querySelector(`[data-item-id="${S}"]`);M&&M.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})},[]),h=Xe((S,M)=>{e(M?P=>P.map(O=>{if(O.id!==M)return O;if(!O.hasOwnProperty("children"))return console.warn(`[useAppFunctions] \u884C ${M} \u6CA1\u6709children\u5B57\u6BB5\uFF0C\u8DF3\u8FC7\u66F4\u65B0`),O;const N=O.children||[],F=N.findIndex(R=>R.id===S.id);if(F>=0){const R=[...N];return R[F]=S,{...O,children:R}}else return{...O,children:[...N,S]}}):Array.isArray(S)?S:[])},[e]);Xe(S=>{e(M=>Array.isArray(M)?Array.isArray(S)?[...M,...S]:M:Array.isArray(S)?S:[])},[e]);const y=Xe(S=>{t(S)},[t]),x=Xe(S=>{e(M=>M.map(P=>P.id===S?{...P,tableLoading:!0}:P))},[e]),b=Xe(S=>{e(M=>M.map(P=>P.id===S?{...P,tableLoading:!1}:P))},[e]),E=Xe(S=>{n(S)},[n]),w=Xe(S=>i.has(S),[i]),k=Xe(S=>{r(S)},[r]),A=Xe(S=>{o(S)},[o]),C=Xe(S=>a.has(S),[a]);return{addItem:s,removeItem:l,removeItems:u,updateItem:g,scrollToItem:f,syncSourceData:h,addPending:y,removePending:E,isPending:w,addAdding:k,removeAdding:A,isAdding:C,tablePending:x,removeTablePending:b,addSubTable:d,deleteSubTable:m,removeSubTableRow:c}};/**
|
|
2
2
|
* @license lucide-react v0.456.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|